Ignore:
Timestamp:
09/05/07 11:18:58 (17 years ago)
Author:
niltonneto
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/inc/class.exporteml.inc.php

    r51 r64  
    4444         
    4545        // create EML File. 
    46         function createFileEml($sEMLData, $tempDir)  
     46        function createFileEml($sEMLData, $tempDir, $id)  
    4747        { 
    48                 $file = "email_".md5(microtime()).".eml"; 
     48                if($id){ 
     49                        $header = imap_headerinfo($this->mbox_stream, imap_msgno($this->mbox_stream, $id), 80, 255); 
     50                        $subject = $this->decode_subject($header->fetchsubject); 
     51                        $subject = ereg_replace('/', '\'', $subject);                    
     52                        $file = $subject."_".$id.".eml"; 
     53                }        
     54                else{ 
     55                        $file = "email_".md5(microtime()).".eml"; 
     56                } 
    4957                $f = fopen($tempDir.'/'.$file,"w"); 
    5058                 
     
    5866        } 
    5967         
    60         function createFileZip($files, $tempDir){ 
    61                  
     68        function createFileZip($files, $tempDir){                
    6269                $tmp_zip_filename =     "email_".md5(microtime()).".zip"; 
    6370                $command = "cd " . $tempDir . "; nice zip -m " . $tmp_zip_filename . " " . $files;                       
     
    8592                        $body           = $this-> getBody($nMsgs);                       
    8693                        $sEMLData       = $this -> parseEml($header, $body); 
    87                         $fileName       = $this -> CreateFileEml($sEMLData, $tempDir); 
     94                        $fileName       = $this -> CreateFileEml($sEMLData, $tempDir,$nMsgs); 
    8895                        if(!$fileName)  { 
    8996                                $error = True;                                   
     
    9198                        } 
    9299                        else 
    93                                 $fileNames .= $fileName.' ';                     
     100                                $fileNames .= "\"".$fileName."\" ";                      
    94101                         
    95102                } 
     
    124131                for($i = 0; $i < count($array_ids); $i++) { 
    125132                                 
    126                         $header         = $this-> getHeader($array_ids[$i]);                                                                     
     133                        $header         = $this-> getHeader($array_ids[$i]);                                                                                     
    127134                        $body           = $this-> getBody($array_ids[$i]);                       
    128                         $sEMLData       = $this -> parseEml($header, $body); 
    129                         $fileName       = $this -> CreateFileEml($sEMLData, $tempDir); 
     135                        $sEMLData       = $this -> parseEml($header, $body);                     
     136                        $fileName       = $this -> CreateFileEml($sEMLData, $tempDir, $array_ids[$i]); 
    130137                         
    131138                        if(!$fileName)  { 
     
    134141                        } 
    135142                        else 
    136                                 $fileNames .= $fileName.' ';                     
     143                                $fileNames .= "\"".$fileName."\" ";                      
    137144                         
    138145                } 
     
    241248        } 
    242249 
     250        function decode_subject($string){ 
     251                if ((strpos(strtolower($string), '=?iso-8859-1') !== false)  
     252                        || (strpos(strtolower($string), '=?windows-1252') !== false)){ 
     253                        $elements = imap_mime_header_decode($string); 
     254                        foreach ($elements as $el) 
     255                                $return .= $el->text; 
     256                } 
     257                else if (strpos(strtolower($string), '=?utf-8') !== false) { 
     258                        $elements = imap_mime_header_decode($string); 
     259                        foreach ($elements as $el){ 
     260                                $charset = $el->charset; 
     261                                $text    = $el->text; 
     262                                if(!strcasecmp($charset, "utf-8") || 
     263                                !strcasecmp($charset, "utf-7")) { 
     264                                $text = iconv($charset, "ISO-8859-1", $text); 
     265                        } 
     266                        $return .= $text; 
     267                        } 
     268                } 
     269                else 
     270                        $return = $string; 
     271 
     272                return $this->remove_accents($return);           
     273        } 
    243274} 
    244275// END CLASS 
Note: See TracChangeset for help on using the changeset viewer.