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
33 // similar logic in server_privileges.php
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;
45 // here $nopass could be == 1
46 if (empty($error_msg)) {
48 // Defines the url to return to in case of error in the sql statement
49 $common_url_query = PMA_generate_common_url();
51 $err_url = 'user_password.php?' . $common_url_query;
52 $hashing_function = (PMA_MYSQL_INT_VERSION
>= 40102 && !empty($pw_hash) && $pw_hash == 'old' ?
'OLD_' : '')
55 $sql_query = 'SET password = ' . (($pma_pw == '') ?
'\'\'' : $hashing_function . '(\'' . preg_replace('@.@s', '*', $pma_pw) . '\')');
56 $local_query = 'SET password = ' . (($pma_pw == '') ?
'\'\'' : $hashing_function . '(\'' . PMA_sqlAddslashes($pma_pw) . '\')');
57 $result = @PMA_DBI_try_query
($local_query) or PMA_mysqlDie(PMA_DBI_getError(), $sql_query, FALSE, $err_url);
59 // Changes password cookie if required
60 // Duration = till the browser is closed for password (we don't want this to be saved)
61 if ($cfg['Server']['auth_type'] == 'cookie') {
63 PMA_setCookie('pmaPass-' . $server, PMA_blowfish_encrypt($pma_pw, $GLOBALS['cfg']['blowfish_secret']));
66 // For http auth. mode, the "back" link will also enforce new
68 $http_logout = ($cfg['Server']['auth_type'] == 'http')
69 ?
'&old_usr=relog'
73 require_once './libraries/header.inc.php';
74 echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
76 PMA_showMessage($strUpdateProfileMessage);
78 <a href
="index.php?<?php echo $common_url_query . $http_logout; ?>" target
="_parent">
79 <b
><?php
echo $strBack; ?
></b
></a
>
87 * If the "change password" form hasn't been submitted or the values submitted
88 * aren't valid -> displays the form
91 $js_to_run = 'user_password.js';
92 require_once './libraries/header.inc.php';
93 echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
95 // Displays an error message if required
96 if (!empty($error_msg)) {
97 echo '<p><b>' . $strError . ': ' . $error_msg . '</b></p>' . "\n";
100 require_once './libraries/display_change_password.lib.php';
103 * Displays the footer
105 require_once './libraries/footer.inc.php';