/**
 * Displays the fields used by the "new user" form as well as the
 * "change login information / copy user" form.
 *
 * @param string $mode are we creating a new user or are we just
 *                     changing  one? (allowed values: 'new', 'change')
 *
 * @global  array      $cfg     the phpMyAdmin configuration
 * @global  resource   $user_link the database connection
 *
 * @return string $html_output  a HTML snippet
 */
function PMA_getHtmlForLoginInformationFields($mode = 'new')
{
    list($username_length, $hostname_length) = PMA_getUsernameAndHostnameLength();
    if (isset($GLOBALS['username']) && mb_strlen($GLOBALS['username']) === 0) {
        $GLOBALS['pred_username'] = '******';
    }
    $html_output = '<fieldset id="fieldset_add_user_login">' . "\n" . '<legend>' . __('Login Information') . '</legend>' . "\n" . '<div class="item">' . "\n" . '<label for="select_pred_username">' . "\n" . '    ' . __('User name:') . "\n" . '</label>' . "\n" . '<span class="options">' . "\n";
    $html_output .= '<select name="pred_username" id="select_pred_username" ' . 'title="' . __('User name') . '"' . "\n";
    $html_output .= '        onchange="' . 'if (this.value == \'any\') {' . '    username.value = \'\'; ' . '    user_exists_warning.style.display = \'none\'; ' . '    username.required = false; ' . '} else if (this.value == \'userdefined\') {' . '    username.focus(); username.select(); ' . '    username.required = true; ' . '}">' . "\n";
    $html_output .= '<option value="any"' . (isset($GLOBALS['pred_username']) && $GLOBALS['pred_username'] == 'any' ? ' selected="selected"' : '') . '>' . __('Any user') . '</option>' . "\n";
    $html_output .= '<option value="userdefined"' . (!isset($GLOBALS['pred_username']) || $GLOBALS['pred_username'] == 'userdefined' ? ' selected="selected"' : '') . '>' . __('Use text field') . ':</option>' . "\n";
    $html_output .= '</select>' . "\n" . '</span>' . "\n";
    $html_output .= '<input type="text" name="username" class="autofocus"' . ' maxlength="' . $username_length . '" title="' . __('User name') . '"' . (empty($GLOBALS['username']) ? '' : ' value="' . htmlspecialchars(isset($GLOBALS['new_username']) ? $GLOBALS['new_username'] : $GLOBALS['username']) . '"') . ' onchange="pred_username.value = \'userdefined\'; this.required = true;" ' . (!isset($GLOBALS['pred_username']) || $GLOBALS['pred_username'] == 'userdefined' ? 'required="required"' : '') . ' />' . "\n";
    $html_output .= '<div id="user_exists_warning"' . ' name="user_exists_warning" style="display:none;">' . PMA_Message::notice(__('An account already exists with the same username ' . 'but possibly a different hostname.'))->getDisplay() . '</div>';
    $html_output .= '</div>';
    $html_output .= '<div class="item">' . "\n" . '<label for="select_pred_hostname">' . "\n" . '    ' . __('Host:') . "\n" . '</label>' . "\n";
    $html_output .= '<span class="options">' . "\n" . '    <select name="pred_hostname" id="select_pred_hostname" ' . 'title="' . __('Host') . '"' . "\n";
    $_current_user = $GLOBALS['dbi']->fetchValue('SELECT USER();');
    if (!empty($_current_user)) {
        $thishost = str_replace("'", '', mb_substr($_current_user, mb_strrpos($_current_user, '@') + 1));
        if ($thishost == 'localhost' || $thishost == '127.0.0.1') {
            unset($thishost);
        }
    }
    $html_output .= '    onchange="' . 'if (this.value == \'any\') { ' . '     hostname.value = \'%\'; ' . '} else if (this.value == \'localhost\') { ' . '    hostname.value = \'localhost\'; ' . '} ' . (empty($thishost) ? '' : 'else if (this.value == \'thishost\') { ' . '    hostname.value = \'' . addslashes(htmlspecialchars($thishost)) . '\'; ' . '} ') . 'else if (this.value == \'hosttable\') { ' . '    hostname.value = \'\'; ' . '    hostname.required = false; ' . '} else if (this.value == \'userdefined\') {' . '    hostname.focus(); hostname.select(); ' . '    hostname.required = true; ' . '}">' . "\n";
    unset($_current_user);
    // when we start editing a user, $GLOBALS['pred_hostname'] is not defined
    if (!isset($GLOBALS['pred_hostname']) && isset($GLOBALS['hostname'])) {
        switch (mb_strtolower($GLOBALS['hostname'])) {
            case 'localhost':
            case '127.0.0.1':
                $GLOBALS['pred_hostname'] = 'localhost';
                break;
            case '%':
                $GLOBALS['pred_hostname'] = 'any';
                break;
            default:
                $GLOBALS['pred_hostname'] = 'userdefined';
                break;
        }
    }
    $html_output .= '<option value="any"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'any' ? ' selected="selected"' : '') . '>' . __('Any host') . '</option>' . "\n" . '<option value="localhost"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'localhost' ? ' selected="selected"' : '') . '>' . __('Local') . '</option>' . "\n";
    if (!empty($thishost)) {
        $html_output .= '<option value="thishost"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'thishost' ? ' selected="selected"' : '') . '>' . __('This Host') . '</option>' . "\n";
    }
    unset($thishost);
    $html_output .= '<option value="hosttable"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'hosttable' ? ' selected="selected"' : '') . '>' . __('Use Host Table') . '</option>' . "\n";
    $html_output .= '<option value="userdefined"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'userdefined' ? ' selected="selected"' : '') . '>' . __('Use text field:') . '</option>' . "\n" . '</select>' . "\n" . '</span>' . "\n";
    $html_output .= '<input type="text" name="hostname" maxlength="' . $hostname_length . '" value="' . htmlspecialchars(isset($GLOBALS['hostname']) ? $GLOBALS['hostname'] : '%') . '" title="' . __('Host') . '" onchange="pred_hostname.value = \'userdefined\'; this.required = true;" ' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'userdefined' ? 'required="required"' : '') . ' />' . "\n" . PMA_Util::showHint(__('When Host table is used, this field is ignored ' . 'and values stored in Host table are used instead.')) . '</div>' . "\n";
    $html_output .= '<div class="item">' . "\n" . '<label for="select_pred_password">' . "\n" . '    ' . __('Password:'******'</label>' . "\n" . '<span class="options">' . "\n" . '<select name="pred_password" id="select_pred_password" title="' . __('Password') . '"' . "\n";
    $html_output .= '            onchange="' . 'if (this.value == \'none\') { ' . '    pma_pw.value = \'\'; pma_pw2.value = \'\'; ' . '    pma_pw.required = false; pma_pw2.required = false; ' . '} else if (this.value == \'userdefined\') { ' . '    pma_pw.focus(); pma_pw.select(); ' . '    pma_pw.required = true; pma_pw2.required = true; ' . '} else { ' . '    pma_pw.required = false; pma_pw2.required = false; ' . '}">' . "\n" . ($mode == 'change' ? '<option value="keep" selected="selected">' . __('Do not change the password') . '</option>' . "\n" : '') . '<option value="none"';
    if (isset($GLOBALS['username']) && $mode != 'change') {
        $html_output .= '  selected="selected"';
    }
    $html_output .= '>' . __('No Password') . '</option>' . "\n" . '<option value="userdefined"' . (isset($GLOBALS['username']) ? '' : ' selected="selected"') . '>' . __('Use text field') . ':</option>' . "\n" . '</select>' . "\n" . '</span>' . "\n" . '<input type="password" id="text_pma_pw" name="pma_pw" ' . 'title="' . __('Password') . '" ' . 'onchange="pred_password.value = \'userdefined\'; this.required = true; pma_pw2.required = true;" ' . (isset($GLOBALS['username']) ? '' : 'required="required"') . '/>' . "\n" . '</div>' . "\n";
    $html_output .= '<div class="item" ' . 'id="div_element_before_generate_password">' . "\n" . '<label for="text_pma_pw2">' . "\n" . '    ' . __('Re-type:') . "\n" . '</label>' . "\n" . '<span class="options">&nbsp;</span>' . "\n" . '<input type="password" name="pma_pw2" id="text_pma_pw2" ' . 'title="' . __('Re-type') . '" ' . 'onchange="pred_password.value = \'userdefined\'; this.required = true; pma_pw.required = true;" ' . (isset($GLOBALS['username']) ? '' : 'required="required"') . '/>' . "\n" . '</div>' . "\n" . '</fieldset>' . "\n";
    return $html_output;
}
/**
 * Displays the fields used by the "new user" form as well as the
 * "change login information / copy user" form.
 *
 * @param string $mode     are we creating a new user or are we just
 *                         changing  one? (allowed values: 'new', 'change')
 * @param string $username User name
 * @param string $hostname Host name
 *
 * @global  array      $cfg     the phpMyAdmin configuration
 * @global  resource   $user_link the database connection
 *
 * @return string $html_output  a HTML snippet
 */
function PMA_getHtmlForLoginInformationFields($mode = 'new', $username = null, $hostname = null)
{
    list($username_length, $hostname_length) = PMA_getUsernameAndHostnameLength();
    if (isset($GLOBALS['username']) && mb_strlen($GLOBALS['username']) === 0) {
        $GLOBALS['pred_username'] = '******';
    }
    $html_output = '<fieldset id="fieldset_add_user_login">' . "\n" . '<legend>' . __('Login Information') . '</legend>' . "\n" . '<div class="item">' . "\n" . '<label for="select_pred_username">' . "\n" . '    ' . __('User name:') . "\n" . '</label>' . "\n" . '<span class="options">' . "\n";
    $html_output .= '<select name="pred_username" id="select_pred_username" ' . 'title="' . __('User name') . '"' . "\n";
    $html_output .= '        onchange="' . 'if (this.value == \'any\') {' . '    username.value = \'\'; ' . '    user_exists_warning.style.display = \'none\'; ' . '    username.required = false; ' . '} else if (this.value == \'userdefined\') {' . '    username.focus(); username.select(); ' . '    username.required = true; ' . '}">' . "\n";
    $html_output .= '<option value="any"' . (isset($GLOBALS['pred_username']) && $GLOBALS['pred_username'] == 'any' ? ' selected="selected"' : '') . '>' . __('Any user') . '</option>' . "\n";
    $html_output .= '<option value="userdefined"' . (!isset($GLOBALS['pred_username']) || $GLOBALS['pred_username'] == 'userdefined' ? ' selected="selected"' : '') . '>' . __('Use text field') . ':</option>' . "\n";
    $html_output .= '</select>' . "\n" . '</span>' . "\n";
    $html_output .= '<input type="text" name="username" class="autofocus"' . ' maxlength="' . $username_length . '" title="' . __('User name') . '"' . (empty($GLOBALS['username']) ? '' : ' value="' . htmlspecialchars(isset($GLOBALS['new_username']) ? $GLOBALS['new_username'] : $GLOBALS['username']) . '"') . ' onchange="pred_username.value = \'userdefined\'; this.required = true;" ' . (!isset($GLOBALS['pred_username']) || $GLOBALS['pred_username'] == 'userdefined' ? 'required="required"' : '') . ' />' . "\n";
    $html_output .= '<div id="user_exists_warning"' . ' name="user_exists_warning" style="display:none;">' . PMA_Message::notice(__('An account already exists with the same username ' . 'but possibly a different hostname.'))->getDisplay() . '</div>';
    $html_output .= '</div>';
    $html_output .= '<div class="item">' . "\n" . '<label for="select_pred_hostname">' . "\n" . '    ' . __('Host name:') . "\n" . '</label>' . "\n";
    $html_output .= '<span class="options">' . "\n" . '    <select name="pred_hostname" id="select_pred_hostname" ' . 'title="' . __('Host name') . '"' . "\n";
    $_current_user = $GLOBALS['dbi']->fetchValue('SELECT USER();');
    if (!empty($_current_user)) {
        $thishost = str_replace("'", '', mb_substr($_current_user, mb_strrpos($_current_user, '@') + 1));
        if ($thishost == 'localhost' || $thishost == '127.0.0.1') {
            unset($thishost);
        }
    }
    $html_output .= '    onchange="' . 'if (this.value == \'any\') { ' . '     hostname.value = \'%\'; ' . '} else if (this.value == \'localhost\') { ' . '    hostname.value = \'localhost\'; ' . '} ' . (empty($thishost) ? '' : 'else if (this.value == \'thishost\') { ' . '    hostname.value = \'' . addslashes(htmlspecialchars($thishost)) . '\'; ' . '} ') . 'else if (this.value == \'hosttable\') { ' . '    hostname.value = \'\'; ' . '    hostname.required = false; ' . '} else if (this.value == \'userdefined\') {' . '    hostname.focus(); hostname.select(); ' . '    hostname.required = true; ' . '}">' . "\n";
    unset($_current_user);
    // when we start editing a user, $GLOBALS['pred_hostname'] is not defined
    if (!isset($GLOBALS['pred_hostname']) && isset($GLOBALS['hostname'])) {
        switch (mb_strtolower($GLOBALS['hostname'])) {
            case 'localhost':
            case '127.0.0.1':
                $GLOBALS['pred_hostname'] = 'localhost';
                break;
            case '%':
                $GLOBALS['pred_hostname'] = 'any';
                break;
            default:
                $GLOBALS['pred_hostname'] = 'userdefined';
                break;
        }
    }
    $html_output .= '<option value="any"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'any' ? ' selected="selected"' : '') . '>' . __('Any host') . '</option>' . "\n" . '<option value="localhost"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'localhost' ? ' selected="selected"' : '') . '>' . __('Local') . '</option>' . "\n";
    if (!empty($thishost)) {
        $html_output .= '<option value="thishost"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'thishost' ? ' selected="selected"' : '') . '>' . __('This Host') . '</option>' . "\n";
    }
    unset($thishost);
    $html_output .= '<option value="hosttable"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'hosttable' ? ' selected="selected"' : '') . '>' . __('Use Host Table') . '</option>' . "\n";
    $html_output .= '<option value="userdefined"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'userdefined' ? ' selected="selected"' : '') . '>' . __('Use text field:') . '</option>' . "\n" . '</select>' . "\n" . '</span>' . "\n";
    $html_output .= '<input type="text" name="hostname" maxlength="' . $hostname_length . '" value="' . htmlspecialchars(isset($GLOBALS['hostname']) ? $GLOBALS['hostname'] : '%') . '" title="' . __('Host name') . '" onchange="pred_hostname.value = \'userdefined\'; ' . 'this.required = true;" ' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'userdefined' ? 'required="required"' : '') . ' />' . "\n" . PMA_Util::showHint(__('When Host table is used, this field is ignored ' . 'and values stored in Host table are used instead.')) . '</div>' . "\n";
    $orig_auth_plugin = PMA_getCurrentAuthenticationPlugin($mode, $username, $hostname);
    $html_output .= '<div class="item">' . "\n" . '<label for="select_pred_password">' . "\n" . '    ' . __('Password:'******'</label>' . "\n" . '<span class="options">' . "\n" . '<select name="pred_password" id="select_pred_password" title="' . __('Password') . '"' . "\n";
    $html_output .= '            onchange="' . 'if (this.value == \'none\') { ' . '    pma_pw.value = \'\'; pma_pw2.value = \'\'; ' . '    pma_pw.required = false; pma_pw2.required = false; ' . '} else if (this.value == \'userdefined\') { ' . '    pma_pw.focus(); pma_pw.select(); ' . '    pma_pw.required = true; pma_pw2.required = true; ' . '} else { ' . '    pma_pw.required = false; pma_pw2.required = false; ' . '}">' . "\n" . ($mode == 'change' ? '<option value="keep" selected="selected">' . __('Do not change the password') . '</option>' . "\n" : '') . '<option value="none"';
    if (isset($GLOBALS['username']) && $mode != 'change') {
        $html_output .= '  selected="selected"';
    }
    $html_output .= '>' . __('No Password') . '</option>' . "\n" . '<option value="userdefined"' . (isset($GLOBALS['username']) ? '' : ' selected="selected"') . '>' . __('Use text field') . ':</option>' . "\n" . '</select>' . "\n" . '</span>' . "\n" . '<input type="password" id="text_pma_pw" name="pma_pw" ' . 'title="' . __('Password') . '" ' . 'onchange="pred_password.value = \'userdefined\'; this.required = true; ' . 'pma_pw2.required = true;" ' . (isset($GLOBALS['username']) ? '' : 'required="required"') . '/>' . "\n" . '</div>' . "\n";
    $html_output .= '<div class="item" ' . 'id="div_element_before_generate_password">' . "\n" . '<label for="text_pma_pw2">' . "\n" . '    ' . __('Re-type:') . "\n" . '</label>' . "\n" . '<span class="options">&nbsp;</span>' . "\n" . '<input type="password" name="pma_pw2" id="text_pma_pw2" ' . 'title="' . __('Re-type') . '" ' . 'onchange="pred_password.value = \'userdefined\'; this.required = true; ' . 'pma_pw.required = true;" ' . (isset($GLOBALS['username']) ? '' : 'required="required"') . '/>' . "\n" . '</div>' . "\n" . '<div class="item" id="authentication_plugin_div">' . '<label for="select_authentication_plugin" >' . __('Authentication Plugin') . '</label><span class="options">&nbsp;</span>' . "\n" . '<select id="select_authentication_plugin" name="authentication_plugin">' . '<option value="mysql_native_password" ' . ($orig_auth_plugin == 'mysql_native_password' ? 'selected ' : '') . '>' . __('MySQL native password') . '</option>';
    // Since, 5.6.6 does not provide a syntax to alter
    // the authentication plugin used for a user,
    // So for 5.6.6+ & prior to 5.7.6, display this option only while 'creating a
    // new user'
    if (PMA_MYSQL_INT_VERSION >= 50706 || $mode == 'new' && PMA_MYSQL_INT_VERSION >= 50606) {
        $html_output .= '<option value="sha256_password" ' . ($orig_auth_plugin == 'sha256_password' ? ' selected ' : '') . ' >' . __('SHA256 password') . '</option>';
    }
    $html_output .= '</select>' . '<div ' . ($orig_auth_plugin != 'sha256_password' ? 'style="display:none"' : '') . ' id="ssl_reqd_warning">' . PMA_Message::notice(__('This method requires using an \'<i>SSL connection</i>\' ' . 'or an \'<i>unencrypted connection that encrypts the password ' . 'using RSA</i>\'; while connecting to the server.') . PMA_Util::showMySQLDocu('sha256-authentication-plugin'))->getDisplay() . '</div>' . '</div>' . "\n" . '</fieldset>' . "\n";
    return $html_output;
}
Exemplo n.º 3
0
/**
 * Displays the fields used by the "new user" form as well as the
 * "change login information / copy user" form.
 *
 * @param string $mode     are we creating a new user or are we just
 *                         changing  one? (allowed values: 'new', 'change')
 * @param string $username User name
 * @param string $hostname Host name
 *
 * @global  array      $cfg     the phpMyAdmin configuration
 * @global  resource   $user_link the database connection
 *
 * @return string $html_output  a HTML snippet
 */
function PMA_getHtmlForLoginInformationFields($mode = 'new', $username = null, $hostname = null)
{
    list($username_length, $hostname_length) = PMA_getUsernameAndHostnameLength();
    if (isset($GLOBALS['username']) && strlen($GLOBALS['username']) === 0) {
        $GLOBALS['pred_username'] = '******';
    }
    $html_output = '<fieldset id="fieldset_add_user_login">' . "\n" . '<legend>' . __('Login Information') . '</legend>' . "\n" . '<div class="item">' . "\n" . '<label for="select_pred_username">' . "\n" . '    ' . __('User name:') . "\n" . '</label>' . "\n" . '<span class="options">' . "\n";
    $html_output .= '<select name="pred_username" id="select_pred_username" ' . 'title="' . __('User name') . '">' . "\n";
    $html_output .= '<option value="any"' . (isset($GLOBALS['pred_username']) && $GLOBALS['pred_username'] == 'any' ? ' selected="selected"' : '') . '>' . __('Any user') . '</option>' . "\n";
    $html_output .= '<option value="userdefined"' . (!isset($GLOBALS['pred_username']) || $GLOBALS['pred_username'] == 'userdefined' ? ' selected="selected"' : '') . '>' . __('Use text field') . ':</option>' . "\n";
    $html_output .= '</select>' . "\n" . '</span>' . "\n";
    $html_output .= '<input type="text" name="username" id="pma_username" class="autofocus"' . ' maxlength="' . $username_length . '" title="' . __('User name') . '"' . (empty($GLOBALS['username']) ? '' : ' value="' . htmlspecialchars(isset($GLOBALS['new_username']) ? $GLOBALS['new_username'] : $GLOBALS['username']) . '"') . (!isset($GLOBALS['pred_username']) || $GLOBALS['pred_username'] == 'userdefined' ? 'required="required"' : '') . ' />' . "\n";
    $html_output .= '<div id="user_exists_warning"' . ' name="user_exists_warning" style="display:none;">' . Message::notice(__('An account already exists with the same username ' . 'but possibly a different hostname.'))->getDisplay() . '</div>';
    $html_output .= '</div>';
    $html_output .= '<div class="item">' . "\n" . '<label for="select_pred_hostname">' . "\n" . '    ' . __('Host name:') . "\n" . '</label>' . "\n";
    $html_output .= '<span class="options">' . "\n" . '    <select name="pred_hostname" id="select_pred_hostname" ' . 'title="' . __('Host name') . '"' . "\n";
    $_current_user = $GLOBALS['dbi']->fetchValue('SELECT USER();');
    if (!empty($_current_user)) {
        $thishost = str_replace("'", '', mb_substr($_current_user, mb_strrpos($_current_user, '@') + 1));
        if ($thishost != 'localhost' && $thishost != '127.0.0.1') {
            $html_output .= ' data-thishost="' . htmlspecialchars($thishost) . '" ';
        } else {
            unset($thishost);
        }
    }
    $html_output .= '>' . "\n";
    unset($_current_user);
    // when we start editing a user, $GLOBALS['pred_hostname'] is not defined
    if (!isset($GLOBALS['pred_hostname']) && isset($GLOBALS['hostname'])) {
        switch (mb_strtolower($GLOBALS['hostname'])) {
            case 'localhost':
            case '127.0.0.1':
                $GLOBALS['pred_hostname'] = 'localhost';
                break;
            case '%':
                $GLOBALS['pred_hostname'] = 'any';
                break;
            default:
                $GLOBALS['pred_hostname'] = 'userdefined';
                break;
        }
    }
    $html_output .= '<option value="any"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'any' ? ' selected="selected"' : '') . '>' . __('Any host') . '</option>' . "\n" . '<option value="localhost"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'localhost' ? ' selected="selected"' : '') . '>' . __('Local') . '</option>' . "\n";
    if (!empty($thishost)) {
        $html_output .= '<option value="thishost"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'thishost' ? ' selected="selected"' : '') . '>' . __('This Host') . '</option>' . "\n";
    }
    unset($thishost);
    $html_output .= '<option value="hosttable"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'hosttable' ? ' selected="selected"' : '') . '>' . __('Use Host Table') . '</option>' . "\n";
    $html_output .= '<option value="userdefined"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'userdefined' ? ' selected="selected"' : '') . '>' . __('Use text field:') . '</option>' . "\n" . '</select>' . "\n" . '</span>' . "\n";
    $html_output .= '<input type="text" name="hostname" id="pma_hostname" maxlength="' . $hostname_length . '" value="' . htmlspecialchars(isset($GLOBALS['hostname']) ? $GLOBALS['hostname'] : '%') . '" title="' . __('Host name') . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'userdefined' ? 'required="required"' : '') . ' />' . "\n" . Util::showHint(__('When Host table is used, this field is ignored ' . 'and values stored in Host table are used instead.')) . '</div>' . "\n";
    $html_output .= '<div class="item">' . "\n" . '<label for="select_pred_password">' . "\n" . '    ' . __('Password:'******'</label>' . "\n" . '<span class="options">' . "\n" . '<select name="pred_password" id="select_pred_password" title="' . __('Password') . '">' . "\n" . ($mode == 'change' ? '<option value="keep" selected="selected">' . __('Do not change the password') . '</option>' . "\n" : '') . '<option value="none"';
    if (isset($GLOBALS['username']) && $mode != 'change') {
        $html_output .= '  selected="selected"';
    }
    $html_output .= '>' . __('No Password') . '</option>' . "\n" . '<option value="userdefined"' . (isset($GLOBALS['username']) ? '' : ' selected="selected"') . '>' . __('Use text field') . ':</option>' . "\n" . '</select>' . "\n" . '</span>' . "\n" . '<input type="password" id="text_pma_pw" name="pma_pw" ' . 'title="' . __('Password') . '" ' . (isset($GLOBALS['username']) ? '' : 'required="required"') . '/>' . "\n" . '<span>Strength:</span> ' . '<meter max="4" id="password_strength_meter" name="pw_meter"></meter> ' . '<span id="password_strength" name="pw_strength"></span>' . "\n" . '</div>' . "\n";
    $html_output .= '<div class="item" ' . 'id="div_element_before_generate_password">' . "\n" . '<label for="text_pma_pw2">' . "\n" . '    ' . __('Re-type:') . "\n" . '</label>' . "\n" . '<span class="options">&nbsp;</span>' . "\n" . '<input type="password" name="pma_pw2" id="text_pma_pw2" ' . 'title="' . __('Re-type') . '" ' . (isset($GLOBALS['username']) ? '' : 'required="required"') . '/>' . "\n" . '</div>' . "\n" . '<div class="item" id="authentication_plugin_div">' . '<label for="select_authentication_plugin" >';
    $serverType = Util::getServerType();
    $orig_auth_plugin = PMA_getCurrentAuthenticationPlugin($mode, $username, $hostname);
    if ($serverType == 'MySQL' && PMA_MYSQL_INT_VERSION >= 50507 || $serverType == 'MariaDB' && PMA_MYSQL_INT_VERSION >= 50200) {
        $html_output .= __('Authentication Plugin') . '</label><span class="options">&nbsp;</span>' . "\n";
        $auth_plugin_dropdown = PMA_getHtmlForAuthPluginsDropdown($orig_auth_plugin, $mode, 'new');
    } else {
        $html_output .= __('Password Hashing Method') . '</label><span class="options">&nbsp;</span>' . "\n";
        $auth_plugin_dropdown = PMA_getHtmlForAuthPluginsDropdown($orig_auth_plugin, $mode, 'old');
    }
    $html_output .= $auth_plugin_dropdown;
    $html_output .= '<div ' . ($orig_auth_plugin != 'sha256_password' ? 'style="display:none"' : '') . ' id="ssl_reqd_warning">' . Message::notice(__('This method requires using an \'<i>SSL connection</i>\' ' . 'or an \'<i>unencrypted connection that encrypts the password ' . 'using RSA</i>\'; while connecting to the server.') . Util::showMySQLDocu('sha256-authentication-plugin'))->getDisplay() . '</div>';
    $html_output .= '</div>' . "\n" . '</fieldset>' . "\n";
    return $html_output;
}
    /**
     * Test for PMA_getHtmlForDisplayLoginInformationFields
     *
     * @return void
     */
    public function testPMAGetHtmlForDisplayLoginInformationFields()
    {
        $GLOBALS['username'] = '******';

        $dbi_old = $GLOBALS['dbi'];
        $dbi = $this->getMockBuilder('PMA_DatabaseInterface')
            ->disableOriginalConstructor()
            ->getMock();
        $fields_info = array(
            "Host" => array(
                "Field" => "host",
                "Type" => "char(60)",
                "Null" => "NO",
            )
        );
        $dbi->expects($this->any())->method('getColumns')
            ->will($this->returnValue($fields_info));

        $fetchValue = "fetchValue";
        $dbi->expects($this->any())->method('fetchValue')
            ->will($this->returnValue($fetchValue));

        $GLOBALS['dbi'] = $dbi;

        $html = PMA_getHtmlForDisplayLoginInformationFields();
        list($username_length, $hostname_length)
            = PMA_getUsernameAndHostnameLength();

        //validate 1: __('Login Information')
        $this->assertContains(
            __('Login Information'),
            $html
        );
        $this->assertContains(
            __('User name:'),
            $html
        );
        $this->assertContains(
            __('Any user'),
            $html
        );
        $this->assertContains(
            __('Use text field'),
            $html
        );

        $output = PMA_Util::showHint(
            __(
                'When Host table is used, this field is ignored '
                . 'and values stored in Host table are used instead.'
            )
        );
        $this->assertContains(
            $output,
            $html
        );

        $GLOBALS['dbi'] = $dbi_old;
    }