2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * displays and handles the form where the user can change his password
5 * linked from index.php
9 declare(strict_types
=1);
11 use PhpMyAdmin\Display\ChangePassword
;
12 use PhpMyAdmin\Message
;
13 use PhpMyAdmin\Response
;
14 use PhpMyAdmin\UserPassword
;
17 * Gets some core libraries
19 require_once './libraries/common.inc.php';
21 $response = Response
::getInstance();
22 $header = $response->getHeader();
23 $scripts = $header->getScripts();
24 $scripts->addFile('server_privileges.js');
25 $scripts->addFile('vendor/zxcvbn.js');
27 $userPassword = new UserPassword();
30 * Displays an error message and exits if the user isn't allowed to use this
33 if (! $GLOBALS['cfg']['ShowChgPassword']) {
34 $GLOBALS['cfg']['ShowChgPassword'] = $GLOBALS['dbi']->selectDb('mysql');
36 if ($cfg['Server']['auth_type'] == 'config' ||
! $cfg['ShowChgPassword']) {
38 __('You don\'t have sufficient privileges to be here right now!')
44 * If the "change password" form has been submitted, checks for valid values
45 * and submit the query or logout
47 if (isset($_REQUEST['nopass'])) {
48 if ($_REQUEST['nopass'] == '1') {
51 $password = $_REQUEST['pma_pw'];
53 $change_password_message = $userPassword->setChangePasswordMsg();
54 $msg = $change_password_message['msg'];
55 if (! $change_password_message['error']) {
56 $userPassword->changePassword($password, $msg, $change_password_message);
58 $userPassword->getChangePassMessage($change_password_message);
63 * If the "change password" form hasn't been submitted or the values submitted
64 * aren't valid -> displays the form
67 // Displays an error message if required
73 echo ChangePassword
::getHtml('change_pw', $username, $hostname);