| | |
| | | $auth_method = 'CHECK'; |
| | | } |
| | | |
| | | if (!empty($this->prefs['disabled_caps'])) { |
| | | $this->prefs['disabled_caps'] = array_map('strtoupper', (array)$this->prefs['disabled_caps']); |
| | | } |
| | | |
| | | $result = false; |
| | | |
| | | // initialize connection |
| | |
| | | $folders[$mailbox] = array(); |
| | | } |
| | | |
| | | // store LSUB options only if not empty, this way |
| | | // we can detect a situation when LIST doesn't return specified folder |
| | | if (!empty($opts) || $cmd == 'LIST') { |
| | | // store folder options |
| | | if ($cmd == 'LIST') { |
| | | // Add to options array |
| | | if (empty($this->data['LIST'][$mailbox])) |
| | | $this->data['LIST'][$mailbox] = $opts; |
| | |
| | | else if ($name == 'RFC822') { |
| | | $result[$id]->body = $value; |
| | | } |
| | | else if ($name == 'BODY') { |
| | | $body = $this->tokenizeResponse($line, 1); |
| | | if ($value[0] == 'HEADER.FIELDS') |
| | | $headers = $body; |
| | | else if (!empty($value)) |
| | | $result[$id]->bodypart[$value[0]] = $body; |
| | | else if (stripos($name, 'BODY[') === 0) { |
| | | $name = str_replace(']', '', substr($name, 5)); |
| | | |
| | | if ($name == 'HEADER.FIELDS') { |
| | | // skip ']' after headers list |
| | | $this->tokenizeResponse($line, 1); |
| | | $headers = $this->tokenizeResponse($line, 1); |
| | | } |
| | | else if (strlen($name)) |
| | | $result[$id]->bodypart[$name] = $value; |
| | | else |
| | | $result[$id]->body = $body; |
| | | $result[$id]->body = $value; |
| | | } |
| | | } |
| | | |
| | |
| | | // handle one line response |
| | | if ($line[0] == '(' && substr($line, -1) == ')') { |
| | | // tokenize content inside brackets |
| | | // the content can be e.g.: (UID 9844 BODY[2.4] NIL) |
| | | $tokens = $this->tokenizeResponse(preg_replace('/(^\(|\)$)/', '', $line)); |
| | | |
| | | for ($i=0; $i<count($tokens); $i+=2) { |
| | |
| | | $prev = ''; |
| | | $found = true; |
| | | |
| | | while ($bytes > 0) { |
| | | // empty body |
| | | if (!$bytes) { |
| | | $result = ''; |
| | | } |
| | | else while ($bytes > 0) { |
| | | $line = $this->readLine(8192); |
| | | |
| | | if ($line === NULL) { |
| | |
| | | } |
| | | |
| | | foreach ($entries as $name => $value) { |
| | | $entries[$name] = $this->escape($name) . ' ' . $this->escape($value); |
| | | $entries[$name] = $this->escape($name) . ' ' . $this->escape($value, true); |
| | | } |
| | | |
| | | $entries = implode(' ', $entries); |
| | |
| | | |
| | | // Parenthesized list |
| | | case '(': |
| | | case '[': |
| | | $str = substr($str, 1); |
| | | $result[] = self::tokenizeResponse($str); |
| | | break; |
| | | case ')': |
| | | case ']': |
| | | $str = substr($str, 1); |
| | | return $result; |
| | | break; |
| | | |
| | | // String atom, number, NIL, *, % |
| | | // String atom, number, astring, NIL, *, % |
| | | default: |
| | | // empty string |
| | | if ($str === '' || $str === null) { |
| | | break 2; |
| | | } |
| | | |
| | | // excluded chars: SP, CTL, ), [, ] |
| | | if (preg_match('/^([^\x00-\x20\x29\x5B\x5D\x7F]+)/', $str, $m)) { |
| | | // excluded chars: SP, CTL, ), DEL |
| | | // we do not exclude [ and ] (#1489223) |
| | | if (preg_match('/^([^\x00-\x20\x29\x7F]+)/', $str, $m)) { |
| | | $result[] = $m[1] == 'NIL' ? NULL : $m[1]; |
| | | $str = substr($str, strlen($m[1])); |
| | | } |
| | |
| | | |
| | | $this->capability = explode(' ', strtoupper($str)); |
| | | |
| | | if (!empty($this->prefs['disabled_caps'])) { |
| | | $this->capability = array_diff($this->capability, $this->prefs['disabled_caps']); |
| | | } |
| | | |
| | | if (!isset($this->prefs['literal+']) && in_array('LITERAL+', $this->capability)) { |
| | | $this->prefs['literal+'] = true; |
| | | } |