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