Convert some comments to phpdoc.
[phpmyadmin/crack.git] / user_password.php
blob3bc0a319733bba3e6fbf931dc78e440e0df97422
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
33 * @ignore
35 if (! defined('PMA_NO_VARIABLES_IMPORT')) {
36 define('PMA_NO_VARIABLES_IMPORT', true);
39 /**
40 * Gets some core libraries
42 require_once './libraries/common.inc.php';
44 /**
45 * Displays an error message and exits if the user isn't allowed to use this
46 * script
48 if (!$cfg['ShowChgPassword']) {
49 $cfg['ShowChgPassword'] = PMA_DBI_select_db('mysql');
51 if ($cfg['Server']['auth_type'] == 'config' || !$cfg['ShowChgPassword']) {
52 require_once './libraries/header.inc.php';
53 PMA_Message::error('strNoRights')->display();
54 require_once './libraries/footer.inc.php';
55 } // end if
58 /**
59 * If the "change password" form has been submitted, checks for valid values
60 * and submit the query or logout
62 if (isset($_REQUEST['nopass'])) {
63 // similar logic in server_privileges.php
64 $_error = false;
66 if ($_REQUEST['nopass'] == '1') {
67 $password = '';
68 } elseif (empty($_REQUEST['pma_pw']) || empty($_REQUEST['pma_pw2'])) {
69 $message = PMA_Message::error('strPasswordEmpty');
70 $_error = true;
71 } elseif ($_REQUEST['pma_pw'] != $_REQUEST['pma_pw2']) {
72 $message = PMA_Message::error('strPasswordNotSame');
73 $_error = true;
74 } else {
75 $password = $_REQUEST['pma_pw'];
78 if (! $_error) {
80 // Defines the url to return to in case of error in the sql statement
81 $_url_params = array();
83 $err_url = 'user_password.php' . PMA_generate_common_url($_url_params);
84 if (PMA_isValid($_REQUEST['pw_hash'], 'identical', 'old')) {
85 $hashing_function = 'OLD_PASSWORD';
86 } else {
87 $hashing_function = 'PASSWORD';
90 $sql_query = 'SET password = ' . (($password == '') ? '\'\'' : $hashing_function . '(\'***\')');
91 $local_query = 'SET password = ' . (($password == '') ? '\'\'' : $hashing_function . '(\'' . PMA_sqlAddslashes($password) . '\')');
92 $result = @PMA_DBI_try_query($local_query)
93 or PMA_mysqlDie(PMA_DBI_getError(), $sql_query, false, $err_url);
95 // Changes password cookie if required
96 // Duration = till the browser is closed for password (we don't want this to be saved)
97 if ($cfg['Server']['auth_type'] == 'cookie') {
98 PMA_setCookie('pmaPass-' . $server,
99 PMA_blowfish_encrypt($password, $GLOBALS['cfg']['blowfish_secret']));
100 } // end if
102 // For http auth. mode, the "back" link will also enforce new
103 // authentication
104 if ($cfg['Server']['auth_type'] == 'http') {
105 $_url_params['old_usr'] = 'relog';
108 // Displays the page
109 require_once './libraries/header.inc.php';
110 echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
111 PMA_showMessage($strUpdateProfileMessage, $sql_query, 'success');
113 <a href="index.php<?php echo PMA_generate_common_url($_url_params); ?>" target="_parent">
114 <strong><?php echo $strBack; ?></strong></a>
115 <?php
116 require_once './libraries/footer.inc.php';
117 } // end if
118 } // end if
122 * If the "change password" form hasn't been submitted or the values submitted
123 * aren't valid -> displays the form
125 // Loads the headers
126 $GLOBALS['js_include'][] = 'server_privileges.js';
127 require_once './libraries/header.inc.php';
128 echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
130 // Displays an error message if required
131 if (isset($message)) {
132 $message->display();
135 require_once './libraries/display_change_password.lib.php';
138 * Displays the footer
140 require_once './libraries/footer.inc.php';