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