updated todo, trying to fix this stupid multiple log email problem,
authorlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 23 Jun 2000 14:32:09 +0000 (14:32 +0000)
committerlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 23 Jun 2000 14:32:09 +0000 (14:32 +0000)
fixed HTML support in mime

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@557 7612ce4b-ef26-0410-bec9-ea0150e637f0

TODO
doc/index.html
functions/mime.php

diff --git a/TODO b/TODO
index 382ac6acc21e0124bd85a78ecd7347f4926a7d79..891bb23d541b06b444a8a3828511c9f46c7c856a 100644 (file)
--- a/TODO
+++ b/TODO
@@ -9,6 +9,7 @@ initials = taken by that person
   -     Filters
   -     Better inline HTML support including graphics (content-disposition)
   -     Foreground themes
   -     Filters
   -     Better inline HTML support including graphics (content-disposition)
   -     Foreground themes
+  -     Configurable so that after login, you go directly to INBOX
 (glp)   When deleting or moving messages (empty trash too), go back to the 
             list for the mail box you were looking at without having to click
             a link
 (glp)   When deleting or moving messages (empty trash too), go back to the 
             list for the mail box you were looking at without having to click
             a link
@@ -16,6 +17,8 @@ initials = taken by that person
 (ssg)   Search mailbox(es) for given criteria
   -     Remove subject and body requirements in Compose
   -     Select multiple Unsubscribe/Subscribe folders at one time
 (ssg)   Search mailbox(es) for given criteria
   -     Remove subject and body requirements in Compose
   -     Select multiple Unsubscribe/Subscribe folders at one time
+  -     decodeHeader on to_ary, cc_ary, and filename
+  -     Decode folder names for non-standard characters
 
 
 Finished:
 
 
 Finished:
index 8242b472f5654230e46f0703b2a0ab10eaba6786..1d3b4d0be536fa27fe6d3e672920b9247dc9288e 100644 (file)
@@ -7,15 +7,6 @@ mistakes, please email them to <a href="lehresma@css.tayloru.edu">lehresma@css.t
 </p>
 
 
 </p>
 
 
-<ul>
-   <a href="message_array.html">Message Array Format</a>
-   <ul>
-      When reading in a message from a mailbox, SquirrelMail shoves all the infomation into a
-      large array.  I have attempted to map out that array.  I have done my best to make this
-      accurate, but there probably are some inacuracies somewhere.
-   </ul>
-</ul>
-
 <ul>
    <a href="sqimap.php3">SquirrelMail IMAP Functions</a>
    <ul>
 <ul>
    <a href="sqimap.php3">SquirrelMail IMAP Functions</a>
    <ul>
@@ -47,6 +38,15 @@ mistakes, please email them to <a href="lehresma@css.tayloru.edu">lehresma@css.t
    </ul>
 </ul>
 
    </ul>
 </ul>
 
+<ul>
+   <a href="mime.txt">MIME</a>
+   <ul>
+      Ever wonder how SquirrelMail handles MIME support?  You need not search
+      any longer.  This document gives an overview of how it works and how
+      we decode MIME encoded messages.
+   </ul>
+</ul>
+
 <ul>
    Basic documentation that comes with distrbution:
    <ul>
 <ul>
    Basic documentation that comes with distrbution:
    <ul>
index c8399e4643144a2321265bc1c371f2906056102f..51a7c7b9fcd87b1b21854f80cab529216f2a923c 100644 (file)
@@ -17,7 +17,7 @@
       include "../config/config.php";
 
 
       include "../config/config.php";
 
 
-   /** Setting up the object that has the structure for the message **/
+   /** Setting up the objects that have the structure for the message **/
 
    class msg_header {
       /** msg_header contains generic variables for values that **/
 
    class msg_header {
       /** msg_header contains generic variables for values that **/
    /* MIME DECODING                                                                     */
    /* --------------------------------------------------------------------------------- */
    
    /* MIME DECODING                                                                     */
    /* --------------------------------------------------------------------------------- */
    
-   /** This function gets the structure of a message and stores it in the "message" class.
-       It will return this object for use with all relevant header information and
-       fully parsed into the standard "message" object format.
-    **/   
+   // This function gets the structure of a message and stores it in the "message" class.
+   // It will return this object for use with all relevant header information and
+   // fully parsed into the standard "message" object format.
    function mime_structure ($imap_stream, $header) {
       global $debug_mime;
       sqimap_messages_flag ($imap_stream, $header->id, $header->id, "Seen");
    function mime_structure ($imap_stream, $header) {
       global $debug_mime;
       sqimap_messages_flag ($imap_stream, $header->id, $header->id, "Seen");
       return $msg;
    }
 
       return $msg;
    }
 
+   // this starts the parsing of a particular structure.  It is called recursively,
+   // so it can be passed different structures.  It returns an object of type
+   // $message.
+   // First, it checks to see if it is a multipart message.  If it is, then it
+   // handles that as it sees is necessary.  If it is just a regular entity,
+   // then it parses it and adds the necessary header information (by calling out
+   // to mime_get_elements()
    function mime_parse_structure ($structure, $ent_id) {
       global $debug_mime;
       if ($debug_mime) echo "<font color=008800><tt>START: mime_parse_structure()</tt></font><br>";
    function mime_parse_structure ($structure, $ent_id) {
       global $debug_mime;
       if ($debug_mime) echo "<font color=008800><tt>START: mime_parse_structure()</tt></font><br>";
                break;
             default:
                if ($msg->header->type0 == "text" && $elem_num == 8) {
                break;
             default:
                if ($msg->header->type0 == "text" && $elem_num == 8) {
+                  // This is a plain text message, so lets get the number of lines
+                  // that it contains.
                   $msg->header->num_lines = $text;
                   if ($debug_mime) echo "<tt>num_lines = $text</tt><br>";
                   $msg->header->num_lines = $text;
                   if ($debug_mime) echo "<tt>num_lines = $text</tt><br>";
+
                } else if ($msg->header->type0 == "message" && $msg->header->type1 == "rfc822" && $elem_num == 8) {
                   // This is an encapsulated message, so lets start all over again and 
                   // parse this message adding it on to the existing one.
                } else if ($msg->header->type0 == "message" && $msg->header->type1 == "rfc822" && $elem_num == 8) {
                   // This is an encapsulated message, so lets start all over again and 
                   // parse this message adding it on to the existing one.
                      $structure = substr($structure, 0, $e);
                      $structure = substr($structure, 1);
                      $m = mime_parse_structure($structure, $msg->header->entity_id);
                      $structure = substr($structure, 0, $e);
                      $structure = substr($structure, 1);
                      $m = mime_parse_structure($structure, $msg->header->entity_id);
+                     
+                     // the following conditional is there to correct a bug that wasn't
+                     // incrementing the entity IDs correctly because of the special case
+                     // that message/rfc822 is.  This fixes it fine.
                      if (substr($structure, 1, 1) != "(") 
                         $m->header->entity_id = mime_increment_id(mime_new_element_level($ent_id));
                      if (substr($structure, 1, 1) != "(") 
                         $m->header->entity_id = mime_increment_id(mime_new_element_level($ent_id));
+                        
+                     // Now we'll go through and reformat the results.
                      if ($m->entities) {
                         for ($i=0; $i < count($m->entities); $i++) {
                      if ($m->entities) {
                         for ($i=0; $i < count($m->entities); $i++) {
-                           //echo "<big>TYPE: $i - ".$m->entities[$i]->header->type0." - ".$m->entities[$i]->header->type1."</big><br>";
                            $msg->addEntity($m->entities[$i]);
                         }
                      } else {
                            $msg->addEntity($m->entities[$i]);
                         }
                      } else {
-                        //echo "<big>TYPE: ".$m->header->type0." - ".$m->header->type1."</big><br>";
                         $msg->addEntity($m);
                      }
                      $structure = ""; 
                         $msg->addEntity($m);
                      }
                      $structure = ""; 
       }
       // loop through the additional properties and put those in the various headers
       if ($msg->header->type0 != "message") {
       }
       // loop through the additional properties and put those in the various headers
       if ($msg->header->type0 != "message") {
-      for ($i=0; $i < count($properties); $i++) {
-         $msg->header->{$properties[$i]["name"]} = $properties[$i]["value"];
-         if ($debug_mime) echo "<tt>".$properties[$i]["name"]." = " . $properties[$i]["value"] . "</tt><br>";
-      }
+         for ($i=0; $i < count($properties); $i++) {
+            $msg->header->{$properties[$i]["name"]} = $properties[$i]["value"];
+            if ($debug_mime) echo "<tt>".$properties[$i]["name"]." = " . $properties[$i]["value"] . "</tt><br>";
+         }
       }
       return $msg;
    }
       }
       return $msg;
    }
    // in the morning and had a flash of insight.  I went to the white-board
    // and scribbled it out, then spent a bit programming it, and this is the
    // result.  Nothing complicated, but I think my brain was fried yesterday.
    // in the morning and had a flash of insight.  I went to the white-board
    // and scribbled it out, then spent a bit programming it, and this is the
    // result.  Nothing complicated, but I think my brain was fried yesterday.
+   // Funny how that happens some times.
    //
    // This gets properties in a nested parenthesisized list.  For example,
    // this would get passed something like:  ("attachment" ("filename" "luke.tar.gz"))
    //
    // This gets properties in a nested parenthesisized list.  For example,
    // this would get passed something like:  ("attachment" ("filename" "luke.tar.gz"))
       return mime_structure ($imap_stream, $header);
    }
 
       return mime_structure ($imap_stream, $header);
    }
 
+   // This is here for debugging purposese.  It will print out a list
+   // of all the entity IDs that are in the $message object.
    function listEntities ($message) {
       if ($message) {
    function listEntities ($message) {
       if ($message) {
-            if ($message->header->entity_id)
-            echo "<tt>" . $message->header->entity_id . " : " . $message->header->type0 . "/" . $message->header->type1 . "<br>";
-            for ($i = 0; $message->entities[$i]; $i++) {
-               $msg = listEntities($message->entities[$i], $ent_id);
-               if ($msg)
-                  return $msg;
-            }
+         if ($message->header->entity_id)
+         echo "<tt>" . $message->header->entity_id . " : " . $message->header->type0 . "/" . $message->header->type1 . "<br>";
+         for ($i = 0; $message->entities[$i]; $i++) {
+            $msg = listEntities($message->entities[$i], $ent_id);
+            if ($msg)
+               return $msg;
+         }
       }
    }
 
       }
    }
 
+   // returns a $message object for a particular entity id
    function getEntity ($message, $ent_id) {
       if ($message) {
          if ($message->header->entity_id == $ent_id && strlen($ent_id) == strlen($message->header->entity_id)) {
    function getEntity ($message, $ent_id) {
       if ($message) {
          if ($message->header->entity_id == $ent_id && strlen($ent_id) == strlen($message->header->entity_id)) {
       }
    }
 
       }
    }
 
+   // figures out what entity to display and returns the $message object
+   // for that entity.
    function findDisplayEntity ($message) {
       if ($message) {
          if ($message->header->type0 == "text") {
    function findDisplayEntity ($message) {
       if ($message) {
          if ($message->header->type0 == "text") {
        bottom, etc.
     **/
    function formatBody($message, $color, $wrap_at) {
        bottom, etc.
     **/
    function formatBody($message, $color, $wrap_at) {
-      /** this if statement checks for the entity to show as the
-          primary message. To add more of them, just put them in the
-          order that is their priority.
-       **/
+      // this if statement checks for the entity to show as the
+      // primary message. To add more of them, just put them in the
+      // order that is their priority.
       global $username, $key, $imapServerAddress, $imapPort;
 
       global $username, $key, $imapServerAddress, $imapPort;
 
-
       $id = $message->header->id;
       $urlmailbox = urlencode($message->header->mailbox);
 
       $id = $message->header->id;
       $urlmailbox = urlencode($message->header->mailbox);
 
       $ent_num = findDisplayEntity ($message);
       $body = mime_fetch_body ($imap_stream, $id, $ent_num); 
 
       $ent_num = findDisplayEntity ($message);
       $body = mime_fetch_body ($imap_stream, $id, $ent_num); 
 
-      /** If there are other types that shouldn't be formatted, add
-          them here **/
-      //if ($->type1 != "html") {   
+      // If there are other types that shouldn't be formatted, add
+      // them here 
+      if ($message->header->type1 != "html") {   
          $body = translateText($body, $wrap_at, $charset);
          $body = translateText($body, $wrap_at, $charset);
-      //}   
+      }   
 
       $body .= "<BR><SMALL><CENTER><A HREF=\"../src/download.php?absolute_dl=true&passed_id=$id&passed_ent_id=$ent_num&mailbox=$urlmailbox\">". _("Download this as a file") ."</A></CENTER><BR></SMALL>";
 
 
       $body .= "<BR><SMALL><CENTER><A HREF=\"../src/download.php?absolute_dl=true&passed_id=$id&passed_ent_id=$ent_num&mailbox=$urlmailbox\">". _("Download this as a file") ."</A></CENTER><BR></SMALL>";