Changeset 2759 for branches/2.0


Ignore:
Timestamp:
05/12/10 16:29:08 (14 years ago)
Author:
rodsouza
Message:

Ticket #405 - Corrige o problema que acontece ao encaminhar o email

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/expressoMail1_2/inc/class.imap_functions.inc.php

    r2758 r2759  
    19021902        } 
    19031903 
    1904 //////////////////////////////////////////////////////////////////////////////////////////////////// 
    1905                 //      Build CID for embedded Images!!! 
    1906                 $pattern = '/src="([^"]*?show_embedded_attach.php\?msg_folder=(.+)?&(amp;)?msg_num=(.+)?&(amp;)?msg_part=(.+)?)"/isU'; 
    1907                 $cid_imgs = ''; 
    1908                 $name_cid_files = array(); 
    1909                 preg_match_all($pattern,$mail->Body,$cid_imgs,PREG_PATTERN_ORDER); 
    1910                 $cid_array = array(); 
    1911                 foreach($cid_imgs[6] as $j => $val){ 
    1912                                 if ( !array_key_exists($cid_imgs[4][$j].$val, $cid_array) ) 
    1913                         { 
    1914                 $cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36); 
    1915                         } 
    1916                         $cid = $cid_array[$cid_imgs[4][$j].$val];  
    1917                         $mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body); 
    1918                          
    1919                                 if ($msg_uid != $cid_imgs[4][$j]) // The image isn't in the same mail? 
    1920                                 { 
    1921                                         $fileContent = $this->get_forwarding_attachment($cid_imgs[2][$j], $cid_imgs[4][$j], $cid_imgs[6][$j], 'base64'); 
    1922                                         $fileName = "image_".($j).".jpg"; 
    1923                                         $fileCode = "base64"; 
    1924                                         $fileType = "image/jpg"; 
    1925                                 } 
    1926                                 else 
    1927                                 { 
    1928                                         $attach_img = $forwarding_attachments[$cid_imgs[6][$j]-2]; 
    1929                                         $file_description = unserialize(rawurldecode($attach_img)); 
    1930  
    1931                                         foreach($file_description as $i => $descriptor){                                 
    1932                                                 $file_description[$i]  = eregi_replace('\'*\'','',$descriptor); 
    1933                                         } 
    1934                                         $fileContent = $this->get_forwarding_attachment($file_description[0], $msg_uid, $file_description[3], 'base64'); 
    1935                                         $fileName = $file_description[2]; 
    1936                                         $fileCode = $file_description[4]; 
    1937                                         $fileType = $this->get_file_type($file_description[2]); 
    1938                                         unset($forwarding_attachments[$cid_imgs[6][$j]-2]); 
    1939                                 } 
    1940                                 $tempDir = ini_get("session.save_path"); 
    1941                                 $file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat";        
    1942                                 $f = fopen($tempDir.'/'.$file,"w"); 
    1943                                 fputs($f,$fileContent); 
    1944                                 fclose($f); 
    1945                                 if ($fileContent) 
    1946                                         $mail->AddEmbeddedImage($tempDir.'/'.$file, $cid, $fileName, $fileCode, $fileType); 
    1947                                 //else 
    1948                                 //      return "Error loading image attachment content";                                                 
    1949  
    1950                 } 
    1951 //////////////////////////////////////////////////////////////////////////////////////////////////// 
     1904                // Build CID images 
     1905                $this->buildEmbeddedImages($mail,$msg_uid,$forwarding_attachments); 
     1906 
    19521907                //      Build Uploading Attachments!!! 
    19531908                if ((count($attachments)) && ($params['is_local_forward']!="1")) //Caso seja forward normal... 
     
    20472002        } 
    20482003 
     2004        function buildEmbeddedImages(&$mail,$msg_uid,&$forwarding_attachments) 
     2005        { 
     2006                //      Build CID for embedded Images!!! 
     2007                $pattern = '/src="([^"]*?show_embedded_attach.php\?msg_folder=(.+)?&(amp;)?msg_num=(.+)?&(amp;)?msg_part=(.+)?)"/isU'; 
     2008                $cid_imgs = ''; 
     2009                $name_cid_files = array(); 
     2010                preg_match_all($pattern,$mail->Body,$cid_imgs,PREG_PATTERN_ORDER); 
     2011                $cid_array = array(); 
     2012                foreach($cid_imgs[6] as $j => $val){ 
     2013                        if ( !array_key_exists($cid_imgs[4][$j].$val, $cid_array) ) 
     2014                        { 
     2015                                $cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36); 
     2016                        } 
     2017                        $cid = $cid_array[$cid_imgs[4][$j].$val];  
     2018                        $mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body); 
     2019 
     2020                        if ($msg_uid != $cid_imgs[4][$j]) // The image is not in the same mail? 
     2021                        { 
     2022                                $fileContent = $this->get_forwarding_attachment($cid_imgs[2][$j], $cid_imgs[4][$j], $cid_imgs[6][$j], 'base64'); 
     2023                                //prototype: get_forwarding_attachment ( folder, msg number, part, encoding) 
     2024                                $fileName = "image_".($j).".jpg"; 
     2025                                $fileCode = "base64"; 
     2026                                $fileType = "image/jpg"; 
     2027                                $file_attached[0] = $cid_imgs[2][$j]; 
     2028                                $file_attached[1] = $cid_imgs[4][$j]; 
     2029                                $file_attached[2] = $fileName; 
     2030                                $file_attached[3] = $cid_imgs[6][$j]; 
     2031                                $file_attached[4] = 'base64'; 
     2032                                $file_attached[5] = strlen($fileContent); //Size of file 
     2033                                $return_forward[] = $file_attached; 
     2034 
     2035                                unset($forwarding_attachments[$cid_imgs[6][$j]-2]); 
     2036                        } 
     2037                        else 
     2038                        { 
     2039                                $attach_img = $forwarding_attachments[$cid_imgs[6][$j]-2]; 
     2040                                $file_description = unserialize(rawurldecode($attach_img)); 
     2041                                if (is_array($file_description)) 
     2042                                        foreach($file_description as $i => $descriptor){                                 
     2043                                                $file_description[$i]  = eregi_replace('\'*\'','',$descriptor); 
     2044                                        } 
     2045                                $fileContent = $this->get_forwarding_attachment($file_description[0], $msg_uid, $file_description[3], 'base64'); 
     2046                                $fileName = $file_description[2]; 
     2047                                $fileCode = $file_description[4]; 
     2048                                $fileType = $this->get_file_type($file_description[2]); 
     2049                                unset($forwarding_attachments[$cid_imgs[6][$j]-2]); 
     2050                                if (!empty($file_description)) 
     2051                                { 
     2052                                        $file_description[5] = strlen($fileContent); //Size of file 
     2053                                        $return_forward[] = $file_description; 
     2054                                } 
     2055                        } 
     2056                        $tempDir = ini_get("session.save_path"); 
     2057                        $file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat";                                        
     2058                        $f = fopen($tempDir.'/'.$file,"w"); 
     2059                        fputs($f,$fileContent); 
     2060                        fclose($f); 
     2061                        if ($fileContent) 
     2062                                $mail->AddEmbeddedImage($tempDir.'/'.$file, $cid, $fileName, $fileCode, $fileType); 
     2063                        //else 
     2064                        //      return "Error loading image attachment content";                                                 
     2065 
     2066                } 
     2067                return $return_forward; 
     2068        } 
    20492069    function add_recipients_cert($full_address) 
    20502070        { 
     
    23742394                $attachments = $params['FILES']; 
    23752395                $return_files = $params['FILES']; 
     2396 
    23762397                  
    23772398                $folder = $params['folder']; 
     
    24022423                $mail->IsHTML(true); 
    24032424                $mail->Body = $body; 
    2404                  
    2405                 //      Build CID for embedded Images!!! 
    2406                 $pattern = '/src="([^"]*?show_embedded_attach.php\?msg_folder=(.+)?&(amp;)?msg_num=(.+)?&(amp;)?msg_part=(.+)?)"/isU'; 
    2407                 $cid_imgs = ''; 
    2408                 $name_cid_files = array(); 
    2409                 preg_match_all($pattern,$mail->Body,$cid_imgs,PREG_PATTERN_ORDER); 
    2410                 $cid_array = array(); 
    2411                 foreach($cid_imgs[6] as $j => $val){ 
    2412                                 if ( !array_key_exists($cid_imgs[4][$j].$val, $cid_array) ) 
    2413                         { 
    2414                 $cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36); 
    2415                         } 
    2416                         $cid = $cid_array[$cid_imgs[4][$j].$val];  
    2417                         $mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body); 
    2418                          
    2419                                 if ($msg_uid != $cid_imgs[4][$j]) // The image isn't in the same mail? 
    2420                                 { 
    2421                                         $fileContent = $this->get_forwarding_attachment($cid_imgs[2][$j], $cid_imgs[4][$j], $cid_imgs[6][$j], 'base64'); 
    2422                                         //prototype: get_forwarding_attachment ( folder, msg number, part, encoding) 
    2423                                         $fileName = "image_".($j).".jpg"; 
    2424                                         $fileCode = "base64"; 
    2425                                         $fileType = "image/jpg"; 
    2426                                         $file_attached[0] = $cid_imgs[2][$j]; 
    2427                                         $file_attached[1] = $cid_imgs[4][$j]; 
    2428                                         $file_attached[2] = $fileName; 
    2429                                         $file_attached[3] = $cid_imgs[6][$j]; 
    2430                                         $file_attached[4] = 'base64'; 
    2431                                         $file_attached[5] = strlen($fileContent); //Size of file 
    2432                                         $return_forward[] = $file_attached; 
    2433                                 } 
    2434                                 else 
    2435                                 { 
    2436                                         $attach_img = $forwarding_attachments[$cid_imgs[6][$j]-2]; 
    2437                                         $file_description = unserialize(rawurldecode($attach_img)); 
    2438                                         foreach($file_description as $i => $descriptor){                                 
    2439                                                 $file_description[$i]  = eregi_replace('\'*\'','',$descriptor); 
    2440                                         } 
    2441                                         $fileContent = $this->get_forwarding_attachment($file_description[0], $msg_uid, $file_description[3], 'base64'); 
    2442                                         $fileName = $file_description[2]; 
    2443                                         $fileCode = $file_description[4]; 
    2444                                         $fileType = $this->get_file_type($file_description[2]); 
    2445                                         unset($forwarding_attachments[$cid_imgs[6][$j]-2]); 
    2446                                         if (!empty($file_description)) 
    2447                                         { 
    2448                                                 $file_description[5] = strlen($fileContent); //Size of file 
    2449                                                 $return_forward[] = $file_description; 
    2450                                         } 
    2451                                 } 
    2452                                 $tempDir = ini_get("session.save_path"); 
    2453                                 $file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat";                                        
    2454                                 $f = fopen($tempDir.'/'.$file,"w"); 
    2455                                 fputs($f,$fileContent); 
    2456                                 fclose($f); 
    2457                                 if ($fileContent) 
    2458                                         $mail->AddEmbeddedImage($tempDir.'/'.$file, $cid, $fileName, $fileCode, $fileType); 
    2459                                 //else 
    2460                                 //      return "Error loading image attachment content";                                                 
    2461  
    2462                 } 
    2463          
    2464         //      Build Forwarding Attachments!!!          
     2425 
     2426                $return_forward = $this->buildEmbeddedImages($mail,$msg_uid,$forwarding_attachments); 
     2427         
     2428                //Build Forwarding Attachments!!!                
    24652429                if (count($forwarding_attachments) > 0) 
    24662430                { 
Note: See TracChangeset for help on using the changeset viewer.