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