Priority stuff is not working properly. I've defaulted prioriy to normal
[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');
f740c049 20
a07cd1a4 21/**
22* Given an IMAP message id number, this will look it up in the cached
23* and sorted msgs array and return the index. Used for finding the next
24* and previous messages.
25*
26* returns the index of the next valid message from the array
27*/
28function findNextMessage() {
29 global $msort, $currentArrayIndex, $msgs, $sort;
30 $result = -1;
31
32 if ($sort == 6) {
33 if ($currentArrayIndex != 1) {
34 $result = $currentArrayIndex - 1;
35 }
36 } else {
37 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
38 if ($currentArrayIndex == $msgs[$key]['ID']) {
39 next($msort);
40 $key = key($msort);
41 if (isset($key))
42 $result = $msgs[$key]['ID'];
43 break;
10f0ce72 44 }
45 }
10f0ce72 46 }
a07cd1a4 47 return ($result);
48}
49
50/** Removes just one address from the list of addresses. */
51function RemoveAddress(&$addr_list, $addr) {
52 if ($addr != '') {
53 foreach (array_keys($addr_list, $addr) as $key_to_delete) {
54 unset($addr_list[$key_to_delete]);
10f0ce72 55 }
a07cd1a4 56 }
57}
58
59/** returns the index of the previous message from the array. */
60function findPreviousMessage() {
61 global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection;
62 global $mailbox, $data_dir, $username;
63 $result = -1;
64
65 if ($sort == 6) {
66 $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
67 if ($currentArrayIndex != $numMessages) {
68 $result = $currentArrayIndex + 1;
69 }
70 } else {
71 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
72 if ($currentArrayIndex == $msgs[$key]['ID']) {
73 prev($msort);
74 $key = key($msort);
75 if (isset($key)) {
76 $result = $msgs[$key]['ID'];
77 break;
10f0ce72 78 }
79 }
10f0ce72 80 }
a07cd1a4 81 }
82 return ($result);
83}
10f0ce72 84
a07cd1a4 85/**
86* Displays a link to a page where the message is displayed more
87* "printer friendly".
88*/
89function printer_friendly_link() {
90 global $passed_id, $mailbox, $ent_num, $color;
91 global $pf_subtle_link;
92 global $javascript_on;
93
94 if (strlen(trim($mailbox)) < 1) {
95 $mailbox = 'INBOX';
96 }
10f0ce72 97
a07cd1a4 98 $params = '?passed_ent_id=' . $ent_num;
99 $params .= '&mailbox=' . urlencode($mailbox);
100 $params .= '&passed_id=' . $passed_id;
10f0ce72 101
a07cd1a4 102 $print_text = _("View Printable Version");
10f0ce72 103
a07cd1a4 104 if (!$pf_subtle_link) {
105 /* The link is large, on the bottom of the header panel. */
106 $result = ' <tr bgcolor="' . $color[0] . '">' . "\n" .
107 ' <td class="medText" align="right" valign="top">' . "\n" .
108 ' &nbsp;' . "\n" .
109 ' </td><td class="medText" valign="top" colspan="2">'."\n";
110 } else {
111 /* The link is subtle, below "view full header". */
112 $result = "<BR>\n";
113 }
10f0ce72 114
a07cd1a4 115 /* Output the link. */
116 if ($javascript_on) {
117 $result .= '<script language="javascript">' . "\n" .
118 '<!--' . "\n" .
119 " function printFormat() {\n" .
120 ' window.open("../src/printer_friendly_main.php' .
121 $params . '","Print","width=800,height=600");' . "\n".
122 " }\n" .
123 "// -->\n" .
124 "</script>\n" .
125 "<A HREF=\"javascript:printFormat();\">$print_text</A>\n";
126 } else {
127 $result .= '<A TARGET="_blank" HREF="../src/printer_friendly_bottom.php' .
128 "$params\">$print_text</A>\n";
129 }
10f0ce72 130
a07cd1a4 131 if (!$pf_subtle_link) {
132 /* The link is large, on the bottom of the header panel. */
133 $result .= ' </td>' . "\n" .
134 ' </tr>' . "\n";
10f0ce72 135 }
136
a07cd1a4 137 return ($result);
138}
139
140/*****************************/
141/*** Main of read_boby.php ***/
142/*****************************/
143
144$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
145sqimap_mailbox_select($imapConnection, $mailbox);
146do_hook('html_top');
147displayPageHeader($color, $mailbox);
148
149if (isset($view_hdr)) {
150 fputs ($imapConnection, sqimap_session_id() . " FETCH $passed_id BODY[HEADER]\r\n");
151 $read = sqimap_read_data ($imapConnection, sqimap_session_id(), true, $a, $b);
152
153 echo '<BR>' .
154 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0" ALIGN="CENTER">' . "\n" .
155 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\"><CENTER><B>" . _("Viewing Full Header") . '</B> - '.
156 '<a href="' . $base_uri . "src/read_body.php?mailbox=".urlencode($mailbox);
157 if (isset($where) && isset($what)) {
158 // Got here from a search
159 echo "&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what).'">';
160 } else {
161 echo "&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more\">";
162 }
163 echo ''._("View message") . "</a></b></center></td></tr></table>\n" .
164 "<table width=\"99%\" cellpadding=2 cellspacing=0 border=0 align=center>\n" .
165 '<tr><td>';
166
167 $cnum = 0;
168 for ($i=1; $i < count($read); $i++) {
169 $line = htmlspecialchars($read[$i]);
170 if (eregi("^&gt;", $line)) {
171 $second[$i] = $line;
172 $first[$i] = '&nbsp;';
173 $cnum++;
174 } else if (eregi("^[ |\t]", $line)) {
175 $second[$i] = $line;
176 $first[$i] = '';
177 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
178 $first[$i] = $regs[1] . ':';
179 $second[$i] = $regs[2];
180 $cnum++;
0606ca1f 181 } else {
a07cd1a4 182 $second[$i] = trim($line);
183 $first[$i] = '';
10f0ce72 184 }
a07cd1a4 185 }
186 for ($i=0; $i < count($second); $i = $j) {
187 if (isset($first[$i])) {
188 $f = $first[$i];
0606ca1f 189 }
a07cd1a4 190 if (isset($second[$i])) {
191 $s = nl2br($second[$i]);
192 }
193 $j = $i + 1;
194 while (($first[$j] == '') && ($j < count($first))) {
195 $s .= '&nbsp;&nbsp;&nbsp;&nbsp;' . nl2br($second[$j]);
196 $j++;
0606ca1f 197 }
a07cd1a4 198 parseEmail($s);
199 if (isset($f)) echo "<nobr><tt><b>$f</b>$s</tt></nobr>";
10f0ce72 200 }
a07cd1a4 201 echo "</td></tr></table>\n";
202 echo '</body></html>';
203 sqimap_logout($imapConnection);
204 exit;
205}
206
207if (isset($msgs)) {
208 $currentArrayIndex = $passed_id;
209} else {
210 $currentArrayIndex = -1;
211}
212
213for ($i = 0; $i < count($msgs); $i++) {
214 if ($msgs[$i]['ID'] == $passed_id) {
215 $msgs[$i]['FLAG_SEEN'] = true;
10f0ce72 216 }
a07cd1a4 217}
218
219// $message contains all information about the message
220// including header and body
221$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
222
223/** translate the subject and mailbox into url-able text **/
224$url_subj = urlencode(trim($message->header->subject));
225$urlMailbox = urlencode($mailbox);
226$url_replyto = '';
227if (isset($message->header->replyto)) {
228 $url_replyto = urlencode($message->header->replyto);
229}
230
231$url_replytoall = $url_replyto;
232
233// If we are replying to all, then find all other addresses and
234// add them to the list. Remove duplicates.
235// This is somewhat messy, so I'll explain:
236// 1) Take all addresses (from, to, cc) (avoid nasty join errors here)
237$url_replytoall_extra_addrs = array_merge(
238 array($message->header->from),
239 $message->header->to,
240 $message->header->cc
241);
242
243// 2) Make one big string out of them
244$url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs);
245
246// 3) Parse that into an array of addresses
247$url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs);
248
249// 4) Make them unique -- weed out duplicates
250// (Coded for PHP 4.0.0)
251$url_replytoall_extra_addrs =
252 array_keys(array_flip($url_replytoall_extra_addrs));
253
254// 5) Remove the addresses we'll be sending the message 'to'
255$url_replytoall_avoid_addrs = '';
256if (isset($message->header->replyto)) {
257 $url_replytoall_avoid_addrs = $message->header->replyto;
258}
259
260$url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs);
261foreach ($url_replytoall_avoid_addrs as $addr) {
262 RemoveAddress($url_replytoall_extra_addrs, $addr);
263}
264
265// 6) Remove our identities from the CC list (they still can be in the
266// TO list) only if $include_self_reply_all is turned off
267if (!$include_self_reply_all) {
268 RemoveAddress($url_replytoall_extra_addrs,
269 getPref($data_dir, $username, 'email_address'));
270 $idents = getPref($data_dir, $username, 'identities');
271 if ($idents != '' && $idents > 1) {
272 for ($i = 1; $i < $idents; $i ++) {
273 $cur_email_address = getPref($data_dir, $username, 'email_address' . $i);
274 RemoveAddress($url_replytoall_extra_addrs, $cur_email_address);
10f0ce72 275 }
692155b7 276 }
a07cd1a4 277}
1108e8bb 278
a07cd1a4 279// 7) Smoosh back into one nice line
280$url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs);
692155b7 281
a07cd1a4 282// 8) urlencode() it
283$url_replytoallcc = urlencode($url_replytoallcc);
be69e508 284
a07cd1a4 285$dateString = getLongDateString($message->header->date);
5bc39e3f 286
a07cd1a4 287// What do we reply to -- text only, if possible
288$ent_num = findDisplayEntity($message);
5bc39e3f 289
a07cd1a4 290/** TEXT STRINGS DEFINITIONS **/
291$echo_more = _("more");
292$echo_less = _("less");
293
294if (!isset($show_more_cc)) $show_more_cc = false;
10f0ce72 295
a07cd1a4 296/** FORMAT THE TO STRING **/
297$i = 0;
298$to_string = '';
299$to_ary = $message->header->to;
300while ($i < count($to_ary)) {
301 $to_ary[$i] = htmlspecialchars(decodeHeader($to_ary[$i]));
302
303 if ($to_string) {
304 $to_string = "$to_string<BR>$to_ary[$i]";
305 } else {
306 $to_string = "$to_ary[$i]";
10f0ce72 307 }
a07cd1a4 308
309 $i++;
310 if (count($to_ary) > 1) {
311 if ($show_more == false) {
312 if ($i == 1) {
313 /* From a search... */
314 $to_string .= '&nbsp;(<A HREF="' . $base_uri .
315 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
316 if (isset($where) && isset($what)) {
317 $to_string .= 'where='.urlencode($where)."&what=".urlencode($what)."&show_more=1&show_more_cc=$show_more_cc\">$echo_more</A>)";
318 } else {
319 $to_string .= "sort=$sort&startMessage=$startMessage&show_more=1&show_more_cc=$show_more_cc\">$echo_more</A>)";
320 }
321 $i = count($to_ary);
322 }
323 } else if ($i == 1) {
324 /* From a search... */
325 $to_string .= '&nbsp;(<A HREF="' . $base_uri .
326 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
327 if (isset($where) && isset($what)) {
328 $to_string .= 'where='.urlencode($where)."&what=".urlencode($what)."&show_more=0&show_more_cc=$show_more_cc\">$echo_less</A>)";
329 } else {
330 $to_string .= "sort=$sort&startMessage=$startMessage&show_more=0&show_more_cc=$show_more_cc\">$echo_less</A>)";
10f0ce72 331 }
332 }
6dc0e464 333 }
a07cd1a4 334}
335
336/** FORMAT THE CC STRING **/
337$i = 0;
338if (isset ($message->header->cc[0]) && trim($message->header->cc[0])) {
339 $cc_string = "";
340 $cc_ary = $message->header->cc;
341 while ($i < count(decodeHeader($cc_ary))) {
342 $cc_ary[$i] = htmlspecialchars($cc_ary[$i]);
343 if ($cc_string) {
344 $cc_string = "$cc_string<BR>$cc_ary[$i]";
10f0ce72 345 } else {
a07cd1a4 346 $cc_string = "$cc_ary[$i]";
10f0ce72 347 }
348
349 $i++;
a07cd1a4 350 if (count($cc_ary) > 1) {
351 if ($show_more_cc == false) {
10f0ce72 352 if ($i == 1) {
353 /* From a search... */
a07cd1a4 354 $cc_string .= '&nbsp;(<A HREF="' . $base_uri .
355 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id";
10f0ce72 356 if (isset($where) && isset($what)) {
a07cd1a4 357 $cc_string .= '&what='.urlencode($what)."&where=".urlencode($where)."&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
10f0ce72 358 } else {
a07cd1a4 359 $cc_string .= "&sort=$sort&startMessage=$startMessage&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
10f0ce72 360 }
a07cd1a4 361 $i = count($cc_ary);
10f0ce72 362 }
363 } else if ($i == 1) {
364 /* From a search... */
a07cd1a4 365 $cc_string .= '&nbsp;(<A HREF="' . $base_uri .
366 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
10f0ce72 367 if (isset($where) && isset($what)) {
a07cd1a4 368 $cc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
10f0ce72 369 } else {
a07cd1a4 370 $cc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
10f0ce72 371 }
2844086d 372 }
10f0ce72 373 }
374 }
a07cd1a4 375}
376
377/** FORMAT THE BCC STRING **/
378$i = 0;
379if (isset ($message->header->bcc[0]) && trim($message->header->bcc[0])){
380 $bcc_string = "";
381 $bcc_ary = $message->header->bcc;
382 while ($i < count(decodeHeader($bcc_ary))) {
383 $bcc_ary[$i] = htmlspecialchars($bcc_ary[$i]);
384 if ($bcc_string) {
385 $bcc_string = "$bcc_string<BR>$bcc_ary[$i]";
386 } else {
387 $bcc_string = "$bcc_ary[$i]";
10f0ce72 388 }
10f0ce72 389
a07cd1a4 390 $i++;
391 if (count($bcc_ary) > 1) {
392 if ($show_more_cc == false) {
393 if ($i == 1) {
10f0ce72 394 /* From a search... */
a07cd1a4 395 $bcc_string .= '&nbsp;(<A HREF="' . $base_uri .
396 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
10f0ce72 397 if (isset($where) && isset($what)) {
a07cd1a4 398 $bcc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
10f0ce72 399 } else {
a07cd1a4 400 $bcc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
401 }
402 $i = count($bcc_ary);
403 }
404 } else if ($i == 1) {
405 /* From a search... */
406 $bcc_string .= '&nbsp;(<A HREF="' . $base_uri .
407 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
408 if (isset($where) && isset($what)) {
409 $bcc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
410 } else {
411 $bcc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
10f0ce72 412 }
413 }
414 }
415 }
a07cd1a4 416}
10f0ce72 417
a07cd1a4 418if ($default_use_priority) {
a7818e8e 419 $priority_level = substr($message->header->priority,0,1);
420
421 switch($priority_level) {
09278ebf 422 /* check for a higher then normal priority. */
423 case '1':
424 case '2':
425 $priority_string = _("High");
426 break;
427
428 /* check for a lower then normal priority. */
429 case '4':
430 case '5':
431 $priority_string = _("Low");
432 break;
433
434 /* check for a normal priority. */
435 case '3':
436 default:
437 $priority_level = '3';
438 $priority_string = _("Normal");
439 break;
440
10f0ce72 441 }
a07cd1a4 442}
443
444/** make sure everything will display in HTML format **/
445$from_name = decodeHeader(htmlspecialchars($message->header->from));
446$subject = decodeHeader(htmlspecialchars($message->header->subject));
447
448do_hook('read_body_top');
449echo '<BR>' .
450 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
451 ' <TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' . "\n" .
452 ' <TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' . "\n" .
453 ' <TR>' . "\n" .
454 ' <TD ALIGN="LEFT" WIDTH="33%">' . "\n" .
455 ' <SMALL>' . "\n" .
456 '<A HREF="' . $base_uri . 'src/';
457
458if ($where && $what) {
459 if( $pos == '' ) {
460 $pos = 0;
10f0ce72 461 }
a07cd1a4 462 echo "search.php?where$pos=".urlencode($where)."&pos=$pos&what$pos=".urlencode($what)."&mailbox=$urlMailbox\">";
463} else {
464 echo "right_main.php?use_mailbox_cache=1&sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
465}
466echo _("Message List") .
467 '</A>&nbsp;|&nbsp;' .
468 '<A HREF="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&";
469if ($where && $what) {
470 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">';
471} else {
472 echo "sort=$sort&startMessage=$startMessage\">";
473}
474echo _("Delete") . '</A>&nbsp;';
475if (($mailbox == $draft_folder) && ($save_as_draft)) {
476 echo '|&nbsp;<A HREF="' . $base_uri .
477 "src/compose.php?mailbox=$mailbox&send_to=$to_string&send_to_cc=$cc_string&send_to_bcc=$bcc_string&subject=$url_subj&draft_id=$passed_id&ent_num=$ent_num\">".
478 _("Resume Draft") . '</a>';
479}
480
481echo '&nbsp;&nbsp;' .
482 ' </SMALL>' . "\n" .
483 ' </TD>' . "\n" .
484 ' <TD WIDTH="33%" ALIGN="CENTER">' . "\n" .
485 ' <SMALL>' . "\n";
486
487if ( !($where && $what) ) {
488
489 if ($currentArrayIndex == -1) {
490 echo 'Previous&nbsp;|&nbsp;Next';
10f0ce72 491 } else {
a07cd1a4 492 $prev = findPreviousMessage();
493 $next = findNextMessage();
10f0ce72 494
a07cd1a4 495 if ($prev != -1) {
496 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A>&nbsp;|&nbsp;";
10f0ce72 497 } else {
a07cd1a4 498 echo _("Previous") . '&nbsp;|&nbsp;';
10f0ce72 499 }
7baf86a9 500
a07cd1a4 501 if ($next != -1) {
502 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
503 } else {
504 echo _("Next");
505 }
10f0ce72 506 }
a07cd1a4 507}
508
509echo ' </SMALL>' . "\n" .
510 ' </TD><TD WIDTH="33%" ALIGN="RIGHT">' .
511 ' <SMALL>' .
a7818e8e 512 ' <A HREF="' . $base_uri . "src/compose.php?forward_id=$passed_id&forward_subj=$url_subj&".
513 (isset($default_use_priority)?"mailprio=$priority_level&":"")
514 ."mailbox=$urlMailbox&ent_num=$ent_num\">" .
a07cd1a4 515 _("Forward") .
516 '</A>&nbsp;|&nbsp;' .
a7818e8e 517 ' <A HREF="' . $base_uri . "src/compose.php?send_to=$url_replyto&reply_subj=$url_subj&".
518 (isset($default_use_priority)?"mailprio=$priority_level&":"").
519 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\">" .
a07cd1a4 520 _("Reply") .
521 '</A>&nbsp;|&nbsp;' .
a7818e8e 522 ' <A HREF="' . $base_uri . "src/compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
523 (isset($default_use_priority)?"mailprio=$priority_level&":"").
524 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\">" .
a07cd1a4 525 _("Reply All") .
526 '</A>&nbsp;&nbsp;' .
527 ' </SMALL>' .
528 ' </TD>' .
529 ' </TR>' .
530 ' </TABLE>' .
531 ' </TD></TR>' .
532 ' <TR><TD CELLSPACING="0" WIDTH="100%">' .
533 ' <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" .
534 ' <TR>' . "\n";
535
536/** subject **/
537echo " <TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" .
538 _("Subject:") .
539 " </TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" .
540 " <B>$subject</B>&nbsp;\n" .
541 " </TD>\n" .
542 ' <TD ROWSPAN="4" width="10%" BGCOLOR="' . $color[0] .
543 '" ALIGN=right VALIGN=top NOWRAP><small>'.
544 '<A HREF="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
545
546/* From a search... */
547if ($where && $what) {
548 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) .
549 "&view_hdr=1\">" . _("View Full Header") . "</A>\n";
550} else {
551 echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" .
552 _("View Full Header") . "</A>\n";
553}
554
555/* Output the printer friendly link if we are in subtle mode. */
556if ($pf_subtle_link) {
557 echo printer_friendly_link(true);
558}
559
560do_hook("read_body_header_right");
561echo '</small></TD>' . "\n" .
562 ' </TR>' ."\n";
563
564/** from **/
565echo ' <TR>' . "\n" .
566 ' <TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
567 _("From:") .
568 ' </TD><TD BGCOLOR="' . $color[0] . '">' . "\n" .
569 " <B>$from_name</B>&nbsp;\n" .
570 ' </TD>' . "\n" .
571 ' </TR>' . "\n";
572/** date **/
573echo ' <TR>' . "\n" .
574 ' <TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
575 _("Date:") .
576 " </TD><TD BGCOLOR=\"$color[0]\">\n" .
577 " <B>$dateString</B>&nbsp;\n" .
578 ' </TD>' . "\n" .
579 ' </TR>' . "\n";
580
581/** to **/
582echo " <TR>\n" .
583 " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
584 _("To:") .
585 ' </TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" .
586 " <B>$to_string</B>&nbsp;\n" .
587 ' </TD>' . "\n" .
588 ' </TR>' . "\n";
589/** cc **/
590if (isset($cc_string)) {
10f0ce72 591 echo " <TR>\n" .
a07cd1a4 592 " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
593 ' Cc:' . "\n" .
594 " </TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>\n" .
595 " <B>$cc_string</B>&nbsp;\n" .
596 ' </TD>' . "\n" .
597 ' </TR>' . "\n";
598}
599
600/** bcc **/
601if (isset($bcc_string)) {
602 echo " <TR>\n" .
603 " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
604 ' Bcc:' . "\n" .
605 " </TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>\n" .
606 " <B>$bcc_string</B>&nbsp;\n" .
607 ' </TD>' . "\n" .
608 ' </TR>' . "\n";
609}
610if ($default_use_priority) {
611 if (isset($priority_string)) {
10f0ce72 612 echo " <TR>\n" .
a07cd1a4 613 " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
614 " "._("Priority").": \n".
615 " </TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>\n" .
616 " <B>$priority_string</B>&nbsp;\n" .
617 " </TD>" . "\n" .
618 " </TR>" . "\n";
10f0ce72 619 }
a07cd1a4 620}
621
622if ($show_xmailer_default) {
623 fputs ($imapConnection, sqimap_session_id() .
624 " FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]\r\n");
625 $read = sqimap_read_data ($imapConnection, sqimap_session_id(), true,
626 $response, $readmessage);
627 $mailer = substr($read[1], strpos($read[1], " "));
628 if (trim($mailer)) {
10f0ce72 629 echo " <TR>\n" .
a07cd1a4 630 " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
631 " "._("Mailer").": \n".
632 " </TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>\n" .
633 " <B>$mailer</B>&nbsp;\n" .
634 " </TD>" . "\n" .
635 " </TR>" . "\n";
10f0ce72 636 }
a07cd1a4 637}
638
639/* Output the printer friendly link if we are not in subtle mode. */
640if (!$pf_subtle_link) {
641 echo printer_friendly_link(true);
642}
643
644do_hook("read_body_header");
645echo '</TABLE>' .
646 ' </TD></TR>' .
647 '</TABLE>';
648flush();
649echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" .
650 " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" .
651 '<BR>'.
652 formatBody($imapConnection, $message, $color, $wrap_at).
653 '</TABLE>' .
654 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
655 " <TR><TD BGCOLOR=\"$color[9]\">&nbsp;</TD></TR>" .
656 '</TABLE>' . "\n";
657
658/* show attached images inline -- if pref'fed so */
659if (($attachment_common_show_images) and
660 is_array($attachment_common_show_images_list)) {
661 foreach ($attachment_common_show_images_list as $img) {
662 echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" .
663 " <TR>\n" .
664 " <TD>\n" .
665 ' <img src="../src/download.php' .
666 '?passed_id=' . urlencode($img['passed_id']) .
667 '&mailbox=' . urlencode($img['mailbox']) .
668 '&passed_ent_id=' . urlencode($img['ent_id']) .
669 '&absolute_dl=true">' . "\n" .
670 " </TD>\n" .
671 " </TR>\n" .
672 "</TABLE>\n";
10f0ce72 673 }
a07cd1a4 674}
675
676do_hook('read_body_bottom');
677do_hook('html_bottom');
678sqimap_logout($imapConnection);
679?>
680</body>
a7818e8e 681</html>