Ignore:
Timestamp:
10/21/10 15:52:45 (14 years ago)
Author:
rafaelraymundo
Message:

Ticket #1265 - Tratamento de mensagens encapsuladas do Outlook.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php

    r3392 r3394  
    5252        function open_mbox($folder = False,$force_die=true) 
    5353        { 
     54                $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1"); 
    5455                if (is_resource($this->mbox)) 
    55                         return $this->mbox; 
    56                 $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1"); 
    57                                 if($force_die)  
    58                         $this->mbox = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder, $this->username, $this->password) or die(serialize(array('imap_error' => $this->parse_error(imap_last_error())))); 
    59                 else  
    60                         $this->mbox = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder, $this->username, $this->password); 
    61                 return $this->mbox; 
     56                { 
     57                     if ($force_die) 
     58                     { 
     59                        @imap_reopen($this->mbox, "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder) or die(serialize(array('imap_error' => $this->parse_error(imap_last_error())))); 
     60                     } 
     61                     else 
     62                        { 
     63                            @imap_reopen($this->mbox, "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder); 
     64                        } 
     65                } 
     66                else 
     67                    { 
     68                        if($force_die) 
     69                        { 
     70                            $this->mbox = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder, $this->username, $this->password) or die(serialize(array('imap_error' => $this->parse_error(imap_last_error())))); 
     71                        } 
     72                        else 
     73                            { 
     74                                $this->mbox = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder, $this->username, $this->password); 
     75                            } 
     76                         
     77                    } 
     78                    return $this->mbox; 
    6279         } 
    6380 
     
    493510                if(!$this->mbox || !is_resource($this->mbox)) 
    494511                        $this->mbox = $this->open_mbox($msg_folder); 
    495  
    496512                $header = $this->get_header($msg_number); 
    497513                if (!$header) { 
     
    753769                $return['login'] = $_SESSION['phpgw_info']['expressomail']['user']['account_id'];//$GLOBALS['phpgw_info']['user']['account_id']; 
    754770                $return['reply_toaddress'] = $header->reply_toaddress; 
     771                 
     772                if($return_get_body['body']=='isSigned'){ 
     773                    imap_close($this->mbox); 
     774                    $new_mail = $this->show_decript($return_get_body,$dec = 1); 
     775                    //$new_mail['signature'] =  $return_get_body['signature']; 
     776                    $return['body']             = $new_mail['body']; 
     777                    $return['attachments']      = $new_mail['attachments']; 
     778                    $return['thumbs']           = $new_mail['thumbs']; 
     779                    $return['folder'] = $return['msg_folder']; 
     780                    $return['original_ID'] =  $return['msg_number']; 
     781                    $return['msg_folder']       = 'INBOX'.$this->imap_delimiter.'decifradas'; 
     782                    $return['msg_number']       = $new_mail['msg_no']; 
     783                    //$return['signature']      = $return_get_body['signature']; 
     784                } 
    755785                return $return; 
    756786        } 
     
    817847                if(!$msg->structure[$msg_number]->parts) //Simple message, only 1 piece 
    818848                { 
    819                         if(strtolower($msg->structure[$msg_number]->subtype) == 'x-pkcs7-mime'){ 
     849                        if((strtolower($msg->structure[$msg_number]->subtype) == 'x-pkcs7-mime') && (count($return['signature']) == 0 ) ){ 
    820850                                $return['body']='isCripted'; 
    821851                                return $return; 
     
    824854                        $attachment = array(); //No attachments 
    825855 
    826                         if(strtolower($msg->structure[$msg_number]->subtype) == 'x-pkcs7-mime'){ 
    827                                 $return['body']='isCripted'; 
    828                                 return $return; 
     856                        if (strtolower($msg->structure[$msg_number]->subtype) == "x-pkcs7-mime") 
     857                        { 
     858                                $return['body']='isSigned'; 
     859                                $headers = imap_fetchheader($this->mbox, imap_msgno($this->mbox, $msg_number)); 
     860                                $header_body_array = explode('MIME-Version: 1.0', $headers); 
     861                                $show_pkcs7 = $header_body_array[0] . 'MIME-Version: 1.0' . chr(0x0D) .chr(0x0A). $return['signature'][0]; 
     862                                $return['source']=$show_pkcs7; 
     863                                array_shift($return['signature']); 
     864                                $return['signature']; 
     865                                //$return['signature'] = $this->get_signature($msg,$msg_number,$msg_folder); 
     866                                imap_close($this->mbox); 
     867                                return $return; 
    829868                        } 
    830869 
     
    860899                        $has_multipart = true; 
    861900                        $this->has_cid = false; 
    862  
     901                        array_shift($return['signature']); 
    863902                        if (strtolower($msg->structure[$msg_number]->subtype) == "related") 
    864903                                $this->has_cid = true; 
     
    13071346                if(strtolower($msg->encoding[$msg_number][$index]) == 'base64') 
    13081347                { 
    1309                     if ($file_type == 'application/x-pkcs7-signature' || $file_type == 'application/pkcs7-signature') 
     1348                    if ($temp['ContentType'] == 'signature') 
    13101349                    { 
    1311                         if(!$this->mbox || !is_resource($this->mbox)) 
    1312                             $this->mbox = $this->open_mbox($msg_folder); 
     1350                        if(!$this->mbox || !is_resource($this->mbox)) 
     1351                        $this->mbox = $this->open_mbox($msg_folder); 
    13131352 
    13141353                        $header = @imap_headerinfo($this->mbox, imap_msgno($this->mbox, $msg_number), 80, 255); 
     
    13191358                        $certificado = new certificadoB(); 
    13201359                        $validade = $certificado->verificar($imap_msg); 
    1321  
     1360                                        $sign[] = $certificado->msg_sem_assinatura; 
    13221361                        if ($certificado->apresentado) 
    13231362                        { 
     
    15841623     */ 
    15851624    function getMessageType($msg_number, $headers = false){ 
    1586  
     1625            include_once(dirname( __FILE__ ) ."/../../security/classes/CertificadoB.php"); 
    15871626            $contentType = "normal"; 
    15881627            if (!$headers){ 
    15891628                $headers = imap_fetchheader($this->mbox, imap_msgno($this->mbox, $msg_number)); 
    15901629            } 
    1591             //$header2 = imap_fetchheader($this->mbox, imap_msgno($this->mbox, $msg_number)); 
    1592             if (preg_match("/Content-Type:.*pkcs7-signature/i", $headers) == 1){ 
     1630             
     1631            if (preg_match("/pkcs7-signature/i", $headers) == 1){ 
    15931632                $contentType = "signature"; 
    1594             } else if (preg_match("/Content-Type:.*x-pkcs7-mime/i", $headers) == 1){ 
    1595                 $contentType = "cipher"; 
     1633            } else if (preg_match("/pkcs7-mime/i", $headers) == 1){ 
     1634                $contentType = testa_p7m( imap_body($this->mbox, imap_msgno($this->mbox, $msg_number)) ); 
    15961635            } 
    15971636 
     
    36773716    } 
    36783717 
    3679     function show_decript($params){ 
     3718    function show_decript($params,$dec=0){ 
     3719         
    36803720        $source = $params['source']; 
    36813721        //error_log("source: $source\nversao: " . PHP_VERSION, 3, '/tmp/teste.log'); 
    3682         $source = str_replace(" ", "+", $source,$i); 
    3683  
    3684         if (version_compare(PHP_VERSION, '5.2.0', '>=')){ 
    3685             if(!$source = base64_decode($source,true)) 
    3686                 return "error ".$source."Espaços ".$i; 
    3687  
     3722 
     3723        if ($dec == 0) 
     3724        { 
     3725            $source = str_replace(" ", "+", $source,$i); 
     3726            if (version_compare(PHP_VERSION, '5.2.0', '>=')){ 
     3727                if(!$source = base64_decode($source,true)) 
     3728                    return "error ".$source."Espaços ".$i; 
     3729 
     3730            } 
     3731            else { 
     3732                if(!$source = base64_decode($source)) 
     3733                    return "error ".$source."Espaços ".$i; 
     3734            } 
    36883735        } 
    3689         else { 
    3690             if(!$source = base64_decode($source)) 
    3691                 return "error ".$source."Espaços ".$i; 
    3692         } 
    3693  
    36943736        $insert = $this->insert_email($source,'INBOX'.$this->imap_delimiter.'decifradas'); 
    36953737 
Note: See TracChangeset for help on using the changeset viewer.