unused variable
[phpmyadmin/crack.git] / user_password.php
blob58f9cfcc75076513299650d0e681637ead2d4a42
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($GLOBALS['is_ajax_request'] == true && $_error == true) {
75 /**
76 * If in an Ajax request, we don't need to show the rest of the page
78 PMA_ajaxResponse($message, false);
81 if (! $_error) {
83 // Defines the url to return to in case of error in the sql statement
84 $_url_params = array();
86 $err_url = 'user_password.php' . PMA_generate_common_url($_url_params);
87 if (PMA_isValid($_REQUEST['pw_hash'], 'identical', 'old')) {
88 $hashing_function = 'OLD_PASSWORD';
89 } else {
90 $hashing_function = 'PASSWORD';
93 $sql_query = 'SET password = ' . (($password == '') ? '\'\'' : $hashing_function . '(\'***\')');
94 $local_query = 'SET password = ' . (($password == '') ? '\'\'' : $hashing_function . '(\'' . PMA_sqlAddslashes($password) . '\')');
95 $result = @PMA_DBI_try_query($local_query)
96 or PMA_mysqlDie(PMA_DBI_getError(), $sql_query, false, $err_url);
98 // Changes password cookie if required
99 // Duration = till the browser is closed for password (we don't want this to be saved)
100 if ($cfg['Server']['auth_type'] == 'cookie') {
101 $GLOBALS['PMA_Config']->setCookie('pmaPass-' . $server,
102 PMA_blowfish_encrypt($password, $GLOBALS['cfg']['blowfish_secret']));
103 } // end if
105 // For http auth. mode, the "back" link will also enforce new
106 // authentication
107 if ($cfg['Server']['auth_type'] == 'http') {
108 $_url_params['old_usr'] = 'relog';
111 $message = PMA_Message::success(__('The profile has been updated.'));
113 if($GLOBALS['is_ajax_request'] == true) {
114 $extra_data['sql_query'] = PMA_showMessage(NULL, $sql_query, 'success');
115 PMA_ajaxResponse($message, true, $extra_data);
118 // Displays the page
119 require_once './libraries/header.inc.php';
120 echo '<h1>' . __('Change password') . '</h1>' . "\n\n";
121 PMA_showMessage($message, $sql_query, 'success');
123 <a href="index.php<?php echo PMA_generate_common_url($_url_params); ?>" target="_parent">
124 <strong><?php echo __('Back'); ?></strong></a>
125 <?php
126 require './libraries/footer.inc.php';
127 } // end if
128 } // end if
132 * If the "change password" form hasn't been submitted or the values submitted
133 * aren't valid -> displays the form
135 // Loads the headers
136 require_once './libraries/header.inc.php';
138 echo '<h1>' . __('Change password') . '</h1>' . "\n\n";
140 // Displays an error message if required
141 if (isset($message)) {
142 $message->display();
145 require_once './libraries/display_change_password.lib.php';
148 * Displays the footer
150 require './libraries/footer.inc.php';