| | |
| | | |
| | | // Send ID info |
| | | if (!empty($this->prefs['ident']) && $this->getCapability('ID')) { |
| | | $this->id($this->prefs['ident']); |
| | | $this->data['ID'] = $this->id($this->prefs['ident']); |
| | | } |
| | | |
| | | $auth_method = $this->prefs['auth_type']; |
| | |
| | | return false; |
| | | } |
| | | |
| | | $this->data['GREETING'] = trim(preg_replace('/\[[^\]]+\]\s*/', '', $line)); |
| | | |
| | | // RFC3501 [7.1] optional CAPABILITY response |
| | | if (preg_match('/\[CAPABILITY ([^]]+)\]/i', $line, $matches)) { |
| | | $this->parseCapability($matches[1], true); |
| | |
| | | list($code, $response) = $this->execute('SELECT', $params); |
| | | |
| | | if ($code == self::ERROR_OK) { |
| | | $this->clear_mailbox_cache(); |
| | | |
| | | $response = explode("\r\n", $response); |
| | | foreach ($response as $line) { |
| | | if (preg_match('/^\* ([0-9]+) (EXISTS|RECENT)$/i', $line, $m)) { |
| | |
| | | * @return array Server identification information key/value hash |
| | | * @since 0.6 |
| | | */ |
| | | function id($items=array()) |
| | | function id($items = array()) |
| | | { |
| | | if (is_array($items) && !empty($items)) { |
| | | foreach ($items as $key => $value) { |
| | |
| | | list($code, $response) = $this->execute('ID', array( |
| | | !empty($args) ? '(' . implode(' ', (array) $args) . ')' : $this->escape(null) |
| | | )); |
| | | |
| | | |
| | | if ($code == self::ERROR_OK && preg_match('/\* ID /i', $response)) { |
| | | $response = substr($response, 5); // remove prefix "* ID " |
| | |
| | | return (int) $arr[0]; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | |
| | | return null; |
| | | } |
| | | |
| | | if ($uid = $this->data['UID-MAP'][$id]) { |
| | | return $uid; |
| | | } |
| | | |
| | | if (isset($this->data['EXISTS']) && $id > $this->data['EXISTS']) { |
| | | return null; |
| | | } |
| | | |
| | | $index = $this->search($mailbox, $id, true); |
| | | |
| | | if ($index->count() == 1) { |
| | | $arr = $index->get(); |
| | | return (int) $arr[0]; |
| | | return $this->data['UID-MAP'][$id] = (int) $arr[0]; |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | |
| | | protected function clear_status_cache($mailbox) |
| | | { |
| | | unset($this->data['STATUS:' . $mailbox]); |
| | | unset($this->data['EXISTS']); |
| | | unset($this->data['RECENT']); |
| | | unset($this->data['UNSEEN']); |
| | | |
| | | $keys = array('EXISTS', 'RECENT', 'UNSEEN', 'UID-MAP'); |
| | | |
| | | foreach ($keys as $key) { |
| | | unset($this->data[$key]); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Clear internal cache of the current mailbox |
| | | */ |
| | | protected function clear_mailbox_cache() |
| | | { |
| | | $this->clear_status_cache($this->selected); |
| | | |
| | | $keys = array('UIDNEXT', 'UIDVALIDITY', 'HIGHESTMODSEQ', 'NOMODSEQ', |
| | | 'PERMANENTFLAGS', 'QRESYNC', 'VANISHED', 'READ-WRITE'); |
| | | |
| | | foreach ($keys as $key) { |
| | | unset($this->data[$key]); |
| | | } |
| | | } |
| | | |
| | | /** |