Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Unknown

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /simplepie/simplepie.php

Documentation is available at simplepie.php

  1. <?php
  2. /**************************************************
  3. SIMPLEPIE
  4. A PHP-Based RSS and Atom Feed Framework
  5. Takes the hard work out of managing a complete RSS/Atom solution.
  6.  
  7. Version: "Lemon Meringue"
  8. Updated: 24 November 2006
  9. Copyright: 2004-2006 Ryan Parman, Geoffrey Sneddon
  10. http://simplepie.org
  11.  
  12. ****************************************************
  13. LICENSE:
  14.  
  15. GNU Lesser General Public License 2.1 (LGPL)
  16. http://creativecommons.org/licenses/LGPL/2.1/
  17.  
  18. ****************************************************
  19. Please submit all bug reports and feature requests to the SimplePie forums.
  20. http://simplepie.org/support/
  21.  
  22. ****************************************************/
  23.  
  24.  
  25. class SimplePie
  26. {
  27.     // SimplePie Info
  28.         var $name = 'SimplePie';
  29.     var $version = '1.0 b3.2';
  30.     var $build = '20061124';
  31.     var $url = 'http://simplepie.org/';
  32.     var $useragent;
  33.     var $linkback;
  34.  
  35.     // Other objects, instances created here so we can set options on them
  36.         var $sanitize;
  37.  
  38.     // Options
  39.         var $rss_url;
  40.     var $file;
  41.     var $timeout = 10;
  42.     var $xml_dump = false;
  43.     var $enable_cache = true;
  44.     var $max_minutes = 60;
  45.     var $cache_location = './cache';
  46.     var $order_by_date = true;
  47.     var $input_encoding = false;
  48.     var $cache_class = 'SimplePie_Cache';
  49.     var $locator_class = 'SimplePie_Locator';
  50.     var $parser_class = 'SimplePie_Parser';
  51.     var $file_class = 'SimplePie_File';
  52.     var $force_fsockopen = false;
  53.     var $cache_name_type = 'sha1';
  54.  
  55.     // Misc. variables
  56.         var $data;
  57.     var $error;
  58.  
  59.     function SimplePie($feed_url null$cache_location null$cache_max_minutes null)
  60.     {
  61.         // Couple of variables built up from other variables
  62.         $this->useragent = $this->name . '/' $this->version . ' (Feed Parser; ' $this->url . '; Allow like Gecko) Build/' $this->build;
  63.         $this->linkback = '<a href="' $this->url . '" title="' $this->name . ' ' $this->version . '">' $this->name . '</a>';
  64.  
  65.         // Other objects, instances created here so we can set options on them
  66.         $this->sanitize = new SimplePie_Sanitize;
  67.  
  68.         // Set options if they're passed to the constructor
  69.         if (!is_null($feed_url))
  70.         {
  71.             $this->feed_url($feed_url);
  72.         }
  73.  
  74.         if (!is_null($cache_location))
  75.         {
  76.             $this->cache_location($cache_location);
  77.         }
  78.  
  79.         if (!is_null($cache_max_minutes))
  80.         {
  81.             $this->cache_max_minutes($cache_max_minutes);
  82.         }
  83.  
  84.         // If we've passed an xmldump variable in the URL, snap into XMLdump mode
  85.         if (isset($_GET['xmldump']))
  86.         {
  87.             $this->enable_xmldump(true);
  88.         }
  89.  
  90.         // Only init the script if we're passed a feed URL
  91.         if (!is_null($feed_url))
  92.         {
  93.             return $this->init();
  94.         }
  95.     }
  96.  
  97.     function feed_url($url)
  98.     {
  99.         $this->rss_url = SimplePie_Misc::fix_protocol($url1);
  100.     }
  101.  
  102.     function set_file(&$file)
  103.     {
  104.         if (is_a($file'SimplePie_File'))
  105.         {
  106.             $this->rss_url = $file->url;
  107.             $this->file =$file;
  108.         }
  109.     }
  110.  
  111.     function set_timeout($timeout 10)
  112.     {
  113.         $this->timeout = (int) $timeout;
  114.     }
  115.  
  116.     function set_raw_data($data)
  117.     {
  118.         $this->raw_data trim((string) $data);
  119.     }
  120.  
  121.     function enable_xmldump($enable false)
  122.     {
  123.         $this->xml_dump = (bool) $enable;
  124.     }
  125.  
  126.     function enable_caching($enable true)
  127.     {
  128.         $this->enable_cache = (bool) $enable;
  129.     }
  130.  
  131.     function cache_max_minutes($minutes 60)
  132.     {
  133.         $this->max_minutes = (float) $minutes;
  134.     }
  135.  
  136.     function cache_location($location './cache')
  137.     {
  138.         $this->cache_location = (string) $location;
  139.     }
  140.  
  141.     function order_by_date($enable true)
  142.     {
  143.         $this->order_by_date = (bool) $enable;
  144.     }
  145.  
  146.     function input_encoding($encoding false)
  147.     {
  148.         if ($encoding)
  149.         {
  150.             $this->input_encoding = (string) $encoding;
  151.         }
  152.         else
  153.         {
  154.             $this->input_encoding = false;
  155.         }
  156.     }
  157.  
  158.     function set_cache_class($class 'SimplePie_Cache')
  159.     {
  160.         if (SimplePie_Misc::is_a_class($class'SimplePie_Cache'))
  161.         {
  162.             $this->cache_class = $class;
  163.             return true;
  164.         }
  165.         return false;
  166.     }
  167.  
  168.     function set_locator_class($class 'SimplePie_Locator')
  169.     {
  170.         if (SimplePie_Misc::is_a_class($class'SimplePie_Locator'))
  171.         {
  172.             $this->locator_class = $class;
  173.             return true;
  174.         }
  175.         return false;
  176.     }
  177.  
  178.     function set_parser_class($class 'SimplePie_Parser')
  179.     {
  180.         if (SimplePie_Misc::is_a_class($class'SimplePie_Parser'))
  181.         {
  182.             $this->parser_class = $class;
  183.             return true;
  184.         }
  185.         return false;
  186.     }
  187.  
  188.     function set_file_class($class 'SimplePie_File')
  189.     {
  190.         if (SimplePie_Misc::is_a_class($class'SimplePie_File'))
  191.         {
  192.             $this->file_class = $class;
  193.             return true;
  194.         }
  195.         return false;
  196.     }
  197.  
  198.     function set_sanitize_class($object 'SimplePie_Sanitize')
  199.     {
  200.         if (class_exists($object))
  201.         {
  202.             $this->sanitize = new $object;
  203.             return true;
  204.         }
  205.         return false;
  206.     }
  207.  
  208.     function set_useragent($ua)
  209.     {
  210.         $this->useragent = (string) $ua;
  211.     }
  212.  
  213.     function force_fsockopen($enable false)
  214.     {
  215.         $this->force_fsockopen = (bool) $enable;
  216.     }
  217.  
  218.     function set_cache_name_type($type 'sha1')
  219.     {
  220.         $type strtolower(trim($type));
  221.         switch ($type)
  222.         {
  223.             case 'crc32':
  224.                 $this->cache_name_type = 'crc32';
  225.                 break;
  226.  
  227.             case 'md5':
  228.                 $this->cache_name_type = 'md5';
  229.                 break;
  230.  
  231.             case 'rawurlencode':
  232.                 $this->cache_name_type = 'rawurlencode';
  233.                 break;
  234.  
  235.             case 'urlencode':
  236.                 $this->cache_name_type = 'urlencode';
  237.                 break;
  238.  
  239.             default:
  240.                 $this->cache_name_type = 'sha1';
  241.                 break;
  242.         }
  243.     }
  244.  
  245.     function bypass_image_hotlink($get false)
  246.     {
  247.         $this->sanitize->bypass_image_hotlink($get);
  248.     }
  249.  
  250.     function bypass_image_hotlink_page($page false)
  251.     {
  252.         $this->sanitize->bypass_image_hotlink_page($page);
  253.     }
  254.  
  255.     function replace_headers($enable false)
  256.     {
  257.         $this->sanitize->replace_headers($enable);
  258.     }
  259.  
  260.     function remove_div($enable true)
  261.     {
  262.         $this->sanitize->remove_div($enable);
  263.     }
  264.  
  265.     function strip_ads($enable false)
  266.     {
  267.         $this->sanitize->strip_ads($enable);
  268.     }
  269.  
  270.     function strip_htmltags($tags array('base''blink''body''doctype''embed''font''form''frame''frameset''html''iframe''input''marquee''meta''noscript''object''param''script''style')$encode null)
  271.     {
  272.         $this->sanitize->strip_htmltags($tags);
  273.         if (!is_null($encode))
  274.         {
  275.             $this->sanitize->encode_instead_of_strip($tags);
  276.         }
  277.     }
  278.  
  279.     function encode_instead_of_strip($enable true)
  280.     {
  281.         $this->sanitize->encode_instead_of_strip($enable);
  282.     }
  283.  
  284.     function strip_attributes($attribs array('bgsound''class''expr''id''style''onclick''onerror''onfinish''onmouseover''onmouseout''onfocus''onblur'))
  285.     {
  286.         $this->sanitize->strip_attributes($attribs);
  287.     }
  288.  
  289.     function output_encoding($encoding 'UTF-8')
  290.     {
  291.         $this->sanitize->output_encoding($encoding);
  292.     }
  293.  
  294.     function set_item_class($class 'SimplePie_Item')
  295.     {
  296.         return $this->sanitize->set_item_class($class);
  297.     }
  298.  
  299.     function set_author_class($class 'SimplePie_Author')
  300.     {
  301.         return $this->sanitize->set_author_class($class);
  302.     }
  303.  
  304.     function set_enclosure_class($class 'SimplePie_Enclosure')
  305.     {
  306.         return $this->sanitize->set_enclosure_class($class);
  307.     }
  308.  
  309.     function init()
  310.     {
  311.         if (!(function_exists('version_compare'&& ((version_compare(phpversion()'4.3.2''>='&& version_compare(phpversion()'5''<')) || version_compare(phpversion()'5.0.3''>='))) || !extension_loaded('xml'|| !extension_loaded('pcre'))
  312.         {
  313.             return false;
  314.         }
  315.         if ($this->sanitize->bypass_image_hotlink && !empty($_GET[$this->sanitize->bypass_image_hotlink]))
  316.         {
  317.             if (get_magic_quotes_gpc())
  318.             {
  319.                 $_GET[$this->sanitize->bypass_image_hotlinkstripslashes($_GET[$this->sanitize->bypass_image_hotlink]);
  320.             }
  321.             SimplePie_Misc::display_file($_GET[$this->sanitize->bypass_image_hotlink]10$this->useragent);
  322.         }
  323.  
  324.         if (isset($_GET['js']))
  325.         {
  326.             $embed = <<<EOT
  327. function embed_odeo(link{
  328.     document.writeln('<embed src="http://odeo.com/flash/audio_player_fullsize.swfpluginspage="http://www.macromedia.com/go/getflashplayertype="application/x-shockwave-flashquality="highwidth="440" height="80" wmode="transparentallowScriptAccess="anyflashvars="valid_sample_rate=true&external_url='+link+'"></embed>');
  329. }
  330.  
  331. function embed_quicktime(typebgcolorwidthheightlinkplaceholderloop{
  332.     if (placeholder != '') {
  333.         document.writeln('<embed type="'+type+'" style="cursor:handcursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="falsetarget="myselfcontroller="falseloop="'+loop+'" scale="aspectbgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
  334.     }
  335.     else {
  336.         document.writeln('<embed type="'+type+'" style="cursor:handcursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="falsetarget="myselfcontroller="trueloop="'+loop+'" scale="aspectbgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
  337.     }
  338. }
  339.  
  340. function embed_flash(bgcolorwidthheightlinklooptype{
  341.     document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlashtype="'+type+'" quality="highwidth="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>');
  342. }
  343.  
  344. function embed_wmedia(widthheightlink{
  345.     document.writeln('<embed type="application/x-mplayer2src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
  346. }
  347. EOT;
  348.             if (function_exists('ob_gzhandler'))
  349.             {
  350.                 ob_start('ob_gzhandler');
  351.             }
  352.             header('Content-type: text/javascript; charset: UTF-8');
  353.             header('Cache-Control: must-revalidate');
  354.             header('Expires: ' .  gmdate('D, d M Y H:i:s'time(86400' GMT');
  355.             echo $embed;
  356.             exit;
  357.         }
  358.  
  359.         if (!empty($this->rss_url|| !empty($this->raw_data))
  360.         {
  361.             $this->data = array();
  362.             $cache false;
  363.  
  364.             if (!empty($this->rss_url))
  365.             {
  366.                 // Decide whether to enable caching
  367.                 if ($this->enable_cache && preg_match('/^http(s)?:\/\//i'$this->rss_url))
  368.                 {
  369.                     $cache new $this->cache_class($this->cache_locationcall_user_func($this->cache_name_type$this->rss_url)'spc');
  370.                 }
  371.                 // If it's enabled and we don't want an XML dump, use the cache
  372.                 if ($cache && !$this->xml_dump)
  373.                 {
  374.                     // Load the Cache
  375.                     $this->data = $cache->load();
  376.                     if (!empty($this->data))
  377.                     {
  378.                         // If we've hit a collision just rerun it with caching disabled
  379.                         if (isset($this->data['url']&& $this->data['url'!= $this->rss_url)
  380.                         {
  381.                             $cache false;
  382.                         }
  383.                         // If we've got a feed_url stored (if the page isn't actually a feed, or is a redirect) use that URL
  384.                         else if (!empty($this->data['feed_url']))
  385.                         {
  386.                             if ($this->data['feed_url'== $this->data['url'])
  387.                             {
  388.                                 $cache->unlink();
  389.                             }
  390.                             else
  391.                             {
  392.                                 $this->feed_url($this->data['feed_url']);
  393.                                 return $this->init();
  394.                             }
  395.                         }
  396.                         // If the cache is new enough
  397.                         else if ($cache->mtime($this->max_minutes * 60 time())
  398.                         {
  399.                             // If we have last-modified and/or etag set
  400.                             if (!empty($this->data['last-modified']|| !empty($this->data['etag']))
  401.                             {
  402.                                 $headers array();
  403.                                 if (!empty($this->data['last-modified']))
  404.                                 {
  405.                                     $headers['if-modified-since'$this->data['last-modified'];
  406.                                 }
  407.                                 if (!empty($this->data['etag']))
  408.                                 {
  409.                                     $headers['if-none-match'$this->data['etag'];
  410.                                 }
  411.                                 $file new $this->file_class($this->rss_url$this->timeout/105$headers$this->useragent$this->force_fsockopen);
  412.                                 if ($file->success)
  413.                                 {
  414.                                     $headers $file->headers();
  415.                                     if ($headers['status']['code'== 304)
  416.                                     {
  417.                                         $cache->touch();
  418.                                         return true;
  419.                                     }
  420.                                 }
  421.                                 else
  422.                                 {
  423.                                     unset($file);
  424.                                 }
  425.                             }
  426.                             // If we don't have last-modified or etag set, just clear the cache
  427.                             else
  428.                             {
  429.                                 $cache->unlink();
  430.                             }
  431.                         }
  432.                         // If the cache is still valid, just return true
  433.                         else
  434.                         {
  435.                             return true;
  436.                         }
  437.                     }
  438.                     // If the cache is empty, delete it
  439.                     else
  440.                     {
  441.                         $cache->unlink();
  442.                     }
  443.                 }
  444.                 $this->data = array();
  445.                 // 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.
  446.                 if (!isset($file))
  447.                 {
  448.                     if (is_a($this->file'SimplePie_File'&& $this->file->url == $this->rss_url)
  449.                     {
  450.                         $file =$this->file;
  451.                     }
  452.                     else
  453.                     {
  454.                         $file new $this->file_class($this->rss_url$this->timeout5null$this->useragent$this->force_fsockopen);
  455.                     }
  456.                 }
  457.                 // If the file connection has an error, set SimplePie::error to that and quit
  458.                 if (!$file->success)
  459.                 {
  460.                     $this->error = $file->error;
  461.                     return false;
  462.                 }
  463.  
  464.                 // Check if the supplied URL is a feed, if it isn't, look for it.
  465.                 $locate new $this->locator_class($file$this->timeout$this->useragent);
  466.                 if (!$locate->is_feed($file))
  467.                 {
  468.                     $feed $locate->find();
  469.                     if ($feed)
  470.                     {
  471.                         if ($cache && !$cache->save(array('url' => $this->rss_url'feed_url' => $feed)))
  472.                         {
  473.                             $this->error = "$cache->name is not writeable";
  474.                             SimplePie_Misc::error($this->errorE_USER_WARNING__FILE____LINE__);
  475.                         }
  476.                         $this->rss_url = $feed;
  477.                         return $this->init();
  478.                     }
  479.                     else
  480.                     {
  481.                         $this->error = "A feed could not be found at $this->rss_url";
  482.                         SimplePie_Misc::error($this->errorE_USER_WARNING__FILE____LINE__);
  483.                         return false;
  484.                     }
  485.                 }
  486.  
  487.                 $headers $file->headers();
  488.                 $data trim($file->body());
  489.                 $file->close();
  490.                 unset($file);
  491.             }
  492.             else
  493.             {
  494.                 $data $this->raw_data;
  495.             }
  496.  
  497.             // First check to see if input has been overridden.
  498.             if (!empty($this->input_encoding))
  499.             {
  500.                 $encoding $this->input_encoding;
  501.             }
  502.             // Second try HTTP headers
  503.             else if (!empty($headers['content-type']&& preg_match('/charset\s*=\s*([^;]*)/i'$headers['content-type']$charset))
  504.             {
  505.                 $encoding $charset[1];
  506.             }
  507.             // Then prolog, if at the very start of the document
  508.             else if (preg_match('/^<\?xml(.*)?>/msiU'$data$prolog&& preg_match('/encoding\s*=\s*("([^"]*)"|\'([^\']*)\')/Ui'$prolog[1]$encoding))
  509.             {
  510.                 $encoding substr($encoding[1]1-1);
  511.             }
  512.             // UTF-32 Big Endian BOM
  513.             else if (strpos($datasprintf('%c%c%c%c'0x000x000xFE0xFF)) === 0)
  514.             {
  515.                 $encoding 'UTF-32be';
  516.             }
  517.             // UTF-32 Little Endian BOM
  518.             else if (strpos($datasprintf('%c%c%c%c'0xFF0xFE0x000x00)) === 0)
  519.             {
  520.                 $encoding 'UTF-32';
  521.             }
  522.             // UTF-16 Big Endian BOM
  523.             else if (strpos($datasprintf('%c%c'0xFE0xFF)) === 0)
  524.             {
  525.                 $encoding 'UTF-16be';
  526.             }
  527.             // UTF-16 Little Endian BOM
  528.             else if (strpos($datasprintf('%c%c'0xFF0xFE)) === 0)
  529.             {
  530.                 $encoding 'UTF-16le';
  531.             }
  532.             // UTF-8 BOM
  533.             else if (strpos($datasprintf('%c%c%c'0xEF0xBB0xBF)) === 0)
  534.             {
  535.                 $encoding 'UTF-8';
  536.             }
  537.             // Fallback to the default
  538.             else
  539.             {
  540.                 $encoding null;
  541.             }
  542.  
  543.             // Change the encoding to UTF-8 (as we always use UTF-8 internally)
  544.             $data SimplePie_Misc::change_encoding($data$encoding'UTF-8');
  545.  
  546.             // Strip illegal characters (if on less  than PHP5, as on PHP5 expat can manage fine)
  547.             if (version_compare(phpversion()'5''<'))
  548.             {
  549.                 if (function_exists('iconv'))
  550.                 {
  551.                     $data iconv('UTF-8''UTF-8//IGNORE'$data);
  552.                 }
  553.                 else if (function_exists('mb_convert_encoding'))
  554.                 {
  555.                     $data mb_convert_encoding($data'UTF-8''UTF-8');
  556.                 }
  557.                 else
  558.                 {
  559.                     $data SimplePie_Misc::utf8_bad_replace($data);
  560.                 }
  561.             }
  562.  
  563.             // Start parsing
  564.             $data new $this->parser_class($data'UTF-8'$this->xml_dump);
  565.             // If we want the XML, just output that and quit
  566.             if ($this->xml_dump)
  567.             {
  568.                 header('Content-type: text/xml; charset=UTF-8');
  569.                 echo $data->data;
  570.                 exit;
  571.             }
  572.             // If it's parsed fine
  573.             else if (!$data->error_code)
  574.             {
  575.                 // Parse the data, and make it sane
  576.                 $this->sanitize->parse_data_array($data->data$this->rss_url);
  577.                 unset($data);
  578.                 // Get the sane data
  579.                 $this->data['feedinfo'$this->sanitize->feedinfo;
  580.                 unset($this->sanitize->feedinfo);
  581.                 $this->data['info'$this->sanitize->info;
  582.                 unset($this->sanitize->info);
  583.                 $this->data['items'$this->sanitize->items;
  584.                 unset($this->sanitize->items);
  585.                 $this->data['feedinfo']['encoding'$this->sanitize->output_encoding;
  586.                 $this->data['url'$this->rss_url;
  587.  
  588.                 // Store the headers that we need
  589.                 if (!empty($headers['last-modified']))
  590.                 {
  591.                     $this->data['last-modified'$headers['last-modified'];
  592.                 }
  593.                 if (!empty($headers['etag']))
  594.                 {
  595.                     $this->data['etag'$headers['etag'];
  596.                 }
  597.  
  598.                 // If we want to order it by date, check if all items have a date, and then sort it
  599.                 if ($this->order_by_date && !empty($this->data['items']))
  600.                 {
  601.                     $do_sort true;
  602.                     foreach ($this->data['items'as $item)
  603.                     {
  604.                         if (!$item->get_date('U'))
  605.                         {
  606.                             $do_sort false;
  607.                             break;
  608.                         }
  609.                     }
  610.                     if ($do_sort)
  611.                     {
  612.                         usort($this->data['items']create_function('$a, $b''if ($a->get_date(\'U\') == $b->get_date(\'U\')) return 1; return ($a->get_date(\'U\') < $b->get_date(\'U\')) ? 1 : -1;'));
  613.                     }
  614.                 }
  615.  
  616.                 // Cache the file if caching is enabled
  617.                 if ($cache && !$cache->save($this->data))
  618.                 {
  619.                     $this->error = "$cache->name is not writeable";
  620.                     SimplePie_Misc::error($this->errorE_USER_WARNING__FILE____LINE__);
  621.                 }
  622.                 return true;
  623.             }
  624.             // If we have an error, just set SimplePie::error to it and quit
  625.             else
  626.             {
  627.                 $this->error = "XML error$data->error_string at line $data->current_linecolumn $data->current_column";
  628.                 SimplePie_Misc::error($this->errorE_USER_WARNING__FILE____LINE__);
  629.                 return false;
  630.             }
  631.         }
  632.     }
  633.  
  634.     function get_encoding()
  635.     {
  636.         if (!empty($this->data['feedinfo']['encoding']))
  637.         {
  638.             return $this->data['feedinfo']['encoding'];
  639.         }
  640.         else
  641.         {
  642.             return false;
  643.         }
  644.     }
  645.  
  646.     function handle_content_type($mime 'text/html')
  647.     {
  648.         if (!headers_sent())
  649.         {
  650.             $header "Content-type$mime;";
  651.             if ($this->get_encoding())
  652.             {
  653.                 $header .= ' charset=' $this->get_encoding();
  654.             }
  655.             else
  656.             {
  657.                 $header .= ' charset=UTF-8';
  658.             }
  659.             header($header);
  660.         }
  661.     }
  662.  
  663.     function get_type()
  664.     {
  665.         if (!empty($this->data['feedinfo']['type']))
  666.         {
  667.             return $this->data['feedinfo']['type'];
  668.         }
  669.         else
  670.         {
  671.             return false;
  672.         }
  673.     }
  674.  
  675.     function get_version()
  676.     {
  677.         if (!empty($this->data['feedinfo']['version']))
  678.         {
  679.             return $this->data['feedinfo']['version'];
  680.         }
  681.         else
  682.         {
  683.             return false;
  684.         }
  685.     }
  686.  
  687.     function get_favicon($check false$alternate null)
  688.     {
  689.         if (!empty($this->data['info']['link']['alternate'][0]))
  690.         {
  691.             $favicon SimplePie_Misc::absolutize_url('/favicon.ico'$this->get_feed_link());
  692.  
  693.             if ($check)
  694.             {
  695.                 $file new $this->file_class($favicon$this->timeout/105null$this->useragent$this->force_fsockopen);
  696.                 $headers $file->headers();
  697.                 $file->close();
  698.  
  699.                 if ($headers['status']['code'== 200)
  700.                 {
  701.                     return $favicon;
  702.                 }
  703.             }
  704.             else
  705.             {
  706.                 return $favicon;
  707.             }
  708.         }
  709.         if (!is_null($alternate))
  710.         {
  711.             return $alternate;
  712.         }
  713.         else
  714.         {
  715.             return false;
  716.         }
  717.     }
  718.  
  719.     function subscribe_url()
  720.     {
  721.         if (!empty($this->rss_url))
  722.         {
  723.             return $this->rss_url;
  724.         }
  725.         else
  726.         {
  727.             return false;
  728.         }
  729.     }
  730.  
  731.     function subscribe_feed()
  732.     {
  733.         if (!empty($this->rss_url))
  734.         {
  735.             return SimplePie_Misc::fix_protocol($this->rss_url2);
  736.         }
  737.         else
  738.         {
  739.             return false;
  740.         }
  741.     }
  742.  
  743.     function subscribe_outlook()
  744.     {
  745.         if (!empty($this->rss_url))
  746.         {
  747.             return 'outlook' SimplePie_Misc::fix_protocol($this->rss_url2);
  748.         }
  749.         else
  750.         {
  751.             return false;
  752.         }
  753.     }
  754.  
  755.     function subscribe_podcast()
  756.     {
  757.         if (!empty($this->rss_url))
  758.         {
  759.             return SimplePie_Misc::fix_protocol($this->rss_url3);
  760.         }
  761.         else
  762.         {
  763.             return false;
  764.         }
  765.     }
  766.  
  767.     function subscribe_aol()
  768.     {
  769.         if ($this->subscribe_url())
  770.         {
  771.             return 'http://feeds.my.aol.com/add.jsp?url=' rawurlencode($this->subscribe_url());
  772.         }
  773.         else
  774.         {
  775.             return false;
  776.         }
  777.     }
  778.  
  779.     function subscribe_bloglines()
  780.     {
  781.         if ($this->subscribe_url())
  782.         {
  783.             return 'http://www.bloglines.com/sub/' rawurlencode($this->subscribe_url());
  784.         }
  785.         else
  786.         {
  787.             return false;
  788.         }
  789.     }
  790.  
  791.     function subscribe_eskobo()
  792.     {
  793.         if ($this->subscribe_url())
  794.         {
  795.             return 'http://www.eskobo.com/?AddToMyPage=' rawurlencode($this->subscribe_url());
  796.         }
  797.         else
  798.         {
  799.             return false;
  800.         }
  801.     }
  802.  
  803.     function subscribe_feedfeeds()
  804.     {
  805.         if ($this->subscribe_url())
  806.         {
  807.             return 'http://www.feedfeeds.com/add?feed=' rawurlencode($this->subscribe_url());
  808.         }
  809.         else
  810.         {
  811.             return false;
  812.         }
  813.     }
  814.  
  815.     function subscribe_feedlounge()
  816.     {
  817.         if ($this->subscribe_url())
  818.         {
  819.             return 'http://my.feedlounge.com/external/subscribe?url=' rawurlencode($this->subscribe_url());
  820.         }
  821.         else
  822.         {
  823.             return false;
  824.         }
  825.     }
  826.  
  827.     function subscribe_feedster()
  828.     {
  829.         if ($this->subscribe_url())
  830.         {
  831.             return 'http://www.feedster.com/myfeedster.php?action=addrss&amp;confirm=no&amp;rssurl=' rawurlencode($this->subscribe_url());
  832.         }
  833.         else
  834.         {
  835.             return false;
  836.         }
  837.     }
  838.  
  839.     function subscribe_google()
  840.     {
  841.         if ($this->subscribe_url())
  842.         {
  843.             return 'http://fusion.google.com/add?feedurl=' rawurlencode($this->subscribe_url());
  844.         }
  845.         else
  846.         {
  847.             return false;
  848.         }
  849.     }
  850.  
  851.     function subscribe_gritwire()
  852.     {
  853.         if ($this->subscribe_url())
  854.         {
  855.             return 'http://my.gritwire.com/feeds/addExternalFeed.aspx?FeedUrl=' rawurlencode($this->subscribe_url());
  856.         }
  857.         else
  858.         {
  859.             return false;
  860.         }
  861.     }
  862.  
  863.     function subscribe_msn()
  864.     {
  865.         if ($this->subscribe_url())
  866.         {
  867.             $url 'http://my.msn.com/addtomymsn.armx?id=rss&amp;ut=' rawurlencode($this->subscribe_url());
  868.             if ($this->get_feed_link())
  869.             {
  870.                 $url .= '&amp;ru=' rawurlencode($this->get_feed_link());
  871.             }
  872.             return $url;
  873.         }
  874.         else
  875.         {
  876.             return false;
  877.         }
  878.     }
  879.  
  880.     function subscribe_netvibes()
  881.     {
  882.         if ($this->subscribe_url())
  883.         {
  884.             return 'http://www.netvibes.com/subscribe.php?url=' rawurlencode($this->subscribe_url());
  885.         }
  886.         else
  887.         {
  888.             return false;
  889.         }
  890.     }
  891.  
  892.     function subscribe_newsburst()
  893.     {
  894.         if ($this->subscribe_url())
  895.         {
  896.             return 'http://www.newsburst.com/Source/?add=' rawurlencode($this->subscribe_url());
  897.         }
  898.         else
  899.         {
  900.             return false;
  901.         }
  902.     }
  903.  
  904.     function subscribe_newsgator()
  905.     {
  906.         if ($this->subscribe_url())
  907.         {
  908.             return 'http://www.newsgator.com/ngs/subscriber/subext.aspx?url=' rawurlencode($this->subscribe_url());
  909.         }
  910.         else
  911.         {
  912.             return false;
  913.         }
  914.     }
  915.  
  916.     function subscribe_odeo()
  917.     {
  918.         if ($this->subscribe_url())
  919.         {
  920.             return 'http://www.odeo.com/listen/subscribe?feed=' rawurlencode($this->subscribe_url());
  921.         }
  922.         else
  923.         {
  924.             return false;
  925.         }
  926.     }
  927.  
  928.     function subscribe_pluck()
  929.     {
  930.         if ($this->subscribe_url())
  931.         {
  932.             return 'http://client.pluck.com/pluckit/prompt.aspx?GCID=C12286x053&amp;a=' rawurlencode($this->subscribe_url());
  933.         }
  934.         else
  935.         {
  936.             return false;
  937.         }
  938.     }
  939.  
  940.     function subscribe_podnova()
  941.     {
  942.         if ($this->subscribe_url())
  943.         {
  944.             return 'http://www.podnova.com/index_your_podcasts.srf?action=add&amp;url=' rawurlencode($this->subscribe_url());
  945.         }
  946.         else
  947.         {
  948.             return false;
  949.         }
  950.     }
  951.  
  952.     function subscribe_rojo()
  953.     {
  954.         if ($this->subscribe_url())
  955.         {
  956.             return 'http://www.rojo.com/add-subscription?resource=' rawurlencode($this->subscribe_url());
  957.         }
  958.         else
  959.         {
  960.             return false;
  961.         }
  962.     }
  963.  
  964.     function subscribe_yahoo()
  965.     {
  966.         if ($this->subscribe_url())
  967.         {
  968.             return 'http://add.my.yahoo.com/rss?url=' rawurlencode($this->subscribe_url());
  969.         }
  970.         else
  971.         {
  972.             return false;
  973.         }
  974.     }
  975.  
  976.     function get_feed_title()
  977.     {
  978.         if (!empty($this->data['info']['title']))
  979.         {
  980.             return $this->data['info']['title'];
  981.         }
  982.         else
  983.         {
  984.             return false;
  985.         }
  986.     }
  987.  
  988.     function get_feed_link()
  989.     {
  990.         if (!empty($this->data['info']['link']['alternate'][0]))
  991.         {
  992.             return $this->data['info']['link']['alternate'][0];
  993.         }
  994.         else
  995.         {
  996.             return false;
  997.         }
  998.     }
  999.  
  1000.     function get_feed_links()
  1001.     {
  1002.         if (!empty($this->data['info']['link']))
  1003.         {
  1004.             return $this->data['info']['link'];
  1005.         }
  1006.         else
  1007.         {
  1008.             return false;
  1009.         }
  1010.     }
  1011.  
  1012.     function get_feed_description()
  1013.     {
  1014.         if (!empty($this->data['info']['description']))
  1015.         {
  1016.             return $this->data['info']['description'];
  1017.         }
  1018.         else if (!empty($this->data['info']['dc:description']))
  1019.         {
  1020.             return $this->data['info']['dc:description'];
  1021.         }
  1022.         else if (!empty($this->data['info']['tagline']))
  1023.         {
  1024.             return $this->data['info']['tagline'];
  1025.         }
  1026.         else if (!empty($this->data['info']['subtitle']))
  1027.         {
  1028.             return $this->data['info']['subtitle'];
  1029.         }
  1030.         else
  1031.         {
  1032.             return false;
  1033.         }
  1034.     }
  1035.  
  1036.     function get_feed_copyright()
  1037.     {
  1038.         if (!empty($this->data['info']['copyright']))
  1039.         {
  1040.             return $this->data['info']['copyright'];
  1041.         }
  1042.         else
  1043.         {
  1044.             return false;
  1045.         }
  1046.     }
  1047.  
  1048.     function get_feed_language()
  1049.     {
  1050.         if (!empty($this->data['info']['language']))
  1051.         {
  1052.             return $this->data['info']['language'];
  1053.         }
  1054.         else if (!empty($this->data['info']['xml:lang']))
  1055.         {
  1056.             return $this->data['info']['xml:lang'];
  1057.         }
  1058.         else
  1059.         {
  1060.             return false;
  1061.         }
  1062.     }
  1063.  
  1064.     function get_image_exist()
  1065.     {
  1066.         if (!empty($this->data['info']['image']['url']|| !empty($this->data['info']['image']['logo']))
  1067.         {
  1068.             return true;
  1069.         }
  1070.         else
  1071.         {
  1072.             return false;
  1073.         }
  1074.     }
  1075.  
  1076.     function get_image_title()
  1077.     {
  1078.         if (!empty($this->data['info']['image']['title']))
  1079.         {
  1080.             return $this->data['info']['image']['title'];
  1081.         }
  1082.         else
  1083.         {
  1084.             return false;
  1085.         }
  1086.     }
  1087.  
  1088.     function get_image_url()
  1089.     {
  1090.         if (!empty($this->data['info']['image']['url']))
  1091.         {
  1092.             return $this->data['info']['image']['url'];
  1093.         }
  1094.         else if (!empty($this->data['info']['image']['logo']))
  1095.         {
  1096.             return $this->data['info']['image']['logo'];
  1097.         }
  1098.         else
  1099.         {
  1100.             return false;
  1101.         }
  1102.     }
  1103.  
  1104.     function get_image_link()
  1105.     {
  1106.         if (!empty($this->data['info']['image']['link']))
  1107.         {
  1108.             return $this->data['info']['image']['link'];
  1109.         }
  1110.         else
  1111.         {
  1112.             return false;
  1113.         }
  1114.     }
  1115.  
  1116.     function get_image_width()
  1117.     {
  1118.         if (!empty($this->data['info']['image']['width']))
  1119.         {
  1120.             return $this->data['info']['image']['width'];
  1121.         }
  1122.         else
  1123.         {
  1124.             return false;
  1125.         }
  1126.     }
  1127.  
  1128.     function get_image_height()
  1129.     {
  1130.         if (!empty($this->data['info']['image']['height']))
  1131.         {
  1132.             return $this->data['info']['image']['height'];
  1133.         }
  1134.         else
  1135.         {
  1136.             return false;
  1137.         }
  1138.     }
  1139.  
  1140.     function get_item_quantity($max 0)
  1141.     {
  1142.         if (!empty($this->data['items']))
  1143.         {
  1144.             $qty sizeof($this->data['items']);
  1145.         }
  1146.         else
  1147.         {
  1148.             $qty 0;
  1149.         }
  1150.         if ($max == 0)
  1151.         {
  1152.             return $qty;
  1153.         }
  1154.         else
  1155.         {
  1156.             return ($qty $max$max $qty;
  1157.         }
  1158.     }
  1159.  
  1160.     function get_item($key 0)
  1161.     {
  1162.         if (!empty($this->data['items'][$key]))
  1163.         {
  1164.             return $this->data['items'][$key];
  1165.         }
  1166.         else
  1167.         {
  1168.             return false;
  1169.         }
  1170.     }
  1171.  
  1172.     function get_items($start 0$end 0)
  1173.     {
  1174.         if ($this->get_item_quantity(0)
  1175.         {
  1176.             if ($end == 0)
  1177.             {
  1178.                 return array_slice($this->data['items']$start);
  1179.             }
  1180.             else
  1181.             {
  1182.                 return array_slice($this->data['items']$start$end);
  1183.             }
  1184.         }
  1185.         else
  1186.         {
  1187.             return false;
  1188.         }
  1189.     }
  1190. }
  1191.  
  1192. {
  1193.     var $data;
  1194.  
  1195.     function SimplePie_Item($data)
  1196.     {
  1197.         $this->data =$data;
  1198.     }
  1199.  
  1200.     function get_id()
  1201.     {
  1202.         if (!empty($this->data['guid']['data']))
  1203.         {
  1204.             return $this->data['guid']['data'];
  1205.         }
  1206.         else if (!empty($this->data['id']))
  1207.         {
  1208.             return $this->data['id'];
  1209.         }
  1210.         else
  1211.         {
  1212.             return false;
  1213.         }
  1214.     }
  1215.  
  1216.     function get_title()
  1217.     {
  1218.         if (!empty($this->data['title']))
  1219.         {
  1220.             return $this->data['title'];
  1221.         }
  1222.         else if (!empty($this->data['dc:title']))
  1223.         {
  1224.             return $this->data['dc:title'];
  1225.         }
  1226.         else
  1227.         {
  1228.             return false;
  1229.         }
  1230.     }
  1231.  
  1232.     function get_description()
  1233.     {
  1234.         if (!empty($this->data['content']))
  1235.         {
  1236.             return $this->data['content'];
  1237.         }
  1238.         else if (!empty($this->data['encoded']))
  1239.         {
  1240.             return $this->data['encoded'];
  1241.         }
  1242.         else if (!empty($this->data['summary']))
  1243.         {
  1244.             return $this->data['summary'];
  1245.         }
  1246.         else if (!empty($this->data['description']))
  1247.         {
  1248.             return $this->data['description'];
  1249.         }
  1250.         else if (!empty($this->data['dc:description']))
  1251.         {
  1252.             return $this->data['dc:description'];
  1253.         }
  1254.         else if (!empty($this->data['longdesc']))
  1255.         {
  1256.             return $this->data['longdesc'];
  1257.         }
  1258.         else
  1259.         {
  1260.             return false;
  1261.         }
  1262.     }
  1263.  
  1264.     function get_category($key 0)
  1265.     {
  1266.         $categories $this->get_categories();
  1267.         if (!empty($categories[$key]))
  1268.         {
  1269.             return $categories[$key];
  1270.         }
  1271.         else
  1272.         {
  1273.             return false;
  1274.         }
  1275.     }
  1276.  
  1277.     function get_categories()
  1278.     {
  1279.         $categories array();
  1280.         if (!empty($this->data['category']))
  1281.         {
  1282.             $categories array_merge($categories$this->data['category']);
  1283.         }
  1284.         if (!empty($this->data['subject']))
  1285.         {
  1286.             $categories array_merge($categories$this->data['subject']);
  1287.         }
  1288.         if (!empty($this->data['term']))
  1289.         {
  1290.             $categories array_merge($categories$this->data['term']);
  1291.         }
  1292.         if (!empty($categories))
  1293.         {
  1294.             return array_unique($categories);
  1295.         }
  1296.         else
  1297.         {
  1298.             return false;
  1299.         }
  1300.     }
  1301.  
  1302.     function get_author($key 0)
  1303.     {
  1304.         $authors $this->get_authors();
  1305.         if (!empty($authors[$key]))
  1306.         {
  1307.             return $authors[$key];
  1308.         }
  1309.         else
  1310.         {
  1311.             return false;
  1312.         }
  1313.     }
  1314.  
  1315.     function get_authors()
  1316.     {
  1317.         $authors array();
  1318.         if (!empty($this->data['author']))
  1319.         {
  1320.             $authors array_merge($authors$this->data['author']);
  1321.         }
  1322.         if (!empty($this->data['creator']))
  1323.         {
  1324.             $authors array_merge($authors$this->data['creator']);
  1325.         }
  1326.         if (!empty($authors))
  1327.         {
  1328.             return array_unique($authors);
  1329.         }
  1330.         else
  1331.         {
  1332.             return false;
  1333.         }
  1334.     }
  1335.  
  1336.     function get_date($date_format 'j F Y, g:i a')
  1337.     {
  1338.         if (!empty($this->data['pubdate']))
  1339.         {
  1340.             return date($date_format$this->data['pubdate']);
  1341.         }
  1342.         else if (!empty($this->data['dc:date']))
  1343.         {
  1344.             return date($date_format$this->data['dc:date']);
  1345.         }
  1346.         else if (!empty($this->data['issued']))
  1347.         {
  1348.             return date($date_format$this->data['issued']);
  1349.         }
  1350.         else if (!empty($this->data['published']))
  1351.         {
  1352.             return date($date_format$this->data['published']);
  1353.         }
  1354.         else if (!empty($this->data['modified']))
  1355.         {
  1356.             return date($date_format$this->data['modified']);
  1357.         }
  1358.         else if (!empty($this->data['updated']))
  1359.         {
  1360.             return date($date_format$this->data['updated']);
  1361.         }
  1362.         else
  1363.         {
  1364.             return false;
  1365.         }
  1366.     }
  1367.  
  1368.     function get_permalink()
  1369.     {
  1370.         $link $this->get_link(0);
  1371.         $enclosure $this->get_enclosure(0);
  1372.         if (!empty($link))
  1373.         {
  1374.             return $link;
  1375.         }
  1376.         else if (!empty($enclosure))
  1377.         {
  1378.             return $enclosure->get_link();
  1379.         }
  1380.         else
  1381.         {
  1382.             return false;
  1383.         }
  1384.     }
  1385.  
  1386.     function get_link($key 0$rel 'alternate')
  1387.     {
  1388.         $links $this->get_links($rel);
  1389.         if (!empty($links[$key]))
  1390.         {
  1391.             return $links[$key];
  1392.         }
  1393.         else
  1394.         {
  1395.             return false;
  1396.         }
  1397.     }
  1398.  
  1399.     function get_links($rel 'alternate')
  1400.     {
  1401.         if ($rel == 'alternate')
  1402.         {
  1403.             $links array();
  1404.             if (!empty($this->data['link'][$rel]))
  1405.             {
  1406.                 $links $this->data['link'][$rel];
  1407.             }
  1408.             if (!empty($this->data['guid']['data']&& $this->data['guid']['permalink'== true)
  1409.             {
  1410.                 $links[$this->data['guid']['data'];
  1411.             }
  1412.             return $links;
  1413.         }
  1414.         else if (!empty($this->data['link'][$rel]))
  1415.         {
  1416.             return $this->data['link'][$rel];
  1417.         }
  1418.         else
  1419.         {
  1420.             return false;
  1421.         }
  1422.     }
  1423.  
  1424.     function get_enclosure($key 0)
  1425.     {
  1426.         $enclosures $this->get_enclosures();
  1427.         if (!empty($enclosures[$key]))
  1428.         {
  1429.             return $enclosures[$key];
  1430.         }
  1431.         else
  1432.         {
  1433.             return false;
  1434.         }
  1435.     }
  1436.  
  1437.     function get_enclosures()
  1438.     {
  1439.         $enclosures array();
  1440.         $links $this->get_links('enclosure');
  1441.         if (!empty($this->data['enclosures']))
  1442.         {
  1443.             $enclosures array_merge($enclosures$this->data['enclosures']);
  1444.         }
  1445.         if (!empty($links))
  1446.         {
  1447.             $enclosures array_merge($enclosures$links);
  1448.         }
  1449.         if (!empty($enclosures))
  1450.         {
  1451.             return array_unique($enclosures);
  1452.         }
  1453.         else
  1454.         {
  1455.             return false;
  1456.         }
  1457.     }
  1458.  
  1459.     function add_to_blinklist()
  1460.     {
  1461.         if ($this->get_permalink())
  1462.         {
  1463.             $url 'http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=' rawurlencode($this->get_permalink());
  1464.             if ($this->get_title())
  1465.             {
  1466.                 $url .= '&amp;Title=' rawurlencode($this->get_title());
  1467.             }
  1468.             return $url;
  1469.         }
  1470.         else
  1471.         {
  1472.             return false;
  1473.         }
  1474.     }
  1475.  
  1476.     function add_to_blogmarks()
  1477.     {
  1478.         if ($this->get_permalink())
  1479.         {
  1480.             $url 'http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=' rawurlencode($this->get_permalink());
  1481.             if ($this->get_title())
  1482.             {
  1483.                 $url .= '&amp;title=' rawurlencode($this->get_title());
  1484.             }
  1485.             return $url;
  1486.         }
  1487.         else
  1488.         {
  1489.             return false;
  1490.         }
  1491.     }
  1492.  
  1493.     function add_to_delicious()
  1494.     {
  1495.         if ($this->get_permalink())
  1496.         {
  1497.             $url 'http://del.icio.us/post/?v=3&amp;url=' rawurlencode($this->get_permalink());
  1498.             if ($this->get_title())
  1499.             {
  1500.                 $url .= '&amp;title=' rawurlencode($this->get_title());
  1501.             }
  1502.             return $url;
  1503.         }
  1504.         else
  1505.         {
  1506.             return false;
  1507.         }
  1508.     }
  1509.  
  1510.     function add_to_digg()
  1511.     {
  1512.         if ($this->get_permalink())
  1513.         {
  1514.             return 'http://digg.com/submit?phase=2&amp;URL=' rawurlencode($this->get_permalink());
  1515.         }
  1516.         else
  1517.         {
  1518.             return false;
  1519.         }
  1520.     }
  1521.  
  1522.     function add_to_furl()
  1523.     {
  1524.         if ($this->get_permalink())
  1525.         {
  1526.             $url 'http://www.furl.net/storeIt.jsp?u=' rawurlencode($this->get_permalink());
  1527.             if ($this->get_title())
  1528.             {
  1529.                 $url .= '&amp;t=' rawurlencode($this->get_title());
  1530.             }
  1531.             return $url;
  1532.         }
  1533.         else
  1534.         {
  1535.             return false;
  1536.         }
  1537.     }
  1538.  
  1539.     function add_to_magnolia()
  1540.     {
  1541.         if ($this->get_permalink())
  1542.         {
  1543.             $url 'http://ma.gnolia.com/bookmarklet/add?url=' rawurlencode($this->get_permalink());
  1544.             if ($this->get_title())
  1545.             {
  1546.                 $url .= '&amp;title=' rawurlencode($this->get_title());
  1547.             }
  1548.             return $url;
  1549.         }
  1550.         else
  1551.         {
  1552.             return false;
  1553.         }
  1554.     }
  1555.  
  1556.     function add_to_myweb20()
  1557.     {
  1558.         if ($this->get_permalink())
  1559.         {
  1560.             $url 'http://myweb2.search.yahoo.com/myresults/bookmarklet?u=' rawurlencode($this->get_permalink());
  1561.             if ($this->get_title())
  1562.             {
  1563.                 $url .= '&amp;t=' rawurlencode($this->get_title());
  1564.             }
  1565.             return $url;
  1566.         }
  1567.         else
  1568.         {
  1569.             return false;
  1570.         }
  1571.     }
  1572.  
  1573.     function add_to_newsvine()
  1574.     {
  1575.         if ($this->get_permalink())
  1576.         {
  1577.             $url 'http://www.newsvine.com/_wine/save?u=' rawurlencode($this->get_permalink());
  1578.             if ($this->get_title())
  1579.             {
  1580.                 $url .= '&amp;h=' rawurlencode($this->get_title());
  1581.             }
  1582.             return $url;
  1583.         }
  1584.         else
  1585.         {
  1586.             return false;
  1587.         }
  1588.     }
  1589.  
  1590.     function add_to_reddit()
  1591.     {
  1592.         if ($this->get_permalink())
  1593.         {
  1594.             $url 'http://reddit.com/submit?url=' rawurlencode($this->get_permalink());
  1595.             if ($this->get_title())
  1596.             {
  1597.                 $url .= '&amp;title=' rawurlencode($this->get_title());
  1598.             }
  1599.             return $url;
  1600.         }
  1601.         else
  1602.         {
  1603.             return false;
  1604.         }
  1605.     }
  1606.  
  1607.     function add_to_segnalo()
  1608.     {
  1609.         if ($this->get_permalink())
  1610.         {
  1611.             $url 'http://segnalo.com/post.html.php?url=' rawurlencode($this->get_permalink());
  1612.             if ($this->get_title())
  1613.             {
  1614.                 $url .= '&amp;title=' rawurlencode($this->get_title());
  1615.             }
  1616.             return $url;
  1617.         }
  1618.         else
  1619.         {
  1620.             return false;
  1621.         }
  1622.     }
  1623.  
  1624.     function add_to_simpy()
  1625.     {
  1626.         if ($this->get_permalink())
  1627.         {
  1628.             $url 'http://www.simpy.com/simpy/LinkAdd.do?href=' rawurlencode($this->get_permalink());
  1629.             if ($this->get_title())
  1630.             {
  1631.                 $url .= '&amp;title=' rawurlencode($this->get_title());
  1632.             }
  1633.             return $url;
  1634.         }
  1635.         else
  1636.         {
  1637.             return false;
  1638.         }
  1639.     }
  1640.  
  1641.     function add_to_smarking()
  1642.     {
  1643.         if ($this->get_permalink())
  1644.         {
  1645.             return 'http://smarking.com/editbookmark/?url=' rawurlencode($this->get_permalink());
  1646.         }
  1647.         else
  1648.         {
  1649.             return false;
  1650.         }
  1651.     }
  1652.  
  1653.     function add_to_spurl()
  1654.     {
  1655.         if ($this->get_permalink())
  1656.         {
  1657.             $url 'http://www.spurl.net/spurl.php?v=3&amp;url=' rawurlencode($this->get_permalink());
  1658.             if ($this->get_title())
  1659.             {
  1660.                 $url .= '&amp;title=' rawurlencode($this->get_title());
  1661.             }
  1662.             return $url;
  1663.         }
  1664.         else
  1665.         {
  1666.             return false;
  1667.         }
  1668.     }
  1669.  
  1670.     function add_to_wists()
  1671.     {
  1672.         if ($this->get_permalink())
  1673.         {
  1674.             $url 'http://wists.com/r.php?c=&amp;r=' rawurlencode($this->get_permalink());
  1675.             if ($this->get_title())
  1676.             {
  1677.                 $url .= '&amp;title=' rawurlencode($this->get_title());
  1678.             }
  1679.             return $url;
  1680.         }
  1681.         else
  1682.         {
  1683.             return false;
  1684.         }
  1685.     }
  1686.  
  1687.     function search_technorati()
  1688.     {
  1689.         if ($this->get_permalink())
  1690.         {
  1691.             return 'http://www.technorati.com/search/' rawurlencode($this->get_permalink());
  1692.         }
  1693.         else
  1694.         {
  1695.             return false;
  1696.         }
  1697.     }
  1698. }
  1699.  
  1700. {
  1701.     var $name;
  1702.     var $link;
  1703.     var $email;
  1704.  
  1705.     // Constructor, used to input the data
  1706.         function SimplePie_Author($name$link$email)
  1707.     {
  1708.         $this->name = $name;
  1709.         $this->link = $link;
  1710.         $this->email = $email;
  1711.     }
  1712.  
  1713.     function get_name()
  1714.     {
  1715.         if (!empty($this->name))
  1716.         {
  1717.             return $this->name;
  1718.         }
  1719.         else
  1720.         {
  1721.             return false;
  1722.         }
  1723.     }
  1724.  
  1725.     function get_link()
  1726.     {
  1727.         if (!empty($this->link))
  1728.         {
  1729.             return $this->link;
  1730.         }
  1731.         else
  1732.         {
  1733.             return false;
  1734.         }
  1735.     }
  1736.  
  1737.     function get_email()
  1738.     {
  1739.         if (!empty($this->email))
  1740.         {
  1741.             return $this->email;
  1742.         }
  1743.         else
  1744.         {
  1745.             return false;
  1746.         }
  1747.     }
  1748. }
  1749.  
  1750. {
  1751.     var $link;
  1752.     var $type;
  1753.     var $length;
  1754.  
  1755.     // Constructor, used to input the data
  1756.         function SimplePie_Enclosure($link$type$length)
  1757.     {
  1758.         $this->link = $link;
  1759.         $this->type = $type;
  1760.         $this->length = $length;
  1761.     }
  1762.  
  1763.     function get_link()
  1764.     {
  1765.         if (!empty($this->link))
  1766.         {
  1767.             if (class_exists('idna_convert'))
  1768.             {
  1769.                 $idn new idna_convert;
  1770.                 $this->link = $idn->encode($this->link);
  1771.             }
  1772.             return $this->link;
  1773.         }
  1774.         else
  1775.         {
  1776.             return false;
  1777.         }
  1778.     }
  1779.  
  1780.     function get_extension()
  1781.     {
  1782.         if (!empty($this->link))
  1783.         {
  1784.             return pathinfo($this->linkPATHINFO_EXTENSION);
  1785.         }
  1786.         else
  1787.         {
  1788.             return false;
  1789.         }
  1790.     }
  1791.  
  1792.     function get_type()
  1793.     {
  1794.         if (!empty($this->type))
  1795.         {
  1796.             return $this->type;
  1797.         }
  1798.         else
  1799.         {
  1800.             return false;
  1801.         }
  1802.     }
  1803.  
  1804.     function get_length()
  1805.     {
  1806.         if (!empty($this->length))
  1807.         {
  1808.             return $this->length;
  1809.         }
  1810.         else
  1811.         {
  1812.             return false;
  1813.         }
  1814.     }
  1815.  
  1816.     function get_size()
  1817.     {
  1818.         $length $this->get_length();
  1819.         if (!empty($length))
  1820.         {
  1821.             return round($length/10485762);
  1822.         }
  1823.         else
  1824.         {
  1825.             return false;
  1826.         }
  1827.     }
  1828.  
  1829.     function native_embed($options='')
  1830.     {
  1831.         return $this->embed($optionstrue);
  1832.     }
  1833.  
  1834.     function embed($options ''$native false)
  1835.     {
  1836.         // Set up defaults
  1837.         $audio '';
  1838.         $video '';
  1839.         $alt '';
  1840.         $altclass '';
  1841.         $loop 'false';
  1842.         $width 'auto';
  1843.         $height 'auto';
  1844.         $bgcolor '#ffffff';
  1845.  
  1846.         // Process options and reassign values as necessary
  1847.         if (is_array($options))
  1848.         {
  1849.             extract($options);
  1850.         }
  1851.         else
  1852.         {
  1853.             $options explode(','$options);
  1854.             foreach($options as $option)
  1855.             {
  1856.                 $opt explode(':'$option2);
  1857.                 if (isset($opt[0]$opt[1]))
  1858.                 {
  1859.                     $opt[0trim($opt[0]);
  1860.                     $opt[1trim($opt[1]);
  1861.                     switch ($opt[0])
  1862.                     {
  1863.                         case 'audio':
  1864.                             $audio $opt[1];
  1865.                             break;
  1866.  
  1867.                         case 'video':
  1868.                             $video $opt[1];
  1869.                             break;
  1870.  
  1871.                         case 'alt':
  1872.                             $alt $opt[1];
  1873.                             break;
  1874.  
  1875.                         case 'altclass':
  1876.                             $altclass $opt[1];
  1877.                             break;
  1878.  
  1879.                         case 'loop':
  1880.                             $loop $opt[1];
  1881.                             break;
  1882.  
  1883.                         case 'width':
  1884.                             $width $opt[1];
  1885.                             break;
  1886.  
  1887.                         case 'height':
  1888.                             $height $opt[1];
  1889.                             break;
  1890.  
  1891.                         case 'bgcolor':
  1892.                             $bgcolor $opt[1];
  1893.                             break;
  1894.                     }
  1895.                 }
  1896.             }
  1897.         }
  1898.  
  1899.         $type strtolower($this->get_type());
  1900.  
  1901.         // If we encounter an unsupported mime-type, check the file extension and guess intelligently.
  1902.         if (!in_array($typearray('audio/3gpp''audio/3gpp2''audio/aac''audio/x-aac''audio/aiff''audio/x-aiff''audio/mid''audio/midi''audio/x-midi''audio/mpeg''audio/x-mpeg''audio/mp3''x-audio/mp3''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''application/x-shockwave-flash''application/futuresplash''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')))
  1903.         {
  1904.             switch (strtolower($this->get_extension()))
  1905.             {
  1906.                 // Audio mime-types
  1907.                 case 'aac':
  1908.                 case 'adts':
  1909.                     $type 'audio/acc';
  1910.                     break;
  1911.  
  1912.                 case 'aif':
  1913.                 case 'aifc':
  1914.                 case 'aiff':
  1915.                 case 'cdda':
  1916.                     $type 'audio/aiff';
  1917.                     break;
  1918.  
  1919.                 case 'bwf':
  1920.                     $type 'audio/wav';
  1921.                     break;
  1922.  
  1923.                 case 'kar':
  1924.                 case 'mid':
  1925.                 case 'midi':
  1926.                 case 'smf':
  1927.                     $type 'audio/midi';
  1928.                     break;
  1929.  
  1930.                 case 'm4a':
  1931.                     $type 'audio/x-m4a';
  1932.                     break;
  1933.  
  1934.                 case 'mp3':
  1935.                 case 'swa':
  1936.                     $type 'audio/mp3';
  1937.                     break;
  1938.  
  1939.                 case 'wav':
  1940.                     $type 'audio/wav';
  1941.                     break;
  1942.  
  1943.                 case 'wax':
  1944.                     $type 'audio/x-ms-wax';
  1945.                     break;
  1946.  
  1947.                 case 'wma':
  1948.                     $type 'audio/x-ms-wma';
  1949.                     break;
  1950.  
  1951.                 // Video mime-types
  1952.                 case '3gp':
  1953.                 case '3gpp':
  1954.                     $type 'video/3gpp';
  1955.                     break;
  1956.  
  1957.                 case '3g2':
  1958.                 case '3gp2':
  1959.                     $type 'video/3gpp2';
  1960.                     break;
  1961.  
  1962.                 case 'asf':
  1963.                     $type 'video/x-ms-asf';
  1964.                     break;
  1965.  
  1966.                 case 'm1a':
  1967.                 case 'm1s':
  1968.                 case 'm1v':
  1969.                 case 'm15':
  1970.                 case 'm75':
  1971.                 case 'mp2':
  1972.                 case 'mpa':
  1973.                 case 'mpeg':
  1974.                 case 'mpg':
  1975.                 case 'mpm':
  1976.                 case 'mpv':
  1977.                     $type 'video/mpeg';
  1978.                     break;
  1979.  
  1980.                 case 'm4v':
  1981.                     $type 'video/x-m4v';
  1982.                     break;
  1983.  
  1984.                 case 'mov':
  1985.                 case 'qt':
  1986.                     $type 'video/quicktime';
  1987.                     break;
  1988.  
  1989.                 case 'mp4':
  1990.                 case 'mpg4':
  1991.                     $type 'video/mp4';
  1992.                     break;
  1993.  
  1994.                 case 'sdv':
  1995.                     $type 'video/sd-video';
  1996.                     break;
  1997.  
  1998.                 case 'wm':
  1999.                     $type 'video/x-ms-wm';
  2000.                     break;
  2001.  
  2002.                 case 'wmv':
  2003.                     $type 'video/x-ms-wmv';
  2004.                     break;
  2005.  
  2006.                 case 'wvx':
  2007.                     $type 'video/x-ms-wvx';
  2008.                     break;
  2009.  
  2010.                 // Flash mime-types
  2011.                 case 'spl':
  2012.                     $type 'application/futuresplash';
  2013.                     break;
  2014.  
  2015.                 case 'swf':
  2016.                     $type 'application/x-shockwave-flash';
  2017.                     break;
  2018.             }
  2019.         }
  2020.  
  2021.         $mime explode('/'$type2);
  2022.         $mime $mime[0];
  2023.  
  2024.         // Process values for 'auto'
  2025.         if ($width == 'auto')
  2026.         {
  2027.             if ($mime == 'video')
  2028.             {
  2029.                 $width '320';
  2030.             }
  2031.             else
  2032.             {
  2033.                 $width '100%';
  2034.             }
  2035.         }
  2036.         if ($height == 'auto')
  2037.         {
  2038.             if ($mime == 'audio')
  2039.             {
  2040.                 $height 0;
  2041.             }
  2042.             else if ($mime == 'video')
  2043.             {
  2044.                 $height 240;
  2045.             }
  2046.             else
  2047.             {
  2048.                 $height 256;
  2049.             }
  2050.         }
  2051.  
  2052.         // Set proper placeholder value
  2053.         if ($mime == 'audio')
  2054.         {
  2055.             $placeholder $audio;
  2056.         }
  2057.         else if ($mime == 'video')
  2058.         {
  2059.             $placeholder $video;
  2060.         }
  2061.  
  2062.         $embed '';
  2063.  
  2064.         // Make sure the JS library is included
  2065.         // (I know it'll be included multiple times, but I can't think of a better way to do this automatically)
  2066.         if (!$native)
  2067.         {
  2068.             $embed .= '<script type="text/javascript" src="?js"></script>';
  2069.         }
  2070.  
  2071.         // Odeo Feed MP3's
  2072.         if (substr(strtolower($this->get_link())015== 'http://odeo.com'{
  2073.             if ($native)
  2074.             {
  2075.                 $embed .= '<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=' $this->get_link('"></embed>';
  2076.             }
  2077.             else
  2078.             {
  2079.                 $embed .= '<script type="text/javascript">embed_odeo("' $this->get_link('");</script>';
  2080.             }
  2081.         }
  2082.  
  2083.         // QuickTime 7 file types.  Need to test with QuickTime 6.
  2084.         else if (in_array($typearray('audio/3gpp''audio/3gpp2''audio/aac''audio/x-aac''audio/aiff''audio/x-aiff''audio/mid''audio/midi''audio/x-midi''audio/mpeg''audio/x-mpeg''audio/mp3''x-audio/mp3''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')))
  2085.         {
  2086.             $height += 16;
  2087.             if ($native)
  2088.             {
  2089.                 if ($placeholder != ""{
  2090.                     $embed .= "<embed type=\"$type\" style=\"cursor:handcursor: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://www.apple.com/quicktime/download/\"></embed>";
  2091.                 }
  2092.                 else {
  2093.                     $embed .= "<embed type=\"$type\" style=\"cursor:handcursor:pointer;\" src=\"$this->get_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>";
  2094.                 }
  2095.             }
  2096.             else
  2097.             {
  2098.                 $embed .= "<script type='text/javascript'>embed_quicktime('$type', '$bgcolor', '$width', '$height', '$this->get_link("', '$placeholder', '$loop');</script>";
  2099.             }
  2100.         }
  2101.  
  2102.         // Flash
  2103.         else if (in_array($typearray('application/x-shockwave-flash''application/futuresplash')))
  2104.         {
  2105.             if ($native)
  2106.             {
  2107.                 $embed .= "<embed src=\"" $this->get_link("\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"$type\" quality=\"high\" width=\"$width\" height=\"$height\" bgcolor=\"$bgcolor\" loop=\"$loop\"></embed>";
  2108.             }
  2109.             else
  2110.             {
  2111.                 $embed .= "<script type='text/javascript'>embed_flash('$bgcolor', '$width', '$height', '$this->get_link("', '$loop', '$type');</script>";
  2112.             }
  2113.         }
  2114.  
  2115.         // Windows Media
  2116.         else if (in_array($typearray('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')))
  2117.         {
  2118.             $height += 45;
  2119.             if ($native)
  2120.             {
  2121.                 $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>";
  2122.             }
  2123.             else
  2124.             {
  2125.                 $embed .= "<script type='text/javascript'>embed_wmedia('$width', '$height', '$this->get_link("');</script>";
  2126.             }
  2127.         }
  2128.  
  2129.         // Everything else
  2130.         else $embed .= '<a href="' $this->get_link('" class="' $altclass '">' $alt '</a>';
  2131.  
  2132.         return $embed;
  2133.     }
  2134. }
  2135.  
  2136. {
  2137.     var $url;
  2138.     var $useragent;
  2139.     var $success = true;
  2140.     var $headers = array();
  2141.     var $body;
  2142.     var $fp;
  2143.     var $redirects = 0;
  2144.     var $error;
  2145.     var $method;
  2146.  
  2147.     function SimplePie_File($url$timeout 10$redirects 5$headers null$useragent null$force_fsockopen false)
  2148.     {
  2149.         if (class_exists('idna_convert'))
  2150.         {
  2151.             $idn new idna_convert;
  2152.             $url $idn->encode($url);
  2153.         }
  2154.         $this->url = $url;
  2155.         $this->useragent = $useragent;
  2156.         if (preg_match('/^http(s)?:\/\//i'$url))
  2157.         {
  2158.             if (empty($useragent))
  2159.             {
  2160.                 $useragent ini_get('user_agent');
  2161.                 $this->useragent = $useragent;
  2162.             }
  2163.             if (!is_array($headers))
  2164.             {
  2165.                 $headers array();
  2166.             }
  2167.             if (extension_loaded('curl'&& version_compare(SimplePie_Misc::get_curl_version()'7.10.5''>='&& !$force_fsockopen)
  2168.             {
  2169.                 $this->method = 'curl';
  2170.                 $fp curl_init();
  2171.                 $headers2 array();
  2172.                 foreach ($headers as $key => $value)
  2173.                 {
  2174.                     $headers2["$key$value";
  2175.                 }
  2176.                 curl_setopt($fpCURLOPT_ENCODING'');
  2177.                 curl_setopt($fpCURLOPT_URL$url);
  2178.                 curl_setopt($fpCURLOPT_HEADER1);
  2179.                 curl_setopt($fpCURLOPT_RETURNTRANSFER1);
  2180.                 curl_setopt($fpCURLOPT_TIMEOUT$timeout);
  2181.                 curl_setopt($fpCURLOPT_REFERER$url);
  2182.                 curl_setopt($fpCURLOPT_USERAGENT$useragent);
  2183.                 curl_setopt($fpCURLOPT_HTTPHEADER$headers2);
  2184.                 if (!ini_get('open_basedir'&& !ini_get('safe_mode'))
  2185.                 {
  2186.                     curl_setopt($fpCURLOPT_FOLLOWLOCATION1);
  2187.                     curl_setopt($fpCURLOPT_MAXREDIRS$redirects);
  2188.                 }
  2189.  
  2190.                 $this->headers = trim(curl_exec($fp));
  2191.                 if (curl_errno($fp== 23 || curl_errno($fp== 61)
  2192.                 {
  2193.                     curl_setopt($fpCURLOPT_ENCODING'none');
  2194.                     $this->headers = trim(curl_exec($fp));
  2195.                 }
  2196.                 if (curl_errno($fp))
  2197.                 {
  2198.                     $this->error = 'cURL error ' curl_errno($fp': ' curl_error($fp);
  2199.                     $this->success = false;
  2200.                     return false;
  2201.                 }
  2202.                 $info curl_getinfo($fp);
  2203.                 $this->headers = explode("\r\n\r\n"$this->headers$info['redirect_count'2);
  2204.                 if (count($this->headers== $info['redirect_count'1)
  2205.                 {
  2206.                     $this->headers = array_pop($this->headers);
  2207.                     $this->body = '';
  2208.                 }
  2209.                 else
  2210.                 {
  2211.                     $this->body = array_pop($this->headers);
  2212.                     $this->headers = array_pop($this->headers);
  2213.                 }
  2214.                 $this->headers = $this->parse_headers($this->headers);
  2215.                 if (($this->headers['status']['code'== 301 || $this->headers['status']['code'== 302 || $this->headers['status']['code'== 303 || $this->headers['status']['code'== 307&& !empty($this->headers['location']&& $this->redirects < $redirects)
  2216.                 {
  2217.                     $this->redirects++;
  2218.                     return $this->SimplePie_File($this->headers['location']$timeout$redirects$headers$useragent$force_fsockopen);
  2219.                 }
  2220.             }
  2221.             else
  2222.             {
  2223.                 $this->method = 'fsockopen';
  2224.                 $url_parts parse_url($url);
  2225.                 if (isset($url_parts['scheme']&& strtolower($url_parts['scheme']== 'https')
  2226.                 {
  2227.                     $url_parts['host'"ssl://$url_parts[host]";
  2228.                     $url_parts['port'443;
  2229.                 }
  2230.                 if (!isset($url_parts['port']))
  2231.                 {
  2232.                     $url_parts['port'80;
  2233.                 }
  2234.                 $this->fp = fsockopen($url_parts['host']$url_parts['port']$errno$errstr$timeout);
  2235.                 if (!$this->fp)
  2236.                 {
  2237.                     $this->error = 'fsockopen error: ' $errstr;
  2238.                     $this->success = false;
  2239.                     return false;
  2240.                 }
  2241.                 else
  2242.                 {
  2243.                     stream_set_timeout($this->fp$timeout);
  2244.                     $get (isset($url_parts['query'])) "$url_parts[path]?$url_parts[query]$url_parts['path'];
  2245.                     $out "GET $get HTTP/1.0\r\n";
  2246.                     $out .= "Host$url_parts[host]\r\n";
  2247.                     $out .= "User-Agent$useragent\r\n";
  2248.                     if (function_exists('gzinflate'))
  2249.                     {
  2250.                         $out .= "Accept-Encoding: gzip,deflate\r\n";
  2251.                     }
  2252.  
  2253.                     if (!empty($url_parts['user']&& !empty($url_parts['pass']))
  2254.                     {
  2255.                         $out .= "Authorization: Basic " base64_encode("$url_parts[user]:$url_parts[pass]""\r\n";
  2256.                     }
  2257.                     foreach ($headers as $key => $value)
  2258.                     {
  2259.                         $out .= "$key$value\r\n";
  2260.                     }
  2261.                     $out .= "Connection: Close\r\n\r\n";
  2262.                     fwrite($this->fp$out);
  2263.  
  2264.                     $info stream_get_meta_data($this->fp);
  2265.                     $data '';
  2266.                     while (strpos($data"\r\n\r\n"=== false && !$info['timed_out'])
  2267.                     {
  2268.                         $data .= fgets($this->fp128);
  2269.                         $info stream_get_meta_data($this->fp);
  2270.                     }
  2271.                     if (!$info['timed_out'])
  2272.                     {
  2273.                         $this->headers = $this->parse_headers($data);
  2274.                         if (($this->headers['status']['code'== 301 || $this->headers['status']['code'== 302 || $this->headers['status']['code'== 303 || $this->headers['status']['code'== 307&& !empty($this->headers['location']&& $this->redirects < $redirects)
  2275.                         {
  2276.                             $this->redirects++;
  2277.                             return $this->SimplePie_File($this->headers['location']$timeout$redirects$headers$useragent$force_fsockopen);
  2278.                         }
  2279.                     }
  2280.                     else
  2281.                     {
  2282.                         $this->close();
  2283.                         $this->error = 'fsocket timed out';
  2284.                         $this->success = false;
  2285.                         return false;
  2286.                     }
  2287.                 }
  2288.             }
  2289.             return $this->headers['status']['code'];
  2290.         }
  2291.         else
  2292.         {
  2293.             $this->method = 'fopen';
  2294.             if ($this->fp = fopen($url'r'))
  2295.             {
  2296.                 return true;
  2297.             }
  2298.             else
  2299.             {
  2300.                 $this->error = 'fopen could not open the file';
  2301.                 $this->success = false;
  2302.                 return false;
  2303.             }
  2304.         }
  2305.     }
  2306.  
  2307.     function headers()
  2308.     {
  2309.         return $this->headers;
  2310.     }
  2311.  
  2312.     function body()
  2313.     {
  2314.         if (is_null($this->body))
  2315.         {
  2316.             if ($this->fp)
  2317.             {
  2318.                 $info stream_get_meta_data($this->fp);
  2319.                 $this->body = '';
  2320.                 while (!$info['eof'&& !$info['timed_out'])
  2321.                 {
  2322.                     $this->body .= fread($this->fp1024);
  2323.                     $info stream_get_meta_data($this->fp);
  2324.                 }
  2325.                 if (!$info['timed_out'])
  2326.                 {
  2327.                     $this->body = trim($this->body);
  2328.                     if ($this->method == 'fsockopen' && !empty($this->headers['content-encoding']&& ($this->headers['content-encoding'== 'gzip' || $this->headers['content-encoding'== 'deflate'))
  2329.                     {
  2330.                         if (substr($this->body08== "\x1f\x8b\x08\x00\x00\x00\x00\x00")
  2331.                         {
  2332.                             $this->body = substr($this->body10);
  2333.                         }
  2334.                         $this->body = gzinflate($this->body);
  2335.                     }
  2336.                     $this->close();
  2337.                 }
  2338.                 else
  2339.                 {
  2340.                     return false;
  2341.                 }
  2342.             }
  2343.             else
  2344.             {
  2345.                 return false;
  2346.             }
  2347.         }
  2348.         return $this->body;
  2349.     }
  2350.  
  2351.     function close()
  2352.     {
  2353.         if (!is_null($this->fp))
  2354.         {
  2355.             if (fclose($this->fp))
  2356.             {
  2357.                 $this->fp = null;
  2358.                 return true;
  2359.             }
  2360.             else
  2361.             {
  2362.                 return false;
  2363.             }
  2364.         }
  2365.         else
  2366.         {
  2367.             return false;
  2368.         }
  2369.     }
  2370.  
  2371.     function parse_headers($headers)
  2372.     {
  2373.         $headers explode("\r\n"trim($headers));
  2374.         $status array_shift($headers);
  2375.         foreach ($headers as $header)
  2376.         {
  2377.             $data explode(':'$header2);
  2378.             $head[strtolower(trim($data[0]))trim($data[1]);
  2379.         }
  2380.         if (preg_match('/HTTP\/[0-9\.]+ ([0-9]+)(.*)$/i'$status$matches))
  2381.         {
  2382.             if (isset($head['status']))
  2383.             {
  2384.                 unset($head['status']);
  2385.             }
  2386.             $head['status']['code'$matches[1];
  2387.             $head['status']['name'trim($matches[2]);
  2388.         }
  2389.         return $head;
  2390.     }
  2391. }
  2392.  
  2393. {
  2394.     var $location;
  2395.     var $filename;
  2396.     var $extension;
  2397.     var $name;
  2398.  
  2399.     function SimplePie_Cache($location$filename$extension)
  2400.     {
  2401.         $this->location = $location;
  2402.         $this->filename = rawurlencode($filename);
  2403.         $this->extension = rawurlencode($extension);
  2404.         $this->name = "$location/$this->filename.$this->extension";
  2405.     }
  2406.  
  2407.     function save($data)
  2408.     {
  2409.         if (file_exists($this->name&& is_writeable($this->name|| file_exists($this->location&& is_writeable($this->location))
  2410.         {
  2411.             $fp fopen($this->name'w');
  2412.             if ($fp)
  2413.             {
  2414.                 fwrite($fpserialize($data));
  2415.                 fclose($fp);
  2416.                 return true;
  2417.             }
  2418.         }
  2419.         return false;
  2420.     }
  2421.  
  2422.     function load()
  2423.     {
  2424.         if (file_exists($this->name&& is_readable($this->name))
  2425.         {
  2426.             return unserialize(file_get_contents($this->name));
  2427.         }
  2428.         return false;
  2429.     }
  2430.  
  2431.     function mtime()
  2432.     {
  2433.         if (file_exists($this->name))
  2434.         {
  2435.             return filemtime($this->name);
  2436.         }
  2437.         return false;
  2438.     }
  2439.  
  2440.     function touch()
  2441.     {
  2442.         if (file_exists($this->name))
  2443.         {
  2444.             return touch($this->name);
  2445.         }
  2446.         return false;
  2447.     }
  2448.  
  2449.     function unlink()
  2450.     {
  2451.         if (file_exists($this->name))
  2452.         {
  2453.             return unlink($this->name);
  2454.         }
  2455.         return false;
  2456.     }
  2457. }
  2458.  
  2459. {
  2460.     function absolutize_url($relative$base)
  2461.     {
  2462.         $relative trim($relative);
  2463.         $base trim($base);
  2464.         if (!empty($relative))
  2465.         {
  2466.             $relative SimplePie_Misc::parse_url($relativefalse);
  2467.             $relative array('scheme' => $relative[2]'authority' => $relative[3]'path' => $relative[5]'query' => $relative[7]'fragment' => $relative[9]);
  2468.             if (!empty($relative['scheme']))
  2469.             {
  2470.                 $target $relative;
  2471.             }
  2472.             else if (!empty($base))
  2473.             {
  2474.                 $base SimplePie_Misc::parse_url($basefalse);
  2475.                 $base array('scheme' => $base[2]'authority' => $base[3]'path' => $base[5]'query' => $base[7]'fragment' => $base[9]);
  2476.                 $target['scheme'$base['scheme'];
  2477.                 if (!empty($relative['authority']))
  2478.                 {
  2479.                     $target array_merge($relative$target);
  2480.                 }
  2481.                 else
  2482.                 {
  2483.                     $target['authority'$base['authority'];
  2484.                     if (!empty($relative['path']))
  2485.                     {
  2486.                         if (strpos($relative['path']'/'=== 0)
  2487.                         {
  2488.                             $target['path'$relative['path'];
  2489.                         }
  2490.                         else
  2491.                         {
  2492.                             if (!empty($base['path']))
  2493.                             {
  2494.                                 $target['path'dirname("$base[path]."'/' $relative['path'];
  2495.                             }
  2496.                             else
  2497.                             {
  2498.                                 $target['path''/' $relative['path'];
  2499.                             }
  2500.                         }
  2501.                         if (!empty($relative['query']))
  2502.                         {
  2503.                             $target['query'$relative['query'];
  2504.                         }
  2505.                         $input $target['path'];
  2506.                         $target['path''';
  2507.                         while (!empty($input))
  2508.                         {
  2509.                             if (strpos($input'../'=== 0)
  2510.                             {
  2511.                                 $input substr($input3);
  2512.                             }
  2513.                             else if (strpos($input'./'=== 0)
  2514.                             {
  2515.                                 $input substr($input2);
  2516.                             }
  2517.                             else if (strpos($input'/./'=== 0)
  2518.                             {
  2519.                                 $input substr_replace($input'/'03);
  2520.                             }
  2521.                             else if (strpos($input'/.'=== && SimplePie_Misc::strendpos($input'/.'=== 0)
  2522.                             {
  2523.                                 $input substr_replace($input'/'-2);
  2524.                             }
  2525.                             else if (strpos($input'/../'=== 0)
  2526.                             {
  2527.                                 $input substr_replace($input'/'04);
  2528.                                 $target['path'preg_replace('/(\/)?([^\/]+)$/msiU'''$target['path']);
  2529.                             }
  2530.                             else if (strpos($input'/..'=== && SimplePie_Misc::strendpos($input'/..'=== 0)
  2531.                             {
  2532.                                 $input substr_replace($input'/'03);
  2533.                                 $target['path'preg_replace('/(\/)?([^\/]+)$/msiU'''$target['path']);
  2534.                             }
  2535.                             else if ($input == '.' || $input == '..')
  2536.                             {
  2537.                                 $input '';
  2538.                             }
  2539.                             else
  2540.                             {
  2541.                                 if (preg_match('/^(.+)(\/|$)/msiU'$input$match))
  2542.                                 {
  2543.                                     $target['path'.= $match[1];
  2544.                                     $input substr_replace($input''0strlen($match[1]));
  2545.                                 }
  2546.                             }
  2547.                         }
  2548.                     }
  2549.                     else
  2550.                     {
  2551.                         if (!empty($base['path']))
  2552.                         {
  2553.                             $target['path'$base['path'];
  2554.                         }
  2555.                         else
  2556.                         {
  2557.                             $target['path''/';
  2558.                         }
  2559.                         if (!empty($relative['query']))
  2560.                         {
  2561.                             $target['query'$relative['query'];
  2562.                         }
  2563.                         else if (!empty($base['query']))
  2564.                         {
  2565.                             $target['query'$base['query'];
  2566.                         }
  2567.                     }
  2568.                 }
  2569.                 if (!empty($relative['fragment']))
  2570.                 {
  2571.                     $target['fragment'$relative['fragment'];
  2572.                 }
  2573.             }
  2574.             else
  2575.             {
  2576.                 return false;
  2577.             }
  2578.             $return '';
  2579.             if (!empty($target['scheme']))
  2580.             {
  2581.                 $return .= "$target[scheme]:";
  2582.             }
  2583.             if (!empty($target['authority']))
  2584.             {
  2585.                 $return .= $target['authority'];
  2586.             }
  2587.             if (!empty($target['path']))
  2588.             {
  2589.                 $return .= $target['path'];
  2590.             }
  2591.             if (!empty($target['query']))
  2592.             {
  2593.                 $return .= "?$target[query]";
  2594.             }
  2595.             if (!empty($target['fragment']))
  2596.             {
  2597.                 $return .= "#$target[fragment]";
  2598.             }
  2599.         }
  2600.         else
  2601.         {
  2602.             $return $base;
  2603.         }
  2604.         return $return;
  2605.     }
  2606.  
  2607.     function strendpos($haystack$needle)
  2608.     {
  2609.         return strlen($haystackstrpos($haystack$needlestrlen($needle);
  2610.     }
  2611.  
  2612.     function get_element($realname$string)
  2613.     {
  2614.         $return array();
  2615.         $name preg_quote($realname'/');
  2616.         preg_match_all("/<($name)((\s*((\w+:)?\w+)\s*=\s*(\"([^\"]*)\"|'([^']*)'|(.*)))*)\s*((\/)?>|>(.*)<\/$name>)/msiU"$string$matchesPREG_SET_ORDER);
  2617.         for ($i 0$i count($matches)$i++)
  2618.         {
  2619.             $return[$i]['tag'$realname;
  2620.             $return[$i]['full'$matches[$i][0];
  2621.             if (strlen($matches[$i][10]<= 2)
  2622.             {
  2623.                 $return[$i]['self_closing'true;
  2624.             }
  2625.             else
  2626.             {
  2627.                 $return[$i]['self_closing'false;
  2628.                 $return[$i]['content'$matches[$i][12];
  2629.             }
  2630.             $return[$i]['attribs'array();
  2631.             if (!empty($matches[$i][2]))
  2632.             {
  2633.                 preg_match_all('/((\w+:)?\w+)\s*=\s*("([^"]*)"|\'([^\']*)\'|(\S+))\s/msiU'' ' $matches[$i][2' '$attribsPREG_SET_ORDER);
  2634.                 for ($j 0$j count($attribs);  $j++)
  2635.                 {
  2636.                     $return[$i]['attribs'][strtoupper($attribs[$j][1])]['data'$attribs[$j][count($attribs[$j])-1];
  2637.                     $first substr($attribs[$j][2]01);
  2638.                     $return[$i]['attribs'][strtoupper($attribs[$j][1])]['split'($first == '"' || $first == "'"$first '"';
  2639.                 }
  2640.             }
  2641.         }
  2642.         return $return;
  2643.     }
  2644.  
  2645.     function element_implode($element)
  2646.     {
  2647.         $full "<$element[tag]";
  2648.         foreach ($element['attribs'as $key => $value)
  2649.         {
  2650.             $key strtolower($key);
  2651.             $full .= " $key=$value[split]$value[data]$value[split]";
  2652.         }
  2653.         if ($element['self_closing'])
  2654.         {
  2655.             $full .= ' />';
  2656.         }
  2657.         else
  2658.         {
  2659.             $full .= ">$element[content]</$element[tag]>";
  2660.         }
  2661.         return $full;
  2662.     }
  2663.  
  2664.     function error($message$level$file$line)
  2665.     {
  2666.         switch ($level)
  2667.         {
  2668.             case E_USER_ERROR:
  2669.                 $note 'PHP Error';
  2670.                 break;
  2671.             case E_USER_WARNING:
  2672.                 $note 'PHP Warning';
  2673.                 break;
  2674.             case E_USER_NOTICE:
  2675.                 $note 'PHP Notice';
  2676.                 break;
  2677.             default:
  2678.                 $note 'Unknown Error';
  2679.                 break;
  2680.         }
  2681.         error_log("$note$message in $file on line $line"0);
  2682.         return $message;
  2683.     }
  2684.  
  2685.     function display_file($url$timeout 10$useragent null)
  2686.     {
  2687.         $file new SimplePie_File($url$timeout5array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR'])$useragent);
  2688.         $headers $file->headers();
  2689.         if ($file->body(!== false)
  2690.         {
  2691.             header('Content-type: ' $headers['content-type']);
  2692.             echo $file->body();
  2693.             exit;
  2694.         }
  2695.     }
  2696.  
  2697.     function fix_protocol($url$http 1)
  2698.     {
  2699.         $parsed SimplePie_Misc::parse_url($url);
  2700.         if (!empty($parsed['scheme']&& strtolower($parsed['scheme']!= 'http' && strtolower($parsed['scheme']!= 'https')
  2701.         {
  2702.             return SimplePie_Misc::fix_protocol("$parsed[authority]$parsed[path]$parsed[query]$parsed[fragment]"$http);
  2703.         }
  2704.         if (!file_exists($url&& empty($parsed['scheme']))
  2705.         {
  2706.             return SimplePie_Misc::fix_protocol("http://$url"$http);
  2707.         }
  2708.  
  2709.         if ($http == && !empty($parsed['scheme']))
  2710.         {
  2711.             return "feed:$url";
  2712.         }
  2713.         else if ($http == && strtolower($parsed['scheme']== 'http')
  2714.         {
  2715.             return substr_replace($url'podcast'04);
  2716.         }
  2717.         else
  2718.         {
  2719.             return $url;
  2720.         }
  2721.     }
  2722.  
  2723.     function parse_url($url$parse_match true)
  2724.     {
  2725.         preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/i'$url$match);
  2726.         if (empty($match[0]))
  2727.         {
  2728.             return false;
  2729.         }
  2730.         else
  2731.         {
  2732.             for ($i 6$i 10$i++)
  2733.             {
  2734.                 if (!isset($match[$i]))
  2735.                 {
  2736.                     $match[$i'';
  2737.                 }
  2738.             }
  2739.             if ($parse_match)
  2740.             {
  2741.                 $match array('scheme' => $match[2]'authority' => $match[4]'path' => $match[5]'query' => $match[6]'fragment' => $match[8]);
  2742.             }
  2743.             return $match;
  2744.         }
  2745.     }
  2746.  
  2747.     /**
  2748.      * Replace bad bytes
  2749.      *
  2750.      * PCRE Pattern to locate bad bytes in a UTF-8 string
  2751.      * Comes from W3 FAQ: Multilingual Forms
  2752.      * Note: modified to include full ASCII range including control chars
  2753.      *
  2754.      * Modified by Geoffrey Sneddon 2006-11-19 to remove functionality
  2755.      * to choose what the replace string is, and to use a variable for
  2756.      * the output instead of PHP's output buffer
  2757.      */
  2758.     function utf8_bad_replace($str)
  2759.     {
  2760.         $UTF8_BAD =
  2761.          '([\x00-\x7F]' .                            # ASCII (including control chars)
  2762.          '|[\xC2-\xDF][\x80-\xBF]' .                # non-overlong 2-byte
  2763.          '|\xE0[\xA0-\xBF][\x80-\xBF]' .            # excluding overlongs
  2764.          '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}' .        # straight 3-byte
  2765.          '|\xED[\x80-\x9F][\x80-\xBF]' .            # excluding surrogates
  2766.          '|\xF0[\x90-\xBF][\x80-\xBF]{2}' .            # planes 1-3
  2767.          '|[\xF1-\xF3][\x80-\xBF]{3}' .                # planes 4-15
  2768.          '|\xF4[\x80-\x8F][\x80-\xBF]{2}' .            # plane 16
  2769.          '|(.{1}))';                                # invalid byte
  2770.         $output '';
  2771.         while (preg_match('/' $UTF8_BAD '/S'$str$matches))
  2772.         {
  2773.             if (!isset($matches[2]))
  2774.             {
  2775.                 $output .= $matches[0];
  2776.             }
  2777.             $str substr($strstrlen($matches[0]));
  2778.         }
  2779.         return $output;
  2780.     }
  2781.  
  2782.     function change_encoding($data$input$output)
  2783.     {
  2784.         $input SimplePie_Misc::encoding($input);
  2785.         $output SimplePie_Misc::encoding($output);
  2786.  
  2787.         if ($input != $output)
  2788.         {
  2789.             if (function_exists('iconv'&& $input['use_iconv'&& $output['use_iconv'&& iconv($input['encoding']"$output[encoding]//TRANSLIT"$data))
  2790.             {
  2791.                 return iconv($input['encoding']"$output[encoding]//TRANSLIT"$data);
  2792.             }
  2793.             else if (function_exists('iconv'&& $input['use_iconv'&& $output['use_iconv'&& iconv($input['encoding']$output['encoding']$data))
  2794.             {
  2795.                 return iconv($input['encoding']$output['encoding']$data);
  2796.             }
  2797.             else if (function_exists('mb_convert_encoding'&& $input['use_mbstring'&& $output['use_mbstring'])
  2798.             {
  2799.                 return mb_convert_encoding($data$output['encoding']$input['encoding']);
  2800.             }
  2801.             else if ($input['encoding'== 'ISO-8859-1' && $output['encoding'== 'UTF-8')
  2802.             {
  2803.                 return utf8_encode($data);
  2804.             }
  2805.             else if ($input['encoding'== 'UTF-8' && $output['encoding'== 'ISO-8859-1')
  2806.             {
  2807.                 return utf8_decode($data);
  2808.             }
  2809.         }
  2810.         return $data;
  2811.     }
  2812.  
  2813.     function encoding($encoding)
  2814.     {
  2815.         $return['use_mbstring'false;
  2816.         $return['use_iconv'false;
  2817.         switch (strtolower($encoding))
  2818.         {
  2819.  
  2820.             // 7bit
  2821.             case '7bit':
  2822.             case '7-bit':
  2823.                 $return['encoding''7bit';
  2824.                 $return['use_mbstring'true;
  2825.                 break;
  2826.  
  2827.             // 8bit
  2828.             case '8bit':
  2829.             case '8-bit':
  2830.                 $return['encoding''8bit';
  2831.                 $return['use_mbstring'true;
  2832.                 break;
  2833.  
  2834.             // ARMSCII-8
  2835.             case 'armscii-8':
  2836.             case 'armscii':
  2837.                 $return['encoding''ARMSCII-8';
  2838.                 $return['use_iconv'true;
  2839.                 break;
  2840.  
  2841.             // ASCII
  2842.             case 'us-ascii':
  2843.             case 'ascii':
  2844.                 $return['encoding''US-ASCII';
  2845.                 $return['use_iconv'true;
  2846.                 $return['use_mbstring'true;
  2847.                 break;
  2848.  
  2849.             // BASE64
  2850.             case 'base64':
  2851.             case 'base-64':
  2852.                 $return['encoding''BASE64';
  2853.                 $return['use_mbstring'true;
  2854.                 break;
  2855.  
  2856.             // Big5 - Traditional Chinese, mainly used in Taiwan
  2857.             case 'big5':
  2858.             case '950':
  2859.                 $return['encoding''BIG5';
  2860.                 $return['use_iconv'true;
  2861.                 $return['use_mbstring'true;
  2862.                 break;
  2863.  
  2864.             // Big5 with Hong Kong extensions, Traditional Chinese
  2865.             case 'big5-hkscs':
  2866.                 $return['encoding''BIG5-HKSCS';
  2867.                 $return['use_iconv'true;
  2868.                 $return['use_mbstring'true;
  2869.                 break;
  2870.  
  2871.             // byte2be
  2872.             case 'byte2be':
  2873.                 $return['encoding''byte2be';
  2874.                 $return['use_mbstring'true;
  2875.                 break;
  2876.  
  2877.             // byte2le
  2878.             case 'byte2le':
  2879.                 $return['encoding''byte2le';
  2880.                 $return['use_mbstring'true;
  2881.                 break;
  2882.  
  2883.             // byte4be
  2884.             case 'byte4be':
  2885.                 $return['encoding''byte4be';
  2886.                 $return['use_mbstring'true;
  2887.                 break;
  2888.  
  2889.             // byte4le
  2890.             case 'byte4le':
  2891.                 $return['encoding''byte4le';
  2892.                 $return['use_mbstring'true;
  2893.                 break;
  2894.  
  2895.             // EUC-CN
  2896.             case 'euc-cn':
  2897.             case 'euccn':
  2898.                 $return['encoding''EUC-CN';
  2899.                 $return['use_iconv'true;
  2900.                 $return['use_mbstring'true;
  2901.                 break;
  2902.  
  2903.             // EUC-JISX0213
  2904.             case 'euc-jisx0213':
  2905.             case 'eucjisx0213':
  2906.                 $return['encoding''EUC-JISX0213';
  2907.                 $return['use_iconv'true;
  2908.                 break;
  2909.  
  2910.             // EUC-JP
  2911.             case 'euc-jp':
  2912.             case 'eucjp':
  2913.                 $return['encoding''EUC-JP';
  2914.                 $return['use_iconv'true;
  2915.                 $return['use_mbstring'true;
  2916.                 break;
  2917.  
  2918.             // EUCJP-win
  2919.             case 'euc-jp-win':
  2920.             case 'eucjp-win':
  2921.             case 'eucjpwin':
  2922.                 $return['encoding''EUCJP-win';
  2923.                 $return['use_iconv'true;
  2924.                 $return['use_mbstring'true;
  2925.                 break;
  2926.  
  2927.             // EUC-KR
  2928.             case 'euc-kr':
  2929.             case 'euckr':
  2930.                 $return['encoding''EUC-KR';
  2931.                 $return['use_iconv'true;
  2932.                 $return['use_mbstring'true;
  2933.                 break;
  2934.  
  2935.             // EUC-TW
  2936.             case 'euc-tw':
  2937.             case 'euctw':
  2938.                 $return['encoding''EUC-TW';
  2939.                 $return['use_iconv'true;
  2940.                 $return['use_mbstring'true;
  2941.                 break;
  2942.  
  2943.             // GB18030 - Simplified Chinese, national standard character set
  2944.             case 'gb18030-2000':
  2945.             case 'gb18030':
  2946.                 $return['encoding''GB18030';
  2947.                 $return['use_iconv'true;
  2948.                 break;
  2949.  
  2950.             // GB2312 - Simplified Chinese, national standard character set
  2951.             case 'gb2312':
  2952.             case '936':
  2953.                 $return['encoding''GB2312';
  2954.                 $return['use_mbstring'true;
  2955.                 break;
  2956.  
  2957.             // GBK
  2958.             case 'gbk':
  2959.                 $return['encoding''GBK';
  2960.                 $return['use_iconv'true;
  2961.                 break;
  2962.  
  2963.             // Georgian-Academy
  2964.             case 'georgian-academy':
  2965.                 $return['encoding''Georgian-Academy';
  2966.                 $return['use_iconv'true;
  2967.                 break;
  2968.  
  2969.             // Georgian-PS
  2970.             case 'georgian-ps':
  2971.                 $return['encoding''Georgian-PS';
  2972.                 $return['use_iconv'true;
  2973.                 break;
  2974.  
  2975.             // HTML-ENTITIES
  2976.             case 'html-entities':
  2977.             case 'htmlentities':
  2978.                 $return['encoding''HTML-ENTITIES';
  2979.                 $return['use_mbstring'true;
  2980.                 break;
  2981.  
  2982.             // HZ
  2983.             case 'hz':
  2984.                 $return['encoding''HZ';
  2985.                 $return['use_iconv'true;
  2986.                 $return['use_mbstring'true;
  2987.                 break;
  2988.  
  2989.             // ISO-2022-CN
  2990.             case 'iso-2022-cn':
  2991.             case 'iso2022-cn':
  2992.             case 'iso2022cn':
  2993.                 $return['encoding''ISO-2022-CN';
  2994.                 $return['use_iconv'true;
  2995.                 break;
  2996.  
  2997.             // ISO-2022-CN-EXT
  2998.             case 'iso-2022-cn-ext':
  2999.             case 'iso2022-cn-ext':
  3000.             case 'iso2022cn-ext':
  3001.             case 'iso2022cnext':
  3002.                 $return['encoding''ISO-2022-CN';
  3003.                 $return['use_iconv'true;
  3004.                 break;
  3005.  
  3006.             // ISO-2022-JP
  3007.             case 'iso-2022-jp':
  3008.             case 'iso2022-jp':
  3009.             case 'iso2022jp':
  3010.                 $return['encoding''ISO-2022-JP';
  3011.                 $return['use_iconv'true;
  3012.                 $return['use_mbstring'true;
  3013.                 break;
  3014.  
  3015.             // ISO-2022-JP-1
  3016.             case 'iso-2022-jp-1':
  3017.             case 'iso2022-jp-1':
  3018.             case 'iso2022jp-1':
  3019.             case 'iso2022jp1':
  3020.                 $return['encoding''ISO-2022-JP-1';
  3021.                 $return['use_iconv'true;
  3022.                 break;
  3023.  
  3024.             // ISO-2022-JP-2
  3025.             case 'iso-2022-jp-2':
  3026.             case 'iso2022-jp-2':
  3027.             case 'iso2022jp-2':
  3028.             case 'iso2022jp2':
  3029.                 $return['encoding''ISO-2022-JP-2';
  3030.                 $return['use_iconv'true;
  3031.                 break;
  3032.  
  3033.             // ISO-2022-JP-3
  3034.             case 'iso-2022-jp-3':
  3035.             case 'iso2022-jp-3':
  3036.             case 'iso2022jp-3':
  3037.             case 'iso2022jp3':
  3038.                 $return['encoding''ISO-2022-JP-3';
  3039.                 $return['use_iconv'true;
  3040.                 break;
  3041.  
  3042.             // ISO-2022-KR
  3043.             case 'iso-2022-kr':
  3044.             case 'iso2022-kr':
  3045.             case 'iso2022kr':
  3046.                 $return['encoding''ISO-2022-KR';
  3047.                 $return['use_iconv'true;
  3048.                 $return['use_mbstring'true;
  3049.                 break;
  3050.  
  3051.             // ISO-8859-1
  3052.             case 'iso-8859-1':
  3053.             case 'iso8859-1':
  3054.                 $return['encoding''ISO-8859-1';
  3055.                 $return['use_iconv'true;
  3056.                 $return['use_mbstring'true;
  3057.                 break;
  3058.  
  3059.             // ISO-8859-2
  3060.             case 'iso-8859-2':
  3061.             case 'iso8859-2':
  3062.                 $return['encoding''ISO-8859-2';
  3063.                 $return['use_iconv'true;
  3064.                 $return['use_mbstring'true;
  3065.                 break;
  3066.  
  3067.             // ISO-8859-3
  3068.             case 'iso-8859-3':
  3069.             case 'iso8859-3':
  3070.                 $return['encoding''ISO-8859-3';
  3071.                 $return['use_iconv'true;
  3072.                 $return['use_mbstring'true;
  3073.                 break;
  3074.  
  3075.             // ISO-8859-4
  3076.             case 'iso-8859-4':
  3077.             case 'iso8859-4':
  3078.                 $return['encoding''ISO-8859-4';
  3079.                 $return['use_iconv'true;
  3080.                 $return['use_mbstring'true;
  3081.                 break;
  3082.  
  3083.             // ISO-8859-5
  3084.             case 'iso-8859-5':
  3085.             case 'iso8859-5':
  3086.                 $return['encoding''ISO-8859-5';
  3087.                 $return['use_iconv'true;
  3088.                 $return['use_mbstring'true;
  3089.                 break;
  3090.  
  3091.             // ISO-8859-6
  3092.             case 'iso-8859-6':
  3093.             case 'iso8859-6':
  3094.                 $return['encoding''ISO-8859-6';
  3095.                 $return['use_iconv'true;
  3096.                 $return['use_mbstring'true;
  3097.                 break;
  3098.  
  3099.             // ISO-8859-7
  3100.             case 'iso-8859-7':
  3101.             case 'iso8859-7':
  3102.                 $return['encoding''ISO-8859-7';
  3103.                 $return['use_iconv'true;
  3104.                 $return['use_mbstring'true;
  3105.                 break;
  3106.  
  3107.             // ISO-8859-8
  3108.             case 'iso-8859-8':
  3109.             case 'iso8859-8':
  3110.                 $return['encoding''ISO-8859-8';
  3111.                 $return['use_iconv'true;
  3112.                 $return['use_mbstring'true;
  3113.                 break;
  3114.  
  3115.             // ISO-8859-9
  3116.             case 'iso-8859-9':
  3117.             case 'iso8859-9':
  3118.                 $return['encoding''ISO-8859-9';
  3119.                 $return['use_iconv'true;
  3120.                 $return['use_mbstring'true;
  3121.                 break;
  3122.  
  3123.             // ISO-8859-10
  3124.             case 'iso-8859-10':
  3125.             case 'iso8859-10':
  3126.                 $return['encoding''ISO-8859-10';
  3127.                 $return['use_iconv'true;
  3128.                 $return['use_mbstring'true;
  3129.                 break;
  3130.  
  3131.             // mbstring/iconv functions don't appear to support 11 & 12
  3132.  
  3133.             // ISO-8859-13
  3134.             case 'iso-8859-13':
  3135.             case 'iso8859-13':
  3136.                 $return['encoding''ISO-8859-13';
  3137.                 $return['use_iconv'true;
  3138.                 $return['use_mbstring'true;
  3139.                 break;
  3140.  
  3141.             // ISO-8859-14
  3142.             case 'iso-8859-14':
  3143.             case 'iso8859-14':
  3144.                 $return['encoding''ISO-8859-14';
  3145.                 $return['use_iconv'true;
  3146.                 $return['use_mbstring'true;
  3147.                 break;
  3148.  
  3149.             // ISO-8859-15
  3150.             case 'iso-8859-15':
  3151.             case 'iso8859-15':
  3152.                 $return['encoding''ISO-8859-15';
  3153.                 $return['use_iconv'true;
  3154.                 $return['use_mbstring'true;
  3155.                 break;
  3156.  
  3157.             // ISO-8859-16
  3158.             case 'iso-8859-16':
  3159.             case 'iso8859-16':
  3160.                 $return['encoding''ISO-8859-16';
  3161.                 $return['use_iconv'true;
  3162.                 break;
  3163.  
  3164.             // JIS
  3165.             case 'jis':
  3166.                 $return['encoding''JIS';
  3167.                 $return['use_mbstring'true;
  3168.                 break;
  3169.  
  3170.             // JOHAB - Korean
  3171.             case 'johab':
  3172.                 $return['encoding''JOHAB';
  3173.                 $return['use_iconv'true;
  3174.                 break;
  3175.  
  3176.             // Russian
  3177.             case 'koi8-r':
  3178.             case 'koi8r':
  3179.                 $return['encoding''KOI8-R';
  3180.                 $return['use_iconv'true;
  3181.                 $return['use_mbstring'true;
  3182.                 break;
  3183.  
  3184.             // Turkish
  3185.             case 'koi8-t':
  3186.             case 'koi8t':
  3187.                 $return['encoding''KOI8-T';
  3188.                 $return['use_iconv'true;
  3189.                 break;
  3190.  
  3191.             // Ukrainian
  3192.             case 'koi8-u':
  3193.             case 'koi8u':
  3194.                 $return['encoding''KOI8-U';
  3195.                 $return['use_iconv'true;
  3196.                 break;
  3197.  
  3198.             // Russian+Ukrainian
  3199.             case 'koi8-ru':
  3200.             case 'koi8ru':
  3201.                 $return['encoding''KOI8-RU';
  3202.                 $return['use_iconv'true;
  3203.                 break;
  3204.  
  3205.             // Macintosh (Mac OS Classic)
  3206.             case 'macintosh':
  3207.                 $return['encoding''Macintosh';
  3208.                 $return['use_iconv'true;
  3209.                 break;
  3210.  
  3211.             // MacArabic (Mac OS Classic)
  3212.             case 'macarabic':
  3213.                 $return['encoding''MacArabic';
  3214.                 $return['use_iconv'true;
  3215.                 break;
  3216.  
  3217.             // MacCentralEurope (Mac OS Classic)
  3218.             case 'maccentraleurope':
  3219.                 $return['encoding''MacCentralEurope';
  3220.                 $return['use_iconv'true;
  3221.                 break;
  3222.  
  3223.             // MacCroatian (Mac OS Classic)
  3224.             case 'maccroatian':
  3225.                 $return['encoding''MacCroatian';
  3226.                 $return['use_iconv'true;
  3227.                 break;
  3228.  
  3229.             // MacCyrillic (Mac OS Classic)
  3230.             case 'maccyrillic':
  3231.                 $return['encoding''MacCyrillic';
  3232.                 $return['use_iconv'true;
  3233.                 break;
  3234.  
  3235.             // MacGreek (Mac OS Classic)
  3236.             case 'macgreek':
  3237.                 $return['encoding''MacGreek';
  3238.                 $return['use_iconv'true;
  3239.                 break;
  3240.  
  3241.             // MacHebrew (Mac OS Classic)
  3242.             case 'machebrew':
  3243.                 $return['encoding''MacHebrew';
  3244.                 $return['use_iconv'true;
  3245.                 break;
  3246.  
  3247.             // MacIceland (Mac OS Classic)
  3248.             case 'maciceland':
  3249.                 $return['encoding''MacIceland';
  3250.                 $return['use_iconv'true;
  3251.                 break;
  3252.  
  3253.             // MacRoman (Mac OS Classic)
  3254.             case 'macroman':
  3255.                 $return['encoding''MacRoman';
  3256.                 $return['use_iconv'true;
  3257.                 break;
  3258.  
  3259.             // MacRomania (Mac OS Classic)
  3260.             case 'macromania':
  3261.                 $return['encoding''MacRomania';
  3262.                 $return['use_iconv'true;
  3263.                 break;
  3264.  
  3265.             // MacThai (Mac OS Classic)
  3266.             case 'macthai':
  3267.                 $return['encoding''MacThai';
  3268.                 $return['use_iconv'true;
  3269.                 break;
  3270.  
  3271.             // MacTurkish (Mac OS Classic)
  3272.             case 'macturkish':
  3273.                 $return['encoding''MacTurkish';
  3274.                 $return['use_iconv'true;
  3275.                 break;
  3276.  
  3277.             // MacUkraine (Mac OS Classic)
  3278.             case 'macukraine':
  3279.                 $return['encoding''MacUkraine';
  3280.                 $return['use_iconv'true;
  3281.                 break;
  3282.  
  3283.             // MuleLao-1
  3284.             case 'mulelao-1':
  3285.             case 'mulelao1':
  3286.                 $return['encoding''MuleLao-1';
  3287.                 $return['use_iconv'true;
  3288.                 break;
  3289.  
  3290.             // Shift_JIS
  3291.             case 'shift_jis':
  3292.             case 'sjis':
  3293.             case '932':
  3294.                 $return['encoding''Shift_JIS';
  3295.                 $return['use_iconv'true;
  3296.                 $return['use_mbstring'true;
  3297.                 break;
  3298.  
  3299.             // Shift_JISX0213
  3300.             case 'shift-jisx0213':
  3301.             case 'shiftjisx0213':
  3302.                 $return['encoding''Shift_JISX0213';
  3303.                 $return['use_iconv'true;
  3304.                 break;
  3305.  
  3306.             // SJIS-win
  3307.             case 'sjis-win':
  3308.             case 'sjiswin':
  3309.             case 'shift_jis-win':
  3310.                 $return['encoding''SJIS-win';
  3311.                 $return['use_iconv'true;
  3312.                 $return['use_mbstring'true;
  3313.                 break;
  3314.  
  3315.             // TCVN - Vietnamese
  3316.             case 'tcvn':
  3317.                 $return['encoding''TCVN';
  3318.                 $return['use_iconv'true;
  3319.                 break;
  3320.  
  3321.             // TDS565 - Turkish
  3322.             case 'tds565':
  3323.                 $return['encoding''TDS565';
  3324.                 $return['use_iconv'true;
  3325.                 break;
  3326.  
  3327.             // TIS-620 Thai
  3328.             case 'tis-620':
  3329.             case 'tis620':
  3330.                 $return['encoding''TIS-620';
  3331.                 $return['use_iconv'true;
  3332.                 $return['use_mbstring'true;
  3333.                 break;
  3334.  
  3335.             // UCS-2
  3336.             case 'ucs-2':
  3337.             case 'ucs2':
  3338.             case 'utf-16':
  3339.             case 'utf16':
  3340.                 $return['encoding''UCS-2';
  3341.                 $return['use_iconv'true;
  3342.                 $return['use_mbstring'true;
  3343.                 break;
  3344.  
  3345.             // UCS-2BE
  3346.             case 'ucs-2be':
  3347.             case 'ucs2be':
  3348.             case 'utf-16be':
  3349.             case 'utf16be':
  3350.                 $return['encoding''UCS-2BE';
  3351.                 $return['use_iconv'true;
  3352.                 $return['use_mbstring'true;
  3353.                 break;
  3354.  
  3355.             // UCS-2LE
  3356.             case 'ucs-2le':
  3357.             case 'ucs2le':
  3358.             case 'utf-16le':
  3359.             case 'utf16le':
  3360.                 $return['encoding''UCS-2LE';
  3361.                 $return['use_iconv'true;
  3362.                 $return['use_mbstring'true;
  3363.                 break;
  3364.  
  3365.             // UCS-2-INTERNAL
  3366.             case 'ucs-2-internal':
  3367.             case 'ucs2internal':
  3368.                 $return['encoding''UCS-2-INTERNAL';
  3369.                 $return['use_iconv'true;
  3370.                 break;
  3371.  
  3372.             // UCS-4
  3373.             case 'ucs-4':
  3374.             case 'ucs4':
  3375.             case 'utf-32':
  3376.             case 'utf32':
  3377.                 $return['encoding''UCS-4';
  3378.                 $return['use_iconv'true;
  3379.                 $return['use_mbstring'true;
  3380.                 break;
  3381.  
  3382.             // UCS-4BE
  3383.             case 'ucs-4be':
  3384.             case 'ucs4be':
  3385.             case 'utf-32be':
  3386.             case 'utf32be':
  3387.                 $return['encoding''UCS-4BE';
  3388.                 $return['use_iconv'true;
  3389.                 $return['use_mbstring'true;
  3390.                 break;
  3391.  
  3392.             // UCS-4LE
  3393.             case 'ucs-4le':
  3394.             case 'ucs4le':
  3395.             case 'utf-32le':
  3396.             case 'utf32le':
  3397.                 $return['encoding''UCS-4LE';
  3398.                 $return['use_iconv'true;
  3399.                 $return['use_mbstring'true;
  3400.                 break;
  3401.  
  3402.             // UCS-4-INTERNAL
  3403.             case 'ucs-4-internal':
  3404.             case 'ucs4internal':
  3405.                 $return['encoding''UCS-4-INTERNAL';
  3406.                 $return['use_iconv'true;
  3407.                 break;
  3408.  
  3409.             // UCS-16
  3410.             case 'ucs-16':
  3411.             case 'ucs16':
  3412.                 $return['encoding''UCS-16';
  3413.                 $return['use_iconv'true;
  3414.                 $return['use_mbstring'true;
  3415.                 break;
  3416.  
  3417.             // UCS-16BE
  3418.             case 'ucs-16be':
  3419.             case 'ucs16be':
  3420.                 $return['encoding''UCS-16BE';
  3421.                 $return['use_iconv'true;
  3422.                 $return['use_mbstring'true;
  3423.                 break;
  3424.  
  3425.             // UCS-16LE
  3426.             case 'ucs-16le':
  3427.             case 'ucs16le':
  3428.                 $return['encoding''UCS-16LE';
  3429.                 $return['use_iconv'true;
  3430.                 $return['use_mbstring'true;
  3431.                 break;
  3432.  
  3433.             // UCS-32
  3434.             case 'ucs-32':
  3435.             case 'ucs32':
  3436.                 $return['encoding''UCS-32';
  3437.                 $return['use_iconv'true;
  3438.                 $return['use_mbstring'true;
  3439.                 break;
  3440.  
  3441.             // UCS-32BE
  3442.             case 'ucs-32be':
  3443.             case 'ucs32be':
  3444.                 $return['encoding''UCS-32BE';
  3445.                 $return['use_iconv'true;
  3446.                 $return['use_mbstring'true;
  3447.                 break;
  3448.  
  3449.             // UCS-32LE
  3450.             case 'ucs-32le':
  3451.             case 'ucs32le':
  3452.                 $return['encoding''UCS-32LE';
  3453.                 $return['use_iconv'true;
  3454.                 $return['use_mbstring'true;
  3455.                 break;
  3456.  
  3457.             // UTF-7
  3458.             case 'utf-7':
  3459.             case 'utf7':
  3460.                 $return['encoding''UTF-7';
  3461.                 $return['use_iconv'true;
  3462.                 $return['use_mbstring'true;
  3463.                 break;
  3464.  
  3465.             // UTF7-IMAP
  3466.             case 'utf-7-imap':
  3467.             case 'utf7-imap':
  3468.             case 'utf7imap':
  3469.                 $return['encoding''UTF7-IMAP';
  3470.                 $return['use_mbstring'true;
  3471.                 break;
  3472.  
  3473.             // VISCII - Vietnamese ASCII
  3474.             case 'viscii':
  3475.                 $return['encoding''VISCII';
  3476.                 $return['use_iconv'true;
  3477.                 break;
  3478.  
  3479.             // Windows-specific Central & Eastern Europe
  3480.             case 'cp1250':
  3481.             case 'windows-1250':
  3482.             case 'win-1250':
  3483.             case '1250':
  3484.                 $return['encoding''Windows-1250';
  3485.                 $return['use_iconv'true;
  3486.                 break;
  3487.  
  3488.             // Windows-specific Cyrillic
  3489.             case 'cp1251':
  3490.             case 'windows-1251':
  3491.             case 'win-1251':
  3492.             case '1251':
  3493.                 $return['encoding''Windows-1251';
  3494.                 $return['use_iconv'true;
  3495.                 $return['use_mbstring'true;
  3496.                 break;
  3497.  
  3498.             // Windows-specific Western Europe
  3499.             case 'cp1252':
  3500.             case 'windows-1252':
  3501.             case '1252':
  3502.                 $return['encoding''Windows-1252';
  3503.                 $return['use_iconv'true;
  3504.                 $return['use_mbstring'true;
  3505.                 break;
  3506.  
  3507.             // Windows-specific Greek
  3508.             case 'cp1253':
  3509.             case 'windows-1253':
  3510.             case '1253':
  3511.                 $return['encoding''Windows-1253';
  3512.                 $return['use_iconv'true;
  3513.                 break;
  3514.  
  3515.             // Windows-specific Turkish
  3516.             case 'cp1254':
  3517.             case 'windows-1254':
  3518.             case '1254':
  3519.                 $return['encoding''Windows-1254';
  3520.                 $return['use_iconv'true;
  3521.                 break;
  3522.  
  3523.             // Windows-specific Hebrew
  3524.             case 'cp1255':
  3525.             case 'windows-1255':
  3526.             case '1255':
  3527.                 $return['encoding''Windows-1255';
  3528.                 $return['use_iconv'true;
  3529.                 break;
  3530.  
  3531.             // Windows-specific Arabic
  3532.             case 'cp1256':
  3533.             case 'windows-1256':
  3534.             case '1256':
  3535.                 $return['encoding''Windows-1256';
  3536.                 $return['use_iconv'true;
  3537.                 break;
  3538.  
  3539.             // Windows-specific Baltic
  3540.             case 'cp1257':
  3541.             case 'windows-1257':
  3542.             case '1257':
  3543.                 $return['encoding''Windows-1257';
  3544.                 $return['use_iconv'true;
  3545.                 break;
  3546.  
  3547.             // Windows-specific Vietnamese
  3548.             case 'cp1258':
  3549.             case 'windows-1258':
  3550.             case '1258':
  3551.                 $return['encoding''Windows-1258';
  3552.                 $return['use_iconv'true;
  3553.                 break;
  3554.  
  3555.             // Default to UTF-8
  3556.             default:
  3557.                 $return['encoding''UTF-8';
  3558.                 $return['use_iconv'true;
  3559.                 $return['use_mbstring'true;
  3560.                 break;
  3561.         }
  3562.  
  3563.         // Then, return it.
  3564.         return $return;
  3565.     }
  3566.  
  3567.     function get_curl_version()
  3568.     {
  3569.         $curl 0;
  3570.         if (is_array(curl_version()))
  3571.         {
  3572.             $curl curl_version();
  3573.             $curl $curl['version'];
  3574.         }
  3575.         else
  3576.         {
  3577.             $curl curl_version();
  3578.             $curl explode(' '$curl);
  3579.             $curl explode('/'$curl[0]);
  3580.             $curl $curl[1];
  3581.         }
  3582.         return $curl;
  3583.     }
  3584.  
  3585.     function is_a_class($class1$class2)
  3586.     {
  3587.         if (class_exists($class1))
  3588.         {
  3589.             $classes array(strtolower($class1));
  3590.             while ($class1 get_parent_class($class1))
  3591.             {
  3592.                 $classes[strtolower($class1);
  3593.             }
  3594.             return in_array(strtolower($class2)$classes);
  3595.         }
  3596.         else
  3597.         {
  3598.             return false;
  3599.         }
  3600.     }
  3601. }
  3602.  
  3603. {
  3604.     var $useragent;
  3605.     var $timeout;
  3606.     var $file;
  3607.     var $local;
  3608.     var $elsewhere;
  3609.     var $file_class = 'SimplePie_File';
  3610.  
  3611.     function SimplePie_Locator(&$file$timeout 10$useragent null$file_class 'SimplePie_File')
  3612.     {
  3613.         if (!is_a($file'SimplePie_File'))
  3614.         {
  3615.             $this->file = new $this->file_class($file$timeout$useragent);
  3616.         }
  3617.         else
  3618.         {
  3619.             $this->file =$file;
  3620.         }
  3621.         $this->file_class = $file_class;
  3622.         $this->useragent = $useragent;
  3623.         $this->timeout = $timeout;
  3624.     }
  3625.  
  3626.  
  3627.     function find()
  3628.     {
  3629.         if ($this->is_feed($this->file))
  3630.         {
  3631.             return $this->file->url;
  3632.         }
  3633.  
  3634.         $autodiscovery $this->autodiscovery($this->file);
  3635.         if ($autodiscovery)
  3636.         {
  3637.             return $autodiscovery;
  3638.         }
  3639.  
  3640.         if ($this->get_links($this->file))
  3641.         {
  3642.             if (!empty($this->local))
  3643.             {
  3644.                 $extension_local $this->extension($this->local);
  3645.                 if ($extension_local)
  3646.                 {
  3647.                     return $extension_local;
  3648.                 }
  3649.  
  3650.                 $body_local $this->body($this->local);
  3651.                 if ($body_local)
  3652.                 {
  3653.                     return $body_local;
  3654.                 }
  3655.             }
  3656.  
  3657.             if (!empty($this->elsewhere))
  3658.             {
  3659.                 $extension_elsewhere $this->extension($this->elsewhere);
  3660.                 if ($extension_elsewhere)
  3661.                 {
  3662.                     return $extension_elsewhere;
  3663.                 }
  3664.  
  3665.                 $body_elsewhere $this->body($this->elsewhere);
  3666.                 if ($body_elsewhere)
  3667.                 {
  3668.                     return $body_elsewhere;
  3669.                 }
  3670.             }
  3671.         }
  3672.         return false;
  3673.     }
  3674.  
  3675.     function is_feed(&$file)
  3676.     {
  3677.         if (!is_a($file'SimplePie_File'))
  3678.         {
  3679.             if (isset($this))
  3680.             {
  3681.                 $file2 new $this->file_class($file$this->timeout5null$this->useragent);
  3682.             }
  3683.             else
  3684.             {
  3685.                 $file2 new $this->file_class($file);
  3686.             }
  3687.             $file2->body();
  3688.             $file2->close();
  3689.         }
  3690.         else
  3691.         {
  3692.             $file2 =$file;
  3693.         }
  3694.         $body preg_replace('/<\!-(.*)-\>/msiU'''$file2->body());
  3695.         if (preg_match('/<(\w+\:)?rss/msiU'$body|| preg_match('/<(\w+\:)?RDF/mi'$body|| preg_match('/<(\w+\:)?feed/mi'$body))
  3696.         {
  3697.             return true;
  3698.         }
  3699.         return false;
  3700.     }
  3701.  
  3702.     function autodiscovery(&$file)
  3703.     {
  3704.         $links SimplePie_Misc::get_element('link'$file->body());
  3705.         $done array();
  3706.         foreach ($links as $link)
  3707.         {
  3708.             if (!empty($link['attribs']['TYPE']['data']&& !empty($link['attribs']['HREF']['data']&& !empty($link['attribs']['REL']['data']))
  3709.             {
  3710.                 $rel preg_split('/\s+/'strtolower(trim($link['attribs']['REL']['data'])));
  3711.                 $type preg_match('/^(application\/rss\+xml|application\/atom\+xml|application\/rdf\+xml|application\/xml\+rss|application\/xml\+atom|application\/xml\+rdf|application\/xml|application\/x\.atom\+xml|text\/xml)(;|$)/msiU'trim($link['attribs']['TYPE']['data']));
  3712.                 $href SimplePie_Misc::absolutize_url(trim($link['attribs']['HREF']['data'])$this->file->url);
  3713.                 if (!in_array($href$done&& in_array('alternate'$rel&& $type)
  3714.                 {
  3715.                     $feed $this->is_feed($href);
  3716.                     if ($feed)
  3717.                     {
  3718.                         return $href;
  3719.                     }
  3720.                 }
  3721.                 $done[$href;
  3722.             }
  3723.         }
  3724.         return false;
  3725.     }
  3726.  
  3727.     function get_links(&$file)
  3728.     {
  3729.         $links SimplePie_Misc::get_element('a'$file->body());
  3730.         foreach ($links as $link)
  3731.         {
  3732.             if (!empty($link['attribs']['HREF']['data']))
  3733.             {
  3734.                 $href trim($link['attribs']['HREF']['data']);
  3735.                 $parsed SimplePie_Misc::parse_url($href);
  3736.                 if (empty($parsed['scheme']|| $parsed['scheme'!= 'javascript')
  3737.                 {
  3738.                     $current SimplePie_Misc::parse_url($this->file->url);
  3739.                     if (empty($parsed['authority']|| $parsed['authority'== $current['authority'])
  3740.                     {
  3741.                         $this->local[SimplePie_Misc::absolutize_url($href$this->file->url);
  3742.                     }
  3743.                     else
  3744.                     {
  3745.                         $this->elsewhere[SimplePie_Misc::absolutize_url($href$this->file->url);
  3746.                     }
  3747.                 }
  3748.             }
  3749.         }
  3750.         if (!empty($this->local))
  3751.         {
  3752.             $this->local = array_unique($this->local);
  3753.         }
  3754.         if (!empty($this->elsewhere))
  3755.         {
  3756.             $this->elsewhere = array_unique($this->elsewhere);
  3757.         }
  3758.         if (!empty($this->local|| !empty($this->elsewhere))
  3759.         {
  3760.             return true;
  3761.         }
  3762.         return false;
  3763.     }
  3764.  
  3765.     function extension(&$array)
  3766.     {
  3767.         foreach ($array as $key => $value)
  3768.         {
  3769.             $value SimplePie_Misc::absolutize_url($value$this->file->url);
  3770.             if (in_array(strrchr($value'.')array('.rss''.rdf''.atom''.xml')))
  3771.             {
  3772.                 if ($this->is_feed($value))
  3773.                 {
  3774.                     return $value;
  3775.                 }
  3776.                 else
  3777.                 {
  3778.                     unset($array[$key]);
  3779.                 }
  3780.             }
  3781.         }
  3782.         return false;
  3783.     }
  3784.  
  3785.     function body(&$array)
  3786.     {
  3787.         foreach ($array as $key => $value)
  3788.         {
  3789.             $value SimplePie_Misc::absolutize_url($value$this->file->url);
  3790.             if (preg_match('/(rss|rdf|atom|xml)/i'$value))
  3791.             {
  3792.                 if ($this->is_feed($value))
  3793.                 {
  3794.                     return $value;
  3795.                 }
  3796.                 else
  3797.                 {
  3798.                     unset($array[$key]);
  3799.                 }
  3800.             }
  3801.         }
  3802.         return false;
  3803.     }
  3804. }
  3805.  
  3806. {
  3807.     var $encoding;
  3808.     var $data;
  3809.     var $namespaces = array('xml' => 'HTTP://WWW.W3.ORG/XML/1998/NAMESPACE''atom' => 'ATOM''rss2' => 'RSS''rdf' => 'RDF''rss1' => 'RSS''dc' => 'DC''xhtml' => 'XHTML''content' => 'CONTENT');
  3810.     var $xml;
  3811.     var $error_code;
  3812.     var $error_string;
  3813.     var $current_line;
  3814.     var $current_column;
  3815.     var $current_byte;
  3816.     var $tag_name;
  3817.     var $inside_item;
  3818.     var $item_number = 0;
  3819.     var $inside_channel;
  3820.     var $author_number0;
  3821.     var $category_number = 0;
  3822.     var $enclosure_number = 0;
  3823.     var $link_number = 0;
  3824.     var $item_link_number = 0;
  3825.     var $inside_image;
  3826.     var $attribs;
  3827.     var $is_first;
  3828.     var $inside_author;
  3829.     var $depth_inside_item = 0;
  3830.  
  3831.     function SimplePie_Parser($data$encoding$return_xml false)
  3832.     {
  3833.         $this->encoding = $encoding;
  3834.  
  3835.         // Strip BOM:
  3836.         // UTF-32 Big Endian BOM
  3837.         if (strpos($datasprintf('%c%c%c%c'0x000x000xFE0xFF)) === 0)
  3838.         {
  3839.             $data substr($data4);
  3840.         }
  3841.         // UTF-32 Little Endian BOM
  3842.         else if (strpos($datasprintf('%c%c%c%c'0xFF0xFE0x000x00)) === 0)
  3843.         {
  3844.             $data substr($data4);
  3845.         }
  3846.         // UTF-16 Big Endian BOM
  3847.         else if (strpos($datasprintf('%c%c'0xFE0xFF)) === 0)
  3848.         {
  3849.             $data substr($data2);
  3850.         }
  3851.         // UTF-16 Little Endian BOM
  3852.         else if (strpos($datasprintf('%c%c'0xFF0xFE)) === 0)
  3853.         {
  3854.             $data substr($data2);
  3855.         }
  3856.         // UTF-8 BOM
  3857.         else if (strpos($datasprintf('%c%c%c'0xEF0xBB0xBF)) === 0)
  3858.         {
  3859.             $data substr($data3);
  3860.         }
  3861.  
  3862.         // Make sure the XML prolog is sane and has the correct encoding
  3863.         if (preg_match('/^<\?xml(.*)?>/msiU'$data$prolog))
  3864.         {
  3865.             $data substr_replace($data''0strlen($prolog[0]));
  3866.         }
  3867.         $data "<?xml version='1.0' encoding='$encoding'?>\n$data;
  3868.  
  3869.         // Put some data into CDATA blocks
  3870.         // If we're RSS
  3871.         if ((stristr($data'<rss'|| preg_match('/<([a-z0-9]+\:)?RDF/mi'$data)) && (preg_match('/<([a-z0-9]+\:)?channel/mi'$data|| preg_match('/<([a-z0-9]+\:)?item/mi'$data)))
  3872.         {
  3873.             $sp_elements array(
  3874.                 'author',
  3875.                 'category',
  3876.                 'copyright',
  3877.                 'description',
  3878.                 'docs',
  3879.                 'generator',
  3880.                 'guid',
  3881.                 'language',
  3882.                 'lastBuildDate',
  3883.                 'link',
  3884.                 'managingEditor',
  3885.                 'pubDate',
  3886.                 'title',
  3887.                 'url',
  3888.                 'webMaster',
  3889.             );
  3890.         }
  3891.         // Or if we're Atom
  3892.         else
  3893.         {
  3894.             $sp_elements array(
  3895.                 'content',
  3896.                 'copyright',
  3897.                 'name',
  3898.                 'subtitle',
  3899.                 'summary',
  3900.                 'tagline',
  3901.                 'title',
  3902.             );
  3903.         }
  3904.         foreach ($sp_elements as $full)
  3905.         {
  3906.             $data preg_replace_callback("/<($full)((\s*((\w+:)?\w+)\s*=\s*(\"([^\"]*)\"|'([^']*)'))*)\s*(\/>|>(.*)<\/$full>)/msiU"array(&$this'add_cdata')$data);
  3907.         }
  3908.         foreach ($sp_elements as $full)
  3909.         {
  3910.             // Deal with CDATA within CDATA (this can be caused by us inserting CDATA above)
  3911.             $data preg_replace_callback("/<($full)((\s*((\w+:)?\w+)\s*=\s*(\"([^\"]*)\"|'([^']*)'))*)\s*(\/>|><!\[CDATA\[(.*)\]\]><\/$full>)/msiU"array(&$this'cdata_in_cdata')$data);
  3912.         }
  3913.  
  3914.         // Return the XML, if so desired
  3915.         if ($return_xml)
  3916.         {
  3917.             $this->data =$data;
  3918.             return;
  3919.         }
  3920.  
  3921.         // Create the parser
  3922.         $this->xml = xml_parser_create_ns($encoding);
  3923.         xml_parser_set_option($this->xmlXML_OPTION_SKIP_WHITE1);
  3924.         xml_set_object($this->xml$this);
  3925.         xml_set_character_data_handler($this->xml'data_handler');
  3926.         xml_set_element_handler($this->xml'start_handler''end_handler');
  3927.         xml_set_start_namespace_decl_handler($this->xml'start_name_space');
  3928.         xml_set_end_namespace_decl_handler($this->xml'end_name_space');
  3929.  
  3930.         // Parse!
  3931.         if (!xml_parse($this->xml$data))
  3932.         {
  3933.             $this->data = null;
  3934.             $this->error_code = xml_get_error_code($this->xml);
  3935.             $this->error_string = xml_error_string($this->error_code);
  3936.         }
  3937.         $this->current_line = xml_get_current_line_number($this->xml);
  3938.         $this->current_column = xml_get_current_column_number($this->xml);
  3939.         $this->current_byte = xml_get_current_byte_index($this->xml);
  3940.         xml_parser_free($this->xml);
  3941.         return;
  3942.     }
  3943.  
  3944.     function add_cdata($match)
  3945.     {
  3946.         if (isset($match[10]))
  3947.         {
  3948.             return "<$match[1]$match[2]><![CDATA[$match[10]]]></$match[1]>";
  3949.         }
  3950.         return $match[0];
  3951.     }
  3952.  
  3953.     function cdata_in_cdata($match)
  3954.     {
  3955.         if (isset($match[10]))
  3956.         {
  3957.             $match[10preg_replace_callback('/<!\[CDATA\[(.*)\]\]>/msiU'array(&$this'real_cdata_in_cdata')$match[10]);
  3958.             return "<$match[1]$match[2]><![CDATA[$match[10]]]></$match[1]>";
  3959.         }
  3960.         return $match[0];
  3961.     }
  3962.  
  3963.     function real_cdata_in_cdata($match)
  3964.     {
  3965.         return htmlspecialchars($match[1]ENT_NOQUOTES);
  3966.     }
  3967.  
  3968.     function do_add_content(&$array$data)
  3969.     {
  3970.         if ($this->is_first)
  3971.         {
  3972.             $array['data'$data;
  3973.             $array['attribs'$this->attribs;
  3974.         }
  3975.         else
  3976.         {
  3977.             $array['data'.= $data;
  3978.         }
  3979.     }
  3980.  
  3981.     function start_handler($parser$name$attribs)
  3982.     {
  3983.         $this->tag_name = $name;
  3984.         $this->attribs = $attribs;
  3985.         $this->is_first = true;
  3986.  
  3987.         if ($this->inside_item)
  3988.         {
  3989.             $this->depth_inside_item++;
  3990.         }
  3991.  
  3992.         switch ($this->tag_name)
  3993.         {
  3994.             case 'ITEM':
  3995.             case $this->namespaces['rss2'':ITEM':
  3996.             case $this->namespaces['rss1'':ITEM':
  3997.             case 'ENTRY':
  3998.             case $this->namespaces['atom'':ENTRY':
  3999.                 $this->inside_item = true;
  4000.                 $this->do_add_content($this->data['items'][$this->item_number]'');
  4001.                 break;
  4002.  
  4003.             case 'CHANNEL':
  4004.             case $this->namespaces['rss2'':CHANNEL':
  4005.             case $this->namespaces['rss1'':CHANNEL':
  4006.                 $this->inside_channel = true;
  4007.                 break;
  4008.  
  4009.             case 'RSS':
  4010.             case $this->namespaces['rss2'':RSS':
  4011.                 $this->data['feedinfo']['type''RSS';
  4012.                 $this->do_add_content($this->data['feeddata']'');
  4013.                 if (!empty($attribs['VERSION']))
  4014.                 {
  4015.                     $this->data['feedinfo']['version'trim($attribs['VERSION']);
  4016.                 }
  4017.                 break;
  4018.  
  4019.             case $this->namespaces['rdf'':RDF':
  4020.                 $this->data['feedinfo']['type''RSS';
  4021.                 $this->do_add_content($this->data['feeddata']'');
  4022.                 $this->data['feedinfo']['version'1;
  4023.                 break;
  4024.  
  4025.             case 'FEED':
  4026.             case $this->namespaces['atom'':FEED':
  4027.                 $this->data['feedinfo']['type''Atom';
  4028.                 $this->do_add_content($this->data['feeddata']'');
  4029.                 if (!empty($attribs['VERSION']))
  4030.                 {
  4031.                     $this->data['feedinfo']['version'trim($attribs['VERSION']);
  4032.                 }
  4033.                 break;
  4034.  
  4035.             case 'IMAGE':
  4036.             case $this->namespaces['rss2'':IMAGE':
  4037.             case $this->namespaces['rss1'':IMAGE':
  4038.                 if ($this->inside_channel)
  4039.                 {
  4040.                     $this->inside_image = true;
  4041.                 }
  4042.                 break;
  4043.         }
  4044.  
  4045.         if (!empty($this->data['feedinfo']['type']&& $this->data['feedinfo']['type'== 'Atom' && ($this->tag_name == 'AUTHOR' || $this->tag_name == $this->namespaces['atom'':AUTHOR'))
  4046.         {
  4047.             $this->inside_author = true;
  4048.         }
  4049.         $this->data_handler($this->xml'');
  4050.     }
  4051.  
  4052.     function data_handler($parser$data)
  4053.     {
  4054.         if ($this->inside_item && $this->depth_inside_item == 1)
  4055.         {
  4056.             switch ($this->tag_name)
  4057.             {
  4058.                 case 'TITLE':
  4059.                 case $this->namespaces['rss1'':TITLE':
  4060.                 case $this->namespaces['rss2'':TITLE':
  4061.                 case $this->namespaces['atom'':TITLE':
  4062.                     $this->do_add_content($this->data['items'][$this->item_number]['title']$data);
  4063.                     break;
  4064.  
  4065.                 case $this->namespaces['dc'':TITLE':
  4066.                     $this->do_add_content($this->data['items'][$this->item_number]['dc:title']$data);
  4067.                     break;
  4068.  
  4069.                 case 'CONTENT':
  4070.                 case $this->namespaces['atom'':CONTENT':
  4071.                     $this->do_add_content($this->data['items'][$this->item_number]['content']$data);
  4072.                     break;
  4073.  
  4074.                 case $this->namespaces['content'':ENCODED':
  4075.                     $this->do_add_content($this->data['items'][$this->item_number]['encoded']$data);
  4076.                     break;
  4077.  
  4078.                 case 'SUMMARY':
  4079.                 case $this->namespaces['atom'':SUMMARY':
  4080.                     $this->do_add_content($this->data['items'][$this->item_number]['summary']$data);
  4081.                     break;
  4082.  
  4083.                 case 'LONGDESC':
  4084.                     $this->do_add_content($this->data['items'][$this->item_number]['longdesc']$data);
  4085.                     break;
  4086.  
  4087.                 case 'DESCRIPTION':
  4088.                 case $this->namespaces['rss1'':DESCRIPTION':
  4089.                 case $this->namespaces['rss2'':DESCRIPTION':
  4090.                     $this->do_add_content($this->data['items'][$this->item_number]['description']$data);
  4091.                     break;
  4092.  
  4093.                 case $this->namespaces['dc'':DESCRIPTION':
  4094.                     $this->do_add_content($this->data['items'][$this->item_number]['dc:description']$data);
  4095.                     break;
  4096.  
  4097.                 case 'LINK':
  4098.                 case $this->namespaces['rss1'':LINK':
  4099.                 case $this->namespaces['rss2'':LINK':
  4100.                 case $this->namespaces['atom'':LINK':
  4101.                     $this->do_add_content($this->data['items'][$this->item_number]['link'][$this->item_link_number]$data);
  4102.                     break;
  4103.  
  4104.                 case 'ENCLOSURE':
  4105.                 case $this->namespaces['rss1'':ENCLOSURE':
  4106.                 case $this->namespaces['rss2'':ENCLOSURE':
  4107.                 case $this->namespaces['atom'':ENCLOSURE':
  4108.                     $this->do_add_content($this->data['items'][$this->item_number]['enclosure'][$this->enclosure_number]$data);
  4109.                     break;
  4110.  
  4111.                 case 'GUID':
  4112.                 case $this->namespaces['rss1'':GUID':
  4113.                 case $this->namespaces['rss2'':GUID':
  4114.                     $this->do_add_content($this->data['items'][$this->item_number]['guid']$data);
  4115.                     break;
  4116.  
  4117.                 case 'ID':
  4118.                 case $this->namespaces['atom'':ID':
  4119.                     $this->do_add_content($this->data['items'][$this->item_number]['id']$data);
  4120.                     break;
  4121.  
  4122.                 case 'PUBDATE':
  4123.                 case $this->namespaces['rss1'':PUBDATE':
  4124.                 case $this->namespaces['rss2'':PUBDATE':
  4125.                     $this->do_add_content($this->data['items'][$this->item_number]['pubdate']$data);
  4126.                     break;
  4127.  
  4128.                 case $this->namespaces['dc'':DATE':
  4129.                     $this->do_add_content($this->data['items'][$this->item_number]['dc:date']$data);
  4130.                     break;
  4131.  
  4132.                 case 'ISSUED':
  4133.                 case $this->namespaces['atom'':ISSUED':
  4134.                     $this->do_add_content($this->data['items'][$this->item_number]['issued']$data);
  4135.                     break;
  4136.  
  4137.                 case 'PUBLISHED':
  4138.                 case $this->namespaces['atom'':PUBLISHED':
  4139.                     $this->do_add_content($this->data['items'][$this->item_number]['published']$data);
  4140.                     break;
  4141.  
  4142.                 case 'MODIFIED':
  4143.                 case $this->namespaces['atom'':MODIFIED':
  4144.                     $this->do_add_content($this->data['items'][$this->item_number]['modified']$data);
  4145.                     break;
  4146.  
  4147.                 case 'UPDATED':
  4148.                 case $this->namespaces['atom'':UPDATED':
  4149.                     $this->do_add_content($this->data['items'][$this->item_number]['updated']$data);
  4150.                     break;
  4151.  
  4152.                 case 'CATEGORY':
  4153.                 case $this->namespaces['rss1'':CATEGORY':
  4154.                 case $this->namespaces['rss2'':CATEGORY':
  4155.                 case $this->namespaces['atom'':CATEGORY':
  4156.                     $this->do_add_content($this->data['items'][$this->item_number]['category'][$this->category_number]$data);
  4157.                     break;
  4158.  
  4159.                 case $this->namespaces['dc'':SUBJECT':
  4160.                     $this->do_add_content($this->data['items'][$this->item_number]['subject'][$this->category_number]$data);
  4161.                     break;
  4162.  
  4163.                 case $this->namespaces['dc'':CREATOR':
  4164.                     $this->do_add_content($this->data['items'][$this->item_number]['creator'][$this->author_number]$data);
  4165.                     break;
  4166.  
  4167.                 case 'AUTHOR':
  4168.                 case $this->namespaces['rss1'':AUTHOR':
  4169.                 case $this->namespaces['rss2'':AUTHOR':
  4170.                     $this->do_add_content($this->data['items'][$this->item_number]['author'][$this->author_number]['rss']$data);
  4171.                     break;
  4172.             }
  4173.  
  4174.             if ($this->inside_author)
  4175.             {
  4176.                 switch ($this->tag_name)
  4177.                 {
  4178.                     case 'NAME':
  4179.                     case $this->namespaces['atom'':NAME':
  4180.                         $this->do_add_content($this->data['items'][$this->item_number]['author'][$this->author_number]['name']$data);
  4181.                         break;
  4182.  
  4183.                     case 'URL':
  4184.                     case $this->namespaces['atom'':URL':
  4185.                         $this->do_add_content($this->data['items'][$this->item_number]['author'][$this->author_number]['url']$data);
  4186.                         break;
  4187.  
  4188.                     case 'URI':
  4189.                     case $this->namespaces['atom'':URI':
  4190.                         $this->do_add_content($this->data['items'][$this->item_number]['author'][$this->author_number]['uri']$data);
  4191.                         break;
  4192.  
  4193.                     case 'HOMEPAGE':
  4194.                     case $this->namespaces['atom'':HOMEPAGE':
  4195.                         $this->do_add_content($this->data['items'][$this->item_number]['author'][$this->author_number]['homepage']$data);
  4196.                         break;
  4197.  
  4198.                     case 'EMAIL':
  4199.                     case $this->namespaces['atom'':EMAIL':
  4200.                         $this->do_add_content($this->data['items'][$this->item_number]['author'][$this->author_number]['email']$data);
  4201.                         break;
  4202.                 }
  4203.             }
  4204.         }
  4205.  
  4206.         else if (($this->inside_channel && !$this->inside_image|| (isset($this->data['feedinfo']['type']&& $this->data['feedinfo']['type'== 'Atom'))
  4207.         {
  4208.             switch ($this->tag_name)
  4209.             {
  4210.                 case 'TITLE':
  4211.                 case $this->namespaces['rss1'':TITLE':
  4212.                 case $this->namespaces['rss2'':TITLE':
  4213.                 case $this->namespaces['atom'':TITLE':
  4214.                     $this->do_add_content($this->data['info']['title']$data);
  4215.                     break;
  4216.  
  4217.                 case 'LINK':
  4218.                 case $this->namespaces['rss1'':LINK':
  4219.                 case $this->namespaces['rss2'':LINK':
  4220.                 case $this->namespaces['atom'':LINK':
  4221.                     $this->do_add_content($this->data['info']['link'][$this->link_number]$data);
  4222.                     break;
  4223.  
  4224.                 case 'DESCRIPTION':
  4225.                 case $this->namespaces['rss1'':DESCRIPTION':
  4226.                 case $this->namespaces['rss2'':DESCRIPTION':
  4227.                     $this->do_add_content($this->data['info']['description']$data);
  4228.                     break;
  4229.  
  4230.                 case $this->namespaces['dc'':DESCRIPTION':
  4231.                     $this->do_add_content($this->data['info']['dc:description']$data);
  4232.                     break;
  4233.  
  4234.                 case 'TAGLINE':
  4235.                 case $this->namespaces['atom'':TAGLINE':
  4236.                     $this->do_add_content($this->data['info']['tagline']$data);
  4237.                     break;
  4238.  
  4239.                 case 'SUBTITLE':
  4240.                 case $this->namespaces['atom'':SUBTITLE':
  4241.                     $this->do_add_content($this->data['info']['subtitle']$data);
  4242.                     break;
  4243.  
  4244.                 case 'COPYRIGHT':
  4245.                 case $this->namespaces['rss1'':COPYRIGHT':
  4246.                 case $this->namespaces['rss2'':COPYRIGHT':
  4247.                 case $this->namespaces['atom'':COPYRIGHT':
  4248.                     $this->do_add_content($this->data['info']['copyright']$data);
  4249.                     break;
  4250.  
  4251.                 case 'LANGUAGE':
  4252.                 case $this->namespaces['rss1'':LANGUAGE':
  4253.                 case $this->namespaces['rss2'':LANGUAGE':
  4254.                     $this->do_add_content($this->data['info']['language']$data);
  4255.                     break;
  4256.  
  4257.                 case 'LOGO':
  4258.                 case $this->namespaces['atom'':LOGO':
  4259.                     $this->do_add_content($this->data['info']['logo']$data);
  4260.                     break;
  4261.  
  4262.             }
  4263.         }
  4264.  
  4265.         else if ($this->inside_channel && $this->inside_image)
  4266.         {
  4267.             switch ($this->tag_name)
  4268.             {
  4269.                 case 'TITLE':
  4270.                 case $this->namespaces['rss1'':TITLE':
  4271.                 case $this->namespaces['rss2'':TITLE':
  4272.                     $this->do_add_content($this->data['info']['image']['title']$data);
  4273.                     break;
  4274.  
  4275.                 case 'URL':
  4276.                 case $this->namespaces['rss1'':URL':
  4277.                 case $this->namespaces['rss2'':URL':
  4278.                     $this->do_add_content($this->data['info']['image']['url']$data);
  4279.                     break;
  4280.  
  4281.                 case 'LINK':
  4282.                 case $this->namespaces['rss1'':LINK':
  4283.                 case $this->namespaces['rss2'':LINK':
  4284.                     $this->do_add_content($this->data['info']['image']['link']$data);
  4285.                     break;
  4286.  
  4287.                 case 'WIDTH':
  4288.                 case $this->namespaces['rss1'':WIDTH':
  4289.                 case $this->namespaces['rss2'':WIDTH':
  4290.                     $this->do_add_content($this->data['info']['image']['width']$data);
  4291.                     break;
  4292.  
  4293.                 case 'HEIGHT':
  4294.                 case $this->namespaces['rss1'':HEIGHT':
  4295.                 case $this->namespaces['rss2'':HEIGHT':
  4296.                     $this->do_add_content($this->data['info']['image']['height']$data);
  4297.                     break;
  4298.             }
  4299.         }
  4300.         $this->is_first = false;
  4301.     }
  4302.  
  4303.     function end_handler($parser$name)
  4304.     {
  4305.         $this->tag_name = '';
  4306.         switch ($name)
  4307.         {
  4308.             case 'ITEM':
  4309.             case $this->namespaces['rss1'':ITEM':
  4310.             case $this->namespaces['rss2'':ITEM':
  4311.             case 'ENTRY':
  4312.             case $this->namespaces['atom'':ENTRY':
  4313.                 $this->inside_item = false;
  4314.                 $this->item_number++;
  4315.                 $this->author_number = 0;
  4316.                 $this->category_number = 0;
  4317.                 $this->enclosure_number = 0;
  4318.                 $this->item_link_number = 0;
  4319.                 break;
  4320.  
  4321.             case 'CHANNEL':
  4322.             case $this->namespaces['rss1'':CHANNEL':
  4323.             case $this->namespaces['rss2'':CHANNEL':
  4324.                 $this->inside_channel = false;
  4325.                 break;
  4326.  
  4327.             case 'IMAGE':
  4328.             case $this->namespaces['rss1'':IMAGE':
  4329.             case $this->namespaces['rss2'':IMAGE':
  4330.                 $this->inside_image = false;
  4331.                 break;
  4332.  
  4333.             case 'AUTHOR':
  4334.             case $this->namespaces['rss1'':AUTHOR':
  4335.             case $this->namespaces['rss2'':AUTHOR':
  4336.             case $this->namespaces['atom'':AUTHOR':
  4337.                 $this->author_number++;
  4338.                 $this->inside_author = false;
  4339.                 break;
  4340.  
  4341.             case 'CATEGORY':
  4342.             case $this->namespaces['rss1'':CATEGORY':
  4343.             case $this->namespaces['rss2'':CATEGORY':
  4344.             case $this->namespaces['atom'':CATEGORY':
  4345.             case $this->namespaces['dc'':SUBJECT':
  4346.                 $this->category_number++;
  4347.                 break;
  4348.  
  4349.             case 'ENCLOSURE':
  4350.             case $this->namespaces['rss1'':ENCLOSURE':
  4351.             case $this->namespaces['rss2'':ENCLOSURE':
  4352.                 $this->enclosure_number++;
  4353.                 break;
  4354.  
  4355.             case 'LINK':
  4356.             case $this->namespaces['rss1'':LINK':
  4357.             case $this->namespaces['rss2'':LINK':
  4358.             case $this->namespaces['atom'':LINK':
  4359.                 if ($this->inside_item)
  4360.                 {
  4361.                     $this->item_link_number++;
  4362.                 }
  4363.                 else
  4364.                 {
  4365.                     $this->link_number++;
  4366.                 }
  4367.                 break;
  4368.         }
  4369.         if ($this->inside_item)
  4370.         {
  4371.             $this->depth_inside_item--;
  4372.         }
  4373.     }
  4374.  
  4375.     function start_name_space($parser$prefix$uri null)
  4376.     {
  4377.         $prefix strtoupper($prefix);
  4378.         $uri strtoupper($uri);
  4379.         if ($prefix == 'ATOM' || $uri == 'HTTP://WWW.W3.ORG/2005/ATOM' || $uri == 'HTTP://PURL.ORG/ATOM/NS#')
  4380.         {
  4381.             $this->namespaces['atom'$uri;
  4382.         }
  4383.         else if ($prefix == 'RSS2' || $uri == 'HTTP://BACKEND.USERLAND.COM/RSS2')
  4384.         {
  4385.             $this->namespaces['rss2'$uri;
  4386.         }
  4387.         else if ($prefix == 'RDF' || $uri == 'HTTP://WWW.W3.ORG/1999/02/22-RDF-SYNTAX-NS#')
  4388.         {
  4389.             $this->namespaces['rdf'$uri;
  4390.         }
  4391.         else if ($prefix == 'RSS' || $uri == 'HTTP://PURL.ORG/RSS/1.0/' || $uri == 'HTTP://MY.NETSCAPE.COM/RDF/SIMPLE/0.9/')
  4392.         {
  4393.             $this->namespaces['rss1'$uri;
  4394.         }
  4395.         else if ($prefix == 'DC' || $uri == 'HTTP://PURL.ORG/DC/ELEMENTS/1.1/')
  4396.         {
  4397.             $this->namespaces['dc'$uri;
  4398.         }
  4399.         else if ($prefix == 'XHTML' || $uri == 'HTTP://WWW.W3.ORG/1999/XHTML')
  4400.         {
  4401.             $this->namespaces['xhtml'$uri;
  4402.             $this->xhtml_prefix $prefix;
  4403.         }
  4404.         else if ($prefix == 'CONTENT' || $uri == 'HTTP://PURL.ORG/RSS/1.0/MODULES/CONTENT/')
  4405.         {
  4406.             $this->namespaces['content'$uri;
  4407.         }
  4408.     }
  4409.  
  4410.     function end_name_space($parser$prefix)
  4411.     {
  4412.         if ($key array_search(strtoupper($prefix)$this->namespaces))
  4413.         {
  4414.             if ($key == 'atom')
  4415.             {
  4416.                 $this->namespaces['atom''ATOM';
  4417.             }
  4418.             else if ($key == 'rss2')
  4419.             {
  4420.                 $this->namespaces['rss2''RSS';
  4421.             }
  4422.             else if ($key == 'rdf')
  4423.             {
  4424.                 $this->namespaces['rdf''RDF';
  4425.             }
  4426.             else if ($key == 'rss1')
  4427.             {
  4428.                 $this->namespaces['rss1''RSS';
  4429.             }
  4430.             else if ($key == 'dc')
  4431.             {
  4432.                 $this->namespaces['dc''DC';
  4433.             }
  4434.             else if ($key == 'xhtml')
  4435.             {
  4436.                 $this->namespaces['xhtml''XHTML';
  4437.                 $this->xhtml_prefix 'XHTML';
  4438.             }
  4439.             else if ($key == 'content')
  4440.             {
  4441.                 $this->namespaces['content''CONTENT';
  4442.             }
  4443.         }
  4444.     }
  4445. }
  4446.  
  4447. {
  4448.     // Private vars
  4449.         var $feedinfo;
  4450.     var $info;
  4451.     var $items;
  4452.     var $feed_xmlbase;
  4453.     var $item_xmlbase;
  4454.     var $attribs;
  4455.     var $cached_entities;
  4456.  
  4457.     // Options
  4458.         var $remove_div = true;
  4459.     var $strip_ads = false;
  4460.     var $replace_headers = false;
  4461.     var $bypass_image_hotlink = false;
  4462.     var $bypass_image_hotlink_page = false;
  4463.     var $strip_htmltags = array('base''blink''body''doctype''embed''font''form''frame''frameset''html''iframe''input''marquee''meta''noscript''object''param''script''style');
  4464.     var $encode_instead_of_strip = false;
  4465.     var $strip_attributes = array('bgsound''class''expr''id''style''onclick''onerror''onfinish''onmouseover''onmouseout''onfocus''onblur');
  4466.     var $input_encoding = 'UTF-8';
  4467.     var $output_encoding = 'UTF-8';
  4468.     var $item_class = 'SimplePie_Item';
  4469.     var $author_class = 'SimplePie_Author';
  4470.     var $enclosure_class = 'SimplePie_Enclosure';
  4471.  
  4472.     function remove_div($enable true)
  4473.     {
  4474.         $this->remove_div = (bool) $enable;
  4475.     }
  4476.  
  4477.     function strip_ads($enable false)
  4478.     {
  4479.         $this->strip_ads = (bool) $enable;
  4480.     }
  4481.  
  4482.     function replace_headers($enable false)
  4483.     {
  4484.         $this->enable_headers = (bool) $enable;
  4485.     }
  4486.  
  4487.     function bypass_image_hotlink($get false)
  4488.     {
  4489.         if ($get)
  4490.         {
  4491.             $this->bypass_image_hotlink = (string) $get;
  4492.         }
  4493.         else
  4494.         {
  4495.             $this->bypass_image_hotlink = false;
  4496.         }
  4497.     }
  4498.  
  4499.     function bypass_image_hotlink_page($page false)
  4500.     {
  4501.         if ($page)
  4502.         {
  4503.             $this->bypass_image_hotlink_page = (string) $page;
  4504.         }
  4505.         else
  4506.         {
  4507.             $this->bypass_image_hotlink_page = false;
  4508.         }
  4509.     }
  4510.  
  4511.     function strip_htmltags($tags array('base''blink''body''doctype''embed''font''form''frame''frameset''html''iframe''input''marquee''meta''noscript''object''param''script''style'))
  4512.     {
  4513.         if ($tags)
  4514.         {
  4515.             if (is_array($tags))
  4516.             {
  4517.                 $this->strip_htmltags = $tags;
  4518.             }
  4519.             else
  4520.             {
  4521.                 $this->strip_htmltags = explode(','$tags);
  4522.             }
  4523.         }
  4524.         else
  4525.         {
  4526.             $this->strip_htmltags = false;
  4527.         }
  4528.     }
  4529.  
  4530.     function encode_instead_of_strip($enable false)
  4531.     {
  4532.         $this->encode_instead_of_strip = (bool) $enable;
  4533.     }
  4534.  
  4535.     function strip_attributes($attribs array('bgsound''class''expr''id''style''onclick''onerror''onfinish''onmouseover''onmouseout''onfocus''onblur'))
  4536.     {
  4537.         if ($attribs)
  4538.         {
  4539.             if (is_array($attribs))
  4540.             {
  4541.                 $this->strip_attributes = $attribs;
  4542.             }
  4543.             else
  4544.             {
  4545.                 $this->strip_attributes = explode(','$attribs);
  4546.             }
  4547.         }
  4548.         else
  4549.         {
  4550.             $this->strip_attributes = false;
  4551.         }
  4552.     }
  4553.  
  4554.     function input_encoding($encoding 'UTF-8')
  4555.     {
  4556.         $this->input_encoding = (string) $encoding;
  4557.     }
  4558.  
  4559.     function output_encoding($encoding 'UTF-8')
  4560.     {
  4561.         $this->output_encoding = (string) $encoding;
  4562.     }
  4563.  
  4564.     function set_item_class($class 'SimplePie_Item')
  4565.     {
  4566.         if (SimplePie_Misc::is_a_class($class'SimplePie_Item'))
  4567.         {
  4568.             $this->item_class = $class;
  4569.             return true;
  4570.         }
  4571.         return false;
  4572.     }
  4573.  
  4574.     function set_author_class($class 'SimplePie_Author')
  4575.     {
  4576.         if (SimplePie_Misc::is_a_class($class'SimplePie_Author'))
  4577.         {
  4578.             $this->author_class = $class;
  4579.             return true;
  4580.         }
  4581.         return false;
  4582.     }
  4583.  
  4584.     function set_enclosure_class($class 'SimplePie_Enclosure')
  4585.     {
  4586.         if (SimplePie_Misc::is_a_class($class'SimplePie_Enclosure'))
  4587.         {
  4588.             $this->enclosure_class = $class;
  4589.             return true;
  4590.         }
  4591.         return false;
  4592.     }
  4593.  
  4594.     function parse_data_array(&$data$url)
  4595.     {
  4596.         // Feed Info (Type and Version)
  4597.         if (!empty($data['feedinfo']['type']))
  4598.         {
  4599.             $this->feedinfo = $data['feedinfo'];
  4600.         }
  4601.  
  4602.         // Feed level xml:base
  4603.         if (!empty($data['feeddata']['attribs']['XML:BASE']))
  4604.         {
  4605.             $this->feed_xmlbase = $data['feeddata']['attribs']['XML:BASE'];
  4606.         }
  4607.         else if (!empty($data['feeddata']['attribs']['HTTP://WWW.W3.ORG/XML/1998/NAMESPACE:BASE']))
  4608.         {
  4609.             $this->feed_xmlbase = $data['feeddata']['attribs']['HTTP://WWW.W3.ORG/XML/1998/NAMESPACE:BASE'];
  4610.         }
  4611.         // FeedBurner feeds use alternate link
  4612.         else if (strpos($url'http://feeds.feedburner.com/'!== 0)
  4613.         {
  4614.             $this->feed_xmlbase = SimplePie_Misc::parse_url($url);
  4615.             if (empty($this->feed_xmlbase['authority']))
  4616.             {
  4617.                 $this->feed_xmlbase = preg_replace('/^' preg_quote(realpath($_SERVER['DOCUMENT_ROOT'])'/''/'''realpath($url));
  4618.             }
  4619.             else
  4620.             {
  4621.                 $this->feed_xmlbase = $url;
  4622.             }
  4623.         }
  4624.  
  4625.  
  4626.         // Feed link(s)
  4627.         if (!empty($data['info']['link']))
  4628.         {
  4629.             foreach ($data['info']['link'as $link)
  4630.             {
  4631.                 if (empty($link['attribs']['REL']))
  4632.                 {
  4633.                     $rel 'alternate';
  4634.                 }
  4635.                 else
  4636.                 {
  4637.                     $rel strtolower($link['attribs']['REL']);
  4638.                 }
  4639.                 if ($rel == 'enclosure')
  4640.                 {
  4641.                     $href null;
  4642.                     $type null;
  4643.                     $length null;
  4644.                     if (!empty($link['data']))
  4645.                     {
  4646.                         $href $this->sanitize($link['data']$link['attribs']true);
  4647.                     }
  4648.                     else if (!empty($link['attribs']['HREF']))
  4649.                     {
  4650.                         $href $this->sanitize($link['attribs']['HREF']$link['attribs']true);
  4651.                     }
  4652.                     if (!empty($link['attribs']['TYPE'])) {
  4653.                         $type $this->sanitize($link['attribs']['TYPE']$link['attribs']);
  4654.                     }
  4655.                     if (!empty($link['attribs']['LENGTH'])) {
  4656.                         $length $this->sanitize($link['attribs']['LENGTH']$link['attribs']);
  4657.                     }
  4658.                     $this->info['link']['enclosure'][new $this->enclosure_class($href$type$length);
  4659.                 }
  4660.                 else
  4661.                 {
  4662.                     if (!empty($link['data']))
  4663.                     {
  4664.                         $this->info['link'][$rel][$this->sanitize($link['data']$link['attribs']true);
  4665.                     }
  4666.                     else if (!empty($link['attribs']['HREF']))
  4667.                     {
  4668.                         $this->info['link'][$rel][$this->sanitize($link['attribs']['HREF']$link['attribs']true);
  4669.                     }
  4670.                 }
  4671.             }
  4672.         }
  4673.  
  4674.         // Use the first alternate link if we don't have any feed xml:base
  4675.         if (empty($this->feed_xmlbase&& !empty($this->info['link']['alternate'][0]))
  4676.         {
  4677.             $this->feed_xmlbase = $this->info['link']['alternate'][0];
  4678.         }
  4679.  
  4680.         // Feed Title
  4681.         if (!empty($data['info']['title']['data']))
  4682.         {
  4683.             $this->info['title'$this->sanitize($data['info']['title']['data']$data['info']['title']['attribs']);
  4684.         }
  4685.  
  4686.         // Feed Descriptions
  4687.         if (!empty($data['info']['description']['data']))
  4688.         {
  4689.             $this->info['description'$this->sanitize($data['info']['description']['data']$data['info']['description']['attribs']falsetrue);
  4690.         }
  4691.         if (!empty($data['info']['dc:description']['data']))
  4692.         {
  4693.             $this->info['dc:description'$this->sanitize($data['info']['dc:description']['data']$data['info']['dc:description']['attribs']);
  4694.         }
  4695.         if (!empty($data['info']['tagline']['data']))
  4696.         {
  4697.             $this->info['tagline'$this->sanitize($data['info']['tagline']['data']$data['info']['tagline']['attribs']);
  4698.         }
  4699.         if (!empty($data['info']['subtitle']['data']))
  4700.         {
  4701.             $this->info['subtitle'$this->sanitize($data['info']['subtitle']['data']$data['info']['subtitle']['attribs']);
  4702.         }
  4703.  
  4704.         // Feed Language
  4705.         if (!empty($data['info']['language']['data']))
  4706.         {
  4707.             $this->info['language'$this->sanitize($data['info']['language']['data']$data['info']['language']['attribs']);
  4708.         }
  4709.         if (!empty($data['feeddata']['attribs']['XML:LANG']))
  4710.         {
  4711.             $this->info['xml:lang'$this->sanitize($data['feeddata']['attribs']['XML:LANG']null);
  4712.         }
  4713.         else if (!empty($data['feeddata']['attribs']['HTTP://WWW.W3.ORG/XML/1998/NAMESPACE:LANG']))
  4714.         {
  4715.             $this->info['xml:lang'$this->sanitize($data['feeddata']['attribs']['HTTP://WWW.W3.ORG/XML/1998/NAMESPACE:LANG']null);
  4716.         }
  4717.  
  4718.         // Feed Copyright
  4719.         if (!empty($data['info']['copyright']['data']))
  4720.         {
  4721.             $this->info['copyright'$this->sanitize($data['info']['copyright']['data']$data['info']['copyright']['attribs']);
  4722.         }
  4723.  
  4724.         // Feed Image
  4725.         if (!empty($data['info']['image']['title']['data']))
  4726.         {
  4727.             $this->info['image']['title'$this->sanitize($data['info']['image']['title']['data']$data['info']['image']['title']['attribs']);
  4728.         }
  4729.         if (!empty($data['info']['image']['url']['data']))
  4730.         {
  4731.             $this->info['image']['url'$this->sanitize($data['info']['image']['url']['data']$data['info']['image']['url']['attribs']true);
  4732.         }
  4733.         if (!empty($data['info']['logo']['data']))
  4734.         {
  4735.             $this->info['image']['logo'$this->sanitize($data['info']['logo']['data']$data['info']['logo']['attribs']true);
  4736.         }
  4737.         if (!empty($data['info']['image']['link']['data']))
  4738.         {
  4739.             $this->info['image']['link'$this->sanitize($data['info']['image']['link']['data']$data['info']['image']['link']['attribs']true);
  4740.         }
  4741.         if (!empty($data['info']['image']['width']['data']))
  4742.         {
  4743.             $this->info['image']['width'$this->sanitize($data['info']['image']['width']['data']$data['info']['image']['width']['attribs']);
  4744.         }
  4745.         if (!empty($data['info']['image']['height']['data']))
  4746.         {
  4747.             $this->info['image']['height'$this->sanitize($data['info']['image']['height']['data']$data['info']['image']['height']['attribs']);
  4748.         }
  4749.  
  4750.         // Items
  4751.         if (!empty($data['items']))
  4752.         {
  4753.             foreach ($data['items'as $key => $item)
  4754.             {
  4755.                 $newitem null;
  4756.  
  4757.                 // Item level xml:base
  4758.                 if (!empty($item['attribs']['XML:BASE']))
  4759.                 {
  4760.                     $this->item_xmlbase = SimplePie_Misc::absolutize_url($item['attribs']['XML:BASE']$this->feed_xmlbase);
  4761.                 }
  4762.                 else if (!empty($item['attribs']['HTTP://WWW.W3.ORG/XML/1998/NAMESPACE:BASE']))
  4763.                 {
  4764.                     $this->item_xmlbase = SimplePie_Misc::absolutize_url($item['attribs']['HTTP://WWW.W3.ORG/XML/1998/NAMESPACE:BASE']$this->feed_xmlbase);
  4765.                 }
  4766.                 else
  4767.                 {
  4768.                     $this->item_xmlbase = null;
  4769.                 }
  4770.  
  4771.                 // Title
  4772.                 if (!empty($item['title']['data'])) {
  4773.                     $newitem['title'$this->sanitize($item['title']['data']$item['title']['attribs']);
  4774.                 }
  4775.                 if (!empty($item['dc:title']['data']))
  4776.                 {
  4777.                     $newitem['dc:title'$this->sanitize($item['dc:title']['data']$item['dc:title']['attribs']);
  4778.                 }
  4779.  
  4780.                 // Description
  4781.                 if (!empty($item['content']['data']))
  4782.                 {
  4783.                     $newitem['content'$this->sanitize($item['content']['data']$item['content']['attribs']);
  4784.                 }
  4785.                 if (!empty($item['encoded']['data']))
  4786.                 {
  4787.                     $newitem['encoded'$this->sanitize($item['encoded']['data']$item['encoded']['attribs']);
  4788.                 }
  4789.                 if (!empty($item['summary']['data']))
  4790.                 {
  4791.                     $newitem['summary'$this->sanitize($item['summary']['data']$item['summary']['attribs']);
  4792.                 }
  4793.                 if (!empty($item['description']['data']))
  4794.                 {
  4795.                     $newitem['description'$this->sanitize($item['description']['data']$item['description']['attribs']falsetrue);
  4796.                 }
  4797.                 if (!empty($item['dc:description']['data']))
  4798.                 {
  4799.                     $newitem['dc:description'$this->sanitize($item['dc:description']['data']$item['dc:description']['attribs']);
  4800.                 }
  4801.                 if (!empty($item['longdesc']['data']))
  4802.                 {
  4803.                     $newitem['longdesc'$this->sanitize($item['longdesc']['data']$item['longdesc']['attribs']);
  4804.                 }
  4805.  
  4806.                 // Link(s)
  4807.                 if (!empty($item['link']))
  4808.                 {
  4809.                     foreach ($item['link'as $link)
  4810.                     {
  4811.                         if (empty($link['attribs']['REL']))
  4812.                         {
  4813.                             $rel 'alternate';
  4814.                         }
  4815.                         else
  4816.                         {
  4817.                             $rel strtolower($link['attribs']['REL']);
  4818.                         }
  4819.                         if ($rel == 'enclosure')
  4820.                         {
  4821.                             $href null;
  4822.                             $type null;
  4823.                             $length null;
  4824.                             if (!empty($link['data']))
  4825.                             {
  4826.                                 $href $this->sanitize($link['data']$link['attribs']true);
  4827.                             }
  4828.                             else if (!empty($link['attribs']['HREF']))
  4829.                             {
  4830.                                 $href $this->sanitize($link['attribs']['HREF']$link['attribs']true);
  4831.                             }
  4832.                             if (!empty($link['attribs']['TYPE'])) {
  4833.                                 $type $this->sanitize($link['attribs']['TYPE']$link['attribs']);
  4834.                             }
  4835.                             if (!empty($link['attribs']['LENGTH'])) {
  4836.                                 $length $this->sanitize($link['attribs']['LENGTH']$link['attribs']);
  4837.                             }
  4838.                             if (!empty($href))
  4839.                             {
  4840.                                 $newitem['link'][$rel][new $this->enclosure_class($href$type$length);
  4841.                             }
  4842.                         }
  4843.                         else
  4844.                         {
  4845.                             if (!empty($link['data']))
  4846.                             {
  4847.                                 $newitem['link'][$rel][$this->sanitize($link['data']$link['attribs']true);
  4848.                             }
  4849.                             else if (!empty($link['attribs']['HREF']))
  4850.                             {
  4851.                                 $newitem['link'][$rel][$this->sanitize($link['attribs']['HREF']$link['attribs']true);
  4852.                             }
  4853.                         }
  4854.                     }
  4855.                 }
  4856.  
  4857.                 // Enclosure(s)
  4858.                 if (!empty($item['enclosure']))
  4859.                 {
  4860.                     foreach ($item['enclosure'as $enclosure)
  4861.                     {
  4862.                         if (!empty($enclosure['attribs']['URL']))
  4863.                         {
  4864.                             $type null;
  4865.                             $length null;
  4866.                             $href $this->sanitize($enclosure['attribs']['URL']$enclosure['attribs']true);
  4867.                             if (!empty($enclosure['attribs']['TYPE']))
  4868.                             {
  4869.                                 $type $this->sanitize($enclosure['attribs']['TYPE']$enclosure['attribs']);
  4870.                             }
  4871.                             if (!empty($enclosure['attribs']['LENGTH']))
  4872.                             {
  4873.                                 $length $this->sanitize($enclosure['attribs']['LENGTH']$enclosure['attribs']);
  4874.                             }
  4875.                             $newitem['enclosures'][new $this->enclosure_class($href$type$length);
  4876.                         }
  4877.                     }
  4878.                 }
  4879.  
  4880.                 // ID
  4881.                 if (!empty($item['guid']['data']))
  4882.                 {
  4883.                     if (!empty($item['guid']['attribs']['ISPERMALINK']&& strtolower($item['guid']['attribs']['ISPERMALINK']== 'false')
  4884.                     {
  4885.                         $newitem['guid']['permalink'false;
  4886.                     }
  4887.                     else
  4888.                     {
  4889.                         $newitem['guid']['permalink'true;
  4890.                     }
  4891.                     $newitem['guid']['data'$this->sanitize($item['guid']['data']$item['guid']['attribs']);
  4892.                 }
  4893.                 if (!empty($item['id']['data']))
  4894.                 {
  4895.                     $newitem['id'$this->sanitize($item['id']['data']$item['id']['attribs']);
  4896.                 }
  4897.  
  4898.                 // Date
  4899.                 if (!empty($item['pubdate']['data']))
  4900.                 {
  4901.                     $newitem['pubdate'$this->parse_date($this->sanitize($item['pubdate']['data']$item['pubdate']['attribs']));
  4902.                 }
  4903.                 if (!empty($item['dc:date']['data']))
  4904.                 {
  4905.                     $newitem['dc:date'$this->parse_date($this->sanitize($item['dc:date']['data']$item['dc:date']['attribs']));
  4906.                 }
  4907.                 if (!empty($item['issued']['data']))
  4908.                 {
  4909.                     $newitem['issued'$this->parse_date($this->sanitize($item['issued']['data']$item['issued']['attribs']));
  4910.                 }
  4911.                 if (!empty($item['published']['data']))
  4912.                 {
  4913.                     $newitem['published'$this->parse_date($this->sanitize($item['published']['data']$item['published']['attribs']));
  4914.                 }
  4915.                 if (!empty($item['modified']['data']))
  4916.                 {
  4917.                     $newitem['modified'$this->parse_date($this->sanitize($item['modified']['data']$item['modified']['attribs']));
  4918.                 }
  4919.                 if (!empty($item['updated']['data']))
  4920.                 {
  4921.                     $newitem['updated'$this->parse_date($this->sanitize($item['updated']['data']$item['updated']['attribs']));
  4922.                 }
  4923.  
  4924.                 // Categories
  4925.                 if (!empty($item['category']))
  4926.                 {
  4927.                     foreach ($item['category'as $category)
  4928.                     {
  4929.                         if (!empty($category['data']))
  4930.                         {
  4931.                             $newitem['category'][$this->sanitize($category['data']$category['attribs']);
  4932.                         }
  4933.                         else if (!empty($category['attribs']['TERM']))
  4934.                         {
  4935.                             $newitem['term'][$this->sanitize($category['attribs']['TERM']$category['attribs']);
  4936.                         }
  4937.                     }
  4938.                 }
  4939.                 if (!empty($item['subject']))
  4940.                 {
  4941.                     foreach ($item['subject'as $category)
  4942.                     {
  4943.                         if (!empty($category['data']))
  4944.                         {
  4945.                             $newitem['subject'][$this->sanitize($category['data']$category['attribs']);
  4946.                         }
  4947.                     }
  4948.                 }
  4949.  
  4950.                 // Author
  4951.                 if (!empty($item['creator']))
  4952.                 {
  4953.                     foreach ($item['creator'as $creator)
  4954.                     {
  4955.                         if (!empty($creator['data']))
  4956.                         {
  4957.                             $newitem['creator'][new $this->author_class($this->sanitize($creator['data']$creator['attribs'])nullnull);
  4958.                         }
  4959.                     }
  4960.                 }
  4961.                 if (!empty($item['author']))
  4962.                 {
  4963.                     foreach ($item['author'as $author)
  4964.                     {
  4965.                         $name null;
  4966.                         $link null;
  4967.                         $email null;
  4968.                         if (!empty($author['rss']))
  4969.                         {
  4970.                             $sane $this->sanitize($author['rss']['data']$author['rss']['attribs']);
  4971.                             if (preg_match('/(.*)@(.*) \((.*)\)/msiU'$sane$matches)) {
  4972.                                 $name trim($matches[3]);
  4973.                                 $email trim("$matches[1]@$matches[2]");
  4974.                             else {
  4975.                                 $email $sane;
  4976.                             }
  4977.                         }
  4978.                         else
  4979.                         {
  4980.                             if (!empty($author['name']))
  4981.                             {
  4982.                                 $name $this->sanitize($author['name']['data']$author['name']['attribs']);
  4983.                             }
  4984.                             if (!empty($author['url']))
  4985.                             {
  4986.                                 $link $this->sanitize($author['url']['data']$author['url']['attribs']true);
  4987.                             }
  4988.                             else if (!empty($author['uri']))
  4989.                             {
  4990.                                 $link $this->sanitize($author['uri']['data']$author['uri']['attribs']true);
  4991.                             }
  4992.                             else if (!empty($author['homepage']))
  4993.                             {
  4994.                                 $link $this->sanitize($author['homepage']['data']$author['homepage']['attribs']true);
  4995.                             }
  4996.                             if (!empty($author['email'])) {
  4997.                                 $email $this->sanitize($author['email']['data']$author['email']['attribs']);
  4998.                             }
  4999.                         }
  5000.                         $newitem['author'][new $this->author_class($name$link$email);
  5001.                     }
  5002.                 }
  5003.                 unset($data['items'][$key]);
  5004.                 $this->items[new $this->item_class($newitem);
  5005.             }
  5006.         }
  5007.     }
  5008.  
  5009.     function sanitize($data$attribs$is_url false$force_decode false)
  5010.     {
  5011.         $this->attribs = $attribs;
  5012.         if (isset($this->feedinfo['type']&& $this->feedinfo['type'== 'Atom')
  5013.         {
  5014.             if ((!empty($attribs['MODE']&& $attribs['MODE'== 'base64'|| (!empty($attribs['TYPE']&& $attribs['TYPE'== 'application/octet-stream'))
  5015.             {
  5016.                 $data trim($data);
  5017.                 $data base64_decode($data);
  5018.             }
  5019.             else if ((!empty($attribs['MODE']&& $attribs['MODE'== 'escaped' || !empty($attribs['TYPE']&& ($attribs['TYPE'== 'html' || $attribs['TYPE'== 'text/html')))
  5020.             {
  5021.                 $data $this->entities_decode($data);
  5022.             }
  5023.             if (!empty($attribs['TYPE']&& ($attribs['TYPE'== 'xhtml' || $attribs['TYPE'== 'application/xhtml+xml'))
  5024.             {
  5025.                 if ($this->remove_div)
  5026.                 {
  5027.                     $data preg_replace('/<div( .*)?>/msiU'''strrev(preg_replace('/>vid\/</i'''strrev($data)1))1);
  5028.                 }
  5029.                 else
  5030.                 {
  5031.                     $data preg_replace('/<div( .*)?>/msiU''<div>'$data1);
  5032.                 }
  5033.                 $data $this->convert_entities($data);
  5034.             }
  5035.         }
  5036.         else
  5037.         {
  5038.             $data $this->convert_entities($data);
  5039.         }
  5040.         if ($force_decode)
  5041.         {
  5042.             $data $this->entities_decode($data);
  5043.         }
  5044.         $data trim($data);
  5045.         $data preg_replace('/<\!--([^-]|-[^-])*-->/msiU'''$data);
  5046.  
  5047.         // If Strip Ads is enabled, strip them.
  5048.         if ($this->strip_ads)
  5049.         {
  5050.             $data preg_replace('/<a (.*)href=(.*)click\.phdo\?s=(.*)<\/a>/msiU'''$data)// Pheedo links (tested with Dooce.com)
  5051.             $data preg_replace('/<p(.*)>(.*)<a href="http:\/\/ad.doubleclick.net\/jump\/(.*)<\/p>/msiU'''$data)// Doubleclick links (tested with InfoWorld.com)
  5052.             $data preg_replace('/<p><map (.*)name=(.*)google_ad_map(.*)<\/p>/msiU'''$data)// Google AdSense for Feeds (tested with tuaw.com).
  5053.             // Feedflare, from Feedburner
  5054.         }
  5055.  
  5056.         // Replace H1, H2, and H3 tags with the less important H4 tags.
  5057.         // This is because on a site, the more important headers might make sense,
  5058.         // but it most likely doesn't fit in the context of RSS-in-a-webpage.
  5059.         if ($this->replace_headers)
  5060.         {
  5061.             $data preg_replace('/<h[1-3]((\s*((\w+:)?\w+)\s*=\s*("([^"]*)"|\'([^\']*)\'|(.*)))*)\s*>/msiU''<h4\\1>'$data);
  5062.             $data preg_replace('/<\/h[1-3]>/i''</h4>'$data);
  5063.         }
  5064.  
  5065.         if ($is_url)
  5066.         {
  5067.             $data $this->replace_urls($datatrue);
  5068.         }
  5069.         else
  5070.         {
  5071.             $data preg_replace_callback('/<(\S+)((\s*((\w+:)?\w+)\s*=\s*("([^"]*)"|\'([^\']*)\'|(.*)))*)\s*(\/>|>(.*)<\/\S+>)/msiU'array(&$this'replace_urls')$data);
  5072.         }
  5073.  
  5074.         // If Bypass Image Hotlink is enabled, rewrite all the image tags.
  5075.         if ($this->bypass_image_hotlink)
  5076.         {
  5077.             $images SimplePie_Misc::get_element('img'$data);
  5078.             foreach ($images as $img)
  5079.             {
  5080.                 if (!empty($img['attribs']['SRC']['data']))
  5081.                 {
  5082.                     $pre '';
  5083.                     if ($this->bypass_image_hotlink_page)
  5084.                     {
  5085.                         $pre $this->bypass_image_hotlink_page;
  5086.                     }
  5087.                     $pre .= "?$this->bypass_image_hotlink=";
  5088.                     $img['attribs']['SRC']['data'$pre rawurlencode(strtr($img['attribs']['SRC']['data']array_flip(get_html_translation_table(HTML_SPECIALCHARSENT_QUOTES))));
  5089.                     $data str_replace($img['full']SimplePie_Misc::element_implode($img)$data);
  5090.                 }
  5091.             }
  5092.         }
  5093.  
  5094.         // Strip out HTML tags and attributes that might cause various security problems.
  5095.         // Based on recommendations by Mark Pilgrim at:
  5096.         // http://diveintomark.org/archives/2003/06/12/how_to_consume_rss_safely
  5097.         if ($this->strip_htmltags)
  5098.         {
  5099.             foreach ($this->strip_htmltags as $tag)
  5100.             {
  5101.                 $data preg_replace_callback("/<($tag)((\s*((\w+:)?\w+)(\s*=\s*(\"([^\"]*)\"|'([^']*)'|(.*)))?)*)\s*(\/>|>(.*)<\/($tag)((\s*((\w+:)?\w+)(\s*=\s*(\"([^\"]*)\"|'([^']*)'|(.*)))?)*)\s*>)/msiU"array(&$this'do_strip_htmltags')$data);
  5102.             }
  5103.         }
  5104.  
  5105.         if ($this->strip_attributes)
  5106.         {
  5107.             foreach ($this->strip_attributes as $attrib)
  5108.             {
  5109.                 $data preg_replace('/ 'trim($attrib.'=("|&quot;)(\w|\s|=|-|:|;|\/|\.|\?|&|,|#|!|\(|\)|\'|&apos;|<|>|\+|{|})*("|&quot;)/i'''$data);
  5110.                 $data preg_replace('/ 'trim($attrib.'=(\'|&apos;)(\w|\s|=|-|:|;|\/|\.|\?|&|,|#|!|\(|\)|"|&quot;|<|>|\+|{|})*(\'|&apos;)/i'''$data);
  5111.                 $data preg_replace('/ 'trim($attrib.'=(\w|\s|=|-|:|;|\/|\.|\?|&|,|#|!|\(|\)|\+|{|})*/i'''$data);
  5112.             }
  5113.         }
  5114.  
  5115.         // Convert encoding
  5116.         $data SimplePie_Misc::change_encoding($data$this->input_encoding$this->output_encoding);
  5117.  
  5118.         return $data;
  5119.     }
  5120.  
  5121.     function do_strip_htmltags($match)
  5122.     {
  5123.         if ($this->encode_instead_of_strip)
  5124.         {
  5125.             if (isset($match[12]&& !in_array(strtolower($match[1])array('script''style')))
  5126.             {
  5127.                 return "&lt;$match[1]$match[2]&gt;$match[12]&lt;/$match[1]&gt;";
  5128.             }
  5129.             else if (isset($match[12]))
  5130.             {
  5131.                 return "&lt;$match[1]$match[2]&gt;&lt;/$match[1]&gt;";
  5132.             }
  5133.             else
  5134.             {
  5135.                 return "&lt;$match[1]$match[2]/&gt;";
  5136.             }
  5137.         }
  5138.         else
  5139.         {
  5140.             if (isset($match[12]&& !in_array(strtolower($match[1])array('script''style')))
  5141.             {
  5142.                 return $match[12];
  5143.             }
  5144.             else
  5145.             {
  5146.                 return '';
  5147.             }
  5148.         }
  5149.     }
  5150.  
  5151.     function replace_urls($data$raw_url false)
  5152.     {
  5153.         if (!empty($this->attribs['XML:BASE']))
  5154.         {
  5155.             $xmlbase $attribs['XML:BASE'];
  5156.         }
  5157.         else if (!empty($this->attribs['HTTP://WWW.W3.ORG/XML/1998/NAMESPACE:BASE']))
  5158.         {
  5159.             $xmlbase $this->attribs['HTTP://WWW.W3.ORG/XML/1998/NAMESPACE:BASE'];
  5160.         }
  5161.         if (!empty($xmlbase))
  5162.         {
  5163.             if (!empty($this->item_xmlbase))
  5164.             {
  5165.                 $xmlbase SimplePie_Misc::absolutize_url($xmlbase$this->item_xmlbase);
  5166.             }
  5167.             else
  5168.             {
  5169.                 $xmlbase SimplePie_Misc::absolutize_url($xmlbase$this->feed_xmlbase);
  5170.             }
  5171.         }
  5172.         else if (!empty($this->item_xmlbase))
  5173.         {
  5174.             $xmlbase $this->item_xmlbase;
  5175.         }
  5176.         else
  5177.         {
  5178.             $xmlbase $this->feed_xmlbase;
  5179.         }
  5180.  
  5181.         if ($raw_url)
  5182.         {
  5183.             return SimplePie_Misc::absolutize_url($data$xmlbase);
  5184.         }
  5185.         else
  5186.         {
  5187.             $attributes array(
  5188.                 'background',
  5189.                 'href',
  5190.                 'src',
  5191.                 'longdesc',
  5192.                 'usemap',
  5193.                 'codebase',
  5194.                 'data',
  5195.                 'classid',
  5196.                 'cite',
  5197.                 'action',
  5198.                 'profile',
  5199.                 'for'
  5200.             );
  5201.             foreach ($attributes as $attribute)
  5202.             {
  5203.                 if (preg_match("/$attribute='(.*)'/siU"$data[0]$attrib|| preg_match("/$attribute=\"(.*)\"/siU"$data[0]$attrib|| preg_match("/$attribute=(.*)[ |\/|>]/siU"$data[0]$attrib))
  5204.                 {
  5205.                     $new_tag str_replace($attrib[1]SimplePie_Misc::absolutize_url($attrib[1]$xmlbase)$attrib[0]);
  5206.                     $data[0str_replace($attrib[0]$new_tag$data[0]);
  5207.                 }
  5208.             }
  5209.             return $data[0];
  5210.         }
  5211.     }
  5212.  
  5213.     function entities_decode($data)
  5214.     {
  5215.         return preg_replace_callback('/&(#)?(x)?([0-9a-z]+);/mi'array(&$this'do_entites_decode')$data);
  5216.     }
  5217.  
  5218.     function do_entites_decode($data)
  5219.     {
  5220.         if (isset($this->cached_entities[$data[0]]))
  5221.         {
  5222.             return $this->cached_entities[$data[0]];
  5223.         }
  5224.         else
  5225.         {
  5226.             $return SimplePie_Misc::change_encoding(html_entity_decode($data[0]ENT_QUOTES)'ISO-8859-1'$this->input_encoding);
  5227.             if ($return == $data[0])
  5228.             {
  5229.                 $return SimplePie_Misc::change_encoding(preg_replace_callback('/&#([x]?[0-9a-f]+);/mi'array(&$this'replace_num_entity')$data[0])'UTF-8'$this->input_encoding);
  5230.             }
  5231.             $this->cached_entities[$data[0]] $return;
  5232.             return $return;
  5233.         }
  5234.     }
  5235.  
  5236.     function convert_entities($data)
  5237.     {
  5238.         return preg_replace_callback('/&#(x)?([0-9a-z]+);/mi'array(&$this'do_convert_entities')$data);
  5239.     }
  5240.  
  5241.     function do_convert_entities($data)
  5242.     {
  5243.         if (isset($this->cache_convert_entities[$data[0]]))
  5244.         {
  5245.             return $this->cache_convert_entities[$data[0]];
  5246.         }
  5247.         else if (isset($this->cached_entities[$data[0]]))
  5248.         {
  5249.             $return htmlentities($this->cached_entities[$data[0]]ENT_QUOTES'UTF-8');
  5250.         }
  5251.         else
  5252.         {
  5253.             $return htmlentities(preg_replace_callback('/&#([x]?[0-9a-f]+);/mi'array(&$this'replace_num_entity')$data[0])ENT_QUOTES'UTF-8');
  5254.         }
  5255.         $this->cache_convert_entities[$data[0]] $return;
  5256.         return $return;
  5257.     }
  5258.  
  5259.     /*
  5260.      * Escape numeric entities
  5261.      * From a PHP Manual note (on html_entity_decode())
  5262.      * Copyright (c) 2005 by "php dot net at c dash ovidiu dot tk",
  5263.      * "emilianomartinezluque at yahoo dot com" and "hurricane at cyberworldz dot org".
  5264.      *
  5265.      * This material may be distributed only subject to the terms and conditions set forth in
  5266.      * the Open Publication License, v1.0 or later (the latest version is presently available at
  5267.      * http://www.opencontent.org/openpub/).
  5268.      */
  5269.     function replace_num_entity($ord)
  5270.     {
  5271.         $ord $ord[1];
  5272.         if (preg_match('/^x([0-9a-f]+)$/i'$ord$match))
  5273.         {
  5274.             $ord hexdec($match[1]);
  5275.         }
  5276.         else
  5277.         {
  5278.             $ord intval($ord);
  5279.         }
  5280.  
  5281.         $no_bytes 0;
  5282.         $byte array();
  5283.         if ($ord 128)
  5284.         {
  5285.             return chr($ord);
  5286.         }
  5287.         if ($ord 2048)
  5288.         {
  5289.             $no_bytes 2;
  5290.         }
  5291.         else if ($ord 65536)
  5292.         {
  5293.             $no_bytes 3;
  5294.         }
  5295.         else if ($ord 1114112)
  5296.         {
  5297.             $no_bytes 4;
  5298.         }
  5299.         else
  5300.         {
  5301.             return;
  5302.         }
  5303.         switch ($no_bytes)
  5304.         {
  5305.             case 2:
  5306.                 $prefix array(31192);
  5307.                 break;
  5308.  
  5309.             case 3:
  5310.                 $prefix array(15224);
  5311.                 break;
  5312.  
  5313.             case 4:
  5314.                 $prefix array(7240);
  5315.                 break;
  5316.         }
  5317.  
  5318.         for ($i 0$i $no_bytes$i++)
  5319.         {
  5320.             $byte[$no_bytes-$i-1(($ord (63 pow(2,6*$i))) pow(2,6*$i)) 63 128;
  5321.         }
  5322.         $byte[0($byte[0$prefix[0]$prefix[1];
  5323.  
  5324.         $ret '';
  5325.         for ($i 0$i $no_bytes$i++)
  5326.         {
  5327.             $ret .= chr($byte[$i]);
  5328.         }
  5329.         return $ret;
  5330.     }
  5331.  
  5332.     function parse_date($date)
  5333.     {
  5334.         $military_timezone array('A' => '-0100''B' => '-0200''C' => '-0300''D' => '-0400''E' => '-0500''F' => '-0600''G' => '-0700''H' => '-0800''I' => '-0900''K' => '-1000''L' => '-1100''M' => '-1200''N' => '+0100''O' => '+0200''P' => '+0300''Q' => '+0400''R' => '+0500''S' => '+0600''T' => '+0700''U' => '+0800''V' => '+0900''W' => '+1000''X' => '+1100''Y' => '+1200''Z' => '-0000');
  5335.         $north_american_timezone array('GMT' => '-0000''EST' => '-0500''EDT' => '-0400''CST' => '-0600''CDT' => '-0500''MST' => '-0700''MDT' => '-0600''PST' => '-0800''PDT' => '-0700');
  5336.         if (preg_match('/([0-9]{2,4})-?([0-9]{2})-?([0-9]{2})T([0-9]{2}):?([0-9]{2})(:?([0-9]{2}(\.[0-9]*)?))?(UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|[a-z]|(\\+|-)[0-9]{4}|(\\+|-)[0-9]{2}:[0-9]{2})?/i'$date$matches))
  5337.         {
  5338.             if (!isset($matches[7]))
  5339.             {
  5340.                 $matches[7'';
  5341.             }
  5342.             if (!isset($matches[9]))
  5343.             {
  5344.                 $matches[9'';
  5345.             }
  5346.             $matches[7str_pad(round($matches[7])2'0'STR_PAD_LEFT);
  5347.             switch (strlen($matches[9]))
  5348.             {
  5349.                 case 0:
  5350.                     $timezone '';
  5351.                     break;
  5352.  
  5353.                 case 1:
  5354.                     $timezone $military_timezone[strtoupper($matches[9])];
  5355.                     break;
  5356.  
  5357.                 case 2:
  5358.                     $timezone '-0000';
  5359.                     break;
  5360.  
  5361.                 case 3:
  5362.                     $timezone $north_american_timezone[strtoupper($matches[9])];
  5363.                     break;
  5364.  
  5365.                 case 5:
  5366.                     $timezone $matches[9];
  5367.                     break;
  5368.  
  5369.                 case 6:
  5370.                     $timezone substr_replace($matches[9]''31);
  5371.                     break;
  5372.             }
  5373.             $date strtotime("$matches[1]-$matches[2]-$matches[3] $matches[4]:$matches[5]:$matches[7] $timezone");
  5374.         }
  5375.         else if (preg_match('/([0-9]{1,2})\s*(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s*([0-9]{2}|[0-9]{4})\s*([0-9]{2}):([0-9]{2})(:([0-9]{2}(\.[0-9]*)?))?\s*(UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|[a-z]|(\\+|-)[0-9]{4}|(\\+|-)[0-9]{2}:[0-9]{2})?/i'$date$matches))
  5376.         {
  5377.             $three_month array('Jan' => 1'Feb' => 2'Mar' => 3'Apr' => 4'May' => 5'Jun' => 6'Jul' => 7'Aug' => 8'Sep' => 9'Oct' => 10'Nov' => 11'Dec' => 12);
  5378.             $month $three_month[$matches[2]];
  5379.             if (strlen($matches[3]== 2)
  5380.             {
  5381.                 $year ($matches[370"20$matches[3]"19$matches[3]";
  5382.             }
  5383.             else
  5384.             {
  5385.                 $year $matches[3];
  5386.             }
  5387.             if (!isset($matches[7]))
  5388.             {
  5389.                 $matches[7'';
  5390.             }
  5391.             if (!isset($matches[9]))
  5392.             {
  5393.                 $matches[9'';
  5394.             }
  5395.             $second str_pad(round($matches[7])2'0'STR_PAD_LEFT);
  5396.             switch (strlen($matches[9]))
  5397.             {
  5398.                 case 0:
  5399.                     $timezone '';
  5400.                     break;
  5401.  
  5402.                 case 1:
  5403.                     $timezone $military_timezone[strtoupper($matches[9])];
  5404.                     break;
  5405.  
  5406.                 case 2:
  5407.                     $timezone '-0000';
  5408.                     break;
  5409.  
  5410.                 case 3:
  5411.                     $timezone $north_american_timezone[strtoupper($matches[9])];
  5412.                     break;
  5413.  
  5414.                 case 5:
  5415.                     $timezone $matches[9];
  5416.                     break;
  5417.  
  5418.                 case 6:
  5419.                     $timezone substr_replace($matches[9]''31);
  5420.                     break;
  5421.             }
  5422.             $date strtotime("$year-$month-$matches[1] $matches[4]:$matches[5]:$second $timezone");
  5423.         }
  5424.         else
  5425.         {
  5426.             $date strtotime($date);
  5427.         }
  5428.         if ($date !== false && $date !== -1)
  5429.         {
  5430.             return $date;
  5431.         }
  5432.         else
  5433.         {
  5434.             return false;
  5435.         }
  5436.     }
  5437. }
  5438.  
  5439. ?>

Documentation generated on Mon, 05 Mar 2007 21:25:08 +0000 by phpDocumentor 1.3.1