1 Author: Roland Mas <lolando@debian.org>
2 Description: Use SimplePie as provided by the libphp-simplepie Debian package
3 Index: src/common/widget/Widget_Rss.class.php
4 ===================================================================
5 --- src.orig/common/widget/Widget_Rss.class.php
6 +++ src/common/widget/Widget_Rss.class.php
8 return idn_to_unicode($param);
11 - require_once('common/rss/simplepie.inc');
12 + require_once('/usr/share/php/simplepie/simplepie.inc');
13 if (!is_dir(forge_get_config('data_path') .'/rss')) {
14 mkdir(forge_get_config('data_path') .'/rss');
17 $vTitle = new Valid_String('title');
19 if (!$request->validInArray('rss', $vTitle)) {
20 - if (function_exists('idn_to_utf8()')) {
21 - require_once('simplepie/simplepie.inc');
24 - require_once('common/rss/simplepie.inc');
26 + require_once('/usr/share/php/simplepie/simplepie.inc');
27 if (!is_dir(forge_get_config('data_path') .'/rss')) {
28 mkdir(forge_get_config('data_path') .'/rss');
30 Index: src/common/rss/simplepie.inc
31 ===================================================================
32 --- src.orig/common/rss/simplepie.inc
39 - * A PHP-Based RSS and Atom Feed Framework.
40 - * Takes the hard work out of managing a complete RSS/Atom solution.
42 - * Copyright (c) 2004-2008, Ryan Parman and Geoffrey Sneddon
43 - * All rights reserved.
45 - * Redistribution and use in source and binary forms, with or without modification, are
46 - * permitted provided that the following conditions are met:
48 - * * Redistributions of source code must retain the above copyright notice, this list of
49 - * conditions and the following disclaimer.
51 - * * Redistributions in binary form must reproduce the above copyright notice, this list
52 - * of conditions and the following disclaimer in the documentation and/or other materials
53 - * provided with the distribution.
55 - * * Neither the name of the SimplePie Team nor the names of its contributors may be used
56 - * to endorse or promote products derived from this software without specific prior
57 - * written permission.
59 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
60 - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
61 - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
62 - * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
63 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
64 - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
65 - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
66 - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
67 - * POSSIBILITY OF SUCH DAMAGE.
69 - * @package SimplePie
71 - * @copyright 2004-2008 Ryan Parman, Geoffrey Sneddon
72 - * @author Ryan Parman
73 - * @author Geoffrey Sneddon
74 - * @link http://simplepie.org/ SimplePie
75 - * @link http://simplepie.org/support/ Please submit all bug reports and feature requests to the SimplePie forums
76 - * @license http://www.opensource.org/licenses/bsd-license.php BSD License
77 - * @todo phpDoc comments
83 -define('SIMPLEPIE_NAME', 'SimplePie');
88 -define('SIMPLEPIE_VERSION', '1.1.3');
93 -define('SIMPLEPIE_BUILD', 20081219);
96 - * SimplePie Website URL
98 -define('SIMPLEPIE_URL', 'http://simplepie.org');
101 - * SimplePie Useragent
102 - * @see SimplePie::set_useragent()
104 -define('SIMPLEPIE_USERAGENT', SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION . ' (Feed Parser; ' . SIMPLEPIE_URL . '; Allow like Gecko) Build/' . SIMPLEPIE_BUILD);
107 - * SimplePie Linkback
109 -define('SIMPLEPIE_LINKBACK', '<a href="' . SIMPLEPIE_URL . '" title="' . SIMPLEPIE_NAME . ' ' . SIMPLEPIE_VERSION . '">' . SIMPLEPIE_NAME . '</a>');
113 - * @see SimplePie::set_autodiscovery_level()
115 -define('SIMPLEPIE_LOCATOR_NONE', 0);
118 - * Feed Link Element Autodiscovery
119 - * @see SimplePie::set_autodiscovery_level()
121 -define('SIMPLEPIE_LOCATOR_AUTODISCOVERY', 1);
124 - * Local Feed Extension Autodiscovery
125 - * @see SimplePie::set_autodiscovery_level()
127 -define('SIMPLEPIE_LOCATOR_LOCAL_EXTENSION', 2);
130 - * Local Feed Body Autodiscovery
131 - * @see SimplePie::set_autodiscovery_level()
133 -define('SIMPLEPIE_LOCATOR_LOCAL_BODY', 4);
136 - * Remote Feed Extension Autodiscovery
137 - * @see SimplePie::set_autodiscovery_level()
139 -define('SIMPLEPIE_LOCATOR_REMOTE_EXTENSION', 8);
142 - * Remote Feed Body Autodiscovery
143 - * @see SimplePie::set_autodiscovery_level()
145 -define('SIMPLEPIE_LOCATOR_REMOTE_BODY', 16);
148 - * All Feed Autodiscovery
149 - * @see SimplePie::set_autodiscovery_level()
151 -define('SIMPLEPIE_LOCATOR_ALL', 31);
154 - * No known feed type
156 -define('SIMPLEPIE_TYPE_NONE', 0);
161 -define('SIMPLEPIE_TYPE_RSS_090', 1);
164 - * RSS 0.91 (Netscape)
166 -define('SIMPLEPIE_TYPE_RSS_091_NETSCAPE', 2);
169 - * RSS 0.91 (Userland)
171 -define('SIMPLEPIE_TYPE_RSS_091_USERLAND', 4);
174 - * RSS 0.91 (both Netscape and Userland)
176 -define('SIMPLEPIE_TYPE_RSS_091', 6);
181 -define('SIMPLEPIE_TYPE_RSS_092', 8);
186 -define('SIMPLEPIE_TYPE_RSS_093', 16);
191 -define('SIMPLEPIE_TYPE_RSS_094', 32);
196 -define('SIMPLEPIE_TYPE_RSS_10', 64);
201 -define('SIMPLEPIE_TYPE_RSS_20', 128);
206 -define('SIMPLEPIE_TYPE_RSS_RDF', 65);
209 - * Non-RDF-based RSS (truly intended as syndication format)
211 -define('SIMPLEPIE_TYPE_RSS_SYNDICATION', 190);
216 -define('SIMPLEPIE_TYPE_RSS_ALL', 255);
221 -define('SIMPLEPIE_TYPE_ATOM_03', 256);
226 -define('SIMPLEPIE_TYPE_ATOM_10', 512);
231 -define('SIMPLEPIE_TYPE_ATOM_ALL', 768);
236 -define('SIMPLEPIE_TYPE_ALL', 1023);
241 -define('SIMPLEPIE_CONSTRUCT_NONE', 0);
246 -define('SIMPLEPIE_CONSTRUCT_TEXT', 1);
251 -define('SIMPLEPIE_CONSTRUCT_HTML', 2);
256 -define('SIMPLEPIE_CONSTRUCT_XHTML', 4);
259 - * base64-encoded construct
261 -define('SIMPLEPIE_CONSTRUCT_BASE64', 8);
266 -define('SIMPLEPIE_CONSTRUCT_IRI', 16);
269 - * A construct that might be HTML
271 -define('SIMPLEPIE_CONSTRUCT_MAYBE_HTML', 32);
276 -define('SIMPLEPIE_CONSTRUCT_ALL', 63);
279 - * PCRE for HTML attributes
281 -define('SIMPLEPIE_PCRE_HTML_ATTRIBUTE', '((?:[\x09\x0A\x0B\x0C\x0D\x20]+[^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?)*)[\x09\x0A\x0B\x0C\x0D\x20]*');
284 - * PCRE for XML attributes
286 -define('SIMPLEPIE_PCRE_XML_ATTRIBUTE', '((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'))*)\s*');
291 -define('SIMPLEPIE_NAMESPACE_XML', 'http://www.w3.org/XML/1998/namespace');
294 - * Atom 1.0 Namespace
296 -define('SIMPLEPIE_NAMESPACE_ATOM_10', 'http://www.w3.org/2005/Atom');
299 - * Atom 0.3 Namespace
301 -define('SIMPLEPIE_NAMESPACE_ATOM_03', 'http://purl.org/atom/ns#');
306 -define('SIMPLEPIE_NAMESPACE_RDF', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
309 - * RSS 0.90 Namespace
311 -define('SIMPLEPIE_NAMESPACE_RSS_090', 'http://my.netscape.com/rdf/simple/0.9/');
314 - * RSS 1.0 Namespace
316 -define('SIMPLEPIE_NAMESPACE_RSS_10', 'http://purl.org/rss/1.0/');
319 - * RSS 1.0 Content Module Namespace
321 -define('SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT', 'http://purl.org/rss/1.0/modules/content/');
324 - * RSS 2.0 Namespace
325 - * (Stupid, I know, but I'm certain it will confuse people less with support.)
327 -define('SIMPLEPIE_NAMESPACE_RSS_20', '');
332 -define('SIMPLEPIE_NAMESPACE_DC_10', 'http://purl.org/dc/elements/1.0/');
337 -define('SIMPLEPIE_NAMESPACE_DC_11', 'http://purl.org/dc/elements/1.1/');
340 - * W3C Basic Geo (WGS84 lat/long) Vocabulary Namespace
342 -define('SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO', 'http://www.w3.org/2003/01/geo/wgs84_pos#');
347 -define('SIMPLEPIE_NAMESPACE_GEORSS', 'http://www.georss.org/georss');
350 - * Media RSS Namespace
352 -define('SIMPLEPIE_NAMESPACE_MEDIARSS', 'http://search.yahoo.com/mrss/');
355 - * Wrong Media RSS Namespace
357 -define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG', 'http://search.yahoo.com/mrss');
360 - * iTunes RSS Namespace
362 -define('SIMPLEPIE_NAMESPACE_ITUNES', 'http://www.itunes.com/dtds/podcast-1.0.dtd');
367 -define('SIMPLEPIE_NAMESPACE_XHTML', 'http://www.w3.org/1999/xhtml');
370 - * IANA Link Relations Registry
372 -define('SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY', 'http://www.iana.org/assignments/relation/');
375 - * Whether we're running on PHP5
377 -define('SIMPLEPIE_PHP5', version_compare(PHP_VERSION, '5.0.0', '>='));
382 -define('SIMPLEPIE_FILE_SOURCE_NONE', 0);
385 - * Remote file source
387 -define('SIMPLEPIE_FILE_SOURCE_REMOTE', 1);
390 - * Local file source
392 -define('SIMPLEPIE_FILE_SOURCE_LOCAL', 2);
395 - * fsockopen() file source
397 -define('SIMPLEPIE_FILE_SOURCE_FSOCKOPEN', 4);
402 -define('SIMPLEPIE_FILE_SOURCE_CURL', 8);
405 - * file_get_contents() file source
407 -define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16);
412 - * @package SimplePie
413 - * @version "Razzleberry"
414 - * @copyright 2004-2007 Ryan Parman, Geoffrey Sneddon
415 - * @author Ryan Parman
416 - * @author Geoffrey Sneddon
417 - * @todo Option for type of fetching (cache, not modified header, fetch, etc.)
422 - * @var array Raw data
425 - var $data = array();
428 - * @var mixed Error string
434 - * @var object Instance of SimplePie_Sanitize (or other class)
435 - * @see SimplePie::set_sanitize_class()
441 - * @var string SimplePie Useragent
442 - * @see SimplePie::set_useragent()
445 - var $useragent = SIMPLEPIE_USERAGENT;
448 - * @var string Feed URL
449 - * @see SimplePie::set_feed_url()
455 - * @var object Instance of SimplePie_File to use as a feed
456 - * @see SimplePie::set_file()
462 - * @var string Raw feed data
463 - * @see SimplePie::set_raw_data()
469 - * @var int Timeout for fetching remote files
470 - * @see SimplePie::set_timeout()
476 - * @var bool Forces fsockopen() to be used for remote files instead
477 - * of cURL, even if a new enough version is installed
478 - * @see SimplePie::force_fsockopen()
481 - var $force_fsockopen = false;
484 - * @var bool Force the given data/URL to be treated as a feed no matter what
486 - * @see SimplePie::force_feed()
489 - var $force_feed = false;
492 - * @var bool Enable/Disable XML dump
493 - * @see SimplePie::enable_xml_dump()
496 - var $xml_dump = false;
499 - * @var bool Enable/Disable Caching
500 - * @see SimplePie::enable_cache()
506 - * @var int Cache duration (in seconds)
507 - * @see SimplePie::set_cache_duration()
510 - var $cache_duration = 3600;
513 - * @var int Auto-discovery cache duration (in seconds)
514 - * @see SimplePie::set_autodiscovery_cache_duration()
517 - var $autodiscovery_cache_duration = 604800; // 7 Days.
520 - * @var string Cache location (relative to executing script)
521 - * @see SimplePie::set_cache_location()
524 - var $cache_location = './cache';
527 - * @var string Function that creates the cache filename
528 - * @see SimplePie::set_cache_name_function()
531 - var $cache_name_function = 'md5';
534 - * @var bool Reorder feed by date descending
535 - * @see SimplePie::enable_order_by_date()
538 - var $order_by_date = true;
541 - * @var mixed Force input encoding to be set to the follow value
542 - * (false, or anything type-cast to false, disables this feature)
543 - * @see SimplePie::set_input_encoding()
546 - var $input_encoding = false;
549 - * @var int Feed Autodiscovery Level
550 - * @see SimplePie::set_autodiscovery_level()
553 - var $autodiscovery = SIMPLEPIE_LOCATOR_ALL;
556 - * @var string Class used for caching feeds
557 - * @see SimplePie::set_cache_class()
560 - var $cache_class = 'SimplePie_Cache';
563 - * @var string Class used for locating feeds
564 - * @see SimplePie::set_locator_class()
567 - var $locator_class = 'SimplePie_Locator';
570 - * @var string Class used for parsing feeds
571 - * @see SimplePie::set_parser_class()
574 - var $parser_class = 'SimplePie_Parser';
577 - * @var string Class used for fetching feeds
578 - * @see SimplePie::set_file_class()
581 - var $file_class = 'SimplePie_File';
584 - * @var string Class used for items
585 - * @see SimplePie::set_item_class()
588 - var $item_class = 'SimplePie_Item';
591 - * @var string Class used for authors
592 - * @see SimplePie::set_author_class()
595 - var $author_class = 'SimplePie_Author';
598 - * @var string Class used for categories
599 - * @see SimplePie::set_category_class()
602 - var $category_class = 'SimplePie_Category';
605 - * @var string Class used for enclosures
606 - * @see SimplePie::set_enclosures_class()
609 - var $enclosure_class = 'SimplePie_Enclosure';
612 - * @var string Class used for Media RSS <media:text> captions
613 - * @see SimplePie::set_caption_class()
616 - var $caption_class = 'SimplePie_Caption';
619 - * @var string Class used for Media RSS <media:copyright>
620 - * @see SimplePie::set_copyright_class()
623 - var $copyright_class = 'SimplePie_Copyright';
626 - * @var string Class used for Media RSS <media:credit>
627 - * @see SimplePie::set_credit_class()
630 - var $credit_class = 'SimplePie_Credit';
633 - * @var string Class used for Media RSS <media:rating>
634 - * @see SimplePie::set_rating_class()
637 - var $rating_class = 'SimplePie_Rating';
640 - * @var string Class used for Media RSS <media:restriction>
641 - * @see SimplePie::set_restriction_class()
644 - var $restriction_class = 'SimplePie_Restriction';
647 - * @var string Class used for content-type sniffing
648 - * @see SimplePie::set_content_type_sniffer_class()
651 - var $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer';
654 - * @var string Class used for item sources.
655 - * @see SimplePie::set_source_class()
658 - var $source_class = 'SimplePie_Source';
661 - * @var mixed Set javascript query string parameter (false, or
662 - * anything type-cast to false, disables this feature)
663 - * @see SimplePie::set_javascript()
666 - var $javascript = 'js';
669 - * @var int Maximum number of feeds to check with autodiscovery
670 - * @see SimplePie::set_max_checked_feeds()
673 - var $max_checked_feeds = 10;
676 - * @var string Web-accessible path to the handler_favicon.php file.
677 - * @see SimplePie::set_favicon_handler()
680 - var $favicon_handler = '';
683 - * @var string Web-accessible path to the handler_image.php file.
684 - * @see SimplePie::set_image_handler()
687 - var $image_handler = '';
690 - * @var array Stores the URLs when multiple feeds are being initialized.
691 - * @see SimplePie::set_feed_url()
694 - var $multifeed_url = array();
697 - * @var array Stores SimplePie objects when multiple feeds initialized.
700 - var $multifeed_objects = array();
703 - * @var array Stores the get_object_vars() array for use with multifeeds.
704 - * @see SimplePie::set_feed_url()
707 - var $config_settings = null;
710 - * @var integer Stores the number of items to return per-feed with multifeeds.
711 - * @see SimplePie::set_item_limit()
714 - var $item_limit = 0;
717 - * @var array Stores the default attributes to be stripped by strip_attributes().
718 - * @see SimplePie::strip_attributes()
721 - var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc');
724 - * @var array Stores the default tags to be stripped by strip_htmltags().
725 - * @see SimplePie::strip_htmltags()
728 - var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style');
731 - * @var string proxy used to fetch feeds
732 - * @see SimplePie::set_proxy()
738 - * The SimplePie class contains feed level data and options
740 - * There are two ways that you can create a new SimplePie object. The first
741 - * is by passing a feed URL as a parameter to the SimplePie constructor
742 - * (as well as optionally setting the cache location and cache expiry). This
743 - * will initialise the whole feed with all of the default settings, and you
744 - * can begin accessing methods and properties immediately.
746 - * The second way is to create the SimplePie object with no parameters
747 - * at all. This will enable you to set configuration options. After setting
748 - * them, you must initialise the feed using $feed->init(). At that point the
749 - * object's methods and properties will be available to you. This format is
750 - * what is used throughout this documentation.
753 - * @since 1.0 Preview Release
754 - * @param string $feed_url This is the URL you want to parse.
755 - * @param string $cache_location This is where you want the cache to be stored.
756 - * @param int $cache_duration This is the number of seconds that you want to store the cache file for.
757 - * @param string $proxy This is the proxy "host:port" used to fetch feeds
759 - function SimplePie($feed_url = null, $cache_location = null, $cache_duration = null, $proxy = null)
761 - // Other objects, instances created here so we can set options on them
762 - $this->sanitize = new SimplePie_Sanitize;
764 - // Set options if they're passed to the constructor
765 - if ($cache_location !== null)
767 - $this->set_cache_location($cache_location);
770 - if ($cache_duration !== null)
772 - $this->set_cache_duration($cache_duration);
775 - if ($proxy !== null)
777 - $this->set_proxy($proxy);
780 - // Only init the script if we're passed a feed URL
781 - if ($feed_url !== null)
783 - $this->set_feed_url($feed_url);
789 - * Used for converting object to a string
791 - function __toString()
793 - return md5(serialize($this->data));
797 - * Remove items that link back to this before destroying this object
799 - function __destruct()
801 - if (!empty($this->data['items']))
803 - foreach ($this->data['items'] as $item)
805 - $item->__destruct();
807 - unset($this->data['items']);
809 - if (!empty($this->data['ordered_items']))
811 - foreach ($this->data['ordered_items'] as $item)
813 - $item->__destruct();
815 - unset($this->data['ordered_items']);
820 - * Force the given data/URL to be treated as a feed no matter what it
825 - * @param bool $enable Force the given data/URL to be treated as a feed
827 - function force_feed($enable = false)
829 - $this->force_feed = (bool) $enable;
833 - * This is the URL of the feed you want to parse.
835 - * This allows you to enter the URL of the feed you want to parse, or the
836 - * website you want to try to use auto-discovery on. This takes priority
837 - * over any set raw data.
839 - * You can set multiple feeds to mash together by passing an array instead
840 - * of a string for the $url. Remember that with each additional feed comes
841 - * additional processing and resources.
844 - * @since 1.0 Preview Release
845 - * @param mixed $url This is the URL (or array of URLs) that you want to parse.
846 - * @see SimplePie::set_raw_data()
848 - function set_feed_url($url)
850 - if (is_array($url))
852 - $this->multifeed_url = array();
853 - foreach ($url as $value)
855 - $this->multifeed_url[] = SimplePie_Misc::fix_protocol($value, 1);
860 - $this->feed_url = SimplePie_Misc::fix_protocol($url, 1);
865 - * This is the proxy used to fetch feeds
868 - * @param string $proxy This is the URL of the proxy "host:port"
870 - function set_proxy($proxy)
872 - $this->proxy = $proxy;
873 - $this->sanitize->proxy = $proxy;
877 - * Provides an instance of SimplePie_File to use as a feed
880 - * @param object &$file Instance of SimplePie_File (or subclass)
881 - * @return bool True on success, false on failure
883 - function set_file(&$file)
885 - if (is_a($file, 'SimplePie_File'))
887 - $this->feed_url = $file->url;
888 - $this->file =& $file;
895 - * Allows you to use a string of RSS/Atom data instead of a remote feed.
897 - * If you have a feed available as a string in PHP, you can tell SimplePie
898 - * to parse that data string instead of a remote feed. Any set feed URL
899 - * takes precedence.
902 - * @since 1.0 Beta 3
903 - * @param string $data RSS or Atom data as a string.
904 - * @see SimplePie::set_feed_url()
906 - function set_raw_data($data)
908 - $this->raw_data = $data;
912 - * Allows you to override the default timeout for fetching remote feeds.
914 - * This allows you to change the maximum time the feed's server to respond
915 - * and send the feed back.
918 - * @since 1.0 Beta 3
919 - * @param int $timeout The maximum number of seconds to spend waiting to retrieve a feed.
921 - function set_timeout($timeout = 10)
923 - $this->timeout = (int) $timeout;
927 - * Forces SimplePie to use fsockopen() instead of the preferred cURL
931 - * @since 1.0 Beta 3
932 - * @param bool $enable Force fsockopen() to be used
934 - function force_fsockopen($enable = false)
936 - $this->force_fsockopen = (bool) $enable;
940 - * Outputs the raw XML content of the feed, after it has gone through
941 - * SimplePie's filters.
943 - * Used only for debugging, this function will output the XML content as
944 - * text/xml. When SimplePie reads in a feed, it does a bit of cleaning up
945 - * before trying to parse it. Many parts of the feed are re-written in
946 - * memory, and in the end, you have a parsable feed. XML dump shows you the
947 - * actual XML that SimplePie tries to parse, which may or may not be very
948 - * different from the original feed.
951 - * @since 1.0 Preview Release
952 - * @param bool $enable Enable XML dump
954 - function enable_xml_dump($enable = false)
956 - $this->xml_dump = (bool) $enable;
960 - * Enables/disables caching in SimplePie.
962 - * This option allows you to disable caching all-together in SimplePie.
963 - * However, disabling the cache can lead to longer load times.
966 - * @since 1.0 Preview Release
967 - * @param bool $enable Enable caching
969 - function enable_cache($enable = true)
971 - $this->cache = (bool) $enable;
975 - * Set the length of time (in seconds) that the contents of a feed
979 - * @param int $seconds The feed content cache duration.
981 - function set_cache_duration($seconds = 3600)
983 - $this->cache_duration = (int) $seconds;
987 - * Set the length of time (in seconds) that the autodiscovered feed
988 - * URL will be cached.
991 - * @param int $seconds The autodiscovered feed URL cache duration.
993 - function set_autodiscovery_cache_duration($seconds = 604800)
995 - $this->autodiscovery_cache_duration = (int) $seconds;
999 - * Set the file system location where the cached files should be stored.
1002 - * @param string $location The file system location.
1004 - function set_cache_location($location = './cache')
1006 - $this->cache_location = (string) $location;
1010 - * Determines whether feed items should be sorted into reverse chronological order.
1013 - * @param bool $enable Sort as reverse chronological order.
1015 - function enable_order_by_date($enable = true)
1017 - $this->order_by_date = (bool) $enable;
1021 - * Allows you to override the character encoding reported by the feed.
1024 - * @param string $encoding Character encoding.
1026 - function set_input_encoding($encoding = false)
1030 - $this->input_encoding = (string) $encoding;
1034 - $this->input_encoding = false;
1039 - * Set how much feed autodiscovery to do
1042 - * @see SIMPLEPIE_LOCATOR_NONE
1043 - * @see SIMPLEPIE_LOCATOR_AUTODISCOVERY
1044 - * @see SIMPLEPIE_LOCATOR_LOCAL_EXTENSION
1045 - * @see SIMPLEPIE_LOCATOR_LOCAL_BODY
1046 - * @see SIMPLEPIE_LOCATOR_REMOTE_EXTENSION
1047 - * @see SIMPLEPIE_LOCATOR_REMOTE_BODY
1048 - * @see SIMPLEPIE_LOCATOR_ALL
1049 - * @param int $level Feed Autodiscovery Level (level can be a
1050 - * combination of the above constants, see bitwise OR operator)
1052 - function set_autodiscovery_level($level = SIMPLEPIE_LOCATOR_ALL)
1054 - $this->autodiscovery = (int) $level;
1058 - * Allows you to change which class SimplePie uses for caching.
1059 - * Useful when you are overloading or extending SimplePie's default classes.
1062 - * @param string $class Name of custom class.
1063 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1064 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1066 - function set_cache_class($class = 'SimplePie_Cache')
1068 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Cache'))
1070 - $this->cache_class = $class;
1077 - * Allows you to change which class SimplePie uses for auto-discovery.
1078 - * Useful when you are overloading or extending SimplePie's default classes.
1081 - * @param string $class Name of custom class.
1082 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1083 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1085 - function set_locator_class($class = 'SimplePie_Locator')
1087 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Locator'))
1089 - $this->locator_class = $class;
1096 - * Allows you to change which class SimplePie uses for XML parsing.
1097 - * Useful when you are overloading or extending SimplePie's default classes.
1100 - * @param string $class Name of custom class.
1101 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1102 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1104 - function set_parser_class($class = 'SimplePie_Parser')
1106 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Parser'))
1108 - $this->parser_class = $class;
1115 - * Allows you to change which class SimplePie uses for remote file fetching.
1116 - * Useful when you are overloading or extending SimplePie's default classes.
1119 - * @param string $class Name of custom class.
1120 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1121 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1123 - function set_file_class($class = 'SimplePie_File')
1125 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_File'))
1127 - $this->file_class = $class;
1134 - * Allows you to change which class SimplePie uses for data sanitization.
1135 - * Useful when you are overloading or extending SimplePie's default classes.
1138 - * @param string $class Name of custom class.
1139 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1140 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1142 - function set_sanitize_class($class = 'SimplePie_Sanitize')
1144 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Sanitize'))
1146 - $this->sanitize = new $class;
1147 - $this->sanitize->proxy = $this->proxy;
1154 - * Allows you to change which class SimplePie uses for handling feed items.
1155 - * Useful when you are overloading or extending SimplePie's default classes.
1158 - * @param string $class Name of custom class.
1159 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1160 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1162 - function set_item_class($class = 'SimplePie_Item')
1164 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Item'))
1166 - $this->item_class = $class;
1173 - * Allows you to change which class SimplePie uses for handling author data.
1174 - * Useful when you are overloading or extending SimplePie's default classes.
1177 - * @param string $class Name of custom class.
1178 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1179 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1181 - function set_author_class($class = 'SimplePie_Author')
1183 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Author'))
1185 - $this->author_class = $class;
1192 - * Allows you to change which class SimplePie uses for handling category data.
1193 - * Useful when you are overloading or extending SimplePie's default classes.
1196 - * @param string $class Name of custom class.
1197 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1198 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1200 - function set_category_class($class = 'SimplePie_Category')
1202 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Category'))
1204 - $this->category_class = $class;
1211 - * Allows you to change which class SimplePie uses for feed enclosures.
1212 - * Useful when you are overloading or extending SimplePie's default classes.
1215 - * @param string $class Name of custom class.
1216 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1217 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1219 - function set_enclosure_class($class = 'SimplePie_Enclosure')
1221 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Enclosure'))
1223 - $this->enclosure_class = $class;
1230 - * Allows you to change which class SimplePie uses for <media:text> captions
1231 - * Useful when you are overloading or extending SimplePie's default classes.
1234 - * @param string $class Name of custom class.
1235 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1236 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1238 - function set_caption_class($class = 'SimplePie_Caption')
1240 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Caption'))
1242 - $this->caption_class = $class;
1249 - * Allows you to change which class SimplePie uses for <media:copyright>
1250 - * Useful when you are overloading or extending SimplePie's default classes.
1253 - * @param string $class Name of custom class.
1254 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1255 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1257 - function set_copyright_class($class = 'SimplePie_Copyright')
1259 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Copyright'))
1261 - $this->copyright_class = $class;
1268 - * Allows you to change which class SimplePie uses for <media:credit>
1269 - * Useful when you are overloading or extending SimplePie's default classes.
1272 - * @param string $class Name of custom class.
1273 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1274 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1276 - function set_credit_class($class = 'SimplePie_Credit')
1278 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Credit'))
1280 - $this->credit_class = $class;
1287 - * Allows you to change which class SimplePie uses for <media:rating>
1288 - * Useful when you are overloading or extending SimplePie's default classes.
1291 - * @param string $class Name of custom class.
1292 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1293 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1295 - function set_rating_class($class = 'SimplePie_Rating')
1297 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Rating'))
1299 - $this->rating_class = $class;
1306 - * Allows you to change which class SimplePie uses for <media:restriction>
1307 - * Useful when you are overloading or extending SimplePie's default classes.
1310 - * @param string $class Name of custom class.
1311 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1312 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1314 - function set_restriction_class($class = 'SimplePie_Restriction')
1316 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Restriction'))
1318 - $this->restriction_class = $class;
1325 - * Allows you to change which class SimplePie uses for content-type sniffing.
1326 - * Useful when you are overloading or extending SimplePie's default classes.
1329 - * @param string $class Name of custom class.
1330 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1331 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1333 - function set_content_type_sniffer_class($class = 'SimplePie_Content_Type_Sniffer')
1335 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Content_Type_Sniffer'))
1337 - $this->content_type_sniffer_class = $class;
1344 - * Allows you to change which class SimplePie uses item sources.
1345 - * Useful when you are overloading or extending SimplePie's default classes.
1348 - * @param string $class Name of custom class.
1349 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1350 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1352 - function set_source_class($class = 'SimplePie_Source')
1354 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Source'))
1356 - $this->source_class = $class;
1363 - * Allows you to override the default user agent string.
1366 - * @param string $ua New user agent string.
1368 - function set_useragent($ua = SIMPLEPIE_USERAGENT)
1370 - $this->useragent = (string) $ua;
1374 - * Set callback function to create cache filename with
1377 - * @param mixed $function Callback function
1379 - function set_cache_name_function($function = 'md5')
1381 - if (is_callable($function))
1383 - $this->cache_name_function = $function;
1388 - * Set javascript query string parameter
1391 - * @param mixed $get Javascript query string parameter
1393 - function set_javascript($get = 'js')
1397 - $this->javascript = (string) $get;
1401 - $this->javascript = false;
1406 - * Set options to make SP as fast as possible. Forgoes a
1407 - * substantial amount of data sanitization in favor of speed.
1410 - * @param bool $set Whether to set them or not
1412 - function set_stupidly_fast($set = false)
1416 - $this->enable_order_by_date(false);
1417 - $this->remove_div(false);
1418 - $this->strip_comments(false);
1419 - $this->strip_htmltags(false);
1420 - $this->strip_attributes(false);
1421 - $this->set_image_handler(false);
1426 - * Set maximum number of feeds to check with autodiscovery
1429 - * @param int $max Maximum number of feeds to check
1431 - function set_max_checked_feeds($max = 10)
1433 - $this->max_checked_feeds = (int) $max;
1436 - function remove_div($enable = true)
1438 - $this->sanitize->remove_div($enable);
1441 - function strip_htmltags($tags = '', $encode = null)
1445 - $tags = $this->strip_htmltags;
1447 - $this->sanitize->strip_htmltags($tags);
1448 - if ($encode !== null)
1450 - $this->sanitize->encode_instead_of_strip($tags);
1454 - function encode_instead_of_strip($enable = true)
1456 - $this->sanitize->encode_instead_of_strip($enable);
1459 - function strip_attributes($attribs = '')
1461 - if ($attribs === '')
1463 - $attribs = $this->strip_attributes;
1465 - $this->sanitize->strip_attributes($attribs);
1468 - function set_output_encoding($encoding = 'UTF-8')
1470 - $this->sanitize->set_output_encoding($encoding);
1473 - function strip_comments($strip = false)
1475 - $this->sanitize->strip_comments($strip);
1479 - * Set element/attribute key/value pairs of HTML attributes
1480 - * containing URLs that need to be resolved relative to the feed
1484 - * @param array $element_attribute Element/attribute key/value pairs
1486 - function set_url_replacements($element_attribute = array('a' => 'href', 'area' => 'href', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite'))
1488 - $this->sanitize->set_url_replacements($element_attribute);
1492 - * Set the handler to enable the display of cached favicons.
1495 - * @param str $page Web-accessible path to the handler_favicon.php file.
1496 - * @param str $qs The query string that the value should be passed to.
1498 - function set_favicon_handler($page = false, $qs = 'i')
1500 - if ($page != false)
1502 - $this->favicon_handler = $page . '?' . $qs . '=';
1506 - $this->favicon_handler = '';
1511 - * Set the handler to enable the display of cached images.
1514 - * @param str $page Web-accessible path to the handler_image.php file.
1515 - * @param str $qs The query string that the value should be passed to.
1517 - function set_image_handler($page = false, $qs = 'i')
1519 - if ($page != false)
1521 - $this->sanitize->set_image_handler($page . '?' . $qs . '=');
1525 - $this->image_handler = '';
1530 - * Set the limit for items returned per-feed with multifeeds.
1533 - * @param integer $limit The maximum number of items to return.
1535 - function set_item_limit($limit = 0)
1537 - $this->item_limit = (int) $limit;
1542 - if ((function_exists('version_compare') && version_compare(PHP_VERSION, '4.3.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre'))
1546 - if (isset($_GET[$this->javascript]))
1548 - if (function_exists('ob_gzhandler'))
1550 - ob_start('ob_gzhandler');
1552 - header('Content-type: text/javascript; charset: UTF-8');
1553 - header('Cache-Control: must-revalidate');
1554 - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
1556 -function embed_odeo(link) {
1557 - 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>');
1560 -function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
1561 - if (placeholder != '') {
1562 - 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>');
1565 - 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>');
1569 -function embed_flash(bgcolor, width, height, link, loop, type) {
1570 - 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>');
1573 -function embed_flv(width, height, link, placeholder, loop, player) {
1574 - 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>');
1577 -function embed_wmedia(width, height, link) {
1578 - document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
1584 - // Pass whatever was set with config options over to the sanitizer.
1585 - $this->sanitize->pass_cache_data($this->cache, $this->cache_location, $this->cache_name_function, $this->cache_class);
1586 - $this->sanitize->pass_file_data($this->file_class, $this->timeout, $this->useragent, $this->force_fsockopen);
1588 - if ($this->feed_url !== null || $this->raw_data !== null)
1590 - $this->data = array();
1591 - $this->multifeed_objects = array();
1594 - if ($this->feed_url !== null)
1596 - $parsed_feed_url = SimplePie_Misc::parse_url($this->feed_url);
1597 - // Decide whether to enable caching
1598 - if ($this->cache && $parsed_feed_url['scheme'] !== '')
1600 - $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc');
1602 - // If it's enabled and we don't want an XML dump, use the cache
1603 - if ($cache && !$this->xml_dump)
1606 - $this->data = $cache->load();
1607 - if (!empty($this->data))
1609 - // If the cache is for an outdated build of SimplePie
1610 - if (!isset($this->data['build']) || $this->data['build'] != SIMPLEPIE_BUILD)
1613 - $this->data = array();
1615 - // If we've hit a collision just rerun it with caching disabled
1616 - elseif (isset($this->data['url']) && $this->data['url'] != $this->feed_url)
1619 - $this->data = array();
1621 - // If we've got a non feed_url stored (if the page isn't actually a feed, or is a redirect) use that URL.
1622 - elseif (isset($this->data['feed_url']))
1624 - // If the autodiscovery cache is still valid use it.
1625 - if ($cache->mtime() + $this->autodiscovery_cache_duration > time())
1627 - // Do not need to do feed autodiscovery yet.
1628 - if ($this->data['feed_url'] == $this->data['url'])
1631 - $this->data = array();
1635 - $this->set_feed_url($this->data['feed_url']);
1636 - return $this->init();
1640 - // Check if the cache has been updated
1641 - elseif ($cache->mtime() + $this->cache_duration < time())
1643 - // If we have last-modified and/or etag set
1644 - if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag']))
1646 - $headers = array();
1647 - if (isset($this->data['headers']['last-modified']))
1649 - $headers['if-modified-since'] = $this->data['headers']['last-modified'];
1651 - if (isset($this->data['headers']['etag']))
1653 - $headers['if-none-match'] = '"' . $this->data['headers']['etag'] . '"';
1655 - $file = new $this->file_class($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen, $this->proxy);
1656 - if ($file->success)
1658 - if ($file->status_code == 304)
1665 - $headers = $file->headers;
1674 - // If the cache is still valid, just return true
1680 - // If the cache is empty, delete it
1684 - $this->data = array();
1687 - // 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.
1688 - if (!isset($file))
1690 - if (is_a($this->file, 'SimplePie_File') && $this->file->url == $this->feed_url)
1692 - $file =& $this->file;
1696 - $file = new $this->file_class($this->feed_url, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen, $this->proxy);
1699 - // If the file connection has an error, set SimplePie::error to that and quit
1700 - if (!$file->success)
1702 - $this->error = $file->error;
1703 - if (!empty($this->data))
1713 - if (!$this->force_feed)
1715 - // Check if the supplied URL is a feed, if it isn't, look for it.
1716 - $locate = new $this->locator_class($file, $this->timeout, $this->useragent, $this->file_class, $this->max_checked_feeds, $this->content_type_sniffer_class);
1717 - if (!$locate->is_feed($file))
1719 - // We need to unset this so that if SimplePie::set_file() has been called that object is untouched
1721 - if ($file = $locate->find($this->autodiscovery))
1725 - $this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
1726 - if (!$cache->save($this))
1728 - trigger_error("$cache->name is not writeable", E_USER_WARNING);
1730 - $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc');
1732 - $this->feed_url = $file->url;
1736 - $this->error = "A feed could not be found at $this->feed_url";
1737 - SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
1744 - $headers = $file->headers;
1745 - $data = $file->body;
1746 - $sniffer = new $this->content_type_sniffer_class($file);
1747 - $sniffed = $sniffer->get_type();
1751 - $data = $this->raw_data;
1754 - // Set up array of possible encodings
1755 - $encodings = array();
1757 - // First check to see if input has been overridden.
1758 - if ($this->input_encoding !== false)
1760 - $encodings[] = $this->input_encoding;
1763 - $application_types = array('application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity');
1764 - $text_types = array('text/xml', 'text/xml-external-parsed-entity');
1766 - // RFC 3023 (only applies to sniffed content)
1767 - if (isset($sniffed))
1769 - if (in_array($sniffed, $application_types) || substr($sniffed, 0, 12) === 'application/' && substr($sniffed, -4) === '+xml')
1771 - if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset))
1773 - $encodings[] = strtoupper($charset[1]);
1775 - $encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data));
1776 - $encodings[] = 'UTF-8';
1778 - elseif (in_array($sniffed, $text_types) || substr($sniffed, 0, 5) === 'text/' && substr($sniffed, -4) === '+xml')
1780 - if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset))
1782 - $encodings[] = $charset[1];
1784 - $encodings[] = 'US-ASCII';
1786 - // Text MIME-type default
1787 - elseif (substr($sniffed, 0, 5) === 'text/')
1789 - $encodings[] = 'US-ASCII';
1793 - // Fallback to XML 1.0 Appendix F.1/UTF-8/ISO-8859-1
1794 - $encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data));
1795 - $encodings[] = 'UTF-8';
1796 - $encodings[] = 'ISO-8859-1';
1798 - // There's no point in trying an encoding twice
1799 - $encodings = array_unique($encodings);
1801 - // If we want the XML, just output that with the most likely encoding and quit
1802 - if ($this->xml_dump)
1804 - header('Content-type: text/xml; charset=' . $encodings[0]);
1809 - // Loop through each possible encoding, till we return something, or run out of possibilities
1810 - foreach ($encodings as $encoding)
1812 - // Change the encoding to UTF-8 (as we always use UTF-8 internally)
1813 - if ($utf8_data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8'))
1815 - // Create new parser
1816 - $parser = new $this->parser_class();
1818 - // If it's parsed fine
1819 - if ($parser->parse($utf8_data, 'UTF-8'))
1821 - $this->data = $parser->get_data();
1822 - if ($this->get_type() & ~SIMPLEPIE_TYPE_NONE)
1824 - if (isset($headers))
1826 - $this->data['headers'] = $headers;
1828 - $this->data['build'] = SIMPLEPIE_BUILD;
1830 - // Cache the file if caching is enabled
1831 - if ($cache && !$cache->save($this))
1833 - trigger_error("$cache->name is not writeable", E_USER_WARNING);
1839 - $this->error = "A feed could not be found at $this->feed_url";
1840 - SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
1846 - // We have an error, just set SimplePie::error to it and quit
1847 - $this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
1848 - SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
1851 - elseif (!empty($this->multifeed_url))
1855 - $this->multifeed_objects = array();
1856 - foreach ($this->multifeed_url as $url)
1858 - if (SIMPLEPIE_PHP5)
1860 - // This keyword needs to defy coding standards for PHP4 compatibility
1861 - $this->multifeed_objects[$i] = clone($this);
1865 - $this->multifeed_objects[$i] = $this;
1867 - $this->multifeed_objects[$i]->set_feed_url($url);
1868 - $success |= $this->multifeed_objects[$i]->init();
1871 - return (bool) $success;
1880 - * Return the error message for the occured error
1883 - * @return string Error message
1887 - return $this->error;
1890 - function get_encoding()
1892 - return $this->sanitize->output_encoding;
1895 - function handle_content_type($mime = 'text/html')
1897 - if (!headers_sent())
1899 - $header = "Content-type: $mime;";
1900 - if ($this->get_encoding())
1902 - $header .= ' charset=' . $this->get_encoding();
1906 - $header .= ' charset=UTF-8';
1912 - function get_type()
1914 - if (!isset($this->data['type']))
1916 - $this->data['type'] = SIMPLEPIE_TYPE_ALL;
1917 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed']))
1919 - $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_10;
1921 - elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed']))
1923 - $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_03;
1925 - elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF']))
1927 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['channel'])
1928 - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['image'])
1929 - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item'])
1930 - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['textinput']))
1932 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_10;
1934 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['channel'])
1935 - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['image'])
1936 - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item'])
1937 - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['textinput']))
1939 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_090;
1942 - elseif (isset($this->data['child']['']['rss']))
1944 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_ALL;
1945 - if (isset($this->data['child']['']['rss'][0]['attribs']['']['version']))
1947 - switch (trim($this->data['child']['']['rss'][0]['attribs']['']['version']))
1950 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091;
1951 - if (isset($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data']))
1953 - switch (trim($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data']))
1956 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE;
1960 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_USERLAND;
1967 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_092;
1971 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_093;
1975 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_094;
1979 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_20;
1986 - $this->data['type'] = SIMPLEPIE_TYPE_NONE;
1989 - return $this->data['type'];
1993 - * Returns the URL for the favicon of the feed's website.
1995 - * @todo Cache atom:icon
1999 - function get_favicon()
2001 - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
2003 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2005 - elseif (($url = $this->get_link()) !== null && preg_match('/^http(s)?:\/\//i', $url))
2007 - $favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $url);
2009 - if ($this->cache && $this->favicon_handler)
2011 - $favicon_filename = call_user_func($this->cache_name_function, $favicon);
2012 - $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, $favicon_filename, 'spi');
2014 - if ($cache->load())
2016 - return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI);
2020 - $file = new $this->file_class($favicon, $this->timeout / 10, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen, $this->proxy);
2022 - if ($file->success && ($file->status_code == 200 || ($file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0)
2024 - $sniffer = new $this->content_type_sniffer_class($file);
2025 - if (substr($sniffer->get_type(), 0, 6) === 'image/')
2027 - if ($cache->save(array('headers' => $file->headers, 'body' => $file->body)))
2029 - return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI);
2033 - trigger_error("$cache->name is not writeable", E_USER_WARNING);
2034 - return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
2042 - return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
2049 - * @todo If we have a perm redirect we should return the new URL
2050 - * @todo When we make the above change, let's support <itunes:new-feed-url> as well
2051 - * @todo Also, |atom:link|@rel=self
2053 - function subscribe_url()
2055 - if ($this->feed_url !== null)
2057 - return $this->sanitize($this->feed_url, SIMPLEPIE_CONSTRUCT_IRI);
2065 - function subscribe_feed()
2067 - if ($this->feed_url !== null)
2069 - return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI);
2077 - function subscribe_outlook()
2079 - if ($this->feed_url !== null)
2081 - return 'outlook' . $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI);
2089 - function subscribe_podcast()
2091 - if ($this->feed_url !== null)
2093 - return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 3), SIMPLEPIE_CONSTRUCT_IRI);
2101 - function subscribe_itunes()
2103 - if ($this->feed_url !== null)
2105 - return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 4), SIMPLEPIE_CONSTRUCT_IRI);
2114 - * Creates the subscribe_* methods' return data
2117 - * @param string $feed_url String to prefix to the feed URL
2118 - * @param string $site_url String to prefix to the site URL (and
2119 - * suffix to the feed URL)
2120 - * @return mixed URL if feed exists, false otherwise
2122 - function subscribe_service($feed_url, $site_url = null)
2124 - if ($this->subscribe_url())
2126 - $return = $this->sanitize($feed_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->feed_url);
2127 - if ($site_url !== null && $this->get_link() !== null)
2129 - $return .= $this->sanitize($site_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_link());
2139 - function subscribe_aol()
2141 - return $this->subscribe_service('http://feeds.my.aol.com/add.jsp?url=');
2144 - function subscribe_bloglines()
2146 - return urldecode($this->subscribe_service('http://www.bloglines.com/sub/'));
2149 - function subscribe_eskobo()
2151 - return $this->subscribe_service('http://www.eskobo.com/?AddToMyPage=');
2154 - function subscribe_feedfeeds()
2156 - return $this->subscribe_service('http://www.feedfeeds.com/add?feed=');
2159 - function subscribe_feedster()
2161 - return $this->subscribe_service('http://www.feedster.com/myfeedster.php?action=addrss&confirm=no&rssurl=');
2164 - function subscribe_google()
2166 - return $this->subscribe_service('http://fusion.google.com/add?feedurl=');
2169 - function subscribe_gritwire()
2171 - return $this->subscribe_service('http://my.gritwire.com/feeds/addExternalFeed.aspx?FeedUrl=');
2174 - function subscribe_msn()
2176 - return $this->subscribe_service('http://my.msn.com/addtomymsn.armx?id=rss&ut=', '&ru=');
2179 - function subscribe_netvibes()
2181 - return $this->subscribe_service('http://www.netvibes.com/subscribe.php?url=');
2184 - function subscribe_newsburst()
2186 - return $this->subscribe_service('http://www.newsburst.com/Source/?add=');
2189 - function subscribe_newsgator()
2191 - return $this->subscribe_service('http://www.newsgator.com/ngs/subscriber/subext.aspx?url=');
2194 - function subscribe_odeo()
2196 - return $this->subscribe_service('http://www.odeo.com/listen/subscribe?feed=');
2199 - function subscribe_podnova()
2201 - return $this->subscribe_service('http://www.podnova.com/index_your_podcasts.srf?action=add&url=');
2204 - function subscribe_rojo()
2206 - return $this->subscribe_service('http://www.rojo.com/add-subscription?resource=');
2209 - function subscribe_yahoo()
2211 - return $this->subscribe_service('http://add.my.yahoo.com/rss?url=');
2214 - function get_feed_tags($namespace, $tag)
2216 - $type = $this->get_type();
2217 - if ($type & SIMPLEPIE_TYPE_ATOM_10)
2219 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag]))
2221 - return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag];
2224 - if ($type & SIMPLEPIE_TYPE_ATOM_03)
2226 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag]))
2228 - return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag];
2231 - if ($type & SIMPLEPIE_TYPE_RSS_RDF)
2233 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag]))
2235 - return $this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag];
2238 - if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
2240 - if (isset($this->data['child']['']['rss'][0]['child'][$namespace][$tag]))
2242 - return $this->data['child']['']['rss'][0]['child'][$namespace][$tag];
2248 - function get_channel_tags($namespace, $tag)
2250 - $type = $this->get_type();
2251 - if ($type & SIMPLEPIE_TYPE_ATOM_ALL)
2253 - if ($return = $this->get_feed_tags($namespace, $tag))
2258 - if ($type & SIMPLEPIE_TYPE_RSS_10)
2260 - if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'channel'))
2262 - if (isset($channel[0]['child'][$namespace][$tag]))
2264 - return $channel[0]['child'][$namespace][$tag];
2268 - if ($type & SIMPLEPIE_TYPE_RSS_090)
2270 - if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'channel'))
2272 - if (isset($channel[0]['child'][$namespace][$tag]))
2274 - return $channel[0]['child'][$namespace][$tag];
2278 - if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
2280 - if ($channel = $this->get_feed_tags('', 'channel'))
2282 - if (isset($channel[0]['child'][$namespace][$tag]))
2284 - return $channel[0]['child'][$namespace][$tag];
2291 - function get_image_tags($namespace, $tag)
2293 - $type = $this->get_type();
2294 - if ($type & SIMPLEPIE_TYPE_RSS_10)
2296 - if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'image'))
2298 - if (isset($image[0]['child'][$namespace][$tag]))
2300 - return $image[0]['child'][$namespace][$tag];
2304 - if ($type & SIMPLEPIE_TYPE_RSS_090)
2306 - if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'image'))
2308 - if (isset($image[0]['child'][$namespace][$tag]))
2310 - return $image[0]['child'][$namespace][$tag];
2314 - if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
2316 - if ($image = $this->get_channel_tags('', 'image'))
2318 - if (isset($image[0]['child'][$namespace][$tag]))
2320 - return $image[0]['child'][$namespace][$tag];
2327 - function get_base($element = array())
2329 - if (!($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION) && !empty($element['xml_base_explicit']) && isset($element['xml_base']))
2331 - return $element['xml_base'];
2333 - elseif ($this->get_link() !== null)
2335 - return $this->get_link();
2339 - return $this->subscribe_url();
2343 - function sanitize($data, $type, $base = '')
2345 - return $this->sanitize->sanitize($data, $type, $base);
2348 - function get_title()
2350 - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
2352 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2354 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
2356 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2358 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
2360 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2362 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
2364 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2366 - elseif ($return = $this->get_channel_tags('', 'title'))
2368 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2370 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
2372 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2374 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
2376 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2384 - function get_category($key = 0)
2386 - $categories = $this->get_categories();
2387 - if (isset($categories[$key]))
2389 - return $categories[$key];
2397 - function get_categories()
2399 - $categories = array();
2401 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
2406 - if (isset($category['attribs']['']['term']))
2408 - $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
2410 - if (isset($category['attribs']['']['scheme']))
2412 - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2414 - if (isset($category['attribs']['']['label']))
2416 - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
2418 - $categories[] = new $this->category_class($term, $scheme, $label);
2420 - foreach ((array) $this->get_channel_tags('', 'category') as $category)
2422 - $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2424 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
2426 - $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2428 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
2430 - $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2433 - if (!empty($categories))
2435 - return SimplePie_Misc::array_unique($categories);
2443 - function get_author($key = 0)
2445 - $authors = $this->get_authors();
2446 - if (isset($authors[$key]))
2448 - return $authors[$key];
2456 - function get_authors()
2458 - $authors = array();
2459 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
2464 - if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
2466 - $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2468 - if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
2470 - $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
2472 - if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
2474 - $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2476 - if ($name !== null || $email !== null || $uri !== null)
2478 - $authors[] = new $this->author_class($name, $uri, $email);
2481 - if ($author = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
2486 - if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
2488 - $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2490 - if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
2492 - $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
2494 - if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
2496 - $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2498 - if ($name !== null || $email !== null || $url !== null)
2500 - $authors[] = new $this->author_class($name, $url, $email);
2503 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
2505 - $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2507 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
2509 - $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2511 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
2513 - $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2516 - if (!empty($authors))
2518 - return SimplePie_Misc::array_unique($authors);
2526 - function get_contributor($key = 0)
2528 - $contributors = $this->get_contributors();
2529 - if (isset($contributors[$key]))
2531 - return $contributors[$key];
2539 - function get_contributors()
2541 - $contributors = array();
2542 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
2547 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
2549 - $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2551 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
2553 - $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
2555 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
2557 - $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2559 - if ($name !== null || $email !== null || $uri !== null)
2561 - $contributors[] = new $this->author_class($name, $uri, $email);
2564 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
2569 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
2571 - $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2573 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
2575 - $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
2577 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
2579 - $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2581 - if ($name !== null || $email !== null || $url !== null)
2583 - $contributors[] = new $this->author_class($name, $url, $email);
2587 - if (!empty($contributors))
2589 - return SimplePie_Misc::array_unique($contributors);
2597 - function get_link($key = 0, $rel = 'alternate')
2599 - $links = $this->get_links($rel);
2600 - if (isset($links[$key]))
2602 - return $links[$key];
2611 - * Added for parity between the parent-level and the item/entry-level.
2613 - function get_permalink()
2615 - return $this->get_link(0);
2618 - function get_links($rel = 'alternate')
2620 - if (!isset($this->data['links']))
2622 - $this->data['links'] = array();
2623 - if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link'))
2625 - foreach ($links as $link)
2627 - if (isset($link['attribs']['']['href']))
2629 - $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
2630 - $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
2634 - if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link'))
2636 - foreach ($links as $link)
2638 - if (isset($link['attribs']['']['href']))
2640 - $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
2641 - $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
2646 - if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
2648 - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2650 - if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
2652 - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2654 - if ($links = $this->get_channel_tags('', 'link'))
2656 - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2659 - $keys = array_keys($this->data['links']);
2660 - foreach ($keys as $key)
2662 - if (SimplePie_Misc::is_isegment_nz_nc($key))
2664 - if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
2666 - $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
2667 - $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
2671 - $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
2674 - elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
2676 - $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
2678 - $this->data['links'][$key] = array_unique($this->data['links'][$key]);
2682 - if (isset($this->data['links'][$rel]))
2684 - return $this->data['links'][$rel];
2692 - function get_description()
2694 - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle'))
2696 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2698 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline'))
2700 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2702 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
2704 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2706 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
2708 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2710 - elseif ($return = $this->get_channel_tags('', 'description'))
2712 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2714 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
2716 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2718 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
2720 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2722 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
2724 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
2726 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
2728 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
2736 - function get_copyright()
2738 - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
2740 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2742 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright'))
2744 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2746 - elseif ($return = $this->get_channel_tags('', 'copyright'))
2748 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2750 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
2752 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2754 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
2756 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2764 - function get_language()
2766 - if ($return = $this->get_channel_tags('', 'language'))
2768 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2770 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language'))
2772 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2774 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language'))
2776 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2778 - elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang']))
2780 - return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
2782 - elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang']))
2784 - return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
2786 - elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang']))
2788 - return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
2790 - elseif (isset($this->data['headers']['content-language']))
2792 - return $this->sanitize($this->data['headers']['content-language'], SIMPLEPIE_CONSTRUCT_TEXT);
2800 - function get_latitude()
2802 - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
2804 - return (float) $return[0]['data'];
2806 - elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
2808 - return (float) $match[1];
2816 - function get_longitude()
2818 - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
2820 - return (float) $return[0]['data'];
2822 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
2824 - return (float) $return[0]['data'];
2826 - elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
2828 - return (float) $match[2];
2836 - function get_image_title()
2838 - if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
2840 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2842 - elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
2844 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2846 - elseif ($return = $this->get_image_tags('', 'title'))
2848 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2850 - elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
2852 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2854 - elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
2856 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2864 - function get_image_url()
2866 - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image'))
2868 - return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI);
2870 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo'))
2872 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2874 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
2876 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2878 - elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'url'))
2880 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2882 - elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'url'))
2884 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2886 - elseif ($return = $this->get_image_tags('', 'url'))
2888 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2896 - function get_image_link()
2898 - if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
2900 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2902 - elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
2904 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2906 - elseif ($return = $this->get_image_tags('', 'link'))
2908 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2916 - function get_image_width()
2918 - if ($return = $this->get_image_tags('', 'width'))
2920 - return round($return[0]['data']);
2922 - elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('', 'url'))
2932 - function get_image_height()
2934 - if ($return = $this->get_image_tags('', 'height'))
2936 - return round($return[0]['data']);
2938 - elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('', 'url'))
2948 - function get_item_quantity($max = 0)
2950 - $qty = count($this->get_items());
2957 - return ($qty > $max) ? $max : $qty;
2961 - function get_item($key = 0)
2963 - $items = $this->get_items();
2964 - if (isset($items[$key]))
2966 - return $items[$key];
2974 - function get_items($start = 0, $end = 0)
2976 - if (!empty($this->multifeed_objects))
2978 - return SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit);
2980 - elseif (!isset($this->data['items']))
2982 - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry'))
2984 - $keys = array_keys($items);
2985 - foreach ($keys as $key)
2987 - $this->data['items'][] = new $this->item_class($this, $items[$key]);
2990 - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry'))
2992 - $keys = array_keys($items);
2993 - foreach ($keys as $key)
2995 - $this->data['items'][] = new $this->item_class($this, $items[$key]);
2998 - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item'))
3000 - $keys = array_keys($items);
3001 - foreach ($keys as $key)
3003 - $this->data['items'][] = new $this->item_class($this, $items[$key]);
3006 - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item'))
3008 - $keys = array_keys($items);
3009 - foreach ($keys as $key)
3011 - $this->data['items'][] = new $this->item_class($this, $items[$key]);
3014 - if ($items = $this->get_channel_tags('', 'item'))
3016 - $keys = array_keys($items);
3017 - foreach ($keys as $key)
3019 - $this->data['items'][] = new $this->item_class($this, $items[$key]);
3024 - if (!empty($this->data['items']))
3026 - // If we want to order it by date, check if all items have a date, and then sort it
3027 - if ($this->order_by_date)
3029 - if (!isset($this->data['ordered_items']))
3032 - foreach ($this->data['items'] as $item)
3034 - if (!$item->get_date('U'))
3041 - $this->data['ordered_items'] = $this->data['items'];
3044 - usort($this->data['ordered_items'], array(&$this, 'sort_items'));
3047 - $items = $this->data['ordered_items'];
3051 - $items = $this->data['items'];
3054 - // Slice the data as desired
3057 - return array_slice($items, $start);
3061 - return array_slice($items, $start, $end);
3070 - function sort_items($a, $b)
3072 - return $a->get_date('U') <= $b->get_date('U');
3075 - function merge_items($urls, $start = 0, $end = 0, $limit = 0)
3077 - if (is_array($urls) && sizeof($urls) > 0)
3080 - foreach ($urls as $arg)
3082 - if (is_a($arg, 'SimplePie'))
3084 - $items = array_merge($items, $arg->get_items(0, $limit));
3088 - trigger_error('Arguments must be SimplePie objects', E_USER_WARNING);
3093 - foreach ($items as $item)
3095 - if (!$item->get_date('U'))
3104 - usort($items, array('SimplePie', 'sort_items'));
3109 - return array_slice($items, $start);
3113 - return array_slice($items, $start, $end);
3118 - trigger_error('Cannot merge zero SimplePie objects', E_USER_WARNING);
3124 -class SimplePie_Item
3127 - var $data = array();
3129 - function SimplePie_Item($feed, $data)
3131 - $this->feed = $feed;
3132 - $this->data = $data;
3135 - function __toString()
3137 - return md5(serialize($this->data));
3141 - * Remove items that link back to this before destroying this object
3143 - function __destruct()
3145 - unset($this->feed);
3148 - function get_item_tags($namespace, $tag)
3150 - if (isset($this->data['child'][$namespace][$tag]))
3152 - return $this->data['child'][$namespace][$tag];
3160 - function get_base($element = array())
3162 - return $this->feed->get_base($element);
3165 - function sanitize($data, $type, $base = '')
3167 - return $this->feed->sanitize($data, $type, $base);
3170 - function get_feed()
3172 - return $this->feed;
3175 - function get_id($hash = false)
3179 - if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id'))
3181 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3183 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id'))
3185 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3187 - elseif ($return = $this->get_item_tags('', 'guid'))
3189 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3191 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier'))
3193 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3195 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier'))
3197 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3199 - elseif (($return = $this->get_permalink()) !== null)
3203 - elseif (($return = $this->get_title()) !== null)
3208 - if ($this->get_permalink() !== null || $this->get_title() !== null)
3210 - return md5($this->get_permalink() . $this->get_title());
3214 - return md5(serialize($this->data));
3218 - function get_title()
3220 - if (!isset($this->data['title']))
3222 - if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
3224 - $this->data['title'] = $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3226 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
3228 - $this->data['title'] = $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3230 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
3232 - $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
3234 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
3236 - $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
3238 - elseif ($return = $this->get_item_tags('', 'title'))
3240 - $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
3242 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
3244 - $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3246 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
3248 - $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3252 - $this->data['title'] = null;
3255 - return $this->data['title'];
3258 - function get_description($description_only = false)
3260 - if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary'))
3262 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3264 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary'))
3266 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3268 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
3270 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
3272 - elseif ($return = $this->get_item_tags('', 'description'))
3274 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
3276 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
3278 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3280 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
3282 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3284 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
3286 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
3288 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
3290 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3292 - elseif (!$description_only)
3294 - return $this->get_content(true);
3302 - function get_content($content_only = false)
3304 - if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content'))
3306 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_content_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3308 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content'))
3310 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3312 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded'))
3314 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
3316 - elseif (!$content_only)
3318 - return $this->get_description(true);
3326 - function get_category($key = 0)
3328 - $categories = $this->get_categories();
3329 - if (isset($categories[$key]))
3331 - return $categories[$key];
3339 - function get_categories()
3341 - $categories = array();
3343 - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
3348 - if (isset($category['attribs']['']['term']))
3350 - $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
3352 - if (isset($category['attribs']['']['scheme']))
3354 - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
3356 - if (isset($category['attribs']['']['label']))
3358 - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
3360 - $categories[] = new $this->feed->category_class($term, $scheme, $label);
3362 - foreach ((array) $this->get_item_tags('', 'category') as $category)
3364 - $categories[] = new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
3366 - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
3368 - $categories[] = new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
3370 - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
3372 - $categories[] = new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
3375 - if (!empty($categories))
3377 - return SimplePie_Misc::array_unique($categories);
3385 - function get_author($key = 0)
3387 - $authors = $this->get_authors();
3388 - if (isset($authors[$key]))
3390 - return $authors[$key];
3398 - function get_contributor($key = 0)
3400 - $contributors = $this->get_contributors();
3401 - if (isset($contributors[$key]))
3403 - return $contributors[$key];
3411 - function get_contributors()
3413 - $contributors = array();
3414 - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
3419 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
3421 - $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3423 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
3425 - $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
3427 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
3429 - $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3431 - if ($name !== null || $email !== null || $uri !== null)
3433 - $contributors[] = new $this->feed->author_class($name, $uri, $email);
3436 - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
3441 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
3443 - $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3445 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
3447 - $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
3449 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
3451 - $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3453 - if ($name !== null || $email !== null || $url !== null)
3455 - $contributors[] = new $this->feed->author_class($name, $url, $email);
3459 - if (!empty($contributors))
3461 - return SimplePie_Misc::array_unique($contributors);
3470 - * @todo Atom inheritance (item author, source author, feed author)
3472 - function get_authors()
3474 - $authors = array();
3475 - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
3480 - if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
3482 - $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3484 - if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
3486 - $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
3488 - if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
3490 - $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3492 - if ($name !== null || $email !== null || $uri !== null)
3494 - $authors[] = new $this->feed->author_class($name, $uri, $email);
3497 - if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
3502 - if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
3504 - $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3506 - if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
3508 - $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
3510 - if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
3512 - $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3514 - if ($name !== null || $email !== null || $url !== null)
3516 - $authors[] = new $this->feed->author_class($name, $url, $email);
3519 - if ($author = $this->get_item_tags('', 'author'))
3521 - $authors[] = new $this->feed->author_class(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
3523 - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
3525 - $authors[] = new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
3527 - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
3529 - $authors[] = new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
3531 - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
3533 - $authors[] = new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
3536 - if (!empty($authors))
3538 - return SimplePie_Misc::array_unique($authors);
3540 - elseif (($source = $this->get_source()) && ($authors = $source->get_authors()))
3544 - elseif ($authors = $this->feed->get_authors())
3554 - function get_copyright()
3556 - if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
3558 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3560 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
3562 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3564 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
3566 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3574 - function get_date($date_format = 'j F Y, g:i a')
3576 - if (!isset($this->data['date']))
3578 - if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published'))
3580 - $this->data['date']['raw'] = $return[0]['data'];
3582 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated'))
3584 - $this->data['date']['raw'] = $return[0]['data'];
3586 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued'))
3588 - $this->data['date']['raw'] = $return[0]['data'];
3590 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created'))
3592 - $this->data['date']['raw'] = $return[0]['data'];
3594 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified'))
3596 - $this->data['date']['raw'] = $return[0]['data'];
3598 - elseif ($return = $this->get_item_tags('', 'pubDate'))
3600 - $this->data['date']['raw'] = $return[0]['data'];
3602 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date'))
3604 - $this->data['date']['raw'] = $return[0]['data'];
3606 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date'))
3608 - $this->data['date']['raw'] = $return[0]['data'];
3611 - if (!empty($this->data['date']['raw']))
3613 - $parser = SimplePie_Parse_Date::get();
3614 - $this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']);
3618 - $this->data['date'] = null;
3621 - if ($this->data['date'])
3623 - $date_format = (string) $date_format;
3624 - switch ($date_format)
3627 - return $this->sanitize($this->data['date']['raw'], SIMPLEPIE_CONSTRUCT_TEXT);
3630 - return $this->data['date']['parsed'];
3633 - return date($date_format, $this->data['date']['parsed']);
3642 - function get_local_date($date_format = '%c')
3644 - if (!$date_format)
3646 - return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT);
3648 - elseif (($date = $this->get_date('U')) !== null)
3650 - return strftime($date_format, $date);
3658 - function get_permalink()
3660 - $link = $this->get_link();
3661 - $enclosure = $this->get_enclosure(0);
3662 - if ($link !== null)
3666 - elseif ($enclosure !== null)
3668 - return $enclosure->get_link();
3676 - function get_link($key = 0, $rel = 'alternate')
3678 - $links = $this->get_links($rel);
3679 - if ($links[$key] !== null)
3681 - return $links[$key];
3689 - function get_links($rel = 'alternate')
3691 - if (!isset($this->data['links']))
3693 - $this->data['links'] = array();
3694 - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link)
3696 - if (isset($link['attribs']['']['href']))
3698 - $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
3699 - $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
3703 - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link)
3705 - if (isset($link['attribs']['']['href']))
3707 - $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
3708 - $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
3711 - if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
3713 - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
3715 - if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
3717 - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
3719 - if ($links = $this->get_item_tags('', 'link'))
3721 - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
3723 - if ($links = $this->get_item_tags('', 'guid'))
3725 - if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) == 'true')
3727 - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
3731 - $keys = array_keys($this->data['links']);
3732 - foreach ($keys as $key)
3734 - if (SimplePie_Misc::is_isegment_nz_nc($key))
3736 - if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
3738 - $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
3739 - $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
3743 - $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
3746 - elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
3748 - $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
3750 - $this->data['links'][$key] = array_unique($this->data['links'][$key]);
3753 - if (isset($this->data['links'][$rel]))
3755 - return $this->data['links'][$rel];
3764 - * @todo Add ability to prefer one type of content over another (in a media group).
3766 - function get_enclosure($key = 0, $prefer = null)
3768 - $enclosures = $this->get_enclosures();
3769 - if (isset($enclosures[$key]))
3771 - return $enclosures[$key];
3780 - * Grabs all available enclosures (podcasts, etc.)
3782 - * Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS.
3784 - * At this point, we're pretty much assuming that all enclosures for an item are the same content. Anything else is too complicated to properly support.
3786 - * @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4).
3787 - * @todo If an element exists at a level, but it's value is empty, we should fall back to the value from the parent (if it exists).
3789 - function get_enclosures()
3791 - if (!isset($this->data['enclosures']))
3793 - $this->data['enclosures'] = array();
3796 - $captions_parent = null;
3797 - $categories_parent = null;
3798 - $copyrights_parent = null;
3799 - $credits_parent = null;
3800 - $description_parent = null;
3801 - $duration_parent = null;
3802 - $hashes_parent = null;
3803 - $keywords_parent = null;
3804 - $player_parent = null;
3805 - $ratings_parent = null;
3806 - $restrictions_parent = null;
3807 - $thumbnails_parent = null;
3808 - $title_parent = null;
3810 - // Let's do the channel and item-level ones first, and just re-use them if we need to.
3811 - $parent = $this->get_feed();
3814 - if ($captions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text'))
3816 - foreach ($captions as $caption)
3818 - $caption_type = null;
3819 - $caption_lang = null;
3820 - $caption_startTime = null;
3821 - $caption_endTime = null;
3822 - $caption_text = null;
3823 - if (isset($caption['attribs']['']['type']))
3825 - $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
3827 - if (isset($caption['attribs']['']['lang']))
3829 - $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
3831 - if (isset($caption['attribs']['']['start']))
3833 - $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
3835 - if (isset($caption['attribs']['']['end']))
3837 - $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
3839 - if (isset($caption['data']))
3841 - $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3843 - $captions_parent[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
3846 - elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text'))
3848 - foreach ($captions as $caption)
3850 - $caption_type = null;
3851 - $caption_lang = null;
3852 - $caption_startTime = null;
3853 - $caption_endTime = null;
3854 - $caption_text = null;
3855 - if (isset($caption['attribs']['']['type']))
3857 - $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
3859 - if (isset($caption['attribs']['']['lang']))
3861 - $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
3863 - if (isset($caption['attribs']['']['start']))
3865 - $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
3867 - if (isset($caption['attribs']['']['end']))
3869 - $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
3871 - if (isset($caption['data']))
3873 - $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3875 - $captions_parent[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
3878 - if (is_array($captions_parent))
3880 - $captions_parent = array_values(SimplePie_Misc::array_unique($captions_parent));
3884 - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category)
3889 - if (isset($category['data']))
3891 - $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3893 - if (isset($category['attribs']['']['scheme']))
3895 - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
3899 - $scheme = 'http://search.yahoo.com/mrss/category_schema';
3901 - if (isset($category['attribs']['']['label']))
3903 - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
3905 - $categories_parent[] = new $this->feed->category_class($term, $scheme, $label);
3907 - foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category)
3912 - if (isset($category['data']))
3914 - $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3916 - if (isset($category['attribs']['']['scheme']))
3918 - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
3922 - $scheme = 'http://search.yahoo.com/mrss/category_schema';
3924 - if (isset($category['attribs']['']['label']))
3926 - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
3928 - $categories_parent[] = new $this->feed->category_class($term, $scheme, $label);
3930 - foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'category') as $category)
3933 - $scheme = 'http://www.itunes.com/dtds/podcast-1.0.dtd';
3935 - if (isset($category['attribs']['']['text']))
3937 - $label = $this->sanitize($category['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT);
3939 - $categories_parent[] = new $this->feed->category_class($term, $scheme, $label);
3941 - if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category']))
3943 - foreach ((array) $category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'] as $subcategory)
3945 - if (isset($subcategory['attribs']['']['text']))
3947 - $label = $this->sanitize($subcategory['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT);
3949 - $categories_parent[] = new $this->feed->category_class($term, $scheme, $label);
3953 - if (is_array($categories_parent))
3955 - $categories_parent = array_values(SimplePie_Misc::array_unique($categories_parent));
3959 - if ($copyright = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright'))
3961 - $copyright_url = null;
3962 - $copyright_label = null;
3963 - if (isset($copyright[0]['attribs']['']['url']))
3965 - $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
3967 - if (isset($copyright[0]['data']))
3969 - $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3971 - $copyrights_parent = new $this->feed->copyright_class($copyright_url, $copyright_label);
3973 - elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright'))
3975 - $copyright_url = null;
3976 - $copyright_label = null;
3977 - if (isset($copyright[0]['attribs']['']['url']))
3979 - $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
3981 - if (isset($copyright[0]['data']))
3983 - $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3985 - $copyrights_parent = new $this->feed->copyright_class($copyright_url, $copyright_label);
3989 - if ($credits = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit'))
3991 - foreach ($credits as $credit)
3993 - $credit_role = null;
3994 - $credit_scheme = null;
3995 - $credit_name = null;
3996 - if (isset($credit['attribs']['']['role']))
3998 - $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
4000 - if (isset($credit['attribs']['']['scheme']))
4002 - $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4006 - $credit_scheme = 'urn:ebu';
4008 - if (isset($credit['data']))
4010 - $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4012 - $credits_parent[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
4015 - elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit'))
4017 - foreach ($credits as $credit)
4019 - $credit_role = null;
4020 - $credit_scheme = null;
4021 - $credit_name = null;
4022 - if (isset($credit['attribs']['']['role']))
4024 - $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
4026 - if (isset($credit['attribs']['']['scheme']))
4028 - $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4032 - $credit_scheme = 'urn:ebu';
4034 - if (isset($credit['data']))
4036 - $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4038 - $credits_parent[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
4041 - if (is_array($credits_parent))
4043 - $credits_parent = array_values(SimplePie_Misc::array_unique($credits_parent));
4047 - if ($description_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description'))
4049 - if (isset($description_parent[0]['data']))
4051 - $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4054 - elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description'))
4056 - if (isset($description_parent[0]['data']))
4058 - $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4063 - if ($duration_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'duration'))
4068 - if (isset($duration_parent[0]['data']))
4070 - $temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
4071 - if (sizeof($temp) > 0)
4073 - (int) $seconds = array_pop($temp);
4075 - if (sizeof($temp) > 0)
4077 - (int) $minutes = array_pop($temp);
4078 - $seconds += $minutes * 60;
4080 - if (sizeof($temp) > 0)
4082 - (int) $hours = array_pop($temp);
4083 - $seconds += $hours * 3600;
4086 - $duration_parent = $seconds;
4091 - if ($hashes_iterator = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash'))
4093 - foreach ($hashes_iterator as $hash)
4097 - if (isset($hash['data']))
4099 - $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4101 - if (isset($hash['attribs']['']['algo']))
4103 - $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
4109 - $hashes_parent[] = $algo.':'.$value;
4112 - elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash'))
4114 - foreach ($hashes_iterator as $hash)
4118 - if (isset($hash['data']))
4120 - $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4122 - if (isset($hash['attribs']['']['algo']))
4124 - $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
4130 - $hashes_parent[] = $algo.':'.$value;
4133 - if (is_array($hashes_parent))
4135 - $hashes_parent = array_values(SimplePie_Misc::array_unique($hashes_parent));
4139 - if ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords'))
4141 - if (isset($keywords[0]['data']))
4143 - $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
4144 - foreach ($temp as $word)
4146 - $keywords_parent[] = trim($word);
4151 - elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords'))
4153 - if (isset($keywords[0]['data']))
4155 - $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
4156 - foreach ($temp as $word)
4158 - $keywords_parent[] = trim($word);
4163 - elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords'))
4165 - if (isset($keywords[0]['data']))
4167 - $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
4168 - foreach ($temp as $word)
4170 - $keywords_parent[] = trim($word);
4175 - elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords'))
4177 - if (isset($keywords[0]['data']))
4179 - $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
4180 - foreach ($temp as $word)
4182 - $keywords_parent[] = trim($word);
4187 - if (is_array($keywords_parent))
4189 - $keywords_parent = array_values(SimplePie_Misc::array_unique($keywords_parent));
4193 - if ($player_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player'))
4195 - if (isset($player_parent[0]['attribs']['']['url']))
4197 - $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
4200 - elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player'))
4202 - if (isset($player_parent[0]['attribs']['']['url']))
4204 - $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
4209 - if ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating'))
4211 - foreach ($ratings as $rating)
4213 - $rating_scheme = null;
4214 - $rating_value = null;
4215 - if (isset($rating['attribs']['']['scheme']))
4217 - $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4221 - $rating_scheme = 'urn:simple';
4223 - if (isset($rating['data']))
4225 - $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4227 - $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value);
4230 - elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit'))
4232 - foreach ($ratings as $rating)
4234 - $rating_scheme = 'urn:itunes';
4235 - $rating_value = null;
4236 - if (isset($rating['data']))
4238 - $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4240 - $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value);
4243 - elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating'))
4245 - foreach ($ratings as $rating)
4247 - $rating_scheme = null;
4248 - $rating_value = null;
4249 - if (isset($rating['attribs']['']['scheme']))
4251 - $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4255 - $rating_scheme = 'urn:simple';
4257 - if (isset($rating['data']))
4259 - $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4261 - $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value);
4264 - elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit'))
4266 - foreach ($ratings as $rating)
4268 - $rating_scheme = 'urn:itunes';
4269 - $rating_value = null;
4270 - if (isset($rating['data']))
4272 - $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4274 - $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value);
4277 - if (is_array($ratings_parent))
4279 - $ratings_parent = array_values(SimplePie_Misc::array_unique($ratings_parent));
4283 - if ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction'))
4285 - foreach ($restrictions as $restriction)
4287 - $restriction_relationship = null;
4288 - $restriction_type = null;
4289 - $restriction_value = null;
4290 - if (isset($restriction['attribs']['']['relationship']))
4292 - $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
4294 - if (isset($restriction['attribs']['']['type']))
4296 - $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4298 - if (isset($restriction['data']))
4300 - $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4302 - $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
4305 - elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block'))
4307 - foreach ($restrictions as $restriction)
4309 - $restriction_relationship = 'allow';
4310 - $restriction_type = null;
4311 - $restriction_value = 'itunes';
4312 - if (isset($restriction['data']) && strtolower($restriction['data']) == 'yes')
4314 - $restriction_relationship = 'deny';
4316 - $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
4319 - elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction'))
4321 - foreach ($restrictions as $restriction)
4323 - $restriction_relationship = null;
4324 - $restriction_type = null;
4325 - $restriction_value = null;
4326 - if (isset($restriction['attribs']['']['relationship']))
4328 - $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
4330 - if (isset($restriction['attribs']['']['type']))
4332 - $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4334 - if (isset($restriction['data']))
4336 - $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4338 - $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
4341 - elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block'))
4343 - foreach ($restrictions as $restriction)
4345 - $restriction_relationship = 'allow';
4346 - $restriction_type = null;
4347 - $restriction_value = 'itunes';
4348 - if (isset($restriction['data']) && strtolower($restriction['data']) == 'yes')
4350 - $restriction_relationship = 'deny';
4352 - $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
4355 - if (is_array($restrictions_parent))
4357 - $restrictions_parent = array_values(SimplePie_Misc::array_unique($restrictions_parent));
4361 - if ($thumbnails = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))
4363 - foreach ($thumbnails as $thumbnail)
4365 - if (isset($thumbnail['attribs']['']['url']))
4367 - $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
4371 - elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))
4373 - foreach ($thumbnails as $thumbnail)
4375 - if (isset($thumbnail['attribs']['']['url']))
4377 - $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
4383 - if ($title_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title'))
4385 - if (isset($title_parent[0]['data']))
4387 - $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4390 - elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title'))
4392 - if (isset($title_parent[0]['data']))
4394 - $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4398 - // Clear the memory
4405 - $expression = null;
4406 - $framerate = null;
4408 - $javascript = null;
4412 - $samplingrate = null;
4419 - $categories = null;
4420 - $copyrights = null;
4422 - $description = null;
4427 - $restrictions = null;
4428 - $thumbnails = null;
4431 - // If we have media:group tags, loop through them.
4432 - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group)
4434 - // If we have media:content tags, loop through them.
4435 - foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
4437 - if (isset($content['attribs']['']['url']))
4443 - $expression = null;
4444 - $framerate = null;
4446 - $javascript = null;
4450 - $samplingrate = null;
4457 - $categories = null;
4458 - $copyrights = null;
4460 - $description = null;
4465 - $restrictions = null;
4466 - $thumbnails = null;
4469 - // Start checking the attributes of media:content
4470 - if (isset($content['attribs']['']['bitrate']))
4472 - $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
4474 - if (isset($content['attribs']['']['channels']))
4476 - $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
4478 - if (isset($content['attribs']['']['duration']))
4480 - $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
4484 - $duration = $duration_parent;
4486 - if (isset($content['attribs']['']['expression']))
4488 - $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
4490 - if (isset($content['attribs']['']['framerate']))
4492 - $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
4494 - if (isset($content['attribs']['']['height']))
4496 - $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
4498 - if (isset($content['attribs']['']['lang']))
4500 - $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
4502 - if (isset($content['attribs']['']['fileSize']))
4504 - $length = ceil($content['attribs']['']['fileSize']);
4506 - if (isset($content['attribs']['']['medium']))
4508 - $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
4510 - if (isset($content['attribs']['']['samplingrate']))
4512 - $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
4514 - if (isset($content['attribs']['']['type']))
4516 - $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4518 - if (isset($content['attribs']['']['width']))
4520 - $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
4522 - $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
4524 - // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
4527 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
4529 - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
4531 - $caption_type = null;
4532 - $caption_lang = null;
4533 - $caption_startTime = null;
4534 - $caption_endTime = null;
4535 - $caption_text = null;
4536 - if (isset($caption['attribs']['']['type']))
4538 - $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4540 - if (isset($caption['attribs']['']['lang']))
4542 - $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
4544 - if (isset($caption['attribs']['']['start']))
4546 - $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
4548 - if (isset($caption['attribs']['']['end']))
4550 - $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
4552 - if (isset($caption['data']))
4554 - $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4556 - $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
4558 - if (is_array($captions))
4560 - $captions = array_values(SimplePie_Misc::array_unique($captions));
4563 - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
4565 - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
4567 - $caption_type = null;
4568 - $caption_lang = null;
4569 - $caption_startTime = null;
4570 - $caption_endTime = null;
4571 - $caption_text = null;
4572 - if (isset($caption['attribs']['']['type']))
4574 - $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4576 - if (isset($caption['attribs']['']['lang']))
4578 - $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
4580 - if (isset($caption['attribs']['']['start']))
4582 - $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
4584 - if (isset($caption['attribs']['']['end']))
4586 - $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
4588 - if (isset($caption['data']))
4590 - $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4592 - $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
4594 - if (is_array($captions))
4596 - $captions = array_values(SimplePie_Misc::array_unique($captions));
4601 - $captions = $captions_parent;
4605 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
4607 - foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
4612 - if (isset($category['data']))
4614 - $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4616 - if (isset($category['attribs']['']['scheme']))
4618 - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4622 - $scheme = 'http://search.yahoo.com/mrss/category_schema';
4624 - if (isset($category['attribs']['']['label']))
4626 - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
4628 - $categories[] = new $this->feed->category_class($term, $scheme, $label);
4631 - if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
4633 - foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
4638 - if (isset($category['data']))
4640 - $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4642 - if (isset($category['attribs']['']['scheme']))
4644 - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4648 - $scheme = 'http://search.yahoo.com/mrss/category_schema';
4650 - if (isset($category['attribs']['']['label']))
4652 - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
4654 - $categories[] = new $this->feed->category_class($term, $scheme, $label);
4657 - if (is_array($categories) && is_array($categories_parent))
4659 - $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent)));
4661 - elseif (is_array($categories))
4663 - $categories = array_values(SimplePie_Misc::array_unique($categories));
4665 - elseif (is_array($categories_parent))
4667 - $categories = array_values(SimplePie_Misc::array_unique($categories_parent));
4671 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
4673 - $copyright_url = null;
4674 - $copyright_label = null;
4675 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
4677 - $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
4679 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
4681 - $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4683 - $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label);
4685 - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
4687 - $copyright_url = null;
4688 - $copyright_label = null;
4689 - if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
4691 - $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
4693 - if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
4695 - $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4697 - $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label);
4701 - $copyrights = $copyrights_parent;
4705 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
4707 - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
4709 - $credit_role = null;
4710 - $credit_scheme = null;
4711 - $credit_name = null;
4712 - if (isset($credit['attribs']['']['role']))
4714 - $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
4716 - if (isset($credit['attribs']['']['scheme']))
4718 - $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4722 - $credit_scheme = 'urn:ebu';
4724 - if (isset($credit['data']))
4726 - $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4728 - $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
4730 - if (is_array($credits))
4732 - $credits = array_values(SimplePie_Misc::array_unique($credits));
4735 - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
4737 - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
4739 - $credit_role = null;
4740 - $credit_scheme = null;
4741 - $credit_name = null;
4742 - if (isset($credit['attribs']['']['role']))
4744 - $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
4746 - if (isset($credit['attribs']['']['scheme']))
4748 - $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4752 - $credit_scheme = 'urn:ebu';
4754 - if (isset($credit['data']))
4756 - $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4758 - $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
4760 - if (is_array($credits))
4762 - $credits = array_values(SimplePie_Misc::array_unique($credits));
4767 - $credits = $credits_parent;
4771 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
4773 - $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4775 - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
4777 - $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4781 - $description = $description_parent;
4785 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
4787 - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
4791 - if (isset($hash['data']))
4793 - $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4795 - if (isset($hash['attribs']['']['algo']))
4797 - $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
4803 - $hashes[] = $algo.':'.$value;
4805 - if (is_array($hashes))
4807 - $hashes = array_values(SimplePie_Misc::array_unique($hashes));
4810 - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
4812 - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
4816 - if (isset($hash['data']))
4818 - $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4820 - if (isset($hash['attribs']['']['algo']))
4822 - $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
4828 - $hashes[] = $algo.':'.$value;
4830 - if (is_array($hashes))
4832 - $hashes = array_values(SimplePie_Misc::array_unique($hashes));
4837 - $hashes = $hashes_parent;
4841 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
4843 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
4845 - $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
4846 - foreach ($temp as $word)
4848 - $keywords[] = trim($word);
4852 - if (is_array($keywords))
4854 - $keywords = array_values(SimplePie_Misc::array_unique($keywords));
4857 - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
4859 - if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
4861 - $temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
4862 - foreach ($temp as $word)
4864 - $keywords[] = trim($word);
4868 - if (is_array($keywords))
4870 - $keywords = array_values(SimplePie_Misc::array_unique($keywords));
4875 - $keywords = $keywords_parent;
4879 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
4881 - $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
4883 - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
4885 - $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
4889 - $player = $player_parent;
4893 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
4895 - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
4897 - $rating_scheme = null;
4898 - $rating_value = null;
4899 - if (isset($rating['attribs']['']['scheme']))
4901 - $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4905 - $rating_scheme = 'urn:simple';
4907 - if (isset($rating['data']))
4909 - $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4911 - $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value);
4913 - if (is_array($ratings))
4915 - $ratings = array_values(SimplePie_Misc::array_unique($ratings));
4918 - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
4920 - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
4922 - $rating_scheme = null;
4923 - $rating_value = null;
4924 - if (isset($rating['attribs']['']['scheme']))
4926 - $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4930 - $rating_scheme = 'urn:simple';
4932 - if (isset($rating['data']))
4934 - $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4936 - $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value);
4938 - if (is_array($ratings))
4940 - $ratings = array_values(SimplePie_Misc::array_unique($ratings));
4945 - $ratings = $ratings_parent;
4949 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
4951 - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
4953 - $restriction_relationship = null;
4954 - $restriction_type = null;
4955 - $restriction_value = null;
4956 - if (isset($restriction['attribs']['']['relationship']))
4958 - $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
4960 - if (isset($restriction['attribs']['']['type']))
4962 - $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4964 - if (isset($restriction['data']))
4966 - $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4968 - $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
4970 - if (is_array($restrictions))
4972 - $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
4975 - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
4977 - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
4979 - $restriction_relationship = null;
4980 - $restriction_type = null;
4981 - $restriction_value = null;
4982 - if (isset($restriction['attribs']['']['relationship']))
4984 - $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
4986 - if (isset($restriction['attribs']['']['type']))
4988 - $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4990 - if (isset($restriction['data']))
4992 - $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4994 - $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
4996 - if (is_array($restrictions))
4998 - $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
5003 - $restrictions = $restrictions_parent;
5007 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
5009 - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
5011 - $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
5013 - if (is_array($thumbnails))
5015 - $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
5018 - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
5020 - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
5022 - $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
5024 - if (is_array($thumbnails))
5026 - $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
5031 - $thumbnails = $thumbnails_parent;
5035 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
5037 - $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5039 - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
5041 - $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5045 - $title = $title_parent;
5048 - $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);
5053 - // If we have standalone media:content tags, loop through them.
5054 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
5056 - foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
5058 - if (isset($content['attribs']['']['url']))
5064 - $expression = null;
5065 - $framerate = null;
5067 - $javascript = null;
5071 - $samplingrate = null;
5078 - $categories = null;
5079 - $copyrights = null;
5081 - $description = null;
5086 - $restrictions = null;
5087 - $thumbnails = null;
5090 - // Start checking the attributes of media:content
5091 - if (isset($content['attribs']['']['bitrate']))
5093 - $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
5095 - if (isset($content['attribs']['']['channels']))
5097 - $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
5099 - if (isset($content['attribs']['']['duration']))
5101 - $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
5105 - $duration = $duration_parent;
5107 - if (isset($content['attribs']['']['expression']))
5109 - $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
5111 - if (isset($content['attribs']['']['framerate']))
5113 - $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
5115 - if (isset($content['attribs']['']['height']))
5117 - $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
5119 - if (isset($content['attribs']['']['lang']))
5121 - $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
5123 - if (isset($content['attribs']['']['fileSize']))
5125 - $length = ceil($content['attribs']['']['fileSize']);
5127 - if (isset($content['attribs']['']['medium']))
5129 - $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
5131 - if (isset($content['attribs']['']['samplingrate']))
5133 - $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
5135 - if (isset($content['attribs']['']['type']))
5137 - $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
5139 - if (isset($content['attribs']['']['width']))
5141 - $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
5143 - $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
5145 - // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
5148 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
5150 - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
5152 - $caption_type = null;
5153 - $caption_lang = null;
5154 - $caption_startTime = null;
5155 - $caption_endTime = null;
5156 - $caption_text = null;
5157 - if (isset($caption['attribs']['']['type']))
5159 - $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
5161 - if (isset($caption['attribs']['']['lang']))
5163 - $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
5165 - if (isset($caption['attribs']['']['start']))
5167 - $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
5169 - if (isset($caption['attribs']['']['end']))
5171 - $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
5173 - if (isset($caption['data']))
5175 - $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5177 - $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
5179 - if (is_array($captions))
5181 - $captions = array_values(SimplePie_Misc::array_unique($captions));
5186 - $captions = $captions_parent;
5190 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
5192 - foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
5197 - if (isset($category['data']))
5199 - $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5201 - if (isset($category['attribs']['']['scheme']))
5203 - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
5207 - $scheme = 'http://search.yahoo.com/mrss/category_schema';
5209 - if (isset($category['attribs']['']['label']))
5211 - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
5213 - $categories[] = new $this->feed->category_class($term, $scheme, $label);
5216 - if (is_array($categories) && is_array($categories_parent))
5218 - $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent)));
5220 - elseif (is_array($categories))
5222 - $categories = array_values(SimplePie_Misc::array_unique($categories));
5224 - elseif (is_array($categories_parent))
5226 - $categories = array_values(SimplePie_Misc::array_unique($categories_parent));
5230 - $categories = null;
5234 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
5236 - $copyright_url = null;
5237 - $copyright_label = null;
5238 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
5240 - $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
5242 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
5244 - $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5246 - $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label);
5250 - $copyrights = $copyrights_parent;
5254 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
5256 - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
5258 - $credit_role = null;
5259 - $credit_scheme = null;
5260 - $credit_name = null;
5261 - if (isset($credit['attribs']['']['role']))
5263 - $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
5265 - if (isset($credit['attribs']['']['scheme']))
5267 - $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
5271 - $credit_scheme = 'urn:ebu';
5273 - if (isset($credit['data']))
5275 - $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5277 - $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
5279 - if (is_array($credits))
5281 - $credits = array_values(SimplePie_Misc::array_unique($credits));
5286 - $credits = $credits_parent;
5290 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
5292 - $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5296 - $description = $description_parent;
5300 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
5302 - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
5306 - if (isset($hash['data']))
5308 - $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5310 - if (isset($hash['attribs']['']['algo']))
5312 - $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
5318 - $hashes[] = $algo.':'.$value;
5320 - if (is_array($hashes))
5322 - $hashes = array_values(SimplePie_Misc::array_unique($hashes));
5327 - $hashes = $hashes_parent;
5331 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
5333 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
5335 - $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
5336 - foreach ($temp as $word)
5338 - $keywords[] = trim($word);
5342 - if (is_array($keywords))
5344 - $keywords = array_values(SimplePie_Misc::array_unique($keywords));
5349 - $keywords = $keywords_parent;
5353 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
5355 - $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
5359 - $player = $player_parent;
5363 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
5365 - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
5367 - $rating_scheme = null;
5368 - $rating_value = null;
5369 - if (isset($rating['attribs']['']['scheme']))
5371 - $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
5375 - $rating_scheme = 'urn:simple';
5377 - if (isset($rating['data']))
5379 - $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5381 - $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value);
5383 - if (is_array($ratings))
5385 - $ratings = array_values(SimplePie_Misc::array_unique($ratings));
5390 - $ratings = $ratings_parent;
5394 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
5396 - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
5398 - $restriction_relationship = null;
5399 - $restriction_type = null;
5400 - $restriction_value = null;
5401 - if (isset($restriction['attribs']['']['relationship']))
5403 - $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
5405 - if (isset($restriction['attribs']['']['type']))
5407 - $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
5409 - if (isset($restriction['data']))
5411 - $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5413 - $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
5415 - if (is_array($restrictions))
5417 - $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
5422 - $restrictions = $restrictions_parent;
5426 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
5428 - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
5430 - $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
5432 - if (is_array($thumbnails))
5434 - $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
5439 - $thumbnails = $thumbnails_parent;
5443 - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
5445 - $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5449 - $title = $title_parent;
5452 - $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);
5457 - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link)
5459 - if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] == 'enclosure')
5465 - $expression = null;
5466 - $framerate = null;
5468 - $javascript = null;
5472 - $samplingrate = null;
5477 - $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
5478 - if (isset($link['attribs']['']['type']))
5480 - $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
5482 - if (isset($link['attribs']['']['length']))
5484 - $length = ceil($link['attribs']['']['length']);
5487 - // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
5488 - $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);
5492 - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link)
5494 - if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] == 'enclosure')
5500 - $expression = null;
5501 - $framerate = null;
5503 - $javascript = null;
5507 - $samplingrate = null;
5512 - $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
5513 - if (isset($link['attribs']['']['type']))
5515 - $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
5517 - if (isset($link['attribs']['']['length']))
5519 - $length = ceil($link['attribs']['']['length']);
5522 - // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
5523 - $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);
5527 - if ($enclosure = $this->get_item_tags('', 'enclosure'))
5529 - if (isset($enclosure[0]['attribs']['']['url']))
5535 - $expression = null;
5536 - $framerate = null;
5538 - $javascript = null;
5542 - $samplingrate = null;
5547 - $url = $this->sanitize($enclosure[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($enclosure[0]));
5548 - if (isset($enclosure[0]['attribs']['']['type']))
5550 - $type = $this->sanitize($enclosure[0]['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
5552 - if (isset($enclosure[0]['attribs']['']['length']))
5554 - $length = ceil($enclosure[0]['attribs']['']['length']);
5557 - // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
5558 - $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);
5562 - 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))
5564 - // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
5565 - $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);
5568 - $this->data['enclosures'] = array_values(SimplePie_Misc::array_unique($this->data['enclosures']));
5570 - if (!empty($this->data['enclosures']))
5572 - return $this->data['enclosures'];
5580 - function get_latitude()
5582 - if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
5584 - return (float) $return[0]['data'];
5586 - elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
5588 - return (float) $match[1];
5596 - function get_longitude()
5598 - if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
5600 - return (float) $return[0]['data'];
5602 - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
5604 - return (float) $return[0]['data'];
5606 - elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
5608 - return (float) $match[2];
5616 - function get_source()
5618 - if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source'))
5620 - return new $this->feed->source_class($this, $return[0]);
5629 - * Creates the add_to_* methods' return data
5632 - * @param string $item_url String to prefix to the item permalink
5633 - * @param string $title_url String to prefix to the item title
5634 - * (and suffix to the item permalink)
5635 - * @return mixed URL if feed exists, false otherwise
5637 - function add_to_service($item_url, $title_url = null, $summary_url = null)
5639 - if ($this->get_permalink() !== null)
5641 - $return = $this->sanitize($item_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_permalink());
5642 - if ($title_url !== null && $this->get_title() !== null)
5644 - $return .= $this->sanitize($title_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_title());
5646 - if ($summary_url !== null && $this->get_description() !== null)
5648 - $return .= $this->sanitize($summary_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_description());
5658 - function add_to_blinklist()
5660 - return $this->add_to_service('http://www.blinklist.com/index.php?Action=Blink/addblink.php&Description=&Url=', '&Title=');
5663 - function add_to_blogmarks()
5665 - return $this->add_to_service('http://blogmarks.net/my/new.php?mini=1&simple=1&url=', '&title=');
5668 - function add_to_delicious()
5670 - return $this->add_to_service('http://del.icio.us/post/?v=4&url=', '&title=');
5673 - function add_to_digg()
5675 - return $this->add_to_service('http://digg.com/submit?url=', '&title=', '&bodytext=');
5678 - function add_to_furl()
5680 - return $this->add_to_service('http://www.furl.net/storeIt.jsp?u=', '&t=');
5683 - function add_to_magnolia()
5685 - return $this->add_to_service('http://ma.gnolia.com/bookmarklet/add?url=', '&title=');
5688 - function add_to_myweb20()
5690 - return $this->add_to_service('http://myweb2.search.yahoo.com/myresults/bookmarklet?u=', '&t=');
5693 - function add_to_newsvine()
5695 - return $this->add_to_service('http://www.newsvine.com/_wine/save?u=', '&h=');
5698 - function add_to_reddit()
5700 - return $this->add_to_service('http://reddit.com/submit?url=', '&title=');
5703 - function add_to_segnalo()
5705 - return $this->add_to_service('http://segnalo.com/post.html.php?url=', '&title=');
5708 - function add_to_simpy()
5710 - return $this->add_to_service('http://www.simpy.com/simpy/LinkAdd.do?href=', '&title=');
5713 - function add_to_spurl()
5715 - return $this->add_to_service('http://www.spurl.net/spurl.php?v=3&url=', '&title=');
5718 - function add_to_wists()
5720 - return $this->add_to_service('http://wists.com/r.php?c=&r=', '&title=');
5723 - function search_technorati()
5725 - return $this->add_to_service('http://www.technorati.com/search/');
5729 -class SimplePie_Source
5732 - var $data = array();
5734 - function SimplePie_Source($item, $data)
5736 - $this->item = $item;
5737 - $this->data = $data;
5740 - function __toString()
5742 - return md5(serialize($this->data));
5746 - * Remove items that link back to this before destroying this object
5748 - function __destruct()
5750 - unset($this->item);
5753 - function get_source_tags($namespace, $tag)
5755 - if (isset($this->data['child'][$namespace][$tag]))
5757 - return $this->data['child'][$namespace][$tag];
5765 - function get_base($element = array())
5767 - return $this->item->get_base($element);
5770 - function sanitize($data, $type, $base = '')
5772 - return $this->item->sanitize($data, $type, $base);
5775 - function get_item()
5777 - return $this->item;
5780 - function get_title()
5782 - if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
5784 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
5786 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
5788 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
5790 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
5792 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
5794 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
5796 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
5798 - elseif ($return = $this->get_source_tags('', 'title'))
5800 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
5802 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
5804 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5806 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
5808 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5816 - function get_category($key = 0)
5818 - $categories = $this->get_categories();
5819 - if (isset($categories[$key]))
5821 - return $categories[$key];
5829 - function get_categories()
5831 - $categories = array();
5833 - foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
5838 - if (isset($category['attribs']['']['term']))
5840 - $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
5842 - if (isset($category['attribs']['']['scheme']))
5844 - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
5846 - if (isset($category['attribs']['']['label']))
5848 - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
5850 - $categories[] = new $this->item->feed->category_class($term, $scheme, $label);
5852 - foreach ((array) $this->get_source_tags('', 'category') as $category)
5854 - $categories[] = new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
5856 - foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
5858 - $categories[] = new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
5860 - foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
5862 - $categories[] = new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
5865 - if (!empty($categories))
5867 - return SimplePie_Misc::array_unique($categories);
5875 - function get_author($key = 0)
5877 - $authors = $this->get_authors();
5878 - if (isset($authors[$key]))
5880 - return $authors[$key];
5888 - function get_authors()
5890 - $authors = array();
5891 - foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
5896 - if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
5898 - $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5900 - if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
5902 - $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
5904 - if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
5906 - $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5908 - if ($name !== null || $email !== null || $uri !== null)
5910 - $authors[] = new $this->item->feed->author_class($name, $uri, $email);
5913 - if ($author = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
5918 - if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
5920 - $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5922 - if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
5924 - $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
5926 - if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
5928 - $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5930 - if ($name !== null || $email !== null || $url !== null)
5932 - $authors[] = new $this->item->feed->author_class($name, $url, $email);
5935 - foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
5937 - $authors[] = new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
5939 - foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
5941 - $authors[] = new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
5943 - foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
5945 - $authors[] = new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
5948 - if (!empty($authors))
5950 - return SimplePie_Misc::array_unique($authors);
5958 - function get_contributor($key = 0)
5960 - $contributors = $this->get_contributors();
5961 - if (isset($contributors[$key]))
5963 - return $contributors[$key];
5971 - function get_contributors()
5973 - $contributors = array();
5974 - foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
5979 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
5981 - $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5983 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
5985 - $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
5987 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
5989 - $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5991 - if ($name !== null || $email !== null || $uri !== null)
5993 - $contributors[] = new $this->item->feed->author_class($name, $uri, $email);
5996 - foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
6001 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
6003 - $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6005 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
6007 - $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
6009 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
6011 - $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6013 - if ($name !== null || $email !== null || $url !== null)
6015 - $contributors[] = new $this->item->feed->author_class($name, $url, $email);
6019 - if (!empty($contributors))
6021 - return SimplePie_Misc::array_unique($contributors);
6029 - function get_link($key = 0, $rel = 'alternate')
6031 - $links = $this->get_links($rel);
6032 - if (isset($links[$key]))
6034 - return $links[$key];
6043 - * Added for parity between the parent-level and the item/entry-level.
6045 - function get_permalink()
6047 - return $this->get_link(0);
6050 - function get_links($rel = 'alternate')
6052 - if (!isset($this->data['links']))
6054 - $this->data['links'] = array();
6055 - if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link'))
6057 - foreach ($links as $link)
6059 - if (isset($link['attribs']['']['href']))
6061 - $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
6062 - $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
6066 - if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link'))
6068 - foreach ($links as $link)
6070 - if (isset($link['attribs']['']['href']))
6072 - $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
6073 - $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
6078 - if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
6080 - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
6082 - if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
6084 - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
6086 - if ($links = $this->get_source_tags('', 'link'))
6088 - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
6091 - $keys = array_keys($this->data['links']);
6092 - foreach ($keys as $key)
6094 - if (SimplePie_Misc::is_isegment_nz_nc($key))
6096 - if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
6098 - $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
6099 - $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
6103 - $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
6106 - elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
6108 - $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
6110 - $this->data['links'][$key] = array_unique($this->data['links'][$key]);
6114 - if (isset($this->data['links'][$rel]))
6116 - return $this->data['links'][$rel];
6124 - function get_description()
6126 - if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle'))
6128 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
6130 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline'))
6132 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
6134 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
6136 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
6138 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
6140 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
6142 - elseif ($return = $this->get_source_tags('', 'description'))
6144 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
6146 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
6148 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6150 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
6152 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6154 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
6156 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
6158 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
6160 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
6168 - function get_copyright()
6170 - if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
6172 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
6174 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright'))
6176 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
6178 - elseif ($return = $this->get_source_tags('', 'copyright'))
6180 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6182 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
6184 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6186 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
6188 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6196 - function get_language()
6198 - if ($return = $this->get_source_tags('', 'language'))
6200 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6202 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language'))
6204 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6206 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language'))
6208 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6210 - elseif (isset($this->data['xml_lang']))
6212 - return $this->sanitize($this->data['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
6220 - function get_latitude()
6222 - if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
6224 - return (float) $return[0]['data'];
6226 - elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
6228 - return (float) $match[1];
6236 - function get_longitude()
6238 - if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
6240 - return (float) $return[0]['data'];
6242 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
6244 - return (float) $return[0]['data'];
6246 - elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
6248 - return (float) $match[2];
6256 - function get_image_url()
6258 - if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image'))
6260 - return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI);
6262 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo'))
6264 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
6266 - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
6268 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
6277 -class SimplePie_Author
6283 - // Constructor, used to input the data
6284 - function SimplePie_Author($name = null, $link = null, $email = null)
6286 - $this->name = $name;
6287 - $this->link = $link;
6288 - $this->email = $email;
6291 - function __toString()
6293 - // There is no $this->data here
6294 - return md5(serialize($this));
6297 - function get_name()
6299 - if ($this->name !== null)
6301 - return $this->name;
6309 - function get_link()
6311 - if ($this->link !== null)
6313 - return $this->link;
6321 - function get_email()
6323 - if ($this->email !== null)
6325 - return $this->email;
6334 -class SimplePie_Category
6340 - // Constructor, used to input the data
6341 - function SimplePie_Category($term = null, $scheme = null, $label = null)
6343 - $this->term = $term;
6344 - $this->scheme = $scheme;
6345 - $this->label = $label;
6348 - function __toString()
6350 - // There is no $this->data here
6351 - return md5(serialize($this));
6354 - function get_term()
6356 - if ($this->term !== null)
6358 - return $this->term;
6366 - function get_scheme()
6368 - if ($this->scheme !== null)
6370 - return $this->scheme;
6378 - function get_label()
6380 - if ($this->label !== null)
6382 - return $this->label;
6386 - return $this->get_term();
6391 -class SimplePie_Enclosure
6414 - var $restrictions;
6415 - var $samplingrate;
6421 - // Constructor, used to input the data
6422 - function SimplePie_Enclosure($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null)
6424 - $this->bitrate = $bitrate;
6425 - $this->captions = $captions;
6426 - $this->categories = $categories;
6427 - $this->channels = $channels;
6428 - $this->copyright = $copyright;
6429 - $this->credits = $credits;
6430 - $this->description = $description;
6431 - $this->duration = $duration;
6432 - $this->expression = $expression;
6433 - $this->framerate = $framerate;
6434 - $this->hashes = $hashes;
6435 - $this->height = $height;
6436 - $this->javascript = $javascript;
6437 - $this->keywords = $keywords;
6438 - $this->lang = $lang;
6439 - $this->length = $length;
6440 - $this->link = $link;
6441 - $this->medium = $medium;
6442 - $this->player = $player;
6443 - $this->ratings = $ratings;
6444 - $this->restrictions = $restrictions;
6445 - $this->samplingrate = $samplingrate;
6446 - $this->thumbnails = $thumbnails;
6447 - $this->title = $title;
6448 - $this->type = $type;
6449 - $this->width = $width;
6450 - if (class_exists('idna_convert'))
6452 - $idn = new idna_convert;
6453 - $parsed = SimplePie_Misc::parse_url($link);
6454 - $this->link = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
6456 - $this->handler = $this->get_handler(); // Needs to load last
6459 - function __toString()
6461 - // There is no $this->data here
6462 - return md5(serialize($this));
6465 - function get_bitrate()
6467 - if ($this->bitrate !== null)
6469 - return $this->bitrate;
6477 - function get_caption($key = 0)
6479 - $captions = $this->get_captions();
6480 - if (isset($captions[$key]))
6482 - return $captions[$key];
6490 - function get_captions()
6492 - if ($this->captions !== null)
6494 - return $this->captions;
6502 - function get_category($key = 0)
6504 - $categories = $this->get_categories();
6505 - if (isset($categories[$key]))
6507 - return $categories[$key];
6515 - function get_categories()
6517 - if ($this->categories !== null)
6519 - return $this->categories;
6527 - function get_channels()
6529 - if ($this->channels !== null)
6531 - return $this->channels;
6539 - function get_copyright()
6541 - if ($this->copyright !== null)
6543 - return $this->copyright;
6551 - function get_credit($key = 0)
6553 - $credits = $this->get_credits();
6554 - if (isset($credits[$key]))
6556 - return $credits[$key];
6564 - function get_credits()
6566 - if ($this->credits !== null)
6568 - return $this->credits;
6576 - function get_description()
6578 - if ($this->description !== null)
6580 - return $this->description;
6588 - function get_duration($convert = false)
6590 - if ($this->duration !== null)
6594 - $time = SimplePie_Misc::time_hms($this->duration);
6599 - return $this->duration;
6608 - function get_expression()
6610 - if ($this->expression !== null)
6612 - return $this->expression;
6620 - function get_extension()
6622 - if ($this->link !== null)
6624 - $url = SimplePie_Misc::parse_url($this->link);
6625 - if ($url['path'] !== '')
6627 - return pathinfo($url['path'], PATHINFO_EXTENSION);
6633 - function get_framerate()
6635 - if ($this->framerate !== null)
6637 - return $this->framerate;
6645 - function get_handler()
6647 - return $this->get_real_type(true);
6650 - function get_hash($key = 0)
6652 - $hashes = $this->get_hashes();
6653 - if (isset($hashes[$key]))
6655 - return $hashes[$key];
6663 - function get_hashes()
6665 - if ($this->hashes !== null)
6667 - return $this->hashes;
6675 - function get_height()
6677 - if ($this->height !== null)
6679 - return $this->height;
6687 - function get_language()
6689 - if ($this->lang !== null)
6691 - return $this->lang;
6699 - function get_keyword($key = 0)
6701 - $keywords = $this->get_keywords();
6702 - if (isset($keywords[$key]))
6704 - return $keywords[$key];
6712 - function get_keywords()
6714 - if ($this->keywords !== null)
6716 - return $this->keywords;
6724 - function get_length()
6726 - if ($this->length !== null)
6728 - return $this->length;
6736 - function get_link()
6738 - if ($this->link !== null)
6740 - return urldecode($this->link);
6748 - function get_medium()
6750 - if ($this->medium !== null)
6752 - return $this->medium;
6760 - function get_player()
6762 - if ($this->player !== null)
6764 - return $this->player;
6772 - function get_rating($key = 0)
6774 - $ratings = $this->get_ratings();
6775 - if (isset($ratings[$key]))
6777 - return $ratings[$key];
6785 - function get_ratings()
6787 - if ($this->ratings !== null)
6789 - return $this->ratings;
6797 - function get_restriction($key = 0)
6799 - $restrictions = $this->get_restrictions();
6800 - if (isset($restrictions[$key]))
6802 - return $restrictions[$key];
6810 - function get_restrictions()
6812 - if ($this->restrictions !== null)
6814 - return $this->restrictions;
6822 - function get_sampling_rate()
6824 - if ($this->samplingrate !== null)
6826 - return $this->samplingrate;
6834 - function get_size()
6836 - $length = $this->get_length();
6837 - if ($length !== null)
6839 - return round($length/1048576, 2);
6847 - function get_thumbnail($key = 0)
6849 - $thumbnails = $this->get_thumbnails();
6850 - if (isset($thumbnails[$key]))
6852 - return $thumbnails[$key];
6860 - function get_thumbnails()
6862 - if ($this->thumbnails !== null)
6864 - return $this->thumbnails;
6872 - function get_title()
6874 - if ($this->title !== null)
6876 - return $this->title;
6884 - function get_type()
6886 - if ($this->type !== null)
6888 - return $this->type;
6896 - function get_width()
6898 - if ($this->width !== null)
6900 - return $this->width;
6908 - function native_embed($options='')
6910 - return $this->embed($options, true);
6914 - * @todo If the dimensions for media:content are defined, use them when width/height are set to 'auto'.
6916 - function embed($options = '', $native = false)
6918 - // Set up defaults
6926 - $bgcolor = '#ffffff';
6927 - $mediaplayer = '';
6928 - $widescreen = false;
6929 - $handler = $this->get_handler();
6930 - $type = $this->get_real_type();
6932 - // Process options and reassign values as necessary
6933 - if (is_array($options))
6935 - extract($options);
6939 - $options = explode(',', $options);
6940 - foreach($options as $option)
6942 - $opt = explode(':', $option, 2);
6943 - if (isset($opt[0], $opt[1]))
6945 - $opt[0] = trim($opt[0]);
6946 - $opt[1] = trim($opt[1]);
6962 - $altclass = $opt[1];
6974 - $height = $opt[1];
6978 - $bgcolor = $opt[1];
6981 - case 'mediaplayer':
6982 - $mediaplayer = $opt[1];
6985 - case 'widescreen':
6986 - $widescreen = $opt[1];
6993 - $mime = explode('/', $type, 2);
6996 - // Process values for 'auto'
6997 - if ($width == 'auto')
6999 - if ($mime == 'video')
7001 - if ($height == 'auto')
7005 - elseif ($widescreen)
7007 - $width = round((intval($height)/9)*16);
7011 - $width = round((intval($height)/3)*4);
7020 - if ($height == 'auto')
7022 - if ($mime == 'audio')
7026 - elseif ($mime == 'video')
7028 - if ($width == 'auto')
7039 - elseif ($widescreen)
7041 - $height = round((intval($width)/16)*9);
7045 - $height = round((intval($width)/4)*3);
7053 - elseif ($mime == 'audio')
7058 - // Set proper placeholder value
7059 - if ($mime == 'audio')
7061 - $placeholder = $audio;
7063 - elseif ($mime == 'video')
7065 - $placeholder = $video;
7070 - // Make sure the JS library is included
7073 - static $javascript_outputted = null;
7074 - if (!$javascript_outputted && $this->javascript)
7076 - $embed .= '<script type="text/javascript" src="?' . htmlspecialchars($this->javascript) . '"></script>';
7077 - $javascript_outputted = true;
7081 - // Odeo Feed MP3's
7082 - if ($handler == 'odeo')
7086 - $embed .= '<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://adobe.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=' . $this->get_link() . '"></embed>';
7090 - $embed .= '<script type="text/javascript">/* <![CDATA[ */embed_odeo("' . $this->get_link() . '");/* ]]> */</script>';
7095 - elseif ($handler == 'flash')
7099 - $embed .= "<embed src=\"" . $this->get_link() . "\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"$type\" quality=\"high\" width=\"$width\" height=\"$height\" bgcolor=\"$bgcolor\" loop=\"$loop\"></embed>";
7103 - $embed .= '<script type="text/javascript">/* <![CDATA[ */' .
7104 - "embed_flash('$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$loop', '$type');/* ]]> */</script>";
7108 - // Flash Media Player file types.
7109 - // Preferred handler for MP3 file types.
7110 - elseif ($handler == 'fmedia' || ($handler == 'mp3' && $mediaplayer != ''))
7115 - $embed .= "<embed src=\"$mediaplayer\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" quality=\"high\" width=\"$width\" height=\"$height\" wmode=\"transparent\" flashvars=\"file=" . rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) . "&autostart=false&repeat=$loop&showdigits=true&showfsbutton=false\"></embed>";
7119 - $embed .= '<script type="text/javascript">/* <![CDATA[ */' .
7120 - "embed_flv('$width', '$height', '" . rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) . "', '$placeholder', '$loop', '$mediaplayer');/* ]]> */</script>";
7124 - // QuickTime 7 file types. Need to test with QuickTime 6.
7125 - // Only handle MP3's if the Flash Media Player is not present.
7126 - elseif ($handler == 'quicktime' || ($handler == 'mp3' && $mediaplayer == ''))
7131 - if ($placeholder != ""){
7132 - $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>";
7135 - $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>";
7140 - $embed .= '<script type="text/javascript">/* <![CDATA[ */' .
7141 - "embed_quicktime('$type', '$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$placeholder', '$loop');/* ]]> */</script>";
7146 - elseif ($handler == 'wmedia')
7151 - $embed .= "<embed type=\"application/x-mplayer2\" src=\"" . $this->get_link() . "\" autosize=\"1\" width=\"$width\" height=\"$height\" showcontrols=\"1\" showstatusbar=\"0\" showdisplay=\"0\" autostart=\"0\"></embed>";
7155 - $embed .= '<script type="text/javascript">/* <![CDATA[ */' .
7156 - "embed_wmedia('$width', '$height', '" . $this->get_link() . "');/* ]]> */</script>";
7160 - // Everything else
7161 - else $embed .= '<a href="' . $this->get_link() . '" class="' . $altclass . '">' . $alt . '</a>';
7166 - function get_real_type($find_handler = false)
7168 - // If it's Odeo, let's get it out of the way.
7169 - if (substr(strtolower($this->get_link()), 0, 15) == 'http://odeo.com')
7174 - // Mime-types by handler.
7175 - $types_flash = array('application/x-shockwave-flash', 'application/futuresplash'); // Flash
7176 - $types_fmedia = array('video/flv', 'video/x-flv','flv-application/octet-stream'); // Flash Media Player
7177 - $types_quicktime = array('audio/3gpp', 'audio/3gpp2', 'audio/aac', 'audio/x-aac', 'audio/aiff', 'audio/x-aiff', 'audio/mid', 'audio/midi', 'audio/x-midi', 'audio/mp4', 'audio/m4a', 'audio/x-m4a', 'audio/wav', 'audio/x-wav', 'video/3gpp', 'video/3gpp2', 'video/m4v', 'video/x-m4v', 'video/mp4', 'video/mpeg', 'video/x-mpeg', 'video/quicktime', 'video/sd-video'); // QuickTime
7178 - $types_wmedia = array('application/asx', 'application/x-mplayer2', 'audio/x-ms-wma', 'audio/x-ms-wax', 'video/x-ms-asf-plugin', 'video/x-ms-asf', 'video/x-ms-wm', 'video/x-ms-wmv', 'video/x-ms-wvx'); // Windows Media
7179 - $types_mp3 = array('audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg'); // MP3
7181 - if ($this->get_type() !== null)
7183 - $type = strtolower($this->type);
7190 - // If we encounter an unsupported mime-type, check the file extension and guess intelligently.
7191 - if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3)))
7193 - switch (strtolower($this->get_extension()))
7195 - // Audio mime-types
7198 - $type = 'audio/acc';
7205 - $type = 'audio/aiff';
7209 - $type = 'audio/wav';
7216 - $type = 'audio/midi';
7220 - $type = 'audio/x-m4a';
7225 - $type = 'audio/mp3';
7229 - $type = 'audio/wav';
7233 - $type = 'audio/x-ms-wax';
7237 - $type = 'audio/x-ms-wma';
7240 - // Video mime-types
7243 - $type = 'video/3gpp';
7248 - $type = 'video/3gpp2';
7252 - $type = 'video/x-ms-asf';
7256 - $type = 'video/x-flv';
7270 - $type = 'video/mpeg';
7274 - $type = 'video/x-m4v';
7279 - $type = 'video/quicktime';
7284 - $type = 'video/mp4';
7288 - $type = 'video/sd-video';
7292 - $type = 'video/x-ms-wm';
7296 - $type = 'video/x-ms-wmv';
7300 - $type = 'video/x-ms-wvx';
7303 - // Flash mime-types
7305 - $type = 'application/futuresplash';
7309 - $type = 'application/x-shockwave-flash';
7314 - if ($find_handler)
7316 - if (in_array($type, $types_flash))
7320 - elseif (in_array($type, $types_fmedia))
7324 - elseif (in_array($type, $types_quicktime))
7326 - return 'quicktime';
7328 - elseif (in_array($type, $types_wmedia))
7332 - elseif (in_array($type, $types_mp3))
7348 -class SimplePie_Caption
7356 - // Constructor, used to input the data
7357 - function SimplePie_Caption($type = null, $lang = null, $startTime = null, $endTime = null, $text = null)
7359 - $this->type = $type;
7360 - $this->lang = $lang;
7361 - $this->startTime = $startTime;
7362 - $this->endTime = $endTime;
7363 - $this->text = $text;
7366 - function __toString()
7368 - // There is no $this->data here
7369 - return md5(serialize($this));
7372 - function get_endtime()
7374 - if ($this->endTime !== null)
7376 - return $this->endTime;
7384 - function get_language()
7386 - if ($this->lang !== null)
7388 - return $this->lang;
7396 - function get_starttime()
7398 - if ($this->startTime !== null)
7400 - return $this->startTime;
7408 - function get_text()
7410 - if ($this->text !== null)
7412 - return $this->text;
7420 - function get_type()
7422 - if ($this->type !== null)
7424 - return $this->type;
7433 -class SimplePie_Credit
7439 - // Constructor, used to input the data
7440 - function SimplePie_Credit($role = null, $scheme = null, $name = null)
7442 - $this->role = $role;
7443 - $this->scheme = $scheme;
7444 - $this->name = $name;
7447 - function __toString()
7449 - // There is no $this->data here
7450 - return md5(serialize($this));
7453 - function get_role()
7455 - if ($this->role !== null)
7457 - return $this->role;
7465 - function get_scheme()
7467 - if ($this->scheme !== null)
7469 - return $this->scheme;
7477 - function get_name()
7479 - if ($this->name !== null)
7481 - return $this->name;
7490 -class SimplePie_Copyright
7495 - // Constructor, used to input the data
7496 - function SimplePie_Copyright($url = null, $label = null)
7498 - $this->url = $url;
7499 - $this->label = $label;
7502 - function __toString()
7504 - // There is no $this->data here
7505 - return md5(serialize($this));
7508 - function get_url()
7510 - if ($this->url !== null)
7512 - return $this->url;
7520 - function get_attribution()
7522 - if ($this->label !== null)
7524 - return $this->label;
7533 -class SimplePie_Rating
7538 - // Constructor, used to input the data
7539 - function SimplePie_Rating($scheme = null, $value = null)
7541 - $this->scheme = $scheme;
7542 - $this->value = $value;
7545 - function __toString()
7547 - // There is no $this->data here
7548 - return md5(serialize($this));
7551 - function get_scheme()
7553 - if ($this->scheme !== null)
7555 - return $this->scheme;
7563 - function get_value()
7565 - if ($this->value !== null)
7567 - return $this->value;
7576 -class SimplePie_Restriction
7578 - var $relationship;
7582 - // Constructor, used to input the data
7583 - function SimplePie_Restriction($relationship = null, $type = null, $value = null)
7585 - $this->relationship = $relationship;
7586 - $this->type = $type;
7587 - $this->value = $value;
7590 - function __toString()
7592 - // There is no $this->data here
7593 - return md5(serialize($this));
7596 - function get_relationship()
7598 - if ($this->relationship !== null)
7600 - return $this->relationship;
7608 - function get_type()
7610 - if ($this->type !== null)
7612 - return $this->type;
7620 - function get_value()
7622 - if ($this->value !== null)
7624 - return $this->value;
7634 - * @todo Move to properly supporting RFC2616 (HTTP/1.1)
7636 -class SimplePie_File
7640 - var $success = true;
7641 - var $headers = array();
7644 - var $redirects = 0;
7646 - var $method = SIMPLEPIE_FILE_SOURCE_NONE;
7648 - function SimplePie_File($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false, $proxy = "")
7650 - if (class_exists('idna_convert'))
7652 - $idn = new idna_convert;
7653 - $parsed = SimplePie_Misc::parse_url($url);
7654 - $url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
7656 - $this->url = $url;
7657 - $this->useragent = $useragent;
7658 - if (preg_match('/^http(s)?:\/\//i', $url))
7660 - if ($useragent === null)
7662 - $useragent = ini_get('user_agent');
7663 - $this->useragent = $useragent;
7665 - if (!is_array($headers))
7667 - $headers = array();
7669 - if (!$force_fsockopen && function_exists('curl_exec'))
7671 - $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL;
7672 - $fp = curl_init();
7673 - $headers2 = array();
7674 - foreach ($headers as $key => $value)
7676 - $headers2[] = "$key: $value";
7678 - if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>='))
7680 - curl_setopt($fp, CURLOPT_ENCODING, '');
7682 - curl_setopt($fp, CURLOPT_URL, $url);
7683 - curl_setopt($fp, CURLOPT_HEADER, 1);
7684 - curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);
7685 - curl_setopt($fp, CURLOPT_TIMEOUT, $timeout);
7686 - curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout);
7687 - curl_setopt($fp, CURLOPT_REFERER, $url);
7688 - curl_setopt($fp, CURLOPT_USERAGENT, $useragent);
7689 - curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);
7690 - if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>='))
7692 - curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1);
7693 - curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects);
7697 - curl_setopt($fp, CURLOPT_PROXY, $proxy);
7700 - $this->headers = curl_exec($fp);
7701 - if (curl_errno($fp) == 23 || curl_errno($fp) == 61)
7703 - curl_setopt($fp, CURLOPT_ENCODING, 'none');
7704 - $this->headers = curl_exec($fp);
7706 - if (curl_errno($fp))
7708 - $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp);
7709 - $this->success = false;
7713 - $info = curl_getinfo($fp);
7715 - $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1);
7716 - $this->headers = array_pop($this->headers);
7717 - $parser = new SimplePie_HTTP_Parser($this->headers);
7718 - if ($parser->parse())
7720 - $this->headers = $parser->headers;
7721 - $this->body = $parser->body;
7722 - $this->status_code = $parser->status_code;
7723 - 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)
7725 - $this->redirects++;
7726 - $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
7727 - return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
7734 - $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
7735 - $url_parts = parse_url($url);
7736 - if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) == 'https')
7738 - $url_parts['host'] = "ssl://$url_parts[host]";
7739 - $url_parts['port'] = 443;
7741 - if (!isset($url_parts['port']))
7743 - $url_parts['port'] = 80;
7746 - $proxy_parts = explode(':', $proxy);
7747 - if (!isset($proxy_parts[1])) {
7748 - $proxy_parts[1] = 80;
7750 - $host = $proxy_parts[0];
7751 - $port = $proxy_parts[1];
7753 - $host = $url_parts['host'];
7754 - $port = $url_parts['port'];
7756 - $fp = @fsockopen($host, $port, $errno, $errstr, $timeout);
7759 - $this->error = 'fsockopen error: ' . $errstr;
7760 - $this->success = false;
7764 - stream_set_timeout($fp, $timeout);
7768 - if (isset($url_parts['path']))
7770 - if (isset($url_parts['query']))
7772 - $get = "$url_parts[path]?$url_parts[query]";
7776 - $get = $url_parts['path'];
7784 - $out = "GET $get HTTP/1.0\r\n";
7785 - $out .= "Host: $url_parts[host]\r\n";
7786 - $out .= "User-Agent: $useragent\r\n";
7787 - if (extension_loaded('zlib'))
7789 - $out .= "Accept-Encoding: x-gzip,gzip,deflate\r\n";
7792 - if (isset($url_parts['user']) && isset($url_parts['pass']))
7794 - $out .= "Authorization: Basic " . base64_encode("$url_parts[user]:$url_parts[pass]") . "\r\n";
7796 - foreach ($headers as $key => $value)
7798 - $out .= "$key: $value\r\n";
7800 - $out .= "Connection: Close\r\n\r\n";
7801 - fwrite($fp, $out);
7803 - $info = stream_get_meta_data($fp);
7805 - $this->headers = '';
7806 - while (!$info['eof'] && !$info['timed_out'])
7808 - $this->headers .= fread($fp, 1160);
7809 - $info = stream_get_meta_data($fp);
7811 - if (!$info['timed_out'])
7813 - $parser = new SimplePie_HTTP_Parser($this->headers);
7814 - if ($parser->parse())
7816 - $this->headers = $parser->headers;
7817 - $this->body = $parser->body;
7818 - $this->status_code = $parser->status_code;
7819 - 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)
7821 - $this->redirects++;
7822 - $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
7823 - return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
7825 - if (isset($this->headers['content-encoding']))
7827 - // Hey, we act dumb elsewhere, so let's do that here too
7828 - switch (strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20")))
7832 - $decoder = new SimplePie_gzdecode($this->body);
7833 - if (!$decoder->parse())
7835 - $this->error = 'Unable to decode HTTP "gzip" stream';
7836 - $this->success = false;
7840 - $this->body = $decoder->data;
7845 - if (($body = gzuncompress($this->body)) === false)
7847 - if (($body = gzinflate($this->body)) === false)
7849 - $this->error = 'Unable to decode HTTP "deflate" stream';
7850 - $this->success = false;
7853 - $this->body = $body;
7857 - $this->error = 'Unknown content coding';
7858 - $this->success = false;
7865 - $this->error = 'fsocket timed out';
7866 - $this->success = false;
7874 - $this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS;
7875 - if (!$this->body = file_get_contents($url))
7877 - $this->error = 'file_get_contents could not read the file';
7878 - $this->success = false;
7885 - * HTTP Response Parser
7887 - * @package SimplePie
7889 -class SimplePie_HTTP_Parser
7897 - var $http_version = 0.0;
7905 - var $status_code = 0;
7916 - * Key/value pairs of the headers
7921 - var $headers = array();
7924 - * Body of the response
7932 - * Current state of the state machine
7937 - var $state = 'http_version';
7948 - * Input data length (to avoid calling strlen() everytime this is needed)
7953 - var $data_length = 0;
7956 - * Current position of the pointer
7961 - var $position = 0;
7964 - * Name of the hedaer currently being parsed
7972 - * Value of the hedaer currently being parsed
7980 - * Create an instance of the class with the input data
7983 - * @param string $data Input data
7985 - function SimplePie_HTTP_Parser($data)
7987 - $this->data = $data;
7988 - $this->data_length = strlen($this->data);
7992 - * Parse the input data
7995 - * @return bool true on success, false on failure
7999 - while ($this->state && $this->state !== 'emit' && $this->has_data())
8001 - $state = $this->state;
8005 - if ($this->state === 'emit' || $this->state === 'body')
8011 - $this->http_version = '';
8012 - $this->status_code = '';
8013 - $this->reason = '';
8014 - $this->headers = array();
8021 - * Check whether there is data beyond the pointer
8024 - * @return bool true if there is further data, false if not
8026 - function has_data()
8028 - return (bool) ($this->position < $this->data_length);
8032 - * See if the next character is LWS
8035 - * @return bool true if the next character is LWS, false if not
8037 - function is_linear_whitespace()
8039 - return (bool) ($this->data[$this->position] === "\x09"
8040 - || $this->data[$this->position] === "\x20"
8041 - || ($this->data[$this->position] === "\x0A"
8042 - && isset($this->data[$this->position + 1])
8043 - && ($this->data[$this->position + 1] === "\x09" || $this->data[$this->position + 1] === "\x20")));
8047 - * Parse the HTTP version
8051 - function http_version()
8053 - if (strpos($this->data, "\x0A") !== false && strtoupper(substr($this->data, 0, 5)) === 'HTTP/')
8055 - $len = strspn($this->data, '0123456789.', 5);
8056 - $this->http_version = substr($this->data, 5, $len);
8057 - $this->position += 5 + $len;
8058 - if (substr_count($this->http_version, '.') <= 1)
8060 - $this->http_version = (float) $this->http_version;
8061 - $this->position += strspn($this->data, "\x09\x20", $this->position);
8062 - $this->state = 'status';
8066 - $this->state = false;
8071 - $this->state = false;
8076 - * Parse the status code
8082 - if ($len = strspn($this->data, '0123456789', $this->position))
8084 - $this->status_code = (int) substr($this->data, $this->position, $len);
8085 - $this->position += $len;
8086 - $this->state = 'reason';
8090 - $this->state = false;
8095 - * Parse the reason phrase
8101 - $len = strcspn($this->data, "\x0A", $this->position);
8102 - $this->reason = trim(substr($this->data, $this->position, $len), "\x09\x0D\x20");
8103 - $this->position += $len + 1;
8104 - $this->state = 'new_line';
8108 - * Deal with a new line, shifting data around as needed
8112 - function new_line()
8114 - $this->value = trim($this->value, "\x0D\x20");
8115 - if ($this->name !== '' && $this->value !== '')
8117 - $this->name = strtolower($this->name);
8118 - if (isset($this->headers[$this->name]))
8120 - $this->headers[$this->name] .= ', ' . $this->value;
8124 - $this->headers[$this->name] = $this->value;
8128 - $this->value = '';
8129 - if (substr($this->data[$this->position], 0, 2) === "\x0D\x0A")
8131 - $this->position += 2;
8132 - $this->state = 'body';
8134 - elseif ($this->data[$this->position] === "\x0A")
8136 - $this->position++;
8137 - $this->state = 'body';
8141 - $this->state = 'name';
8146 - * Parse a header name
8152 - $len = strcspn($this->data, "\x0A:", $this->position);
8153 - if (isset($this->data[$this->position + $len]))
8155 - if ($this->data[$this->position + $len] === "\x0A")
8157 - $this->position += $len;
8158 - $this->state = 'new_line';
8162 - $this->name = substr($this->data, $this->position, $len);
8163 - $this->position += $len + 1;
8164 - $this->state = 'value';
8169 - $this->state = false;
8174 - * Parse LWS, replacing consecutive LWS characters with a single space
8178 - function linear_whitespace()
8182 - if (substr($this->data, $this->position, 2) === "\x0D\x0A")
8184 - $this->position += 2;
8186 - elseif ($this->data[$this->position] === "\x0A")
8188 - $this->position++;
8190 - $this->position += strspn($this->data, "\x09\x20", $this->position);
8191 - } while ($this->has_data() && $this->is_linear_whitespace());
8192 - $this->value .= "\x20";
8196 - * See what state to move to while within non-quoted header values
8202 - if ($this->is_linear_whitespace())
8204 - $this->linear_whitespace();
8208 - switch ($this->data[$this->position])
8211 - $this->position++;
8212 - $this->state = 'quote';
8216 - $this->position++;
8217 - $this->state = 'new_line';
8221 - $this->state = 'value_char';
8228 - * Parse a header value while outside quotes
8232 - function value_char()
8234 - $len = strcspn($this->data, "\x09\x20\x0A\"", $this->position);
8235 - $this->value .= substr($this->data, $this->position, $len);
8236 - $this->position += $len;
8237 - $this->state = 'value';
8241 - * See what state to move to while within quoted header values
8247 - if ($this->is_linear_whitespace())
8249 - $this->linear_whitespace();
8253 - switch ($this->data[$this->position])
8256 - $this->position++;
8257 - $this->state = 'value';
8261 - $this->position++;
8262 - $this->state = 'new_line';
8266 - $this->position++;
8267 - $this->state = 'quote_escaped';
8271 - $this->state = 'quote_char';
8278 - * Parse a header value while within quotes
8282 - function quote_char()
8284 - $len = strcspn($this->data, "\x09\x20\x0A\"\\", $this->position);
8285 - $this->value .= substr($this->data, $this->position, $len);
8286 - $this->position += $len;
8287 - $this->state = 'value';
8291 - * Parse an escaped character within quotes
8295 - function quote_escaped()
8297 - $this->value .= $this->data[$this->position];
8298 - $this->position++;
8299 - $this->state = 'quote';
8309 - $this->body = substr($this->data, $this->position);
8310 - $this->state = 'emit';
8317 - * @package SimplePie
8319 -class SimplePie_gzdecode
8325 - * @see gzdecode::$data
8327 - var $compressed_data;
8330 - * Size of compressed data
8334 - var $compressed_size;
8337 - * Minimum size of a valid gzip string
8341 - var $min_compressed_size = 18;
8344 - * Current position of pointer
8348 - var $position = 0;
8358 - * Uncompressed data
8361 - * @see gzdecode::$compressed_data
8380 - * Operating System
8390 - * @see gzdecode::$extra_field
8391 - * @see gzdecode::$SI2
8399 - * @see gzdecode::$extra_field
8400 - * @see gzdecode::$SI1
8405 - * Extra field content
8408 - * @see gzdecode::$SI1
8409 - * @see gzdecode::$SI2
8414 - * Original filename
8421 - * Human readable comment
8428 - * Don't allow anything to be set
8432 - function __set($name, $value)
8434 - trigger_error("Cannot write property $name", E_USER_ERROR);
8438 - * Set the compressed string and related properties
8442 - function SimplePie_gzdecode($data)
8444 - $this->compressed_data = $data;
8445 - $this->compressed_size = strlen($data);
8449 - * Decode the GZIP stream
8455 - if ($this->compressed_size >= $this->min_compressed_size)
8457 - // Check ID1, ID2, and CM
8458 - if (substr($this->compressed_data, 0, 3) !== "\x1F\x8B\x08")
8463 - // Get the FLG (FLaGs)
8464 - $this->flags = ord($this->compressed_data[3]);
8466 - // FLG bits above (1 << 4) are reserved
8467 - if ($this->flags > 0x1F)
8472 - // Advance the pointer after the above
8473 - $this->position += 4;
8476 - $mtime = substr($this->compressed_data, $this->position, 4);
8477 - // Reverse the string if we're on a big-endian arch because l is the only signed long and is machine endianness
8478 - if (current(unpack('S', "\x00\x01")) === 1)
8480 - $mtime = strrev($mtime);
8482 - $this->MTIME = current(unpack('l', $mtime));
8483 - $this->position += 4;
8485 - // Get the XFL (eXtra FLags)
8486 - $this->XFL = ord($this->compressed_data[$this->position++]);
8488 - // Get the OS (Operating System)
8489 - $this->OS = ord($this->compressed_data[$this->position++]);
8491 - // Parse the FEXTRA
8492 - if ($this->flags & 4)
8494 - // Read subfield IDs
8495 - $this->SI1 = $this->compressed_data[$this->position++];
8496 - $this->SI2 = $this->compressed_data[$this->position++];
8498 - // SI2 set to zero is reserved for future use
8499 - if ($this->SI2 === "\x00")
8504 - // Get the length of the extra field
8505 - $len = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
8508 - // Check the length of the string is still valid
8509 - $this->min_compressed_size += $len + 4;
8510 - if ($this->compressed_size >= $this->min_compressed_size)
8512 - // Set the extra field to the given data
8513 - $this->extra_field = substr($this->compressed_data, $this->position, $len);
8514 - $this->position += $len;
8522 - // Parse the FNAME
8523 - if ($this->flags & 8)
8525 - // Get the length of the filename
8526 - $len = strspn($this->compressed_data, "\x00", $this->position);
8528 - // Check the length of the string is still valid
8529 - $this->min_compressed_size += $len + 1;
8530 - if ($this->compressed_size >= $this->min_compressed_size)
8532 - // Set the original filename to the given string
8533 - $this->filename = substr($this->compressed_data, $this->position, $len);
8534 - $this->position += $len + 1;
8542 - // Parse the FCOMMENT
8543 - if ($this->flags & 16)
8545 - // Get the length of the comment
8546 - $len = strspn($this->compressed_data, "\x00", $this->position);
8548 - // Check the length of the string is still valid
8549 - $this->min_compressed_size += $len + 1;
8550 - if ($this->compressed_size >= $this->min_compressed_size)
8552 - // Set the original comment to the given string
8553 - $this->comment = substr($this->compressed_data, $this->position, $len);
8554 - $this->position += $len + 1;
8562 - // Parse the FHCRC
8563 - if ($this->flags & 2)
8565 - // Check the length of the string is still valid
8566 - $this->min_compressed_size += $len + 2;
8567 - if ($this->compressed_size >= $this->min_compressed_size)
8570 - $crc = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
8572 - // Check the CRC matches
8573 - if ((crc32(substr($this->compressed_data, 0, $this->position)) & 0xFFFF) === $crc)
8575 - $this->position += 2;
8588 - // Decompress the actual data
8589 - if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false)
8595 - $this->position = $this->compressed_size - 8;
8598 - // Check CRC of data
8599 - $crc = current(unpack('V', substr($this->compressed_data, $this->position, 4)));
8600 - $this->position += 4;
8601 - /*if (extension_loaded('hash') && sprintf('%u', current(unpack('V', hash('crc32b', $this->data)))) !== sprintf('%u', $crc))
8606 - // Check ISIZE of data
8607 - $isize = current(unpack('V', substr($this->compressed_data, $this->position, 4)));
8608 - $this->position += 4;
8609 - if (sprintf('%u', strlen($this->data) & 0xFFFFFFFF) !== sprintf('%u', $isize))
8614 - // Wow, against all odds, we've actually got a valid gzip string
8624 -class SimplePie_Cache
8627 - * Don't call the constructor. Please.
8631 - function SimplePie_Cache()
8633 - trigger_error('Please call SimplePie_Cache::create() instead of the constructor', E_USER_ERROR);
8637 - * Create a new SimplePie_Cache object
8642 - static function create($location, $filename, $extension)
8644 - return new SimplePie_Cache_File($location, $filename, $extension);
8648 -class SimplePie_Cache_File
8655 - function SimplePie_Cache_File($location, $filename, $extension)
8657 - $this->location = $location;
8658 - $this->filename = rawurlencode($filename);
8659 - $this->extension = rawurlencode($extension);
8660 - $this->name = "$location/$this->filename.$this->extension";
8663 - function save($data)
8665 - if (file_exists($this->name) && is_writeable($this->name) || file_exists($this->location) && is_writeable($this->location))
8667 - if (is_a($data, 'SimplePie'))
8669 - $data = $data->data;
8672 - $data = serialize($data);
8674 - if (function_exists('file_put_contents'))
8676 - return (bool) file_put_contents($this->name, $data);
8680 - $fp = fopen($this->name, 'wb');
8683 - fwrite($fp, $data);
8694 - if (file_exists($this->name) && is_readable($this->name))
8696 - return unserialize(file_get_contents($this->name));
8703 - if (file_exists($this->name))
8705 - return filemtime($this->name);
8712 - if (file_exists($this->name))
8714 - return touch($this->name);
8721 - if (file_exists($this->name))
8723 - return unlink($this->name);
8729 -class SimplePie_Misc
8731 - function time_hms($seconds)
8735 - $hours = floor($seconds / 3600);
8736 - $remainder = $seconds % 3600;
8739 - $time .= $hours.':';
8742 - $minutes = floor($remainder / 60);
8743 - $seconds = $remainder % 60;
8744 - if ($minutes < 10 && $hours > 0)
8746 - $minutes = '0' . $minutes;
8748 - if ($seconds < 10)
8750 - $seconds = '0' . $seconds;
8753 - $time .= $minutes.':';
8754 - $time .= $seconds;
8759 - static function absolutize_url($relative, $base)
8761 - if ($relative !== '')
8763 - $relative = SimplePie_Misc::parse_url($relative);
8764 - if ($relative['scheme'] !== '')
8766 - $target = $relative;
8768 - elseif ($base !== '')
8770 - $base = SimplePie_Misc::parse_url($base);
8771 - $target = SimplePie_Misc::parse_url('');
8772 - if ($relative['authority'] !== '')
8774 - $target = $relative;
8775 - $target['scheme'] = $base['scheme'];
8779 - $target['scheme'] = $base['scheme'];
8780 - $target['authority'] = $base['authority'];
8781 - if ($relative['path'] !== '')
8783 - if (strpos($relative['path'], '/') === 0)
8785 - $target['path'] = $relative['path'];
8787 - elseif ($base['authority'] !== '' && $base['path'] === '')
8789 - $target['path'] = '/' . $relative['path'];
8791 - elseif (($last_segment = strrpos($base['path'], '/')) !== false)
8793 - $target['path'] = substr($base['path'], 0, $last_segment + 1) . $relative['path'];
8797 - $target['path'] = $relative['path'];
8799 - $target['query'] = $relative['query'];
8803 - $target['path'] = $base['path'];
8804 - if ($relative['query'] !== '')
8806 - $target['query'] = $relative['query'];
8808 - elseif ($base['query'] !== '')
8810 - $target['query'] = $base['query'];
8814 - $target['fragment'] = $relative['fragment'];
8818 - // No base URL, just return the relative URL
8819 - $target = $relative;
8821 - $return = SimplePie_Misc::compress_parse_url($target['scheme'], $target['authority'], $target['path'], $target['query'], $target['fragment']);
8827 - $return = SimplePie_Misc::normalize_url($return);
8831 - static function remove_dot_segments($input)
8834 - while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input == '.' || $input == '..')
8836 - // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise,
8837 - if (strpos($input, '../') === 0)
8839 - $input = substr($input, 3);
8841 - elseif (strpos($input, './') === 0)
8843 - $input = substr($input, 2);
8845 - // B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise,
8846 - elseif (strpos($input, '/./') === 0)
8848 - $input = substr_replace($input, '/', 0, 3);
8850 - elseif ($input == '/.')
8854 - // C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise,
8855 - elseif (strpos($input, '/../') === 0)
8857 - $input = substr_replace($input, '/', 0, 4);
8858 - $output = substr_replace($output, '', strrpos($output, '/'));
8860 - elseif ($input == '/..')
8863 - $output = substr_replace($output, '', strrpos($output, '/'));
8865 - // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise,
8866 - elseif ($input == '.' || $input == '..')
8870 - // E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer
8871 - elseif (($pos = strpos($input, '/', 1)) !== false)
8873 - $output .= substr($input, 0, $pos);
8874 - $input = substr_replace($input, '', 0, $pos);
8878 - $output .= $input;
8882 - return $output . $input;
8885 - static function get_element($realname, $string)
8887 - $return = array();
8888 - $name = preg_quote($realname, '/');
8889 - if (preg_match_all("/<($name)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE))
8891 - for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++)
8893 - $return[$i]['tag'] = $realname;
8894 - $return[$i]['full'] = $matches[$i][0][0];
8895 - $return[$i]['offset'] = $matches[$i][0][1];
8896 - if (strlen($matches[$i][3][0]) <= 2)
8898 - $return[$i]['self_closing'] = true;
8902 - $return[$i]['self_closing'] = false;
8903 - $return[$i]['content'] = $matches[$i][4][0];
8905 - $return[$i]['attribs'] = array();
8906 - if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER))
8908 - for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++)
8910 - if (count($attribs[$j]) == 2)
8912 - $attribs[$j][2] = $attribs[$j][1];
8914 - $return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = SimplePie_Misc::entities_decode(end($attribs[$j]), 'UTF-8');
8922 - function element_implode($element)
8924 - $full = "<$element[tag]";
8925 - foreach ($element['attribs'] as $key => $value)
8927 - $key = strtolower($key);
8928 - $full .= " $key=\"" . htmlspecialchars($value['data']) . '"';
8930 - if ($element['self_closing'])
8936 - $full .= ">$element[content]</$element[tag]>";
8941 - static function error($message, $level, $file, $line)
8945 - case E_USER_ERROR:
8946 - $note = 'PHP Error';
8948 - case E_USER_WARNING:
8949 - $note = 'PHP Warning';
8951 - case E_USER_NOTICE:
8952 - $note = 'PHP Notice';
8955 - $note = 'Unknown Error';
8958 - error_log("$note: $message in $file on line $line", 0);
8963 - * If a file has been cached, retrieve and display it.
8965 - * This is most useful for caching images (get_favicon(), etc.),
8966 - * however it works for all cached files. This WILL NOT display ANY
8967 - * file/image/page/whatever, but rather only display what has already
8968 - * been cached by SimplePie.
8971 - * @see SimplePie::get_favicon()
8972 - * @param str $identifier_url URL that is used to identify the content.
8973 - * This may or may not be the actual URL of the live content.
8974 - * @param str $cache_location Location of SimplePie's cache. Defaults
8976 - * @param str $cache_extension The file extension that the file was
8977 - * cached with. Defaults to 'spc'.
8978 - * @param str $cache_class Name of the cache-handling class being used
8979 - * in SimplePie. Defaults to 'SimplePie_Cache', and should be left
8980 - * as-is unless you've overloaded the class.
8981 - * @param str $cache_name_function Obsolete. Exists for backwards
8982 - * compatibility reasons only.
8984 - function display_cached_file($identifier_url, $cache_location = './cache', $cache_extension = 'spc', $cache_class = 'SimplePie_Cache', $cache_name_function = 'md5')
8986 - $cache = call_user_func(array($cache_class, 'create'), $cache_location, $identifier_url, $cache_extension);
8988 - if ($file = $cache->load())
8990 - if (isset($file['headers']['content-type']))
8992 - header('Content-type:' . $file['headers']['content-type']);
8996 - header('Content-type: application/octet-stream');
8998 - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
8999 - echo $file['body'];
9003 - die('Cached file for ' . $identifier_url . ' cannot be found.');
9006 - static function fix_protocol($url, $http = 1)
9008 - $url = SimplePie_Misc::normalize_url($url);
9009 - $parsed = SimplePie_Misc::parse_url($url);
9010 - if ($parsed['scheme'] !== '' && $parsed['scheme'] != 'http' && $parsed['scheme'] != 'https')
9012 - return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http);
9015 - if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url))
9017 - return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http);
9020 - if ($http == 2 && $parsed['scheme'] !== '')
9022 - return "feed:$url";
9024 - elseif ($http == 3 && strtolower($parsed['scheme']) == 'http')
9026 - return substr_replace($url, 'podcast', 0, 4);
9028 - elseif ($http == 4 && strtolower($parsed['scheme']) == 'http')
9030 - return substr_replace($url, 'itpc', 0, 4);
9038 - static function parse_url($url)
9040 - static $cache = array();
9041 - if (isset($cache[$url]))
9043 - return $cache[$url];
9045 - elseif (preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/', $url, $match))
9047 - for ($i = count($match); $i <= 9; $i++)
9051 - return $cache[$url] = array('scheme' => $match[2], 'authority' => $match[4], 'path' => $match[5], 'query' => $match[7], 'fragment' => $match[9]);
9055 - return $cache[$url] = array('scheme' => '', 'authority' => '', 'path' => '', 'query' => '', 'fragment' => '');
9059 - static function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '')
9062 - if ($scheme !== '')
9064 - $return .= "$scheme:";
9066 - if ($authority !== '')
9068 - $return .= "//$authority";
9074 - if ($query !== '')
9076 - $return .= "?$query";
9078 - if ($fragment !== '')
9080 - $return .= "#$fragment";
9085 - static function normalize_url($url)
9087 - $url = preg_replace_callback('/%([0-9A-Fa-f]{2})/', array('SimplePie_Misc', 'percent_encoding_normalization'), $url);
9088 - $url = SimplePie_Misc::parse_url($url);
9089 - $url['scheme'] = strtolower($url['scheme']);
9090 - if ($url['authority'] !== '')
9092 - $url['authority'] = strtolower($url['authority']);
9093 - $url['path'] = SimplePie_Misc::remove_dot_segments($url['path']);
9095 - return SimplePie_Misc::compress_parse_url($url['scheme'], $url['authority'], $url['path'], $url['query'], $url['fragment']);
9098 - static function percent_encoding_normalization($match)
9100 - $integer = hexdec($match[1]);
9101 - if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer == 0x2D || $integer == 0x2E || $integer == 0x5F || $integer == 0x7E)
9103 - return chr($integer);
9107 - return strtoupper($match[0]);
9112 - * Remove bad UTF-8 bytes
9114 - * PCRE Pattern to locate bad bytes in a UTF-8 string comes from W3C
9115 - * FAQ: Multilingual Forms (modified to include full ASCII range)
9117 - * @author Geoffrey Sneddon
9118 - * @see http://www.w3.org/International/questions/qa-forms-utf-8
9119 - * @param string $str String to remove bad UTF-8 bytes from
9120 - * @return string UTF-8 string
9122 - function utf8_bad_replace($str)
9124 - if (function_exists('iconv') && ($return = @iconv('UTF-8', 'UTF-8//IGNORE', $str)))
9128 - elseif (function_exists('mb_convert_encoding') && ($return = @mb_convert_encoding($str, 'UTF-8', 'UTF-8')))
9132 - elseif (preg_match_all('/(?:[\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})+/', $str, $matches))
9134 - return implode("\xEF\xBF\xBD", $matches[0]);
9136 - elseif ($str !== '')
9138 - return "\xEF\xBF\xBD";
9147 - * Converts a Windows-1252 encoded string to a UTF-8 encoded string
9151 - * @param string $string Windows-1252 encoded string
9152 - * @return string UTF-8 encoded string
9154 - static function windows_1252_to_utf8($string)
9156 - static $convert_table = array("\x80" => "\xE2\x82\xAC", "\x81" => "\xEF\xBF\xBD", "\x82" => "\xE2\x80\x9A", "\x83" => "\xC6\x92", "\x84" => "\xE2\x80\x9E", "\x85" => "\xE2\x80\xA6", "\x86" => "\xE2\x80\xA0", "\x87" => "\xE2\x80\xA1", "\x88" => "\xCB\x86", "\x89" => "\xE2\x80\xB0", "\x8A" => "\xC5\xA0", "\x8B" => "\xE2\x80\xB9", "\x8C" => "\xC5\x92", "\x8D" => "\xEF\xBF\xBD", "\x8E" => "\xC5\xBD", "\x8F" => "\xEF\xBF\xBD", "\x90" => "\xEF\xBF\xBD", "\x91" => "\xE2\x80\x98", "\x92" => "\xE2\x80\x99", "\x93" => "\xE2\x80\x9C", "\x94" => "\xE2\x80\x9D", "\x95" => "\xE2\x80\xA2", "\x96" => "\xE2\x80\x93", "\x97" => "\xE2\x80\x94", "\x98" => "\xCB\x9C", "\x99" => "\xE2\x84\xA2", "\x9A" => "\xC5\xA1", "\x9B" => "\xE2\x80\xBA", "\x9C" => "\xC5\x93", "\x9D" => "\xEF\xBF\xBD", "\x9E" => "\xC5\xBE", "\x9F" => "\xC5\xB8", "\xA0" => "\xC2\xA0", "\xA1" => "\xC2\xA1", "\xA2" => "\xC2\xA2", "\xA3" => "\xC2\xA3", "\xA4" => "\xC2\xA4", "\xA5" => "\xC2\xA5", "\xA6" => "\xC2\xA6", "\xA7" => "\xC2\xA7", "\xA8" => "\xC2\xA8", "\xA9" => "\xC2\xA9", "\xAA" => "\xC2\xAA", "\xAB" => "\xC2\xAB", "\xAC" => "\xC2\xAC", "\xAD" => "\xC2\xAD", "\xAE" => "\xC2\xAE", "\xAF" => "\xC2\xAF", "\xB0" => "\xC2\xB0", "\xB1" => "\xC2\xB1", "\xB2" => "\xC2\xB2", "\xB3" => "\xC2\xB3", "\xB4" => "\xC2\xB4", "\xB5" => "\xC2\xB5", "\xB6" => "\xC2\xB6", "\xB7" => "\xC2\xB7", "\xB8" => "\xC2\xB8", "\xB9" => "\xC2\xB9", "\xBA" => "\xC2\xBA", "\xBB" => "\xC2\xBB", "\xBC" => "\xC2\xBC", "\xBD" => "\xC2\xBD", "\xBE" => "\xC2\xBE", "\xBF" => "\xC2\xBF", "\xC0" => "\xC3\x80", "\xC1" => "\xC3\x81", "\xC2" => "\xC3\x82", "\xC3" => "\xC3\x83", "\xC4" => "\xC3\x84", "\xC5" => "\xC3\x85", "\xC6" => "\xC3\x86", "\xC7" => "\xC3\x87", "\xC8" => "\xC3\x88", "\xC9" => "\xC3\x89", "\xCA" => "\xC3\x8A", "\xCB" => "\xC3\x8B", "\xCC" => "\xC3\x8C", "\xCD" => "\xC3\x8D", "\xCE" => "\xC3\x8E", "\xCF" => "\xC3\x8F", "\xD0" => "\xC3\x90", "\xD1" => "\xC3\x91", "\xD2" => "\xC3\x92", "\xD3" => "\xC3\x93", "\xD4" => "\xC3\x94", "\xD5" => "\xC3\x95", "\xD6" => "\xC3\x96", "\xD7" => "\xC3\x97", "\xD8" => "\xC3\x98", "\xD9" => "\xC3\x99", "\xDA" => "\xC3\x9A", "\xDB" => "\xC3\x9B", "\xDC" => "\xC3\x9C", "\xDD" => "\xC3\x9D", "\xDE" => "\xC3\x9E", "\xDF" => "\xC3\x9F", "\xE0" => "\xC3\xA0", "\xE1" => "\xC3\xA1", "\xE2" => "\xC3\xA2", "\xE3" => "\xC3\xA3", "\xE4" => "\xC3\xA4", "\xE5" => "\xC3\xA5", "\xE6" => "\xC3\xA6", "\xE7" => "\xC3\xA7", "\xE8" => "\xC3\xA8", "\xE9" => "\xC3\xA9", "\xEA" => "\xC3\xAA", "\xEB" => "\xC3\xAB", "\xEC" => "\xC3\xAC", "\xED" => "\xC3\xAD", "\xEE" => "\xC3\xAE", "\xEF" => "\xC3\xAF", "\xF0" => "\xC3\xB0", "\xF1" => "\xC3\xB1", "\xF2" => "\xC3\xB2", "\xF3" => "\xC3\xB3", "\xF4" => "\xC3\xB4", "\xF5" => "\xC3\xB5", "\xF6" => "\xC3\xB6", "\xF7" => "\xC3\xB7", "\xF8" => "\xC3\xB8", "\xF9" => "\xC3\xB9", "\xFA" => "\xC3\xBA", "\xFB" => "\xC3\xBB", "\xFC" => "\xC3\xBC", "\xFD" => "\xC3\xBD", "\xFE" => "\xC3\xBE", "\xFF" => "\xC3\xBF");
9158 - return strtr($string, $convert_table);
9161 - static function change_encoding($data, $input, $output)
9163 - $input = SimplePie_Misc::encoding($input);
9164 - $output = SimplePie_Misc::encoding($output);
9166 - // We fail to fail on non US-ASCII bytes
9167 - if ($input === 'US-ASCII')
9169 - static $non_ascii_octects = '';
9170 - if (!$non_ascii_octects)
9172 - for ($i = 0x80; $i <= 0xFF; $i++)
9174 - $non_ascii_octects .= chr($i);
9177 - $data = substr($data, 0, strcspn($data, $non_ascii_octects));
9180 - // This is first, as behaviour of this is completely predictable
9181 - if ($input === 'Windows-1252' && $output === 'UTF-8')
9183 - return SimplePie_Misc::windows_1252_to_utf8($data);
9185 - // This is second, as behaviour of this varies only with PHP version
9186 - elseif (function_exists('mb_convert_encoding') && ($return = @mb_convert_encoding($data, $output, $input)))
9190 - // This is last, as behaviour of this varies with OS userland and PHP version
9191 - elseif (function_exists('iconv') && ($return = @iconv($input, $output, $data)))
9195 - // If we can't do anything, just fail
9202 - static function encoding($charset)
9204 - /* Character sets are case-insensitive, and also need some further
9205 - normalization in the real world (though we'll return them in the form given
9206 - in their registration). */
9207 - switch (strtolower(preg_replace('/[\x09-\x0D\x20-\x2F\x3A-\x40\x5B-\x60\x7B-\x7E]/', '', $charset)))
9209 - case 'adobestandardencoding':
9210 - case 'csadobestandardencoding':
9211 - return 'Adobe-Standard-Encoding';
9213 - case 'adobesymbolencoding':
9214 - case 'cshppsmath':
9215 - return 'Adobe-Symbol-Encoding';
9221 - return 'Amiga-1251';
9223 - case 'ansix31101983':
9224 - case 'csat5001983':
9225 - case 'csiso99naplps':
9228 - return 'ANSI_X3.110-1983';
9232 - case 'csiso89asmo449':
9235 - return 'ASMO_449';
9243 - return 'Big5-HKSCS';
9254 - case 'csiso4unitedkingdom':
9261 - case 'bsviewdata':
9262 - case 'csiso47bsviewdata':
9264 - return 'BS_viewdata';
9272 - case 'csaz243419851':
9273 - case 'csiso121canadian1':
9276 - return 'CSA_Z243.4-1985-1';
9279 - case 'csaz243419852':
9280 - case 'csiso122canadian2':
9283 - return 'CSA_Z243.4-1985-2';
9285 - case 'csaz24341985gr':
9286 - case 'csiso123csaz24341985gr':
9288 - return 'CSA_Z243.4-1985-gr';
9290 - case 'csiso139csn369103':
9293 - return 'CSN_369103';
9300 - case 'csiso21german':
9305 - return 'DIN_66003';
9311 - case 'csiso646danish':
9318 - case 'csibmebcdicatde':
9319 - case 'ebcdicatde':
9320 - return 'EBCDIC-AT-DE';
9322 - case 'csebcdicatdea':
9323 - case 'ebcdicatdea':
9324 - return 'EBCDIC-AT-DE-A';
9326 - case 'csebcdiccafr':
9327 - case 'ebcdiccafr':
9328 - return 'EBCDIC-CA-FR';
9330 - case 'csebcdicdkno':
9331 - case 'ebcdicdkno':
9332 - return 'EBCDIC-DK-NO';
9334 - case 'csebcdicdknoa':
9335 - case 'ebcdicdknoa':
9336 - return 'EBCDIC-DK-NO-A';
9338 - case 'csebcdices':
9340 - return 'EBCDIC-ES';
9342 - case 'csebcdicesa':
9344 - return 'EBCDIC-ES-A';
9346 - case 'csebcdicess':
9348 - return 'EBCDIC-ES-S';
9350 - case 'csebcdicfise':
9351 - case 'ebcdicfise':
9352 - return 'EBCDIC-FI-SE';
9354 - case 'csebcdicfisea':
9355 - case 'ebcdicfisea':
9356 - return 'EBCDIC-FI-SE-A';
9358 - case 'csebcdicfr':
9360 - return 'EBCDIC-FR';
9362 - case 'csebcdicit':
9364 - return 'EBCDIC-IT';
9366 - case 'csebcdicpt':
9368 - return 'EBCDIC-PT';
9370 - case 'csebcdicuk':
9372 - return 'EBCDIC-UK';
9374 - case 'csebcdicus':
9376 - return 'EBCDIC-US';
9378 - case 'csiso111ecmacyrillic':
9379 - case 'ecmacyrillic':
9382 - return 'ECMA-cyrillic';
9384 - case 'csiso17spanish':
9390 - case 'csiso85spanish2':
9396 - case 'cseucfixwidjapanese':
9397 - case 'extendedunixcodefixedwidthforjapanese':
9398 - return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
9400 - case 'cseucpkdfmtjapanese':
9402 - case 'extendedunixcodepackedformatforjapanese':
9403 - return 'Extended_UNIX_Code_Packed_Format_for_Japanese';
9411 - case 'windows936':
9415 - case 'csiso58gb231280':
9421 - case 'csiso57gb1988':
9425 - return 'GB_1988-80';
9427 - case 'csiso153gost1976874':
9428 - case 'gost1976874':
9430 - case 'stsev35888':
9431 - return 'GOST_19768-74';
9434 - case 'csiso150greekccitt':
9435 - case 'greekccitt':
9437 - return 'greek-ccitt';
9439 - case 'csiso88greek7':
9444 - case 'csiso18greek7old':
9447 - return 'greek7-old';
9449 - case 'cshpdesktop':
9451 - return 'HP-DeskTop';
9455 - return 'HP-Legal';
9459 - return 'HP-Math8';
9461 - case 'cshppifont':
9463 - return 'HP-Pi-font';
9465 - case 'cshproman8':
9469 - return 'hp-roman8';
9472 - return 'HZ-GB-2312';
9474 - case 'csibmsymbols':
9475 - case 'ibmsymbols':
9476 - return 'IBM-Symbols';
9480 - return 'IBM-Thai';
9482 - case 'ccsid00858':
9485 - case 'pcmultilingual850euro':
9486 - return 'IBM00858';
9488 - case 'ccsid00924':
9490 - case 'ebcdiclatin9euro':
9492 - return 'IBM00924';
9494 - case 'ccsid01140':
9496 - case 'ebcdicus37euro':
9498 - return 'IBM01140';
9500 - case 'ccsid01141':
9502 - case 'ebcdicde273euro':
9504 - return 'IBM01141';
9506 - case 'ccsid01142':
9508 - case 'ebcdicdk277euro':
9509 - case 'ebcdicno277euro':
9511 - return 'IBM01142';
9513 - case 'ccsid01143':
9515 - case 'ebcdicfi278euro':
9516 - case 'ebcdicse278euro':
9518 - return 'IBM01143';
9520 - case 'ccsid01144':
9522 - case 'ebcdicit280euro':
9524 - return 'IBM01144';
9526 - case 'ccsid01145':
9528 - case 'ebcdices284euro':
9530 - return 'IBM01145';
9532 - case 'ccsid01146':
9534 - case 'ebcdicgb285euro':
9536 - return 'IBM01146';
9538 - case 'ccsid01147':
9540 - case 'ebcdicfr297euro':
9542 - return 'IBM01147';
9544 - case 'ccsid01148':
9546 - case 'ebcdicinternational500euro':
9548 - return 'IBM01148';
9550 - case 'ccsid01149':
9552 - case 'ebcdicis871euro':
9554 - return 'IBM01149';
9558 - case 'ebcdiccpca':
9559 - case 'ebcdiccpnl':
9560 - case 'ebcdiccpus':
9561 - case 'ebcdiccpwt':
9589 - case 'ebcdiccpdk':
9590 - case 'ebcdiccpno':
9596 - case 'ebcdiccpfi':
9597 - case 'ebcdiccpse':
9603 - case 'ebcdiccpit':
9615 - case 'ebcdiccpes':
9621 - case 'ebcdiccpgb':
9627 - case 'ebcdicjpkana':
9633 - case 'ebcdiccpfr':
9639 - case 'ebcdiccpar1':
9645 - case 'ebcdiccpgr':
9651 - case 'ebcdiccphe':
9657 - case 'cspc8codepage437':
9663 - case 'ebcdiccpbe':
9664 - case 'ebcdiccpch':
9669 - case 'cspc775baltic':
9675 - case 'cspc850multilingual':
9718 - case 'cspc862latinhebrew':
9760 - case 'ebcdiccproece':
9761 - case 'ebcdiccpyu':
9767 - case 'ebcdiccpis':
9773 - case 'ebcdiccyrillic':
9795 - case 'ebcdiccptr':
9801 - case 'ebcdiccpar2':
9814 - case 'csiso143iecp271':
9817 - return 'IEC_P27-1';
9819 - case 'csiso49inis':
9824 - case 'csiso50inis8':
9829 - case 'csiso51iniscyrillic':
9830 - case 'iniscyrillic':
9832 - return 'INIS-cyrillic';
9834 - case 'csinvariant':
9836 - return 'INVARIANT';
9839 - return 'ISO-2022-CN';
9841 - case 'iso2022cnext':
9842 - return 'ISO-2022-CN-EXT';
9844 - case 'csiso2022jp':
9846 - return 'ISO-2022-JP';
9848 - case 'csiso2022jp2':
9849 - case 'iso2022jp2':
9850 - return 'ISO-2022-JP-2';
9852 - case 'csiso2022kr':
9854 - return 'ISO-2022-KR';
9856 - case 'cswindows30latin1':
9857 - case 'iso88591windows30latin1':
9858 - return 'ISO-8859-1-Windows-3.0-Latin-1';
9860 - case 'cswindows31latin1':
9861 - case 'iso88591windows31latin1':
9862 - return 'ISO-8859-1-Windows-3.1-Latin-1';
9864 - case 'csisolatin2':
9868 - case 'iso885921987':
9871 - return 'ISO-8859-2';
9873 - case 'cswindows31latin2':
9874 - case 'iso88592windowslatin2':
9875 - return 'ISO-8859-2-Windows-Latin-2';
9877 - case 'csisolatin3':
9881 - case 'iso885931988':
9884 - return 'ISO-8859-3';
9886 - case 'csisolatin4':
9890 - case 'iso885941988':
9893 - return 'ISO-8859-4';
9895 - case 'csisolatincyrillic':
9900 - case 'iso885951988':
9901 - return 'ISO-8859-5';
9905 - case 'csisolatinarabic':
9910 - case 'iso885961987':
9911 - return 'ISO-8859-6';
9913 - case 'csiso88596e':
9916 - return 'ISO-8859-6-E';
9918 - case 'csiso88596i':
9921 - return 'ISO-8859-6-I';
9923 - case 'csisolatingreek':
9931 - case 'iso885971987':
9932 - return 'ISO-8859-7';
9934 - case 'csisolatinhebrew':
9939 - case 'iso885981988':
9940 - return 'ISO-8859-8';
9942 - case 'csiso88598e':
9945 - return 'ISO-8859-8-E';
9947 - case 'csiso88598i':
9950 - return 'ISO-8859-8-I';
9952 - case 'cswindows31latin5':
9953 - case 'iso88599windowslatin5':
9954 - return 'ISO-8859-9-Windows-Latin-5';
9956 - case 'csisolatin6':
9959 - case 'iso8859101992':
9962 - return 'ISO-8859-10';
9965 - return 'ISO-8859-13';
9971 - case 'iso8859141998':
9974 - return 'ISO-8859-14';
9979 - return 'ISO-8859-15';
9984 - case 'iso8859162001':
9987 - return 'ISO-8859-16';
9989 - case 'iso10646j1':
9990 - return 'ISO-10646-J-1';
9993 - case 'iso10646ucs2':
9994 - return 'ISO-10646-UCS-2';
9997 - case 'iso10646ucs4':
9998 - return 'ISO-10646-UCS-4';
10000 - case 'csunicodeascii':
10001 - case 'iso10646ucsbasic':
10002 - return 'ISO-10646-UCS-Basic';
10004 - case 'csunicodelatin1':
10006 - case 'iso10646unicodelatin1':
10007 - return 'ISO-10646-Unicode-Latin1';
10009 - case 'csiso10646utf1':
10010 - case 'iso10646utf1':
10011 - return 'ISO-10646-UTF-1';
10013 - case 'csiso115481':
10014 - case 'iso115481':
10015 - case 'iso115481':
10016 - case 'isotr115481':
10017 - return 'ISO-11548-1';
10021 - return 'iso-ir-90';
10023 - case 'csunicodeibm1261':
10024 - case 'isounicodeibm1261':
10025 - return 'ISO-Unicode-IBM-1261';
10027 - case 'csunicodeibm1264':
10028 - case 'isounicodeibm1264':
10029 - return 'ISO-Unicode-IBM-1264';
10031 - case 'csunicodeibm1265':
10032 - case 'isounicodeibm1265':
10033 - return 'ISO-Unicode-IBM-1265';
10035 - case 'csunicodeibm1268':
10036 - case 'isounicodeibm1268':
10037 - return 'ISO-Unicode-IBM-1268';
10039 - case 'csunicodeibm1276':
10040 - case 'isounicodeibm1276':
10041 - return 'ISO-Unicode-IBM-1276';
10043 - case 'csiso646basic1983':
10044 - case 'iso646basic1983':
10046 - return 'ISO_646.basic:1983';
10048 - case 'csiso2intlrefversion':
10051 - case 'iso646irv1983':
10052 - return 'ISO_646.irv:1983';
10054 - case 'csiso2033':
10057 - case 'iso20331983':
10058 - return 'ISO_2033-1983';
10060 - case 'csiso5427cyrillic':
10063 - return 'ISO_5427';
10066 - case 'iso5427cyrillic1981':
10067 - case 'iso54271981':
10068 - return 'ISO_5427:1981';
10070 - case 'csiso5428greek':
10072 - case 'iso54281980':
10073 - return 'ISO_5428:1980';
10075 - case 'csiso6937add':
10077 - case 'iso6937225':
10078 - return 'ISO_6937-2-25';
10080 - case 'csisotextcomm':
10082 - case 'iso69372add':
10083 - return 'ISO_6937-2-add';
10085 - case 'csiso8859supp':
10087 - case 'iso8859supp':
10089 - return 'ISO_8859-supp';
10091 - case 'csiso10367box':
10093 - case 'iso10367box':
10094 - return 'ISO_10367-box';
10096 - case 'csiso15italian':
10102 - case 'csiso13jisc6220jp':
10104 - case 'jisc62201969':
10105 - case 'jisc62201969jp':
10108 - return 'JIS_C6220-1969-jp';
10110 - case 'csiso14jisc6220ro':
10113 - case 'jisc62201969ro':
10115 - return 'JIS_C6220-1969-ro';
10117 - case 'csiso42jisc62261978':
10119 - case 'jisc62261978':
10120 - return 'JIS_C6226-1978';
10122 - case 'csiso87jisx0208':
10124 - case 'jisc62261983':
10125 - case 'jisx02081983':
10127 - return 'JIS_C6226-1983';
10129 - case 'csiso91jisc62291984a':
10131 - case 'jisc62291984a':
10133 - return 'JIS_C6229-1984-a';
10135 - case 'csiso92jisc62991984b':
10137 - case 'iso646jpocrb':
10138 - case 'jisc62291984b':
10140 - return 'JIS_C6229-1984-b';
10142 - case 'csiso93jis62291984badd':
10144 - case 'jisc62291984badd':
10145 - case 'jpocrbadd':
10146 - return 'JIS_C6229-1984-b-add';
10148 - case 'csiso94jis62291984hand':
10150 - case 'jisc62291984hand':
10151 - case 'jpocrhand':
10152 - return 'JIS_C6229-1984-hand';
10154 - case 'csiso95jis62291984handadd':
10156 - case 'jisc62291984handadd':
10157 - case 'jpocrhandadd':
10158 - return 'JIS_C6229-1984-hand-add';
10160 - case 'csiso96jisc62291984kana':
10162 - case 'jisc62291984kana':
10163 - return 'JIS_C6229-1984-kana';
10165 - case 'csjisencoding':
10166 - case 'jisencoding':
10167 - return 'JIS_Encoding';
10169 - case 'cshalfwidthkatakana':
10172 - return 'JIS_X0201';
10174 - case 'csiso159jisx02121990':
10176 - case 'jisx02121990':
10178 - return 'JIS_X0212-1990';
10180 - case 'csiso141jusib1002':
10184 - case 'jusib1002':
10186 - return 'JUS_I.B1.002';
10188 - case 'csiso147macedonian':
10190 - case 'jusib1003mac':
10191 - case 'macedonian':
10192 - return 'JUS_I.B1.003-mac';
10194 - case 'csiso146serbian':
10196 - case 'jusib1003serb':
10198 - return 'JUS_I.B1.003-serb';
10200 - case 'koi7switched':
10201 - return 'KOI7-switched';
10210 - case 'csksc5636':
10213 - return 'KSC5636';
10218 - case 'strk10482002':
10219 - return 'KZ-1048';
10221 - case 'csiso19latingreek':
10223 - case 'latingreek':
10224 - return 'latin-greek';
10226 - case 'csiso27latingreek1':
10228 - case 'latingreek1':
10229 - return 'Latin-greek-1';
10231 - case 'csiso158lap':
10235 - return 'latin-lap';
10237 - case 'csmacintosh':
10239 - case 'macintosh':
10240 - return 'macintosh';
10242 - case 'csmicrosoftpublishing':
10243 - case 'microsoftpublishing':
10244 - return 'Microsoft-Publishing';
10250 - case 'csmnemonic':
10252 - return 'MNEMONIC';
10254 - case 'csiso86hungarian':
10259 - return 'MSZ_7795.3';
10261 - case 'csnatsdano':
10264 - return 'NATS-DANO';
10266 - case 'csnatsdanoadd':
10268 - case 'natsdanoadd':
10269 - return 'NATS-DANO-ADD';
10271 - case 'csnatssefi':
10274 - return 'NATS-SEFI';
10276 - case 'csnatssefiadd':
10278 - case 'natssefiadd':
10279 - return 'NATS-SEFI-ADD';
10281 - case 'csiso151cuba':
10285 - case 'ncnc001081':
10286 - return 'NC_NC00-10:81';
10288 - case 'csiso69french':
10293 - return 'NF_Z_62-010';
10295 - case 'csiso25french':
10297 - case 'iso646fr1':
10298 - case 'nfz620101973':
10299 - return 'NF_Z_62-010_(1973)';
10301 - case 'csiso60danishnorwegian':
10302 - case 'csiso60norwegian1':
10307 - return 'NS_4551-1';
10309 - case 'csiso61norwegian2':
10311 - case 'iso646no2':
10314 - return 'NS_4551-2';
10316 - case 'osdebcdicdf03irv':
10317 - return 'OSD_EBCDIC_DF03_IRV';
10319 - case 'osdebcdicdf041':
10320 - return 'OSD_EBCDIC_DF04_1';
10322 - case 'osdebcdicdf0415':
10323 - return 'OSD_EBCDIC_DF04_15';
10325 - case 'cspc8danishnorwegian':
10326 - case 'pc8danishnorwegian':
10327 - return 'PC8-Danish-Norwegian';
10329 - case 'cspc8turkish':
10330 - case 'pc8turkish':
10331 - return 'PC8-Turkish';
10333 - case 'csiso16portuguese':
10339 - case 'csiso84portuguese2':
10341 - case 'iso646pt2':
10346 - case 'csptcp154':
10347 - case 'cyrillicasian':
10350 - return 'PTCP154';
10355 - case 'csiso10swedish':
10361 - case 'sen850200b':
10362 - return 'SEN_850200_B';
10364 - case 'csiso11swedishfornames':
10366 - case 'iso646se2':
10368 - case 'sen850200c':
10369 - return 'SEN_850200_C';
10371 - case 'csshiftjis':
10374 - return 'Shift_JIS';
10376 - case 'csiso102t617bit':
10379 - return 'T.61-7bit';
10381 - case 'csiso103t618bit':
10385 - return 'T.61-8bit';
10387 - case 'csiso128t101g2':
10390 - return 'T.101-G2';
10396 - case 'csunicode11':
10397 - case 'unicode11':
10398 - return 'UNICODE-1-1';
10400 - case 'csunicode11utf7':
10401 - case 'unicode11utf7':
10402 - return 'UNICODE-1-1-UTF-7';
10404 - case 'csunknown8bit':
10405 - case 'unknown8bit':
10406 - return 'UNKNOWN-8BIT';
10408 - case 'ansix341968':
10409 - case 'ansix341986':
10416 - case 'iso646irv1991':
10419 - return 'US-ASCII';
10435 - return 'UTF-16BE';
10438 - return 'UTF-16LE';
10444 - return 'UTF-32BE';
10447 - return 'UTF-32LE';
10449 - case 'csventurainternational':
10450 - case 'venturainternational':
10451 - return 'Ventura-International';
10453 - case 'csventuramath':
10454 - case 'venturamath':
10455 - return 'Ventura-Math';
10457 - case 'csventuraus':
10458 - case 'venturaus':
10459 - return 'Ventura-US';
10461 - case 'csiso70videotexsupp1':
10463 - case 'videotexsuppl':
10464 - return 'videotex-suppl';
10474 - case 'cswindows31j':
10475 - case 'windows31j':
10476 - return 'Windows-31J';
10478 - case 'iso885911':
10480 - return 'Windows-874';
10484 - case 'windows949':
10485 - case 'csksc56011987':
10489 - case 'ksc56011987':
10490 - case 'ksc56011989':
10491 - return 'Windows-949';
10493 - case 'windows1250':
10494 - return 'windows-1250';
10496 - case 'windows1251':
10497 - return 'windows-1251';
10500 - case 'csisolatin1':
10504 - case 'iso885911987':
10507 - case 'windows1252':
10508 - return 'Windows-1252';
10510 - case 'windows1252':
10511 - return 'windows-1252';
10513 - case 'windows1253':
10514 - return 'windows-1253';
10516 - case 'csisolatin5':
10519 - case 'iso885991989':
10522 - case 'windows1254':
10523 - return 'Windows-1254';
10525 - case 'windows1254':
10526 - return 'windows-1254';
10528 - case 'windows1255':
10529 - return 'windows-1255';
10531 - case 'windows1256':
10532 - return 'windows-1256';
10534 - case 'windows1257':
10535 - return 'windows-1257';
10537 - case 'windows1258':
10538 - return 'windows-1258';
10545 - function get_curl_version()
10547 - if (is_array($curl = curl_version()))
10549 - $curl = $curl['version'];
10551 - elseif (substr($curl, 0, 5) == 'curl/')
10553 - $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5));
10555 - elseif (substr($curl, 0, 8) == 'libcurl/')
10557 - $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8));
10566 - function is_subclass_of($class1, $class2)
10568 - if (func_num_args() != 2)
10570 - trigger_error('Wrong parameter count for SimplePie_Misc::is_subclass_of()', E_USER_WARNING);
10572 - elseif (version_compare(PHP_VERSION, '5.0.3', '>=') || is_object($class1))
10574 - return is_subclass_of($class1, $class2);
10576 - elseif (is_string($class1) && is_string($class2))
10578 - if (class_exists($class1))
10580 - if (class_exists($class2))
10582 - $class2 = strtolower($class2);
10583 - while ($class1 = strtolower(get_parent_class($class1)))
10585 - if ($class1 == $class2)
10594 - trigger_error('Unknown class passed as parameter', E_USER_WARNNG);
10601 - * Strip HTML comments
10604 - * @param string $data Data to strip comments from
10605 - * @return string Comment stripped string
10607 - function strip_comments($data)
10610 - while (($start = strpos($data, '<!--')) !== false)
10612 - $output .= substr($data, 0, $start);
10613 - if (($end = strpos($data, '-->', $start)) !== false)
10615 - $data = substr_replace($data, '', 0, $end + 3);
10622 - return $output . $data;
10625 - function parse_date($dt)
10627 - $parser = SimplePie_Parse_Date::get();
10628 - return $parser->parse($dt);
10632 - * Decode HTML entities
10636 - * @param string $data Input data
10637 - * @return string Output data
10639 - function entities_decode($data)
10641 - $decoder = new SimplePie_Decode_HTML_Entities($data);
10642 - return $decoder->parse();
10646 - * Remove RFC822 comments
10649 - * @param string $data Data to strip comments from
10650 - * @return string Comment stripped string
10652 - function uncomment_rfc822($string)
10654 - $string = (string) $string;
10656 - $length = strlen($string);
10661 - while ($position < $length && ($pos = strpos($string, '(', $position)) !== false)
10663 - $output .= substr($string, $position, $pos - $position);
10664 - $position = $pos + 1;
10665 - if ($string[$pos - 1] !== '\\')
10668 - while ($depth && $position < $length)
10670 - $position += strcspn($string, '()', $position);
10671 - if ($string[$position - 1] === '\\')
10676 - elseif (isset($string[$position]))
10678 - switch ($string[$position])
10701 - $output .= substr($string, $position);
10706 - function parse_mime($mime)
10708 - if (($pos = strpos($mime, ';')) === false)
10710 - return trim($mime);
10714 - return trim(substr($mime, 0, $pos));
10718 - function htmlspecialchars_decode($string, $quote_style)
10720 - if (function_exists('htmlspecialchars_decode'))
10722 - return htmlspecialchars_decode($string, $quote_style);
10726 - return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)));
10730 - function atom_03_construct_type($attribs)
10732 - if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) == 'base64'))
10734 - $mode = SIMPLEPIE_CONSTRUCT_BASE64;
10738 - $mode = SIMPLEPIE_CONSTRUCT_NONE;
10740 - if (isset($attribs['']['type']))
10742 - switch (strtolower(trim($attribs['']['type'])))
10745 - case 'text/plain':
10746 - return SIMPLEPIE_CONSTRUCT_TEXT | $mode;
10749 - case 'text/html':
10750 - return SIMPLEPIE_CONSTRUCT_HTML | $mode;
10753 - case 'application/xhtml+xml':
10754 - return SIMPLEPIE_CONSTRUCT_XHTML | $mode;
10757 - return SIMPLEPIE_CONSTRUCT_NONE | $mode;
10762 - return SIMPLEPIE_CONSTRUCT_TEXT | $mode;
10766 - static function atom_10_construct_type($attribs)
10768 - if (isset($attribs['']['type']))
10770 - switch (strtolower(trim($attribs['']['type'])))
10773 - return SIMPLEPIE_CONSTRUCT_TEXT;
10776 - return SIMPLEPIE_CONSTRUCT_HTML;
10779 - return SIMPLEPIE_CONSTRUCT_XHTML;
10782 - return SIMPLEPIE_CONSTRUCT_NONE;
10785 - return SIMPLEPIE_CONSTRUCT_TEXT;
10788 - function atom_10_content_construct_type($attribs)
10790 - if (isset($attribs['']['type']))
10792 - $type = strtolower(trim($attribs['']['type']));
10796 - return SIMPLEPIE_CONSTRUCT_TEXT;
10799 - return SIMPLEPIE_CONSTRUCT_HTML;
10802 - return SIMPLEPIE_CONSTRUCT_XHTML;
10804 - if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) == 'text/')
10806 - return SIMPLEPIE_CONSTRUCT_NONE;
10810 - return SIMPLEPIE_CONSTRUCT_BASE64;
10815 - return SIMPLEPIE_CONSTRUCT_TEXT;
10819 - static function is_isegment_nz_nc($string)
10821 - return (bool) preg_match('/^([A-Za-z0-9\-._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!$&\'()*+,;=@]|(%[0-9ABCDEF]{2}))+$/u', $string);
10824 - function space_seperated_tokens($string)
10826 - $space_characters = "\x20\x09\x0A\x0B\x0C\x0D";
10827 - $string_length = strlen($string);
10829 - $position = strspn($string, $space_characters);
10830 - $tokens = array();
10832 - while ($position < $string_length)
10834 - $len = strcspn($string, $space_characters, $position);
10835 - $tokens[] = substr($string, $position, $len);
10836 - $position += $len;
10837 - $position += strspn($string, $space_characters, $position);
10843 - function array_unique($array)
10845 - if (version_compare(PHP_VERSION, '5.2', '>='))
10847 - return array_unique($array);
10851 - $array = (array) $array;
10852 - $new_array = array();
10853 - $new_array_strings = array();
10854 - foreach ($array as $key => $value)
10856 - if (is_object($value))
10858 - if (method_exists($value, '__toString'))
10860 - $cmp = $value->__toString();
10864 - trigger_error('Object of class ' . get_class($value) . ' could not be converted to string', E_USER_ERROR);
10867 - elseif (is_array($value))
10869 - $cmp = (string) reset($value);
10873 - $cmp = (string) $value;
10875 - if (!in_array($cmp, $new_array_strings))
10877 - $new_array[$key] = $value;
10878 - $new_array_strings[] = $cmp;
10881 - return $new_array;
10886 - * Converts a unicode codepoint to a UTF-8 character
10890 - * @param int $codepoint Unicode codepoint
10891 - * @return string UTF-8 character
10893 - function codepoint_to_utf8($codepoint)
10895 - static $cache = array();
10896 - $codepoint = (int) $codepoint;
10897 - if (isset($cache[$codepoint]))
10899 - return $cache[$codepoint];
10901 - elseif ($codepoint < 0)
10903 - return $cache[$codepoint] = false;
10905 - else if ($codepoint <= 0x7f)
10907 - return $cache[$codepoint] = chr($codepoint);
10909 - else if ($codepoint <= 0x7ff)
10911 - return $cache[$codepoint] = chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f));
10913 - else if ($codepoint <= 0xffff)
10915 - return $cache[$codepoint] = chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
10917 - else if ($codepoint <= 0x10ffff)
10919 - return $cache[$codepoint] = chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
10923 - // U+FFFD REPLACEMENT CHARACTER
10924 - return $cache[$codepoint] = "\xEF\xBF\xBD";
10929 - * Re-implementation of PHP 5's stripos()
10931 - * Returns the numeric position of the first occurrence of needle in the
10932 - * haystack string.
10936 - * @param object $haystack
10937 - * @param string $needle Note that the needle may be a string of one or more
10938 - * characters. If needle is not a string, it is converted to an integer
10939 - * and applied as the ordinal value of a character.
10940 - * @param int $offset The optional offset parameter allows you to specify which
10941 - * character in haystack to start searching. The position returned is still
10942 - * relative to the beginning of haystack.
10943 - * @return bool If needle is not found, stripos() will return boolean false.
10945 - function stripos($haystack, $needle, $offset = 0)
10947 - if (function_exists('stripos'))
10949 - return stripos($haystack, $needle, $offset);
10953 - if (is_string($needle))
10955 - $needle = strtolower($needle);
10957 - elseif (is_int($needle) || is_bool($needle) || is_double($needle))
10959 - $needle = strtolower(chr($needle));
10963 - trigger_error('needle is not a string or an integer', E_USER_WARNING);
10967 - return strpos(strtolower($haystack), $needle, $offset);
10972 - * Similar to parse_str()
10974 - * Returns an associative array of name/value pairs, where the value is an
10975 - * array of values that have used the same name
10979 - * @param string $str The input string.
10982 - function parse_str($str)
10984 - $return = array();
10985 - $str = explode('&', $str);
10987 - foreach ($str as $section)
10989 - if (strpos($section, '=') !== false)
10991 - list($name, $value) = explode('=', $section, 2);
10992 - $return[urldecode($name)][] = urldecode($value);
10996 - $return[urldecode($section)][] = null;
11004 - * Detect XML encoding, as per XML 1.0 Appendix F.1
11006 - * @todo Add support for EBCDIC
11007 - * @param string $data XML data
11008 - * @return array Possible encodings
11010 - static function xml_encoding($data)
11012 - // UTF-32 Big Endian BOM
11013 - if (substr($data, 0, 4) === "\x00\x00\xFE\xFF")
11015 - $encoding[] = 'UTF-32BE';
11017 - // UTF-32 Little Endian BOM
11018 - elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00")
11020 - $encoding[] = 'UTF-32LE';
11022 - // UTF-16 Big Endian BOM
11023 - elseif (substr($data, 0, 2) === "\xFE\xFF")
11025 - $encoding[] = 'UTF-16BE';
11027 - // UTF-16 Little Endian BOM
11028 - elseif (substr($data, 0, 2) === "\xFF\xFE")
11030 - $encoding[] = 'UTF-16LE';
11033 - elseif (substr($data, 0, 3) === "\xEF\xBB\xBF")
11035 - $encoding[] = 'UTF-8';
11037 - // UTF-32 Big Endian Without BOM
11038 - elseif (substr($data, 0, 20) === "\x00\x00\x00\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C")
11040 - if ($pos = strpos($data, "\x00\x00\x00\x3F\x00\x00\x00\x3E"))
11042 - $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32BE', 'UTF-8'));
11043 - if ($parser->parse())
11045 - $encoding[] = $parser->encoding;
11048 - $encoding[] = 'UTF-32BE';
11050 - // UTF-32 Little Endian Without BOM
11051 - elseif (substr($data, 0, 20) === "\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C\x00\x00\x00")
11053 - if ($pos = strpos($data, "\x3F\x00\x00\x00\x3E\x00\x00\x00"))
11055 - $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32LE', 'UTF-8'));
11056 - if ($parser->parse())
11058 - $encoding[] = $parser->encoding;
11061 - $encoding[] = 'UTF-32LE';
11063 - // UTF-16 Big Endian Without BOM
11064 - elseif (substr($data, 0, 10) === "\x00\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C")
11066 - if ($pos = strpos($data, "\x00\x3F\x00\x3E"))
11068 - $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16BE', 'UTF-8'));
11069 - if ($parser->parse())
11071 - $encoding[] = $parser->encoding;
11074 - $encoding[] = 'UTF-16BE';
11076 - // UTF-16 Little Endian Without BOM
11077 - elseif (substr($data, 0, 10) === "\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C\x00")
11079 - if ($pos = strpos($data, "\x3F\x00\x3E\x00"))
11081 - $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16LE', 'UTF-8'));
11082 - if ($parser->parse())
11084 - $encoding[] = $parser->encoding;
11087 - $encoding[] = 'UTF-16LE';
11089 - // US-ASCII (or superset)
11090 - elseif (substr($data, 0, 5) === "\x3C\x3F\x78\x6D\x6C")
11092 - if ($pos = strpos($data, "\x3F\x3E"))
11094 - $parser = new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5));
11095 - if ($parser->parse())
11097 - $encoding[] = $parser->encoding;
11100 - $encoding[] = 'UTF-8';
11102 - // Fallback to UTF-8
11105 - $encoding[] = 'UTF-8';
11107 - return $encoding;
11112 - * Decode HTML Entities
11114 - * This implements HTML5 as of revision 967 (2007-06-28)
11116 - * @package SimplePie
11118 -class SimplePie_Decode_HTML_Entities
11121 - * Data to be parsed
11123 - * @access private
11129 - * Currently consumed bytes
11131 - * @access private
11134 - var $consumed = '';
11137 - * Position of the current byte being parsed
11139 - * @access private
11142 - var $position = 0;
11145 - * Create an instance of the class with the input data
11148 - * @param string $data Input data
11150 - function SimplePie_Decode_HTML_Entities($data)
11152 - $this->data = $data;
11156 - * Parse the input data
11159 - * @return string Output data
11163 - while (($this->position = strpos($this->data, '&', $this->position)) !== false)
11165 - $this->consume();
11167 - $this->consumed = '';
11169 - return $this->data;
11173 - * Consume the next byte
11175 - * @access private
11176 - * @return mixed The next byte, or false, if there is no more data
11178 - function consume()
11180 - if (isset($this->data[$this->position]))
11182 - $this->consumed .= $this->data[$this->position];
11183 - return $this->data[$this->position++];
11187 - $this->consumed = false;
11193 - * Consume a range of characters
11195 - * @access private
11196 - * @param string $chars Characters to consume
11197 - * @return mixed A series of characters that match the range, or false
11199 - function consume_range($chars)
11201 - if ($len = strspn($this->data, $chars, $this->position))
11203 - $data = substr($this->data, $this->position, $len);
11204 - $this->consumed .= $data;
11205 - $this->position += $len;
11210 - $this->consumed = false;
11216 - * Unconsume one byte
11218 - * @access private
11220 - function unconsume()
11222 - $this->consumed = substr($this->consumed, 0, -1);
11223 - $this->position--;
11227 - * Decode an entity
11229 - * @access private
11231 - function entity()
11233 - switch ($this->consume())
11247 - switch ($this->consume())
11251 - $range = '0123456789ABCDEFabcdef';
11256 - $range = '0123456789';
11258 - $this->unconsume();
11262 - if ($codepoint = $this->consume_range($range))
11264 - static $windows_1252_specials = array(0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8");
11268 - $codepoint = hexdec($codepoint);
11272 - $codepoint = intval($codepoint);
11275 - if (isset($windows_1252_specials[$codepoint]))
11277 - $replacement = $windows_1252_specials[$codepoint];
11281 - $replacement = SimplePie_Misc::codepoint_to_utf8($codepoint);
11284 - if ($this->consume() != ';')
11286 - $this->unconsume();
11289 - $consumed_length = strlen($this->consumed);
11290 - $this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length);
11291 - $this->position += strlen($replacement) - $consumed_length;
11296 - static $entities = array('Aacute' => "\xC3\x81", 'aacute' => "\xC3\xA1", 'Aacute;' => "\xC3\x81", 'aacute;' => "\xC3\xA1", 'Acirc' => "\xC3\x82", 'acirc' => "\xC3\xA2", 'Acirc;' => "\xC3\x82", 'acirc;' => "\xC3\xA2", 'acute' => "\xC2\xB4", 'acute;' => "\xC2\xB4", 'AElig' => "\xC3\x86", 'aelig' => "\xC3\xA6", 'AElig;' => "\xC3\x86", 'aelig;' => "\xC3\xA6", 'Agrave' => "\xC3\x80", 'agrave' => "\xC3\xA0", 'Agrave;' => "\xC3\x80", 'agrave;' => "\xC3\xA0", 'alefsym;' => "\xE2\x84\xB5", 'Alpha;' => "\xCE\x91", 'alpha;' => "\xCE\xB1", 'AMP' => "\x26", 'amp' => "\x26", 'AMP;' => "\x26", 'amp;' => "\x26", 'and;' => "\xE2\x88\xA7", 'ang;' => "\xE2\x88\xA0", 'apos;' => "\x27", 'Aring' => "\xC3\x85", 'aring' => "\xC3\xA5", 'Aring;' => "\xC3\x85", 'aring;' => "\xC3\xA5", 'asymp;' => "\xE2\x89\x88", 'Atilde' => "\xC3\x83", 'atilde' => "\xC3\xA3", 'Atilde;' => "\xC3\x83", 'atilde;' => "\xC3\xA3", 'Auml' => "\xC3\x84", 'auml' => "\xC3\xA4", 'Auml;' => "\xC3\x84", 'auml;' => "\xC3\xA4", 'bdquo;' => "\xE2\x80\x9E", 'Beta;' => "\xCE\x92", 'beta;' => "\xCE\xB2", 'brvbar' => "\xC2\xA6", 'brvbar;' => "\xC2\xA6", 'bull;' => "\xE2\x80\xA2", 'cap;' => "\xE2\x88\xA9", 'Ccedil' => "\xC3\x87", 'ccedil' => "\xC3\xA7", 'Ccedil;' => "\xC3\x87", 'ccedil;' => "\xC3\xA7", 'cedil' => "\xC2\xB8", 'cedil;' => "\xC2\xB8", 'cent' => "\xC2\xA2", 'cent;' => "\xC2\xA2", 'Chi;' => "\xCE\xA7", 'chi;' => "\xCF\x87", 'circ;' => "\xCB\x86", 'clubs;' => "\xE2\x99\xA3", 'cong;' => "\xE2\x89\x85", 'COPY' => "\xC2\xA9", 'copy' => "\xC2\xA9", 'COPY;' => "\xC2\xA9", 'copy;' => "\xC2\xA9", 'crarr;' => "\xE2\x86\xB5", 'cup;' => "\xE2\x88\xAA", 'curren' => "\xC2\xA4", 'curren;' => "\xC2\xA4", 'Dagger;' => "\xE2\x80\xA1", 'dagger;' => "\xE2\x80\xA0", 'dArr;' => "\xE2\x87\x93", 'darr;' => "\xE2\x86\x93", 'deg' => "\xC2\xB0", 'deg;' => "\xC2\xB0", 'Delta;' => "\xCE\x94", 'delta;' => "\xCE\xB4", 'diams;' => "\xE2\x99\xA6", 'divide' => "\xC3\xB7", 'divide;' => "\xC3\xB7", 'Eacute' => "\xC3\x89", 'eacute' => "\xC3\xA9", 'Eacute;' => "\xC3\x89", 'eacute;' => "\xC3\xA9", 'Ecirc' => "\xC3\x8A", 'ecirc' => "\xC3\xAA", 'Ecirc;' => "\xC3\x8A", 'ecirc;' => "\xC3\xAA", 'Egrave' => "\xC3\x88", 'egrave' => "\xC3\xA8", 'Egrave;' => "\xC3\x88", 'egrave;' => "\xC3\xA8", 'empty;' => "\xE2\x88\x85", 'emsp;' => "\xE2\x80\x83", 'ensp;' => "\xE2\x80\x82", 'Epsilon;' => "\xCE\x95", 'epsilon;' => "\xCE\xB5", 'equiv;' => "\xE2\x89\xA1", 'Eta;' => "\xCE\x97", 'eta;' => "\xCE\xB7", 'ETH' => "\xC3\x90", 'eth' => "\xC3\xB0", 'ETH;' => "\xC3\x90", 'eth;' => "\xC3\xB0", 'Euml' => "\xC3\x8B", 'euml' => "\xC3\xAB", 'Euml;' => "\xC3\x8B", 'euml;' => "\xC3\xAB", 'euro;' => "\xE2\x82\xAC", 'exist;' => "\xE2\x88\x83", 'fnof;' => "\xC6\x92", 'forall;' => "\xE2\x88\x80", 'frac12' => "\xC2\xBD", 'frac12;' => "\xC2\xBD", 'frac14' => "\xC2\xBC", 'frac14;' => "\xC2\xBC", 'frac34' => "\xC2\xBE", 'frac34;' => "\xC2\xBE", 'frasl;' => "\xE2\x81\x84", 'Gamma;' => "\xCE\x93", 'gamma;' => "\xCE\xB3", 'ge;' => "\xE2\x89\xA5", 'GT' => "\x3E", 'gt' => "\x3E", 'GT;' => "\x3E", 'gt;' => "\x3E", 'hArr;' => "\xE2\x87\x94", 'harr;' => "\xE2\x86\x94", 'hearts;' => "\xE2\x99\xA5", 'hellip;' => "\xE2\x80\xA6", 'Iacute' => "\xC3\x8D", 'iacute' => "\xC3\xAD", 'Iacute;' => "\xC3\x8D", 'iacute;' => "\xC3\xAD", 'Icirc' => "\xC3\x8E", 'icirc' => "\xC3\xAE", 'Icirc;' => "\xC3\x8E", 'icirc;' => "\xC3\xAE", 'iexcl' => "\xC2\xA1", 'iexcl;' => "\xC2\xA1", 'Igrave' => "\xC3\x8C", 'igrave' => "\xC3\xAC", 'Igrave;' => "\xC3\x8C", 'igrave;' => "\xC3\xAC", 'image;' => "\xE2\x84\x91", 'infin;' => "\xE2\x88\x9E", 'int;' => "\xE2\x88\xAB", 'Iota;' => "\xCE\x99", 'iota;' => "\xCE\xB9", 'iquest' => "\xC2\xBF", 'iquest;' => "\xC2\xBF", 'isin;' => "\xE2\x88\x88", 'Iuml' => "\xC3\x8F", 'iuml' => "\xC3\xAF", 'Iuml;' => "\xC3\x8F", 'iuml;' => "\xC3\xAF", 'Kappa;' => "\xCE\x9A", 'kappa;' => "\xCE\xBA", 'Lambda;' => "\xCE\x9B", 'lambda;' => "\xCE\xBB", 'lang;' => "\xE3\x80\x88", 'laquo' => "\xC2\xAB", 'laquo;' => "\xC2\xAB", 'lArr;' => "\xE2\x87\x90", 'larr;' => "\xE2\x86\x90", 'lceil;' => "\xE2\x8C\x88", 'ldquo;' => "\xE2\x80\x9C", 'le;' => "\xE2\x89\xA4", 'lfloor;' => "\xE2\x8C\x8A", 'lowast;' => "\xE2\x88\x97", 'loz;' => "\xE2\x97\x8A", 'lrm;' => "\xE2\x80\x8E", 'lsaquo;' => "\xE2\x80\xB9", 'lsquo;' => "\xE2\x80\x98", 'LT' => "\x3C", 'lt' => "\x3C", 'LT;' => "\x3C", 'lt;' => "\x3C", 'macr' => "\xC2\xAF", 'macr;' => "\xC2\xAF", 'mdash;' => "\xE2\x80\x94", 'micro' => "\xC2\xB5", 'micro;' => "\xC2\xB5", 'middot' => "\xC2\xB7", 'middot;' => "\xC2\xB7", 'minus;' => "\xE2\x88\x92", 'Mu;' => "\xCE\x9C", 'mu;' => "\xCE\xBC", 'nabla;' => "\xE2\x88\x87", 'nbsp' => "\xC2\xA0", 'nbsp;' => "\xC2\xA0", 'ndash;' => "\xE2\x80\x93", 'ne;' => "\xE2\x89\xA0", 'ni;' => "\xE2\x88\x8B", 'not' => "\xC2\xAC", 'not;' => "\xC2\xAC", 'notin;' => "\xE2\x88\x89", 'nsub;' => "\xE2\x8A\x84", 'Ntilde' => "\xC3\x91", 'ntilde' => "\xC3\xB1", 'Ntilde;' => "\xC3\x91", 'ntilde;' => "\xC3\xB1", 'Nu;' => "\xCE\x9D", 'nu;' => "\xCE\xBD", 'Oacute' => "\xC3\x93", 'oacute' => "\xC3\xB3", 'Oacute;' => "\xC3\x93", 'oacute;' => "\xC3\xB3", 'Ocirc' => "\xC3\x94", 'ocirc' => "\xC3\xB4", 'Ocirc;' => "\xC3\x94", 'ocirc;' => "\xC3\xB4", 'OElig;' => "\xC5\x92", 'oelig;' => "\xC5\x93", 'Ograve' => "\xC3\x92", 'ograve' => "\xC3\xB2", 'Ograve;' => "\xC3\x92", 'ograve;' => "\xC3\xB2", 'oline;' => "\xE2\x80\xBE", 'Omega;' => "\xCE\xA9", 'omega;' => "\xCF\x89", 'Omicron;' => "\xCE\x9F", 'omicron;' => "\xCE\xBF", 'oplus;' => "\xE2\x8A\x95", 'or;' => "\xE2\x88\xA8", 'ordf' => "\xC2\xAA", 'ordf;' => "\xC2\xAA", 'ordm' => "\xC2\xBA", 'ordm;' => "\xC2\xBA", 'Oslash' => "\xC3\x98", 'oslash' => "\xC3\xB8", 'Oslash;' => "\xC3\x98", 'oslash;' => "\xC3\xB8", 'Otilde' => "\xC3\x95", 'otilde' => "\xC3\xB5", 'Otilde;' => "\xC3\x95", 'otilde;' => "\xC3\xB5", 'otimes;' => "\xE2\x8A\x97", 'Ouml' => "\xC3\x96", 'ouml' => "\xC3\xB6", 'Ouml;' => "\xC3\x96", 'ouml;' => "\xC3\xB6", 'para' => "\xC2\xB6", 'para;' => "\xC2\xB6", 'part;' => "\xE2\x88\x82", 'permil;' => "\xE2\x80\xB0", 'perp;' => "\xE2\x8A\xA5", 'Phi;' => "\xCE\xA6", 'phi;' => "\xCF\x86", 'Pi;' => "\xCE\xA0", 'pi;' => "\xCF\x80", 'piv;' => "\xCF\x96", 'plusmn' => "\xC2\xB1", 'plusmn;' => "\xC2\xB1", 'pound' => "\xC2\xA3", 'pound;' => "\xC2\xA3", 'Prime;' => "\xE2\x80\xB3", 'prime;' => "\xE2\x80\xB2", 'prod;' => "\xE2\x88\x8F", 'prop;' => "\xE2\x88\x9D", 'Psi;' => "\xCE\xA8", 'psi;' => "\xCF\x88", 'QUOT' => "\x22", 'quot' => "\x22", 'QUOT;' => "\x22", 'quot;' => "\x22", 'radic;' => "\xE2\x88\x9A", 'rang;' => "\xE3\x80\x89", 'raquo' => "\xC2\xBB", 'raquo;' => "\xC2\xBB", 'rArr;' => "\xE2\x87\x92", 'rarr;' => "\xE2\x86\x92", 'rceil;' => "\xE2\x8C\x89", 'rdquo;' => "\xE2\x80\x9D", 'real;' => "\xE2\x84\x9C", 'REG' => "\xC2\xAE", 'reg' => "\xC2\xAE", 'REG;' => "\xC2\xAE", 'reg;' => "\xC2\xAE", 'rfloor;' => "\xE2\x8C\x8B", 'Rho;' => "\xCE\xA1", 'rho;' => "\xCF\x81", 'rlm;' => "\xE2\x80\x8F", 'rsaquo;' => "\xE2\x80\xBA", 'rsquo;' => "\xE2\x80\x99", 'sbquo;' => "\xE2\x80\x9A", 'Scaron;' => "\xC5\xA0", 'scaron;' => "\xC5\xA1", 'sdot;' => "\xE2\x8B\x85", 'sect' => "\xC2\xA7", 'sect;' => "\xC2\xA7", 'shy' => "\xC2\xAD", 'shy;' => "\xC2\xAD", 'Sigma;' => "\xCE\xA3", 'sigma;' => "\xCF\x83", 'sigmaf;' => "\xCF\x82", 'sim;' => "\xE2\x88\xBC", 'spades;' => "\xE2\x99\xA0", 'sub;' => "\xE2\x8A\x82", 'sube;' => "\xE2\x8A\x86", 'sum;' => "\xE2\x88\x91", 'sup;' => "\xE2\x8A\x83", 'sup1' => "\xC2\xB9", 'sup1;' => "\xC2\xB9", 'sup2' => "\xC2\xB2", 'sup2;' => "\xC2\xB2", 'sup3' => "\xC2\xB3", 'sup3;' => "\xC2\xB3", 'supe;' => "\xE2\x8A\x87", 'szlig' => "\xC3\x9F", 'szlig;' => "\xC3\x9F", 'Tau;' => "\xCE\xA4", 'tau;' => "\xCF\x84", 'there4;' => "\xE2\x88\xB4", 'Theta;' => "\xCE\x98", 'theta;' => "\xCE\xB8", 'thetasym;' => "\xCF\x91", 'thinsp;' => "\xE2\x80\x89", 'THORN' => "\xC3\x9E", 'thorn' => "\xC3\xBE", 'THORN;' => "\xC3\x9E", 'thorn;' => "\xC3\xBE", 'tilde;' => "\xCB\x9C", 'times' => "\xC3\x97", 'times;' => "\xC3\x97", 'TRADE;' => "\xE2\x84\xA2", 'trade;' => "\xE2\x84\xA2", 'Uacute' => "\xC3\x9A", 'uacute' => "\xC3\xBA", 'Uacute;' => "\xC3\x9A", 'uacute;' => "\xC3\xBA", 'uArr;' => "\xE2\x87\x91", 'uarr;' => "\xE2\x86\x91", 'Ucirc' => "\xC3\x9B", 'ucirc' => "\xC3\xBB", 'Ucirc;' => "\xC3\x9B", 'ucirc;' => "\xC3\xBB", 'Ugrave' => "\xC3\x99", 'ugrave' => "\xC3\xB9", 'Ugrave;' => "\xC3\x99", 'ugrave;' => "\xC3\xB9", 'uml' => "\xC2\xA8", 'uml;' => "\xC2\xA8", 'upsih;' => "\xCF\x92", 'Upsilon;' => "\xCE\xA5", 'upsilon;' => "\xCF\x85", 'Uuml' => "\xC3\x9C", 'uuml' => "\xC3\xBC", 'Uuml;' => "\xC3\x9C", 'uuml;' => "\xC3\xBC", 'weierp;' => "\xE2\x84\x98", 'Xi;' => "\xCE\x9E", 'xi;' => "\xCE\xBE", 'Yacute' => "\xC3\x9D", 'yacute' => "\xC3\xBD", 'Yacute;' => "\xC3\x9D", 'yacute;' => "\xC3\xBD", 'yen' => "\xC2\xA5", 'yen;' => "\xC2\xA5", 'yuml' => "\xC3\xBF", 'Yuml;' => "\xC5\xB8", 'yuml;' => "\xC3\xBF", 'Zeta;' => "\xCE\x96", 'zeta;' => "\xCE\xB6", 'zwj;' => "\xE2\x80\x8D", 'zwnj;' => "\xE2\x80\x8C");
11298 - for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++)
11300 - $consumed = substr($this->consumed, 1);
11301 - if (isset($entities[$consumed]))
11303 - $match = $consumed;
11307 - if ($match !== null)
11309 - $this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1);
11310 - $this->position += strlen($entities[$match]) - strlen($consumed) - 1;
11320 - * @package SimplePie
11322 -class SimplePie_Parse_Date
11327 - * @access protected
11333 - * List of days, calendar day name => ordinal day number in the week
11335 - * @access protected
11338 - var $day = array(
11345 - 'wednesday' => 3,
11358 - 'donderdag' => 4,
11374 - 'donnerstag' => 4,
11377 - 'sonnabend' => 6,
11382 - 'mercoledì' => 3,
11390 - 'miércoles' => 3,
11396 - 'maanantai' => 1,
11398 - 'keskiviikko' => 3,
11400 - 'perjantai' => 5,
11402 - 'sunnuntai' => 7,
11407 - 'csütörtok' => 4,
11422 - * List of months, calendar month name => calendar month number
11424 - * @access protected
11427 - var $month = array(
11438 - // No long form of May
11446 - 'september' => 8,
11450 - 'november' => 11,
11452 - 'december' => 12,
11462 - 'september' => 9,
11464 - 'november' => 11,
11465 - 'december' => 12,
11475 - 'septembre' => 9,
11477 - 'novembre' => 11,
11478 - 'décembre' => 12,
11488 - 'september' => 9,
11490 - 'november' => 11,
11491 - 'dezember' => 12,
11501 - 'settembre' => 9,
11503 - 'novembre' => 11,
11504 - 'dicembre' => 12,
11514 - 'septiembre' => 9,
11515 - 'setiembre' => 9,
11517 - 'noviembre' => 11,
11518 - 'diciembre' => 12,
11522 - 'maaliskuu' => 3,
11531 - 'joulukuu' => 12,
11540 - 'augusztus' => 8,
11541 - 'szeptember' => 9,
11543 - 'november' => 11,
11544 - 'december' => 12,
11567 - * List of timezones, abbreviation => offset from UTC
11569 - * @access protected
11572 - var $timezone = array(
11577 - 'ACWDT' => 35100,
11578 - 'ACWST' => 31500,
11582 - 'AKDT' => -28800,
11583 - 'AKST' => -32400,
11586 - 'ANAST' => 46800,
11589 - 'AZOST' => -3600,
11607 - 'CHADT' => 49500,
11608 - 'CHAST' => 45900,
11609 - 'CIST' => -28800,
11611 - 'CLDT' => -10800,
11612 - 'CLST' => -14400,
11619 - 'EADT' => -18000,
11620 - 'EAST' => -21600,
11630 - 'FKDT' => -10800,
11631 - 'FKST' => -14400,
11633 - 'GALT' => -21600,
11644 - 'HADT' => -32400,
11648 - 'HAST' => -36000,
11661 - 'IRKST' => 32400,
11664 - 'JFDT' => -10800,
11665 - 'JFST' => -14400,
11670 - 'KOVST' => 28800,
11672 - 'KRAST' => 28800,
11679 - 'MAGST' => 43200,
11698 - 'NOVST' => 25200,
11706 - 'OMSST' => 25200,
11710 - 'PETST' => 46800,
11717 - 'PMST' => -10800,
11721 - 'PYST' => -10800,
11724 - 'ROTT' => -10800,
11725 - 'SAMST' => 18000,
11740 - 'THAT' => -36000,
11753 - 'VLAST' => 39600,
11767 - 'YAKST' => 36000,
11770 - 'YEKST' => 21600,
11775 - * Cached PCRE for SimplePie_Parse_Date::$day
11777 - * @access protected
11783 - * Cached PCRE for SimplePie_Parse_Date::$month
11785 - * @access protected
11791 - * Array of user-added callback methods
11793 - * @access private
11796 - var $built_in = array();
11799 - * Array of user-added callback methods
11801 - * @access private
11804 - var $user = array();
11807 - * Create new SimplePie_Parse_Date object, and set self::day_pcre,
11808 - * self::month_pcre, and self::built_in
11810 - * @access private
11812 - function SimplePie_Parse_Date()
11814 - $this->day_pcre = '(' . implode(array_keys($this->day), '|') . ')';
11815 - $this->month_pcre = '(' . implode(array_keys($this->month), '|') . ')';
11818 - if (!isset($cache[get_class($this)]))
11820 - if (extension_loaded('Reflection'))
11822 - $class = new ReflectionClass(get_class($this));
11823 - $methods = $class->getMethods();
11824 - $all_methods = array();
11825 - foreach ($methods as $method)
11827 - $all_methods[] = $method->getName();
11832 - $all_methods = get_class_methods($this);
11835 - foreach ($all_methods as $method)
11837 - if (strtolower(substr($method, 0, 5)) === 'date_')
11839 - $cache[get_class($this)][] = $method;
11844 - foreach ($cache[get_class($this)] as $method)
11846 - $this->built_in[] = $method;
11855 - static function get()
11860 - $object = new SimplePie_Parse_Date;
11870 - * @param string $date Date to parse
11871 - * @return int Timestamp corresponding to date string, or false on failure
11873 - function parse($date)
11875 - foreach ($this->user as $method)
11877 - if (($returned = call_user_func($method, $date)) !== false)
11879 - return $returned;
11883 - foreach ($this->built_in as $method)
11885 - if (($returned = call_user_func(array(&$this, $method), $date)) !== false)
11887 - return $returned;
11895 - * Add a callback method to parse a date
11899 - * @param callback $callback
11901 - function add_callback($callback)
11903 - if (is_callable($callback))
11905 - $this->user[] = $callback;
11909 - trigger_error('User-supplied function must be a valid callback', E_USER_WARNING);
11914 - * Parse a superset of W3C-DTF (allows hyphens and colons to be omitted, as
11915 - * well as allowing any of upper or lower case "T", horizontal tabs, or
11916 - * spaces to be used as the time seperator (including more than one))
11918 - * @access protected
11919 - * @return int Timestamp
11921 - function date_w3cdtf($date)
11926 - $year = '([0-9]{4})';
11927 - $month = $day = $hour = $minute = $second = '([0-9]{2})';
11928 - $decimal = '([0-9]*)';
11929 - $zone = '(?:(Z)|([+\-])([0-9]{1,2}):?([0-9]{1,2}))';
11930 - $pcre = '/^' . $year . '(?:-?' . $month . '(?:-?' . $day . '(?:[Tt\x09\x20]+' . $hour . '(?::?' . $minute . '(?::?' . $second . '(?:.' . $decimal . ')?)?)?' . $zone . ')?)?)?$/';
11932 - if (preg_match($pcre, $date, $match))
11935 - Capturing subpatterns:
11942 - 7: Decimal fraction of a second
11945 - 10: Timezone hours
11946 - 11: Timezone minutes
11949 - // Fill in empty matches
11950 - for ($i = count($match); $i <= 3; $i++)
11952 - $match[$i] = '1';
11955 - for ($i = count($match); $i <= 7; $i++)
11957 - $match[$i] = '0';
11960 - // Numeric timezone
11961 - if (isset($match[9]) && $match[9] !== '')
11963 - $timezone = $match[10] * 3600;
11964 - $timezone += $match[11] * 60;
11965 - if ($match[9] === '-')
11967 - $timezone = 0 - $timezone;
11975 - // Convert the number of seconds to an integer, taking decimals into account
11976 - $second = round($match[6] + $match[7] / pow(10, strlen($match[7])));
11978 - return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone;
11987 - * Remove RFC822 comments
11989 - * @access protected
11990 - * @param string $data Data to strip comments from
11991 - * @return string Comment stripped string
11993 - function remove_rfc2822_comments($string)
11995 - $string = (string) $string;
11997 - $length = strlen($string);
12002 - while ($position < $length && ($pos = strpos($string, '(', $position)) !== false)
12004 - $output .= substr($string, $position, $pos - $position);
12005 - $position = $pos + 1;
12006 - if ($string[$pos - 1] !== '\\')
12009 - while ($depth && $position < $length)
12011 - $position += strcspn($string, '()', $position);
12012 - if ($string[$position - 1] === '\\')
12017 - elseif (isset($string[$position]))
12019 - switch ($string[$position])
12042 - $output .= substr($string, $position);
12048 - * Parse RFC2822's date format
12050 - * @access protected
12051 - * @return int Timestamp
12053 - function date_rfc2822($date)
12058 - $wsp = '[\x09\x20]';
12059 - $fws = '(?:' . $wsp . '+|' . $wsp . '*(?:\x0D\x0A' . $wsp . '+)+)';
12060 - $optional_fws = $fws . '?';
12061 - $day_name = $this->day_pcre;
12062 - $month = $this->month_pcre;
12063 - $day = '([0-9]{1,2})';
12064 - $hour = $minute = $second = '([0-9]{2})';
12065 - $year = '([0-9]{2,4})';
12066 - $num_zone = '([+\-])([0-9]{2})([0-9]{2})';
12067 - $character_zone = '([A-Z]{1,5})';
12068 - $zone = '(?:' . $num_zone . '|' . $character_zone . ')';
12069 - $pcre = '/(?:' . $optional_fws . $day_name . $optional_fws . ',)?' . $optional_fws . $day . $fws . $month . $fws . $year . $fws . $hour . $optional_fws . ':' . $optional_fws . $minute . '(?:' . $optional_fws . ':' . $optional_fws . $second . ')?' . $fws . $zone . '/i';
12071 - if (preg_match($pcre, $this->remove_rfc2822_comments($date), $match))
12074 - Capturing subpatterns:
12083 - 9: Timezone hours
12084 - 10: Timezone minutes
12085 - 11: Alphabetic timezone
12088 - // Find the month number
12089 - $month = $this->month[strtolower($match[3])];
12091 - // Numeric timezone
12092 - if ($match[8] !== '')
12094 - $timezone = $match[9] * 3600;
12095 - $timezone += $match[10] * 60;
12096 - if ($match[8] === '-')
12098 - $timezone = 0 - $timezone;
12101 - // Character timezone
12102 - elseif (isset($this->timezone[strtoupper($match[11])]))
12104 - $timezone = $this->timezone[strtoupper($match[11])];
12106 - // Assume everything else to be -0000
12112 - // Deal with 2/3 digit years
12113 - if ($match[4] < 50)
12115 - $match[4] += 2000;
12117 - elseif ($match[4] < 1000)
12119 - $match[4] += 1900;
12122 - // Second is optional, if it is empty set it to zero
12123 - if ($match[7] !== '')
12125 - $second = $match[7];
12132 - return gmmktime($match[5], $match[6], $second, $month, $match[2], $match[4]) - $timezone;
12141 - * Parse RFC850's date format
12143 - * @access protected
12144 - * @return int Timestamp
12146 - function date_rfc850($date)
12151 - $space = '[\x09\x20]+';
12152 - $day_name = $this->day_pcre;
12153 - $month = $this->month_pcre;
12154 - $day = '([0-9]{1,2})';
12155 - $year = $hour = $minute = $second = '([0-9]{2})';
12156 - $zone = '([A-Z]{1,5})';
12157 - $pcre = '/^' . $day_name . ',' . $space . $day . '-' . $month . '-' . $year . $space . $hour . ':' . $minute . ':' . $second . $space . $zone . '$/i';
12159 - if (preg_match($pcre, $date, $match))
12162 - Capturing subpatterns:
12174 - $month = $this->month[strtolower($match[3])];
12176 - // Character timezone
12177 - if (isset($this->timezone[strtoupper($match[8])]))
12179 - $timezone = $this->timezone[strtoupper($match[8])];
12181 - // Assume everything else to be -0000
12187 - // Deal with 2 digit year
12188 - if ($match[4] < 50)
12190 - $match[4] += 2000;
12194 - $match[4] += 1900;
12197 - return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone;
12206 - * Parse C99's asctime()'s date format
12208 - * @access protected
12209 - * @return int Timestamp
12211 - function date_asctime($date)
12216 - $space = '[\x09\x20]+';
12217 - $wday_name = $this->day_pcre;
12218 - $mon_name = $this->month_pcre;
12219 - $day = '([0-9]{1,2})';
12220 - $hour = $sec = $min = '([0-9]{2})';
12221 - $year = '([0-9]{4})';
12222 - $terminator = '\x0A?\x00?';
12223 - $pcre = '/^' . $wday_name . $space . $mon_name . $space . $day . $space . $hour . ':' . $min . ':' . $sec . $space . $year . $terminator . '$/i';
12225 - if (preg_match($pcre, $date, $match))
12228 - Capturing subpatterns:
12238 - $month = $this->month[strtolower($match[2])];
12239 - return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]);
12248 - * Parse dates using strtotime()
12250 - * @access protected
12251 - * @return int Timestamp
12253 - function date_strtotime($date)
12255 - $strtotime = strtotime($date);
12256 - if ($strtotime === -1 || $strtotime === false)
12262 - return $strtotime;
12268 - * Content-type sniffing
12270 - * @package SimplePie
12272 -class SimplePie_Content_Type_Sniffer
12277 - * @var SimplePie_File
12278 - * @access private
12283 - * Create an instance of the class with the input file
12286 - * @param SimplePie_Content_Type_Sniffer $file Input file
12288 - function SimplePie_Content_Type_Sniffer($file)
12290 - $this->file = $file;
12294 - * Get the Content-Type of the specified file
12297 - * @return string Actual Content-Type
12299 - function get_type()
12301 - if (isset($this->file->headers['content-type']))
12303 - if (!isset($this->file->headers['content-encoding'])
12304 - && ($this->file->headers['content-type'] === 'text/plain'
12305 - || $this->file->headers['content-type'] === 'text/plain; charset=ISO-8859-1'
12306 - || $this->file->headers['content-type'] === 'text/plain; charset=iso-8859-1'))
12308 - return $this->text_or_binary();
12311 - if (($pos = strpos($this->file->headers['content-type'], ';')) !== false)
12313 - $official = substr($this->file->headers['content-type'], 0, $pos);
12317 - $official = $this->file->headers['content-type'];
12319 - $official = strtolower($official);
12321 - if ($official === 'unknown/unknown'
12322 - || $official === 'application/unknown')
12324 - return $this->unknown();
12326 - elseif (substr($official, -4) === '+xml'
12327 - || $official === 'text/xml'
12328 - || $official === 'application/xml')
12330 - return $official;
12332 - elseif (substr($official, 0, 6) === 'image/')
12334 - if ($return = $this->image())
12340 - return $official;
12343 - elseif ($official === 'text/html')
12345 - return $this->feed_or_html();
12349 - return $official;
12354 - return $this->unknown();
12359 - * Sniff text or binary
12361 - * @access private
12362 - * @return string Actual Content-Type
12364 - function text_or_binary()
12366 - if (substr($this->file->body, 0, 2) === "\xFE\xFF"
12367 - || substr($this->file->body, 0, 2) === "\xFF\xFE"
12368 - || substr($this->file->body, 0, 4) === "\x00\x00\xFE\xFF"
12369 - || substr($this->file->body, 0, 3) === "\xEF\xBB\xBF")
12371 - return 'text/plain';
12373 - elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $this->file->body))
12375 - return 'application/octect-stream';
12379 - return 'text/plain';
12386 - * @access private
12387 - * @return string Actual Content-Type
12389 - function unknown()
12391 - $ws = strspn($this->file->body, "\x09\x0A\x0B\x0C\x0D\x20");
12392 - if (strtolower(substr($this->file->body, $ws, 14)) === '<!doctype html'
12393 - || strtolower(substr($this->file->body, $ws, 5)) === '<html'
12394 - || strtolower(substr($this->file->body, $ws, 7)) === '<script')
12396 - return 'text/html';
12398 - elseif (substr($this->file->body, 0, 5) === '%PDF-')
12400 - return 'application/pdf';
12402 - elseif (substr($this->file->body, 0, 11) === '%!PS-Adobe-')
12404 - return 'application/postscript';
12406 - elseif (substr($this->file->body, 0, 6) === 'GIF87a'
12407 - || substr($this->file->body, 0, 6) === 'GIF89a')
12409 - return 'image/gif';
12411 - elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")
12413 - return 'image/png';
12415 - elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF")
12417 - return 'image/jpeg';
12419 - elseif (substr($this->file->body, 0, 2) === "\x42\x4D")
12421 - return 'image/bmp';
12425 - return $this->text_or_binary();
12432 - * @access private
12433 - * @return string Actual Content-Type
12437 - if (substr($this->file->body, 0, 6) === 'GIF87a'
12438 - || substr($this->file->body, 0, 6) === 'GIF89a')
12440 - return 'image/gif';
12442 - elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")
12444 - return 'image/png';
12446 - elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF")
12448 - return 'image/jpeg';
12450 - elseif (substr($this->file->body, 0, 2) === "\x42\x4D")
12452 - return 'image/bmp';
12463 - * @access private
12464 - * @return string Actual Content-Type
12466 - function feed_or_html()
12468 - $len = strlen($this->file->body);
12469 - $pos = strspn($this->file->body, "\x09\x0A\x0D\x20");
12471 - while ($pos < $len)
12473 - switch ($this->file->body[$pos])
12479 - $pos += strspn($this->file->body, "\x09\x0A\x0D\x20", $pos);
12487 - return 'text/html';
12490 - if (substr($this->file->body, $pos, 3) === '!--')
12493 - if ($pos < $len && ($pos = strpos($this->file->body, '-->', $pos)) !== false)
12499 - return 'text/html';
12502 - elseif (substr($this->file->body, $pos, 1) === '!')
12504 - if ($pos < $len && ($pos = strpos($this->file->body, '>', $pos)) !== false)
12510 - return 'text/html';
12513 - elseif (substr($this->file->body, $pos, 1) === '?')
12515 - if ($pos < $len && ($pos = strpos($this->file->body, '?>', $pos)) !== false)
12521 - return 'text/html';
12524 - elseif (substr($this->file->body, $pos, 3) === 'rss'
12525 - || substr($this->file->body, $pos, 7) === 'rdf:RDF')
12527 - return 'application/rss+xml';
12529 - elseif (substr($this->file->body, $pos, 4) === 'feed')
12531 - return 'application/atom+xml';
12535 - return 'text/html';
12539 - return 'text/html';
12544 - * Parses the XML Declaration
12546 - * @package SimplePie
12548 -class SimplePie_XML_Declaration_Parser
12556 - var $version = '1.0';
12564 - var $encoding = 'UTF-8';
12572 - var $standalone = false;
12575 - * Current state of the state machine
12577 - * @access private
12580 - var $state = 'before_version_name';
12585 - * @access private
12591 - * Input data length (to avoid calling strlen() everytime this is needed)
12593 - * @access private
12596 - var $data_length = 0;
12599 - * Current position of the pointer
12602 - * @access private
12604 - var $position = 0;
12607 - * Create an instance of the class with the input data
12610 - * @param string $data Input data
12612 - function SimplePie_XML_Declaration_Parser($data)
12614 - $this->data = $data;
12615 - $this->data_length = strlen($this->data);
12619 - * Parse the input data
12622 - * @return bool true on success, false on failure
12626 - while ($this->state && $this->state !== 'emit' && $this->has_data())
12628 - $state = $this->state;
12631 - $this->data = '';
12632 - if ($this->state === 'emit')
12638 - $this->version = '';
12639 - $this->encoding = '';
12640 - $this->standalone = '';
12646 - * Check whether there is data beyond the pointer
12648 - * @access private
12649 - * @return bool true if there is further data, false if not
12651 - function has_data()
12653 - return (bool) ($this->position < $this->data_length);
12657 - * Advance past any whitespace
12659 - * @return int Number of whitespace characters passed
12661 - function skip_whitespace()
12663 - $whitespace = strspn($this->data, "\x09\x0A\x0D\x20", $this->position);
12664 - $this->position += $whitespace;
12665 - return $whitespace;
12671 - function get_value()
12673 - $quote = substr($this->data, $this->position, 1);
12674 - if ($quote === '"' || $quote === "'")
12676 - $this->position++;
12677 - $len = strcspn($this->data, $quote, $this->position);
12678 - if ($this->has_data())
12680 - $value = substr($this->data, $this->position, $len);
12681 - $this->position += $len + 1;
12688 - function before_version_name()
12690 - if ($this->skip_whitespace())
12692 - $this->state = 'version_name';
12696 - $this->state = false;
12700 - function version_name()
12702 - if (substr($this->data, $this->position, 7) === 'version')
12704 - $this->position += 7;
12705 - $this->skip_whitespace();
12706 - $this->state = 'version_equals';
12710 - $this->state = false;
12714 - function version_equals()
12716 - if (substr($this->data, $this->position, 1) === '=')
12718 - $this->position++;
12719 - $this->skip_whitespace();
12720 - $this->state = 'version_value';
12724 - $this->state = false;
12728 - function version_value()
12730 - if ($this->version = $this->get_value())
12732 - $this->skip_whitespace();
12733 - if ($this->has_data())
12735 - $this->state = 'encoding_name';
12739 - $this->state = 'emit';
12744 - $this->state = 'standalone_name';
12748 - function encoding_name()
12750 - if (substr($this->data, $this->position, 8) === 'encoding')
12752 - $this->position += 8;
12753 - $this->skip_whitespace();
12754 - $this->state = 'encoding_equals';
12758 - $this->state = false;
12762 - function encoding_equals()
12764 - if (substr($this->data, $this->position, 1) === '=')
12766 - $this->position++;
12767 - $this->skip_whitespace();
12768 - $this->state = 'encoding_value';
12772 - $this->state = false;
12776 - function encoding_value()
12778 - if ($this->encoding = $this->get_value())
12780 - $this->skip_whitespace();
12781 - if ($this->has_data())
12783 - $this->state = 'standalone_name';
12787 - $this->state = 'emit';
12792 - $this->state = false;
12796 - function standalone_name()
12798 - if (substr($this->data, $this->position, 10) === 'standalone')
12800 - $this->position += 10;
12801 - $this->skip_whitespace();
12802 - $this->state = 'standalone_equals';
12806 - $this->state = false;
12810 - function standalone_equals()
12812 - if (substr($this->data, $this->position, 1) === '=')
12814 - $this->position++;
12815 - $this->skip_whitespace();
12816 - $this->state = 'standalone_value';
12820 - $this->state = false;
12824 - function standalone_value()
12826 - if ($standalone = $this->get_value())
12828 - switch ($standalone)
12831 - $this->standalone = true;
12835 - $this->standalone = false;
12839 - $this->state = false;
12843 - $this->skip_whitespace();
12844 - if ($this->has_data())
12846 - $this->state = false;
12850 - $this->state = 'emit';
12855 - $this->state = false;
12860 -class SimplePie_Locator
12865 - var $local = array();
12866 - var $elsewhere = array();
12867 - var $file_class = 'SimplePie_File';
12868 - var $cached_entities = array();
12871 - var $base_location = 0;
12872 - var $checked_feeds = 0;
12873 - var $max_checked_feeds = 10;
12874 - var $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer';
12877 - function SimplePie_Locator(&$file, $timeout = 10, $useragent = null, $file_class = 'SimplePie_File', $max_checked_feeds = 10, $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer', $proxy = "")
12879 - $this->file =& $file;
12880 - $this->file_class = $file_class;
12881 - $this->useragent = $useragent;
12882 - $this->timeout = $timeout;
12883 - $this->max_checked_feeds = $max_checked_feeds;
12884 - $this->content_type_sniffer_class = $content_type_sniffer_class;
12885 - $this->proxy = $proxy;
12888 - function find($type = SIMPLEPIE_LOCATOR_ALL)
12890 - if ($this->is_feed($this->file))
12892 - return $this->file;
12895 - if ($this->file->method & SIMPLEPIE_FILE_SOURCE_REMOTE)
12897 - $sniffer = new $this->content_type_sniffer_class($this->file);
12898 - if ($sniffer->get_type() !== 'text/html')
12904 - if ($type & ~SIMPLEPIE_LOCATOR_NONE)
12906 - $this->get_base();
12909 - if ($type & SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working = $this->autodiscovery())
12914 - if ($type & (SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY | SIMPLEPIE_LOCATOR_REMOTE_EXTENSION | SIMPLEPIE_LOCATOR_REMOTE_BODY) && $this->get_links())
12916 - if ($type & SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working = $this->extension($this->local))
12921 - if ($type & SIMPLEPIE_LOCATOR_LOCAL_BODY && $working = $this->body($this->local))
12926 - if ($type & SIMPLEPIE_LOCATOR_REMOTE_EXTENSION && $working = $this->extension($this->elsewhere))
12931 - if ($type & SIMPLEPIE_LOCATOR_REMOTE_BODY && $working = $this->body($this->elsewhere))
12939 - function is_feed(&$file)
12941 - if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE)
12943 - $sniffer = new $this->content_type_sniffer_class($file);
12944 - $sniffed = $sniffer->get_type();
12945 - if (in_array($sniffed, array('application/rss+xml', 'application/rdf+xml', 'text/rdf', 'application/atom+xml', 'text/xml', 'application/xml')))
12954 - elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL)
12964 - function get_base()
12966 - $this->http_base = $this->file->url;
12967 - $this->base = $this->http_base;
12968 - $elements = SimplePie_Misc::get_element('base', $this->file->body);
12969 - foreach ($elements as $element)
12971 - if ($element['attribs']['href']['data'] !== '')
12973 - $this->base = SimplePie_Misc::absolutize_url(trim($element['attribs']['href']['data']), $this->http_base);
12974 - $this->base_location = $element['offset'];
12980 - function autodiscovery()
12982 - $links = array_merge(SimplePie_Misc::get_element('link', $this->file->body), SimplePie_Misc::get_element('a', $this->file->body), SimplePie_Misc::get_element('area', $this->file->body));
12984 - foreach ($links as $link)
12986 - if ($this->checked_feeds == $this->max_checked_feeds)
12990 - if (isset($link['attribs']['href']['data']) && isset($link['attribs']['rel']['data']))
12992 - $rel = array_unique(SimplePie_Misc::space_seperated_tokens(strtolower($link['attribs']['rel']['data'])));
12994 - if ($this->base_location < $link['offset'])
12996 - $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->base);
13000 - $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base);
13003 - if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !empty($link['attribs']['type']['data']) && in_array(strtolower(SimplePie_Misc::parse_mime($link['attribs']['type']['data'])), array('application/rss+xml', 'application/atom+xml'))))
13005 - $this->checked_feeds++;
13006 - $feed = new $this->file_class($href, $this->timeout, 5, null, $this->useragent, false, $this->proxy);
13007 - if ($this->is_feed($feed))
13018 - function get_links()
13020 - $links = SimplePie_Misc::get_element('a', $this->file->body);
13021 - foreach ($links as $link)
13023 - if (isset($link['attribs']['href']['data']))
13025 - $href = trim($link['attribs']['href']['data']);
13026 - $parsed = SimplePie_Misc::parse_url($href);
13027 - if ($parsed['scheme'] === '' || preg_match('/^(http(s)|feed)?$/i', $parsed['scheme']))
13029 - if ($this->base_location < $link['offset'])
13031 - $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->base);
13035 - $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base);
13038 - $current = SimplePie_Misc::parse_url($this->file->url);
13040 - if ($parsed['authority'] === '' || $parsed['authority'] == $current['authority'])
13042 - $this->local[] = $href;
13046 - $this->elsewhere[] = $href;
13051 - $this->local = array_unique($this->local);
13052 - $this->elsewhere = array_unique($this->elsewhere);
13053 - if (!empty($this->local) || !empty($this->elsewhere))
13060 - function extension(&$array)
13062 - foreach ($array as $key => $value)
13064 - if ($this->checked_feeds == $this->max_checked_feeds)
13068 - if (in_array(strtolower(strrchr($value, '.')), array('.rss', '.rdf', '.atom', '.xml')))
13070 - $this->checked_feeds++;
13071 - $feed = new $this->file_class($value, $this->timeout, 5, null, $this->useragent, false, $this->proxy);
13072 - if ($this->is_feed($feed))
13078 - unset($array[$key]);
13085 - function body(&$array)
13087 - foreach ($array as $key => $value)
13089 - if ($this->checked_feeds == $this->max_checked_feeds)
13093 - if (preg_match('/(rss|rdf|atom|xml)/i', $value))
13095 - $this->checked_feeds++;
13096 - $feed = new $this->file_class($value, $this->timeout, 5, null, $this->useragent, false, $this->proxy);
13097 - if ($this->is_feed($feed))
13103 - unset($array[$key]);
13111 -class SimplePie_Parser
13114 - var $error_string;
13115 - var $current_line;
13116 - var $current_column;
13117 - var $current_byte;
13118 - var $separator = ' ';
13119 - var $feed = false;
13120 - var $namespace = array('');
13121 - var $element = array('');
13122 - var $xml_base = array('');
13123 - var $xml_base_explicit = array(false);
13124 - var $xml_lang = array('');
13125 - var $data = array();
13126 - var $datas = array(array());
13127 - var $current_xhtml_construct = -1;
13130 - function parse(&$data, $encoding)
13132 - // Use UTF-8 if we get passed US-ASCII, as every US-ASCII character is a UTF-8 character
13133 - if (strtoupper($encoding) == 'US-ASCII')
13135 - $this->encoding = 'UTF-8';
13139 - $this->encoding = $encoding;
13143 - // UTF-32 Big Endian BOM
13144 - if (substr($data, 0, 4) === "\x00\x00\xFE\xFF")
13146 - $data = substr($data, 4);
13148 - // UTF-32 Little Endian BOM
13149 - elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00")
13151 - $data = substr($data, 4);
13153 - // UTF-16 Big Endian BOM
13154 - elseif (substr($data, 0, 2) === "\xFE\xFF")
13156 - $data = substr($data, 2);
13158 - // UTF-16 Little Endian BOM
13159 - elseif (substr($data, 0, 2) === "\xFF\xFE")
13161 - $data = substr($data, 2);
13164 - elseif (substr($data, 0, 3) === "\xEF\xBB\xBF")
13166 - $data = substr($data, 3);
13169 - if (substr($data, 0, 5) === '<?xml' && strspn(substr($data, 5, 1), "\x09\x0A\x0D\x20") && ($pos = strpos($data, '?>')) !== false)
13171 - $declaration = new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5));
13172 - if ($declaration->parse())
13174 - $data = substr($data, $pos + 2);
13175 - $data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . $data;
13179 - $this->error_string = 'SimplePie bug! Please report this!';
13184 - // Work around libxml bug
13185 - $data = str_replace('<', '<', $data);
13186 - $data = str_replace('>', '>', $data);
13187 - $data = str_replace('&', '&', $data);
13188 - $data = str_replace(''', ''', $data);
13189 - $data = str_replace('"', '"', $data);
13193 - // Create the parser
13194 - $xml = xml_parser_create_ns($this->encoding, $this->separator);
13195 - xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1);
13196 - xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 0);
13197 - xml_set_object($xml, $this);
13198 - xml_set_character_data_handler($xml, 'cdata');
13199 - xml_set_element_handler($xml, 'tag_open', 'tag_close');
13202 - if (!xml_parse($xml, $data, true))
13204 - $this->error_code = xml_get_error_code($xml);
13205 - $this->error_string = xml_error_string($this->error_code);
13208 - $this->current_line = xml_get_current_line_number($xml);
13209 - $this->current_column = xml_get_current_column_number($xml);
13210 - $this->current_byte = xml_get_current_byte_index($xml);
13211 - xml_parser_free($xml);
13215 - function get_error_code()
13217 - return $this->error_code;
13220 - function get_error_string()
13222 - return $this->error_string;
13225 - function get_current_line()
13227 - return $this->current_line;
13230 - function get_current_column()
13232 - return $this->current_column;
13235 - function get_current_byte()
13237 - return $this->current_byte;
13240 - function get_data()
13242 - return $this->data;
13245 - function tag_open($parser, $tag, $attributes)
13247 - if ($this->feed === 0)
13251 - elseif ($this->feed == false)
13253 - if (in_array($tag, array(
13254 - SIMPLEPIE_NAMESPACE_ATOM_10 . $this->separator . 'feed',
13255 - SIMPLEPIE_NAMESPACE_ATOM_03 . $this->separator . 'feed',
13257 - SIMPLEPIE_NAMESPACE_RDF . $this->separator . 'RDF'
13268 - list($this->namespace[], $this->element[]) = $this->split_ns($tag);
13270 - $attribs = array();
13271 - foreach ($attributes as $name => $value)
13273 - list($attrib_namespace, $attribute) = $this->split_ns($name);
13274 - $attribs[$attrib_namespace][$attribute] = $value;
13277 - if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['base']))
13279 - $this->xml_base[] = SimplePie_Misc::absolutize_url($attribs[SIMPLEPIE_NAMESPACE_XML]['base'], end($this->xml_base));
13280 - $this->xml_base_explicit[] = true;
13284 - $this->xml_base[] = end($this->xml_base);
13285 - $this->xml_base_explicit[] = end($this->xml_base_explicit);
13288 - if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['lang']))
13290 - $this->xml_lang[] = $attribs[SIMPLEPIE_NAMESPACE_XML]['lang'];
13294 - $this->xml_lang[] = end($this->xml_lang);
13297 - if ($this->current_xhtml_construct >= 0)
13299 - $this->current_xhtml_construct++;
13300 - if (end($this->namespace) == SIMPLEPIE_NAMESPACE_XHTML)
13302 - $this->data['data'] .= '<' . end($this->element);
13303 - if (isset($attribs['']))
13305 - foreach ($attribs[''] as $name => $value)
13307 - $this->data['data'] .= ' ' . $name . '="' . htmlspecialchars($value, ENT_COMPAT, $this->encoding) . '"';
13310 - $this->data['data'] .= '>';
13315 - $this->datas[] =& $this->data;
13316 - $this->data =& $this->data['child'][end($this->namespace)][end($this->element)][];
13317 - $this->data = array('data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang));
13318 - if ((end($this->namespace) == SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] == 'xml')
13319 - || (end($this->namespace) == SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] == 'xhtml'))
13321 - $this->current_xhtml_construct = 0;
13326 - function cdata($parser, $cdata)
13328 - if ($this->current_xhtml_construct >= 0)
13330 - $this->data['data'] .= htmlspecialchars($cdata, ENT_QUOTES, $this->encoding);
13332 - elseif ($this->feed > 1)
13334 - $this->data['data'] .= $cdata;
13338 - function tag_close($parser, $tag)
13340 - if (!$this->feed)
13345 - if ($this->current_xhtml_construct >= 0)
13347 - $this->current_xhtml_construct--;
13348 - if (end($this->namespace) == SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param')))
13350 - $this->data['data'] .= '</' . end($this->element) . '>';
13353 - if ($this->current_xhtml_construct == -1)
13355 - $this->data =& $this->datas[$this->feed];
13356 - array_pop($this->datas);
13359 - array_pop($this->element);
13360 - array_pop($this->namespace);
13361 - array_pop($this->xml_base);
13362 - array_pop($this->xml_base_explicit);
13363 - array_pop($this->xml_lang);
13367 - function split_ns($string)
13369 - static $cache = array();
13370 - if (!isset($cache[$string]))
13372 - if ($pos = strpos($string, $this->separator))
13374 - static $separator_length;
13375 - if (!$separator_length)
13377 - $separator_length = strlen($this->separator);
13379 - $namespace = substr($string, 0, $pos);
13380 - $local_name = substr($string, $pos + $separator_length);
13381 - if (strtolower($namespace) === SIMPLEPIE_NAMESPACE_ITUNES)
13383 - $namespace = SIMPLEPIE_NAMESPACE_ITUNES;
13386 - // Normalize the Media RSS namespaces
13387 - if ($namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG)
13389 - $namespace = SIMPLEPIE_NAMESPACE_MEDIARSS;
13391 - $cache[$string] = array($namespace, $local_name);
13395 - $cache[$string] = array('', $string);
13398 - return $cache[$string];
13403 - * @todo Move to using an actual HTML parser (this will allow tags to be properly stripped, and to switch between HTML and XHTML), this will also make it easier to shorten a string while preserving HTML tags
13405 -class SimplePie_Sanitize
13411 - var $remove_div = true;
13412 - var $image_handler = '';
13413 - var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style');
13414 - var $encode_instead_of_strip = false;
13415 - var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc');
13416 - var $strip_comments = false;
13417 - var $output_encoding = 'UTF-8';
13418 - var $enable_cache = true;
13419 - var $cache_location = './cache';
13420 - var $cache_name_function = 'md5';
13421 - var $cache_class = 'SimplePie_Cache';
13422 - var $file_class = 'SimplePie_File';
13423 - var $timeout = 10;
13424 - var $useragent = '';
13425 - var $force_fsockopen = false;
13428 - var $replace_url_attributes = array(
13430 - 'area' => 'href',
13431 - 'blockquote' => 'cite',
13433 - 'form' => 'action',
13434 - 'img' => array('longdesc', 'src'),
13435 - 'input' => 'src',
13440 - function remove_div($enable = true)
13442 - $this->remove_div = (bool) $enable;
13445 - function set_image_handler($page = false)
13449 - $this->image_handler = (string) $page;
13453 - $this->image_handler = false;
13457 - function pass_cache_data($enable_cache = true, $cache_location = './cache', $cache_name_function = 'md5', $cache_class = 'SimplePie_Cache')
13459 - if (isset($enable_cache))
13461 - $this->enable_cache = (bool) $enable_cache;
13464 - if ($cache_location)
13466 - $this->cache_location = (string) $cache_location;
13469 - if ($cache_name_function)
13471 - $this->cache_name_function = (string) $cache_name_function;
13474 - if ($cache_class)
13476 - $this->cache_class = (string) $cache_class;
13480 - function pass_file_data($file_class = 'SimplePie_File', $timeout = 10, $useragent = '', $force_fsockopen = false)
13484 - $this->file_class = (string) $file_class;
13489 - $this->timeout = (string) $timeout;
13494 - $this->useragent = (string) $useragent;
13497 - if ($force_fsockopen)
13499 - $this->force_fsockopen = (string) $force_fsockopen;
13503 - function strip_htmltags($tags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'))
13507 - if (is_array($tags))
13509 - $this->strip_htmltags = $tags;
13513 - $this->strip_htmltags = explode(',', $tags);
13518 - $this->strip_htmltags = false;
13522 - function encode_instead_of_strip($encode = false)
13524 - $this->encode_instead_of_strip = (bool) $encode;
13527 - function strip_attributes($attribs = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'))
13531 - if (is_array($attribs))
13533 - $this->strip_attributes = $attribs;
13537 - $this->strip_attributes = explode(',', $attribs);
13542 - $this->strip_attributes = false;
13546 - function strip_comments($strip = false)
13548 - $this->strip_comments = (bool) $strip;
13551 - function set_output_encoding($encoding = 'UTF-8')
13553 - $this->output_encoding = (string) $encoding;
13557 - * Set element/attribute key/value pairs of HTML attributes
13558 - * containing URLs that need to be resolved relative to the feed
13562 - * @param array $element_attribute Element/attribute key/value pairs
13564 - function set_url_replacements($element_attribute = array('a' => 'href', 'area' => 'href', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite'))
13566 - $this->replace_url_attributes = (array) $element_attribute;
13569 - function sanitize($data, $type, $base = '')
13571 - $data = trim($data);
13572 - if ($data !== '' || $type & SIMPLEPIE_CONSTRUCT_IRI)
13574 - if ($type & SIMPLEPIE_CONSTRUCT_MAYBE_HTML)
13576 - if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>)/', $data))
13578 - $type |= SIMPLEPIE_CONSTRUCT_HTML;
13582 - $type |= SIMPLEPIE_CONSTRUCT_TEXT;
13586 - if ($type & SIMPLEPIE_CONSTRUCT_BASE64)
13588 - $data = base64_decode($data);
13591 - if ($type & SIMPLEPIE_CONSTRUCT_XHTML)
13593 - if ($this->remove_div)
13595 - $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '', $data);
13596 - $data = preg_replace('/<\/div>$/', '', $data);
13600 - $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '<div>', $data);
13604 - if ($type & (SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML))
13606 - // Strip comments
13607 - if ($this->strip_comments)
13609 - $data = SimplePie_Misc::strip_comments($data);
13612 - // Strip out HTML tags and attributes that might cause various security problems.
13613 - // Based on recommendations by Mark Pilgrim at:
13614 - // http://diveintomark.org/archives/2003/06/12/how_to_consume_rss_safely
13615 - if ($this->strip_htmltags)
13617 - foreach ($this->strip_htmltags as $tag)
13619 - $pcre = "/<($tag)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$tag" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>|(\/)?>)/siU';
13620 - while (preg_match($pcre, $data))
13622 - $data = preg_replace_callback($pcre, array(&$this, 'do_strip_htmltags'), $data);
13627 - if ($this->strip_attributes)
13629 - foreach ($this->strip_attributes as $attrib)
13631 - $data = preg_replace('/(<[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*)' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . trim($attrib) . '(?:\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>/', '\1\2\3>', $data);
13635 - // Replace relative URLs
13636 - $this->base = $base;
13637 - foreach ($this->replace_url_attributes as $element => $attributes)
13639 - $data = $this->replace_urls($data, $element, $attributes);
13642 - // If image handling (caching, etc.) is enabled, cache and rewrite all the image tags.
13643 - if (isset($this->image_handler) && ((string) $this->image_handler) !== '' && $this->enable_cache)
13645 - $images = SimplePie_Misc::get_element('img', $data);
13646 - foreach ($images as $img)
13648 - if (isset($img['attribs']['src']['data']))
13650 - $image_url = call_user_func($this->cache_name_function, $img['attribs']['src']['data']);
13651 - $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, $image_url, 'spi');
13653 - if ($cache->load())
13655 - $img['attribs']['src']['data'] = $this->image_handler . $image_url;
13656 - $data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data);
13660 - $file = new $this->file_class($img['attribs']['src']['data'], $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen, $this->proxy);
13661 - $headers = $file->headers;
13663 - if ($file->success && ($file->status_code == 200 || ($file->status_code > 206 && $file->status_code < 300)))
13665 - if ($cache->save(array('headers' => $file->headers, 'body' => $file->body)))
13667 - $img['attribs']['src']['data'] = $this->image_handler . $image_url;
13668 - $data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data);
13672 - trigger_error("$cache->name is not writeable", E_USER_WARNING);
13680 - // Having (possibly) taken stuff out, there may now be whitespace at the beginning/end of the data
13681 - $data = trim($data);
13684 - if ($type & SIMPLEPIE_CONSTRUCT_IRI)
13686 - $data = SimplePie_Misc::absolutize_url($data, $base);
13689 - if ($type & (SIMPLEPIE_CONSTRUCT_TEXT | SIMPLEPIE_CONSTRUCT_IRI))
13691 - $data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8');
13694 - if ($this->output_encoding != 'UTF-8')
13696 - $data = SimplePie_Misc::change_encoding($data, 'UTF-8', $this->output_encoding);
13702 - function replace_urls($data, $tag, $attributes)
13704 - if (!is_array($this->strip_htmltags) || !in_array($tag, $this->strip_htmltags))
13706 - $elements = SimplePie_Misc::get_element($tag, $data);
13707 - foreach ($elements as $element)
13709 - if (is_array($attributes))
13711 - foreach ($attributes as $attribute)
13713 - if (isset($element['attribs'][$attribute]['data']))
13715 - $element['attribs'][$attribute]['data'] = SimplePie_Misc::absolutize_url($element['attribs'][$attribute]['data'], $this->base);
13716 - $new_element = SimplePie_Misc::element_implode($element);
13717 - $data = str_replace($element['full'], $new_element, $data);
13718 - $element['full'] = $new_element;
13722 - elseif (isset($element['attribs'][$attributes]['data']))
13724 - $element['attribs'][$attributes]['data'] = SimplePie_Misc::absolutize_url($element['attribs'][$attributes]['data'], $this->base);
13725 - $data = str_replace($element['full'], SimplePie_Misc::element_implode($element), $data);
13732 - function do_strip_htmltags($match)
13734 - if ($this->encode_instead_of_strip)
13736 - if (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
13738 - $match[1] = htmlspecialchars($match[1], ENT_COMPAT, 'UTF-8');
13739 - $match[2] = htmlspecialchars($match[2], ENT_COMPAT, 'UTF-8');
13740 - return "<$match[1]$match[2]>$match[3]</$match[1]>";
13744 - return htmlspecialchars($match[0], ENT_COMPAT, 'UTF-8');
13747 - elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
13749 - return $match[4];