X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fread_body.php;h=dd69e6e2d3922fe729db8d97197d5fa13c75333a;hb=c1cb7ba47f57c63d037508747e684b9193ea07e1;hp=8e3f24a5b00f8af868b54d84a15ec274b23e34d7;hpb=9c83f905fef00de60528b7efcfc4dd3b7c4fa4ee;p=squirrelmail.git
diff --git a/src/read_body.php b/src/read_body.php
index 8e3f24a5..dd69e6e2 100644
--- a/src/read_body.php
+++ b/src/read_body.php
@@ -1,182 +1,658 @@
";
- echo "
\n";
- displayPageHeader($color, $mailbox);
-
- /** translate the subject and mailbox into url-able text **/
- $url_subj = urlencode(trim(stripslashes($message["HEADER"]["SUBJECT"])));
- $urlMailbox = urlencode($mailbox);
- $url_replyto = urlencode($message["HEADER"]["REPLYTO"]);
-
- $url_replytoall = urlencode($message["HEADER"]["REPLYTO"]);
- $url_replytoallcc = urlencode(getLineOfAddrs($message["HEADER"]["TO"]) . ", " . getLineOfAddrs($message["HEADER"]["CC"]));
-
- $dateString = getLongDateString($message["HEADER"]["DATE"]);
-
- /** TEXT STRINGS DEFINITIONS **/
- $echo_more = _("more");
- $echo_less = _("less");
-
- /** FORMAT THE TO STRING **/
- $i = 0;
- $to_string = "";
- $to_ary = $message["HEADER"]["TO"];
- while ($i < count($to_ary)) {
- $to_ary[$i] = htmlspecialchars($to_ary[$i]);
- if ($to_string)
- $to_string = "$to_string
$to_ary[$i]";
- else
- $to_string = "$to_ary[$i]";
-
- $i++;
- if (count($to_ary) > 1) {
- if ($show_more == false) {
- if ($i == 1) {
- $to_string = "$to_string ($echo_more)";
- $i = count($to_ary);
- }
- } else if ($i == 1) {
- $to_string = "$to_string ($echo_less)";
- }
- }
- }
-
- /** FORMAT THE CC STRING **/
- $i = 0;
- $cc_string = "";
- $cc_ary = $message["HEADER"]["CC"];
- while ($i < count($cc_ary)) {
- $cc_ary[$i] = htmlspecialchars($cc_ary[$i]);
- if ($cc_string)
- $cc_string = "$cc_string
$cc_ary[$i]";
- else
- $cc_string = "$cc_ary[$i]";
-
- $i++;
- if (count($cc_ary) > 1) {
- if ($show_more_cc == false) {
- if ($i == 1) {
- $cc_string = "$cc_string ($echo_more)";
- $i = count($cc_ary);
- }
- } else if ($i == 1) {
- $cc_string = "$cc_string ($echo_less)";
- }
- }
- }
-
- /** make sure everything will display in HTML format **/
- $from_name = decodeHeader(htmlspecialchars($message["HEADER"]["FROM"]));
- $subject = decodeHeader(htmlspecialchars(stripslashes($message["HEADER"]["SUBJECT"])));
-
- echo "
";
- echo "\n";
- echo " ";
- echo " ";
- echo " |
";
- echo " ";
- echo " \n";
- echo " \n";
- /** subject **/
- echo " \n";
- echo _("Subject:");
- echo " | \n";
- echo " $subject\n";
- echo " | \n";
- echo " \n";
- /** from **/
- echo " \n";
- echo " \n";
- echo _("From:");
- echo " | \n";
- echo " $from_name\n";
- echo " | \n";
- echo " \n";
- /** date **/
- echo " \n";
- echo " \n";
- echo _("Date:");
- echo " | \n";
- echo " $dateString\n";
- echo " | \n";
- echo " \n";
- /** to **/
- echo " \n";
- echo " \n";
- echo _("To:");
- echo " | \n";
- echo " $to_string\n";
- echo " | \n";
- echo " \n";
- /** cc **/
- if ($message["HEADER"]["CC"][0]) {
- echo " \n";
- echo " \n";
- echo " Cc:\n";
- echo " | \n";
- echo " $cc_string\n";
- echo " | \n";
- echo " \n";
- }
- echo " ";
- echo " |
";
-
- echo " \n";
- $body = formatBody($message, $color, $wrap_at);
- echo " ";
-
- echo "$body";
-
- echo " |
\n";
- echo " |
";
- echo "
\n";
+/**
+ * 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$
+ /
+
+/*****************************************************************/
+/*** 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');
+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" .
+ ' | '."\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" .
+ '
' . "\n";
+ }
+
+ 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 {
+ $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 "$f$s";
+ }
+ echo " |
\n";
+ echo '