Fixed a bug where users that did not log in before would get tons of
[squirrelmail.git] / functions / imap_mailbox.php
index ed043c7b67453d108055cc94a2c651b2f7bc8d80..8e2600f059f6e70d70a553fc68377e1cc43a8291 100755 (executable)
@@ -12,7 +12,6 @@
       sqimap_mailbox_select ($imap_stream, $mailbox);
       fputs ($imap_stream, "a001 EXPUNGE\r\n");
       $read = sqimap_read_data($imap_stream, "a001", $handle_errors, $response, $message);
-      sqimap_mailbox_close ($imap_stream);
    }
 
 
       }
    }
 
-   /******************************************************************************
-    **  Closes an open mailbox 
-    ******************************************************************************/
-   function sqimap_mailbox_close ($imap_stream) {
-      fputs ($imap_stream, "a001 CLOSE\r\n");
-      $tmp = sqimap_read_data($imap_stream, "a001", false, $response, $message);
-   }
-
    /******************************************************************************
     **  Selects a mailbox
     ******************************************************************************/
       fputs ($imap_stream, "a001 LSUB \"\" \"*\"\r\n");
       $lsub_ary = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
 
+         /** OS: we don't want to parse last element of array, 'cause it is OK command, so we unset it **/
+         unset($lsub_ary[count($lsub_ary)-1]);
+
       for ($i=0;$i < count($lsub_ary); $i++) {
          $sorted_lsub_ary[$i] = find_mailbox_name($lsub_ary[$i]);
          if ($sorted_lsub_ary[$i] == "INBOX")
 
          // Then list special folders and their subfolders
          for ($i = 0 ; $i <= count($boxes) ; $i++) {
-            if((eregi("^".$trash_folder.'$', $boxes[$i]["unformatted"]) ||
-                eregi("^".$trash_folder.quotemeta($dm), $boxes[$i]["unformatted"]) )  &&
+            if((eregi("^".quotemeta($trash_folder).'$', $boxes[$i]["unformatted"]) ||
+                eregi("^".quotemeta($trash_folder).quotemeta($dm), $boxes[$i]["unformatted"]) )  &&
                ($move_to_trash)) {        
                $boxesnew[] = $boxes[$i];
                $boxes[$i]["used"] = true;
             }
-            else if((eregi("^".$sent_folder.'$', $boxes[$i]["unformatted"]) ||
-                     eregi("^".$sent_folder.quotemeta($dm), $boxes[$i]["unformatted"]) )  &&
+            else if((eregi("^".quotemeta($sent_folder).'$', $boxes[$i]["unformatted"]) ||
+                     eregi("^".quotemeta($sent_folder).quotemeta($dm), $boxes[$i]["unformatted"]) )  &&
                     ($move_to_sent)) {        
                $boxesnew[] = $boxes[$i];
                $boxes[$i]["used"] = true;