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