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

  1. <?php
  2. /* $Id: user_password.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.  * Gets some core libraries
  8.  */
  9. require_once('./libraries/grab_globals.lib.php');
  10. require_once('./libraries/common.lib.php');
  11.  
  12. /**
  13.  * Displays an error message and exits if the user isn't allowed to use this
  14.  * script
  15.  */
  16. if (!$cfg['ShowChgPassword']) {
  17.     $cfg['ShowChgPassword'] = @PMA_mysql_query('USE mysql', $userlink);
  18. }
  19. if ($cfg['Server']['auth_type'] == 'config' || !$cfg['ShowChgPassword']) {
  20.     require_once('./header.inc.php');
  21.     echo '<p><b>' . $strError . '</b></p>' . "\n"
  22.        . '<p>    ' .  $strNoRights . '</p>' . "\n";
  23.     require_once('./footer.inc.php');
  24. } // end if
  25.  
  26.  
  27. /**
  28.  * If the "change password" form has been submitted, checks for valid values
  29.  * and submit the query or logout
  30.  */
  31. if (isset($nopass)) {
  32.     $error_msg = '';
  33.  
  34.     if ($nopass == 0 && isset($pma_pw) && isset($pma_pw2)) {
  35.         if ($pma_pw != $pma_pw2) {
  36.             $error_msg = $strPasswordNotSame;
  37.         }
  38.         if (empty($pma_pw) || empty($pma_pw2)) {
  39.             $error_msg = $strPasswordEmpty;
  40.         }
  41.     } // end if
  42.  
  43.     // here $nopass could be == 1
  44.     if (empty($error_msg)) {
  45.  
  46.         // Defines the url to return to in case of error in the sql statement
  47.         $common_url_query = PMA_generate_common_url();
  48.  
  49.         $err_url          = 'user_password.php?' . $common_url_query;
  50.  
  51.         $sql_query        = 'SET password = ' . (($pma_pw == '') ? '\'\'' : 'PASSWORD(\'' . preg_replace('@.@s', '*', $pma_pw) . '\')');
  52.         $local_query      = 'SET password = ' . (($pma_pw == '') ? '\'\'' : 'PASSWORD(\'' . PMA_sqlAddslashes($pma_pw) . '\')');
  53.         $result           = @PMA_mysql_query($local_query) or PMA_mysqlDie('', '', FALSE, $err_url);
  54.  
  55.         // Changes password cookie if required
  56.         if ($cfg['Server']['auth_type'] == 'cookie') {
  57.             setcookie('pma_cookie_password', base64_encode(PMA_blowfish_encrypt($pma_pw,$GLOBALS['cfg']['blowfish_secret'])), 0, $cookie_path, '', $is_https);
  58.         } // end if
  59.         // For http auth. mode, the "back" link will also enforce new
  60.         // authentication
  61.         $http_logout = ($cfg['Server']['auth_type'] == 'http')
  62.                      ? '&old_usr=relog'
  63.                      : '';
  64.  
  65.         // Displays the page
  66.         require_once('./header.inc.php');
  67.         echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
  68.         $show_query = 'y';
  69.         PMA_showMessage($strUpdateProfileMessage);
  70.         ?>
  71.         <a href="index.php?<?php echo $common_url_query . $http_logout; ?>" target="_parent">
  72.             <b><?php echo $strBack; ?></b></a>
  73.         <?php
  74.         exit();
  75.     } // end if
  76. } // end if
  77.  
  78.  
  79. /**
  80.  * If the "change password" form hasn't been submitted or the values submitted
  81.  * aren't valid -> displays the form
  82.  */
  83. // Loads the headers
  84. $js_to_run = 'user_password.js';
  85. require_once('./header.inc.php');
  86. echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
  87.  
  88. // Displays an error message if required
  89. if (!empty($error_msg)) {
  90.     echo '<p><b>' . $strError . ' : ' . $error_msg . '</b></p>' . "\n";
  91. }
  92.  
  93. // loic1: autocomplete feature of IE kills the "onchange" event handler and it
  94. //        must be replaced by the "onpropertychange" one in this case
  95. $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5)
  96.                  ? 'onpropertychange'
  97.                  : 'onchange';
  98.  
  99. // Displays the form
  100. ?>
  101. <form method="post" action="./user_password.php" name="chgPassword" onsubmit="return checkPassword(this)">
  102.     <?php echo PMA_generate_common_hidden_inputs(); ?>
  103.     <table border="0">
  104.     <tr>
  105.         <td colspan="2">
  106.             <input type="radio" name="nopass" value="1" onclick="pma_pw.value = ''; pma_pw2.value = ''; this.checked = true" />
  107.             <?php echo $GLOBALS['strNoPassword'] . "\n"; ?>
  108.         </td>
  109.     </tr>
  110.     <tr>
  111.         <td>
  112.             <input type="radio" name="nopass" value="0" checked="checked " />
  113.             <?php echo $GLOBALS['strPassword']; ?> : 
  114.         </td>
  115.         <td>
  116.             <input type="password" name="pma_pw" size="10" class="textfield" <?php echo $chg_evt_handler; ?>="nopass[1].checked = true" />
  117.               
  118.             <?php echo $GLOBALS['strReType']; ?> : 
  119.             <input type="password" name="pma_pw2" size="10" class="textfield" <?php echo $chg_evt_handler; ?>="nopass[1].checked = true" />
  120.         </td>
  121.     </tr>
  122.     <tr>
  123.         <td colspan="2"> </td>
  124.     </tr>
  125.     <tr>
  126.         <td colspan="2">
  127.             <input type="submit" value="<?php echo($strChange); ?>" />
  128.         </td>
  129.     </tr>
  130.     </table>
  131. </form>
  132.  
  133. <?php
  134. /**
  135.  * Displays the footer
  136.  */
  137. require_once('./footer.inc.php');
  138. ?>
  139.