SimplePie
[ class tree: SimplePie ] [ index: SimplePie ] [ all elements ]

Source for file simplepie.inc

Documentation is available at simplepie.inc

  1. <?php
  2. /**
  3.  * SimplePie
  4.  *
  5.  * A PHP-Based RSS and Atom Feed Framework.
  6.  * Takes the hard work out of managing a complete RSS/Atom solution.
  7.  *
  8.  * Copyright (c) 2004-2007, Ryan Parman and Geoffrey Sneddon
  9.  * All rights reserved.
  10.  *
  11.  * Redistribution and use in source and binary forms, with or without modification, are
  12.  * permitted provided that the following conditions are met:
  13.  *
  14.  *     * Redistributions of source code must retain the above copyright notice, this list of
  15.  *       conditions and the following disclaimer.
  16.  *
  17.  *     * Redistributions in binary form must reproduce the above copyright notice, this list
  18.  *       of conditions and the following disclaimer in the documentation and/or other materials
  19.  *       provided with the distribution.
  20.  *
  21.  *     * Neither the name of the SimplePie Team nor the names of its contributors may be used
  22.  *       to endorse or promote products derived from this software without specific prior
  23.  *       written permission.
  24.  *
  25.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  26.  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  27.  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
  28.  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  29.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30.  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  31.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  32.  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33.  * POSSIBILITY OF SUCH DAMAGE.
  34.  *
  35.  * @package SimplePie
  36.  * @version 1.1
  37.  * @copyright 2004-2007 Ryan Parman, Geoffrey Sneddon
  38.  * @author Ryan Parman
  39.  * @author Geoffrey Sneddon
  40.  * @link http://simplepie.org/ SimplePie
  41.  * @link http://simplepie.org/support/ Please submit all bug reports and feature requests to the SimplePie forums
  42.  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  43.  * @todo phpDoc comments
  44.  */
  45.  
  46. /**
  47.  * SimplePie Name
  48.  */
  49. define('SIMPLEPIE_NAME''SimplePie');
  50.  
  51. /**
  52.  * SimplePie Version
  53.  */
  54. define('SIMPLEPIE_VERSION''1.1');
  55.  
  56. /**
  57.  * SimplePie Build
  58.  */
  59. define('SIMPLEPIE_BUILD'20080102221556);
  60.  
  61. /**
  62.  * SimplePie Website URL
  63.  */
  64. define('SIMPLEPIE_URL''http://simplepie.org');
  65.  
  66. /**
  67.  * SimplePie Useragent
  68.  * @see SimplePie::set_useragent()
  69.  */
  70. define('SIMPLEPIE_USERAGENT'SIMPLEPIE_NAME '/' SIMPLEPIE_VERSION ' (Feed Parser; ' SIMPLEPIE_URL '; Allow like Gecko) Build/' SIMPLEPIE_BUILD);
  71.  
  72. /**
  73.  * SimplePie Linkback
  74.  */
  75. define('SIMPLEPIE_LINKBACK''<a href="' SIMPLEPIE_URL '" title="' SIMPLEPIE_NAME ' ' SIMPLEPIE_VERSION '">' SIMPLEPIE_NAME '</a>');
  76.  
  77. /**
  78.  * No Autodiscovery
  79.  * @see SimplePie::set_autodiscovery_level()
  80.  */
  81. define('SIMPLEPIE_LOCATOR_NONE'0);
  82.  
  83. /**
  84.  * Feed Link Element Autodiscovery
  85.  * @see SimplePie::set_autodiscovery_level()
  86.  */
  87. define('SIMPLEPIE_LOCATOR_AUTODISCOVERY'1);
  88.  
  89. /**
  90.  * Local Feed Extension Autodiscovery
  91.  * @see SimplePie::set_autodiscovery_level()
  92.  */
  93. define('SIMPLEPIE_LOCATOR_LOCAL_EXTENSION'2);
  94.  
  95. /**
  96.  * Local Feed Body Autodiscovery
  97.  * @see SimplePie::set_autodiscovery_level()
  98.  */
  99. define('SIMPLEPIE_LOCATOR_LOCAL_BODY'4);
  100.  
  101. /**
  102.  * Remote Feed Extension Autodiscovery
  103.  * @see SimplePie::set_autodiscovery_level()
  104.  */
  105. define('SIMPLEPIE_LOCATOR_REMOTE_EXTENSION'8);
  106.  
  107. /**
  108.  * Remote Feed Body Autodiscovery
  109.  * @see SimplePie::set_autodiscovery_level()
  110.  */
  111. define('SIMPLEPIE_LOCATOR_REMOTE_BODY'16);
  112.  
  113. /**
  114.  * All Feed Autodiscovery
  115.  * @see SimplePie::set_autodiscovery_level()
  116.  */
  117. define('SIMPLEPIE_LOCATOR_ALL'31);
  118.  
  119. /**
  120.  * No known feed type
  121.  */
  122. define('SIMPLEPIE_TYPE_NONE'0);
  123.  
  124. /**
  125.  * RSS 0.90
  126.  */
  127. define('SIMPLEPIE_TYPE_RSS_090'1);
  128.  
  129. /**
  130.  * RSS 0.91 (Netscape)
  131.  */
  132. define('SIMPLEPIE_TYPE_RSS_091_NETSCAPE'2);
  133.  
  134. /**
  135.  * RSS 0.91 (Userland)
  136.  */
  137. define('SIMPLEPIE_TYPE_RSS_091_USERLAND'4);
  138.  
  139. /**
  140.  * RSS 0.91 (both Netscape and Userland)
  141.  */
  142. define('SIMPLEPIE_TYPE_RSS_091'6);
  143.  
  144. /**
  145.  * RSS 0.92
  146.  */
  147. define('SIMPLEPIE_TYPE_RSS_092'8);
  148.  
  149. /**
  150.  * RSS 0.93
  151.  */
  152. define('SIMPLEPIE_TYPE_RSS_093'16);
  153.  
  154. /**
  155.  * RSS 0.94
  156.  */
  157. define('SIMPLEPIE_TYPE_RSS_094'32);
  158.  
  159. /**
  160.  * RSS 1.0
  161.  */
  162. define('SIMPLEPIE_TYPE_RSS_10'64);
  163.  
  164. /**
  165.  * RSS 2.0
  166.  */
  167. define('SIMPLEPIE_TYPE_RSS_20'128);
  168.  
  169. /**
  170.  * RDF-based RSS
  171.  */
  172. define('SIMPLEPIE_TYPE_RSS_RDF'65);
  173.  
  174. /**
  175.  * Non-RDF-based RSS (truly intended as syndication format)
  176.  */
  177. define('SIMPLEPIE_TYPE_RSS_SYNDICATION'190);
  178.  
  179. /**
  180.  * All RSS
  181.  */
  182. define('SIMPLEPIE_TYPE_RSS_ALL'255);
  183.  
  184. /**
  185.  * Atom 0.3
  186.  */
  187. define('SIMPLEPIE_TYPE_ATOM_03'256);
  188.  
  189. /**
  190.  * Atom 1.0
  191.  */
  192. define('SIMPLEPIE_TYPE_ATOM_10'512);
  193.  
  194. /**
  195.  * All Atom
  196.  */
  197. define('SIMPLEPIE_TYPE_ATOM_ALL'768);
  198.  
  199. /**
  200.  * All feed types
  201.  */
  202. define('SIMPLEPIE_TYPE_ALL'1023);
  203.  
  204. /**
  205.  * No construct
  206.  */
  207. define('SIMPLEPIE_CONSTRUCT_NONE'0);
  208.  
  209. /**
  210.  * Text construct
  211.  */
  212. define('SIMPLEPIE_CONSTRUCT_TEXT'1);
  213.  
  214. /**
  215.  * HTML construct
  216.  */
  217. define('SIMPLEPIE_CONSTRUCT_HTML'2);
  218.  
  219. /**
  220.  * XHTML construct
  221.  */
  222. define('SIMPLEPIE_CONSTRUCT_XHTML'4);
  223.  
  224. /**
  225.  * base64-encoded construct
  226.  */
  227. define('SIMPLEPIE_CONSTRUCT_BASE64'8);
  228.  
  229. /**
  230.  * IRI construct
  231.  */
  232. define('SIMPLEPIE_CONSTRUCT_IRI'16);
  233.  
  234. /**
  235.  * A construct that might be HTML
  236.  */
  237. define('SIMPLEPIE_CONSTRUCT_MAYBE_HTML'32);
  238.  
  239. /**
  240.  * All constructs
  241.  */
  242. define('SIMPLEPIE_CONSTRUCT_ALL'63);
  243.  
  244. /**
  245.  * PCRE for HTML attributes
  246.  */
  247. 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]*');
  248.  
  249. /**
  250.  * PCRE for XML attributes
  251.  */
  252. define('SIMPLEPIE_PCRE_XML_ATTRIBUTE''((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'))*)\s*');
  253.  
  254. /**
  255.  * XML Namespace
  256.  */
  257. define('SIMPLEPIE_NAMESPACE_XML''http://www.w3.org/XML/1998/namespace');
  258.  
  259. /**
  260.  * Atom 1.0 Namespace
  261.  */
  262. define('SIMPLEPIE_NAMESPACE_ATOM_10''http://www.w3.org/2005/Atom');
  263.  
  264. /**
  265.  * Atom 0.3 Namespace
  266.  */
  267. define('SIMPLEPIE_NAMESPACE_ATOM_03''http://purl.org/atom/ns#');
  268.  
  269. /**
  270.  * RDF Namespace
  271.  */
  272. define('SIMPLEPIE_NAMESPACE_RDF''http://www.w3.org/1999/02/22-rdf-syntax-ns#');
  273.  
  274. /**
  275.  * RSS 0.90 Namespace
  276.  */
  277. define('SIMPLEPIE_NAMESPACE_RSS_090''http://my.netscape.com/rdf/simple/0.9/');
  278.  
  279. /**
  280.  * RSS 1.0 Namespace
  281.  */
  282. define('SIMPLEPIE_NAMESPACE_RSS_10''http://purl.org/rss/1.0/');
  283.  
  284. /**
  285.  * RSS 1.0 Content Module Namespace
  286.  */
  287. define('SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT''http://purl.org/rss/1.0/modules/content/');
  288.  
  289. /**
  290.  * DC 1.0 Namespace
  291.  */
  292. define('SIMPLEPIE_NAMESPACE_DC_10''http://purl.org/dc/elements/1.0/');
  293.  
  294. /**
  295.  * DC 1.1 Namespace
  296.  */
  297. define('SIMPLEPIE_NAMESPACE_DC_11''http://purl.org/dc/elements/1.1/');
  298.  
  299. /**
  300.  * W3C Basic Geo (WGS84 lat/long) Vocabulary Namespace
  301.  */
  302. define('SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO''http://www.w3.org/2003/01/geo/wgs84_pos#');
  303.  
  304. /**
  305.  * GeoRSS Namespace
  306.  */
  307. define('SIMPLEPIE_NAMESPACE_GEORSS''http://www.georss.org/georss');
  308.  
  309. /**
  310.  * Media RSS Namespace
  311.  */
  312. define('SIMPLEPIE_NAMESPACE_MEDIARSS''http://search.yahoo.com/mrss/');
  313.  
  314. /**
  315.  * iTunes RSS Namespace
  316.  */
  317. define('SIMPLEPIE_NAMESPACE_ITUNES''http://www.itunes.com/dtds/podcast-1.0.dtd');
  318.  
  319. /**
  320.  * XHTML Namespace
  321.  */
  322. define('SIMPLEPIE_NAMESPACE_XHTML''http://www.w3.org/1999/xhtml');
  323.  
  324. /**
  325.  * IANA Link Relations Registry
  326.  */
  327. define('SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY''http://www.iana.org/assignments/relation/');
  328.  
  329. /**
  330.  * Whether we're running on PHP5
  331.  */
  332. define('SIMPLEPIE_PHP5'version_compare(PHP_VERSION'5.0.0''>='));
  333.  
  334. /**
  335.  * No file source
  336.  */
  337. define('SIMPLEPIE_FILE_SOURCE_NONE'0);
  338.  
  339. /**
  340.  * Remote file source
  341.  */
  342. define('SIMPLEPIE_FILE_SOURCE_REMOTE'1);
  343.  
  344. /**
  345.  * Local file source
  346.  */
  347. define('SIMPLEPIE_FILE_SOURCE_LOCAL'2);
  348.  
  349. /**
  350.  * fsockopen() file source
  351.  */
  352. define('SIMPLEPIE_FILE_SOURCE_FSOCKOPEN'4);
  353.  
  354. /**
  355.  * cURL file source
  356.  */
  357. define('SIMPLEPIE_FILE_SOURCE_CURL'8);
  358.  
  359. /**
  360.  * file_get_contents() file source
  361.  */
  362. define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS'16);
  363.  
  364. /**
  365.  * SimplePie
  366.  *
  367.  * @package SimplePie
  368.  * @version "Razzleberry"
  369.  * @copyright 2004-2007 Ryan Parman, Geoffrey Sneddon
  370.  * @author Ryan Parman
  371.  * @author Geoffrey Sneddon
  372.  * @todo Option for type of fetching (cache, not modified header, fetch, etc.)
  373.  */
  374. class SimplePie
  375. {
  376.     /**
  377.      * @var array Raw data
  378.      * @access private
  379.      */
  380.     var $data array();
  381.  
  382.     /**
  383.      * @var mixed Error string
  384.      * @access private
  385.      */
  386.     var $error;
  387.  
  388.     /**
  389.      * @var object Instance of SimplePie_Sanitize (or other class)
  390.      * @see SimplePie::set_sanitize_class()
  391.      * @access private
  392.      */
  393.     var $sanitize;
  394.  
  395.     /**
  396.      * @var string SimplePie Useragent
  397.      * @see SimplePie::set_useragent()
  398.      * @access private
  399.      */
  400.     var $useragent SIMPLEPIE_USERAGENT;
  401.  
  402.     /**
  403.      * @var string Feed URL
  404.      * @see SimplePie::set_feed_url()
  405.      * @access private
  406.      */
  407.     var $feed_url;
  408.  
  409.     /**
  410.      * @var object Instance of SimplePie_File to use as a feed
  411.      * @see SimplePie::set_file()
  412.      * @access private
  413.      */
  414.     var $file;
  415.  
  416.     /**
  417.      * @var string Raw feed data
  418.      * @see SimplePie::set_raw_data()
  419.      * @access private
  420.      */
  421.     var $raw_data;
  422.  
  423.     /**
  424.      * @var int Timeout for fetching remote files
  425.      * @see SimplePie::set_timeout()
  426.      * @access private
  427.      */
  428.     var $timeout 10;
  429.  
  430.     /**
  431.      * @var bool Forces fsockopen() to be used for remote files instead
  432.      *  of cURL, even if a new enough version is installed
  433.      * @see SimplePie::force_fsockopen()
  434.      * @access private
  435.      */
  436.     var $force_fsockopen false;
  437.  
  438.     /**
  439.      * @var bool Force the given data/URL to be treated as a feed no matter what
  440.      *  it appears like
  441.      * @see SimplePie::force_feed()
  442.      * @access private
  443.      */
  444.     var $force_feed false;
  445.  
  446.     /**
  447.      * @var bool Enable/Disable XML dump
  448.      * @see SimplePie::enable_xml_dump()
  449.      * @access private
  450.      */
  451.     var $xml_dump false;
  452.  
  453.     /**
  454.      * @var bool Enable/Disable Caching
  455.      * @see SimplePie::enable_cache()
  456.      * @access private
  457.      */
  458.     var $cache true;
  459.  
  460.     /**
  461.      * @var int Cache duration (in seconds)
  462.      * @see SimplePie::set_cache_duration()
  463.      * @access private
  464.      */
  465.     var $cache_duration 3600;
  466.  
  467.     /**
  468.      * @var int Auto-discovery cache duration (in seconds)
  469.      * @see SimplePie::set_autodiscovery_cache_duration()
  470.      * @access private
  471.      */
  472.     var $autodiscovery_cache_duration 604800// 7 Days.
  473.  
  474.     /**
  475.      * @var string Cache location (relative to executing script)
  476.      * @see SimplePie::set_cache_location()
  477.      * @access private
  478.      */
  479.     var $cache_location './cache';
  480.  
  481.     /**
  482.      * @var string Function that creates the cache filename
  483.      * @see SimplePie::set_cache_name_function()
  484.      * @access private
  485.      */
  486.     var $cache_name_function 'md5';
  487.  
  488.     /**
  489.      * @var bool Reorder feed by date descending
  490.      * @see SimplePie::enable_order_by_date()
  491.      * @access private
  492.      */
  493.     var $order_by_date true;
  494.  
  495.     /**
  496.      * @var mixed Force input encoding to be set to the follow value
  497.      *  (false, or anything type-cast to false, disables this feature)
  498.      * @see SimplePie::set_input_encoding()
  499.      * @access private
  500.      */
  501.     var $input_encoding false;
  502.  
  503.     /**
  504.      * @var int Feed Autodiscovery Level
  505.      * @see SimplePie::set_autodiscovery_level()
  506.      * @access private
  507.      */
  508.     var $autodiscovery SIMPLEPIE_LOCATOR_ALL;
  509.  
  510.     /**
  511.      * @var string Class used for caching feeds
  512.      * @see SimplePie::set_cache_class()
  513.      * @access private
  514.      */
  515.     var $cache_class 'SimplePie_Cache';
  516.  
  517.     /**
  518.      * @var string Class used for locating feeds
  519.      * @see SimplePie::set_locator_class()
  520.      * @access private
  521.      */
  522.     var $locator_class 'SimplePie_Locator';
  523.  
  524.     /**
  525.      * @var string Class used for parsing feeds
  526.      * @see SimplePie::set_parser_class()
  527.      * @access private
  528.      */
  529.     var $parser_class 'SimplePie_Parser';
  530.  
  531.     /**
  532.      * @var string Class used for fetching feeds
  533.      * @see SimplePie::set_file_class()
  534.      * @access private
  535.      */
  536.     var $file_class 'SimplePie_File';
  537.  
  538.     /**
  539.      * @var string Class used for items
  540.      * @see SimplePie::set_item_class()
  541.      * @access private
  542.      */
  543.     var $item_class 'SimplePie_Item';
  544.  
  545.     /**
  546.      * @var string Class used for authors
  547.      * @see SimplePie::set_author_class()
  548.      * @access private
  549.      */
  550.     var $author_class 'SimplePie_Author';
  551.  
  552.     /**
  553.      * @var string Class used for categories
  554.      * @see SimplePie::set_category_class()
  555.      * @access private
  556.      */
  557.     var $category_class 'SimplePie_Category';
  558.  
  559.     /**
  560.      * @var string Class used for enclosures
  561.      * @see SimplePie::set_enclosures_class()
  562.      * @access private
  563.      */
  564.     var $enclosure_class 'SimplePie_Enclosure';
  565.  
  566.     /**
  567.      * @var string Class used for Media RSS <media:text> captions
  568.      * @see SimplePie::set_caption_class()
  569.      * @access private
  570.      */
  571.     var $caption_class 'SimplePie_Caption';
  572.  
  573.     /**
  574.      * @var string Class used for Media RSS <media:copyright>
  575.      * @see SimplePie::set_copyright_class()
  576.      * @access private
  577.      */
  578.     var $copyright_class 'SimplePie_Copyright';
  579.  
  580.     /**
  581.      * @var string Class used for Media RSS <media:credit>
  582.      * @see SimplePie::set_credit_class()
  583.      * @access private
  584.      */
  585.     var $credit_class 'SimplePie_Credit';
  586.  
  587.     /**
  588.      * @var string Class used for Media RSS <media:rating>
  589.      * @see SimplePie::set_rating_class()
  590.      * @access private
  591.      */
  592.     var $rating_class 'SimplePie_Rating';
  593.  
  594.     /**
  595.      * @var string Class used for Media RSS <media:restriction>
  596.      * @see SimplePie::set_restriction_class()
  597.      * @access private
  598.      */
  599.     var $restriction_class 'SimplePie_Restriction';
  600.  
  601.     /**
  602.      * @var string Class used for content-type sniffing
  603.      * @see SimplePie::set_content_type_sniffer_class()
  604.      * @access private
  605.      */
  606.     var $content_type_sniffer_class 'SimplePie_Content_Type_Sniffer';
  607.  
  608.     /**
  609.      * @var string Class used for item sources.
  610.      * @see SimplePie::set_source_class()
  611.      * @access private
  612.      */
  613.     var $source_class 'SimplePie_Source';
  614.  
  615.     /**
  616.      * @var mixed Set javascript query string parameter (false, or
  617.      *  anything type-cast to false, disables this feature)
  618.      * @see SimplePie::set_javascript()
  619.      * @access private
  620.      */
  621.     var $javascript 'js';
  622.  
  623.     /**
  624.      * @var int Maximum number of feeds to check with autodiscovery
  625.      * @see SimplePie::set_max_checked_feeds()
  626.      * @access private
  627.      */
  628.     var $max_checked_feeds 10;
  629.  
  630.     /**
  631.      * @var string Web-accessible path to the handler_favicon.php file.
  632.      * @see SimplePie::set_favicon_handler()
  633.      * @access private
  634.      */
  635.     var $favicon_handler '';
  636.  
  637.     /**
  638.      * @var string Web-accessible path to the handler_image.php file.
  639.      * @see SimplePie::set_image_handler()
  640.      * @access private
  641.      */
  642.     var $image_handler '';
  643.  
  644.     /**
  645.      * @var array Stores the URLs when multiple feeds are being initialized.
  646.      * @see SimplePie::set_feed_url()
  647.      * @access private
  648.      */
  649.     var $multifeed_url array();
  650.  
  651.     /**
  652.      * @var array Stores SimplePie objects when multiple feeds initialized.
  653.      * @access private
  654.      */
  655.     var $multifeed_objects array();
  656.  
  657.     /**
  658.      * @var array Stores the get_object_vars() array for use with multifeeds.
  659.      * @see SimplePie::set_feed_url()
  660.      * @access private
  661.      */
  662.     var $config_settings null;
  663.  
  664.     /**
  665.      * @var integer Stores the number of items to return per-feed with multifeeds.
  666.      * @see SimplePie::set_item_limit()
  667.      * @access private
  668.      */
  669.     var $item_limit 0;
  670.  
  671.     /**
  672.      * @var array Stores the default attributes to be stripped by strip_attributes().
  673.      * @see SimplePie::strip_attributes()
  674.      * @access private
  675.      */
  676.     var $strip_attributes array('bgsound''class''expr''id''style''onclick''onerror''onfinish''onmouseover''onmouseout''onfocus''onblur''lowsrc''dynsrc');
  677.  
  678.     /**
  679.      * @var array Stores the default tags to be stripped by strip_htmltags().
  680.      * @see SimplePie::strip_htmltags()
  681.      * @access private
  682.      */
  683.     var $strip_htmltags array('base''blink''body''doctype''embed''font''form''frame''frameset''html''iframe''input''marquee''meta''noscript''object''param''script''style');
  684.  
  685.     /**
  686.      * The SimplePie class contains feed level data and options
  687.      *
  688.      * There are two ways that you can create a new SimplePie object. The first
  689.      * is by passing a feed URL as a parameter to the SimplePie constructor
  690.      * (as well as optionally setting the cache location and cache expiry). This
  691.      * will initialise the whole feed with all of the default settings, and you
  692.      * can begin accessing methods and properties immediately.
  693.      *
  694.      * The second way is to create the SimplePie object with no parameters
  695.      * at all. This will enable you to set configuration options. After setting
  696.      * them, you must initialise the feed using $feed->init(). At that point the
  697.      * object's methods and properties will be available to you. This format is
  698.      * what is used throughout this documentation.
  699.      *
  700.      * @access public
  701.      * @since 1.0 Preview Release
  702.      * @param string $feed_url This is the URL you want to parse.
  703.      * @param string $cache_location This is where you want the cache to be stored.
  704.      * @param int $cache_duration This is the number of seconds that you want to store the cache file for.
  705.      */
  706.     function SimplePie($feed_url null$cache_location null$cache_duration null)
  707.     {
  708.         // Other objects, instances created here so we can set options on them
  709.         $this->sanitize =new SimplePie_Sanitize;
  710.  
  711.         // Set options if they're passed to the constructor
  712.         if ($cache_location !== null)
  713.         {
  714.             $this->set_cache_location($cache_location);
  715.         }
  716.  
  717.         if ($cache_duration !== null)
  718.         {
  719.             $this->set_cache_duration($cache_duration);
  720.         }
  721.  
  722.         // Only init the script if we're passed a feed URL
  723.         if ($feed_url !== null)
  724.         {
  725.             $this->set_feed_url($feed_url);
  726.             $this->init();
  727.         }
  728.     }
  729.  
  730.     /**
  731.      * Used for converting object to a string
  732.      */
  733.     function __toString()
  734.     {
  735.         return md5(serialize($this->data));
  736.     }
  737.     
  738.     /**
  739.      * Remove items that link back to this before destroying this object
  740.      */
  741.     function __destruct()
  742.     {
  743.         if (!empty($this->data['items']))
  744.         {
  745.             foreach ($this->data['items'as $item)
  746.             {
  747.                 $item->__destruct();
  748.             }
  749.             unset($this->data['items']);
  750.         }
  751.         if (!empty($this->data['ordered_items']))
  752.         {
  753.             foreach ($this->data['ordered_items'as $item)
  754.             {
  755.                 $item->__destruct();
  756.             }
  757.             unset($this->data['ordered_items']);
  758.         }
  759.     }
  760.     
  761.     /**
  762.      * Force the given data/URL to be treated as a feed no matter what it
  763.      * appears like
  764.      *
  765.      * @access public
  766.      * @since 1.1
  767.      * @param bool $enable Force the given data/URL to be treated as a feed
  768.      */
  769.     function force_feed($enable false)
  770.     {
  771.         $this->force_feed = (bool) $enable;
  772.     }
  773.  
  774.     /**
  775.      * This is the URL of the feed you want to parse.
  776.      *
  777.      * This allows you to enter the URL of the feed you want to parse, or the
  778.      * website you want to try to use auto-discovery on. This takes priority
  779.      * over any set raw data.
  780.      *
  781.      * You can set multiple feeds to mash together by passing an array instead
  782.      * of a string for the $url. Remember that with each additional feed comes
  783.      * additional processing and resources.
  784.      *
  785.      * @access public
  786.      * @since 1.0 Preview Release
  787.      * @param mixed $url This is the URL (or array of URLs) that you want to parse.
  788.      * @see SimplePie::set_raw_data()
  789.      */
  790.     function set_feed_url($url)
  791.     {
  792.         if (is_array($url))
  793.         {
  794.             $this->multifeed_url array();
  795.             foreach ($url as $value)
  796.             {
  797.                 $this->multifeed_url[SimplePie_Misc::fix_protocol($value1);
  798.             }
  799.         }
  800.         else
  801.         {
  802.             $this->feed_url SimplePie_Misc::fix_protocol($url1);
  803.         }
  804.     }
  805.  
  806.     /**
  807.      * Provides an instance of SimplePie_File to use as a feed
  808.      *
  809.      * @access public
  810.      * @param object &$file Instance of SimplePie_File (or subclass)
  811.      * @return bool True on success, false on failure
  812.      */
  813.     function set_file(&$file)
  814.     {
  815.         if (is_a($file'SimplePie_File'))
  816.         {
  817.             $this->feed_url $file->url;
  818.             $this->file =$file;
  819.             return true;
  820.         }
  821.         return false;
  822.     }
  823.  
  824.     /**
  825.      * Allows you to use a string of RSS/Atom data instead of a remote feed.
  826.      *
  827.      * If you have a feed available as a string in PHP, you can tell SimplePie
  828.      * to parse that data string instead of a remote feed. Any set feed URL
  829.      * takes precedence.
  830.      *
  831.      * @access public
  832.      * @since 1.0 Beta 3
  833.      * @param string $data RSS or Atom data as a string.
  834.      * @see SimplePie::set_feed_url()
  835.      */
  836.     function set_raw_data($data)
  837.     {
  838.         $this->raw_data trim($data);
  839.     }
  840.  
  841.     /**
  842.      * Allows you to override the default timeout for fetching remote feeds.
  843.      *
  844.      * This allows you to change the maximum time the feed's server to respond
  845.      * and send the feed back.
  846.      *
  847.      * @access public
  848.      * @since 1.0 Beta 3
  849.      * @param int $timeout The maximum number of seconds to spend waiting to retrieve a feed.
  850.      */
  851.     function set_timeout($timeout 10)
  852.     {
  853.         $this->timeout = (int) $timeout;
  854.     }
  855.  
  856.     /**
  857.      * Forces SimplePie to use fsockopen() instead of the preferred cURL
  858.      * functions.
  859.      *
  860.      * @access public
  861.      * @since 1.0 Beta 3
  862.      * @param bool $enable Force fsockopen() to be used
  863.      */
  864.     function force_fsockopen($enable false)
  865.     {
  866.         $this->force_fsockopen = (bool) $enable;
  867.     }
  868.  
  869.     /**
  870.      * Outputs the raw XML content of the feed, after it has gone through
  871.      * SimplePie's filters.
  872.      *
  873.      * Used only for debugging, this function will output the XML content as
  874.      * text/xml. When SimplePie reads in a feed, it does a bit of cleaning up
  875.      * before trying to parse it. Many parts of the feed are re-written in
  876.      * memory, and in the end, you have a parsable feed. XML dump shows you the
  877.      * actual XML that SimplePie tries to parse, which may or may not be very
  878.      * different from the original feed.
  879.      *
  880.      * @access public
  881.      * @since 1.0 Preview Release
  882.      * @param bool $enable Enable XML dump
  883.      */
  884.     function enable_xml_dump($enable false)
  885.     {
  886.         $this->xml_dump = (bool) $enable;
  887.     }
  888.  
  889.     /**
  890.      * Enables/disables caching in SimplePie.
  891.      *
  892.      * This option allows you to disable caching all-together in SimplePie.
  893.      * However, disabling the cache can lead to longer load times.
  894.      *
  895.      * @access public
  896.      * @since 1.0 Preview Release
  897.      * @param bool $enable Enable caching
  898.      */
  899.     function enable_cache($enable true)
  900.     {
  901.         $this->cache = (bool) $enable;
  902.     }
  903.  
  904.     /**
  905.      * Set the length of time (in seconds) that the contents of a feed
  906.      * will be cached.
  907.      *
  908.      * @access public
  909.      * @param int $seconds The feed content cache duration.
  910.      */
  911.     function set_cache_duration($seconds 3600)
  912.     {
  913.         $this->cache_duration = (int) $seconds;
  914.     }
  915.  
  916.     /**
  917.      * Set the length of time (in seconds) that the autodiscovered feed
  918.      * URL will be cached.
  919.      *
  920.      * @access public
  921.      * @param int $seconds The autodiscovered feed URL cache duration.
  922.      */
  923.     function set_autodiscovery_cache_duration($seconds 604800)
  924.     {
  925.         $this->autodiscovery_cache_duration = (int) $seconds;
  926.     }
  927.  
  928.     /**
  929.      * Set the file system location where the cached files should be stored.
  930.      *
  931.      * @access public
  932.      * @param string $location The file system location.
  933.      */
  934.     function set_cache_location($location './cache')
  935.     {
  936.         $this->cache_location = (string) $location;
  937.     }
  938.  
  939.     /**
  940.      * Determines whether feed items should be sorted into reverse chronological order.
  941.      *
  942.      * @access public
  943.      * @param bool $enable Sort as reverse chronological order.
  944.      */
  945.     function enable_order_by_date($enable true)
  946.     {
  947.         $this->order_by_date = (bool) $enable;
  948.     }
  949.  
  950.     /**
  951.      * Allows you to override the character encoding reported by the feed.
  952.      *
  953.      * @access public
  954.      * @param string $encoding Character encoding.
  955.      */
  956.     function set_input_encoding($encoding false)
  957.     {
  958.         if ($encoding)
  959.         {
  960.             $this->input_encoding = (string) $encoding;
  961.         }
  962.         else
  963.         {
  964.             $this->input_encoding false;
  965.         }
  966.     }
  967.  
  968.     /**
  969.      * Set how much feed autodiscovery to do
  970.      *
  971.      * @access public
  972.      * @see SIMPLEPIE_LOCATOR_NONE
  973.      * @see SIMPLEPIE_LOCATOR_AUTODISCOVERY
  974.      * @see SIMPLEPIE_LOCATOR_LOCAL_EXTENSION
  975.      * @see SIMPLEPIE_LOCATOR_LOCAL_BODY
  976.      * @see SIMPLEPIE_LOCATOR_REMOTE_EXTENSION
  977.      * @see SIMPLEPIE_LOCATOR_REMOTE_BODY
  978.      * @see SIMPLEPIE_LOCATOR_ALL
  979.      * @param int $level Feed Autodiscovery Level (level can be a
  980.      *  combination of the above constants, see bitwise OR operator)
  981.      */
  982.     function set_autodiscovery_level($level SIMPLEPIE_LOCATOR_ALL)
  983.     {
  984.         $this->autodiscovery = (int) $level;
  985.     }
  986.  
  987.     /**
  988.      * Allows you to change which class SimplePie uses for caching.
  989.      * Useful when you are overloading or extending SimplePie's default classes.
  990.      *
  991.      * @access public
  992.      * @param string $class Name of custom class.
  993.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  994.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  995.      */
  996.     function set_cache_class($class 'SimplePie_Cache')
  997.     {
  998.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Cache'))
  999.         {
  1000.             $this->cache_class $class;
  1001.             return true;
  1002.         }
  1003.         return false;
  1004.     }
  1005.  
  1006.     /**
  1007.      * Allows you to change which class SimplePie uses for auto-discovery.
  1008.      * Useful when you are overloading or extending SimplePie's default classes.
  1009.      *
  1010.      * @access public
  1011.      * @param string $class Name of custom class.
  1012.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1013.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1014.      */
  1015.     function set_locator_class($class 'SimplePie_Locator')
  1016.     {
  1017.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Locator'))
  1018.         {
  1019.             $this->locator_class $class;
  1020.             return true;
  1021.         }
  1022.         return false;
  1023.     }
  1024.  
  1025.     /**
  1026.      * Allows you to change which class SimplePie uses for XML parsing.
  1027.      * Useful when you are overloading or extending SimplePie's default classes.
  1028.      *
  1029.      * @access public
  1030.      * @param string $class Name of custom class.
  1031.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1032.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1033.      */
  1034.     function set_parser_class($class 'SimplePie_Parser')
  1035.     {
  1036.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Parser'))
  1037.         {
  1038.             $this->parser_class $class;
  1039.             return true;
  1040.         }
  1041.         return false;
  1042.     }
  1043.  
  1044.     /**
  1045.      * Allows you to change which class SimplePie uses for remote file fetching.
  1046.      * Useful when you are overloading or extending SimplePie's default classes.
  1047.      *
  1048.      * @access public
  1049.      * @param string $class Name of custom class.
  1050.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1051.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1052.      */
  1053.     function set_file_class($class 'SimplePie_File')
  1054.     {
  1055.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_File'))
  1056.         {
  1057.             $this->file_class $class;
  1058.             return true;
  1059.         }
  1060.         return false;
  1061.     }
  1062.  
  1063.     /**
  1064.      * Allows you to change which class SimplePie uses for data sanitization.
  1065.      * Useful when you are overloading or extending SimplePie's default classes.
  1066.      *
  1067.      * @access public
  1068.      * @param string $class Name of custom class.
  1069.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1070.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1071.      */
  1072.     function set_sanitize_class($class 'SimplePie_Sanitize')
  1073.     {
  1074.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Sanitize'))
  1075.         {
  1076.             $this->sanitize =new $class;
  1077.             return true;
  1078.         }
  1079.         return false;
  1080.     }
  1081.  
  1082.     /**
  1083.      * Allows you to change which class SimplePie uses for handling feed items.
  1084.      * Useful when you are overloading or extending SimplePie's default classes.
  1085.      *
  1086.      * @access public
  1087.      * @param string $class Name of custom class.
  1088.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1089.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1090.      */
  1091.     function set_item_class($class 'SimplePie_Item')
  1092.     {
  1093.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Item'))
  1094.         {
  1095.             $this->item_class $class;
  1096.             return true;
  1097.         }
  1098.         return false;
  1099.     }
  1100.  
  1101.     /**
  1102.      * Allows you to change which class SimplePie uses for handling author data.
  1103.      * Useful when you are overloading or extending SimplePie's default classes.
  1104.      *
  1105.      * @access public
  1106.      * @param string $class Name of custom class.
  1107.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1108.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1109.      */
  1110.     function set_author_class($class 'SimplePie_Author')
  1111.     {
  1112.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Author'))
  1113.         {
  1114.             $this->author_class $class;
  1115.             return true;
  1116.         }
  1117.         return false;
  1118.     }
  1119.  
  1120.     /**
  1121.      * Allows you to change which class SimplePie uses for handling category data.
  1122.      * Useful when you are overloading or extending SimplePie's default classes.
  1123.      *
  1124.      * @access public
  1125.      * @param string $class Name of custom class.
  1126.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1127.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1128.      */
  1129.     function set_category_class($class 'SimplePie_Category')
  1130.     {
  1131.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Category'))
  1132.         {
  1133.             $this->category_class $class;
  1134.             return true;
  1135.         }
  1136.         return false;
  1137.     }
  1138.  
  1139.     /**
  1140.      * Allows you to change which class SimplePie uses for feed enclosures.
  1141.      * Useful when you are overloading or extending SimplePie's default classes.
  1142.      *
  1143.      * @access public
  1144.      * @param string $class Name of custom class.
  1145.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1146.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1147.      */
  1148.     function set_enclosure_class($class 'SimplePie_Enclosure')
  1149.     {
  1150.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Enclosure'))
  1151.         {
  1152.             $this->enclosure_class $class;
  1153.             return true;
  1154.         }
  1155.         return false;
  1156.     }
  1157.  
  1158.     /**
  1159.      * Allows you to change which class SimplePie uses for <media:text> captions
  1160.      * Useful when you are overloading or extending SimplePie's default classes.
  1161.      *
  1162.      * @access public
  1163.      * @param string $class Name of custom class.
  1164.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1165.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1166.      */
  1167.     function set_caption_class($class 'SimplePie_Caption')
  1168.     {
  1169.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Caption'))
  1170.         {
  1171.             $this->caption_class $class;
  1172.             return true;
  1173.         }
  1174.         return false;
  1175.     }
  1176.  
  1177.     /**
  1178.      * Allows you to change which class SimplePie uses for <media:copyright>
  1179.      * Useful when you are overloading or extending SimplePie's default classes.
  1180.      *
  1181.      * @access public
  1182.      * @param string $class Name of custom class.
  1183.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1184.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1185.      */
  1186.     function set_copyright_class($class 'SimplePie_Copyright')
  1187.     {
  1188.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Copyright'))
  1189.         {
  1190.             $this->copyright_class $class;
  1191.             return true;
  1192.         }
  1193.         return false;
  1194.     }
  1195.  
  1196.     /**
  1197.      * Allows you to change which class SimplePie uses for <media:credit>
  1198.      * Useful when you are overloading or extending SimplePie's default classes.
  1199.      *
  1200.      * @access public
  1201.      * @param string $class Name of custom class.
  1202.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1203.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1204.      */
  1205.     function set_credit_class($class 'SimplePie_Credit')
  1206.     {
  1207.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Credit'))
  1208.         {
  1209.             $this->credit_class $class;
  1210.             return true;
  1211.         }
  1212.         return false;
  1213.     }
  1214.  
  1215.     /**
  1216.      * Allows you to change which class SimplePie uses for <media:rating>
  1217.      * Useful when you are overloading or extending SimplePie's default classes.
  1218.      *
  1219.      * @access public
  1220.      * @param string $class Name of custom class.
  1221.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1222.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1223.      */
  1224.     function set_rating_class($class 'SimplePie_Rating')
  1225.     {
  1226.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Rating'))
  1227.         {
  1228.             $this->rating_class $class;
  1229.             return true;
  1230.         }
  1231.         return false;
  1232.     }
  1233.  
  1234.     /**
  1235.      * Allows you to change which class SimplePie uses for <media:restriction>
  1236.      * Useful when you are overloading or extending SimplePie's default classes.
  1237.      *
  1238.      * @access public
  1239.      * @param string $class Name of custom class.
  1240.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1241.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1242.      */
  1243.     function set_restriction_class($class 'SimplePie_Restriction')
  1244.     {
  1245.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Restriction'))
  1246.         {
  1247.             $this->restriction_class $class;
  1248.             return true;
  1249.         }
  1250.         return false;
  1251.     }
  1252.  
  1253.     /**
  1254.      * Allows you to change which class SimplePie uses for content-type sniffing.
  1255.      * Useful when you are overloading or extending SimplePie's default classes.
  1256.      *
  1257.      * @access public
  1258.      * @param string $class Name of custom class.
  1259.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1260.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1261.      */
  1262.     function set_content_type_sniffer_class($class 'SimplePie_Content_Type_Sniffer')
  1263.     {
  1264.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Content_Type_Sniffer'))
  1265.         {
  1266.             $this->content_type_sniffer_class $class;
  1267.             return true;
  1268.         }
  1269.         return false;
  1270.     }
  1271.  
  1272.     /**
  1273.      * Allows you to change which class SimplePie uses item sources.
  1274.      * Useful when you are overloading or extending SimplePie's default classes.
  1275.      *
  1276.      * @access public
  1277.      * @param string $class Name of custom class.
  1278.      * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
  1279.      * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
  1280.      */
  1281.     function set_source_class($class 'SimplePie_Source')
  1282.     {
  1283.         if (SimplePie_Misc::is_subclass_of($class'SimplePie_Source'))
  1284.         {
  1285.             $this->source_class $class;
  1286.             return true;
  1287.         }
  1288.         return false;
  1289.     }
  1290.  
  1291.     /**
  1292.      * Allows you to override the default user agent string.
  1293.      *
  1294.      * @access public
  1295.      * @param string $ua New user agent string.
  1296.      */
  1297.     function set_useragent($ua SIMPLEPIE_USERAGENT)
  1298.     {
  1299.         $this->useragent = (string) $ua;
  1300.     }
  1301.  
  1302.     /**
  1303.      * Set callback function to create cache filename with
  1304.      *
  1305.      * @access public
  1306.      * @param mixed $function Callback function
  1307.      */
  1308.     function set_cache_name_function($function 'md5')
  1309.     {
  1310.         if (is_callable($function))
  1311.         {
  1312.             $this->cache_name_function $function;
  1313.         }
  1314.     }
  1315.  
  1316.     /**
  1317.      * Set javascript query string parameter
  1318.      *
  1319.      * @access public
  1320.      * @param mixed $get Javascript query string parameter
  1321.      */
  1322.     function set_javascript($get 'js')
  1323.     {
  1324.         if ($get)
  1325.         {
  1326.             $this->javascript = (string) $get;
  1327.         }
  1328.         else
  1329.         {
  1330.             $this->javascript false;
  1331.         }
  1332.     }
  1333.  
  1334.     /**
  1335.      * Set options to make SP as fast as possible.  Forgoes a
  1336.      * substantial amount of data sanitization in favor of speed.
  1337.      *
  1338.      * @access public
  1339.      * @param bool $set Whether to set them or not
  1340.      */
  1341.     function set_stupidly_fast($set false)
  1342.     {
  1343.         if ($set)
  1344.         {
  1345.             $this->enable_order_by_date(false);
  1346.             $this->remove_div(false);
  1347.             $this->strip_comments(false);
  1348.             $this->strip_htmltags(false);
  1349.             $this->strip_attributes(false);
  1350.             $this->set_image_handler(false);
  1351.         }
  1352.     }
  1353.  
  1354.     /**
  1355.      * Set maximum number of feeds to check with autodiscovery
  1356.      *
  1357.      * @access public
  1358.      * @param int $max Maximum number of feeds to check
  1359.      */
  1360.     function set_max_checked_feeds($max 10)
  1361.     {
  1362.         $this->max_checked_feeds = (int) $max;
  1363.     }
  1364.  
  1365.     function remove_div($enable true)
  1366.     {
  1367.         $this->sanitize->remove_div($enable);
  1368.     }
  1369.  
  1370.     function strip_htmltags($tags ''$encode null)
  1371.     {
  1372.         if ($tags === '')
  1373.         {
  1374.             $tags $this->strip_htmltags;
  1375.         }
  1376.         $this->sanitize->strip_htmltags($tags);
  1377.         if ($encode !== null)
  1378.         {
  1379.             $this->sanitize->encode_instead_of_strip($tags);
  1380.         }
  1381.     }
  1382.  
  1383.     function encode_instead_of_strip($enable true)
  1384.     {
  1385.         $this->sanitize->encode_instead_of_strip($enable);
  1386.     }
  1387.  
  1388.     function strip_attributes($attribs '')
  1389.     {
  1390.         if ($attribs === '')
  1391.         {
  1392.             $attribs $this->strip_attributes;
  1393.         }
  1394.         $this->sanitize->strip_attributes($attribs);
  1395.     }
  1396.  
  1397.     function set_output_encoding($encoding 'UTF-8')
  1398.     {
  1399.         $this->sanitize->set_output_encoding($encoding);
  1400.     }
  1401.  
  1402.     function strip_comments($strip false)
  1403.     {
  1404.         $this->sanitize->strip_comments($strip);
  1405.     }
  1406.  
  1407.     /**
  1408.      * Set element/attribute key/value pairs of HTML attributes
  1409.      * containing URLs that need to be resolved relative to the feed
  1410.      *
  1411.      * @access public
  1412.      * @since 1.0
  1413.      * @param array $element_attribute Element/attribute key/value pairs
  1414.      */
  1415.     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'))
  1416.     {
  1417.         $this->sanitize->set_url_replacements($element_attribute);
  1418.     }
  1419.  
  1420.     /**
  1421.      * Set the handler to enable the display of cached favicons.
  1422.      *
  1423.      * @access public
  1424.      * @param str $page Web-accessible path to the handler_favicon.php file.
  1425.      * @param str $qs The query string that the value should be passed to.
  1426.      */
  1427.     function set_favicon_handler($page false$qs 'i')
  1428.     {
  1429.         if ($page != false)
  1430.         {
  1431.             $this->favicon_handler $page '?' $qs '=';
  1432.         }
  1433.         else
  1434.         {
  1435.             $this->favicon_handler '';
  1436.         }
  1437.     }
  1438.  
  1439.     /**
  1440.      * Set the handler to enable the display of cached images.
  1441.      *
  1442.      * @access public
  1443.      * @param str $page Web-accessible path to the handler_image.php file.
  1444.      * @param str $qs The query string that the value should be passed to.
  1445.      */
  1446.     function set_image_handler($page false$qs 'i')
  1447.     {
  1448.         if ($page != false)
  1449.         {
  1450.             $this->sanitize->set_image_handler($page '?' $qs '=');
  1451.         }
  1452.         else
  1453.         {
  1454.             $this->image_handler '';
  1455.         }
  1456.     }
  1457.  
  1458.     /**
  1459.      * Set the limit for items returned per-feed with multifeeds.
  1460.      *
  1461.      * @access public
  1462.      * @param integer $limit The maximum number of items to return.
  1463.      */
  1464.     function set_item_limit($limit 0)
  1465.     {
  1466.         $this->item_limit = (int) $limit;
  1467.     }
  1468.  
  1469.     function init()
  1470.     {
  1471.         if ((function_exists('version_compare'&& version_compare(PHP_VERSION'4.3.0''<')) || !extension_loaded('xml'|| !extension_loaded('pcre'))
  1472.         {
  1473.             return false;
  1474.         }
  1475.         if (isset($_GET[$this->javascript]))
  1476.         {
  1477.             if (function_exists('ob_gzhandler'))
  1478.             {
  1479.                 ob_start('ob_gzhandler');
  1480.             }
  1481.             header('Content-type: text/javascript; charset: UTF-8');
  1482.             header('Cache-Control: must-revalidate');
  1483.             header('Expires: ' gmdate('D, d M Y H:i:s'time(604800' GMT')// 7 days
  1484.             ?>
  1485. function embed_odeo(link) {
  1486.     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>');
  1487. }
  1488.  
  1489. function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
  1490.     if (placeholder != '') {
  1491.         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>');
  1492.     }
  1493.     else {
  1494.         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>');
  1495.     }
  1496. }
  1497.  
  1498. function embed_flash(bgcolor, width, height, link, loop, type) {
  1499.     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>');
  1500. }
  1501.  
  1502. function embed_flv(width, height, link, placeholder, loop, player) {
  1503.     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>');
  1504. }
  1505.  
  1506. function embed_wmedia(width, height, link) {
  1507.     document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
  1508. }
  1509.             <?php
  1510.             exit;
  1511.         }
  1512.  
  1513.         // Pass whatever was set with config options over to the sanitizer.
  1514.         $this->sanitize->pass_cache_data($this->cache$this->cache_location$this->cache_name_function$this->cache_class);
  1515.         $this->sanitize->pass_file_data($this->file_class$this->timeout$this->useragent$this->force_fsockopen);
  1516.  
  1517.         if ($this->feed_url !== null || $this->raw_data !== null)
  1518.         {
  1519.             $this->data array();
  1520.             $this->multifeed_objects array();
  1521.             $cache false;
  1522.  
  1523.             if ($this->feed_url !== null)
  1524.             {
  1525.                 $parsed_feed_url SimplePie_Misc::parse_url($this->feed_url);
  1526.                 // Decide whether to enable caching
  1527.                 if ($this->cache && $parsed_feed_url['scheme'!== '')
  1528.                 {
  1529.                     $cache call_user_func(array($this->cache_class'create')$this->cache_locationcall_user_func($this->cache_name_function$this->feed_url)'spc');
  1530.                 }
  1531.                 // If it's enabled and we don't want an XML dump, use the cache
  1532.                 if ($cache && !$this->xml_dump)
  1533.                 {
  1534.                     // Load the Cache
  1535.                     $this->data $cache->load();
  1536.                     if (!empty($this->data))
  1537.                     {
  1538.                         // If the cache is for an outdated build of SimplePie
  1539.                         if (!isset($this->data['build']|| $this->data['build'!= SIMPLEPIE_BUILD)
  1540.                         {
  1541.                             $cache->unlink();
  1542.                             $this->data array();
  1543.                         }
  1544.                         // If we've hit a collision just rerun it with caching disabled
  1545.                         elseif (isset($this->data['url']&& $this->data['url'!= $this->feed_url)
  1546.                         {
  1547.                             $cache false;
  1548.                             $this->data array();
  1549.                         }
  1550.                         // If we've got a non feed_url stored (if the page isn't actually a feed, or is a redirect) use that URL.
  1551.                         elseif (isset($this->data['feed_url']))
  1552.                         {
  1553.                             // If the autodiscovery cache is still valid use it.
  1554.                             if ($cache->mtime($this->autodiscovery_cache_duration time())
  1555.                             {
  1556.                                 // Do not need to do feed autodiscovery yet.
  1557.                                 if ($this->data['feed_url'== $this->data['url'])
  1558.                                 {
  1559.                                     $cache->unlink();
  1560.                                     $this->data array();
  1561.                                 }
  1562.                                 else
  1563.                                 {
  1564.                                     $this->set_feed_url($this->data['feed_url']);
  1565.                                     return $this->init();
  1566.                                 }
  1567.                             }
  1568.                         }
  1569.                         // Check if the cache has been updated
  1570.                         elseif ($cache->mtime($this->cache_duration time())
  1571.                         {
  1572.                             // If we have last-modified and/or etag set
  1573.                             if (isset($this->data['headers']['last-modified']|| isset($this->data['headers']['etag']))
  1574.                             {
  1575.                                 $headers array();
  1576.                                 if (isset($this->data['headers']['last-modified']))
  1577.                                 {
  1578.                                     $headers['if-modified-since'$this->data['headers']['last-modified'];
  1579.                                 }
  1580.                                 if (isset($this->data['headers']['etag']))
  1581.                                 {
  1582.                                     $headers['if-none-match''"' $this->data['headers']['etag''"';
  1583.                                 }
  1584.                                 $file =new $this->file_class($this->feed_url$this->timeout/105$headers$this->useragent$this->force_fsockopen);
  1585.                                 if ($file->success)
  1586.                                 {
  1587.                                     if ($file->status_code == 304)
  1588.                                     {
  1589.                                         $cache->touch();
  1590.                                         return true;
  1591.                                     }
  1592.                                     else
  1593.                                     {
  1594.                                         $headers $file->headers;
  1595.                                     }
  1596.                                 }
  1597.                                 else
  1598.                                 {
  1599.                                     unset($file);
  1600.                                 }
  1601.                             }
  1602.                         }
  1603.                         // If the cache is still valid, just return true
  1604.                         else
  1605.                         {
  1606.                             return true;
  1607.                         }
  1608.                     }
  1609.                     // If the cache is empty, delete it
  1610.                     else
  1611.                     {
  1612.                         $cache->unlink();
  1613.                         $this->data array();
  1614.                     }
  1615.                 }
  1616.                 // 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.
  1617.                 if (!isset($file))
  1618.                 {
  1619.                     if (is_a($this->file'SimplePie_File'&& $this->file->url == $this->feed_url)
  1620.                     {
  1621.                         $file =$this->file;
  1622.                     }
  1623.                     else
  1624.                     {
  1625.                         $file =new $this->file_class($this->feed_url$this->timeout5null$this->useragent$this->force_fsockopen);
  1626.                     }
  1627.                 }
  1628.                 // If the file connection has an error, set SimplePie::error to that and quit
  1629.                 if (!$file->success)
  1630.                 {
  1631.                     $this->error $file->error;
  1632.                     if (!empty($this->data))
  1633.                     {
  1634.                         return true;
  1635.                     }
  1636.                     else
  1637.                     {
  1638.                         return false;
  1639.                     }
  1640.                 }
  1641.  
  1642.                 if (!$this->force_feed)
  1643.                 {
  1644.                     // Check if the supplied URL is a feed, if it isn't, look for it.
  1645.                     $locate =new $this->locator_class($file$this->timeout$this->useragent$this->file_class$this->max_checked_feeds$this->content_type_sniffer_class);
  1646.                     if (!$locate->is_feed($file))
  1647.                     {
  1648.                         // We need to unset this so that if SimplePie::set_file() has been called that object is untouched
  1649.                         unset($file);
  1650.                         if ($file $locate->find($this->autodiscovery))
  1651.                         {
  1652.                             if ($cache)
  1653.                             {
  1654.                                 $this->data array('url' => $this->feed_url'feed_url' => $file->url'build' => SIMPLEPIE_BUILD);
  1655.                                 if (!$cache->save($this))
  1656.                                 {
  1657.                                     trigger_error("$cache->name is not writeable"E_USER_WARNING);
  1658.                                 }
  1659.                                 $cache call_user_func(array($this->cache_class'create')$this->cache_locationcall_user_func($this->cache_name_function$file->url)'spc');
  1660.                             }
  1661.                             $this->feed_url $file->url;
  1662.                         }
  1663.                         else
  1664.                         {
  1665.                             $this->error "A feed could not be found at $this->feed_url";
  1666.                             SimplePie_Misc::error($this->errorE_USER_NOTICE__FILE____LINE__);
  1667.                             return false;
  1668.                         }
  1669.                     }
  1670.                     $locate null;
  1671.                 }
  1672.  
  1673.                 $headers $file->headers;
  1674.                 $data $file->body;
  1675.                 $sniffer new $this->content_type_sniffer_class($file);
  1676.                 $sniffed $sniffer->get_type();
  1677.             }
  1678.             else
  1679.             {
  1680.                 $data $this->raw_data;
  1681.             }
  1682.             
  1683.             // Set up array of possible encodings
  1684.             $encodings array();
  1685.  
  1686.             // First check to see if input has been overridden.
  1687.             if ($this->input_encoding !== false)
  1688.             {
  1689.                 $encodings[$this->input_encoding;
  1690.             }
  1691.             
  1692.             $application_types array('application/xml''application/xml-dtd''application/xml-external-parsed-entity');
  1693.             $text_types array('text/xml''text/xml-external-parsed-entity');
  1694.             
  1695.             // RFC 3023 (only applies to sniffed content)
  1696.             if (isset($sniffed))
  1697.             {
  1698.                 if (in_array($sniffed$application_types|| substr($sniffed012=== 'application/' && substr($sniffed-4=== '+xml')
  1699.                 {
  1700.                     if (isset($headers['content-type']&& preg_match('/;\x20?charset=([^;]*)/i'$headers['content-type']$charset))
  1701.                     {
  1702.                         $encodings[strtoupper($charset[1]);
  1703.                     }
  1704.                     $encodings array_merge($encodingsSimplePie_Misc::xml_encoding($data));
  1705.                     $encodings['UTF-8';
  1706.                 }
  1707.                 elseif (in_array($sniffed$text_types|| substr($sniffed05=== 'text/' && substr($sniffed-4=== '+xml')
  1708.                 {
  1709.                     if (isset($headers['content-type']&& preg_match('/;\x20?charset=([^;]*)/i'$headers['content-type']$charset))
  1710.                     {
  1711.                         $encodings[$charset[1];
  1712.                     }
  1713.                     $encodings['US-ASCII';
  1714.                 }
  1715.                 // Text MIME-type default
  1716.                 elseif (substr($sniffed05=== 'text/')
  1717.                 {
  1718.                     $encodings['US-ASCII';
  1719.                 }
  1720.             }
  1721.             
  1722.             // Fallback to XML 1.0 Appendix F.1/UTF-8/ISO-8859-1
  1723.             $encodings array_merge($encodingsSimplePie_Misc::xml_encoding($data));
  1724.             $encodings['UTF-8';
  1725.             $encodings['ISO-8859-1';
  1726.             
  1727.             // There's no point in trying an encoding twice
  1728.             $encodings array_unique($encodings);
  1729.             
  1730.             // If we want the XML, just output that with the most likely encoding and quit
  1731.             if ($this->xml_dump)
  1732.             {
  1733.                 header('Content-type: text/xml; charset=' $encodings[0]);
  1734.                 echo $data;
  1735.                 exit;
  1736.             }
  1737.             
  1738.             // Loop through each possible encoding, till we return something, or run out of possibilities
  1739.             foreach ($encodings as $encoding)
  1740.             {
  1741.                 // Change the encoding to UTF-8 (as we always use UTF-8 internally)
  1742.                 $utf8_data SimplePie_Misc::change_encoding($data$encoding'UTF-8');
  1743.  
  1744.                 // Create new parser
  1745.                 $parser =new $this->parser_class();
  1746.                 
  1747.                 // If it's parsed fine
  1748.                 if ($parser->parse($utf8_data'UTF-8'))
  1749.                 {
  1750.                     $this->data $parser->get_data();
  1751.                     if (isset($this->data['child']))
  1752.                     {
  1753.                         if (isset($headers))
  1754.                         {
  1755.                             $this->data['headers'$headers;
  1756.                         }
  1757.                         $this->data['build'SIMPLEPIE_BUILD;
  1758.     
  1759.                         // Cache the file if caching is enabled
  1760.                         if ($cache && !$cache->save($this))
  1761.                         {
  1762.                             trigger_error("$cache->name is not writeable"E_USER_WARNING);
  1763.                         }
  1764.                         return true;
  1765.                     }
  1766.                     else
  1767.                     {
  1768.                         $this->error "A feed could not be found at $this->feed_url";
  1769.                         SimplePie_Misc::error($this->errorE_USER_NOTICE__FILE____LINE__);
  1770.                         return false;
  1771.                     }
  1772.                 }
  1773.             }
  1774.             // We have an error, just set SimplePie::error to it and quit
  1775.             $this->error sprintf('XML error: %s at line %d, column %d'$parser->get_error_string()$parser->get_current_line()$parser->get_current_column());
  1776.             SimplePie_Misc::error($this->errorE_USER_NOTICE__FILE____LINE__);
  1777.             return false;
  1778.         }
  1779.         elseif (!empty($this->multifeed_url))
  1780.         {
  1781.             $i 0;
  1782.             $success 0;
  1783.             $this->multifeed_objects array();
  1784.             foreach ($this->multifeed_url as $url)
  1785.             {
  1786.                 if (SIMPLEPIE_PHP5)
  1787.                 {
  1788.                     // This keyword needs to defy coding standards for PHP4 compatibility
  1789.                     $this->multifeed_objects[$iclone($this);
  1790.                 }
  1791.                 else
  1792.                 {
  1793.                     $this->multifeed_objects[$i$this;
  1794.                 }
  1795.                 $this->multifeed_objects[$i]->set_feed_url($url);
  1796.                 $success |= $this->multifeed_objects[$i]->init();
  1797.                 $i++;
  1798.             }
  1799.             return (bool) $success;
  1800.         }
  1801.         else
  1802.         {
  1803.             return false;
  1804.         }
  1805.     }
  1806.  
  1807.     /**
  1808.      * Return the error message for the occured error
  1809.      *
  1810.      * @access public
  1811.      * @return string Error message
  1812.      */
  1813.     function error()
  1814.     {
  1815.         return $this->error;
  1816.     }
  1817.  
  1818.     function get_encoding()
  1819.     {
  1820.         return $this->sanitize->output_encoding;
  1821.     }
  1822.  
  1823.     function handle_content_type($mime 'text/html')
  1824.     {
  1825.         if (!headers_sent())
  1826.         {
  1827.             $header "Content-type: $mime;";
  1828.             if ($this->get_encoding())
  1829.             {
  1830.                 $header .= ' charset=' $this->get_encoding();
  1831.             }
  1832.             else
  1833.             {
  1834.                 $header .= ' charset=UTF-8';
  1835.             }
  1836.             header($header);
  1837.         }
  1838.     }
  1839.  
  1840.     function get_type()
  1841.     {
  1842.         if (!isset($this->data['type']))
  1843.         {
  1844.             $this->data['type'SIMPLEPIE_TYPE_ALL;
  1845.             if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed']))
  1846.             {
  1847.                 $this->data['type'&= SIMPLEPIE_TYPE_ATOM_10;
  1848.             }
  1849.             elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed']))
  1850.             {
  1851.                 $this->data['type'&= SIMPLEPIE_TYPE_ATOM_03;
  1852.             }
  1853.             elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF']))
  1854.             {
  1855.                 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['channel'])
  1856.                 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['image'])
  1857.                 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item'])
  1858.                 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['textinput']))
  1859.                 {
  1860.                     $this->data['type'&= SIMPLEPIE_TYPE_RSS_10;
  1861.                 }
  1862.                 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['channel'])
  1863.                 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['image'])
  1864.                 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item'])
  1865.                 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['textinput']))
  1866.                 {
  1867.                     $this->data['type'&= SIMPLEPIE_TYPE_RSS_090;
  1868.                 }
  1869.             }
  1870.             elseif (isset($this->data['child']['']['rss']))
  1871.             {
  1872.                 $this->data['type'&= SIMPLEPIE_TYPE_RSS_ALL;
  1873.                 if (isset($this->data['child']['']['rss'][0]['attribs']['']['version']))
  1874.                 {
  1875.                     switch (trim($this->data['child']['']['rss'][0]['attribs']['']['version']))
  1876.                     {
  1877.                         case '0.91':
  1878.                             $this->data['type'&= SIMPLEPIE_TYPE_RSS_091;
  1879.                             if (isset($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data']))
  1880.                             {
  1881.                                 switch (trim($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data']))
  1882.                                 {
  1883.                                     case '0':
  1884.                                         $this->data['type'&= SIMPLEPIE_TYPE_RSS_091_NETSCAPE;
  1885.                                         break;
  1886.  
  1887.                                     case '24':
  1888.                                         $this->data['type'&= SIMPLEPIE_TYPE_RSS_091_USERLAND;
  1889.                                         break;
  1890.                                 }
  1891.                             }
  1892.                             break;
  1893.  
  1894.                         case '0.92':
  1895.                             $this->data['type'&= SIMPLEPIE_TYPE_RSS_092;
  1896.                             break;
  1897.  
  1898.                         case '0.93':
  1899.                             $this->data['type'&= SIMPLEPIE_TYPE_RSS_093;
  1900.                             break;
  1901.  
  1902.                         case '0.94':
  1903.                             $this->data['type'&= SIMPLEPIE_TYPE_RSS_094;
  1904.                             break;
  1905.  
  1906.                         case '2.0':
  1907.                             $this->data['type'&= SIMPLEPIE_TYPE_RSS_20;
  1908.                             break;
  1909.                     }
  1910.                 }
  1911.             }
  1912.             else
  1913.             {
  1914.                 $this->data['type'SIMPLEPIE_TYPE_NONE;
  1915.             }
  1916.         }
  1917.         return $this->data['type'];
  1918.     }
  1919.  
  1920.     /**
  1921.      * Returns the URL for the favicon of the feed's website.
  1922.      *
  1923.      * @todo Cache atom:icon
  1924.      * @access public
  1925.      * @since 1.0
  1926.      */
  1927.     function get_favicon()
  1928.     {
  1929.         if ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'icon'))
  1930.         {
  1931.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  1932.         }
  1933.         elseif (($url $this->get_link()) !== null && preg_match('/^http(s)?:\/\//i'$url))
  1934.         {
  1935.             $favicon SimplePie_Misc::absolutize_url('/favicon.ico'$url);
  1936.  
  1937.             if ($this->cache && $this->favicon_handler)
  1938.             {
  1939.                 $favicon_filename call_user_func($this->cache_name_function$favicon);
  1940.                 $cache call_user_func(array($this->cache_class'create')$this->cache_location$favicon_filename'spi');
  1941.  
  1942.                 if ($cache->load())
  1943.                 {
  1944.                     return $this->sanitize($this->favicon_handler $favicon_filenameSIMPLEPIE_CONSTRUCT_IRI);
  1945.                 }
  1946.                 else
  1947.                 {
  1948.                     $file =new $this->file_class($favicon$this->timeout 105array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR'])$this->useragent$this->force_fsockopen);
  1949.  
  1950.                     if ($file->success && ($file->status_code == 200 || ($file->status_code 206 && $file->status_code 300)) && strlen($file->body0)
  1951.                     {
  1952.                         $sniffer new $this->content_type_sniffer_class($file);
  1953.                         if (substr($sniffer->get_type()06=== 'image/')
  1954.                         {
  1955.                             if ($cache->save(array('headers' => $file->headers'body' => $file->body)))
  1956.                             {
  1957.                                 return $this->sanitize($this->favicon_handler $favicon_filenameSIMPLEPIE_CONSTRUCT_IRI);
  1958.                             }
  1959.                             else
  1960.                             {
  1961.                                 trigger_error("$cache->name is not writeable"E_USER_WARNING);
  1962.                                 return $this->sanitize($faviconSIMPLEPIE_CONSTRUCT_IRI);
  1963.                             }
  1964.                         }
  1965.                     }
  1966.                 }
  1967.             }
  1968.             else
  1969.             {
  1970.                 return $this->sanitize($faviconSIMPLEPIE_CONSTRUCT_IRI);
  1971.             }
  1972.         }
  1973.         return false;
  1974.     }
  1975.  
  1976.     /**
  1977.      * @todo If we have a perm redirect we should return the new URL
  1978.      * @todo When we make the above change, let's support <itunes:new-feed-url> as well
  1979.      * @todo Also, |atom:link|@rel=self
  1980.      */
  1981.     function subscribe_url()
  1982.     {
  1983.         if ($this->feed_url !== null)
  1984.         {
  1985.             return $this->sanitize($this->feed_urlSIMPLEPIE_CONSTRUCT_IRI);
  1986.         }
  1987.         else
  1988.         {
  1989.             return null;
  1990.         }
  1991.     }
  1992.  
  1993.     function subscribe_feed()
  1994.     {
  1995.         if ($this->feed_url !== null)
  1996.         {
  1997.             return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url2)SIMPLEPIE_CONSTRUCT_IRI);
  1998.         }
  1999.         else
  2000.         {
  2001.             return null;
  2002.         }
  2003.     }
  2004.  
  2005.     function subscribe_outlook()
  2006.     {
  2007.         if ($this->feed_url !== null)
  2008.         {
  2009.             return 'outlook' $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url2)SIMPLEPIE_CONSTRUCT_IRI);
  2010.         }
  2011.         else
  2012.         {
  2013.             return null;
  2014.         }
  2015.     }
  2016.  
  2017.     function subscribe_podcast()
  2018.     {
  2019.         if ($this->feed_url !== null)
  2020.         {
  2021.             return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url3)SIMPLEPIE_CONSTRUCT_IRI);
  2022.         }
  2023.         else
  2024.         {
  2025.             return null;
  2026.         }
  2027.     }
  2028.  
  2029.     function subscribe_itunes()
  2030.     {
  2031.         if ($this->feed_url !== null)
  2032.         {
  2033.             return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url4)SIMPLEPIE_CONSTRUCT_IRI);
  2034.         }
  2035.         else
  2036.         {
  2037.             return null;
  2038.         }
  2039.     }
  2040.  
  2041.     /**
  2042.      * Creates the subscribe_* methods' return data
  2043.      *
  2044.      * @access private
  2045.      * @param string $feed_url String to prefix to the feed URL
  2046.      * @param string $site_url String to prefix to the site URL (and
  2047.      *  suffix to the feed URL)
  2048.      * @return mixed URL if feed exists, false otherwise
  2049.      */
  2050.     function subscribe_service($feed_url$site_url null)
  2051.     {
  2052.         if ($this->subscribe_url())
  2053.         {
  2054.             $return $this->sanitize($feed_urlSIMPLEPIE_CONSTRUCT_IRIrawurlencode($this->feed_url);
  2055.             if ($site_url !== null && $this->get_link(!== null)
  2056.             {
  2057.                 $return .= $this->sanitize($site_urlSIMPLEPIE_CONSTRUCT_IRIrawurlencode($this->get_link());
  2058.             }
  2059.             return $return;
  2060.         }
  2061.         else
  2062.         {
  2063.             return null;
  2064.         }
  2065.     }
  2066.  
  2067.     function subscribe_aol()
  2068.     {
  2069.         return $this->subscribe_service('http://feeds.my.aol.com/add.jsp?url=');
  2070.     }
  2071.  
  2072.     function subscribe_bloglines()
  2073.     {
  2074.         return urldecode($this->subscribe_service('http://www.bloglines.com/sub/'));
  2075.     }
  2076.  
  2077.     function subscribe_eskobo()
  2078.     {
  2079.         return $this->subscribe_service('http://www.eskobo.com/?AddToMyPage=');
  2080.     }
  2081.  
  2082.     function subscribe_feedfeeds()
  2083.     {
  2084.         return $this->subscribe_service('http://www.feedfeeds.com/add?feed=');
  2085.     }
  2086.  
  2087.     function subscribe_feedster()
  2088.     {
  2089.         return $this->subscribe_service('http://www.feedster.com/myfeedster.php?action=addrss&confirm=no&rssurl=');
  2090.     }
  2091.  
  2092.     function subscribe_google()
  2093.     {
  2094.         return $this->subscribe_service('http://fusion.google.com/add?feedurl=');
  2095.     }
  2096.  
  2097.     function subscribe_gritwire()
  2098.     {
  2099.         return $this->subscribe_service('http://my.gritwire.com/feeds/addExternalFeed.aspx?FeedUrl=');
  2100.     }
  2101.  
  2102.     function subscribe_msn()
  2103.     {
  2104.         return $this->subscribe_service('http://my.msn.com/addtomymsn.armx?id=rss&ut=''&ru=');
  2105.     }
  2106.  
  2107.     function subscribe_netvibes()
  2108.     {
  2109.         return $this->subscribe_service('http://www.netvibes.com/subscribe.php?url=');
  2110.     }
  2111.  
  2112.     function subscribe_newsburst()
  2113.     {
  2114.         return $this->subscribe_service('http://www.newsburst.com/Source/?add=');
  2115.     }
  2116.  
  2117.     function subscribe_newsgator()
  2118.     {
  2119.         return $this->subscribe_service('http://www.newsgator.com/ngs/subscriber/subext.aspx?url=');
  2120.     }
  2121.  
  2122.     function subscribe_odeo()
  2123.     {
  2124.         return $this->subscribe_service('http://www.odeo.com/listen/subscribe?feed=');
  2125.     }
  2126.  
  2127.     function subscribe_podnova()
  2128.     {
  2129.         return $this->subscribe_service('http://www.podnova.com/index_your_podcasts.srf?action=add&url=');
  2130.     }
  2131.  
  2132.     function subscribe_rojo()
  2133.     {
  2134.         return $this->subscribe_service('http://www.rojo.com/add-subscription?resource=');
  2135.     }
  2136.  
  2137.     function subscribe_yahoo()
  2138.     {
  2139.         return $this->subscribe_service('http://add.my.yahoo.com/rss?url=');
  2140.     }
  2141.  
  2142.     function get_feed_tags($namespace$tag)
  2143.     {
  2144.         $type $this->get_type();
  2145.         if ($type SIMPLEPIE_TYPE_ATOM_10)
  2146.         {
  2147.             if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag]))
  2148.             {
  2149.                 return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag];
  2150.             }
  2151.         }
  2152.         if ($type SIMPLEPIE_TYPE_ATOM_03)
  2153.         {
  2154.             if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag]))
  2155.             {
  2156.                 return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag];
  2157.             }
  2158.         }
  2159.         if ($type SIMPLEPIE_TYPE_RSS_RDF)
  2160.         {
  2161.             if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag]))
  2162.             {
  2163.                 return $this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag];
  2164.             }
  2165.         }
  2166.         if ($type SIMPLEPIE_TYPE_RSS_SYNDICATION)
  2167.         {
  2168.             if (isset($this->data['child']['']['rss'][0]['child'][$namespace][$tag]))
  2169.             {
  2170.                 return $this->data['child']['']['rss'][0]['child'][$namespace][$tag];
  2171.             }
  2172.         }
  2173.         return null;
  2174.     }
  2175.  
  2176.     function get_channel_tags($namespace$tag)
  2177.     {
  2178.         $type $this->get_type();
  2179.         if ($type SIMPLEPIE_TYPE_ATOM_ALL)
  2180.         {
  2181.             if ($return $this->get_feed_tags($namespace$tag))
  2182.             {
  2183.                 return $return;
  2184.             }
  2185.         }
  2186.         if ($type SIMPLEPIE_TYPE_RSS_10)
  2187.         {
  2188.             if ($channel $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10'channel'))
  2189.             {
  2190.                 if (isset($channel[0]['child'][$namespace][$tag]))
  2191.                 {
  2192.                     return $channel[0]['child'][$namespace][$tag];
  2193.                 }
  2194.             }
  2195.         }
  2196.         if ($type SIMPLEPIE_TYPE_RSS_090)
  2197.         {
  2198.             if ($channel $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090'channel'))
  2199.             {
  2200.                 if (isset($channel[0]['child'][$namespace][$tag]))
  2201.                 {
  2202.                     return $channel[0]['child'][$namespace][$tag];
  2203.                 }
  2204.             }
  2205.         }
  2206.         if ($type SIMPLEPIE_TYPE_RSS_SYNDICATION)
  2207.         {
  2208.             if ($channel $this->get_feed_tags('''channel'))
  2209.             {
  2210.                 if (isset($channel[0]['child'][$namespace][$tag]))
  2211.                 {
  2212.                     return $channel[0]['child'][$namespace][$tag];
  2213.                 }
  2214.             }
  2215.         }
  2216.         return null;
  2217.     }
  2218.  
  2219.     function get_image_tags($namespace$tag)
  2220.     {
  2221.         $type $this->get_type();
  2222.         if ($type SIMPLEPIE_TYPE_RSS_10)
  2223.         {
  2224.             if ($image $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10'image'))
  2225.             {
  2226.                 if (isset($image[0]['child'][$namespace][$tag]))
  2227.                 {
  2228.                     return $image[0]['child'][$namespace][$tag];
  2229.                 }
  2230.             }
  2231.         }
  2232.         if ($type SIMPLEPIE_TYPE_RSS_090)
  2233.         {
  2234.             if ($image $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090'image'))
  2235.             {
  2236.                 if (isset($image[0]['child'][$namespace][$tag]))
  2237.                 {
  2238.                     return $image[0]['child'][$namespace][$tag];
  2239.                 }
  2240.             }
  2241.         }
  2242.         if ($type SIMPLEPIE_TYPE_RSS_SYNDICATION)
  2243.         {
  2244.             if ($image $this->get_channel_tags('''image'))
  2245.             {
  2246.                 if (isset($image[0]['child'][$namespace][$tag]))
  2247.                 {
  2248.                     return $image[0]['child'][$namespace][$tag];
  2249.                 }
  2250.             }
  2251.         }
  2252.         return null;
  2253.     }
  2254.  
  2255.     function get_base($element array())
  2256.     {
  2257.         if (!($this->get_type(SIMPLEPIE_TYPE_RSS_SYNDICATION&& !empty($element['xml_base_explicit']&& isset($element['xml_base']))
  2258.         {
  2259.             return $element['xml_base'];
  2260.         }
  2261.         elseif ($this->get_link(!== null)
  2262.         {
  2263.             return $this->get_link();
  2264.         }
  2265.         else
  2266.         {
  2267.             return $this->subscribe_url();
  2268.         }
  2269.     }
  2270.  
  2271.     function sanitize($data$type$base '')
  2272.     {
  2273.         return $this->sanitize->sanitize($data$type$base);
  2274.     }
  2275.  
  2276.     function get_title()
  2277.     {
  2278.         if ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'title'))
  2279.         {
  2280.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_10_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  2281.         }
  2282.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03'title'))
  2283.         {
  2284.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_03_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  2285.         }
  2286.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10'title'))
  2287.         {
  2288.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  2289.         }
  2290.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090'title'))
  2291.         {
  2292.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  2293.         }
  2294.         elseif ($return $this->get_channel_tags('''title'))
  2295.         {
  2296.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  2297.         }
  2298.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11'title'))
  2299.         {
  2300.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2301.         }
  2302.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10'title'))
  2303.         {
  2304.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2305.         }
  2306.         else
  2307.         {
  2308.             return null;
  2309.         }
  2310.     }
  2311.  
  2312.     function get_category($key 0)
  2313.     {
  2314.         $categories $this->get_categories();
  2315.         if (isset($categories[$key]))
  2316.         {
  2317.             return $categories[$key];
  2318.         }
  2319.         else
  2320.         {
  2321.             return null;
  2322.         }
  2323.     }
  2324.  
  2325.     function get_categories()
  2326.     {
  2327.         $categories array();
  2328.  
  2329.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'category'as $category)
  2330.         {
  2331.             $term null;
  2332.             $scheme null;
  2333.             $label null;
  2334.             if (isset($category['attribs']['']['term']))
  2335.             {
  2336.                 $term $this->sanitize($category['attribs']['']['term']SIMPLEPIE_CONSTRUCT_TEXT);
  2337.             }
  2338.             if (isset($category['attribs']['']['scheme']))
  2339.             {
  2340.                 $scheme $this->sanitize($category['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  2341.             }
  2342.             if (isset($category['attribs']['']['label']))
  2343.             {
  2344.                 $label $this->sanitize($category['attribs']['']['label']SIMPLEPIE_CONSTRUCT_TEXT);
  2345.             }
  2346.             $categories[=new $this->category_class($term$scheme$label);
  2347.         }
  2348.         foreach ((array) $this->get_channel_tags('''category'as $category)
  2349.         {
  2350.             $categories[=new $this->category_class($this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  2351.         }
  2352.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11'subject'as $category)
  2353.         {
  2354.             $categories[=new $this->category_class($this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  2355.         }
  2356.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10'subject'as $category)
  2357.         {
  2358.             $categories[=new $this->category_class($this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  2359.         }
  2360.  
  2361.         if (!empty($categories))
  2362.         {
  2363.             return SimplePie_Misc::array_unique($categories);
  2364.         }
  2365.         else
  2366.         {
  2367.             return null;
  2368.         }
  2369.     }
  2370.  
  2371.     function get_author($key 0)
  2372.     {
  2373.         $authors $this->get_authors();
  2374.         if (isset($authors[$key]))
  2375.         {
  2376.             return $authors[$key];
  2377.         }
  2378.         else
  2379.         {
  2380.             return null;
  2381.         }
  2382.     }
  2383.  
  2384.     function get_authors()
  2385.     {
  2386.         $authors array();
  2387.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'author'as $author)
  2388.         {
  2389.             $name null;
  2390.             $uri null;
  2391.             $email null;
  2392.             if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
  2393.             {
  2394.                 $name $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2395.             }
  2396.             if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
  2397.             {
  2398.                 $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]));
  2399.             }
  2400.             if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
  2401.             {
  2402.                 $email $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2403.             }
  2404.             if ($name !== null || $email !== null || $uri !== null)
  2405.             {
  2406.                 $authors[=new $this->author_class($name$uri$email);
  2407.             }
  2408.         }
  2409.         if ($author $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03'author'))
  2410.         {
  2411.             $name null;
  2412.             $url null;
  2413.             $email null;
  2414.             if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
  2415.             {
  2416.                 $name $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2417.             }
  2418.             if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
  2419.             {
  2420.                 $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]));
  2421.             }
  2422.             if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
  2423.             {
  2424.                 $email $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2425.             }
  2426.             if ($name !== null || $email !== null || $url !== null)
  2427.             {
  2428.                 $authors[=new $this->author_class($name$url$email);
  2429.             }
  2430.         }
  2431.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11'creator'as $author)
  2432.         {
  2433.             $authors[=new $this->author_class($this->sanitize($author['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  2434.         }
  2435.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10'creator'as $author)
  2436.         {
  2437.             $authors[=new $this->author_class($this->sanitize($author['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  2438.         }
  2439.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES'author'as $author)
  2440.         {
  2441.             $authors[=new $this->author_class($this->sanitize($author['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  2442.         }
  2443.  
  2444.         if (!empty($authors))
  2445.         {
  2446.             return SimplePie_Misc::array_unique($authors);
  2447.         }
  2448.         else
  2449.         {
  2450.             return null;
  2451.         }
  2452.     }
  2453.  
  2454.     function get_contributor($key 0)
  2455.     {
  2456.         $contributors $this->get_contributors();
  2457.         if (isset($contributors[$key]))
  2458.         {
  2459.             return $contributors[$key];
  2460.         }
  2461.         else
  2462.         {
  2463.             return null;
  2464.         }
  2465.     }
  2466.  
  2467.     function get_contributors()
  2468.     {
  2469.         $contributors array();
  2470.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'contributor'as $contributor)
  2471.         {
  2472.             $name null;
  2473.             $uri null;
  2474.             $email null;
  2475.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
  2476.             {
  2477.                 $name $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2478.             }
  2479.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
  2480.             {
  2481.                 $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]));
  2482.             }
  2483.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
  2484.             {
  2485.                 $email $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2486.             }
  2487.             if ($name !== null || $email !== null || $uri !== null)
  2488.             {
  2489.                 $contributors[=new $this->author_class($name$uri$email);
  2490.             }
  2491.         }
  2492.         foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03'contributor'as $contributor)
  2493.         {
  2494.             $name null;
  2495.             $url null;
  2496.             $email null;
  2497.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
  2498.             {
  2499.                 $name $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2500.             }
  2501.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
  2502.             {
  2503.                 $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]));
  2504.             }
  2505.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
  2506.             {
  2507.                 $email $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2508.             }
  2509.             if ($name !== null || $email !== null || $url !== null)
  2510.             {
  2511.                 $contributors[=new $this->author_class($name$url$email);
  2512.             }
  2513.         }
  2514.  
  2515.         if (!empty($contributors))
  2516.         {
  2517.             return SimplePie_Misc::array_unique($contributors);
  2518.         }
  2519.         else
  2520.         {
  2521.             return null;
  2522.         }
  2523.     }
  2524.  
  2525.     function get_link($key 0$rel 'alternate')
  2526.     {
  2527.         $links $this->get_links($rel);
  2528.         if (isset($links[$key]))
  2529.         {
  2530.             return $links[$key];
  2531.         }
  2532.         else
  2533.         {
  2534.             return null;
  2535.         }
  2536.     }
  2537.  
  2538.     /**
  2539.      * Added for parity between the parent-level and the item/entry-level.
  2540.      */
  2541.     function get_permalink()
  2542.     {
  2543.         return $this->get_link(0);
  2544.     }
  2545.  
  2546.     function get_links($rel 'alternate')
  2547.     {
  2548.         if (!isset($this->data['links']))
  2549.         {
  2550.             $this->data['links'array();
  2551.             if ($links $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'link'))
  2552.             {
  2553.                 foreach ($links as $link)
  2554.                 {
  2555.                     if (isset($link['attribs']['']['href']))
  2556.                     {
  2557.                         $link_rel (isset($link['attribs']['']['rel'])) $link['attribs']['']['rel''alternate';
  2558.                         $this->data['links'][$link_rel][$this->sanitize($link['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($link));
  2559.                     }
  2560.                 }
  2561.             }
  2562.             if ($links $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03'link'))
  2563.             {
  2564.                 foreach ($links as $link)
  2565.                 {
  2566.                     if (isset($link['attribs']['']['href']))
  2567.                     {
  2568.                         $link_rel (isset($link['attribs']['']['rel'])) $link['attribs']['']['rel''alternate';
  2569.                         $this->data['links'][$link_rel][$this->sanitize($link['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($link));
  2570.  
  2571.                     }
  2572.                 }
  2573.             }
  2574.             if ($links $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10'link'))
  2575.             {
  2576.                 $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  2577.             }
  2578.             if ($links $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090'link'))
  2579.             {
  2580.                 $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  2581.             }
  2582.             if ($links $this->get_channel_tags('''link'))
  2583.             {
  2584.                 $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  2585.             }
  2586.  
  2587.             $keys array_keys($this->data['links']);
  2588.             foreach ($keys as $key)
  2589.             {
  2590.                 if (SimplePie_Misc::is_isegment_nz_nc($key))
  2591.                 {
  2592.                     if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key]))
  2593.                     {
  2594.                         $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $keyarray_merge($this->data['links'][$key]$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key]);
  2595.                         $this->data['links'][$key=$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key];
  2596.                     }
  2597.                     else
  2598.                     {
  2599.                         $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key=$this->data['links'][$key];
  2600.                     }
  2601.                 }
  2602.                 elseif (substr($key041== SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
  2603.                 {
  2604.                     $this->data['links'][substr($key41)=$this->data['links'][$key];
  2605.                 }
  2606.                 $this->data['links'][$keyarray_unique($this->data['links'][$key]);
  2607.             }
  2608.         }
  2609.  
  2610.         if (isset($this->data['links'][$rel]))
  2611.         {
  2612.             return $this->data['links'][$rel];
  2613.         }
  2614.         else
  2615.         {
  2616.             return null;
  2617.         }
  2618.     }
  2619.  
  2620.     function get_description()
  2621.     {
  2622.         if ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'subtitle'))
  2623.         {
  2624.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_10_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  2625.         }
  2626.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03'tagline'))
  2627.         {
  2628.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_03_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  2629.         }
  2630.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10'description'))
  2631.         {
  2632.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  2633.         }
  2634.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090'description'))
  2635.         {
  2636.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  2637.         }
  2638.         elseif ($return $this->get_channel_tags('''description'))
  2639.         {
  2640.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  2641.         }
  2642.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11'description'))
  2643.         {
  2644.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2645.         }
  2646.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10'description'))
  2647.         {
  2648.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2649.         }
  2650.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES'summary'))
  2651.         {
  2652.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_HTML$this->get_base($return[0]));
  2653.         }
  2654.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES'subtitle'))
  2655.         {
  2656.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_HTML$this->get_base($return[0]));
  2657.         }
  2658.         else
  2659.         {
  2660.             return null;
  2661.         }
  2662.     }
  2663.  
  2664.     function get_copyright()
  2665.     {
  2666.         if ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'rights'))
  2667.         {
  2668.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_10_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  2669.         }
  2670.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03'copyright'))
  2671.         {
  2672.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_03_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  2673.         }
  2674.         elseif ($return $this->get_channel_tags('''copyright'))
  2675.         {
  2676.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2677.         }
  2678.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11'rights'))
  2679.         {
  2680.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2681.         }
  2682.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10'rights'))
  2683.         {
  2684.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2685.         }
  2686.         else
  2687.         {
  2688.             return null;
  2689.         }
  2690.     }
  2691.  
  2692.     function get_language()
  2693.     {
  2694.         if ($return $this->get_channel_tags('''language'))
  2695.         {
  2696.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2697.         }
  2698.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11'language'))
  2699.         {
  2700.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2701.         }
  2702.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10'language'))
  2703.         {
  2704.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2705.         }
  2706.         elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang']))
  2707.         {
  2708.             return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang']SIMPLEPIE_CONSTRUCT_TEXT);
  2709.         }
  2710.         elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang']))
  2711.         {
  2712.             return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang']SIMPLEPIE_CONSTRUCT_TEXT);
  2713.         }
  2714.         elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang']))
  2715.         {
  2716.             return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang']SIMPLEPIE_CONSTRUCT_TEXT);
  2717.         }
  2718.         elseif (isset($this->data['headers']['content-language']))
  2719.         {
  2720.             return $this->sanitize($this->data['headers']['content-language']SIMPLEPIE_CONSTRUCT_TEXT);
  2721.         }
  2722.         else
  2723.         {
  2724.             return null;
  2725.         }
  2726.     }
  2727.  
  2728.     function get_latitude()
  2729.     {
  2730.         if ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO'lat'))
  2731.         {
  2732.             return (float) $return[0]['data'];
  2733.         }
  2734.         elseif (($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/'$return[0]['data']$match))
  2735.         {
  2736.             return (float) $match[1];
  2737.         }
  2738.         else
  2739.         {
  2740.             return null;
  2741.         }
  2742.     }
  2743.  
  2744.     function get_longitude()
  2745.     {
  2746.         if ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO'long'))
  2747.         {
  2748.             return (float) $return[0]['data'];
  2749.         }
  2750.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO'lon'))
  2751.         {
  2752.             return (float) $return[0]['data'];
  2753.         }
  2754.         elseif (($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/'$return[0]['data']$match))
  2755.         {
  2756.             return (float) $match[2];
  2757.         }
  2758.         else
  2759.         {
  2760.             return null;
  2761.         }
  2762.     }
  2763.  
  2764.     function get_image_title()
  2765.     {
  2766.         if ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10'title'))
  2767.         {
  2768.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2769.         }
  2770.         elseif ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090'title'))
  2771.         {
  2772.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2773.         }
  2774.         elseif ($return $this->get_image_tags('''title'))
  2775.         {
  2776.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2777.         }
  2778.         elseif ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_11'title'))
  2779.         {
  2780.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2781.         }
  2782.         elseif ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_10'title'))
  2783.         {
  2784.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  2785.         }
  2786.         else
  2787.         {
  2788.             return null;
  2789.         }
  2790.     }
  2791.  
  2792.     function get_image_url()
  2793.     {
  2794.         if ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES'image'))
  2795.         {
  2796.             return $this->sanitize($return[0]['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI);
  2797.         }
  2798.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'logo'))
  2799.         {
  2800.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  2801.         }
  2802.         elseif ($return $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10'icon'))
  2803.         {
  2804.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  2805.         }
  2806.         elseif ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10'url'))
  2807.         {
  2808.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  2809.         }
  2810.         elseif ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090'url'))
  2811.         {
  2812.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  2813.         }
  2814.         elseif ($return $this->get_image_tags('''url'))
  2815.         {
  2816.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  2817.         }
  2818.         else
  2819.         {
  2820.             return null;
  2821.         }
  2822.     }
  2823.  
  2824.     function get_image_link()
  2825.     {
  2826.         if ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10'link'))
  2827.         {
  2828.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  2829.         }
  2830.         elseif ($return $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090'link'))
  2831.         {
  2832.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  2833.         }
  2834.         elseif ($return $this->get_image_tags('''link'))
  2835.         {
  2836.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  2837.         }
  2838.         else
  2839.         {
  2840.             return null;
  2841.         }
  2842.     }
  2843.  
  2844.     function get_image_width()
  2845.     {
  2846.         if ($return $this->get_image_tags('''width'))
  2847.         {
  2848.             return round($return[0]['data']);
  2849.         }
  2850.         elseif ($this->get_type(SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('''url'))
  2851.         {
  2852.             return 88.0;
  2853.         }
  2854.         else
  2855.         {
  2856.             return null;
  2857.         }
  2858.     }
  2859.  
  2860.     function get_image_height()
  2861.     {
  2862.         if ($return $this->get_image_tags('''height'))
  2863.         {
  2864.             return round($return[0]['data']);
  2865.         }
  2866.         elseif ($this->get_type(SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('''url'))
  2867.         {
  2868.             return 31.0;
  2869.         }
  2870.         else
  2871.         {
  2872.             return null;
  2873.         }
  2874.     }
  2875.  
  2876.     function get_item_quantity($max 0)
  2877.     {
  2878.         $qty count($this->get_items());
  2879.         if ($max == 0)
  2880.         {
  2881.             return $qty;
  2882.         }
  2883.         else
  2884.         {
  2885.             return ($qty $max$max $qty;
  2886.         }
  2887.     }
  2888.  
  2889.     function get_item($key 0)
  2890.     {
  2891.         $items $this->get_items();
  2892.         if (isset($items[$key]))
  2893.         {
  2894.             return $items[$key];
  2895.         }
  2896.         else
  2897.         {
  2898.             return null;
  2899.         }
  2900.     }
  2901.  
  2902.     function get_items($start 0$end 0)
  2903.     {
  2904.         if (!empty($this->multifeed_objects))
  2905.         {
  2906.             return SimplePie::merge_items($this->multifeed_objects$start$end$this->item_limit);
  2907.         }
  2908.         elseif (!isset($this->data['items']))
  2909.         {
  2910.             if ($items $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10'entry'))
  2911.             {
  2912.                 $keys array_keys($items);
  2913.                 foreach ($keys as $key)
  2914.                 {
  2915.                     $this->data['items'][=new $this->item_class($this$items[$key]);
  2916.                 }
  2917.             }
  2918.             if ($items $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03'entry'))
  2919.             {
  2920.                 $keys array_keys($items);
  2921.                 foreach ($keys as $key)
  2922.                 {
  2923.                     $this->data['items'][=new $this->item_class($this$items[$key]);
  2924.                 }
  2925.             }
  2926.             if ($items $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10'item'))
  2927.             {
  2928.                 $keys array_keys($items);
  2929.                 foreach ($keys as $key)
  2930.                 {
  2931.                     $this->data['items'][=new $this->item_class($this$items[$key]);
  2932.                 }
  2933.             }
  2934.             if ($items $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090'item'))
  2935.             {
  2936.                 $keys array_keys($items);
  2937.                 foreach ($keys as $key)
  2938.                 {
  2939.                     $this->data['items'][=new $this->item_class($this$items[$key]);
  2940.                 }
  2941.             }
  2942.             if ($items $this->get_channel_tags('''item'))
  2943.             {
  2944.                 $keys array_keys($items);
  2945.                 foreach ($keys as $key)
  2946.                 {
  2947.                     $this->data['items'][=new $this->item_class($this$items[$key]);
  2948.                 }
  2949.             }
  2950.         }
  2951.  
  2952.         if (!empty($this->data['items']))
  2953.         {
  2954.             // If we want to order it by date, check if all items have a date, and then sort it
  2955.             if ($this->order_by_date)
  2956.             {
  2957.                 if (!isset($this->data['ordered_items']))
  2958.                 {
  2959.                     $do_sort true;
  2960.                     foreach ($this->data['items'as $item)
  2961.                     {
  2962.                         if (!$item->get_date('U'))
  2963.                         {
  2964.                             $do_sort false;
  2965.                             break;
  2966.                         }
  2967.                     }
  2968.                     $item null;
  2969.                     $this->data['ordered_items'$this->data['items'];
  2970.                     if ($do_sort)
  2971.                     {
  2972.                         usort($this->data['ordered_items']array(&$this'sort_items'));
  2973.                     }
  2974.                 }
  2975.                 $items $this->data['ordered_items'];
  2976.             }
  2977.             else
  2978.             {
  2979.                 $items $this->data['items'];
  2980.             }
  2981.  
  2982.             // Slice the data as desired
  2983.             if ($end == 0)
  2984.             {
  2985.                 return array_slice($items$start);
  2986.             }
  2987.             else
  2988.             {
  2989.                 return array_slice($items$start$end);
  2990.             }
  2991.         }
  2992.         else
  2993.         {
  2994.             return array();
  2995.         }
  2996.     }
  2997.  
  2998.     function sort_items($a$b)
  2999.     {
  3000.         return $a->get_date('U'<= $b->get_date('U');
  3001.     }
  3002.  
  3003.     function merge_items($urls$start 0$end 0$limit 0)
  3004.     {
  3005.         if (is_array($urls&& sizeof($urls0)
  3006.         {
  3007.             $items array();
  3008.             foreach ($urls as $arg)
  3009.             {
  3010.                 if (is_a($arg'SimplePie'))
  3011.                 {
  3012.                     $items array_merge($items$arg->get_items(0$limit));
  3013.                 }
  3014.                 else
  3015.                 {
  3016.                     trigger_error('Arguments must be SimplePie objects'E_USER_WARNING);
  3017.                 }
  3018.             }
  3019.  
  3020.             $do_sort true;
  3021.             foreach ($items as $item)
  3022.             {
  3023.                 if (!$item->get_date('U'))
  3024.                 {
  3025.                     $do_sort false;
  3026.                     break;
  3027.                 }
  3028.             }
  3029.             $item null;
  3030.             if ($do_sort)
  3031.             {
  3032.                 usort($itemsarray('SimplePie''sort_items'));
  3033.             }
  3034.  
  3035.             if ($end == 0)
  3036.             {
  3037.                 return array_slice($items$start);
  3038.             }
  3039.             else
  3040.             {
  3041.                 return array_slice($items$start$end);
  3042.             }
  3043.         }
  3044.         else
  3045.         {
  3046.             trigger_error('Cannot merge zero SimplePie objects'E_USER_WARNING);
  3047.             return array();
  3048.         }
  3049.     }
  3050. }
  3051.  
  3052. {
  3053.     var $feed;
  3054.     var $data = array();
  3055.  
  3056.     function SimplePie_Item($feed$data)
  3057.     {
  3058.         $this->feed = $feed;
  3059.         $this->data = $data;
  3060.     }
  3061.  
  3062.     function __toString()
  3063.     {
  3064.         return md5(serialize($this->data));
  3065.     }
  3066.     
  3067.     /**
  3068.      * Remove items that link back to this before destroying this object
  3069.      */
  3070.     function __destruct()
  3071.     {
  3072.         unset($this->feed);
  3073.     }
  3074.  
  3075.     function get_item_tags($namespace$tag)
  3076.     {
  3077.         if (isset($this->data['child'][$namespace][$tag]))
  3078.         {
  3079.             return $this->data['child'][$namespace][$tag];
  3080.         }
  3081.         else
  3082.         {
  3083.             return null;
  3084.         }
  3085.     }
  3086.  
  3087.     function get_base($element array())
  3088.     {
  3089.         return $this->feed->get_base($element);
  3090.     }
  3091.  
  3092.     function sanitize($data$type$base '')
  3093.     {
  3094.         return $this->feed->sanitize($data$type$base);
  3095.     }
  3096.  
  3097.     function get_feed()
  3098.     {
  3099.         return $this->feed;
  3100.     }
  3101.  
  3102.     function get_id($hash false)
  3103.     {
  3104.         if (!$hash)
  3105.         {
  3106.             if ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'id'))
  3107.             {
  3108.                 return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3109.             }
  3110.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'id'))
  3111.             {
  3112.                 return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3113.             }
  3114.             elseif ($return $this->get_item_tags('''guid'))
  3115.             {
  3116.                 return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3117.             }
  3118.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11'identifier'))
  3119.             {
  3120.                 return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3121.             }
  3122.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10'identifier'))
  3123.             {
  3124.                 return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3125.             }
  3126.             elseif (($return $this->get_permalink()) !== null)
  3127.             {
  3128.                 return $return;
  3129.             }
  3130.             elseif (($return $this->get_title()) !== null)
  3131.             {
  3132.                 return $return;
  3133.             }
  3134.         }
  3135.         if ($this->get_permalink(!== null || $this->get_title(!== null)
  3136.         {
  3137.             return md5($this->get_permalink($this->get_title());
  3138.         }
  3139.         else
  3140.         {
  3141.             return md5(serialize($this->data));
  3142.         }
  3143.     }
  3144.  
  3145.     function get_title()
  3146.     {
  3147.         if (!isset($this->data['title']))
  3148.         {
  3149.             if ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'title'))
  3150.             {
  3151.                 $this->data['title'$this->sanitize($return[0]['data']SimplePie_Misc::atom_10_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  3152.             }
  3153.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'title'))
  3154.             {
  3155.                 $this->data['title'$this->sanitize($return[0]['data']SimplePie_Misc::atom_03_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  3156.             }
  3157.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10'title'))
  3158.             {
  3159.                 $this->data['title'$this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  3160.             }
  3161.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090'title'))
  3162.             {
  3163.                 $this->data['title'$this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  3164.             }
  3165.             elseif ($return $this->get_item_tags('''title'))
  3166.             {
  3167.                 $this->data['title'$this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  3168.             }
  3169.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11'title'))
  3170.             {
  3171.                 $this->data['title'$this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3172.             }
  3173.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10'title'))
  3174.             {
  3175.                 $this->data['title'$this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3176.             }
  3177.             else
  3178.             {
  3179.                 $this->data['title'null;
  3180.             }
  3181.         }
  3182.         return $this->data['title'];
  3183.     }
  3184.  
  3185.     function get_description($description_only false)
  3186.     {
  3187.         if ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'summary'))
  3188.         {
  3189.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_10_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  3190.         }
  3191.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'summary'))
  3192.         {
  3193.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_03_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  3194.         }
  3195.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10'description'))
  3196.         {
  3197.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  3198.         }
  3199.         elseif ($return $this->get_item_tags('''description'))
  3200.         {
  3201.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_HTML$this->get_base($return[0]));
  3202.         }
  3203.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11'description'))
  3204.         {
  3205.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3206.         }
  3207.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10'description'))
  3208.         {
  3209.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3210.         }
  3211.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES'summary'))
  3212.         {
  3213.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_HTML$this->get_base($return[0]));
  3214.         }
  3215.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES'subtitle'))
  3216.         {
  3217.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3218.         }
  3219.         elseif (!$description_only)
  3220.         {
  3221.             return $this->get_content(true);
  3222.         }
  3223.         else
  3224.         {
  3225.             return null;
  3226.         }
  3227.     }
  3228.  
  3229.     function get_content($content_only false)
  3230.     {
  3231.         if ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'content'))
  3232.         {
  3233.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_10_content_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  3234.         }
  3235.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'content'))
  3236.         {
  3237.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_03_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  3238.         }
  3239.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT'encoded'))
  3240.         {
  3241.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_HTML$this->get_base($return[0]));
  3242.         }
  3243.         elseif (!$content_only)
  3244.         {
  3245.             return $this->get_description(true);
  3246.         }
  3247.         else
  3248.         {
  3249.             return null;
  3250.         }
  3251.     }
  3252.  
  3253.     function get_category($key 0)
  3254.     {
  3255.         $categories $this->get_categories();
  3256.         if (isset($categories[$key]))
  3257.         {
  3258.             return $categories[$key];
  3259.         }
  3260.         else
  3261.         {
  3262.             return null;
  3263.         }
  3264.     }
  3265.  
  3266.     function get_categories()
  3267.     {
  3268.         $categories array();
  3269.  
  3270.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'category'as $category)
  3271.         {
  3272.             $term null;
  3273.             $scheme null;
  3274.             $label null;
  3275.             if (isset($category['attribs']['']['term']))
  3276.             {
  3277.                 $term $this->sanitize($category['attribs']['']['term']SIMPLEPIE_CONSTRUCT_TEXT);
  3278.             }
  3279.             if (isset($category['attribs']['']['scheme']))
  3280.             {
  3281.                 $scheme $this->sanitize($category['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  3282.             }
  3283.             if (isset($category['attribs']['']['label']))
  3284.             {
  3285.                 $label $this->sanitize($category['attribs']['']['label']SIMPLEPIE_CONSTRUCT_TEXT);
  3286.             }
  3287.             $categories[=new $this->feed->category_class($term$scheme$label);
  3288.         }
  3289.         foreach ((array) $this->get_item_tags('''category'as $category)
  3290.         {
  3291.             $categories[=new $this->feed->category_class($this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  3292.         }
  3293.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11'subject'as $category)
  3294.         {
  3295.             $categories[=new $this->feed->category_class($this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  3296.         }
  3297.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10'subject'as $category)
  3298.         {
  3299.             $categories[=new $this->feed->category_class($this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  3300.         }
  3301.  
  3302.         if (!empty($categories))
  3303.         {
  3304.             return SimplePie_Misc::array_unique($categories);
  3305.         }
  3306.         else
  3307.         {
  3308.             return null;
  3309.         }
  3310.     }
  3311.  
  3312.     function get_author($key 0)
  3313.     {
  3314.         $authors $this->get_authors();
  3315.         if (isset($authors[$key]))
  3316.         {
  3317.             return $authors[$key];
  3318.         }
  3319.         else
  3320.         {
  3321.             return null;
  3322.         }
  3323.     }
  3324.  
  3325.     function get_contributor($key 0)
  3326.     {
  3327.         $contributors $this->get_contributors();
  3328.         if (isset($contributors[$key]))
  3329.         {
  3330.             return $contributors[$key];
  3331.         }
  3332.         else
  3333.         {
  3334.             return null;
  3335.         }
  3336.     }
  3337.  
  3338.     function get_contributors()
  3339.     {
  3340.         $contributors array();
  3341.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'contributor'as $contributor)
  3342.         {
  3343.             $name null;
  3344.             $uri null;
  3345.             $email null;
  3346.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
  3347.             {
  3348.                 $name $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3349.             }
  3350.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
  3351.             {
  3352.                 $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]));
  3353.             }
  3354.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
  3355.             {
  3356.                 $email $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3357.             }
  3358.             if ($name !== null || $email !== null || $uri !== null)
  3359.             {
  3360.                 $contributors[=new $this->feed->author_class($name$uri$email);
  3361.             }
  3362.         }
  3363.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'contributor'as $contributor)
  3364.         {
  3365.             $name null;
  3366.             $url null;
  3367.             $email null;
  3368.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
  3369.             {
  3370.                 $name $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3371.             }
  3372.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
  3373.             {
  3374.                 $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]));
  3375.             }
  3376.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
  3377.             {
  3378.                 $email $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3379.             }
  3380.             if ($name !== null || $email !== null || $url !== null)
  3381.             {
  3382.                 $contributors[=new $this->feed->author_class($name$url$email);
  3383.             }
  3384.         }
  3385.  
  3386.         if (!empty($contributors))
  3387.         {
  3388.             return SimplePie_Misc::array_unique($contributors);
  3389.         }
  3390.         else
  3391.         {
  3392.             return null;
  3393.         }
  3394.     }
  3395.  
  3396.     /**
  3397.      * @todo Atom inheritance (item author, source author, feed author)
  3398.      */
  3399.     function get_authors()
  3400.     {
  3401.         $authors array();
  3402.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'author'as $author)
  3403.         {
  3404.             $name null;
  3405.             $uri null;
  3406.             $email null;
  3407.             if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
  3408.             {
  3409.                 $name $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3410.             }
  3411.             if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
  3412.             {
  3413.                 $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]));
  3414.             }
  3415.             if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
  3416.             {
  3417.                 $email $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3418.             }
  3419.             if ($name !== null || $email !== null || $uri !== null)
  3420.             {
  3421.                 $authors[=new $this->feed->author_class($name$uri$email);
  3422.             }
  3423.         }
  3424.         if ($author $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'author'))
  3425.         {
  3426.             $name null;
  3427.             $url null;
  3428.             $email null;
  3429.             if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
  3430.             {
  3431.                 $name $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3432.             }
  3433.             if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
  3434.             {
  3435.                 $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]));
  3436.             }
  3437.             if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
  3438.             {
  3439.                 $email $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3440.             }
  3441.             if ($name !== null || $email !== null || $url !== null)
  3442.             {
  3443.                 $authors[=new $this->feed->author_class($name$url$email);
  3444.             }
  3445.         }
  3446.         if ($author $this->get_item_tags('''author'))
  3447.         {
  3448.             $authors[=new $this->feed->author_class(nullnull$this->sanitize($author[0]['data']SIMPLEPIE_CONSTRUCT_TEXT));
  3449.         }
  3450.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11'creator'as $author)
  3451.         {
  3452.             $authors[=new $this->feed->author_class($this->sanitize($author['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  3453.         }
  3454.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10'creator'as $author)
  3455.         {
  3456.             $authors[=new $this->feed->author_class($this->sanitize($author['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  3457.         }
  3458.         foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES'author'as $author)
  3459.         {
  3460.             $authors[=new $this->feed->author_class($this->sanitize($author['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  3461.         }
  3462.  
  3463.         if (!empty($authors))
  3464.         {
  3465.             return SimplePie_Misc::array_unique($authors);
  3466.         }
  3467.         elseif (($source $this->get_source()) && ($authors $source->get_authors()))
  3468.         {
  3469.             return $authors;
  3470.         }
  3471.         elseif ($authors $this->feed->get_authors())
  3472.         {
  3473.             return $authors;
  3474.         }
  3475.         else
  3476.         {
  3477.             return null;
  3478.         }
  3479.     }
  3480.  
  3481.     function get_copyright()
  3482.     {
  3483.         if ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'rights'))
  3484.         {
  3485.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_10_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  3486.         }
  3487.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11'rights'))
  3488.         {
  3489.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3490.         }
  3491.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10'rights'))
  3492.         {
  3493.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3494.         }
  3495.         else
  3496.         {
  3497.             return null;
  3498.         }
  3499.     }
  3500.  
  3501.     function get_date($date_format 'j F Y, g:i a')
  3502.     {
  3503.         if (!isset($this->data['date']))
  3504.         {
  3505.             if ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'published'))
  3506.             {
  3507.                 $this->data['date']['raw'$return[0]['data'];
  3508.             }
  3509.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'updated'))
  3510.             {
  3511.                 $this->data['date']['raw'$return[0]['data'];
  3512.             }
  3513.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'issued'))
  3514.             {
  3515.                 $this->data['date']['raw'$return[0]['data'];
  3516.             }
  3517.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'created'))
  3518.             {
  3519.                 $this->data['date']['raw'$return[0]['data'];
  3520.             }
  3521.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'modified'))
  3522.             {
  3523.                 $this->data['date']['raw'$return[0]['data'];
  3524.             }
  3525.             elseif ($return $this->get_item_tags('''pubDate'))
  3526.             {
  3527.                 $this->data['date']['raw'$return[0]['data'];
  3528.             }
  3529.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11'date'))
  3530.             {
  3531.                 $this->data['date']['raw'$return[0]['data'];
  3532.             }
  3533.             elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10'date'))
  3534.             {
  3535.                 $this->data['date']['raw'$return[0]['data'];
  3536.             }
  3537.  
  3538.             if (!empty($this->data['date']['raw']))
  3539.             {
  3540.                 $parser SimplePie_Parse_Date::get();
  3541.                 $this->data['date']['parsed'$parser->parse($this->data['date']['raw']);
  3542.             }
  3543.             else
  3544.             {
  3545.                 $this->data['date'null;
  3546.             }
  3547.         }
  3548.         if ($this->data['date'])
  3549.         {
  3550.             $date_format = (string) $date_format;
  3551.             switch ($date_format)
  3552.             {
  3553.                 case '':
  3554.                     return $this->sanitize($this->data['date']['raw']SIMPLEPIE_CONSTRUCT_TEXT);
  3555.  
  3556.                 case 'U':
  3557.                     return $this->data['date']['parsed'];
  3558.  
  3559.                 default:
  3560.                     return date($date_format$this->data['date']['parsed']);
  3561.             }
  3562.         }
  3563.         else
  3564.         {
  3565.             return null;
  3566.         }
  3567.     }
  3568.  
  3569.     function get_local_date($date_format '%c')
  3570.     {
  3571.         if (!$date_format)
  3572.         {
  3573.             return $this->sanitize($this->get_date('')SIMPLEPIE_CONSTRUCT_TEXT);
  3574.         }
  3575.         elseif (($date $this->get_date('U')) !== null)
  3576.         {
  3577.             return strftime($date_format$date);
  3578.         }
  3579.         else
  3580.         {
  3581.             return null;
  3582.         }
  3583.     }
  3584.  
  3585.     function get_permalink()
  3586.     {
  3587.         $link $this->get_link();
  3588.         $enclosure $this->get_enclosure(0);
  3589.         if ($link !== null)
  3590.         {
  3591.             return $link;
  3592.         }
  3593.         elseif ($enclosure !== null)
  3594.         {
  3595.             return $enclosure->get_link();
  3596.         }
  3597.         else
  3598.         {
  3599.             return null;
  3600.         }
  3601.     }
  3602.  
  3603.     function get_link($key 0$rel 'alternate')
  3604.     {
  3605.         $links $this->get_links($rel);
  3606.         if ($links[$key!== null)
  3607.         {
  3608.             return $links[$key];
  3609.         }
  3610.         else
  3611.         {
  3612.             return null;
  3613.         }
  3614.     }
  3615.  
  3616.     function get_links($rel 'alternate')
  3617.     {
  3618.         if (!isset($this->data['links']))
  3619.         {
  3620.             $this->data['links'array();
  3621.             foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'link'as $link)
  3622.             {
  3623.                 if (isset($link['attribs']['']['href']))
  3624.                 {
  3625.                     $link_rel (isset($link['attribs']['']['rel'])) $link['attribs']['']['rel''alternate';
  3626.                     $this->data['links'][$link_rel][$this->sanitize($link['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($link));
  3627.  
  3628.                 }
  3629.             }
  3630.             foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'link'as $link)
  3631.             {
  3632.                 if (isset($link['attribs']['']['href']))
  3633.                 {
  3634.                     $link_rel (isset($link['attribs']['']['rel'])) $link['attribs']['']['rel''alternate';
  3635.                     $this->data['links'][$link_rel][$this->sanitize($link['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($link));
  3636.                 }
  3637.             }
  3638.             if ($links $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10'link'))
  3639.             {
  3640.                 $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  3641.             }
  3642.             if ($links $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090'link'))
  3643.             {
  3644.                 $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  3645.             }
  3646.             if ($links $this->get_item_tags('''link'))
  3647.             {
  3648.                 $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  3649.             }
  3650.             if ($links $this->get_item_tags('''guid'))
  3651.             {
  3652.                 if (!isset($links[0]['attribs']['']['isPermaLink']|| strtolower(trim($links[0]['attribs']['']['isPermaLink'])) == 'true')
  3653.                 {
  3654.                     $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  3655.                 }
  3656.             }
  3657.  
  3658.             $keys array_keys($this->data['links']);
  3659.             foreach ($keys as $key)
  3660.             {
  3661.                 if (SimplePie_Misc::is_isegment_nz_nc($key))
  3662.                 {
  3663.                     if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key]))
  3664.                     {
  3665.                         $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $keyarray_merge($this->data['links'][$key]$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key]);
  3666.                         $this->data['links'][$key=$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key];
  3667.                     }
  3668.                     else
  3669.                     {
  3670.                         $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key=$this->data['links'][$key];
  3671.                     }
  3672.                 }
  3673.                 elseif (substr($key041== SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
  3674.                 {
  3675.                     $this->data['links'][substr($key41)=$this->data['links'][$key];
  3676.                 }
  3677.                 $this->data['links'][$keyarray_unique($this->data['links'][$key]);
  3678.             }
  3679.         }
  3680.         if (isset($this->data['links'][$rel]))
  3681.         {
  3682.             return $this->data['links'][$rel];
  3683.         }
  3684.         else
  3685.         {
  3686.             return null;
  3687.         }
  3688.     }
  3689.  
  3690.     /**
  3691.      * @todo Add ability to prefer one type of content over another (in a media group).
  3692.      */
  3693.     function get_enclosure($key 0$prefer null)
  3694.     {
  3695.         $enclosures $this->get_enclosures();
  3696.         if (isset($enclosures[$key]))
  3697.         {
  3698.             return $enclosures[$key];
  3699.         }
  3700.         else
  3701.         {
  3702.             return null;
  3703.         }
  3704.     }
  3705.  
  3706.     /**
  3707.      * Grabs all available enclosures (podcasts, etc.)
  3708.      *
  3709.      * Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS.
  3710.      *
  3711.      * 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.
  3712.      *
  3713.      * @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4).
  3714.      * @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).
  3715.      */
  3716.     function get_enclosures()
  3717.     {
  3718.         if (!isset($this->data['enclosures']))
  3719.         {
  3720.             $this->data['enclosures'array();
  3721.  
  3722.             // Elements
  3723.             $captions_parent null;
  3724.             $categories_parent null;
  3725.             $copyrights_parent null;
  3726.             $credits_parent null;
  3727.             $description_parent null;
  3728.             $duration_parent null;
  3729.             $hashes_parent null;
  3730.             $keywords_parent null;
  3731.             $player_parent null;
  3732.             $ratings_parent null;
  3733.             $restrictions_parent null;
  3734.             $thumbnails_parent null;
  3735.             $title_parent null;
  3736.  
  3737.             // Let's do the channel and item-level ones first, and just re-use them if we need to.
  3738.             $parent $this->get_feed();
  3739.  
  3740.             // CAPTIONS
  3741.             if ($captions $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'text'))
  3742.             {
  3743.                 foreach ($captions as $caption)
  3744.                 {
  3745.                     $caption_type null;
  3746.                     $caption_lang null;
  3747.                     $caption_startTime null;
  3748.                     $caption_endTime null;
  3749.                     $caption_text null;
  3750.                     if (isset($caption['attribs']['']['type']))
  3751.                     {
  3752.                         $caption_type $this->sanitize($caption['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  3753.                     }
  3754.                     if (isset($caption['attribs']['']['lang']))
  3755.                     {
  3756.                         $caption_lang $this->sanitize($caption['attribs']['']['lang']SIMPLEPIE_CONSTRUCT_TEXT);
  3757.                     }
  3758.                     if (isset($caption['attribs']['']['start']))
  3759.                     {
  3760.                         $caption_startTime $this->sanitize($caption['attribs']['']['start']SIMPLEPIE_CONSTRUCT_TEXT);
  3761.                     }
  3762.                     if (isset($caption['attribs']['']['end']))
  3763.                     {
  3764.                         $caption_endTime $this->sanitize($caption['attribs']['']['end']SIMPLEPIE_CONSTRUCT_TEXT);
  3765.                     }
  3766.                     if (isset($caption['data']))
  3767.                     {
  3768.                         $caption_text $this->sanitize($caption['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3769.                     }
  3770.                     $captions_parent[=new $this->feed->caption_class($caption_type$caption_lang$caption_startTime$caption_endTime$caption_text);
  3771.                 }
  3772.             }
  3773.             elseif ($captions $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'text'))
  3774.             {
  3775.                 foreach ($captions as $caption)
  3776.                 {
  3777.                     $caption_type null;
  3778.                     $caption_lang null;
  3779.                     $caption_startTime null;
  3780.                     $caption_endTime null;
  3781.                     $caption_text null;
  3782.                     if (isset($caption['attribs']['']['type']))
  3783.                     {
  3784.                         $caption_type $this->sanitize($caption['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  3785.                     }
  3786.                     if (isset($caption['attribs']['']['lang']))
  3787.                     {
  3788.                         $caption_lang $this->sanitize($caption['attribs']['']['lang']SIMPLEPIE_CONSTRUCT_TEXT);
  3789.                     }
  3790.                     if (isset($caption['attribs']['']['start']))
  3791.                     {
  3792.                         $caption_startTime $this->sanitize($caption['attribs']['']['start']SIMPLEPIE_CONSTRUCT_TEXT);
  3793.                     }
  3794.                     if (isset($caption['attribs']['']['end']))
  3795.                     {
  3796.                         $caption_endTime $this->sanitize($caption['attribs']['']['end']SIMPLEPIE_CONSTRUCT_TEXT);
  3797.                     }
  3798.                     if (isset($caption['data']))
  3799.                     {
  3800.                         $caption_text $this->sanitize($caption['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3801.                     }
  3802.                     $captions_parent[=new $this->feed->caption_class($caption_type$caption_lang$caption_startTime$caption_endTime$caption_text);
  3803.                 }
  3804.             }
  3805.             if (is_array($captions_parent))
  3806.             {
  3807.                 $captions_parent array_values(SimplePie_Misc::array_unique($captions_parent));
  3808.             }
  3809.  
  3810.             // CATEGORIES
  3811.             foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'category'as $category)
  3812.             {
  3813.                 $term null;
  3814.                 $scheme null;
  3815.                 $label null;
  3816.                 if (isset($category['data']))
  3817.                 {
  3818.                     $term $this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3819.                 }
  3820.                 if (isset($category['attribs']['']['scheme']))
  3821.                 {
  3822.                     $scheme $this->sanitize($category['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  3823.                 }
  3824.                 else
  3825.                 {
  3826.                     $scheme 'http://search.yahoo.com/mrss/category_schema';
  3827.                 }
  3828.                 if (isset($category['attribs']['']['label']))
  3829.                 {
  3830.                     $label $this->sanitize($category['attribs']['']['label']SIMPLEPIE_CONSTRUCT_TEXT);
  3831.                 }
  3832.                 $categories_parent[=new $this->feed->category_class($term$scheme$label);
  3833.             }
  3834.             foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'category'as $category)
  3835.             {
  3836.                 $term null;
  3837.                 $scheme null;
  3838.                 $label null;
  3839.                 if (isset($category['data']))
  3840.                 {
  3841.                     $term $this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3842.                 }
  3843.                 if (isset($category['attribs']['']['scheme']))
  3844.                 {
  3845.                     $scheme $this->sanitize($category['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  3846.                 }
  3847.                 else
  3848.                 {
  3849.                     $scheme 'http://search.yahoo.com/mrss/category_schema';
  3850.                 }
  3851.                 if (isset($category['attribs']['']['label']))
  3852.                 {
  3853.                     $label $this->sanitize($category['attribs']['']['label']SIMPLEPIE_CONSTRUCT_TEXT);
  3854.                 }
  3855.                 $categories_parent[=new $this->feed->category_class($term$scheme$label);
  3856.             }
  3857.             foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES'category'as $category)
  3858.             {
  3859.                 $term null;
  3860.                 $scheme 'http://www.itunes.com/dtds/podcast-1.0.dtd';
  3861.                 $label null;
  3862.                 if (isset($category['attribs']['']['text']))
  3863.                 {
  3864.                     $label $this->sanitize($category['attribs']['']['text']SIMPLEPIE_CONSTRUCT_TEXT);
  3865.                 }
  3866.                 $categories_parent[=new $this->feed->category_class($term$scheme$label);
  3867.  
  3868.                 if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category']))
  3869.                 {
  3870.                     foreach ((array) $category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'as $subcategory)
  3871.                     {
  3872.                         if (isset($subcategory['attribs']['']['text']))
  3873.                         {
  3874.                             $label $this->sanitize($subcategory['attribs']['']['text']SIMPLEPIE_CONSTRUCT_TEXT);
  3875.                         }
  3876.                         $categories_parent[=new $this->feed->category_class($term$scheme$label);
  3877.                     }
  3878.                 }
  3879.             }
  3880.             if (is_array($categories_parent))
  3881.             {
  3882.                 $categories_parent array_values(SimplePie_Misc::array_unique($categories_parent));
  3883.             }
  3884.  
  3885.             // COPYRIGHT
  3886.             if ($copyright $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'copyright'))
  3887.             {
  3888.                 $copyright_url null;
  3889.                 $copyright_label null;
  3890.                 if (isset($copyright[0]['attribs']['']['url']))
  3891.                 {
  3892.                     $copyright_url $this->sanitize($copyright[0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_TEXT);
  3893.                 }
  3894.                 if (isset($copyright[0]['data']))
  3895.                 {
  3896.                     $copyright_label $this->sanitize($copyright[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3897.                 }
  3898.                 $copyrights_parent =new $this->feed->copyright_class($copyright_url$copyright_label);
  3899.             }
  3900.             elseif ($copyright $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'copyright'))
  3901.             {
  3902.                 $copyright_url null;
  3903.                 $copyright_label null;
  3904.                 if (isset($copyright[0]['attribs']['']['url']))
  3905.                 {
  3906.                     $copyright_url $this->sanitize($copyright[0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_TEXT);
  3907.                 }
  3908.                 if (isset($copyright[0]['data']))
  3909.                 {
  3910.                     $copyright_label $this->sanitize($copyright[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3911.                 }
  3912.                 $copyrights_parent =new $this->feed->copyright_class($copyright_url$copyright_label);
  3913.             }
  3914.  
  3915.             // CREDITS
  3916.             if ($credits $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'credit'))
  3917.             {
  3918.                 foreach ($credits as $credit)
  3919.                 {
  3920.                     $credit_role null;
  3921.                     $credit_scheme null;
  3922.                     $credit_name null;
  3923.                     if (isset($credit['attribs']['']['role']))
  3924.                     {
  3925.                         $credit_role $this->sanitize($credit['attribs']['']['role']SIMPLEPIE_CONSTRUCT_TEXT);
  3926.                     }
  3927.                     if (isset($credit['attribs']['']['scheme']))
  3928.                     {
  3929.                         $credit_scheme $this->sanitize($credit['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  3930.                     }
  3931.                     else
  3932.                     {
  3933.                         $credit_scheme 'urn:ebu';
  3934.                     }
  3935.                     if (isset($credit['data']))
  3936.                     {
  3937.                         $credit_name $this->sanitize($credit['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3938.                     }
  3939.                     $credits_parent[=new $this->feed->credit_class($credit_role$credit_scheme$credit_name);
  3940.                 }
  3941.             }
  3942.             elseif ($credits $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'credit'))
  3943.             {
  3944.                 foreach ($credits as $credit)
  3945.                 {
  3946.                     $credit_role null;
  3947.                     $credit_scheme null;
  3948.                     $credit_name null;
  3949.                     if (isset($credit['attribs']['']['role']))
  3950.                     {
  3951.                         $credit_role $this->sanitize($credit['attribs']['']['role']SIMPLEPIE_CONSTRUCT_TEXT);
  3952.                     }
  3953.                     if (isset($credit['attribs']['']['scheme']))
  3954.                     {
  3955.                         $credit_scheme $this->sanitize($credit['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  3956.                     }
  3957.                     else
  3958.                     {
  3959.                         $credit_scheme 'urn:ebu';
  3960.                     }
  3961.                     if (isset($credit['data']))
  3962.                     {
  3963.                         $credit_name $this->sanitize($credit['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3964.                     }
  3965.                     $credits_parent[=new $this->feed->credit_class($credit_role$credit_scheme$credit_name);
  3966.                 }
  3967.             }
  3968.             if (is_array($credits_parent))
  3969.             {
  3970.                 $credits_parent array_values(SimplePie_Misc::array_unique($credits_parent));
  3971.             }
  3972.  
  3973.             // DESCRIPTION
  3974.             if ($description_parent $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'description'))
  3975.             {
  3976.                 if (isset($description_parent[0]['data']))
  3977.                 {
  3978.                     $description_parent $this->sanitize($description_parent[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3979.                 }
  3980.             }
  3981.             elseif ($description_parent $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'description'))
  3982.             {
  3983.                 if (isset($description_parent[0]['data']))
  3984.                 {
  3985.                     $description_parent $this->sanitize($description_parent[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  3986.                 }
  3987.             }
  3988.  
  3989.             // DURATION
  3990.             if ($duration_parent $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES'duration'))
  3991.             {
  3992.                 $seconds null;
  3993.                 $minutes null;
  3994.                 $hours null;
  3995.                 if (isset($duration_parent[0]['data']))
  3996.                 {
  3997.                     $temp explode(':'$this->sanitize($duration_parent[0]['data']SIMPLEPIE_CONSTRUCT_TEXT));
  3998.                     if (sizeof($temp0)
  3999.                     {
  4000.                         (int) $seconds array_pop($temp);
  4001.                     }
  4002.                     if (sizeof($temp0)
  4003.                     {
  4004.                         (int) $minutes array_pop($temp);
  4005.                         $seconds += $minutes 60;
  4006.                     }
  4007.                     if (sizeof($temp0)
  4008.                     {
  4009.                         (int) $hours array_pop($temp);
  4010.                         $seconds += $hours 3600;
  4011.                     }
  4012.                     unset($temp);
  4013.                     $duration_parent $seconds;
  4014.                 }
  4015.             }
  4016.  
  4017.             // HASHES
  4018.             if ($hashes_iterator $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'hash'))
  4019.             {
  4020.                 foreach ($hashes_iterator as $hash)
  4021.                 {
  4022.                     $value null;
  4023.                     $algo null;
  4024.                     if (isset($hash['data']))
  4025.                     {
  4026.                         $value $this->sanitize($hash['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4027.                     }
  4028.                     if (isset($hash['attribs']['']['algo']))
  4029.                     {
  4030.                         $algo $this->sanitize($hash['attribs']['']['algo']SIMPLEPIE_CONSTRUCT_TEXT);
  4031.                     }
  4032.                     else
  4033.                     {
  4034.                         $algo 'md5';
  4035.                     }
  4036.                     $hashes_parent[$algo.':'.$value;
  4037.                 }
  4038.             }
  4039.             elseif ($hashes_iterator $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'hash'))
  4040.             {
  4041.                 foreach ($hashes_iterator as $hash)
  4042.                 {
  4043.                     $value null;
  4044.                     $algo null;
  4045.                     if (isset($hash['data']))
  4046.                     {
  4047.                         $value $this->sanitize($hash['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4048.                     }
  4049.                     if (isset($hash['attribs']['']['algo']))
  4050.                     {
  4051.                         $algo $this->sanitize($hash['attribs']['']['algo']SIMPLEPIE_CONSTRUCT_TEXT);
  4052.                     }
  4053.                     else
  4054.                     {
  4055.                         $algo 'md5';
  4056.                     }
  4057.                     $hashes_parent[$algo.':'.$value;
  4058.                 }
  4059.             }
  4060.             if (is_array($hashes_parent))
  4061.             {
  4062.                 $hashes_parent array_values(SimplePie_Misc::array_unique($hashes_parent));
  4063.             }
  4064.  
  4065.             // KEYWORDS
  4066.             if ($keywords $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'keywords'))
  4067.             {
  4068.                 if (isset($keywords[0]['data']))
  4069.                 {
  4070.                     $temp explode(','$this->sanitize($keywords[0]['data']SIMPLEPIE_CONSTRUCT_TEXT));
  4071.                     foreach ($temp as $word)
  4072.                     {
  4073.                         $keywords_parent[trim($word);
  4074.                     }
  4075.                 }
  4076.                 unset($temp);
  4077.             }
  4078.             elseif ($keywords $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES'keywords'))
  4079.             {
  4080.                 if (isset($keywords[0]['data']))
  4081.                 {
  4082.                     $temp explode(','$this->sanitize($keywords[0]['data']SIMPLEPIE_CONSTRUCT_TEXT));
  4083.                     foreach ($temp as $word)
  4084.                     {
  4085.                         $keywords_parent[trim($word);
  4086.                     }
  4087.                 }
  4088.                 unset($temp);
  4089.             }
  4090.             elseif ($keywords $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'keywords'))
  4091.             {
  4092.                 if (isset($keywords[0]['data']))
  4093.                 {
  4094.                     $temp explode(','$this->sanitize($keywords[0]['data']SIMPLEPIE_CONSTRUCT_TEXT));
  4095.                     foreach ($temp as $word)
  4096.                     {
  4097.                         $keywords_parent[trim($word);
  4098.                     }
  4099.                 }
  4100.                 unset($temp);
  4101.             }
  4102.             elseif ($keywords $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES'keywords'))
  4103.             {
  4104.                 if (isset($keywords[0]['data']))
  4105.                 {
  4106.                     $temp explode(','$this->sanitize($keywords[0]['data']SIMPLEPIE_CONSTRUCT_TEXT));
  4107.                     foreach ($temp as $word)
  4108.                     {
  4109.                         $keywords_parent[trim($word);
  4110.                     }
  4111.                 }
  4112.                 unset($temp);
  4113.             }
  4114.             if (is_array($keywords_parent))
  4115.             {
  4116.                 $keywords_parent array_values(SimplePie_Misc::array_unique($keywords_parent));
  4117.             }
  4118.  
  4119.             // PLAYER
  4120.             if ($player_parent $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'player'))
  4121.             {
  4122.                 if (isset($player_parent[0]['attribs']['']['url']))
  4123.                 {
  4124.                     $player_parent $this->sanitize($player_parent[0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  4125.                 }
  4126.             }
  4127.             elseif ($player_parent $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'player'))
  4128.             {
  4129.                 if (isset($player_parent[0]['attribs']['']['url']))
  4130.                 {
  4131.                     $player_parent $this->sanitize($player_parent[0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  4132.                 }
  4133.             }
  4134.  
  4135.             // RATINGS
  4136.             if ($ratings $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'rating'))
  4137.             {
  4138.                 foreach ($ratings as $rating)
  4139.                 {
  4140.                     $rating_scheme null;
  4141.                     $rating_value null;
  4142.                     if (isset($rating['attribs']['']['scheme']))
  4143.                     {
  4144.                         $rating_scheme $this->sanitize($rating['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  4145.                     }
  4146.                     else
  4147.                     {
  4148.                         $rating_scheme 'urn:simple';
  4149.                     }
  4150.                     if (isset($rating['data']))
  4151.                     {
  4152.                         $rating_value $this->sanitize($rating['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4153.                     }
  4154.                     $ratings_parent[=new $this->feed->rating_class($rating_scheme$rating_value);
  4155.                 }
  4156.             }
  4157.             elseif ($ratings $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES'explicit'))
  4158.             {
  4159.                 foreach ($ratings as $rating)
  4160.                 {
  4161.                     $rating_scheme 'urn:itunes';
  4162.                     $rating_value null;
  4163.                     if (isset($rating['data']))
  4164.                     {
  4165.                         $rating_value $this->sanitize($rating['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4166.                     }
  4167.                     $ratings_parent[=new $this->feed->rating_class($rating_scheme$rating_value);
  4168.                 }
  4169.             }
  4170.             elseif ($ratings $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'rating'))
  4171.             {
  4172.                 foreach ($ratings as $rating)
  4173.                 {
  4174.                     $rating_scheme null;
  4175.                     $rating_value null;
  4176.                     if (isset($rating['attribs']['']['scheme']))
  4177.                     {
  4178.                         $rating_scheme $this->sanitize($rating['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  4179.                     }
  4180.                     else
  4181.                     {
  4182.                         $rating_scheme 'urn:simple';
  4183.                     }
  4184.                     if (isset($rating['data']))
  4185.                     {
  4186.                         $rating_value $this->sanitize($rating['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4187.                     }
  4188.                     $ratings_parent[=new $this->feed->rating_class($rating_scheme$rating_value);
  4189.                 }
  4190.             }
  4191.             elseif ($ratings $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES'explicit'))
  4192.             {
  4193.                 foreach ($ratings as $rating)
  4194.                 {
  4195.                     $rating_scheme 'urn:itunes';
  4196.                     $rating_value null;
  4197.                     if (isset($rating['data']))
  4198.                     {
  4199.                         $rating_value $this->sanitize($rating['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4200.                     }
  4201.                     $ratings_parent[=new $this->feed->rating_class($rating_scheme$rating_value);
  4202.                 }
  4203.             }
  4204.             if (is_array($ratings_parent))
  4205.             {
  4206.                 $ratings_parent array_values(SimplePie_Misc::array_unique($ratings_parent));
  4207.             }
  4208.  
  4209.             // RESTRICTIONS
  4210.             if ($restrictions $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'restriction'))
  4211.             {
  4212.                 foreach ($restrictions as $restriction)
  4213.                 {
  4214.                     $restriction_relationship null;
  4215.                     $restriction_type null;
  4216.                     $restriction_value null;
  4217.                     if (isset($restriction['attribs']['']['relationship']))
  4218.                     {
  4219.                         $restriction_relationship $this->sanitize($restriction['attribs']['']['relationship']SIMPLEPIE_CONSTRUCT_TEXT);
  4220.                     }
  4221.                     if (isset($restriction['attribs']['']['type']))
  4222.                     {
  4223.                         $restriction_type $this->sanitize($restriction['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  4224.                     }
  4225.                     if (isset($restriction['data']))
  4226.                     {
  4227.                         $restriction_value $this->sanitize($restriction['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4228.                     }
  4229.                     $restrictions_parent[=new $this->feed->restriction_class($restriction_relationship$restriction_type$restriction_value);
  4230.                 }
  4231.             }
  4232.             elseif ($restrictions $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES'block'))
  4233.             {
  4234.                 foreach ($restrictions as $restriction)
  4235.                 {
  4236.                     $restriction_relationship 'allow';
  4237.                     $restriction_type null;
  4238.                     $restriction_value 'itunes';
  4239.                     if (isset($restriction['data']&& strtolower($restriction['data']== 'yes')
  4240.                     {
  4241.                         $restriction_relationship 'deny';
  4242.                     }
  4243.                     $restrictions_parent[=new $this->feed->restriction_class($restriction_relationship$restriction_type$restriction_value);
  4244.                 }
  4245.             }
  4246.             elseif ($restrictions $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'restriction'))
  4247.             {
  4248.                 foreach ($restrictions as $restriction)
  4249.                 {
  4250.                     $restriction_relationship null;
  4251.                     $restriction_type null;
  4252.                     $restriction_value null;
  4253.                     if (isset($restriction['attribs']['']['relationship']))
  4254.                     {
  4255.                         $restriction_relationship $this->sanitize($restriction['attribs']['']['relationship']SIMPLEPIE_CONSTRUCT_TEXT);
  4256.                     }
  4257.                     if (isset($restriction['attribs']['']['type']))
  4258.                     {
  4259.                         $restriction_type $this->sanitize($restriction['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  4260.                     }
  4261.                     if (isset($restriction['data']))
  4262.                     {
  4263.                         $restriction_value $this->sanitize($restriction['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4264.                     }
  4265.                     $restrictions_parent[=new $this->feed->restriction_class($restriction_relationship$restriction_type$restriction_value);
  4266.                 }
  4267.             }
  4268.             elseif ($restrictions $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES'block'))
  4269.             {
  4270.                 foreach ($restrictions as $restriction)
  4271.                 {
  4272.                     $restriction_relationship 'allow';
  4273.                     $restriction_type null;
  4274.                     $restriction_value 'itunes';
  4275.                     if (isset($restriction['data']&& strtolower($restriction['data']== 'yes')
  4276.                     {
  4277.                         $restriction_relationship 'deny';
  4278.                     }
  4279.                     $restrictions_parent[=new $this->feed->restriction_class($restriction_relationship$restriction_type$restriction_value);
  4280.                 }
  4281.             }
  4282.             if (is_array($restrictions_parent))
  4283.             {
  4284.                 $restrictions_parent array_values(SimplePie_Misc::array_unique($restrictions_parent));
  4285.             }
  4286.  
  4287.             // THUMBNAILS
  4288.             if ($thumbnails $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'thumbnail'))
  4289.             {
  4290.                 foreach ($thumbnails as $thumbnail)
  4291.                 {
  4292.                     if (isset($thumbnail['attribs']['']['url']))
  4293.                     {
  4294.                         $thumbnails_parent[$this->sanitize($thumbnail['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  4295.                     }
  4296.                 }
  4297.             }
  4298.             elseif ($thumbnails $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'thumbnail'))
  4299.             {
  4300.                 foreach ($thumbnails as $thumbnail)
  4301.                 {
  4302.                     if (isset($thumbnail['attribs']['']['url']))
  4303.                     {
  4304.                         $thumbnails_parent[$this->sanitize($thumbnail['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  4305.                     }
  4306.                 }
  4307.             }
  4308.  
  4309.             // TITLES
  4310.             if ($title_parent $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'title'))
  4311.             {
  4312.                 if (isset($title_parent[0]['data']))
  4313.                 {
  4314.                     $title_parent $this->sanitize($title_parent[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4315.                 }
  4316.             }
  4317.             elseif ($title_parent $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'title'))
  4318.             {
  4319.                 if (isset($title_parent[0]['data']))
  4320.                 {
  4321.                     $title_parent $this->sanitize($title_parent[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4322.                 }
  4323.             }
  4324.  
  4325.             // Clear the memory
  4326.             unset($parent);
  4327.  
  4328.             // If we have media:group tags, loop through them.
  4329.             foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS'group'as $group)
  4330.             {
  4331.                 // If we have media:content tags, loop through them.
  4332.                 foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'as $content)
  4333.                 {
  4334.                     if (isset($content['attribs']['']['url']))
  4335.                     {
  4336.                         // Attributes
  4337.                         $bitrate null;
  4338.                         $channels null;
  4339.                         $duration null;
  4340.                         $expression null;
  4341.                         $framerate null;
  4342.                         $height null;
  4343.                         $javascript null;
  4344.                         $lang null;
  4345.                         $length null;
  4346.                         $medium null;
  4347.                         $samplingrate null;
  4348.                         $type null;
  4349.                         $url null;
  4350.                         $width null;
  4351.  
  4352.                         // Elements
  4353.                         $captions null;
  4354.                         $categories null;
  4355.                         $copyrights null;
  4356.                         $credits null;
  4357.                         $description null;
  4358.                         $hashes null;
  4359.                         $keywords null;
  4360.                         $player null;
  4361.                         $ratings null;
  4362.                         $restrictions null;
  4363.                         $thumbnails null;
  4364.                         $title null;
  4365.  
  4366.                         // Start checking the attributes of media:content
  4367.                         if (isset($content['attribs']['']['bitrate']))
  4368.                         {
  4369.                             $bitrate $this->sanitize($content['attribs']['']['bitrate']SIMPLEPIE_CONSTRUCT_TEXT);
  4370.                         }
  4371.                         if (isset($content['attribs']['']['channels']))
  4372.                         {
  4373.                             $channels $this->sanitize($content['attribs']['']['channels']SIMPLEPIE_CONSTRUCT_TEXT);
  4374.                         }
  4375.                         if (isset($content['attribs']['']['duration']))
  4376.                         {
  4377.                             $duration $this->sanitize($content['attribs']['']['duration']SIMPLEPIE_CONSTRUCT_TEXT);
  4378.                         }
  4379.                         else
  4380.                         {
  4381.                             $duration $duration_parent;
  4382.                         }
  4383.                         if (isset($content['attribs']['']['expression']))
  4384.                         {
  4385.                             $expression $this->sanitize($content['attribs']['']['expression']SIMPLEPIE_CONSTRUCT_TEXT);
  4386.                         }
  4387.                         if (isset($content['attribs']['']['framerate']))
  4388.                         {
  4389.                             $framerate $this->sanitize($content['attribs']['']['framerate']SIMPLEPIE_CONSTRUCT_TEXT);
  4390.                         }
  4391.                         if (isset($content['attribs']['']['height']))
  4392.                         {
  4393.                             $height $this->sanitize($content['attribs']['']['height']SIMPLEPIE_CONSTRUCT_TEXT);
  4394.                         }
  4395.                         if (isset($content['attribs']['']['lang']))
  4396.                         {
  4397.                             $lang $this->sanitize($content['attribs']['']['lang']SIMPLEPIE_CONSTRUCT_TEXT);
  4398.                         }
  4399.                         if (isset($content['attribs']['']['fileSize']))
  4400.                         {
  4401.                             $length ceil($content['attribs']['']['fileSize']);
  4402.                         }
  4403.                         if (isset($content['attribs']['']['medium']))
  4404.                         {
  4405.                             $medium $this->sanitize($content['attribs']['']['medium']SIMPLEPIE_CONSTRUCT_TEXT);
  4406.                         }
  4407.                         if (isset($content['attribs']['']['samplingrate']))
  4408.                         {
  4409.                             $samplingrate $this->sanitize($content['attribs']['']['samplingrate']SIMPLEPIE_CONSTRUCT_TEXT);
  4410.                         }
  4411.                         if (isset($content['attribs']['']['type']))
  4412.                         {
  4413.                             $type $this->sanitize($content['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  4414.                         }
  4415.                         if (isset($content['attribs']['']['width']))
  4416.                         {
  4417.                             $width $this->sanitize($content['attribs']['']['width']SIMPLEPIE_CONSTRUCT_TEXT);
  4418.                         }
  4419.                         $url $this->sanitize($content['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  4420.  
  4421.                         // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
  4422.  
  4423.                         // CAPTIONS
  4424.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
  4425.                         {
  4426.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'as $caption)
  4427.                             {
  4428.                                 $caption_type null;
  4429.                                 $caption_lang null;
  4430.                                 $caption_startTime null;
  4431.                                 $caption_endTime null;
  4432.                                 $caption_text null;
  4433.                                 if (isset($caption['attribs']['']['type']))
  4434.                                 {
  4435.                                     $caption_type $this->sanitize($caption['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  4436.                                 }
  4437.                                 if (isset($caption['attribs']['']['lang']))
  4438.                                 {
  4439.                                     $caption_lang $this->sanitize($caption['attribs']['']['lang']SIMPLEPIE_CONSTRUCT_TEXT);
  4440.                                 }
  4441.                                 if (isset($caption['attribs']['']['start']))
  4442.                                 {
  4443.                                     $caption_startTime $this->sanitize($caption['attribs']['']['start']SIMPLEPIE_CONSTRUCT_TEXT);
  4444.                                 }
  4445.                                 if (isset($caption['attribs']['']['end']))
  4446.                                 {
  4447.                                     $caption_endTime $this->sanitize($caption['attribs']['']['end']SIMPLEPIE_CONSTRUCT_TEXT);
  4448.                                 }
  4449.                                 if (isset($caption['data']))
  4450.                                 {
  4451.                                     $caption_text $this->sanitize($caption['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4452.                                 }
  4453.                                 $captions[=new $this->feed->caption_class($caption_type$caption_lang$caption_startTime$caption_endTime$caption_text);
  4454.                             }
  4455.                             if (is_array($captions))
  4456.                             {
  4457.                                 $captions array_values(SimplePie_Misc::array_unique($captions));
  4458.                             }
  4459.                         }
  4460.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
  4461.                         {
  4462.                             foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'as $caption)
  4463.                             {
  4464.                                 $caption_type null;
  4465.                                 $caption_lang null;
  4466.                                 $caption_startTime null;
  4467.                                 $caption_endTime null;
  4468.                                 $caption_text null;
  4469.                                 if (isset($caption['attribs']['']['type']))
  4470.                                 {
  4471.                                     $caption_type $this->sanitize($caption['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  4472.                                 }
  4473.                                 if (isset($caption['attribs']['']['lang']))
  4474.                                 {
  4475.                                     $caption_lang $this->sanitize($caption['attribs']['']['lang']SIMPLEPIE_CONSTRUCT_TEXT);
  4476.                                 }
  4477.                                 if (isset($caption['attribs']['']['start']))
  4478.                                 {
  4479.                                     $caption_startTime $this->sanitize($caption['attribs']['']['start']SIMPLEPIE_CONSTRUCT_TEXT);
  4480.                                 }
  4481.                                 if (isset($caption['attribs']['']['end']))
  4482.                                 {
  4483.                                     $caption_endTime $this->sanitize($caption['attribs']['']['end']SIMPLEPIE_CONSTRUCT_TEXT);
  4484.                                 }
  4485.                                 if (isset($caption['data']))
  4486.                                 {
  4487.                                     $caption_text $this->sanitize($caption['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4488.                                 }
  4489.                                 $captions[=new $this->feed->caption_class($caption_type$caption_lang$caption_startTime$caption_endTime$caption_text);
  4490.                             }
  4491.                             if (is_array($captions))
  4492.                             {
  4493.                                 $captions array_values(SimplePie_Misc::array_unique($captions));
  4494.                             }
  4495.                         }
  4496.                         else
  4497.                         {
  4498.                             $captions $captions_parent;
  4499.                         }
  4500.  
  4501.                         // CATEGORIES
  4502.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
  4503.                         {
  4504.                             foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'as $category)
  4505.                             {
  4506.                                 $term null;
  4507.                                 $scheme null;
  4508.                                 $label null;
  4509.                                 if (isset($category['data']))
  4510.                                 {
  4511.                                     $term $this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4512.                                 }
  4513.                                 if (isset($category['attribs']['']['scheme']))
  4514.                                 {
  4515.                                     $scheme $this->sanitize($category['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  4516.                                 }
  4517.                                 else
  4518.                                 {
  4519.                                     $scheme 'http://search.yahoo.com/mrss/category_schema';
  4520.                                 }
  4521.                                 if (isset($category['attribs']['']['label']))
  4522.                                 {
  4523.                                     $label $this->sanitize($category['attribs']['']['label']SIMPLEPIE_CONSTRUCT_TEXT);
  4524.                                 }
  4525.                                 $categories[=new $this->feed->category_class($term$scheme$label);
  4526.                             }
  4527.                         }
  4528.                         if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
  4529.                         {
  4530.                             foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'as $category)
  4531.                             {
  4532.                                 $term null;
  4533.                                 $scheme null;
  4534.                                 $label null;
  4535.                                 if (isset($category['data']))
  4536.                                 {
  4537.                                     $term $this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4538.                                 }
  4539.                                 if (isset($category['attribs']['']['scheme']))
  4540.                                 {
  4541.                                     $scheme $this->sanitize($category['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  4542.                                 }
  4543.                                 else
  4544.                                 {
  4545.                                     $scheme 'http://search.yahoo.com/mrss/category_schema';
  4546.                                 }
  4547.                                 if (isset($category['attribs']['']['label']))
  4548.                                 {
  4549.                                     $label $this->sanitize($category['attribs']['']['label']SIMPLEPIE_CONSTRUCT_TEXT);
  4550.                                 }
  4551.                                 $categories[=new $this->feed->category_class($term$scheme$label);
  4552.                             }
  4553.                         }
  4554.                         if (is_array($categories&& is_array($categories_parent))
  4555.                         {
  4556.                             $categories array_values(SimplePie_Misc::array_unique(array_merge($categories$categories_parent)));
  4557.                         }
  4558.                         elseif (is_array($categories))
  4559.                         {
  4560.                             $categories array_values(SimplePie_Misc::array_unique($categories));
  4561.                         }
  4562.                         elseif (is_array($categories_parent))
  4563.                         {
  4564.                             $categories array_values(SimplePie_Misc::array_unique($categories_parent));
  4565.                         }
  4566.  
  4567.                         // COPYRIGHTS
  4568.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
  4569.                         {
  4570.                             $copyright_url null;
  4571.                             $copyright_label null;
  4572.                             if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
  4573.                             {
  4574.                                 $copyright_url $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_TEXT);
  4575.                             }
  4576.                             if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
  4577.                             {
  4578.                                 $copyright_label $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4579.                             }
  4580.                             $copyrights =new $this->feed->copyright_class($copyright_url$copyright_label);
  4581.                         }
  4582.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
  4583.                         {
  4584.                             $copyright_url null;
  4585.                             $copyright_label null;
  4586.                             if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
  4587.                             {
  4588.                                 $copyright_url $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_TEXT);
  4589.                             }
  4590.                             if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
  4591.                             {
  4592.                                 $copyright_label $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4593.                             }
  4594.                             $copyrights =new $this->feed->copyright_class($copyright_url$copyright_label);
  4595.                         }
  4596.                         else
  4597.                         {
  4598.                             $copyrights $copyrights_parent;
  4599.                         }
  4600.  
  4601.                         // CREDITS
  4602.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
  4603.                         {
  4604.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'as $credit)
  4605.                             {
  4606.                                 $credit_role null;
  4607.                                 $credit_scheme null;
  4608.                                 $credit_name null;
  4609.                                 if (isset($credit['attribs']['']['role']))
  4610.                                 {
  4611.                                     $credit_role $this->sanitize($credit['attribs']['']['role']SIMPLEPIE_CONSTRUCT_TEXT);
  4612.                                 }
  4613.                                 if (isset($credit['attribs']['']['scheme']))
  4614.                                 {
  4615.                                     $credit_scheme $this->sanitize($credit['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  4616.                                 }
  4617.                                 else
  4618.                                 {
  4619.                                     $credit_scheme 'urn:ebu';
  4620.                                 }
  4621.                                 if (isset($credit['data']))
  4622.                                 {
  4623.                                     $credit_name $this->sanitize($credit['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4624.                                 }
  4625.                                 $credits[=new $this->feed->credit_class($credit_role$credit_scheme$credit_name);
  4626.                             }
  4627.                             if (is_array($credits))
  4628.                             {
  4629.                                 $credits array_values(SimplePie_Misc::array_unique($credits));
  4630.                             }
  4631.                         }
  4632.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
  4633.                         {
  4634.                             foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'as $credit)
  4635.                             {
  4636.                                 $credit_role null;
  4637.                                 $credit_scheme null;
  4638.                                 $credit_name null;
  4639.                                 if (isset($credit['attribs']['']['role']))
  4640.                                 {
  4641.                                     $credit_role $this->sanitize($credit['attribs']['']['role']SIMPLEPIE_CONSTRUCT_TEXT);
  4642.                                 }
  4643.                                 if (isset($credit['attribs']['']['scheme']))
  4644.                                 {
  4645.                                     $credit_scheme $this->sanitize($credit['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  4646.                                 }
  4647.                                 else
  4648.                                 {
  4649.                                     $credit_scheme 'urn:ebu';
  4650.                                 }
  4651.                                 if (isset($credit['data']))
  4652.                                 {
  4653.                                     $credit_name $this->sanitize($credit['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4654.                                 }
  4655.                                 $credits[=new $this->feed->credit_class($credit_role$credit_scheme$credit_name);
  4656.                             }
  4657.                             if (is_array($credits))
  4658.                             {
  4659.                                 $credits array_values(SimplePie_Misc::array_unique($credits));
  4660.                             }
  4661.                         }
  4662.                         else
  4663.                         {
  4664.                             $credits $credits_parent;
  4665.                         }
  4666.  
  4667.                         // DESCRIPTION
  4668.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
  4669.                         {
  4670.                             $description $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4671.                         }
  4672.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
  4673.                         {
  4674.                             $description $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4675.                         }
  4676.                         else
  4677.                         {
  4678.                             $description $description_parent;
  4679.                         }
  4680.  
  4681.                         // HASHES
  4682.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
  4683.                         {
  4684.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'as $hash)
  4685.                             {
  4686.                                 $value null;
  4687.                                 $algo null;
  4688.                                 if (isset($hash['data']))
  4689.                                 {
  4690.                                     $value $this->sanitize($hash['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4691.                                 }
  4692.                                 if (isset($hash['attribs']['']['algo']))
  4693.                                 {
  4694.                                     $algo $this->sanitize($hash['attribs']['']['algo']SIMPLEPIE_CONSTRUCT_TEXT);
  4695.                                 }
  4696.                                 else
  4697.                                 {
  4698.                                     $algo 'md5';
  4699.                                 }
  4700.                                 $hashes[$algo.':'.$value;
  4701.                             }
  4702.                             if (is_array($hashes))
  4703.                             {
  4704.                                 $hashes array_values(SimplePie_Misc::array_unique($hashes));
  4705.                             }
  4706.                         }
  4707.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
  4708.                         {
  4709.                             foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'as $hash)
  4710.                             {
  4711.                                 $value null;
  4712.                                 $algo null;
  4713.                                 if (isset($hash['data']))
  4714.                                 {
  4715.                                     $value $this->sanitize($hash['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4716.                                 }
  4717.                                 if (isset($hash['attribs']['']['algo']))
  4718.                                 {
  4719.                                     $algo $this->sanitize($hash['attribs']['']['algo']SIMPLEPIE_CONSTRUCT_TEXT);
  4720.                                 }
  4721.                                 else
  4722.                                 {
  4723.                                     $algo 'md5';
  4724.                                 }
  4725.                                 $hashes[$algo.':'.$value;
  4726.                             }
  4727.                             if (is_array($hashes))
  4728.                             {
  4729.                                 $hashes array_values(SimplePie_Misc::array_unique($hashes));
  4730.                             }
  4731.                         }
  4732.                         else
  4733.                         {
  4734.                             $hashes $hashes_parent;
  4735.                         }
  4736.  
  4737.                         // KEYWORDS
  4738.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
  4739.                         {
  4740.                             if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
  4741.                             {
  4742.                                 $temp explode(','$this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT));
  4743.                                 foreach ($temp as $word)
  4744.                                 {
  4745.                                     $keywords[trim($word);
  4746.                                 }
  4747.                                 unset($temp);
  4748.                             }
  4749.                             if (is_array($keywords))
  4750.                             {
  4751.                                 $keywords array_values(SimplePie_Misc::array_unique($keywords));
  4752.                             }
  4753.                         }
  4754.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
  4755.                         {
  4756.                             if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
  4757.                             {
  4758.                                 $temp explode(','$this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT));
  4759.                                 foreach ($temp as $word)
  4760.                                 {
  4761.                                     $keywords[trim($word);
  4762.                                 }
  4763.                                 unset($temp);
  4764.                             }
  4765.                             if (is_array($keywords))
  4766.                             {
  4767.                                 $keywords array_values(SimplePie_Misc::array_unique($keywords));
  4768.                             }
  4769.                         }
  4770.                         else
  4771.                         {
  4772.                             $keywords $keywords_parent;
  4773.                         }
  4774.  
  4775.                         // PLAYER
  4776.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
  4777.                         {
  4778.                             $player $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  4779.                         }
  4780.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
  4781.                         {
  4782.                             $player $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  4783.                         }
  4784.                         else
  4785.                         {
  4786.                             $player $player_parent;
  4787.                         }
  4788.  
  4789.                         // RATINGS
  4790.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
  4791.                         {
  4792.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'as $rating)
  4793.                             {
  4794.                                 $rating_scheme null;
  4795.                                 $rating_value null;
  4796.                                 if (isset($rating['attribs']['']['scheme']))
  4797.                                 {
  4798.                                     $rating_scheme $this->sanitize($rating['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  4799.                                 }
  4800.                                 else
  4801.                                 {
  4802.                                     $rating_scheme 'urn:simple';
  4803.                                 }
  4804.                                 if (isset($rating['data']))
  4805.                                 {
  4806.                                     $rating_value $this->sanitize($rating['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4807.                                 }
  4808.                                 $ratings[=new $this->feed->rating_class($rating_scheme$rating_value);
  4809.                             }
  4810.                             if (is_array($ratings))
  4811.                             {
  4812.                                 $ratings array_values(SimplePie_Misc::array_unique($ratings));
  4813.                             }
  4814.                         }
  4815.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
  4816.                         {
  4817.                             foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'as $rating)
  4818.                             {
  4819.                                 $rating_scheme null;
  4820.                                 $rating_value null;
  4821.                                 if (isset($rating['attribs']['']['scheme']))
  4822.                                 {
  4823.                                     $rating_scheme $this->sanitize($rating['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  4824.                                 }
  4825.                                 else
  4826.                                 {
  4827.                                     $rating_scheme 'urn:simple';
  4828.                                 }
  4829.                                 if (isset($rating['data']))
  4830.                                 {
  4831.                                     $rating_value $this->sanitize($rating['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4832.                                 }
  4833.                                 $ratings[=new $this->feed->rating_class($rating_scheme$rating_value);
  4834.                             }
  4835.                             if (is_array($ratings))
  4836.                             {
  4837.                                 $ratings array_values(SimplePie_Misc::array_unique($ratings));
  4838.                             }
  4839.                         }
  4840.                         else
  4841.                         {
  4842.                             $ratings $ratings_parent;
  4843.                         }
  4844.  
  4845.                         // RESTRICTIONS
  4846.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
  4847.                         {
  4848.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'as $restriction)
  4849.                             {
  4850.                                 $restriction_relationship null;
  4851.                                 $restriction_type null;
  4852.                                 $restriction_value null;
  4853.                                 if (isset($restriction['attribs']['']['relationship']))
  4854.                                 {
  4855.                                     $restriction_relationship $this->sanitize($restriction['attribs']['']['relationship']SIMPLEPIE_CONSTRUCT_TEXT);
  4856.                                 }
  4857.                                 if (isset($restriction['attribs']['']['type']))
  4858.                                 {
  4859.                                     $restriction_type $this->sanitize($restriction['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  4860.                                 }
  4861.                                 if (isset($restriction['data']))
  4862.                                 {
  4863.                                     $restriction_value $this->sanitize($restriction['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4864.                                 }
  4865.                                 $restrictions[=new $this->feed->restriction_class($restriction_relationship$restriction_type$restriction_value);
  4866.                             }
  4867.                             if (is_array($restrictions))
  4868.                             {
  4869.                                 $restrictions array_values(SimplePie_Misc::array_unique($restrictions));
  4870.                             }
  4871.                         }
  4872.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
  4873.                         {
  4874.                             foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'as $restriction)
  4875.                             {
  4876.                                 $restriction_relationship null;
  4877.                                 $restriction_type null;
  4878.                                 $restriction_value null;
  4879.                                 if (isset($restriction['attribs']['']['relationship']))
  4880.                                 {
  4881.                                     $restriction_relationship $this->sanitize($restriction['attribs']['']['relationship']SIMPLEPIE_CONSTRUCT_TEXT);
  4882.                                 }
  4883.                                 if (isset($restriction['attribs']['']['type']))
  4884.                                 {
  4885.                                     $restriction_type $this->sanitize($restriction['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  4886.                                 }
  4887.                                 if (isset($restriction['data']))
  4888.                                 {
  4889.                                     $restriction_value $this->sanitize($restriction['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4890.                                 }
  4891.                                 $restrictions[=new $this->feed->restriction_class($restriction_relationship$restriction_type$restriction_value);
  4892.                             }
  4893.                             if (is_array($restrictions))
  4894.                             {
  4895.                                 $restrictions array_values(SimplePie_Misc::array_unique($restrictions));
  4896.                             }
  4897.                         }
  4898.                         else
  4899.                         {
  4900.                             $restrictions $restrictions_parent;
  4901.                         }
  4902.  
  4903.                         // THUMBNAILS
  4904.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
  4905.                         {
  4906.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'as $thumbnail)
  4907.                             {
  4908.                                 $thumbnails[$this->sanitize($thumbnail['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  4909.                             }
  4910.                             if (is_array($thumbnails))
  4911.                             {
  4912.                                 $thumbnails array_values(SimplePie_Misc::array_unique($thumbnails));
  4913.                             }
  4914.                         }
  4915.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
  4916.                         {
  4917.                             foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'as $thumbnail)
  4918.                             {
  4919.                                 $thumbnails[$this->sanitize($thumbnail['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  4920.                             }
  4921.                             if (is_array($thumbnails))
  4922.                             {
  4923.                                 $thumbnails array_values(SimplePie_Misc::array_unique($thumbnails));
  4924.                             }
  4925.                         }
  4926.                         else
  4927.                         {
  4928.                             $thumbnails $thumbnails_parent;
  4929.                         }
  4930.  
  4931.                         // TITLES
  4932.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
  4933.                         {
  4934.                             $title $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4935.                         }
  4936.                         elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
  4937.                         {
  4938.                             $title $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  4939.                         }
  4940.                         else
  4941.                         {
  4942.                             $title $title_parent;
  4943.                         }
  4944.  
  4945.                         $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);
  4946.                     }
  4947.                 }
  4948.             }
  4949.  
  4950.             // If we have standalone media:content tags, loop through them.
  4951.             if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
  4952.             {
  4953.                 foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'as $content)
  4954.                 {
  4955.                     if (isset($content['attribs']['']['url']))
  4956.                     {
  4957.                         // Attributes
  4958.                         $bitrate null;
  4959.                         $channels null;
  4960.                         $duration null;
  4961.                         $expression null;
  4962.                         $framerate null;
  4963.                         $height null;
  4964.                         $javascript null;
  4965.                         $lang null;
  4966.                         $length null;
  4967.                         $medium null;
  4968.                         $samplingrate null;
  4969.                         $type null;
  4970.                         $url null;
  4971.                         $width null;
  4972.  
  4973.                         // Elements
  4974.                         $captions null;
  4975.                         $categories null;
  4976.                         $copyrights null;
  4977.                         $credits null;
  4978.                         $description null;
  4979.                         $hashes null;
  4980.                         $keywords null;
  4981.                         $player null;
  4982.                         $ratings null;
  4983.                         $restrictions null;
  4984.                         $thumbnails null;
  4985.                         $title null;
  4986.  
  4987.                         // Start checking the attributes of media:content
  4988.                         if (isset($content['attribs']['']['bitrate']))
  4989.                         {
  4990.                             $bitrate $this->sanitize($content['attribs']['']['bitrate']SIMPLEPIE_CONSTRUCT_TEXT);
  4991.                         }
  4992.                         if (isset($content['attribs']['']['channels']))
  4993.                         {
  4994.                             $channels $this->sanitize($content['attribs']['']['channels']SIMPLEPIE_CONSTRUCT_TEXT);
  4995.                         }
  4996.                         if (isset($content['attribs']['']['duration']))
  4997.                         {
  4998.                             $duration $this->sanitize($content['attribs']['']['duration']SIMPLEPIE_CONSTRUCT_TEXT);
  4999.                         }
  5000.                         else
  5001.                         {
  5002.                             $duration $duration_parent;
  5003.                         }
  5004.                         if (isset($content['attribs']['']['expression']))
  5005.                         {
  5006.                             $expression $this->sanitize($content['attribs']['']['expression']SIMPLEPIE_CONSTRUCT_TEXT);
  5007.                         }
  5008.                         if (isset($content['attribs']['']['framerate']))
  5009.                         {
  5010.                             $framerate $this->sanitize($content['attribs']['']['framerate']SIMPLEPIE_CONSTRUCT_TEXT);
  5011.                         }
  5012.                         if (isset($content['attribs']['']['height']))
  5013.                         {
  5014.                             $height $this->sanitize($content['attribs']['']['height']SIMPLEPIE_CONSTRUCT_TEXT);
  5015.                         }
  5016.                         if (isset($content['attribs']['']['lang']))
  5017.                         {
  5018.                             $lang $this->sanitize($content['attribs']['']['lang']SIMPLEPIE_CONSTRUCT_TEXT);
  5019.                         }
  5020.                         if (isset($content['attribs']['']['fileSize']))
  5021.                         {
  5022.                             $length ceil($content['attribs']['']['fileSize']);
  5023.                         }
  5024.                         if (isset($content['attribs']['']['medium']))
  5025.                         {
  5026.                             $medium $this->sanitize($content['attribs']['']['medium']SIMPLEPIE_CONSTRUCT_TEXT);
  5027.                         }
  5028.                         if (isset($content['attribs']['']['samplingrate']))
  5029.                         {
  5030.                             $samplingrate $this->sanitize($content['attribs']['']['samplingrate']SIMPLEPIE_CONSTRUCT_TEXT);
  5031.                         }
  5032.                         if (isset($content['attribs']['']['type']))
  5033.                         {
  5034.                             $type $this->sanitize($content['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  5035.                         }
  5036.                         if (isset($content['attribs']['']['width']))
  5037.                         {
  5038.                             $width $this->sanitize($content['attribs']['']['width']SIMPLEPIE_CONSTRUCT_TEXT);
  5039.                         }
  5040.                         $url $this->sanitize($content['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  5041.  
  5042.                         // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
  5043.  
  5044.                         // CAPTIONS
  5045.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
  5046.                         {
  5047.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'as $caption)
  5048.                             {
  5049.                                 $caption_type null;
  5050.                                 $caption_lang null;
  5051.                                 $caption_startTime null;
  5052.                                 $caption_endTime null;
  5053.                                 $caption_text null;
  5054.                                 if (isset($caption['attribs']['']['type']))
  5055.                                 {
  5056.                                     $caption_type $this->sanitize($caption['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  5057.                                 }
  5058.                                 if (isset($caption['attribs']['']['lang']))
  5059.                                 {
  5060.                                     $caption_lang $this->sanitize($caption['attribs']['']['lang']SIMPLEPIE_CONSTRUCT_TEXT);
  5061.                                 }
  5062.                                 if (isset($caption['attribs']['']['start']))
  5063.                                 {
  5064.                                     $caption_startTime $this->sanitize($caption['attribs']['']['start']SIMPLEPIE_CONSTRUCT_TEXT);
  5065.                                 }
  5066.                                 if (isset($caption['attribs']['']['end']))
  5067.                                 {
  5068.                                     $caption_endTime $this->sanitize($caption['attribs']['']['end']SIMPLEPIE_CONSTRUCT_TEXT);
  5069.                                 }
  5070.                                 if (isset($caption['data']))
  5071.                                 {
  5072.                                     $caption_text $this->sanitize($caption['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5073.                                 }
  5074.                                 $captions[=new $this->feed->caption_class($caption_type$caption_lang$caption_startTime$caption_endTime$caption_text);
  5075.                             }
  5076.                             if (is_array($captions))
  5077.                             {
  5078.                                 $captions array_values(SimplePie_Misc::array_unique($captions));
  5079.                             }
  5080.                         }
  5081.                         else
  5082.                         {
  5083.                             $captions $captions_parent;
  5084.                         }
  5085.  
  5086.                         // CATEGORIES
  5087.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
  5088.                         {
  5089.                             foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'as $category)
  5090.                             {
  5091.                                 $term null;
  5092.                                 $scheme null;
  5093.                                 $label null;
  5094.                                 if (isset($category['data']))
  5095.                                 {
  5096.                                     $term $this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5097.                                 }
  5098.                                 if (isset($category['attribs']['']['scheme']))
  5099.                                 {
  5100.                                     $scheme $this->sanitize($category['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  5101.                                 }
  5102.                                 else
  5103.                                 {
  5104.                                     $scheme 'http://search.yahoo.com/mrss/category_schema';
  5105.                                 }
  5106.                                 if (isset($category['attribs']['']['label']))
  5107.                                 {
  5108.                                     $label $this->sanitize($category['attribs']['']['label']SIMPLEPIE_CONSTRUCT_TEXT);
  5109.                                 }
  5110.                                 $categories[=new $this->feed->category_class($term$scheme$label);
  5111.                             }
  5112.                         }
  5113.                         if (is_array($categories&& is_array($categories_parent))
  5114.                         {
  5115.                             $categories array_values(SimplePie_Misc::array_unique(array_merge($categories$categories_parent)));
  5116.                         }
  5117.                         elseif (is_array($categories))
  5118.                         {
  5119.                             $categories array_values(SimplePie_Misc::array_unique($categories));
  5120.                         }
  5121.                         elseif (is_array($categories_parent))
  5122.                         {
  5123.                             $categories array_values(SimplePie_Misc::array_unique($categories_parent));
  5124.                         }
  5125.                         else
  5126.                         {
  5127.                             $categories null;
  5128.                         }
  5129.  
  5130.                         // COPYRIGHTS
  5131.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
  5132.                         {
  5133.                             $copyright_url null;
  5134.                             $copyright_label null;
  5135.                             if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
  5136.                             {
  5137.                                 $copyright_url $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_TEXT);
  5138.                             }
  5139.                             if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
  5140.                             {
  5141.                                 $copyright_label $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5142.                             }
  5143.                             $copyrights =new $this->feed->copyright_class($copyright_url$copyright_label);
  5144.                         }
  5145.                         else
  5146.                         {
  5147.                             $copyrights $copyrights_parent;
  5148.                         }
  5149.  
  5150.                         // CREDITS
  5151.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
  5152.                         {
  5153.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'as $credit)
  5154.                             {
  5155.                                 $credit_role null;
  5156.                                 $credit_scheme null;
  5157.                                 $credit_name null;
  5158.                                 if (isset($credit['attribs']['']['role']))
  5159.                                 {
  5160.                                     $credit_role $this->sanitize($credit['attribs']['']['role']SIMPLEPIE_CONSTRUCT_TEXT);
  5161.                                 }
  5162.                                 if (isset($credit['attribs']['']['scheme']))
  5163.                                 {
  5164.                                     $credit_scheme $this->sanitize($credit['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  5165.                                 }
  5166.                                 else
  5167.                                 {
  5168.                                     $credit_scheme 'urn:ebu';
  5169.                                 }
  5170.                                 if (isset($credit['data']))
  5171.                                 {
  5172.                                     $credit_name $this->sanitize($credit['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5173.                                 }
  5174.                                 $credits[=new $this->feed->credit_class($credit_role$credit_scheme$credit_name);
  5175.                             }
  5176.                             if (is_array($credits))
  5177.                             {
  5178.                                 $credits array_values(SimplePie_Misc::array_unique($credits));
  5179.                             }
  5180.                         }
  5181.                         else
  5182.                         {
  5183.                             $credits $credits_parent;
  5184.                         }
  5185.  
  5186.                         // DESCRIPTION
  5187.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
  5188.                         {
  5189.                             $description $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5190.                         }
  5191.                         else
  5192.                         {
  5193.                             $description $description_parent;
  5194.                         }
  5195.  
  5196.                         // HASHES
  5197.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
  5198.                         {
  5199.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'as $hash)
  5200.                             {
  5201.                                 $value null;
  5202.                                 $algo null;
  5203.                                 if (isset($hash['data']))
  5204.                                 {
  5205.                                     $value $this->sanitize($hash['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5206.                                 }
  5207.                                 if (isset($hash['attribs']['']['algo']))
  5208.                                 {
  5209.                                     $algo $this->sanitize($hash['attribs']['']['algo']SIMPLEPIE_CONSTRUCT_TEXT);
  5210.                                 }
  5211.                                 else
  5212.                                 {
  5213.                                     $algo 'md5';
  5214.                                 }
  5215.                                 $hashes[$algo.':'.$value;
  5216.                             }
  5217.                             if (is_array($hashes))
  5218.                             {
  5219.                                 $hashes array_values(SimplePie_Misc::array_unique($hashes));
  5220.                             }
  5221.                         }
  5222.                         else
  5223.                         {
  5224.                             $hashes $hashes_parent;
  5225.                         }
  5226.  
  5227.                         // KEYWORDS
  5228.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
  5229.                         {
  5230.                             if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
  5231.                             {
  5232.                                 $temp explode(','$this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT));
  5233.                                 foreach ($temp as $word)
  5234.                                 {
  5235.                                     $keywords[trim($word);
  5236.                                 }
  5237.                                 unset($temp);
  5238.                             }
  5239.                             if (is_array($keywords))
  5240.                             {
  5241.                                 $keywords array_values(SimplePie_Misc::array_unique($keywords));
  5242.                             }
  5243.                         }
  5244.                         else
  5245.                         {
  5246.                             $keywords $keywords_parent;
  5247.                         }
  5248.  
  5249.                         // PLAYER
  5250.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
  5251.                         {
  5252.                             $player $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  5253.                         }
  5254.                         else
  5255.                         {
  5256.                             $player $player_parent;
  5257.                         }
  5258.  
  5259.                         // RATINGS
  5260.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
  5261.                         {
  5262.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'as $rating)
  5263.                             {
  5264.                                 $rating_scheme null;
  5265.                                 $rating_value null;
  5266.                                 if (isset($rating['attribs']['']['scheme']))
  5267.                                 {
  5268.                                     $rating_scheme $this->sanitize($rating['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  5269.                                 }
  5270.                                 else
  5271.                                 {
  5272.                                     $rating_scheme 'urn:simple';
  5273.                                 }
  5274.                                 if (isset($rating['data']))
  5275.                                 {
  5276.                                     $rating_value $this->sanitize($rating['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5277.                                 }
  5278.                                 $ratings[=new $this->feed->rating_class($rating_scheme$rating_value);
  5279.                             }
  5280.                             if (is_array($ratings))
  5281.                             {
  5282.                                 $ratings array_values(SimplePie_Misc::array_unique($ratings));
  5283.                             }
  5284.                         }
  5285.                         else
  5286.                         {
  5287.                             $ratings $ratings_parent;
  5288.                         }
  5289.  
  5290.                         // RESTRICTIONS
  5291.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
  5292.                         {
  5293.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'as $restriction)
  5294.                             {
  5295.                                 $restriction_relationship null;
  5296.                                 $restriction_type null;
  5297.                                 $restriction_value null;
  5298.                                 if (isset($restriction['attribs']['']['relationship']))
  5299.                                 {
  5300.                                     $restriction_relationship $this->sanitize($restriction['attribs']['']['relationship']SIMPLEPIE_CONSTRUCT_TEXT);
  5301.                                 }
  5302.                                 if (isset($restriction['attribs']['']['type']))
  5303.                                 {
  5304.                                     $restriction_type $this->sanitize($restriction['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  5305.                                 }
  5306.                                 if (isset($restriction['data']))
  5307.                                 {
  5308.                                     $restriction_value $this->sanitize($restriction['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5309.                                 }
  5310.                                 $restrictions[=new $this->feed->restriction_class($restriction_relationship$restriction_type$restriction_value);
  5311.                             }
  5312.                             if (is_array($restrictions))
  5313.                             {
  5314.                                 $restrictions array_values(SimplePie_Misc::array_unique($restrictions));
  5315.                             }
  5316.                         }
  5317.                         else
  5318.                         {
  5319.                             $restrictions $restrictions_parent;
  5320.                         }
  5321.  
  5322.                         // THUMBNAILS
  5323.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
  5324.                         {
  5325.                             foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'as $thumbnail)
  5326.                             {
  5327.                                 $thumbnails[$this->sanitize($thumbnail['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI);
  5328.                             }
  5329.                             if (is_array($thumbnails))
  5330.                             {
  5331.                                 $thumbnails array_values(SimplePie_Misc::array_unique($thumbnails));
  5332.                             }
  5333.                         }
  5334.                         else
  5335.                         {
  5336.                             $thumbnails $thumbnails_parent;
  5337.                         }
  5338.  
  5339.                         // TITLES
  5340.                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
  5341.                         {
  5342.                             $title $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5343.                         }
  5344.                         else
  5345.                         {
  5346.                             $title $title_parent;
  5347.                         }
  5348.  
  5349.                         $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);
  5350.                     }
  5351.                 }
  5352.             }
  5353.  
  5354.             foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'link'as $link)
  5355.             {
  5356.                 if (isset($link['attribs']['']['href']&& !empty($link['attribs']['']['rel']&& $link['attribs']['']['rel'== 'enclosure')
  5357.                 {
  5358.                     // Attributes
  5359.                     $bitrate null;
  5360.                     $channels null;
  5361.                     $duration null;
  5362.                     $expression null;
  5363.                     $framerate null;
  5364.                     $height null;
  5365.                     $javascript null;
  5366.                     $lang null;
  5367.                     $length null;
  5368.                     $medium null;
  5369.                     $samplingrate null;
  5370.                     $type null;
  5371.                     $url null;
  5372.                     $width null;
  5373.  
  5374.                     $url $this->sanitize($link['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($link));
  5375.                     if (isset($link['attribs']['']['type']))
  5376.                     {
  5377.                         $type $this->sanitize($link['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  5378.                     }
  5379.                     if (isset($link['attribs']['']['length']))
  5380.                     {
  5381.                         $length ceil($link['attribs']['']['length']);
  5382.                     }
  5383.  
  5384.                     // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
  5385.                     $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);
  5386.                 }
  5387.             }
  5388.  
  5389.             foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03'link'as $link)
  5390.             {
  5391.                 if (isset($link['attribs']['']['href']&& !empty($link['attribs']['']['rel']&& $link['attribs']['']['rel'== 'enclosure')
  5392.                 {
  5393.                     // Attributes
  5394.                     $bitrate null;
  5395.                     $channels null;
  5396.                     $duration null;
  5397.                     $expression null;
  5398.                     $framerate null;
  5399.                     $height null;
  5400.                     $javascript null;
  5401.                     $lang null;
  5402.                     $length null;
  5403.                     $medium null;
  5404.                     $samplingrate null;
  5405.                     $type null;
  5406.                     $url null;
  5407.                     $width null;
  5408.  
  5409.                     $url $this->sanitize($link['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($link));
  5410.                     if (isset($link['attribs']['']['type']))
  5411.                     {
  5412.                         $type $this->sanitize($link['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  5413.                     }
  5414.                     if (isset($link['attribs']['']['length']))
  5415.                     {
  5416.                         $length ceil($link['attribs']['']['length']);
  5417.                     }
  5418.  
  5419.                     // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
  5420.                     $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);
  5421.                 }
  5422.             }
  5423.  
  5424.             if ($enclosure $this->get_item_tags('''enclosure'))
  5425.             {
  5426.                 if (isset($enclosure[0]['attribs']['']['url']))
  5427.                 {
  5428.                     // Attributes
  5429.                     $bitrate null;
  5430.                     $channels null;
  5431.                     $duration null;
  5432.                     $expression null;
  5433.                     $framerate null;
  5434.                     $height null;
  5435.                     $javascript null;
  5436.                     $lang null;
  5437.                     $length null;
  5438.                     $medium null;
  5439.                     $samplingrate null;
  5440.                     $type null;
  5441.                     $url null;
  5442.                     $width null;
  5443.  
  5444.                     $url $this->sanitize($enclosure[0]['attribs']['']['url']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($enclosure[0]));
  5445.                     if (isset($enclosure[0]['attribs']['']['type']))
  5446.                     {
  5447.                         $type $this->sanitize($enclosure[0]['attribs']['']['type']SIMPLEPIE_CONSTRUCT_TEXT);
  5448.                     }
  5449.                     if (isset($enclosure[0]['attribs']['']['length']))
  5450.                     {
  5451.                         $length ceil($enclosure[0]['attribs']['']['length']);
  5452.                     }
  5453.  
  5454.                     // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
  5455.                     $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);
  5456.                 }
  5457.             }
  5458.  
  5459.             if (sizeof($this->data['enclosures']== 0)
  5460.             {
  5461.                 // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
  5462.                 $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);
  5463.             }
  5464.  
  5465.             $this->data['enclosures'array_values(SimplePie_Misc::array_unique($this->data['enclosures']));
  5466.         }
  5467.         if (!empty($this->data['enclosures']))
  5468.         {
  5469.             return $this->data['enclosures'];
  5470.         }
  5471.         else
  5472.         {
  5473.             return null;
  5474.         }
  5475.     }
  5476.  
  5477.     function get_latitude()
  5478.     {
  5479.         if ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO'lat'))
  5480.         {
  5481.             return (float) $return[0]['data'];
  5482.         }
  5483.         elseif (($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/'$return[0]['data']$match))
  5484.         {
  5485.             return (float) $match[1];
  5486.         }
  5487.         else
  5488.         {
  5489.             return null;
  5490.         }
  5491.     }
  5492.  
  5493.     function get_longitude()
  5494.     {
  5495.         if ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO'long'))
  5496.         {
  5497.             return (float) $return[0]['data'];
  5498.         }
  5499.         elseif ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO'lon'))
  5500.         {
  5501.             return (float) $return[0]['data'];
  5502.         }
  5503.         elseif (($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/'$return[0]['data']$match))
  5504.         {
  5505.             return (float) $match[2];
  5506.         }
  5507.         else
  5508.         {
  5509.             return null;
  5510.         }
  5511.     }
  5512.     
  5513.     function get_source()
  5514.     {
  5515.         if ($return $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10'source'))
  5516.         {
  5517.             return new $this->feed->source_class($this$return[0]);
  5518.         }
  5519.         else
  5520.         {
  5521.             return null;
  5522.         }
  5523.     }
  5524.  
  5525.     /**
  5526.      * Creates the add_to_* methods' return data
  5527.      *
  5528.      * @access private
  5529.      * @param string $item_url String to prefix to the item permalink
  5530.      * @param string $title_url String to prefix to the item title
  5531.      *  (and suffix to the item permalink)
  5532.      * @return mixed URL if feed exists, false otherwise
  5533.      */
  5534.     function add_to_service($item_url$title_url null)
  5535.     {
  5536.         if ($this->get_permalink(!== null)
  5537.         {
  5538.             $return $this->sanitize($item_urlSIMPLEPIE_CONSTRUCT_IRIrawurlencode($this->get_permalink());
  5539.             if ($title_url !== null && $this->get_title(!== null)
  5540.             {
  5541.                 $return .= $this->sanitize($title_urlSIMPLEPIE_CONSTRUCT_IRIrawurlencode($this->get_title());
  5542.             }
  5543.             return $return;
  5544.         }
  5545.         else
  5546.         {
  5547.             return null;
  5548.         }
  5549.     }
  5550.  
  5551.     function add_to_blinklist()
  5552.     {
  5553.         return $this->add_to_service('http://www.blinklist.com/index.php?Action=Blink/addblink.php&Description=&Url=''&Title=');
  5554.     }
  5555.  
  5556.     function add_to_blogmarks()
  5557.     {
  5558.         return $this->add_to_service('http://blogmarks.net/my/new.php?mini=1&simple=1&url=''&title=');
  5559.     }
  5560.  
  5561.     function add_to_delicious()
  5562.     {
  5563.         return $this->add_to_service('http://del.icio.us/post/?v=4&url=''&title=');
  5564.     }
  5565.  
  5566.     function add_to_digg()
  5567.     {
  5568.         return $this->add_to_service('http://digg.com/submit?phase=2&URL=');
  5569.     }
  5570.  
  5571.     function add_to_furl()
  5572.     {
  5573.         return $this->add_to_service('http://www.furl.net/storeIt.jsp?u=''&t=');
  5574.     }
  5575.  
  5576.     function add_to_magnolia()
  5577.     {
  5578.         return $this->add_to_service('http://ma.gnolia.com/bookmarklet/add?url=''&title=');
  5579.     }
  5580.  
  5581.     function add_to_myweb20()
  5582.     {
  5583.         return $this->add_to_service('http://myweb2.search.yahoo.com/myresults/bookmarklet?u=''&t=');
  5584.     }
  5585.  
  5586.     function add_to_newsvine()
  5587.     {
  5588.         return $this->add_to_service('http://www.newsvine.com/_wine/save?u=''&h=');
  5589.     }
  5590.  
  5591.     function add_to_reddit()
  5592.     {
  5593.         return $this->add_to_service('http://reddit.com/submit?url=''&title=');
  5594.     }
  5595.  
  5596.     function add_to_segnalo()
  5597.     {
  5598.         return $this->add_to_service('http://segnalo.com/post.html.php?url=''&title=');
  5599.     }
  5600.  
  5601.     function add_to_simpy()
  5602.     {
  5603.         return $this->add_to_service('http://www.simpy.com/simpy/LinkAdd.do?href=''&title=');
  5604.     }
  5605.  
  5606.     function add_to_spurl()
  5607.     {
  5608.         return $this->add_to_service('http://www.spurl.net/spurl.php?v=3&url=''&title=');
  5609.     }
  5610.  
  5611.     function add_to_wists()
  5612.     {
  5613.         return $this->add_to_service('http://wists.com/r.php?c=&r=''&title=');
  5614.     }
  5615.  
  5616.     function search_technorati()
  5617.     {
  5618.         return $this->add_to_service('http://www.technorati.com/search/');
  5619.     }
  5620. }
  5621.  
  5622. {
  5623.     var $item;
  5624.     var $data = array();
  5625.  
  5626.     function SimplePie_Source($item$data)
  5627.     {
  5628.         $this->item = $item;
  5629.         $this->data = $data;
  5630.     }
  5631.  
  5632.     function __toString()
  5633.     {
  5634.         return md5(serialize($this->data));
  5635.     }
  5636.     
  5637.     /**
  5638.      * Remove items that link back to this before destroying this object
  5639.      */
  5640.     function __destruct()
  5641.     {
  5642.         unset($this->item);
  5643.     }
  5644.  
  5645.     function get_source_tags($namespace$tag)
  5646.     {
  5647.         if (isset($this->data['child'][$namespace][$tag]))
  5648.         {
  5649.             return $this->data['child'][$namespace][$tag];
  5650.         }
  5651.         else
  5652.         {
  5653.             return null;
  5654.         }
  5655.     }
  5656.  
  5657.     function get_base($element array())
  5658.     {
  5659.         return $this->item->get_base($element);
  5660.     }
  5661.  
  5662.     function sanitize($data$type$base '')
  5663.     {
  5664.         return $this->item->sanitize($data$type$base);
  5665.     }
  5666.  
  5667.     function get_item()
  5668.     {
  5669.         return $this->item;
  5670.     }
  5671.  
  5672.     function get_title()
  5673.     {
  5674.         if ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10'title'))
  5675.         {
  5676.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_10_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  5677.         }
  5678.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03'title'))
  5679.         {
  5680.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_03_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  5681.         }
  5682.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10'title'))
  5683.         {
  5684.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  5685.         }
  5686.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090'title'))
  5687.         {
  5688.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  5689.         }
  5690.         elseif ($return $this->get_source_tags('''title'))
  5691.         {
  5692.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  5693.         }
  5694.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11'title'))
  5695.         {
  5696.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5697.         }
  5698.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10'title'))
  5699.         {
  5700.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5701.         }
  5702.         else
  5703.         {
  5704.             return null;
  5705.         }
  5706.     }
  5707.  
  5708.     function get_category($key 0)
  5709.     {
  5710.         $categories $this->get_categories();
  5711.         if (isset($categories[$key]))
  5712.         {
  5713.             return $categories[$key];
  5714.         }
  5715.         else
  5716.         {
  5717.             return null;
  5718.         }
  5719.     }
  5720.  
  5721.     function get_categories()
  5722.     {
  5723.         $categories array();
  5724.  
  5725.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10'category'as $category)
  5726.         {
  5727.             $term null;
  5728.             $scheme null;
  5729.             $label null;
  5730.             if (isset($category['attribs']['']['term']))
  5731.             {
  5732.                 $term $this->sanitize($category['attribs']['']['term']SIMPLEPIE_CONSTRUCT_TEXT);
  5733.             }
  5734.             if (isset($category['attribs']['']['scheme']))
  5735.             {
  5736.                 $scheme $this->sanitize($category['attribs']['']['scheme']SIMPLEPIE_CONSTRUCT_TEXT);
  5737.             }
  5738.             if (isset($category['attribs']['']['label']))
  5739.             {
  5740.                 $label $this->sanitize($category['attribs']['']['label']SIMPLEPIE_CONSTRUCT_TEXT);
  5741.             }
  5742.             $categories[=new $this->item->feed->category_class($term$scheme$label);
  5743.         }
  5744.         foreach ((array) $this->get_source_tags('''category'as $category)
  5745.         {
  5746.             $categories[=new $this->item->feed->category_class($this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  5747.         }
  5748.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11'subject'as $category)
  5749.         {
  5750.             $categories[=new $this->item->feed->category_class($this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  5751.         }
  5752.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10'subject'as $category)
  5753.         {
  5754.             $categories[=new $this->item->feed->category_class($this->sanitize($category['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  5755.         }
  5756.  
  5757.         if (!empty($categories))
  5758.         {
  5759.             return SimplePie_Misc::array_unique($categories);
  5760.         }
  5761.         else
  5762.         {
  5763.             return null;
  5764.         }
  5765.     }
  5766.  
  5767.     function get_author($key 0)
  5768.     {
  5769.         $authors $this->get_authors();
  5770.         if (isset($authors[$key]))
  5771.         {
  5772.             return $authors[$key];
  5773.         }
  5774.         else
  5775.         {
  5776.             return null;
  5777.         }
  5778.     }
  5779.  
  5780.     function get_authors()
  5781.     {
  5782.         $authors array();
  5783.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10'author'as $author)
  5784.         {
  5785.             $name null;
  5786.             $uri null;
  5787.             $email null;
  5788.             if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
  5789.             {
  5790.                 $name $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5791.             }
  5792.             if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
  5793.             {
  5794.                 $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]));
  5795.             }
  5796.             if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
  5797.             {
  5798.                 $email $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5799.             }
  5800.             if ($name !== null || $email !== null || $uri !== null)
  5801.             {
  5802.                 $authors[=new $this->item->feed->author_class($name$uri$email);
  5803.             }
  5804.         }
  5805.         if ($author $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03'author'))
  5806.         {
  5807.             $name null;
  5808.             $url null;
  5809.             $email null;
  5810.             if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
  5811.             {
  5812.                 $name $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5813.             }
  5814.             if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
  5815.             {
  5816.                 $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]));
  5817.             }
  5818.             if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
  5819.             {
  5820.                 $email $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5821.             }
  5822.             if ($name !== null || $email !== null || $url !== null)
  5823.             {
  5824.                 $authors[=new $this->item->feed->author_class($name$url$email);
  5825.             }
  5826.         }
  5827.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11'creator'as $author)
  5828.         {
  5829.             $authors[=new $this->item->feed->author_class($this->sanitize($author['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  5830.         }
  5831.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10'creator'as $author)
  5832.         {
  5833.             $authors[=new $this->item->feed->author_class($this->sanitize($author['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  5834.         }
  5835.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES'author'as $author)
  5836.         {
  5837.             $authors[=new $this->item->feed->author_class($this->sanitize($author['data']SIMPLEPIE_CONSTRUCT_TEXT)nullnull);
  5838.         }
  5839.  
  5840.         if (!empty($authors))
  5841.         {
  5842.             return SimplePie_Misc::array_unique($authors);
  5843.         }
  5844.         else
  5845.         {
  5846.             return null;
  5847.         }
  5848.     }
  5849.  
  5850.     function get_contributor($key 0)
  5851.     {
  5852.         $contributors $this->get_contributors();
  5853.         if (isset($contributors[$key]))
  5854.         {
  5855.             return $contributors[$key];
  5856.         }
  5857.         else
  5858.         {
  5859.             return null;
  5860.         }
  5861.     }
  5862.  
  5863.     function get_contributors()
  5864.     {
  5865.         $contributors array();
  5866.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10'contributor'as $contributor)
  5867.         {
  5868.             $name null;
  5869.             $uri null;
  5870.             $email null;
  5871.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
  5872.             {
  5873.                 $name $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5874.             }
  5875.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
  5876.             {
  5877.                 $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]));
  5878.             }
  5879.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
  5880.             {
  5881.                 $email $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5882.             }
  5883.             if ($name !== null || $email !== null || $uri !== null)
  5884.             {
  5885.                 $contributors[=new $this->item->feed->author_class($name$uri$email);
  5886.             }
  5887.         }
  5888.         foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03'contributor'as $contributor)
  5889.         {
  5890.             $name null;
  5891.             $url null;
  5892.             $email null;
  5893.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
  5894.             {
  5895.                 $name $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5896.             }
  5897.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
  5898.             {
  5899.                 $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]));
  5900.             }
  5901.             if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
  5902.             {
  5903.                 $email $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  5904.             }
  5905.             if ($name !== null || $email !== null || $url !== null)
  5906.             {
  5907.                 $contributors[=new $this->item->feed->author_class($name$url$email);
  5908.             }
  5909.         }
  5910.  
  5911.         if (!empty($contributors))
  5912.         {
  5913.             return SimplePie_Misc::array_unique($contributors);
  5914.         }
  5915.         else
  5916.         {
  5917.             return null;
  5918.         }
  5919.     }
  5920.  
  5921.     function get_link($key 0$rel 'alternate')
  5922.     {
  5923.         $links $this->get_links($rel);
  5924.         if (isset($links[$key]))
  5925.         {
  5926.             return $links[$key];
  5927.         }
  5928.         else
  5929.         {
  5930.             return null;
  5931.         }
  5932.     }
  5933.  
  5934.     /**
  5935.      * Added for parity between the parent-level and the item/entry-level.
  5936.      */
  5937.     function get_permalink()
  5938.     {
  5939.         return $this->get_link(0);
  5940.     }
  5941.  
  5942.     function get_links($rel 'alternate')
  5943.     {
  5944.         if (!isset($this->data['links']))
  5945.         {
  5946.             $this->data['links'array();
  5947.             if ($links $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10'link'))
  5948.             {
  5949.                 foreach ($links as $link)
  5950.                 {
  5951.                     if (isset($link['attribs']['']['href']))
  5952.                     {
  5953.                         $link_rel (isset($link['attribs']['']['rel'])) $link['attribs']['']['rel''alternate';
  5954.                         $this->data['links'][$link_rel][$this->sanitize($link['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($link));
  5955.                     }
  5956.                 }
  5957.             }
  5958.             if ($links $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03'link'))
  5959.             {
  5960.                 foreach ($links as $link)
  5961.                 {
  5962.                     if (isset($link['attribs']['']['href']))
  5963.                     {
  5964.                         $link_rel (isset($link['attribs']['']['rel'])) $link['attribs']['']['rel''alternate';
  5965.                         $this->data['links'][$link_rel][$this->sanitize($link['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($link));
  5966.  
  5967.                     }
  5968.                 }
  5969.             }
  5970.             if ($links $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10'link'))
  5971.             {
  5972.                 $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  5973.             }
  5974.             if ($links $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090'link'))
  5975.             {
  5976.                 $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  5977.             }
  5978.             if ($links $this->get_source_tags('''link'))
  5979.             {
  5980.                 $this->data['links']['alternate'][$this->sanitize($links[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($links[0]));
  5981.             }
  5982.  
  5983.             $keys array_keys($this->data['links']);
  5984.             foreach ($keys as $key)
  5985.             {
  5986.                 if (SimplePie_Misc::is_isegment_nz_nc($key))
  5987.                 {
  5988.                     if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key]))
  5989.                     {
  5990.                         $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $keyarray_merge($this->data['links'][$key]$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key]);
  5991.                         $this->data['links'][$key=$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key];
  5992.                     }
  5993.                     else
  5994.                     {
  5995.                         $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY $key=$this->data['links'][$key];
  5996.                     }
  5997.                 }
  5998.                 elseif (substr($key041== SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
  5999.                 {
  6000.                     $this->data['links'][substr($key41)=$this->data['links'][$key];
  6001.                 }
  6002.                 $this->data['links'][$keyarray_unique($this->data['links'][$key]);
  6003.             }
  6004.         }
  6005.  
  6006.         if (isset($this->data['links'][$rel]))
  6007.         {
  6008.             return $this->data['links'][$rel];
  6009.         }
  6010.         else
  6011.         {
  6012.             return null;
  6013.         }
  6014.     }
  6015.  
  6016.     function get_description()
  6017.     {
  6018.         if ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10'subtitle'))
  6019.         {
  6020.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_10_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  6021.         }
  6022.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03'tagline'))
  6023.         {
  6024.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_03_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  6025.         }
  6026.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10'description'))
  6027.         {
  6028.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  6029.         }
  6030.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090'description'))
  6031.         {
  6032.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  6033.         }
  6034.         elseif ($return $this->get_source_tags('''description'))
  6035.         {
  6036.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_MAYBE_HTML$this->get_base($return[0]));
  6037.         }
  6038.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11'description'))
  6039.         {
  6040.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  6041.         }
  6042.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10'description'))
  6043.         {
  6044.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  6045.         }
  6046.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES'summary'))
  6047.         {
  6048.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_HTML$this->get_base($return[0]));
  6049.         }
  6050.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES'subtitle'))
  6051.         {
  6052.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_HTML$this->get_base($return[0]));
  6053.         }
  6054.         else
  6055.         {
  6056.             return null;
  6057.         }
  6058.     }
  6059.  
  6060.     function get_copyright()
  6061.     {
  6062.         if ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10'rights'))
  6063.         {
  6064.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_10_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  6065.         }
  6066.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03'copyright'))
  6067.         {
  6068.             return $this->sanitize($return[0]['data']SimplePie_Misc::atom_03_construct_type($return[0]['attribs'])$this->get_base($return[0]));
  6069.         }
  6070.         elseif ($return $this->get_source_tags('''copyright'))
  6071.         {
  6072.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  6073.         }
  6074.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11'rights'))
  6075.         {
  6076.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  6077.         }
  6078.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10'rights'))
  6079.         {
  6080.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  6081.         }
  6082.         else
  6083.         {
  6084.             return null;
  6085.         }
  6086.     }
  6087.  
  6088.     function get_language()
  6089.     {
  6090.         if ($return $this->get_source_tags('''language'))
  6091.         {
  6092.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  6093.         }
  6094.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11'language'))
  6095.         {
  6096.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  6097.         }
  6098.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10'language'))
  6099.         {
  6100.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_TEXT);
  6101.         }
  6102.         elseif (isset($this->data['xml_lang']))
  6103.         {
  6104.             return $this->sanitize($this->data['xml_lang']SIMPLEPIE_CONSTRUCT_TEXT);
  6105.         }
  6106.         else
  6107.         {
  6108.             return null;
  6109.         }
  6110.     }
  6111.  
  6112.     function get_latitude()
  6113.     {
  6114.         if ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO'lat'))
  6115.         {
  6116.             return (float) $return[0]['data'];
  6117.         }
  6118.         elseif (($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/'$return[0]['data']$match))
  6119.         {
  6120.             return (float) $match[1];
  6121.         }
  6122.         else
  6123.         {
  6124.             return null;
  6125.         }
  6126.     }
  6127.  
  6128.     function get_longitude()
  6129.     {
  6130.         if ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO'long'))
  6131.         {
  6132.             return (float) $return[0]['data'];
  6133.         }
  6134.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO'lon'))
  6135.         {
  6136.             return (float) $return[0]['data'];
  6137.         }
  6138.         elseif (($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/'$return[0]['data']$match))
  6139.         {
  6140.             return (float) $match[2];
  6141.         }
  6142.         else
  6143.         {
  6144.             return null;
  6145.         }
  6146.     }
  6147.  
  6148.     function get_image_url()
  6149.     {
  6150.         if ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES'image'))
  6151.         {
  6152.             return $this->sanitize($return[0]['attribs']['']['href']SIMPLEPIE_CONSTRUCT_IRI);
  6153.         }
  6154.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10'logo'))
  6155.         {
  6156.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  6157.         }
  6158.         elseif ($return $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10'icon'))
  6159.         {
  6160.             return $this->sanitize($return[0]['data']SIMPLEPIE_CONSTRUCT_IRI$this->get_base($return[0]));
  6161.         }
  6162.         else
  6163.         {
  6164.             return null;
  6165.         }
  6166.     }
  6167. }
  6168.  
  6169. {
  6170.     var $name;
  6171.     var $link;
  6172.     var $email;
  6173.  
  6174.     // Constructor, used to input the data
  6175.     function SimplePie_Author($name null$link null$email null)
  6176.     {
  6177.         $this->name = $name;
  6178.         $this->link = $link;
  6179.         $this->email = $email;
  6180.     }
  6181.  
  6182.     function __toString()
  6183.     {
  6184.         // There is no $this->data here
  6185.         return md5(serialize($this));
  6186.     }
  6187.  
  6188.     function get_name()
  6189.     {
  6190.         if ($this->name !== null)
  6191.         {
  6192.             return $this->name;
  6193.         }
  6194.         else
  6195.         {
  6196.             return null;
  6197.         }
  6198.     }
  6199.  
  6200.     function get_link()
  6201.     {
  6202.         if ($this->link !== null)
  6203.         {
  6204.             return $this->link;
  6205.         }
  6206.         else
  6207.         {
  6208.             return null;
  6209.         }
  6210.     }
  6211.  
  6212.     function get_email()
  6213.     {
  6214.         if ($this->email !== null)
  6215.         {
  6216.             return $this->email;
  6217.         }
  6218.         else
  6219.         {
  6220.             return null;
  6221.         }
  6222.     }
  6223. }
  6224.  
  6225. {
  6226.     var $term;
  6227.     var $scheme;
  6228.     var $label;
  6229.  
  6230.     // Constructor, used to input the data
  6231.     function SimplePie_Category($term null$scheme null$label null)
  6232.     {
  6233.         $this->term = $term;
  6234.         $this->scheme = $scheme;
  6235.         $this->label = $label;
  6236.     }
  6237.  
  6238.     function __toString()
  6239.     {
  6240.         // There is no $this->data here
  6241.         return md5(serialize($this));
  6242.     }
  6243.  
  6244.     function get_term()
  6245.     {
  6246.         if ($this->term !== null)
  6247.         {
  6248.             return $this->term;
  6249.         }
  6250.         else
  6251.         {
  6252.             return null;
  6253.         }
  6254.     }
  6255.  
  6256.     function get_scheme()
  6257.     {
  6258.         if ($this->scheme !== null)
  6259.         {
  6260.             return $this->scheme;
  6261.         }
  6262.         else
  6263.         {
  6264.             return null;
  6265.         }
  6266.     }
  6267.  
  6268.     function get_label()
  6269.     {
  6270.         if ($this->label !== null)
  6271.         {
  6272.             return $this->label;
  6273.         }
  6274.         else
  6275.         {
  6276.             return $this->get_term();
  6277.         }
  6278.     }
  6279. }
  6280.  
  6281. {
  6282.     var $bitrate;
  6283.     var $captions;
  6284.     var $categories;
  6285.     var $channels;
  6286.     var $copyright;
  6287.     var $credits;
  6288.     var $description;
  6289.     var $duration;
  6290.     var $expression;
  6291.     var $framerate;
  6292.     var $handler;
  6293.     var $hashes;
  6294.     var $height;
  6295.     var $javascript;
  6296.     var $keywords;
  6297.     var $lang;
  6298.     var $length;
  6299.     var $link;
  6300.     var $medium;
  6301.     var $player;
  6302.     var $ratings;
  6303.     var $restrictions;
  6304.     var $samplingrate;
  6305.     var $thumbnails;
  6306.     var $title;
  6307.     var $type;
  6308.     var $width;
  6309.  
  6310.     // Constructor, used to input the data
  6311.     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)
  6312.     {
  6313.         $this->bitrate = $bitrate;
  6314.         $this->captions = $captions;
  6315.         $this->categories = $categories;
  6316.         $this->channels = $channels;
  6317.         $this->copyright = $copyright;
  6318.         $this->credits = $credits;
  6319.         $this->description = $description;
  6320.         $this->duration = $duration;
  6321.         $this->expression = $expression;
  6322.         $this->framerate = $framerate;
  6323.         $this->hashes = $hashes;
  6324.         $this->height = $height;
  6325.         $this->javascript = $javascript;
  6326.         $this->keywords = $keywords;
  6327.         $this->lang = $lang;
  6328.         $this->length = $length;
  6329.         $this->link = $link;
  6330.         $this->medium = $medium;
  6331.         $this->player = $player;
  6332.         $this->ratings = $ratings;
  6333.         $this->restrictions = $restrictions;
  6334.         $this->samplingrate = $samplingrate;
  6335.         $this->thumbnails = $thumbnails;
  6336.         $this->title = $title;
  6337.         $this->type = $type;
  6338.         $this->width = $width;
  6339.         if (class_exists('idna_convert'))
  6340.         {
  6341.             $idn =new idna_convert;
  6342.             $parsed SimplePie_Misc::parse_url($link);
  6343.             $this->link = SimplePie_Misc::compress_parse_url($parsed['scheme']$idn->encode($parsed['authority'])$parsed['path']$parsed['query']$parsed['fragment']);
  6344.         }
  6345.         $this->handler = $this->get_handler()// Needs to load last
  6346.     }
  6347.  
  6348.     function __toString()
  6349.     {
  6350.         // There is no $this->data here
  6351.         return md5(serialize($this));
  6352.     }
  6353.  
  6354.     function get_bitrate()
  6355.     {
  6356.         if ($this->bitrate !== null)
  6357.         {
  6358.             return $this->bitrate;
  6359.         }
  6360.         else
  6361.         {
  6362.             return null;
  6363.         }
  6364.     }
  6365.  
  6366.     function get_caption($key 0)
  6367.     {
  6368.         $captions $this->get_captions();
  6369.         if (isset($captions[$key]))
  6370.         {
  6371.             return $captions[$key];
  6372.         }
  6373.         else
  6374.         {
  6375.             return null;
  6376.         }
  6377.     }
  6378.  
  6379.     function get_captions()
  6380.     {
  6381.         if ($this->captions !== null)
  6382.         {
  6383.             return $this->captions;
  6384.         }
  6385.         else
  6386.         {
  6387.             return null;
  6388.         }
  6389.     }
  6390.  
  6391.     function get_category($key 0)
  6392.     {
  6393.         $categories $this->get_categories();
  6394.         if (isset($categories[$key]))
  6395.         {
  6396.             return $categories[$key];
  6397.         }
  6398.         else
  6399.         {
  6400.             return null;
  6401.         }
  6402.     }
  6403.  
  6404.     function get_categories()
  6405.     {
  6406.         if ($this->categories !== null)
  6407.         {
  6408.             return $this->categories;
  6409.         }
  6410.         else
  6411.         {
  6412.             return null;
  6413.         }
  6414.     }
  6415.  
  6416.     function get_channels()
  6417.     {
  6418.         if ($this->channels !== null)
  6419.         {
  6420.             return $this->channels;
  6421.         }
  6422.         else
  6423.         {
  6424.             return null;
  6425.         }
  6426.     }
  6427.  
  6428.     function get_copyright()
  6429.     {
  6430.         if ($this->copyright !== null)
  6431.         {
  6432.             return $this->copyright;
  6433.         }
  6434.         else
  6435.         {
  6436.             return null;
  6437.         }
  6438.     }
  6439.  
  6440.     function get_credit($key 0)
  6441.     {
  6442.         $credits $this->get_credits();
  6443.         if (isset($credits[$key]))
  6444.         {
  6445.             return $credits[$key];
  6446.         }
  6447.         else
  6448.         {
  6449.             return null;
  6450.         }
  6451.     }
  6452.  
  6453.     function get_credits()
  6454.     {
  6455.         if ($this->credits !== null)
  6456.         {
  6457.             return $this->credits;
  6458.         }
  6459.         else
  6460.         {
  6461.             return null;
  6462.         }
  6463.     }
  6464.  
  6465.     function get_description()
  6466.     {
  6467.         if ($this->description !== null)
  6468.         {
  6469.             return $this->description;
  6470.         }
  6471.         else
  6472.         {
  6473.             return null;
  6474.         }
  6475.     }
  6476.  
  6477.     function get_duration($convert false)
  6478.     {
  6479.         if ($this->duration !== null)
  6480.         {
  6481.             if ($convert)
  6482.             {
  6483.                 $time SimplePie_Misc::time_hms($this->duration);
  6484.                 return $time;
  6485.             }
  6486.             else
  6487.             {
  6488.                 return $this->duration;
  6489.             }
  6490.         }
  6491.         else
  6492.         {
  6493.             return null;
  6494.         }
  6495.     }
  6496.  
  6497.     function get_expression()
  6498.     {
  6499.         if ($this->expression !== null)
  6500.         {
  6501.             return $this->expression;
  6502.         }
  6503.         else
  6504.         {
  6505.             return 'full';
  6506.         }
  6507.     }
  6508.  
  6509.     function get_extension()
  6510.     {
  6511.         if ($this->link !== null)
  6512.         {
  6513.             $url SimplePie_Misc::parse_url($this->link);
  6514.             if ($url['path'!== '')
  6515.             {
  6516.                 return pathinfo($url['path']PATHINFO_EXTENSION);
  6517.             }
  6518.         }
  6519.         return null;
  6520.     }
  6521.  
  6522.     function get_framerate()
  6523.     {
  6524.         if ($this->framerate !== null)
  6525.         {
  6526.             return $this->framerate;
  6527.         }
  6528.         else
  6529.         {
  6530.             return null;
  6531.         }
  6532.     }
  6533.  
  6534.     function get_handler()
  6535.     {
  6536.         return $this->get_real_type(true);
  6537.     }
  6538.  
  6539.     function get_hash($key 0)
  6540.     {
  6541.         $hashes $this->get_hashes();
  6542.         if (isset($hashes[$key]))
  6543.         {
  6544.             return $hashes[$key];
  6545.         }
  6546.         else
  6547.         {
  6548.             return null;
  6549.         }
  6550.     }
  6551.  
  6552.     function get_hashes()
  6553.     {
  6554.         if ($this->hashes !== null)
  6555.         {
  6556.             return $this->hashes;
  6557.         }
  6558.         else
  6559.         {
  6560.             return null;
  6561.         }
  6562.     }
  6563.  
  6564.     function get_height()
  6565.     {
  6566.         if ($this->height !== null)
  6567.         {
  6568.             return $this->height;
  6569.         }
  6570.         else
  6571.         {
  6572.             return null;
  6573.         }
  6574.     }
  6575.  
  6576.     function get_language()
  6577.     {
  6578.         if ($this->lang !== null)
  6579.         {
  6580.             return $this->lang;
  6581.         }
  6582.         else
  6583.         {
  6584.             return null;
  6585.         }
  6586.     }
  6587.  
  6588.     function get_keyword($key 0)
  6589.     {
  6590.         $keywords $this->get_keywords();
  6591.         if (isset($keywords[$key]))
  6592.         {
  6593.             return $keywords[$key];
  6594.         }
  6595.         else
  6596.         {
  6597.             return null;
  6598.         }
  6599.     }
  6600.  
  6601.     function get_keywords()
  6602.     {
  6603.         if ($this->keywords !== null)
  6604.         {
  6605.             return $this->keywords;
  6606.         }
  6607.         else
  6608.         {
  6609.             return null;
  6610.         }
  6611.     }
  6612.  
  6613.     function get_length()
  6614.     {
  6615.         if ($this->length !== null)
  6616.         {
  6617.             return $this->length;
  6618.         }
  6619.         else
  6620.         {
  6621.             return null;
  6622.         }
  6623.     }
  6624.  
  6625.     function get_link()
  6626.     {
  6627.         if ($this->link !== null)
  6628.         {
  6629.             return urldecode($this->link);
  6630.         }
  6631.         else
  6632.         {
  6633.             return null;
  6634.         }
  6635.     }
  6636.  
  6637.     function get_medium()
  6638.     {
  6639.         if ($this->medium !== null)
  6640.         {
  6641.             return $this->medium;
  6642.         }
  6643.         else
  6644.         {
  6645.             return null;
  6646.         }
  6647.     }
  6648.  
  6649.     function get_player()
  6650.     {
  6651.         if ($this->player !== null)
  6652.         {
  6653.             return $this->player;
  6654.         }
  6655.         else
  6656.         {
  6657.             return null;
  6658.         }
  6659.     }
  6660.  
  6661.     function get_rating($key 0)
  6662.     {
  6663.         $ratings $this->get_ratings();
  6664.         if (isset($ratings[$key]))
  6665.         {
  6666.             return $ratings[$key];
  6667.         }
  6668.         else
  6669.         {
  6670.             return null;
  6671.         }
  6672.     }
  6673.  
  6674.     function get_ratings()
  6675.     {
  6676.         if ($this->ratings !== null)
  6677.         {
  6678.             return $this->ratings;
  6679.         }
  6680.         else
  6681.         {
  6682.             return null;
  6683.         }
  6684.     }
  6685.  
  6686.     function get_restriction($key 0)
  6687.     {
  6688.         $restrictions $this->get_restrictions();
  6689.         if (isset($restrictions[$key]))
  6690.         {
  6691.             return $restrictions[$key];
  6692.         }
  6693.         else
  6694.         {
  6695.             return null;
  6696.         }
  6697.     }
  6698.  
  6699.     function get_restrictions()
  6700.     {
  6701.         if ($this->restrictions !== null)
  6702.         {
  6703.             return $this->restrictions;
  6704.         }
  6705.         else
  6706.         {
  6707.             return null;
  6708.         }
  6709.     }
  6710.  
  6711.     function get_sampling_rate()
  6712.     {
  6713.         if ($this->samplingrate !== null)
  6714.         {
  6715.             return $this->samplingrate;
  6716.         }
  6717.         else
  6718.         {
  6719.             return null;
  6720.         }
  6721.     }
  6722.  
  6723.     function get_size()
  6724.     {
  6725.         $length $this->get_length();
  6726.         if ($length !== null)
  6727.         {
  6728.             return round($length/10485762);
  6729.         }
  6730.         else
  6731.         {
  6732.             return null;
  6733.         }
  6734.     }
  6735.  
  6736.     function get_thumbnail($key 0)
  6737.     {
  6738.         $thumbnails $this->get_thumbnails();
  6739.         if (isset($thumbnails[$key]))
  6740.         {
  6741.             return $thumbnails[$key];
  6742.         }
  6743.         else
  6744.         {
  6745.             return null;
  6746.         }
  6747.     }
  6748.  
  6749.     function get_thumbnails()
  6750.     {
  6751.         if ($this->thumbnails !== null)
  6752.         {
  6753.             return $this->thumbnails;
  6754.         }
  6755.         else
  6756.         {
  6757.             return null;
  6758.         }
  6759.     }
  6760.  
  6761.     function get_title()
  6762.     {
  6763.         if ($this->title !== null)
  6764.         {
  6765.             return $this->title;
  6766.         }
  6767.         else
  6768.         {
  6769.             return null;
  6770.         }
  6771.     }
  6772.  
  6773.     function get_type()
  6774.     {
  6775.         if ($this->type !== null)
  6776.         {
  6777.             return $this->type;
  6778.         }
  6779.         else
  6780.         {
  6781.             return null;
  6782.         }
  6783.     }
  6784.  
  6785.     function get_width()
  6786.     {
  6787.         if ($this->width !== null)
  6788.         {
  6789.             return $this->width;
  6790.         }
  6791.         else
  6792.         {
  6793.             return null;
  6794.         }
  6795.     }
  6796.  
  6797.     function native_embed($options='')
  6798.     {
  6799.         return $this->embed($optionstrue);
  6800.     }
  6801.  
  6802.     /**
  6803.      * @todo If the dimensions for media:content are defined, use them when width/height are set to 'auto'.
  6804.      */
  6805.     function embed($options ''$native false)
  6806.     {
  6807.         // Set up defaults
  6808.         $audio '';
  6809.         $video '';
  6810.         $alt '';
  6811.         $altclass '';
  6812.         $loop 'false';
  6813.         $width 'auto';
  6814.         $height 'auto';
  6815.         $bgcolor '#ffffff';
  6816.         $mediaplayer '';
  6817.         $widescreen false;
  6818.         $handler $this->get_handler();
  6819.         $type $this->get_real_type();
  6820.  
  6821.         // Process options and reassign values as necessary
  6822.         if (is_array($options))
  6823.         {
  6824.             extract($options);
  6825.         }
  6826.         else
  6827.         {
  6828.             $options explode(','$options);
  6829.             foreach($options as $option)
  6830.             {
  6831.                 $opt explode(':'$option2);
  6832.                 if (isset($opt[0]$opt[1]))
  6833.                 {
  6834.                     $opt[0trim($opt[0]);
  6835.                     $opt[1trim($opt[1]);
  6836.                     switch ($opt[0])
  6837.                     {
  6838.                         case 'audio':
  6839.                             $audio $opt[1];
  6840.                             break;
  6841.  
  6842.                         case 'video':
  6843.                             $video $opt[1];
  6844.                             break;
  6845.  
  6846.                         case 'alt':
  6847.                             $alt $opt[1];
  6848.                             break;
  6849.  
  6850.                         case 'altclass':
  6851.                             $altclass $opt[1];
  6852.                             break;
  6853.  
  6854.                         case 'loop':
  6855.                             $loop $opt[1];
  6856.                             break;
  6857.  
  6858.                         case 'width':
  6859.                             $width $opt[1];
  6860.                             break;
  6861.  
  6862.                         case 'height':
  6863.                             $height $opt[1];
  6864.                             break;
  6865.  
  6866.                         case 'bgcolor':
  6867.                             $bgcolor $opt[1];
  6868.                             break;
  6869.  
  6870.                         case 'mediaplayer':
  6871.                             $mediaplayer $opt[1];
  6872.                             break;
  6873.  
  6874.                         case 'widescreen':
  6875.                             $widescreen $opt[1];
  6876.                             break;
  6877.                     }
  6878.                 }
  6879.             }
  6880.         }
  6881.  
  6882.         $mime explode('/'$type2);
  6883.         $mime $mime[0];
  6884.  
  6885.         // Process values for 'auto'
  6886.         if ($width == 'auto')
  6887.         {
  6888.             if ($mime == 'video')
  6889.             {
  6890.                 if ($height == 'auto')
  6891.                 {
  6892.                     $width 480;
  6893.                 }
  6894.                 elseif ($widescreen)
  6895.                 {
  6896.                     $width round((intval($height)/9)*16);
  6897.                 }
  6898.                 else
  6899.                 {
  6900.                     $width round((intval($height)/3)*4);
  6901.                 }
  6902.             }
  6903.             else
  6904.             {
  6905.                 $width '100%';
  6906.             }
  6907.         }
  6908.  
  6909.         if ($height == 'auto')
  6910.         {
  6911.             if ($mime == 'audio')
  6912.             {
  6913.                 $height 0;
  6914.             }
  6915.             elseif ($mime == 'video')
  6916.             {
  6917.                 if ($width == 'auto')
  6918.                 {
  6919.                     if ($widescreen)
  6920.                     {
  6921.                         $height 270;
  6922.                     }
  6923.                     else
  6924.                     {
  6925.                         $height 360;
  6926.                     }
  6927.                 }
  6928.                 elseif ($widescreen)
  6929.                 {
  6930.                     $height round((intval($width)/16)*9);
  6931.                 }
  6932.                 else
  6933.                 {
  6934.                     $height round((intval($width)/4)*3);
  6935.                 }
  6936.             }
  6937.             else
  6938.             {
  6939.                 $height 376;
  6940.             }
  6941.         }
  6942.         elseif ($mime == 'audio')
  6943.         {
  6944.             $height 0;
  6945.         }
  6946.  
  6947.         // Set proper placeholder value
  6948.         if ($mime == 'audio')
  6949.         {
  6950.             $placeholder $audio;
  6951.         }
  6952.         elseif ($mime == 'video')
  6953.         {
  6954.             $placeholder $video;
  6955.         }
  6956.  
  6957.         $embed '';
  6958.  
  6959.         // Make sure the JS library is included
  6960.         if (!$native)
  6961.         {
  6962.             static $javascript_outputted null;
  6963.             if (!$javascript_outputted && $this->javascript)
  6964.             {
  6965.                 $embed .= '<script type="text/javascript" src="?' htmlspecialchars($this->javascript'"></script>';
  6966.                 $javascript_outputted true;
  6967.             }
  6968.         }
  6969.  
  6970.         // Odeo Feed MP3's
  6971.         if ($handler == 'odeo')
  6972.         {
  6973.             if ($native)
  6974.             {
  6975.                 $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>';
  6976.             }
  6977.             else
  6978.             {
  6979.                 $embed .= '<script type="text/javascript">embed_odeo("' $this->get_link('");</script>';
  6980.             }
  6981.         }
  6982.  
  6983.         // Flash
  6984.         elseif ($handler == 'flash')
  6985.         {
  6986.             if ($native)
  6987.             {
  6988.                 $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>";
  6989.             }
  6990.             else
  6991.             {
  6992.                 $embed .= "<script type='text/javascript'>embed_flash('$bgcolor', '$width', '$height', '$this->get_link("', '$loop', '$type');</script>";
  6993.             }
  6994.         }
  6995.  
  6996.         // Flash Media Player file types.
  6997.         // Preferred handler for MP3 file types.
  6998.         elseif ($handler == 'fmedia' || ($handler == 'mp3' && $mediaplayer != ''))
  6999.         {
  7000.             $height += 20;
  7001.             if ($native)
  7002.             {
  7003.                 $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>";
  7004.             }
  7005.             else
  7006.             {
  7007.                 $embed .= "<script type='text/javascript'>embed_flv('$width', '$height', 'rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) "', '$placeholder', '$loop', '$mediaplayer');</script>";
  7008.             }
  7009.         }
  7010.  
  7011.         // QuickTime 7 file types.  Need to test with QuickTime 6.
  7012.         // Only handle MP3's if the Flash Media Player is not present.
  7013.         elseif ($handler == 'quicktime' || ($handler == 'mp3' && $mediaplayer == ''))
  7014.         {
  7015.             $height += 16;
  7016.             if ($native)
  7017.             {
  7018.                 if ($placeholder != ""){
  7019.                     $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>";
  7020.                 }
  7021.                 else {
  7022.                     $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>";
  7023.                 }
  7024.             }
  7025.             else
  7026.             {
  7027.                 $embed .= "<script type='text/javascript'>embed_quicktime('$type', '$bgcolor', '$width', '$height', '$this->get_link("', '$placeholder', '$loop');</script>";
  7028.             }
  7029.         }
  7030.  
  7031.         // Windows Media
  7032.         elseif ($handler == 'wmedia')
  7033.         {
  7034.             $height += 45;
  7035.             if ($native)
  7036.             {
  7037.                 $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>";
  7038.             }
  7039.             else
  7040.             {
  7041.                 $embed .= "<script type='text/javascript'>embed_wmedia('$width', '$height', '$this->get_link("');</script>";
  7042.             }
  7043.         }
  7044.  
  7045.         // Everything else
  7046.         else $embed .= '<a href="' $this->get_link('" class="' $altclass '">' $alt '</a>';
  7047.  
  7048.         return $embed;
  7049.     }
  7050.  
  7051.     function get_real_type($find_handler false)
  7052.     {
  7053.         // If it's Odeo, let's get it out of the way.
  7054.         if (substr(strtolower($this->get_link())015== 'http://odeo.com')
  7055.         {
  7056.             return 'odeo';
  7057.         }
  7058.  
  7059.         // Mime-types by handler.
  7060.         $types_flash array('application/x-shockwave-flash''application/futuresplash')// Flash
  7061.         $types_fmedia array('video/flv''video/x-flv')// Flash Media Player
  7062.         $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
  7063.         $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
  7064.         $types_mp3 array('audio/mp3''audio/x-mp3''audio/mpeg''audio/x-mpeg')// MP3
  7065.  
  7066.         if ($this->get_type(!== null)
  7067.         {
  7068.             $type strtolower($this->type);
  7069.         }
  7070.         else
  7071.         {
  7072.             $type null;
  7073.         }
  7074.  
  7075.         // If we encounter an unsupported mime-type, check the file extension and guess intelligently.
  7076.         if (!in_array($typearray_merge($types_flash$types_fmedia$types_quicktime$types_wmedia$types_mp3)))
  7077.         {
  7078.             switch (strtolower($this->get_extension()))
  7079.             {
  7080.                 // Audio mime-types
  7081.                 case 'aac':
  7082.                 case 'adts':
  7083.                     $type 'audio/acc';
  7084.                     break;
  7085.  
  7086.                 case 'aif':
  7087.                 case 'aifc':
  7088.                 case 'aiff':
  7089.                 case 'cdda':
  7090.                     $type 'audio/aiff';
  7091.                     break;
  7092.  
  7093.                 case 'bwf':
  7094.                     $type 'audio/wav';
  7095.                     break;
  7096.  
  7097.                 case 'kar':
  7098.                 case 'mid':
  7099.                 case 'midi':
  7100.                 case 'smf':
  7101.                     $type 'audio/midi';
  7102.                     break;
  7103.  
  7104.                 case 'm4a':
  7105.                     $type 'audio/x-m4a';
  7106.                     break;
  7107.  
  7108.                 case 'mp3':
  7109.                 case 'swa':
  7110.                     $type 'audio/mp3';
  7111.                     break;
  7112.  
  7113.                 case 'wav':
  7114.                     $type 'audio/wav';
  7115.                     break;
  7116.  
  7117.                 case 'wax':
  7118.                     $type 'audio/x-ms-wax';
  7119.                     break;
  7120.  
  7121.                 case 'wma':
  7122.                     $type 'audio/x-ms-wma';
  7123.                     break;
  7124.  
  7125.                 // Video mime-types
  7126.                 case '3gp':
  7127.                 case '3gpp':
  7128.                     $type 'video/3gpp';
  7129.                     break;
  7130.  
  7131.                 case '3g2':
  7132.                 case '3gp2':
  7133.                     $type 'video/3gpp2';
  7134.                     break;
  7135.  
  7136.                 case 'asf':
  7137.                     $type 'video/x-ms-asf';
  7138.                     break;
  7139.  
  7140.                 case 'flv':
  7141.                     $type 'video/x-flv';
  7142.                     break;
  7143.  
  7144.                 case 'm1a':
  7145.                 case 'm1s':
  7146.                 case 'm1v':
  7147.                 case 'm15':
  7148.                 case 'm75':
  7149.                 case 'mp2':
  7150.                 case 'mpa':
  7151.                 case 'mpeg':
  7152.                 case 'mpg':
  7153.                 case 'mpm':
  7154.                 case 'mpv':
  7155.                     $type 'video/mpeg';
  7156.                     break;
  7157.  
  7158.                 case 'm4v':
  7159.                     $type 'video/x-m4v';
  7160.                     break;
  7161.  
  7162.                 case 'mov':
  7163.                 case 'qt':
  7164.                     $type 'video/quicktime';
  7165.                     break;
  7166.  
  7167.                 case 'mp4':
  7168.                 case 'mpg4':
  7169.                     $type 'video/mp4';
  7170.                     break;
  7171.  
  7172.                 case 'sdv':
  7173.                     $type 'video/sd-video';
  7174.                     break;
  7175.  
  7176.                 case 'wm':
  7177.                     $type 'video/x-ms-wm';
  7178.                     break;
  7179.  
  7180.                 case 'wmv':
  7181.                     $type 'video/x-ms-wmv';
  7182.                     break;
  7183.  
  7184.                 case 'wvx':
  7185.                     $type 'video/x-ms-wvx';
  7186.                     break;
  7187.  
  7188.                 // Flash mime-types
  7189.                 case 'spl':
  7190.                     $type 'application/futuresplash';
  7191.                     break;
  7192.  
  7193.                 case 'swf':
  7194.                     $type 'application/x-shockwave-flash';
  7195.                     break;
  7196.             }
  7197.         }
  7198.  
  7199.         if ($find_handler)
  7200.         {
  7201.             if (in_array($type$types_flash))
  7202.             {
  7203.                 return 'flash';
  7204.             }
  7205.             elseif (in_array($type$types_fmedia))
  7206.             {
  7207.                 return 'fmedia';
  7208.             }
  7209.             elseif (in_array($type$types_quicktime))
  7210.             {
  7211.                 return 'quicktime';
  7212.             }
  7213.             elseif (in_array($type$types_wmedia))
  7214.             {
  7215.                 return 'wmedia';
  7216.             }
  7217.             elseif (in_array($type$types_mp3))
  7218.             {
  7219.                 return 'mp3';
  7220.             }
  7221.             else
  7222.             {
  7223.                 return null;
  7224.             }
  7225.         }
  7226.         else
  7227.         {
  7228.             return $type;
  7229.         }
  7230.     }
  7231. }
  7232.  
  7233. {
  7234.     var $type;
  7235.     var $lang;
  7236.     var $startTime;
  7237.     var $endTime;
  7238.     var $text;
  7239.  
  7240.     // Constructor, used to input the data
  7241.     function SimplePie_Caption($type null$lang null$startTime null$endTime null$text null)
  7242.     {
  7243.         $this->type = $type;
  7244.         $this->lang = $lang;
  7245.         $this->startTime = $startTime;
  7246.         $this->endTime = $endTime;
  7247.         $this->text = $text;
  7248.     }
  7249.  
  7250.     function __toString()
  7251.     {
  7252.         // There is no $this->data here
  7253.         return md5(serialize($this));
  7254.     }
  7255.  
  7256.     function get_endtime()
  7257.     {
  7258.         if ($this->endTime !== null)
  7259.         {
  7260.             return $this->endTime;
  7261.         }
  7262.         else
  7263.         {
  7264.             return null;
  7265.         }
  7266.     }
  7267.  
  7268.     function get_language()
  7269.     {
  7270.         if ($this->lang !== null)
  7271.         {
  7272.             return $this->lang;
  7273.         }
  7274.         else
  7275.         {
  7276.             return null;
  7277.         }
  7278.     }
  7279.  
  7280.     function get_starttime()
  7281.     {
  7282.         if ($this->startTime !== null)
  7283.         {
  7284.             return $this->startTime;
  7285.         }
  7286.         else
  7287.         {
  7288.             return null;
  7289.         }
  7290.     }
  7291.  
  7292.     function get_text()
  7293.     {
  7294.         if ($this->text !== null)
  7295.         {
  7296.             return $this->text;
  7297.         }
  7298.         else
  7299.         {
  7300.             return null;
  7301.         }
  7302.     }
  7303.  
  7304.     function get_type()
  7305.     {
  7306.         if ($this->type !== null)
  7307.         {
  7308.             return $this->type;
  7309.         }
  7310.         else
  7311.         {
  7312.             return null;
  7313.         }
  7314.     }
  7315. }
  7316.  
  7317. {
  7318.     var $role;
  7319.     var $scheme;
  7320.     var $name;
  7321.  
  7322.     // Constructor, used to input the data
  7323.     function SimplePie_Credit($role null$scheme null$name null)
  7324.     {
  7325.         $this->role = $role;
  7326.         $this->scheme = $scheme;
  7327.         $this->name = $name;
  7328.     }
  7329.  
  7330.     function __toString()
  7331.     {
  7332.         // There is no $this->data here
  7333.         return md5(serialize($this));
  7334.     }
  7335.  
  7336.     function get_role()
  7337.     {
  7338.         if ($this->role !== null)
  7339.         {
  7340.             return $this->role;
  7341.         }
  7342.         else
  7343.         {
  7344.             return null;
  7345.         }
  7346.     }
  7347.  
  7348.     function get_scheme()
  7349.     {
  7350.         if ($this->scheme !== null)
  7351.         {
  7352.             return $this->scheme;
  7353.         }
  7354.         else
  7355.         {
  7356.             return null;
  7357.         }
  7358.     }
  7359.  
  7360.     function get_name()
  7361.     {
  7362.         if ($this->name !== null)
  7363.         {
  7364.             return $this->name;
  7365.         }
  7366.         else
  7367.         {
  7368.             return null;
  7369.         }
  7370.     }
  7371. }
  7372.  
  7373. {
  7374.     var $url;
  7375.     var $label;
  7376.  
  7377.     // Constructor, used to input the data
  7378.     function SimplePie_Copyright($url null$label null)
  7379.     {
  7380.         $this->url = $url;
  7381.         $this->label = $label;
  7382.     }
  7383.  
  7384.     function __toString()
  7385.     {
  7386.         // There is no $this->data here
  7387.         return md5(serialize($this));
  7388.     }
  7389.  
  7390.     function get_url()
  7391.     {
  7392.         if ($this->url !== null)
  7393.         {
  7394.             return $this->url;
  7395.         }
  7396.         else
  7397.         {
  7398.             return null;
  7399.         }
  7400.     }
  7401.  
  7402.     function get_attribution()
  7403.     {
  7404.         if ($this->label !== null)
  7405.         {
  7406.             return $this->label;
  7407.         }
  7408.         else
  7409.         {
  7410.             return null;
  7411.         }
  7412.     }
  7413. }
  7414.  
  7415. {
  7416.     var $scheme;
  7417.     var $value;
  7418.  
  7419.     // Constructor, used to input the data
  7420.     function SimplePie_Rating($scheme null$value null)
  7421.     {
  7422.         $this->scheme = $scheme;
  7423.         $this->value = $value;
  7424.     }
  7425.  
  7426.     function __toString()
  7427.     {
  7428.         // There is no $this->data here
  7429.         return md5(serialize($this));
  7430.     }
  7431.  
  7432.     function get_scheme()
  7433.     {
  7434.         if ($this->scheme !== null)
  7435.         {
  7436.             return $this->scheme;
  7437.         }
  7438.         else
  7439.         {
  7440.             return null;
  7441.         }
  7442.     }
  7443.  
  7444.     function get_value()
  7445.     {
  7446.         if ($this->value !== null)
  7447.         {
  7448.             return $this->value;
  7449.         }
  7450.         else
  7451.         {
  7452.             return null;
  7453.         }
  7454.     }
  7455. }
  7456.  
  7457. {
  7458.     var $relationship;
  7459.     var $type;
  7460.     var $value;
  7461.  
  7462.     // Constructor, used to input the data
  7463.     function SimplePie_Restriction($relationship null$type null$value null)
  7464.     {
  7465.         $this->relationship = $relationship;
  7466.         $this->type = $type;
  7467.         $this->value = $value;
  7468.     }
  7469.  
  7470.     function __toString()
  7471.     {
  7472.         // There is no $this->data here
  7473.         return md5(serialize($this));
  7474.     }
  7475.  
  7476.     function get_relationship()
  7477.     {
  7478.         if ($this->relationship !== null)
  7479.         {
  7480.             return $this->relationship;
  7481.         }
  7482.         else
  7483.         {
  7484.             return null;
  7485.         }
  7486.     }
  7487.  
  7488.     function get_type()
  7489.     {
  7490.         if ($this->type !== null)
  7491.         {
  7492.             return $this->type;
  7493.         }
  7494.         else
  7495.         {
  7496.             return null;
  7497.         }
  7498.     }
  7499.  
  7500.     function get_value()
  7501.     {
  7502.         if ($this->value !== null)
  7503.         {
  7504.             return $this->value;
  7505.         }
  7506.         else
  7507.         {
  7508.             return null;
  7509.         }
  7510.     }
  7511. }
  7512.  
  7513. /**
  7514.  * @todo Move to properly supporting RFC2616 (HTTP/1.1)
  7515.  */
  7516. {
  7517.     var $url;
  7518.     var $useragent;
  7519.     var $success = true;
  7520.     var $headers = array();
  7521.     var $body;
  7522.     var $status_code;
  7523.     var $redirects = 0;
  7524.     var $error;
  7525.     var $method = SIMPLEPIE_FILE_SOURCE_NONE;
  7526.  
  7527.     function SimplePie_File($url$timeout 10$redirects 5$headers null$useragent null$force_fsockopen false)
  7528.     {
  7529.         if (class_exists('idna_convert'))
  7530.         {
  7531.             $idn =new idna_convert;
  7532.             $parsed SimplePie_Misc::parse_url($url);
  7533.             $url SimplePie_Misc::compress_parse_url($parsed['scheme']$idn->encode($parsed['authority'])$parsed['path']$parsed['query']$parsed['fragment']);
  7534.         }
  7535.         $this->url = $url;
  7536.         $this->useragent = $useragent;
  7537.         if (preg_match('/^http(s)?:\/\//i'$url))
  7538.         {
  7539.             if ($useragent === null)
  7540.             {
  7541.                 $useragent ini_get('user_agent');
  7542.                 $this->useragent = $useragent;
  7543.             }
  7544.             if (!is_array($headers))
  7545.             {
  7546.                 $headers array();
  7547.             }
  7548.             if (!$force_fsockopen && function_exists('curl_exec'))
  7549.             {
  7550.                 $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE SIMPLEPIE_FILE_SOURCE_CURL;
  7551.                 $fp curl_init();
  7552.                 $headers2 array();
  7553.                 foreach ($headers as $key => $value)
  7554.                 {
  7555.                     $headers2["$key$value";
  7556.                 }
  7557.                 if (version_compare(SimplePie_Misc::get_curl_version()'7.10.5''>='))
  7558.                 {
  7559.                     curl_setopt($fpCURLOPT_ENCODING'');
  7560.                 }
  7561.                 curl_setopt($fpCURLOPT_URL$url);
  7562.                 curl_setopt($fpCURLOPT_HEADER1);
  7563.                 curl_setopt($fpCURLOPT_RETURNTRANSFER1);
  7564.                 curl_setopt($fpCURLOPT_TIMEOUT$timeout);
  7565.                 curl_setopt($fpCURLOPT_CONNECTTIMEOUT$timeout);
  7566.                 curl_setopt($fpCURLOPT_REFERER$url);
  7567.                 curl_setopt($fpCURLOPT_USERAGENT$useragent);
  7568.                 curl_setopt($fpCURLOPT_HTTPHEADER$headers2);
  7569.                 if (!ini_get('open_basedir'&& !ini_get('safe_mode'&& version_compare(SimplePie_Misc::get_curl_version()'7.15.2''>='))
  7570.                 {
  7571.                     curl_setopt($fpCURLOPT_FOLLOWLOCATION1);
  7572.                     curl_setopt($fpCURLOPT_MAXREDIRS$redirects);
  7573.                 }
  7574.  
  7575.                 $this->headers = curl_exec($fp);
  7576.                 if (curl_errno($fp== 23 || curl_errno($fp== 61)
  7577.                 {
  7578.                     curl_setopt($fpCURLOPT_ENCODING'none');
  7579.                     $this->headers = curl_exec($fp);
  7580.                 }
  7581.                 if (curl_errno($fp))
  7582.                 {
  7583.                     $this->error = 'cURL error ' curl_errno($fp': ' curl_error($fp);
  7584.                     $this->success = false;
  7585.                 }
  7586.                 else
  7587.                 {
  7588.                     $info curl_getinfo($fp);
  7589.                     curl_close($fp);
  7590.                     $this->headers = explode("\r\n\r\n"$this->headers$info['redirect_count'1);
  7591.                     $this->headers = array_pop($this->headers);
  7592.                     $parser =new SimplePie_HTTP_Parser($this->headers);
  7593.                     if ($parser->parse())
  7594.                     {
  7595.                         $this->headers = $parser->headers;
  7596.                         $this->body = $parser->body;
  7597.                         $this->status_code = $parser->status_code;
  7598.                         if (($this->status_code == 300 || $this->status_code == 301 || $this->status_code == 302 || $this->status_code == 303 || $this->status_code == 307 || $this->status_code > 307 && $this->status_code < 400&& isset($this->headers['location']&& $this->redirects < $redirects)
  7599.                         {
  7600.                             $this->redirects++;
  7601.                             $location SimplePie_Misc::absolutize_url($this->headers['location']$url);
  7602.                             return $this->SimplePie_File($location$timeout$redirects$headers$useragent$force_fsockopen);
  7603.                         }
  7604.                     }
  7605.                 }
  7606.             }
  7607.             else
  7608.             {
  7609.                 $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
  7610.                 $url_parts parse_url($url);
  7611.                 if (isset($url_parts['scheme']&& strtolower($url_parts['scheme']== 'https')
  7612.                 {
  7613.                     $url_parts['host'"ssl://$url_parts[host]";
  7614.                     $url_parts['port'443;
  7615.                 }
  7616.                 if (!isset($url_parts['port']))
  7617.                 {
  7618.                     $url_parts['port'80;
  7619.                 }
  7620.                 $fp @fsockopen($url_parts['host']$url_parts['port']$errno$errstr$timeout);
  7621.                 if (!$fp)
  7622.                 {
  7623.                     $this->error = 'fsockopen error: ' $errstr;
  7624.                     $this->success = false;
  7625.                 }
  7626.                 else
  7627.                 {
  7628.                     stream_set_timeout($fp$timeout);
  7629.                     if (isset($url_parts['path']))
  7630.                     {
  7631.                         if (isset($url_parts['query']))
  7632.                         {
  7633.                             $get "$url_parts[path]?$url_parts[query]";
  7634.                         }
  7635.                         else
  7636.                         {
  7637.                             $get $url_parts['path'];
  7638.                         }
  7639.                     }
  7640.                     else
  7641.                     {
  7642.                         $get '/';
  7643.                     }
  7644.                     $out "GET $get HTTP/1.0\r\n";
  7645.                     $out .= "Host: $url_parts[host]\r\n";
  7646.                     $out .= "User-Agent: $useragent\r\n";
  7647.                     if (function_exists('gzinflate'))
  7648.                     {
  7649.                         $out .= "Accept-Encoding: gzip,deflate\r\n";
  7650.                     }
  7651.  
  7652.                     if (isset($url_parts['user']&& isset($url_parts['pass']))
  7653.                     {
  7654.                         $out .= "Authorization: Basic " base64_encode("$url_parts[user]:$url_parts[pass]""\r\n";
  7655.                     }
  7656.                     foreach ($headers as $key => $value)
  7657.                     {
  7658.                         $out .= "$key$value\r\n";
  7659.                     }
  7660.                     $out .= "Connection: Close\r\n\r\n";
  7661.                     fwrite($fp$out);
  7662.  
  7663.                     $info stream_get_meta_data($fp);
  7664.  
  7665.                     $this->headers = '';
  7666.                     while (!$info['eof'&& !$info['timed_out'])
  7667.                     {
  7668.                         $this->headers .= fread($fp1160);
  7669.                         $info stream_get_meta_data($fp);
  7670.                     }
  7671.                     if (!$info['timed_out'])
  7672.                     {
  7673.                         $parser =new SimplePie_HTTP_Parser($this->headers);
  7674.                         if ($parser->parse())
  7675.                         {
  7676.                             $this->headers = $parser->headers;
  7677.                             $this->body = $parser->body;
  7678.                             $this->status_code = $parser->status_code;
  7679.                             if (($this->status_code == 300 || $this->status_code == 301 || $this->status_code == 302 || $this->status_code == 303 || $this->status_code == 307 || $this->status_code > 307 && $this->status_code < 400&& isset($this->headers['location']&& $this->redirects < $redirects)
  7680.                             {
  7681.                                 $this->redirects++;
  7682.                                 $location SimplePie_Misc::absolutize_url($this->headers['location']$url);
  7683.                                 return $this->SimplePie_File($location$timeout$redirects$headers$useragent$force_fsockopen);
  7684.                             }
  7685.                             if (isset($this->headers['content-encoding']&& ($this->headers['content-encoding'== 'gzip' || $this->headers['content-encoding'== 'deflate'))
  7686.                             {
  7687.                                 if (substr($this->body08== "\x1f\x8b\x08\x00\x00\x00\x00\x00")
  7688.                                 {
  7689.                                     $this->body = substr($this->body10);
  7690.                                 }
  7691.                                 $this->body = gzinflate($this->body);
  7692.                             }
  7693.                         }
  7694.                     }
  7695.                     else
  7696.                     {
  7697.                         $this->error = 'fsocket timed out';
  7698.                         $this->success = false;
  7699.                     }
  7700.                     fclose($fp);
  7701.                 }
  7702.             }
  7703.         }
  7704.         else
  7705.         {
  7706.             if (!$this->body = file_get_contents($url))
  7707.             {
  7708.                 $this->error = 'file_get_contents could not read the file';
  7709.                 $this->success = false;
  7710.             }
  7711.         }
  7712.     }
  7713. }
  7714.  
  7715. /**
  7716.  * HTTP Response Parser
  7717.  *
  7718.  * @package SimplePie
  7719.  */
  7720. {
  7721.     /**
  7722.      * HTTP Version
  7723.      *
  7724.      * @access public
  7725.      * @var float 
  7726.      */
  7727.     var $http_version = 0.0;
  7728.  
  7729.     /**
  7730.      * Status code
  7731.      *
  7732.      * @access public
  7733.      * @var int 
  7734.      */
  7735.     var $status_code = 0;
  7736.  
  7737.     /**
  7738.      * Reason phrase
  7739.      *
  7740.      * @access public
  7741.      * @var string 
  7742.      */
  7743.     var $reason = '';
  7744.  
  7745.     /**
  7746.      * Key/value pairs of the headers
  7747.      *
  7748.      * @access public
  7749.      * @var array 
  7750.      */
  7751.     var $headers = array();
  7752.  
  7753.     /**
  7754.      * Body of the response
  7755.      *
  7756.      * @access public
  7757.      * @var string 
  7758.      */
  7759.     var $body = '';
  7760.  
  7761.     /**
  7762.      * Current state of the state machine
  7763.      *
  7764.      * @access private
  7765.      * @var string 
  7766.      */
  7767.     var $state 'http_version';
  7768.  
  7769.     /**
  7770.      * Input data
  7771.      *
  7772.      * @access private
  7773.      * @var string 
  7774.      */
  7775.     var $data '';
  7776.  
  7777.     /**
  7778.      * Input data length (to avoid calling strlen() everytime this is needed)
  7779.      *
  7780.      * @access private
  7781.      * @var int 
  7782.      */
  7783.     var $data_length 0;
  7784.  
  7785.     /**
  7786.      * Current position of the pointer
  7787.      *
  7788.      * @var int 
  7789.      * @access private
  7790.      */
  7791.     var $position 0;
  7792.  
  7793.     /**
  7794.      * Name of the hedaer currently being parsed
  7795.      *
  7796.      * @access private
  7797.      * @var string 
  7798.      */
  7799.     var $name '';
  7800.  
  7801.     /**
  7802.      * Value of the hedaer currently being parsed
  7803.      *
  7804.      * @access private
  7805.      * @var string 
  7806.      */
  7807.     var $value '';
  7808.  
  7809.     /**
  7810.      * Create an instance of the class with the input data
  7811.      *
  7812.      * @access public
  7813.      * @param string $data Input data
  7814.      */
  7815.     function SimplePie_HTTP_Parser($data)
  7816.     {
  7817.         $this->data $data;
  7818.         $this->data_length strlen($this->data);
  7819.     }
  7820.  
  7821.     /**
  7822.      * Parse the input data
  7823.      *
  7824.      * @access public
  7825.      * @return bool true on success, false on failure
  7826.      */
  7827.     function parse()
  7828.     {
  7829.         while ($this->state && $this->state !== 'emit' && $this->has_data())
  7830.         {
  7831.             $state $this->state;
  7832.             $this->$state();
  7833.         }
  7834.         $this->data '';
  7835.         if ($this->state === 'emit')
  7836.         {
  7837.             return true;
  7838.         }
  7839.         else
  7840.         {
  7841.             $this->http_version = '';
  7842.             $this->status_code = '';
  7843.             $this->reason = '';
  7844.             $this->headers = array();
  7845.             $this->body = '';
  7846.             return false;
  7847.         }
  7848.     }
  7849.  
  7850.     /**
  7851.      * Check whether there is data beyond the pointer
  7852.      *
  7853.      * @access private
  7854.      * @return bool true if there is further data, false if not
  7855.      */
  7856.     function has_data()
  7857.     {
  7858.         return (bool) ($this->position $this->data_length);
  7859.     }
  7860.  
  7861.     /**
  7862.      * See if the next character is LWS
  7863.      *
  7864.      * @access private
  7865.      * @return bool true if the next character is LWS, false if not
  7866.      */
  7867.     function is_linear_whitespace()
  7868.     {
  7869.         return (bool) ($this->data[$this->position=== "\x09"
  7870.             || $this->data[$this->position=== "\x20"
  7871.             || ($this->data[$this->position=== "\x0A"
  7872.                 && isset($this->data[$this->position 1])
  7873.                 && ($this->data[$this->position 1=== "\x09" || $this->data[$this->position 1=== "\x20")));
  7874.     }
  7875.  
  7876.     /**
  7877.      * Parse the HTTP version
  7878.      *
  7879.      * @access private
  7880.      */
  7881.     function http_version()
  7882.     {
  7883.         if (strpos($this->data"\x0A"!== false && strtoupper(substr($this->data05)) === 'HTTP/')
  7884.         {
  7885.             $len strspn($this->data'0123456789.'5);
  7886.             $this->http_version = substr($this->data5$len);
  7887.             $this->position += $len;
  7888.             if (substr_count($this->http_version'.'<= 1)
  7889.             {
  7890.                 $this->http_version = (float) $this->http_version;
  7891.                 $this->position += strspn($this->data"\x09\x20"$this->position);
  7892.                 $this->state 'status';
  7893.             }
  7894.             else
  7895.             {
  7896.                 $this->state false;
  7897.             }
  7898.         }
  7899.         else
  7900.         {
  7901.             $this->state false;
  7902.         }
  7903.     }
  7904.  
  7905.     /**
  7906.      * Parse the status code
  7907.      *
  7908.      * @access private
  7909.      */
  7910.     function status()
  7911.     {
  7912.         if ($len strspn($this->data'0123456789'$this->position))
  7913.         {
  7914.             $this->status_code = (int) substr($this->data$this->position$len);
  7915.             $this->position += $len;
  7916.             $this->state 'reason';
  7917.         }
  7918.         else
  7919.         {
  7920.             $this->state false;
  7921.         }
  7922.     }
  7923.  
  7924.     /**
  7925.      * Parse the reason phrase
  7926.      *
  7927.      * @access private
  7928.      */
  7929.     function reason()
  7930.     {
  7931.         $len strcspn($this->data"\x0A"$this->position);
  7932.         $this->reason = trim(substr($this->data$this->position$len)"\x09\x0D\x20");
  7933.         $this->position += $len 1;
  7934.         $this->state 'new_line';
  7935.     }
  7936.  
  7937.     /**
  7938.      * Deal with a new line, shifting data around as needed
  7939.      *
  7940.      * @access private
  7941.      */
  7942.     function new_line()
  7943.     {
  7944.         $this->value trim($this->value"\x0D\x20");
  7945.         if ($this->name !== '' && $this->value !== '')
  7946.         {
  7947.             $this->name strtolower($this->name);
  7948.             if (isset($this->headers[$this->name]))
  7949.             {
  7950.                 $this->headers[$this->name.= ', ' $this->value;
  7951.             }
  7952.             else
  7953.             {
  7954.                 $this->headers[$this->name$this->value;
  7955.             }
  7956.         }
  7957.         $this->name '';
  7958.         $this->value '';
  7959.         if (substr($this->data[$this->position]02=== "\x0D\x0A")
  7960.         {
  7961.             $this->position += 2;
  7962.             $this->state 'body';
  7963.         }
  7964.         elseif ($this->data[$this->position=== "\x0A")
  7965.         {
  7966.             $this->position++;
  7967.             $this->state 'body';
  7968.         }
  7969.         else
  7970.         {
  7971.             $this->state 'name';
  7972.         }
  7973.     }
  7974.  
  7975.     /**
  7976.      * Parse a header name
  7977.      *
  7978.      * @access private
  7979.      */
  7980.     function name()
  7981.     {
  7982.         $len strcspn($this->data"\x0A:"$this->position);
  7983.         if (isset($this->data[$this->position $len]))
  7984.         {
  7985.             if ($this->data[$this->position $len=== "\x0A")
  7986.             {
  7987.                 $this->position += $len;
  7988.                 $this->state 'new_line';
  7989.             }
  7990.             else
  7991.             {
  7992.                 $this->name substr($this->data$this->position$len);
  7993.                 $this->position += $len 1;
  7994.                 $this->state 'value';
  7995.             }
  7996.         }
  7997.         else
  7998.         {
  7999.             $this->state false;
  8000.         }
  8001.     }
  8002.  
  8003.     /**
  8004.      * Parse LWS, replacing consecutive LWS characters with a single space
  8005.      *
  8006.      * @access private
  8007.      */
  8008.     function linear_whitespace()
  8009.     {
  8010.         do
  8011.         {
  8012.             if (substr($this->data$this->position2=== "\x0D\x0A")
  8013.             {
  8014.                 $this->position += 2;
  8015.             }
  8016.             elseif ($this->data[$this->position=== "\x0A")
  8017.             {
  8018.                 $this->position++;
  8019.             }
  8020.             $this->position += strspn($this->data"\x09\x20"$this->position);
  8021.         while ($this->has_data(&& $this->is_linear_whitespace());
  8022.         $this->value .= "\x20";
  8023.     }
  8024.  
  8025.     /**
  8026.      * See what state to move to while within non-quoted header values
  8027.      *
  8028.      * @access private
  8029.      */
  8030.     function value()
  8031.     {
  8032.         if ($this->is_linear_whitespace())
  8033.         {
  8034.             $this->linear_whitespace();
  8035.         }
  8036.         else
  8037.         {
  8038.             switch ($this->data[$this->position])
  8039.             {
  8040.                 case '"':
  8041.                     $this->position++;
  8042.                     $this->state 'quote';
  8043.                     break;
  8044.  
  8045.                 case "\x0A":
  8046.                     $this->position++;
  8047.                     $this->state 'new_line';
  8048.                     break;
  8049.  
  8050.                 default:
  8051.                     $this->state 'value_char';
  8052.                     break;
  8053.             }
  8054.         }
  8055.     }
  8056.  
  8057.     /**
  8058.      * Parse a header value while outside quotes
  8059.      *
  8060.      * @access private
  8061.      */
  8062.     function value_char()
  8063.     {
  8064.         $len strcspn($this->data"\x09\x20\x0A\""$this->position);
  8065.         $this->value .= substr($this->data$this->position$len);
  8066.         $this->position += $len;
  8067.         $this->state 'value';
  8068.     }
  8069.  
  8070.     /**
  8071.      * See what state to move to while within quoted header values
  8072.      *
  8073.      * @access private
  8074.      */
  8075.     function quote()
  8076.     {
  8077.         if ($this->is_linear_whitespace())
  8078.         {
  8079.             $this->linear_whitespace();
  8080.         }
  8081.         else
  8082.         {
  8083.             switch ($this->data[$this->position])
  8084.             {
  8085.                 case '"':
  8086.                     $this->position++;
  8087.                     $this->state 'value';
  8088.                     break;
  8089.  
  8090.                 case "\x0A":
  8091.                     $this->position++;
  8092.                     $this->state 'new_line';
  8093.                     break;
  8094.  
  8095.                 case '\\':
  8096.                     $this->position++;
  8097.                     $this->state 'quote_escaped';
  8098.                     break;
  8099.  
  8100.                 default:
  8101.                     $this->state 'quote_char';
  8102.                     break;
  8103.             }
  8104.         }
  8105.     }
  8106.  
  8107.     /**
  8108.      * Parse a header value while within quotes
  8109.      *
  8110.      * @access private
  8111.      */
  8112.     function quote_char()
  8113.     {
  8114.         $len strcspn($this->data"\x09\x20\x0A\"\\"$this->position);
  8115.         $this->value .= substr($this->data$this->position$len);
  8116.         $this->position += $len;
  8117.         $this->state 'value';
  8118.     }
  8119.  
  8120.     /**
  8121.      * Parse an escaped character within quotes
  8122.      *
  8123.      * @access private
  8124.      */
  8125.     function quote_escaped()
  8126.     {
  8127.         $this->value .= $this->data[$this->position];
  8128.         $this->position++;
  8129.         $this->state 'quote';
  8130.     }
  8131.  
  8132.     /**
  8133.      * Parse the body
  8134.      *
  8135.      * @access private
  8136.      */
  8137.     function body()
  8138.     {
  8139.         $this->body = substr($this->data$this->position);
  8140.         $this->state 'emit';
  8141.     }
  8142. }
  8143.  
  8144. {
  8145.     /**
  8146.      * Don't call the constructor. Please.
  8147.      *
  8148.      * @access private
  8149.      */
  8150.     function SimplePie_Cache()
  8151.     {
  8152.         trigger_error('Please call SimplePie_Cache::create() instead of the constructor'E_USER_ERROR);
  8153.     }
  8154.  
  8155.     /**
  8156.      * Create a new SimplePie_Cache object
  8157.      *
  8158.      * @static
  8159.      * @access public
  8160.      */
  8161.     function create($location$filename$extension)
  8162.     {
  8163.         return new SimplePie_Cache_File($location$filename$extension);
  8164.     }
  8165. }
  8166.  
  8167. {
  8168.     var $location;
  8169.     var $filename;
  8170.     var $extension;
  8171.     var $name;
  8172.  
  8173.     function SimplePie_Cache_File($location$filename$extension)
  8174.     {
  8175.         $this->location = $location;
  8176.         $this->filename = rawurlencode($filename);
  8177.         $this->extension = rawurlencode($extension);
  8178.         $this->name = "$location/$this->filename.$this->extension";
  8179.     }
  8180.  
  8181.     function save($data)
  8182.     {
  8183.         if (file_exists($this->name&& is_writeable($this->name|| file_exists($this->location&& is_writeable($this->location))
  8184.         {
  8185.             if (is_a($data'SimplePie'))
  8186.             {
  8187.                 $data $data->data;
  8188.             }
  8189.  
  8190.             $data serialize($data);
  8191.  
  8192.             if (function_exists('file_put_contents'))
  8193.             {
  8194.                 return (bool) file_put_contents($this->name$data);
  8195.             }
  8196.             else
  8197.             {
  8198.                 $fp fopen($this->name'wb');
  8199.                 if ($fp)
  8200.                 {
  8201.                     fwrite($fp$data);
  8202.                     fclose($fp);
  8203.                     return true;
  8204.                 }
  8205.             }
  8206.         }
  8207.         return false;
  8208.     }
  8209.  
  8210.     function load()
  8211.     {
  8212.         if (file_exists($this->name&& is_readable($this->name))
  8213.         {
  8214.             return unserialize(file_get_contents($this->name));
  8215.         }
  8216.         return false;
  8217.     }
  8218.  
  8219.     function mtime()
  8220.     {
  8221.         if (file_exists($this->name))
  8222.         {
  8223.             return filemtime($this->name);
  8224.         }
  8225.         return false;
  8226.     }
  8227.  
  8228.     function touch()
  8229.     {
  8230.         if (file_exists($this->name))
  8231.         {
  8232.             return touch($this->name);
  8233.         }
  8234.         return false;
  8235.     }
  8236.  
  8237.     function unlink()
  8238.     {
  8239.         if (file_exists($this->name))
  8240.         {
  8241.             return unlink($this->name);
  8242.         }
  8243.         return false;
  8244.     }
  8245. }
  8246.  
  8247. {
  8248.     function time_hms($seconds)
  8249.     {
  8250.         $time '';
  8251.  
  8252.         $hours floor($seconds 3600);
  8253.         $remainder $seconds 3600;
  8254.         if ($hours 0)
  8255.         {
  8256.             $time .= $hours.':';
  8257.         }
  8258.  
  8259.         $minutes floor($remainder 60);
  8260.         $seconds $remainder 60;
  8261.         if ($minutes 10 && $hours 0)
  8262.         {
  8263.             $minutes '0' $minutes;
  8264.         }
  8265.         if ($seconds 10)
  8266.         {
  8267.             $seconds '0' $seconds;
  8268.         }
  8269.  
  8270.         $time .= $minutes.':';
  8271.         $time .= $seconds;
  8272.  
  8273.         return $time;
  8274.     }
  8275.  
  8276.     function absolutize_url($relative$base)
  8277.     {
  8278.         if ($relative !== '')
  8279.         {
  8280.             $relative SimplePie_Misc::parse_url($relative);
  8281.             if ($relative['scheme'!== '')
  8282.             {
  8283.                 $target $relative;
  8284.             }
  8285.             elseif ($base !== '')
  8286.             {
  8287.                 $base SimplePie_Misc::parse_url($base);
  8288.                 $target SimplePie_Misc::parse_url('');
  8289.                 if ($relative['authority'!== '')
  8290.                 {
  8291.                     $target $relative;
  8292.                     $target['scheme'$base['scheme'];
  8293.                 }
  8294.                 else
  8295.                 {
  8296.                     $target['scheme'$base['scheme'];
  8297.                     $target['authority'$base['authority'];
  8298.                     if ($relative['path'!== '')
  8299.                     {
  8300.                         if (strpos($relative['path']'/'=== 0)
  8301.                         {
  8302.                             $target['path'$relative['path'];
  8303.                         }
  8304.                         elseif ($base['authority'!== '' && $base['path'=== '')
  8305.                         {
  8306.                             $target['path''/' $relative['path'];
  8307.                         }
  8308.                         elseif (($last_segment strrpos($base['path']'/')) !== false)
  8309.                         {
  8310.                             $target['path'substr($base['path']0$last_segment 1$relative['path'];
  8311.                         }
  8312.                         else
  8313.                         {
  8314.                             $target['path'$relative['path'];
  8315.                         }
  8316.                         $target['query'$relative['query'];
  8317.                     }
  8318.                     else
  8319.                     {
  8320.                         $target['path'$base['path'];
  8321.                         if ($relative['query'!== '')
  8322.                         {
  8323.                             $target['query'$relative['query'];
  8324.                         }
  8325.                         elseif ($base['query'!== '')
  8326.                         {
  8327.                             $target['query'$base['query'];
  8328.                         }
  8329.                     }
  8330.                 }
  8331.                 $target['fragment'$relative['fragment'];
  8332.             }
  8333.             else
  8334.             {
  8335.                 // No base URL, just return the relative URL
  8336.                 $target $relative;
  8337.             }
  8338.             $return SimplePie_Misc::compress_parse_url($target['scheme']$target['authority']$target['path']$target['query']$target['fragment']);
  8339.         }
  8340.         else
  8341.         {
  8342.             $return $base;
  8343.         }
  8344.         $return SimplePie_Misc::normalize_url($return);
  8345.         return $return;
  8346.     }
  8347.  
  8348.     function remove_dot_segments($input)
  8349.     {
  8350.         $output '';
  8351.         while (strpos($input'./'!== false || strpos($input'/.'!== false || $input == '.' || $input == '..')
  8352.         {
  8353.             // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise,
  8354.             if (strpos($input'../'=== 0)
  8355.             {
  8356.                 $input substr($input3);
  8357.             }
  8358.             elseif (strpos($input'./'=== 0)
  8359.             {
  8360.                 $input substr($input2);
  8361.             }
  8362.             // 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,
  8363.             elseif (strpos($input'/./'=== 0)
  8364.             {
  8365.                 $input substr_replace($input'/'03);
  8366.             }
  8367.             elseif ($input == '/.')
  8368.             {
  8369.                 $input '/';
  8370.             }
  8371.             // 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,
  8372.             elseif (strpos($input'/../'=== 0)
  8373.             {
  8374.                 $input substr_replace($input'/'04);
  8375.                 $output substr_replace($output''strrpos($output'/'));
  8376.             }
  8377.             elseif ($input == '/..')
  8378.             {
  8379.                 $input '/';
  8380.                 $output substr_replace($output''strrpos($output'/'));
  8381.             }
  8382.             // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise,
  8383.             elseif ($input == '.' || $input == '..')
  8384.             {
  8385.                 $input '';
  8386.             }
  8387.             // 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
  8388.             elseif (($pos strpos($input'/'1)) !== false)
  8389.             {
  8390.                 $output .= substr($input0$pos);
  8391.                 $input substr_replace($input''0$pos);
  8392.             }
  8393.             else
  8394.             {
  8395.                 $output .= $input;
  8396.                 $input '';
  8397.             }
  8398.         }
  8399.         return $output $input;
  8400.     }
  8401.  
  8402.     function get_element($realname$string)
  8403.     {
  8404.         $return array();
  8405.         $name preg_quote($realname'/');
  8406.         if (preg_match_all("/<($name)SIMPLEPIE_PCRE_HTML_ATTRIBUTE "(>(.*)<\/$name>|(\/)?>)/siU"$string$matchesPREG_SET_ORDER PREG_OFFSET_CAPTURE))
  8407.         {
  8408.             for ($i 0$total_matches count($matches)$i $total_matches$i++)
  8409.             {
  8410.                 $return[$i]['tag'$realname;
  8411.                 $return[$i]['full'$matches[$i][0][0];
  8412.                 $return[$i]['offset'$matches[$i][0][1];
  8413.                 if (strlen($matches[$i][3][0]<= 2)
  8414.                 {
  8415.                     $return[$i]['self_closing'true;
  8416.                 }
  8417.                 else
  8418.                 {
  8419.                     $return[$i]['self_closing'false;
  8420.                     $return[$i]['content'$matches[$i][4][0];
  8421.                 }
  8422.                 $return[$i]['attribs'array();
  8423.                 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))
  8424.                 {
  8425.                     for ($j 0$total_attribs count($attribs)$j $total_attribs$j++)
  8426.                     {
  8427.                         if (count($attribs[$j]== 2)
  8428.                         {
  8429.                             $attribs[$j][2$attribs[$j][1];
  8430.                         }
  8431.                         $return[$i]['attribs'][strtolower($attribs[$j][1])]['data'SimplePie_Misc::entities_decode(end($attribs[$j])'UTF-8');
  8432.                     }
  8433.                 }
  8434.             }
  8435.         }
  8436.         return $return;
  8437.     }
  8438.  
  8439.     function element_implode($element)
  8440.     {
  8441.         $full "<$element[tag]";
  8442.         foreach ($element['attribs'as $key => $value)
  8443.         {
  8444.             $key strtolower($key);
  8445.             $full .= " $key=\"htmlspecialchars($value['data']'"';
  8446.         }
  8447.         if ($element['self_closing'])
  8448.         {
  8449.             $full .= ' />';
  8450.         }
  8451.         else
  8452.         {
  8453.             $full .= ">$element[content]</$element[tag]>";
  8454.         }
  8455.         return $full;
  8456.     }
  8457.  
  8458.     function error($message$level$file$line)
  8459.     {
  8460.         switch ($level)
  8461.         {
  8462.             case E_USER_ERROR:
  8463.                 $note 'PHP Error';
  8464.                 break;
  8465.             case E_USER_WARNING:
  8466.                 $note 'PHP Warning';
  8467.                 break;
  8468.             case E_USER_NOTICE:
  8469.                 $note 'PHP Notice';
  8470.                 break;
  8471.             default:
  8472.                 $note 'Unknown Error';
  8473.                 break;
  8474.         }
  8475.         error_log("$note$message in $file on line $line"0);
  8476.         return $message;
  8477.     }
  8478.  
  8479.     /**
  8480.      * If a file has been cached, retrieve and display it.
  8481.      *
  8482.      * This is most useful for caching images (get_favicon(), etc.),
  8483.      * however it works for all cached files.  This WILL NOT display ANY
  8484.      * file/image/page/whatever, but rather only display what has already
  8485.      * been cached by SimplePie.
  8486.      *
  8487.      * @access public
  8488.      * @see SimplePie::get_favicon()
  8489.      * @param str $identifier_url URL that is used to identify the content.
  8490.      *  This may or may not be the actual URL of the live content.
  8491.      * @param str $cache_location Location of SimplePie's cache.  Defaults
  8492.      *  to './cache'.
  8493.      * @param str $cache_extension The file extension that the file was
  8494.      *  cached with.  Defaults to 'spc'.
  8495.      * @param str $cache_class Name of the cache-handling class being used
  8496.      *  in SimplePie.  Defaults to 'SimplePie_Cache', and should be left
  8497.      *  as-is unless you've overloaded the class.
  8498.      * @param str $cache_name_function Obsolete. Exists for backwards
  8499.      *  compatibility reasons only.
  8500.      */
  8501.     function display_cached_file($identifier_url$cache_location './cache'$cache_extension 'spc'$cache_class 'SimplePie_Cache'$cache_name_function 'md5')
  8502.     {
  8503.         $cache call_user_func(array($cache_class'create')$cache_location$identifier_url$cache_extension);
  8504.  
  8505.         if ($file $cache->load())
  8506.         {
  8507.             if (isset($file['headers']['content-type']))
  8508.             {
  8509.                 header('Content-type:' $file['headers']['content-type']);
  8510.             }
  8511.             else
  8512.             {
  8513.                 header('Content-type: application/octet-stream');
  8514.             }
  8515.             header('Expires: ' gmdate('D, d M Y H:i:s'time(604800' GMT')// 7 days
  8516.             echo $file['body'];
  8517.             exit;
  8518.         }
  8519.  
  8520.         die('Cached file for ' $identifier_url ' cannot be found.');
  8521.     }
  8522.  
  8523.     function fix_protocol($url$http 1)
  8524.     {
  8525.         $url SimplePie_Misc::normalize_url($url);
  8526.         $parsed SimplePie_Misc::parse_url($url);
  8527.         if ($parsed['scheme'!== '' && $parsed['scheme'!= 'http' && $parsed['scheme'!= 'https')
  8528.         {
  8529.             return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http'$parsed['authority']$parsed['path']$parsed['query']$parsed['fragment'])$http);
  8530.         }
  8531.  
  8532.         if ($parsed['scheme'=== '' && $parsed['authority'=== '' && !file_exists($url))
  8533.         {
  8534.             return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http'$parsed['path']''$parsed['query']$parsed['fragment'])$http);
  8535.         }
  8536.  
  8537.         if ($http == && $parsed['scheme'!== '')
  8538.         {
  8539.             return "feed:$url";
  8540.         }
  8541.         elseif ($http == && strtolower($parsed['scheme']== 'http')
  8542.         {
  8543.             return substr_replace($url'podcast'04);
  8544.         }
  8545.         elseif ($http == && strtolower($parsed['scheme']== 'http')
  8546.         {
  8547.             return substr_replace($url'itpc'04);
  8548.         }
  8549.         else
  8550.         {
  8551.             return $url;
  8552.         }
  8553.     }
  8554.  
  8555.     function parse_url($url)
  8556.     {
  8557.         static $cache array();
  8558.         if (isset($cache[$url]))
  8559.         {
  8560.             return $cache[$url];
  8561.         }
  8562.         elseif (preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/'$url$match))
  8563.         {
  8564.             for ($i count($match)$i <= 9$i++)
  8565.             {
  8566.                 $match[$i'';
  8567.             }
  8568.             return $cache[$urlarray('scheme' => $match[2]'authority' => $match[4]'path' => $match[5]'query' => $match[7]'fragment' => $match[9]);
  8569.         }
  8570.         else
  8571.         {
  8572.             return $cache[$urlarray('scheme' => '''authority' => '''path' => '''query' => '''fragment' => '');
  8573.         }
  8574.     }
  8575.  
  8576.     function compress_parse_url($scheme ''$authority ''$path ''$query ''$fragment '')
  8577.     {
  8578.         $return '';
  8579.         if ($scheme !== '')
  8580.         {
  8581.             $return .= "$scheme:";
  8582.         }
  8583.         if ($authority !== '')
  8584.         {
  8585.             $return .= "//$authority";
  8586.         }
  8587.         if ($path !== '')
  8588.         {
  8589.             $return .= $path;
  8590.         }
  8591.         if ($query !== '')
  8592.         {
  8593.             $return .= "?$query";
  8594.         }
  8595.         if ($fragment !== '')
  8596.         {
  8597.             $return .= "#$fragment";
  8598.         }
  8599.         return $return;
  8600.     }
  8601.  
  8602.     function normalize_url($url)
  8603.     {
  8604.         $url preg_replace_callback('/%([0-9A-Fa-f]{2})/'array('SimplePie_Misc''percent_encoding_normalization')$url);
  8605.         $url SimplePie_Misc::parse_url($url);
  8606.         $url['scheme'strtolower($url['scheme']);
  8607.         if ($url['authority'!== '')
  8608.         {
  8609.             $url['authority'strtolower($url['authority']);
  8610.             $url['path'SimplePie_Misc::remove_dot_segments($url['path']);
  8611.         }
  8612.         return SimplePie_Misc::compress_parse_url($url['scheme']$url['authority']$url['path']$url['query']$url['fragment']);
  8613.     }
  8614.  
  8615.     function percent_encoding_normalization($match)
  8616.     {
  8617.         $integer hexdec($match[1]);
  8618.         if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer == 0x2D || $integer == 0x2E || $integer == 0x5F || $integer == 0x7E)
  8619.         {
  8620.             return chr($integer);
  8621.         }
  8622.         else
  8623.         {
  8624.             return strtoupper($match[0]);
  8625.         }
  8626.     }
  8627.  
  8628.     /**
  8629.      * Remove bad UTF-8 bytes
  8630.      *
  8631.      * PCRE Pattern to locate bad bytes in a UTF-8 string comes from W3C
  8632.      * FAQ: Multilingual Forms (modified to include full ASCII range)
  8633.      *
  8634.      * @author Geoffrey Sneddon
  8635.      * @see http://www.w3.org/International/questions/qa-forms-utf-8
  8636.      * @param string $str String to remove bad UTF-8 bytes from
  8637.      * @return string UTF-8 string
  8638.      */
  8639.     function utf8_bad_replace($str)
  8640.     {
  8641.         if (function_exists('iconv'&& ($return @iconv('UTF-8''UTF-8//IGNORE'$str)))
  8642.         {
  8643.             return $return;
  8644.         }
  8645.         elseif (function_exists('mb_convert_encoding'&& ($return @mb_convert_encoding($str'UTF-8''UTF-8')))
  8646.         {
  8647.             return $return;
  8648.         }
  8649.         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))
  8650.         {
  8651.             return implode("\xEF\xBF\xBD"$matches[0]);
  8652.         }
  8653.         elseif ($str !== '')
  8654.         {
  8655.             return "\xEF\xBF\xBD";
  8656.         }
  8657.         else
  8658.         {
  8659.             return '';
  8660.         }
  8661.     }
  8662.     
  8663.     /**
  8664.      * Converts a Windows-1252 encoded string to a UTF-8 encoded string
  8665.      *
  8666.      * @static
  8667.      * @access public
  8668.      * @param string $string Windows-1252 encoded string
  8669.      * @return string UTF-8 encoded string
  8670.      */
  8671.     function windows_1252_to_utf8($string)
  8672.     {
  8673.         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");
  8674.         
  8675.         return strtr($string$convert_table);
  8676.     }
  8677.  
  8678.     function change_encoding($data$input$output)
  8679.     {
  8680.         $input SimplePie_Misc::encoding($input);
  8681.         $output SimplePie_Misc::encoding($output);
  8682.         
  8683.         // We fail to fail on non US-ASCII bytes
  8684.         if ($input === 'US-ASCII')
  8685.         {
  8686.             static $non_ascii_octects '';
  8687.             if (!$non_ascii_octects)
  8688.             {
  8689.                 for ($i 0x80$i <= 0xFF$i++)
  8690.                 {
  8691.                     $non_ascii_octects .= chr($i);
  8692.                 }
  8693.             }
  8694.             $data substr($data0strcspn($data$non_ascii_octects));
  8695.         }
  8696.  
  8697.         if (function_exists('iconv'&& ($return @iconv($input$output$data)))
  8698.         {
  8699.             return $return;
  8700.         }
  8701.         elseif (function_exists('mb_convert_encoding'&& ($return @mb_convert_encoding($data$output$input)))
  8702.         {
  8703.             return $return;
  8704.         }
  8705.         elseif ($input == 'windows-1252' && $output == 'UTF-8')
  8706.         {
  8707.             return SimplePie_Misc::windows_1252_to_utf8($data);
  8708.         }
  8709.         elseif ($input == 'UTF-8' && $output == 'windows-1252')
  8710.         {
  8711.             return utf8_decode($data);
  8712.         }
  8713.         return $data;
  8714.     }
  8715.  
  8716.     function encoding($encoding)
  8717.     {
  8718.         // Character sets are case-insensitive (though we'll return them in the form given in their registration)
  8719.         switch (strtoupper($encoding))
  8720.         {
  8721.             case 'ANSI_X3.110-1983':
  8722.             case 'CSA_T500-1983':
  8723.             case 'CSISO99NAPLPS':
  8724.             case 'ISO-IR-99':
  8725.             case 'NAPLPS':
  8726.                 return 'ANSI_X3.110-1983';
  8727.     
  8728.             case 'ARABIC7':
  8729.             case 'ASMO_449':
  8730.             case 'CSISO89ASMO449':
  8731.             case 'ISO-IR-89':
  8732.             case 'ISO_9036':
  8733.                 return 'ASMO_449';
  8734.     
  8735.             case 'ADOBE-STANDARD-ENCODING':
  8736.             case 'CSADOBESTANDARDENCODING':
  8737.                 return 'Adobe-Standard-Encoding';
  8738.     
  8739.             case 'ADOBE-SYMBOL-ENCODING':
  8740.             case 'CSHPPSMATH':
  8741.                 return 'Adobe-Symbol-Encoding';
  8742.     
  8743.             case 'AMI-1251':
  8744.             case 'AMI1251':
  8745.             case 'AMIGA-1251':
  8746.             case 'AMIGA1251':
  8747.                 return 'Amiga-1251';
  8748.     
  8749.             case 'BOCU-1':
  8750.             case 'CSBOCU-1':
  8751.                 return 'BOCU-1';
  8752.     
  8753.             case 'BRF':
  8754.             case 'CSBRF':
  8755.                 return 'BRF';
  8756.     
  8757.             case 'BS_4730':
  8758.             case 'CSISO4UNITEDKINGDOM':
  8759.             case 'GB':
  8760.             case 'ISO-IR-4':
  8761.             case 'ISO646-GB':
  8762.             case 'UK':
  8763.                 return 'BS_4730';
  8764.     
  8765.             case 'BS_VIEWDATA':
  8766.             case 'CSISO47BSVIEWDATA':
  8767.             case 'ISO-IR-47':
  8768.                 return 'BS_viewdata';
  8769.     
  8770.             case 'BIG5':
  8771.             case 'CSBIG5':
  8772.                 return 'Big5';
  8773.     
  8774.             case 'BIG5-HKSCS':
  8775.                 return 'Big5-HKSCS';
  8776.     
  8777.             case 'CESU-8':
  8778.             case 'CSCESU-8':
  8779.                 return 'CESU-8';
  8780.     
  8781.             case 'CA':
  8782.             case 'CSA7-1':
  8783.             case 'CSA_Z243.4-1985-1':
  8784.             case 'CSISO121CANADIAN1':
  8785.             case 'ISO-IR-121':
  8786.             case 'ISO646-CA':
  8787.                 return 'CSA_Z243.4-1985-1';
  8788.     
  8789.             case 'CSA7-2':
  8790.             case 'CSA_Z243.4-1985-2':
  8791.             case 'CSISO122CANADIAN2':
  8792.             case 'ISO-IR-122':
  8793.             case 'ISO646-CA2':
  8794.                 return 'CSA_Z243.4-1985-2';
  8795.     
  8796.             case 'CSA_Z243.4-1985-GR':
  8797.             case 'CSISO123CSAZ24341985GR':
  8798.             case 'ISO-IR-123':
  8799.                 return 'CSA_Z243.4-1985-gr';
  8800.     
  8801.             case 'CSISO139CSN369103':
  8802.             case 'CSN_369103':
  8803.             case 'ISO-IR-139':
  8804.                 return 'CSN_369103';
  8805.     
  8806.             case 'CSDECMCS':
  8807.             case 'DEC':
  8808.             case 'DEC-MCS':
  8809.                 return 'DEC-MCS';
  8810.     
  8811.             case 'CSISO21GERMAN':
  8812.             case 'DE':
  8813.             case 'DIN_66003':
  8814.             case 'ISO-IR-21':
  8815.             case 'ISO646-DE':
  8816.                 return 'DIN_66003';
  8817.     
  8818.             case 'CSISO646DANISH':
  8819.             case 'DK':
  8820.             case 'DS2089':
  8821.             case 'DS_2089':
  8822.             case 'ISO646-DK':
  8823.                 return 'DS_2089';
  8824.     
  8825.             case 'CSIBMEBCDICATDE':
  8826.             case 'EBCDIC-AT-DE':
  8827.                 return 'EBCDIC-AT-DE';
  8828.     
  8829.             case 'CSEBCDICATDEA':
  8830.             case 'EBCDIC-AT-DE-A':
  8831.                 return 'EBCDIC-AT-DE-A';
  8832.     
  8833.             case 'CSEBCDICCAFR':
  8834.             case 'EBCDIC-CA-FR':
  8835.                 return 'EBCDIC-CA-FR';
  8836.     
  8837.             case 'CSEBCDICDKNO':
  8838.             case 'EBCDIC-DK-NO':
  8839.                 return 'EBCDIC-DK-NO';
  8840.     
  8841.             case 'CSEBCDICDKNOA':
  8842.             case 'EBCDIC-DK-NO-A':
  8843.                 return 'EBCDIC-DK-NO-A';
  8844.     
  8845.             case 'CSEBCDICES':
  8846.             case 'EBCDIC-ES':
  8847.                 return 'EBCDIC-ES';
  8848.     
  8849.             case 'CSEBCDICESA':
  8850.             case 'EBCDIC-ES-A':
  8851.                 return 'EBCDIC-ES-A';
  8852.     
  8853.             case 'CSEBCDICESS':
  8854.             case 'EBCDIC-ES-S':
  8855.                 return 'EBCDIC-ES-S';
  8856.     
  8857.             case 'CSEBCDICFISE':
  8858.             case 'EBCDIC-FI-SE':
  8859.                 return 'EBCDIC-FI-SE';
  8860.     
  8861.             case 'CSEBCDICFISEA':
  8862.             case 'EBCDIC-FI-SE-A':
  8863.                 return 'EBCDIC-FI-SE-A';
  8864.     
  8865.             case 'CSEBCDICFR':
  8866.             case 'EBCDIC-FR':
  8867.                 return 'EBCDIC-FR';
  8868.     
  8869.             case 'CSEBCDICIT':
  8870.             case 'EBCDIC-IT':
  8871.                 return 'EBCDIC-IT';
  8872.     
  8873.             case 'CSEBCDICPT':
  8874.             case 'EBCDIC-PT':
  8875.                 return 'EBCDIC-PT';
  8876.     
  8877.             case 'CSEBCDICUK':
  8878.             case 'EBCDIC-UK':
  8879.                 return 'EBCDIC-UK';
  8880.     
  8881.             case 'CSEBCDICUS':
  8882.             case 'EBCDIC-US':
  8883.                 return 'EBCDIC-US';
  8884.     
  8885.             case 'CSISO111ECMACYRILLIC':
  8886.             case 'ECMA-CYRILLIC':
  8887.             case 'ISO-IR-111':
  8888.             case 'KOI8-E':
  8889.                 return 'ECMA-cyrillic';
  8890.     
  8891.             case 'CSISO17SPANISH':
  8892.             case 'ES':
  8893.             case 'ISO-IR-17':
  8894.             case 'ISO646-ES':
  8895.                 return 'ES';
  8896.     
  8897.             case 'CSISO85SPANISH2':
  8898.             case 'ES2':
  8899.             case 'ISO-IR-85':
  8900.             case 'ISO646-ES2':
  8901.                 return 'ES2';
  8902.     
  8903.             case 'CSEUCPKDFMTJAPANESE':
  8904.             case 'EUC-JP':
  8905.             case 'EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE':
  8906.                 return 'EUC-JP';
  8907.     
  8908.             case 'CSEUCKR':
  8909.             case 'EUC-KR':
  8910.                 return 'EUC-KR';
  8911.     
  8912.             case 'CSEUCFIXWIDJAPANESE':
  8913.             case 'EXTENDED_UNIX_CODE_FIXED_WIDTH_FOR_JAPANESE':
  8914.                 return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
  8915.     
  8916.             case 'GB18030':
  8917.                 return 'GB18030';
  8918.     
  8919.             case 'CSGB2312':
  8920.             case 'GB2312':
  8921.                 return 'GB2312';
  8922.     
  8923.             case 'CP936':
  8924.             case 'GBK':
  8925.             case 'MS936':
  8926.             case 'WINDOWS-936':
  8927.                 return 'GBK';
  8928.     
  8929.             case 'CN':
  8930.             case 'CSISO57GB1988':
  8931.             case 'GB_1988-80':
  8932.             case 'ISO-IR-57':
  8933.             case 'ISO646-CN':
  8934.                 return 'GB_1988-80';
  8935.     
  8936.             case 'CHINESE':
  8937.             case 'CSISO58GB231280':
  8938.             case 'GB_2312-80':
  8939.             case 'ISO-IR-58':
  8940.                 return 'GB_2312-80';
  8941.     
  8942.             case 'CSISO153GOST1976874':
  8943.             case 'GOST_19768-74':
  8944.             case 'ISO-IR-153':
  8945.             case 'ST_SEV_358-88':
  8946.                 return 'GOST_19768-74';
  8947.     
  8948.             case 'CSHPDESKTOP':
  8949.             case 'HP-DESKTOP':
  8950.                 return 'HP-DeskTop';
  8951.     
  8952.             case 'CSHPLEGAL':
  8953.             case 'HP-LEGAL':
  8954.                 return 'HP-Legal';
  8955.     
  8956.             case 'CSHPMATH8':
  8957.             case 'HP-MATH8':
  8958.                 return 'HP-Math8';
  8959.     
  8960.             case 'CSHPPIFONT':
  8961.             case 'HP-PI-FONT':
  8962.                 return 'HP-Pi-font';
  8963.     
  8964.             case 'HZ-GB-2312':
  8965.                 return 'HZ-GB-2312';
  8966.     
  8967.             case 'CSIBMSYMBOLS':
  8968.             case 'IBM-SYMBOLS':
  8969.                 return 'IBM-Symbols';
  8970.     
  8971.             case 'CSIBMTHAI':
  8972.             case 'IBM-THAI':
  8973.                 return 'IBM-Thai';
  8974.     
  8975.             case 'CCSID00858':
  8976.             case 'CP00858':
  8977.             case 'IBM00858':
  8978.             case 'PC-MULTILINGUAL-850+EURO':
  8979.                 return 'IBM00858';
  8980.     
  8981.             case 'CCSID00924':
  8982.             case 'CP00924':
  8983.             case 'EBCDIC-LATIN9--EURO':
  8984.             case 'IBM00924':
  8985.                 return 'IBM00924';
  8986.     
  8987.             case 'CCSID01140':
  8988.             case 'CP01140':
  8989.             case 'EBCDIC-US-37+EURO':
  8990.             case 'IBM01140':
  8991.                 return 'IBM01140';
  8992.     
  8993.             case 'CCSID01141':
  8994.             case 'CP01141':
  8995.             case 'EBCDIC-DE-273+EURO':
  8996.             case 'IBM01141':
  8997.                 return 'IBM01141';
  8998.     
  8999.             case 'CCSID01142':
  9000.             case 'CP01142':
  9001.             case 'EBCDIC-DK-277+EURO':
  9002.             case 'EBCDIC-NO-277+EURO':
  9003.             case 'IBM01142':
  9004.                 return 'IBM01142';
  9005.     
  9006.             case 'CCSID01143':
  9007.             case 'CP01143':
  9008.             case 'EBCDIC-FI-278+EURO':
  9009.             case 'EBCDIC-SE-278+EURO':
  9010.             case 'IBM01143':
  9011.                 return 'IBM01143';
  9012.     
  9013.             case 'CCSID01144':
  9014.             case 'CP01144':
  9015.             case 'EBCDIC-IT-280+EURO':
  9016.             case 'IBM01144':
  9017.                 return 'IBM01144';
  9018.     
  9019.             case 'CCSID01145':
  9020.             case 'CP01145':
  9021.             case 'EBCDIC-ES-284+EURO':
  9022.             case 'IBM01145':
  9023.                 return 'IBM01145';
  9024.     
  9025.             case 'CCSID01146':
  9026.             case 'CP01146':
  9027.             case 'EBCDIC-GB-285+EURO':
  9028.             case 'IBM01146':
  9029.                 return 'IBM01146';
  9030.     
  9031.             case 'CCSID01147':
  9032.             case 'CP01147':
  9033.             case 'EBCDIC-FR-297+EURO':
  9034.             case 'IBM01147':
  9035.                 return 'IBM01147';
  9036.     
  9037.             case 'CCSID01148':
  9038.             case 'CP01148':
  9039.             case 'EBCDIC-INTERNATIONAL-500+EURO':
  9040.             case 'IBM01148':
  9041.                 return 'IBM01148';
  9042.     
  9043.             case 'CCSID01149':
  9044.             case 'CP01149':
  9045.             case 'EBCDIC-IS-871+EURO':
  9046.             case 'IBM01149':
  9047.                 return 'IBM01149';
  9048.     
  9049.             case 'CP037':
  9050.             case 'CSIBM037':
  9051.             case 'EBCDIC-CP-CA':
  9052.             case 'EBCDIC-CP-NL':
  9053.             case 'EBCDIC-CP-US':
  9054.             case 'EBCDIC-CP-WT':
  9055.             case 'IBM037':
  9056.                 return 'IBM037';
  9057.     
  9058.             case 'CP038':
  9059.             case 'CSIBM038':
  9060.             case 'EBCDIC-INT':
  9061.             case 'IBM038':
  9062.                 return 'IBM038';
  9063.     
  9064.             case 'CP1026':
  9065.             case 'CSIBM1026':
  9066.             case 'IBM1026':
  9067.                 return 'IBM1026';
  9068.     
  9069.             case 'IBM-1047':
  9070.             case 'IBM1047':
  9071.                 return 'IBM1047';
  9072.     
  9073.             case 'CP273':
  9074.             case 'CSIBM273':
  9075.             case 'IBM273':
  9076.                 return 'IBM273';
  9077.     
  9078.             case 'CP274':
  9079.             case 'CSIBM274':
  9080.             case 'EBCDIC-BE':
  9081.             case 'IBM274':
  9082.                 return 'IBM274';
  9083.     
  9084.             case 'CP275':
  9085.             case 'CSIBM275':
  9086.             case 'EBCDIC-BR':
  9087.             case 'IBM275':
  9088.                 return 'IBM275';
  9089.     
  9090.             case 'CSIBM277':
  9091.             case 'EBCDIC-CP-DK':
  9092.             case 'EBCDIC-CP-NO':
  9093.             case 'IBM277':
  9094.                 return 'IBM277';
  9095.     
  9096.             case 'CP278':
  9097.             case 'CSIBM278':
  9098.             case 'EBCDIC-CP-FI':
  9099.             case 'EBCDIC-CP-SE':
  9100.             case 'IBM278':
  9101.                 return 'IBM278';
  9102.     
  9103.             case 'CP280':
  9104.             case 'CSIBM280':
  9105.             case 'EBCDIC-CP-IT':
  9106.             case 'IBM280':
  9107.                 return 'IBM280';
  9108.     
  9109.             case 'CP281':
  9110.             case 'CSIBM281':
  9111.             case 'EBCDIC-JP-E':
  9112.             case 'IBM281':
  9113.                 return 'IBM281';
  9114.     
  9115.             case 'CP284':
  9116.             case 'CSIBM284':
  9117.             case 'EBCDIC-CP-ES':
  9118.             case 'IBM284':
  9119.                 return 'IBM284';
  9120.     
  9121.             case 'CP285':
  9122.             case 'CSIBM285':
  9123.             case 'EBCDIC-CP-GB':
  9124.             case 'IBM285':
  9125.                 return 'IBM285';
  9126.     
  9127.             case 'CP290':
  9128.             case 'CSIBM290':
  9129.             case 'EBCDIC-JP-KANA':
  9130.             case 'IBM290':
  9131.                 return 'IBM290';
  9132.     
  9133.             case 'CP297':
  9134.             case 'CSIBM297':
  9135.             case 'EBCDIC-CP-FR':
  9136.             case 'IBM297':
  9137.                 return 'IBM297';
  9138.     
  9139.             case 'CP420':
  9140.             case 'CSIBM420':
  9141.             case 'EBCDIC-CP-AR1':
  9142.             case 'IBM420':
  9143.                 return 'IBM420';
  9144.     
  9145.             case 'CP423':
  9146.             case 'CSIBM423':
  9147.             case 'EBCDIC-CP-GR':
  9148.             case 'IBM423':
  9149.                 return 'IBM423';
  9150.     
  9151.             case 'CP424':
  9152.             case 'CSIBM424':
  9153.             case 'EBCDIC-CP-HE':
  9154.             case 'IBM424':
  9155.                 return 'IBM424';
  9156.     
  9157.             case '437':
  9158.             case 'CP437':
  9159.             case 'CSPC8CODEPAGE437':
  9160.             case 'IBM437':
  9161.                 return 'IBM437';
  9162.     
  9163.             case 'CP500':
  9164.             case 'CSIBM500':
  9165.             case 'EBCDIC-CP-BE':
  9166.             case 'EBCDIC-CP-CH':
  9167.             case 'IBM500':
  9168.                 return 'IBM500';
  9169.     
  9170.             case 'CP775':
  9171.             case 'CSPC775BALTIC':
  9172.             case 'IBM775':
  9173.                 return 'IBM775';
  9174.     
  9175.             case '850':
  9176.             case 'CP850':
  9177.             case 'CSPC850MULTILINGUAL':
  9178.             case 'IBM850':
  9179.                 return 'IBM850';
  9180.     
  9181.             case '851':
  9182.             case 'CP851':
  9183.             case 'CSIBM851':
  9184.             case 'IBM851':
  9185.                 return 'IBM851';
  9186.     
  9187.             case '852':
  9188.             case 'CP852':
  9189.             case 'CSPCP852':
  9190.             case 'IBM852':
  9191.                 return 'IBM852';
  9192.     
  9193.             case '855':
  9194.             case 'CP855':
  9195.             case 'CSIBM855':
  9196.             case 'IBM855':
  9197.                 return 'IBM855';
  9198.     
  9199.             case '857':
  9200.             case 'CP857':
  9201.             case 'CSIBM857':
  9202.             case 'IBM857':
  9203.                 return 'IBM857';
  9204.     
  9205.             case '860':
  9206.             case 'CP860':
  9207.             case 'CSIBM860':
  9208.             case 'IBM860':
  9209.                 return 'IBM860';
  9210.     
  9211.             case '861':
  9212.             case 'CP-IS':
  9213.             case 'CP861':
  9214.             case 'CSIBM861':
  9215.             case 'IBM861':
  9216.                 return 'IBM861';
  9217.     
  9218.             case '862':
  9219.             case 'CP862':
  9220.             case 'CSPC862LATINHEBREW':
  9221.             case 'IBM862':
  9222.                 return 'IBM862';
  9223.     
  9224.             case '863':
  9225.             case 'CP863':
  9226.             case 'CSIBM863':
  9227.             case 'IBM863':
  9228.                 return 'IBM863';
  9229.     
  9230.             case 'CP864':
  9231.             case 'CSIBM864':
  9232.             case 'IBM864':
  9233.                 return 'IBM864';
  9234.     
  9235.             case '865':
  9236.             case 'CP865':
  9237.             case 'CSIBM865':
  9238.             case 'IBM865':
  9239.                 return 'IBM865';
  9240.     
  9241.             case '866':
  9242.             case 'CP866':
  9243.             case 'CSIBM866':
  9244.             case 'IBM866':
  9245.                 return 'IBM866';
  9246.     
  9247.             case 'CP-AR':
  9248.             case 'CP868':
  9249.             case 'CSIBM868':
  9250.             case 'IBM868':
  9251.                 return 'IBM868';
  9252.     
  9253.             case '869':
  9254.             case 'CP-GR':
  9255.             case 'CP869':
  9256.             case 'CSIBM869':
  9257.             case 'IBM869':
  9258.                 return 'IBM869';
  9259.     
  9260.             case 'CP870':
  9261.             case 'CSIBM870':
  9262.             case 'EBCDIC-CP-ROECE':
  9263.             case 'EBCDIC-CP-YU':
  9264.             case 'IBM870':
  9265.                 return 'IBM870';
  9266.     
  9267.             case 'CP871':
  9268.             case 'CSIBM871':
  9269.             case 'EBCDIC-CP-IS':
  9270.             case 'IBM871':
  9271.                 return 'IBM871';
  9272.     
  9273.             case 'CP880':
  9274.             case 'CSIBM880':
  9275.             case 'EBCDIC-CYRILLIC':
  9276.             case 'IBM880':
  9277.                 return 'IBM880';
  9278.     
  9279.             case 'CP891':
  9280.             case 'CSIBM891':
  9281.             case 'IBM891':
  9282.                 return 'IBM891';
  9283.     
  9284.             case 'CP903':
  9285.             case 'CSIBM903':
  9286.             case 'IBM903':
  9287.                 return 'IBM903';
  9288.     
  9289.             case '904':
  9290.             case 'CP904':
  9291.             case 'CSIBBM904':
  9292.             case 'IBM904':
  9293.                 return 'IBM904';
  9294.     
  9295.             case 'CP905':
  9296.             case 'CSIBM905':
  9297.             case 'EBCDIC-CP-TR':
  9298.             case 'IBM905':
  9299.                 return 'IBM905';
  9300.     
  9301.             case 'CP918':
  9302.             case 'CSIBM918':
  9303.             case 'EBCDIC-CP-AR2':
  9304.             case 'IBM918':
  9305.                 return 'IBM918';
  9306.     
  9307.             case 'CSISO143IECP271':
  9308.             case 'IEC_P27-1':
  9309.             case 'ISO-IR-143':
  9310.                 return 'IEC_P27-1';
  9311.     
  9312.             case 'CSISO49INIS':
  9313.             case 'INIS':
  9314.             case 'ISO-IR-49':
  9315.                 return 'INIS';
  9316.     
  9317.             case 'CSISO50INIS8':
  9318.             case 'INIS-8':
  9319.             case 'ISO-IR-50':
  9320.                 return 'INIS-8';
  9321.     
  9322.             case 'CSISO51INISCYRILLIC':
  9323.             case 'INIS-CYRILLIC':
  9324.             case 'ISO-IR-51':
  9325.                 return 'INIS-cyrillic';
  9326.     
  9327.             case 'CSINVARIANT':
  9328.             case 'INVARIANT':
  9329.                 return 'INVARIANT';
  9330.     
  9331.             case 'ISO-10646-J-1':
  9332.                 return 'ISO-10646-J-1';
  9333.     
  9334.             case 'CSUNICODE':
  9335.             case 'ISO-10646-UCS-2':
  9336.                 return 'ISO-10646-UCS-2';
  9337.     
  9338.             case 'CSUCS4':
  9339.             case 'ISO-10646-UCS-4':
  9340.                 return 'ISO-10646-UCS-4';
  9341.     
  9342.             case 'CSUNICODEASCII':
  9343.             case 'ISO-10646-UCS-BASIC':
  9344.                 return 'ISO-10646-UCS-Basic';
  9345.     
  9346.             case 'CSISO10646UTF1':
  9347.             case 'ISO-10646-UTF-1':
  9348.                 return 'ISO-10646-UTF-1';
  9349.     
  9350.             case 'CSUNICODELATIN1':
  9351.             case 'ISO-10646':
  9352.             case 'ISO-10646-UNICODE-LATIN1':
  9353.                 return 'ISO-10646-Unicode-Latin1';
  9354.     
  9355.             case 'CSISO115481':
  9356.             case 'ISO-11548-1':
  9357.             case 'ISO_11548-1':
  9358.             case 'ISO_TR_11548-1':
  9359.                 return 'ISO-11548-1';
  9360.     
  9361.             case 'ISO-2022-CN':
  9362.                 return 'ISO-2022-CN';
  9363.     
  9364.             case 'ISO-2022-CN-EXT':
  9365.                 return 'ISO-2022-CN-EXT';
  9366.     
  9367.             case 'CSISO2022JP':
  9368.             case 'ISO-2022-JP':
  9369.                 return 'ISO-2022-JP';
  9370.     
  9371.             case 'CSISO2022JP2':
  9372.             case 'ISO-2022-JP-2':
  9373.                 return 'ISO-2022-JP-2';
  9374.     
  9375.             case 'CSISO2022KR':
  9376.             case 'ISO-2022-KR':
  9377.                 return 'ISO-2022-KR';
  9378.     
  9379.             case 'CSWINDOWS30LATIN1':
  9380.             case 'ISO-8859-1-WINDOWS-3.0-LATIN-1':
  9381.                 return 'ISO-8859-1-Windows-3.0-Latin-1';
  9382.     
  9383.             case 'CSWINDOWS31LATIN1':
  9384.             case 'ISO-8859-1-WINDOWS-3.1-LATIN-1':
  9385.                 return 'ISO-8859-1-Windows-3.1-Latin-1';
  9386.     
  9387.             case 'CSISOLATIN6':
  9388.             case 'ISO-8859-10':
  9389.             case 'ISO-IR-157':
  9390.             case 'ISO_8859-10:1992':
  9391.             case 'L6':
  9392.             case 'LATIN6':
  9393.                 return 'ISO-8859-10';
  9394.     
  9395.             case 'ISO-8859-13':
  9396.                 return 'ISO-8859-13';
  9397.     
  9398.             case 'ISO-8859-14':
  9399.             case 'ISO-CELTIC':
  9400.             case 'ISO-IR-199':
  9401.             case 'ISO_8859-14':
  9402.             case 'ISO_8859-14:1998':
  9403.             case 'L8':
  9404.             case 'LATIN8':
  9405.                 return 'ISO-8859-14';
  9406.     
  9407.             case 'ISO-8859-15':
  9408.             case 'ISO_8859-15':
  9409.             case 'LATIN-9':
  9410.                 return 'ISO-8859-15';
  9411.     
  9412.             case 'ISO-8859-16':
  9413.             case 'ISO-IR-226':
  9414.             case 'ISO_8859-16':
  9415.             case 'ISO_8859-16:2001':
  9416.             case 'L10':
  9417.             case 'LATIN10':
  9418.                 return 'ISO-8859-16';
  9419.     
  9420.             case 'CSISOLATIN2':
  9421.             case 'ISO-8859-2':
  9422.             case 'ISO-IR-101':
  9423.             case 'ISO_8859-2':
  9424.             case 'ISO_8859-2:1987':
  9425.             case 'L2':
  9426.             case 'LATIN2':
  9427.                 return 'ISO-8859-2';
  9428.     
  9429.             case 'CSWINDOWS31LATIN2':
  9430.             case 'ISO-8859-2-WINDOWS-LATIN-2':
  9431.                 return 'ISO-8859-2-Windows-Latin-2';
  9432.     
  9433.             case 'CSISOLATIN3':
  9434.             case 'ISO-8859-3':
  9435.             case 'ISO-IR-109':
  9436.             case 'ISO_8859-3':
  9437.             case 'ISO_8859-3:1988':
  9438.             case 'L3':
  9439.             case 'LATIN3':
  9440.                 return 'ISO-8859-3';
  9441.     
  9442.             case 'CSISOLATIN4':
  9443.             case 'ISO-8859-4':
  9444.             case 'ISO-IR-110':
  9445.             case 'ISO_8859-4':
  9446.             case 'ISO_8859-4:1988':
  9447.             case 'L4':
  9448.             case 'LATIN4':
  9449.                 return 'ISO-8859-4';
  9450.     
  9451.             case 'CSISOLATINCYRILLIC':
  9452.             case 'CYRILLIC':
  9453.             case 'ISO-8859-5':
  9454.             case 'ISO-IR-144':
  9455.             case 'ISO_8859-5':
  9456.             case 'ISO_8859-5:1988':
  9457.                 return 'ISO-8859-5';
  9458.     
  9459.             case 'ARABIC':
  9460.             case 'ASMO-708':
  9461.             case 'CSISOLATINARABIC':
  9462.             case 'ECMA-114':
  9463.             case 'ISO-8859-6':
  9464.             case 'ISO-IR-127':
  9465.             case 'ISO_8859-6':
  9466.             case 'ISO_8859-6:1987':
  9467.                 return 'ISO-8859-6';
  9468.     
  9469.             case 'CSISO88596E':
  9470.             case 'ISO-8859-6-E':
  9471.             case 'ISO_8859-6-E':
  9472.                 return 'ISO-8859-6-E';
  9473.     
  9474.             case 'CSISO88596I':
  9475.             case 'ISO-8859-6-I':
  9476.             case 'ISO_8859-6-I':
  9477.                 return 'ISO-8859-6-I';
  9478.     
  9479.             case 'CSISOLATINGREEK':
  9480.             case 'ECMA-118':
  9481.             case 'ELOT_928':
  9482.             case 'GREEK':
  9483.             case 'GREEK8':
  9484.             case 'ISO-8859-7':
  9485.             case 'ISO-IR-126':
  9486.             case 'ISO_8859-7':
  9487.             case 'ISO_8859-7:1987':
  9488.                 return 'ISO-8859-7';
  9489.     
  9490.             case 'CSISOLATINHEBREW':
  9491.             case 'HEBREW':
  9492.             case 'ISO-8859-8':
  9493.             case 'ISO-IR-138':
  9494.             case 'ISO_8859-8':
  9495.             case 'ISO_8859-8:1988':
  9496.                 return 'ISO-8859-8';
  9497.     
  9498.             case 'CSISO88598E':
  9499.             case 'ISO-8859-8-E':
  9500.             case 'ISO_8859-8-E':
  9501.                 return 'ISO-8859-8-E';
  9502.     
  9503.             case 'CSISO88598I':
  9504.             case 'ISO-8859-8-I':
  9505.             case 'ISO_8859-8-I':
  9506.                 return 'ISO-8859-8-I';
  9507.     
  9508.             case 'CSISOLATIN5':
  9509.             case 'ISO-8859-9':
  9510.             case 'ISO-IR-148':
  9511.             case 'ISO_8859-9':
  9512.             case 'ISO_8859-9:1989':
  9513.             case 'L5':
  9514.             case 'LATIN5':
  9515.                 return 'ISO-8859-9';
  9516.     
  9517.             case 'CSWINDOWS31LATIN5':
  9518.             case 'ISO-8859-9-WINDOWS-LATIN-5':
  9519.                 return 'ISO-8859-9-Windows-Latin-5';
  9520.     
  9521.             case 'CSUNICODEIBM1261':
  9522.             case 'ISO-UNICODE-IBM-1261':
  9523.                 return 'ISO-Unicode-IBM-1261';
  9524.     
  9525.             case 'CSUNICODEIBM1264':
  9526.             case 'ISO-UNICODE-IBM-1264':
  9527.                 return 'ISO-Unicode-IBM-1264';
  9528.     
  9529.             case 'CSUNICODEIBM1265':
  9530.             case 'ISO-UNICODE-IBM-1265':
  9531.                 return 'ISO-Unicode-IBM-1265';
  9532.     
  9533.             case 'CSUNICODEIBM1268':
  9534.             case 'ISO-UNICODE-IBM-1268':
  9535.                 return 'ISO-Unicode-IBM-1268';
  9536.     
  9537.             case 'CSUNICODEIBM1276':
  9538.             case 'ISO-UNICODE-IBM-1276':
  9539.                 return 'ISO-Unicode-IBM-1276';
  9540.     
  9541.             case 'CSISO10367BOX':
  9542.             case 'ISO-IR-155':
  9543.             case 'ISO_10367-BOX':
  9544.                 return 'ISO_10367-box';
  9545.     
  9546.             case 'CSISO2033':
  9547.             case 'E13B':
  9548.             case 'ISO-IR-98':
  9549.             case 'ISO_2033-1983':
  9550.                 return 'ISO_2033-1983';
  9551.     
  9552.             case 'CSISO5427CYRILLIC':
  9553.             case 'ISO-IR-37':
  9554.             case 'ISO_5427':
  9555.                 return 'ISO_5427';
  9556.     
  9557.             case 'ISO-IR-54':
  9558.             case 'ISO5427CYRILLIC1981':
  9559.             case 'ISO_5427:1981':
  9560.                 return 'ISO_5427:1981';
  9561.     
  9562.             case 'CSISO5428GREEK':
  9563.             case 'ISO-IR-55':
  9564.             case 'ISO_5428:1980':
  9565.                 return 'ISO_5428:1980';
  9566.     
  9567.             case 'CSISO646BASIC1983':
  9568.             case 'ISO_646.BASIC:1983':
  9569.             case 'REF':
  9570.                 return 'ISO_646.basic:1983';
  9571.     
  9572.             case 'CSISO2INTLREFVERSION':
  9573.             case 'IRV':
  9574.             case 'ISO-IR-2':
  9575.             case 'ISO_646.IRV:1983':
  9576.                 return 'ISO_646.irv:1983';
  9577.     
  9578.             case 'CSISO6937ADD':
  9579.             case 'ISO-IR-152':
  9580.             case 'ISO_6937-2-25':
  9581.                 return 'ISO_6937-2-25';
  9582.     
  9583.             case 'CSISOTEXTCOMM':
  9584.             case 'ISO-IR-142':
  9585.             case 'ISO_6937-2-ADD':
  9586.                 return 'ISO_6937-2-add';
  9587.     
  9588.             case 'CSISO8859SUPP':
  9589.             case 'ISO-IR-154':
  9590.             case 'ISO_8859-SUPP':
  9591.             case 'LATIN1-2-5':
  9592.                 return 'ISO_8859-supp';
  9593.     
  9594.             case 'CSISO15ITALIAN':
  9595.             case 'ISO-IR-15':
  9596.             case 'ISO646-IT':
  9597.             case 'IT':
  9598.                 return 'IT';
  9599.     
  9600.             case 'CSISO13JISC6220JP':
  9601.             case 'ISO-IR-13':
  9602.             case 'JIS_C6220-1969':
  9603.             case 'JIS_C6220-1969-JP':
  9604.             case 'KATAKANA':
  9605.             case 'X0201-7':
  9606.                 return 'JIS_C6220-1969-jp';
  9607.     
  9608.             case 'CSISO14JISC6220RO':
  9609.             case 'ISO-IR-14':
  9610.             case 'ISO646-JP':
  9611.             case 'JIS_C6220-1969-RO':
  9612.             case 'JP':
  9613.                 return 'JIS_C6220-1969-ro';
  9614.     
  9615.             case 'CSISO42JISC62261978':
  9616.             case 'ISO-IR-42':
  9617.             case 'JIS_C6226-1978':
  9618.                 return 'JIS_C6226-1978';
  9619.     
  9620.             case 'CSISO87JISX0208':
  9621.             case 'ISO-IR-87':
  9622.             case 'JIS_C6226-1983':
  9623.             case 'JIS_X0208-1983':
  9624.             case 'X0208':
  9625.                 return 'JIS_C6226-1983';
  9626.     
  9627.             case 'CSISO91JISC62291984A':
  9628.             case 'ISO-IR-91':
  9629.             case 'JIS_C6229-1984-A':
  9630.             case 'JP-OCR-A':
  9631.                 return 'JIS_C6229-1984-a';
  9632.     
  9633.             case 'CSISO92JISC62991984B':
  9634.             case 'ISO-IR-92':
  9635.             case 'ISO646-JP-OCR-B':
  9636.             case 'JIS_C6229-1984-B':
  9637.             case 'JP-OCR-B':
  9638.                 return 'JIS_C6229-1984-b';
  9639.     
  9640.             case 'CSISO93JIS62291984BADD':
  9641.             case 'ISO-IR-93':
  9642.             case 'JIS_C6229-1984-B-ADD':
  9643.             case 'JP-OCR-B-ADD':
  9644.                 return 'JIS_C6229-1984-b-add';
  9645.     
  9646.             case 'CSISO94JIS62291984HAND':
  9647.             case 'ISO-IR-94':
  9648.             case 'JIS_C6229-1984-HAND':
  9649.             case 'JP-OCR-HAND':
  9650.                 return 'JIS_C6229-1984-hand';
  9651.     
  9652.             case 'CSISO95JIS62291984HANDADD':
  9653.             case 'ISO-IR-95':
  9654.             case 'JIS_C6229-1984-HAND-ADD':
  9655.             case 'JP-OCR-HAND-ADD':
  9656.                 return 'JIS_C6229-1984-hand-add';
  9657.     
  9658.             case 'CSISO96JISC62291984KANA':
  9659.             case 'ISO-IR-96':
  9660.             case 'JIS_C6229-1984-KANA':
  9661.                 return 'JIS_C6229-1984-kana';
  9662.     
  9663.             case 'CSJISENCODING':
  9664.             case 'JIS_ENCODING':
  9665.                 return 'JIS_Encoding';
  9666.     
  9667.             case 'CSHALFWIDTHKATAKANA':
  9668.             case 'JIS_X0201':
  9669.             case 'X0201':
  9670.                 return 'JIS_X0201';
  9671.     
  9672.             case 'CSISO159JISX02121990':
  9673.             case 'ISO-IR-159':
  9674.             case 'JIS_X0212-1990':
  9675.             case 'X0212':
  9676.                 return 'JIS_X0212-1990';
  9677.     
  9678.             case 'CSISO141JUSIB1002':
  9679.             case 'ISO-IR-141':
  9680.             case 'ISO646-YU':
  9681.             case 'JS':
  9682.             case 'JUS_I.B1.002':
  9683.             case 'YU':
  9684.                 return 'JUS_I.B1.002';
  9685.     
  9686.             case 'CSISO147MACEDONIAN':
  9687.             case 'ISO-IR-147':
  9688.             case 'JUS_I.B1.003-MAC':
  9689.             case 'MACEDONIAN':
  9690.                 return 'JUS_I.B1.003-mac';
  9691.     
  9692.             case 'CSISO146SERBIAN':
  9693.             case 'ISO-IR-146':
  9694.             case 'JUS_I.B1.003-SERB':
  9695.             case 'SERBIAN':
  9696.                 return 'JUS_I.B1.003-serb';
  9697.     
  9698.             case 'KOI7-SWITCHED':
  9699.                 return 'KOI7-switched';
  9700.     
  9701.             case 'CSKOI8R':
  9702.             case 'KOI8-R':
  9703.                 return 'KOI8-R';
  9704.     
  9705.             case 'KOI8-U':
  9706.                 return 'KOI8-U';
  9707.     
  9708.             case 'CSKSC5636':
  9709.             case 'ISO646-KR':
  9710.             case 'KSC5636':
  9711.                 return 'KSC5636';
  9712.     
  9713.             case 'CSKSC56011987':
  9714.             case 'ISO-IR-149':
  9715.             case 'KOREAN':
  9716.             case 'KSC_5601':
  9717.             case 'KS_C_5601-1987':
  9718.             case 'KS_C_5601-1989':
  9719.                 return 'KS_C_5601-1987';
  9720.     
  9721.             case 'CSKZ1048':
  9722.             case 'KZ-1048':
  9723.             case 'RK1048':
  9724.             case 'STRK1048-2002':
  9725.                 return 'KZ-1048';
  9726.     
  9727.             case 'CSISO27LATINGREEK1':
  9728.             case 'ISO-IR-27':
  9729.             case 'LATIN-GREEK-1':
  9730.                 return 'Latin-greek-1';
  9731.     
  9732.             case 'CSMNEM':
  9733.             case 'MNEM':
  9734.                 return 'MNEM';
  9735.     
  9736.             case 'CSMNEMONIC':
  9737.             case 'MNEMONIC':
  9738.                 return 'MNEMONIC';
  9739.     
  9740.             case 'CSISO86HUNGARIAN':
  9741.             case 'HU':
  9742.             case 'ISO-IR-86':
  9743.             case 'ISO646-HU':
  9744.             case 'MSZ_7795.3':
  9745.                 return 'MSZ_7795.3';
  9746.     
  9747.             case 'CSMICROSOFTPUBLISHING':
  9748.             case 'MICROSOFT-PUBLISHING':
  9749.                 return 'Microsoft-Publishing';
  9750.     
  9751.             case 'CSNATSDANO':
  9752.             case 'ISO-IR-9-1':
  9753.             case 'NATS-DANO':
  9754.                 return 'NATS-DANO';
  9755.     
  9756.             case 'CSNATSDANOADD':
  9757.             case 'ISO-IR-9-2':
  9758.             case 'NATS-DANO-ADD':
  9759.                 return 'NATS-DANO-ADD';
  9760.     
  9761.             case 'CSNATSSEFI':
  9762.             case 'ISO-IR-8-1':
  9763.             case 'NATS-SEFI':
  9764.                 return 'NATS-SEFI';
  9765.     
  9766.             case 'CSNATSSEFIADD':
  9767.             case 'ISO-IR-8-2':
  9768.             case 'NATS-SEFI-ADD':
  9769.                 return 'NATS-SEFI-ADD';
  9770.     
  9771.             case 'CSISO151CUBA':
  9772.             case 'CUBA':
  9773.             case 'ISO-IR-151':
  9774.             case 'ISO646-CU':
  9775.             case 'NC_NC00-10:81':
  9776.                 return 'NC_NC00-10:81';
  9777.     
  9778.             case 'CSISO69FRENCH':
  9779.             case 'FR':
  9780.             case 'ISO-IR-69':
  9781.             case 'ISO646-FR':
  9782.             case 'NF_Z_62-010':
  9783.                 return 'NF_Z_62-010';
  9784.     
  9785.             case 'CSISO25FRENCH':
  9786.             case 'ISO-IR-25':
  9787.             case 'ISO646-FR1':
  9788.             case 'NF_Z_62-010_(1973)':
  9789.                 return 'NF_Z_62-010_(1973)';
  9790.     
  9791.             case 'CSISO60DANISHNORWEGIAN':
  9792.             case 'CSISO60NORWEGIAN1':
  9793.             case 'ISO-IR-60':
  9794.             case 'ISO646-NO':
  9795.             case 'NO':
  9796.             case 'NS_4551-1':
  9797.                 return 'NS_4551-1';
  9798.     
  9799.             case 'CSISO61NORWEGIAN2':
  9800.             case 'ISO-IR-61':
  9801.             case 'ISO646-NO2':
  9802.             case 'NO2':
  9803.             case 'NS_4551-2':
  9804.                 return 'NS_4551-2';
  9805.     
  9806.             case 'OSD_EBCDIC_DF03_IRV':
  9807.                 return 'OSD_EBCDIC_DF03_IRV';
  9808.     
  9809.             case 'OSD_EBCDIC_DF04_1':
  9810.                 return 'OSD_EBCDIC_DF04_1';
  9811.     
  9812.             case 'OSD_EBCDIC_DF04_15':
  9813.                 return 'OSD_EBCDIC_DF04_15';
  9814.     
  9815.             case 'CSPC8DANISHNORWEGIAN':
  9816.             case 'PC8-DANISH-NORWEGIAN':
  9817.                 return 'PC8-Danish-Norwegian';
  9818.     
  9819.             case 'CSPC8TURKISH':
  9820.             case 'PC8-TURKISH':
  9821.                 return 'PC8-Turkish';
  9822.     
  9823.             case 'CSISO16PORTUGUESE':
  9824.             case 'ISO-IR-16':
  9825.             case 'ISO646-PT':
  9826.             case 'PT':
  9827.                 return 'PT';
  9828.     
  9829.             case 'CSISO84PORTUGUESE2':
  9830.             case 'ISO-IR-84':
  9831.             case 'ISO646-PT2':
  9832.             case 'PT2':
  9833.                 return 'PT2';
  9834.     
  9835.             case 'CP154':
  9836.             case 'CSPTCP154':
  9837.             case 'CYRILLIC-ASIAN':
  9838.             case 'PT154':
  9839.             case 'PTCP154':
  9840.                 return 'PTCP154';
  9841.     
  9842.             case 'SCSU':
  9843.                 return 'SCSU';
  9844.     
  9845.             case 'CSISO10SWEDISH':
  9846.             case 'FI':
  9847.             case 'ISO-IR-10':
  9848.             case 'ISO646-FI':
  9849.             case 'ISO646-SE':
  9850.             case 'SE':
  9851.             case 'SEN_850200_B':
  9852.                 return 'SEN_850200_B';
  9853.     
  9854.             case 'CSISO11SWEDISHFORNAMES':
  9855.             case 'ISO-IR-11':
  9856.             case 'ISO646-SE2':
  9857.             case 'SE2':
  9858.             case 'SEN_850200_C':
  9859.                 return 'SEN_850200_C';
  9860.     
  9861.             case 'CSSHIFTJIS':
  9862.             case 'MS_KANJI':
  9863.             case 'SHIFT_JIS':
  9864.                 return 'Shift_JIS';
  9865.     
  9866.             case 'CSISO128T101G2':
  9867.             case 'ISO-IR-128':
  9868.             case 'T.101-G2':
  9869.                 return 'T.101-G2';
  9870.     
  9871.             case 'CSISO102T617BIT':
  9872.             case 'ISO-IR-102':
  9873.             case 'T.61-7BIT':
  9874.                 return 'T.61-7bit';
  9875.     
  9876.             case 'CSISO103T618BIT':
  9877.             case 'ISO-IR-103':
  9878.             case 'T.61':
  9879.             case 'T.61-8BIT':
  9880.                 return 'T.61-8bit';
  9881.     
  9882.             case 'CSTSCII':
  9883.             case 'TSCII':
  9884.                 return 'TSCII';
  9885.     
  9886.             case 'CSUNICODE11':
  9887.             case 'UNICODE-1-1':
  9888.                 return 'UNICODE-1-1';
  9889.     
  9890.             case 'CSUNICODE11UTF7':
  9891.             case 'UNICODE-1-1-UTF-7':
  9892.                 return 'UNICODE-1-1-UTF-7';
  9893.     
  9894.             case 'CSUNKNOWN8BIT':
  9895.             case 'UNKNOWN-8BIT':
  9896.                 return 'UNKNOWN-8BIT';
  9897.     
  9898.             case 'ANSI':
  9899.             case 'ANSI_X3.4-1968':
  9900.             case 'ANSI_X3.4-1986':
  9901.             case 'ASCII':
  9902.             case 'CP367':
  9903.             case 'CSASCII':
  9904.             case 'IBM367':
  9905.             case 'ISO-IR-6':
  9906.             case 'ISO646-US':
  9907.             case 'ISO_646.IRV:1991':
  9908.             case 'US':
  9909.             case 'US-ASCII':
  9910.                 return 'US-ASCII';
  9911.     
  9912.             case 'UTF-16':
  9913.                 return 'UTF-16';
  9914.     
  9915.             case 'UTF-16BE':
  9916.                 return 'UTF-16BE';
  9917.     
  9918.             case 'UTF-16LE':
  9919.                 return 'UTF-16LE';
  9920.     
  9921.             case 'UTF-32':
  9922.                 return 'UTF-32';
  9923.     
  9924.             case 'UTF-32BE':
  9925.                 return 'UTF-32BE';
  9926.     
  9927.             case 'UTF-32LE':
  9928.                 return 'UTF-32LE';
  9929.     
  9930.             case 'UTF-7':
  9931.                 return 'UTF-7';
  9932.     
  9933.             case 'UTF-8':
  9934.                 return 'UTF-8';
  9935.     
  9936.             case 'CSVIQR':
  9937.             case 'VIQR':
  9938.                 return 'VIQR';
  9939.     
  9940.             case 'CSVISCII':
  9941.             case 'VISCII':
  9942.                 return 'VISCII';
  9943.     
  9944.             case 'CSVENTURAINTERNATIONAL':
  9945.             case 'VENTURA-INTERNATIONAL':
  9946.                 return 'Ventura-International';
  9947.     
  9948.             case 'CSVENTURAMATH':
  9949.             case 'VENTURA-MATH':
  9950.                 return 'Ventura-Math';
  9951.     
  9952.             case 'CSVENTURAUS':
  9953.             case 'VENTURA-US':
  9954.                 return 'Ventura-US';
  9955.     
  9956.             case 'CSWINDOWS31J':
  9957.             case 'WINDOWS-31J':
  9958.                 return 'Windows-31J';
  9959.     
  9960.             case 'CSDKUS':
  9961.             case 'DK-US':
  9962.                 return 'dk-us';
  9963.     
  9964.             case 'CSISO150':
  9965.             case 'CSISO150GREEKCCITT':
  9966.             case 'GREEK-CCITT':
  9967.             case 'ISO-IR-150':
  9968.                 return 'greek-ccitt';
  9969.     
  9970.             case 'CSISO88GREEK7':
  9971.             case 'GREEK7':
  9972.             case 'ISO-IR-88':
  9973.                 return 'greek7';
  9974.     
  9975.             case 'CSISO18GREEK7OLD':
  9976.             case 'GREEK7-OLD':
  9977.             case 'ISO-IR-18':
  9978.                 return 'greek7-old';
  9979.     
  9980.             case 'CSHPROMAN8':
  9981.             case 'HP-ROMAN8':
  9982.             case 'R8':
  9983.             case 'ROMAN8':
  9984.                 return 'hp-roman8';
  9985.     
  9986.             case 'CSISO90':
  9987.             case 'ISO-IR-90':
  9988.                 return 'iso-ir-90';
  9989.     
  9990.             case 'CSISO19LATINGREEK':
  9991.             case 'ISO-IR-19':
  9992.             case 'LATIN-GREEK':
  9993.                 return 'latin-greek';
  9994.     
  9995.             case 'CSISO158LAP':
  9996.             case 'ISO-IR-158':
  9997.             case 'LAP':
  9998.             case 'LATIN-LAP':
  9999.                 return 'latin-lap';
  10000.     
  10001.             case 'CSMACINTOSH':
  10002.             case 'MAC':
  10003.             case 'MACINTOSH':
  10004.                 return 'macintosh';
  10005.     
  10006.             case 'CSUSDK':
  10007.             case 'US-DK':
  10008.                 return 'us-dk';
  10009.     
  10010.             case 'CSISO70VIDEOTEXSUPP1':
  10011.             case 'ISO-IR-70':
  10012.             case 'VIDEOTEX-SUPPL':
  10013.                 return 'videotex-suppl';
  10014.     
  10015.             case 'WINDOWS-1250':
  10016.                 return 'windows-1250';
  10017.     
  10018.             case 'WINDOWS-1251':
  10019.                 return 'windows-1251';
  10020.     
  10021.             case 'CP819':
  10022.             case 'CSISOLATIN1':
  10023.             case 'IBM819':
  10024.             case 'ISO-8859-1':
  10025.             case 'ISO-IR-100':
  10026.             case 'ISO_8859-1':
  10027.             case 'ISO_8859-1:1987':
  10028.             case 'L1':
  10029.             case 'LATIN1':
  10030.             case 'WINDOWS-1252':
  10031.                 return 'windows-1252';
  10032.     
  10033.             case 'WINDOWS-1253':
  10034.                 return 'windows-1253';
  10035.     
  10036.             case 'WINDOWS-1254':
  10037.                 return 'windows-1254';
  10038.     
  10039.             case 'WINDOWS-1255':
  10040.                 return 'windows-1255';
  10041.     
  10042.             case 'WINDOWS-1256':
  10043.                 return 'windows-1256';
  10044.     
  10045.             case 'WINDOWS-1257':
  10046.                 return 'windows-1257';
  10047.     
  10048.             case 'WINDOWS-1258':
  10049.                 return 'windows-1258';
  10050.     
  10051.             default:
  10052.                 return $encoding;
  10053.         }
  10054.     }
  10055.  
  10056.     function get_curl_version()
  10057.     {
  10058.         if (is_array($curl curl_version()))
  10059.         {
  10060.             $curl $curl['version'];
  10061.         }
  10062.         elseif (substr($curl05== 'curl/')
  10063.         {
  10064.             $curl substr($curl5strcspn($curl"\x09\x0A\x0B\x0C\x0D"5));
  10065.         }
  10066.         elseif (substr($curl08== 'libcurl/')
  10067.         {
  10068.             $curl substr($curl8strcspn($curl"\x09\x0A\x0B\x0C\x0D"8));
  10069.         }
  10070.         else
  10071.         {
  10072.             $curl 0;
  10073.         }
  10074.         return $curl;
  10075.     }
  10076.  
  10077.     function is_subclass_of($class1$class2)
  10078.     {
  10079.         if (func_num_args(!= 2)
  10080.         {
  10081.             trigger_error('Wrong parameter count for SimplePie_Misc::is_subclass_of()'E_USER_WARNING);
  10082.         }
  10083.         elseif (version_compare(PHP_VERSION'5.0.3''>='|| is_object($class1))
  10084.         {
  10085.             return is_subclass_of($class1$class2);
  10086.         }
  10087.         elseif (is_string($class1&& is_string($class2))
  10088.         {
  10089.             if (class_exists($class1))
  10090.             {
  10091.                 if (class_exists($class2))
  10092.                 {
  10093.                     $class2 strtolower($class2);
  10094.                     while ($class1 strtolower(get_parent_class($class1)))
  10095.                     {
  10096.                         if ($class1 == $class2)
  10097.                         {
  10098.                             return true;
  10099.                         }
  10100.                     }
  10101.                 }
  10102.             }
  10103.             else
  10104.             {
  10105.                 trigger_error('Unknown class passed as parameter'E_USER_WARNNG);
  10106.             }
  10107.         }
  10108.         return false;
  10109.     }
  10110.  
  10111.     /**
  10112.      * Strip HTML comments
  10113.      *
  10114.      * @access public
  10115.      * @param string $data Data to strip comments from
  10116.      * @return string Comment stripped string
  10117.      */
  10118.     function strip_comments($data)
  10119.     {
  10120.         $output '';
  10121.         while (($start strpos($data'<!--')) !== false)
  10122.         {
  10123.             $output .= substr($data0$start);
  10124.             if (($end strpos($data'-->'$start)) !== false)
  10125.             {
  10126.                 $data substr_replace($data''0$end 3);
  10127.             }
  10128.             else
  10129.             {
  10130.                 $data '';
  10131.             }
  10132.         }
  10133.         return $output $data;
  10134.     }
  10135.  
  10136.     function parse_date($dt)
  10137.     {
  10138.         $parser SimplePie_Parse_Date::get();
  10139.         return $parser->parse($dt);
  10140.     }
  10141.  
  10142.     /**
  10143.      * Decode HTML entities
  10144.      *
  10145.      * @static
  10146.      * @access public
  10147.      * @param string $data Input data
  10148.      * @return string Output data
  10149.      */
  10150.     function entities_decode($data)
  10151.     {
  10152.         $decoder new SimplePie_Decode_HTML_Entities($data);
  10153.         return $decoder->parse();
  10154.     }
  10155.  
  10156.     /**
  10157.      * Remove RFC822 comments
  10158.      *
  10159.      * @access public
  10160.      * @param string $data Data to strip comments from
  10161.      * @return string Comment stripped string
  10162.      */
  10163.     function uncomment_rfc822($string)
  10164.     {
  10165.         $string = (string) $string;
  10166.         $position 0;
  10167.         $length strlen($string);
  10168.         $depth 0;
  10169.         
  10170.         $output '';
  10171.         
  10172.         while ($position $length && ($pos strpos($string'('$position)) !== false)
  10173.         {
  10174.             $output .= substr($string$position$pos $position);
  10175.             $position $pos 1;
  10176.             if ($string[$pos 1!== '\\')
  10177.             {
  10178.                 $depth++;
  10179.                 while ($depth && $position $length)
  10180.                 {
  10181.                     $position += strcspn($string'()'$position);
  10182.                     if ($string[$position 1=== '\\')
  10183.                     {
  10184.                         $position++;
  10185.                         continue;
  10186.                     }
  10187.                     elseif (isset($string[$position]))
  10188.                     {
  10189.                         switch ($string[$position])
  10190.                         {
  10191.                             case '(':
  10192.                                 $depth++;
  10193.                                 break;
  10194.                             
  10195.                             case ')':
  10196.                                 $depth--;
  10197.                                 break;
  10198.                         }
  10199.                         $position++;
  10200.                     }
  10201.                     else
  10202.                     {
  10203.                         break;
  10204.                     }
  10205.                 }
  10206.             }
  10207.             else
  10208.             {
  10209.                 $output .= '(';
  10210.             }
  10211.         }
  10212.         $output .= substr($string$position);
  10213.         
  10214.         return $output;
  10215.     }
  10216.  
  10217.     function parse_mime($mime)
  10218.     {
  10219.         if (($pos strpos($mime';')) === false)
  10220.         {
  10221.             return trim($mime);
  10222.         }
  10223.         else
  10224.         {
  10225.             return trim(substr($mime0$pos));
  10226.         }
  10227.     }
  10228.  
  10229.     function htmlspecialchars_decode($string$quote_style)
  10230.     {
  10231.         if (function_exists('htmlspecialchars_decode'))
  10232.         {
  10233.             return htmlspecialchars_decode($string$quote_style);
  10234.         }
  10235.         else
  10236.         {
  10237.             return strtr($stringarray_flip(get_html_translation_table(HTML_SPECIALCHARS$quote_style)));
  10238.         }
  10239.     }
  10240.  
  10241.     function atom_03_construct_type($attribs)
  10242.     {
  10243.         if (isset($attribs['']['mode']&& strtolower(trim($attribs['']['mode']== 'base64'))
  10244.         {
  10245.             $mode SIMPLEPIE_CONSTRUCT_BASE64;
  10246.         }
  10247.         else
  10248.         {
  10249.             $mode SIMPLEPIE_CONSTRUCT_NONE;
  10250.         }
  10251.         if (isset($attribs['']['type']))
  10252.         {
  10253.             switch (strtolower(trim($attribs['']['type'])))
  10254.             {
  10255.                 case 'text':
  10256.                 case 'text/plain':
  10257.                     return SIMPLEPIE_CONSTRUCT_TEXT $mode;
  10258.  
  10259.                 case 'html':
  10260.                 case 'text/html':
  10261.                     return SIMPLEPIE_CONSTRUCT_HTML $mode;
  10262.  
  10263.                 case 'xhtml':
  10264.                 case 'application/xhtml+xml':
  10265.                     return SIMPLEPIE_CONSTRUCT_XHTML $mode;
  10266.  
  10267.                 default:
  10268.                     return SIMPLEPIE_CONSTRUCT_NONE $mode;
  10269.             }
  10270.         }
  10271.         else
  10272.         {
  10273.             return SIMPLEPIE_CONSTRUCT_TEXT $mode;
  10274.         }
  10275.     }
  10276.  
  10277.     function atom_10_construct_type($attribs)
  10278.     {
  10279.         if (isset($attribs['']['type']))
  10280.         {
  10281.             switch (strtolower(trim($attribs['']['type'])))
  10282.             {
  10283.                 case 'text':
  10284.                     return SIMPLEPIE_CONSTRUCT_TEXT;
  10285.  
  10286.                 case 'html':
  10287.                     return SIMPLEPIE_CONSTRUCT_HTML;
  10288.  
  10289.                 case 'xhtml':
  10290.                     return SIMPLEPIE_CONSTRUCT_XHTML;
  10291.  
  10292.                 default:
  10293.                     return SIMPLEPIE_CONSTRUCT_NONE;
  10294.             }
  10295.         }
  10296.         return SIMPLEPIE_CONSTRUCT_TEXT;
  10297.     }
  10298.  
  10299.     function atom_10_content_construct_type($attribs)
  10300.     {
  10301.         if (isset($attribs['']['type']))
  10302.         {
  10303.             $type strtolower(trim($attribs['']['type']));
  10304.             switch ($type)
  10305.             {
  10306.                 case 'text':
  10307.                     return SIMPLEPIE_CONSTRUCT_TEXT;
  10308.  
  10309.                 case 'html':
  10310.                     return SIMPLEPIE_CONSTRUCT_HTML;
  10311.  
  10312.                 case 'xhtml':
  10313.                     return SIMPLEPIE_CONSTRUCT_XHTML;
  10314.             }
  10315.             if (in_array(substr($type-4)array('+xml''/xml')) || substr($type05== 'text/')
  10316.             {
  10317.                 return SIMPLEPIE_CONSTRUCT_NONE;
  10318.             }
  10319.             else
  10320.             {
  10321.                 return SIMPLEPIE_CONSTRUCT_BASE64;
  10322.             }
  10323.         }
  10324.         else
  10325.         {
  10326.             return SIMPLEPIE_CONSTRUCT_TEXT;
  10327.         }
  10328.     }
  10329.  
  10330.     function is_isegment_nz_nc($string)
  10331.     {
  10332.         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);
  10333.     }
  10334.  
  10335.     function space_seperated_tokens($string)
  10336.     {
  10337.         $space_characters "\x20\x09\x0A\x0B\x0C\x0D";
  10338.         $string_length strlen($string);
  10339.  
  10340.         $position strspn($string$space_characters);
  10341.         $tokens array();
  10342.  
  10343.         while ($position $string_length)
  10344.         {
  10345.             $len strcspn($string$space_characters$position);
  10346.             $tokens[substr($string$position$len);
  10347.             $position += $len;
  10348.             $position += strspn($string$space_characters$position);
  10349.         }
  10350.  
  10351.         return $tokens;
  10352.     }
  10353.  
  10354.     function array_unique($array)
  10355.     {
  10356.         if (version_compare(PHP_VERSION'5.2''>='))
  10357.         {
  10358.             return array_unique($array);
  10359.         }
  10360.         else
  10361.         {
  10362.             $array = (array) $array;
  10363.             $new_array array();
  10364.             $new_array_strings array();
  10365.             foreach ($array as $key => $value)
  10366.             {
  10367.                 if (is_object($value))
  10368.                 {
  10369.                     if (method_exists($value'__toString'))
  10370.                     {
  10371.                         $cmp $value->__toString();
  10372.                     }
  10373.                     else
  10374.                     {
  10375.                         trigger_error('Object of class ' get_class($value' could not be converted to string'E_USER_ERROR);
  10376.                     }
  10377.                 }
  10378.                 elseif (is_array($value))
  10379.                 {
  10380.                     $cmp = (string) reset($value);
  10381.                 }
  10382.                 else
  10383.                 {
  10384.                     $cmp = (string) $value;
  10385.                 }
  10386.                 if (!in_array($cmp$new_array_strings))
  10387.                 {
  10388.                     $new_array[$key$value;
  10389.                     $new_array_strings[$cmp;
  10390.                 }
  10391.             }
  10392.             return $new_array;
  10393.         }
  10394.     }
  10395.  
  10396.     /**
  10397.      * Converts a unicode codepoint to a UTF-8 character
  10398.      *
  10399.      * @static
  10400.      * @access public
  10401.      * @param int $codepoint Unicode codepoint
  10402.      * @return string UTF-8 character
  10403.      */
  10404.     function codepoint_to_utf8($codepoint)
  10405.     {
  10406.         static $cache array();
  10407.         $codepoint = (int) $codepoint;
  10408.         if (isset($cache[$codepoint]))
  10409.         {
  10410.             return $cache[$codepoint];
  10411.         }
  10412.         elseif ($codepoint 0)
  10413.         {
  10414.             return $cache[$codepointfalse;
  10415.         }
  10416.         else if ($codepoint <= 0x7f)
  10417.         {
  10418.             return $cache[$codepointchr($codepoint);
  10419.         }
  10420.         else if ($codepoint <= 0x7ff)
  10421.         {
  10422.             return $cache[$codepointchr(0xc0 ($codepoint >> 6)) chr(0x80 ($codepoint 0x3f));
  10423.         }
  10424.         else if ($codepoint <= 0xffff)
  10425.         {
  10426.             return $cache[$codepointchr(0xe0 ($codepoint >> 12)) chr(0x80 (($codepoint >> 60x3f)) chr(0x80 ($codepoint 0x3f));
  10427.         }
  10428.         else if ($codepoint <= 0x10ffff)
  10429.         {
  10430.             return $cache[$codepointchr(0xf0 ($codepoint >> 18)) chr(0x80 (($codepoint >> 120x3f)) chr(0x80 (($codepoint >> 60x3f)) chr(0x80 ($codepoint 0x3f));
  10431.         }
  10432.         else
  10433.         {
  10434.             // U+FFFD REPLACEMENT CHARACTER
  10435.             return $cache[$codepoint"\xEF\xBF\xBD";
  10436.         }
  10437.     }
  10438.  
  10439.     /**
  10440.      * Re-implementation of PHP 5's stripos()
  10441.      *
  10442.      * Returns the numeric position of the first occurrence of needle in the
  10443.      * haystack string.
  10444.      *
  10445.      * @static
  10446.      * @access string
  10447.      * @param object $haystack 
  10448.      * @param string $needle Note that the needle may be a string of one or more
  10449.      *      characters. If needle is not a string, it is converted to an integer
  10450.      *      and applied as the ordinal value of a character.
  10451.      * @param int $offset The optional offset parameter allows you to specify which
  10452.      *      character in haystack to start searching. The position returned is still
  10453.      *      relative to the beginning of haystack.
  10454.      * @return bool If needle is not found, stripos() will return boolean false.
  10455.      */
  10456.     function stripos($haystack$needle$offset 0)
  10457.     {
  10458.         if (function_exists('stripos'))
  10459.         {
  10460.             return stripos($haystack$needle$offset);
  10461.         }
  10462.         else
  10463.         {
  10464.             if (is_string($needle))
  10465.             {
  10466.                 $needle strtolower($needle);
  10467.             }
  10468.             elseif (is_int($needle|| is_bool($needle|| is_double($needle))
  10469.             {
  10470.                 $needle strtolower(chr($needle));
  10471.             }
  10472.             else
  10473.             {
  10474.                 trigger_error('needle is not a string or an integer'E_USER_WARNING);
  10475.                 return false;
  10476.             }
  10477.     
  10478.             return strpos(strtolower($haystack)$needle$offset);
  10479.         }
  10480.     }
  10481.  
  10482.     /**
  10483.      * Similar to parse_str()
  10484.      *
  10485.      * Returns an associative array of name/value pairs, where the value is an
  10486.      * array of values that have used the same name
  10487.      *
  10488.      * @static
  10489.      * @access string
  10490.      * @param string $str The input string.
  10491.      * @return array 
  10492.      */
  10493.     function parse_str($str)
  10494.     {
  10495.         $return array();
  10496.         $str explode('&'$str);
  10497.  
  10498.         foreach ($str as $section)
  10499.         {
  10500.             if (strpos($section'='!== false)
  10501.             {
  10502.                 list($name$valueexplode('='$section2);
  10503.                 $return[urldecode($name)][urldecode($value);
  10504.             }
  10505.             else
  10506.             {
  10507.                 $return[urldecode($section)][null;
  10508.             }
  10509.         }
  10510.  
  10511.         return $return;
  10512.     }
  10513.     
  10514.     /**
  10515.      * Detect XML encoding, as per XML 1.0 Appendix F.1
  10516.      *
  10517.      * @todo Add support for EBCDIC
  10518.      * @param string $data XML data
  10519.      * @return array Possible encodings
  10520.      */
  10521.     function xml_encoding($data)
  10522.     {
  10523.         // UTF-32 Big Endian BOM
  10524.         if (substr($data04=== "\x00\x00\xFE\xFF")
  10525.         {
  10526.             $encoding['UTF-32BE';
  10527.         }
  10528.         // UTF-32 Little Endian BOM
  10529.         elseif (substr($data04=== "\xFF\xFE\x00\x00")
  10530.         {
  10531.             $encoding['UTF-32LE';
  10532.         }
  10533.         // UTF-16 Big Endian BOM
  10534.         elseif (substr($data02=== "\xFE\xFF")
  10535.         {
  10536.             $encoding['UTF-16BE';
  10537.         }
  10538.         // UTF-16 Little Endian BOM
  10539.         elseif (substr($data02=== "\xFF\xFE")
  10540.         {
  10541.             $encoding['UTF-16LE';
  10542.         }
  10543.         // UTF-8 BOM
  10544.         elseif (substr($data03=== "\xEF\xBB\xBF")
  10545.         {
  10546.             $encoding['UTF-8';
  10547.         }
  10548.         // UTF-32 Big Endian Without BOM
  10549.         elseif (substr($data020=== "\x00\x00\x00\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C")
  10550.         {
  10551.             if ($pos strpos($data"\x00\x00\x00\x3F\x00\x00\x00\x3E"))
  10552.             {
  10553.                 $parser new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data20$pos 20)'UTF-32BE''UTF-8'));
  10554.                 if ($parser->parse())
  10555.                 {
  10556.                     $encoding[$parser->encoding;
  10557.                 }
  10558.             }
  10559.             $encoding['UTF-32BE';
  10560.         }
  10561.         // UTF-32 Little Endian Without BOM
  10562.         elseif (substr($data020=== "\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C\x00\x00\x00")
  10563.         {
  10564.             if ($pos strpos($data"\x3F\x00\x00\x00\x3E\x00\x00\x00"))
  10565.             {
  10566.                 $parser new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data20$pos 20)'UTF-32LE''UTF-8'));
  10567.                 if ($parser->parse())
  10568.                 {
  10569.                     $encoding[$parser->encoding;
  10570.                 }
  10571.             }
  10572.             $encoding['UTF-32LE';
  10573.         }
  10574.         // UTF-16 Big Endian Without BOM
  10575.         elseif (substr($data010=== "\x00\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C")
  10576.         {
  10577.             if ($pos strpos($data"\x00\x3F\x00\x3E"))
  10578.             {
  10579.                 $parser new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data20$pos 10)'UTF-16BE''UTF-8'));
  10580.                 if ($parser->parse())
  10581.                 {
  10582.                     $encoding[$parser->encoding;
  10583.                 }
  10584.             }
  10585.             $encoding['UTF-16BE';
  10586.         }
  10587.         // UTF-16 Little Endian Without BOM
  10588.         elseif (substr($data010=== "\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C\x00")
  10589.         {
  10590.             if ($pos strpos($data"\x3F\x00\x3E\x00"))
  10591.             {
  10592.                 $parser new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data20$pos 10)'UTF-16LE''UTF-8'));
  10593.                 if ($parser->parse())
  10594.                 {
  10595.                     $encoding[$parser->encoding;
  10596.                 }
  10597.             }
  10598.             $encoding['UTF-16LE';
  10599.         }
  10600.         // US-ASCII (or superset)
  10601.         elseif (substr($data05=== "\x3C\x3F\x78\x6D\x6C")
  10602.         {
  10603.             if ($pos strpos($data"\x3F\x3E"))
  10604.             {
  10605.                 $parser new SimplePie_XML_Declaration_Parser(substr($data5$pos 5));
  10606.                 if ($parser->parse())
  10607.                 {
  10608.                     $encoding[$parser->encoding;
  10609.                 }
  10610.             }
  10611.             $encoding['UTF-8';
  10612.         }
  10613.         // Fallback to UTF-8
  10614.         else
  10615.         {
  10616.             $encoding['UTF-8';
  10617.         }
  10618.         return $encoding;
  10619.     }
  10620. }
  10621.  
  10622. /**
  10623.  * Decode HTML Entities
  10624.  *
  10625.  * This implements HTML5 as of revision 967 (2007-06-28)
  10626.  *
  10627.  * @package SimplePie
  10628.  */
  10629. {
  10630.     /**
  10631.      * Data to be parsed
  10632.      *
  10633.      * @access private
  10634.      * @var string 
  10635.      */
  10636.     var $data '';
  10637.  
  10638.     /**
  10639.      * Currently consumed bytes
  10640.      *
  10641.      * @access private
  10642.      * @var string 
  10643.      */
  10644.     var $consumed '';
  10645.  
  10646.     /**
  10647.      * Position of the current byte being parsed
  10648.      *
  10649.      * @access private
  10650.      * @var int 
  10651.      */
  10652.     var $position 0;
  10653.  
  10654.     /**
  10655.      * Create an instance of the class with the input data
  10656.      *
  10657.      * @access public
  10658.      * @param string $data Input data
  10659.      */
  10660.     function SimplePie_Decode_HTML_Entities($data)
  10661.     {
  10662.         $this->data $data;
  10663.     }
  10664.  
  10665.     /**
  10666.      * Parse the input data
  10667.      *
  10668.      * @access public
  10669.      * @return string Output data
  10670.      */
  10671.     function parse()
  10672.     {
  10673.         while (($this->position strpos($this->data'&'$this->position)) !== false)
  10674.         {
  10675.             $this->consume();
  10676.             $this->entity();
  10677.             $this->consumed '';
  10678.         }
  10679.         return $this->data;
  10680.     }
  10681.  
  10682.     /**
  10683.      * Consume the next byte
  10684.      *
  10685.      * @access private
  10686.      * @return mixed The next byte, or false, if there is no more data
  10687.      */
  10688.     function consume()
  10689.     {
  10690.         if (isset($this->data[$this->position]))
  10691.         {
  10692.             $this->consumed .= $this->data[$this->position];
  10693.             return $this->data[$this->position++];
  10694.         }
  10695.         else
  10696.         {
  10697.             $this->consumed false;
  10698.             return false;
  10699.         }
  10700.     }
  10701.  
  10702.     /**
  10703.      * Consume a range of characters
  10704.      *
  10705.      * @access private
  10706.      * @param string $chars Characters to consume
  10707.      * @return mixed A series of characters that match the range, or false
  10708.      */
  10709.     function consume_range($chars)
  10710.     {
  10711.         if ($len strspn($this->data$chars$this->position))
  10712.         {
  10713.             $data substr($this->data$this->position$len);
  10714.             $this->consumed .= $data;
  10715.             $this->position += $len;
  10716.             return $data;
  10717.         }
  10718.         else
  10719.         {
  10720.             $this->consumed false;
  10721.             return false;
  10722.         }
  10723.     }
  10724.  
  10725.     /**
  10726.      * Unconsume one byte
  10727.      *
  10728.      * @access private
  10729.      */
  10730.     function unconsume()
  10731.     {
  10732.         $this->consumed substr($this->consumed0-1);
  10733.         $this->position--;
  10734.     }
  10735.  
  10736.     /**
  10737.      * Decode an entity
  10738.      *
  10739.      * @access private
  10740.      */
  10741.     function entity()
  10742.     {
  10743.         switch ($this->consume())
  10744.         {
  10745.             case "\x09":
  10746.             case "\x0A":
  10747.             case "\x0B":
  10748.             case "\x0B":
  10749.             case "\x0C":
  10750.             case "\x20":
  10751.             case "\x3C":
  10752.             case "\x26":
  10753.             case false:
  10754.                 break;
  10755.  
  10756.             case "\x23":
  10757.                 switch ($this->consume())
  10758.                 {
  10759.                     case "\x78":
  10760.                     case "\x58":
  10761.                         $range '0123456789ABCDEFabcdef';
  10762.                         $hex true;
  10763.                         break;
  10764.  
  10765.                     default:
  10766.                         $range '0123456789';
  10767.                         $hex false;
  10768.                         $this->unconsume();
  10769.                         break;
  10770.                 }
  10771.  
  10772.                 if ($codepoint $this->consume_range($range))
  10773.                 {
  10774.                     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");
  10775.  
  10776.                     if ($hex)
  10777.                     {
  10778.                         $codepoint hexdec($codepoint);
  10779.                     }
  10780.                     else
  10781.                     {
  10782.                         $codepoint intval($codepoint);
  10783.                     }
  10784.  
  10785.                     if (isset($windows_1252_specials[$codepoint]))
  10786.                     {
  10787.                         $replacement $windows_1252_specials[$codepoint];
  10788.                     }
  10789.                     else
  10790.                     {
  10791.                         $replacement SimplePie_Misc::codepoint_to_utf8($codepoint);
  10792.                     }
  10793.  
  10794.                     if ($this->consume(!= ';')
  10795.                     {
  10796.                         $this->unconsume();
  10797.                     }
  10798.  
  10799.                     $consumed_length strlen($this->consumed);
  10800.                     $this->data substr_replace($this->data$replacement$this->position $consumed_length$consumed_length);
  10801.                     $this->position += strlen($replacement$consumed_length;
  10802.                 }
  10803.                 break;
  10804.  
  10805.             default:
  10806.                 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");
  10807.  
  10808.                 for ($i 0$match null$i && $this->consume(!== false$i++)
  10809.                 {
  10810.                     $consumed substr($this->consumed1);
  10811.                     if (isset($entities[$consumed]))
  10812.                     {
  10813.                         $match $consumed;
  10814.                     }
  10815.                 }
  10816.  
  10817.                 if ($match !== null)
  10818.                 {
  10819.                      $this->data substr_replace($this->data$entities[$match]$this->position strlen($consumed1strlen($match1);
  10820.                     $this->position += strlen($entities[$match]strlen($consumed1;
  10821.                 }
  10822.                 break;
  10823.         }
  10824.     }
  10825. }
  10826.  
  10827. /**
  10828.  * Date Parser
  10829.  *
  10830.  * @package SimplePie
  10831.  */
  10832. {
  10833.     /**
  10834.      * Input data
  10835.      *
  10836.      * @access protected
  10837.      * @var string 
  10838.      */
  10839.     var $date;
  10840.  
  10841.     /**
  10842.      * List of days, calendar day name => ordinal day number in the week
  10843.      *
  10844.      * @access protected
  10845.      * @var array 
  10846.      */
  10847.     var $day = array(
  10848.         // English
  10849.         'mon' => 1,
  10850.         'monday' => 1,
  10851.         'tue' => 2,
  10852.         'tuesday' => 2,
  10853.         'wed' => 3,
  10854.         'wednesday' => 3,
  10855.         'thu' => 4,
  10856.         'thursday' => 4,
  10857.         'fri' => 5,
  10858.         'friday' => 5,
  10859.         'sat' => 6,
  10860.         'saturday' => 6,
  10861.         'sun' => 7,
  10862.         'sunday' => 7,
  10863.         // Dutch
  10864.         'maandag' => 1,
  10865.         'dinsdag' => 2,
  10866.         'woensdag' => 3,
  10867.         'donderdag' => 4,
  10868.         'vrijdag' => 5,
  10869.         'zaterdag' => 6,
  10870.         'zondag' => 7,
  10871.         // French
  10872.         'lundi' => 1,
  10873.         'mardi' => 2,
  10874.         'mercredi' => 3,
  10875.         'jeudi' => 4,
  10876.         'vendredi' => 5,
  10877.         'samedi' => 6,
  10878.         'dimanche' => 7,
  10879.         // German
  10880.         'montag' => 1,
  10881.         'dienstag' => 2,
  10882.         'mittwoch' => 3,
  10883.         'donnerstag' => 4,
  10884.         'freitag' => 5,
  10885.         'samstag' => 6,
  10886.         'sonnabend' => 6,
  10887.         'sonntag' => 7,
  10888.         // Italian
  10889.         'lunedì' => 1,
  10890.         'martedì' => 2,
  10891.         'mercoledì' => 3,
  10892.         'giovedì' => 4,
  10893.         'venerdì' => 5,
  10894.         'sabato' => 6,
  10895.         'domenica' => 7,
  10896.         // Spanish
  10897.         'lunes' => 1,
  10898.         'martes' => 2,
  10899.         'miércoles' => 3,
  10900.         'jueves' => 4,
  10901.         'viernes' => 5,
  10902.         'sábado' => 6,
  10903.         'domingo' => 7,
  10904.         // Finnish
  10905.         'maanantai' => 1,
  10906.         'tiistai' => 2,
  10907.         'keskiviikko' => 3,
  10908.         'torstai' => 4,
  10909.         'perjantai' => 5,
  10910.         'lauantai' => 6,
  10911.         'sunnuntai' => 7,
  10912.         // Hungarian
  10913.         'hétfő' => 1,
  10914.         'kedd' => 2,
  10915.         'szerda' => 3,
  10916.         'csütörtok' => 4,
  10917.         'péntek' => 5,
  10918.         'szombat' => 6,
  10919.         'vasárnap' => 7,
  10920.         // Greek
  10921.         'Δευ' => 1,
  10922.         'Τρι' => 2,
  10923.         'Τετ' => 3,
  10924.         'Πεμ' => 4,
  10925.         'Παρ' => 5,
  10926.         'Σαβ' => 6,
  10927.         'Κυρ' => 7,
  10928.     );
  10929.  
  10930.     /**
  10931.      * List of months, calendar month name => calendar month number
  10932.      *
  10933.      * @access protected
  10934.      * @var array 
  10935.      */
  10936.     var $month = array(
  10937.         // English
  10938.         'jan' => 1,
  10939.         'january' => 1,
  10940.         'feb' => 2,
  10941.         'february' => 2,
  10942.         'mar' => 3,
  10943.         'march' => 3,
  10944.         'apr' => 4,
  10945.         'april' => 4,
  10946.         'may' => 5,
  10947.         // No long form of May
  10948.         'jun' => 6,
  10949.         'june' => 6,
  10950.         'jul' => 7,
  10951.         'july' => 7,
  10952.         'aug' => 8,
  10953.         'august' => 8,
  10954.         'sep' => 9,
  10955.         'september' => 8,
  10956.         'oct' => 10,
  10957.         'october' => 10,
  10958.         'nov' => 11,
  10959.         'november' => 11,
  10960.         'dec' => 12,
  10961.         'december' => 12,
  10962.         // Dutch
  10963.         'januari' => 1,
  10964.         'februari' => 2,
  10965.         'maart' => 3,
  10966.         'april' => 4,
  10967.         'mei' => 5,
  10968.         'juni' => 6,
  10969.         'juli' => 7,
  10970.         'augustus' => 8,
  10971.         'september' => 9,
  10972.         'oktober' => 10,
  10973.         'november' => 11,
  10974.         'december' => 12,
  10975.         // French
  10976.         'janvier' => 1,
  10977.         'février' => 2,
  10978.         'mars' => 3,
  10979.         'avril' => 4,
  10980.         'mai' => 5,
  10981.         'juin' => 6,
  10982.         'juillet' => 7,
  10983.         'août' => 8,
  10984.         'septembre' => 9,
  10985.         'octobre' => 10,
  10986.         'novembre' => 11,
  10987.         'décembre' => 12,
  10988.         // German
  10989.         'januar' => 1,
  10990.         'februar' => 2,
  10991.         'märz' => 3,
  10992.         'april' => 4,
  10993.         'mai' => 5,
  10994.         'juni' => 6,
  10995.         'juli' => 7,
  10996.         'august' => 8,
  10997.         'september' => 9,
  10998.         'oktober' => 10,
  10999.         'november' => 11,
  11000.         'dezember' => 12,
  11001.         // Italian
  11002.         'gennaio' => 1,
  11003.         'febbraio' => 2,
  11004.         'marzo' => 3,
  11005.         'aprile' => 4,
  11006.         'maggio' => 5,
  11007.         'giugno' => 6,
  11008.         'luglio' => 7,
  11009.         'agosto' => 8,
  11010.         'settembre' => 9,
  11011.         'ottobre' => 10,
  11012.         'novembre' => 11,
  11013.         'dicembre' => 12,
  11014.         // Spanish
  11015.         'enero' => 1,
  11016.         'febrero' => 2,
  11017.         'marzo' => 3,
  11018.         'abril' => 4,
  11019.         'mayo' => 5,
  11020.         'junio' => 6,
  11021.         'julio' => 7,
  11022.         'agosto' => 8,
  11023.         'septiembre' => 9,
  11024.         'setiembre' => 9,
  11025.         'octubre' => 10,
  11026.         'noviembre' => 11,
  11027.         'diciembre' => 12,
  11028.         // Finnish
  11029.         'tammikuu' => 1,
  11030.         'helmikuu' => 2,
  11031.         'maaliskuu' => 3,
  11032.         'huhtikuu' => 4,
  11033.         'toukokuu' => 5,
  11034.         'kesäkuu' => 6,
  11035.         'heinäkuu' => 7,
  11036.         'elokuu' => 8,
  11037.         'suuskuu' => 9,
  11038.         'lokakuu' => 10,
  11039.         'marras' => 11,
  11040.         'joulukuu' => 12,
  11041.         // Hungarian
  11042.         'január' => 1,
  11043.         'február' => 2,
  11044.         'március' => 3,
  11045.         'április' => 4,
  11046.         'május' => 5,
  11047.         'június' => 6,
  11048.         'július' => 7,
  11049.         'augusztus' => 8,
  11050.         'szeptember' => 9,
  11051.         'október' => 10,
  11052.         'november' => 11,
  11053.         'december' => 12,
  11054.         // Greek
  11055.         'Ιαν' => 1,
  11056.         'Φεβ' => 2,
  11057.         'Μάώ' => 3,
  11058.         'Μαώ' => 3,
  11059.         'Απρ' => 4,
  11060.         'Μάι' => 5,
  11061.         'Μαϊ' => 5,
  11062.         'Μαι' => 5,
  11063.         'Ιούν' => 6,
  11064.         'Ιον' => 6,
  11065.         'Ιούλ' => 7,
  11066.         'Ιολ' => 7,
  11067.         'Αύγ' => 8,
  11068.         'Αυγ' => 8,
  11069.         'Σεπ' => 9,
  11070.         'Οκτ' => 10,
  11071.         'Νοέ' => 11,
  11072.         'Δεκ' => 12,
  11073.     );
  11074.  
  11075.     /**
  11076.      * List of timezones, abbreviation => offset from UTC
  11077.      *
  11078.      * @access protected
  11079.      * @var array 
  11080.      */
  11081.     var $timezone = array(
  11082.         'ACDT' => 37800,
  11083.         'ACIT' => 28800,
  11084.         'ACST' => 34200,
  11085.         'ACT' => -18000,
  11086.         'ACWDT' => 35100,
  11087.         'ACWST' => 31500,
  11088.         'AEDT' => 39600,
  11089.         'AEST' => 36000,
  11090.         'AFT' => 16200,
  11091.         'AKDT' => -28800,
  11092.         'AKST' => -32400,
  11093.         'AMDT' => 18000,
  11094.         'AMT' => -14400,
  11095.         'ANAST' => 46800,
  11096.         'ANAT' => 43200,
  11097.         'ART' => -10800,
  11098.         'AZOST' => -3600,
  11099.         'AZST' => 18000,
  11100.         'AZT' => 14400,
  11101.         'BIOT' => 21600,
  11102.         'BIT' => -43200,
  11103.         'BOT' => -14400,
  11104.         'BRST' => -7200,
  11105.         'BRT' => -10800,
  11106.         'BST' => 3600,
  11107.         'BTT' => 21600,
  11108.         'CAST' => 18000,
  11109.         'CAT' => 7200,
  11110.         'CCT' => 23400,
  11111.         'CDT' => -18000,
  11112.         'CEDT' => 7200,
  11113.         'CET' => 3600,
  11114.         'CGST' => -7200,
  11115.         'CGT' => -10800,
  11116.         'CHADT' => 49500,
  11117.         'CHAST' => 45900,
  11118.         'CIST' => -28800,
  11119.         'CKT' => -36000,
  11120.         'CLDT' => -10800,
  11121.         'CLST' => -14400,
  11122.         'COT' => -18000,
  11123.         'CST' => -21600,
  11124.         'CVT' => -3600,
  11125.         'CXT' => 25200,
  11126.         'DAVT' => 25200,
  11127.         'DTAT' => 36000,
  11128.         'EADT' => -18000,
  11129.         'EAST' => -21600,
  11130.         'EAT' => 10800,
  11131.         'ECT' => -18000,
  11132.         'EDT' => -14400,
  11133.         'EEST' => 10800,
  11134.         'EET' => 7200,
  11135.         'EGT' => -3600,
  11136.         'EKST' => 21600,
  11137.         'EST' => -18000,
  11138.         'FJT' => 43200,
  11139.         'FKDT' => -10800,
  11140.         'FKST' => -14400,
  11141.         'FNT' => -7200,
  11142.         'GALT' => -21600,
  11143.         'GEDT' => 14400,
  11144.         'GEST' => 10800,
  11145.         'GFT' => -10800,
  11146.         'GILT' => 43200,
  11147.         'GIT' => -32400,
  11148.         'GST' => 14400,
  11149.         'GST' => -7200,
  11150.         'GYT' => -14400,
  11151.         'HAA' => -10800,
  11152.         'HAC' => -18000,
  11153.         'HADT' => -32400,
  11154.         'HAE' => -14400,
  11155.         'HAP' => -25200,
  11156.         'HAR' => -21600,
  11157.         'HAST' => -36000,
  11158.         'HAT' => -9000,
  11159.         'HAY' => -28800,
  11160.         'HKST' => 28800,
  11161.         'HMT' => 18000,
  11162.         'HNA' => -14400,
  11163.         'HNC' => -21600,
  11164.         'HNE' => -18000,
  11165.         'HNP' => -28800,
  11166.         'HNR' => -25200,
  11167.         'HNT' => -12600,
  11168.         'HNY' => -32400,
  11169.         'IRDT' => 16200,
  11170.         'IRKST' => 32400,
  11171.         'IRKT' => 28800,
  11172.         'IRST' => 12600,
  11173.         'JFDT' => -10800,
  11174.         'JFST' => -14400,
  11175.         'JST' => 32400,
  11176.         'KGST' => 21600,
  11177.         'KGT' => 18000,
  11178.         'KOST' => 39600,
  11179.         'KOVST' => 28800,
  11180.         'KOVT' => 25200,
  11181.         'KRAST' => 28800,
  11182.         'KRAT' => 25200,
  11183.         'KST' => 32400,
  11184.         'LHDT' => 39600,
  11185.         'LHST' => 37800,
  11186.         'LINT' => 50400,
  11187.         'LKT' => 21600,
  11188.         'MAGST' => 43200,
  11189.         'MAGT' => 39600,
  11190.         'MAWT' => 21600,
  11191.         'MDT' => -21600,
  11192.         'MESZ' => 7200,
  11193.         'MEZ' => 3600,
  11194.         'MHT' => 43200,
  11195.         'MIT' => -34200,
  11196.         'MNST' => 32400,
  11197.         'MSDT' => 14400,
  11198.         'MSST' => 10800,
  11199.         'MST' => -25200,
  11200.         'MUT' => 14400,
  11201.         'MVT' => 18000,
  11202.         'MYT' => 28800,
  11203.         'NCT' => 39600,
  11204.         'NDT' => -9000,
  11205.         'NFT' => 41400,
  11206.         'NMIT' => 36000,
  11207.         'NOVST' => 25200,
  11208.         'NOVT' => 21600,
  11209.         'NPT' => 20700,
  11210.         'NRT' => 43200,
  11211.         'NST' => -12600,
  11212.         'NUT' => -39600,
  11213.         'NZDT' => 46800,
  11214.         'NZST' => 43200,
  11215.         'OMSST' => 25200,
  11216.         'OMST' => 21600,
  11217.         'PDT' => -25200,
  11218.         'PET' => -18000,
  11219.         'PETST' => 46800,
  11220.         'PETT' => 43200,
  11221.         'PGT' => 36000,
  11222.         'PHOT' => 46800,
  11223.         'PHT' => 28800,
  11224.         'PKT' => 18000,
  11225.         'PMDT' => -7200,
  11226.         'PMST' => -10800,
  11227.         'PONT' => 39600,
  11228.         'PST' => -28800,
  11229.         'PWT' => 32400,
  11230.         'PYST' => -10800,
  11231.         'PYT' => -14400,
  11232.         'RET' => 14400,
  11233.         'ROTT' => -10800,
  11234.         'SAMST' => 18000,
  11235.         'SAMT' => 14400,
  11236.         'SAST' => 7200,
  11237.         'SBT' => 39600,
  11238.         'SCDT' => 46800,
  11239.         'SCST' => 43200,
  11240.         'SCT' => 14400,
  11241.         'SEST' => 3600,
  11242.         'SGT' => 28800,
  11243.         'SIT' => 28800,
  11244.         'SRT' => -10800,
  11245.         'SST' => -39600,
  11246.         'SYST' => 10800,
  11247.         'SYT' => 7200,
  11248.         'TFT' => 18000,
  11249.         'THAT' => -36000,
  11250.         'TJT' => 18000,
  11251.         'TKT' => -36000,
  11252.         'TMT' => 18000,
  11253.         'TOT' => 46800,
  11254.         'TPT' => 32400,
  11255.         'TRUT' => 36000,
  11256.         'TVT' => 43200,
  11257.         'TWT' => 28800,
  11258.         'UYST' => -7200,
  11259.         'UYT' => -10800,
  11260.         'UZT' => 18000,
  11261.         'VET' => -14400,
  11262.         'VLAST' => 39600,
  11263.         'VLAT' => 36000,
  11264.         'VOST' => 21600,
  11265.         'VUT' => 39600,
  11266.         'WAST' => 7200,
  11267.         'WAT' => 3600,
  11268.         'WDT' => 32400,
  11269.         'WEST' => 3600,
  11270.         'WFT' => 43200,
  11271.         'WIB' => 25200,
  11272.         'WIT' => 32400,
  11273.         'WITA' => 28800,
  11274.         'WKST' => 18000,
  11275.         'WST' => 28800,
  11276.         'YAKST' => 36000,
  11277.         'YAKT' => 32400,
  11278.         'YAPT' => 36000,
  11279.         'YEKST' => 21600,
  11280.         'YEKT' => 18000,
  11281.     );
  11282.  
  11283.     /**
  11284.      * Cached PCRE for SimplePie_Parse_Date::$day
  11285.      *
  11286.      * @access protected
  11287.      * @var string 
  11288.      */
  11289.     var $day_pcre;
  11290.  
  11291.     /**
  11292.      * Cached PCRE for SimplePie_Parse_Date::$month
  11293.      *
  11294.      * @access protected
  11295.      * @var string 
  11296.      */
  11297.     var $month_pcre;
  11298.  
  11299.     /**
  11300.      * Array of user-added callback methods
  11301.      *
  11302.      * @access private
  11303.      * @var array 
  11304.      */
  11305.     var $built_in array();
  11306.  
  11307.     /**
  11308.      * Array of user-added callback methods
  11309.      *
  11310.      * @access private
  11311.      * @var array 
  11312.      */
  11313.     var $user array();
  11314.  
  11315.     /**
  11316.      * Create new SimplePie_Parse_Date object, and set self::day_pcre,
  11317.      * self::month_pcre, and self::built_in
  11318.      *
  11319.      * @access private
  11320.      */
  11321.     function SimplePie_Parse_Date()
  11322.     {
  11323.         $this->day_pcre = '(' implode(array_keys($this->day)'|'')';
  11324.         $this->month_pcre = '(' implode(array_keys($this->month)'|'')';
  11325.         
  11326.         static $cache;
  11327.         if (!isset($cache[get_class($this)]))
  11328.         {
  11329.             if (extension_loaded('Reflection'))
  11330.             {
  11331.                 $class new ReflectionClass(get_class($this));
  11332.                 $methods $class->getMethods();
  11333.                 $all_methods array();
  11334.                 foreach ($methods as $method)
  11335.                 {
  11336.                     $all_methods[$method->getName();
  11337.                 }
  11338.             }
  11339.             else
  11340.             {
  11341.                 $all_methods get_class_methods($this);
  11342.             }
  11343.         
  11344.             foreach ($all_methods as $method)
  11345.             {
  11346.                 if (strtolower(substr($method05)) === 'date_')
  11347.                 {
  11348.                     $cache[get_class($this)][$method;
  11349.                 }
  11350.             }
  11351.         }
  11352.         
  11353.         foreach ($cache[get_class($this)as $method)
  11354.         {
  11355.             $this->built_in[$method;
  11356.         }
  11357.     }
  11358.     
  11359.     /**
  11360.      * Get the object
  11361.      *
  11362.      * @access public
  11363.      */
  11364.     function get()
  11365.     {
  11366.         static $object;
  11367.         if (!$object)
  11368.         {
  11369.             $object new SimplePie_Parse_Date;
  11370.         }
  11371.         return $object;
  11372.     }
  11373.  
  11374.     /**
  11375.      * Parse a date
  11376.      *
  11377.      * @final
  11378.      * @access public
  11379.      * @param string $date Date to parse
  11380.      * @return int Timestamp corresponding to date string, or false on failure
  11381.      */
  11382.     function parse($date)
  11383.     {
  11384.         foreach ($this->user as $method)
  11385.         {
  11386.             if (($returned call_user_func($method$date)) !== false)
  11387.             {
  11388.                 return $returned;
  11389.             }
  11390.         }
  11391.         
  11392.         foreach ($this->built_in as $method)
  11393.         {
  11394.             if (($returned call_user_func(array(&$this$method)$date)) !== false)
  11395.             {
  11396.                 return $returned;
  11397.             }
  11398.         }
  11399.  
  11400.         return false;
  11401.     }
  11402.  
  11403.     /**
  11404.      * Add a callback method to parse a date
  11405.      *
  11406.      * @final
  11407.      * @access public
  11408.      * @param callback $callback 
  11409.      */
  11410.     function add_callback($callback)
  11411.     {
  11412.         if (is_callable($callback))
  11413.         {
  11414.             $this->user[$callback;
  11415.         }
  11416.         else
  11417.         {
  11418.             trigger_error('User-supplied function must be a valid callback'E_USER_WARNING);
  11419.         }
  11420.     }
  11421.  
  11422.     /**
  11423.      * Parse a superset of W3C-DTF (allows hyphens and colons to be omitted, as
  11424.      * well as allowing any of upper or lower case "T", horizontal tabs, or
  11425.      * spaces to be used as the time seperator (including more than one))
  11426.      *
  11427.      * @access protected
  11428.      * @return int Timestamp
  11429.      */
  11430.     function date_w3cdtf($date)
  11431.     {
  11432.         static $pcre;
  11433.         if (!$pcre)
  11434.         {
  11435.             $year '([0-9]{4})';
  11436.             $month $day $hour $minute $second '([0-9]{2})';
  11437.             $decimal '([0-9]*)';
  11438.             $zone '(?:(Z)|([+\-])([0-9]{1,2}):?([0-9]{1,2}))';
  11439.             $pcre '/^' $year '(?:-?' $month '(?:-?' $day '(?:[Tt\x09\x20]+' $hour '(?::?' $minute '(?::?' $second '(?:.' $decimal ')?)?)?' $zone ')?)?)?$/';
  11440.         }
  11441.         if (preg_match($pcre$date$match))
  11442.         {
  11443.             /*
  11444.             Capturing subpatterns:
  11445.             1: Year
  11446.             2: Month
  11447.             3: Day
  11448.             4: Hour
  11449.             5: Minute
  11450.             6: Second
  11451.             7: Decimal fraction of a second
  11452.             8: Zulu
  11453.             9: Timezone ±
  11454.             10: Timezone hours
  11455.             11: Timezone minutes
  11456.             */
  11457.  
  11458.             // Fill in empty matches
  11459.             for ($i count($match)$i <= 3$i++)
  11460.             {
  11461.                 $match[$i'1';
  11462.             }
  11463.  
  11464.             for ($i count($match)$i <= 7$i++)
  11465.             {
  11466.                 $match[$i'0';
  11467.             }
  11468.  
  11469.             // Numeric timezone
  11470.             if (isset($match[9]&& $match[9!== '')
  11471.             {
  11472.                 $timezone $match[103600;
  11473.                 $timezone += $match[1160;
  11474.                 if ($match[9=== '-')
  11475.                 {
  11476.                     $timezone $timezone;
  11477.                 }
  11478.             }
  11479.             else
  11480.             {
  11481.                 $timezone 0;
  11482.             }
  11483.  
  11484.             // Convert the number of seconds to an integer, taking decimals into account
  11485.             $second round($match[6$match[7pow(10strlen($match[7])));
  11486.  
  11487.             return gmmktime($match[4]$match[5]$second$match[2]$match[3]$match[1]$timezone;
  11488.         }
  11489.         else
  11490.         {
  11491.             return false;
  11492.         }
  11493.     }
  11494.  
  11495.     /**
  11496.      * Remove RFC822 comments
  11497.      *
  11498.      * @access protected
  11499.      * @param string $data Data to strip comments from
  11500.      * @return string Comment stripped string
  11501.      */
  11502.     function remove_rfc2822_comments($string)
  11503.     {
  11504.         $string = (string) $string;
  11505.         $position 0;
  11506.         $length strlen($string);
  11507.         $depth 0;
  11508.  
  11509.         $output '';
  11510.  
  11511.         while ($position $length && ($pos strpos($string'('$position)) !== false)
  11512.         {
  11513.             $output .= substr($string$position$pos $position);
  11514.             $position $pos 1;
  11515.             if ($string[$pos 1!== '\\')
  11516.             {
  11517.                 $depth++;
  11518.                 while ($depth && $position $length)
  11519.                 {
  11520.                     $position += strcspn($string'()'$position);
  11521.                     if ($string[$position 1=== '\\')
  11522.                     {
  11523.                         $position++;
  11524.                         continue;
  11525.                     }
  11526.                     elseif (isset($string[$position]))
  11527.                     {
  11528.                         switch ($string[$position])
  11529.                         {
  11530.                             case '(':
  11531.                                 $depth++;
  11532.                                 break;
  11533.  
  11534.                             case ')':
  11535.                                 $depth--;
  11536.                                 break;
  11537.                         }
  11538.                         $position++;
  11539.                     }
  11540.                     else
  11541.                     {
  11542.                         break;
  11543.                     }
  11544.                 }
  11545.             }
  11546.             else
  11547.             {
  11548.                 $output .= '(';
  11549.             }
  11550.         }
  11551.         $output .= substr($string$position);
  11552.  
  11553.         return $output;
  11554.     }
  11555.  
  11556.     /**
  11557.      * Parse RFC2822's date format
  11558.      *
  11559.      * @access protected
  11560.      * @return int Timestamp
  11561.      */
  11562.     function date_rfc2822($date)
  11563.     {
  11564.         static $pcre;
  11565.         if (!$pcre)
  11566.         {
  11567.             $wsp '[\x09\x20]';
  11568.             $fws '(?:' $wsp '+|' $wsp '*(?:\x0D\x0A' $wsp '+)+)';
  11569.             $optional_fws $fws '?';
  11570.             $day_name $this->day_pcre;
  11571.             $month $this->month_pcre;
  11572.             $day '([0-9]{1,2})';
  11573.             $hour $minute $second '([0-9]{2})';
  11574.             $year '([0-9]{2,4})';
  11575.             $num_zone '([+\-])([0-9]{2})([0-9]{2})';
  11576.             $character_zone '([A-Z]{1,5})';
  11577.             $zone '(?:' $num_zone '|' $character_zone ')';
  11578.             $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';
  11579.         }
  11580.         if (preg_match($pcre$this->remove_rfc2822_comments($date)$match))
  11581.         {
  11582.             /*
  11583.             Capturing subpatterns:
  11584.             1: Day name
  11585.             2: Day
  11586.             3: Month
  11587.             4: Year
  11588.             5: Hour
  11589.             6: Minute
  11590.             7: Second
  11591.             8: Timezone ±
  11592.             9: Timezone hours
  11593.             10: Timezone minutes
  11594.             11: Alphabetic timezone
  11595.             */
  11596.  
  11597.             // Find the month number
  11598.             $month $this->month[strtolower($match[3])];
  11599.  
  11600.             // Numeric timezone
  11601.             if ($match[8!== '')
  11602.             {
  11603.                 $timezone $match[93600;
  11604.                 $timezone += $match[1060;
  11605.                 if ($match[8=== '-')
  11606.                 {
  11607.                     $timezone $timezone;
  11608.                 }
  11609.             }
  11610.             // Character timezone
  11611.             elseif (isset($this->timezone[strtoupper($match[11])]))
  11612.             {
  11613.                 $timezone $this->timezone[strtoupper($match[11])];
  11614.             }
  11615.             // Assume everything else to be -0000
  11616.             else
  11617.             {
  11618.                 $timezone 0;
  11619.             }
  11620.  
  11621.             // Deal with 2/3 digit years
  11622.             if ($match[450)
  11623.             {
  11624.                 $match[4+= 2000;
  11625.             }
  11626.             elseif ($match[41000)
  11627.             {
  11628.                 $match[4+= 1900;
  11629.             }
  11630.             
  11631.             // Second is optional, if it is empty set it to zero
  11632.             if ($match[7!== '')
  11633.             {
  11634.                 $second $match[7];
  11635.             }
  11636.             else
  11637.             {
  11638.                 $second 0;
  11639.             }
  11640.  
  11641.             return gmmktime($match[5]$match[6]$second$month$match[2]$match[4]$timezone;
  11642.         }
  11643.         else
  11644.         {
  11645.             return false;
  11646.         }
  11647.     }
  11648.  
  11649.     /**
  11650.      * Parse RFC850's date format
  11651.      *
  11652.      * @access protected
  11653.      * @return int Timestamp
  11654.      */
  11655.     function date_rfc850($date)
  11656.     {
  11657.         static $pcre;
  11658.         if (!$pcre)
  11659.         {
  11660.             $space '[\x09\x20]+';
  11661.             $day_name $this->day_pcre;
  11662.             $month $this->month_pcre;
  11663.             $day '([0-9]{1,2})';
  11664.             $year $hour $minute $second '([0-9]{2})';
  11665.             $zone '([A-Z]{1,5})';
  11666.             $pcre '/^' $day_name ',' $space $day '-' $month '-' $year $space $hour ':' $minute ':' $second $space $zone '$/i';
  11667.         }
  11668.         if (preg_match($pcre$date$match))
  11669.         {
  11670.             /*
  11671.             Capturing subpatterns:
  11672.             1: Day name
  11673.             2: Day
  11674.             3: Month
  11675.             4: Year
  11676.             5: Hour
  11677.             6: Minute
  11678.             7: Second
  11679.             8: Timezone
  11680.             */
  11681.  
  11682.             // Month
  11683.             $month $this->month[strtolower($match[3])];
  11684.  
  11685.             // Character timezone
  11686.             if (isset($this->timezone[strtoupper($match[8])]))
  11687.             {
  11688.                 $timezone $this->timezone[strtoupper($match[8])];
  11689.             }
  11690.             // Assume everything else to be -0000
  11691.             else
  11692.             {
  11693.                 $timezone 0;
  11694.             }
  11695.  
  11696.             // Deal with 2 digit year
  11697.             if ($match[450)
  11698.             {
  11699.                 $match[4+= 2000;
  11700.             }
  11701.             else
  11702.             {
  11703.                 $match[4+= 1900;
  11704.             }
  11705.  
  11706.             return gmmktime($match[5]$match[6]$match[7]$month$match[2]$match[4]$timezone;
  11707.         }
  11708.         else
  11709.         {
  11710.             return false;
  11711.         }
  11712.     }
  11713.  
  11714.     /**
  11715.      * Parse C99's asctime()'s date format
  11716.      *
  11717.      * @access protected
  11718.      * @return int Timestamp
  11719.      */
  11720.     function date_asctime($date)
  11721.     {
  11722.         static $pcre;
  11723.         if (!$pcre)
  11724.         {
  11725.             $space '[\x09\x20]+';
  11726.             $wday_name $this->day_pcre;
  11727.             $mon_name $this->month_pcre;
  11728.             $day '([0-9]{1,2})';
  11729.             $hour $sec $min '([0-9]{2})';
  11730.             $year '([0-9]{4})';
  11731.             $terminator '\x0A?\x00?';
  11732.             $pcre '/^' $wday_name $space $mon_name $space $day $space $hour ':' $min ':' $sec $space $year $terminator '$/i';
  11733.         }
  11734.         if (preg_match($pcre$date$match))
  11735.         {
  11736.             /*
  11737.             Capturing subpatterns:
  11738.             1: Day name
  11739.             2: Month
  11740.             3: Day
  11741.             4: Hour
  11742.             5: Minute
  11743.             6: Second
  11744.             7: Year
  11745.             */
  11746.  
  11747.             $month $this->month[strtolower($match[2])];
  11748.             return gmmktime($match[4]$match[5]$match[6]$month$match[3]$match[7]);
  11749.         }
  11750.         else
  11751.         {
  11752.             return false;
  11753.         }
  11754.     }
  11755.  
  11756.     /**
  11757.      * Parse dates using strtotime()
  11758.      *
  11759.      * @access protected
  11760.      * @return int Timestamp
  11761.      */
  11762.     function date_strtotime($date)
  11763.     {
  11764.         $strtotime strtotime($date);
  11765.         if ($strtotime === -|| $strtotime === false)
  11766.         {
  11767.             return false;
  11768.         }
  11769.         else
  11770.         {
  11771.             return $strtotime;
  11772.         }
  11773.     }
  11774. }
  11775.  
  11776. /**
  11777.  * Content-type sniffing
  11778.  *
  11779.  * @package SimplePie
  11780.  */
  11781. {
  11782.     /**
  11783.      * File object
  11784.      *
  11785.      * @var SimplePie_File 
  11786.      * @access private
  11787.      */
  11788.     var $file;
  11789.     
  11790.     /**
  11791.      * Create an instance of the class with the input file
  11792.      *
  11793.      * @access public
  11794.      * @param SimplePie_Content_Type_Sniffer $file Input file
  11795.      */
  11796.     function SimplePie_Content_Type_Sniffer($file)
  11797.     {
  11798.         $this->file $file;
  11799.     }
  11800.     
  11801.     /**
  11802.      * Get the Content-Type of the specified file
  11803.      *
  11804.      * @access public
  11805.      * @return string Actual Content-Type
  11806.      */
  11807.     function get_type()
  11808.     {
  11809.         if (isset($this->file->headers['content-type']))
  11810.         {
  11811.             if (!isset($this->file->headers['content-encoding'])
  11812.                 && ($this->file->headers['content-type'=== 'text/plain'
  11813.                     || $this->file->headers['content-type'=== 'text/plain; charset=ISO-8859-1'
  11814.                     || $this->file->headers['content-type'=== 'text/plain; charset=iso-8859-1'))
  11815.             {
  11816.                 return $this->text_or_binary();
  11817.             }
  11818.             
  11819.             if (($pos strpos($this->file->headers['content-type']';')) !== false)
  11820.             
  11821.                 $official substr($this->file->headers['content-type']0$pos);
  11822.             }
  11823.             else
  11824.             {
  11825.                 $official $this->file->headers['content-type'];
  11826.             }
  11827.             $official strtolower($official);
  11828.             
  11829.             if ($official === 'unknown/unknown'
  11830.                 || $official === 'application/unknown')
  11831.             {
  11832.                 return $this->unknown();
  11833.             }
  11834.             elseif (substr($official-4=== '+xml'
  11835.                 || $official === 'text/xml'
  11836.                 || $official === 'application/xml')
  11837.             {
  11838.                 return $official;
  11839.             }
  11840.             elseif (substr($official06=== 'image/')
  11841.             {
  11842.                 if ($return $this->image())
  11843.                 {
  11844.                     return $return;
  11845.                 }
  11846.                 else
  11847.                 {
  11848.                     return $official;
  11849.                 }
  11850.             }
  11851.             elseif ($official === 'text/html')
  11852.             {
  11853.                 return $this->feed_or_html();
  11854.             }
  11855.             else
  11856.             {
  11857.                 return $official;
  11858.             }
  11859.         }
  11860.         else
  11861.         {
  11862.             return $this->unknown();
  11863.         }
  11864.     }
  11865.     
  11866.     /**
  11867.      * Sniff text or binary
  11868.      *
  11869.      * @access private
  11870.      * @return string Actual Content-Type
  11871.      */
  11872.     function text_or_binary()
  11873.     {
  11874.         if (substr($this->file->body02=== "\xFE\xFF"
  11875.             || substr($this->file->body02=== "\xFF\xFE"
  11876.             || substr($this->file->body04=== "\x00\x00\xFE\xFF"
  11877.             || substr($this->file->body03=== "\xEF\xBB\xBF")
  11878.         {
  11879.             return 'text/plain';
  11880.         }
  11881.         elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/'$this->file->body))
  11882.         {
  11883.             return 'application/octect-stream';
  11884.         }
  11885.         else
  11886.         {
  11887.             return 'text/plain';
  11888.         }
  11889.     }
  11890.     
  11891.     /**
  11892.      * Sniff unknown
  11893.      *
  11894.      * @access private
  11895.      * @return string Actual Content-Type
  11896.      */
  11897.     function unknown()
  11898.     {
  11899.         $ws strspn($this->file->body"\x09\x0A\x0B\x0C\x0D\x20");
  11900.         if (strtolower(substr($this->file->body$ws14)) === '<!doctype html'
  11901.             || strtolower(substr($this->file->body$ws5)) === '<html'
  11902.             || strtolower(substr($this->file->body$ws7)) === '<script')
  11903.         {
  11904.             return 'text/html';
  11905.         }
  11906.         elseif (substr($this->file->body05=== '%PDF-')
  11907.         {
  11908.             return 'application/pdf';
  11909.         }
  11910.         elseif (substr($this->file->body011=== '%!PS-Adobe-')
  11911.         {
  11912.             return 'application/postscript';
  11913.         }
  11914.         elseif (substr($this->file->body06=== 'GIF87a'
  11915.             || substr($this->file->body06=== 'GIF89a')
  11916.         {
  11917.             return 'image/gif';
  11918.         }
  11919.         elseif (substr($this->file->body08=== "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")
  11920.         {
  11921.             return 'image/png';
  11922.         }
  11923.         elseif (substr($this->file->body03=== "\xFF\xD8\xFF")
  11924.         {
  11925.             return 'image/jpeg';
  11926.         }
  11927.         elseif (substr($this->file->body02=== "\x42\x4D")
  11928.         {
  11929.             return 'image/bmp';
  11930.         }
  11931.         else
  11932.         {
  11933.             return $this->text_or_binary();
  11934.         }
  11935.     }
  11936.     
  11937.     /**
  11938.      * Sniff images
  11939.      *
  11940.      * @access private
  11941.      * @return string Actual Content-Type
  11942.      */
  11943.     function image()
  11944.     {
  11945.         if (substr($this->file->body06=== 'GIF87a'
  11946.             || substr($this->file->body06=== 'GIF89a')
  11947.         {
  11948.             return 'image/gif';
  11949.         }
  11950.         elseif (substr($this->file->body08=== "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")
  11951.         {
  11952.             return 'image/png';
  11953.         }
  11954.         elseif (substr($this->file->body03=== "\xFF\xD8\xFF")
  11955.         {
  11956.             return 'image/jpeg';
  11957.         }
  11958.         elseif (substr($this->file->body02=== "\x42\x4D")
  11959.         {
  11960.             return 'image/bmp';
  11961.         }
  11962.         else
  11963.         {
  11964.             return false;
  11965.         }
  11966.     }
  11967.     
  11968.     /**
  11969.      * Sniff HTML
  11970.      *
  11971.      * @access private
  11972.      * @return string Actual Content-Type
  11973.      */
  11974.     function feed_or_html()
  11975.     {
  11976.         $len strlen($this->file->body);
  11977.         $pos strspn($this->file->body"\x09\x0A\x0D\x20");
  11978.         
  11979.         while ($pos $len)
  11980.         {
  11981.             switch ($this->file->body[$pos])
  11982.             {
  11983.                 case "\x09":
  11984.                 case "\x0A":
  11985.                 case "\x0D":
  11986.                 case "\x20":
  11987.                     $pos += strspn($this->file->body"\x09\x0A\x0D\x20"$pos);
  11988.                     continue 2;
  11989.                 
  11990.                 case '<':
  11991.                     $pos++;
  11992.                     break;
  11993.                 
  11994.                 default:
  11995.                     return 'text/html';
  11996.             }
  11997.             
  11998.             if (substr($this->file->body$pos3=== '!--')
  11999.             {
  12000.                 $pos += 3;
  12001.                 if ($pos $len && ($pos strpos($this->file->body'-->'$pos)) !== false)
  12002.                 {
  12003.                     $pos += 3;
  12004.                 }
  12005.                 else
  12006.                 {
  12007.                     return 'text/html';
  12008.                 }
  12009.             }
  12010.             elseif (substr($this->file->body$pos1=== '!')
  12011.             {
  12012.                 if ($pos $len && ($pos strpos($this->file->body'>'$pos)) !== false)
  12013.                 {
  12014.                     $pos++;
  12015.                 }
  12016.                 else
  12017.                 {
  12018.                     return 'text/html';
  12019.                 }
  12020.             }
  12021.             elseif (substr($this->file->body$pos1=== '?')
  12022.             {
  12023.                 if ($pos $len && ($pos strpos($this->file->body'?>'$pos)) !== false)
  12024.                 {
  12025.                     $pos += 2;
  12026.                 }
  12027.                 else
  12028.                 {
  12029.                     return 'text/html';
  12030.                 }
  12031.             }
  12032.             elseif (substr($this->file->body$pos3=== 'rss'
  12033.                 || substr($this->file->body$pos7=== 'rdf:RDF')
  12034.             {
  12035.                 return 'application/rss+xml';
  12036.             }
  12037.             elseif (substr($this->file->body$pos4=== 'feed')
  12038.             {
  12039.                 return 'application/atom+xml';
  12040.             }
  12041.             else
  12042.             {
  12043.                 return 'text/html';
  12044.             }
  12045.         }
  12046.         
  12047.         return 'text/html';
  12048.     }
  12049. }
  12050.  
  12051. /**
  12052.  * Parses the XML Declaration
  12053.  *
  12054.  * @package SimplePie
  12055.  */
  12056. {
  12057.     /**
  12058.      * XML Version
  12059.      *
  12060.      * @access public
  12061.      * @var string 
  12062.      */
  12063.     var $version = '1.0';
  12064.     
  12065.     /**
  12066.      * Encoding
  12067.      *
  12068.      * @access public
  12069.      * @var string 
  12070.      */
  12071.     var $encoding = 'UTF-8';
  12072.     
  12073.     /**
  12074.      * Standalone
  12075.      *
  12076.      * @access public
  12077.      * @var bool 
  12078.      */
  12079.     var $standalone = false;
  12080.  
  12081.     /**
  12082.      * Current state of the state machine
  12083.      *
  12084.      * @access private
  12085.      * @var string 
  12086.      */
  12087.     var $state 'before_version_name';
  12088.     
  12089.     /**
  12090.      * Input data
  12091.      *
  12092.      * @access private
  12093.      * @var string 
  12094.      */
  12095.     var $data '';
  12096.  
  12097.     /**
  12098.      * Input data length (to avoid calling strlen() everytime this is needed)
  12099.      *
  12100.      * @access private
  12101.      * @var int 
  12102.      */
  12103.     var $data_length 0;
  12104.  
  12105.     /**
  12106.      * Current position of the pointer
  12107.      *
  12108.      * @var int 
  12109.      * @access private
  12110.      */
  12111.     var $position 0;
  12112.     
  12113.     /**
  12114.      * Create an instance of the class with the input data
  12115.      *
  12116.      * @access public
  12117.      * @param string $data Input data
  12118.      */
  12119.     function SimplePie_XML_Declaration_Parser($data)
  12120.     {
  12121.         $this->data $data;
  12122.         $this->data_length strlen($this->data);
  12123.     }
  12124.  
  12125.     /**
  12126.      * Parse the input data
  12127.      *
  12128.      * @access public
  12129.      * @return bool true on success, false on failure
  12130.      */
  12131.     function parse()
  12132.     {
  12133.         while ($this->state && $this->state !== 'emit' && $this->has_data())
  12134.         {
  12135.             $state $this->state;
  12136.             $this->$state();
  12137.         }
  12138.         $this->data '';
  12139.         if ($this->state === 'emit')
  12140.         {
  12141.             return true;
  12142.         }
  12143.         else
  12144.         {
  12145.             $this->version = '';
  12146.             $this->encoding = '';
  12147.             $this->standalone = '';
  12148.             return false;
  12149.         }
  12150.     }
  12151.  
  12152.     /**
  12153.      * Check whether there is data beyond the pointer
  12154.      *
  12155.      * @access private
  12156.      * @return bool true if there is further data, false if not
  12157.      */
  12158.     function has_data()
  12159.     {
  12160.         return (bool) ($this->position $this->data_length);
  12161.     }
  12162.     
  12163.     /**
  12164.      * Advance past any whitespace
  12165.      *
  12166.      * @return int Number of whitespace characters passed
  12167.      */
  12168.     function skip_whitespace()
  12169.     {
  12170.         $whitespace strspn($this->data"\x09\x0A\x0D\x20"$this->position);
  12171.         $this->position += $whitespace;
  12172.         return $whitespace;
  12173.     }
  12174.     
  12175.     /**
  12176.      * Read value
  12177.      */
  12178.     function get_value()
  12179.     {
  12180.         $quote substr($this->data$this->position1);
  12181.         if ($quote === '"' || $quote === "'")
  12182.         {
  12183.             $this->position++;
  12184.             $len strcspn($this->data$quote$this->position);
  12185.             if ($this->has_data())
  12186.             {
  12187.                 $value substr($this->data$this->position$len);
  12188.                 $this->position += $len 1;
  12189.                 return $value;
  12190.             }
  12191.         }
  12192.         return false;
  12193.     }
  12194.     
  12195.     function before_version_name()
  12196.     {
  12197.         if ($this->skip_whitespace())
  12198.         {
  12199.             $this->state 'version_name';
  12200.         }
  12201.         else
  12202.         {
  12203.             $this->state false;
  12204.         }
  12205.     }
  12206.     
  12207.     function version_name()
  12208.     {
  12209.         if (substr($this->data$this->position7=== 'version')
  12210.         {
  12211.             $this->position += 7;
  12212.             $this->skip_whitespace();
  12213.             $this->state 'version_equals';
  12214.         }
  12215.         else
  12216.         {
  12217.             $this->state false;
  12218.         }
  12219.     }
  12220.     
  12221.     function version_equals()
  12222.     {
  12223.         if (substr($this->data$this->position1=== '=')
  12224.         {
  12225.             $this->position++;
  12226.             $this->skip_whitespace();
  12227.             $this->state 'version_value';
  12228.         }
  12229.         else
  12230.         {
  12231.             $this->state false;
  12232.         }
  12233.     }
  12234.     
  12235.     function version_value()
  12236.     {
  12237.         if ($this->version = $this->get_value())
  12238.         {
  12239.             $this->skip_whitespace();
  12240.             if ($this->has_data())
  12241.             {
  12242.                 $this->state 'encoding_name';
  12243.             }
  12244.             else
  12245.             {
  12246.                 $this->state 'emit';
  12247.             }
  12248.         }
  12249.         else
  12250.         {
  12251.             $this->state 'standalone_name';
  12252.         }
  12253.     }
  12254.     
  12255.     function encoding_name()
  12256.     {
  12257.         if (substr($this->data$this->position8=== 'encoding')
  12258.         {
  12259.             $this->position += 8;
  12260.             $this->skip_whitespace();
  12261.             $this->state 'encoding_equals';
  12262.         }
  12263.         else
  12264.         {
  12265.             $this->state false;
  12266.         }
  12267.     }
  12268.     
  12269.     function encoding_equals()
  12270.     {
  12271.         if (substr($this->data$this->position1=== '=')
  12272.         {
  12273.             $this->position++;
  12274.             $this->skip_whitespace();
  12275.             $this->state 'encoding_value';
  12276.         }
  12277.         else
  12278.         {
  12279.             $this->state false;
  12280.         }
  12281.     }
  12282.     
  12283.     function encoding_value()
  12284.     {
  12285.         if ($this->encoding = $this->get_value())
  12286.         {
  12287.             $this->skip_whitespace();
  12288.             if ($this->has_data())
  12289.             {
  12290.                 $this->state 'standalone_name';
  12291.             }
  12292.             else
  12293.             {
  12294.                 $this->state 'emit';
  12295.             }
  12296.         }
  12297.         else
  12298.         {
  12299.             $this->state false;
  12300.         }
  12301.     }
  12302.     
  12303.     function standalone_name()
  12304.     {
  12305.         if (substr($this->data$this->position10=== 'standalone')
  12306.         {
  12307.             $this->position += 10;
  12308.             $this->skip_whitespace();
  12309.             $this->state 'standalone_equals';
  12310.         }
  12311.         else
  12312.         {
  12313.             $this->state false;
  12314.         }
  12315.     }
  12316.     
  12317.     function standalone_equals()
  12318.     {
  12319.         if (substr($this->data$this->position1=== '=')
  12320.         {
  12321.             $this->position++;
  12322.             $this->skip_whitespace();
  12323.             $this->state 'standalone_value';
  12324.         }
  12325.         else
  12326.         {
  12327.             $this->state false;
  12328.         }
  12329.     }
  12330.     
  12331.     function standalone_value()
  12332.     {
  12333.         if ($standalone $this->get_value())
  12334.         {
  12335.             switch ($standalone)
  12336.             {
  12337.                 case 'yes':
  12338.                     $this->standalone = true;
  12339.                     break;
  12340.                 
  12341.                 case 'no':
  12342.                     $this->standalone = false;
  12343.                     break;
  12344.                 
  12345.                 default:
  12346.                     $this->state false;
  12347.                     return;
  12348.             }
  12349.             
  12350.             $this->skip_whitespace();
  12351.             if ($this->has_data())
  12352.             {
  12353.                 $this->state false;
  12354.             }
  12355.             else
  12356.             {
  12357.                 $this->state 'emit';
  12358.             }
  12359.         }
  12360.         else
  12361.         {
  12362.             $this->state false;
  12363.         }
  12364.     }
  12365. }
  12366.  
  12367. {
  12368.     var $useragent;
  12369.     var $timeout;
  12370.     var $file;
  12371.     var $local = array();
  12372.     var $elsewhere = array();
  12373.     var $file_class = 'SimplePie_File';
  12374.     var $cached_entities = array();
  12375.     var $http_base;
  12376.     var $base;
  12377.     var $base_location = 0;
  12378.     var $checked_feeds = 0;
  12379.     var $max_checked_feeds = 10;
  12380.     var $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer';
  12381.  
  12382.     function SimplePie_Locator(&$file$timeout 10$useragent null$file_class 'SimplePie_File'$max_checked_feeds 10$content_type_sniffer_class 'SimplePie_Content_Type_Sniffer')
  12383.     {
  12384.         $this->file =$file;
  12385.         $this->file_class = $file_class;
  12386.         $this->useragent = $useragent;
  12387.         $this->timeout = $timeout;
  12388.         $this->max_checked_feeds = $max_checked_feeds;
  12389.         $this->content_type_sniffer_class;
  12390.     }
  12391.  
  12392.     function find($type SIMPLEPIE_LOCATOR_ALL)
  12393.     {
  12394.         if ($this->is_feed($this->file))
  12395.         {
  12396.             return $this->file;
  12397.         }
  12398.         
  12399.         if ($this->file->method SIMPLEPIE_FILE_SOURCE_REMOTE)
  12400.         {
  12401.             $sniffer new $this->content_type_sniffer_class($this->file);
  12402.             if ($sniffer->get_type(!== 'text/html')
  12403.             {
  12404.                 return null;
  12405.             }
  12406.         }
  12407.  
  12408.         if ($type ~SIMPLEPIE_LOCATOR_NONE)
  12409.         {
  12410.             $this->get_base();
  12411.         }
  12412.  
  12413.         if ($type SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working $this->autodiscovery())
  12414.         {
  12415.             return $working;
  12416.         }
  12417.  
  12418.         {
  12419.             if ($type SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working $this->extension($this->local))
  12420.             {
  12421.                 return $working;
  12422.             }
  12423.  
  12424.             if ($type SIMPLEPIE_LOCATOR_LOCAL_BODY && $working $this->body($this->local))
  12425.             {
  12426.                 return $working;
  12427.             }
  12428.  
  12429.             if ($type SIMPLEPIE_LOCATOR_REMOTE_EXTENSION && $working $this->extension($this->elsewhere))
  12430.             {
  12431.                 return $working;
  12432.             }
  12433.  
  12434.             if ($type SIMPLEPIE_LOCATOR_REMOTE_BODY && $working $this->body($this->elsewhere))
  12435.             {
  12436.                 return $working;
  12437.             }
  12438.         }
  12439.         return null;
  12440.     }
  12441.  
  12442.     function is_feed(&$file)
  12443.     {
  12444.         if ($file->method SIMPLEPIE_FILE_SOURCE_REMOTE)
  12445.         {
  12446.             $sniffer new $this->content_type_sniffer_class($file);
  12447.             $sniffed $sniffer->get_type();
  12448.             if (in_array($sniffedarray('application/rss+xml''application/rdf+xml''application/atom+xml''text/xml''application/xml''text/plain')))
  12449.             {
  12450.                 return true;
  12451.             }
  12452.             else
  12453.             {
  12454.                 return false;
  12455.             }
  12456.         }
  12457.         elseif ($file->method SIMPLEPIE_FILE_SOURCE_LOCAL)
  12458.         {
  12459.             return true;
  12460.         }
  12461.         else
  12462.         {
  12463.             return false;
  12464.         }
  12465.     }
  12466.  
  12467.     function get_base()
  12468.     {
  12469.         $this->http_base = $this->file->url;
  12470.         $this->base = $this->http_base;
  12471.         $elements SimplePie_Misc::get_element('base'$this->file->body);
  12472.         foreach ($elements as $element)
  12473.         {
  12474.             if ($element['attribs']['href']['data'!== '')
  12475.             {
  12476.                 $this->base = SimplePie_Misc::absolutize_url(trim($element['attribs']['href']['data'])$this->http_base);
  12477.                 $this->base_location = $element['offset'];
  12478.                 break;
  12479.             }
  12480.         }
  12481.     }
  12482.  
  12483.     function autodiscovery()
  12484.     {
  12485.         $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));
  12486.         $done array();
  12487.         foreach ($links as $link)
  12488.         {
  12489.             if ($this->checked_feeds == $this->max_checked_feeds)
  12490.             {
  12491.                 break;
  12492.             }
  12493.             if (isset($link['attribs']['href']['data']&& isset($link['attribs']['rel']['data']))
  12494.             {
  12495.                 $rel array_unique(SimplePie_Misc::space_seperated_tokens(strtolower($link['attribs']['rel']['data'])));
  12496.  
  12497.                 if ($this->base_location < $link['offset'])
  12498.                 {
  12499.                     $href SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data'])$this->base);
  12500.                 }
  12501.                 else
  12502.                 {
  12503.                     $href SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data'])$this->http_base);
  12504.                 }
  12505.  
  12506.                 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'))))
  12507.                 {
  12508.                     $this->checked_feeds++;
  12509.                     $feed =new $this->file_class($href$this->timeout5null$this->useragent);
  12510.                     if ($this->is_feed($feed))
  12511.                     {
  12512.                         return $feed;
  12513.                     }
  12514.                 }
  12515.                 $done[$href;
  12516.             }
  12517.         }
  12518.         return null;
  12519.     }
  12520.  
  12521.     function get_links()
  12522.     {
  12523.         $links SimplePie_Misc::get_element('a'$this->file->body);
  12524.         foreach ($links as $link)
  12525.         {
  12526.             if (isset($link['attribs']['href']['data']))
  12527.             {
  12528.                 $href trim($link['attribs']['href']['data']);
  12529.                 $parsed SimplePie_Misc::parse_url($href);
  12530.                 if ($parsed['scheme'=== '' || preg_match('/^(http(s)|feed)?$/i'$parsed['scheme']))
  12531.                 {
  12532.                     if ($this->base_location < $link['offset'])
  12533.                     {
  12534.                         $href SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data'])$this->base);
  12535.                     }
  12536.                     else
  12537.                     {
  12538.                         $href SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data'])$this->http_base);
  12539.                     }
  12540.  
  12541.                     $current SimplePie_Misc::parse_url($this->file->url);
  12542.  
  12543.                     if ($parsed['authority'=== '' || $parsed['authority'== $current['authority'])
  12544.                     {
  12545.                         $this->local[$href;
  12546.                     }
  12547.                     else
  12548.                     {
  12549.                         $this->elsewhere[$href;
  12550.                     }
  12551.                 }
  12552.             }
  12553.         }
  12554.         $this->local = array_unique($this->local);
  12555.         $this->elsewhere = array_unique($this->elsewhere);
  12556.         if (!empty($this->local|| !empty($this->elsewhere))
  12557.         {
  12558.             return true;
  12559.         }
  12560.         return null;
  12561.     }
  12562.  
  12563.     function extension(&$array)
  12564.     {
  12565.         foreach ($array as $key => $value)
  12566.         {
  12567.             if ($this->checked_feeds == $this->max_checked_feeds)
  12568.             {
  12569.                 break;
  12570.             }
  12571.             if (in_array(strtolower(strrchr($value'.'))array('.rss''.rdf''.atom''.xml')))
  12572.             {
  12573.                 $this->checked_feeds++;
  12574.                 $feed =new $this->file_class($value$this->timeout5null$this->useragent);
  12575.                 if ($this->is_feed($feed))
  12576.                 {
  12577.                     return $feed;
  12578.                 }
  12579.                 else
  12580.                 {
  12581.                     unset($array[$key]);
  12582.                 }
  12583.             }
  12584.         }
  12585.         return null;
  12586.     }
  12587.  
  12588.     function body(&$array)
  12589.     {
  12590.         foreach ($array as $key => $value)
  12591.         {
  12592.             if ($this->checked_feeds == $this->max_checked_feeds)
  12593.             {
  12594.                 break;
  12595.             }
  12596.             if (preg_match('/(rss|rdf|atom|xml)/i'$value))
  12597.             {
  12598.                 $this->checked_feeds++;
  12599.                 $feed =new $this->file_class($value$this->timeout5null$this->useragent);
  12600.                 if ($this->is_feed($feed))
  12601.                 {
  12602.                     return $feed;
  12603.                 }
  12604.                 else
  12605.                 {
  12606.                     unset($array[$key]);
  12607.                 }
  12608.             }
  12609.         }
  12610.         return null;
  12611.     }
  12612. }
  12613.  
  12614. {
  12615.     var $error_code;
  12616.     var $error_string;
  12617.     var $current_line;
  12618.     var $current_column;
  12619.     var $current_byte;
  12620.     var $separator = ' ';
  12621.     var $feed = false;
  12622.     var $namespace = array('');
  12623.     var $element = array('');
  12624.     var $xml_base = array('');
  12625.     var $xml_base_explicit = array(false);
  12626.     var $xml_lang = array('');
  12627.     var $data = array();
  12628.     var $datas = array(array());
  12629.     var $current_xhtml_construct = -1;
  12630.     var $encoding;
  12631.  
  12632.     function parse(&$data$encoding)
  12633.     {
  12634.         // Use UTF-8 if we get passed US-ASCII, as every US-ASCII character is a UTF-8 character
  12635.         if (strtoupper($encoding== 'US-ASCII')
  12636.         {
  12637.             $this->encoding = 'UTF-8';
  12638.         }
  12639.         else
  12640.         {
  12641.             $this->encoding = $encoding;
  12642.         }
  12643.  
  12644.         // Strip BOM:
  12645.         // UTF-32 Big Endian BOM
  12646.         if (substr($data04=== "\x00\x00\xFE\xFF")
  12647.         {
  12648.             $data substr($data4);
  12649.         }
  12650.         // UTF-32 Little Endian BOM
  12651.         elseif (substr($data04=== "\xFF\xFE\x00\x00")
  12652.         {
  12653.             $data substr($data4);
  12654.         }
  12655.         // UTF-16 Big Endian BOM
  12656.         elseif (substr($data02=== "\xFE\xFF")
  12657.         {
  12658.             $data substr($data2);
  12659.         }
  12660.         // UTF-16 Little Endian BOM
  12661.         elseif (substr($data02=== "\xFF\xFE")
  12662.         {
  12663.             $data substr($data2);
  12664.         }
  12665.         // UTF-8 BOM
  12666.         elseif (substr($data03=== "\xEF\xBB\xBF")
  12667.         {
  12668.             $data substr($data3);
  12669.         }
  12670.         
  12671.         if (substr($data05=== '<?xml' && strspn(substr($data51)"\x09\x0A\x0D\x20"&& ($pos strpos($data'?>')) !== false)
  12672.         {
  12673.             $declaration new SimplePie_XML_Declaration_Parser(substr($data5$pos 5));
  12674.             if ($declaration->parse())
  12675.             {
  12676.                 $data substr($data$pos 2);
  12677.                 $data '<?xml version="' $declaration->version '" encoding="' $encoding '" standalone="' (($declaration->standalone'yes' 'no''"?>' $data;
  12678.             }
  12679.             else
  12680.             {
  12681.                 $this->error_string = 'SimplePie bug! Please report this!';
  12682.                 return false;
  12683.             }
  12684.         }
  12685.         
  12686.         $return true;
  12687.  
  12688.         // Create the parser
  12689.         $xml xml_parser_create_ns($this->encoding$this->separator);
  12690.         xml_parser_set_option($xmlXML_OPTION_SKIP_WHITE1);
  12691.         xml_parser_set_option($xmlXML_OPTION_CASE_FOLDING0);
  12692.         xml_set_object($xml$this);
  12693.         xml_set_character_data_handler($xml'cdata');
  12694.         xml_set_element_handler($xml'tag_open''tag_close');
  12695.  
  12696.         // Parse!
  12697.         if (!xml_parse($xml$datatrue))
  12698.         {
  12699.             $this->error_code = xml_get_error_code($xml);
  12700.             $this->error_string = xml_error_string($this->error_code);
  12701.             $return false;
  12702.         }
  12703.         $this->current_line = xml_get_current_line_number($xml);
  12704.         $this->current_column = xml_get_current_column_number($xml);
  12705.         $this->current_byte = xml_get_current_byte_index($xml);
  12706.         xml_parser_free($xml);
  12707.         return $return;
  12708.     }
  12709.  
  12710.     function get_error_code()
  12711.     {
  12712.         return $this->error_code;
  12713.     }
  12714.  
  12715.     function get_error_string()
  12716.     {
  12717.         return $this->error_string;
  12718.     }
  12719.  
  12720.     function get_current_line()
  12721.     {
  12722.         return $this->current_line;
  12723.     }
  12724.  
  12725.     function get_current_column()
  12726.     {
  12727.         return $this->current_column;
  12728.     }
  12729.  
  12730.     function get_current_byte()
  12731.     {
  12732.         return $this->current_byte;
  12733.     }
  12734.  
  12735.     function get_data()
  12736.     {
  12737.         return $this->data;
  12738.     }
  12739.  
  12740.     function tag_open($parser$tag$attributes)
  12741.     {
  12742.         if ($this->feed === 0)
  12743.         {
  12744.             return;
  12745.         }
  12746.         elseif ($this->feed == false)
  12747.         {
  12748.             if (in_array($tagarray(
  12749.                 SIMPLEPIE_NAMESPACE_ATOM_10 $this->separator . 'feed',
  12750.                 SIMPLEPIE_NAMESPACE_ATOM_03 $this->separator . 'feed',
  12751.                 'rss',
  12752.                 SIMPLEPIE_NAMESPACE_RDF $this->separator . 'RDF'
  12753.             )))
  12754.             {
  12755.                     $this->feed = 1;
  12756.             }
  12757.         }
  12758.         else
  12759.         {
  12760.             $this->feed++;
  12761.         }
  12762.  
  12763.         list($this->namespace[]$this->element[]$this->split_ns($tag);
  12764.  
  12765.         $attribs array();
  12766.         foreach ($attributes as $name => $value)
  12767.         {
  12768.             list($attrib_namespace$attribute$this->split_ns($name);
  12769.             $attribs[$attrib_namespace][$attribute$value;
  12770.         }
  12771.  
  12772.         if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['base']))
  12773.         {
  12774.             $this->xml_base[SimplePie_Misc::absolutize_url($attribs[SIMPLEPIE_NAMESPACE_XML]['base']end($this->xml_base));
  12775.             $this->xml_base_explicit[true;
  12776.         }
  12777.         else
  12778.         {
  12779.             $this->xml_base[end($this->xml_base);
  12780.             $this->xml_base_explicit[end($this->xml_base_explicit);
  12781.         }
  12782.  
  12783.         if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['lang']))
  12784.         {
  12785.             $this->xml_lang[$attribs[SIMPLEPIE_NAMESPACE_XML]['lang'];
  12786.         }
  12787.         else
  12788.         {
  12789.             $this->xml_lang[end($this->xml_lang);
  12790.         }
  12791.  
  12792.         if ($this->current_xhtml_construct >= 0)
  12793.         {
  12794.             $this->current_xhtml_construct++;
  12795.             if (end($this->namespace== SIMPLEPIE_NAMESPACE_XHTML)
  12796.             {
  12797.                 $this->data['data'.= '<' end($this->element);
  12798.                 if (isset($attribs['']))
  12799.                 {
  12800.                     foreach ($attribs[''as $name => $value)
  12801.                     {
  12802.                         $this->data['data'.= ' ' $name '="' htmlspecialchars($valueENT_COMPAT$this->encoding'"';
  12803.                     }
  12804.                 }
  12805.                 $this->data['data'.= '>';
  12806.             }
  12807.         }
  12808.         else
  12809.         {
  12810.             $this->datas[=$this->data;
  12811.             $this->data =$this->data['child'][end($this->namespace)][end($this->element)][];
  12812.             $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));
  12813.             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')
  12814.             || (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'))
  12815.             {
  12816.                 $this->current_xhtml_construct = 0;
  12817.             }
  12818.         }
  12819.     }
  12820.  
  12821.     function cdata($parser$cdata)
  12822.     {
  12823.         if ($this->current_xhtml_construct >= 0)
  12824.         {
  12825.             $this->data['data'.= htmlspecialchars($cdataENT_QUOTES$this->encoding);
  12826.         }
  12827.         elseif ($this->feed > 1)
  12828.         {
  12829.             $this->data['data'.= $cdata;
  12830.         }
  12831.     }
  12832.  
  12833.     function tag_close($parser$tag)
  12834.     {
  12835.         if (!$this->feed)
  12836.         {
  12837.             return;
  12838.         }
  12839.  
  12840.         if ($this->current_xhtml_construct >= 0)
  12841.         {
  12842.             $this->current_xhtml_construct--;
  12843.             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')))
  12844.             {
  12845.                 $this->data['data'.= '</' end($this->element'>';
  12846.             }
  12847.         }
  12848.         if ($this->current_xhtml_construct == -1)
  12849.         {
  12850.             $this->data =$this->datas[$this->feed];
  12851.             array_pop($this->datas);
  12852.         }
  12853.  
  12854.         array_pop($this->element);
  12855.         array_pop($this->namespace);
  12856.         array_pop($this->xml_base);
  12857.         array_pop($this->xml_base_explicit);
  12858.         array_pop($this->xml_lang);
  12859.         $this->feed--;
  12860.     }
  12861.  
  12862.     function split_ns($string)
  12863.     {
  12864.         static $cache array();
  12865.         if (!isset($cache[$string]))
  12866.         {
  12867.             if ($pos strpos($string$this->separator))
  12868.             {
  12869.                 static $separator_length;
  12870.                 if (!$separator_length)
  12871.                 {
  12872.                     $separator_length strlen($this->separator);
  12873.                 }
  12874.                 $namespace substr($string0$pos);
  12875.                 $local_name substr($string$pos $separator_length);
  12876.                 if (strtolower($namespace=== SIMPLEPIE_NAMESPACE_ITUNES)
  12877.                 {
  12878.                     $namespace SIMPLEPIE_NAMESPACE_ITUNES;
  12879.                 }
  12880.                 $cache[$stringarray($namespace$local_name);
  12881.             }
  12882.             else
  12883.             {
  12884.                 $cache[$stringarray(''$string);
  12885.             }
  12886.         }
  12887.         return $cache[$string];
  12888.     }
  12889. }
  12890.  
  12891. /**
  12892.  * @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 shortern a string while preserving HTML tags
  12893.  */
  12894. {
  12895.     // Private vars
  12896.     var $base;
  12897.  
  12898.     // Options
  12899.     var $remove_div = true;
  12900.     var $image_handler = '';
  12901.     var $strip_htmltags = array('base''blink''body''doctype''embed''font''form''frame''frameset''html''iframe''input''marquee''meta''noscript''object''param''script''style');
  12902.     var $encode_instead_of_strip = false;
  12903.     var $strip_attributes = array('bgsound''class''expr''id''style''onclick''onerror''onfinish''onmouseover''onmouseout''onfocus''onblur''lowsrc''dynsrc');
  12904.     var $strip_comments = false;
  12905.     var $output_encoding = 'UTF-8';
  12906.     var $enable_cache = true;
  12907.     var $cache_location = './cache';
  12908.     var $cache_name_function = 'md5';
  12909.     var $cache_class = 'SimplePie_Cache';
  12910.     var $file_class = 'SimplePie_File';
  12911.     var $timeout = 10;
  12912.     var $useragent = '';
  12913.     var $force_fsockopen = false;
  12914.  
  12915.     var $replace_url_attributes = array(
  12916.         'a' => 'href',
  12917.         'area' => 'href',
  12918.         'blockquote' => 'cite',
  12919.         'del' => 'cite',
  12920.         'form' => 'action',
  12921.         'img' => array('longdesc''src'),
  12922.         'input' => 'src',
  12923.         'ins' => 'cite',
  12924.         'q' => 'cite'
  12925.     );
  12926.  
  12927.     function remove_div($enable true)
  12928.     {
  12929.         $this->remove_div = (bool) $enable;
  12930.     }
  12931.  
  12932.     function set_image_handler($page false)
  12933.     {
  12934.         if ($page)
  12935.         {
  12936.             $this->image_handler = (string) $page;
  12937.         }
  12938.         else
  12939.         {
  12940.             $this->image_handler = false;
  12941.         }
  12942.     }
  12943.  
  12944.     function pass_cache_data($enable_cache true$cache_location './cache'$cache_name_function 'md5'$cache_class 'SimplePie_Cache')
  12945.     {
  12946.         if (isset($enable_cache))
  12947.         {
  12948.             $this->enable_cache = (bool) $enable_cache;
  12949.         }
  12950.  
  12951.         if ($cache_location)
  12952.         {
  12953.             $this->cache_location = (string) $cache_location;
  12954.         }
  12955.  
  12956.         if ($cache_name_function)
  12957.         {
  12958.             $this->cache_name_function = (string) $cache_name_function;
  12959.         }
  12960.  
  12961.         if ($cache_class)
  12962.         {
  12963.             $this->cache_class = (string) $cache_class;
  12964.         }
  12965.     }
  12966.  
  12967.     function pass_file_data($file_class 'SimplePie_File'$timeout 10$useragent ''$force_fsockopen false)
  12968.     {
  12969.         if ($file_class)
  12970.         {
  12971.             $this->file_class = (string) $file_class;
  12972.         }
  12973.  
  12974.         if ($timeout)
  12975.         {
  12976.             $this->timeout = (string) $timeout;
  12977.         }
  12978.  
  12979.         if ($useragent)
  12980.         {
  12981.             $this->useragent = (string) $useragent;
  12982.         }
  12983.  
  12984.         if ($force_fsockopen)
  12985.         {
  12986.             $this->force_fsockopen = (string) $force_fsockopen;
  12987.         }
  12988.     }
  12989.  
  12990.     function strip_htmltags($tags array('base''blink''body''doctype''embed''font''form''frame''frameset''html''iframe''input''marquee''meta''noscript''object''param''script''style'))
  12991.     {
  12992.         if ($tags)
  12993.         {
  12994.             if (is_array($tags))
  12995.             {
  12996.                 $this->strip_htmltags = $tags;
  12997.             }
  12998.             else
  12999.             {
  13000.                 $this->strip_htmltags = explode(','$tags);
  13001.             }
  13002.         }
  13003.         else
  13004.         {
  13005.             $this->strip_htmltags = false;
  13006.         }
  13007.     }
  13008.  
  13009.     function encode_instead_of_strip($encode false)
  13010.     {
  13011.         $this->encode_instead_of_strip = (bool) $encode;
  13012.     }
  13013.  
  13014.     function strip_attributes($attribs array('bgsound''class''expr''id''style''onclick''onerror''onfinish''onmouseover''onmouseout''onfocus''onblur''lowsrc''dynsrc'))
  13015.     {
  13016.         if ($attribs)
  13017.         {
  13018.             if (is_array($attribs))
  13019.             {
  13020.                 $this->strip_attributes = $attribs;
  13021.             }
  13022.             else
  13023.             {
  13024.                 $this->strip_attributes = explode(','$attribs);
  13025.             }
  13026.         }
  13027.         else
  13028.         {
  13029.             $this->strip_attributes = false;
  13030.         }
  13031.     }
  13032.  
  13033.     function strip_comments($strip false)
  13034.     {
  13035.         $this->strip_comments = (bool) $strip;
  13036.     }
  13037.  
  13038.     function set_output_encoding($encoding 'UTF-8')
  13039.     {
  13040.         $this->output_encoding = (string) $encoding;
  13041.     }
  13042.  
  13043.     /**
  13044.      * Set element/attribute key/value pairs of HTML attributes
  13045.      * containing URLs that need to be resolved relative to the feed
  13046.      *
  13047.      * @access public
  13048.      * @since 1.0
  13049.      * @param array $element_attribute Element/attribute key/value pairs
  13050.      */
  13051.     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'))
  13052.     {
  13053.         $this->replace_url_attributes = (array) $element_attribute;
  13054.     }
  13055.  
  13056.     function sanitize($data$type$base '')
  13057.     {
  13058.         $data trim($data);
  13059.         if ($data !== '' || $type SIMPLEPIE_CONSTRUCT_IRI)
  13060.         {
  13061.             if ($type SIMPLEPIE_CONSTRUCT_MAYBE_HTML)
  13062.             {
  13063.                 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))
  13064.                 {
  13065.                     $type |= SIMPLEPIE_CONSTRUCT_HTML;
  13066.                 }
  13067.                 else
  13068.                 {
  13069.                     $type |= SIMPLEPIE_CONSTRUCT_TEXT;
  13070.                 }
  13071.             }
  13072.  
  13073.             if ($type SIMPLEPIE_CONSTRUCT_BASE64)
  13074.             {
  13075.                 $data base64_decode($data);
  13076.             }
  13077.  
  13078.             if ($type SIMPLEPIE_CONSTRUCT_XHTML)
  13079.             {
  13080.                 if ($this->remove_div)
  13081.                 {
  13082.                     $data preg_replace('/^<div' SIMPLEPIE_PCRE_XML_ATTRIBUTE '>/'''$data);
  13083.                     $data preg_replace('/<\/div>$/'''$data);
  13084.                 }
  13085.                 else
  13086.                 {
  13087.                     $data preg_replace('/^<div' SIMPLEPIE_PCRE_XML_ATTRIBUTE '>/''<div>'$data);
  13088.                 }
  13089.             }
  13090.  
  13091.             if ($type (SIMPLEPIE_CONSTRUCT_HTML SIMPLEPIE_CONSTRUCT_XHTML))
  13092.             {
  13093.                 // Strip comments
  13094.                 if ($this->strip_comments)
  13095.                 {
  13096.                     $data SimplePie_Misc::strip_comments($data);
  13097.                 }
  13098.  
  13099.                 // Strip out HTML tags and attributes that might cause various security problems.
  13100.                 // Based on recommendations by Mark Pilgrim at:
  13101.                 // http://diveintomark.org/archives/2003/06/12/how_to_consume_rss_safely
  13102.                 if ($this->strip_htmltags)
  13103.                 {
  13104.                     foreach ($this->strip_htmltags as $tag)
  13105.                     {
  13106.                         $pcre "/<($tag)SIMPLEPIE_PCRE_HTML_ATTRIBUTE "(>(.*)<\/$tagSIMPLEPIE_PCRE_HTML_ATTRIBUTE '>|(\/)?>)/siU';
  13107.                         while (preg_match($pcre$data))
  13108.                         {
  13109.                             $data preg_replace_callback($pcrearray(&$this'do_strip_htmltags')$data);
  13110.                         }
  13111.                     }
  13112.                 }
  13113.  
  13114.                 if ($this->strip_attributes)
  13115.                 {
  13116.                     foreach ($this->strip_attributes as $attrib)
  13117.                     {
  13118.                         $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);
  13119.                     }
  13120.                 }
  13121.  
  13122.                 // Replace relative URLs
  13123.                 $this->base = $base;
  13124.                 foreach ($this->replace_url_attributes as $element => $attributes)
  13125.                 {
  13126.                     $data $this->replace_urls($data$element$attributes);
  13127.                 }
  13128.  
  13129.                 // If image handling (caching, etc.) is enabled, cache and rewrite all the image tags.
  13130.                 if (isset($this->image_handler&& ((string) $this->image_handler!== '' && $this->enable_cache)
  13131.                 {
  13132.                     $images SimplePie_Misc::get_element('img'$data);
  13133.                     foreach ($images as $img)
  13134.                     {
  13135.                         if (isset($img['attribs']['src']['data']))
  13136.                         {
  13137.                             $image_url call_user_func($this->cache_name_function$img['attribs']['src']['data']);
  13138.                             $cache call_user_func(array($this->cache_class'create')$this->cache_location$image_url'spi');
  13139.  
  13140.                             if ($cache->load())
  13141.                             {
  13142.                                 $img['attribs']['src']['data'$this->image_handler . $image_url;
  13143.                                 $data str_replace($img['full']SimplePie_Misc::element_implode($img)$data);
  13144.                             }
  13145.                             else
  13146.                             {
  13147.                                 $file =new $this->file_class($img['attribs']['src']['data']$this->timeout5array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR'])$this->useragent$this->force_fsockopen);
  13148.                                 $headers $file->headers;
  13149.  
  13150.                                 if ($file->success && ($file->status_code == 200 || ($file->status_code 206 && $file->status_code 300)))
  13151.                                 {
  13152.                                     if ($cache->save(array('headers' => $file->headers'body' => $file->body)))
  13153.                                     {
  13154.                                         $img['attribs']['src']['data'$this->image_handler . $image_url;
  13155.                                         $data str_replace($img['full']SimplePie_Misc::element_implode($img)$data);
  13156.                                     }
  13157.                                     else
  13158.                                     {
  13159.                                         trigger_error("$cache->name is not writeable"E_USER_WARNING);
  13160.                                     }
  13161.                                 }
  13162.                             }
  13163.                         }
  13164.                     }
  13165.                 }
  13166.  
  13167.                 // Having (possibly) taken stuff out, there may now be whitespace at the beginning/end of the data
  13168.                 $data trim($data);
  13169.             }
  13170.  
  13171.             if ($type SIMPLEPIE_CONSTRUCT_IRI)
  13172.             {
  13173.                 $data SimplePie_Misc::absolutize_url($data$base);
  13174.             }
  13175.  
  13176.             if ($type (SIMPLEPIE_CONSTRUCT_TEXT SIMPLEPIE_CONSTRUCT_IRI))
  13177.             {
  13178.                 $data htmlspecialchars($dataENT_COMPAT'UTF-8');
  13179.             }
  13180.  
  13181.             if ($this->output_encoding != 'UTF-8')
  13182.             {
  13183.                 $data SimplePie_Misc::change_encoding($data'UTF-8'$this->output_encoding);
  13184.             }
  13185.         }
  13186.         return $data;
  13187.     }
  13188.  
  13189.     function replace_urls($data$tag$attributes)
  13190.     {
  13191.         if (!is_array($this->strip_htmltags|| !in_array($tag$this->strip_htmltags))
  13192.         {
  13193.             $elements SimplePie_Misc::get_element($tag$data);
  13194.             foreach ($elements as $element)
  13195.             {
  13196.                 if (is_array($attributes))
  13197.                 {
  13198.                     foreach ($attributes as $attribute)
  13199.                     {
  13200.                         if (isset($element['attribs'][$attribute]['data']))
  13201.                         {
  13202.                             $element['attribs'][$attribute]['data'SimplePie_Misc::absolutize_url($element['attribs'][$attribute]['data']$this->base);
  13203.                             $new_element SimplePie_Misc::element_implode($element);
  13204.                             $data str_replace($element['full']$new_element$data);
  13205.                             $element['full'$new_element;
  13206.                         }
  13207.                     }
  13208.                 }
  13209.                 elseif (isset($element['attribs'][$attributes]['data']))
  13210.                 {
  13211.                     $element['attribs'][$attributes]['data'SimplePie_Misc::absolutize_url($element['attribs'][$attributes]['data']$this->base);
  13212.                     $data str_replace($element['full']SimplePie_Misc::element_implode($element)$data);
  13213.                 }
  13214.             }
  13215.         }
  13216.         return $data;
  13217.     }
  13218.  
  13219.     function do_strip_htmltags($match)
  13220.     {
  13221.         if ($this->encode_instead_of_strip)
  13222.         {
  13223.             if (isset($match[4]&& !in_array(strtolower($match[1])array('script''style')))
  13224.             {
  13225.                 $match[1htmlspecialchars($match[1]ENT_COMPAT'UTF-8');
  13226.                 $match[2htmlspecialchars($match[2]ENT_COMPAT'UTF-8');
  13227.                 return "&lt;$match[1]$match[2]&gt;$match[3]&lt;/$match[1]&gt;";
  13228.             }
  13229.             else
  13230.             {
  13231.                 return htmlspecialchars($match[0]ENT_COMPAT'UTF-8');
  13232.             }
  13233.         }
  13234.         elseif (isset($match[4]&& !in_array(strtolower($match[1])array('script''style')))
  13235.         {
  13236.             return $match[4];
  13237.         }
  13238.         else
  13239.         {
  13240.             return '';
  13241.         }
  13242.     }
  13243. }
  13244.  
  13245. ?>

Documentation generated on Fri, 18 Jul 2008 21:57:53 +0200 by phpDocumentor 1.4.1