Changeset 3289


Ignore:
Timestamp:
09/24/10 16:20:17 (14 years ago)
Author:
rafaelraymundo
Message:

Ticket #1275 - anexos com caracteres especiais convertidos para underline.

Location:
branches/2.2
Files:
4 edited

Legend:

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

    r3273 r3289  
    9191        function createFileZip($files, $tempDir){                
    9292                $tmp_zip_filename = "email_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].".zip"; 
    93                 $command = "cd " . escapeshellarg($tempDir) . " && nice zip -m9 " . escapeshellarg($tmp_zip_filename) . " " .  escapeshellcmd($files); 
     93                 
     94                if (!empty($files)) 
     95                { 
     96                    if (is_array($files)) 
     97                    { 
     98                        for ($i=0; $i < count($files); $i++) 
     99                        { 
     100                            $files[$i] = escapeshellarg($files[$i]); 
     101                        } 
     102                        $files = implode(' ', $files); 
     103                    } 
     104                    else 
     105                    { 
     106                        $files = escapeshellcmd($files); 
     107                    } 
     108                } 
     109                 
     110                $command = "cd " . escapeshellarg($tempDir) . " && nice zip -m9 " . escapeshellarg($tmp_zip_filename) . " " .  $files; 
    94111                if(!exec($command)) { 
    95                         $command = "cd " .  escapeshellarg($tempDir) . " && rm ".escapeshellcmd($files)." ". escapeshellarg($tmp_zip_filename); 
     112                        $command = "cd " .  escapeshellarg($tempDir) . " && rm ".$files." ". escapeshellarg($tmp_zip_filename); 
    96113                        exec($command); 
    97114                        return null; 
     
    464481                $imap_attachment = new imap_attachment(); 
    465482                $attachments = $imap_attachment->download_attachment($this->mbox_stream, $id_number); 
    466                 foreach($attachments as $i => $attachment){ 
    467                         if($i && $i == 'names') 
    468                                 continue; 
    469                                                                                                                                                  
     483                 
     484                $fileNames = Array(); 
    470485                         
    471                         $fileName = $this->remove_accents($attachment['name']); 
     486                for ($i = 0; $i < count($attachments); $i++) 
     487                { 
     488                   $attachments[$i]['name'] = $this->remove_accents($attachments[$i]['name']); 
     489                   $fileNames[$i] = $attachments[$i]['name']; 
     490                } 
     491 
     492                for ($i = 0; $i < count($attachments); $i++) 
     493                { 
     494                        $fileName = $attachments[$i]['name']; 
     495                        $result = array_keys($fileNames, $fileName); 
     496 
     497                        // Detecta duplicatas 
     498                        if (count($result) > 1) 
     499                        { 
     500                            for ($j = 1; $j < count($result); $j++) 
     501                            { 
     502                                $replacement = '('.$j.')$0'; 
     503                                if (preg_match('/\.\w{2,4}$/', $fileName)) 
     504                                { 
     505                                    $fileNames[$result[$j]] = preg_replace('/\.\w{2,4}$/', $replacement, $fileName); 
     506                                } 
     507                                else 
     508                                { 
     509                                    $fileNames[$result[$j]] .= "($j)"; 
     510                                } 
     511                                $attachments[$result[$j]]['name'] = $fileNames[$result[$j]]; 
     512                            } 
     513                        } 
     514                        // Fim detecta duplicatas 
     515 
    472516                        $f = fopen($tempDir . '/'.$tempSubDir.'/'.$fileName,"wb"); 
    473517                        if(!$f) 
    474518                                return False;                    
    475519                                                 
    476                         $fileNames .= "'".$fileName."' "; 
    477                         $fileContent = imap_fetchbody($this->mbox_stream, $id_number,$attachment['pid'], FT_UID); 
    478                         if($attachment['encoding'] == 'base64') 
     520                        $fileContent = imap_fetchbody($this->mbox_stream, $id_number,$attachments[$i]['pid'], FT_UID); 
     521                        if($attachments[$i]['encoding'] == 'base64') 
    479522                                fputs($f,imap_base64($fileContent)); 
    480523                        else             
     
    487530                $nameFileZip = ''; 
    488531                 
    489                 if($fileNames) { 
     532                if(!empty($fileNames)) { 
    490533                        $nameFileZip = $this -> createFileZip($fileNames, $tempDir . '/'.$tempSubDir);                                           
    491534                        if($nameFileZip) 
  • branches/2.2/expressoMail1_2/inc/class.imap_attachment.inc.php

    r1059 r3289  
    5353                $msg->fetch_structure($msgno); 
    5454                $array_parts_attachments = array();              
    55                 $array_parts_attachments['names'] = ''; 
     55                //$array_parts_attachments['names'] = ''; 
    5656                 
    5757                //print_r($msg->fname[$msgno]); 
     
    6767                                $array_parts_attachments[$i]['name'] = $array_parts_attachments[$i]['name'] ? $array_parts_attachments[$i]['name'] : "attachment.bin"; 
    6868                                $array_parts_attachments[$i]['encoding'] = $msg->encoding[$msgno][$index]; 
    69                                 $array_parts_attachments['names'] .= $array_parts_attachments[$i]['name'] . ', '; 
     69                                //$array_parts_attachments['names'] .= $array_parts_attachments[$i]['name'] . ', '; 
    7070                                $array_parts_attachments[$i]['fsize'] = $msg->fsize[$msgno][$index]; 
    7171                                $i++; 
    7272                        } 
    7373                } 
    74                 $array_parts_attachments['names'] = substr($array_parts_attachments['names'],0,(strlen($array_parts_attachments['names']) - 2)); 
     74                //$array_parts_attachments['names'] = substr($array_parts_attachments['names'],0,(strlen($array_parts_attachments['names']) - 2)); 
    7575                return $array_parts_attachments; 
    7676        } 
  • branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php

    r3271 r3289  
    35603560        { 
    35613561                $array_parts_attachments = array(); 
    3562                 $array_parts_attachments['names'] = ''; 
     3562                //$array_parts_attachments['names'] = ''; 
    35633563                include_once("class.imap_attachment.inc.php"); 
    35643564                $imap_attachment = new imap_attachment(); 
     
    35733573                                $array_parts_attachments[$i]['name'] = $array_parts_attachments[$i]['name'] ? $array_parts_attachments[$i]['name'] : "attachment.bin"; 
    35743574                                $array_parts_attachments[$i]['encoding'] = $msg->encoding[$msgno][$index]; 
    3575                                 $array_parts_attachments['names'] .= $array_parts_attachments[$i]['name'] . ', '; 
     3575                                //$array_parts_attachments['names'] .= $array_parts_attachments[$i]['name'] . ', '; 
    35763576                                $array_parts_attachments[$i]['fsize'] = $msg->fsize[$msgno][$index]; 
    35773577                                $i++; 
    35783578                        } 
    35793579                } 
    3580                 $array_parts_attachments['names'] = substr($array_parts_attachments['names'],0,(strlen($array_parts_attachments['names']) - 2)); 
     3580                //$array_parts_attachments['names'] = substr($array_parts_attachments['names'],0,(strlen($array_parts_attachments['names']) - 2)); 
    35813581                return $array_parts_attachments; 
    35823582        } 
  • branches/2.2/mobile/inc/class.ui_mobilemail.inc.php

    r3248 r3289  
    203203                        $p->set_var('reply_all', "index.php?menuaction=mobile.ui_mobilemail.new_msg&msg_number=$msg_number&msg_folder=$msg_folder&reply_all=true"); 
    204204                        $p->set_var('forward', "index.php?menuaction=mobile.ui_mobilemail.new_msg&msg_number=$msg_number&msg_folder=$msg_folder&forward=true"); 
    205                         if (!empty($msg['attachments']) && !empty($msg['attachments']['names'])) 
     205                        if (!empty($msg['attachments'])) 
    206206                        { 
    207207                                $attachs = "<br>".lang("This message has the follow attachments:")."<br>"; 
Note: See TracChangeset for help on using the changeset viewer.