bf3ce39162558b2d18b2ba8d0be63f0f59d37f37
[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 require_once('../src/validate.php');
16 require_once('../functions/imap.php');
17 require_once('../functions/mime.php');
18 require_once('../functions/date.php');
19 require_once('../functions/url_parser.php');
20
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 */
28 function 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;
44 }
45 }
46 }
47 return ($result);
48 }
49
50 /** Removes just one address from the list of addresses. */
51 function 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]);
55 }
56 }
57 }
58
59 /** returns the index of the previous message from the array. */
60 function 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;
78 }
79 }
80 }
81 }
82 return ($result);
83 }
84
85 /**
86 * Displays a link to a page where the message is displayed more
87 * "printer friendly".
88 */
89 function 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 }
97
98 $params = '?passed_ent_id=' . $ent_num;
99 $params .= '&mailbox=' . urlencode($mailbox);
100 $params .= '&passed_id=' . $passed_id;
101
102 $print_text = _("View Printable Version");
103
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 }
114
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 }
130
131 if (!$pf_subtle_link) {
132 /* The link is large, on the bottom of the header panel. */
133 $result .= ' </td>' . "\n" .
134 ' </tr>' . "\n";
135 }
136
137 return ($result);
138 }
139
140 /*****************************/
141 /*** Main of read_boby.php ***/
142 /*****************************/
143
144 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
145 sqimap_mailbox_select($imapConnection, $mailbox);
146 do_hook('html_top');
147 displayPageHeader($color, $mailbox);
148
149 if (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++;
181 } else {
182 $second[$i] = trim($line);
183 $first[$i] = '';
184 }
185 }
186 for ($i=0; $i < count($second); $i = $j) {
187 if (isset($first[$i])) {
188 $f = $first[$i];
189 }
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++;
197 }
198 parseEmail($s);
199 if (isset($f)) echo "<nobr><tt><b>$f</b>$s</tt></nobr>";
200 }
201 echo "</td></tr></table>\n";
202 echo '</body></html>';
203 sqimap_logout($imapConnection);
204 exit;
205 }
206
207 if (isset($msgs)) {
208 $currentArrayIndex = $passed_id;
209 } else {
210 $currentArrayIndex = -1;
211 }
212
213 for ($i = 0; $i < count($msgs); $i++) {
214 if ($msgs[$i]['ID'] == $passed_id) {
215 $msgs[$i]['FLAG_SEEN'] = true;
216 }
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 = '';
227 if (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 = '';
256 if (isset($message->header->replyto)) {
257 $url_replytoall_avoid_addrs = $message->header->replyto;
258 }
259
260 $url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs);
261 foreach ($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
267 if (!$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);
275 }
276 }
277 }
278
279 // 7) Smoosh back into one nice line
280 $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs);
281
282 // 8) urlencode() it
283 $url_replytoallcc = urlencode($url_replytoallcc);
284
285 $dateString = getLongDateString($message->header->date);
286
287 // What do we reply to -- text only, if possible
288 $ent_num = findDisplayEntity($message);
289
290 /** TEXT STRINGS DEFINITIONS **/
291 $echo_more = _("more");
292 $echo_less = _("less");
293
294 if (!isset($show_more_cc)) $show_more_cc = false;
295
296 /** FORMAT THE TO STRING **/
297 $i = 0;
298 $to_string = '';
299 $to_ary = $message->header->to;
300 while ($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]";
307 }
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>)";
331 }
332 }
333 }
334 }
335
336 /** FORMAT THE CC STRING **/
337 $i = 0;
338 if (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]";
345 } else {
346 $cc_string = "$cc_ary[$i]";
347 }
348
349 $i++;
350 if (count($cc_ary) > 1) {
351 if ($show_more_cc == false) {
352 if ($i == 1) {
353 /* From a search... */
354 $cc_string .= '&nbsp;(<A HREF="' . $base_uri .
355 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id";
356 if (isset($where) && isset($what)) {
357 $cc_string .= '&what='.urlencode($what)."&where=".urlencode($where)."&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
358 } else {
359 $cc_string .= "&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 $cc_string .= '&nbsp;(<A HREF="' . $base_uri .
366 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
367 if (isset($where) && isset($what)) {
368 $cc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
369 } else {
370 $cc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
371 }
372 }
373 }
374 }
375 }
376
377 /** FORMAT THE BCC STRING **/
378 $i = 0;
379 if (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]";
388 }
389
390 $i++;
391 if (count($bcc_ary) > 1) {
392 if ($show_more_cc == false) {
393 if ($i == 1) {
394 /* From a search... */
395 $bcc_string .= '&nbsp;(<A HREF="' . $base_uri .
396 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
397 if (isset($where) && isset($what)) {
398 $bcc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
399 } else {
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>)";
412 }
413 }
414 }
415 }
416 }
417
418 if ($default_use_priority) {
419 $priority_level = substr($message->header->priority,0,1);
420
421 switch($priority_level) {
422 /* First, check for a higher then normal priority. */
423 case "1":
424 case "2": $priority_string = _("High"); break;
425
426 /* Second, check for a normal priority. */
427 case "3": $priority_string = _("Normal"); break;
428
429 /* Last, check for a lower then normal priority. */
430 case "4":
431 case "5": $priority_string = _("Low"); break;
432 }
433 }
434
435 /** make sure everything will display in HTML format **/
436 $from_name = decodeHeader(htmlspecialchars($message->header->from));
437 $subject = decodeHeader(htmlspecialchars($message->header->subject));
438
439 do_hook('read_body_top');
440 echo '<BR>' .
441 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
442 ' <TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' . "\n" .
443 ' <TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' . "\n" .
444 ' <TR>' . "\n" .
445 ' <TD ALIGN="LEFT" WIDTH="33%">' . "\n" .
446 ' <SMALL>' . "\n" .
447 '<A HREF="' . $base_uri . 'src/';
448
449 if ($where && $what) {
450 if( $pos == '' ) {
451 $pos = 0;
452 }
453 echo "search.php?where$pos=".urlencode($where)."&pos=$pos&what$pos=".urlencode($what)."&mailbox=$urlMailbox\">";
454 } else {
455 echo "right_main.php?use_mailbox_cache=1&sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
456 }
457 echo _("Message List") .
458 '</A>&nbsp;|&nbsp;' .
459 '<A HREF="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&";
460 if ($where && $what) {
461 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">';
462 } else {
463 echo "sort=$sort&startMessage=$startMessage\">";
464 }
465 echo _("Delete") . '</A>&nbsp;';
466 if (($mailbox == $draft_folder) && ($save_as_draft)) {
467 echo '|&nbsp;<A HREF="' . $base_uri .
468 "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\">".
469 _("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
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="' . $base_uri . "src/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="' . $base_uri . "src/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="' . $base_uri . "src/compose.php?forward_id=$passed_id&forward_subj=$url_subj&".
504 (isset($default_use_priority)?"mailprio=$priority_level&":"")
505 ."mailbox=$urlMailbox&ent_num=$ent_num\">" .
506 _("Forward") .
507 '</A>&nbsp;|&nbsp;' .
508 ' <A HREF="' . $base_uri . "src/compose.php?send_to=$url_replyto&reply_subj=$url_subj&".
509 (isset($default_use_priority)?"mailprio=$priority_level&":"").
510 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\">" .
511 _("Reply") .
512 '</A>&nbsp;|&nbsp;' .
513 ' <A HREF="' . $base_uri . "src/compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
514 (isset($default_use_priority)?"mailprio=$priority_level&":"").
515 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\">" .
516 _("Reply All") .
517 '</A>&nbsp;&nbsp;' .
518 ' </SMALL>' .
519 ' </TD>' .
520 ' </TR>' .
521 ' </TABLE>' .
522 ' </TD></TR>' .
523 ' <TR><TD CELLSPACING="0" WIDTH="100%">' .
524 ' <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" .
525 ' <TR>' . "\n";
526
527 /** subject **/
528 echo " <TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" .
529 _("Subject:") .
530 " </TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" .
531 " <B>$subject</B>&nbsp;\n" .
532 " </TD>\n" .
533 ' <TD ROWSPAN="4" width="10%" BGCOLOR="' . $color[0] .
534 '" ALIGN=right VALIGN=top NOWRAP><small>'.
535 '<A HREF="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
536
537 /* From a search... */
538 if ($where && $what) {
539 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) .
540 "&view_hdr=1\">" . _("View Full Header") . "</A>\n";
541 } else {
542 echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" .
543 _("View Full Header") . "</A>\n";
544 }
545
546 /* Output the printer friendly link if we are in subtle mode. */
547 if ($pf_subtle_link) {
548 echo printer_friendly_link(true);
549 }
550
551 do_hook("read_body_header_right");
552 echo '</small></TD>' . "\n" .
553 ' </TR>' ."\n";
554
555 /** from **/
556 echo ' <TR>' . "\n" .
557 ' <TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
558 _("From:") .
559 ' </TD><TD BGCOLOR="' . $color[0] . '">' . "\n" .
560 " <B>$from_name</B>&nbsp;\n" .
561 ' </TD>' . "\n" .
562 ' </TR>' . "\n";
563 /** date **/
564 echo ' <TR>' . "\n" .
565 ' <TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
566 _("Date:") .
567 " </TD><TD BGCOLOR=\"$color[0]\">\n" .
568 " <B>$dateString</B>&nbsp;\n" .
569 ' </TD>' . "\n" .
570 ' </TR>' . "\n";
571
572 /** to **/
573 echo " <TR>\n" .
574 " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
575 _("To:") .
576 ' </TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" .
577 " <B>$to_string</B>&nbsp;\n" .
578 ' </TD>' . "\n" .
579 ' </TR>' . "\n";
580 /** cc **/
581 if (isset($cc_string)) {
582 echo " <TR>\n" .
583 " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
584 ' Cc:' . "\n" .
585 " </TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>\n" .
586 " <B>$cc_string</B>&nbsp;\n" .
587 ' </TD>' . "\n" .
588 ' </TR>' . "\n";
589 }
590
591 /** bcc **/
592 if (isset($bcc_string)) {
593 echo " <TR>\n" .
594 " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
595 ' Bcc:' . "\n" .
596 " </TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>\n" .
597 " <B>$bcc_string</B>&nbsp;\n" .
598 ' </TD>' . "\n" .
599 ' </TR>' . "\n";
600 }
601 if ($default_use_priority) {
602 if (isset($priority_string)) {
603 echo " <TR>\n" .
604 " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
605 " "._("Priority").": \n".
606 " </TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>\n" .
607 " <B>$priority_string</B>&nbsp;\n" .
608 " </TD>" . "\n" .
609 " </TR>" . "\n";
610 }
611 }
612
613 if ($show_xmailer_default) {
614 fputs ($imapConnection, sqimap_session_id() .
615 " FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]\r\n");
616 $read = sqimap_read_data ($imapConnection, sqimap_session_id(), true,
617 $response, $readmessage);
618 $mailer = substr($read[1], strpos($read[1], " "));
619 if (trim($mailer)) {
620 echo " <TR>\n" .
621 " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
622 " "._("Mailer").": \n".
623 " </TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>\n" .
624 " <B>$mailer</B>&nbsp;\n" .
625 " </TD>" . "\n" .
626 " </TR>" . "\n";
627 }
628 }
629
630 /* Output the printer friendly link if we are not in subtle mode. */
631 if (!$pf_subtle_link) {
632 echo printer_friendly_link(true);
633 }
634
635 do_hook("read_body_header");
636 echo '</TABLE>' .
637 ' </TD></TR>' .
638 '</TABLE>';
639 flush();
640 echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" .
641 " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" .
642 '<BR>'.
643 formatBody($imapConnection, $message, $color, $wrap_at).
644 '</TABLE>' .
645 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
646 " <TR><TD BGCOLOR=\"$color[9]\">&nbsp;</TD></TR>" .
647 '</TABLE>' . "\n";
648
649 /* show attached images inline -- if pref'fed so */
650 if (($attachment_common_show_images) and
651 is_array($attachment_common_show_images_list)) {
652 foreach ($attachment_common_show_images_list as $img) {
653 echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" .
654 " <TR>\n" .
655 " <TD>\n" .
656 ' <img src="../src/download.php' .
657 '?passed_id=' . urlencode($img['passed_id']) .
658 '&mailbox=' . urlencode($img['mailbox']) .
659 '&passed_ent_id=' . urlencode($img['ent_id']) .
660 '&absolute_dl=true">' . "\n" .
661 " </TD>\n" .
662 " </TR>\n" .
663 "</TABLE>\n";
664 }
665 }
666
667 do_hook('read_body_bottom');
668 do_hook('html_bottom');
669 sqimap_logout($imapConnection);
670 ?>
671 </body>
672 </html>