X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fnetwork.php;h=f6e6cc2a30825c189ab77f196f0780b39ac80586;hb=5f1ef732e05c79584e6ea1cdb14360a7dd388a9d;hp=0e1a63792f5a04676cf3f23b00123c5cd7aad12b;hpb=9ecb9842858541db669e6ee61627e8526bf4c719;p=friendica.git diff --git a/include/network.php b/include/network.php index 0e1a63792f..f6e6cc2a30 100644 --- a/include/network.php +++ b/include/network.php @@ -15,6 +15,9 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_ @curl_setopt($ch, CURLOPT_HEADER, true); + @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + @curl_setopt($ch, CURLOPT_MAXREDIRS, 5); + if (!is_null($accept_content)){ curl_setopt($ch,CURLOPT_HTTPHEADER, array ( "Accept: " . $accept_content @@ -99,7 +102,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 +826,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()) { @@ -856,8 +857,7 @@ function scale_external_images($s, $include_link = true, $scale_replace = false) } // replace the special char encoding - - $s = htmlspecialchars($s,ENT_QUOTES,'UTF-8'); + $s = htmlspecialchars($s,ENT_NOQUOTES,'UTF-8'); return $s; }