From 3d2504a1792b621707aa71e80aa5aa9d93ad8282 Mon Sep 17 00:00:00 2001 From: fidian Date: Sun, 22 Oct 2000 23:04:06 +0000 Subject: [PATCH] sqimap_read_data now uses the $response and $message vars sqimap_login now uses sqimap_read_data, and is shortened a bit sqimap_mailbox_select now forms proper request to sqimap_read_data Potential fix for the UW version 8 IMAP server git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@816 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/imap_general.php | 40 ++++++++++++++++++++++++-------------- functions/imap_mailbox.php | 2 +- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/functions/imap_general.php b/functions/imap_general.php index e8ee3deb..c4d1d9c1 100755 --- a/functions/imap_general.php +++ b/functions/imap_general.php @@ -10,7 +10,7 @@ ** this will also handle all errors that are received. If it is not set, ** the errors will be sent back through $response and $message ******************************************************************************/ - function sqimap_read_data ($imap_stream, $pre, $handle_errors, $response, $message) { + function sqimap_read_data ($imap_stream, $pre, $handle_errors, &$response, &$message) { global $color, $squirrelmail_language; //$imap_general_debug = true; @@ -24,25 +24,29 @@ $read = fgets ($imap_stream, 1024); if ($imap_general_debug) echo "$read
"; $counter++; - } + } + + $response = $regs[1]; + $message = trim($regs[2]); + if ($imap_general_debug) echo "--
"; if ($handle_errors == true) { - if ($regs[1] == "NO") { + if ($response == "NO") { set_up_language($squirrelmail_language); echo "
\n"; echo _("ERROR : Could not complete request."); echo "
\n"; echo _("Reason Given: "); - echo trim($regs[2]) . "

\n"; + echo $message . "
\n"; exit; - } else if ($regs[1] == "BAD") { + } else if ($response == "BAD") { set_up_language($squirrelmail_language); echo "
\n"; echo _("ERROR : Bad or malformed request."); echo "
\n"; echo _("Server responded: "); - echo trim($regs[2]) . "

\n"; + echo $message . "
\n"; exit; } } @@ -77,16 +81,26 @@ } fputs ($imap_stream, "a001 LOGIN \"$username\" \"$password\"\r\n"); - $read = fgets ($imap_stream, 1024); + $read = sqimap_read_data ($imap_stream, "a001", false, $response, $message); /** If the connection was not successful, lets see why **/ - if (substr($read, 0, 7) != "a001 OK") { + if ($response != "OK") { if (!$hide) { - if (substr($read, 0, 8) == "a001 BAD") { + if ($response != "NO") { + // "BAD" and anything else gets reported here. set_up_language($squirrelmail_language, true); - printf (_("Bad request: %s")."
\r\n", $read); + if ($response == "BAD") + printf (_("Bad request: %s")."
\r\n", $message); + else + printf (_("Unknown error: %s") . "
\n", $message); + echo "
"; + echo _("Read data:") . "
\n"; + foreach ($read as $line) + { + echo htmlspecialchars($line) . "
\n"; + } exit; - } else if (substr($read, 0, 7) == "a001 NO") { + } else if ($response == "NO") { // If the user does not log in with the correct // username and password it is not possible to get the // correct locale from the user's preferences. @@ -128,10 +142,6 @@ ", $read); - exit; } } else { exit; diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index e7e4aad4..a8b8ed1a 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -57,7 +57,7 @@ } if ($auto_expunge) { fputs ($imap_stream, "a001 EXPUNGE\r\n"); - $tmp = sqimap_read_data($imap_stream, "a001", $a, $b, true); + $tmp = sqimap_read_data($imap_stream, "a001", true, $a, $b); } } -- 2.25.1