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 | $sg = $set?'+':'-'; |
265 | $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)'; |
0892e427 |
266 | $read = sqimap_run_command ($imapConnection, $cmd, true, $response, |
267 | $readmessage); |
57257333 |
268 | } |
269 | |
270 | function ClearAttachments() { |
271 | global $username, $attachments, $attachment_dir; |
272 | |
273 | $hashed_attachment_dir = getHashedDir($username, $attachment_dir); |
274 | |
aa866a40 |
275 | $rem_attachments = array(); |
57257333 |
276 | foreach ($attachments as $info) { |
b2c19764 |
277 | if ($info['session'] == -1) { |
aa866a40 |
278 | $attached_file = "$hashed_attachment_dir/$info[localfilename]"; |
279 | if (file_exists($attached_file)) { |
280 | unlink($attached_file); |
281 | } |
282 | } else { |
283 | $rem_attachments[] = $info; |
284 | } |
285 | } |
68c3b52a |
286 | $attachments = $rem_attachments; |
57257333 |
287 | } |
288 | |
4d0cd98b |
289 | function formatRecipientString($recipients, $item ) { |
1fca12b5 |
290 | global $base_uri, $passed_id, $urlMailbox, $startMessage, $show_more_cc, |
291 | $echo_more, $echo_less, $show_more, $show_more_bcc, $sort; |
4d0cd98b |
292 | |
293 | $i = 0; |
294 | $url_string = ''; |
295 | |
296 | if (isset ($recipients[0]) && trim($recipients[0])) { |
1fca12b5 |
297 | $string = ''; |
4d0cd98b |
298 | $ary = $recipients; |
299 | |
1fca12b5 |
300 | switch ($item) { |
4d0cd98b |
301 | case 'to': |
1fca12b5 |
302 | $show = "&show_more=1&show_more_cc=$show_more_cc&". |
303 | "show_more_bcc=$show_more_bcc"; |
304 | $show_n = "&show_more=0&show_more_cc=$show_more_cc&". |
305 | "show_more_bcc=$show_more_bcc"; |
306 | break; |
4d0cd98b |
307 | case 'cc': |
1fca12b5 |
308 | $show = "&show_more=$show_more&show_more_cc=1&". |
309 | "show_more_bcc=$show_more_bcc"; |
310 | $show_n = "&show_more=$show_more&show_more_cc=0&". |
311 | "show_more_bcc=$show_more_bcc"; |
312 | $show_more = $show_more_cc; |
313 | break; |
4d0cd98b |
314 | case 'bcc': |
1fca12b5 |
315 | $show = "&show_more=$show_more&show_more_cc=$show_more_cc". |
316 | "&show_more_bcc=1"; |
317 | $show_n = "&show_more=$show_more&show_more_cc=". |
318 | "$show_more_cc&show_more_bcc=0"; |
319 | $show_more = $show_more_bcc; |
320 | break; |
4d0cd98b |
321 | default: |
1fca12b5 |
322 | $break; |
323 | } |
324 | |
325 | while ($i < count($ary)) { |
326 | $ary[$i] = decodeHeader(htmlspecialchars($ary[$i])); |
4d0cd98b |
327 | $url_string .= $ary[$i]; |
328 | if ($string) { |
1fca12b5 |
329 | $string = "$string<BR>$ary[$i]"; |
4d0cd98b |
330 | } else { |
1fca12b5 |
331 | $string = "$ary[$i]"; |
4d0cd98b |
332 | } |
333 | |
334 | $i++; |
335 | if (count($ary) > 1) { |
1fca12b5 |
336 | if ($show_more == false) { |
4d0cd98b |
337 | if ($i == 1) { |
1fca12b5 |
338 | /* From a search... */ |
339 | $string .= ' (<A HREF="' . $base_uri . |
340 | "src/read_body.php?mailbox=$urlMailbox&". |
341 | "passed_id=$passed_id&"; |
342 | if (isset($where) && isset($what)) { |
343 | $string .= 'what=' . urlencode($what). |
344 | "&where=".urlencode($where). |
345 | "$show\">$echo_more</A>)"; |
346 | } else { |
347 | $string .= "sort=$sort&startMessage=". |
348 | "$startMessage"."$show\">$echo_more</A>)"; |
349 | } |
350 | $i = count($ary); |
4d0cd98b |
351 | } |
1fca12b5 |
352 | } else if ($i == 1) { |
4d0cd98b |
353 | /* From a search... */ |
354 | $string .= ' (<A HREF="' . $base_uri . |
1fca12b5 |
355 | "src/read_body.php?mailbox=$urlMailbox&". |
356 | "passed_id=$passed_id&"; |
4d0cd98b |
357 | if (isset($where) && isset($what)) { |
1fca12b5 |
358 | $string .= 'what=' . urlencode($what). |
359 | "&where=".urlencode($where). |
360 | "$show_n\">$echo_less</A>)"; |
4d0cd98b |
361 | } else { |
1fca12b5 |
362 | $string .= "sort=$sort&startMessage=$startMessage". |
363 | "$show_n\">$echo_less</A>)"; |
4d0cd98b |
364 | } |
1fca12b5 |
365 | } |
4d0cd98b |
366 | } |
1fca12b5 |
367 | } |
4d0cd98b |
368 | } |
369 | else { |
1fca12b5 |
370 | $string = ''; |
4d0cd98b |
371 | } |
372 | $url_string = urlencode($url_string); |
373 | $result = array(); |
374 | $result['str'] = $string; |
375 | $result['url_str'] = $url_string; |
376 | return $result; |
377 | } |
378 | |
379 | |
57257333 |
380 | |
381 | /* |
382 | * Main of read_boby.php -------------------------------------------------- |
383 | */ |
384 | |
385 | /* |
386 | Urled vars |
387 | ---------- |
388 | $passed_id |
389 | */ |
a07cd1a4 |
390 | |
1fca12b5 |
391 | if (isset($mailbox)){ |
4366bea4 |
392 | $mailbox = urldecode( $mailbox ); |
393 | } |
1fca12b5 |
394 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, |
395 | $imapPort, 0); |
650be221 |
396 | $read = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true); |
57257333 |
397 | |
a07cd1a4 |
398 | do_hook('html_top'); |
57257333 |
399 | |
400 | /* |
401 | * The following code sets necesarry stuff for the MDN thing |
402 | */ |
1fca12b5 |
403 | if($default_use_mdn && |
404 | ($mdn_user_support = getPref($data_dir, $username, 'mdn_user_support', |
405 | $default_use_mdn))) { |
406 | |
f69feefe |
407 | $supportMDN = ServerMDNSupport($read["PERMANENTFLAGS"]); |
57257333 |
408 | $flags = sqimap_get_flags ($imapConnection, $passed_id); |
650be221 |
409 | $FirstTimeSee = !(in_array( 'Seen', $flags )); |
57257333 |
410 | } |
411 | |
a07cd1a4 |
412 | displayPageHeader($color, $mailbox); |
413 | |
57257333 |
414 | |
415 | /* |
416 | * The following code shows the header of the message and then exit |
417 | */ |
a07cd1a4 |
418 | if (isset($view_hdr)) { |
1fca12b5 |
419 | $read=sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]", |
420 | true, $a, $b); |
421 | |
a07cd1a4 |
422 | echo '<BR>' . |
1fca12b5 |
423 | '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0"'. |
424 | ' ALIGN="CENTER">' . "\n" . |
425 | " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>". |
426 | _("Viewing Full Header") . '</B> - '. |
427 | '<a href="' . $base_uri . 'src/read_body.php?mailbox='. |
428 | urlencode($mailbox); |
a07cd1a4 |
429 | if (isset($where) && isset($what)) { |
430 | // Got here from a search |
1fca12b5 |
431 | echo "&passed_id=$passed_id&where=".urlencode($where). |
432 | "&what=".urlencode($what).'">'; |
a07cd1a4 |
433 | } else { |
1fca12b5 |
434 | echo "&passed_id=$passed_id&startMessage=$startMessage". |
435 | "&show_more=$show_more\">"; |
a07cd1a4 |
436 | } |
1fca12b5 |
437 | echo _("View message") . "</a></b></td></tr></table>\n". |
438 | "<table width='99%' cellpadding='2' cellspacing='0' border='0'". |
439 | "align=center>\n". |
440 | '<tr><td>'; |
441 | |
a07cd1a4 |
442 | $cnum = 0; |
443 | for ($i=1; $i < count($read); $i++) { |
444 | $line = htmlspecialchars($read[$i]); |
445 | if (eregi("^>", $line)) { |
446 | $second[$i] = $line; |
447 | $first[$i] = ' '; |
448 | $cnum++; |
449 | } else if (eregi("^[ |\t]", $line)) { |
450 | $second[$i] = $line; |
451 | $first[$i] = ''; |
452 | } else if (eregi("^([^:]+):(.+)", $line, $regs)) { |
453 | $first[$i] = $regs[1] . ':'; |
454 | $second[$i] = $regs[2]; |
455 | $cnum++; |
0606ca1f |
456 | } else { |
a07cd1a4 |
457 | $second[$i] = trim($line); |
458 | $first[$i] = ''; |
10f0ce72 |
459 | } |
a07cd1a4 |
460 | } |
461 | for ($i=0; $i < count($second); $i = $j) { |
462 | if (isset($first[$i])) { |
463 | $f = $first[$i]; |
0606ca1f |
464 | } |
a07cd1a4 |
465 | if (isset($second[$i])) { |
466 | $s = nl2br($second[$i]); |
467 | } |
468 | $j = $i + 1; |
469 | while (($first[$j] == '') && ($j < count($first))) { |
470 | $s .= ' ' . nl2br($second[$j]); |
471 | $j++; |
0606ca1f |
472 | } |
a07cd1a4 |
473 | parseEmail($s); |
1190197c |
474 | if (isset($f)) { |
7e235a1a |
475 | echo "<nobr><tt><b>$f</b>$s</tt></nobr>"; |
1190197c |
476 | } |
10f0ce72 |
477 | } |
57257333 |
478 | echo "</td></tr></table>\n" . |
1fca12b5 |
479 | '</body></html>'; |
a07cd1a4 |
480 | sqimap_logout($imapConnection); |
481 | exit; |
482 | } |
483 | |
484 | if (isset($msgs)) { |
485 | $currentArrayIndex = $passed_id; |
486 | } else { |
487 | $currentArrayIndex = -1; |
488 | } |
489 | |
490 | for ($i = 0; $i < count($msgs); $i++) { |
491 | if ($msgs[$i]['ID'] == $passed_id) { |
492 | $msgs[$i]['FLAG_SEEN'] = true; |
10f0ce72 |
493 | } |
a07cd1a4 |
494 | } |
495 | |
1fca12b5 |
496 | /** |
497 | * $message contains all information about the message |
498 | * including header and body |
499 | */ |
a07cd1a4 |
500 | $message = sqimap_get_message($imapConnection, $passed_id, $mailbox); |
501 | |
502 | /** translate the subject and mailbox into url-able text **/ |
503 | $url_subj = urlencode(trim($message->header->subject)); |
504 | $urlMailbox = urlencode($mailbox); |
505 | $url_replyto = ''; |
506 | if (isset($message->header->replyto)) { |
507 | $url_replyto = urlencode($message->header->replyto); |
508 | } |
509 | |
1fca12b5 |
510 | $url_replytoall = $url_replyto; |
a07cd1a4 |
511 | |
1fca12b5 |
512 | /** |
513 | * If we are replying to all, then find all other addresses and |
514 | * add them to the list. Remove duplicates. |
515 | * This is somewhat messy, so I'll explain: |
516 | * 1) Take all addresses (from, to, cc) (avoid nasty join errors here) |
517 | */ |
a07cd1a4 |
518 | $url_replytoall_extra_addrs = array_merge( |
1fca12b5 |
519 | array($message->header->from), |
520 | $message->header->to, |
521 | $message->header->cc |
522 | ); |
a07cd1a4 |
523 | |
1fca12b5 |
524 | /** |
525 | * 2) Make one big string out of them |
526 | */ |
a07cd1a4 |
527 | $url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs); |
528 | |
1fca12b5 |
529 | /** |
530 | * 3) Parse that into an array of addresses |
531 | */ |
a07cd1a4 |
532 | $url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs); |
533 | |
1fca12b5 |
534 | /** |
535 | * 4) Make them unique -- weed out duplicates |
536 | * (Coded for PHP 4.0.0) |
537 | */ |
a07cd1a4 |
538 | $url_replytoall_extra_addrs = |
539 | array_keys(array_flip($url_replytoall_extra_addrs)); |
540 | |
1fca12b5 |
541 | /** |
542 | * 5) Remove the addresses we'll be sending the message 'to' |
543 | */ |
a07cd1a4 |
544 | $url_replytoall_avoid_addrs = ''; |
545 | if (isset($message->header->replyto)) { |
546 | $url_replytoall_avoid_addrs = $message->header->replyto; |
547 | } |
548 | |
549 | $url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs); |
550 | foreach ($url_replytoall_avoid_addrs as $addr) { |
551 | RemoveAddress($url_replytoall_extra_addrs, $addr); |
552 | } |
553 | |
1fca12b5 |
554 | /** |
555 | * 6) Remove our identities from the CC list (they still can be in the |
556 | * TO list) only if $include_self_reply_all is turned off |
557 | */ |
a07cd1a4 |
558 | if (!$include_self_reply_all) { |
559 | RemoveAddress($url_replytoall_extra_addrs, |
1fca12b5 |
560 | getPref($data_dir, $username, 'email_address')); |
a07cd1a4 |
561 | $idents = getPref($data_dir, $username, 'identities'); |
562 | if ($idents != '' && $idents > 1) { |
563 | for ($i = 1; $i < $idents; $i ++) { |
1fca12b5 |
564 | $cur_email_address = getPref($data_dir, $username, |
565 | 'email_address' . $i); |
a07cd1a4 |
566 | RemoveAddress($url_replytoall_extra_addrs, $cur_email_address); |
10f0ce72 |
567 | } |
692155b7 |
568 | } |
a07cd1a4 |
569 | } |
1108e8bb |
570 | |
1fca12b5 |
571 | /** |
572 | * 7) Smoosh back into one nice line |
573 | */ |
a07cd1a4 |
574 | $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs); |
692155b7 |
575 | |
1fca12b5 |
576 | /** |
577 | * 8) urlencode() it |
578 | */ |
a07cd1a4 |
579 | $url_replytoallcc = urlencode($url_replytoallcc); |
be69e508 |
580 | |
a07cd1a4 |
581 | $dateString = getLongDateString($message->header->date); |
5bc39e3f |
582 | |
1fca12b5 |
583 | /** |
584 | * What do we reply to -- text only, if possible |
585 | */ |
e5fdc771 |
586 | |
587 | $body = ''; |
588 | |
589 | /* experimental */ |
590 | /* |
591 | if ($message->header->type0 == 'multipart' && $message->header->type1 == 'digest') { |
592 | listEntities($message); |
593 | for ($i = 0; $i < count($message->entities); $i++) { |
594 | |
595 | $msg = $message->entities[$i]; |
596 | $body .= $msg->header->type0 .'/'.$msg->header->type1 .'<BR>'; |
597 | |
598 | $msg->header->type0 = 'message'; |
599 | $msg->header->type1 = 'rfc822'; |
600 | $ent_ar = findDisplayEntity($msg, false); |
601 | for ($i = 0; $i < count($ent_ar); $i++) { |
602 | $body .= formatBody($imapConnection, $msg, $color, $wrap_at, $ent_ar[$i]); |
603 | } |
604 | $i++; |
605 | } |
606 | } else { |
607 | */ |
608 | $ent_ar = findDisplayEntity($message, false); |
609 | $i = 0; |
610 | for ($i = 0; $i < count($ent_ar); $i++) { |
611 | $body .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i]); |
612 | } |
613 | /* |
614 | } |
615 | */ |
616 | |
32c661f4 |
617 | /* first step in displaying multiple entities */ |
e5fdc771 |
618 | $ent_ar = findDisplayEntity($message,true); |
5bc39e3f |
619 | |
f557f53e |
620 | $ent_num = $ent_ar[0]; |
e5fdc771 |
621 | for ($i = 1 ; $i < count($ent_ar); $i++) { |
f557f53e |
622 | $ent_num .= '_'.$ent_ar[$i]; |
e5fdc771 |
623 | } |
a07cd1a4 |
624 | /** TEXT STRINGS DEFINITIONS **/ |
625 | $echo_more = _("more"); |
626 | $echo_less = _("less"); |
627 | |
57257333 |
628 | if (!isset($show_more_cc)) { |
629 | $show_more_cc = FALSE; |
630 | } |
10f0ce72 |
631 | |
4d0cd98b |
632 | if (!isset($show_more_bcc)) { |
633 | $show_more_bcc = FALSE; |
a07cd1a4 |
634 | } |
4d0cd98b |
635 | |
636 | /** FORMAT THE TO STRING **/ |
637 | $to = formatRecipientString($message->header->to, "to"); |
638 | $to_string = $to['str']; |
639 | $url_to_string = $to['url_str']; |
dfd93ee7 |
640 | |
a07cd1a4 |
641 | |
642 | /** FORMAT THE CC STRING **/ |
10f0ce72 |
643 | |
4d0cd98b |
644 | $cc = formatRecipientString($message->header->cc, "cc"); |
645 | $cc_string = $cc['str']; |
646 | $url_cc_string = $cc['url_str']; |
a07cd1a4 |
647 | |
648 | /** FORMAT THE BCC STRING **/ |
10f0ce72 |
649 | |
4d0cd98b |
650 | $bcc = formatRecipientString($message->header->bcc, "bcc"); |
651 | $bcc_string = $bcc['str']; |
652 | $url_bcc_string = $bcc['url_str']; |
10f0ce72 |
653 | |
a07cd1a4 |
654 | if ($default_use_priority) { |
a7818e8e |
655 | $priority_level = substr($message->header->priority,0,1); |
656 | |
657 | switch($priority_level) { |
09278ebf |
658 | /* check for a higher then normal priority. */ |
659 | case '1': |
5be9f195 |
660 | case '2': |
661 | $priority_string = _("High"); |
09278ebf |
662 | break; |
663 | |
664 | /* check for a lower then normal priority. */ |
665 | case '4': |
5be9f195 |
666 | case '5': |
667 | $priority_string = _("Low"); |
09278ebf |
668 | break; |
5be9f195 |
669 | |
09278ebf |
670 | /* check for a normal priority. */ |
5be9f195 |
671 | case '3': |
09278ebf |
672 | default: |
673 | $priority_level = '3'; |
5be9f195 |
674 | $priority_string = _("Normal"); |
09278ebf |
675 | break; |
5be9f195 |
676 | |
10f0ce72 |
677 | } |
a07cd1a4 |
678 | } |
679 | |
680 | /** make sure everything will display in HTML format **/ |
681 | $from_name = decodeHeader(htmlspecialchars($message->header->from)); |
682 | $subject = decodeHeader(htmlspecialchars($message->header->subject)); |
fa77d354 |
683 | $identity = ''; |
684 | $idents = getPref($data_dir, $username, 'identities'); |
685 | if (!empty($idents) && $idents > 1) { |
686 | for ($i = 1; $i < $idents; $i++) { |
1fca12b5 |
687 | $enc_from_name = '"'. |
688 | encodeHeader(getPref($data_dir, |
689 | $username, |
690 | 'full_name' . $i)) . |
691 | '" <' . getPref($data_dir, $username, |
692 | 'email_address' . $i) . '>'; |
693 | if (htmlspecialchars($enc_from_name) == $from_name) { |
fa77d354 |
694 | $identity = $i; |
695 | break; |
696 | } |
697 | } |
698 | } |
a07cd1a4 |
699 | |
700 | do_hook('read_body_top'); |
701 | echo '<BR>' . |
57257333 |
702 | '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . |
703 | '<TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' . |
704 | '<TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' . |
705 | '<TR>' . |
706 | '<TD ALIGN="LEFT" WIDTH="33%">' . |
707 | '<SMALL>' . |
708 | '<A HREF="' . $base_uri . 'src/'; |
a07cd1a4 |
709 | |
710 | if ($where && $what) { |
c52c873e |
711 | if ($pos == '') { |
712 | $pos=0; |
10f0ce72 |
713 | } |
c52c873e |
714 | echo "search.php?where=".urlencode($where)."&pos=$pos&what=".urlencode($what)."&mailbox=$urlMailbox\">"; |
a07cd1a4 |
715 | } else { |
3d570ba0 |
716 | echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">"; |
a07cd1a4 |
717 | } |
718 | echo _("Message List") . |
719 | '</A> | ' . |
3d570ba0 |
720 | '<A HREF="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&"; |
a07cd1a4 |
721 | if ($where && $what) { |
3d570ba0 |
722 | echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">'; |
a07cd1a4 |
723 | } else { |
3d570ba0 |
724 | echo "sort=$sort&startMessage=$startMessage\">"; |
a07cd1a4 |
725 | } |
726 | echo _("Delete") . '</A> '; |
727 | if (($mailbox == $draft_folder) && ($save_as_draft)) { |
d7f8e6e6 |
728 | $comp_uri = $base_uri . "src/compose.php?mailbox=$mailbox&". |
729 | "identity=$identity&send_to=$url_to_string&". |
730 | "send_to_cc=$url_cc_string&send_to_bcc=$url_bcc_string&". |
731 | "subject=$url_subj&mailprio=$priority_level&". |
d748c12b |
732 | "draft_id=$passed_id&ent_num=$ent_num"; |
d7f8e6e6 |
733 | |
9c3e6cd4 |
734 | if ($compose_new_win == '1') { |
d7f8e6e6 |
735 | echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\""; |
736 | } else { |
737 | echo '| <A HREF="' . $comp_uri .'"'; |
9c3e6cd4 |
738 | } |
739 | echo '>'. |
a07cd1a4 |
740 | _("Resume Draft") . '</a>'; |
741 | } |
fa77d354 |
742 | if ($mailbox == $sent_folder) { |
d7f8e6e6 |
743 | $comp_uri = $base_uri . "src/compose.php?mailbox=$mailbox&". |
744 | "identity=$identity&send_to=$url_to_string&". |
745 | "send_to_cc=$url_cc_string&send_to_bcc=$url_bcc_string&". |
746 | "subject=$url_subj&mailprio=$priority_level&". |
747 | "ent_num=$ent_num&passed_id=$passed_id&edit_as_new=1"; |
748 | |
fa77d354 |
749 | if ($compose_new_win == '1') { |
d7f8e6e6 |
750 | echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\""; |
751 | } else { |
752 | echo '| <A HREF="' . $comp_uri .'"'; |
fa77d354 |
753 | } |
754 | echo '>'. |
755 | _("Edit Message as New") . '</a>'; |
756 | } |
a07cd1a4 |
757 | |
758 | echo ' ' . |
57257333 |
759 | '</SMALL>' . |
760 | '</TD>' . |
761 | '<TD WIDTH="33%" ALIGN="CENTER">' . |
762 | '<SMALL>'; |
a07cd1a4 |
763 | |
764 | if ( !($where && $what) ) { |
a07cd1a4 |
765 | if ($currentArrayIndex == -1) { |
766 | echo 'Previous | Next'; |
10f0ce72 |
767 | } else { |
a07cd1a4 |
768 | $prev = findPreviousMessage(); |
769 | $next = findNextMessage(); |
10f0ce72 |
770 | |
a07cd1a4 |
771 | if ($prev != -1) { |
3d570ba0 |
772 | echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | "; |
10f0ce72 |
773 | } else { |
a07cd1a4 |
774 | echo _("Previous") . ' | '; |
10f0ce72 |
775 | } |
7baf86a9 |
776 | |
a07cd1a4 |
777 | if ($next != -1) { |
3d570ba0 |
778 | echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>"; |
a07cd1a4 |
779 | } else { |
780 | echo _("Next"); |
781 | } |
10f0ce72 |
782 | } |
a07cd1a4 |
783 | } |
784 | |
57257333 |
785 | echo '</SMALL>' . |
786 | '</TD><TD WIDTH="33%" ALIGN="RIGHT">' . |
d7f8e6e6 |
787 | '<SMALL>' ; |
788 | |
789 | $comp_uri = $base_uri . "src/compose.php?forward_id=$passed_id&". |
790 | "forward_subj=$url_subj&". |
791 | ($default_use_priority?"mailprio=$priority_level&":''). |
792 | "mailbox=$urlMailbox&ent_num=$ent_num"; |
793 | |
794 | if ($compose_new_win == '1') { |
795 | echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\""; |
796 | } else { |
797 | echo '| <A HREF="' . $comp_uri .'"'; |
798 | } |
799 | |
9c3e6cd4 |
800 | echo '>'. |
a07cd1a4 |
801 | _("Forward") . |
d7f8e6e6 |
802 | '</A> | '; |
803 | |
804 | $comp_uri = $base_uri . "src/compose.php?send_to=$url_replyto&". |
805 | "reply_subj=$url_subj&". |
806 | ($default_use_priority?"mailprio=$priority_level&":''). |
807 | "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num"; |
808 | |
809 | if ($compose_new_win == '1') { |
810 | echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\""; |
811 | } else { |
812 | echo '| <A HREF="' . $comp_uri .'"'; |
813 | } |
814 | |
9c3e6cd4 |
815 | echo '>'. |
a07cd1a4 |
816 | _("Reply") . |
d7f8e6e6 |
817 | '</A> | '; |
818 | |
819 | $comp_uri = $base_uri . "src/compose.php?send_to=$url_replytoall&". |
820 | "send_to_cc=$url_replytoallcc&reply_subj=$url_subj&". |
821 | ($default_use_priority?"mailprio=$priority_level&":''). |
822 | "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num"; |
823 | |
824 | if ($compose_new_win == '1') { |
825 | echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\""; |
826 | } else { |
827 | echo '| <A HREF="' . $comp_uri .'"'; |
828 | } |
829 | |
9c3e6cd4 |
830 | echo '>'. |
a07cd1a4 |
831 | _("Reply All") . |
832 | '</A> ' . |
57257333 |
833 | '</SMALL>' . |
834 | '</TD>' . |
835 | '</TR>' . |
836 | '</TABLE>' . |
837 | '</TD></TR>' . |
3d570ba0 |
838 | '<TR><TD WIDTH="100%">' . |
57257333 |
839 | '<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" . |
840 | '<TR>' . "\n"; |
a07cd1a4 |
841 | |
842 | /** subject **/ |
57257333 |
843 | echo "<TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" . |
a07cd1a4 |
844 | _("Subject:") . |
57257333 |
845 | "</TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" . |
846 | "<B>$subject</B> \n" . |
847 | "</TD>\n" . |
848 | '<TD ROWSPAN="4" width="10%" BGCOLOR="' . $color[0] . |
a07cd1a4 |
849 | '" ALIGN=right VALIGN=top NOWRAP><small>'. |
3d570ba0 |
850 | '<A HREF="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&"; |
a07cd1a4 |
851 | |
852 | /* From a search... */ |
853 | if ($where && $what) { |
3d570ba0 |
854 | echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . |
855 | "&view_hdr=1\">" . _("View Full Header") . "</A>\n"; |
a07cd1a4 |
856 | } else { |
3d570ba0 |
857 | echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" . |
a07cd1a4 |
858 | _("View Full Header") . "</A>\n"; |
859 | } |
860 | |
861 | /* Output the printer friendly link if we are in subtle mode. */ |
862 | if ($pf_subtle_link) { |
863 | echo printer_friendly_link(true); |
864 | } |
865 | |
866 | do_hook("read_body_header_right"); |
57257333 |
867 | echo '</small></TD>' . |
868 | ' </TR>'; |
a07cd1a4 |
869 | |
870 | /** from **/ |
57257333 |
871 | echo '<TR>' . |
872 | '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . |
a07cd1a4 |
873 | _("From:") . |
57257333 |
874 | '</TD><TD BGCOLOR="' . $color[0] . '">' . |
47268e2c |
875 | "<B>$from_name</B> \n"; |
876 | do_hook("read_body_after_from"); |
877 | echo '</TD>' . |
57257333 |
878 | '</TR>'; |
a07cd1a4 |
879 | /** date **/ |
57257333 |
880 | echo '<TR>' . "\n" . |
881 | '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" . |
a07cd1a4 |
882 | _("Date:") . |
57257333 |
883 | "</TD><TD BGCOLOR=\"$color[0]\">\n" . |
884 | "<B>$dateString</B> \n" . |
885 | '</TD>' . "\n" . |
886 | '</TR>' . "\n"; |
a07cd1a4 |
887 | |
888 | /** to **/ |
57257333 |
889 | echo "<TR>\n" . |
890 | "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" . |
a07cd1a4 |
891 | _("To:") . |
57257333 |
892 | '</TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" . |
893 | "<B>$to_string</B> \n" . |
894 | '</TD>' . "\n" . |
895 | '</TR>' . "\n"; |
a07cd1a4 |
896 | /** cc **/ |
9e9ad58b |
897 | if (isset($cc_string) && $cc_string <> '') { |
57257333 |
898 | echo '<TR>' . |
899 | "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" . |
900 | 'Cc:' . |
901 | "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" . |
902 | "<B>$cc_string</B> " . |
903 | '</TD>' . |
904 | '</TR>' . "\n"; |
a07cd1a4 |
905 | } |
906 | |
907 | /** bcc **/ |
9e9ad58b |
908 | if (isset($bcc_string) && $bcc_string <> '') { |
57257333 |
909 | echo '<TR>'. |
910 | "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" . |
911 | 'Bcc:' . |
912 | "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" . |
913 | "<B>$bcc_string</B> " . |
914 | '</TD>' . |
915 | '</TR>' . "\n"; |
a07cd1a4 |
916 | } |
9e9ad58b |
917 | if ($default_use_priority && isset($priority_string) && $priority_string <> '' ) { |
918 | echo '<TR>' . |
919 | "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" . |
920 | _("Priority") . ': '. |
921 | "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" . |
922 | "<B>$priority_string</B> " . |
923 | '</TD>' . |
924 | "</TR>" . "\n"; |
a07cd1a4 |
925 | } |
926 | |
927 | if ($show_xmailer_default) { |
451a5790 |
928 | $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]", true, |
a07cd1a4 |
929 | $response, $readmessage); |
930 | $mailer = substr($read[1], strpos($read[1], " ")); |
931 | if (trim($mailer)) { |
57257333 |
932 | echo '<TR>' . |
933 | "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" . |
934 | _("Mailer") . ': '. |
935 | "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" . |
936 | "<B>$mailer</B> " . |
937 | '</TD>' . |
938 | "</TR>" . "\n"; |
10f0ce72 |
939 | } |
a07cd1a4 |
940 | } |
941 | |
942 | /* Output the printer friendly link if we are not in subtle mode. */ |
943 | if (!$pf_subtle_link) { |
944 | echo printer_friendly_link(true); |
945 | } |
946 | |
57257333 |
947 | if ($default_use_mdn) { |
948 | if ($mdn_user_support) { |
949 | |
950 | // debug gives you the capability to remove mdn-flags |
1190197c |
951 | // $MDNDebug = false; |
57257333 |
952 | $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true, |
953 | $response, $readmessage); |
954 | $MDN_to = substr($read[1], strpos($read[1], ' ')); |
955 | $MDN_flag_present = false; |
956 | |
957 | $read = sqimap_run_command ($imapConnection, "FETCH $passed_id FLAGS", true, |
958 | $response, $readmessage); |
77b88425 |
959 | $MDN_flag_present = preg_match( '/.*\$MDNSent/i', $read[0]); |
960 | |
57257333 |
961 | if (trim($MDN_to) && |
962 | (!isset( $sendreceipt ) || $sendreceipt == '' ) ) { |
963 | |
964 | if ( $MDN_flag_present && $supportMDN) { |
77b88425 |
965 | $sendreceipt = 'removeMDN'; |
3d570ba0 |
966 | $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\""; |
1190197c |
967 | $sendreceipt=''; |
968 | /* |
650be221 |
969 | if ($MDNDebug ) { |
57257333 |
970 | echo '<TR>' . |
971 | "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" . |
972 | _("Read receipt") . ': ' . |
973 | "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" . |
974 | '<B>' . |
975 | _("send") . |
976 | "</B> <a href=$url>[" . _("Remove MDN flag") . '] </a>' . |
977 | '</TD>' . |
978 | '</TR>' . "\n"; |
979 | } else { |
1190197c |
980 | */ |
981 | echo '<TR>' . |
982 | "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" . |
983 | _("Read receipt") . ': ' . |
984 | "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" . |
985 | '<B>'._("send").'</B>'. |
986 | '</TD>' . |
987 | '</TR>' . "\n"; |
988 | /* |
57257333 |
989 | } |
1190197c |
990 | */ |
57257333 |
991 | |
992 | } // when deleted or draft flag is set don't offer to send a MDN response |
f69feefe |
993 | else if ( ereg('\\Draft',$read[0] || ereg('\\Deleted',$read[0])) ) { |
57257333 |
994 | echo '<TR>' . |
995 | "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" . |
996 | _("Read receipt") . ': '. |
997 | "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" . |
998 | '<B>' . _("requested") . "</B>" . |
999 | '</TD>' . |
1000 | '</TR>' . "\n"; |
1001 | } |
1002 | // if no MDNsupport don't use the annoying popup messages |
1003 | else if ( !$FirstTimeSee ) { |
1004 | $sendreceipt = 'send'; |
3b1410d9 |
1005 | $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\""; |
57257333 |
1006 | echo '<TR>' . |
1007 | "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" . |
1008 | _("Read receipt") . ': ' . |
1009 | "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" . |
1010 | '<B>' . _("requested") . |
2c64e145 |
1011 | "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" . |
57257333 |
1012 | '</TD>' . |
1013 | '</TR>' . "\n"; |
1014 | $sendreceipt=''; |
1015 | } |
1016 | else { |
1017 | $sendreceipt = 'send'; |
3b1410d9 |
1018 | $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\""; |
57257333 |
1019 | if ($javascript_on) { |
3d570ba0 |
1020 | echo "<script language=\"javascript\" type=\"text/javascript\"> \n" . |
57257333 |
1021 | '<!-- ' . "\n" . |
1022 | " if (window.confirm(\"" . |
1023 | _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") . |
1024 | "\")) { \n" . |
34a6b7c2 |
1025 | ' window.open('.$url.',"right");' . "\n" . |
57257333 |
1026 | ' }' . "\n" . |
1027 | '// -->' . "\n" . |
1028 | '</script>' . "\n"; |
1029 | } |
1030 | echo '<TR>' . |
1031 | "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" . |
1032 | _("Read receipt") . ': ' . |
1033 | "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" . |
1034 | '<B>' . _("requested") . "  </B><a href=$url>" . '[' . |
1035 | _("Send read receipt now") . '] </a>' ." \n" . |
1036 | '</TD>' . |
1037 | '</TR>' . "\n"; |
1038 | $sendreceipt = ''; |
1039 | } |
1040 | } |
1041 | |
77b88425 |
1042 | if ( !isset( $sendreceipt ) || $sendreceipt == '' ) { |
57257333 |
1043 | } else if ( $sendreceipt == 'send' ) { |
1044 | if ( !$MDN_flag_present) { |
1045 | if (isset($identity) ) { |
77b88425 |
1046 | $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' ); |
1047 | } else { |
1048 | $final_recipient = getPref($data_dir, $username, 'email_address', '' ); |
1049 | } |
57257333 |
1050 | |
1051 | $final_recipient = trim($final_recipient); |
1052 | if ($final_recipient == '' ) { |
77b88425 |
1053 | $final_recipient = getPref($data_dir, $username, 'email_address', '' ); |
57257333 |
1054 | } |
1055 | |
77b88425 |
1056 | if ( SendMDN( $MDN_to, $final_recipient ) > 0 && $supportMDN ) { |
1057 | ToggleMDNflag( true); |
57257333 |
1058 | } |
34a6b7c2 |
1059 | ClearAttachments(); |
57257333 |
1060 | } |
1061 | $sendreceipt = 'removeMDN'; |
3d570ba0 |
1062 | $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\""; |
1190197c |
1063 | $sendreceipt=''; |
7e235a1a |
1064 | /* |
650be221 |
1065 | if ($MDNDebug && $supportMDN) { |
57257333 |
1066 | echo " <TR>\n" . |
1067 | " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" . |
1068 | " "._("Read receipt").": \n". |
1069 | " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" . |
1070 | ' <B>'._("send").'</B>'." <a href=$url>" . '[' . _("Remove MDN flag") . '] </a>' . "\n" . |
1071 | ' </TD>' . "\n" . |
1072 | ' </TR>' . "\n"; |
1073 | } else { |
1190197c |
1074 | */ |
57257333 |
1075 | echo " <TR>\n" . |
1076 | " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" . |
1077 | " "._("Read receipt").": \n". |
1078 | " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" . |
1079 | ' <B>'._("send").'</B>'. "\n" . |
1080 | ' </TD>' . "\n" . |
1081 | ' </TR>' . "\n"; |
1190197c |
1082 | /* |
57257333 |
1083 | } |
1190197c |
1084 | */ |
57257333 |
1085 | } |
1086 | elseif ($sendreceipt == 'removeMDN' ) { |
1087 | ToggleMDNflag ( false ); |
1088 | |
1089 | $sendreceipt = 'send'; |
3d570ba0 |
1090 | $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\""; |
57257333 |
1091 | echo '<TR>'. |
1092 | "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" . |
1093 | _("Read receipt") . ': ' . |
1094 | "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" . |
1095 | '<B>' . _("requested") . |
1096 | "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" . |
1097 | '</TD>' . |
1098 | '</TR>' . "\n"; |
1099 | $sendreceipt = ''; |
1100 | |
1101 | } |
1102 | } |
1103 | } |
1104 | |
5be9f195 |
1105 | do_hook('read_body_header'); |
57257333 |
1106 | |
a07cd1a4 |
1107 | echo '</TABLE>' . |
1108 | ' </TD></TR>' . |
1109 | '</TABLE>'; |
1110 | flush(); |
1111 | echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" . |
1112 | " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" . |
e5fdc771 |
1113 | '<BR>'; |
1114 | echo $body; |
1115 | |
1116 | echo '</TD></TR></TABLE>' . |
a07cd1a4 |
1117 | '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" . |
1118 | " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>" . |
1119 | '</TABLE>' . "\n"; |
1120 | |
1121 | /* show attached images inline -- if pref'fed so */ |
5be9f195 |
1122 | if (($attachment_common_show_images) && |
a07cd1a4 |
1123 | is_array($attachment_common_show_images_list)) { |
5be9f195 |
1124 | |
a07cd1a4 |
1125 | foreach ($attachment_common_show_images_list as $img) { |
5be9f195 |
1126 | $imgurl = '../src/download.php' . |
57257333 |
1127 | '?' . |
cd7b8833 |
1128 | 'passed_id=' . urlencode($img['passed_id']) . |
3d570ba0 |
1129 | '&mailbox=' . urlencode($mailbox) . |
1130 | '&passed_ent_id=' . urlencode($img['ent_id']) . |
1131 | '&absolute_dl=true'; |
5be9f195 |
1132 | |
a07cd1a4 |
1133 | echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" . |
57257333 |
1134 | '<TR>' . |
1135 | '<TD>' . |
1136 | "<img src=\"$imgurl\">\n" . |
1137 | "</TD>\n" . |
1138 | "</TR>\n" . |
a07cd1a4 |
1139 | "</TABLE>\n"; |
5be9f195 |
1140 | |
10f0ce72 |
1141 | } |
a07cd1a4 |
1142 | } |
1143 | |
5be9f195 |
1144 | |
a07cd1a4 |
1145 | do_hook('read_body_bottom'); |
1146 | do_hook('html_bottom'); |
1147 | sqimap_logout($imapConnection); |
1148 | ?> |
1149 | </body> |
a7818e8e |
1150 | </html> |