| | |
| | | |
| | | // did we get the right number of replies? |
| | | $parts_count = count($a); |
| | | if ($parts_count>=8) { |
| | | if ($parts_count>=6) { |
| | | for ($i=0; $i<$parts_count; $i=$i+2) { |
| | | if (strcasecmp($a[$i],'UID') == 0) |
| | | $result[$id]->uid = $a[$i+1]; |
| | |
| | | $time_str = $a[$i+1]; |
| | | else if (strcasecmp($a[$i],'FLAGS') == 0) |
| | | $flags_str = $a[$i+1]; |
| | | } |
| | | |
| | | // process flags |
| | | $flags_str = eregi_replace('[\\\"]', '', $flags_str); |
| | | $flags_a = explode(' ', $flags_str); |
| | | |
| | | if (is_array($flags_a)) { |
| | | reset($flags_a); |
| | | while (list(,$val)=each($flags_a)) { |
| | | if (strcasecmp($val,'Seen') == 0) { |
| | | $result[$id]->seen = true; |
| | | } else if (strcasecmp($val, 'Deleted') == 0) { |
| | | $result[$id]->deleted=true; |
| | | } else if (strcasecmp($val, 'Recent') == 0) { |
| | | $result[$id]->recent = true; |
| | | } else if (strcasecmp($val, 'Answered') == 0) { |
| | | $result[$id]->answered = true; |
| | | } else if (strcasecmp($val, '$Forwarded') == 0) { |
| | | $result[$id]->forwarded = true; |
| | | } else if (strcasecmp($val, 'Draft') == 0) { |
| | | $result[$id]->is_draft = true; |
| | | } else if (strcasecmp($val, '$MDNSent') == 0) { |
| | | $result[$id]->mdn_sent = true; |
| | | } else if (strcasecmp($val, 'Flagged') == 0) { |
| | | $result[$id]->flagged = true; |
| | | } |
| | | } |
| | | $result[$id]->flags = $flags_a; |
| | | } |
| | | |
| | | $time_str = str_replace('"', '', $time_str); |
| | |
| | | do { |
| | | $line = chop(iil_ReadLine($fp, 300), "\r\n"); |
| | | |
| | | // The preg_match below works around communigate imap, which outputs " UID <number>)". |
| | | // Without this, the while statement continues on and gets the "FH0 OK completed" message. |
| | | // If this loop gets the ending message, then the outer loop does not receive it from radline on line 1249. |
| | | // This in causes the if statement on line 1278 to never be true, which causes the headers to end up missing |
| | | // If the if statement was changed to pick up the fh0 from this loop, then it causes the outer loop to spin |
| | | // An alternative might be: |
| | | // if (!preg_match("/:/",$line) && preg_match("/\)$/",$line)) break; |
| | | // however, unsure how well this would work with all imap clients. |
| | | if (preg_match("/^\s*UID [0-9]+\)$/", $line)) { |
| | | break; |
| | | } |
| | | |
| | | // handle FLAGS reply after headers (AOL, Zimbra?) |
| | | if (preg_match('/\s+FLAGS \((.*)\)\)$/', $line, $matches)) { |
| | | $flags_str = $matches[1]; |
| | | break; |
| | | } |
| | | |
| | | if (ord($line[0])<=32) { |
| | | $lines[$ln] .= (empty($lines[$ln])?'':"\n").trim($line); |
| | | } else { |
| | | $lines[++$ln] = trim($line); |
| | | } |
| | | /* |
| | | The preg_match below works around communigate imap, which outputs " UID <number>)". |
| | | Without this, the while statement continues on and gets the "FH0 OK completed" message. |
| | | If this loop gets the ending message, then the outer loop does not receive it from radline on line 1249. |
| | | This in causes the if statement on line 1278 to never be true, which causes the headers to end up missing |
| | | If the if statement was changed to pick up the fh0 from this loop, then it causes the outer loop to spin |
| | | An alternative might be: |
| | | if (!preg_match("/:/",$line) && preg_match("/\)$/",$line)) break; |
| | | however, unsure how well this would work with all imap clients. |
| | | */ |
| | | if (preg_match("/^\s*UID [0-9]+\)$/", $line)) { |
| | | break; |
| | | } |
| | | // patch from "Maksim Rubis" <siburny@hotmail.com> |
| | | } while (trim($line[0]) != ')' && strncmp($line, $key, strlen($key))); |
| | |
| | | } else { |
| | | $a = explode(' ', $line); |
| | | } |
| | | |
| | | // process flags |
| | | if (!empty($flags_str)) { |
| | | $flags_str = eregi_replace('[\\\"]', '', $flags_str); |
| | | $flags_a = explode(' ', $flags_str); |
| | | |
| | | if (is_array($flags_a)) { |
| | | reset($flags_a); |
| | | while (list(,$val)=each($flags_a)) { |
| | | if (strcasecmp($val,'Seen') == 0) { |
| | | $result[$id]->seen = true; |
| | | } else if (strcasecmp($val, 'Deleted') == 0) { |
| | | $result[$id]->deleted=true; |
| | | } else if (strcasecmp($val, 'Recent') == 0) { |
| | | $result[$id]->recent = true; |
| | | } else if (strcasecmp($val, 'Answered') == 0) { |
| | | $result[$id]->answered = true; |
| | | } else if (strcasecmp($val, '$Forwarded') == 0) { |
| | | $result[$id]->forwarded = true; |
| | | } else if (strcasecmp($val, 'Draft') == 0) { |
| | | $result[$id]->is_draft = true; |
| | | } else if (strcasecmp($val, '$MDNSent') == 0) { |
| | | $result[$id]->mdn_sent = true; |
| | | } else if (strcasecmp($val, 'Flagged') == 0) { |
| | | $result[$id]->flagged = true; |
| | | } |
| | | } |
| | | $result[$id]->flags = $flags_a; |
| | | } |
| | | } |
| | | } |
| | | } while (strcmp($a[0], $key) != 0); |
| | | |