Ignore:
Timestamp:
06/30/11 19:00:36 (13 years ago)
Author:
fernando-alberto
Message:

Ticket #1269 - Mergiando revisoes do brach22 de rev4447 ate rev4643

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
  • sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/inc/class.imap_functions.inc.php

    r4437 r4644  
    5252        function open_mbox($folder = False,$force_die=true) 
    5353        { 
    54                 $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1"); 
     54                $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO-8859-1"); 
    5555                if (is_resource($this->mbox)) 
    5656                { 
     
    120120                 
    121121                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); 
    123123 
    124124 
     
    335335                $invalid_format = false; 
    336336                $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"); 
    338338                $quota = imap_get_quotaroot($this->mbox, $params["folder"]); 
    339339                if((($quota['limit'] - $quota['usage'])*1024) <= $params['FILES'][0]['size']){ 
     
    456456                        $body_part_to_show = '1'; 
    457457 
    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                } 
    471489 
    472490                if(!$status) 
     
    13881406 
    13891407                $pattern = "/(<\w[^>]+|[\/\"'@=])?{$url}/"; 
    1390                 ini_set( 'pcre.backtrack_limit', 300000 );  
     1408                $limit = strlen($body).strlen($body); 
     1409                ini_set( 'pcre.backtrack_limit', $limit );  
     1410                 
    13911411 
    13921412                /*  
     
    16221642 
    16231643                $return = array(); 
     1644                $return['new_msgs'] = imap_num_recent($this->mbox); 
    16241645                $i = 0; 
    16251646                foreach($msgs_to_exec as $msg_number) 
     
    17091730                    $this->open_mbox($folder); 
    17101731                } 
    1711                 $return['new_msgs'] = imap_num_recent($this->mbox); 
     1732 
    17121733                $return['msgs_to_delete'] = $msg_to_delete; 
    17131734                $return['offsetToGMT'] = $this->functions->CalculateDateOffset(); 
     
    17601781                } 
    17611782 
    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']; 
    17641785                $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']; 
    17671788                $uid2cn = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['uid2cn'];  
    17681789                // Free others requests  
     
    17821803                $resultDefault = array();  
    17831804 
    1784                 if (is_array($folders_list)) { 
     1805                if ( is_array($folders_list) ) 
     1806                { 
    17851807                        reset($folders_list); 
    17861808                        $this->ldap = new ldap_functions(); 
    17871809 
    17881810                        $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                        } 
    18371881                } 
    18381882 
     
    19251969                foreach($nameboxs as $key=>$tmp){ 
    19261970                        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                                        } 
    19321986                                } 
    19331987                        } 
     
    20952149                } 
    20962150                 
    2097                 $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1"); 
     2151                $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO-8859-1"); 
    20982152                $folder_name = $params['folder_name']; 
    20992153                // Fix problem with cyrus delimiter changes. 
     
    21302184                $this->add_recipients("cc", $ccaddress, &$mail); 
    21312185                $this->add_recipients("cco", $ccoaddress, &$mail); 
     2186                if ($replytoaddress !="")  
     2187                { 
    21322188                $mail->AddReplyTo($replytoaddress); 
     2189                } 
    21332190                $mail->Subject = $subject; 
    21342191                $mail->IsHTML( ( array_key_exists( 'type', $params ) && in_array( strtolower( $params[ 'type' ] ), array( 'html', 'plain' ) ) ) ? strtolower( $params[ 'type' ] ) != 'plain' : true ); 
     
    26132670                $mbox_stream = $this->open_mbox($folder); 
    26142671                $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"); 
    26162673                $new_folder_name = $params['new_folder_name']; 
    26172674                $msgs_number = $params['msgs_number']; 
     
    27392796 
    27402797                $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"); 
    27422799                // Fix problem with cyrus delimiter changes. 
    27432800                // Dots in names: enabled/disabled. 
     
    31923249                $subject = lang("Read receipt: %1",$params['subject']); 
    31933250                $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>'; 
    31953252                $body .= lang("Has been read by: %1 &lt; %2 &gt; at %3", $_SESSION['phpgw_info']['expressomail']['user']['fullname'], $_SESSION['phpgw_info']['expressomail']['user']['email'], date("d/m/Y H:i")); 
    31963253                $mail->SMTPDebug = false; 
     
    33673424                $return["has_more_msg"] = (sizeof($return["msgs"]) > $max_msgs); 
    33683425                $return["msgs"] = array_slice($return["msgs"], 0, $max_msgs); 
     3426                $return["msgs"]['num_msgs'] = $num_msgs; 
    33693427                 
    33703428                return $return; 
     
    34693527                                } 
    34703528                                 
    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" ); 
    34723530                                $filter = $this->remove_accents($filter); 
    34733531 
     
    34853543                                } 
    34863544                                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" ); 
    34883546                                 
    34893547                                if(!is_resource($mbox_stream)) 
     
    35083566                                                        { 
    35093567                                                                $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" );  
    35113569                                                                $elem['uid'] = $new_search;  
    35123570                                                                /* compare dates in ordering */ 
     
    35533611                                                { 
    35543612                                                        $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" );  
    35563614                                                        $elem['uid'] = $new_search;  
    35573615                                                        /* compare dates in ordering */ 
     
    37273785                }*/ 
    37283786 
    3729                 if (count($remove_share)) 
    3730                 { 
    3731                         foreach ($remove_share as $index=>$uid) 
    3732                         { 
    3733                         if (is_array($mailboxes_list)) 
    3734                         { 
    3735                         foreach ($mailboxes_list as $key => $val) 
    3736                         { 
    3737                         $folder = str_replace($serverString, "", imap_utf7_decode($val->name)); 
    3738                                                 imap_setacl ($mbox_stream, $folder, "$uid", ""); 
    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                } 
    37433801 
    37443802                return true; 
     
    40694127                    $quota_used = str_replace(")","",$size);  
    40704128                    $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");  
    40724130                    if(!preg_match('/user\\'.$this->imap_delimiter.$this->username.'\\'.$this->imap_delimiter.'/i',$folder)){  
    40734131                            $folder = $this->functions->getLang("Inbox");  
Note: See TracChangeset for help on using the changeset viewer.