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;
/** If this isn't a multipart message **/
$j = 0;
$entity_body = "";
- while ((substr(trim($body[$j]), 0, strlen("--$bound")) != "--$bound") && ($j < count($body))) {
+ while ($j < count($body)) {
$entity_body .= $body[$j];
$j++;
}
as the actual message in the HTML. It contains everything needed, including
HTML Tags, Attachments at the bottom, etc.
**/
- function formatBody($message) {
- include ("../config/config.php");
+ 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"]);
+
if (containsType($message, "text", "html", $ent_num)) {
$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>";
}
// 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>";
} 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>";
}
}
- $body .= "<BR>";
+ /** If there are other types that shouldn't be formatted, add them here **/
+ if ($message["ENTITIES"][$ent_num]["TYPE1"] != "html")
+ $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>";
/** 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;
}
$newbody = $body; // if only they all were this easy
} else if ($encoding == "quoted-printable") {
- echo "$body";
- $body = ereg_replace("=3D", "=", $body);
- $body = ereg_replace("=\n", "", $body);
- $body = ereg_replace("=20", "\n", $body);
- $newbody= $body;
+ $body_ary = explode("\n", $body);
+
+ for ($q=0; $q < count($body_ary); $q++) {
+ if (substr(trim($body_ary[$q]), -1) == "=") {
+ $body_ary[$q] = trim($body_ary[$q]);
+ $body_ary[$q] = substr($body_ary[$q], 0, strlen($body_ary[$q])-1);
+ } else if (substr(trim($body_ary[$q]), -3) == "=20") {
+ $body_ary[$q] = trim($body_ary[$q]);
+ $body_ary[$q] = substr($body_ary[$q], 0, strlen($body_ary[$q])-3);
+ $body_ary[$q] = "$body_ary[$q]\n";
+ }
+ }
+ for ($q=0;$q < count($body_ary);$q++) {
+ $body_ary[$q] = ereg_replace("=3D", "=", $body_ary[$q]);
+ }
+
+ $body = "";
+ for ($i = 0; $i < count($body_ary); $i++) {
+ $body .= "$body_ary[$i]\n";
+ }
+
+ $newbody = $body;
} else if ($encoding == "base64") {
$newbody = base64_decode($body);
}
return $newbody;
}
-?>
\ No newline at end of file
+?>