Fixed vertical alignment of envelope attributes (which I broke last
[squirrelmail.git] / src / redirect.php
index 34e8a568bc2545a9cec7022e6040756d8e06c354..2907ab6d8fb3532e431b5de8d43c84bdfe921eda 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);
@@ -138,13 +143,35 @@ if ($javascript_setting != SMPREF_JS_ON){
 /* Update the prefs */
 setPref($data_dir, $username, 'javascript_on', $js_pref);
 
+global $attachments;
+$attachments = unserialize(getPref($data_dir, $username, 'attachments', 0));
 /* Compute the URL to forward the user to. */
-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);
+       if (is_array($attachments)) {
+          session_register('attachments');
+       }
+    } else {
+       if (is_array($attachments)) {
+          $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
+          foreach ($attachments as $attachment) {
+            $attached_file = $hashed_attachment_dir.'/'.$attachment['localfilename'];
+            if (file_exists($attached_file)) {
+                unlink($attached_file);
+            }
+          }
+          removePref($data_dir, $username, 'attachments');
+       }
+       $redirect_url = 'webmail.php';
+    }
 
 /* Send them off to the appropriate page. */
 header("Location: $redirect_url");