From 991a059e3b2b9341adfa5625c2a0b33f6f952908 Mon Sep 17 00:00:00 2001 From: fidian Date: Fri, 16 Feb 2001 13:23:04 +0000 Subject: [PATCH] * Probable bugfixes for attachment code * Not sure if they work perfectly, but it's worth a try. * We need to make 1.0 a branch and 1.1 be the main * Because it's not set up that way, I'll need to patch that version too. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1134 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- src/compose.php | 69 +++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/src/compose.php b/src/compose.php index 0a4db331..abb60da2 100644 --- a/src/compose.php +++ b/src/compose.php @@ -158,37 +158,41 @@ if (!$message) { sqimap_mailbox_select($imapConnection, $mailbox); - $message = sqimap_get_message($imapConnection, $forward_id, $mailbox); } - - if (!$message->entities) { - if ($message->header->entity_id != $ent_num) { - $filename = decodeHeader($message->header->filename); + $message = sqimap_get_message($imapConnection, $forward_id, + $mailbox); + } - if ($filename == "") - $filename = "untitled-".$message->header->entity_id; + if (count($message->entities) == 0) { + if ($message->header->entity_id != $ent_num) { + $filename = decodeHeader($message->header->filename); - $localfilename = md5($filename.", $REMOTE_IP, REMOTE_PORT, $UNIQUE_ID, extra-stuff here"); + if ($filename == "") + $filename = "untitled-".$message->header->entity_id; - // Write File Info - $fp = fopen ($attachment_dir.$localfilename.".info", "w"); - fputs ($fp, strtolower($message->header->type0)."/".strtolower($message->header->type1)."\n".$filename."\n"); - fclose ($fp); - - // Write Attachment to file - $fp = fopen ($attachment_dir.$localfilename, "w"); - fputs ($fp, decodeBody(mime_fetch_body($imapConnection, $forward_id, $message->header->entity_id), $message->header->encoding)); - fclose ($fp); + $localfilename = GenerateRandomString(32, '', 7); - $attachments[$localfilename] = $filename; + // Write File Info + $fp = fopen ($attachment_dir.$localfilename.".info", "w"); + fputs ($fp, strtolower($message->header->type0)."/". + strtolower($message->header->type1)."\n".$filename."\n"); + fclose ($fp); + + // Write Attachment to file + $fp = fopen ($attachment_dir.$localfilename, "w"); + fputs ($fp, decodeBody(mime_fetch_body($imapConnection, + $forward_id, $message->header->entity_id), + $message->header->encoding)); + fclose ($fp); - } + $attachments[$localfilename] = $filename; + } } else { - for ($i = 0; $i < count($message->entities); $i++) { + for ($i = 0; $i < count($message->entities); $i++) { getAttachments($message->entities[$i]); - } + } } return; - } + } function showInputForm () { global $send_to, $send_to_cc, $reply_subj, $forward_subj, $body, @@ -305,7 +309,7 @@ echo " value=\"" . _("Add") ."\">\n"; echo " \n"; echo " \n"; - if (isset($attachments) && count($attachments)>0) { + if (count($attachments) > 0) { echo "\n"; echo " "; echo ""; @@ -483,23 +487,16 @@ } showInputForm(); - } else if (isset($smtpErrors)) { - $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); - displayPageHeader($color, $mailbox); - - $newmail = true; - if ($forward_id && $ent_num) getAttachments(0); - - newMail(); - showInputForm(); - sqimap_logout($imapConnection); } else { - $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); + // This handles the default case as well as the error case + // (they had the same code) --> if (isset($smtpErrors)) + $imapConnection = sqimap_login($username, $key, $imapServerAddress, + $imapPort, 0); displayPageHeader($color, $mailbox); $newmail = true; - - if (isset($forward_id) && isset($ent_num)) getAttachments(0); + if (isset($forward_id) && $forward_id && isset($ent_num) && $ent_num) + getAttachments(0); newMail(); showInputForm(); -- 2.25.1