From 2844086da1696de4ab45981b0d749d57502781d0 Mon Sep 17 00:00:00 2001 From: lkehresman Date: Mon, 6 Dec 1999 22:07:20 +0000 Subject: [PATCH] added To: field git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@65 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/mailbox.php | 38 +++++++++++++++++++++++++++++++ functions/mailbox_display.php | 4 ++-- src/compose.php | 7 +++--- src/read_body.php | 42 +++++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 5 deletions(-) diff --git a/functions/mailbox.php b/functions/mailbox.php index 9092744d..31eb5542 100644 --- a/functions/mailbox.php +++ b/functions/mailbox.php @@ -316,4 +316,42 @@ return $line; } + + function getMessageHeadersTo($imapConnection, $start, $end, &$to) { + $rel_start = $start; + if (($start > $end) || ($start < 1)) { + echo "Error in message header fetching. Start message: $start, End message: $end
"; + exit; + } + + $pos = 0; + while ($rel_start <= $end) { + if ($end - $rel_start > 50) { + $rel_end = $rel_start + 49; + } else { + $rel_end = $end; + } + fputs($imapConnection, "messageFetch FETCH $rel_start:$rel_end RFC822.HEADER.LINES (To)\n"); + $read = fgets($imapConnection, 1024); + + while ((substr($read, 0, 15) != "messageFetch OK") && (substr($read, 0, 16) != "messageFetch BAD")) { + if (substr($read, 0, 3) == "To:") { + $read = ereg_replace("<", "<", $read); + $read = ereg_replace(">", ">", $read); + $to[$pos] = substr($read, 3, strlen($read)); + if (strlen(Chop($to[$pos])) == 0) + $to[$pos] = "Unknown Recipients"; + } + else if (substr($read, 0, 1) == ")") { + if ($subject[$pos] == "") + $subject[$pos] = "Unknown Recipients"; + $pos++; + } + + $read = fgets($imapConnection, 1024); + } + $rel_start = $rel_start + 50; + } + } + ?> diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 6e49080e..1010d31f 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -16,12 +16,12 @@ echo " \n"; echo " $senderName\n"; echo "
$dateString
\n"; - echo " $subject\n"; + echo " $subject\n"; } else { echo " \n"; echo " $senderName\n"; echo "
$dateString
\n"; - echo " $subject\n"; + echo " $subject\n"; } echo "\n"; } diff --git a/src/compose.php b/src/compose.php index f2383bfb..4ac944e8 100644 --- a/src/compose.php +++ b/src/compose.php @@ -8,10 +8,10 @@ echo "\n"; $imapConnection = loginToImapServer($username, $key, $imapServerAddress); - displayPageHeader($mailbox); - selectMailbox($imapConnection, $mailbox, $numMessages); + displayPageHeader("None"); if ($reply_id) { + selectMailbox($imapConnection, $mailbox, $numMessages); $body_ary = fetchBody($imapConnection, $reply_id); for ($i=0;$i < count($body_ary);$i++) { $tmp = strip_tags($body_ary[$i]); @@ -19,6 +19,7 @@ $body = "$body> $tmp"; } } else if ($forward_id) { + selectMailbox($imapConnection, $mailbox, $numMessages); $body_ary = fetchBody($imapConnection, $forward_id); for ($i=0;$i < count($body_ary);$i++) { $tmp = strip_tags($body_ary[$i]); @@ -61,7 +62,7 @@ if ($reply_subj) echo "
"; else if ($forward_subj) - echo "
"; + echo "
"; else echo "
"; echo " \n"; diff --git a/src/read_body.php b/src/read_body.php index 053bcb3f..98e7f568 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -13,6 +13,7 @@ displayPageHeader($mailbox); $body = fetchBody($imapConnection, $passed_id); getMessageHeaders($imapConnection, $passed_id, $passed_id, $f, $s, $d); + getMessageHeadersTo($imapConnection, $passed_id, $passed_id, $t); $subject = $s[0]; $url_subj = urlencode(trim($subject)); @@ -25,6 +26,39 @@ $url_from = trim(decodeEmailAddr($f[0])); $url_from = urlencode($url_from); + $to_left = trim($t[0]); + for ($i = 0; $to_left;$i++) { + if (strpos($to_left, ",")) { + $to_ary[$i] = trim(substr($to_left, 0, strpos($to_left, ","))); + $to_left = substr($to_left, strpos($to_left, ",")+1, strlen($to_left)); + } + else { + $to_ary[$i] = trim($to_left); + $to_left = ""; + } + } + + $i = 0; + $to_string = ""; + while ($i < count($to_ary)) { + 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   (more)"; + $i = count($to_ary); + } + } else if ($i == 1) { + $to_string = "$to_string   (less)"; + } + } + } + echo "
"; echo "\n"; echo " \n"; echo " \n"; + /** to **/ + echo " \n"; + echo " \n"; + echo " \n"; echo "
"; @@ -70,6 +104,14 @@ echo " $date\n"; echo "
\n"; + echo " To:\n"; + echo " \n"; + echo " $to_string\n"; + echo "
\n"; -- 2.25.1