3.1.3.1
[phpmyadmin/crack.git] / user_password.php
blob51c0fb6f09c63ae1e41281cd026244e431fa34a2
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['strUpdateProfileMessage']
8 * @uses $GLOBALS['strBack']
9 * @uses $GLOBALS['js_include']
10 * @uses $GLOBALS['strChangePassword']
11 * @uses $GLOBALS['strPasswordEmpty']
12 * @uses $GLOBALS['strPasswordNotSame']
13 * @uses $GLOBALS['strError']
14 * @uses $GLOBALS['strNoRights']
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 PMA_setCookie()
25 * @uses PMA_blowfish_encrypt()
26 * @uses PMA_showMessage()
27 * @uses define()
28 * @version $Id$
31 /**
32 * no need for variables importing
34 if (! defined('PMA_NO_VARIABLES_IMPORT')) {
35 define('PMA_NO_VARIABLES_IMPORT', true);
38 /**
39 * Gets some core libraries
41 require_once './libraries/common.inc.php';
43 /**
44 * Displays an error message and exits if the user isn't allowed to use this
45 * script
47 if (!$cfg['ShowChgPassword']) {
48 $cfg['ShowChgPassword'] = PMA_DBI_select_db('mysql');
50 if ($cfg['Server']['auth_type'] == 'config' || !$cfg['ShowChgPassword']) {
51 require_once './libraries/header.inc.php';
52 PMA_Message::error('strNoRights')->display();
53 require_once './libraries/footer.inc.php';
54 } // end if
57 /**
58 * If the "change password" form has been submitted, checks for valid values
59 * and submit the query or logout
61 if (isset($_REQUEST['nopass'])) {
62 // similar logic in server_privileges.php
63 $_error = false;
65 if ($_REQUEST['nopass'] == '1') {
66 $password = '';
67 } elseif (empty($_REQUEST['pma_pw']) || empty($_REQUEST['pma_pw2'])) {
68 $message = PMA_Message::error('strPasswordEmpty');
69 $_error = true;
70 } elseif ($_REQUEST['pma_pw'] != $_REQUEST['pma_pw2']) {
71 $message = PMA_Message::error('strPasswordNotSame');
72 $_error = true;
73 } else {
74 $password = $_REQUEST['pma_pw'];
77 if (! $_error) {
79 // Defines the url to return to in case of error in the sql statement
80 $_url_params = array();
82 $err_url = 'user_password.php' . PMA_generate_common_url($_url_params);
83 if (PMA_isValid($_REQUEST['pw_hash'], 'identical', 'old')) {
84 $hashing_function = 'OLD_PASSWORD';
85 } else {
86 $hashing_function = 'PASSWORD';
89 $sql_query = 'SET password = ' . (($password == '') ? '\'\'' : $hashing_function . '(\'***\')');
90 $local_query = 'SET password = ' . (($password == '') ? '\'\'' : $hashing_function . '(\'' . PMA_sqlAddslashes($password) . '\')');
91 $result = @PMA_DBI_try_query($local_query)
92 or PMA_mysqlDie(PMA_DBI_getError(), $sql_query, false, $err_url);
94 // Changes password cookie if required
95 // Duration = till the browser is closed for password (we don't want this to be saved)
96 if ($cfg['Server']['auth_type'] == 'cookie') {
97 PMA_setCookie('pmaPass-' . $server,
98 PMA_blowfish_encrypt($password, $GLOBALS['cfg']['blowfish_secret']));
99 } // end if
101 // For http auth. mode, the "back" link will also enforce new
102 // authentication
103 if ($cfg['Server']['auth_type'] == 'http') {
104 $_url_params['old_usr'] = 'relog';
107 // Displays the page
108 require_once './libraries/header.inc.php';
109 echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
110 PMA_showMessage($strUpdateProfileMessage, $sql_query, 'success');
112 <a href="index.php<?php echo PMA_generate_common_url($_url_params); ?>" target="_parent">
113 <strong><?php echo $strBack; ?></strong></a>
114 <?php
115 require_once './libraries/footer.inc.php';
116 } // end if
117 } // end if
121 * If the "change password" form hasn't been submitted or the values submitted
122 * aren't valid -> displays the form
124 // Loads the headers
125 $GLOBALS['js_include'][] = 'server_privileges.js';
126 require_once './libraries/header.inc.php';
127 echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
129 // Displays an error message if required
130 if (isset($message)) {
131 $message->display();
134 require_once './libraries/display_change_password.lib.php';
137 * Displays the footer
139 require_once './libraries/footer.inc.php';