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