| 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 | |
| 21 | /** |
| 22 | * Given an IMAP message id number, this will look it up in the cached |
| 23 | * and sorted msgs array and return the index. Used for finding the next |
| 24 | * and previous messages. |
| 25 | * |
| 26 | * returns the index of the next valid message from the array |
| 27 | */ |
| 28 | function findNextMessage() { |
| 29 | global $msort, $currentArrayIndex, $msgs, $sort; |
| 30 | $result = -1; |
| 31 | |
| 32 | if ($sort == 6) { |
| 33 | if ($currentArrayIndex != 1) { |
| 34 | $result = $currentArrayIndex - 1; |
| 35 | } |
| 36 | } else { |
| 37 | for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { |
| 38 | if ($currentArrayIndex == $msgs[$key]['ID']) { |
| 39 | next($msort); |
| 40 | $key = key($msort); |
| 41 | if (isset($key)) |
| 42 | $result = $msgs[$key]['ID']; |
| 43 | break; |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | return ($result); |
| 48 | } |
| 49 | |
| 50 | /** Removes just one address from the list of addresses. */ |
| 51 | function RemoveAddress(&$addr_list, $addr) { |
| 52 | if ($addr != '') { |
| 53 | foreach (array_keys($addr_list, $addr) as $key_to_delete) { |
| 54 | unset($addr_list[$key_to_delete]); |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | /** returns the index of the previous message from the array. */ |
| 60 | function findPreviousMessage() { |
| 61 | global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection; |
| 62 | global $mailbox, $data_dir, $username; |
| 63 | $result = -1; |
| 64 | |
| 65 | if ($sort == 6) { |
| 66 | $numMessages = sqimap_get_num_messages($imapConnection, $mailbox); |
| 67 | if ($currentArrayIndex != $numMessages) { |
| 68 | $result = $currentArrayIndex + 1; |
| 69 | } |
| 70 | } else { |
| 71 | for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { |
| 72 | if ($currentArrayIndex == $msgs[$key]['ID']) { |
| 73 | prev($msort); |
| 74 | $key = key($msort); |
| 75 | if (isset($key)) { |
| 76 | $result = $msgs[$key]['ID']; |
| 77 | break; |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | return ($result); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Displays a link to a page where the message is displayed more |
| 87 | * "printer friendly". |
| 88 | */ |
| 89 | function printer_friendly_link() { |
| 90 | global $passed_id, $mailbox, $ent_num, $color; |
| 91 | global $pf_subtle_link; |
| 92 | global $javascript_on; |
| 93 | |
| 94 | if (strlen(trim($mailbox)) < 1) { |
| 95 | $mailbox = 'INBOX'; |
| 96 | } |
| 97 | |
| 98 | $params = '?passed_ent_id=' . $ent_num; |
| 99 | $params .= '&mailbox=' . urlencode($mailbox); |
| 100 | $params .= '&passed_id=' . $passed_id; |
| 101 | |
| 102 | $print_text = _("View Printable Version"); |
| 103 | |
| 104 | if (!$pf_subtle_link) { |
| 105 | /* The link is large, on the bottom of the header panel. */ |
| 106 | $result = ' <tr bgcolor="' . $color[0] . '">' . "\n" . |
| 107 | ' <td class="medText" align="right" valign="top">' . "\n" . |
| 108 | ' ' . "\n" . |
| 109 | ' </td><td class="medText" valign="top" colspan="2">'."\n"; |
| 110 | } else { |
| 111 | /* The link is subtle, below "view full header". */ |
| 112 | $result = "<BR>\n"; |
| 113 | } |
| 114 | |
| 115 | /* Output the link. */ |
| 116 | if ($javascript_on) { |
| 117 | $result .= '<script language="javascript">' . "\n" . |
| 118 | '<!--' . "\n" . |
| 119 | " function printFormat() {\n" . |
| 120 | ' window.open("../src/printer_friendly_main.php' . |
| 121 | $params . '","Print","width=800,height=600");' . "\n". |
| 122 | " }\n" . |
| 123 | "// -->\n" . |
| 124 | "</script>\n" . |
| 125 | "<A HREF=\"javascript:printFormat();\">$print_text</A>\n"; |
| 126 | } else { |
| 127 | $result .= '<A TARGET="_blank" HREF="../src/printer_friendly_bottom.php' . |
| 128 | "$params\">$print_text</A>\n"; |
| 129 | } |
| 130 | |
| 131 | if (!$pf_subtle_link) { |
| 132 | /* The link is large, on the bottom of the header panel. */ |
| 133 | $result .= ' </td>' . "\n" . |
| 134 | ' </tr>' . "\n"; |
| 135 | } |
| 136 | |
| 137 | return ($result); |
| 138 | } |
| 139 | |
| 140 | /*****************************/ |
| 141 | /*** Main of read_boby.php ***/ |
| 142 | /*****************************/ |
| 143 | |
| 144 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
| 145 | sqimap_mailbox_select($imapConnection, $mailbox); |
| 146 | do_hook('html_top'); |
| 147 | displayPageHeader($color, $mailbox); |
| 148 | |
| 149 | if (isset($view_hdr)) { |
| 150 | $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]", true, $a, $b); |
| 151 | |
| 152 | echo '<BR>' . |
| 153 | '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0" ALIGN="CENTER">' . "\n" . |
| 154 | " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\"><CENTER><B>" . _("Viewing Full Header") . '</B> - '. |
| 155 | '<a href="' . $base_uri . "src/read_body.php?mailbox=".urlencode($mailbox); |
| 156 | if (isset($where) && isset($what)) { |
| 157 | // Got here from a search |
| 158 | echo "&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what).'">'; |
| 159 | } else { |
| 160 | echo "&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more\">"; |
| 161 | } |
| 162 | echo ''._("View message") . "</a></b></center></td></tr></table>\n" . |
| 163 | "<table width=\"99%\" cellpadding=2 cellspacing=0 border=0 align=center>\n" . |
| 164 | '<tr><td>'; |
| 165 | |
| 166 | $cnum = 0; |
| 167 | for ($i=1; $i < count($read); $i++) { |
| 168 | $line = htmlspecialchars($read[$i]); |
| 169 | if (eregi("^>", $line)) { |
| 170 | $second[$i] = $line; |
| 171 | $first[$i] = ' '; |
| 172 | $cnum++; |
| 173 | } else if (eregi("^[ |\t]", $line)) { |
| 174 | $second[$i] = $line; |
| 175 | $first[$i] = ''; |
| 176 | } else if (eregi("^([^:]+):(.+)", $line, $regs)) { |
| 177 | $first[$i] = $regs[1] . ':'; |
| 178 | $second[$i] = $regs[2]; |
| 179 | $cnum++; |
| 180 | } else { |
| 181 | $second[$i] = trim($line); |
| 182 | $first[$i] = ''; |
| 183 | } |
| 184 | } |
| 185 | for ($i=0; $i < count($second); $i = $j) { |
| 186 | if (isset($first[$i])) { |
| 187 | $f = $first[$i]; |
| 188 | } |
| 189 | if (isset($second[$i])) { |
| 190 | $s = nl2br($second[$i]); |
| 191 | } |
| 192 | $j = $i + 1; |
| 193 | while (($first[$j] == '') && ($j < count($first))) { |
| 194 | $s .= ' ' . nl2br($second[$j]); |
| 195 | $j++; |
| 196 | } |
| 197 | parseEmail($s); |
| 198 | if (isset($f)) echo "<nobr><tt><b>$f</b>$s</tt></nobr>"; |
| 199 | } |
| 200 | echo "</td></tr></table>\n"; |
| 201 | echo '</body></html>'; |
| 202 | sqimap_logout($imapConnection); |
| 203 | exit; |
| 204 | } |
| 205 | |
| 206 | if (isset($msgs)) { |
| 207 | $currentArrayIndex = $passed_id; |
| 208 | } else { |
| 209 | $currentArrayIndex = -1; |
| 210 | } |
| 211 | |
| 212 | for ($i = 0; $i < count($msgs); $i++) { |
| 213 | if ($msgs[$i]['ID'] == $passed_id) { |
| 214 | $msgs[$i]['FLAG_SEEN'] = true; |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | // $message contains all information about the message |
| 219 | // including header and body |
| 220 | $message = sqimap_get_message($imapConnection, $passed_id, $mailbox); |
| 221 | |
| 222 | /** translate the subject and mailbox into url-able text **/ |
| 223 | $url_subj = urlencode(trim($message->header->subject)); |
| 224 | $urlMailbox = urlencode($mailbox); |
| 225 | $url_replyto = ''; |
| 226 | if (isset($message->header->replyto)) { |
| 227 | $url_replyto = urlencode($message->header->replyto); |
| 228 | } |
| 229 | |
| 230 | $url_replytoall = $url_replyto; |
| 231 | |
| 232 | // If we are replying to all, then find all other addresses and |
| 233 | // add them to the list. Remove duplicates. |
| 234 | // This is somewhat messy, so I'll explain: |
| 235 | // 1) Take all addresses (from, to, cc) (avoid nasty join errors here) |
| 236 | $url_replytoall_extra_addrs = array_merge( |
| 237 | array($message->header->from), |
| 238 | $message->header->to, |
| 239 | $message->header->cc |
| 240 | ); |
| 241 | |
| 242 | // 2) Make one big string out of them |
| 243 | $url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs); |
| 244 | |
| 245 | // 3) Parse that into an array of addresses |
| 246 | $url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs); |
| 247 | |
| 248 | // 4) Make them unique -- weed out duplicates |
| 249 | // (Coded for PHP 4.0.0) |
| 250 | $url_replytoall_extra_addrs = |
| 251 | array_keys(array_flip($url_replytoall_extra_addrs)); |
| 252 | |
| 253 | // 5) Remove the addresses we'll be sending the message 'to' |
| 254 | $url_replytoall_avoid_addrs = ''; |
| 255 | if (isset($message->header->replyto)) { |
| 256 | $url_replytoall_avoid_addrs = $message->header->replyto; |
| 257 | } |
| 258 | |
| 259 | $url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs); |
| 260 | foreach ($url_replytoall_avoid_addrs as $addr) { |
| 261 | RemoveAddress($url_replytoall_extra_addrs, $addr); |
| 262 | } |
| 263 | |
| 264 | // 6) Remove our identities from the CC list (they still can be in the |
| 265 | // TO list) only if $include_self_reply_all is turned off |
| 266 | if (!$include_self_reply_all) { |
| 267 | RemoveAddress($url_replytoall_extra_addrs, |
| 268 | getPref($data_dir, $username, 'email_address')); |
| 269 | $idents = getPref($data_dir, $username, 'identities'); |
| 270 | if ($idents != '' && $idents > 1) { |
| 271 | for ($i = 1; $i < $idents; $i ++) { |
| 272 | $cur_email_address = getPref($data_dir, $username, 'email_address' . $i); |
| 273 | RemoveAddress($url_replytoall_extra_addrs, $cur_email_address); |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | // 7) Smoosh back into one nice line |
| 279 | $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs); |
| 280 | |
| 281 | // 8) urlencode() it |
| 282 | $url_replytoallcc = urlencode($url_replytoallcc); |
| 283 | |
| 284 | $dateString = getLongDateString($message->header->date); |
| 285 | |
| 286 | // What do we reply to -- text only, if possible |
| 287 | $ent_num = findDisplayEntity($message); |
| 288 | |
| 289 | /** TEXT STRINGS DEFINITIONS **/ |
| 290 | $echo_more = _("more"); |
| 291 | $echo_less = _("less"); |
| 292 | |
| 293 | if (!isset($show_more_cc)) $show_more_cc = false; |
| 294 | |
| 295 | /** FORMAT THE TO STRING **/ |
| 296 | $i = 0; |
| 297 | $to_string = ''; |
| 298 | $to_ary = $message->header->to; |
| 299 | while ($i < count($to_ary)) { |
| 300 | $to_ary[$i] = htmlspecialchars(decodeHeader($to_ary[$i])); |
| 301 | |
| 302 | if ($to_string) { |
| 303 | $to_string = "$to_string<BR>$to_ary[$i]"; |
| 304 | } else { |
| 305 | $to_string = "$to_ary[$i]"; |
| 306 | } |
| 307 | |
| 308 | $i++; |
| 309 | if (count($to_ary) > 1) { |
| 310 | if ($show_more == false) { |
| 311 | if ($i == 1) { |
| 312 | /* From a search... */ |
| 313 | $to_string .= ' (<A HREF="' . $base_uri . |
| 314 | "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&"; |
| 315 | if (isset($where) && isset($what)) { |
| 316 | $to_string .= 'where='.urlencode($where)."&what=".urlencode($what)."&show_more=1&show_more_cc=$show_more_cc\">$echo_more</A>)"; |
| 317 | } else { |
| 318 | $to_string .= "sort=$sort&startMessage=$startMessage&show_more=1&show_more_cc=$show_more_cc\">$echo_more</A>)"; |
| 319 | } |
| 320 | $i = count($to_ary); |
| 321 | } |
| 322 | } else if ($i == 1) { |
| 323 | /* From a search... */ |
| 324 | $to_string .= ' (<A HREF="' . $base_uri . |
| 325 | "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&"; |
| 326 | if (isset($where) && isset($what)) { |
| 327 | $to_string .= 'where='.urlencode($where)."&what=".urlencode($what)."&show_more=0&show_more_cc=$show_more_cc\">$echo_less</A>)"; |
| 328 | } else { |
| 329 | $to_string .= "sort=$sort&startMessage=$startMessage&show_more=0&show_more_cc=$show_more_cc\">$echo_less</A>)"; |
| 330 | } |
| 331 | } |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | /** FORMAT THE CC STRING **/ |
| 336 | $i = 0; |
| 337 | if (isset ($message->header->cc[0]) && trim($message->header->cc[0])) { |
| 338 | $cc_string = ""; |
| 339 | $cc_ary = $message->header->cc; |
| 340 | while ($i < count(decodeHeader($cc_ary))) { |
| 341 | $cc_ary[$i] = htmlspecialchars($cc_ary[$i]); |
| 342 | if ($cc_string) { |
| 343 | $cc_string = "$cc_string<BR>$cc_ary[$i]"; |
| 344 | } else { |
| 345 | $cc_string = "$cc_ary[$i]"; |
| 346 | } |
| 347 | |
| 348 | $i++; |
| 349 | if (count($cc_ary) > 1) { |
| 350 | if ($show_more_cc == false) { |
| 351 | if ($i == 1) { |
| 352 | /* From a search... */ |
| 353 | $cc_string .= ' (<A HREF="' . $base_uri . |
| 354 | "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id"; |
| 355 | if (isset($where) && isset($what)) { |
| 356 | $cc_string .= '&what='.urlencode($what)."&where=".urlencode($where)."&show_more_cc=1&show_more=$show_more\">$echo_more</A>)"; |
| 357 | } else { |
| 358 | $cc_string .= "&sort=$sort&startMessage=$startMessage&show_more_cc=1&show_more=$show_more\">$echo_more</A>)"; |
| 359 | } |
| 360 | $i = count($cc_ary); |
| 361 | } |
| 362 | } else if ($i == 1) { |
| 363 | /* From a search... */ |
| 364 | $cc_string .= ' (<A HREF="' . $base_uri . |
| 365 | "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&"; |
| 366 | if (isset($where) && isset($what)) { |
| 367 | $cc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=0&show_more=$show_more\">$echo_less</A>)"; |
| 368 | } else { |
| 369 | $cc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=0&show_more=$show_more\">$echo_less</A>)"; |
| 370 | } |
| 371 | } |
| 372 | } |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | /** FORMAT THE BCC STRING **/ |
| 377 | $i = 0; |
| 378 | if (isset ($message->header->bcc[0]) && trim($message->header->bcc[0])){ |
| 379 | $bcc_string = ""; |
| 380 | $bcc_ary = $message->header->bcc; |
| 381 | while ($i < count(decodeHeader($bcc_ary))) { |
| 382 | $bcc_ary[$i] = htmlspecialchars($bcc_ary[$i]); |
| 383 | if ($bcc_string) { |
| 384 | $bcc_string = "$bcc_string<BR>$bcc_ary[$i]"; |
| 385 | } else { |
| 386 | $bcc_string = "$bcc_ary[$i]"; |
| 387 | } |
| 388 | |
| 389 | $i++; |
| 390 | if (count($bcc_ary) > 1) { |
| 391 | if ($show_more_cc == false) { |
| 392 | if ($i == 1) { |
| 393 | /* From a search... */ |
| 394 | $bcc_string .= ' (<A HREF="' . $base_uri . |
| 395 | "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&"; |
| 396 | if (isset($where) && isset($what)) { |
| 397 | $bcc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=1&show_more=$show_more\">$echo_more</A>)"; |
| 398 | } else { |
| 399 | $bcc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=1&show_more=$show_more\">$echo_more</A>)"; |
| 400 | } |
| 401 | $i = count($bcc_ary); |
| 402 | } |
| 403 | } else if ($i == 1) { |
| 404 | /* From a search... */ |
| 405 | $bcc_string .= ' (<A HREF="' . $base_uri . |
| 406 | "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&"; |
| 407 | if (isset($where) && isset($what)) { |
| 408 | $bcc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=0&show_more=$show_more\">$echo_less</A>)"; |
| 409 | } else { |
| 410 | $bcc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=0&show_more=$show_more\">$echo_less</A>)"; |
| 411 | } |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | if ($default_use_priority) { |
| 418 | $priority_level = substr($message->header->priority,0,1); |
| 419 | |
| 420 | switch($priority_level) { |
| 421 | /* check for a higher then normal priority. */ |
| 422 | case '1': |
| 423 | case '2': |
| 424 | $priority_string = _("High"); |
| 425 | break; |
| 426 | |
| 427 | /* check for a lower then normal priority. */ |
| 428 | case '4': |
| 429 | case '5': |
| 430 | $priority_string = _("Low"); |
| 431 | break; |
| 432 | |
| 433 | /* check for a normal priority. */ |
| 434 | case '3': |
| 435 | default: |
| 436 | $priority_level = '3'; |
| 437 | $priority_string = _("Normal"); |
| 438 | break; |
| 439 | |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | /** make sure everything will display in HTML format **/ |
| 444 | $from_name = decodeHeader(htmlspecialchars($message->header->from)); |
| 445 | $subject = decodeHeader(htmlspecialchars($message->header->subject)); |
| 446 | |
| 447 | do_hook('read_body_top'); |
| 448 | echo '<BR>' . |
| 449 | '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" . |
| 450 | ' <TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' . "\n" . |
| 451 | ' <TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' . "\n" . |
| 452 | ' <TR>' . "\n" . |
| 453 | ' <TD ALIGN="LEFT" WIDTH="33%">' . "\n" . |
| 454 | ' <SMALL>' . "\n" . |
| 455 | '<A HREF="' . $base_uri . 'src/'; |
| 456 | |
| 457 | if ($where && $what) { |
| 458 | if( $pos == '' ) { |
| 459 | $pos = 0; |
| 460 | } |
| 461 | echo "search.php?where$pos=".urlencode($where)."&pos=$pos&what$pos=".urlencode($what)."&mailbox=$urlMailbox\">"; |
| 462 | } else { |
| 463 | echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">"; |
| 464 | } |
| 465 | echo _("Message List") . |
| 466 | '</A> | ' . |
| 467 | '<A HREF="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&"; |
| 468 | if ($where && $what) { |
| 469 | echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">'; |
| 470 | } else { |
| 471 | echo "sort=$sort&startMessage=$startMessage\">"; |
| 472 | } |
| 473 | echo _("Delete") . '</A> '; |
| 474 | if (($mailbox == $draft_folder) && ($save_as_draft)) { |
| 475 | echo '| <A HREF="' . $base_uri . |
| 476 | "src/compose.php?mailbox=$mailbox&send_to=$to_string&send_to_cc=$cc_string&send_to_bcc=$bcc_string&subject=$url_subj&draft_id=$passed_id&ent_num=$ent_num\">". |
| 477 | _("Resume Draft") . '</a>'; |
| 478 | } |
| 479 | |
| 480 | echo ' ' . |
| 481 | ' </SMALL>' . "\n" . |
| 482 | ' </TD>' . "\n" . |
| 483 | ' <TD WIDTH="33%" ALIGN="CENTER">' . "\n" . |
| 484 | ' <SMALL>' . "\n"; |
| 485 | |
| 486 | if ( !($where && $what) ) { |
| 487 | |
| 488 | if ($currentArrayIndex == -1) { |
| 489 | echo 'Previous | Next'; |
| 490 | } else { |
| 491 | $prev = findPreviousMessage(); |
| 492 | $next = findNextMessage(); |
| 493 | |
| 494 | if ($prev != -1) { |
| 495 | echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | "; |
| 496 | } else { |
| 497 | echo _("Previous") . ' | '; |
| 498 | } |
| 499 | |
| 500 | if ($next != -1) { |
| 501 | echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>"; |
| 502 | } else { |
| 503 | echo _("Next"); |
| 504 | } |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | echo ' </SMALL>' . "\n" . |
| 509 | ' </TD><TD WIDTH="33%" ALIGN="RIGHT">' . |
| 510 | ' <SMALL>' . |
| 511 | ' <A HREF="' . $base_uri . "src/compose.php?forward_id=$passed_id&forward_subj=$url_subj&". |
| 512 | ($default_use_priority?"mailprio=$priority_level&":"") |
| 513 | ."mailbox=$urlMailbox&ent_num=$ent_num\">" . |
| 514 | _("Forward") . |
| 515 | '</A> | ' . |
| 516 | ' <A HREF="' . $base_uri . "src/compose.php?send_to=$url_replyto&reply_subj=$url_subj&". |
| 517 | ($default_use_priority?"mailprio=$priority_level&":""). |
| 518 | "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\">" . |
| 519 | _("Reply") . |
| 520 | '</A> | ' . |
| 521 | ' <A HREF="' . $base_uri . "src/compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&". |
| 522 | ($default_use_priority?"mailprio=$priority_level&":""). |
| 523 | "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\">" . |
| 524 | _("Reply All") . |
| 525 | '</A> ' . |
| 526 | ' </SMALL>' . |
| 527 | ' </TD>' . |
| 528 | ' </TR>' . |
| 529 | ' </TABLE>' . |
| 530 | ' </TD></TR>' . |
| 531 | ' <TR><TD CELLSPACING="0" WIDTH="100%">' . |
| 532 | ' <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" . |
| 533 | ' <TR>' . "\n"; |
| 534 | |
| 535 | /** subject **/ |
| 536 | echo " <TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" . |
| 537 | _("Subject:") . |
| 538 | " </TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" . |
| 539 | " <B>$subject</B> \n" . |
| 540 | " </TD>\n" . |
| 541 | ' <TD ROWSPAN="4" width="10%" BGCOLOR="' . $color[0] . |
| 542 | '" ALIGN=right VALIGN=top NOWRAP><small>'. |
| 543 | '<A HREF="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&"; |
| 544 | |
| 545 | /* From a search... */ |
| 546 | if ($where && $what) { |
| 547 | echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . |
| 548 | "&view_hdr=1\">" . _("View Full Header") . "</A>\n"; |
| 549 | } else { |
| 550 | echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" . |
| 551 | _("View Full Header") . "</A>\n"; |
| 552 | } |
| 553 | |
| 554 | /* Output the printer friendly link if we are in subtle mode. */ |
| 555 | if ($pf_subtle_link) { |
| 556 | echo printer_friendly_link(true); |
| 557 | } |
| 558 | |
| 559 | do_hook("read_body_header_right"); |
| 560 | echo '</small></TD>' . "\n" . |
| 561 | ' </TR>' ."\n"; |
| 562 | |
| 563 | /** from **/ |
| 564 | echo ' <TR>' . "\n" . |
| 565 | ' <TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" . |
| 566 | _("From:") . |
| 567 | ' </TD><TD BGCOLOR="' . $color[0] . '">' . "\n" . |
| 568 | " <B>$from_name</B> \n" . |
| 569 | ' </TD>' . "\n" . |
| 570 | ' </TR>' . "\n"; |
| 571 | /** date **/ |
| 572 | echo ' <TR>' . "\n" . |
| 573 | ' <TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" . |
| 574 | _("Date:") . |
| 575 | " </TD><TD BGCOLOR=\"$color[0]\">\n" . |
| 576 | " <B>$dateString</B> \n" . |
| 577 | ' </TD>' . "\n" . |
| 578 | ' </TR>' . "\n"; |
| 579 | |
| 580 | /** to **/ |
| 581 | echo " <TR>\n" . |
| 582 | " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" . |
| 583 | _("To:") . |
| 584 | ' </TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" . |
| 585 | " <B>$to_string</B> \n" . |
| 586 | ' </TD>' . "\n" . |
| 587 | ' </TR>' . "\n"; |
| 588 | /** cc **/ |
| 589 | if (isset($cc_string)) { |
| 590 | echo " <TR>\n" . |
| 591 | " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" . |
| 592 | ' Cc:' . "\n" . |
| 593 | " </TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>\n" . |
| 594 | " <B>$cc_string</B> \n" . |
| 595 | ' </TD>' . "\n" . |
| 596 | ' </TR>' . "\n"; |
| 597 | } |
| 598 | |
| 599 | /** bcc **/ |
| 600 | if (isset($bcc_string)) { |
| 601 | echo " <TR>\n" . |
| 602 | " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" . |
| 603 | ' Bcc:' . "\n" . |
| 604 | " </TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>\n" . |
| 605 | " <B>$bcc_string</B> \n" . |
| 606 | ' </TD>' . "\n" . |
| 607 | ' </TR>' . "\n"; |
| 608 | } |
| 609 | if ($default_use_priority) { |
| 610 | if (isset($priority_string)) { |
| 611 | echo " <TR>\n" . |
| 612 | " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" . |
| 613 | " "._("Priority").": \n". |
| 614 | " </TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>\n" . |
| 615 | " <B>$priority_string</B> \n" . |
| 616 | " </TD>" . "\n" . |
| 617 | " </TR>" . "\n"; |
| 618 | } |
| 619 | } |
| 620 | |
| 621 | if ($show_xmailer_default) { |
| 622 | $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]", true, |
| 623 | $response, $readmessage); |
| 624 | $mailer = substr($read[1], strpos($read[1], " ")); |
| 625 | if (trim($mailer)) { |
| 626 | echo " <TR>\n" . |
| 627 | " <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" . |
| 628 | " "._("Mailer").": \n". |
| 629 | " </TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>\n" . |
| 630 | " <B>$mailer</B> \n" . |
| 631 | " </TD>" . "\n" . |
| 632 | " </TR>" . "\n"; |
| 633 | } |
| 634 | } |
| 635 | |
| 636 | /* Output the printer friendly link if we are not in subtle mode. */ |
| 637 | if (!$pf_subtle_link) { |
| 638 | echo printer_friendly_link(true); |
| 639 | } |
| 640 | |
| 641 | do_hook('read_body_header'); |
| 642 | echo '</TABLE>' . |
| 643 | ' </TD></TR>' . |
| 644 | '</TABLE>'; |
| 645 | flush(); |
| 646 | |
| 647 | echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" . |
| 648 | " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" . |
| 649 | '<BR>'. |
| 650 | formatBody($imapConnection, $message, $color, $wrap_at). |
| 651 | '</TABLE>' . |
| 652 | '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" . |
| 653 | " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>" . |
| 654 | '</TABLE>' . "\n"; |
| 655 | |
| 656 | /* show attached images inline -- if pref'fed so */ |
| 657 | if (($attachment_common_show_images) && |
| 658 | is_array($attachment_common_show_images_list)) { |
| 659 | |
| 660 | foreach ($attachment_common_show_images_list as $img) { |
| 661 | $imgurl = '../src/download.php' . |
| 662 | '?' . |
| 663 | 'passed_id=' . urlencode($img['passed_id']) . |
| 664 | '&mailbox=' . urlencode($mailbox) . |
| 665 | '&passed_ent_id=' . urlencode($img['ent_id']) . |
| 666 | '&absolute_dl=true'; |
| 667 | |
| 668 | echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" . |
| 669 | " <TR>\n" . |
| 670 | " <TD>\n" . |
| 671 | " <img src=\"$imgurl\">\n" . |
| 672 | " </TD>\n" . |
| 673 | " </TR>\n" . |
| 674 | "</TABLE>\n"; |
| 675 | |
| 676 | } |
| 677 | } |
| 678 | |
| 679 | |
| 680 | do_hook('read_body_bottom'); |
| 681 | do_hook('html_bottom'); |
| 682 | sqimap_logout($imapConnection); |
| 683 | ?> |
| 684 | </body> |
| 685 | </html> |