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