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