Browse Source

Replaced ereg_replace with str_replace on several occasions, should be faster.

Thijs Kinkhorst 23 years ago
parent
commit
46e29148e7

+ 1 - 1
functions/imap_messages.php

@@ -245,7 +245,7 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list, $issent) {
 function sqimap_get_flags ($imap_stream, $i) {
     $read = sqimap_run_command ($imap_stream, "FETCH $i:$i FLAGS", true, $response, $message);
     if (ereg("FLAGS(.*)", $read[0], $regs)) {
-        return explode(" ", trim(ereg_replace('[\\(\\)\\\\]', '', $regs[1])));
+        return explode(' ', trim(ereg_replace('[\\(\\)\\\\]', '', $regs[1])));
     }
     return Array('None');
 }

+ 7 - 7
functions/imap_search.php

@@ -31,19 +31,19 @@ function sqimap_search($imapConnection,$search_where,$search_what,$mailbox,$colo
 #  account for multiple search terms
 
         $multi_search = array ();
-        $search_what = ereg_replace("[ ]{2,}", " ", $search_what);
-        $multi_search = split (" ", $search_what);
+        $search_what = ereg_replace("[ ]{2,}", ' ', $search_what);
+        $multi_search = split (' ', $search_what);
         if (count($multi_search)==1) {
-                $search_string = $search_where . " " . "\"" . $multi_search[0] . "\"";
+                $search_string = $search_where . ' ' . '"' . $multi_search[0] . '"';
         }
         else {
-                $search_string = "";
+                $search_string = '';
 		$count = count($multi_search);
                 for ($x=0;$x<$count;$x++) {
-                	$search_string = $search_string . " " . $search_where . " " . "\"" . $multi_search[$x] . "\"";
+                	$search_string = $search_string . ' ' . $search_where . " " . '"' . $multi_search[$x] . '" ';
                 }
         }
-	$search_string = ereg_replace("^ ", "", $search_string);
+	$search_string = trim($search_string);
 
 # now use $search_string in the imap search
 
@@ -110,7 +110,7 @@ function sqimap_search($imapConnection,$search_where,$search_what,$mailbox,$colo
 
     $j = 0;
     while ($j < count($messagelist)) {
-            $date[$j] = ereg_replace('  ', ' ', $date[$j]);
+            $date[$j] = str_replace('  ', ' ', $date[$j]);
             $tmpdate = explode(" ", trim($date[$j]));
 
             $messages[$j]["TIME_STAMP"] = getTimeStamp($tmpdate);

+ 1 - 1
functions/mailbox_display.php

@@ -266,7 +266,7 @@ function showMessagesForMailbox
 
         while ($j < $end_loop) {
             if (isset($date[$j])) {
-                $date[$j] = ereg_replace('  ', ' ', $date[$j]);
+                $date[$j] = str_replace('  ', ' ', $date[$j]);
                 $tmpdate = explode(' ', trim($date[$j]));
             } else {
                 $tmpdate = $date = array('', '', '', '', '', '');

+ 2 - 2
functions/mime.php

@@ -765,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)) {

+ 1 - 1
src/compose.php

@@ -330,7 +330,7 @@ function newMail () {
     /* This formats a CC string if they hit "reply all" */
     if ($send_to_cc != '') {
         $send_to_cc = ereg_replace('"[^"]*"', '', $send_to_cc);
-        $send_to_cc = ereg_replace(';', ',', $send_to_cc);
+        $send_to_cc = str_replace(';', ',', $send_to_cc);
         $sendcc = explode(',', $send_to_cc);
         $send_to_cc = '';
 

+ 6 - 6
src/options_highlight.php

@@ -38,16 +38,16 @@ if ($action == 'delete' && isset($theid)) {
     exit;
 } else if ($action == 'save') {
     if (!$theid) $theid = 0;
-    $identname = ereg_replace(',', ' ', $identname);
+    $identname = str_replace(',', ' ', $identname);
     if ($color_type == 1) $newcolor = $newcolor_choose;
     elseif ($color_type == 2) $newcolor = $newcolor_input;
     else $newcolor = $color_type;
 
-    $newcolor = ereg_replace(',', '', $newcolor);
-    $newcolor = ereg_replace('#', '', $newcolor);
-    $newcolor = ereg_replace('"', '', $newcolor);
-    $newcolor = ereg_replace('\'', '', $newcolor);
-    $value = ereg_replace(',', ' ', $value);
+    $newcolor = str_replace(',', '', $newcolor);
+    $newcolor = str_replace('#', '', $newcolor);
+    $newcolor = str_replace('"', '', $newcolor);
+    $newcolor = str_replace('\'', '', $newcolor);
+    $value = str_replace(',', ' ', $value);
 
     setPref($data_dir, $username, "highlight$theid", $identname.','.$newcolor.','.$value.','.$match_type);
     $message_highlight_list[$theid]['name'] = $identname;

+ 2 - 2
src/vcard.php

@@ -59,7 +59,7 @@ foreach ($vcard as $l) {
             $k .= ';' . $attr;
     }
 
-    $v = ereg_replace(';', "\n", $v);
+    $v = str_replace(';', "\n", $v);
     $vcard_nice[$k] = $v;
 }
 
@@ -201,4 +201,4 @@ echo '</select>' .
         '</TD></TR></TABLE>' .
         '</body></html>';
 
-?>
+?>