Fixed major problems with IMAP session handling in the MIME code. This
authorlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 8 Jul 2000 11:59:01 +0000 (11:59 +0000)
committerlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 8 Jul 2000 11:59:01 +0000 (11:59 +0000)
fixed a bunch of bugs including "reply", "forward", and the weird attachment
problem I was having.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@604 7612ce4b-ef26-0410-bec9-ea0150e637f0

ChangeLog
functions/imap_messages.php
functions/mime.php
src/compose.php
src/read_body.php

index 8fbb88d27798a8994f8b4df0d421fa918f7638e8..2f028ac1808a5863f6c628c9a8db6ebb240baecd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 Version 0.5pre1 -- DEVELOPMENT
 ------------------------------
+- Removed a bunch of annoying "success" screens
+- Better IMAP session handling
 - Redid the options section and split it into different parts
 - Added "view all headers" option when reading a message
 - In-Reply-To and References headers are inserted when replying to a message.
index 89be0e2a4dd51dec2245a14c758700877539985a..e3e23b2b4cdb180e82002aed4e458d8e32a9f2ed 100755 (executable)
     ******************************************************************************/
    function sqimap_get_message ($imap_stream, $id, $mailbox) {
       $header = sqimap_get_message_header($imap_stream, $id, $mailbox);
-      $msg = sqimap_get_message_body(&$header);
+      $msg = sqimap_get_message_body($imap_stream, &$header);
       return $msg;
    }
 
    /******************************************************************************
     **  Returns the body of a message.
     ******************************************************************************/
-   function sqimap_get_message_body (&$header) {
+   function sqimap_get_message_body ($imap_stream, &$header) {
       $id = $header->id;
       //fputs ($imap_stream, "a001 FETCH $id:$id BODY[TEXT]\r\n");
       //$read = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
          $i++;
       }
       */
-      return decodeMime($body, &$header);
+      return decodeMime($imap_stream, $body, &$header);
    }
 
 
index ab021936083a3b2e1847d0954967c566843036a1..765e140d30fffd8c5de4af6fbb1d4c703b8c9fce 100644 (file)
@@ -59,6 +59,7 @@
       $id = $header->id;
       fputs ($imap_stream, "a001 FETCH $id BODYSTRUCTURE\r\n");
       $read = fgets ($imap_stream, 10000);
+      $endline = fgets($imap_stream, 1024);
       $read = strtolower($read);
 
       if ($debug_mime) echo "<tt>$read</tt><br><br>";
    /** This is the first function called.  It decides if this is a multipart
        message or if it should be handled as a single entity
     **/
-   function decodeMime ($body, $header) {
+   function decodeMime ($imap_stream, $body, $header) {
       global $username, $key, $imapServerAddress, $imapPort;
-      $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
-      sqimap_mailbox_select($imap_stream, $header->mailbox);
-      $struct = mime_structure ($imap_stream, $header);
-      sqimap_logout($imap_stream);
-      return $struct;
+      return mime_structure ($imap_stream, $header);
    }
 
    // This is here for debugging purposese.  It will print out a list
        everything needed, including HTML Tags, Attachments at the
        bottom, etc.
     **/
-   function formatBody($message, $color, $wrap_at) {
+   function formatBody($imap_stream, $message, $color, $wrap_at) {
       // this if statement checks for the entity to show as the
       // primary message. To add more of them, just put them in the
       // order that is their priority.
       $id = $message->header->id;
       $urlmailbox = urlencode($message->header->mailbox);
 
-      $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
-      sqimap_mailbox_select($imap_stream, $message->header->mailbox);
-
       $ent_num = findDisplayEntity ($message);
       $body = mime_fetch_body ($imap_stream, $id, $ent_num); 
-      sqimap_logout($imap_stream); 
 
       // If there are other types that shouldn't be formatted, add
       // them here 
index 0b90800d4ec53e75e8da29635901e0145f1944cb..e0a7ca74c0041f3a295689ce90cfd09658a7aa23 100644 (file)
@@ -53,6 +53,7 @@
       if ($id) {
          sqimap_mailbox_select($imapConnection, $mailbox);
          $message = sqimap_get_message($imapConnection, $id, $mailbox);
+         $orig_header = $message->header;
          if ($ent_num)
             $message = getEntity($message, $ent_num);
 
             $body = "";
          }
          
-         if ($forward_id)
-            $tmp = _("-------- Original Message ---------\n");
          if ($message->header->type1 == "html")
             $body = strip_tags($body);
             
          $body_ary = explode("\n", $body);
          $body = "";
          for ($i=0; $i < count($body_ary); $i++) {
-            if ($i==0 && $forward_id)
-               $tmp = _("-------- Original Message ---------\n") . $body_ary[$i];
-            else
+            if ($i==0 && $forward_id) {
+               $tmp = _("-------- Original Message ---------\n");
+               $tmp .= _("Subject") . ": " . $orig_header->subject . "\n"; 
+               $tmp .= "   " . _("From") . ": " . $orig_header->from . "\n"; 
+               $tmp .= "     " . _("To") . ": " . $orig_header->to[0] . "\n"; 
+               if (count($orig_header->to) > 1) {
+                  for ($x=1; $x < count($orig_header->to); $x++) {
+                     $tmp .= "         " . $orig_header->to[$x] . "\n";
+                  }
+               }
+               $tmp .= "\n" . $body_ary[$i];
+            } else {
                $tmp = $body_ary[$i];
-            
+            }
             if ($forward_id)
-               $body .= "$body$tmp\n";
+               $body = "$body$tmp\n";
             else
-               $body .= "$body> $tmp\n";
+               $body = "$body> $tmp\n";
          }
          return $body;   
       }
index 022ddd014ba3748316cc00112fb990f6b8ed31d7..964f79d58ff14fa04bbe0efd47db80d5edf85118 100644 (file)
    echo "   </TD></TR>";
 
    echo "   <TR><TD BGCOLOR=\"$color[4]\" WIDTH=100%>\n";
-   $body = formatBody($message, $color, $wrap_at);
+   $body = formatBody($imapConnection, $message, $color, $wrap_at);
    echo "<BR>";
 
    echo "$body";