Translation update done using Pootle.
[phpmyadmin/madhuracj.git] / user_password.php
blobc4fdaabaa8d7b27e7e1a7576703b80fb9d43266c
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * displays and handles the form where the user can change his password
5 * linked from main.php
7 * @package PhpMyAdmin
8 */
10 /**
11 * no need for variables importing
12 * @ignore
14 if (! defined('PMA_NO_VARIABLES_IMPORT')) {
15 define('PMA_NO_VARIABLES_IMPORT', true);
18 /**
19 * Gets some core libraries
21 require_once './libraries/common.inc.php';
23 $GLOBALS['js_include'][] = 'server_privileges.js';
25 /**
26 * Displays an error message and exits if the user isn't allowed to use this
27 * script
29 if (!$cfg['ShowChgPassword']) {
30 $cfg['ShowChgPassword'] = PMA_DBI_select_db('mysql');
32 if ($cfg['Server']['auth_type'] == 'config' || !$cfg['ShowChgPassword']) {
33 include_once './libraries/header.inc.php';
34 PMA_Message::error(__('You don\'t have sufficient privileges to be here right now!'))->display();
35 include './libraries/footer.inc.php';
36 } // end if
39 /**
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
45 $_error = false;
47 if ($_REQUEST['nopass'] == '1') {
48 $password = '';
49 } elseif (empty($_REQUEST['pma_pw']) || empty($_REQUEST['pma_pw2'])) {
50 $message = PMA_Message::error(__('The password is empty!'));
51 $_error = true;
52 } elseif ($_REQUEST['pma_pw'] != $_REQUEST['pma_pw2']) {
53 $message = PMA_Message::error(__('The passwords aren\'t the same!'));
54 $_error = true;
55 } else {
56 $password = $_REQUEST['pma_pw'];
59 if ($GLOBALS['is_ajax_request'] == true && $_error == true) {
60 /**
61 * If in an Ajax request, we don't need to show the rest of the page
63 PMA_ajaxResponse($message, false);
66 if (! $_error) {
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';
74 } else {
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']));
88 } // end if
90 // For http auth. mode, the "back" link will also enforce new
91 // authentication
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);
103 // Displays the page
104 include_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>
110 <?php
111 include './libraries/footer.inc.php';
112 } // end if
113 } // end if
117 * If the "change password" form hasn't been submitted or the values submitted
118 * aren't valid -> displays the form
120 // Loads the headers
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)) {
127 $message->display();
130 require_once './libraries/display_change_password.lib.php';
133 * Displays the footer
135 require './libraries/footer.inc.php';