Changeset f66f5f0 in github for program/include/rcube_imap_generic.php
- Timestamp:
- Apr 8, 2011 2:15:37 AM (2 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 8abc176
- Parents:
- 89a3035
- File:
-
- 1 edited
-
program/include/rcube_imap_generic.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/include/rcube_imap_generic.php
rc09e328 rf66f5f0 1559 1559 $str = $matches[1]; 1560 1560 1561 // swap parents with quotes, then explode 1562 $str = preg_replace('/[()]/', '"', $str); 1563 $a = rcube_explode_quoted_string(' ', $str); 1564 1565 // did we get the right number of replies? 1566 $parts_count = count($a); 1567 if ($parts_count>=6) { 1568 for ($i=0; $i<$parts_count; $i=$i+2) { 1569 if ($a[$i] == 'UID') { 1570 $result[$id]->uid = intval($a[$i+1]); 1571 } 1572 else if ($a[$i] == 'RFC822.SIZE') { 1573 $result[$id]->size = intval($a[$i+1]); 1574 } 1575 else if ($a[$i] == 'INTERNALDATE') { 1576 $time_str = $a[$i+1]; 1577 } 1578 else if ($a[$i] == 'FLAGS') { 1579 $flags_str = $a[$i+1]; 1580 } 1561 while (list($name, $value) = $this->tokenizeResponse($str, 2)) { 1562 if ($name == 'UID') { 1563 $result[$id]->uid = intval($value); 1581 1564 } 1582 1583 $time_str = str_replace('"', '', $time_str); 1584 1585 // if time is gmt... 1586 $time_str = str_replace('GMT','+0000',$time_str); 1587 1588 $result[$id]->internaldate = $time_str; 1589 $result[$id]->timestamp = $this->StrToTime($time_str); 1590 $result[$id]->date = $time_str; 1565 else if ($name == 'RFC822.SIZE') { 1566 $result[$id]->size = intval($value); 1567 } 1568 else if ($name == 'INTERNALDATE') { 1569 $result[$id]->internaldate = $value; 1570 $result[$id]->date = $value; 1571 $result[$id]->timestamp = $this->StrToTime($value); 1572 } 1573 else if ($name == 'FLAGS') { 1574 $flags_a = $value; 1575 } 1591 1576 } 1592 1577 … … 1636 1621 // handle FLAGS reply after headers (AOL, Zimbra?) 1637 1622 if (preg_match('/\s+FLAGS \((.*)\)\)$/', $line, $matches)) { 1638 $flags_ str = $matches[1];1623 $flags_a = $this->tokenizeResponse($matches[1]); 1639 1624 break; 1640 1625 } … … 1660 1645 // create array with header field:data 1661 1646 while (list($lines_key, $str) = each($lines)) { 1662 list($field, $string) = $this->splitHeaderLine($str);1647 list($field, $string) = explode(':', $str, 2); 1663 1648 1664 1649 $field = strtolower($field); 1665 $string = preg_replace('/\n \s*/', ' ', $string);1650 $string = preg_replace('/\n[\t\s]*/', ' ', trim($string)); 1666 1651 1667 1652 switch ($field) { … … 1727 1712 1728 1713 // process flags 1729 if (!empty($flags_str)) { 1730 $flags_str = preg_replace('/[\\\"]/', '', $flags_str); 1731 $flags_a = explode(' ', $flags_str); 1732 1733 if (is_array($flags_a)) { 1734 foreach($flags_a as $flag) { 1735 $flag = strtoupper($flag); 1736 if ($flag == 'SEEN') { 1737 $result[$id]->seen = true; 1738 } else if ($flag == 'DELETED') { 1739 $result[$id]->deleted = true; 1740 } else if ($flag == 'ANSWERED') { 1741 $result[$id]->answered = true; 1742 } else if ($flag == '$FORWARDED') { 1743 $result[$id]->forwarded = true; 1744 } else if ($flag == '$MDNSENT') { 1745 $result[$id]->mdn_sent = true; 1746 } else if ($flag == 'FLAGGED') { 1747 $result[$id]->flagged = true; 1748 } 1714 if (!empty($flags_a)) { 1715 foreach ($flags_a as $flag) { 1716 $flag = str_replace('\\', '', $flag); 1717 $result[$id]->flags[] = $flag; 1718 1719 switch (strtoupper($flag)) { 1720 case 'SEEN': 1721 $result[$id]->seen = true; 1722 break; 1723 case 'DELETED': 1724 $result[$id]->deleted = true; 1725 break; 1726 case 'ANSWERED': 1727 $result[$id]->answered = true; 1728 break; 1729 case '$FORWARDED': 1730 $result[$id]->forwarded = true; 1731 break; 1732 case '$MDNSENT': 1733 $result[$id]->mdn_sent = true; 1734 break; 1735 case 'FLAGGED': 1736 $result[$id]->flagged = true; 1737 break; 1749 1738 } 1750 $result[$id]->flags = $flags_a;1751 1739 } 1752 1740 } … … 3279 3267 * @return int Unix timestamp 3280 3268 */ 3281 private function strToTime($date) 3282 { 3283 $ts = (int) rcube_strtotime($date); 3269 static function strToTime($date) 3270 { 3271 // support non-standard "GMTXXXX" literal 3272 $date = preg_replace('/GMT\s*([+-][0-9]+)/', '\\1', $date); 3273 3274 // if date parsing fails, we have a date in non-rfc format 3275 // remove token from the end and try again 3276 while (($ts = intval(@strtotime($date))) <= 0) { 3277 $d = explode(' ', $date); 3278 array_pop($d); 3279 if (empty($d)) { 3280 break; 3281 } 3282 $date = implode(' ', $d); 3283 } 3284 3284 3285 return $ts < 0 ? 0 : $ts; 3285 }3286 3287 private function splitHeaderLine($string)3288 {3289 $pos = strpos($string, ':');3290 if ($pos>0) {3291 $res[0] = substr($string, 0, $pos);3292 $res[1] = trim(substr($string, $pos+1));3293 return $res;3294 }3295 return $string;3296 3286 } 3297 3287
Note: See TracChangeset
for help on using the changeset viewer.
