Changeset 4644 for sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/inc/class.imap_functions.inc.php
- Timestamp:
- 06/30/11 19:00:36 (13 years ago)
- Location:
- sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/inc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/inc
-
Property
svn:ignore
set to
.class.ScriptS.inc.php.swp
.class.SieveS.inc.php.swp
-
Property
svn:ignore
set to
-
sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/inc/class.imap_functions.inc.php
r4437 r4644 52 52 function open_mbox($folder = False,$force_die=true) 53 53 { 54 $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO _8859-1");54 $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO-8859-1"); 55 55 if (is_resource($this->mbox)) 56 56 { … … 120 120 121 121 if(!$search_box_type || $search_box_type=="UNSEEN" || $search_box_type=="SEEN") { 122 $msgs_info = imap_status($this->mbox,"{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".mb_convert_encoding( $folder, "UTF7-IMAP", "ISO _8859-1" ) ,SA_ALL);122 $msgs_info = imap_status($this->mbox,"{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".mb_convert_encoding( $folder, "UTF7-IMAP", "ISO-8859-1" ) ,SA_ALL); 123 123 124 124 … … 335 335 $invalid_format = false; 336 336 $filename = $params['FILES'][0]['name']; 337 $params["folder"] = mb_convert_encoding($params["folder"], "UTF7-IMAP","ISO _8859-1");337 $params["folder"] = mb_convert_encoding($params["folder"], "UTF7-IMAP","ISO-8859-1"); 338 338 $quota = imap_get_quotaroot($this->mbox, $params["folder"]); 339 339 if((($quota['limit'] - $quota['usage'])*1024) <= $params['FILES'][0]['size']){ … … 456 456 $body_part_to_show = '1'; 457 457 458 $status = imap_append($this->mbox, 459 "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$params["folder"], 460 $header. 461 "Content-Type: ".$all_body_type."; charset = \"".$all_body_charset."\"". 462 "\r\n". 463 "Content-Transfer-Encoding: ".$all_body_encoding. 464 "\r\n". 465 "\r\n". 466 str_replace("\n","\r\n",$this->decodeBody( 467 imap_fetchbody($this->mbox,imap_msgno($this->mbox, $params["msg_num"]),$body_part_to_show), 468 $all_body_encoding, $all_body_charset 469 ) 470 ), "\\Seen"); //Append do novo email, só com header e conteúdo sem anexos. 458 if (($all_body_charset == "utf-8") && ($all_body_encoding == "base64")){ 459 $status = imap_append($this->mbox, 460 "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$params["folder"], 461 $header. 462 "Content-Type: ".$all_body_type."; charset = \"iso-8859-1\"". 463 "\r\n". 464 "Content-Transfer-Encoding: quoted-printable". 465 "\r\n". 466 "\r\n". 467 str_replace("\n","\r\n",$this->decodeBody( 468 imap_fetchbody($this->mbox,imap_msgno($this->mbox, $params["msg_num"]),$body_part_to_show), 469 $all_body_encoding, $all_body_charset 470 ) 471 ) 472 , "\\Seen"); //Append do novo email, só com header e conteúdo sem anexos. 473 }else{ 474 $status = imap_append($this->mbox, 475 "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$params["folder"], 476 $header. 477 "Content-Type: ".$all_body_type."; charset = \"".$all_body_charset."\"". 478 "\r\n". 479 "Content-Transfer-Encoding: ".$all_body_encoding. 480 "\r\n". 481 "\r\n". 482 str_replace("\n","\r\n",$this->decodeBody( 483 imap_fetchbody($this->mbox,imap_msgno($this->mbox, $params["msg_num"]),$body_part_to_show), 484 $all_body_encoding, $all_body_charset 485 ) 486 ) 487 , "\\Seen"); //Append do novo email, só com header e conteúdo sem anexos. 488 } 471 489 472 490 if(!$status) … … 1388 1406 1389 1407 $pattern = "/(<\w[^>]+|[\/\"'@=])?{$url}/"; 1390 ini_set( 'pcre.backtrack_limit', 300000 ); 1408 $limit = strlen($body).strlen($body); 1409 ini_set( 'pcre.backtrack_limit', $limit ); 1410 1391 1411 1392 1412 /* … … 1622 1642 1623 1643 $return = array(); 1644 $return['new_msgs'] = imap_num_recent($this->mbox); 1624 1645 $i = 0; 1625 1646 foreach($msgs_to_exec as $msg_number) … … 1709 1730 $this->open_mbox($folder); 1710 1731 } 1711 $return['new_msgs'] = imap_num_recent($this->mbox); 1732 1712 1733 $return['msgs_to_delete'] = $msg_to_delete; 1713 1734 $return['offsetToGMT'] = $this->functions->CalculateDateOffset(); … … 1760 1781 } 1761 1782 1762 $inbox = 'INBOX';1763 $trash = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'];1783 $inbox = 'INBOX'; 1784 $trash = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder']; 1764 1785 $drafts = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder']; 1765 $spam = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'];1766 $sent = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'];1786 $spam = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder']; 1787 $sent = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder']; 1767 1788 $uid2cn = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['uid2cn']; 1768 1789 // Free others requests … … 1782 1803 $resultDefault = array(); 1783 1804 1784 if (is_array($folders_list)) { 1805 if ( is_array($folders_list) ) 1806 { 1785 1807 reset($folders_list); 1786 1808 $this->ldap = new ldap_functions(); 1787 1809 1788 1810 $i = 0; 1789 while (list($key, $val) = each($folders_list)) { 1790 $status = imap_status($mbox_stream, $val->name, SA_UNSEEN); 1791 1792 //$tmp_folder_id = explode("}", imap_utf7_decode($val->name)); 1793 $tmp_folder_id = explode("}", mb_convert_encoding($val->name, "ISO_8859-1", "UTF7-IMAP" )); 1794 1795 if($tmp_folder_id[1]=='INBOX'.$this->imap_delimiter.'decifradas') { 1796 //error_log('passou', 3,'/tmp/imap_get_list.log'); 1797 //imap_deletemailbox($mbox_stream,imap_utf7_encode("{".$this->imap_server."}".'INBOX/decifradas')); 1798 continue; 1799 } 1800 $result[$i]['folder_unseen'] = $status->unseen; 1801 $folder_id = $tmp_folder_id[1]; 1802 $result[$i]['folder_id'] = $folder_id; 1803 1804 $tmp_folder_parent = explode($this->imap_delimiter, $folder_id); 1805 $result[$i]['folder_name'] = array_pop($tmp_folder_parent); 1806 $result[$i]['folder_name'] = $result[$i]['folder_name'] == 'INBOX' ? 'Inbox' : $result[$i]['folder_name']; 1807 1808 if ($uid2cn && substr($folder_id,0,4) == 'user') { 1809 //$this->ldap = new ldap_functions(); 1810 if ($cn = $this->ldap->uid2cn($result[$i]['folder_name'])) { 1811 $result[$i]['folder_name'] = $cn; 1812 } 1813 } 1814 1815 $tmp_folder_parent = implode($this->imap_delimiter, $tmp_folder_parent); 1816 $result[$i]['folder_parent'] = $tmp_folder_parent == 'INBOX' ? '' : $tmp_folder_parent; 1817 1818 if (($val->attributes == 32) && ($result[$i]['folder_name'] != 'Inbox')) 1819 $result[$i]['folder_hasChildren'] = 1; 1820 else 1821 $result[$i]['folder_hasChildren'] = 0; 1822 1823 switch ($tmp_folder_id[1]) { 1824 case $inbox: 1825 case $sent: 1826 case $drafts: 1827 case $spam: 1828 case $trash: 1829 $resultDefault[]=$result[$i]; 1830 break; 1831 default: 1832 $resultMine[]=$result[$i]; 1833 } 1834 1835 $i++; 1836 } 1811 1812 while (list($key, $val) = each($folders_list)) 1813 { 1814 $status = imap_status( $mbox_stream, $val->name, SA_UNSEEN ); 1815 1816 $tmp_folder_id = explode("}", $val->name ); 1817 1818 $folderUser = trim( strpos( $tmp_folder_id[1], $this->imap_delimiter , 5 ) ); 1819 1820 $folderUser = trim( substr( $tmp_folder_id[1], 0, $folderUser ) ); 1821 1822 $Permission = true; 1823 1824 if( $folderUser != "INBOX" && $folderUser != "" ) 1825 { 1826 $Permission = imap_getacl( $mbox_stream, $folderUser ); 1827 } 1828 1829 if( $Permission ) 1830 { 1831 $tmp_folder_id[1] = mb_convert_encoding( $tmp_folder_id[1], "ISO-8859-1", "UTF7-IMAP" ); 1832 1833 if( $tmp_folder_id[1]=='INBOX'.$this->imap_delimiter.'decifradas') 1834 { 1835 //error_log('passou', 3,'/tmp/imap_get_list.log'); 1836 //imap_deletemailbox($mbox_stream,imap_utf7_encode("{".$this->imap_server."}".'INBOX/decifradas')); 1837 continue; 1838 } 1839 1840 $result[$i]['folder_unseen'] = $status->unseen; 1841 $folder_id = $tmp_folder_id[1]; 1842 $result[$i]['folder_id'] = $folder_id; 1843 1844 $tmp_folder_parent = explode($this->imap_delimiter, $folder_id); 1845 $result[$i]['folder_name'] = array_pop($tmp_folder_parent); 1846 $result[$i]['folder_name'] = $result[$i]['folder_name'] == 'INBOX' ? 'Inbox' : $result[$i]['folder_name']; 1847 1848 if ($uid2cn && substr($folder_id,0,4) == 'user') 1849 { 1850 //$this->ldap = new ldap_functions(); 1851 if ($cn = $this->ldap->uid2cn($result[$i]['folder_name'])) 1852 { 1853 $result[$i]['folder_name'] = $cn; 1854 } 1855 } 1856 1857 $tmp_folder_parent = implode($this->imap_delimiter, $tmp_folder_parent); 1858 $result[$i]['folder_parent'] = $tmp_folder_parent == 'INBOX' ? '' : $tmp_folder_parent; 1859 1860 if (($val->attributes == 32) && ($result[$i]['folder_name'] != 'Inbox')) 1861 $result[$i]['folder_hasChildren'] = 1; 1862 else 1863 $result[$i]['folder_hasChildren'] = 0; 1864 1865 switch ($tmp_folder_id[1]) 1866 { 1867 case $inbox: 1868 case $sent: 1869 case $drafts: 1870 case $spam: 1871 case $trash: 1872 $resultDefault[]=$result[$i]; 1873 break; 1874 default: 1875 $resultMine[]=$result[$i]; 1876 } 1877 } 1878 1879 $i++; 1880 } 1837 1881 } 1838 1882 … … 1925 1969 foreach($nameboxs as $key=>$tmp){ 1926 1970 if($tmp != ""){ 1927 if(!imap_createmailbox($mbox_stream,imap_utf7_encode("{".$imap_server."}$tmp"))){ 1928 $result = implode("<br />\n", imap_errors()); 1929 if($mbox_stream) 1930 imap_close($mbox_stream); 1931 return $result; 1971 $to_create_array = explode($this->imap_delimiter, $tmp); 1972 array_pop(&$to_create_array); 1973 $folder = array(); 1974 foreach($to_create_array as $k=>$to_create){ 1975 $folder[] = $to_create; 1976 if($to_create != 'INBOX') { 1977 $tmp = implode($this->imap_delimiter, $folder); 1978 if(!imap_createmailbox($mbox_stream,imap_utf7_encode("{".$imap_server."}$tmp"))){ 1979 $result = implode("<br />\n", imap_errors()); 1980 if("Mailbox already exists" != $result) { 1981 imap_close($mbox_stream); 1982 return $result; 1983 } 1984 } 1985 } 1932 1986 } 1933 1987 } … … 2095 2149 } 2096 2150 2097 $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO _8859-1");2151 $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO-8859-1"); 2098 2152 $folder_name = $params['folder_name']; 2099 2153 // Fix problem with cyrus delimiter changes. … … 2130 2184 $this->add_recipients("cc", $ccaddress, &$mail); 2131 2185 $this->add_recipients("cco", $ccoaddress, &$mail); 2186 if ($replytoaddress !="") 2187 { 2132 2188 $mail->AddReplyTo($replytoaddress); 2189 } 2133 2190 $mail->Subject = $subject; 2134 2191 $mail->IsHTML( ( array_key_exists( 'type', $params ) && in_array( strtolower( $params[ 'type' ] ), array( 'html', 'plain' ) ) ) ? strtolower( $params[ 'type' ] ) != 'plain' : true ); … … 2613 2670 $mbox_stream = $this->open_mbox($folder); 2614 2671 $newmailbox = ($params['new_folder']); 2615 $newmailbox = mb_convert_encoding($newmailbox, "UTF7-IMAP","ISO _8859-1");2672 $newmailbox = mb_convert_encoding($newmailbox, "UTF7-IMAP","ISO-8859-1"); 2616 2673 $new_folder_name = $params['new_folder_name']; 2617 2674 $msgs_number = $params['msgs_number']; … … 2739 2796 2740 2797 $folder = $params['folder']; 2741 $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO _8859-1");2798 $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO-8859-1"); 2742 2799 // Fix problem with cyrus delimiter changes. 2743 2800 // Dots in names: enabled/disabled. … … 3192 3249 $subject = lang("Read receipt: %1",$params['subject']); 3193 3250 $body = lang("Your message: %1",$params['subject']) . '<br>'; 3194 $body .= lang("Received in: %1", $params['date']) . '<br>';3251 $body .= lang("Received in: %1",date("d/m/Y H:i",$params['date'])) . '<br>'; 3195 3252 $body .= lang("Has been read by: %1 < %2 > at %3", $_SESSION['phpgw_info']['expressomail']['user']['fullname'], $_SESSION['phpgw_info']['expressomail']['user']['email'], date("d/m/Y H:i")); 3196 3253 $mail->SMTPDebug = false; … … 3367 3424 $return["has_more_msg"] = (sizeof($return["msgs"]) > $max_msgs); 3368 3425 $return["msgs"] = array_slice($return["msgs"], 0, $max_msgs); 3426 $return["msgs"]['num_msgs'] = $num_msgs; 3369 3427 3370 3428 return $return; … … 3469 3527 } 3470 3528 3471 $name_box = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO _8859-1" );3529 $name_box = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO-8859-1" ); 3472 3530 $filter = $this->remove_accents($filter); 3473 3531 … … 3485 3543 } 3486 3544 else 3487 $folder_name = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO _8859-1" );3545 $folder_name = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO-8859-1" ); 3488 3546 3489 3547 if(!is_resource($mbox_stream)) … … 3508 3566 { 3509 3567 $elem = $this->get_msg_detail($new_search,$name_box,$mbox_stream); 3510 $elem['boxname'] = mb_convert_encoding( $name_box, "ISO _8859-1", "UTF7-IMAP" );3568 $elem['boxname'] = mb_convert_encoding( $name_box, "ISO-8859-1", "UTF7-IMAP" ); 3511 3569 $elem['uid'] = $new_search; 3512 3570 /* compare dates in ordering */ … … 3553 3611 { 3554 3612 $elem = $this->get_msg_detail($new_search,$name_box,$mbox_stream); 3555 $elem['boxname'] = mb_convert_encoding( $name_box, "ISO _8859-1", "UTF7-IMAP" );3613 $elem['boxname'] = mb_convert_encoding( $name_box, "ISO-8859-1", "UTF7-IMAP" ); 3556 3614 $elem['uid'] = $new_search; 3557 3615 /* compare dates in ordering */ … … 3727 3785 }*/ 3728 3786 3729 3730 3731 3732 3733 3734 3735 3736 3737 $folder = str_replace($serverString, "", imap_utf7_decode($val->name));3738 3739 3740 3741 3742 3787 if (count($remove_share)) 3788 { 3789 foreach ($remove_share as $index=>$uid) 3790 { 3791 if (is_array($mailboxes_list)) 3792 { 3793 foreach ($mailboxes_list as $key => $val) 3794 { 3795 $folder = str_replace($serverString, "", $val->name); 3796 imap_setacl ($mbox_stream, $folder, "$uid", ""); 3797 } 3798 } 3799 } 3800 } 3743 3801 3744 3802 return true; … … 4069 4127 $quota_used = str_replace(")","",$size); 4070 4128 $quotaPercent = (($quota_used / 1024) / $data["quota_root"]["quota_limit"])*100; 4071 $folder = mb_convert_encoding($folder, "ISO _8859-1", "UTF7-IMAP");4129 $folder = mb_convert_encoding($folder, "ISO-8859-1", "UTF7-IMAP"); 4072 4130 if(!preg_match('/user\\'.$this->imap_delimiter.$this->username.'\\'.$this->imap_delimiter.'/i',$folder)){ 4073 4131 $folder = $this->functions->getLang("Inbox");
Note: See TracChangeset
for help on using the changeset viewer.