2 /* vim: set expandtab sw=4 ts=4 sts=4: */
9 * Gets some core libraries
11 require_once './libraries/common.inc.php';
14 * Displays an error message and exits if the user isn't allowed to use this
17 if (!$cfg['ShowChgPassword']) {
18 $cfg['ShowChgPassword'] = PMA_DBI_select_db('mysql');
20 if ($cfg['Server']['auth_type'] == 'config' ||
!$cfg['ShowChgPassword']) {
21 require_once './libraries/header.inc.php';
22 echo '<p><b>' . $strError . '</b></p>' . "\n"
23 . '<p> ' . $strNoRights . '</p>' . "\n";
24 require_once './libraries/footer.inc.php';
29 * If the "change password" form has been submitted, checks for valid values
30 * and submit the query or logout
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;
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.php?' . $common_url_query;
51 $hashing_function = (PMA_MYSQL_INT_VERSION
>= 40102 && !empty($pw_hash) && $pw_hash == 'old' ?
'OLD_' : '')
54 $sql_query = 'SET password = ' . (($pma_pw == '') ?
'\'\'' : $hashing_function . '(\'' . preg_replace('@.@s', '*', $pma_pw) . '\')');
55 $local_query = 'SET password = ' . (($pma_pw == '') ?
'\'\'' : $hashing_function . '(\'' . PMA_sqlAddslashes($pma_pw) . '\')');
56 $result = @PMA_DBI_try_query
($local_query) or PMA_mysqlDie(PMA_DBI_getError(), $sql_query, FALSE, $err_url);
58 // Changes password cookie if required
59 // Duration = till the browser is closed for password (we don't want this to be saved)
60 if ($cfg['Server']['auth_type'] == 'cookie') {
62 PMA_setCookie('pmaPass-' . $server, PMA_blowfish_encrypt($pma_pw, $GLOBALS['cfg']['blowfish_secret'] . $GLOBALS['current_time']));
65 // For http auth. mode, the "back" link will also enforce new
67 $http_logout = ($cfg['Server']['auth_type'] == 'http')
68 ?
'&old_usr=relog'
72 require_once './libraries/header.inc.php';
73 echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
75 PMA_showMessage($strUpdateProfileMessage);
77 <a href
="index.php?<?php echo $common_url_query . $http_logout; ?>" target
="_parent">
78 <b
><?php
echo $strBack; ?
></b
></a
>
86 * If the "change password" form hasn't been submitted or the values submitted
87 * aren't valid -> displays the form
90 $js_to_run = 'user_password.js';
91 require_once './libraries/header.inc.php';
92 echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
94 // Displays an error message if required
95 if (!empty($error_msg)) {
96 echo '<p><b>' . $strError . ': ' . $error_msg . '</b></p>' . "\n";
99 // loic1: autocomplete feature of IE kills the "onchange" event handler and it
100 // must be replaced by the "onpropertychange" one in this case
101 $chg_evt_handler = (PMA_USR_BROWSER_AGENT
== 'IE' && PMA_USR_BROWSER_VER
>= 5)
107 <form method
="post" action
="./user_password.php" name
="chgPassword" onsubmit
="return checkPassword(this)">
108 <?php
echo PMA_generate_common_hidden_inputs(); ?
>
112 <input type
="radio" name
="nopass" value
="1" onclick
="pma_pw.value = ''; pma_pw2.value = ''; this.checked = true" />
113 <?php
echo $GLOBALS['strNoPassword'] . "\n"; ?
>
118 <input type
="radio" name
="nopass" value
="0" checked
="checked " />
119 <?php
echo $GLOBALS['strPassword']; ?
>: 
;
122 <input type
="password" name
="pma_pw" size
="10" class="textfield" <?php
echo $chg_evt_handler; ?
>="nopass[1].checked = true" />
124 <?php
echo $GLOBALS['strReType']; ?
>: 
;
125 <input type
="password" name
="pma_pw2" size
="10" class="textfield" <?php
echo $chg_evt_handler; ?
>="nopass[1].checked = true" />
130 if (PMA_MYSQL_INT_VERSION
>= 40102) {
134 <?php
echo $strPasswordHashing; ?
>:
137 <input type
="radio" name
="pw_hash" id
="radio_pw_hash_new" value
="new" checked
="checked" />
138 <label
for="radio_pw_hash_new">
146 <input type
="radio" name
="pw_hash" id
="radio_pw_hash_old" value
="old" />
147 <label
for="radio_pw_hash_old">
148 <?php
echo $strCompatibleHashing; ?
>
157 <td colspan
="2"> 
;</td
>
161 <input type
="submit" value
="<?php echo($strChange); ?>" />
169 * Displays the footer
171 require_once './libraries/footer.inc.php';