and * Dan Wilson who built this patch for the Debian package. * * @version $Id: cookie.auth.lib.php 12277 2009-03-03 13:30:49Z nijel $ */ if (! defined('PHPMYADMIN')) { exit; } require './libraries/auth/swekey/swekey.auth.lib.php'; if (function_exists('mcrypt_encrypt')) { /** * Uses faster mcrypt library if available * (as this is not called from anywhere else, put the code in-line * for faster execution) */ /** * Initialization * Store the initialization vector because it will be needed for * further decryption. I don't think necessary to have one iv * per server so I don't put the server number in the cookie name. */ if (empty($_COOKIE['pma_mcrypt_iv']) || false === ($iv = base64_decode($_COOKIE['pma_mcrypt_iv'], true))) { srand((double) microtime() * 1000000); $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_CBC), MCRYPT_RAND); PMA_setCookie('pma_mcrypt_iv', base64_encode($iv)); } /** * Encryption using blowfish algorithm (mcrypt) * * @param string original data * @param string the secret * * @return string the encrypted result * * @access public * * @author lem9 */ function PMA_blowfish_encrypt($data, $secret) { global $iv; return base64_encode(mcrypt_encrypt(MCRYPT_BLOWFISH, $secret, $data, MCRYPT_MODE_CBC, $iv)); } /** * Decryption using blowfish algorithm (mcrypt) * * @param string encrypted data * @param string the secret * * @return string original data * * @access public * * @author lem9 */ function PMA_blowfish_decrypt($encdata, $secret) { global $iv; return trim(mcrypt_decrypt(MCRYPT_BLOWFISH, $secret, base64_decode($encdata), MCRYPT_MODE_CBC, $iv)); } } else { require_once './libraries/blowfish.php'; trigger_error(PMA_sanitize(sprintf($strCantLoad, 'mcrypt')), E_USER_WARNING); } /** * Returns blowfish secret or generates one if needed. * @uses $cfg['blowfish_secret'] * @uses $_SESSION['auto_blowfish_secret'] * * @access public */ function PMA_get_blowfish_secret() { if (empty($GLOBALS['cfg']['blowfish_secret'])) { if (empty($_SESSION['auto_blowfish_secret'])) { $_SESSION['auto_blowfish_secret'] = uniqid('', true); } return $_SESSION['auto_blowfish_secret']; } else { return $GLOBALS['cfg']['blowfish_secret']; } } /** * 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['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; } /* No recall if blowfish secret is not configured as it would produce garbage */ if ($GLOBALS['cfg']['LoginCookieRecall'] && !empty($GLOBALS['cfg']['blowfish_secret'])) { $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'; ?>