|
|
@ -2060,12 +2060,12 @@ class rcube_imap_generic
|
|
|
|
if (preg_match('/BODY\[HEADER\.FIELDS \("*DATE"*\)\] (.*)/', $line, $matches)) {
|
|
|
|
if (preg_match('/BODY\[HEADER\.FIELDS \("*DATE"*\)\] (.*)/', $line, $matches)) {
|
|
|
|
$value = preg_replace(array('/^"*[a-z]+:/i'), '', $matches[1]);
|
|
|
|
$value = preg_replace(array('/^"*[a-z]+:/i'), '', $matches[1]);
|
|
|
|
$value = trim($value);
|
|
|
|
$value = trim($value);
|
|
|
|
$result[$id] = $this->strToTime($value);
|
|
|
|
$result[$id] = rcube_utils::strtotime($value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// non-existent/empty Date: header, use INTERNALDATE
|
|
|
|
// non-existent/empty Date: header, use INTERNALDATE
|
|
|
|
if (empty($result[$id])) {
|
|
|
|
if (empty($result[$id])) {
|
|
|
|
if (preg_match('/INTERNALDATE "([^"]+)"/', $line, $matches)) {
|
|
|
|
if (preg_match('/INTERNALDATE "([^"]+)"/', $line, $matches)) {
|
|
|
|
$result[$id] = $this->strToTime($matches[1]);
|
|
|
|
$result[$id] = rcube_utils::strtotime($matches[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
$result[$id] = 0;
|
|
|
|
$result[$id] = 0;
|
|
|
@ -2097,7 +2097,7 @@ class rcube_imap_generic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($mode == 4) {
|
|
|
|
else if ($mode == 4) {
|
|
|
|
if (preg_match('/INTERNALDATE "([^"]+)"/', $line, $matches)) {
|
|
|
|
if (preg_match('/INTERNALDATE "([^"]+)"/', $line, $matches)) {
|
|
|
|
$result[$id] = $this->strToTime($matches[1]);
|
|
|
|
$result[$id] = rcube_utils::strtotime($matches[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
$result[$id] = 0;
|
|
|
|
$result[$id] = 0;
|
|
|
@ -2426,7 +2426,7 @@ class rcube_imap_generic
|
|
|
|
else if ($name == 'INTERNALDATE') {
|
|
|
|
else if ($name == 'INTERNALDATE') {
|
|
|
|
$result[$id]->internaldate = $value;
|
|
|
|
$result[$id]->internaldate = $value;
|
|
|
|
$result[$id]->date = $value;
|
|
|
|
$result[$id]->date = $value;
|
|
|
|
$result[$id]->timestamp = $this->StrToTime($value);
|
|
|
|
$result[$id]->timestamp = rcube_utils::strtotime($value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($name == 'FLAGS') {
|
|
|
|
else if ($name == 'FLAGS') {
|
|
|
|
if (!empty($value)) {
|
|
|
|
if (!empty($value)) {
|
|
|
@ -2491,7 +2491,7 @@ class rcube_imap_generic
|
|
|
|
switch ($field) {
|
|
|
|
switch ($field) {
|
|
|
|
case 'date';
|
|
|
|
case 'date';
|
|
|
|
$result[$id]->date = $string;
|
|
|
|
$result[$id]->date = $string;
|
|
|
|
$result[$id]->timestamp = $this->strToTime($string);
|
|
|
|
$result[$id]->timestamp = rcube_utils::strtotime($string);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'to':
|
|
|
|
case 'to':
|
|
|
|
$result[$id]->to = preg_replace('/undisclosed-recipients:[;,]*/', '', $string);
|
|
|
|
$result[$id]->to = preg_replace('/undisclosed-recipients:[;,]*/', '', $string);
|
|
|
@ -2640,7 +2640,7 @@ class rcube_imap_generic
|
|
|
|
case 'date':
|
|
|
|
case 'date':
|
|
|
|
case 'internaldate':
|
|
|
|
case 'internaldate':
|
|
|
|
case 'timestamp':
|
|
|
|
case 'timestamp':
|
|
|
|
$value = self::strToTime($headers->$field);
|
|
|
|
$value = rcube_utils::strtotime($headers->$field);
|
|
|
|
if (!$value && $field != 'timestamp') {
|
|
|
|
if (!$value && $field != 'timestamp') {
|
|
|
|
$value = $headers->timestamp;
|
|
|
|
$value = $headers->timestamp;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -3988,44 +3988,6 @@ class rcube_imap_generic
|
|
|
|
return implode(' ', (array)$flags);
|
|
|
|
return implode(' ', (array)$flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Converts datetime string into unix timestamp
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param string $date Date string
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return int Unix timestamp
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
protected static function strToTime($date)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Clean malformed data
|
|
|
|
|
|
|
|
$date = preg_replace(
|
|
|
|
|
|
|
|
array(
|
|
|
|
|
|
|
|
'/GMT\s*([+-][0-9]+)/', // support non-standard "GMTXXXX" literal
|
|
|
|
|
|
|
|
'/[^a-z0-9\x20\x09:+-]/i', // remove any invalid characters
|
|
|
|
|
|
|
|
'/\s*(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s*/i', // remove weekday names
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
array(
|
|
|
|
|
|
|
|
'\\1',
|
|
|
|
|
|
|
|
'',
|
|
|
|
|
|
|
|
'',
|
|
|
|
|
|
|
|
), $date);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$date = trim($date);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if date parsing fails, we have a date in non-rfc format
|
|
|
|
|
|
|
|
// remove token from the end and try again
|
|
|
|
|
|
|
|
while (($ts = intval(@strtotime($date))) <= 0) {
|
|
|
|
|
|
|
|
$d = explode(' ', $date);
|
|
|
|
|
|
|
|
array_pop($d);
|
|
|
|
|
|
|
|
if (empty($d)) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$date = implode(' ', $d);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $ts < 0 ? 0 : $ts;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* CAPABILITY response parser
|
|
|
|
* CAPABILITY response parser
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|