| | |
| | | return true; |
| | | } |
| | | |
| | | if (!$this->getCapability('NAMESPACE')) { |
| | | return false; |
| | | } |
| | | |
| | | if (!$this->putLine("ns1 NAMESPACE")) { |
| | | return false; |
| | | } |
| | | do { |
| | | $line = $this->readLine(1024); |
| | | if (preg_match('/^\* NAMESPACE/', $line)) { |
| | | $i = 0; |
| | | $line = $this->unEscape($line); |
| | | $data = $this->parseNamespace(substr($line,11), $i, 0, 0); |
| | | } |
| | | } while (!$this->startsWith($line, 'ns1', true, true)); |
| | | |
| | | if (!is_array($data)) { |
| | | if (!is_array($data = $this->_namespace())) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | do { |
| | | $line = $this->readLine(500); |
| | | if ($line[0] == '*') { |
| | | $line = rtrim($line); |
| | | $a = rcube_explode_quoted_string(' ', $this->unEscape($line)); |
| | | if ($a[0] == '*') { |
| | | $delimiter = str_replace('"', '', $a[count($a)-2]); |
| | | } |
| | | $line = $this->readLine(1024); |
| | | if (preg_match('/^\* LIST \([^\)]*\) "*([^"]+)"* ""/', $line, $m)) { |
| | | $delimiter = $this->unEscape($m[1]); |
| | | } |
| | | } while (!$this->startsWith($line, 'ghd', true, true)); |
| | | |
| | |
| | | |
| | | // if that fails, try namespace extension |
| | | // try to fetch namespace data |
| | | if (!$this->putLine("ns1 NAMESPACE")) { |
| | | if (!is_array($data = $this->_namespace())) { |
| | | return false; |
| | | } |
| | | |
| | | do { |
| | | $line = $this->readLine(1024); |
| | | if (preg_match('/^\* NAMESPACE/', $line)) { |
| | | $i = 0; |
| | | $line = $this->unEscape($line); |
| | | $data = $this->parseNamespace(substr($line,11), $i, 0, 0); |
| | | } |
| | | } while (!$this->startsWith($line, 'ns1', true, true)); |
| | | |
| | | if (!is_array($data)) { |
| | | return false; |
| | | } |
| | | |
| | | // extract user space data (opposed to global/shared space) |
| | | $user_space_data = $data[0]; |
| | |
| | | $delimiter = $first_userspace[1]; |
| | | |
| | | return $delimiter; |
| | | } |
| | | |
| | | function _namespace() |
| | | { |
| | | if (!$this->getCapability('NAMESPACE')) { |
| | | return false; |
| | | } |
| | | |
| | | if (!$this->putLine("ns1 NAMESPACE")) { |
| | | return false; |
| | | } |
| | | |
| | | do { |
| | | $line = $this->readLine(1024); |
| | | if (preg_match('/^\* NAMESPACE/', $line)) { |
| | | $i = 0; |
| | | $data = $this->parseNamespace(substr($line,11), $i, 0, 0); |
| | | } |
| | | } while (!$this->startsWith($line, 'ns1', true, true)); |
| | | |
| | | if (!is_array($data)) { |
| | | return false; |
| | | } |
| | | |
| | | return $data; |
| | | } |
| | | |
| | | function connect($host, $user, $password, $options=null) |
| | |
| | | $message_set = $this->compressMessageSet($message_set); |
| | | |
| | | if ($add) |
| | | $add = ' '.strtoupper(trim($add)); |
| | | $add = ' '.trim($add); |
| | | |
| | | /* FETCH uid, size, flags and headers */ |
| | | $key = 'FH12'; |
| | |
| | | $request .= "(UID RFC822.SIZE FLAGS INTERNALDATE "; |
| | | if ($bodystr) |
| | | $request .= "BODYSTRUCTURE "; |
| | | $request .= "BODY.PEEK[HEADER.FIELDS "; |
| | | $request .= "(DATE FROM TO SUBJECT REPLY-TO IN-REPLY-TO CC BCC "; |
| | | $request .= "CONTENT-TRANSFER-ENCODING CONTENT-TYPE MESSAGE-ID "; |
| | | $request .= "REFERENCES DISPOSITION-NOTIFICATION-TO X-PRIORITY "; |
| | | $request .= "X-DRAFT-INFO".$add.")])"; |
| | | $request .= "BODY.PEEK[HEADER.FIELDS (DATE FROM TO SUBJECT CONTENT-TYPE "; |
| | | $request .= "LIST-POST DISPOSITION-NOTIFICATION-TO".$add.")])"; |
| | | |
| | | if (!$this->putLine($request)) { |
| | | return false; |
| | |
| | | break; |
| | | |
| | | if (preg_match('/^\* ([0-9]+) FETCH/', $line, $m)) { |
| | | $id = $m[1]; |
| | | $id = intval($m[1]); |
| | | |
| | | $result[$id] = new rcube_mail_header; |
| | | $result[$id]->id = $id; |
| | |
| | | if ($parts_count>=6) { |
| | | for ($i=0; $i<$parts_count; $i=$i+2) { |
| | | if ($a[$i] == 'UID') |
| | | $result[$id]->uid = $a[$i+1]; |
| | | $result[$id]->uid = intval($a[$i+1]); |
| | | else if ($a[$i] == 'RFC822.SIZE') |
| | | $result[$id]->size = $a[$i+1]; |
| | | $result[$id]->size = intval($a[$i+1]); |
| | | else if ($a[$i] == 'INTERNALDATE') |
| | | $time_str = $a[$i+1]; |
| | | else if ($a[$i] == 'FLAGS') |
| | |
| | | // folder name |
| | | $folders[] = preg_replace(array('/^"/', '/"$/'), '', $this->unEscape($m[3])); |
| | | // attributes |
| | | // $attrib = explode(' ', $m[1]); |
| | | // $attrib = explode(' ', $this->unEscape($m[1])); |
| | | // delimiter |
| | | // $delim = $m[2]; |
| | | // $delim = $this->unEscape($m[2]); |
| | | } |
| | | } while (!$this->startsWith($line, $key, true)); |
| | | |
| | |
| | | $in_quotes = false; |
| | | $elem = 0; |
| | | |
| | | for ($i;$i<$len;$i++) { |
| | | for ($i; $i<$len; $i++) { |
| | | $c = (string)$str[$i]; |
| | | if ($c == '(' && !$in_quotes) { |
| | | $i++; |
| | |
| | | } else if ($c == '\\') { |
| | | $i++; |
| | | if ($in_quotes) { |
| | | $data[$elem] .= $c.$str[$i]; |
| | | $data[$elem] .= $str[$i]; |
| | | } |
| | | } else if ($c == '"') { |
| | | $in_quotes = !$in_quotes; |