]> git.mxchange.org Git - friendica.git/blobdiff - include/network.php
New caching system for photos
[friendica.git] / include / network.php
index 0fff5c7cc9eea0993682da0810cc2748b4819e11..5877dda41b876651810cc8e76e3766b0bd475cb7 100644 (file)
@@ -99,7 +99,7 @@ if(! function_exists('post_url')) {
 function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0) {
        $a = get_app();
        $ch = curl_init($url);
-       if(($redirects > 8) || (! $ch)) 
+       if(($redirects > 8) || (! $ch))
                return false;
 
        curl_setopt($ch, CURLOPT_HEADER, true);
@@ -823,15 +823,13 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
                                $scaled = $mtch[1];
                        $i = fetch_url($scaled);
 
-                       $cache = get_config('system','itemcache');
-                       if (($cache != '') and is_dir($cache)) {
-                               $cachefile = $cache."/".hash("md5", $scaled);
+                       $cachefile = get_cachefile(hash("md5", $scaled));
+                       if ($cachefile != '')
                                file_put_contents($cachefile, $i);
-                       }
 
                        // guess mimetype from headers or filename
                        $type = guess_image_type($mtch[1],true);
-                       
+
                        if($i) {
                                $ph = new Photo($i, $type);
                                if($ph->is_valid()) {
@@ -854,6 +852,9 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
                        }
                }
        }
+
+       // replace the special char encoding
+       $s = htmlspecialchars($s,ENT_NOQUOTES,'UTF-8');
        return $s;
 }