Changeset 4774


Ignore:
Timestamp:
07/15/11 16:59:09 (13 years ago)
Author:
airton
Message:

Ticket #2131 - Problema de codificacao de caracteres na visualizacao de nome de anexos no Expresso

File:
1 edited

Legend:

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

    r4729 r4774  
    242242                        if($currentIndex == $soughtIndex) 
    243243                        { 
    244                             $info['pid'] = $currentIndex; 
    245                             $info['name'] = addslashes($part->d_parameters['filename']); 
    246                             $info['encoding'] = $part->headers['content-transfer-encoding']; 
    247                             $info['fsize'] = mb_strlen($part->body, $part->headers['content-transfer-encoding']); 
     244                                                        $this->_pushAttachmentsInfo($part,$info,$currentIndex); 
    248245                            break; 
    249246                        } 
     
    252249            } 
    253250        }else if($soughtIndex == '0') 
    254         { 
    255             $info['pid'] = '0'; 
    256             $info['name'] = $structure->d_parameters['filename']; 
    257             $info['encoding'] = $structure->headers['content-transfer-encoding']; 
    258             $info['fsize'] = mb_strlen($structure->body, $structure->headers['content-transfer-encoding']); 
    259         } 
     251                        $this->_pushAttachmentsInfo($structure,$info); 
    260252    } 
    261253 
     
    284276                        if(!$part->headers['content-transfer-encoding']) //Caso não esteja especificado a codificação  
    285277                                    $part->headers['content-transfer-encoding'] = mb_detect_encoding ($part->body,array('BASE64','Quoted-Printable','7bit','8bit','ASCII'));  
    286                                 if($part->headers['content-transfer-encoding'] === FALSE) //Caso a tentativa de achar a codificação retorne FALSE  
    287                                                         $part->headers['content-transfer-encoding'] = 'binary';  
    288                                                 if($part->headers['content-transfer-encoding'] === 'ASCII') //Caso a codificação retorne ascii especifica como base64  
     278                                                if($part->headers['content-transfer-encoding'] === ('ASCII' || false)) //Caso a codificação retorne ascii ou false especifica como base64 
    289279                                                        $part->headers['content-transfer-encoding'] = 'base64'; 
    290280                                                 
    291                                                 if($part->d_parameters['filename']) 
    292                         { 
    293                             $definition['pid'] = $pIndex.'.'.$index; 
    294                             $definition['name'] = addslashes($part->d_parameters['filename']); 
    295                             $definition['encoding'] = $part->headers['content-transfer-encoding']; 
    296                             $definition['fsize'] = mb_strlen($part->body, $part->headers['content-transfer-encoding']); 
    297  
    298                             array_push($attachments, $definition); 
    299                         } 
    300                         else if($part->ctype_parameters['name']) 
    301                         { 
    302                             $definition['pid'] = $pIndex.'.'.$index; 
    303                             $definition['name'] = addslashes($part->ctype_parameters['name']); 
    304                             $definition['encoding'] = $part->headers['content-transfer-encoding']; 
    305                             $definition['fsize'] = mb_strlen($part->body, $part->headers['content-transfer-encoding']); 
    306  
    307                             array_push($attachments, $definition); 
    308                         } 
    309                         else if(strtolower($part->ctype_primary) == 'text' &&  strtolower($part->ctype_secondary) == 'calendar') 
    310                         { 
    311                             $definition['pid'] = $pIndex.'.'.$index; 
    312                             $definition['name'] = 'calendar.ics'; 
    313                             $definition['encoding'] = $part->headers['content-transfer-encoding']; 
    314                             $definition['fsize'] = mb_strlen($part->body, $part->headers['content-transfer-encoding']); 
    315  
    316                             array_push($attachments, $definition); 
    317                         } 
     281                                                        $this->_pushAttachmentsInfo($part,$attachments,$pIndex.'.'.$index); 
    318282                      
    319283                    } 
     
    322286        } 
    323287        else 
    324         { 
    325             if($structure->d_parameters['filename']) 
    326             { 
    327                 $definition['pid'] = '0'; 
    328                 $definition['name'] = addslashes($structure->d_parameters['filename']); 
    329                 $definition['encoding'] = $structure->headers['content-transfer-encoding']; 
    330                 $definition['fsize'] = mb_strlen($structure->body, $structure->headers['content-transfer-encoding']); 
    331  
    332                 array_push($attachments, $definition); 
    333             } 
    334             else if($structure->ctype_parameters['name']) 
    335             { 
    336                 $definition['pid'] = '0'; 
    337                 $definition['name'] = addslashes($structure->ctype_parameters['name']); 
    338                 $definition['encoding'] = $structure->headers['content-transfer-encoding']; 
    339                 $definition['fsize'] = mb_strlen($structure->body, $structure->headers['content-transfer-encoding']); 
    340  
    341                 array_push($attachments, $definition); 
    342             } 
    343             else if(strtolower($structure->ctype_primary) == 'text' &&  strtolower($structure->ctype_secondary) == 'calendar') 
    344             { 
    345                 $definition['pid'] = '0'; 
    346                 $definition['name'] = 'calendar.ics'; 
    347                 $definition['encoding'] = $structure->headers['content-transfer-encoding']; 
    348                 $definition['fsize'] = mb_strlen($structure->body, $structure->headers['content-transfer-encoding']); 
    349  
    350                 array_push($attachments, $definition); 
    351              } 
    352         } 
    353  
    354     } 
    355  
     288                        $this->_pushAttachmentsInfo($structure,$attachments); 
     289 
     290    } 
     291 
     292         
     293        /**  
     294        * Write in $$attachments, array with the information of attachment  
     295        * @param <type> $structure  
     296        * @param <type> $attachments  
     297        * @param <type> $pIndex  
     298        */  
     299        private function _pushAttachmentsInfo(&$structure, &$attachments, $pIndex = '0')  
     300        {  
     301                        $name = false;  
     302                        if($structure->d_parameters['filename']) $name = $structure->d_parameters['filename'];  
     303                        else if($structure->ctype_parameters['name']) $name = $structure->ctype_parameters['name'];  
     304                        else if(strtolower($structure->ctype_primary) == 'text' &&  strtolower($structure->ctype_secondary) == 'calendar') $name = 'calendar.ics';  
     305                  
     306                        if($name)  
     307                        {  
     308                            $codificao =  mb_detect_encoding($name.'x', 'UTF-8, ISO-8859-1');  
     309                            if($codificao == 'UTF-8') $name = utf8_decode($name);  
     310                              
     311                            $definition['pid'] = $pIndex;  
     312                            $definition['name'] = addslashes(mb_convert_encoding($name, "ISO-8859-1"));  
     313                            $definition['encoding'] = $structure->headers['content-transfer-encoding'];  
     314                            $definition['fsize'] = mb_strlen($structure->body, $structure->headers['content-transfer-encoding']);  
     315                  
     316                            array_push($attachments, $definition);  
     317                        }      
     318        } 
     319         
     320         
     321         
     322         
     323         
     324         
    356325    /** 
    357326     * Write in $images, array with the information of Embedded Images 
Note: See TracChangeset for help on using the changeset viewer.