some more html cleanup provided by Dave Huang
[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 if (isset($where) && isset($what)) {
366 $cc_string = "$cc_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>)";
367 } else {
368 $cc_string = "$cc_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>)";
369 }
370 $i = count($cc_ary);
371 }
372 } else if ($i == 1) {
373 /* From a search... */
374 if (isset($where) && isset($what)) {
375 $cc_string = "$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>)";
376 } else {
377 $cc_string = "$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>)";
378 }
379 }
380 }
381 }
382 }
383
384 /** FORMAT THE BCC STRING **/
385 $i = 0;
386 if (isset ($message->header->bcc[0]) && trim($message->header->bcc[0])){
387 $bcc_string = "";
388 $bcc_ary = $message->header->bcc;
389 while ($i < count(decodeHeader($bcc_ary))) {
390 $bcc_ary[$i] = htmlspecialchars($bcc_ary[$i]);
391 if ($bcc_string) {
392 $bcc_string = "$bcc_string<BR>$bcc_ary[$i]";
393 } else {
394 $bcc_string = "$bcc_ary[$i]";
395 }
396
397 $i++;
398 if (count($bcc_ary) > 1) {
399 if ($show_more_cc == false) {
400 if ($i == 1) {
401 /* From a search... */
402 if (isset($where) && isset($what)) {
403 $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>)";
404 } else {
405 $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>)";
406 }
407 $i = count($bcc_ary);
408 }
409 } else if ($i == 1) {
410 /* From a search... */
411 if (isset($where) && isset($what)) {
412 $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>)";
413 } else {
414 $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>)";
415 }
416 }
417 }
418 }
419 }
420
421 if ($default_use_priority) {
422 switch(substr($message->header->priority,0,1)) {
423 /* First, check for a higher then normal priority. */
424 case "1":
425 case "2": $priority_string = _("High"); break;
426
427 /* Second, check for a normal priority. */
428 case "3": $priority_string = _("Normal"); break;
429
430 /* Last, check for a lower then normal priority. */
431 case "4":
432 case "5": $priority_string = _("Low"); break;
433 }
434 }
435
436 /** make sure everything will display in HTML format **/
437 $from_name = decodeHeader(htmlspecialchars($message->header->from));
438 $subject = decodeHeader(htmlspecialchars($message->header->subject));
439
440 do_hook('read_body_top');
441 echo '<BR>' .
442 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
443 ' <TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' . "\n" .
444 ' <TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' . "\n" .
445 ' <TR>' . "\n" .
446 ' <TD ALIGN="LEFT" WIDTH="33%">' . "\n" .
447 ' <SMALL>' . "\n";
448 if ($where && $what) {
449 echo " <A HREF=\"search.php?where=".urlencode($where)."&what=".urlencode($what)."&mailbox=$urlMailbox\">";
450 } else {
451 echo " <A HREF=\"right_main.php?use_mailbox_cache=1&sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
452 }
453 echo _("Message List");
454 echo '</A>&nbsp;|&nbsp;';
455 if ($where && $what) {
456 echo " <A HREF=\"delete_message.php?mailbox=$urlMailbox&message=$passed_id&where=".urlencode($where)."&what=".urlencode($what).'">';
457 } else {
458 echo " <A HREF=\"delete_message.php?mailbox=$urlMailbox&message=$passed_id&sort=$sort&startMessage=$startMessage\">";
459 }
460 echo _("Delete") . '</A>&nbsp;';
461 if (($mailbox == $draft_folder) && ($save_as_draft)) {
462 echo '|&nbsp;';
463 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\">";
464 echo _("Resume Draft") . '</a>';
465 }
466
467 echo '&nbsp;&nbsp;' .
468 ' </SMALL>' . "\n" .
469 ' </TD>' . "\n" .
470 ' <TD WIDTH="33%" ALIGN="CENTER">' . "\n" .
471 ' <SMALL>' . "\n";
472
473 if ($where && $what) {
474 } else {
475 if ($currentArrayIndex == -1) {
476 echo 'Previous&nbsp;|&nbsp;Next';
477 } else {
478 $prev = findPreviousMessage();
479 $next = findNextMessage();
480
481 if ($prev != -1) {
482 echo "<a href=\"read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A>&nbsp;|&nbsp;";
483 } else {
484 echo _("Previous") . '&nbsp;|&nbsp;';
485 }
486
487 if ($next != -1) {
488 echo "<a href=\"read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
489 } else {
490 echo _("Next");
491 }
492 }
493 }
494
495 echo ' </SMALL>' . "\n" .
496 ' </TD><TD WIDTH="33%" ALIGN="RIGHT">' .
497 ' <SMALL>' .
498 " <A HREF=\"compose.php?forward_id=$passed_id&forward_subj=$url_subj&mailbox=$urlMailbox&ent_num=$ent_num\">" .
499 _("Forward") .
500 '</A>&nbsp;|&nbsp;' .
501 " <A HREF=\"compose.php?send_to=$url_replyto&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\">" .
502 _("Reply") .
503 '</A>&nbsp;|&nbsp;' .
504 " <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\">" .
505 _("Reply All") .
506 '</A>&nbsp;&nbsp;' .
507 ' </SMALL>' .
508 ' </TD>' .
509 ' </TR>' .
510 ' </TABLE>' .
511 ' </TD></TR>' .
512 ' <TR><TD CELLSPACING="0" WIDTH="100%">' .
513 ' <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" .
514 ' <TR>' . "\n";
515
516 /** subject **/
517 echo " <TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" .
518 _("Subject:") .
519 " </TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" .
520 " <B>$subject</B>&nbsp;\n" .
521 " </TD>\n" .
522 ' <TD ROWSPAN="4" width="10%" BGCOLOR="'.$color[0].'" ALIGN=right VALIGN=top NOWRAP><small>' . "\n";
523
524 /* From a search... */
525 if ($where && $what) {
526 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";
527 } else {
528 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";
529 }
530
531 /* Output the printer friendly link if we are in subtle mode. */
532 if ($pf_subtle_link) {
533 echo printer_friendly_link(true);
534 }
535
536 do_hook("read_body_header_right");
537 echo '</small></TD>' . "\n" .
538 ' </TR>' ."\n";
539
540 /** from **/
541 echo ' <TR>' . "\n" .
542 ' <TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
543 _("From:") .
544 ' </TD><TD BGCOLOR="' . $color[0] . '">' . "\n" .
545 " <B>$from_name</B>&nbsp;\n" .
546 ' </TD>' . "\n" .
547 ' </TR>' . "\n";
548 /** date **/
549 echo ' <TR>' . "\n" .
550 ' <TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
551 _("Date:") .
552 " </TD><TD BGCOLOR=\"$color[0]\">\n" .
553 " <B>$dateString</B>&nbsp;\n" .
554 ' </TD>' . "\n" .
555 ' </TR>' . "\n";
556
557 /** to **/
558 echo " <TR>\n" .
559 " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
560 _("To:") .
561 ' </TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" .
562 " <B>$to_string</B>&nbsp;\n" .
563 ' </TD>' . "\n" .
564 ' </TR>' . "\n";
565 /** cc **/
566 if (isset($cc_string)) {
567 echo " <TR>\n" .
568 " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
569 ' Cc:' . "\n" .
570 " </TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>\n" .
571 " <B>$cc_string</B>&nbsp;\n" .
572 ' </TD>' . "\n" .
573 ' </TR>' . "\n";
574 }
575
576 /** bcc **/
577 if (isset($bcc_string)) {
578 echo " <TR>\n" .
579 " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
580 ' Bcc:' . "\n" .
581 " </TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>\n" .
582 " <B>$bcc_string</B>&nbsp;\n" .
583 ' </TD>' . "\n" .
584 ' </TR>' . "\n";
585 }
586 if ($default_use_priority) {
587 if (isset($priority_string)) {
588 echo " <TR>\n" .
589 " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
590 " "._("Priority").": \n".
591 " </TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>\n" .
592 " <B>$priority_string</B>&nbsp;\n" .
593 " </TD>" . "\n" .
594 " </TR>" . "\n";
595 }
596 }
597
598 if ($show_xmailer_default) {
599 fputs ($imapConnection, sqimap_session_id() .
600 " FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]\r\n");
601 $read = sqimap_read_data ($imapConnection, sqimap_session_id(), true,
602 $response, $readmessage);
603 $mailer = substr($read[1], strpos($read[1], " "));
604 if (trim($mailer)) {
605 echo " <TR>\n" .
606 " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
607 " "._("Mailer").": \n".
608 " </TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>\n" .
609 " <B>$mailer</B>&nbsp;\n" .
610 " </TD>" . "\n" .
611 " </TR>" . "\n";
612 }
613 }
614
615 /* Output the printer friendly link if we are not in subtle mode. */
616 if (!$pf_subtle_link) {
617 echo printer_friendly_link(true);
618 }
619
620 do_hook("read_body_header");
621 echo '</TABLE>' .
622 ' </TD></TR>' .
623 '</TABLE>';
624 flush();
625 echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" .
626 " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" .
627 '<BR>';
628
629 $body = formatBody($imapConnection, $message, $color, $wrap_at);
630
631 echo $body .
632 '</TABLE>' .
633 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
634 " <TR><TD BGCOLOR=\"$color[9]\">&nbsp;</TD></TR>" .
635 '</TABLE>' . "\n";
636
637 /* show attached images inline -- if pref'fed so */
638 if (($attachment_common_show_images) and
639 is_array($attachment_common_show_images_list)) {
640 foreach ($attachment_common_show_images_list as $img) {
641 echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" .
642 " <TR>\n" .
643 " <TD>\n" .
644 ' <img src="../src/download.php' .
645 '?passed_id=' . urlencode($img['passed_id']) .
646 '&mailbox=' . urlencode($img['mailbox']) .
647 '&passed_ent_id=' . urlencode($img['ent_id']) .
648 '&absolute_dl=true">' . "\n" .
649 " </TD>\n" .
650 " </TR>\n" .
651 "</TABLE>\n";
652 }
653 }
654
655 do_hook('read_body_bottom');
656 do_hook('html_bottom');
657 sqimap_logout($imapConnection);
658 ?>