small fix
[squirrelmail.git] / functions / mime.php
index 278e5673f202a9a255e47322b19c8b16a1da5d16..a1394a6647e2c632e9f20043219e0024de0f7c86 100644 (file)
@@ -453,7 +453,11 @@ function mime_print_body_lines ($imap_stream, $id, $ent_id, $encoding) {
     $sid = sqimap_session_id();
     // Don't kill the connection if the browser is over a dialup
     // and it would take over 30 seconds to download it.
-    set_time_limit(0);
+
+    // donĀ“t call set_time_limit in safe mode.
+    if (!ini_get("safe_mode")) {
+        set_time_limit(0);
+    }
     
     fputs ($imap_stream, "$sid FETCH $id BODY[$ent_id]\r\n");
     $cnt = 0;
@@ -690,9 +694,17 @@ function formatAttachments ($message, $ent_id, $mailbox, $id) {
                "../src/download.php?absolute_dl=true&passed_id=$id&mailbox=$urlMailbox&passed_ent_id=$ent";
            $ImageURL = '';
 
+           /* this executes the attachment hook with a specific MIME-type.
+            * if that doens't have results, it tries if there's a rule
+            * for a more generic type. */
            $HookResults = do_hook("attachment $type0/$type1", $Links,
                $startMessage, $id, $urlMailbox, $ent, $DefaultLink,
                $display_filename, $where, $what);
+           if(count($HookResults[1]) <= 1) {
+               $HookResults = do_hook("attachment $type0/*", $Links,
+               $startMessage, $id, $urlMailbox, $ent, $DefaultLink,  
+               $display_filename, $where, $what);
+           }
 
            $Links = $HookResults[1];
            $DefaultLink = $HookResults[6];
@@ -761,10 +773,10 @@ function decodeBody($body, $encoding) {
 function decodeHeader ($string, $utfencode=true) {
   if (eregi('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=',
             $string, $res)) {
-     if (ucfirst($res[2]) == "B") {
+     if (ucfirst($res[2]) == 'B') {
         $replace = base64_decode($res[3]);
      } else {
-        $replace = ereg_replace("_", " ", $res[3]);
+        $replace = str_replace('_', ' ', $res[3]);
     // Convert lowercase Quoted Printable to uppercase for
     // quoted_printable_decode to understand it.
     while (ereg("(=(([0-9][abcdef])|([abcdef][0-9])|([abcdef][abcdef])))", $replace, $res)) {
@@ -836,7 +848,7 @@ function encodeHeader ($string) {
 */
 function MagicHTML( $body, $id ) {
 
-    global $message, $PHP_SELF, $HTTP_SERVER_VARS, 
+    global $message, $HTTP_SERVER_VARS, 
            $attachment_common_show_images;
 
     $attachment_common_show_images =