Changeset d5ff9276 in github
- Timestamp:
- Feb 12, 2008 1:44:58 PM (5 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- a9a8ef2
- Parents:
- a8d23d8
- File:
-
- 1 edited
-
program/lib/imap.inc (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/lib/imap.inc
r90180ef rd5ff9276 756 756 757 757 //strip off day of week 758 $pos =strpos($str, ' ');758 $pos = strpos($str, ' '); 759 759 if (!is_numeric(substr($str, 0, $pos))) { 760 760 $str = substr($str, $pos+1); … … 916 916 $received = 0; 917 917 do { 918 $line = iil_ReadLine($fp, 0);919 $received +=strlen($line);920 $line = chop($line);918 $line = iil_ReadLine($fp, 0); 919 $received += strlen($line); 920 $line = chop($line); 921 921 922 if ($received>$bytes) break; 923 else if (!$line) continue; 922 if ($received>$bytes) { 923 break; 924 } else if (!$line) { 925 continue; 926 } 927 928 list($field, $string) = explode(': ', $line); 924 929 925 list($field,$string)=explode(": ", $line); 926 927 if (strcasecmp($field, "date") == 0) 930 if (strcasecmp($field, 'date') == 0) { 928 931 $result[$id] = iil_StrToTime($string); 929 else if ($index_field!="DATE")932 } else if ($index_field != 'DATE') { 930 933 $result[$id]=strtoupper(str_replace('"', '', $string)); 931 } while ($line[0]!=")"); 934 } 935 } while ($line[0] != ')'); 932 936 }Â else { 933 937 //one line response, not expected so ignore … … 935 939 */ 936 940 } while (!iil_StartsWith($line, $key)); 941 937 942 }else if ($mode == 6) { 943 938 944 $key = 'fhi' . ($c++); 939 945 $request = $key." FETCH $message_set (INTERNALDATE)\r\n"; … … 1473 1479 } 1474 1480 1475 function iil_C_FetchHeaders(&$conn, $mailbox, $message_set, $uidfetch=false) { 1481 function iil_C_FetchHeaders(&$conn, $mailbox, $message_set, $uidfetch=false) 1482 { 1476 1483 global $IMAP_USE_INTERNAL_DATE; 1477 1484 … … 1521 1528 $request .= "(DATE FROM TO SUBJECT REPLY-TO IN-REPLY-TO CC BCC "; 1522 1529 $request .= "CONTENT-TRANSFER-ENCODING CONTENT-TYPE MESSAGE-ID "; 1523 $request .= "REFERENCES RECEIVEDDISPOSITION-NOTIFICATION-TO X-PRIORITY)])\r\n";1530 $request .= "REFERENCES DISPOSITION-NOTIFICATION-TO X-PRIORITY)])\r\n"; 1524 1531 1525 1532 if (!fputs($fp, $request)) { … … 1536 1543 $result[$id]->subject = ''; 1537 1544 $result[$id]->messageID = 'mid:' . $id; 1545 1538 1546 /* 1539 1547 Start parsing headers. The problem is, some header "lines" take up multiple lines. … … 1562 1570 however, unsure how well this would work with all imap clients. 1563 1571 */ 1564 if (preg_match("/^\s*UID [0-9]+\)$/", $line)) {1572 if (preg_match("/^\s*UID [0-9]+\)$/", $line)) { 1565 1573 break; 1566 1574 } … … 1589 1597 $result[$id]->timestamp = iil_StrToTime($string); 1590 1598 break; 1591 case 'received':1592 if (!isset($result[$id]->date)) {1593 $_received = substr(strstr(str_replace("\n",1594 '', $string), '; '), 2);1595 1596 $result[$id]->date = str_replace("\n", '', $_received);1597 $result[$id]->timestamp = iil_StrToTime($_received);1598 }1599 break;1600 1599 case 'from': 1601 1600 $result[$id]->from = $string; … … 1650 1649 } // end while () 1651 1650 } else { 1652 $a =explode(' ', $line);1651 $a = explode(' ', $line); 1653 1652 } 1654 } 1655 } while (strcmp($a[0], $key)!=0); 1656 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); 1701 } 1702 } while (strcmp($a[0], $key) != 0); 1703 1657 1704 /* 1658 1705 FETCH uid, size, flags … … 1670 1717 //$a = explode(' ', $line); 1671 1718 //if (($line[0]=="*") && ($a[2]=="FETCH")) { 1672 if ($line[0] =="*") {1719 if ($line[0] == '*') { 1673 1720 //echo "<!-- $line //-->\n"; 1674 1721 //get outter most parens … … 1763 1810 } 1764 1811 1765 1766 1812 function iil_C_FetchHeader(&$conn, $mailbox, $id, $uidfetch=false) { 1767 1813 $fp = $conn->fp; … … 1818 1864 1819 1865 // sort index 1820 $i =0;1866 $i = 0; 1821 1867 if ($flag == 'ASC') { 1822 1868 asort($index); … … 1844 1890 do { 1845 1891 $line=chop(iil_ReadLine($fp, 100)); 1846 if ($line[0]=="*") $c++; 1892 if ($line[0] == '*') { 1893 $c++; 1894 } 1847 1895 } while (!iil_StartsWith($line, 'exp1')); 1848 1896 … … 1940 1988 $month = (int) $month; 1941 1989 $months = $GLOBALS['IMAP_MONTHS']; 1942 /* $months=array(1943 1=>"Jan", 2=>"Feb", 3=>"Mar", 4=>"Apr",1944 5=>"May", 6=>"Jun", 7=>"Jul", 8=>"Aug",1945 9=>"Sep", 10=>"Oct", 11=>"Nov", 12=>"Dec"1946 );1947 */1948 1990 return $day . '-' . $months[$month] . '-' . $year; 1949 1991 }
Note: See TracChangeset
for help on using the changeset viewer.
