Fixed a problem with sqimap_unseen_messages where some versions of UW
[squirrelmail.git] / functions / imap_general.php
index a92084cb55aeb22a80e01e87b1fb4af77fec2b4b..d8bad0152fe63ba8ca36a465a435ca4b1e7a12cd 100755 (executable)
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * imap.php
+ * imap_general.php
  *
  * Copyright (c) 1999-2002 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
@@ -19,7 +19,7 @@ require_once('../functions/display_messages.php');
  *
  * Sets an unique session id in order to avoid simultanous sessions crash.
  *
- * @return     string  a 4 chars unique string
+ * @return  string  a 4 chars unique string
  */
 
 global $sqimap_session_id;
@@ -429,7 +429,13 @@ function sqimap_find_displayable_name ($string) {
 function sqimap_unseen_messages ($imap_stream, $mailbox) {
     //fputs ($imap_stream, sqimap_session_id() . " SEARCH UNSEEN NOT DELETED\r\n");
     $read_ary = sqimap_run_command ($imap_stream, "STATUS \"$mailbox\" (UNSEEN)", true, $result, $message);
-    ereg("UNSEEN ([0-9]+)", $read_ary[0], $regs);
+    $i = 0;
+    while (isset($read_ary[$i])) {
+        if (ereg("UNSEEN ([0-9]+)", $read_ary[$i], $regs)) {
+            break;
+        }
+        $i++;
+    }
     return $regs[1];
 }