- Timestamp:
- 05/16/11 11:44:10 (13 years ago)
- Location:
- sandbox/2.2.0.2/expressoMail1_2
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.2.0.2/expressoMail1_2/inc/class.exporteml.inc.php
r4348 r4416 304 304 $body = $this-> getBody($id_number); 305 305 306 $file = "source_".$_SESSION[ 'phpgw_session' ][ 'session_id' ]." .eml";306 $file = "source_".$_SESSION[ 'phpgw_session' ][ 'session_id' ]."_".time().".php"; //source_[sessao]_[timestamp].php 307 307 $f = fopen($tempDir.'/'.$file,"w"); 308 308 fputs($f,$header ."\r\n\r\n". $body); … … 351 351 $return_attachments = array(); 352 352 353 $id_number = $params['num_msg']; 353 $id_number = $params['num_msg']; 354 354 $attachments =unserialize(rawurldecode($params['s_attachments'])); 355 356 $tempDir = $_SESSION['phpgw_info']['server']['temp_dir']; 355 356 $tempDir = dirname( __FILE__ ) . '/../tmpLclAtt'; 357 $tempSubDir = md5(microtime()); 358 exec('mkdir ' . $tempDir . '/'.$tempSubDir.'; cd ' . $tempDir . '/'.$tempSubDir); 359 357 360 $this-> folder = $params['folder']; 358 $this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP"," ISO_8859-1");361 $this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP","UTF-8"); 359 362 $this->connectImap(); 360 363 … … 366 369 if($i && $i == 'names') 367 370 continue; 368 369 $fileName = $_SESSION[ 'phpgw_session' ][ 'session_id' ].md5($attachment['name'].microtime()); 371 $fileNameReal = $this->remove_accents($attachment['name']); 370 372 $ContentType = $this->getFileType($fileNameReal); 371 $f = fopen($tempDir . '/'.$fileName,"wb"); 373 $fileName = $fileNameReal . ".php"; 374 $f = fopen($tempDir . '/'.$tempSubDir.'/'.$fileName,"wb"); 372 375 if(!$f) 373 return false;376 return $tempDir . '/'.$tempSubDir.'/'.$fileName; 374 377 375 378 $fileContent = imap_fetchbody($this->mbox_stream, $id_number,$attachment['pid'], FT_UID); 376 379 $urlPath = 'tmpLclAtt/'.$tempSubDir.'/'.$fileName; 380 381 $headers = "<?php header('Content-Type: ".$ContentType."'); 382 header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 383 header('Pragma: public'); 384 header('Expires: 0'); // set expiration time 385 header('Content-Disposition: attachment; filename=\"". addslashes($fileNameReal) ."\"');\n echo "; 386 377 387 if($attachment['encoding'] == 'base64') { 378 $headers =imap_base64($fileContent);388 $headers.=" imap_base64('".$fileContent."');?>"; 379 389 } 380 390 else if($attachment['encoding'] == 'quoted_printable_decode') { 381 $headers =quoted_printable_decode($fileContent);391 $headers.=" quoted_printable_decode('".$fileContent."');?>"; 382 392 } 383 393 else { 384 $headers =$fileContent;385 } 386 394 $headers.=" '".$fileContent."';?>"; 395 } 396 387 397 fputs($f,$headers); 388 398 389 $url = "inc/gotodownload.php?idx_file=".$tempDir .'/'.$fileName."&newfilename=".$attachment['name']; 390 array_push($return_attachments,array('name' => $fileName,'url' => $url,'pid' =>$attachment['pid'])); 399 array_push($return_attachments,array('name' => $fileName,'url' => $urlPath,'pid' =>$attachment['pid'])); 391 400 fclose($f); 392 401 } -
sandbox/2.2.0.2/expressoMail1_2/inc/class.imap_functions.inc.php
r4413 r4416 84 84 return str_replace("%1", $this->functions->getLang("Mail"), $this->functions->getLang("Connection failed with %1 Server. Try later.")); 85 85 } 86 // This error is returned from Postfix.87 elseif(strstr($error,'message file too big')) {88 return str_replace("%1",$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['max_attachment_size'],$this->functions->getLang('The size of this message has exceeded the limit (%1B).'));89 }90 86 elseif(strstr($error,'virus')) { 91 87 return str_replace("%1", $this->functions->getLang("Mail"), $this->functions->getLang("Your message was rejected by antivirus. Perhaps your attachment has been infected.")); 92 88 } 93 89 // This condition verifies if SESSION is expired. 94 elseif(!count($_SESSION)) 90 elseif(!count($_SESSION)) 95 91 return "nosession"; 96 92 … … 141 137 { 142 138 $temp = $this->get_info_head_msg($msg_number); 143 139 //$temp['msg_sample'] = $this->get_msg_sample($msg_number,$folder); 144 140 if(!$temp) 145 141 return false; … … 283 279 } 284 280 281 /** 282 * 283 * @license http://www.gnu.org/copyleft/gpl.html GPL 284 * @param string $string String a ser decodificada 285 * @return string 286 * @todo Verificar a possibilidade de se utilizar a função iconv_mime_decode, que é capaz de identificar a codificação por si só, mas que pode ser interpretada de forma diversa dependendo da implementação do sistema 287 * @todo Executar testes suficientes para validar a funçao iconv_mime_decode em substituição à este método decode_string 288 */ 285 289 function decode_string($string) 286 { 287 288 if ((strpos(strtolower($string), '=?iso-8859-1') !== false) || (strpos(strtolower($string), '=?windows-1252') !== false)) 289 { 290 $return = ''; 291 $tmp = imap_mime_header_decode($string); 292 foreach ($tmp as $tmp1) 293 $return .= $this->htmlspecialchars_encode($tmp1->text); 294 295 $return = str_replace("\t", "", $return); 296 return $return; 297 } 298 else if (strpos(strtolower($string), '=?utf-8') !== false) 299 { 300 $elements = imap_mime_header_decode($string); 301 302 for($i = 0;$i < count($elements);$i++) 303 { 304 $charset = strtolower($elements[$i]->charset); 305 $text = $elements[$i]->text; 306 307 if(!strcasecmp($charset, "utf-8") || !strcasecmp($charset, "utf-7")) 308 { 309 $decoded .= $this->functions->utf8_to_ncr($text); 310 } 311 else 312 { 313 if( strcasecmp($charset,"default") ) 314 $decoded .= $this->htmlspecialchars_encode(iconv($charset, "iso-8859-1", $text)); 315 else 316 $decoded .= $this->htmlspecialchars_encode($text); 317 } 318 } 319 return $decoded; 320 } 321 else 322 return $this->htmlspecialchars_encode($string); 323 } 290 { 291 if ((strpos(strtolower($string), '=?iso-8859-1') !== false) || (strpos(strtolower($string), '=?windows-1252') !== false)) 292 { 293 $retun = ''; 294 $tmp = imap_mime_header_decode($string); 295 foreach ($tmp as $tmp1) 296 { 297 $return .= $this->htmlspecialchars_encode($tmp1->text); 298 } 299 300 return str_replace("\t", "", $return); 301 } 302 else if (strpos(strtolower($string), '=?utf-8') !== false) 303 { 304 $elements = imap_mime_header_decode($string); 305 306 for($i = 0;$i < count($elements);$i++) 307 { 308 $charset = strtolower($elements[$i]->charset); 309 $text = $elements[$i]->text; 310 311 if(!strcasecmp($charset, "utf-8") || !strcasecmp($charset, "utf-7")) 312 { 313 $decoded .= $this->functions->utf8_to_ncr($text); 314 } 315 else 316 { 317 if( strcasecmp($charset,"default") ) 318 $decoded .= $this->htmlspecialchars_encode(iconv($charset, "iso-8859-1", $text)); 319 else 320 $decoded .= $this->htmlspecialchars_encode($text); 321 } 322 } 323 324 return str_replace("\t", "", $decoded); 325 } 326 else if (eregi('=?', $string)) 327 { 328 return iconv_mime_decode($string); 329 } 330 331 return $this->htmlspecialchars_encode($string); 332 } 324 333 /** 325 334 * Função que importa arquivos .eml exportados pelo expresso para a caixa do usuário. Testado apenas … … 566 575 return $return; 567 576 } 568 577 578 function getRawHeader($msg_number) 579 { 580 return imap_fetchheader($this->mbox, $msg_number, FT_UID); 581 } 582 583 function getRawBody($msg_number) 584 { 585 return imap_body($this->mbox, $msg_number, FT_UID); 586 } 587 588 function builderMsgHeader($msg) 589 { 590 591 592 $fromMail = str_replace('<','', str_replace('>','',$msg->headers['from'])); 593 $tosMails = str_replace('<','', str_replace('>','',$msg->headers['to'])); 594 595 $tos = explode(',',$tosMails); 596 $to = ''; 597 foreach ($tos as $value) 598 { 599 $to .= '<a href="mailto:'.str_replace(' ','',$value).'">'.$value.'</a>, '; 600 } 601 602 $header = ' 603 <table style="margin: 2px; border: 1px solid black; background: none repeat scroll 0% 0% rgb(234, 234, 234);"> 604 <tbody> 605 <tr><td><b>'.$this->functions->getLang('Subject').':</b></td><td>'.$msg->headers['subject'].'</td></tr> 606 <tr><td><b>'.$this->functions->getLang('From').':</b></td><td><a href="mailto:'.$fromMail.'">'.$fromMail.'</a></td></tr> 607 <tr><td><b>'.$this->functions->getLang('Date').':</b></td><td>'.$msg->headers['date'].'</td></tr> 608 <tr><td><b>'.$this->functions->getLang('To').':</b></td><td>'.$to.'</td></tr> 609 </tbody> 610 </table> 611 <br />' 612 ; 613 614 return $header; 615 } 616 617 /** 618 * Constroe o corpo da msg direto na variavel de conteudo 619 * @param Mail_mimeDecode $structure 620 * @param <type> $content Ponteiro para Variavel de conteudo da msg 621 */ 622 function builderMsgBody($structure , &$content , $printHeader = false) 623 { 624 if(strtolower($structure->ctype_primary) == 'multipart' && strtolower($structure->ctype_secondary) == 'alternative') 625 { 626 $numParts = count($structure->parts) - 1; 627 628 for($i = $numParts; $i >= 0; $i--) 629 { 630 $part = $structure->parts[$i]; 631 632 switch (strtolower($part->ctype_primary)) 633 { 634 case 'text': 635 $disposition = strtolower($part->disposition); 636 if($disposition != 'attachment') 637 { 638 if(strtolower($part->ctype_secondary) == 'html') 639 { 640 if($printHeader) 641 $content .= $this->builderMsgHeader($part); 642 643 $content .= $this->decodeMailPart($part->body,$part->ctype_parameters['charset']); 644 } 645 646 if(strtolower($part->ctype_secondary) == 'plain' ) 647 { 648 if($printHeader) 649 $content .= $this->builderMsgHeader($part); 650 651 $content .= '<pre>'.$this->decodeMailPart($part->body,$part->ctype_parameters['charset']).'</pre>'; 652 } 653 654 655 656 } 657 658 $i = -1; 659 break; 660 661 case 'multipart': 662 663 if($printHeader) 664 $content .= $this->builderMsgHeader($part); 665 666 $this->builderMsgBody($part,$content); 667 668 $i = -1; 669 break; 670 671 case 'message': 672 673 if(!is_array($part->parts)) 674 { 675 $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; 676 $content .= '<pre>'. $this->decodeMailPart($part->body, $structure->ctype_parameters['charset']).'</pre>'; 677 $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; 678 } 679 else 680 $this->builderMsgBody($part,$content,true); 681 682 $i = -1; 683 break; 684 } 685 } 686 } 687 else 688 { 689 foreach ($structure->parts as $index => $part) 690 { 691 switch (strtolower($part->ctype_primary)) 692 { 693 case 'text': 694 695 $disposition = strtolower($part->disposition); 696 if($disposition != 'attachment') 697 { 698 if(strtolower($part->ctype_secondary) == 'html') 699 { 700 if($printHeader) 701 $content .= $this->builderMsgHeader($part); 702 703 $content .= $this->decodeMailPart($part->body,$part->ctype_parameters['charset']); 704 } 705 706 if(strtolower($part->ctype_secondary) == 'plain') 707 { 708 if($printHeader) 709 $content .= $this->builderMsgHeader($part); 710 711 $content .= '<pre>'.$this->decodeMailPart($part->body,$part->ctype_parameters['charset']).'</pre>'; 712 } 713 714 715 } 716 break; 717 case 'multipart': 718 719 if($printHeader) 720 $content .= $this->builderMsgHeader($part); 721 722 $this->builderMsgBody($part,$content); 723 724 break; 725 case 'message': 726 727 if(!is_array($part->parts)) 728 { 729 $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; 730 $content .= '<pre>'. $this->decodeMailPart($part->body, $structure->ctype_parameters['charset']).'</pre>'; 731 $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; 732 } 733 else 734 $this->builderMsgBody($part,$content,true); 735 break; 736 } 737 } 738 } 739 } 740 741 742 743 function get_msg_sample($msg_number) 744 { 745 746 $return = ""; 747 if( (!isset($this->prefs['preview_msg_subject']) || ($this->prefs['preview_msg_subject'] != "1")) && 748 (!isset($this->prefs['preview_msg_tip'] ) || ($this->prefs['preview_msg_tip'] != "1")) ) 749 { 750 $return['body'] = ""; 751 return $return; 752 } 753 754 include_once("class.message_components.inc.php"); 755 $msg = &new message_components($this->mbox); 756 $msg->fetch_structure($msg_number); 757 758 if(!$msg->structure[$msg_number]->parts) 759 { 760 $content = ''; 761 if (strtolower($msg->structure[$msg_number]->subtype) == "plain" || strtolower($msg->structure[$msg_number]->subtype) == "html") 762 { 763 $content = $this->decodeBody(imap_body($this->mbox, $msg_number, FT_UID|FT_PEEK), $msg->encoding[$msg_number][0], $msg->charset[$msg_number][0]); 764 } 765 } 766 else 767 { 768 foreach($msg->pid[$msg_number] as $values => $msg_part) 769 { 770 771 $file_type = strtolower($msg->file_type[$msg_number][$values]); 772 if($file_type == "text/plain" || $file_type == "text/html") { 773 $content = $this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID|FT_PEEK), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values]); 774 break; 775 } 776 } 777 } 778 $content = $this->replace_special_characters($content); 779 $tags_replace = array("<br>","<br/>","<br />"); 780 $content = str_replace($tags_replace," ", $content); 781 $content = strip_tags($content); 782 $content = str_replace(array("{","}"," "), " ", $content); 783 $content = trim($content); 784 $content = html_entity_decode(substr($content,0,300)); 785 $content != "" ? $return['body'] = " - " . $content: $return['body'] = ""; 786 return $return; 787 } 788 789 569 790 function get_info_msg($params) 570 791 { 571 792 $return = array(); 572 793 $msg_number = $params['msg_number']; 573 if(@preg_match('(.+)(_[a-zA-Z0-9]+)',$msg_number,$matches)) { //Verifies if it comes from a tab diferent of the main one.574 $msg_number = $matches[1];575 $plus_id = $matches[2];576 }577 else {578 $plus_id = '';579 }580 794 $msg_folder = urldecode($params['msg_folder']); 581 795 796 if(preg_match('(.+)(_[a-zA-Z0-9]+)',$msg_number,$matches)) { //Verifies if it comes from a tab diferent of the main one. 797 $msg_number = $matches[1]; 798 $plus_id = $matches[2]; 799 } 800 else { 801 $plus_id = ''; 802 } 803 582 804 if(!$this->mbox || !is_resource($this->mbox)) 583 $this->mbox = $this->open_mbox($msg_folder); 805 $this->mbox = $this->open_mbox($msg_folder); 806 584 807 $header = $this->get_header($msg_number); 585 808 if (!$header) { 586 $return['status_get_msg_info'] = "false"; 809 $return['status_get_msg_info'] = "false"; 587 810 return $return; 588 811 } 589 590 $header_ = imap_fetchheader($this->mbox, $msg_number, FT_UID); 591 812 813 $header_ = imap_fetchheader($this->mbox, $msg_number, FT_UID); 592 814 $return_get_body = $this->get_body_msg($msg_number, $msg_folder); 593 594 815 $body = $return_get_body['body']; 595 816 596 817 if($return_get_body['body']=='isCripted'){ 597 818 $exporteml = new ExportEml(); … … 603 824 //return $return; 604 825 }else{ 605 $return['body'] = $body; 606 $return['attachments'] = $return_get_body['attachments']; 607 $return['thumbs'] = $return_get_body['thumbs']; 608 $return['signature'] = $return_get_body['signature']; 609 } 610 611 $flag = preg_match('/importance *: *(.*)\r/i', $header_, $importance); 612 $return['Importance'] = ($flag == 0) ? "Normal" : $importance[1]; 613 826 $return['body'] = $body; 827 $return['attachments'] = $return_get_body['attachments']; 828 $return['thumbs'] = $return_get_body['thumbs']; 829 $return['signature'] = $return_get_body['signature']; 830 } 614 831 $pattern = '/^[ \t]*Disposition-Notification-To:[ ]*<?[[:alnum:]\._-]+@[[:alnum:]_-]+[\.[:alnum:]]+>?/sm'; 615 832 if (preg_match($pattern, $header_, $fields)) 616 833 { 617 if(preg_match('/[[:alnum:]\._\-]+@[[:alnum:]_\-\.]+/',$fields[0], $matches)){ 618 $return['DispositionNotificationTo'] = "<".$matches[0].">"; 619 } 834 if(preg_match('/[[:alnum:]\._\-]+@[[:alnum:]_\-\.]+/',$fields[0], $matches)){ 835 $return['DispositionNotificationTo'] = "<".$matches[0].">"; 836 } 620 837 } 621 838 622 839 $return['Recent'] = $header->Recent; 623 840 $return['Unseen'] = $header->Unseen; 624 $return['Deleted'] = $header->Deleted; 841 $return['Deleted'] = $header->Deleted; 625 842 $return['Flagged'] = $header->Flagged; 626 843 … … 628 845 $return['Forwarded'] = 'F'; 629 846 } 630 847 631 848 else { 632 849 $return['Answered'] = $header->Answered; 633 $return['Draft'] = $header->Draft; 634 } 635 636 $return['msg_number'] = $msg_number.$plus_id; 850 $return['Draft'] = $header->Draft; 851 } 852 853 $return['msg_number'] = $msg_number.$plus_id; 637 854 $return['msg_folder'] = $msg_folder; 638 639 $offset = $this->functions->CalculateDateOffset(); 640 $msgTimestamp = $header->udate + $offset; 641 642 $date_msg = gmdate("d/m/Y",$msgTimestamp); 643 // if (date("d/m/Y") == $date_msg) 644 // $return['udate'] = $header->udate; 645 // else 646 $return['udate'] = $header->udate; 647 648 $return['msg_day'] = $date_msg; 649 $return['msg_hour'] = gmdate("H:i",$msgTimestamp); 650 855 856 $date_msg = gmdate("d/m/Y",$header->udate); 857 if (date("d/m/Y") == $date_msg) 858 $return['udate'] = gmdate("H:i",$header->udate); 859 else 860 $return['udate'] = $date_msg; 861 862 $return['msg_day'] = $date_msg; 863 $return['msg_hour'] = gmdate("H:i",$header->udate); 864 651 865 if (date("d/m/Y") == $date_msg) //no dia 652 866 { 653 $return['fulldate'] = gmdate("d/m/Y H:i",$ msgTimestamp);654 $return['smalldate'] = gmdate("H:i",$ msgTimestamp);655 656 $timestamp_now = strtotime("now"); 657 $timestamp_msg_time = $ msgTimestamp;658 // $timestamp_now and $timestamp_msg_time are GMT.867 $return['fulldate'] = gmdate("d/m/Y H:i",$header->udate); 868 $return['smalldate'] = gmdate("H:i",$header->udate); 869 870 $timestamp_now = strtotime("now"); 871 $timestamp_msg_time = $header->udate; 872 // $timestamp_now is GMT and $timestamp_msg_time is MailDate TZ. 659 873 // The variable $timestamp_diff is calculated without MailDate TZ. 660 $timestamp_diff = $timestamp_now - $timestamp_msg_time; 661 874 $pdate = date_parse($header->MailDate); 875 $timestamp_diff = $timestamp_now - $timestamp_msg_time + ($pdate['zone']*(-60)); 876 662 877 if (gmdate("H",$timestamp_diff) > 0) 663 878 { … … 678 893 } 679 894 else{ 680 $return['fulldate'] = gmdate("d/m/Y H:i",$ msgTimestamp);681 $return['smalldate'] = gmdate("d/m/Y",$ msgTimestamp);682 } 683 895 $return['fulldate'] = gmdate("d/m/Y H:i",$header->udate); 896 $return['smalldate'] = gmdate("d/m/Y",$header->udate); 897 } 898 684 899 $from = $header->from; 685 900 $return['from'] = array(); … … 695 910 else 696 911 $return['from']['full'] = $return['from']['email']; 697 912 698 913 // Sender attribute 699 914 $sender = $header->sender; 700 $return['sender'] = array(); 915 $return['sender'] = array(); 701 916 $return['sender']['name'] = $this->decode_string($sender[0]->personal); 702 917 $return['sender']['email'] = $this->decode_string($sender[0]->mailbox . "@" . $sender[0]->host); … … 743 958 $return['toaddress2'] = $this->del_last_two_caracters($return['toaddress2']); 744 959 } 745 960 else 961 { 962 $return['toaddress2'] = "<Empty>"; 963 } 964 746 965 $cc = $header->cc; 747 966 $return['cc'] = ""; … … 771 990 { 772 991 $return['cc'] = ""; 773 } 992 } 774 993 775 994 ## … … 778 997 # @BRIEF Adding the BCC field. 779 998 ## 780 $bcc = $header->bcc; 999 1000 $bcc = $header->bcc; 781 1001 $return['bcc'] = ""; 782 1002 if (!empty($bcc)) … … 805 1025 { 806 1026 $return['bcc'] = ""; 807 } 1027 } 808 1028 809 1029 $reply_to = $header->reply_to; … … 835 1055 $return['reply_to'] = $this->decode_string($return['reply_to']); 836 1056 $return['subject'] = $this->decode_string($header->fetchsubject); 837 $return['Size'] = $header->Size; 1057 $return['Size'] = $header->Size; 838 1058 $return['reply_toaddress'] = $header->reply_toaddress; 839 1059 840 1060 //All this is to help in local messages 841 //$return['timestamp'] = $header->udate; 842 $return['timestamp'] = $header->udate; 1061 $return['timestamp'] = $header->udate; 843 1062 $return['login'] = $_SESSION['phpgw_info']['expressomail']['user']['account_id'];//$GLOBALS['phpgw_info']['user']['account_id']; 844 1063 $return['reply_toaddress'] = $header->reply_toaddress; 845 846 if($return_get_body['body']=='isSigned'){ 847 imap_close($this->mbox); 848 $new_mail = $this->show_decript($return_get_body,$dec = 1); 849 //$new_mail['signature'] = $return_get_body['signature']; 850 $return['body'] = $new_mail['body']; 851 $return['attachments'] = $new_mail['attachments']; 852 $return['thumbs'] = $new_mail['thumbs']; 853 $return['folder'] = $return['msg_folder']; 854 $return['original_ID'] = $return['msg_number']; 855 $return['msg_folder'] = 'INBOX'.$this->imap_delimiter.'decifradas'; 856 $return['msg_number'] = $new_mail['msg_no']; 857 //$return['signature'] = $return_get_body['signature']; 858 } 1064 859 1065 return $return; 860 1066 } 861 1067 862 function get_msg_sample($msg_number) 863 { 864 865 $return = ""; 866 if( (!isset($this->prefs['preview_msg_subject']) || ($this->prefs['preview_msg_subject'] != "1")) && 867 (!isset($this->prefs['preview_msg_tip'] ) || ($this->prefs['preview_msg_tip'] != "1")) ) 868 { 869 $return['body'] = ""; 870 return $return; 871 } 872 873 include_once("class.message_components.inc.php"); 874 $msg = &new message_components($this->mbox); 875 $msg->fetch_structure($msg_number); 876 877 if(!$msg->structure[$msg_number]->parts) 878 { 879 $content = ''; 880 if (strtolower($msg->structure[$msg_number]->subtype) == "plain" || strtolower($msg->structure[$msg_number]->subtype) == "html") 881 { 882 $content = $this->decodeBody(imap_body($this->mbox, $msg_number, FT_UID|FT_PEEK), $msg->encoding[$msg_number][0], $msg->charset[$msg_number][0]); 883 } 884 } 885 else 886 { 887 foreach($msg->pid[$msg_number] as $values => $msg_part) 888 { 889 890 $file_type = strtolower($msg->file_type[$msg_number][$values]); 891 if($file_type == "text/plain" || $file_type == "text/html") { 892 $content = $this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID|FT_PEEK), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values]); 893 break; 894 } 895 } 896 } 897 $content = $this->replace_special_characters($content); 898 $tags_replace = array("<br>","<br/>","<br />"); 899 $content = str_replace($tags_replace," ", $content); 900 $content = strip_tags($content); 901 $content = str_replace(array("{","}"," "), " ", $content); 902 $content = trim($content); 903 $content = html_entity_decode(substr($content,0,300)); 904 $content != "" ? $return['body'] = " - " . $content: $return['body'] = ""; 905 return $return; 906 } 907 1068 /** 1069 * Decodifica uma part da mensagem para iso-8859-1 1070 * @param <type> $part parte do email 1071 * @param <type> $encode codificação da parte 1072 * @return <type> string decodificada 1073 */ 1074 function decodeMailPart($part, $encode) 1075 { 1076 switch (strtolower($encode)) 1077 { 1078 case 'iso-8859-1': 1079 return $part; 1080 break; 1081 1082 case 'utf-8': 1083 return utf8_decode($part); 1084 break; 1085 1086 default: 1087 return mb_convert_encoding($part, 'iso-8859-1'); 1088 break; 1089 } 1090 } 1091 1092 908 1093 function get_body_msg($msg_number, $msg_folder) 909 1094 { 910 include_once("class.message_components.inc.php"); 911 $msg = &new message_components($this->mbox); 912 $msg->fetch_structure($msg_number); 913 $return = array(); 914 $return['attachments'] = $this-> download_attachment($msg,$msg_number); 915 if(!$this->has_cid) 916 { 917 $return['thumbs'] = $this->get_thumbs($msg,$msg_number,urlencode($msg_folder)); 918 $return['signature'] = $this->get_signature($msg,$msg_number,$msg_folder); 919 } 920 921 if(!$msg->structure[$msg_number]->parts) //Simple message, only 1 piece 922 { 923 if((strtolower($msg->structure[$msg_number]->subtype) == 'x-pkcs7-mime') && (count($return['signature']) == 0 ) ){ 924 $return['body']='isCripted'; 925 return $return; 926 } 927 928 $attachment = array(); //No attachments 929 930 if (strtolower($msg->structure[$msg_number]->subtype) == "x-pkcs7-mime") 931 { 932 $return['body']='isSigned'; 933 $headers = imap_fetchheader($this->mbox, imap_msgno($this->mbox, $msg_number)); 934 $header_body_array = explode('MIME-Version: 1.0', $headers); 935 $show_pkcs7 = $header_body_array[0] . 'MIME-Version: 1.0' . chr(0x0D) .chr(0x0A). $return['signature'][0]; 936 $return['source']=$show_pkcs7; 937 array_shift($return['signature']); 938 $return['signature']; 939 //$return['signature'] = $this->get_signature($msg,$msg_number,$msg_folder); 940 imap_close($this->mbox); 1095 /* 1096 * Requires of librarys 1097 */ 1098 require_once $_SESSION['rootPath'].'/library/mime/mimePart.php'; 1099 require_once $_SESSION['rootPath'].'/library/mime/mimeDecode.php'; 1100 require_once $_SESSION['rootPath'].'/expressoMail1_2/inc/class.attachment.inc.php'; 1101 include_once ("class.message_components.inc.php"); 1102 //--------------------------------------------------------------------// 1103 1104 $return = array(); 1105 1106 $msg = &new message_components($this->mbox); 1107 $msg->fetch_structure($msg_number); 1108 1109 $content = ''; 1110 1111 $rawMessageData = $this->getRawHeader($msg_number).$this->getRawBody($msg_number); 1112 1113 $decoder = new Mail_mimeDecode($rawMessageData); 1114 1115 $params['include_bodies'] = true; 1116 $params['decode_bodies'] = true; 1117 $params['decode_headers'] = true; 1118 $structure = $decoder->decode($params); 1119 1120 /* 1121 * Inicia Gerenciador de Anexos 1122 */ 1123 $attachmentManager = new attachment(); 1124 $attachmentManager->setStructure($structure); 1125 //----------------------------------------------// 1126 1127 /* 1128 * Monta informações dos anexos para o cabecarios 1129 */ 1130 $attachments = $attachmentManager->getAttachmentsInfo(); 1131 $return['attachments'] = $attachments; 1132 //----------------------------------------------// 1133 1134 /* 1135 * Monta informações das imagens 1136 */ 1137 $images = $attachmentManager->getEmbeddedImagesInfo(); 1138 //----------------------------------------------// 1139 1140 if(!$this->has_cid) 1141 { 1142 $return['thumbs'] = $this->get_thumbs($images,$msg_number,$msg_folder); 1143 $return['signature'] = $this->get_signature($msg,$msg_number,$msg_folder); 1144 } 1145 1146 switch (strtolower($structure->ctype_primary)) 1147 { 1148 1149 case 'text': 1150 if(strtolower($structure->ctype_secondary) == 'x-pkcs7-mime') 1151 { 1152 $return['body']='isCripted'; 941 1153 return $return; 942 } 943 944 $content = ''; 945 // If simple message is subtype 'html' or 'plain', then get content body. 946 if(strtolower($msg->structure[$msg_number]->subtype) == "html" || 947 strtolower( $msg -> structure[ $msg_number ] -> subtype ) == 'plain'){ 948 949 $content = $this->decodeBody( 950 imap_body( $this -> mbox, $msg_number, FT_UID ), 951 $msg -> encoding[ $msg_number ][ 0 ], 952 $msg -> charset[ $msg_number ][ 0 ] 953 ); 954 955 if ( strtolower( $msg -> structure[ $msg_number ] -> subtype ) == 'plain' ) 956 { 957 $content = str_replace( array( '<', '>' ), array( ' #$<$# ', ' #$>$# ' ), $content ); 958 $content = htmlentities( $content ); 959 $content = $this -> replace_links( $content ); 960 $content = str_replace( array( ' #$<$# ', ' #$>$# ' ), array( '<', '>' ), $content ); 961 $content = '<pre>' . $content . '</pre>'; 962 $content = str_replace("\x00", '', $content); 963 $return[ 'body' ] = $content; 964 965 return $return; 966 } 967 } 968 } 969 else 970 { //Complicated message, multiple parts 971 $html_body = ''; 972 $content = ''; 973 $has_multipart = true; 974 $is_alternative = false; 975 $this->has_cid = false; 976 $alternative_content; 977 array_shift($return['signature']); 978 if (strtolower($msg->structure[$msg_number]->subtype) == "related") 979 $this->has_cid = true; 980 981 if (strtolower($msg->structure[$msg_number]->subtype) == "alternative") { 982 $is_alternative = true; 983 $show_only_html = false; 984 foreach($msg->pid[$msg_number] as $values => $msg_part) { 985 $file_type = strtolower($msg->file_type[$msg_number][$values]); 986 if($file_type == "text/html") 987 $show_only_html = true; 988 } 989 } 990 else 991 $show_only_html = false; 992 993 foreach($msg->pid[$msg_number] as $values => $msg_part) 994 { 995 996 $file_type = strtolower($msg->file_type[$msg_number][$values]); 997 if($file_type == "message/rfc822" || $file_type == "multipart/alternative") 998 { 999 // Show only 'text/html' part, when message/rfc822 format contains 'text/plain' alternative part. 1000 if(array_key_exists($values+1, $msg->file_type[$msg_number]) && 1001 strtolower($msg->file_type[$msg_number][$values+1]) == 'text/plain' && 1002 array_key_exists($values+2, $msg->file_type[$msg_number]) && 1003 strtolower($msg->file_type[$msg_number][$values+2]) == 'text/html') { 1004 $has_multipart = false; 1005 } 1006 } 1007 1008 if(($file_type == "text/plain" 1009 || $file_type == "text/html") 1010 && $file_type != 'attachment') 1011 { 1012 1013 1014 if($this->prefs['max_msg_size'] == "1") 1015 $max_size = 1048576; 1016 else 1017 $max_size = 102400; 1018 1019 if($file_type == "text/plain" && !$show_only_html && $has_multipart) 1020 { 1021 // if TXT file size > 100kb, then it will not expand. 1022 if(!($file_type == "text/plain" && $msg->fsize[$msg_number][$values] > $max_size)) { 1023 $content .= htmlentities($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values])); 1024 $content = '<pre>' . $content . '</pre>'; 1025 } 1026 } 1027 // if HTML attachment file size > 300kb, then it will not expand. 1028 else if($file_type == "text/html" && $msg->fsize[$msg_number][$values] < $max_size*3) 1029 { 1030 if ($is_alternative) 1031 { 1032 $alternative_content = $this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values]); 1033 } 1034 else 1035 { 1036 $content .= $this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values]); 1037 $show_only_html = true; 1038 } 1039 } 1040 } 1041 else if($file_type == "message/delivery-status" || $file_type == "message/feedback-report"){ 1042 $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; 1043 $content .= $this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values]); 1044 $content = '<pre>' . $content . '</pre>'; 1045 } 1046 else if($file_type == "message/rfc822" || $file_type == "text/rfc822-headers"){ 1047 1048 include_once("class.imap_attachment.inc.php"); 1049 $att = new imap_attachment(); 1050 $attachments = $att -> get_attachment_info($this->mbox,$msg_number); 1051 if($attachments['number_attachments'] > 0) { 1052 foreach($attachments ['attachment'] as $index => $attachment) 1053 { 1054 if ( in_array( strtolower( $attachment[ 'type' ] ), array( 'delivery-status', 'rfc822', 'rfc822-headers', 'plain' ) ) ) 1055 { 1056 $obj = imap_rfc822_parse_headers( imap_fetchbody( $this -> mbox, $msg_number, $msg_part, FT_UID ), $msg -> encoding[ $msg_number ][ $values ] ); 1057 1058 $content .= '<hr align="left" width="95%" style="border:1px solid #DCDCDC">'; 1059 $content .= '<br><table style="margin:2px;border:1px solid black;background:#EAEAEA">'; 1060 1061 $content .= '<tr><td><b>' . $this->functions->getLang("Subject") 1062 . ':</b></td><td>' .$this->decode_string($obj->subject) . '</td></tr>'; 1063 1064 $content .= '<tr><td><b>' . $this -> functions -> getLang( 'From' ) . ':</b></td><td>' 1065 . $this -> replace_links( $this -> decode_string( $obj -> from[ 0 ] -> mailbox . '@' . $obj -> from[ 0 ] -> host) ) 1066 . '</td></tr>'; 1067 1068 $content .= '<tr><td><b>' . $this->functions->getLang("Date") . ':</b></td><td>' . $obj->date . '</td></tr>'; 1069 1070 $content .= '<tr><td><b>' . $this -> functions -> getLang( 'TO' ) . ':</b></td><td>' 1071 . $this -> replace_links( $this -> decode_string( $obj -> to[ 0 ] -> mailbox . '@' . $obj -> to[ 0 ] -> host ) ) 1072 . '</td></tr>'; 1073 1074 if ( $obj->cc ) 1075 $content .= '<tr><td><b>' . $this -> functions -> getLang( 'CC' ) . ':</b></td><td>' 1076 . $this -> replace_links( $this -> decode_string( $obj -> cc[ 0 ] -> mailbox . '@' . $obj -> cc[ 0 ] -> host ) ) 1077 . '</td></tr>'; 1078 1079 $content .= '</table><br>'; 1080 1081 1082 $id = ( ( strtolower( $attachment[ 'type' ] ) == 'delivery-status' ) ? false : true ); 1083 if ( strtolower( $msg->structure[$msg_number]->parts[1]->parts[0]->subtype ) == 'plain' ) 1084 { 1085 $id = !$id; 1086 if ( $msg->structure[$msg_number]->parts[1]->parts[0]->encoding == 4 ) 1087 $msg->encoding[ $msg_number ][ $values ] = 'quoted-printable'; 1088 } 1089 1090 $body = $this->decodeBody( 1091 imap_fetchbody( 1092 $this->mbox, 1093 $msg_number, 1094 ( $attachment['part_in_msg'] + ( ( int ) $id ) ) . ".1", 1095 FT_UID 1096 ), 1097 $msg->encoding[ $msg_number ][ $values ], 1098 $msg->charset[ $msg_number ][ $values ] 1099 ); 1100 1101 if ( strtolower( $msg->structure[$msg_number]->parts[1]->parts[0]->subtype ) == 'plain' ) 1102 { 1103 $body = str_replace( array( '<', '>' ), array( ' #$<$# ', ' #$>$# ' ), $body ); 1104 $body = htmlentities( $body ); 1105 $body = $this -> replace_links( $body ); 1106 $body = str_replace( array( ' #$<$# ', ' #$>$# ' ), array( '<', '>' ), $body ); 1107 $body = '<pre>' . $body . '</pre>'; 1108 } 1109 1110 $content .= $body; 1111 break; 1112 } 1113 } 1114 } 1115 } 1116 } 1117 if ($is_alternative && !empty($alternative_content)) 1154 } 1155 $attachment = array(); 1156 1157 $msg_subtype = strtolower($structure->ctype_secondary); 1158 $disposition = strtolower($structure->disposition); 1159 1160 if(($msg_subtype == "html" || $msg_subtype == 'plain') && ($disposition != 'attachment')) 1118 1161 { 1119 $content .= $alternative_content; 1162 $content = $this->decodeMailPart($structure->body, $structure->ctype_parameters['charset']) ; 1163 1164 if(strtolower($msg_subtype) == 'plain') 1165 { 1166 $content = str_replace(array('<', '>'), array(' #$<$# ', ' #$>$# '), $content); 1167 $content = htmlentities($content); 1168 $content = $this -> replace_links($content); 1169 $content = str_replace(array(' #$<$# ', ' #$>$# '), array('<', '>'), $content); 1170 $content = '<pre>' . $content . '</pre>'; 1171 $return[ 'body' ] = $content; 1172 return $return; 1173 } 1120 1174 } 1121 if($file_type == "text/plain" && ($show_only_html && $msg_part == 1) || (!$show_only_html && $msg_part == 3)){ 1122 if(strtolower($msg->structure[$msg_number]->subtype) == "mixed" && $msg_part == 1) 1123 $content .= nl2br(imap_base64(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID))); 1124 else if(!strtolower($msg->structure[$msg_number]->subtype) == "mixed") 1125 $content .= nl2br(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID)); 1126 } 1127 } 1128 // Force message with flag Seen (imap_fetchbody not works correctly) 1175 1176 1177 1178 1179 break; 1180 case 'multipart': 1181 1182 $this-> builderMsgBody($structure , $content); 1183 1184 break; 1185 1186 case 'message': 1187 1188 if(!is_array($structure->parts)) 1189 { 1190 $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; 1191 $content .= '<pre>'.$this->decodeMailPart($structure->body, $structure->ctype_parameters['charset']).'</pre>'; 1192 $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; 1193 } 1194 else 1195 $this->builderMsgBody($structure , $content,true); 1196 1197 break; 1198 1199 default: 1200 1201 if(count($attachments) > 0) 1202 $content .= ''; 1203 else 1204 $content .= $this->functions->getLang('Message does not supported').'. '.$this->functions->getLang('Type').': '.$structure->ctype_primary.'/'.$structure->ctype_secondary; 1205 break; 1206 } 1207 1129 1208 $params = array('folder' => $msg_folder, "msgs_to_set" => $msg_number, "flag" => "seen"); 1130 1209 $this->set_messages_flag($params); 1131 $content = $this->process_embedded_images($msg,$msg_number,$content, $msg_folder); 1132 $content = $this->replace_special_characters($content); 1133 $return['body'] = $content; 1134 return $return; 1210 $content = $this->process_embedded_images($images,$msg_number,$content, $msg_folder); 1211 $content = $this->replace_special_characters($content); 1212 $this->replace_links($content); 1213 $return['body'] = &$content; 1214 1215 return $return; 1135 1216 } 1136 1217 … … 1255 1336 function decodeBody($body, $encoding, $charset=null) 1256 1337 { 1257 /** 1258 * replace e-mail by anchor. 1259 */ 1260 // HTML Filter 1261 //$body = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=# onclick=\"javascript:new_message('new_by_message', '\\2@\\3')\">\\2@\\3</a>", $body); 1262 //$body = str_replace("\r\n", "\n", $body); 1338 1263 1339 if ($encoding == 'quoted-printable') 1264 1340 { 1265 /*1266 1267 for($i=0;$i<256;$i++) {1268 $c1=dechex($i);1269 if(strlen($c1)==1){$c1="0".$c1;}1270 $c1="=".$c1;1271 $myqprinta[]=$c1;1272 $myqprintb[]=chr($i);1273 }1274 */1275 $body = str_replace($myqprinta,$myqprintb,($body));1276 1341 $body = quoted_printable_decode($body); 1277 while (ereg("=\n", $body)) 1278 { 1279 $body = ereg_replace ("=\n", '', $body); 1280 } 1281 } 1282 else if ($encoding == 'base64') 1283 { 1284 $body = base64_decode($body); 1285 } 1286 1287 // All other encodings are returned raw. 1288 if (strtolower($charset) == "utf-8") 1289 return utf8_decode($body); 1290 else 1291 return $body; 1292 } 1293 1294 function process_embedded_images($msg, $msgno, $body, $msg_folder) 1295 { 1296 if (count($msg->inline_id[$msgno]) > 0) 1297 { 1298 foreach ($msg->inline_id[$msgno] as $index => $cid) 1299 { 1300 $cid = eregi_replace("<", "", $cid); 1301 $cid = eregi_replace(">", "", $cid); 1302 $msg_part = $msg->pid[$msgno][$index]; 1303 //$body = eregi_replace("alt=\"\"", "", $body); 1304 $body = eregi_replace("<br/>", "", $body); 1305 $body = str_replace("src=\"cid:".$cid."\"", " src=\"./inc/show_embedded_attach.php?msg_folder=$msg_folder&msg_num=$msgno&msg_part=$msg_part\" ", $body); 1306 $body = str_replace("src='cid:".$cid."'", " src=\"./inc/show_embedded_attach.php?msg_folder=$msg_folder&msg_num=$msgno&msg_part=$msg_part\" ", $body); 1307 $body = str_replace("src=cid:".$cid, " src=\"./inc/show_embedded_attach.php?msg_folder=$msg_folder&msg_num=$msgno&msg_part=$msg_part\" ", $body); 1308 } 1309 } 1310 1311 return $body; 1342 1343 } 1344 else if ($encoding == 'base64') 1345 { 1346 $body = base64_decode($body); 1347 } 1348 // All other encodings are returned raw. 1349 if (strtolower($charset) == "utf-8") 1350 return utf8_decode($body); 1351 else 1352 return $body; 1353 } 1354 1355 function process_embedded_images($images, $msgno, $body, $msg_folder) 1356 { 1357 1358 foreach ($images as $image) 1359 { 1360 $image['cid'] = eregi_replace("<", "", $image['cid']); 1361 $image['cid'] = eregi_replace(">", "", $image['cid']); 1362 $body = eregi_replace("<br/>", "", $body); 1363 $body = str_replace("src=\"cid:".$image['cid']."\"", " src=\"./inc/show_embedded_attach.php?msg_folder=$msg_folder&msg_num=$msgno&msg_part=".$image['pid']."\" ", $body); 1364 $body = str_replace("src='cid:".$image['cid']."'", " src=\"./inc/show_embedded_attach.php?msg_folder=$msg_folder&msg_num=$msgno&msg_part=".$image['pid']."\" ", $body); 1365 $body = str_replace("src=cid:".$image['cid'], " src=\"./inc/show_embedded_attach.php?msg_folder=$msg_folder&msg_num=$msgno&msg_part=".$image['pid']."\" ", $body); 1366 } 1367 return $body; 1312 1368 } 1313 1369 … … 1315 1371 { 1316 1372 // Suspected TAGS! 1317 /*$tag_list = Array( 1318 'blink','object','meta', 1319 'html','link','frame', 1320 'iframe','layer','ilayer', 1321 'plaintext','script','style','img', 1322 'applet','embed','head', 1323 'frameset','xml','xmp'); 1324 */ 1325 1326 // Layout problem: Change html elements 1327 // with absolute position to relate position, CASE INSENSITIVE. 1328 $body = str_replace("\x00", '', $body); 1329 $body = @mb_eregi_replace("POSITION: ABSOLUTE;","",$body); 1330 1331 $tag_list = Array('head','blink','object','frame', 1332 'iframe','layer','ilayer','plaintext','script', 1333 'applet','embed','frameset','xml','xmp','style'); 1334 1335 $blocked_tags = array(); 1373 // $tag_list = Array('blink','object','meta','html','link','frame','iframe','layer','ilayer','plaintext','script','style','img','applet','embed','head','frameset','xml','xmp'); 1374 1375 // remove MS Office's proprietary tag 1376 //$body = mb_ereg_replace('<!\-\-\[if [^!]* mso .*\]>.*<!\[endif\]\-\->', '', $body); 1377 1378 // Layout problem: Change html elements 1379 // with absolute position to relate position, CASE INSENSITIVE. 1380 $body = @mb_eregi_replace("POSITION: ABSOLUTE;","",$body); 1381 1382 // tags to be removed doe to security reasons 1383 $tag_list = Array( 1384 'head','blink','object','frame','iframe', 1385 'layer','ilayer','plaintext','script', 1386 'applet','embed','frameset','xml','xmp' 1387 ); 1388 1336 1389 foreach($tag_list as $index => $tag) { 1337 $new_body = @mb_eregi_replace("<$tag", "<!--$tag", $body); 1338 if($body != $new_body) { 1339 $blocked_tags[] = $tag; 1340 } 1341 $body = @mb_eregi_replace("</$tag>", "</$tag-->", $new_body); 1342 } 1390 $body = @mb_eregi_replace("<$tag\\b[^>]*>(.*?)</$tag>", "<!-- TAG <$tag> Removed by ExpressoMail -->", $body); 1391 } 1392 1393 //try to wrap CSS code instead of remove STYLE tags 1394 require_once('../library/csstidy/class.csstidy.php'); 1395 $css = new csstidy(); 1396 $css->set_cfg('preserve_css', false); 1397 1398 $regs_found = array(); 1399 $tags_found = @mb_eregi("<style\b[^>]*>(.*?)</style>", $body, $regs_found); 1400 $wrapper_class = 'ExpressoCssWrapper'.time(); 1401 1402 foreach ($regs_found as $block_found) { 1403 $n_start = strpos($block_found, '>')+1; 1404 $n_length = strrpos($block_found, '<')-$n_start; 1405 $bf_innerHTML = substr($block_found, $n_start, $n_length); 1406 1407 $bf_innerHTML = mb_ereg_replace('<!--', '', $bf_innerHTML); 1408 $bf_innerHTML = mb_ereg_replace('-->', '', $bf_innerHTML); 1409 1410 $css->parse($bf_innerHTML); 1411 1412 $prefix = ".$wrapper_class "; 1413 foreach ($css->css[41] as $key => $value) { 1414 //explode multiple selectors per block 1415 $selectors = explode(',', $key); 1416 foreach ($selectors as $selector) { 1417 if (ereg('\*', $key)) { 1418 //skip selecto '*' 1419 continue; 1420 } 1421 1422 $selector = eregi_replace('[^#\.]*body.*', '', $selector); 1423 $css->css[41][$prefix.trim($selector)] = $value; 1424 } 1425 unset($css->css[41][$key]); 1426 } 1427 1428 $body = str_replace($block_found, '<style>'.$css->print->plain().'</style>', $body); 1429 } 1430 1431 1343 1432 // Malicious Code Remove 1344 1433 $dirtyCodePattern = "/(<([\w]+[\w0-9]*)(.*)on(mouse(move|over|down|up)|load|blur|change|error|click|dblclick|focus|key(down|up|press)|select)([\n\ ]*)=([\n\ ]*)[\"'][^>\"']*[\"']([^>]*)>)(.*)(<\/\\2>)?/misU"; 1345 1434 preg_match_all($dirtyCodePattern,$body,$rest,PREG_PATTERN_ORDER); 1346 foreach($rest[0] as $i => $val) 1435 foreach($rest[0] as $i => $val) { 1347 1436 if (!(preg_match("/javascript:window\.open\(\"([^'\"]*)\/index\.php\?menuaction=calendar\.uicalendar\.set_action\&cal_id=([^;'\"]+);?['\"]/i",$rest[1][$i]) && strtoupper($rest[4][$i]) == "CLICK" )) //Calendar events 1348 1437 $body = str_replace($rest[1][$i],"<".$rest[2][$i].$rest[3][$i].$rest[7][$i].">",$body); 1349 1350 $body = $this-> replace_links($body); 1351 1352 //Remoção de tags <span></span> para correção de erro no firefox 1353 $body = mb_eregi_replace("<span><span>","",$body); 1354 $body = mb_eregi_replace("</span></span>","",$body); 1355 //Correção para compatibilização com Outlook, ao visualizar a mensagem 1356 $body = mb_ereg_replace('<!--\[','<!-- [',$body); 1438 } 1439 1440 //$body = $this->replace_links($body); 1441 1442 //Remoção de tags <span></span> para correção de erro no firefox 1443 $body = mb_eregi_replace("<span><span>", "", $body); 1444 $body = mb_eregi_replace("</span></span>", "", $body); 1445 1446 //Correção para compatibilização com Outlook, ao visualizar a mensagem 1447 $body = mb_ereg_replace('<!--\[','<!-- [',$body); 1357 1448 $body = mb_ereg_replace('<!\[endif\]-->', '<![endif]-->', $body); 1358 $body = str_replace("\x00", '', $body); 1359 1360 return "<span>".$body; 1361 } 1362 1363 function replace_links( $body ) 1364 { 1365 // Domains and IPs addresses found in the text and which is not a link yet should be replaced by one. 1366 // See more informations in www.iana.org 1367 $octets = array( 1368 'first' => '(2[0-3][0-9]|1[0-9]{2}|[1-9][0-9]?)', 1369 'middle' => '(25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})', 1370 'last' => '(25[0-4]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)' 1371 ); 1372 1373 $ip = "\b{$octets[ 'first' ]}\.({$octets[ 'middle' ]}\.){2}{$octets[ 'last' ]}\b"; 1374 1375 $top_level_domains = '(\.(ac|ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|as|asia|at|au|aw|ax|az|' 1376 . 'ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bl|bm|bn|bo|br|bs|bt|bv|bw|by|bz|' 1377 . 'ca|cat|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cu|cv|cx|cy|cz|' 1378 . 'de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|' 1379 . 'ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|' 1380 . 'hk|hm|hn|hr|ht|hu|id|ie|il|im|in|info|int|io|iq|ir|is|it|je|jm|jo|jobs|jp|' 1381 . 'ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|' 1382 . 'ma|mc|md|me|mf|mg|mh|mil|mk|ml|mm|mn|mo|mobi|mp|mq|mr|ms|mt|mu|museum|' 1383 . 'mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|' 1384 . 'pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|ps|pt|pw|py|qa|re|ro|rs|ru|rw|' 1385 . 'sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|' 1386 . 'tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|travel|tt|tv|tw|tz|' 1387 . 'ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))+\b'; 1388 1389 $path = '(?>\/[\w\d\/\.\'\(\)\-\+~?!&#@$%|:;,*=_]+)?'; 1390 $port = '(?>:\d{2,5})?'; 1391 $domain = '(?>[\w\d_\-]+)'; 1392 $subdomain = "(?>{$domain}\.)*"; 1393 $protocol = '(?>(http|ftp)(s)?:\/\/)?'; 1394 $url = "(?>{$protocol}((?>{$subdomain}{$domain}{$top_level_domains}|{$ip}){$port}{$path}))"; 1449 1450 return "<div class=\"$wrapper_class\"><span>".$body.'</span></div>'; 1451 } 1452 1453 function replace_links(&$body) 1454 { 1455 // Domains and IPs addresses found in the text and which is not a link yet should be replaced by one. 1456 // See more informations in www.iana.org 1457 $octets = array( 1458 'first' => '(2[0-3][0-9]|1[0-9]{2}|[1-9][0-9]?)', 1459 'middle' => '(25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})', 1460 'last' => '(25[0-4]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)' 1461 ); 1462 1463 $ip = "\b{$octets[ 'first' ]}\.({$octets[ 'middle' ]}\.){2}{$octets[ 'last' ]}\b"; 1464 1465 $top_level_domains = '(\.(ac|ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|as|asia|at|au|aw|ax|az|' 1466 . 'ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bl|bm|bn|bo|br|bs|bt|bv|bw|by|bz|' 1467 . 'ca|cat|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cu|cv|cx|cy|cz|' 1468 . 'de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|' 1469 . 'ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|' 1470 . 'hk|hm|hn|hr|ht|hu|id|ie|il|im|in|info|int|io|iq|ir|is|it|je|jm|jo|jobs|jp|' 1471 . 'ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|' 1472 . 'ma|mc|md|me|mf|mg|mh|mil|mk|ml|mm|mn|mo|mobi|mp|mq|mr|ms|mt|mu|museum|' 1473 . 'mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|' 1474 . 'pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|ps|pt|pw|py|qa|re|ro|rs|ru|rw|' 1475 . 'sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|' 1476 . 'tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|travel|tt|tv|tw|tz|' 1477 . 'ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))+\b'; 1478 1479 $path = '(?>\/[\w\d\/\.\'\(\)\-\+~?!&#@$%|:;,*=_]+)?'; 1480 $port = '(?>:\d{2,5})?'; 1481 $domain = '(?>[\w\d_\-]+)'; 1482 $subdomain = "(?>{$domain}\.)*"; 1483 $protocol = '(?>(http|ftp)(s)?:\/\/)?'; 1484 $url = "(?>{$protocol}((?>{$subdomain}{$domain}{$top_level_domains}|{$ip}){$port}{$path}))"; 1395 1485 1396 1486 $pattern = "/(<\w[^>]+|[\/\"'@=])?{$url}/"; 1397 ini_set( 'pcre.backtrack_limit', 300000 );1398 1399 /* 1400 // PHP 5.3 1401 $replace = function( $matches ) 1402 { 1403 if ( $matches[ 1 ] ) 1404 return $matches[ 0 ]; 1405 1406 $url = ( $matches[ 2 ] ) ? $matches[ 2 ] : 'http'; 1407 $url .= "{$matches[ 3 ]}://{$matches[ 4 ]}"; 1408 return "<a href=\"{$url}\" target=\"_blank\">{$matches[ 4 ]}</a>"; 1409 }; 1410 $body = preg_replace_callback( $pattern, $replace, $body ); 1411 */1412 1413 // PHP 5.2.x - Remover assim que possível 1414 $body = preg_replace_callback( $pattern, 1415 create_function( 1416 '$matches', 1417 'if ( $matches[ 1 ] ) return $matches[ 0 ];' 1418 . '$url = ( $matches[ 2 ] ) ? $matches[ 2 ] : "http";'1419 . '$url .= "{$matches[ 3 ]}://{$matches[ 4 ]}";'1420 . 'return "<a href=\"{$url}\" target=\"_blank\">{$matches[ 4 ]}</a>";'1487 1488 ini_set( 'pcre.backtrack_limit', 300000 ); 1489 /* 1490 // PHP 5.3 1491 $replace = function( $matches ) 1492 { 1493 if ( $matches[ 1 ] ) 1494 return $matches[ 0 ]; 1495 1496 $url = ( $matches[ 2 ] ) ? $matches[ 2 ] : 'http'; 1497 $url .= "{$matches[ 3 ]}://{$matches[ 4 ]}"; 1498 return "<a href=\"{$url}\" target=\"_blank\">{$matches[ 4 ]}</a>"; 1499 }; 1500 $body = preg_replace_callback( $pattern, $replace, $body ); 1501 */ 1502 1503 // PHP 5.2.x - Remover assim que possível 1504 $body = preg_replace_callback( $pattern, 1505 create_function( 1506 '$matches', 1507 'if ( $matches[ 1 ] ) return $matches[ 0 ];' 1508 . '$url = ( $matches[ 2 ] ) ? $matches[ 2 ] : "http";' 1509 . '$url .= "{$matches[ 3 ]}://{$matches[ 4 ]}";' 1510 . 'return "<a href=\"{$url}\" target=\"_blank\">{$matches[ 4 ]}</a>";' 1421 1511 ), $body 1422 1512 ); 1423 ini_set( 'pcre.backtrack_limit', 100000 ); 1513 ini_set( 'pcre.backtrack_limit', 100000 ); 1514 1424 1515 // E-mail address in the text should create a new e-mail on ExpressoMail 1425 $pattern = '/( |<|<|>)([A-Za-z0-9\.~?\/_=#\-]*@[A-Za-z0-9\.~?\/_=#\-]*)( |>|>|<)/im'; 1516 $pattern = '/( |<|<|>)([A-Za-z0-9\.~?\/_=#\-]*@[A-Za-z0-9\.~?\/_=#\-]*)( |>|>|<)/im'; 1426 1517 $replacement = '$1<a href="mailto:$2">$2</a>$3'; 1427 1518 $body = preg_replace( $pattern, $replacement, $body ); … … 1533 1624 } 1534 1625 1535 function get_thumbs($msg, $msg_number, $msg_folder) 1536 { 1537 $thumbs_array = array(); 1538 $i = 0; 1539 foreach ($msg->file_type[$msg_number] as $index => $file_type) 1540 { 1541 $file_type = strtolower($file_type); 1542 if(strtolower($msg->encoding[$msg_number][$index]) == 'base64') { 1543 if (($file_type == 'image/jpeg') || ($file_type == 'image/pjpeg') || ($file_type == 'image/gif') || ($file_type == 'image/png')) { 1544 $img = "<IMG id='".$msg_folder.";;".$msg_number.";;".$i.";;".$msg->pid[$msg_number][$index].";;".$msg->encoding[$msg_number][$index]."' style='border:2px solid #fde7bc;padding:5px' title='".$this->functions->getLang("Click here do view (+)")."'src=./inc/show_thumbs.php?file_type=".$file_type."&msg_num=".$msg_number."&msg_folder=".$msg_folder."&msg_part=".$msg->pid[$msg_number][$index].">"; 1545 $href = "<a onMouseDown='save_image(event,this,\"".$file_type."\")' href='#".$msg_folder.";;".$msg_number.";;".$i.";;".$msg->pid[$msg_number][$index].";;".$msg->encoding[$msg_number][$index]."' onClick=\"window.open('./inc/show_img.php?msg_num=".$msg_number."&msg_folder=".$msg_folder."&msg_part=".$msg->pid[$msg_number][$index]."','mywindow','width=700,height=600,scrollbars=yes');\">". $img ."</a>"; 1546 $thumbs_array[] = $href; 1547 } 1548 $i++; 1549 } 1550 } 1551 return $thumbs_array; 1626 function get_thumbs($images, $msg_number, $msg_folder) 1627 { 1628 1629 $thumbs_array = array(); 1630 $i = 0; 1631 1632 foreach ($images as $x => $image) 1633 { 1634 if($x && $x == 'names') 1635 continue; 1636 1637 $img = "<IMG id='".$msg_folder.";;".$msg_number.";;".$i.";;".$image['pid'].";;".$image['encoding']."' style='border:2px solid #fde7bc;padding:5px' title='".$this->functions->getLang("Click here do view (+)")."'src=./inc/show_thumbs.php?&msg_num=".$msg_number."&msg_folder=".$msg_folder."&msg_part=".$image['pid'].">"; 1638 $href = "<a onMouseDown='save_image(event,this,\"".$image['type']."\")' href='#".$msg_folder.";;".$msg_number.";;".$i.";;".$image['pid'].";;".$image['encoding']."' onClick=\"window.open('./inc/show_img.php?msg_num=".$msg_number."&msg_folder=".$msg_folder."&msg_part=".$image['pid']."','mywindow','width=700,height=600,scrollbars=yes');\">". $img ."</a>"; 1639 $thumbs_array[] = $href; 1640 $i++; 1641 1642 } 1643 return $thumbs_array; 1552 1644 } 1553 1645 … … 1569 1661 function delete_msgs($params) 1570 1662 { 1571 1663 1572 1664 $folder = $params['folder']; 1573 1665 $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO-8859-1"); 1574 1666 $msgs_number = explode(",",$params['msgs_number']); 1575 1667 $border_ID = $params['border_ID']; 1576 1668 1577 1669 $return = array(); 1578 1670 1579 1671 if ($params['get_previous_msg']){ 1580 1672 $return['previous_msg'] = $this->get_info_previous_msg($params); … … 1583 1675 } 1584 1676 1585 //$mbox_stream = $this->open_mbox($folder); 1677 //$mbox_stream = $this->open_mbox($folder); 1586 1678 $mbox_stream = @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())))); 1587 1679 1588 1680 foreach ($msgs_number as $msg_number) 1589 1681 { … … 1591 1683 $return['msgs_number'][] = $msg_number; 1592 1684 } 1593 1685 1594 1686 $return['folder'] = $folder; 1595 1687 $return['border_ID'] = $border_ID; 1596 1688 1597 1689 if($mbox_stream) 1598 1690 imap_close($mbox_stream, CL_EXPUNGE); … … 2339 2431 } 2340 2432 } 2341 function buildEmbeddedImages(&$mail,$msg_uid,&$forwarding_attachments) 2342 { 2343 // Build CID for embedded Images!!! 2344 $pattern = '/src="([^"]*?show_embedded_attach.php\?msg_folder=(.+)?&(amp;)?msg_num=(.+)?&(amp;)?msg_part=(.+)?)"/isU'; 2345 $cid_imgs = ''; 2346 preg_match_all($pattern,$mail->Body,$cid_imgs,PREG_PATTERN_ORDER); 2347 $cid_array = array(); 2348 foreach($cid_imgs[6] as $j => $val){ 2349 if ( !array_key_exists($cid_imgs[4][$j].$val, $cid_array) ) 2350 { 2351 $cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36); 2352 } 2353 $cid = $cid_array[$cid_imgs[4][$j].$val]; 2354 $mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body); 2355 2356 if ($msg_uid != $cid_imgs[4][$j]) // The image is not in the same mail? 2357 { 2358 $fileContent = $this->get_forwarding_attachment($cid_imgs[2][$j], $cid_imgs[4][$j], $cid_imgs[6][$j], 'base64'); 2359 //prototype: get_forwarding_attachment ( folder, msg number, part, encoding) 2360 $fileName = "image_".($j).".jpg"; 2361 $fileCode = "base64"; 2362 $fileType = "image/jpg"; 2363 $file_attached[0] = $cid_imgs[2][$j]; 2364 $file_attached[1] = $cid_imgs[4][$j]; 2365 $file_attached[2] = $fileName; 2366 $file_attached[3] = $cid_imgs[6][$j]; 2367 $file_attached[4] = 'base64'; 2368 $file_attached[5] = strlen($fileContent); //Size of file 2369 $return_forward[] = $file_attached; 2370 2371 $attachment_ = unserialize(rawurldecode($forwarding_attachments[$cid_imgs[6][$j]-2])); 2372 if ($file_attached[3] == $attachment_[3]) 2373 unset($forwarding_attachments[$cid_imgs[6][$j]-2]); 2374 } 2375 else 2376 { 2377 $attach_img = $forwarding_attachments[$cid_imgs[6][$j]-2]; 2378 $file_description = unserialize(rawurldecode($attach_img)); 2379 if (is_array($file_description)) 2380 foreach($file_description as $i => $descriptor){ 2381 $file_description[$i] = eregi_replace('\'*\'','',$descriptor); 2382 } 2383 $fileContent = $this->get_forwarding_attachment($file_description[0], $msg_uid, $file_description[3], 'base64'); 2384 $fileName = $file_description[2]; 2385 $fileCode = $file_description[4]; 2386 $fileType = $this->get_file_type($file_description[2]); 2387 unset($forwarding_attachments[$cid_imgs[6][$j]-2]); 2388 if (!empty($file_description)) 2389 { 2390 $file_description[5] = strlen($fileContent); //Size of file 2391 $return_forward[] = $file_description; 2392 } 2393 } 2394 $tempDir = ini_get("session.save_path"); 2395 $file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat"; 2396 $f = fopen($tempDir.'/'.$file,"w"); 2397 fputs($f,$fileContent); 2398 fclose($f); 2399 if ($fileContent) 2400 $mail->AddEmbeddedImage($tempDir.'/'.$file, $cid, $fileName, $fileCode, $fileType); 2401 //else 2402 // return "Error loading image attachment content"; 2403 2404 } 2405 return $return_forward; 2406 } 2433 2434 function buildEmbeddedImages(&$mail,$msg_uid,&$forwarding_attachments) 2435 { 2436 //Build CID for embedded Images!!! 2437 $pattern = '/src="([^"]*?show_embedded_attach.php\?msg_folder=(.+)?&(amp;)?msg_num=(.+)?&(amp;)?msg_part=(.+)?)"/isU'; 2438 $cid_imgs = ''; 2439 preg_match_all($pattern,$mail->Body,$cid_imgs,PREG_PATTERN_ORDER); 2440 $cid_array = array(); 2441 2442 foreach($cid_imgs[6] as $j => $val){ 2443 if ( !array_key_exists($cid_imgs[4][$j].$val, $cid_array) ) 2444 { 2445 $cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36); 2446 } 2447 $cid = $cid_array[$cid_imgs[4][$j].$val]; 2448 2449 $mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body); 2450 2451 $count = strlen($cid_imgs[6][$j]); 2452 $position = substr($cid_imgs[6][$j], 2, $count); 2453 $position--; 2454 2455 $attach_img = $forwarding_attachments[$position]; 2456 $file_description = unserialize(rawurldecode($attach_img)); 2457 2458 if (is_array($file_description)) 2459 foreach($file_description as $i => $descriptor) 2460 $file_description[$i] = eregi_replace('\'*\'','',$descriptor); 2461 2462 // The image is not in the same mail? 2463 if ($msg_uid != $cid_imgs[4][$j]) 2464 { 2465 $fileContent = $this->get_forwarding_attachment($cid_imgs[2][$j], $cid_imgs[4][$j], $cid_imgs[6][$j], 'base64'); 2466 $fileName = ($msg_uid != 'undefined') ? "image_".($j).".jpg" : $file_description[2]; 2467 $fileCode = "base64"; 2468 $fileType = "image/jpg"; 2469 $file_attached[0] = $cid_imgs[2][$j]; 2470 $file_attached[1] = $cid_imgs[4][$j]; 2471 $file_attached[2] = $fileName; 2472 $file_attached[3] = '0.'.($j+1); 2473 $file_attached[4] = 'base64'; 2474 $file_attached[5] = strlen($fileContent); //Size of file 2475 $file_attached[6] = $cid_imgs[6][$j]; 2476 $return_forward[] = $file_attached; 2477 2478 if ($file_attached[3] == $file_description[3] || $msg_uid == 'undefined') 2479 unset($forwarding_attachments[$position]); 2480 2481 } 2482 else 2483 { 2484 $fileContent = $this->get_forwarding_attachment($file_description[0], $msg_uid, $file_description[3], 'base64'); 2485 $fileName = $file_description[2]; 2486 $fileCode = $file_description[4]; 2487 $file_description[3] = '0.'.($j+1); 2488 $file_description[6] = $cid_imgs[6][$j]; 2489 $fileType = $this->get_file_type($file_description[2]); 2490 unset($forwarding_attachments[$position]); 2491 if (!empty($file_description)) 2492 { 2493 $file_description[5] = strlen($fileContent); //Size of file 2494 $return_forward[] = $file_description; 2495 } 2496 } 2497 $tempDir = '/tmp'; 2498 $file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat"; 2499 $f = fopen($tempDir.'/'.$file,"w"); 2500 fputs($f,$fileContent); 2501 fclose($f); 2502 2503 if ($fileContent) 2504 $mail->AddEmbeddedImage($tempDir.'/'.$file, $cid, $fileName, $fileCode, $fileType); 2505 } 2506 2507 return $return_forward; 2508 } 2407 2509 function add_recipients_cert($full_address) 2408 2510 { … … 2472 2574 function get_forwarding_attachment($msg_folder, $msg_number, $msg_part, $encoding) 2473 2575 { 2474 $mbox_stream = $this->open_mbox(utf8_decode(urldecode($msg_folder))); 2475 $fileContent = imap_fetchbody($mbox_stream, $msg_number, $msg_part, FT_UID); 2476 if($encoding == 'base64') 2477 # The function imap_base64 adds a new line 2478 # at ASCII text, with CRLF line terminators. 2479 # So is being exchanged for base64_decode. 2480 # 2481 #$fileContent = imap_base64($fileContent); 2482 $fileContent = base64_decode($fileContent); 2483 else if($encoding == 'quoted-printable') 2484 $fileContent = quoted_printable_decode($fileContent); 2485 return $fileContent; 2576 include_once $_SESSION['rootPath'].'/expressoMail1_2/inc/class.attachment.inc.php'; 2577 $attachment = new attachment(); 2578 $attachment->setStructureFromMail($msg_folder, $msg_number); 2579 return $attachment->getAttachment($msg_part); 2486 2580 } 2487 2581 … … 2728 2822 { 2729 2823 2730 2824 include_once("class.phpmailer.php"); 2731 2825 $mail = new PHPMailer(); 2732 2826 include_once("class.db_functions.inc.php"); 2733 $toaddress = $params['input_to'];2734 $ccaddress = $params['input_cc'];2827 $toaddress = $params['input_to']; 2828 $ccaddress = $params['input_cc']; 2735 2829 $ccoaddress = $params['input_cco']; 2736 2737 2738 $subject = $params['input_subject'];2739 $msg_uid = $params['msg_id'];2740 $body = $params['body'];2741 $body = str_replace("%nbsp;"," ", 2830 $return_receipt = $params['input_return_receipt']; 2831 $is_important = $params['input_important_message']; 2832 $subject = $params['input_subject']; 2833 $msg_uid = $params['msg_id']; 2834 $body = $params['body']; 2835 $body = str_replace("%nbsp;"," ",$body); 2742 2836 $body = preg_replace("/\n/"," ",$body); 2743 2837 $body = preg_replace("/\r/","",$body); 2744 2838 $forwarding_attachments = $params['forwarding_attachments']; 2745 $attachments = $params['FILES'];2839 $attachments = $params['FILES']; 2746 2840 $return_files = $params['FILES']; 2747 2841 2842 2748 2843 $folder = $params['folder']; 2749 $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1"); 2844 $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1"); 2750 2845 // Fix problem with cyrus delimiter changes. 2751 // Dots in names: enabled/disabled. 2846 // Dots in names: enabled/disabled. 2752 2847 $folder = @eregi_replace("INBOX/", "INBOX".$this->imap_delimiter, $folder); 2753 2848 $folder = @eregi_replace("INBOX.", "INBOX".$this->imap_delimiter, $folder); 2754 2849 // End Fix. 2755 if(strtoupper($folder) == 'INBOX/DRAFTS') $mail->SaveMessageAsDraft = $folder; 2756 2850 2757 2851 $mail->SaveMessageInFolder = $folder; 2758 2852 $mail->SMTPDebug = false; 2759 2853 2760 2854 $mail->IsSMTP(); 2761 2855 $mail->Host = $_SESSION['phpgw_info']['expressomail']['email_server']['smtpServer']; … … 2763 2857 $mail->From = $_SESSION['phpgw_info']['expressomail']['user']['email']; 2764 2858 $mail->FromName = $_SESSION['phpgw_info']['expressomail']['user']['fullname']; 2765 2859 2766 2860 $mail->Sender = $mail->From; 2767 2861 $mail->SenderName = $mail->FromName; 2768 2862 $mail->FromName = $_SESSION['phpgw_info']['expressomail']['user']['fullname']; 2769 2863 $mail->From = $_SESSION['phpgw_info']['expressomail']['user']['email']; 2770 2864 2771 2865 $this->add_recipients("to", $toaddress, &$mail); 2772 2866 $this->add_recipients("cc", $ccaddress, &$mail); 2773 $this->add_recipients("cco", $ccoaddress, &$mail);2774 $mail->AddReplyTo($replytoaddress);2775 2867 $mail->Subject = $subject; 2776 2868 $mail->IsHTML(true); 2777 2869 $mail->Body = $body; 2778 2779 // Important message 2780 if($is_important) 2781 $mail->isImportant(); 2782 2783 // Disposition-Notification-To 2784 if ($return_receipt) 2785 $mail->ConfirmReadingTo = $_SESSION['phpgw_info']['expressomail']['user']['email']; 2786 2787 $return_forward = $this->buildEmbeddedImages($mail,$msg_uid,$forwarding_attachments); 2788 2789 // Build Forwarding Attachments!!! 2790 if (count($forwarding_attachments) > 0) 2791 { 2792 foreach($forwarding_attachments as $forwarding_attachment) 2793 { 2794 $file_description = unserialize(rawurldecode($forwarding_attachment)); 2795 $tmp = array_values($file_description); 2796 foreach($file_description as $i => $descriptor){ 2797 $tmp[$i] = eregi_replace('\'*\'','',$descriptor); 2798 } 2799 $file_description = $tmp; 2800 2801 $fileContent = $this->get_forwarding_attachment($file_description[0], $file_description[1], $file_description[3],$file_description[4]); 2802 $fileName = $file_description[2]; 2803 2804 $file_description[5] = strlen($fileContent); //Size of file 2805 $return_forward[] = $file_description; 2806 2807 $mail->AddStringAttachment($fileContent, $fileName, $file_description[4], $this->get_file_type($file_description[2])); 2808 } 2809 } 2810 2870 2871 $return_forward = $this->buildEmbeddedImages($mail,$msg_uid,$forwarding_attachments); 2872 $imagesParts = array(); 2873 2874 foreach ($return_forward as $value) 2875 $imagesParts[$value[6]] = $value[3]; 2876 2877 //Build Forwarding Attachments!!! 2878 foreach($forwarding_attachments as $forwarding_attachment) 2879 { 2880 $file_description = unserialize(rawurldecode($forwarding_attachment)); 2881 2882 $file_description = array_values($file_description); 2883 foreach($file_description as $i => $descriptor){ 2884 $file_description[$i] = eregi_replace('\'*\'','',$descriptor); 2885 } 2886 $fileContent = $this->get_forwarding_attachment($file_description[0], $file_description[1], $file_description[3],$file_description[4]); 2887 $fileName = $file_description[2]; 2888 2889 $file_description[5] = strlen($fileContent); //Size of file 2890 $return_forward[] = $file_description; 2891 2892 $mail->AddStringAttachment($fileContent, $fileName, $file_description[4], $this->get_file_type($file_description[2])); 2893 } 2894 2811 2895 if ((count($return_forward) > 0) && (count($return_files) > 0)) 2896 { 2812 2897 $return_files = array_merge_recursive($return_forward,$return_files); 2813 else 2814 if (count($return_files) < 1) 2815 $return_files = $return_forward; 2816 2817 // Build Uploading Attachments!!! 2898 } 2899 else if (count($return_files) < 1) 2900 { 2901 $return_files = $return_forward; 2902 } 2903 2904 //Build Uploading Attachments!!! 2818 2905 $sizeof_attachments = count($attachments); 2819 2906 if ($sizeof_attachments) 2820 foreach ($attachments as $numb => $attach){ 2821 if ($numb == ($sizeof_attachments-1) && $params['insertImg'] == 'true'){ // Auto-resize image 2907 { 2908 foreach ($attachments as $numb => $attach) 2909 { 2910 if ($numb == ($sizeof_attachments-1) && $params['insertImg'] == 'true') 2911 { // Auto-resize image 2822 2912 list($width, $height,$image_type) = getimagesize($attach['tmp_name']); 2823 2913 switch ($image_type) 2824 2914 { 2825 // Do not corrupt animated gif 2826 //case 1: $image_big = imagecreatefromgif($attach['tmp_name']);break; 2827 case 2: $image_big = imagecreatefromjpeg($attach['tmp_name']); break; 2828 case 3: $image_big = imagecreatefrompng($attach['tmp_name']); break; 2829 case 6: 2830 require_once("gd_functions.php"); 2831 $image_big = imagecreatefrombmp($attach['tmp_name']); break; 2832 default: 2833 $mail->AddAttachment($attach['tmp_name'], $attach['name'], "base64", $this->get_file_type($attach['name'])); 2834 break; 2915 // Do not corrupt animated gif 2916 //case 1: $image_big = imagecreatefromgif($attach['tmp_name']);break; 2917 case 2: 2918 $image_big = imagecreatefromjpeg($attach['tmp_name']); break; 2919 case 3: 2920 $image_big = imagecreatefrompng($attach['tmp_name']); break; 2921 case 6: 2922 require_once("gd_functions.php"); 2923 $image_big = imagecreatefrombmp($attach['tmp_name']); break; 2924 default: 2925 $mail->AddAttachment($attach['tmp_name'], $attach['name'], "base64", $this->get_file_type($attach['name'])); 2926 break; 2835 2927 } 2836 2928 header('Content-type: image/jpeg'); 2837 2929 $max_resolution = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['image_size']; 2838 2930 $max_resolution = ($max_resolution==""?'65536':$max_resolution); 2839 if ($width < $max_resolution && $height < $max_resolution){ 2931 if ($width < $max_resolution && $height < $max_resolution) 2932 { 2840 2933 $new_width = $width; 2841 2934 $new_height = $height; 2842 2935 } 2843 else if ($width > $max_resolution){ 2936 else if ($width > $max_resolution) 2937 { 2844 2938 $new_width = $max_resolution; 2845 2939 $new_height = $height*($new_width/$width); 2846 2940 } 2847 else { 2941 else 2942 { 2848 2943 $new_height = $max_resolution; 2849 2944 $new_width = $width*($new_height/$height); … … 2851 2946 $image_new = imagecreatetruecolor($new_width, $new_height); 2852 2947 imagecopyresampled($image_new, $image_big, 0, 0, 0, 0, $new_width, $new_height, $width, $height); 2853 $tmpDir = ini_get("session.save_path"); 2948 $tmpDir = '/tmp'; 2949 2950 // $tmpDir = ini_get("session.save_path"); 2854 2951 $_file = "/cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].".dat"; 2855 2952 imagejpeg($image_new,$tmpDir.$_file, 85); … … 2858 2955 else 2859 2956 $mail->AddAttachment($attach['tmp_name'], $attach['name'], "base64", $this->get_file_type($attach['name'])); 2860 // optional name 2861 } 2862 2863 2864 2865 2957 2958 } 2959 } 2960 2866 2961 if(!empty($mail->AltBody)) 2867 $mail->ContentType = "multipart/alternative";2962 $mail->ContentType = "multipart/alternative"; 2868 2963 2869 2964 $mail->error_count = 0; // reset errors 2870 2965 $mail->SetMessageType(); 2871 2966 $header = $mail->CreateHeader(); 2872 $body = $mail->CreateBody();2873 2874 $mbox_stream = $this->open_mbox($folder); 2875 $new_header = str_replace("\n", "\r\n", $header);2876 $new_body = str_replace("\n", "\r\n", $body);2967 $body = $mail->CreateBody(); 2968 2969 $mbox_stream = $this->open_mbox($folder); 2970 $new_header = str_replace("\n", "\r\n", $header); 2971 $new_body = str_replace("\n", "\r\n", $body); 2877 2972 $return['append'] = imap_append($mbox_stream, "{".$this->imap_server.":".$this->imap_port."}".$folder, $new_header . $new_body, "\\Seen \\Draft"); 2878 $status = imap_status($mbox_stream, "{".$this->imap_server.":".$this->imap_port."}".$folder, SA_UIDNEXT);2973 $status = imap_status($mbox_stream, "{".$this->imap_server.":".$this->imap_port."}".$folder, SA_UIDNEXT); 2879 2974 $return['msg_no'] = $status->uidnext - 1; 2880 2975 $return['folder_id'] = $folder; 2976 $return['imagesParts'] = $imagesParts; 2881 2977 2882 2978 if($mbox_stream) 2883 2979 imap_close($mbox_stream); 2980 2884 2981 if (is_array($return_files)) 2885 foreach ($return_files as $index => $_attachment) { 2886 if (array_key_exists("name",$_attachment)){ 2887 unset($return_files[$index]); 2888 $return_files[$index] = $_attachment['name']."_SIZE_".$return_files[$index][1] = $_attachment['size']; 2889 } 2890 else 2982 { 2983 foreach ($return_files as $index => $_attachment) 2891 2984 { 2892 unset($return_files[$index]); 2893 $return_files[$index] = $_attachment[2]."_SIZE_". $return_files[$index][1] = $_attachment[5]; 2894 } 2895 } 2896 2985 if (array_key_exists("name", $_attachment)) 2986 { 2987 //unset($return_files[$index]); 2988 $return_files[$index] = $_attachment['name']."_SIZE_".$return_files[$index][1] = $_attachment['size']; 2989 } 2990 else 2991 { 2992 //unset($return_files[$index]); 2993 $return_files[$index] = $_attachment[2]."_SIZE_". $return_files[$index][1] = $_attachment[5]; 2994 } 2995 } 2996 } 2997 2897 2998 $return['files'] = serialize($return_files); 2898 2999 $return["subject"] = $subject; 2899 2900 if (!$return['append']) {3000 3001 if (!$return['append']) 2901 3002 $return['append'] = imap_last_error(); 2902 $return['has_error'] = true;2903 }2904 3003 2905 3004 return $return; … … 3850 3949 } 3851 3950 3852 function spam($params) 3853 { 3854 $is_spam = $params['spam']; 3855 $folder = $params['folder']; 3856 $mbox_stream = $this->open_mbox($folder); 3951 function spam($params) 3952 { 3953 3954 $mbox_stream = $this->open_mbox($params['folder']); 3857 3955 $msgs_number = explode(',',$params['msgs_number']); 3858 3956 3859 foreach($msgs_number as $msg_number) { 3957 $user = Array(); 3958 3959 if(substr($params['folder'], 0, 4) == 'user') 3960 { 3961 $ldapObject = new ldap_functions(); 3962 3963 $folderArray = Array(); 3964 $folderArray = explode($this->imap_delimiter, $params['folder']); 3965 3966 $user['name'] = $folderArray[1]; 3967 $user['email'] = $ldapObject->getMailByUid($user['name']); 3968 3969 } 3970 else 3971 { 3972 $user['name'] = $this->username; 3973 $user['email'] = $_SESSION['phpgw_info']['expressomail']['user']['email']; 3974 } 3975 3976 foreach($msgs_number as $msg_number) 3977 { 3860 3978 $imap_msg_number = imap_msgno($mbox_stream, $msg_number); 3861 3979 $header = imap_fetchheader($mbox_stream, $imap_msg_number); 3862 3980 $body = imap_body($mbox_stream, $imap_msg_number); 3863 3981 $msg = $header . $body; 3864 $email = $_SESSION['phpgw_info']['expressomail']['user']['email']; 3865 $username = $this->username; 3866 strtok($email, '@'); 3982 strtok($user['email'], '@'); 3867 3983 $domain = strtok('@'); 3984 3985 3868 3986 3869 3987 //Encontrar a assinatura do dspam no cabecalho … … 3880 3998 3881 3999 // Seleciona qual comando a ser executado 3882 switch($ is_spam){4000 switch($params['spam']){ 3883 4001 case 'true': $cmd = $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_command_for_spam']; break; 3884 4002 case 'false': $cmd = $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_command_for_ham']; break; 3885 4003 } 3886 4004 4005 3887 4006 $tags = array('##EMAIL##', '##USERNAME##', '##DOMAIN##', '##SIGNATURE##', '##MSGID##'); 3888 $cmd = str_replace($tags, array($email, $username, $domain, $signature, $msg_id), $cmd); 4007 $cmd = str_replace($tags, array($user['email'], $user['name'], $domain, $signature, $msg_id), $cmd); 4008 3889 4009 system($cmd); 3890 4010 } 4011 3891 4012 imap_close($mbox_stream); 3892 4013 return false; -
sandbox/2.2.0.2/expressoMail1_2/inc/show_embedded_attach.php
r3018 r4416 1 1 <?php 2 /* 3 * Requieres 4 */ 5 require_once '../../header.session.inc.php'; 6 require_once $_SESSION['rootPath'].'/expressoMail1_2/inc/class.attachment.inc.php'; 7 //------------------------// 2 8 3 require_once '../../header.session.inc.php'; 9 /* 10 * Get variables 11 */ 12 $msgFolder = $_GET['msg_folder']; 13 $msgNumber = $_GET['msg_num']; 14 $embeddedPart = $_GET['msg_part']; 15 //-------------------------------------// 4 16 5 $username = $_SESSION['phpgw_info']['expressomail']['user']['userid']; 6 $password = $_SESSION['phpgw_info']['expressomail']['user']['passwd']; 7 $imap_server = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer']; 8 $imap_port = $_SESSION['phpgw_info']['expressomail']['email_server']['imapPort']; 9 $msg_folder = $_GET['msg_folder']; 10 $msg_folder = mb_convert_encoding($msg_folder,"UTF7-IMAP", mb_detect_encoding($msg_folder, "UTF-8, ISO-8859-1", true)); 11 if ($_SESSION['phpgw_info']['expressomail']['email_server']['imapTLSEncryption'] == 'yes') 12 { 13 $imap_options = '/tls/novalidate-cert'; 14 } 15 else 16 { 17 $imap_options = '/notls/novalidate-cert'; 18 } 19 20 if (is_array($_SESSION['phpgw_info']['expressomail']['email_server'])) 21 { 22 $mb = imap_open("{".$imap_server.":".$imap_port.$imap_options."}".$msg_folder, $username, $password); 23 24 if ($mb) 25 { 26 $msgno = $_GET['msg_num']; 27 $embedded_part = $_GET['msg_part']; 28 29 $embedded_body = imap_fetchbody($mb, $msgno, $embedded_part, FT_UID); 30 31 header("Content-Type: image/jpeg"); 32 header("Content-Disposition: inline"); 33 echo imap_base64($embedded_body); 34 } 35 } 17 18 /* 19 * Main 20 */ 21 $attachmentObj = new attachment(); 22 $attachmentObj->setStructureFromMail($msgFolder, $msgNumber); 23 $fileContent = $attachmentObj->getAttachment($embeddedPart); 24 25 header("Content-Type: image/jpeg"); 26 header("Content-Disposition: inline"); 27 28 echo $fileContent; 29 //------------------------------------------// 30 36 31 ?> -
sandbox/2.2.0.2/expressoMail1_2/inc/show_img.php
r3163 r4416 1 1 <?php 2 /* 3 * Requieres 4 */ 5 require_once '../../header.session.inc.php'; 6 require_once $_SESSION['rootPath'].'/expressoMail1_2/inc/class.attachment.inc.php'; 7 //------------------------// 2 8 3 require_once '../../header.session.inc.php'; 4 header("Content-Type: image/jpeg"); 5 if($_GET['msg_num'] && $_GET['msg_part'] && $_GET['msg_folder']) { 6 $username = $_SESSION['phpgw_info']['expressomail']['user']['userid']; 7 $password = $_SESSION['phpgw_info']['expressomail']['user']['passwd']; 8 $imap_server = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer']; 9 $imap_port = $_SESSION['phpgw_info']['expressomail']['email_server']['imapPort']; 10 if ($_SESSION['phpgw_info']['expressomail']['email_server']['imapTLSEncryption'] == 'yes') 11 { 12 $imap_options = '/tls/novalidate-cert'; 13 } 14 else 15 { 16 $imap_options = '/notls/novalidate-cert'; 17 } 18 19 $msg_num = $_GET['msg_num']; 20 $msg_part = $_GET['msg_part']; 21 $msg_folder = $_GET['msg_folder']; 22 $msg_folder = mb_convert_encoding($msg_folder,"UTF7-IMAP", mb_detect_encoding($msg_folder, "UTF-8, ISO-8859-1", true)); 23 24 $mb = imap_open("{".$imap_server.":".$imap_port.$imap_options."}".$msg_folder, $username, $password); 25 26 $image_mail = imap_fetchbody($mb, $msg_num, $msg_part, FT_UID); 9 /* 10 * Get variables 11 */ 12 $fileType = $_GET['file_type']; 13 $msgFolder = $_GET['msg_folder']; 14 $msgNumber = $_GET['msg_num']; 15 $part = $_GET['msg_part']; 16 //-------------------------------------// 27 17 28 header("Content-Disposition: inline"); 29 $image = imap_base64($image_mail); 30 echo $image; 31 } 32 else{ 33 $expires = 60*60*24*30; /* 30 days */ 34 header("Cache-Control: maxage=".$expires); 35 header("Pragma: public"); 36 header("Expires: ".gmdate('D, d M Y H:i:s', time()+$expires)); 37 if($_SESSION['phpgw_info']['expressomail']['contact_photo']){ 38 $data = $_SESSION['phpgw_info']['expressomail']['contact_photo']; 18 /* 19 * Main 20 */ 21 header("Content-Type: image/jpeg"); 39 22 40 if($data) { 23 if($_GET['msg_num'] != null && $_GET['msg_part'] != null && $_GET['msg_folder'] != null) 24 { 25 $attachmentObj = new attachment(); 26 $attachmentObj->setStructureFromMail($msgFolder, $msgNumber); 27 $fileContent = $attachmentObj->getAttachment($part); 28 header("Content-Disposition: inline"); 41 29 42 $photo = imagecreatefromstring($data[0]); 43 if($photo){ 44 $width = imagesx($photo); 45 $height = imagesy($photo); 46 $twidth = 60; 47 $theight = 80; 48 $small_photo = imagecreatetruecolor ($twidth, $theight); 49 imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height); 50 imagejpeg($small_photo,'',100); 51 unset($_SESSION['phpgw_info']['expressomail']['contact_photo']); 52 } 53 } 54 } 55 else 56 readfile("./../../contactcenter/templates/default/images/photo_celepar.png"); 57 } 30 echo $fileContent; 31 } 32 else if($_SESSION['phpgw_info']['expressomail']['contact_photo']) 33 { 34 $data = $_SESSION['phpgw_info']['expressomail']['contact_photo']; 35 36 if($data) 37 { 38 $photo = imagecreatefromstring($data[0]); 39 if($photo) 40 { 41 $width = imagesx($photo); 42 $height = imagesy($photo); 43 $twidth = 60; 44 $theight = 80; 45 $small_photo = imagecreatetruecolor ($twidth, $theight); 46 imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height); 47 imagejpeg($small_photo,'',100); 48 unset($_SESSION['phpgw_info']['expressomail']['contact_photo']); 49 } 50 } 51 } 52 else 53 readfile("./../../contactcenter/templates/default/images/photo_celepar.png"); 54 //------------------------------------------// 55 58 56 ?> -
sandbox/2.2.0.2/expressoMail1_2/inc/show_thumbs.php
r3018 r4416 1 1 <?php 2 /* 3 * Requieres 4 */ 5 require_once '../../header.session.inc.php'; 6 require_once $_SESSION['rootPath'].'/expressoMail1_2/inc/class.attachment.inc.php'; 7 //------------------------// 2 8 3 require_once '../../header.session.inc.php'; 4 $username = $_SESSION['phpgw_info']['expressomail']['user']['userid']; 5 $password = $_SESSION['phpgw_info']['expressomail']['user']['passwd']; 6 $imap_server = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer']; 7 $imap_port = $_SESSION['phpgw_info']['expressomail']['email_server']['imapPort']; 8 if ($_SESSION['phpgw_info']['expressomail']['email_server']['imapTLSEncryption'] == 'yes') 9 { 10 $imap_options = '/tls/novalidate-cert'; 11 } 12 else 13 { 14 $imap_options = '/notls/novalidate-cert'; 15 } 9 /* 10 * Get variables 11 */ 12 $fileType = $_GET['file_type']; 13 $msgFolder = $_GET['msg_folder']; 14 $msgNumber = $_GET['msg_num']; 15 $part = $_GET['msg_part']; 16 //-------------------------------------// 16 17 17 $file_type = $_GET['file_type'];18 $msg_num = $_GET['msg_num'];19 $msg_part = $_GET['msg_part'];20 $msg_folder = $_GET['msg_folder'];21 $msg_folder = mb_convert_encoding($msg_folder,"UTF7-IMAP", mb_detect_encoding($msg_folder, "UTF-8, ISO-8859-1", true));22 $mb = imap_open("{".$imap_server.":".$imap_port.$imap_options."}".$msg_folder, $username, $password);23 18 24 $image_mail = imap_fetchbody($mb, $msg_num, $msg_part, FT_UID); 25 $image = imap_base64($image_mail); 26 $pic = @imagecreatefromstring ($image); 27 if($pic !== FALSE) { 28 header("Content-Type: ".$file_type); 29 header("Content-Disposition: inline"); 30 $width = imagesx($pic); 31 $height = imagesy($pic); 32 $twidth = 160; # width of the thumb 160 pixel 33 $theight = $twidth * $height / $width; # calculate height 34 $theight = $theight < 1 ? 1 : $theight; 35 $thumb = imagecreatetruecolor ($twidth, $theight); 36 imagecopyresized($thumb, $pic, 0, 0, 0, 0,$twidth, $theight, $width, $height); # resize image into thumb 37 imagejpeg($thumb,"",75); # Thumbnail as JPEG 38 } 19 /* 20 * Main 21 */ 22 $attachmentObj = new attachment(); 23 $attachmentObj->setStructureFromMail($msgFolder, $msgNumber); 24 $fileContent = $attachmentObj->getAttachment($part); 25 $pic = @imagecreatefromstring($fileContent); 26 if($pic !== FALSE) 27 { 28 header("Content-Type: ".$fileType); 29 header("Content-Disposition: inline"); 30 $width = imagesx($pic); 31 $height = imagesy($pic); 32 $twidth = 160; # width of the thumb 160 pixel 33 $theight = $twidth * $height / $width; # calculate height 34 $theight = $theight < 1 ? 1 : $theight; 35 $thumb = imagecreatetruecolor ($twidth, $theight); 36 imagecopyresized($thumb, $pic, 0, 0, 0, 0,$twidth, $theight, $width, $height); # resize image into thumb 37 imagejpeg($thumb,"",75); # Thumbnail as JPEG 38 } 39 //------------------------------------------// 39 40 ?> -
sandbox/2.2.0.2/expressoMail1_2/js/common_functions.js
r4413 r4416 224 224 div_attachment = document.getElementById("id_div_attachment"); 225 225 var params = ''; 226 226 227 227 if (div_attachment == null){ 228 228 var div_attachment = document.createElement("DIV"); … … 230 230 document.body.appendChild(div_attachment); 231 231 } 232 if(new_file_name) 233 params = "&newfilename="+escape(new_file_name); 232 if(new_file_name) { 233 var extension = new_file_name.substring(new_file_name.length-4, new_file_name.length); 234 if (extension == ".eml") // if the extension is .eml 235 params = "&newFilename="+new_file_name; //name_of_message.eml 236 else // when more than one message 237 params = "&newFilename="+escape(new_file_name); //mensagens.zip 238 } 234 239 if(encoding) 235 240 params += "&encoding="+encoding; 236 241 237 div_attachment.innerHTML="<iframe style='display:none;width:0;height:0' name='attachment' src='inc/gotodownload.php?msg_folder="+msg_folder+"&msg_number="+msg_number+"&idx_file="+idx_file+"&msg_part="+msg_part+params+"'></iframe>"; 242 div_attachment.innerHTML="<iframe style='display:none;width:0;height:0' name='attachment' src='inc/get_archive.php?msgFolder="+msg_folder+"&msgNumber="+msg_number+"&idx_file="+idx_file+"&indexPart="+msg_part+params+"'></iframe>"; 243 238 244 } 239 245
Note: See TracChangeset
for help on using the changeset viewer.