Removed ereg and ereg_replace calls. Using simple string manipulation.
[squirrelmail.git] / functions / imap_messages.php
index 98449ad9e079b567580e442a0dd9fd2b9f538364..e0215d6fe2d53ac2d7b45d2bdff9ec2a9c6b5b1d 100755 (executable)
@@ -2,7 +2,9 @@
    /**
     **  imap_messages.php
     **
-    **  This implements functions that manipulate messages 
+    **  This implements functions that manipulate messages
+    **
+    **  $Id$
     **/
 
    if (!isset($mime_php)) include "../functions/mime.php";
@@ -51,7 +53,8 @@
     **  Returns some general header information -- FROM, DATE, and SUBJECT
     ******************************************************************************/
    class small_header {
-      var $from, $subject, $date, $to, $priority, $message_id;
+      var $from = '', $subject = '', $date = '', $to = '', 
+          $priority = 0, $message_id = 0, $cc = '';
    }
         
    function sqimap_get_small_header ($imap_stream, $id, $sent) {
       $from = _("Unknown Sender");
       $priority = "0";
       $messageid = "<>";
+      $cc = "";
+      $to = "";
+      $date = "";
+      $type[0] = "";
+      $type[1] = "";
 
       $g = 0;
       for ($i = 0; $i < count($read); $i++) {
       
       $header = new small_header;
       if ($sent == true)
-         $header->from = (trim($to) != '')? $to : _('(only Cc/Bcc)');
+         $header->from = (trim($to) != '')? $to : _("(only Cc/Bcc)");
       else   
          $header->from = $from;
 
       $header->size = $size;
       $header->type0 = $type[0];
       $header->type1 = $type[1];
-
+      
       return $header;
    }
 
     ******************************************************************************/
    function sqimap_get_message ($imap_stream, $id, $mailbox) {
       $header = sqimap_get_message_header($imap_stream, $id, $mailbox);
-      $msg = sqimap_get_message_body($imap_stream, &$header);
-      return $msg;
+      return sqimap_get_message_body($imap_stream, $header);
    }
 
    /******************************************************************************
             if (strpos(strtolower(trim($line)), "charset=")) {
                $pos = strpos($line, "charset=") + 8;
                $charset = trim($line);
-               if (strpos($line, " ", $pos) > 0) {
-                  $charset = substr($charset, $pos, strpos($line, " ", $pos));
+               if (strpos($line, ";", $pos) > 0) {
+                  $charset = substr($charset, $pos, strpos($line, ";", $pos)-$pos);
                } else {
                   $charset = substr($charset, $pos);
                }
          /** FROM **/
          else if (strtolower(substr($read[$i], 0, 5)) == "from:") {
             $hdr->from = trim(substr($read[$i], 5, strlen($read[$i]) - 6));
-            if ($hdr->replyto == "")
+            if (! isset($hdr->replyto) || $hdr->replyto == "")
                $hdr->replyto = $hdr->from;
             $i++;
          }
     ******************************************************************************/
    function sqimap_get_message_body ($imap_stream, &$header) {
       $id = $header->id;
-      return decodeMime($imap_stream, $body, &$header);
+      return decodeMime($imap_stream, $header);
    }