I do devel in SquirrelMail too.
[squirrelmail.git] / functions / mime.php
index dbd1bbd5606c8c75b37f8690368c0c0cf4f52149..c9a1892d9bea51b658e01bcc099c2174cf5d21ed 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * mime.php
  *
- * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Copyright (c) 1999-2003 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * This contains the functions necessary to detect and decode MIME
@@ -29,9 +29,8 @@ function mime_structure ($bodystructure, $flags=array()) {
     /* Isolate the body structure and remove beginning and end parenthesis. */
     $read = trim(substr ($bodystructure, strpos(strtolower($bodystructure), 'bodystructure') + 13));
     $read = trim(substr ($read, 0, -1));
-    $msg =& new Message();
-    $res  = $msg->parseStructure($read);
-    $msg  = $res[0];
+    $i = 0;
+    $msg = Message::parseStructure($read,$i);
     if (!is_object($msg)) {
         include_once(SM_PATH . 'functions/display_messages.php');
         global $color, $mailbox;
@@ -84,6 +83,8 @@ function mime_structure ($bodystructure, $flags=array()) {
     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.
@@ -323,16 +324,12 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma
      * order that is their priority.
      */
     global $startMessage, $username, $key, $imapServerAddress, $imapPort,
-           $show_html_default, $has_unsafe_images, $sort;
+           $show_html_default, $sort, $has_unsafe_images;
 
-    if ( !check_php_version(4,1) ) {
-        global $_GET;
-    }
-    if(isset($_GET['view_unsafe_images'])) {
-        $view_unsafe_images = $_GET['view_unsafe_images'];
+    if( !sqgetGlobalVar('view_unsafe_images', $view_unsafe_images, SQ_GET) ) {
+        $view_unsafe_images = false;
     }
 
-    $has_unsafe_images= 0;
     $body = '';
     $urlmailbox = urlencode($mailbox);
     $body_message = getEntity($message, $ent_num);
@@ -369,17 +366,20 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma
                           $body_message->header->getParameter('charset'));
         }
 
-        if ($has_unsafe_images) {
-            if ($view_unsafe_images) {
-                $untext = '">' . _("Hide Unsafe Images");
-            } else {
-                $untext = '&view_unsafe_images=1">' . _("View Unsafe Images");
-            }
-            $body .= '<center><small><a href="read_body.php?passed_id=' . $id .
-                     '&amp;passed_ent_id=' . $message->entity_id . '&amp;mailbox=' . $urlmailbox .
-                     '&amp;sort=' . $sort . '&amp;startMessage=' . $startMessage . '&amp;show_more=0' .
-                     $untext . '</a></small></center><br>' . "\n";
+        if ($view_unsafe_images) {
+            $untext = '">' . _("Hide Unsafe Images");
+        } else {
+           if (isset($has_unsafe_images) && $has_unsafe_images) {
+               $untext = '&amp;view_unsafe_images=1">' . _("View Unsafe Images");
+           } else {
+               $untext = '">';
+           }
         }
+        $body .= '<center><small><a href="read_body.php?passed_id=' . $id .
+                 '&amp;passed_ent_id=' . $message->entity_id . '&amp;mailbox=' . $urlmailbox .
+                 '&amp;sort=' . $sort . '&amp;startMessage=' . $startMessage . '&amp;show_more=0' .
+                 $untext . '</a></small></center><br>' . "\n";
+        
     }
     return $body;
 }
@@ -411,7 +411,9 @@ function formatAttachments($message, $exclude_id, $mailbox, $id) {
             $default_page = '../src/read_body.php';
             $rfc822_header = $att->rfc822_header;
             $filename = decodeHeader($rfc822_header->subject);
-
+            if (trim( $filename ) == '') {
+                $filename = 'untitled-[' . $ent . ']' ;
+           }           
             $from_o = $rfc822_header->from;
             if (is_object($from_o)) {
                 $from_name = $from_o->getAddress(false);
@@ -1487,7 +1489,7 @@ function sq_sanitize($body,
  * @param  $id    the id of the message
  * @return        a string with html safe to display in the browser.
  */
-function magicHTML($body, $id, $message, $mailbox = 'INBOX'){
+function magicHTML($body, $id, $message, $mailbox = 'INBOX') {
     global $attachment_common_show_images, $view_unsafe_images,
            $has_unsafe_images;
     /**
@@ -1589,8 +1591,8 @@ function magicHTML($body, $id, $message, $mailbox = 'INBOX'){
                           )
                 )
         );
-    if(isset($_GET['view_unsafe_images'])) {
-        $view_unsafe_images = $_GET['view_unsafe_images'];
+    if( !sqgetGlobalVar('view_unsafe_images', $view_unsafe_images, SQ_GET) ) {
+       $view_unsafe_images = false;
     }
     if (!$view_unsafe_images){
         /**