Source for file imap_search.php
Documentation is available at imap_search.php
* Copyright (c) 1999-2006 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
* @version $Id: imap_search.php,v 1.63.2.7 2006/02/03 22:27:47 jervfors Exp $
* @deprecated This search interface has been largely replaced by asearch
* Load up a bunch of SM functions */
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 $message_highlight_list, $squirrelmail_language, $languages,
/* construct the search query, taking multiple search terms into account */
$search_what =
trim($search_what);
$multi_search =
explode(' ', $search_what);
/* it seems macosx and hmailserver do not support the prefered search
syntax so we fall back to the older style. This IMAP
server has a problem with multiple search terms. Instead
of returning the messages that match all the terms it
returns the messages that match each term. Could be fixed
on the client side, but should be fixed on the server
if ($imap_server_type ==
'macosx' ||
$imap_server_type ==
'hmailserver') {
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 .
' ' .
$multi_search_part .
' ';
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 */
if ($allow_charset_search && isset
($languages[$squirrelmail_language]['CHARSET']) &&
$languages[$squirrelmail_language]['CHARSET']) {
.
strtoupper($languages[$squirrelmail_language]['CHARSET'])
$ss =
"SEARCH ALL $search_string";
/* read data back from IMAP */
$readin =
sqimap_run_command($imapConnection, $ss, false, $result, $message, $uid_support);
/* try US-ASCII charset if search fails */
if (isset
($languages[$squirrelmail_language]['CHARSET'])
$ss =
"SEARCH CHARSET \"US-ASCII\" ALL $search_string";
$result, $message, $uid_support);
/* 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 ') {
} else if (isset
($errors)) {
$errors =
$errors.
$readin_part;
/* If nothing is found * SEARCH should be the first error else echo errors */
if (strstr($errors,'* SEARCH')) {
$cnt =
count($messagelist);
for ($q =
0; $q <
$cnt; $q++
) {
$id[$q] =
trim($messagelist[$q]);
$issent =
($mailbox ==
$sent_folder);
Documentation generated on Sat, 07 Oct 2006 16:31:49 +0300 by phpDocumentor 1.3.0RC6