added debugging
[squirrelmail.git] / functions / mime.php
index cc00e3c771f94d582e139a6055ce9d77b74cd053..f61322bf1f30b9d2e6f91323bdf3334e11748e6b 100644 (file)
@@ -11,6 +11,7 @@
    function decodeMime($body, $bound, $type0, $type1, &$entities) {
       if ($type0 == "multipart") {
          $bound = trim($bound);
+         $i = 0;
          while (($i < count($body)) && (substr($body[$i], 0, strlen("--$bound--")) != "--$bound--")) {
             if (trim($body[$i]) == "--$bound") {
                $j = $i+1;
        as the actual message in the HTML.   It contains everything needed, including
        HTML Tags, Attachments at the bottom, etc.
     **/
-   function formatBody($message, $color) {
+   function formatBody($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["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)) {
-         $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
-         $body .= "<TT>" . nl2br(trim($tmpbody)) . "</TT>";
+         $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
       }
       // add other primary displaying message types here
       else {
          // find any type that's displayable
          if (containsType($message, "text", "any_type", $ent_num)) {
-            $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
-            $body .= "<TT>" . nl2br(trim($tmpbody)) . "</TT>";
+            $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
          } else if (containsType($message, "message", "any_type", $ent_num)) {
-            $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
-            $body .= "<TT>" . nl2br(trim($tmpbody)) . "</TT>";
+            $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
          }
       }
 
       /** If there are other types that shouldn't be formatted, add them here **/
       if ($message["ENTITIES"][$ent_num]["TYPE1"] != "html")
-         $body = translateText($body);
+         $body = translateText($body, $wrap_at);
+
 
       $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>";