| | |
| | | // INTERNALDATE "16-Nov-2008 21:08:46 +0100" BODYSTRUCTURE (...) |
| | | // BODY[HEADER.FIELDS ... |
| | | |
| | | if (preg_match('/^\* [0-9]+ FETCH \((.*) BODY/s', $line, $matches)) { |
| | | if (preg_match('/^\* [0-9]+ FETCH \((.*) BODY/sU', $line, $matches)) { |
| | | $str = $matches[1]; |
| | | |
| | | // swap parents with quotes, then explode |
| | |
| | | |
| | | // BODYSTRUCTURE |
| | | if ($bodystr) { |
| | | while (!preg_match('/ BODYSTRUCTURE (.*) BODY\[HEADER.FIELDS/s', $line, $m)) { |
| | | while (!preg_match('/ BODYSTRUCTURE (.*) BODY\[HEADER.FIELDS/sU', $line, $m)) { |
| | | $line2 = $this->readLine(1024); |
| | | $line .= $this->multLine($line2, true); |
| | | } |
| | |
| | | break; |
| | | case 'content-type': |
| | | $ctype_parts = preg_split('/[; ]/', $string); |
| | | $result[$id]->ctype = array_shift($ctype_parts); |
| | | $result[$id]->ctype = strtolower(array_shift($ctype_parts)); |
| | | if (preg_match('/charset\s*=\s*"?([a-z0-9\-\.\_]+)"?/i', $string, $regs)) { |
| | | $result[$id]->charset = $regs[1]; |
| | | } |
| | |
| | | */ |
| | | private function strToTime($date) |
| | | { |
| | | // support non-standard "GMTXXXX" literal |
| | | $date = preg_replace('/GMT\s*([+-][0-9]+)/', '\\1', $date); |
| | | // if date parsing fails, we have a date in non-rfc format. |
| | | // remove token from the end and try again |
| | | while ((($ts = @strtotime($date))===false) || ($ts < 0)) { |
| | | $d = explode(' ', $date); |
| | | array_pop($d); |
| | | if (!$d) { |
| | | break; |
| | | } |
| | | $date = implode(' ', $d); |
| | | } |
| | | |
| | | $ts = (int) $ts; |
| | | |
| | | $ts = (int) rcube_strtotime($date); |
| | | return $ts < 0 ? 0 : $ts; |
| | | } |
| | | |