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