Happy New Year
[squirrelmail.git] / functions / imap_asearch.php
index 0db279c0a298557219e86a1cd654a2b9db2a0b92..e8371a364fa95eb3866b691cadf67a1ba38da859 100644 (file)
@@ -8,7 +8,7 @@
  * Subfolder search idea from Patch #806075 by Thomas Pohl xraven at users.sourceforge.net. Thanks Thomas!
  *
  * @author Alex Lemaresquier - Brainstorm <alex at brainstorm.fr>
- * @copyright &copy; 1999-2005 The SquirrelMail Project Team
+ * @copyright 1999-2020 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
@@ -19,8 +19,8 @@
 
 /** This functionality requires the IMAP and date functions
  */
-require_once(SM_PATH . 'functions/imap_general.php');
-require_once(SM_PATH . 'functions/date.php');
+//require_once(SM_PATH . 'functions/imap_general.php');
+//require_once(SM_PATH . 'functions/date.php');
 
 /** Set to TRUE to dump the IMAP dialogue
  * @global bool $imap_asearch_debug_dump
@@ -190,7 +190,7 @@ function sqimap_asearch_parse_date($what)
     global $imap_asearch_months;
 
     $what = trim($what);
-    $what = ereg_replace('[ /\\.,]+', '-', $what);
+    $what = preg_replace('/[ \/\\.,]+/', '-', $what);
     if ($what) {
         preg_match('/^([0-9]+)-+([^\-]+)-+([0-9]+)$/', $what, $what_parts);
         if (count($what_parts) == 4) {
@@ -232,7 +232,7 @@ function sqimap_asearch_build_criteria($opcode, $what, $charset)
         default:
         case 'anum':
             $what = str_replace(' ', '', $what);
-            $what = ereg_replace('[^0-9]+[^KMG]$', '', strtoupper($what));
+            $what = preg_replace('/[^0-9]+[^KMG]$/', '', strtoupper($what));
             if ($what != '') {
                 switch (substr($what, -1)) {
                     case 'G':
@@ -268,7 +268,7 @@ function sqimap_asearch_build_criteria($opcode, $what, $charset)
             $criteria = $opcode . ' ' . sqimap_asearch_encode_string($what, $charset) . ' ';
         break;
         case 'asequence':
-            $what = ereg_replace('[^0-9:\(\)]+', '', $what);
+            $what = preg_replace('/[^0-9:()]+/', '', $what);
             if ($what != '')
                 $criteria = $opcode . ' ' . $what . ' ';
         break;
@@ -313,12 +313,12 @@ function sqimap_run_search($imapConnection, $search_string, $search_charset)
         $query = 'SEARCH CHARSET "' . strtoupper($search_charset) . '" ' . $search_string;
     else
         $query = 'SEARCH ' . $search_string;
-    $readin = sqimap_run_command($imapConnection, $query, false, $response, $message, TRUE);
+    $readin = sqimap_run_command_list($imapConnection, $query, false, $response, $message, TRUE);
 
     /* 6.4.4 try US-ASCII charset if we tried an OPTIONAL [CHARSET] and received a tagged NO response (SHOULD be [BADCHARSET]) */
     if (($search_charset != '')  && (strtoupper($response) == 'NO')) {
         $query = 'SEARCH CHARSET US-ASCII ' . $search_string;
-        $readin = sqimap_run_command($imapConnection, $query, false, $response, $message, TRUE);
+        $readin = sqimap_run_command_list($imapConnection, $query, false, $response, $message, TRUE);
     }
     if (strtoupper($response) != 'OK') {
         sqimap_asearch_error_box($response, $query, $message);
@@ -368,6 +368,7 @@ function sqimap_asearch_get_sort_criteria($mailbox, $sort_by)
     $sort_opcodes = array ('DATE', 'FROM', 'SUBJECT', 'SIZE');
     if ($internal_date_sort == true)
         $sort_opcodes[0] = 'ARRIVAL';
+// FIXME: Why are these commented out?  I have no idea what this code does, but both of these functions sound more robust than the simple string check that's being used now.  Someone who understands this code should either fix this or remove these lines completely or document why they are here commented out
 //        if (handleAsSent($mailbox))
 //        if (isSentFolder($mailbox))
     if ($mailbox == $sent_folder)
@@ -486,5 +487,3 @@ function sqimap_asearch($imapConnection, &$mailbox_array, &$biop_array, &$unop_a
     }
     return ($mbox_search);
 }
-
-?>