Ignore:
Timestamp:
05/16/11 11:44:10 (13 years ago)
Author:
airton
Message:

Ticket #1887 - Redefinicao do parser de email - Todas as adequacoes feitas no parser.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.2.0.2/expressoMail1_2/inc/class.exporteml.inc.php

    r4348 r4416  
    304304                $body           = $this-> getBody($id_number); 
    305305                 
    306                 $file = "source_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].".eml"; 
     306                $file = "source_".$_SESSION[ 'phpgw_session' ][ 'session_id' ]."_".time().".php"; //source_[sessao]_[timestamp].php 
    307307                $f = fopen($tempDir.'/'.$file,"w"); 
    308308                fputs($f,$header ."\r\n\r\n". $body); 
     
    351351                $return_attachments = array(); 
    352352 
    353                 $id_number = $params['num_msg']; 
     353                $id_number = $params['num_msg'];                 
    354354                $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                 
    357360                $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"); 
    359362                $this->connectImap(); 
    360363 
     
    366369                        if($i && $i == 'names') 
    367370                                continue; 
    368  
    369                         $fileName = $_SESSION[ 'phpgw_session' ][ 'session_id' ].md5($attachment['name'].microtime()); 
     371                        $fileNameReal = $this->remove_accents($attachment['name']); 
    370372                        $ContentType = $this->getFileType($fileNameReal); 
    371                         $f = fopen($tempDir . '/'.$fileName,"wb"); 
     373                        $fileName = $fileNameReal . ".php"; 
     374                        $f = fopen($tempDir . '/'.$tempSubDir.'/'.$fileName,"wb"); 
    372375                        if(!$f) 
    373                                 return false; 
     376                                return $tempDir . '/'.$tempSubDir.'/'.$fileName;                         
    374377 
    375378                        $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                         
    377387                        if($attachment['encoding'] == 'base64') { 
    378                                 $headers=imap_base64($fileContent); 
     388                                $headers.=" imap_base64('".$fileContent."');?>"; 
    379389                        } 
    380390                        else if($attachment['encoding'] == 'quoted_printable_decode') { 
    381                                 $headers=quoted_printable_decode($fileContent); 
     391                                $headers.=" quoted_printable_decode('".$fileContent."');?>"; 
    382392                        } 
    383393                        else { 
    384                                 $headers=$fileContent; 
    385                         } 
    386  
     394                                $headers.=" '".$fileContent."';?>"; 
     395                        } 
     396                         
    387397                        fputs($f,$headers); 
    388398 
    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'])); 
    391400                        fclose($f); 
    392401                } 
Note: See TracChangeset for help on using the changeset viewer.