* Probable bugfixes for attachment code
authorfidian <fidian@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 16 Feb 2001 13:23:04 +0000 (13:23 +0000)
committerfidian <fidian@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 16 Feb 2001 13:23:04 +0000 (13:23 +0000)
* 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

index 0a4db331b3595cafcbeff1e701822ab9ec5ff6cd..abb60da22ca6ceaf3632a460fc0e53c6245433c6 100644 (file)
       
       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,
       echo " value=\"" . _("Add") ."\">\n";
       echo "     </td>\n";
       echo "   </tr>\n";
-      if (isset($attachments) && count($attachments)>0) {
+      if (count($attachments) > 0) {
          echo "<tr><td bgcolor=\"$color[0]\" align=right>\n";
          echo "&nbsp;";
          echo "</td><td align=left bgcolor=\"$color[0]\">";
       }
 
       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();