diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php index ea7b32ac1..d9f8aeb62 100644 --- a/libraries/auth/cookie.auth.lib.php +++ b/libraries/auth/cookie.auth.lib.php @@ -16,16 +16,17 @@ if (!isset($coming_from_common)) { exit; } -// timestamp for login timeout -$current_time = time(); - -// Uses faster mcrypt library if available -// (Note: mcrypt.lib.php needs $cookie_path and $is_https) if (function_exists('mcrypt_encrypt') || PMA_dl('mcrypt')) { + /** + * Uses faster mcrypt library if available + * (Note: mcrypt.lib.php needs $cookie_path and $is_https) + */ require_once './libraries/mcrypt.lib.php'; } else { require_once './libraries/blowfish.php'; - // for main.php: + /** + * display warning in main.php + */ define('PMA_WARN_FOR_MCRYPT', 1); } @@ -33,54 +34,69 @@ if (function_exists('mcrypt_encrypt') || PMA_dl('mcrypt')) { /** * Displays authentication form * - * @global string the font face to use - * @global string the default font size to use - * @global string the big font size to use - * @global array the list of servers settings - * @global array the list of available translations - * @global string the current language - * @global integer the current server id - * @global string the currect charset for MySQL - * @global array the array of cookie variables if register_globals is - * off - * - * @return boolean always true (no return indeed) + * @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 $cfg['Servers'] + * @uses $cfg['LoginCookieRecall'] + * @uses $cfg['Lang'] + * @uses $cfg['Server'] + * @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 PMA_VERSION + * @uses file_exists() + * @uses sprintf() + * @uses count() + * @uses htmlspecialchars() + * @uses is_array() + * @global string the last connection error * * @access public */ function PMA_auth() { - global $cfg, $lang, $server, $convcharset, $conn_error; + global $conn_error; /* Perform logout to custom URL */ - if (!empty($_REQUEST['old_usr']) && !empty($GLOBALS['cfg']['Server']['LogoutURL'])) { + if (! empty($_REQUEST['old_usr']) + && ! empty($GLOBALS['cfg']['Server']['LogoutURL'])) { PMA_sendHeaderLocation($GLOBALS['cfg']['Server']['LogoutURL']); exit; } - // Tries to get the username from cookie whatever are the values of the - // 'register_globals' and the 'variables_order' directives if last login - // should be recalled, else skip the IE autocomplete feature. - if ($cfg['LoginCookieRecall'] && !empty($GLOBALS['cfg']['blowfish_secret'])) { - // username - // do not try to use pma_cookie_username as it was encoded differently - // in previous versions and would produce an undefined offset in blowfish - if (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_username-' . $server])) { - $default_user = $_COOKIE['pma_cookie_username-' . $server]; - } - $default_user = isset($default_user) ? PMA_blowfish_decrypt($default_user, $GLOBALS['cfg']['blowfish_secret']) : ''; - - // server name - if (!empty($GLOBALS['pma_cookie_servername'])) { - $default_server = $GLOBALS['pma_cookie_servername']; - } elseif (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_servername-' . $server])) { - $default_server = $_COOKIE['pma_cookie_servername-' . $server]; - } - - $autocomplete = ''; + if ($GLOBALS['cfg']['LoginCookieRecall']) { + $default_user = $GLOBALS['PHP_AUTH_USER']; + $default_server = $GLOBALS['pma_auth_server']; + $autocomplete = ''; } else { - $default_user = ''; - $autocomplete = ' autocomplete="off"'; + $default_user = ''; + $default_server = ''; + // skip the IE autocomplete feature. + $autocomplete = ' autocomplete="off"'; } $cell_align = ($GLOBALS['text_dir'] == 'ltr') ? 'left' : 'right'; @@ -88,7 +104,7 @@ function PMA_auth() // 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_ltr.png'; + $item_img = $GLOBALS['pmaThemeImage'] . 'item_' . $GLOBALS['text_dir'] . '.png'; /* HTML header */ $page_title = 'phpMyAdmin ' . PMA_VERSION; @@ -124,8 +140,8 @@ if (top != self) { ?>