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