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