diff --git a/htdocs/site/simplepie/simplepie.php b/htdocs/site/simplepie/simplepie.php index 1aa58984e..d0283f5a3 100644 --- a/htdocs/site/simplepie/simplepie.php +++ b/htdocs/site/simplepie/simplepie.php @@ -2,6 +2,12 @@ /** * SimplePie * + * A PHP-Based RSS and Atom Feed Framework. + * Takes the hard work out of managing a complete RSS/Atom solution. + * + * Please note: This file is automatically generated by a build script. The + * full original source is always available from http://simplepie.org/ + * * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors * All rights reserved. * @@ -29,13 +35,19 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @version 1.3 + * @package SimplePie + * @version 1.3.1 + * @copyright 2004-2012 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 */ define('SIMPLEPIE_NAME', 'SimplePie'); -define('SIMPLEPIE_VERSION', '1.3'); -define('SIMPLEPIE_BUILD', '20120707113013'); +define('SIMPLEPIE_VERSION', '1.3.1'); +define('SIMPLEPIE_BUILD', '20121030175911'); define('SIMPLEPIE_URL', 'http://simplepie.org'); define('SIMPLEPIE_USERAGENT', SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION . ' (Feed Parser; ' . SIMPLEPIE_URL . '; Allow like Gecko) Build/' . SIMPLEPIE_BUILD); define('SIMPLEPIE_LINKBACK', '' . SIMPLEPIE_NAME . ''); @@ -105,34 +117,63 @@ define('SIMPLEPIE_FILE_SOURCE_CURL', 8); define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16); class SimplePie { + public $data = array(); + public $error; + public $sanitize; + public $useragent = SIMPLEPIE_USERAGENT; + public $feed_url; + public $file; + public $raw_data; + public $timeout = 10; + public $force_fsockopen = false; + public $force_feed = false; + public $cache = true; + public $cache_duration = 3600; + public $autodiscovery_cache_duration = 604800; // 7 Days. + public $cache_location = './cache'; + public $cache_name_function = 'md5'; + public $order_by_date = true; + public $input_encoding = false; + public $autodiscovery = SIMPLEPIE_LOCATOR_ALL; + public $registry; + public $max_checked_feeds = 10; + public $all_discovered_feeds = array(); + public $image_handler = ''; + public $multifeed_url = array(); + public $multifeed_objects = array(); + public $config_settings = null; + public $item_limit = 0; + public $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'); + public $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'); + public function __construct() { if (version_compare(PHP_VERSION, '5.2', '<')) @@ -140,20 +181,31 @@ class SimplePie trigger_error('PHP 4.x, 5.0 and 5.1 are no longer supported. Please upgrade to PHP 5.2 or newer.'); die(); } - // Other objects, instances created here so we can set options on them $this->sanitize = new SimplePie_Sanitize(); $this->registry = new SimplePie_Registry(); - if (func_num_args() > 0) { - trigger_error('Passing parameters to the constructor is no longer supported. Please use set_feed_url(), set_cache_location(), and set_cache_location() directly.'); + $level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; + trigger_error('Passing parameters to the constructor is no longer supported. Please use set_feed_url(), set_cache_location(), and set_cache_location() directly.', $level); + $args = func_get_args(); + switch (count($args)) { + case 3: + $this->set_cache_duration($args[2]); + case 2: + $this->set_cache_location($args[1]); + case 1: + $this->set_feed_url($args[0]); + $this->init(); + } } } + public function __toString() { return md5(serialize($this->data)); } + public function __destruct() { if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) @@ -176,10 +228,12 @@ class SimplePie } } } + public function force_feed($enable = false) { $this->force_feed = (bool) $enable; } + public function set_feed_url($url) { $this->multifeed_url = array(); @@ -195,6 +249,7 @@ class SimplePie $this->feed_url = $this->registry->call('Misc', 'fix_protocol', array($url, 1)); } } + public function set_file(&$file) { if ($file instanceof SimplePie_File) @@ -205,38 +260,47 @@ class SimplePie } return false; } + public function set_raw_data($data) { $this->raw_data = $data; } + public function set_timeout($timeout = 10) { $this->timeout = (int) $timeout; } + public function force_fsockopen($enable = false) { $this->force_fsockopen = (bool) $enable; } + public function enable_cache($enable = true) { $this->cache = (bool) $enable; } + public function set_cache_duration($seconds = 3600) { $this->cache_duration = (int) $seconds; } + public function set_autodiscovery_cache_duration($seconds = 604800) { $this->autodiscovery_cache_duration = (int) $seconds; } + public function set_cache_location($location = './cache') { $this->cache_location = (string) $location; } + public function enable_order_by_date($enable = true) { $this->order_by_date = (bool) $enable; } + public function set_input_encoding($encoding = false) { if ($encoding) @@ -248,86 +312,104 @@ class SimplePie $this->input_encoding = false; } } + public function set_autodiscovery_level($level = SIMPLEPIE_LOCATOR_ALL) { $this->autodiscovery = (int) $level; } + public function &get_registry() { return $this->registry; } - /** - * Set which class SimplePie uses for caching - */ + + public function set_cache_class($class = 'SimplePie_Cache') { return $this->registry->register('Cache', $class, true); } + public function set_locator_class($class = 'SimplePie_Locator') { return $this->registry->register('Locator', $class, true); } + public function set_parser_class($class = 'SimplePie_Parser') { return $this->registry->register('Parser', $class, true); } + public function set_file_class($class = 'SimplePie_File') { return $this->registry->register('File', $class, true); } + public function set_sanitize_class($class = 'SimplePie_Sanitize') { return $this->registry->register('Sanitize', $class, true); } + public function set_item_class($class = 'SimplePie_Item') { return $this->registry->register('Item', $class, true); } + public function set_author_class($class = 'SimplePie_Author') { return $this->registry->register('Author', $class, true); } + public function set_category_class($class = 'SimplePie_Category') { return $this->registry->register('Category', $class, true); } + public function set_enclosure_class($class = 'SimplePie_Enclosure') { return $this->registry->register('Enclosure', $class, true); } + public function set_caption_class($class = 'SimplePie_Caption') { return $this->registry->register('Caption', $class, true); } + public function set_copyright_class($class = 'SimplePie_Copyright') { return $this->registry->register('Copyright', $class, true); } + public function set_credit_class($class = 'SimplePie_Credit') { return $this->registry->register('Credit', $class, true); } + public function set_rating_class($class = 'SimplePie_Rating') { return $this->registry->register('Rating', $class, true); } + public function set_restriction_class($class = 'SimplePie_Restriction') { return $this->registry->register('Restriction', $class, true); } + public function set_content_type_sniffer_class($class = 'SimplePie_Content_Type_Sniffer') { return $this->registry->register('Content_Type_Sniffer', $class, true); } + public function set_source_class($class = 'SimplePie_Source') { return $this->registry->register('Source', $class, true); } + public function set_useragent($ua = SIMPLEPIE_USERAGENT) { $this->useragent = (string) $ua; } + public function set_cache_name_function($function = 'md5') { if (is_callable($function)) @@ -335,6 +417,7 @@ class SimplePie $this->cache_name_function = $function; } } + public function set_stupidly_fast($set = false) { if ($set) @@ -347,16 +430,15 @@ class SimplePie $this->set_image_handler(false); } } + public function set_max_checked_feeds($max = 10) { $this->max_checked_feeds = (int) $max; } - public function remove_div($enable = true) { $this->sanitize->remove_div($enable); } - public function strip_htmltags($tags = '', $encode = null) { if ($tags === '') @@ -369,12 +451,10 @@ class SimplePie $this->sanitize->encode_instead_of_strip($tags); } } - public function encode_instead_of_strip($enable = true) { $this->sanitize->encode_instead_of_strip($enable); } - public function strip_attributes($attribs = '') { if ($attribs === '') @@ -383,19 +463,21 @@ class SimplePie } $this->sanitize->strip_attributes($attribs); } + public function set_output_encoding($encoding = 'UTF-8') { $this->sanitize->set_output_encoding($encoding); } - public function strip_comments($strip = false) { $this->sanitize->strip_comments($strip); } + public function set_url_replacements($element_attribute = null) { $this->sanitize->set_url_replacements($element_attribute); } + public function set_image_handler($page = false, $qs = 'i') { if ($page !== false) @@ -407,10 +489,12 @@ class SimplePie $this->image_handler = ''; } } + public function set_item_limit($limit = 0) { $this->item_limit = (int) $limit; } + public function init() { // Check absolute bare minimum requirements. @@ -434,17 +518,14 @@ class SimplePie return false; } } - if (method_exists($this->sanitize, 'set_registry')) { $this->sanitize->set_registry($this->registry); } - // Pass whatever was set with config options over to the sanitizer. // Pass the classes in for legacy support; new classes should use the registry instead $this->sanitize->pass_cache_data($this->cache, $this->cache_location, $this->cache_name_function, $this->registry->get_class('Cache')); $this->sanitize->pass_file_data($this->registry->get_class('File'), $this->timeout, $this->useragent, $this->force_fsockopen); - if (!empty($this->multifeed_url)) { $i = 0; @@ -469,22 +550,18 @@ class SimplePie { return false; } - $this->error = null; $this->data = array(); $this->multifeed_objects = array(); $cache = false; - if ($this->feed_url !== null) { $parsed_feed_url = $this->registry->call('Misc', 'parse_url', array($this->feed_url)); - // Decide whether to enable caching if ($this->cache && $parsed_feed_url['scheme'] !== '') { - $cache = $this->registry->call('Cache', 'create', array($this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc')); + $cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc')); } - // Fetch the data via SimplePie_File into $this->raw_data if (($fetched = $this->fetch_data($cache)) === true) { @@ -493,22 +570,17 @@ class SimplePie elseif ($fetched === false) { return false; } - list($headers, $sniffed) = $fetched; } - // Set up array of possible encodings $encodings = array(); - // First check to see if input has been overridden. if ($this->input_encoding !== false) { $encodings[] = $this->input_encoding; } - $application_types = array('application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity'); $text_types = array('text/xml', 'text/xml-external-parsed-entity'); - // RFC 3023 (only applies to sniffed content) if (isset($sniffed)) { @@ -535,15 +607,12 @@ class SimplePie $encodings[] = 'US-ASCII'; } } - // Fallback to XML 1.0 Appendix F.1/UTF-8/ISO-8859-1 $encodings = array_merge($encodings, $this->registry->call('Misc', 'xml_encoding', array($this->raw_data, &$this->registry))); $encodings[] = 'UTF-8'; $encodings[] = 'ISO-8859-1'; - // There's no point in trying an encoding twice $encodings = array_unique($encodings); - // Loop through each possible encoding, till we return something, or run out of possibilities foreach ($encodings as $encoding) { @@ -552,7 +621,6 @@ class SimplePie { // Create new parser $parser = $this->registry->create('Parser'); - // If it's parsed fine if ($parser->parse($utf8_data, 'UTF-8')) { @@ -563,13 +631,11 @@ class SimplePie $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); return false; } - if (isset($headers)) { $this->data['headers'] = $headers; } $this->data['build'] = SIMPLEPIE_BUILD; - // Cache the file if caching is enabled if ($cache && !$cache->save($this)) { @@ -579,7 +645,6 @@ class SimplePie } } } - if (isset($parser)) { // We have an error, just set SimplePie_Misc::error to it and quit @@ -589,11 +654,10 @@ class SimplePie { $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->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); - return false; } + protected function fetch_data(&$cache) { // If it's enabled, use the cache @@ -627,7 +691,6 @@ class SimplePie $this->set_feed_url($this->data['feed_url']); return $this->init(); } - $cache->unlink(); $this->data = array(); } @@ -649,9 +712,7 @@ class SimplePie { $headers['if-none-match'] = $this->data['headers']['etag']; } - $file = $this->registry->create('File', array($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen)); - if ($file->success) { if ($file->status_code === 304) @@ -701,20 +762,28 @@ class SimplePie $this->error = $file->error; return !empty($this->data); } - if (!$this->force_feed) { // Check if the supplied URL is a feed, if it isn't, look for it. $locate = $this->registry->create('Locator', array(&$file, $this->timeout, $this->useragent, $this->max_checked_feeds)); - if (!$locate->is_feed($file)) { // We need to unset this so that if SimplePie::set_file() has been called that object is untouched unset($file); - if (!($file = $locate->find($this->autodiscovery, $this->all_discovered_feeds))) + try { - $this->error = "A feed could not be found at $this->feed_url. A feed with an invalid mime type may fall victim to this error, or " . SIMPLEPIE_NAME . " was unable to auto-discover it.. Use force_feed() if you are certain this URL is a real feed."; - $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); + if (!($file = $locate->find($this->autodiscovery, $this->all_discovered_feeds))) + { + $this->error = "A feed could not be found at $this->feed_url. A feed with an invalid mime type may fall victim to this error, or " . SIMPLEPIE_NAME . " was unable to auto-discover it.. Use force_feed() if you are certain this URL is a real feed."; + $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); + return false; + } + } + catch (SimplePie_Exception $e) + { + // This is usually because DOMDocument doesn't exist + $this->error = $e->getMessage(); + $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, $e->getFile(), $e->getLine())); return false; } if ($cache) @@ -724,33 +793,34 @@ class SimplePie { 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); } - $cache = $this->registry->call('Cache', 'create', array($this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc')); + $cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc')); } $this->feed_url = $file->url; } $locate = null; } - $this->raw_data = $file->body; - $headers = $file->headers; $sniffer = $this->registry->create('Content_Type_Sniffer', array(&$file)); $sniffed = $sniffer->get_type(); - return array($headers, $sniffed); } + public function error() { return $this->error; } + public function get_raw_data() { return $this->raw_data; } + public function get_encoding() { return $this->sanitize->output_encoding; } + public function handle_content_type($mime = 'text/html') { if (!headers_sent()) @@ -767,6 +837,7 @@ class SimplePie header($header); } } + public function get_type() { if (!isset($this->data['type'])) @@ -813,26 +884,21 @@ class SimplePie case '0': $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE; break; - case '24': $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_USERLAND; break; } } break; - case '0.92': $this->data['type'] &= SIMPLEPIE_TYPE_RSS_092; break; - case '0.93': $this->data['type'] &= SIMPLEPIE_TYPE_RSS_093; break; - case '0.94': $this->data['type'] &= SIMPLEPIE_TYPE_RSS_094; break; - case '2.0': $this->data['type'] &= SIMPLEPIE_TYPE_RSS_20; break; @@ -846,6 +912,7 @@ class SimplePie } return $this->data['type']; } + public function subscribe_url() { if ($this->feed_url !== null) @@ -857,6 +924,7 @@ class SimplePie return null; } } + public function get_feed_tags($namespace, $tag) { $type = $this->get_type(); @@ -890,6 +958,7 @@ class SimplePie } return null; } + public function get_channel_tags($namespace, $tag) { $type = $this->get_type(); @@ -932,6 +1001,7 @@ class SimplePie } return null; } + public function get_image_tags($namespace, $tag) { $type = $this->get_type(); @@ -967,6 +1037,7 @@ class SimplePie } return null; } + public function get_base($element = array()) { if (!($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION) && !empty($element['xml_base_explicit']) && isset($element['xml_base'])) @@ -982,10 +1053,12 @@ class SimplePie return $this->subscribe_url(); } } + public function sanitize($data, $type, $base = '') { return $this->sanitize->sanitize($data, $type, $base); } + public function get_title() { if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) @@ -1021,6 +1094,7 @@ class SimplePie return null; } } + public function get_category($key = 0) { $categories = $this->get_categories(); @@ -1033,10 +1107,10 @@ class SimplePie return null; } } + public function get_categories() { $categories = array(); - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) { $term = null; @@ -1079,7 +1153,6 @@ class SimplePie { $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); } - if (!empty($categories)) { return array_unique($categories); @@ -1089,6 +1162,7 @@ class SimplePie return null; } } + public function get_author($key = 0) { $authors = $this->get_authors(); @@ -1101,6 +1175,7 @@ class SimplePie return null; } } + public function get_authors() { $authors = array(); @@ -1160,7 +1235,6 @@ class SimplePie { $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); } - if (!empty($authors)) { return array_unique($authors); @@ -1170,6 +1244,7 @@ class SimplePie return null; } } + public function get_contributor($key = 0) { $contributors = $this->get_contributors(); @@ -1182,6 +1257,7 @@ class SimplePie return null; } } + public function get_contributors() { $contributors = array(); @@ -1229,7 +1305,6 @@ class SimplePie $contributors[] = $this->registry->create('Author', array($name, $url, $email)); } } - if (!empty($contributors)) { return array_unique($contributors); @@ -1239,6 +1314,7 @@ class SimplePie return null; } } + public function get_link($key = 0, $rel = 'alternate') { $links = $this->get_links($rel); @@ -1251,10 +1327,12 @@ class SimplePie return null; } } + public function get_permalink() { return $this->get_link(0); } + public function get_links($rel = 'alternate') { if (!isset($this->data['links'])) @@ -1279,7 +1357,6 @@ class SimplePie { $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); - } } } @@ -1295,7 +1372,6 @@ class SimplePie { $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); } - $keys = array_keys($this->data['links']); foreach ($keys as $key) { @@ -1318,7 +1394,6 @@ class SimplePie $this->data['links'][$key] = array_unique($this->data['links'][$key]); } } - if (isset($this->data['links'][$rel])) { return $this->data['links'][$rel]; @@ -1328,11 +1403,11 @@ class SimplePie return null; } } - public function get_all_discovered_feeds() { return $this->all_discovered_feeds; } + public function get_description() { if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) @@ -1376,6 +1451,7 @@ class SimplePie return null; } } + public function get_copyright() { if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) @@ -1403,6 +1479,7 @@ class SimplePie return null; } } + public function get_language() { if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) @@ -1438,9 +1515,9 @@ class SimplePie return null; } } + public function get_latitude() { - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) { return (float) $return[0]['data']; @@ -1454,6 +1531,7 @@ class SimplePie return null; } } + public function get_longitude() { if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) @@ -1473,6 +1551,7 @@ class SimplePie return null; } } + public function get_image_title() { if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) @@ -1500,6 +1579,7 @@ class SimplePie return null; } } + public function get_image_url() { if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) @@ -1531,6 +1611,7 @@ class SimplePie return null; } } + public function get_image_link() { if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) @@ -1550,6 +1631,7 @@ class SimplePie return null; } } + public function get_image_width() { if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'width')) @@ -1565,6 +1647,7 @@ class SimplePie return null; } } + public function get_image_height() { if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'height')) @@ -1580,6 +1663,7 @@ class SimplePie return null; } } + public function get_item_quantity($max = 0) { $max = (int) $max; @@ -1593,6 +1677,7 @@ class SimplePie return ($qty > $max) ? $max : $qty; } } + public function get_item($key = 0) { $items = $this->get_items(); @@ -1605,6 +1690,7 @@ class SimplePie return null; } } + public function get_items($start = 0, $end = 0) { if (!isset($this->data['items'])) @@ -1658,7 +1744,6 @@ class SimplePie } } } - if (!empty($this->data['items'])) { // If we want to order it by date, check if all items have a date, and then sort it @@ -1688,7 +1773,6 @@ class SimplePie { $items = $this->data['items']; } - // Slice the data as desired if ($end === 0) { @@ -1704,10 +1788,51 @@ class SimplePie return array(); } } + + public function set_favicon_handler($page = false, $qs = 'i') + { + $level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; + trigger_error('Favicon handling has been removed, please use your own handling', $level); + return false; + } + + public function get_favicon() + { + $level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; + trigger_error('Favicon handling has been removed, please use your own handling', $level); + if (($url = $this->get_link()) !== null) + { + return 'http://g.etfv.co/' . urlencode($url); + } + return false; + } + + public function __call($method, $args) + { + if (strpos($method, 'subscribe_') === 0) + { + $level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; + trigger_error('subscribe_*() has been deprecated, implement the callback yourself', $level); + return ''; + } + if ($method === 'enable_xml_dump') + { + $level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; + trigger_error('enable_xml_dump() has been deprecated, use get_raw_data() instead', $level); + return false; + } + $class = get_class($this); + $trace = debug_backtrace(); + $file = $trace[0]['file']; + $line = $trace[0]['line']; + trigger_error("Call to undefined method $class::$method() in $file on line $line", E_USER_ERROR); + } + public static function sort_items($a, $b) { return $a->get_date('U') <= $b->get_date('U'); } + public static function merge_items($urls, $start = 0, $end = 0, $limit = 0) { if (is_array($urls) && sizeof($urls) > 0) @@ -1724,7 +1849,6 @@ class SimplePie trigger_error('Arguments must be SimplePie objects', E_USER_WARNING); } } - $do_sort = true; foreach ($items as $item) { @@ -1739,7 +1863,6 @@ class SimplePie { usort($items, array(get_class($urls[0]), 'sort_items')); } - if ($end === 0) { return array_slice($items, $start); @@ -1758,20 +1881,26 @@ class SimplePie } class SimplePie_Author { + var $name; + var $link; + var $email; + public function __construct($name = null, $link = null, $email = null) { $this->name = $name; $this->link = $link; $this->email = $email; } + public function __toString() { // There is no $this->data here return md5(serialize($this)); } + public function get_name() { if ($this->name !== null) @@ -1783,6 +1912,7 @@ class SimplePie_Author return null; } } + public function get_link() { if ($this->link !== null) @@ -1794,6 +1924,7 @@ class SimplePie_Author return null; } } + public function get_email() { if ($this->email !== null) @@ -1808,29 +1939,36 @@ class SimplePie_Author } interface SimplePie_Cache_Base { + const TYPE_FEED = 'spc'; + const TYPE_IMAGE = 'spi'; + public function __construct($location, $name, $type); + public function save($data); + public function load(); + public function mtime(); + public function touch(); + public function unlink(); } abstract class SimplePie_Cache_DB implements SimplePie_Cache_Base { + protected static function prepare_simplepie_object_for_cache($data) { $items = $data->get_items(); $items_by_id = array(); - if (!empty($items)) { foreach ($items as $item) { $items_by_id[$item->get_id()] = $item; } - if (count($items_by_id) !== count($items)) { $items_by_id = array(); @@ -1839,7 +1977,6 @@ abstract class SimplePie_Cache_DB implements SimplePie_Cache_Base $items_by_id[$item->get_id(true)] = $item; } } - if (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0])) { $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]; @@ -1860,7 +1997,6 @@ abstract class SimplePie_Cache_DB implements SimplePie_Cache_Base { $channel = null; } - if ($channel !== null) { if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'])) @@ -1898,10 +2034,15 @@ abstract class SimplePie_Cache_DB implements SimplePie_Cache_Base } class SimplePie_Cache_File implements SimplePie_Cache_Base { + protected $location; + protected $filename; + protected $extension; + protected $name; + public function __construct($location, $name, $type) { $this->location = $location; @@ -1909,6 +2050,7 @@ class SimplePie_Cache_File implements SimplePie_Cache_Base $this->extension = $type; $this->name = "$this->location/$this->filename.$this->extension"; } + public function save($data) { if (file_exists($this->name) && is_writeable($this->name) || file_exists($this->location) && is_writeable($this->location)) @@ -1917,12 +2059,12 @@ class SimplePie_Cache_File implements SimplePie_Cache_Base { $data = $data->data; } - $data = serialize($data); return (bool) file_put_contents($this->name, $data); } return false; } + public function load() { if (file_exists($this->name) && is_readable($this->name)) @@ -1931,6 +2073,7 @@ class SimplePie_Cache_File implements SimplePie_Cache_Base } return false; } + public function mtime() { if (file_exists($this->name)) @@ -1939,6 +2082,7 @@ class SimplePie_Cache_File implements SimplePie_Cache_Base } return false; } + public function touch() { if (file_exists($this->name)) @@ -1947,6 +2091,7 @@ class SimplePie_Cache_File implements SimplePie_Cache_Base } return false; } + public function unlink() { if (file_exists($this->name)) @@ -1958,9 +2103,13 @@ class SimplePie_Cache_File implements SimplePie_Cache_Base } class SimplePie_Cache_Memcache implements SimplePie_Cache_Base { + protected $cache; + protected $options; + protected $name; + public function __construct($location, $name, $type) { $this->options = array( @@ -1976,10 +2125,10 @@ class SimplePie_Cache_Memcache implements SimplePie_Cache_Base $this->options['port'] = empty($parsed['port']) ? $this->options['port'] : $parsed['port']; $this->options['extras'] = array_merge($this->options['extras'], $parsed['extras']); $this->name = $this->options['extras']['prefix'] . md5("$name:$type"); - $this->cache = new Memcache(); $this->cache->addServer($this->options['host'], (int) $this->options['port']); } + public function save($data) { if ($data instanceof SimplePie) @@ -1988,39 +2137,38 @@ class SimplePie_Cache_Memcache implements SimplePie_Cache_Base } return $this->cache->set($this->name, serialize($data), MEMCACHE_COMPRESSED, (int) $this->options['extras']['timeout']); } + public function load() { $data = $this->cache->get($this->name); - if ($data !== false) { return unserialize($data); } return false; } + public function mtime() { $data = $this->cache->get($this->name); - if ($data !== false) { // essentially ignore the mtime because Memcache expires on it's own return time(); } - return false; } + public function touch() { $data = $this->cache->get($this->name); - if ($data !== false) { return $this->cache->set($this->name, $data, MEMCACHE_COMPRESSED, (int) $this->duration); } - return false; } + public function unlink() { return $this->cache->delete($this->name, 0); @@ -2028,9 +2176,13 @@ class SimplePie_Cache_Memcache implements SimplePie_Cache_Base } class SimplePie_Cache_MySQL extends SimplePie_Cache_DB { + protected $mysql; + protected $options; + protected $id; + public function __construct($location, $name, $type) { $this->options = array( @@ -2044,10 +2196,8 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB ), ); $this->options = array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location)); - // Path is prefixed with a "/" $this->options['dbname'] = substr($this->options['path'], 1); - try { $this->mysql = new PDO("mysql:dbname={$this->options['dbname']};host={$this->options['host']};port={$this->options['port']}", $this->options['user'], $this->options['pass'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); @@ -2057,21 +2207,17 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB $this->mysql = null; return; } - $this->id = $name . $type; - if (!$query = $this->mysql->query('SHOW TABLES')) { $this->mysql = null; return; } - $db = array(); while ($row = $query->fetchColumn()) { $db[] = $row; } - if (!in_array($this->options['extras']['prefix'] . 'cache_data', $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)))'); @@ -2080,7 +2226,6 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB $this->mysql = null; } } - 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` TEXT CHARACTER SET utf8 NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))'); @@ -2090,19 +2235,17 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB } } } + public function save($data) { if ($this->mysql === null) { return false; } - if ($data instanceof SimplePie) { $data = clone $data; - $prepared = self::prepare_simplepie_object_for_cache($data); - $query = $this->mysql->prepare('SELECT COUNT(*) FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :feed'); $query->bindValue(':feed', $this->id); if ($query->execute()) @@ -2121,7 +2264,6 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB $sql = 'UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `data` = :data, `mtime` = :time WHERE `id` = :feed'; $query = $this->mysql->prepare($sql); } - $query->bindValue(':data', $prepared[0]); $query->bindValue(':time', time()); $query->bindValue(':feed', $this->id); @@ -2142,7 +2284,6 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB return false; } } - $ids = array_keys($prepared[1]); if (!empty($ids)) { @@ -2150,10 +2291,8 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB { $database_ids[] = $this->mysql->quote($id); } - $query = $this->mysql->prepare('SELECT `id` FROM `' . $this->options['extras']['prefix'] . 'items` WHERE `id` = ' . implode(' OR `id` = ', $database_ids) . ' AND `feed_id` = :feed'); $query->bindValue(':feed', $this->id); - if ($query->execute()) { $existing_ids = array(); @@ -2161,16 +2300,13 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB { $existing_ids[] = $row; } - $new_ids = array_diff($ids, $existing_ids); - foreach ($new_ids as $new_id) { if (!($date = $prepared[1][$new_id]->get_date('U'))) { $date = time(); } - $query = $this->mysql->prepare('INSERT INTO `' . $this->options['extras']['prefix'] . 'items` (`feed_id`, `id`, `data`, `posted`) VALUES(:feed, :id, :data, :date)'); $query->bindValue(':feed', $this->id); $query->bindValue(':id', $new_id); @@ -2222,19 +2358,18 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB } return false; } + public function load() { if ($this->mysql === null) { return false; } - $query = $this->mysql->prepare('SELECT `items`, `data` FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :id'); $query->bindValue(':id', $this->id); if ($query->execute() && ($row = $query->fetch())) { $data = unserialize($row[1]); - if (isset($this->options['items'][0])) { $items = (int) $this->options['items'][0]; @@ -2243,7 +2378,6 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB { $items = (int) $row[0]; } - if ($items !== 0) { if (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0])) @@ -2266,7 +2400,6 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB { $feed = null; } - if ($feed !== null) { $sql = 'SELECT `data` FROM `' . $this->options['extras']['prefix'] . 'items` WHERE `feed_id` = :feed ORDER BY `posted` DESC'; @@ -2274,7 +2407,6 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB { $sql .= ' LIMIT ' . $items; } - $query = $this->mysql->prepare($sql); $query->bindValue(':feed', $this->id); if ($query->execute()) @@ -2294,13 +2426,13 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB } return false; } + public function mtime() { if ($this->mysql === null) { return false; } - $query = $this->mysql->prepare('SELECT `mtime` FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :id'); $query->bindValue(':id', $this->id); if ($query->execute() && ($time = $query->fetchColumn())) @@ -2312,13 +2444,13 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB return false; } } + public function touch() { if ($this->mysql === null) { return false; } - $query = $this->mysql->prepare('UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `mtime` = :time WHERE `id` = :id'); $query->bindValue(':time', time()); $query->bindValue(':id', $this->id); @@ -2331,13 +2463,13 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB return false; } } + public function unlink() { if ($this->mysql === null) { return false; } - $query = $this->mysql->prepare('DELETE FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :id'); $query->bindValue(':id', $this->id); $query2 = $this->mysql->prepare('DELETE FROM `' . $this->options['extras']['prefix'] . 'items` WHERE `feed_id` = :id'); @@ -2354,12 +2486,15 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB } class SimplePie_Cache { + protected static $handlers = array( 'mysql' => 'SimplePie_Cache_MySQL', 'memcache' => 'SimplePie_Cache_Memcache', ); + private function __construct() { } - public static function create($location, $filename, $extension) + + public static function get_handler($location, $filename, $extension) { $type = explode(':', $location, 2); $type = $type[0]; @@ -2368,13 +2503,20 @@ class SimplePie_Cache $class = self::$handlers[$type]; return new $class($location, $filename, $extension); } - return new SimplePie_Cache_File($location, $filename, $extension); } + + public function create($location, $filename, $extension) + { + trigger_error('Cache::create() has been replaced with Cache::get_handler(). Switch to the registry system to use this.', E_USER_DEPRECATED); + return self::get_handler($location, $filename, $extension); + } + public static function register($type, $class) { self::$handlers[$type] = $class; } + public static function parse_URL($url) { $params = parse_url($url); @@ -2388,11 +2530,17 @@ class SimplePie_Cache } class SimplePie_Caption { + var $type; + var $lang; + var $startTime; + var $endTime; + var $text; + public function __construct($type = null, $lang = null, $startTime = null, $endTime = null, $text = null) { $this->type = $type; @@ -2401,11 +2549,13 @@ class SimplePie_Caption $this->endTime = $endTime; $this->text = $text; } + public function __toString() { // There is no $this->data here return md5(serialize($this)); } + public function get_endtime() { if ($this->endTime !== null) @@ -2417,6 +2567,7 @@ class SimplePie_Caption return null; } } + public function get_language() { if ($this->lang !== null) @@ -2428,6 +2579,7 @@ class SimplePie_Caption return null; } } + public function get_starttime() { if ($this->startTime !== null) @@ -2439,6 +2591,7 @@ class SimplePie_Caption return null; } } + public function get_text() { if ($this->text !== null) @@ -2450,6 +2603,7 @@ class SimplePie_Caption return null; } } + public function get_type() { if ($this->type !== null) @@ -2464,20 +2618,26 @@ class SimplePie_Caption } class SimplePie_Category { + var $term; + var $scheme; + var $label; + public function __construct($term = null, $scheme = null, $label = null) { $this->term = $term; $this->scheme = $scheme; $this->label = $label; } + public function __toString() { // There is no $this->data here return md5(serialize($this)); } + public function get_term() { if ($this->term !== null) @@ -2489,6 +2649,7 @@ class SimplePie_Category return null; } } + public function get_scheme() { if ($this->scheme !== null) @@ -2500,6 +2661,7 @@ class SimplePie_Category return null; } } + public function get_label() { if ($this->label !== null) @@ -2514,11 +2676,14 @@ class SimplePie_Category } class SimplePie_Content_Type_Sniffer { + var $file; + public function __construct($file) { $this->file = $file; } + public function get_type() { if (isset($this->file->headers['content-type'])) @@ -2531,7 +2696,6 @@ class SimplePie_Content_Type_Sniffer { return $this->text_or_binary(); } - if (($pos = strpos($this->file->headers['content-type'], ';')) !== false) { $official = substr($this->file->headers['content-type'], 0, $pos); @@ -2541,7 +2705,6 @@ class SimplePie_Content_Type_Sniffer $official = $this->file->headers['content-type']; } $official = trim(strtolower($official)); - if ($official === 'unknown/unknown' || $official === 'application/unknown') { @@ -2578,6 +2741,7 @@ class SimplePie_Content_Type_Sniffer return $this->unknown(); } } + public function text_or_binary() { if (substr($this->file->body, 0, 2) === "\xFE\xFF" @@ -2596,6 +2760,7 @@ class SimplePie_Content_Type_Sniffer return 'text/plain'; } } + public function unknown() { $ws = strspn($this->file->body, "\x09\x0A\x0B\x0C\x0D\x20"); @@ -2639,6 +2804,7 @@ class SimplePie_Content_Type_Sniffer return $this->text_or_binary(); } } + public function image() { if (substr($this->file->body, 0, 6) === 'GIF87a' @@ -2667,11 +2833,11 @@ class SimplePie_Content_Type_Sniffer return false; } } + public function feed_or_html() { $len = strlen($this->file->body); $pos = strspn($this->file->body, "\x09\x0A\x0D\x20"); - while ($pos < $len) { switch ($this->file->body[$pos]) @@ -2682,15 +2848,12 @@ class SimplePie_Content_Type_Sniffer case "\x20": $pos += strspn($this->file->body, "\x09\x0A\x0D\x20", $pos); continue 2; - case '<': $pos++; break; - default: return 'text/html'; } - if (substr($this->file->body, $pos, 3) === '!--') { $pos += 3; @@ -2739,24 +2902,28 @@ class SimplePie_Content_Type_Sniffer return 'text/html'; } } - return 'text/html'; } } class SimplePie_Copyright { + var $url; + var $label; + public function __construct($url = null, $label = null) { $this->url = $url; $this->label = $label; } + public function __toString() { // There is no $this->data here return md5(serialize($this)); } + public function get_url() { if ($this->url !== null) @@ -2768,6 +2935,7 @@ class SimplePie_Copyright return null; } } + public function get_attribution() { if ($this->label !== null) @@ -2782,24 +2950,29 @@ class SimplePie_Copyright } class SimplePie_Core extends SimplePie { - } class SimplePie_Credit { + var $role; + var $scheme; + var $name; + public function __construct($role = null, $scheme = null, $name = null) { $this->role = $role; $this->scheme = $scheme; $this->name = $name; } + public function __toString() { // There is no $this->data here return md5(serialize($this)); } + public function get_role() { if ($this->role !== null) @@ -2811,6 +2984,7 @@ class SimplePie_Credit return null; } } + public function get_scheme() { if ($this->scheme !== null) @@ -2822,6 +2996,7 @@ class SimplePie_Credit return null; } } + public function get_name() { if ($this->name !== null) @@ -2836,13 +3011,18 @@ class SimplePie_Credit } class SimplePie_Decode_HTML_Entities { + var $data = ''; + var $consumed = ''; + var $position = 0; + public function __construct($data) { $this->data = $data; } + public function parse() { while (($this->position = strpos($this->data, '&', $this->position)) !== false) @@ -2853,6 +3033,7 @@ class SimplePie_Decode_HTML_Entities } return $this->data; } + public function consume() { if (isset($this->data[$this->position])) @@ -2865,6 +3046,7 @@ class SimplePie_Decode_HTML_Entities return false; } } + public function consume_range($chars) { if ($len = strspn($this->data, $chars, $this->position)) @@ -2879,11 +3061,13 @@ class SimplePie_Decode_HTML_Entities return false; } } + public function unconsume() { $this->consumed = substr($this->consumed, 0, -1); $this->position--; } + public function entity() { switch ($this->consume()) @@ -2898,7 +3082,6 @@ class SimplePie_Decode_HTML_Entities case "\x26": case false: break; - case "\x23": switch ($this->consume()) { @@ -2907,18 +3090,15 @@ class SimplePie_Decode_HTML_Entities $range = '0123456789ABCDEFabcdef'; $hex = true; break; - default: $range = '0123456789'; $hex = false; $this->unconsume(); break; } - if ($codepoint = $this->consume_range($range)) { static $windows_1252_specials = array(0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8"); - if ($hex) { $codepoint = hexdec($codepoint); @@ -2927,7 +3107,6 @@ class SimplePie_Decode_HTML_Entities { $codepoint = intval($codepoint); } - if (isset($windows_1252_specials[$codepoint])) { $replacement = $windows_1252_specials[$codepoint]; @@ -2936,18 +3115,15 @@ class SimplePie_Decode_HTML_Entities { $replacement = SimplePie_Misc::codepoint_to_utf8($codepoint); } - if (!in_array($this->consume(), array(';', false), true)) { $this->unconsume(); } - $consumed_length = strlen($this->consumed); $this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length); $this->position += strlen($replacement) - $consumed_length; } break; - default: static $entities = array( 'Aacute' => "\xC3\x81", @@ -3317,7 +3493,6 @@ class SimplePie_Decode_HTML_Entities 'zwj;' => "\xE2\x80\x8D", 'zwnj;' => "\xE2\x80\x8C" ); - for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++) { $consumed = substr($this->consumed, 1); @@ -3326,7 +3501,6 @@ class SimplePie_Decode_HTML_Entities $match = $consumed; } } - if ($match !== null) { $this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1); @@ -3338,33 +3512,61 @@ class SimplePie_Decode_HTML_Entities } class SimplePie_Enclosure { + var $bitrate; + var $captions; + var $categories; + var $channels; + var $copyright; + var $credits; + var $description; + var $duration; + var $expression; + var $framerate; + var $handler; + var $hashes; + var $height; + var $javascript; + var $keywords; + var $lang; + var $length; + var $link; + var $medium; + var $player; + var $ratings; + var $restrictions; + var $samplingrate; + var $thumbnails; + var $title; + var $type; + var $width; + public function __construct($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null) { $this->bitrate = $bitrate; @@ -3392,7 +3594,6 @@ class SimplePie_Enclosure $this->title = $title; $this->type = $type; $this->width = $width; - if (class_exists('idna_convert')) { $idn = new idna_convert(); @@ -3401,11 +3602,13 @@ class SimplePie_Enclosure } $this->handler = $this->get_handler(); // Needs to load last } + public function __toString() { // There is no $this->data here return md5(serialize($this)); } + public function get_bitrate() { if ($this->bitrate !== null) @@ -3417,6 +3620,7 @@ class SimplePie_Enclosure return null; } } + public function get_caption($key = 0) { $captions = $this->get_captions(); @@ -3429,6 +3633,7 @@ class SimplePie_Enclosure return null; } } + public function get_captions() { if ($this->captions !== null) @@ -3440,6 +3645,7 @@ class SimplePie_Enclosure return null; } } + public function get_category($key = 0) { $categories = $this->get_categories(); @@ -3452,6 +3658,7 @@ class SimplePie_Enclosure return null; } } + public function get_categories() { if ($this->categories !== null) @@ -3463,6 +3670,7 @@ class SimplePie_Enclosure return null; } } + public function get_channels() { if ($this->channels !== null) @@ -3474,6 +3682,7 @@ class SimplePie_Enclosure return null; } } + public function get_copyright() { if ($this->copyright !== null) @@ -3485,6 +3694,7 @@ class SimplePie_Enclosure return null; } } + public function get_credit($key = 0) { $credits = $this->get_credits(); @@ -3497,6 +3707,7 @@ class SimplePie_Enclosure return null; } } + public function get_credits() { if ($this->credits !== null) @@ -3508,6 +3719,7 @@ class SimplePie_Enclosure return null; } } + public function get_description() { if ($this->description !== null) @@ -3519,6 +3731,7 @@ class SimplePie_Enclosure return null; } } + public function get_duration($convert = false) { if ($this->duration !== null) @@ -3538,6 +3751,7 @@ class SimplePie_Enclosure return null; } } + public function get_expression() { if ($this->expression !== null) @@ -3549,6 +3763,7 @@ class SimplePie_Enclosure return 'full'; } } + public function get_extension() { if ($this->link !== null) @@ -3561,6 +3776,7 @@ class SimplePie_Enclosure } return null; } + public function get_framerate() { if ($this->framerate !== null) @@ -3572,10 +3788,12 @@ class SimplePie_Enclosure return null; } } + public function get_handler() { return $this->get_real_type(true); } + public function get_hash($key = 0) { $hashes = $this->get_hashes(); @@ -3588,6 +3806,7 @@ class SimplePie_Enclosure return null; } } + public function get_hashes() { if ($this->hashes !== null) @@ -3599,6 +3818,7 @@ class SimplePie_Enclosure return null; } } + public function get_height() { if ($this->height !== null) @@ -3610,6 +3830,7 @@ class SimplePie_Enclosure return null; } } + public function get_language() { if ($this->lang !== null) @@ -3621,6 +3842,7 @@ class SimplePie_Enclosure return null; } } + public function get_keyword($key = 0) { $keywords = $this->get_keywords(); @@ -3633,6 +3855,7 @@ class SimplePie_Enclosure return null; } } + public function get_keywords() { if ($this->keywords !== null) @@ -3644,6 +3867,7 @@ class SimplePie_Enclosure return null; } } + public function get_length() { if ($this->length !== null) @@ -3655,6 +3879,7 @@ class SimplePie_Enclosure return null; } } + public function get_link() { if ($this->link !== null) @@ -3666,6 +3891,7 @@ class SimplePie_Enclosure return null; } } + public function get_medium() { if ($this->medium !== null) @@ -3677,6 +3903,7 @@ class SimplePie_Enclosure return null; } } + public function get_player() { if ($this->player !== null) @@ -3688,6 +3915,7 @@ class SimplePie_Enclosure return null; } } + public function get_rating($key = 0) { $ratings = $this->get_ratings(); @@ -3700,6 +3928,7 @@ class SimplePie_Enclosure return null; } } + public function get_ratings() { if ($this->ratings !== null) @@ -3711,6 +3940,7 @@ class SimplePie_Enclosure return null; } } + public function get_restriction($key = 0) { $restrictions = $this->get_restrictions(); @@ -3723,6 +3953,7 @@ class SimplePie_Enclosure return null; } } + public function get_restrictions() { if ($this->restrictions !== null) @@ -3734,6 +3965,7 @@ class SimplePie_Enclosure return null; } } + public function get_sampling_rate() { if ($this->samplingrate !== null) @@ -3745,6 +3977,7 @@ class SimplePie_Enclosure return null; } } + public function get_size() { $length = $this->get_length(); @@ -3757,6 +3990,7 @@ class SimplePie_Enclosure return null; } } + public function get_thumbnail($key = 0) { $thumbnails = $this->get_thumbnails(); @@ -3769,6 +4003,7 @@ class SimplePie_Enclosure return null; } } + public function get_thumbnails() { if ($this->thumbnails !== null) @@ -3780,6 +4015,7 @@ class SimplePie_Enclosure return null; } } + public function get_title() { if ($this->title !== null) @@ -3791,6 +4027,7 @@ class SimplePie_Enclosure return null; } } + public function get_type() { if ($this->type !== null) @@ -3802,6 +4039,7 @@ class SimplePie_Enclosure return null; } } + public function get_width() { if ($this->width !== null) @@ -3813,10 +4051,12 @@ class SimplePie_Enclosure return null; } } + public function native_embed($options='') { return $this->embed($options, true); } + public function embed($options = '', $native = false) { // Set up defaults @@ -3832,7 +4072,6 @@ class SimplePie_Enclosure $widescreen = false; $handler = $this->get_handler(); $type = $this->get_real_type(); - // Process options and reassign values as necessary if (is_array($options)) { @@ -3853,39 +4092,30 @@ class SimplePie_Enclosure case 'audio': $audio = $opt[1]; break; - case 'video': $video = $opt[1]; break; - case 'alt': $alt = $opt[1]; break; - case 'altclass': $altclass = $opt[1]; break; - case 'loop': $loop = $opt[1]; break; - case 'width': $width = $opt[1]; break; - case 'height': $height = $opt[1]; break; - case 'bgcolor': $bgcolor = $opt[1]; break; - case 'mediaplayer': $mediaplayer = $opt[1]; break; - case 'widescreen': $widescreen = $opt[1]; break; @@ -3893,10 +4123,8 @@ class SimplePie_Enclosure } } } - $mime = explode('/', $type, 2); $mime = $mime[0]; - // Process values for 'auto' if ($width === 'auto') { @@ -3920,7 +4148,6 @@ class SimplePie_Enclosure $width = '100%'; } } - if ($height === 'auto') { if ($mime === 'audio') @@ -3958,7 +4185,6 @@ class SimplePie_Enclosure { $height = 0; } - // Set proper placeholder value if ($mime === 'audio') { @@ -3968,9 +4194,7 @@ class SimplePie_Enclosure { $placeholder = $video; } - $embed = ''; - // Flash if ($handler === 'flash') { @@ -3983,7 +4207,6 @@ class SimplePie_Enclosure $embed .= ""; } } - // Flash Media Player file types. // Preferred handler for MP3 file types. elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== '')) @@ -3998,7 +4221,6 @@ class SimplePie_Enclosure $embed .= ""; } } - // QuickTime 7 file types. Need to test with QuickTime 6. // Only handle MP3's if the Flash Media Player is not present. elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === '')) @@ -4020,7 +4242,6 @@ class SimplePie_Enclosure $embed .= ""; } } - // Windows Media elseif ($handler === 'wmedia') { @@ -4034,12 +4255,11 @@ class SimplePie_Enclosure $embed .= ""; } } - // Everything else else $embed .= '' . $alt . ''; - return $embed; } + public function get_real_type($find_handler = false) { // Mime-types by handler. @@ -4048,7 +4268,6 @@ class SimplePie_Enclosure $types_quicktime = array('audio/3gpp', 'audio/3gpp2', 'audio/aac', 'audio/x-aac', 'audio/aiff', 'audio/x-aiff', 'audio/mid', 'audio/midi', 'audio/x-midi', 'audio/mp4', 'audio/m4a', 'audio/x-m4a', 'audio/wav', 'audio/x-wav', 'video/3gpp', 'video/3gpp2', 'video/m4v', 'video/x-m4v', 'video/mp4', 'video/mpeg', 'video/x-mpeg', 'video/quicktime', 'video/sd-video'); // QuickTime $types_wmedia = array('application/asx', 'application/x-mplayer2', 'audio/x-ms-wma', 'audio/x-ms-wax', 'video/x-ms-asf-plugin', 'video/x-ms-asf', 'video/x-ms-wm', 'video/x-ms-wmv', 'video/x-ms-wvx'); // Windows Media $types_mp3 = array('audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg'); // MP3 - if ($this->get_type() !== null) { $type = strtolower($this->type); @@ -4057,7 +4276,6 @@ class SimplePie_Enclosure { $type = null; } - // If we encounter an unsupported mime-type, check the file extension and guess intelligently. if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3))) { @@ -4068,65 +4286,52 @@ class SimplePie_Enclosure case 'adts': $type = 'audio/acc'; break; - case 'aif': case 'aifc': case 'aiff': case 'cdda': $type = 'audio/aiff'; break; - case 'bwf': $type = 'audio/wav'; break; - case 'kar': case 'mid': case 'midi': case 'smf': $type = 'audio/midi'; break; - case 'm4a': $type = 'audio/x-m4a'; break; - case 'mp3': case 'swa': $type = 'audio/mp3'; break; - case 'wav': $type = 'audio/wav'; break; - case 'wax': $type = 'audio/x-ms-wax'; break; - case 'wma': $type = 'audio/x-ms-wma'; break; - // Video mime-types case '3gp': case '3gpp': $type = 'video/3gpp'; break; - case '3g2': case '3gp2': $type = 'video/3gpp2'; break; - case 'asf': $type = 'video/x-ms-asf'; break; - case 'flv': $type = 'video/x-flv'; break; - case 'm1a': case 'm1s': case 'm1v': @@ -4140,48 +4345,38 @@ class SimplePie_Enclosure case 'mpv': $type = 'video/mpeg'; break; - case 'm4v': $type = 'video/x-m4v'; break; - case 'mov': case 'qt': $type = 'video/quicktime'; break; - case 'mp4': case 'mpg4': $type = 'video/mp4'; break; - case 'sdv': $type = 'video/sd-video'; break; - case 'wm': $type = 'video/x-ms-wm'; break; - case 'wmv': $type = 'video/x-ms-wmv'; break; - case 'wvx': $type = 'video/x-ms-wvx'; break; - // Flash mime-types case 'spl': $type = 'application/futuresplash'; break; - case 'swf': $type = 'application/x-shockwave-flash'; break; } } - if ($find_handler) { if (in_array($type, $types_flash)) @@ -4215,6 +4410,9 @@ class SimplePie_Enclosure } } } +class SimplePie_Exception extends Exception +{ +} class SimplePie_File { var $url; @@ -4226,7 +4424,6 @@ class SimplePie_File var $redirects = 0; var $error; var $method = SIMPLEPIE_FILE_SOURCE_NONE; - public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) { if (class_exists('idna_convert')) @@ -4274,7 +4471,6 @@ class SimplePie_File curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects); } - $this->headers = curl_exec($fp); if (curl_errno($fp) === 23 || curl_errno($fp) === 61) { @@ -4352,7 +4548,6 @@ class SimplePie_File { $out .= "Accept-Encoding: x-gzip,gzip,deflate\r\n"; } - if (isset($url_parts['user']) && isset($url_parts['pass'])) { $out .= "Authorization: Basic " . base64_encode("$url_parts[user]:$url_parts[pass]") . "\r\n"; @@ -4363,9 +4558,7 @@ class SimplePie_File } $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); - $info = stream_get_meta_data($fp); - $this->headers = ''; while (!$info['eof'] && !$info['timed_out']) { @@ -4404,7 +4597,6 @@ class SimplePie_File $this->body = $decoder->data; } break; - case 'deflate': if (($decompressed = gzinflate($this->body)) !== false) { @@ -4424,7 +4616,6 @@ class SimplePie_File $this->success = false; } break; - default: $this->error = 'Unknown content coding'; $this->success = false; @@ -4454,29 +4645,46 @@ class SimplePie_File } class SimplePie_gzdecode { + var $compressed_data; + var $compressed_size; + var $min_compressed_size = 18; + var $position = 0; + var $flags; + var $data; + var $MTIME; + var $XFL; + var $OS; + var $SI1; + var $SI2; + var $extra_field; + var $filename; + var $comment; + public function __set($name, $value) { trigger_error("Cannot write property $name", E_USER_ERROR); } + public function __construct($data) { $this->compressed_data = $data; $this->compressed_size = strlen($data); } + public function parse() { if ($this->compressed_size >= $this->min_compressed_size) @@ -4486,19 +4694,15 @@ class SimplePie_gzdecode { return false; } - // Get the FLG (FLaGs) $this->flags = ord($this->compressed_data[3]); - // FLG bits above (1 << 4) are reserved if ($this->flags > 0x1F) { return false; } - // Advance the pointer after the above $this->position += 4; - // MTIME $mtime = substr($this->compressed_data, $this->position, 4); // Reverse the string if we're on a big-endian arch because l is the only signed long and is machine endianness @@ -4508,30 +4712,24 @@ class SimplePie_gzdecode } $this->MTIME = current(unpack('l', $mtime)); $this->position += 4; - // Get the XFL (eXtra FLags) $this->XFL = ord($this->compressed_data[$this->position++]); - // Get the OS (Operating System) $this->OS = ord($this->compressed_data[$this->position++]); - // Parse the FEXTRA if ($this->flags & 4) { // Read subfield IDs $this->SI1 = $this->compressed_data[$this->position++]; $this->SI2 = $this->compressed_data[$this->position++]; - // SI2 set to zero is reserved for future use if ($this->SI2 === "\x00") { return false; } - // Get the length of the extra field $len = current(unpack('v', substr($this->compressed_data, $this->position, 2))); $this->position += 2; - // Check the length of the string is still valid $this->min_compressed_size += $len + 4; if ($this->compressed_size >= $this->min_compressed_size) @@ -4545,13 +4743,11 @@ class SimplePie_gzdecode return false; } } - // Parse the FNAME if ($this->flags & 8) { // Get the length of the filename $len = strcspn($this->compressed_data, "\x00", $this->position); - // Check the length of the string is still valid $this->min_compressed_size += $len + 1; if ($this->compressed_size >= $this->min_compressed_size) @@ -4565,13 +4761,11 @@ class SimplePie_gzdecode return false; } } - // Parse the FCOMMENT if ($this->flags & 16) { // Get the length of the comment $len = strcspn($this->compressed_data, "\x00", $this->position); - // Check the length of the string is still valid $this->min_compressed_size += $len + 1; if ($this->compressed_size >= $this->min_compressed_size) @@ -4585,7 +4779,6 @@ class SimplePie_gzdecode return false; } } - // Parse the FHCRC if ($this->flags & 2) { @@ -4595,7 +4788,6 @@ class SimplePie_gzdecode { // Read the CRC $crc = current(unpack('v', substr($this->compressed_data, $this->position, 2))); - // Check the CRC matches if ((crc32(substr($this->compressed_data, 0, $this->position)) & 0xFFFF) === $crc) { @@ -4611,7 +4803,6 @@ class SimplePie_gzdecode return false; } } - // Decompress the actual data if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false) { @@ -4621,7 +4812,6 @@ class SimplePie_gzdecode { $this->position = $this->compressed_size - 8; } - // Check CRC of data $crc = current(unpack('V', substr($this->compressed_data, $this->position, 4))); $this->position += 4; @@ -4629,7 +4819,6 @@ class SimplePie_gzdecode { return false; }*/ - // Check ISIZE of data $isize = current(unpack('V', substr($this->compressed_data, $this->position, 4))); $this->position += 4; @@ -4637,7 +4826,6 @@ class SimplePie_gzdecode { return false; } - // Wow, against all odds, we've actually got a valid gzip string return true; } @@ -4649,22 +4837,35 @@ class SimplePie_gzdecode } class SimplePie_HTTP_Parser { + public $http_version = 0.0; + public $status_code = 0; + public $reason = ''; + public $headers = array(); + public $body = ''; + protected $state = 'http_version'; + protected $data = ''; + protected $data_length = 0; + protected $position = 0; + protected $name = ''; + protected $value = ''; + public function __construct($data) { $this->data = $data; $this->data_length = strlen($this->data); } + public function parse() { while ($this->state && $this->state !== 'emit' && $this->has_data()) @@ -4687,10 +4888,12 @@ class SimplePie_HTTP_Parser return false; } } + protected function has_data() { return (bool) ($this->position < $this->data_length); } + protected function is_linear_whitespace() { return (bool) ($this->data[$this->position] === "\x09" @@ -4699,6 +4902,7 @@ class SimplePie_HTTP_Parser && isset($this->data[$this->position + 1]) && ($this->data[$this->position + 1] === "\x09" || $this->data[$this->position + 1] === "\x20"))); } + protected function http_version() { if (strpos($this->data, "\x0A") !== false && strtoupper(substr($this->data, 0, 5)) === 'HTTP/') @@ -4722,6 +4926,7 @@ class SimplePie_HTTP_Parser $this->state = false; } } + protected function status() { if ($len = strspn($this->data, '0123456789', $this->position)) @@ -4735,6 +4940,7 @@ class SimplePie_HTTP_Parser $this->state = false; } } + protected function reason() { $len = strcspn($this->data, "\x0A", $this->position); @@ -4742,6 +4948,7 @@ class SimplePie_HTTP_Parser $this->position += $len + 1; $this->state = 'new_line'; } + protected function new_line() { $this->value = trim($this->value, "\x0D\x20"); @@ -4775,6 +4982,7 @@ class SimplePie_HTTP_Parser $this->state = 'name'; } } + protected function name() { $len = strcspn($this->data, "\x0A:", $this->position); @@ -4797,6 +5005,7 @@ class SimplePie_HTTP_Parser $this->state = false; } } + protected function linear_whitespace() { do @@ -4813,6 +5022,7 @@ class SimplePie_HTTP_Parser } while ($this->has_data() && $this->is_linear_whitespace()); $this->value .= "\x20"; } + protected function value() { if ($this->is_linear_whitespace()) @@ -4836,18 +5046,17 @@ class SimplePie_HTTP_Parser $this->position++; $this->state = 'quote'; break; - case "\x0A": $this->position++; $this->state = 'new_line'; break; - default: $this->state = 'value_char'; break; } } } + protected function value_char() { $len = strcspn($this->data, "\x09\x20\x0A\"", $this->position); @@ -4855,6 +5064,7 @@ class SimplePie_HTTP_Parser $this->position += $len; $this->state = 'value'; } + protected function quote() { if ($this->is_linear_whitespace()) @@ -4869,23 +5079,21 @@ class SimplePie_HTTP_Parser $this->position++; $this->state = 'value'; break; - case "\x0A": $this->position++; $this->state = 'new_line'; break; - case '\\': $this->position++; $this->state = 'quote_escaped'; break; - default: $this->state = 'quote_char'; break; } } } + protected function quote_char() { $len = strcspn($this->data, "\x09\x20\x0A\"\\", $this->position); @@ -4893,12 +5101,14 @@ class SimplePie_HTTP_Parser $this->position += $len; $this->state = 'value'; } + protected function quote_escaped() { $this->value .= $this->data[$this->position]; $this->position++; $this->state = 'quote'; } + protected function body() { $this->body = substr($this->data, $this->position); @@ -4912,6 +5122,7 @@ class SimplePie_HTTP_Parser $this->state = 'emit'; } } + protected function chunked() { if (!preg_match('/^([0-9a-f]+)[^\r\n]*\r\n/i', trim($this->body))) @@ -4919,10 +5130,8 @@ class SimplePie_HTTP_Parser $this->state = 'emit'; return; } - $decoded = ''; $encoded = $this->body; - while (true) { $is_chunked = (bool) preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', $encoded, $matches ); @@ -4932,7 +5141,6 @@ class SimplePie_HTTP_Parser $this->state = 'emit'; return; } - $length = hexdec(trim($matches[1])); if ($length === 0) { @@ -4941,11 +5149,9 @@ class SimplePie_HTTP_Parser $this->body = $decoded; return; } - $chunk_length = strlen($matches[0]); $decoded .= $part = substr($encoded, $chunk_length, $length); $encoded = substr($encoded, $chunk_length + $length + 2); - if (trim($encoded) === '0' || empty($encoded)) { $this->state = 'emit'; @@ -4957,13 +5163,21 @@ class SimplePie_HTTP_Parser } class SimplePie_IRI { + protected $scheme = null; + protected $iuserinfo = null; + protected $ihost = null; + protected $port = null; + protected $ipath = ''; + protected $iquery = null; + protected $ifragment = null; + protected $normalization = array( 'acap' => array( 'port' => 674 @@ -4983,10 +5197,12 @@ class SimplePie_IRI 'ipath' => '/' ), ); + public function __toString() { return $this->get_iri(); } + public function __set($name, $value) { if (method_exists($this, 'set_' . $name)) @@ -5005,12 +5221,12 @@ class SimplePie_IRI call_user_func(array($this, 'set_' . substr($name, 1)), $value); } } + public function __get($name) { // isset() returns false for null, we don't want to do that // Also why we use array_key_exists below instead of isset() $props = get_object_vars($this); - if ( $name === 'iri' || $name === 'uri' || @@ -5041,7 +5257,6 @@ class SimplePie_IRI trigger_error('Undefined property: ' . get_class($this) . '::' . $name, E_USER_NOTICE); $return = null; } - if ($return === null && isset($this->normalization[$this->scheme][$name])) { return $this->normalization[$this->scheme][$name]; @@ -5051,6 +5266,7 @@ class SimplePie_IRI return $return; } } + public function __isset($name) { if (method_exists($this, 'get_' . $name) || isset($this->$name)) @@ -5062,6 +5278,7 @@ class SimplePie_IRI return false; } } + public function __unset($name) { if (method_exists($this, 'set_' . $name)) @@ -5069,10 +5286,12 @@ class SimplePie_IRI call_user_func(array($this, 'set_' . $name), ''); } } + public function __construct($iri = null) { $this->set_iri($iri); } + public static function absolutize($base, $relative) { if (!($relative instanceof SimplePie_IRI)) @@ -5159,6 +5378,7 @@ class SimplePie_IRI } } } + protected function parse_iri($iri) { $iri = trim($iri, "\x20\x09\x0A\x0C\x0D"); @@ -5188,10 +5408,11 @@ class SimplePie_IRI } else { - trigger_error('This should never happen', E_USER_ERROR); - die; + // This can occur when a paragraph is accidentally parsed as a URI + return false; } } + protected function remove_dot_segments($input) { $output = ''; @@ -5245,31 +5466,26 @@ class SimplePie_IRI } return $output . $input; } + protected function replace_invalid_with_pct_encoding($string, $extra_chars, $iprivate = false) { // Normalize as many pct-encoded sections as possible $string = preg_replace_callback('/(?:%[A-Fa-f0-9]{2})+/', array($this, 'remove_iunreserved_percent_encoded'), $string); - // Replace invalid percent characters $string = preg_replace('/%(?![A-Fa-f0-9]{2})/', '%25', $string); - // Add unreserved and % to $extra_chars (the latter is safe because all // pct-encoded sections are now valid). $extra_chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~%'; - // Now replace any bytes that aren't allowed with their pct-encoded versions $position = 0; $strlen = strlen($string); while (($position += strspn($string, $extra_chars, $position)) < $strlen) { $value = ord($string[$position]); - // Start position $start = $position; - // By default we are valid $valid = true; - // No one byte sequences are valid due to the while. // Two byte sequence: if (($value & 0xE0) === 0xC0) @@ -5299,7 +5515,6 @@ class SimplePie_IRI $length = 1; $remaining = 0; } - if ($remaining) { if ($position + $length <= $strlen) @@ -5307,7 +5522,6 @@ class SimplePie_IRI for ($position++; $remaining; $position++) { $value = ord($string[$position]); - // Check that the byte is valid, then add it to the character: if (($value & 0xC0) === 0x80) { @@ -5328,7 +5542,6 @@ class SimplePie_IRI $valid = false; } } - // Percent encode anything invalid or not in ucschar if ( // Invalid sequences @@ -5358,7 +5571,6 @@ class SimplePie_IRI // If we were a character, pretend we weren't, but rather an error. if ($valid) $position--; - for ($j = $start; $j <= $position; $j++) { $string = substr_replace($string, sprintf('%%%02X', ord($string[$j])), $j, 1); @@ -5368,35 +5580,30 @@ class SimplePie_IRI } } } - return $string; } + protected function remove_iunreserved_percent_encoded($match) { // As we just have valid percent encoded sequences we can just explode // and ignore the first member of the returned array (an empty string). $bytes = explode('%', $match[0]); - // Initialize the new string (this is what will be returned) and that // there are no bytes remaining in the current sequence (unsurprising // at the first byte!). $string = ''; $remaining = 0; - // Loop over each and every byte, and set $value to its value for ($i = 1, $len = count($bytes); $i < $len; $i++) { $value = hexdec($bytes[$i]); - // If we're the first byte of sequence: if (!$remaining) { // Start position $start = $i; - // By default we are valid $valid = true; - // One byte sequence: if ($value <= 0x7F) { @@ -5448,7 +5655,6 @@ class SimplePie_IRI $i--; } } - // If we've reached the end of the current byte sequence, append it to Unicode::$data if (!$remaining) { @@ -5489,7 +5695,6 @@ class SimplePie_IRI } } } - // If we have any bytes left over they are invalid (i.e., we are // mid-way through a multi-byte sequence) if ($remaining) @@ -5499,10 +5704,8 @@ class SimplePie_IRI $string .= '%' . strtoupper($bytes[$j]); } } - return $string; } - protected function scheme_normalization() { if (isset($this->normalization[$this->scheme]['iuserinfo']) && $this->iuserinfo === $this->normalization[$this->scheme]['iuserinfo']) @@ -5530,6 +5733,7 @@ class SimplePie_IRI $this->ifragment = null; } } + public function is_valid() { $isauthority = $this->iuserinfo !== null || $this->ihost !== null || $this->port !== null; @@ -5550,9 +5754,9 @@ class SimplePie_IRI { return false; } - return true; } + public function set_iri($iri) { static $cache; @@ -5560,7 +5764,6 @@ class SimplePie_IRI { $cache = array(); } - if ($iri === null) { return true; @@ -5580,13 +5783,15 @@ class SimplePie_IRI else { $parsed = $this->parse_iri((string) $iri); - + if (!$parsed) + { + return false; + } $return = $this->set_scheme($parsed['scheme']) && $this->set_authority($parsed['authority']) && $this->set_path($parsed['path']) && $this->set_query($parsed['query']) && $this->set_fragment($parsed['fragment']); - $cache[$iri] = array($this->scheme, $this->iuserinfo, $this->ihost, @@ -5598,6 +5803,7 @@ class SimplePie_IRI return $return; } } + public function set_scheme($scheme) { if ($scheme === null) @@ -5615,12 +5821,12 @@ class SimplePie_IRI } return true; } + public function set_authority($authority) { static $cache; if (!$cache) $cache = array(); - if ($authority === null) { $this->iuserinfo = null; @@ -5634,7 +5840,6 @@ class SimplePie_IRI $this->ihost, $this->port, $return) = $cache[$authority]; - return $return; } else @@ -5661,19 +5866,17 @@ class SimplePie_IRI { $port = null; } - $return = $this->set_userinfo($iuserinfo) && $this->set_host($remaining) && $this->set_port($port); - $cache[$authority] = array($this->iuserinfo, $this->ihost, $this->port, $return); - return $return; } } + public function set_userinfo($iuserinfo) { if ($iuserinfo === null) @@ -5685,9 +5888,9 @@ class SimplePie_IRI $this->iuserinfo = $this->replace_invalid_with_pct_encoding($iuserinfo, '!$&\'()*+,;=:'); $this->scheme_normalization(); } - return true; } + public function set_host($ihost) { if ($ihost === null) @@ -5710,7 +5913,6 @@ class SimplePie_IRI else { $ihost = $this->replace_invalid_with_pct_encoding($ihost, '!$&\'()*+,;='); - // Lowercase, but ignore pct-encoded sections (as they should // remain uppercase). This must be done after the previous step // as that can add unescaped characters. @@ -5728,14 +5930,12 @@ class SimplePie_IRI $position++; } } - $this->ihost = $ihost; } - $this->scheme_normalization(); - return true; } + public function set_port($port) { if ($port === null) @@ -5755,6 +5955,7 @@ class SimplePie_IRI return false; } } + public function set_path($ipath) { static $cache; @@ -5762,9 +5963,7 @@ class SimplePie_IRI { $cache = array(); } - $ipath = (string) $ipath; - if (isset($cache[$ipath])) { $this->ipath = $cache[$ipath][(int) ($this->scheme !== null)]; @@ -5773,14 +5972,13 @@ class SimplePie_IRI { $valid = $this->replace_invalid_with_pct_encoding($ipath, '!$&\'()*+,;=@:/'); $removed = $this->remove_dot_segments($valid); - $cache[$ipath] = array($valid, $removed); $this->ipath = ($this->scheme !== null) ? $removed : $valid; } - $this->scheme_normalization(); return true; } + public function set_query($iquery) { if ($iquery === null) @@ -5794,6 +5992,7 @@ class SimplePie_IRI } return true; } + public function set_fragment($ifragment) { if ($ifragment === null) @@ -5807,6 +6006,7 @@ class SimplePie_IRI } return true; } + public function to_uri($string) { static $non_ascii; @@ -5814,7 +6014,6 @@ class SimplePie_IRI { $non_ascii = implode('', range("\x80", "\xFF")); } - $position = 0; $strlen = strlen($string); while (($position += strcspn($string, $non_ascii, $position)) < $strlen) @@ -5823,16 +6022,15 @@ class SimplePie_IRI $position += 3; $strlen += 2; } - return $string; } + public function get_iri() { if (!$this->is_valid()) { return false; } - $iri = ''; if ($this->scheme !== null) { @@ -5858,13 +6056,14 @@ class SimplePie_IRI { $iri .= '#' . $this->ifragment; } - return $iri; } + public function get_uri() { return $this->to_uri($this->get_iri()); } + protected function get_iauthority() { if ($this->iuserinfo !== null || $this->ihost !== null || $this->port !== null) @@ -5889,6 +6088,7 @@ class SimplePie_IRI return null; } } + protected function get_authority() { $iauthority = $this->get_iauthority(); @@ -5900,22 +6100,29 @@ class SimplePie_IRI } class SimplePie_Item { + var $feed; + var $data = array(); + protected $registry; + public function __construct($feed, $data) { $this->feed = $feed; $this->data = $data; } + public function set_registry(SimplePie_Registry $registry) { $this->registry = $registry; } + public function __toString() { return md5(serialize($this->data)); } + public function __destruct() { if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) @@ -5923,6 +6130,7 @@ class SimplePie_Item unset($this->feed); } } + public function get_item_tags($namespace, $tag) { if (isset($this->data['child'][$namespace][$tag])) @@ -5934,18 +6142,22 @@ class SimplePie_Item return null; } } + public function get_base($element = array()) { return $this->feed->get_base($element); } + public function sanitize($data, $type, $base = '') { return $this->feed->sanitize($data, $type, $base); } + public function get_feed() { return $this->feed; } + public function get_id($hash = false) { if (!$hash) @@ -5992,6 +6204,7 @@ class SimplePie_Item return md5(serialize($this->data)); } } + public function get_title() { if (!isset($this->data['title'])) @@ -6031,6 +6244,7 @@ class SimplePie_Item } return $this->data['title']; } + public function get_description($description_only = false) { if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) @@ -6069,7 +6283,6 @@ class SimplePie_Item { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML); } - elseif (!$description_only) { return $this->get_content(true); @@ -6079,6 +6292,7 @@ class SimplePie_Item return null; } } + public function get_content($content_only = false) { if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) @@ -6102,6 +6316,7 @@ class SimplePie_Item return null; } } + public function get_category($key = 0) { $categories = $this->get_categories(); @@ -6114,10 +6329,10 @@ class SimplePie_Item return null; } } + public function get_categories() { $categories = array(); - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) { $term = null; @@ -6160,7 +6375,6 @@ class SimplePie_Item { $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); } - if (!empty($categories)) { return array_unique($categories); @@ -6170,6 +6384,7 @@ class SimplePie_Item return null; } } + public function get_author($key = 0) { $authors = $this->get_authors(); @@ -6182,6 +6397,7 @@ class SimplePie_Item return null; } } + public function get_contributor($key = 0) { $contributors = $this->get_contributors(); @@ -6194,6 +6410,7 @@ class SimplePie_Item return null; } } + public function get_contributors() { $contributors = array(); @@ -6241,7 +6458,6 @@ class SimplePie_Item $contributors[] = $this->registry->create('Author', array($name, $url, $email)); } } - if (!empty($contributors)) { return array_unique($contributors); @@ -6251,6 +6467,7 @@ class SimplePie_Item return null; } } + public function get_authors() { $authors = array(); @@ -6314,7 +6531,6 @@ class SimplePie_Item { $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); } - if (!empty($authors)) { return array_unique($authors); @@ -6332,6 +6548,7 @@ class SimplePie_Item return null; } } + public function get_copyright() { if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) @@ -6351,6 +6568,7 @@ class SimplePie_Item return null; } } + public function get_date($date_format = 'j F Y, g:i a') { if (!isset($this->data['date'])) @@ -6387,7 +6605,6 @@ class SimplePie_Item { $this->data['date']['raw'] = $return[0]['data']; } - if (!empty($this->data['date']['raw'])) { $parser = $this->registry->call('Parse_Date', 'get'); @@ -6405,10 +6622,8 @@ class SimplePie_Item { case '': return $this->sanitize($this->data['date']['raw'], SIMPLEPIE_CONSTRUCT_TEXT); - case 'U': return $this->data['date']['parsed']; - default: return date($date_format, $this->data['date']['parsed']); } @@ -6418,6 +6633,7 @@ class SimplePie_Item return null; } } + public function get_updated_date($date_format = 'j F Y, g:i a') { if (!isset($this->data['updated'])) @@ -6426,7 +6642,6 @@ class SimplePie_Item { $this->data['updated']['raw'] = $return[0]['data']; } - if (!empty($this->data['updated']['raw'])) { $parser = $this->registry->call('Parse_Date', 'get'); @@ -6444,10 +6659,8 @@ class SimplePie_Item { case '': return $this->sanitize($this->data['updated']['raw'], SIMPLEPIE_CONSTRUCT_TEXT); - case 'U': return $this->data['updated']['parsed']; - default: return date($date_format, $this->data['updated']['parsed']); } @@ -6457,6 +6670,7 @@ class SimplePie_Item return null; } } + public function get_local_date($date_format = '%c') { if (!$date_format) @@ -6472,6 +6686,7 @@ class SimplePie_Item return null; } } + public function get_gmdate($date_format = 'j F Y, g:i a') { $date = $this->get_date('U'); @@ -6479,9 +6694,9 @@ class SimplePie_Item { return null; } - return gmdate($date_format, $date); } + public function get_updated_gmdate($date_format = 'j F Y, g:i a') { $date = $this->get_updated_date('U'); @@ -6489,9 +6704,9 @@ class SimplePie_Item { return null; } - return gmdate($date_format, $date); } + public function get_permalink() { $link = $this->get_link(); @@ -6509,6 +6724,7 @@ class SimplePie_Item return null; } } + public function get_link($key = 0, $rel = 'alternate') { $links = $this->get_links($rel); @@ -6521,6 +6737,7 @@ class SimplePie_Item return null; } } + public function get_links($rel = 'alternate') { if (!isset($this->data['links'])) @@ -6532,7 +6749,6 @@ class SimplePie_Item { $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); - } } foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) @@ -6562,7 +6778,6 @@ class SimplePie_Item $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); } } - $keys = array_keys($this->data['links']); foreach ($keys as $key) { @@ -6594,6 +6809,7 @@ class SimplePie_Item return null; } } + public function get_enclosure($key = 0, $prefer = null) { $enclosures = $this->get_enclosures(); @@ -6606,12 +6822,12 @@ class SimplePie_Item return null; } } + public function get_enclosures() { if (!isset($this->data['enclosures'])) { $this->data['enclosures'] = array(); - // Elements $captions_parent = null; $categories_parent = null; @@ -6626,10 +6842,8 @@ class SimplePie_Item $restrictions_parent = null; $thumbnails_parent = null; $title_parent = null; - // Let's do the channel and item-level ones first, and just re-use them if we need to. $parent = $this->get_feed(); - // CAPTIONS if ($captions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) { @@ -6699,7 +6913,6 @@ class SimplePie_Item { $captions_parent = array_values(array_unique($captions_parent)); } - // CATEGORIES foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category) { @@ -6757,7 +6970,6 @@ class SimplePie_Item $label = $this->sanitize($category['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT); } $categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label)); - if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'])) { foreach ((array) $category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'] as $subcategory) @@ -6774,7 +6986,6 @@ class SimplePie_Item { $categories_parent = array_values(array_unique($categories_parent)); } - // COPYRIGHT if ($copyright = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) { @@ -6804,7 +7015,6 @@ class SimplePie_Item } $copyrights_parent = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); } - // CREDITS if ($credits = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) { @@ -6862,7 +7072,6 @@ class SimplePie_Item { $credits_parent = array_values(array_unique($credits_parent)); } - // DESCRIPTION if ($description_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) { @@ -6878,7 +7087,6 @@ class SimplePie_Item $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } } - // DURATION if ($duration_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'duration')) { @@ -6906,7 +7114,6 @@ class SimplePie_Item $duration_parent = $seconds; } } - // HASHES if ($hashes_iterator = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) { @@ -6954,7 +7161,6 @@ class SimplePie_Item { $hashes_parent = array_values(array_unique($hashes_parent)); } - // KEYWORDS if ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) { @@ -7008,7 +7214,6 @@ class SimplePie_Item { $keywords_parent = array_values(array_unique($keywords_parent)); } - // PLAYER if ($player_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) { @@ -7024,7 +7229,6 @@ class SimplePie_Item $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); } } - // RATINGS if ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) { @@ -7098,7 +7302,6 @@ class SimplePie_Item { $ratings_parent = array_values(array_unique($ratings_parent)); } - // RESTRICTIONS if ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) { @@ -7180,7 +7383,6 @@ class SimplePie_Item { $restrictions_parent = array(new SimplePie_Restriction('allow', null, 'default')); } - // THUMBNAILS if ($thumbnails = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) { @@ -7202,7 +7404,6 @@ class SimplePie_Item } } } - // TITLES if ($title_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) { @@ -7218,10 +7419,8 @@ class SimplePie_Item $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } } - // Clear the memory unset($parent); - // Attributes $bitrate = null; $channels = null; @@ -7237,7 +7436,6 @@ class SimplePie_Item $type = null; $url = null; $width = null; - // Elements $captions = null; $categories = null; @@ -7251,7 +7449,6 @@ class SimplePie_Item $restrictions = null; $thumbnails = null; $title = null; - // If we have media:group tags, loop through them. foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group) { @@ -7277,7 +7474,6 @@ class SimplePie_Item $type = null; $url = null; $width = null; - // Elements $captions = null; $categories = null; @@ -7291,7 +7487,6 @@ class SimplePie_Item $restrictions = null; $thumbnails = null; $title = null; - // Start checking the attributes of media:content if (isset($content['attribs']['']['bitrate'])) { @@ -7346,9 +7541,7 @@ class SimplePie_Item $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); } $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); - // Checking the other optional media: elements. Priority: media:content, media:group, item, channel - // CAPTIONS if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) { @@ -7426,7 +7619,6 @@ class SimplePie_Item { $captions = $captions_parent; } - // CATEGORIES if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) { @@ -7492,7 +7684,6 @@ class SimplePie_Item { $categories = array_values(array_unique($categories_parent)); } - // COPYRIGHTS if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) { @@ -7526,7 +7717,6 @@ class SimplePie_Item { $copyrights = $copyrights_parent; } - // CREDITS if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) { @@ -7592,7 +7782,6 @@ class SimplePie_Item { $credits = $credits_parent; } - // DESCRIPTION if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) { @@ -7606,7 +7795,6 @@ class SimplePie_Item { $description = $description_parent; } - // HASHES if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) { @@ -7662,7 +7850,6 @@ class SimplePie_Item { $hashes = $hashes_parent; } - // KEYWORDS if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) { @@ -7700,7 +7887,6 @@ class SimplePie_Item { $keywords = $keywords_parent; } - // PLAYER if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) { @@ -7714,7 +7900,6 @@ class SimplePie_Item { $player = $player_parent; } - // RATINGS if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) { @@ -7770,7 +7955,6 @@ class SimplePie_Item { $ratings = $ratings_parent; } - // RESTRICTIONS if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) { @@ -7828,7 +8012,6 @@ class SimplePie_Item { $restrictions = $restrictions_parent; } - // THUMBNAILS if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) { @@ -7856,7 +8039,6 @@ class SimplePie_Item { $thumbnails = $thumbnails_parent; } - // TITLES if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) { @@ -7870,13 +8052,11 @@ class SimplePie_Item { $title = $title_parent; } - $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width)); } } } } - // If we have standalone media:content tags, loop through them. if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'])) { @@ -7899,7 +8079,6 @@ class SimplePie_Item $type = null; $url = null; $width = null; - // Elements $captions = null; $categories = null; @@ -7913,7 +8092,6 @@ class SimplePie_Item $restrictions = null; $thumbnails = null; $title = null; - // Start checking the attributes of media:content if (isset($content['attribs']['']['bitrate'])) { @@ -7972,7 +8150,6 @@ class SimplePie_Item $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); } // Checking the other optional media: elements. Priority: media:content, media:group, item, channel - // CAPTIONS if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) { @@ -8014,7 +8191,6 @@ class SimplePie_Item { $captions = $captions_parent; } - // CATEGORIES if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) { @@ -8058,7 +8234,6 @@ class SimplePie_Item { $categories = null; } - // COPYRIGHTS if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) { @@ -8078,7 +8253,6 @@ class SimplePie_Item { $copyrights = $copyrights_parent; } - // CREDITS if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) { @@ -8114,7 +8288,6 @@ class SimplePie_Item { $credits = $credits_parent; } - // DESCRIPTION if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) { @@ -8124,7 +8297,6 @@ class SimplePie_Item { $description = $description_parent; } - // HASHES if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) { @@ -8155,7 +8327,6 @@ class SimplePie_Item { $hashes = $hashes_parent; } - // KEYWORDS if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) { @@ -8177,7 +8348,6 @@ class SimplePie_Item { $keywords = $keywords_parent; } - // PLAYER if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) { @@ -8187,7 +8357,6 @@ class SimplePie_Item { $player = $player_parent; } - // RATINGS if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) { @@ -8218,7 +8387,6 @@ class SimplePie_Item { $ratings = $ratings_parent; } - // RESTRICTIONS if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) { @@ -8250,7 +8418,6 @@ class SimplePie_Item { $restrictions = $restrictions_parent; } - // THUMBNAILS if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) { @@ -8267,7 +8434,6 @@ class SimplePie_Item { $thumbnails = $thumbnails_parent; } - // TITLES if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) { @@ -8277,12 +8443,10 @@ class SimplePie_Item { $title = $title_parent; } - $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width)); } } } - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) { if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') @@ -8302,7 +8466,6 @@ class SimplePie_Item $type = null; $url = null; $width = null; - $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); if (isset($link['attribs']['']['type'])) { @@ -8312,12 +8475,10 @@ class SimplePie_Item { $length = ceil($link['attribs']['']['length']); } - // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width)); } } - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) { if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') @@ -8337,7 +8498,6 @@ class SimplePie_Item $type = null; $url = null; $width = null; - $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); if (isset($link['attribs']['']['type'])) { @@ -8347,12 +8507,10 @@ class SimplePie_Item { $length = ceil($link['attribs']['']['length']); } - // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width)); } } - if ($enclosure = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure')) { if (isset($enclosure[0]['attribs']['']['url'])) @@ -8372,7 +8530,6 @@ class SimplePie_Item $type = null; $url = null; $width = null; - $url = $this->sanitize($enclosure[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($enclosure[0])); if (isset($enclosure[0]['attribs']['']['type'])) { @@ -8382,18 +8539,15 @@ class SimplePie_Item { $length = ceil($enclosure[0]['attribs']['']['length']); } - // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width)); } } - if (sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width)) { // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width)); } - $this->data['enclosures'] = array_values(array_unique($this->data['enclosures'])); } if (!empty($this->data['enclosures'])) @@ -8405,6 +8559,7 @@ class SimplePie_Item return null; } } + public function get_latitude() { if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) @@ -8420,6 +8575,7 @@ class SimplePie_Item return null; } } + public function get_longitude() { if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) @@ -8439,6 +8595,7 @@ class SimplePie_Item return null; } } + public function get_source() { if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source')) @@ -8465,33 +8622,34 @@ class SimplePie_Locator var $checked_feeds = 0; var $max_checked_feeds = 10; protected $registry; - public function __construct(SimplePie_File $file, $timeout = 10, $useragent = null, $max_checked_feeds = 10) { $this->file = $file; $this->useragent = $useragent; $this->timeout = $timeout; $this->max_checked_feeds = $max_checked_feeds; - - $this->dom = new DOMDocument(); - - set_error_handler(array('SimplePie_Misc', 'silence_errors')); - $this->dom->loadHTML($this->file->body); - restore_error_handler(); + if (class_exists('DOMDocument')) + { + $this->dom = new DOMDocument(); + set_error_handler(array('SimplePie_Misc', 'silence_errors')); + $this->dom->loadHTML($this->file->body); + restore_error_handler(); + } + else + { + $this->dom = null; + } } - public function set_registry(SimplePie_Registry $registry) { $this->registry = $registry; } - public function find($type = SIMPLEPIE_LOCATOR_ALL, &$working) { if ($this->is_feed($this->file)) { return $this->file; } - if ($this->file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) { $sniffer = $this->registry->create('Content_Type_Sniffer', array($this->file)); @@ -8500,34 +8658,28 @@ class SimplePie_Locator return null; } } - if ($type & ~SIMPLEPIE_LOCATOR_NONE) { $this->get_base(); } - if ($type & SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working = $this->autodiscovery()) { return $working[0]; } - if ($type & (SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY | SIMPLEPIE_LOCATOR_REMOTE_EXTENSION | SIMPLEPIE_LOCATOR_REMOTE_BODY) && $this->get_links()) { if ($type & SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working = $this->extension($this->local)) { return $working; } - if ($type & SIMPLEPIE_LOCATOR_LOCAL_BODY && $working = $this->body($this->local)) { return $working; } - if ($type & SIMPLEPIE_LOCATOR_REMOTE_EXTENSION && $working = $this->extension($this->elsewhere)) { return $working; } - if ($type & SIMPLEPIE_LOCATOR_REMOTE_BODY && $working = $this->body($this->elsewhere)) { return $working; @@ -8535,7 +8687,6 @@ class SimplePie_Locator } return null; } - public function is_feed($file) { if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) @@ -8560,9 +8711,12 @@ class SimplePie_Locator return false; } } - public function get_base() { + if ($this->dom === null) + { + throw new SimplePie_Exception('DOMDocument not found, unable to use locator'); + } $this->http_base = $this->file->url; $this->base = $this->http_base; $elements = $this->dom->getElementsByTagName('base'); @@ -8570,13 +8724,17 @@ class SimplePie_Locator { if ($element->hasAttribute('href')) { - $this->base = $this->registry->call('Misc', 'absolutize_url', array(trim($element->getAttribute('href')), $this->http_base)); + $base = $this->registry->call('Misc', 'absolutize_url', array(trim($element->getAttribute('href')), $this->http_base)); + if ($base === false) + { + continue; + } + $this->base = $base; $this->base_location = method_exists($element, 'getLineNo') ? $element->getLineNo() : 0; break; } } } - public function autodiscovery() { $done = array(); @@ -8584,7 +8742,6 @@ class SimplePie_Locator $feeds = array_merge($feeds, $this->search_elements_by_tag('link', $done, $feeds)); $feeds = array_merge($feeds, $this->search_elements_by_tag('a', $done, $feeds)); $feeds = array_merge($feeds, $this->search_elements_by_tag('area', $done, $feeds)); - if (!empty($feeds)) { return array_values($feeds); @@ -8594,9 +8751,12 @@ class SimplePie_Locator return null; } } - protected function search_elements_by_tag($name, &$done, $feeds) { + if ($this->dom === null) + { + throw new SimplePie_Exception('DOMDocument not found, unable to use locator'); + } $links = $this->dom->getElementsByTagName($name); foreach ($links as $link) { @@ -8608,7 +8768,6 @@ class SimplePie_Locator { $rel = array_unique($this->registry->call('Misc', 'space_seperated_tokens', array(strtolower($link->getAttribute('rel'))))); $line = method_exists($link, 'getLineNo') ? $link->getLineNo() : 1; - if ($this->base_location < $line) { $href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->base)); @@ -8617,7 +8776,10 @@ class SimplePie_Locator { $href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->http_base)); } - + if ($href === false) + { + continue; + } if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !in_array('stylesheet', $rel) && $link->hasAttribute('type') && in_array(strtolower($this->registry->call('Misc', 'parse_mime', array($link->getAttribute('type')))), array('application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href])) { $this->checked_feeds++; @@ -8633,12 +8795,14 @@ class SimplePie_Locator $done[] = $href; } } - return $feeds; } - public function get_links() { + if ($this->dom === null) + { + throw new SimplePie_Exception('DOMDocument not found, unable to use locator'); + } $links = $this->dom->getElementsByTagName('a'); foreach ($links as $link) { @@ -8656,9 +8820,11 @@ class SimplePie_Locator { $href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->http_base)); } - + if ($href === false) + { + continue; + } $current = $this->registry->call('Misc', 'parse_url', array($this->file->url)); - if ($parsed['authority'] === '' || $parsed['authority'] === $current['authority']) { $this->local[] = $href; @@ -8678,7 +8844,6 @@ class SimplePie_Locator } return null; } - public function extension(&$array) { foreach ($array as $key => $value) @@ -8690,7 +8855,6 @@ class SimplePie_Locator if (in_array(strtolower(strrchr($value, '.')), array('.rss', '.rdf', '.atom', '.xml'))) { $this->checked_feeds++; - $headers = array( 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', ); @@ -8707,7 +8871,6 @@ class SimplePie_Locator } return null; } - public function body(&$array) { foreach ($array as $key => $value) @@ -8741,14 +8904,12 @@ class SimplePie_Misc public static function time_hms($seconds) { $time = ''; - $hours = floor($seconds / 3600); $remainder = $seconds % 3600; if ($hours > 0) { $time .= $hours.':'; } - $minutes = floor($remainder / 60); $seconds = $remainder % 60; if ($minutes < 10 && $hours > 0) @@ -8759,18 +8920,20 @@ class SimplePie_Misc { $seconds = '0' . $seconds; } - $time .= $minutes.':'; $time .= $seconds; - return $time; } - public static function absolutize_url($relative, $base) { $iri = SimplePie_IRI::absolutize(new SimplePie_IRI($base), $relative); + if ($iri === false) + { + return false; + } return $iri->get_uri(); } + public static function get_element($realname, $string) { $return = array(); @@ -8807,7 +8970,6 @@ class SimplePie_Misc } return $return; } - public static function element_implode($element) { $full = "<$element[tag]"; @@ -8826,7 +8988,6 @@ class SimplePie_Misc } return $full; } - public static function error($message, $level, $file, $line) { if ((ini_get('error_reporting') & $level) > 0) @@ -8846,28 +9007,23 @@ class SimplePie_Misc $note = 'Unknown Error'; break; } - $log_error = true; if (!function_exists('error_log')) { $log_error = false; } - $log_file = @ini_get('error_log'); if (!empty($log_file) && ('syslog' !== $log_file) && !@is_writable($log_file)) { $log_error = false; } - if ($log_error) { @error_log("$note: $message in $file on line $line", 0); } } - return $message; } - public static function fix_protocol($url, $http = 1) { $url = SimplePie_Misc::normalize_url($url); @@ -8876,12 +9032,10 @@ class SimplePie_Misc { return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http); } - if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url)) { return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http); } - if ($http === 2 && $parsed['scheme'] !== '') { return "feed:$url"; @@ -8899,7 +9053,6 @@ class SimplePie_Misc return $url; } } - public static function parse_url($url) { $iri = new SimplePie_IRI($url); @@ -8911,7 +9064,6 @@ class SimplePie_Misc 'fragment' => (string) $iri->fragment ); } - public static function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '') { $iri = new SimplePie_IRI(''); @@ -8922,13 +9074,11 @@ class SimplePie_Misc $iri->fragment = $fragment; return $iri->get_uri(); } - public static function normalize_url($url) { $iri = new SimplePie_IRI($url); return $iri->get_uri(); } - public static function percent_encoding_normalization($match) { $integer = hexdec($match[1]); @@ -8941,17 +9091,17 @@ class SimplePie_Misc return strtoupper($match[0]); } } + public static function windows_1252_to_utf8($string) { static $convert_table = array("\x80" => "\xE2\x82\xAC", "\x81" => "\xEF\xBF\xBD", "\x82" => "\xE2\x80\x9A", "\x83" => "\xC6\x92", "\x84" => "\xE2\x80\x9E", "\x85" => "\xE2\x80\xA6", "\x86" => "\xE2\x80\xA0", "\x87" => "\xE2\x80\xA1", "\x88" => "\xCB\x86", "\x89" => "\xE2\x80\xB0", "\x8A" => "\xC5\xA0", "\x8B" => "\xE2\x80\xB9", "\x8C" => "\xC5\x92", "\x8D" => "\xEF\xBF\xBD", "\x8E" => "\xC5\xBD", "\x8F" => "\xEF\xBF\xBD", "\x90" => "\xEF\xBF\xBD", "\x91" => "\xE2\x80\x98", "\x92" => "\xE2\x80\x99", "\x93" => "\xE2\x80\x9C", "\x94" => "\xE2\x80\x9D", "\x95" => "\xE2\x80\xA2", "\x96" => "\xE2\x80\x93", "\x97" => "\xE2\x80\x94", "\x98" => "\xCB\x9C", "\x99" => "\xE2\x84\xA2", "\x9A" => "\xC5\xA1", "\x9B" => "\xE2\x80\xBA", "\x9C" => "\xC5\x93", "\x9D" => "\xEF\xBF\xBD", "\x9E" => "\xC5\xBE", "\x9F" => "\xC5\xB8", "\xA0" => "\xC2\xA0", "\xA1" => "\xC2\xA1", "\xA2" => "\xC2\xA2", "\xA3" => "\xC2\xA3", "\xA4" => "\xC2\xA4", "\xA5" => "\xC2\xA5", "\xA6" => "\xC2\xA6", "\xA7" => "\xC2\xA7", "\xA8" => "\xC2\xA8", "\xA9" => "\xC2\xA9", "\xAA" => "\xC2\xAA", "\xAB" => "\xC2\xAB", "\xAC" => "\xC2\xAC", "\xAD" => "\xC2\xAD", "\xAE" => "\xC2\xAE", "\xAF" => "\xC2\xAF", "\xB0" => "\xC2\xB0", "\xB1" => "\xC2\xB1", "\xB2" => "\xC2\xB2", "\xB3" => "\xC2\xB3", "\xB4" => "\xC2\xB4", "\xB5" => "\xC2\xB5", "\xB6" => "\xC2\xB6", "\xB7" => "\xC2\xB7", "\xB8" => "\xC2\xB8", "\xB9" => "\xC2\xB9", "\xBA" => "\xC2\xBA", "\xBB" => "\xC2\xBB", "\xBC" => "\xC2\xBC", "\xBD" => "\xC2\xBD", "\xBE" => "\xC2\xBE", "\xBF" => "\xC2\xBF", "\xC0" => "\xC3\x80", "\xC1" => "\xC3\x81", "\xC2" => "\xC3\x82", "\xC3" => "\xC3\x83", "\xC4" => "\xC3\x84", "\xC5" => "\xC3\x85", "\xC6" => "\xC3\x86", "\xC7" => "\xC3\x87", "\xC8" => "\xC3\x88", "\xC9" => "\xC3\x89", "\xCA" => "\xC3\x8A", "\xCB" => "\xC3\x8B", "\xCC" => "\xC3\x8C", "\xCD" => "\xC3\x8D", "\xCE" => "\xC3\x8E", "\xCF" => "\xC3\x8F", "\xD0" => "\xC3\x90", "\xD1" => "\xC3\x91", "\xD2" => "\xC3\x92", "\xD3" => "\xC3\x93", "\xD4" => "\xC3\x94", "\xD5" => "\xC3\x95", "\xD6" => "\xC3\x96", "\xD7" => "\xC3\x97", "\xD8" => "\xC3\x98", "\xD9" => "\xC3\x99", "\xDA" => "\xC3\x9A", "\xDB" => "\xC3\x9B", "\xDC" => "\xC3\x9C", "\xDD" => "\xC3\x9D", "\xDE" => "\xC3\x9E", "\xDF" => "\xC3\x9F", "\xE0" => "\xC3\xA0", "\xE1" => "\xC3\xA1", "\xE2" => "\xC3\xA2", "\xE3" => "\xC3\xA3", "\xE4" => "\xC3\xA4", "\xE5" => "\xC3\xA5", "\xE6" => "\xC3\xA6", "\xE7" => "\xC3\xA7", "\xE8" => "\xC3\xA8", "\xE9" => "\xC3\xA9", "\xEA" => "\xC3\xAA", "\xEB" => "\xC3\xAB", "\xEC" => "\xC3\xAC", "\xED" => "\xC3\xAD", "\xEE" => "\xC3\xAE", "\xEF" => "\xC3\xAF", "\xF0" => "\xC3\xB0", "\xF1" => "\xC3\xB1", "\xF2" => "\xC3\xB2", "\xF3" => "\xC3\xB3", "\xF4" => "\xC3\xB4", "\xF5" => "\xC3\xB5", "\xF6" => "\xC3\xB6", "\xF7" => "\xC3\xB7", "\xF8" => "\xC3\xB8", "\xF9" => "\xC3\xB9", "\xFA" => "\xC3\xBA", "\xFB" => "\xC3\xBB", "\xFC" => "\xC3\xBC", "\xFD" => "\xC3\xBD", "\xFE" => "\xC3\xBE", "\xFF" => "\xC3\xBF"); - return strtr($string, $convert_table); } + public static function change_encoding($data, $input, $output) { $input = SimplePie_Misc::encoding($input); $output = SimplePie_Misc::encoding($output); - // We fail to fail on non US-ASCII bytes if ($input === 'US-ASCII') { @@ -8965,7 +9115,6 @@ class SimplePie_Misc } $data = substr($data, 0, strcspn($data, $non_ascii_octects)); } - // This is first, as behaviour of this is completely predictable if ($input === 'windows-1252' && $output === 'UTF-8') { @@ -8987,7 +9136,6 @@ class SimplePie_Misc return false; } } - protected static function change_encoding_mbstring($data, $input, $output) { if ($input === 'windows-949') @@ -9006,7 +9154,6 @@ class SimplePie_Misc { $output = 'SJIS'; } - // Check that the encoding is supported if (@mb_convert_encoding("\x80", 'UTF-16BE', $input) === "\x00\x80") { @@ -9016,20 +9163,18 @@ class SimplePie_Misc { return false; } - // Let's do some conversion if ($return = @mb_convert_encoding($data, $output, $input)) { return $return; } - return false; } - protected static function change_encoding_iconv($data, $input, $output) { return @iconv($input, $output, $data); } + public static function encoding($charset) { // Normalization from UTS #22 @@ -9038,44 +9183,35 @@ class SimplePie_Misc case 'adobestandardencoding': case 'csadobestandardencoding': return 'Adobe-Standard-Encoding'; - case 'adobesymbolencoding': case 'cshppsmath': return 'Adobe-Symbol-Encoding'; - case 'ami1251': case 'amiga1251': return 'Amiga-1251'; - case 'ansix31101983': case 'csat5001983': case 'csiso99naplps': case 'isoir99': case 'naplps': return 'ANSI_X3.110-1983'; - case 'arabic7': case 'asmo449': case 'csiso89asmo449': case 'iso9036': case 'isoir89': return 'ASMO_449'; - case 'big5': case 'csbig5': return 'Big5'; - case 'big5hkscs': return 'Big5-HKSCS'; - case 'bocu1': case 'csbocu1': return 'BOCU-1'; - case 'brf': case 'csbrf': return 'BRF'; - case 'bs4730': case 'csiso4unitedkingdom': case 'gb': @@ -9083,16 +9219,13 @@ class SimplePie_Misc case 'isoir4': case 'uk': return 'BS_4730'; - case 'bsviewdata': case 'csiso47bsviewdata': case 'isoir47': return 'BS_viewdata'; - case 'cesu8': case 'cscesu8': return 'CESU-8'; - case 'ca': case 'csa71': case 'csaz243419851': @@ -9100,136 +9233,107 @@ class SimplePie_Misc case 'iso646ca': case 'isoir121': return 'CSA_Z243.4-1985-1'; - case 'csa72': case 'csaz243419852': case 'csiso122canadian2': case 'iso646ca2': case 'isoir122': return 'CSA_Z243.4-1985-2'; - case 'csaz24341985gr': case 'csiso123csaz24341985gr': case 'isoir123': return 'CSA_Z243.4-1985-gr'; - case 'csiso139csn369103': case 'csn369103': case 'isoir139': return 'CSN_369103'; - case 'csdecmcs': case 'dec': case 'decmcs': return 'DEC-MCS'; - case 'csiso21german': case 'de': case 'din66003': case 'iso646de': case 'isoir21': return 'DIN_66003'; - case 'csdkus': case 'dkus': return 'dk-us'; - case 'csiso646danish': case 'dk': case 'ds2089': case 'iso646dk': return 'DS_2089'; - case 'csibmebcdicatde': case 'ebcdicatde': return 'EBCDIC-AT-DE'; - case 'csebcdicatdea': case 'ebcdicatdea': return 'EBCDIC-AT-DE-A'; - case 'csebcdiccafr': case 'ebcdiccafr': return 'EBCDIC-CA-FR'; - case 'csebcdicdkno': case 'ebcdicdkno': return 'EBCDIC-DK-NO'; - case 'csebcdicdknoa': case 'ebcdicdknoa': return 'EBCDIC-DK-NO-A'; - case 'csebcdices': case 'ebcdices': return 'EBCDIC-ES'; - case 'csebcdicesa': case 'ebcdicesa': return 'EBCDIC-ES-A'; - case 'csebcdicess': case 'ebcdicess': return 'EBCDIC-ES-S'; - case 'csebcdicfise': case 'ebcdicfise': return 'EBCDIC-FI-SE'; - case 'csebcdicfisea': case 'ebcdicfisea': return 'EBCDIC-FI-SE-A'; - case 'csebcdicfr': case 'ebcdicfr': return 'EBCDIC-FR'; - case 'csebcdicit': case 'ebcdicit': return 'EBCDIC-IT'; - case 'csebcdicpt': case 'ebcdicpt': return 'EBCDIC-PT'; - case 'csebcdicuk': case 'ebcdicuk': return 'EBCDIC-UK'; - case 'csebcdicus': case 'ebcdicus': return 'EBCDIC-US'; - case 'csiso111ecmacyrillic': case 'ecmacyrillic': case 'isoir111': case 'koi8e': return 'ECMA-cyrillic'; - case 'csiso17spanish': case 'es': case 'iso646es': case 'isoir17': return 'ES'; - case 'csiso85spanish2': case 'es2': case 'iso646es2': case 'isoir85': return 'ES2'; - case 'cseucpkdfmtjapanese': case 'eucjp': case 'extendedunixcodepackedformatforjapanese': return 'EUC-JP'; - case 'cseucfixwidjapanese': case 'extendedunixcodefixedwidthforjapanese': return 'Extended_UNIX_Code_Fixed_Width_for_Japanese'; - case 'gb18030': return 'GB18030'; - case 'chinese': case 'cp936': case 'csgb2312': @@ -9241,69 +9345,55 @@ class SimplePie_Misc case 'ms936': case 'windows936': return 'GBK'; - case 'cn': case 'csiso57gb1988': case 'gb198880': case 'iso646cn': case 'isoir57': return 'GB_1988-80'; - case 'csiso153gost1976874': case 'gost1976874': case 'isoir153': case 'stsev35888': return 'GOST_19768-74'; - case 'csiso150': case 'csiso150greekccitt': case 'greekccitt': case 'isoir150': return 'greek-ccitt'; - case 'csiso88greek7': case 'greek7': case 'isoir88': return 'greek7'; - case 'csiso18greek7old': case 'greek7old': case 'isoir18': return 'greek7-old'; - case 'cshpdesktop': case 'hpdesktop': return 'HP-DeskTop'; - case 'cshplegal': case 'hplegal': return 'HP-Legal'; - case 'cshpmath8': case 'hpmath8': return 'HP-Math8'; - case 'cshppifont': case 'hppifont': return 'HP-Pi-font'; - case 'cshproman8': case 'hproman8': case 'r8': case 'roman8': return 'hp-roman8'; - case 'hzgb2312': return 'HZ-GB-2312'; - case 'csibmsymbols': case 'ibmsymbols': return 'IBM-Symbols'; - case 'csibmthai': case 'ibmthai': return 'IBM-Thai'; - case 'cp37': case 'csibm37': case 'ebcdiccpca': @@ -9312,379 +9402,312 @@ class SimplePie_Misc case 'ebcdiccpwt': case 'ibm37': return 'IBM037'; - case 'cp38': case 'csibm38': case 'ebcdicint': case 'ibm38': return 'IBM038'; - case 'cp273': case 'csibm273': case 'ibm273': return 'IBM273'; - case 'cp274': case 'csibm274': case 'ebcdicbe': case 'ibm274': return 'IBM274'; - case 'cp275': case 'csibm275': case 'ebcdicbr': case 'ibm275': return 'IBM275'; - case 'csibm277': case 'ebcdiccpdk': case 'ebcdiccpno': case 'ibm277': return 'IBM277'; - case 'cp278': case 'csibm278': case 'ebcdiccpfi': case 'ebcdiccpse': case 'ibm278': return 'IBM278'; - case 'cp280': case 'csibm280': case 'ebcdiccpit': case 'ibm280': return 'IBM280'; - case 'cp281': case 'csibm281': case 'ebcdicjpe': case 'ibm281': return 'IBM281'; - case 'cp284': case 'csibm284': case 'ebcdiccpes': case 'ibm284': return 'IBM284'; - case 'cp285': case 'csibm285': case 'ebcdiccpgb': case 'ibm285': return 'IBM285'; - case 'cp290': case 'csibm290': case 'ebcdicjpkana': case 'ibm290': return 'IBM290'; - case 'cp297': case 'csibm297': case 'ebcdiccpfr': case 'ibm297': return 'IBM297'; - case 'cp420': case 'csibm420': case 'ebcdiccpar1': case 'ibm420': return 'IBM420'; - case 'cp423': case 'csibm423': case 'ebcdiccpgr': case 'ibm423': return 'IBM423'; - case 'cp424': case 'csibm424': case 'ebcdiccphe': case 'ibm424': return 'IBM424'; - case '437': case 'cp437': case 'cspc8codepage437': case 'ibm437': return 'IBM437'; - case 'cp500': case 'csibm500': case 'ebcdiccpbe': case 'ebcdiccpch': case 'ibm500': return 'IBM500'; - case 'cp775': case 'cspc775baltic': case 'ibm775': return 'IBM775'; - case '850': case 'cp850': case 'cspc850multilingual': case 'ibm850': return 'IBM850'; - case '851': case 'cp851': case 'csibm851': case 'ibm851': return 'IBM851'; - case '852': case 'cp852': case 'cspcp852': case 'ibm852': return 'IBM852'; - case '855': case 'cp855': case 'csibm855': case 'ibm855': return 'IBM855'; - case '857': case 'cp857': case 'csibm857': case 'ibm857': return 'IBM857'; - case 'ccsid858': case 'cp858': case 'ibm858': case 'pcmultilingual850euro': return 'IBM00858'; - case '860': case 'cp860': case 'csibm860': case 'ibm860': return 'IBM860'; - case '861': case 'cp861': case 'cpis': case 'csibm861': case 'ibm861': return 'IBM861'; - case '862': case 'cp862': case 'cspc862latinhebrew': case 'ibm862': return 'IBM862'; - case '863': case 'cp863': case 'csibm863': case 'ibm863': return 'IBM863'; - case 'cp864': case 'csibm864': case 'ibm864': return 'IBM864'; - case '865': case 'cp865': case 'csibm865': case 'ibm865': return 'IBM865'; - case '866': case 'cp866': case 'csibm866': case 'ibm866': return 'IBM866'; - case 'cp868': case 'cpar': case 'csibm868': case 'ibm868': return 'IBM868'; - case '869': case 'cp869': case 'cpgr': case 'csibm869': case 'ibm869': return 'IBM869'; - case 'cp870': case 'csibm870': case 'ebcdiccproece': case 'ebcdiccpyu': case 'ibm870': return 'IBM870'; - case 'cp871': case 'csibm871': case 'ebcdiccpis': case 'ibm871': return 'IBM871'; - case 'cp880': case 'csibm880': case 'ebcdiccyrillic': case 'ibm880': return 'IBM880'; - case 'cp891': case 'csibm891': case 'ibm891': return 'IBM891'; - case 'cp903': case 'csibm903': case 'ibm903': return 'IBM903'; - case '904': case 'cp904': case 'csibbm904': case 'ibm904': return 'IBM904'; - case 'cp905': case 'csibm905': case 'ebcdiccptr': case 'ibm905': return 'IBM905'; - case 'cp918': case 'csibm918': case 'ebcdiccpar2': case 'ibm918': return 'IBM918'; - case 'ccsid924': case 'cp924': case 'ebcdiclatin9euro': case 'ibm924': return 'IBM00924'; - case 'cp1026': case 'csibm1026': case 'ibm1026': return 'IBM1026'; - case 'ibm1047': return 'IBM1047'; - case 'ccsid1140': case 'cp1140': case 'ebcdicus37euro': case 'ibm1140': return 'IBM01140'; - case 'ccsid1141': case 'cp1141': case 'ebcdicde273euro': case 'ibm1141': return 'IBM01141'; - case 'ccsid1142': case 'cp1142': case 'ebcdicdk277euro': case 'ebcdicno277euro': case 'ibm1142': return 'IBM01142'; - case 'ccsid1143': case 'cp1143': case 'ebcdicfi278euro': case 'ebcdicse278euro': case 'ibm1143': return 'IBM01143'; - case 'ccsid1144': case 'cp1144': case 'ebcdicit280euro': case 'ibm1144': return 'IBM01144'; - case 'ccsid1145': case 'cp1145': case 'ebcdices284euro': case 'ibm1145': return 'IBM01145'; - case 'ccsid1146': case 'cp1146': case 'ebcdicgb285euro': case 'ibm1146': return 'IBM01146'; - case 'ccsid1147': case 'cp1147': case 'ebcdicfr297euro': case 'ibm1147': return 'IBM01147'; - case 'ccsid1148': case 'cp1148': case 'ebcdicinternational500euro': case 'ibm1148': return 'IBM01148'; - case 'ccsid1149': case 'cp1149': case 'ebcdicis871euro': case 'ibm1149': return 'IBM01149'; - case 'csiso143iecp271': case 'iecp271': case 'isoir143': return 'IEC_P27-1'; - case 'csiso49inis': case 'inis': case 'isoir49': return 'INIS'; - case 'csiso50inis8': case 'inis8': case 'isoir50': return 'INIS-8'; - case 'csiso51iniscyrillic': case 'iniscyrillic': case 'isoir51': return 'INIS-cyrillic'; - case 'csinvariant': case 'invariant': return 'INVARIANT'; - case 'iso2022cn': return 'ISO-2022-CN'; - case 'iso2022cnext': return 'ISO-2022-CN-EXT'; - case 'csiso2022jp': case 'iso2022jp': return 'ISO-2022-JP'; - case 'csiso2022jp2': case 'iso2022jp2': return 'ISO-2022-JP-2'; - case 'csiso2022kr': case 'iso2022kr': return 'ISO-2022-KR'; - case 'cswindows30latin1': case 'iso88591windows30latin1': return 'ISO-8859-1-Windows-3.0-Latin-1'; - case 'cswindows31latin1': case 'iso88591windows31latin1': return 'ISO-8859-1-Windows-3.1-Latin-1'; - case 'csisolatin2': case 'iso88592': case 'iso885921987': @@ -9692,11 +9715,9 @@ class SimplePie_Misc case 'l2': case 'latin2': return 'ISO-8859-2'; - case 'cswindows31latin2': case 'iso88592windowslatin2': return 'ISO-8859-2-Windows-Latin-2'; - case 'csisolatin3': case 'iso88593': case 'iso885931988': @@ -9704,7 +9725,6 @@ class SimplePie_Misc case 'l3': case 'latin3': return 'ISO-8859-3'; - case 'csisolatin4': case 'iso88594': case 'iso885941988': @@ -9712,14 +9732,12 @@ class SimplePie_Misc case 'l4': case 'latin4': return 'ISO-8859-4'; - case 'csisolatincyrillic': case 'cyrillic': case 'iso88595': case 'iso885951988': case 'isoir144': return 'ISO-8859-5'; - case 'arabic': case 'asmo708': case 'csisolatinarabic': @@ -9728,15 +9746,12 @@ class SimplePie_Misc case 'iso885961987': case 'isoir127': return 'ISO-8859-6'; - case 'csiso88596e': case 'iso88596e': return 'ISO-8859-6-E'; - case 'csiso88596i': case 'iso88596i': return 'ISO-8859-6-I'; - case 'csisolatingreek': case 'ecma118': case 'elot928': @@ -9746,26 +9761,21 @@ class SimplePie_Misc case 'iso885971987': case 'isoir126': return 'ISO-8859-7'; - case 'csisolatinhebrew': case 'hebrew': case 'iso88598': case 'iso885981988': case 'isoir138': return 'ISO-8859-8'; - case 'csiso88598e': case 'iso88598e': return 'ISO-8859-8-E'; - case 'csiso88598i': case 'iso88598i': return 'ISO-8859-8-I'; - case 'cswindows31latin5': case 'iso88599windowslatin5': return 'ISO-8859-9-Windows-Latin-5'; - case 'csisolatin6': case 'iso885910': case 'iso8859101992': @@ -9773,10 +9783,8 @@ class SimplePie_Misc case 'l6': case 'latin6': return 'ISO-8859-10'; - case 'iso885913': return 'ISO-8859-13'; - case 'iso885914': case 'iso8859141998': case 'isoceltic': @@ -9784,130 +9792,103 @@ class SimplePie_Misc case 'l8': case 'latin8': return 'ISO-8859-14'; - case 'iso885915': case 'latin9': return 'ISO-8859-15'; - case 'iso885916': case 'iso8859162001': case 'isoir226': case 'l10': case 'latin10': return 'ISO-8859-16'; - case 'iso10646j1': return 'ISO-10646-J-1'; - case 'csunicode': case 'iso10646ucs2': return 'ISO-10646-UCS-2'; - case 'csucs4': case 'iso10646ucs4': return 'ISO-10646-UCS-4'; - case 'csunicodeascii': case 'iso10646ucsbasic': return 'ISO-10646-UCS-Basic'; - case 'csunicodelatin1': case 'iso10646': case 'iso10646unicodelatin1': return 'ISO-10646-Unicode-Latin1'; - case 'csiso10646utf1': case 'iso10646utf1': return 'ISO-10646-UTF-1'; - case 'csiso115481': case 'iso115481': case 'isotr115481': return 'ISO-11548-1'; - case 'csiso90': case 'isoir90': return 'iso-ir-90'; - case 'csunicodeibm1261': case 'isounicodeibm1261': return 'ISO-Unicode-IBM-1261'; - case 'csunicodeibm1264': case 'isounicodeibm1264': return 'ISO-Unicode-IBM-1264'; - case 'csunicodeibm1265': case 'isounicodeibm1265': return 'ISO-Unicode-IBM-1265'; - case 'csunicodeibm1268': case 'isounicodeibm1268': return 'ISO-Unicode-IBM-1268'; - case 'csunicodeibm1276': case 'isounicodeibm1276': return 'ISO-Unicode-IBM-1276'; - case 'csiso646basic1983': case 'iso646basic1983': case 'ref': return 'ISO_646.basic:1983'; - case 'csiso2intlrefversion': case 'irv': case 'iso646irv1983': case 'isoir2': return 'ISO_646.irv:1983'; - case 'csiso2033': case 'e13b': case 'iso20331983': case 'isoir98': return 'ISO_2033-1983'; - case 'csiso5427cyrillic': case 'iso5427': case 'isoir37': return 'ISO_5427'; - case 'iso5427cyrillic1981': case 'iso54271981': case 'isoir54': return 'ISO_5427:1981'; - case 'csiso5428greek': case 'iso54281980': case 'isoir55': return 'ISO_5428:1980'; - case 'csiso6937add': case 'iso6937225': case 'isoir152': return 'ISO_6937-2-25'; - case 'csisotextcomm': case 'iso69372add': case 'isoir142': return 'ISO_6937-2-add'; - case 'csiso8859supp': case 'iso8859supp': case 'isoir154': case 'latin125': return 'ISO_8859-supp'; - case 'csiso10367box': case 'iso10367box': case 'isoir155': return 'ISO_10367-box'; - case 'csiso15italian': case 'iso646it': case 'isoir15': case 'it': return 'IT'; - case 'csiso13jisc6220jp': case 'isoir13': case 'jisc62201969': @@ -9915,77 +9896,64 @@ class SimplePie_Misc case 'katakana': case 'x2017': return 'JIS_C6220-1969-jp'; - case 'csiso14jisc6220ro': case 'iso646jp': case 'isoir14': case 'jisc62201969ro': case 'jp': return 'JIS_C6220-1969-ro'; - case 'csiso42jisc62261978': case 'isoir42': case 'jisc62261978': return 'JIS_C6226-1978'; - case 'csiso87jisx208': case 'isoir87': case 'jisc62261983': case 'jisx2081983': case 'x208': return 'JIS_C6226-1983'; - case 'csiso91jisc62291984a': case 'isoir91': case 'jisc62291984a': case 'jpocra': return 'JIS_C6229-1984-a'; - case 'csiso92jisc62991984b': case 'iso646jpocrb': case 'isoir92': case 'jisc62291984b': case 'jpocrb': return 'JIS_C6229-1984-b'; - case 'csiso93jis62291984badd': case 'isoir93': case 'jisc62291984badd': case 'jpocrbadd': return 'JIS_C6229-1984-b-add'; - case 'csiso94jis62291984hand': case 'isoir94': case 'jisc62291984hand': case 'jpocrhand': return 'JIS_C6229-1984-hand'; - case 'csiso95jis62291984handadd': case 'isoir95': case 'jisc62291984handadd': case 'jpocrhandadd': return 'JIS_C6229-1984-hand-add'; - case 'csiso96jisc62291984kana': case 'isoir96': case 'jisc62291984kana': return 'JIS_C6229-1984-kana'; - case 'csjisencoding': case 'jisencoding': return 'JIS_Encoding'; - case 'cshalfwidthkatakana': case 'jisx201': case 'x201': return 'JIS_X0201'; - case 'csiso159jisx2121990': case 'isoir159': case 'jisx2121990': case 'x212': return 'JIS_X0212-1990'; - case 'csiso141jusib1002': case 'iso646yu': case 'isoir141': @@ -9993,120 +9961,97 @@ class SimplePie_Misc case 'jusib1002': case 'yu': return 'JUS_I.B1.002'; - case 'csiso147macedonian': case 'isoir147': case 'jusib1003mac': case 'macedonian': return 'JUS_I.B1.003-mac'; - case 'csiso146serbian': case 'isoir146': case 'jusib1003serb': case 'serbian': return 'JUS_I.B1.003-serb'; - case 'koi7switched': return 'KOI7-switched'; - case 'cskoi8r': case 'koi8r': return 'KOI8-R'; - case 'koi8u': return 'KOI8-U'; - case 'csksc5636': case 'iso646kr': case 'ksc5636': return 'KSC5636'; - case 'cskz1048': case 'kz1048': case 'rk1048': case 'strk10482002': return 'KZ-1048'; - case 'csiso19latingreek': case 'isoir19': case 'latingreek': return 'latin-greek'; - case 'csiso27latingreek1': case 'isoir27': case 'latingreek1': return 'Latin-greek-1'; - case 'csiso158lap': case 'isoir158': case 'lap': case 'latinlap': return 'latin-lap'; - case 'csmacintosh': case 'mac': case 'macintosh': return 'macintosh'; - case 'csmicrosoftpublishing': case 'microsoftpublishing': return 'Microsoft-Publishing'; - case 'csmnem': case 'mnem': return 'MNEM'; - case 'csmnemonic': case 'mnemonic': return 'MNEMONIC'; - case 'csiso86hungarian': case 'hu': case 'iso646hu': case 'isoir86': case 'msz77953': return 'MSZ_7795.3'; - case 'csnatsdano': case 'isoir91': case 'natsdano': return 'NATS-DANO'; - case 'csnatsdanoadd': case 'isoir92': case 'natsdanoadd': return 'NATS-DANO-ADD'; - case 'csnatssefi': case 'isoir81': case 'natssefi': return 'NATS-SEFI'; - case 'csnatssefiadd': case 'isoir82': case 'natssefiadd': return 'NATS-SEFI-ADD'; - case 'csiso151cuba': case 'cuba': case 'iso646cu': case 'isoir151': case 'ncnc1081': return 'NC_NC00-10:81'; - case 'csiso69french': case 'fr': case 'iso646fr': case 'isoir69': case 'nfz62010': return 'NF_Z_62-010'; - case 'csiso25french': case 'iso646fr1': case 'isoir25': case 'nfz620101973': return 'NF_Z_62-010_(1973)'; - case 'csiso60danishnorwegian': case 'csiso60norwegian1': case 'iso646no': @@ -10114,53 +10059,42 @@ class SimplePie_Misc case 'no': case 'ns45511': return 'NS_4551-1'; - case 'csiso61norwegian2': case 'iso646no2': case 'isoir61': case 'no2': case 'ns45512': return 'NS_4551-2'; - case 'osdebcdicdf3irv': return 'OSD_EBCDIC_DF03_IRV'; - case 'osdebcdicdf41': return 'OSD_EBCDIC_DF04_1'; - case 'osdebcdicdf415': return 'OSD_EBCDIC_DF04_15'; - case 'cspc8danishnorwegian': case 'pc8danishnorwegian': return 'PC8-Danish-Norwegian'; - case 'cspc8turkish': case 'pc8turkish': return 'PC8-Turkish'; - case 'csiso16portuguese': case 'iso646pt': case 'isoir16': case 'pt': return 'PT'; - case 'csiso84portuguese2': case 'iso646pt2': case 'isoir84': case 'pt2': return 'PT2'; - case 'cp154': case 'csptcp154': case 'cyrillicasian': case 'pt154': case 'ptcp154': return 'PTCP154'; - case 'scsu': return 'SCSU'; - case 'csiso10swedish': case 'fi': case 'iso646fi': @@ -10169,46 +10103,37 @@ class SimplePie_Misc case 'se': case 'sen850200b': return 'SEN_850200_B'; - case 'csiso11swedishfornames': case 'iso646se2': case 'isoir11': case 'se2': case 'sen850200c': return 'SEN_850200_C'; - case 'csiso102t617bit': case 'isoir102': case 't617bit': return 'T.61-7bit'; - case 'csiso103t618bit': case 'isoir103': case 't61': case 't618bit': return 'T.61-8bit'; - case 'csiso128t101g2': case 'isoir128': case 't101g2': return 'T.101-G2'; - case 'cstscii': case 'tscii': return 'TSCII'; - case 'csunicode11': case 'unicode11': return 'UNICODE-1-1'; - case 'csunicode11utf7': case 'unicode11utf7': return 'UNICODE-1-1-UTF-7'; - case 'csunknown8bit': case 'unknown8bit': return 'UNKNOWN-8BIT'; - case 'ansix341968': case 'ansix341986': case 'ascii': @@ -10221,71 +10146,53 @@ class SimplePie_Misc case 'us': case 'usascii': return 'US-ASCII'; - case 'csusdk': case 'usdk': return 'us-dk'; - case 'utf7': return 'UTF-7'; - case 'utf8': return 'UTF-8'; - case 'utf16': return 'UTF-16'; - case 'utf16be': return 'UTF-16BE'; - case 'utf16le': return 'UTF-16LE'; - case 'utf32': return 'UTF-32'; - case 'utf32be': return 'UTF-32BE'; - case 'utf32le': return 'UTF-32LE'; - case 'csventurainternational': case 'venturainternational': return 'Ventura-International'; - case 'csventuramath': case 'venturamath': return 'Ventura-Math'; - case 'csventuraus': case 'venturaus': return 'Ventura-US'; - case 'csiso70videotexsupp1': case 'isoir70': case 'videotexsuppl': return 'videotex-suppl'; - case 'csviqr': case 'viqr': return 'VIQR'; - case 'csviscii': case 'viscii': return 'VISCII'; - case 'csshiftjis': case 'cswindows31j': case 'mskanji': case 'shiftjis': case 'windows31j': return 'Windows-31J'; - case 'iso885911': case 'tis620': return 'windows-874'; - case 'cseuckr': case 'csksc56011987': case 'euckr': @@ -10296,13 +10203,10 @@ class SimplePie_Misc case 'ksc56011989': case 'windows949': return 'windows-949'; - case 'windows1250': return 'windows-1250'; - case 'windows1251': return 'windows-1251'; - case 'cp819': case 'csisolatin1': case 'ibm819': @@ -10313,10 +10217,8 @@ class SimplePie_Misc case 'latin1': case 'windows1252': return 'windows-1252'; - case 'windows1253': return 'windows-1253'; - case 'csisolatin5': case 'iso88599': case 'iso885991989': @@ -10325,24 +10227,18 @@ class SimplePie_Misc case 'latin5': case 'windows1254': return 'windows-1254'; - case 'windows1255': return 'windows-1255'; - case 'windows1256': return 'windows-1256'; - case 'windows1257': return 'windows-1257'; - case 'windows1258': return 'windows-1258'; - default: return $charset; } } - public static function get_curl_version() { if (is_array($curl = curl_version())) @@ -10363,6 +10259,7 @@ class SimplePie_Misc } return $curl; } + public static function strip_comments($data) { $output = ''; @@ -10380,26 +10277,25 @@ class SimplePie_Misc } return $output . $data; } - public static function parse_date($dt) { $parser = SimplePie_Parse_Date::get(); return $parser->parse($dt); } + public static function entities_decode($data) { $decoder = new SimplePie_Decode_HTML_Entities($data); return $decoder->parse(); } + public static function uncomment_rfc822($string) { $string = (string) $string; $position = 0; $length = strlen($string); $depth = 0; - $output = ''; - while ($position < $length && ($pos = strpos($string, '(', $position)) !== false) { $output .= substr($string, $position, $pos - $position); @@ -10422,7 +10318,6 @@ class SimplePie_Misc case '(': $depth++; break; - case ')': $depth--; break; @@ -10441,10 +10336,8 @@ class SimplePie_Misc } } $output .= substr($string, $position); - return $output; } - public static function parse_mime($mime) { if (($pos = strpos($mime, ';')) === false) @@ -10456,7 +10349,6 @@ class SimplePie_Misc return trim(substr($mime, 0, $pos)); } } - public static function atom_03_construct_type($attribs) { if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) === 'base64')) @@ -10474,15 +10366,12 @@ class SimplePie_Misc case 'text': case 'text/plain': return SIMPLEPIE_CONSTRUCT_TEXT | $mode; - case 'html': case 'text/html': return SIMPLEPIE_CONSTRUCT_HTML | $mode; - case 'xhtml': case 'application/xhtml+xml': return SIMPLEPIE_CONSTRUCT_XHTML | $mode; - default: return SIMPLEPIE_CONSTRUCT_NONE | $mode; } @@ -10492,7 +10381,6 @@ class SimplePie_Misc return SIMPLEPIE_CONSTRUCT_TEXT | $mode; } } - public static function atom_10_construct_type($attribs) { if (isset($attribs['']['type'])) @@ -10501,20 +10389,16 @@ class SimplePie_Misc { case 'text': return SIMPLEPIE_CONSTRUCT_TEXT; - case 'html': return SIMPLEPIE_CONSTRUCT_HTML; - case 'xhtml': return SIMPLEPIE_CONSTRUCT_XHTML; - default: return SIMPLEPIE_CONSTRUCT_NONE; } } return SIMPLEPIE_CONSTRUCT_TEXT; } - public static function atom_10_content_construct_type($attribs) { if (isset($attribs['']['type'])) @@ -10524,10 +10408,8 @@ class SimplePie_Misc { case 'text': return SIMPLEPIE_CONSTRUCT_TEXT; - case 'html': return SIMPLEPIE_CONSTRUCT_HTML; - case 'xhtml': return SIMPLEPIE_CONSTRUCT_XHTML; } @@ -10545,20 +10427,16 @@ class SimplePie_Misc return SIMPLEPIE_CONSTRUCT_TEXT; } } - public static function is_isegment_nz_nc($string) { return (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) { $space_characters = "\x20\x09\x0A\x0B\x0C\x0D"; $string_length = strlen($string); - $position = strspn($string, $space_characters); $tokens = array(); - while ($position < $string_length) { $len = strcspn($string, $space_characters, $position); @@ -10566,9 +10444,9 @@ class SimplePie_Misc $position += $len; $position += strspn($string, $space_characters, $position); } - return $tokens; } + public static function codepoint_to_utf8($codepoint) { $codepoint = (int) $codepoint; @@ -10598,11 +10476,11 @@ class SimplePie_Misc return "\xEF\xBF\xBD"; } } + public static function parse_str($str) { $return = array(); $str = explode('&', $str); - foreach ($str as $section) { if (strpos($section, '=') !== false) @@ -10615,9 +10493,9 @@ class SimplePie_Misc $return[urldecode($section)][] = null; } } - return $return; } + public static function xml_encoding($data, $registry) { // UTF-32 Big Endian BOM @@ -10717,7 +10595,6 @@ class SimplePie_Misc } return $encoding; } - public static function output_javascript() { if (function_exists('ob_gzhandler')) @@ -10736,20 +10613,18 @@ function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) document.writeln(''); } } - function embed_flash(bgcolor, width, height, link, loop, type) { document.writeln(''); } - function embed_flv(width, height, link, placeholder, loop, player) { document.writeln(''); } - function embed_wmedia(width, height, link) { document.writeln(''); } 4) return false; - // Remove leading zeros (this is safe because of the above) $ipv6_part = ltrim($ipv6_part, '0'); if ($ipv6_part === '') $ipv6_part = '0'; - // Check the value is valid $value = hexdec($ipv6_part); if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF) @@ -10978,6 +10850,7 @@ class SimplePie_Net_IPv6 return false; } } + public static function checkIPv6($ip) { return self::check_ipv6($ip); @@ -10985,7 +10858,9 @@ class SimplePie_Net_IPv6 } class SimplePie_Parse_Date { + var $date; + var $day = array( // English 'mon' => 1, @@ -11028,20 +10903,20 @@ class SimplePie_Parse_Date 'sonnabend' => 6, 'sonntag' => 7, // Italian - 'lunedA' => 1, - 'martedA' => 2, - 'mercoledA' => 3, - 'giovedA' => 4, - 'venerdA' => 5, + 'lunedi' => 1, + 'martedi' => 2, + 'mercoledi' => 3, + 'giovedi' => 4, + 'venerdi' => 5, 'sabato' => 6, 'domenica' => 7, // Spanish 'lunes' => 1, 'martes' => 2, - 'miArcoles' => 3, + 'miercoles' => 3, 'jueves' => 4, 'viernes' => 5, - 'sA?bado' => 6, + 'sabado' => 6, 'domingo' => 7, // Finnish 'maanantai' => 1, @@ -11052,22 +10927,23 @@ class SimplePie_Parse_Date 'lauantai' => 6, 'sunnuntai' => 7, // Hungarian - 'hAtfA' => 1, + 'hetfo' => 1, 'kedd' => 2, 'szerda' => 3, - 'csA?tArtok' => 4, - 'pAntek' => 5, + 'csutortok' => 4, + 'pentek' => 5, 'szombat' => 6, - 'vasA?rnap' => 7, + 'vasarnap' => 7, // Greek - 'III' => 1, - 'III?' => 2, - 'III' => 3, - 'I II?' => 4, - 'I II' => 5, - 'III' => 6, - 'IsII' => 7, + '' => 1, + '' => 2, + '' => 3, + '' => 4, + '' => 5, + '' => 6, + '' => 7, ); + var $month = array( // English 'jan' => 1, @@ -11109,21 +10985,21 @@ class SimplePie_Parse_Date 'december' => 12, // French 'janvier' => 1, - 'fAvrier' => 2, + 'fevrier' => 2, 'mars' => 3, 'avril' => 4, 'mai' => 5, 'juin' => 6, 'juillet' => 7, - 'aoAt' => 8, + 'aout' => 8, 'septembre' => 9, 'octobre' => 10, 'novembre' => 11, - 'dAcembre' => 12, + 'decembre' => 12, // German 'januar' => 1, 'februar' => 2, - 'mArz' => 3, + 'marz' => 3, 'april' => 4, 'mai' => 5, 'juni' => 6, @@ -11166,46 +11042,47 @@ class SimplePie_Parse_Date 'maaliskuu' => 3, 'huhtikuu' => 4, 'toukokuu' => 5, - 'kesAkuu' => 6, - 'heinAkuu' => 7, + 'kesakuu' => 6, + 'heinakuu' => 7, 'elokuu' => 8, 'suuskuu' => 9, 'lokakuu' => 10, 'marras' => 11, 'joulukuu' => 12, // Hungarian - 'januA?r' => 1, - 'februA?r' => 2, - 'mA?rcius' => 3, - 'A?prilis' => 4, - 'mA?jus' => 5, - 'jA?nius' => 6, - 'jA?lius' => 7, + 'januar' => 1, + 'februar' => 2, + 'marcius' => 3, + 'aprilis' => 4, + 'majus' => 5, + 'junius' => 6, + 'julius' => 7, 'augusztus' => 8, 'szeptember' => 9, - 'oktAber' => 10, + 'oktober' => 10, 'november' => 11, 'december' => 12, // Greek - 'III' => 1, - 'III' => 2, - 'I?IIZ' => 3, - 'I?IIZ' => 3, - 'III' => 4, - 'I?II?' => 5, - 'I?IIS' => 5, - 'I?II?' => 5, - 'II?II' => 6, - 'II?I' => 6, - 'II?II' => 7, - 'II?I' => 7, - 'III' => 8, - 'III' => 8, - 'III' => 9, - 'IYI?I' => 10, - 'II?I' => 11, - 'III?' => 12, + '' => 1, + '' => 2, + '' => 3, + '' => 3, + '' => 4, + '' => 5, + '' => 5, + '' => 5, + '' => 6, + '' => 6, + '' => 7, + '' => 7, + '' => 8, + '' => 8, + '' => 9, + '' => 10, + '' => 11, + '' => 12, ); + var $timezone = array( 'ACDT' => 37800, 'ACIT' => 28800, @@ -11407,20 +11284,23 @@ class SimplePie_Parse_Date 'YEKST' => 21600, 'YEKT' => 18000, ); + var $day_pcre; + var $month_pcre; + var $built_in = array(); + var $user = array(); + public function __construct() { $this->day_pcre = '(' . implode(array_keys($this->day), '|') . ')'; $this->month_pcre = '(' . implode(array_keys($this->month), '|') . ')'; - static $cache; if (!isset($cache[get_class($this)])) { $all_methods = get_class_methods($this); - foreach ($all_methods as $method) { if (strtolower(substr($method, 0, 5)) === 'date_') @@ -11429,12 +11309,12 @@ class SimplePie_Parse_Date } } } - foreach ($cache[get_class($this)] as $method) { $this->built_in[] = $method; } } + public static function get() { static $object; @@ -11444,6 +11324,7 @@ class SimplePie_Parse_Date } return $object; } + public function parse($date) { foreach ($this->user as $method) @@ -11453,7 +11334,6 @@ class SimplePie_Parse_Date return $returned; } } - foreach ($this->built_in as $method) { if (($returned = call_user_func(array($this, $method), $date)) !== false) @@ -11461,9 +11341,9 @@ class SimplePie_Parse_Date return $returned; } } - return false; } + public function add_callback($callback) { if (is_callable($callback)) @@ -11475,6 +11355,7 @@ class SimplePie_Parse_Date trigger_error('User-supplied function must be a valid callback', E_USER_WARNING); } } + public function date_w3cdtf($date) { static $pcre; @@ -11498,22 +11379,19 @@ class SimplePie_Parse_Date 6: Second 7: Decimal fraction of a second 8: Zulu - 9: Timezone A + 9: Timezone 10: Timezone hours 11: Timezone minutes */ - // Fill in empty matches for ($i = count($match); $i <= 3; $i++) { $match[$i] = '1'; } - for ($i = count($match); $i <= 7; $i++) { $match[$i] = '0'; } - // Numeric timezone if (isset($match[9]) && $match[9] !== '') { @@ -11528,10 +11406,8 @@ class SimplePie_Parse_Date { $timezone = 0; } - // Convert the number of seconds to an integer, taking decimals into account $second = round($match[6] + $match[7] / pow(10, strlen($match[7]))); - return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone; } else @@ -11539,15 +11415,14 @@ class SimplePie_Parse_Date return false; } } + public function remove_rfc2822_comments($string) { $string = (string) $string; $position = 0; $length = strlen($string); $depth = 0; - $output = ''; - while ($position < $length && ($pos = strpos($string, '(', $position)) !== false) { $output .= substr($string, $position, $pos - $position); @@ -11570,7 +11445,6 @@ class SimplePie_Parse_Date case '(': $depth++; break; - case ')': $depth--; break; @@ -11589,9 +11463,9 @@ class SimplePie_Parse_Date } } $output .= substr($string, $position); - return $output; } + public function date_rfc2822($date) { static $pcre; @@ -11621,15 +11495,13 @@ class SimplePie_Parse_Date 5: Hour 6: Minute 7: Second - 8: Timezone A + 8: Timezone 9: Timezone hours 10: Timezone minutes 11: Alphabetic timezone */ - // Find the month number $month = $this->month[strtolower($match[3])]; - // Numeric timezone if ($match[8] !== '') { @@ -11650,7 +11522,6 @@ class SimplePie_Parse_Date { $timezone = 0; } - // Deal with 2/3 digit years if ($match[4] < 50) { @@ -11660,7 +11531,6 @@ class SimplePie_Parse_Date { $match[4] += 1900; } - // Second is optional, if it is empty set it to zero if ($match[7] !== '') { @@ -11670,7 +11540,6 @@ class SimplePie_Parse_Date { $second = 0; } - return gmmktime($match[5], $match[6], $second, $month, $match[2], $match[4]) - $timezone; } else @@ -11678,6 +11547,7 @@ class SimplePie_Parse_Date return false; } } + public function date_rfc850($date) { static $pcre; @@ -11704,10 +11574,8 @@ class SimplePie_Parse_Date 7: Second 8: Timezone */ - // Month $month = $this->month[strtolower($match[3])]; - // Character timezone if (isset($this->timezone[strtoupper($match[8])])) { @@ -11718,7 +11586,6 @@ class SimplePie_Parse_Date { $timezone = 0; } - // Deal with 2 digit year if ($match[4] < 50) { @@ -11728,7 +11595,6 @@ class SimplePie_Parse_Date { $match[4] += 1900; } - return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone; } else @@ -11736,6 +11602,7 @@ class SimplePie_Parse_Date return false; } } + public function date_asctime($date) { static $pcre; @@ -11762,7 +11629,6 @@ class SimplePie_Parse_Date 6: Second 7: Year */ - $month = $this->month[strtolower($match[2])]; return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]); } @@ -11771,6 +11637,7 @@ class SimplePie_Parse_Date return false; } } + public function date_strtotime($date) { $strtotime = strtotime($date); @@ -11802,12 +11669,10 @@ class SimplePie_Parser var $current_xhtml_construct = -1; var $encoding; protected $registry; - public function set_registry(SimplePie_Registry $registry) { $this->registry = $registry; } - public function parse(&$data, $encoding) { // Use UTF-8 if we get passed US-ASCII, as every US-ASCII character is a UTF-8 character @@ -11819,7 +11684,6 @@ class SimplePie_Parser { $this->encoding = $encoding; } - // Strip BOM: // UTF-32 Big Endian BOM if (substr($data, 0, 4) === "\x00\x00\xFE\xFF") @@ -11846,7 +11710,6 @@ class SimplePie_Parser { $data = substr($data, 3); } - if (substr($data, 0, 5) === '')) !== false) { $declaration = $this->registry->create('XML_Declaration_Parser', array(substr($data, 5, $pos - 5))); @@ -11861,9 +11724,7 @@ class SimplePie_Parser return false; } } - $return = true; - static $xml_is_sane = null; if ($xml_is_sane === null) { @@ -11872,7 +11733,6 @@ class SimplePie_Parser xml_parser_free($parser_check); $xml_is_sane = isset($values[0]['value']); } - // Create the parser if ($xml_is_sane) { @@ -11882,7 +11742,6 @@ class SimplePie_Parser xml_set_object($xml, $this); xml_set_character_data_handler($xml, 'cdata'); xml_set_element_handler($xml, 'tag_open', 'tag_close'); - // Parse! if (!xml_parse($xml, $data, true)) { @@ -11905,7 +11764,6 @@ class SimplePie_Parser { switch ($xml->nodeType) { - case constant('XMLReader::END_ELEMENT'): if ($xml->namespaceURI !== '') { @@ -11947,7 +11805,6 @@ class SimplePie_Parser } break; case constant('XMLReader::TEXT'): - case constant('XMLReader::CDATA'): $this->cdata(null, $xml->value); break; @@ -11967,59 +11824,53 @@ class SimplePie_Parser } } } - public function get_error_code() { return $this->error_code; } - public function get_error_string() { return $this->error_string; } - public function get_current_line() { return $this->current_line; } - public function get_current_column() { return $this->current_column; } - public function get_current_byte() { return $this->current_byte; } - public function get_data() { return $this->data; } - public function tag_open($parser, $tag, $attributes) { list($this->namespace[], $this->element[]) = $this->split_ns($tag); - $attribs = array(); foreach ($attributes as $name => $value) { list($attrib_namespace, $attribute) = $this->split_ns($name); $attribs[$attrib_namespace][$attribute] = $value; } - if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['base'])) { - $this->xml_base[] = $this->registry->call('Misc', 'absolutize_url', array($attribs[SIMPLEPIE_NAMESPACE_XML]['base'], end($this->xml_base))); - $this->xml_base_explicit[] = true; + $base = $this->registry->call('Misc', 'absolutize_url', array($attribs[SIMPLEPIE_NAMESPACE_XML]['base'], end($this->xml_base))); + if ($base !== false) + { + $this->xml_base[] = $base; + $this->xml_base_explicit[] = true; + } } else { $this->xml_base[] = end($this->xml_base); $this->xml_base_explicit[] = end($this->xml_base_explicit); } - if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['lang'])) { $this->xml_lang[] = $attribs[SIMPLEPIE_NAMESPACE_XML]['lang']; @@ -12028,7 +11879,6 @@ class SimplePie_Parser { $this->xml_lang[] = end($this->xml_lang); } - if ($this->current_xhtml_construct >= 0) { $this->current_xhtml_construct++; @@ -12060,7 +11910,6 @@ class SimplePie_Parser } } } - public function cdata($parser, $cdata) { if ($this->current_xhtml_construct >= 0) @@ -12072,7 +11921,6 @@ class SimplePie_Parser $this->data['data'] .= $cdata; } } - public function tag_close($parser, $tag) { if ($this->current_xhtml_construct >= 0) @@ -12088,14 +11936,12 @@ class SimplePie_Parser $this->data =& $this->datas[count($this->datas) - 1]; array_pop($this->datas); } - array_pop($this->element); array_pop($this->namespace); array_pop($this->xml_base); array_pop($this->xml_base_explicit); array_pop($this->xml_lang); } - public function split_ns($string) { static $cache = array(); @@ -12114,7 +11960,6 @@ class SimplePie_Parser { $namespace = SIMPLEPIE_NAMESPACE_ITUNES; } - // Normalize the Media RSS namespaces if ($namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG || $namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG2 || @@ -12136,18 +11981,23 @@ class SimplePie_Parser } class SimplePie_Rating { + var $scheme; + var $value; + public function __construct($scheme = null, $value = null) { $this->scheme = $scheme; $this->value = $value; } + public function __toString() { // There is no $this->data here return md5(serialize($this)); } + public function get_scheme() { if ($this->scheme !== null) @@ -12159,6 +12009,7 @@ class SimplePie_Rating return null; } } + public function get_value() { if ($this->value !== null) @@ -12173,6 +12024,7 @@ class SimplePie_Rating } class SimplePie_Registry { + protected $default = array( 'Cache' => 'SimplePie_Cache', 'Locator' => 'SimplePie_Locator', @@ -12194,25 +12046,27 @@ class SimplePie_Registry 'XML_Declaration_Parser' => 'SimplePie_XML_Declaration_Parser', 'Parse_Date' => 'SimplePie_Parse_Date', ); + protected $classes = array(); + protected $legacy = array(); + public function __construct() { } + public function register($type, $class, $legacy = false) { if (!is_subclass_of($class, $this->default[$type])) { return false; } - $this->classes[$type] = $class; - if ($legacy) { $this->legacy[] = $class; } - return true; } + public function get_class($type) { if (!empty($this->classes[$type])) @@ -12223,13 +12077,12 @@ class SimplePie_Registry { return $this->default[$type]; } - return null; } + public function &create($type, $parameters = array()) { $class = $this->get_class($type); - if (in_array($class, $this->legacy)) { switch ($type) @@ -12242,7 +12095,6 @@ class SimplePie_Registry break; } } - if (!method_exists($class, '__construct')) { $instance = new $class; @@ -12252,37 +12104,57 @@ class SimplePie_Registry $reflector = new ReflectionClass($class); $instance = $reflector->newInstanceArgs($parameters); } - if (method_exists($instance, 'set_registry')) { $instance->set_registry($this); } return $instance; } + public function &call($type, $method, $parameters = array()) { $class = $this->get_class($type); - + if (in_array($class, $this->legacy)) + { + switch ($type) + { + case 'Cache': + // For backwards compatibility with old non-static + // Cache::create() methods + if ($method === 'get_handler') + { + $result = @call_user_func_array(array($class, 'create'), $parameters); + return $result; + } + break; + } + } $result = call_user_func_array(array($class, $method), $parameters); return $result; } } class SimplePie_Restriction { + var $relationship; + var $type; + var $value; + public function __construct($relationship = null, $type = null, $value = null) { $this->relationship = $relationship; $this->type = $type; $this->value = $value; } + public function __toString() { // There is no $this->data here return md5(serialize($this)); } + public function get_relationship() { if ($this->relationship !== null) @@ -12294,6 +12166,7 @@ class SimplePie_Restriction return null; } } + public function get_type() { if ($this->type !== null) @@ -12305,6 +12178,7 @@ class SimplePie_Restriction return null; } } + public function get_value() { if ($this->value !== null) @@ -12321,7 +12195,6 @@ class SimplePie_Sanitize { // Private vars var $base; - // Options var $remove_div = true; var $image_handler = ''; @@ -12337,18 +12210,15 @@ class SimplePie_Sanitize var $useragent = ''; var $force_fsockopen = false; var $replace_url_attributes = null; - public function __construct() { // Set defaults $this->set_url_replacements(null); } - public function remove_div($enable = true) { $this->remove_div = (bool) $enable; } - public function set_image_handler($page = false) { if ($page) @@ -12360,48 +12230,40 @@ class SimplePie_Sanitize $this->image_handler = false; } } - public function set_registry(SimplePie_Registry $registry) { $this->registry = $registry; } - public function pass_cache_data($enable_cache = true, $cache_location = './cache', $cache_name_function = 'md5', $cache_class = 'SimplePie_Cache') { if (isset($enable_cache)) { $this->enable_cache = (bool) $enable_cache; } - if ($cache_location) { $this->cache_location = (string) $cache_location; } - if ($cache_name_function) { $this->cache_name_function = (string) $cache_name_function; } } - public function pass_file_data($file_class = 'SimplePie_File', $timeout = 10, $useragent = '', $force_fsockopen = false) { if ($timeout) { $this->timeout = (string) $timeout; } - if ($useragent) { $this->useragent = (string) $useragent; } - if ($force_fsockopen) { $this->force_fsockopen = (string) $force_fsockopen; } } - public function strip_htmltags($tags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style')) { if ($tags) @@ -12420,12 +12282,10 @@ class SimplePie_Sanitize $this->strip_htmltags = false; } } - public function encode_instead_of_strip($encode = false) { $this->encode_instead_of_strip = (bool) $encode; } - public function strip_attributes($attribs = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc')) { if ($attribs) @@ -12444,16 +12304,15 @@ class SimplePie_Sanitize $this->strip_attributes = false; } } - public function strip_comments($strip = false) { $this->strip_comments = (bool) $strip; } - public function set_output_encoding($encoding = 'UTF-8') { $this->output_encoding = (string) $encoding; } + public function set_url_replacements($element_attribute = null) { if ($element_attribute === null) @@ -12475,7 +12334,6 @@ class SimplePie_Sanitize } $this->replace_url_attributes = (array) $element_attribute; } - public function sanitize($data, $type, $base = '') { $data = trim($data); @@ -12492,35 +12350,28 @@ class SimplePie_Sanitize $type |= SIMPLEPIE_CONSTRUCT_TEXT; } } - if ($type & SIMPLEPIE_CONSTRUCT_BASE64) { $data = base64_decode($data); } - if ($type & (SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML)) { - $document = new DOMDocument(); $document->encoding = 'UTF-8'; $data = $this->preprocess($data, $type); - set_error_handler(array('SimplePie_Misc', 'silence_errors')); $document->loadHTML($data); restore_error_handler(); - // Strip comments if ($this->strip_comments) { $xpath = new DOMXPath($document); $comments = $xpath->query('//comment()'); - foreach ($comments as $comment) { $comment->parentNode->removeChild($comment); } } - // Strip out HTML tags and attributes that might cause various security problems. // Based on recommendations by Mark Pilgrim at: // http://diveintomark.org/archives/2003/06/12/how_to_consume_rss_safely @@ -12531,7 +12382,6 @@ class SimplePie_Sanitize $this->strip_tag($tag, $document, $type); } } - if ($this->strip_attributes) { foreach ($this->strip_attributes as $attrib) @@ -12539,14 +12389,12 @@ class SimplePie_Sanitize $this->strip_attr($attrib, $document); } } - // Replace relative URLs $this->base = $base; foreach ($this->replace_url_attributes as $element => $attributes) { $this->replace_urls($document, $element, $attributes); } - // If image handling (caching, etc.) is enabled, cache and rewrite all the image tags. if (isset($this->image_handler) && ((string) $this->image_handler) !== '' && $this->enable_cache) { @@ -12556,8 +12404,7 @@ class SimplePie_Sanitize if ($img->hasAttribute('src')) { $image_url = call_user_func($this->cache_name_function, $img->getAttribute('src')); - $cache = $this->registry->call('Cache', 'create', array($this->cache_location, $image_url, 'spi')); - + $cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, $image_url, 'spi')); if ($cache->load()) { $img->setAttribute('src', $this->image_handler . $image_url); @@ -12566,7 +12413,6 @@ class SimplePie_Sanitize { $file = $this->registry->create('File', array($img['attribs']['src']['data'], $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen)); $headers = $file->headers; - if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) { if ($cache->save(array('headers' => $file->headers, 'body' => $file->body))) @@ -12582,21 +12428,17 @@ class SimplePie_Sanitize } } } - // Remove the DOCTYPE // Seems to cause segfaulting if we don't do this if ($document->firstChild instanceof DOMDocumentType) { $document->removeChild($document->firstChild); } - // Move everything from the body to the root $real_body = $document->getElementsByTagName('body')->item(0)->childNodes->item(0); $document->replaceChild($real_body, $document->firstChild); - // Finally, convert to a HTML string $data = trim($document->saveHTML()); - if ($this->remove_div) { $data = preg_replace('/^/', '', $data); @@ -12607,17 +12449,18 @@ class SimplePie_Sanitize $data = preg_replace('/^/', '
', $data); } } - if ($type & SIMPLEPIE_CONSTRUCT_IRI) { - $data = $this->registry->call('Misc', 'absolutize_url', array($data, $base)); + $absolute = $this->registry->call('Misc', 'absolutize_url', array($data, $base)); + if ($absolute !== false) + { + $data = $absolute; + } } - if ($type & (SIMPLEPIE_CONSTRUCT_TEXT | SIMPLEPIE_CONSTRUCT_IRI)) { $data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8'); } - if ($this->output_encoding !== 'UTF-8') { $data = $this->registry->call('Misc', 'change_encoding', array($data, 'UTF-8', $this->output_encoding)); @@ -12625,7 +12468,6 @@ class SimplePie_Sanitize } return $data; } - protected function preprocess($html, $type) { $ret = ''; @@ -12642,20 +12484,17 @@ class SimplePie_Sanitize $ret .= ''; $content_type = 'application/xhtml+xml'; } - $ret .= ''; $ret .= ''; $ret .= '' . $html . ''; return $ret; } - public function replace_urls($document, $tag, $attributes) { if (!is_array($attributes)) { $attributes = array($attributes); } - if (!is_array($this->strip_htmltags) || !in_array($tag, $this->strip_htmltags)) { $elements = $document->getElementsByTagName($tag); @@ -12666,13 +12505,15 @@ class SimplePie_Sanitize if ($element->hasAttribute($attribute)) { $value = $this->registry->call('Misc', 'absolutize_url', array($element->getAttribute($attribute), $this->base)); - $element->setAttribute($attribute, $value); + if ($value !== false) + { + $element->setAttribute($attribute, $value); + } } } } } } - public function do_strip_htmltags($match) { if ($this->encode_instead_of_strip) @@ -12697,7 +12538,6 @@ class SimplePie_Sanitize return ''; } } - protected function strip_tag($tag, $document, $type) { $xpath = new DOMXPath($document); @@ -12707,7 +12547,6 @@ class SimplePie_Sanitize foreach ($elements as $element) { $fragment = $document->createDocumentFragment(); - // For elements which aren't script or style, include the tag itself if (!in_array($tag, array('script', 'style'))) { @@ -12718,7 +12557,6 @@ class SimplePie_Sanitize foreach ($element->attributes as $name => $attr) { $value = $attr->value; - // In XHTML, empty values should never exist, so we repeat the value if (empty($value) && ($type & SIMPLEPIE_CONSTRUCT_XHTML)) { @@ -12730,7 +12568,6 @@ class SimplePie_Sanitize $attrs[] = $name; continue; } - // Standard attribute text $attrs[] = $name . '="' . $attr->value . '"'; } @@ -12739,22 +12576,18 @@ class SimplePie_Sanitize $text .= '>'; $fragment->appendChild(new DOMText($text)); } - $number = $element->childNodes->length; for ($i = $number; $i > 0; $i--) { $child = $element->childNodes->item(0); $fragment->appendChild($child); } - if (!in_array($tag, array('script', 'style'))) { $fragment->appendChild(new DOMText('')); } - $element->parentNode->replaceChild($fragment, $element); } - return; } elseif (in_array($tag, array('script', 'style'))) @@ -12763,7 +12596,6 @@ class SimplePie_Sanitize { $element->parentNode->removeChild($element); } - return; } else @@ -12777,17 +12609,14 @@ class SimplePie_Sanitize $child = $element->childNodes->item(0); $fragment->appendChild($child); } - $element->parentNode->replaceChild($fragment, $element); } } } - protected function strip_attr($attrib, $document) { $xpath = new DOMXPath($document); $elements = $xpath->query('//*[@' . $attrib . ']'); - foreach ($elements as $element) { $element->removeAttribute($attrib); @@ -12799,23 +12628,19 @@ class SimplePie_Source var $item; var $data = array(); protected $registry; - public function __construct($item, $data) { $this->item = $item; $this->data = $data; } - public function set_registry(SimplePie_Registry $registry) { $this->registry = $registry; } - public function __toString() { return md5(serialize($this->data)); } - public function get_source_tags($namespace, $tag) { if (isset($this->data['child'][$namespace][$tag])) @@ -12827,22 +12652,18 @@ class SimplePie_Source return null; } } - public function get_base($element = array()) { return $this->item->get_base($element); } - public function sanitize($data, $type, $base = '') { return $this->item->sanitize($data, $type, $base); } - public function get_item() { return $this->item; } - public function get_title() { if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) @@ -12878,7 +12699,6 @@ class SimplePie_Source return null; } } - public function get_category($key = 0) { $categories = $this->get_categories(); @@ -12891,11 +12711,9 @@ class SimplePie_Source return null; } } - public function get_categories() { $categories = array(); - foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) { $term = null; @@ -12938,7 +12756,6 @@ class SimplePie_Source { $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); } - if (!empty($categories)) { return array_unique($categories); @@ -12948,7 +12765,6 @@ class SimplePie_Source return null; } } - public function get_author($key = 0) { $authors = $this->get_authors(); @@ -12961,7 +12777,6 @@ class SimplePie_Source return null; } } - public function get_authors() { $authors = array(); @@ -13021,7 +12836,6 @@ class SimplePie_Source { $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); } - if (!empty($authors)) { return array_unique($authors); @@ -13031,7 +12845,6 @@ class SimplePie_Source return null; } } - public function get_contributor($key = 0) { $contributors = $this->get_contributors(); @@ -13044,7 +12857,6 @@ class SimplePie_Source return null; } } - public function get_contributors() { $contributors = array(); @@ -13092,7 +12904,6 @@ class SimplePie_Source $contributors[] = $this->registry->create('Author', array($name, $url, $email)); } } - if (!empty($contributors)) { return array_unique($contributors); @@ -13102,7 +12913,6 @@ class SimplePie_Source return null; } } - public function get_link($key = 0, $rel = 'alternate') { $links = $this->get_links($rel); @@ -13115,11 +12925,11 @@ class SimplePie_Source return null; } } + public function get_permalink() { return $this->get_link(0); } - public function get_links($rel = 'alternate') { if (!isset($this->data['links'])) @@ -13144,7 +12954,6 @@ class SimplePie_Source { $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); - } } } @@ -13160,7 +12969,6 @@ class SimplePie_Source { $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); } - $keys = array_keys($this->data['links']); foreach ($keys as $key) { @@ -13183,7 +12991,6 @@ class SimplePie_Source $this->data['links'][$key] = array_unique($this->data['links'][$key]); } } - if (isset($this->data['links'][$rel])) { return $this->data['links'][$rel]; @@ -13193,7 +13000,6 @@ class SimplePie_Source return null; } } - public function get_description() { if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) @@ -13237,7 +13043,6 @@ class SimplePie_Source return null; } } - public function get_copyright() { if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) @@ -13265,7 +13070,6 @@ class SimplePie_Source return null; } } - public function get_language() { if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) @@ -13289,7 +13093,6 @@ class SimplePie_Source return null; } } - public function get_latitude() { if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) @@ -13305,7 +13108,6 @@ class SimplePie_Source return null; } } - public function get_longitude() { if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) @@ -13325,7 +13127,6 @@ class SimplePie_Source return null; } } - public function get_image_url() { if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) @@ -13348,18 +13149,27 @@ class SimplePie_Source } class SimplePie_XML_Declaration_Parser { + var $version = '1.0'; + var $encoding = 'UTF-8'; + var $standalone = false; + var $state = 'before_version_name'; + var $data = ''; + var $data_length = 0; + var $position = 0; + public function __construct($data) { $this->data = $data; $this->data_length = strlen($this->data); } + public function parse() { while ($this->state && $this->state !== 'emit' && $this->has_data()) @@ -13380,16 +13190,19 @@ class SimplePie_XML_Declaration_Parser return false; } } + public function has_data() { return (bool) ($this->position < $this->data_length); } + public function skip_whitespace() { $whitespace = strspn($this->data, "\x09\x0A\x0D\x20", $this->position); $this->position += $whitespace; return $whitespace; } + public function get_value() { $quote = substr($this->data, $this->position, 1); @@ -13406,7 +13219,6 @@ class SimplePie_XML_Declaration_Parser } return false; } - public function before_version_name() { if ($this->skip_whitespace()) @@ -13418,7 +13230,6 @@ class SimplePie_XML_Declaration_Parser $this->state = false; } } - public function version_name() { if (substr($this->data, $this->position, 7) === 'version') @@ -13432,7 +13243,6 @@ class SimplePie_XML_Declaration_Parser $this->state = false; } } - public function version_equals() { if (substr($this->data, $this->position, 1) === '=') @@ -13446,7 +13256,6 @@ class SimplePie_XML_Declaration_Parser $this->state = false; } } - public function version_value() { if ($this->version = $this->get_value()) @@ -13466,7 +13275,6 @@ class SimplePie_XML_Declaration_Parser $this->state = false; } } - public function encoding_name() { if (substr($this->data, $this->position, 8) === 'encoding') @@ -13480,7 +13288,6 @@ class SimplePie_XML_Declaration_Parser $this->state = 'standalone_name'; } } - public function encoding_equals() { if (substr($this->data, $this->position, 1) === '=') @@ -13494,7 +13301,6 @@ class SimplePie_XML_Declaration_Parser $this->state = false; } } - public function encoding_value() { if ($this->encoding = $this->get_value()) @@ -13514,7 +13320,6 @@ class SimplePie_XML_Declaration_Parser $this->state = false; } } - public function standalone_name() { if (substr($this->data, $this->position, 10) === 'standalone') @@ -13528,7 +13333,6 @@ class SimplePie_XML_Declaration_Parser $this->state = false; } } - public function standalone_equals() { if (substr($this->data, $this->position, 1) === '=') @@ -13542,7 +13346,6 @@ class SimplePie_XML_Declaration_Parser $this->state = false; } } - public function standalone_value() { if ($standalone = $this->get_value()) @@ -13552,16 +13355,13 @@ class SimplePie_XML_Declaration_Parser case 'yes': $this->standalone = true; break; - case 'no': $this->standalone = false; break; - default: $this->state = false; return; } - $this->skip_whitespace(); if ($this->has_data()) { @@ -13578,4 +13378,3 @@ class SimplePie_XML_Declaration_Parser } } } -