Lots of small user interface fixes. Added user option to enable/disable "forward...
[squirrelmail.git] / src / read_body.php
1 <?php
2
3 /**
4 * read_body.php
5 *
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This file is used for reading the msgs array and displaying
10 * the resulting emails in the right frame.
11 *
12 * $Id$
13 */
14
15 require_once('../src/validate.php');
16 require_once('../functions/imap.php');
17 require_once('../functions/mime.php');
18 require_once('../functions/date.php');
19 require_once('../functions/url_parser.php');
20 require_once('../functions/smtp.php');
21 require_once('../functions/html.php');
22
23 /**
24 * Given an IMAP message id number, this will look it up in the cached
25 * and sorted msgs array and return the index. Used for finding the next
26 * and previous messages.
27 *
28 * @return the index of the next valid message from the array
29 */
30 function findNextMessage($passed_id) {
31 global $msort, $msgs, $sort,
32 $thread_sort_messages, $allow_server_sort,
33 $server_sort_array;
34 if (!is_array($server_sort_array)) {
35 $thread_sort_messages = 0;
36 $allow_server_sort = FALSE;
37 }
38 $result = -1;
39 if ($thread_sort_messages || $allow_server_sort) {
40 reset($server_sort_array);
41 while(list($key, $value) = each ($server_sort_array)) {
42 if ($passed_id == $value) {
43 if ($key == (count($server_sort_array) - 1)) {
44 $result = -1;
45 break;
46 }
47 $result = $server_sort_array[$key + 1];
48 break;
49 }
50 }
51 } else if ($sort == 6 && !$allow_server_sort &&
52 !$thread_sort_messages ) {
53 if ($passed_id != 1) {
54 $result = $passed_id - 1;
55 }
56 } else if (!$allow_server_sort && !$thread_sort_messages ) {
57 if (!is_array($msort)) {
58 return -1;
59 }
60 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
61 if ($passed_id == $msgs[$key]['ID']) {
62 next($msort);
63 $key = key($msort);
64 if (isset($key)){
65 $result = $msgs[$key]['ID'];
66 break;
67 }
68 }
69 }
70 }
71 return ($result);
72 }
73
74 /** returns the index of the previous message from the array. */
75 function findPreviousMessage($numMessages, $passed_id) {
76 global $msort, $sort, $msgs,
77 $thread_sort_messages,
78 $allow_server_sort, $server_sort_array;
79 $result = -1;
80 if (!is_array($server_sort_array)) {
81 $thread_sort_messages = 0;
82 $allow_server_sort = FALSE;
83 }
84 if ($thread_sort_messages || $allow_server_sort ) {
85 reset($server_sort_array);
86 while(list($key, $value) = each ($server_sort_array)) {
87 if ($passed_id == $value) {
88 if ($key == 0) {
89 $result = -1;
90 break;
91 }
92 $result = $server_sort_array[$key -1];
93 break;
94 }
95 }
96 } else if ($sort == 6 && !$allow_server_sort &&
97 !$thread_sort_messages) {
98 if ($passed_id != $numMessages) {
99 $result = $passed_id + 1;
100 }
101 } else if (!$thread_sort_messages && !$allow_server_sort) {
102 if (!is_array($msort)) {
103 return -1;
104 }
105 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
106 if ($passed_id == $msgs[$key]['ID']) {
107 prev($msort);
108 $key = key($msort);
109 if (isset($key)) {
110 //echo $msort[$key]; /* Why again were we echoing here? */
111 $result = $msgs[$key]['ID'];
112 break;
113 }
114 }
115 }
116 }
117 return ($result);
118 }
119
120 /**
121 * Displays a link to a page where the message is displayed more
122 * "printer friendly".
123 */
124 function printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color) {
125 global $javascript_on;
126
127 $params = '?passed_ent_id=' . $passed_ent_id .
128 '&mailbox=' . urlencode($mailbox) .
129 '&passed_id=' . $passed_id;
130
131 $print_text = _("View Printable Version");
132
133 $result = '';
134 /* Output the link. */
135 if ($javascript_on) {
136 $result .= '<script language="javascript" type="text/javascript">' . "\n" .
137 '<!--' . "\n" .
138 " function printFormat() {\n" .
139 ' window.open("../src/printer_friendly_main.php' .
140 $params . '","Print","width=800,height=600");' . "\n".
141 " }\n" .
142 "// -->\n" .
143 "</script>\n" .
144 "<a href=\"javascript:printFormat();\">$print_text</a>\n";
145 } else {
146 $result .= '<A target="_blank" HREF="../src/printer_friendly_bottom.php' .
147 "$params\">$print_text</a>\n";
148 }
149 return ($result);
150 }
151
152 function ServerMDNSupport( $read ) {
153 /* escaping $ doesn't work -> \x36 */
154 $ret = preg_match( '/(\x36MDNSent|\\\*)/i', $read );
155 return ( $ret );
156 }
157
158 function SendMDN ( $mailbox, $passed_id, $sender, $message) {
159 global $username, $attachment_dir, $SERVER_NAME,
160 $version, $attachments;
161
162 $header = $message->rfc822_header;
163 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
164
165 $recipient_o = $header->dnt;
166 $recipient = $recipient_o->getAddress(true);
167
168 // part 1 (RFC2298)
169
170 $senton = getLongDateString( $header->date );
171 $to_array = $header->to;
172 $to = '';
173 foreach ($to_array as $line) {
174 $to .= ' '.$line->getAddress();
175 }
176
177 $subject = $header->subject;
178 $now = getLongDateString( time() );
179
180 set_my_charset();
181
182 $body = _("Your message") . "\r\n\r\n" .
183 "\t" . _("To:") . ' ' . $to . "\r\n" .
184 "\t" . _("Subject:") . ' ' . $subject . "\r\n" .
185 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
186 "\r\n" .
187 sprintf( _("Was displayed on %s"), $now );
188
189 // part2 (RFC2298)
190 $original_recipient = $to;
191 $original_message_id = $header->message_id;
192
193 $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
194 if ($original_recipient != '') {
195 $part2 .= "Original-Recipient : $original_recipient\r\n";
196 }
197 $final_recipient = $sender;
198 $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" .
199 "Original-Message-ID : $original_message_id\r\n" .
200 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
201
202 $localfilename = GenerateRandomString(32, 'FILE', 7);
203 $full_localfilename = "$hashed_attachment_dir/$localfilename";
204
205 $fp = fopen( $full_localfilename, 'w');
206 fwrite ($fp, $part2);
207 fclose($fp);
208
209 $newAttachment = array();
210 $newAttachment['localfilename'] = $localfilename;
211 $newAttachment['type'] = "message/disposition-notification";
212 $newAttachment['session']=-1;
213 $attachments[] = $newAttachment;
214
215 return (SendMessage($recipient, '', '', _("Read:") . ' ' . $subject,
216 $body, 0, True, 3, -1) );
217 }
218
219
220 function ToggleMDNflag ( $set ,$imapConnection, $mailbox, $passed_id, $uid_support) {
221 $sg = $set?'+':'-';
222 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
223 $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
224 $readmessage, $uid_support);
225 }
226
227 function ClearAttachments() {
228 global $username, $attachments, $attachment_dir;
229
230 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
231
232 $rem_attachments = array();
233 foreach ($attachments as $info) {
234 if ($info['session'] == -1) {
235 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
236 if (file_exists($attached_file)) {
237 unlink($attached_file);
238 }
239 } else {
240 $rem_attachments[] = $info;
241 }
242 }
243 $attachments = $rem_attachments;
244 }
245
246 function formatRecipientString($recipients, $item ) {
247 global $show_more_cc, $show_more, $show_more_bcc,
248 $PHP_SELF;
249
250 if ((is_array($recipients)) && (isset($recipients[0]))) {
251 $string = '';
252 $ary = $recipients;
253 $show = false;
254
255 if ($item == 'to') {
256 if ($show_more) {
257 $show = true;
258 $url = set_url_var($PHP_SELF, 'show_more',0);
259 } else {
260 $url = set_url_var($PHP_SELF, 'show_more',1);
261 }
262 } else if ($item == 'cc') {
263 if ($show_more_cc) {
264 $url = set_url_var($PHP_SELF, 'show_more_cc',0);
265 $show = true;
266 } else {
267 $url = set_url_var($PHP_SELF, 'show_more_cc',1);
268 }
269 } else if ($item == 'bcc') {
270 if ($show_more_bcc) {
271 $url = set_url_var($PHP_SELF, 'show_more_bcc',0);
272 $show = true;
273 } else {
274 $url = set_url_var($PHP_SELF, 'show_more_bcc',1);
275 }
276 }
277
278 $cnt = count($ary);
279 $i = 0;
280 while ($i < $cnt) {
281 $ary[$i] = htmlspecialchars($ary[$i]->getAddress());
282 if ($string) {
283 $string .= '<BR>'.$ary[$i];
284 } else {
285 $string = $ary[$i];
286 if ($cnt>1) {
287 $string .= '&nbsp;(<A HREF="'.$url;
288 if ($show) {
289 $string .= '">'._("less").'</A>)';
290 } else {
291 $string .= '">'._("more").'</A>)';
292 break;
293 }
294 }
295 }
296 $i++;
297 }
298 }
299 else {
300 $string = '';
301 }
302 return $string;
303 }
304
305 function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
306 $color, $FirstTimeSee) {
307 global $msn_user_support, $default_use_mdn, $draft_folder, $sent_folder,
308 $default_use_priority, $show_xmailer_default,
309 $mdn_user_support, $PHP_SELF, $javascript_on;
310
311 $header = $message->rfc822_header;
312 $env = array();
313 $env[_("Subject")] = htmlspecialchars($header->subject);
314 $from_name = $header->getAddr_s('from');
315 if (!$from_name) {
316 $from_name = $header->getAddr_s('sender');
317 if (!$from_name) {
318 $from_name = _("Unknown sender");
319 }
320 }
321 $env[_("From")] = htmlspecialchars($from_name);
322 $env[_("Date")] = getLongDateString($header->date);
323 $env[_("To")] = formatRecipientString($header->to, "to");
324 $env[_("Cc")] = formatRecipientString($header->cc, "cc");
325 $env[_("Bcc")] = formatRecipientString($header->bcc, "bcc");
326 if ($default_use_priority) {
327 $env[_("Priority")] = getPriorityStr($header->priority);
328 }
329 if ($show_xmailer_default) {
330 $env[_("Mailer")] = $header->xmailer;
331 }
332 if ($default_use_mdn) {
333 if ($mdn_user_support) {
334 if ($header->dnt) {
335 if ($message->is_mdnsent) {
336 $env[_("Read receipt")] = _("send");
337 } else {
338 if ( !($mailbox == $draft_folder ||
339 $mailbox == $sent_folder ||
340 $message->is_deleted ||
341 $passed_ent_id)) {
342 $mdn_url = $PHP_SELF . '&sendreceipt=1';
343 if ($FirstTimeSee && $javascript_on) {
344 $script = '<script language="JavaScript" type="text/javascript">' ."\n";
345 $script .= '<!--'. "\n";
346 $script .= 'if(window.confirm("' .
347 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
348 '")) { '."\n" .
349 ' sendMDN()'.
350 '}' . "\n";
351 $script .= '// -->'. "\n";
352 $script .= '</script>'. "\n";
353 echo $script;
354 }
355 $env[_("Read receipt")] = _("requested") .
356 '&nbsp;<a href="'.$mdn_url.'">['. _("Send read receipt now") .']</a>';
357 } else {
358 $env[_("Read receipt")] = _("requested");
359 }
360 }
361 }
362 }
363 }
364
365 $s = '<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"';
366 $s .= ' ALIGN="center" BGCOLOR="' . $color[0] . '">';
367 foreach ($env as $key => $val) {
368 if ($val) {
369 $s .= '<TR>';
370 $s .= html_tag('TD', '<B>' . $key . ':&nbsp;&nbsp;</B>', 'RIGHT', '', 'VALIGN="TOP" WIDTH="20%"') . "\n";
371 $s .= html_tag('TD', $val, 'left', '', 'VALIGN="TOP" WIDTH="80%"') . "\n";
372 $s .= '</TR>';
373 }
374 }
375 echo $s;
376 do_hook("read_body_header");
377 formatToolbar($mailbox,$passed_id,$passed_ent_id,$message, $color);
378 echo '</table>';
379 }
380
381 function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response) {
382 global $base_uri, $sent_folder, $draft_folder, $where, $what, $color, $sort,
383 $startMessage, $compose_new_win, $PHP_SELF, $save_as_draft,
384 $enable_forward_as_attachment;
385
386 $topbar_delimiter = '&nbsp;|&nbsp;';
387 $urlMailbox = urlencode($mailbox);
388 $s = '<table width="100%" cellpadding="3" cellspacing="0" align="center"'.
389 ' border="0" bgcolor="'.$color[9].'"><tr><td align="left" width="33%"><small>';
390
391 $msgs_url = $base_uri . 'src/';
392 if (isset($where) && isset($what)) {
393 $msgs_url .= 'search.php?where='.urlencode($where).
394 '&amp;what='.urlencode($what).'&amp;mailbox='.$urlMailbox;
395 $msgs_str = _("Search results");
396 } else {
397 $msgs_url .= 'right_main.php?sort='.$sort.'&amp;startMessage='.
398 $startMessage.'&amp;mailbox='.$urlMailbox;
399 $msgs_str = _("Message List");
400 }
401 $s .= '<a href="'. $msgs_url.'">'.$msgs_str.'</a>';
402 $s .= $topbar_delimiter;
403
404 $delete_url = $base_uri . 'src/delete_message.php?mailbox='.$urlMailbox.
405 '&amp;message='.$passed_id.'&amp;';
406 if (!(isset($passed_ent_id) && $passed_ent_id)) {
407 if ($where && $what) {
408 $delete_url .= 'where=' . urlencode($where) . '&amp;what=' . urlencode($what);
409 } else {
410 $delete_url .= 'sort='. $sort . '&amp;startMessage='. $startMessage;
411 }
412 $s .= '<a href="'. $delete_url.'">'._("Delete").'</a>';
413 }
414
415 $comp_uri = $base_uri . 'src/compose.php'.
416 '?passed_id='.$passed_id.
417 '&amp;mailbox='.$urlMailbox.
418 (isset($passed_ent_id)?'&amp;passed_ent_id='.$passed_ent_id:'');
419
420 if (($mailbox == $draft_folder) && ($save_as_draft)) {
421 $comp_alt_uri = $comp_uri . '&amp;action=draft';
422 $comp_alt_string = _("Resume Draft");
423 } else if ($mailbox == $sent_folder) {
424 $comp_alt_uri = $comp_uri . '&amp;action=edit_as_new';
425 $comp_alt_string = _("Edit Message as New");
426 }
427 if (isset($comp_alt_uri)) {
428 $s .= $topbar_delimiter;
429 if ($compose_new_win == '1') {
430 $s .= '<a href="javascript:void(0)" '.
431 'onclick="comp_in_new(\''.$comp_alt_uri.'\')">'.$comp_alt_string.'</a>';
432 } else {
433 $s .= '<a href="'.$comp_alt_uri.'">'.$comp_alt_string.'</a>';
434 }
435 }
436
437 $s .= '</small></td><td align="center" width="33%"><small>';
438
439 if (!(isset($where) && isset($what)) && !$passed_ent_id) {
440 $prev = findPreviousMessage($mbx_response['EXISTS'], $passed_id);
441 $next = findNextMessage($passed_id);
442 if ($prev != -1) {
443 $uri = $base_uri . 'src/read_body.php?passed_id='.$prev.
444 '&amp;mailbox='.$urlMailbox.'&amp;sort='.$sort.
445 '&amp;startMessage='.$startMessage.'&amp;show_more=0';
446 $s .= '<a href="'.$uri.'">'._("Previous").'</a>';
447 } else {
448 $s .= _("Previous");
449 }
450 $s .= $topbar_delimiter;
451 if ($next != -1) {
452 $uri = $base_uri . 'src/read_body.php?passed_id='.$next.
453 '&amp;mailbox='.$urlMailbox.'&amp;sort='.$sort.
454 '&amp;startMessage='.$startMessage.'&amp;show_more=0';
455 $s .= '<a href="'.$uri.'">'._("Next").'</a>';
456 } else {
457 $s .= _("Next");
458 }
459 } else if (isset($passed_ent_id) && $passed_ent_id) {
460 /* code for navigating through attached message/rfc822 messages */
461 $url = set_url_var($PHP_SELF, 'passed_ent_id',0);
462 $s .= '<a href="'.$url.'">'._("View Message").'</a>';
463 $par_ent_id = $message->parent->entity_id;
464 if ($par_ent_id) {
465 $par_ent_id = substr($par_ent_id,0,-2);
466 $s .= $topbar_delimiter;
467 $url = set_url_var($PHP_SELF, 'passed_ent_id',$par_ent_id);
468 $s .= '<a href="'.$url.'">'._("Up").'</a>';
469 }
470 }
471
472 $s .= '</small></td><td align="right" width="33%" nowrap><small>';
473 $comp_action_uri = $comp_uri . '&amp;action=forward';
474 if ($compose_new_win == '1') {
475 $s .= '<a href="javascript:void(0)" '.
476 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Forward").'</a>';
477 } else {
478 $s .= '<a href="'.$comp_action_uri.'">'._("Forward").'</a>';
479 }
480 $s .= $topbar_delimiter;
481
482 if ($enable_forward_as_attachment) {
483 $comp_action_uri = $comp_uri . '&amp;action=forward_as_attachment';
484 if ($compose_new_win == '1') {
485 $s .= '<a href="javascript:void(0)" '.
486 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Forward as Attachment").'</a>';
487 } else {
488 $s .= '<a href="'.$comp_action_uri.'">'._("Forward as Attachment").'</a>';
489 }
490 $s .= $topbar_delimiter;
491 }
492
493
494 $comp_action_uri = decodeHeader($comp_uri . '&amp;action=reply');
495 if ($compose_new_win == '1') {
496 $s .= '<a href="javascript:void(0)" '.
497 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Reply").'</a>';
498 } else {
499 $s .= '<a href="'.$comp_action_uri.'">'._("Reply").'</a>';
500 }
501 $s .= $topbar_delimiter;
502
503 $comp_action_uri = $comp_uri . '&amp;action=reply_all';
504 if ($compose_new_win == '1') {
505 $s .= '<a href="javascript:void(0)" '.
506 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Reply All").'</a>';
507 } else {
508 $s .= '<a href="'.$comp_action_uri.'">'._("Reply All").'</a>';
509 }
510 $s .= '</small></td></tr></table>';
511 echo $s;
512 }
513
514 function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
515 global $QUERY_STRING, $base_uri;
516
517 $urlMailbox = urlencode($mailbox);
518 $url = $base_uri.'src/view_header.php?'.$QUERY_STRING;
519
520 $s = "<TR>\n";
521 $s .= '<TD VALIGN="MIDDLE" ALIGN="RIGHT" WIDTH="20%"><B>' . _("Options") . ":&nbsp;&nbsp;</B></TD>\n";
522 $s .= '<TD VALIGN="MIDDLE" ALIGN="LEFT" WIDTH="80%"><SMALL>';
523 $s .= '<a href="'.$url.'">'.("View Full Header").'</a>';
524
525 /* Output the printer friendly link if we are in subtle mode. */
526 $s .= '&nbsp;|&nbsp;';
527 $s .= printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color);
528 echo $s;
529 do_hook("read_body_header_right");
530 $s = "</SMALL></TD>\n";
531 $s .= "</TR>\n";
532 echo $s;
533
534
535 }
536
537 /***************************/
538 /* Main of read_boby.php */
539 /***************************/
540
541 /*
542 Urled vars
543 ----------
544 $passed_id
545 */
546
547 global $uid_support, $sqimap_capabilities;
548
549 if (isset($mailbox)) {
550 $mailbox = urldecode( $mailbox );
551 }
552
553 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
554 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
555
556 if (!isset($messages)) {
557 $messages = array();
558 session_register('messages');
559 }
560
561 /**
562 * $message contains all information about the message
563 * including header and body
564 */
565
566 $uidvalidity = $mbx_response['UIDVALIDITY'];
567
568 if (!isset($messages[$uidvalidity])) {
569 $messages[$uidvalidity] = array();
570 }
571 if (!isset($messages[$uidvalidity][$passed_id]) || !$uid_support) {
572 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
573 $messages[$uidvalidity][$passed_id] = $message;
574 } else {
575 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
576 // $message = $messages[$uidvalidity][$passed_id];
577 }
578 $FirstTimeSee = !$message->is_seen;
579 $message->is_seen = true;
580 $messages[$uidvalidity][$passed_id] = $message;
581
582 if (isset($passed_ent_id) && $passed_ent_id) {
583 $message = $message->getEntity($passed_ent_id);
584 if ($message->type0 != 'message' && $message->type1 != 'rfc822') {
585 $message = $message->parent;
586 }
587 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[$passed_ent_id.HEADER]", true, $response, $msg, $uid_support);
588 $rfc822_header = new rfc822_header();
589 $rfc822_header->parseHeader($read);
590 $message->rfc822_header = $rfc822_header;
591 } else {
592 $passed_ent_id = 0;
593 }
594 $header = $message->header;
595
596 do_hook('html_top');
597
598 /****************************************/
599 /* Block for handling incoming url vars */
600 /****************************************/
601
602 if (isset($sendreceipt)) {
603 if ( !$message->is_mdnsent ) {
604 if (isset($identity) ) {
605 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
606 } else {
607 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
608 }
609
610 $final_recipient = trim($final_recipient);
611 if ($final_recipient == '' ) {
612 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
613 }
614 $supportMDN = ServerMDNSupport($mbx_response["PERMANENTFLAGS"]);
615 if ( SendMDN( $mailbox, $passed_id, $final_recipient, $message ) > 0 && $supportMDN ) {
616 ToggleMDNflag( true, $imapConnection, $mailbox, $passed_id, $uid_support);
617 $message->is_mdnsent = true;
618 $messages[$uidvalidity][$passed_id]=$message;
619 }
620 ClearAttachments();
621 }
622 }
623 /***********************************************/
624 /* End of block for handling incoming url vars */
625 /***********************************************/
626
627 $msgs[$passed_id]['FLAG_SEEN'] = true;
628
629 $messagebody = '';
630 do_hook('read_body_top');
631 if ($show_html_default == 1) {
632 $ent_ar = $message->findDisplayEntity(array());
633 } else {
634 $ent_ar = $message->findDisplayEntity(array(), array('text/plain'));
635 }
636 $cnt = count($ent_ar);
637 for ($i = 0; $i < $cnt; $i++) {
638 $messagebody .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox);
639 if ($i != $cnt-1) {
640 $messagebody .= '<hr noshade size=1>';
641 }
642 }
643
644 displayPageHeader($color, $mailbox);
645 formatMenuBar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response);
646 formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee);
647 echo '<table width="100%" cellpadding="0" cellspacing="0" align="center" border="0">';
648 echo ' <tr><td>';
649 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[9].'">';
650 echo ' <tr><td>';
651 echo ' <table width="100%" cellpadding="3" cellspacing="0" align="center" border="0">';
652 echo ' <tr bgcolor="'.$color[4].'"><td>';
653 echo ' <table cellpadding="0" cellspacing="0" align="center" border="0">';
654 echo ' <tr><td><br>' . $messagebody . '</td></td>';
655 echo ' </table>';
656 echo ' </td></tr>';
657 echo ' </table></td></tr>';
658 echo ' </table>';
659 echo ' </td></tr>';
660
661 $attachmentsdisplay = formatAttachments($message,$ent_ar,$mailbox, $passed_id);
662 if ($attachmentsdisplay) {
663 echo ' <tr><td>';
664 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
665 echo ' <tr><td>';
666 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">';
667 echo ' <tr><td ALIGN="left" bgcolor="'.$color[9].'">';
668 echo ' <b>' . _("Attachments") . ':</b>';
669 echo ' </td></tr>';
670 echo ' <tr><td>';
671 echo ' <table width="100%" cellpadding="2" cellspacing="2" align="center"'.' border="0" bgcolor="'.$color[0].'"><tr><td>';
672 echo $attachmentsdisplay;
673 echo ' </td></tr></table>';
674 echo ' </table></td></tr>';
675 echo ' </table></td></tr>';
676 echo ' </table>';
677 echo ' </td></tr>';
678 }
679 echo '</table>';
680
681
682 /* show attached images inline -- if pref'fed so */
683 if (($attachment_common_show_images) &&
684 is_array($attachment_common_show_images_list)) {
685 foreach ($attachment_common_show_images_list as $img) {
686 $imgurl = '../src/download.php' .
687 '?' .
688 'passed_id=' . urlencode($img['passed_id']) .
689 '&amp;mailbox=' . urlencode($mailbox) .
690 '&amp;ent_id=' . urlencode($img['ent_id']) .
691 '&amp;absolute_dl=true';
692
693 echo html_tag( 'table', "\n" .
694 html_tag( 'tr', "\n" .
695 html_tag( 'td', '<img src="' . $imgurl . '">' ."\n", 'left'
696 )
697 ) ,
698 'center', '', 'cellspacing=0 border="0" cellpadding="2"');
699 }
700 }
701
702 do_hook('read_body_bottom');
703 do_hook('html_bottom');
704 //$message->clean_up();
705 sqimap_logout($imapConnection);
706 ?>
707 </body>
708 </html>