From c5eb2c035ef288266b9e7568686ce9e365cecfb4 Mon Sep 17 00:00:00 2001 From: lkehresman Date: Fri, 28 Apr 2000 03:43:43 +0000 Subject: [PATCH] speed optomizations and less imap commands git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@469 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/imap_general.php | 17 +++++------------ functions/imap_mailbox.php | 14 ++++++++++---- functions/imap_messages.php | 19 ++++++++++++++----- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/functions/imap_general.php b/functions/imap_general.php index 7f044002..07fca891 100755 --- a/functions/imap_general.php +++ b/functions/imap_general.php @@ -217,21 +217,14 @@ /****************************************************************************** ** Returns the number of unseen messages in this folder ******************************************************************************/ - function sqimap_unseen_messages ($imap_stream, &$num_unseen) { - fputs ($imap_stream, "a001 SEARCH UNSEEN NOT DELETED\r\n"); + function sqimap_unseen_messages ($imap_stream, &$num_unseen, $mailbox) { + //fputs ($imap_stream, "a001 SEARCH UNSEEN NOT DELETED\r\n"); + fputs ($imap_stream, "a001 STATUS \"$mailbox\" (UNSEEN)\r\n"); $read_ary = sqimap_read_data ($imap_stream, "a001", true, $result, $message); $unseen = false; - if (strlen($read_ary[0]) > 10) { - $unseen = true; - $ary = explode (" ", $read_ary[0]); - $num_unseen = count($ary) - 2; - } else { - $unseen = false; - $num_unseen = 0; - } - - return $unseen; + $read_ary[0] = trim($read_ary[0]); + return substr($read_ary[0], strrpos($read_ary[0], " ")+1, (strlen($read_ary[0]) - strrpos($read_ary[0], " ") - 2)); } diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index 018f2737..436f4d41 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -33,9 +33,9 @@ /****************************************************************************** ** Selects a mailbox ******************************************************************************/ - function sqimap_mailbox_select ($imap_stream, $mailbox) { + function sqimap_mailbox_select ($imap_stream, $mailbox, $hide) { fputs ($imap_stream, "a001 SELECT \"$mailbox\"\r\n"); - $read = sqimap_read_data($imap_stream, "a001", true, $response, $message); + $read = sqimap_read_data($imap_stream, "a001", true, $response, $message); } @@ -229,24 +229,30 @@ if (strtolower($boxes[$i]["unformatted"]) == "inbox") { $boxesnew[0] = $boxes[$i]; $boxes[$i]["used"] = true; + $i = count($boxes); } } if ($list_special_folders_first == true) { - for ($i = 0; $i < count($boxes); $i++) { + for ($i = count($boxes)-1; $i >= 0 ; $i--) { if (($boxes[$i]["unformatted"] == $trash_folder) && ($move_to_trash)) { $pos = count($boxesnew); $boxesnew[$pos] = $boxes[$i]; $boxes[$i]["used"] = true; + $trash_found = true; } else if (($boxes[$i]["unformatted"] == $sent_folder) && ($move_to_sent)) { $pos = count($boxesnew); $boxesnew[$pos] = $boxes[$i]; $boxes[$i]["used"] = true; + $sent_found = true; } + + if (($sent_found && $trash_found) || ($sent_found && !$move_to_trash) || ($trash_found && !$move_to_sent) || (!$move_to_sent && !$move_to_trash)) + $i = -1; } } - + for ($i = 0; $i < count($boxes); $i++) { if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && ($boxes[$i]["used"] == false)) { diff --git a/functions/imap_messages.php b/functions/imap_messages.php index f5ad32be..95985009 100755 --- a/functions/imap_messages.php +++ b/functions/imap_messages.php @@ -38,18 +38,27 @@ /****************************************************************************** ** Returns some general header information -- FROM, DATE, and SUBJECT ******************************************************************************/ - function sqimap_get_small_header ($imap_stream, $id, &$from, &$subject, &$date) { + function sqimap_get_small_header ($imap_stream, $id, &$from, &$subject, &$date, $sent) { //fputs ($imap_stream, "a001 FETCH $id BODY[HEADER.FIELDS (DATE FROM SUBJECT)]\r\n"); //fputs ($imap_stream, "a001 FETCH $id RFC822.HEADER\r\n"); - fputs ($imap_stream, "a001 FETCH $id BODY.PEEK[HEADER.FIELDS (Date From Subject)]\r\n"); + fputs ($imap_stream, "a001 FETCH $id BODY.PEEK[HEADER.FIELDS (Date To From Subject)]\r\n"); $read = sqimap_read_data ($imap_stream, "a001", true, $response, $message); $subject = _("(no subject)"); $from = _("Unknown Sender"); for ($i = 0; $i < count($read); $i++) { - if (eregi ("^from:", $read[$i])) { - $from = sqimap_find_displayable_name(substr($read[$i], 5)); - } else if (eregi ("^date:", $read[$i])) { + + if ($sent == true) { + if (eregi ("^to:", $read[$i])) { + $from = sqimap_find_displayable_name(substr($read[$i], 3)); + } + } else { + if (eregi ("^from:", $read[$i])) { + $from = sqimap_find_displayable_name(substr($read[$i], 5)); + } + } + + if (eregi ("^date:", $read[$i])) { $date = substr($read[$i], 5); } else if (eregi ("^subject:", $read[$i])) { $subject = htmlspecialchars(eregi_replace ("^subject: ", "", $read[$i])); -- 2.25.1