aboutsummaryrefslogtreecommitdiff
path: root/lib/SimplePie
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2015-03-21 18:20:36 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2015-03-21 18:20:36 +0100
commit1a35e2271d3b9383e882371d37d5fef16abd745d (patch)
tree00744058d6a6b381100e89e3e4a08176bd22ca53 /lib/SimplePie
parentdfe781c30b2e189d4ba679e70a75d03f261c695c (diff)
SimplePie option to restaure syslog of HTTP requests
https://github.com/FreshRSS/FreshRSS/issues/711
Diffstat (limited to 'lib/SimplePie')
-rw-r--r--lib/SimplePie/SimplePie.php41
-rw-r--r--lib/SimplePie/SimplePie/File.php7
2 files changed, 40 insertions, 8 deletions
diff --git a/lib/SimplePie/SimplePie.php b/lib/SimplePie/SimplePie.php
index c4872b5be..bb8ce4191 100644
--- a/lib/SimplePie/SimplePie.php
+++ b/lib/SimplePie/SimplePie.php
@@ -75,6 +75,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()
*/
@@ -623,6 +629,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
*
* To use SimplePie, create the SimplePie object with no parameters. You can
@@ -1136,7 +1148,7 @@ class SimplePie
$this->sanitize->strip_attributes($attribs);
}
- public function add_attributes($attribs = '')
+ public function add_attributes($attribs = '') //FreshRSS
{
if ($attribs === '')
{
@@ -1146,6 +1158,14 @@ class SimplePie
}
/**
+ * 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
*
* Allows you to override SimplePie's output to match that of your webpage.
@@ -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 SimplePie
list($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.php
index 9625af2a9..56fe72196 100644
--- a/lib/SimplePie/SimplePie/File.php
+++ b/lib/SimplePie/SimplePie/File.php
@@ -66,7 +66,7 @@ class SimplePie_File
var $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');