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'); |
fab3baa6 |
21 | require_once('../functions/html.php'); |
38c944cc |
22 | |
a07cd1a4 |
23 | /** |
1fca12b5 |
24 | * Given an IMAP message id number, this will look it up in the cached |
25 | * and sorted msgs array and return the index. Used for finding the next |
26 | * and previous messages. |
27 | * |
28 | * @return the index of the next valid message from the array |
29 | */ |
c615b1da |
30 | function findNextMessage($passed_id) { |
31 | global $msort, $msgs, $sort, |
cf710efe |
32 | $thread_sort_messages, $allow_server_sort, |
60a3e687 |
33 | $server_sort_array; |
2728fa19 |
34 | if (!is_array($server_sort_array)) { |
35 | $thread_sort_messages = 0; |
794d59c0 |
36 | $allow_server_sort = FALSE; |
2728fa19 |
37 | } |
a07cd1a4 |
38 | $result = -1; |
c615b1da |
39 | if ($thread_sort_messages || $allow_server_sort) { |
60a3e687 |
40 | reset($server_sort_array); |
41 | while(list($key, $value) = each ($server_sort_array)) { |
c615b1da |
42 | if ($passed_id == $value) { |
1fca12b5 |
43 | if ($key == (count($server_sort_array) - 1)) { |
60a3e687 |
44 | $result = -1; |
45 | break; |
46 | } |
1fca12b5 |
47 | $result = $server_sort_array[$key + 1]; |
60a3e687 |
48 | break; |
789b4d79 |
49 | } |
60a3e687 |
50 | } |
6206f6c4 |
51 | } else if ($sort == 6 && !$allow_server_sort && |
c615b1da |
52 | !$thread_sort_messages ) { |
53 | if ($passed_id != 1) { |
54 | $result = $passed_id - 1; |
a07cd1a4 |
55 | } |
6206f6c4 |
56 | } else if (!$allow_server_sort && !$thread_sort_messages ) { |
75ef78d8 |
57 | if (!is_array($msort)) { |
58 | return -1; |
59 | } |
a07cd1a4 |
60 | for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { |
c615b1da |
61 | if ($passed_id == $msgs[$key]['ID']) { |
a07cd1a4 |
62 | next($msort); |
63 | $key = key($msort); |
1fca12b5 |
64 | if (isset($key)){ |
a07cd1a4 |
65 | $result = $msgs[$key]['ID']; |
66 | break; |
1fca12b5 |
67 | } |
10f0ce72 |
68 | } |
69 | } |
10f0ce72 |
70 | } |
a07cd1a4 |
71 | return ($result); |
72 | } |
73 | |
a07cd1a4 |
74 | /** returns the index of the previous message from the array. */ |
c615b1da |
75 | function findPreviousMessage($numMessages, $passed_id) { |
76 | global $msort, $sort, $msgs, |
77 | $thread_sort_messages, |
60a3e687 |
78 | $allow_server_sort, $server_sort_array; |
a07cd1a4 |
79 | $result = -1; |
2728fa19 |
80 | if (!is_array($server_sort_array)) { |
81 | $thread_sort_messages = 0; |
794d59c0 |
82 | $allow_server_sort = FALSE; |
2728fa19 |
83 | } |
c615b1da |
84 | if ($thread_sort_messages || $allow_server_sort ) { |
60a3e687 |
85 | reset($server_sort_array); |
86 | while(list($key, $value) = each ($server_sort_array)) { |
c615b1da |
87 | if ($passed_id == $value) { |
60a3e687 |
88 | if ($key == 0) { |
89 | $result = -1; |
90 | break; |
91 | } |
92 | $result = $server_sort_array[$key -1]; |
93 | break; |
789b4d79 |
94 | } |
60a3e687 |
95 | } |
6206f6c4 |
96 | } else if ($sort == 6 && !$allow_server_sort && |
c615b1da |
97 | !$thread_sort_messages) { |
98 | if ($passed_id != $numMessages) { |
99 | $result = $passed_id + 1; |
a07cd1a4 |
100 | } |
6206f6c4 |
101 | } else if (!$thread_sort_messages && !$allow_server_sort) { |
1fca12b5 |
102 | if (!is_array($msort)) { |
75ef78d8 |
103 | return -1; |
1fca12b5 |
104 | } |
a07cd1a4 |
105 | for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { |
c615b1da |
106 | if ($passed_id == $msgs[$key]['ID']) { |
a07cd1a4 |
107 | prev($msort); |
108 | $key = key($msort); |
109 | if (isset($key)) { |
6206f6c4 |
110 | //echo $msort[$key]; /* Why again were we echoing here? */ |
a07cd1a4 |
111 | $result = $msgs[$key]['ID']; |
112 | break; |
10f0ce72 |
113 | } |
114 | } |
10f0ce72 |
115 | } |
a07cd1a4 |
116 | } |
117 | return ($result); |
118 | } |
10f0ce72 |
119 | |
a07cd1a4 |
120 | /** |
1fca12b5 |
121 | * Displays a link to a page where the message is displayed more |
122 | * "printer friendly". |
123 | */ |
c615b1da |
124 | function printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color) { |
125 | global $javascript_on; |
a07cd1a4 |
126 | |
c615b1da |
127 | $params = '?passed_ent_id=' . $passed_ent_id . |
1fca12b5 |
128 | '&mailbox=' . urlencode($mailbox) . |
129 | '&passed_id=' . $passed_id; |
10f0ce72 |
130 | |
a07cd1a4 |
131 | $print_text = _("View Printable Version"); |
10f0ce72 |
132 | |
c615b1da |
133 | $result = ''; |
a07cd1a4 |
134 | /* Output the link. */ |
135 | if ($javascript_on) { |
3d570ba0 |
136 | $result .= '<script language="javascript" type="text/javascript">' . "\n" . |
a07cd1a4 |
137 | '<!--' . "\n" . |
138 | " function printFormat() {\n" . |
139 | ' window.open("../src/printer_friendly_main.php' . |
c615b1da |
140 | $params . '","Print","width=800,height=600");' . "\n". |
a07cd1a4 |
141 | " }\n" . |
142 | "// -->\n" . |
143 | "</script>\n" . |
b5058e9e |
144 | "<a href=\"javascript:printFormat();\">$print_text</a>\n"; |
a07cd1a4 |
145 | } else { |
b5058e9e |
146 | $result .= '<A target="_blank" HREF="../src/printer_friendly_bottom.php' . |
147 | "$params\">$print_text</a>\n"; |
a07cd1a4 |
148 | } |
a07cd1a4 |
149 | return ($result); |
150 | } |
151 | |
57257333 |
152 | function ServerMDNSupport( $read ) { |
f69feefe |
153 | /* escaping $ doesn't work -> \x36 */ |
154 | $ret = preg_match( '/(\x36MDNSent|\\\*)/i', $read ); |
57257333 |
155 | return ( $ret ); |
156 | } |
157 | |
c615b1da |
158 | function SendMDN ( $mailbox, $passed_id, $sender, $message) { |
159 | global $username, $attachment_dir, $SERVER_NAME, |
160 | $version, $attachments; |
57257333 |
161 | |
38bca81c |
162 | $header = $message->rfc822_header; |
57257333 |
163 | $hashed_attachment_dir = getHashedDir($username, $attachment_dir); |
5200c026 |
164 | |
165 | $recipient_o = $header->dnt; |
166 | $recipient = $recipient_o->getAddress(true); |
57257333 |
167 | |
168 | // part 1 (RFC2298) |
169 | |
170 | $senton = getLongDateString( $header->date ); |
171 | $to_array = $header->to; |
172 | $to = ''; |
173 | foreach ($to_array as $line) { |
af568a82 |
174 | $to .= ' '.$line->getAddress(); |
57257333 |
175 | } |
176 | |
177 | $subject = $header->subject; |
178 | $now = getLongDateString( time() ); |
46bb8da8 |
179 | |
78db1583 |
180 | set_my_charset(); |
181 | |
46bb8da8 |
182 | $body = _("Your message") . "\r\n\r\n" . |
183 | "\t" . _("To:") . ' ' . $to . "\r\n" . |
184 | "\t" . _("Subject:") . ' ' . $subject . "\r\n" . |
185 | "\t" . _("Sent:") . ' ' . $senton . "\r\n" . |
186 | "\r\n" . |
187 | sprintf( _("Was displayed on %s"), $now ); |
f69feefe |
188 | |
83be314a |
189 | $body = charset_encode_japanese($body); |
190 | |
57257333 |
191 | // part2 (RFC2298) |
57257333 |
192 | $original_recipient = $to; |
193 | $original_message_id = $header->message_id; |
194 | |
195 | $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n"; |
196 | if ($original_recipient != '') { |
197 | $part2 .= "Original-Recipient : $original_recipient\r\n"; |
198 | } |
199 | $final_recipient = $sender; |
200 | $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" . |
201 | "Original-Message-ID : $original_message_id\r\n" . |
202 | "Disposition: manual-action/MDN-sent-manually; displayed\r\n"; |
203 | |
57257333 |
204 | $localfilename = GenerateRandomString(32, 'FILE', 7); |
205 | $full_localfilename = "$hashed_attachment_dir/$localfilename"; |
206 | |
207 | $fp = fopen( $full_localfilename, 'w'); |
208 | fwrite ($fp, $part2); |
209 | fclose($fp); |
210 | |
211 | $newAttachment = array(); |
212 | $newAttachment['localfilename'] = $localfilename; |
213 | $newAttachment['type'] = "message/disposition-notification"; |
aa866a40 |
214 | $newAttachment['session']=-1; |
57257333 |
215 | $attachments[] = $newAttachment; |
5200c026 |
216 | |
5200c026 |
217 | return (SendMessage($recipient, '', '', _("Read:") . ' ' . $subject, |
c615b1da |
218 | $body, 0, True, 3, -1) ); |
57257333 |
219 | } |
220 | |
221 | |
c615b1da |
222 | function ToggleMDNflag ( $set ,$imapConnection, $mailbox, $passed_id, $uid_support) { |
0892e427 |
223 | $sg = $set?'+':'-'; |
224 | $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)'; |
0892e427 |
225 | $read = sqimap_run_command ($imapConnection, $cmd, true, $response, |
507d14ea |
226 | $readmessage, $uid_support); |
57257333 |
227 | } |
228 | |
229 | function ClearAttachments() { |
230 | global $username, $attachments, $attachment_dir; |
231 | |
232 | $hashed_attachment_dir = getHashedDir($username, $attachment_dir); |
233 | |
aa866a40 |
234 | $rem_attachments = array(); |
57257333 |
235 | foreach ($attachments as $info) { |
b2c19764 |
236 | if ($info['session'] == -1) { |
aa866a40 |
237 | $attached_file = "$hashed_attachment_dir/$info[localfilename]"; |
238 | if (file_exists($attached_file)) { |
239 | unlink($attached_file); |
240 | } |
241 | } else { |
242 | $rem_attachments[] = $info; |
243 | } |
244 | } |
68c3b52a |
245 | $attachments = $rem_attachments; |
57257333 |
246 | } |
247 | |
4d0cd98b |
248 | function formatRecipientString($recipients, $item ) { |
c615b1da |
249 | global $show_more_cc, $show_more, $show_more_bcc, |
38c944cc |
250 | $PHP_SELF; |
4d0cd98b |
251 | |
38c944cc |
252 | if ((is_array($recipients)) && (isset($recipients[0]))) { |
1fca12b5 |
253 | $string = ''; |
4d0cd98b |
254 | $ary = $recipients; |
38c944cc |
255 | $show = false; |
256 | |
257 | if ($item == 'to') { |
258 | if ($show_more) { |
259 | $show = true; |
260 | $url = set_url_var($PHP_SELF, 'show_more',0); |
261 | } else { |
262 | $url = set_url_var($PHP_SELF, 'show_more',1); |
263 | } |
264 | } else if ($item == 'cc') { |
265 | if ($show_more_cc) { |
266 | $url = set_url_var($PHP_SELF, 'show_more_cc',0); |
267 | $show = true; |
268 | } else { |
269 | $url = set_url_var($PHP_SELF, 'show_more_cc',1); |
270 | } |
271 | } else if ($item == 'bcc') { |
272 | if ($show_more_bcc) { |
273 | $url = set_url_var($PHP_SELF, 'show_more_bcc',0); |
274 | $show = true; |
275 | } else { |
276 | $url = set_url_var($PHP_SELF, 'show_more_bcc',1); |
277 | } |
278 | } |
4d0cd98b |
279 | |
38c944cc |
280 | $cnt = count($ary); |
c615b1da |
281 | $i = 0; |
38c944cc |
282 | while ($i < $cnt) { |
c615b1da |
283 | $ary[$i] = htmlspecialchars($ary[$i]->getAddress()); |
4d0cd98b |
284 | if ($string) { |
38c944cc |
285 | $string .= '<BR>'.$ary[$i]; |
4d0cd98b |
286 | } else { |
38c944cc |
287 | $string = $ary[$i]; |
288 | if ($cnt>1) { |
289 | $string .= ' (<A HREF="'.$url; |
290 | if ($show) { |
c615b1da |
291 | $string .= '">'._("less").'</A>)'; |
38c944cc |
292 | } else { |
c615b1da |
293 | $string .= '">'._("more").'</A>)'; |
38c944cc |
294 | break; |
295 | } |
296 | } |
4d0cd98b |
297 | } |
4d0cd98b |
298 | $i++; |
1fca12b5 |
299 | } |
4d0cd98b |
300 | } |
301 | else { |
1fca12b5 |
302 | $string = ''; |
4d0cd98b |
303 | } |
c615b1da |
304 | return $string; |
305 | } |
306 | |
af568a82 |
307 | function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message, |
308 | $color, $FirstTimeSee) { |
2ffa3f57 |
309 | global $msn_user_support, $default_use_mdn, $draft_folder, $sent_folder, |
310 | $default_use_priority, $show_xmailer_default, |
311 | $mdn_user_support, $PHP_SELF, $javascript_on; |
38bca81c |
312 | |
313 | $header = $message->rfc822_header; |
c615b1da |
314 | $env = array(); |
83be314a |
315 | $env[_("Subject")] = htmlspecialchars(decodeHeader($header->subject)); |
38bca81c |
316 | $from_name = $header->getAddr_s('from'); |
317 | if (!$from_name) { |
318 | $from_name = $header->getAddr_s('sender'); |
319 | if (!$from_name) { |
320 | $from_name = _("Unknown sender"); |
321 | } |
c615b1da |
322 | } |
83be314a |
323 | $env[_("From")] = htmlspecialchars(decodeHeader($from_name)); |
88d3af4f |
324 | $env[_("Date")] = getLongDateString($header->date); |
c615b1da |
325 | $env[_("To")] = formatRecipientString($header->to, "to"); |
326 | $env[_("Cc")] = formatRecipientString($header->cc, "cc"); |
327 | $env[_("Bcc")] = formatRecipientString($header->bcc, "bcc"); |
328 | if ($default_use_priority) { |
329 | $env[_("Priority")] = getPriorityStr($header->priority); |
330 | } |
331 | if ($show_xmailer_default) { |
83be314a |
332 | $env[_("Mailer")] = decodeHeader($header->xmailer); |
c615b1da |
333 | } |
334 | if ($default_use_mdn) { |
335 | if ($mdn_user_support) { |
336 | if ($header->dnt) { |
337 | if ($message->is_mdnsent) { |
338 | $env[_("Read receipt")] = _("send"); |
339 | } else { |
340 | if ( !($mailbox == $draft_folder || |
27ff41bd |
341 | $mailbox == $sent_folder || |
342 | $message->is_deleted || |
343 | $passed_ent_id)) { |
c615b1da |
344 | $mdn_url = $PHP_SELF . '&sendreceipt=1'; |
c615b1da |
345 | if ($FirstTimeSee && $javascript_on) { |
346 | $script = '<script language="JavaScript" type="text/javascript">' ."\n"; |
347 | $script .= '<!--'. "\n"; |
348 | $script .= 'if(window.confirm("' . |
349 | _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") . |
350 | '")) { '."\n" . |
351 | ' sendMDN()'. |
352 | '}' . "\n"; |
353 | $script .= '// -->'. "\n"; |
354 | $script .= '</script>'. "\n"; |
355 | echo $script; |
356 | } |
357 | $env[_("Read receipt")] = _("requested") . |
358 | ' <a href="'.$mdn_url.'">['. _("Send read receipt now") .']</a>'; |
359 | } else { |
360 | $env[_("Read receipt")] = _("requested"); |
361 | } |
362 | } |
363 | } |
364 | } |
365 | } |
366 | |
9feb4369 |
367 | $s = '<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"'; |
368 | $s .= ' ALIGN="center" BGCOLOR="' . $color[0] . '">'; |
c615b1da |
369 | foreach ($env as $key => $val) { |
370 | if ($val) { |
9feb4369 |
371 | $s .= '<TR>'; |
9a231083 |
372 | $s .= html_tag('TD', '<B>' . $key . ': </B>', 'RIGHT', '', 'VALIGN="TOP" WIDTH="20%"') . "\n"; |
373 | $s .= html_tag('TD', $val, 'left', '', 'VALIGN="TOP" WIDTH="80%"') . "\n"; |
9feb4369 |
374 | $s .= '</TR>'; |
c615b1da |
375 | } |
376 | } |
7172cad7 |
377 | echo $s; |
2ffa3f57 |
378 | do_hook("read_body_header"); |
9feb4369 |
379 | formatToolbar($mailbox,$passed_id,$passed_ent_id,$message, $color); |
380 | echo '</table>'; |
c615b1da |
381 | } |
382 | |
7172cad7 |
383 | function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response) { |
c615b1da |
384 | global $base_uri, $sent_folder, $draft_folder, $where, $what, $color, $sort, |
6206f6c4 |
385 | $startMessage, $compose_new_win, $PHP_SELF, $save_as_draft, |
386 | $enable_forward_as_attachment; |
c615b1da |
387 | |
388 | $topbar_delimiter = ' | '; |
f099d05f |
389 | $urlMailbox = urlencode($mailbox); |
c615b1da |
390 | $s = '<table width="100%" cellpadding="3" cellspacing="0" align="center"'. |
391 | ' border="0" bgcolor="'.$color[9].'"><tr><td align="left" width="33%"><small>'; |
392 | |
393 | $msgs_url = $base_uri . 'src/'; |
394 | if (isset($where) && isset($what)) { |
d215ca7d |
395 | $msgs_url .= 'search.php?where='.urlencode($where). |
c615b1da |
396 | '&what='.urlencode($what).'&mailbox='.$urlMailbox; |
2ffa3f57 |
397 | $msgs_str = _("Search results"); |
c615b1da |
398 | } else { |
399 | $msgs_url .= 'right_main.php?sort='.$sort.'&startMessage='. |
400 | $startMessage.'&mailbox='.$urlMailbox; |
d215ca7d |
401 | $msgs_str = _("Message List"); |
c615b1da |
402 | } |
d215ca7d |
403 | $s .= '<a href="'. $msgs_url.'">'.$msgs_str.'</a>'; |
c615b1da |
404 | $s .= $topbar_delimiter; |
6206f6c4 |
405 | |
c615b1da |
406 | $delete_url = $base_uri . 'src/delete_message.php?mailbox='.$urlMailbox. |
407 | '&message='.$passed_id.'&'; |
408 | if (!(isset($passed_ent_id) && $passed_ent_id)) { |
409 | if ($where && $what) { |
410 | $delete_url .= 'where=' . urlencode($where) . '&what=' . urlencode($what); |
411 | } else { |
412 | $delete_url .= 'sort='. $sort . '&startMessage='. $startMessage; |
413 | } |
414 | $s .= '<a href="'. $delete_url.'">'._("Delete").'</a>'; |
415 | } |
416 | |
417 | $comp_uri = $base_uri . 'src/compose.php'. |
418 | '?passed_id='.$passed_id. |
2ffa3f57 |
419 | '&mailbox='.$urlMailbox. |
420 | (isset($passed_ent_id)?'&passed_ent_id='.$passed_ent_id:''); |
c615b1da |
421 | |
422 | if (($mailbox == $draft_folder) && ($save_as_draft)) { |
423 | $comp_alt_uri = $comp_uri . '&action=draft'; |
424 | $comp_alt_string = _("Resume Draft"); |
425 | } else if ($mailbox == $sent_folder) { |
426 | $comp_alt_uri = $comp_uri . '&action=edit_as_new'; |
427 | $comp_alt_string = _("Edit Message as New"); |
428 | } |
429 | if (isset($comp_alt_uri)) { |
430 | $s .= $topbar_delimiter; |
431 | if ($compose_new_win == '1') { |
432 | $s .= '<a href="javascript:void(0)" '. |
2ffa3f57 |
433 | 'onclick="comp_in_new(\''.$comp_alt_uri.'\')">'.$comp_alt_string.'</a>'; |
c615b1da |
434 | } else { |
435 | $s .= '<a href="'.$comp_alt_uri.'">'.$comp_alt_string.'</a>'; |
436 | } |
437 | } |
2ffa3f57 |
438 | |
c615b1da |
439 | $s .= '</small></td><td align="center" width="33%"><small>'; |
2ffa3f57 |
440 | |
c615b1da |
441 | if (!(isset($where) && isset($what)) && !$passed_ent_id) { |
442 | $prev = findPreviousMessage($mbx_response['EXISTS'], $passed_id); |
443 | $next = findNextMessage($passed_id); |
444 | if ($prev != -1) { |
445 | $uri = $base_uri . 'src/read_body.php?passed_id='.$prev. |
446 | '&mailbox='.$urlMailbox.'&sort='.$sort. |
447 | '&startMessage='.$startMessage.'&show_more=0'; |
448 | $s .= '<a href="'.$uri.'">'._("Previous").'</a>'; |
449 | } else { |
450 | $s .= _("Previous"); |
451 | } |
452 | $s .= $topbar_delimiter; |
453 | if ($next != -1) { |
454 | $uri = $base_uri . 'src/read_body.php?passed_id='.$next. |
455 | '&mailbox='.$urlMailbox.'&sort='.$sort. |
456 | '&startMessage='.$startMessage.'&show_more=0'; |
2ffa3f57 |
457 | $s .= '<a href="'.$uri.'">'._("Next").'</a>'; |
c615b1da |
458 | } else { |
459 | $s .= _("Next"); |
460 | } |
461 | } else if (isset($passed_ent_id) && $passed_ent_id) { |
7172cad7 |
462 | /* code for navigating through attached message/rfc822 messages */ |
463 | $url = set_url_var($PHP_SELF, 'passed_ent_id',0); |
464 | $s .= '<a href="'.$url.'">'._("View Message").'</a>'; |
465 | $par_ent_id = $message->parent->entity_id; |
466 | if ($par_ent_id) { |
2ffa3f57 |
467 | $par_ent_id = substr($par_ent_id,0,-2); |
468 | $s .= $topbar_delimiter; |
469 | $url = set_url_var($PHP_SELF, 'passed_ent_id',$par_ent_id); |
470 | $s .= '<a href="'.$url.'">'._("Up").'</a>'; |
7172cad7 |
471 | } |
2ffa3f57 |
472 | } |
c615b1da |
473 | |
a128c967 |
474 | $s .= '</small></td><td align="right" width="33%" nowrap><small>'; |
c615b1da |
475 | $comp_action_uri = $comp_uri . '&action=forward'; |
476 | if ($compose_new_win == '1') { |
477 | $s .= '<a href="javascript:void(0)" '. |
478 | 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Forward").'</a>'; |
479 | } else { |
480 | $s .= '<a href="'.$comp_action_uri.'">'._("Forward").'</a>'; |
481 | } |
482 | $s .= $topbar_delimiter; |
483 | |
6206f6c4 |
484 | if ($enable_forward_as_attachment) { |
485 | $comp_action_uri = $comp_uri . '&action=forward_as_attachment'; |
486 | if ($compose_new_win == '1') { |
487 | $s .= '<a href="javascript:void(0)" '. |
488 | 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Forward as Attachment").'</a>'; |
489 | } else { |
490 | $s .= '<a href="'.$comp_action_uri.'">'._("Forward as Attachment").'</a>'; |
491 | } |
492 | $s .= $topbar_delimiter; |
a128c967 |
493 | } |
a128c967 |
494 | |
c615b1da |
495 | $comp_action_uri = decodeHeader($comp_uri . '&action=reply'); |
496 | if ($compose_new_win == '1') { |
497 | $s .= '<a href="javascript:void(0)" '. |
498 | 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Reply").'</a>'; |
499 | } else { |
500 | $s .= '<a href="'.$comp_action_uri.'">'._("Reply").'</a>'; |
501 | } |
502 | $s .= $topbar_delimiter; |
503 | |
504 | $comp_action_uri = $comp_uri . '&action=reply_all'; |
505 | if ($compose_new_win == '1') { |
506 | $s .= '<a href="javascript:void(0)" '. |
507 | 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Reply All").'</a>'; |
508 | } else { |
509 | $s .= '<a href="'.$comp_action_uri.'">'._("Reply All").'</a>'; |
510 | } |
511 | $s .= '</small></td></tr></table>'; |
2ffa3f57 |
512 | do_hook("read_body_menu_top"); |
7172cad7 |
513 | echo $s; |
2ffa3f57 |
514 | do_hook("read_body_menu_bottom"); |
c615b1da |
515 | } |
516 | |
517 | function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) { |
8fde8417 |
518 | global $QUERY_STRING, $base_uri; |
c615b1da |
519 | |
f099d05f |
520 | $urlMailbox = urlencode($mailbox); |
8fde8417 |
521 | $url = $base_uri.'src/view_header.php?'.$QUERY_STRING; |
9feb4369 |
522 | |
9feb4369 |
523 | $s = "<TR>\n"; |
25516e56 |
524 | $s .= '<TD VALIGN="MIDDLE" ALIGN="RIGHT" WIDTH="20%"><B>' . _("Options") . ": </B></TD>\n"; |
a128c967 |
525 | $s .= '<TD VALIGN="MIDDLE" ALIGN="LEFT" WIDTH="80%"><SMALL>'; |
8fde8417 |
526 | $s .= '<a href="'.$url.'">'.("View Full Header").'</a>'; |
9feb4369 |
527 | |
528 | /* Output the printer friendly link if we are in subtle mode. */ |
529 | $s .= ' | '; |
530 | $s .= printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color); |
7172cad7 |
531 | echo $s; |
c615b1da |
532 | do_hook("read_body_header_right"); |
a128c967 |
533 | $s = "</SMALL></TD>\n"; |
534 | $s .= "</TR>\n"; |
535 | echo $s; |
536 | |
537 | |
4d0cd98b |
538 | } |
539 | |
6206f6c4 |
540 | /***************************/ |
2ffa3f57 |
541 | /* Main of read_body.php */ |
6206f6c4 |
542 | /***************************/ |
57257333 |
543 | |
544 | /* |
545 | Urled vars |
546 | ---------- |
547 | $passed_id |
548 | */ |
a07cd1a4 |
549 | |
38c944cc |
550 | global $uid_support, $sqimap_capabilities; |
551 | |
6a108031 |
552 | if (isset($mailbox)) { |
4366bea4 |
553 | $mailbox = urldecode( $mailbox ); |
554 | } |
38c944cc |
555 | |
6206f6c4 |
556 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
38c944cc |
557 | $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true); |
558 | |
559 | if (!isset($messages)) { |
560 | $messages = array(); |
561 | session_register('messages'); |
38c944cc |
562 | } |
563 | |
564 | /** |
565 | * $message contains all information about the message |
566 | * including header and body |
567 | */ |
37d2a6ee |
568 | |
569 | $uidvalidity = $mbx_response['UIDVALIDITY']; |
570 | |
571 | if (!isset($messages[$uidvalidity])) { |
572 | $messages[$uidvalidity] = array(); |
573 | } |
5200c026 |
574 | if (!isset($messages[$uidvalidity][$passed_id]) || !$uid_support) { |
575 | $message = sqimap_get_message($imapConnection, $passed_id, $mailbox); |
576 | $messages[$uidvalidity][$passed_id] = $message; |
38c944cc |
577 | } else { |
38bca81c |
578 | $message = sqimap_get_message($imapConnection, $passed_id, $mailbox); |
579 | // $message = $messages[$uidvalidity][$passed_id]; |
5200c026 |
580 | } |
af568a82 |
581 | $FirstTimeSee = !$message->is_seen; |
582 | $message->is_seen = true; |
583 | $messages[$uidvalidity][$passed_id] = $message; |
584 | |
dd628162 |
585 | if (isset($passed_ent_id) && $passed_ent_id) { |
5200c026 |
586 | $message = $message->getEntity($passed_ent_id); |
ff9d4297 |
587 | if ($message->type0 != 'message' && $message->type1 != 'rfc822') { |
588 | $message = $message->parent; |
589 | } |
141a16b2 |
590 | $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[$passed_ent_id.HEADER]", true, $response, $msg, $uid_support); |
591 | $rfc822_header = new rfc822_header(); |
592 | $rfc822_header->parseHeader($read); |
593 | $message->rfc822_header = $rfc822_header; |
c615b1da |
594 | } else { |
595 | $passed_ent_id = 0; |
38c944cc |
596 | } |
5200c026 |
597 | $header = $message->header; |
57257333 |
598 | |
6c31f818 |
599 | do_hook('html_top'); |
57257333 |
600 | |
6206f6c4 |
601 | /****************************************/ |
602 | /* Block for handling incoming url vars */ |
603 | /****************************************/ |
5200c026 |
604 | |
5200c026 |
605 | if (isset($sendreceipt)) { |
606 | if ( !$message->is_mdnsent ) { |
607 | if (isset($identity) ) { |
608 | $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' ); |
609 | } else { |
610 | $final_recipient = getPref($data_dir, $username, 'email_address', '' ); |
611 | } |
612 | |
613 | $final_recipient = trim($final_recipient); |
614 | if ($final_recipient == '' ) { |
615 | $final_recipient = getPref($data_dir, $username, 'email_address', '' ); |
616 | } |
af568a82 |
617 | $supportMDN = ServerMDNSupport($mbx_response["PERMANENTFLAGS"]); |
c615b1da |
618 | if ( SendMDN( $mailbox, $passed_id, $final_recipient, $message ) > 0 && $supportMDN ) { |
619 | ToggleMDNflag( true, $imapConnection, $mailbox, $passed_id, $uid_support); |
5200c026 |
620 | $message->is_mdnsent = true; |
6a108031 |
621 | $messages[$uidvalidity][$passed_id]=$message; |
5200c026 |
622 | } |
623 | ClearAttachments(); |
624 | } |
625 | } |
6206f6c4 |
626 | /***********************************************/ |
627 | /* End of block for handling incoming url vars */ |
628 | /***********************************************/ |
629 | |
38c944cc |
630 | $msgs[$passed_id]['FLAG_SEEN'] = true; |
38c944cc |
631 | |
5200c026 |
632 | $messagebody = ''; |
c4ad259b |
633 | do_hook('read_body_top'); |
634 | if ($show_html_default == 1) { |
635 | $ent_ar = $message->findDisplayEntity(array()); |
636 | } else { |
637 | $ent_ar = $message->findDisplayEntity(array(), array('text/plain')); |
638 | } |
a128c967 |
639 | $cnt = count($ent_ar); |
640 | for ($i = 0; $i < $cnt; $i++) { |
6a108031 |
641 | $messagebody .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox); |
a128c967 |
642 | if ($i != $cnt-1) { |
643 | $messagebody .= '<hr noshade size=1>'; |
644 | } |
38c944cc |
645 | } |
6a108031 |
646 | |
c615b1da |
647 | displayPageHeader($color, $mailbox); |
7172cad7 |
648 | formatMenuBar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response); |
af568a82 |
649 | formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee); |
6206f6c4 |
650 | echo '<table width="100%" cellpadding="0" cellspacing="0" align="center" border="0">'; |
651 | echo ' <tr><td>'; |
652 | echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[9].'">'; |
a128c967 |
653 | echo ' <tr><td>'; |
6206f6c4 |
654 | echo ' <table width="100%" cellpadding="3" cellspacing="0" align="center" border="0">'; |
655 | echo ' <tr bgcolor="'.$color[4].'"><td>'; |
656 | echo ' <table cellpadding="0" cellspacing="0" align="center" border="0">'; |
657 | echo ' <tr><td><br>' . $messagebody . '</td></td>'; |
658 | echo ' </table>'; |
659 | echo ' </td></tr>'; |
660 | echo ' </table></td></tr>'; |
2ffa3f57 |
661 | echo ' </table>'; |
662 | echo ' </td></tr>'; |
a128c967 |
663 | |
664 | $attachmentsdisplay = formatAttachments($message,$ent_ar,$mailbox, $passed_id); |
665 | if ($attachmentsdisplay) { |
2ffa3f57 |
666 | echo ' <tr><td>'; |
6206f6c4 |
667 | echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">'; |
2ffa3f57 |
668 | echo ' <tr><td>'; |
669 | echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">'; |
6206f6c4 |
670 | echo ' <tr><td ALIGN="left" bgcolor="'.$color[9].'">'; |
671 | echo ' <b>' . _("Attachments") . ':</b>'; |
672 | echo ' </td></tr>'; |
673 | echo ' <tr><td>'; |
674 | echo ' <table width="100%" cellpadding="2" cellspacing="2" align="center"'.' border="0" bgcolor="'.$color[0].'"><tr><td>'; |
675 | echo $attachmentsdisplay; |
676 | echo ' </td></tr></table>'; |
677 | echo ' </table></td></tr>'; |
2ffa3f57 |
678 | echo ' </table></td></tr>'; |
6206f6c4 |
679 | echo ' </table>'; |
680 | echo ' </td></tr>'; |
a128c967 |
681 | } |
c615b1da |
682 | echo '</table>'; |
a07cd1a4 |
683 | |
a128c967 |
684 | |
a07cd1a4 |
685 | /* show attached images inline -- if pref'fed so */ |
5be9f195 |
686 | if (($attachment_common_show_images) && |
a07cd1a4 |
687 | is_array($attachment_common_show_images_list)) { |
688 | foreach ($attachment_common_show_images_list as $img) { |
5be9f195 |
689 | $imgurl = '../src/download.php' . |
57257333 |
690 | '?' . |
cd7b8833 |
691 | 'passed_id=' . urlencode($img['passed_id']) . |
3d570ba0 |
692 | '&mailbox=' . urlencode($mailbox) . |
ff9d4297 |
693 | '&ent_id=' . urlencode($img['ent_id']) . |
3d570ba0 |
694 | '&absolute_dl=true'; |
5be9f195 |
695 | |
b5058e9e |
696 | echo html_tag( 'table', "\n" . |
697 | html_tag( 'tr', "\n" . |
698 | html_tag( 'td', '<img src="' . $imgurl . '">' ."\n", 'left' |
699 | ) |
700 | ) , |
701 | 'center', '', 'cellspacing=0 border="0" cellpadding="2"'); |
10f0ce72 |
702 | } |
a07cd1a4 |
703 | } |
704 | |
c615b1da |
705 | do_hook('read_body_bottom'); |
706 | do_hook('html_bottom'); |
d7eab095 |
707 | //$message->clean_up(); |
a07cd1a4 |
708 | sqimap_logout($imapConnection); |
709 | ?> |
c615b1da |
710 | </body> |
711 | </html> |