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