diff --git a/controllers/item.php b/controllers/item.php index f20c564..0a17e93 100644 --- a/controllers/item.php +++ b/controllers/item.php @@ -65,13 +65,13 @@ Router\get_action('show', function() { break; } - $image_proxy = Model\Config\get('image_proxy'); + $image_proxy = (bool) Model\Config\get('image_proxy'); // add the image proxy if requested and required - $item['content'] = Model\Proxy\addProxyToTags($item['content'], $item['url'], $image_proxy, $feed['cloak_referrer']); + $item['content'] = Model\Proxy\rewrite_html($item['content'], $item['url'], $image_proxy, $feed['cloak_referrer']); if ($image_proxy && strpos($item['enclosure_type'], 'image') === 0) { - $item['enclosure'] = Model\Proxy\addProxyToLink($item['enclosure']); + $item['enclosure'] = Model\Proxy\rewrite_link($item['enclosure']); } Response\html(Template\layout('show_item', array( @@ -120,7 +120,7 @@ Router\post_action('download-item', function() { $feed = Model\Feed\get($item['feed_id']); $download = Model\Item\download_content_id($id); - $download['content'] = Model\Proxy\addProxyToTags($download['content'], $item['url'], Model\Config\get('image_proxy'), $feed['cloak_referrer']); + $download['content'] = Model\Proxy\rewrite_html($download['content'], $item['url'], Model\Config\get('image_proxy'), $feed['cloak_referrer']); Response\json($download); }); diff --git a/models/proxy.php b/models/proxy.php index 313ff9e..2e0cca3 100644 --- a/models/proxy.php +++ b/models/proxy.php @@ -9,7 +9,7 @@ use PicoFeed\Filter\Filter; use PicoFeed\Client\Client; use PicoFeed\Logging\Logger; -function addProxyToLink($link) +function rewrite_link($link) { if (Helper\is_secure_connection() && strpos($link, 'http:') === 0) { $link = '?action=proxy&url='.rawurlencode($link); @@ -18,7 +18,7 @@ function addProxyToLink($link) return $link; } -function addProxyToTags($html, $website, $proxy_images, $cloak_referrer) +function rewrite_html($html, $website, $proxy_images, $cloak_referrer) { if ($html === '' // no content, no proxy || (! $cloak_referrer && ! $proxy_images) // neither cloaking nor proxing enabled