X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Fread_body.php;h=380c5fcb8532c78bb707a5afd4769652e3204d33;hp=ba9be44d45ff93026a69e16e7e22811e13af26c7;hb=a07cd1a401ba4efc7fdcf418cb51449bee09fbdc;hpb=a5ee5ac2abfa64906394d54b9d94719517274b90
diff --git a/src/read_body.php b/src/read_body.php
index ba9be44d..380c5fcb 100644
--- a/src/read_body.php
+++ b/src/read_body.php
@@ -10,23 +10,7 @@
* the resulting emails in the right frame.
*
* $Id$
- /
-
-/*****************************************************************/
-/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/
-/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/
-/*** + Base level indent should begin at left margin, as ***/
-/*** the require_once below looks. ***/
-/*** + All identation should consist of four space blocks ***/
-/*** + Tab characters are evil. ***/
-/*** + all comments should use "slash-star ... star-slash" ***/
-/*** style -- no pound characters, no slash-slash style ***/
-/*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/
-/*** ALWAYS USE { AND } CHARACTERS!!! ***/
-/*** + Please use ' instead of ", when possible. Note " ***/
-/*** should always be used in _( ) function calls. ***/
-/*** Thank you for your help making the SM code more readable. ***/
-/*****************************************************************/
+ */
require_once('../src/validate.php');
require_once('../functions/imap.php');
@@ -34,630 +18,647 @@ 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;
- }
+/**
+* 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]);
- }
+ 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;
- }
+ }
+}
+
+/** 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';
}
+ }
+ return ($result);
+}
- $params = '?passed_ent_id=' . $ent_num;
- $params .= '&mailbox=' . urlencode($mailbox);
- $params .= '&passed_id=' . $passed_id;
+/**
+* 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';
+ }
- $print_text = _("View Printable Version");
+ $params = '?passed_ent_id=' . $ent_num;
+ $params .= '&mailbox=' . urlencode($mailbox);
+ $params .= '&passed_id=' . $passed_id;
- if (!$pf_subtle_link) {
- /* The link is large, on the bottom of the header panel. */
- $result = '
' . "\n" .
- ' ' . "\n" .
- ' ' . "\n" .
- ' | '."\n";
- } else {
- /* The link is subtle, below "view full header". */
- $result = " \n";
- }
+ $print_text = _("View Printable Version");
- /* 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" .
+ ' ' . "\n" .
+ ' ' . "\n" .
+ ' | '."\n";
+ } else {
+ /* The link is subtle, below "view full header". */
+ $result = " \n";
+ }
- if (!$pf_subtle_link) {
- /* The link is large, on the bottom of the header panel. */
- $result .= ' | ' . "\n" .
- '
' . "\n";
- }
+ /* Output the link. */
+ if ($javascript_on) {
+ $result .= '\n" .
+ "$print_text\n";
+ } else {
+ $result .= '$print_text\n";
+ }
- return ($result);
+ if (!$pf_subtle_link) {
+ /* The link is large, on the bottom of the header panel. */
+ $result .= ' ' . "\n" .
+ ' ' . "\n";
}
- /*****************************/
- /*** Main of read_boby.php ***/
- /*****************************/
-
- $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
- sqimap_mailbox_select($imapConnection, $mailbox);
- do_hook('html_top');
- displayPageHeader($color, $mailbox);
-
- if (isset($view_hdr)) {
- fputs ($imapConnection, sqimap_session_id() . " FETCH $passed_id BODY[HEADER]\r\n");
- $read = sqimap_read_data ($imapConnection, sqimap_session_id(), true, $a, $b);
-
- echo '
' .
- '' . "\n" .
- " " . _("Viewing Full Header") . ' - ';
- if (isset($where) && isset($what)) {
- // Got here from a search
- echo "';
+ return ($result);
+}
+
+/*****************************/
+/*** Main of read_boby.php ***/
+/*****************************/
+
+$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+sqimap_mailbox_select($imapConnection, $mailbox);
+do_hook('html_top');
+displayPageHeader($color, $mailbox);
+
+if (isset($view_hdr)) {
+ fputs ($imapConnection, sqimap_session_id() . " FETCH $passed_id BODY[HEADER]\r\n");
+ $read = sqimap_read_data ($imapConnection, sqimap_session_id(), true, $a, $b);
+
+ echo ' ' .
+ '\n" .
+ "\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)) {
+ $first[$i] = $regs[1] . ':';
+ $second[$i] = $regs[2];
+ $cnum++;
} else {
- echo "";
+ $second[$i] = trim($line);
+ $first[$i] = '';
}
- echo ''._("View message") . " | \n" .
- "\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)) {
- $first[$i] = $regs[1] . ':';
- $second[$i] = $regs[2];
- $cnum++;
- } else {
- $second[$i] = trim($line);
- $first[$i] = '';
- }
+ }
+ for ($i=0; $i < count($second); $i = $j) {
+ if (isset($first[$i])) {
+ $f = $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 "$f$s";
+ if (isset($second[$i])) {
+ $s = nl2br($second[$i]);
+ }
+ $j = $i + 1;
+ while (($first[$j] == '') && ($j < count($first))) {
+ $s .= ' ' . nl2br($second[$j]);
+ $j++;
}
- echo " | \n";
- echo ' |