| | |
| | | $line = ''; |
| | | |
| | | if (!$fp) { |
| | | return $line; |
| | | return NULL; |
| | | } |
| | | |
| | | if (!$size) { |
| | |
| | | } |
| | | |
| | | do { |
| | | if (feof($fp)) { |
| | | return $line ? $line : NULL; |
| | | } |
| | | |
| | | $buffer = fgets($fp, $size); |
| | | |
| | | if ($buffer === false) { |
| | |
| | | $bytes = $a[2][0]; |
| | | while (strlen($out) < $bytes) { |
| | | $line = iil_ReadBytes($fp, $bytes); |
| | | if ($line === NULL) |
| | | break; |
| | | $out .= $line; |
| | | } |
| | | |
| | |
| | | global $my_prefs; |
| | | $data = ''; |
| | | $len = 0; |
| | | do { |
| | | while ($len < $bytes && !feof($fp)) |
| | | { |
| | | $d = fread($fp, $bytes-$len); |
| | | if (!empty($my_prefs['debug_mode'])) |
| | | write_log('imap', 'S: '. $d); |
| | |
| | | break; //nothing was read -> exit to avoid apache lockups |
| | | } |
| | | $len = $data_len; |
| | | } while ($len < $bytes); |
| | | }; |
| | | |
| | | return $data; |
| | | } |
| | |
| | | } |
| | | if ($error && preg_match('/^\* (BYE|BAD) /i', $string)) { |
| | | return true; |
| | | |
| | | } |
| | | return false; |
| | | } |
| | |
| | | // set some imap options |
| | | if (is_array($options)) { |
| | | foreach($options as $optkey => $optval) { |
| | | if ($optkey == 'imap') { |
| | | if ($optkey == 'auth_method') { |
| | | $auth_method = strtoupper($optval); |
| | | } else if ($optkey == 'rootdir') { |
| | | $my_prefs['rootdir'] = $optval; |
| | |
| | | |
| | | function iil_Close(&$conn) { |
| | | if (iil_PutLine($conn->fp, "I LOGOUT")) { |
| | | fgets($conn->fp, 1024); |
| | | if (!feof($conn->fp)) |
| | | fgets($conn->fp, 1024); |
| | | fclose($conn->fp); |
| | | $conn->fp = false; |
| | | } |
| | |
| | | $lines[++$ln] = trim($line); |
| | | } |
| | | // patch from "Maksim Rubis" <siburny@hotmail.com> |
| | | } while (trim($line[0]) != ')' && strncmp($line, $key, strlen($key))); |
| | | } while ($line[0] != ')' && !iil_StartsWith($line, $key, true)); |
| | | |
| | | if (strncmp($line, $key, strlen($key))) { |
| | | // process header, fill iilBasicHeader obj. |
| | |
| | | $result[$id]->encoding = $string; |
| | | break; |
| | | case 'content-type': |
| | | $ctype_parts = explode(";", $string); |
| | | $ctype_parts = preg_split('/[; ]/', $string); |
| | | $result[$id]->ctype = array_shift($ctype_parts); |
| | | foreach ($ctype_parts as $ctype_add) { |
| | | if (preg_match('/charset="?([a-z0-9\-\.\_]+)"?/i', |
| | | $ctype_add, $regs)) { |
| | | $result[$id]->charset = $regs[1]; |
| | | } |
| | | if (preg_match('/charset\s*=\s*"?([a-z0-9\-\.\_]+)"?/i', $string, $regs)) { |
| | | $result[$id]->charset = $regs[1]; |
| | | } |
| | | break; |
| | | case 'in-reply-to': |
| | |
| | | return (iil_ParseResult($line) == 0); |
| | | } |
| | | |
| | | function iil_C_FetchMIMEHeaders(&$conn, $mailbox, $id, $parts) { |
| | | function iil_C_FetchMIMEHeaders(&$conn, $mailbox, $id, $parts, $mime=true) { |
| | | |
| | | $fp = $conn->fp; |
| | | |
| | |
| | | $key = 'fmh0'; |
| | | $peeks = ''; |
| | | $idx = 0; |
| | | $type = $mime ? 'MIME' : 'HEADER'; |
| | | |
| | | // format request |
| | | foreach($parts as $part) |
| | | $peeks[] = "BODY.PEEK[$part.MIME]"; |
| | | $peeks[] = "BODY.PEEK[$part.$type]"; |
| | | |
| | | $request = "$key FETCH $id (" . implode(' ', $peeks) . ')'; |
| | | |
| | |
| | | $line = iil_ReadLine($fp, 1000); |
| | | $line = iil_MultLine($fp, $line); |
| | | |
| | | if (preg_match('/BODY\[([0-9\.]+)\.MIME\]/', $line, $matches)) { |
| | | if (preg_match('/BODY\[([0-9\.]+)\.'.$type.'\]/', $line, $matches)) { |
| | | $idx = $matches[1]; |
| | | $result[$idx] = preg_replace('/^(\* '.$id.' FETCH \()?\s*BODY\['.$idx.'\.MIME\]\s+/', '', $line); |
| | | $result[$idx] = preg_replace('/^(\* '.$id.' FETCH \()?\s*BODY\['.$idx.'\.'.$type.'\]\s+/', '', $line); |
| | | $result[$idx] = trim($result[$idx], '"'); |
| | | $result[$idx] = rtrim($result[$idx], "\t\r\n\0\x0B"); |
| | | } |
| | |
| | | } |
| | | else |
| | | $prev = ''; |
| | | |
| | | |
| | | if ($file) |
| | | fwrite($file, base64_decode($line)); |
| | | else if ($print) |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // read in anything up until last line |
| | | if (!$end) |
| | | do { |
| | |
| | | } while (!iil_StartsWith($line, $key, true)); |
| | | |
| | | if ($result) { |
| | | $result = rtrim($result, "\t\r\n\0\x0B"); |
| | | if ($file) { |
| | | fwrite($file, $result); |
| | | } else if ($print) { |
| | | echo $result; |
| | | } else |
| | | return $result; // substr($result, 0, strlen($result)-1); |
| | | return $result; |
| | | |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | |
| | | return false; |
| | | } |
| | | |