2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * displays and handles the form where the user can change his password
11 * no need for variables importing
14 if (! defined('PMA_NO_VARIABLES_IMPORT')) {
15 define('PMA_NO_VARIABLES_IMPORT', true);
19 * Gets some core libraries
21 require_once './libraries/common.inc.php';
23 $GLOBALS['js_include'][] = 'server_privileges.js';
26 * Displays an error message and exits if the user isn't allowed to use this
29 if (!$cfg['ShowChgPassword']) {
30 $cfg['ShowChgPassword'] = PMA_DBI_select_db('mysql');
32 if ($cfg['Server']['auth_type'] == 'config' ||
!$cfg['ShowChgPassword']) {
33 require_once './libraries/header.inc.php';
34 PMA_Message
::error(__('You don\'t have sufficient privileges to be here right now!'))->display();
35 require './libraries/footer.inc.php';
40 * If the "change password" form has been submitted, checks for valid values
41 * and submit the query or logout
43 if (isset($_REQUEST['nopass'])) {
44 // similar logic in server_privileges.php
47 if ($_REQUEST['nopass'] == '1') {
49 } elseif (empty($_REQUEST['pma_pw']) ||
empty($_REQUEST['pma_pw2'])) {
50 $message = PMA_Message
::error(__('The password is empty!'));
52 } elseif ($_REQUEST['pma_pw'] != $_REQUEST['pma_pw2']) {
53 $message = PMA_Message
::error(__('The passwords aren\'t the same!'));
56 $password = $_REQUEST['pma_pw'];
59 if($GLOBALS['is_ajax_request'] == true && $_error == true) {
61 * If in an Ajax request, we don't need to show the rest of the page
63 PMA_ajaxResponse($message, false);
68 // Defines the url to return to in case of error in the sql statement
69 $_url_params = array();
71 $err_url = 'user_password.php' . PMA_generate_common_url($_url_params);
72 if (PMA_isValid($_REQUEST['pw_hash'], 'identical', 'old')) {
73 $hashing_function = 'OLD_PASSWORD';
75 $hashing_function = 'PASSWORD';
78 $sql_query = 'SET password = ' . (($password == '') ?
'\'\'' : $hashing_function . '(\'***\')');
79 $local_query = 'SET password = ' . (($password == '') ?
'\'\'' : $hashing_function . '(\'' . PMA_sqlAddSlashes($password) . '\')');
80 $result = @PMA_DBI_try_query
($local_query)
81 or PMA_mysqlDie(PMA_DBI_getError(), $sql_query, false, $err_url);
83 // Changes password cookie if required
84 // Duration = till the browser is closed for password (we don't want this to be saved)
85 if ($cfg['Server']['auth_type'] == 'cookie') {
86 $GLOBALS['PMA_Config']->setCookie('pmaPass-' . $server,
87 PMA_blowfish_encrypt($password, $GLOBALS['cfg']['blowfish_secret']));
90 // For http auth. mode, the "back" link will also enforce new
92 if ($cfg['Server']['auth_type'] == 'http') {
93 $_url_params['old_usr'] = 'relog';
96 $message = PMA_Message
::success(__('The profile has been updated.'));
98 if($GLOBALS['is_ajax_request'] == true) {
99 $extra_data['sql_query'] = PMA_showMessage($message, $sql_query, 'success');
100 PMA_ajaxResponse($message, true, $extra_data);
104 require_once './libraries/header.inc.php';
105 echo '<h1>' . __('Change password') . '</h1>' . "\n\n";
106 PMA_showMessage($message, $sql_query, 'success');
108 <a href
="index.php<?php echo PMA_generate_common_url($_url_params); ?>" target
="_parent">
109 <strong
><?php
echo __('Back'); ?
></strong
></a
>
111 require './libraries/footer.inc.php';
117 * If the "change password" form hasn't been submitted or the values submitted
118 * aren't valid -> displays the form
121 require_once './libraries/header.inc.php';
123 echo '<h1>' . __('Change password') . '</h1>' . "\n\n";
125 // Displays an error message if required
126 if (isset($message)) {
130 require_once './libraries/display_change_password.lib.php';
133 * Displays the footer
135 require './libraries/footer.inc.php';