Replaced ereg_replace with str_replace on several occasions, should be faster.
[squirrelmail.git] / functions / mime.php
index 263d55fc54df47f47d770e406b8b5deb49352b3e..1175f26f4ba2eaee8aa3659463f8a6e9795857d5 100644 (file)
@@ -411,6 +411,7 @@ function mime_fetch_body ($imap_stream, $id, $ent_id ) {
                 $k++;
             }
             if ( $base <> '' )
+                
                 $ret = "<base href=\"$base\">" . $ret;
         }
     } else if (ereg('"([^"]*)"', $topline, $regs)) {
@@ -452,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;
@@ -760,10 +765,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)) {
@@ -835,8 +840,11 @@ 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 =
+                     FALSE; // Don't display attached images in HTML mode
     $j = strlen( $body );   // Legnth of the HTML
     $ret = '';              // Returned string
     $bgcolor = '#ffffff';   // Background style color (defaults to white)
@@ -1023,7 +1031,7 @@ function MagicHTML( $body, $id ) {
 return( "\n\n<!-- HTML Output ahead -->\n" .
         $ret .
         "\n<!-- END of HTML Output --><base href=\"".
-        $HTTP_SERVER_VARS["SERVER_NAME"] . substr( $PHP_SELF, 0, strlen( $PHP_SELF ) - 13 ) .
+        get_location() . '/'.
         "\">\n\n" );
 }