Source for file simplepie.php

Documentation is available at simplepie.php

  1. <?php
  2. /**
  3.  * This file will be removed in Joomla! CMS version 3.2. Developers should either supply their own copy
  4.  * in their installation packages or switch to JFeed.
  5.  */
  6. /**
  7.  * SimplePie
  8.  *
  9.  * A PHP-Based RSS and Atom Feed Framework.
  10.  * Takes the hard work out of managing a complete RSS/Atom solution.
  11.  *
  12.  * Copyright (c) 2004-2009, Ryan Parman and Geoffrey Sneddon
  13.  * All rights reserved.
  14.  *
  15.  * Redistribution and use in source and binary forms, with or without modification, are
  16.  * permitted provided that the following conditions are met:
  17.  *
  18.  *     * Redistributions of source code must retain the above copyright notice, this list of
  19.  *       conditions and the following disclaimer.
  20.  *
  21.  *     * Redistributions in binary form must reproduce the above copyright notice, this list
  22.  *       of conditions and the following disclaimer in the documentation and/or other materials
  23.  *       provided with the distribution.
  24.  *
  25.  *     * Neither the name of the SimplePie Team nor the names of its contributors may be used
  26.  *       to endorse or promote products derived from this software without specific prior
  27.  *       written permission.
  28.  *
  29.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  30.  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  31.  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
  32.  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  34.  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  35.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  36.  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  37.  * POSSIBILITY OF SUCH DAMAGE.
  38.  *
  39.  * @package SimplePie
  40.  * @version 1.2
  41.  * @copyright 2004-2009 Ryan Parman, Geoffrey Sneddon
  42.  * @author Ryan Parman
  43.  * @author Geoffrey Sneddon
  44.  * @link http://simplepie.org/ SimplePie
  45.  * @link http://simplepie.org/support/ Please submit all bug reports and feature requests to the SimplePie forums
  46.  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  47.  * @todo phpDoc comments
  48.  */
  49.  
  50. /**
  51.  * SimplePie Name
  52.  */
  53. define('SIMPLEPIE_NAME''SimplePie');
  54.  
  55. /**
  56.  * SimplePie Version
  57.  */
  58. define('SIMPLEPIE_VERSION''1.2');
  59.  
  60. /**
  61.  * SimplePie Build
  62.  */
  63. define('SIMPLEPIE_BUILD''20090627192103');
  64.  
  65. /**
  66.  * SimplePie Website URL
  67.  */
  68. define('SIMPLEPIE_URL''http://simplepie.org');
  69.  
  70. /**
  71.  * SimplePie Useragent
  72.  * @see SimplePie::set_useragent()
  73.  */
  74. define('SIMPLEPIE_USERAGENT'SIMPLEPIE_NAME '/' SIMPLEPIE_VERSION ' (Feed Parser; ' SIMPLEPIE_URL '; Allow like Gecko) Build/' SIMPLEPIE_BUILD);
  75.  
  76. /**
  77.  * SimplePie Linkback
  78.  */
  79. define('SIMPLEPIE_LINKBACK''<a href="' SIMPLEPIE_URL '" title="' SIMPLEPIE_NAME ' ' SIMPLEPIE_VERSION '">' SIMPLEPIE_NAME '</a>');
  80.  
  81. /**
  82.  * No Autodiscovery
  83.  * @see SimplePie::set_autodiscovery_level()
  84.  */
  85. define('SIMPLEPIE_LOCATOR_NONE'0);
  86.  
  87. /**
  88.  * Feed Link Element Autodiscovery
  89.  * @see SimplePie::set_autodiscovery_level()
  90.  */
  91. define('SIMPLEPIE_LOCATOR_AUTODISCOVERY'1);
  92.  
  93. /**
  94.  * Local Feed Extension Autodiscovery
  95.  * @see SimplePie::set_autodiscovery_level()
  96.  */
  97. define('SIMPLEPIE_LOCATOR_LOCAL_EXTENSION'2);
  98.  
  99. /**
  100.  * Local Feed Body Autodiscovery
  101.  * @see SimplePie::set_autodiscovery_level()
  102.  */
  103. define('SIMPLEPIE_LOCATOR_LOCAL_BODY'4);
  104.  
  105. /**
  106.  * Remote Feed Extension Autodiscovery
  107.  * @see SimplePie::set_autodiscovery_level()
  108.  */
  109. define('SIMPLEPIE_LOCATOR_REMOTE_EXTENSION'8);
  110.  
  111. /**
  112.  * Remote Feed Body Autodiscovery
  113.  * @see SimplePie::set_autodiscovery_level()
  114.  */
  115. define('SIMPLEPIE_LOCATOR_REMOTE_BODY'16);
  116.  
  117. /**
  118.  * All Feed Autodiscovery
  119.  * @see SimplePie::set_autodiscovery_level()
  120.  */
  121. define('SIMPLEPIE_LOCATOR_ALL'31);
  122.  
  123. /**
  124.  * No known feed type
  125.  */
  126. define('SIMPLEPIE_TYPE_NONE'0);
  127.  
  128. /**
  129.  * RSS 0.90
  130.  */
  131. define('SIMPLEPIE_TYPE_RSS_090'1);
  132.  
  133. /**
  134.  * RSS 0.91 (Netscape)
  135.  */
  136. define('SIMPLEPIE_TYPE_RSS_091_NETSCAPE'2);
  137.  
  138. /**
  139.  * RSS 0.91 (Userland)
  140.  */
  141. define('SIMPLEPIE_TYPE_RSS_091_USERLAND'4);
  142.  
  143. /**
  144.  * RSS 0.91 (both Netscape and Userland)
  145.  */
  146. define('SIMPLEPIE_TYPE_RSS_091'6);
  147.  
  148. /**
  149.  * RSS 0.92
  150.  */
  151. define('SIMPLEPIE_TYPE_RSS_092'8);
  152.  
  153. /**
  154.  * RSS 0.93
  155.  */
  156. define('SIMPLEPIE_TYPE_RSS_093'16);
  157.  
  158. /**
  159.  * RSS 0.94
  160.  */
  161. define('SIMPLEPIE_TYPE_RSS_094'32);
  162.  
  163. /**
  164.  * RSS 1.0
  165.  */
  166. define('SIMPLEPIE_TYPE_RSS_10'64);
  167.  
  168. /**
  169.  * RSS 2.0
  170.  */
  171. define('SIMPLEPIE_TYPE_RSS_20'128);
  172.  
  173. /**
  174.  * RDF-based RSS
  175.  */
  176. define('SIMPLEPIE_TYPE_RSS_RDF'65);
  177.  
  178. /**
  179.  * Non-RDF-based RSS (truly intended as syndication format)
  180.  */
  181. define('SIMPLEPIE_TYPE_RSS_SYNDICATION'190);
  182.  
  183. /**
  184.  * All RSS
  185.  */
  186. define('SIMPLEPIE_TYPE_RSS_ALL'255);
  187.  
  188. /**
  189.  * Atom 0.3
  190.  */
  191. define('SIMPLEPIE_TYPE_ATOM_03'256);
  192.  
  193. /**
  194.  * Atom 1.0
  195.  */
  196. define('SIMPLEPIE_TYPE_ATOM_10'512);
  197.  
  198. /**
  199.  * All Atom
  200.  */
  201. define('SIMPLEPIE_TYPE_ATOM_ALL'768);
  202.  
  203. /**
  204.  * All feed types
  205.  */
  206. define('SIMPLEPIE_TYPE_ALL'1023);
  207.  
  208. /**
  209.  * No construct
  210.  */
  211. define('SIMPLEPIE_CONSTRUCT_NONE'0);
  212.  
  213. /**
  214.  * Text construct
  215.  */
  216. define('SIMPLEPIE_CONSTRUCT_TEXT'1);
  217.  
  218. /**
  219.  * HTML construct
  220.  */
  221. define('SIMPLEPIE_CONSTRUCT_HTML'2);
  222.  
  223. /**
  224.  * XHTML construct
  225.  */
  226. define('SIMPLEPIE_CONSTRUCT_XHTML'4);
  227.  
  228. /**
  229.  * base64-encoded construct
  230.  */
  231. define('SIMPLEPIE_CONSTRUCT_BASE64'8);
  232.  
  233. /**
  234.  * IRI construct
  235.  */
  236. define('SIMPLEPIE_CONSTRUCT_IRI'16);
  237.  
  238. /**
  239.  * A construct that might be HTML
  240.  */
  241. define('SIMPLEPIE_CONSTRUCT_MAYBE_HTML'32);
  242.  
  243. /**
  244.  * All constructs
  245.  */
  246. define('SIMPLEPIE_CONSTRUCT_ALL'63);
  247.  
  248. /**
  249.  * Don't change case
  250.  */
  251. define('SIMPLEPIE_SAME_CASE'1);
  252.  
  253. /**
  254.  * Change to lowercase
  255.  */
  256. define('SIMPLEPIE_LOWERCASE'2);
  257.  
  258. /**
  259.  * Change to uppercase
  260.  */
  261. define('SIMPLEPIE_UPPERCASE'4);
  262.  
  263. /**
  264.  * PCRE for HTML attributes
  265.  */
  266. 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]*');
  267.  
  268. /**
  269.  * PCRE for XML attributes
  270.  */
  271. define('SIMPLEPIE_PCRE_XML_ATTRIBUTE''((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'))*)\s*');
  272.  
  273. /**
  274.  * XML Namespace
  275.  */
  276. define('SIMPLEPIE_NAMESPACE_XML''http://www.w3.org/XML/1998/namespace');
  277.  
  278. /**
  279.  * Atom 1.0 Namespace
  280.  */
  281. define('SIMPLEPIE_NAMESPACE_ATOM_10''http://www.w3.org/2005/Atom');
  282.  
  283. /**
  284.  * Atom 0.3 Namespace
  285.  */
  286. define('SIMPLEPIE_NAMESPACE_ATOM_03''http://purl.org/atom/ns#');
  287.  
  288. /**
  289.  * RDF Namespace
  290.  */
  291. define('SIMPLEPIE_NAMESPACE_RDF''http://www.w3.org/1999/02/22-rdf-syntax-ns#');
  292.  
  293. /**
  294.  * RSS 0.90 Namespace
  295.  */
  296. define('SIMPLEPIE_NAMESPACE_RSS_090''http://my.netscape.com/rdf/simple/0.9/');
  297.  
  298. /**
  299.  * RSS 1.0 Namespace
  300.  */
  301. define('SIMPLEPIE_NAMESPACE_RSS_10''http://purl.org/rss/1.0/');
  302.  
  303. /**
  304.  * RSS 1.0 Content Module Namespace
  305.  */
  306. define('SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT''http://purl.org/rss/1.0/modules/content/');
  307.  
  308. /**
  309.  * RSS 2.0 Namespace
  310.  * (Stupid, I know, but I'm certain it will confuse people less with support.)
  311.  */
  312. define('SIMPLEPIE_NAMESPACE_RSS_20''');
  313.  
  314. /**
  315.  * DC 1.0 Namespace
  316.  */
  317. define('SIMPLEPIE_NAMESPACE_DC_10''http://purl.org/dc/elements/1.0/');
  318.  
  319. /**
  320.  * DC 1.1 Namespace
  321.  */
  322. define('SIMPLEPIE_NAMESPACE_DC_11''http://purl.org/dc/elements/1.1/');
  323.  
  324. /**
  325.  * W3C Basic Geo (WGS84 lat/long) Vocabulary Namespace
  326.  */
  327. define('SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO''http://www.w3.org/2003/01/geo/wgs84_pos#');
  328.  
  329. /**
  330.  * GeoRSS Namespace
  331.  */
  332. define('SIMPLEPIE_NAMESPACE_GEORSS''http://www.georss.org/georss');
  333.  
  334. /**
  335.  * Media RSS Namespace
  336.  */
  337. define('SIMPLEPIE_NAMESPACE_MEDIARSS''http://search.yahoo.com/mrss/');
  338.  
  339. /**
  340.  * Wrong Media RSS Namespace
  341.  */
  342. define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG''http://search.yahoo.com/mrss');
  343.  
  344. /**
  345.  * iTunes RSS Namespace
  346.  */
  347. define('SIMPLEPIE_NAMESPACE_ITUNES''http://www.itunes.com/dtds/podcast-1.0.dtd');
  348.  
  349. /**
  350.  * XHTML Namespace
  351.  */
  352. define('SIMPLEPIE_NAMESPACE_XHTML''http://www.w3.org/1999/xhtml');
  353.  
  354. /**
  355.  * IANA Link Relations Registry
  356.  */
  357. define('SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY''http://www.iana.org/assignments/relation/');
  358.  
  359. /**
  360.  * Whether we're running on PHP5
  361.  */
  362. define('SIMPLEPIE_PHP5'version_compare(PHP_VERSION'5.0.0''>='));
  363.  
  364. /**
  365.  * No file source
  366.  */
  367. define('SIMPLEPIE_FILE_SOURCE_NONE'0);
  368.  
  369. /**
  370.  * Remote file source
  371.  */
  372. define('SIMPLEPIE_FILE_SOURCE_REMOTE'1);
  373.  
  374. /**
  375.  * Local file source
  376.  */
  377. define('SIMPLEPIE_FILE_SOURCE_LOCAL'2);
  378.  
  379. /**
  380.  * fsockopen() file source
  381.  */
  382. define('SIMPLEPIE_FILE_SOURCE_FSOCKOPEN'4);
  383.  
  384. /**
  385.  * cURL file source
  386.  */
  387. define('SIMPLEPIE_FILE_SOURCE_CURL'8);
  388.  
  389. /**
  390.  * file_get_contents() file source
  391.  */
  392. define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS'16);
  393.  
  394. /**
  395.  * SimplePie
  396.  *
  397.  * @package SimplePie
  398.  */
  399. class SimplePie
  400. {
  401.     /**
  402.      * @var array Raw data
  403.      * @access private
  404.      */
  405.     var $data array();
  406.  
  407.     /**
  408.      * @var mixed Error string
  409.      * @access private
  410.      */
  411.     var $error;
  412.  
  413.     /**
  414.      * @var object Instance of SimplePie_Sanitize (or other class)
  415.      * @see SimplePie::set_sanitize_class()
  416.      * @access private
  417.      */
  418.     var $sanitize;
  419.  
  420.     /**
  421.      * @var string SimplePie Useragent
  422.      * @see SimplePie::set_useragent()
  423.      * @access private
  424.      */
  425.     var $useragent SIMPLEPIE_USERAGENT;
  426.  
  427.     /**
  428.      * @var string Feed URL
  429.      * @see SimplePie::set_feed_url()
  430.      * @access private
  431.      */
  432.     var $feed_url;
  433.  
  434.     /**
  435.      * @var object Instance of SimplePie_File to use as a feed
  436.      * @see SimplePie::set_file()
  437.      * @access private
  438.      */
  439.     var $file;
  440.  
  441.     /**
  442.      * @var string Raw feed data
  443.      * @see SimplePie::set_raw_data()
  444.      * @access private
  445.      */
  446.     var $raw_data;
  447.  
  448.     /**
  449.      * @var int Timeout for fetching remote files
  450.      * @see SimplePie::set_timeout()
  451.      * @access private
  452.      */
  453.     var $timeout 10;
  454.  
  455.     /**
  456.      * @var bool Forces fsockopen() to be used for remote files instead
  457.      *  of cURL, even if a new enough version is installed
  458.      * @see SimplePie::force_fsockopen()
  459.      * @access private
  460.      */
  461.     var $force_fsockopen false;
  462.  
  463.     /**
  464.      * @var bool Force the given data/URL to be treated as a feed no matter what
  465.      *  it appears like
  466.      * @see SimplePie::force_feed()
  467.      * @access private
  468.      */
  469.     var $force_feed false;
  470.  
  471.     /**
  472.      * @var bool Enable/Disable XML dump
  473.      * @see SimplePie::enable_xml_dump()
  474.      * @access private
  475.      */
  476.     var $xml_dump false;
  477.  
  478.     /**
  479.      * @var bool Enable/Disable Caching
  480.      * @see SimplePie::enable_cache()
  481.      * @access private
  482.      */
  483.     var $cache true;
  484.  
  485.     /**
  486.      * @var int Cache duration (in seconds)
  487.      * @see SimplePie::set_cache_duration()
  488.      * @access private
  489.      */
  490.     var $cache_duration 3600;
  491.  
  492.     /**
  493.      * @var int Auto-discovery cache duration (in seconds)
  494.      * @see SimplePie::set_autodiscovery_cache_duration()
  495.      * @access private
  496.      */
  497.     var $autodiscovery_cache_duration 604800// 7 Days.
  498.  
  499.     /**
  500.      * @var string Cache location (relative to executing script)
  501.      * @see SimplePie::set_cache_location()
  502.      * @access private
  503.      */
  504.     var $cache_location './cache';
  505.  
  506.     /**
  507.      * @var string Function that creates the cache filename
  508.      * @see SimplePie::set_cache_name_function()
  509.      * @access private
  510.      */
  511.     var $cache_name_function 'md5';
  512.  
  513.     /**
  514.      * @var bool Reorder feed by date descending
  515.      * @see SimplePie::enable_order_by_date()
  516.      * @access private
  517.      */
  518.     var $order_by_date true;
  519.  
  520.     /**
  521.      * @var mixed Force input encoding to be set to the follow value
  522.      *  (false, or anything type-cast to false, disables this feature)
  523.      * @see SimplePie::set_input_encoding()
  524.      * @access private
  525.      */
  526.     var $input_encoding false;
  527.  
  528.     /**
  529.      * @var int Feed Autodiscovery Level
  530.      * @see SimplePie::set_autodiscovery_level()
  531.      * @access private
  532.      */
  533.     var $autodiscovery SIMPLEPIE_LOCATOR_ALL;
  534.  
  535.     /**
  536.      * @var string Class used for caching feeds
  537.      * @see SimplePie::set_cache_class()
  538.      * @access private
  539.      */
  540.     var $cache_class 'SimplePie_Cache';
  541.  
  542.     /**
  543.      * @var string Class used for locating feeds
  544.      * @see SimplePie::set_locator_class()
  545.      * @access private
  546.      */
  547.     var $locator_class 'SimplePie_Locator';
  548.  
  549.     /**
  550.      * @var string Class used for parsing feeds
  551.      * @see SimplePie::set_parser_class()
  552.      * @access private
  553.      */
  554.     var $parser_class 'SimplePie_Parser';
  555.  
  556.     /**
  557.      * @var string Class used for fetching feeds
  558.      * @see SimplePie::set_file_class()
  559.      * @access private
  560.      */
  561.     var $file_class 'SimplePie_File';
  562.  
  563.     /**
  564.      * @var string Class used for items
  565.      * @see SimplePie::set_item_class()
  566.      * @access private
  567.      */
  568.     var $item_class 'SimplePie_Item';
  569.  
  570.     /**
  571.      * @var string Class used for authors
  572.      * @see SimplePie::set_author_class()
  573.      * @access private
  574.      */
  575.     var $author_class 'SimplePie_Author';
  576.  
  577.     /**
  578.      * @var string Class used for categories
  579.      * @see SimplePie::set_category_class()
  580.      * @access private
  581.      */
  582.     var $category_class 'SimplePie_Category';
  583.  
  584.     /**
  585.      * @var string Class used for enclosures
  586.      * @see SimplePie::set_enclosures_class()
  587.      * @access private
  588.      */
  589.     var $enclosure_class 'SimplePie_Enclosure';
  590.  
  591.     /**
  592.      * @var string Class used for Media RSS <media:text> captions
  593.      * @see SimplePie::set_caption_class()
  594.      * @access private
  595.      */
  596.     var $caption_class 'SimplePie_Caption';
  597.  
  598.     /**
  599.      * @var string Class used for Media RSS <media:copyright>
  600.      * @see SimplePie::set_copyright_class()
  601.      * @access private
  602.      */
  603.     var $copyright_class 'SimplePie_Copyright';
  604.  
  605.     /**
  606.      * @var string Class used for Media RSS <media:credit>
  607.      * @see SimplePie::set_credit_class()
  608.      * @access private
  609.      */
  610.     var $credit_class 'SimplePie_Credit';
  611.  
  612.     /**
  613.      * @var string Class used for Media RSS <media:rating>
  614.      * @see SimplePie::set_rating_class()
  615.      * @access private
  616.      */
  617.     var $rating_class 'SimplePie_Rating';
  618.  
  619.     /**
  620.      * @var string Class used for Media RSS <media:restriction>
  621.      * @see SimplePie::set_restriction_class()
  622.      * @access private
  623.      */
  624.     var $restriction_class 'SimplePie_Restriction';
  625.  
  626.     /**
  627.      * @var string Class used for content-type sniffing
  628.      * @see SimplePie::set_content_type_sniffer_class()
  629.      * @access private
  630.      */
  631.     var $content_type_sniffer_class 'SimplePie_Content_Type_Sniffer';
  632.  
  633.     /**
  634.      * @var string Class used for item sources.
  635.      * @see SimplePie::set_source_class()
  636.      * @access private
  637.      */
  638.     var $source_class 'SimplePie_Source';
  639.  
  640.     /**
  641.      * @var mixed Set javascript query string parameter (false, or
  642.      *  anything type-cast to false, disables this feature)
  643.      * @see SimplePie::set_javascript()
  644.      * @access private
  645.      */
  646.     var $javascript 'js';
  647.  
  648.     /**
  649.      * @var int Maximum number of feeds to check with autodiscovery
  650.      * @see SimplePie::set_max_checked_feeds()
  651.      * @access private
  652.      */
  653.     var $max_checked_feeds 10;
  654.  
  655.     /**
  656.      * @var array All the feeds found during the autodiscovery process
  657.      * @see SimplePie::get_all_discovered_feeds()
  658.      * @access private
  659.      */
  660.     var $all_discovered_feeds array();
  661.  
  662.     /**
  663.      * @var string Web-accessible path to the handler_favicon.php file.
  664.      * @see SimplePie::set_favicon_handler()
  665.      * @access private
  666.      */
  667.     var $favicon_handler '';
  668.  
  669.     /**
  670.      * @var string Web-accessible path to the handler_image.php file.
  671.      * @see SimplePie::set_image_handler()
  672.      * @access private
  673.      */
  674.     var $image_handler '';
  675.  
  676.     /**
  677.      * @var array Stores the URLs when multiple feeds are being initialized.
  678.      * @see SimplePie::set_feed_url()
  679.      * @access private
  680.      */
  681.     var $multifeed_url array();
  682.  
  683.     /**
  684.      * @var array Stores SimplePie objects when multiple feeds initialized.
  685.      * @access private
  686.      */
  687.     var $multifeed_objects array();
  688.  
  689.     /**
  690.      * @var array Stores the get_object_vars() array for use with multifeeds.
  691.      * @see SimplePie::set_feed_url()
  692.      * @access private
  693.      */
  694.     var $config_settings null;
  695.  
  696.     /**
  697.      * @var integer Stores the number of items to return per-feed with multifeeds.
  698.      * @see SimplePie::set_item_limit()
  699.      * @access private
  700.      */
  701.     var $item_limit 0;
  702.  
  703.     /**
  704.      * @var array Stores the default attributes to be stripped by strip_attributes().
  705.      * @see SimplePie::strip_attributes()
  706.      * @access private
  707.      */
  708.     var $strip_attributes array('bgsound''class''expr''id''style''onclick''onerror''onfinish''onmouseover''onmouseout''onfocus''onblur''lowsrc''dynsrc');
  709.  
  710.     /**
  711.      * @var array Stores the default tags to be stripped by strip_htmltags().
  712.      * @see SimplePie::strip_htmltags()
  713.      * @access private
  714.      */
  715.     var $strip_htmltags array('base''blink''body''doctype''embed''font''form''frame''frameset''html''iframe''input''marquee''meta''noscript''object''param''script''style');
  716.  
  717.     /**
  718.      * The SimplePie class contains feed level data and options
  719.      *
  720.      * There are two ways that you can create a new SimplePie object. The first
  721.      * is by passing a feed URL as a parameter to the SimplePie constructor
  722.      * (as well as optionally setting the cache location and cache expiry). This
  723.      * will initialise the whole feed with all of the default settings, and you
  724.      * can begin accessing methods and properties immediately.
  725.      *
  726.      * The second way is to create the SimplePie object with no parameters
  727.      * at all. This will enable you to set configuration options. After setting
  728.      * them, you must initialise the feed using $feed->init(). At that point the
  729.      * object's methods and properties will be available to you. This format is
  730.      * what is used throughout this documentation.
  731.      *
  732.      * @access public
  733.      * @since 1.0 Preview Release
  734.      * @param string $feed_url This is the URL you want to parse.
  735.      * @param string $cache_location This is where you want the cache to be stored.
  736.      * @param int $cache_duration This is the number of seconds that you want to store the cache file for.
  737.      */
  738.     function SimplePie($feed_url null$cache_location null$cache_duration null)
  739.     {
  740.         // Other objects, instances created here so we can set options on them
  741.         $this->sanitize new SimplePie_Sanitize;
  742.  
  743.         // Set options if they're passed to the constructor
  744.         if ($cache_location !== null)
  745.         {
  746.             $this->set_cache_location($cache_location);
  747.         }
  748.  
  749.         if ($cache_duration !== null)
  750.         {
  751.             $this->set_cache_duration($cache_duration);
  752.         }
  753.  
  754.         // Only init the script if we're passed a feed URL
  755.         if ($feed_url !== null)
  756.         {
  757.             $this->set_feed_url($feed_url);
  758.             $this->init();
  759.         }
  760.     }
  761.  
  762.     /**
  763.      * Used for converting object to a string
  764.      */
  765.     function __toString()
  766.     {
  767.         return md5(serialize($this->data));
  768.     }
  769.  
  770.     /**
  771.      * Remove items that link back to this before destroying this object
  772.      */
  773.     function __destruct()
  774.     {
  775.         if ((version_compare(PHP_VERSION'5.3''<'|| !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))
  776.         {
  777.             if (!empty($this->data['items']))
  778.             {
  779.                 foreach ($this->data['items'as $item)
  780.                 {
  781.                     $item->__destruct();
  782.                 }
  783.                 unset($item$this->data['items']);
  784.             }
  785.             if (!empty($this->data['ordered_items']))
  786.             {
  787.                 foreach ($this->data['ordered_items'as $item)
  788.                 {
  789.                     $item->__destruct();
  790.                 }
  791.                 unset($item$this->data['ordered_items']);
  792.             }
  793.         }
  794.     }
  795.  
  796.     /**
  797.      * Force the given data/URL to be treated as a feed no matter what it
  798.      * appears like
  799.      *
  800.      * @access public
  801.      * @since 1.1
  802.      * @param bool $enable Force the given data/URL to be treated as a feed
  803.      */
  804.     function force_feed($enable false)
  805.     {
  806.         $this->force_feed = (bool) $enable;
  807.     }
  808.  
  809.     /**
  810.      * This is the URL of the feed you want to parse.
  811.      *
  812.      * This allows you to enter the URL of the feed you want to parse, or the
  813.      * website you want to try to use auto-discovery on. This takes priority
  814.      * over any set raw data.
  815.      *
  816.      * You can set multiple feeds to mash together by passing an array instead
  817.      * of a string for the $url. Remember that with each additional feed comes
  818.      * additional processing and resources.
  819.      *
  820.      * @access public
  821.      * @since 1.0 Preview Release
  822.      * @param mixed $url This is the URL (or array of URLs) that you want to parse.
  823.      * @see SimplePie::set_raw_data()
  824.      */
  825.     function set_feed_url($url)
  826.     {
  827.         if (is_array($url))
  828.         {
  829.             $this->multifeed_url array();
  830.             foreach ($url as $value)
  831.             {
  832.                 $this->multifeed_url[SimplePie_Misc::fix_protocol($value1);
  833.             }
  834.         }
  835.         else
  836.         {
  837.             $this->feed_url SimplePie_Misc::fix_protocol($url1);
  838.         }
  839.     }
  840.  
  841.     /**
  842.      * Provides an instance of SimplePie_File to use as a feed
  843.      *
  844.      * @access public
  845.      * @param object &$file Instance of SimplePie_File (or subclass)
  846.      * @return bool True on success, false on failure
  847.      */
  848.     function set_file(&$file)
  849.     {
  850.         if (is_a($file'SimplePie_File'))
  851.         {
  852.             $this->feed_url $file->url;
  853.             $this->file =$file;
  854.             return true;
  855.         }
  856.         return false;
  857.     }
  858.  
  859.     /**
  860.      * Allows you to use a string of RSS/Atom data instead of a remote feed.
  861.      *
  862.      * If you have a feed available as a string in PHP, you can tell SimplePie
  863.      * to parse that data string instead of a remote feed. Any set feed URL
  864.      * takes precedence.
  865.      *
  866.      * @access public
  867.      * @since 1.0 Beta 3
  868.      * @param string $data RSS or Atom data as a string.
  869.      * @see SimplePie::set_feed_url()
  870.      */
  871.     function set_raw_data($data)
  872.     {
  873.         $this->raw_data $data;
  874.     }
  875.  
  876.     /**
  877.      * Allows you to override the default timeout for fetching remote feeds.
  878.      *
  879.      * This allows you to change the maximum time the feed's server to respond
  880.      * and send the feed back.
  881.      *
  882.      * @access public
  883.      * @since 1.0 Beta 3
  884.      * @param int $timeout The maximum number of seconds to spend waiting to retrieve a feed.
  885.      */
  886.     function set_timeout($timeout 10)
  887.     {
  888.         $this->timeout = (int) $timeout;
  889.     }
  890.  
  891.     /**
  892.      * Forces SimplePie to use fsockopen() instead of the preferred cURL
  893.      * functions.
  894.      *
  895.      * @access public
  896.      * @since 1.0 Beta 3
  897.      * @param bool $enable Force fsockopen() to be used
  898.      */
  899.     function force_fsockopen($enable false)
  900.     {
  901.         $this->force_fsockopen = (bool) $enable;
  902.     }
  903.  
  904.     /**
  905.      * Outputs the raw XML content of the feed, after it has gone through
  906.      * SimplePie's filters.
  907.      *
  908.      * Used only for debugging, this function will output the XML content as
  909.      * text/xml. When SimplePie reads in a feed, it does a bit of cleaning up
  910.      * before trying to parse it. Many parts of the feed are re-written in
  911.      * memory, and in the end, you have a parsable feed. XML dump shows you the
  912.      * actual XML that SimplePie tries to parse, which may or may not be very
  913.      * different from the original feed.
  914.      *
  915.      * @access public
  916.      * @since 1.0 Preview Release
  917.      * @param bool $enable Enable XML dump
  918.      */
  919.     function enable_xml_dump($enable false)
  920.     {
  921.         $this->xml_dump = (bool) $enable;
  922.     }
  923.  
  924.     /**
  925.      * Enables/disables caching in SimplePie.
  926.      *
  927.      * This option allows you to disable caching all-together in SimplePie.
  928.      * However, disabling the cache can lead to longer load times.
  929.      *
  930.      * @access public
  931.      * @since 1.0 Preview Release
  932.      * @param bool $enable Enable caching
  933.      */
  934.     function enable_cache($enable true)
  935.     {
  936.         $this->cache = (bool) $enable;
  937.     }
  938.  
  939.     /**
  940.      * Set the length of time (in seconds) that the contents of a feed
  941.      * will be cached.
  942.      *
  943.      * @access public
  944.      * @param int $seconds The feed content cache duration.
  945.      */
  946.     function set_cache_duration($seconds 3600)
  947.     {
  948.         $this->cache_duration = (int) $seconds;
  949.     }
  950.  
  951.     /**
  952.      * Set the length of time (in seconds) that the autodiscovered feed
  953.      * URL will be cached.
  954.      *
  955.      * @access public
  956.      * @param int $seconds The autodiscovered feed URL cache duration.
  957.      */
  958.     function set_autodiscovery_cache_duration($seconds 604800)
  959.     {
  960.         $this->autodiscovery_cache_duration = (int) $seconds;
  961.     }
  962.  
  963.     /**
  964.      * Set the file system location where the cached files should be stored.
  965.      *
  966.      * @access public
  967.      * @param string $location The file system location.
  968.      */
  969.     function set_cache_location($location './cache')
  970.     {
  971.         $this->cache_location = (string) $location;
  972.     }
  973.  
  974.     /**
  975.      * Determines whether feed items should be sorted into reverse chronological order.
  976.      *
  977.      * @access public
  978.      * @param bool $enable Sort as reverse chronological order.
  979.      */
  980.     function enable_order_by_date($enable true)
  981.     {
  982.         $this->order_by_date = (bool) $enable;
  983.     }
  984.  
  985.     /**
  986.      * Allows you to override the character encoding reported by the feed.
  987.      *
  988.      * @access public
  989.      * @param string $encoding Character encoding.
  990.      */
  991.     function set_input_encoding($encoding false)
  992.     {
  993.         if ($encoding)
  994.         {
  995.             $this->input_encoding = (string) $encoding;
  996.         }
  997.         else
  998.         {
  999.             $this->input_encoding false;
  1000.         }
  1001.     }
  1002.  
  1003.     /**
  1004.      * Set how much feed autodiscovery to do
  1005.      *
  1006.      * @access public
  1007.      * @see SIMPLEPIE_LOCATOR_NONE
  1008.      * @see SIMPLEPIE_LOCATOR_AUTODISCOVERY
  1009.      * @see SIMPLEPIE_LOCATOR_LOCAL_EXTENSION
  1010.      * @see SIMPLEPIE_LOCATOR_LOCAL_BODY
  1011.      * @see SIMPLEPIE_LOCATOR_REMOTE_EXTENSION
  1012.      * @see SIMPLEPIE_LOCATOR_REMOTE_BODY
  1013.      * @see SIMPLEPIE_LOCATOR_ALL
  1014.      * @param int $level Feed Autodiscovery Level (level can be a
  1015.      *  combination of the above constants, see bitwise OR operator)
  1016.      */
  1017.     function set_autodiscovery_level($level SIMPLEPIE_LOCATOR_ALL)
  1018.     {
  1019.         $this->autodiscovery = (int) $level;
  1020.     }
  1021.  
  1022.     /**
  1023.      * Allows you to change which class SimplePie uses for caching.
  1024.      * Useful when you are overloading or extending SimplePie's default classes.
  1025.      *
  1026.      * @access public
  1027.      * @param string $class Name of custom class.
  1028.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1029.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1030.      */
  1031.     function set_cache_class($class 'SimplePie_Cache')
  1032.     {
  1033.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Cache'))
  1034.         {
  1035.             $this->cache_class $class;
  1036.             return true;
  1037.         }
  1038.         return false;
  1039.     }
  1040.  
  1041.     /**
  1042.      * Allows you to change which class SimplePie uses for auto-discovery.
  1043.      * Useful when you are overloading or extending SimplePie's default classes.
  1044.      *
  1045.      * @access public
  1046.      * @param string $class Name of custom class.
  1047.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1048.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1049.      */
  1050.     function set_locator_class($class 'SimplePie_Locator')
  1051.     {
  1052.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Locator'))
  1053.         {
  1054.             $this->locator_class $class;
  1055.             return true;
  1056.         }
  1057.         return false;
  1058.     }
  1059.  
  1060.     /**
  1061.      * Allows you to change which class SimplePie uses for XML parsing.
  1062.      * Useful when you are overloading or extending SimplePie's default classes.
  1063.      *
  1064.      * @access public
  1065.      * @param string $class Name of custom class.
  1066.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1067.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1068.      */
  1069.     function set_parser_class($class 'SimplePie_Parser')
  1070.     {
  1071.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Parser'))
  1072.         {
  1073.             $this->parser_class $class;
  1074.             return true;
  1075.         }
  1076.         return false;
  1077.     }
  1078.  
  1079.     /**
  1080.      * Allows you to change which class SimplePie uses for remote file fetching.
  1081.      * Useful when you are overloading or extending SimplePie's default classes.
  1082.      *
  1083.      * @access public
  1084.      * @param string $class Name of custom class.
  1085.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1086.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1087.      */
  1088.     function set_file_class($class 'SimplePie_File')
  1089.     {
  1090.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_File'))
  1091.         {
  1092.             $this->file_class $class;
  1093.             return true;
  1094.         }
  1095.         return false;
  1096.     }
  1097.  
  1098.     /**
  1099.      * Allows you to change which class SimplePie uses for data sanitization.
  1100.      * Useful when you are overloading or extending SimplePie's default classes.
  1101.      *
  1102.      * @access public
  1103.      * @param string $class Name of custom class.
  1104.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1105.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1106.      */
  1107.     function set_sanitize_class($class 'SimplePie_Sanitize')
  1108.     {
  1109.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Sanitize'))
  1110.         {
  1111.             $this->sanitize new $class;
  1112.             return true;
  1113.         }
  1114.         return false;
  1115.     }
  1116.  
  1117.     /**
  1118.      * Allows you to change which class SimplePie uses for handling feed items.
  1119.      * Useful when you are overloading or extending SimplePie's default classes.
  1120.      *
  1121.      * @access public
  1122.      * @param string $class Name of custom class.
  1123.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1124.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1125.      */
  1126.     function set_item_class($class 'SimplePie_Item')
  1127.     {
  1128.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Item'))
  1129.         {
  1130.             $this->item_class $class;
  1131.             return true;
  1132.         }
  1133.         return false;
  1134.     }
  1135.  
  1136.     /**
  1137.      * Allows you to change which class SimplePie uses for handling author data.
  1138.      * Useful when you are overloading or extending SimplePie's default classes.
  1139.      *
  1140.      * @access public
  1141.      * @param string $class Name of custom class.
  1142.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1143.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1144.      */
  1145.     function set_author_class($class 'SimplePie_Author')
  1146.     {
  1147.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Author'))
  1148.         {
  1149.             $this->author_class $class;
  1150.             return true;
  1151.         }
  1152.         return false;
  1153.     }
  1154.  
  1155.     /**
  1156.      * Allows you to change which class SimplePie uses for handling category data.
  1157.      * Useful when you are overloading or extending SimplePie's default classes.
  1158.      *
  1159.      * @access public
  1160.      * @param string $class Name of custom class.
  1161.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1162.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1163.      */
  1164.     function set_category_class($class 'SimplePie_Category')
  1165.     {
  1166.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Category'))
  1167.         {
  1168.             $this->category_class $class;
  1169.             return true;
  1170.         }
  1171.         return false;
  1172.     }
  1173.  
  1174.     /**
  1175.      * Allows you to change which class SimplePie uses for feed enclosures.
  1176.      * Useful when you are overloading or extending SimplePie's default classes.
  1177.      *
  1178.      * @access public
  1179.      * @param string $class Name of custom class.
  1180.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1181.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1182.      */
  1183.     function set_enclosure_class($class 'SimplePie_Enclosure')
  1184.     {
  1185.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Enclosure'))
  1186.         {
  1187.             $this->enclosure_class $class;
  1188.             return true;
  1189.         }
  1190.         return false;
  1191.     }
  1192.  
  1193.     /**
  1194.      * Allows you to change which class SimplePie uses for <media:text> captions
  1195.      * Useful when you are overloading or extending SimplePie's default classes.
  1196.      *
  1197.      * @access public
  1198.      * @param string $class Name of custom class.
  1199.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1200.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1201.      */
  1202.     function set_caption_class($class 'SimplePie_Caption')
  1203.     {
  1204.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Caption'))
  1205.         {
  1206.             $this->caption_class $class;
  1207.             return true;
  1208.         }
  1209.         return false;
  1210.     }
  1211.  
  1212.     /**
  1213.      * Allows you to change which class SimplePie uses for <media:copyright>
  1214.      * Useful when you are overloading or extending SimplePie's default classes.
  1215.      *
  1216.      * @access public
  1217.      * @param string $class Name of custom class.
  1218.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1219.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1220.      */
  1221.     function set_copyright_class($class 'SimplePie_Copyright')
  1222.     {
  1223.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Copyright'))
  1224.         {
  1225.             $this->copyright_class $class;
  1226.             return true;
  1227.         }
  1228.         return false;
  1229.     }
  1230.  
  1231.     /**
  1232.      * Allows you to change which class SimplePie uses for <media:credit>
  1233.      * Useful when you are overloading or extending SimplePie's default classes.
  1234.      *
  1235.      * @access public
  1236.      * @param string $class Name of custom class.
  1237.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1238.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1239.      */
  1240.     function set_credit_class($class 'SimplePie_Credit')
  1241.     {
  1242.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Credit'))
  1243.         {
  1244.             $this->credit_class $class;
  1245.             return true;
  1246.         }
  1247.         return false;
  1248.     }
  1249.  
  1250.     /**
  1251.      * Allows you to change which class SimplePie uses for <media:rating>
  1252.      * Useful when you are overloading or extending SimplePie's default classes.
  1253.      *
  1254.      * @access public
  1255.      * @param string $class Name of custom class.
  1256.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1257.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1258.      */
  1259.     function set_rating_class($class 'SimplePie_Rating')
  1260.     {
  1261.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Rating'))
  1262.         {
  1263.             $this->rating_class $class;
  1264.             return true;
  1265.         }
  1266.         return false;
  1267.     }
  1268.  
  1269.     /**
  1270.      * Allows you to change which class SimplePie uses for <media:restriction>
  1271.      * Useful when you are overloading or extending SimplePie's default classes.
  1272.      *
  1273.      * @access public
  1274.      * @param string $class Name of custom class.
  1275.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1276.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1277.      */
  1278.     function set_restriction_class($class 'SimplePie_Restriction')
  1279.     {
  1280.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Restriction'))
  1281.         {
  1282.             $this->restriction_class $class;
  1283.             return true;
  1284.         }
  1285.         return false;
  1286.     }
  1287.  
  1288.     /**
  1289.      * Allows you to change which class SimplePie uses for content-type sniffing.
  1290.      * Useful when you are overloading or extending SimplePie's default classes.
  1291.      *
  1292.      * @access public
  1293.      * @param string $class Name of custom class.
  1294.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1295.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1296.      */
  1297.     function set_content_type_sniffer_class($class 'SimplePie_Content_Type_Sniffer')
  1298.     {
  1299.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Content_Type_Sniffer'))
  1300.         {
  1301.             $this->content_type_sniffer_class $class;
  1302.             return true;
  1303.         }
  1304.         return false;
  1305.     }
  1306.  
  1307.     /**
  1308.      * Allows you to change which class SimplePie uses item sources.
  1309.      * Useful when you are overloading or extending SimplePie's default classes.
  1310.      *
  1311.      * @access public
  1312.      * @param string $class Name of custom class.
  1313.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1314.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1315.      */
  1316.     function set_source_class($class 'SimplePie_Source')
  1317.     {
  1318.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Source'))
  1319.         {
  1320.             $this->source_class $class;
  1321.             return true;
  1322.         }
  1323.         return false;
  1324.     }
  1325.  
  1326.     /**
  1327.      * Allows you to override the default user agent string.
  1328.      *
  1329.      * @access public
  1330.      * @param string $ua New user agent string.
  1331.      */
  1332.     function set_useragent($ua SIMPLEPIE_USERAGENT)
  1333.     {
  1334.         $this->useragent = (string) $ua;
  1335.     }
  1336.  
  1337.     /**
  1338.      * Set callback function to create cache filename with
  1339.      *
  1340.      * @access public
  1341.      * @param mixed $function Callback function
  1342.      */
  1343.     function set_cache_name_function($function 'md5')
  1344.     {
  1345.         if (is_callable($function))
  1346.         {
  1347.             $this->cache_name_function $function;
  1348.         }
  1349.     }
  1350.  
  1351.     /**
  1352.      * Set javascript query string parameter
  1353.      *
  1354.      * @access public
  1355.      * @param mixed $get Javascript query string parameter
  1356.      */
  1357.     function set_javascript($get 'js')
  1358.     {
  1359.         if ($get)
  1360.         {
  1361.             $this->javascript = (string) $get;
  1362.         }
  1363.         else
  1364.         {
  1365.             $this->javascript false;
  1366.         }
  1367.     }
  1368.  
  1369.     /**
  1370.      * Set options to make SP as fast as possible.  Forgoes a
  1371.      * substantial amount of data sanitization in favor of speed.
  1372.      *
  1373.      * @access public
  1374.      * @param bool $set Whether to set them or not
  1375.      */
  1376.     function set_stupidly_fast($set false)
  1377.     {
  1378.         if ($set)
  1379.         {
  1380.             $this->enable_order_by_date(false);
  1381.             $this->remove_div(false);
  1382.             $this->strip_comments(false);
  1383.             $this->strip_htmltags(false);
  1384.             $this->strip_attributes(false);
  1385.             $this->set_image_handler(false);
  1386.         }
  1387.     }
  1388.  
  1389.     /**
  1390.      * Set maximum number of feeds to check with autodiscovery
  1391.      *
  1392.      * @access public
  1393.      * @param int $max Maximum number of feeds to check
  1394.      */
  1395.     function set_max_checked_feeds($max 10)
  1396.     {
  1397.         $this->max_checked_feeds = (int) $max;
  1398.     }
  1399.  
  1400.     function remove_div($enable true)
  1401.     {
  1402.         $this->sanitize->remove_div($enable);
  1403.     }
  1404.  
  1405.     function strip_htmltags($tags ''$encode null)
  1406.     {
  1407.         if ($tags === '')
  1408.         {
  1409.             $tags $this->strip_htmltags;
  1410.         }
  1411.         $this->sanitize->strip_htmltags($tags);
  1412.         if ($encode !== null)
  1413.         {
  1414.             $this->sanitize->encode_instead_of_strip($tags);
  1415.         }
  1416.     }
  1417.  
  1418.     function encode_instead_of_strip($enable true)
  1419.     {
  1420.         $this->sanitize->encode_instead_of_strip($enable);
  1421.     }
  1422.  
  1423.     function strip_attributes($attribs '')
  1424.     {
  1425.         if ($attribs === '')
  1426.         {
  1427.             $attribs $this->strip_attributes;
  1428.         }
  1429.         $this->sanitize->strip_attributes($attribs);
  1430.     }
  1431.  
  1432.     function set_output_encoding($encoding 'UTF-8')
  1433.     {
  1434.         $this->sanitize->set_output_encoding($encoding);
  1435.     }
  1436.  
  1437.     function strip_comments($strip false)
  1438.     {
  1439.         $this->sanitize->strip_comments($strip);
  1440.     }
  1441.  
  1442.     /**
  1443.      * Set element/attribute key/value pairs of HTML attributes
  1444.      * containing URLs that need to be resolved relative to the feed
  1445.      *
  1446.      * @access public
  1447.      * @since 1.0
  1448.      * @param array $element_attribute Element/attribute key/value pairs
  1449.      */
  1450.     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'))
  1451.     {
  1452.         $this->sanitize->set_url_replacements($element_attribute);
  1453.     }
  1454.  
  1455.     /**
  1456.      * Set the handler to enable the display of cached favicons.
  1457.      *
  1458.      * @access public
  1459.      * @param str $page Web-accessible path to the handler_favicon.php file.
  1460.      * @param str $qs The query string that the value should be passed to.
  1461.      */
  1462.     function set_favicon_handler($page false$qs 'i')
  1463.     {
  1464.         if ($page !== false)
  1465.         {
  1466.             $this->favicon_handler $page '?' $qs '=';
  1467.         }
  1468.         else
  1469.         {
  1470.             $this->favicon_handler '';
  1471.         }
  1472.     }
  1473.  
  1474.     /**
  1475.      * Set the handler to enable the display of cached images.
  1476.      *
  1477.      * @access public
  1478.      * @param str $page Web-accessible path to the handler_image.php file.
  1479.      * @param str $qs The query string that the value should be passed to.
  1480.      */
  1481.     function set_image_handler($page false$qs 'i')
  1482.     {
  1483.         if ($page !== false)
  1484.         {
  1485.             $this->sanitize->set_image_handler($page '?' $qs '=');
  1486.         }
  1487.         else
  1488.         {
  1489.             $this->image_handler '';
  1490.         }
  1491.     }
  1492.  
  1493.     /**
  1494.      * Set the limit for items returned per-feed with multifeeds.
  1495.      *
  1496.      * @access public
  1497.      * @param integer $limit The maximum number of items to return.
  1498.      */
  1499.     function set_item_limit($limit 0)
  1500.     {
  1501.         $this->item_limit = (int) $limit;
  1502.     }
  1503.  
  1504.     function init()
  1505.     {
  1506.         // Check absolute bare minimum requirements.
  1507.         if ((function_exists('version_compare'&& version_compare(PHP_VERSION'4.3.0''<')) || !extension_loaded('xml'|| !extension_loaded('pcre'))
  1508.         {
  1509.             return false;
  1510.         }
  1511.         // Then check the xml extension is sane (i.e., libxml 2.7.x issue on PHP < 5.2.9 and libxml 2.7.0 to 2.7.2 on any version) if we don't have xmlreader.
  1512.         elseif (!extension_loaded('xmlreader'))
  1513.         {
  1514.             static $xml_is_sane null;
  1515.             if ($xml_is_sane === null)
  1516.             {
  1517.                 $parser_check xml_parser_create();
  1518.                 xml_parse_into_struct($parser_check'<foo>&amp;</foo>'$values);
  1519.                 xml_parser_free($parser_check);
  1520.                 $xml_is_sane = isset($values[0]['value']);
  1521.             }
  1522.             if (!$xml_is_sane)
  1523.             {
  1524.                 return false;
  1525.             }
  1526.         }
  1527.  
  1528.         if (isset($_GET[$this->javascript]))
  1529.         {
  1530.             SimplePie_Misc::output_javascript();
  1531.             exit;
  1532.         }
  1533.  
  1534.         // Pass whatever was set with config options over to the sanitizer.
  1535.         $this->sanitize->pass_cache_data($this->cache$this->cache_location$this->cache_name_function$this->cache_class);
  1536.         $this->sanitize->pass_file_data($this->file_class$this->timeout$this->useragent$this->force_fsockopen);
  1537.  
  1538.         if ($this->feed_url !== null || $this->raw_data !== null)
  1539.         {
  1540.             $this->data array();
  1541.             $this->multifeed_objects array();
  1542.             $cache false;
  1543.  
  1544.             if ($this->feed_url !== null)
  1545.             {
  1546.                 $parsed_feed_url SimplePie_Misc::parse_url($this->feed_url);
  1547.                 // Decide whether to enable caching
  1548.                 if ($this->cache && $parsed_feed_url['scheme'!== '')
  1549.                 {
  1550.                     $cache call_user_func(array($this->cache_class'create')$this->cache_locationcall_user_func($this->cache_name_function$this->feed_url)'spc');
  1551.                 }
  1552.                 // If it's enabled and we don't want an XML dump, use the cache
  1553.                 if ($cache && !$this->xml_dump)
  1554.                 {
  1555.                     // Load the Cache
  1556.                     $this->data $cache->load();
  1557.                     if (!empty($this->data))
  1558.                     {
  1559.                         // If the cache is for an outdated build of SimplePie
  1560.                         if (!isset($this->data['build']|| $this->data['build'!== SIMPLEPIE_BUILD)
  1561.                         {
  1562.                             $cache->unlink();
  1563.                             $this->data array();
  1564.                         }
  1565.                         // If we've hit a collision just rerun it with caching disabled
  1566.                         elseif (isset($this->data['url']&& $this->data['url'!== $this->feed_url)
  1567.                         {
  1568.                             $cache false;
  1569.                             $this->data array();
  1570.                         }
  1571.                         // If we've got a non feed_url stored (if the page isn't actually a feed, or is a redirect) use that URL.
  1572.                         elseif (isset($this->data['feed_url']))
  1573.                         {
  1574.                             // If the autodiscovery cache is still valid use it.
  1575.                             if ($cache->mtime($this->autodiscovery_cache_duration time())
  1576.                             {
  1577.                                 // Do not need to do feed autodiscovery yet.
  1578.                                 if ($this->data['feed_url'=== $this->data['url'])
  1579.                                 {
  1580.                                     $cache->unlink();
  1581.                                     $this->data array();
  1582.                                 }
  1583.                                 else
  1584.                                 {
  1585.                                     $this->set_feed_url($this->data['feed_url']);
  1586.                                     return $this->init();
  1587.                                 }
  1588.                             }
  1589.                         }
  1590.                         // Check if the cache has been updated
  1591.                         elseif ($cache->mtime($this->cache_duration time())
  1592.                         {
  1593.                             // If we have last-modified and/or etag set
  1594.                             if (isset($this->data['headers']['last-modified']|| isset($this->data['headers']['etag']))
  1595.                             {
  1596.                                 $headers array();
  1597.                                 if (isset($this->data['headers']['last-modified']))
  1598.                                 {
  1599.                                     $headers['if-modified-since'$this->data['headers']['last-modified'];
  1600.                                 }
  1601.                                 if (isset($this->data['headers']['etag']))
  1602.                                 {
  1603.                                     $headers['if-none-match''"' $this->data['headers']['etag''"';
  1604.                                 }
  1605.                                 $file new $this->file_class($this->feed_url$this->timeout/105$headers$this->useragent$this->force_fsockopen);
  1606.                                 if ($file->success)
  1607.                                 {
  1608.                                     if ($file->status_code === 304)
  1609.                                     {
  1610.                                         $cache->touch();
  1611.                                         return true;
  1612.                                     }
  1613.                                     else
  1614.                                     {
  1615.                                         $headers $file->headers;
  1616.                                     }
  1617.                                 }
  1618.                                 else
  1619.                                 {
  1620.                                     unset($file);
  1621.                                 }
  1622.                             }
  1623.                         }
  1624.                         // If the cache is still valid, just return true
  1625.                         else
  1626.                         {
  1627.                             return true;
  1628.                         }
  1629.                     }
  1630.                     // If the cache is empty, delete it
  1631.                     else
  1632.                     {
  1633.                         $cache->unlink();
  1634.                         $this->data array();
  1635.                     }
  1636.                 }
  1637.                 // 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.
  1638.                 if (!isset($file))
  1639.                 {
  1640.                     if (is_a($this->file'SimplePie_File'&& $this->file->url === $this->feed_url)
  1641.                     {
  1642.                         $file =$this->file;
  1643.                     }
  1644.                     else
  1645.                     {
  1646.                         $file new $this->file_class($this->feed_url$this->timeout5null$this->useragent$this->force_fsockopen);
  1647.                     }
  1648.                 }
  1649.                 // If the file connection has an error, set SimplePie::error to that and quit
  1650.                 if (!$file->success && !($file->method SIMPLEPIE_FILE_SOURCE_REMOTE === || ($file->status_code === 200 || $file->status_code 206 && $file->status_code 300)))
  1651.                 {
  1652.                     $this->error = $file->error;
  1653.                     if (!empty($this->data))
  1654.                     {
  1655.                         return true;
  1656.                     }
  1657.                     else
  1658.                     {
  1659.                         return false;
  1660.                     }
  1661.                 }
  1662.  
  1663.                 if (!$this->force_feed)
  1664.                 {
  1665.                     // Check if the supplied URL is a feed, if it isn't, look for it.
  1666.                     $locate new $this->locator_class($file$this->timeout$this->useragent$this->file_class$this->max_checked_feeds$this->content_type_sniffer_class);
  1667.                     if (!$locate->is_feed($file))
  1668.                     {
  1669.                         // We need to unset this so that if SimplePie::set_file() has been called that object is untouched
  1670.                         unset($file);
  1671.                         if ($file $locate->find($this->autodiscovery$this->all_discovered_feeds))
  1672.                         {
  1673.                             if ($cache)
  1674.                             {
  1675.                                 $this->data array('url' => $this->feed_url'feed_url' => $file->url'build' => SIMPLEPIE_BUILD);
  1676.                                 if (!$cache->save($this))
  1677.                                 {
  1678.                                     trigger_error("$this->cache_location is not writeable"E_USER_WARNING);
  1679.                                 }
  1680.                                 $cache call_user_func(array($this->cache_class'create')$this->cache_locationcall_user_func($this->cache_name_function$file->url)'spc');
  1681.                             }
  1682.                             $this->feed_url $file->url;
  1683.                         }
  1684.                         else
  1685.                         {
  1686.                             $this->error = "A feed could not be found at $this->feed_url";
  1687.                             SimplePie_Misc::error($this->errorE_USER_NOTICE__FILE____LINE__);
  1688.                             return false;
  1689.                         }
  1690.                     }
  1691.                     $locate null;
  1692.                 }
  1693.  
  1694.                 $headers $file->headers;
  1695.                 $data $file->body;
  1696.                 $sniffer new $this->content_type_sniffer_class($file);
  1697.                 $sniffed $sniffer->get_type();
  1698.             }
  1699.             else
  1700.             {
  1701.                 $data $this->raw_data;
  1702.             }
  1703.  
  1704.             // Set up array of possible encodings
  1705.             $encodings array();
  1706.  
  1707.             // First check to see if input has been overridden.
  1708.             if ($this->input_encoding !== false)
  1709.             {
  1710.                 $encodings[$this->input_encoding;
  1711.             }
  1712.  
  1713.             $application_types array('application/xml''application/xml-dtd''application/xml-external-parsed-entity');
  1714.             $text_types array('text/xml''text/xml-external-parsed-entity');
  1715.  
  1716.             // RFC 3023 (only applies to sniffed content)
  1717.             if (isset($sniffed))
  1718.             {
  1719.                 if (in_array($sniffed$application_types|| substr($sniffed012=== 'application/' && substr($sniffed-4=== '+xml')
  1720.                 {
  1721.                     if (isset($headers['content-type']&& preg_match('/;\x20?charset=([^;]*)/i'$headers['content-type']$charset))
  1722.                     {
  1723.                         $encodings[strtoupper($charset[1]);
  1724.                     }
  1725.                     $encodings array_merge($encodingsSimplePie_Misc::xml_encoding($data));
  1726.                     $encodings['UTF-8';
  1727.                 }
  1728.                 elseif (in_array($sniffed$text_types|| substr($sniffed05=== 'text/' && substr($sniffed-4=== '+xml')
  1729.                 {
  1730.                     if (isset($headers['content-type']&& preg_match('/;\x20?charset=([^;]*)/i'$headers['content-type']$charset))
  1731.                     {
  1732.                         $encodings[$charset[1];
  1733.                     }
  1734.                     $encodings['US-ASCII';
  1735.                 }
  1736.                 // Text MIME-type default
  1737.                 elseif (substr($sniffed05=== 'text/')
  1738.                 {
  1739.                     $encodings['US-ASCII';
  1740.                 }
  1741.             }
  1742.  
  1743.             // Fallback to XML 1.0 Appendix F.1/UTF-8/ISO-8859-1
  1744.             $encodings array_merge($encodingsSimplePie_Misc::xml_encoding($data));
  1745.             $encodings['UTF-8';
  1746.             $encodings['ISO-8859-1';
  1747.  
  1748.             // There's no point in trying an encoding twice
  1749.             $encodings array_unique($encodings);
  1750.  
  1751.             // If we want the XML, just output that with the most likely encoding and quit
  1752.             if ($this->xml_dump)
  1753.             {
  1754.                 header('Content-type: text/xml; charset=' $encodings[0]);
  1755.                 echo $data;
  1756.                 exit;
  1757.             }
  1758.  
  1759.             // Loop through each possible encoding, till we return something, or run out of possibilities
  1760.             foreach ($encodings as $encoding)
  1761.             {
  1762.                 // Change the encoding to UTF-8 (as we always use UTF-8 internally)
  1763.                 if ($utf8_data SimplePie_Misc::change_encoding($data$encoding'UTF-8'))
  1764.                 {
  1765.                     // Create new parser
  1766.                     $parser new $this->parser_class();
  1767.  
  1768.                     // If it's parsed fine
  1769.                     if ($parser->parse($utf8_data'UTF-8'))
  1770.                     {
  1771.                         $this->data $parser->get_data();
  1772.                         if ($this->get_type(~SIMPLEPIE_TYPE_NONE)
  1773.                         {
  1774.                             if (isset($headers))
  1775.                             {
  1776.                                 $this->data['headers'$headers;
  1777.                             }
  1778.                             $this->data['build'SIMPLEPIE_BUILD;
  1779.  
  1780.                             // Cache the file if caching is enabled
  1781.                             if ($cache && !$cache->save($this))
  1782.                             {
  1783.                                 trigger_error("$cache->name is not writeable"E_USER_WARNING);
  1784.                             }
  1785.                             return true;
  1786.                         }
  1787.                         else
  1788.                         {
  1789.                             $this->error = "A feed could not be found at $this->feed_url";
  1790.                             SimplePie_Misc::error($this->errorE_USER_NOTICE__FILE____LINE__);
  1791.                             return false;
  1792.                         }
  1793.                     }
  1794.                 }
  1795.             }
  1796.             if(isset($parser))
  1797.             {
  1798.                 // We have an error, just set SimplePie_Misc::error to it and quit
  1799.                 $this->error = sprintf('XML error: %s at line %d, column %d'$parser->get_error_string()$parser->get_current_line()$parser->get_current_column());
  1800.             }
  1801.             else
  1802.             {
  1803.                 $this->error = 'The data could not be converted to UTF-8';
  1804.             }
  1805.             SimplePie_Misc::error($this->errorE_USER_NOTICE__FILE____LINE__);
  1806.             return false;
  1807.         }
  1808.         elseif (!empty($this->multifeed_url))
  1809.         {
  1810.             $i 0;
  1811.             $success 0;
  1812.             $this->multifeed_objects array();
  1813.             foreach ($this->multifeed_url as $url)
  1814.             {
  1815.                 if (SIMPLEPIE_PHP5)
  1816.                 {
  1817.                     // This keyword needs to defy coding standards for PHP4 compatibility
  1818.                     $this->multifeed_objects[$iclone($this);
  1819.                 }
  1820.                 else
  1821.                 {
  1822.                     $this->multifeed_objects[$i$this;
  1823.                 }
  1824.                 $this->multifeed_objects[$i]->set_feed_url($url);
  1825.                 $success |= $this->multifeed_objects[$i]->init();
  1826.                 $i++;
  1827.             }
  1828.             return (bool) $success;
  1829.         }
  1830.         else
  1831.         {
  1832.             return false;
  1833.         }
  1834.     }
  1835.  
  1836.     /**
  1837.      * Return the error message for the occured error
  1838.      *
  1839.      * @access public
  1840.      * @return string Error message
  1841.      */
  1842.     function error()
  1843.     {
  1844.         return $this->error;
  1845.     }
  1846.  
  1847.     function get_encoding()
  1848.     {
  1849.         return $this->sanitize->output_encoding;
  1850.     }
  1851.  
  1852.     function handle_content_type($mime 'text/html')
  1853.     {
  1854.         if (!headers_sent())
  1855.         {
  1856.             $header "Content-type: $mime;";
  1857.             if ($this->get_encoding())
  1858.             {
  1859.                 $header .= ' charset=' $this->get_encoding();
  1860.             }
  1861.             else
  1862.             {
  1863.                 $header .= ' charset=UTF-8';
  1864.             }
  1865.             header($header);
  1866.         }
  1867.     }
  1868.  
  1869.     function get_type()
  1870.     {
  1871.         if (!isset($this->data['type']))
  1872.         {
  1873.             $this->data['type'SIMPLEPIE_TYPE_ALL;
  1874.             if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed']))
  1875.             {
  1876.                 $this->data['type'&= SIMPLEPIE_TYPE_ATOM_10;
  1877.             }
  1878.             elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed']))
  1879.             {
  1880.                 $this->data['type'&= SIMPLEPIE_TYPE_ATOM_03;
  1881.             }
  1882.             elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF']))
  1883.             {
  1884.                 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['channel'])
  1885.                 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['image'])
  1886.                 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item'])
  1887.                 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['textinput']))
  1888.                 {
  1889.                     $this->data['type'&= SIMPLEPIE_TYPE_RSS_10;
  1890.                 }
  1891.                 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['channel'])
  1892.                 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['image'])
  1893.                 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item'])
  1894.                 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['textinput']))
  1895.                 {
  1896.                     $this->data['type'&= SIMPLEPIE_TYPE_RSS_090;
  1897.                 }
  1898.             }
  1899.             elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss']))
  1900.             {
  1901.                 $this->data['type'&= SIMPLEPIE_TYPE_RSS_ALL;
  1902.                 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version']))
  1903.                 {
  1904.                     switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version']))
  1905.                     {
  1906.                         case '0.91':
  1907.                             $this->data['type'&= SIMPLEPIE_TYPE_RSS_091;
  1908.                             if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data']))
  1909.                             {
  1910.                                 switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data']))
  1911.                                 {
  1912.                                     case '0':
  1913.                                         $this->data['type'&= SIMPLEPIE_TYPE_RSS_091_NETSCAPE;
  1914.                                         break;
  1915.  
  1916.                                     case '24':
  1917.                                         $this->data['type'&= SIMPLEPIE_TYPE_RSS_091_USERLAND;
  1918.                                         break;
  1919.                                 }
  1920.                             }
  1921.                             break;
  1922.  
  1923.                         case '0.92':
  1924.                             $this->data['type'&= SIMPLEPIE_TYPE_RSS_092;
  1925.                             break;
  1926.  
  1927.                         case '0.93':
  1928.                             $this->data['type'&= SIMPLEPIE_TYPE_RSS_093;
  1929.                             break;
  1930.  
  1931.                         case '0.94':
  1932.                             $this->data['type'&= SIMPLEPIE_TYPE_RSS_094;
  1933.                             break;
  1934.  
  1935.                         case '2.0':
  1936.                             $this->data['type'&= SIMPLEPIE_TYPE_RSS_20;
  1937.                             break;
  1938.                     }
  1939.                 }
  1940.             }
  1941.             else
  1942.             {
  1943.                 $this->data['type'SIMPLEPIE_TYPE_NONE;
  1944.             }
  1945.         }
  1946.         return $this->data['type'];
  1947.     }
  1948.  
  1949.     /**
  1950.      * Returns the URL for the favicon of the feed's website.
  1951.      *
  1952.      * @todo Cache atom:icon
  1953.      * @access public
  1954.      * @since 1.0
  1955.      */
  1956.     function get_favicon()
  1957.     {
  1958.         if ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'icon'))
  1959.         {
  1960.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  1961.         }
  1962.         elseif (($url $this->get_link()) !== null && preg_match('/^http(s)?:\/\//i'$url))
  1963.         {
  1964.             $favicon SimplePie_Misc::absolutize_url('/favicon.ico'$url);
  1965.  
  1966.             if ($this->cache && $this->favicon_handler)
  1967.             {
  1968.                 $favicon_filename call_user_func($this->cache_name_function$favicon);
  1969.                 $cache call_user_func(array($this->cache_class'create')$this->cache_location$favicon_filename'spi');
  1970.  
  1971.                 if ($cache->load())
  1972.                 {
  1973.                     return $this->sanitize($this->favicon_handler $favicon_filenameSIMPLEPIE_CONSTRUCT_IRI);
  1974.                 }
  1975.                 else
  1976.                 {
  1977.                     $file new $this->file_class($favicon$this->timeout 105array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR'])$this->useragent$this->force_fsockopen);
  1978.  
  1979.                     if ($file->success && ($file->method SIMPLEPIE_FILE_SOURCE_REMOTE === || ($file->status_code === 200 || $file->status_code 206 && $file->status_code 300)) && strlen($file->body0)
  1980.                     {
  1981.                         $sniffer new $this->content_type_sniffer_class($file);
  1982.                         if (substr($sniffer->get_type()06=== 'image/')
  1983.                         {
  1984.                             if ($cache->save(array('headers' => $file->headers'body' => $file->body)))
  1985.                             {
  1986.                                 return $this->sanitize($this->favicon_handler $favicon_filenameSIMPLEPIE_CONSTRUCT_IRI);
  1987.                             }
  1988.                             else
  1989.                             {
  1990.                                 trigger_error("$cache->name is not writeable"E_USER_WARNING);
  1991.                                 return $this->sanitize($faviconSIMPLEPIE_CONSTRUCT_IRI);
  1992.                             }
  1993.                         }
  1994.                         // not an image
  1995.                         else
  1996.                         {
  1997.                             return false;
  1998.                         }
  1999.                     }
  2000.                 }
  2001.             }
  2002.             else
  2003.             {
  2004.                 return $this->sanitize($faviconSIMPLEPIE_CONSTRUCT_IRI);
  2005.             }
  2006.         }
  2007.         return false;
  2008.     }
  2009.  
  2010.     /**
  2011.      * @todo If we have a perm redirect we should return the new URL
  2012.      * @todo When we make the above change, let's support <itunes:new-feed-url> as well
  2013.      * @todo Also, |atom:link|@rel=self
  2014.      */
  2015.     function subscribe_url()
  2016.     {
  2017.         if ($this->feed_url !== null)
  2018.         {
  2019.             return $this->sanitize($this->feed_urlSIMPLEPIE_CONSTRUCT_IRI);
  2020.         }
  2021.         else
  2022.         {
  2023.             return null;
  2024.         }
  2025.     }
  2026.  
  2027.     function subscribe_feed()
  2028.     {
  2029.         if ($this->feed_url !== null)
  2030.         {
  2031.             return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url2)SIMPLEPIE_CONSTRUCT_IRI);
  2032.         }
  2033.         else
  2034.         {
  2035.             return null;
  2036.         }
  2037.     }
  2038.  
  2039.     function subscribe_outlook()
  2040.     {
  2041.         if ($this->feed_url !== null)
  2042.         {
  2043.             return $this->sanitize('outlook' SimplePie_Misc::fix_protocol($this->feed_url2)SIMPLEPIE_CONSTRUCT_IRI);
  2044.         }
  2045.         else
  2046.         {
  2047.             return null;
  2048.         }
  2049.     }
  2050.  
  2051.     function subscribe_podcast()
  2052.     {
  2053.         if ($this->feed_url !== null)
  2054.         {
  2055.             return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url3)SIMPLEPIE_CONSTRUCT_IRI);
  2056.         }
  2057.         else
  2058.         {
  2059.             return null;
  2060.         }
  2061.     }
  2062.  
  2063.     function subscribe_itunes()
  2064.     {
  2065.         if ($this->feed_url !== null)
  2066.         {
  2067.             return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url4)SIMPLEPIE_CONSTRUCT_IRI);
  2068.         }
  2069.         else
  2070.         {
  2071.             return null;
  2072.         }
  2073.     }
  2074.  
  2075.     /**
  2076.      * Creates the subscribe_* methods' return data
  2077.      *
  2078.      * @access private
  2079.      * @param string $feed_url String to prefix to the feed URL
  2080.      * @param string $site_url String to prefix to the site URL (and
  2081.      *  suffix to the feed URL)
  2082.      * @return mixed URL if feed exists, false otherwise
  2083.      */
  2084.     function subscribe_service($feed_url$site_url null)
  2085.     {
  2086.         if ($this->subscribe_url())
  2087.         {
  2088.             $return $feed_url rawurlencode($this->feed_url);
  2089.             if ($site_url !== null && $this->get_link(!== null)
  2090.             {
  2091.                 $return .= $site_url rawurlencode($this->get_link());
  2092.             }
  2093.             return $this->sanitize($returnSIMPLEPIE_CONSTRUCT_IRI);
  2094.         }
  2095.         else
  2096.         {
  2097.             return null;
  2098.         }
  2099.     }
  2100.  
  2101.     function subscribe_aol()
  2102.     {
  2103.         return $this->subscribe_service('http://feeds.my.aol.com/add.jsp?url=');
  2104.     }
  2105.  
  2106.     function subscribe_bloglines()
  2107.     {
  2108.         return $this->subscribe_service('http://www.bloglines.com/sub/');
  2109.     }
  2110.  
  2111.     function subscribe_eskobo()
  2112.     {
  2113.         return $this->subscribe_service('http://www.eskobo.com/?AddToMyPage=');
  2114.     }
  2115.  
  2116.     function subscribe_feedfeeds()
  2117.     {
  2118.         return $this->subscribe_service('http://www.feedfeeds.com/add?feed=');
  2119.     }
  2120.  
  2121.     function subscribe_feedster()
  2122.     {
  2123.         return $this->subscribe_service('http://www.feedster.com/myfeedster.php?action=addrss&confirm=no&rssurl=');
  2124.     }
  2125.  
  2126.     function subscribe_google()
  2127.     {
  2128.         return $this->subscribe_service('http://fusion.google.com/add?feedurl=');
  2129.     }
  2130.  
  2131.     function subscribe_gritwire()
  2132.     {
  2133.         return $this->subscribe_service('http://my.gritwire.com/feeds/addExternalFeed.aspx?FeedUrl=');
  2134.     }
  2135.  
  2136.     function subscribe_msn()
  2137.     {
  2138.         return $this->subscribe_service('http://my.msn.com/addtomymsn.armx?id=rss&ut=''&ru=');
  2139.     }
  2140.  
  2141.     function subscribe_netvibes()
  2142.     {
  2143.         return $this->subscribe_service('http://www.netvibes.com/subscribe.php?url=');
  2144.     }
  2145.  
  2146.     function subscribe_newsburst()
  2147.     {
  2148.         return $this->subscribe_service('http://www.newsburst.com/Source/?add=');
  2149.     }
  2150.  
  2151.     function subscribe_newsgator()
  2152.     {
  2153.         return $this->subscribe_service('http://www.newsgator.com/ngs/subscriber/subext.aspx?url=');
  2154.     }
  2155.  
  2156.     function subscribe_odeo()
  2157.     {
  2158.         return $this->subscribe_service('http://www.odeo.com/listen/subscribe?feed=');
  2159.     }
  2160.  
  2161.     function subscribe_podnova()
  2162.     {
  2163.         return $this->subscribe_service('http://www.podnova.com/index_your_podcasts.srf?action=add&url=');
  2164.     }
  2165.  
  2166.     function subscribe_rojo()
  2167.     {
  2168.         return $this->subscribe_service('http://www.rojo.com/add-subscription?resource=');
  2169.     }
  2170.  
  2171.     function subscribe_yahoo()
  2172.     {
  2173.         return $this->subscribe_service('http://add.my.yahoo.com/rss?url=');
  2174.     }
  2175.  
  2176.     function get_feed_tags($namespace$tag)
  2177.     {
  2178.         $type $this->get_type();
  2179.         if ($type SIMPLEPIE_TYPE_ATOM_10)
  2180.         {
  2181.             if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag]))
  2182.             {
  2183.                 return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag];
  2184.             }
  2185.         }
  2186.         if ($type SIMPLEPIE_TYPE_ATOM_03)
  2187.         {
  2188.             if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag]))
  2189.             {
  2190.                 return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag];
  2191.             }
  2192.         }
  2193.         if ($type SIMPLEPIE_TYPE_RSS_RDF)
  2194.         {
  2195.             if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag]))
  2196.             {
  2197.                 return $this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag];
  2198.             }
  2199.         }
  2200.         if ($type SIMPLEPIE_TYPE_RSS_SYNDICATION)
  2201.         {
  2202.             if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag]))
  2203.             {
  2204.                 return $this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag];
  2205.             }
  2206.         }
  2207.         return null;
  2208.     }
  2209.  
  2210.     function get_channel_tags($namespace$tag)
  2211.     {
  2212.         $type $this->get_type();
  2213.         if ($type SIMPLEPIE_TYPE_ATOM_ALL)
  2214.         {
  2215.             if ($return $this->get_feed_tags($namespace$tag))
  2216.             {
  2217.                 return $return;
  2218.             }
  2219.         }
  2220.         if ($type SIMPLEPIE_TYPE_RSS_10)
  2221.         {
  2222.             if ($channel $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10'channel'))
  2223.             {
  2224.                 if (isset($channel[0]['child'][$namespace][$tag]))
  2225.                 {
  2226.                     return $channel[0]['child'][$namespace][$tag];
  2227.                 }
  2228.             }
  2229.         }
  2230.         if ($type SIMPLEPIE_TYPE_RSS_090)
  2231.         {
  2232.             if ($channel $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090'channel'))
  2233.             {
  2234.                 if (isset($channel[0]['child'][$namespace][$tag]))
  2235.                 {
  2236.                     return $channel[0]['child'][$namespace][$tag];
  2237.                 }
  2238.             }
  2239.         }
  2240.         if ($type SIMPLEPIE_TYPE_RSS_SYNDICATION)
  2241.         {
  2242.             if ($channel $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_20'channel'))
  2243.             {
  2244.                 if (isset($channel[0]['child'][$namespace][$tag]))
  2245.                 {
  2246.                     return $channel[0]['child'][$namespace][$tag];
  2247.                 }
  2248.             }
  2249.         }
  2250.         return null;
  2251.     }
  2252.  
  2253.     function get_image_tags($namespace$tag)
  2254.     {
  2255.         $type $this->get_type();
  2256.         if ($type SIMPLEPIE_TYPE_RSS_10)
  2257.         {
  2258.             if ($image $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10'image'))
  2259.             {
  2260.                 if (isset($image[0]['child'][$namespace][$tag]))
  2261.                 {
  2262.                     return $image[0]['child'][$namespace][$tag];
  2263.                 }
  2264.             }
  2265.         }
  2266.         if ($type SIMPLEPIE_TYPE_RSS_090)
  2267.         {
  2268.             if ($image $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090'image'))
  2269.             {
  2270.                 if (isset($image[0]['child'][$namespace][$tag]))
  2271.                 {
  2272.                     return $image[0]['child'][$namespace][$tag];
  2273.                 }
  2274.             }
  2275.         }
  2276.         if ($type SIMPLEPIE_TYPE_RSS_SYNDICATION)
  2277.         {
  2278.             if ($image $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20'image'))
  2279.             {
  2280.                 if (isset($image[0]['child'][$namespace][$tag]))
  2281.                 {
  2282.                     return $image[0]['child'][$namespace][$tag];
  2283.                 }
  2284.             }
  2285.         }
  2286.         return null;
  2287.     }
  2288.  
  2289.     function get_base($element array())
  2290.     {
  2291.         if (!($this->get_type(SIMPLEPIE_TYPE_RSS_SYNDICATION&& !empty($element['xml_base_explicit']&& isset($element['xml_base']))
  2292.         {
  2293.             return $element['xml_base'];
  2294.         }
  2295.         elseif ($this->get_link(!== null)
  2296.         {
  2297.             return $this->get_link();
  2298.         }
  2299.         else
  2300.         {
  2301.             return $this->subscribe_url();
  2302.         }
  2303.     }
  2304.  
  2305.     function sanitize($data$type$base '')
  2306.     {
  2307.         return $this->sanitize->sanitize($data$type$base);
  2308.     }
  2309.  
  2310.     function get_title()
  2311.     {
  2312.         if ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'title'))
  2313.         {
  2314.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_10_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  2315.         }
  2316.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03'title'))
  2317.         {
  2318.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_03_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  2319.         }
  2320.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10'title'))
  2321.         {
  2322.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  2323.         }
  2324.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090'title'))
  2325.         {
  2326.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  2327.         }
  2328.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20'title'))
  2329.         {
  2330.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  2331.         }
  2332.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11'title'))
  2333.         {
  2334.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2335.         }
  2336.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10'title'))
  2337.         {
  2338.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2339.         }
  2340.         else
  2341.         {
  2342.             return null;
  2343.         }
  2344.     }
  2345.  
  2346.     function get_category($key 0)
  2347.     {
  2348.         $categories $this->get_categories();
  2349.         if (isset($categories[$key]))
  2350.         {
  2351.             return $categories[$key];
  2352.         }
  2353.         else
  2354.         {
  2355.             return null;
  2356.         }
  2357.     }
  2358.  
  2359.     function get_categories()
  2360.     {
  2361.         $categories array();
  2362.  
  2363.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'category'as $category)
  2364.         {
  2365.             $term null;
  2366.             $scheme null;
  2367.             $label null;
  2368.             if (isset($category['attribs']['']['term']))
  2369.             {
  2370.                 $term $this->sanitize($category['attribs']['']['term']SIMPLEPIE_CONSTRUCT_TEXT);
  2371.             }
  2372.             if (isset($category['attribs']['']['scheme']))
  2373.             {
  2374.                 $scheme $this->sanitize($category['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  2375.             }
  2376.             if (isset($category['attribs']['']['label']))
  2377.             {
  2378.                 $label $this->sanitize($category['attribs']['']['label']SIMPLEPIE_CONSTRUCT_TEXT);
  2379.             }
  2380.             $categories[new $this->category_class($term$scheme$label);
  2381.         }
  2382.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20'category'as $category)
  2383.         {
  2384.             // This is really the label, but keep this as the term also for BC.
  2385.             // Label will also work on retrieving because that falls back to term.
  2386.             $term $this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2387.             if (isset($category['attribs']['']['domain']))
  2388.             {
  2389.                 $scheme $this->sanitize($category['attribs']['']['domain']SIMPLEPIE_CONSTRUCT_TEXT);
  2390.             }
  2391.             else
  2392.             {
  2393.                 $scheme null;
  2394.             }
  2395.             $categories[new $this->category_class($term$schemenull);
  2396.         }
  2397.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11'subject'as $category)
  2398.         {
  2399.             $categories[new $this->category_class($this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  2400.         }
  2401.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10'subject'as $category)
  2402.         {
  2403.             $categories[new $this->category_class($this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  2404.         }
  2405.  
  2406.         if (!empty($categories))
  2407.         {
  2408.             return SimplePie_Misc::array_unique($categories);
  2409.         }
  2410.         else
  2411.         {
  2412.             return null;
  2413.         }
  2414.     }
  2415.  
  2416.     function get_author($key 0)
  2417.     {
  2418.         $authors $this->get_authors();
  2419.         if (isset($authors[$key]))
  2420.         {
  2421.             return $authors[$key];
  2422.         }
  2423.         else
  2424.         {
  2425.             return null;
  2426.         }
  2427.     }
  2428.  
  2429.     function get_authors()
  2430.     {
  2431.         $authors array();
  2432.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'author'as $author)
  2433.         {
  2434.             $name null;
  2435.             $uri null;
  2436.             $email null;
  2437.             if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
  2438.             {
  2439.                 $name $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2440.             }
  2441.             if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
  2442.             {
  2443.                 $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]));
  2444.             }
  2445.             if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
  2446.             {
  2447.                 $email $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2448.             }
  2449.             if ($name !== null || $email !== null || $uri !== null)
  2450.             {
  2451.                 $authors[new $this->author_class($name$uri$email);
  2452.             }
  2453.         }
  2454.         if ($author $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03'author'))
  2455.         {
  2456.             $name null;
  2457.             $url null;
  2458.             $email null;
  2459.             if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
  2460.             {
  2461.                 $name $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2462.             }
  2463.             if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
  2464.             {
  2465.                 $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]));
  2466.             }
  2467.             if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
  2468.             {
  2469.                 $email $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2470.             }
  2471.             if ($name !== null || $email !== null || $url !== null)
  2472.             {
  2473.                 $authors[new $this->author_class($name$url$email);
  2474.             }
  2475.         }
  2476.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11'creator'as $author)
  2477.         {
  2478.             $authors[new $this->author_class($this->sanitize($author['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  2479.         }
  2480.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10'creator'as $author)
  2481.         {
  2482.             $authors[new $this->author_class($this->sanitize($author['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  2483.         }
  2484.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES'author'as $author)
  2485.         {
  2486.             $authors[new $this->author_class($this->sanitize($author['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  2487.         }
  2488.  
  2489.         if (!empty($authors))
  2490.         {
  2491.             return SimplePie_Misc::array_unique($authors);
  2492.         }
  2493.         else
  2494.         {
  2495.             return null;
  2496.         }
  2497.     }
  2498.  
  2499.     function get_contributor($key 0)
  2500.     {
  2501.         $contributors $this->get_contributors();
  2502.         if (isset($contributors[$key]))
  2503.         {
  2504.             return $contributors[$key];
  2505.         }
  2506.         else
  2507.         {
  2508.             return null;
  2509.         }
  2510.     }
  2511.  
  2512.     function get_contributors()
  2513.     {
  2514.         $contributors array();
  2515.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'contributor'as $contributor)
  2516.         {
  2517.             $name null;
  2518.             $uri null;
  2519.             $email null;
  2520.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
  2521.             {
  2522.                 $name $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2523.             }
  2524.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
  2525.             {
  2526.                 $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]));
  2527.             }
  2528.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
  2529.             {
  2530.                 $email $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2531.             }
  2532.             if ($name !== null || $email !== null || $uri !== null)
  2533.             {
  2534.                 $contributors[new $this->author_class($name$uri$email);
  2535.             }
  2536.         }
  2537.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03'contributor'as $contributor)
  2538.         {
  2539.             $name null;
  2540.             $url null;
  2541.             $email null;
  2542.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
  2543.             {
  2544.                 $name $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2545.             }
  2546.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
  2547.             {
  2548.                 $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]));
  2549.             }
  2550.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
  2551.             {
  2552.                 $email $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2553.             }
  2554.             if ($name !== null || $email !== null || $url !== null)
  2555.             {
  2556.                 $contributors[new $this->author_class($name$url$email);
  2557.             }
  2558.         }
  2559.  
  2560.         if (!empty($contributors))
  2561.         {
  2562.             return SimplePie_Misc::array_unique($contributors);
  2563.         }
  2564.         else
  2565.         {
  2566.             return null;
  2567.         }
  2568.     }
  2569.  
  2570.     function get_link($key 0$rel 'alternate')
  2571.     {
  2572.         $links $this->get_links($rel);
  2573.         if (isset($links[$key]))
  2574.         {
  2575.             return $links[$key];
  2576.         }
  2577.         else
  2578.         {
  2579.             return null;
  2580.         }
  2581.     }
  2582.  
  2583.     /**
  2584.      * Added for parity between the parent-level and the item/entry-level.
  2585.      */
  2586.     function get_permalink()
  2587.     {
  2588.         return $this->get_link(0);
  2589.     }
  2590.  
  2591.     function get_links($rel 'alternate')
  2592.     {
  2593.         if (!isset($this->data['links']))
  2594.         {
  2595.             $this->data['links'array();
  2596.             if ($links $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'link'))
  2597.             {
  2598.                 foreach ($links as $link)
  2599.                 {
  2600.                     if (isset($link['attribs']['']['href']))
  2601.                     {
  2602.                         $link_rel (isset($link['attribs']['']['rel'])) $link['attribs']['']['rel''alternate';
  2603.                         $this->data['links'][$link_rel][$this->sanitize($link['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($link));
  2604.                     }
  2605.                 }
  2606.             }
  2607.             if ($links $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03'link'))
  2608.             {
  2609.                 foreach ($links as $link)
  2610.                 {
  2611.                     if (isset($link['attribs']['']['href']))
  2612.                     {
  2613.                         $link_rel (isset($link['attribs']['']['rel'])) $link['attribs']['']['rel''alternate';
  2614.                         $this->data['links'][$link_rel][$this->sanitize($link['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($link));
  2615.  
  2616.                     }
  2617.                 }
  2618.             }
  2619.             if ($links $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10'link'))
  2620.             {
  2621.                 $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  2622.             }
  2623.             if ($links $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090'link'))
  2624.             {
  2625.                 $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  2626.             }
  2627.             if ($links $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20'link'))
  2628.             {
  2629.                 $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  2630.             }
  2631.  
  2632.             $keys array_keys($this->data['links']);
  2633.             foreach ($keys as $key)
  2634.             {
  2635.                 if (SimplePie_Misc::is_isegment_nz_nc($key))
  2636.                 {
  2637.                     if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key]))
  2638.                     {
  2639.                         $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $keyarray_merge($this->data['links'][$key]$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key]);
  2640.                         $this->data['links'][$key=$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key];
  2641.                     }
  2642.                     else
  2643.                     {
  2644.                         $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key=$this->data['links'][$key];
  2645.                     }
  2646.                 }
  2647.                 elseif (substr($key041=== SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
  2648.                 {
  2649.                     $this->data['links'][substr($key41)=$this->data['links'][$key];
  2650.                 }
  2651.                 $this->data['links'][$keyarray_unique($this->data['links'][$key]);
  2652.             }
  2653.         }
  2654.  
  2655.         if (isset($this->data['links'][$rel]))
  2656.         {
  2657.             return $this->data['links'][$rel];
  2658.         }
  2659.         else
  2660.         {
  2661.             return null;
  2662.         }
  2663.     }
  2664.  
  2665.     function get_all_discovered_feeds()
  2666.     {
  2667.         return $this->all_discovered_feeds;
  2668.     }
  2669.  
  2670.     function get_description()
  2671.     {
  2672.         if ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'subtitle'))
  2673.         {
  2674.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_10_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  2675.         }
  2676.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03'tagline'))
  2677.         {
  2678.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_03_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  2679.         }
  2680.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10'description'))
  2681.         {
  2682.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  2683.         }
  2684.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090'description'))
  2685.         {
  2686.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  2687.         }
  2688.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20'description'))
  2689.         {
  2690.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_HTML$this->get_base($return[0]));
  2691.         }
  2692.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11'description'))
  2693.         {
  2694.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2695.         }
  2696.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10'description'))
  2697.         {
  2698.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2699.         }
  2700.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES'summary'))
  2701.         {
  2702.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_HTML$this->get_base($return[0]));
  2703.         }
  2704.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES'subtitle'))
  2705.         {
  2706.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_HTML$this->get_base($return[0]));
  2707.         }
  2708.         else
  2709.         {
  2710.             return null;
  2711.         }
  2712.     }
  2713.  
  2714.     function get_copyright()
  2715.     {
  2716.         if ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'rights'))
  2717.         {
  2718.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_10_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  2719.         }
  2720.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03'copyright'))
  2721.         {
  2722.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_03_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  2723.         }
  2724.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20'copyright'))
  2725.         {
  2726.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2727.         }
  2728.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11'rights'))
  2729.         {
  2730.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2731.         }
  2732.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10'rights'))
  2733.         {
  2734.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2735.         }
  2736.         else
  2737.         {
  2738.             return null;
  2739.         }
  2740.     }
  2741.  
  2742.     function get_language()
  2743.     {
  2744.         if ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20'language'))
  2745.         {
  2746.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2747.         }
  2748.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11'language'))
  2749.         {
  2750.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2751.         }
  2752.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10'language'))
  2753.         {
  2754.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2755.         }
  2756.         elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang']))
  2757.         {
  2758.             return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang']SIMPLEPIE_CONSTRUCT_TEXT);
  2759.         }
  2760.         elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang']))
  2761.         {
  2762.             return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang']SIMPLEPIE_CONSTRUCT_TEXT);
  2763.         }
  2764.         elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang']))
  2765.         {
  2766.             return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang']SIMPLEPIE_CONSTRUCT_TEXT);
  2767.         }
  2768.         elseif (isset($this->data['headers']['content-language']))
  2769.         {
  2770.             return $this->sanitize($this->data['headers']['content-language']SIMPLEPIE_CONSTRUCT_TEXT);
  2771.         }
  2772.         else
  2773.         {
  2774.             return null;
  2775.         }
  2776.     }
  2777.  
  2778.     function get_latitude()
  2779.     {
  2780.         if ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO'lat'))
  2781.         {
  2782.             return (float) $return[0]['data'];
  2783.         }
  2784.         elseif (($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/'$return[0]['data']$match))
  2785.         {
  2786.             return (float) $match[1];
  2787.         }
  2788.         else
  2789.         {
  2790.             return null;
  2791.         }
  2792.     }
  2793.  
  2794.     function get_longitude()
  2795.     {
  2796.         if ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO'long'))
  2797.         {
  2798.             return (float) $return[0]['data'];
  2799.         }
  2800.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO'lon'))
  2801.         {
  2802.             return (float) $return[0]['data'];
  2803.         }
  2804.         elseif (($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/'$return[0]['data']$match))
  2805.         {
  2806.             return (float) $match[2];
  2807.         }
  2808.         else
  2809.         {
  2810.             return null;
  2811.         }
  2812.     }
  2813.  
  2814.     function get_image_title()
  2815.     {
  2816.         if ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10'title'))
  2817.         {
  2818.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2819.         }
  2820.         elseif ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090'title'))
  2821.         {
  2822.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2823.         }
  2824.         elseif ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20'title'))
  2825.         {
  2826.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2827.         }
  2828.         elseif ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_11'title'))
  2829.         {
  2830.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2831.         }
  2832.         elseif ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_10'title'))
  2833.         {
  2834.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2835.         }
  2836.         else
  2837.         {
  2838.             return null;
  2839.         }
  2840.     }
  2841.  
  2842.     function get_image_url()
  2843.     {
  2844.         if ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES'image'))
  2845.         {
  2846.             return $this->sanitize($return[0]['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI);
  2847.         }
  2848.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'logo'))
  2849.         {
  2850.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  2851.         }
  2852.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'icon'))
  2853.         {
  2854.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  2855.         }
  2856.         elseif ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10'url'))
  2857.         {
  2858.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  2859.         }
  2860.         elseif ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090'url'))
  2861.         {
  2862.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  2863.         }
  2864.         elseif ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20'url'))
  2865.         {
  2866.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  2867.         }
  2868.         else
  2869.         {
  2870.             return null;
  2871.         }
  2872.     }
  2873.  
  2874.     function get_image_link()
  2875.     {
  2876.         if ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10'link'))
  2877.         {
  2878.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  2879.         }
  2880.         elseif ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090'link'))
  2881.         {
  2882.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  2883.         }
  2884.         elseif ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20'link'))
  2885.         {
  2886.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  2887.         }
  2888.         else
  2889.         {
  2890.             return null;
  2891.         }
  2892.     }
  2893.  
  2894.     function get_image_width()
  2895.     {
  2896.         if ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20'width'))
  2897.         {
  2898.             return round($return[0]['data']);
  2899.         }
  2900.         elseif ($this->get_type(SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20'url'))
  2901.         {
  2902.             return 88.0;
  2903.         }
  2904.         else
  2905.         {
  2906.             return null;
  2907.         }
  2908.     }
  2909.  
  2910.     function get_image_height()
  2911.     {
  2912.         if ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20'height'))
  2913.         {
  2914.             return round($return[0]['data']);
  2915.         }
  2916.         elseif ($this->get_type(SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20'url'))
  2917.         {
  2918.             return 31.0;
  2919.         }
  2920.         else
  2921.         {
  2922.             return null;
  2923.         }
  2924.     }
  2925.  
  2926.     function get_item_quantity($max 0)
  2927.     {
  2928.         $max = (int) $max;
  2929.         $qty count($this->get_items());
  2930.         if ($max === 0)
  2931.         {
  2932.             return $qty;
  2933.         }
  2934.         else
  2935.         {
  2936.             return ($qty $max$max $qty;
  2937.         }
  2938.     }
  2939.  
  2940.     function get_item($key 0)
  2941.     {
  2942.         $items $this->get_items();
  2943.         if (isset($items[$key]))
  2944.         {
  2945.             return $items[$key];
  2946.         }
  2947.         else
  2948.         {
  2949.             return null;
  2950.         }
  2951.     }
  2952.  
  2953.     function get_items($start 0$end 0)
  2954.     {
  2955.         if (!isset($this->data['items']))
  2956.         {
  2957.             if (!empty($this->multifeed_objects))
  2958.             {
  2959.                 $this->data['items'SimplePie::merge_items($this->multifeed_objects$start$end$this->item_limit);
  2960.             }
  2961.             else
  2962.             {
  2963.                 $this->data['items'array();
  2964.                 if ($items $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10'entry'))
  2965.                 {
  2966.                     $keys array_keys($items);
  2967.                     foreach ($keys as $key)
  2968.                     {
  2969.                         $this->data['items'][new $this->item_class($this$items[$key]);
  2970.                     }
  2971.                 }
  2972.                 if ($items $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03'entry'))
  2973.                 {
  2974.                     $keys array_keys($items);
  2975.                     foreach ($keys as $key)
  2976.                     {
  2977.                         $this->data['items'][new $this->item_class($this$items[$key]);
  2978.                     }
  2979.                 }
  2980.                 if ($items $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10'item'))
  2981.                 {
  2982.                     $keys array_keys($items);
  2983.                     foreach ($keys as $key)
  2984.                     {
  2985.                         $this->data['items'][new $this->item_class($this$items[$key]);
  2986.                     }
  2987.                 }
  2988.                 if ($items $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090'item'))
  2989.                 {
  2990.                     $keys array_keys($items);
  2991.                     foreach ($keys as $key)
  2992.                     {
  2993.                         $this->data['items'][new $this->item_class($this$items[$key]);
  2994.                     }
  2995.                 }
  2996.                 if ($items $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20'item'))
  2997.                 {
  2998.                     $keys array_keys($items);
  2999.                     foreach ($keys as $key)
  3000.                     {
  3001.                         $this->data['items'][new $this->item_class($this$items[$key]);
  3002.                     }
  3003.                 }
  3004.             }
  3005.         }
  3006.  
  3007.         if (!empty($this->data['items']))
  3008.         {
  3009.             // If we want to order it by date, check if all items have a date, and then sort it
  3010.             if ($this->order_by_date && empty($this->multifeed_objects))
  3011.             {
  3012.                 if (!isset($this->data['ordered_items']))
  3013.                 {
  3014.                     $do_sort true;
  3015.                     foreach ($this->data['items'as $item)
  3016.                     {
  3017.                         if (!$item->get_date('U'))
  3018.                         {
  3019.                             $do_sort false;
  3020.                             break;
  3021.                         }
  3022.                     }
  3023.                     $item null;
  3024.                     $this->data['ordered_items'$this->data['items'];
  3025.                     if ($do_sort)
  3026.                     {
  3027.                         usort($this->data['ordered_items']array(&$this'sort_items'));
  3028.                     }
  3029.                 }
  3030.                 $items $this->data['ordered_items'];
  3031.             }
  3032.             else
  3033.             {
  3034.                 $items $this->data['items'];
  3035.             }
  3036.  
  3037.             // Slice the data as desired
  3038.             if ($end === 0)
  3039.             {
  3040.                 return array_slice($items$start);
  3041.             }
  3042.             else
  3043.             {
  3044.                 return array_slice($items$start$end);
  3045.             }
  3046.         }
  3047.         else
  3048.         {
  3049.             return array();
  3050.         }
  3051.     }
  3052.  
  3053.     /**
  3054.      * @static
  3055.      */
  3056.     function sort_items($a$b)
  3057.     {
  3058.         return $a->get_date('U'<= $b->get_date('U');
  3059.     }
  3060.  
  3061.     /**
  3062.      * @static
  3063.      */
  3064.     function merge_items($urls$start 0$end 0$limit 0)
  3065.     {
  3066.         if (is_array($urls&& sizeof($urls0)
  3067.         {
  3068.             $items array();
  3069.             foreach ($urls as $arg)
  3070.             {
  3071.                 if (is_a($arg'SimplePie'))
  3072.                 {
  3073.                     $items array_merge($items$arg->get_items(0$limit));
  3074.                 }
  3075.                 else
  3076.                 {
  3077.                     trigger_error('Arguments must be SimplePie objects'E_USER_WARNING);
  3078.                 }
  3079.             }
  3080.  
  3081.             $do_sort true;
  3082.             foreach ($items as $item)
  3083.             {
  3084.                 if (!$item->get_date('U'))
  3085.                 {
  3086.                     $do_sort false;
  3087.                     break;
  3088.                 }
  3089.             }
  3090.             $item null;
  3091.             if ($do_sort)
  3092.             {
  3093.                 usort($itemsarray('SimplePie''sort_items'));
  3094.             }
  3095.  
  3096.             if ($end === 0)
  3097.             {
  3098.                 return array_slice($items$start);
  3099.             }
  3100.             else
  3101.             {
  3102.                 return array_slice($items$start$end);
  3103.             }
  3104.         }
  3105.         else
  3106.         {
  3107.             trigger_error('Cannot merge zero SimplePie objects'E_USER_WARNING);
  3108.             return array();
  3109.         }
  3110.     }
  3111. }
  3112.  
  3113. {
  3114.     var $feed;
  3115.     var $data = array();
  3116.  
  3117.     function SimplePie_Item($feed$data)
  3118.     {
  3119.         $this->feed = $feed;
  3120.         $this->data = $data;
  3121.     }
  3122.  
  3123.     function __toString()
  3124.     {
  3125.         return md5(serialize($this->data));
  3126.     }
  3127.  
  3128.     /**
  3129.      * Remove items that link back to this before destroying this object
  3130.      */
  3131.     function __destruct()
  3132.     {
  3133.         if ((version_compare(PHP_VERSION'5.3''<'|| !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))
  3134.         {
  3135.             unset($this->feed);
  3136.         }
  3137.     }
  3138.  
  3139.     function get_item_tags($namespace$tag)
  3140.     {
  3141.         if (isset($this->data['child'][$namespace][$tag]))
  3142.         {
  3143.             return $this->data['child'][$namespace][$tag];
  3144.         }
  3145.         else
  3146.         {
  3147.             return null;
  3148.         }
  3149.     }
  3150.  
  3151.     function get_base($element array())
  3152.     {
  3153.         return $this->feed->get_base($element);
  3154.     }
  3155.  
  3156.     function sanitize($data$type$base '')
  3157.     {
  3158.         return $this->feed->sanitize($data$type$base);
  3159.     }
  3160.  
  3161.     function get_feed()
  3162.     {
  3163.         return $this->feed;
  3164.     }
  3165.  
  3166.     function get_id($hash false)
  3167.     {
  3168.         if (!$hash)
  3169.         {
  3170.             if ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'id'))
  3171.             {
  3172.                 return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3173.             }
  3174.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'id'))
  3175.             {
  3176.                 return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3177.             }
  3178.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20'guid'))
  3179.             {
  3180.                 return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3181.             }
  3182.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11'identifier'))
  3183.             {
  3184.                 return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3185.             }
  3186.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10'identifier'))
  3187.             {
  3188.                 return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3189.             }
  3190.             elseif (($return $this->get_permalink()) !== null)
  3191.             {
  3192.                 return $return;
  3193.             }
  3194.             elseif (($return $this->get_title()) !== null)
  3195.             {
  3196.                 return $return;
  3197.             }
  3198.         }
  3199.         if ($this->get_permalink(!== null || $this->get_title(!== null)
  3200.         {
  3201.             return md5($this->get_permalink($this->get_title());
  3202.         }
  3203.         else
  3204.         {
  3205.             return md5(serialize($this->data));
  3206.         }
  3207.     }
  3208.  
  3209.     function get_title()
  3210.     {
  3211.         if (!isset($this->data['title']))
  3212.         {
  3213.             if ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'title'))
  3214.             {
  3215.                 $this->data['title'$this->sanitize($return[0]['data']SimplePie_Misc::atom_10_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  3216.             }
  3217.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'title'))
  3218.             {
  3219.                 $this->data['title'$this->sanitize($return[0]['data']SimplePie_Misc::atom_03_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  3220.             }
  3221.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10'title'))
  3222.             {
  3223.                 $this->data['title'$this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  3224.             }
  3225.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090'title'))
  3226.             {
  3227.                 $this->data['title'$this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  3228.             }
  3229.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20'title'))
  3230.             {
  3231.                 $this->data['title'$this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  3232.             }
  3233.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11'title'))
  3234.             {
  3235.                 $this->data['title'$this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3236.             }
  3237.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10'title'))
  3238.             {
  3239.                 $this->data['title'$this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3240.             }
  3241.             else
  3242.             {
  3243.                 $this->data['title'null;
  3244.             }
  3245.         }
  3246.         return $this->data['title'];
  3247.     }
  3248.  
  3249.     function get_description($description_only false)
  3250.     {
  3251.         if ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'summary'))
  3252.         {
  3253.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_10_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  3254.         }
  3255.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'summary'))
  3256.         {
  3257.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_03_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  3258.         }
  3259.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10'description'))
  3260.         {
  3261.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  3262.         }
  3263.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20'description'))
  3264.         {
  3265.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_HTML$this->get_base($return[0]));
  3266.         }
  3267.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11'description'))
  3268.         {
  3269.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3270.         }
  3271.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10'description'))
  3272.         {
  3273.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3274.         }
  3275.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES'summary'))
  3276.         {
  3277.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_HTML$this->get_base($return[0]));
  3278.         }
  3279.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES'subtitle'))
  3280.         {
  3281.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3282.         }
  3283.         elseif (!$description_only)
  3284.         {
  3285.             return $this->get_content(true);
  3286.         }
  3287.         else
  3288.         {
  3289.             return null;
  3290.         }
  3291.     }
  3292.  
  3293.     function get_content($content_only false)
  3294.     {
  3295.         if ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'content'))
  3296.         {
  3297.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_10_content_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  3298.         }
  3299.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'content'))
  3300.         {
  3301.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_03_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  3302.         }
  3303.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT'encoded'))
  3304.         {
  3305.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_HTML$this->get_base($return[0]));
  3306.         }
  3307.         elseif (!$content_only)
  3308.         {
  3309.             return $this->get_description(true);
  3310.         }
  3311.         else
  3312.         {
  3313.             return null;
  3314.         }
  3315.     }
  3316.  
  3317.     function get_category($key 0)
  3318.     {
  3319.         $categories $this->get_categories();
  3320.         if (isset($categories[$key]))
  3321.         {
  3322.             return $categories[$key];
  3323.         }
  3324.         else
  3325.         {
  3326.             return null;
  3327.         }
  3328.     }
  3329.  
  3330.     function get_categories()
  3331.     {
  3332.         $categories array();
  3333.  
  3334.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'category'as $category)
  3335.         {
  3336.             $term null;
  3337.             $scheme null;
  3338.             $label null;
  3339.             if (isset($category['attribs']['']['term']))
  3340.             {
  3341.                 $term $this->sanitize($category['attribs']['']['term']SIMPLEPIE_CONSTRUCT_TEXT);
  3342.             }
  3343.             if (isset($category['attribs']['']['scheme']))
  3344.             {
  3345.                 $scheme $this->sanitize($category['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  3346.             }
  3347.             if (isset($category['attribs']['']['label']))
  3348.             {
  3349.                 $label $this->sanitize($category['attribs']['']['label']SIMPLEPIE_CONSTRUCT_TEXT);
  3350.             }
  3351.             $categories[new $this->feed->category_class($term$scheme$label);
  3352.         }
  3353.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20'category'as $category)
  3354.         {
  3355.             // This is really the label, but keep this as the term also for BC.
  3356.             // Label will also work on retrieving because that falls back to term.
  3357.             $term $this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3358.             if (isset($category['attribs']['']['domain']))
  3359.             {
  3360.                 $scheme $this->sanitize($category['attribs']['']['domain']SIMPLEPIE_CONSTRUCT_TEXT);
  3361.             }
  3362.             else
  3363.             {
  3364.                 $scheme null;
  3365.             }
  3366.             $categories[new $this->feed->category_class($term$schemenull);
  3367.         }
  3368.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11'subject'as $category)
  3369.         {
  3370.             $categories[new $this->feed->category_class($this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  3371.         }
  3372.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10'subject'as $category)
  3373.         {
  3374.             $categories[new $this->feed->category_class($this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  3375.         }
  3376.  
  3377.         if (!empty($categories))
  3378.         {
  3379.             return SimplePie_Misc::array_unique($categories);
  3380.         }
  3381.         else
  3382.         {
  3383.             return null;
  3384.         }
  3385.     }
  3386.  
  3387.     function get_author($key 0)
  3388.     {
  3389.         $authors $this->get_authors();
  3390.         if (isset($authors[$key]))
  3391.         {
  3392.             return $authors[$key];
  3393.         }
  3394.         else
  3395.         {
  3396.             return null;
  3397.         }
  3398.     }
  3399.  
  3400.     function get_contributor($key 0)
  3401.     {
  3402.         $contributors $this->get_contributors();
  3403.         if (isset($contributors[$key]))
  3404.         {
  3405.             return $contributors[$key];
  3406.         }
  3407.         else
  3408.         {
  3409.             return null;
  3410.         }
  3411.     }
  3412.  
  3413.     function get_contributors()
  3414.     {
  3415.         $contributors array();
  3416.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'contributor'as $contributor)
  3417.         {
  3418.             $name null;
  3419.             $uri null;
  3420.             $email null;
  3421.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
  3422.             {
  3423.                 $name $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3424.             }
  3425.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
  3426.             {
  3427.                 $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]));
  3428.             }
  3429.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
  3430.             {
  3431.                 $email $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3432.             }
  3433.             if ($name !== null || $email !== null || $uri !== null)
  3434.             {
  3435.                 $contributors[new $this->feed->author_class($name$uri$email);
  3436.             }
  3437.         }
  3438.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'contributor'as $contributor)
  3439.         {
  3440.             $name null;
  3441.             $url null;
  3442.             $email null;
  3443.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
  3444.             {
  3445.                 $name $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3446.             }
  3447.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
  3448.             {
  3449.                 $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]));
  3450.             }
  3451.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
  3452.             {
  3453.                 $email $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3454.             }
  3455.             if ($name !== null || $email !== null || $url !== null)
  3456.             {
  3457.                 $contributors[new $this->feed->author_class($name$url$email);
  3458.             }
  3459.         }
  3460.  
  3461.         if (!empty($contributors))
  3462.         {
  3463.             return SimplePie_Misc::array_unique($contributors);
  3464.         }
  3465.         else
  3466.         {
  3467.             return null;
  3468.         }
  3469.     }
  3470.  
  3471.     function get_authors()
  3472.     {
  3473.         $authors array();
  3474.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'author'as $author)
  3475.         {
  3476.             $name null;
  3477.             $uri null;
  3478.             $email null;
  3479.             if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
  3480.             {
  3481.                 $name $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3482.             }
  3483.             if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
  3484.             {
  3485.                 $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]));
  3486.             }
  3487.             if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
  3488.             {
  3489.                 $email $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3490.             }
  3491.             if ($name !== null || $email !== null || $uri !== null)
  3492.             {
  3493.                 $authors[new $this->feed->author_class($name$uri$email);
  3494.             }
  3495.         }
  3496.         if ($author $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'author'))
  3497.         {
  3498.             $name null;
  3499.             $url null;
  3500.             $email null;
  3501.             if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
  3502.             {
  3503.                 $name $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3504.             }
  3505.             if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
  3506.             {
  3507.                 $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]));
  3508.             }
  3509.             if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
  3510.             {
  3511.                 $email $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3512.             }
  3513.             if ($name !== null || $email !== null || $url !== null)
  3514.             {
  3515.                 $authors[new $this->feed->author_class($name$url$email);
  3516.             }
  3517.         }
  3518.         if ($author $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20'author'))
  3519.         {
  3520.             $authors[new $this->feed->author_class(nullnull$this->sanitize($author[0]['data']SIMPLEPIE_CONSTRUCT_TEXT));
  3521.         }
  3522.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11'creator'as $author)
  3523.         {
  3524.             $authors[new $this->feed->author_class($this->sanitize($author['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  3525.         }
  3526.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10'creator'as $author)
  3527.         {
  3528.             $authors[new $this->feed->author_class($this->sanitize($author['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  3529.         }
  3530.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES'author'as $author)
  3531.         {
  3532.             $authors[new $this->feed->author_class($this->sanitize($author['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  3533.         }
  3534.  
  3535.         if (!empty($authors))
  3536.         {
  3537.             return SimplePie_Misc::array_unique($authors);
  3538.         }
  3539.         elseif (($source $this->get_source()) && ($authors $source->get_authors()))
  3540.         {
  3541.             return $authors;
  3542.         }
  3543.         elseif ($authors $this->feed->get_authors())
  3544.         {
  3545.             return $authors;
  3546.         }
  3547.         else
  3548.         {
  3549.             return null;
  3550.         }
  3551.     }
  3552.  
  3553.     function get_copyright()
  3554.     {
  3555.         if ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'rights'))
  3556.         {
  3557.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_10_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  3558.         }
  3559.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11'rights'))
  3560.         {
  3561.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3562.         }
  3563.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10'rights'))
  3564.         {
  3565.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3566.         }
  3567.         else
  3568.         {
  3569.             return null;
  3570.         }
  3571.     }
  3572.  
  3573.     function get_date($date_format 'j F Y, g:i a')
  3574.     {
  3575.         if (!isset($this->data['date']))
  3576.         {
  3577.             if ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'published'))
  3578.             {
  3579.                 $this->data['date']['raw'$return[0]['data'];
  3580.             }
  3581.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'updated'))
  3582.             {
  3583.                 $this->data['date']['raw'$return[0]['data'];
  3584.             }
  3585.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'issued'))
  3586.             {
  3587.                 $this->data['date']['raw'$return[0]['data'];
  3588.             }
  3589.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'created'))
  3590.             {
  3591.                 $this->data['date']['raw'$return[0]['data'];
  3592.             }
  3593.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'modified'))
  3594.             {
  3595.                 $this->data['date']['raw'$return[0]['data'];
  3596.             }
  3597.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20'pubDate'))
  3598.             {
  3599.                 $this->data['date']['raw'$return[0]['data'];
  3600.             }
  3601.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11'date'))
  3602.             {
  3603.                 $this->data['date']['raw'$return[0]['data'];
  3604.             }
  3605.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10'date'))
  3606.             {
  3607.                 $this->data['date']['raw'$return[0]['data'];
  3608.             }
  3609.  
  3610.             if (!empty($this->data['date']['raw']))
  3611.             {
  3612.                 $parser SimplePie_Parse_Date::get();
  3613.                 $this->data['date']['parsed'$parser->parse($this->data['date']['raw']);
  3614.             }
  3615.             else
  3616.             {
  3617.                 $this->data['date'null;
  3618.             }
  3619.         }
  3620.         if ($this->data['date'])
  3621.         {
  3622.             $date_format = (string) $date_format;
  3623.             switch ($date_format)
  3624.             {
  3625.                 case '':
  3626.                     return $this->sanitize($this->data['date']['raw']SIMPLEPIE_CONSTRUCT_TEXT);
  3627.  
  3628.                 case 'U':
  3629.                     return $this->data['date']['parsed'];
  3630.  
  3631.                 default:
  3632.                     return date($date_format$this->data['date']['parsed']);
  3633.             }
  3634.         }
  3635.         else
  3636.         {
  3637.             return null;
  3638.         }
  3639.     }
  3640.  
  3641.     function get_local_date($date_format '%c')
  3642.     {
  3643.         if (!$date_format)
  3644.         {
  3645.             return $this->sanitize($this->get_date('')SIMPLEPIE_CONSTRUCT_TEXT);
  3646.         }
  3647.         elseif (($date $this->get_date('U')) !== null)
  3648.         {
  3649.             return strftime($date_format$date);
  3650.         }
  3651.         else
  3652.         {
  3653.             return null;
  3654.         }
  3655.     }
  3656.  
  3657.     function get_permalink()
  3658.     {
  3659.         $link $this->get_link();
  3660.         $enclosure $this->get_enclosure(0);
  3661.         if ($link !== null)
  3662.         {
  3663.             return $link;
  3664.         }
  3665.         elseif ($enclosure !== null)
  3666.         {
  3667.             return $enclosure->get_link();
  3668.         }
  3669.         else
  3670.         {
  3671.             return null;
  3672.         }
  3673.     }
  3674.  
  3675.     function get_link($key 0$rel 'alternate')
  3676.     {
  3677.         $links $this->get_links($rel);
  3678.         if ($links[$key!== null)
  3679.         {
  3680.             return $links[$key];
  3681.         }
  3682.         else
  3683.         {
  3684.             return null;
  3685.         }
  3686.     }
  3687.  
  3688.     function get_links($rel 'alternate')
  3689.     {
  3690.         if (!isset($this->data['links']))
  3691.         {
  3692.             $this->data['links'array();
  3693.             foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'link'as $link)
  3694.             {
  3695.                 if (isset($link['attribs']['']['href']))
  3696.                 {
  3697.                     $link_rel (isset($link['attribs']['']['rel'])) $link['attribs']['']['rel''alternate';
  3698.                     $this->data['links'][$link_rel][$this->sanitize($link['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($link));
  3699.  
  3700.                 }
  3701.             }
  3702.             foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'link'as $link)
  3703.             {
  3704.                 if (isset($link['attribs']['']['href']))
  3705.                 {
  3706.                     $link_rel (isset($link['attribs']['']['rel'])) $link['attribs']['']['rel''alternate';
  3707.                     $this->data['links'][$link_rel][$this->sanitize($link['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($link));
  3708.                 }
  3709.             }
  3710.             if ($links $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10'link'))
  3711.             {
  3712.                 $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  3713.             }
  3714.             if ($links $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090'link'))
  3715.             {
  3716.                 $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  3717.             }
  3718.             if ($links $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20'link'))
  3719.             {
  3720.                 $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  3721.             }
  3722.             if ($links $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20'guid'))
  3723.             {
  3724.                 if (!isset($links[0]['attribs']['']['isPermaLink']|| strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true')
  3725.                 {
  3726.                     $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  3727.                 }
  3728.             }
  3729.  
  3730.             $keys array_keys($this->data['links']);
  3731.             foreach ($keys as $key)
  3732.             {
  3733.                 if (SimplePie_Misc::is_isegment_nz_nc($key))
  3734.                 {
  3735.                     if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key]))
  3736.                     {
  3737.                         $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $keyarray_merge($this->data['links'][$key]$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key]);
  3738.                         $this->data['links'][$key=$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key];
  3739.                     }
  3740.                     else
  3741.                     {
  3742.                         $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key=$this->data['links'][$key];
  3743.                     }
  3744.                 }
  3745.                 elseif (substr($key041=== SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
  3746.                 {
  3747.                     $this->data['links'][substr($key41)=$this->data['links'][$key];
  3748.                 }
  3749.                 $this->data['links'][$keyarray_unique($this->data['links'][$key]);
  3750.             }
  3751.         }
  3752.         if (isset($this->data['links'][$rel]))
  3753.         {
  3754.             return $this->data['links'][$rel];
  3755.         }
  3756.         else
  3757.         {
  3758.             return null;
  3759.         }
  3760.     }
  3761.  
  3762.     /**
  3763.      * @todo Add ability to prefer one type of content over another (in a media group).
  3764.      */
  3765.     function get_enclosure($key 0$prefer null)
  3766.     {
  3767.         $enclosures $this->get_enclosures();
  3768.         if (isset($enclosures[$key]))
  3769.         {
  3770.             return $enclosures[$key];
  3771.         }
  3772.         else
  3773.         {
  3774.             return null;
  3775.         }
  3776.     }
  3777.  
  3778.     /**
  3779.      * Grabs all available enclosures (podcasts, etc.)
  3780.      *
  3781.      * Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS.
  3782.      *
  3783.      * 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.
  3784.      *
  3785.      * @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4).
  3786.      * @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).
  3787.      */
  3788.     function get_enclosures()
  3789.     {
  3790.         if (!isset($this->data['enclosures']))
  3791.         {
  3792.             $this->data['enclosures'array();
  3793.  
  3794.             // Elements
  3795.             $captions_parent null;
  3796.             $categories_parent null;
  3797.             $copyrights_parent null;
  3798.             $credits_parent null;
  3799.             $description_parent null;
  3800.             $duration_parent null;
  3801.             $hashes_parent null;
  3802.             $keywords_parent null;
  3803.             $player_parent null;
  3804.             $ratings_parent null;
  3805.             $restrictions_parent null;
  3806.             $thumbnails_parent null;
  3807.             $title_parent null;
  3808.  
  3809.             // Let's do the channel and item-level ones first, and just re-use them if we need to.
  3810.             $parent $this->get_feed();
  3811.  
  3812.             // CAPTIONS
  3813.             if ($captions $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'text'))
  3814.             {
  3815.                 foreach ($captions as $caption)
  3816.                 {
  3817.                     $caption_type null;
  3818.                     $caption_lang null;
  3819.                     $caption_startTime null;
  3820.                     $caption_endTime null;
  3821.                     $caption_text null;
  3822.                     if (isset($caption['attribs']['']['type']))
  3823.                     {
  3824.                         $caption_type $this->sanitize($caption['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  3825.                     }
  3826.                     if (isset($caption['attribs']['']['lang']))
  3827.                     {
  3828.                         $caption_lang $this->sanitize($caption['attribs']['']['lang']SIMPLEPIE_CONSTRUCT_TEXT);
  3829.                     }
  3830.                     if (isset($caption['attribs']['']['start']))
  3831.                     {
  3832.                         $caption_startTime $this->sanitize($caption['attribs']['']['start']SIMPLEPIE_CONSTRUCT_TEXT);
  3833.                     }
  3834.                     if (isset($caption['attribs']['']['end']))
  3835.                     {
  3836.                         $caption_endTime $this->sanitize($caption['attribs']['']['end']SIMPLEPIE_CONSTRUCT_TEXT);
  3837.                     }
  3838.                     if (isset($caption['data']))
  3839.                     {
  3840.                         $caption_text $this->sanitize($caption['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3841.                     }
  3842.                     $captions_parent[new $this->feed->caption_class($caption_type$caption_lang$caption_startTime$caption_endTime$caption_text);
  3843.                 }
  3844.             }
  3845.             elseif ($captions $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'text'))
  3846.             {
  3847.                 foreach ($captions as $caption)
  3848.                 {
  3849.                     $caption_type null;
  3850.                     $caption_lang null;
  3851.                     $caption_startTime null;
  3852.                     $caption_endTime null;
  3853.                     $caption_text null;
  3854.                     if (isset($caption['attribs']['']['type']))
  3855.                     {
  3856.                         $caption_type $this->sanitize($caption['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  3857.                     }
  3858.                     if (isset($caption['attribs']['']['lang']))
  3859.                     {
  3860.                         $caption_lang $this->sanitize($caption['attribs']['']['lang']SIMPLEPIE_CONSTRUCT_TEXT);
  3861.                     }
  3862.                     if (isset($caption['attribs']['']['start']))
  3863.                     {
  3864.                         $caption_startTime $this->sanitize($caption['attribs']['']['start']SIMPLEPIE_CONSTRUCT_TEXT);
  3865.                     }
  3866.                     if (isset($caption['attribs']['']['end']))
  3867.                     {
  3868.                         $caption_endTime $this->sanitize($caption['attribs']['']['end']SIMPLEPIE_CONSTRUCT_TEXT);
  3869.                     }
  3870.                     if (isset($caption['data']))
  3871.                     {
  3872.                         $caption_text $this->sanitize($caption['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3873.                     }
  3874.                     $captions_parent[new $this->feed->caption_class($caption_type$caption_lang$caption_startTime$caption_endTime$caption_text);
  3875.                 }
  3876.             }
  3877.             if (is_array($captions_parent))
  3878.             {
  3879.                 $captions_parent array_values(SimplePie_Misc::array_unique($captions_parent));
  3880.             }
  3881.  
  3882.             // CATEGORIES
  3883.             foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'category'as $category)
  3884.             {
  3885.                 $term null;
  3886.                 $scheme null;
  3887.                 $label null;
  3888.                 if (isset($category['data']))
  3889.                 {
  3890.                     $term $this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3891.                 }
  3892.                 if (isset($category['attribs']['']['scheme']))
  3893.                 {
  3894.                     $scheme $this->sanitize($category['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  3895.                 }
  3896.                 else
  3897.                 {
  3898.                     $scheme 'http://search.yahoo.com/mrss/category_schema';
  3899.                 }
  3900.                 if (isset($category['attribs']['']['label']))
  3901.                 {
  3902.                     $label $this->sanitize($category['attribs']['']['label']SIMPLEPIE_CONSTRUCT_TEXT);
  3903.                 }
  3904.                 $categories_parent[new $this->feed->category_class($term$scheme$label);
  3905.             }
  3906.             foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'category'as $category)
  3907.             {
  3908.                 $term null;
  3909.                 $scheme null;
  3910.                 $label null;
  3911.                 if (isset($category['data']))
  3912.                 {
  3913.                     $term $this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3914.                 }
  3915.                 if (isset($category['attribs']['']['scheme']))
  3916.                 {
  3917.                     $scheme $this->sanitize($category['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  3918.                 }
  3919.                 else
  3920.                 {
  3921.                     $scheme 'http://search.yahoo.com/mrss/category_schema';
  3922.                 }
  3923.                 if (isset($category['attribs']['']['label']))
  3924.                 {
  3925.                     $label $this->sanitize($category['attribs']['']['label']SIMPLEPIE_CONSTRUCT_TEXT);
  3926.                 }
  3927.                 $categories_parent[new $this->feed->category_class($term$scheme$label);
  3928.             }
  3929.             foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES'category'as $category)
  3930.             {
  3931.                 $term null;
  3932.                 $scheme 'http://www.itunes.com/dtds/podcast-1.0.dtd';
  3933.                 $label null;
  3934.                 if (isset($category['attribs']['']['text']))
  3935.                 {
  3936.                     $label $this->sanitize($category['attribs']['']['text']SIMPLEPIE_CONSTRUCT_TEXT);
  3937.                 }
  3938.                 $categories_parent[new $this->feed->category_class($term$scheme$label);
  3939.  
  3940.                 if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category']))
  3941.                 {
  3942.                     foreach ((array) $category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'as $subcategory)
  3943.                     {
  3944.                         if (isset($subcategory['attribs']['']['text']))
  3945.                         {
  3946.                             $label $this->sanitize($subcategory['attribs']['']['text']SIMPLEPIE_CONSTRUCT_TEXT);
  3947.                         }
  3948.                         $categories_parent[new $this->feed->category_class($term$scheme$label);
  3949.                     }
  3950.                 }
  3951.             }
  3952.             if (is_array($categories_parent))
  3953.             {
  3954.                 $categories_parent array_values(SimplePie_Misc::array_unique($categories_parent));
  3955.             }
  3956.  
  3957.             // COPYRIGHT
  3958.             if ($copyright $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'copyright'))
  3959.             {
  3960.                 $copyright_url null;
  3961.                 $copyright_label null;
  3962.                 if (isset($copyright[0]['attribs']['']['url']))
  3963.                 {
  3964.                     $copyright_url $this->sanitize($copyright[0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_TEXT);
  3965.                 }
  3966.                 if (isset($copyright[0]['data']))
  3967.                 {
  3968.                     $copyright_label $this->sanitize($copyright[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3969.                 }
  3970.                 $copyrights_parent new $this->feed->copyright_class($copyright_url$copyright_label);
  3971.             }
  3972.             elseif ($copyright $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'copyright'))
  3973.             {
  3974.                 $copyright_url null;
  3975.                 $copyright_label null;
  3976.                 if (isset($copyright[0]['attribs']['']['url']))
  3977.                 {
  3978.                     $copyright_url $this->sanitize($copyright[0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_TEXT);
  3979.                 }
  3980.                 if (isset($copyright[0]['data']))
  3981.                 {
  3982.                     $copyright_label $this->sanitize($copyright[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3983.                 }
  3984.                 $copyrights_parent new $this->feed->copyright_class($copyright_url$copyright_label);
  3985.             }
  3986.  
  3987.             // CREDITS
  3988.             if ($credits $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'credit'))
  3989.             {
  3990.                 foreach ($credits as $credit)
  3991.                 {
  3992.                     $credit_role null;
  3993.                     $credit_scheme null;
  3994.                     $credit_name null;
  3995.                     if (isset($credit['attribs']['']['role']))
  3996.                     {
  3997.                         $credit_role $this->sanitize($credit['attribs']['']['role']SIMPLEPIE_CONSTRUCT_TEXT);
  3998.                     }
  3999.                     if (isset($credit['attribs']['']['scheme']))
  4000.                     {
  4001.                         $credit_scheme $this->sanitize($credit['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  4002.                     }
  4003.                     else
  4004.                     {
  4005.                         $credit_scheme 'urn:ebu';
  4006.                     }
  4007.                     if (isset($credit['data']))
  4008.                     {
  4009.                         $credit_name $this->sanitize($credit['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4010.                     }
  4011.                     $credits_parent[new $this->feed->credit_class($credit_role$credit_scheme$credit_name);
  4012.                 }
  4013.             }
  4014.             elseif ($credits $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'credit'))
  4015.             {
  4016.                 foreach ($credits as $credit)
  4017.                 {
  4018.                     $credit_role null;
  4019.                     $credit_scheme null;
  4020.                     $credit_name null;
  4021.                     if (isset($credit['attribs']['']['role']))
  4022.                     {
  4023.                         $credit_role $this->sanitize($credit['attribs']['']['role']SIMPLEPIE_CONSTRUCT_TEXT);
  4024.                     }
  4025.                     if (isset($credit['attribs']['']['scheme']))
  4026.                     {
  4027.                         $credit_scheme $this->sanitize($credit['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  4028.                     }
  4029.                     else
  4030.                     {
  4031.                         $credit_scheme 'urn:ebu';
  4032.                     }
  4033.                     if (isset($credit['data']))
  4034.                     {
  4035.                         $credit_name $this->sanitize($credit['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4036.                     }
  4037.                     $credits_parent[new $this->feed->credit_class($credit_role$credit_scheme$credit_name);
  4038.                 }
  4039.             }
  4040.             if (is_array($credits_parent))
  4041.             {
  4042.                 $credits_parent array_values(SimplePie_Misc::array_unique($credits_parent));
  4043.             }
  4044.  
  4045.             // DESCRIPTION
  4046.             if ($description_parent $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'description'))
  4047.             {
  4048.                 if (isset($description_parent[0]['data']))
  4049.                 {
  4050.                     $description_parent $this->sanitize($description_parent[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4051.                 }
  4052.             }
  4053.             elseif ($description_parent $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'description'))
  4054.             {
  4055.                 if (isset($description_parent[0]['data']))
  4056.                 {
  4057.                     $description_parent $this->sanitize($description_parent[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4058.                 }
  4059.             }
  4060.  
  4061.             // DURATION
  4062.             if ($duration_parent $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES'duration'))
  4063.             {
  4064.                 $seconds null;
  4065.                 $minutes null;
  4066.                 $hours null;
  4067.                 if (isset($duration_parent[0]['data']))
  4068.                 {
  4069.                     $temp explode(':'$this->sanitize($duration_parent[0]['data']SIMPLEPIE_CONSTRUCT_TEXT));
  4070.                     if (sizeof($temp0)
  4071.                     {
  4072.                         (int) $seconds array_pop($temp);
  4073.                     }
  4074.                     if (sizeof($temp0)
  4075.                     {
  4076.                         (int) $minutes array_pop($temp);
  4077.                         $seconds += $minutes 60;
  4078.                     }
  4079.                     if (sizeof($temp0)
  4080.                     {
  4081.                         (int) $hours array_pop($temp);
  4082.                         $seconds += $hours 3600;
  4083.                     }
  4084.                     unset($temp);
  4085.                     $duration_parent $seconds;
  4086.                 }
  4087.             }
  4088.  
  4089.             // HASHES
  4090.             if ($hashes_iterator $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'hash'))
  4091.             {
  4092.                 foreach ($hashes_iterator as $hash)
  4093.                 {
  4094.                     $value null;
  4095.                     $algo null;
  4096.                     if (isset($hash['data']))
  4097.                     {
  4098.                         $value $this->sanitize($hash['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4099.                     }
  4100.                     if (isset($hash['attribs']['']['algo']))
  4101.                     {
  4102.                         $algo $this->sanitize($hash['attribs']['']['algo']SIMPLEPIE_CONSTRUCT_TEXT);
  4103.                     }
  4104.                     else
  4105.                     {
  4106.                         $algo 'md5';
  4107.                     }
  4108.                     $hashes_parent[$algo.':'.$value;
  4109.                 }
  4110.             }
  4111.             elseif ($hashes_iterator $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'hash'))
  4112.             {
  4113.                 foreach ($hashes_iterator as $hash)
  4114.                 {
  4115.                     $value null;
  4116.                     $algo null;
  4117.                     if (isset($hash['data']))
  4118.                     {
  4119.                         $value $this->sanitize($hash['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4120.                     }
  4121.                     if (isset($hash['attribs']['']['algo']))
  4122.                     {
  4123.                         $algo $this->sanitize($hash['attribs']['']['algo']SIMPLEPIE_CONSTRUCT_TEXT);
  4124.                     }
  4125.                     else
  4126.                     {
  4127.                         $algo 'md5';
  4128.                     }
  4129.                     $hashes_parent[$algo.':'.$value;
  4130.                 }
  4131.             }
  4132.             if (is_array($hashes_parent))
  4133.             {
  4134.                 $hashes_parent array_values(SimplePie_Misc::array_unique($hashes_parent));
  4135.             }
  4136.  
  4137.             // KEYWORDS
  4138.             if ($keywords $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'keywords'))
  4139.             {
  4140.                 if (isset($keywords[0]['data']))
  4141.                 {
  4142.                     $temp explode(','$this->sanitize($keywords[0]['data']SIMPLEPIE_CONSTRUCT_TEXT));
  4143.                     foreach ($temp as $word)
  4144.                     {
  4145.                         $keywords_parent[trim($word);
  4146.                     }
  4147.                 }
  4148.                 unset($temp);
  4149.             }
  4150.             elseif ($keywords $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES'keywords'))
  4151.             {
  4152.                 if (isset($keywords[0]['data']))
  4153.                 {
  4154.                     $temp explode(','$this->sanitize($keywords[0]['data']SIMPLEPIE_CONSTRUCT_TEXT));
  4155.                     foreach ($temp as $word)
  4156.                     {
  4157.                         $keywords_parent[trim($word);
  4158.                     }
  4159.                 }
  4160.                 unset($temp);
  4161.             }
  4162.             elseif ($keywords $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'keywords'))
  4163.             {
  4164.                 if (isset($keywords[0]['data']))
  4165.                 {
  4166.                     $temp explode(','$this->sanitize($keywords[0]['data']SIMPLEPIE_CONSTRUCT_TEXT));
  4167.                     foreach ($temp as $word)
  4168.                     {
  4169.                         $keywords_parent[trim($word);
  4170.                     }
  4171.                 }
  4172.                 unset($temp);
  4173.             }
  4174.             elseif ($keywords $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES'keywords'))
  4175.             {
  4176.                 if (isset($keywords[0]['data']))
  4177.                 {
  4178.                     $temp explode(','$this->sanitize($keywords[0]['data']SIMPLEPIE_CONSTRUCT_TEXT));
  4179.                     foreach ($temp as $word)
  4180.                     {
  4181.                         $keywords_parent[trim($word);
  4182.                     }
  4183.                 }
  4184.                 unset($temp);
  4185.             }
  4186.             if (is_array($keywords_parent))
  4187.             {
  4188.                 $keywords_parent array_values(SimplePie_Misc::array_unique($keywords_parent));
  4189.             }
  4190.  
  4191.             // PLAYER
  4192.             if ($player_parent $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'player'))
  4193.             {
  4194.                 if (isset($player_parent[0]['attribs']['']['url']))
  4195.                 {
  4196.                     $player_parent $this->sanitize($player_parent[0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  4197.                 }
  4198.             }
  4199.             elseif ($player_parent $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'player'))
  4200.             {
  4201.                 if (isset($player_parent[0]['attribs']['']['url']))
  4202.                 {
  4203.                     $player_parent $this->sanitize($player_parent[0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  4204.                 }
  4205.             }
  4206.  
  4207.             // RATINGS
  4208.             if ($ratings $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'rating'))
  4209.             {
  4210.                 foreach ($ratings as $rating)
  4211.                 {
  4212.                     $rating_scheme null;
  4213.                     $rating_value null;
  4214.                     if (isset($rating['attribs']['']['scheme']))
  4215.                     {
  4216.                         $rating_scheme $this->sanitize($rating['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  4217.                     }
  4218.                     else
  4219.                     {
  4220.                         $rating_scheme 'urn:simple';
  4221.                     }
  4222.                     if (isset($rating['data']))
  4223.                     {
  4224.                         $rating_value $this->sanitize($rating['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4225.                     }
  4226.                     $ratings_parent[new $this->feed->rating_class($rating_scheme$rating_value);
  4227.                 }
  4228.             }
  4229.             elseif ($ratings $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES'explicit'))
  4230.             {
  4231.                 foreach ($ratings as $rating)
  4232.                 {
  4233.                     $rating_scheme 'urn:itunes';
  4234.                     $rating_value null;
  4235.                     if (isset($rating['data']))
  4236.                     {
  4237.                         $rating_value $this->sanitize($rating['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4238.                     }
  4239.                     $ratings_parent[new $this->feed->rating_class($rating_scheme$rating_value);
  4240.                 }
  4241.             }
  4242.             elseif ($ratings $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'rating'))
  4243.             {
  4244.                 foreach ($ratings as $rating)
  4245.                 {
  4246.                     $rating_scheme null;
  4247.                     $rating_value null;
  4248.                     if (isset($rating['attribs']['']['scheme']))
  4249.                     {
  4250.                         $rating_scheme $this->sanitize($rating['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  4251.                     }
  4252.                     else
  4253.                     {
  4254.                         $rating_scheme 'urn:simple';
  4255.                     }
  4256.                     if (isset($rating['data']))
  4257.                     {
  4258.                         $rating_value $this->sanitize($rating['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4259.                     }
  4260.                     $ratings_parent[new $this->feed->rating_class($rating_scheme$rating_value);
  4261.                 }
  4262.             }
  4263.             elseif ($ratings $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES'explicit'))
  4264.             {
  4265.                 foreach ($ratings as $rating)
  4266.                 {
  4267.                     $rating_scheme 'urn:itunes';
  4268.                     $rating_value null;
  4269.                     if (isset($rating['data']))
  4270.                     {
  4271.                         $rating_value $this->sanitize($rating['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4272.                     }
  4273.                     $ratings_parent[new $this->feed->rating_class($rating_scheme$rating_value);
  4274.                 }
  4275.             }
  4276.             if (is_array($ratings_parent))
  4277.             {
  4278.                 $ratings_parent array_values(SimplePie_Misc::array_unique($ratings_parent));
  4279.             }
  4280.  
  4281.             // RESTRICTIONS
  4282.             if ($restrictions $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'restriction'))
  4283.             {
  4284.                 foreach ($restrictions as $restriction)
  4285.                 {
  4286.                     $restriction_relationship null;
  4287.                     $restriction_type null;
  4288.                     $restriction_value null;
  4289.                     if (isset($restriction['attribs']['']['relationship']))
  4290.                     {
  4291.                         $restriction_relationship $this->sanitize($restriction['attribs']['']['relationship']SIMPLEPIE_CONSTRUCT_TEXT);
  4292.                     }
  4293.                     if (isset($restriction['attribs']['']['type']))
  4294.                     {
  4295.                         $restriction_type $this->sanitize($restriction['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  4296.                     }
  4297.                     if (isset($restriction['data']))
  4298.                     {
  4299.                         $restriction_value $this->sanitize($restriction['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4300.                     }
  4301.                     $restrictions_parent[new $this->feed->restriction_class($restriction_relationship$restriction_type$restriction_value);
  4302.                 }
  4303.             }
  4304.             elseif ($restrictions $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES'block'))
  4305.             {
  4306.                 foreach ($restrictions as $restriction)
  4307.                 {
  4308.                     $restriction_relationship 'allow';
  4309.                     $restriction_type null;
  4310.                     $restriction_value 'itunes';
  4311.                     if (isset($restriction['data']&& strtolower($restriction['data']=== 'yes')
  4312.                     {
  4313.                         $restriction_relationship 'deny';
  4314.                     }
  4315.                     $restrictions_parent[new $this->feed->restriction_class($restriction_relationship$restriction_type$restriction_value);
  4316.                 }
  4317.             }
  4318.             elseif ($restrictions $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'restriction'))
  4319.             {
  4320.                 foreach ($restrictions as $restriction)
  4321.                 {
  4322.                     $restriction_relationship null;
  4323.                     $restriction_type null;
  4324.                     $restriction_value null;
  4325.                     if (isset($restriction['attribs']['']['relationship']))
  4326.                     {
  4327.                         $restriction_relationship $this->sanitize($restriction['attribs']['']['relationship']SIMPLEPIE_CONSTRUCT_TEXT);
  4328.                     }
  4329.                     if (isset($restriction['attribs']['']['type']))
  4330.                     {
  4331.                         $restriction_type $this->sanitize($restriction['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  4332.                     }
  4333.                     if (isset($restriction['data']))
  4334.                     {
  4335.                         $restriction_value $this->sanitize($restriction['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4336.                     }
  4337.                     $restrictions_parent[new $this->feed->restriction_class($restriction_relationship$restriction_type$restriction_value);
  4338.                 }
  4339.             }
  4340.             elseif ($restrictions $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES'block'))
  4341.             {
  4342.                 foreach ($restrictions as $restriction)
  4343.                 {
  4344.                     $restriction_relationship 'allow';
  4345.                     $restriction_type null;
  4346.                     $restriction_value 'itunes';
  4347.                     if (isset($restriction['data']&& strtolower($restriction['data']=== 'yes')
  4348.                     {
  4349.                         $restriction_relationship 'deny';
  4350.                     }
  4351.                     $restrictions_parent[new $this->feed->restriction_class($restriction_relationship$restriction_type$restriction_value);
  4352.                 }
  4353.             }
  4354.             if (is_array($restrictions_parent))
  4355.             {
  4356.                 $restrictions_parent array_values(SimplePie_Misc::array_unique($restrictions_parent));
  4357.             }
  4358.  
  4359.             // THUMBNAILS
  4360.             if ($thumbnails $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'thumbnail'))
  4361.             {
  4362.                 foreach ($thumbnails as $thumbnail)
  4363.                 {
  4364.                     if (isset($thumbnail['attribs']['']['url']))
  4365.                     {
  4366.                         $thumbnails_parent[$this->sanitize($thumbnail['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  4367.                     }
  4368.                 }
  4369.             }
  4370.             elseif ($thumbnails $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'thumbnail'))
  4371.             {
  4372.                 foreach ($thumbnails as $thumbnail)
  4373.                 {
  4374.                     if (isset($thumbnail['attribs']['']['url']))
  4375.                     {
  4376.                         $thumbnails_parent[$this->sanitize($thumbnail['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  4377.                     }
  4378.                 }
  4379.             }
  4380.  
  4381.             // TITLES
  4382.             if ($title_parent $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'title'))
  4383.             {
  4384.                 if (isset($title_parent[0]['data']))
  4385.                 {
  4386.                     $title_parent $this->sanitize($title_parent[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4387.                 }
  4388.             }
  4389.             elseif ($title_parent $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'title'))
  4390.             {
  4391.                 if (isset($title_parent[0]['data']))
  4392.                 {
  4393.                     $title_parent $this->sanitize($title_parent[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4394.                 }
  4395.             }
  4396.  
  4397.             // Clear the memory
  4398.             unset($parent);
  4399.  
  4400.             // Attributes
  4401.             $bitrate null;
  4402.             $channels null;
  4403.             $duration null;
  4404.             $expression null;
  4405.             $framerate null;
  4406.             $height null;
  4407.             $javascript null;
  4408.             $lang null;
  4409.             $length null;
  4410.             $medium null;
  4411.             $samplingrate null;
  4412.             $type null;
  4413.             $url null;
  4414.             $width null;
  4415.  
  4416.             // Elements
  4417.             $captions null;
  4418.             $categories null;
  4419.             $copyrights null;
  4420.             $credits null;
  4421.             $description null;
  4422.             $hashes null;
  4423.             $keywords null;
  4424.             $player null;
  4425.             $ratings null;
  4426.             $restrictions null;
  4427.             $thumbnails null;
  4428.             $title null;
  4429.  
  4430.             // If we have media:group tags, loop through them.
  4431.             foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'group'as $group)
  4432.             {
  4433.                 // If we have media:content tags, loop through them.
  4434.                 foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'as $content)
  4435.                 {
  4436.                     if (isset($content['attribs']['']['url']))
  4437.                     {
  4438.                         // Attributes
  4439.                         $bitrate null;
  4440.                         $channels null;
  4441.                         $duration null;
  4442.                         $expression null;
  4443.                         $framerate null;
  4444.                         $height null;
  4445.                         $javascript null;
  4446.                         $lang null;
  4447.                         $length null;
  4448.                         $medium null;
  4449.                         $samplingrate null;
  4450.                         $type null;
  4451.                         $url null;
  4452.                         $width null;
  4453.  
  4454.                         // Elements
  4455.                         $captions null;
  4456.                         $categories null;
  4457.                         $copyrights null;
  4458.                         $credits null;
  4459.                         $description null;
  4460.                         $hashes null;
  4461.                         $keywords null;
  4462.                         $player null;
  4463.                         $ratings null;
  4464.                         $restrictions null;
  4465.                         $thumbnails null;
  4466.                         $title null;
  4467.  
  4468.                         // Start checking the attributes of media:content
  4469.                         if (isset($content['attribs']['']['bitrate']))
  4470.                         {
  4471.                             $bitrate $this->sanitize($content['attribs']['']['bitrate']SIMPLEPIE_CONSTRUCT_TEXT);
  4472.                         }
  4473.                         if (isset($content['attribs']['']['channels']))
  4474.                         {
  4475.                             $channels $this->sanitize($content['attribs']['']['channels']SIMPLEPIE_CONSTRUCT_TEXT);
  4476.                         }
  4477.                         if (isset($content['attribs']['']['duration']))
  4478.                         {
  4479.                             $duration $this->sanitize($content['attribs']['']['duration']SIMPLEPIE_CONSTRUCT_TEXT);
  4480.                         }
  4481.                         else
  4482.                         {
  4483.                             $duration $duration_parent;
  4484.                         }
  4485.                         if (isset($content['attribs']['']['expression']))
  4486.                         {
  4487.                             $expression $this->sanitize($content['attribs']['']['expression']SIMPLEPIE_CONSTRUCT_TEXT);
  4488.                         }
  4489.                         if (isset($content['attribs']['']['framerate']))
  4490.                         {
  4491.                             $framerate $this->sanitize($content['attribs']['']['framerate']SIMPLEPIE_CONSTRUCT_TEXT);
  4492.                         }
  4493.                         if (isset($content['attribs']['']['height']))
  4494.                         {
  4495.                             $height $this->sanitize($content['attribs']['']['height']SIMPLEPIE_CONSTRUCT_TEXT);
  4496.                         }
  4497.                         if (isset($content['attribs']['']['lang']))
  4498.                         {
  4499.                             $lang $this->sanitize($content['attribs']['']['lang']SIMPLEPIE_CONSTRUCT_TEXT);
  4500.                         }
  4501.                         if (isset($content['attribs']['']['fileSize']))
  4502.                         {
  4503.                             $length ceil($content['attribs']['']['fileSize']);
  4504.                         }
  4505.                         if (isset($content['attribs']['']['medium']))
  4506.                         {
  4507.                             $medium $this->sanitize($content['attribs']['']['medium']SIMPLEPIE_CONSTRUCT_TEXT);
  4508.                         }
  4509.                         if (isset($content['attribs']['']['samplingrate']))
  4510.                         {
  4511.                             $samplingrate $this->sanitize($content['attribs']['']['samplingrate']SIMPLEPIE_CONSTRUCT_TEXT);
  4512.                         }
  4513.                         if (isset($content['attribs']['']['type']))
  4514.                         {
  4515.                             $type $this->sanitize($content['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  4516.                         }
  4517.                         if (isset($content['attribs']['']['width']))
  4518.                         {
  4519.                             $width $this->sanitize($content['attribs']['']['width']SIMPLEPIE_CONSTRUCT_TEXT);
  4520.                         }
  4521.                         $url $this->sanitize($content['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  4522.  
  4523.                         // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
  4524.  
  4525.                         // CAPTIONS
  4526.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
  4527.                         {
  4528.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'as $caption)
  4529.                             {
  4530.                                 $caption_type null;
  4531.                                 $caption_lang null;
  4532.                                 $caption_startTime null;
  4533.                                 $caption_endTime null;
  4534.                                 $caption_text null;
  4535.                                 if (isset($caption['attribs']['']['type']))
  4536.                                 {
  4537.                                     $caption_type $this->sanitize($caption['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  4538.                                 }
  4539.                                 if (isset($caption['attribs']['']['lang']))
  4540.                                 {
  4541.                                     $caption_lang $this->sanitize($caption['attribs']['']['lang']SIMPLEPIE_CONSTRUCT_TEXT);
  4542.                                 }
  4543.                                 if (isset($caption['attribs']['']['start']))
  4544.                                 {
  4545.                                     $caption_startTime $this->sanitize($caption['attribs']['']['start']SIMPLEPIE_CONSTRUCT_TEXT);
  4546.                                 }
  4547.                                 if (isset($caption['attribs']['']['end']))
  4548.                                 {
  4549.                                     $caption_endTime $this->sanitize($caption['attribs']['']['end']SIMPLEPIE_CONSTRUCT_TEXT);
  4550.                                 }
  4551.                                 if (isset($caption['data']))
  4552.                                 {
  4553.                                     $caption_text $this->sanitize($caption['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4554.                                 }
  4555.                                 $captions[new $this->feed->caption_class($caption_type$caption_lang$caption_startTime$caption_endTime$caption_text);
  4556.                             }
  4557.                             if (is_array($captions))
  4558.                             {
  4559.                                 $captions array_values(SimplePie_Misc::array_unique($captions));
  4560.                             }
  4561.                         }
  4562.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
  4563.                         {
  4564.                             foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'as $caption)
  4565.                             {
  4566.                                 $caption_type null;
  4567.                                 $caption_lang null;
  4568.                                 $caption_startTime null;
  4569.                                 $caption_endTime null;
  4570.                                 $caption_text null;
  4571.                                 if (isset($caption['attribs']['']['type']))
  4572.                                 {
  4573.                                     $caption_type $this->sanitize($caption['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  4574.                                 }
  4575.                                 if (isset($caption['attribs']['']['lang']))
  4576.                                 {
  4577.                                     $caption_lang $this->sanitize($caption['attribs']['']['lang']SIMPLEPIE_CONSTRUCT_TEXT);
  4578.                                 }
  4579.                                 if (isset($caption['attribs']['']['start']))
  4580.                                 {
  4581.                                     $caption_startTime $this->sanitize($caption['attribs']['']['start']SIMPLEPIE_CONSTRUCT_TEXT);
  4582.                                 }
  4583.                                 if (isset($caption['attribs']['']['end']))
  4584.                                 {
  4585.                                     $caption_endTime $this->sanitize($caption['attribs']['']['end']SIMPLEPIE_CONSTRUCT_TEXT);
  4586.                                 }
  4587.                                 if (isset($caption['data']))
  4588.                                 {
  4589.                                     $caption_text $this->sanitize($caption['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4590.                                 }
  4591.                                 $captions[new $this->feed->caption_class($caption_type$caption_lang$caption_startTime$caption_endTime$caption_text);
  4592.                             }
  4593.                             if (is_array($captions))
  4594.                             {
  4595.                                 $captions array_values(SimplePie_Misc::array_unique($captions));
  4596.                             }
  4597.                         }
  4598.                         else
  4599.                         {
  4600.                             $captions $captions_parent;
  4601.                         }
  4602.  
  4603.                         // CATEGORIES
  4604.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
  4605.                         {
  4606.                             foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'as $category)
  4607.                             {
  4608.                                 $term null;
  4609.                                 $scheme null;
  4610.                                 $label null;
  4611.                                 if (isset($category['data']))
  4612.                                 {
  4613.                                     $term $this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4614.                                 }
  4615.                                 if (isset($category['attribs']['']['scheme']))
  4616.                                 {
  4617.                                     $scheme $this->sanitize($category['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  4618.                                 }
  4619.                                 else
  4620.                                 {
  4621.                                     $scheme 'http://search.yahoo.com/mrss/category_schema';
  4622.                                 }
  4623.                                 if (isset($category['attribs']['']['label']))
  4624.                                 {
  4625.                                     $label $this->sanitize($category['attribs']['']['label']SIMPLEPIE_CONSTRUCT_TEXT);
  4626.                                 }
  4627.                                 $categories[new $this->feed->category_class($term$scheme$label);
  4628.                             }
  4629.                         }
  4630.                         if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
  4631.                         {
  4632.                             foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'as $category)
  4633.                             {
  4634.                                 $term null;
  4635.                                 $scheme null;
  4636.                                 $label null;
  4637.                                 if (isset($category['data']))
  4638.                                 {
  4639.                                     $term $this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4640.                                 }
  4641.                                 if (isset($category['attribs']['']['scheme']))
  4642.                                 {
  4643.                                     $scheme $this->sanitize($category['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  4644.                                 }
  4645.                                 else
  4646.                                 {
  4647.                                     $scheme 'http://search.yahoo.com/mrss/category_schema';
  4648.                                 }
  4649.                                 if (isset($category['attribs']['']['label']))
  4650.                                 {
  4651.                                     $label $this->sanitize($category['attribs']['']['label']SIMPLEPIE_CONSTRUCT_TEXT);
  4652.                                 }
  4653.                                 $categories[new $this->feed->category_class($term$scheme$label);
  4654.                             }
  4655.                         }
  4656.                         if (is_array($categories&& is_array($categories_parent))
  4657.                         {
  4658.                             $categories array_values(SimplePie_Misc::array_unique(array_merge($categories$categories_parent)));
  4659.                         }
  4660.                         elseif (is_array($categories))
  4661.                         {
  4662.                             $categories array_values(SimplePie_Misc::array_unique($categories));
  4663.                         }
  4664.                         elseif (is_array($categories_parent))
  4665.                         {
  4666.                             $categories array_values(SimplePie_Misc::array_unique($categories_parent));
  4667.                         }
  4668.  
  4669.                         // COPYRIGHTS
  4670.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
  4671.                         {
  4672.                             $copyright_url null;
  4673.                             $copyright_label null;
  4674.                             if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
  4675.                             {
  4676.                                 $copyright_url $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_TEXT);
  4677.                             }
  4678.                             if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
  4679.                             {
  4680.                                 $copyright_label $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4681.                             }
  4682.                             $copyrights new $this->feed->copyright_class($copyright_url$copyright_label);
  4683.                         }
  4684.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
  4685.                         {
  4686.                             $copyright_url null;
  4687.                             $copyright_label null;
  4688.                             if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
  4689.                             {
  4690.                                 $copyright_url $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_TEXT);
  4691.                             }
  4692.                             if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
  4693.                             {
  4694.                                 $copyright_label $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4695.                             }
  4696.                             $copyrights new $this->feed->copyright_class($copyright_url$copyright_label);
  4697.                         }
  4698.                         else
  4699.                         {
  4700.                             $copyrights $copyrights_parent;
  4701.                         }
  4702.  
  4703.                         // CREDITS
  4704.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
  4705.                         {
  4706.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'as $credit)
  4707.                             {
  4708.                                 $credit_role null;
  4709.                                 $credit_scheme null;
  4710.                                 $credit_name null;
  4711.                                 if (isset($credit['attribs']['']['role']))
  4712.                                 {
  4713.                                     $credit_role $this->sanitize($credit['attribs']['']['role']SIMPLEPIE_CONSTRUCT_TEXT);
  4714.                                 }
  4715.                                 if (isset($credit['attribs']['']['scheme']))
  4716.                                 {
  4717.                                     $credit_scheme $this->sanitize($credit['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  4718.                                 }
  4719.                                 else
  4720.                                 {
  4721.                                     $credit_scheme 'urn:ebu';
  4722.                                 }
  4723.                                 if (isset($credit['data']))
  4724.                                 {
  4725.                                     $credit_name $this->sanitize($credit['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4726.                                 }
  4727.                                 $credits[new $this->feed->credit_class($credit_role$credit_scheme$credit_name);
  4728.                             }
  4729.                             if (is_array($credits))
  4730.                             {
  4731.                                 $credits array_values(SimplePie_Misc::array_unique($credits));
  4732.                             }
  4733.                         }
  4734.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
  4735.                         {
  4736.                             foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'as $credit)
  4737.                             {
  4738.                                 $credit_role null;
  4739.                                 $credit_scheme null;
  4740.                                 $credit_name null;
  4741.                                 if (isset($credit['attribs']['']['role']))
  4742.                                 {
  4743.                                     $credit_role $this->sanitize($credit['attribs']['']['role']SIMPLEPIE_CONSTRUCT_TEXT);
  4744.                                 }
  4745.                                 if (isset($credit['attribs']['']['scheme']))
  4746.                                 {
  4747.                                     $credit_scheme $this->sanitize($credit['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  4748.                                 }
  4749.                                 else
  4750.                                 {
  4751.                                     $credit_scheme 'urn:ebu';
  4752.                                 }
  4753.                                 if (isset($credit['data']))
  4754.                                 {
  4755.                                     $credit_name $this->sanitize($credit['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4756.                                 }
  4757.                                 $credits[new $this->feed->credit_class($credit_role$credit_scheme$credit_name);
  4758.                             }
  4759.                             if (is_array($credits))
  4760.                             {
  4761.                                 $credits array_values(SimplePie_Misc::array_unique($credits));
  4762.                             }
  4763.                         }
  4764.                         else
  4765.                         {
  4766.                             $credits $credits_parent;
  4767.                         }
  4768.  
  4769.                         // DESCRIPTION
  4770.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
  4771.                         {
  4772.                             $description $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4773.                         }
  4774.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
  4775.                         {
  4776.                             $description $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4777.                         }
  4778.                         else
  4779.                         {
  4780.                             $description $description_parent;
  4781.                         }
  4782.  
  4783.                         // HASHES
  4784.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
  4785.                         {
  4786.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'as $hash)
  4787.                             {
  4788.                                 $value null;
  4789.                                 $algo null;
  4790.                                 if (isset($hash['data']))
  4791.                                 {
  4792.                                     $value $this->sanitize($hash['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4793.                                 }
  4794.                                 if (isset($hash['attribs']['']['algo']))
  4795.                                 {
  4796.                                     $algo $this->sanitize($hash['attribs']['']['algo']SIMPLEPIE_CONSTRUCT_TEXT);
  4797.                                 }
  4798.                                 else
  4799.                                 {
  4800.                                     $algo 'md5';
  4801.                                 }
  4802.                                 $hashes[$algo.':'.$value;
  4803.                             }
  4804.                             if (is_array($hashes))
  4805.                             {
  4806.                                 $hashes array_values(SimplePie_Misc::array_unique($hashes));
  4807.                             }
  4808.                         }
  4809.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
  4810.                         {
  4811.                             foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'as $hash)
  4812.                             {
  4813.                                 $value null;
  4814.                                 $algo null;
  4815.                                 if (isset($hash['data']))
  4816.                                 {
  4817.                                     $value $this->sanitize($hash['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4818.                                 }
  4819.                                 if (isset($hash['attribs']['']['algo']))
  4820.                                 {
  4821.                                     $algo $this->sanitize($hash['attribs']['']['algo']SIMPLEPIE_CONSTRUCT_TEXT);
  4822.                                 }
  4823.                                 else
  4824.                                 {
  4825.                                     $algo 'md5';
  4826.                                 }
  4827.                                 $hashes[$algo.':'.$value;
  4828.                             }
  4829.                             if (is_array($hashes))
  4830.                             {
  4831.                                 $hashes array_values(SimplePie_Misc::array_unique($hashes));
  4832.                             }
  4833.                         }
  4834.                         else
  4835.                         {
  4836.                             $hashes $hashes_parent;
  4837.                         }
  4838.  
  4839.                         // KEYWORDS
  4840.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
  4841.                         {
  4842.                             if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
  4843.                             {
  4844.                                 $temp explode(','$this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT));
  4845.                                 foreach ($temp as $word)
  4846.                                 {
  4847.                                     $keywords[trim($word);
  4848.                                 }
  4849.                                 unset($temp);
  4850.                             }
  4851.                             if (is_array($keywords))
  4852.                             {
  4853.                                 $keywords array_values(SimplePie_Misc::array_unique($keywords));
  4854.                             }
  4855.                         }
  4856.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
  4857.                         {
  4858.                             if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
  4859.                             {
  4860.                                 $temp explode(','$this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT));
  4861.                                 foreach ($temp as $word)
  4862.                                 {
  4863.                                     $keywords[trim($word);
  4864.                                 }
  4865.                                 unset($temp);
  4866.                             }
  4867.                             if (is_array($keywords))
  4868.                             {
  4869.                                 $keywords array_values(SimplePie_Misc::array_unique($keywords));
  4870.                             }
  4871.                         }
  4872.                         else
  4873.                         {
  4874.                             $keywords $keywords_parent;
  4875.                         }
  4876.  
  4877.                         // PLAYER
  4878.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
  4879.                         {
  4880.                             $player $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  4881.                         }
  4882.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
  4883.                         {
  4884.                             $player $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  4885.                         }
  4886.                         else
  4887.                         {
  4888.                             $player $player_parent;
  4889.                         }
  4890.  
  4891.                         // RATINGS
  4892.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
  4893.                         {
  4894.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'as $rating)
  4895.                             {
  4896.                                 $rating_scheme null;
  4897.                                 $rating_value null;
  4898.                                 if (isset($rating['attribs']['']['scheme']))
  4899.                                 {
  4900.                                     $rating_scheme $this->sanitize($rating['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  4901.                                 }
  4902.                                 else
  4903.                                 {
  4904.                                     $rating_scheme 'urn:simple';
  4905.                                 }
  4906.                                 if (isset($rating['data']))
  4907.                                 {
  4908.                                     $rating_value $this->sanitize($rating['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4909.                                 }
  4910.                                 $ratings[new $this->feed->rating_class($rating_scheme$rating_value);
  4911.                             }
  4912.                             if (is_array($ratings))
  4913.                             {
  4914.                                 $ratings array_values(SimplePie_Misc::array_unique($ratings));
  4915.                             }
  4916.                         }
  4917.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
  4918.                         {
  4919.                             foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'as $rating)
  4920.                             {
  4921.                                 $rating_scheme null;
  4922.                                 $rating_value null;
  4923.                                 if (isset($rating['attribs']['']['scheme']))
  4924.                                 {
  4925.                                     $rating_scheme $this->sanitize($rating['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  4926.                                 }
  4927.                                 else
  4928.                                 {
  4929.                                     $rating_scheme 'urn:simple';
  4930.                                 }
  4931.                                 if (isset($rating['data']))
  4932.                                 {
  4933.                                     $rating_value $this->sanitize($rating['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4934.                                 }
  4935.                                 $ratings[new $this->feed->rating_class($rating_scheme$rating_value);
  4936.                             }
  4937.                             if (is_array($ratings))
  4938.                             {
  4939.                                 $ratings array_values(SimplePie_Misc::array_unique($ratings));
  4940.                             }
  4941.                         }
  4942.                         else
  4943.                         {
  4944.                             $ratings $ratings_parent;
  4945.                         }
  4946.  
  4947.                         // RESTRICTIONS
  4948.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
  4949.                         {
  4950.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'as $restriction)
  4951.                             {
  4952.                                 $restriction_relationship null;
  4953.                                 $restriction_type null;
  4954.                                 $restriction_value null;
  4955.                                 if (isset($restriction['attribs']['']['relationship']))
  4956.                                 {
  4957.                                     $restriction_relationship $this->sanitize($restriction['attribs']['']['relationship']SIMPLEPIE_CONSTRUCT_TEXT);
  4958.                                 }
  4959.                                 if (isset($restriction['attribs']['']['type']))
  4960.                                 {
  4961.                                     $restriction_type $this->sanitize($restriction['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  4962.                                 }
  4963.                                 if (isset($restriction['data']))
  4964.                                 {
  4965.                                     $restriction_value $this->sanitize($restriction['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4966.                                 }
  4967.                                 $restrictions[new $this->feed->restriction_class($restriction_relationship$restriction_type$restriction_value);
  4968.                             }
  4969.                             if (is_array($restrictions))
  4970.                             {
  4971.                                 $restrictions array_values(SimplePie_Misc::array_unique($restrictions));
  4972.                             }
  4973.                         }
  4974.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
  4975.                         {
  4976.                             foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'as $restriction)
  4977.                             {
  4978.                                 $restriction_relationship null;
  4979.                                 $restriction_type null;
  4980.                                 $restriction_value null;
  4981.                                 if (isset($restriction['attribs']['']['relationship']))
  4982.                                 {
  4983.                                     $restriction_relationship $this->sanitize($restriction['attribs']['']['relationship']SIMPLEPIE_CONSTRUCT_TEXT);
  4984.                                 }
  4985.                                 if (isset($restriction['attribs']['']['type']))
  4986.                                 {
  4987.                                     $restriction_type $this->sanitize($restriction['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  4988.                                 }
  4989.                                 if (isset($restriction['data']))
  4990.                                 {
  4991.                                     $restriction_value $this->sanitize($restriction['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4992.                                 }
  4993.                                 $restrictions[new $this->feed->restriction_class($restriction_relationship$restriction_type$restriction_value);
  4994.                             }
  4995.                             if (is_array($restrictions))
  4996.                             {
  4997.                                 $restrictions array_values(SimplePie_Misc::array_unique($restrictions));
  4998.                             }
  4999.                         }
  5000.                         else
  5001.                         {
  5002.                             $restrictions $restrictions_parent;
  5003.                         }
  5004.  
  5005.                         // THUMBNAILS
  5006.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
  5007.                         {
  5008.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'as $thumbnail)
  5009.                             {
  5010.                                 $thumbnails[$this->sanitize($thumbnail['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  5011.                             }
  5012.                             if (is_array($thumbnails))
  5013.                             {
  5014.                                 $thumbnails array_values(SimplePie_Misc::array_unique($thumbnails));
  5015.                             }
  5016.                         }
  5017.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
  5018.                         {
  5019.                             foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'as $thumbnail)
  5020.                             {
  5021.                                 $thumbnails[$this->sanitize($thumbnail['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  5022.                             }
  5023.                             if (is_array($thumbnails))
  5024.                             {
  5025.                                 $thumbnails array_values(SimplePie_Misc::array_unique($thumbnails));
  5026.                             }
  5027.                         }
  5028.                         else
  5029.                         {
  5030.                             $thumbnails $thumbnails_parent;
  5031.                         }
  5032.  
  5033.                         // TITLES
  5034.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
  5035.                         {
  5036.                             $title $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5037.                         }
  5038.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
  5039.                         {
  5040.                             $title $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5041.                         }
  5042.                         else
  5043.                         {
  5044.                             $title $title_parent;
  5045.                         }
  5046.  
  5047.                         $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);
  5048.                     }
  5049.                 }
  5050.             }
  5051.  
  5052.             // If we have standalone media:content tags, loop through them.
  5053.             if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
  5054.             {
  5055.                 foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'as $content)
  5056.                 {
  5057.                     if (isset($content['attribs']['']['url']))
  5058.                     {
  5059.                         // Attributes
  5060.                         $bitrate null;
  5061.                         $channels null;
  5062.                         $duration null;
  5063.                         $expression null;
  5064.                         $framerate null;
  5065.                         $height null;
  5066.                         $javascript null;
  5067.                         $lang null;
  5068.                         $length null;
  5069.                         $medium null;
  5070.                         $samplingrate null;
  5071.                         $type null;
  5072.                         $url null;
  5073.                         $width null;
  5074.  
  5075.                         // Elements
  5076.                         $captions null;
  5077.                         $categories null;
  5078.                         $copyrights null;
  5079.                         $credits null;
  5080.                         $description null;
  5081.                         $hashes null;
  5082.                         $keywords null;
  5083.                         $player null;
  5084.                         $ratings null;
  5085.                         $restrictions null;
  5086.                         $thumbnails null;
  5087.                         $title null;
  5088.  
  5089.                         // Start checking the attributes of media:content
  5090.                         if (isset($content['attribs']['']['bitrate']))
  5091.                         {
  5092.                             $bitrate $this->sanitize($content['attribs']['']['bitrate']SIMPLEPIE_CONSTRUCT_TEXT);
  5093.                         }
  5094.                         if (isset($content['attribs']['']['channels']))
  5095.                         {
  5096.                             $channels $this->sanitize($content['attribs']['']['channels']SIMPLEPIE_CONSTRUCT_TEXT);
  5097.                         }
  5098.                         if (isset($content['attribs']['']['duration']))
  5099.                         {
  5100.                             $duration $this->sanitize($content['attribs']['']['duration']SIMPLEPIE_CONSTRUCT_TEXT);
  5101.                         }
  5102.                         else
  5103.                         {
  5104.                             $duration $duration_parent;
  5105.                         }
  5106.                         if (isset($content['attribs']['']['expression']))
  5107.                         {
  5108.                             $expression $this->sanitize($content['attribs']['']['expression']SIMPLEPIE_CONSTRUCT_TEXT);
  5109.                         }
  5110.                         if (isset($content['attribs']['']['framerate']))
  5111.                         {
  5112.                             $framerate $this->sanitize($content['attribs']['']['framerate']SIMPLEPIE_CONSTRUCT_TEXT);
  5113.                         }
  5114.                         if (isset($content['attribs']['']['height']))
  5115.                         {
  5116.                             $height $this->sanitize($content['attribs']['']['height']SIMPLEPIE_CONSTRUCT_TEXT);
  5117.                         }
  5118.                         if (isset($content['attribs']['']['lang']))
  5119.                         {
  5120.                             $lang $this->sanitize($content['attribs']['']['lang']SIMPLEPIE_CONSTRUCT_TEXT);
  5121.                         }
  5122.                         if (isset($content['attribs']['']['fileSize']))
  5123.                         {
  5124.                             $length ceil($content['attribs']['']['fileSize']);
  5125.                         }
  5126.                         if (isset($content['attribs']['']['medium']))
  5127.                         {
  5128.                             $medium $this->sanitize($content['attribs']['']['medium']SIMPLEPIE_CONSTRUCT_TEXT);
  5129.                         }
  5130.                         if (isset($content['attribs']['']['samplingrate']))
  5131.                         {
  5132.                             $samplingrate $this->sanitize($content['attribs']['']['samplingrate']SIMPLEPIE_CONSTRUCT_TEXT);
  5133.                         }
  5134.                         if (isset($content['attribs']['']['type']))
  5135.                         {
  5136.                             $type $this->sanitize($content['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  5137.                         }
  5138.                         if (isset($content['attribs']['']['width']))
  5139.                         {
  5140.                             $width $this->sanitize($content['attribs']['']['width']SIMPLEPIE_CONSTRUCT_TEXT);
  5141.                         }
  5142.                         $url $this->sanitize($content['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  5143.  
  5144.                         // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
  5145.  
  5146.                         // CAPTIONS
  5147.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
  5148.                         {
  5149.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'as $caption)
  5150.                             {
  5151.                                 $caption_type null;
  5152.                                 $caption_lang null;
  5153.                                 $caption_startTime null;
  5154.                                 $caption_endTime null;
  5155.                                 $caption_text null;
  5156.                                 if (isset($caption['attribs']['']['type']))
  5157.                                 {
  5158.                                     $caption_type $this->sanitize($caption['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  5159.                                 }
  5160.                                 if (isset($caption['attribs']['']['lang']))
  5161.                                 {
  5162.                                     $caption_lang $this->sanitize($caption['attribs']['']['lang']SIMPLEPIE_CONSTRUCT_TEXT);
  5163.                                 }
  5164.                                 if (isset($caption['attribs']['']['start']))
  5165.                                 {
  5166.                                     $caption_startTime $this->sanitize($caption['attribs']['']['start']SIMPLEPIE_CONSTRUCT_TEXT);
  5167.                                 }
  5168.                                 if (isset($caption['attribs']['']['end']))
  5169.                                 {
  5170.                                     $caption_endTime $this->sanitize($caption['attribs']['']['end']SIMPLEPIE_CONSTRUCT_TEXT);
  5171.                                 }
  5172.                                 if (isset($caption['data']))
  5173.                                 {
  5174.                                     $caption_text $this->sanitize($caption['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5175.                                 }
  5176.                                 $captions[new $this->feed->caption_class($caption_type$caption_lang$caption_startTime$caption_endTime$caption_text);
  5177.                             }
  5178.                             if (is_array($captions))
  5179.                             {
  5180.                                 $captions array_values(SimplePie_Misc::array_unique($captions));
  5181.                             }
  5182.                         }
  5183.                         else
  5184.                         {
  5185.                             $captions $captions_parent;
  5186.                         }
  5187.  
  5188.                         // CATEGORIES
  5189.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
  5190.                         {
  5191.                             foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'as $category)
  5192.                             {
  5193.                                 $term null;
  5194.                                 $scheme null;
  5195.                                 $label null;
  5196.                                 if (isset($category['data']))
  5197.                                 {
  5198.                                     $term $this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5199.                                 }
  5200.                                 if (isset($category['attribs']['']['scheme']))
  5201.                                 {
  5202.                                     $scheme $this->sanitize($category['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  5203.                                 }
  5204.                                 else
  5205.                                 {
  5206.                                     $scheme 'http://search.yahoo.com/mrss/category_schema';
  5207.                                 }
  5208.                                 if (isset($category['attribs']['']['label']))
  5209.                                 {
  5210.                                     $label $this->sanitize($category['attribs']['']['label']SIMPLEPIE_CONSTRUCT_TEXT);
  5211.                                 }
  5212.                                 $categories[new $this->feed->category_class($term$scheme$label);
  5213.                             }
  5214.                         }
  5215.                         if (is_array($categories&& is_array($categories_parent))
  5216.                         {
  5217.                             $categories array_values(SimplePie_Misc::array_unique(array_merge($categories$categories_parent)));
  5218.                         }
  5219.                         elseif (is_array($categories))
  5220.                         {
  5221.                             $categories array_values(SimplePie_Misc::array_unique($categories));
  5222.                         }
  5223.                         elseif (is_array($categories_parent))
  5224.                         {
  5225.                             $categories array_values(SimplePie_Misc::array_unique($categories_parent));
  5226.                         }
  5227.                         else
  5228.                         {
  5229.                             $categories null;
  5230.                         }
  5231.  
  5232.                         // COPYRIGHTS
  5233.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
  5234.                         {
  5235.                             $copyright_url null;
  5236.                             $copyright_label null;
  5237.                             if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
  5238.                             {
  5239.                                 $copyright_url $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_TEXT);
  5240.                             }
  5241.                             if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
  5242.                             {
  5243.                                 $copyright_label $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5244.                             }
  5245.                             $copyrights new $this->feed->copyright_class($copyright_url$copyright_label);
  5246.                         }
  5247.                         else
  5248.                         {
  5249.                             $copyrights $copyrights_parent;
  5250.                         }
  5251.  
  5252.                         // CREDITS
  5253.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
  5254.                         {
  5255.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'as $credit)
  5256.                             {
  5257.                                 $credit_role null;
  5258.                                 $credit_scheme null;
  5259.                                 $credit_name null;
  5260.                                 if (isset($credit['attribs']['']['role']))
  5261.                                 {
  5262.                                     $credit_role $this->sanitize($credit['attribs']['']['role']SIMPLEPIE_CONSTRUCT_TEXT);
  5263.                                 }
  5264.                                 if (isset($credit['attribs']['']['scheme']))
  5265.                                 {
  5266.                                     $credit_scheme $this->sanitize($credit['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  5267.                                 }
  5268.                                 else
  5269.                                 {
  5270.                                     $credit_scheme 'urn:ebu';
  5271.                                 }
  5272.                                 if (isset($credit['data']))
  5273.                                 {
  5274.                                     $credit_name $this->sanitize($credit['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5275.                                 }
  5276.                                 $credits[new $this->feed->credit_class($credit_role$credit_scheme$credit_name);
  5277.                             }
  5278.                             if (is_array($credits))
  5279.                             {
  5280.                                 $credits array_values(SimplePie_Misc::array_unique($credits));
  5281.                             }
  5282.                         }
  5283.                         else
  5284.                         {
  5285.                             $credits $credits_parent;
  5286.                         }
  5287.  
  5288.                         // DESCRIPTION
  5289.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
  5290.                         {
  5291.                             $description $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5292.                         }
  5293.                         else
  5294.                         {
  5295.                             $description $description_parent;
  5296.                         }
  5297.  
  5298.                         // HASHES
  5299.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
  5300.                         {
  5301.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'as $hash)
  5302.                             {
  5303.                                 $value null;
  5304.                                 $algo null;
  5305.                                 if (isset($hash['data']))
  5306.                                 {
  5307.                                     $value $this->sanitize($hash['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5308.                                 }
  5309.                                 if (isset($hash['attribs']['']['algo']))
  5310.                                 {
  5311.                                     $algo $this->sanitize($hash['attribs']['']['algo']SIMPLEPIE_CONSTRUCT_TEXT);
  5312.                                 }
  5313.                                 else
  5314.                                 {
  5315.                                     $algo 'md5';
  5316.                                 }
  5317.                                 $hashes[$algo.':'.$value;
  5318.                             }
  5319.                             if (is_array($hashes))
  5320.                             {
  5321.                                 $hashes array_values(SimplePie_Misc::array_unique($hashes));
  5322.                             }
  5323.                         }
  5324.                         else
  5325.                         {
  5326.                             $hashes $hashes_parent;
  5327.                         }
  5328.  
  5329.                         // KEYWORDS
  5330.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
  5331.                         {
  5332.                             if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
  5333.                             {
  5334.                                 $temp explode(','$this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT));
  5335.                                 foreach ($temp as $word)
  5336.                                 {
  5337.                                     $keywords[trim($word);
  5338.                                 }
  5339.                                 unset($temp);
  5340.                             }
  5341.                             if (is_array($keywords))
  5342.                             {
  5343.                                 $keywords array_values(SimplePie_Misc::array_unique($keywords));
  5344.                             }
  5345.                         }
  5346.                         else
  5347.                         {
  5348.                             $keywords $keywords_parent;
  5349.                         }
  5350.  
  5351.                         // PLAYER
  5352.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
  5353.                         {
  5354.                             $player $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  5355.                         }
  5356.                         else
  5357.                         {
  5358.                             $player $player_parent;
  5359.                         }
  5360.  
  5361.                         // RATINGS
  5362.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
  5363.                         {
  5364.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'as $rating)
  5365.                             {
  5366.                                 $rating_scheme null;
  5367.                                 $rating_value null;
  5368.                                 if (isset($rating['attribs']['']['scheme']))
  5369.                                 {
  5370.                                     $rating_scheme $this->sanitize($rating['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  5371.                                 }
  5372.                                 else
  5373.                                 {
  5374.                                     $rating_scheme 'urn:simple';
  5375.                                 }
  5376.                                 if (isset($rating['data']))
  5377.                                 {
  5378.                                     $rating_value $this->sanitize($rating['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5379.                                 }
  5380.                                 $ratings[new $this->feed->rating_class($rating_scheme$rating_value);
  5381.                             }
  5382.                             if (is_array($ratings))
  5383.                             {
  5384.                                 $ratings array_values(SimplePie_Misc::array_unique($ratings));
  5385.                             }
  5386.                         }
  5387.                         else
  5388.                         {
  5389.                             $ratings $ratings_parent;
  5390.                         }
  5391.  
  5392.                         // RESTRICTIONS
  5393.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
  5394.                         {
  5395.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'as $restriction)
  5396.                             {
  5397.                                 $restriction_relationship null;
  5398.                                 $restriction_type null;
  5399.                                 $restriction_value null;
  5400.                                 if (isset($restriction['attribs']['']['relationship']))
  5401.                                 {
  5402.                                     $restriction_relationship $this->sanitize($restriction['attribs']['']['relationship']SIMPLEPIE_CONSTRUCT_TEXT);
  5403.                                 }
  5404.                                 if (isset($restriction['attribs']['']['type']))
  5405.                                 {
  5406.                                     $restriction_type $this->sanitize($restriction['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  5407.                                 }
  5408.                                 if (isset($restriction['data']))
  5409.                                 {
  5410.                                     $restriction_value $this->sanitize($restriction['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5411.                                 }
  5412.                                 $restrictions[new $this->feed->restriction_class($restriction_relationship$restriction_type$restriction_value);
  5413.                             }
  5414.                             if (is_array($restrictions))
  5415.                             {
  5416.                                 $restrictions array_values(SimplePie_Misc::array_unique($restrictions));
  5417.                             }
  5418.                         }
  5419.                         else
  5420.                         {
  5421.                             $restrictions $restrictions_parent;
  5422.                         }
  5423.  
  5424.                         // THUMBNAILS
  5425.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
  5426.                         {
  5427.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'as $thumbnail)
  5428.                             {
  5429.                                 $thumbnails[$this->sanitize($thumbnail['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  5430.                             }
  5431.                             if (is_array($thumbnails))
  5432.                             {
  5433.                                 $thumbnails array_values(SimplePie_Misc::array_unique($thumbnails));
  5434.                             }
  5435.                         }
  5436.                         else
  5437.                         {
  5438.                             $thumbnails $thumbnails_parent;
  5439.                         }
  5440.  
  5441.                         // TITLES
  5442.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
  5443.                         {
  5444.                             $title $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5445.                         }
  5446.                         else
  5447.                         {
  5448.                             $title $title_parent;
  5449.                         }
  5450.  
  5451.                         $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);
  5452.                     }
  5453.                 }
  5454.             }
  5455.  
  5456.             foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'link'as $link)
  5457.             {
  5458.                 if (isset($link['attribs']['']['href']&& !empty($link['attribs']['']['rel']&& $link['attribs']['']['rel'=== 'enclosure')
  5459.                 {
  5460.                     // Attributes
  5461.                     $bitrate null;
  5462.                     $channels null;
  5463.                     $duration null;
  5464.                     $expression null;
  5465.                     $framerate null;
  5466.                     $height null;
  5467.                     $javascript null;
  5468.                     $lang null;
  5469.                     $length null;
  5470.                     $medium null;
  5471.                     $samplingrate null;
  5472.                     $type null;
  5473.                     $url null;
  5474.                     $width null;
  5475.  
  5476.                     $url $this->sanitize($link['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($link));
  5477.                     if (isset($link['attribs']['']['type']))
  5478.                     {
  5479.                         $type $this->sanitize($link['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  5480.                     }
  5481.                     if (isset($link['attribs']['']['length']))
  5482.                     {
  5483.                         $length ceil($link['attribs']['']['length']);
  5484.                     }
  5485.  
  5486.                     // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
  5487.                     $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);
  5488.                 }
  5489.             }
  5490.  
  5491.             foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'link'as $link)
  5492.             {
  5493.                 if (isset($link['attribs']['']['href']&& !empty($link['attribs']['']['rel']&& $link['attribs']['']['rel'=== 'enclosure')
  5494.                 {
  5495.                     // Attributes
  5496.                     $bitrate null;
  5497.                     $channels null;
  5498.                     $duration null;
  5499.                     $expression null;
  5500.                     $framerate null;
  5501.                     $height null;
  5502.                     $javascript null;
  5503.                     $lang null;
  5504.                     $length null;
  5505.                     $medium null;
  5506.                     $samplingrate null;
  5507.                     $type null;
  5508.                     $url null;
  5509.                     $width null;
  5510.  
  5511.                     $url $this->sanitize($link['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($link));
  5512.                     if (isset($link['attribs']['']['type']))
  5513.                     {
  5514.                         $type $this->sanitize($link['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  5515.                     }
  5516.                     if (isset($link['attribs']['']['length']))
  5517.                     {
  5518.                         $length ceil($link['attribs']['']['length']);
  5519.                     }
  5520.  
  5521.                     // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
  5522.                     $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);
  5523.                 }
  5524.             }
  5525.  
  5526.             if ($enclosure $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20'enclosure'))
  5527.             {
  5528.                 if (isset($enclosure[0]['attribs']['']['url']))
  5529.                 {
  5530.                     // Attributes
  5531.                     $bitrate null;
  5532.                     $channels null;
  5533.                     $duration null;
  5534.                     $expression null;
  5535.                     $framerate null;
  5536.                     $height null;
  5537.                     $javascript null;
  5538.                     $lang null;
  5539.                     $length null;
  5540.                     $medium null;
  5541.                     $samplingrate null;
  5542.                     $type null;
  5543.                     $url null;
  5544.                     $width null;
  5545.  
  5546.                     $url $this->sanitize($enclosure[0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($enclosure[0]));
  5547.                     if (isset($enclosure[0]['attribs']['']['type']))
  5548.                     {
  5549.                         $type $this->sanitize($enclosure[0]['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  5550.                     }
  5551.                     if (isset($enclosure[0]['attribs']['']['length']))
  5552.                     {
  5553.                         $length ceil($enclosure[0]['attribs']['']['length']);
  5554.                     }
  5555.  
  5556.                     // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
  5557.                     $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);
  5558.                 }
  5559.             }
  5560.  
  5561.             if (sizeof($this->data['enclosures']=== && ($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))
  5562.             {
  5563.                 // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
  5564.                 $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);
  5565.             }
  5566.  
  5567.             $this->data['enclosures'array_values(SimplePie_Misc::array_unique($this->data['enclosures']));
  5568.         }
  5569.         if (!empty($this->data['enclosures']))
  5570.         {
  5571.             return $this->data['enclosures'];
  5572.         }
  5573.         else
  5574.         {
  5575.             return null;
  5576.         }
  5577.     }
  5578.  
  5579.     function get_latitude()
  5580.     {
  5581.         if ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO'lat'))
  5582.         {
  5583.             return (float) $return[0]['data'];
  5584.         }
  5585.         elseif (($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/'$return[0]['data']$match))
  5586.         {
  5587.             return (float) $match[1];
  5588.         }
  5589.         else
  5590.         {
  5591.             return null;
  5592.         }
  5593.     }
  5594.  
  5595.     function get_longitude()
  5596.     {
  5597.         if ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO'long'))
  5598.         {
  5599.             return (float) $return[0]['data'];
  5600.         }
  5601.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO'lon'))
  5602.         {
  5603.             return (float) $return[0]['data'];
  5604.         }
  5605.         elseif (($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/'$return[0]['data']$match))
  5606.         {
  5607.             return (float) $match[2];
  5608.         }
  5609.         else
  5610.         {
  5611.             return null;
  5612.         }
  5613.     }
  5614.  
  5615.     function get_source()
  5616.     {
  5617.         if ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'source'))
  5618.         {
  5619.             return new $this->feed->source_class($this$return[0]);
  5620.         }
  5621.         else
  5622.         {
  5623.             return null;
  5624.         }
  5625.     }
  5626.  
  5627.     /**
  5628.      * Creates the add_to_* methods' return data
  5629.      *
  5630.      * @access private
  5631.      * @param string $item_url String to prefix to the item permalink
  5632.      * @param string $title_url String to prefix to the item title
  5633.      *  (and suffix to the item permalink)
  5634.      * @return mixed URL if feed exists, false otherwise
  5635.      */
  5636.     function add_to_service($item_url$title_url null$summary_url null)
  5637.     {
  5638.         if ($this->get_permalink(!== null)
  5639.         {
  5640.             $return $item_url rawurlencode($this->get_permalink());
  5641.             if ($title_url !== null && $this->get_title(!== null)
  5642.             {
  5643.                 $return .= $title_url rawurlencode($this->get_title());
  5644.             }
  5645.             if ($summary_url !== null && $this->get_description(!== null)
  5646.             {
  5647.                 $return .= $summary_url rawurlencode($this->get_description());
  5648.             }
  5649.             return $this->sanitize($returnSIMPLEPIE_CONSTRUCT_IRI);
  5650.         }
  5651.         else
  5652.         {
  5653.             return null;
  5654.         }
  5655.     }
  5656.  
  5657.     function add_to_blinklist()
  5658.     {
  5659.         return $this->add_to_service('http://www.blinklist.com/index.php?Action=Blink/addblink.php&Description=&Url=''&Title=');
  5660.     }
  5661.  
  5662.     function add_to_blogmarks()
  5663.     {
  5664.         return $this->add_to_service('http://blogmarks.net/my/new.php?mini=1&simple=1&url=''&title=');
  5665.     }
  5666.  
  5667.     function add_to_delicious()
  5668.     {
  5669.         return $this->add_to_service('http://del.icio.us/post/?v=4&url=''&title=');
  5670.     }
  5671.  
  5672.     function add_to_digg()
  5673.     {
  5674.         return $this->add_to_service('http://digg.com/submit?url=''&title=''&bodytext=');
  5675.     }
  5676.  
  5677.     function add_to_furl()
  5678.     {
  5679.         return $this->add_to_service('http://www.furl.net/storeIt.jsp?u=''&t=');
  5680.     }
  5681.  
  5682.     function add_to_magnolia()
  5683.     {
  5684.         return $this->add_to_service('http://ma.gnolia.com/bookmarklet/add?url=''&title=');
  5685.     }
  5686.  
  5687.     function add_to_myweb20()
  5688.     {
  5689.         return $this->add_to_service('http://myweb2.search.yahoo.com/myresults/bookmarklet?u=''&t=');
  5690.     }
  5691.  
  5692.     function add_to_newsvine()
  5693.     {
  5694.         return $this->add_to_service('http://www.newsvine.com/_wine/save?u=''&h=');
  5695.     }
  5696.  
  5697.     function add_to_reddit()
  5698.     {
  5699.         return $this->add_to_service('http://reddit.com/submit?url=''&title=');
  5700.     }
  5701.  
  5702.     function add_to_segnalo()
  5703.     {
  5704.         return $this->add_to_service('http://segnalo.com/post.html.php?url=''&title=');
  5705.     }
  5706.  
  5707.     function add_to_simpy()
  5708.     {
  5709.         return $this->add_to_service('http://www.simpy.com/simpy/LinkAdd.do?href=''&title=');
  5710.     }
  5711.  
  5712.     function add_to_spurl()
  5713.     {
  5714.         return $this->add_to_service('http://www.spurl.net/spurl.php?v=3&url=''&title=');
  5715.     }
  5716.  
  5717.     function add_to_wists()
  5718.     {
  5719.         return $this->add_to_service('http://wists.com/r.php?c=&r=''&title=');
  5720.     }
  5721.  
  5722.     function search_technorati()
  5723.     {
  5724.         return $this->add_to_service('http://www.technorati.com/search/');
  5725.     }
  5726. }
  5727.  
  5728. {
  5729.     var $item;
  5730.     var $data = array();
  5731.  
  5732.     function SimplePie_Source($item$data)
  5733.     {
  5734.         $this->item = $item;
  5735.         $this->data = $data;
  5736.     }
  5737.  
  5738.     function __toString()
  5739.     {
  5740.         return md5(serialize($this->data));
  5741.     }
  5742.  
  5743.     function get_source_tags($namespace$tag)
  5744.     {
  5745.         if (isset($this->data['child'][$namespace][$tag]))
  5746.         {
  5747.             return $this->data['child'][$namespace][$tag];
  5748.         }
  5749.         else
  5750.         {
  5751.             return null;
  5752.         }
  5753.     }
  5754.  
  5755.     function get_base($element array())
  5756.     {
  5757.         return $this->item->get_base($element);
  5758.     }
  5759.  
  5760.     function sanitize($data$type$base '')
  5761.     {
  5762.         return $this->item->sanitize($data$type$base);
  5763.     }
  5764.  
  5765.     function get_item()
  5766.     {
  5767.         return $this->item;
  5768.     }
  5769.  
  5770.     function get_title()
  5771.     {
  5772.         if ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10'title'))
  5773.         {
  5774.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_10_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  5775.         }
  5776.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03'title'))
  5777.         {
  5778.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_03_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  5779.         }
  5780.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10'title'))
  5781.         {
  5782.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  5783.         }
  5784.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090'title'))
  5785.         {
  5786.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  5787.         }
  5788.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20'title'))
  5789.         {
  5790.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  5791.         }
  5792.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11'title'))
  5793.         {
  5794.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5795.         }
  5796.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10'title'))
  5797.         {
  5798.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5799.         }
  5800.         else
  5801.         {
  5802.             return null;
  5803.         }
  5804.     }
  5805.  
  5806.     function get_category($key 0)
  5807.     {
  5808.         $categories $this->get_categories();
  5809.         if (isset($categories[$key]))
  5810.         {
  5811.             return $categories[$key];
  5812.         }
  5813.         else
  5814.         {
  5815.             return null;
  5816.         }
  5817.     }
  5818.  
  5819.     function get_categories()
  5820.     {
  5821.         $categories array();
  5822.  
  5823.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10'category'as $category)
  5824.         {
  5825.             $term null;
  5826.             $scheme null;
  5827.             $label null;
  5828.             if (isset($category['attribs']['']['term']))
  5829.             {
  5830.                 $term $this->sanitize($category['attribs']['']['term']SIMPLEPIE_CONSTRUCT_TEXT);
  5831.             }
  5832.             if (isset($category['attribs']['']['scheme']))
  5833.             {
  5834.                 $scheme $this->sanitize($category['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  5835.             }
  5836.             if (isset($category['attribs']['']['label']))
  5837.             {
  5838.                 $label $this->sanitize($category['attribs']['']['label']SIMPLEPIE_CONSTRUCT_TEXT);
  5839.             }
  5840.             $categories[new $this->item->feed->category_class($term$scheme$label);
  5841.         }
  5842.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20'category'as $category)
  5843.         {
  5844.             // This is really the label, but keep this as the term also for BC.
  5845.             // Label will also work on retrieving because that falls back to term.
  5846.             $term $this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5847.             if (isset($category['attribs']['']['domain']))
  5848.             {
  5849.                 $scheme $this->sanitize($category['attribs']['']['domain']SIMPLEPIE_CONSTRUCT_TEXT);
  5850.             }
  5851.             else
  5852.             {
  5853.                 $scheme null;
  5854.             }
  5855.             $categories[new $this->item->feed->category_class($term$schemenull);
  5856.         }
  5857.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11'subject'as $category)
  5858.         {
  5859.             $categories[new $this->item->feed->category_class($this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  5860.         }
  5861.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10'subject'as $category)
  5862.         {
  5863.             $categories[new $this->item->feed->category_class($this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  5864.         }
  5865.  
  5866.         if (!empty($categories))
  5867.         {
  5868.             return SimplePie_Misc::array_unique($categories);
  5869.         }
  5870.         else
  5871.         {
  5872.             return null;
  5873.         }
  5874.     }
  5875.  
  5876.     function get_author($key 0)
  5877.     {
  5878.         $authors $this->get_authors();
  5879.         if (isset($authors[$key]))
  5880.         {
  5881.             return $authors[$key];
  5882.         }
  5883.         else
  5884.         {
  5885.             return null;
  5886.         }
  5887.     }
  5888.  
  5889.     function get_authors()
  5890.     {
  5891.         $authors array();
  5892.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10'author'as $author)
  5893.         {
  5894.             $name null;
  5895.             $uri null;
  5896.             $email null;
  5897.             if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
  5898.             {
  5899.                 $name $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5900.             }
  5901.             if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
  5902.             {
  5903.                 $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.             }
  5905.             if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
  5906.             {
  5907.                 $email $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5908.             }
  5909.             if ($name !== null || $email !== null || $uri !== null)
  5910.             {
  5911.                 $authors[new $this->item->feed->author_class($name$uri$email);
  5912.             }
  5913.         }
  5914.         if ($author $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03'author'))
  5915.         {
  5916.             $name null;
  5917.             $url null;
  5918.             $email null;
  5919.             if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
  5920.             {
  5921.                 $name $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5922.             }
  5923.             if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
  5924.             {
  5925.                 $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.             }
  5927.             if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
  5928.             {
  5929.                 $email $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5930.             }
  5931.             if ($name !== null || $email !== null || $url !== null)
  5932.             {
  5933.                 $authors[new $this->item->feed->author_class($name$url$email);
  5934.             }
  5935.         }
  5936.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11'creator'as $author)
  5937.         {
  5938.             $authors[new $this->item->feed->author_class($this->sanitize($author['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  5939.         }
  5940.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10'creator'as $author)
  5941.         {
  5942.             $authors[new $this->item->feed->author_class($this->sanitize($author['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  5943.         }
  5944.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES'author'as $author)
  5945.         {
  5946.             $authors[new $this->item->feed->author_class($this->sanitize($author['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  5947.         }
  5948.  
  5949.         if (!empty($authors))
  5950.         {
  5951.             return SimplePie_Misc::array_unique($authors);
  5952.         }
  5953.         else
  5954.         {
  5955.             return null;
  5956.         }
  5957.     }
  5958.  
  5959.     function get_contributor($key 0)
  5960.     {
  5961.         $contributors $this->get_contributors();
  5962.         if (isset($contributors[$key]))
  5963.         {
  5964.             return $contributors[$key];
  5965.         }
  5966.         else
  5967.         {
  5968.             return null;
  5969.         }
  5970.     }
  5971.  
  5972.     function get_contributors()
  5973.     {
  5974.         $contributors array();
  5975.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10'contributor'as $contributor)
  5976.         {
  5977.             $name null;
  5978.             $uri null;
  5979.             $email null;
  5980.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
  5981.             {
  5982.                 $name $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5983.             }
  5984.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
  5985.             {
  5986.                 $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.             }
  5988.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
  5989.             {
  5990.                 $email $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5991.             }
  5992.             if ($name !== null || $email !== null || $uri !== null)
  5993.             {
  5994.                 $contributors[new $this->item->feed->author_class($name$uri$email);
  5995.             }
  5996.         }
  5997.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03'contributor'as $contributor)
  5998.         {
  5999.             $name null;
  6000.             $url null;
  6001.             $email null;
  6002.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
  6003.             {
  6004.                 $name $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  6005.             }
  6006.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
  6007.             {
  6008.                 $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.             }
  6010.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
  6011.             {
  6012.                 $email $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  6013.             }
  6014.             if ($name !== null || $email !== null || $url !== null)
  6015.             {
  6016.                 $contributors[new $this->item->feed->author_class($name$url$email);
  6017.             }
  6018.         }
  6019.  
  6020.         if (!empty($contributors))
  6021.         {
  6022.             return SimplePie_Misc::array_unique($contributors);
  6023.         }
  6024.         else
  6025.         {
  6026.             return null;
  6027.         }
  6028.     }
  6029.  
  6030.     function get_link($key 0$rel 'alternate')
  6031.     {
  6032.         $links $this->get_links($rel);
  6033.         if (isset($links[$key]))
  6034.         {
  6035.             return $links[$key];
  6036.         }
  6037.         else
  6038.         {
  6039.             return null;
  6040.         }
  6041.     }
  6042.  
  6043.     /**
  6044.      * Added for parity between the parent-level and the item/entry-level.
  6045.      */
  6046.     function get_permalink()
  6047.     {
  6048.         return $this->get_link(0);
  6049.     }
  6050.  
  6051.     function get_links($rel 'alternate')
  6052.     {
  6053.         if (!isset($this->data['links']))
  6054.         {
  6055.             $this->data['links'array();
  6056.             if ($links $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10'link'))
  6057.             {
  6058.                 foreach ($links as $link)
  6059.                 {
  6060.                     if (isset($link['attribs']['']['href']))
  6061.                     {
  6062.                         $link_rel (isset($link['attribs']['']['rel'])) $link['attribs']['']['rel''alternate';
  6063.                         $this->data['links'][$link_rel][$this->sanitize($link['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($link));
  6064.                     }
  6065.                 }
  6066.             }
  6067.             if ($links $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03'link'))
  6068.             {
  6069.                 foreach ($links as $link)
  6070.                 {
  6071.                     if (isset($link['attribs']['']['href']))
  6072.                     {
  6073.                         $link_rel (isset($link['attribs']['']['rel'])) $link['attribs']['']['rel''alternate';
  6074.                         $this->data['links'][$link_rel][$this->sanitize($link['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($link));
  6075.  
  6076.                     }
  6077.                 }
  6078.             }
  6079.             if ($links $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10'link'))
  6080.             {
  6081.                 $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  6082.             }
  6083.             if ($links $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090'link'))
  6084.             {
  6085.                 $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  6086.             }
  6087.             if ($links $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20'link'))
  6088.             {
  6089.                 $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  6090.             }
  6091.  
  6092.             $keys array_keys($this->data['links']);
  6093.             foreach ($keys as $key)
  6094.             {
  6095.                 if (SimplePie_Misc::is_isegment_nz_nc($key))
  6096.                 {
  6097.                     if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key]))
  6098.                     {
  6099.                         $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $keyarray_merge($this->data['links'][$key]$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key]);
  6100.                         $this->data['links'][$key=$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key];
  6101.                     }
  6102.                     else
  6103.                     {
  6104.                         $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key=$this->data['links'][$key];
  6105.                     }
  6106.                 }
  6107.                 elseif (substr($key041=== SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
  6108.                 {
  6109.                     $this->data['links'][substr($key41)=$this->data['links'][$key];
  6110.                 }
  6111.                 $this->data['links'][$keyarray_unique($this->data['links'][$key]);
  6112.             }
  6113.         }
  6114.  
  6115.         if (isset($this->data['links'][$rel]))
  6116.         {
  6117.             return $this->data['links'][$rel];
  6118.         }
  6119.         else
  6120.         {
  6121.             return null;
  6122.         }
  6123.     }
  6124.  
  6125.     function get_description()
  6126.     {
  6127.         if ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10'subtitle'))
  6128.         {
  6129.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_10_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  6130.         }
  6131.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03'tagline'))
  6132.         {
  6133.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_03_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  6134.         }
  6135.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10'description'))
  6136.         {
  6137.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  6138.         }
  6139.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090'description'))
  6140.         {
  6141.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  6142.         }
  6143.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20'description'))
  6144.         {
  6145.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  6146.         }
  6147.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11'description'))
  6148.         {
  6149.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  6150.         }
  6151.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10'description'))
  6152.         {
  6153.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  6154.         }
  6155.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES'summary'))
  6156.         {
  6157.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_HTML$this->get_base($return[0]));
  6158.         }
  6159.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES'subtitle'))
  6160.         {
  6161.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_HTML$this->get_base($return[0]));
  6162.         }
  6163.         else
  6164.         {
  6165.             return null;
  6166.         }
  6167.     }
  6168.  
  6169.     function get_copyright()
  6170.     {
  6171.         if ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10'rights'))
  6172.         {
  6173.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_10_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  6174.         }
  6175.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03'copyright'))
  6176.         {
  6177.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_03_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  6178.         }
  6179.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20'copyright'))
  6180.         {
  6181.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  6182.         }
  6183.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11'rights'))
  6184.         {
  6185.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  6186.         }
  6187.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10'rights'))
  6188.         {
  6189.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  6190.         }
  6191.         else
  6192.         {
  6193.             return null;
  6194.         }
  6195.     }
  6196.  
  6197.     function get_language()
  6198.     {
  6199.         if ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20'language'))
  6200.         {
  6201.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  6202.         }
  6203.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11'language'))
  6204.         {
  6205.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  6206.         }
  6207.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10'language'))
  6208.         {
  6209.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  6210.         }
  6211.         elseif (isset($this->data['xml_lang']))
  6212.         {
  6213.             return $this->sanitize($this->data['xml_lang']SIMPLEPIE_CONSTRUCT_TEXT);
  6214.         }
  6215.         else
  6216.         {
  6217.             return null;
  6218.         }
  6219.     }
  6220.  
  6221.     function get_latitude()
  6222.     {
  6223.         if ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO'lat'))
  6224.         {
  6225.             return (float) $return[0]['data'];
  6226.         }
  6227.         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.         {
  6229.             return (float) $match[1];
  6230.         }
  6231.         else
  6232.         {
  6233.             return null;
  6234.         }
  6235.     }
  6236.  
  6237.     function get_longitude()
  6238.     {
  6239.         if ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO'long'))
  6240.         {
  6241.             return (float) $return[0]['data'];
  6242.         }
  6243.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO'lon'))
  6244.         {
  6245.             return (float) $return[0]['data'];
  6246.         }
  6247.         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.         {
  6249.             return (float) $match[2];
  6250.         }
  6251.         else
  6252.         {
  6253.             return null;
  6254.         }
  6255.     }
  6256.  
  6257.     function get_image_url()
  6258.     {
  6259.         if ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES'image'))
  6260.         {
  6261.             return $this->sanitize($return[0]['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI);
  6262.         }
  6263.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10'logo'))
  6264.         {
  6265.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  6266.         }
  6267.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10'icon'))
  6268.         {
  6269.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  6270.         }
  6271.         else
  6272.         {
  6273.             return null;
  6274.         }
  6275.     }
  6276. }
  6277.  
  6278. {
  6279.     var $name;
  6280.     var $link;
  6281.     var $email;
  6282.  
  6283.     // Constructor, used to input the data
  6284.     function SimplePie_Author($name null$link null$email null)
  6285.     {
  6286.         $this->name = $name;
  6287.         $this->link = $link;
  6288.         $this->email = $email;
  6289.     }
  6290.  
  6291.     function __toString()
  6292.     {
  6293.         // There is no $this->data here
  6294.         return md5(serialize($this));
  6295.     }
  6296.  
  6297.     function get_name()
  6298.     {
  6299.         if ($this->name !== null)
  6300.         {
  6301.             return $this->name;
  6302.         }
  6303.         else
  6304.         {
  6305.             return null;
  6306.         }
  6307.     }
  6308.  
  6309.     function get_link()
  6310.     {
  6311.         if ($this->link !== null)
  6312.         {
  6313.             return $this->link;
  6314.         }
  6315.         else
  6316.         {
  6317.             return null;
  6318.         }
  6319.     }
  6320.  
  6321.     function get_email()
  6322.     {
  6323.         if ($this->email !== null)
  6324.         {
  6325.             return $this->email;
  6326.         }
  6327.         else
  6328.         {
  6329.             return null;
  6330.         }
  6331.     }
  6332. }
  6333.  
  6334. {
  6335.     var $term;
  6336.     var $scheme;
  6337.     var $label;
  6338.  
  6339.     // Constructor, used to input the data
  6340.     function SimplePie_Category($term null$scheme null$label null)
  6341.     {
  6342.         $this->term = $term;
  6343.         $this->scheme = $scheme;
  6344.         $this->label = $label;
  6345.     }
  6346.  
  6347.     function __toString()
  6348.     {
  6349.         // There is no $this->data here
  6350.         return md5(serialize($this));
  6351.     }
  6352.  
  6353.     function get_term()
  6354.     {
  6355.         if ($this->term !== null)
  6356.         {
  6357.             return $this->term;
  6358.         }
  6359.         else
  6360.         {
  6361.             return null;
  6362.         }
  6363.     }
  6364.  
  6365.     function get_scheme()
  6366.     {
  6367.         if ($this->scheme !== null)
  6368.         {
  6369.             return $this->scheme;
  6370.         }
  6371.         else
  6372.         {
  6373.             return null;
  6374.         }
  6375.     }
  6376.  
  6377.     function get_label()
  6378.     {
  6379.         if ($this->label !== null)
  6380.         {
  6381.             return $this->label;
  6382.         }
  6383.         else
  6384.         {
  6385.             return $this->get_term();
  6386.         }
  6387.     }
  6388. }
  6389.  
  6390. {
  6391.     var $bitrate;
  6392.     var $captions;
  6393.     var $categories;
  6394.     var $channels;
  6395.     var $copyright;
  6396.     var $credits;
  6397.     var $description;
  6398.     var $duration;
  6399.     var $expression;
  6400.     var $framerate;
  6401.     var $handler;
  6402.     var $hashes;
  6403.     var $height;
  6404.     var $javascript;
  6405.     var $keywords;
  6406.     var $lang;
  6407.     var $length;
  6408.     var $link;
  6409.     var $medium;
  6410.     var $player;
  6411.     var $ratings;
  6412.     var $restrictions;
  6413.     var $samplingrate;
  6414.     var $thumbnails;
  6415.     var $title;
  6416.     var $type;
  6417.     var $width;
  6418.  
  6419.     // Constructor, used to input the data
  6420.     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)
  6421.     {
  6422.         $this->bitrate = $bitrate;
  6423.         $this->captions = $captions;
  6424.         $this->categories = $categories;
  6425.         $this->channels = $channels;
  6426.         $this->copyright = $copyright;
  6427.         $this->credits = $credits;
  6428.         $this->description = $description;
  6429.         $this->duration = $duration;
  6430.         $this->expression = $expression;
  6431.         $this->framerate = $framerate;
  6432.         $this->hashes = $hashes;
  6433.         $this->height = $height;
  6434.         $this->javascript = $javascript;
  6435.         $this->keywords = $keywords;
  6436.         $this->lang = $lang;
  6437.         $this->length = $length;
  6438.         $this->link = $link;
  6439.         $this->medium = $medium;
  6440.         $this->player = $player;
  6441.         $this->ratings = $ratings;
  6442.         $this->restrictions = $restrictions;
  6443.         $this->samplingrate = $samplingrate;
  6444.         $this->thumbnails = $thumbnails;
  6445.         $this->title = $title;
  6446.         $this->type = $type;
  6447.         $this->width = $width;
  6448.         if (class_exists('idna_convert'))
  6449.         {
  6450.             $idn new idna_convert;
  6451.             $parsed SimplePie_Misc::parse_url($link);
  6452.             $this->link = SimplePie_Misc::compress_parse_url($parsed['scheme']$idn->encode($parsed['authority'])$parsed['path']$parsed['query']$parsed['fragment']);
  6453.         }
  6454.         $this->handler = $this->get_handler()// Needs to load last
  6455.     }
  6456.  
  6457.     function __toString()
  6458.     {
  6459.         // There is no $this->data here
  6460.         return md5(serialize($this));
  6461.     }
  6462.  
  6463.     function get_bitrate()
  6464.     {
  6465.         if ($this->bitrate !== null)
  6466.         {
  6467.             return $this->bitrate;
  6468.         }
  6469.         else
  6470.         {
  6471.             return null;
  6472.         }
  6473.     }
  6474.  
  6475.     function get_caption($key 0)
  6476.     {
  6477.         $captions $this->get_captions();
  6478.         if (isset($captions[$key]))
  6479.         {
  6480.             return $captions[$key];
  6481.         }
  6482.         else
  6483.         {
  6484.             return null;
  6485.         }
  6486.     }
  6487.  
  6488.     function get_captions()
  6489.     {
  6490.         if ($this->captions !== null)
  6491.         {
  6492.             return $this->captions;
  6493.         }
  6494.         else
  6495.         {
  6496.             return null;
  6497.         }
  6498.     }
  6499.  
  6500.     function get_category($key 0)
  6501.     {
  6502.         $categories $this->get_categories();
  6503.         if (isset($categories[$key]))
  6504.         {
  6505.             return $categories[$key];
  6506.         }
  6507.         else
  6508.         {
  6509.             return null;
  6510.         }
  6511.     }
  6512.  
  6513.     function get_categories()
  6514.     {
  6515.         if ($this->categories !== null)
  6516.         {
  6517.             return $this->categories;
  6518.         }
  6519.         else
  6520.         {
  6521.             return null;
  6522.         }
  6523.     }
  6524.  
  6525.     function get_channels()
  6526.     {
  6527.         if ($this->channels !== null)
  6528.         {
  6529.             return $this->channels;
  6530.         }
  6531.         else
  6532.         {
  6533.             return null;
  6534.         }
  6535.     }
  6536.  
  6537.     function get_copyright()
  6538.     {
  6539.         if ($this->copyright !== null)
  6540.         {
  6541.             return $this->copyright;
  6542.         }
  6543.         else
  6544.         {
  6545.             return null;
  6546.         }
  6547.     }
  6548.  
  6549.     function get_credit($key 0)
  6550.     {
  6551.         $credits $this->get_credits();
  6552.         if (isset($credits[$key]))
  6553.         {
  6554.             return $credits[$key];
  6555.         }
  6556.         else
  6557.         {
  6558.             return null;
  6559.         }
  6560.     }
  6561.  
  6562.     function get_credits()
  6563.     {
  6564.         if ($this->credits !== null)
  6565.         {
  6566.             return $this->credits;
  6567.         }
  6568.         else
  6569.         {
  6570.             return null;
  6571.         }
  6572.     }
  6573.  
  6574.     function get_description()
  6575.     {
  6576.         if ($this->description !== null)
  6577.         {
  6578.             return $this->description;
  6579.         }
  6580.         else
  6581.         {
  6582.             return null;
  6583.         }
  6584.     }
  6585.  
  6586.     function get_duration($convert false)
  6587.     {
  6588.         if ($this->duration !== null)
  6589.         {
  6590.             if ($convert)
  6591.             {
  6592.                 $time SimplePie_Misc::time_hms($this->duration);
  6593.                 return $time;
  6594.             }
  6595.             else
  6596.             {
  6597.                 return $this->duration;
  6598.             }
  6599.         }
  6600.         else
  6601.         {
  6602.             return null;
  6603.         }
  6604.     }
  6605.  
  6606.     function get_expression()
  6607.     {
  6608.         if ($this->expression !== null)
  6609.         {
  6610.             return $this->expression;
  6611.         }
  6612.         else
  6613.         {
  6614.             return 'full';
  6615.         }
  6616.     }
  6617.  
  6618.     function get_extension()
  6619.     {
  6620.         if ($this->link !== null)
  6621.         {
  6622.             $url SimplePie_Misc::parse_url($this->link);
  6623.             if ($url['path'!== '')
  6624.             {
  6625.                 return pathinfo($url['path']PATHINFO_EXTENSION);
  6626.             }
  6627.         }
  6628.         return null;
  6629.     }
  6630.  
  6631.     function get_framerate()
  6632.     {
  6633.         if ($this->framerate !== null)
  6634.         {
  6635.             return $this->framerate;
  6636.         }
  6637.         else
  6638.         {
  6639.             return null;
  6640.         }
  6641.     }
  6642.  
  6643.     function get_handler()
  6644.     {
  6645.         return $this->get_real_type(true);
  6646.     }
  6647.  
  6648.     function get_hash($key 0)
  6649.     {
  6650.         $hashes $this->get_hashes();
  6651.         if (isset($hashes[$key]))
  6652.         {
  6653.             return $hashes[$key];
  6654.         }
  6655.         else
  6656.         {
  6657.             return null;
  6658.         }
  6659.     }
  6660.  
  6661.     function get_hashes()
  6662.     {
  6663.         if ($this->hashes !== null)
  6664.         {
  6665.             return $this->hashes;
  6666.         }
  6667.         else
  6668.         {
  6669.             return null;
  6670.         }
  6671.     }
  6672.  
  6673.     function get_height()
  6674.     {
  6675.         if ($this->height !== null)
  6676.         {
  6677.             return $this->height;
  6678.         }
  6679.         else
  6680.         {
  6681.             return null;
  6682.         }
  6683.     }
  6684.  
  6685.     function get_language()
  6686.     {
  6687.         if ($this->lang !== null)
  6688.         {
  6689.             return $this->lang;
  6690.         }
  6691.         else
  6692.         {
  6693.             return null;
  6694.         }
  6695.     }
  6696.  
  6697.     function get_keyword($key 0)
  6698.     {
  6699.         $keywords $this->get_keywords();
  6700.         if (isset($keywords[$key]))
  6701.         {
  6702.             return $keywords[$key];
  6703.         }
  6704.         else
  6705.         {
  6706.             return null;
  6707.         }
  6708.     }
  6709.  
  6710.     function get_keywords()
  6711.     {
  6712.         if ($this->keywords !== null)
  6713.         {
  6714.             return $this->keywords;
  6715.         }
  6716.         else
  6717.         {
  6718.             return null;
  6719.         }
  6720.     }
  6721.  
  6722.     function get_length()
  6723.     {
  6724.         if ($this->length !== null)
  6725.         {
  6726.             return $this->length;
  6727.         }
  6728.         else
  6729.         {
  6730.             return null;
  6731.         }
  6732.     }
  6733.  
  6734.     function get_link()
  6735.     {
  6736.         if ($this->link !== null)
  6737.         {
  6738.             return urldecode($this->link);
  6739.         }
  6740.         else
  6741.         {
  6742.             return null;
  6743.         }
  6744.     }
  6745.  
  6746.     function get_medium()
  6747.     {
  6748.         if ($this->medium !== null)
  6749.         {
  6750.             return $this->medium;
  6751.         }
  6752.         else
  6753.         {
  6754.             return null;
  6755.         }
  6756.     }
  6757.  
  6758.     function get_player()
  6759.     {
  6760.         if ($this->player !== null)
  6761.         {
  6762.             return $this->player;
  6763.         }
  6764.         else
  6765.         {
  6766.             return null;
  6767.         }
  6768.     }
  6769.  
  6770.     function get_rating($key 0)
  6771.     {
  6772.         $ratings $this->get_ratings();
  6773.         if (isset($ratings[$key]))
  6774.         {
  6775.             return $ratings[$key];
  6776.         }
  6777.         else
  6778.         {
  6779.             return null;
  6780.         }
  6781.     }
  6782.  
  6783.     function get_ratings()
  6784.     {
  6785.         if ($this->ratings !== null)
  6786.         {
  6787.             return $this->ratings;
  6788.         }
  6789.         else
  6790.         {
  6791.             return null;
  6792.         }
  6793.     }
  6794.  
  6795.     function get_restriction($key 0)
  6796.     {
  6797.         $restrictions $this->get_restrictions();
  6798.         if (isset($restrictions[$key]))
  6799.         {
  6800.             return $restrictions[$key];
  6801.         }
  6802.         else
  6803.         {
  6804.             return null;
  6805.         }
  6806.     }
  6807.  
  6808.     function get_restrictions()
  6809.     {
  6810.         if ($this->restrictions !== null)
  6811.         {
  6812.             return $this->restrictions;
  6813.         }
  6814.         else
  6815.         {
  6816.             return null;
  6817.         }
  6818.     }
  6819.  
  6820.     function get_sampling_rate()
  6821.     {
  6822.         if ($this->samplingrate !== null)
  6823.         {
  6824.             return $this->samplingrate;
  6825.         }
  6826.         else
  6827.         {
  6828.             return null;
  6829.         }
  6830.     }
  6831.  
  6832.     function get_size()
  6833.     {
  6834.         $length $this->get_length();
  6835.         if ($length !== null)
  6836.         {
  6837.             return round($length/10485762);
  6838.         }
  6839.         else
  6840.         {
  6841.             return null;
  6842.         }
  6843.     }
  6844.  
  6845.     function get_thumbnail($key 0)
  6846.     {
  6847.         $thumbnails $this->get_thumbnails();
  6848.         if (isset($thumbnails[$key]))
  6849.         {
  6850.             return $thumbnails[$key];
  6851.         }
  6852.         else
  6853.         {
  6854.             return null;
  6855.         }
  6856.     }
  6857.  
  6858.     function get_thumbnails()
  6859.     {
  6860.         if ($this->thumbnails !== null)
  6861.         {
  6862.             return $this->thumbnails;
  6863.         }
  6864.         else
  6865.         {
  6866.             return null;
  6867.         }
  6868.     }
  6869.  
  6870.     function get_title()
  6871.     {
  6872.         if ($this->title !== null)
  6873.         {
  6874.             return $this->title;
  6875.         }
  6876.         else
  6877.         {
  6878.             return null;
  6879.         }
  6880.     }
  6881.  
  6882.     function get_type()
  6883.     {
  6884.         if ($this->type !== null)
  6885.         {
  6886.             return $this->type;
  6887.         }
  6888.         else
  6889.         {
  6890.             return null;
  6891.         }
  6892.     }
  6893.  
  6894.     function get_width()
  6895.     {
  6896.         if ($this->width !== null)
  6897.         {
  6898.             return $this->width;
  6899.         }
  6900.         else
  6901.         {
  6902.             return null;
  6903.         }
  6904.     }
  6905.  
  6906.     function native_embed($options='')
  6907.     {
  6908.         return $this->embed($optionstrue);
  6909.     }
  6910.  
  6911.     /**
  6912.      * @todo If the dimensions for media:content are defined, use them when width/height are set to 'auto'.
  6913.      */
  6914.     function embed($options ''$native false)
  6915.     {
  6916.         // Set up defaults
  6917.         $audio '';
  6918.         $video '';
  6919.         $alt '';
  6920.         $altclass '';
  6921.         $loop 'false';
  6922.         $width 'auto';
  6923.         $height 'auto';
  6924.         $bgcolor '#ffffff';
  6925.         $mediaplayer '';
  6926.         $widescreen false;
  6927.         $handler $this->get_handler();
  6928.         $type $this->get_real_type();
  6929.  
  6930.         // Process options and reassign values as necessary
  6931.         if (is_array($options))
  6932.         {
  6933.             extract($options);
  6934.         }
  6935.         else
  6936.         {
  6937.             $options explode(','$options);
  6938.             foreach($options as $option)
  6939.             {
  6940.                 $opt explode(':'$option2);
  6941.                 if (isset($opt[0]$opt[1]))
  6942.                 {
  6943.                     $opt[0trim($opt[0]);
  6944.                     $opt[1trim($opt[1]);
  6945.                     switch ($opt[0])
  6946.                     {
  6947.                         case 'audio':
  6948.                             $audio $opt[1];
  6949.                             break;
  6950.  
  6951.                         case 'video':
  6952.                             $video $opt[1];
  6953.                             break;
  6954.  
  6955.                         case 'alt':
  6956.                             $alt $opt[1];
  6957.                             break;
  6958.  
  6959.                         case 'altclass':
  6960.                             $altclass $opt[1];
  6961.                             break;
  6962.  
  6963.                         case 'loop':
  6964.                             $loop $opt[1];
  6965.                             break;
  6966.  
  6967.                         case 'width':
  6968.                             $width $opt[1];
  6969.                             break;
  6970.  
  6971.                         case 'height':
  6972.                             $height $opt[1];
  6973.                             break;
  6974.  
  6975.                         case 'bgcolor':
  6976.                             $bgcolor $opt[1];
  6977.                             break;
  6978.  
  6979.                         case 'mediaplayer':
  6980.                             $mediaplayer $opt[1];
  6981.                             break;
  6982.  
  6983.                         case 'widescreen':
  6984.                             $widescreen $opt[1];
  6985.                             break;
  6986.                     }
  6987.                 }
  6988.             }
  6989.         }
  6990.  
  6991.         $mime explode('/'$type2);
  6992.         $mime $mime[0];
  6993.  
  6994.         // Process values for 'auto'
  6995.         if ($width === 'auto')
  6996.         {
  6997.             if ($mime === 'video')
  6998.             {
  6999.                 if ($height === 'auto')
  7000.                 {
  7001.                     $width 480;
  7002.                 }
  7003.                 elseif ($widescreen)
  7004.                 {
  7005.                     $width round((intval($height)/9)*16);
  7006.                 }
  7007.                 else
  7008.                 {
  7009.                     $width round((intval($height)/3)*4);
  7010.                 }
  7011.             }
  7012.             else
  7013.             {
  7014.                 $width '100%';
  7015.             }
  7016.         }
  7017.  
  7018.         if ($height === 'auto')
  7019.         {
  7020.             if ($mime === 'audio')
  7021.             {
  7022.                 $height 0;
  7023.             }
  7024.             elseif ($mime === 'video')
  7025.             {
  7026.                 if ($width === 'auto')
  7027.                 {
  7028.                     if ($widescreen)
  7029.                     {
  7030.                         $height 270;
  7031.                     }
  7032.                     else
  7033.                     {
  7034.                         $height 360;
  7035.                     }
  7036.                 }
  7037.                 elseif ($widescreen)
  7038.                 {
  7039.                     $height round((intval($width)/16)*9);
  7040.                 }
  7041.                 else
  7042.                 {
  7043.                     $height round((intval($width)/4)*3);
  7044.                 }
  7045.             }
  7046.             else
  7047.             {
  7048.                 $height 376;
  7049.             }
  7050.         }
  7051.         elseif ($mime === 'audio')
  7052.         {
  7053.             $height 0;
  7054.         }
  7055.  
  7056.         // Set proper placeholder value
  7057.         if ($mime === 'audio')
  7058.         {
  7059.             $placeholder $audio;
  7060.         }
  7061.         elseif ($mime === 'video')
  7062.         {
  7063.             $placeholder $video;
  7064.         }
  7065.  
  7066.         $embed '';
  7067.  
  7068.         // Make sure the JS library is included
  7069.         if (!$native)
  7070.         {
  7071.             static $javascript_outputted null;
  7072.             if (!$javascript_outputted && $this->javascript)
  7073.             {
  7074.                 $embed .= '<script type="text/javascript" src="?' htmlspecialchars($this->javascript'"></script>';
  7075.                 $javascript_outputted true;
  7076.             }
  7077.         }
  7078.  
  7079.         // Odeo Feed MP3's
  7080.         if ($handler === 'odeo')
  7081.         {
  7082.             if ($native)
  7083.             {
  7084.                 $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>';
  7085.             }
  7086.             else
  7087.             {
  7088.                 $embed .= '<script type="text/javascript">embed_odeo("' $this->get_link('");</script>';
  7089.             }
  7090.         }
  7091.  
  7092.         // Flash
  7093.         elseif ($handler === 'flash')
  7094.         {
  7095.             if ($native)
  7096.             {
  7097.                 $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>";
  7098.             }
  7099.             else
  7100.             {
  7101.                 $embed .= "<script type='text/javascript'>embed_flash('$bgcolor', '$width', '$height', '$this->get_link("', '$loop', '$type');</script>";
  7102.             }
  7103.         }
  7104.  
  7105.         // Flash Media Player file types.
  7106.         // Preferred handler for MP3 file types.
  7107.         elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== ''))
  7108.         {
  7109.             $height += 20;
  7110.             if ($native)
  7111.             {
  7112.                 $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>";
  7113.             }
  7114.             else
  7115.             {
  7116.                 $embed .= "<script type='text/javascript'>embed_flv('$width', '$height', 'rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) "', '$placeholder', '$loop', '$mediaplayer');</script>";
  7117.             }
  7118.         }
  7119.  
  7120.         // QuickTime 7 file types.  Need to test with QuickTime 6.
  7121.         // Only handle MP3's if the Flash Media Player is not present.
  7122.         elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === ''))
  7123.         {
  7124.             $height += 16;
  7125.             if ($native)
  7126.             {
  7127.                 if ($placeholder !== '')
  7128.                 {
  7129.                     $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>";
  7130.                 }
  7131.                 else
  7132.                 {
  7133.                     $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>";
  7134.                 }
  7135.             }
  7136.             else
  7137.             {
  7138.                 $embed .= "<script type='text/javascript'>embed_quicktime('$type', '$bgcolor', '$width', '$height', '$this->get_link("', '$placeholder', '$loop');</script>";
  7139.             }
  7140.         }
  7141.  
  7142.         // Windows Media
  7143.         elseif ($handler === 'wmedia')
  7144.         {
  7145.             $height += 45;
  7146.             if ($native)
  7147.             {
  7148.                 $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>";
  7149.             }
  7150.             else
  7151.             {
  7152.                 $embed .= "<script type='text/javascript'>embed_wmedia('$width', '$height', '$this->get_link("');</script>";
  7153.             }
  7154.         }
  7155.  
  7156.         // Everything else
  7157.         else $embed .= '<a href="' $this->get_link('" class="' $altclass '">' $alt '</a>';
  7158.  
  7159.         return $embed;
  7160.     }
  7161.  
  7162.     function get_real_type($find_handler false)
  7163.     {
  7164.         // If it's Odeo, let's get it out of the way.
  7165.         if (substr(strtolower($this->get_link())015=== 'http://odeo.com')
  7166.         {
  7167.             return 'odeo';
  7168.         }
  7169.  
  7170.         // Mime-types by handler.
  7171.         $types_flash array('application/x-shockwave-flash''application/futuresplash')// Flash
  7172.         $types_fmedia array('video/flv''video/x-flv','flv-application/octet-stream')// Flash Media Player
  7173.         $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
  7174.         $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
  7175.         $types_mp3 array('audio/mp3''audio/x-mp3''audio/mpeg''audio/x-mpeg')// MP3
  7176.  
  7177.         if ($this->get_type(!== null)
  7178.         {
  7179.             $type strtolower($this->type);
  7180.         }
  7181.         else
  7182.         {
  7183.             $type null;
  7184.         }
  7185.  
  7186.         // If we encounter an unsupported mime-type, check the file extension and guess intelligently.
  7187.         if (!in_array($typearray_merge($types_flash$types_fmedia$types_quicktime$types_wmedia$types_mp3)))
  7188.         {
  7189.             switch (strtolower($this->get_extension()))
  7190.             {
  7191.                 // Audio mime-types
  7192.                 case 'aac':
  7193.                 case 'adts':
  7194.                     $type 'audio/acc';
  7195.                     break;
  7196.  
  7197.                 case 'aif':
  7198.                 case 'aifc':
  7199.                 case 'aiff':
  7200.                 case 'cdda':
  7201.                     $type 'audio/aiff';
  7202.                     break;
  7203.  
  7204.                 case 'bwf':
  7205.                     $type 'audio/wav';
  7206.                     break;
  7207.  
  7208.                 case 'kar':
  7209.                 case 'mid':
  7210.                 case 'midi':
  7211.                 case 'smf':
  7212.                     $type 'audio/midi';
  7213.                     break;
  7214.  
  7215.                 case 'm4a':
  7216.                     $type 'audio/x-m4a';
  7217.                     break;
  7218.  
  7219.                 case 'mp3':
  7220.                 case 'swa':
  7221.                     $type 'audio/mp3';
  7222.                     break;
  7223.  
  7224.                 case 'wav':
  7225.                     $type 'audio/wav';
  7226.                     break;
  7227.  
  7228.                 case 'wax':
  7229.                     $type 'audio/x-ms-wax';
  7230.                     break;
  7231.  
  7232.                 case 'wma':
  7233.                     $type 'audio/x-ms-wma';
  7234.                     break;
  7235.  
  7236.                 // Video mime-types
  7237.                 case '3gp':
  7238.                 case '3gpp':
  7239.                     $type 'video/3gpp';
  7240.                     break;
  7241.  
  7242.                 case '3g2':
  7243.                 case '3gp2':
  7244.                     $type 'video/3gpp2';
  7245.                     break;
  7246.  
  7247.                 case 'asf':
  7248.                     $type 'video/x-ms-asf';
  7249.                     break;
  7250.  
  7251.                 case 'flv':
  7252.                     $type 'video/x-flv';
  7253.                     break;
  7254.  
  7255.                 case 'm1a':
  7256.                 case 'm1s':
  7257.                 case 'm1v':
  7258.                 case 'm15':
  7259.                 case 'm75':
  7260.                 case 'mp2':
  7261.                 case 'mpa':
  7262.                 case 'mpeg':
  7263.                 case 'mpg':
  7264.                 case 'mpm':
  7265.                 case 'mpv':
  7266.                     $type 'video/mpeg';
  7267.                     break;
  7268.  
  7269.                 case 'm4v':
  7270.                     $type 'video/x-m4v';
  7271.                     break;
  7272.  
  7273.                 case 'mov':
  7274.                 case 'qt':
  7275.                     $type 'video/quicktime';
  7276.                     break;
  7277.  
  7278.                 case 'mp4':
  7279.                 case 'mpg4':
  7280.                     $type 'video/mp4';
  7281.                     break;
  7282.  
  7283.                 case 'sdv':
  7284.                     $type 'video/sd-video';
  7285.                     break;
  7286.  
  7287.                 case 'wm':
  7288.                     $type 'video/x-ms-wm';
  7289.                     break;
  7290.  
  7291.                 case 'wmv':
  7292.                     $type 'video/x-ms-wmv';
  7293.                     break;
  7294.  
  7295.                 case 'wvx':
  7296.                     $type 'video/x-ms-wvx';
  7297.                     break;
  7298.  
  7299.                 // Flash mime-types
  7300.                 case 'spl':
  7301.                     $type 'application/futuresplash';
  7302.                     break;
  7303.  
  7304.                 case 'swf':
  7305.                     $type 'application/x-shockwave-flash';
  7306.                     break;
  7307.             }
  7308.         }
  7309.  
  7310.         if ($find_handler)
  7311.         {
  7312.             if (in_array($type$types_flash))
  7313.             {
  7314.                 return 'flash';
  7315.             }
  7316.             elseif (in_array($type$types_fmedia))
  7317.             {
  7318.                 return 'fmedia';
  7319.             }
  7320.             elseif (in_array($type$types_quicktime))
  7321.             {
  7322.                 return 'quicktime';
  7323.             }
  7324.             elseif (in_array($type$types_wmedia))
  7325.             {
  7326.                 return 'wmedia';
  7327.             }
  7328.             elseif (in_array($type$types_mp3))
  7329.             {
  7330.                 return 'mp3';
  7331.             }
  7332.             else
  7333.             {
  7334.                 return null;
  7335.             }
  7336.         }
  7337.         else
  7338.         {
  7339.             return $type;
  7340.         }
  7341.     }
  7342. }
  7343.  
  7344. {
  7345.     var $type;
  7346.     var $lang;
  7347.     var $startTime;
  7348.     var $endTime;
  7349.     var $text;
  7350.  
  7351.     // Constructor, used to input the data
  7352.     function SimplePie_Caption($type null$lang null$startTime null$endTime null$text null)
  7353.     {
  7354.         $this->type = $type;
  7355.         $this->lang = $lang;
  7356.         $this->startTime = $startTime;
  7357.         $this->endTime = $endTime;
  7358.         $this->text = $text;
  7359.     }
  7360.  
  7361.     function __toString()
  7362.     {
  7363.         // There is no $this->data here
  7364.         return md5(serialize($this));
  7365.     }
  7366.  
  7367.     function get_endtime()
  7368.     {
  7369.         if ($this->endTime !== null)
  7370.         {
  7371.             return $this->endTime;
  7372.         }
  7373.         else
  7374.         {
  7375.             return null;
  7376.         }
  7377.     }
  7378.  
  7379.     function get_language()
  7380.     {
  7381.         if ($this->lang !== null)
  7382.         {
  7383.             return $this->lang;
  7384.         }
  7385.         else
  7386.         {
  7387.             return null;
  7388.         }
  7389.     }
  7390.  
  7391.     function get_starttime()
  7392.     {
  7393.         if ($this->startTime !== null)
  7394.         {
  7395.             return $this->startTime;
  7396.         }
  7397.         else
  7398.         {
  7399.             return null;
  7400.         }
  7401.     }
  7402.  
  7403.     function get_text()
  7404.     {
  7405.         if ($this->text !== null)
  7406.         {
  7407.             return $this->text;
  7408.         }
  7409.         else
  7410.         {
  7411.             return null;
  7412.         }
  7413.     }
  7414.  
  7415.     function get_type()
  7416.     {
  7417.         if ($this->type !== null)
  7418.         {
  7419.             return $this->type;
  7420.         }
  7421.         else
  7422.         {
  7423.             return null;
  7424.         }
  7425.     }
  7426. }
  7427.  
  7428. {
  7429.     var $role;
  7430.     var $scheme;
  7431.     var $name;
  7432.  
  7433.     // Constructor, used to input the data
  7434.     function SimplePie_Credit($role null$scheme null$name null)
  7435.     {
  7436.         $this->role = $role;
  7437.         $this->scheme = $scheme;
  7438.         $this->name = $name;
  7439.     }
  7440.  
  7441.     function __toString()
  7442.     {
  7443.         // There is no $this->data here
  7444.         return md5(serialize($this));
  7445.     }
  7446.  
  7447.     function get_role()
  7448.     {
  7449.         if ($this->role !== null)
  7450.         {
  7451.             return $this->role;
  7452.         }
  7453.         else
  7454.         {
  7455.             return null;
  7456.         }
  7457.     }
  7458.  
  7459.     function get_scheme()
  7460.     {
  7461.         if ($this->scheme !== null)
  7462.         {
  7463.             return $this->scheme;
  7464.         }
  7465.         else
  7466.         {
  7467.             return null;
  7468.         }
  7469.     }
  7470.  
  7471.     function get_name()
  7472.     {
  7473.         if ($this->name !== null)
  7474.         {
  7475.             return $this->name;
  7476.         }
  7477.         else
  7478.         {
  7479.             return null;
  7480.         }
  7481.     }
  7482. }
  7483.  
  7484. {
  7485.     var $url;
  7486.     var $label;
  7487.  
  7488.     // Constructor, used to input the data
  7489.     function SimplePie_Copyright($url null$label null)
  7490.     {
  7491.         $this->url = $url;
  7492.         $this->label = $label;
  7493.     }
  7494.  
  7495.     function __toString()
  7496.     {
  7497.         // There is no $this->data here
  7498.         return md5(serialize($this));
  7499.     }
  7500.  
  7501.     function get_url()
  7502.     {
  7503.         if ($this->url !== null)
  7504.         {
  7505.             return $this->url;
  7506.         }
  7507.         else
  7508.         {
  7509.             return null;
  7510.         }
  7511.     }
  7512.  
  7513.     function get_attribution()
  7514.     {
  7515.         if ($this->label !== null)
  7516.         {
  7517.             return $this->label;
  7518.         }
  7519.         else
  7520.         {
  7521.             return null;
  7522.         }
  7523.     }
  7524. }
  7525.  
  7526. {
  7527.     var $scheme;
  7528.     var $value;
  7529.  
  7530.     // Constructor, used to input the data
  7531.     function SimplePie_Rating($scheme null$value null)
  7532.     {
  7533.         $this->scheme = $scheme;
  7534.         $this->value = $value;
  7535.     }
  7536.  
  7537.     function __toString()
  7538.     {
  7539.         // There is no $this->data here
  7540.         return md5(serialize($this));
  7541.     }
  7542.  
  7543.     function get_scheme()
  7544.     {
  7545.         if ($this->scheme !== null)
  7546.         {
  7547.             return $this->scheme;
  7548.         }
  7549.         else
  7550.         {
  7551.             return null;
  7552.         }
  7553.     }
  7554.  
  7555.     function get_value()
  7556.     {
  7557.         if ($this->value !== null)
  7558.         {
  7559.             return $this->value;
  7560.         }
  7561.         else
  7562.         {
  7563.             return null;
  7564.         }
  7565.     }
  7566. }
  7567.  
  7568. {
  7569.     var $relationship;
  7570.     var $type;
  7571.     var $value;
  7572.  
  7573.     // Constructor, used to input the data
  7574.     function SimplePie_Restriction($relationship null$type null$value null)
  7575.     {
  7576.         $this->relationship = $relationship;
  7577.         $this->type = $type;
  7578.         $this->value = $value;
  7579.     }
  7580.  
  7581.     function __toString()
  7582.     {
  7583.         // There is no $this->data here
  7584.         return md5(serialize($this));
  7585.     }
  7586.  
  7587.     function get_relationship()
  7588.     {
  7589.         if ($this->relationship !== null)
  7590.         {
  7591.             return $this->relationship;
  7592.         }
  7593.         else
  7594.         {
  7595.             return null;
  7596.         }
  7597.     }
  7598.  
  7599.     function get_type()
  7600.     {
  7601.         if ($this->type !== null)
  7602.         {
  7603.             return $this->type;
  7604.         }
  7605.         else
  7606.         {
  7607.             return null;
  7608.         }
  7609.     }
  7610.  
  7611.     function get_value()
  7612.     {
  7613.         if ($this->value !== null)
  7614.         {
  7615.             return $this->value;
  7616.         }
  7617.         else
  7618.         {
  7619.             return null;
  7620.         }
  7621.     }
  7622. }
  7623.  
  7624. /**
  7625.  * @todo Move to properly supporting RFC2616 (HTTP/1.1)
  7626.  */
  7627. {
  7628.     var $url;
  7629.     var $useragent;
  7630.     var $success = true;
  7631.     var $headers = array();
  7632.     var $body;
  7633.     var $status_code;
  7634.     var $redirects = 0;
  7635.     var $error;
  7636.     var $method = SIMPLEPIE_FILE_SOURCE_NONE;
  7637.  
  7638.     function SimplePie_File($url$timeout 10$redirects 5$headers null$useragent null$force_fsockopen false)
  7639.     {
  7640.         if (class_exists('idna_convert'))
  7641.         {
  7642.             $idn new idna_convert;
  7643.             $parsed SimplePie_Misc::parse_url($url);
  7644.             $url SimplePie_Misc::compress_parse_url($parsed['scheme']$idn->encode($parsed['authority'])$parsed['path']$parsed['query']$parsed['fragment']);
  7645.         }
  7646.         $this->url = $url;
  7647.         $this->useragent = $useragent;
  7648.         if (preg_match('/^http(s)?:\/\//i'$url))
  7649.         {
  7650.             if ($useragent === null)
  7651.             {
  7652.                 $useragent ini_get('user_agent');
  7653.                 $this->useragent = $useragent;
  7654.             }
  7655.             if (!is_array($headers))
  7656.             {
  7657.                 $headers array();
  7658.             }
  7659.             if (!$force_fsockopen && function_exists('curl_exec'))
  7660.             {
  7661.                 $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE SIMPLEPIE_FILE_SOURCE_CURL;
  7662.                 $fp curl_init();
  7663.                 $headers2 array();
  7664.                 foreach ($headers as $key => $value)
  7665.                 {
  7666.                     $headers2["$key$value";
  7667.                 }
  7668.                 if (version_compare(SimplePie_Misc::get_curl_version()'7.10.5''>='))
  7669.                 {
  7670.                     curl_setopt($fpCURLOPT_ENCODING'');
  7671.                 }
  7672.                 curl_setopt($fpCURLOPT_URL$url);
  7673.                 curl_setopt($fpCURLOPT_HEADER1);
  7674.                 curl_setopt($fpCURLOPT_RETURNTRANSFER1);
  7675.                 curl_setopt($fpCURLOPT_TIMEOUT$timeout);
  7676.                 curl_setopt($fpCURLOPT_CONNECTTIMEOUT$timeout);
  7677.                 curl_setopt($fpCURLOPT_REFERER$url);
  7678.                 curl_setopt($fpCURLOPT_USERAGENT$useragent);
  7679.                 curl_setopt($fpCURLOPT_HTTPHEADER$headers2);
  7680.                 if (!ini_get('open_basedir'&& !ini_get('safe_mode'&& version_compare(SimplePie_Misc::get_curl_version()'7.15.2''>='))
  7681.                 {
  7682.                     curl_setopt($fpCURLOPT_FOLLOWLOCATION1);
  7683.                     curl_setopt($fpCURLOPT_MAXREDIRS$redirects);
  7684.                 }
  7685.  
  7686.                 $this->headers = curl_exec($fp);
  7687.                 if (curl_errno($fp=== 23 || curl_errno($fp=== 61)
  7688.                 {
  7689.                     curl_setopt($fpCURLOPT_ENCODING'none');
  7690.                     $this->headers = curl_exec($fp);
  7691.                 }
  7692.                 if (curl_errno($fp))
  7693.                 {
  7694.                     $this->error = 'cURL error ' curl_errno($fp': ' curl_error($fp);
  7695.                     $this->success = false;
  7696.                 }
  7697.                 else
  7698.                 {
  7699.                     $info curl_getinfo($fp);
  7700.                     curl_close($fp);
  7701.                     $this->headers = explode("\r\n\r\n"$this->headers$info['redirect_count'1);
  7702.                     $this->headers = array_pop($this->headers);
  7703.                     $parser new SimplePie_HTTP_Parser($this->headers);
  7704.                     if ($parser->parse())
  7705.                     {
  7706.                         $this->headers = $parser->headers;
  7707.                         $this->body = $parser->body;
  7708.                         $this->status_code = $parser->status_code;
  7709.                         if ((in_array($this->status_codearray(300301302303307)) || $this->status_code > 307 && $this->status_code < 400&& isset($this->headers['location']&& $this->redirects < $redirects)
  7710.                         {
  7711.                             $this->redirects++;
  7712.                             $location SimplePie_Misc::absolutize_url($this->headers['location']$url);
  7713.                             return $this->SimplePie_File($location$timeout$redirects$headers$useragent$force_fsockopen);
  7714.                         }
  7715.                     }
  7716.                 }
  7717.             }
  7718.             else
  7719.             {
  7720.                 $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
  7721.                 $url_parts parse_url($url);
  7722.                 if (isset($url_parts['scheme']&& strtolower($url_parts['scheme']=== 'https')
  7723.                 {
  7724.                     $url_parts['host'"ssl://$url_parts[host]";
  7725.                     $url_parts['port'443;
  7726.                 }
  7727.                 if (!isset($url_parts['port']))
  7728.                 {
  7729.                     $url_parts['port'80;
  7730.                 }
  7731.                 $fp @fsockopen($url_parts['host']$url_parts['port']$errno$errstr$timeout);
  7732.                 if (!$fp)
  7733.                 {
  7734.                     $this->error = 'fsockopen error: ' $errstr;
  7735.                     $this->success = false;
  7736.                 }
  7737.                 else
  7738.                 {
  7739.                     stream_set_timeout($fp$timeout);
  7740.                     if (isset($url_parts['path']))
  7741.                     {
  7742.                         if (isset($url_parts['query']))
  7743.                         {
  7744.                             $get "$url_parts[path]?$url_parts[query]";
  7745.                         }
  7746.                         else
  7747.                         {
  7748.                             $get $url_parts['path'];
  7749.                         }
  7750.                     }
  7751.                     else
  7752.                     {
  7753.                         $get '/';
  7754.                     }
  7755.                     $out "GET $get HTTP/1.0\r\n";
  7756.                     $out .= "Host: $url_parts[host]\r\n";
  7757.                     $out .= "User-Agent: $useragent\r\n";
  7758.                     if (extension_loaded('zlib'))
  7759.                     {
  7760.                         $out .= "Accept-Encoding: x-gzip,gzip,deflate\r\n";
  7761.                     }
  7762.  
  7763.                     if (isset($url_parts['user']&& isset($url_parts['pass']))
  7764.                     {
  7765.                         $out .= "Authorization: Basic " base64_encode("$url_parts[user]:$url_parts[pass]""\r\n";
  7766.                     }
  7767.                     foreach ($headers as $key => $value)
  7768.                     {
  7769.                         $out .= "$key$value\r\n";
  7770.                     }
  7771.                     $out .= "Connection: Close\r\n\r\n";
  7772.                     fwrite($fp$out);
  7773.  
  7774.                     $info stream_get_meta_data($fp);
  7775.  
  7776.                     $this->headers = '';
  7777.                     while (!$info['eof'&& !$info['timed_out'])
  7778.                     {
  7779.                         $this->headers .= fread($fp1160);
  7780.                         $info stream_get_meta_data($fp);
  7781.                     }
  7782.                     if (!$info['timed_out'])
  7783.                     {
  7784.                         $parser new SimplePie_HTTP_Parser($this->headers);
  7785.                         if ($parser->parse())
  7786.                         {
  7787.                             $this->headers = $parser->headers;
  7788.                             $this->body = $parser->body;
  7789.                             $this->status_code = $parser->status_code;
  7790.                             if ((in_array($this->status_codearray(300301302303307)) || $this->status_code > 307 && $this->status_code < 400&& isset($this->headers['location']&& $this->redirects < $redirects)
  7791.                             {
  7792.                                 $this->redirects++;
  7793.                                 $location SimplePie_Misc::absolutize_url($this->headers['location']$url);
  7794.                                 return $this->SimplePie_File($location$timeout$redirects$headers$useragent$force_fsockopen);
  7795.                             }
  7796.                             if (isset($this->headers['content-encoding']))
  7797.                             {
  7798.                                 // Hey, we act dumb elsewhere, so let's do that here too
  7799.                                 switch (strtolower(trim($this->headers['content-encoding']"\x09\x0A\x0D\x20")))
  7800.                                 {
  7801.                                     case 'gzip':
  7802.                                     case 'x-gzip':
  7803.                                         $decoder new SimplePie_gzdecode($this->body);
  7804.                                         if (!$decoder->parse())
  7805.                                         {
  7806.                                             $this->error = 'Unable to decode HTTP "gzip" stream';
  7807.                                             $this->success = false;
  7808.                                         }
  7809.                                         else
  7810.                                         {
  7811.                                             $this->body = $decoder->data;
  7812.                                         }
  7813.                                         break;
  7814.  
  7815.                                     case 'deflate':
  7816.                                         if (($body gzuncompress($this->body)) === false)
  7817.                                         {
  7818.                                             if (($body gzinflate($this->body)) === false)
  7819.                                             {
  7820.                                                 $this->error = 'Unable to decode HTTP "deflate" stream';
  7821.                                                 $this->success = false;
  7822.                                             }
  7823.                                         }
  7824.                                         $this->body = $body;
  7825.                                         break;
  7826.  
  7827.                                     default:
  7828.                                         $this->error = 'Unknown content coding';
  7829.                                         $this->success = false;
  7830.                                 }
  7831.                             }
  7832.                         }
  7833.                     }
  7834.                     else
  7835.                     {
  7836.                         $this->error = 'fsocket timed out';
  7837.                         $this->success = false;
  7838.                     }
  7839.                     fclose($fp);
  7840.                 }
  7841.             }
  7842.         }
  7843.         else
  7844.         {
  7845.             if (!$this->body = file_get_contents($url))
  7846.             {
  7847.                 $this->error = 'file_get_contents could not read the file';
  7848.                 $this->success = false;
  7849.             }
  7850.         }
  7851.     }
  7852. }
  7853.  
  7854. /**
  7855.  * HTTP Response Parser
  7856.  *
  7857.  * @package SimplePie
  7858.  */
  7859. {
  7860.     /**
  7861.      * HTTP Version
  7862.      *
  7863.      * @access public
  7864.      * @var float 
  7865.      */
  7866.     var $http_version = 0.0;
  7867.  
  7868.     /**
  7869.      * Status code
  7870.      *
  7871.      * @access public
  7872.      * @var int 
  7873.      */
  7874.     var $status_code = 0;
  7875.  
  7876.     /**
  7877.      * Reason phrase
  7878.      *
  7879.      * @access public
  7880.      * @var string 
  7881.      */
  7882.     var $reason = '';
  7883.  
  7884.     /**
  7885.      * Key/value pairs of the headers
  7886.      *
  7887.      * @access public
  7888.      * @var array 
  7889.      */
  7890.     var $headers = array();
  7891.  
  7892.     /**
  7893.      * Body of the response
  7894.      *
  7895.      * @access public
  7896.      * @var string 
  7897.      */
  7898.     var $body = '';
  7899.  
  7900.     /**
  7901.      * Current state of the state machine
  7902.      *
  7903.      * @access private
  7904.      * @var string 
  7905.      */
  7906.     var $state 'http_version';
  7907.  
  7908.     /**
  7909.      * Input data
  7910.      *
  7911.      * @access private
  7912.      * @var string 
  7913.      */
  7914.     var $data '';
  7915.  
  7916.     /**
  7917.      * Input data length (to avoid calling strlen() everytime this is needed)
  7918.      *
  7919.      * @access private
  7920.      * @var int 
  7921.      */
  7922.     var $data_length 0;
  7923.  
  7924.     /**
  7925.      * Current position of the pointer
  7926.      *
  7927.      * @var int 
  7928.      * @access private
  7929.      */
  7930.     var $position 0;
  7931.  
  7932.     /**
  7933.      * Name of the hedaer currently being parsed
  7934.      *
  7935.      * @access private
  7936.      * @var string 
  7937.      */
  7938.     var $name '';
  7939.  
  7940.     /**
  7941.      * Value of the hedaer currently being parsed
  7942.      *
  7943.      * @access private
  7944.      * @var string 
  7945.      */
  7946.     var $value '';
  7947.  
  7948.     /**
  7949.      * Create an instance of the class with the input data
  7950.      *
  7951.      * @access public
  7952.      * @param string $data Input data
  7953.      */
  7954.     function SimplePie_HTTP_Parser($data)
  7955.     {
  7956.         $this->data $data;
  7957.         $this->data_length strlen($this->data);
  7958.     }
  7959.  
  7960.     /**
  7961.      * Parse the input data
  7962.      *
  7963.      * @access public
  7964.      * @return bool true on success, false on failure
  7965.      */
  7966.     function parse()
  7967.     {
  7968.         while ($this->state && $this->state !== 'emit' && $this->has_data())
  7969.         {
  7970.             $state $this->state;
  7971.             $this->$state();
  7972.         }
  7973.         $this->data '';
  7974.         if ($this->state === 'emit' || $this->state === 'body')
  7975.         {
  7976.             return true;
  7977.         }
  7978.         else
  7979.         {
  7980.             $this->http_version = '';
  7981.             $this->status_code = '';
  7982.             $this->reason = '';
  7983.             $this->headers = array();
  7984.             $this->body = '';
  7985.             return false;
  7986.         }
  7987.     }
  7988.  
  7989.     /**
  7990.      * Check whether there is data beyond the pointer
  7991.      *
  7992.      * @access private
  7993.      * @return bool true if there is further data, false if not
  7994.      */
  7995.     function has_data()
  7996.     {
  7997.         return (bool) ($this->position $this->data_length);
  7998.     }
  7999.  
  8000.     /**
  8001.      * See if the next character is LWS
  8002.      *
  8003.      * @access private
  8004.      * @return bool true if the next character is LWS, false if not
  8005.      */
  8006.     function is_linear_whitespace()
  8007.     {
  8008.         return (bool) ($this->data[$this->position=== "\x09"
  8009.             || $this->data[$this->position=== "\x20"
  8010.             || ($this->data[$this->position=== "\x0A"
  8011.                 && isset($this->data[$this->position 1])
  8012.                 && ($this->data[$this->position 1=== "\x09" || $this->data[$this->position 1=== "\x20")));
  8013.     }
  8014.  
  8015.     /**
  8016.      * Parse the HTTP version
  8017.      *
  8018.      * @access private
  8019.      */
  8020.     function http_version()
  8021.     {
  8022.         if (strpos($this->data"\x0A"!== false && strtoupper(substr($this->data05)) === 'HTTP/')
  8023.         {
  8024.             $len strspn($this->data'0123456789.'5);
  8025.             $this->http_version = substr($this->data5$len);
  8026.             $this->position += $len;
  8027.             if (substr_count($this->http_version'.'<= 1)
  8028.             {
  8029.                 $this->http_version = (float) $this->http_version;
  8030.                 $this->position += strspn($this->data"\x09\x20"$this->position);
  8031.                 $this->state 'status';
  8032.             }
  8033.             else
  8034.             {
  8035.                 $this->state false;
  8036.             }
  8037.         }
  8038.         else
  8039.         {
  8040.             $this->state false;
  8041.         }
  8042.     }
  8043.  
  8044.     /**
  8045.      * Parse the status code
  8046.      *
  8047.      * @access private
  8048.      */
  8049.     function status()
  8050.     {
  8051.         if ($len strspn($this->data'0123456789'$this->position))
  8052.         {
  8053.             $this->status_code = (int) substr($this->data$this->position$len);
  8054.             $this->position += $len;
  8055.             $this->state 'reason';
  8056.         }
  8057.         else
  8058.         {
  8059.             $this->state false;
  8060.         }
  8061.     }
  8062.  
  8063.     /**
  8064.      * Parse the reason phrase
  8065.      *
  8066.      * @access private
  8067.      */
  8068.     function reason()
  8069.     {
  8070.         $len strcspn($this->data"\x0A"$this->position);
  8071.         $this->reason = trim(substr($this->data$this->position$len)"\x09\x0D\x20");
  8072.         $this->position += $len 1;
  8073.         $this->state 'new_line';
  8074.     }
  8075.  
  8076.     /**
  8077.      * Deal with a new line, shifting data around as needed
  8078.      *
  8079.      * @access private
  8080.      */
  8081.     function new_line()
  8082.     {
  8083.         $this->value trim($this->value"\x0D\x20");
  8084.         if ($this->name !== '' && $this->value !== '')
  8085.         {
  8086.             $this->name strtolower($this->name);
  8087.             if (isset($this->headers[$this->name]))
  8088.             {
  8089.                 $this->headers[$this->name.= ', ' $this->value;
  8090.             }
  8091.             else
  8092.             {
  8093.                 $this->headers[$this->name$this->value;
  8094.             }
  8095.         }
  8096.         $this->name '';
  8097.         $this->value '';
  8098.         if (substr($this->data[$this->position]02=== "\x0D\x0A")
  8099.         {
  8100.             $this->position += 2;
  8101.             $this->state 'body';
  8102.         }
  8103.         elseif ($this->data[$this->position=== "\x0A")
  8104.         {
  8105.             $this->position++;
  8106.             $this->state 'body';
  8107.         }
  8108.         else
  8109.         {
  8110.             $this->state 'name';
  8111.         }
  8112.     }
  8113.  
  8114.     /**
  8115.      * Parse a header name
  8116.      *
  8117.      * @access private
  8118.      */
  8119.     function name()
  8120.     {
  8121.         $len strcspn($this->data"\x0A:"$this->position);
  8122.         if (isset($this->data[$this->position $len]))
  8123.         {
  8124.             if ($this->data[$this->position $len=== "\x0A")
  8125.             {
  8126.                 $this->position += $len;
  8127.                 $this->state 'new_line';
  8128.             }
  8129.             else
  8130.             {
  8131.                 $this->name substr($this->data$this->position$len);
  8132.                 $this->position += $len 1;
  8133.                 $this->state 'value';
  8134.             }
  8135.         }
  8136.         else
  8137.         {
  8138.             $this->state false;
  8139.         }
  8140.     }
  8141.  
  8142.     /**
  8143.      * Parse LWS, replacing consecutive LWS characters with a single space
  8144.      *
  8145.      * @access private
  8146.      */
  8147.     function linear_whitespace()
  8148.     {
  8149.         do
  8150.         {
  8151.             if (substr($this->data$this->position2=== "\x0D\x0A")
  8152.             {
  8153.                 $this->position += 2;
  8154.             }
  8155.             elseif ($this->data[$this->position=== "\x0A")
  8156.             {
  8157.                 $this->position++;
  8158.             }
  8159.             $this->position += strspn($this->data"\x09\x20"$this->position);
  8160.         while ($this->has_data(&& $this->is_linear_whitespace());
  8161.         $this->value .= "\x20";
  8162.     }
  8163.  
  8164.     /**
  8165.      * See what state to move to while within non-quoted header values
  8166.      *
  8167.      * @access private
  8168.      */
  8169.     function value()
  8170.     {
  8171.         if ($this->is_linear_whitespace())
  8172.         {
  8173.             $this->linear_whitespace();
  8174.         }
  8175.         else
  8176.         {
  8177.             switch ($this->data[$this->position])
  8178.             {
  8179.                 case '"':
  8180.                     $this->position++;
  8181.                     $this->state 'quote';
  8182.                     break;
  8183.  
  8184.                 case "\x0A":
  8185.                     $this->position++;
  8186.                     $this->state 'new_line';
  8187.                     break;
  8188.  
  8189.                 default:
  8190.                     $this->state 'value_char';
  8191.                     break;
  8192.             }
  8193.         }
  8194.     }
  8195.  
  8196.     /**
  8197.      * Parse a header value while outside quotes
  8198.      *
  8199.      * @access private
  8200.      */
  8201.     function value_char()
  8202.     {
  8203.         $len strcspn($this->data"\x09\x20\x0A\""$this->position);
  8204.         $this->value .= substr($this->data$this->position$len);
  8205.         $this->position += $len;
  8206.         $this->state 'value';
  8207.     }
  8208.  
  8209.     /**
  8210.      * See what state to move to while within quoted header values
  8211.      *
  8212.      * @access private
  8213.      */
  8214.     function quote()
  8215.     {
  8216.         if ($this->is_linear_whitespace())
  8217.         {
  8218.             $this->linear_whitespace();
  8219.         }
  8220.         else
  8221.         {
  8222.             switch ($this->data[$this->position])
  8223.             {
  8224.                 case '"':
  8225.                     $this->position++;
  8226.                     $this->state 'value';
  8227.                     break;
  8228.  
  8229.                 case "\x0A":
  8230.                     $this->position++;
  8231.                     $this->state 'new_line';
  8232.                     break;
  8233.  
  8234.                 case '\\':
  8235.                     $this->position++;
  8236.                     $this->state 'quote_escaped';
  8237.                     break;
  8238.  
  8239.                 default:
  8240.                     $this->state 'quote_char';
  8241.                     break;
  8242.             }
  8243.         }
  8244.     }
  8245.  
  8246.     /**
  8247.      * Parse a header value while within quotes
  8248.      *
  8249.      * @access private
  8250.      */
  8251.     function quote_char()
  8252.     {
  8253.         $len strcspn($this->data"\x09\x20\x0A\"\\"$this->position);
  8254.         $this->value .= substr($this->data$this->position$len);
  8255.         $this->position += $len;
  8256.         $this->state 'value';
  8257.     }
  8258.  
  8259.     /**
  8260.      * Parse an escaped character within quotes
  8261.      *
  8262.      * @access private
  8263.      */
  8264.     function quote_escaped()
  8265.     {
  8266.         $this->value .= $this->data[$this->position];
  8267.         $this->position++;
  8268.         $this->state 'quote';
  8269.     }
  8270.  
  8271.     /**
  8272.      * Parse the body
  8273.      *
  8274.      * @access private
  8275.      */
  8276.     function body()
  8277.     {
  8278.         $this->body = substr($this->data$this->position);
  8279.         $this->state 'emit';
  8280.     }
  8281. }
  8282.  
  8283. /**
  8284.  * gzdecode
  8285.  *
  8286.  * @package SimplePie
  8287.  */
  8288. {
  8289.     /**
  8290.      * Compressed data
  8291.      *
  8292.      * @access private
  8293.      * @see gzdecode::$data
  8294.      */
  8295.     var $compressed_data;
  8296.  
  8297.     /**
  8298.      * Size of compressed data
  8299.      *
  8300.      * @access private
  8301.      */
  8302.     var $compressed_size;
  8303.  
  8304.     /**
  8305.      * Minimum size of a valid gzip string
  8306.      *
  8307.      * @access private
  8308.      */
  8309.     var $min_compressed_size 18;
  8310.  
  8311.     /**
  8312.      * Current position of pointer
  8313.      *
  8314.      * @access private
  8315.      */
  8316.     var $position 0;
  8317.  
  8318.     /**
  8319.      * Flags (FLG)
  8320.      *
  8321.      * @access private
  8322.      */
  8323.     var $flags;
  8324.  
  8325.     /**
  8326.      * Uncompressed data
  8327.      *
  8328.      * @access public
  8329.      * @see gzdecode::$compressed_data
  8330.      */
  8331.     var $data;
  8332.  
  8333.     /**
  8334.      * Modified time
  8335.      *
  8336.      * @access public
  8337.      */
  8338.     var $MTIME;
  8339.  
  8340.     /**
  8341.      * Extra Flags
  8342.      *
  8343.      * @access public
  8344.      */
  8345.     var $XFL;
  8346.  
  8347.     /**
  8348.      * Operating System
  8349.      *
  8350.      * @access public
  8351.      */
  8352.     var $OS;
  8353.  
  8354.     /**
  8355.      * Subfield ID 1
  8356.      *
  8357.      * @access public
  8358.      * @see gzdecode::$extra_field
  8359.      * @see gzdecode::$SI2
  8360.      */
  8361.     var $SI1;
  8362.  
  8363.     /**
  8364.      * Subfield ID 2
  8365.      *
  8366.      * @access public
  8367.      * @see gzdecode::$extra_field
  8368.      * @see gzdecode::$SI1
  8369.      */
  8370.     var $SI2;
  8371.  
  8372.     /**
  8373.      * Extra field content
  8374.      *
  8375.      * @access public
  8376.      * @see gzdecode::$SI1
  8377.      * @see gzdecode::$SI2
  8378.      */
  8379.     var $extra_field;
  8380.  
  8381.     /**
  8382.      * Original filename
  8383.      *
  8384.      * @access public
  8385.      */
  8386.     var $filename;
  8387.  
  8388.     /**
  8389.      * Human readable comment
  8390.      *
  8391.      * @access public
  8392.      */
  8393.     var $comment;
  8394.  
  8395.     /**
  8396.      * Don't allow anything to be set
  8397.      *
  8398.      * @access public
  8399.      */
  8400.     function __set($name$value)
  8401.     {
  8402.         trigger_error("Cannot write property $name"E_USER_ERROR);
  8403.     }
  8404.  
  8405.     /**
  8406.      * Set the compressed string and related properties
  8407.      *
  8408.      * @access public
  8409.      */
  8410.     function SimplePie_gzdecode($data)
  8411.     {
  8412.         $this->compressed_data $data;
  8413.         $this->compressed_size strlen($data);
  8414.     }
  8415.  
  8416.     /**
  8417.      * Decode the GZIP stream
  8418.      *
  8419.      * @access public
  8420.      */
  8421.     function parse()
  8422.     {
  8423.         if ($this->compressed_size >= $this->min_compressed_size)
  8424.         {
  8425.             // Check ID1, ID2, and CM
  8426.             if (substr($this->compressed_data03!== "\x1F\x8B\x08")
  8427.             {
  8428.                 return false;
  8429.             }
  8430.  
  8431.             // Get the FLG (FLaGs)
  8432.             $this->flags ord($this->compressed_data[3]);
  8433.  
  8434.             // FLG bits above (1 << 4) are reserved
  8435.             if ($this->flags 0x1F)
  8436.             {
  8437.                 return false;
  8438.             }
  8439.  
  8440.             // Advance the pointer after the above
  8441.             $this->position += 4;
  8442.  
  8443.             // MTIME
  8444.             $mtime substr($this->compressed_data$this->position4);
  8445.             // Reverse the string if we're on a big-endian arch because l is the only signed long and is machine endianness
  8446.             if (current(unpack('S'"\x00\x01")) === 1)
  8447.             {
  8448.                 $mtime strrev($mtime);
  8449.             }
  8450.             $this->MTIME = current(unpack('l'$mtime));
  8451.             $this->position += 4;
  8452.  
  8453.             // Get the XFL (eXtra FLags)
  8454.             $this->XFL = ord($this->compressed_data[$this->position++]);
  8455.  
  8456.             // Get the OS (Operating System)
  8457.             $this->OS = ord($this->compressed_data[$this->position++]);
  8458.  
  8459.             // Parse the FEXTRA
  8460.             if ($this->flags 4)
  8461.             {
  8462.                 // Read subfield IDs
  8463.                 $this->SI1 = $this->compressed_data[$this->position++];
  8464.                 $this->SI2 = $this->compressed_data[$this->position++];
  8465.  
  8466.                 // SI2 set to zero is reserved for future use
  8467.                 if ($this->SI2 === "\x00")
  8468.                 {
  8469.                     return false;
  8470.                 }
  8471.  
  8472.                 // Get the length of the extra field
  8473.                 $len current(unpack('v'substr($this->compressed_data$this->position2)));
  8474.                 $position += 2;
  8475.  
  8476.                 // Check the length of the string is still valid
  8477.                 $this->min_compressed_size += $len 4;
  8478.                 if ($this->compressed_size >= $this->min_compressed_size)
  8479.                 {
  8480.                     // Set the extra field to the given data
  8481.                     $this->extra_field = substr($this->compressed_data$this->position$len);
  8482.                     $this->position += $len;
  8483.                 }
  8484.                 else
  8485.                 {
  8486.                     return false;
  8487.                 }
  8488.             }
  8489.  
  8490.             // Parse the FNAME
  8491.             if ($this->flags 8)
  8492.             {
  8493.                 // Get the length of the filename
  8494.                 $len strcspn($this->compressed_data"\x00"$this->position);
  8495.  
  8496.                 // Check the length of the string is still valid
  8497.                 $this->min_compressed_size += $len 1;
  8498.                 if ($this->compressed_size >= $this->min_compressed_size)
  8499.                 {
  8500.                     // Set the original filename to the given string
  8501.                     $this->filename = substr($this->compressed_data$this->position$len);
  8502.                     $this->position += $len 1;
  8503.                 }
  8504.                 else
  8505.                 {
  8506.                     return false;
  8507.                 }
  8508.             }
  8509.  
  8510.             // Parse the FCOMMENT
  8511.             if ($this->flags 16)
  8512.             {
  8513.                 // Get the length of the comment
  8514.                 $len strcspn($this->compressed_data"\x00"$this->position);
  8515.  
  8516.                 // Check the length of the string is still valid
  8517.                 $this->min_compressed_size += $len 1;
  8518.                 if ($this->compressed_size >= $this->min_compressed_size)
  8519.                 {
  8520.                     // Set the original comment to the given string
  8521.                     $this->comment = substr($this->compressed_data$this->position$len);
  8522.                     $this->position += $len 1;
  8523.                 }
  8524.                 else
  8525.                 {
  8526.                     return false;
  8527.                 }
  8528.             }
  8529.  
  8530.             // Parse the FHCRC
  8531.             if ($this->flags 2)
  8532.             {
  8533.                 // Check the length of the string is still valid
  8534.                 $this->min_compressed_size += $len 2;
  8535.                 if ($this->compressed_size >= $this->min_compressed_size)
  8536.                 {
  8537.                     // Read the CRC
  8538.                     $crc current(unpack('v'substr($this->compressed_data$this->position2)));
  8539.  
  8540.                     // Check the CRC matches
  8541.                     if ((crc32(substr($this->compressed_data0$this->position)) 0xFFFF=== $crc)
  8542.                     {
  8543.                         $this->position += 2;
  8544.                     }
  8545.                     else
  8546.                     {
  8547.                         return false;
  8548.                     }
  8549.                 }
  8550.                 else
  8551.                 {
  8552.                     return false;
  8553.                 }
  8554.             }
  8555.  
  8556.             // Decompress the actual data
  8557.             if (($this->data = gzinflate(substr($this->compressed_data$this->position-8))) === false)
  8558.             {
  8559.                 return false;
  8560.             }
  8561.             else
  8562.             {
  8563.                 $this->position $this->compressed_size 8;
  8564.             }
  8565.  
  8566.             // Check CRC of data
  8567.             $crc current(unpack('V'substr($this->compressed_data$this->position4)));
  8568.             $this->position += 4;
  8569.             /*if (extension_loaded('hash') && sprintf('%u', current(unpack('V', hash('crc32b', $this->data)))) !== sprintf('%u', $crc))
  8570.             {
  8571.                 return false;
  8572.             }*/
  8573.  
  8574.             // Check ISIZE of data
  8575.             $isize current(unpack('V'substr($this->compressed_data$this->position4)));
  8576.             $this->position += 4;
  8577.             if (sprintf('%u'strlen($this->data0xFFFFFFFF!== sprintf('%u'$isize))
  8578.             {
  8579.                 return false;
  8580.             }
  8581.  
  8582.             // Wow, against all odds, we've actually got a valid gzip string
  8583.             return true;
  8584.         }
  8585.         else
  8586.         {
  8587.             return false;
  8588.         }
  8589.     }
  8590. }
  8591.  
  8592. {
  8593.     /**
  8594.      * Don't call the constructor. Please.
  8595.      *
  8596.      * @access private
  8597.      */
  8598.     function SimplePie_Cache()
  8599.     {
  8600.         trigger_error('Please call SimplePie_Cache::create() instead of the constructor'E_USER_ERROR);
  8601.     }
  8602.  
  8603.     /**
  8604.      * Create a new SimplePie_Cache object
  8605.      *
  8606.      * @static
  8607.      * @access public
  8608.      */
  8609.     function create($location$filename$extension)
  8610.     {
  8611.         $location_iri new SimplePie_IRI($location);
  8612.         switch ($location_iri->get_scheme())
  8613.         {
  8614.             case 'mysql':
  8615.                 if (extension_loaded('mysql'))
  8616.                 {
  8617.                     return new SimplePie_Cache_MySQL($location_iri$filename$extension);
  8618.                 }
  8619.                 break;
  8620.  
  8621.             default:
  8622.                 return new SimplePie_Cache_File($location$filename$extension);
  8623.         }
  8624.     }
  8625. }
  8626.  
  8627. {
  8628.     var $location;
  8629.     var $filename;
  8630.     var $extension;
  8631.     var $name;
  8632.  
  8633.     function SimplePie_Cache_File($location$filename$extension)
  8634.     {
  8635.         $this->location = $location;
  8636.         $this->filename = $filename;
  8637.         $this->extension = $extension;
  8638.         $this->name = "$this->location/$this->filename.$this->extension";
  8639.     }
  8640.  
  8641.     function save($data)
  8642.     {
  8643.         if (file_exists($this->name&& is_writeable($this->name|| file_exists($this->location&& is_writeable($this->location))
  8644.         {
  8645.             if (is_a($data'SimplePie'))
  8646.             {
  8647.                 $data $data->data;
  8648.             }
  8649.  
  8650.             $data serialize($data);
  8651.  
  8652.             if (function_exists('file_put_contents'))
  8653.             {
  8654.                 return (bool) file_put_contents($this->name$data);
  8655.             }
  8656.             else
  8657.             {
  8658.                 $fp fopen($this->name'wb');
  8659.                 if ($fp)
  8660.                 {
  8661.                     fwrite($fp$data);
  8662.                     fclose($fp);
  8663.                     return true;
  8664.                 }
  8665.             }
  8666.         }
  8667.         return false;
  8668.     }
  8669.  
  8670.     function load()
  8671.     {
  8672.         if (file_exists($this->name&& is_readable($this->name))
  8673.         {
  8674.             return unserialize(file_get_contents($this->name));
  8675.         }
  8676.         return false;
  8677.     }
  8678.  
  8679.     function mtime()
  8680.     {
  8681.         if (file_exists($this->name))
  8682.         {
  8683.             return filemtime($this->name);
  8684.         }
  8685.         return false;
  8686.     }
  8687.  
  8688.     function touch()
  8689.     {
  8690.         if (file_exists($this->name))
  8691.         {
  8692.             return touch($this->name);
  8693.         }
  8694.         return false;
  8695.     }
  8696.  
  8697.     function unlink()
  8698.     {
  8699.         if (file_exists($this->name))
  8700.         {
  8701.             return unlink($this->name);
  8702.         }
  8703.         return false;
  8704.     }
  8705. }
  8706.  
  8707. {
  8708.     function prepare_simplepie_object_for_cache($data)
  8709.     {
  8710.         $items $data->get_items();
  8711.         $items_by_id array();
  8712.  
  8713.         if (!empty($items))
  8714.         {
  8715.             foreach ($items as $item)
  8716.             {
  8717.                 $items_by_id[$item->get_id()$item;
  8718.             }
  8719.  
  8720.             if (count($items_by_id!== count($items))
  8721.             {
  8722.                 $items_by_id array();
  8723.                 foreach ($items as $item)
  8724.                 {
  8725.                     $items_by_id[$item->get_id(true)$item;
  8726.                 }
  8727.             }
  8728.  
  8729.             if (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]))
  8730.             {
  8731.                 $channel =$data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0];
  8732.             }
  8733.             elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]))
  8734.             {
  8735.                 $channel =$data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0];
  8736.             }
  8737.             elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]))
  8738.             {
  8739.                 $channel =$data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0];
  8740.             }
  8741.             elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0]))
  8742.             {
  8743.                 $channel =$data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0];
  8744.             }
  8745.             else
  8746.             {
  8747.                 $channel null;
  8748.             }
  8749.  
  8750.             if ($channel !== null)
  8751.             {
  8752.                 if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry']))
  8753.                 {
  8754.                     unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry']);
  8755.                 }
  8756.                 if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry']))
  8757.                 {
  8758.                     unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry']);
  8759.                 }
  8760.                 if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']))
  8761.                 {
  8762.                     unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']);
  8763.                 }
  8764.                 if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']))
  8765.                 {
  8766.                     unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']);
  8767.                 }
  8768.                 if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item']))
  8769.                 {
  8770.                     unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item']);
  8771.                 }
  8772.             }
  8773.             if (isset($data->data['items']))
  8774.             {
  8775.                 unset($data->data['items']);
  8776.             }
  8777.             if (isset($data->data['ordered_items']))
  8778.             {
  8779.                 unset($data->data['ordered_items']);
  8780.             }
  8781.         }
  8782.         return array(serialize($data->data)$items_by_id);
  8783.     }
  8784. }
  8785.  
  8786. {
  8787.     var $mysql;
  8788.     var $options;
  8789.     var $id;
  8790.  
  8791.     function SimplePie_Cache_MySQL($mysql_location$name$extension)
  8792.     {
  8793.         $host $mysql_location->get_host();
  8794.         if (SimplePie_Misc::stripos($host'unix('=== && substr($host-1=== ')')
  8795.         {
  8796.             $server ':' substr($host5-1);
  8797.         }
  8798.         else
  8799.         {
  8800.             $server $host;
  8801.             if ($mysql_location->get_port(!== null)
  8802.             {
  8803.                 $server .= ':' $mysql_location->get_port();
  8804.             }
  8805.         }
  8806.  
  8807.         if (strpos($mysql_location->get_userinfo()':'!== false)
  8808.         {
  8809.             list($username$passwordexplode(':'$mysql_location->get_userinfo()2);
  8810.         }
  8811.         else
  8812.         {
  8813.             $username $mysql_location->get_userinfo();
  8814.             $password null;
  8815.         }
  8816.  
  8817.         if ($this->mysql = mysql_connect($server$username$password))
  8818.         {
  8819.             $this->id = $name $extension;
  8820.             $this->options = SimplePie_Misc::parse_str($mysql_location->get_query());
  8821.             if (!isset($this->options['prefix'][0]))
  8822.             {
  8823.                 $this->options['prefix'][0'';
  8824.             }
  8825.  
  8826.             if (mysql_select_db(ltrim($mysql_location->get_path()'/'))
  8827.                 && mysql_query('SET NAMES utf8')
  8828.                 && ($query mysql_unbuffered_query('SHOW TABLES')))
  8829.             {
  8830.                 $db array();
  8831.                 while ($row mysql_fetch_row($query))
  8832.                 {
  8833.                     $db[$row[0];
  8834.                 }
  8835.  
  8836.                 if (!in_array($this->options['prefix'][0'cache_data'$db))
  8837.                 {
  8838.                     if (!mysql_query('CREATE TABLE `' $this->options['prefix'][0'cache_data` (`id` TEXT CHARACTER SET utf8 NOT NULL, `items` SMALLINT NOT NULL DEFAULT 0, `data` BLOB NOT NULL, `mtime` INT UNSIGNED NOT NULL, UNIQUE (`id`(125)))'))
  8839.                     {
  8840.                         $this->mysql = null;
  8841.                     }
  8842.                 }
  8843.  
  8844.                 if (!in_array($this->options['prefix'][0'items'$db))
  8845.                 {
  8846.                     if (!mysql_query('CREATE TABLE `' $this->options['prefix'][0'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` TEXT CHARACTER SET utf8 NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))'))
  8847.                     {
  8848.                         $this->mysql = null;
  8849.                     }
  8850.                 }
  8851.             }
  8852.             else
  8853.             {
  8854.                 $this->mysql = null;
  8855.             }
  8856.         }
  8857.     }
  8858.  
  8859.     function save($data)
  8860.     {
  8861.         if ($this->mysql)
  8862.         {
  8863.             $feed_id "'" mysql_real_escape_string($this->id"'";
  8864.  
  8865.             if (is_a($data'SimplePie'))
  8866.             {
  8867.                 if (SIMPLEPIE_PHP5)
  8868.                 {
  8869.                     // This keyword needs to defy coding standards for PHP4 compatibility
  8870.                     $data clone($data);
  8871.                 }
  8872.  
  8873.                 $prepared $this->prepare_simplepie_object_for_cache($data);
  8874.  
  8875.                 if ($query mysql_query('SELECT `id` FROM `' $this->options['prefix'][0'cache_data` WHERE `id` = ' $feed_id$this->mysql))
  8876.                 {
  8877.                     if (mysql_num_rows($query))
  8878.                     {
  8879.                         $items count($prepared[1]);
  8880.                         if ($items)
  8881.                         {
  8882.                             $sql 'UPDATE `' $this->options['prefix'][0'cache_data` SET `items` = ' $items ', `data` = \'' mysql_real_escape_string($prepared[0]'\', `mtime` = ' time(' WHERE `id` = ' $feed_id;
  8883.                         }
  8884.                         else
  8885.                         {
  8886.                             $sql 'UPDATE `' $this->options['prefix'][0'cache_data` SET `data` = \'' mysql_real_escape_string($prepared[0]'\', `mtime` = ' time(' WHERE `id` = ' $feed_id;
  8887.                         }
  8888.  
  8889.                         if (!mysql_query($sql$this->mysql))
  8890.                         {
  8891.                             return false;
  8892.                         }
  8893.                     }
  8894.                     elseif (!mysql_query('INSERT INTO `' $this->options['prefix'][0'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(' $feed_id ', ' count($prepared[1]', \'' mysql_real_escape_string($prepared[0]'\', ' time(')'$this->mysql))
  8895.                     {
  8896.                         return false;
  8897.                     }
  8898.  
  8899.                     $ids array_keys($prepared[1]);
  8900.                     if (!empty($ids))
  8901.                     {
  8902.                         foreach ($ids as $id)
  8903.                         {
  8904.                             $database_ids[mysql_real_escape_string($id);
  8905.                         }
  8906.  
  8907.                         if ($query mysql_unbuffered_query('SELECT `id` FROM `' $this->options['prefix'][0'items` WHERE `id` = \'' implode('\' OR `id` = \''$database_ids'\' AND `feed_id` = ' $feed_id$this->mysql))
  8908.                         {
  8909.                             $existing_ids array();
  8910.                             while ($row mysql_fetch_row($query))
  8911.                             {
  8912.                                 $existing_ids[$row[0];
  8913.                             }
  8914.  
  8915.                             $new_ids array_diff($ids$existing_ids);
  8916.  
  8917.                             foreach ($new_ids as $new_id)
  8918.                             {
  8919.                                 if (!($date $prepared[1][$new_id]->get_date('U')))
  8920.                                 {
  8921.                                     $date time();
  8922.                                 }
  8923.  
  8924.                                 if (!mysql_query('INSERT INTO `' $this->options['prefix'][0'items` (`feed_id`, `id`, `data`, `posted`) VALUES(' $feed_id ', \'' mysql_real_escape_string($new_id'\', \'' mysql_real_escape_string(serialize($prepared[1][$new_id]->data)) '\', ' $date ')'$this->mysql))
  8925.                                 {
  8926.                                     return false;
  8927.                                 }
  8928.                             }
  8929.                             return true;
  8930.                         }
  8931.                     }
  8932.                     else
  8933.                     {
  8934.                         return true;
  8935.                     }
  8936.                 }
  8937.             }
  8938.             elseif ($query mysql_query('SELECT `id` FROM `' $this->options['prefix'][0'cache_data` WHERE `id` = ' $feed_id$this->mysql))
  8939.             {
  8940.                 if (mysql_num_rows($query))
  8941.                 {
  8942.                     if (mysql_query('UPDATE `' $this->options['prefix'][0'cache_data` SET `items` = 0, `data` = \'' mysql_real_escape_string(serialize($data)) '\', `mtime` = ' time(' WHERE `id` = ' $feed_id$this->mysql))
  8943.                     {
  8944.                         return true;
  8945.                     }
  8946.                 }
  8947.                 elseif (mysql_query('INSERT INTO `' $this->options['prefix'][0'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(\'' mysql_real_escape_string($this->id'\', 0, \'' mysql_real_escape_string(serialize($data)) '\', ' time(')'$this->mysql))
  8948.                 {
  8949.                     return true;
  8950.                 }
  8951.             }
  8952.         }
  8953.         return false;
  8954.     }
  8955.  
  8956.     function load()
  8957.     {
  8958.         if ($this->mysql && ($query mysql_query('SELECT `items`, `data` FROM `' $this->options['prefix'][0'cache_data` WHERE `id` = \'' mysql_real_escape_string($this->id"'"$this->mysql)) && ($row mysql_fetch_row($query)))
  8959.         {
  8960.             $data unserialize($row[1]);
  8961.  
  8962.             if (isset($this->options['items'][0]))
  8963.             {
  8964.                 $items = (int) $this->options['items'][0];
  8965.             }
  8966.             else
  8967.             {
  8968.                 $items = (int) $row[0];
  8969.             }
  8970.  
  8971.             if ($items !== 0)
  8972.             {
  8973.                 if (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]))
  8974.                 {
  8975.                     $feed =$data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0];
  8976.                 }
  8977.                 elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]))
  8978.                 {
  8979.                     $feed =$data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0];
  8980.                 }
  8981.                 elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]))
  8982.                 {
  8983.                     $feed =$data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0];
  8984.                 }
  8985.                 elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]))
  8986.                 {
  8987.                     $feed =$data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0];
  8988.                 }
  8989.                 else
  8990.                 {
  8991.                     $feed null;
  8992.                 }
  8993.  
  8994.                 if ($feed !== null)
  8995.                 {
  8996.                     $sql 'SELECT `data` FROM `' $this->options['prefix'][0'items` WHERE `feed_id` = \'' mysql_real_escape_string($this->id'\' ORDER BY `posted` DESC';
  8997.                     if ($items 0)
  8998.                     {
  8999.                         $sql .= ' LIMIT ' $items;
  9000.                     }
  9001.  
  9002.                     if ($query mysql_unbuffered_query($sql$this->mysql))
  9003.                     {
  9004.                         while ($row mysql_fetch_row($query))
  9005.                         {
  9006.                             $feed['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'][unserialize($row[0]);
  9007.                         }
  9008.                     }
  9009.                     else
  9010.                     {
  9011.                         return false;
  9012.                     }
  9013.                 }
  9014.             }
  9015.             return $data;
  9016.         }
  9017.         return false;
  9018.     }
  9019.  
  9020.     function mtime()
  9021.     {
  9022.         if ($this->mysql && ($query mysql_query('SELECT `mtime` FROM `' $this->options['prefix'][0'cache_data` WHERE `id` = \'' mysql_real_escape_string($this->id"'"$this->mysql)) && ($row mysql_fetch_row($query)))
  9023.         {
  9024.             return $row[0];
  9025.         }
  9026.         else
  9027.         {
  9028.             return false;
  9029.         }
  9030.     }
  9031.  
  9032.     function touch()
  9033.     {
  9034.         if ($this->mysql && ($query mysql_query('UPDATE `' $this->options['prefix'][0'cache_data` SET `mtime` = ' time(' WHERE `id` = \'' mysql_real_escape_string($this->id"'"$this->mysql)) && mysql_affected_rows($this->mysql))
  9035.         {
  9036.             return true;
  9037.         }
  9038.         else
  9039.         {
  9040.             return false;
  9041.         }
  9042.     }
  9043.  
  9044.     function unlink()
  9045.     {
  9046.         if ($this->mysql && ($query mysql_query('DELETE FROM `' $this->options['prefix'][0'cache_data` WHERE `id` = \'' mysql_real_escape_string($this->id"'"$this->mysql)) && ($query2 mysql_query('DELETE FROM `' $this->options['prefix'][0'items` WHERE `feed_id` = \'' mysql_real_escape_string($this->id"'"$this->mysql)))
  9047.         {
  9048.             return true;
  9049.         }
  9050.         else
  9051.         {
  9052.             return false;
  9053.         }
  9054.     }
  9055. }
  9056.  
  9057. {
  9058.     function time_hms($seconds)
  9059.     {
  9060.         $time '';
  9061.  
  9062.         $hours floor($seconds 3600);
  9063.         $remainder $seconds 3600;
  9064.         if ($hours 0)
  9065.         {
  9066.             $time .= $hours.':';
  9067.         }
  9068.  
  9069.         $minutes floor($remainder 60);
  9070.         $seconds $remainder 60;
  9071.         if ($minutes 10 && $hours 0)
  9072.         {
  9073.             $minutes '0' $minutes;
  9074.         }
  9075.         if ($seconds 10)
  9076.         {
  9077.             $seconds '0' $seconds;
  9078.         }
  9079.  
  9080.         $time .= $minutes.':';
  9081.         $time .= $seconds;
  9082.  
  9083.         return $time;
  9084.     }
  9085.  
  9086.     function absolutize_url($relative$base)
  9087.     {
  9088.         $iri SimplePie_IRI::absolutize(new SimplePie_IRI($base)$relative);
  9089.         return $iri->get_iri();
  9090.     }
  9091.  
  9092.     function remove_dot_segments($input)
  9093.     {
  9094.         $output '';
  9095.         while (strpos($input'./'!== false || strpos($input'/.'!== false || $input === '.' || $input === '..')
  9096.         {
  9097.             // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise,
  9098.             if (strpos($input'../'=== 0)
  9099.             {
  9100.                 $input substr($input3);
  9101.             }
  9102.             elseif (strpos($input'./'=== 0)
  9103.             {
  9104.                 $input substr($input2);
  9105.             }
  9106.             // 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,
  9107.             elseif (strpos($input'/./'=== 0)
  9108.             {
  9109.                 $input substr_replace($input'/'03);
  9110.             }
  9111.             elseif ($input === '/.')
  9112.             {
  9113.                 $input '/';
  9114.             }
  9115.             // 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,
  9116.             elseif (strpos($input'/../'=== 0)
  9117.             {
  9118.                 $input substr_replace($input'/'04);
  9119.                 $output substr_replace($output''strrpos($output'/'));
  9120.             }
  9121.             elseif ($input === '/..')
  9122.             {
  9123.                 $input '/';
  9124.                 $output substr_replace($output''strrpos($output'/'));
  9125.             }
  9126.             // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise,
  9127.             elseif ($input === '.' || $input === '..')
  9128.             {
  9129.                 $input '';
  9130.             }
  9131.             // 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
  9132.             elseif (($pos strpos($input'/'1)) !== false)
  9133.             {
  9134.                 $output .= substr($input0$pos);
  9135.                 $input substr_replace($input''0$pos);
  9136.             }
  9137.             else
  9138.             {
  9139.                 $output .= $input;
  9140.                 $input '';
  9141.             }
  9142.         }
  9143.         return $output $input;
  9144.     }
  9145.  
  9146.     function get_element($realname$string)
  9147.     {
  9148.         $return array();
  9149.         $name preg_quote($realname'/');
  9150.         if (preg_match_all("/<($name)SIMPLEPIE_PCRE_HTML_ATTRIBUTE "(>(.*)<\/$name>|(\/)?>)/siU"$string$matchesPREG_SET_ORDER PREG_OFFSET_CAPTURE))
  9151.         {
  9152.             for ($i 0$total_matches count($matches)$i $total_matches$i++)
  9153.             {
  9154.                 $return[$i]['tag'$realname;
  9155.                 $return[$i]['full'$matches[$i][0][0];
  9156.                 $return[$i]['offset'$matches[$i][0][1];
  9157.                 if (strlen($matches[$i][3][0]<= 2)
  9158.                 {
  9159.                     $return[$i]['self_closing'true;
  9160.                 }
  9161.                 else
  9162.                 {
  9163.                     $return[$i]['self_closing'false;
  9164.                     $return[$i]['content'$matches[$i][4][0];
  9165.                 }
  9166.                 $return[$i]['attribs'array();
  9167.                 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' '$attribsPREG_SET_ORDER))
  9168.                 {
  9169.                     for ($j 0$total_attribs count($attribs)$j $total_attribs$j++)
  9170.                     {
  9171.                         if (count($attribs[$j]=== 2)
  9172.                         {
  9173.                             $attribs[$j][2$attribs[$j][1];
  9174.                         }
  9175.                         $return[$i]['attribs'][strtolower($attribs[$j][1])]['data'SimplePie_Misc::entities_decode(end($attribs[$j])'UTF-8');
  9176.                     }
  9177.                 }
  9178.             }
  9179.         }
  9180.         return $return;
  9181.     }
  9182.  
  9183.     function element_implode($element)
  9184.     {
  9185.         $full "<$element[tag]";
  9186.         foreach ($element['attribs'as $key => $value)
  9187.         {
  9188.             $key strtolower($key);
  9189.             $full .= " $key=\"htmlspecialchars($value['data']'"';
  9190.         }
  9191.         if ($element['self_closing'])
  9192.         {
  9193.             $full .= ' />';
  9194.         }
  9195.         else
  9196.         {
  9197.             $full .= ">$element[content]</$element[tag]>";
  9198.         }
  9199.         return $full;
  9200.     }
  9201.  
  9202.     function error($message$level$file$line)
  9203.     {
  9204.         if ((ini_get('error_reporting'$level0)
  9205.         {
  9206.             switch ($level)
  9207.             {
  9208.                 case E_USER_ERROR:
  9209.                     $note 'PHP Error';
  9210.                     break;
  9211.                 case E_USER_WARNING:
  9212.                     $note 'PHP Warning';
  9213.                     break;
  9214.                 case E_USER_NOTICE:
  9215.                     $note 'PHP Notice';
  9216.                     break;
  9217.                 default:
  9218.                     $note 'Unknown Error';
  9219.                     break;
  9220.             }
  9221.             error_log("$note$message in $file on line $line"0);
  9222.         }
  9223.         return $message;
  9224.     }
  9225.  
  9226.     /**
  9227.      * If a file has been cached, retrieve and display it.
  9228.      *
  9229.      * This is most useful for caching images (get_favicon(), etc.),
  9230.      * however it works for all cached files.  This WILL NOT display ANY
  9231.      * file/image/page/whatever, but rather only display what has already
  9232.      * been cached by SimplePie.
  9233.      *
  9234.      * @access public
  9235.      * @see SimplePie::get_favicon()
  9236.      * @param str $identifier_url URL that is used to identify the content.
  9237.      *  This may or may not be the actual URL of the live content.
  9238.      * @param str $cache_location Location of SimplePie's cache.  Defaults
  9239.      *  to './cache'.
  9240.      * @param str $cache_extension The file extension that the file was
  9241.      *  cached with.  Defaults to 'spc'.
  9242.      * @param str $cache_class Name of the cache-handling class being used
  9243.      *  in SimplePie.  Defaults to 'SimplePie_Cache', and should be left
  9244.      *  as-is unless you've overloaded the class.
  9245.      * @param str $cache_name_function Obsolete. Exists for backwards
  9246.      *  compatibility reasons only.
  9247.      */
  9248.     function display_cached_file($identifier_url$cache_location './cache'$cache_extension 'spc'$cache_class 'SimplePie_Cache'$cache_name_function 'md5')
  9249.     {
  9250.         $cache call_user_func(array($cache_class'create')$cache_location$identifier_url$cache_extension);
  9251.  
  9252.         if ($file $cache->load())
  9253.         {
  9254.             if (isset($file['headers']['content-type']))
  9255.             {
  9256.                 header('Content-type:' $file['headers']['content-type']);
  9257.             }
  9258.             else
  9259.             {
  9260.                 header('Content-type: application/octet-stream');
  9261.             }
  9262.             header('Expires: ' gmdate('D, d M Y H:i:s'time(604800' GMT')// 7 days
  9263.             echo $file['body'];
  9264.             exit;
  9265.         }
  9266.  
  9267.         die('Cached file for ' $identifier_url ' cannot be found.');
  9268.     }
  9269.  
  9270.     function fix_protocol($url$http 1)
  9271.     {
  9272.         $url SimplePie_Misc::normalize_url($url);
  9273.         $parsed SimplePie_Misc::parse_url($url);
  9274.         if ($parsed['scheme'!== '' && $parsed['scheme'!== 'http' && $parsed['scheme'!== 'https')
  9275.         {
  9276.             return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http'$parsed['authority']$parsed['path']$parsed['query']$parsed['fragment'])$http);
  9277.         }
  9278.  
  9279.         if ($parsed['scheme'=== '' && $parsed['authority'=== '' && !file_exists($url))
  9280.         {
  9281.             return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http'$parsed['path']''$parsed['query']$parsed['fragment'])$http);
  9282.         }
  9283.  
  9284.         if ($http === && $parsed['scheme'!== '')
  9285.         {
  9286.             return "feed:$url";
  9287.         }
  9288.         elseif ($http === && strtolower($parsed['scheme']=== 'http')
  9289.         {
  9290.             return substr_replace($url'podcast'04);
  9291.         }
  9292.         elseif ($http === && strtolower($parsed['scheme']=== 'http')
  9293.         {
  9294.             return substr_replace($url'itpc'04);
  9295.         }
  9296.         else
  9297.         {
  9298.             return $url;
  9299.         }
  9300.     }
  9301.  
  9302.     function parse_url($url)
  9303.     {
  9304.         $iri new SimplePie_IRI($url);
  9305.         return array(
  9306.             'scheme' => (string) $iri->get_scheme(),
  9307.             'authority' => (string) $iri->get_authority(),
  9308.             'path' => (string) $iri->get_path(),
  9309.             'query' => (string) $iri->get_query(),
  9310.             'fragment' => (string) $iri->get_fragment()
  9311.         );
  9312.     }
  9313.  
  9314.     function compress_parse_url($scheme ''$authority ''$path ''$query ''$fragment '')
  9315.     {
  9316.         $iri new SimplePie_IRI('');
  9317.         $iri->set_scheme($scheme);
  9318.         $iri->set_authority($authority);
  9319.         $iri->set_path($path);
  9320.         $iri->set_query($query);
  9321.         $iri->set_fragment($fragment);
  9322.         return $iri->get_iri();
  9323.     }
  9324.  
  9325.     function normalize_url($url)
  9326.     {
  9327.         $iri new SimplePie_IRI($url);
  9328.         return $iri->get_iri();
  9329.     }
  9330.  
  9331.     function percent_encoding_normalization($match)
  9332.     {
  9333.         $integer hexdec($match[1]);
  9334.         if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E)
  9335.         {
  9336.             return chr($integer);
  9337.         }
  9338.         else
  9339.         {
  9340.             return strtoupper($match[0]);
  9341.         }
  9342.     }
  9343.  
  9344.     /**
  9345.      * Remove bad UTF-8 bytes
  9346.      *
  9347.      * PCRE Pattern to locate bad bytes in a UTF-8 string comes from W3C
  9348.      * FAQ: Multilingual Forms (modified to include full ASCII range)
  9349.      *
  9350.      * @author Geoffrey Sneddon
  9351.      * @see http://www.w3.org/International/questions/qa-forms-utf-8
  9352.      * @param string $str String to remove bad UTF-8 bytes from
  9353.      * @return string UTF-8 string
  9354.      */
  9355.     function utf8_bad_replace($str)
  9356.     {
  9357.         if (function_exists('iconv'&& ($return @iconv('UTF-8''UTF-8//IGNORE'$str)))
  9358.         {
  9359.             return $return;
  9360.         }
  9361.         elseif (function_exists('mb_convert_encoding'&& ($return @mb_convert_encoding($str'UTF-8''UTF-8')))
  9362.         {
  9363.             return $return;
  9364.         }
  9365.         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))
  9366.         {
  9367.             return implode("\xEF\xBF\xBD"$matches[0]);
  9368.         }
  9369.         elseif ($str !== '')
  9370.         {
  9371.             return "\xEF\xBF\xBD";
  9372.         }
  9373.         else
  9374.         {
  9375.             return '';
  9376.         }
  9377.     }
  9378.  
  9379.     /**
  9380.      * Converts a Windows-1252 encoded string to a UTF-8 encoded string
  9381.      *
  9382.      * @static
  9383.      * @access public
  9384.      * @param string $string Windows-1252 encoded string
  9385.      * @return string UTF-8 encoded string
  9386.      */
  9387.     function windows_1252_to_utf8($string)
  9388.     {
  9389.         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");
  9390.  
  9391.         return strtr($string$convert_table);
  9392.     }
  9393.  
  9394.     function change_encoding($data$input$output)
  9395.     {
  9396.         $input SimplePie_Misc::encoding($input);
  9397.         $output SimplePie_Misc::encoding($output);
  9398.  
  9399.         // We fail to fail on non US-ASCII bytes
  9400.         if ($input === 'US-ASCII')
  9401.         {
  9402.             static $non_ascii_octects '';
  9403.             if (!$non_ascii_octects)
  9404.             {
  9405.                 for ($i 0x80$i <= 0xFF$i++)
  9406.                 {
  9407.                     $non_ascii_octects .= chr($i);
  9408.                 }
  9409.             }
  9410.             $data substr($data0strcspn($data$non_ascii_octects));
  9411.         }
  9412.  
  9413.         // This is first, as behaviour of this is completely predictable
  9414.         if ($input === 'Windows-1252' && $output === 'UTF-8')
  9415.         {
  9416.             return SimplePie_Misc::windows_1252_to_utf8($data);
  9417.         }
  9418.         // This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported).
  9419.         elseif (function_exists('mb_convert_encoding'&& @mb_convert_encoding("\x80"'UTF-16BE'$input!== "\x00\x80" && ($return @mb_convert_encoding($data$output$input)))
  9420.         {
  9421.             return $return;
  9422.         }
  9423.         // This is last, as behaviour of this varies with OS userland and PHP version
  9424.         elseif (function_exists('iconv'&& ($return @iconv($input$output$data)))
  9425.         {
  9426.             return $return;
  9427.         }
  9428.         // If we can't do anything, just fail
  9429.         else
  9430.         {
  9431.             return false;
  9432.         }
  9433.     }
  9434.  
  9435.     function encoding($charset)
  9436.     {
  9437.         // Normalization from UTS #22
  9438.         switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/''\1'$charset)))
  9439.         {
  9440.             case 'adobestandardencoding':
  9441.             case 'csadobestandardencoding':
  9442.                 return 'Adobe-Standard-Encoding';
  9443.  
  9444.             case 'adobesymbolencoding':
  9445.             case 'cshppsmath':
  9446.                 return 'Adobe-Symbol-Encoding';
  9447.  
  9448.             case 'ami1251':
  9449.             case 'amiga1251':
  9450.                 return 'Amiga-1251';
  9451.  
  9452.             case 'ansix31101983':
  9453.             case 'csat5001983':
  9454.             case 'csiso99naplps':
  9455.             case 'isoir99':
  9456.             case 'naplps':
  9457.                 return 'ANSI_X3.110-1983';
  9458.  
  9459.             case 'arabic7':
  9460.             case 'asmo449':
  9461.             case 'csiso89asmo449':
  9462.             case 'iso9036':
  9463.             case 'isoir89':
  9464.                 return 'ASMO_449';
  9465.  
  9466.             case 'big5':
  9467.             case 'csbig5':
  9468.             case 'xxbig5':
  9469.                 return 'Big5';
  9470.  
  9471.             case 'big5hkscs':
  9472.                 return 'Big5-HKSCS';
  9473.  
  9474.             case 'bocu1':
  9475.             case 'csbocu1':
  9476.                 return 'BOCU-1';
  9477.  
  9478.             case 'brf':
  9479.             case 'csbrf':
  9480.                 return 'BRF';
  9481.  
  9482.             case 'bs4730':
  9483.             case 'csiso4unitedkingdom':
  9484.             case 'gb':
  9485.             case 'iso646gb':
  9486.             case 'isoir4':
  9487.             case 'uk':
  9488.                 return 'BS_4730';
  9489.  
  9490.             case 'bsviewdata':
  9491.             case 'csiso47bsviewdata':
  9492.             case 'isoir47':
  9493.                 return 'BS_viewdata';
  9494.  
  9495.             case 'cesu8':
  9496.             case 'cscesu8':
  9497.                 return 'CESU-8';
  9498.  
  9499.             case 'ca':
  9500.             case 'csa71':
  9501.             case 'csaz243419851':
  9502.             case 'csiso121canadian1':
  9503.             case 'iso646ca':
  9504.             case 'isoir121':
  9505.                 return 'CSA_Z243.4-1985-1';
  9506.  
  9507.             case 'csa72':
  9508.             case 'csaz243419852':
  9509.             case 'csiso122canadian2':
  9510.             case 'iso646ca2':
  9511.             case 'isoir122':
  9512.                 return 'CSA_Z243.4-1985-2';
  9513.  
  9514.             case 'csaz24341985gr':
  9515.             case 'csiso123csaz24341985gr':
  9516.             case 'isoir123':
  9517.                 return 'CSA_Z243.4-1985-gr';
  9518.  
  9519.             case 'csiso139csn369103':
  9520.             case 'csn369103':
  9521.             case 'isoir139':
  9522.                 return 'CSN_369103';
  9523.  
  9524.             case 'csdecmcs':
  9525.             case 'dec':
  9526.             case 'decmcs':
  9527.                 return 'DEC-MCS';
  9528.  
  9529.             case 'csiso21german':
  9530.             case 'de':
  9531.             case 'din66003':
  9532.             case 'iso646de':
  9533.             case 'isoir21':
  9534.                 return 'DIN_66003';
  9535.  
  9536.             case 'csdkus':
  9537.             case 'dkus':
  9538.                 return 'dk-us';
  9539.  
  9540.             case 'csiso646danish':
  9541.             case 'dk':
  9542.             case 'ds2089':
  9543.             case 'iso646dk':
  9544.                 return 'DS_2089';
  9545.  
  9546.             case 'csibmebcdicatde':
  9547.             case 'ebcdicatde':
  9548.                 return 'EBCDIC-AT-DE';
  9549.  
  9550.             case 'csebcdicatdea':
  9551.             case 'ebcdicatdea':
  9552.                 return 'EBCDIC-AT-DE-A';
  9553.  
  9554.             case 'csebcdiccafr':
  9555.             case 'ebcdiccafr':
  9556.                 return 'EBCDIC-CA-FR';
  9557.  
  9558.             case 'csebcdicdkno':
  9559.             case 'ebcdicdkno':
  9560.                 return 'EBCDIC-DK-NO';
  9561.  
  9562.             case 'csebcdicdknoa':
  9563.             case 'ebcdicdknoa':
  9564.                 return 'EBCDIC-DK-NO-A';
  9565.  
  9566.             case 'csebcdices':
  9567.             case 'ebcdices':
  9568.                 return 'EBCDIC-ES';
  9569.  
  9570.             case 'csebcdicesa':
  9571.             case 'ebcdicesa':
  9572.                 return 'EBCDIC-ES-A';
  9573.  
  9574.             case 'csebcdicess':
  9575.             case 'ebcdicess':
  9576.                 return 'EBCDIC-ES-S';
  9577.  
  9578.             case 'csebcdicfise':
  9579.             case 'ebcdicfise':
  9580.                 return 'EBCDIC-FI-SE';
  9581.  
  9582.             case 'csebcdicfisea':
  9583.             case 'ebcdicfisea':
  9584.                 return 'EBCDIC-FI-SE-A';
  9585.  
  9586.             case 'csebcdicfr':
  9587.             case 'ebcdicfr':
  9588.                 return 'EBCDIC-FR';
  9589.  
  9590.             case 'csebcdicit':
  9591.             case 'ebcdicit':
  9592.                 return 'EBCDIC-IT';
  9593.  
  9594.             case 'csebcdicpt':
  9595.             case 'ebcdicpt':
  9596.                 return 'EBCDIC-PT';
  9597.  
  9598.             case 'csebcdicuk':
  9599.             case 'ebcdicuk':
  9600.                 return 'EBCDIC-UK';
  9601.  
  9602.             case 'csebcdicus':
  9603.             case 'ebcdicus':
  9604.                 return 'EBCDIC-US';
  9605.  
  9606.             case 'csiso111ecmacyrillic':
  9607.             case 'ecmacyrillic':
  9608.             case 'isoir111':
  9609.             case 'koi8e':
  9610.                 return 'ECMA-cyrillic';
  9611.  
  9612.             case 'csiso17spanish':
  9613.             case 'es':
  9614.             case 'iso646es':
  9615.             case 'isoir17':
  9616.                 return 'ES';
  9617.  
  9618.             case 'csiso85spanish2':
  9619.             case 'es2':
  9620.             case 'iso646es2':
  9621.             case 'isoir85':
  9622.                 return 'ES2';
  9623.  
  9624.             case 'cseucfixwidjapanese':
  9625.             case 'extendedunixcodefixedwidthforjapanese':
  9626.                 return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
  9627.  
  9628.             case 'cseucpkdfmtjapanese':
  9629.             case 'eucjp':
  9630.             case 'extendedunixcodepackedformatforjapanese':
  9631.                 return 'Extended_UNIX_Code_Packed_Format_for_Japanese';
  9632.  
  9633.             case 'gb18030':
  9634.                 return 'GB18030';
  9635.  
  9636.             case 'chinese':
  9637.             case 'cp936':
  9638.             case 'csgb2312':
  9639.             case 'csiso58gb231280':
  9640.             case 'gb2312':
  9641.             case 'gb231280':
  9642.             case 'gbk':
  9643.             case 'isoir58':
  9644.             case 'ms936':
  9645.             case 'windows936':
  9646.                 return 'GBK';
  9647.  
  9648.             case 'cn':
  9649.             case 'csiso57gb1988':
  9650.             case 'gb198880':
  9651.             case 'iso646cn':
  9652.             case 'isoir57':
  9653.                 return 'GB_1988-80';
  9654.  
  9655.             case 'csiso153gost1976874':
  9656.             case 'gost1976874':
  9657.             case 'isoir153':
  9658.             case 'stsev35888':
  9659.                 return 'GOST_19768-74';
  9660.  
  9661.             case 'csiso150':
  9662.             case 'csiso150greekccitt':
  9663.             case 'greekccitt':
  9664.             case 'isoir150':
  9665.                 return 'greek-ccitt';
  9666.  
  9667.             case 'csiso88greek7':
  9668.             case 'greek7':
  9669.             case 'isoir88':
  9670.                 return 'greek7';
  9671.  
  9672.             case 'csiso18greek7old':
  9673.             case 'greek7old':
  9674.             case 'isoir18':
  9675.                 return 'greek7-old';
  9676.  
  9677.             case 'cshpdesktop':
  9678.             case 'hpdesktop':
  9679.                 return 'HP-DeskTop';
  9680.  
  9681.             case 'cshplegal':
  9682.             case 'hplegal':
  9683.                 return 'HP-Legal';
  9684.  
  9685.             case 'cshpmath8':
  9686.             case 'hpmath8':
  9687.                 return 'HP-Math8';
  9688.  
  9689.             case 'cshppifont':
  9690.             case 'hppifont':
  9691.                 return 'HP-Pi-font';
  9692.  
  9693.             case 'cshproman8':
  9694.             case 'hproman8':
  9695.             case 'r8':
  9696.             case 'roman8':
  9697.                 return 'hp-roman8';
  9698.  
  9699.             case 'hzgb2312':
  9700.                 return 'HZ-GB-2312';
  9701.  
  9702.             case 'csibmsymbols':
  9703.             case 'ibmsymbols':
  9704.                 return 'IBM-Symbols';
  9705.  
  9706.             case 'csibmthai':
  9707.             case 'ibmthai':
  9708.                 return 'IBM-Thai';
  9709.  
  9710.             case 'ccsid858':
  9711.             case 'cp858':
  9712.             case 'ibm858':
  9713.             case 'pcmultilingual850euro':
  9714.                 return 'IBM00858';
  9715.  
  9716.             case 'ccsid924':
  9717.             case 'cp924':
  9718.             case 'ebcdiclatin9euro':
  9719.             case 'ibm924':
  9720.                 return 'IBM00924';
  9721.  
  9722.             case 'ccsid1140':
  9723.             case 'cp1140':
  9724.             case 'ebcdicus37euro':
  9725.             case 'ibm1140':
  9726.                 return 'IBM01140';
  9727.  
  9728.             case 'ccsid1141':
  9729.             case 'cp1141':
  9730.             case 'ebcdicde273euro':
  9731.             case 'ibm1141':
  9732.                 return 'IBM01141';
  9733.  
  9734.             case 'ccsid1142':
  9735.             case 'cp1142':
  9736.             case 'ebcdicdk277euro':
  9737.             case 'ebcdicno277euro':
  9738.             case 'ibm1142':
  9739.                 return 'IBM01142';
  9740.  
  9741.             case 'ccsid1143':
  9742.             case 'cp1143':
  9743.             case 'ebcdicfi278euro':
  9744.             case 'ebcdicse278euro':
  9745.             case 'ibm1143':
  9746.                 return 'IBM01143';
  9747.  
  9748.             case 'ccsid1144':
  9749.             case 'cp1144':
  9750.             case 'ebcdicit280euro':
  9751.             case 'ibm1144':
  9752.                 return 'IBM01144';
  9753.  
  9754.             case 'ccsid1145':
  9755.             case 'cp1145':
  9756.             case 'ebcdices284euro':
  9757.             case 'ibm1145':
  9758.                 return 'IBM01145';
  9759.  
  9760.             case 'ccsid1146':
  9761.             case 'cp1146':
  9762.             case 'ebcdicgb285euro':
  9763.             case 'ibm1146':
  9764.                 return 'IBM01146';
  9765.  
  9766.             case 'ccsid1147':
  9767.             case 'cp1147':
  9768.             case 'ebcdicfr297euro':
  9769.             case 'ibm1147':
  9770.                 return 'IBM01147';
  9771.  
  9772.             case 'ccsid1148':
  9773.             case 'cp1148':
  9774.             case 'ebcdicinternational500euro':
  9775.             case 'ibm1148':
  9776.                 return 'IBM01148';
  9777.  
  9778.             case 'ccsid1149':
  9779.             case 'cp1149':
  9780.             case 'ebcdicis871euro':
  9781.             case 'ibm1149':
  9782.                 return 'IBM01149';
  9783.  
  9784.             case 'cp37':
  9785.             case 'csibm37':
  9786.             case 'ebcdiccpca':
  9787.             case 'ebcdiccpnl':
  9788.             case 'ebcdiccpus':
  9789.             case 'ebcdiccpwt':
  9790.             case 'ibm37':
  9791.                 return 'IBM037';
  9792.  
  9793.             case 'cp38':
  9794.             case 'csibm38':
  9795.             case 'ebcdicint':
  9796.             case 'ibm38':
  9797.                 return 'IBM038';
  9798.  
  9799.             case 'cp273':
  9800.             case 'csibm273':
  9801.             case 'ibm273':
  9802.                 return 'IBM273';
  9803.  
  9804.             case 'cp274':
  9805.             case 'csibm274':
  9806.             case 'ebcdicbe':
  9807.             case 'ibm274':
  9808.                 return 'IBM274';
  9809.  
  9810.             case 'cp275':
  9811.             case 'csibm275':
  9812.             case 'ebcdicbr':
  9813.             case 'ibm275':
  9814.                 return 'IBM275';
  9815.  
  9816.             case 'csibm277':
  9817.             case 'ebcdiccpdk':
  9818.             case 'ebcdiccpno':
  9819.             case 'ibm277':
  9820.                 return 'IBM277';
  9821.  
  9822.             case 'cp278':
  9823.             case 'csibm278':
  9824.             case 'ebcdiccpfi':
  9825.             case 'ebcdiccpse':
  9826.             case 'ibm278':
  9827.                 return 'IBM278';
  9828.  
  9829.             case 'cp280':
  9830.             case 'csibm280':
  9831.             case 'ebcdiccpit':
  9832.             case 'ibm280':
  9833.                 return 'IBM280';
  9834.  
  9835.             case 'cp281':
  9836.             case 'csibm281':
  9837.             case 'ebcdicjpe':
  9838.             case 'ibm281':
  9839.                 return 'IBM281';
  9840.  
  9841.             case 'cp284':
  9842.             case 'csibm284':
  9843.             case 'ebcdiccpes':
  9844.             case 'ibm284':
  9845.                 return 'IBM284';
  9846.  
  9847.             case 'cp285':
  9848.             case 'csibm285':
  9849.             case 'ebcdiccpgb':
  9850.             case 'ibm285':
  9851.                 return 'IBM285';
  9852.  
  9853.             case 'cp290':
  9854.             case 'csibm290':
  9855.             case 'ebcdicjpkana':
  9856.             case 'ibm290':
  9857.                 return 'IBM290';
  9858.  
  9859.             case 'cp297':
  9860.             case 'csibm297':
  9861.             case 'ebcdiccpfr':
  9862.             case 'ibm297':
  9863.                 return 'IBM297';
  9864.  
  9865.             case 'cp420':
  9866.             case 'csibm420':
  9867.             case 'ebcdiccpar1':
  9868.             case 'ibm420':
  9869.                 return 'IBM420';
  9870.  
  9871.             case 'cp423':
  9872.             case 'csibm423':
  9873.             case 'ebcdiccpgr':
  9874.             case 'ibm423':
  9875.                 return 'IBM423';
  9876.  
  9877.             case 'cp424':
  9878.             case 'csibm424':
  9879.             case 'ebcdiccphe':
  9880.             case 'ibm424':
  9881.                 return 'IBM424';
  9882.  
  9883.             case '437':
  9884.             case 'cp437':
  9885.             case 'cspc8codepage437':
  9886.             case 'ibm437':
  9887.                 return 'IBM437';
  9888.  
  9889.             case 'cp500':
  9890.             case 'csibm500':
  9891.             case 'ebcdiccpbe':
  9892.             case 'ebcdiccpch':
  9893.             case 'ibm500':
  9894.                 return 'IBM500';
  9895.  
  9896.             case 'cp775':
  9897.             case 'cspc775baltic':
  9898.             case 'ibm775':
  9899.                 return 'IBM775';
  9900.  
  9901.             case '850':
  9902.             case 'cp850':
  9903.             case 'cspc850multilingual':
  9904.             case 'ibm850':
  9905.                 return 'IBM850';
  9906.  
  9907.             case '851':
  9908.             case 'cp851':
  9909.             case 'csibm851':
  9910.             case 'ibm851':
  9911.                 return 'IBM851';
  9912.  
  9913.             case '852':
  9914.             case 'cp852':
  9915.             case 'cspcp852':
  9916.             case 'ibm852':
  9917.                 return 'IBM852';
  9918.  
  9919.             case '855':
  9920.             case 'cp855':
  9921.             case 'csibm855':
  9922.             case 'ibm855':
  9923.                 return 'IBM855';
  9924.  
  9925.             case '857':
  9926.             case 'cp857':
  9927.             case 'csibm857':
  9928.             case 'ibm857':
  9929.                 return 'IBM857';
  9930.  
  9931.             case '860':
  9932.             case 'cp860':
  9933.             case 'csibm860':
  9934.             case 'ibm860':
  9935.                 return 'IBM860';
  9936.  
  9937.             case '861':
  9938.             case 'cp861':
  9939.             case 'cpis':
  9940.             case 'csibm861':
  9941.             case 'ibm861':
  9942.                 return 'IBM861';
  9943.  
  9944.             case '862':
  9945.             case 'cp862':
  9946.             case 'cspc862latinhebrew':
  9947.             case 'ibm862':
  9948.                 return 'IBM862';
  9949.  
  9950.             case '863':
  9951.             case 'cp863':
  9952.             case 'csibm863':
  9953.             case 'ibm863':
  9954.                 return 'IBM863';
  9955.  
  9956.             case 'cp864':
  9957.             case 'csibm864':
  9958.             case 'ibm864':
  9959.                 return 'IBM864';
  9960.  
  9961.             case '865':
  9962.             case 'cp865':
  9963.             case 'csibm865':
  9964.             case 'ibm865':
  9965.                 return 'IBM865';
  9966.  
  9967.             case '866':
  9968.             case 'cp866':
  9969.             case 'csibm866':
  9970.             case 'ibm866':
  9971.                 return 'IBM866';
  9972.  
  9973.             case 'cp868':
  9974.             case 'cpar':
  9975.             case 'csibm868':
  9976.             case 'ibm868':
  9977.                 return 'IBM868';
  9978.  
  9979.             case '869':
  9980.             case 'cp869':
  9981.             case 'cpgr':
  9982.             case 'csibm869':
  9983.             case 'ibm869':
  9984.                 return 'IBM869';
  9985.  
  9986.             case 'cp870':
  9987.             case 'csibm870':
  9988.             case 'ebcdiccproece':
  9989.             case 'ebcdiccpyu':
  9990.             case 'ibm870':
  9991.                 return 'IBM870';
  9992.  
  9993.             case 'cp871':
  9994.             case 'csibm871':
  9995.             case 'ebcdiccpis':
  9996.             case 'ibm871':
  9997.                 return 'IBM871';
  9998.  
  9999.             case 'cp880':
  10000.             case 'csibm880':
  10001.             case 'ebcdiccyrillic':
  10002.             case 'ibm880':
  10003.                 return 'IBM880';
  10004.  
  10005.             case 'cp891':
  10006.             case 'csibm891':
  10007.             case 'ibm891':
  10008.                 return 'IBM891';
  10009.  
  10010.             case 'cp903':
  10011.             case 'csibm903':
  10012.             case 'ibm903':
  10013.                 return 'IBM903';
  10014.  
  10015.             case '904':
  10016.             case 'cp904':
  10017.             case 'csibbm904':
  10018.             case 'ibm904':
  10019.                 return 'IBM904';
  10020.  
  10021.             case 'cp905':
  10022.             case 'csibm905':
  10023.             case 'ebcdiccptr':
  10024.             case 'ibm905':
  10025.                 return 'IBM905';
  10026.  
  10027.             case 'cp918':
  10028.             case 'csibm918':
  10029.             case 'ebcdiccpar2':
  10030.             case 'ibm918':
  10031.                 return 'IBM918';
  10032.  
  10033.             case 'cp1026':
  10034.             case 'csibm1026':
  10035.             case 'ibm1026':
  10036.                 return 'IBM1026';
  10037.  
  10038.             case 'ibm1047':
  10039.                 return 'IBM1047';
  10040.  
  10041.             case 'csiso143iecp271':
  10042.             case 'iecp271':
  10043.             case 'isoir143':
  10044.                 return 'IEC_P27-1';
  10045.  
  10046.             case 'csiso49inis':
  10047.             case 'inis':
  10048.             case 'isoir49':
  10049.                 return 'INIS';
  10050.  
  10051.             case 'csiso50inis8':
  10052.             case 'inis8':
  10053.             case 'isoir50':
  10054.                 return 'INIS-8';
  10055.  
  10056.             case 'csiso51iniscyrillic':
  10057.             case 'iniscyrillic':
  10058.             case 'isoir51':
  10059.                 return 'INIS-cyrillic';
  10060.  
  10061.             case 'csinvariant':
  10062.             case 'invariant':
  10063.                 return 'INVARIANT';
  10064.  
  10065.             case 'iso2022cn':
  10066.                 return 'ISO-2022-CN';
  10067.  
  10068.             case 'iso2022cnext':
  10069.                 return 'ISO-2022-CN-EXT';
  10070.  
  10071.             case 'csiso2022jp':
  10072.             case 'iso2022jp':
  10073.                 return 'ISO-2022-JP';
  10074.  
  10075.             case 'csiso2022jp2':
  10076.             case 'iso2022jp2':
  10077.                 return 'ISO-2022-JP-2';
  10078.  
  10079.             case 'csiso2022kr':
  10080.             case 'iso2022kr':
  10081.                 return 'ISO-2022-KR';
  10082.  
  10083.             case 'cswindows30latin1':
  10084.             case 'iso88591windows30latin1':
  10085.                 return 'ISO-8859-1-Windows-3.0-Latin-1';
  10086.  
  10087.             case 'cswindows31latin1':
  10088.             case 'iso88591windows31latin1':
  10089.                 return 'ISO-8859-1-Windows-3.1-Latin-1';
  10090.  
  10091.             case 'csisolatin2':
  10092.             case 'iso88592':
  10093.             case 'iso885921987':
  10094.             case 'isoir101':
  10095.             case 'l2':
  10096.             case 'latin2':
  10097.                 return 'ISO-8859-2';
  10098.  
  10099.             case 'cswindows31latin2':
  10100.             case 'iso88592windowslatin2':
  10101.                 return 'ISO-8859-2-Windows-Latin-2';
  10102.  
  10103.             case 'csisolatin3':
  10104.             case 'iso88593':
  10105.             case 'iso885931988':
  10106.             case 'isoir109':
  10107.             case 'l3':
  10108.             case 'latin3':
  10109.                 return 'ISO-8859-3';
  10110.  
  10111.             case 'csisolatin4':
  10112.             case 'iso88594':
  10113.             case 'iso885941988':
  10114.             case 'isoir110':
  10115.             case 'l4':
  10116.             case 'latin4':
  10117.                 return 'ISO-8859-4';
  10118.  
  10119.             case 'csisolatincyrillic':
  10120.             case 'cyrillic':
  10121.             case 'iso88595':
  10122.             case 'iso885951988':
  10123.             case 'isoir144':
  10124.                 return 'ISO-8859-5';
  10125.  
  10126.             case 'arabic':
  10127.             case 'asmo708':
  10128.             case 'csisolatinarabic':
  10129.             case 'ecma114':
  10130.             case 'iso88596':
  10131.             case 'iso885961987':
  10132.             case 'isoir127':
  10133.                 return 'ISO-8859-6';
  10134.  
  10135.             case 'csiso88596e':
  10136.             case 'iso88596e':
  10137.                 return 'ISO-8859-6-E';
  10138.  
  10139.             case 'csiso88596i':
  10140.             case 'iso88596i':
  10141.                 return 'ISO-8859-6-I';
  10142.  
  10143.             case 'csisolatingreek':
  10144.             case 'ecma118':
  10145.             case 'elot928':
  10146.             case 'greek':
  10147.             case 'greek8':
  10148.             case 'iso88597':
  10149.             case 'iso885971987':
  10150.             case 'isoir126':
  10151.                 return 'ISO-8859-7';
  10152.  
  10153.             case 'csisolatinhebrew':
  10154.             case 'hebrew':
  10155.             case 'iso88598':
  10156.             case 'iso885981988':
  10157.             case 'isoir138':
  10158.                 return 'ISO-8859-8';
  10159.  
  10160.             case 'csiso88598e':
  10161.             case 'iso88598e':
  10162.                 return 'ISO-8859-8-E';
  10163.  
  10164.             case 'csiso88598i':
  10165.             case 'iso88598i':
  10166.                 return 'ISO-8859-8-I';
  10167.  
  10168.             case 'cswindows31latin5':
  10169.             case 'iso88599windowslatin5':
  10170.                 return 'ISO-8859-9-Windows-Latin-5';
  10171.  
  10172.             case 'csisolatin6':
  10173.             case 'iso885910':
  10174.             case 'iso8859101992':
  10175.             case 'isoir157':
  10176.             case 'l6':
  10177.             case 'latin6':
  10178.                 return 'ISO-8859-10';
  10179.  
  10180.             case 'iso885913':
  10181.                 return 'ISO-8859-13';
  10182.  
  10183.             case 'iso885914':
  10184.             case 'iso8859141998':
  10185.             case 'isoceltic':
  10186.             case 'isoir199':
  10187.             case 'l8':
  10188.             case 'latin8':
  10189.                 return 'ISO-8859-14';
  10190.  
  10191.             case 'iso885915':
  10192.             case 'latin9':
  10193.                 return 'ISO-8859-15';
  10194.  
  10195.             case 'iso885916':
  10196.             case 'iso8859162001':
  10197.             case 'isoir226':
  10198.             case 'l10':
  10199.             case 'latin10':
  10200.                 return 'ISO-8859-16';
  10201.  
  10202.             case 'iso10646j1':
  10203.                 return 'ISO-10646-J-1';
  10204.  
  10205.             case 'csunicode':
  10206.             case 'iso10646ucs2':
  10207.                 return 'ISO-10646-UCS-2';
  10208.  
  10209.             case 'csucs4':
  10210.             case 'iso10646ucs4':
  10211.                 return 'ISO-10646-UCS-4';
  10212.  
  10213.             case 'csunicodeascii':
  10214.             case 'iso10646ucsbasic':
  10215.                 return 'ISO-10646-UCS-Basic';
  10216.  
  10217.             case 'csunicodelatin1':
  10218.             case 'iso10646':
  10219.             case 'iso10646unicodelatin1':
  10220.                 return 'ISO-10646-Unicode-Latin1';
  10221.  
  10222.             case 'csiso10646utf1':
  10223.             case 'iso10646utf1':
  10224.                 return 'ISO-10646-UTF-1';
  10225.  
  10226.             case 'csiso115481':
  10227.             case 'iso115481':
  10228.             case 'isotr115481':
  10229.                 return 'ISO-11548-1';
  10230.  
  10231.             case 'csiso90':
  10232.             case 'isoir90':
  10233.                 return 'iso-ir-90';
  10234.  
  10235.             case 'csunicodeibm1261':
  10236.             case 'isounicodeibm1261':
  10237.                 return 'ISO-Unicode-IBM-1261';
  10238.  
  10239.             case 'csunicodeibm1264':
  10240.             case 'isounicodeibm1264':
  10241.                 return 'ISO-Unicode-IBM-1264';
  10242.  
  10243.             case 'csunicodeibm1265':
  10244.             case 'isounicodeibm1265':
  10245.                 return 'ISO-Unicode-IBM-1265';
  10246.  
  10247.             case 'csunicodeibm1268':
  10248.             case 'isounicodeibm1268':
  10249.                 return 'ISO-Unicode-IBM-1268';
  10250.  
  10251.             case 'csunicodeibm1276':
  10252.             case 'isounicodeibm1276':
  10253.                 return 'ISO-Unicode-IBM-1276';
  10254.  
  10255.             case 'csiso646basic1983':
  10256.             case 'iso646basic1983':
  10257.             case 'ref':
  10258.                 return 'ISO_646.basic:1983';
  10259.  
  10260.             case 'csiso2intlrefversion':
  10261.             case 'irv':
  10262.             case 'iso646irv1983':
  10263.             case 'isoir2':
  10264.                 return 'ISO_646.irv:1983';
  10265.  
  10266.             case 'csiso2033':
  10267.             case 'e13b':
  10268.             case 'iso20331983':
  10269.             case 'isoir98':
  10270.                 return 'ISO_2033-1983';
  10271.  
  10272.             case 'csiso5427cyrillic':
  10273.             case 'iso5427':
  10274.             case 'isoir37':
  10275.                 return 'ISO_5427';
  10276.  
  10277.             case 'iso5427cyrillic1981':
  10278.             case 'iso54271981':
  10279.             case 'isoir54':
  10280.                 return 'ISO_5427:1981';
  10281.  
  10282.             case 'csiso5428greek':
  10283.             case 'iso54281980':
  10284.             case 'isoir55':
  10285.                 return 'ISO_5428:1980';
  10286.  
  10287.             case 'csiso6937add':
  10288.             case 'iso6937225':
  10289.             case 'isoir152':
  10290.                 return 'ISO_6937-2-25';
  10291.  
  10292.             case 'csisotextcomm':
  10293.             case 'iso69372add':
  10294.             case 'isoir142':
  10295.                 return 'ISO_6937-2-add';
  10296.  
  10297.             case 'csiso8859supp':
  10298.             case 'iso8859supp':
  10299.             case 'isoir154':
  10300.             case 'latin125':
  10301.                 return 'ISO_8859-supp';
  10302.  
  10303.             case 'csiso10367box':
  10304.             case 'iso10367box':
  10305.             case 'isoir155':
  10306.                 return 'ISO_10367-box';
  10307.  
  10308.             case 'csiso15italian':
  10309.             case 'iso646it':
  10310.             case 'isoir15':
  10311.             case 'it':
  10312.                 return 'IT';
  10313.  
  10314.             case 'csiso13jisc6220jp':
  10315.             case 'isoir13':
  10316.             case 'jisc62201969':
  10317.             case 'jisc62201969jp':
  10318.             case 'katakana':
  10319.             case 'x2017':
  10320.                 return 'JIS_C6220-1969-jp';
  10321.  
  10322.             case 'csiso14jisc6220ro':
  10323.             case 'iso646jp':
  10324.             case 'isoir14':
  10325.             case 'jisc62201969ro':
  10326.             case 'jp':
  10327.                 return 'JIS_C6220-1969-ro';
  10328.  
  10329.             case 'csiso42jisc62261978':
  10330.             case 'isoir42':
  10331.             case 'jisc62261978':
  10332.                 return 'JIS_C6226-1978';
  10333.  
  10334.             case 'csiso87jisx208':
  10335.             case 'isoir87':
  10336.             case 'jisc62261983':
  10337.             case 'jisx2081983':
  10338.             case 'x208':
  10339.                 return 'JIS_C6226-1983';
  10340.  
  10341.             case 'csiso91jisc62291984a':
  10342.             case 'isoir91':
  10343.             case 'jisc62291984a':
  10344.             case 'jpocra':
  10345.                 return 'JIS_C6229-1984-a';
  10346.  
  10347.             case 'csiso92jisc62991984b':
  10348.             case 'iso646jpocrb':
  10349.             case 'isoir92':
  10350.             case 'jisc62291984b':
  10351.             case 'jpocrb':
  10352.                 return 'JIS_C6229-1984-b';
  10353.  
  10354.             case 'csiso93jis62291984badd':
  10355.             case 'isoir93':
  10356.             case 'jisc62291984badd':
  10357.             case 'jpocrbadd':
  10358.                 return 'JIS_C6229-1984-b-add';
  10359.  
  10360.             case 'csiso94jis62291984hand':
  10361.             case 'isoir94':
  10362.             case 'jisc62291984hand':
  10363.             case 'jpocrhand':
  10364.                 return 'JIS_C6229-1984-hand';
  10365.  
  10366.             case 'csiso95jis62291984handadd':
  10367.             case 'isoir95':
  10368.             case 'jisc62291984handadd':
  10369.             case 'jpocrhandadd':
  10370.                 return 'JIS_C6229-1984-hand-add';
  10371.  
  10372.             case 'csiso96jisc62291984kana':
  10373.             case 'isoir96':
  10374.             case 'jisc62291984kana':
  10375.                 return 'JIS_C6229-1984-kana';
  10376.  
  10377.             case 'csjisencoding':
  10378.             case 'jisencoding':
  10379.                 return 'JIS_Encoding';
  10380.  
  10381.             case 'cshalfwidthkatakana':
  10382.             case 'jisx201':
  10383.             case 'x201':
  10384.                 return 'JIS_X0201';
  10385.  
  10386.             case 'csiso159jisx2121990':
  10387.             case 'isoir159':
  10388.             case 'jisx2121990':
  10389.             case 'x212':
  10390.                 return 'JIS_X0212-1990';
  10391.  
  10392.             case 'csiso141jusib1002':
  10393.             case 'iso646yu':
  10394.             case 'isoir141':
  10395.             case 'js':
  10396.             case 'jusib1002':
  10397.             case 'yu':
  10398.                 return 'JUS_I.B1.002';
  10399.  
  10400.             case 'csiso147macedonian':
  10401.             case 'isoir147':
  10402.             case 'jusib1003mac':
  10403.             case 'macedonian':
  10404.                 return 'JUS_I.B1.003-mac';
  10405.  
  10406.             case 'csiso146serbian':
  10407.             case 'isoir146':
  10408.             case 'jusib1003serb':
  10409.             case 'serbian':
  10410.                 return 'JUS_I.B1.003-serb';
  10411.  
  10412.             case 'koi7switched':
  10413.                 return 'KOI7-switched';
  10414.  
  10415.             case 'cskoi8r':
  10416.             case 'koi8r':
  10417.                 return 'KOI8-R';
  10418.  
  10419.             case 'koi8u':
  10420.                 return 'KOI8-U';
  10421.  
  10422.             case 'csksc5636':
  10423.             case 'iso646kr':
  10424.             case 'ksc5636':
  10425.                 return 'KSC5636';
  10426.  
  10427.             case 'cskz1048':
  10428.             case 'kz1048':
  10429.             case 'rk1048':
  10430.             case 'strk10482002':
  10431.                 return 'KZ-1048';
  10432.  
  10433.             case 'csiso19latingreek':
  10434.             case 'isoir19':
  10435.             case 'latingreek':
  10436.                 return 'latin-greek';
  10437.  
  10438.             case 'csiso27latingreek1':
  10439.             case 'isoir27':
  10440.             case 'latingreek1':
  10441.                 return 'Latin-greek-1';
  10442.  
  10443.             case 'csiso158lap':
  10444.             case 'isoir158':
  10445.             case 'lap':
  10446.             case 'latinlap':
  10447.                 return 'latin-lap';
  10448.  
  10449.             case 'csmacintosh':
  10450.             case 'mac':
  10451.             case 'macintosh':
  10452.                 return 'macintosh';
  10453.  
  10454.             case 'csmicrosoftpublishing':
  10455.             case 'microsoftpublishing':
  10456.                 return 'Microsoft-Publishing';
  10457.  
  10458.             case 'csmnem':
  10459.             case 'mnem':
  10460.                 return 'MNEM';
  10461.  
  10462.             case 'csmnemonic':
  10463.             case 'mnemonic':
  10464.                 return 'MNEMONIC';
  10465.  
  10466.             case 'csiso86hungarian':
  10467.             case 'hu':
  10468.             case 'iso646hu':
  10469.             case 'isoir86':
  10470.             case 'msz77953':
  10471.                 return 'MSZ_7795.3';
  10472.  
  10473.             case 'csnatsdano':
  10474.             case 'isoir91':
  10475.             case 'natsdano':
  10476.                 return 'NATS-DANO';
  10477.  
  10478.             case 'csnatsdanoadd':
  10479.             case 'isoir92':
  10480.             case 'natsdanoadd':
  10481.                 return 'NATS-DANO-ADD';
  10482.  
  10483.             case 'csnatssefi':
  10484.             case 'isoir81':
  10485.             case 'natssefi':
  10486.                 return 'NATS-SEFI';
  10487.  
  10488.             case 'csnatssefiadd':
  10489.             case 'isoir82':
  10490.             case 'natssefiadd':
  10491.                 return 'NATS-SEFI-ADD';
  10492.  
  10493.             case 'csiso151cuba':
  10494.             case 'cuba':
  10495.             case 'iso646cu':
  10496.             case 'isoir151':
  10497.             case 'ncnc1081':
  10498.                 return 'NC_NC00-10:81';
  10499.  
  10500.             case 'csiso69french':
  10501.             case 'fr':
  10502.             case 'iso646fr':
  10503.             case 'isoir69':
  10504.             case 'nfz62010':
  10505.                 return 'NF_Z_62-010';
  10506.  
  10507.             case 'csiso25french':
  10508.             case 'iso646fr1':
  10509.             case 'isoir25':
  10510.             case 'nfz620101973':
  10511.                 return 'NF_Z_62-010_(1973)';
  10512.  
  10513.             case 'csiso60danishnorwegian':
  10514.             case 'csiso60norwegian1':
  10515.             case 'iso646no':
  10516.             case 'isoir60':
  10517.             case 'no':
  10518.             case 'ns45511':
  10519.                 return 'NS_4551-1';
  10520.  
  10521.             case 'csiso61norwegian2':
  10522.             case 'iso646no2':
  10523.             case 'isoir61':
  10524.             case 'no2':
  10525.             case 'ns45512':
  10526.                 return 'NS_4551-2';
  10527.  
  10528.             case 'osdebcdicdf3irv':
  10529.                 return 'OSD_EBCDIC_DF03_IRV';
  10530.  
  10531.             case 'osdebcdicdf41':
  10532.                 return 'OSD_EBCDIC_DF04_1';
  10533.  
  10534.             case 'osdebcdicdf415':
  10535.                 return 'OSD_EBCDIC_DF04_15';
  10536.  
  10537.             case 'cspc8danishnorwegian':
  10538.             case 'pc8danishnorwegian':
  10539.                 return 'PC8-Danish-Norwegian';
  10540.  
  10541.             case 'cspc8turkish':
  10542.             case 'pc8turkish':
  10543.                 return 'PC8-Turkish';
  10544.  
  10545.             case 'csiso16portuguese':
  10546.             case 'iso646pt':
  10547.             case 'isoir16':
  10548.             case 'pt':
  10549.                 return 'PT';
  10550.  
  10551.             case 'csiso84portuguese2':
  10552.             case 'iso646pt2':
  10553.             case 'isoir84':
  10554.             case 'pt2':
  10555.                 return 'PT2';
  10556.  
  10557.             case 'cp154':
  10558.             case 'csptcp154':
  10559.             case 'cyrillicasian':
  10560.             case 'pt154':
  10561.             case 'ptcp154':
  10562.                 return 'PTCP154';
  10563.  
  10564.             case 'scsu':
  10565.                 return 'SCSU';
  10566.  
  10567.             case 'csiso10swedish':
  10568.             case 'fi':
  10569.             case 'iso646fi':
  10570.             case 'iso646se':
  10571.             case 'isoir10':
  10572.             case 'se':
  10573.             case 'sen850200b':
  10574.                 return 'SEN_850200_B';
  10575.  
  10576.             case 'csiso11swedishfornames':
  10577.             case 'iso646se2':
  10578.             case 'isoir11':
  10579.             case 'se2':
  10580.             case 'sen850200c':
  10581.                 return 'SEN_850200_C';
  10582.  
  10583.             case 'csshiftjis':
  10584.             case 'mskanji':
  10585.             case 'shiftjis':
  10586.                 return 'Shift_JIS';
  10587.  
  10588.             case 'csiso102t617bit':
  10589.             case 'isoir102':
  10590.             case 't617bit':
  10591.                 return 'T.61-7bit';
  10592.  
  10593.             case 'csiso103t618bit':
  10594.             case 'isoir103':
  10595.             case 't61':
  10596.             case 't618bit':
  10597.                 return 'T.61-8bit';
  10598.  
  10599.             case 'csiso128t101g2':
  10600.             case 'isoir128':
  10601.             case 't101g2':
  10602.                 return 'T.101-G2';
  10603.  
  10604.             case 'cstscii':
  10605.             case 'tscii':
  10606.                 return 'TSCII';
  10607.  
  10608.             case 'csunicode11':
  10609.             case 'unicode11':
  10610.                 return 'UNICODE-1-1';
  10611.  
  10612.             case 'csunicode11utf7':
  10613.             case 'unicode11utf7':
  10614.                 return 'UNICODE-1-1-UTF-7';
  10615.  
  10616.             case 'csunknown8bit':
  10617.             case 'unknown8bit':
  10618.                 return 'UNKNOWN-8BIT';
  10619.  
  10620.             case 'ansix341968':
  10621.             case 'ansix341986':
  10622.             case 'ascii':
  10623.             case 'cp367':
  10624.             case 'csascii':
  10625.             case 'ibm367':
  10626.             case 'iso646irv1991':
  10627.             case 'iso646us':
  10628.             case 'isoir6':
  10629.             case 'us':
  10630.             case 'usascii':
  10631.                 return 'US-ASCII';
  10632.  
  10633.             case 'csusdk':
  10634.             case 'usdk':
  10635.                 return 'us-dk';
  10636.  
  10637.             case 'utf7':
  10638.                 return 'UTF-7';
  10639.  
  10640.             case 'utf8':
  10641.                 return 'UTF-8';
  10642.  
  10643.             case 'utf16':
  10644.                 return 'UTF-16';
  10645.  
  10646.             case 'utf16be':
  10647.                 return 'UTF-16BE';
  10648.  
  10649.             case 'utf16le':
  10650.                 return 'UTF-16LE';
  10651.  
  10652.             case 'utf32':
  10653.                 return 'UTF-32';
  10654.  
  10655.             case 'utf32be':
  10656.                 return 'UTF-32BE';
  10657.  
  10658.             case 'utf32le':
  10659.                 return 'UTF-32LE';
  10660.  
  10661.             case 'csventurainternational':
  10662.             case 'venturainternational':
  10663.                 return 'Ventura-International';
  10664.  
  10665.             case 'csventuramath':
  10666.             case 'venturamath':
  10667.                 return 'Ventura-Math';
  10668.  
  10669.             case 'csventuraus':
  10670.             case 'venturaus':
  10671.                 return 'Ventura-US';
  10672.  
  10673.             case 'csiso70videotexsupp1':
  10674.             case 'isoir70':
  10675.             case 'videotexsuppl':
  10676.                 return 'videotex-suppl';
  10677.  
  10678.             case 'csviqr':
  10679.             case 'viqr':
  10680.                 return 'VIQR';
  10681.  
  10682.             case 'csviscii':
  10683.             case 'viscii':
  10684.                 return 'VISCII';
  10685.  
  10686.             case 'cswindows31j':
  10687.             case 'windows31j':
  10688.                 return 'Windows-31J';
  10689.  
  10690.             case 'iso885911':
  10691.             case 'tis620':
  10692.                 return 'windows-874';
  10693.  
  10694.             case 'cseuckr':
  10695.             case 'csksc56011987':
  10696.             case 'euckr':
  10697.             case 'isoir149':
  10698.             case 'korean':
  10699.             case 'ksc5601':
  10700.             case 'ksc56011987':
  10701.             case 'ksc56011989':
  10702.             case 'windows949':
  10703.                 return 'windows-949';
  10704.  
  10705.             case 'windows1250':
  10706.                 return 'windows-1250';
  10707.  
  10708.             case 'windows1251':
  10709.                 return 'windows-1251';
  10710.  
  10711.             case 'cp819':
  10712.             case 'csisolatin1':
  10713.             case 'ibm819':
  10714.             case 'iso88591':
  10715.             case 'iso885911987':
  10716.             case 'isoir100':
  10717.             case 'l1':
  10718.             case 'latin1':
  10719.             case 'windows1252':
  10720.                 return 'windows-1252';
  10721.  
  10722.             case 'windows1253':
  10723.                 return 'windows-1253';
  10724.  
  10725.             case 'csisolatin5':
  10726.             case 'iso88599':
  10727.             case 'iso885991989':
  10728.             case 'isoir148':
  10729.             case 'l5':
  10730.             case 'latin5':
  10731.             case 'windows1254':
  10732.                 return 'windows-1254';
  10733.  
  10734.             case 'windows1255':
  10735.                 return 'windows-1255';
  10736.  
  10737.             case 'windows1256':
  10738.                 return 'windows-1256';
  10739.  
  10740.             case 'windows1257':
  10741.                 return 'windows-1257';
  10742.  
  10743.             case 'windows1258':
  10744.                 return 'windows-1258';
  10745.  
  10746.             default:
  10747.                 return $charset;
  10748.         }
  10749.     }
  10750.  
  10751.     function get_curl_version()
  10752.     {
  10753.         if (is_array($curl curl_version()))
  10754.         {
  10755.             $curl $curl['version'];
  10756.         }
  10757.         elseif (substr($curl05=== 'curl/')
  10758.         {
  10759.             $curl substr($curl5strcspn($curl"\x09\x0A\x0B\x0C\x0D"5));
  10760.         }
  10761.         elseif (substr($curl08=== 'libcurl/')
  10762.         {
  10763.             $curl substr($curl8strcspn($curl"\x09\x0A\x0B\x0C\x0D"8));
  10764.         }
  10765.         else
  10766.         {
  10767.             $curl 0;
  10768.         }
  10769.         return $curl;
  10770.     }
  10771.  
  10772.     function is_subclass_of($class1$class2)
  10773.     {
  10774.         if (func_num_args(!== 2)
  10775.         {
  10776.             trigger_error('Wrong parameter count for SimplePie_Misc::is_subclass_of()'E_USER_WARNING);
  10777.         }
  10778.         elseif (version_compare(PHP_VERSION'5.0.3''>='|| is_object($class1))
  10779.         {
  10780.             return is_subclass_of($class1$class2);
  10781.         }
  10782.         elseif (is_string($class1&& is_string($class2))
  10783.         {
  10784.             if (class_exists($class1))
  10785.             {
  10786.                 if (class_exists($class2))
  10787.                 {
  10788.                     $class2 strtolower($class2);
  10789.                     while ($class1 strtolower(get_parent_class($class1)))
  10790.                     {
  10791.                         if ($class1 === $class2)
  10792.                         {
  10793.                             return true;
  10794.                         }
  10795.                     }
  10796.                 }
  10797.             }
  10798.             else
  10799.             {
  10800.                 trigger_error('Unknown class passed as parameter'E_USER_WARNNG);
  10801.             }
  10802.         }
  10803.         return false;
  10804.     }
  10805.  
  10806.     /**
  10807.      * Strip HTML comments
  10808.      *
  10809.      * @access public
  10810.      * @param string $data Data to strip comments from
  10811.      * @return string Comment stripped string
  10812.      */
  10813.     function strip_comments($data)
  10814.     {
  10815.         $output '';
  10816.         while (($start strpos($data'<!--')) !== false)
  10817.         {
  10818.             $output .= substr($data0$start);
  10819.             if (($end strpos($data'-->'$start)) !== false)
  10820.             {
  10821.                 $data substr_replace($data''0$end 3);
  10822.             }
  10823.             else
  10824.             {
  10825.                 $data '';
  10826.             }
  10827.         }
  10828.         return $output $data;
  10829.     }
  10830.  
  10831.     function parse_date($dt)
  10832.     {
  10833.         $parser SimplePie_Parse_Date::get();
  10834.         return $parser->parse($dt);
  10835.     }
  10836.  
  10837.     /**
  10838.      * Decode HTML entities
  10839.      *
  10840.      * @static
  10841.      * @access public
  10842.      * @param string $data Input data
  10843.      * @return string Output data
  10844.      */
  10845.     function entities_decode($data)
  10846.     {
  10847.         $decoder new SimplePie_Decode_HTML_Entities($data);
  10848.         return $decoder->parse();
  10849.     }
  10850.  
  10851.     /**
  10852.      * Remove RFC822 comments
  10853.      *
  10854.      * @access public
  10855.      * @param string $data Data to strip comments from
  10856.      * @return string Comment stripped string
  10857.      */
  10858.     function uncomment_rfc822($string)
  10859.     {
  10860.         $string = (string) $string;
  10861.         $position 0;
  10862.         $length strlen($string);
  10863.         $depth 0;
  10864.  
  10865.         $output '';
  10866.  
  10867.         while ($position $length && ($pos strpos($string'('$position)) !== false)
  10868.         {
  10869.             $output .= substr($string$position$pos $position);
  10870.             $position $pos 1;
  10871.             if ($string[$pos 1!== '\\')
  10872.             {
  10873.                 $depth++;
  10874.                 while ($depth && $position $length)
  10875.                 {
  10876.                     $position += strcspn($string'()'$position);
  10877.                     if ($string[$position 1=== '\\')
  10878.                     {
  10879.                         $position++;
  10880.                         continue;
  10881.                     }
  10882.                     elseif (isset($string[$position]))
  10883.                     {
  10884.                         switch ($string[$position])
  10885.                         {
  10886.                             case '(':
  10887.                                 $depth++;
  10888.                                 break;
  10889.  
  10890.                             case ')':
  10891.                                 $depth--;
  10892.                                 break;
  10893.                         }
  10894.                         $position++;
  10895.                     }
  10896.                     else
  10897.                     {
  10898.                         break;
  10899.                     }
  10900.                 }
  10901.             }
  10902.             else
  10903.             {
  10904.                 $output .= '(';
  10905.             }
  10906.         }
  10907.         $output .= substr($string$position);
  10908.  
  10909.         return $output;
  10910.     }
  10911.  
  10912.     function parse_mime($mime)
  10913.     {
  10914.         if (($pos strpos($mime';')) === false)
  10915.         {
  10916.             return trim($mime);
  10917.         }
  10918.         else
  10919.         {
  10920.             return trim(substr($mime0$pos));
  10921.         }
  10922.     }
  10923.  
  10924.     function htmlspecialchars_decode($string$quote_style)
  10925.     {
  10926.         if (function_exists('htmlspecialchars_decode'))
  10927.         {
  10928.             return htmlspecialchars_decode($string$quote_style);
  10929.         }
  10930.         else
  10931.         {
  10932.             return strtr($stringarray_flip(get_html_translation_table(HTML_SPECIALCHARS$quote_style)));
  10933.         }
  10934.     }
  10935.  
  10936.     function atom_03_construct_type($attribs)
  10937.     {
  10938.         if (isset($attribs['']['mode']&& strtolower(trim($attribs['']['mode']=== 'base64'))
  10939.         {
  10940.             $mode SIMPLEPIE_CONSTRUCT_BASE64;
  10941.         }
  10942.         else
  10943.         {
  10944.             $mode SIMPLEPIE_CONSTRUCT_NONE;
  10945.         }
  10946.         if (isset($attribs['']['type']))
  10947.         {
  10948.             switch (strtolower(trim($attribs['']['type'])))
  10949.             {
  10950.                 case 'text':
  10951.                 case 'text/plain':
  10952.                     return SIMPLEPIE_CONSTRUCT_TEXT $mode;
  10953.  
  10954.                 case 'html':
  10955.                 case 'text/html':
  10956.                     return SIMPLEPIE_CONSTRUCT_HTML $mode;
  10957.  
  10958.                 case 'xhtml':
  10959.                 case 'application/xhtml+xml':
  10960.                     return SIMPLEPIE_CONSTRUCT_XHTML $mode;
  10961.  
  10962.                 default:
  10963.                     return SIMPLEPIE_CONSTRUCT_NONE $mode;
  10964.             }
  10965.         }
  10966.         else
  10967.         {
  10968.             return SIMPLEPIE_CONSTRUCT_TEXT $mode;
  10969.         }
  10970.     }
  10971.  
  10972.     function atom_10_construct_type($attribs)
  10973.     {
  10974.         if (isset($attribs['']['type']))
  10975.         {
  10976.             switch (strtolower(trim($attribs['']['type'])))
  10977.             {
  10978.                 case 'text':
  10979.                     return SIMPLEPIE_CONSTRUCT_TEXT;
  10980.  
  10981.                 case 'html':
  10982.                     return SIMPLEPIE_CONSTRUCT_HTML;
  10983.  
  10984.                 case 'xhtml':
  10985.                     return SIMPLEPIE_CONSTRUCT_XHTML;
  10986.  
  10987.                 default:
  10988.                     return SIMPLEPIE_CONSTRUCT_NONE;
  10989.             }
  10990.         }
  10991.         return SIMPLEPIE_CONSTRUCT_TEXT;
  10992.     }
  10993.  
  10994.     function atom_10_content_construct_type($attribs)
  10995.     {
  10996.         if (isset($attribs['']['type']))
  10997.         {
  10998.             $type strtolower(trim($attribs['']['type']));
  10999.             switch ($type)
  11000.             {
  11001.                 case 'text':
  11002.                     return SIMPLEPIE_CONSTRUCT_TEXT;
  11003.  
  11004.                 case 'html':
  11005.                     return SIMPLEPIE_CONSTRUCT_HTML;
  11006.  
  11007.                 case 'xhtml':
  11008.                     return SIMPLEPIE_CONSTRUCT_XHTML;
  11009.             }
  11010.             if (in_array(substr($type-4)array('+xml''/xml')) || substr($type05=== 'text/')
  11011.             {
  11012.                 return SIMPLEPIE_CONSTRUCT_NONE;
  11013.             }
  11014.             else
  11015.             {
  11016.                 return SIMPLEPIE_CONSTRUCT_BASE64;
  11017.             }
  11018.         }
  11019.         else
  11020.         {
  11021.             return SIMPLEPIE_CONSTRUCT_TEXT;
  11022.         }
  11023.     }
  11024.  
  11025.     function is_isegment_nz_nc($string)
  11026.     {
  11027.         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);
  11028.     }
  11029.  
  11030.     function space_seperated_tokens($string)
  11031.     {
  11032.         $space_characters "\x20\x09\x0A\x0B\x0C\x0D";
  11033.         $string_length strlen($string);
  11034.  
  11035.         $position strspn($string$space_characters);
  11036.         $tokens array();
  11037.  
  11038.         while ($position $string_length)
  11039.         {
  11040.             $len strcspn($string$space_characters$position);
  11041.             $tokens[substr($string$position$len);
  11042.             $position += $len;
  11043.             $position += strspn($string$space_characters$position);
  11044.         }
  11045.  
  11046.         return $tokens;
  11047.     }
  11048.  
  11049.     function array_unique($array)
  11050.     {
  11051.         if (version_compare(PHP_VERSION'5.2''>='))
  11052.         {
  11053.             return array_unique($array);
  11054.         }
  11055.         else
  11056.         {
  11057.             $array = (array) $array;
  11058.             $new_array array();
  11059.             $new_array_strings array();
  11060.             foreach ($array as $key => $value)
  11061.             {
  11062.                 if (is_object($value))
  11063.                 {
  11064.                     if (method_exists($value'__toString'))
  11065.                     {
  11066.                         $cmp $value->__toString();
  11067.                     }
  11068.                     else
  11069.                     {
  11070.                         trigger_error('Object of class ' get_class($value' could not be converted to string'E_USER_ERROR);
  11071.                     }
  11072.                 }
  11073.                 elseif (is_array($value))
  11074.                 {
  11075.                     $cmp = (string) reset($value);
  11076.                 }
  11077.                 else
  11078.                 {
  11079.                     $cmp = (string) $value;
  11080.                 }
  11081.                 if (!in_array($cmp$new_array_strings))
  11082.                 {
  11083.                     $new_array[$key$value;
  11084.                     $new_array_strings[$cmp;
  11085.                 }
  11086.             }
  11087.             return $new_array;
  11088.         }
  11089.     }
  11090.  
  11091.     /**
  11092.      * Converts a unicode codepoint to a UTF-8 character
  11093.      *
  11094.      * @static
  11095.      * @access public
  11096.      * @param int $codepoint Unicode codepoint
  11097.      * @return string UTF-8 character
  11098.      */
  11099.     function codepoint_to_utf8($codepoint)
  11100.     {
  11101.         $codepoint = (int) $codepoint;
  11102.         if ($codepoint 0)
  11103.         {
  11104.             return false;
  11105.         }
  11106.         else if ($codepoint <= 0x7f)
  11107.         {
  11108.             return chr($codepoint);
  11109.         }
  11110.         else if ($codepoint <= 0x7ff)
  11111.         {
  11112.             return chr(0xc0 ($codepoint >> 6)) chr(0x80 ($codepoint 0x3f));
  11113.         }
  11114.         else if ($codepoint <= 0xffff)
  11115.         {
  11116.             return chr(0xe0 ($codepoint >> 12)) chr(0x80 (($codepoint >> 60x3f)) chr(0x80 ($codepoint 0x3f));
  11117.         }
  11118.         else if ($codepoint <= 0x10ffff)
  11119.         {
  11120.             return chr(0xf0 ($codepoint >> 18)) chr(0x80 (($codepoint >> 120x3f)) chr(0x80 (($codepoint >> 60x3f)) chr(0x80 ($codepoint 0x3f));
  11121.         }
  11122.         else
  11123.         {
  11124.             // U+FFFD REPLACEMENT CHARACTER
  11125.             return "\xEF\xBF\xBD";
  11126.         }
  11127.     }
  11128.  
  11129.     /**
  11130.      * Re-implementation of PHP 5's stripos()
  11131.      *
  11132.      * Returns the numeric position of the first occurrence of needle in the
  11133.      * haystack string.
  11134.      *
  11135.      * @static
  11136.      * @access string
  11137.      * @param object $haystack 
  11138.      * @param string $needle Note that the needle may be a string of one or more
  11139.      *      characters. If needle is not a string, it is converted to an integer
  11140.      *      and applied as the ordinal value of a character.
  11141.      * @param int $offset The optional offset parameter allows you to specify which
  11142.      *      character in haystack to start searching. The position returned is still
  11143.      *      relative to the beginning of haystack.
  11144.      * @return bool If needle is not found, stripos() will return boolean false.
  11145.      */
  11146.     function stripos($haystack$needle$offset 0)
  11147.     {
  11148.         if (function_exists('stripos'))
  11149.         {
  11150.             return stripos($haystack$needle$offset);
  11151.         }
  11152.         else
  11153.         {
  11154.             if (is_string($needle))
  11155.             {
  11156.                 $needle strtolower($needle);
  11157.             }
  11158.             elseif (is_int($needle|| is_bool($needle|| is_double($needle))
  11159.             {
  11160.                 $needle strtolower(chr($needle));
  11161.             }
  11162.             else
  11163.             {
  11164.                 trigger_error('needle is not a string or an integer'E_USER_WARNING);
  11165.                 return false;
  11166.             }
  11167.  
  11168.             return strpos(strtolower($haystack)$needle$offset);
  11169.         }
  11170.     }
  11171.  
  11172.     /**
  11173.      * Similar to parse_str()
  11174.      *
  11175.      * Returns an associative array of name/value pairs, where the value is an
  11176.      * array of values that have used the same name
  11177.      *
  11178.      * @static
  11179.      * @access string
  11180.      * @param string $str The input string.
  11181.      * @return array 
  11182.      */
  11183.     function parse_str($str)
  11184.     {
  11185.         $return array();
  11186.         $str explode('&'$str);
  11187.  
  11188.         foreach ($str as $section)
  11189.         {
  11190.             if (strpos($section'='!== false)
  11191.             {
  11192.                 list($name$valueexplode('='$section2);
  11193.                 $return[urldecode($name)][urldecode($value);
  11194.             }
  11195.             else
  11196.             {
  11197.                 $return[urldecode($section)][null;
  11198.             }
  11199.         }
  11200.  
  11201.         return $return;
  11202.     }
  11203.  
  11204.     /**
  11205.      * Detect XML encoding, as per XML 1.0 Appendix F.1
  11206.      *
  11207.      * @todo Add support for EBCDIC
  11208.      * @param string $data XML data
  11209.      * @return array Possible encodings
  11210.      */
  11211.     function xml_encoding($data)
  11212.     {
  11213.         // UTF-32 Big Endian BOM
  11214.         if (substr($data04=== "\x00\x00\xFE\xFF")
  11215.         {
  11216.             $encoding['UTF-32BE';
  11217.         }
  11218.         // UTF-32 Little Endian BOM
  11219.         elseif (substr($data04=== "\xFF\xFE\x00\x00")
  11220.         {
  11221.             $encoding['UTF-32LE';
  11222.         }
  11223.         // UTF-16 Big Endian BOM
  11224.         elseif (substr($data02=== "\xFE\xFF")
  11225.         {
  11226.             $encoding['UTF-16BE';
  11227.         }
  11228.         // UTF-16 Little Endian BOM
  11229.         elseif (substr($data02=== "\xFF\xFE")
  11230.         {
  11231.             $encoding['UTF-16LE';
  11232.         }
  11233.         // UTF-8 BOM
  11234.         elseif (substr($data03=== "\xEF\xBB\xBF")
  11235.         {
  11236.             $encoding['UTF-8';
  11237.         }
  11238.         // UTF-32 Big Endian Without BOM
  11239.         elseif (substr($data020=== "\x00\x00\x00\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C")
  11240.         {
  11241.             if ($pos strpos($data"\x00\x00\x00\x3F\x00\x00\x00\x3E"))
  11242.             {
  11243.                 $parser new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data20$pos 20)'UTF-32BE''UTF-8'));
  11244.                 if ($parser->parse())
  11245.                 {
  11246.                     $encoding[$parser->encoding;
  11247.                 }
  11248.             }
  11249.             $encoding['UTF-32BE';
  11250.         }
  11251.         // UTF-32 Little Endian Without BOM
  11252.         elseif (substr($data020=== "\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C\x00\x00\x00")
  11253.         {
  11254.             if ($pos strpos($data"\x3F\x00\x00\x00\x3E\x00\x00\x00"))
  11255.             {
  11256.                 $parser new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data20$pos 20)'UTF-32LE''UTF-8'));
  11257.                 if ($parser->parse())
  11258.                 {
  11259.                     $encoding[$parser->encoding;
  11260.                 }
  11261.             }
  11262.             $encoding['UTF-32LE';
  11263.         }
  11264.         // UTF-16 Big Endian Without BOM
  11265.         elseif (substr($data010=== "\x00\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C")
  11266.         {
  11267.             if ($pos strpos($data"\x00\x3F\x00\x3E"))
  11268.             {
  11269.                 $parser new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data20$pos 10)'UTF-16BE''UTF-8'));
  11270.                 if ($parser->parse())
  11271.                 {
  11272.                     $encoding[$parser->encoding;
  11273.                 }
  11274.             }
  11275.             $encoding['UTF-16BE';
  11276.         }
  11277.         // UTF-16 Little Endian Without BOM
  11278.         elseif (substr($data010=== "\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C\x00")
  11279.         {
  11280.             if ($pos strpos($data"\x3F\x00\x3E\x00"))
  11281.             {
  11282.                 $parser new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data20$pos 10)'UTF-16LE''UTF-8'));
  11283.                 if ($parser->parse())
  11284.                 {
  11285.                     $encoding[$parser->encoding;
  11286.                 }
  11287.             }
  11288.             $encoding['UTF-16LE';
  11289.         }
  11290.         // US-ASCII (or superset)
  11291.         elseif (substr($data05=== "\x3C\x3F\x78\x6D\x6C")
  11292.         {
  11293.             if ($pos strpos($data"\x3F\x3E"))
  11294.             {
  11295.                 $parser new SimplePie_XML_Declaration_Parser(substr($data5$pos 5));
  11296.                 if ($parser->parse())
  11297.                 {
  11298.                     $encoding[$parser->encoding;
  11299.                 }
  11300.             }
  11301.             $encoding['UTF-8';
  11302.         }
  11303.         // Fallback to UTF-8
  11304.         else
  11305.         {
  11306.             $encoding['UTF-8';
  11307.         }
  11308.         return $encoding;
  11309.     }
  11310.  
  11311.     function output_javascript()
  11312.     {
  11313.         if (function_exists('ob_gzhandler'))
  11314.         {
  11315.             ob_start('ob_gzhandler');
  11316.         }
  11317.         header('Content-type: text/javascript; charset: UTF-8');
  11318.         header('Cache-Control: must-revalidate');
  11319.         header('Expires: ' gmdate('D, d M Y H:i:s'time(604800' GMT')// 7 days
  11320.         ?>
  11321. function embed_odeo(link) {
  11322.     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>');
  11323. }
  11324.  
  11325. function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
  11326.     if (placeholder != '')
  11327.     {
  11328.         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>');
  11329.     }
  11330.     else {
  11331.         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>');
  11332.     }
  11333. }
  11334.  
  11335. function embed_flash(bgcolor, width, height, link, loop, type) {
  11336.     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>');
  11337. }
  11338.  
  11339. function embed_flv(width, height, link, placeholder, loop, player) {
  11340.     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>');
  11341. }
  11342.  
  11343. function embed_wmedia(width, height, link) {
  11344.     document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
  11345. }
  11346.         <?php
  11347.     }
  11348. }
  11349.  
  11350. /**
  11351.  * Decode HTML Entities
  11352.  *
  11353.  * This implements HTML5 as of revision 967 (2007-06-28)
  11354.  *
  11355.  * @package SimplePie
  11356.  */
  11357. {
  11358.     /**
  11359.      * Data to be parsed
  11360.      *
  11361.      * @access private
  11362.      * @var string 
  11363.      */
  11364.     var $data '';
  11365.  
  11366.     /**
  11367.      * Currently consumed bytes
  11368.      *
  11369.      * @access private
  11370.      * @var string 
  11371.      */
  11372.     var $consumed '';
  11373.  
  11374.     /**
  11375.      * Position of the current byte being parsed
  11376.      *
  11377.      * @access private
  11378.      * @var int 
  11379.      */
  11380.     var $position 0;
  11381.  
  11382.     /**
  11383.      * Create an instance of the class with the input data
  11384.      *
  11385.      * @access public
  11386.      * @param string $data Input data
  11387.      */
  11388.     function SimplePie_Decode_HTML_Entities($data)
  11389.     {
  11390.         $this->data $data;
  11391.     }
  11392.  
  11393.     /**
  11394.      * Parse the input data
  11395.      *
  11396.      * @access public
  11397.      * @return string Output data
  11398.      */
  11399.     function parse()
  11400.     {
  11401.         while (($this->position strpos($this->data'&'$this->position)) !== false)
  11402.         {
  11403.             $this->consume();
  11404.             $this->entity();
  11405.             $this->consumed '';
  11406.         }
  11407.         return $this->data;
  11408.     }
  11409.  
  11410.     /**
  11411.      * Consume the next byte
  11412.      *
  11413.      * @access private
  11414.      * @return mixed The next byte, or false, if there is no more data
  11415.      */
  11416.     function consume()
  11417.     {
  11418.         if (isset($this->data[$this->position]))
  11419.         {
  11420.             $this->consumed .= $this->data[$this->position];
  11421.             return $this->data[$this->position++];
  11422.         }
  11423.         else
  11424.         {
  11425.             return false;
  11426.         }
  11427.     }
  11428.  
  11429.     /**
  11430.      * Consume a range of characters
  11431.      *
  11432.      * @access private
  11433.      * @param string $chars Characters to consume
  11434.      * @return mixed A series of characters that match the range, or false
  11435.      */
  11436.     function consume_range($chars)
  11437.     {
  11438.         if ($len strspn($this->data$chars$this->position))
  11439.         {
  11440.             $data substr($this->data$this->position$len);
  11441.             $this->consumed .= $data;
  11442.             $this->position += $len;
  11443.             return $data;
  11444.         }
  11445.         else
  11446.         {
  11447.             return false;
  11448.         }
  11449.     }
  11450.  
  11451.     /**
  11452.      * Unconsume one byte
  11453.      *
  11454.      * @access private
  11455.      */
  11456.     function unconsume()
  11457.     {
  11458.         $this->consumed substr($this->consumed0-1);
  11459.         $this->position--;
  11460.     }
  11461.  
  11462.     /**
  11463.      * Decode an entity
  11464.      *
  11465.      * @access private
  11466.      */
  11467.     function entity()
  11468.     {
  11469.         switch ($this->consume())
  11470.         {
  11471.             case "\x09":
  11472.             case "\x0A":
  11473.             case "\x0B":
  11474.             case "\x0B":
  11475.             case "\x0C":
  11476.             case "\x20":
  11477.             case "\x3C":
  11478.             case "\x26":
  11479.             case false:
  11480.                 break;
  11481.  
  11482.             case "\x23":
  11483.                 switch ($this->consume())
  11484.                 {
  11485.                     case "\x78":
  11486.                     case "\x58":
  11487.                         $range '0123456789ABCDEFabcdef';
  11488.                         $hex true;
  11489.                         break;
  11490.  
  11491.                     default:
  11492.                         $range '0123456789';
  11493.                         $hex false;
  11494.                         $this->unconsume();
  11495.                         break;
  11496.                 }
  11497.  
  11498.                 if ($codepoint $this->consume_range($range))
  11499.                 {
  11500.                     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");
  11501.  
  11502.                     if ($hex)
  11503.                     {
  11504.                         $codepoint hexdec($codepoint);
  11505.                     }
  11506.                     else
  11507.                     {
  11508.                         $codepoint intval($codepoint);
  11509.                     }
  11510.  
  11511.                     if (isset($windows_1252_specials[$codepoint]))
  11512.                     {
  11513.                         $replacement $windows_1252_specials[$codepoint];
  11514.                     }
  11515.                     else
  11516.                     {
  11517.                         $replacement SimplePie_Misc::codepoint_to_utf8($codepoint);
  11518.                     }
  11519.  
  11520.                     if (!in_array($this->consume()array(';'false)true))
  11521.                     {
  11522.                         $this->unconsume();
  11523.                     }
  11524.  
  11525.                     $consumed_length strlen($this->consumed);
  11526.                     $this->data substr_replace($this->data$replacement$this->position $consumed_length$consumed_length);
  11527.                     $this->position += strlen($replacement$consumed_length;
  11528.                 }
  11529.                 break;
  11530.  
  11531.             default:
  11532.                 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");
  11533.  
  11534.                 for ($i 0$match null$i && $this->consume(!== false$i++)
  11535.                 {
  11536.                     $consumed substr($this->consumed1);
  11537.                     if (isset($entities[$consumed]))
  11538.                     {
  11539.                         $match $consumed;
  11540.                     }
  11541.                 }
  11542.  
  11543.                 if ($match !== null)
  11544.                 {
  11545.                      $this->data substr_replace($this->data$entities[$match]$this->position strlen($consumed1strlen($match1);
  11546.                     $this->position += strlen($entities[$match]strlen($consumed1;
  11547.                 }
  11548.                 break;
  11549.         }
  11550.     }
  11551. }
  11552.  
  11553. /**
  11554.  * IRI parser/serialiser
  11555.  *
  11556.  * @package SimplePie
  11557.  */
  11558. {
  11559.     /**
  11560.      * Scheme
  11561.      *
  11562.      * @access private
  11563.      * @var string 
  11564.      */
  11565.     var $scheme;
  11566.  
  11567.     /**
  11568.      * User Information
  11569.      *
  11570.      * @access private
  11571.      * @var string 
  11572.      */
  11573.     var $userinfo;
  11574.  
  11575.     /**
  11576.      * Host
  11577.      *
  11578.      * @access private
  11579.      * @var string 
  11580.      */
  11581.     var $host;
  11582.  
  11583.     /**
  11584.      * Port
  11585.      *
  11586.      * @access private
  11587.      * @var string 
  11588.      */
  11589.     var $port;
  11590.  
  11591.     /**
  11592.      * Path
  11593.      *
  11594.      * @access private
  11595.      * @var string 
  11596.      */
  11597.     var $path;
  11598.  
  11599.     /**
  11600.      * Query
  11601.      *
  11602.      * @access private
  11603.      * @var string 
  11604.      */
  11605.     var $query;
  11606.  
  11607.     /**
  11608.      * Fragment
  11609.      *
  11610.      * @access private
  11611.      * @var string 
  11612.      */
  11613.     var $fragment;
  11614.  
  11615.     /**
  11616.      * Whether the object represents a valid IRI
  11617.      *
  11618.      * @access private
  11619.      * @var array 
  11620.      */
  11621.     var $valid array();
  11622.  
  11623.     /**
  11624.      * Return the entire IRI when you try and read the object as a string
  11625.      *
  11626.      * @access public
  11627.      * @return string 
  11628.      */
  11629.     function __toString()
  11630.     {
  11631.         return $this->get_iri();
  11632.     }
  11633.  
  11634.     /**
  11635.      * Create a new IRI object, from a specified string
  11636.      *
  11637.      * @access public
  11638.      * @param string $iri 
  11639.      * @return SimplePie_IRI 
  11640.      */
  11641.     function SimplePie_IRI($iri)
  11642.     {
  11643.         $iri = (string) $iri;
  11644.         if ($iri !== '')
  11645.         {
  11646.             $parsed $this->parse_iri($iri);
  11647.             $this->set_scheme($parsed['scheme']);
  11648.             $this->set_authority($parsed['authority']);
  11649.             $this->set_path($parsed['path']);
  11650.             $this->set_query($parsed['query']);
  11651.             $this->set_fragment($parsed['fragment']);
  11652.         }
  11653.     }
  11654.  
  11655.     /**
  11656.      * Create a new IRI object by resolving a relative IRI
  11657.      *
  11658.      * @static
  11659.      * @access public
  11660.      * @param SimplePie_IRI $base Base IRI
  11661.      * @param string $relative Relative IRI
  11662.      * @return SimplePie_IRI 
  11663.      */
  11664.     function absolutize($base$relative)
  11665.     {
  11666.         $relative = (string) $relative;
  11667.         if ($relative !== '')
  11668.         {
  11669.             $relative new SimplePie_IRI($relative);
  11670.             if ($relative->get_scheme(!== null)
  11671.             {
  11672.                 $target $relative;
  11673.             }
  11674.             elseif ($base->get_iri(!== null)
  11675.             {
  11676.                 if ($relative->get_authority(!== null)
  11677.                 {
  11678.                     $target $relative;
  11679.                     $target->set_scheme($base->get_scheme());
  11680.                 }
  11681.                 else
  11682.                 {
  11683.                     $target new SimplePie_IRI('');
  11684.                     $target->set_scheme($base->get_scheme());
  11685.                     $target->set_userinfo($base->get_userinfo());
  11686.                     $target->set_host($base->get_host());
  11687.                     $target->set_port($base->get_port());
  11688.                     if ($relative->get_path(!== null)
  11689.                     {
  11690.                         if (strpos($relative->get_path()'/'=== 0)
  11691.                         {
  11692.                             $target->set_path($relative->get_path());
  11693.                         }
  11694.                         elseif (($base->get_userinfo(!== null || $base->get_host(!== null || $base->get_port(!== null&& $base->get_path(=== null)
  11695.                         {
  11696.                             $target->set_path('/' $relative->get_path());
  11697.                         }
  11698.                         elseif (($last_segment strrpos($base->get_path()'/')) !== false)
  11699.                         {
  11700.                             $target->set_path(substr($base->get_path()0$last_segment 1$relative->get_path());
  11701.                         }
  11702.                         else
  11703.                         {
  11704.                             $target->set_path($relative->get_path());
  11705.                         }
  11706.                         $target->set_query($relative->get_query());
  11707.                     }
  11708.                     else
  11709.                     {
  11710.                         $target->set_path($base->get_path());
  11711.                         if ($relative->get_query(!== null)
  11712.                         {
  11713.                             $target->set_query($relative->get_query());
  11714.                         }
  11715.                         elseif ($base->get_query(!== null)
  11716.                         {
  11717.                             $target->set_query($base->get_query());
  11718.                         }
  11719.                     }
  11720.                 }
  11721.                 $target->set_fragment($relative->get_fragment());
  11722.             }
  11723.             else
  11724.             {
  11725.                 // No base URL, just return the relative URL
  11726.                 $target $relative;
  11727.             }
  11728.         }
  11729.         else
  11730.         {
  11731.             $target $base;
  11732.         }
  11733.         return $target;
  11734.     }
  11735.  
  11736.     /**
  11737.      * Parse an IRI into scheme/authority/path/query/fragment segments
  11738.      *
  11739.      * @access private
  11740.      * @param string $iri 
  11741.      * @return array 
  11742.      */
  11743.     function parse_iri($iri)
  11744.     {
  11745.         preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/'$iri$match);
  11746.         for ($i count($match)$i <= 9$i++)
  11747.         {
  11748.             $match[$i'';
  11749.         }
  11750.         return array('scheme' => $match[2]'authority' => $match[4]'path' => $match[5]'query' => $match[7]'fragment' => $match[9]);
  11751.     }
  11752.  
  11753.     /**
  11754.      * Remove dot segments from a path
  11755.      *
  11756.      * @access private
  11757.      * @param string $input 
  11758.      * @return string 
  11759.      */
  11760.     function remove_dot_segments($input)
  11761.     {
  11762.         $output '';
  11763.         while (strpos($input'./'!== false || strpos($input'/.'!== false || $input === '.' || $input === '..')
  11764.         {
  11765.             // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise,
  11766.             if (strpos($input'../'=== 0)
  11767.             {
  11768.                 $input substr($input3);
  11769.             }
  11770.             elseif (strpos($input'./'=== 0)
  11771.             {
  11772.                 $input substr($input2);
  11773.             }
  11774.             // 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,
  11775.             elseif (strpos($input'/./'=== 0)
  11776.             {
  11777.                 $input substr_replace($input'/'03);
  11778.             }
  11779.             elseif ($input === '/.')
  11780.             {
  11781.                 $input '/';
  11782.             }
  11783.             // 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,
  11784.             elseif (strpos($input'/../'=== 0)
  11785.             {
  11786.                 $input substr_replace($input'/'04);
  11787.                 $output substr_replace($output''strrpos($output'/'));
  11788.             }
  11789.             elseif ($input === '/..')
  11790.             {
  11791.                 $input '/';
  11792.                 $output substr_replace($output''strrpos($output'/'));
  11793.             }
  11794.             // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise,
  11795.             elseif ($input === '.' || $input === '..')
  11796.             {
  11797.                 $input '';
  11798.             }
  11799.             // 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
  11800.             elseif (($pos strpos($input'/'1)) !== false)
  11801.             {
  11802.                 $output .= substr($input0$pos);
  11803.                 $input substr_replace($input''0$pos);
  11804.             }
  11805.             else
  11806.             {
  11807.                 $output .= $input;
  11808.                 $input '';
  11809.             }
  11810.         }
  11811.         return $output $input;
  11812.     }
  11813.  
  11814.     /**
  11815.      * Replace invalid character with percent encoding
  11816.      *
  11817.      * @access private
  11818.      * @param string $string Input string
  11819.      * @param string $valid_chars Valid characters
  11820.      * @param int $case Normalise case
  11821.      * @return string 
  11822.      */
  11823.     function replace_invalid_with_pct_encoding($string$valid_chars$case SIMPLEPIE_SAME_CASE)
  11824.     {
  11825.         // Normalise case
  11826.         if ($case SIMPLEPIE_LOWERCASE)
  11827.         {
  11828.             $string strtolower($string);
  11829.         }
  11830.         elseif ($case SIMPLEPIE_UPPERCASE)
  11831.         {
  11832.             $string strtoupper($string);
  11833.         }
  11834.  
  11835.         // Store position and string length (to avoid constantly recalculating this)
  11836.         $position 0;
  11837.         $strlen strlen($string);
  11838.  
  11839.         // Loop as long as we have invalid characters, advancing the position to the next invalid character
  11840.         while (($position += strspn($string$valid_chars$position)) $strlen)
  11841.         {
  11842.             // If we have a % character
  11843.             if ($string[$position=== '%')
  11844.             {
  11845.                 // If we have a pct-encoded section
  11846.                 if ($position $strlen && strspn($string'0123456789ABCDEFabcdef'$position 12=== 2)
  11847.                 {
  11848.                     // Get the the represented character
  11849.                     $chr chr(hexdec(substr($string$position 12)));
  11850.  
  11851.                     // If the character is valid, replace the pct-encoded with the actual character while normalising case
  11852.                     if (strpos($valid_chars$chr!== false)
  11853.                     {
  11854.                         if ($case SIMPLEPIE_LOWERCASE)
  11855.                         {
  11856.                             $chr strtolower($chr);
  11857.                         }
  11858.                         elseif ($case SIMPLEPIE_UPPERCASE)
  11859.                         {
  11860.                             $chr strtoupper($chr);
  11861.                         }
  11862.                         $string substr_replace($string$chr$position3);
  11863.                         $strlen -= 2;
  11864.                         $position++;
  11865.                     }
  11866.  
  11867.                     // Otherwise just normalise the pct-encoded to uppercase
  11868.                     else
  11869.                     {
  11870.                         $string substr_replace($stringstrtoupper(substr($string$position 12))$position 12);
  11871.                         $position += 3;
  11872.                     }
  11873.                 }
  11874.                 // If we don't have a pct-encoded section, just replace the % with its own esccaped form
  11875.                 else
  11876.                 {
  11877.                     $string substr_replace($string'%25'$position1);
  11878.                     $strlen += 2;
  11879.                     $position += 3;
  11880.                 }
  11881.             }
  11882.             // If we have an invalid character, change into its pct-encoded form
  11883.             else
  11884.             {
  11885.                 $replacement sprintf("%%%02X"ord($string[$position]));
  11886.                 $string str_replace($string[$position]$replacement$string);
  11887.                 $strlen strlen($string);
  11888.             }
  11889.         }
  11890.         return $string;
  11891.     }
  11892.  
  11893.     /**
  11894.      * Check if the object represents a valid IRI
  11895.      *
  11896.      * @access public
  11897.      * @return bool 
  11898.      */
  11899.     function is_valid()
  11900.     {
  11901.         return array_sum($this->valid=== count($this->valid);
  11902.     }
  11903.  
  11904.     /**
  11905.      * Set the scheme. Returns true on success, false on failure (if there are
  11906.      * any invalid characters).
  11907.      *
  11908.      * @access public
  11909.      * @param string $scheme 
  11910.      * @return bool 
  11911.      */
  11912.     function set_scheme($scheme)
  11913.     {
  11914.         if ($scheme === null || $scheme === '')
  11915.         {
  11916.             $this->scheme null;
  11917.         }
  11918.         else
  11919.         {
  11920.             $len strlen($scheme);
  11921.             switch (true)
  11922.             {
  11923.                 case $len 1:
  11924.                     if (!strspn($scheme'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-.'1))
  11925.                     {
  11926.                         $this->scheme null;
  11927.                         $this->valid[__FUNCTION__false;
  11928.                         return false;
  11929.                     }
  11930.  
  11931.                 case $len 0:
  11932.                     if (!strspn($scheme'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'01))
  11933.                     {
  11934.                         $this->scheme null;
  11935.                         $this->valid[__FUNCTION__false;
  11936.                         return false;
  11937.                     }
  11938.             }
  11939.             $this->scheme strtolower($scheme);
  11940.         }
  11941.         $this->valid[__FUNCTION__true;
  11942.         return true;
  11943.     }
  11944.  
  11945.     /**
  11946.      * Set the authority. Returns true on success, false on failure (if there are
  11947.      * any invalid characters).
  11948.      *
  11949.      * @access public
  11950.      * @param string $authority 
  11951.      * @return bool 
  11952.      */
  11953.     function set_authority($authority)
  11954.     {
  11955.         if (($userinfo_end strrpos($authority'@')) !== false)
  11956.         {
  11957.             $userinfo substr($authority0$userinfo_end);
  11958.             $authority substr($authority$userinfo_end 1);
  11959.         }
  11960.         else
  11961.         {
  11962.             $userinfo null;
  11963.         }
  11964.  
  11965.         if (($port_start strpos($authority':')) !== false)
  11966.         {
  11967.             $port substr($authority$port_start 1);
  11968.             $authority substr($authority0$port_start);
  11969.         }
  11970.         else
  11971.         {
  11972.             $port null;
  11973.         }
  11974.  
  11975.         return $this->set_userinfo($userinfo&& $this->set_host($authority&& $this->set_port($port);
  11976.     }
  11977.  
  11978.     /**
  11979.      * Set the userinfo.
  11980.      *
  11981.      * @access public
  11982.      * @param string $userinfo 
  11983.      * @return bool 
  11984.      */
  11985.     function set_userinfo($userinfo)
  11986.     {
  11987.         if ($userinfo === null || $userinfo === '')
  11988.         {
  11989.             $this->userinfo null;
  11990.         }
  11991.         else
  11992.         {
  11993.             $this->userinfo $this->replace_invalid_with_pct_encoding($userinfo'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:');
  11994.         }
  11995.         $this->valid[__FUNCTION__true;
  11996.         return true;
  11997.     }
  11998.  
  11999.     /**
  12000.      * Set the host. Returns true on success, false on failure (if there are
  12001.      * any invalid characters).
  12002.      *
  12003.      * @access public
  12004.      * @param string $host 
  12005.      * @return bool 
  12006.      */
  12007.     function set_host($host)
  12008.     {
  12009.         if ($host === null || $host === '')
  12010.         {
  12011.             $this->host null;
  12012.             $this->valid[__FUNCTION__true;
  12013.             return true;
  12014.         }
  12015.         elseif ($host[0=== '[' && substr($host-1=== ']')
  12016.         {
  12017.             if (Net_IPv6::checkIPv6(substr($host1-1)))
  12018.             {
  12019.                 $this->host $host;
  12020.                 $this->valid[__FUNCTION__true;
  12021.                 return true;
  12022.             }
  12023.             else
  12024.             {
  12025.                 $this->host null;
  12026.                 $this->valid[__FUNCTION__false;
  12027.                 return false;
  12028.             }
  12029.         }
  12030.         else
  12031.         {
  12032.             $this->host $this->replace_invalid_with_pct_encoding($host'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;='SIMPLEPIE_LOWERCASE);
  12033.             $this->valid[__FUNCTION__true;
  12034.             return true;
  12035.         }
  12036.     }
  12037.  
  12038.     /**
  12039.      * Set the port. Returns true on success, false on failure (if there are
  12040.      * any invalid characters).
  12041.      *
  12042.      * @access public
  12043.      * @param string $port 
  12044.      * @return bool 
  12045.      */
  12046.     function set_port($port)
  12047.     {
  12048.         if ($port === null || $port === '')
  12049.         {
  12050.             $this->port null;
  12051.             $this->valid[__FUNCTION__true;
  12052.             return true;
  12053.         }
  12054.         elseif (strspn($port'0123456789'=== strlen($port))
  12055.         {
  12056.             $this->port = (int) $port;
  12057.             $this->valid[__FUNCTION__true;
  12058.             return true;
  12059.         }
  12060.         else
  12061.         {
  12062.             $this->port null;
  12063.             $this->valid[__FUNCTION__false;
  12064.             return false;
  12065.         }
  12066.     }
  12067.  
  12068.     /**
  12069.      * Set the path.
  12070.      *
  12071.      * @access public
  12072.      * @param string $path 
  12073.      * @return bool 
  12074.      */
  12075.     function set_path($path)
  12076.     {
  12077.         if ($path === null || $path === '')
  12078.         {
  12079.             $this->path null;
  12080.             $this->valid[__FUNCTION__true;
  12081.             return true;
  12082.         }
  12083.         elseif (substr($path02=== '//' && $this->userinfo === null && $this->host === null && $this->port === null)
  12084.         {
  12085.             $this->path null;
  12086.             $this->valid[__FUNCTION__false;
  12087.             return false;
  12088.         }
  12089.         else
  12090.         {
  12091.             $this->path $this->replace_invalid_with_pct_encoding($path'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=@/');
  12092.             if ($this->scheme !== null)
  12093.             {
  12094.                 $this->path $this->remove_dot_segments($this->path);
  12095.             }
  12096.             $this->valid[__FUNCTION__true;
  12097.             return true;
  12098.         }
  12099.     }
  12100.  
  12101.     /**
  12102.      * Set the query.
  12103.      *
  12104.      * @access public
  12105.      * @param string $query 
  12106.      * @return bool 
  12107.      */
  12108.     function set_query($query)
  12109.     {
  12110.         if ($query === null || $query === '')
  12111.         {
  12112.             $this->query null;
  12113.         }
  12114.         else
  12115.         {
  12116.             $this->query $this->replace_invalid_with_pct_encoding($query'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:@/?');
  12117.         }
  12118.         $this->valid[__FUNCTION__true;
  12119.         return true;
  12120.     }
  12121.  
  12122.     /**
  12123.      * Set the fragment.
  12124.      *
  12125.      * @access public
  12126.      * @param string $fragment 
  12127.      * @return bool 
  12128.      */
  12129.     function set_fragment($fragment)
  12130.     {
  12131.         if ($fragment === null || $fragment === '')
  12132.         {
  12133.             $this->fragment null;
  12134.         }
  12135.         else
  12136.         {
  12137.             $this->fragment $this->replace_invalid_with_pct_encoding($fragment'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:@/?');
  12138.         }
  12139.         $this->valid[__FUNCTION__true;
  12140.         return true;
  12141.     }
  12142.  
  12143.     /**
  12144.      * Get the complete IRI
  12145.      *
  12146.      * @access public
  12147.      * @return string 
  12148.      */
  12149.     function get_iri()
  12150.     {
  12151.         $iri '';
  12152.         if ($this->scheme !== null)
  12153.         {
  12154.             $iri .= $this->scheme ':';
  12155.         }
  12156.         if (($authority $this->get_authority()) !== null)
  12157.         {
  12158.             $iri .= '//' $authority;
  12159.         }
  12160.         if ($this->path !== null)
  12161.         {
  12162.             $iri .= $this->path;
  12163.         }
  12164.         if ($this->query !== null)
  12165.         {
  12166.             $iri .= '?' $this->query;
  12167.         }
  12168.         if ($this->fragment !== null)
  12169.         {
  12170.             $iri .= '#' $this->fragment;
  12171.         }
  12172.  
  12173.         if ($iri !== '')
  12174.         {
  12175.             return $iri;
  12176.         }
  12177.         else
  12178.         {
  12179.             return null;
  12180.         }
  12181.     }
  12182.  
  12183.     /**
  12184.      * Get the scheme
  12185.      *
  12186.      * @access public
  12187.      * @return string 
  12188.      */
  12189.     function get_scheme()
  12190.     {
  12191.         return $this->scheme;
  12192.     }
  12193.  
  12194.     /**
  12195.      * Get the complete authority
  12196.      *
  12197.      * @access public
  12198.      * @return string 
  12199.      */
  12200.     function get_authority()
  12201.     {
  12202.         $authority '';
  12203.         if ($this->userinfo !== null)
  12204.         {
  12205.             $authority .= $this->userinfo '@';
  12206.         }
  12207.         if ($this->host !== null)
  12208.         {
  12209.             $authority .= $this->host;
  12210.         }
  12211.         if ($this->port !== null)
  12212.         {
  12213.             $authority .= ':' $this->port;
  12214.         }
  12215.  
  12216.         if ($authority !== '')
  12217.         {
  12218.             return $authority;
  12219.         }
  12220.         else
  12221.         {
  12222.             return null;
  12223.         }
  12224.     }
  12225.  
  12226.     /**
  12227.      * Get the user information
  12228.      *
  12229.      * @access public
  12230.      * @return string 
  12231.      */
  12232.     function get_userinfo()
  12233.     {
  12234.         return $this->userinfo;
  12235.     }
  12236.  
  12237.     /**
  12238.      * Get the host
  12239.      *
  12240.      * @access public
  12241.      * @return string 
  12242.      */
  12243.     function get_host()
  12244.     {
  12245.         return $this->host;
  12246.     }
  12247.  
  12248.     /**
  12249.      * Get the port
  12250.      *
  12251.      * @access public
  12252.      * @return string 
  12253.      */
  12254.     function get_port()
  12255.     {
  12256.         return $this->port;
  12257.     }
  12258.  
  12259.     /**
  12260.      * Get the path
  12261.      *
  12262.      * @access public
  12263.      * @return string 
  12264.      */
  12265.     function get_path()
  12266.     {
  12267.         return $this->path;
  12268.     }
  12269.  
  12270.     /**
  12271.      * Get the query
  12272.      *
  12273.      * @access public
  12274.      * @return string 
  12275.      */
  12276.     function get_query()
  12277.     {
  12278.         return $this->query;
  12279.     }
  12280.  
  12281.     /**
  12282.      * Get the fragment
  12283.      *
  12284.      * @access public
  12285.      * @return string 
  12286.      */
  12287.     function get_fragment()
  12288.     {
  12289.         return $this->fragment;
  12290.     }
  12291. }
  12292.  
  12293. /**
  12294.  * Class to validate and to work with IPv6 addresses.
  12295.  *
  12296.  * @package SimplePie
  12297.  * @copyright 2003-2005 The PHP Group
  12298.  * @license http://www.opensource.org/licenses/bsd-license.php
  12299.  * @link http://pear.php.net/package/Net_IPv6
  12300.  * @author Alexander Merz <alexander.merz@web.de>
  12301.  * @author elfrink at introweb dot nl
  12302.  * @author Josh Peck <jmp at joshpeck dot org>
  12303.  * @author Geoffrey Sneddon <geoffers@gmail.com>
  12304.  */
  12305. {
  12306.     /**
  12307.      * Removes a possible existing netmask specification of an IP address.
  12308.      *
  12309.      * @param string $ip the (compressed) IP as Hex representation
  12310.      * @return string the IP the without netmask
  12311.      * @since 1.1.0
  12312.      * @access public
  12313.      * @static
  12314.      */
  12315.     function removeNetmaskSpec($ip)
  12316.     {
  12317.         if (strpos($ip'/'!== false)
  12318.         {
  12319.             list($addr$nmexplode('/'$ip);
  12320.         }
  12321.         else
  12322.         {
  12323.             $addr $ip;
  12324.         }
  12325.         return $addr;
  12326.     }
  12327.  
  12328.     /**
  12329.      * Uncompresses an IPv6 address
  12330.      *
  12331.      * RFC 2373 allows you to compress zeros in an address to '::'. This
  12332.      * function expects an valid IPv6 address and expands the '::' to
  12333.      * the required zeros.
  12334.      *
  12335.      * Example:     FF01::101    ->    FF01:0:0:0:0:0:0:101
  12336.      *             ::1        ->    0:0:0:0:0:0:0:1
  12337.      *
  12338.      * @access public
  12339.      * @static
  12340.      * @param string $ip a valid IPv6-address (hex format)
  12341.      * @return string the uncompressed IPv6-address (hex format)
  12342.      */
  12343.     function Uncompress($ip)
  12344.     {
  12345.         $uip SimplePie_Net_IPv6::removeNetmaskSpec($ip);
  12346.         $c1 = -1;
  12347.         $c2 = -1;
  12348.         if (strpos($ip'::'!== false)
  12349.         {
  12350.             list($ip1$ip2explode('::'$ip);
  12351.             if ($ip1 === '')
  12352.             {
  12353.                 $c1 = -1;
  12354.             }
  12355.             else
  12356.             {
  12357.                 $pos 0;
  12358.                 if (($pos substr_count($ip1':')) 0)
  12359.                 {
  12360.                     $c1 $pos;
  12361.                 }
  12362.                 else
  12363.                 {
  12364.                     $c1 0;
  12365.                 }
  12366.             }
  12367.             if ($ip2 === '')
  12368.             {
  12369.                 $c2 = -1;
  12370.             }
  12371.             else
  12372.             {
  12373.                 $pos 0;
  12374.                 if (($pos substr_count($ip2':')) 0)
  12375.                 {
  12376.                     $c2 $pos;
  12377.                 }
  12378.                 else
  12379.                 {
  12380.                     $c2 0;
  12381.                 }
  12382.             }
  12383.             if (strstr($ip2'.'))
  12384.             {
  12385.                 $c2++;
  12386.             }
  12387.             // ::
  12388.             if ($c1 === -&& $c2 === -1)
  12389.             {
  12390.                 $uip '0:0:0:0:0:0:0:0';
  12391.             }
  12392.             // ::xxx
  12393.             else if ($c1 === -1)
  12394.             {
  12395.                 $fill str_repeat('0:'$c2);
  12396.                 $uip =    str_replace('::'$fill$uip);
  12397.             }
  12398.             // xxx::
  12399.             else if ($c2 === -1)
  12400.             {
  12401.                 $fill str_repeat(':0'$c1);
  12402.                 $uip =    str_replace('::'$fill$uip);
  12403.             }
  12404.             // xxx::xxx
  12405.             else
  12406.             {
  12407.                 $fill str_repeat(':0:'$c2 $c1);
  12408.                 $uip =    str_replace('::'$fill$uip);
  12409.                 $uip =    str_replace('::'':'$uip);
  12410.             }
  12411.         }
  12412.         return $uip;
  12413.     }
  12414.  
  12415.     /**
  12416.      * Splits an IPv6 address into the IPv6 and a possible IPv4 part
  12417.      *
  12418.      * RFC 2373 allows you to note the last two parts of an IPv6 address as
  12419.      * an IPv4 compatible address
  12420.      *
  12421.      * Example:     0:0:0:0:0:0:13.1.68.3
  12422.      *             0:0:0:0:0:FFFF:129.144.52.38
  12423.      *
  12424.      * @access public
  12425.      * @static
  12426.      * @param string $ip a valid IPv6-address (hex format)
  12427.      * @return array [0] contains the IPv6 part, [1] the IPv4 part (hex format)
  12428.      */
  12429.     function SplitV64($ip)
  12430.     {
  12431.         $ip SimplePie_Net_IPv6::Uncompress($ip);
  12432.         if (strstr($ip'.'))
  12433.         {
  12434.             $pos strrpos($ip':');
  12435.             $ip[$pos'_';
  12436.             $ipPart explode('_'$ip);
  12437.             return $ipPart;
  12438.         }
  12439.         else
  12440.         {
  12441.             return array($ip'');
  12442.         }
  12443.     }
  12444.  
  12445.     /**
  12446.      * Checks an IPv6 address
  12447.      *
  12448.      * Checks if the given IP is IPv6-compatible
  12449.      *
  12450.      * @access public
  12451.      * @static
  12452.      * @param string $ip a valid IPv6-address
  12453.      * @return bool true if $ip is an IPv6 address
  12454.      */
  12455.     function checkIPv6($ip)
  12456.     {
  12457.         $ipPart SimplePie_Net_IPv6::SplitV64($ip);
  12458.         $count 0;
  12459.         if (!empty($ipPart[0]))
  12460.         {
  12461.             $ipv6 explode(':'$ipPart[0]);
  12462.             for ($i 0$i count($ipv6)$i++)
  12463.             {
  12464.                 $dec hexdec($ipv6[$i]);
  12465.                 $hex strtoupper(preg_replace('/^[0]{1,3}(.*[0-9a-fA-F])$/''\\1'$ipv6[$i]));
  12466.                 if ($ipv6[$i>= && $dec <= 65535 && $hex === strtoupper(dechex($dec)))
  12467.                 {
  12468.                     $count++;
  12469.                 }
  12470.             }
  12471.             if ($count === 8)
  12472.             {
  12473.                 return true;
  12474.             }
  12475.             elseif ($count === && !empty($ipPart[1]))
  12476.             {
  12477.                 $ipv4 explode('.'$ipPart[1]);
  12478.                 $count 0;
  12479.                 foreach ($ipv4 as $ipv4_part)
  12480.                 {
  12481.                     if ($ipv4_part >= && $ipv4_part <= 255 && preg_match('/^\d{1,3}$/'$ipv4_part))
  12482.                     {
  12483.                         $count++;
  12484.                     }
  12485.                 }
  12486.                 if ($count === 4)
  12487.                 {
  12488.                     return true;
  12489.                 }
  12490.             }
  12491.             else
  12492.             {
  12493.                 return false;
  12494.             }
  12495.  
  12496.         }
  12497.         else
  12498.         {
  12499.             return false;
  12500.         }
  12501.     }
  12502. }
  12503.  
  12504. /**
  12505.  * Date Parser
  12506.  *
  12507.  * @package SimplePie
  12508.  */
  12509. {
  12510.     /**
  12511.      * Input data
  12512.      *
  12513.      * @access protected
  12514.      * @var string 
  12515.      */
  12516.     var $date;
  12517.  
  12518.     /**
  12519.      * List of days, calendar day name => ordinal day number in the week
  12520.      *
  12521.      * @access protected
  12522.      * @var array 
  12523.      */
  12524.     var $day = array(
  12525.         // English
  12526.         'mon' => 1,
  12527.         'monday' => 1,
  12528.         'tue' => 2,
  12529.         'tuesday' => 2,
  12530.         'wed' => 3,
  12531.         'wednesday' => 3,
  12532.         'thu' => 4,
  12533.         'thursday' => 4,
  12534.         'fri' => 5,
  12535.         'friday' => 5,
  12536.         'sat' => 6,
  12537.         'saturday' => 6,
  12538.         'sun' => 7,
  12539.         'sunday' => 7,
  12540.         // Dutch
  12541.         'maandag' => 1,
  12542.         'dinsdag' => 2,
  12543.         'woensdag' => 3,
  12544.         'donderdag' => 4,
  12545.         'vrijdag' => 5,
  12546.         'zaterdag' => 6,
  12547.         'zondag' => 7,
  12548.         // French
  12549.         'lundi' => 1,
  12550.         'mardi' => 2,
  12551.         'mercredi' => 3,
  12552.         'jeudi' => 4,
  12553.         'vendredi' => 5,
  12554.         'samedi' => 6,
  12555.         'dimanche' => 7,
  12556.         // German
  12557.         'montag' => 1,
  12558.         'dienstag' => 2,
  12559.         'mittwoch' => 3,
  12560.         'donnerstag' => 4,
  12561.         'freitag' => 5,
  12562.         'samstag' => 6,
  12563.         'sonnabend' => 6,
  12564.         'sonntag' => 7,
  12565.         // Italian
  12566.         'lunedì' => 1,
  12567.         'martedì' => 2,
  12568.         'mercoledì' => 3,
  12569.         'giovedì' => 4,
  12570.         'venerdì' => 5,
  12571.         'sabato' => 6,
  12572.         'domenica' => 7,
  12573.         // Spanish
  12574.         'lunes' => 1,
  12575.         'martes' => 2,
  12576.         'miércoles' => 3,
  12577.         'jueves' => 4,
  12578.         'viernes' => 5,
  12579.         'sábado' => 6,
  12580.         'domingo' => 7,
  12581.         // Finnish
  12582.         'maanantai' => 1,
  12583.         'tiistai' => 2,
  12584.         'keskiviikko' => 3,
  12585.         'torstai' => 4,
  12586.         'perjantai' => 5,
  12587.         'lauantai' => 6,
  12588.         'sunnuntai' => 7,
  12589.         // Hungarian
  12590.         'hétfő' => 1,
  12591.         'kedd' => 2,
  12592.         'szerda' => 3,
  12593.         'csütörtok' => 4,
  12594.         'péntek' => 5,
  12595.         'szombat' => 6,
  12596.         'vasárnap' => 7,
  12597.         // Greek
  12598.         'Δευ' => 1,
  12599.         'Τρι' => 2,
  12600.         'Τετ' => 3,
  12601.         'Πεμ' => 4,
  12602.         'Παρ' => 5,
  12603.         'Σαβ' => 6,
  12604.         'Κυρ' => 7,
  12605.     );
  12606.  
  12607.     /**
  12608.      * List of months, calendar month name => calendar month number
  12609.      *
  12610.      * @access protected
  12611.      * @var array 
  12612.      */
  12613.     var $month = array(
  12614.         // English
  12615.         'jan' => 1,
  12616.         'january' => 1,
  12617.         'feb' => 2,
  12618.         'february' => 2,
  12619.         'mar' => 3,
  12620.         'march' => 3,
  12621.         'apr' => 4,
  12622.         'april' => 4,
  12623.         'may' => 5,
  12624.         // No long form of May
  12625.         'jun' => 6,
  12626.         'june' => 6,
  12627.         'jul' => 7,
  12628.         'july' => 7,
  12629.         'aug' => 8,
  12630.         'august' => 8,
  12631.         'sep' => 9,
  12632.         'september' => 8,
  12633.         'oct' => 10,
  12634.         'october' => 10,
  12635.         'nov' => 11,
  12636.         'november' => 11,
  12637.         'dec' => 12,
  12638.         'december' => 12,
  12639.         // Dutch
  12640.         'januari' => 1,
  12641.         'februari' => 2,
  12642.         'maart' => 3,
  12643.         'april' => 4,
  12644.         'mei' => 5,
  12645.         'juni' => 6,
  12646.         'juli' => 7,
  12647.         'augustus' => 8,
  12648.         'september' => 9,
  12649.         'oktober' => 10,
  12650.         'november' => 11,
  12651.         'december' => 12,
  12652.         // French
  12653.         'janvier' => 1,
  12654.         'février' => 2,
  12655.         'mars' => 3,
  12656.         'avril' => 4,
  12657.         'mai' => 5,
  12658.         'juin' => 6,
  12659.         'juillet' => 7,
  12660.         'août' => 8,
  12661.         'septembre' => 9,
  12662.         'octobre' => 10,
  12663.         'novembre' => 11,
  12664.         'décembre' => 12,
  12665.         // German
  12666.         'januar' => 1,
  12667.         'februar' => 2,
  12668.         'märz' => 3,
  12669.         'april' => 4,
  12670.         'mai' => 5,
  12671.         'juni' => 6,
  12672.         'juli' => 7,
  12673.         'august' => 8,
  12674.         'september' => 9,
  12675.         'oktober' => 10,
  12676.         'november' => 11,
  12677.         'dezember' => 12,
  12678.         // Italian
  12679.         'gennaio' => 1,
  12680.         'febbraio' => 2,
  12681.         'marzo' => 3,
  12682.         'aprile' => 4,
  12683.         'maggio' => 5,
  12684.         'giugno' => 6,
  12685.         'luglio' => 7,
  12686.         'agosto' => 8,
  12687.         'settembre' => 9,
  12688.         'ottobre' => 10,
  12689.         'novembre' => 11,
  12690.         'dicembre' => 12,
  12691.         // Spanish
  12692.         'enero' => 1,
  12693.         'febrero' => 2,
  12694.         'marzo' => 3,
  12695.         'abril' => 4,
  12696.         'mayo' => 5,
  12697.         'junio' => 6,
  12698.         'julio' => 7,
  12699.         'agosto' => 8,
  12700.         'septiembre' => 9,
  12701.         'setiembre' => 9,
  12702.         'octubre' => 10,
  12703.         'noviembre' => 11,
  12704.         'diciembre' => 12,
  12705.         // Finnish
  12706.         'tammikuu' => 1,
  12707.         'helmikuu' => 2,
  12708.         'maaliskuu' => 3,
  12709.         'huhtikuu' => 4,
  12710.         'toukokuu' => 5,
  12711.         'kesäkuu' => 6,
  12712.         'heinäkuu' => 7,
  12713.         'elokuu' => 8,
  12714.         'suuskuu' => 9,
  12715.         'lokakuu' => 10,
  12716.         'marras' => 11,
  12717.         'joulukuu' => 12,
  12718.         // Hungarian
  12719.         'január' => 1,
  12720.         'február' => 2,
  12721.         'március' => 3,
  12722.         'április' => 4,
  12723.         'május' => 5,
  12724.         'június' => 6,
  12725.         'július' => 7,
  12726.         'augusztus' => 8,
  12727.         'szeptember' => 9,
  12728.         'október' => 10,
  12729.         'november' => 11,
  12730.         'december' => 12,
  12731.         // Greek
  12732.         'Ιαν' => 1,
  12733.         'Φεβ' => 2,
  12734.         'Μάώ' => 3,
  12735.         'Μαώ' => 3,
  12736.         'Απρ' => 4,
  12737.         'Μάι' => 5,
  12738.         'Μαϊ' => 5,
  12739.         'Μαι' => 5,
  12740.         'Ιούν' => 6,
  12741.         'Ιον' => 6,
  12742.         'Ιούλ' => 7,
  12743.         'Ιολ' => 7,
  12744.         'Αύγ' => 8,
  12745.         'Αυγ' => 8,
  12746.         'Σεπ' => 9,
  12747.         'Οκτ' => 10,
  12748.         'Νοέ' => 11,
  12749.         'Δεκ' => 12,
  12750.     );
  12751.  
  12752.     /**
  12753.      * List of timezones, abbreviation => offset from UTC
  12754.      *
  12755.      * @access protected
  12756.      * @var array 
  12757.      */
  12758.     var $timezone = array(
  12759.         'ACDT' => 37800,
  12760.         'ACIT' => 28800,
  12761.         'ACST' => 34200,
  12762.         'ACT' => -18000,
  12763.         'ACWDT' => 35100,
  12764.         'ACWST' => 31500,
  12765.         'AEDT' => 39600,
  12766.         'AEST' => 36000,
  12767.         'AFT' => 16200,
  12768.         'AKDT' => -28800,
  12769.         'AKST' => -32400,
  12770.         'AMDT' => 18000,
  12771.         'AMT' => -14400,
  12772.         'ANAST' => 46800,
  12773.         'ANAT' => 43200,
  12774.         'ART' => -10800,
  12775.         'AZOST' => -3600,
  12776.         'AZST' => 18000,
  12777.         'AZT' => 14400,
  12778.         'BIOT' => 21600,
  12779.         'BIT' => -43200,
  12780.         'BOT' => -14400,
  12781.         'BRST' => -7200,
  12782.         'BRT' => -10800,
  12783.         'BST' => 3600,
  12784.         'BTT' => 21600,
  12785.         'CAST' => 18000,
  12786.         'CAT' => 7200,
  12787.         'CCT' => 23400,
  12788.         'CDT' => -18000,
  12789.         'CEDT' => 7200,
  12790.         'CET' => 3600,
  12791.         'CGST' => -7200,
  12792.         'CGT' => -10800,
  12793.         'CHADT' => 49500,
  12794.         'CHAST' => 45900,
  12795.         'CIST' => -28800,
  12796.         'CKT' => -36000,
  12797.         'CLDT' => -10800,
  12798.         'CLST' => -14400,
  12799.         'COT' => -18000,
  12800.         'CST' => -21600,
  12801.         'CVT' => -3600,
  12802.         'CXT' => 25200,
  12803.         'DAVT' => 25200,
  12804.         'DTAT' => 36000,
  12805.         'EADT' => -18000,
  12806.         'EAST' => -21600,
  12807.         'EAT' => 10800,
  12808.         'ECT' => -18000,
  12809.         'EDT' => -14400,
  12810.         'EEST' => 10800,
  12811.         'EET' => 7200,
  12812.         'EGT' => -3600,
  12813.         'EKST' => 21600,
  12814.         'EST' => -18000,
  12815.         'FJT' => 43200,
  12816.         'FKDT' => -10800,
  12817.         'FKST' => -14400,
  12818.         'FNT' => -7200,
  12819.         'GALT' => -21600,
  12820.         'GEDT' => 14400,
  12821.         'GEST' => 10800,
  12822.         'GFT' => -10800,
  12823.         'GILT' => 43200,
  12824.         'GIT' => -32400,
  12825.         'GST' => 14400,
  12826.         'GST' => -7200,
  12827.         'GYT' => -14400,
  12828.         'HAA' => -10800,
  12829.         'HAC' => -18000,
  12830.         'HADT' => -32400,
  12831.         'HAE' => -14400,
  12832.         'HAP' => -25200,
  12833.         'HAR' => -21600,
  12834.         'HAST' => -36000,
  12835.         'HAT' => -9000,
  12836.         'HAY' => -28800,
  12837.         'HKST' => 28800,
  12838.         'HMT' => 18000,
  12839.         'HNA' => -14400,
  12840.         'HNC' => -21600,
  12841.         'HNE' => -18000,
  12842.         'HNP' => -28800,
  12843.         'HNR' => -25200,
  12844.         'HNT' => -12600,
  12845.         'HNY' => -32400,
  12846.         'IRDT' => 16200,
  12847.         'IRKST' => 32400,
  12848.         'IRKT' => 28800,
  12849.         'IRST' => 12600,
  12850.         'JFDT' => -10800,
  12851.         'JFST' => -14400,
  12852.         'JST' => 32400,
  12853.         'KGST' => 21600,
  12854.         'KGT' => 18000,
  12855.         'KOST' => 39600,
  12856.         'KOVST' => 28800,
  12857.         'KOVT' => 25200,
  12858.         'KRAST' => 28800,
  12859.         'KRAT' => 25200,
  12860.         'KST' => 32400,
  12861.         'LHDT' => 39600,
  12862.         'LHST' => 37800,
  12863.         'LINT' => 50400,
  12864.         'LKT' => 21600,
  12865.         'MAGST' => 43200,
  12866.         'MAGT' => 39600,
  12867.         'MAWT' => 21600,
  12868.         'MDT' => -21600,
  12869.         'MESZ' => 7200,
  12870.         'MEZ' => 3600,
  12871.         'MHT' => 43200,
  12872.         'MIT' => -34200,
  12873.         'MNST' => 32400,
  12874.         'MSDT' => 14400,
  12875.         'MSST' => 10800,
  12876.         'MST' => -25200,
  12877.         'MUT' => 14400,
  12878.         'MVT' => 18000,
  12879.         'MYT' => 28800,
  12880.         'NCT' => 39600,
  12881.         'NDT' => -9000,
  12882.         'NFT' => 41400,
  12883.         'NMIT' => 36000,
  12884.         'NOVST' => 25200,
  12885.         'NOVT' => 21600,
  12886.         'NPT' => 20700,
  12887.         'NRT' => 43200,
  12888.         'NST' => -12600,
  12889.         'NUT' => -39600,
  12890.         'NZDT' => 46800,
  12891.         'NZST' => 43200,
  12892.         'OMSST' => 25200,
  12893.         'OMST' => 21600,
  12894.         'PDT' => -25200,
  12895.         'PET' => -18000,
  12896.         'PETST' => 46800,
  12897.         'PETT' => 43200,
  12898.         'PGT' => 36000,
  12899.         'PHOT' => 46800,
  12900.         'PHT' => 28800,
  12901.         'PKT' => 18000,
  12902.         'PMDT' => -7200,
  12903.         'PMST' => -10800,
  12904.         'PONT' => 39600,
  12905.         'PST' => -28800,
  12906.         'PWT' => 32400,
  12907.         'PYST' => -10800,
  12908.         'PYT' => -14400,
  12909.         'RET' => 14400,
  12910.         'ROTT' => -10800,
  12911.         'SAMST' => 18000,
  12912.         'SAMT' => 14400,
  12913.         'SAST' => 7200,
  12914.         'SBT' => 39600,
  12915.         'SCDT' => 46800,
  12916.         'SCST' => 43200,
  12917.         'SCT' => 14400,
  12918.         'SEST' => 3600,
  12919.         'SGT' => 28800,
  12920.         'SIT' => 28800,
  12921.         'SRT' => -10800,
  12922.         'SST' => -39600,
  12923.         'SYST' => 10800,
  12924.         'SYT' => 7200,
  12925.         'TFT' => 18000,
  12926.         'THAT' => -36000,
  12927.         'TJT' => 18000,
  12928.         'TKT' => -36000,
  12929.         'TMT' => 18000,
  12930.         'TOT' => 46800,
  12931.         'TPT' => 32400,
  12932.         'TRUT' => 36000,
  12933.         'TVT' => 43200,
  12934.         'TWT' => 28800,
  12935.         'UYST' => -7200,
  12936.         'UYT' => -10800,
  12937.         'UZT' => 18000,
  12938.         'VET' => -14400,
  12939.         'VLAST' => 39600,
  12940.         'VLAT' => 36000,
  12941.         'VOST' => 21600,
  12942.         'VUT' => 39600,
  12943.         'WAST' => 7200,
  12944.         'WAT' => 3600,
  12945.         'WDT' => 32400,
  12946.         'WEST' => 3600,
  12947.         'WFT' => 43200,
  12948.         'WIB' => 25200,
  12949.         'WIT' => 32400,
  12950.         'WITA' => 28800,
  12951.         'WKST' => 18000,
  12952.         'WST' => 28800,
  12953.         'YAKST' => 36000,
  12954.         'YAKT' => 32400,
  12955.         'YAPT' => 36000,
  12956.         'YEKST' => 21600,
  12957.         'YEKT' => 18000,
  12958.     );
  12959.  
  12960.     /**
  12961.      * Cached PCRE for SimplePie_Parse_Date::$day
  12962.      *
  12963.      * @access protected
  12964.      * @var string 
  12965.      */
  12966.     var $day_pcre;
  12967.  
  12968.     /**
  12969.      * Cached PCRE for SimplePie_Parse_Date::$month
  12970.      *
  12971.      * @access protected
  12972.      * @var string 
  12973.      */
  12974.     var $month_pcre;
  12975.  
  12976.     /**
  12977.      * Array of user-added callback methods
  12978.      *
  12979.      * @access private
  12980.      * @var array 
  12981.      */
  12982.     var $built_in array();
  12983.  
  12984.     /**
  12985.      * Array of user-added callback methods
  12986.      *
  12987.      * @access private
  12988.      * @var array 
  12989.      */
  12990.     var $user array();
  12991.  
  12992.     /**
  12993.      * Create new SimplePie_Parse_Date object, and set self::day_pcre,
  12994.      * self::month_pcre, and self::built_in
  12995.      *
  12996.      * @access private
  12997.      */
  12998.     function SimplePie_Parse_Date()
  12999.     {
  13000.         $this->day_pcre = '(' implode(array_keys($this->day)'|'')';
  13001.         $this->month_pcre = '(' implode(array_keys($this->month)'|'')';
  13002.  
  13003.         static $cache;
  13004.         if (!isset($cache[get_class($this)]))
  13005.         {
  13006.             $all_methods get_class_methods($this);
  13007.  
  13008.             foreach ($all_methods as $method)
  13009.             {
  13010.                 if (strtolower(substr($method05)) === 'date_')
  13011.                 {
  13012.                     $cache[get_class($this)][$method;
  13013.                 }
  13014.             }
  13015.         }
  13016.  
  13017.         foreach ($cache[get_class($this)as $method)
  13018.         {
  13019.             $this->built_in[$method;
  13020.         }
  13021.     }
  13022.  
  13023.     /**
  13024.      * Get the object
  13025.      *
  13026.      * @access public
  13027.      */
  13028.     function get()
  13029.     {
  13030.         static $object;
  13031.         if (!$object)
  13032.         {
  13033.             $object new SimplePie_Parse_Date;
  13034.         }
  13035.         return $object;
  13036.     }
  13037.  
  13038.     /**
  13039.      * Parse a date
  13040.      *
  13041.      * @final
  13042.      * @access public
  13043.      * @param string $date Date to parse
  13044.      * @return int Timestamp corresponding to date string, or false on failure
  13045.      */
  13046.     function parse($date)
  13047.     {
  13048.         foreach ($this->user as $method)
  13049.         {
  13050.             if (($returned call_user_func($method$date)) !== false)
  13051.             {
  13052.                 return $returned;
  13053.             }
  13054.         }
  13055.  
  13056.         foreach ($this->built_in as $method)
  13057.         {
  13058.             if (($returned call_user_func(array(&$this$method)$date)) !== false)
  13059.             {
  13060.                 return $returned;
  13061.             }
  13062.         }
  13063.  
  13064.         return false;
  13065.     }
  13066.  
  13067.     /**
  13068.      * Add a callback method to parse a date
  13069.      *
  13070.      * @final
  13071.      * @access public
  13072.      * @param callback $callback 
  13073.      */
  13074.     function add_callback($callback)
  13075.     {
  13076.         if (is_callable($callback))
  13077.         {
  13078.             $this->user[$callback;
  13079.         }
  13080.         else
  13081.         {
  13082.             trigger_error('User-supplied function must be a valid callback'E_USER_WARNING);
  13083.         }
  13084.     }
  13085.  
  13086.     /**
  13087.      * Parse a superset of W3C-DTF (allows hyphens and colons to be omitted, as
  13088.      * well as allowing any of upper or lower case "T", horizontal tabs, or
  13089.      * spaces to be used as the time seperator (including more than one))
  13090.      *
  13091.      * @access protected
  13092.      * @return int Timestamp
  13093.      */
  13094.     function date_w3cdtf($date)
  13095.     {
  13096.         static $pcre;
  13097.         if (!$pcre)
  13098.         {
  13099.             $year '([0-9]{4})';
  13100.             $month $day $hour $minute $second '([0-9]{2})';
  13101.             $decimal '([0-9]*)';
  13102.             $zone '(?:(Z)|([+\-])([0-9]{1,2}):?([0-9]{1,2}))';
  13103.             $pcre '/^' $year '(?:-?' $month '(?:-?' $day '(?:[Tt\x09\x20]+' $hour '(?::?' $minute '(?::?' $second '(?:.' $decimal ')?)?)?' $zone ')?)?)?$/';
  13104.         }
  13105.         if (preg_match($pcre$date$match))
  13106.         {
  13107.             /*
  13108.             Capturing subpatterns:
  13109.             1: Year
  13110.             2: Month
  13111.             3: Day
  13112.             4: Hour
  13113.             5: Minute
  13114.             6: Second
  13115.             7: Decimal fraction of a second
  13116.             8: Zulu
  13117.             9: Timezone ±
  13118.             10: Timezone hours
  13119.             11: Timezone minutes
  13120.             */
  13121.  
  13122.             // Fill in empty matches
  13123.             for ($i count($match)$i <= 3$i++)
  13124.             {
  13125.                 $match[$i'1';
  13126.             }
  13127.  
  13128.             for ($i count($match)$i <= 7$i++)
  13129.             {
  13130.                 $match[$i'0';
  13131.             }
  13132.  
  13133.             // Numeric timezone
  13134.             if (isset($match[9]&& $match[9!== '')
  13135.             {
  13136.                 $timezone $match[103600;
  13137.                 $timezone += $match[1160;
  13138.                 if ($match[9=== '-')
  13139.                 {
  13140.                     $timezone $timezone;
  13141.                 }
  13142.             }
  13143.             else
  13144.             {
  13145.                 $timezone 0;
  13146.             }
  13147.  
  13148.             // Convert the number of seconds to an integer, taking decimals into account
  13149.             $second round($match[6$match[7pow(10strlen($match[7])));
  13150.  
  13151.             return gmmktime($match[4]$match[5]$second$match[2]$match[3]$match[1]$timezone;
  13152.         }
  13153.         else
  13154.         {
  13155.             return false;
  13156.         }
  13157.     }
  13158.  
  13159.     /**
  13160.      * Remove RFC822 comments
  13161.      *
  13162.      * @access protected
  13163.      * @param string $data Data to strip comments from
  13164.      * @return string Comment stripped string
  13165.      */
  13166.     function remove_rfc2822_comments($string)
  13167.     {
  13168.         $string = (string) $string;
  13169.         $position 0;
  13170.         $length strlen($string);
  13171.         $depth 0;
  13172.  
  13173.         $output '';
  13174.  
  13175.         while ($position $length && ($pos strpos($string'('$position)) !== false)
  13176.         {
  13177.             $output .= substr($string$position$pos $position);
  13178.             $position $pos 1;
  13179.             if ($string[$pos 1!== '\\')
  13180.             {
  13181.                 $depth++;
  13182.                 while ($depth && $position $length)
  13183.                 {
  13184.                     $position += strcspn($string'()'$position);
  13185.                     if ($string[$position 1=== '\\')
  13186.                     {
  13187.                         $position++;
  13188.                         continue;
  13189.                     }
  13190.                     elseif (isset($string[$position]))
  13191.                     {
  13192.                         switch ($string[$position])
  13193.                         {
  13194.                             case '(':
  13195.                                 $depth++;
  13196.                                 break;
  13197.  
  13198.                             case ')':
  13199.                                 $depth--;
  13200.                                 break;
  13201.                         }
  13202.                         $position++;
  13203.                     }
  13204.                     else
  13205.                     {
  13206.                         break;
  13207.                     }
  13208.                 }
  13209.             }
  13210.             else
  13211.             {
  13212.                 $output .= '(';
  13213.             }
  13214.         }
  13215.         $output .= substr($string$position);
  13216.  
  13217.         return $output;
  13218.     }
  13219.  
  13220.     /**
  13221.      * Parse RFC2822's date format
  13222.      *
  13223.      * @access protected
  13224.      * @return int Timestamp
  13225.      */
  13226.     function date_rfc2822($date)
  13227.     {
  13228.         static $pcre;
  13229.         if (!$pcre)
  13230.         {
  13231.             $wsp '[\x09\x20]';
  13232.             $fws '(?:' $wsp '+|' $wsp '*(?:\x0D\x0A' $wsp '+)+)';
  13233.             $optional_fws $fws '?';
  13234.             $day_name $this->day_pcre;
  13235.             $month $this->month_pcre;
  13236.             $day '([0-9]{1,2})';
  13237.             $hour $minute $second '([0-9]{2})';
  13238.             $year '([0-9]{2,4})';
  13239.             $num_zone '([+\-])([0-9]{2})([0-9]{2})';
  13240.             $character_zone '([A-Z]{1,5})';
  13241.             $zone '(?:' $num_zone '|' $character_zone ')';
  13242.             $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';
  13243.         }
  13244.         if (preg_match($pcre$this->remove_rfc2822_comments($date)$match))
  13245.         {
  13246.             /*
  13247.             Capturing subpatterns:
  13248.             1: Day name
  13249.             2: Day
  13250.             3: Month
  13251.             4: Year
  13252.             5: Hour
  13253.             6: Minute
  13254.             7: Second
  13255.             8: Timezone ±
  13256.             9: Timezone hours
  13257.             10: Timezone minutes
  13258.             11: Alphabetic timezone
  13259.             */
  13260.  
  13261.             // Find the month number
  13262.             $month $this->month[strtolower($match[3])];
  13263.  
  13264.             // Numeric timezone
  13265.             if ($match[8!== '')
  13266.             {
  13267.                 $timezone $match[93600;
  13268.                 $timezone += $match[1060;
  13269.                 if ($match[8=== '-')
  13270.                 {
  13271.                     $timezone $timezone;
  13272.                 }
  13273.             }
  13274.             // Character timezone
  13275.             elseif (isset($this->timezone[strtoupper($match[11])]))
  13276.             {
  13277.                 $timezone $this->timezone[strtoupper($match[11])];
  13278.             }
  13279.             // Assume everything else to be -0000
  13280.             else
  13281.             {
  13282.                 $timezone 0;
  13283.             }
  13284.  
  13285.             // Deal with 2/3 digit years
  13286.             if ($match[450)
  13287.             {
  13288.                 $match[4+= 2000;
  13289.             }
  13290.             elseif ($match[41000)
  13291.             {
  13292.                 $match[4+= 1900;
  13293.             }
  13294.  
  13295.             // Second is optional, if it is empty set it to zero
  13296.             if ($match[7!== '')
  13297.             {
  13298.                 $second $match[7];
  13299.             }
  13300.             else
  13301.             {
  13302.                 $second 0;
  13303.             }
  13304.  
  13305.             return gmmktime($match[5]$match[6]$second$month$match[2]$match[4]$timezone;
  13306.         }
  13307.         else
  13308.         {
  13309.             return false;
  13310.         }
  13311.     }
  13312.  
  13313.     /**
  13314.      * Parse RFC850's date format
  13315.      *
  13316.      * @access protected
  13317.      * @return int Timestamp
  13318.      */
  13319.     function date_rfc850($date)
  13320.     {
  13321.         static $pcre;
  13322.         if (!$pcre)
  13323.         {
  13324.             $space '[\x09\x20]+';
  13325.             $day_name $this->day_pcre;
  13326.             $month $this->month_pcre;
  13327.             $day '([0-9]{1,2})';
  13328.             $year $hour $minute $second '([0-9]{2})';
  13329.             $zone '([A-Z]{1,5})';
  13330.             $pcre '/^' $day_name ',' $space $day '-' $month '-' $year $space $hour ':' $minute ':' $second $space $zone '$/i';
  13331.         }
  13332.         if (preg_match($pcre$date$match))
  13333.         {
  13334.             /*
  13335.             Capturing subpatterns:
  13336.             1: Day name
  13337.             2: Day
  13338.             3: Month
  13339.             4: Year
  13340.             5: Hour
  13341.             6: Minute
  13342.             7: Second
  13343.             8: Timezone
  13344.             */
  13345.  
  13346.             // Month
  13347.             $month $this->month[strtolower($match[3])];
  13348.  
  13349.             // Character timezone
  13350.             if (isset($this->timezone[strtoupper($match[8])]))
  13351.             {
  13352.                 $timezone $this->timezone[strtoupper($match[8])];
  13353.             }
  13354.             // Assume everything else to be -0000
  13355.             else
  13356.             {
  13357.                 $timezone 0;
  13358.             }
  13359.  
  13360.             // Deal with 2 digit year
  13361.             if ($match[450)
  13362.             {
  13363.                 $match[4+= 2000;
  13364.             }
  13365.             else
  13366.             {
  13367.                 $match[4+= 1900;
  13368.             }
  13369.  
  13370.             return gmmktime($match[5]$match[6]$match[7]$month$match[2]$match[4]$timezone;
  13371.         }
  13372.         else
  13373.         {
  13374.             return false;
  13375.         }
  13376.     }
  13377.  
  13378.     /**
  13379.      * Parse C99's asctime()'s date format
  13380.      *
  13381.      * @access protected
  13382.      * @return int Timestamp
  13383.      */
  13384.     function date_asctime($date)
  13385.     {
  13386.         static $pcre;
  13387.         if (!$pcre)
  13388.         {
  13389.             $space '[\x09\x20]+';
  13390.             $wday_name $this->day_pcre;
  13391.             $mon_name $this->month_pcre;
  13392.             $day '([0-9]{1,2})';
  13393.             $hour $sec $min '([0-9]{2})';
  13394.             $year '([0-9]{4})';
  13395.             $terminator '\x0A?\x00?';
  13396.             $pcre '/^' $wday_name $space $mon_name $space $day $space $hour ':' $min ':' $sec $space $year $terminator '$/i';
  13397.         }
  13398.         if (preg_match($pcre$date$match))
  13399.         {
  13400.             /*
  13401.             Capturing subpatterns:
  13402.             1: Day name
  13403.             2: Month
  13404.             3: Day
  13405.             4: Hour
  13406.             5: Minute
  13407.             6: Second
  13408.             7: Year
  13409.             */
  13410.  
  13411.             $month $this->month[strtolower($match[2])];
  13412.             return gmmktime($match[4]$match[5]$match[6]$month$match[3]$match[7]);
  13413.         }
  13414.         else
  13415.         {
  13416.             return false;
  13417.         }
  13418.     }
  13419.  
  13420.     /**
  13421.      * Parse dates using strtotime()
  13422.      *
  13423.      * @access protected
  13424.      * @return int Timestamp
  13425.      */
  13426.     function date_strtotime($date)
  13427.     {
  13428.         $strtotime strtotime($date);
  13429.         if ($strtotime === -|| $strtotime === false)
  13430.         {
  13431.             return false;
  13432.         }
  13433.         else
  13434.         {
  13435.             return $strtotime;
  13436.         }
  13437.     }
  13438. }
  13439.  
  13440. /**
  13441.  * Content-type sniffing
  13442.  *
  13443.  * @package SimplePie
  13444.  */
  13445. {
  13446.     /**
  13447.      * File object
  13448.      *
  13449.      * @var SimplePie_File 
  13450.      * @access private
  13451.      */
  13452.     var $file;
  13453.  
  13454.     /**
  13455.      * Create an instance of the class with the input file
  13456.      *
  13457.      * @access public
  13458.      * @param SimplePie_Content_Type_Sniffer $file Input file
  13459.      */
  13460.     function SimplePie_Content_Type_Sniffer($file)
  13461.     {
  13462.         $this->file $file;
  13463.     }
  13464.  
  13465.     /**
  13466.      * Get the Content-Type of the specified file
  13467.      *
  13468.      * @access public
  13469.      * @return string Actual Content-Type
  13470.      */
  13471.     function get_type()
  13472.     {
  13473.         if (isset($this->file->headers['content-type']))
  13474.         {
  13475.             if (!isset($this->file->headers['content-encoding'])
  13476.                 && ($this->file->headers['content-type'=== 'text/plain'
  13477.                     || $this->file->headers['content-type'=== 'text/plain; charset=ISO-8859-1'
  13478.                     || $this->file->headers['content-type'=== 'text/plain; charset=iso-8859-1'))
  13479.             {
  13480.                 return $this->text_or_binary();
  13481.             }
  13482.  
  13483.             if (($pos strpos($this->file->headers['content-type']';')) !== false)
  13484.             {
  13485.                 $official substr($this->file->headers['content-type']0$pos);
  13486.             }
  13487.             else
  13488.             {
  13489.                 $official $this->file->headers['content-type'];
  13490.             }
  13491.             $official strtolower($official);
  13492.  
  13493.             if ($official === 'unknown/unknown'
  13494.                 || $official === 'application/unknown')
  13495.             {
  13496.                 return $this->unknown();
  13497.             }
  13498.             elseif (substr($official-4=== '+xml'
  13499.                 || $official === 'text/xml'
  13500.                 || $official === 'application/xml')
  13501.             {
  13502.                 return $official;
  13503.             }
  13504.             elseif (substr($official06=== 'image/')
  13505.             {
  13506.                 if ($return $this->image())
  13507.                 {
  13508.                     return $return;
  13509.                 }
  13510.                 else
  13511.                 {
  13512.                     return $official;
  13513.                 }
  13514.             }
  13515.             elseif ($official === 'text/html')
  13516.             {
  13517.                 return $this->feed_or_html();
  13518.             }
  13519.             else
  13520.             {
  13521.                 return $official;
  13522.             }
  13523.         }
  13524.         else
  13525.         {
  13526.             return $this->unknown();
  13527.         }
  13528.     }
  13529.  
  13530.     /**
  13531.      * Sniff text or binary
  13532.      *
  13533.      * @access private
  13534.      * @return string Actual Content-Type
  13535.      */
  13536.     function text_or_binary()
  13537.     {
  13538.         if (substr($this->file->body02=== "\xFE\xFF"
  13539.             || substr($this->file->body02=== "\xFF\xFE"
  13540.             || substr($this->file->body04=== "\x00\x00\xFE\xFF"
  13541.             || substr($this->file->body03=== "\xEF\xBB\xBF")
  13542.         {
  13543.             return 'text/plain';
  13544.         }
  13545.         elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/'$this->file->body))
  13546.         {
  13547.             return 'application/octect-stream';
  13548.         }
  13549.         else
  13550.         {
  13551.             return 'text/plain';
  13552.         }
  13553.     }
  13554.  
  13555.     /**
  13556.      * Sniff unknown
  13557.      *
  13558.      * @access private
  13559.      * @return string Actual Content-Type
  13560.      */
  13561.     function unknown()
  13562.     {
  13563.         $ws strspn($this->file->body"\x09\x0A\x0B\x0C\x0D\x20");
  13564.         if (strtolower(substr($this->file->body$ws14)) === '<!doctype html'
  13565.             || strtolower(substr($this->file->body$ws5)) === '<html'
  13566.             || strtolower(substr($this->file->body$ws7)) === '<script')
  13567.         {
  13568.             return 'text/html';
  13569.         }
  13570.         elseif (substr($this->file->body05=== '%PDF-')
  13571.         {
  13572.             return 'application/pdf';
  13573.         }
  13574.         elseif (substr($this->file->body011=== '%!PS-Adobe-')
  13575.         {
  13576.             return 'application/postscript';
  13577.         }
  13578.         elseif (substr($this->file->body06=== 'GIF87a'
  13579.             || substr($this->file->body06=== 'GIF89a')
  13580.         {
  13581.             return 'image/gif';
  13582.         }
  13583.         elseif (substr($this->file->body08=== "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")
  13584.         {
  13585.             return 'image/png';
  13586.         }
  13587.         elseif (substr($this->file->body03=== "\xFF\xD8\xFF")
  13588.         {
  13589.             return 'image/jpeg';
  13590.         }
  13591.         elseif (substr($this->file->body02=== "\x42\x4D")
  13592.         {
  13593.             return 'image/bmp';
  13594.         }
  13595.         else
  13596.         {
  13597.             return $this->text_or_binary();
  13598.         }
  13599.     }
  13600.  
  13601.     /**
  13602.      * Sniff images
  13603.      *
  13604.      * @access private
  13605.      * @return string Actual Content-Type
  13606.      */
  13607.     function image()
  13608.     {
  13609.         if (substr($this->file->body06=== 'GIF87a'
  13610.             || substr($this->file->body06=== 'GIF89a')
  13611.         {
  13612.             return 'image/gif';
  13613.         }
  13614.         elseif (substr($this->file->body08=== "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")
  13615.         {
  13616.             return 'image/png';
  13617.         }
  13618.         elseif (substr($this->file->body03=== "\xFF\xD8\xFF")
  13619.         {
  13620.             return 'image/jpeg';
  13621.         }
  13622.         elseif (substr($this->file->body02=== "\x42\x4D")
  13623.         {
  13624.             return 'image/bmp';
  13625.         }
  13626.         else
  13627.         {
  13628.             return false;
  13629.         }
  13630.     }
  13631.  
  13632.     /**
  13633.      * Sniff HTML
  13634.      *
  13635.      * @access private
  13636.      * @return string Actual Content-Type
  13637.      */
  13638.     function feed_or_html()
  13639.     {
  13640.         $len strlen($this->file->body);
  13641.         $pos strspn($this->file->body"\x09\x0A\x0D\x20");
  13642.  
  13643.         while ($pos $len)
  13644.         {
  13645.             switch ($this->file->body[$pos])
  13646.             {
  13647.                 case "\x09":
  13648.                 case "\x0A":
  13649.                 case "\x0D":
  13650.                 case "\x20":
  13651.                     $pos += strspn($this->file->body"\x09\x0A\x0D\x20"$pos);
  13652.                     continue 2;
  13653.  
  13654.                 case '<':
  13655.                     $pos++;
  13656.                     break;
  13657.  
  13658.                 default:
  13659.                     return 'text/html';
  13660.             }
  13661.  
  13662.             if (substr($this->file->body$pos3=== '!--')
  13663.             {
  13664.                 $pos += 3;
  13665.                 if ($pos $len && ($pos strpos($this->file->body'-->'$pos)) !== false)
  13666.                 {
  13667.                     $pos += 3;
  13668.                 }
  13669.                 else
  13670.                 {
  13671.                     return 'text/html';
  13672.                 }
  13673.             }
  13674.             elseif (substr($this->file->body$pos1=== '!')
  13675.             {
  13676.                 if ($pos $len && ($pos strpos($this->file->body'>'$pos)) !== false)
  13677.                 {
  13678.                     $pos++;
  13679.                 }
  13680.                 else
  13681.                 {
  13682.                     return 'text/html';
  13683.                 }
  13684.             }
  13685.             elseif (substr($this->file->body$pos1=== '?')
  13686.             {
  13687.                 if ($pos $len && ($pos strpos($this->file->body'?>'$pos)) !== false)
  13688.                 {
  13689.                     $pos += 2;
  13690.                 }
  13691.                 else
  13692.                 {
  13693.                     return 'text/html';
  13694.                 }
  13695.             }
  13696.             elseif (substr($this->file->body$pos3=== 'rss'
  13697.                 || substr($this->file->body$pos7=== 'rdf:RDF')
  13698.             {
  13699.                 return 'application/rss+xml';
  13700.             }
  13701.             elseif (substr($this->file->body$pos4=== 'feed')
  13702.             {
  13703.                 return 'application/atom+xml';
  13704.             }
  13705.             else
  13706.             {
  13707.                 return 'text/html';
  13708.             }
  13709.         }
  13710.  
  13711.         return 'text/html';
  13712.     }
  13713. }
  13714.  
  13715. /**
  13716.  * Parses the XML Declaration
  13717.  *
  13718.  * @package SimplePie
  13719.  */
  13720. {
  13721.     /**
  13722.      * XML Version
  13723.      *
  13724.      * @access public
  13725.      * @var string 
  13726.      */
  13727.     var $version = '1.0';
  13728.  
  13729.     /**
  13730.      * Encoding
  13731.      *
  13732.      * @access public
  13733.      * @var string 
  13734.      */
  13735.     var $encoding = 'UTF-8';
  13736.  
  13737.     /**
  13738.      * Standalone
  13739.      *
  13740.      * @access public
  13741.      * @var bool 
  13742.      */
  13743.     var $standalone = false;
  13744.  
  13745.     /**
  13746.      * Current state of the state machine
  13747.      *
  13748.      * @access private
  13749.      * @var string 
  13750.      */
  13751.     var $state 'before_version_name';
  13752.  
  13753.     /**
  13754.      * Input data
  13755.      *
  13756.      * @access private
  13757.      * @var string 
  13758.      */
  13759.     var $data '';
  13760.  
  13761.     /**
  13762.      * Input data length (to avoid calling strlen() everytime this is needed)
  13763.      *
  13764.      * @access private
  13765.      * @var int 
  13766.      */
  13767.     var $data_length 0;
  13768.  
  13769.     /**
  13770.      * Current position of the pointer
  13771.      *
  13772.      * @var int 
  13773.      * @access private
  13774.      */
  13775.     var $position 0;
  13776.  
  13777.     /**
  13778.      * Create an instance of the class with the input data
  13779.      *
  13780.      * @access public
  13781.      * @param string $data Input data
  13782.      */
  13783.     function SimplePie_XML_Declaration_Parser($data)
  13784.     {
  13785.         $this->data $data;
  13786.         $this->data_length strlen($this->data);
  13787.     }
  13788.  
  13789.     /**
  13790.      * Parse the input data
  13791.      *
  13792.      * @access public
  13793.      * @return bool true on success, false on failure
  13794.      */
  13795.     function parse()
  13796.     {
  13797.         while ($this->state && $this->state !== 'emit' && $this->has_data())
  13798.         {
  13799.             $state $this->state;
  13800.             $this->$state();
  13801.         }
  13802.         $this->data '';
  13803.         if ($this->state === 'emit')
  13804.         {
  13805.             return true;
  13806.         }
  13807.         else
  13808.         {
  13809.             $this->version = '';
  13810.             $this->encoding = '';
  13811.             $this->standalone = '';
  13812.             return false;
  13813.         }
  13814.     }
  13815.  
  13816.     /**
  13817.      * Check whether there is data beyond the pointer
  13818.      *
  13819.      * @access private
  13820.      * @return bool true if there is further data, false if not
  13821.      */
  13822.     function has_data()
  13823.     {
  13824.         return (bool) ($this->position $this->data_length);
  13825.     }
  13826.  
  13827.     /**
  13828.      * Advance past any whitespace
  13829.      *
  13830.      * @return int Number of whitespace characters passed
  13831.      */
  13832.     function skip_whitespace()
  13833.     {
  13834.         $whitespace strspn($this->data"\x09\x0A\x0D\x20"$this->position);
  13835.         $this->position += $whitespace;
  13836.         return $whitespace;
  13837.     }
  13838.  
  13839.     /**
  13840.      * Read value
  13841.      */
  13842.     function get_value()
  13843.     {
  13844.         $quote substr($this->data$this->position1);
  13845.         if ($quote === '"' || $quote === "'")
  13846.         {
  13847.             $this->position++;
  13848.             $len strcspn($this->data$quote$this->position);
  13849.             if ($this->has_data())
  13850.             {
  13851.                 $value substr($this->data$this->position$len);
  13852.                 $this->position += $len 1;
  13853.                 return $value;
  13854.             }
  13855.         }
  13856.         return false;
  13857.     }
  13858.  
  13859.     function before_version_name()
  13860.     {
  13861.         if ($this->skip_whitespace())
  13862.         {
  13863.             $this->state 'version_name';
  13864.         }
  13865.         else
  13866.         {
  13867.             $this->state false;
  13868.         }
  13869.     }
  13870.  
  13871.     function version_name()
  13872.     {
  13873.         if (substr($this->data$this->position7=== 'version')
  13874.         {
  13875.             $this->position += 7;
  13876.             $this->skip_whitespace();
  13877.             $this->state 'version_equals';
  13878.         }
  13879.         else
  13880.         {
  13881.             $this->state false;
  13882.         }
  13883.     }
  13884.  
  13885.     function version_equals()
  13886.     {
  13887.         if (substr($this->data$this->position1=== '=')
  13888.         {
  13889.             $this->position++;
  13890.             $this->skip_whitespace();
  13891.             $this->state 'version_value';
  13892.         }
  13893.         else
  13894.         {
  13895.             $this->state false;
  13896.         }
  13897.     }
  13898.  
  13899.     function version_value()
  13900.     {
  13901.         if ($this->version = $this->get_value())
  13902.         {
  13903.             $this->skip_whitespace();
  13904.             if ($this->has_data())
  13905.             {
  13906.                 $this->state 'encoding_name';
  13907.             }
  13908.             else
  13909.             {
  13910.                 $this->state 'emit';
  13911.             }
  13912.         }
  13913.         else
  13914.         {
  13915.             $this->state 'standalone_name';
  13916.         }
  13917.     }
  13918.  
  13919.     function encoding_name()
  13920.     {
  13921.         if (substr($this->data$this->position8=== 'encoding')
  13922.         {
  13923.             $this->position += 8;
  13924.             $this->skip_whitespace();
  13925.             $this->state 'encoding_equals';
  13926.         }
  13927.         else
  13928.         {
  13929.             $this->state false;
  13930.         }
  13931.     }
  13932.  
  13933.     function encoding_equals()
  13934.     {
  13935.         if (substr($this->data$this->position1=== '=')
  13936.         {
  13937.             $this->position++;
  13938.             $this->skip_whitespace();
  13939.             $this->state 'encoding_value';
  13940.         }
  13941.         else
  13942.         {
  13943.             $this->state false;
  13944.         }
  13945.     }
  13946.  
  13947.     function encoding_value()
  13948.     {
  13949.         if ($this->encoding = $this->get_value())
  13950.         {
  13951.             $this->skip_whitespace();
  13952.             if ($this->has_data())
  13953.             {
  13954.                 $this->state 'standalone_name';
  13955.             }
  13956.             else
  13957.             {
  13958.                 $this->state 'emit';
  13959.             }
  13960.         }
  13961.         else
  13962.         {
  13963.             $this->state false;
  13964.         }
  13965.     }
  13966.  
  13967.     function standalone_name()
  13968.     {
  13969.         if (substr($this->data$this->position10=== 'standalone')
  13970.         {
  13971.             $this->position += 10;
  13972.             $this->skip_whitespace();
  13973.             $this->state 'standalone_equals';
  13974.         }
  13975.         else
  13976.         {
  13977.             $this->state false;
  13978.         }
  13979.     }
  13980.  
  13981.     function standalone_equals()
  13982.     {
  13983.         if (substr($this->data$this->position1=== '=')
  13984.         {
  13985.             $this->position++;
  13986.             $this->skip_whitespace();
  13987.             $this->state 'standalone_value';
  13988.         }
  13989.         else
  13990.         {
  13991.             $this->state false;
  13992.         }
  13993.     }
  13994.  
  13995.     function standalone_value()
  13996.     {
  13997.         if ($standalone $this->get_value())
  13998.         {
  13999.             switch ($standalone)
  14000.             {
  14001.                 case 'yes':
  14002.                     $this->standalone = true;
  14003.                     break;
  14004.  
  14005.                 case 'no':
  14006.                     $this->standalone = false;
  14007.                     break;
  14008.  
  14009.                 default:
  14010.                     $this->state false;
  14011.                     return;
  14012.             }
  14013.  
  14014.             $this->skip_whitespace();
  14015.             if ($this->has_data())
  14016.             {
  14017.                 $this->state false;
  14018.             }
  14019.             else
  14020.             {
  14021.                 $this->state 'emit';
  14022.             }
  14023.         }
  14024.         else
  14025.         {
  14026.             $this->state false;
  14027.         }
  14028.     }
  14029. }
  14030.  
  14031. {
  14032.     var $useragent;
  14033.     var $timeout;
  14034.     var $file;
  14035.     var $local = array();
  14036.     var $elsewhere = array();
  14037.     var $file_class = 'SimplePie_File';
  14038.     var $cached_entities = array();
  14039.     var $http_base;
  14040.     var $base;
  14041.     var $base_location = 0;
  14042.     var $checked_feeds = 0;
  14043.     var $max_checked_feeds = 10;
  14044.     var $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer';
  14045.  
  14046.     function SimplePie_Locator(&$file$timeout 10$useragent null$file_class 'SimplePie_File'$max_checked_feeds 10$content_type_sniffer_class 'SimplePie_Content_Type_Sniffer')
  14047.     {
  14048.         $this->file =$file;
  14049.         $this->file_class = $file_class;
  14050.         $this->useragent = $useragent;
  14051.         $this->timeout = $timeout;
  14052.         $this->max_checked_feeds = $max_checked_feeds;
  14053.         $this->content_type_sniffer_class = $content_type_sniffer_class;
  14054.     }
  14055.  
  14056.     function find($type SIMPLEPIE_LOCATOR_ALL&$working)
  14057.     {
  14058.         if ($this->is_feed($this->file))
  14059.         {
  14060.             return $this->file;
  14061.         }
  14062.  
  14063.         if ($this->file->method SIMPLEPIE_FILE_SOURCE_REMOTE)
  14064.         {
  14065.             $sniffer new $this->content_type_sniffer_class($this->file);
  14066.             if ($sniffer->get_type(!== 'text/html')
  14067.             {
  14068.                 return null;
  14069.             }
  14070.         }
  14071.  
  14072.         if ($type ~SIMPLEPIE_LOCATOR_NONE)
  14073.         {
  14074.             $this->get_base();
  14075.         }
  14076.  
  14077.         if ($type SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working $this->autodiscovery())
  14078.         {
  14079.             return $working[0];
  14080.         }
  14081.  
  14082.         {
  14083.             if ($type SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working $this->extension($this->local))
  14084.             {
  14085.                 return $working;
  14086.             }
  14087.  
  14088.             if ($type SIMPLEPIE_LOCATOR_LOCAL_BODY && $working $this->body($this->local))
  14089.             {
  14090.                 return $working;
  14091.             }
  14092.  
  14093.             if ($type SIMPLEPIE_LOCATOR_REMOTE_EXTENSION && $working $this->extension($this->elsewhere))
  14094.             {
  14095.                 return $working;
  14096.             }
  14097.  
  14098.             if ($type SIMPLEPIE_LOCATOR_REMOTE_BODY && $working $this->body($this->elsewhere))
  14099.             {
  14100.                 return $working;
  14101.             }
  14102.         }
  14103.         return null;
  14104.     }
  14105.  
  14106.     function is_feed(&$file)
  14107.     {
  14108.         if ($file->method SIMPLEPIE_FILE_SOURCE_REMOTE)
  14109.         {
  14110.             $sniffer new $this->content_type_sniffer_class($file);
  14111.             $sniffed $sniffer->get_type();
  14112.             if (in_array($sniffedarray('application/rss+xml''application/rdf+xml''text/rdf''application/atom+xml''text/xml''application/xml')))
  14113.             {
  14114.                 return true;
  14115.             }
  14116.             else
  14117.             {
  14118.                 return false;
  14119.             }
  14120.         }
  14121.         elseif ($file->method SIMPLEPIE_FILE_SOURCE_LOCAL)
  14122.         {
  14123.             return true;
  14124.         }
  14125.         else
  14126.         {
  14127.             return false;
  14128.         }
  14129.     }
  14130.  
  14131.     function get_base()
  14132.     {
  14133.         $this->http_base = $this->file->url;
  14134.         $this->base = $this->http_base;
  14135.         $elements SimplePie_Misc::get_element('base'$this->file->body);
  14136.         foreach ($elements as $element)
  14137.         {
  14138.             if ($element['attribs']['href']['data'!== '')
  14139.             {
  14140.                 $this->base = SimplePie_Misc::absolutize_url(trim($element['attribs']['href']['data'])$this->http_base);
  14141.                 $this->base_location = $element['offset'];
  14142.                 break;
  14143.             }
  14144.         }
  14145.     }
  14146.  
  14147.     function autodiscovery()
  14148.     {
  14149.         $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));
  14150.         $done array();
  14151.         $feeds array();
  14152.         foreach ($links as $link)
  14153.         {
  14154.             if ($this->checked_feeds === $this->max_checked_feeds)
  14155.             {
  14156.                 break;
  14157.             }
  14158.             if (isset($link['attribs']['href']['data']&& isset($link['attribs']['rel']['data']))
  14159.             {
  14160.                 $rel array_unique(SimplePie_Misc::space_seperated_tokens(strtolower($link['attribs']['rel']['data'])));
  14161.  
  14162.                 if ($this->base_location < $link['offset'])
  14163.                 {
  14164.                     $href SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data'])$this->base);
  14165.                 }
  14166.                 else
  14167.                 {
  14168.                     $href SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data'])$this->http_base);
  14169.                 }
  14170.  
  14171.                 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'))) && !isset($feeds[$href]))
  14172.                 {
  14173.                     $this->checked_feeds++;
  14174.                     $feed new $this->file_class($href$this->timeout5null$this->useragent);
  14175.                     if ($feed->success && ($feed->method SIMPLEPIE_FILE_SOURCE_REMOTE === || ($feed->status_code === 200 || $feed->status_code 206 && $feed->status_code 300)) && $this->is_feed($feed))
  14176.                     {
  14177.                         $feeds[$href$feed;
  14178.                     }
  14179.                 }
  14180.                 $done[$href;
  14181.             }
  14182.         }
  14183.  
  14184.         if (!empty($feeds))
  14185.         {
  14186.             return array_values($feeds);
  14187.         }
  14188.         else
  14189.         {
  14190.             return null;
  14191.         }
  14192.     }
  14193.  
  14194.     function get_links()
  14195.     {
  14196.         $links SimplePie_Misc::get_element('a'$this->file->body);
  14197.         foreach ($links as $link)
  14198.         {
  14199.             if (isset($link['attribs']['href']['data']))
  14200.             {
  14201.                 $href trim($link['attribs']['href']['data']);
  14202.                 $parsed SimplePie_Misc::parse_url($href);
  14203.                 if ($parsed['scheme'=== '' || preg_match('/^(http(s)|feed)?$/i'$parsed['scheme']))
  14204.                 {
  14205.                     if ($this->base_location < $link['offset'])
  14206.                     {
  14207.                         $href SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data'])$this->base);
  14208.                     }
  14209.                     else
  14210.                     {
  14211.                         $href SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data'])$this->http_base);
  14212.                     }
  14213.  
  14214.                     $current SimplePie_Misc::parse_url($this->file->url);
  14215.  
  14216.                     if ($parsed['authority'=== '' || $parsed['authority'=== $current['authority'])
  14217.                     {
  14218.                         $this->local[$href;
  14219.                     }
  14220.                     else
  14221.                     {
  14222.                         $this->elsewhere[$href;
  14223.                     }
  14224.                 }
  14225.             }
  14226.         }
  14227.         $this->local = array_unique($this->local);
  14228.         $this->elsewhere = array_unique($this->elsewhere);
  14229.         if (!empty($this->local|| !empty($this->elsewhere))
  14230.         {
  14231.             return true;
  14232.         }
  14233.         return null;
  14234.     }
  14235.  
  14236.     function extension(&$array)
  14237.     {
  14238.         foreach ($array as $key => $value)
  14239.         {
  14240.             if ($this->checked_feeds === $this->max_checked_feeds)
  14241.             {
  14242.                 break;
  14243.             }
  14244.             if (in_array(strtolower(strrchr($value'.'))array('.rss''.rdf''.atom''.xml')))
  14245.             {
  14246.                 $this->checked_feeds++;
  14247.                 $feed new $this->file_class($value$this->timeout5null$this->useragent);
  14248.                 if ($feed->success && ($feed->method SIMPLEPIE_FILE_SOURCE_REMOTE === || ($feed->status_code === 200 || $feed->status_code 206 && $feed->status_code 300)) && $this->is_feed($feed))
  14249.                 {
  14250.                     return $feed;
  14251.                 }
  14252.                 else
  14253.                 {
  14254.                     unset($array[$key]);
  14255.                 }
  14256.             }
  14257.         }
  14258.         return null;
  14259.     }
  14260.  
  14261.     function body(&$array)
  14262.     {
  14263.         foreach ($array as $key => $value)
  14264.         {
  14265.             if ($this->checked_feeds === $this->max_checked_feeds)
  14266.             {
  14267.                 break;
  14268.             }
  14269.             if (preg_match('/(rss|rdf|atom|xml)/i'$value))
  14270.             {
  14271.                 $this->checked_feeds++;
  14272.                 $feed new $this->file_class($value$this->timeout5null$this->useragent);
  14273.                 if ($feed->success && ($feed->method SIMPLEPIE_FILE_SOURCE_REMOTE === || ($feed->status_code === 200 || $feed->status_code 206 && $feed->status_code 300)) && $this->is_feed($feed))
  14274.                 {
  14275.                     return $feed;
  14276.                 }
  14277.                 else
  14278.                 {
  14279.                     unset($array[$key]);
  14280.                 }
  14281.             }
  14282.         }
  14283.         return null;
  14284.     }
  14285. }
  14286.  
  14287. {
  14288.     var $error_code;
  14289.     var $error_string;
  14290.     var $current_line;
  14291.     var $current_column;
  14292.     var $current_byte;
  14293.     var $separator = ' ';
  14294.     var $namespace = array('');
  14295.     var $element = array('');
  14296.     var $xml_base = array('');
  14297.     var $xml_base_explicit = array(false);
  14298.     var $xml_lang = array('');
  14299.     var $data = array();
  14300.     var $datas = array(array());
  14301.     var $current_xhtml_construct = -1;
  14302.     var $encoding;
  14303.  
  14304.     function parse(&$data$encoding)
  14305.     {
  14306.         // Use UTF-8 if we get passed US-ASCII, as every US-ASCII character is a UTF-8 character
  14307.         if (strtoupper($encoding=== 'US-ASCII')
  14308.         {
  14309.             $this->encoding = 'UTF-8';
  14310.         }
  14311.         else
  14312.         {
  14313.             $this->encoding = $encoding;
  14314.         }
  14315.  
  14316.         // Strip BOM:
  14317.         // UTF-32 Big Endian BOM
  14318.         if (substr($data04=== "\x00\x00\xFE\xFF")
  14319.         {
  14320.             $data substr($data4);
  14321.         }
  14322.         // UTF-32 Little Endian BOM
  14323.         elseif (substr($data04=== "\xFF\xFE\x00\x00")
  14324.         {
  14325.             $data substr($data4);
  14326.         }
  14327.         // UTF-16 Big Endian BOM
  14328.         elseif (substr($data02=== "\xFE\xFF")
  14329.         {
  14330.             $data substr($data2);
  14331.         }
  14332.         // UTF-16 Little Endian BOM
  14333.         elseif (substr($data02=== "\xFF\xFE")
  14334.         {
  14335.             $data substr($data2);
  14336.         }
  14337.         // UTF-8 BOM
  14338.         elseif (substr($data03=== "\xEF\xBB\xBF")
  14339.         {
  14340.             $data substr($data3);
  14341.         }
  14342.  
  14343.         if (substr($data05=== '<?xml' && strspn(substr($data51)"\x09\x0A\x0D\x20"&& ($pos strpos($data'?>')) !== false)
  14344.         {
  14345.             $declaration new SimplePie_XML_Declaration_Parser(substr($data5$pos 5));
  14346.             if ($declaration->parse())
  14347.             {
  14348.                 $data substr($data$pos 2);
  14349.                 $data '<?xml version="' $declaration->version '" encoding="' $encoding '" standalone="' (($declaration->standalone'yes' 'no''"?>' $data;
  14350.             }
  14351.             else
  14352.             {
  14353.                 $this->error_string = 'SimplePie bug! Please report this!';
  14354.                 return false;
  14355.             }
  14356.         }
  14357.  
  14358.         $return true;
  14359.  
  14360.         static $xml_is_sane null;
  14361.         if ($xml_is_sane === null)
  14362.         {
  14363.             $parser_check xml_parser_create();
  14364.             xml_parse_into_struct($parser_check'<foo>&amp;</foo>'$values);
  14365.             xml_parser_free($parser_check);
  14366.             $xml_is_sane = isset($values[0]['value']);
  14367.         }
  14368.  
  14369.         // Create the parser
  14370.         if ($xml_is_sane)
  14371.         {
  14372.             $xml xml_parser_create_ns($this->encoding$this->separator);
  14373.             xml_parser_set_option($xmlXML_OPTION_SKIP_WHITE1);
  14374.             xml_parser_set_option($xmlXML_OPTION_CASE_FOLDING0);
  14375.             xml_set_object($xml$this);
  14376.             xml_set_character_data_handler($xml'cdata');
  14377.             xml_set_element_handler($xml'tag_open''tag_close');
  14378.  
  14379.             // Parse!
  14380.             if (!xml_parse($xml$datatrue))
  14381.             {
  14382.                 $this->error_code xml_get_error_code($xml);
  14383.                 $this->error_string xml_error_string($this->error_code);
  14384.                 $return false;
  14385.             }
  14386.             $this->current_line xml_get_current_line_number($xml);
  14387.             $this->current_column xml_get_current_column_number($xml);
  14388.             $this->current_byte xml_get_current_byte_index($xml);
  14389.             xml_parser_free($xml);
  14390.             return $return;
  14391.         }
  14392.         else
  14393.         {
  14394.             libxml_clear_errors();
  14395.             $xml new XMLReader();
  14396.             $xml->xml($data);
  14397.             while (@$xml->read())
  14398.             {
  14399.                 switch ($xml->nodeType)
  14400.                 {
  14401.  
  14402.                     case constant('XMLReader::END_ELEMENT'):
  14403.                         if ($xml->namespaceURI !== '')
  14404.                         {
  14405.                             $tagName "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
  14406.                         }
  14407.                         else
  14408.                         {
  14409.                             $tagName $xml->localName;
  14410.                         }
  14411.                         $this->tag_close(null$tagName);
  14412.                         break;
  14413.                     case constant('XMLReader::ELEMENT'):
  14414.                         $empty $xml->isEmptyElement;
  14415.                         if ($xml->namespaceURI !== '')
  14416.                         {
  14417.                             $tagName "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
  14418.                         }
  14419.                         else
  14420.                         {
  14421.                             $tagName $xml->localName;
  14422.                         }
  14423.                         $attributes array();
  14424.                         while ($xml->moveToNextAttribute())
  14425.                         {
  14426.                             if ($xml->namespaceURI !== '')
  14427.                             {
  14428.                                 $attrName "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
  14429.                             }
  14430.                             else
  14431.                             {
  14432.                                 $attrName $xml->localName;
  14433.                             }
  14434.                             $attributes[$attrName$xml->value;
  14435.                         }
  14436.                         $this->tag_open(null$tagName$attributes);
  14437.                         if ($empty)
  14438.                         {
  14439.                             $this->tag_close(null$tagName);
  14440.                         }
  14441.                         break;
  14442.                     case constant('XMLReader::TEXT'):
  14443.  
  14444.                     case constant('XMLReader::CDATA'):
  14445.                         $this->cdata(null$xml->value);
  14446.                         break;
  14447.                 }
  14448.             }
  14449.             if ($error libxml_get_last_error())
  14450.             {
  14451.                 $this->error_code $error->code;
  14452.                 $this->error_string $error->message;
  14453.                 $this->current_line $error->line;
  14454.                 $this->current_column $error->column;
  14455.                 return false;
  14456.             }
  14457.             else
  14458.             {
  14459.                 return true;
  14460.             }
  14461.         }
  14462.     }
  14463.  
  14464.     function get_error_code()
  14465.     {
  14466.         return $this->error_code;
  14467.     }
  14468.  
  14469.     function get_error_string()
  14470.     {
  14471.         return $this->error_string;
  14472.     }
  14473.  
  14474.     function get_current_line()
  14475.     {
  14476.         return $this->current_line;
  14477.     }
  14478.  
  14479.     function get_current_column()
  14480.     {
  14481.         return $this->current_column;
  14482.     }
  14483.  
  14484.     function get_current_byte()
  14485.     {
  14486.         return $this->current_byte;
  14487.     }
  14488.  
  14489.     function get_data()
  14490.     {
  14491.         return $this->data;
  14492.     }
  14493.  
  14494.     function tag_open($parser$tag$attributes)
  14495.     {
  14496.         list($this->namespace[]$this->element[]$this->split_ns($tag);
  14497.  
  14498.         $attribs array();
  14499.         foreach ($attributes as $name => $value)
  14500.         {
  14501.             list($attrib_namespace$attribute$this->split_ns($name);
  14502.             $attribs[$attrib_namespace][$attribute$value;
  14503.         }
  14504.  
  14505.         if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['base']))
  14506.         {
  14507.             $this->xml_base[SimplePie_Misc::absolutize_url($attribs[SIMPLEPIE_NAMESPACE_XML]['base']end($this->xml_base));
  14508.             $this->xml_base_explicit[true;
  14509.         }
  14510.         else
  14511.         {
  14512.             $this->xml_base[end($this->xml_base);
  14513.             $this->xml_base_explicit[end($this->xml_base_explicit);
  14514.         }
  14515.  
  14516.         if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['lang']))
  14517.         {
  14518.             $this->xml_lang[$attribs[SIMPLEPIE_NAMESPACE_XML]['lang'];
  14519.         }
  14520.         else
  14521.         {
  14522.             $this->xml_lang[end($this->xml_lang);
  14523.         }
  14524.  
  14525.         if ($this->current_xhtml_construct >= 0)
  14526.         {
  14527.             $this->current_xhtml_construct++;
  14528.             if (end($this->namespace=== SIMPLEPIE_NAMESPACE_XHTML)
  14529.             {
  14530.                 $this->data['data'.= '<' end($this->element);
  14531.                 if (isset($attribs['']))
  14532.                 {
  14533.                     foreach ($attribs[''as $name => $value)
  14534.                     {
  14535.                         $this->data['data'.= ' ' $name '="' htmlspecialchars($valueENT_COMPAT$this->encoding'"';
  14536.                     }
  14537.                 }
  14538.                 $this->data['data'.= '>';
  14539.             }
  14540.         }
  14541.         else
  14542.         {
  14543.             $this->datas[=$this->data;
  14544.             $this->data =$this->data['child'][end($this->namespace)][end($this->element)][];
  14545.             $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));
  14546.             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')
  14547.             || (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'))
  14548.             {
  14549.                 $this->current_xhtml_construct 0;
  14550.             }
  14551.         }
  14552.     }
  14553.  
  14554.     function cdata($parser$cdata)
  14555.     {
  14556.         if ($this->current_xhtml_construct >= 0)
  14557.         {
  14558.             $this->data['data'.= htmlspecialchars($cdataENT_QUOTES$this->encoding);
  14559.         }
  14560.         else
  14561.         {
  14562.             $this->data['data'.= $cdata;
  14563.         }
  14564.     }
  14565.  
  14566.     function tag_close($parser$tag)
  14567.     {
  14568.         if ($this->current_xhtml_construct >= 0)
  14569.         {
  14570.             $this->current_xhtml_construct--;
  14571.             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')))
  14572.             {
  14573.                 $this->data['data'.= '</' end($this->element'>';
  14574.             }
  14575.         }
  14576.         if ($this->current_xhtml_construct === -1)
  14577.         {
  14578.             $this->data =$this->datas[count($this->datas1];
  14579.             array_pop($this->datas);
  14580.         }
  14581.  
  14582.         array_pop($this->element);
  14583.         array_pop($this->namespace);
  14584.         array_pop($this->xml_base);
  14585.         array_pop($this->xml_base_explicit);
  14586.         array_pop($this->xml_lang);
  14587.     }
  14588.  
  14589.     function split_ns($string)
  14590.     {
  14591.         static $cache array();
  14592.         if (!isset($cache[$string]))
  14593.         {
  14594.             if ($pos strpos($string$this->separator))
  14595.             {
  14596.                 static $separator_length;
  14597.                 if (!$separator_length)
  14598.                 {
  14599.                     $separator_length strlen($this->separator);
  14600.                 }
  14601.                 $namespace substr($string0$pos);
  14602.                 $local_name substr($string$pos $separator_length);
  14603.                 if (strtolower($namespace=== SIMPLEPIE_NAMESPACE_ITUNES)
  14604.                 {
  14605.                     $namespace SIMPLEPIE_NAMESPACE_ITUNES;
  14606.                 }
  14607.  
  14608.                 // Normalize the Media RSS namespaces
  14609.                 if ($namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG)
  14610.                 {
  14611.                     $namespace SIMPLEPIE_NAMESPACE_MEDIARSS;
  14612.                 }
  14613.                 $cache[$stringarray($namespace$local_name);
  14614.             }
  14615.             else
  14616.             {
  14617.                 $cache[$stringarray(''$string);
  14618.             }
  14619.         }
  14620.         return $cache[$string];
  14621.     }
  14622. }
  14623.  
  14624. /**
  14625.  * @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
  14626.  */
  14627. {
  14628.     // Private vars
  14629.     var $base;
  14630.  
  14631.     // Options
  14632.     var $remove_div = true;
  14633.     var $image_handler = '';
  14634.     var $strip_htmltags = array('base''blink''body''doctype''embed''font''form''frame''frameset''html''iframe''input''marquee''meta''noscript''object''param''script''style');
  14635.     var $encode_instead_of_strip = false;
  14636.     var $strip_attributes = array('bgsound''class''expr''id''style''onclick''onerror''onfinish''onmouseover''onmouseout''onfocus''onblur''lowsrc''dynsrc');
  14637.     var $strip_comments = false;
  14638.     var $output_encoding = 'UTF-8';
  14639.     var $enable_cache = true;
  14640.     var $cache_location = './cache';
  14641.     var $cache_name_function = 'md5';
  14642.     var $cache_class = 'SimplePie_Cache';
  14643.     var $file_class = 'SimplePie_File';
  14644.     var $timeout = 10;
  14645.     var $useragent = '';
  14646.     var $force_fsockopen = false;
  14647.  
  14648.     var $replace_url_attributes = array(
  14649.         'a' => 'href',
  14650.         'area' => 'href',
  14651.         'blockquote' => 'cite',
  14652.         'del' => 'cite',
  14653.         'form' => 'action',
  14654.         'img' => array('longdesc''src'),
  14655.         'input' => 'src',
  14656.         'ins' => 'cite',
  14657.         'q' => 'cite'
  14658.     );
  14659.  
  14660.     function remove_div($enable true)
  14661.     {
  14662.         $this->remove_div = (bool) $enable;
  14663.     }
  14664.  
  14665.     function set_image_handler($page false)
  14666.     {
  14667.         if ($page)
  14668.         {
  14669.             $this->image_handler = (string) $page;
  14670.         }
  14671.         else
  14672.         {
  14673.             $this->image_handler = false;
  14674.         }
  14675.     }
  14676.  
  14677.     function pass_cache_data($enable_cache true$cache_location './cache'$cache_name_function 'md5'$cache_class 'SimplePie_Cache')
  14678.     {
  14679.         if (isset($enable_cache))
  14680.         {
  14681.             $this->enable_cache = (bool) $enable_cache;
  14682.         }
  14683.  
  14684.         if ($cache_location)
  14685.         {
  14686.             $this->cache_location = (string) $cache_location;
  14687.         }
  14688.  
  14689.         if ($cache_name_function)
  14690.         {
  14691.             $this->cache_name_function = (string) $cache_name_function;
  14692.         }
  14693.  
  14694.         if ($cache_class)
  14695.         {
  14696.             $this->cache_class = (string) $cache_class;
  14697.         }
  14698.     }
  14699.  
  14700.     function pass_file_data($file_class 'SimplePie_File'$timeout 10$useragent ''$force_fsockopen false)
  14701.     {
  14702.         if ($file_class)
  14703.         {
  14704.             $this->file_class = (string) $file_class;
  14705.         }
  14706.  
  14707.         if ($timeout)
  14708.         {
  14709.             $this->timeout = (string) $timeout;
  14710.         }
  14711.  
  14712.         if ($useragent)
  14713.         {
  14714.             $this->useragent = (string) $useragent;
  14715.         }
  14716.  
  14717.         if ($force_fsockopen)
  14718.         {
  14719.             $this->force_fsockopen = (string) $force_fsockopen;
  14720.         }
  14721.     }
  14722.  
  14723.     function strip_htmltags($tags array('base''blink''body''doctype''embed''font''form''frame''frameset''html''iframe''input''marquee''meta''noscript''object''param''script''style'))
  14724.     {
  14725.         if ($tags)
  14726.         {
  14727.             if (is_array($tags))
  14728.             {
  14729.                 $this->strip_htmltags = $tags;
  14730.             }
  14731.             else
  14732.             {
  14733.                 $this->strip_htmltags = explode(','$tags);
  14734.             }
  14735.         }
  14736.         else
  14737.         {
  14738.             $this->strip_htmltags = false;
  14739.         }
  14740.     }
  14741.  
  14742.     function encode_instead_of_strip($encode false)
  14743.     {
  14744.         $this->encode_instead_of_strip = (bool) $encode;
  14745.     }
  14746.  
  14747.     function strip_attributes($attribs array('bgsound''class''expr''id''style''onclick''onerror''onfinish''onmouseover''onmouseout''onfocus''onblur''lowsrc''dynsrc'))
  14748.     {
  14749.         if ($attribs)
  14750.         {
  14751.             if (is_array($attribs))
  14752.             {
  14753.                 $this->strip_attributes = $attribs;
  14754.             }
  14755.             else
  14756.             {
  14757.                 $this->strip_attributes = explode(','$attribs);
  14758.             }
  14759.         }
  14760.         else
  14761.         {
  14762.             $this->strip_attributes = false;
  14763.         }
  14764.     }
  14765.  
  14766.     function strip_comments($strip false)
  14767.     {
  14768.         $this->strip_comments = (bool) $strip;
  14769.     }
  14770.  
  14771.     function set_output_encoding($encoding 'UTF-8')
  14772.     {
  14773.         $this->output_encoding = (string) $encoding;
  14774.     }
  14775.  
  14776.     /**
  14777.      * Set element/attribute key/value pairs of HTML attributes
  14778.      * containing URLs that need to be resolved relative to the feed
  14779.      *
  14780.      * @access public
  14781.      * @since 1.0
  14782.      * @param array $element_attribute Element/attribute key/value pairs
  14783.      */
  14784.     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'))
  14785.     {
  14786.         $this->replace_url_attributes = (array) $element_attribute;
  14787.     }
  14788.  
  14789.     function sanitize($data$type$base '')
  14790.     {
  14791.         $data trim($data);
  14792.         if ($data !== '' || $type SIMPLEPIE_CONSTRUCT_IRI)
  14793.         {
  14794.             if ($type SIMPLEPIE_CONSTRUCT_MAYBE_HTML)
  14795.             {
  14796.                 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))
  14797.                 {
  14798.                     $type |= SIMPLEPIE_CONSTRUCT_HTML;
  14799.                 }
  14800.                 else
  14801.                 {
  14802.                     $type |= SIMPLEPIE_CONSTRUCT_TEXT;
  14803.                 }
  14804.             }
  14805.  
  14806.             if ($type SIMPLEPIE_CONSTRUCT_BASE64)
  14807.             {
  14808.                 $data base64_decode($data);
  14809.             }
  14810.  
  14811.             if ($type SIMPLEPIE_CONSTRUCT_XHTML)
  14812.             {
  14813.                 if ($this->remove_div)
  14814.                 {
  14815.                     $data preg_replace('/^<div' SIMPLEPIE_PCRE_XML_ATTRIBUTE '>/'''$data);
  14816.                     $data preg_replace('/<\/div>$/'''$data);
  14817.                 }
  14818.                 else
  14819.                 {
  14820.                     $data preg_replace('/^<div' SIMPLEPIE_PCRE_XML_ATTRIBUTE '>/''<div>'$data);
  14821.                 }
  14822.             }
  14823.  
  14824.             if ($type (SIMPLEPIE_CONSTRUCT_HTML SIMPLEPIE_CONSTRUCT_XHTML))
  14825.             {
  14826.                 // Strip comments
  14827.                 if ($this->strip_comments)
  14828.                 {
  14829.                     $data SimplePie_Misc::strip_comments($data);
  14830.                 }
  14831.  
  14832.                 // Strip out HTML tags and attributes that might cause various security problems.
  14833.                 // Based on recommendations by Mark Pilgrim at:
  14834.                 // http://diveintomark.org/archives/2003/06/12/how_to_consume_rss_safely
  14835.                 if ($this->strip_htmltags)
  14836.                 {
  14837.                     foreach ($this->strip_htmltags as $tag)
  14838.                     {
  14839.                         $pcre "/<($tag)SIMPLEPIE_PCRE_HTML_ATTRIBUTE "(>(.*)<\/$tagSIMPLEPIE_PCRE_HTML_ATTRIBUTE '>|(\/)?>)/siU';
  14840.                         while (preg_match($pcre$data))
  14841.                         {
  14842.                             $data preg_replace_callback($pcrearray(&$this'do_strip_htmltags')$data);
  14843.                         }
  14844.                     }
  14845.                 }
  14846.  
  14847.                 if ($this->strip_attributes)
  14848.                 {
  14849.                     foreach ($this->strip_attributes as $attrib)
  14850.                     {
  14851.                         $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);
  14852.                     }
  14853.                 }
  14854.  
  14855.                 // Replace relative URLs
  14856.                 $this->base = $base;
  14857.                 foreach ($this->replace_url_attributes as $element => $attributes)
  14858.                 {
  14859.                     $data $this->replace_urls($data$element$attributes);
  14860.                 }
  14861.  
  14862.                 // If image handling (caching, etc.) is enabled, cache and rewrite all the image tags.
  14863.                 if (isset($this->image_handler&& ((string) $this->image_handler!== '' && $this->enable_cache)
  14864.                 {
  14865.                     $images SimplePie_Misc::get_element('img'$data);
  14866.                     foreach ($images as $img)
  14867.                     {
  14868.                         if (isset($img['attribs']['src']['data']))
  14869.                         {
  14870.                             $image_url call_user_func($this->cache_name_function$img['attribs']['src']['data']);
  14871.                             $cache call_user_func(array($this->cache_class'create')$this->cache_location$image_url'spi');
  14872.  
  14873.                             if ($cache->load())
  14874.                             {
  14875.                                 $img['attribs']['src']['data'$this->image_handler . $image_url;
  14876.                                 $data str_replace($img['full']SimplePie_Misc::element_implode($img)$data);
  14877.                             }
  14878.                             else
  14879.                             {
  14880.                                 $file new $this->file_class($img['attribs']['src']['data']$this->timeout5array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR'])$this->useragent$this->force_fsockopen);
  14881.                                 $headers $file->headers;
  14882.  
  14883.                                 if ($file->success && ($file->method SIMPLEPIE_FILE_SOURCE_REMOTE === || ($file->status_code === 200 || $file->status_code 206 && $file->status_code 300)))
  14884.                                 {
  14885.                                     if ($cache->save(array('headers' => $file->headers'body' => $file->body)))
  14886.                                     {
  14887.                                         $img['attribs']['src']['data'$this->image_handler . $image_url;
  14888.                                         $data str_replace($img['full']SimplePie_Misc::element_implode($img)$data);
  14889.                                     }
  14890.                                     else
  14891.                                     {
  14892.                                         trigger_error("$this->cache_location is not writeable"E_USER_WARNING);
  14893.                                     }
  14894.                                 }
  14895.                             }
  14896.                         }
  14897.                     }
  14898.                 }
  14899.  
  14900.                 // Having (possibly) taken stuff out, there may now be whitespace at the beginning/end of the data
  14901.                 $data trim($data);
  14902.             }
  14903.  
  14904.             if ($type SIMPLEPIE_CONSTRUCT_IRI)
  14905.             {
  14906.                 $data SimplePie_Misc::absolutize_url($data$base);
  14907.             }
  14908.  
  14909.             if ($type (SIMPLEPIE_CONSTRUCT_TEXT SIMPLEPIE_CONSTRUCT_IRI))
  14910.             {
  14911.                 $data htmlspecialchars($dataENT_COMPAT'UTF-8');
  14912.             }
  14913.  
  14914.             if ($this->output_encoding !== 'UTF-8')
  14915.             {
  14916.                 $data SimplePie_Misc::change_encoding($data'UTF-8'$this->output_encoding);
  14917.             }
  14918.         }
  14919.         return $data;
  14920.     }
  14921.  
  14922.     function replace_urls($data$tag$attributes)
  14923.     {
  14924.         if (!is_array($this->strip_htmltags|| !in_array($tag$this->strip_htmltags))
  14925.         {
  14926.             $elements SimplePie_Misc::get_element($tag$data);
  14927.             foreach ($elements as $element)
  14928.             {
  14929.                 if (is_array($attributes))
  14930.                 {
  14931.                     foreach ($attributes as $attribute)
  14932.                     {
  14933.                         if (isset($element['attribs'][$attribute]['data']))
  14934.                         {
  14935.                             $element['attribs'][$attribute]['data'SimplePie_Misc::absolutize_url($element['attribs'][$attribute]['data']$this->base);
  14936.                             $new_element SimplePie_Misc::element_implode($element);
  14937.                             $data str_replace($element['full']$new_element$data);
  14938.                             $element['full'$new_element;
  14939.                         }
  14940.                     }
  14941.                 }
  14942.                 elseif (isset($element['attribs'][$attributes]['data']))
  14943.                 {
  14944.                     $element['attribs'][$attributes]['data'SimplePie_Misc::absolutize_url($element['attribs'][$attributes]['data']$this->base);
  14945.                     $data str_replace($element['full']SimplePie_Misc::element_implode($element)$data);
  14946.                 }
  14947.             }
  14948.         }
  14949.         return $data;
  14950.     }
  14951.  
  14952.     function do_strip_htmltags($match)
  14953.     {
  14954.         if ($this->encode_instead_of_strip)
  14955.         {
  14956.             if (isset($match[4]&& !in_array(strtolower($match[1])array('script''style')))
  14957.             {
  14958.                 $match[1htmlspecialchars($match[1]ENT_COMPAT'UTF-8');
  14959.                 $match[2htmlspecialchars($match[2]ENT_COMPAT'UTF-8');
  14960.                 return "&lt;$match[1]$match[2]&gt;$match[3]&lt;/$match[1]&gt;";
  14961.             }
  14962.             else
  14963.             {
  14964.                 return htmlspecialchars($match[0]ENT_COMPAT'UTF-8');
  14965.             }
  14966.         }
  14967.         elseif (isset($match[4]&& !in_array(strtolower($match[1])array('script''style')))
  14968.         {
  14969.             return $match[4];
  14970.         }
  14971.         else
  14972.         {
  14973.             return '';
  14974.         }
  14975.     }
  14976. }
  14977.  
  14978. ?>

Documentation generated on Tue, 19 Nov 2013 15:13:48 +0100 by phpDocumentor 1.4.3