- $total_size += strlen($read);
- } else {
- if (preg_match("/^$pre (OK|BAD|NO)(.*)/", $read, $regs) ||
- // if (ereg("^$pre (OK|BAD|NO)(.*)", $read, $regs) ||
- (($size == -1) && ereg("^\\* [0-9]+ FETCH.*", $read, $regs))) {
- break;
- } else if ( preg_match("/^\* OK \[PARSE.*/", $read, $regs ) ) {
- /*
- This block has been added in order to avoid the problem
- caused by the * OK [PARSE] Missing parameter answer
- Please, replace it with a better parsing if you know how.
- */
- $read = fgets ($imap_stream, $bufsize);
- $data[] = $read;
- $read = fgets ($imap_stream, $bufsize);
- } else if (preg_match("/^\* BYE \[ALERT\](.*)/", $read, $regs)) {
- /*
- It seems that the IMAP server has coughed a lung up
- and hung up the connection. Print any info we have
- and abort.
- */
- echo _("Please contact your system administrator and report the following error:") . "<br>\n";
- echo "$regs[1]";
- exit(0);
- } else {
- $data[] = $read;
- $read = fgets ($imap_stream, $bufsize);
- }
- }
- }
-
- // while (($more_msgs = !ereg("^$pre (OK|BAD|NO)(.*)$", $read, $regs)) &&
- // !ereg("^\\* [0-9]+ FETCH.*", $read, $regs)) {
- while (($more_msgs = !preg_match("/^$pre (OK|BAD|NO)(.*)$/", $read, $regs)) &&
- !preg_match('/^\* [0-9]+ FETCH.*/', $read, $regs)) {
- $read = fgets($imap_stream, $bufsize);