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