6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This file is used for reading the msgs array and displaying
10 * the resulting emails in the right frame.
15 /* Path for SquirrelMail required files. */
16 define('SM_PATH','../');
18 /* SquirrelMail required files. */
19 require_once(SM_PATH
. 'include/validate.php');
20 require_once(SM_PATH
. 'functions/imap.php');
21 require_once(SM_PATH
. 'functions/mime.php');
22 require_once(SM_PATH
. 'functions/date.php');
23 require_once(SM_PATH
. 'functions/url_parser.php');
24 require_once(SM_PATH
. 'functions/html.php');
27 * Given an IMAP message id number, this will look it up in the cached
28 * and sorted msgs array and return the index. Used for finding the next
29 * and previous messages.
31 * @return the index of the next valid message from the array
33 function findNextMessage($passed_id) {
34 global $msort, $msgs, $sort,
35 $thread_sort_messages, $allow_server_sort,
37 if (!is_array($server_sort_array)) {
38 $thread_sort_messages = 0;
39 $allow_server_sort = FALSE;
42 if ($thread_sort_messages ||
$allow_server_sort) {
43 reset($server_sort_array);
44 while(list($key, $value) = each ($server_sort_array)) {
45 if ($passed_id == $value) {
46 if ($key == (count($server_sort_array) - 1)) {
50 $result = $server_sort_array[$key +
1];
54 } else if ($sort == 6 && !$allow_server_sort &&
55 !$thread_sort_messages ) {
56 if ($passed_id != 1) {
57 $result = $passed_id - 1;
59 } else if (!$allow_server_sort && !$thread_sort_messages ) {
60 if (!is_array($msort)) {
63 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
64 if ($passed_id == $msgs[$key]['ID']) {
68 $result = $msgs[$key]['ID'];
77 /** returns the index of the previous message from the array. */
78 function findPreviousMessage($numMessages, $passed_id) {
79 global $msort, $sort, $msgs,
80 $thread_sort_messages,
81 $allow_server_sort, $server_sort_array;
83 if (!is_array($server_sort_array)) {
84 $thread_sort_messages = 0;
85 $allow_server_sort = FALSE;
87 if ($thread_sort_messages ||
$allow_server_sort ) {
88 reset($server_sort_array);
89 while(list($key, $value) = each ($server_sort_array)) {
90 if ($passed_id == $value) {
95 $result = $server_sort_array[$key -1];
99 } else if ($sort == 6 && !$allow_server_sort &&
100 !$thread_sort_messages) {
101 if ($passed_id != $numMessages) {
102 $result = $passed_id +
1;
104 } else if (!$thread_sort_messages && !$allow_server_sort) {
105 if (!is_array($msort)) {
108 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
109 if ($passed_id == $msgs[$key]['ID']) {
113 //echo $msort[$key]; /* Why again were we echoing here? */
114 $result = $msgs[$key]['ID'];
124 * Displays a link to a page where the message is displayed more
125 * "printer friendly".
127 function printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color) {
128 global $javascript_on;
130 $params = '?passed_ent_id=' . $passed_ent_id .
131 '&mailbox=' . urlencode($mailbox) .
132 '&passed_id=' . $passed_id;
134 $print_text = _("View Printable Version");
137 /* Output the link. */
138 if ($javascript_on) {
139 $result .= '<script language="javascript" type="text/javascript">' . "\n" .
141 " function printFormat() {\n" .
142 ' window.open("../src/printer_friendly_main.php' .
143 $params . '","Print","width=800,height=600");' . "\n".
147 "<a href=\"javascript:printFormat();\">$print_text</a>\n";
149 $result .= '<A target="_blank" HREF="../src/printer_friendly_bottom.php' .
150 "$params\">$print_text</a>\n";
155 function ServerMDNSupport( $read ) {
156 /* escaping $ doesn't work -> \x36 */
157 $ret = preg_match( '/(\x36MDNSent|\\\*)/i', $read );
161 function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
162 global $username, $attachment_dir, $SERVER_NAME,
163 $version, $attachments, $squirrelmail_language, $default_charset,
164 $languages, $useSendmail, $domain, $sent_folder,
165 $popuser, $data_dir, $username;
167 $header = $message->rfc822_header
;
168 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
170 $rfc822_header = new Rfc822Header();
171 $content_type = new ContentType('multipart/report');
172 $content_type->properties
['report-type']='disposition-notification';
175 if ($default_charset) {
176 $content_type->properties
['charset']=$default_charset;
178 $rfc822_header->content_type
= $content_type;
179 $rfc822_header->to
[] = $header->dnt
;
180 $rfc822_header->subject
= _("Read:") . ' ' . $header->subject
;
184 if (isset($identity) && $identity != 'default') {
185 $from_mail = getPref($data_dir, $username,
186 'email_address' . $identity);
187 $full_name = getPref($data_dir, $username,
188 'full_name' . $identity);
189 $from_addr = '"'.$full_name.'" <'.$from_mail.'>';
190 $reply_to = getPref($data_dir, $username,
191 'reply_to' . $identity);
193 $from_mail = getPref($data_dir, $username, 'email_address');
194 $full_name = getPref($data_dir, $username, 'full_name');
195 $from_addr = '"'.$full_name.'" <'.$from_mail.'>';
196 $reply_to = getPref($data_dir, $username,'reply_to');
199 $from_addr = "$popuser@$domain";
200 $from_mail = $from_addr;
202 $rfc822_header->from
= $rfc822_header->parseAddress($from_addr,true);
204 $rfc822_header->reply_to
= $rfc822_header->parseAddress($reply_to,true);
208 $senton = getLongDateString( $header->date
);
209 $to_array = $header->to
;
211 foreach ($to_array as $line) {
212 $to .= ' '.$line->getAddress();
214 $now = getLongDateString( time() );
216 $body = _("Your message") . "\r\n\r\n" .
217 "\t" . _("To:") . ' ' . $to . "\r\n" .
218 "\t" . _("Subject:") . ' ' . $header->subject
. "\r\n" .
219 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
221 sprintf( _("Was displayed on %s"), $now );
223 $special_encoding = '';
224 if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
225 function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
226 $body = $languages[$squirrelmail_language]['XTRA_CODE']('encode', $body);
227 if (strtolower($default_charset) == 'iso-2022-jp') {
228 if (mb_detect_encoding($body) == 'ASCII') {
229 $special_encoding = '8bit';
231 $body = mb_convert_encoding($body, 'JIS');
232 $special_encoding = '7bit';
236 $part1 = new Message();
237 $part1->setBody($body);
238 $mime_header = new MessageHeader
;
239 $mime_header->type0
= 'text';
240 $mime_header->type1
= 'plain';
241 if ($special_encoding) {
242 $mime_header->encoding
= $special_encoding;
244 $mime_header->encoding
= 'us-ascii';
246 if ($default_charset) {
247 $mime_header->parameters
['charset'] = $default_charset;
249 $part1->mime_header
= $mime_header;
252 $original_recipient = $to;
253 $original_message_id = $header->message_id
;
255 $report = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
256 if ($original_recipient != '') {
257 $report .= "Original-Recipient : $original_recipient\r\n";
259 $final_recipient = $sender;
260 $report .= "Final-Recipient: rfc822; $final_recipient\r\n" .
261 "Original-Message-ID : $original_message_id\r\n" .
262 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
264 $part2 = new Message();
265 $part2->setBody($report);
266 $mime_header = new MessageHeader
;
267 $mime_header->type0
= 'message';
268 $mime_header->type1
= 'disposition-notification';
269 $mime_header->encoding
= 'us-ascii';
270 $part2->mime_header
= $mime_header;
272 $composeMessage = new Message();
273 $composeMessage->rfc822_header
= $rfc822_header;
274 $composeMessage->addEntity($part1);
275 $composeMessage->addEntity($part2);
279 require_once(SM_PATH
. 'class/deliver/Deliver_SMTP.class.php');
280 $deliver = new Deliver_SMTP();
281 global $smtpServerAddress, $smtpPort, $use_authenticated_smtp, $pop_before_smtp;
282 if ($use_authenticated_smtp) {
283 global $key, $onetimepad;
285 $pass = OneTimePadDecrypt($key, $onetimepad);
290 $authPop = (isset($pop_before_smtp) && $pop_before_smtp) ?
true : false;
291 $stream = $deliver->initStream($composeMessage,$domain,0,
292 $smtpServerAddress, $smtpPort, $authPop);
294 require_once(SM_PATH
. 'class/deliver/Deliver_SendMail.class.php');
295 global $sendmail_path;
296 $deliver = new Deliver_SendMail();
297 $stream = $deliver->initStream($composeMessage,$sendmail_path);
301 $length = $deliver->mail($composeMessage, $stream);
302 $succes = $deliver->finalizeStream($stream);
305 $msg = $deliver->dlv_msg
. '<br>Server replied: '.$deliver->dlv_ret_nr
;
306 require_once(SM_PATH
. 'functions/display_messages.php');
307 plain_error_message($msg, $color);
310 if (sqimap_mailbox_exists ($imapConnection, $sent_folder)) {
311 sqimap_append ($imapConnection, $sent_folder, $length);
312 require_once(SM_PATH
. 'class/deliver/Deliver_IMAP.class.php');
313 $imap_deliver = new Deliver_IMAP();
314 $imap_deliver->mail($composeMessage, $imapConnection);
315 sqimap_append_done ($imapConnection);
316 unset ($imap_deliver);
323 function ToggleMDNflag ( $set ,$imapConnection, $mailbox, $passed_id, $uid_support) {
325 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
326 $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
327 $readmessage, $uid_support);
330 function ClearAttachments() {
331 global $username, $attachments, $attachment_dir;
333 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
335 $rem_attachments = array();
336 foreach ($attachments as $info) {
337 if ($info['session'] == -1) {
338 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
339 if (file_exists($attached_file)) {
340 unlink($attached_file);
343 $rem_attachments[] = $info;
346 $attachments = $rem_attachments;
349 function formatRecipientString($recipients, $item ) {
350 global $show_more_cc, $show_more, $show_more_bcc,
353 if ((is_array($recipients)) && (isset($recipients[0]))) {
361 $url = set_url_var($PHP_SELF, 'show_more',0);
363 $url = set_url_var($PHP_SELF, 'show_more',1);
365 } else if ($item == 'cc') {
367 $url = set_url_var($PHP_SELF, 'show_more_cc',0);
370 $url = set_url_var($PHP_SELF, 'show_more_cc',1);
372 } else if ($item == 'bcc') {
373 if ($show_more_bcc) {
374 $url = set_url_var($PHP_SELF, 'show_more_bcc',0);
377 $url = set_url_var($PHP_SELF, 'show_more_bcc',1);
384 $ary[$i] = htmlspecialchars($ary[$i]->getAddress());
386 $string .= '<BR>'.$ary[$i];
390 $string .= ' (<A HREF="'.$url;
392 $string .= '">'._("less").'</A>)';
394 $string .= '">'._("more").'</A>)';
408 function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
409 $color, $FirstTimeSee) {
410 global $msn_user_support, $default_use_mdn, $draft_folder, $sent_folder,
411 $default_use_priority, $show_xmailer_default,
412 $mdn_user_support, $PHP_SELF, $javascript_on;
414 $header = $message->rfc822_header
;
416 $env[_("Subject")] = htmlspecialchars(decodeHeader($header->subject
));
417 $from_name = $header->getAddr_s('from');
419 $from_name = $header->getAddr_s('sender');
421 $from_name = _("Unknown sender");
424 $env[_("From")] = htmlspecialchars(decodeHeader($from_name));
425 $env[_("Date")] = getLongDateString($header->date
);
426 $env[_("To")] = formatRecipientString($header->to
, "to");
427 $env[_("Cc")] = formatRecipientString($header->cc
, "cc");
428 $env[_("Bcc")] = formatRecipientString($header->bcc
, "bcc");
429 if ($default_use_priority) {
430 $env[_("Priority")] = getPriorityStr($header->priority
);
432 if ($show_xmailer_default) {
433 $env[_("Mailer")] = decodeHeader($header->xmailer
);
435 if ($default_use_mdn) {
436 if ($mdn_user_support) {
438 if ($message->is_mdnsent
) {
439 $env[_("Read receipt")] = _("send");
441 if ( !($mailbox == $draft_folder ||
442 $mailbox == $sent_folder ||
443 $message->is_deleted ||
445 $mdn_url = $PHP_SELF . '&sendreceipt=1';
446 if ($FirstTimeSee && $javascript_on) {
447 $script = '<script language="JavaScript" type="text/javascript">' ."\n";
448 $script .= '<!--'. "\n";
449 $script .= 'if(window.confirm("' .
450 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
454 $script .= '// -->'. "\n";
455 $script .= '</script>'. "\n";
458 $env[_("Read receipt")] = _("requested") .
459 ' <a href="'.$mdn_url.'">['. _("Send read receipt now") .']</a>';
461 $env[_("Read receipt")] = _("requested");
468 $s = '<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"';
469 $s .= ' ALIGN="center" BGCOLOR="' . $color[0] . '">';
470 foreach ($env as $key => $val) {
473 $s .= html_tag('TD', '<B>' . $key . ': </B>', 'RIGHT', '', 'VALIGN="TOP" WIDTH="20%"') . "\n";
474 $s .= html_tag('TD', $val, 'left', '', 'VALIGN="TOP" WIDTH="80%"') . "\n";
479 do_hook("read_body_header");
480 formatToolbar($mailbox,$passed_id,$passed_ent_id,$message, $color);
484 function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response) {
485 global $base_uri, $sent_folder, $draft_folder, $where, $what, $color, $sort,
486 $startMessage, $compose_new_win, $PHP_SELF, $save_as_draft,
487 $enable_forward_as_attachment;
489 $topbar_delimiter = ' | ';
490 $urlMailbox = urlencode($mailbox);
491 $s = '<table width="100%" cellpadding="3" cellspacing="0" align="center"'.
492 ' border="0" bgcolor="'.$color[9].'"><tr><td align="left" width="33%"><small>';
494 $msgs_url = $base_uri . 'src/';
495 if (isset($where) && isset($what)) {
496 $msgs_url .= 'search.php?where='.urlencode($where).
497 '&what='.urlencode($what).'&mailbox='.$urlMailbox;
498 $msgs_str = _("Search results");
500 $msgs_url .= 'right_main.php?sort='.$sort.'&startMessage='.
501 $startMessage.'&mailbox='.$urlMailbox;
502 $msgs_str = _("Message List");
504 $s .= '<a href="'. $msgs_url.'">'.$msgs_str.'</a>';
505 $s .= $topbar_delimiter;
507 $delete_url = $base_uri . 'src/delete_message.php?mailbox='.$urlMailbox.
508 '&message='.$passed_id.'&';
509 if (!(isset($passed_ent_id) && $passed_ent_id)) {
510 if ($where && $what) {
511 $delete_url .= 'where=' . urlencode($where) . '&what=' . urlencode($what);
513 $delete_url .= 'sort='. $sort . '&startMessage='. $startMessage;
515 $s .= '<a href="'. $delete_url.'">'._("Delete").'</a>';
518 $comp_uri = $base_uri . 'src/compose.php'.
519 '?passed_id='.$passed_id.
520 '&mailbox='.$urlMailbox.
521 (isset($passed_ent_id)?
'&passed_ent_id='.$passed_ent_id:'');
523 if (($mailbox == $draft_folder) && ($save_as_draft)) {
524 $comp_alt_uri = $comp_uri . '&action=draft';
525 $comp_alt_string = _("Resume Draft");
526 } else if ($mailbox == $sent_folder) {
527 $comp_alt_uri = $comp_uri . '&action=edit_as_new';
528 $comp_alt_string = _("Edit Message as New");
530 if (isset($comp_alt_uri)) {
531 $s .= $topbar_delimiter;
532 if ($compose_new_win == '1') {
533 $s .= '<a href="javascript:void(0)" '.
534 'onclick="comp_in_new(\''.$comp_alt_uri.'\')">'.$comp_alt_string.'</a>';
536 $s .= '<a href="'.$comp_alt_uri.'">'.$comp_alt_string.'</a>';
540 $s .= '</small></td><td align="center" width="33%"><small>';
542 if (!(isset($where) && isset($what)) && !$passed_ent_id) {
543 $prev = findPreviousMessage($mbx_response['EXISTS'], $passed_id);
544 $next = findNextMessage($passed_id);
546 $uri = $base_uri . 'src/read_body.php?passed_id='.$prev.
547 '&mailbox='.$urlMailbox.'&sort='.$sort.
548 '&startMessage='.$startMessage.'&show_more=0';
549 $s .= '<a href="'.$uri.'">'._("Previous").'</a>';
553 $s .= $topbar_delimiter;
555 $uri = $base_uri . 'src/read_body.php?passed_id='.$next.
556 '&mailbox='.$urlMailbox.'&sort='.$sort.
557 '&startMessage='.$startMessage.'&show_more=0';
558 $s .= '<a href="'.$uri.'">'._("Next").'</a>';
562 } else if (isset($passed_ent_id) && $passed_ent_id) {
563 /* code for navigating through attached message/rfc822 messages */
564 $url = set_url_var($PHP_SELF, 'passed_ent_id',0);
565 $s .= '<a href="'.$url.'">'._("View Message").'</a>';
566 $par_ent_id = $message->parent
->entity_id
;
568 $par_ent_id = substr($par_ent_id,0,-2);
569 $s .= $topbar_delimiter;
570 $url = set_url_var($PHP_SELF, 'passed_ent_id',$par_ent_id);
571 $s .= '<a href="'.$url.'">'._("Up").'</a>';
575 $s .= '</small></td><td align="right" width="33%" nowrap><small>';
576 $comp_action_uri = $comp_uri . '&action=forward';
577 if ($compose_new_win == '1') {
578 $s .= '<a href="javascript:void(0)" '.
579 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Forward").'</a>';
581 $s .= '<a href="'.$comp_action_uri.'">'._("Forward").'</a>';
583 $s .= $topbar_delimiter;
585 if ($enable_forward_as_attachment) {
586 $comp_action_uri = $comp_uri . '&action=forward_as_attachment';
587 if ($compose_new_win == '1') {
588 $s .= '<a href="javascript:void(0)" '.
589 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Forward as Attachment").'</a>';
591 $s .= '<a href="'.$comp_action_uri.'">'._("Forward as Attachment").'</a>';
593 $s .= $topbar_delimiter;
596 $comp_action_uri = decodeHeader($comp_uri . '&action=reply');
597 if ($compose_new_win == '1') {
598 $s .= '<a href="javascript:void(0)" '.
599 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Reply").'</a>';
601 $s .= '<a href="'.$comp_action_uri.'">'._("Reply").'</a>';
603 $s .= $topbar_delimiter;
605 $comp_action_uri = $comp_uri . '&action=reply_all';
606 if ($compose_new_win == '1') {
607 $s .= '<a href="javascript:void(0)" '.
608 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Reply All").'</a>';
610 $s .= '<a href="'.$comp_action_uri.'">'._("Reply All").'</a>';
612 $s .= '</small></td></tr></table>';
613 do_hook("read_body_menu_top");
615 do_hook("read_body_menu_bottom");
618 function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
619 global $QUERY_STRING, $base_uri;
621 $urlMailbox = urlencode($mailbox);
622 $url = $base_uri.'src/view_header.php?'.$QUERY_STRING;
625 '<TD VALIGN="MIDDLE" ALIGN="RIGHT" WIDTH="20%"><B>' . _("Options") . ": </B></TD>\n" .
626 '<TD VALIGN="MIDDLE" ALIGN="LEFT" WIDTH="80%"><SMALL>' .
627 '<a href="'.$url.'">'._("View Full Header").'</a>';
629 /* Output the printer friendly link if we are in subtle mode. */
630 $s .= ' | ' .
631 printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color);
633 do_hook("read_body_header_right");
634 $s = "</SMALL></TD>\n" .
640 /***************************/
641 /* Main of read_body.php */
642 /***************************/
650 global $uid_support, $sqimap_capabilities;
652 if (isset($mailbox)) {
653 $mailbox = urldecode( $mailbox );
656 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
657 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
659 if (!isset($messages)) {
661 sqsession_register($messages,'messages');
665 * $message contains all information about the message
666 * including header and body
669 $uidvalidity = $mbx_response['UIDVALIDITY'];
671 if (!isset($messages[$uidvalidity])) {
672 $messages[$uidvalidity] = array();
674 if (!isset($messages[$uidvalidity][$passed_id]) ||
!$uid_support) {
675 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
676 $FirstTimeSee = !$message->is_seen
;
677 $message->is_seen
= true;
678 $messages[$uidvalidity][$passed_id] = $message;
679 sqsession_register($messages, 'messages');
681 // $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
682 $message = $messages[$uidvalidity][$passed_id];
683 $FirstTimeSee = !$message->is_seen
;
685 //$FirstTimeSee = !$message->is_seen;
686 //$message->is_seen = true;
687 //$messages[$uidvalidity][$passed_id] = $message;
689 if (isset($passed_ent_id) && $passed_ent_id) {
690 $message = $message->getEntity($passed_ent_id);
691 if ($message->type0
!= 'message' && $message->type1
!= 'rfc822') {
692 $message = $message->parent
;
694 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[$passed_ent_id.HEADER]", true, $response, $msg, $uid_support);
695 $rfc822_header = new Rfc822Header();
696 $rfc822_header->parseHeader($read);
697 $message->rfc822_header
= $rfc822_header;
701 $header = $message->header
;
705 /****************************************/
706 /* Block for handling incoming url vars */
707 /****************************************/
709 if (isset($sendreceipt)) {
710 if ( !$message->is_mdnsent
) {
711 if (isset($identity) ) {
712 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
714 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
717 $final_recipient = trim($final_recipient);
718 if ($final_recipient == '' ) {
719 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
721 $supportMDN = ServerMDNSupport($mbx_response["PERMANENTFLAGS"]);
722 if ( SendMDN( $mailbox, $passed_id, $final_recipient, $message, $imapConnection ) > 0 && $supportMDN ) {
723 ToggleMDNflag( true, $imapConnection, $mailbox, $passed_id, $uid_support);
724 $message->is_mdnsent
= true;
725 $messages[$uidvalidity][$passed_id]=$message;
730 /***********************************************/
731 /* End of block for handling incoming url vars */
732 /***********************************************/
734 $msgs[$passed_id]['FLAG_SEEN'] = true;
737 do_hook('read_body_top');
738 if ($show_html_default == 1) {
739 $ent_ar = $message->findDisplayEntity(array());
741 $ent_ar = $message->findDisplayEntity(array(), array('text/plain'));
743 $cnt = count($ent_ar);
744 for ($i = 0; $i < $cnt; $i++
) {
745 $messagebody .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox);
747 $messagebody .= '<hr noshade size=1>';
751 displayPageHeader($color, $mailbox);
752 formatMenuBar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response);
753 formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee);
754 echo '<table width="100%" cellpadding="0" cellspacing="0" align="center" border="0">';
756 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[9].'">';
758 echo ' <table width="100%" cellpadding="3" cellspacing="0" align="center" border="0">';
759 echo ' <tr bgcolor="'.$color[4].'"><td>';
760 echo ' <table cellpadding="0" cellspacing="0" align="center" border="0">';
761 echo ' <tr><td><br>' . $messagebody . '</td></td>';
764 echo ' </table></td></tr>';
768 $attachmentsdisplay = formatAttachments($message,$ent_ar,$mailbox, $passed_id);
769 if ($attachmentsdisplay) {
771 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
773 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">';
774 echo ' <tr><td ALIGN="left" bgcolor="'.$color[9].'">';
775 echo ' <b>' . _("Attachments") . ':</b>';
778 echo ' <table width="100%" cellpadding="2" cellspacing="2" align="center"'.' border="0" bgcolor="'.$color[0].'"><tr><td>';
779 echo $attachmentsdisplay;
780 echo ' </td></tr></table>';
781 echo ' </table></td></tr>';
782 echo ' </table></td></tr>';
789 /* show attached images inline -- if pref'fed so */
790 if (($attachment_common_show_images) &&
791 is_array($attachment_common_show_images_list)) {
792 foreach ($attachment_common_show_images_list as $img) {
793 $imgurl = '../src/download.php' .
795 'passed_id=' . urlencode($img['passed_id']) .
796 '&mailbox=' . urlencode($mailbox) .
797 '&ent_id=' . urlencode($img['ent_id']) .
798 '&absolute_dl=true';
800 echo html_tag( 'table', "\n" .
801 html_tag( 'tr', "\n" .
802 html_tag( 'td', '<img src="' . $imgurl . '">' ."\n", 'left'
805 'center', '', 'cellspacing=0 border="0" cellpadding="2"');
809 do_hook('read_body_bottom');
810 do_hook('html_bottom');
811 //$message->clean_up();
812 sqimap_logout($imapConnection);