Ignore:
Timestamp:
07/08/10 17:52:20 (14 years ago)
Author:
amuller
Message:

Ticket #1135 - Aplicando alterações do branches 2.0 no branches 2.2

Location:
branches/2.2/expressoMail1_2/inc
Files:
13 edited

Legend:

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

    r1352 r3018  
    6262                        if(!$aux){ 
    6363                                // Caso de erro, grava dentro da variável errstr; 
    64                                 $this->errstr = "O arquivo não foi criado"; 
     64                                $this->errstr = "Error: file not created";  
     65                                return $this->errstr;  
    6566                        } 
    6667                        // Mata a variavel; 
     
    7172                        if(!$aux){ 
    7273                                // Caso de erro, grava dentro da variavel errstr; 
    73                                 $this->errstr = "O arquivo não foi ativado"; 
     74                                $this->errstr = "Error: error to activate file";  
     75                                return $this->errstr;  
    7476                        } 
    7577                        else{ 
     
    8486                $this->SieveS->close(); 
    8587                         
    86                 if($this->rules){                
     88                if($this->rules) 
    8789                        return $this->rules; 
    88                 }else{ 
    89                         return $this->errstr; 
    90                 } 
    9190                         
    9291        } 
     
    9998         
    10099                $var_decode = rawurldecode($params['arfilter']); 
     100                $var_decode = preg_replace('/\n\./', '.', $var_decode); 
    101101                 
    102102                $narray  = explode("_end_",$var_decode); 
  • branches/2.2/expressoMail1_2/inc/class.SieveS.inc.php

    r1149 r3018  
    178178 
    179179                //Verifica a conexao 
    180                 if(!$this->socket){ 
     180                if(!is_resource($this->socket)){  
    181181                        $this->errstr = "listscripts: sem conexão para o servidor $this->host"; 
    182182                        return false; 
     
    187187         
    188188                $said = $this->read(); 
    189                 while (!preg_match("/^OK/",$said) && !preg_match("/^NO/",$said)) { 
     189                while (is_resource($this->socket) && (!preg_match("/^OK/",$said) && !preg_match("/^NO/",$said))) {  
    190190         
    191191                    // Cyrus v1 script lines look like '"script*"' with the  
  • branches/2.2/expressoMail1_2/inc/class.db_functions.inc.php

    r1992 r3018  
    11<?php 
    2 define('PHPGW_INCLUDE_ROOT','../');      
    3 define('PHPGW_API_INC','../phpgwapi/inc');       
    4 include_once(PHPGW_API_INC.'/class.db.inc.php'); 
     2if(!isset($_SESSION['phpgw_info']['expressomail']['server']['db_name'])) {  
     3        include_once('../header.inc.php');  
     4        $_SESSION['phpgw_info']['expressomail']['server']['db_name'] = $GLOBALS['phpgw_info']['server']['db_name'];   
     5        $_SESSION['phpgw_info']['expressomail']['server']['db_host'] = $GLOBALS['phpgw_info']['server']['db_host'];  
     6        $_SESSION['phpgw_info']['expressomail']['server']['db_port'] = $GLOBALS['phpgw_info']['server']['db_port'];  
     7        $_SESSION['phpgw_info']['expressomail']['server']['db_user'] = $GLOBALS['phpgw_info']['server']['db_user'];  
     8        $_SESSION['phpgw_info']['expressomail']['server']['db_pass'] = $GLOBALS['phpgw_info']['server']['db_pass'];  
     9        $_SESSION['phpgw_info']['expressomail']['server']['db_type'] = $GLOBALS['phpgw_info']['server']['db_type'];  
     10}  
     11else{  
     12        define('PHPGW_INCLUDE_ROOT','../');       
     13        define('PHPGW_API_INC','../phpgwapi/inc');        
     14        include_once(PHPGW_API_INC.'/class.db.inc.php');  
     15}  
    516include_once('class.dynamic_contacts.inc.php'); 
    617         
     
    214225                if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['number_of_contacts'] && 
    215226                        $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts']) { 
     227                        // Free others requests  
     228                        session_write_close();  
    216229                        $dynamic_contact = new dynamic_contacts(); 
    217230                        $dynamic = $dynamic_contact->dynamic_contact_toString(); 
     
    353366                                $calendar = $fileContent; 
    354367                } 
     368                // It's necessary to access calendar method.  
     369                include_once(PHPGW_INCLUDE_ROOT.'/header.inc.php');  
    355370                         
    356371                $uiicalendar = CreateObject("calendar.uiicalendar"); 
  • branches/2.2/expressoMail1_2/inc/class.functions.inc.php

    r1572 r3018  
    116116                $h = ord($c{0});    
    117117                    if ($h <= 0x7F || $h < 0xC2) { 
    118                         $result .= $c; 
    119                     } 
     118                            // fixing curly brackets  
     119                            if($h == 0x7B || $h == 0x7D)  
     120                                    $result .= "&#" . $h . ";";  
     121                            else  
     122                                    $result .= $c; 
     123                    } 
    120124                        else if ($h <= 0xDF) { 
    121125                        $h = ($h & 0x1F) << 6 | (ord($c{1}) & 0x3F); 
  • branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php

    r1969 r3018  
    7777        function get_range_msgs2($params) 
    7878        { 
     79                // Free others requests  
     80                session_write_close();  
    7981                $folder = $params['folder']; 
    8082                $msg_range_begin = $params['msg_range_begin']; 
     
    335337                        $head1 = explode(":",$head); 
    336338                        if ( (strtoupper($head1[0]) == "TO") || 
    337                                         (strtoupper($head1[0]) == "FROM") || 
    338                                         (strtoupper($head1[0]) == "SUBJECT") || 
    339                                         (strtoupper($head1[0]) == "DATE") ) 
    340                                 $header .= $head."\r\n"; 
     339                                (strtoupper($head1[0]) == "FROM") || 
     340                                (strtoupper($head1[0]) == "SUBJECT") || 
     341                                (strtoupper($head1[0]) == "DATE") ||  
     342                                (strtoupper($head1[0]) == "CONTENT-TYPE")) {  
     343 
     344                                        if(strtoupper($head1[0]) == "CONTENT-TYPE"){  
     345                                                $head = str_replace("multipart/mixed","text/html",$head);                         
     346                                        }  
     347                                        $header .= $head."\n";  
     348                                }  
    341349                } 
    342350 
     
    474482                $body = $return_get_body['body']; 
    475483                //Remoção de tags <span></span> para correção de erro no firefox 
    476                 $body = mb_ereg_replace("<span><span>","",$body); 
    477                 $body = mb_ereg_replace("</span></span>","",$body); 
     484                $body = mb_eregi_replace("<span><span>","",$body); 
     485                $body = mb_eregi_replace("</span></span>","",$body); 
    478486 
    479487                if($return_get_body['body']=='isCripted'){ 
     
    492500                } 
    493501 
    494                 $pattern = '/^[ \t]*Disposition-Notification-To(^:)*:(.+)*@(.+)*$/isUm'; 
     502                $pattern = '/^[ \t]*Disposition-Notification-To:[ ]*<?[[:alnum:]\._-]+@[[:alnum:]_-]+[\.[:alnum:]]+>?/sm'; 
    495503                if (preg_match($pattern, $header_, $fields)) 
    496504                { 
    497                         preg_match('/[[:alnum:]\._\-]+@[[:alnum:]_\-\.]+/',$fields[0], $matches); 
    498                         $return['DispositionNotificationTo'] = "<".$matches[0].">"; 
     505                        if(preg_match('/[[:alnum:]\._\-]+@[[:alnum:]_\-\.]+/',$fields[0], $matches)){  
     506                                $return['DispositionNotificationTo'] = "<".$matches[0].">";  
     507                        }  
    499508                } 
    500509 
     
    789798                if(!$msg->structure[$msg_number]->parts) //Simple message, only 1 piece 
    790799                { 
    791             if(strtolower($msg->structure[$msg_number]->subtype) == 'x-pkcs7-mime'){ 
    792                 $return['body']='isCripted'; 
    793                 return $return; 
    794             } 
     800                        if(strtolower($msg->structure[$msg_number]->subtype) == 'x-pkcs7-mime'){ 
     801                                $return['body']='isCripted'; 
     802                                return $return; 
     803                        } 
    795804 
    796805                        $attachment = array(); //No attachments 
    797806 
    798             if(strtolower($msg->structure[$msg_number]->subtype) == 'x-pkcs7-mime'){ 
    799                                         $return['body']='isCripted'; 
    800                                         return $return; 
    801                         } 
    802  
    803                         $content = ''; 
    804                         if (strtolower($msg->structure[$msg_number]->subtype) == "plain") 
    805                         { 
    806                                 $content .= '<span style="font-family: monospace">' . nl2br($this->decodeBody((imap_body($this->mbox, $msg_number, FT_UID)), $msg->encoding[$msg_number][0], $msg->charset[$msg_number][0])) . '</span>'; 
    807                         } 
    808                         else if (strtolower($msg->structure[$msg_number]->subtype) == "html") 
    809                         { 
    810                                 $content .= $this->decodeBody(imap_body($this->mbox, $msg_number, FT_UID), $msg->encoding[$msg_number][0], $msg->charset[$msg_number][0]); 
    811                         } 
     807                        if(strtolower($msg->structure[$msg_number]->subtype) == 'x-pkcs7-mime'){ 
     808                                $return['body']='isCripted'; 
     809                                return $return; 
     810                        } 
     811 
     812                        $content = '';  
     813                        // If simple message is subtype 'html' or 'plain', then get content body.  
     814                        if(strtolower($msg->structure[$msg_number]->subtype) == "html" ||   
     815                                strtolower( $msg -> structure[ $msg_number ] -> subtype ) == 'plain'){  
     816 
     817                                        $content = $this->decodeBody(  
     818                                                imap_body( $this -> mbox, $msg_number, FT_UID ),  
     819                                                $msg -> encoding[ $msg_number ][ 0 ],  
     820                                                $msg -> charset[ $msg_number ][ 0 ]  
     821                                        );  
     822 
     823                                        if ( strtolower( $msg -> structure[ $msg_number ] -> subtype ) == 'plain' )  
     824                                        {  
     825                                                $content = str_replace( array( '<', '>' ), array( ' #$<$# ', ' #$>$# ' ), $content );  
     826                                                $content = htmlentities( $content );  
     827                                                $content = $this -> replace_links( $content );  
     828                                                $content = str_replace( array( ' #$&lt;$# ', ' #$&gt;$# ' ), array( '&lt;', '&gt;' ), $content );  
     829                                                $content = '<pre style="white-space:pre;word-wrap: break-word;white-space:pre-wrap;font-family: monospace;font-size:12px">' . $content . '</pre>';  
     830 
     831                                                $return[ 'body' ] = $content;  
     832 
     833                                                return $return;  
     834                                        }  
     835                                } 
    812836                } 
    813837                else 
     
    836860 
    837861                                $file_type = strtolower($msg->file_type[$msg_number][$values]); 
    838                                 if($file_type == "message/rfc822") 
    839                                         $has_multipart = false; 
    840  
    841                                 if($file_type == "multipart/alternative") 
    842                                         $has_multipart = false; 
     862                                if($file_type == "message/rfc822" || $file_type == "multipart/alternative")  
     863                                {  
     864                                        // Show only 'text/html' part, when message/rfc822 format contains 'text/plain' alternative part.  
     865                                        if(array_key_exists($values+1, $msg->file_type[$msg_number]) &&  
     866                                                strtolower($msg->file_type[$msg_number][$values+1]) == 'text/plain' &&  
     867                                                array_key_exists($values+2, $msg->file_type[$msg_number]) &&  
     868                                                strtolower($msg->file_type[$msg_number][$values+2]) == 'text/html') {  
     869                                                        $has_multipart = false;  
     870                                                }  
     871                                }        
    843872 
    844873                                if(($file_type == "text/plain" 
    845874                                        || $file_type == "text/html") 
    846                                         && $file_type != 'attachment') 
     875                                                && $file_type != 'attachment') 
    847876                                { 
    848877                                        if($file_type == "text/plain" && !$show_only_html && $has_multipart) 
     
    850879                                                // if TXT file size > 100kb, then it will not expand. 
    851880                                                if(!($file_type == "text/plain" && $msg->fsize[$msg_number][$values] > 102400)) { 
    852                                                         $content .= nl2br(htmlentities($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values]))); 
     881                                                         $content .= htmlentities($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values]));  
     882                                                         $content = '<pre style="white-space:pre;word-wrap: break-word;white-space:pre-wrap;font-family: monospace;font-size:12px">' . $content . '</pre>';     
    853883                                                } 
    854884                                        } 
     
    860890                                        } 
    861891                                } 
    862                                 else if($file_type == "message/delivery-status"){ 
     892                                 else if($file_type == "message/delivery-status" || $file_type == "message/feedback-report"){  
    863893                                        $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; 
    864                                         $content .= nl2br($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values])); 
    865  
     894                                         $content .= $this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values]);  
     895                                        $content = '<pre style="white-space:pre;word-wrap: break-word;white-space:pre-wrap;font-family: monospace;font-size:12px">' . $content . '</pre>';  
    866896                                } 
    867897                                else if($file_type == "message/rfc822" || $file_type == "text/rfc822-headers"){ 
     
    870900                                        $att = new imap_attachment(); 
    871901                                        $attachments =  $att -> get_attachment_info($this->mbox,$msg_number); 
    872                                         if($attachments['number_attachments'] > 0) { 
    873                                                 foreach($attachments ['attachment'] as $index => $attachment) 
    874                                                 { 
    875                                                         if ( in_array( strtolower( $attachment[ 'type' ] ), array( 'delivery-status', 'rfc822', 'rfc822-headers', 'plain' ) ) ) 
    876                                                         { 
    877                                                                 $obj = imap_rfc822_parse_headers( imap_fetchbody( $this -> mbox, $msg_number, $msg_part, FT_UID ), $msg -> encoding[ $msg_number ][ $values ] ); 
    878  
    879                                                                 $content .= '<hr align="left" width="95%" style="border:1px solid #DCDCDC">'; 
    880                                                                 $content .= '<br><table  style="margin:2px;border:1px solid black;background:#EAEAEA">'; 
    881  
    882                                                                 $content .= '<tr><td><b>' . $this->functions->getLang("Subject") 
    883                                                                         . ':</b></td><td>' .$this->decode_string($obj->subject) . '</td></tr>'; 
    884  
    885                                                                 $content .= '<tr><td><b>' . $this -> functions -> getLang( 'From' ) . ':</b></td><td>' 
    886                                                                         . $this -> replace_links( $this -> decode_string( $obj -> from[ 0 ] -> mailbox . '@' . $obj -> from[ 0 ] -> host) ) 
    887                                                                         . '</td></tr>'; 
    888  
    889                                                                 $content .= '<tr><td><b>' . $this->functions->getLang("Date") . ':</b></td><td>' . $obj->date . '</td></tr>'; 
    890  
    891                                                                 $content .= '<tr><td><b>' . $this -> functions -> getLang( 'TO' ) . ':</b></td><td>' 
    892                                                                         . $this -> replace_links( $this -> decode_string( $obj -> to[ 0 ] -> mailbox . '@' . $obj -> to[ 0 ] -> host ) ) 
    893                                                                         . '</td></tr>'; 
    894  
    895                                                                 if ( $obj->cc ) 
    896                                                                         $content .= '<tr><td><b>' . $this -> functions -> getLang( 'CC' ) . ':</b></td><td>' 
    897                                                                                 . $this -> replace_links( $this -> decode_string( $obj -> cc[ 0 ] -> mailbox . '@' . $obj -> cc[ 0 ] -> host ) ) 
    898                                                                                 . '</td></tr>'; 
    899  
    900                                                                 $content .= '</table><br>'; 
    901  
    902                                                                 $content .= $this->decodeBody( 
    903                                                                         imap_fetchbody( 
    904                                                                                 $this->mbox, 
    905                                                                                 $msg_number, 
    906                                                                                 ( $attachment['part_in_msg'] + ( 
    907                                                                                         ( strtolower( $attachment[ 'type' ] ) == 'delivery-status' ) ? 0 : 1 ) 
    908                                                                                 ) . ".1", 
    909                                                                                 FT_UID 
    910                                                                         ), 
    911                                                                         $msg->encoding[ $msg_number ][ $values ], 
    912                                                                         $msg->charset[ $msg_number ][ $values ] 
    913                                                                 ); 
    914                                                                 break; 
     902                                        if($attachments['number_attachments'] > 0) {  
     903                                                foreach($attachments ['attachment'] as $index => $attachment)  
     904                                                {  
     905                                                        if ( in_array( strtolower( $attachment[ 'type' ] ), array( 'delivery-status', 'rfc822', 'rfc822-headers', 'plain' ) ) )  
     906                                                        {  
     907                                                                $obj = imap_rfc822_parse_headers( imap_fetchbody( $this -> mbox, $msg_number, $msg_part, FT_UID ), $msg -> encoding[ $msg_number ][ $values ] );  
     908 
     909                                                                $content .= '<hr align="left" width="95%" style="border:1px solid #DCDCDC">';  
     910                                                                $content .= '<br><table  style="margin:2px;border:1px solid black;background:#EAEAEA">';  
     911 
     912                                                                $content .= '<tr><td><b>' . $this->functions->getLang("Subject")  
     913                                                                        . ':</b></td><td>' .$this->decode_string($obj->subject) . '</td></tr>';  
     914 
     915                                                                $content .= '<tr><td><b>' . $this -> functions -> getLang( 'From' ) . ':</b></td><td>'  
     916                                                                        . $this -> replace_links( $this -> decode_string( $obj -> from[ 0 ] -> mailbox . '@' . $obj -> from[ 0 ] -> host) )  
     917                                                                        . '</td></tr>';  
     918 
     919                                                                $content .= '<tr><td><b>' . $this->functions->getLang("Date") . ':</b></td><td>' . $obj->date . '</td></tr>';  
     920 
     921                                                                $content .= '<tr><td><b>' . $this -> functions -> getLang( 'TO' ) . ':</b></td><td>'  
     922                                                                        . $this -> replace_links( $this -> decode_string( $obj -> to[ 0 ] -> mailbox . '@' . $obj -> to[ 0 ] -> host ) )  
     923                                                                        . '</td></tr>';  
     924 
     925                                                                if ( $obj->cc )  
     926                                                                        $content .= '<tr><td><b>' . $this -> functions -> getLang( 'CC' ) . ':</b></td><td>'  
     927                                                                                . $this -> replace_links( $this -> decode_string( $obj -> cc[ 0 ] -> mailbox . '@' . $obj -> cc[ 0 ] -> host ) )  
     928                                                                                . '</td></tr>';  
     929 
     930                                                                $content .= '</table><br>';  
     931 
     932 
     933                                                                $id = ( ( strtolower( $attachment[ 'type' ] ) == 'delivery-status' ) ? false : true );  
     934                                                                if ( strtolower( $msg->structure[$msg_number]->parts[1]->parts[0]->subtype ) == 'plain' )  
     935                                                                {  
     936                                                                        $id = !$id;  
     937                                                                        if ( $msg->structure[$msg_number]->parts[1]->parts[0]->encoding == 4 )  
     938                                                                                $msg->encoding[ $msg_number ][ $values ] = 'quoted-printable';  
     939                                                                }  
     940 
     941                                                                $body = $this->decodeBody(  
     942                                                                        imap_fetchbody(  
     943                                                                                $this->mbox,  
     944                                                                                $msg_number,  
     945                                                                                ( $attachment['part_in_msg'] + ( ( int ) $id ) ) . ".1",  
     946                                                                                FT_UID  
     947                                                                        ),  
     948                                                                        $msg->encoding[ $msg_number ][ $values ],  
     949                                                                        $msg->charset[ $msg_number ][ $values ]  
     950                                                                );  
     951 
     952                                                                if ( strtolower( $msg->structure[$msg_number]->parts[1]->parts[0]->subtype ) == 'plain' )  
     953                                                                {  
     954                                                                        $body = str_replace( array( '<', '>' ), array( ' #$<$# ', ' #$>$# ' ), $body );  
     955                                                                        $body = htmlentities( $body );  
     956                                                                        $body = $this -> replace_links( $body );  
     957                                                                        $body = str_replace( array( ' #$&lt;$# ', ' #$&gt;$# ' ), array( '&lt;', '&gt;' ), $body );  
     958                                                                        $body = '<pre style="white-space:pre;word-wrap: break-word;white-space:pre-wrap;font-family: monospace;font-size:12px">' . $body . '</pre>';  
     959                                                                }  
     960 
     961                                                                $content .= $body;  
     962                                                                break;  
    915963                                                        } 
    916964                                                } 
     
    11511199        function replace_links( $body ) 
    11521200        { 
    1153                 $matches = array( ); 
    1154                 // Verify exception. 
    1155                 @preg_match( "/<a href=\"notes:\/\/\//", $body, $matches ); 
    1156  
    1157                 // If there is no exception, then open the link in new window. 
    1158                 if ( count( $matches ) ) 
    1159                         return $body; 
    1160  
    1161                 // All links should be moderated and they should only have the attribute 'target="blank"'. 
    1162                 $pattern = '/<a[^>]+href="([^>"]+)"[^>]*>(.*)<\/a>/im'; 
    1163                 $replacement = '<a href="$1" target="_blank">$2</a>'; 
     1201                // Domains and IPs addresses found in the text and which is not a link yet should be replaced by one.  
     1202                // See more informations in www.iana.org  
     1203                $octets = array(  
     1204                        'first' => '(2[0-3][0-9]|1[0-9]{2}|[1-9][0-9]?)',  
     1205                        'middle' => '(25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})',  
     1206                        'last' => '(25[0-4]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)'  
     1207                );  
     1208 
     1209                $ip = "\b{$octets[ 'first' ]}\.({$octets[ 'middle' ]}\.){2}{$octets[ 'last' ]}\b";  
     1210 
     1211                $top_level_domains = '(\.(ac|ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|as|asia|at|au|aw|ax|az|'  
     1212                        . 'ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bl|bm|bn|bo|br|bs|bt|bv|bw|by|bz|'  
     1213                        . 'ca|cat|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cu|cv|cx|cy|cz|'  
     1214                        . 'de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|'  
     1215                        . 'ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|'  
     1216                        . 'hk|hm|hn|hr|ht|hu|id|ie|il|im|in|info|int|io|iq|ir|is|it|je|jm|jo|jobs|jp|'  
     1217                        . 'ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|'  
     1218                        . 'ma|mc|md|me|mf|mg|mh|mil|mk|ml|mm|mn|mo|mobi|mp|mq|mr|ms|mt|mu|museum|'  
     1219                        . 'mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|'  
     1220                        . 'pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|ps|pt|pw|py|qa|re|ro|rs|ru|rw|'  
     1221                        . 'sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|'  
     1222                        . 'tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|travel|tt|tv|tw|tz|'  
     1223                        . 'ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))+\b';  
     1224 
     1225                $path = '(?>\/[\w\d\/\.\'\(\)\-\+~?!&#@$%|:;,*=_]+)?';  
     1226                $port = '(?>:\d{2,5})?';  
     1227                $domain = '(?>[\w\d_\-]+)';  
     1228                $subdomain = "(?>{$domain}\.)*";  
     1229                $protocol = '(?>(http|ftp)(s)?:\/\/)?';  
     1230                $url = "(?>{$protocol}((?>{$subdomain}{$domain}{$top_level_domains}|{$ip}){$port}{$path}))";  
     1231 
     1232                $pattern = "/(<\w[^>]+|[\/\"'@=])?{$url}/"; 
     1233                ini_set( 'pcre.backtrack_limit', 300000 );  
     1234 
     1235                /*  
     1236                // PHP 5.3  
     1237                $replace = function( $matches )  
     1238                {  
     1239                        if ( $matches[ 1 ] )  
     1240                                return $matches[ 0 ];  
     1241 
     1242                        $url = ( $matches[ 2 ] ) ? $matches[ 2 ] : 'http';  
     1243                        $url .= "{$matches[ 3 ]}://{$matches[ 4 ]}";  
     1244                        return "<a href=\"{$url}\" target=\"_blank\">{$matches[ 4 ]}</a>";  
     1245                };  
     1246                $body = preg_replace_callback( $pattern, $replace, $body );  
     1247                 */  
     1248 
     1249                // PHP 5.2.x - Remover assim que possível  
     1250                $body = preg_replace_callback( $pattern,  
     1251                        create_function(  
     1252                                '$matches',  
     1253                                'if ( $matches[ 1 ] ) return $matches[ 0 ];'  
     1254                                . '$url = ( $matches[ 2 ] ) ? $matches[ 2 ] : "http";' 
     1255                                . '$url .= "{$matches[ 3 ]}://{$matches[ 4 ]}";' 
     1256                                . 'return "<a href=\"{$url}\" target=\"_blank\">{$matches[ 4 ]}</a>";' 
     1257                        ), $body 
     1258                ); 
     1259                ini_set( 'pcre.backtrack_limit', 100000 );  
     1260                // E-mail address in the text should create a new e-mail on ExpressoMail 
     1261                $pattern = '/( |<|&lt;|>)([A-Za-z0-9\.~?\/_=#\-]*@[A-Za-z0-9\.~?\/_=#\-]*)( |>|&gt;|<)/im';  
     1262                $replacement = '$1<a href="mailto:$2">$2</a>$3'; 
    11641263                $body = preg_replace( $pattern, $replacement, $body ); 
    11651264 
    1166                 // Url found in the text and which is not a link yet should be replaced by one. 
    1167                 $pattern = '/(^|\w>|[ \(\[])((http(s)?:\/\/)?([\w\d_\-@]{2,}(\.[\w\d~?\/_=&#;\-:@$]+)+))/im'; 
    1168                 $replacement = '$1<a href="http$4://$5" target="_blank">$2</a>'; 
    1169                 $body = preg_replace( $pattern, $replacement, $body ); 
    1170  
    1171                 // E-mail address in the text should create a new e-mail on ExpressoMail 
    1172                 $pattern = '/( |<|&lt;|>)([A-Za-z0-9\.~?\/_=#\-]*@[A-Za-z0-9\.~?\/_=#\-]*)( |>|&gt;|<)/im'; 
    1173                 $replacement = '$1<a href="javascript:new_message_to(\'$2\')">$2</a>$3'; 
    1174                 $body = preg_replace( $pattern, $replacement, $body ); 
    1175  
    1176                 // If there is an link with a "mailto:" in href attribute, it will changed to create a new e-mail on ExpressoMail. 
    1177                 $pattern = '/<a[^>]+href=["\']mailto:([^"]+)["\'][^>]*>([^<]+)<\/a>/im'; 
    1178                 $replacement = '<a href="javascript:new_message_to(\'$1\')">$2</a>'; 
    1179                 $body = preg_replace( $pattern, $replacement, $body ); 
    1180  
    11811265                return $body; 
    11821266        } 
     
    11841268        function get_signature($msg, $msg_number, $msg_folder) 
    11851269        { 
    1186         include_once("../security/classes/CertificadoB.php"); 
     1270        include_once(dirname( __FILE__ ) ."/../../security/classes/CertificadoB.php"); 
    11871271                include_once("class.db_functions.inc.php"); 
    11881272                foreach ($msg->file_type[$msg_number] as $index => $file_type) 
     
    15571641                        $this->delete_mailbox(array("del_past" => "INBOX/decifradas")); 
    15581642                } 
    1559                 $serverString = "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}"; 
    1560                 $folders_list = imap_getmailboxes($mbox_stream, $serverString, ($params && $params['noSharedFolders']) ? "INBOX/*" : "*"); 
    1561                 $folders_list = array_slice($folders_list,0,$this->foldersLimit); 
    1562  
    1563                 $tmp = array(); 
    1564                 $resultMine = array(); 
    1565                 $resultDefault = array(); 
     1643 
    15661644 
    15671645                $inbox = 'INBOX'; 
    15681646                $trash = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder']; 
    1569                 $drafts = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder']; 
    1570                 $spam = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder']; 
    1571                 $sent = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder']; 
     1647                $drafts = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder']; 
     1648                $spam = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder']; 
     1649                $sent = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder']; 
     1650                $uid2cn = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['uid2cn'];  
     1651                // Free others requests  
     1652                session_write_close();  
     1653 
     1654                $serverString = "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}";  
     1655                $folders_list = imap_getmailboxes($mbox_stream, $serverString, ($params && $params['noSharedFolders']) ? "INBOX/*" : "*");  
     1656                $folders_list = array_slice($folders_list,0,$this->foldersLimit);  
     1657 
     1658                $tmp = array();  
     1659                $resultMine = array();  
     1660                $resultDefault = array();  
    15721661 
    15731662                if (is_array($folders_list)) { 
     
    15931682                                $result[$i]['folder_name'] = array_pop($tmp_folder_parent); 
    15941683                                $result[$i]['folder_name'] = $result[$i]['folder_name'] == 'INBOX' ? 'Inbox' : $result[$i]['folder_name']; 
    1595                                 if ($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['uid2cn'] && substr($folder_id,0,4) == 'user') { 
     1684                                if ($uid2cn && substr($folder_id,0,4) == 'user') { 
    15961685                                        //$this->ldap = new ldap_functions(); 
    15971686                                        if ($cn = $this->ldap->uid2cn($result[$i]['folder_name'])) { 
     
    17981887                                return "The server denied your request to send a mail, you cannot use this mail address."; 
    17991888                } 
    1800  
    1801                 //new_message_to backs to mailto: pattern 
    1802                 $params['body'] = eregi_replace("<a href=\"javascript:new_message_to\('([^>]+)'\)\">[^>]+</a>","<a href='mailto:\\1'>\\1</a>",$params['body']); 
    18031889 
    18041890                $toaddress = implode(',',$db->getAddrs(explode(',',$params['input_to']))); 
     
    19972083            $mail->Certs_crypt = $aux_mails; 
    19982084        } 
    1999  
    2000 //////////////////////////////////////////////////////////////////////////////////////////////////// 
    2001                 //      Build CID for embedded Images!!! 
    2002                 $pattern = '/src="([^"]*?show_embedded_attach.php\?msg_folder=(.+)?&(amp;)?msg_num=(.+)?&(amp;)?msg_part=(.+)?)"/isU'; 
    2003                 $cid_imgs = ''; 
    2004                 $name_cid_files = array(); 
    2005                 preg_match_all($pattern,$mail->Body,$cid_imgs,PREG_PATTERN_ORDER); 
    2006                 $cid_array = array(); 
    2007                 foreach($cid_imgs[6] as $j => $val){ 
    2008                                 if ( !array_key_exists($cid_imgs[4][$j].$val, $cid_array) ) 
    2009                         { 
    2010                 $cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36); 
    2011                         } 
    2012                         $cid = $cid_array[$cid_imgs[4][$j].$val]; 
    2013                         $mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body); 
    2014  
    2015                                 if (!$forwarding_attachments[$cid_imgs[6][$j]-2]) // The image isn't in the same mail? 
    2016                                 { 
    2017                                         $fileContent = $this->get_forwarding_attachment($cid_imgs[2][$j], $cid_imgs[4][$j], $cid_imgs[6][$j], 'base64'); 
    2018                                         $fileName = "image_".($j).".jpg"; 
    2019                                         $fileCode = "base64"; 
    2020                                         $fileType = "image/jpg"; 
    2021                                 } 
    2022                                 else 
    2023                                 { 
    2024                                         $attach_img = $forwarding_attachments[$cid_imgs[6][$j]-2]; 
    2025                                         $file_description = unserialize(rawurldecode($attach_img)); 
    2026  
    2027                                         foreach($file_description as $i => $descriptor){ 
    2028                                                 $file_description[$i]  = eregi_replace('\'*\'','',$descriptor); 
    2029                                         } 
    2030                                         $fileContent = $this->get_forwarding_attachment($file_description[0], $cid_imgs[4][$j], $file_description[3], 'base64'); 
    2031                                         $fileName = $file_description[2]; 
    2032                                         $fileCode = $file_description[4]; 
    2033                                         $fileType = $this->get_file_type($file_description[2]); 
    2034                                         unset($forwarding_attachments[$cid_imgs[6][$j]-2]); 
    2035                                 } 
    2036                                 $tempDir = ini_get("session.save_path"); 
    2037                                 $file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat"; 
    2038                                 $f = fopen($tempDir.'/'.$file,"w"); 
    2039                                 fputs($f,$fileContent); 
    2040                                 fclose($f); 
    2041                                 if ($fileContent) 
    2042                                         $mail->AddEmbeddedImage($tempDir.'/'.$file, $cid, $fileName, $fileCode, $fileType); 
    2043                                 //else 
    2044                                 //      return "Error loading image attachment content"; 
    2045  
    2046                 } 
    2047 //////////////////////////////////////////////////////////////////////////////////////////////////// 
     2085                // Build CID images  
     2086                $this->buildEmbeddedImages($mail,$msg_uid,$forwarding_attachments);  
     2087 
    20482088                //      Build Uploading Attachments!!! 
    20492089                if ((count($attachments)) && ($params['is_local_forward']!="1")) //Caso seja forward normal... 
     
    20802120                { 
    20812121                        // Bug fixed for array_search function 
     2122                        $name_cid_files = array();  
    20822123                        if(count($name_cid_files) > 0) { 
    20832124                                $name_cid_files[count($name_cid_files)] = $name_cid_files[0]; 
     
    21422183                } 
    21432184        } 
    2144  
    2145     function add_recipients_cert($full_address) 
     2185        function buildEmbeddedImages(&$mail,$msg_uid,&$forwarding_attachments)  
     2186        {  
     2187                //      Build CID for embedded Images!!!  
     2188                $pattern = '/src="([^"]*?show_embedded_attach.php\?msg_folder=(.+)?&(amp;)?msg_num=(.+)?&(amp;)?msg_part=(.+)?)"/isU';  
     2189                $cid_imgs = '';  
     2190                preg_match_all($pattern,$mail->Body,$cid_imgs,PREG_PATTERN_ORDER);  
     2191                $cid_array = array();  
     2192                foreach($cid_imgs[6] as $j => $val){  
     2193                        if ( !array_key_exists($cid_imgs[4][$j].$val, $cid_array) )  
     2194                        {  
     2195                                $cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36);  
     2196                        }  
     2197                        $cid = $cid_array[$cid_imgs[4][$j].$val];   
     2198                        $mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body);  
     2199 
     2200                        if ($msg_uid != $cid_imgs[4][$j]) // The image is not in the same mail?  
     2201                        {  
     2202                                $fileContent = $this->get_forwarding_attachment($cid_imgs[2][$j], $cid_imgs[4][$j], $cid_imgs[6][$j], 'base64');  
     2203                                //prototype: get_forwarding_attachment ( folder, msg number, part, encoding)  
     2204                                $fileName = "image_".($j).".jpg";  
     2205                                $fileCode = "base64";  
     2206                                $fileType = "image/jpg";  
     2207                                $file_attached[0] = $cid_imgs[2][$j];  
     2208                                $file_attached[1] = $cid_imgs[4][$j];  
     2209                                $file_attached[2] = $fileName;  
     2210                                $file_attached[3] = $cid_imgs[6][$j];  
     2211                                $file_attached[4] = 'base64';  
     2212                                $file_attached[5] = strlen($fileContent); //Size of file  
     2213                                $return_forward[] = $file_attached;  
     2214 
     2215                                $attachment_ = unserialize(rawurldecode($forwarding_attachments[$cid_imgs[6][$j]-2]));  
     2216                                if ($file_attached[3] == $attachment_[3])  
     2217                                        unset($forwarding_attachments[$cid_imgs[6][$j]-2]);      
     2218                        }  
     2219                        else  
     2220                        {  
     2221                                $attach_img = $forwarding_attachments[$cid_imgs[6][$j]-2];  
     2222                                $file_description = unserialize(rawurldecode($attach_img));  
     2223                                if (is_array($file_description))  
     2224                                        foreach($file_description as $i => $descriptor){                                  
     2225                                                $file_description[$i]  = eregi_replace('\'*\'','',$descriptor);  
     2226                                        }  
     2227                                $fileContent = $this->get_forwarding_attachment($file_description[0], $msg_uid, $file_description[3], 'base64');  
     2228                                $fileName = $file_description[2];  
     2229                                $fileCode = $file_description[4];  
     2230                                $fileType = $this->get_file_type($file_description[2]);  
     2231                                unset($forwarding_attachments[$cid_imgs[6][$j]-2]);  
     2232                                if (!empty($file_description))  
     2233                                {  
     2234                                        $file_description[5] = strlen($fileContent); //Size of file  
     2235                                        $return_forward[] = $file_description;  
     2236                                }  
     2237                        }  
     2238                        $tempDir = ini_get("session.save_path");  
     2239                        $file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat";                                         
     2240                        $f = fopen($tempDir.'/'.$file,"w");  
     2241                        fputs($f,$fileContent);  
     2242                        fclose($f);  
     2243                        if ($fileContent)  
     2244                                $mail->AddEmbeddedImage($tempDir.'/'.$file, $cid, $fileName, $fileCode, $fileType);  
     2245                        //else  
     2246                        //      return "Error loading image attachment content";                                                  
     2247 
     2248                }  
     2249                return $return_forward;  
     2250        }  
     2251        function add_recipients_cert($full_address) 
    21462252        { 
    21472253                $result = ""; 
     
    25122618                $mail->Body = $body; 
    25132619 
    2514                 //      Build CID for embedded Images!!! 
    2515                 $pattern = '/src="([^"]*?show_embedded_attach.php\?msg_folder=(.+)?&(amp;)?msg_num=(.+)?&(amp;)?msg_part=(.+)?)"/isU'; 
    2516                 $cid_imgs = ''; 
    2517                 $name_cid_files = array(); 
    2518                 preg_match_all($pattern,$mail->Body,$cid_imgs,PREG_PATTERN_ORDER); 
    2519                 $cid_array = array(); 
    2520                 foreach($cid_imgs[6] as $j => $val){ 
    2521                                 if ( !array_key_exists($cid_imgs[4][$j].$val, $cid_array) ) 
    2522                         { 
    2523                 $cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36); 
    2524                         } 
    2525                         $cid = $cid_array[$cid_imgs[4][$j].$val]; 
    2526                         $mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body); 
    2527  
    2528                                 if ($msg_uid != $cid_imgs[4][$j]) // The image isn't in the same mail? 
    2529                                 { 
    2530                                         $fileContent = $this->get_forwarding_attachment($cid_imgs[2][$j], $cid_imgs[4][$j], $cid_imgs[6][$j], 'base64'); 
    2531                                         //prototype: get_forwarding_attachment ( folder, msg number, part, encoding) 
    2532                                         $fileName = "image_".($j).".jpg"; 
    2533                                         $fileCode = "base64"; 
    2534                                         $fileType = "image/jpg"; 
    2535                                         $file_attached[0] = $cid_imgs[2][$j]; 
    2536                                         $file_attached[1] = $cid_imgs[4][$j]; 
    2537                                         $file_attached[2] = $fileName; 
    2538                                         $file_attached[3] = $cid_imgs[6][$j]; 
    2539                                         $file_attached[4] = 'base64'; 
    2540                                         $file_attached[5] = strlen($fileContent); //Size of file 
    2541                                         $return_forward[] = $file_attached; 
    2542                                 } 
    2543                                 else 
    2544                                 { 
    2545                                         $attach_img = $forwarding_attachments[$cid_imgs[6][$j]-2]; 
    2546                                         $file_description = unserialize(rawurldecode($attach_img)); 
    2547                                         foreach($file_description as $i => $descriptor){ 
    2548                                                 $file_description[$i]  = eregi_replace('\'*\'','',$descriptor); 
    2549                                         } 
    2550                                         $fileContent = $this->get_forwarding_attachment($file_description[0], $msg_uid, $file_description[3], 'base64'); 
    2551                                         $fileName = $file_description[2]; 
    2552                                         $fileCode = $file_description[4]; 
    2553                                         $fileType = $this->get_file_type($file_description[2]); 
    2554                                         unset($forwarding_attachments[$cid_imgs[6][$j]-2]); 
    2555                                         if (!empty($file_description)) 
    2556                                         { 
    2557                                                 $file_description[5] = strlen($fileContent); //Size of file 
    2558                                                 $return_forward[] = $file_description; 
    2559                                         } 
    2560                                 } 
    2561                                 $tempDir = ini_get("session.save_path"); 
    2562                                 $file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat"; 
    2563                                 $f = fopen($tempDir.'/'.$file,"w"); 
    2564                                 fputs($f,$fileContent); 
    2565                                 fclose($f); 
    2566                                 if ($fileContent) 
    2567                                         $mail->AddEmbeddedImage($tempDir.'/'.$file, $cid, $fileName, $fileCode, $fileType); 
    2568                                 //else 
    2569                                 //      return "Error loading image attachment content"; 
    2570  
    2571                 } 
     2620                $return_forward = $this->buildEmbeddedImages($mail,$msg_uid,$forwarding_attachments);  
    25722621 
    25732622        //      Build Forwarding Attachments!!! 
     
    31593208                $criteria =  'BEFORE "'.$before_date.'"'; 
    31603209                $mbox_stream = $this->open_mbox('INBOX'.$this->imap_delimiter.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder']); 
     3210                // Free others requests  
     3211                session_write_close();  
    31613212                $messages = imap_search($mbox_stream, $criteria, SE_UID); 
    31623213                if (is_array($messages)){ 
     
    32013252 
    32023253        function search_msg($params = ''){ 
    3203             $retorno = ""; 
    32043254            $mbox_stream = ""; 
    32053255            if(strpos($params['condition'],"#")===false) { //local messages 
     
    32803330                                foreach($search_criteria as $new_search) 
    32813331                                { 
     3332                                    $elem = $this->get_msg_detail($new_search,$name_box,$mbox_stream);  
     3333                                    $elem['boxname'] = mb_convert_encoding( $name_box, "ISO_8859-1", "UTF7-IMAP" );  
     3334                                    $elem['uid'] = $new_search;  
     3335                                    $retorno[] = $elem;  
     3336 
     3337                                    /* NOTE: This code was lost on 2.2 merge  
    32823338                                    if ($search_result_number != '65536' && $sum == $search_result_number) 
    32833339                                    { 
     
    32903346                                        $retorno .= $m_token; 
    32913347                                        $sum ++; 
    3292                                     } 
     3348                                    } 
     3349                                     */ 
    32933350                                } 
    32943351                            } 
     
    33003357                        { 
    33013358                            foreach($search_criteria as $new_search) 
    3302                             { 
    3303                                 if ($search_result_number != '65536' && $sum == $search_result_number) 
     3359                            { 
     3360                                    $elem = $this->get_msg_detail($new_search,$name_box,$mbox_stream);  
     3361                                    $elem['boxname'] = mb_convert_encoding( $name_box, "ISO_8859-1", "UTF7-IMAP" );  
     3362                                    $elem['uid'] = $new_search;  
     3363                                    $retorno[] = $elem;  
     3364                                //  NOTE: This code was lost on 2.2 merge  
     3365                                /*if ($search_result_number != '65536' && $sum == $search_result_number) 
    33043366                                { 
    33053367                                    return $retorno ? $sum . "=sumResults=" . $retorno : "none"; 
    33063368                                } 
    33073369                                $retorno .= trim("##".mb_convert_encoding( $name_box, "ISO_8859-1", "UTF7-IMAP" ) . "--" . $this->get_msg($new_search,$name_box,$mbox_stream) . "--" . $new_search."##"."\n"); 
    3308                                 $sum++; 
     3370                                $sum++;*/ 
    33093371                            } 
    33103372                        } 
     
    33273389        } 
    33283390 
    3329         function get_msg($uid_msg,$name_box, $mbox_stream ) 
     3391        function get_msg_detail($uid_msg,$name_box, $mbox_stream ) 
    33303392        { 
    33313393                $header = $this->get_header($uid_msg); 
    3332                 include_once("class.imap_attachment.inc.php"); 
     3394                require_once("class.imap_attachment.inc.php"); 
    33333395                $imap_attachment = new imap_attachment(); 
    33343396                $attachments =  $imap_attachment->get_attachment_headerinfo($mbox_stream, $uid_msg); 
     
    33473409                if($header->from[0]->personal != "") 
    33483410                        $from = $header->from[0]->personal; 
    3349                 $ret_msg = $this->decode_string($from) . "--" . $subject . "--". gmdate("d/m/Y",$header ->udate)."--". $this->size_msg($header->Size) ."--". $flag; 
     3411                $ret_msg['from'] = $this->decode_string($from);  
     3412                $ret_msg['subject'] = $subject;  
     3413                $ret_msg['udate'] = $header ->udate;  
     3414                $ret_msg['size'] = $header->Size;  
     3415                $ret_msg['flag'] = $flag;  
    33503416                return $ret_msg; 
    33513417        } 
    3352  
    3353         function size_msg($size){ 
    3354                 $var = floor($size/1024); 
    3355                 if($var >= 1){ 
    3356                         return $var." kb"; 
    3357                 }else{ 
    3358                         return $size ." b"; 
    3359                 } 
    3360         } 
    3361  
    33623418        function ob_array($the_object) 
    33633419        { 
  • branches/2.2/expressoMail1_2/inc/class.message_components.inc.php

    r1739 r3018  
    112112                    $skip_next    = ($ftype == 'message/rfc822')?        true : false; 
    113113 
    114                     if ($ftype == 'multipart/mixed' || $skip_part == true && $ftype == 'multipart/alternative' || $ftype == 'multipart/related' ) 
     114                    if ($ftype == 'multipart/report' || $ftype == 'multipart/mixed' || $skip_part == true && $ftype == 'multipart/alternative' || ( $ftype == 'multipart/related' && strtolower( $parts[$p]->parts[0]->subtype ) == 'alternative' ) )  
    115115                    { 
    116116                        $n--; 
    117117                    } 
    118118                    else 
    119                     { 
    120                         $this->pid[$mid][$n]       = ($is_sub_part == false)? $i : ($sub_pid == '' ? '1' : $sub_pid).'.'.$i; 
     119                    { 
     120                        $this->pid[$mid][$n]       = ($is_sub_part == false || $skip_part && $ftype == 'multipart/related' )? $i : ($sub_pid == '' ? '1' : $sub_pid).'.'.$i;  
    121121                        $this->file_type[$mid][$n] = $ftype; 
    122122                        $this->encoding[$mid][$n]  = $encoding; 
  • branches/2.2/expressoMail1_2/inc/class.phpmailer.php

    r1793 r3018  
    525525        for($i = 0; $i < count($this->to); $i++) 
    526526        { 
    527             if($this->valEm($this->to[$i][0])) 
    528             { 
    529                 if(!$this->smtp->Recipient($this->to[$i][0]))  $bad_rcpt[] = $this->to[$i][0]; 
    530             } 
    531             else 
    532             { 
    533                 $errorx .= $this->to[$i][0] . ', '; 
    534             } 
     527                if(!$this->smtp->Recipient($this->to[$i][0])) 
     528                        $bad_rcpt[] = $this->to[$i][0]; 
    535529        } 
    536530        for($i = 0; $i < count($this->cc); $i++) 
    537531        { 
    538             if($this->valEm($this->cc[$i][0])) 
    539             { 
    540                 if(!$this->smtp->Recipient($this->cc[$i][0])) $bad_rcpt[] = $this->cc[$i][0]; 
    541             } 
    542                         else 
    543             { 
    544                 $errorx .= $this->cc[$i][0] . ', '; 
    545             } 
     532                if(!$this->smtp->Recipient($this->cc[$i][0])) 
     533                        $bad_rcpt[] = $this->cc[$i][0]; 
    546534        } 
    547535        for($i = 0; $i < count($this->bcc); $i++) 
    548536        { 
    549             if($this->valEm($this->bcc[$i][0])) 
    550             { 
    551                 if(!$this->smtp->Recipient($this->bcc[$i][0])) $bad_rcpt[] = $this->bcc[$i][0]; 
    552             } 
    553                         else 
    554             { 
    555                 $errorx .= $this->bcc[$i][0] . ', '; 
    556             } 
     537                if(!$this->smtp->Recipient($this->bcc[$i][0])) 
     538                        $bad_rcpt[] = $this->bcc[$i][0];       
    557539        } 
    558540        if($errorx != '') 
     
    728710    } 
    729711 
    730     function valEm($email) 
    731     { 
    732         $mail_retorno = FALSE; 
    733         if ((strlen($email) >= 6) && (substr_count($email,"@") == 1) && (substr($email,0,1) != "@") && (substr($email,strlen($email)-1,1) != "@")) 
    734         { 
    735             if ((!strstr($email,"'")) && (!strstr($email,"\"")) && (!strstr($email,"\\")) && (!strstr($email,"\$")) && (!strstr($email," "))) 
    736             { 
    737                 //testa se tem caracter . 
    738                 if (substr_count($email,".")>= 1) 
    739                 { 
    740                     //obtem a terminação do dominio 
    741                     $term_dom = substr(strrchr ($email, '.'),1); 
    742                     //verifica se terminação do dominio esta correcta 
    743                     if (strlen($term_dom)>1 && strlen($term_dom)<5 && (!strstr($term_dom,"@")) ) 
    744                     { 
    745                         $antes_dom = substr($email,0,strlen($email) - strlen($term_dom) - 1); 
    746                         $caracter_ult = substr($antes_dom,strlen($antes_dom)-1,1); 
    747                         if ($caracter_ult != "@" && $caracter_ult != ".") 
    748                         { 
    749                             $mail_retorno = TRUE; 
    750                         } 
    751                     } 
    752                 } 
    753             } 
    754         } 
    755         return $mail_retorno; 
    756     } 
    757712 
    758713    /** 
  • branches/2.2/expressoMail1_2/inc/gotodownload.php

    r1937 r3018  
    1212        $msg_number = $_GET['msg_number']; 
    1313        $idx_file = $_GET['idx_file']; 
    14         $newfilename = $_GET['newfilename']; 
     14        $newfilename = urldecode($_GET['newfilename']); 
    1515        $msg_part = $_GET['msg_part']; 
    1616        $msg_folder = $_GET['msg_folder']; 
     
    171171                        if (preg_match("#^".ini_get('session.save_path')."/(".$GLOBALS['phpgw']->session->sessionid."/)*[A-z]+_".$GLOBALS['phpgw']->session->sessionid."[A-z0-9]*(\.[A-z]{3,4})?$#",$strFileName)) 
    172172                        { 
    173                                 readfile($strFileName); 
    174                                 exec("rm -f ".escapeshellcmd(escapeshellarg($strFileName))); 
     173                                if (preg_match("#^".dirname( __FILE__ ) . '/../tmpLclAtt'."/source_#",$strFileName)) { 
     174                                        //avoid stuck request  
     175                                        session_write_close();  
     176 
     177                                        //reset time limit for big files  
     178                                        set_time_limit(0);  
     179                                        ob_end_flush();  
     180 
     181                                        if ($fp = fopen ($strFileName, 'rb'))  
     182                                        {  
     183                                                $bufferSize=1024;  
     184                                                for ($i=$bufferSize; $i<=(filesize($strFileName)+$bufferSize); $i+=$bufferSize)   
     185                                                {  
     186                                                        echo fread($fp, $i);  
     187                                                        flush();  
     188                                                }  
     189                                                fclose ($fp);  
     190                                        }  
     191                                        //readfile($strFileName);        
     192 
     193                                        exec("rm -f ".escapeshellcmd(escapeshellarg($strFileName))); 
     194                                } 
     195                                else  
     196                                        if (preg_match("#^".dirname( __FILE__ ) . '/../tmpLclAtt'."/source_#",$strFileName)) { 
     197                                                readfile($strFileName); 
     198                                        } 
    175199                        } 
    176                         else  
    177                                 if (preg_match("#^".dirname( __FILE__ ) . '/../tmpLclAtt'."/source_#",$strFileName)) { 
    178                                         readfile($strFileName); 
    179                                 } 
    180         } 
    181200?> 
  • branches/2.2/expressoMail1_2/inc/hook_home.inc.php

    r1402 r3018  
    1111        $current_app = 'expressoMail1_2'; 
    1212        $current_name    = 'Expresso Mail'; 
    13         $preferences = $GLOBALS['phpgw']->preferences->read(); 
    14         $_SESSION['phpgw_info']['user']['preferences']['expressoMail'] = $preferences['expressoMail']; 
     13        if(!$_SESSION['phpgw_info']['user']['preferences']['expressoMail']) {  
     14                $preferences = $GLOBALS['phpgw']->preferences->read();  
     15                $_SESSION['phpgw_info']['user']['preferences']['expressoMail'] = $preferences['expressoMail']; 
     16        } 
    1517        $homedisplay = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['mainscreen_showmail']; 
    1618        if($homedisplay=='True') 
  • branches/2.2/expressoMail1_2/inc/show_embedded_attach.php

    r1040 r3018  
    11<?php 
    2 if(!isset($GLOBALS['phpgw_info'])){ 
    3         $GLOBALS['phpgw_info']['flags'] = array( 
    4                 'currentapp' => 'expressoMail1_2', 
    5                 'nonavbar'   => true, 
    6                 'noheader'   => true 
    7         ); 
    8 } 
    9 require_once '../../header.inc.php'; 
     2 
     3        require_once '../../header.session.inc.php';  
    104 
    115        $username = $_SESSION['phpgw_info']['expressomail']['user']['userid']; 
  • branches/2.2/expressoMail1_2/inc/show_img.php

    r1040 r3018  
    11<?php 
    2 if(!isset($GLOBALS['phpgw_info'])){ 
    3         $GLOBALS['phpgw_info']['flags'] = array( 
    4                 'currentapp' => 'expressoMail1_2', 
    5                 'nonavbar'   => true, 
    6                 'noheader'   => true 
    7         ); 
    8 } 
    9 require_once '../../header.inc.php'; 
    102 
     3        require_once '../../header.session.inc.php';  
    114        header("Content-Type: image/jpeg"); 
    125        if($_GET['msg_num'] && $_GET['msg_part'] && $_GET['msg_folder']) { 
  • branches/2.2/expressoMail1_2/inc/show_thumbs.php

    r1040 r3018  
    11<?php 
    2 if(!isset($GLOBALS['phpgw_info'])){ 
    3         $GLOBALS['phpgw_info']['flags'] = array( 
    4                 'currentapp' => 'expressoMail1_2', 
    5                 'nonavbar'   => true, 
    6                 'noheader'   => true 
    7         ); 
    8 } 
    9 require_once '../../header.inc.php'; 
    102 
     3        require_once '../../header.session.inc.php';  
    114        $username = $_SESSION['phpgw_info']['expressomail']['user']['userid']; 
    125        $password = $_SESSION['phpgw_info']['expressomail']['user']['passwd']; 
     
    3124        $image_mail = imap_fetchbody($mb, $msg_num, $msg_part, FT_UID); 
    3225        $image = imap_base64($image_mail); 
    33         $image = imagecreatefromstring ($image); 
    34          
    35         header("Content-Type: ".$file_type); 
    36         header("Content-Disposition: inline"); 
    37   
    38         $pic = $image; 
    39     if ($pic) { 
    40         $width = imagesx($pic); 
    41         $height = imagesy($pic); 
    42         $twidth = 160; # width of the thumb 160 pixel 
    43         $theight = $twidth * $height / $width; # calculate height 
    44         $thumb = imagecreatetruecolor ($twidth, $theight); 
     26        $pic = @imagecreatefromstring ($image); 
     27        if($pic !== FALSE) {  
     28                header("Content-Type: ".$file_type);  
     29                header("Content-Disposition: inline"); 
     30                $width = imagesx($pic); 
     31                $height = imagesy($pic); 
     32                $twidth = 160; # width of the thumb 160 pixel 
     33                $theight = $twidth * $height / $width; # calculate height 
     34                $theight =  $theight < 1 ? 1 : $theight;  
     35                $thumb = imagecreatetruecolor ($twidth, $theight); 
    4536                imagecopyresized($thumb, $pic, 0, 0, 0, 0,$twidth, $theight, $width, $height); # resize image into thumb 
    4637                imagejpeg($thumb,"",75); # Thumbnail as JPEG 
    47     } 
     38        } 
    4839?> 
  • branches/2.2/expressoMail1_2/inc/show_user_photo.php

    r1495 r3018  
    11<?php 
    2 if(!isset($GLOBALS['phpgw_info'])){ 
    3         $GLOBALS['phpgw_info']['flags'] = array( 
    4                 'currentapp' => 'expressoMail1_2', 
    5                 'nonavbar'   => true, 
    6                 'noheader'   => true 
    7         ); 
    8 } 
    9 require_once '../../header.inc.php'; 
     2 
     3        require_once '../../header.session.inc.php';  
    104 
    115 
Note: See TracChangeset for help on using the changeset viewer.