make use of the location field
[squirrelmail.git] / src / read_body.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * read_body.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
35586184 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$
a07cd1a4 13 */
35586184 14
15require_once('../src/validate.php');
16require_once('../functions/imap.php');
17require_once('../functions/mime.php');
18require_once('../functions/date.php');
19require_once('../functions/url_parser.php');
57257333 20require_once('../functions/smtp.php');
fab3baa6 21require_once('../functions/html.php');
38c944cc 22
a07cd1a4 23/**
1fca12b5 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 */
c615b1da 30function findNextMessage($passed_id) {
31 global $msort, $msgs, $sort,
cf710efe 32 $thread_sort_messages, $allow_server_sort,
60a3e687 33 $server_sort_array;
2728fa19 34 if (!is_array($server_sort_array)) {
35 $thread_sort_messages = 0;
794d59c0 36 $allow_server_sort = FALSE;
2728fa19 37 }
a07cd1a4 38 $result = -1;
c615b1da 39 if ($thread_sort_messages || $allow_server_sort) {
60a3e687 40 reset($server_sort_array);
41 while(list($key, $value) = each ($server_sort_array)) {
c615b1da 42 if ($passed_id == $value) {
1fca12b5 43 if ($key == (count($server_sort_array) - 1)) {
60a3e687 44 $result = -1;
45 break;
46 }
1fca12b5 47 $result = $server_sort_array[$key + 1];
60a3e687 48 break;
789b4d79 49 }
60a3e687 50 }
1fca12b5 51 }
c615b1da 52 elseif ($sort == 6 && !$allow_server_sort &&
53 !$thread_sort_messages ) {
54 if ($passed_id != 1) {
55 $result = $passed_id - 1;
a07cd1a4 56 }
1fca12b5 57 }
c615b1da 58 elseif (!$allow_server_sort && !$thread_sort_messages ) {
75ef78d8 59 if (!is_array($msort)) {
60 return -1;
61 }
a07cd1a4 62 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
c615b1da 63 if ($passed_id == $msgs[$key]['ID']) {
a07cd1a4 64 next($msort);
65 $key = key($msort);
1fca12b5 66 if (isset($key)){
a07cd1a4 67 $result = $msgs[$key]['ID'];
68 break;
1fca12b5 69 }
10f0ce72 70 }
71 }
10f0ce72 72 }
a07cd1a4 73 return ($result);
74}
75
a07cd1a4 76/** returns the index of the previous message from the array. */
c615b1da 77function findPreviousMessage($numMessages, $passed_id) {
78 global $msort, $sort, $msgs,
79 $thread_sort_messages,
60a3e687 80 $allow_server_sort, $server_sort_array;
a07cd1a4 81 $result = -1;
2728fa19 82 if (!is_array($server_sort_array)) {
83 $thread_sort_messages = 0;
794d59c0 84 $allow_server_sort = FALSE;
2728fa19 85 }
c615b1da 86 if ($thread_sort_messages || $allow_server_sort ) {
60a3e687 87 reset($server_sort_array);
88 while(list($key, $value) = each ($server_sort_array)) {
c615b1da 89 if ($passed_id == $value) {
60a3e687 90 if ($key == 0) {
91 $result = -1;
92 break;
93 }
94 $result = $server_sort_array[$key -1];
95 break;
789b4d79 96 }
60a3e687 97 }
789b4d79 98 }
c615b1da 99 elseif ($sort == 6 && !$allow_server_sort &&
100 !$thread_sort_messages) {
101 if ($passed_id != $numMessages) {
102 $result = $passed_id + 1;
a07cd1a4 103 }
60a3e687 104 }
c615b1da 105 elseif (!$thread_sort_messages && !$allow_server_sort) {
1fca12b5 106 if (!is_array($msort)) {
75ef78d8 107 return -1;
1fca12b5 108 }
a07cd1a4 109 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
c615b1da 110 if ($passed_id == $msgs[$key]['ID']) {
a07cd1a4 111 prev($msort);
112 $key = key($msort);
113 if (isset($key)) {
c615b1da 114 echo $msort[$key];
a07cd1a4 115 $result = $msgs[$key]['ID'];
116 break;
10f0ce72 117 }
118 }
10f0ce72 119 }
a07cd1a4 120 }
121 return ($result);
122}
10f0ce72 123
a07cd1a4 124/**
1fca12b5 125 * Displays a link to a page where the message is displayed more
126 * "printer friendly".
127 */
c615b1da 128function printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color) {
129 global $javascript_on;
a07cd1a4 130
c615b1da 131 $params = '?passed_ent_id=' . $passed_ent_id .
1fca12b5 132 '&mailbox=' . urlencode($mailbox) .
133 '&passed_id=' . $passed_id;
10f0ce72 134
a07cd1a4 135 $print_text = _("View Printable Version");
10f0ce72 136
c615b1da 137 $result = '';
a07cd1a4 138 /* Output the link. */
139 if ($javascript_on) {
3d570ba0 140 $result .= '<script language="javascript" type="text/javascript">' . "\n" .
a07cd1a4 141 '<!--' . "\n" .
142 " function printFormat() {\n" .
143 ' window.open("../src/printer_friendly_main.php' .
c615b1da 144 $params . '","Print","width=800,height=600");' . "\n".
a07cd1a4 145 " }\n" .
146 "// -->\n" .
147 "</script>\n" .
b5058e9e 148 "<a href=\"javascript:printFormat();\">$print_text</a>\n";
a07cd1a4 149 } else {
b5058e9e 150 $result .= '<A target="_blank" HREF="../src/printer_friendly_bottom.php' .
151 "$params\">$print_text</a>\n";
a07cd1a4 152 }
a07cd1a4 153 return ($result);
154}
155
57257333 156function ServerMDNSupport( $read ) {
f69feefe 157 /* escaping $ doesn't work -> \x36 */
158 $ret = preg_match( '/(\x36MDNSent|\\\*)/i', $read );
57257333 159 return ( $ret );
160}
161
c615b1da 162function SendMDN ( $mailbox, $passed_id, $sender, $message) {
163 global $username, $attachment_dir, $SERVER_NAME,
164 $version, $attachments;
57257333 165
5200c026 166 $header = $message->header;
57257333 167 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
5200c026 168
169 $recipient_o = $header->dnt;
170 $recipient = $recipient_o->getAddress(true);
57257333 171
172 // part 1 (RFC2298)
173
174 $senton = getLongDateString( $header->date );
175 $to_array = $header->to;
176 $to = '';
177 foreach ($to_array as $line) {
af568a82 178 $to .= ' '.$line->getAddress();
57257333 179 }
180
181 $subject = $header->subject;
182 $now = getLongDateString( time() );
46bb8da8 183
78db1583 184 set_my_charset();
185
46bb8da8 186 $body = _("Your message") . "\r\n\r\n" .
187 "\t" . _("To:") . ' ' . $to . "\r\n" .
188 "\t" . _("Subject:") . ' ' . $subject . "\r\n" .
189 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
190 "\r\n" .
191 sprintf( _("Was displayed on %s"), $now );
f69feefe 192
57257333 193 // part2 (RFC2298)
57257333 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
57257333 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";
aa866a40 216 $newAttachment['session']=-1;
57257333 217 $attachments[] = $newAttachment;
5200c026 218
5200c026 219 return (SendMessage($recipient, '', '', _("Read:") . ' ' . $subject,
c615b1da 220 $body, 0, True, 3, -1) );
57257333 221}
222
223
c615b1da 224function ToggleMDNflag ( $set ,$imapConnection, $mailbox, $passed_id, $uid_support) {
0892e427 225 $sg = $set?'+':'-';
226 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
0892e427 227 $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
507d14ea 228 $readmessage, $uid_support);
57257333 229}
230
231function ClearAttachments() {
232 global $username, $attachments, $attachment_dir;
233
234 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
235
aa866a40 236 $rem_attachments = array();
57257333 237 foreach ($attachments as $info) {
b2c19764 238 if ($info['session'] == -1) {
aa866a40 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 }
68c3b52a 247 $attachments = $rem_attachments;
57257333 248}
249
4d0cd98b 250function formatRecipientString($recipients, $item ) {
c615b1da 251 global $show_more_cc, $show_more, $show_more_bcc,
38c944cc 252 $PHP_SELF;
4d0cd98b 253
38c944cc 254 if ((is_array($recipients)) && (isset($recipients[0]))) {
1fca12b5 255 $string = '';
4d0cd98b 256 $ary = $recipients;
38c944cc 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 }
4d0cd98b 281
38c944cc 282 $cnt = count($ary);
c615b1da 283 $i = 0;
38c944cc 284 while ($i < $cnt) {
c615b1da 285 $ary[$i] = htmlspecialchars($ary[$i]->getAddress());
4d0cd98b 286 if ($string) {
38c944cc 287 $string .= '<BR>'.$ary[$i];
4d0cd98b 288 } else {
38c944cc 289 $string = $ary[$i];
290 if ($cnt>1) {
291 $string .= '&nbsp;(<A HREF="'.$url;
292 if ($show) {
c615b1da 293 $string .= '">'._("less").'</A>)';
38c944cc 294 } else {
c615b1da 295 $string .= '">'._("more").'</A>)';
38c944cc 296 break;
297 }
298 }
4d0cd98b 299 }
4d0cd98b 300 $i++;
1fca12b5 301 }
4d0cd98b 302 }
303 else {
1fca12b5 304 $string = '';
4d0cd98b 305 }
c615b1da 306 return $string;
307}
308
af568a82 309function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
310 $color, $FirstTimeSee) {
c615b1da 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->header;
316 $env = array();
88d3af4f 317 $env[_("Subject")] = htmlspecialchars($header->subject);
c615b1da 318 $from_o = $header->from;
319 if (is_object($from_o)) {
320 $from_name = $from_o->getAddress();
321 } else {
322 $from_name = _("Unknown sender");
323 }
324 $env[_("From")] = htmlspecialchars($from_name);
88d3af4f 325 $env[_("Date")] = getLongDateString($header->date);
c615b1da 326 $env[_("To")] = formatRecipientString($header->to, "to");
327 $env[_("Cc")] = formatRecipientString($header->cc, "cc");
328 $env[_("Bcc")] = formatRecipientString($header->bcc, "bcc");
329 if ($default_use_priority) {
330 $env[_("Priority")] = getPriorityStr($header->priority);
331 }
332 if ($show_xmailer_default) {
333 $env[_("Mailer")] = $header->xmailer;
334 }
335 if ($default_use_mdn) {
336 if ($mdn_user_support) {
337 if ($header->dnt) {
338 if ($message->is_mdnsent) {
339 $env[_("Read receipt")] = _("send");
340 } else {
341 if ( !($mailbox == $draft_folder ||
342 $mailbox == $sent_folder || $message->is_deleted)) {
343 $mdn_url = $PHP_SELF . '&sendreceipt=1';
c615b1da 344 if ($FirstTimeSee && $javascript_on) {
345 $script = '<script language="JavaScript" type="text/javascript">' ."\n";
346 $script .= '<!--'. "\n";
347 $script .= 'if(window.confirm("' .
348 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
349 '")) { '."\n" .
350 ' sendMDN()'.
351 '}' . "\n";
352 $script .= '// -->'. "\n";
353 $script .= '</script>'. "\n";
354 echo $script;
355 }
356 $env[_("Read receipt")] = _("requested") .
357 '&nbsp;<a href="'.$mdn_url.'">['. _("Send read receipt now") .']</a>';
358 } else {
359 $env[_("Read receipt")] = _("requested");
360 }
361 }
362 }
363 }
364 }
365
366 $s = '<table width="100%" cellpadding="0" cellspacing="0" border="0" ' .
367 'align="center">';
368 foreach ($env as $key => $val) {
369 if ($val) {
370 $s .= '<tr>';
371 $s .= html_tag( 'td', '<b>'.$key.':&nbsp;&nbsp;</b>', 'right', $color[0], 'valign="top" width="20%"') . "\n";
372 $s .= html_tag( 'td', $val, 'left', $color[0], 'valign="top" width="80%"');
373 $s .= "\n</tr>";
374 }
375 }
376 $s .= '</table>';
7172cad7 377 echo $s;
c615b1da 378}
379
7172cad7 380function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response) {
c615b1da 381 global $base_uri, $sent_folder, $draft_folder, $where, $what, $color, $sort,
8fde8417 382 $startMessage, $compose_new_win, $PHP_SELF, $save_as_draft;
c615b1da 383
384 $topbar_delimiter = '&nbsp;|&nbsp;';
f099d05f 385 $urlMailbox = urlencode($mailbox);
c615b1da 386 $s = '<table width="100%" cellpadding="3" cellspacing="0" align="center"'.
387 ' border="0" bgcolor="'.$color[9].'"><tr><td align="left" width="33%"><small>';
388
389 $msgs_url = $base_uri . 'src/';
390 if (isset($where) && isset($what)) {
d215ca7d 391 $msgs_url .= 'search.php?where='.urlencode($where).
c615b1da 392 '&amp;what='.urlencode($what).'&amp;mailbox='.$urlMailbox;
d215ca7d 393 $msgs_str = _("Search results");
c615b1da 394 } else {
395 $msgs_url .= 'right_main.php?sort='.$sort.'&amp;startMessage='.
396 $startMessage.'&amp;mailbox='.$urlMailbox;
d215ca7d 397 $msgs_str = _("Message List");
c615b1da 398 }
d215ca7d 399 $s .= '<a href="'. $msgs_url.'">'.$msgs_str.'</a>';
c615b1da 400 $s .= $topbar_delimiter;
401
402 $delete_url = $base_uri . 'src/delete_message.php?mailbox='.$urlMailbox.
403 '&amp;message='.$passed_id.'&amp;';
404 if (!(isset($passed_ent_id) && $passed_ent_id)) {
405 if ($where && $what) {
406 $delete_url .= 'where=' . urlencode($where) . '&amp;what=' . urlencode($what);
407 } else {
408 $delete_url .= 'sort='. $sort . '&amp;startMessage='. $startMessage;
409 }
410 $s .= '<a href="'. $delete_url.'">'._("Delete").'</a>';
411 }
412
413 $comp_uri = $base_uri . 'src/compose.php'.
414 '?passed_id='.$passed_id.
415 '&amp;mailbox='.$urlMailbox.
8fde8417 416 (isset($passed_ent_id)?'&amp;passed_ent_id='.$passed_ent_id:'');
c615b1da 417
418 if (($mailbox == $draft_folder) && ($save_as_draft)) {
419 $comp_alt_uri = $comp_uri . '&amp;action=draft';
420 $comp_alt_string = _("Resume Draft");
421 } else if ($mailbox == $sent_folder) {
422 $comp_alt_uri = $comp_uri . '&amp;action=edit_as_new';
423 $comp_alt_string = _("Edit Message as New");
424 }
425 if (isset($comp_alt_uri)) {
426 $s .= $topbar_delimiter;
427 if ($compose_new_win == '1') {
428 $s .= '<a href="javascript:void(0)" '.
8fde8417 429 'onclick="comp_in_new(\''.$comp_alt_uri.'\')">'.$comp_alt_string.'</a>';
c615b1da 430 } else {
431 $s .= '<a href="'.$comp_alt_uri.'">'.$comp_alt_string.'</a>';
432 }
433 }
434
435 $s .= '</small></td><td align="center" width="33%"><small>';
436
437 if (!(isset($where) && isset($what)) && !$passed_ent_id) {
438 $prev = findPreviousMessage($mbx_response['EXISTS'], $passed_id);
439 $next = findNextMessage($passed_id);
440 if ($prev != -1) {
441 $uri = $base_uri . 'src/read_body.php?passed_id='.$prev.
442 '&amp;mailbox='.$urlMailbox.'&amp;sort='.$sort.
443 '&amp;startMessage='.$startMessage.'&amp;show_more=0';
444 $s .= '<a href="'.$uri.'">'._("Previous").'</a>';
445 } else {
446 $s .= _("Previous");
447 }
448 $s .= $topbar_delimiter;
449 if ($next != -1) {
450 $uri = $base_uri . 'src/read_body.php?passed_id='.$next.
451 '&amp;mailbox='.$urlMailbox.'&amp;sort='.$sort.
452 '&amp;startMessage='.$startMessage.'&amp;show_more=0';
453 $s .= '<a href="'.$uri.'">'._("Next").'</a>';
454 } else {
455 $s .= _("Next");
456 }
457 } else if (isset($passed_ent_id) && $passed_ent_id) {
7172cad7 458 /* code for navigating through attached message/rfc822 messages */
459 $url = set_url_var($PHP_SELF, 'passed_ent_id',0);
460 $s .= '<a href="'.$url.'">'._("View Message").'</a>';
461 $par_ent_id = $message->parent->entity_id;
462 if ($par_ent_id) {
463 $par_ent_id = substr($par_ent_id,0,-2);
464 $s .= $topbar_delimiter;
465 $url = set_url_var($PHP_SELF, 'passed_ent_id',$par_ent_id);
466 $s .= '<a href="'.$url.'">'._("Up").'</a>';
467 }
c615b1da 468 }
469
470 $s .= '</small></td><td align="right" width="33%"><small>';
471
472 $comp_action_uri = $comp_uri . '&amp;action=forward';
473 if ($compose_new_win == '1') {
474 $s .= '<a href="javascript:void(0)" '.
475 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Forward").'</a>';
476 } else {
477 $s .= '<a href="'.$comp_action_uri.'">'._("Forward").'</a>';
478 }
479 $s .= $topbar_delimiter;
480
481 $comp_action_uri = decodeHeader($comp_uri . '&amp;action=reply');
482 if ($compose_new_win == '1') {
483 $s .= '<a href="javascript:void(0)" '.
484 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Reply").'</a>';
485 } else {
486 $s .= '<a href="'.$comp_action_uri.'">'._("Reply").'</a>';
487 }
488 $s .= $topbar_delimiter;
489
490 $comp_action_uri = $comp_uri . '&amp;action=reply_all';
491 if ($compose_new_win == '1') {
492 $s .= '<a href="javascript:void(0)" '.
493 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Reply All").'</a>';
494 } else {
495 $s .= '<a href="'.$comp_action_uri.'">'._("Reply All").'</a>';
496 }
497 $s .= '</small></td></tr></table>';
7172cad7 498 echo $s;
c615b1da 499}
500
501function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
8fde8417 502 global $QUERY_STRING, $base_uri;
c615b1da 503
f099d05f 504 $urlMailbox = urlencode($mailbox);
7172cad7 505 $s = '<table width="100%" cellpadding="3" cellspacing="0" align="center"'.
506 ' border="0" bgcolor="'.$color[9].'">'. "\n".
c615b1da 507 '<tr align="right"><td valign="top" align="right"><small>';
8fde8417 508 $url = $base_uri.'src/view_header.php?'.$QUERY_STRING;
509 $s .= '<a href="'.$url.'">'.("View Full Header").'</a>';
c615b1da 510 /* Output the printer friendly link if we are in subtle mode. */
511 $s .= '&nbsp;|&nbsp;'.
512 printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color);
7172cad7 513 echo $s;
c615b1da 514 do_hook("read_body_header_right");
c8e1425b 515 echo '</small></td></tr>';
516 echo '</table>'."\n";
4d0cd98b 517}
518
519
57257333 520/*
521 * Main of read_boby.php --------------------------------------------------
522 */
523
524/*
525 Urled vars
526 ----------
527 $passed_id
528*/
a07cd1a4 529
38c944cc 530global $uid_support, $sqimap_capabilities;
531
6a108031 532if (isset($mailbox)) {
4366bea4 533 $mailbox = urldecode( $mailbox );
534}
38c944cc 535
1fca12b5 536$imapConnection = sqimap_login($username, $key, $imapServerAddress,
537 $imapPort, 0);
38c944cc 538
539$mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
540
541if (!isset($messages)) {
542 $messages = array();
543 session_register('messages');
38c944cc 544}
545
546/**
547 * $message contains all information about the message
548 * including header and body
549 */
37d2a6ee 550
551$uidvalidity = $mbx_response['UIDVALIDITY'];
552
553if (!isset($messages[$uidvalidity])) {
554 $messages[$uidvalidity] = array();
555}
5200c026 556if (!isset($messages[$uidvalidity][$passed_id]) || !$uid_support) {
557 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
558 $messages[$uidvalidity][$passed_id] = $message;
38c944cc 559} else {
6a108031 560// $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
5200c026 561 $message = $messages[$uidvalidity][$passed_id];
562}
af568a82 563$FirstTimeSee = !$message->is_seen;
564$message->is_seen = true;
565$messages[$uidvalidity][$passed_id] = $message;
566
5200c026 567if (isset($passed_ent_id)) {
568 $message = $message->getEntity($passed_ent_id);
569 $message->id = $passed_id;
570 $message->mailbox = $mailbox;
c615b1da 571} else {
572 $passed_ent_id = 0;
38c944cc 573}
5200c026 574$header = $message->header;
57257333 575
5200c026 576//do_hook('html_top');
57257333 577
5200c026 578/* =============================================================================
579 * block for handling incoming url vars
580 *
581 * =============================================================================
582 */
583
5200c026 584if (isset($sendreceipt)) {
585 if ( !$message->is_mdnsent ) {
586 if (isset($identity) ) {
587 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
588 } else {
589 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
590 }
591
592 $final_recipient = trim($final_recipient);
593 if ($final_recipient == '' ) {
594 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
595 }
af568a82 596 $supportMDN = ServerMDNSupport($mbx_response["PERMANENTFLAGS"]);
c615b1da 597 if ( SendMDN( $mailbox, $passed_id, $final_recipient, $message ) > 0 && $supportMDN ) {
598 ToggleMDNflag( true, $imapConnection, $mailbox, $passed_id, $uid_support);
5200c026 599 $message->is_mdnsent = true;
6a108031 600 $messages[$uidvalidity][$passed_id]=$message;
5200c026 601 }
602 ClearAttachments();
603 }
604}
5200c026 605/* =============================================================================
606 * end block for handling incoming url vars
607 *
608 * =============================================================================
609 */
38c944cc 610$msgs[$passed_id]['FLAG_SEEN'] = true;
38c944cc 611
5200c026 612$messagebody = '';
6a108031 613$ent_ar = $message->findDisplayEntity(array());
6a108031 614for ($i = 0; $i < count($ent_ar); $i++) {
615 $messagebody .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox);
c8e1425b 616 $messagebody .= '<hr noshade size=1>';
38c944cc 617}
6a108031 618
c615b1da 619displayPageHeader($color, $mailbox);
620do_hook('read_body_top');
7172cad7 621formatMenuBar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response);
af568a82 622formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee);
c8e1425b 623do_hook("read_body_header");
7172cad7 624formatToolbar($mailbox,$passed_id,$passed_ent_id,$message, $color);
c615b1da 625echo '<table width="100%" cellpadding="3" cellspacing="3" align="center"'.
626 ' border="0" bgcolor="'.$color[4].'">';
627echo '<tr><td>'.$messagebody.'</td></tr>';
628echo '<tr><td>'.formatAttachments($message,$ent_ar,$mailbox, $passed_id).'</td></tr>';
629echo '</table>';
a07cd1a4 630
631/* show attached images inline -- if pref'fed so */
5be9f195 632if (($attachment_common_show_images) &&
a07cd1a4 633 is_array($attachment_common_show_images_list)) {
634 foreach ($attachment_common_show_images_list as $img) {
5be9f195 635 $imgurl = '../src/download.php' .
57257333 636 '?' .
cd7b8833 637 'passed_id=' . urlencode($img['passed_id']) .
3d570ba0 638 '&amp;mailbox=' . urlencode($mailbox) .
639 '&amp;passed_ent_id=' . urlencode($img['ent_id']) .
640 '&amp;absolute_dl=true';
5be9f195 641
b5058e9e 642 echo html_tag( 'table', "\n" .
643 html_tag( 'tr', "\n" .
644 html_tag( 'td', '<img src="' . $imgurl . '">' ."\n", 'left'
645 )
646 ) ,
647 'center', '', 'cellspacing=0 border="0" cellpadding="2"');
10f0ce72 648 }
a07cd1a4 649}
650
c615b1da 651do_hook('read_body_bottom');
652do_hook('html_bottom');
d7eab095 653//$message->clean_up();
a07cd1a4 654sqimap_logout($imapConnection);
655?>
c615b1da 656</body>
657</html>