$read = trim(substr ($bodystructure, strpos(strtolower($bodystructure), 'bodystructure') + 13));
$msg = &new message();
$read = trim(substr ($read, 0, -1));
- $msg = $msg->parseStructure($read,0);
+ $res = $msg->parseStructure($read);
+ $msg = $res[0];
$msg->setEnt('0');
if (count($flags)) {
foreach ($flags as $flag) {
}
break;
case 'M':
- if (strtolower($flag) == '\$mdnsent') {
- $msg->is_mdn = true;
+ if (strtolower($flag) == '$mdnsent') {
+ $msg->is_mdnsent = true;
}
break;
default:
$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.
}
}
+function getPriorityStr($priority) {
+ $priority_level = substr($priority,0,1);
+
+ switch($priority_level) {
+ /* check for a higher then normal priority. */
+ case '1':
+ case '2':
+ $priority_string = _("High");
+ break;
+
+ /* check for a lower then normal priority. */
+ case '4':
+ case '5':
+ $priority_string = _("Low");
+ break;
+
+ /* check for a normal priority. */
+ case '3':
+ default:
+ $priority_level = '3';
+ $priority_string = _("Normal");
+ break;
+
+ }
+ return $priority_string;
+}
+
/* returns a $message object for a particular entity id */
function getEntity ($message, $ent_id) {
return $message->getEntity($ent_id);
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) {
$att_ar = $message->getAttachments($exclude_id);
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);
- $header = $att->header;
+ $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);
- $display_filename = $filename;
-
- $DefaultLink =
- "../src/read_body.php?startMessage=$startMessage&passed_id=$id&mailbox=$urlMailbox&passed_ent_id=$ent";
- if ($where && $what) {
- $DefaultLink .= '&where=' . urlencode($where) . '&what=' . urlencode($what);
- }
- $Links['download link']['text'] = _("download");
- $Links['download link']['href'] =
+ $name = '';
+ $Links['download link']['text'] = _("download");
+ $Links['download link']['href'] =
"../src/download.php?absolute_dl=true&passed_id=$id&mailbox=$urlMailbox&passed_ent_id=$ent";
- $ImageURL = '';
-
- /* this executes the attachment hook with a specific MIME-type.
- * if that doens't have results, it tries if there's a rule
- * for a more generic type. */
- $HookResults = do_hook("attachment $type0/$type1", $Links,
- $startMessage, $id, $urlMailbox, $ent, $DefaultLink, $display_filename, $where, $what);
- if(count($HookResults[1]) <= 1) {
- $HookResults = do_hook("attachment $type0/*", $Links,
- $startMessage, $id, $urlMailbox, $ent, $DefaultLink,
- $display_filename, $where, $what);
+ $ImageURL = '';
+ if ($type0 =='message' && $type1 == 'rfc822') {
+ $default_page = '../src/read_body.php';
+ $rfc822_header = $att->rfc822_header;
+ $filename = decodeHeader($rfc822_header->subject);
+
+ $from_o = $rfc822_header->from;
+ if (is_object($from_o)) {
+ $from_name = $from_o->getAddress(false);
+ } else {
+ $from_name = _("Unknown sender");
}
-
- $Links = $HookResults[1];
- $DefaultLink = $HookResults[6];
-
- $attachments .= '<TR><TD> </TD><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_name = $from_o->getAddress(false);
+ $from_name = decodeHeader(htmlspecialchars($from_name));
+ $description = $from_name;
+ } else {
+ $default_page = '../src/download.php';
+ if (is_object($header->disposition)) {
+ $filename = decodeHeader($header->disposition->getProperty('filename'));
+ if (trim($filename) == '') {
+ $name = decodeHeader($header->disposition->getProperty('name'));
+ if (trim($name) == '') {
+ if ( trim( $header->id ) == '' )
+ $filename = 'untitled-[' . $ent . ']' ;
+ else
+ $filename = 'cid: ' . $header->id;
+ } else {
+ $filename = $name;
+ }
+ }
} else {
- $from_name = _("Unknown sender");
+ if ( trim( $header->id ) == '' )
+ $filename = 'untitled-[' . $ent . ']' ;
+ else
+ $filename = 'cid: ' . $header->id;
}
- $from_name = decodeHeader(htmlspecialchars($from_name));
- $attachments .= '<b>' . $from_name . '</b>';
- $attachments .= '</SMALL></TD><TD><SMALL> ';
-
- $SkipSpaces = 1;
- foreach ($Links as $Val) {
- if ($SkipSpaces) {
- $SkipSpaces = 0;
- } else {
- $attachments .= ' | ';
- }
- $attachments .= '<a href="' . $Val['href'] . '">' . $Val['text'] . '</a>';
- }
- unset($Links);
- } else {
- $filename = decodeHeader($header->filename);
- if (trim($filename) == '') {
- if (trim($name) == '') {
- if ( trim( $header->id ) == '' )
- $display_filename = 'untitled-[' . $ent . ']' ;
- else
- $display_filename = 'cid: ' . $header->id;
- } else {
- $display_filename = $name;
- $filename = $name;
- }
+
+ if ($header->description) {
+ $description = htmlspecialchars($header->description);
} else {
- $display_filename = $filename;
- }
+ $description = '';
+ }
+ }
- $DefaultLink =
- "../src/download.php?startMessage=$startMessage&passed_id=$id&mailbox=$urlMailbox&passed_ent_id=$ent";
- if ($where && $what) {
- $DefaultLink = '&where='. urlencode($where).'&what='.urlencode($what);
- }
- $Links['download link']['text'] = _("download");
- $Links['download link']['href'] =
- "../src/download.php?absolute_dl=true&passed_id=$id&mailbox=$urlMailbox&passed_ent_id=$ent";
- $ImageURL = '';
-
- /* this executes the attachment hook with a specific MIME-type.
- * if that doens't have results, it tries if there's a rule
- * for a more generic type. */
- $HookResults = do_hook("attachment $type0/$type1", $Links,
- $startMessage, $id, $urlMailbox, $ent, $DefaultLink,
- $display_filename, $where, $what);
- if(count($HookResults[1]) <= 1) {
- $HookResults = do_hook("attachment $type0/*", $Links,
- $startMessage, $id, $urlMailbox, $ent, $DefaultLink,
- $display_filename, $where, $what);
- }
+ $display_filename = $filename;
+ $DefaultLink = $default_page . "?startMessage=$startMessage"
+ . "&passed_id=$id&mailbox=$urlMailbox"
+ . "&passed_ent_id=$ent";
+ if ($where && $what) {
+ $DefaultLink = '&where='. urlencode($where).'&what='.urlencode($what);
+ }
+ /* this executes the attachment hook with a specific MIME-type.
+ * if that doens't have results, it tries if there's a rule
+ * for a more generic type. */
+ $HookResults = do_hook("attachment $type0/$type1", $Links,
+ $startMessage, $id, $urlMailbox, $ent, $DefaultLink,
+ $display_filename, $where, $what);
+ if(count($HookResults[1]) <= 1) {
+ $HookResults = do_hook("attachment $type0/*", $Links,
+ $startMessage, $id, $urlMailbox, $ent, $DefaultLink,
+ $display_filename, $where, $what);
+ }
- $Links = $HookResults[1];
- $DefaultLink = $HookResults[6];
+ $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>';
- if ($message->header->description) {
- $attachments .= '<b>' . htmlspecialchars(_($header->description)) . '</b>';
- }
- $attachments .= '</SMALL></TD><TD><SMALL> ';
+ $attachments .= '<b>' . $description . '</b>';
+ $attachments .= '</SMALL></TD><TD><SMALL> ';
- $SkipSpaces = 1;
- foreach ($Links as $Val) {
- if ($SkipSpaces) {
- $SkipSpaces = 0;
- } else {
- $attachments .= ' | ';
- }
- $attachments .= '<a href="' . $Val['href'] . '">' . $Val['text'] . '</a>';
+ $SkipSpaces = 1;
+ foreach ($Links as $Val) {
+ if ($SkipSpaces) {
+ $SkipSpaces = 0;
+ } else {
+ $attachments .= ' | ';
}
-
- unset($Links);
- }
-
- }
- $attachments .= "</SMALL></TD></TR>\n";
-
- $attachments .= "</TABLE></TD></TR></TABLE>";
-
- return $attachments;
+ $attachments .= '<a href="' . $Val['href'] . '">' . $Val['text'] . '</a>';
+ }
+ unset($Links);
+ $attachments .= "</TD></TR>\n";
+ }
+ return $attachments;
}
/** this function decodes the body depending on the encoding type. **/
return $trusted;
}
-?>
\ No newline at end of file
+?>