From 8d8ab69aaf81e9fdd15396c783f0e40e698e839f Mon Sep 17 00:00:00 2001 From: lkehresman Date: Sat, 8 Jul 2000 11:59:01 +0000 Subject: [PATCH] Fixed major problems with IMAP session handling in the MIME code. This 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 | 2 ++ functions/imap_messages.php | 6 +++--- functions/mime.php | 15 ++++----------- src/compose.php | 24 ++++++++++++++++-------- src/read_body.php | 2 +- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8fbb88d2..2f028ac1 100644 --- 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. diff --git a/functions/imap_messages.php b/functions/imap_messages.php index 89be0e2a..e3e23b2b 100755 --- a/functions/imap_messages.php +++ b/functions/imap_messages.php @@ -117,7 +117,7 @@ ******************************************************************************/ 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; } @@ -326,7 +326,7 @@ /****************************************************************************** ** 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); @@ -342,7 +342,7 @@ $i++; } */ - return decodeMime($body, &$header); + return decodeMime($imap_stream, $body, &$header); } diff --git a/functions/mime.php b/functions/mime.php index ab021936..765e140d 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -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 "$read

"; @@ -360,13 +361,9 @@ /** 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 @@ -420,7 +417,7 @@ 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. @@ -429,12 +426,8 @@ $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 diff --git a/src/compose.php b/src/compose.php index 0b90800d..e0a7ca74 100644 --- a/src/compose.php +++ b/src/compose.php @@ -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); @@ -65,23 +66,30 @@ $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; } diff --git a/src/read_body.php b/src/read_body.php index 022ddd01..964f79d5 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -273,7 +273,7 @@ echo " "; echo " \n"; - $body = formatBody($message, $color, $wrap_at); + $body = formatBody($imapConnection, $message, $color, $wrap_at); echo "
"; echo "$body"; -- 2.25.1