59177427 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * read_body.php |
5 | * |
15e6162e |
6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
35586184 |
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$ |
a07cd1a4 |
13 | */ |
35586184 |
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'); |
57257333 |
20 | require_once('../functions/smtp.php'); |
5be9f195 |
21 | |
a07cd1a4 |
22 | /** |
1fca12b5 |
23 | * Given an IMAP message id number, this will look it up in the cached |
24 | * and sorted msgs array and return the index. Used for finding the next |
25 | * and previous messages. |
26 | * |
27 | * @return the index of the next valid message from the array |
28 | */ |
a07cd1a4 |
29 | function findNextMessage() { |
92592f0e |
30 | global $msort, $currentArrayIndex, $msgs, $sort, |
cf710efe |
31 | $thread_sort_messages, $allow_server_sort, |
60a3e687 |
32 | $server_sort_array; |
2728fa19 |
33 | if (!is_array($server_sort_array)) { |
34 | $thread_sort_messages = 0; |
794d59c0 |
35 | $allow_server_sort = FALSE; |
2728fa19 |
36 | } |
a07cd1a4 |
37 | $result = -1; |
794d59c0 |
38 | if ($thread_sort_messages == 1 || $allow_server_sort == TRUE) { |
60a3e687 |
39 | reset($server_sort_array); |
40 | while(list($key, $value) = each ($server_sort_array)) { |
41 | if ($currentArrayIndex == $value) { |
1fca12b5 |
42 | if ($key == (count($server_sort_array) - 1)) { |
60a3e687 |
43 | $result = -1; |
44 | break; |
45 | } |
1fca12b5 |
46 | $result = $server_sort_array[$key + 1]; |
60a3e687 |
47 | break; |
789b4d79 |
48 | } |
60a3e687 |
49 | } |
1fca12b5 |
50 | } |
794d59c0 |
51 | elseif ($sort == 6 && $allow_server_sort != TRUE && |
cf710efe |
52 | $thread_sort_messages != 1) { |
a07cd1a4 |
53 | if ($currentArrayIndex != 1) { |
54 | $result = $currentArrayIndex - 1; |
55 | } |
1fca12b5 |
56 | } |
794d59c0 |
57 | elseif ($allow_server_sort != TRUE && $thread_sort_messages != 1 ) { |
75ef78d8 |
58 | if (!is_array($msort)) { |
59 | return -1; |
60 | } |
a07cd1a4 |
61 | for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { |
62 | if ($currentArrayIndex == $msgs[$key]['ID']) { |
63 | next($msort); |
64 | $key = key($msort); |
1fca12b5 |
65 | if (isset($key)){ |
a07cd1a4 |
66 | $result = $msgs[$key]['ID']; |
67 | break; |
1fca12b5 |
68 | } |
10f0ce72 |
69 | } |
70 | } |
10f0ce72 |
71 | } |
a07cd1a4 |
72 | return ($result); |
73 | } |
74 | |
1fca12b5 |
75 | /** |
76 | * Removes just one address from the list of addresses. |
77 | * |
78 | * @param &$addr_list a by-ref array of addresses |
79 | * @param $addr an address to remove |
80 | * @return void, since it operates on a by-ref param |
81 | */ |
a07cd1a4 |
82 | function RemoveAddress(&$addr_list, $addr) { |
83 | if ($addr != '') { |
84 | foreach (array_keys($addr_list, $addr) as $key_to_delete) { |
85 | unset($addr_list[$key_to_delete]); |
10f0ce72 |
86 | } |
a07cd1a4 |
87 | } |
88 | } |
89 | |
90 | /** returns the index of the previous message from the array. */ |
91 | function findPreviousMessage() { |
57257333 |
92 | global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection, |
cf710efe |
93 | $mailbox, $data_dir, $username, $thread_sort_messages, |
60a3e687 |
94 | $allow_server_sort, $server_sort_array; |
a07cd1a4 |
95 | $result = -1; |
2728fa19 |
96 | if (!is_array($server_sort_array)) { |
97 | $thread_sort_messages = 0; |
794d59c0 |
98 | $allow_server_sort = FALSE; |
2728fa19 |
99 | } |
794d59c0 |
100 | if ($thread_sort_messages == 1 || $allow_server_sort == TRUE) { |
60a3e687 |
101 | reset($server_sort_array); |
102 | while(list($key, $value) = each ($server_sort_array)) { |
103 | if ($currentArrayIndex == $value) { |
104 | if ($key == 0) { |
105 | $result = -1; |
106 | break; |
107 | } |
108 | $result = $server_sort_array[$key -1]; |
109 | break; |
789b4d79 |
110 | } |
60a3e687 |
111 | } |
789b4d79 |
112 | } |
794d59c0 |
113 | elseif ($sort == 6 && $allow_server_sort != TRUE && |
cf710efe |
114 | $thread_sort_messages != 1) { |
a07cd1a4 |
115 | $numMessages = sqimap_get_num_messages($imapConnection, $mailbox); |
116 | if ($currentArrayIndex != $numMessages) { |
117 | $result = $currentArrayIndex + 1; |
118 | } |
60a3e687 |
119 | } |
794d59c0 |
120 | elseif ($thread_sort_messages != 1 && $allow_server_sort != TRUE) { |
1fca12b5 |
121 | if (!is_array($msort)) { |
75ef78d8 |
122 | return -1; |
1fca12b5 |
123 | } |
a07cd1a4 |
124 | for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { |
125 | if ($currentArrayIndex == $msgs[$key]['ID']) { |
126 | prev($msort); |
127 | $key = key($msort); |
128 | if (isset($key)) { |
129 | $result = $msgs[$key]['ID']; |
130 | break; |
10f0ce72 |
131 | } |
132 | } |
10f0ce72 |
133 | } |
a07cd1a4 |
134 | } |
135 | return ($result); |
136 | } |
10f0ce72 |
137 | |
a07cd1a4 |
138 | /** |
1fca12b5 |
139 | * Displays a link to a page where the message is displayed more |
140 | * "printer friendly". |
141 | */ |
a07cd1a4 |
142 | function printer_friendly_link() { |
57257333 |
143 | global $passed_id, $mailbox, $ent_num, $color, |
144 | $pf_subtle_link, |
145 | $javascript_on; |
a07cd1a4 |
146 | |
147 | if (strlen(trim($mailbox)) < 1) { |
148 | $mailbox = 'INBOX'; |
149 | } |
10f0ce72 |
150 | |
57257333 |
151 | $params = '?passed_ent_id=' . $ent_num . |
1fca12b5 |
152 | '&mailbox=' . urlencode($mailbox) . |
153 | '&passed_id=' . $passed_id; |
10f0ce72 |
154 | |
a07cd1a4 |
155 | $print_text = _("View Printable Version"); |
10f0ce72 |
156 | |
a07cd1a4 |
157 | if (!$pf_subtle_link) { |
158 | /* The link is large, on the bottom of the header panel. */ |
1fca12b5 |
159 | $result = '<tr bgcolor="' . $color[0] . '">' . |
160 | '<td class="medText" align="right" valign="top">' . |
161 | ' ' . |
162 | '</td><td class="medText" valign="top" colspan="2">'."\n"; |
a07cd1a4 |
163 | } else { |
164 | /* The link is subtle, below "view full header". */ |
165 | $result = "<BR>\n"; |
166 | } |
10f0ce72 |
167 | |
a07cd1a4 |
168 | /* Output the link. */ |
169 | if ($javascript_on) { |
3d570ba0 |
170 | $result .= '<script language="javascript" type="text/javascript">' . "\n" . |
a07cd1a4 |
171 | '<!--' . "\n" . |
172 | " function printFormat() {\n" . |
173 | ' window.open("../src/printer_friendly_main.php' . |
174 | $params . '","Print","width=800,height=600");' . "\n". |
175 | " }\n" . |
176 | "// -->\n" . |
177 | "</script>\n" . |
178 | "<A HREF=\"javascript:printFormat();\">$print_text</A>\n"; |
179 | } else { |
180 | $result .= '<A TARGET="_blank" HREF="../src/printer_friendly_bottom.php' . |
181 | "$params\">$print_text</A>\n"; |
182 | } |
10f0ce72 |
183 | |
a07cd1a4 |
184 | if (!$pf_subtle_link) { |
185 | /* The link is large, on the bottom of the header panel. */ |
57257333 |
186 | $result .= '</td></tr>' . "\n"; |
10f0ce72 |
187 | } |
188 | |
a07cd1a4 |
189 | return ($result); |
190 | } |
191 | |
57257333 |
192 | function ServerMDNSupport( $read ) { |
f69feefe |
193 | /* escaping $ doesn't work -> \x36 */ |
194 | $ret = preg_match( '/(\x36MDNSent|\\\*)/i', $read ); |
57257333 |
195 | return ( $ret ); |
196 | } |
197 | |
198 | function SendMDN ( $recipient , $sender) { |
199 | global $imapConnection, $mailbox, $username, $attachment_dir, $SERVER_NAME, |
200 | $version, $attachments, $identity, $data_dir, $passed_id; |
201 | |
99fbb343 |
202 | $header = sqimap_get_message_header($imapConnection, $passed_id, $mailbox); |
57257333 |
203 | $hashed_attachment_dir = getHashedDir($username, $attachment_dir); |
204 | |
205 | // part 1 (RFC2298) |
206 | |
207 | $senton = getLongDateString( $header->date ); |
208 | $to_array = $header->to; |
209 | $to = ''; |
210 | foreach ($to_array as $line) { |
211 | $to .= " $line "; |
212 | } |
213 | |
214 | $subject = $header->subject; |
215 | $now = getLongDateString( time() ); |
46bb8da8 |
216 | |
78db1583 |
217 | set_my_charset(); |
218 | |
46bb8da8 |
219 | $body = _("Your message") . "\r\n\r\n" . |
220 | "\t" . _("To:") . ' ' . $to . "\r\n" . |
221 | "\t" . _("Subject:") . ' ' . $subject . "\r\n" . |
222 | "\t" . _("Sent:") . ' ' . $senton . "\r\n" . |
223 | "\r\n" . |
224 | sprintf( _("Was displayed on %s"), $now ); |
f69feefe |
225 | |
57257333 |
226 | // part2 (RFC2298) |
227 | |
228 | $original_recipient = $to; |
229 | $original_message_id = $header->message_id; |
230 | |
231 | $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n"; |
232 | if ($original_recipient != '') { |
233 | $part2 .= "Original-Recipient : $original_recipient\r\n"; |
234 | } |
235 | $final_recipient = $sender; |
236 | $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" . |
237 | "Original-Message-ID : $original_message_id\r\n" . |
238 | "Disposition: manual-action/MDN-sent-manually; displayed\r\n"; |
239 | |
240 | |
241 | $localfilename = GenerateRandomString(32, 'FILE', 7); |
242 | $full_localfilename = "$hashed_attachment_dir/$localfilename"; |
243 | |
244 | $fp = fopen( $full_localfilename, 'w'); |
245 | fwrite ($fp, $part2); |
246 | fclose($fp); |
247 | |
248 | $newAttachment = array(); |
249 | $newAttachment['localfilename'] = $localfilename; |
250 | $newAttachment['type'] = "message/disposition-notification"; |
aa866a40 |
251 | $newAttachment['session']=-1; |
57257333 |
252 | $attachments[] = $newAttachment; |
253 | $MDN_to = trim($recipient); |
254 | $reply_id = 0; |
255 | |
1fca12b5 |
256 | return (SendMessage($MDN_to, '', '', _("Read:") . ' ' . $subject, |
257 | $body, $reply_id, True, 3, -1) ); |
57257333 |
258 | } |
259 | |
260 | |
261 | function ToggleMDNflag ( $set ) { |
77b88425 |
262 | global $imapConnection, $passed_id, $mailbox; |
f69feefe |
263 | sqimap_mailbox_select($imapConnection, $mailbox); |
0892e427 |
264 | |
265 | $sg = $set?'+':'-'; |
266 | $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)'; |
0892e427 |
267 | $read = sqimap_run_command ($imapConnection, $cmd, true, $response, |
268 | $readmessage); |
57257333 |
269 | } |
270 | |
271 | function ClearAttachments() { |
272 | global $username, $attachments, $attachment_dir; |
273 | |
274 | $hashed_attachment_dir = getHashedDir($username, $attachment_dir); |
275 | |
aa866a40 |
276 | $rem_attachments = array(); |
57257333 |
277 | foreach ($attachments as $info) { |
aa866a40 |
278 | if ($info->session == -1) { |
279 | $attached_file = "$hashed_attachment_dir/$info[localfilename]"; |
280 | if (file_exists($attached_file)) { |
281 | unlink($attached_file); |
282 | } |
283 | } else { |
284 | $rem_attachments[] = $info; |
285 | } |
286 | } |
68c3b52a |
287 | $attachments = $rem_attachments; |
57257333 |
288 | } |
289 | |
4d0cd98b |
290 | function formatRecipientString($recipients, $item ) { |
1fca12b5 |
291 | global $base_uri, $passed_id, $urlMailbox, $startMessage, $show_more_cc, |
292 | $echo_more, $echo_less, $show_more, $show_more_bcc, $sort; |
4d0cd98b |
293 | |
294 | $i = 0; |
295 | $url_string = ''; |
296 | |
297 | if (isset ($recipients[0]) && trim($recipients[0])) { |
1fca12b5 |
298 | $string = ''; |
4d0cd98b |
299 | $ary = $recipients; |
300 | |
1fca12b5 |
301 | switch ($item) { |
4d0cd98b |
302 | case 'to': |
1fca12b5 |
303 | $show = "&show_more=1&show_more_cc=$show_more_cc&". |
304 | "show_more_bcc=$show_more_bcc"; |
305 | $show_n = "&show_more=0&show_more_cc=$show_more_cc&". |
306 | "show_more_bcc=$show_more_bcc"; |
307 | break; |
4d0cd98b |
308 | case 'cc': |
1fca12b5 |
309 | $show = "&show_more=$show_more&show_more_cc=1&". |
310 | "show_more_bcc=$show_more_bcc"; |
311 | $show_n = "&show_more=$show_more&show_more_cc=0&". |
312 | "show_more_bcc=$show_more_bcc"; |
313 | $show_more = $show_more_cc; |
314 | break; |
4d0cd98b |
315 | case 'bcc': |
1fca12b5 |
316 | $show = "&show_more=$show_more&show_more_cc=$show_more_cc". |
317 | "&show_more_bcc=1"; |
318 | $show_n = "&show_more=$show_more&show_more_cc=". |
319 | "$show_more_cc&show_more_bcc=0"; |
320 | $show_more = $show_more_bcc; |
321 | break; |
4d0cd98b |
322 | default: |
1fca12b5 |
323 | $break; |
324 | } |
325 | |
326 | while ($i < count($ary)) { |
327 | $ary[$i] = decodeHeader(htmlspecialchars($ary[$i])); |
4d0cd98b |
328 | $url_string .= $ary[$i]; |
329 | if ($string) { |
1fca12b5 |
330 | $string = "$string<BR>$ary[$i]"; |
4d0cd98b |
331 | } else { |
1fca12b5 |
332 | $string = "$ary[$i]"; |
4d0cd98b |
333 | } |
334 | |
335 | $i++; |
336 | if (count($ary) > 1) { |
1fca12b5 |
337 | if ($show_more == false) { |
4d0cd98b |
338 | if ($i == 1) { |
1fca12b5 |
339 | /* From a search... */ |
340 | $string .= ' (<A HREF="' . $base_uri . |
341 | "src/read_body.php?mailbox=$urlMailbox&". |
342 | "passed_id=$passed_id&"; |
343 | if (isset($where) && isset($what)) { |
344 | $string .= 'what=' . urlencode($what). |
345 | "&where=".urlencode($where). |
346 | "$show\">$echo_more</A>)"; |
347 | } else { |
348 | $string .= "sort=$sort&startMessage=". |
349 | "$startMessage"."$show\">$echo_more</A>)"; |
350 | } |
351 | $i = count($ary); |
4d0cd98b |
352 | } |
1fca12b5 |
353 | } else if ($i == 1) { |
4d0cd98b |
354 | /* From a search... */ |
355 | $string .= ' (<A HREF="' . $base_uri . |
1fca12b5 |
356 | "src/read_body.php?mailbox=$urlMailbox&". |
357 | "passed_id=$passed_id&"; |
4d0cd98b |
358 | if (isset($where) && isset($what)) { |
1fca12b5 |
359 | $string .= 'what=' . urlencode($what). |
360 | "&where=".urlencode($where). |
361 | "$show_n\">$echo_less</A>)"; |
4d0cd98b |
362 | } else { |
1fca12b5 |
363 | $string .= "sort=$sort&startMessage=$startMessage". |
364 | "$show_n\">$echo_less</A>)"; |
4d0cd98b |
365 | } |
1fca12b5 |
366 | } |
4d0cd98b |
367 | } |
1fca12b5 |
368 | } |
4d0cd98b |
369 | } |
370 | else { |
1fca12b5 |
371 | $string = ''; |
4d0cd98b |
372 | } |
373 | $url_string = urlencode($url_string); |
374 | $result = array(); |
375 | $result['str'] = $string; |
376 | $result['url_str'] = $url_string; |
377 | return $result; |
378 | } |
379 | |
380 | |
57257333 |
381 | |
382 | /* |
383 | * Main of read_boby.php -------------------------------------------------- |
384 | */ |
385 | |
386 | /* |
387 | Urled vars |
388 | ---------- |
389 | $passed_id |
390 | */ |
a07cd1a4 |
391 | |
1fca12b5 |
392 | if (isset($mailbox)){ |
4366bea4 |
393 | $mailbox = urldecode( $mailbox ); |
394 | } |
1fca12b5 |
395 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, |
396 | $imapPort, 0); |
650be221 |
397 | $read = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true); |
57257333 |
398 | |
a07cd1a4 |
399 | do_hook('html_top'); |
57257333 |
400 | |
401 | /* |
402 | * The following code sets necesarry stuff for the MDN thing |
403 | */ |
1fca12b5 |
404 | if($default_use_mdn && |
405 | ($mdn_user_support = getPref($data_dir, $username, 'mdn_user_support', |
406 | $default_use_mdn))) { |
407 | |
f69feefe |
408 | $supportMDN = ServerMDNSupport($read["PERMANENTFLAGS"]); |
57257333 |
409 | $flags = sqimap_get_flags ($imapConnection, $passed_id); |
650be221 |
410 | $FirstTimeSee = !(in_array( 'Seen', $flags )); |
57257333 |
411 | } |
412 | |
a07cd1a4 |
413 | displayPageHeader($color, $mailbox); |
414 | |
57257333 |
415 | |
416 | /* |
417 | * The following code shows the header of the message and then exit |
418 | */ |
a07cd1a4 |
419 | if (isset($view_hdr)) { |
1fca12b5 |
420 | $read=sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]", |
421 | true, $a, $b); |
422 | |
a07cd1a4 |
423 | echo '<BR>' . |
1fca12b5 |
424 | '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0"'. |
425 | ' ALIGN="CENTER">' . "\n" . |
426 | " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>". |
427 | _("Viewing Full Header") . '</B> - '. |
428 | '<a href="' . $base_uri . 'src/read_body.php?mailbox='. |
429 | urlencode($mailbox); |
a07cd1a4 |
430 | if (isset($where) && isset($what)) { |
431 | // Got here from a search |
1fca12b5 |
432 | echo "&passed_id=$passed_id&where=".urlencode($where). |
433 | "&what=".urlencode($what).'">'; |
a07cd1a4 |
434 | } else { |
1fca12b5 |
435 | echo "&passed_id=$passed_id&startMessage=$startMessage". |
436 | "&show_more=$show_more\">"; |
a07cd1a4 |
437 | } |
1fca12b5 |
438 | echo _("View message") . "</a></b></td></tr></table>\n". |
439 | "<table width='99%' cellpadding='2' cellspacing='0' border='0'". |
440 | "align=center>\n". |
441 | '<tr><td>'; |
442 | |
a07cd1a4 |
443 | $cnum = 0; |
444 | for ($i=1; $i < count($read); $i++) { |
445 | $line = htmlspecialchars($read[$i]); |
446 | if (eregi("^>", $line)) { |
447 | $second[$i] = $line; |
448 | $first[$i] = ' '; |
449 | $cnum++; |
450 | } else if (eregi("^[ |\t]", $line)) { |
451 | $second[$i] = $line; |
452 | $first[$i] = ''; |
453 | } else if (eregi("^([^:]+):(.+)", $line, $regs)) { |
454 | $first[$i] = $regs[1] . ':'; |
455 | $second[$i] = $regs[2]; |
456 | $cnum++; |
0606ca1f |
457 | } else { |
a07cd1a4 |
458 | $second[$i] = trim($line); |
459 | $first[$i] = ''; |
10f0ce72 |
460 | } |
a07cd1a4 |
461 | } |
462 | for ($i=0; $i < count($second); $i = $j) { |
463 | if (isset($first[$i])) { |
464 | $f = $first[$i]; |
0606ca1f |
465 | } |
a07cd1a4 |
466 | if (isset($second[$i])) { |
467 | $s = nl2br($second[$i]); |
468 | } |
469 | $j = $i + 1; |
470 | while (($first[$j] == '') && ($j < count($first))) { |
471 | $s .= ' ' . nl2br($second[$j]); |
472 | $j++; |
0606ca1f |
473 | } |
a07cd1a4 |
474 | parseEmail($s); |
1190197c |
475 | if (isset($f)) { |
7e235a1a |
476 | echo "<nobr><tt><b>$f</b>$s</tt></nobr>"; |
1190197c |
477 | } |
10f0ce72 |
478 | } |
57257333 |
479 | echo "</td></tr></table>\n" . |
1fca12b5 |
480 | '</body></html>'; |
a07cd1a4 |
481 | sqimap_logout($imapConnection); |
482 | exit; |
483 | } |
484 | |
485 | if (isset($msgs)) { |
486 | $currentArrayIndex = $passed_id; |
487 | } else { |
488 | $currentArrayIndex = -1; |
489 | } |
490 | |
491 | for ($i = 0; $i < count($msgs); $i++) { |
492 | if ($msgs[$i]['ID'] == $passed_id) { |
493 | $msgs[$i]['FLAG_SEEN'] = true; |
10f0ce72 |
494 | } |
a07cd1a4 |
495 | } |
496 | |
1fca12b5 |
497 | /** |
498 | * $message contains all information about the message |
499 | * including header and body |
500 | */ |
a07cd1a4 |
501 | $message = sqimap_get_message($imapConnection, $passed_id, $mailbox); |
502 | |
503 | /** translate the subject and mailbox into url-able text **/ |
504 | $url_subj = urlencode(trim($message->header->subject)); |
505 | $urlMailbox = urlencode($mailbox); |
506 | $url_replyto = ''; |
507 | if (isset($message->header->replyto)) { |
508 | $url_replyto = urlencode($message->header->replyto); |
509 | } |
510 | |
1fca12b5 |
511 | $url_replytoall = $url_replyto; |
a07cd1a4 |
512 | |
1fca12b5 |
513 | /** |
514 | * If we are replying to all, then find all other addresses and |
515 | * add them to the list. Remove duplicates. |
516 | * This is somewhat messy, so I'll explain: |
517 | * 1) Take all addresses (from, to, cc) (avoid nasty join errors here) |
518 | */ |
a07cd1a4 |
519 | $url_replytoall_extra_addrs = array_merge( |
1fca12b5 |
520 | array($message->header->from), |
521 | $message->header->to, |
522 | $message->header->cc |
523 | ); |
a07cd1a4 |
524 | |
1fca12b5 |
525 | /** |
526 | * 2) Make one big string out of them |
527 | */ |
a07cd1a4 |
528 | $url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs); |
529 | |
1fca12b5 |
530 | /** |
531 | * 3) Parse that into an array of addresses |
532 | */ |
a07cd1a4 |
533 | $url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs); |
534 | |
1fca12b5 |
535 | /** |
536 | * 4) Make them unique -- weed out duplicates |
537 | * (Coded for PHP 4.0.0) |
538 | */ |
a07cd1a4 |
539 | $url_replytoall_extra_addrs = |
540 | array_keys(array_flip($url_replytoall_extra_addrs)); |
541 | |
1fca12b5 |
542 | /** |
543 | * 5) Remove the addresses we'll be sending the message 'to' |
544 | */ |
a07cd1a4 |
545 | $url_replytoall_avoid_addrs = ''; |
546 | if (isset($message->header->replyto)) { |
547 | $url_replytoall_avoid_addrs = $message->header->replyto; |
548 | } |
549 | |
550 | $url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs); |
551 | foreach ($url_replytoall_avoid_addrs as $addr) { |
552 | RemoveAddress($url_replytoall_extra_addrs, $addr); |
553 | } |
554 | |
1fca12b5 |
555 | /** |
556 | * 6) Remove our identities from the CC list (they still can be in the |
557 | * TO list) only if $include_self_reply_all is turned off |
558 | */ |
a07cd1a4 |
559 | if (!$include_self_reply_all) { |
560 | RemoveAddress($url_replytoall_extra_addrs, |
1fca12b5 |
561 | getPref($data_dir, $username, 'email_address')); |
a07cd1a4 |
562 | $idents = getPref($data_dir, $username, 'identities'); |
563 | if ($idents != '' && $idents > 1) { |
564 | for ($i = 1; $i < $idents; $i ++) { |
1fca12b5 |
565 | $cur_email_address = getPref($data_dir, $username, |
566 | 'email_address' . $i); |
a07cd1a4 |
567 | RemoveAddress($url_replytoall_extra_addrs, $cur_email_address); |
10f0ce72 |
568 | } |
692155b7 |
569 | } |
a07cd1a4 |
570 | } |
1108e8bb |
571 | |
1fca12b5 |
572 | /** |
573 | * 7) Smoosh back into one nice line |
574 | */ |
a07cd1a4 |
575 | $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs); |
692155b7 |
576 | |
1fca12b5 |
577 | /** |
578 | * 8) urlencode() it |
579 | */ |
a07cd1a4 |
580 | $url_replytoallcc = urlencode($url_replytoallcc); |
be69e508 |
581 | |
a07cd1a4 |
582 | $dateString = getLongDateString($message->header->date); |
5bc39e3f |
583 | |
1fca12b5 |
584 | /** |
585 | * What do we reply to -- text only, if possible |
586 | */ |
a07cd1a4 |
587 | $ent_num = findDisplayEntity($message); |
5bc39e3f |
588 | |
a07cd1a4 |
589 | /** TEXT STRINGS DEFINITIONS **/ |
590 | $echo_more = _("more"); |
591 | $echo_less = _("less"); |
592 | |
57257333 |
593 | if (!isset($show_more_cc)) { |
594 | $show_more_cc = FALSE; |
595 | } |
10f0ce72 |
596 | |
4d0cd98b |
597 | if (!isset($show_more_bcc)) { |
598 | $show_more_bcc = FALSE; |
a07cd1a4 |
599 | } |
4d0cd98b |
600 | |
601 | /** FORMAT THE TO STRING **/ |
602 | $to = formatRecipientString($message->header->to, "to"); |
603 | $to_string = $to['str']; |
604 | $url_to_string = $to['url_str']; |
dfd93ee7 |
605 | |
a07cd1a4 |
606 | |
607 | /** FORMAT THE CC STRING **/ |
10f0ce72 |
608 | |
4d0cd98b |
609 | $cc = formatRecipientString($message->header->cc, "cc"); |
610 | $cc_string = $cc['str']; |
611 | $url_cc_string = $cc['url_str']; |
a07cd1a4 |
612 | |
613 | /** FORMAT THE BCC STRING **/ |
10f0ce72 |
614 | |
4d0cd98b |
615 | $bcc = formatRecipientString($message->header->bcc, "bcc"); |
616 | $bcc_string = $bcc['str']; |
617 | $url_bcc_string = $bcc['url_str']; |
10f0ce72 |
618 | |
a07cd1a4 |
619 | if ($default_use_priority) { |
a7818e8e |
620 | $priority_level = substr($message->header->priority,0,1); |
621 | |
622 | switch($priority_level) { |
09278ebf |
623 | /* check for a higher then normal priority. */ |
624 | case '1': |
5be9f195 |
625 | case '2': |
626 | $priority_string = _("High"); |
09278ebf |
627 | break; |
628 | |
629 | /* check for a lower then normal priority. */ |
630 | case '4': |
5be9f195 |
631 | case '5': |
632 | $priority_string = _("Low"); |
09278ebf |
633 | break; |
5be9f195 |
634 | |
09278ebf |
635 | /* check for a normal priority. */ |
5be9f195 |
636 | case '3': |
09278ebf |
637 | default: |
638 | $priority_level = '3'; |
5be9f195 |
639 | $priority_string = _("Normal"); |
09278ebf |
640 | break; |
5be9f195 |
641 | |
10f0ce72 |
642 | } |
a07cd1a4 |
643 | } |
644 | |
645 | /** make sure everything will display in HTML format **/ |
646 | $from_name = decodeHeader(htmlspecialchars($message->header->from)); |
647 | $subject = decodeHeader(htmlspecialchars($message->header->subject)); |
fa77d354 |
648 | $identity = ''; |
649 | $idents = getPref($data_dir, $username, 'identities'); |
650 | if (!empty($idents) && $idents > 1) { |
651 | for ($i = 1; $i < $idents; $i++) { |
1fca12b5 |
652 | $enc_from_name = '"'. |
653 | encodeHeader(getPref($data_dir, |
654 | $username, |
655 | 'full_name' . $i)) . |
656 | '" <' . getPref($data_dir, $username, |
657 | 'email_address' . $i) . '>'; |
658 | if (htmlspecialchars($enc_from_name) == $from_name) { |
fa77d354 |
659 | $identity = $i; |
660 | break; |
661 | } |
662 | } |
663 | } |
a07cd1a4 |
664 | |
665 | do_hook('read_body_top'); |
666 | echo '<BR>' . |
57257333 |
667 | '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . |
668 | '<TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' . |
669 | '<TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' . |
670 | '<TR>' . |
671 | '<TD ALIGN="LEFT" WIDTH="33%">' . |
672 | '<SMALL>' . |
673 | '<A HREF="' . $base_uri . 'src/'; |
a07cd1a4 |
674 | |
675 | if ($where && $what) { |
c52c873e |
676 | if ($pos == '') { |
677 | $pos=0; |
10f0ce72 |
678 | } |
c52c873e |
679 | echo "search.php?where=".urlencode($where)."&pos=$pos&what=".urlencode($what)."&mailbox=$urlMailbox\">"; |
a07cd1a4 |
680 | } else { |
3d570ba0 |
681 | echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">"; |
a07cd1a4 |
682 | } |
683 | echo _("Message List") . |
684 | '</A> | ' . |
3d570ba0 |
685 | '<A HREF="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&"; |
a07cd1a4 |
686 | if ($where && $what) { |
3d570ba0 |
687 | echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">'; |
a07cd1a4 |
688 | } else { |
3d570ba0 |
689 | echo "sort=$sort&startMessage=$startMessage\">"; |
a07cd1a4 |
690 | } |
691 | echo _("Delete") . '</A> '; |
692 | if (($mailbox == $draft_folder) && ($save_as_draft)) { |
d7f8e6e6 |
693 | $comp_uri = $base_uri . "src/compose.php?mailbox=$mailbox&". |
694 | "identity=$identity&send_to=$url_to_string&". |
695 | "send_to_cc=$url_cc_string&send_to_bcc=$url_bcc_string&". |
696 | "subject=$url_subj&mailprio=$priority_level&". |
d748c12b |
697 | "draft_id=$passed_id&ent_num=$ent_num"; |
d7f8e6e6 |
698 | |
9c3e6cd4 |
699 | if ($compose_new_win == '1') { |
d7f8e6e6 |
700 | echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\""; |
701 | } else { |
702 | echo '| <A HREF="' . $comp_uri .'"'; |
9c3e6cd4 |
703 | } |
704 | echo '>'. |
a07cd1a4 |
705 | _("Resume Draft") . '</a>'; |
706 | } |
fa77d354 |
707 | if ($mailbox == $sent_folder) { |
d7f8e6e6 |
708 | $comp_uri = $base_uri . "src/compose.php?mailbox=$mailbox&". |
709 | "identity=$identity&send_to=$url_to_string&". |
710 | "send_to_cc=$url_cc_string&send_to_bcc=$url_bcc_string&". |
711 | "subject=$url_subj&mailprio=$priority_level&". |
712 | "ent_num=$ent_num&passed_id=$passed_id&edit_as_new=1"; |
713 | |
fa77d354 |
714 | if ($compose_new_win == '1') { |
d7f8e6e6 |
715 | echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\""; |
716 | } else { |
717 | echo '| <A HREF="' . $comp_uri .'"'; |
fa77d354 |
718 | } |
719 | echo '>'. |
720 | _("Edit Message as New") . '</a>'; |
721 | } |
a07cd1a4 |
722 | |
723 | echo ' ' . |
57257333 |
724 | '</SMALL>' . |
725 | '</TD>' . |
726 | '<TD WIDTH="33%" ALIGN="CENTER">' . |
727 | '<SMALL>'; |
a07cd1a4 |
728 | |
729 | if ( !($where && $what) ) { |
a07cd1a4 |
730 | if ($currentArrayIndex == -1) { |
731 | echo 'Previous | Next'; |
10f0ce72 |
732 | } else { |
a07cd1a4 |
733 | $prev = findPreviousMessage(); |
734 | $next = findNextMessage(); |
10f0ce72 |
735 | |
a07cd1a4 |
736 | if ($prev != -1) { |
3d570ba0 |
737 | echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | "; |
10f0ce72 |
738 | } else { |
a07cd1a4 |
739 | echo _("Previous") . ' | '; |
10f0ce72 |
740 | } |
7baf86a9 |
741 | |
a07cd1a4 |
742 | if ($next != -1) { |
3d570ba0 |
743 | echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>"; |
a07cd1a4 |
744 | } else { |
745 | echo _("Next"); |
746 | } |
10f0ce72 |
747 | } |
a07cd1a4 |
748 | } |
749 | |
57257333 |
750 | echo '</SMALL>' . |
751 | '</TD><TD WIDTH="33%" ALIGN="RIGHT">' . |
d7f8e6e6 |
752 | '<SMALL>' ; |
753 | |
754 | $comp_uri = $base_uri . "src/compose.php?forward_id=$passed_id&". |
755 | "forward_subj=$url_subj&". |
756 | ($default_use_priority?"mailprio=$priority_level&":''). |
757 | "mailbox=$urlMailbox&ent_num=$ent_num"; |
758 | |
759 | if ($compose_new_win == '1') { |
760 | echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\""; |
761 | } else { |
762 | echo '| <A HREF="' . $comp_uri .'"'; |
763 | } |
764 | |
9c3e6cd4 |
765 | echo '>'. |
a07cd1a4 |
766 | _("Forward") . |
d7f8e6e6 |
767 | '</A> | '; |
768 | |
769 | $comp_uri = $base_uri . "src/compose.php?send_to=$url_replyto&". |
770 | "reply_subj=$url_subj&". |
771 | ($default_use_priority?"mailprio=$priority_level&":''). |
772 | "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num"; |
773 | |
774 | if ($compose_new_win == '1') { |
775 | echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\""; |
776 | } else { |
777 | echo '| <A HREF="' . $comp_uri .'"'; |
778 | } |
779 | |
9c3e6cd4 |
780 | echo '>'. |
a07cd1a4 |
781 | _("Reply") . |
d7f8e6e6 |
782 | '</A> | '; |
783 | |
784 | $comp_uri = $base_uri . "src/compose.php?send_to=$url_replytoall&". |
785 | "send_to_cc=$url_replytoallcc&reply_subj=$url_subj&". |
786 | ($default_use_priority?"mailprio=$priority_level&":''). |
787 | "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num"; |
788 | |
789 | if ($compose_new_win == '1') { |
790 | echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\""; |
791 | } else { |
792 | echo '| <A HREF="' . $comp_uri .'"'; |
793 | } |
794 | |
9c3e6cd4 |
795 | echo '>'. |
a07cd1a4 |
796 | _("Reply All") . |
797 | '</A> ' . |
57257333 |
798 | '</SMALL>' . |
799 | '</TD>' . |
800 | '</TR>' . |
801 | '</TABLE>' . |
802 | '</TD></TR>' . |
3d570ba0 |
803 | '<TR><TD WIDTH="100%">' . |
57257333 |
804 | '<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" . |
805 | '<TR>' . "\n"; |
a07cd1a4 |
806 | |
807 | /** subject **/ |
57257333 |
808 | echo "<TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" . |
a07cd1a4 |
809 | _("Subject:") . |
57257333 |
810 | "</TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" . |
811 | "<B>$subject</B> \n" . |
812 | "</TD>\n" . |
813 | '<TD ROWSPAN="4" width="10%" BGCOLOR="' . $color[0] . |
a07cd1a4 |
814 | '" ALIGN=right VALIGN=top NOWRAP><small>'. |
3d570ba0 |
815 | '<A HREF="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&"; |
a07cd1a4 |
816 | |
817 | /* From a search... */ |
818 | if ($where && $what) { |
3d570ba0 |
819 | echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . |
820 | "&view_hdr=1\">" . _("View Full Header") . "</A>\n"; |
a07cd1a4 |
821 | } else { |
3d570ba0 |
822 | echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" . |
a07cd1a4 |
823 | _("View Full Header") . "</A>\n"; |
824 | } |
825 | |
826 | /* Output the printer friendly link if we are in subtle mode. */ |
827 | if ($pf_subtle_link) { |
828 | echo printer_friendly_link(true); |
829 | } |
830 | |
831 | do_hook("read_body_header_right"); |
57257333 |
832 | echo '</small></TD>' . |
833 | ' </TR>'; |
a07cd1a4 |
834 | |
835 | /** from **/ |
57257333 |
836 | echo '<TR>' . |
837 | '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . |
a07cd1a4 |
838 | _("From:") . |
57257333 |
839 | '</TD><TD BGCOLOR="' . $color[0] . '">' . |
840 | "<B>$from_name</B> \n" . |
841 | '</TD>' . |
842 | '</TR>'; |
a07cd1a4 |
843 | /** date **/ |
57257333 |
844 | echo '<TR>' . "\n" . |
845 | '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" . |
a07cd1a4 |
846 | _("Date:") . |
57257333 |
847 | "</TD><TD BGCOLOR=\"$color[0]\">\n" . |
848 | "<B>$dateString</B> \n" . |
849 | '</TD>' . "\n" . |
850 | '</TR>' . "\n"; |
a07cd1a4 |
851 | |
852 | /** to **/ |
57257333 |
853 | echo "<TR>\n" . |
854 | "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" . |
a07cd1a4 |
855 | _("To:") . |
57257333 |
856 | '</TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" . |
857 | "<B>$to_string</B> \n" . |
858 | '</TD>' . "\n" . |
859 | '</TR>' . "\n"; |
a07cd1a4 |
860 | /** cc **/ |
9e9ad58b |
861 | if (isset($cc_string) && $cc_string <> '') { |
57257333 |
862 | echo '<TR>' . |
863 | "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" . |
864 | 'Cc:' . |
865 | "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" . |
866 | "<B>$cc_string</B> " . |
867 | '</TD>' . |
868 | '</TR>' . "\n"; |
a07cd1a4 |
869 | } |
870 | |
871 | /** bcc **/ |
9e9ad58b |
872 | if (isset($bcc_string) && $bcc_string <> '') { |
57257333 |
873 | echo '<TR>'. |
874 | "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" . |
875 | 'Bcc:' . |
876 | "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" . |
877 | "<B>$bcc_string</B> " . |
878 | '</TD>' . |
879 | '</TR>' . "\n"; |
a07cd1a4 |
880 | } |
9e9ad58b |
881 | if ($default_use_priority && isset($priority_string) && $priority_string <> '' ) { |
882 | echo '<TR>' . |
883 | "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" . |
884 | _("Priority") . ': '. |
885 | "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" . |
886 | "<B>$priority_string</B> " . |
887 | '</TD>' . |
888 | "</TR>" . "\n"; |
a07cd1a4 |
889 | } |
890 | |
891 | if ($show_xmailer_default) { |
451a5790 |
892 | $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]", true, |
a07cd1a4 |
893 | $response, $readmessage); |
894 | $mailer = substr($read[1], strpos($read[1], " ")); |
895 | if (trim($mailer)) { |
57257333 |
896 | echo '<TR>' . |
897 | "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" . |
898 | _("Mailer") . ': '. |
899 | "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" . |
900 | "<B>$mailer</B> " . |
901 | '</TD>' . |
902 | "</TR>" . "\n"; |
10f0ce72 |
903 | } |
a07cd1a4 |
904 | } |
905 | |
906 | /* Output the printer friendly link if we are not in subtle mode. */ |
907 | if (!$pf_subtle_link) { |
908 | echo printer_friendly_link(true); |
909 | } |
910 | |
57257333 |
911 | if ($default_use_mdn) { |
912 | if ($mdn_user_support) { |
913 | |
914 | // debug gives you the capability to remove mdn-flags |
1190197c |
915 | // $MDNDebug = false; |
57257333 |
916 | $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true, |
917 | $response, $readmessage); |
918 | $MDN_to = substr($read[1], strpos($read[1], ' ')); |
919 | $MDN_flag_present = false; |
920 | |
921 | $read = sqimap_run_command ($imapConnection, "FETCH $passed_id FLAGS", true, |
922 | $response, $readmessage); |
77b88425 |
923 | |
924 | $MDN_flag_present = preg_match( '/.*\$MDNSent/i', $read[0]); |
925 | |
57257333 |
926 | if (trim($MDN_to) && |
927 | (!isset( $sendreceipt ) || $sendreceipt == '' ) ) { |
928 | |
929 | if ( $MDN_flag_present && $supportMDN) { |
77b88425 |
930 | $sendreceipt = 'removeMDN'; |
3d570ba0 |
931 | $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\""; |
1190197c |
932 | $sendreceipt=''; |
933 | /* |
650be221 |
934 | if ($MDNDebug ) { |
57257333 |
935 | echo '<TR>' . |
936 | "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" . |
937 | _("Read receipt") . ': ' . |
938 | "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" . |
939 | '<B>' . |
940 | _("send") . |
941 | "</B> <a href=$url>[" . _("Remove MDN flag") . '] </a>' . |
942 | '</TD>' . |
943 | '</TR>' . "\n"; |
944 | } else { |
1190197c |
945 | */ |
946 | echo '<TR>' . |
947 | "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" . |
948 | _("Read receipt") . ': ' . |
949 | "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" . |
950 | '<B>'._("send").'</B>'. |
951 | '</TD>' . |
952 | '</TR>' . "\n"; |
953 | /* |
57257333 |
954 | } |
1190197c |
955 | */ |
57257333 |
956 | |
957 | } // when deleted or draft flag is set don't offer to send a MDN response |
f69feefe |
958 | else if ( ereg('\\Draft',$read[0] || ereg('\\Deleted',$read[0])) ) { |
57257333 |
959 | echo '<TR>' . |
960 | "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" . |
961 | _("Read receipt") . ': '. |
962 | "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" . |
963 | '<B>' . _("requested") . "</B>" . |
964 | '</TD>' . |
965 | '</TR>' . "\n"; |
966 | } |
967 | // if no MDNsupport don't use the annoying popup messages |
968 | else if ( !$FirstTimeSee ) { |
969 | $sendreceipt = 'send'; |
3b1410d9 |
970 | $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\""; |
57257333 |
971 | echo '<TR>' . |
972 | "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" . |
973 | _("Read receipt") . ': ' . |
974 | "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" . |
975 | '<B>' . _("requested") . |
2c64e145 |
976 | "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" . |
57257333 |
977 | '</TD>' . |
978 | '</TR>' . "\n"; |
979 | $sendreceipt=''; |
980 | } |
981 | else { |
982 | $sendreceipt = 'send'; |
3b1410d9 |
983 | $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\""; |
57257333 |
984 | if ($javascript_on) { |
3d570ba0 |
985 | echo "<script language=\"javascript\" type=\"text/javascript\"> \n" . |
57257333 |
986 | '<!-- ' . "\n" . |
987 | " if (window.confirm(\"" . |
988 | _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") . |
989 | "\")) { \n" . |
990 | " window.location=($url); \n" . |
0c896421 |
991 | ' window.location.reload()' . "\n" . |
57257333 |
992 | ' }' . "\n" . |
993 | '// -->' . "\n" . |
994 | '</script>' . "\n"; |
995 | } |
996 | echo '<TR>' . |
997 | "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" . |
998 | _("Read receipt") . ': ' . |
999 | "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" . |
1000 | '<B>' . _("requested") . "  </B><a href=$url>" . '[' . |
1001 | _("Send read receipt now") . '] </a>' ." \n" . |
1002 | '</TD>' . |
1003 | '</TR>' . "\n"; |
1004 | $sendreceipt = ''; |
1005 | } |
1006 | } |
1007 | |
77b88425 |
1008 | if ( !isset( $sendreceipt ) || $sendreceipt == '' ) { |
57257333 |
1009 | } else if ( $sendreceipt == 'send' ) { |
1010 | if ( !$MDN_flag_present) { |
1011 | if (isset($identity) ) { |
77b88425 |
1012 | $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' ); |
1013 | } else { |
1014 | $final_recipient = getPref($data_dir, $username, 'email_address', '' ); |
1015 | } |
57257333 |
1016 | |
1017 | $final_recipient = trim($final_recipient); |
1018 | if ($final_recipient == '' ) { |
77b88425 |
1019 | $final_recipient = getPref($data_dir, $username, 'email_address', '' ); |
57257333 |
1020 | } |
1021 | |
77b88425 |
1022 | if ( SendMDN( $MDN_to, $final_recipient ) > 0 && $supportMDN ) { |
1023 | ToggleMDNflag( true); |
57257333 |
1024 | } |
1025 | } |
1026 | $sendreceipt = 'removeMDN'; |
3d570ba0 |
1027 | $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\""; |
1190197c |
1028 | $sendreceipt=''; |
7e235a1a |
1029 | /* |
650be221 |
1030 | if ($MDNDebug && $supportMDN) { |
57257333 |
1031 | echo " <TR>\n" . |
1032 | " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" . |
1033 | " "._("Read receipt").": \n". |
1034 | " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" . |
1035 | ' <B>'._("send").'</B>'." <a href=$url>" . '[' . _("Remove MDN flag") . '] </a>' . "\n" . |
1036 | ' </TD>' . "\n" . |
1037 | ' </TR>' . "\n"; |
1038 | } else { |
1190197c |
1039 | */ |
57257333 |
1040 | echo " <TR>\n" . |
1041 | " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" . |
1042 | " "._("Read receipt").": \n". |
1043 | " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" . |
1044 | ' <B>'._("send").'</B>'. "\n" . |
1045 | ' </TD>' . "\n" . |
1046 | ' </TR>' . "\n"; |
1190197c |
1047 | /* |
57257333 |
1048 | } |
1190197c |
1049 | */ |
57257333 |
1050 | } |
1051 | elseif ($sendreceipt == 'removeMDN' ) { |
1052 | ToggleMDNflag ( false ); |
1053 | |
1054 | $sendreceipt = 'send'; |
3d570ba0 |
1055 | $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\""; |
57257333 |
1056 | echo '<TR>'. |
1057 | "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" . |
1058 | _("Read receipt") . ': ' . |
1059 | "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" . |
1060 | '<B>' . _("requested") . |
1061 | "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" . |
1062 | '</TD>' . |
1063 | '</TR>' . "\n"; |
1064 | $sendreceipt = ''; |
1065 | |
1066 | } |
1067 | } |
1068 | } |
1069 | |
5be9f195 |
1070 | do_hook('read_body_header'); |
57257333 |
1071 | |
a07cd1a4 |
1072 | echo '</TABLE>' . |
1073 | ' </TD></TR>' . |
1074 | '</TABLE>'; |
1075 | flush(); |
5be9f195 |
1076 | |
a07cd1a4 |
1077 | echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" . |
1078 | " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" . |
1079 | '<BR>'. |
1080 | formatBody($imapConnection, $message, $color, $wrap_at). |
3d570ba0 |
1081 | '</TD></TR></TABLE>' . |
a07cd1a4 |
1082 | '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" . |
1083 | " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>" . |
1084 | '</TABLE>' . "\n"; |
1085 | |
1086 | /* show attached images inline -- if pref'fed so */ |
5be9f195 |
1087 | if (($attachment_common_show_images) && |
a07cd1a4 |
1088 | is_array($attachment_common_show_images_list)) { |
5be9f195 |
1089 | |
a07cd1a4 |
1090 | foreach ($attachment_common_show_images_list as $img) { |
5be9f195 |
1091 | $imgurl = '../src/download.php' . |
57257333 |
1092 | '?' . |
cd7b8833 |
1093 | 'passed_id=' . urlencode($img['passed_id']) . |
3d570ba0 |
1094 | '&mailbox=' . urlencode($mailbox) . |
1095 | '&passed_ent_id=' . urlencode($img['ent_id']) . |
1096 | '&absolute_dl=true'; |
5be9f195 |
1097 | |
a07cd1a4 |
1098 | echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" . |
57257333 |
1099 | '<TR>' . |
1100 | '<TD>' . |
1101 | "<img src=\"$imgurl\">\n" . |
1102 | "</TD>\n" . |
1103 | "</TR>\n" . |
a07cd1a4 |
1104 | "</TABLE>\n"; |
5be9f195 |
1105 | |
10f0ce72 |
1106 | } |
a07cd1a4 |
1107 | } |
1108 | |
5be9f195 |
1109 | |
a07cd1a4 |
1110 | do_hook('read_body_bottom'); |
1111 | do_hook('html_bottom'); |
1112 | sqimap_logout($imapConnection); |
1113 | ?> |
1114 | </body> |
a7818e8e |
1115 | </html> |