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