Typo. _ was missing.
[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, $squirrelmail_language;
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 if (function_exists($languages[$squrrelmail_language]['XTRA_CODE'])) {
190 $body = $languages[$squirrelmail_language]['XTRA_CODE']('encode', $body);
191 }
192
193 // part2 (RFC2298)
194 $original_recipient = $to;
195 $original_message_id = $header->message_id;
196
197 $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
198 if ($original_recipient != '') {
199 $part2 .= "Original-Recipient : $original_recipient\r\n";
200 }
201 $final_recipient = $sender;
202 $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" .
203 "Original-Message-ID : $original_message_id\r\n" .
204 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
205
206 $localfilename = GenerateRandomString(32, 'FILE', 7);
207 $full_localfilename = "$hashed_attachment_dir/$localfilename";
208
209 $fp = fopen( $full_localfilename, 'w');
210 fwrite ($fp, $part2);
211 fclose($fp);
212
213 $newAttachment = array();
214 $newAttachment['localfilename'] = $localfilename;
215 $newAttachment['type'] = "message/disposition-notification";
216 $newAttachment['session']=-1;
217 $attachments[] = $newAttachment;
218
219 return (SendMessage($recipient, '', '', _("Read:") . ' ' . $subject,
220 $body, 0, True, 3, -1) );
221 }
222
223
224 function ToggleMDNflag ( $set ,$imapConnection, $mailbox, $passed_id, $uid_support) {
225 $sg = $set?'+':'-';
226 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
227 $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
228 $readmessage, $uid_support);
229 }
230
231 function ClearAttachments() {
232 global $username, $attachments, $attachment_dir;
233
234 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
235
236 $rem_attachments = array();
237 foreach ($attachments as $info) {
238 if ($info['session'] == -1) {
239 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
240 if (file_exists($attached_file)) {
241 unlink($attached_file);
242 }
243 } else {
244 $rem_attachments[] = $info;
245 }
246 }
247 $attachments = $rem_attachments;
248 }
249
250 function formatRecipientString($recipients, $item ) {
251 global $show_more_cc, $show_more, $show_more_bcc,
252 $PHP_SELF;
253
254 if ((is_array($recipients)) && (isset($recipients[0]))) {
255 $string = '';
256 $ary = $recipients;
257 $show = false;
258
259 if ($item == 'to') {
260 if ($show_more) {
261 $show = true;
262 $url = set_url_var($PHP_SELF, 'show_more',0);
263 } else {
264 $url = set_url_var($PHP_SELF, 'show_more',1);
265 }
266 } else if ($item == 'cc') {
267 if ($show_more_cc) {
268 $url = set_url_var($PHP_SELF, 'show_more_cc',0);
269 $show = true;
270 } else {
271 $url = set_url_var($PHP_SELF, 'show_more_cc',1);
272 }
273 } else if ($item == 'bcc') {
274 if ($show_more_bcc) {
275 $url = set_url_var($PHP_SELF, 'show_more_bcc',0);
276 $show = true;
277 } else {
278 $url = set_url_var($PHP_SELF, 'show_more_bcc',1);
279 }
280 }
281
282 $cnt = count($ary);
283 $i = 0;
284 while ($i < $cnt) {
285 $ary[$i] = htmlspecialchars($ary[$i]->getAddress());
286 if ($string) {
287 $string .= '<BR>'.$ary[$i];
288 } else {
289 $string = $ary[$i];
290 if ($cnt>1) {
291 $string .= '&nbsp;(<A HREF="'.$url;
292 if ($show) {
293 $string .= '">'._("less").'</A>)';
294 } else {
295 $string .= '">'._("more").'</A>)';
296 break;
297 }
298 }
299 }
300 $i++;
301 }
302 }
303 else {
304 $string = '';
305 }
306 return $string;
307 }
308
309 function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
310 $color, $FirstTimeSee) {
311 global $msn_user_support, $default_use_mdn, $draft_folder, $sent_folder,
312 $default_use_priority, $show_xmailer_default,
313 $mdn_user_support, $PHP_SELF, $javascript_on;
314
315 $header = $message->rfc822_header;
316 $env = array();
317 $env[_("Subject")] = htmlspecialchars(decodeHeader($header->subject));
318 $from_name = $header->getAddr_s('from');
319 if (!$from_name) {
320 $from_name = $header->getAddr_s('sender');
321 if (!$from_name) {
322 $from_name = _("Unknown sender");
323 }
324 }
325 $env[_("From")] = htmlspecialchars(decodeHeader($from_name));
326 $env[_("Date")] = getLongDateString($header->date);
327 $env[_("To")] = formatRecipientString($header->to, "to");
328 $env[_("Cc")] = formatRecipientString($header->cc, "cc");
329 $env[_("Bcc")] = formatRecipientString($header->bcc, "bcc");
330 if ($default_use_priority) {
331 $env[_("Priority")] = getPriorityStr($header->priority);
332 }
333 if ($show_xmailer_default) {
334 $env[_("Mailer")] = decodeHeader($header->xmailer);
335 }
336 if ($default_use_mdn) {
337 if ($mdn_user_support) {
338 if ($header->dnt) {
339 if ($message->is_mdnsent) {
340 $env[_("Read receipt")] = _("send");
341 } else {
342 if ( !($mailbox == $draft_folder ||
343 $mailbox == $sent_folder ||
344 $message->is_deleted ||
345 $passed_ent_id)) {
346 $mdn_url = $PHP_SELF . '&sendreceipt=1';
347 if ($FirstTimeSee && $javascript_on) {
348 $script = '<script language="JavaScript" type="text/javascript">' ."\n";
349 $script .= '<!--'. "\n";
350 $script .= 'if(window.confirm("' .
351 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
352 '")) { '."\n" .
353 ' sendMDN()'.
354 '}' . "\n";
355 $script .= '// -->'. "\n";
356 $script .= '</script>'. "\n";
357 echo $script;
358 }
359 $env[_("Read receipt")] = _("requested") .
360 '&nbsp;<a href="'.$mdn_url.'">['. _("Send read receipt now") .']</a>';
361 } else {
362 $env[_("Read receipt")] = _("requested");
363 }
364 }
365 }
366 }
367 }
368
369 $s = '<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"';
370 $s .= ' ALIGN="center" BGCOLOR="' . $color[0] . '">';
371 foreach ($env as $key => $val) {
372 if ($val) {
373 $s .= '<TR>';
374 $s .= html_tag('TD', '<B>' . $key . ':&nbsp;&nbsp;</B>', 'RIGHT', '', 'VALIGN="TOP" WIDTH="20%"') . "\n";
375 $s .= html_tag('TD', $val, 'left', '', 'VALIGN="TOP" WIDTH="80%"') . "\n";
376 $s .= '</TR>';
377 }
378 }
379 echo $s;
380 do_hook("read_body_header");
381 formatToolbar($mailbox,$passed_id,$passed_ent_id,$message, $color);
382 echo '</table>';
383 }
384
385 function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response) {
386 global $base_uri, $sent_folder, $draft_folder, $where, $what, $color, $sort,
387 $startMessage, $compose_new_win, $PHP_SELF, $save_as_draft,
388 $enable_forward_as_attachment;
389
390 $topbar_delimiter = '&nbsp;|&nbsp;';
391 $urlMailbox = urlencode($mailbox);
392 $s = '<table width="100%" cellpadding="3" cellspacing="0" align="center"'.
393 ' border="0" bgcolor="'.$color[9].'"><tr><td align="left" width="33%"><small>';
394
395 $msgs_url = $base_uri . 'src/';
396 if (isset($where) && isset($what)) {
397 $msgs_url .= 'search.php?where='.urlencode($where).
398 '&amp;what='.urlencode($what).'&amp;mailbox='.$urlMailbox;
399 $msgs_str = _("Search results");
400 } else {
401 $msgs_url .= 'right_main.php?sort='.$sort.'&amp;startMessage='.
402 $startMessage.'&amp;mailbox='.$urlMailbox;
403 $msgs_str = _("Message List");
404 }
405 $s .= '<a href="'. $msgs_url.'">'.$msgs_str.'</a>';
406 $s .= $topbar_delimiter;
407
408 $delete_url = $base_uri . 'src/delete_message.php?mailbox='.$urlMailbox.
409 '&amp;message='.$passed_id.'&amp;';
410 if (!(isset($passed_ent_id) && $passed_ent_id)) {
411 if ($where && $what) {
412 $delete_url .= 'where=' . urlencode($where) . '&amp;what=' . urlencode($what);
413 } else {
414 $delete_url .= 'sort='. $sort . '&amp;startMessage='. $startMessage;
415 }
416 $s .= '<a href="'. $delete_url.'">'._("Delete").'</a>';
417 }
418
419 $comp_uri = $base_uri . 'src/compose.php'.
420 '?passed_id='.$passed_id.
421 '&amp;mailbox='.$urlMailbox.
422 (isset($passed_ent_id)?'&amp;passed_ent_id='.$passed_ent_id:'');
423
424 if (($mailbox == $draft_folder) && ($save_as_draft)) {
425 $comp_alt_uri = $comp_uri . '&amp;action=draft';
426 $comp_alt_string = _("Resume Draft");
427 } else if ($mailbox == $sent_folder) {
428 $comp_alt_uri = $comp_uri . '&amp;action=edit_as_new';
429 $comp_alt_string = _("Edit Message as New");
430 }
431 if (isset($comp_alt_uri)) {
432 $s .= $topbar_delimiter;
433 if ($compose_new_win == '1') {
434 $s .= '<a href="javascript:void(0)" '.
435 'onclick="comp_in_new(\''.$comp_alt_uri.'\')">'.$comp_alt_string.'</a>';
436 } else {
437 $s .= '<a href="'.$comp_alt_uri.'">'.$comp_alt_string.'</a>';
438 }
439 }
440
441 $s .= '</small></td><td align="center" width="33%"><small>';
442
443 if (!(isset($where) && isset($what)) && !$passed_ent_id) {
444 $prev = findPreviousMessage($mbx_response['EXISTS'], $passed_id);
445 $next = findNextMessage($passed_id);
446 if ($prev != -1) {
447 $uri = $base_uri . 'src/read_body.php?passed_id='.$prev.
448 '&amp;mailbox='.$urlMailbox.'&amp;sort='.$sort.
449 '&amp;startMessage='.$startMessage.'&amp;show_more=0';
450 $s .= '<a href="'.$uri.'">'._("Previous").'</a>';
451 } else {
452 $s .= _("Previous");
453 }
454 $s .= $topbar_delimiter;
455 if ($next != -1) {
456 $uri = $base_uri . 'src/read_body.php?passed_id='.$next.
457 '&amp;mailbox='.$urlMailbox.'&amp;sort='.$sort.
458 '&amp;startMessage='.$startMessage.'&amp;show_more=0';
459 $s .= '<a href="'.$uri.'">'._("Next").'</a>';
460 } else {
461 $s .= _("Next");
462 }
463 } else if (isset($passed_ent_id) && $passed_ent_id) {
464 /* code for navigating through attached message/rfc822 messages */
465 $url = set_url_var($PHP_SELF, 'passed_ent_id',0);
466 $s .= '<a href="'.$url.'">'._("View Message").'</a>';
467 $par_ent_id = $message->parent->entity_id;
468 if ($par_ent_id) {
469 $par_ent_id = substr($par_ent_id,0,-2);
470 $s .= $topbar_delimiter;
471 $url = set_url_var($PHP_SELF, 'passed_ent_id',$par_ent_id);
472 $s .= '<a href="'.$url.'">'._("Up").'</a>';
473 }
474 }
475
476 $s .= '</small></td><td align="right" width="33%" nowrap><small>';
477 $comp_action_uri = $comp_uri . '&amp;action=forward';
478 if ($compose_new_win == '1') {
479 $s .= '<a href="javascript:void(0)" '.
480 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Forward").'</a>';
481 } else {
482 $s .= '<a href="'.$comp_action_uri.'">'._("Forward").'</a>';
483 }
484 $s .= $topbar_delimiter;
485
486 if ($enable_forward_as_attachment) {
487 $comp_action_uri = $comp_uri . '&amp;action=forward_as_attachment';
488 if ($compose_new_win == '1') {
489 $s .= '<a href="javascript:void(0)" '.
490 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Forward as Attachment").'</a>';
491 } else {
492 $s .= '<a href="'.$comp_action_uri.'">'._("Forward as Attachment").'</a>';
493 }
494 $s .= $topbar_delimiter;
495 }
496
497 $comp_action_uri = decodeHeader($comp_uri . '&amp;action=reply');
498 if ($compose_new_win == '1') {
499 $s .= '<a href="javascript:void(0)" '.
500 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Reply").'</a>';
501 } else {
502 $s .= '<a href="'.$comp_action_uri.'">'._("Reply").'</a>';
503 }
504 $s .= $topbar_delimiter;
505
506 $comp_action_uri = $comp_uri . '&amp;action=reply_all';
507 if ($compose_new_win == '1') {
508 $s .= '<a href="javascript:void(0)" '.
509 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Reply All").'</a>';
510 } else {
511 $s .= '<a href="'.$comp_action_uri.'">'._("Reply All").'</a>';
512 }
513 $s .= '</small></td></tr></table>';
514 do_hook("read_body_menu_top");
515 echo $s;
516 do_hook("read_body_menu_bottom");
517 }
518
519 function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
520 global $QUERY_STRING, $base_uri;
521
522 $urlMailbox = urlencode($mailbox);
523 $url = $base_uri.'src/view_header.php?'.$QUERY_STRING;
524
525 $s = "<TR>\n" .
526 '<TD VALIGN="MIDDLE" ALIGN="RIGHT" WIDTH="20%"><B>' . _("Options") . ":&nbsp;&nbsp;</B></TD>\n" .
527 '<TD VALIGN="MIDDLE" ALIGN="LEFT" WIDTH="80%"><SMALL>' .
528 '<a href="'.$url.'">'._("View Full Header").'</a>';
529
530 /* Output the printer friendly link if we are in subtle mode. */
531 $s .= '&nbsp;|&nbsp;' .
532 printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color);
533 echo $s;
534 do_hook("read_body_header_right");
535 $s = "</SMALL></TD>\n" .
536 "</TR>\n";
537 echo $s;
538
539 }
540
541 /***************************/
542 /* Main of read_body.php */
543 /***************************/
544
545 /*
546 Urled vars
547 ----------
548 $passed_id
549 */
550
551 global $uid_support, $sqimap_capabilities;
552
553 if (isset($mailbox)) {
554 $mailbox = urldecode( $mailbox );
555 }
556
557 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
558 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
559
560 if (!isset($messages)) {
561 $messages = array();
562 session_register('messages');
563 }
564
565 /**
566 * $message contains all information about the message
567 * including header and body
568 */
569
570 $uidvalidity = $mbx_response['UIDVALIDITY'];
571
572 if (!isset($messages[$uidvalidity])) {
573 $messages[$uidvalidity] = array();
574 }
575 if (!isset($messages[$uidvalidity][$passed_id]) || !$uid_support) {
576 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
577 $messages[$uidvalidity][$passed_id] = $message;
578 } else {
579 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
580 // $message = $messages[$uidvalidity][$passed_id];
581 }
582 $FirstTimeSee = !$message->is_seen;
583 $message->is_seen = true;
584 $messages[$uidvalidity][$passed_id] = $message;
585
586 if (isset($passed_ent_id) && $passed_ent_id) {
587 $message = $message->getEntity($passed_ent_id);
588 if ($message->type0 != 'message' && $message->type1 != 'rfc822') {
589 $message = $message->parent;
590 }
591 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[$passed_ent_id.HEADER]", true, $response, $msg, $uid_support);
592 $rfc822_header = new rfc822_header();
593 $rfc822_header->parseHeader($read);
594 $message->rfc822_header = $rfc822_header;
595 } else {
596 $passed_ent_id = 0;
597 }
598 $header = $message->header;
599
600 do_hook('html_top');
601
602 /****************************************/
603 /* Block for handling incoming url vars */
604 /****************************************/
605
606 if (isset($sendreceipt)) {
607 if ( !$message->is_mdnsent ) {
608 if (isset($identity) ) {
609 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
610 } else {
611 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
612 }
613
614 $final_recipient = trim($final_recipient);
615 if ($final_recipient == '' ) {
616 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
617 }
618 $supportMDN = ServerMDNSupport($mbx_response["PERMANENTFLAGS"]);
619 if ( SendMDN( $mailbox, $passed_id, $final_recipient, $message ) > 0 && $supportMDN ) {
620 ToggleMDNflag( true, $imapConnection, $mailbox, $passed_id, $uid_support);
621 $message->is_mdnsent = true;
622 $messages[$uidvalidity][$passed_id]=$message;
623 }
624 ClearAttachments();
625 }
626 }
627 /***********************************************/
628 /* End of block for handling incoming url vars */
629 /***********************************************/
630
631 $msgs[$passed_id]['FLAG_SEEN'] = true;
632
633 $messagebody = '';
634 do_hook('read_body_top');
635 if ($show_html_default == 1) {
636 $ent_ar = $message->findDisplayEntity(array());
637 } else {
638 $ent_ar = $message->findDisplayEntity(array(), array('text/plain'));
639 }
640 $cnt = count($ent_ar);
641 for ($i = 0; $i < $cnt; $i++) {
642 $messagebody .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox);
643 if ($i != $cnt-1) {
644 $messagebody .= '<hr noshade size=1>';
645 }
646 }
647
648 displayPageHeader($color, $mailbox);
649 formatMenuBar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response);
650 formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee);
651 echo '<table width="100%" cellpadding="0" cellspacing="0" align="center" border="0">';
652 echo ' <tr><td>';
653 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[9].'">';
654 echo ' <tr><td>';
655 echo ' <table width="100%" cellpadding="3" cellspacing="0" align="center" border="0">';
656 echo ' <tr bgcolor="'.$color[4].'"><td>';
657 echo ' <table cellpadding="0" cellspacing="0" align="center" border="0">';
658 echo ' <tr><td><br>' . $messagebody . '</td></td>';
659 echo ' </table>';
660 echo ' </td></tr>';
661 echo ' </table></td></tr>';
662 echo ' </table>';
663 echo ' </td></tr>';
664
665 $attachmentsdisplay = formatAttachments($message,$ent_ar,$mailbox, $passed_id);
666 if ($attachmentsdisplay) {
667 echo ' <tr><td>';
668 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
669 echo ' <tr><td>';
670 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">';
671 echo ' <tr><td ALIGN="left" bgcolor="'.$color[9].'">';
672 echo ' <b>' . _("Attachments") . ':</b>';
673 echo ' </td></tr>';
674 echo ' <tr><td>';
675 echo ' <table width="100%" cellpadding="2" cellspacing="2" align="center"'.' border="0" bgcolor="'.$color[0].'"><tr><td>';
676 echo $attachmentsdisplay;
677 echo ' </td></tr></table>';
678 echo ' </table></td></tr>';
679 echo ' </table></td></tr>';
680 echo ' </table>';
681 echo ' </td></tr>';
682 }
683 echo '</table>';
684
685
686 /* show attached images inline -- if pref'fed so */
687 if (($attachment_common_show_images) &&
688 is_array($attachment_common_show_images_list)) {
689 foreach ($attachment_common_show_images_list as $img) {
690 $imgurl = '../src/download.php' .
691 '?' .
692 'passed_id=' . urlencode($img['passed_id']) .
693 '&amp;mailbox=' . urlencode($mailbox) .
694 '&amp;ent_id=' . urlencode($img['ent_id']) .
695 '&amp;absolute_dl=true';
696
697 echo html_tag( 'table', "\n" .
698 html_tag( 'tr', "\n" .
699 html_tag( 'td', '<img src="' . $imgurl . '">' ."\n", 'left'
700 )
701 ) ,
702 'center', '', 'cellspacing=0 border="0" cellpadding="2"');
703 }
704 }
705
706 do_hook('read_body_bottom');
707 do_hook('html_bottom');
708 //$message->clean_up();
709 sqimap_logout($imapConnection);
710 ?>
711 </body>
712 </html>