⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cookie.auth.lib.php

📁 简介:一个用PHP编写的
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/* vim: set expandtab sw=4 ts=4 sts=4: *//** * Set of functions used to run cookie based authentication. * Thanks to Piotr Roszatycki <d3xter at users.sourceforge.net> and * Dan Wilson who built this patch for the Debian package. * * @version $Id: cookie.auth.lib.php 11390 2008-07-15 14:14:09Z lem9 $ */if (! defined('PHPMYADMIN')) {    exit;}if (function_exists('mcrypt_encrypt') || PMA_dl('mcrypt')) {    /**     * Uses faster mcrypt library if available     */    require_once './libraries/mcrypt.lib.php';} else {    require_once './libraries/blowfish.php';    /**     * display warning in main.php     */    define('PMA_WARN_FOR_MCRYPT', 1);}/** * Displays authentication form * * this function MUST exit/quit the application * * @uses    $GLOBALS['server'] * @uses    $GLOBALS['PHP_AUTH_USER'] * @uses    $GLOBALS['pma_auth_server'] * @uses    $GLOBALS['text_dir'] * @uses    $GLOBALS['pmaThemeImage'] * @uses    $GLOBALS['charset'] * @uses    $GLOBALS['target'] * @uses    $GLOBALS['db'] * @uses    $GLOBALS['table'] * @uses    $GLOBALS['PMA_errors'] * @uses    $GLOBALS['convcharset'] * @uses    $GLOBALS['lang'] * @uses    $GLOBALS['strWelcome'] * @uses    $GLOBALS['strSecretRequired'] * @uses    $GLOBALS['strError'] * @uses    $GLOBALS['strLogin'] * @uses    $GLOBALS['strLogServer'] * @uses    $GLOBALS['strLogUsername'] * @uses    $GLOBALS['strLogPassword'] * @uses    $GLOBALS['strServerChoice'] * @uses    $GLOBALS['strGo'] * @uses    $GLOBALS['strCookiesRequired'] * @uses    $GLOBALS['strPmaDocumentation'] * @uses    $GLOBALS['pmaThemeImage'] * @uses    $cfg['Servers'] * @uses    $cfg['LoginCookieRecall'] * @uses    $cfg['Lang'] * @uses    $cfg['Server'] * @uses    $cfg['ReplaceHelpImg'] * @uses    $cfg['blowfish_secret'] * @uses    $cfg['AllowArbitraryServer'] * @uses    $_COOKIE * @uses    $_REQUEST['old_usr'] * @uses    PMA_sendHeaderLocation() * @uses    PMA_select_language() * @uses    PMA_select_server() * @uses    file_exists() * @uses    sprintf() * @uses    count() * @uses    htmlspecialchars() * @uses    is_array() * @global  string    the last connection error * * @access  public */function PMA_auth(){    global $conn_error;    /* Perform logout to custom URL */    if (! empty($_REQUEST['old_usr'])     && ! empty($GLOBALS['cfg']['Server']['LogoutURL'])) {        PMA_sendHeaderLocation($GLOBALS['cfg']['Server']['LogoutURL']);        exit;    }    if ($GLOBALS['cfg']['LoginCookieRecall']) {        $default_user   = $GLOBALS['PHP_AUTH_USER'];        $default_server = $GLOBALS['pma_auth_server'];        $autocomplete   = '';    } else {        $default_user   = '';        $default_server = '';        // skip the IE autocomplete feature.        $autocomplete   = ' autocomplete="off"';    }    $cell_align = ($GLOBALS['text_dir'] == 'ltr') ? 'left' : 'right';    // Defines the charset to be used    header('Content-Type: text/html; charset=' . $GLOBALS['charset']);    // Defines the "item" image depending on text direction    $item_img = $GLOBALS['pmaThemeImage'] . 'item_' . $GLOBALS['text_dir'] . '.png';    /* HTML header; do not show here the PMA version to improve security  */    $page_title = 'phpMyAdmin ';    require './libraries/header_meta_style.inc.php';    ?><script type="text/javascript">//<![CDATA[// show login form in top frameif (top != self) {    window.top.location.href=location;}//]]></script></head><body class="loginform">    <?php    if (file_exists('./config.header.inc.php')) {          require './config.header.inc.php';    }    ?><div class="container"><a href="http://www.phpmyadmin.net" target="_blank" class="logo"><?php    $logo_image = $GLOBALS['pmaThemeImage'] . 'logo_right.png';    if (@file_exists($logo_image)) {        echo '<img src="' . $logo_image . '" id="imLogo" name="imLogo" alt="phpMyAdmin" border="0" />';    } else {        echo '<img name="imLogo" id="imLogo" src="' . $GLOBALS['pmaThemeImage'] . 'pma_logo.png' . '" '           . 'border="0" width="88" height="31" alt="phpMyAdmin" />';    }    ?></a><h1>    <?php    echo sprintf($GLOBALS['strWelcome'],        '<bdo dir="ltr" xml:lang="en">' . $page_title . '</bdo>');    ?></h1>    <?php    // Show error message    if (! empty($conn_error)) {        echo '<div class="error"><h1>' . $GLOBALS['strError'] . '</h1>' . "\n";        echo $conn_error . '</div>' . "\n";    }    // Displays the languages form    if (empty($GLOBALS['cfg']['Lang'])) {        require_once './libraries/display_select_lang.lib.php';        PMA_select_language(true);    }    // Displays the warning message and the login form    if (empty($GLOBALS['cfg']['blowfish_secret'])) {        ?>        <div class="error"><h1><?php echo $GLOBALS['strError']; ?></h1>            <?php echo $GLOBALS['strSecretRequired']; ?>        </div>        <?php        echo '</div>' . "\n";        if (file_exists('./config.footer.inc.php')) {            require './config.footer.inc.php';        }        echo '</body></html>';        exit;    }    ?><br /><!-- Login form --><form method="post" action="index.php" name="login_form"<?php echo $autocomplete; ?> target="_top" class="login">    <fieldset>    <legend><?php     echo $GLOBALS['strLogin'];     echo '<a href="./Documentation.html" target="documentation" ' .        'title="' . $GLOBALS['strPmaDocumentation'] . '">';    if ($GLOBALS['cfg']['ReplaceHelpImg']) {        echo '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_help.png" width="11" height="11" alt="' . $GLOBALS['strPmaDocumentation'] . '" />';    } else {        echo '(*)';    }    echo '</a>';?></legend><?php if ($GLOBALS['cfg']['AllowArbitraryServer']) { ?>        <div class="item">            <label for="input_servername"><?php echo $GLOBALS['strLogServer']; ?></label>            <input type="text" name="pma_servername" id="input_servername" value="<?php echo htmlspecialchars($default_server); ?>" size="24" class="textfield" />        </div><?php } ?>        <div class="item">            <label for="input_username"><?php echo $GLOBALS['strLogUsername']; ?></label>            <input type="text" name="pma_username" id="input_username" value="<?php echo htmlspecialchars($default_user); ?>" size="24" class="textfield" />        </div>        <div class="item">            <label for="input_password"><?php echo $GLOBALS['strLogPassword']; ?></label>            <input type="password" name="pma_password" id="input_password" value="" size="24" class="textfield" />        </div>    <?php    if (count($GLOBALS['cfg']['Servers']) > 1) {        ?>        <div class="item">            <label for="select_server"><?php echo $GLOBALS['strServerChoice']; ?>:</label>            <select name="server" id="select_server"        <?php        if ($GLOBALS['cfg']['AllowArbitraryServer']) {            echo ' onchange="document.forms[\'login_form\'].elements[\'pma_servername\'].value = \'\'" ';        }        echo '>';        require_once './libraries/select_server.lib.php';        PMA_select_server(false, false);        echo '</select></div>';    } else {        echo '    <input type="hidden" name="server" value="' . $GLOBALS['server'] . '" />';    } // end if (server choice)    ?>    </fieldset>    <fieldset class="tblFooters">        <input value="<?php echo $GLOBALS['strGo']; ?>" type="submit" />        <input type="hidden" name="lang" value="<?php echo $GLOBALS['lang']; ?>" />        <input type="hidden" name="convcharset" value="<?php echo htmlspecialchars($GLOBALS['convcharset'], ENT_QUOTES); ?>" />    <?php    if (!empty($GLOBALS['target'])) {        echo '            <input type="hidden" name="target" value="' . htmlspecialchars($GLOBALS['target']) . '" />' . "\n";    }    if (!empty($GLOBALS['db'])) {        echo '            <input type="hidden" name="db" value="' . htmlspecialchars($GLOBALS['db']) . '" />' . "\n";    }    if (!empty($GLOBALS['table'])) {        echo '            <input type="hidden" name="table" value="' . htmlspecialchars($GLOBALS['table']) . '" />' . "\n";    }    ?>    </fieldset></form>    <?php    // show the "Cookies required" message only if cookies are disabled    // (we previously tried to set some cookies)    if (empty($_COOKIE)) {        echo '<div class="notice">' . $GLOBALS['strCookiesRequired'] . '</div>' . "\n";    }    if (! empty($GLOBALS['PMA_errors']) && is_array($GLOBALS['PMA_errors'])) {        foreach ($GLOBALS['PMA_errors'] as $error) {            echo '<div class="error">' . $error . '</div>' . "\n";        }    }    // the warning is also displayed on main page but show it also here,    // because on some PHP versions running on 64-bit, the blowfish library    // does not work and this would prevent login    if (defined('PMA_WARN_FOR_MCRYPT')) {        echo '<div class="warning">' . PMA_sanitize(sprintf($GLOBALS['strCantLoad'], 'mcrypt')) . '</div>' . "\n";    }    ?></div><script type="text/javascript">// <![CDATA[function PMA_focusInput(){    var input_username = document.getElementById('input_username');    var input_password = document.getElementById('input_password');    if (input_username.value == '') {        input_username.focus();    } else {        input_password.focus();    }}window.setTimeout('PMA_focusInput()', 500);// ]]></script></body></html>    <?php    if (file_exists('./config.footer.inc.php')) {         require './config.footer.inc.php';    }    exit;} // end of the 'PMA_auth()' function/** * Gets advanced authentication settings * * this function DOES NOT check authentication - it just checks/provides * authentication credentials required to connect to the MySQL server * usally with PMA_DBI_connect() * * it returns false if there is missing something - which usally leads to * PMA_auth() which displays login form * * it returns true if all seems ok which usally leads to PMA_auth_set_user() * * it directly switches to PMA_auth_fails() if user inactivity timout is reached * * @todo    AllowArbitraryServer on does not imply that the user wnats an *          arbitrary server, or? so we should also check if this is filled and

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -