Translated using Weblate (Chinese (Simplified))
[phpmyadmin.git] / user_password.php
blob10663e9360705a39fa7753300078c5b76f960464
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 index.php
7 * @package PhpMyAdmin
8 */
10 use PhpMyAdmin\Display\ChangePassword;
11 use PhpMyAdmin\Message;
12 use PhpMyAdmin\Response;
13 use PhpMyAdmin\UserPassword;
15 /**
16 * Gets some core libraries
18 require_once './libraries/common.inc.php';
20 $response = Response::getInstance();
21 $header = $response->getHeader();
22 $scripts = $header->getScripts();
23 $scripts->addFile('server_privileges.js');
24 $scripts->addFile('vendor/zxcvbn.js');
26 $userPassword = new UserPassword();
28 /**
29 * Displays an error message and exits if the user isn't allowed to use this
30 * script
32 if (! $GLOBALS['cfg']['ShowChgPassword']) {
33 $GLOBALS['cfg']['ShowChgPassword'] = $GLOBALS['dbi']->selectDb('mysql');
35 if ($cfg['Server']['auth_type'] == 'config' || ! $cfg['ShowChgPassword']) {
36 Message::error(
37 __('You don\'t have sufficient privileges to be here right now!')
38 )->display();
39 exit;
40 } // end if
42 /**
43 * If the "change password" form has been submitted, checks for valid values
44 * and submit the query or logout
46 if (isset($_POST['nopass'])) {
47 if ($_POST['nopass'] == '1') {
48 $password = '';
49 } else {
50 $password = $_POST['pma_pw'];
52 $change_password_message = $userPassword->setChangePasswordMsg();
53 $msg = $change_password_message['msg'];
54 if (! $change_password_message['error']) {
55 $userPassword->changePassword($password, $msg, $change_password_message);
56 } else {
57 $userPassword->getChangePassMessage($change_password_message);
61 /**
62 * If the "change password" form hasn't been submitted or the values submitted
63 * aren't valid -> displays the form
66 // Displays an error message if required
67 if (isset($msg)) {
68 $msg->display();
69 unset($msg);
72 echo ChangePassword::getHtml('change_pw', $username, $hostname);
73 exit;