Make WordPress Core


Ignore:
Timestamp:
09/15/2009 04:33:59 PM (16 years ago)
Author:
ryan
Message:

Update SimplePie to 1.2. fixes #10392

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-simplepie.php

    r11657 r11938  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2008, Ryan Parman and Geoffrey Sneddon
     8 * Copyright (c) 2004-2009, Ryan Parman and Geoffrey Sneddon
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @package SimplePie
    36  * @version 1.1.3
    37  * @copyright 2004-2008 Ryan Parman, Geoffrey Sneddon
     36 * @version 1.2
     37 * @copyright 2004-2009 Ryan Parman, Geoffrey Sneddon
    3838 * @author Ryan Parman
    3939 * @author Geoffrey Sneddon
     
    5252 * SimplePie Version
    5353 */
    54 define('SIMPLEPIE_VERSION', '1.1.3');
     54define('SIMPLEPIE_VERSION', '1.2');
    5555
    5656/**
    5757 * SimplePie Build
    5858 */
    59 define('SIMPLEPIE_BUILD', 20081219);
     59define('SIMPLEPIE_BUILD', '20090627192103');
    6060
    6161/**
     
    243243
    244244/**
     245 * Don't change case
     246 */
     247define('SIMPLEPIE_SAME_CASE', 1);
     248
     249/**
     250 * Change to lowercase
     251 */
     252define('SIMPLEPIE_LOWERCASE', 2);
     253
     254/**
     255 * Change to uppercase
     256 */
     257define('SIMPLEPIE_UPPERCASE', 4);
     258
     259/**
    245260 * PCRE for HTML attributes
    246261 */
     
    377392 *
    378393 * @package SimplePie
    379  * @version "Razzleberry"
    380  * @copyright 2004-2007 Ryan Parman, Geoffrey Sneddon
    381  * @author Ryan Parman
    382  * @author Geoffrey Sneddon
    383  * @todo Option for type of fetching (cache, not modified header, fetch, etc.)
    384394 */
    385395class SimplePie
     
    638648     */
    639649    var $max_checked_feeds = 10;
     650
     651    /**
     652     * @var array All the feeds found during the autodiscovery process
     653     * @see SimplePie::get_all_discovered_feeds()
     654     * @access private
     655     */
     656    var $all_discovered_feeds = array();
    640657
    641658    /**
     
    14411458    function set_favicon_handler($page = false, $qs = 'i')
    14421459    {
    1443         if ($page != false)
     1460        if ($page !== false)
    14441461        {
    14451462            $this->favicon_handler = $page . '?' . $qs . '=';
     
    14601477    function set_image_handler($page = false, $qs = 'i')
    14611478    {
    1462         if ($page != false)
     1479        if ($page !== false)
    14631480        {
    14641481            $this->sanitize->set_image_handler($page . '?' . $qs . '=');
     
    14831500    function init()
    14841501    {
     1502        // Check absolute bare minimum requirements.
    14851503        if ((function_exists('version_compare') && version_compare(PHP_VERSION, '4.3.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre'))
    14861504        {
    14871505            return false;
    14881506        }
     1507        // Then check the xml extension is sane (i.e., libxml 2.7.x issue on PHP < 5.2.9 and libxml 2.7.0 to 2.7.2 on any version) if we don't have xmlreader.
     1508        elseif (!extension_loaded('xmlreader'))
     1509        {
     1510            static $xml_is_sane = null;
     1511            if ($xml_is_sane === null)
     1512            {
     1513                $parser_check = xml_parser_create();
     1514                xml_parse_into_struct($parser_check, '<foo>&amp;</foo>', $values);
     1515                xml_parser_free($parser_check);
     1516                $xml_is_sane = isset($values[0]['value']);
     1517            }
     1518            if (!$xml_is_sane)
     1519            {
     1520                return false;
     1521            }
     1522        }
     1523
    14891524        if (isset($_GET[$this->javascript]))
    14901525        {
    1491             if (function_exists('ob_gzhandler'))
    1492             {
    1493                 ob_start('ob_gzhandler');
    1494             }
    1495             header('Content-type: text/javascript; charset: UTF-8');
    1496             header('Cache-Control: must-revalidate');
    1497             header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
    1498             ?>
    1499 function embed_odeo(link) {
    1500     document.writeln('<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url='+link+'"></embed>');
    1501 }
    1502 
    1503 function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
    1504     if (placeholder != '') {
    1505         document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
    1506     }
    1507     else {
    1508         document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="true" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
    1509     }
    1510 }
    1511 
    1512 function embed_flash(bgcolor, width, height, link, loop, type) {
    1513     document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>');
    1514 }
    1515 
    1516 function embed_flv(width, height, link, placeholder, loop, player) {
    1517     document.writeln('<embed src="'+player+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="'+width+'" height="'+height+'" wmode="transparent" flashvars="file='+link+'&autostart=false&repeat='+loop+'&showdigits=true&showfsbutton=false"></embed>');
    1518 }
    1519 
    1520 function embed_wmedia(width, height, link) {
    1521     document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
    1522 }
    1523             <?php
     1526            SimplePie_Misc::output_javascript();
    15241527            exit;
    15251528        }
     
    15511554                    {
    15521555                        // If the cache is for an outdated build of SimplePie
    1553                         if (!isset($this->data['build']) || $this->data['build'] != SIMPLEPIE_BUILD)
     1556                        if (!isset($this->data['build']) || $this->data['build'] !== SIMPLEPIE_BUILD)
    15541557                        {
    15551558                            $cache->unlink();
     
    15571560                        }
    15581561                        // If we've hit a collision just rerun it with caching disabled
    1559                         elseif (isset($this->data['url']) && $this->data['url'] != $this->feed_url)
     1562                        elseif (isset($this->data['url']) && $this->data['url'] !== $this->feed_url)
    15601563                        {
    15611564                            $cache = false;
     
    15691572                            {
    15701573                                // Do not need to do feed autodiscovery yet.
    1571                                 if ($this->data['feed_url'] == $this->data['url'])
     1574                                if ($this->data['feed_url'] === $this->data['url'])
    15721575                                {
    15731576                                    $cache->unlink();
     
    15991602                                if ($file->success)
    16001603                                {
    1601                                     if ($file->status_code == 304)
     1604                                    if ($file->status_code === 304)
    16021605                                    {
    16031606                                        $cache->touch();
     
    16311634                if (!isset($file))
    16321635                {
    1633                     if (is_a($this->file, 'SimplePie_File') && $this->file->url == $this->feed_url)
     1636                    if (is_a($this->file, 'SimplePie_File') && $this->file->url === $this->feed_url)
    16341637                    {
    16351638                        $file =& $this->file;
     
    16411644                }
    16421645                // If the file connection has an error, set SimplePie::error to that and quit
    1643                 if (!$file->success)
     1646                if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)))
    16441647                {
    16451648                    $this->error = $file->error;
     
    16621665                        // We need to unset this so that if SimplePie::set_file() has been called that object is untouched
    16631666                        unset($file);
    1664                         if ($file = $locate->find($this->autodiscovery))
     1667                        if ($file = $locate->find($this->autodiscovery, $this->all_discovered_feeds))
    16651668                        {
    16661669                            if ($cache)
     
    16691672                                if (!$cache->save($this))
    16701673                                {
    1671                                     trigger_error("$cache->name is not writeable", E_USER_WARNING);
     1674                                    trigger_error("$this->cache_location is not writeable", E_USER_WARNING);
    16721675                                }
    16731676                                $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc');
     
    17871790                }
    17881791            }
    1789             // We have an error, just set SimplePie::error to it and quit
    1790             $this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
     1792            if(isset($parser))
     1793            {
     1794                // We have an error, just set SimplePie_Misc::error to it and quit
     1795                $this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
     1796            }
     1797            else
     1798            {
     1799                $this->error = 'The data could not be converted to UTF-8';
     1800            }
    17911801            SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
    17921802            return false;
     
    18831893                }
    18841894            }
    1885             elseif (isset($this->data['child']['']['rss']))
     1895            elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss']))
    18861896            {
    18871897                $this->data['type'] &= SIMPLEPIE_TYPE_RSS_ALL;
    1888                 if (isset($this->data['child']['']['rss'][0]['attribs']['']['version']))
    1889                 {
    1890                     switch (trim($this->data['child']['']['rss'][0]['attribs']['']['version']))
     1898                if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version']))
     1899                {
     1900                    switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version']))
    18911901                    {
    18921902                        case '0.91':
    18931903                            $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091;
    1894                             if (isset($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data']))
     1904                            if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data']))
    18951905                            {
    1896                                 switch (trim($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data']))
     1906                                switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data']))
    18971907                                {
    18981908                                    case '0':
     
    19631973                    $file =& new $this->file_class($favicon, $this->timeout / 10, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen);
    19641974
    1965                     if ($file->success && ($file->status_code == 200 || ($file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0)
     1975                    if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0)
    19661976                    {
    19671977                        $sniffer =& new $this->content_type_sniffer_class($file);
     
    19781988                            }
    19791989                        }
     1990                        // not an image
     1991                        else
     1992                        {
     1993                            return false;
     1994                        }
    19801995                    }
    19811996                }
     
    20222037        if ($this->feed_url !== null)
    20232038        {
    2024             return 'outlook' . $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI);
     2039            return $this->sanitize('outlook' . SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI);
    20252040        }
    20262041        else
     
    20672082        if ($this->subscribe_url())
    20682083        {
    2069             $return = $this->sanitize($feed_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->feed_url);
     2084            $return = $feed_url . rawurlencode($this->feed_url);
    20702085            if ($site_url !== null && $this->get_link() !== null)
    20712086            {
    2072                 $return .= $this->sanitize($site_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_link());
    2073             }
    2074             return $return;
     2087                $return .= $site_url . rawurlencode($this->get_link());
     2088            }
     2089            return $this->sanitize($return, SIMPLEPIE_CONSTRUCT_IRI);
    20752090        }
    20762091        else
     
    20872102    function subscribe_bloglines()
    20882103    {
    2089         return urldecode($this->subscribe_service('http://www.bloglines.com/sub/'));
     2104        return $this->subscribe_service('http://www.bloglines.com/sub/');
    20902105    }
    20912106
     
    21812196        if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
    21822197        {
    2183             if (isset($this->data['child']['']['rss'][0]['child'][$namespace][$tag]))
    2184             {
    2185                 return $this->data['child']['']['rss'][0]['child'][$namespace][$tag];
     2198            if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag]))
     2199            {
     2200                return $this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag];
    21862201            }
    21872202        }
     
    22212236        if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
    22222237        {
    2223             if ($channel = $this->get_feed_tags('', 'channel'))
     2238            if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'channel'))
    22242239            {
    22252240                if (isset($channel[0]['child'][$namespace][$tag]))
     
    22572272        if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
    22582273        {
    2259             if ($image = $this->get_channel_tags('', 'image'))
     2274            if ($image = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'image'))
    22602275            {
    22612276                if (isset($image[0]['child'][$namespace][$tag]))
     
    23072322            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
    23082323        }
    2309         elseif ($return = $this->get_channel_tags('', 'title'))
     2324        elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
    23102325        {
    23112326            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
     
    23612376            $categories[] =& new $this->category_class($term, $scheme, $label);
    23622377        }
    2363         foreach ((array) $this->get_channel_tags('', 'category') as $category)
    2364         {
    2365             $categories[] =& new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
     2378        foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
     2379        {
     2380            // This is really the label, but keep this as the term also for BC.
     2381            // Label will also work on retrieving because that falls back to term.
     2382            $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     2383            if (isset($category['attribs']['']['domain']))
     2384            {
     2385                $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
     2386            }
     2387            else
     2388            {
     2389                $scheme = null;
     2390            }
     2391            $categories[] =& new $this->category_class($term, $scheme, null);
    23662392        }
    23672393        foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
     
    25952621                $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
    25962622            }
    2597             if ($links = $this->get_channel_tags('', 'link'))
     2623            if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
    25982624            {
    25992625                $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
     
    26152641                    }
    26162642                }
    2617                 elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
     2643                elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
    26182644                {
    26192645                    $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
     
    26332659    }
    26342660
     2661    function get_all_discovered_feeds()
     2662    {
     2663        return $this->all_discovered_feeds;
     2664    }
     2665
    26352666    function get_description()
    26362667    {
     
    26512682            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
    26522683        }
    2653         elseif ($return = $this->get_channel_tags('', 'description'))
    2654         {
    2655             return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
     2684        elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
     2685        {
     2686            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
    26562687        }
    26572688        elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
     
    26872718            return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
    26882719        }
    2689         elseif ($return = $this->get_channel_tags('', 'copyright'))
     2720        elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright'))
    26902721        {
    26912722            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     
    27072738    function get_language()
    27082739    {
    2709         if ($return = $this->get_channel_tags('', 'language'))
     2740        if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language'))
    27102741        {
    27112742            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     
    27872818            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    27882819        }
    2789         elseif ($return = $this->get_image_tags('', 'title'))
     2820        elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
    27902821        {
    27912822            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     
    28272858            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
    28282859        }
    2829         elseif ($return = $this->get_image_tags('', 'url'))
     2860        elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url'))
    28302861        {
    28312862            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
     
    28472878            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
    28482879        }
    2849         elseif ($return = $this->get_image_tags('', 'link'))
     2880        elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
    28502881        {
    28512882            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
     
    28592890    function get_image_width()
    28602891    {
    2861         if ($return = $this->get_image_tags('', 'width'))
     2892        if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'width'))
    28622893        {
    28632894            return round($return[0]['data']);
    28642895        }
    2865         elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('', 'url'))
     2896        elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url'))
    28662897        {
    28672898            return 88.0;
     
    28752906    function get_image_height()
    28762907    {
    2877         if ($return = $this->get_image_tags('', 'height'))
     2908        if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'height'))
    28782909        {
    28792910            return round($return[0]['data']);
    28802911        }
    2881         elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('', 'url'))
     2912        elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url'))
    28822913        {
    28832914            return 31.0;
     
    28912922    function get_item_quantity($max = 0)
    28922923    {
     2924        $max = (int) $max;
    28932925        $qty = count($this->get_items());
    2894         if ($max == 0)
     2926        if ($max === 0)
    28952927        {
    28962928            return $qty;
     
    29172949    function get_items($start = 0, $end = 0)
    29182950    {
    2919         if (!empty($this->multifeed_objects))
    2920         {
    2921             return SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit);
    2922         }
    2923         elseif (!isset($this->data['items']))
    2924         {
    2925             if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry'))
    2926             {
    2927                 $keys = array_keys($items);
    2928                 foreach ($keys as $key)
    2929                 {
    2930                     $this->data['items'][] =& new $this->item_class($this, $items[$key]);
    2931                 }
    2932             }
    2933             if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry'))
    2934             {
    2935                 $keys = array_keys($items);
    2936                 foreach ($keys as $key)
    2937                 {
    2938                     $this->data['items'][] =& new $this->item_class($this, $items[$key]);
    2939                 }
    2940             }
    2941             if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item'))
    2942             {
    2943                 $keys = array_keys($items);
    2944                 foreach ($keys as $key)
    2945                 {
    2946                     $this->data['items'][] =& new $this->item_class($this, $items[$key]);
    2947                 }
    2948             }
    2949             if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item'))
    2950             {
    2951                 $keys = array_keys($items);
    2952                 foreach ($keys as $key)
    2953                 {
    2954                     $this->data['items'][] =& new $this->item_class($this, $items[$key]);
    2955                 }
    2956             }
    2957             if ($items = $this->get_channel_tags('', 'item'))
    2958             {
    2959                 $keys = array_keys($items);
    2960                 foreach ($keys as $key)
    2961                 {
    2962                     $this->data['items'][] =& new $this->item_class($this, $items[$key]);
     2951        if (!isset($this->data['items']))
     2952        {
     2953            if (!empty($this->multifeed_objects))
     2954            {
     2955                $this->data['items'] = SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit);
     2956            }
     2957            else
     2958            {
     2959                $this->data['items'] = array();
     2960                if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry'))
     2961                {
     2962                    $keys = array_keys($items);
     2963                    foreach ($keys as $key)
     2964                    {
     2965                        $this->data['items'][] =& new $this->item_class($this, $items[$key]);
     2966                    }
     2967                }
     2968                if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry'))
     2969                {
     2970                    $keys = array_keys($items);
     2971                    foreach ($keys as $key)
     2972                    {
     2973                        $this->data['items'][] =& new $this->item_class($this, $items[$key]);
     2974                    }
     2975                }
     2976                if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item'))
     2977                {
     2978                    $keys = array_keys($items);
     2979                    foreach ($keys as $key)
     2980                    {
     2981                        $this->data['items'][] =& new $this->item_class($this, $items[$key]);
     2982                    }
     2983                }
     2984                if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item'))
     2985                {
     2986                    $keys = array_keys($items);
     2987                    foreach ($keys as $key)
     2988                    {
     2989                        $this->data['items'][] =& new $this->item_class($this, $items[$key]);
     2990                    }
     2991                }
     2992                if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item'))
     2993                {
     2994                    $keys = array_keys($items);
     2995                    foreach ($keys as $key)
     2996                    {
     2997                        $this->data['items'][] =& new $this->item_class($this, $items[$key]);
     2998                    }
    29632999                }
    29643000            }
     
    29683004        {
    29693005            // If we want to order it by date, check if all items have a date, and then sort it
    2970             if ($this->order_by_date)
     3006            if ($this->order_by_date && empty($this->multifeed_objects))
    29713007            {
    29723008                if (!isset($this->data['ordered_items']))
     
    29963032
    29973033            // Slice the data as desired
    2998             if ($end == 0)
     3034            if ($end === 0)
    29993035            {
    30003036                return array_slice($items, $start);
     
    30113047    }
    30123048
     3049    /**
     3050     * @static
     3051     */
    30133052    function sort_items($a, $b)
    30143053    {
     
    30163055    }
    30173056
     3057    /**
     3058     * @static
     3059     */
    30183060    function merge_items($urls, $start = 0, $end = 0, $limit = 0)
    30193061    {
     
    30483090            }
    30493091
    3050             if ($end == 0)
     3092            if ($end === 0)
    30513093            {
    30523094                return array_slice($items, $start);
     
    31313173                return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    31323174            }
    3133             elseif ($return = $this->get_item_tags('', 'guid'))
     3175            elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
    31343176            {
    31353177                return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     
    31823224                $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
    31833225            }
    3184             elseif ($return = $this->get_item_tags('', 'title'))
     3226            elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
    31853227            {
    31863228                $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
     
    32163258            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
    32173259        }
    3218         elseif ($return = $this->get_item_tags('', 'description'))
     3260        elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
    32193261        {
    32203262            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
     
    33063348            $categories[] =& new $this->feed->category_class($term, $scheme, $label);
    33073349        }
    3308         foreach ((array) $this->get_item_tags('', 'category') as $category)
    3309         {
    3310             $categories[] =& new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
     3350        foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
     3351        {
     3352            // This is really the label, but keep this as the term also for BC.
     3353            // Label will also work on retrieving because that falls back to term.
     3354            $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     3355            if (isset($category['attribs']['']['domain']))
     3356            {
     3357                $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
     3358            }
     3359            else
     3360            {
     3361                $scheme = null;
     3362            }
     3363            $categories[] =& new $this->feed->category_class($term, $scheme, null);
    33113364        }
    33123365        foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
     
    34133466    }
    34143467
    3415     /**
    3416      * @todo Atom inheritance (item author, source author, feed author)
    3417      */
    34183468    function get_authors()
    34193469    {
     
    34633513            }
    34643514        }
    3465         if ($author = $this->get_item_tags('', 'author'))
     3515        if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author'))
    34663516        {
    34673517            $authors[] =& new $this->feed->author_class(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
     
    35423592                $this->data['date']['raw'] = $return[0]['data'];
    35433593            }
    3544             elseif ($return = $this->get_item_tags('', 'pubDate'))
     3594            elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate'))
    35453595            {
    35463596                $this->data['date']['raw'] = $return[0]['data'];
     
    36633713                $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
    36643714            }
    3665             if ($links = $this->get_item_tags('', 'link'))
     3715            if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
    36663716            {
    36673717                $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
    36683718            }
    3669             if ($links = $this->get_item_tags('', 'guid'))
    3670             {
    3671                 if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) == 'true')
     3719            if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
     3720            {
     3721                if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true')
    36723722                {
    36733723                    $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
     
    36903740                    }
    36913741                }
    3692                 elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
     3742                elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
    36933743                {
    36943744                    $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
     
    42564306                    $restriction_type = null;
    42574307                    $restriction_value = 'itunes';
    4258                     if (isset($restriction['data']) && strtolower($restriction['data']) == 'yes')
     4308                    if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes')
    42594309                    {
    42604310                        $restriction_relationship = 'deny';
     
    42924342                    $restriction_type = null;
    42934343                    $restriction_value = 'itunes';
    4294                     if (isset($restriction['data']) && strtolower($restriction['data']) == 'yes')
     4344                    if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes')
    42954345                    {
    42964346                        $restriction_relationship = 'deny';
     
    54035453            foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link)
    54045454            {
    5405                 if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] == 'enclosure')
     5455                if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure')
    54065456                {
    54075457                    // Attributes
     
    54385488            foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link)
    54395489            {
    5440                 if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] == 'enclosure')
     5490                if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure')
    54415491                {
    54425492                    // Attributes
     
    54715521            }
    54725522
    5473             if ($enclosure = $this->get_item_tags('', 'enclosure'))
     5523            if ($enclosure = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure'))
    54745524            {
    54755525                if (isset($enclosure[0]['attribs']['']['url']))
     
    55065556            }
    55075557
    5508             if (sizeof($this->data['enclosures']) == 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width))
     5558            if (sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width))
    55095559            {
    55105560                // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
     
    55855635        if ($this->get_permalink() !== null)
    55865636        {
    5587             $return = $this->sanitize($item_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_permalink());
     5637            $return = $item_url . rawurlencode($this->get_permalink());
    55885638            if ($title_url !== null && $this->get_title() !== null)
    55895639            {
    5590                 $return .= $this->sanitize($title_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_title());
     5640                $return .= $title_url . rawurlencode($this->get_title());
    55915641            }
    55925642            if ($summary_url !== null && $this->get_description() !== null)
    55935643            {
    5594                 $return .= $this->sanitize($summary_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_description());
    5595             }
    5596             return $return;
     5644                $return .= $summary_url . rawurlencode($this->get_description());
     5645            }
     5646            return $this->sanitize($return, SIMPLEPIE_CONSTRUCT_IRI);
    55975647        }
    55985648        else
     
    57345784            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
    57355785        }
    5736         elseif ($return = $this->get_source_tags('', 'title'))
     5786        elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
    57375787        {
    57385788            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
     
    57885838            $categories[] =& new $this->item->feed->category_class($term, $scheme, $label);
    57895839        }
    5790         foreach ((array) $this->get_source_tags('', 'category') as $category)
    5791         {
    5792             $categories[] =& new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
     5840        foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
     5841        {
     5842            // This is really the label, but keep this as the term also for BC.
     5843            // Label will also work on retrieving because that falls back to term.
     5844            $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     5845            if (isset($category['attribs']['']['domain']))
     5846            {
     5847                $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
     5848            }
     5849            else
     5850            {
     5851                $scheme = null;
     5852            }
     5853            $categories[] =& new $this->item->feed->category_class($term, $scheme, null);
    57935854        }
    57945855        foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
     
    60226083                $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
    60236084            }
    6024             if ($links = $this->get_source_tags('', 'link'))
     6085            if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
    60256086            {
    60266087                $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
     
    60426103                    }
    60436104                }
    6044                 elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
     6105                elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
    60456106                {
    60466107                    $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
     
    60786139            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
    60796140        }
    6080         elseif ($return = $this->get_source_tags('', 'description'))
     6141        elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
    60816142        {
    60826143            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
     
    61146175            return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
    61156176        }
    6116         elseif ($return = $this->get_source_tags('', 'copyright'))
     6177        elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright'))
    61176178        {
    61186179            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     
    61346195    function get_language()
    61356196    {
    6136         if ($return = $this->get_source_tags('', 'language'))
     6197        if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language'))
    61376198        {
    61386199            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     
    69336994
    69346995        // Process values for 'auto'
    6935         if ($width == 'auto')
    6936         {
    6937             if ($mime == 'video')
    6938             {
    6939                 if ($height == 'auto')
     6996        if ($width === 'auto')
     6997        {
     6998            if ($mime === 'video')
     6999            {
     7000                if ($height === 'auto')
    69407001                {
    69417002                    $width = 480;
     
    69567017        }
    69577018
    6958         if ($height == 'auto')
    6959         {
    6960             if ($mime == 'audio')
     7019        if ($height === 'auto')
     7020        {
     7021            if ($mime === 'audio')
    69617022            {
    69627023                $height = 0;
    69637024            }
    6964             elseif ($mime == 'video')
    6965             {
    6966                 if ($width == 'auto')
     7025            elseif ($mime === 'video')
     7026            {
     7027                if ($width === 'auto')
    69677028                {
    69687029                    if ($widescreen)
     
    69897050            }
    69907051        }
    6991         elseif ($mime == 'audio')
     7052        elseif ($mime === 'audio')
    69927053        {
    69937054            $height = 0;
     
    69957056
    69967057        // Set proper placeholder value
    6997         if ($mime == 'audio')
     7058        if ($mime === 'audio')
    69987059        {
    69997060            $placeholder = $audio;
    70007061        }
    7001         elseif ($mime == 'video')
     7062        elseif ($mime === 'video')
    70027063        {
    70037064            $placeholder = $video;
     
    70187079
    70197080        // Odeo Feed MP3's
    7020         if ($handler == 'odeo')
     7081        if ($handler === 'odeo')
    70217082        {
    70227083            if ($native)
     
    70317092
    70327093        // Flash
    7033         elseif ($handler == 'flash')
     7094        elseif ($handler === 'flash')
    70347095        {
    70357096            if ($native)
     
    70457106        // Flash Media Player file types.
    70467107        // Preferred handler for MP3 file types.
    7047         elseif ($handler == 'fmedia' || ($handler == 'mp3' && $mediaplayer != ''))
     7108        elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== ''))
    70487109        {
    70497110            $height += 20;
     
    70607121        // QuickTime 7 file types.  Need to test with QuickTime 6.
    70617122        // Only handle MP3's if the Flash Media Player is not present.
    7062         elseif ($handler == 'quicktime' || ($handler == 'mp3' && $mediaplayer == ''))
     7123        elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === ''))
    70637124        {
    70647125            $height += 16;
    70657126            if ($native)
    70667127            {
    7067                 if ($placeholder != ""){
     7128                if ($placeholder !== '')
     7129                {
    70687130                    $embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" href=\"" . $this->get_link() . "\" src=\"$placeholder\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"false\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>";
    70697131                }
    7070                 else {
     7132                else
     7133                {
    70717134                    $embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" src=\"" . $this->get_link() . "\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"true\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>";
    70727135                }
     
    70797142
    70807143        // Windows Media
    7081         elseif ($handler == 'wmedia')
     7144        elseif ($handler === 'wmedia')
    70827145        {
    70837146            $height += 45;
     
    71017164    {
    71027165        // If it's Odeo, let's get it out of the way.
    7103         if (substr(strtolower($this->get_link()), 0, 15) == 'http://odeo.com')
     7166        if (substr(strtolower($this->get_link()), 0, 15) === 'http://odeo.com')
    71047167        {
    71057168            return 'odeo';
     
    76297692
    76307693                $this->headers = curl_exec($fp);
    7631                 if (curl_errno($fp) == 23 || curl_errno($fp) == 61)
     7694                if (curl_errno($fp) === 23 || curl_errno($fp) === 61)
    76327695                {
    76337696                    curl_setopt($fp, CURLOPT_ENCODING, 'none');
     
    76517714                        $this->body = $parser->body;
    76527715                        $this->status_code = $parser->status_code;
    7653                         if (($this->status_code == 300 || $this->status_code == 301 || $this->status_code == 302 || $this->status_code == 303 || $this->status_code == 307 || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
     7716                        if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
    76547717                        {
    76557718                            $this->redirects++;
     
    76647727                $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
    76657728                $url_parts = parse_url($url);
    7666                 if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) == 'https')
     7729                if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https')
    76677730                {
    76687731                    $url_parts['host'] = "ssl://$url_parts[host]";
     
    77327795                            $this->body = $parser->body;
    77337796                            $this->status_code = $parser->status_code;
    7734                             if (($this->status_code == 300 || $this->status_code == 301 || $this->status_code == 302 || $this->status_code == 303 || $this->status_code == 307 || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
     7797                            if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
    77357798                            {
    77367799                                $this->redirects++;
     
    84398502            {
    84408503                // Get the length of the filename
    8441                 $len = strspn($this->compressed_data, "\x00", $this->position);
     8504                $len = strcspn($this->compressed_data, "\x00", $this->position);
    84428505
    84438506                // Check the length of the string is still valid
     
    84598522            {
    84608523                // Get the length of the comment
    8461                 $len = strspn($this->compressed_data, "\x00", $this->position);
     8524                $len = strcspn($this->compressed_data, "\x00", $this->position);
    84628525
    84638526                // Check the length of the string is still valid
     
    85578620    function create($location, $filename, $extension)
    85588621    {
    8559         return new SimplePie_Cache_File($location, $filename, $extension);
     8622        $location_iri =& new SimplePie_IRI($location);
     8623        switch ($location_iri->get_scheme())
     8624        {
     8625            case 'mysql':
     8626                if (extension_loaded('mysql'))
     8627                {
     8628                    return new SimplePie_Cache_MySQL($location_iri, $filename, $extension);
     8629                }
     8630                break;
     8631
     8632            default:
     8633                return new SimplePie_Cache_File($location, $filename, $extension);
     8634        }
    85608635    }
    85618636}
     
    85718646    {
    85728647        $this->location = $location;
    8573         $this->filename = rawurlencode($filename);
    8574         $this->extension = rawurlencode($extension);
    8575         $this->name = "$location/$this->filename.$this->extension";
     8648        $this->filename = $filename;
     8649        $this->extension = $extension;
     8650        $this->name = "$this->location/$this->filename.$this->extension";
    85768651    }
    85778652
     
    86428717}
    86438718
     8719class SimplePie_Cache_DB
     8720{
     8721    function prepare_simplepie_object_for_cache($data)
     8722    {
     8723        $items = $data->get_items();
     8724        $items_by_id = array();
     8725
     8726        if (!empty($items))
     8727        {
     8728            foreach ($items as $item)
     8729            {
     8730                $items_by_id[$item->get_id()] = $item;
     8731            }
     8732
     8733            if (count($items_by_id) !== count($items))
     8734            {
     8735                $items_by_id = array();
     8736                foreach ($items as $item)
     8737                {
     8738                    $items_by_id[$item->get_id(true)] = $item;
     8739                }
     8740            }
     8741
     8742            if (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]))
     8743            {
     8744                $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0];
     8745            }
     8746            elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]))
     8747            {
     8748                $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0];
     8749            }
     8750            elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]))
     8751            {
     8752                $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0];
     8753            }
     8754            elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0]))
     8755            {
     8756                $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0];
     8757            }
     8758            else
     8759            {
     8760                $channel = null;
     8761            }
     8762
     8763            if ($channel !== null)
     8764            {
     8765                if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry']))
     8766                {
     8767                    unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry']);
     8768                }
     8769                if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry']))
     8770                {
     8771                    unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry']);
     8772                }
     8773                if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']))
     8774                {
     8775                    unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']);
     8776                }
     8777                if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']))
     8778                {
     8779                    unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']);
     8780                }
     8781                if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item']))
     8782                {
     8783                    unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item']);
     8784                }
     8785            }
     8786            if (isset($data->data['items']))
     8787            {
     8788                unset($data->data['items']);
     8789            }
     8790            if (isset($data->data['ordered_items']))
     8791            {
     8792                unset($data->data['ordered_items']);
     8793            }
     8794        }
     8795        return array(serialize($data->data), $items_by_id);
     8796    }
     8797}
     8798
     8799class SimplePie_Cache_MySQL extends SimplePie_Cache_DB
     8800{
     8801    var $mysql;
     8802    var $options;
     8803    var $id;
     8804
     8805    function SimplePie_Cache_MySQL($mysql_location, $name, $extension)
     8806    {
     8807        $host = $mysql_location->get_host();
     8808        if (SimplePie_Misc::stripos($host, 'unix(') === 0 && substr($host, -1) === ')')
     8809        {
     8810            $server = ':' . substr($host, 5, -1);
     8811        }
     8812        else
     8813        {
     8814            $server = $host;
     8815            if ($mysql_location->get_port() !== null)
     8816            {
     8817                $server .= ':' . $mysql_location->get_port();
     8818            }
     8819        }
     8820
     8821        if (strpos($mysql_location->get_userinfo(), ':') !== false)
     8822        {
     8823            list($username, $password) = explode(':', $mysql_location->get_userinfo(), 2);
     8824        }
     8825        else
     8826        {
     8827            $username = $mysql_location->get_userinfo();
     8828            $password = null;
     8829        }
     8830
     8831        if ($this->mysql = mysql_connect($server, $username, $password))
     8832        {
     8833            $this->id = $name . $extension;
     8834            $this->options = SimplePie_Misc::parse_str($mysql_location->get_query());
     8835            if (!isset($this->options['prefix'][0]))
     8836            {
     8837                $this->options['prefix'][0] = '';
     8838            }
     8839
     8840            if (mysql_select_db(ltrim($mysql_location->get_path(), '/'))
     8841                && mysql_query('SET NAMES utf8')
     8842                && ($query = mysql_unbuffered_query('SHOW TABLES')))
     8843            {
     8844                $db = array();
     8845                while ($row = mysql_fetch_row($query))
     8846                {
     8847                    $db[] = $row[0];
     8848                }
     8849
     8850                if (!in_array($this->options['prefix'][0] . 'cache_data', $db))
     8851                {
     8852                    if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . 'cache_data` (`id` TEXT CHARACTER SET utf8 NOT NULL, `items` SMALLINT NOT NULL DEFAULT 0, `data` BLOB NOT NULL, `mtime` INT UNSIGNED NOT NULL, UNIQUE (`id`(125)))'))
     8853                    {
     8854                        $this->mysql = null;
     8855                    }
     8856                }
     8857
     8858                if (!in_array($this->options['prefix'][0] . 'items', $db))
     8859                {
     8860                    if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` TEXT CHARACTER SET utf8 NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))'))
     8861                    {
     8862                        $this->mysql = null;
     8863                    }
     8864                }
     8865            }
     8866            else
     8867            {
     8868                $this->mysql = null;
     8869            }
     8870        }
     8871    }
     8872
     8873    function save($data)
     8874    {
     8875        if ($this->mysql)
     8876        {
     8877            $feed_id = "'" . mysql_real_escape_string($this->id) . "'";
     8878
     8879            if (is_a($data, 'SimplePie'))
     8880            {
     8881                if (SIMPLEPIE_PHP5)
     8882                {
     8883                    // This keyword needs to defy coding standards for PHP4 compatibility
     8884                    $data = clone($data);
     8885                }
     8886
     8887                $prepared = $this->prepare_simplepie_object_for_cache($data);
     8888
     8889                if ($query = mysql_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = ' . $feed_id, $this->mysql))
     8890                {
     8891                    if (mysql_num_rows($query))
     8892                    {
     8893                        $items = count($prepared[1]);
     8894                        if ($items)
     8895                        {
     8896                            $sql = 'UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `items` = ' . $items . ', `data` = \'' . mysql_real_escape_string($prepared[0]) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id;
     8897                        }
     8898                        else
     8899                        {
     8900                            $sql = 'UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `data` = \'' . mysql_real_escape_string($prepared[0]) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id;
     8901                        }
     8902
     8903                        if (!mysql_query($sql, $this->mysql))
     8904                        {
     8905                            return false;
     8906                        }
     8907                    }
     8908                    elseif (!mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(' . $feed_id . ', ' . count($prepared[1]) . ', \'' . mysql_real_escape_string($prepared[0]) . '\', ' . time() . ')', $this->mysql))
     8909                    {
     8910                        return false;
     8911                    }
     8912
     8913                    $ids = array_keys($prepared[1]);
     8914                    if (!empty($ids))
     8915                    {
     8916                        foreach ($ids as $id)
     8917                        {
     8918                            $database_ids[] = mysql_real_escape_string($id);
     8919                        }
     8920
     8921                        if ($query = mysql_unbuffered_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'items` WHERE `id` = \'' . implode('\' OR `id` = \'', $database_ids) . '\' AND `feed_id` = ' . $feed_id, $this->mysql))
     8922                        {
     8923                            $existing_ids = array();
     8924                            while ($row = mysql_fetch_row($query))
     8925                            {
     8926                                $existing_ids[] = $row[0];
     8927                            }
     8928
     8929                            $new_ids = array_diff($ids, $existing_ids);
     8930
     8931                            foreach ($new_ids as $new_id)
     8932                            {
     8933                                if (!($date = $prepared[1][$new_id]->get_date('U')))
     8934                                {
     8935                                    $date = time();
     8936                                }
     8937
     8938                                if (!mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'items` (`feed_id`, `id`, `data`, `posted`) VALUES(' . $feed_id . ', \'' . mysql_real_escape_string($new_id) . '\', \'' . mysql_real_escape_string(serialize($prepared[1][$new_id]->data)) . '\', ' . $date . ')', $this->mysql))
     8939                                {
     8940                                    return false;
     8941                                }
     8942                            }
     8943                            return true;
     8944                        }
     8945                    }
     8946                    else
     8947                    {
     8948                        return true;
     8949                    }
     8950                }
     8951            }
     8952            elseif ($query = mysql_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = ' . $feed_id, $this->mysql))
     8953            {
     8954                if (mysql_num_rows($query))
     8955                {
     8956                    if (mysql_query('UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `items` = 0, `data` = \'' . mysql_real_escape_string(serialize($data)) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id, $this->mysql))
     8957                    {
     8958                        return true;
     8959                    }
     8960                }
     8961                elseif (mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(\'' . mysql_real_escape_string($this->id) . '\', 0, \'' . mysql_real_escape_string(serialize($data)) . '\', ' . time() . ')', $this->mysql))
     8962                {
     8963                    return true;
     8964                }
     8965            }
     8966        }
     8967        return false;
     8968    }
     8969
     8970    function load()
     8971    {
     8972        if ($this->mysql && ($query = mysql_query('SELECT `items`, `data` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($row = mysql_fetch_row($query)))
     8973        {
     8974            $data = unserialize($row[1]);
     8975
     8976            if (isset($this->options['items'][0]))
     8977            {
     8978                $items = (int) $this->options['items'][0];
     8979            }
     8980            else
     8981            {
     8982                $items = (int) $row[0];
     8983            }
     8984
     8985            if ($items !== 0)
     8986            {
     8987                if (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]))
     8988                {
     8989                    $feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0];
     8990                }
     8991                elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]))
     8992                {
     8993                    $feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0];
     8994                }
     8995                elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]))
     8996                {
     8997                    $feed =& $data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0];
     8998                }
     8999                elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]))
     9000                {
     9001                    $feed =& $data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0];
     9002                }
     9003                else
     9004                {
     9005                    $feed = null;
     9006                }
     9007
     9008                if ($feed !== null)
     9009                {
     9010                    $sql = 'SELECT `data` FROM `' . $this->options['prefix'][0] . 'items` WHERE `feed_id` = \'' . mysql_real_escape_string($this->id) . '\' ORDER BY `posted` DESC';
     9011                    if ($items > 0)
     9012                    {
     9013                        $sql .= ' LIMIT ' . $items;
     9014                    }
     9015
     9016                    if ($query = mysql_unbuffered_query($sql, $this->mysql))
     9017                    {
     9018                        while ($row = mysql_fetch_row($query))
     9019                        {
     9020                            $feed['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'][] = unserialize($row[0]);
     9021                        }
     9022                    }
     9023                    else
     9024                    {
     9025                        return false;
     9026                    }
     9027                }
     9028            }
     9029            return $data;
     9030        }
     9031        return false;
     9032    }
     9033
     9034    function mtime()
     9035    {
     9036        if ($this->mysql && ($query = mysql_query('SELECT `mtime` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($row = mysql_fetch_row($query)))
     9037        {
     9038            return $row[0];
     9039        }
     9040        else
     9041        {
     9042            return false;
     9043        }
     9044    }
     9045
     9046    function touch()
     9047    {
     9048        if ($this->mysql && ($query = mysql_query('UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `mtime` = ' . time() . ' WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && mysql_affected_rows($this->mysql))
     9049        {
     9050            return true;
     9051        }
     9052        else
     9053        {
     9054            return false;
     9055        }
     9056    }
     9057
     9058    function unlink()
     9059    {
     9060        if ($this->mysql && ($query = mysql_query('DELETE FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($query2 = mysql_query('DELETE FROM `' . $this->options['prefix'][0] . 'items` WHERE `feed_id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)))
     9061        {
     9062            return true;
     9063        }
     9064        else
     9065        {
     9066            return false;
     9067        }
     9068    }
     9069}
     9070
    86449071class SimplePie_Misc
    86459072{
     
    86749101    function absolutize_url($relative, $base)
    86759102    {
    8676         if ($relative !== '')
    8677         {
    8678             $relative = SimplePie_Misc::parse_url($relative);
    8679             if ($relative['scheme'] !== '')
    8680             {
    8681                 $target = $relative;
    8682             }
    8683             elseif ($base !== '')
    8684             {
    8685                 $base = SimplePie_Misc::parse_url($base);
    8686                 $target = SimplePie_Misc::parse_url('');
    8687                 if ($relative['authority'] !== '')
    8688                 {
    8689                     $target = $relative;
    8690                     $target['scheme'] = $base['scheme'];
    8691                 }
    8692                 else
    8693                 {
    8694                     $target['scheme'] = $base['scheme'];
    8695                     $target['authority'] = $base['authority'];
    8696                     if ($relative['path'] !== '')
    8697                     {
    8698                         if (strpos($relative['path'], '/') === 0)
    8699                         {
    8700                             $target['path'] = $relative['path'];
    8701                         }
    8702                         elseif ($base['authority'] !== '' && $base['path'] === '')
    8703                         {
    8704                             $target['path'] = '/' . $relative['path'];
    8705                         }
    8706                         elseif (($last_segment = strrpos($base['path'], '/')) !== false)
    8707                         {
    8708                             $target['path'] = substr($base['path'], 0, $last_segment + 1) . $relative['path'];
    8709                         }
    8710                         else
    8711                         {
    8712                             $target['path'] = $relative['path'];
    8713                         }
    8714                         $target['query'] = $relative['query'];
    8715                     }
    8716                     else
    8717                     {
    8718                         $target['path'] = $base['path'];
    8719                         if ($relative['query'] !== '')
    8720                         {
    8721                             $target['query'] = $relative['query'];
    8722                         }
    8723                         elseif ($base['query'] !== '')
    8724                         {
    8725                             $target['query'] = $base['query'];
    8726                         }
    8727                     }
    8728                 }
    8729                 $target['fragment'] = $relative['fragment'];
    8730             }
    8731             else
    8732             {
    8733                 // No base URL, just return the relative URL
    8734                 $target = $relative;
    8735             }
    8736             $return = SimplePie_Misc::compress_parse_url($target['scheme'], $target['authority'], $target['path'], $target['query'], $target['fragment']);
    8737         }
    8738         else
    8739         {
    8740             $return = $base;
    8741         }
    8742         $return = SimplePie_Misc::normalize_url($return);
    8743         return $return;
     9103        $iri = SimplePie_IRI::absolutize(new SimplePie_IRI($base), $relative);
     9104        return $iri->get_iri();
    87449105    }
    87459106
     
    87479108    {
    87489109        $output = '';
    8749         while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input == '.' || $input == '..')
     9110        while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..')
    87509111        {
    87519112            // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise,
     
    87639124                $input = substr_replace($input, '/', 0, 3);
    87649125            }
    8765             elseif ($input == '/.')
     9126            elseif ($input === '/.')
    87669127            {
    87679128                $input = '/';
     
    87739134                $output = substr_replace($output, '', strrpos($output, '/'));
    87749135            }
    8775             elseif ($input == '/..')
     9136            elseif ($input === '/..')
    87769137            {
    87779138                $input = '/';
     
    87799140            }
    87809141            // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise,
    8781             elseif ($input == '.' || $input == '..')
     9142            elseif ($input === '.' || $input === '..')
    87829143            {
    87839144                $input = '';
     
    88239184                    for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++)
    88249185                    {
    8825                         if (count($attribs[$j]) == 2)
     9186                        if (count($attribs[$j]) === 2)
    88269187                        {
    88279188                            $attribs[$j][2] = $attribs[$j][1];
     
    88569217    function error($message, $level, $file, $line)
    88579218    {
    8858         switch ($level)
    8859         {
    8860             case E_USER_ERROR:
    8861                 $note = 'PHP Error';
    8862                 break;
    8863             case E_USER_WARNING:
    8864                 $note = 'PHP Warning';
    8865                 break;
    8866             case E_USER_NOTICE:
    8867                 $note = 'PHP Notice';
    8868                 break;
    8869             default:
    8870                 $note = 'Unknown Error';
    8871                 break;
    8872         }
    8873         error_log("$note: $message in $file on line $line", 0);
     9219        if ((ini_get('error_reporting') & $level) > 0)
     9220        {
     9221            switch ($level)
     9222            {
     9223                case E_USER_ERROR:
     9224                    $note = 'PHP Error';
     9225                    break;
     9226                case E_USER_WARNING:
     9227                    $note = 'PHP Warning';
     9228                    break;
     9229                case E_USER_NOTICE:
     9230                    $note = 'PHP Notice';
     9231                    break;
     9232                default:
     9233                    $note = 'Unknown Error';
     9234                    break;
     9235            }
     9236            error_log("$note: $message in $file on line $line", 0);
     9237        }
    88749238        return $message;
    88759239    }
     
    89239287        $url = SimplePie_Misc::normalize_url($url);
    89249288        $parsed = SimplePie_Misc::parse_url($url);
    8925         if ($parsed['scheme'] !== '' && $parsed['scheme'] != 'http' && $parsed['scheme'] != 'https')
     9289        if ($parsed['scheme'] !== '' && $parsed['scheme'] !== 'http' && $parsed['scheme'] !== 'https')
    89269290        {
    89279291            return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http);
     
    89339297        }
    89349298
    8935         if ($http == 2 && $parsed['scheme'] !== '')
     9299        if ($http === 2 && $parsed['scheme'] !== '')
    89369300        {
    89379301            return "feed:$url";
    89389302        }
    8939         elseif ($http == 3 && strtolower($parsed['scheme']) == 'http')
     9303        elseif ($http === 3 && strtolower($parsed['scheme']) === 'http')
    89409304        {
    89419305            return substr_replace($url, 'podcast', 0, 4);
    89429306        }
    8943         elseif ($http == 4 && strtolower($parsed['scheme']) == 'http')
     9307        elseif ($http === 4 && strtolower($parsed['scheme']) === 'http')
    89449308        {
    89459309            return substr_replace($url, 'itpc', 0, 4);
     
    89539317    function parse_url($url)
    89549318    {
    8955         preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/', $url, $match);
    8956         for ($i = count($match); $i <= 9; $i++)
    8957         {
    8958             $match[$i] = '';
    8959         }
    8960         return array('scheme' => $match[2], 'authority' => $match[4], 'path' => $match[5], 'query' => $match[7], 'fragment' => $match[9]);
     9319        $iri =& new SimplePie_IRI($url);
     9320        return array(
     9321            'scheme' => (string) $iri->get_scheme(),
     9322            'authority' => (string) $iri->get_authority(),
     9323            'path' => (string) $iri->get_path(),
     9324            'query' => (string) $iri->get_query(),
     9325            'fragment' => (string) $iri->get_fragment()
     9326        );
    89619327    }
    89629328
    89639329    function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '')
    89649330    {
    8965         $return = '';
    8966         if ($scheme !== '')
    8967         {
    8968             $return .= "$scheme:";
    8969         }
    8970         if ($authority !== '')
    8971         {
    8972             $return .= "//$authority";
    8973         }
    8974         if ($path !== '')
    8975         {
    8976             $return .= $path;
    8977         }
    8978         if ($query !== '')
    8979         {
    8980             $return .= "?$query";
    8981         }
    8982         if ($fragment !== '')
    8983         {
    8984             $return .= "#$fragment";
    8985         }
    8986         return $return;
     9331        $iri =& new SimplePie_IRI('');
     9332        $iri->set_scheme($scheme);
     9333        $iri->set_authority($authority);
     9334        $iri->set_path($path);
     9335        $iri->set_query($query);
     9336        $iri->set_fragment($fragment);
     9337        return $iri->get_iri();
    89879338    }
    89889339
    89899340    function normalize_url($url)
    89909341    {
    8991         $url = preg_replace_callback('/%([0-9A-Fa-f]{2})/', array('SimplePie_Misc', 'percent_encoding_normalization'), $url);
    8992         $url = SimplePie_Misc::parse_url($url);
    8993         $url['scheme'] = strtolower($url['scheme']);
    8994         if ($url['authority'] !== '')
    8995         {
    8996             $url['authority'] = strtolower($url['authority']);
    8997             $url['path'] = SimplePie_Misc::remove_dot_segments($url['path']);
    8998         }
    8999         return SimplePie_Misc::compress_parse_url($url['scheme'], $url['authority'], $url['path'], $url['query'], $url['fragment']);
     9342        $iri =& new SimplePie_IRI($url);
     9343        return $iri->get_iri();
    90009344    }
    90019345
     
    90039347    {
    90049348        $integer = hexdec($match[1]);
    9005         if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer == 0x2D || $integer == 0x2E || $integer == 0x5F || $integer == 0x7E)
     9349        if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E)
    90069350        {
    90079351            return chr($integer);
     
    90879431            return SimplePie_Misc::windows_1252_to_utf8($data);
    90889432        }
    9089         // This is second, as behaviour of this varies only with PHP version
    9090         elseif (function_exists('mb_convert_encoding') && ($return = @mb_convert_encoding($data, $output, $input)))
     9433        // This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported).
     9434        elseif (function_exists('mb_convert_encoding') && @mb_convert_encoding("\x80", 'UTF-16BE', $input) !== "\x00\x80" && ($return = @mb_convert_encoding($data, $output, $input)))
    90919435        {
    90929436            return $return;
     
    91069450    function encoding($charset)
    91079451    {
    9108         /* Character sets are case-insensitive, and also need some further
    9109         normalization in the real world (though we'll return them in the form given
    9110         in their registration). */
    9111         switch (strtolower(preg_replace('/[\x09-\x0D\x20-\x2F\x3A-\x40\x5B-\x60\x7B-\x7E]/', '', $charset)))
     9452        // Normalization from UTS #22
     9453        switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset)))
    91129454        {
    91139455            case 'adobestandardencoding':
     
    91209462
    91219463            case 'ami1251':
    9122             case 'ami1251':
    9123             case 'amiga1251':
    91249464            case 'amiga1251':
    91259465                return 'Amiga-1251';
     
    91359475            case 'asmo449':
    91369476            case 'csiso89asmo449':
     9477            case 'iso9036':
    91379478            case 'isoir89':
    9138             case 'iso9036':
    91399479                return 'ASMO_449';
    91409480
     
    91589498            case 'csiso4unitedkingdom':
    91599499            case 'gb':
     9500            case 'iso646gb':
    91609501            case 'isoir4':
    9161             case 'iso646gb':
    91629502            case 'uk':
    91639503                return 'BS_4730';
     
    91769516            case 'csaz243419851':
    91779517            case 'csiso121canadian1':
     9518            case 'iso646ca':
    91789519            case 'isoir121':
    9179             case 'iso646ca':
    91809520                return 'CSA_Z243.4-1985-1';
    91819521
     
    91839523            case 'csaz243419852':
    91849524            case 'csiso122canadian2':
     9525            case 'iso646ca2':
    91859526            case 'isoir122':
    9186             case 'iso646ca2':
    91879527                return 'CSA_Z243.4-1985-2';
    91889528
     
    92059545            case 'de':
    92069546            case 'din66003':
     9547            case 'iso646de':
    92079548            case 'isoir21':
    9208             case 'iso646de':
    92099549                return 'DIN_66003';
    92109550
     
    92159555            case 'csiso646danish':
    92169556            case 'dk':
    9217             case 'ds2089':
    92189557            case 'ds2089':
    92199558            case 'iso646dk':
     
    92889627            case 'csiso17spanish':
    92899628            case 'es':
     9629            case 'iso646es':
    92909630            case 'isoir17':
    9291             case 'iso646es':
    92929631                return 'ES';
    92939632
    92949633            case 'csiso85spanish2':
    92959634            case 'es2':
     9635            case 'iso646es2':
    92969636            case 'isoir85':
    9297             case 'iso646es2':
    92989637                return 'ES2';
    92999638
     
    93109649                return 'GB18030';
    93119650
     9651            case 'chinese':
    93129652            case 'cp936':
     9653            case 'csgb2312':
     9654            case 'csiso58gb231280':
     9655            case 'gb2312':
     9656            case 'gb231280':
    93139657            case 'gbk':
     9658            case 'isoir58':
    93149659            case 'ms936':
    93159660            case 'windows936':
    9316             case 'csgb2312':
    9317             case 'gb2312':
    9318             case 'chinese':
    9319             case 'csiso58gb231280':
    9320             case 'gb231280':
    9321             case 'isoir58':
    93229661                return 'GBK';
    93239662
     
    93259664            case 'csiso57gb1988':
    93269665            case 'gb198880':
     9666            case 'iso646cn':
    93279667            case 'isoir57':
    9328             case 'iso646cn':
    93299668                return 'GB_1988-80';
    93309669
     
    93849723                return 'IBM-Thai';
    93859724
    9386             case 'ccsid00858':
    9387             case 'cp00858':
    9388             case 'ibm00858':
     9725            case 'ccsid858':
     9726            case 'cp858':
     9727            case 'ibm858':
    93899728            case 'pcmultilingual850euro':
    93909729                return 'IBM00858';
    93919730
    9392             case 'ccsid00924':
    9393             case 'cp00924':
     9731            case 'ccsid924':
     9732            case 'cp924':
    93949733            case 'ebcdiclatin9euro':
    9395             case 'ibm00924':
     9734            case 'ibm924':
    93969735                return 'IBM00924';
    93979736
    9398             case 'ccsid01140':
    9399             case 'cp01140':
     9737            case 'ccsid1140':
     9738            case 'cp1140':
    94009739            case 'ebcdicus37euro':
    9401             case 'ibm01140':
     9740            case 'ibm1140':
    94029741                return 'IBM01140';
    94039742
    9404             case 'ccsid01141':
    9405             case 'cp01141':
     9743            case 'ccsid1141':
     9744            case 'cp1141':
    94069745            case 'ebcdicde273euro':
    9407             case 'ibm01141':
     9746            case 'ibm1141':
    94089747                return 'IBM01141';
    94099748
    9410             case 'ccsid01142':
    9411             case 'cp01142':
     9749            case 'ccsid1142':
     9750            case 'cp1142':
    94129751            case 'ebcdicdk277euro':
    94139752            case 'ebcdicno277euro':
    9414             case 'ibm01142':
     9753            case 'ibm1142':
    94159754                return 'IBM01142';
    94169755
    9417             case 'ccsid01143':
    9418             case 'cp01143':
     9756            case 'ccsid1143':
     9757            case 'cp1143':
    94199758            case 'ebcdicfi278euro':
    94209759            case 'ebcdicse278euro':
    9421             case 'ibm01143':
     9760            case 'ibm1143':
    94229761                return 'IBM01143';
    94239762
    9424             case 'ccsid01144':
    9425             case 'cp01144':
     9763            case 'ccsid1144':
     9764            case 'cp1144':
    94269765            case 'ebcdicit280euro':
    9427             case 'ibm01144':
     9766            case 'ibm1144':
    94289767                return 'IBM01144';
    94299768
    9430             case 'ccsid01145':
    9431             case 'cp01145':
     9769            case 'ccsid1145':
     9770            case 'cp1145':
    94329771            case 'ebcdices284euro':
    9433             case 'ibm01145':
     9772            case 'ibm1145':
    94349773                return 'IBM01145';
    94359774
    9436             case 'ccsid01146':
    9437             case 'cp01146':
     9775            case 'ccsid1146':
     9776            case 'cp1146':
    94389777            case 'ebcdicgb285euro':
    9439             case 'ibm01146':
     9778            case 'ibm1146':
    94409779                return 'IBM01146';
    94419780
    9442             case 'ccsid01147':
    9443             case 'cp01147':
     9781            case 'ccsid1147':
     9782            case 'cp1147':
    94449783            case 'ebcdicfr297euro':
    9445             case 'ibm01147':
     9784            case 'ibm1147':
    94469785                return 'IBM01147';
    94479786
    9448             case 'ccsid01148':
    9449             case 'cp01148':
     9787            case 'ccsid1148':
     9788            case 'cp1148':
    94509789            case 'ebcdicinternational500euro':
    9451             case 'ibm01148':
     9790            case 'ibm1148':
    94529791                return 'IBM01148';
    94539792
    9454             case 'ccsid01149':
    9455             case 'cp01149':
     9793            case 'ccsid1149':
     9794            case 'cp1149':
    94569795            case 'ebcdicis871euro':
    9457             case 'ibm01149':
     9796            case 'ibm1149':
    94589797                return 'IBM01149';
    94599798
    9460             case 'cp037':
    9461             case 'csibm037':
     9799            case 'cp37':
     9800            case 'csibm37':
    94629801            case 'ebcdiccpca':
    94639802            case 'ebcdiccpnl':
    94649803            case 'ebcdiccpus':
    94659804            case 'ebcdiccpwt':
    9466             case 'ibm037':
     9805            case 'ibm37':
    94679806                return 'IBM037';
    94689807
    9469             case 'cp038':
    9470             case 'csibm038':
     9808            case 'cp38':
     9809            case 'csibm38':
    94719810            case 'ebcdicint':
    9472             case 'ibm038':
     9811            case 'ibm38':
    94739812                return 'IBM038';
    94749813
     
    96129951
    96139952            case '861':
     9953            case 'cp861':
    96149954            case 'cpis':
    9615             case 'cp861':
    96169955            case 'csibm861':
    96179956            case 'ibm861':
     
    96479986                return 'IBM866';
    96489987
     9988            case 'cp868':
    96499989            case 'cpar':
    9650             case 'cp868':
    96519990            case 'csibm868':
    96529991            case 'ibm868':
     
    96549993
    96559994            case '869':
     9995            case 'cp869':
    96569996            case 'cpgr':
    9657             case 'cp869':
    96589997            case 'csibm869':
    96599998            case 'ibm869':
     
    971310052
    971410053            case 'ibm1047':
    9715             case 'ibm1047':
    971610054                return 'IBM1047';
    971710055
     
    976810106            case 'csisolatin2':
    976910107            case 'iso88592':
     10108            case 'iso885921987':
    977010109            case 'isoir101':
    9771             case 'iso88592':
    9772             case 'iso885921987':
    977310110            case 'l2':
    977410111            case 'latin2':
     
    978110118            case 'csisolatin3':
    978210119            case 'iso88593':
     10120            case 'iso885931988':
    978310121            case 'isoir109':
    9784             case 'iso88593':
    9785             case 'iso885931988':
    978610122            case 'l3':
    978710123            case 'latin3':
     
    979010126            case 'csisolatin4':
    979110127            case 'iso88594':
     10128            case 'iso885941988':
    979210129            case 'isoir110':
    9793             case 'iso88594':
    9794             case 'iso885941988':
    979510130            case 'l4':
    979610131            case 'latin4':
     
    980010135            case 'cyrillic':
    980110136            case 'iso88595':
     10137            case 'iso885951988':
    980210138            case 'isoir144':
    9803             case 'iso88595':
    9804             case 'iso885951988':
    980510139                return 'ISO-8859-5';
    980610140
     
    981010144            case 'ecma114':
    981110145            case 'iso88596':
     10146            case 'iso885961987':
    981210147            case 'isoir127':
    9813             case 'iso88596':
    9814             case 'iso885961987':
    981510148                return 'ISO-8859-6';
    981610149
    981710150            case 'csiso88596e':
    981810151            case 'iso88596e':
    9819             case 'iso88596e':
    982010152                return 'ISO-8859-6-E';
    982110153
    982210154            case 'csiso88596i':
    9823             case 'iso88596i':
    982410155            case 'iso88596i':
    982510156                return 'ISO-8859-6-I';
     
    983110162            case 'greek8':
    983210163            case 'iso88597':
     10164            case 'iso885971987':
    983310165            case 'isoir126':
    9834             case 'iso88597':
    9835             case 'iso885971987':
    983610166                return 'ISO-8859-7';
    983710167
     
    983910169            case 'hebrew':
    984010170            case 'iso88598':
     10171            case 'iso885981988':
    984110172            case 'isoir138':
    9842             case 'iso88598':
    9843             case 'iso885981988':
    984410173                return 'ISO-8859-8';
    984510174
    984610175            case 'csiso88598e':
    984710176            case 'iso88598e':
    9848             case 'iso88598e':
    984910177                return 'ISO-8859-8-E';
    985010178
    985110179            case 'csiso88598i':
    9852             case 'iso88598i':
    985310180            case 'iso88598i':
    985410181                return 'ISO-8859-8-I';
     
    986010187            case 'csisolatin6':
    986110188            case 'iso885910':
     10189            case 'iso8859101992':
    986210190            case 'isoir157':
    9863             case 'iso8859101992':
    986410191            case 'l6':
    986510192            case 'latin6':
     
    987010197
    987110198            case 'iso885914':
     10199            case 'iso8859141998':
    987210200            case 'isoceltic':
    987310201            case 'isoir199':
    9874             case 'iso885914':
    9875             case 'iso8859141998':
    987610202            case 'l8':
    987710203            case 'latin8':
     
    987910205
    988010206            case 'iso885915':
    9881             case 'iso885915':
    988210207            case 'latin9':
    988310208                return 'ISO-8859-15';
    988410209
    988510210            case 'iso885916':
     10211            case 'iso8859162001':
    988610212            case 'isoir226':
    9887             case 'iso885916':
    9888             case 'iso8859162001':
    988910213            case 'l10':
    989010214            case 'latin10':
     
    991710241            case 'csiso115481':
    991810242            case 'iso115481':
    9919             case 'iso115481':
    992010243            case 'isotr115481':
    992110244                return 'ISO-11548-1';
     
    995210275            case 'csiso2intlrefversion':
    995310276            case 'irv':
     10277            case 'iso646irv1983':
    995410278            case 'isoir2':
    9955             case 'iso646irv1983':
    995610279                return 'ISO_646.irv:1983';
    995710280
    995810281            case 'csiso2033':
    995910282            case 'e13b':
     10283            case 'iso20331983':
    996010284            case 'isoir98':
    9961             case 'iso20331983':
    996210285                return 'ISO_2033-1983';
    996310286
    996410287            case 'csiso5427cyrillic':
     10288            case 'iso5427':
    996510289            case 'isoir37':
    9966             case 'iso5427':
    996710290                return 'ISO_5427';
    996810291
    9969             case 'isoir54':
    997010292            case 'iso5427cyrillic1981':
    997110293            case 'iso54271981':
     10294            case 'isoir54':
    997210295                return 'ISO_5427:1981';
    997310296
    997410297            case 'csiso5428greek':
     10298            case 'iso54281980':
    997510299            case 'isoir55':
    9976             case 'iso54281980':
    997710300                return 'ISO_5428:1980';
    997810301
    997910302            case 'csiso6937add':
     10303            case 'iso6937225':
    998010304            case 'isoir152':
    9981             case 'iso6937225':
    998210305                return 'ISO_6937-2-25';
    998310306
    998410307            case 'csisotextcomm':
     10308            case 'iso69372add':
    998510309            case 'isoir142':
    9986             case 'iso69372add':
    998710310                return 'ISO_6937-2-add';
    998810311
    998910312            case 'csiso8859supp':
     10313            case 'iso8859supp':
    999010314            case 'isoir154':
    9991             case 'iso8859supp':
    999210315            case 'latin125':
    999310316                return 'ISO_8859-supp';
    999410317
    999510318            case 'csiso10367box':
     10319            case 'iso10367box':
    999610320            case 'isoir155':
    9997             case 'iso10367box':
    999810321                return 'ISO_10367-box';
    999910322
    1000010323            case 'csiso15italian':
     10324            case 'iso646it':
    1000110325            case 'isoir15':
    10002             case 'iso646it':
    1000310326            case 'it':
    1000410327                return 'IT';
     
    1000910332            case 'jisc62201969jp':
    1001010333            case 'katakana':
    10011             case 'x02017':
     10334            case 'x2017':
    1001210335                return 'JIS_C6220-1969-jp';
    1001310336
    1001410337            case 'csiso14jisc6220ro':
     10338            case 'iso646jp':
    1001510339            case 'isoir14':
    10016             case 'iso646jp':
    1001710340            case 'jisc62201969ro':
    1001810341            case 'jp':
     
    1002410347                return 'JIS_C6226-1978';
    1002510348
    10026             case 'csiso87jisx0208':
     10349            case 'csiso87jisx208':
    1002710350            case 'isoir87':
    1002810351            case 'jisc62261983':
    10029             case 'jisx02081983':
    10030             case 'x0208':
     10352            case 'jisx2081983':
     10353            case 'x208':
    1003110354                return 'JIS_C6226-1983';
    1003210355
     
    1003810361
    1003910362            case 'csiso92jisc62991984b':
     10363            case 'iso646jpocrb':
    1004010364            case 'isoir92':
    10041             case 'iso646jpocrb':
    1004210365            case 'jisc62291984b':
    1004310366            case 'jpocrb':
     
    1007210395
    1007310396            case 'cshalfwidthkatakana':
    10074             case 'jisx0201':
    10075             case 'x0201':
     10397            case 'jisx201':
     10398            case 'x201':
    1007610399                return 'JIS_X0201';
    1007710400
    10078             case 'csiso159jisx02121990':
     10401            case 'csiso159jisx2121990':
    1007910402            case 'isoir159':
    10080             case 'jisx02121990':
    10081             case 'x0212':
     10403            case 'jisx2121990':
     10404            case 'x212':
    1008210405                return 'JIS_X0212-1990';
    1008310406
    1008410407            case 'csiso141jusib1002':
     10408            case 'iso646yu':
    1008510409            case 'isoir141':
    10086             case 'iso646yu':
    1008710410            case 'js':
    1008810411            case 'jusib1002':
     
    1015810481            case 'csiso86hungarian':
    1015910482            case 'hu':
     10483            case 'iso646hu':
    1016010484            case 'isoir86':
    10161             case 'iso646hu':
    1016210485            case 'msz77953':
    1016310486                return 'MSZ_7795.3';
     
    1018510508            case 'csiso151cuba':
    1018610509            case 'cuba':
     10510            case 'iso646cu':
    1018710511            case 'isoir151':
    10188             case 'iso646cu':
    10189             case 'ncnc001081':
     10512            case 'ncnc1081':
    1019010513                return 'NC_NC00-10:81';
    1019110514
    1019210515            case 'csiso69french':
    1019310516            case 'fr':
     10517            case 'iso646fr':
    1019410518            case 'isoir69':
    10195             case 'iso646fr':
    1019610519            case 'nfz62010':
    1019710520                return 'NF_Z_62-010';
    1019810521
    1019910522            case 'csiso25french':
     10523            case 'iso646fr1':
    1020010524            case 'isoir25':
    10201             case 'iso646fr1':
    1020210525            case 'nfz620101973':
    1020310526                return 'NF_Z_62-010_(1973)';
     
    1020510528            case 'csiso60danishnorwegian':
    1020610529            case 'csiso60norwegian1':
     10530            case 'iso646no':
    1020710531            case 'isoir60':
    10208             case 'iso646no':
    1020910532            case 'no':
    1021010533            case 'ns45511':
     
    1021210535
    1021310536            case 'csiso61norwegian2':
     10537            case 'iso646no2':
    1021410538            case 'isoir61':
    10215             case 'iso646no2':
    1021610539            case 'no2':
    1021710540            case 'ns45512':
    1021810541                return 'NS_4551-2';
    1021910542
    10220             case 'osdebcdicdf03irv':
     10543            case 'osdebcdicdf3irv':
    1022110544                return 'OSD_EBCDIC_DF03_IRV';
    1022210545
    10223             case 'osdebcdicdf041':
     10546            case 'osdebcdicdf41':
    1022410547                return 'OSD_EBCDIC_DF04_1';
    1022510548
    10226             case 'osdebcdicdf0415':
     10549            case 'osdebcdicdf415':
    1022710550                return 'OSD_EBCDIC_DF04_15';
    1022810551
     
    1023610559
    1023710560            case 'csiso16portuguese':
     10561            case 'iso646pt':
    1023810562            case 'isoir16':
    10239             case 'iso646pt':
    1024010563            case 'pt':
    1024110564                return 'PT';
    1024210565
    1024310566            case 'csiso84portuguese2':
     10567            case 'iso646pt2':
    1024410568            case 'isoir84':
    10245             case 'iso646pt2':
    1024610569            case 'pt2':
    1024710570                return 'PT2';
     
    1025910582            case 'csiso10swedish':
    1026010583            case 'fi':
    10261             case 'isoir10':
    1026210584            case 'iso646fi':
    1026310585            case 'iso646se':
     10586            case 'isoir10':
    1026410587            case 'se':
    1026510588            case 'sen850200b':
     
    1026710590
    1026810591            case 'csiso11swedishfornames':
     10592            case 'iso646se2':
    1026910593            case 'isoir11':
    10270             case 'iso646se2':
    1027110594            case 'se2':
    1027210595            case 'sen850200c':
     
    1031610639            case 'csascii':
    1031710640            case 'ibm367':
     10641            case 'iso646irv1991':
     10642            case 'iso646us':
    1031810643            case 'isoir6':
    10319             case 'iso646us':
    10320             case 'iso646irv1991':
    1032110644            case 'us':
    1032210645            case 'usascii':
     
    1038210705            case 'iso885911':
    1038310706            case 'tis620':
    10384                 return 'Windows-874';
     10707                return 'windows-874';
    1038510708
    1038610709            case 'cseuckr':
     10710            case 'csksc56011987':
    1038710711            case 'euckr':
    10388             case 'windows949':
    10389             case 'csksc56011987':
    1039010712            case 'isoir149':
    1039110713            case 'korean':
     
    1039310715            case 'ksc56011987':
    1039410716            case 'ksc56011989':
    10395                 return 'Windows-949';
     10717            case 'windows949':
     10718                return 'windows-949';
    1039610719
    1039710720            case 'windows1250':
     
    1040510728            case 'ibm819':
    1040610729            case 'iso88591':
     10730            case 'iso885911987':
    1040710731            case 'isoir100':
    10408             case 'iso885911987':
    1040910732            case 'l1':
    1041010733            case 'latin1':
    1041110734            case 'windows1252':
    10412                 return 'Windows-1252';
    10413 
    10414             case 'windows1252':
    1041510735                return 'windows-1252';
    1041610736
     
    1042010740            case 'csisolatin5':
    1042110741            case 'iso88599':
     10742            case 'iso885991989':
    1042210743            case 'isoir148':
    10423             case 'iso885991989':
    1042410744            case 'l5':
    1042510745            case 'latin5':
    1042610746            case 'windows1254':
    10427                 return 'Windows-1254';
    10428 
    10429             case 'windows1254':
    1043010747                return 'windows-1254';
    1043110748
     
    1045310770            $curl = $curl['version'];
    1045410771        }
    10455         elseif (substr($curl, 0, 5) == 'curl/')
     10772        elseif (substr($curl, 0, 5) === 'curl/')
    1045610773        {
    1045710774            $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5));
    1045810775        }
    10459         elseif (substr($curl, 0, 8) == 'libcurl/')
     10776        elseif (substr($curl, 0, 8) === 'libcurl/')
    1046010777        {
    1046110778            $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8));
     
    1047010787    function is_subclass_of($class1, $class2)
    1047110788    {
    10472         if (func_num_args() != 2)
     10789        if (func_num_args() !== 2)
    1047310790        {
    1047410791            trigger_error('Wrong parameter count for SimplePie_Misc::is_subclass_of()', E_USER_WARNING);
     
    1048710804                    while ($class1 = strtolower(get_parent_class($class1)))
    1048810805                    {
    10489                         if ($class1 == $class2)
     10806                        if ($class1 === $class2)
    1049010807                        {
    1049110808                            return true;
     
    1063410951    function atom_03_construct_type($attribs)
    1063510952    {
    10636         if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) == 'base64'))
     10953        if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) === 'base64'))
    1063710954        {
    1063810955            $mode = SIMPLEPIE_CONSTRUCT_BASE64;
     
    1070611023                    return SIMPLEPIE_CONSTRUCT_XHTML;
    1070711024            }
    10708             if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) == 'text/')
     11025            if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) === 'text/')
    1070911026            {
    1071011027                return SIMPLEPIE_CONSTRUCT_NONE;
     
    1100611323        return $encoding;
    1100711324    }
     11325
     11326    function output_javascript()
     11327    {
     11328        if (function_exists('ob_gzhandler'))
     11329        {
     11330            ob_start('ob_gzhandler');
     11331        }
     11332        header('Content-type: text/javascript; charset: UTF-8');
     11333        header('Cache-Control: must-revalidate');
     11334        header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
     11335        ?>
     11336function embed_odeo(link) {
     11337    document.writeln('<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url='+link+'"></embed>');
     11338}
     11339
     11340function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
     11341    if (placeholder != '') {
     11342        document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
     11343    }
     11344    else {
     11345        document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="true" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
     11346    }
     11347}
     11348
     11349function embed_flash(bgcolor, width, height, link, loop, type) {
     11350    document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>');
     11351}
     11352
     11353function embed_flv(width, height, link, placeholder, loop, player) {
     11354    document.writeln('<embed src="'+player+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="'+width+'" height="'+height+'" wmode="transparent" flashvars="file='+link+'&autostart=false&repeat='+loop+'&showdigits=true&showfsbutton=false"></embed>');
     11355}
     11356
     11357function embed_wmedia(width, height, link) {
     11358    document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
     11359}
     11360        <?php
     11361    }
    1100811362}
    1100911363
     
    1108411438        else
    1108511439        {
    11086             $this->consumed = false;
    1108711440            return false;
    1108811441        }
     
    1110711460        else
    1110811461        {
    11109             $this->consumed = false;
    1111011462            return false;
    1111111463        }
     
    1118111533                    }
    1118211534
    11183                     if ($this->consume() != ';')
     11535                    if (!in_array($this->consume(), array(';', false), true))
    1118411536                    {
    1118511537                        $this->unconsume();
     
    1121011562                }
    1121111563                break;
     11564        }
     11565    }
     11566}
     11567
     11568/**
     11569 * IRI parser/serialiser
     11570 *
     11571 * @package SimplePie
     11572 */
     11573class SimplePie_IRI
     11574{
     11575    /**
     11576     * Scheme
     11577     *
     11578     * @access private
     11579     * @var string
     11580     */
     11581    var $scheme;
     11582
     11583    /**
     11584     * User Information
     11585     *
     11586     * @access private
     11587     * @var string
     11588     */
     11589    var $userinfo;
     11590
     11591    /**
     11592     * Host
     11593     *
     11594     * @access private
     11595     * @var string
     11596     */
     11597    var $host;
     11598
     11599    /**
     11600     * Port
     11601     *
     11602     * @access private
     11603     * @var string
     11604     */
     11605    var $port;
     11606
     11607    /**
     11608     * Path
     11609     *
     11610     * @access private
     11611     * @var string
     11612     */
     11613    var $path;
     11614
     11615    /**
     11616     * Query
     11617     *
     11618     * @access private
     11619     * @var string
     11620     */
     11621    var $query;
     11622
     11623    /**
     11624     * Fragment
     11625     *
     11626     * @access private
     11627     * @var string
     11628     */
     11629    var $fragment;
     11630
     11631    /**
     11632     * Whether the object represents a valid IRI
     11633     *
     11634     * @access private
     11635     * @var array
     11636     */
     11637    var $valid = array();
     11638
     11639    /**
     11640     * Return the entire IRI when you try and read the object as a string
     11641     *
     11642     * @access public
     11643     * @return string
     11644     */
     11645    function __toString()
     11646    {
     11647        return $this->get_iri();
     11648    }
     11649
     11650    /**
     11651     * Create a new IRI object, from a specified string
     11652     *
     11653     * @access public
     11654     * @param string $iri
     11655     * @return SimplePie_IRI
     11656     */
     11657    function SimplePie_IRI($iri)
     11658    {
     11659        $iri = (string) $iri;
     11660        if ($iri !== '')
     11661        {
     11662            $parsed = $this->parse_iri($iri);
     11663            $this->set_scheme($parsed['scheme']);
     11664            $this->set_authority($parsed['authority']);
     11665            $this->set_path($parsed['path']);
     11666            $this->set_query($parsed['query']);
     11667            $this->set_fragment($parsed['fragment']);
     11668        }
     11669    }
     11670
     11671    /**
     11672     * Create a new IRI object by resolving a relative IRI
     11673     *
     11674     * @static
     11675     * @access public
     11676     * @param SimplePie_IRI $base Base IRI
     11677     * @param string $relative Relative IRI
     11678     * @return SimplePie_IRI
     11679     */
     11680    function absolutize($base, $relative)
     11681    {
     11682        $relative = (string) $relative;
     11683        if ($relative !== '')
     11684        {
     11685            $relative =& new SimplePie_IRI($relative);
     11686            if ($relative->get_scheme() !== null)
     11687            {
     11688                $target = $relative;
     11689            }
     11690            elseif ($base->get_iri() !== null)
     11691            {
     11692                if ($relative->get_authority() !== null)
     11693                {
     11694                    $target = $relative;
     11695                    $target->set_scheme($base->get_scheme());
     11696                }
     11697                else
     11698                {
     11699                    $target =& new SimplePie_IRI('');
     11700                    $target->set_scheme($base->get_scheme());
     11701                    $target->set_userinfo($base->get_userinfo());
     11702                    $target->set_host($base->get_host());
     11703                    $target->set_port($base->get_port());
     11704                    if ($relative->get_path() !== null)
     11705                    {
     11706                        if (strpos($relative->get_path(), '/') === 0)
     11707                        {
     11708                            $target->set_path($relative->get_path());
     11709                        }
     11710                        elseif (($base->get_userinfo() !== null || $base->get_host() !== null || $base->get_port() !== null) && $base->get_path() === null)
     11711                        {
     11712                            $target->set_path('/' . $relative->get_path());
     11713                        }
     11714                        elseif (($last_segment = strrpos($base->get_path(), '/')) !== false)
     11715                        {
     11716                            $target->set_path(substr($base->get_path(), 0, $last_segment + 1) . $relative->get_path());
     11717                        }
     11718                        else
     11719                        {
     11720                            $target->set_path($relative->get_path());
     11721                        }
     11722                        $target->set_query($relative->get_query());
     11723                    }
     11724                    else
     11725                    {
     11726                        $target->set_path($base->get_path());
     11727                        if ($relative->get_query() !== null)
     11728                        {
     11729                            $target->set_query($relative->get_query());
     11730                        }
     11731                        elseif ($base->get_query() !== null)
     11732                        {
     11733                            $target->set_query($base->get_query());
     11734                        }
     11735                    }
     11736                }
     11737                $target->set_fragment($relative->get_fragment());
     11738            }
     11739            else
     11740            {
     11741                // No base URL, just return the relative URL
     11742                $target = $relative;
     11743            }
     11744        }
     11745        else
     11746        {
     11747            $target = $base;
     11748        }
     11749        return $target;
     11750    }
     11751
     11752    /**
     11753     * Parse an IRI into scheme/authority/path/query/fragment segments
     11754     *
     11755     * @access private
     11756     * @param string $iri
     11757     * @return array
     11758     */
     11759    function parse_iri($iri)
     11760    {
     11761        preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/', $iri, $match);
     11762        for ($i = count($match); $i <= 9; $i++)
     11763        {
     11764            $match[$i] = '';
     11765        }
     11766        return array('scheme' => $match[2], 'authority' => $match[4], 'path' => $match[5], 'query' => $match[7], 'fragment' => $match[9]);
     11767    }
     11768
     11769    /**
     11770     * Remove dot segments from a path
     11771     *
     11772     * @access private
     11773     * @param string $input
     11774     * @return string
     11775     */
     11776    function remove_dot_segments($input)
     11777    {
     11778        $output = '';
     11779        while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..')
     11780        {
     11781            // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise,
     11782            if (strpos($input, '../') === 0)
     11783            {
     11784                $input = substr($input, 3);
     11785            }
     11786            elseif (strpos($input, './') === 0)
     11787            {
     11788                $input = substr($input, 2);
     11789            }
     11790            // B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise,
     11791            elseif (strpos($input, '/./') === 0)
     11792            {
     11793                $input = substr_replace($input, '/', 0, 3);
     11794            }
     11795            elseif ($input === '/.')
     11796            {
     11797                $input = '/';
     11798            }
     11799            // C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise,
     11800            elseif (strpos($input, '/../') === 0)
     11801            {
     11802                $input = substr_replace($input, '/', 0, 4);
     11803                $output = substr_replace($output, '', strrpos($output, '/'));
     11804            }
     11805            elseif ($input === '/..')
     11806            {
     11807                $input = '/';
     11808                $output = substr_replace($output, '', strrpos($output, '/'));
     11809            }
     11810            // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise,
     11811            elseif ($input === '.' || $input === '..')
     11812            {
     11813                $input = '';
     11814            }
     11815            // E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer
     11816            elseif (($pos = strpos($input, '/', 1)) !== false)
     11817            {
     11818                $output .= substr($input, 0, $pos);
     11819                $input = substr_replace($input, '', 0, $pos);
     11820            }
     11821            else
     11822            {
     11823                $output .= $input;
     11824                $input = '';
     11825            }
     11826        }
     11827        return $output . $input;
     11828    }
     11829
     11830    /**
     11831     * Replace invalid character with percent encoding
     11832     *
     11833     * @access private
     11834     * @param string $string Input string
     11835     * @param string $valid_chars Valid characters
     11836     * @param int $case Normalise case
     11837     * @return string
     11838     */
     11839    function replace_invalid_with_pct_encoding($string, $valid_chars, $case = SIMPLEPIE_SAME_CASE)
     11840    {
     11841        // Normalise case
     11842        if ($case & SIMPLEPIE_LOWERCASE)
     11843        {
     11844            $string = strtolower($string);
     11845        }
     11846        elseif ($case & SIMPLEPIE_UPPERCASE)
     11847        {
     11848            $string = strtoupper($string);
     11849        }
     11850
     11851        // Store position and string length (to avoid constantly recalculating this)
     11852        $position = 0;
     11853        $strlen = strlen($string);
     11854
     11855        // Loop as long as we have invalid characters, advancing the position to the next invalid character
     11856        while (($position += strspn($string, $valid_chars, $position)) < $strlen)
     11857        {
     11858            // If we have a % character
     11859            if ($string[$position] === '%')
     11860            {
     11861                // If we have a pct-encoded section
     11862                if ($position + 2 < $strlen && strspn($string, '0123456789ABCDEFabcdef', $position + 1, 2) === 2)
     11863                {
     11864                    // Get the the represented character
     11865                    $chr = chr(hexdec(substr($string, $position + 1, 2)));
     11866
     11867                    // If the character is valid, replace the pct-encoded with the actual character while normalising case
     11868                    if (strpos($valid_chars, $chr) !== false)
     11869                    {
     11870                        if ($case & SIMPLEPIE_LOWERCASE)
     11871                        {
     11872                            $chr = strtolower($chr);
     11873                        }
     11874                        elseif ($case & SIMPLEPIE_UPPERCASE)
     11875                        {
     11876                            $chr = strtoupper($chr);
     11877                        }
     11878                        $string = substr_replace($string, $chr, $position, 3);
     11879                        $strlen -= 2;
     11880                        $position++;
     11881                    }
     11882
     11883                    // Otherwise just normalise the pct-encoded to uppercase
     11884                    else
     11885                    {
     11886                        $string = substr_replace($string, strtoupper(substr($string, $position + 1, 2)), $position + 1, 2);
     11887                        $position += 3;
     11888                    }
     11889                }
     11890                // If we don't have a pct-encoded section, just replace the % with its own esccaped form
     11891                else
     11892                {
     11893                    $string = substr_replace($string, '%25', $position, 1);
     11894                    $strlen += 2;
     11895                    $position += 3;
     11896                }
     11897            }
     11898            // If we have an invalid character, change into its pct-encoded form
     11899            else
     11900            {
     11901                $replacement = sprintf("%%%02X", ord($string[$position]));
     11902                $string = str_replace($string[$position], $replacement, $string);
     11903                $strlen = strlen($string);
     11904            }
     11905        }
     11906        return $string;
     11907    }
     11908
     11909    /**
     11910     * Check if the object represents a valid IRI
     11911     *
     11912     * @access public
     11913     * @return bool
     11914     */
     11915    function is_valid()
     11916    {
     11917        return array_sum($this->valid) === count($this->valid);
     11918    }
     11919
     11920    /**
     11921     * Set the scheme. Returns true on success, false on failure (if there are
     11922     * any invalid characters).
     11923     *
     11924     * @access public
     11925     * @param string $scheme
     11926     * @return bool
     11927     */
     11928    function set_scheme($scheme)
     11929    {
     11930        if ($scheme === null || $scheme === '')
     11931        {
     11932            $this->scheme = null;
     11933        }
     11934        else
     11935        {
     11936            $len = strlen($scheme);
     11937            switch (true)
     11938            {
     11939                case $len > 1:
     11940                    if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-.', 1))
     11941                    {
     11942                        $this->scheme = null;
     11943                        $this->valid[__FUNCTION__] = false;
     11944                        return false;
     11945                    }
     11946
     11947                case $len > 0:
     11948                    if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 0, 1))
     11949                    {
     11950                        $this->scheme = null;
     11951                        $this->valid[__FUNCTION__] = false;
     11952                        return false;
     11953                    }
     11954            }
     11955            $this->scheme = strtolower($scheme);
     11956        }
     11957        $this->valid[__FUNCTION__] = true;
     11958        return true;
     11959    }
     11960
     11961    /**
     11962     * Set the authority. Returns true on success, false on failure (if there are
     11963     * any invalid characters).
     11964     *
     11965     * @access public
     11966     * @param string $authority
     11967     * @return bool
     11968     */
     11969    function set_authority($authority)
     11970    {
     11971        if (($userinfo_end = strrpos($authority, '@')) !== false)
     11972        {
     11973            $userinfo = substr($authority, 0, $userinfo_end);
     11974            $authority = substr($authority, $userinfo_end + 1);
     11975        }
     11976        else
     11977        {
     11978            $userinfo = null;
     11979        }
     11980
     11981        if (($port_start = strpos($authority, ':')) !== false)
     11982        {
     11983            $port = substr($authority, $port_start + 1);
     11984            $authority = substr($authority, 0, $port_start);
     11985        }
     11986        else
     11987        {
     11988            $port = null;
     11989        }
     11990
     11991        return $this->set_userinfo($userinfo) && $this->set_host($authority) && $this->set_port($port);
     11992    }
     11993
     11994    /**
     11995     * Set the userinfo.
     11996     *
     11997     * @access public
     11998     * @param string $userinfo
     11999     * @return bool
     12000     */
     12001    function set_userinfo($userinfo)
     12002    {
     12003        if ($userinfo === null || $userinfo === '')
     12004        {
     12005            $this->userinfo = null;
     12006        }
     12007        else
     12008        {
     12009            $this->userinfo = $this->replace_invalid_with_pct_encoding($userinfo, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:');
     12010        }
     12011        $this->valid[__FUNCTION__] = true;
     12012        return true;
     12013    }
     12014
     12015    /**
     12016     * Set the host. Returns true on success, false on failure (if there are
     12017     * any invalid characters).
     12018     *
     12019     * @access public
     12020     * @param string $host
     12021     * @return bool
     12022     */
     12023    function set_host($host)
     12024    {
     12025        if ($host === null || $host === '')
     12026        {
     12027            $this->host = null;
     12028            $this->valid[__FUNCTION__] = true;
     12029            return true;
     12030        }
     12031        elseif ($host[0] === '[' && substr($host, -1) === ']')
     12032        {
     12033            if (Net_IPv6::checkIPv6(substr($host, 1, -1)))
     12034            {
     12035                $this->host = $host;
     12036                $this->valid[__FUNCTION__] = true;
     12037                return true;
     12038            }
     12039            else
     12040            {
     12041                $this->host = null;
     12042                $this->valid[__FUNCTION__] = false;
     12043                return false;
     12044            }
     12045        }
     12046        else
     12047        {
     12048            $this->host = $this->replace_invalid_with_pct_encoding($host, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=', SIMPLEPIE_LOWERCASE);
     12049            $this->valid[__FUNCTION__] = true;
     12050            return true;
     12051        }
     12052    }
     12053
     12054    /**
     12055     * Set the port. Returns true on success, false on failure (if there are
     12056     * any invalid characters).
     12057     *
     12058     * @access public
     12059     * @param string $port
     12060     * @return bool
     12061     */
     12062    function set_port($port)
     12063    {
     12064        if ($port === null || $port === '')
     12065        {
     12066            $this->port = null;
     12067            $this->valid[__FUNCTION__] = true;
     12068            return true;
     12069        }
     12070        elseif (strspn($port, '0123456789') === strlen($port))
     12071        {
     12072            $this->port = (int) $port;
     12073            $this->valid[__FUNCTION__] = true;
     12074            return true;
     12075        }
     12076        else
     12077        {
     12078            $this->port = null;
     12079            $this->valid[__FUNCTION__] = false;
     12080            return false;
     12081        }
     12082    }
     12083
     12084    /**
     12085     * Set the path.
     12086     *
     12087     * @access public
     12088     * @param string $path
     12089     * @return bool
     12090     */
     12091    function set_path($path)
     12092    {
     12093        if ($path === null || $path === '')
     12094        {
     12095            $this->path = null;
     12096            $this->valid[__FUNCTION__] = true;
     12097            return true;
     12098        }
     12099        elseif (substr($path, 0, 2) === '//' && $this->userinfo === null && $this->host === null && $this->port === null)
     12100        {
     12101            $this->path = null;
     12102            $this->valid[__FUNCTION__] = false;
     12103            return false;
     12104        }
     12105        else
     12106        {
     12107            $this->path = $this->replace_invalid_with_pct_encoding($path, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=@/');
     12108            if ($this->scheme !== null)
     12109            {
     12110                $this->path = $this->remove_dot_segments($this->path);
     12111            }
     12112            $this->valid[__FUNCTION__] = true;
     12113            return true;
     12114        }
     12115    }
     12116
     12117    /**
     12118     * Set the query.
     12119     *
     12120     * @access public
     12121     * @param string $query
     12122     * @return bool
     12123     */
     12124    function set_query($query)
     12125    {
     12126        if ($query === null || $query === '')
     12127        {
     12128            $this->query = null;
     12129        }
     12130        else
     12131        {
     12132            $this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:@/?');
     12133        }
     12134        $this->valid[__FUNCTION__] = true;
     12135        return true;
     12136    }
     12137
     12138    /**
     12139     * Set the fragment.
     12140     *
     12141     * @access public
     12142     * @param string $fragment
     12143     * @return bool
     12144     */
     12145    function set_fragment($fragment)
     12146    {
     12147        if ($fragment === null || $fragment === '')
     12148        {
     12149            $this->fragment = null;
     12150        }
     12151        else
     12152        {
     12153            $this->fragment = $this->replace_invalid_with_pct_encoding($fragment, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:@/?');
     12154        }
     12155        $this->valid[__FUNCTION__] = true;
     12156        return true;
     12157    }
     12158
     12159    /**
     12160     * Get the complete IRI
     12161     *
     12162     * @access public
     12163     * @return string
     12164     */
     12165    function get_iri()
     12166    {
     12167        $iri = '';
     12168        if ($this->scheme !== null)
     12169        {
     12170            $iri .= $this->scheme . ':';
     12171        }
     12172        if (($authority = $this->get_authority()) !== null)
     12173        {
     12174            $iri .= '//' . $authority;
     12175        }
     12176        if ($this->path !== null)
     12177        {
     12178            $iri .= $this->path;
     12179        }
     12180        if ($this->query !== null)
     12181        {
     12182            $iri .= '?' . $this->query;
     12183        }
     12184        if ($this->fragment !== null)
     12185        {
     12186            $iri .= '#' . $this->fragment;
     12187        }
     12188
     12189        if ($iri !== '')
     12190        {
     12191            return $iri;
     12192        }
     12193        else
     12194        {
     12195            return null;
     12196        }
     12197    }
     12198
     12199    /**
     12200     * Get the scheme
     12201     *
     12202     * @access public
     12203     * @return string
     12204     */
     12205    function get_scheme()
     12206    {
     12207        return $this->scheme;
     12208    }
     12209
     12210    /**
     12211     * Get the complete authority
     12212     *
     12213     * @access public
     12214     * @return string
     12215     */
     12216    function get_authority()
     12217    {
     12218        $authority = '';
     12219        if ($this->userinfo !== null)
     12220        {
     12221            $authority .= $this->userinfo . '@';
     12222        }
     12223        if ($this->host !== null)
     12224        {
     12225            $authority .= $this->host;
     12226        }
     12227        if ($this->port !== null)
     12228        {
     12229            $authority .= ':' . $this->port;
     12230        }
     12231
     12232        if ($authority !== '')
     12233        {
     12234            return $authority;
     12235        }
     12236        else
     12237        {
     12238            return null;
     12239        }
     12240    }
     12241
     12242    /**
     12243     * Get the user information
     12244     *
     12245     * @access public
     12246     * @return string
     12247     */
     12248    function get_userinfo()
     12249    {
     12250        return $this->userinfo;
     12251    }
     12252
     12253    /**
     12254     * Get the host
     12255     *
     12256     * @access public
     12257     * @return string
     12258     */
     12259    function get_host()
     12260    {
     12261        return $this->host;
     12262    }
     12263
     12264    /**
     12265     * Get the port
     12266     *
     12267     * @access public
     12268     * @return string
     12269     */
     12270    function get_port()
     12271    {
     12272        return $this->port;
     12273    }
     12274
     12275    /**
     12276     * Get the path
     12277     *
     12278     * @access public
     12279     * @return string
     12280     */
     12281    function get_path()
     12282    {
     12283        return $this->path;
     12284    }
     12285
     12286    /**
     12287     * Get the query
     12288     *
     12289     * @access public
     12290     * @return string
     12291     */
     12292    function get_query()
     12293    {
     12294        return $this->query;
     12295    }
     12296
     12297    /**
     12298     * Get the fragment
     12299     *
     12300     * @access public
     12301     * @return string
     12302     */
     12303    function get_fragment()
     12304    {
     12305        return $this->fragment;
     12306    }
     12307}
     12308
     12309/**
     12310 * Class to validate and to work with IPv6 addresses.
     12311 *
     12312 * @package SimplePie
     12313 * @copyright 2003-2005 The PHP Group
     12314 * @license http://www.opensource.org/licenses/bsd-license.php
     12315 * @link http://pear.php.net/package/Net_IPv6
     12316 * @author Alexander Merz <alexander.merz@web.de>
     12317 * @author elfrink at introweb dot nl
     12318 * @author Josh Peck <jmp at joshpeck dot org>
     12319 * @author Geoffrey Sneddon <geoffers@gmail.com>
     12320 */
     12321class SimplePie_Net_IPv6
     12322{
     12323    /**
     12324     * Removes a possible existing netmask specification of an IP address.
     12325     *
     12326     * @param string $ip the (compressed) IP as Hex representation
     12327     * @return string the IP the without netmask
     12328     * @since 1.1.0
     12329     * @access public
     12330     * @static
     12331     */
     12332    function removeNetmaskSpec($ip)
     12333    {
     12334        if (strpos($ip, '/') !== false)
     12335        {
     12336            list($addr, $nm) = explode('/', $ip);
     12337        }
     12338        else
     12339        {
     12340            $addr = $ip;
     12341        }
     12342        return $addr;
     12343    }
     12344
     12345    /**
     12346     * Uncompresses an IPv6 address
     12347     *
     12348     * RFC 2373 allows you to compress zeros in an address to '::'. This
     12349     * function expects an valid IPv6 address and expands the '::' to
     12350     * the required zeros.
     12351     *
     12352     * Example:  FF01::101  ->  FF01:0:0:0:0:0:0:101
     12353     *           ::1        ->  0:0:0:0:0:0:0:1
     12354     *
     12355     * @access public
     12356     * @static
     12357     * @param string $ip a valid IPv6-address (hex format)
     12358     * @return string the uncompressed IPv6-address (hex format)
     12359     */
     12360    function Uncompress($ip)
     12361    {
     12362        $uip = SimplePie_Net_IPv6::removeNetmaskSpec($ip);
     12363        $c1 = -1;
     12364        $c2 = -1;
     12365        if (strpos($ip, '::') !== false)
     12366        {
     12367            list($ip1, $ip2) = explode('::', $ip);
     12368            if ($ip1 === '')
     12369            {
     12370                $c1 = -1;
     12371            }
     12372            else
     12373            {
     12374                $pos = 0;
     12375                if (($pos = substr_count($ip1, ':')) > 0)
     12376                {
     12377                    $c1 = $pos;
     12378                }
     12379                else
     12380                {
     12381                    $c1 = 0;
     12382                }
     12383            }
     12384            if ($ip2 === '')
     12385            {
     12386                $c2 = -1;
     12387            }
     12388            else
     12389            {
     12390                $pos = 0;
     12391                if (($pos = substr_count($ip2, ':')) > 0)
     12392                {
     12393                    $c2 = $pos;
     12394                }
     12395                else
     12396                {
     12397                    $c2 = 0;
     12398                }
     12399            }
     12400            if (strstr($ip2, '.'))
     12401            {
     12402                $c2++;
     12403            }
     12404            // ::
     12405            if ($c1 === -1 && $c2 === -1)
     12406            {
     12407                $uip = '0:0:0:0:0:0:0:0';
     12408            }
     12409            // ::xxx
     12410            else if ($c1 === -1)
     12411            {
     12412                $fill = str_repeat('0:', 7 - $c2);
     12413                $uip =  str_replace('::', $fill, $uip);
     12414            }
     12415            // xxx::
     12416            else if ($c2 === -1)
     12417            {
     12418                $fill = str_repeat(':0', 7 - $c1);
     12419                $uip =  str_replace('::', $fill, $uip);
     12420            }
     12421            // xxx::xxx
     12422            else
     12423            {
     12424                $fill = str_repeat(':0:', 6 - $c2 - $c1);
     12425                $uip =  str_replace('::', $fill, $uip);
     12426                $uip =  str_replace('::', ':', $uip);
     12427            }
     12428        }
     12429        return $uip;
     12430    }
     12431
     12432    /**
     12433     * Splits an IPv6 address into the IPv6 and a possible IPv4 part
     12434     *
     12435     * RFC 2373 allows you to note the last two parts of an IPv6 address as
     12436     * an IPv4 compatible address
     12437     *
     12438     * Example:  0:0:0:0:0:0:13.1.68.3
     12439     *           0:0:0:0:0:FFFF:129.144.52.38
     12440     *
     12441     * @access public
     12442     * @static
     12443     * @param string $ip a valid IPv6-address (hex format)
     12444     * @return array [0] contains the IPv6 part, [1] the IPv4 part (hex format)
     12445     */
     12446    function SplitV64($ip)
     12447    {
     12448        $ip = SimplePie_Net_IPv6::Uncompress($ip);
     12449        if (strstr($ip, '.'))
     12450        {
     12451            $pos = strrpos($ip, ':');
     12452            $ip[$pos] = '_';
     12453            $ipPart = explode('_', $ip);
     12454            return $ipPart;
     12455        }
     12456        else
     12457        {
     12458            return array($ip, '');
     12459        }
     12460    }
     12461
     12462    /**
     12463     * Checks an IPv6 address
     12464     *
     12465     * Checks if the given IP is IPv6-compatible
     12466     *
     12467     * @access public
     12468     * @static
     12469     * @param string $ip a valid IPv6-address
     12470     * @return bool true if $ip is an IPv6 address
     12471     */
     12472    function checkIPv6($ip)
     12473    {
     12474        $ipPart = SimplePie_Net_IPv6::SplitV64($ip);
     12475        $count = 0;
     12476        if (!empty($ipPart[0]))
     12477        {
     12478            $ipv6 = explode(':', $ipPart[0]);
     12479            for ($i = 0; $i < count($ipv6); $i++)
     12480            {
     12481                $dec = hexdec($ipv6[$i]);
     12482                $hex = strtoupper(preg_replace('/^[0]{1,3}(.*[0-9a-fA-F])$/', '\\1', $ipv6[$i]));
     12483                if ($ipv6[$i] >= 0 && $dec <= 65535 && $hex === strtoupper(dechex($dec)))
     12484                {
     12485                    $count++;
     12486                }
     12487            }
     12488            if ($count === 8)
     12489            {
     12490                return true;
     12491            }
     12492            elseif ($count === 6 && !empty($ipPart[1]))
     12493            {
     12494                $ipv4 = explode('.', $ipPart[1]);
     12495                $count = 0;
     12496                foreach ($ipv4 as $ipv4_part)
     12497                {
     12498                    if ($ipv4_part >= 0 && $ipv4_part <= 255 && preg_match('/^\d{1,3}$/', $ipv4_part))
     12499                    {
     12500                        $count++;
     12501                    }
     12502                }
     12503                if ($count === 4)
     12504                {
     12505                    return true;
     12506                }
     12507            }
     12508            else
     12509            {
     12510                return false;
     12511            }
     12512
     12513        }
     12514        else
     12515        {
     12516            return false;
    1121212517        }
    1121312518    }
     
    1277014075    }
    1277114076
    12772     function find($type = SIMPLEPIE_LOCATOR_ALL)
     14077    function find($type = SIMPLEPIE_LOCATOR_ALL, &$working)
    1277314078    {
    1277414079        if ($this->is_feed($this->file))
     
    1279314098        if ($type & SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working = $this->autodiscovery())
    1279414099        {
    12795             return $working;
     14100            return $working[0];
    1279614101        }
    1279714102
     
    1286614171        $links = array_merge(SimplePie_Misc::get_element('link', $this->file->body), SimplePie_Misc::get_element('a', $this->file->body), SimplePie_Misc::get_element('area', $this->file->body));
    1286714172        $done = array();
     14173        $feeds = array();
    1286814174        foreach ($links as $link)
    1286914175        {
    12870             if ($this->checked_feeds == $this->max_checked_feeds)
     14176            if ($this->checked_feeds === $this->max_checked_feeds)
    1287114177            {
    1287214178                break;
     
    1288514191                }
    1288614192
    12887                 if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !empty($link['attribs']['type']['data']) && in_array(strtolower(SimplePie_Misc::parse_mime($link['attribs']['type']['data'])), array('application/rss+xml', 'application/atom+xml'))))
     14193                if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !empty($link['attribs']['type']['data']) && in_array(strtolower(SimplePie_Misc::parse_mime($link['attribs']['type']['data'])), array('application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href]))
    1288814194                {
    1288914195                    $this->checked_feeds++;
    1289014196                    $feed =& new $this->file_class($href, $this->timeout, 5, null, $this->useragent);
    12891                     if ($this->is_feed($feed))
     14197                    if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
    1289214198                    {
    12893                         return $feed;
     14199                        $feeds[$href] = $feed;
    1289414200                    }
    1289514201                }
     
    1289714203            }
    1289814204        }
    12899         return null;
     14205
     14206        if (!empty($feeds))
     14207        {
     14208            return array_values($feeds);
     14209        }
     14210        else {
     14211            return null;
     14212        }
    1290014213    }
    1290114214
     
    1292214235                    $current = SimplePie_Misc::parse_url($this->file->url);
    1292314236
    12924                     if ($parsed['authority'] === '' || $parsed['authority'] == $current['authority'])
     14237                    if ($parsed['authority'] === '' || $parsed['authority'] === $current['authority'])
    1292514238                    {
    1292614239                        $this->local[] = $href;
     
    1294614259        foreach ($array as $key => $value)
    1294714260        {
    12948             if ($this->checked_feeds == $this->max_checked_feeds)
     14261            if ($this->checked_feeds === $this->max_checked_feeds)
    1294914262            {
    1295014263                break;
     
    1295414267                $this->checked_feeds++;
    1295514268                $feed =& new $this->file_class($value, $this->timeout, 5, null, $this->useragent);
    12956                 if ($this->is_feed($feed))
     14269                if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
    1295714270                {
    1295814271                    return $feed;
     
    1297114284        foreach ($array as $key => $value)
    1297214285        {
    12973             if ($this->checked_feeds == $this->max_checked_feeds)
     14286            if ($this->checked_feeds === $this->max_checked_feeds)
    1297414287            {
    1297514288                break;
     
    1297914292                $this->checked_feeds++;
    1298014293                $feed =& new $this->file_class($value, $this->timeout, 5, null, $this->useragent);
    12981                 if ($this->is_feed($feed))
     14294                if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
    1298214295                {
    1298314296                    return $feed;
     
    1300114314    var $current_byte;
    1300214315    var $separator = ' ';
    13003     var $feed = false;
    1300414316    var $namespace = array('');
    1300514317    var $element = array('');
     
    1301514327    {
    1301614328        // Use UTF-8 if we get passed US-ASCII, as every US-ASCII character is a UTF-8 character
    13017         if (strtoupper($encoding) == 'US-ASCII')
     14329        if (strtoupper($encoding) === 'US-ASCII')
    1301814330        {
    1301914331            $this->encoding = 'UTF-8';
     
    1306614378        }
    1306714379
    13068         // Work around libxml bug
    13069         $data = str_replace('&lt;', '&#60;', $data);
    13070         $data = str_replace('&gt;', '&#62;', $data);
    13071         $data = str_replace('&amp;', '&#38;', $data);
    13072         $data = str_replace('&apos;', '&#39;', $data);
    13073         $data = str_replace('&quot;', '&#34;', $data);
    13074 
    1307514380        $return = true;
    1307614381
     14382        static $xml_is_sane = null;
     14383        if ($xml_is_sane === null)
     14384        {
     14385            $parser_check = xml_parser_create();
     14386            xml_parse_into_struct($parser_check, '<foo>&amp;</foo>', $values);
     14387            xml_parser_free($parser_check);
     14388            $xml_is_sane = isset($values[0]['value']);
     14389        }
     14390
    1307714391        // Create the parser
    13078         $xml = xml_parser_create_ns($this->encoding, $this->separator);
    13079         xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1);
    13080         xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 0);
    13081         xml_set_object($xml, $this);
    13082         xml_set_character_data_handler($xml, 'cdata');
    13083         xml_set_element_handler($xml, 'tag_open', 'tag_close');
    13084 
    13085         // Parse!
    13086         if (!xml_parse($xml, $data, true))
    13087         {
    13088             $this->error_code = xml_get_error_code($xml);
    13089             $this->error_string = xml_error_string($this->error_code);
    13090             $return = false;
    13091         }
    13092         $this->current_line = xml_get_current_line_number($xml);
    13093         $this->current_column = xml_get_current_column_number($xml);
    13094         $this->current_byte = xml_get_current_byte_index($xml);
    13095         xml_parser_free($xml);
    13096         return $return;
     14392        if ($xml_is_sane)
     14393        {
     14394            $xml = xml_parser_create_ns($this->encoding, $this->separator);
     14395            xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1);
     14396            xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 0);
     14397            xml_set_object($xml, $this);
     14398            xml_set_character_data_handler($xml, 'cdata');
     14399            xml_set_element_handler($xml, 'tag_open', 'tag_close');
     14400
     14401            // Parse!
     14402            if (!xml_parse($xml, $data, true))
     14403            {
     14404                $this->error_code = xml_get_error_code($xml);
     14405                $this->error_string = xml_error_string($this->error_code);
     14406                $return = false;
     14407            }
     14408            $this->current_line = xml_get_current_line_number($xml);
     14409            $this->current_column = xml_get_current_column_number($xml);
     14410            $this->current_byte = xml_get_current_byte_index($xml);
     14411            xml_parser_free($xml);
     14412            return $return;
     14413        }
     14414        else
     14415        {
     14416            libxml_clear_errors();
     14417            $xml =& new XMLReader();
     14418            $xml->xml($data);
     14419            while (@$xml->read())
     14420            {
     14421                switch ($xml->nodeType)
     14422                {
     14423
     14424                    case constant('XMLReader::END_ELEMENT'):
     14425                        if ($xml->namespaceURI !== '')
     14426                        {
     14427                            $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
     14428                        }
     14429                        else
     14430                        {
     14431                            $tagName = $xml->localName;
     14432                        }
     14433                        $this->tag_close(null, $tagName);
     14434                        break;
     14435                    case constant('XMLReader::ELEMENT'):
     14436                        $empty = $xml->isEmptyElement;
     14437                        if ($xml->namespaceURI !== '')
     14438                        {
     14439                            $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
     14440                        }
     14441                        else
     14442                        {
     14443                            $tagName = $xml->localName;
     14444                        }
     14445                        $attributes = array();
     14446                        while ($xml->moveToNextAttribute())
     14447                        {
     14448                            if ($xml->namespaceURI !== '')
     14449                            {
     14450                                $attrName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
     14451                            }
     14452                            else
     14453                            {
     14454                                $attrName = $xml->localName;
     14455                            }
     14456                            $attributes[$attrName] = $xml->value;
     14457                        }
     14458                        $this->tag_open(null, $tagName, $attributes);
     14459                        if ($empty)
     14460                        {
     14461                            $this->tag_close(null, $tagName);
     14462                        }
     14463                        break;
     14464                    case constant('XMLReader::TEXT'):
     14465
     14466                    case constant('XMLReader::CDATA'):
     14467                        $this->cdata(null, $xml->value);
     14468                        break;
     14469                }
     14470            }
     14471            if ($error = libxml_get_last_error())
     14472            {
     14473                $this->error_code = $error->code;
     14474                $this->error_string = $error->message;
     14475                $this->current_line = $error->line;
     14476                $this->current_column = $error->column;
     14477                return false;
     14478            }
     14479            else
     14480            {
     14481                return true;
     14482            }
     14483        }
    1309714484    }
    1309814485
     
    1312914516    function tag_open($parser, $tag, $attributes)
    1313014517    {
    13131         if ($this->feed === 0)
    13132         {
    13133             return;
    13134         }
    13135         elseif ($this->feed == false)
    13136         {
    13137             if (in_array($tag, array(
    13138                 SIMPLEPIE_NAMESPACE_ATOM_10 . $this->separator . 'feed',
    13139                 SIMPLEPIE_NAMESPACE_ATOM_03 . $this->separator . 'feed',
    13140                 'rss',
    13141                 SIMPLEPIE_NAMESPACE_RDF . $this->separator . 'RDF'
    13142             )))
    13143             {
    13144                     $this->feed = 1;
    13145             }
    13146         }
    13147         else
    13148         {
    13149             $this->feed++;
    13150         }
    13151 
    1315214518        list($this->namespace[], $this->element[]) = $this->split_ns($tag);
    1315314519
     
    1318214548        {
    1318314549            $this->current_xhtml_construct++;
    13184             if (end($this->namespace) == SIMPLEPIE_NAMESPACE_XHTML)
     14550            if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML)
    1318514551            {
    1318614552                $this->data['data'] .= '<' . end($this->element);
     
    1320014566            $this->data =& $this->data['child'][end($this->namespace)][end($this->element)][];
    1320114567            $this->data = array('data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang));
    13202             if ((end($this->namespace) == SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] == 'xml')
    13203             || (end($this->namespace) == SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] == 'xhtml'))
     14568            if ((end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] === 'xml')
     14569            || (end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml'))
    1320414570            {
    1320514571                $this->current_xhtml_construct = 0;
     
    1321414580            $this->data['data'] .= htmlspecialchars($cdata, ENT_QUOTES, $this->encoding);
    1321514581        }
    13216         elseif ($this->feed > 1)
     14582        else
    1321714583        {
    1321814584            $this->data['data'] .= $cdata;
     
    1322214588    function tag_close($parser, $tag)
    1322314589    {
    13224         if (!$this->feed)
    13225         {
    13226             return;
    13227         }
    13228 
    1322914590        if ($this->current_xhtml_construct >= 0)
    1323014591        {
    1323114592            $this->current_xhtml_construct--;
    13232             if (end($this->namespace) == SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param')))
     14593            if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param')))
    1323314594            {
    1323414595                $this->data['data'] .= '</' . end($this->element) . '>';
    1323514596            }
    1323614597        }
    13237         if ($this->current_xhtml_construct == -1)
    13238         {
    13239             $this->data =& $this->datas[$this->feed];
     14598        if ($this->current_xhtml_construct === -1)
     14599        {
     14600            $this->data =& $this->datas[count($this->datas) - 1];
    1324014601            array_pop($this->datas);
    1324114602        }
     
    1324614607        array_pop($this->xml_base_explicit);
    1324714608        array_pop($this->xml_lang);
    13248         $this->feed--;
    1324914609    }
    1325014610
     
    1354414904                                $headers = $file->headers;
    1354514905
    13546                                 if ($file->success && ($file->status_code == 200 || ($file->status_code > 206 && $file->status_code < 300)))
     14906                                if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)))
    1354714907                                {
    1354814908                                    if ($cache->save(array('headers' => $file->headers, 'body' => $file->body)))
     
    1355314913                                    else
    1355414914                                    {
    13555                                         trigger_error("$cache->name is not writeable", E_USER_WARNING);
     14915                                        trigger_error("$this->cache_location is not writeable", E_USER_WARNING);
    1355614916                                    }
    1355714917                                }
     
    1357514935            }
    1357614936
    13577             if ($this->output_encoding != 'UTF-8')
     14937            if ($this->output_encoding !== 'UTF-8')
    1357814938            {
    1357914939                $data = SimplePie_Misc::change_encoding($data, 'UTF-8', $this->output_encoding);
Note: See TracChangeset for help on using the changeset viewer.