|
|
@@ -402,9 +402,6 @@ define('SIMPLEPIE_FILE_SOURCE_CURL', 8);
|
|
|
*/
|
|
|
define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16);
|
|
|
|
|
|
-define('SIMPLEPIE_INIT_FAIL', 0); //FreshRSS
|
|
|
-define('SIMPLEPIE_INIT_SUCCESS', 1); //FreshRSS
|
|
|
-define('SIMPLEPIE_INIT_CACHE', 2); //FreshRSS
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -1222,14 +1219,14 @@ class SimplePie
|
|
|
* configuration options get processed, feeds are fetched, cached, and
|
|
|
* parsed, and all of that other good stuff.
|
|
|
*
|
|
|
- * @return boolean True if successful, false otherwise
|
|
|
+ * @return positive integer with modification time if using cache, boolean true if otherwise successful, false otherwise
|
|
|
*/
|
|
|
public function init()
|
|
|
{
|
|
|
// Check absolute bare minimum requirements.
|
|
|
if (!extension_loaded('xml') || !extension_loaded('pcre'))
|
|
|
{
|
|
|
- return SIMPLEPIE_INIT_FAIL;
|
|
|
+ return false;
|
|
|
}
|
|
|
// Then check the xml extension is sane (i.e., libxml 2.7.x issue on PHP < 5.2.9 and libxml 2.7.0 to 2.7.2 on any version) if we don't have xmlreader.
|
|
|
elseif (!extension_loaded('xmlreader'))
|
|
|
@@ -1244,7 +1241,7 @@ class SimplePie
|
|
|
}
|
|
|
if (!$xml_is_sane)
|
|
|
{
|
|
|
- return SIMPLEPIE_INIT_FAIL;
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1276,11 +1273,11 @@ class SimplePie
|
|
|
}
|
|
|
$i++;
|
|
|
}
|
|
|
- return inval($success);
|
|
|
+ return (bool) $success;
|
|
|
}
|
|
|
elseif ($this->feed_url === null && $this->raw_data === null)
|
|
|
{
|
|
|
- return SIMPLEPIE_INIT_FAIL;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
$this->error = null;
|
|
|
@@ -1301,10 +1298,10 @@ class SimplePie
|
|
|
// Fetch the data via SimplePie_File into $this->raw_data
|
|
|
if (($fetched = $this->fetch_data($cache)) === true)
|
|
|
{
|
|
|
- return SIMPLEPIE_INIT_CACHE;
|
|
|
+ return $this->data['mtime']; //FreshRSS
|
|
|
}
|
|
|
elseif ($fetched === false) {
|
|
|
- return SIMPLEPIE_INIT_FAIL;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
list($headers, $sniffed) = $fetched;
|
|
|
@@ -1381,7 +1378,7 @@ class SimplePie
|
|
|
{
|
|
|
$this->error = "A feed could not be found at $this->feed_url. This does not appear to be a valid RSS or Atom feed.";
|
|
|
$this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__));
|
|
|
- return SIMPLEPIE_INIT_FAIL;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
if (isset($headers))
|
|
|
@@ -1389,13 +1386,14 @@ class SimplePie
|
|
|
$this->data['headers'] = $headers;
|
|
|
}
|
|
|
$this->data['build'] = SIMPLEPIE_BUILD;
|
|
|
+ $this->data['mtime'] = time(); //FreshRSS
|
|
|
|
|
|
// Cache the file if caching is enabled
|
|
|
if ($cache && !$cache->save($this))
|
|
|
{
|
|
|
trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
|
|
|
}
|
|
|
- return SIMPLEPIE_INIT_SUCCESS;
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1412,7 +1410,7 @@ class SimplePie
|
|
|
|
|
|
$this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__));
|
|
|
|
|
|
- return SIMPLEPIE_INIT_FAIL;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1558,6 +1556,7 @@ class SimplePie
|
|
|
if ($cache)
|
|
|
{
|
|
|
$this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
|
|
|
+ $this->data['mtime'] = time(); //FreshRSS
|
|
|
if (!$cache->save($this))
|
|
|
{
|
|
|
trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
|