$sid_s = $sid;
}
+ $body = mime_fetch_body ($imap_stream, $id, $ent_id);
+ echo decodeBody($body, $encoding);
+ return;
+/*
fputs ($imap_stream, "$sid FETCH $id BODY[$ent_id]\r\n");
$cnt = 0;
$continue = true;
// This could be bad -- if the section has sqimap_session_id() . ' OK'
// or similar, it will kill the download.
while (!ereg("^".$sid_s." (OK|BAD|NO)(.*)$", $read, $regs)) {
- if (trim($read) == ')==') {
- $read1 = $read;
- $read = fgets ($imap_stream,4096);
- if (ereg("^".$sid." (OK|BAD|NO)(.*)$", $read, $regs)) {
- return;
- } else {
- echo decodeBody($read1, $encoding) .
- decodeBody($read, $encoding);
- }
- } else if ($cnt) {
- echo decodeBody($read, $encoding);
- }
- $read = fgets ($imap_stream,4096);
- $cnt++;
+ if (trim($read) == ')==') {
+ $read1 = $read;
+ $read = fgets ($imap_stream,4096);
+ if (ereg("^".$sid." (OK|BAD|NO)(.*)$", $read, $regs)) {
+ return;
+ } else {
+ echo decodeBody($read1, $encoding) .
+ decodeBody($read, $encoding);
+ }
+ } else if ($cnt) {
+ echo decodeBody($read, $encoding);
+ }
+ $read = fgets ($imap_stream,4096);
+ $cnt++;
// break;
}
+*/
}
/* -[ END MIME DECODING ]----------------------------------------------------------- */
+/* findDisplayEntity
+ * Checks to see if $message contains content of type $type0/$type1
+ * returns the first entity number it finds of that type, or NULL if
+ * none is found. Takes optional argument $start to allow the caller
+ * to continue where they left off
+ */
+function findDisplayEntity($message, $type0, $type1, $start=0) {
+ if ($message) {
+ for ($i = $start;isset($message->entities[$i]); $i++) {
+ $entity = $message->entities[$i];
+ if ($entity->type0 == $type0 && $entity->type1 == $type1) {
+ return $i;
+ }
+ }
+ }
+ return NULL;
+}
// This is here for debugging purposese. It will print out a list
// of all the entity IDs that are in the $message object.
if (($body_message->header->type0 == 'text') ||
($body_message->header->type0 == 'rfc822')) {
$body = mime_fetch_body ($imap_stream, $id, $ent_num);
-
$body = decodeBody($body, $body_message->header->encoding);
$hookResults = do_hook("message_body", $body);
$body = $hookResults[1];
if ($body_message->header->type1 == 'html') {
if ( $show_html_default <> 1 ) {
$body = strip_tags( $body );
- translateText($body, $wrap_at, $body_message->header->charset);
+ translateText($body, $wrap_at,
+ $body_message->header->getParameter['charset']);
} else {
$body = magicHTML( $body, $id, $message, $mailbox );
}
} else {
- translateText($body, $wrap_at, $body_message->header->charset);
+ translateText($body, $wrap_at,
+ $body_message->header->getParameter('charset'));
}
if ($has_unsafe_images) {
if (!count($att_ar)) return '';
- $attachments = "<TABLE WIDTH=\"100%\" CELLSPACING=0 CELLPADDING=2 BORDER=0 BGCOLOR=\"$color[0]\"><TR>\n" .
- "<TH ALIGN=\"left\" BGCOLOR=\"$color[9]\"><B>\n" .
- _("Attachments") . ':' .
- "</B></TH></TR><TR><TD>\n" .
- "<TABLE CELLSPACING=0 CELLPADDING=1 BORDER=0>\n";
+ $attachments = '';
$urlMailbox = urlencode($mailbox);
foreach ($att_ar as $att) {
- $ent = urlencode($att->entity_id);
+ $ent = urldecode($att->entity_id);
$header = $att->header;
$type0 = strtolower($header->type0);
$type1 = strtolower($header->type1);
$name = '';
if ($type0 =='message' && $type1 == 'rfc822') {
-
- $filename = decodeHeader($header->subject);
+ $rfc822_header = $att->rfc822_header;
+ $filename = decodeHeader($rfc822_header->subject);
$display_filename = $filename;
$DefaultLink =
$Links = $HookResults[1];
$DefaultLink = $HookResults[6];
- $attachments .= '<TR><TD> </TD><TD>' .
+ $attachments .= '<TR><TD>' .
"<A HREF=\"$DefaultLink\">$display_filename</A> </TD>" .
'<TD><SMALL><b>' . show_readable_size($header->size) .
'</b> </small></TD>' .
"<TD><SMALL>[ $type0/$type1 ] </SMALL></TD>" .
'<TD><SMALL>';
- $from_o = $header->from;
- if (isset($from_o)) {
+ $from_o = $rfc822_header->from;
+ if (is_object($from_o)) {
$from_name = $from_o->getAddress(false);
} else {
$from_name = _("Unknown sender");
$attachments .= '<a href="' . $Val['href'] . '">' . $Val['text'] . '</a>';
}
unset($Links);
+ $attachments .= "</TD></TR>\n";
} else {
- $filename = decodeHeader($header->filename);
+ $filename = decodeHeader($header->getParameter('filename'));
if (trim($filename) == '') {
+ $name = decodeHeader($header->getParameter('name'));
if (trim($name) == '') {
if ( trim( $header->id ) == '' )
$display_filename = 'untitled-[' . $ent . ']' ;
$Links = $HookResults[1];
$DefaultLink = $HookResults[6];
- $attachments .= '<TR><TD> </TD><TD>' .
+ $attachments .= '<TR><TD>' .
"<A HREF=\"$DefaultLink\">$display_filename</A> </TD>" .
'<TD><SMALL><b>' . show_readable_size($header->size) .
'</b> </small></TD>' .
}
$attachments .= '<a href="' . $Val['href'] . '">' . $Val['text'] . '</a>';
}
-
+ $attachments .= "</TD></TR>\n";
unset($Links);
}
- }
- $attachments .= "</SMALL></TD></TR>\n";
-
- $attachments .= "</TABLE></TD></TR></TABLE>";
+ }
return $attachments;
}
return $trusted;
}
-?>
\ No newline at end of file
+?>