Enable logging for image proxy

This commit is contained in:
Frederic Guillot 2015-02-07 11:09:43 -05:00
parent 3a80fccbab
commit ba4aa5173d

View File

@ -6,14 +6,15 @@ use Model\Config;
use PicoFeed\Config\Config as PicoFeedConfig; use PicoFeed\Config\Config as PicoFeedConfig;
use PicoFeed\Filter\Filter; use PicoFeed\Filter\Filter;
use PicoFeed\Client\Client; use PicoFeed\Client\Client;
use PicoFeed\Logging\Logger;
function isSecureConnection() function isSecureConnection()
{ {
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'); return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off');
} }
function addProxyToLink($link) { function addProxyToLink($link)
{
if (isSecureConnection() && strpos($link, 'http:') === 0) { if (isSecureConnection() && strpos($link, 'http:') === 0) {
$link = '?action=proxy&url='.urlencode($link); $link = '?action=proxy&url='.urlencode($link);
} }
@ -53,11 +54,14 @@ function addProxyToTags($html, $website, $proxy_images, $cloak_referrer)
function download($url) function download($url)
{ {
if ((bool) Config\get('debug_mode')) {
Logger::enable();
}
$client = Client::getInstance(); $client = Client::getInstance();
$client->setUserAgent(Config\HTTP_USER_AGENT); $client->setUserAgent(Config\HTTP_USER_AGENT);
$client->enablePassthroughMode(); $client->enablePassthroughMode();
$client->execute($url); $client->execute($url);
// does not work
Config\write_debug(); Config\write_debug();
} }