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