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