support for picking up attachments in case of a expired session
[squirrelmail.git] / src / redirect.php
index 9b82bee7aa8ff0e2770da716443a2bd30744749d..883d5291535aad13a37462aa3b5128c61bba5c04 100644 (file)
@@ -36,7 +36,10 @@ if (get_magic_quotes_gpc()) {
 
 /* Before starting the session, the base URI must be known. Assuming */
 /* that this file is in the src/ subdirectory (or something).        */
-$base_uri = dirname(dirname($PHP_SELF));
+if (!function_exists('sqm_baseuri')){
+    require_once('../functions/display_messages.php');
+}
+$base_uri = sqm_baseuri();
 
 header('Pragma: no-cache');
 $location = get_location();
@@ -83,11 +86,13 @@ if (!session_is_registered('user_is_logged_in')) {
         logout_error( _("You must be logged in to access this page.") );            
         exit;
     } else {
+        $sqimap_capabilities = sqimap_capability($imapConnection);
+       session_register('sqimap_capabilities');
         $delimiter = sqimap_get_delimiter ($imapConnection);
     }
     sqimap_logout($imapConnection);
     session_register('delimiter');
-
+    global $username;    
     $username = $login_username;
     session_register ('username');
     setcookie('key', $key, 0, $base_uri);
@@ -143,9 +148,20 @@ if(isset($rcptemail)) {
     $redirect_url = 'webmail.php?right_frame=compose.php&rcptaddress=';
     $redirect_url .= $rcptemail;
 } else {
-    $redirect_url = 'webmail.php';
+    global $session_expired_location, $session_expired_post;
+    if (isset($session_expired_location) && $session_expired_location) {
+       $compose_new_win = getPref($data_dir, $username, 'compose_new_win', 0);
+       if ($compose_new_win) {
+          $redirect_url = $session_expired_location;
+       } else {
+          $redirect_url = 'webmail.php?right_frame='.urldecode($session_expired_location);
+       }
+       session_unregister('session_expired_location');
+       unset($session_expired_location);
+    } else {
+       $redirect_url = 'webmail.php';
+    }
 }
-
 /* Send them off to the appropriate page. */
 header("Location: $redirect_url");