| | |
| | | File altered by Aleksander Machniak <alec@alec.pl> |
| | | - RFC3501 [7.1] don't call CAPABILITY if was returned in server |
| | | optional resposne in iil_Connect() |
| | | - trim(chop()) replaced by trim() |
| | | |
| | | |
| | | ********************************************************/ |
| | |
| | | |
| | | function iil_ReadReply($fp) { |
| | | do { |
| | | $line = chop(trim(iil_ReadLine($fp, 1024))); |
| | | $line = trim(iil_ReadLine($fp, 1024)); |
| | | } while ($line[0] == '*'); |
| | | |
| | | return $line; |
| | |
| | | $line = iil_ReadLine($conn->fp, 1024); |
| | | |
| | | // RFC3501 [7.1] optional CAPABILITY response |
| | | if (preg_match('/\[CAPABILITY ([^]]+)\]/i', $line, $matches)) { |
| | | $conn->capability = explode(' ', $matches[1]); |
| | | } else { |
| | | // commented out, because it's not working always as should |
| | | // if (preg_match('/\[CAPABILITY ([^]]+)\]/i', $line, $matches)) { |
| | | // $conn->capability = explode(' ', $matches[1]); |
| | | // } else { |
| | | fputs($conn->fp, "cp01 CAPABILITY\r\n"); |
| | | do { |
| | | $line = trim(chop(iil_ReadLine($conn->fp, 100))); |
| | | $line = trim(iil_ReadLine($conn->fp, 100)); |
| | | |
| | | $conn->message .= "$line\n"; |
| | | |
| | |
| | | } |
| | | } |
| | | } while ($a[0] != 'cp01'); |
| | | } |
| | | // } |
| | | |
| | | if (strcasecmp($auth_method, "check") == 0) { |
| | | //check for supported auth methods |
| | |
| | | |
| | | //do CRAM-MD5 authentication |
| | | fputs($conn->fp, "a000 AUTHENTICATE CRAM-MD5\r\n"); |
| | | $line = trim(chop(iil_ReadLine($conn->fp, 1024))); |
| | | $line = trim(iil_ReadLine($conn->fp, 1024)); |
| | | |
| | | $conn->message .= "$line\n"; |
| | | |
| | |
| | | do { |
| | | $line = chop(iil_ReadLine($fp, 300), "\r\n"); |
| | | if (ord($line[0])<=32) { |
| | | $lines[$i] .= (empty($lines[$i])?'':"\n").trim(chop($line)); |
| | | $lines[$i] .= (empty($lines[$i])?'':"\n").trim($line); |
| | | } else { |
| | | $i++; |
| | | $lines[$i] = trim(chop($line)); |
| | | $lines[$i] = trim($line); |
| | | } |
| | | /* |
| | | The preg_match below works around communigate imap, which outputs " UID <number>)". |
| | |
| | | $query = 'srch1 SEARCH ' . chop($criteria) . "\r\n"; |
| | | fputs($fp, $query); |
| | | do { |
| | | $line=trim(chop(iil_ReadLine($fp, 10000))); |
| | | $line=trim(iil_ReadLine($fp, 10000)); |
| | | if (eregi("^\* SEARCH", $line)) { |
| | | $str = trim(substr($line, 8)); |
| | | $messages = explode(' ', $str); |
| | |
| | | } |
| | | |
| | | function iil_C_Move(&$conn, $messages, $from, $to) { |
| | | $fp = $conn->fp; |
| | | |
| | | if (!$from || !$to) { |
| | | return -1; |
| | | } |
| | | |
| | | $r = iil_C_Copy($conn, $messages, $from,$to); |
| | | if ($r==0) { |
| | | return iil_C_Delete($conn, $from, $messages); |
| | | } |
| | | $fp = $conn->fp; |
| | | |
| | | if (!$from || !$to) { |
| | | return -1; |
| | | } |
| | | $r = iil_C_Copy($conn, $messages, $from,$to); |
| | | if ($r==0) { |
| | | return iil_C_Delete($conn, $from, $messages); |
| | | } |
| | | return $r; |
| | | } |
| | | |
| | |
| | | $query = 'sub1 SUBSCRIBE "' . $folder. '"' . "\r\n"; |
| | | fputs($fp, $query); |
| | | |
| | | $line = trim(chop(iil_ReadLine($fp, 10000))); |
| | | $line = trim(iil_ReadLine($fp, 10000)); |
| | | return iil_ParseResult($line); |
| | | } |
| | | |
| | |
| | | $query = 'usub1 UNSUBSCRIBE "' . $folder . '"' . "\r\n"; |
| | | fputs($fp, $query); |
| | | |
| | | $line = trim(chop(iil_ReadLine($fp, 10000))); |
| | | $line = trim(iil_ReadLine($fp, 10000)); |
| | | return iil_ParseResult($line); |
| | | } |
| | | |
| | |
| | | if (($line[0] == '*') && ($a[2] == 'FETCH') |
| | | && ($line[strlen($line)-1] != ')')) { |
| | | $line=iil_ReadLine($fp, 300); |
| | | while (chop($line) != ')') { |
| | | while (trim($line) != ')') { |
| | | $result .= $line; |
| | | $line=iil_ReadLine($fp, 300); |
| | | } |