Browse Source

speed improvements mailbox_list. Need testing before we release!

stekkel 23 years ago
parent
commit
fb711df79e
1 changed files with 11 additions and 7 deletions
  1. 11 7
      functions/imap_mailbox.php

+ 11 - 7
functions/imap_mailbox.php

@@ -76,6 +76,8 @@ function sortSpecialMbx($a, $b) {
 }     	
 }     	
 
 
 function find_mailbox_name ($mailbox) {
 function find_mailbox_name ($mailbox) {
+    if (preg_match('/\*.+\"([^\r\n\"]*)\"[\s\r\n]*$/', $mailbox, $regs)) 
+        return $regs[1];
     if (ereg(" *\"([^\r\n\"]*)\"[ \r\n]*$", $mailbox, $regs))
     if (ereg(" *\"([^\r\n\"]*)\"[ \r\n]*$", $mailbox, $regs))
         return $regs[1];
         return $regs[1];
     ereg(" *([^ \r\n\"]*)[ \r\n]*$",$mailbox,$regs);
     ereg(" *([^ \r\n\"]*)[ \r\n]*$",$mailbox,$regs);
@@ -402,6 +404,8 @@ function sqimap_mailbox_parse ($line, $line_lsub) {
 function user_strcasecmp($a, $b) {
 function user_strcasecmp($a, $b) {
     global $delimiter;
     global $delimiter;
 
 
+    return  strnatcasecmp($a, $b);
+
     /* Calculate the length of some strings. */
     /* Calculate the length of some strings. */
     $a_length = strlen($a);
     $a_length = strlen($a);
     $b_length = strlen($b);
     $b_length = strlen($b);
@@ -409,8 +413,7 @@ function user_strcasecmp($a, $b) {
     $delimiter_length = strlen($delimiter);
     $delimiter_length = strlen($delimiter);
 
 
     /* Set the initial result value. */
     /* Set the initial result value. */
-    $result = 0;
-
+    $result = 0;    
     /* Check the strings... */
     /* Check the strings... */
     for ($c = 0; $c < $min_length; ++$c) {
     for ($c = 0; $c < $min_length; ++$c) {
         $a_del = substr($a, $c, $delimiter_length);
         $a_del = substr($a, $c, $delimiter_length);
@@ -508,10 +511,11 @@ function sqimap_mailbox_list($imap_stream) {
         if (isset($sorted_lsub_ary)) {
         if (isset($sorted_lsub_ary)) {
             usort($sorted_lsub_ary, 'user_strcasecmp');
             usort($sorted_lsub_ary, 'user_strcasecmp');
         }
         }
-
+	$sorted_list_ary = $sorted_lsub_ary;
         /* LIST array */
         /* LIST array */
-        $sorted_list_ary = array();
-        for ($i=0; $i < count($sorted_lsub_ary); $i++) {
+//        $sorted_list_ary = array();
+//        for ($i=0; $i < count($sorted_lsub_ary); $i++) {
+        if (false) {
             if (substr($sorted_lsub_ary[$i], -1) == $delimiter) {
             if (substr($sorted_lsub_ary[$i], -1) == $delimiter) {
                 $mbx = substr($sorted_lsub_ary[$i], 0, strlen($sorted_lsub_ary[$i])-1);
                 $mbx = substr($sorted_lsub_ary[$i], 0, strlen($sorted_lsub_ary[$i])-1);
             }
             }
@@ -544,12 +548,12 @@ function sqimap_mailbox_list($imap_stream) {
                 $inbox_in_list = true;
                 $inbox_in_list = true;
             }
             }
         }
         }
-
+//        $inbox_in_list = true;
         /*
         /*
          * Just in case they're not subscribed to their inbox,
          * Just in case they're not subscribed to their inbox,
          * we'll get it for them anyway
          * we'll get it for them anyway
          */
          */
-        if (!$inbox_subscribed || !$inbox_in_list) {
+        if (!$inbox_subscribed) {// || !$inbox_in_list) {
             $inbox_ary = sqimap_run_command ($imap_stream, "LIST \"\" \"INBOX\"",
             $inbox_ary = sqimap_run_command ($imap_stream, "LIST \"\" \"INBOX\"",
                                              true, $response, $message);
                                              true, $response, $message);
             /* Another workaround for EIMS */
             /* Another workaround for EIMS */