Changed regexps
[squirrelmail.git] / src / read_body.php
index 609635c538ac00cf7859080089e2f01f582f5a0d..c29b9497b24a15e8c6bf237697bedea31db76e77 100644 (file)
@@ -7,14 +7,16 @@
    **
    **  This file is used for reading the msgs array and displaying
    **  the resulting emails in the right frame.
+   **
+   **  $Id$
    **/
 
    session_start();
 
-   if (!isset($config_php))
-      include("../config/config.php");
    if (!isset($strings_php))
       include("../functions/strings.php");
+   if (!isset($config_php))
+      include("../config/config.php");
    if (!isset($page_header_php))
       include("../functions/page_header.php");
    if (!isset($imap_php))
@@ -32,7 +34,7 @@
    do_hook("html_top");
    displayPageHeader($color, $mailbox);
 
-   if ($view_hdr) {
+   if (isset($view_hdr)) {
       fputs ($imapConnection, "a003 FETCH $passed_id BODY[HEADER]\r\n");
       $read = sqimap_read_data ($imapConnection, "a003", true, $a, $b); 
       
    $url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs);
    
    // 4) Make them unique -- weed out duplicates
-   $url_replytoall_extra_addrs = array_unique($url_replytoall_extra_addrs);
+   // (Coded for PHP 4.0.0)
+   $url_replytoall_extra_addrs =
+      array_keys(array_flip($url_replytoall_extra_addrs));
    
    // 5) Remove the addresses we'll be sending the message 'to'
    $url_replytoall_avoid_addrs = parseAddrs($message->header->replyto);
 
    /** FORMAT THE CC STRING **/
    $i = 0;
-   $cc_string = "";
-   $cc_ary = $message->header->cc;
-   while ($i < count(decodeHeader($cc_ary))) {
-      $cc_ary[$i] = htmlspecialchars($cc_ary[$i]);
-      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) {
+   if (isset ($message->header->cc[0]) && trim($message->header->cc[0])){
+      $cc_string = "";
+      $cc_ary = $message->header->cc;
+      while ($i < count(decodeHeader($cc_ary))) {
+         $cc_ary[$i] = htmlspecialchars($cc_ary[$i]);
+         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) {
+                  if ($where && $what) {
+                     // from a search
+                     $cc_string = "$cc_string&nbsp;(<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&what=".urlencode($what)."&where=".urlencode($where)."&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
+                  } else {
+                     $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\">$echo_more</A>)";
+                  }   
+                  $i = count($cc_ary);
+               }
+            } else if ($i == 1) {
                if ($where && $what) {
                   // from a search
-                  $cc_string = "$cc_string&nbsp;(<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&what=".urlencode($what)."&where=".urlencode($where)."&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
+                  $cc_string = "$cc_string&nbsp;(<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&what=".urlencode($what)."&where=".urlencode($where)."&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
                } else {
-                  $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\">$echo_more</A>)";
+                  $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\">$echo_less</A>)";
                }   
-               $i = count($cc_ary);
             }
-         } else if ($i == 1) {
-            if ($where && $what) {
-               // from a search
-               $cc_string = "$cc_string&nbsp;(<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&what=".urlencode($what)."&where=".urlencode($where)."&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
-            } else {
-               $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\">$echo_less</A>)";
-            }   
          }
       }
    }
-
    /** make sure everything will display in HTML format **/
    $from_name = decodeHeader(htmlspecialchars($message->header->from));
    $subject = decodeHeader(htmlspecialchars($message->header->subject));
    echo "         </TD>\n";
    echo "      </TR>\n";
    /** cc **/
-   if ($message->header->cc) {
+   if (isset($cc_string)) {
       echo "      <TR>\n";
       echo "         <TD BGCOLOR=\"$color[0]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
       echo "            Cc:\n";