diff options
author | Andrew Dolgov <[email protected]> | 2019-11-25 09:48:24 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2019-11-25 09:48:24 +0300 |
commit | e5b7b145e53915b8ff026f8caaa92fa2f7c833aa (patch) | |
tree | 4493fc238b3e3ddcb6f7a9bc212379d3f7dc826e /include | |
parent | 304d3a0b88052d16aca0230f67532acd6822e482 (diff) |
cache media: set referrer to source URL when fetching images
Diffstat (limited to 'include')
-rw-r--r-- | include/functions.php | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/include/functions.php b/include/functions.php index c6d33d2fd..c152454b9 100644 --- a/include/functions.php +++ b/include/functions.php @@ -230,6 +230,7 @@ $followlocation = isset($options["followlocation"]) ? $options["followlocation"] : true; $max_size = isset($options["max_size"]) ? $options["max_size"] : MAX_DOWNLOAD_FILE_SIZE; // in bytes $http_accept = isset($options["http_accept"]) ? $options["http_accept"] : false; + $http_referrer = isset($options["http_referrer"]) ? $options["http_referrer"] : false; $url = ltrim($url, ' '); $url = str_replace(' ', '%20', $url); @@ -273,7 +274,9 @@ curl_setopt($ch, CURLOPT_USERAGENT, $useragent ? $useragent : SELF_USER_AGENT); curl_setopt($ch, CURLOPT_ENCODING, ""); - //curl_setopt($ch, CURLOPT_REFERER, $url); + + if ($http_referrer) + curl_setopt($ch, CURLOPT_REFERER, $http_referrer); if ($max_size) { curl_setopt($ch, CURLOPT_NOPROGRESS, false); @@ -401,6 +404,9 @@ if ($http_accept) array_push($context_options['http']['header'], "Accept: $http_accept"); + if ($http_referrer) + array_push($context_options['http']['header'], "Referer: $http_referrer"); + if (defined('_HTTP_PROXY')) { $context_options['http']['request_fulluri'] = true; $context_options['http']['proxy'] = _HTTP_PROXY; |