X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fmime.php;h=8b364a37ea2e949addcbc07caa7eda70d161ee29;hb=abddc974c228ad2762c276ad68778dde7cdfeabf;hp=8186b747961b2dc1f2fa98a930de0f5ce9eebd8d;hpb=4809f4894f2e81992b5e172aacb3e337da29e615;p=squirrelmail.git
diff --git a/functions/mime.php b/functions/mime.php
index 8186b747..8b364a37 100644
--- a/functions/mime.php
+++ b/functions/mime.php
@@ -1,29 +1,38 @@
/** mime.php
**
- ** This contains the functions necessary to detect and decode MIME messages.
+ ** This contains the functions necessary to detect and decode MIME
+ ** messages.
+ **
**/
+ $mime_php = true;
+
+ if (!isset($i18n_php))
+ include "../functions/i18n.php";
/** This is the first function called. It decides if this is a multipart
message or if it should be handled as a single entity
**/
- function decodeMime($body, $bound, $type0, $type1, &$entities) {
+ function decodeMime($body, $bound, $type0, $type1, $encoding, &$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;
$p = 0;
/** Lets find the header for this entity **/
- /** If the first line after the boundary is blank, we use default values **/
+ /** If the first line after the boundary is blank, we
+ use default values **/
if (trim($body[$j]) == "") {
$ent_type0 = "text";
$ent_type1 = "plain";
$charset = "us-ascii";
$j++;
- /** If the first line ISNT blank, read in the header for this entity **/
+ /** If the first line ISNT blank, read in the header
+ for this entity **/
} else {
while ((substr(trim($body[$j]), 0, strlen("--$bound")) != "--$bound") && (trim($body[$j]) != "")) {
$entity_header[$p] = $body[$j];
@@ -31,11 +40,12 @@
$p++;
}
/** All of these values are getting passed back to us **/
- fetchEntityHeader($imapConnection, $entity_header, $ent_type0, $ent_type1, $ent_bound, $encoding, $charset, $filename);
+ sqimap_get_entity_header($imapConnection, $entity_header, $ent_type0, $ent_type1, $ent_bound, $encoding, $charset, $filename);
}
- /** OK, we have the header information, now lets decide what to do with it **/
+ /** OK, we have the header information, now lets decide
+ what to do with it **/
if ($ent_type0 == "multipart") {
$y = 0;
while (substr($body[$j], 0, strlen("--$bound--")) != "--$bound--") {
@@ -45,15 +55,6 @@
}
$ent = decodeMime($ent_body, $ent_bound, $ent_type0, $ent_type1, $entities);
$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 {
$j++;
$entity_body = "";
@@ -68,8 +69,16 @@
$i++;
}
} else {
+ /** If this isn't a multipart message **/
+ $j = 0;
+ $entity_body = "";
+ while ($j < count($body)) {
+ $entity_body .= $body[$j];
+ $j++;
+ }
+
$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;
@@ -83,26 +92,7 @@
$msg["CHARSET"] = $charset;
$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;
}
@@ -132,14 +122,20 @@
return false;
}
- /** This returns a parsed string called $body. That string can then be displayed
- as the actual message in the HTML. It contains everything needed, including
- HTML Tags, Attachments at the bottom, etc.
+ /** This returns a parsed string called $body. That string can then
+ be displayed as the actual message in the HTML. It contains
+ everything needed, including HTML Tags, Attachments at the
+ bottom, etc.
**/
- function formatBody($message) {
- /** 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.
+ 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)) {
@@ -155,10 +151,19 @@
}
}
+ /** 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 .= "
";
+
/** Display the ATTACHMENTS: message if there's more than one part **/
if (count($message["ENTITIES"]) > 1) {
- $pos = count($body);
- $body[$pos] .= "
ATTACHMENTS:
";
+ $body .= "
"; + $body .= "ATTACHMENTS:"; + $body .= " |
";
$num = 0;
for ($i = 0; $i < count($message["ENTITIES"]); $i++) {
@@ -172,16 +177,16 @@
$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;
}
$urlMailbox = urlencode($message["INFO"]["MAILBOX"]);
$id = $message["INFO"]["ID"];
- $body[$pos] .= " " . $display_filename . " (TYPE: $type0/$type1) "; + $body .= " " . $display_filename . " (TYPE: $type0/$type1) "; } + $body .= " |