From cb48c2455cde2cf6ba67944c45decc4eca7df306 Mon Sep 17 00:00:00 2001 From: philippe_mingo Date: Tue, 27 Nov 2001 19:10:28 +0000 Subject: [PATCH] Fixed login crash git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1812 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/imap_general.php | 20 ++++----- src/login.php | 16 +------ src/redirect.php | 90 ++++++++++++++++++-------------------- 3 files changed, 53 insertions(+), 73 deletions(-) diff --git a/functions/imap_general.php b/functions/imap_general.php index 1826d912..8bd2485a 100755 --- a/functions/imap_general.php +++ b/functions/imap_general.php @@ -20,15 +20,12 @@ */ function sqimap_session_id() { - if (session_id() == '') - global $RememberedSessionID; - - if (! isset($RememberedSessionID)) - $RememberedSessionID = GenerateRandomString(4, '', 7); - else - $RememberedSessionID = substr(session_id(), -4); + $IMAPSessionID = substr(session_id(), -4); + if( $IMAPSessionID == '' ) { + $IMAPSessionID = GenerateRandomString(4, '', 7); + } - return( $RememberedSessionID ); + return( $IMAPSessionID ); } @@ -142,12 +139,13 @@ ** will be displayed. This function returns the imap connection handle. ******************************************************************************/ function sqimap_login ($username, $password, $imap_server_address, $imap_port, $hide) { + global $color, $squirrelmail_language, $HTTP_ACCEPT_LANGUAGE, $onetimepad; - $imap_stream = fsockopen ($imap_server_address, $imap_port, - $error_number, $error_string, 15); + $imap_stream = fsockopen ( $imap_server_address, $imap_port, + $error_number, $error_string, 15); $server_info = fgets ($imap_stream, 1024); - + // Decrypt the password $password = OneTimePadDecrypt($password, $onetimepad); diff --git a/src/login.php b/src/login.php index 11537e7d..dc1d6662 100644 --- a/src/login.php +++ b/src/login.php @@ -53,21 +53,7 @@ $rcptaddress = urlencode($rcptaddress); } - /* Check if system has been configured */ - if ( !file_exists( '../config/config.php' ) ) { - echo "\n". - "\n". - '' . _("Configuration Error") . "\n". - "\n". - "\n" . - '

' . - _("This system has not been configured yet.") . - '
' . - _("Please contact system administrator.") . - '

'. - "\n"; - exit; - } + require_once('../functions/strings.php'); require_once('../config/config.php'); diff --git a/src/redirect.php b/src/redirect.php index 38802107..f4091057 100644 --- a/src/redirect.php +++ b/src/redirect.php @@ -15,6 +15,29 @@ require_once('../functions/i18n.php'); require_once('../functions/strings.php'); require_once('../config/config.php'); + require_once('../functions/prefs.php'); + require_once('../functions/imap.php'); + require_once('../functions/plugin.php'); + require_once('../functions/constants.php'); + + function attachment_common_parse($str, $debug) { + global $attachment_common_types, $attachment_common_types_parsed; + + $attachment_common_types_parsed[$str] = true; + $types = explode(', ', $str); + + foreach ($types as $val) + { + // Ignore the ";q=1.0" stuff + if (strpos($val, ';') !== false) + $val = substr($val, 0, strpos($val, ';')); + + if (! isset($attachment_common_types[$val])) { + $attachment_common_types[$val] = true; + } + } + } + /* Before starting the session, the base URI must be known. Assuming */ /* that this file is in the src/ subdirectory (or something). */ @@ -30,32 +53,25 @@ session_unregister ('user_is_logged_in'); session_register ('base_uri'); - if (! isset($squirrelmail_language)) { - $squirrelmail_language = ''; + if (! isset($squirrelmail_language) || + $squirrelmail_language == '' ) { + $squirrelmail_language = $squirrelmail_default_language; } set_up_language($squirrelmail_language, true); + /* Refresh the language cookie. */ + setcookie('squirrelmail_language', $squirrelmail_language, time()+2592000,$base_uri); if (!isset($login_username)) { - echo "\n"; - echo "

\n"; - echo "
\n"; - echo ' ' . _("You must be logged in to access this page.") . "
"; - echo ' ' . _("Go to the login page") . "\n"; - echo "
\n"; - echo "\n"; + echo "\n" . + "
 
\n" . + "
\n" . + '' . _("You must be logged in to access this page.") . "
" . + '' . _("Go to the login page") . "\n" . + "
\n" . + "\n"; exit; } - /* Refresh the language cookie. */ - if (isset($squirrelmail_language)) { - setcookie('squirrelmail_language', $squirrelmail_language, time()+2592000,$base_uri); - } - - require_once('../functions/prefs.php'); - require_once('../functions/imap.php'); - require_once('../functions/plugin.php'); - require_once('../functions/constants.php'); - if (!session_is_registered('user_is_logged_in')) { do_hook ('login_before'); @@ -67,16 +83,16 @@ if ($force_username_lowercase) { $login_username = strtolower($login_username); } - + $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0); if (!$imapConnection) { - echo "\n"; - echo "

"; - echo "
"; - echo ""._("There was an error contacting the mail server.")."
"; - echo _("Contact your administrator for help.")."\n"; - echo "
"; - echo "\n"; + echo "\n". + "

\n". + "
\n". + '' . _("There was an error contacting the mail server.") . "
\n". + _("Contact your administrator for help.") . "\n". + "
\n". + "\n"; exit; } else { $delimiter = sqimap_get_delimiter ($imapConnection); @@ -138,24 +154,4 @@ /* Send them off to the appropriate page. */ header("Location: $redirect_url"); - -function attachment_common_parse($str, $debug) -{ - global $attachment_common_types, $attachment_common_types_parsed; - - $attachment_common_types_parsed[$str] = true; - $types = explode(', ', $str); - - foreach ($types as $val) - { - // Ignore the ";q=1.0" stuff - if (strpos($val, ';') !== false) - $val = substr($val, 0, strpos($val, ';')); - - if (! isset($attachment_common_types[$val])) { - $attachment_common_types[$val] = true; - } - } -} - ?> -- 2.25.1