everything needed, including HTML Tags, Attachments at the
bottom, etc.
*/
-function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num) {
+function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $mailbox='INBOX') {
// 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.
$has_unsafe_images = 0;
- $id = $message->id;
-
if ($message->type0 == 'message' && $message->type1 == 'rfc822') {
- $message = $message->entities[0];
+ $message = $message->entities[0];
}
$urlmailbox = urlencode($message->mailbox);
$body_message = getEntity($message, $ent_num);
$body = strip_tags( $body );
translateText($body, $wrap_at, $body_message->header->charset);
} else {
- $body = magicHTML( $body, $id, $message );
+ $body = magicHTML( $body, $id, $message, $mailbox );
}
} else {
translateText($body, $wrap_at, $body_message->header->charset);
}
/** Display the ATTACHMENTS: message if there's more than one part **/
- if ($message->type0 == 'message') {
- $id = $message->id;
- $mailbox = $message->mailbox;
-// $message->header->setVar('message_id',$id);
-// $message->header->setVar('mailbox',$mailbox);
- }
if (isset($message->entities[1])) {
/* Header-type alternative means we choose the best one to display
so don't show the alternatives as attachment. Header-type related
means that the attachments are already part of the related message.
*/
if ($message->header->type1 !='related' && $message->header->type1 !='alternative') {
- $body .= formatAttachments ($message, $ent_num, $message->mailbox, $id);
+ $body .= formatAttachments ($message, $ent_num, $mailbox, $id);
}
}
} else {
$bad_attvals,
$add_attr_to_tag,
$message,
- $id
+ $id,
+ $mailbox
){
$me = "sq_fixatts";
while (list($attname, $attvalue) = each($attary)){
* Turn cid: urls into http-friendly ones.
*/
if (preg_match("/^[\'\"]\s*cid:/si", $attvalue)){
- $attary{$attname} = sq_cid2http($message, $id, $attvalue);
+ $attary{$attname} = sq_cid2http($message, $id, $attvalue, $mailbox);
}
}
/**
* @param $cidurl the cid: url.
* @return a string with a http-friendly url
*/
-function sq_cid2http($message, $id, $cidurl){
+function sq_cid2http($message, $id, $cidurl, $mailbox){
/**
* Get rid of quotes.
*/
$cidurl = str_replace($quotchar, "", $cidurl);
$cidurl = substr(trim($cidurl), 4);
$httpurl = $quotchar . "../src/download.php?absolute_dl=true&" .
- "passed_id=$id&mailbox=" . urlencode($message->mailbox) .
+ "passed_id=$id&mailbox=" . urlencode($mailbox) .
"&passed_ent_id=" . find_ent_id($cidurl, $message) . $quotchar;
return $httpurl;
}
$bad_attvals,
$add_attr_to_tag,
$message,
- $id
+ $id,
+ $mailbox
){
$me = "sq_sanitize";
/**
$bad_attvals,
$add_attr_to_tag,
$message,
- $id
+ $id,
+ $mailbox
);
}
/**
* @param $id the id of the message
* @return a string with html safe to display in the browser.
*/
-function magicHTML($body, $id, $message){
+function magicHTML($body, $id, $message, $mailbox = 'INBOX'){
global $attachment_common_show_images, $view_unsafe_images,
$has_unsafe_images;
/**
$bad_attvals,
$add_attr_to_tag,
$message,
- $id
+ $id,
+ $mailbox
);
if (preg_match("|$secremoveimg|si", $trusted)){
$has_unsafe_images = true;