X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fread_body.php;h=380c5fcb8532c78bb707a5afd4769652e3204d33;hb=a07cd1a401ba4efc7fdcf418cb51449bee09fbdc;hp=266086a60441b6743ee13df15c91c5a2a8cb24a4;hpb=e5a067194eb800d0a1ad5e0a46a61dd63f9119a0;p=squirrelmail.git diff --git a/src/read_body.php b/src/read_body.php index 266086a6..380c5fcb 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -1,414 +1,664 @@ '; - echo '
'; - - $cnum = 0; - for ($i=1; $i < count($read)-1; $i++) { - $line = htmlspecialchars($read[$i]); - if (eregi("^>", $line)) { - $second[$i] = $line; - $first[$i] = ' '; - $cnum++; - } else if (eregi("^[ |\t]", $line)) { + +/** + * read_body.php + * + * Copyright (c) 1999-2002 The SquirrelMail Project Team + * Licensed under the GNU GPL. For full terms see the file COPYING. + * + * This file is used for reading the msgs array and displaying + * the resulting emails in the right frame. + * + * $Id$ + */ + +require_once('../src/validate.php'); +require_once('../functions/imap.php'); +require_once('../functions/mime.php'); +require_once('../functions/date.php'); +require_once('../functions/url_parser.php'); + +/** +* Given an IMAP message id number, this will look it up in the cached +* and sorted msgs array and return the index. Used for finding the next +* and previous messages. +* +* returns the index of the next valid message from the array +*/ +function findNextMessage() { + global $msort, $currentArrayIndex, $msgs, $sort; + $result = -1; + + if ($sort == 6) { + if ($currentArrayIndex != 1) { + $result = $currentArrayIndex - 1; + } + } else { + for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { + if ($currentArrayIndex == $msgs[$key]['ID']) { + next($msort); + $key = key($msort); + if (isset($key)) + $result = $msgs[$key]['ID']; + break; + } + } + } + return ($result); +} + +/** Removes just one address from the list of addresses. */ +function RemoveAddress(&$addr_list, $addr) { + if ($addr != '') { + foreach (array_keys($addr_list, $addr) as $key_to_delete) { + unset($addr_list[$key_to_delete]); + } + } +} + +/** returns the index of the previous message from the array. */ +function findPreviousMessage() { + global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection; + global $mailbox, $data_dir, $username; + $result = -1; + + if ($sort == 6) { + $numMessages = sqimap_get_num_messages($imapConnection, $mailbox); + if ($currentArrayIndex != $numMessages) { + $result = $currentArrayIndex + 1; + } + } else { + for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { + if ($currentArrayIndex == $msgs[$key]['ID']) { + prev($msort); + $key = key($msort); + if (isset($key)) { + $result = $msgs[$key]['ID']; + break; + } + } + } + } + return ($result); +} + +/** +* Displays a link to a page where the message is displayed more +* "printer friendly". +*/ +function printer_friendly_link() { + global $passed_id, $mailbox, $ent_num, $color; + global $pf_subtle_link; + global $javascript_on; + + if (strlen(trim($mailbox)) < 1) { + $mailbox = 'INBOX'; + } + + $params = '?passed_ent_id=' . $ent_num; + $params .= '&mailbox=' . urlencode($mailbox); + $params .= '&passed_id=' . $passed_id; + + $print_text = _("View Printable Version"); + + if (!$pf_subtle_link) { + /* The link is large, on the bottom of the header panel. */ + $result = ' | ||
' . "\n" . + ' ' . "\n" . + ' | '."\n";
+ } else {
+ /* The link is subtle, below "view full header". */
+ $result = " \n"; + } + + /* Output the link. */ + if ($javascript_on) { + $result .= '\n" . + "$print_text\n"; + } else { + $result .= '$print_text\n"; + } + + if (!$pf_subtle_link) { + /* The link is large, on the bottom of the header panel. */ + $result .= ' | ' . "\n" .
+ '
';
+
+ $cnum = 0;
+ for ($i=1; $i < count($read); $i++) {
+ $line = htmlspecialchars($read[$i]);
+ if (eregi("^>", $line)) {
+ $second[$i] = $line;
+ $first[$i] = ' ';
+ $cnum++;
+ } else if (eregi("^[ |\t]", $line)) {
$second[$i] = $line;
$first[$i] = '';
- } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
+ } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
$first[$i] = $regs[1] . ':';
$second[$i] = $regs[2];
- $cnum++;
- } else {
+ $cnum++;
+ } else {
$second[$i] = trim($line);
$first[$i] = '';
- }
- }
- for ($i=0; $i < count($second); $i = $j) {
- if (isset($first[$i]))
- $f = $first[$i];
- if (isset($second[$i]))
- $s = nl2br($second[$i]);
- $j = $i + 1;
- while ($first[$j] == '' && $j < count($first)) {
- $s .= ' ' . nl2br($second[$j]);
- $j++;
- }
- parseEmail($s);
- if (isset($f)) echo " |