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