Translated using Weblate (Estonian)
[phpmyadmin.git] / user_password.php
blob6097ccf55290a85b7ee2f47be7f1e22568598b45
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 */
9 declare(strict_types=1);
11 use PhpMyAdmin\Display\ChangePassword;
12 use PhpMyAdmin\Message;
13 use PhpMyAdmin\Response;
14 use PhpMyAdmin\UserPassword;
16 /**
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();
29 /**
30 * Displays an error message and exits if the user isn't allowed to use this
31 * script
33 if (! $GLOBALS['cfg']['ShowChgPassword']) {
34 $GLOBALS['cfg']['ShowChgPassword'] = $GLOBALS['dbi']->selectDb('mysql');
36 if ($cfg['Server']['auth_type'] == 'config' || ! $cfg['ShowChgPassword']) {
37 Message::error(
38 __('You don\'t have sufficient privileges to be here right now!')
39 )->display();
40 exit;
41 } // end if
43 /**
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') {
49 $password = '';
50 } else {
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);
57 } else {
58 $userPassword->getChangePassMessage($change_password_message);
62 /**
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
68 if (isset($msg)) {
69 $msg->display();
70 unset($msg);
73 echo ChangePassword::getHtml('change_pw', $username, $hostname);
74 exit;