home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / cookie.auth.lib.php < prev    next >
Encoding:
PHP Script  |  2003-11-26  |  21.1 KB  |  608 lines

  1. <?php
  2. /* $Id: cookie.auth.lib.php,v 2.3 2003/11/26 22:52:24 rabus Exp $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4.  
  5.  
  6. // +--------------------------------------------------------------------------+
  7. // | Set of functions used to run cookie based authentication.                |
  8. // | Thanks to Piotr Roszatycki <d3xter at users.sourceforge.net> and         |
  9. // | Dan Wilson who builds this patch for the Debian package.                 |
  10. // +--------------------------------------------------------------------------+
  11.  
  12.  
  13. if (!isset($coming_from_common)) {
  14.    exit();
  15. }
  16.  
  17. require_once('./libraries/blowfish.php');
  18.  
  19. // Gets the default font sizes
  20. PMA_setFontSizes();
  21. // Defines the cookie path and whether the server is using https or not
  22. $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
  23. $cookie_path   = substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/'));
  24. $is_https      = (isset($pma_uri_parts['scheme']) && $pma_uri_parts['scheme'] == 'https') ? 1 : 0;
  25.  
  26. /**
  27.  * String padding
  28.  *
  29.  * @param   string  input string
  30.  * @param   integer length of the result
  31.  * @param   string  the filling string
  32.  * @param   integer padding mode
  33.  *
  34.  * @return  string  the padded string
  35.  *
  36.  * @access  public
  37.  */
  38. function full_str_pad($input, $pad_length, $pad_string = '', $pad_type = 0) {
  39.     $str = '';
  40.     $length = $pad_length - strlen($input);
  41.     if ($length > 0) { // str_repeat doesn't like negatives
  42.         if ($pad_type == STR_PAD_RIGHT) { // STR_PAD_RIGHT == 1
  43.             $str = $input.str_repeat($pad_string, $length);
  44.         } elseif ($pad_type == STR_PAD_BOTH) { // STR_PAD_BOTH == 2
  45.             $str = str_repeat($pad_string, floor($length/2));
  46.             $str .= $input;
  47.             $str .= str_repeat($pad_string, ceil($length/2));
  48.         } else { // defaults to STR_PAD_LEFT == 0
  49.             $str = str_repeat($pad_string, $length).$input;
  50.         }
  51.     } else { // if $length is negative or zero we don't need to do anything
  52.         $str = $input;
  53.     }
  54.     return $str;
  55. }
  56.  
  57. /**
  58.  * Encryption using blowfish algorithm
  59.  *
  60.  * @param   string  original data
  61.  * @param   string  the secret
  62.  *
  63.  * @return  string  the encrypted result
  64.  *
  65.  * @access  public
  66.  *
  67.  * @author  lem9
  68.  */
  69. function PMA_blowfish_encrypt($data, $secret) {
  70.     $pma_cipher = new Horde_Cipher_blowfish;
  71.     $encrypt = '';
  72.     for ($i=0; $i<strlen($data); $i+=8) {
  73.         $block = substr($data, $i, 8);
  74.         if (strlen($block) < 8) {
  75.             $block = full_str_pad($block,8,"\0", 1);
  76.         }
  77.         $encrypt .= $pma_cipher->encryptBlock($block, $secret);
  78.     }
  79.     return $encrypt;
  80. }
  81.  
  82. /**
  83.  * Decryption using blowfish algorithm
  84.  *
  85.  * @param   string  encrypted data
  86.  * @param   string  the secret
  87.  *
  88.  * @return  string  original data
  89.  *
  90.  * @access  public
  91.  *
  92.  * @author  lem9
  93.  */
  94. function PMA_blowfish_decrypt($data, $secret) {
  95.     $pma_cipher = new Horde_Cipher_blowfish;
  96.     $decrypt = '';
  97.     for ($i=0; $i<strlen($data); $i+=8) {
  98.         $decrypt .= $pma_cipher->decryptBlock(substr($data, $i, 8), $secret);
  99.     }
  100.     return trim($decrypt);
  101. }
  102.  
  103. /**
  104.  * Sorts available languages by their true names
  105.  *
  106.  * @param   array   the array to be sorted
  107.  * @param   mixed   a required parameter
  108.  *
  109.  * @return  the sorted array
  110.  *
  111.  * @access  private
  112.  */
  113. function PMA_cookie_cmp(&$a, $b)
  114. {
  115.     return (strcmp($a[1], $b[1]));
  116. } // end of the 'PMA_cmp()' function
  117.  
  118.  
  119. /**
  120.  * Displays authentication form
  121.  *
  122.  * @global  string    the font face to use
  123.  * @global  string    the default font size to use
  124.  * @global  string    the big font size to use
  125.  * @global  array     the list of servers settings
  126.  * @global  array     the list of available translations
  127.  * @global  string    the current language
  128.  * @global  integer   the current server id
  129.  * @global  string    the currect charset for MySQL
  130.  * @global  array     the array of cookie variables if register_globals is
  131.  *                    off
  132.  *
  133.  * @return  boolean   always true (no return indeed)
  134.  *
  135.  * @access  public
  136.  */
  137. function PMA_auth()
  138. {
  139.     global $right_font_family, $font_size, $font_bigger;
  140.     global $cfg, $available_languages;
  141.     global $lang, $server, $convcharset;
  142.     global $conn_error;
  143.  
  144.     // Tries to get the username from cookie whatever are the values of the
  145.     // 'register_globals' and the 'variables_order' directives if last login
  146.     // should be recalled, else skip the IE autocomplete feature.
  147.     if ($cfg['LoginCookieRecall']) {
  148.         // username
  149.         if (!empty($GLOBALS['pma_cookie_username'])) {
  150.             $default_user = $GLOBALS['pma_cookie_username'];
  151.         }
  152.         else if (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_username'])) {
  153.             $default_user = $_COOKIE['pma_cookie_username'];
  154.         }
  155.  
  156.         if (isset($default_user) && get_magic_quotes_gpc()) {
  157.             $default_user = stripslashes($default_user);
  158.         }
  159.  
  160.         // server name
  161.         if (!empty($GLOBALS['pma_cookie_servername'])) {
  162.             $default_server = $GLOBALS['pma_cookie_servername'];
  163.         }
  164.         else if (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_servername'])) {
  165.             $default_server = $_COOKIE['pma_cookie_servername'];
  166.         }
  167.         if (isset($default_server) && get_magic_quotes_gpc()) {
  168.             $default_server = stripslashes($default_server);
  169.         }
  170.  
  171.         $autocomplete     = '';
  172.     }
  173.     else {
  174.         $default_user     = '';
  175.         $autocomplete     = ' autocomplete="off"';
  176.     }
  177.  
  178.     $cell_align = ($GLOBALS['text_dir'] == 'ltr') ? 'left' : 'right';
  179.  
  180.     // Defines the charset to be used
  181.     header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
  182.  
  183.     // Title
  184.     ?>
  185. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  186.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  187. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $GLOBALS['available_languages'][$GLOBALS['lang']][2]; ?>" lang="<?php echo $GLOBALS['available_languages'][$GLOBALS['lang']][2]; ?>" dir="<?php echo $GLOBALS['text_dir']; ?>">
  188.  
  189. <head>
  190. <title>phpMyAdmin <?php echo PMA_VERSION; ?></title>
  191. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $GLOBALS['charset']; ?>" />
  192. <base href="<?php echo $cfg['PmaAbsoluteUri']; ?>" />
  193. <style type="text/css">
  194. <!--
  195. body            {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
  196. td              {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
  197. h1              {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo $font_bigger; ?>; font-weight: bold}
  198. select          {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo $font_size; ?>; background-color:#ffffff; color:#000000}
  199. input.textfield {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo $font_size; ?>; background-color:#ffffff; color:#000000}
  200. .warning        {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo $font_size; ?>; font-weight: bold; color: #FF0000}
  201. //-->
  202. </style>
  203. </head>
  204.  
  205. <body bgcolor="<?php echo $cfg['RightBgColor']; ?>">
  206. <center>
  207. <a href="http://www.phpmyadmin.net" target="_blank"><img name="imLogo" id="imLogo" src="images/pma_logo.png" border="0" width="88" height="31" alt="phpMyAdmin" /></a>
  208. <h1><?php echo sprintf($GLOBALS['strWelcome'], ' phpMyAdmin ' . PMA_VERSION . ' - ' . $GLOBALS['strLogin']); ?></h1>
  209. <br />
  210.  
  211.     <?php
  212.     // Displays the languages form
  213.     if (empty($cfg['Lang'])) {
  214.         echo "\n";
  215.         ?>
  216. <!-- Language selection -->
  217. <form method="post" action="index.php">
  218.     <input type="hidden" name="server" value="<?php echo $server; ?>" />
  219.     <b>Language: </b>
  220.     <select name="lang" dir="ltr" onchange="this.form.submit();">
  221.         <?php
  222.         echo "\n";
  223.  
  224.         uasort($available_languages, 'PMA_cookie_cmp');
  225.         foreach($available_languages AS $id => $tmplang) {
  226.             $lang_name = ucfirst(substr(strstr($tmplang[0], '|'), 1));
  227.             if ($lang == $id) {
  228.                 $selected = ' selected="selected"';
  229.             } else {
  230.                 $selected = '';
  231.             }
  232.             echo '        ';
  233.             echo '<option value="' . $id . '"' . $selected . '>' . $lang_name . ' (' . $id . ')</option>' . "\n";
  234.         } // end while
  235.         ?>
  236.     </select>
  237.     <input type="submit" value="<?php echo $GLOBALS['strGo']; ?>" />
  238. </form>
  239. <br />
  240.         <?php
  241.     }
  242.     echo "\n\n";
  243.  
  244.     // Displays the warning message and the login form
  245.  
  246.     if ($GLOBALS['cfg']['blowfish_secret']=='') {
  247.     ?>
  248. <p class="warning"><?php echo $GLOBALS['strSecretRequired']; ?></p>
  249. </body>
  250. </html>
  251.     <?php
  252.     exit();
  253.     }
  254.     ?>
  255. <p><?php echo '(' . $GLOBALS['strCookiesRequired'] . ')'; ?></p>
  256. <br />
  257.  
  258.  
  259. <!-- Login form -->
  260. <form method="post" action="index.php" name="login_form"<?php echo $autocomplete; ?>>
  261.     <table cellpadding="5">
  262. <?php if ($GLOBALS['cfg']['AllowArbitraryServer']) { ?>
  263.     <tr>
  264.         <td align="<?php echo $cell_align; ?>"><b><?php echo $GLOBALS['strLogServer']; ?> </b></td>
  265.         <td align="<?php echo $cell_align; ?>">
  266.             <input type="text" name="pma_servername" value="<?php echo (isset($default_server) ? $default_server : ''); ?>" size="24" class="textfield" onfocus="this.select()" />
  267.         </td>
  268.     </tr>
  269. <?php } ?>
  270.     <tr>
  271.         <td align="<?php echo $cell_align; ?>"><b><?php echo $GLOBALS['strLogUsername']; ?> </b></td>
  272.         <td align="<?php echo $cell_align; ?>">
  273.             <input type="text" name="pma_username" value="<?php echo (isset($default_user) ? $default_user : ''); ?>" size="24" class="textfield" onfocus="this.select()" />
  274.         </td>
  275.     </tr>
  276.     <tr>
  277.         <td align="<?php echo $cell_align; ?>"><b><?php echo $GLOBALS['strLogPassword']; ?> </b></td>
  278.         <td align="<?php echo $cell_align; ?>">
  279.             <input type="password" name="pma_password" value="" size="24" class="textfield" onfocus="this.select()" />
  280.         </td>
  281.     </tr>
  282.     <?php
  283.     if (count($cfg['Servers']) > 1) {
  284.         echo "\n";
  285.         ?>
  286.     <tr>
  287.         <td align="<?php echo $cell_align; ?>"><b><?php echo $GLOBALS['strServerChoice']; ?> : </b></td>
  288.         <td align="<?php echo $cell_align; ?>">
  289.             <select name="server"
  290.             <?php
  291.             if ($GLOBALS['cfg']['AllowArbitraryServer']) {
  292.                 echo ' onchange="document.forms[\'login_form\'].elements[\'pma_servername\'].value = \'\'" ';
  293.             }
  294.             ?>
  295.             >
  296.         <?php
  297.         echo "\n";
  298.         // Displays the MySQL servers choice
  299.         foreach($cfg['Servers'] AS $key => $val) {
  300.             if (!empty($val['host']) || $val['auth_type'] == 'arbitrary') {
  301.                 echo '                <option value="' . $key . '"';
  302.                 if (!empty($server) && ($server == $key)) {
  303.                     echo ' selected="selected"';
  304.                 }
  305.                 echo '>';
  306.                 if ($val['verbose'] != '') {
  307.                     echo $val['verbose'];
  308.                 } elseif ($val['auth_type'] == 'arbitrary') {
  309.                     echo $GLOBALS['strArbitrary'];
  310.                 } else {
  311.                     echo $val['host'];
  312.                     if (!empty($val['port'])) {
  313.                         echo ':' . $val['port'];
  314.                     }
  315.                     // loic1: skip this because it's not a so good idea to
  316.                     //        display sockets used to everybody
  317.                     // if (!empty($val['socket']) && PMA_PHP_INT_VERSION >= 30010) {
  318.                     //     echo ':' . $val['socket'];
  319.                     // }
  320.                 }
  321.                 // loic1: if 'only_db' is an array and there is more than one
  322.                 //        value, displaying such informations may not be a so
  323.                 //        good idea
  324.                 if (!empty($val['only_db'])) {
  325.                     echo ' - ' . (is_array($val['only_db']) ? implode(', ', $val['only_db']) : $val['only_db']);
  326.                 }
  327.                 if (!empty($val['user']) && ($val['auth_type'] == 'basic')) {
  328.                     echo '  (' . $val['user'] . ')';
  329.                 }
  330.                 echo ' </option>' . "\n";
  331.             } // end if (!empty($val['host']))
  332.         } // end while
  333.         ?>
  334.             </select>
  335.         </td>
  336.     </tr>
  337.         <?php
  338.     } // end if (server choice)
  339.     echo "\n";
  340.     if (!empty($conn_error)) {
  341.         echo '<tr><td colspan="2" align="center"><p class="warning">'. $conn_error . '</p></td></tr>' . "\n";
  342.     }
  343.     ?>
  344.     <tr>
  345.         <td colspan="2" align="center">
  346.     <?php
  347.     if (count($cfg['Servers']) == 1) {
  348.         echo '    <input type="hidden" name="server" value="' . $server . '" />';
  349.     }
  350.     echo "\n";
  351.     ?>
  352.             <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  353.             <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
  354.             <input type="submit" value="<?php echo $GLOBALS['strLogin']; ?>" />
  355.         </td>
  356.     </tr>
  357.     </table>
  358. </form>
  359. </center>
  360.  
  361. <script type="text/javascript" language="javascript">
  362. <!--
  363. var uname = document.forms['login_form'].elements['pma_username'];
  364. var pword = document.forms['login_form'].elements['pma_password'];
  365. if (uname.value == '') {
  366.     uname.focus();
  367. } else {
  368.     pword.focus();
  369. }
  370. //-->
  371. </script>
  372. </body>
  373.  
  374. </html>
  375.     <?php
  376.     exit();
  377.  
  378.     return TRUE;
  379. } // end of the 'PMA_auth()' function
  380.  
  381.  
  382. /**
  383.  * Gets advanced authentication settings
  384.  *
  385.  * @global  string    the username if register_globals is on
  386.  * @global  string    the password if register_globals is on
  387.  * @global  array     the array of cookie variables if register_globals is
  388.  *                    off
  389.  * @global  string    the servername sent by the login form
  390.  * @global  string    the username sent by the login form
  391.  * @global  string    the password sent by the login form
  392.  * @global  string    the username of the user who logs out
  393.  * @global  boolean   whether the login/password pair is grabbed from a
  394.  *                    cookie or not
  395.  *
  396.  * @return  boolean   whether we get authentication settings or not
  397.  *
  398.  * @access  public
  399.  */
  400. function PMA_auth_check()
  401. {
  402.     global $PHP_AUTH_USER, $PHP_AUTH_PW, $pma_auth_server;
  403.     global $pma_servername, $pma_username, $pma_password, $old_usr;
  404.     global $from_cookie;
  405.  
  406.     // Initialization
  407.     $PHP_AUTH_USER = $PHP_AUTH_PW = '';
  408.     $from_cookie   = FALSE;
  409.     $from_form     = FALSE;
  410.  
  411.     // The user wants to be logged out -> delete password cookie
  412.     if (!empty($old_usr)) {
  413.         setcookie('pma_cookie_password', '', 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']);
  414.     }
  415.  
  416.     // The user just logged in
  417.     else if (!empty($pma_username)) {
  418.         $PHP_AUTH_USER = $pma_username;
  419.         $PHP_AUTH_PW   = (empty($pma_password)) ? '' : $pma_password;
  420.         if ($GLOBALS['cfg']['AllowArbitraryServer']) {
  421.             $pma_auth_server = $pma_servername;
  422.         }
  423.         $from_form     = TRUE;
  424.     }
  425.  
  426.     // At the end, try to set the $PHP_AUTH_USER & $PHP_AUTH_PW variables
  427.     // from cookies whatever are the values of the 'register_globals' and
  428.     // the 'variables_order' directives
  429.     else {
  430.         if ($GLOBALS['cfg']['AllowArbitraryServer']) {
  431.             // servername
  432.             if (!empty($pma_cookie_servername)) {
  433.                 $pma_auth_server = $pma_cookie_servername;
  434.                 $from_cookie   = TRUE;
  435.             }
  436.             else if (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_servername'])) {
  437.                 $pma_auth_server = $_COOKIE['pma_cookie_servername'];
  438.                 $from_cookie   = TRUE;
  439.             }
  440.         }
  441.         // username
  442.         if (!empty($pma_cookie_username)) {
  443.             $PHP_AUTH_USER = $pma_cookie_username;
  444.             $from_cookie   = TRUE;
  445.         }
  446.         else if (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_username'])) {
  447.             $PHP_AUTH_USER = $_COOKIE['pma_cookie_username'];
  448.             $from_cookie   = TRUE;
  449.         }
  450.         // password
  451.         if (!empty($pma_cookie_password)) {
  452.             $PHP_AUTH_PW   = $pma_cookie_password;
  453.         }
  454.         else if (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_password'])) {
  455.             $PHP_AUTH_PW   = $_COOKIE['pma_cookie_password'];
  456.         }
  457.         else {
  458.             $from_cookie   = FALSE;
  459.         }
  460.         $PHP_AUTH_PW = base64_decode($PHP_AUTH_PW);
  461.         $PHP_AUTH_PW = PMA_blowfish_decrypt($PHP_AUTH_PW,$GLOBALS['cfg']['blowfish_secret']);
  462.  
  463.         if ($PHP_AUTH_PW == "\xff(blank)") {
  464.             $PHP_AUTH_PW   = '';
  465.         }
  466.     }
  467.  
  468.     // Returns whether we get authentication settings or not
  469.     if (!$from_cookie && !$from_form) {
  470.         return FALSE;
  471.     } elseif ($from_cookie) {
  472.         if (get_magic_quotes_gpc()) {
  473.             $PHP_AUTH_USER = stripslashes($PHP_AUTH_USER);
  474.             // no need to strip password as it is encrypted during transfer
  475.         }
  476.         return TRUE;
  477.     } else {
  478.         // we don't need to strip here, it is done in grab_globals
  479.         return TRUE;
  480.     }
  481. } // end of the 'PMA_auth_check()' function
  482.  
  483.  
  484. /**
  485.  * Set the user and password after last checkings if required
  486.  *
  487.  * @global  array     the valid servers settings
  488.  * @global  integer   the id of the current server
  489.  * @global  array     the current server settings
  490.  * @global  string    the current username
  491.  * @global  string    the current password
  492.  * @global  boolean   whether the login/password pair has been grabbed from
  493.  *                    a cookie or not
  494.  *
  495.  * @return  boolean   always true
  496.  *
  497.  * @access  public
  498.  */
  499. function PMA_auth_set_user()
  500. {
  501.     global $cfg, $server;
  502.     global $PHP_AUTH_USER, $PHP_AUTH_PW, $pma_auth_server;
  503.     global $from_cookie;
  504.  
  505.     // Ensures valid authentication mode, 'only_db', bookmark database and
  506.     // table names and relation table name are used
  507.     if ($cfg['Server']['user'] != $PHP_AUTH_USER) {
  508.         $servers_cnt = count($cfg['Servers']);
  509.         for ($i = 1; $i <= $servers_cnt; $i++) {
  510.             if (isset($cfg['Servers'][$i])
  511.                 && ($cfg['Servers'][$i]['host'] == $cfg['Server']['host'] && $cfg['Servers'][$i]['user'] == $PHP_AUTH_USER)) {
  512.                 $server        = $i;
  513.                 $cfg['Server'] = $cfg['Servers'][$i];
  514.                 break;
  515.             }
  516.         } // end for
  517.     } // end if
  518.  
  519.     $pma_server_changed = FALSE;
  520.     if ($GLOBALS['cfg']['AllowArbitraryServer']
  521.             && isset($pma_auth_server) && !empty($pma_auth_server)
  522.             && ($cfg['Server']['host'] != $pma_auth_server)
  523.             ) {
  524.         $cfg['Server']['host'] = $pma_auth_server;
  525.         $pma_server_changed = TRUE;
  526.     }
  527.     $cfg['Server']['user']     = $PHP_AUTH_USER;
  528.     $cfg['Server']['password'] = $PHP_AUTH_PW;
  529.  
  530.     // Set cookies if required (once per session) and, in this case, force
  531.     // reload to ensure the client accepts cookies
  532.     if (!$from_cookie) {
  533.         if ($GLOBALS['cfg']['AllowArbitraryServer']) {
  534.             if (isset($pma_auth_server) && !empty($pma_auth_server) && $pma_server_changed) {
  535.                 // Duration = one month for serverrname
  536.                 setcookie('pma_cookie_servername',
  537.                     $cfg['Server']['host'],
  538.                     time() + (60 * 60 * 24 * 30),
  539.                     $GLOBALS['cookie_path'], '',
  540.                     $GLOBALS['is_https']);
  541.             } else {
  542.                 // Delete servername cookie
  543.                 setcookie('pma_cookie_servername', '', 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']);
  544.             }
  545.         }
  546.         // Duration = one month for username
  547.         setcookie('pma_cookie_username',
  548.             $cfg['Server']['user'],
  549.             time() + (60 * 60 * 24 * 30),
  550.             $GLOBALS['cookie_path'], '',
  551.             $GLOBALS['is_https']);
  552.  
  553.         // Duration = till the browser is closed for password
  554.         // Some binary contents are now retrieved properly when stored
  555.         // as a cookie, so we base64_encode()
  556.         setcookie('pma_cookie_password',
  557.             base64_encode(PMA_blowfish_encrypt(((!empty($cfg['Server']['password'])) ? $cfg['Server']['password'] : "\xff(blank)"), $GLOBALS['cfg']['blowfish_secret'])),
  558.             0,
  559.             $GLOBALS['cookie_path'], '',
  560.             $GLOBALS['is_https']);
  561.         // loic1: workaround against a IIS 5.0 bug
  562.         if (empty($GLOBALS['SERVER_SOFTWARE'])) {
  563.             if (isset($_SERVER) && !empty($_SERVER['SERVER_SOFTWARE'])) {
  564.                 $GLOBALS['SERVER_SOFTWARE'] = $_SERVER['SERVER_SOFTWARE'];
  565.             }
  566.         } // end if
  567.         if (!empty($GLOBALS['SERVER_SOFTWARE']) && $GLOBALS['SERVER_SOFTWARE'] == 'Microsoft-IIS/5.0') {
  568.             header('Refresh: 0; url=' . $cfg['PmaAbsoluteUri'] . 'index.php?' . PMA_generate_common_url('', '', '&'));
  569.         }
  570.         else {
  571.             header('Location: ' . $cfg['PmaAbsoluteUri'] . 'index.php?' . PMA_generate_common_url('', '', '&'));
  572.         }
  573.         exit();
  574.     } // end if
  575.  
  576.     return TRUE;
  577. } // end of the 'PMA_auth_set_user()' function
  578.  
  579.  
  580. /**
  581.  * User is not allowed to login to MySQL -> authentication failed
  582.  *
  583.  * @return  boolean   always true (no return indeed)
  584.  *
  585.  * @access  public
  586.  */
  587. function PMA_auth_fails()
  588. {
  589. global $conn_error;
  590.  
  591.     // Deletes password cookie and displays the login form
  592.     setcookie('pma_cookie_password', base64_encode(''), 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']);
  593.  
  594.     if (PMA_mysql_error()) {
  595.         $conn_error = PMA_mysql_error();
  596.     } else if (isset($php_errormsg)) {
  597.         $conn_error = $php_errormsg;
  598.     } else {
  599.         $conn_error = $GLOBALS['strCannotLogin'];
  600.     }
  601.  
  602.     PMA_auth();
  603.  
  604.     return TRUE;
  605. } // end of the 'PMA_auth_fails()' function
  606.  
  607. ?>
  608.