<?php
+if ( ! class_exists( 'SimplePie' ) ) :
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
- * Copyright (c) 2004-2008, Ryan Parman and Geoffrey Sneddon
+ * Copyright (c) 2004-2011, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
- * @version 1.1.3
- * @copyright 2004-2008 Ryan Parman, Geoffrey Sneddon
+ * @version 1.2.1
+ * @copyright 2004-2011 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
+ * @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @link http://simplepie.org/support/ Please submit all bug reports and feature requests to the SimplePie forums
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
/**
* SimplePie Version
*/
-define('SIMPLEPIE_VERSION', '1.1.3');
+define('SIMPLEPIE_VERSION', '1.2.1');
/**
* SimplePie Build
*/
-define('SIMPLEPIE_BUILD', 20081219);
+define('SIMPLEPIE_BUILD', '20111015034325');
/**
* SimplePie Website URL
*/
define('SIMPLEPIE_CONSTRUCT_ALL', 63);
+/**
+ * Don't change case
+ */
+define('SIMPLEPIE_SAME_CASE', 1);
+
+/**
+ * Change to lowercase
+ */
+define('SIMPLEPIE_LOWERCASE', 2);
+
+/**
+ * Change to uppercase
+ */
+define('SIMPLEPIE_UPPERCASE', 4);
+
/**
* PCRE for HTML attributes
*/
* SimplePie
*
* @package SimplePie
- * @version "Razzleberry"
- * @copyright 2004-2007 Ryan Parman, Geoffrey Sneddon
- * @author Ryan Parman
- * @author Geoffrey Sneddon
- * @todo Option for type of fetching (cache, not modified header, fetch, etc.)
*/
class SimplePie
{
*/
var $max_checked_feeds = 10;
+ /**
+ * @var array All the feeds found during the autodiscovery process
+ * @see SimplePie::get_all_discovered_feeds()
+ * @access private
+ */
+ var $all_discovered_feeds = array();
+
/**
* @var string Web-accessible path to the handler_favicon.php file.
* @see SimplePie::set_favicon_handler()
*/
function __destruct()
{
- if (!empty($this->data['items']))
+ if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))
{
- foreach ($this->data['items'] as $item)
+ if (!empty($this->data['items']))
{
- $item->__destruct();
+ foreach ($this->data['items'] as $item)
+ {
+ $item->__destruct();
+ }
+ unset($item, $this->data['items']);
}
- unset($this->data['items']);
- }
- if (!empty($this->data['ordered_items']))
- {
- foreach ($this->data['ordered_items'] as $item)
+ if (!empty($this->data['ordered_items']))
{
- $item->__destruct();
+ foreach ($this->data['ordered_items'] as $item)
+ {
+ $item->__destruct();
+ }
+ unset($item, $this->data['ordered_items']);
}
- unset($this->data['ordered_items']);
}
}
*/
function set_favicon_handler($page = false, $qs = 'i')
{
- if ($page != false)
+ if ($page !== false)
{
$this->favicon_handler = $page . '?' . $qs . '=';
}
*/
function set_image_handler($page = false, $qs = 'i')
{
- if ($page != false)
+ if ($page !== false)
{
$this->sanitize->set_image_handler($page . '?' . $qs . '=');
}
function init()
{
+ // Check absolute bare minimum requirements.
if ((function_exists('version_compare') && version_compare(PHP_VERSION, '4.3.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre'))
{
return false;
}
- if (isset($_GET[$this->javascript]))
+ // Then check the xml extension is sane (i.e., libxml 2.7.x issue on PHP < 5.2.9 and libxml 2.7.0 to 2.7.2 on any version) if we don't have xmlreader.
+ elseif (!extension_loaded('xmlreader'))
{
- if (function_exists('ob_gzhandler'))
+ static $xml_is_sane = null;
+ if ($xml_is_sane === null)
{
- ob_start('ob_gzhandler');
+ $parser_check = xml_parser_create();
+ xml_parse_into_struct($parser_check, '<foo>&</foo>', $values);
+ xml_parser_free($parser_check);
+ $xml_is_sane = isset($values[0]['value']);
}
- header('Content-type: text/javascript; charset: UTF-8');
- header('Cache-Control: must-revalidate');
- header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
- ?>
-function embed_odeo(link) {
- document.writeln('<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url='+link+'"></embed>');
-}
-
-function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
- if (placeholder != '') {
- document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
- }
- else {
- document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="true" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
- }
-}
-
-function embed_flash(bgcolor, width, height, link, loop, type) {
- document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>');
-}
-
-function embed_flv(width, height, link, placeholder, loop, player) {
- document.writeln('<embed src="'+player+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="'+width+'" height="'+height+'" wmode="transparent" flashvars="file='+link+'&autostart=false&repeat='+loop+'&showdigits=true&showfsbutton=false"></embed>');
-}
+ if (!$xml_is_sane)
+ {
+ return false;
+ }
+ }
-function embed_wmedia(width, height, link) {
- document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
-}
- <?php
+ if (isset($_GET[$this->javascript]))
+ {
+ SimplePie_Misc::output_javascript();
exit;
}
if (!empty($this->data))
{
// If the cache is for an outdated build of SimplePie
- if (!isset($this->data['build']) || $this->data['build'] != SIMPLEPIE_BUILD)
+ if (!isset($this->data['build']) || $this->data['build'] !== SIMPLEPIE_BUILD)
{
$cache->unlink();
$this->data = array();
}
// If we've hit a collision just rerun it with caching disabled
- elseif (isset($this->data['url']) && $this->data['url'] != $this->feed_url)
+ elseif (isset($this->data['url']) && $this->data['url'] !== $this->feed_url)
{
$cache = false;
$this->data = array();
if ($cache->mtime() + $this->autodiscovery_cache_duration > time())
{
// Do not need to do feed autodiscovery yet.
- if ($this->data['feed_url'] == $this->data['url'])
+ if ($this->data['feed_url'] === $this->data['url'])
{
$cache->unlink();
$this->data = array();
$file =& new $this->file_class($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen);
if ($file->success)
{
- if ($file->status_code == 304)
+ if ($file->status_code === 304)
{
$cache->touch();
return true;
// If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it.
if (!isset($file))
{
- if (is_a($this->file, 'SimplePie_File') && $this->file->url == $this->feed_url)
+ if (is_a($this->file, 'SimplePie_File') && $this->file->url === $this->feed_url)
{
$file =& $this->file;
}
}
}
// If the file connection has an error, set SimplePie::error to that and quit
- if (!$file->success)
+ if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)))
{
$this->error = $file->error;
if (!empty($this->data))
{
// 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))
+ if ($file = $locate->find($this->autodiscovery, $this->all_discovered_feeds))
{
if ($cache)
{
$this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
if (!$cache->save($this))
{
- trigger_error("$cache->name is not writeable", E_USER_WARNING);
+ 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 = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc');
}
}
else
{
- $this->error = "A feed could not be found at $this->feed_url";
+ $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.";
SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
return false;
}
$headers = $file->headers;
$data = $file->body;
- $sniffer = new $this->content_type_sniffer_class($file);
+ $sniffer =& new $this->content_type_sniffer_class($file);
$sniffed = $sniffer->get_type();
}
else
// Cache the file if caching is enabled
if ($cache && !$cache->save($this))
{
- trigger_error("$cache->name is not writeable", E_USER_WARNING);
+ trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
}
return true;
}
else
{
- $this->error = "A feed could not be found at $this->feed_url";
+ $this->error = "A feed could not be found at $this->feed_url. This does not appear to be a valid RSS or Atom feed.";
SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
return false;
}
}
}
}
- // We have an error, just set SimplePie::error to it and quit
- $this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
+ if (isset($parser))
+ {
+ // We have an error, just set SimplePie_Misc::error to it and quit
+ $this->error = sprintf('This XML document is invalid, likely due to invalid characters. XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
+ }
+ else
+ {
+ $this->error = 'The data could not be converted to UTF-8. You MUST have either the iconv or mbstring extension installed. Upgrading to PHP 5.x (which includes iconv) is highly recommended.';
+ }
SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
return false;
}
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_090;
}
}
- elseif (isset($this->data['child']['']['rss']))
+ elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss']))
{
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_ALL;
- if (isset($this->data['child']['']['rss'][0]['attribs']['']['version']))
+ if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version']))
{
- switch (trim($this->data['child']['']['rss'][0]['attribs']['']['version']))
+ switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version']))
{
case '0.91':
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_091;
- if (isset($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data']))
+ if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data']))
{
- switch (trim($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data']))
+ switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data']))
{
case '0':
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE;
{
$file =& new $this->file_class($favicon, $this->timeout / 10, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen);
- if ($file->success && ($file->status_code == 200 || ($file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0)
+ if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0)
{
- $sniffer = new $this->content_type_sniffer_class($file);
+ $sniffer =& new $this->content_type_sniffer_class($file);
if (substr($sniffer->get_type(), 0, 6) === 'image/')
{
if ($cache->save(array('headers' => $file->headers, 'body' => $file->body)))
}
else
{
- trigger_error("$cache->name is not writeable", E_USER_WARNING);
+ trigger_error("$cache->name is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
}
}
+ // not an image
+ else
+ {
+ return false;
+ }
}
}
}
{
if ($this->feed_url !== null)
{
- return 'outlook' . $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI);
+ return $this->sanitize('outlook' . SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI);
}
else
{
{
if ($this->subscribe_url())
{
- $return = $this->sanitize($feed_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->feed_url);
+ $return = $feed_url . rawurlencode($this->feed_url);
if ($site_url !== null && $this->get_link() !== null)
{
- $return .= $this->sanitize($site_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_link());
+ $return .= $site_url . rawurlencode($this->get_link());
}
- return $return;
+ return $this->sanitize($return, SIMPLEPIE_CONSTRUCT_IRI);
}
else
{
function subscribe_bloglines()
{
- return urldecode($this->subscribe_service('http://www.bloglines.com/sub/'));
+ return $this->subscribe_service('http://www.bloglines.com/sub/');
}
function subscribe_eskobo()
}
if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
{
- if (isset($this->data['child']['']['rss'][0]['child'][$namespace][$tag]))
+ if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag]))
{
- return $this->data['child']['']['rss'][0]['child'][$namespace][$tag];
+ return $this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag];
}
}
return null;
}
if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
{
- if ($channel = $this->get_feed_tags('', 'channel'))
+ if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'channel'))
{
if (isset($channel[0]['child'][$namespace][$tag]))
{
}
if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
{
- if ($image = $this->get_channel_tags('', 'image'))
+ if ($image = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'image'))
{
if (isset($image[0]['child'][$namespace][$tag]))
{
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
- elseif ($return = $this->get_channel_tags('', 'title'))
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
}
$categories[] =& new $this->category_class($term, $scheme, $label);
}
- foreach ((array) $this->get_channel_tags('', 'category') as $category)
+ foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
{
- $categories[] =& new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
+ // This is really the label, but keep this as the term also for BC.
+ // Label will also work on retrieving because that falls back to term.
+ $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ if (isset($category['attribs']['']['domain']))
+ {
+ $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $scheme = null;
+ }
+ $categories[] =& new $this->category_class($term, $scheme, null);
}
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
{
{
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
}
- if ($links = $this->get_channel_tags('', 'link'))
+ if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
{
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
}
$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
}
}
- elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
+ elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
{
$this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
}
}
}
+ function get_all_discovered_feeds()
+ {
+ return $this->all_discovered_feeds;
+ }
+
function get_description()
{
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
- elseif ($return = $this->get_channel_tags('', 'description'))
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
{
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
}
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
{
{
return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
}
- elseif ($return = $this->get_channel_tags('', 'copyright'))
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
function get_language()
{
- if ($return = $this->get_channel_tags('', 'language'))
+ if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
function get_latitude()
{
+
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
{
return (float) $return[0]['data'];
}
- elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
+ elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
{
return (float) $match[1];
}
{
return (float) $return[0]['data'];
}
- elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
+ elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
{
return (float) $match[2];
}
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- elseif ($return = $this->get_image_tags('', 'title'))
+ elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
}
- elseif ($return = $this->get_image_tags('', 'url'))
+ elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
}
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
}
- elseif ($return = $this->get_image_tags('', 'link'))
+ elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
}
function get_image_width()
{
- if ($return = $this->get_image_tags('', 'width'))
+ if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'width'))
{
return round($return[0]['data']);
}
- elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('', 'url'))
+ elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url'))
{
return 88.0;
}
function get_image_height()
{
- if ($return = $this->get_image_tags('', 'height'))
+ if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'height'))
{
return round($return[0]['data']);
}
- elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('', 'url'))
+ elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url'))
{
return 31.0;
}
function get_item_quantity($max = 0)
{
+ $max = (int) $max;
$qty = count($this->get_items());
- if ($max == 0)
+ if ($max === 0)
{
return $qty;
}
function get_items($start = 0, $end = 0)
{
- if (!empty($this->multifeed_objects))
+ if (!isset($this->data['items']))
{
- return SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit);
- }
- elseif (!isset($this->data['items']))
- {
- if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry'))
+ if (!empty($this->multifeed_objects))
{
- $keys = array_keys($items);
- foreach ($keys as $key)
- {
- $this->data['items'][] =& new $this->item_class($this, $items[$key]);
- }
+ $this->data['items'] = SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit);
}
- if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry'))
+ else
{
- $keys = array_keys($items);
- foreach ($keys as $key)
+ $this->data['items'] = array();
+ if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry'))
{
- $this->data['items'][] =& new $this->item_class($this, $items[$key]);
+ $keys = array_keys($items);
+ foreach ($keys as $key)
+ {
+ $this->data['items'][] =& new $this->item_class($this, $items[$key]);
+ }
}
- }
- if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item'))
- {
- $keys = array_keys($items);
- foreach ($keys as $key)
+ if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry'))
{
- $this->data['items'][] =& new $this->item_class($this, $items[$key]);
+ $keys = array_keys($items);
+ foreach ($keys as $key)
+ {
+ $this->data['items'][] =& new $this->item_class($this, $items[$key]);
+ }
}
- }
- if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item'))
- {
- $keys = array_keys($items);
- foreach ($keys as $key)
+ if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item'))
{
- $this->data['items'][] =& new $this->item_class($this, $items[$key]);
+ $keys = array_keys($items);
+ foreach ($keys as $key)
+ {
+ $this->data['items'][] =& new $this->item_class($this, $items[$key]);
+ }
}
- }
- if ($items = $this->get_channel_tags('', 'item'))
- {
- $keys = array_keys($items);
- foreach ($keys as $key)
+ if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item'))
+ {
+ $keys = array_keys($items);
+ foreach ($keys as $key)
+ {
+ $this->data['items'][] =& new $this->item_class($this, $items[$key]);
+ }
+ }
+ if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item'))
{
- $this->data['items'][] =& new $this->item_class($this, $items[$key]);
+ $keys = array_keys($items);
+ foreach ($keys as $key)
+ {
+ $this->data['items'][] =& new $this->item_class($this, $items[$key]);
+ }
}
}
}
if (!empty($this->data['items']))
{
// If we want to order it by date, check if all items have a date, and then sort it
- if ($this->order_by_date)
+ if ($this->order_by_date && empty($this->multifeed_objects))
{
if (!isset($this->data['ordered_items']))
{
}
// Slice the data as desired
- if ($end == 0)
+ if ($end === 0)
{
return array_slice($items, $start);
}
}
}
+ /**
+ * @static
+ */
function sort_items($a, $b)
{
return $a->get_date('U') <= $b->get_date('U');
}
+ /**
+ * @static
+ */
function merge_items($urls, $start = 0, $end = 0, $limit = 0)
{
if (is_array($urls) && sizeof($urls) > 0)
usort($items, array('SimplePie', 'sort_items'));
}
- if ($end == 0)
+ if ($end === 0)
{
return array_slice($items, $start);
}
*/
function __destruct()
{
- unset($this->feed);
+ if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))
+ {
+ unset($this->feed);
+ }
}
function get_item_tags($namespace, $tag)
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- elseif ($return = $this->get_item_tags('', 'guid'))
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
{
$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
- elseif ($return = $this->get_item_tags('', 'title'))
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
{
$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
- elseif ($return = $this->get_item_tags('', 'description'))
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
}
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
+ {
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML);
+ }
+
elseif (!$description_only)
{
return $this->get_content(true);
}
$categories[] =& new $this->feed->category_class($term, $scheme, $label);
}
- foreach ((array) $this->get_item_tags('', 'category') as $category)
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
{
- $categories[] =& new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
+ // This is really the label, but keep this as the term also for BC.
+ // Label will also work on retrieving because that falls back to term.
+ $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ if (isset($category['attribs']['']['domain']))
+ {
+ $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $scheme = null;
+ }
+ $categories[] =& new $this->feed->category_class($term, $scheme, null);
}
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
{
}
}
- /**
- * @todo Atom inheritance (item author, source author, feed author)
- */
function get_authors()
{
$authors = array();
$authors[] =& new $this->feed->author_class($name, $url, $email);
}
}
- if ($author = $this->get_item_tags('', 'author'))
+ if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author'))
{
$authors[] =& new $this->feed->author_class(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
}
{
$this->data['date']['raw'] = $return[0]['data'];
}
- elseif ($return = $this->get_item_tags('', 'pubDate'))
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate'))
{
$this->data['date']['raw'] = $return[0]['data'];
}
{
return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT);
}
- elseif (($date = $this->get_date('U')) !== null)
+ elseif (($date = $this->get_date('U')) !== null && $date !== false)
{
return strftime($date_format, $date);
}
{
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
}
- if ($links = $this->get_item_tags('', 'link'))
+ if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
{
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
}
- if ($links = $this->get_item_tags('', 'guid'))
+ if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
{
- if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) == 'true')
+ if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true')
{
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
}
$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
}
}
- elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
+ elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
{
$this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
}
$temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
if (sizeof($temp) > 0)
{
- (int) $seconds = array_pop($temp);
+ $seconds = (int) array_pop($temp);
}
if (sizeof($temp) > 0)
{
- (int) $minutes = array_pop($temp);
+ $minutes = (int) array_pop($temp);
$seconds += $minutes * 60;
}
if (sizeof($temp) > 0)
{
- (int) $hours = array_pop($temp);
+ $hours = (int) array_pop($temp);
$seconds += $hours * 3600;
}
unset($temp);
$restriction_relationship = 'allow';
$restriction_type = null;
$restriction_value = 'itunes';
- if (isset($restriction['data']) && strtolower($restriction['data']) == 'yes')
+ if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes')
{
$restriction_relationship = 'deny';
}
$restriction_relationship = 'allow';
$restriction_type = null;
$restriction_value = 'itunes';
- if (isset($restriction['data']) && strtolower($restriction['data']) == 'yes')
+ if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes')
{
$restriction_relationship = 'deny';
}
// If we have media:group tags, loop through them.
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group)
{
- // If we have media:content tags, loop through them.
- foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
+ if(isset($group['child']) && isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
{
- if (isset($content['attribs']['']['url']))
+ // If we have media:content tags, loop through them.
+ foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
{
- // Attributes
- $bitrate = null;
- $channels = null;
- $duration = null;
- $expression = null;
- $framerate = null;
- $height = null;
- $javascript = null;
- $lang = null;
- $length = null;
- $medium = null;
- $samplingrate = null;
- $type = null;
- $url = null;
- $width = null;
-
- // Elements
- $captions = null;
- $categories = null;
- $copyrights = null;
- $credits = null;
- $description = null;
- $hashes = null;
- $keywords = null;
- $player = null;
- $ratings = null;
- $restrictions = null;
- $thumbnails = null;
- $title = null;
-
- // Start checking the attributes of media:content
- if (isset($content['attribs']['']['bitrate']))
- {
- $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($content['attribs']['']['channels']))
- {
- $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($content['attribs']['']['duration']))
- {
- $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- else
- {
- $duration = $duration_parent;
- }
- if (isset($content['attribs']['']['expression']))
- {
- $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($content['attribs']['']['framerate']))
- {
- $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($content['attribs']['']['height']))
- {
- $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($content['attribs']['']['lang']))
- {
- $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($content['attribs']['']['fileSize']))
- {
- $length = ceil($content['attribs']['']['fileSize']);
- }
- if (isset($content['attribs']['']['medium']))
- {
- $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($content['attribs']['']['samplingrate']))
- {
- $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($content['attribs']['']['type']))
- {
- $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($content['attribs']['']['width']))
+ if (isset($content['attribs']['']['url']))
{
- $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+ // Attributes
+ $bitrate = null;
+ $channels = null;
+ $duration = null;
+ $expression = null;
+ $framerate = null;
+ $height = null;
+ $javascript = null;
+ $lang = null;
+ $length = null;
+ $medium = null;
+ $samplingrate = null;
+ $type = null;
+ $url = null;
+ $width = null;
+
+ // Elements
+ $captions = null;
+ $categories = null;
+ $copyrights = null;
+ $credits = null;
+ $description = null;
+ $hashes = null;
+ $keywords = null;
+ $player = null;
+ $ratings = null;
+ $restrictions = null;
+ $thumbnails = null;
+ $title = null;
+
+ // Start checking the attributes of media:content
+ if (isset($content['attribs']['']['bitrate']))
+ {
+ $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($content['attribs']['']['channels']))
+ {
+ $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($content['attribs']['']['duration']))
+ {
+ $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $duration = $duration_parent;
+ }
+ if (isset($content['attribs']['']['expression']))
+ {
+ $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($content['attribs']['']['framerate']))
+ {
+ $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($content['attribs']['']['height']))
+ {
+ $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($content['attribs']['']['lang']))
+ {
+ $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($content['attribs']['']['fileSize']))
+ {
+ $length = ceil($content['attribs']['']['fileSize']);
+ }
+ if (isset($content['attribs']['']['medium']))
+ {
+ $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($content['attribs']['']['samplingrate']))
+ {
+ $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($content['attribs']['']['type']))
+ {
+ $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($content['attribs']['']['width']))
+ {
+ $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
+ // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
- // CAPTIONS
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
- {
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
+ // CAPTIONS
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
{
- $caption_type = null;
- $caption_lang = null;
- $caption_startTime = null;
- $caption_endTime = null;
- $caption_text = null;
- if (isset($caption['attribs']['']['type']))
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
{
- $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $caption_type = null;
+ $caption_lang = null;
+ $caption_startTime = null;
+ $caption_endTime = null;
+ $caption_text = null;
+ if (isset($caption['attribs']['']['type']))
+ {
+ $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($caption['attribs']['']['lang']))
+ {
+ $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($caption['attribs']['']['start']))
+ {
+ $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($caption['attribs']['']['end']))
+ {
+ $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($caption['data']))
+ {
+ $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
}
- if (isset($caption['attribs']['']['lang']))
+ if (is_array($captions))
{
- $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $captions = array_values(SimplePie_Misc::array_unique($captions));
}
- if (isset($caption['attribs']['']['start']))
+ }
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
+ {
+ foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
{
- $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($caption['attribs']['']['end']))
- {
- $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $caption_type = null;
+ $caption_lang = null;
+ $caption_startTime = null;
+ $caption_endTime = null;
+ $caption_text = null;
+ if (isset($caption['attribs']['']['type']))
+ {
+ $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($caption['attribs']['']['lang']))
+ {
+ $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($caption['attribs']['']['start']))
+ {
+ $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($caption['attribs']['']['end']))
+ {
+ $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($caption['data']))
+ {
+ $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
}
- if (isset($caption['data']))
+ if (is_array($captions))
{
- $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $captions = array_values(SimplePie_Misc::array_unique($captions));
}
- $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
}
- if (is_array($captions))
+ else
{
- $captions = array_values(SimplePie_Misc::array_unique($captions));
+ $captions = $captions_parent;
}
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
- {
- foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
+
+ // CATEGORIES
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
{
- $caption_type = null;
- $caption_lang = null;
- $caption_startTime = null;
- $caption_endTime = null;
- $caption_text = null;
- if (isset($caption['attribs']['']['type']))
- {
- $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($caption['attribs']['']['lang']))
- {
- $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($caption['attribs']['']['start']))
- {
- $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($caption['attribs']['']['end']))
+ foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
{
- $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $term = null;
+ $scheme = null;
+ $label = null;
+ if (isset($category['data']))
+ {
+ $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($category['attribs']['']['scheme']))
+ {
+ $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $scheme = 'http://search.yahoo.com/mrss/category_schema';
+ }
+ if (isset($category['attribs']['']['label']))
+ {
+ $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $categories[] =& new $this->feed->category_class($term, $scheme, $label);
}
- if (isset($caption['data']))
+ }
+ if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
+ {
+ foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
{
- $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $term = null;
+ $scheme = null;
+ $label = null;
+ if (isset($category['data']))
+ {
+ $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($category['attribs']['']['scheme']))
+ {
+ $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $scheme = 'http://search.yahoo.com/mrss/category_schema';
+ }
+ if (isset($category['attribs']['']['label']))
+ {
+ $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $categories[] =& new $this->feed->category_class($term, $scheme, $label);
}
- $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
}
- if (is_array($captions))
+ if (is_array($categories) && is_array($categories_parent))
{
- $captions = array_values(SimplePie_Misc::array_unique($captions));
+ $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent)));
+ }
+ elseif (is_array($categories))
+ {
+ $categories = array_values(SimplePie_Misc::array_unique($categories));
+ }
+ elseif (is_array($categories_parent))
+ {
+ $categories = array_values(SimplePie_Misc::array_unique($categories_parent));
}
- }
- else
- {
- $captions = $captions_parent;
- }
- // CATEGORIES
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
- {
- foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
+ // COPYRIGHTS
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
{
- $term = null;
- $scheme = null;
- $label = null;
- if (isset($category['data']))
+ $copyright_url = null;
+ $copyright_label = null;
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
{
- $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- if (isset($category['attribs']['']['scheme']))
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
{
- $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- else
+ $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
+ }
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
+ {
+ $copyright_url = null;
+ $copyright_label = null;
+ if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
{
- $scheme = 'http://search.yahoo.com/mrss/category_schema';
+ $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- if (isset($category['attribs']['']['label']))
+ if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
{
- $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- $categories[] =& new $this->feed->category_class($term, $scheme, $label);
+ $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
}
- }
- if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
- {
- foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
+ else
{
- $term = null;
- $scheme = null;
- $label = null;
- if (isset($category['data']))
+ $copyrights = $copyrights_parent;
+ }
+
+ // CREDITS
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
+ {
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
{
- $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $credit_role = null;
+ $credit_scheme = null;
+ $credit_name = null;
+ if (isset($credit['attribs']['']['role']))
+ {
+ $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($credit['attribs']['']['scheme']))
+ {
+ $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $credit_scheme = 'urn:ebu';
+ }
+ if (isset($credit['data']))
+ {
+ $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
}
- if (isset($category['attribs']['']['scheme']))
+ if (is_array($credits))
{
- $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $credits = array_values(SimplePie_Misc::array_unique($credits));
}
- else
+ }
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
+ {
+ foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
{
- $scheme = 'http://search.yahoo.com/mrss/category_schema';
+ $credit_role = null;
+ $credit_scheme = null;
+ $credit_name = null;
+ if (isset($credit['attribs']['']['role']))
+ {
+ $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($credit['attribs']['']['scheme']))
+ {
+ $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $credit_scheme = 'urn:ebu';
+ }
+ if (isset($credit['data']))
+ {
+ $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
}
- if (isset($category['attribs']['']['label']))
+ if (is_array($credits))
{
- $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $credits = array_values(SimplePie_Misc::array_unique($credits));
}
- $categories[] =& new $this->feed->category_class($term, $scheme, $label);
}
- }
- if (is_array($categories) && is_array($categories_parent))
- {
- $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent)));
- }
- elseif (is_array($categories))
- {
- $categories = array_values(SimplePie_Misc::array_unique($categories));
- }
- elseif (is_array($categories_parent))
- {
- $categories = array_values(SimplePie_Misc::array_unique($categories_parent));
- }
-
- // COPYRIGHTS
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
- {
- $copyright_url = null;
- $copyright_label = null;
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
+ else
{
- $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $credits = $credits_parent;
}
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
+
+ // DESCRIPTION
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
{
- $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
- {
- $copyright_url = null;
- $copyright_label = null;
- if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
{
- $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
+ else
{
- $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $description = $description_parent;
}
- $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
- }
- else
- {
- $copyrights = $copyrights_parent;
- }
- // CREDITS
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
- {
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
+ // HASHES
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
{
- $credit_role = null;
- $credit_scheme = null;
- $credit_name = null;
- if (isset($credit['attribs']['']['role']))
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
{
- $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $value = null;
+ $algo = null;
+ if (isset($hash['data']))
+ {
+ $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($hash['attribs']['']['algo']))
+ {
+ $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $algo = 'md5';
+ }
+ $hashes[] = $algo.':'.$value;
}
- if (isset($credit['attribs']['']['scheme']))
+ if (is_array($hashes))
{
- $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $hashes = array_values(SimplePie_Misc::array_unique($hashes));
}
- else
+ }
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
+ {
+ foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
{
- $credit_scheme = 'urn:ebu';
+ $value = null;
+ $algo = null;
+ if (isset($hash['data']))
+ {
+ $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($hash['attribs']['']['algo']))
+ {
+ $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $algo = 'md5';
+ }
+ $hashes[] = $algo.':'.$value;
}
- if (isset($credit['data']))
+ if (is_array($hashes))
{
- $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $hashes = array_values(SimplePie_Misc::array_unique($hashes));
}
- $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
}
- if (is_array($credits))
+ else
{
- $credits = array_values(SimplePie_Misc::array_unique($credits));
+ $hashes = $hashes_parent;
}
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
- {
- foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
+
+ // KEYWORDS
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
{
- $credit_role = null;
- $credit_scheme = null;
- $credit_name = null;
- if (isset($credit['attribs']['']['role']))
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
{
- $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
+ foreach ($temp as $word)
+ {
+ $keywords[] = trim($word);
+ }
+ unset($temp);
}
- if (isset($credit['attribs']['']['scheme']))
+ if (is_array($keywords))
{
- $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $keywords = array_values(SimplePie_Misc::array_unique($keywords));
}
- else
+ }
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
+ {
+ if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
{
- $credit_scheme = 'urn:ebu';
+ $temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
+ foreach ($temp as $word)
+ {
+ $keywords[] = trim($word);
+ }
+ unset($temp);
}
- if (isset($credit['data']))
+ if (is_array($keywords))
{
- $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $keywords = array_values(SimplePie_Misc::array_unique($keywords));
}
- $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
}
- if (is_array($credits))
+ else
{
- $credits = array_values(SimplePie_Misc::array_unique($credits));
+ $keywords = $keywords_parent;
}
- }
- else
- {
- $credits = $credits_parent;
- }
- // DESCRIPTION
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
- {
- $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
- {
- $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- else
- {
- $description = $description_parent;
- }
+ // PLAYER
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
+ {
+ $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+ }
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
+ {
+ $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+ }
+ else
+ {
+ $player = $player_parent;
+ }
- // HASHES
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
- {
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
+ // RATINGS
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
{
- $value = null;
- $algo = null;
- if (isset($hash['data']))
- {
- $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($hash['attribs']['']['algo']))
- {
- $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- else
- {
- $algo = 'md5';
- }
- $hashes[] = $algo.':'.$value;
- }
- if (is_array($hashes))
- {
- $hashes = array_values(SimplePie_Misc::array_unique($hashes));
- }
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
- {
- foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
- {
- $value = null;
- $algo = null;
- if (isset($hash['data']))
- {
- $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($hash['attribs']['']['algo']))
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
{
- $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $rating_scheme = null;
+ $rating_value = null;
+ if (isset($rating['attribs']['']['scheme']))
+ {
+ $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $rating_scheme = 'urn:simple';
+ }
+ if (isset($rating['data']))
+ {
+ $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
}
- else
+ if (is_array($ratings))
{
- $algo = 'md5';
+ $ratings = array_values(SimplePie_Misc::array_unique($ratings));
}
- $hashes[] = $algo.':'.$value;
- }
- if (is_array($hashes))
- {
- $hashes = array_values(SimplePie_Misc::array_unique($hashes));
}
- }
- else
- {
- $hashes = $hashes_parent;
- }
-
- // KEYWORDS
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
- {
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
{
- $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
- foreach ($temp as $word)
+ foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
{
- $keywords[] = trim($word);
+ $rating_scheme = null;
+ $rating_value = null;
+ if (isset($rating['attribs']['']['scheme']))
+ {
+ $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $rating_scheme = 'urn:simple';
+ }
+ if (isset($rating['data']))
+ {
+ $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
}
- unset($temp);
- }
- if (is_array($keywords))
- {
- $keywords = array_values(SimplePie_Misc::array_unique($keywords));
- }
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
- {
- if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
- {
- $temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
- foreach ($temp as $word)
+ if (is_array($ratings))
{
- $keywords[] = trim($word);
+ $ratings = array_values(SimplePie_Misc::array_unique($ratings));
}
- unset($temp);
}
- if (is_array($keywords))
+ else
{
- $keywords = array_values(SimplePie_Misc::array_unique($keywords));
+ $ratings = $ratings_parent;
}
- }
- else
- {
- $keywords = $keywords_parent;
- }
-
- // PLAYER
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
- {
- $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
- {
- $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
- }
- else
- {
- $player = $player_parent;
- }
- // RATINGS
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
- {
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
+ // RESTRICTIONS
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
{
- $rating_scheme = null;
- $rating_value = null;
- if (isset($rating['attribs']['']['scheme']))
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
{
- $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- else
- {
- $rating_scheme = 'urn:simple';
+ $restriction_relationship = null;
+ $restriction_type = null;
+ $restriction_value = null;
+ if (isset($restriction['attribs']['']['relationship']))
+ {
+ $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($restriction['attribs']['']['type']))
+ {
+ $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($restriction['data']))
+ {
+ $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
}
- if (isset($rating['data']))
+ if (is_array($restrictions))
{
- $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
}
- $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
- }
- if (is_array($ratings))
- {
- $ratings = array_values(SimplePie_Misc::array_unique($ratings));
}
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
- {
- foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
{
- $rating_scheme = null;
- $rating_value = null;
- if (isset($rating['attribs']['']['scheme']))
- {
- $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- else
+ foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
{
- $rating_scheme = 'urn:simple';
+ $restriction_relationship = null;
+ $restriction_type = null;
+ $restriction_value = null;
+ if (isset($restriction['attribs']['']['relationship']))
+ {
+ $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($restriction['attribs']['']['type']))
+ {
+ $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($restriction['data']))
+ {
+ $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
}
- if (isset($rating['data']))
+ if (is_array($restrictions))
{
- $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
}
- $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
}
- if (is_array($ratings))
+ else
{
- $ratings = array_values(SimplePie_Misc::array_unique($ratings));
+ $restrictions = $restrictions_parent;
}
- }
- else
- {
- $ratings = $ratings_parent;
- }
- // RESTRICTIONS
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
- {
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
+ // THUMBNAILS
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
{
- $restriction_relationship = null;
- $restriction_type = null;
- $restriction_value = null;
- if (isset($restriction['attribs']['']['relationship']))
- {
- $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($restriction['attribs']['']['type']))
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
{
- $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
}
- if (isset($restriction['data']))
+ if (is_array($thumbnails))
{
- $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
}
- $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
- }
- if (is_array($restrictions))
- {
- $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
}
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
- {
- foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
{
- $restriction_relationship = null;
- $restriction_type = null;
- $restriction_value = null;
- if (isset($restriction['attribs']['']['relationship']))
- {
- $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($restriction['attribs']['']['type']))
+ foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
{
- $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
}
- if (isset($restriction['data']))
+ if (is_array($thumbnails))
{
- $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
}
- $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
}
- if (is_array($restrictions))
+ else
{
- $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
+ $thumbnails = $thumbnails_parent;
}
- }
- else
- {
- $restrictions = $restrictions_parent;
- }
- // THUMBNAILS
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
- {
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
- {
- $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
- }
- if (is_array($thumbnails))
+ // TITLES
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
{
- $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
+ $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
- {
- foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
{
- $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+ $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- if (is_array($thumbnails))
+ else
{
- $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
+ $title = $title_parent;
}
- }
- else
- {
- $thumbnails = $thumbnails_parent;
- }
- // TITLES
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
- {
- $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
- {
- $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- else
- {
- $title = $title_parent;
+ $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width);
}
-
- $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $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->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
{
- if (isset($content['attribs']['']['url']))
+ if (isset($content['attribs']['']['url']) || isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
{
// Attributes
$bitrate = null;
{
$width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
-
+ if (isset($content['attribs']['']['url']))
+ {
+ $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+ }
// Checking the other optional media: elements. Priority: media:content, media:group, item, channel
// CAPTIONS
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')
+ if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure')
{
// Attributes
$bitrate = null;
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')
+ if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure')
{
// Attributes
$bitrate = null;
}
}
- if ($enclosure = $this->get_item_tags('', 'enclosure'))
+ if ($enclosure = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure'))
{
if (isset($enclosure[0]['attribs']['']['url']))
{
}
}
- 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))
+ 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'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $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);
{
return (float) $return[0]['data'];
}
- elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
+ elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
{
return (float) $match[1];
}
{
return (float) $return[0]['data'];
}
- elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
+ elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
{
return (float) $match[2];
}
{
if ($this->get_permalink() !== null)
{
- $return = $this->sanitize($item_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_permalink());
+ $return = $item_url . rawurlencode($this->get_permalink());
if ($title_url !== null && $this->get_title() !== null)
{
- $return .= $this->sanitize($title_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_title());
+ $return .= $title_url . rawurlencode($this->get_title());
}
if ($summary_url !== null && $this->get_description() !== null)
{
- $return .= $this->sanitize($summary_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_description());
+ $return .= $summary_url . rawurlencode($this->get_description());
}
- return $return;
+ return $this->sanitize($return, SIMPLEPIE_CONSTRUCT_IRI);
}
else
{
return md5(serialize($this->data));
}
- /**
- * Remove items that link back to this before destroying this object
- */
- function __destruct()
- {
- unset($this->item);
- }
-
function get_source_tags($namespace, $tag)
{
if (isset($this->data['child'][$namespace][$tag]))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
- elseif ($return = $this->get_source_tags('', 'title'))
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
}
$categories[] =& new $this->item->feed->category_class($term, $scheme, $label);
}
- foreach ((array) $this->get_source_tags('', 'category') as $category)
+ foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
{
- $categories[] =& new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
+ // This is really the label, but keep this as the term also for BC.
+ // Label will also work on retrieving because that falls back to term.
+ $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ if (isset($category['attribs']['']['domain']))
+ {
+ $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $scheme = null;
+ }
+ $categories[] =& new $this->item->feed->category_class($term, $scheme, null);
}
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
{
{
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
}
- if ($links = $this->get_source_tags('', 'link'))
+ if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
{
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
}
$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
}
}
- elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
+ elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
{
$this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
}
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
- elseif ($return = $this->get_source_tags('', 'description'))
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
{
return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
}
- elseif ($return = $this->get_source_tags('', 'copyright'))
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
function get_language()
{
- if ($return = $this->get_source_tags('', 'language'))
+ if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
{
return (float) $return[0]['data'];
}
- elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
+ elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
{
return (float) $match[1];
}
{
return (float) $return[0]['data'];
}
- elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
+ elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
{
return (float) $match[2];
}
$mime = $mime[0];
// Process values for 'auto'
- if ($width == 'auto')
+ if ($width === 'auto')
{
- if ($mime == 'video')
+ if ($mime === 'video')
{
- if ($height == 'auto')
+ if ($height === 'auto')
{
$width = 480;
}
}
}
- if ($height == 'auto')
+ if ($height === 'auto')
{
- if ($mime == 'audio')
+ if ($mime === 'audio')
{
$height = 0;
}
- elseif ($mime == 'video')
+ elseif ($mime === 'video')
{
- if ($width == 'auto')
+ if ($width === 'auto')
{
if ($widescreen)
{
$height = 376;
}
}
- elseif ($mime == 'audio')
+ elseif ($mime === 'audio')
{
$height = 0;
}
// Set proper placeholder value
- if ($mime == 'audio')
+ if ($mime === 'audio')
{
$placeholder = $audio;
}
- elseif ($mime == 'video')
+ elseif ($mime === 'video')
{
$placeholder = $video;
}
}
// Odeo Feed MP3's
- if ($handler == 'odeo')
+ if ($handler === 'odeo')
{
if ($native)
{
}
// Flash
- elseif ($handler == 'flash')
+ elseif ($handler === 'flash')
{
if ($native)
{
// Flash Media Player file types.
// Preferred handler for MP3 file types.
- elseif ($handler == 'fmedia' || ($handler == 'mp3' && $mediaplayer != ''))
+ elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== ''))
{
$height += 20;
if ($native)
// 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 == ''))
+ elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === ''))
{
$height += 16;
if ($native)
{
- if ($placeholder != ""){
+ if ($placeholder !== '')
+ {
$embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" href=\"" . $this->get_link() . "\" src=\"$placeholder\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"false\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>";
}
- else {
+ else
+ {
$embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" src=\"" . $this->get_link() . "\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"true\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>";
}
}
}
// Windows Media
- elseif ($handler == 'wmedia')
+ elseif ($handler === 'wmedia')
{
$height += 45;
if ($native)
function get_real_type($find_handler = false)
{
// If it's Odeo, let's get it out of the way.
- if (substr(strtolower($this->get_link()), 0, 15) == 'http://odeo.com')
+ if (substr(strtolower($this->get_link()), 0, 15) === 'http://odeo.com')
{
return 'odeo';
}
}
$this->headers = curl_exec($fp);
- if (curl_errno($fp) == 23 || curl_errno($fp) == 61)
+ if (curl_errno($fp) === 23 || curl_errno($fp) === 61)
{
curl_setopt($fp, CURLOPT_ENCODING, 'none');
$this->headers = curl_exec($fp);
$this->headers = $parser->headers;
$this->body = $parser->body;
$this->status_code = $parser->status_code;
- if (($this->status_code == 300 || $this->status_code == 301 || $this->status_code == 302 || $this->status_code == 303 || $this->status_code == 307 || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
+ if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
{
$this->redirects++;
$location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
{
$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
$url_parts = parse_url($url);
- if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) == 'https')
+ $socket_host = $url_parts['host'];
+ if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https')
{
- $url_parts['host'] = "ssl://$url_parts[host]";
+ $socket_host = "ssl://$url_parts[host]";
$url_parts['port'] = 443;
}
if (!isset($url_parts['port']))
{
$url_parts['port'] = 80;
}
- $fp = @fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout);
+ $fp = @fsockopen($socket_host, $url_parts['port'], $errno, $errstr, $timeout);
if (!$fp)
{
$this->error = 'fsockopen error: ' . $errstr;
$this->headers = $parser->headers;
$this->body = $parser->body;
$this->status_code = $parser->status_code;
- if (($this->status_code == 300 || $this->status_code == 301 || $this->status_code == 302 || $this->status_code == 303 || $this->status_code == 307 || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
+ if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
{
$this->redirects++;
$location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
{
case 'gzip':
case 'x-gzip':
- $decoder = new SimplePie_gzdecode($this->body);
+ $decoder =& new SimplePie_gzdecode($this->body);
if (!$decoder->parse())
{
$this->error = 'Unable to decode HTTP "gzip" stream';
// Get the length of the extra field
$len = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
- $position += 2;
+ $this->position += 2;
// Check the length of the string is still valid
$this->min_compressed_size += $len + 4;
if ($this->flags & 8)
{
// Get the length of the filename
- $len = strspn($this->compressed_data, "\x00", $this->position);
+ $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->flags & 16)
{
// Get the length of the comment
- $len = strspn($this->compressed_data, "\x00", $this->position);
+ $len = strcspn($this->compressed_data, "\x00", $this->position);
// Check the length of the string is still valid
$this->min_compressed_size += $len + 1;
*/
function create($location, $filename, $extension)
{
- return new SimplePie_Cache_File($location, $filename, $extension);
+ $location_iri =& new SimplePie_IRI($location);
+ switch ($location_iri->get_scheme())
+ {
+ case 'mysql':
+ if (extension_loaded('mysql'))
+ {
+ return new SimplePie_Cache_MySQL($location_iri, $filename, $extension);
+ }
+ break;
+
+ default:
+ return new SimplePie_Cache_File($location, $filename, $extension);
+ }
}
}
function SimplePie_Cache_File($location, $filename, $extension)
{
$this->location = $location;
- $this->filename = rawurlencode($filename);
- $this->extension = rawurlencode($extension);
- $this->name = "$location/$this->filename.$this->extension";
+ $this->filename = $filename;
+ $this->extension = $extension;
+ $this->name = "$this->location/$this->filename.$this->extension";
}
function save($data)
}
}
-class SimplePie_Misc
+class SimplePie_Cache_DB
{
- function time_hms($seconds)
+ function prepare_simplepie_object_for_cache($data)
{
- $time = '';
+ $items = $data->get_items();
+ $items_by_id = array();
- $hours = floor($seconds / 3600);
- $remainder = $seconds % 3600;
- if ($hours > 0)
+ if (!empty($items))
{
- $time .= $hours.':';
+ foreach ($items as $item)
+ {
+ $items_by_id[$item->get_id()] = $item;
+ }
+
+ if (count($items_by_id) !== count($items))
+ {
+ $items_by_id = array();
+ foreach ($items as $item)
+ {
+ $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];
+ }
+ elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]))
+ {
+ $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0];
+ }
+ elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]))
+ {
+ $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0];
+ }
+ elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0]))
+ {
+ $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0];
+ }
+ else
+ {
+ $channel = null;
+ }
+
+ if ($channel !== null)
+ {
+ if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry']))
+ {
+ unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry']);
+ }
+ if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry']))
+ {
+ unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry']);
+ }
+ if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']))
+ {
+ unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']);
+ }
+ if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']))
+ {
+ unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']);
+ }
+ if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item']))
+ {
+ unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item']);
+ }
+ }
+ if (isset($data->data['items']))
+ {
+ unset($data->data['items']);
+ }
+ if (isset($data->data['ordered_items']))
+ {
+ unset($data->data['ordered_items']);
+ }
}
+ return array(serialize($data->data), $items_by_id);
+ }
+}
- $minutes = floor($remainder / 60);
- $seconds = $remainder % 60;
- if ($minutes < 10 && $hours > 0)
+class SimplePie_Cache_MySQL extends SimplePie_Cache_DB
+{
+ var $mysql;
+ var $options;
+ var $id;
+
+ function SimplePie_Cache_MySQL($mysql_location, $name, $extension)
+ {
+ $host = $mysql_location->get_host();
+ if (SimplePie_Misc::stripos($host, 'unix(') === 0 && substr($host, -1) === ')')
{
- $minutes = '0' . $minutes;
+ $server = ':' . substr($host, 5, -1);
}
- if ($seconds < 10)
+ else
{
- $seconds = '0' . $seconds;
+ $server = $host;
+ if ($mysql_location->get_port() !== null)
+ {
+ $server .= ':' . $mysql_location->get_port();
+ }
}
- $time .= $minutes.':';
- $time .= $seconds;
+ if (strpos($mysql_location->get_userinfo(), ':') !== false)
+ {
+ list($username, $password) = explode(':', $mysql_location->get_userinfo(), 2);
+ }
+ else
+ {
+ $username = $mysql_location->get_userinfo();
+ $password = null;
+ }
- return $time;
+ if ($this->mysql = mysql_connect($server, $username, $password))
+ {
+ $this->id = $name . $extension;
+ $this->options = SimplePie_Misc::parse_str($mysql_location->get_query());
+ if (!isset($this->options['prefix'][0]))
+ {
+ $this->options['prefix'][0] = '';
+ }
+
+ if (mysql_select_db(ltrim($mysql_location->get_path(), '/'))
+ && mysql_query('SET NAMES utf8')
+ && ($query = mysql_unbuffered_query('SHOW TABLES')))
+ {
+ $db = array();
+ while ($row = mysql_fetch_row($query))
+ {
+ $db[] = $row[0];
+ }
+
+ if (!in_array($this->options['prefix'][0] . 'cache_data', $db))
+ {
+ if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . '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)))'))
+ {
+ $this->mysql = null;
+ }
+ }
+
+ if (!in_array($this->options['prefix'][0] . 'items', $db))
+ {
+ if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . '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)))'))
+ {
+ $this->mysql = null;
+ }
+ }
+ }
+ else
+ {
+ $this->mysql = null;
+ }
+ }
}
- function absolutize_url($relative, $base)
+ function save($data)
{
- if ($relative !== '')
+ if ($this->mysql)
{
- $relative = SimplePie_Misc::parse_url($relative);
- if ($relative['scheme'] !== '')
- {
- $target = $relative;
- }
- elseif ($base !== '')
+ $feed_id = "'" . mysql_real_escape_string($this->id) . "'";
+
+ if (is_a($data, 'SimplePie'))
{
- $base = SimplePie_Misc::parse_url($base);
- $target = SimplePie_Misc::parse_url('');
- if ($relative['authority'] !== '')
+ if (SIMPLEPIE_PHP5)
{
- $target = $relative;
- $target['scheme'] = $base['scheme'];
+ // This keyword needs to defy coding standards for PHP4 compatibility
+ $data = clone($data);
}
- else
+
+ $prepared = $this->prepare_simplepie_object_for_cache($data);
+
+ if ($query = mysql_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = ' . $feed_id, $this->mysql))
{
- $target['scheme'] = $base['scheme'];
- $target['authority'] = $base['authority'];
- if ($relative['path'] !== '')
+ if (mysql_num_rows($query))
{
- if (strpos($relative['path'], '/') === 0)
- {
- $target['path'] = $relative['path'];
- }
- elseif ($base['authority'] !== '' && $base['path'] === '')
+ $items = count($prepared[1]);
+ if ($items)
{
- $target['path'] = '/' . $relative['path'];
+ $sql = 'UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `items` = ' . $items . ', `data` = \'' . mysql_real_escape_string($prepared[0]) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id;
}
- elseif (($last_segment = strrpos($base['path'], '/')) !== false)
+ else
{
- $target['path'] = substr($base['path'], 0, $last_segment + 1) . $relative['path'];
+ $sql = 'UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `data` = \'' . mysql_real_escape_string($prepared[0]) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id;
}
- else
+
+ if (!mysql_query($sql, $this->mysql))
{
- $target['path'] = $relative['path'];
+ return false;
}
- $target['query'] = $relative['query'];
}
- else
+ elseif (!mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(' . $feed_id . ', ' . count($prepared[1]) . ', \'' . mysql_real_escape_string($prepared[0]) . '\', ' . time() . ')', $this->mysql))
+ {
+ return false;
+ }
+
+ $ids = array_keys($prepared[1]);
+ if (!empty($ids))
{
- $target['path'] = $base['path'];
- if ($relative['query'] !== '')
+ foreach ($ids as $id)
{
- $target['query'] = $relative['query'];
+ $database_ids[] = mysql_real_escape_string($id);
}
- elseif ($base['query'] !== '')
+
+ if ($query = mysql_unbuffered_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'items` WHERE `id` = \'' . implode('\' OR `id` = \'', $database_ids) . '\' AND `feed_id` = ' . $feed_id, $this->mysql))
{
- $target['query'] = $base['query'];
+ $existing_ids = array();
+ while ($row = mysql_fetch_row($query))
+ {
+ $existing_ids[] = $row[0];
+ }
+
+ $new_ids = array_diff($ids, $existing_ids);
+
+ foreach ($new_ids as $new_id)
+ {
+ if (!($date = $prepared[1][$new_id]->get_date('U')))
+ {
+ $date = time();
+ }
+
+ if (!mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'items` (`feed_id`, `id`, `data`, `posted`) VALUES(' . $feed_id . ', \'' . mysql_real_escape_string($new_id) . '\', \'' . mysql_real_escape_string(serialize($prepared[1][$new_id]->data)) . '\', ' . $date . ')', $this->mysql))
+ {
+ return false;
+ }
+ }
+ return true;
}
}
+ else
+ {
+ return true;
+ }
+ }
+ }
+ elseif ($query = mysql_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = ' . $feed_id, $this->mysql))
+ {
+ if (mysql_num_rows($query))
+ {
+ if (mysql_query('UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `items` = 0, `data` = \'' . mysql_real_escape_string(serialize($data)) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id, $this->mysql))
+ {
+ return true;
+ }
+ }
+ elseif (mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(\'' . mysql_real_escape_string($this->id) . '\', 0, \'' . mysql_real_escape_string(serialize($data)) . '\', ' . time() . ')', $this->mysql))
+ {
+ return true;
}
- $target['fragment'] = $relative['fragment'];
+ }
+ }
+ return false;
+ }
+
+ function load()
+ {
+ if ($this->mysql && ($query = mysql_query('SELECT `items`, `data` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($row = mysql_fetch_row($query)))
+ {
+ $data = unserialize($row[1]);
+
+ if (isset($this->options['items'][0]))
+ {
+ $items = (int) $this->options['items'][0];
}
else
{
- // No base URL, just return the relative URL
- $target = $relative;
+ $items = (int) $row[0];
+ }
+
+ if ($items !== 0)
+ {
+ if (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]))
+ {
+ $feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0];
+ }
+ elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]))
+ {
+ $feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0];
+ }
+ elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]))
+ {
+ $feed =& $data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0];
+ }
+ elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]))
+ {
+ $feed =& $data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0];
+ }
+ else
+ {
+ $feed = null;
+ }
+
+ if ($feed !== null)
+ {
+ $sql = 'SELECT `data` FROM `' . $this->options['prefix'][0] . 'items` WHERE `feed_id` = \'' . mysql_real_escape_string($this->id) . '\' ORDER BY `posted` DESC';
+ if ($items > 0)
+ {
+ $sql .= ' LIMIT ' . $items;
+ }
+
+ if ($query = mysql_unbuffered_query($sql, $this->mysql))
+ {
+ while ($row = mysql_fetch_row($query))
+ {
+ $feed['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'][] = unserialize($row[0]);
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
}
- $return = SimplePie_Misc::compress_parse_url($target['scheme'], $target['authority'], $target['path'], $target['query'], $target['fragment']);
+ return $data;
+ }
+ return false;
+ }
+
+ function mtime()
+ {
+ if ($this->mysql && ($query = mysql_query('SELECT `mtime` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($row = mysql_fetch_row($query)))
+ {
+ return $row[0];
}
else
{
- $return = $base;
+ return false;
}
- $return = SimplePie_Misc::normalize_url($return);
- return $return;
+ }
+
+ function touch()
+ {
+ if ($this->mysql && ($query = mysql_query('UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `mtime` = ' . time() . ' WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && mysql_affected_rows($this->mysql))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ function unlink()
+ {
+ if ($this->mysql && ($query = mysql_query('DELETE FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($query2 = mysql_query('DELETE FROM `' . $this->options['prefix'][0] . 'items` WHERE `feed_id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+}
+
+class SimplePie_Misc
+{
+ 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)
+ {
+ $minutes = '0' . $minutes;
+ }
+ if ($seconds < 10)
+ {
+ $seconds = '0' . $seconds;
+ }
+
+ $time .= $minutes.':';
+ $time .= $seconds;
+
+ return $time;
+ }
+
+ function absolutize_url($relative, $base)
+ {
+ $iri = SimplePie_IRI::absolutize(new SimplePie_IRI($base), $relative);
+ return $iri->get_iri();
}
function remove_dot_segments($input)
{
$output = '';
- while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input == '.' || $input == '..')
+ while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..')
{
// A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise,
if (strpos($input, '../') === 0)
{
$input = substr_replace($input, '/', 0, 3);
}
- elseif ($input == '/.')
+ elseif ($input === '/.')
{
$input = '/';
}
$input = substr_replace($input, '/', 0, 4);
$output = substr_replace($output, '', strrpos($output, '/'));
}
- elseif ($input == '/..')
+ elseif ($input === '/..')
{
$input = '/';
$output = substr_replace($output, '', strrpos($output, '/'));
}
// D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise,
- elseif ($input == '.' || $input == '..')
+ elseif ($input === '.' || $input === '..')
{
$input = '';
}
{
for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++)
{
- if (count($attribs[$j]) == 2)
+ if (count($attribs[$j]) === 2)
{
$attribs[$j][2] = $attribs[$j][1];
}
function error($message, $level, $file, $line)
{
- switch ($level)
+ if ((ini_get('error_reporting') & $level) > 0)
{
- case E_USER_ERROR:
- $note = 'PHP Error';
- break;
- case E_USER_WARNING:
- $note = 'PHP Warning';
- break;
- case E_USER_NOTICE:
- $note = 'PHP Notice';
- break;
- default:
- $note = 'Unknown Error';
- break;
- }
- error_log("$note: $message in $file on line $line", 0);
- return $message;
- }
-
- /**
- * If a file has been cached, retrieve and display it.
- *
- * This is most useful for caching images (get_favicon(), etc.),
+ switch ($level)
+ {
+ case E_USER_ERROR:
+ $note = 'PHP Error';
+ break;
+ case E_USER_WARNING:
+ $note = 'PHP Warning';
+ break;
+ case E_USER_NOTICE:
+ $note = 'PHP Notice';
+ break;
+ default:
+ $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;
+ }
+
+ /**
+ * If a file has been cached, retrieve and display it.
+ *
+ * This is most useful for caching images (get_favicon(), etc.),
* however it works for all cached files. This WILL NOT display ANY
* file/image/page/whatever, but rather only display what has already
* been cached by SimplePie.
{
$url = SimplePie_Misc::normalize_url($url);
$parsed = SimplePie_Misc::parse_url($url);
- if ($parsed['scheme'] !== '' && $parsed['scheme'] != 'http' && $parsed['scheme'] != 'https')
+ if ($parsed['scheme'] !== '' && $parsed['scheme'] !== 'http' && $parsed['scheme'] !== 'https')
{
return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http);
}
return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http);
}
- if ($http == 2 && $parsed['scheme'] !== '')
+ if ($http === 2 && $parsed['scheme'] !== '')
{
return "feed:$url";
}
- elseif ($http == 3 && strtolower($parsed['scheme']) == 'http')
+ elseif ($http === 3 && strtolower($parsed['scheme']) === 'http')
{
return substr_replace($url, 'podcast', 0, 4);
}
- elseif ($http == 4 && strtolower($parsed['scheme']) == 'http')
+ elseif ($http === 4 && strtolower($parsed['scheme']) === 'http')
{
return substr_replace($url, 'itpc', 0, 4);
}
function parse_url($url)
{
- static $cache = array();
- if (isset($cache[$url]))
- {
- return $cache[$url];
- }
- elseif (preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/', $url, $match))
- {
- for ($i = count($match); $i <= 9; $i++)
- {
- $match[$i] = '';
- }
- return $cache[$url] = array('scheme' => $match[2], 'authority' => $match[4], 'path' => $match[5], 'query' => $match[7], 'fragment' => $match[9]);
- }
- else
- {
- return $cache[$url] = array('scheme' => '', 'authority' => '', 'path' => '', 'query' => '', 'fragment' => '');
- }
+ $iri =& new SimplePie_IRI($url);
+ return array(
+ 'scheme' => (string) $iri->get_scheme(),
+ 'authority' => (string) $iri->get_authority(),
+ 'path' => (string) $iri->get_path(),
+ 'query' => (string) $iri->get_query(),
+ 'fragment' => (string) $iri->get_fragment()
+ );
}
function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '')
{
- $return = '';
- if ($scheme !== '')
- {
- $return .= "$scheme:";
- }
- if ($authority !== '')
- {
- $return .= "//$authority";
- }
- if ($path !== '')
- {
- $return .= $path;
- }
- if ($query !== '')
- {
- $return .= "?$query";
- }
- if ($fragment !== '')
- {
- $return .= "#$fragment";
- }
- return $return;
+ $iri =& new SimplePie_IRI('');
+ $iri->set_scheme($scheme);
+ $iri->set_authority($authority);
+ $iri->set_path($path);
+ $iri->set_query($query);
+ $iri->set_fragment($fragment);
+ return $iri->get_iri();
}
function normalize_url($url)
{
- $url = preg_replace_callback('/%([0-9A-Fa-f]{2})/', array('SimplePie_Misc', 'percent_encoding_normalization'), $url);
- $url = SimplePie_Misc::parse_url($url);
- $url['scheme'] = strtolower($url['scheme']);
- if ($url['authority'] !== '')
- {
- $url['authority'] = strtolower($url['authority']);
- $url['path'] = SimplePie_Misc::remove_dot_segments($url['path']);
- }
- return SimplePie_Misc::compress_parse_url($url['scheme'], $url['authority'], $url['path'], $url['query'], $url['fragment']);
+ $iri =& new SimplePie_IRI($url);
+ return $iri->get_iri();
}
function percent_encoding_normalization($match)
{
$integer = hexdec($match[1]);
- if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer == 0x2D || $integer == 0x2E || $integer == 0x5F || $integer == 0x7E)
+ if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E)
{
return chr($integer);
}
}
// This is first, as behaviour of this is completely predictable
- if ($input === 'Windows-1252' && $output === 'UTF-8')
+ if ($input === 'windows-1252' && $output === 'UTF-8')
{
return SimplePie_Misc::windows_1252_to_utf8($data);
}
- // This is second, as behaviour of this varies only with PHP version
- elseif (function_exists('mb_convert_encoding') && ($return = @mb_convert_encoding($data, $output, $input)))
+ // This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported).
+ elseif (function_exists('mb_convert_encoding') && @mb_convert_encoding("\x80", 'UTF-16BE', $input) !== "\x00\x80" && in_array($input, mb_list_encodings()) && ($return = @mb_convert_encoding($data, $output, $input)))
{
return $return;
}
}
}
+ /**
+ * Normalize an encoding name
+ *
+ * This is automatically generated by create.php
+ *
+ * To generate it, run `php create.php` on the command line, and copy the
+ * output to replace this function.
+ *
+ * @param string $charset Character set to standardise
+ * @return string Standardised name
+ */
function encoding($charset)
{
- /* Character sets are case-insensitive, and also need some further
- normalization in the real world (though we'll return them in the form given
- in their registration). */
- switch (strtolower(preg_replace('/[\x09-\x0D\x20-\x2F\x3A-\x40\x5B-\x60\x7B-\x7E]/', '', $charset)))
+ // Normalization from UTS #22
+ switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset)))
{
case 'adobestandardencoding':
case 'csadobestandardencoding':
return 'Adobe-Symbol-Encoding';
case 'ami1251':
- case 'ami1251':
- case 'amiga1251':
case 'amiga1251':
return 'Amiga-1251';
case 'arabic7':
case 'asmo449':
case 'csiso89asmo449':
- case 'isoir89':
case 'iso9036':
+ case 'isoir89':
return 'ASMO_449';
case 'big5':
case 'csbig5':
- case 'xxbig5':
return 'Big5';
case 'big5hkscs':
case 'bs4730':
case 'csiso4unitedkingdom':
case 'gb':
- case 'isoir4':
case 'iso646gb':
+ case 'isoir4':
case 'uk':
return 'BS_4730';
case 'csa71':
case 'csaz243419851':
case 'csiso121canadian1':
- case 'isoir121':
case 'iso646ca':
+ case 'isoir121':
return 'CSA_Z243.4-1985-1';
case 'csa72':
case 'csaz243419852':
case 'csiso122canadian2':
- case 'isoir122':
case 'iso646ca2':
+ case 'isoir122':
return 'CSA_Z243.4-1985-2';
case 'csaz24341985gr':
case 'csiso21german':
case 'de':
case 'din66003':
- case 'isoir21':
case 'iso646de':
+ case 'isoir21':
return 'DIN_66003';
case 'csdkus':
case 'csiso646danish':
case 'dk':
case 'ds2089':
- case 'ds2089':
case 'iso646dk':
return 'DS_2089';
case 'csiso17spanish':
case 'es':
- case 'isoir17':
case 'iso646es':
+ case 'isoir17':
return 'ES';
case 'csiso85spanish2':
case 'es2':
- case 'isoir85':
case 'iso646es2':
+ case 'isoir85':
return 'ES2';
- case 'cseucfixwidjapanese':
- case 'extendedunixcodefixedwidthforjapanese':
- return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
-
case 'cseucpkdfmtjapanese':
case 'eucjp':
case 'extendedunixcodepackedformatforjapanese':
- return 'Extended_UNIX_Code_Packed_Format_for_Japanese';
+ return 'EUC-JP';
+
+ case 'cseucfixwidjapanese':
+ case 'extendedunixcodefixedwidthforjapanese':
+ return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
case 'gb18030':
return 'GB18030';
+ case 'chinese':
case 'cp936':
- case 'gbk':
- case 'ms936':
- case 'windows936':
case 'csgb2312':
- case 'gb2312':
- case 'chinese':
case 'csiso58gb231280':
+ case 'gb2312':
case 'gb231280':
+ case 'gbk':
case 'isoir58':
+ case 'ms936':
+ case 'windows936':
return 'GBK';
case 'cn':
case 'csiso57gb1988':
case 'gb198880':
- case 'isoir57':
case 'iso646cn':
+ case 'isoir57':
return 'GB_1988-80';
case 'csiso153gost1976874':
case 'ibmthai':
return 'IBM-Thai';
- case 'ccsid00858':
- case 'cp00858':
- case 'ibm00858':
- case 'pcmultilingual850euro':
- return 'IBM00858';
-
- case 'ccsid00924':
- case 'cp00924':
- case 'ebcdiclatin9euro':
- case 'ibm00924':
- return 'IBM00924';
-
- case 'ccsid01140':
- case 'cp01140':
- case 'ebcdicus37euro':
- case 'ibm01140':
- return 'IBM01140';
-
- case 'ccsid01141':
- case 'cp01141':
- case 'ebcdicde273euro':
- case 'ibm01141':
- return 'IBM01141';
-
- case 'ccsid01142':
- case 'cp01142':
- case 'ebcdicdk277euro':
- case 'ebcdicno277euro':
- case 'ibm01142':
- return 'IBM01142';
-
- case 'ccsid01143':
- case 'cp01143':
- case 'ebcdicfi278euro':
- case 'ebcdicse278euro':
- case 'ibm01143':
- return 'IBM01143';
-
- case 'ccsid01144':
- case 'cp01144':
- case 'ebcdicit280euro':
- case 'ibm01144':
- return 'IBM01144';
-
- case 'ccsid01145':
- case 'cp01145':
- case 'ebcdices284euro':
- case 'ibm01145':
- return 'IBM01145';
-
- case 'ccsid01146':
- case 'cp01146':
- case 'ebcdicgb285euro':
- case 'ibm01146':
- return 'IBM01146';
-
- case 'ccsid01147':
- case 'cp01147':
- case 'ebcdicfr297euro':
- case 'ibm01147':
- return 'IBM01147';
-
- case 'ccsid01148':
- case 'cp01148':
- case 'ebcdicinternational500euro':
- case 'ibm01148':
- return 'IBM01148';
-
- case 'ccsid01149':
- case 'cp01149':
- case 'ebcdicis871euro':
- case 'ibm01149':
- return 'IBM01149';
-
- case 'cp037':
- case 'csibm037':
+ case 'cp37':
+ case 'csibm37':
case 'ebcdiccpca':
case 'ebcdiccpnl':
case 'ebcdiccpus':
case 'ebcdiccpwt':
- case 'ibm037':
+ case 'ibm37':
return 'IBM037';
- case 'cp038':
- case 'csibm038':
+ case 'cp38':
+ case 'csibm38':
case 'ebcdicint':
- case 'ibm038':
+ case 'ibm38':
return 'IBM038';
case 'cp273':
case 'ibm857':
return 'IBM857';
+ case 'ccsid858':
+ case 'cp858':
+ case 'ibm858':
+ case 'pcmultilingual850euro':
+ return 'IBM00858';
+
case '860':
case 'cp860':
case 'csibm860':
return 'IBM860';
case '861':
- case 'cpis':
case 'cp861':
+ case 'cpis':
case 'csibm861':
case 'ibm861':
return 'IBM861';
case 'ibm866':
return 'IBM866';
- case 'cpar':
case 'cp868':
+ case 'cpar':
case 'csibm868':
case 'ibm868':
return 'IBM868';
case '869':
- case 'cpgr':
case 'cp869':
+ case 'cpgr':
case 'csibm869':
case 'ibm869':
return 'IBM869';
case 'ibm918':
return 'IBM918';
+ case 'ccsid924':
+ case 'cp924':
+ case 'ebcdiclatin9euro':
+ case 'ibm924':
+ return 'IBM00924';
+
case 'cp1026':
case 'csibm1026':
case 'ibm1026':
return 'IBM1026';
- case 'ibm1047':
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':
case 'csisolatin2':
case 'iso88592':
- case 'isoir101':
- case 'iso88592':
case 'iso885921987':
+ case 'isoir101':
case 'l2':
case 'latin2':
return 'ISO-8859-2';
case 'csisolatin3':
case 'iso88593':
- case 'isoir109':
- case 'iso88593':
case 'iso885931988':
+ case 'isoir109':
case 'l3':
case 'latin3':
return 'ISO-8859-3';
case 'csisolatin4':
case 'iso88594':
- case 'isoir110':
- case 'iso88594':
case 'iso885941988':
+ case 'isoir110':
case 'l4':
case 'latin4':
return 'ISO-8859-4';
case 'csisolatincyrillic':
case 'cyrillic':
case 'iso88595':
- case 'isoir144':
- case 'iso88595':
case 'iso885951988':
+ case 'isoir144':
return 'ISO-8859-5';
case 'arabic':
case 'csisolatinarabic':
case 'ecma114':
case 'iso88596':
- case 'isoir127':
- case 'iso88596':
case 'iso885961987':
+ case 'isoir127':
return 'ISO-8859-6';
case 'csiso88596e':
- case 'iso88596e':
case 'iso88596e':
return 'ISO-8859-6-E';
case 'csiso88596i':
- case 'iso88596i':
case 'iso88596i':
return 'ISO-8859-6-I';
case 'greek':
case 'greek8':
case 'iso88597':
- case 'isoir126':
- case 'iso88597':
case 'iso885971987':
+ case 'isoir126':
return 'ISO-8859-7';
case 'csisolatinhebrew':
case 'hebrew':
case 'iso88598':
- case 'isoir138':
- case 'iso88598':
case 'iso885981988':
+ case 'isoir138':