A free, self-hostable news aggregator…
SimplePie option to restaure syslog of HTTP requests
Alexandre Alapetite1a35e2271d3b
diff --git a/app/Models/Feed.php b/app/Models/Feed.phpindex 5ce03be5d..5f67ea6ce 100644--- a/app/Models/Feed.php+++ b/app/Models/Feed.php@@ -246,10 +246,10 @@ class FreshRSS_Feed extends Minz_Model {}if (($mtime === true) ||($mtime > $this->lastUpdate)) {- Minz_Log::notice('FreshRSS no cache ' . $mtime . ' > ' . $this->lastUpdate . ' for ' . $clean_url);+ //Minz_Log::debug('FreshRSS no cache ' . $mtime . ' > ' . $this->lastUpdate . ' for ' . $clean_url);$this->loadEntries($feed); // et on charge les articles du flux} else {- Minz_Log::notice('FreshRSS use cache for ' . $clean_url);+ //Minz_Log::debug('FreshRSS use cache for ' . $clean_url);$this->entries = array();}diff --git a/data/config.default.php b/data/config.default.phpindex 97df3a299..839bd1687 100644--- a/data/config.default.php+++ b/data/config.default.php@@ -12,6 +12,7 @@ return array('auth_type' => 'none','api_enabled' => false,'unsafe_autologin_enabled' => false,+ 'simplepie_syslog_enabled' => true,'limits' => array('cache_duration' => 800,'timeout' => 10,diff --git a/lib/SimplePie/SimplePie.php b/lib/SimplePie/SimplePie.phpindex c4872b5be..bb8ce4191 100644--- a/lib/SimplePie/SimplePie.php+++ b/lib/SimplePie/SimplePie.php@@ -74,6 +74,12 @@ define('SIMPLEPIE_USERAGENT', SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION . ' (Feed*/define('SIMPLEPIE_LINKBACK', '<a href="' . SIMPLEPIE_URL . '" title="' . SIMPLEPIE_NAME . ' ' . SIMPLEPIE_VERSION . '">' . SIMPLEPIE_NAME . '</a>');+/**+ * Use syslog to report HTTP requests done by SimplePie.+ * @see SimplePie::set_syslog()+ */+define('SIMPLEPIE_SYSLOG', true); //FreshRSS+/*** No Autodiscovery* @see SimplePie::set_autodiscovery_level()@@ -622,6 +628,12 @@ class SimplePie*/public $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style');+ /**+ * Use syslog to report HTTP requests done by SimplePie.+ * @see SimplePie::set_syslog()+ */+ public $syslog_enabled = SIMPLEPIE_SYSLOG;+/*** The SimplePie class contains feed level data and options*@@ -1136,7 +1148,7 @@ class SimplePie$this->sanitize->strip_attributes($attribs);}- public function add_attributes($attribs = '')+ public function add_attributes($attribs = '') //FreshRSS{if ($attribs === ''){@@ -1145,6 +1157,14 @@ class SimplePie$this->sanitize->add_attributes($attribs);}+ /**+ * Use syslog to report HTTP requests done by SimplePie.+ */+ public function set_syslog($value = SIMPLEPIE_SYSLOG) //FreshRSS+ {+ $this->syslog_enabled = $value == true;+ }+/*** Set the output encoding*@@ -1231,7 +1251,8 @@ class SimplePie$this->enable_exceptions = $enable;}- function cleanMd5($rss) { //FreshRSS+ function cleanMd5($rss) //FreshRSS+ {return md5(preg_replace(array('#<(lastBuildDate|pubDate|updated|feedDate|dc:date|slash:comments)>[^<]+</\\1>#', '#<!--.+?-->#s'), '', $rss));}@@ -1329,7 +1350,8 @@ class SimplePielist($headers, $sniffed) = $fetched;- if (isset($this->data['md5'])) { //FreshRSS+ if (isset($this->data['md5'])) //FreshRSS+ {$md5 = $this->data['md5'];}}@@ -1455,7 +1477,8 @@ class SimplePie{// Load the Cache$this->data = $cache->load();- if ($cache->mtime() + $this->cache_duration > time()) { //FreshRSS+ if ($cache->mtime() + $this->cache_duration > time()) //FreshRSS+ {$this->raw_data = false;return true; // If the cache is still valid, just return true}@@ -1529,11 +1552,17 @@ class SimplePie{ //FreshRSS$md5 = $this->cleanMd5($file->body);if ($this->data['md5'] === $md5) {- // syslog(LOG_DEBUG, 'SimplePie MD5 cache match for ' . $this->feed_url);+ if ($this->syslog_enabled)+ {+ syslog(LOG_DEBUG, 'SimplePie MD5 cache match for ' . $this->feed_url);+ }$cache->touch();return true; //Content unchanged even though server did not send a 304} else {- // syslog(LOG_DEBUG, 'SimplePie MD5 cache no match for ' . $this->feed_url);+ if ($this->syslog_enabled)+ {+ syslog(LOG_DEBUG, 'SimplePie MD5 cache no match for ' . $this->feed_url);+ }$this->data['md5'] = $md5;}}diff --git a/lib/SimplePie/SimplePie/File.php b/lib/SimplePie/SimplePie/File.phpindex 9625af2a9..56fe72196 100644--- a/lib/SimplePie/SimplePie/File.php+++ b/lib/SimplePie/SimplePie/File.php@@ -66,7 +66,7 @@ class SimplePie_Filevar $method = SIMPLEPIE_FILE_SOURCE_NONE;var $permanent_url; //FreshRSS- public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false)+ public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false, $syslog_enabled = SIMPLEPIE_SYSLOG){if (class_exists('idna_convert')){@@ -79,7 +79,10 @@ class SimplePie_File$this->useragent = $useragent;if (preg_match('/^http(s)?:\/\//i', $url)){- // syslog(LOG_INFO, 'SimplePie GET ' . $url); //FreshRSS+ if ($syslog_enabled)+ {+ syslog(LOG_INFO, 'SimplePie GET ' . $url); //FreshRSS+ }if ($useragent === null){$useragent = ini_get('user_agent');diff --git a/lib/lib_rss.php b/lib/lib_rss.phpindex e5fe73041..16ae3097f 100644--- a/lib/lib_rss.php+++ b/lib/lib_rss.php@@ -123,6 +123,7 @@ function customSimplePie() {$limits = $system_conf->limits;$simplePie = new SimplePie();$simplePie->set_useragent(_t('gen.freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ') ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION);+ $simplePie->set_syslog($system_conf->simplepie_syslog_enabled);$simplePie->set_cache_location(CACHE_PATH);$simplePie->set_cache_duration($limits['cache_duration']);$simplePie->set_timeout($limits['timeout']);