Translation update done using Pootle.
[phpmyadmin-themes.git] / user_password.php
blobcd84b790a1556c2081512d20316228c8b683522a
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 * @uses $GLOBALS['js_include']
8 * @uses $cfg['ShowChgPassword']
9 * @uses $cfg['Server']['auth_type']
10 * @uses PMA_DBI_select_db()
11 * @uses PMA_DBI_try_query()
12 * @uses PMA_DBI_getError()
13 * @uses PMA_sanitize()
14 * @uses PMA_generate_common_url()
15 * @uses PMA_isValid()
16 * @uses PMA_mysqlDie()
17 * @uses $GLOBALS['PMA_Config']->setCookie()
18 * @uses PMA_blowfish_encrypt()
19 * @uses PMA_showMessage()
20 * @uses define()
21 * @package phpMyAdmin
24 /**
25 * no need for variables importing
26 * @ignore
28 if (! defined('PMA_NO_VARIABLES_IMPORT')) {
29 define('PMA_NO_VARIABLES_IMPORT', true);
32 /**
33 * Gets some core libraries
35 require_once './libraries/common.inc.php';
37 $GLOBALS['js_include'][] = 'server_privileges.js';
38 $GLOBALS['js_include'][] = 'password_generation.js';
40 /**
41 * Displays an error message and exits if the user isn't allowed to use this
42 * script
44 if (!$cfg['ShowChgPassword']) {
45 $cfg['ShowChgPassword'] = PMA_DBI_select_db('mysql');
47 if ($cfg['Server']['auth_type'] == 'config' || !$cfg['ShowChgPassword']) {
48 require_once './libraries/header.inc.php';
49 PMA_Message::error(__('You don\'t have sufficient privileges to be here right now!'))->display();
50 require './libraries/footer.inc.php';
51 } // end if
54 /**
55 * If the "change password" form has been submitted, checks for valid values
56 * and submit the query or logout
58 if (isset($_REQUEST['nopass'])) {
59 // similar logic in server_privileges.php
60 $_error = false;
62 if ($_REQUEST['nopass'] == '1') {
63 $password = '';
64 } elseif (empty($_REQUEST['pma_pw']) || empty($_REQUEST['pma_pw2'])) {
65 $message = PMA_Message::error(__('The password is empty!'));
66 $_error = true;
67 } elseif ($_REQUEST['pma_pw'] != $_REQUEST['pma_pw2']) {
68 $message = PMA_Message::error(__('The passwords aren\'t the same!'));
69 $_error = true;
70 } else {
71 $password = $_REQUEST['pma_pw'];
74 if (! $_error) {
76 // Defines the url to return to in case of error in the sql statement
77 $_url_params = array();
79 $err_url = 'user_password.php' . PMA_generate_common_url($_url_params);
80 if (PMA_isValid($_REQUEST['pw_hash'], 'identical', 'old')) {
81 $hashing_function = 'OLD_PASSWORD';
82 } else {
83 $hashing_function = 'PASSWORD';
86 $sql_query = 'SET password = ' . (($password == '') ? '\'\'' : $hashing_function . '(\'***\')');
87 $local_query = 'SET password = ' . (($password == '') ? '\'\'' : $hashing_function . '(\'' . PMA_sqlAddslashes($password) . '\')');
88 $result = @PMA_DBI_try_query($local_query)
89 or PMA_mysqlDie(PMA_DBI_getError(), $sql_query, false, $err_url);
91 // Changes password cookie if required
92 // Duration = till the browser is closed for password (we don't want this to be saved)
93 if ($cfg['Server']['auth_type'] == 'cookie') {
94 $GLOBALS['PMA_Config']->setCookie('pmaPass-' . $server,
95 PMA_blowfish_encrypt($password, $GLOBALS['cfg']['blowfish_secret']));
96 } // end if
98 // For http auth. mode, the "back" link will also enforce new
99 // authentication
100 if ($cfg['Server']['auth_type'] == 'http') {
101 $_url_params['old_usr'] = 'relog';
104 // Displays the page
105 require_once './libraries/header.inc.php';
106 echo '<h1>' . __('Change password') . '</h1>' . "\n\n";
107 PMA_showMessage(__('The profile has been updated.'), $sql_query, 'success');
109 <a href="index.php<?php echo PMA_generate_common_url($_url_params); ?>" target="_parent">
110 <strong><?php echo __('Back'); ?></strong></a>
111 <?php
112 require './libraries/footer.inc.php';
113 } // end if
114 } // end if
118 * If the "change password" form hasn't been submitted or the values submitted
119 * aren't valid -> displays the form
121 // Loads the headers
122 require_once './libraries/header.inc.php';
124 echo '<h1>' . __('Change password') . '</h1>' . "\n\n";
126 // Displays an error message if required
127 if (isset($message)) {
128 $message->display();
131 require_once './libraries/display_change_password.lib.php';
134 * Displays the footer
136 require './libraries/footer.inc.php';