$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 */
/* 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');
_("Reason Given: ") .
htmlspecialchars($message) . "</font><br>\n";
error_box($string,$color);
+ echo '</body></html>';
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" .
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;
- }
- 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;
}
}