rfc822_header
authorstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 6 Aug 2002 22:46:03 +0000 (22:46 +0000)
committerstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 6 Aug 2002 22:46:03 +0000 (22:46 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@3262 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/imap_messages.php
functions/mime.php

index f2e38335161f49379d9dfecb357063af4839c31c..f0d5366504b6518055feb00aa5c80d5634e21d04 100755 (executable)
@@ -621,6 +621,60 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list) {
     return $result;
 }
 
+function sqimap_get_headerfield($imap_stream, $field) {
+    $sid = sqimap_session_id(false);
+
+    $results = array();
+    $read_list = array();
+
+    $query = "$sid FETCH 1:* (UID BODY.PEEK[HEADER.FIELDS ($field)])\r\n";
+    fputs ($imap_stream, $query);
+    $readin_list = sqimap_read_data_list($imap_stream, $sid, false, $response, $message);
+    $i = 0;
+
+    foreach ($readin_list as $r) {
+        $r = implode('',$r);
+        /* first we unfold the header */
+       $r = str_replace(array("\r\n\t","\r\n\s"),array('',''),$r);
+       /* 
+        * now we can make a new header array with each element representing 
+        * a headerline
+        */
+       $r = explode("\r\n" , $r);  
+        if (!$uid_support) {
+            if (!preg_match("/^\\*\s+([0-9]+)\s+FETCH/iAU",$r[0], $regs)) {
+                set_up_language($squirrelmail_language);
+                echo '<br><b><font color=$color[2]>' .
+                      _("ERROR : Could not complete request.") .
+                      '</b><br>' .
+                      _("Unknown response from IMAP server: ") . ' 1.' .
+                      $r[0] . "</font><br>\n";
+            } else {
+                $id = $regs[1];
+            }
+        } else {
+            if (!preg_match("/^\\*\s+([0-9]+)\s+FETCH.*UID\s+([0-9]+)\s+/iAU",$r[0], $regs)) {
+                set_up_language($squirrelmail_language);
+                echo '<br><b><font color=$color[2]>' .
+                     _("ERROR : Could not complete request.") .
+                     '</b><br>' .
+                     _("Unknown response from IMAP server: ") . ' 1.' .
+                     $r[0] . "</font><br>\n";
+            } else {
+               $id = $regs[2];
+            }
+        }
+       $field = $r[1];
+       $field = substr($field,strlen($field)+2);
+       $result[] = array($id,$field);
+    }
+    return $result;
+}
+
+
+
+
 /*
  * Returns a message array with all the information about a message.  
  * See the documentation folder for more information about this array.
@@ -643,9 +697,9 @@ function sqimap_get_message ($imap_stream, $id, $mailbox) {
     $bodystructure = implode('',$read);
     $msg =  mime_structure($bodystructure,$flags);
     $read = sqimap_run_command ($imap_stream, "FETCH $id BODY[HEADER]", true, $response, $message, $uid_support);
-    $msg->addRFC822Header($read);
-    $msg->id = $id;
-    $msg->mailbox = $mailbox;
+    $rfc822_header = new rfc822_header();
+    $rfc822_header->parseHeader($read);
+    $msg->rfc822_header = $rfc822_header;
     return $msg;
 }
 
index 8717a5b639d4015abf09ff98a8306756f56271ba..cc44fd614057601606a8223410faab163ef7b4f2 100644 (file)
@@ -318,7 +318,6 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma
     if (($body_message->header->type0 == 'text') ||
         ($body_message->header->type0 == 'rfc822')) {
        $body = mime_fetch_body ($imap_stream, $id, $ent_num);
-       
         $body = decodeBody($body, $body_message->header->encoding);
         $hookResults = do_hook("message_body", $body);
         $body = $hookResults[1];
@@ -328,12 +327,14 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma
         if ($body_message->header->type1 == 'html') {
             if ( $show_html_default <> 1 ) {
                 $body = strip_tags( $body );
-                translateText($body, $wrap_at, $body_message->header->charset);
+                translateText($body, $wrap_at, 
+                 $body_message->header->getParameter['charset']);
             } else {
                 $body = magicHTML( $body, $id, $message, $mailbox );
             }
         } else {
-            translateText($body, $wrap_at, $body_message->header->charset);
+            translateText($body, $wrap_at, 
+              $body_message->header->getParameter('charset'));
         }
 
         if ($has_unsafe_images) {
@@ -367,14 +368,14 @@ function formatAttachments($message, $exclude_id, $mailbox, $id) {
 
     foreach ($att_ar as $att) {
                 
-        $ent = urlencode($att->entity_id);
+        $ent = urldecode($att->entity_id);
        $header = $att->header;
         $type0 = strtolower($header->type0);
         $type1 = strtolower($header->type1);
        $name = '';
        if ($type0 =='message' && $type1 == 'rfc822') {
-
-            $filename = decodeHeader($header->subject);
+           $rfc822_header = $att->rfc822_header;
+            $filename = decodeHeader($rfc822_header->subject);
             $display_filename = $filename;
             
             $DefaultLink =
@@ -407,7 +408,7 @@ function formatAttachments($message, $exclude_id, $mailbox, $id) {
                         '</b>&nbsp;&nbsp;</small></TD>' .
                         "<TD><SMALL>[ $type0/$type1 ]&nbsp;</SMALL></TD>" .
                         '<TD><SMALL>';
-           $from_o = $header->from;
+           $from_o = $rfc822_header->from;
            if (is_object($from_o)) {
                $from_name = $from_o->getAddress(false);
            } else {
@@ -428,9 +429,9 @@ function formatAttachments($message, $exclude_id, $mailbox, $id) {
             }
             unset($Links);
         } else {
-            $filename = decodeHeader($header->filename);
+            $filename = decodeHeader($header->getParameter('filename'));
             if (trim($filename) == '') {
-               $name = decodeHeader($header->name);
+               $name = decodeHeader($header->getParameter('name'));
                 if (trim($name) == '') {
                     if ( trim( $header->id ) == '' )
                         $display_filename = 'untitled-[' . $ent . ']' ;