- Timestamp:
- 10/21/10 15:52:45 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php
r3392 r3394 52 52 function open_mbox($folder = False,$force_die=true) 53 53 { 54 $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1"); 54 55 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; 62 79 } 63 80 … … 493 510 if(!$this->mbox || !is_resource($this->mbox)) 494 511 $this->mbox = $this->open_mbox($msg_folder); 495 496 512 $header = $this->get_header($msg_number); 497 513 if (!$header) { … … 753 769 $return['login'] = $_SESSION['phpgw_info']['expressomail']['user']['account_id'];//$GLOBALS['phpgw_info']['user']['account_id']; 754 770 $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 } 755 785 return $return; 756 786 } … … 817 847 if(!$msg->structure[$msg_number]->parts) //Simple message, only 1 piece 818 848 { 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 ) ){ 820 850 $return['body']='isCripted'; 821 851 return $return; … … 824 854 $attachment = array(); //No attachments 825 855 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; 829 868 } 830 869 … … 860 899 $has_multipart = true; 861 900 $this->has_cid = false; 862 901 array_shift($return['signature']); 863 902 if (strtolower($msg->structure[$msg_number]->subtype) == "related") 864 903 $this->has_cid = true; … … 1307 1346 if(strtolower($msg->encoding[$msg_number][$index]) == 'base64') 1308 1347 { 1309 if ($ file_type == 'application/x-pkcs7-signature' || $file_type == 'application/pkcs7-signature')1348 if ($temp['ContentType'] == 'signature') 1310 1349 { 1311 1312 1350 if(!$this->mbox || !is_resource($this->mbox)) 1351 $this->mbox = $this->open_mbox($msg_folder); 1313 1352 1314 1353 $header = @imap_headerinfo($this->mbox, imap_msgno($this->mbox, $msg_number), 80, 255); … … 1319 1358 $certificado = new certificadoB(); 1320 1359 $validade = $certificado->verificar($imap_msg); 1321 1360 $sign[] = $certificado->msg_sem_assinatura; 1322 1361 if ($certificado->apresentado) 1323 1362 { … … 1584 1623 */ 1585 1624 function getMessageType($msg_number, $headers = false){ 1586 1625 include_once(dirname( __FILE__ ) ."/../../security/classes/CertificadoB.php"); 1587 1626 $contentType = "normal"; 1588 1627 if (!$headers){ 1589 1628 $headers = imap_fetchheader($this->mbox, imap_msgno($this->mbox, $msg_number)); 1590 1629 } 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){ 1593 1632 $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)) ); 1596 1635 } 1597 1636 … … 3677 3716 } 3678 3717 3679 function show_decript($params){ 3718 function show_decript($params,$dec=0){ 3719 3680 3720 $source = $params['source']; 3681 3721 //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 } 3688 3735 } 3689 else {3690 if(!$source = base64_decode($source))3691 return "error ".$source."Espaços ".$i;3692 }3693 3694 3736 $insert = $this->insert_email($source,'INBOX'.$this->imap_delimiter.'decifradas'); 3695 3737
Note: See TracChangeset
for help on using the changeset viewer.