| | |
| | | private $prefs; |
| | | private $cmd_tag; |
| | | private $cmd_num = 0; |
| | | private $resourceid; |
| | | private $_debug = false; |
| | | private $_debug_handler = false; |
| | | |
| | |
| | | |
| | | $line = trim(fgets($this->fp, 8192)); |
| | | |
| | | if ($this->_debug && $line) { |
| | | $this->debug('S: '. $line); |
| | | if ($this->_debug) { |
| | | // set connection identifier for debug output |
| | | preg_match('/#([0-9]+)/', (string)$this->fp, $m); |
| | | $this->resourceid = strtoupper(substr(md5($m[1].$this->user.microtime()), 0, 4)); |
| | | |
| | | if ($line) |
| | | $this->debug('S: '. $line); |
| | | } |
| | | |
| | | // Connected to wrong port or connection error? |
| | |
| | | * @param string $mailbox Mailbox name |
| | | * |
| | | * @return boolean True on success, false on error |
| | | * @access public |
| | | */ |
| | | function select($mailbox) |
| | | { |
| | |
| | | * in RFC3501: UIDNEXT, UIDVALIDITY, RECENT |
| | | * |
| | | * @return array Status item-value hash |
| | | * @access public |
| | | * @since 0.5-beta |
| | | */ |
| | | function status($mailbox, $items=array()) |
| | |
| | | * @param string $messages Message UIDs to expunge |
| | | * |
| | | * @return boolean True on success, False on error |
| | | * @access public |
| | | */ |
| | | function expunge($mailbox, $messages=NULL) |
| | | { |
| | |
| | | * Executes CLOSE command |
| | | * |
| | | * @return boolean True on success, False on error |
| | | * @access public |
| | | * @since 0.5 |
| | | */ |
| | | function close() |
| | |
| | | * @param string $mailbox Mailbox name |
| | | * |
| | | * @return boolean True on success, False on error |
| | | * @access public |
| | | */ |
| | | function subscribe($mailbox) |
| | | { |
| | |
| | | * @param string $mailbox Mailbox name |
| | | * |
| | | * @return boolean True on success, False on error |
| | | * @access public |
| | | */ |
| | | function unsubscribe($mailbox) |
| | | { |
| | |
| | | * @param string $mailbox Mailbox name |
| | | * |
| | | * @return boolean True on success, False on error |
| | | * @access public |
| | | */ |
| | | function deleteFolder($mailbox) |
| | | { |
| | |
| | | * @param string $mailbox Mailbox name |
| | | * |
| | | * @return boolean True on success, False on error |
| | | * @access public |
| | | */ |
| | | function clearFolder($mailbox) |
| | | { |
| | |
| | | * @param string $mailbox Mailbox name |
| | | * |
| | | * @return int Number of messages, False on error |
| | | * @access public |
| | | */ |
| | | function countMessages($mailbox, $refresh = false) |
| | | { |
| | |
| | | * @param string $mailbox Mailbox name |
| | | * |
| | | * @return int Number of messages, False on error |
| | | * @access public |
| | | */ |
| | | function countRecent($mailbox) |
| | | { |
| | |
| | | * @param string $mailbox Mailbox name |
| | | * |
| | | * @return int Number of messages, False on error |
| | | * @access public |
| | | */ |
| | | function countUnseen($mailbox) |
| | | { |
| | |
| | | * @param array $items Client identification information key/value hash |
| | | * |
| | | * @return array Server identification information key/value hash |
| | | * @access public |
| | | * @since 0.6 |
| | | */ |
| | | function id($items=array()) |
| | |
| | | for ($i=0, $len=count($items); $i<$len; $i += 2) { |
| | | $result[$items[$i]] = $items[$i+1]; |
| | | } |
| | | |
| | | return $result; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Executes ENABLE command (RFC5161) |
| | | * |
| | | * @param mixed $extension Extension name to enable (or array of names) |
| | | * |
| | | * @return array|bool List of enabled extensions, False on error |
| | | * @since 0.6 |
| | | */ |
| | | function enable($extension) |
| | | { |
| | | if (empty($extension)) |
| | | return false; |
| | | |
| | | if (!$this->hasCapability('ENABLE')) |
| | | return false; |
| | | |
| | | if (!is_array($extension)) |
| | | $extension = array($extension); |
| | | |
| | | list($code, $response) = $this->execute('ENABLE', $extension); |
| | | |
| | | if ($code == self::ERROR_OK && preg_match('/\* ENABLED /i', $response)) { |
| | | $response = substr($response, 10); // remove prefix "* ENABLED " |
| | | $result = (array) $this->tokenizeResponse($response); |
| | | |
| | | return $result; |
| | | } |
| | |
| | | * @param int $uid Message unique identifier (UID) |
| | | * |
| | | * @return int Message sequence identifier |
| | | * @access public |
| | | */ |
| | | function UID2ID($mailbox, $uid) |
| | | { |
| | |
| | | * @param int $uid Message sequence identifier |
| | | * |
| | | * @return int Message unique identifier |
| | | * @access public |
| | | */ |
| | | function ID2UID($mailbox, $id) |
| | | { |
| | |
| | | if ($bodystr) |
| | | $request .= "BODYSTRUCTURE "; |
| | | $request .= "BODY.PEEK[HEADER.FIELDS (DATE FROM TO SUBJECT CONTENT-TYPE "; |
| | | $request .= "CC REPLY-TO LIST-POST DISPOSITION-NOTIFICATION-TO".$add.")])"; |
| | | $request .= "CC REPLY-TO LIST-POST DISPOSITION-NOTIFICATION-TO X-PRIORITY".$add.")])"; |
| | | |
| | | if (!$this->putLine($request)) { |
| | | $this->setError(self::ERROR_COMMAND, "Unable to send command: $request"); |
| | |
| | | * |
| | | * @return array List of mailboxes or hash of options if $status_opts argument |
| | | * is non-empty. |
| | | * @access public |
| | | */ |
| | | function listMailboxes($ref, $mailbox, $status_opts=array(), $select_opts=array()) |
| | | { |
| | |
| | | * |
| | | * @return array List of mailboxes or hash of options if $status_opts argument |
| | | * is non-empty. |
| | | * @access public |
| | | */ |
| | | function listSubscribed($ref, $mailbox, $status_opts=array()) |
| | | { |
| | |
| | | * |
| | | * @return array List of mailboxes or hash of options if $status_ops argument |
| | | * is non-empty. |
| | | * @access private |
| | | */ |
| | | private function _listMailboxes($ref, $mailbox, $subscribed=false, |
| | | $status_opts=array(), $select_opts=array()) |
| | |
| | | * |
| | | * @return boolean True on success, False on failure |
| | | * |
| | | * @access public |
| | | * @since 0.5-beta |
| | | */ |
| | | function setACL($mailbox, $user, $acl) |
| | |
| | | * |
| | | * @return boolean True on success, False on failure |
| | | * |
| | | * @access public |
| | | * @since 0.5-beta |
| | | */ |
| | | function deleteACL($mailbox, $user) |
| | |
| | | * @param string $mailbox Mailbox name |
| | | * |
| | | * @return array User-rights array on success, NULL on error |
| | | * @access public |
| | | * @since 0.5-beta |
| | | */ |
| | | function getACL($mailbox) |
| | |
| | | * @param string $user User name |
| | | * |
| | | * @return array List of user rights |
| | | * @access public |
| | | * @since 0.5-beta |
| | | */ |
| | | function listRights($mailbox, $user) |
| | |
| | | * @param string $mailbox Mailbox name |
| | | * |
| | | * @return array MYRIGHTS response on success, NULL on error |
| | | * @access public |
| | | * @since 0.5-beta |
| | | */ |
| | | function myRights($mailbox) |
| | |
| | | * @param array $entries Entry-value array (use NULL value as NIL) |
| | | * |
| | | * @return boolean True on success, False on failure |
| | | * @access public |
| | | * @since 0.5-beta |
| | | */ |
| | | function setMetadata($mailbox, $entries) |
| | |
| | | * |
| | | * @return boolean True on success, False on failure |
| | | * |
| | | * @access public |
| | | * @since 0.5-beta |
| | | */ |
| | | function deleteMetadata($mailbox, $entries) |
| | |
| | | * |
| | | * @return array GETMETADATA result on success, NULL on error |
| | | * |
| | | * @access public |
| | | * @since 0.5-beta |
| | | */ |
| | | function getMetadata($mailbox, $entries, $options=array()) |
| | |
| | | * three elements: entry name, attribute name, value |
| | | * |
| | | * @return boolean True on success, False on failure |
| | | * @access public |
| | | * @since 0.5-beta |
| | | */ |
| | | function setAnnotation($mailbox, $data) |
| | |
| | | * |
| | | * @return boolean True on success, False on failure |
| | | * |
| | | * @access public |
| | | * @since 0.5-beta |
| | | */ |
| | | function deleteAnnotation($mailbox, $data) |
| | |
| | | * |
| | | * @return array Annotations result on success, NULL on error |
| | | * |
| | | * @access public |
| | | * @since 0.5-beta |
| | | */ |
| | | function getAnnotation($mailbox, $entries, $attribs) |
| | |
| | | * Creates next command identifier (tag) |
| | | * |
| | | * @return string Command identifier |
| | | * @access public |
| | | * @since 0.5-beta |
| | | */ |
| | | function nextTag() |
| | |
| | | * @param int $options Execution options |
| | | * |
| | | * @return mixed Response code or list of response code and data |
| | | * @access public |
| | | * @since 0.5-beta |
| | | */ |
| | | function execute($command, $arguments=array(), $options=0) |
| | |
| | | * @param int $num Number of tokens to return |
| | | * |
| | | * @return mixed Tokens array or string if $num=1 |
| | | * @access public |
| | | * @since 0.5-beta |
| | | */ |
| | | static function tokenizeResponse(&$str, $num=0) |
| | |
| | | * |
| | | * @param boolean $debug New value for the debugging flag. |
| | | * |
| | | * @access public |
| | | * @since 0.5-stable |
| | | */ |
| | | function setDebug($debug, $handler = null) |
| | |
| | | * |
| | | * @param string $message Debug mesage text. |
| | | * |
| | | * @access private |
| | | * @since 0.5-stable |
| | | */ |
| | | private function debug($message) |
| | | { |
| | | if ($this->resourceid) { |
| | | $message = sprintf('[%s] %s', $this->resourceid, $message); |
| | | } |
| | | |
| | | if ($this->_debug_handler) { |
| | | call_user_func_array($this->_debug_handler, array(&$this, $message)); |
| | | } else { |