function decodeMime($body, $bound, $type0, $type1) {
-// echo "$type0/$type1<BR>";
+ echo "<TT>decodeMime: $type0/$type1</TT><BR>";
if ($type0 == "multipart") {
if ($body[0] == "")
$i = 1;
$j = $i + 1;
$p = 0;
- while (substr(trim($body[$j]), 0, strlen($bound)) != $bound) {
- $entity_body[$p] = $body[$j];
+ while ((substr(trim($body[$j]), 0, strlen($bound)) != $bound) && (trim($body[$j]) != "")) {
+ $entity_header[$p] = $body[$j];
$j++;
$p++;
}
- fetchEntityHeader($imapConnection, $entity_body, $ent_type0, $ent_type1, $ent_bound, &$encoding, &$charset);
+
+ fetchEntityHeader($imapConnection, $entity_header, $ent_type0, $ent_type1, $ent_bound, $encoding, $charset);
+
+ if ($ent_type0 == "text") {
+ while (substr(trim($body[$j]), 0, strlen($bound)) != $bound) {
+ $entity_body[$p] = $body[$j];
+ $j++;
+ $p++;
+ }
+ } else {
+ if (trim($body[$j]) == "")
+ $j++;
+ while (substr(trim($body[$j]), 0, strlen($bound)) != $bound) {
+ $entity_body .= $body[$j];
+ $j++;
+ }
+ }
$entity = getEntity($entity_body, $ent_bound, $ent_type0, $ent_type1, $encoding, $charset);
$q = count($full_message);
/** This gets one entity's properties **/
function getEntity($body, $bound, $type0, $type1, $encoding, $charset) {
-// echo "--$type0/$type1--<BR>";
+ echo "<TT>getEntity: $type0/$type1</TT><BR>";
$msg[0]["TYPE0"] = $type0;
$msg[0]["TYPE1"] = $type1;
$msg[0]["ENCODING"] = $encoding;
$msg[0]["BODY"][$p] = $body[$q];
}
}
+ } else if ($type0 == "image") {
+ $msg[0]["PRIORITY"] == 5;
+ $msg[0]["BODY"][0] = $body;
} else {
$msg[0]["BODY"][0] = "<B><FONT COLOR=DD0000>This attachment is of an unknown format: $type0/$type1</FONT></B>";
}
$pos = count($body);
if ($message["ENTITIES"][$i]["TYPE0"] != "text") {
if ($message["ENTITIES"][$i]["TYPE0"] == "image") {
- $body[$pos] = "<TT> Image: " . strtoupper($message["ENTITIES"][$i]["TYPE1"]) . "</TT><BR>";
+ $body[$pos] = "<TT> Image: " . $message["ENTITIES"][$i]["TYPE0"] . "/" . $message["ENTITIES"][$i]["TYPE1"] . "</TT><BR>";
+
+/* $file = fopen("../data/tmp.png", "w");
+ fwrite($file, base64_decode($message["ENTITIES"][$i]["BODY"][0]));
+ fclose($file);
+*/
} else {
$body[$pos] = "<TT> Unknown Type: " . $message["ENTITIES"][$i]["TYPE0"] . "/" . $message["ENTITIES"][$i]["TYPE1"] . "</TT><BR>";
}