2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Displays form for password change
8 if (! defined('PHPMYADMIN')) {
13 * Get HTML for the Change password dialog
15 * @param string $mode where is the function being called?
16 * values : 'change_pw' or 'edit_other'
17 * @param string $username username
18 * @param string $hostname hostname
20 * @return string html snippet
22 function PMA_getHtmlForChangePassword($mode, $username, $hostname)
25 * autocomplete feature of IE kills the "onchange" event handler and it
26 * must be replaced by the "onpropertychange" one in this case
28 $chg_evt_handler = (PMA_USR_BROWSER_AGENT
== 'IE'
29 && PMA_USR_BROWSER_VER
>= 5
30 && PMA_USR_BROWSER_VER
< 7)
34 $is_privileges = basename($_SERVER['SCRIPT_NAME']) === 'server_privileges.php';
36 $html = '<form method="post" id="change_password_form" '
37 . 'action="' . basename($GLOBALS['PMA_PHP_SELF']) . '" '
38 . 'name="chgPassword" '
39 . 'class="' . ($is_privileges ?
'submenu-item' : '') . '">';
41 $html .= PMA_URL_getHiddenInputs();
43 if (strpos($GLOBALS['PMA_PHP_SELF'], 'server_privileges') !== false) {
44 $html .= '<input type="hidden" name="username" '
45 . 'value="' . htmlspecialchars($username) . '" />'
46 . '<input type="hidden" name="hostname" '
47 . 'value="' . htmlspecialchars($hostname) . '" />';
49 $html .= '<fieldset id="fieldset_change_password">'
52 ?
' data-submenu-label="' . __('Change password') . '"'
55 . '>' . __('Change password') . '</legend>'
56 . '<table class="data noclick">'
59 . '<input type="radio" name="nopass" value="1" id="nopass_1" '
60 . 'onclick="pma_pw.value = \'\'; pma_pw2.value = \'\'; '
61 . 'this.checked = true" />'
62 . '<label for="nopass_1">' . __('No Password') . '</label>'
65 . '<tr class="even vmiddle">'
67 . '<input type="radio" name="nopass" value="0" id="nopass_0" '
68 . 'onclick="document.getElementById(\'text_pma_pw\').focus();" '
69 . 'checked="checked" />'
70 . '<label for="nopass_0">' . __('Password:') . ' </label>'
73 . '<input type="password" name="pma_pw" id="text_pma_pw" size="10" '
75 . $chg_evt_handler . '="nopass[1].checked = true" />'
76 . ' ' . __('Re-type:') . ' '
77 . '<input type="password" name="pma_pw2" id="text_pma_pw2" size="10" '
79 . $chg_evt_handler . '="nopass[1].checked = true" />'
83 $serverType = PMA_Util
::getServerType();
84 $orig_auth_plugin = PMA_getCurrentAuthenticationPlugin(
89 $is_superuser = $GLOBALS['dbi']->isSuperuser();
91 if (($serverType == 'MySQL'
92 && PMA_MYSQL_INT_VERSION
>= 50507)
93 ||
($serverType == 'MariaDB'
94 && PMA_MYSQL_INT_VERSION
>= 50200)
96 // Provide this option only for 5.7.6+
97 // OR for privileged users in 5.5.7+
98 if (($serverType == 'MySQL'
99 && PMA_MYSQL_INT_VERSION
>= 50706)
100 ||
($is_superuser && $mode == 'edit_other')
102 $auth_plugin_dropdown = PMA_getHtmlForAuthPluginsDropdown(
103 $username, $hostname, $orig_auth_plugin, 'change_pw', 'new'
106 $html .= '<tr class="vmiddle">'
107 . '<td>' . __('Password Hashing:') . '</td><td>';
108 $html .= $auth_plugin_dropdown;
109 $html .= '</td></tr>'
110 . '<tr id="tr_element_before_generate_password"></tr>'
114 . ($orig_auth_plugin != 'sha256_password' ?
'style="display:none"' : '')
115 . ' id="ssl_reqd_warning_cp">'
116 . PMA_Message
::notice(
118 'This method requires using an \'<i>SSL connection</i>\' '
119 . 'or an \'<i>unencrypted connection that encrypts the password '
120 . 'using RSA</i>\'; while connecting to the server.'
122 . PMA_Util
::showMySQLDocu('sha256-authentication-plugin')
127 $html .= '<tr id="tr_element_before_generate_password"></tr>'
131 $auth_plugin_dropdown = PMA_getHtmlForAuthPluginsDropdown(
132 $username, $hostname, $orig_auth_plugin, 'change_pw', 'old'
135 $html .= '<tr class="vmiddle">'
136 . '<td>' . __('Password Hashing:') . '</td><td>';
137 $html .= $auth_plugin_dropdown . '</td></tr>'
138 . '<tr id="tr_element_before_generate_password"></tr>'
142 $html .= '</fieldset>'
143 . '<fieldset id="fieldset_change_password_footer" class="tblFooters">'
144 . '<input type="hidden" name="change_pw" value="1" />'
145 . '<input type="submit" value="' . __('Go') . '" />'