1. Check existence of mb_string, mysql and xml extensions before installation.
[openemr.git] / phpmyadmin / libraries / display_change_password.lib.php
blobbe881c5312c28d4c46a63822279d44a69d237b41
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Displays form for password change
6 * @package PhpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 /**
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)
24 /**
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)
31 ? 'onpropertychange'
32 : 'onchange';
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">'
50 . '<legend'
51 . ($is_privileges
52 ? ' data-submenu-label="' . __('Change password') . '"'
53 : ''
55 . '>' . __('Change password') . '</legend>'
56 . '<table class="data noclick">'
57 . '<tr class="odd">'
58 . '<td colspan="2">'
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>'
63 . '</td>'
64 . '</tr>'
65 . '<tr class="even vmiddle">'
66 . '<td>'
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:') . '&nbsp;</label>'
71 . '</td>'
72 . '<td>'
73 . '<input type="password" name="pma_pw" id="text_pma_pw" size="10" '
74 . 'class="textfield"'
75 . $chg_evt_handler . '="nopass[1].checked = true" />'
76 . '&nbsp;&nbsp;' . __('Re-type:') . '&nbsp;'
77 . '<input type="password" name="pma_pw2" id="text_pma_pw2" size="10" '
78 . 'class="textfield"'
79 . $chg_evt_handler . '="nopass[1].checked = true" />'
80 . '</td>'
81 . '</tr>';
83 $serverType = PMA_Util::getServerType();
84 $orig_auth_plugin = PMA_getCurrentAuthenticationPlugin(
85 'change',
86 $username,
87 $hostname
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)
95 ) {
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>'
111 . '</table>';
113 $html .= '<div '
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')
124 ->getDisplay()
125 . '</div>';
126 } else {
127 $html .= '<tr id="tr_element_before_generate_password"></tr>'
128 . '</table>';
130 } else {
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>'
139 . '</table>';
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') . '" />'
146 . '</fieldset>'
147 . '</form>';
148 return $html;