From 078a40a425c8f7dd8120128e55212464e3051ca0 Mon Sep 17 00:00:00 2001 From: lkehresman Date: Thu, 9 Dec 1999 20:11:31 +0000 Subject: [PATCH] Added "CC" to read_body.php, and rewrote the code to handle getting TO and CC git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@73 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/imap.php | 1 + functions/mailbox.php | 82 +++++++++++++++++++++++++------------------ src/read_body.php | 57 +++++++++++++++++++++--------- 3 files changed, 89 insertions(+), 51 deletions(-) diff --git a/functions/imap.php b/functions/imap.php index 7fd356f9..49e348d5 100644 --- a/functions/imap.php +++ b/functions/imap.php @@ -28,6 +28,7 @@ $temp .= $char; $char = substr($mailbox, $i, 1); } + echo $tmp; return strrev($temp); } diff --git a/functions/mailbox.php b/functions/mailbox.php index f96eb523..f8a71f87 100644 --- a/functions/mailbox.php +++ b/functions/mailbox.php @@ -363,51 +363,63 @@ return $line; } -/* - $start = strpos(strtolower($line), "http://"); - $text = substr($line, $start, strlen($line)); - $linktext = substr($link, 0, $end); - $link = trim(ereg_replace("
", "", $linktext)); - + function getMessageHeadersTo($imapConnection, $i, &$to) { + $pos = 0; + fputs($imapConnection, "messageFetch FETCH $i:$i RFC822.HEADER.LINES (To)\n"); + $read = fgets($imapConnection, 1024); -// $line = str_replace($text, "$link", $line); -*/ + $firstline = true; + while ((substr($read, 0, 15) != "messageFetch OK") && (substr($read, 0, 16) != "messageFetch BAD")) { + if ($firstline == true) { + $firstline = false; + $read = fgets($imapConnection, 1024); + } else if (strlen(trim($read)) <= 1) { + $firstline = false; + $read = fgets($imapConnection, 1024); + } else if ($read == ")") { + $firstline = false; + $read = fgets($imapConnection, 1024); + } else { + $firstline = false; + $read = ereg_replace("<", "<", $read); + $read = ereg_replace(">", ">", $read); + if (strlen(trim($read)) != 0) + $to[$pos] = substr($read, 3, strlen($read)); - 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++; + $read = fgets($imapConnection, 1024); + } } + } + function getMessageHeadersCc($imapConnection, $i, &$cc) { $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); + fputs($imapConnection, "messageFetch FETCH $i:$i RFC822.HEADER.LINES (Cc)\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++; - } + $firstline = true; + while ((strlen(trim($read)) > 0) && (substr($read, 0, 15) != "messageFetch OK") && (substr($read, 0, 16) != "messageFetch BAD")) { + if ($firstline == true) { + $firstline = false; + $read = fgets($imapConnection, 1024); + } else if (strlen(trim($read)) <= 1) { + $firstline = false; + $read = fgets($imapConnection, 1024); + } else if ($read == ")") { + $firstline = false; + $read = fgets($imapConnection, 1024); + } else { + $read = ereg_replace("<", "<", $read); + $read = ereg_replace(">", ">", $read); + if (strlen(trim($read)) != 0) + $cc[$pos] = substr($read, 3, strlen($read)); + $pos++; $read = fgets($imapConnection, 1024); } - $rel_start = $rel_start + 50; } + $read = fgets($imapConnection, 1024); // get rid of the last line } + ?> diff --git a/src/read_body.php b/src/read_body.php index c2122833..8a8f0c00 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -13,7 +13,8 @@ displayPageHeader($mailbox); $body = fetchBody($imapConnection, $passed_id); getMessageHeaders($imapConnection, $passed_id, $passed_id, $f, $s, $d); - getMessageHeadersTo($imapConnection, $passed_id, $passed_id, $t); + getMessageHeadersTo($imapConnection, $passed_id, $t); + getMessageHeadersCc($imapConnection, $passed_id, $c); $subject = $s[0]; $url_subj = urlencode(trim($subject)); @@ -28,20 +29,10 @@ $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 = ""; - } - } - + /** FORMAT THE TO STRING **/ $i = 0; $to_string = ""; + $to_ary = $t; while ($i < count($to_ary)) { if ($to_string) $to_string = "$to_string
$to_ary[$i]"; @@ -52,15 +43,40 @@ if (count($to_ary) > 1) { if ($show_more == false) { if ($i == 1) { - $to_string = "$to_string   (more)"; + $to_string = "$to_string (more)"; $i = count($to_ary); } } else if ($i == 1) { - $to_string = "$to_string   (less)"; + $to_string = "$to_string (less)"; } } } + /** FORMAT THE CC STRING **/ + $i = 0; + $cc_string = ""; + $cc_ary = $c; + while ($i < count($cc_ary)) { + 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 (more)"; + $i = count($cc_ary); + } + } else if ($i == 1) { + $cc_string = "$cc_string (less)"; + } + } + } + + + echo "
"; echo "\n"; echo " \n"; echo " \n"; - + /** cc **/ + if ($c[0]) { + echo " \n"; + echo " \n"; + echo " \n"; + } echo "
"; @@ -114,7 +130,16 @@ echo " $to_string\n"; echo "
\n"; + echo " Cc:\n"; + echo " \n"; + echo " $cc_string\n"; + echo "
\n"; echo "
\n"; -- 2.25.1