Bugfix, remove bcc and cc display when empty
[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');
5be9f195 21
a07cd1a4 22/**
23* Given an IMAP message id number, this will look it up in the cached
24* and sorted msgs array and return the index. Used for finding the next
25* and previous messages.
26*
27* returns the index of the next valid message from the array
28*/
29function findNextMessage() {
30 global $msort, $currentArrayIndex, $msgs, $sort;
31 $result = -1;
32
33 if ($sort == 6) {
34 if ($currentArrayIndex != 1) {
35 $result = $currentArrayIndex - 1;
36 }
37 } else {
38 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
39 if ($currentArrayIndex == $msgs[$key]['ID']) {
40 next($msort);
41 $key = key($msort);
42 if (isset($key))
43 $result = $msgs[$key]['ID'];
44 break;
10f0ce72 45 }
46 }
10f0ce72 47 }
a07cd1a4 48 return ($result);
49}
50
51/** Removes just one address from the list of addresses. */
52function RemoveAddress(&$addr_list, $addr) {
53 if ($addr != '') {
54 foreach (array_keys($addr_list, $addr) as $key_to_delete) {
55 unset($addr_list[$key_to_delete]);
10f0ce72 56 }
a07cd1a4 57 }
58}
59
60/** returns the index of the previous message from the array. */
61function findPreviousMessage() {
57257333 62 global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection,
63 $mailbox, $data_dir, $username;
64
a07cd1a4 65 $result = -1;
66
67 if ($sort == 6) {
68 $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
69 if ($currentArrayIndex != $numMessages) {
70 $result = $currentArrayIndex + 1;
71 }
72 } else {
73 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
74 if ($currentArrayIndex == $msgs[$key]['ID']) {
75 prev($msort);
76 $key = key($msort);
77 if (isset($key)) {
78 $result = $msgs[$key]['ID'];
79 break;
10f0ce72 80 }
81 }
10f0ce72 82 }
a07cd1a4 83 }
84 return ($result);
85}
10f0ce72 86
a07cd1a4 87/**
88* Displays a link to a page where the message is displayed more
89* "printer friendly".
90*/
91function printer_friendly_link() {
57257333 92 global $passed_id, $mailbox, $ent_num, $color,
93 $pf_subtle_link,
94 $javascript_on;
a07cd1a4 95
96 if (strlen(trim($mailbox)) < 1) {
97 $mailbox = 'INBOX';
98 }
10f0ce72 99
57257333 100 $params = '?passed_ent_id=' . $ent_num .
101 '&mailbox=' . urlencode($mailbox) .
102 '&passed_id=' . $passed_id;
10f0ce72 103
a07cd1a4 104 $print_text = _("View Printable Version");
10f0ce72 105
a07cd1a4 106 if (!$pf_subtle_link) {
107 /* The link is large, on the bottom of the header panel. */
57257333 108 $result = '<tr bgcolor="' . $color[0] . '">' .
109 '<td class="medText" align="right" valign="top">' .
110 '&nbsp;' .
111 '</td><td class="medText" valign="top" colspan="2">'."\n";
a07cd1a4 112 } else {
113 /* The link is subtle, below "view full header". */
114 $result = "<BR>\n";
115 }
10f0ce72 116
a07cd1a4 117 /* Output the link. */
118 if ($javascript_on) {
119 $result .= '<script language="javascript">' . "\n" .
120 '<!--' . "\n" .
121 " function printFormat() {\n" .
122 ' window.open("../src/printer_friendly_main.php' .
123 $params . '","Print","width=800,height=600");' . "\n".
124 " }\n" .
125 "// -->\n" .
126 "</script>\n" .
127 "<A HREF=\"javascript:printFormat();\">$print_text</A>\n";
128 } else {
129 $result .= '<A TARGET="_blank" HREF="../src/printer_friendly_bottom.php' .
130 "$params\">$print_text</A>\n";
131 }
10f0ce72 132
a07cd1a4 133 if (!$pf_subtle_link) {
134 /* The link is large, on the bottom of the header panel. */
57257333 135 $result .= '</td></tr>' . "\n";
10f0ce72 136 }
137
a07cd1a4 138 return ($result);
139}
140
57257333 141function ServerMDNSupport( $read ) {
142
143 $num = 0;
144 $resp = '';
145 while ($num < count($read) ) {
146 $resp .= $read[$num];
147 $num++;
148 }
149 $read[] = split(' * ', $resp);
150 $num = 0;
151 $ret = FALSE;
152 while ( !$ret && $num < count($read) ) {
ad15d687 153 $ret = preg_match( '/.*PERMANENTFLAGS.*(MDNSent|\\\*).*/i', $read[$num] );
154 /*
57257333 155 if ( ereg('PERMANENTFLAGS', $read[$num] ) ) {
156 $ret = ( ereg('mdnsent',strtolower($read[$num]) ) || ereg("\\\*", $read[$num] ) );
157 }
ad15d687 158 */
57257333 159 $num++;
160 }
161 return ( $ret );
162}
163
164function SendMDN ( $recipient , $sender) {
165 global $imapConnection, $mailbox, $username, $attachment_dir, $SERVER_NAME,
166 $version, $attachments, $identity, $data_dir, $passed_id;
167
99fbb343 168 $header = sqimap_get_message_header($imapConnection, $passed_id, $mailbox);
57257333 169 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
170
171 // part 1 (RFC2298)
172
173 $senton = getLongDateString( $header->date );
174 $to_array = $header->to;
175 $to = '';
176 foreach ($to_array as $line) {
177 $to .= " $line ";
178 }
179
180 $subject = $header->subject;
181 $now = getLongDateString( time() );
46bb8da8 182
183 $body = _("Your message") . "\r\n\r\n" .
184 "\t" . _("To:") . ' ' . $to . "\r\n" .
185 "\t" . _("Subject:") . ' ' . $subject . "\r\n" .
186 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
187 "\r\n" .
188 sprintf( _("Was displayed on %s"), $now );
189/*
57257333 190 $body = sprintf( _("This message sent on %s to %s with subject \"%s\" has been displayed on %s."),
191 $senton, $to, $subject, $now ) .
192 "\r\n" .
193 _("This is no guarantee that the message has been read or understood.") . "\r\n";
46bb8da8 194*/
57257333 195 // part2 (RFC2298)
196
197 $original_recipient = $to;
198 $original_message_id = $header->message_id;
199
200 $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
201 if ($original_recipient != '') {
202 $part2 .= "Original-Recipient : $original_recipient\r\n";
203 }
204 $final_recipient = $sender;
205 $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" .
206 "Original-Message-ID : $original_message_id\r\n" .
207 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
208
209
210 $localfilename = GenerateRandomString(32, 'FILE', 7);
211 $full_localfilename = "$hashed_attachment_dir/$localfilename";
212
213 $fp = fopen( $full_localfilename, 'w');
214 fwrite ($fp, $part2);
215 fclose($fp);
216
217 $newAttachment = array();
218 $newAttachment['localfilename'] = $localfilename;
219 $newAttachment['type'] = "message/disposition-notification";
220
221 $attachments[] = $newAttachment;
222 $MDN_to = trim($recipient);
223 $reply_id = 0;
224
54817114 225 return (SendMessage($MDN_to,'','', _("Read:") . ' ' . $subject, $body,$reply_id, True, 3) );
57257333 226}
227
228
229function ToggleMDNflag ( $set ) {
230
77b88425 231 global $imapConnection, $passed_id, $mailbox;
232
233 if ( $set ) {
234 $sg = '+';
57257333 235
57257333 236 } else {
77b88425 237 $sg = '-';
57257333 238 }
77b88425 239
46bb8da8 240 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
77b88425 241 sqimap_mailbox_select($imapConnection, $mailbox);
242 $read = sqimap_run_command ($imapConnection, $cmd, true, $response, $readmessage);
243
57257333 244}
245
246function ClearAttachments() {
247 global $username, $attachments, $attachment_dir;
248
249 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
250
251 foreach ($attachments as $info) {
252 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
253 if (file_exists($attached_file)) {
254 unlink($attached_file);
255 }
256 }
257
258 $attachments = array();
259}
260
261
262/*
263 * Main of read_boby.php --------------------------------------------------
264 */
265
266/*
267 Urled vars
268 ----------
269 $passed_id
270*/
a07cd1a4 271
272$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
57257333 273$read = sqimap_mailbox_select($imapConnection, $mailbox);
274
a07cd1a4 275do_hook('html_top');
57257333 276
277/*
278 * The following code sets necesarry stuff for the MDN thing
279 */
280if( $default_use_mdn &&
281 ( $mdn_user_support = getPref($data_dir, $username, 'mdn_user_support', $default_use_mdn) ) ) {
282
283 $supportMDN = ServerMDNSupport($read);
57257333 284 $flags = sqimap_get_flags ($imapConnection, $passed_id);
77b88425 285 $FirstTimeSee = !(in_array( 'Seen', $flags ));
57257333 286}
287
a07cd1a4 288displayPageHeader($color, $mailbox);
289
57257333 290
291/*
292 * The following code shows the header of the message and then exit
293 */
a07cd1a4 294if (isset($view_hdr)) {
451a5790 295 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]", true, $a, $b);
a07cd1a4 296
297 echo '<BR>' .
298 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0" ALIGN="CENTER">' . "\n" .
299 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\"><CENTER><B>" . _("Viewing Full Header") . '</B> - '.
300 '<a href="' . $base_uri . "src/read_body.php?mailbox=".urlencode($mailbox);
301 if (isset($where) && isset($what)) {
302 // Got here from a search
303 echo "&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what).'">';
304 } else {
305 echo "&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more\">";
306 }
57257333 307 echo _("View message") . "</a></b></center></td></tr></table>\n" .
308 "<table width=\"99%\" cellpadding=2 cellspacing=0 border=0 align=center>\n" .
309 '<tr><td>';
a07cd1a4 310
311 $cnum = 0;
312 for ($i=1; $i < count($read); $i++) {
313 $line = htmlspecialchars($read[$i]);
314 if (eregi("^&gt;", $line)) {
315 $second[$i] = $line;
316 $first[$i] = '&nbsp;';
317 $cnum++;
318 } else if (eregi("^[ |\t]", $line)) {
319 $second[$i] = $line;
320 $first[$i] = '';
321 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
322 $first[$i] = $regs[1] . ':';
323 $second[$i] = $regs[2];
324 $cnum++;
0606ca1f 325 } else {
a07cd1a4 326 $second[$i] = trim($line);
327 $first[$i] = '';
10f0ce72 328 }
a07cd1a4 329 }
330 for ($i=0; $i < count($second); $i = $j) {
331 if (isset($first[$i])) {
332 $f = $first[$i];
0606ca1f 333 }
a07cd1a4 334 if (isset($second[$i])) {
335 $s = nl2br($second[$i]);
336 }
337 $j = $i + 1;
338 while (($first[$j] == '') && ($j < count($first))) {
339 $s .= '&nbsp;&nbsp;&nbsp;&nbsp;' . nl2br($second[$j]);
340 $j++;
0606ca1f 341 }
a07cd1a4 342 parseEmail($s);
343 if (isset($f)) echo "<nobr><tt><b>$f</b>$s</tt></nobr>";
10f0ce72 344 }
57257333 345 echo "</td></tr></table>\n" .
346 '</body></html>';
a07cd1a4 347 sqimap_logout($imapConnection);
348 exit;
349}
350
351if (isset($msgs)) {
352 $currentArrayIndex = $passed_id;
353} else {
354 $currentArrayIndex = -1;
355}
356
357for ($i = 0; $i < count($msgs); $i++) {
358 if ($msgs[$i]['ID'] == $passed_id) {
359 $msgs[$i]['FLAG_SEEN'] = true;
10f0ce72 360 }
a07cd1a4 361}
362
363// $message contains all information about the message
364// including header and body
365$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
366
367/** translate the subject and mailbox into url-able text **/
368$url_subj = urlencode(trim($message->header->subject));
369$urlMailbox = urlencode($mailbox);
370$url_replyto = '';
371if (isset($message->header->replyto)) {
372 $url_replyto = urlencode($message->header->replyto);
373}
374
375$url_replytoall = $url_replyto;
376
377// If we are replying to all, then find all other addresses and
378// add them to the list. Remove duplicates.
379// This is somewhat messy, so I'll explain:
380// 1) Take all addresses (from, to, cc) (avoid nasty join errors here)
381$url_replytoall_extra_addrs = array_merge(
382 array($message->header->from),
383 $message->header->to,
384 $message->header->cc
385);
386
387// 2) Make one big string out of them
388$url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs);
389
390// 3) Parse that into an array of addresses
391$url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs);
392
393// 4) Make them unique -- weed out duplicates
394// (Coded for PHP 4.0.0)
395$url_replytoall_extra_addrs =
396 array_keys(array_flip($url_replytoall_extra_addrs));
397
398// 5) Remove the addresses we'll be sending the message 'to'
399$url_replytoall_avoid_addrs = '';
400if (isset($message->header->replyto)) {
401 $url_replytoall_avoid_addrs = $message->header->replyto;
402}
403
404$url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs);
405foreach ($url_replytoall_avoid_addrs as $addr) {
406 RemoveAddress($url_replytoall_extra_addrs, $addr);
407}
408
409// 6) Remove our identities from the CC list (they still can be in the
410// TO list) only if $include_self_reply_all is turned off
411if (!$include_self_reply_all) {
412 RemoveAddress($url_replytoall_extra_addrs,
413 getPref($data_dir, $username, 'email_address'));
414 $idents = getPref($data_dir, $username, 'identities');
415 if ($idents != '' && $idents > 1) {
416 for ($i = 1; $i < $idents; $i ++) {
417 $cur_email_address = getPref($data_dir, $username, 'email_address' . $i);
418 RemoveAddress($url_replytoall_extra_addrs, $cur_email_address);
10f0ce72 419 }
692155b7 420 }
a07cd1a4 421}
1108e8bb 422
a07cd1a4 423// 7) Smoosh back into one nice line
424$url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs);
692155b7 425
a07cd1a4 426// 8) urlencode() it
427$url_replytoallcc = urlencode($url_replytoallcc);
be69e508 428
a07cd1a4 429$dateString = getLongDateString($message->header->date);
5bc39e3f 430
a07cd1a4 431// What do we reply to -- text only, if possible
432$ent_num = findDisplayEntity($message);
5bc39e3f 433
a07cd1a4 434/** TEXT STRINGS DEFINITIONS **/
435$echo_more = _("more");
436$echo_less = _("less");
437
57257333 438if (!isset($show_more_cc)) {
439 $show_more_cc = FALSE;
440}
10f0ce72 441
a07cd1a4 442/** FORMAT THE TO STRING **/
443$i = 0;
444$to_string = '';
445$to_ary = $message->header->to;
446while ($i < count($to_ary)) {
447 $to_ary[$i] = htmlspecialchars(decodeHeader($to_ary[$i]));
448
449 if ($to_string) {
450 $to_string = "$to_string<BR>$to_ary[$i]";
451 } else {
452 $to_string = "$to_ary[$i]";
10f0ce72 453 }
a07cd1a4 454
455 $i++;
456 if (count($to_ary) > 1) {
457 if ($show_more == false) {
458 if ($i == 1) {
459 /* From a search... */
460 $to_string .= '&nbsp;(<A HREF="' . $base_uri .
461 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
462 if (isset($where) && isset($what)) {
463 $to_string .= 'where='.urlencode($where)."&what=".urlencode($what)."&show_more=1&show_more_cc=$show_more_cc\">$echo_more</A>)";
464 } else {
465 $to_string .= "sort=$sort&startMessage=$startMessage&show_more=1&show_more_cc=$show_more_cc\">$echo_more</A>)";
466 }
467 $i = count($to_ary);
468 }
469 } else if ($i == 1) {
470 /* From a search... */
471 $to_string .= '&nbsp;(<A HREF="' . $base_uri .
472 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
473 if (isset($where) && isset($what)) {
474 $to_string .= 'where='.urlencode($where)."&what=".urlencode($what)."&show_more=0&show_more_cc=$show_more_cc\">$echo_less</A>)";
475 } else {
476 $to_string .= "sort=$sort&startMessage=$startMessage&show_more=0&show_more_cc=$show_more_cc\">$echo_less</A>)";
10f0ce72 477 }
478 }
6dc0e464 479 }
a07cd1a4 480}
481
482/** FORMAT THE CC STRING **/
483$i = 0;
484if (isset ($message->header->cc[0]) && trim($message->header->cc[0])) {
485 $cc_string = "";
486 $cc_ary = $message->header->cc;
487 while ($i < count(decodeHeader($cc_ary))) {
488 $cc_ary[$i] = htmlspecialchars($cc_ary[$i]);
489 if ($cc_string) {
490 $cc_string = "$cc_string<BR>$cc_ary[$i]";
10f0ce72 491 } else {
a07cd1a4 492 $cc_string = "$cc_ary[$i]";
10f0ce72 493 }
494
495 $i++;
a07cd1a4 496 if (count($cc_ary) > 1) {
497 if ($show_more_cc == false) {
10f0ce72 498 if ($i == 1) {
499 /* From a search... */
a07cd1a4 500 $cc_string .= '&nbsp;(<A HREF="' . $base_uri .
501 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id";
10f0ce72 502 if (isset($where) && isset($what)) {
a07cd1a4 503 $cc_string .= '&what='.urlencode($what)."&where=".urlencode($where)."&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
10f0ce72 504 } else {
a07cd1a4 505 $cc_string .= "&sort=$sort&startMessage=$startMessage&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
10f0ce72 506 }
a07cd1a4 507 $i = count($cc_ary);
10f0ce72 508 }
509 } else if ($i == 1) {
510 /* From a search... */
a07cd1a4 511 $cc_string .= '&nbsp;(<A HREF="' . $base_uri .
512 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
10f0ce72 513 if (isset($where) && isset($what)) {
a07cd1a4 514 $cc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
10f0ce72 515 } else {
a07cd1a4 516 $cc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
10f0ce72 517 }
2844086d 518 }
10f0ce72 519 }
520 }
a07cd1a4 521}
9c3e6cd4 522else {
523 $cc_string = '';
524}
a07cd1a4 525
526/** FORMAT THE BCC STRING **/
527$i = 0;
528if (isset ($message->header->bcc[0]) && trim($message->header->bcc[0])){
529 $bcc_string = "";
530 $bcc_ary = $message->header->bcc;
531 while ($i < count(decodeHeader($bcc_ary))) {
532 $bcc_ary[$i] = htmlspecialchars($bcc_ary[$i]);
533 if ($bcc_string) {
534 $bcc_string = "$bcc_string<BR>$bcc_ary[$i]";
535 } else {
536 $bcc_string = "$bcc_ary[$i]";
10f0ce72 537 }
10f0ce72 538
a07cd1a4 539 $i++;
540 if (count($bcc_ary) > 1) {
541 if ($show_more_cc == false) {
542 if ($i == 1) {
10f0ce72 543 /* From a search... */
a07cd1a4 544 $bcc_string .= '&nbsp;(<A HREF="' . $base_uri .
545 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
10f0ce72 546 if (isset($where) && isset($what)) {
a07cd1a4 547 $bcc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
10f0ce72 548 } else {
a07cd1a4 549 $bcc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
550 }
551 $i = count($bcc_ary);
552 }
553 } else if ($i == 1) {
554 /* From a search... */
555 $bcc_string .= '&nbsp;(<A HREF="' . $base_uri .
556 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
557 if (isset($where) && isset($what)) {
558 $bcc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
559 } else {
560 $bcc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
10f0ce72 561 }
562 }
563 }
564 }
a07cd1a4 565}
9c3e6cd4 566else {
567 $bcc_string = '';
568}
10f0ce72 569
a07cd1a4 570if ($default_use_priority) {
a7818e8e 571 $priority_level = substr($message->header->priority,0,1);
572
573 switch($priority_level) {
09278ebf 574 /* check for a higher then normal priority. */
575 case '1':
5be9f195 576 case '2':
577 $priority_string = _("High");
09278ebf 578 break;
579
580 /* check for a lower then normal priority. */
581 case '4':
5be9f195 582 case '5':
583 $priority_string = _("Low");
09278ebf 584 break;
5be9f195 585
09278ebf 586 /* check for a normal priority. */
5be9f195 587 case '3':
09278ebf 588 default:
589 $priority_level = '3';
5be9f195 590 $priority_string = _("Normal");
09278ebf 591 break;
5be9f195 592
10f0ce72 593 }
a07cd1a4 594}
595
596/** make sure everything will display in HTML format **/
597$from_name = decodeHeader(htmlspecialchars($message->header->from));
598$subject = decodeHeader(htmlspecialchars($message->header->subject));
599
600do_hook('read_body_top');
601echo '<BR>' .
57257333 602 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' .
603 '<TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' .
604 '<TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' .
605 '<TR>' .
606 '<TD ALIGN="LEFT" WIDTH="33%">' .
607 '<SMALL>' .
608 '<A HREF="' . $base_uri . 'src/';
a07cd1a4 609
610if ($where && $what) {
611 if( $pos == '' ) {
612 $pos = 0;
10f0ce72 613 }
a07cd1a4 614 echo "search.php?where$pos=".urlencode($where)."&pos=$pos&what$pos=".urlencode($what)."&mailbox=$urlMailbox\">";
615} else {
5dd6c4d7 616 echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
a07cd1a4 617}
618echo _("Message List") .
619 '</A>&nbsp;|&nbsp;' .
620 '<A HREF="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&";
621if ($where && $what) {
622 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">';
623} else {
624 echo "sort=$sort&startMessage=$startMessage\">";
625}
626echo _("Delete") . '</A>&nbsp;';
627if (($mailbox == $draft_folder) && ($save_as_draft)) {
628 echo '|&nbsp;<A HREF="' . $base_uri .
9c3e6cd4 629 "src/compose.php?mailbox=$mailbox&send_to=$to_string&send_to_cc=$cc_string&send_to_bcc=$bcc_string&subject=$url_subj&draft_id=$passed_id&ent_num=$ent_num\"";
630 if ($compose_new_win == '1') {
631 echo 'TARGET="compose_window" onClick="comp_in_new()"';
632 }
633 echo '>'.
a07cd1a4 634 _("Resume Draft") . '</a>';
635}
636
637echo '&nbsp;&nbsp;' .
57257333 638 '</SMALL>' .
639 '</TD>' .
640 '<TD WIDTH="33%" ALIGN="CENTER">' .
641 '<SMALL>';
a07cd1a4 642
643if ( !($where && $what) ) {
644
645 if ($currentArrayIndex == -1) {
646 echo 'Previous&nbsp;|&nbsp;Next';
10f0ce72 647 } else {
a07cd1a4 648 $prev = findPreviousMessage();
649 $next = findNextMessage();
10f0ce72 650
a07cd1a4 651 if ($prev != -1) {
652 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A>&nbsp;|&nbsp;";
10f0ce72 653 } else {
a07cd1a4 654 echo _("Previous") . '&nbsp;|&nbsp;';
10f0ce72 655 }
7baf86a9 656
a07cd1a4 657 if ($next != -1) {
658 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
659 } else {
660 echo _("Next");
661 }
10f0ce72 662 }
a07cd1a4 663}
664
57257333 665echo '</SMALL>' .
666 '</TD><TD WIDTH="33%" ALIGN="RIGHT">' .
667 '<SMALL>' .
668 '<A HREF="' . $base_uri . "src/compose.php?forward_id=$passed_id&forward_subj=$url_subj&".
5dd6c4d7 669 ($default_use_priority?"mailprio=$priority_level&":"")
9c3e6cd4 670 ."mailbox=$urlMailbox&ent_num=$ent_num\"";
671 if ($compose_new_win == '1') {
672 echo 'TARGET="compose_window" onClick="comp_in_new()"';
673 }
674 echo '>'.
a07cd1a4 675 _("Forward") .
676 '</A>&nbsp;|&nbsp;' .
57257333 677 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replyto&reply_subj=$url_subj&".
5dd6c4d7 678 ($default_use_priority?"mailprio=$priority_level&":"").
9c3e6cd4 679 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
680 if ($compose_new_win == '1') {
681 echo 'TARGET="compose_window" onClick="comp_in_new()"';
682 }
683 echo '>'.
a07cd1a4 684 _("Reply") .
685 '</A>&nbsp;|&nbsp;' .
57257333 686 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
5dd6c4d7 687 ($default_use_priority?"mailprio=$priority_level&":"").
9c3e6cd4 688 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
689 if ($compose_new_win == '1') {
690 echo 'TARGET="compose_window" onClick="comp_in_new()"';
691 }
692 echo '>'.
a07cd1a4 693 _("Reply All") .
694 '</A>&nbsp;&nbsp;' .
57257333 695 '</SMALL>' .
696 '</TD>' .
697 '</TR>' .
698 '</TABLE>' .
699 '</TD></TR>' .
700 '<TR><TD CELLSPACING="0" WIDTH="100%">' .
701 '<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" .
702 '<TR>' . "\n";
a07cd1a4 703
704/** subject **/
57257333 705echo "<TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" .
a07cd1a4 706 _("Subject:") .
57257333 707 "</TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" .
708 "<B>$subject</B>&nbsp;\n" .
709 "</TD>\n" .
710 '<TD ROWSPAN="4" width="10%" BGCOLOR="' . $color[0] .
a07cd1a4 711 '" ALIGN=right VALIGN=top NOWRAP><small>'.
712 '<A HREF="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
713
714/* From a search... */
715if ($where && $what) {
716 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) .
717 "&view_hdr=1\">" . _("View Full Header") . "</A>\n";
718} else {
719 echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" .
720 _("View Full Header") . "</A>\n";
721}
722
723/* Output the printer friendly link if we are in subtle mode. */
724if ($pf_subtle_link) {
725 echo printer_friendly_link(true);
726}
727
728do_hook("read_body_header_right");
57257333 729echo '</small></TD>' .
730 ' </TR>';
a07cd1a4 731
732/** from **/
57257333 733echo '<TR>' .
734 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' .
a07cd1a4 735 _("From:") .
57257333 736 '</TD><TD BGCOLOR="' . $color[0] . '">' .
737 "<B>$from_name</B>&nbsp;\n" .
738 '</TD>' .
739 '</TR>';
a07cd1a4 740/** date **/
57257333 741echo '<TR>' . "\n" .
742 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
a07cd1a4 743 _("Date:") .
57257333 744 "</TD><TD BGCOLOR=\"$color[0]\">\n" .
745 "<B>$dateString</B>&nbsp;\n" .
746 '</TD>' . "\n" .
747 '</TR>' . "\n";
a07cd1a4 748
749/** to **/
57257333 750echo "<TR>\n" .
751 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
a07cd1a4 752 _("To:") .
57257333 753 '</TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" .
754 "<B>$to_string</B>&nbsp;\n" .
755 '</TD>' . "\n" .
756 '</TR>' . "\n";
a07cd1a4 757/** cc **/
9e9ad58b 758if (isset($cc_string) && $cc_string <> '') {
57257333 759 echo '<TR>' .
760 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
761 'Cc:' .
762 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
763 "<B>$cc_string</B>&nbsp;" .
764 '</TD>' .
765 '</TR>' . "\n";
a07cd1a4 766}
767
768/** bcc **/
9e9ad58b 769if (isset($bcc_string) && $bcc_string <> '') {
57257333 770 echo '<TR>'.
771 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
772 'Bcc:' .
773 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
774 "<B>$bcc_string</B>&nbsp;" .
775 '</TD>' .
776 '</TR>' . "\n";
a07cd1a4 777}
9e9ad58b 778if ($default_use_priority && isset($priority_string) && $priority_string <> '' ) {
779 echo '<TR>' .
780 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
781 _("Priority") . ': '.
782 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
783 "<B>$priority_string</B>&nbsp;" .
784 '</TD>' .
785 "</TR>" . "\n";
a07cd1a4 786}
787
788if ($show_xmailer_default) {
451a5790 789 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]", true,
a07cd1a4 790 $response, $readmessage);
791 $mailer = substr($read[1], strpos($read[1], " "));
792 if (trim($mailer)) {
57257333 793 echo '<TR>' .
794 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
795 _("Mailer") . ': '.
796 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
797 "<B>$mailer</B>&nbsp;" .
798 '</TD>' .
799 "</TR>" . "\n";
10f0ce72 800 }
a07cd1a4 801}
802
803/* Output the printer friendly link if we are not in subtle mode. */
804if (!$pf_subtle_link) {
805 echo printer_friendly_link(true);
806}
807
57257333 808if ($default_use_mdn) {
809 if ($mdn_user_support) {
810
811 // debug gives you the capability to remove mdn-flags
77b88425 812 $debug = false;
57257333 813 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true,
814 $response, $readmessage);
815 $MDN_to = substr($read[1], strpos($read[1], ' '));
816 $MDN_flag_present = false;
817
818 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id FLAGS", true,
819 $response, $readmessage);
77b88425 820
821 $MDN_flag_present = preg_match( '/.*\$MDNSent/i', $read[0]);
822
57257333 823 if (trim($MDN_to) &&
824 (!isset( $sendreceipt ) || $sendreceipt == '' ) ) {
825
826 if ( $MDN_flag_present && $supportMDN) {
77b88425 827 $sendreceipt = 'removeMDN';
57257333 828 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
829 $sendreceipt="";
830 if ($debug ) {
831 echo '<TR>' .
832 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
833 _("Read receipt") . ': ' .
834 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
835 '<B>' .
836 _("send") .
837 "</B> <a href=$url>[" . _("Remove MDN flag") . '] </a>' .
838 '</TD>' .
839 '</TR>' . "\n";
840 } else {
841 echo '<TR>' .
842 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
843 _("Read receipt") . ': ' .
844 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
845 '<B>'._("send").'</B>'.
846 '</TD>' .
847 '</TR>' . "\n";
848 }
849
850 } // when deleted or draft flag is set don't offer to send a MDN response
851 else if ( ereg('Draft',$read[0] || ereg('Deleted',$read[0])) ) {
852 echo '<TR>' .
853 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
854 _("Read receipt") . ': '.
855 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
856 '<B>' . _("requested") . "</B>" .
857 '</TD>' .
858 '</TR>' . "\n";
859 }
860 // if no MDNsupport don't use the annoying popup messages
861 else if ( !$FirstTimeSee ) {
862 $sendreceipt = 'send';
863 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
864 echo '<TR>' .
865 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
866 _("Read receipt") . ': ' .
867 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
868 '<B>' . _("requested") .
869 "</B> &nbsp; <a href=$url>[" . _("Send read receipt now") . "]</a>" .
870 '</TD>' .
871 '</TR>' . "\n";
872 $sendreceipt='';
873 }
874 else {
875 $sendreceipt = 'send';
876 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
877 if ($javascript_on) {
878 echo "<script language=\"javascript\"> \n" .
879 '<!-- ' . "\n" .
880 " if (window.confirm(\"" .
881 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
882 "\")) { \n" .
883 " window.location=($url); \n" .
884 ' window.reload()' . "\n" .
885 ' }' . "\n" .
886 '// -->' . "\n" .
887 '</script>' . "\n";
888 }
889 echo '<TR>' .
890 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
891 _("Read receipt") . ': ' .
892 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
893 '<B>' . _("requested") . "&nbsp&nbsp</B><a href=$url>" . '[' .
894 _("Send read receipt now") . '] </a>' ." \n" .
895 '</TD>' .
896 '</TR>' . "\n";
897 $sendreceipt = '';
898 }
899 }
900
77b88425 901 if ( !isset( $sendreceipt ) || $sendreceipt == '' ) {
57257333 902 } else if ( $sendreceipt == 'send' ) {
903 if ( !$MDN_flag_present) {
904 if (isset($identity) ) {
77b88425 905 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
906 } else {
907 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
908 }
57257333 909
910 $final_recipient = trim($final_recipient);
911 if ($final_recipient == '' ) {
77b88425 912 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
57257333 913 }
914
77b88425 915 if ( SendMDN( $MDN_to, $final_recipient ) > 0 && $supportMDN ) {
916 ToggleMDNflag( true);
57257333 917 }
918 }
919 $sendreceipt = 'removeMDN';
920 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
921 $sendreceipt="";
922
923 if ($debug && $supportMDN) {
924 echo " <TR>\n" .
925 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
926 " "._("Read receipt").": \n".
927 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
928 ' <B>'._("send").'</B>'." <a href=$url>" . '[' . _("Remove MDN flag") . '] </a>' . "\n" .
929 ' </TD>' . "\n" .
930 ' </TR>' . "\n";
931 } else {
932 echo " <TR>\n" .
933 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
934 " "._("Read receipt").": \n".
935 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
936 ' <B>'._("send").'</B>'. "\n" .
937 ' </TD>' . "\n" .
938 ' </TR>' . "\n";
939 }
940 }
941 elseif ($sendreceipt == 'removeMDN' ) {
942 ToggleMDNflag ( false );
943
944 $sendreceipt = 'send';
945 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
946 echo '<TR>'.
947 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
948 _("Read receipt") . ': ' .
949 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
950 '<B>' . _("requested") .
951 "</B> &nbsp; <a href=$url>[" . _("Send read receipt now") . "]</a>" .
952 '</TD>' .
953 '</TR>' . "\n";
954 $sendreceipt = '';
955
956 }
957 }
958}
959
5be9f195 960do_hook('read_body_header');
57257333 961
a07cd1a4 962echo '</TABLE>' .
963 ' </TD></TR>' .
964 '</TABLE>';
965flush();
5be9f195 966
a07cd1a4 967echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" .
968 " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" .
969 '<BR>'.
970 formatBody($imapConnection, $message, $color, $wrap_at).
971 '</TABLE>' .
972 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
973 " <TR><TD BGCOLOR=\"$color[9]\">&nbsp;</TD></TR>" .
974 '</TABLE>' . "\n";
975
976/* show attached images inline -- if pref'fed so */
5be9f195 977if (($attachment_common_show_images) &&
a07cd1a4 978 is_array($attachment_common_show_images_list)) {
5be9f195 979
a07cd1a4 980 foreach ($attachment_common_show_images_list as $img) {
5be9f195 981 $imgurl = '../src/download.php' .
57257333 982 '?' .
cd7b8833 983 'passed_id=' . urlencode($img['passed_id']) .
984 '&mailbox=' . urlencode($mailbox) .
5be9f195 985 '&passed_ent_id=' . urlencode($img['ent_id']) .
986 '&absolute_dl=true';
987
a07cd1a4 988 echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" .
57257333 989 '<TR>' .
990 '<TD>' .
991 "<img src=\"$imgurl\">\n" .
992 "</TD>\n" .
993 "</TR>\n" .
a07cd1a4 994 "</TABLE>\n";
5be9f195 995
10f0ce72 996 }
a07cd1a4 997}
998
5be9f195 999
a07cd1a4 1000do_hook('read_body_bottom');
1001do_hook('html_bottom');
1002sqimap_logout($imapConnection);
1003?>
1004</body>
a7818e8e 1005</html>