|
@@ -45,15 +45,6 @@
|
|
}
|
|
}
|
|
$ent = decodeMime($ent_body, $ent_bound, $ent_type0, $ent_type1, $entities);
|
|
$ent = decodeMime($ent_body, $ent_bound, $ent_type0, $ent_type1, $entities);
|
|
$entities = $ent;
|
|
$entities = $ent;
|
|
- } else if ($ent_type0 == "text") {
|
|
|
|
- while (substr(trim($body[$j]), 0, strlen("--$bound")) != "--$bound") {
|
|
|
|
- $entity_body[$p] = $body[$j];
|
|
|
|
- $j++;
|
|
|
|
- $p++;
|
|
|
|
- }
|
|
|
|
- $count = count($entities);
|
|
|
|
- $entities[$count] = getEntity($entity_body, $ent_bound, $ent_type0, $ent_type1, $encoding, $charset, $filename);
|
|
|
|
-
|
|
|
|
} else {
|
|
} else {
|
|
$j++;
|
|
$j++;
|
|
$entity_body = "";
|
|
$entity_body = "";
|
|
@@ -68,8 +59,16 @@
|
|
$i++;
|
|
$i++;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
|
|
+ /** If this isn't a multipart message **/
|
|
|
|
+ $j = 0;
|
|
|
|
+ $entity_body = "";
|
|
|
|
+ while ((substr(trim($body[$j]), 0, strlen("--$bound")) != "--$bound") && ($j < count($body))) {
|
|
|
|
+ $entity_body .= $body[$j];
|
|
|
|
+ $j++;
|
|
|
|
+ }
|
|
|
|
+
|
|
$count = count($entities);
|
|
$count = count($entities);
|
|
- $entities[$count] = getEntity($body, $bound, $type0, $type1, $encoding, $charset, $filename);
|
|
|
|
|
|
+ $entities[$count] = getEntity($entity_body, $bound, $type0, $type1, $encoding, $charset, $filename);
|
|
}
|
|
}
|
|
|
|
|
|
return $entities;
|
|
return $entities;
|
|
@@ -83,26 +82,7 @@
|
|
$msg["CHARSET"] = $charset;
|
|
$msg["CHARSET"] = $charset;
|
|
$msg["FILENAME"] = $filename;
|
|
$msg["FILENAME"] = $filename;
|
|
|
|
|
|
- $msg["BODY"][0] = $body;
|
|
|
|
- if ($type0 == "text") {
|
|
|
|
- // error correcting if they didn't follow RFC standards
|
|
|
|
- if (trim($type1) == "")
|
|
|
|
- $type1 = "plain";
|
|
|
|
-
|
|
|
|
- if ($type1 == "plain") {
|
|
|
|
- for ($p = 0;$p < count($body);$p++) {
|
|
|
|
- $msg["BODY"][$p] = parsePlainTextMessage($body[$p]);
|
|
|
|
- }
|
|
|
|
- } else if ($type1 == "html") {
|
|
|
|
- for ($p = 0;$p < count($body);$p++) {
|
|
|
|
- $msg["BODY"][$p] = parseHTMLMessage($body[$p]);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- $msg["BODY"] = $body;
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- $msg["BODY"][0] = $body;
|
|
|
|
- }
|
|
|
|
|
|
+ $msg["BODY"] = $body;
|
|
|
|
|
|
return $msg;
|
|
return $msg;
|
|
}
|
|
}
|
|
@@ -137,6 +117,8 @@
|
|
HTML Tags, Attachments at the bottom, etc.
|
|
HTML Tags, Attachments at the bottom, etc.
|
|
**/
|
|
**/
|
|
function formatBody($message) {
|
|
function formatBody($message) {
|
|
|
|
+ include ("../config/config.php");
|
|
|
|
+
|
|
/** this if statement checks for the entity to show as the primary message. To
|
|
/** 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.
|
|
add more of them, just put them in the order that is their priority.
|
|
**/
|
|
**/
|
|
@@ -144,21 +126,27 @@
|
|
$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)) {
|
|
} else if (containsType($message, "text", "plain", $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"]);
|
|
|
|
+ $body = "<TT>" . nl2br($body) . "</TT>";
|
|
}
|
|
}
|
|
// add other primary displaying message types here
|
|
// add other primary displaying message types here
|
|
else {
|
|
else {
|
|
// find any type that's displayable
|
|
// find any type that's displayable
|
|
if (containsType($message, "text", "any_type", $ent_num)) {
|
|
if (containsType($message, "text", "any_type", $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"]);
|
|
|
|
+ $body = "<TT>" . nl2br($body) . "</TT>";
|
|
} else if (containsType($message, "message", "any_type", $ent_num)) {
|
|
} else if (containsType($message, "message", "any_type", $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"]);
|
|
|
|
+ $body = "<TT>" . nl2br($body) . "</TT>";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ $body .= "<BR>";
|
|
|
|
+
|
|
/** Display the ATTACHMENTS: message if there's more than one part **/
|
|
/** Display the ATTACHMENTS: message if there's more than one part **/
|
|
if (count($message["ENTITIES"]) > 1) {
|
|
if (count($message["ENTITIES"]) > 1) {
|
|
- $pos = count($body);
|
|
|
|
- $body[$pos] .= "<BR><TT><U><B>ATTACHMENTS:</B></U></TT><BR>";
|
|
|
|
|
|
+ $body .= "<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=4 BORDER=0><TR><TD BGCOLOR=\"$color[0]\">";
|
|
|
|
+ $body .= "<TT><B>ATTACHMENTS:</B></TT>";
|
|
|
|
+ $body .= "</TD></TR><TR><TD BGCOLOR=\"$color[0]\">";
|
|
$num = 0;
|
|
$num = 0;
|
|
|
|
|
|
for ($i = 0; $i < count($message["ENTITIES"]); $i++) {
|
|
for ($i = 0; $i < count($message["ENTITIES"]); $i++) {
|
|
@@ -180,8 +168,9 @@
|
|
|
|
|
|
$urlMailbox = urlencode($message["INFO"]["MAILBOX"]);
|
|
$urlMailbox = urlencode($message["INFO"]["MAILBOX"]);
|
|
$id = $message["INFO"]["ID"];
|
|
$id = $message["INFO"]["ID"];
|
|
- $body[$pos] .= "<TT> <A HREF=\"../src/download.php?passed_id=$id&mailbox=$urlMailbox&passed_ent_id=$i\">" . $display_filename . "</A> <SMALL>(TYPE: $type0/$type1)</SMALL></TT><BR>";
|
|
|
|
|
|
+ $body .= "<TT> <A HREF=\"../src/download.php?passed_id=$id&mailbox=$urlMailbox&passed_ent_id=$i\">" . $display_filename . "</A> <SMALL>(TYPE: $type0/$type1)</SMALL></TT><BR>";
|
|
}
|
|
}
|
|
|
|
+ $body .= "</TD></TR></TABLE>";
|
|
}
|
|
}
|
|
return $body;
|
|
return $body;
|
|
}
|
|
}
|
|
@@ -191,25 +180,20 @@
|
|
/** this function decodes the body depending on the encoding type. **/
|
|
/** this function decodes the body depending on the encoding type. **/
|
|
function decodeBody($body, $encoding) {
|
|
function decodeBody($body, $encoding) {
|
|
$encoding = strtolower($encoding);
|
|
$encoding = strtolower($encoding);
|
|
|
|
+
|
|
if ($encoding == "us-ascii") {
|
|
if ($encoding == "us-ascii") {
|
|
$newbody = $body; // if only they all were this easy
|
|
$newbody = $body; // if only they all were this easy
|
|
|
|
+
|
|
} else if ($encoding == "quoted-printable") {
|
|
} else if ($encoding == "quoted-printable") {
|
|
- for ($q=0; $q < count($body); $q++) {
|
|
|
|
- if (substr(trim($body[$q]), -1) == "=") {
|
|
|
|
- $body[$q] = trim($body[$q]);
|
|
|
|
- $body[$q] = substr($body[$q], 0, strlen($body[$q])-1);
|
|
|
|
- } else if (substr(trim($body[$q]), -3) == "=20") {
|
|
|
|
- $body[$q] = trim($body[$q]);
|
|
|
|
- $body[$q] = substr($body[$q], 0, strlen($body[$q])-3);
|
|
|
|
- $body[$q] = "$body[$q]\n"; // maybe should be \n.. dunno
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for ($q=0;$q < count($body);$q++) {
|
|
|
|
- $body[$q] = ereg_replace("=3D", "=", $body[$q]);
|
|
|
|
- }
|
|
|
|
- $newbody = $body;
|
|
|
|
|
|
+ echo "$body";
|
|
|
|
+ $body = ereg_replace("=3D", "=", $body);
|
|
|
|
+ $body = ereg_replace("=\n", "", $body);
|
|
|
|
+ $body = ereg_replace("=20", "\n", $body);
|
|
|
|
+ $newbody= $body;
|
|
|
|
+
|
|
} else if ($encoding == "base64") {
|
|
} else if ($encoding == "base64") {
|
|
$newbody = base64_decode($body);
|
|
$newbody = base64_decode($body);
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
$newbody = $body;
|
|
$newbody = $body;
|
|
}
|
|
}
|