A free, self-hostable news aggregator…
SimplePie light manual update
Alexandre Alapetitecc235c6af36e
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.phpindex afcde3d7f..0167695ca 100644--- a/app/Models/EntryDAO.php+++ b/app/Models/EntryDAO.php@@ -157,7 +157,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {$info = $this->addEntryPrepared == null ? array(0 => '', 1 => '', 2 => 'syntax error') : $this->addEntryPrepared->errorInfo();if ($this->autoUpdateDb($info)) {return $this->addEntry($valuesTmp);- } elseif ((int)($info[0] / 1000) !== 23) { //Filter out "SQLSTATE Class code 23: Constraint Violation" because of expected duplicate entries+ } elseif ((int)((int)$info[0] / 1000) !== 23) { //Filter out "SQLSTATE Class code 23: Constraint Violation" because of expected duplicate entriesMinz_Log::error('SQL error addEntry: ' . $info[0] . ': ' . $info[1] . ' ' . $info[2]. ' while adding entry in feed ' . $valuesTmp['id_feed'] . ' with title: ' . $valuesTmp['title']);}diff --git a/lib/SimplePie/SimplePie.php b/lib/SimplePie/SimplePie.phpindex 0f2fdbb87..7240fdf66 100644--- a/lib/SimplePie/SimplePie.php+++ b/lib/SimplePie/SimplePie.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -34,7 +34,7 @@** @package SimplePie* @version 1.4-dev-FreshRSS- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCue@@ -614,6 +614,12 @@ class SimplePie*/public $item_limit = 0;+ /**+ * @var bool Stores if last-modified and/or etag headers were sent with the+ * request when checking a feed.+ */+ public $check_modified = false;+/*** @var array Stores the default attributes to be stripped by strip_attributes().* @see SimplePie::strip_attributes()@@ -626,7 +632,7 @@ class SimplePie* @see SimplePie::add_attributes()* @access private*/- public $add_attributes = array('audio' => array('preload' => 'none'), 'iframe' => array('sandbox' => 'allow-scripts allow-same-origin'), 'video' => array('preload' => 'none')); //FreshRSS+ public $add_attributes = array('audio' => array('preload' => 'none'), 'iframe' => array('sandbox' => 'allow-scripts allow-same-origin'), 'video' => array('preload' => 'none'));/*** @var array Stores the default tags to be stripped by strip_htmltags().@@ -657,9 +663,9 @@ class SimplePie*/public function __construct(){- if (version_compare(PHP_VERSION, '5.2', '<'))+ if (version_compare(PHP_VERSION, '5.3', '<')){- trigger_error('PHP 4.x, 5.0 and 5.1 are no longer supported. Please upgrade to PHP 5.2 or newer.');+ trigger_error('Please upgrade to PHP 5.3 or newer.');die();}@@ -814,7 +820,7 @@ class SimplePie{$this->timeout = (int) $timeout;}-+/*** Set custom curl options*@@ -1169,7 +1175,7 @@ class SimplePie$this->sanitize->strip_attributes($attribs);}- public function add_attributes($attribs = '') //FreshRSS+ public function add_attributes($attribs = ''){if ($attribs === ''){@@ -1191,11 +1197,11 @@ class SimplePie** Allows you to override SimplePie's output to match that of your webpage.* This is useful for times when your webpages are not being served as- * UTF-8. This setting will be obeyed by {@see handle_content_type()}, and+ * UTF-8. This setting will be obeyed by {@see handle_content_type()}, and* is similar to {@see set_input_encoding()}.** It should be noted, however, that not all character encodings can support- * all characters. If your page is being served as ISO-8859-1 and you try+ * all characters. If your page is being served as ISO-8859-1 and you try* to display a Japanese feed, you'll likely see garbled characters.* Because of this, it is highly recommended to ensure that your webpages* are served as UTF-8.@@ -1293,7 +1299,7 @@ class SimplePie/*** Initialize the feed object*- * This is what makes everything happen. Period. This is where all of the+ * This is what makes everything happen. Period. This is where all of the* configuration options get processed, feeds are fetched, cached, and* parsed, and all of that other good stuff.*@@ -1361,6 +1367,7 @@ class SimplePie$this->error = null;$this->data = array();+ $this->check_modified = false;$this->multifeed_objects = array();$cache = false;@@ -1380,6 +1387,7 @@ class SimplePiereturn $this->data['mtime'];}elseif ($fetched === false) {+ $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__));return false;}@@ -1486,11 +1494,19 @@ class SimplePieif (isset($parser)){// We have an error, just set SimplePie_Misc::error to it and quit- $this->error = sprintf('This XML document is invalid, likely due to invalid characters. XML error: %s at line %d, column %d, encoding %s, URL: %s', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column(), $encoding, $this->feed_url);+ $this->error = $this->feed_url;+ $this->error .= sprintf(' is invalid XML, likely due to invalid characters. XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());}else{- $this->error = 'The data could not be converted to UTF-8. You MUST have either the iconv or mbstring extension installed. Upgrading to PHP 5.x (which includes iconv) is highly recommended.';+ $this->error = 'The data could not be converted to UTF-8.';+ if (!extension_loaded('mbstring') && !extension_loaded('iconv')) {+ $this->error .= ' You MUST have either the iconv or mbstring extension installed.';+ } elseif (!extension_loaded('mbstring')) {+ $this->error .= ' Try installing the mbstring extension.';+ } elseif (!extension_loaded('iconv')) {+ $this->error .= ' Try installing the iconv extension.';+ }}$this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__));@@ -1575,6 +1591,7 @@ class SimplePie}else{+ $this->check_modified = false;$cache->touch();$this->error = $file->error;return !empty($this->data);@@ -1669,7 +1686,7 @@ class SimplePie$locate = null;}- $file->body = trim($file->body);+ $file->body = trim($file->body); //FreshRSS$this->raw_data = $file->body;$this->permanent_url = $file->permanent_url;$headers = $file->headers;@@ -1870,7 +1887,7 @@ class SimplePie* @todo Support <itunes:new-feed-url>* @todo Also, |atom:link|@rel=self* @param bool $permanent Permanent mode to return only the original URL or the first redirection- * iff it is a 301 redirection+ * iff it is a 301 redirection* @return string|null*/public function subscribe_url($permanent = false)@@ -2169,7 +2186,7 @@ class SimplePie* Get a category for the feed** @since Unknown- * @param int $key The category that you want to return. Remember that arrays begin with 0, not 1+ * @param int $key The category that you want to return. Remember that arrays begin with 0, not 1* @return SimplePie_Category|null*/public function get_category($key = 0)@@ -2254,7 +2271,7 @@ class SimplePie* Get an author for the feed** @since 1.1- * @param int $key The author that you want to return. Remember that arrays begin with 0, not 1+ * @param int $key The author that you want to return. Remember that arrays begin with 0, not 1* @return SimplePie_Author|null*/public function get_author($key = 0)@@ -2352,7 +2369,7 @@ class SimplePie* Get a contributor for the feed** @since 1.1- * @param int $key The contrbutor that you want to return. Remember that arrays begin with 0, not 1+ * @param int $key The contrbutor that you want to return. Remember that arrays begin with 0, not 1* @return SimplePie_Author|null*/public function get_contributor($key = 0)@@ -2438,7 +2455,7 @@ class SimplePie* Get a single link for the feed** @since 1.0 (previously called `get_feed_link` since Preview Release, `get_feed_permalink()` since 0.8)- * @param int $key The link that you want to return. Remember that arrays begin with 0, not 1+ * @param int $key The link that you want to return. Remember that arrays begin with 0, not 1* @param string $rel The relationship of the link to return* @return string|null Link URL*/@@ -2949,7 +2966,7 @@ class SimplePie** @see get_item_quantity()* @since Beta 2- * @param int $key The item that you want to return. Remember that arrays begin with 0, not 1+ * @param int $key The item that you want to return. Remember that arrays begin with 0, not 1* @return SimplePie_Item|null*/public function get_item($key = 0)@@ -2976,7 +2993,7 @@ class SimplePie* @since Beta 2* @param int $start Index to start at* @param int $end Number of items to return. 0 for all items after `$start`- * @return array|null List of {@see SimplePie_Item} objects+ * @return SimplePie_Item[]|null List of {@see SimplePie_Item} objects*/public function get_items($start = 0, $end = 0){@@ -3147,7 +3164,19 @@ class SimplePie*/public static function sort_items($a, $b){- return $a->get_date('U') <= $b->get_date('U');+ $a_date = $a->get_date('U');+ $b_date = $b->get_date('U');+ if ($a_date && $b_date) {+ return $a_date > $b_date ? -1 : 1;+ }+ // Sort items without dates to the top.+ if ($a_date) {+ return 1;+ }+ if ($b_date) {+ return -1;+ }+ return 0;}/**@@ -3180,20 +3209,7 @@ class SimplePie}}- $do_sort = true;- foreach ($items as $item)- {- if (!$item->get_date('U'))- {- $do_sort = false;- break;- }- }- $item = null;- if ($do_sort)- {- usort($items, array(get_class($urls[0]), 'sort_items'));- }+ usort($items, array(get_class($urls[0]), 'sort_items'));if ($end === 0){diff --git a/lib/SimplePie/SimplePie/Author.php b/lib/SimplePie/SimplePie/Author.phpindex 19563c5cc..e6768ff29 100644--- a/lib/SimplePie/SimplePie/Author.php+++ b/lib/SimplePie/SimplePie/Author.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/Cache.php b/lib/SimplePie/SimplePie/Cache.phpindex 86b618693..d98cc6511 100644--- a/lib/SimplePie/SimplePie/Cache.php+++ b/lib/SimplePie/SimplePie/Cache.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCue@@ -62,8 +61,10 @@ class SimplePie_Cache* @var array*/protected static $handlers = array(- 'mysql' => 'SimplePie_Cache_MySQL',- 'memcache' => 'SimplePie_Cache_Memcache',+ 'mysql' => 'SimplePie_Cache_MySQL',+ 'memcache' => 'SimplePie_Cache_Memcache',+ 'memcached' => 'SimplePie_Cache_Memcached',+ 'redis' => 'SimplePie_Cache_Redis');/**diff --git a/lib/SimplePie/SimplePie/Cache/Base.php b/lib/SimplePie/SimplePie/Cache/Base.phpindex d3f353961..333fb05cf 100644--- a/lib/SimplePie/SimplePie/Cache/Base.php+++ b/lib/SimplePie/SimplePie/Cache/Base.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/Cache/DB.php b/lib/SimplePie/SimplePie/Cache/DB.phpindex d728a9a6d..7e8f77532 100644--- a/lib/SimplePie/SimplePie/Cache/DB.php+++ b/lib/SimplePie/SimplePie/Cache/DB.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/Cache/File.php b/lib/SimplePie/SimplePie/Cache/File.phpindex 72e75a4b6..6ba6c5f6e 100644--- a/lib/SimplePie/SimplePie/Cache/File.php+++ b/lib/SimplePie/SimplePie/Cache/File.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/Cache/Memcache.php b/lib/SimplePie/SimplePie/Cache/Memcache.phpindex 23b1c9367..5190eef93 100644--- a/lib/SimplePie/SimplePie/Cache/Memcache.php+++ b/lib/SimplePie/SimplePie/Cache/Memcache.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/Cache/Memcached.php b/lib/SimplePie/SimplePie/Cache/Memcached.phpnew file mode 100644index 000000000..1f73b3890--- /dev/null+++ b/lib/SimplePie/SimplePie/Cache/Memcached.php@@ -0,0 +1,166 @@+<?php+/**+ * SimplePie+ *+ * A PHP-Based RSS and Atom Feed Framework.+ * Takes the hard work out of managing a complete RSS/Atom solution.+ *+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * All rights reserved.+ *+ * Redistribution and use in source and binary forms, with or without modification, are+ * permitted provided that the following conditions are met:+ *+ * * Redistributions of source code must retain the above copyright notice, this list of+ * conditions and the following disclaimer.+ *+ * * Redistributions in binary form must reproduce the above copyright notice, this list+ * of conditions and the following disclaimer in the documentation and/or other materials+ * provided with the distribution.+ *+ * * Neither the name of the SimplePie Team nor the names of its contributors may be used+ * to endorse or promote products derived from this software without specific prior+ * written permission.+ *+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS+ * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE+ * POSSIBILITY OF SUCH DAMAGE.+ *+ * @package SimplePie+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @author Ryan Parman+ * @author Geoffrey Sneddon+ * @author Ryan McCue+ * @link http://simplepie.org/ SimplePie+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License+ */++/**+ * Caches data to memcached+ *+ * Registered for URLs with the "memcached" protocol+ *+ * For example, `memcached://localhost:11211/?timeout=3600&prefix=sp_` will+ * connect to memcached on `localhost` on port 11211. All tables will be+ * prefixed with `sp_` and data will expire after 3600 seconds+ *+ * @package SimplePie+ * @subpackage Caching+ * @author Paul L. McNeely+ * @uses Memcached+ */+class SimplePie_Cache_Memcached implements SimplePie_Cache_Base+{+ /**+ * Memcached instance+ * @var Memcached+ */+ protected $cache;++ /**+ * Options+ * @var array+ */+ protected $options;++ /**+ * Cache name+ * @var string+ */+ protected $name;++ /**+ * Create a new cache object+ * @param string $location Location string (from SimplePie::$cache_location)+ * @param string $name Unique ID for the cache+ * @param string $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data+ */+ public function __construct($location, $name, $type) {+ $this->options = array(+ 'host' => '127.0.0.1',+ 'port' => 11211,+ 'extras' => array(+ 'timeout' => 3600, // one hour+ 'prefix' => 'simplepie_',+ ),+ );+ $this->options = SimplePie_Misc::array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location));++ $this->name = $this->options['extras']['prefix'] . md5("$name:$type");++ $this->cache = new Memcached();+ $this->cache->addServer($this->options['host'], (int)$this->options['port']);+ }++ /**+ * Save data to the cache+ * @param array|SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property+ * @return bool Successfulness+ */+ public function save($data) {+ if ($data instanceof SimplePie) {+ $data = $data->data;+ }++ return $this->setData(serialize($data));+ }++ /**+ * Retrieve the data saved to the cache+ * @return array Data for SimplePie::$data+ */+ public function load() {+ $data = $this->cache->get($this->name);++ if ($data !== false) {+ return unserialize($data);+ }+ return false;+ }++ /**+ * Retrieve the last modified time for the cache+ * @return int Timestamp+ */+ public function mtime() {+ $data = $this->cache->get($this->name . '_mtime');+ return (int) $data;+ }++ /**+ * Set the last modified time to the current time+ * @return bool Success status+ */+ public function touch() {+ $data = $this->cache->get($this->name);+ return $this->setData($data);+ }++ /**+ * Remove the cache+ * @return bool Success status+ */+ public function unlink() {+ return $this->cache->delete($this->name, 0);+ }++ /**+ * Set the last modified time and data to Memcached+ * @return bool Success status+ */+ private function setData($data) {++ if ($data !== false) {+ $this->cache->set($this->name . '_mtime', time(), (int)$this->options['extras']['timeout']);+ return $this->cache->set($this->name, $data, (int)$this->options['extras']['timeout']);+ }++ return false;+ }+}diff --git a/lib/SimplePie/SimplePie/Cache/MySQL.php b/lib/SimplePie/SimplePie/Cache/MySQL.phpindex 511ef6d3a..8686b6c67 100644--- a/lib/SimplePie/SimplePie/Cache/MySQL.php+++ b/lib/SimplePie/SimplePie/Cache/MySQL.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCue@@ -94,6 +93,7 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB'path' => '','extras' => array('prefix' => '',+ 'cache_purge_time' => 2592000),);@@ -131,16 +131,20 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB$query = $this->mysql->exec('CREATE TABLE `' . $this->options['extras']['prefix'] . 'cache_data` (`id` TEXT CHARACTER SET utf8 NOT NULL, `items` SMALLINT NOT NULL DEFAULT 0, `data` BLOB NOT NULL, `mtime` INT UNSIGNED NOT NULL, UNIQUE (`id`(125)))');if ($query === false){+ trigger_error("Can't create " . $this->options['extras']['prefix'] . "cache_data table, check permissions", E_USER_WARNING);$this->mysql = null;+ return;}}if (!in_array($this->options['extras']['prefix'] . 'items', $db)){- $query = $this->mysql->exec('CREATE TABLE `' . $this->options['extras']['prefix'] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` MEDIUMBLOB CHARACTER SET utf8 NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))');+ $query = $this->mysql->exec('CREATE TABLE `' . $this->options['extras']['prefix'] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` MEDIUMBLOB NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))');if ($query === false){+ trigger_error("Can't create " . $this->options['extras']['prefix'] . "items table, check permissions", E_USER_WARNING);$this->mysql = null;+ return;}}}@@ -158,6 +162,17 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DBreturn false;}+ $query = $this->mysql->prepare('DELETE i, cd FROM `' . $this->options['extras']['prefix'] . 'cache_data` cd, ' .+ '`' . $this->options['extras']['prefix'] . 'items` i ' .+ 'WHERE cd.id = i.feed_id ' .+ 'AND cd.mtime < (unix_timestamp() - :purge_time)');+ $query->bindValue(':purge_time', $this->options['extras']['cache_purge_time']);++ if (!$query->execute())+ {+ return false;+ }+if ($data instanceof SimplePie){$data = clone $data;diff --git a/lib/SimplePie/SimplePie/Cache/Redis.php b/lib/SimplePie/SimplePie/Cache/Redis.phpnew file mode 100644index 000000000..04d72c79a--- /dev/null+++ b/lib/SimplePie/SimplePie/Cache/Redis.php@@ -0,0 +1,166 @@+<?php++/**+ * SimplePie Redis Cache Extension+ *+ * @package SimplePie+ * @author Jan Kozak <[email protected]>+ * @link http://galvani.cz/+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License+ * @version 0.2.9+ */+++/**+ * Caches data to redis+ *+ * Registered for URLs with the "redis" protocol+ *+ * For example, `redis://localhost:6379/?timeout=3600&prefix=sp_&dbIndex=0` will+ * connect to redis on `localhost` on port 6379. All tables will be+ * prefixed with `simple_primary-` and data will expire after 3600 seconds+ *+ * @package SimplePie+ * @subpackage Caching+ * @uses Redis+ */+class SimplePie_Cache_Redis implements SimplePie_Cache_Base {+ /**+ * Redis instance+ *+ * @var \Redis+ */+ protected $cache;++ /**+ * Options+ *+ * @var array+ */+ protected $options;++ /**+ * Cache name+ *+ * @var string+ */+ protected $name;++ /**+ * Cache Data+ *+ * @var type+ */+ protected $data;++ /**+ * Create a new cache object+ *+ * @param string $location Location string (from SimplePie::$cache_location)+ * @param string $name Unique ID for the cache+ * @param string $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data+ */+ public function __construct($location, $name, $options = null) {+ //$this->cache = \flow\simple\cache\Redis::getRedisClientInstance();+ $parsed = SimplePie_Cache::parse_URL($location);+ $redis = new Redis();+ $redis->connect($parsed['host'], $parsed['port']);+ $this->cache = $redis;++ if (!is_null($options) && is_array($options)) {+ $this->options = $options;+ } else {+ $this->options = array (+ 'prefix' => 'rss:simple_primary:',+ 'expire' => 0,+ );+ }++ $this->name = $this->options['prefix'] . $name;+ }++ /**+ * @param \Redis $cache+ */+ public function setRedisClient(\Redis $cache) {+ $this->cache = $cache;+ }++ /**+ * Save data to the cache+ *+ * @param array|SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property+ * @return bool Successfulness+ */+ public function save($data) {+ if ($data instanceof SimplePie) {+ $data = $data->data;+ }+ $response = $this->cache->set($this->name, serialize($data));+ if ($this->options['expire']) {+ $this->cache->expire($this->name, $this->options['expire']);+ }++ return $response;+ }++ /**+ * Retrieve the data saved to the cache+ *+ * @return array Data for SimplePie::$data+ */+ public function load() {+ $data = $this->cache->get($this->name);++ if ($data !== false) {+ return unserialize($data);+ }+ return false;+ }++ /**+ * Retrieve the last modified time for the cache+ *+ * @return int Timestamp+ */+ public function mtime() {++ $data = $this->cache->get($this->name);++ if ($data !== false) {+ return time();+ }++ return false;+ }++ /**+ * Set the last modified time to the current time+ *+ * @return bool Success status+ */+ public function touch() {++ $data = $this->cache->get($this->name);++ if ($data !== false) {+ $return = $this->cache->set($this->name, $data);+ if ($this->options['expire']) {+ return $this->cache->expire($this->name, $this->ttl);+ }+ return $return;+ }++ return false;+ }++ /**+ * Remove the cache+ *+ * @return bool Success status+ */+ public function unlink() {+ return $this->cache->set($this->name, null);+ }++}diff --git a/lib/SimplePie/SimplePie/Caption.php b/lib/SimplePie/SimplePie/Caption.phpindex a77b02ef1..abf07de1b 100644--- a/lib/SimplePie/SimplePie/Caption.php+++ b/lib/SimplePie/SimplePie/Caption.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/Category.php b/lib/SimplePie/SimplePie/Category.phpindex c6a273989..92d511e1a 100644--- a/lib/SimplePie/SimplePie/Category.php+++ b/lib/SimplePie/SimplePie/Category.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/Content/Type/Sniffer.php b/lib/SimplePie/SimplePie/Content/Type/Sniffer.phpindex ec0bf0952..b68b73134 100644--- a/lib/SimplePie/SimplePie/Content/Type/Sniffer.php+++ b/lib/SimplePie/SimplePie/Content/Type/Sniffer.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/Copyright.php b/lib/SimplePie/SimplePie/Copyright.phpindex 09f22f8df..3f3d07d3b 100644--- a/lib/SimplePie/SimplePie/Copyright.php+++ b/lib/SimplePie/SimplePie/Copyright.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/Core.php b/lib/SimplePie/SimplePie/Core.phpindex 7cf34876f..c856ba361 100644--- a/lib/SimplePie/SimplePie/Core.php+++ b/lib/SimplePie/SimplePie/Core.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2009, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/Credit.php b/lib/SimplePie/SimplePie/Credit.phpindex 50aef1c68..9bad9ef34 100644--- a/lib/SimplePie/SimplePie/Credit.php+++ b/lib/SimplePie/SimplePie/Credit.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/Decode/HTML/Entities.php b/lib/SimplePie/SimplePie/Decode/HTML/Entities.phpindex 46b3a1dff..de3f2cb53 100644--- a/lib/SimplePie/SimplePie/Decode/HTML/Entities.php+++ b/lib/SimplePie/SimplePie/Decode/HTML/Entities.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/Enclosure.php b/lib/SimplePie/SimplePie/Enclosure.phpindex fa0217800..15060e193 100644--- a/lib/SimplePie/SimplePie/Enclosure.php+++ b/lib/SimplePie/SimplePie/Enclosure.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCue@@ -451,7 +450,7 @@ class SimplePie_Enclosure/*** Get the duration of the enclosure*- * @param string $convert Convert seconds into hh:mm:ss+ * @param bool $convert Convert seconds into hh:mm:ss* @return string|int|null 'hh:mm:ss' string if `$convert` was specified, otherwise integer (or null if none found)*/public function get_duration($convert = false)diff --git a/lib/SimplePie/SimplePie/Exception.php b/lib/SimplePie/SimplePie/Exception.phpindex 73e104d69..53c015e77 100644--- a/lib/SimplePie/SimplePie/Exception.php+++ b/lib/SimplePie/SimplePie/Exception.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/File.php b/lib/SimplePie/SimplePie/File.phpindex 45994d102..c1fab42dc 100644--- a/lib/SimplePie/SimplePie/File.php+++ b/lib/SimplePie/SimplePie/File.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCue@@ -64,7 +63,7 @@ class SimplePie_Filevar $redirects = 0;var $error;var $method = SIMPLEPIE_FILE_SOURCE_NONE;- var $permanent_url; //FreshRSS+ var $permanent_url;public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false, $curl_options = array(), $syslog_enabled = SIMPLEPIE_SYSLOG){@@ -108,6 +107,7 @@ class SimplePie_Filecurl_setopt($fp, CURLOPT_URL, $url);curl_setopt($fp, CURLOPT_HEADER, 1);curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);+ curl_setopt($fp, CURLOPT_FAILONERROR, 1);curl_setopt($fp, CURLOPT_TIMEOUT, $timeout);curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout);curl_setopt($fp, CURLOPT_REFERER, $url);@@ -144,7 +144,7 @@ class SimplePie_Fileif ($parser->parse()){$this->headers = $parser->headers;- $this->body = $parser->body;+ $this->body = trim($parser->body);$this->status_code = $parser->status_code;if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects){@@ -237,7 +237,7 @@ class SimplePie_File$location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);$previousStatusCode = $this->status_code;$this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);- $this->permanent_url = ($previousStatusCode == 301) ? $location : $url; //FreshRSS+ $this->permanent_url = ($previousStatusCode == 301) ? $location : $url;return;}if (isset($this->headers['content-encoding']))@@ -255,7 +255,7 @@ class SimplePie_File}else{- $this->body = $decoder->data;+ $this->body = trim($decoder->data);}break;@@ -298,7 +298,7 @@ class SimplePie_Fileelse{$this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS;- if (empty($url) || !($this->body = file_get_contents($url)))+ if (empty($url) || !($this->body = trim(file_get_contents($url)))){$this->error = 'file_get_contents could not read the file';$this->success = false;diff --git a/lib/SimplePie/SimplePie/HTTP/Parser.php b/lib/SimplePie/SimplePie/HTTP/Parser.phpindex 2fc3a6779..63ae1e03d 100644--- a/lib/SimplePie/SimplePie/HTTP/Parser.php+++ b/lib/SimplePie/SimplePie/HTTP/Parser.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/IRI.php b/lib/SimplePie/SimplePie/IRI.phpindex ed0574701..2b3fbaf07 100644--- a/lib/SimplePie/SimplePie/IRI.php+++ b/lib/SimplePie/SimplePie/IRI.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCue@@ -259,6 +258,15 @@ class SimplePie_IRI$this->set_iri($iri);}+ /**+ * Clean up+ */+ public function __destruct() {+ $this->set_iri(null, true);+ $this->set_path(null, true);+ $this->set_authority(null, true);+ }+/*** Create a new IRI object by resolving a relative IRI*@@ -768,24 +776,20 @@ class SimplePie_IRI*/public function is_valid(){- $isauthority = $this->iuserinfo !== null || $this->ihost !== null || $this->port !== null;- if ($this->ipath !== '' &&- (- $isauthority && (- $this->ipath[0] !== '/' ||- substr($this->ipath, 0, 2) === '//'- ) ||- (- $this->scheme === null &&- !$isauthority &&- strpos($this->ipath, ':') !== false &&- (strpos($this->ipath, '/') === false ? true : strpos($this->ipath, ':') < strpos($this->ipath, '/'))- )- )- )- {- return false;- }+ if ($this->ipath === '') return true;++ $isauthority = $this->iuserinfo !== null || $this->ihost !== null ||+ $this->port !== null;+ if ($isauthority && $this->ipath[0] === '/') return true;++ if (!$isauthority && (substr($this->ipath, 0, 2) === '//')) return false;++ // Relative urls cannot have a colon in the first path segment (and the+ // slashes themselves are not included so skip the first character).+ if (!$this->scheme && !$isauthority &&+ strpos($this->ipath, ':') !== false &&+ strpos($this->ipath, '/', 1) !== false &&+ strpos($this->ipath, ':') < strpos($this->ipath, '/', 1)) return false;return true;}@@ -797,9 +801,14 @@ class SimplePie_IRI* @param string $iri* @return bool*/- public function set_iri($iri)+ public function set_iri($iri, $clear_cache = false){static $cache;+ if ($clear_cache)+ {+ $cache = null;+ return;+ }if (!$cache){$cache = array();@@ -879,9 +888,14 @@ class SimplePie_IRI* @param string $authority* @return bool*/- public function set_authority($authority)+ public function set_authority($authority, $clear_cache = false){static $cache;+ if ($clear_cache)+ {+ $cache = null;+ return;+ }if (!$cache)$cache = array();@@ -1049,9 +1063,14 @@ class SimplePie_IRI* @param string $ipath* @return bool*/- public function set_path($ipath)+ public function set_path($ipath, $clear_cache = false){static $cache;+ if ($clear_cache)+ {+ $cache = null;+ return;+ }if (!$cache){$cache = array();diff --git a/lib/SimplePie/SimplePie/Item.php b/lib/SimplePie/SimplePie/Item.phpindex 19ba7c8f4..daecf0a15 100644--- a/lib/SimplePie/SimplePie/Item.php+++ b/lib/SimplePie/SimplePie/Item.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCue@@ -203,14 +202,13 @@ class SimplePie_Item** Uses `<atom:id>`, `<guid>`, `<dc:identifier>` or the `about` attribute* for RDF. If none of these are supplied (or `$hash` is true), creates an- * MD5 hash based on the permalink and title. If either of those are not- * supplied, creates a hash based on the full feed data.+ * MD5 hash based on the permalink, title and content.** @since Beta 2* @param boolean $hash Should we force using a hash instead of the supplied ID?* @return string*/- public function get_id($hash = false)+ public function get_id($hash = false, $fn = ''){if (!$hash){@@ -238,23 +236,10 @@ class SimplePie_Item{return $this->sanitize($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'], SIMPLEPIE_CONSTRUCT_TEXT);}- elseif (($return = $this->get_permalink()) !== null)- {- return $return;- }- elseif (($return = $this->get_title()) !== null)- {- return $return;- }- }- if ($this->get_permalink() !== null || $this->get_title() !== null)- {- return md5($this->get_permalink() . $this->get_title());- }- else- {- return md5(serialize($this->data));}+ if ($fn === '' || !is_callable($fn)) $fn = 'md5';+ return call_user_func($fn,+ $this->get_permalink().$this->get_title().$this->get_content());}/**@@ -457,7 +442,7 @@ class SimplePie_Item* Uses `<atom:category>`, `<category>` or `<dc:subject>`** @since Beta 3- * @return array|null List of {@see SimplePie_Category} objects+ * @return SimplePie_Category[]|null List of {@see SimplePie_Category} objects*/public function get_categories(){@@ -1105,7 +1090,7 @@ class SimplePie_Item* @since Beta 2* @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4).* @todo If an element exists at a level, but its value is empty, we should fall back to the value from the parent (if it exists).- * @return array|null List of SimplePie_Enclosure items+ * @return SimplePie_Enclosure[]|null List of SimplePie_Enclosure items*/public function get_enclosures(){@@ -2682,7 +2667,9 @@ class SimplePie_Item// PLAYERif (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])){- $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'])) {+ $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);+ }}else{diff --git a/lib/SimplePie/SimplePie/Locator.php b/lib/SimplePie/SimplePie/Locator.phpindex ba4a843b0..36bc02895 100644--- a/lib/SimplePie/SimplePie/Locator.php+++ b/lib/SimplePie/SimplePie/Locator.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCue@@ -226,7 +225,7 @@ class SimplePie_Locator}if ($link->hasAttribute('href') && $link->hasAttribute('rel')){- $rel = array_unique($this->registry->call('Misc', 'space_seperated_tokens', array(strtolower($link->getAttribute('rel')))));+ $rel = array_unique($this->registry->call('Misc', 'space_separated_tokens', array(strtolower($link->getAttribute('rel')))));$line = method_exists($link, 'getLineNo') ? $link->getLineNo() : 1;if ($this->base_location < $line)@@ -275,7 +274,7 @@ class SimplePie_Locator{$href = trim($link->getAttribute('href'));$parsed = $this->registry->call('Misc', 'parse_url', array($href));- if ($parsed['scheme'] === '' || preg_match('/^(http(s)|feed)?$/i', $parsed['scheme']))+ if ($parsed['scheme'] === '' || preg_match('/^(https?|feed)?$/i', $parsed['scheme'])){if (method_exists($link, 'getLineNo') && $this->base_location < $link->getLineNo()){@@ -312,6 +311,57 @@ class SimplePie_Locatorreturn null;}+ public function get_rel_link($rel)+ {+ if ($this->dom === null)+ {+ throw new SimplePie_Exception('DOMDocument not found, unable to use '.+ 'locator');+ }+ if (!class_exists('DOMXpath'))+ {+ throw new SimplePie_Exception('DOMXpath not found, unable to use '.+ 'get_rel_link');+ }++ $xpath = new DOMXpath($this->dom);+ $query = '//a[@rel and @href] | //link[@rel and @href]';+ foreach ($xpath->query($query) as $link)+ {+ $href = trim($link->getAttribute('href'));+ $parsed = $this->registry->call('Misc', 'parse_url', array($href));+ if ($parsed['scheme'] === '' ||+ preg_match('/^https?$/i', $parsed['scheme']))+ {+ if (method_exists($link, 'getLineNo') &&+ $this->base_location < $link->getLineNo())+ {+ $href =+ $this->registry->call('Misc', 'absolutize_url',+ array(trim($link->getAttribute('href')),+ $this->base));+ }+ else+ {+ $href =+ $this->registry->call('Misc', 'absolutize_url',+ array(trim($link->getAttribute('href')),+ $this->http_base));+ }+ if ($href === false)+ {+ return null;+ }+ $rel_values = explode(' ', strtolower($link->getAttribute('rel')));+ if (in_array($rel, $rel_values))+ {+ return $href;+ }+ }+ }+ return null;+ }+public function extension(&$array){foreach ($array as $key => $value)diff --git a/lib/SimplePie/SimplePie/Misc.php b/lib/SimplePie/SimplePie/Misc.phpindex 2d154cbcb..ca2810611 100644--- a/lib/SimplePie/SimplePie/Misc.php+++ b/lib/SimplePie/SimplePie/Misc.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCue@@ -1947,7 +1946,7 @@ class SimplePie_Miscreturn (bool) preg_match('/^([A-Za-z0-9\-._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!$&\'()*+,;=@]|(%[0-9ABCDEF]{2}))+$/u', $string);}- public static function space_seperated_tokens($string)+ public static function space_separated_tokens($string){$space_characters = "\x20\x09\x0A\x0B\x0C\x0D";$string_length = strlen($string);@@ -2178,7 +2177,8 @@ function embed_wmedia(width, height, link) {/*** Get the SimplePie build timestamp*- * Return SimplePie.php modification time.+ * Uses the git index if it exists, otherwise uses the modification time+ * of the newest file.*/public static function get_build(){diff --git a/lib/SimplePie/SimplePie/Net/IPv6.php b/lib/SimplePie/SimplePie/Net/IPv6.phpindex 2ff1afc90..47658aff2 100644--- a/lib/SimplePie/SimplePie/Net/IPv6.php+++ b/lib/SimplePie/SimplePie/Net/IPv6.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/Parse/Date.php b/lib/SimplePie/SimplePie/Parse/Date.phpindex 50bb5cffa..1f2156655 100644--- a/lib/SimplePie/SimplePie/Parse/Date.php+++ b/lib/SimplePie/SimplePie/Parse/Date.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCue@@ -331,8 +330,8 @@ class SimplePie_Parse_Date'CCT' => 23400,'CDT' => -18000,'CEDT' => 7200,- 'CET' => 3600,'CEST' => 7200,+ 'CET' => 3600,'CGST' => -7200,'CGT' => -10800,'CHADT' => 49500,@@ -631,7 +630,7 @@ class SimplePie_Parse_Date/*** Parse a superset of W3C-DTF (allows hyphens and colons to be omitted, as* well as allowing any of upper or lower case "T", horizontal tabs, or- * spaces to be used as the time seperator (including more than one))+ * spaces to be used as the time separator (including more than one))** @access protected* @return int Timestamp@@ -691,7 +690,7 @@ class SimplePie_Parse_Date}// Convert the number of seconds to an integer, taking decimals into account- $second = round($match[6] + $match[7] / pow(10, strlen($match[7])));+ $second = round((int)$match[6] + (int)$match[7] / pow(10, strlen($match[7])));return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone;}diff --git a/lib/SimplePie/SimplePie/Parser.php b/lib/SimplePie/SimplePie/Parser.phpindex 7fb7bd9be..e3966218c 100644--- a/lib/SimplePie/SimplePie/Parser.php+++ b/lib/SimplePie/SimplePie/Parser.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/Rating.php b/lib/SimplePie/SimplePie/Rating.phpindex b5fe80516..eaf57080c 100644--- a/lib/SimplePie/SimplePie/Rating.php+++ b/lib/SimplePie/SimplePie/Rating.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/Registry.php b/lib/SimplePie/SimplePie/Registry.phpindex dac55e34e..e0909bb74 100755--- a/lib/SimplePie/SimplePie/Registry.php+++ b/lib/SimplePie/SimplePie/Registry.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/Restriction.php b/lib/SimplePie/SimplePie/Restriction.phpindex a1d59916d..001a5cd28 100644--- a/lib/SimplePie/SimplePie/Restriction.php+++ b/lib/SimplePie/SimplePie/Restriction.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/Sanitize.php b/lib/SimplePie/SimplePie/Sanitize.phpindex bdc601100..49fe5dbd5 100644--- a/lib/SimplePie/SimplePie/Sanitize.php+++ b/lib/SimplePie/SimplePie/Sanitize.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCue@@ -348,6 +347,7 @@ class SimplePie_Sanitize}$document = new DOMDocument();$document->encoding = 'UTF-8';+$data = $this->preprocess($data, $type);set_error_handler(array('SimplePie_Misc', 'silence_errors'));diff --git a/lib/SimplePie/SimplePie/Source.php b/lib/SimplePie/SimplePie/Source.phpindex 2613798fd..1a66a392d 100644--- a/lib/SimplePie/SimplePie/Source.php+++ b/lib/SimplePie/SimplePie/Source.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/XML/Declaration/Parser.php b/lib/SimplePie/SimplePie/XML/Declaration/Parser.phpindex 589e452a2..99e751672 100644--- a/lib/SimplePie/SimplePie/XML/Declaration/Parser.php+++ b/lib/SimplePie/SimplePie/XML/Declaration/Parser.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCuediff --git a/lib/SimplePie/SimplePie/gzdecode.php b/lib/SimplePie/SimplePie/gzdecode.phpindex 6e65f0811..0e8bc8fc6 100644--- a/lib/SimplePie/SimplePie/gzdecode.php+++ b/lib/SimplePie/SimplePie/gzdecode.php@@ -5,7 +5,7 @@* A PHP-Based RSS and Atom Feed Framework.* Takes the hard work out of managing a complete RSS/Atom solution.*- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors+ * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors* All rights reserved.** Redistribution and use in source and binary forms, with or without modification, are@@ -33,8 +33,7 @@* POSSIBILITY OF SUCH DAMAGE.** @package SimplePie- * @version 1.4-dev- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue+ * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue* @author Ryan Parman* @author Geoffrey Sneddon* @author Ryan McCue