sanitize $after_field
[phpmyadmin/dkf.git] / user_password.php
blob4091ffb1576d69359e3f4f44f1684f1f2547de4c
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 */
8 /**
9 * Gets some core libraries
11 require_once './libraries/common.inc.php';
13 /**
14 * Displays an error message and exits if the user isn't allowed to use this
15 * script
17 if (!$cfg['ShowChgPassword']) {
18 $cfg['ShowChgPassword'] = PMA_DBI_select_db('mysql');
20 if ($cfg['Server']['auth_type'] == 'config' || !$cfg['ShowChgPassword']) {
21 require_once './libraries/header.inc.php';
22 echo '<p><b>' . $strError . '</b></p>' . "\n"
23 . '<p>&nbsp;&nbsp;&nbsp;&nbsp;' . $strNoRights . '</p>' . "\n";
24 require_once './libraries/footer.inc.php';
25 } // end if
28 /**
29 * If the "change password" form has been submitted, checks for valid values
30 * and submit the query or logout
32 if (isset($nopass)) {
33 // similar logic in server_privileges.php
34 $error_msg = '';
36 if ($nopass == 0 && isset($pma_pw) && isset($pma_pw2)) {
37 if ($pma_pw != $pma_pw2) {
38 $error_msg = $strPasswordNotSame;
40 if (empty($pma_pw) || empty($pma_pw2)) {
41 $error_msg = $strPasswordEmpty;
43 } // end if
45 // here $nopass could be == 1
46 if (empty($error_msg)) {
48 // Defines the url to return to in case of error in the sql statement
49 $common_url_query = PMA_generate_common_url();
51 $err_url = 'user_password.php?' . $common_url_query;
52 $hashing_function = (PMA_MYSQL_INT_VERSION >= 40102 && !empty($pw_hash) && $pw_hash == 'old' ? 'OLD_' : '')
53 . 'PASSWORD';
55 $sql_query = 'SET password = ' . (($pma_pw == '') ? '\'\'' : $hashing_function . '(\'' . preg_replace('@.@s', '*', $pma_pw) . '\')');
56 $local_query = 'SET password = ' . (($pma_pw == '') ? '\'\'' : $hashing_function . '(\'' . PMA_sqlAddslashes($pma_pw) . '\')');
57 $result = @PMA_DBI_try_query($local_query) or PMA_mysqlDie(PMA_DBI_getError(), $sql_query, FALSE, $err_url);
59 // Changes password cookie if required
60 // Duration = till the browser is closed for password (we don't want this to be saved)
61 if ($cfg['Server']['auth_type'] == 'cookie') {
63 PMA_setCookie('pmaPass-' . $server, PMA_blowfish_encrypt($pma_pw, $GLOBALS['cfg']['blowfish_secret']));
65 } // end if
66 // For http auth. mode, the "back" link will also enforce new
67 // authentication
68 $http_logout = ($cfg['Server']['auth_type'] == 'http')
69 ? '&amp;old_usr=relog'
70 : '';
72 // Displays the page
73 require_once './libraries/header.inc.php';
74 echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
75 $show_query = 'y';
76 PMA_showMessage($strUpdateProfileMessage);
78 <a href="index.php?<?php echo $common_url_query . $http_logout; ?>" target="_parent">
79 <b><?php echo $strBack; ?></b></a>
80 <?php
81 exit();
82 } // end if
83 } // end if
86 /**
87 * If the "change password" form hasn't been submitted or the values submitted
88 * aren't valid -> displays the form
90 // Loads the headers
91 $js_to_run = 'user_password.js';
92 require_once './libraries/header.inc.php';
93 echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
95 // Displays an error message if required
96 if (!empty($error_msg)) {
97 echo '<p><b>' . $strError . ':&nbsp;' . $error_msg . '</b></p>' . "\n";
100 require_once './libraries/display_change_password.lib.php';
103 * Displays the footer
105 require_once './libraries/footer.inc.php';