| | |
| | | |
| | | if ($this->putLine("sel1 SELECT \"".$this->escape($mailbox).'"')) { |
| | | do { |
| | | $line = rtrim($this->readLine(300)); |
| | | $a = explode(' ', $line); |
| | | if (count($a) == 3) { |
| | | $token = strtoupper($a[2]); |
| | | if ($token == 'EXISTS') { |
| | | $this->exists = (int) $a[1]; |
| | | } |
| | | else if ($token == 'RECENT') { |
| | | $this->recent = (int) $a[1]; |
| | | } |
| | | $line = rtrim($this->readLine(512)); |
| | | |
| | | if (preg_match('/^\* ([0-9]+) (EXISTS|RECENT)$/', $line, $m)) { |
| | | $token = strtolower($m[2]); |
| | | $this->$token = (int) $m[1]; |
| | | } |
| | | else if (preg_match('/\[?PERMANENTFLAGS\s+\(([^\)]+)\)\]/U', $line, $match)) { |
| | | $this->permanentflags = explode(' ', $match[1]); |
| | | } |
| | | } while (!$this->startsWith($line, 'sel1', true, true)); |
| | | |
| | | if (strcasecmp($a[1], 'OK') == 0) { |
| | | if ($this->parseResult($line) == 0) { |
| | | $this->selected = $mailbox; |
| | | return true; |
| | | } |
| | | else { |
| | | $this->error = "Couldn't select $mailbox"; |
| | | } |
| | | } |
| | | |
| | | $this->error = "Couldn't select $mailbox"; |
| | | return false; |
| | | } |
| | | |
| | |
| | | } |
| | | break; |
| | | case 'in-reply-to': |
| | | $result[$id]->in_reply_to = preg_replace('/[\n<>]/', '', $string); |
| | | $result[$id]->in_reply_to = str_replace(array("\n", '<', '>'), '', $string); |
| | | break; |
| | | case 'references': |
| | | $result[$id]->references = $string; |
| | |
| | | $command = 'LIST'; |
| | | } |
| | | |
| | | $ref = $this->escape($ref); |
| | | $mailbox = $this->escape($mailbox); |
| | | |
| | | // send command |
| | | if (!$this->putLine($key." ".$command." \"". $this->escape($ref) ."\" \"". $this->escape($mailbox) ."\"")) { |
| | | if (!$this->putLine($key." ".$command." \"". $ref ."\" \"". $mailbox ."\"")) { |
| | | $this->error = "Couldn't send $command command"; |
| | | return false; |
| | | } |
| | |
| | | do { |
| | | $line = $this->readLine(500); |
| | | $line = $this->multLine($line, true); |
| | | $a = explode(' ', $line); |
| | | $line = trim($line); |
| | | |
| | | if (($line[0] == '*') && ($a[1] == $command)) { |
| | | $line = rtrim($line); |
| | | // split one line |
| | | $a = rcube_explode_quoted_string(' ', $line); |
| | | // last string is folder name |
| | | $folders[] = preg_replace(array('/^"/', '/"$/'), '', $this->unEscape($a[count($a)-1])); |
| | | // second from last is delimiter |
| | | $delim = trim($a[count($a)-2], '"'); |
| | | if (preg_match('/^\* '.$command.' \(([^\)]*)\) "*([^"]+)"* (.*)$/', $line, $m)) { |
| | | // folder name |
| | | $folders[] = preg_replace(array('/^"/', '/"$/'), '', $this->unEscape($m[3])); |
| | | // attributes |
| | | // $attrib = explode(' ', $m[1]); |
| | | // delimiter |
| | | // $delim = $m[2]; |
| | | } |
| | | } while (!$this->startsWith($line, $key, true)); |
| | | |
| | |
| | | return false; |
| | | } |
| | | |
| | | function appendFromFile($folder, $path, $headers=null, $separator="\n\n") |
| | | function appendFromFile($folder, $path, $headers=null) |
| | | { |
| | | if (!$folder) { |
| | | return false; |
| | |
| | | return false; |
| | | } |
| | | |
| | | $body_separator = "\r\n\r\n"; |
| | | $len = filesize($path); |
| | | |
| | | if (!$len) { |
| | | return false; |
| | | } |
| | | |
| | | if ($headers) { |
| | | $headers = preg_replace('/[\r\n]+$/', '', $headers); |
| | | $len += strlen($headers) + strlen($separator); |
| | | $len += strlen($headers) + strlen($body_separator); |
| | | } |
| | | |
| | | // send APPEND command |
| | |
| | | |
| | | // send headers with body separator |
| | | if ($headers) { |
| | | $this->putLine($headers . $separator, false); |
| | | $this->putLine($headers . $body_separator, false); |
| | | } |
| | | |
| | | // send file |
| | |
| | | // return false if not found, parse if found |
| | | $min_free = PHP_INT_MAX; |
| | | foreach ($quota_lines as $key => $quota_line) { |
| | | $quota_line = preg_replace('/[()]/', '', $quota_line); |
| | | $quota_line = str_replace(array('(', ')'), '', $quota_line); |
| | | $parts = explode(' ', $quota_line); |
| | | $storage_part = array_search('STORAGE', $parts); |
| | | |