update
[phpmyadmin/crack.git] / user_password.php3
blob6f7c22d1f21b66bc36724b29cad718305ace88bc
1 <?php
2 /* $Id$ */
5 /**
6 * Gets some core libraries
7 */
8 require('./libraries/grab_globals.lib.php3');
9 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 if (get_magic_quotes_gpc() && $pma_pw != '') {
48 $pma_pw = stripslashes($pma_pw);
51 // Defines the url to return to in case of error in the sql statement
52 $common_url_query = 'lang=' . $lang
53 . '&amp;convcharset=' . $convcharset
54 . '&amp;server=' . $server;
56 $err_url = 'user_password.php3?' . $common_url_query;
58 $sql_query = 'SET password = ' . (($pma_pw == '') ? '\'\'' : 'PASSWORD(\'' . ereg_replace('.', '*', $pma_pw) . '\')');
59 $local_query = 'SET password = ' . (($pma_pw == '') ? '\'\'' : 'PASSWORD(\'' . PMA_sqlAddslashes($pma_pw) . '\')');
60 $result = @PMA_mysql_query($local_query) or PMA_mysqlDie('', '', FALSE, $err_url);
62 // Changes password cookie if required
63 if ($cfg['Server']['auth_type'] == 'cookie') {
64 setcookie('pma_cookie_password', $pma_pw, 0, $cookie_path, '', $is_https);
65 } // end if
66 // For http auth. mode, the "back" link will also enforce new
67 // authentication
68 $http_logout = ($cfg['Server']['auth_type'] == 'http')
69 ? '&amp;old_usr=relog'
70 : '';
72 // Displays the page
73 include('./header.inc.php3');
74 echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
75 $show_query = 'y';
76 PMA_showMessage(get_magic_quotes_gpc() ? addslashes($strUpdateProfileMessage) : $strUpdateProfileMessage);
78 <a href="index.php3?<?php echo $common_url_query . $http_logout; ?>" target="_parent">
79 <b><?php echo $strBack; ?></b></a>
80 <?php
81 exit();
82 } // end if
83 } // end if
86 /**
87 * If the "change password" form hasn't been submitted or the values submitted
88 * aren't valid -> displays the form
90 // Loads the headers
91 $js_to_run = 'user_details.js';
92 require('./header.inc.php3');
93 echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
95 // Displays an error message if required
96 if (!empty($error_msg)) {
97 echo '<p><b>' . $strError . '&nbsp;:&nbsp;' . $error_msg . '</b></p>' . "\n";
100 // loic1: autocomplete feature of IE kills the "onchange" event handler and it
101 // must be replaced by the "onpropertychange" one in this case
102 $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5)
103 ? 'onpropertychange'
104 : 'onchange';
106 // Displays the form
108 <form method="post" action="./user_password.php3" name="chgPassword" onsubmit="return checkPassword(this)">
109 <table border="0">
110 <tr>
111 <td colspan="2">
112 <input type="radio" name="nopass" value="1" onclick="pma_pw.value = ''; pma_pw2.value = ''; this.checked = true" />
113 <?php echo $GLOBALS['strNoPassword'] . "\n"; ?>
114 </td>
115 </tr>
116 <tr>
117 <td>
118 <input type="radio" name="nopass" value="0" checked="checked " />
119 <?php echo $GLOBALS['strPassword']; ?>&nbsp;:&nbsp;
120 </td>
121 <td>
122 <input type="password" name="pma_pw" size="10" class="textfield" <?php echo $chg_evt_handler; ?>="nopass[1].checked = true" />
123 &nbsp;&nbsp;
124 <?php echo $GLOBALS['strReType']; ?>&nbsp;:&nbsp;
125 <input type="password" name="pma_pw2" size="10" class="textfield" <?php echo $chg_evt_handler; ?>="nopass[1].checked = true" />
126 </td>
127 </tr>
128 <tr>
129 <td colspan="2">&nbsp;</td>
130 </tr>
131 <tr>
132 <td colspan="2">
133 <input type="submit" value="<?php echo($strChange); ?>" />
134 </td>
135 </tr>
136 </table>
137 </form>
139 <?php
141 * Displays the footer
143 echo "\n";
144 require('./footer.inc.php3');