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