Changeset a9a8ef2 in github
- Timestamp:
- Feb 12, 2008 2:20:14 PM (5 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- a0ce2f0
- Parents:
- d5ff9276
- File:
-
- 1 edited
-
program/lib/imap.inc (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/lib/imap.inc
rd5ff9276 ra9a8ef2 792 792 } 793 793 $fields = array('ARRIVAL'=>1,'CC'=>1,'DATE'=>1,'FROM'=>1,'SIZE'=>1, 794 'SUBJECT'=>1,'TO'=>1);794 'SUBJECT'=>1,'TO'=>1); 795 795 796 796 if (!$fields[$field]) { … … 1489 1489 list($from_idx, $to_idx) = explode(':', $message_set); 1490 1490 if (empty($message_set) || (isset($to_idx) 1491 && (int)$from_idx > (int)$to_idx)) {1491 && (int)$from_idx > (int)$to_idx)) { 1492 1492 return false; 1493 }1493 } 1494 1494 1495 1495 /* Do "SELECT" command */ … … 1510 1510 } else { 1511 1511 $needed_set.=($needed_set ? ',': '') . $id; 1512 }1512 } 1513 1513 } 1514 1514 //echo "<!-- iil_C_FetchHeader\nMessage Set: $message_set\nNeeded Set:$needed_set\n//-->\n"; 1515 1515 if ($needed_set) { 1516 $message_set = iil_CompressMessageSet($needed_set);1517 } else {1518 return $result;1519 }1516 $message_set = iil_CompressMessageSet($needed_set); 1517 } else { 1518 return $result; 1519 } 1520 1520 } 1521 1521 } 1522 1522 1523 1523 /* FETCH date,from,subject headers */ 1524 $key = 'fh' . ($c++);1525 $prefix = $uidfetch?' UID':'';1524 $key = 'fh' . ($c++); 1525 $prefix = $uidfetch?' UID':''; 1526 1526 $request = $key . $prefix; 1527 $request .= " FETCH $message_set (BODY.PEEK[HEADER.FIELDS ";1528 $request .= "(DATE FROM TO SUBJECT REPLY-TO IN-REPLY-TO CC BCC ";1529 $request .= "CONTENT-TRANSFER-ENCODING CONTENT-TYPE MESSAGE-ID ";1530 $request .= "REFERENCES DISPOSITION-NOTIFICATION-TO X-PRIORITY)])\r\n";1527 $request .= " FETCH $message_set (BODY.PEEK[HEADER.FIELDS "; 1528 $request .= "(DATE FROM TO SUBJECT REPLY-TO IN-REPLY-TO CC BCC "; 1529 $request .= "CONTENT-TRANSFER-ENCODING CONTENT-TYPE MESSAGE-ID "; 1530 $request .= "REFERENCES DISPOSITION-NOTIFICATION-TO X-PRIORITY)])\r\n"; 1531 1531 1532 1532 if (!fputs($fp, $request)) { 1533 return false;1534 }1533 return false; 1534 } 1535 1535 do { 1536 1536 $line = chop(iil_ReadLine($fp, 200)); … … 1572 1572 if (preg_match("/^\s*UID [0-9]+\)$/", $line)) { 1573 1573 break; 1574 }1575 // patch from "Maksim Rubis" <siburny@hotmail.com>1574 } 1575 // patch from "Maksim Rubis" <siburny@hotmail.com> 1576 1576 } while (trim($line[0]) != ')' && strncmp($line, $key, strlen($key))); 1577 1577 1578 if (strncmp($line, $key, strlen($key))) {1579 //process header, fill iilBasicHeader obj.1580 // initialize1581 if (is_array($headers)) {1582 reset($headers);1583 while (list($k, $bar) = each($headers)) {1584 $headers[$k] = '';1585 }1586 }1587 1588 // create array with header field:data1589 while ( list($lines_key, $str) = each($lines) ) {1590 list($field, $string) = iil_SplitHeaderLine($str);1591 1592 $field = strtolower($field);1593 1594 switch ($field) {1578 if (strncmp($line, $key, strlen($key))) { 1579 //process header, fill iilBasicHeader obj. 1580 // initialize 1581 if (is_array($headers)) { 1582 reset($headers); 1583 while (list($k, $bar) = each($headers)) { 1584 $headers[$k] = ''; 1585 } 1586 } 1587 1588 // create array with header field:data 1589 while ( list($lines_key, $str) = each($lines) ) { 1590 list($field, $string) = iil_SplitHeaderLine($str); 1591 1592 $field = strtolower($field); 1593 1594 switch ($field) { 1595 1595 case 'date'; 1596 $result[$id]->date = $string;1596 $result[$id]->date = $string; 1597 1597 $result[$id]->timestamp = iil_StrToTime($string); 1598 1598 break; … … 1619 1619 break; 1620 1620 case 'content-type': 1621 $ctype_parts = explode(";", $string);1621 $ctype_parts = explode(";", $string); 1622 1622 $result[$id]->ctype = array_shift($ctype_parts); 1623 1623 foreach ($ctype_parts as $ctype_add) { 1624 if (preg_match('/charset="?([a-z0-9\-\.\_]+)"?/i',1625 $ctype_add, $regs)) {1626 $result[$id]->charset = $regs[1];1624 if (preg_match('/charset="?([a-z0-9\-\.\_]+)"?/i', 1625 $ctype_add, $regs)) { 1626 $result[$id]->charset = $regs[1]; 1627 1627 } 1628 }1629 break;1628 } 1629 break; 1630 1630 case 'in-reply-to': 1631 1631 $result[$id]->in_reply_to = ereg_replace("[\n<>]", '', $string); … … 1646 1646 $result[$id]->priority = intval($matches[1]); 1647 1647 break; 1648 } // end switch () 1649 } // end while () 1650 } else { 1651 $a = explode(' ', $line); 1652 } 1653 1654 if (!isset($result[$id]->date)) { 1655 $result[$id]->date = ''; 1656 } 1657 $result[$id]->date = trim($result[$id]->date); 1658 1659 $before = true; 1660 1661 if ($result[$id]->date == '') { 1662 1663 $before = false; 1664 1665 /* FETCH RECEIVED header */ 1666 $key = 'fh' . ($c++); 1667 $request = $key; 1668 $request .= " UID FETCH $id (BODY.PEEK[HEADER.FIELDS "; 1669 $request .= "(RECEIVED)])\r\n"; 1670 1671 if (fputs($fp, $request)) { 1672 $_received = ''; 1673 while ($line = chop(iil_ReadLine($fp, 200))) { 1674 $line = trim($line); 1675 if (preg_match('/for <(.*)>;(.*)/', $line)) { 1676 $_received .= trim($line); 1677 break; 1678 } 1679 } 1680 if ($_received != '') { 1681 $_received = trim(str_replace(';', '', 1682 substr($_received, strpos($_received, ';')) )); 1683 1684 if ($_received != '') { 1685 $result[$id]->date = $_received; 1686 $result[$id]->timestamp = iil_StrToTime($_received); 1687 //trigger_error("Date: {$result[$id]->timestamp}", E_USER_WARNING); 1688 } 1689 } 1690 $result[$id]->date = trim($result[$id]->date); 1691 } 1692 /** 1693 * This is hack to display something. 1694 */ 1695 if ($result[$id]->date == '') { 1696 $result[$id]->date = date('r'); 1697 $result[$id]->timestamp = time(); 1698 } 1699 } 1700 trigger_error("set before? {$before}, ID {$id}: {$result[$id]->date} / {$result[$id]->timestamp}", E_USER_WARNING); 1648 } // end switch () 1649 } // end while () 1650 } else { 1651 $a = explode(' ', $line); 1652 } 1701 1653 } 1702 1654 } while (strcmp($a[0], $key) != 0); … … 1707 1659 */ 1708 1660 $command_key = 'fh' . ($c++); 1709 1710 1661 $request = $command_key . $prefix; 1711 $request .= " FETCH $message_set (UID RFC822.SIZE FLAGS INTERNALDATE)\r\n"; 1662 $request .= " FETCH $message_set (UID RFC822.SIZE FLAGS INTERNALDATE)\r\n"; 1663 1712 1664 if (!fputs($fp, $request)) { 1713 1665 return false; 1714 1666 } 1715 1667 do { 1716 $line =chop(iil_ReadLine($fp, 200));1668 $line = chop(iil_ReadLine($fp, 200)); 1717 1669 //$a = explode(' ', $line); 1718 1670 //if (($line[0]=="*") && ($a[2]=="FETCH")) { … … 1780 1732 $time_zone += 0.5; //handle half hour offset 1781 1733 } 1782 if ($time_zone_str[0] == '-') {1783 $time_zone = $time_zone * -1.0; //minus?1734 if ($time_zone_str[0] == '-') { 1735 $time_zone = $time_zone * -1.0; //minus? 1784 1736 } 1785 $result[$id]->internaldate = $time_str;1737 $result[$id]->internaldate = $time_str; 1786 1738 1787 if ($IMAP_USE_INTERNAL_DATE ) {1739 if ($IMAP_USE_INTERNAL_DATE || empty($result[$id]->date)) { 1788 1740 //calculate timestamp 1789 1741 $timestamp = strtotime($time_str); //return's server's time … … 1792 1744 1793 1745 $result[$id]->timestamp = $timestamp; 1746 $result[$id]->date = $time_str; 1794 1747 } 1795 1748 … … 1814 1767 $a = iil_C_FetchHeaders($conn, $mailbox, $id, $uidfetch); 1815 1768 if (is_array($a)) { 1816 return array_shift($a);1817 }1769 return array_shift($a); 1770 } 1818 1771 return false; 1819 1772 }
Note: See TracChangeset
for help on using the changeset viewer.
