Mailer.php
[Pman.Core] / Mailer.php
index 334baa3..832b6b9 100644 (file)
@@ -386,7 +386,7 @@ class Pman_Core_Mailer {
         @$dom->loadHTML('<?xml encoding="UTF-8">' .$html);
         $imgs= $dom->getElementsByTagName('img');
         
-        $test = array();
+        $urls = array();
         
         foreach ($imgs as $i=>$img) {
             $url  = $img->getAttribute('src');
@@ -397,11 +397,19 @@ class Pman_Core_Mailer {
             if ($me == 'no') {
                 continue;
             }
-            $test[] = $url;
+            
+            if(!array_key_exists($url, $urls)){
+                $conv = $this->fetchImage($url);
+                $urls[$url] = $conv;
+                $this->images[$conv['contentid']] = $conv;
+            } else {
+                $conv = $urls[$url];
+            }
+            
+            $img->setAttribute('src', 'cid:' . $conv['contentid']);
         }
         
-        print_R($test);exit;
-        
+        /*
         foreach ($imgs as $i=>$img) {
             $url  = $img->getAttribute('src');
             if (preg_match('#^cid:#', $url)) {
@@ -416,9 +424,10 @@ class Pman_Core_Mailer {
             $this->images[$conv['contentid']] = $conv;
             
             $img->setAttribute('src', 'cid:' . $conv['contentid']);
-            
-            
         }
+        * 
+        */
+        
         return $dom->saveHTML();