* Fix for the UW/mh problem with deleting messages.
[squirrelmail.git] / functions / imap_search.php
index a9cda0660a1fc32bf1920dac85f614a88db5a80b..d628446146432564cfc9aad319900a42b296459c 100644 (file)
@@ -1,20 +1,19 @@
 <?php 
-/******************************************************************
- ** IMAP SEARCH ROUTIES
- ** $Id$
- *****************************************************************/
-   if (!isset($imap_php))
-      include("../functions/imap.php");
-   if (!isset($date_php))
-      include("../functions/date.php");
-   if (!isset($array_php))
-      include("../functions/array.php");
-   if (!isset($mailbox_display_php))
-      include("../functions/mailbox_display.php");
-   if (!isset($mime_php))
-      include("../functions/mime.php");
-
-   $imap_search_php = true;
+   /******************************************************************
+    ** IMAP SEARCH ROUTIES
+    ** $Id$
+    *****************************************************************/
+    
+   if (defined ('imap_search_php'))
+      return;
+   define ('imap_search_php', true);
+   
+   include("../functions/imap.php");
+   include("../functions/date.php");
+   include("../functions/array.php");
+   include("../functions/mailbox_display.php");
+   include("../functions/mime.php");
+
 
 function sqimap_search($imapConnection,$search_where,$search_what,$mailbox,$color) {
    global $msgs, $message_highlight_list, $squirrelmail_language, $languages, $index_order;
@@ -30,7 +29,12 @@ function sqimap_search($imapConnection,$search_where,$search_what,$mailbox,$colo
    fputs($imapConnection,$ss);
 
    # Read Data Back From IMAP
-   $readin = sqimap_read_data ($imapConnection, "a001", true, $result, $message);
+   $readin = sqimap_read_data ($imapConnection, "a001", false, $result, $message);
+   if (isset($languages[$squirrelmail_language]["CHARSET"]) && strtolower($result) == "no") { 
+      $ss = "a001 SEARCH CHARSET \"US-ASCII\" ALL $search_where \"$search_what\"\r\n";
+      fputs ($imapConnection, $ss);
+      $readin = sqimap_read_data ($imapConnection, "a001", true, $result, $message);
+   }
    unset($messagelist); $msgs=""; $c = 0;
 
    #Keep going till we find the SEARCH responce
@@ -80,7 +84,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] = ereg_replace('  ', ' ', $date[$j]);
          $tmpdate = explode(" ", trim($date[$j]));
 
          $messages[$j]["TIME_STAMP"] = getTimeStamp($tmpdate);