InitMessage($p[$i]);
$content = $this->ContentType();
$this->ContentDisposition();
if ($is_multipart_related AND (chop($this->Headers("Content-ID")) != '')) :
$cont["id"] = ereg_replace("[<>]","", $this->Headers("Content-ID"));
$cont["name"] = $content["name"];
$contentid[] = $cont;
unset($cont);
endif;
if (eregi("multipart", $content["type"])) :
$multiparts[] = $p[$i];
elseif (eregi("message", $content["type"])) :
$messages[] = $p[$i];
elseif ($this->choose_best AND eregi("text/plain", $content["type"]) AND
$is_multipart_alternative AND !($found_best)) :
$best = $p[$i];
elseif ($this->choose_best
AND eregi($this->best_format, $content["type"]) AND $is_multipart_alternative ) :
if (eregi("[[:alpha:]]", chop($p[$i]))) : $best = $p[$i];
$found_best = true;
endif;
elseif (chop($content["type"]) != '' AND chop($this->body) !='') :
$parts[] = $p[$i];
endif;
#echo "($i)###".htmlspecialchars($this->header)."</pre>--###
";
}
if (chop($best) != '') :
$parts[] = $best;
endif;
else :
if (eregi("(message)", $content["type"])) :
$messages[] = $this->fullmessage;
elseif (chop($this->body) != '') :
$parts[] = $this->fullmessage;
endif;
endif;
unset($is_multipart_alternative);
unset($best);
unset($found_best);
if (count($multiparts) > 0) :
$next_multipart = $this->my_array_shift($multiparts);
$this->InitMessage($next_multipart);
endif;
} while ($next_multipart != "");
if (chop($parts) != '') :
for ($i=0;$iInitMessage($parts[$i]);
$ct = $this->ContentType();
$cd = $this->ContentDisposition();
if (eregi("text/html", $ct["type"]) AND count($contentid > 0)) :
for ($k=0;$kattachment_path."/".$contentid[$k]["name"];
$cid = $contentid[$k]["id"];
$cid = ereg_replace("[[:space:]]", "", $cid);
$this->body = str_replace("cid:", "", $this->body);
$this->body = str_replace($cid, $filelocation, $this->body);
}
endif;
if ($this->auto_decode
AND eregi("attachment", $cd["type"])
OR eregi("base64", $this->Headers("Content-Transfer-Encoding"))
) :
$filename = chop($ct["name"]) ? $ct["name"] : $cd["filename"];
if (eregi("base64", $this->Headers("Content-Transfer-Encoding"))) :
$file = base64_decode($this->body);
elseif(eregi("quoted-printable", $this->Headers("Content-Transfer-
Encoding"))) :
$file = quoted_printable_decode($this->body);
$file = ereg_replace("(=\n)", "", $this->body);
$file = $this->body;
elseif(eregi("7bit", $this->Headers("Content-Transfer-Encoding"))) :
$file = $this->body;
endif;
$filepath = $this->attachment_path."/".$filename;
@unlink($filepath);
if (chop($filename != '')) :
$fp = @fopen($filepath, "a") OR die("Cannot open file \"$filepath\"");
fwrite($fp, $file);
fclose($fp);
if (eregi("attachment", $cd["type"]) OR eregi("inline", $cd["type"])) :
#echo "\n$filename</a>";
$decoded_part["attachments"] = $filename;
endif;
endif;
endif;
if (eregi("^(text)", $ct["type"] )
AND !(eregi("text/html", $ct["type"] ))
AND !(eregi("attachment", $cd["type"] ))
OR (chop($ct["type"]) == "")
) :
$decoded_part["body"]["type"] = $ct["type"];
$decoded_part["body"]["body"] = $this->body;
elseif (eregi("text/html", $ct["type"] ) AND !(eregi("attachment", $cd["type"] ))) :
$decoded_part["body"]["type"] = $ct["type"];
$decoded_part["body"]["body"] = $this->body;
#echo "
($parts_count)###".htmlspecialchars($ct["type"])."</pre>--###
";
endif;
$dp[] = $decoded_part;
unset($decoded_part);
}
endif;
$message[] = $dp;
unset($dp);
unset($is_multpart_related);
unset($contentid);
unset($parts);
if (count($messages) > 0) :
$this->my_array_compact($messages);
$next_message = $this->my_array_shift($messages);
$this->InitMessage($next_message);
$this->InitMessage($this->body);
endif;
} while ($next_message != "");
return $message;
}
};
?>