Translated using Weblate (Dutch)
[phpmyadmin.git] / libraries / display_change_password.lib.php
blob11f77cb57fe317f3e73d02b1568bb90d29ca9224
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Displays form for password change
6 * @package PhpMyAdmin
7 */
8 use PMA\libraries\Message;
9 use PMA\libraries\URL;
11 /**
12 * Get HTML for the Change password dialog
14 * @param string $mode where is the function being called?
15 * values : 'change_pw' or 'edit_other'
16 * @param string $username username
17 * @param string $hostname hostname
19 * @return string html snippet
21 function PMA_getHtmlForChangePassword($mode, $username, $hostname)
23 /**
24 * autocomplete feature of IE kills the "onchange" event handler and it
25 * must be replaced by the "onpropertychange" one in this case
27 $chg_evt_handler = 'onchange';
29 $is_privileges = basename($_SERVER['SCRIPT_NAME']) === 'server_privileges.php';
31 $html = '<form method="post" id="change_password_form" '
32 . 'action="' . basename($GLOBALS['PMA_PHP_SELF']) . '" '
33 . 'name="chgPassword" '
34 . 'class="' . ($is_privileges ? 'submenu-item' : '') . '">';
36 $html .= URL::getHiddenInputs();
38 if (strpos($GLOBALS['PMA_PHP_SELF'], 'server_privileges') !== false) {
39 $html .= '<input type="hidden" name="username" '
40 . 'value="' . htmlspecialchars($username) . '" />'
41 . '<input type="hidden" name="hostname" '
42 . 'value="' . htmlspecialchars($hostname) . '" />';
44 $html .= '<fieldset id="fieldset_change_password">'
45 . '<legend'
46 . ($is_privileges
47 ? ' data-submenu-label="' . __('Change password') . '"'
48 : ''
50 . '>' . __('Change password') . '</legend>'
51 . '<table class="data noclick">'
52 . '<tr>'
53 . '<td colspan="2">'
54 . '<input type="radio" name="nopass" value="1" id="nopass_1" '
55 . 'onclick="pma_pw.value = \'\'; pma_pw2.value = \'\'; '
56 . 'this.checked = true" />'
57 . '<label for="nopass_1">' . __('No Password') . '</label>'
58 . '</td>'
59 . '</tr>'
60 . '<tr class="vmiddle">'
61 . '<td>'
62 . '<input type="radio" name="nopass" value="0" id="nopass_0" '
63 . 'onclick="document.getElementById(\'text_pma_change_pw\').focus();" '
64 . 'checked="checked" />'
65 . '<label for="nopass_0">' . __('Password:') . '&nbsp;</label>'
66 . '</td>'
67 . '<td>'
68 . __('Enter:') . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp'
69 . '<input type="password" name="pma_pw" id="text_pma_change_pw" size="10" '
70 . 'class="textfield"'
71 . $chg_evt_handler . '="nopass[1].checked = true" />'
72 . '<span>Strength:</span> '
73 . '<meter max="4" id="change_password_strength_meter" name="pw_meter"></meter> '
74 . '<span id="change_password_strength" name="pw_strength">Good</span>'
75 . '<br>' . __('Re-type:') . '&nbsp;'
76 . '<input type="password" name="pma_pw2" id="text_pma_change_pw2" size="10" '
77 . 'class="textfield"'
78 . $chg_evt_handler . '="nopass[1].checked = true" />'
79 . '</td>'
80 . '</tr>';
82 $serverType = PMA\libraries\Util::getServerType();
83 $orig_auth_plugin = PMA_getCurrentAuthenticationPlugin(
84 'change',
85 $username,
86 $hostname
88 $is_superuser = $GLOBALS['dbi']->isSuperuser();
90 if (($serverType == 'MySQL'
91 && PMA_MYSQL_INT_VERSION >= 50507)
92 || ($serverType == 'MariaDB'
93 && PMA_MYSQL_INT_VERSION >= 50200)
94 ) {
95 // Provide this option only for 5.7.6+
96 // OR for privileged users in 5.5.7+
97 if (($serverType == 'MySQL'
98 && PMA_MYSQL_INT_VERSION >= 50706)
99 || ($is_superuser && $mode == 'edit_other')
101 $auth_plugin_dropdown = PMA_getHtmlForAuthPluginsDropdown(
102 $orig_auth_plugin, 'change_pw', 'new'
105 $html .= '<tr class="vmiddle">'
106 . '<td>' . __('Password Hashing:') . '</td><td>';
107 $html .= $auth_plugin_dropdown;
108 $html .= '</td></tr>'
109 . '<tr id="tr_element_before_generate_password"></tr>'
110 . '</table>';
112 $html .= '<div'
113 . ($orig_auth_plugin != 'sha256_password'
114 ? ' class="hide"'
115 : '')
116 . ' id="ssl_reqd_warning_cp">'
117 . Message::notice(
119 'This method requires using an \'<i>SSL connection</i>\' '
120 . 'or an \'<i>unencrypted connection that encrypts the '
121 . 'password using RSA</i>\'; while connecting to the server.'
123 . PMA\libraries\Util::showMySQLDocu(
124 'sha256-authentication-plugin'
127 ->getDisplay()
128 . '</div>';
129 } else {
130 $html .= '<tr id="tr_element_before_generate_password"></tr>'
131 . '</table>';
133 } else {
134 $auth_plugin_dropdown = PMA_getHtmlForAuthPluginsDropdown(
135 $orig_auth_plugin, 'change_pw', 'old'
138 $html .= '<tr class="vmiddle">'
139 . '<td>' . __('Password Hashing:') . '</td><td>';
140 $html .= $auth_plugin_dropdown . '</td></tr>'
141 . '<tr id="tr_element_before_generate_password"></tr>'
142 . '</table>';
145 $html .= '</fieldset>'
146 . '<fieldset id="fieldset_change_password_footer" class="tblFooters">'
147 . '<input type="hidden" name="change_pw" value="1" />'
148 . '<input type="submit" value="' . __('Go') . '" />'
149 . '</fieldset>'
150 . '</form>';
151 return $html;