X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fimap_search.php;h=38832fc1be862cc1af0ec8fc60ea3d7ac8b743cb;hb=76911253eb850bacde3d86c8cb7b4af072e67ebe;hp=fa2b6a95e6fbbcd280991bc12c9e0f6d93c8eb49;hpb=5c9a316d0538c44ec3bfd4d262f6269bf29c21f4;p=squirrelmail.git
diff --git a/functions/imap_search.php b/functions/imap_search.php
index fa2b6a95..38832fc1 100644
--- a/functions/imap_search.php
+++ b/functions/imap_search.php
@@ -3,7 +3,7 @@
/**
* imap_search.php
*
- * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Copyright (c) 1999-2003 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* IMAP search routines
@@ -11,17 +11,18 @@
* $Id$
*/
-require_once('../functions/imap.php');
-require_once('../functions/date.php');
-require_once('../functions/array.php');
-require_once('../functions/mailbox_display.php');
-require_once('../functions/mime.php');
+require_once(SM_PATH . 'functions/imap.php');
+require_once(SM_PATH . 'functions/date.php');
+require_once(SM_PATH . 'functions/mailbox_display.php');
+require_once(SM_PATH . 'functions/mime.php');
function sqimap_search($imapConnection, $search_where, $search_what, $mailbox,
$color, $search_position = '', $search_all, $count_all) {
- global $msgs, $message_highlight_list, $squirrelmail_language, $languages,
- $index_order, $pos, $allow_charset_search, $imap_server_type;
+ global $message_highlight_list, $squirrelmail_language, $languages,
+ $index_order, $pos, $allow_charset_search, $uid_support,
+ $imap_server_type;
+
$pos = $search_position;
$urlMailbox = urlencode($mailbox);
@@ -40,19 +41,25 @@ function sqimap_search($imapConnection, $search_where, $search_what, $mailbox,
returns the messages that match each term. Could be fixed
on the client side, but should be fixed on the server
as per the RFC */
-
+
if ($imap_server_type == 'macosx') {
foreach ($multi_search as $multi_search_part) {
- $search_string .= $search_where . ' ' .$multi_search_part. ' ';
+ if (strtoupper($languages[$squirrelmail_language]['CHARSET']) == 'ISO-2022-JP') {
+ $multi_search_part = mb_convert_encoding($multi_search_part, 'JIS', 'auto');
+ }
+ $search_string .= $search_where . ' ' .$multi_search_part . ' ';
}
}
else {
foreach ($multi_search as $multi_search_part) {
+ if (strtoupper($languages[$squirrelmail_language]['CHARSET']) == 'ISO-2022-JP') {
+ $multi_search_part = mb_convert_encoding($multi_search_part, 'JIS', 'auto');
+ }
$search_string .= $search_where . ' {' . strlen($multi_search_part)
. "}\r\n" . $multi_search_part . ' ';
}
}
-
+
$search_string = trim($search_string);
/* now use $search_string in the imap search */
@@ -66,7 +73,7 @@ function sqimap_search($imapConnection, $search_where, $search_what, $mailbox,
}
/* read data back from IMAP */
- $readin = sqimap_run_command($imapConnection, $ss, false, $result, $message);
+ $readin = sqimap_run_command($imapConnection, $ss, false, $result, $message, $uid_support);
/* try US-ASCII charset if search fails */
if (isset($languages[$squirrelmail_language]['CHARSET'])
@@ -77,13 +84,12 @@ function sqimap_search($imapConnection, $search_where, $search_what, $mailbox,
}
unset($messagelist);
- $msgs = '';
/* Keep going till we find the SEARCH response */
foreach ($readin as $readin_part) {
/* Check to see if a SEARCH response was received */
if (substr($readin_part, 0, 9) == '* SEARCH ') {
- $messagelist = explode(' ', substr($readin_part, 9));
+ $messagelist = preg_split("/ /", substr($readin_part, 9));
} else if (isset($errors)) {
$errors = $errors.$readin_part;
} else {
@@ -94,140 +100,25 @@ function sqimap_search($imapConnection, $search_where, $search_what, $mailbox,
/* If nothing is found * SEARCH should be the first error else echo errors */
if (isset($errors)) {
if (strstr($errors,'* SEARCH')) {
- if ($search_all != 'all') {
- echo '