in case of BYE response display errormessage
authorstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 13 Jun 2003 15:30:28 +0000 (15:30 +0000)
committerstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 13 Jun 2003 15:30:28 +0000 (15:30 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@5038 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/imap_general.php

index 04799a6065f2eefc30ba4dfba7e66975ae2f8ce0..9cfd1c74fb2037ad38c36b84e2d14672bf4bd8bc 100755 (executable)
@@ -81,7 +81,6 @@ function sqimap_fgets($imap_stream) {
     $buffer = 4096;
     $results = '';
     $offset = 0;
     $buffer = 4096;
     $results = '';
     $offset = 0;
-    $i=0;
     while (strpos($results, "\r\n", $offset) === false) {
         if (!($read = fgets($imap_stream, $buffer))) {
            /* this happens in case of an error */
     while (strpos($results, "\r\n", $offset) === false) {
         if (!($read = fgets($imap_stream, $buffer))) {
            /* this happens in case of an error */
@@ -269,9 +268,14 @@ function sqimap_read_data_list ($imap_stream, $tag_uid, $handle_errors, &$respon
     /* Return result or handle errors */
     if ($handle_errors == false) {
         return( $resultlist );
     /* Return result or handle errors */
     if ($handle_errors == false) {
         return( $resultlist );
-    } 
-    elseif ($response == 'NO') {
-    /* ignore this error from M$ exchange, it is not fatal (aka bug) */
+    }
+    switch ($response)
+    {
+    case 'OK':
+        return $resultlist;
+       break;
+    case 'NO': 
+        /* ignore this error from M$ exchange, it is not fatal (aka bug) */
         if (strstr($message, 'command resulted in') === false) {
             set_up_language($squirrelmail_language);
             require_once(SM_PATH . 'functions/display_messages.php');
         if (strstr($message, 'command resulted in') === false) {
             set_up_language($squirrelmail_language);
             require_once(SM_PATH . 'functions/display_messages.php');
@@ -283,10 +287,11 @@ function sqimap_read_data_list ($imap_stream, $tag_uid, $handle_errors, &$respon
                 _("Reason Given: ") .
                 htmlspecialchars($message) . "</font><br>\n";
             error_box($string,$color);
                 _("Reason Given: ") .
                 htmlspecialchars($message) . "</font><br>\n";
             error_box($string,$color);
+           echo '</body></html>';
             exit;
         }
             exit;
         }
-    } 
-    elseif ($response == 'BAD') {
+       break;
+    case 'BAD': 
         set_up_language($squirrelmail_language);
         require_once(SM_PATH . 'functions/display_messages.php');
         $string = "<b><font color=$color[2]>\n" .
         set_up_language($squirrelmail_language);
         require_once(SM_PATH . 'functions/display_messages.php');
         $string = "<b><font color=$color[2]>\n" .
@@ -296,11 +301,37 @@ function sqimap_read_data_list ($imap_stream, $tag_uid, $handle_errors, &$respon
             htmlspecialchars($query) . '<br>' .
             _("Server responded: ") .
             htmlspecialchars($message) . "</font><br>\n";
             htmlspecialchars($query) . '<br>' .
             _("Server responded: ") .
             htmlspecialchars($message) . "</font><br>\n";
-        error_box($string,$color);    
+        error_box($string,$color);
+       echo '</body></html>';      
+        exit; 
+    case 'BYE': 
+        set_up_language($squirrelmail_language);
+        require_once(SM_PATH . 'functions/display_messages.php');
+        $string = "<b><font color=$color[2]>\n" .
+            _("ERROR : Imap server closed the connection.") .
+            "</b><br>\n" .
+            _("Query:") . ' '.
+            htmlspecialchars($query) . '<br>' .
+            _("Server responded: ") .
+            htmlspecialchars($message) . "</font><br>\n";
+        error_box($string,$color);
+       echo '</body></html>';      
         exit;
         exit;
-    } 
-    else {
-        return $resultlist;
+    default: 
+        set_up_language($squirrelmail_language);
+        require_once(SM_PATH . 'functions/display_messages.php');
+        $string = "<b><font color=$color[2]>\n" .
+            _("ERROR : Unknown imap response.") .
+            "</b><br>\n" .
+            _("Query:") . ' '.
+            htmlspecialchars($query) . '<br>' .
+            _("Server responded: ") .
+            htmlspecialchars($message) . "</font><br>\n";
+        error_box($string,$color);
+       /* the error is displayed but because we don't know the reponse we
+          return the result anyway */
+       return $resultlist;    
+        break;
     }
 }
 
     }
 }