Bugfixes in MIME stuff
authorlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 5 Jan 2000 18:17:37 +0000 (18:17 +0000)
committerlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 5 Jan 2000 18:17:37 +0000 (18:17 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@104 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/mime.php
src/download.php

index d6e98d8..068c754 100644 (file)
       /** 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["INFO"]["ID"];
+      $urlmailbox = urlencode($message["INFO"]["MAILBOX"]);
+      $body = "";
+
       if (containsType($message, "text", "html", $ent_num)) {
-         $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+         $body .= decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
       } else if (containsType($message, "text", "plain", $ent_num)) {
-         $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
-         $body = "<TT>" . nl2br($body) . "</TT>";
+         $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+         $body .= "<TT>" . nl2br($tmpbody) . "</TT>";
       }
       // add other primary displaying message types here
       else {
          // find any type that's displayable
          if (containsType($message, "text", "any_type", $ent_num)) {
-            $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
-            $body = "<TT>" . nl2br($body) . "</TT>";
+            $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+            $body .= "<TT>" . nl2br($tmpbody) . "</TT>";
          } else if (containsType($message, "message", "any_type", $ent_num)) {
-            $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
-            $body = "<TT>" . nl2br($body) . "</TT>";
+            $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+            $body .= "<TT>" . nl2br($tmpbody) . "</TT>";
          }
       }
 
-      $body .= "<BR>";
+      $body .= "<BR><SMALL><CENTER><A HREF=\"../src/download.php?absolute_dl=true&passed_id=$id&passed_ent_id=$ent_num&mailbox=$urlmailbox\">Download this as a file</A></CENTER><BR></SMALL>";
 
       /** Display the ATTACHMENTS: message if there's more than one part **/
       if (count($message["ENTITIES"]) > 1) {
             $num++;
             $filename = $message["ENTITIES"][$i]["FILENAME"];
             if (trim($filename) == "") {
-               $filename = "UNKNOWN_FORMAT_" . time() . $i;
-               $display_filename = "Attachment $i";
+               $display_filename = "untitled$i";
             } else {
                $display_filename = $filename;
             }
index 07e6e14..56c5733 100644 (file)
@@ -32,7 +32,7 @@
    $filename = $message["ENTITIES"][$passed_ent_id]["FILENAME"];
 
    if (strlen($filename) < 1) {
-      $filename = "message" . time();
+      $filename = "untitled$passed_ent_id";
    }
 
    if ($absolute_dl == "true") {
@@ -41,8 +41,7 @@
             $body = decodeBody($message["ENTITIES"][$passed_ent_id]["BODY"], $message["ENTITIES"][$passed_ent_id]["ENCODING"]);
             header("Content-type: $type0/$type1");
             header("Content-Disposition: attachment; filename=\"$filename\"");
-            if ($type1 != "html")
-               echo nl2br($body);
+            echo $body;
             break;
          default:
             $body = decodeBody($message["ENTITIES"][$passed_ent_id]["BODY"], $message["ENTITIES"][$passed_ent_id]["ENCODING"]);