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