Changeset 1384


Ignore:
Timestamp:
09/01/09 14:59:15 (15 years ago)
Author:
niltonneto
Message:

Ticket #528 - Adição de novo método para correção desse ticket.

Location:
trunk/expressoMail1_2/inc
Files:
2 edited

Legend:

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

    r1059 r1384  
    11<?php 
    22        class Functions{ 
    3                  
    4                  
    53                function CallVoipConnect($params){ 
    64                        $fromNumber = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['telephone_number']; 
     
    112110                        return $_SESSION['phpgw_info']['user']['preferences']['expressoMail']; 
    113111                } 
    114         } 
     112                // Unicode Conversor: convert everything from UTF-8 into an NCR[Numeric Character Reference] 
     113                function utf8_to_ncr($content)  { 
     114            $result = "";             
     115            while ($strlen = mb_strlen($content)) { 
     116                $c = mb_substr($content, 0, 1, "UTF-8"); 
     117                $h = ord($c{0});    
     118                    if ($h <= 0x7F || $h < 0xC2) { 
     119                        $result .= $c; 
     120                    } 
     121                        else if ($h <= 0xDF) { 
     122                        $h = ($h & 0x1F) << 6 | (ord($c{1}) & 0x3F); 
     123                        $result .= "&#" . $h . ";"; 
     124                    } else if ($h <= 0xEF) { 
     125                        $h = ($h & 0x0F) << 12 | (ord($c{1}) & 0x3F) << 6 | (ord($c{2}) & 0x3F); 
     126                        $result .= "&#" . $h . ";"; 
     127                    } else if ($h <= 0xF4) { 
     128                        $h = ($h & 0x0F) << 18 | (ord($c{1}) & 0x3F) << 12 | (ord($c{2}) & 0x3F) << 6 | (ord($c{3}) & 0x3F); 
     129                        $result .= "&#" . $h . ";"; 
     130                    }                 
     131                $content = mb_substr( $content, 1, $strlen, "UTF-8"); 
     132            } 
     133            return mb_convert_encoding($result,"UTF-8"); 
     134        } 
     135    }    
    115136?> 
  • trunk/expressoMail1_2/inc/class.imap_functions.inc.php

    r1382 r1384  
    162162                $from = $header->from; 
    163163                $head_array['from'] = array(); 
    164                 $head_array['from']['name'] = $this->decode_string( trim( $header -> fetchfrom ) ); 
     164                $head_array['from']['name'] = $this->decode_string($from[0]->personal); 
    165165                $head_array['from']['email'] = $this->decode_string($from[0]->mailbox) . "@" . $from[0]->host; 
    166166                if(!$head_array['from']['name']) 
     
    185185        function decode_string($string) 
    186186        {        
     187                 
    187188                if ((strpos(strtolower($string), '=?iso-8859-1') !== false) || (strpos(strtolower($string), '=?windows-1252') !== false)) 
    188189                { 
     
    190191                        foreach ($tmp as $tmp1) 
    191192                                $return .= $this->htmlspecialchars_encode($tmp1->text); 
     193                                 
    192194                        return $return; 
    193195                } 
    194196                else if (strpos(strtolower($string), '=?utf-8') !== false) 
    195197                { 
    196                         $elements = imap_mime_header_decode($string); 
    197                         for($i = 0;$i < count($elements);$i++) { 
    198                                 $charset = $elements[$i]->charset; 
    199                                 $text =$elements[$i]->text; 
    200                                 if(!strcasecmp($charset, "utf-8") || 
    201                                 !strcasecmp($charset, "utf-7")) { 
    202                                 $text = iconv($charset, "ISO-8859-1", $text); 
    203                         } 
    204                                 $decoded .= $this->htmlspecialchars_encode($text); 
    205                         } 
     198                        $elements = imap_mime_header_decode($string);                    
     199                        for($i = 0;$i < count($elements);$i++) { 
     200                                $charset = strtolower($elements[$i]->charset); 
     201                                $text =$elements[$i]->text; 
     202                                if(!strcasecmp($charset, "utf-8") || 
     203                                !strcasecmp($charset, "utf-7")) { 
     204                                $decoded .= $this->functions->utf8_to_ncr($text); 
     205                        } 
     206                                else 
     207                                        $decoded .= $this->htmlspecialchars_encode(iconv($charset, "iso-8859-1", $text)); 
     208                        } 
    206209                        return $decoded; 
    207210                } 
     
    503506                $from = $header->from; 
    504507                $return['from'] = array(); 
    505                 $tmp = imap_mime_header_decode($from[0]->personal); 
    506                 $return['from']['name'] = $this->decode_string($tmp[0]->text); 
     508                $return['from']['name'] = $this->decode_string($from[0]->personal); 
    507509                $return['from']['email'] = $this->decode_string($from[0]->mailbox . "@" . $from[0]->host); 
    508510                if ($return['from']['name']) 
     
    518520                // Sender attribute 
    519521                $sender = $header->sender; 
    520                 $return['sender'] = array(); 
    521                 $tmp = imap_mime_header_decode($sender[0]->personal); 
    522                 $return['sender']['name'] = $this->decode_string($tmp[0]->text); 
     522                $return['sender'] = array();             
     523                $return['sender']['name'] = $this->decode_string($sender[0]->personal); 
    523524                $return['sender']['email'] = $this->decode_string($sender[0]->mailbox . "@" . $sender[0]->host); 
    524525                if ($return['sender']['name']) 
Note: See TracChangeset for help on using the changeset viewer.