X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Fredirect.php;h=d8253f638c8f2e2c4f3fb6a67a3bb557d342df38;hp=cc2dde99ef55e55997ca827cb81ed9ebf2b0bbd3;hb=f2ad47f19d5b71cca9d4d50095d0f9306d5e74cf;hpb=9a02b0ef32c5d5369c6e0cbd1fada0e19f3d66cc diff --git a/src/redirect.php b/src/redirect.php index cc2dde99..d8253f63 100644 --- a/src/redirect.php +++ b/src/redirect.php @@ -5,7 +5,7 @@ * * Derived from webmail.php by Ralf Kraudelt * - * @copyright © 1999-2007 The SquirrelMail Project Team + * @copyright 1999-2010 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ * @package squirrelmail @@ -23,7 +23,11 @@ require('../include/init.php'); require_once(SM_PATH . 'functions/imap_general.php'); require_once(SM_PATH . 'functions/strings.php'); +// Disable browser caching +// +header('Cache-Control: no-cache, no-store, must-revalidate, max-age=0'); header('Pragma: no-cache'); +header('Expires: Sat, 1 Jan 2000 00:00:00 GMT'); $location = get_location(); // session_set_cookie_params (0, $base_uri); @@ -70,10 +74,23 @@ if ($force_username_lowercase) { $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0); /* From now on we are logged it. If the login failed then sqimap_login handles it */ -/* regenerate the session id to avoid session hyijacking */ -sqsession_destroy(); -@sqsession_is_active(); -session_regenerate_id(); +/** + * Regenerate session id to make sure that authenticated session uses + * different ID than one used before user authenticated. This is a + * countermeasure against session fixation attacks. + * NB: session_regenerate_id() was added in PHP 4.3.2 (and new session + * cookie is only sent out in this call as of PHP 4.3.3), but PHP 4 + * is not vulnerable to session fixation problems in SquirrelMail + * because it prioritizes $base_uri subdirectory cookies differently + * than PHP 5, which is otherwise vulnerable. If we really want to, + * we could define our own session_regenerate_id() when one does not + * exist, but there seems to be no reason to do so. + */ +sqsession_is_active(); +if (function_exists('session_regenerate_id')) { + session_regenerate_id(); +} + /** * The cookie part. session_start and session_regenerate_session normally set * their own cookie. SquirrelMail sets another cookie which overwites the @@ -135,6 +152,12 @@ if ( sqgetGlobalVar('HTTP_ACCEPT', $http_accept, SQ_SERVER) && attachment_common_parse($http_accept); } +// having just logged in, need to synch the template file cache +// so the right template set is displayed (per user prefs) +require(SM_PATH . 'include/load_prefs.php'); +global $sTemplateID; +Template::cache_template_file_hierarchy($sTemplateID, TRUE); + /* Complete autodetection of Javascript. */ checkForJavascript(); @@ -148,10 +171,13 @@ if ( sqgetGlobalVar('session_expired_location', $session_expired_location, SQ_SE if ($compose_new_win) { // do not prefix $location here because $session_expired_location is set to the PAGE_NAME // of the last page - $redirect_url = $session_expired_location.'.php'; + $redirect_url = $location . '/' . $session_expired_location . '.php'; } else { - $redirect_url = $location.'/webmail.php?right_frame='.urlencode($session_expired_location).'php'; + $redirect_url = $location . '/webmail.php?right_frame=' . urlencode($session_expired_location . '.php'); } + } else if ($session_expired_location != 'webmail' + && $session_expired_location != 'left_main') { + $redirect_url = $location . '/webmail.php?right_frame=' . urlencode($session_expired_location . '.php'); } unset($session_expired_location); }