59177427 |
1 | <?php |
35586184 |
2 | /** |
3 | * read_body.php |
4 | * |
82d304a0 |
5 | * Copyright (c) 1999-2004 The SquirrelMail Project Team |
35586184 |
6 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
7 | * |
8 | * This file is used for reading the msgs array and displaying |
9 | * the resulting emails in the right frame. |
10 | * |
11 | * $Id$ |
8f6f9ba5 |
12 | * @package squirrelmail |
a07cd1a4 |
13 | */ |
35586184 |
14 | |
8f6f9ba5 |
15 | /** Path for SquirrelMail required files. */ |
86725763 |
16 | define('SM_PATH','../'); |
17 | |
18 | /* SquirrelMail required files. */ |
08185f2a |
19 | require_once(SM_PATH . 'include/validate.php'); |
8650e9e1 |
20 | require_once(SM_PATH . 'functions/global.php'); |
86725763 |
21 | require_once(SM_PATH . 'functions/imap.php'); |
22 | require_once(SM_PATH . 'functions/mime.php'); |
23 | require_once(SM_PATH . 'functions/date.php'); |
24 | require_once(SM_PATH . 'functions/url_parser.php'); |
25 | require_once(SM_PATH . 'functions/html.php'); |
e95c04ec |
26 | require_once(SM_PATH . 'functions/global.php'); |
6d021521 |
27 | require_once(SM_PATH . 'functions/identity.php'); |
d6b6d221 |
28 | require_once(SM_PATH . 'functions/mailbox_display.php'); |
38c944cc |
29 | |
a07cd1a4 |
30 | /** |
1fca12b5 |
31 | * Given an IMAP message id number, this will look it up in the cached |
1e150c97 |
32 | * and sorted msgs array and return the index of the next message |
1fca12b5 |
33 | * |
1e150c97 |
34 | * @param int $passed_id The current message UID |
1fca12b5 |
35 | * @return the index of the next valid message from the array |
36 | */ |
c615b1da |
37 | function findNextMessage($passed_id) { |
38 | global $msort, $msgs, $sort, |
cf710efe |
39 | $thread_sort_messages, $allow_server_sort, |
60a3e687 |
40 | $server_sort_array; |
2728fa19 |
41 | if (!is_array($server_sort_array)) { |
42 | $thread_sort_messages = 0; |
794d59c0 |
43 | $allow_server_sort = FALSE; |
2728fa19 |
44 | } |
a07cd1a4 |
45 | $result = -1; |
c615b1da |
46 | if ($thread_sort_messages || $allow_server_sort) { |
d9c1dccc |
47 | $count = count($server_sort_array) - 1; |
48 | foreach($server_sort_array as $key=>$value) { |
c615b1da |
49 | if ($passed_id == $value) { |
d9c1dccc |
50 | if ($key == $count) { |
60a3e687 |
51 | break; |
52 | } |
1fca12b5 |
53 | $result = $server_sort_array[$key + 1]; |
60a3e687 |
54 | break; |
789b4d79 |
55 | } |
60a3e687 |
56 | } |
d9c1dccc |
57 | } else { |
7e818af0 |
58 | if (is_array($msort)) { |
59 | for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { |
60 | if ($passed_id == $msgs[$key]['ID']) { |
61 | next($msort); |
62 | $key = key($msort); |
63 | if (isset($key)){ |
64 | $result = $msgs[$key]['ID']; |
65 | break; |
d9c1dccc |
66 | } |
1fca12b5 |
67 | } |
10f0ce72 |
68 | } |
69 | } |
10f0ce72 |
70 | } |
d9c1dccc |
71 | return $result; |
a07cd1a4 |
72 | } |
73 | |
1e150c97 |
74 | /** |
75 | * Given an IMAP message id number, this will look it up in the cached |
76 | * and sorted msgs array and return the index of the previous message |
77 | * |
78 | * @param int $passed_id The current message UID |
79 | * @return the index of the next valid message from the array |
80 | */ |
c615b1da |
81 | function findPreviousMessage($numMessages, $passed_id) { |
82 | global $msort, $sort, $msgs, |
83 | $thread_sort_messages, |
60a3e687 |
84 | $allow_server_sort, $server_sort_array; |
a07cd1a4 |
85 | $result = -1; |
2728fa19 |
86 | if (!is_array($server_sort_array)) { |
87 | $thread_sort_messages = 0; |
794d59c0 |
88 | $allow_server_sort = FALSE; |
2728fa19 |
89 | } |
c615b1da |
90 | if ($thread_sort_messages || $allow_server_sort ) { |
d9c1dccc |
91 | foreach($server_sort_array as $key=>$value) { |
c615b1da |
92 | if ($passed_id == $value) { |
60a3e687 |
93 | if ($key == 0) { |
60a3e687 |
94 | break; |
95 | } |
d9c1dccc |
96 | $result = $server_sort_array[$key - 1]; |
60a3e687 |
97 | break; |
789b4d79 |
98 | } |
60a3e687 |
99 | } |
d9c1dccc |
100 | } else { |
7e818af0 |
101 | if (is_array($msort)) { |
102 | for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { |
103 | if ($passed_id == $msgs[$key]['ID']) { |
104 | prev($msort); |
105 | $key = key($msort); |
106 | if (isset($key)) { |
107 | $result = $msgs[$key]['ID']; |
108 | break; |
d9c1dccc |
109 | } |
10f0ce72 |
110 | } |
111 | } |
10f0ce72 |
112 | } |
a07cd1a4 |
113 | } |
d9c1dccc |
114 | return $result; |
a07cd1a4 |
115 | } |
10f0ce72 |
116 | |
a07cd1a4 |
117 | /** |
1fca12b5 |
118 | * Displays a link to a page where the message is displayed more |
119 | * "printer friendly". |
1e150c97 |
120 | * @param string $mailbox Name of current mailbox |
121 | * @param int $passed_id |
1fca12b5 |
122 | */ |
1e150c97 |
123 | function printer_friendly_link($mailbox, $passed_id, $passed_ent_id) { |
124 | global $javascript_on, $color; |
a07cd1a4 |
125 | |
c615b1da |
126 | $params = '?passed_ent_id=' . $passed_ent_id . |
c2324b26 |
127 | '&mailbox=' . urlencode($mailbox) . |
128 | '&passed_id=' . $passed_id; |
10f0ce72 |
129 | |
a07cd1a4 |
130 | $print_text = _("View Printable Version"); |
10f0ce72 |
131 | |
c615b1da |
132 | $result = ''; |
a07cd1a4 |
133 | /* Output the link. */ |
134 | if ($javascript_on) { |
9f42bfc8 |
135 | $result = '<script language="javascript" type="text/javascript">' . "\n" . |
136 | '<!--' . "\n" . |
137 | " function printFormat() {\n" . |
138 | ' window.open("../src/printer_friendly_main.php' . |
139 | $params . '","Print","width=800,height=600");' . "\n". |
140 | " }\n" . |
141 | "// -->\n" . |
142 | "</script>\n" . |
143 | "<a href=\"javascript:printFormat();\">$print_text</a>\n"; |
a07cd1a4 |
144 | } else { |
c2324b26 |
145 | $result = '<a target="_blank" href="../src/printer_friendly_bottom.php' . |
9f42bfc8 |
146 | "$params\">$print_text</a>\n"; |
a07cd1a4 |
147 | } |
d9c1dccc |
148 | return $result; |
a07cd1a4 |
149 | } |
150 | |
d9c1dccc |
151 | function ServerMDNSupport($read) { |
f69feefe |
152 | /* escaping $ doesn't work -> \x36 */ |
781b93d4 |
153 | $ret = preg_match('/(\x36MDNSent|\\\\\*)/i', $read); |
d9c1dccc |
154 | return $ret; |
57257333 |
155 | } |
156 | |
fc224f68 |
157 | function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) { |
e95c04ec |
158 | global $username, $attachment_dir, |
fc224f68 |
159 | $version, $attachments, $squirrelmail_language, $default_charset, |
d9c1dccc |
160 | $languages, $useSendmail, $domain, $sent_folder, |
161 | $popuser, $data_dir, $username; |
57257333 |
162 | |
e95c04ec |
163 | sqgetGlobalVar('SERVER_NAME', $SERVER_NAME, SQ_SERVER); |
0b97a708 |
164 | |
38bca81c |
165 | $header = $message->rfc822_header; |
57257333 |
166 | $hashed_attachment_dir = getHashedDir($username, $attachment_dir); |
167 | |
fc224f68 |
168 | $rfc822_header = new Rfc822Header(); |
d9c1dccc |
169 | $content_type = new ContentType('multipart/report'); |
fc224f68 |
170 | $content_type->properties['report-type']='disposition-notification'; |
d9c1dccc |
171 | |
fc224f68 |
172 | set_my_charset(); |
173 | if ($default_charset) { |
d9c1dccc |
174 | $content_type->properties['charset']=$default_charset; |
fc224f68 |
175 | } |
176 | $rfc822_header->content_type = $content_type; |
177 | $rfc822_header->to[] = $header->dnt; |
a20855e4 |
178 | $rfc822_header->subject = _("Read:") . ' ' . encodeHeader($header->subject); |
fc224f68 |
179 | |
27a1d10a |
180 | // Patch #793504 Return Receipt Failing with <@> from Tim Craig (burny_md) |
181 | // This merely comes from compose.php and only happens when there is no |
182 | // email_addr specified in user's identity (which is the startup config) |
183 | if (ereg("^([^@%/]+)[@%/](.+)$", $username, $usernamedata)) { |
184 | $popuser = $usernamedata[1]; |
185 | $domain = $usernamedata[2]; |
186 | unset($usernamedata); |
187 | } else { |
188 | $popuser = $username; |
189 | } |
fc224f68 |
190 | |
191 | $reply_to = ''; |
6d021521 |
192 | $ident = get_identities(); |
193 | if(!isset($identity)) $identity = 0; |
194 | $full_name = $ident[$identity]['full_name']; |
195 | $from_mail = $ident[$identity]['email_address']; |
196 | $from_addr = '"'.$full_name.'" <'.$from_mail.'>'; |
197 | $reply_to = $ident[$identity]['reply_to']; |
198 | |
27a1d10a |
199 | if (!$from_mail) { |
200 | $from_mail = "$popuser@$domain"; |
201 | $from_addr = $from_mail; |
fc224f68 |
202 | } |
203 | $rfc822_header->from = $rfc822_header->parseAddress($from_addr,true); |
204 | if ($reply_to) { |
205 | $rfc822_header->reply_to = $rfc822_header->parseAddress($reply_to,true); |
206 | } |
d9c1dccc |
207 | |
57257333 |
208 | // part 1 (RFC2298) |
57257333 |
209 | $senton = getLongDateString( $header->date ); |
210 | $to_array = $header->to; |
211 | $to = ''; |
212 | foreach ($to_array as $line) { |
af568a82 |
213 | $to .= ' '.$line->getAddress(); |
57257333 |
214 | } |
57257333 |
215 | $now = getLongDateString( time() ); |
78db1583 |
216 | set_my_charset(); |
46bb8da8 |
217 | $body = _("Your message") . "\r\n\r\n" . |
d39b7293 |
218 | "\t" . _("To:") . ' ' . decodeHeader($to,false,false) . "\r\n" . |
219 | "\t" . _("Subject:") . ' ' . decodeHeader($header->subject,false,false) . "\r\n" . |
46bb8da8 |
220 | "\t" . _("Sent:") . ' ' . $senton . "\r\n" . |
221 | "\r\n" . |
222 | sprintf( _("Was displayed on %s"), $now ); |
f69feefe |
223 | |
fc224f68 |
224 | $special_encoding = ''; |
225 | if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && |
226 | function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) { |
6fbd125b |
227 | $body = $languages[$squirrelmail_language]['XTRA_CODE']('encode', $body); |
d9c1dccc |
228 | if (strtolower($default_charset) == 'iso-2022-jp') { |
229 | if (mb_detect_encoding($body) == 'ASCII') { |
230 | $special_encoding = '8bit'; |
231 | } else { |
232 | $body = mb_convert_encoding($body, 'JIS'); |
233 | $special_encoding = '7bit'; |
234 | } |
235 | } |
6fbd125b |
236 | } |
fc224f68 |
237 | $part1 = new Message(); |
238 | $part1->setBody($body); |
239 | $mime_header = new MessageHeader; |
240 | $mime_header->type0 = 'text'; |
241 | $mime_header->type1 = 'plain'; |
242 | if ($special_encoding) { |
243 | $mime_header->encoding = $special_encoding; |
d9c1dccc |
244 | } else { |
fc224f68 |
245 | $mime_header->encoding = 'us-ascii'; |
246 | } |
247 | if ($default_charset) { |
248 | $mime_header->parameters['charset'] = $default_charset; |
249 | } |
250 | $part1->mime_header = $mime_header; |
251 | |
57257333 |
252 | // part2 (RFC2298) |
d9c1dccc |
253 | $original_recipient = $to; |
57257333 |
254 | $original_message_id = $header->message_id; |
255 | |
fc224f68 |
256 | $report = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n"; |
57257333 |
257 | if ($original_recipient != '') { |
fc224f68 |
258 | $report .= "Original-Recipient : $original_recipient\r\n"; |
57257333 |
259 | } |
260 | $final_recipient = $sender; |
fc224f68 |
261 | $report .= "Final-Recipient: rfc822; $final_recipient\r\n" . |
57257333 |
262 | "Original-Message-ID : $original_message_id\r\n" . |
263 | "Disposition: manual-action/MDN-sent-manually; displayed\r\n"; |
264 | |
fc224f68 |
265 | $part2 = new Message(); |
266 | $part2->setBody($report); |
267 | $mime_header = new MessageHeader; |
268 | $mime_header->type0 = 'message'; |
269 | $mime_header->type1 = 'disposition-notification'; |
270 | $mime_header->encoding = 'us-ascii'; |
271 | $part2->mime_header = $mime_header; |
272 | |
273 | $composeMessage = new Message(); |
274 | $composeMessage->rfc822_header = $rfc822_header; |
275 | $composeMessage->addEntity($part1); |
276 | $composeMessage->addEntity($part2); |
277 | |
278 | |
d9c1dccc |
279 | if ($useSendmail) { |
280 | require_once(SM_PATH . 'class/deliver/Deliver_SendMail.class.php'); |
281 | global $sendmail_path; |
282 | $deliver = new Deliver_SendMail(); |
283 | $stream = $deliver->initStream($composeMessage,$sendmail_path); |
fc224f68 |
284 | } else { |
d9c1dccc |
285 | require_once(SM_PATH . 'class/deliver/Deliver_SMTP.class.php'); |
286 | $deliver = new Deliver_SMTP(); |
47a29326 |
287 | global $smtpServerAddress, $smtpPort, $smtp_auth_mech, $pop_before_smtp; |
d9c1dccc |
288 | $authPop = (isset($pop_before_smtp) && $pop_before_smtp) ? true : false; |
9bd3b1e6 |
289 | get_smtp_user($user, $pass); |
d9c1dccc |
290 | $stream = $deliver->initStream($composeMessage,$domain,0, |
70ce2218 |
291 | $smtpServerAddress, $smtpPort, $user, $pass, $authPop); |
d9c1dccc |
292 | } |
293 | $success = false; |
fc224f68 |
294 | if ($stream) { |
d9c1dccc |
295 | $length = $deliver->mail($composeMessage, $stream); |
296 | $success = $deliver->finalizeStream($stream); |
fc224f68 |
297 | } |
d9c1dccc |
298 | if (!$success) { |
00ac2f42 |
299 | $msg = $deliver->dlv_msg . '<br>' . |
300 | _("Server replied: ") . $deliver->dlv_ret_nr . ' '. |
301 | $deliver->dlv_server_msg; |
d9c1dccc |
302 | require_once(SM_PATH . 'functions/display_messages.php'); |
fc224f68 |
303 | plain_error_message($msg, $color); |
304 | } else { |
305 | unset ($deliver); |
d9c1dccc |
306 | if (sqimap_mailbox_exists ($imapConnection, $sent_folder)) { |
307 | sqimap_append ($imapConnection, $sent_folder, $length); |
308 | require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php'); |
309 | $imap_deliver = new Deliver_IMAP(); |
310 | $imap_deliver->mail($composeMessage, $imapConnection); |
311 | sqimap_append_done ($imapConnection); |
312 | unset ($imap_deliver); |
313 | } |
314 | } |
315 | return $success; |
57257333 |
316 | } |
317 | |
6201339c |
318 | function ToggleMDNflag ($set ,$imapConnection, $mailbox, $passed_id) { |
d9c1dccc |
319 | $sg = $set?'+':'-'; |
320 | $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)'; |
0892e427 |
321 | $read = sqimap_run_command ($imapConnection, $cmd, true, $response, |
6201339c |
322 | $readmessage, TRUE); |
57257333 |
323 | } |
324 | |
325 | function ClearAttachments() { |
d9c1dccc |
326 | global $username, $attachments, $attachment_dir; |
327 | |
328 | $hashed_attachment_dir = getHashedDir($username, $attachment_dir); |
329 | |
330 | $rem_attachments = array(); |
6191bcb1 |
331 | if (isset($attachments)) { |
332 | foreach ($attachments as $info) { |
333 | if ($info['session'] == -1) { |
334 | $attached_file = "$hashed_attachment_dir/$info[localfilename]"; |
335 | if (file_exists($attached_file)) { |
336 | unlink($attached_file); |
337 | } |
338 | } else { |
339 | $rem_attachments[] = $info; |
340 | } |
341 | } |
d9c1dccc |
342 | } |
343 | $attachments = $rem_attachments; |
57257333 |
344 | } |
345 | |
4d0cd98b |
346 | function formatRecipientString($recipients, $item ) { |
d9c1dccc |
347 | global $show_more_cc, $show_more, $show_more_bcc, |
348 | $PHP_SELF; |
4d0cd98b |
349 | |
d9c1dccc |
350 | $string = ''; |
38c944cc |
351 | if ((is_array($recipients)) && (isset($recipients[0]))) { |
d9c1dccc |
352 | $show = false; |
38c944cc |
353 | |
354 | if ($item == 'to') { |
d9c1dccc |
355 | if ($show_more) { |
356 | $show = true; |
357 | $url = set_url_var($PHP_SELF, 'show_more',0); |
358 | } else { |
359 | $url = set_url_var($PHP_SELF, 'show_more',1); |
360 | } |
361 | } else if ($item == 'cc') { |
362 | if ($show_more_cc) { |
363 | $show = true; |
364 | $url = set_url_var($PHP_SELF, 'show_more_cc',0); |
365 | } else { |
366 | $url = set_url_var($PHP_SELF, 'show_more_cc',1); |
367 | } |
368 | } else if ($item == 'bcc') { |
369 | if ($show_more_bcc) { |
370 | $show = true; |
371 | $url = set_url_var($PHP_SELF, 'show_more_bcc',0); |
372 | } else { |
373 | $url = set_url_var($PHP_SELF, 'show_more_bcc',1); |
374 | } |
375 | } |
376 | |
377 | $cnt = count($recipients); |
378 | foreach($recipients as $r) { |
a91189d6 |
379 | $add = decodeHeader($r->getAddress(true)); |
d9c1dccc |
380 | if ($string) { |
381 | $string .= '<BR>' . $add; |
382 | } else { |
383 | $string = $add; |
384 | if ($cnt > 1) { |
38c944cc |
385 | $string .= ' (<A HREF="'.$url; |
d9c1dccc |
386 | if ($show) { |
387 | $string .= '">'._("less").'</A>)'; |
388 | } else { |
389 | $string .= '">'._("more").'</A>)'; |
390 | break; |
391 | } |
392 | } |
393 | } |
1fca12b5 |
394 | } |
4d0cd98b |
395 | } |
c615b1da |
396 | return $string; |
397 | } |
398 | |
af568a82 |
399 | function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message, |
400 | $color, $FirstTimeSee) { |
a94c1db1 |
401 | global $msn_user_support, $default_use_mdn, $default_use_priority, |
77836429 |
402 | $show_xmailer_default, $mdn_user_support, $PHP_SELF, $javascript_on, |
403 | $squirrelmail_language; |
38bca81c |
404 | |
d9c1dccc |
405 | $header = $message->rfc822_header; |
406 | $env = array(); |
bdb9ce72 |
407 | $env[_("Subject")] = str_replace(" "," ",decodeHeader($header->subject)); |
7893c8a5 |
408 | |
d9c1dccc |
409 | $from_name = $header->getAddr_s('from'); |
d6b6d221 |
410 | if (!$from_name) |
d9c1dccc |
411 | $from_name = $header->getAddr_s('sender'); |
d6b6d221 |
412 | if (!$from_name) |
413 | $env[_("From")] = _("Unknown sender"); |
414 | else |
415 | $env[_("From")] = decodeHeader($from_name); |
d9c1dccc |
416 | $env[_("Date")] = getLongDateString($header->date); |
417 | $env[_("To")] = formatRecipientString($header->to, "to"); |
418 | $env[_("Cc")] = formatRecipientString($header->cc, "cc"); |
419 | $env[_("Bcc")] = formatRecipientString($header->bcc, "bcc"); |
420 | if ($default_use_priority) { |
0e8006dc |
421 | $env[_("Priority")] = htmlspecialchars(getPriorityStr($header->priority)); |
d9c1dccc |
422 | } |
423 | if ($show_xmailer_default) { |
a91189d6 |
424 | $env[_("Mailer")] = decodeHeader($header->xmailer); |
d9c1dccc |
425 | } |
426 | if ($default_use_mdn) { |
427 | if ($mdn_user_support) { |
428 | if ($header->dnt) { |
429 | if ($message->is_mdnsent) { |
509ce88e |
430 | $env[_("Read receipt")] = _("sent"); |
d9c1dccc |
431 | } else { |
432 | $env[_("Read receipt")] = _("requested"); |
8e1d27aa |
433 | if (!(handleAsSent($mailbox) || |
d9c1dccc |
434 | $message->is_deleted || |
435 | $passed_ent_id)) { |
436 | $mdn_url = $PHP_SELF . '&sendreceipt=1'; |
437 | if ($FirstTimeSee && $javascript_on) { |
438 | $script = '<script language="JavaScript" type="text/javascript">' . "\n"; |
439 | $script .= '<!--'. "\n"; |
440 | $script .= 'if(window.confirm("' . |
441 | _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") . |
442 | '")) { '."\n" . |
443 | ' sendMDN()'. |
444 | '}' . "\n"; |
445 | $script .= '// -->'. "\n"; |
446 | $script .= '</script>'. "\n"; |
447 | echo $script; |
448 | } |
449 | $env[_("Read receipt")] .= ' <a href="' . $mdn_url . '">[' . |
450 | _("Send read receipt now") . ']</a>'; |
451 | } |
452 | } |
453 | } |
454 | } |
455 | } |
c615b1da |
456 | |
a94c1db1 |
457 | $s = '<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="2" BORDER="0"'; |
0e02d604 |
458 | $s .= ' ALIGN="center" BGCOLOR="'.$color[0].'">'; |
d9c1dccc |
459 | foreach ($env as $key => $val) { |
460 | if ($val) { |
461 | $s .= '<TR>'; |
462 | $s .= html_tag('TD', '<B>' . $key . ': </B>', 'RIGHT', '', 'VALIGN="TOP" WIDTH="20%"') . "\n"; |
463 | $s .= html_tag('TD', $val, 'left', '', 'VALIGN="TOP" WIDTH="80%"') . "\n"; |
464 | $s .= '</TR>'; |
465 | } |
466 | } |
a94c1db1 |
467 | echo '<TABLE BGCOLOR="'.$color[9].'" WIDTH="100%" CELLPADDING="1"'. |
da9a8410 |
468 | ' CELLSPACING="0" BORDER="0" ALIGN="center">'."\n"; |
a94c1db1 |
469 | echo '<TR><TD HEIGHT="5" COLSPAN="2" BGCOLOR="'. |
470 | $color[4].'"></TD></TR><TR><TD align=center>'."\n"; |
d9c1dccc |
471 | echo $s; |
00ac2f42 |
472 | do_hook('read_body_header'); |
d9c1dccc |
473 | formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color); |
474 | echo '</TABLE>'; |
a94c1db1 |
475 | echo '</TD></TR><TR><TD HEIGHT="5" COLSPAN="2" BGCOLOR="'.$color[4].'"></TD></TR>'."\n"; |
feb5ec1b |
476 | echo '</TABLE>'; |
d9c1dccc |
477 | } |
c615b1da |
478 | |
1e150c97 |
479 | /** |
480 | * Format message toolbar |
481 | * |
482 | * @param string $mailbox Name of current mailbox |
483 | * @param int $passed_id UID of current message |
484 | * @param int $passed_ent_id Id of entity within message |
485 | * @param object $message Current message object |
486 | * @param object $mbx_response |
487 | */ |
488 | function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response, $nav_on_top = TRUE) { |
a94c1db1 |
489 | global $base_uri, $draft_folder, $where, $what, $color, $sort, |
6201339c |
490 | $startMessage, $PHP_SELF, $save_as_draft, |
1e150c97 |
491 | $enable_forward_as_attachment, $imapConnection, $lastTargetMailbox, |
1a531551 |
492 | $data_dir, $username, $delete_prev_next_display, |
493 | $compose_new_win, $javascript_on; |
c615b1da |
494 | |
d9c1dccc |
495 | $topbar_delimiter = ' | '; |
1e150c97 |
496 | $double_delimiter = ' '; |
d9c1dccc |
497 | $urlMailbox = urlencode($mailbox); |
c615b1da |
498 | |
1e150c97 |
499 | $msgs_url = $base_uri . 'src/'; |
2ffa3f57 |
500 | |
1e150c97 |
501 | // BEGIN NAV ROW - PREV/NEXT, DEL PREV/NEXT, LINKS TO INDEX, etc. |
45c1ed84 |
502 | $nav_row = '<tr><td align="left" colspan="2" style="border: 1px solid '.$color[9].';"><small>'; |
e55c441a |
503 | |
1e150c97 |
504 | // Create Prev & Next links |
505 | // Handle nested entities first (i.e. Mime Attach parts) |
506 | if (isset($passed_ent_id) && $passed_ent_id) { |
507 | // code for navigating through attached message/rfc822 messages |
d9c1dccc |
508 | $url = set_url_var($PHP_SELF, 'passed_ent_id',0); |
70bdc740 |
509 | $entities = array(); |
510 | $entity_count = array(); |
511 | $c = 0; |
f2f03410 |
512 | |
70bdc740 |
513 | foreach($message->parent->entities as $ent) { |
9f42bfc8 |
514 | if ($ent->type0 == 'message' && $ent->type1 == 'rfc822') { |
515 | $c++; |
516 | $entity_count[$c] = $ent->entity_id; |
517 | $entities[$ent->entity_id] = $c; |
518 | } |
70bdc740 |
519 | } |
1e150c97 |
520 | |
70bdc740 |
521 | $prev_link = _("Previous"); |
70bdc740 |
522 | if($entities[$passed_ent_id] > 1) { |
523 | $prev_ent_id = $entity_count[$entities[$passed_ent_id] - 1]; |
524 | $prev_link = '<a href="' |
525 | . set_url_var($PHP_SELF, 'passed_ent_id', $prev_ent_id) |
526 | . '">' . $prev_link . '</a>'; |
527 | } |
1e150c97 |
528 | |
529 | $next_link = _("Next"); |
70bdc740 |
530 | if($entities[$passed_ent_id] < $c) { |
531 | $next_ent_id = $entity_count[$entities[$passed_ent_id] + 1]; |
532 | $next_link = '<a href="' |
533 | . set_url_var($PHP_SELF, 'passed_ent_id', $next_ent_id) |
534 | . '">' . $next_link . '</a>'; |
535 | } |
1e150c97 |
536 | |
d9c1dccc |
537 | $par_ent_id = $message->parent->entity_id; |
1e150c97 |
538 | $up_link = ''; |
d9c1dccc |
539 | if ($par_ent_id) { |
540 | $par_ent_id = substr($par_ent_id,0,-2); |
1e150c97 |
541 | if ( $par_ent_id != 0 ) { |
542 | $up_link = $topbar_delimiter; |
543 | $url = set_url_var($PHP_SELF, 'passed_ent_id',$par_ent_id); |
544 | $up_link .= '<a href="'.$url.'">'._("Up").'</a>'; |
545 | } |
546 | } |
547 | |
548 | $nav_row .= $prev_link . $up_link . $topbar_delimiter . $next_link; |
abafb676 |
549 | $nav_row .= $double_delimiter . '[<a href="'.$url.'">'._("View Message").'</a>]'; |
1e150c97 |
550 | |
551 | // Prev/Next links for regular messages |
552 | } else if ( !(isset($where) && isset($what)) ) { |
553 | $prev = findPreviousMessage($mbx_response['EXISTS'], $passed_id); |
554 | $next = findNextMessage($passed_id); |
555 | |
556 | $prev_link = _("Previous"); |
557 | if ($prev >= 0) { |
558 | $uri = $base_uri . 'src/read_body.php?passed_id='.$prev. |
559 | '&mailbox='.$urlMailbox.'&sort='.$sort. |
560 | '&startMessage='.$startMessage.'&show_more=0'; |
561 | $prev_link = '<a href="'.$uri.'">'.$prev_link.'</a>'; |
d9c1dccc |
562 | } |
1e150c97 |
563 | |
564 | $next_link = _("Next"); |
565 | if ($next >= 0) { |
566 | $uri = $base_uri . 'src/read_body.php?passed_id='.$next. |
567 | '&mailbox='.$urlMailbox.'&sort='.$sort. |
568 | '&startMessage='.$startMessage.'&show_more=0'; |
569 | $next_link = '<a href="'.$uri.'">'.$next_link.'</a>'; |
570 | } |
571 | |
1e150c97 |
572 | // Only bother with Delete & Prev and Delete & Next IF |
6201339c |
573 | // top display is enabled. |
574 | if ( $delete_prev_next_display == 1 ) { |
45c1ed84 |
575 | $del_prev_link = _("Delete & Prev"); |
1e150c97 |
576 | if ($prev >= 0) { |
577 | $uri = $base_uri . 'src/read_body.php?passed_id='.$prev. |
578 | '&mailbox='.$urlMailbox.'&sort='.$sort. |
579 | '&startMessage='.$startMessage.'&show_more=0'. |
580 | '&delete_id='.$passed_id; |
45c1ed84 |
581 | $del_prev_link = '<a href="'.$uri.'">'.$del_prev_link.'</a>'; |
1e150c97 |
582 | } |
583 | |
45c1ed84 |
584 | $del_next_link = _("Delete & Next"); |
1e150c97 |
585 | if ($next >= 0) { |
586 | $uri = $base_uri . 'src/read_body.php?passed_id='.$next. |
587 | '&mailbox='.$urlMailbox.'&sort='.$sort. |
588 | '&startMessage='.$startMessage.'&show_more=0'. |
589 | '&delete_id='.$passed_id; |
45c1ed84 |
590 | $del_next_link = '<a href="'.$uri.'">'.$del_next_link.'</a>'; |
1e150c97 |
591 | } |
1e150c97 |
592 | } |
45c1ed84 |
593 | |
abafb676 |
594 | $nav_row .= '['.$prev_link.$topbar_delimiter.$next_link.']'; |
595 | if ( isset($del_prev_link) && isset($del_next_link) ) |
596 | $nav_row .= $double_delimiter.'['.$del_prev_link.$topbar_delimiter.$del_next_link.']'; |
1e150c97 |
597 | } |
598 | |
599 | // Start with Search Results or Message List link. |
600 | if (isset($where) && isset($what)) { |
601 | $msgs_url .= 'search.php?where=' . urlencode($where) . |
602 | '&what=' . urlencode($what) . '&mailbox=' . $urlMailbox; |
603 | $msgs_str = _("Search Results"); |
604 | } else { |
605 | $msgs_url .= 'right_main.php?sort=' . $sort . '&startMessage=' . |
606 | $startMessage . '&mailbox=' . $urlMailbox; |
607 | $msgs_str = _("Message List"); |
608 | } |
609 | $nav_row .= $double_delimiter . |
abafb676 |
610 | '[<a href="' . $msgs_url . '">' . $msgs_str . '</a>]'; |
1e150c97 |
611 | |
612 | $nav_row .= '</small></td></tr>'; |
613 | |
614 | |
615 | // BEGIN MENU ROW - DELETE/REPLY/FORWARD/MOVE/etc. |
616 | $menu_row = '<tr bgcolor="'.$color[9].'"><td><small>'; |
98a9cc03 |
617 | $comp_uri = $base_uri.'src/compose.php' . |
618 | '?passed_id=' . $passed_id . |
619 | '&mailbox=' . $urlMailbox . |
620 | '&startMessage=' . $startMessage . |
621 | (isset($passed_ent_id) ? '&passed_ent_id='.$passed_ent_id : ''); |
1a531551 |
622 | |
623 | // Start form for reply/reply all/forward.. |
624 | $target = ''; |
625 | $on_click=''; |
626 | $method='method="get" '; |
627 | if ($compose_new_win == '1') { |
628 | if ( $javascript_on ) { |
629 | $on_click=' onclick="comp_in_new_form(\''.$comp_uri.'\', this, this.form)"'; |
630 | $comp_uri = 'javascript:void(0)'; |
631 | } else { |
632 | $target = 'target="_blank"'; |
633 | $method='method="post" '; |
634 | } |
635 | } |
636 | |
637 | $menu_row .= "\n".'<form name="composeForm" action="'.$comp_uri.'" '.$method.$target.'><small>'."\n"; |
98a9cc03 |
638 | |
1e150c97 |
639 | // If Draft folder - create Resume link |
640 | if (($mailbox == $draft_folder) && ($save_as_draft)) { |
1a531551 |
641 | $new_button = 'smaction_draft'; |
1e150c97 |
642 | $comp_alt_string = _("Resume Draft"); |
643 | } else if (handleAsSent($mailbox)) { |
644 | // If in Sent folder, edit as new |
1a531551 |
645 | $new_button = 'smaction_edit_new'; |
1e150c97 |
646 | $comp_alt_string = _("Edit Message as New"); |
647 | } |
1e150c97 |
648 | // Show Alt URI for Draft/Sent |
98a9cc03 |
649 | if (isset($comp_alt_string)) |
1a531551 |
650 | $menu_row .= getButton('SUBMIT', $new_button, $comp_alt_string, $on_click) . "\n"; |
1e150c97 |
651 | |
1a531551 |
652 | $menu_row .= getButton('SUBMIT', 'smaction_reply', _("Reply"), $on_click) . "\n"; |
653 | $menu_row .= getButton('SUBMIT', 'smaction_reply_all', _("Reply All"), $on_click) ."\n"; |
654 | $menu_row .= getButton('SUBMIT', 'smaction_forward', _("Forward"), $on_click); |
98a9cc03 |
655 | if ($enable_forward_as_attachment) |
1a531551 |
656 | $menu_row .= '<input type="checkbox" name="smaction_attache">' . _("Attachment") ."\n"; |
1e150c97 |
657 | |
1a531551 |
658 | $menu_row .= '</form>'.' '."\n"; |
c615b1da |
659 | |
98a9cc03 |
660 | // Form for deletion |
661 | $delete_url = $base_uri . 'src/delete_message.php?mailbox=' . $urlMailbox; |
662 | $menu_row .= '<form action="'.$delete_url.'" method="post" style="display: inline"><small>'; |
a128c967 |
663 | |
abafb676 |
664 | if (!(isset($passed_ent_id) && $passed_ent_id)) { |
98a9cc03 |
665 | $menu_row .= '<input type="hidden" name="message" value="'.$passed_id.'" />'; |
abafb676 |
666 | |
667 | if ($where && $what) { |
98a9cc03 |
668 | $menu_row .= '<input type="hidden" name="where" value="'.$where.'" />'; |
669 | $menu_row .= '<input type="hidden" name="what" value="'.$what.'" />'; |
abafb676 |
670 | } else { |
98a9cc03 |
671 | $menu_row .= '<input type="hidden" name="sort" value="'.$sort.'" />'; |
672 | $menu_row .= '<input type="hidden" name="startMessage" value="'.$startMessage.'" />'; |
abafb676 |
673 | } |
98a9cc03 |
674 | $menu_row .= getButton('SUBMIT', 'delete', _("Delete")); |
675 | $menu_row .= '<input type="checkbox" name="bypass_trash">' . _("Bypass Trash"); |
abafb676 |
676 | } |
98a9cc03 |
677 | else |
1a531551 |
678 | $menu_row .= getButton('SUBMIT', 'delete', _("Delete"), '', FALSE) . "\n"; // delete button is disabled |
98a9cc03 |
679 | |
680 | $menu_row .= '</form>' . "\n"; |
abafb676 |
681 | |
682 | |
1e150c97 |
683 | // Add top move link |
684 | $menu_row .= '</small></td><td align="right">'; |
b2811304 |
685 | if ( !(isset($passed_ent_id) && $passed_ent_id) ) { |
b2811304 |
686 | |
687 | $current_box = 'mailbox='.$mailbox.'&sort='.$sort.'&startMessage='.$startMessage; |
1c13663f |
688 | |
689 | // Set subsequent location based on whether or not there is a 'next' message. |
b2811304 |
690 | if ( isset($next) && $next >= 0 ) { |
1c13663f |
691 | $location = $base_uri . 'src/read_body.php?passed_id='.$next.'&'; |
b2811304 |
692 | } else { |
1c13663f |
693 | $location = $base_uri . 'src/right_main.php?'; |
b2811304 |
694 | } |
b2811304 |
695 | |
1c13663f |
696 | $menu_row .= '<form action="'.$base_uri.'src/move_messages.php?'.$current_box.'" method="post">'. |
1e150c97 |
697 | '<small><input type="hidden" name="show_more" value="0" />'. |
1c13663f |
698 | '<input type="hidden" name="location" value="'.$location.$current_box.'" />'. |
b2811304 |
699 | '<input type="hidden" name="msg[0]" value="'.$passed_id.'" />'._("Move to:") . |
1e150c97 |
700 | '<select name="targetMailbox" style="padding: 0px; margin: 0px">'; |
b2811304 |
701 | |
1e150c97 |
702 | if (isset($lastTargetMailbox) && !empty($lastTargetMailbox)) { |
703 | $menu_row .= sqimap_mailbox_option_list($imapConnection, array(strtolower($lastTargetMailbox))); |
704 | } else { |
705 | $menu_row .= sqimap_mailbox_option_list($imapConnection); |
706 | } |
b2811304 |
707 | $menu_row .= '</select> '; |
708 | |
b2811304 |
709 | $menu_row .= getButton('SUBMIT', 'moveButton',_("Move")) . "\n" . '</form>'; |
1e150c97 |
710 | } |
711 | $menu_row .= '</td></tr>'; |
d9c1dccc |
712 | |
1e150c97 |
713 | // echo rows, with hooks |
764971df |
714 | $ret = do_hook_function('read_body_menu_top', array($nav_row, $menu_row)); |
988e24f6 |
715 | if (is_array($ret)) { |
716 | if (isset($ret[0]) && !empty($ret[0])) { |
717 | $nav_row = $ret[0]; |
718 | } |
719 | if (isset($ret[1]) && !empty($ret[1])) { |
720 | $menu_row = $ret[1]; |
721 | } |
764971df |
722 | } |
1e150c97 |
723 | echo '<table width="100%" cellpadding="3" cellspacing="0" align="center" border="0">'; |
724 | echo $nav_on_top ? $nav_row . $menu_row : $menu_row . $nav_row; |
725 | echo '</table>'."\n"; |
d62c4938 |
726 | do_hook('read_body_menu_bottom'); |
c615b1da |
727 | } |
728 | |
729 | function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) { |
a94c1db1 |
730 | global $base_uri; |
fe369c70 |
731 | |
d9c1dccc |
732 | $urlMailbox = urlencode($mailbox); |
e95c04ec |
733 | sqgetGlobalVar('QUERY_STRING', $query_string, SQ_SERVER); |
734 | $url = $base_uri.'src/view_header.php?'.$query_string; |
d9c1dccc |
735 | |
a94c1db1 |
736 | $s = "<TR>\n" . |
98fb28fd |
737 | html_tag( 'td', '', 'right', '', 'VALIGN="MIDDLE" WIDTH="20%"' ) . '<B>' . _("Options") . ": </B></TD>\n" . |
738 | html_tag( 'td', '', 'left', '', 'VALIGN="MIDDLE" WIDTH="80%"' ) . '<SMALL>' . |
d9c1dccc |
739 | '<a href="'.$url.'">'._("View Full Header").'</a>'; |
740 | |
741 | /* Output the printer friendly link if we are in subtle mode. */ |
742 | $s .= ' | ' . |
1e150c97 |
743 | printer_friendly_link($mailbox, $passed_id, $passed_ent_id); |
d9c1dccc |
744 | echo $s; |
745 | do_hook("read_body_header_right"); |
746 | $s = "</SMALL></TD>\n" . |
747 | "</TR>\n"; |
748 | echo $s; |
a128c967 |
749 | |
4d0cd98b |
750 | } |
751 | |
6206f6c4 |
752 | /***************************/ |
2ffa3f57 |
753 | /* Main of read_body.php */ |
6206f6c4 |
754 | /***************************/ |
57257333 |
755 | |
0b97a708 |
756 | /* get the globals we may need */ |
757 | |
1e12d1ff |
758 | sqgetGlobalVar('key', $key, SQ_COOKIE); |
e95c04ec |
759 | sqgetGlobalVar('username', $username, SQ_SESSION); |
760 | sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION); |
e95c04ec |
761 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); |
1e12d1ff |
762 | sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION); |
763 | |
e95c04ec |
764 | sqgetGlobalVar('msgs', $msgs, SQ_SESSION); |
765 | sqgetGlobalVar('msort', $msort, SQ_SESSION); |
766 | sqgetGlobalVar('lastTargetMailbox', $lastTargetMailbox, SQ_SESSION); |
767 | sqgetGlobalVar('server_sort_array', $server_sort_array, SQ_SESSION); |
768 | if (!sqgetGlobalVar('messages', $messages, SQ_SESSION) ) { |
769 | $messages = array(); |
ce274df9 |
770 | } |
771 | |
e95c04ec |
772 | /** GET VARS */ |
773 | sqgetGlobalVar('sendreceipt', $sendreceipt, SQ_GET); |
774 | sqgetGlobalVar('where', $where, SQ_GET); |
775 | sqgetGlobalVar('what', $what, SQ_GET); |
776 | if ( sqgetGlobalVar('show_more', $temp, SQ_GET) ) { |
777 | $show_more = (int) $temp; |
1b9f3c04 |
778 | } |
e95c04ec |
779 | if ( sqgetGlobalVar('show_more_cc', $temp, SQ_GET) ) { |
780 | $show_more_cc = (int) $temp; |
0b97a708 |
781 | } |
e95c04ec |
782 | if ( sqgetGlobalVar('show_more_bcc', $temp, SQ_GET) ) { |
783 | $show_more_bcc = (int) $temp; |
0b97a708 |
784 | } |
e95c04ec |
785 | if ( sqgetGlobalVar('view_hdr', $temp, SQ_GET) ) { |
786 | $view_hdr = (int) $temp; |
0b97a708 |
787 | } |
e95c04ec |
788 | |
e95c04ec |
789 | /** GET/POST VARS */ |
790 | sqgetGlobalVar('passed_ent_id', $passed_ent_id); |
791 | sqgetGlobalVar('mailbox', $mailbox); |
792 | |
793 | if ( sqgetGlobalVar('passed_id', $temp) ) { |
794 | $passed_id = (int) $temp; |
0b97a708 |
795 | } |
e95c04ec |
796 | if ( sqgetGlobalVar('sort', $temp) ) { |
797 | $sort = (int) $temp; |
0b97a708 |
798 | } |
e95c04ec |
799 | if ( sqgetGlobalVar('startMessage', $temp) ) { |
800 | $startMessage = (int) $temp; |
ce274df9 |
801 | } |
0b97a708 |
802 | |
ce274df9 |
803 | /* end of get globals */ |
6201339c |
804 | global $sqimap_capabilities, $lastTargetMailbox; |
38c944cc |
805 | |
6206f6c4 |
806 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
9f42bfc8 |
807 | $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true); |
38c944cc |
808 | |
1e150c97 |
809 | /** |
810 | * Process Delete from delete-move-next |
811 | * but only if delete_id was set |
812 | */ |
813 | if ( sqgetGlobalVar('delete_id', $delete_id, SQ_GET) ) { |
653ff1e6 |
814 | sqimap_messages_delete($imapConnection, $delete_id, $delete_id, $mailbox); |
1e150c97 |
815 | |
653ff1e6 |
816 | sqimap_mailbox_expunge_dmn($delete_id); |
1e150c97 |
817 | } |
818 | |
38c944cc |
819 | /** |
820 | * $message contains all information about the message |
821 | * including header and body |
822 | */ |
37d2a6ee |
823 | |
824 | $uidvalidity = $mbx_response['UIDVALIDITY']; |
9f42bfc8 |
825 | |
37d2a6ee |
826 | if (!isset($messages[$uidvalidity])) { |
827 | $messages[$uidvalidity] = array(); |
9f42bfc8 |
828 | } |
6201339c |
829 | if (!isset($messages[$uidvalidity][$passed_id])) { |
5200c026 |
830 | $message = sqimap_get_message($imapConnection, $passed_id, $mailbox); |
fc224f68 |
831 | $FirstTimeSee = !$message->is_seen; |
832 | $message->is_seen = true; |
5200c026 |
833 | $messages[$uidvalidity][$passed_id] = $message; |
38c944cc |
834 | } else { |
fc224f68 |
835 | // $message = sqimap_get_message($imapConnection, $passed_id, $mailbox); |
836 | $message = $messages[$uidvalidity][$passed_id]; |
837 | $FirstTimeSee = !$message->is_seen; |
5200c026 |
838 | } |
af568a82 |
839 | |
dd628162 |
840 | if (isset($passed_ent_id) && $passed_ent_id) { |
5200c026 |
841 | $message = $message->getEntity($passed_ent_id); |
ff9d4297 |
842 | if ($message->type0 != 'message' && $message->type1 != 'rfc822') { |
843 | $message = $message->parent; |
844 | } |
6201339c |
845 | $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[$passed_ent_id.HEADER]", true, $response, $msg, TRUE); |
19d470aa |
846 | $rfc822_header = new Rfc822Header(); |
141a16b2 |
847 | $rfc822_header->parseHeader($read); |
848 | $message->rfc822_header = $rfc822_header; |
c615b1da |
849 | } else { |
850 | $passed_ent_id = 0; |
38c944cc |
851 | } |
5200c026 |
852 | $header = $message->header; |
57257333 |
853 | |
6c31f818 |
854 | do_hook('html_top'); |
57257333 |
855 | |
6206f6c4 |
856 | /****************************************/ |
857 | /* Block for handling incoming url vars */ |
858 | /****************************************/ |
5200c026 |
859 | |
5200c026 |
860 | if (isset($sendreceipt)) { |
861 | if ( !$message->is_mdnsent ) { |
27a1d10a |
862 | $final_recipient = ''; |
863 | if ((isset($identity)) && ($identity != 0)) //Main identity |
864 | $final_recipient = trim(getPref($data_dir, $username, 'email_address' . $identity, '' )); |
865 | if ($final_recipient == '' ) |
866 | $final_recipient = trim(getPref($data_dir, $username, 'email_address', '' )); |
af568a82 |
867 | $supportMDN = ServerMDNSupport($mbx_response["PERMANENTFLAGS"]); |
fc224f68 |
868 | if ( SendMDN( $mailbox, $passed_id, $final_recipient, $message, $imapConnection ) > 0 && $supportMDN ) { |
6201339c |
869 | ToggleMDNflag( true, $imapConnection, $mailbox, $passed_id); |
5200c026 |
870 | $message->is_mdnsent = true; |
6a108031 |
871 | $messages[$uidvalidity][$passed_id]=$message; |
5200c026 |
872 | } |
873 | ClearAttachments(); |
874 | } |
875 | } |
6206f6c4 |
876 | /***********************************************/ |
877 | /* End of block for handling incoming url vars */ |
878 | /***********************************************/ |
879 | |
38c944cc |
880 | $msgs[$passed_id]['FLAG_SEEN'] = true; |
9f42bfc8 |
881 | |
882 | $messagebody = ''; |
c4ad259b |
883 | do_hook('read_body_top'); |
884 | if ($show_html_default == 1) { |
885 | $ent_ar = $message->findDisplayEntity(array()); |
886 | } else { |
887 | $ent_ar = $message->findDisplayEntity(array(), array('text/plain')); |
888 | } |
a128c967 |
889 | $cnt = count($ent_ar); |
890 | for ($i = 0; $i < $cnt; $i++) { |
6a108031 |
891 | $messagebody .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox); |
a128c967 |
892 | if ($i != $cnt-1) { |
893 | $messagebody .= '<hr noshade size=1>'; |
894 | } |
38c944cc |
895 | } |
e55c441a |
896 | |
c615b1da |
897 | displayPageHeader($color, $mailbox); |
7172cad7 |
898 | formatMenuBar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response); |
af568a82 |
899 | formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee); |
a94c1db1 |
900 | echo '<table width="100%" cellpadding="0" cellspacing="0" align="center" border="0">'; |
6206f6c4 |
901 | echo ' <tr><td>'; |
a94c1db1 |
902 | echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[9].'">'; |
a128c967 |
903 | echo ' <tr><td>'; |
a94c1db1 |
904 | echo ' <table width="100%" cellpadding="3" cellspacing="0" align="center" border="0">'; |
6206f6c4 |
905 | echo ' <tr bgcolor="'.$color[4].'"><td>'; |
98fb28fd |
906 | // echo ' <table cellpadding="1" cellspacing="5" align="left" border="0">'; |
907 | echo html_tag( 'table' ,'' , 'left', '', 'cellpadding="1" cellspacing="5" border="0"' ); |
ce810ea7 |
908 | echo ' <tr>' . html_tag( 'td', '<br>'. $messagebody."\n", 'left') |
6c7b5d8c |
909 | . '</tr>'; |
6206f6c4 |
910 | echo ' </table>'; |
911 | echo ' </td></tr>'; |
912 | echo ' </table></td></tr>'; |
2ffa3f57 |
913 | echo ' </table>'; |
914 | echo ' </td></tr>'; |
a128c967 |
915 | |
d0a2476a |
916 | echo '<TR><TD HEIGHT="5" COLSPAN="2" BGCOLOR="'. |
6c7b5d8c |
917 | $color[4].'"></TD></TR>'."\n"; |
d0a2476a |
918 | |
a128c967 |
919 | $attachmentsdisplay = formatAttachments($message,$ent_ar,$mailbox, $passed_id); |
920 | if ($attachmentsdisplay) { |
8acd2fb5 |
921 | echo ' </table>'; |
6206f6c4 |
922 | echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">'; |
2ffa3f57 |
923 | echo ' <tr><td>'; |
d0a2476a |
924 | echo ' <table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">'; |
98fb28fd |
925 | echo ' <tr>' . html_tag( 'td', '', 'left', $color[9] ); |
6206f6c4 |
926 | echo ' <b>' . _("Attachments") . ':</b>'; |
927 | echo ' </td></tr>'; |
928 | echo ' <tr><td>'; |
929 | echo ' <table width="100%" cellpadding="2" cellspacing="2" align="center"'.' border="0" bgcolor="'.$color[0].'"><tr><td>'; |
930 | echo $attachmentsdisplay; |
931 | echo ' </td></tr></table>'; |
6c7b5d8c |
932 | echo ' </td></tr></table>'; |
6206f6c4 |
933 | echo ' </td></tr>'; |
6c7b5d8c |
934 | echo '<TR><TD HEIGHT="5" COLSPAN="2" BGCOLOR="'. |
935 | $color[4].'"></TD></TR>'; |
a128c967 |
936 | } |
c615b1da |
937 | echo '</table>'; |
a07cd1a4 |
938 | |
939 | /* show attached images inline -- if pref'fed so */ |
5be9f195 |
940 | if (($attachment_common_show_images) && |
a07cd1a4 |
941 | is_array($attachment_common_show_images_list)) { |
942 | foreach ($attachment_common_show_images_list as $img) { |
ce274df9 |
943 | $imgurl = SM_PATH . 'src/download.php' . |
57257333 |
944 | '?' . |
cd7b8833 |
945 | 'passed_id=' . urlencode($img['passed_id']) . |
3d570ba0 |
946 | '&mailbox=' . urlencode($mailbox) . |
ff9d4297 |
947 | '&ent_id=' . urlencode($img['ent_id']) . |
3d570ba0 |
948 | '&absolute_dl=true'; |
5be9f195 |
949 | |
b5058e9e |
950 | echo html_tag( 'table', "\n" . |
d9c1dccc |
951 | html_tag( 'tr', "\n" . |
952 | html_tag( 'td', '<img src="' . $imgurl . '">' ."\n", 'left' |
953 | ) |
954 | ) , |
b5058e9e |
955 | 'center', '', 'cellspacing=0 border="0" cellpadding="2"'); |
10f0ce72 |
956 | } |
a07cd1a4 |
957 | } |
958 | |
4267d5de |
959 | formatMenuBar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response, FALSE); |
1e150c97 |
960 | |
c615b1da |
961 | do_hook('read_body_bottom'); |
962 | do_hook('html_bottom'); |
a07cd1a4 |
963 | sqimap_logout($imapConnection); |
ce274df9 |
964 | /* sessions are written at the end of the script. it's better to register |
965 | them at the end so we avoid double session_register calls */ |
966 | sqsession_register($messages,'messages'); |
e55c441a |
967 | |
dcc1cc82 |
968 | ?> |
969 | </body> |
970 | </html> |