2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Displays form for password change
8 use PMA\libraries\Message
;
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)
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">'
47 ?
' data-submenu-label="' . __('Change password') . '"'
50 . '>' . __('Change password') . '</legend>'
51 . '<table class="data noclick">'
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>'
60 . '<tr class="vmiddle">'
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:') . ' </label>'
68 . __('Enter:') . '  '
69 . '<input type="password" name="pma_pw" id="text_pma_change_pw" size="10" '
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:') . ' '
76 . '<input type="password" name="pma_pw2" id="text_pma_change_pw2" size="10" '
78 . $chg_evt_handler . '="nopass[1].checked = true" />'
82 $serverType = PMA\libraries\Util
::getServerType();
83 $orig_auth_plugin = PMA_getCurrentAuthenticationPlugin(
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)
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>'
113 . ($orig_auth_plugin != 'sha256_password'
116 . ' id="ssl_reqd_warning_cp">'
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'
130 $html .= '<tr id="tr_element_before_generate_password"></tr>'
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>'
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') . '" />'