';
-
- $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)) {
+
+/**
+ * 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');
+require_once('../functions/smtp.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,
+ $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,
+ $pf_subtle_link,
+ $javascript_on;
+
+ if (strlen(trim($mailbox)) < 1) {
+ $mailbox = 'INBOX';
+ }
+
+ $params = '?passed_ent_id=' . $ent_num .
+ '&mailbox=' . urlencode($mailbox) .
+ '&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 = ' |