Changeset 2764
- Timestamp:
- 05/12/10 17:28:23 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/inc/class.imap_functions.inc.php
r2763 r2764 2088 2088 } 2089 2089 2090 //////////////////////////////////////////////////////////////////////////////////////////////////// 2091 // Build CID for embedded Images!!! 2092 $pattern = '/src="([^"]*?show_embedded_attach.php\?msg_folder=(.+)?&(amp;)?msg_num=(.+)?&(amp;)?msg_part=(.+)?)"/isU'; 2093 $cid_imgs = ''; 2094 $name_cid_files = array(); 2095 preg_match_all($pattern,$mail->Body,$cid_imgs,PREG_PATTERN_ORDER); 2096 $cid_array = array(); 2097 foreach($cid_imgs[6] as $j => $val){ 2098 if ( !array_key_exists($cid_imgs[4][$j].$val, $cid_array) ) 2099 { 2100 $cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36); 2101 } 2102 $cid = $cid_array[$cid_imgs[4][$j].$val]; 2103 $mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body); 2104 2105 if (!$forwarding_attachments[$cid_imgs[6][$j]-2]) // The image isn't in the same mail? 2106 { 2107 $fileContent = $this->get_forwarding_attachment($cid_imgs[2][$j], $cid_imgs[4][$j], $cid_imgs[6][$j], 'base64'); 2108 $fileName = "image_".($j).".jpg"; 2109 $fileCode = "base64"; 2110 $fileType = "image/jpg"; 2111 } 2112 else 2113 { 2114 $attach_img = $forwarding_attachments[$cid_imgs[6][$j]-2]; 2115 $file_description = unserialize(rawurldecode($attach_img)); 2116 2117 foreach($file_description as $i => $descriptor){ 2118 $file_description[$i] = eregi_replace('\'*\'','',$descriptor); 2119 } 2120 $fileContent = $this->get_forwarding_attachment($file_description[0], $cid_imgs[4][$j], $file_description[3], 'base64'); 2121 $fileName = $file_description[2]; 2122 $fileCode = $file_description[4]; 2123 $fileType = $this->get_file_type($file_description[2]); 2124 unset($forwarding_attachments[$cid_imgs[6][$j]-2]); 2125 } 2126 $tempDir = ini_get("session.save_path"); 2127 $file = "cidimage_".$this->session_id.$cid_imgs[6][$j].".dat"; 2128 $f = fopen($tempDir.'/'.$file,"w"); 2129 fputs($f,$fileContent); 2130 fclose($f); 2131 if ($fileContent) 2132 $mail->AddEmbeddedImage($tempDir.'/'.$file, $cid, $fileName, $fileCode, $fileType); 2133 //else 2134 // return "Error loading image attachment content"; 2135 2136 } 2137 //////////////////////////////////////////////////////////////////////////////////////////////////// 2138 // Build Uploading Attachments!!! 2090 $this->buildEmbeddedImages($mail,$msg_uid,$forwarding_attachments); 2091 // Build Uploading Attachments!!! 2139 2092 if ((count($attachments)) && ($params['is_local_forward']!="1")) //Caso seja forward normal... 2140 2093 { … … 2233 2186 } 2234 2187 2188 function buildEmbeddedImages(&$mail,$msg_uid,&$forwarding_attachments) 2189 { 2190 // Build CID for embedded Images!!! 2191 $pattern = '/src="([^"]*?show_embedded_attach.php\?msg_folder=(.+)?&(amp;)?msg_num=(.+)?&(amp;)?msg_part=(.+)?)"/isU'; 2192 $cid_imgs = ''; 2193 $name_cid_files = array(); 2194 preg_match_all($pattern,$mail->Body,$cid_imgs,PREG_PATTERN_ORDER); 2195 $cid_array = array(); 2196 foreach($cid_imgs[6] as $j => $val){ 2197 if ( !array_key_exists($cid_imgs[4][$j].$val, $cid_array) ) 2198 { 2199 $cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36); 2200 } 2201 $cid = $cid_array[$cid_imgs[4][$j].$val]; 2202 $mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body); 2203 2204 if ($msg_uid != $cid_imgs[4][$j]) // The image is not in the same mail? 2205 { 2206 $fileContent = $this->get_forwarding_attachment($cid_imgs[2][$j], $cid_imgs[4][$j], $cid_imgs[6][$j], 'base64'); 2207 //prototype: get_forwarding_attachment ( folder, msg number, part, encoding) 2208 $fileName = "image_".($j).".jpg"; 2209 $fileCode = "base64"; 2210 $fileType = "image/jpg"; 2211 $file_attached[0] = $cid_imgs[2][$j]; 2212 $file_attached[1] = $cid_imgs[4][$j]; 2213 $file_attached[2] = $fileName; 2214 $file_attached[3] = $cid_imgs[6][$j]; 2215 $file_attached[4] = 'base64'; 2216 $file_attached[5] = strlen($fileContent); //Size of file 2217 $return_forward[] = $file_attached; 2218 2219 unset($forwarding_attachments[$cid_imgs[6][$j]-2]); 2220 } 2221 else 2222 { 2223 $attach_img = $forwarding_attachments[$cid_imgs[6][$j]-2]; 2224 $file_description = unserialize(rawurldecode($attach_img)); 2225 if (is_array($file_description)) 2226 foreach($file_description as $i => $descriptor){ 2227 $file_description[$i] = eregi_replace('\'*\'','',$descriptor); 2228 } 2229 $fileContent = $this->get_forwarding_attachment($file_description[0], $msg_uid, $file_description[3], 'base64'); 2230 $fileName = $file_description[2]; 2231 $fileCode = $file_description[4]; 2232 $fileType = $this->get_file_type($file_description[2]); 2233 unset($forwarding_attachments[$cid_imgs[6][$j]-2]); 2234 if (!empty($file_description)) 2235 { 2236 $file_description[5] = strlen($fileContent); //Size of file 2237 $return_forward[] = $file_description; 2238 } 2239 } 2240 $tempDir = ini_get("session.save_path"); 2241 $file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat"; 2242 $f = fopen($tempDir.'/'.$file,"w"); 2243 fputs($f,$fileContent); 2244 fclose($f); 2245 if ($fileContent) 2246 $mail->AddEmbeddedImage($tempDir.'/'.$file, $cid, $fileName, $fileCode, $fileType); 2247 //else 2248 // return "Error loading image attachment content"; 2249 2250 } 2251 return $return_forward; 2252 } 2235 2253 function add_recipients_cert($full_address) 2236 2254 { … … 2614 2632 $mail->Body = $body; 2615 2633 2616 // Build CID for embedded Images!!! 2617 $pattern = '/src="([^"]*?show_embedded_attach.php\?msg_folder=(.+)?&(amp;)?msg_num=(.+)?&(amp;)?msg_part=(.+)?)"/isU'; 2618 $cid_imgs = ''; 2619 $name_cid_files = array(); 2620 preg_match_all($pattern,$mail->Body,$cid_imgs,PREG_PATTERN_ORDER); 2621 $cid_array = array(); 2622 foreach($cid_imgs[6] as $j => $val){ 2623 if ( !array_key_exists($cid_imgs[4][$j].$val, $cid_array) ) 2624 { 2625 $cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36); 2626 } 2627 $cid = $cid_array[$cid_imgs[4][$j].$val]; 2628 $mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body); 2629 2630 if ($msg_uid != $cid_imgs[4][$j]) // The image isn't in the same mail? 2631 { 2632 $fileContent = $this->get_forwarding_attachment($cid_imgs[2][$j], $cid_imgs[4][$j], $cid_imgs[6][$j], 'base64'); 2633 //prototype: get_forwarding_attachment ( folder, msg number, part, encoding) 2634 $fileName = "image_".($j).".jpg"; 2635 $fileCode = "base64"; 2636 $fileType = "image/jpg"; 2637 $file_attached[0] = $cid_imgs[2][$j]; 2638 $file_attached[1] = $cid_imgs[4][$j]; 2639 $file_attached[2] = $fileName; 2640 $file_attached[3] = $cid_imgs[6][$j]; 2641 $file_attached[4] = 'base64'; 2642 $file_attached[5] = strlen($fileContent); //Size of file 2643 $return_forward[] = $file_attached; 2644 } 2645 else 2646 { 2647 $attach_img = $forwarding_attachments[$cid_imgs[6][$j]-2]; 2648 $file_description = unserialize(rawurldecode($attach_img)); 2649 foreach($file_description as $i => $descriptor){ 2650 $file_description[$i] = eregi_replace('\'*\'','',$descriptor); 2651 } 2652 $fileContent = $this->get_forwarding_attachment($file_description[0], $msg_uid, $file_description[3], 'base64'); 2653 $fileName = $file_description[2]; 2654 $fileCode = $file_description[4]; 2655 $fileType = $this->get_file_type($file_description[2]); 2656 unset($forwarding_attachments[$cid_imgs[6][$j]-2]); 2657 if (!empty($file_description)) 2658 { 2659 $file_description[5] = strlen($fileContent); //Size of file 2660 $return_forward[] = $file_description; 2661 } 2662 } 2663 $tempDir = ini_get("session.save_path"); 2664 $file = "cidimage_".$session_id.$cid_imgs[6][$j].".dat"; 2665 $f = fopen($tempDir.'/'.$file,"w"); 2666 fputs($f,$fileContent); 2667 fclose($f); 2668 if ($fileContent) 2669 $mail->AddEmbeddedImage($tempDir.'/'.$file, $cid, $fileName, $fileCode, $fileType); 2670 //else 2671 // return "Error loading image attachment content"; 2672 2673 } 2634 $return_forward = $this->buildEmbeddedImages($mail,$msg_uid,$forwarding_attachments); 2674 2635 2675 2636 // Build Forwarding Attachments!!!
Note: See TracChangeset
for help on using the changeset viewer.