840a4bf0f82671f0d81f5ce454bd5142dde39000
1 /******************************************************************************
2 ** Reads the output from the IMAP stream. If handle_errors is set to true,
3 ** this will also handle all errors that are received. If it is not set,
4 ** the errors will be sent back through $response and $message
5 ******************************************************************************/
6 function sqimap_read_data ($imap_stream, $pre, $handle_errors, &$response, &$message) {
7 global $color, $squirrelmail_language, $imap_general_debug;
13 $read = fgets($imap_stream, 9096);
14 if (ereg("^$pre (OK|BAD|NO)(.*)$", $read, $regs)) {
15 break; // found end of reply
18 // Continue if needed for this single line
19 while (strpos($read, "\n") === false) {
20 $read .= fgets($imap_stream, 9096);
25 if (ereg("^\\* [0-9]+ FETCH.*\\{([0-9]+)\\}", $read, $regs)) {
27 if ($imap_general_debug) {
28 echo "<small><tt><font color=\"#CC0000\">Size is $size</font></tt></small><br>\n";
33 $read = fgets($imap_stream, 9096);
34 if ($imap_general_debug) {
35 echo "<small><tt><font color=\"#CC0000\">$read</font></tt></small><br>\n";
39 $total_size +
= strlen($read);
40 } while ($total_size < $size);
44 // For debugging purposes
45 if ($imap_general_debug) {
46 echo "<small><tt><font color=\"#CC0000\">$read</font></tt></small><br>\n";
52 $message = trim($regs[2]);
54 if ($imap_general_debug) echo '--<br>';
56 if ($handle_errors == false)
59 if ($response == 'NO') {
60 // ignore this error from m$ exchange, it is not fatal (aka bug)
61 if (strstr($message, 'command resulted in') === false) {
62 set_up_language($squirrelmail_language);
63 echo "<br><b><font color=$color[2]>\n";
64 echo _("ERROR : Could not complete request.");
66 echo _("Reason Given: ");
67 echo $message . "</font><br>\n";
70 } else if ($response == 'BAD') {
71 set_up_language($squirrelmail_language);
72 echo "<br><b><font color=$color[2]>\n";
73 echo _("ERROR : Bad or malformed request.");
75 echo _("Server responded: ");
76 echo $message . "</font><br>\n";