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