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