bug #1258956, typo
[phpmyadmin/crack.git] / user_password.php
blobf656f3547c65132f15a25dedefd1ae029a71835f
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 /**
7 * Gets some core libraries
8 */
9 require_once('./libraries/grab_globals.lib.php');
10 require_once('./libraries/common.lib.php');
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_DBI_select_db('mysql');
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>&nbsp;&nbsp;&nbsp;&nbsp;' . $strNoRights . '</p>' . "\n";
23 require_once('./footer.inc.php');
24 } // end if
27 /**
28 * If the "change password" form has been submitted, checks for valid values
29 * and submit the query or logout
31 if (isset($nopass)) {
32 $error_msg = '';
34 if ($nopass == 0 && isset($pma_pw) && isset($pma_pw2)) {
35 if ($pma_pw != $pma_pw2) {
36 $error_msg = $strPasswordNotSame;
38 if (empty($pma_pw) || empty($pma_pw2)) {
39 $error_msg = $strPasswordEmpty;
41 } // end if
43 // here $nopass could be == 1
44 if (empty($error_msg)) {
46 // Defines the url to return to in case of error in the sql statement
47 $common_url_query = PMA_generate_common_url();
49 $err_url = 'user_password.php?' . $common_url_query;
50 $hashing_function = (PMA_MYSQL_INT_VERSION >= 40102 && !empty($pw_hash) && $pw_hash == 'old' ? 'OLD_' : '')
51 . 'PASSWORD';
53 $sql_query = 'SET password = ' . (($pma_pw == '') ? '\'\'' : $hashing_function . '(\'' . preg_replace('@.@s', '*', $pma_pw) . '\')');
54 $local_query = 'SET password = ' . (($pma_pw == '') ? '\'\'' : $hashing_function . '(\'' . PMA_sqlAddslashes($pma_pw) . '\')');
55 $result = @PMA_DBI_try_query($local_query) or PMA_mysqlDie(PMA_DBI_getError(), $sql_query, FALSE, $err_url);
57 // Changes password cookie if required
58 // Duration = till the browser is closed for password (we don't want this to be saved)
59 if ($cfg['Server']['auth_type'] == 'cookie') {
61 setcookie('pma_cookie_password-' . $server,
62 PMA_blowfish_encrypt($pma_pw,
63 $GLOBALS['cfg']['blowfish_secret'] . $GLOBALS['current_time']),
65 $GLOBALS['cookie_path'], '',
66 $GLOBALS['is_https']);
68 } // end if
69 // For http auth. mode, the "back" link will also enforce new
70 // authentication
71 $http_logout = ($cfg['Server']['auth_type'] == 'http')
72 ? '&amp;old_usr=relog'
73 : '';
75 // Displays the page
76 require_once('./header.inc.php');
77 echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
78 $show_query = 'y';
79 PMA_showMessage($strUpdateProfileMessage);
81 <a href="index.php?<?php echo $common_url_query . $http_logout; ?>" target="_parent">
82 <b><?php echo $strBack; ?></b></a>
83 <?php
84 exit();
85 } // end if
86 } // end if
89 /**
90 * If the "change password" form hasn't been submitted or the values submitted
91 * aren't valid -> displays the form
93 // Loads the headers
94 $js_to_run = 'user_password.js';
95 require_once('./header.inc.php');
96 echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
98 // Displays an error message if required
99 if (!empty($error_msg)) {
100 echo '<p><b>' . $strError . ':&nbsp;' . $error_msg . '</b></p>' . "\n";
103 // loic1: autocomplete feature of IE kills the "onchange" event handler and it
104 // must be replaced by the "onpropertychange" one in this case
105 $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5)
106 ? 'onpropertychange'
107 : 'onchange';
109 // Displays the form
111 <form method="post" action="./user_password.php" name="chgPassword" onsubmit="return checkPassword(this)">
112 <?php echo PMA_generate_common_hidden_inputs(); ?>
113 <table border="0">
114 <tr>
115 <td colspan="2">
116 <input type="radio" name="nopass" value="1" onclick="pma_pw.value = ''; pma_pw2.value = ''; this.checked = true" />
117 <?php echo $GLOBALS['strNoPassword'] . "\n"; ?>
118 </td>
119 </tr>
120 <tr>
121 <td>
122 <input type="radio" name="nopass" value="0" checked="checked " />
123 <?php echo $GLOBALS['strPassword']; ?>:&nbsp;
124 </td>
125 <td>
126 <input type="password" name="pma_pw" size="10" class="textfield" <?php echo $chg_evt_handler; ?>="nopass[1].checked = true" />
127 &nbsp;&nbsp;
128 <?php echo $GLOBALS['strReType']; ?>:&nbsp;
129 <input type="password" name="pma_pw2" size="10" class="textfield" <?php echo $chg_evt_handler; ?>="nopass[1].checked = true" />
130 </td>
131 </tr>
132 <?php
134 if (PMA_MYSQL_INT_VERSION >= 40102) {
136 <tr>
137 <td>
138 <?php echo $strPasswordHashing; ?>:
139 </td>
140 <td>
141 <input type="radio" name="pw_hash" id="radio_pw_hash_new" value="new" checked="checked" />
142 <label for="radio_pw_hash_new">
143 MySQL&nbsp;4.1
144 </label>
145 </td>
146 </tr>
147 <tr>
148 <td>&nbsp;</td>
149 <td>
150 <input type="radio" name="pw_hash" id="radio_pw_hash_old" value="old" />
151 <label for="radio_pw_hash_old">
152 <?php echo $strCompatibleHashing; ?>
153 </label>
154 </td>
155 </tr>
156 <?php
160 <tr>
161 <td colspan="2">&nbsp;</td>
162 </tr>
163 <tr>
164 <td colspan="2">
165 <input type="submit" value="<?php echo($strChange); ?>" />
166 </td>
167 </tr>
168 </table>
169 </form>
171 <?php
173 * Displays the footer
175 require_once('./footer.inc.php');