Added "CC" to read_body.php, and rewrote the code to handle getting TO and CC
authorlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 9 Dec 1999 20:11:31 +0000 (20:11 +0000)
committerlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 9 Dec 1999 20:11:31 +0000 (20:11 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@73 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/imap.php
functions/mailbox.php
src/read_body.php

index 7fd356f9b89b2e7a6f1ee9050f5841ce903fabfc..49e348d515b0733c94b5f10ce30374b5f129fe4b 100644 (file)
@@ -28,6 +28,7 @@
          $temp .= $char;
          $char = substr($mailbox, $i, 1);
       }
          $temp .= $char;
          $char = substr($mailbox, $i, 1);
       }
+      echo $tmp;
       return strrev($temp);
    }
 
       return strrev($temp);
    }
 
index f96eb52375717247058ea1a94bc470a484d4435f..f8a71f873c8eeed96578f265adad417a89678e69 100644 (file)
       return $line;
    }
 
       return $line;
    }
 
-/*
-         $start = strpos(strtolower($line), "http://");
-         $text = substr($line, $start, strlen($line));
-         $linktext = substr($link, 0, $end);
-         $link = trim(ereg_replace("<BR>", "", $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, "<A HREF=\"$link\" TARGET=_top>$link</A>", $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("<", "&lt;", $read);
+            $read = ereg_replace(">", "&gt;", $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<BR>";
-         exit;
+            $pos++;
+            $read = fgets($imapConnection, 1024);
+         }
       }
       }
+   }
 
 
+   function getMessageHeadersCc($imapConnection, $i, &$cc) {
       $pos = 0;
       $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("<", "&lt;", $read);
-               $read = ereg_replace(">", "&gt;", $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("<", "&lt;", $read);
+            $read = ereg_replace(">", "&gt;", $read);
+            if (strlen(trim($read)) != 0)
+               $cc[$pos] = substr($read, 3, strlen($read));
 
 
+            $pos++;
             $read = fgets($imapConnection, 1024);
          }
             $read = fgets($imapConnection, 1024);
          }
-         $rel_start = $rel_start + 50;
       }
       }
+      $read = fgets($imapConnection, 1024); // get rid of the last line
    }
 
    }
 
+
 ?>
 ?>
index c2122833e13feaa3eb4c6f4191faf6d69580170b..8a8f0c00ebb13629cc056e7e6e4523d11518e360 100644 (file)
@@ -13,7 +13,8 @@
    displayPageHeader($mailbox);
    $body = fetchBody($imapConnection, $passed_id);
    getMessageHeaders($imapConnection, $passed_id, $passed_id, $f, $s, $d);
    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));
 
    $subject = $s[0];
    $url_subj = urlencode(trim($subject));
    $url_from = trim(decodeEmailAddr($f[0]));
    $url_from = urlencode($url_from);
 
    $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 = "";
    $i = 0;
    $to_string = "";
+   $to_ary = $t;
    while ($i < count($to_ary)) {
       if ($to_string)
          $to_string = "$to_string<BR>$to_ary[$i]";
    while ($i < count($to_ary)) {
       if ($to_string)
          $to_string = "$to_string<BR>$to_ary[$i]";
       if (count($to_ary) > 1) {
          if ($show_more == false) {
             if ($i == 1) {
       if (count($to_ary) > 1) {
          if ($show_more == false) {
             if ($i == 1) {
-               $to_string = "$to_string&nbsp;&nbsp;&nbsp;(<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more=1\">more</A>)";
+               $to_string = "$to_string&nbsp;(<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more=1&show_more_cc=$show_more_cc\">more</A>)";
                $i = count($to_ary);
             }
          } else if ($i == 1) {
                $i = count($to_ary);
             }
          } else if ($i == 1) {
-            $to_string = "$to_string&nbsp;&nbsp;&nbsp;(<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more=0\">less</A>)";
+            $to_string = "$to_string&nbsp;(<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more=0&show_more_cc=$show_more_cc\">less</A>)";
          }
       }
    }
 
          }
       }
    }
 
+   /** FORMAT THE CC STRING **/
+   $i = 0;
+   $cc_string = "";
+   $cc_ary = $c;
+   while ($i < count($cc_ary)) {
+      if ($cc_string)
+         $cc_string = "$cc_string<BR>$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&nbsp;(<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more_cc=1&show_more=$show_more\">more</A>)";
+               $i = count($cc_ary);
+            }
+         } else if ($i == 1) {
+            $cc_string = "$cc_string&nbsp;(<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more_cc=0&show_more=$show_more\">less</A>)";
+         }
+      }
+   }
+
+
+
    echo "<BR>";
    echo "<TABLE COLS=1 WIDTH=95% BORDER=0 ALIGN=CENTER CELLPADDING=2>\n";
    echo "   <TR><TD BGCOLOR=DCDCDC WIDTH=100%>";
    echo "<BR>";
    echo "<TABLE COLS=1 WIDTH=95% BORDER=0 ALIGN=CENTER CELLPADDING=2>\n";
    echo "   <TR><TD BGCOLOR=DCDCDC WIDTH=100%>";
    echo "            <FONT FACE=\"Arial,Helvetica\"><B>$to_string</B></FONT>\n";
    echo "         </TD>\n";
    echo "      </TR>\n";
    echo "            <FONT FACE=\"Arial,Helvetica\"><B>$to_string</B></FONT>\n";
    echo "         </TD>\n";
    echo "      </TR>\n";
-
+   /** cc **/
+   if ($c[0]) {
+      echo "      <TR>\n";
+      echo "         <TD BGCOLOR=FFFFFF WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
+      echo "            <FONT FACE=\"Arial,Helvetica\">Cc:</FONT>\n";
+      echo "         </TD><TD BGCOLOR=FFFFFF WIDTH=85% VALIGN=TOP>\n";
+      echo "            <FONT FACE=\"Arial,Helvetica\"><B>$cc_string</B></FONT>\n";
+      echo "         </TD>\n";
+      echo "      </TR>\n";
+   }
    echo "   </TABLE></TD></TR>\n";
 
    echo "   <TR><TD BGCOLOR=FFFFFF WIDTH=100%><BR>\n";
    echo "   </TABLE></TD></TR>\n";
 
    echo "   <TR><TD BGCOLOR=FFFFFF WIDTH=100%><BR>\n";