Modified sqimap_session_id to return something when there is no session ID
[squirrelmail.git] / functions / mime.php
index cfb9e9d9706255e6b60aa6094b59aa1e01a601e2..e95246e79ffcc7c9b2baf245150f5e820db39016 100644 (file)
@@ -1,5 +1,9 @@
 <?php
+
    /** mime.php
+    **
+    **  Copyright (c) 1999-2001 The Squirrelmail Development Team
+    **  Licensed under the GNU GPL. For full terms see the file COPYING.
     **
     ** This contains the functions necessary to detect and decode MIME
     ** messages.
@@ -7,11 +11,8 @@
     ** $Id$
     **/
 
-   if (defined('mime_php'))
-      return;
-   define('mime_php', true);
-
    require_once('../functions/imap.php');
+   require_once('../functions/attachment_common.php');
 
    /** Setting up the objects that have the structure for the message **/
 
         $j = strlen( $body );   // Legnth of the HTML
         $ret = '';              // Returned string
         $bgcolor = '#ffffff';   // Background style color (defaults to white)
+       $textcolor = '#000000'; // Foreground style color (defaults to black)
         $leftmargin = '';       // Left margin style
         $title = '';            // HTML title if any
 
         $i = 0;
         while( $i < $j ) {
             if( $body{$i} == '<' ) {
-                $tag = $body{$i+1}.$body{$i+2}.$body{$i+3}.$body{$i+4};
+               $pos = $i + 1;
+               $tag = '';
+               while ($body{$pos} == ' ' || $body{$pos} == "\t" ||
+                      $body{$pos} == "\n")
+                   $pos ++;
+               while (strlen($tag) < 4 && $body{$pos} != ' ' && 
+                      $body{$pos} != "\t" && $body{$pos} != "\n") {
+                   $tag .= $body{$pos};
+                   $pos ++;
+               }
                 switch( strtoupper( $tag ) ) {
                     // Strips the entire tag and contents
                     case 'APPL':
                         $i += 5;
                        if (! isset($base))
                           $base = '';
-                        $ret .= stripEvent( $i, $j, $body, $id, $base );
-                        //if( $bgcolor <> '' )
-                            $ret .= " bgcolor=$bgcolor";
-                        $ret .= ' width=100%><tr>';
+                       $ret .= stripEvent( $i, $j, $body, $id, $base );
+                        $ret .= " bgcolor=$bgcolor width=100%><tr>";
                         if( $leftmargin <> '' )
                             $ret .= "<td width=$leftmargin>&nbsp;</td>";
                         $ret .= '<td>';
+                       if (strtolower($bgcolor) == 'ffffff' || 
+                           strtolower($bgcolor) == '#ffffff')
+                          $ret .= '<font color=#000000>';
                         break;
                     case 'BASE':
                         $i += 5;
                         }
                         break;
                     case '/BOD':
-                        $ret .= '</td></tr></TABLE>';
+                        $ret .= '</font></td></tr></TABLE>';
                         $i += 6;
                         break;
                     default: