~katiekitty/+junk/wordpress-byet

« back to all changes in this revision

Viewing changes to wp-includes/class-simplepie.php

  • Committer: kserver
  • Date: 2010-05-15 01:16:36 UTC
  • Revision ID: kserver@kserver-desktop-20100515011636-mnr1j7t637suptdq
Wordpress 2.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 * A PHP-Based RSS and Atom Feed Framework.
6
6
 * Takes the hard work out of managing a complete RSS/Atom solution.
7
7
 *
8
 
 * Copyright (c) 2004-2008, Ryan Parman and Geoffrey Sneddon
 
8
 * Copyright (c) 2004-2009, Ryan Parman and Geoffrey Sneddon
9
9
 * All rights reserved.
10
10
 *
11
11
 * Redistribution and use in source and binary forms, with or without modification, are
33
33
 * POSSIBILITY OF SUCH DAMAGE.
34
34
 *
35
35
 * @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
38
38
 * @author Ryan Parman
39
39
 * @author Geoffrey Sneddon
40
40
 * @link http://simplepie.org/ SimplePie
51
51
/**
52
52
 * SimplePie Version
53
53
 */
54
 
define('SIMPLEPIE_VERSION', '1.1.3');
 
54
define('SIMPLEPIE_VERSION', '1.2');
55
55
 
56
56
/**
57
57
 * SimplePie Build
58
58
 */
59
 
define('SIMPLEPIE_BUILD', 20081219);
 
59
define('SIMPLEPIE_BUILD', '20090627192103');
60
60
 
61
61
/**
62
62
 * SimplePie Website URL
242
242
define('SIMPLEPIE_CONSTRUCT_ALL', 63);
243
243
 
244
244
/**
 
245
 * Don't change case
 
246
 */
 
247
define('SIMPLEPIE_SAME_CASE', 1);
 
248
 
 
249
/**
 
250
 * Change to lowercase
 
251
 */
 
252
define('SIMPLEPIE_LOWERCASE', 2);
 
253
 
 
254
/**
 
255
 * Change to uppercase
 
256
 */
 
257
define('SIMPLEPIE_UPPERCASE', 4);
 
258
 
 
259
/**
245
260
 * PCRE for HTML attributes
246
261
 */
247
262
define('SIMPLEPIE_PCRE_HTML_ATTRIBUTE', '((?:[\x09\x0A\x0B\x0C\x0D\x20]+[^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?)*)[\x09\x0A\x0B\x0C\x0D\x20]*');
376
391
 * SimplePie
377
392
 *
378
393
 * @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.)
384
394
 */
385
395
class SimplePie
386
396
{
639
649
        var $max_checked_feeds = 10;
640
650
 
641
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();
 
657
 
 
658
        /**
642
659
         * @var string Web-accessible path to the handler_favicon.php file.
643
660
         * @see SimplePie::set_favicon_handler()
644
661
         * @access private
1440
1457
         */
1441
1458
        function set_favicon_handler($page = false, $qs = 'i')
1442
1459
        {
1443
 
                if ($page != false)
 
1460
                if ($page !== false)
1444
1461
                {
1445
1462
                        $this->favicon_handler = $page . '?' . $qs . '=';
1446
1463
                }
1459
1476
         */
1460
1477
        function set_image_handler($page = false, $qs = 'i')
1461
1478
        {
1462
 
                if ($page != false)
 
1479
                if ($page !== false)
1463
1480
                {
1464
1481
                        $this->sanitize->set_image_handler($page . '?' . $qs . '=');
1465
1482
                }
1482
1499
 
1483
1500
        function init()
1484
1501
        {
 
1502
                // Check absolute bare minimum requirements.
1485
1503
                if ((function_exists('version_compare') && version_compare(PHP_VERSION, '4.3.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre'))
1486
1504
                {
1487
1505
                        return false;
1488
1506
                }
 
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
 
1489
1524
                if (isset($_GET[$this->javascript]))
1490
1525
                {
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();
1524
1527
                        exit;
1525
1528
                }
1526
1529
 
1550
1553
                                        if (!empty($this->data))
1551
1554
                                        {
1552
1555
                                                // 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)
1554
1557
                                                {
1555
1558
                                                        $cache->unlink();
1556
1559
                                                        $this->data = array();
1557
1560
                                                }
1558
1561
                                                // 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)
1560
1563
                                                {
1561
1564
                                                        $cache = false;
1562
1565
                                                        $this->data = array();
1568
1571
                                                        if ($cache->mtime() + $this->autodiscovery_cache_duration > time())
1569
1572
                                                        {
1570
1573
                                                                // 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'])
1572
1575
                                                                {
1573
1576
                                                                        $cache->unlink();
1574
1577
                                                                        $this->data = array();
1598
1601
                                                                $file =& new $this->file_class($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen);
1599
1602
                                                                if ($file->success)
1600
1603
                                                                {
1601
 
                                                                        if ($file->status_code == 304)
 
1604
                                                                        if ($file->status_code === 304)
1602
1605
                                                                        {
1603
1606
                                                                                $cache->touch();
1604
1607
                                                                                return true;
1630
1633
                                // If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it.
1631
1634
                                if (!isset($file))
1632
1635
                                {
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)
1634
1637
                                        {
1635
1638
                                                $file =& $this->file;
1636
1639
                                        }
1640
1643
                                        }
1641
1644
                                }
1642
1645
                                // 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)))
1644
1647
                                {
1645
1648
                                        $this->error = $file->error;
1646
1649
                                        if (!empty($this->data))
1661
1664
                                        {
1662
1665
                                                // We need to unset this so that if SimplePie::set_file() has been called that object is untouched
1663
1666
                                                unset($file);
1664
 
                                                if ($file = $locate->find($this->autodiscovery))
 
1667
                                                if ($file = $locate->find($this->autodiscovery, $this->all_discovered_feeds))
1665
1668
                                                {
1666
1669
                                                        if ($cache)
1667
1670
                                                        {
1668
1671
                                                                $this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
1669
1672
                                                                if (!$cache->save($this))
1670
1673
                                                                {
1671
 
                                                                        trigger_error("$cache->name is not writeable", E_USER_WARNING);
 
1674
                                                                        trigger_error("$this->cache_location is not writeable", E_USER_WARNING);
1672
1675
                                                                }
1673
1676
                                                                $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc');
1674
1677
                                                        }
1786
1789
                                        }
1787
1790
                                }
1788
1791
                        }
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
                        }
1791
1801
                        SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
1792
1802
                        return false;
1793
1803
                }
1882
1892
                                        $this->data['type'] &= SIMPLEPIE_TYPE_RSS_090;
1883
1893
                                }
1884
1894
                        }
1885
 
                        elseif (isset($this->data['child']['']['rss']))
 
1895
                        elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss']))
1886
1896
                        {
1887
1897
                                $this->data['type'] &= SIMPLEPIE_TYPE_RSS_ALL;
1888
 
                                if (isset($this->data['child']['']['rss'][0]['attribs']['']['version']))
 
1898
                                if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version']))
1889
1899
                                {
1890
 
                                        switch (trim($this->data['child']['']['rss'][0]['attribs']['']['version']))
 
1900
                                        switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version']))
1891
1901
                                        {
1892
1902
                                                case '0.91':
1893
1903
                                                        $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']))
1895
1905
                                                        {
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']))
1897
1907
                                                                {
1898
1908
                                                                        case '0':
1899
1909
                                                                                $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE;
1962
1972
                                {
1963
1973
                                        $file =& new $this->file_class($favicon, $this->timeout / 10, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen);
1964
1974
 
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)
1966
1976
                                        {
1967
1977
                                                $sniffer =& new $this->content_type_sniffer_class($file);
1968
1978
                                                if (substr($sniffer->get_type(), 0, 6) === 'image/')
1977
1987
                                                                return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
1978
1988
                                                        }
1979
1989
                                                }
 
1990
                                                // not an image
 
1991
                                                else
 
1992
                                                {
 
1993
                                                        return false;
 
1994
                                                }
1980
1995
                                        }
1981
1996
                                }
1982
1997
                        }
2021
2036
        {
2022
2037
                if ($this->feed_url !== null)
2023
2038
                {
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);
2025
2040
                }
2026
2041
                else
2027
2042
                {
2066
2081
        {
2067
2082
                if ($this->subscribe_url())
2068
2083
                {
2069
 
                        $return = $this->sanitize($feed_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->feed_url);
 
2084
                        $return = $feed_url . rawurlencode($this->feed_url);
2070
2085
                        if ($site_url !== null && $this->get_link() !== null)
2071
2086
                        {
2072
 
                                $return .= $this->sanitize($site_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_link());
 
2087
                                $return .= $site_url . rawurlencode($this->get_link());
2073
2088
                        }
2074
 
                        return $return;
 
2089
                        return $this->sanitize($return, SIMPLEPIE_CONSTRUCT_IRI);
2075
2090
                }
2076
2091
                else
2077
2092
                {
2086
2101
 
2087
2102
        function subscribe_bloglines()
2088
2103
        {
2089
 
                return urldecode($this->subscribe_service('http://www.bloglines.com/sub/'));
 
2104
                return $this->subscribe_service('http://www.bloglines.com/sub/');
2090
2105
        }
2091
2106
 
2092
2107
        function subscribe_eskobo()
2180
2195
                }
2181
2196
                if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
2182
2197
                {
2183
 
                        if (isset($this->data['child']['']['rss'][0]['child'][$namespace][$tag]))
 
2198
                        if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag]))
2184
2199
                        {
2185
 
                                return $this->data['child']['']['rss'][0]['child'][$namespace][$tag];
 
2200
                                return $this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag];
2186
2201
                        }
2187
2202
                }
2188
2203
                return null;
2220
2235
                }
2221
2236
                if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
2222
2237
                {
2223
 
                        if ($channel = $this->get_feed_tags('', 'channel'))
 
2238
                        if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'channel'))
2224
2239
                        {
2225
2240
                                if (isset($channel[0]['child'][$namespace][$tag]))
2226
2241
                                {
2256
2271
                }
2257
2272
                if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
2258
2273
                {
2259
 
                        if ($image = $this->get_channel_tags('', 'image'))
 
2274
                        if ($image = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'image'))
2260
2275
                        {
2261
2276
                                if (isset($image[0]['child'][$namespace][$tag]))
2262
2277
                                {
2306
2321
                {
2307
2322
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2308
2323
                }
2309
 
                elseif ($return = $this->get_channel_tags('', 'title'))
 
2324
                elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
2310
2325
                {
2311
2326
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2312
2327
                }
2360
2375
                        }
2361
2376
                        $categories[] =& new $this->category_class($term, $scheme, $label);
2362
2377
                }
2363
 
                foreach ((array) $this->get_channel_tags('', 'category') as $category)
 
2378
                foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
2364
2379
                {
2365
 
                        $categories[] =& new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
 
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);
2366
2392
                }
2367
2393
                foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
2368
2394
                {
2594
2620
                        {
2595
2621
                                $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2596
2622
                        }
2597
 
                        if ($links = $this->get_channel_tags('', 'link'))
 
2623
                        if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
2598
2624
                        {
2599
2625
                                $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2600
2626
                        }
2614
2640
                                                $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
2615
2641
                                        }
2616
2642
                                }
2617
 
                                elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
 
2643
                                elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
2618
2644
                                {
2619
2645
                                        $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
2620
2646
                                }
2632
2658
                }
2633
2659
        }
2634
2660
 
 
2661
        function get_all_discovered_feeds()
 
2662
        {
 
2663
                return $this->all_discovered_feeds;
 
2664
        }
 
2665
 
2635
2666
        function get_description()
2636
2667
        {
2637
2668
                if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle'))
2650
2681
                {
2651
2682
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2652
2683
                }
2653
 
                elseif ($return = $this->get_channel_tags('', 'description'))
 
2684
                elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
2654
2685
                {
2655
 
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
 
2686
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
2656
2687
                }
2657
2688
                elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
2658
2689
                {
2686
2717
                {
2687
2718
                        return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2688
2719
                }
2689
 
                elseif ($return = $this->get_channel_tags('', 'copyright'))
 
2720
                elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright'))
2690
2721
                {
2691
2722
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2692
2723
                }
2706
2737
 
2707
2738
        function get_language()
2708
2739
        {
2709
 
                if ($return = $this->get_channel_tags('', 'language'))
 
2740
                if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language'))
2710
2741
                {
2711
2742
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2712
2743
                }
2786
2817
                {
2787
2818
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2788
2819
                }
2789
 
                elseif ($return = $this->get_image_tags('', 'title'))
 
2820
                elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
2790
2821
                {
2791
2822
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2792
2823
                }
2826
2857
                {
2827
2858
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2828
2859
                }
2829
 
                elseif ($return = $this->get_image_tags('', 'url'))
 
2860
                elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url'))
2830
2861
                {
2831
2862
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2832
2863
                }
2846
2877
                {
2847
2878
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2848
2879
                }
2849
 
                elseif ($return = $this->get_image_tags('', 'link'))
 
2880
                elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
2850
2881
                {
2851
2882
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2852
2883
                }
2858
2889
 
2859
2890
        function get_image_width()
2860
2891
        {
2861
 
                if ($return = $this->get_image_tags('', 'width'))
 
2892
                if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'width'))
2862
2893
                {
2863
2894
                        return round($return[0]['data']);
2864
2895
                }
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'))
2866
2897
                {
2867
2898
                        return 88.0;
2868
2899
                }
2874
2905
 
2875
2906
        function get_image_height()
2876
2907
        {
2877
 
                if ($return = $this->get_image_tags('', 'height'))
 
2908
                if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'height'))
2878
2909
                {
2879
2910
                        return round($return[0]['data']);
2880
2911
                }
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'))
2882
2913
                {
2883
2914
                        return 31.0;
2884
2915
                }
2890
2921
 
2891
2922
        function get_item_quantity($max = 0)
2892
2923
        {
 
2924
                $max = (int) $max;
2893
2925
                $qty = count($this->get_items());
2894
 
                if ($max == 0)
 
2926
                if ($max === 0)
2895
2927
                {
2896
2928
                        return $qty;
2897
2929
                }
2916
2948
 
2917
2949
        function get_items($start = 0, $end = 0)
2918
2950
        {
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
                                        }
2963
2999
                                }
2964
3000
                        }
2965
3001
                }
2967
3003
                if (!empty($this->data['items']))
2968
3004
                {
2969
3005
                        // 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))
2971
3007
                        {
2972
3008
                                if (!isset($this->data['ordered_items']))
2973
3009
                                {
2995
3031
                        }
2996
3032
 
2997
3033
                        // Slice the data as desired
2998
 
                        if ($end == 0)
 
3034
                        if ($end === 0)
2999
3035
                        {
3000
3036
                                return array_slice($items, $start);
3001
3037
                        }
3010
3046
                }
3011
3047
        }
3012
3048
 
 
3049
        /**
 
3050
         * @static
 
3051
         */
3013
3052
        function sort_items($a, $b)
3014
3053
        {
3015
3054
                return $a->get_date('U') <= $b->get_date('U');
3016
3055
        }
3017
3056
 
 
3057
        /**
 
3058
         * @static
 
3059
         */
3018
3060
        function merge_items($urls, $start = 0, $end = 0, $limit = 0)
3019
3061
        {
3020
3062
                if (is_array($urls) && sizeof($urls) > 0)
3047
3089
                                usort($items, array('SimplePie', 'sort_items'));
3048
3090
                        }
3049
3091
 
3050
 
                        if ($end == 0)
 
3092
                        if ($end === 0)
3051
3093
                        {
3052
3094
                                return array_slice($items, $start);
3053
3095
                        }
3130
3172
                        {
3131
3173
                                return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3132
3174
                        }
3133
 
                        elseif ($return = $this->get_item_tags('', 'guid'))
 
3175
                        elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
3134
3176
                        {
3135
3177
                                return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3136
3178
                        }
3181
3223
                        {
3182
3224
                                $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
3183
3225
                        }
3184
 
                        elseif ($return = $this->get_item_tags('', 'title'))
 
3226
                        elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
3185
3227
                        {
3186
3228
                                $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
3187
3229
                        }
3215
3257
                {
3216
3258
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
3217
3259
                }
3218
 
                elseif ($return = $this->get_item_tags('', 'description'))
 
3260
                elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
3219
3261
                {
3220
3262
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
3221
3263
                }
3305
3347
                        }
3306
3348
                        $categories[] =& new $this->feed->category_class($term, $scheme, $label);
3307
3349
                }
3308
 
                foreach ((array) $this->get_item_tags('', 'category') as $category)
 
3350
                foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
3309
3351
                {
3310
 
                        $categories[] =& new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
 
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);
3311
3364
                }
3312
3365
                foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
3313
3366
                {
3412
3465
                }
3413
3466
        }
3414
3467
 
3415
 
        /**
3416
 
         * @todo Atom inheritance (item author, source author, feed author)
3417
 
         */
3418
3468
        function get_authors()
3419
3469
        {
3420
3470
                $authors = array();
3462
3512
                                $authors[] =& new $this->feed->author_class($name, $url, $email);
3463
3513
                        }
3464
3514
                }
3465
 
                if ($author = $this->get_item_tags('', 'author'))
 
3515
                if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author'))
3466
3516
                {
3467
3517
                        $authors[] =& new $this->feed->author_class(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
3468
3518
                }
3541
3591
                        {
3542
3592
                                $this->data['date']['raw'] = $return[0]['data'];
3543
3593
                        }
3544
 
                        elseif ($return = $this->get_item_tags('', 'pubDate'))
 
3594
                        elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate'))
3545
3595
                        {
3546
3596
                                $this->data['date']['raw'] = $return[0]['data'];
3547
3597
                        }
3662
3712
                        {
3663
3713
                                $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
3664
3714
                        }
3665
 
                        if ($links = $this->get_item_tags('', 'link'))
 
3715
                        if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
3666
3716
                        {
3667
3717
                                $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
3668
3718
                        }
3669
 
                        if ($links = $this->get_item_tags('', 'guid'))
 
3719
                        if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
3670
3720
                        {
3671
 
                                if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) == 'true')
 
3721
                                if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true')
3672
3722
                                {
3673
3723
                                        $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
3674
3724
                                }
3689
3739
                                                $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
3690
3740
                                        }
3691
3741
                                }
3692
 
                                elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
 
3742
                                elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
3693
3743
                                {
3694
3744
                                        $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
3695
3745
                                }
4255
4305
                                        $restriction_relationship = 'allow';
4256
4306
                                        $restriction_type = null;
4257
4307
                                        $restriction_value = 'itunes';
4258
 
                                        if (isset($restriction['data']) && strtolower($restriction['data']) == 'yes')
 
4308
                                        if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes')
4259
4309
                                        {
4260
4310
                                                $restriction_relationship = 'deny';
4261
4311
                                        }
4291
4341
                                        $restriction_relationship = 'allow';
4292
4342
                                        $restriction_type = null;
4293
4343
                                        $restriction_value = 'itunes';
4294
 
                                        if (isset($restriction['data']) && strtolower($restriction['data']) == 'yes')
 
4344
                                        if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes')
4295
4345
                                        {
4296
4346
                                                $restriction_relationship = 'deny';
4297
4347
                                        }
5402
5452
 
5403
5453
                        foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link)
5404
5454
                        {
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')
5406
5456
                                {
5407
5457
                                        // Attributes
5408
5458
                                        $bitrate = null;
5437
5487
 
5438
5488
                        foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link)
5439
5489
                        {
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')
5441
5491
                                {
5442
5492
                                        // Attributes
5443
5493
                                        $bitrate = null;
5470
5520
                                }
5471
5521
                        }
5472
5522
 
5473
 
                        if ($enclosure = $this->get_item_tags('', 'enclosure'))
 
5523
                        if ($enclosure = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure'))
5474
5524
                        {
5475
5525
                                if (isset($enclosure[0]['attribs']['']['url']))
5476
5526
                                {
5505
5555
                                }
5506
5556
                        }
5507
5557
 
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))
5509
5559
                        {
5510
5560
                                // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
5511
5561
                                $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width);
5584
5634
        {
5585
5635
                if ($this->get_permalink() !== null)
5586
5636
                {
5587
 
                        $return = $this->sanitize($item_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_permalink());
 
5637
                        $return = $item_url . rawurlencode($this->get_permalink());
5588
5638
                        if ($title_url !== null && $this->get_title() !== null)
5589
5639
                        {
5590
 
                                $return .= $this->sanitize($title_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_title());
 
5640
                                $return .= $title_url . rawurlencode($this->get_title());
5591
5641
                        }
5592
5642
                        if ($summary_url !== null && $this->get_description() !== null)
5593
5643
                        {
5594
 
                                $return .= $this->sanitize($summary_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_description());
 
5644
                                $return .= $summary_url . rawurlencode($this->get_description());
5595
5645
                        }
5596
 
                        return $return;
 
5646
                        return $this->sanitize($return, SIMPLEPIE_CONSTRUCT_IRI);
5597
5647
                }
5598
5648
                else
5599
5649
                {
5733
5783
                {
5734
5784
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
5735
5785
                }
5736
 
                elseif ($return = $this->get_source_tags('', 'title'))
 
5786
                elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
5737
5787
                {
5738
5788
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
5739
5789
                }
5787
5837
                        }
5788
5838
                        $categories[] =& new $this->item->feed->category_class($term, $scheme, $label);
5789
5839
                }
5790
 
                foreach ((array) $this->get_source_tags('', 'category') as $category)
 
5840
                foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
5791
5841
                {
5792
 
                        $categories[] =& new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
 
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);
5793
5854
                }
5794
5855
                foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
5795
5856
                {
6021
6082
                        {
6022
6083
                                $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
6023
6084
                        }
6024
 
                        if ($links = $this->get_source_tags('', 'link'))
 
6085
                        if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
6025
6086
                        {
6026
6087
                                $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
6027
6088
                        }
6041
6102
                                                $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
6042
6103
                                        }
6043
6104
                                }
6044
 
                                elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
 
6105
                                elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
6045
6106
                                {
6046
6107
                                        $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
6047
6108
                                }
6077
6138
                {
6078
6139
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
6079
6140
                }
6080
 
                elseif ($return = $this->get_source_tags('', 'description'))
 
6141
                elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
6081
6142
                {
6082
6143
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
6083
6144
                }
6113
6174
                {
6114
6175
                        return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
6115
6176
                }
6116
 
                elseif ($return = $this->get_source_tags('', 'copyright'))
 
6177
                elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright'))
6117
6178
                {
6118
6179
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6119
6180
                }
6133
6194
 
6134
6195
        function get_language()
6135
6196
        {
6136
 
                if ($return = $this->get_source_tags('', 'language'))
 
6197
                if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language'))
6137
6198
                {
6138
6199
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6139
6200
                }
6932
6993
                $mime = $mime[0];
6933
6994
 
6934
6995
                // Process values for 'auto'
6935
 
                if ($width == 'auto')
 
6996
                if ($width === 'auto')
6936
6997
                {
6937
 
                        if ($mime == 'video')
 
6998
                        if ($mime === 'video')
6938
6999
                        {
6939
 
                                if ($height == 'auto')
 
7000
                                if ($height === 'auto')
6940
7001
                                {
6941
7002
                                        $width = 480;
6942
7003
                                }
6955
7016
                        }
6956
7017
                }
6957
7018
 
6958
 
                if ($height == 'auto')
 
7019
                if ($height === 'auto')
6959
7020
                {
6960
 
                        if ($mime == 'audio')
 
7021
                        if ($mime === 'audio')
6961
7022
                        {
6962
7023
                                $height = 0;
6963
7024
                        }
6964
 
                        elseif ($mime == 'video')
 
7025
                        elseif ($mime === 'video')
6965
7026
                        {
6966
 
                                if ($width == 'auto')
 
7027
                                if ($width === 'auto')
6967
7028
                                {
6968
7029
                                        if ($widescreen)
6969
7030
                                        {
6988
7049
                                $height = 376;
6989
7050
                        }
6990
7051
                }
6991
 
                elseif ($mime == 'audio')
 
7052
                elseif ($mime === 'audio')
6992
7053
                {
6993
7054
                        $height = 0;
6994
7055
                }
6995
7056
 
6996
7057
                // Set proper placeholder value
6997
 
                if ($mime == 'audio')
 
7058
                if ($mime === 'audio')
6998
7059
                {
6999
7060
                        $placeholder = $audio;
7000
7061
                }
7001
 
                elseif ($mime == 'video')
 
7062
                elseif ($mime === 'video')
7002
7063
                {
7003
7064
                        $placeholder = $video;
7004
7065
                }
7017
7078
                }
7018
7079
 
7019
7080
                // Odeo Feed MP3's
7020
 
                if ($handler == 'odeo')
 
7081
                if ($handler === 'odeo')
7021
7082
                {
7022
7083
                        if ($native)
7023
7084
                        {
7030
7091
                }
7031
7092
 
7032
7093
                // Flash
7033
 
                elseif ($handler == 'flash')
 
7094
                elseif ($handler === 'flash')
7034
7095
                {
7035
7096
                        if ($native)
7036
7097
                        {
7044
7105
 
7045
7106
                // Flash Media Player file types.
7046
7107
                // Preferred handler for MP3 file types.
7047
 
                elseif ($handler == 'fmedia' || ($handler == 'mp3' && $mediaplayer != ''))
 
7108
                elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== ''))
7048
7109
                {
7049
7110
                        $height += 20;
7050
7111
                        if ($native)
7059
7120
 
7060
7121
                // QuickTime 7 file types.  Need to test with QuickTime 6.
7061
7122
                // 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 === ''))
7063
7124
                {
7064
7125
                        $height += 16;
7065
7126
                        if ($native)
7066
7127
                        {
7067
 
                                if ($placeholder != ""){
 
7128
                                if ($placeholder !== '')
 
7129
                                {
7068
7130
                                        $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>";
7069
7131
                                }
7070
 
                                else {
 
7132
                                else
 
7133
                                {
7071
7134
                                        $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>";
7072
7135
                                }
7073
7136
                        }
7078
7141
                }
7079
7142
 
7080
7143
                // Windows Media
7081
 
                elseif ($handler == 'wmedia')
 
7144
                elseif ($handler === 'wmedia')
7082
7145
                {
7083
7146
                        $height += 45;
7084
7147
                        if ($native)
7100
7163
        function get_real_type($find_handler = false)
7101
7164
        {
7102
7165
                // 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')
7104
7167
                {
7105
7168
                        return 'odeo';
7106
7169
                }
7628
7691
                                }
7629
7692
 
7630
7693
                                $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)
7632
7695
                                {
7633
7696
                                        curl_setopt($fp, CURLOPT_ENCODING, 'none');
7634
7697
                                        $this->headers = curl_exec($fp);
7650
7713
                                                $this->headers = $parser->headers;
7651
7714
                                                $this->body = $parser->body;
7652
7715
                                                $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)
7654
7717
                                                {
7655
7718
                                                        $this->redirects++;
7656
7719
                                                        $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
7663
7726
                        {
7664
7727
                                $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
7665
7728
                                $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')
7667
7730
                                {
7668
7731
                                        $url_parts['host'] = "ssl://$url_parts[host]";
7669
7732
                                        $url_parts['port'] = 443;
7731
7794
                                                        $this->headers = $parser->headers;
7732
7795
                                                        $this->body = $parser->body;
7733
7796
                                                        $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)
7735
7798
                                                        {
7736
7799
                                                                $this->redirects++;
7737
7800
                                                                $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
8438
8501
                        if ($this->flags & 8)
8439
8502
                        {
8440
8503
                                // Get the length of the filename
8441
 
                                $len = strspn($this->compressed_data, "\x00", $this->position);
 
8504
                                $len = strcspn($this->compressed_data, "\x00", $this->position);
8442
8505
 
8443
8506
                                // Check the length of the string is still valid
8444
8507
                                $this->min_compressed_size += $len + 1;
8458
8521
                        if ($this->flags & 16)
8459
8522
                        {
8460
8523
                                // Get the length of the comment
8461
 
                                $len = strspn($this->compressed_data, "\x00", $this->position);
 
8524
                                $len = strcspn($this->compressed_data, "\x00", $this->position);
8462
8525
 
8463
8526
                                // Check the length of the string is still valid
8464
8527
                                $this->min_compressed_size += $len + 1;
8556
8619
         */
8557
8620
        function create($location, $filename, $extension)
8558
8621
        {
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
                }
8560
8635
        }
8561
8636
}
8562
8637
 
8570
8645
        function SimplePie_Cache_File($location, $filename, $extension)
8571
8646
        {
8572
8647
                $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";
8576
8651
        }
8577
8652
 
8578
8653
        function save($data)
8641
8716
        }
8642
8717
}
8643
8718
 
 
8719
class 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
 
 
8799
class 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
 
8644
9071
class SimplePie_Misc
8645
9072
{
8646
9073
        function time_hms($seconds)
8673
9100
 
8674
9101
        function absolutize_url($relative, $base)
8675
9102
        {
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();
8744
9105
        }
8745
9106
 
8746
9107
        function remove_dot_segments($input)
8747
9108
        {
8748
9109
                $output = '';
8749
 
                while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input == '.' || $input == '..')
 
9110
                while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..')
8750
9111
                {
8751
9112
                        // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise,
8752
9113
                        if (strpos($input, '../') === 0)
8762
9123
                        {
8763
9124
                                $input = substr_replace($input, '/', 0, 3);
8764
9125
                        }
8765
 
                        elseif ($input == '/.')
 
9126
                        elseif ($input === '/.')
8766
9127
                        {
8767
9128
                                $input = '/';
8768
9129
                        }
8772
9133
                                $input = substr_replace($input, '/', 0, 4);
8773
9134
                                $output = substr_replace($output, '', strrpos($output, '/'));
8774
9135
                        }
8775
 
                        elseif ($input == '/..')
 
9136
                        elseif ($input === '/..')
8776
9137
                        {
8777
9138
                                $input = '/';
8778
9139
                                $output = substr_replace($output, '', strrpos($output, '/'));
8779
9140
                        }
8780
9141
                        // 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 === '..')
8782
9143
                        {
8783
9144
                                $input = '';
8784
9145
                        }
8822
9183
                                {
8823
9184
                                        for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++)
8824
9185
                                        {
8825
 
                                                if (count($attribs[$j]) == 2)
 
9186
                                                if (count($attribs[$j]) === 2)
8826
9187
                                                {
8827
9188
                                                        $attribs[$j][2] = $attribs[$j][1];
8828
9189
                                                }
8855
9216
 
8856
9217
        function error($message, $level, $file, $line)
8857
9218
        {
8858
 
                switch ($level)
 
9219
                if ((ini_get('error_reporting') & $level) > 0)
8859
9220
                {
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;
 
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);
8872
9237
                }
8873
 
                error_log("$note: $message in $file on line $line", 0);
8874
9238
                return $message;
8875
9239
        }
8876
9240
 
8922
9286
        {
8923
9287
                $url = SimplePie_Misc::normalize_url($url);
8924
9288
                $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')
8926
9290
                {
8927
9291
                        return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http);
8928
9292
                }
8932
9296
                        return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http);
8933
9297
                }
8934
9298
 
8935
 
                if ($http == 2 && $parsed['scheme'] !== '')
 
9299
                if ($http === 2 && $parsed['scheme'] !== '')
8936
9300
                {
8937
9301
                        return "feed:$url";
8938
9302
                }
8939
 
                elseif ($http == 3 && strtolower($parsed['scheme']) == 'http')
 
9303
                elseif ($http === 3 && strtolower($parsed['scheme']) === 'http')
8940
9304
                {
8941
9305
                        return substr_replace($url, 'podcast', 0, 4);
8942
9306
                }
8943
 
                elseif ($http == 4 && strtolower($parsed['scheme']) == 'http')
 
9307
                elseif ($http === 4 && strtolower($parsed['scheme']) === 'http')
8944
9308
                {
8945
9309
                        return substr_replace($url, 'itpc', 0, 4);
8946
9310
                }
8952
9316
 
8953
9317
        function parse_url($url)
8954
9318
        {
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
                );
8961
9327
        }
8962
9328
 
8963
9329
        function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '')
8964
9330
        {
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();
8987
9338
        }
8988
9339
 
8989
9340
        function normalize_url($url)
8990
9341
        {
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();
9000
9344
        }
9001
9345
 
9002
9346
        function percent_encoding_normalization($match)
9003
9347
        {
9004
9348
                $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)
9006
9350
                {
9007
9351
                        return chr($integer);
9008
9352
                }
9082
9426
                }
9083
9427
 
9084
9428
                // This is first, as behaviour of this is completely predictable
9085
 
                if ($input === 'Windows-1252' && $output === 'UTF-8')
 
9429
                if ($input === 'windows-1252' && $output === 'UTF-8')
9086
9430
                {
9087
9431
                        return SimplePie_Misc::windows_1252_to_utf8($data);
9088
9432
                }
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)))
9091
9435
                {
9092
9436
                        return $return;
9093
9437
                }
9105
9449
 
9106
9450
        function encoding($charset)
9107
9451
        {
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)))
9112
9454
                {
9113
9455
                        case 'adobestandardencoding':
9114
9456
                        case 'csadobestandardencoding':
9119
9461
                                return 'Adobe-Symbol-Encoding';
9120
9462
 
9121
9463
                        case 'ami1251':
9122
 
                        case 'ami1251':
9123
 
                        case 'amiga1251':
9124
9464
                        case 'amiga1251':
9125
9465
                                return 'Amiga-1251';
9126
9466
 
9134
9474
                        case 'arabic7':
9135
9475
                        case 'asmo449':
9136
9476
                        case 'csiso89asmo449':
 
9477
                        case 'iso9036':
9137
9478
                        case 'isoir89':
9138
 
                        case 'iso9036':
9139
9479
                                return 'ASMO_449';
9140
9480
 
9141
9481
                        case 'big5':
9157
9497
                        case 'bs4730':
9158
9498
                        case 'csiso4unitedkingdom':
9159
9499
                        case 'gb':
 
9500
                        case 'iso646gb':
9160
9501
                        case 'isoir4':
9161
 
                        case 'iso646gb':
9162
9502
                        case 'uk':
9163
9503
                                return 'BS_4730';
9164
9504
 
9175
9515
                        case 'csa71':
9176
9516
                        case 'csaz243419851':
9177
9517
                        case 'csiso121canadian1':
 
9518
                        case 'iso646ca':
9178
9519
                        case 'isoir121':
9179
 
                        case 'iso646ca':
9180
9520
                                return 'CSA_Z243.4-1985-1';
9181
9521
 
9182
9522
                        case 'csa72':
9183
9523
                        case 'csaz243419852':
9184
9524
                        case 'csiso122canadian2':
 
9525
                        case 'iso646ca2':
9185
9526
                        case 'isoir122':
9186
 
                        case 'iso646ca2':
9187
9527
                                return 'CSA_Z243.4-1985-2';
9188
9528
 
9189
9529
                        case 'csaz24341985gr':
9204
9544
                        case 'csiso21german':
9205
9545
                        case 'de':
9206
9546
                        case 'din66003':
 
9547
                        case 'iso646de':
9207
9548
                        case 'isoir21':
9208
 
                        case 'iso646de':
9209
9549
                                return 'DIN_66003';
9210
9550
 
9211
9551
                        case 'csdkus':
9215
9555
                        case 'csiso646danish':
9216
9556
                        case 'dk':
9217
9557
                        case 'ds2089':
9218
 
                        case 'ds2089':
9219
9558
                        case 'iso646dk':
9220
9559
                                return 'DS_2089';
9221
9560
 
9287
9626
 
9288
9627
                        case 'csiso17spanish':
9289
9628
                        case 'es':
 
9629
                        case 'iso646es':
9290
9630
                        case 'isoir17':
9291
 
                        case 'iso646es':
9292
9631
                                return 'ES';
9293
9632
 
9294
9633
                        case 'csiso85spanish2':
9295
9634
                        case 'es2':
 
9635
                        case 'iso646es2':
9296
9636
                        case 'isoir85':
9297
 
                        case 'iso646es2':
9298
9637
                                return 'ES2';
9299
9638
 
9300
9639
                        case 'cseucfixwidjapanese':
9309
9648
                        case 'gb18030':
9310
9649
                                return 'GB18030';
9311
9650
 
 
9651
                        case 'chinese':
9312
9652
                        case 'cp936':
9313
 
                        case 'gbk':
9314
 
                        case 'ms936':
9315
 
                        case 'windows936':
9316
9653
                        case 'csgb2312':
 
9654
                        case 'csiso58gb231280':
9317
9655
                        case 'gb2312':
9318
 
                        case 'chinese':
9319
 
                        case 'csiso58gb231280':
9320
9656
                        case 'gb231280':
 
9657
                        case 'gbk':
9321
9658
                        case 'isoir58':
 
9659
                        case 'ms936':
 
9660
                        case 'windows936':
9322
9661
                                return 'GBK';
9323
9662
 
9324
9663
                        case 'cn':
9325
9664
                        case 'csiso57gb1988':
9326
9665
                        case 'gb198880':
 
9666
                        case 'iso646cn':
9327
9667
                        case 'isoir57':
9328
 
                        case 'iso646cn':
9329
9668
                                return 'GB_1988-80';
9330
9669
 
9331
9670
                        case 'csiso153gost1976874':
9383
9722
                        case 'ibmthai':
9384
9723
                                return 'IBM-Thai';
9385
9724
 
9386
 
                        case 'ccsid00858':
9387
 
                        case 'cp00858':
9388
 
                        case 'ibm00858':
 
9725
                        case 'ccsid858':
 
9726
                        case 'cp858':
 
9727
                        case 'ibm858':
9389
9728
                        case 'pcmultilingual850euro':
9390
9729
                                return 'IBM00858';
9391
9730
 
9392
 
                        case 'ccsid00924':
9393
 
                        case 'cp00924':
 
9731
                        case 'ccsid924':
 
9732
                        case 'cp924':
9394
9733
                        case 'ebcdiclatin9euro':
9395
 
                        case 'ibm00924':
 
9734
                        case 'ibm924':
9396
9735
                                return 'IBM00924';
9397
9736
 
9398
 
                        case 'ccsid01140':
9399
 
                        case 'cp01140':
 
9737
                        case 'ccsid1140':
 
9738
                        case 'cp1140':
9400
9739
                        case 'ebcdicus37euro':
9401
 
                        case 'ibm01140':
 
9740
                        case 'ibm1140':
9402
9741
                                return 'IBM01140';
9403
9742
 
9404
 
                        case 'ccsid01141':
9405
 
                        case 'cp01141':
 
9743
                        case 'ccsid1141':
 
9744
                        case 'cp1141':
9406
9745
                        case 'ebcdicde273euro':
9407
 
                        case 'ibm01141':
 
9746
                        case 'ibm1141':
9408
9747
                                return 'IBM01141';
9409
9748
 
9410
 
                        case 'ccsid01142':
9411
 
                        case 'cp01142':
 
9749
                        case 'ccsid1142':
 
9750
                        case 'cp1142':
9412
9751
                        case 'ebcdicdk277euro':
9413
9752
                        case 'ebcdicno277euro':
9414
 
                        case 'ibm01142':
 
9753
                        case 'ibm1142':
9415
9754
                                return 'IBM01142';
9416
9755
 
9417
 
                        case 'ccsid01143':
9418
 
                        case 'cp01143':
 
9756
                        case 'ccsid1143':
 
9757
                        case 'cp1143':
9419
9758
                        case 'ebcdicfi278euro':
9420
9759
                        case 'ebcdicse278euro':
9421
 
                        case 'ibm01143':
 
9760
                        case 'ibm1143':
9422
9761
                                return 'IBM01143';
9423
9762
 
9424
 
                        case 'ccsid01144':
9425
 
                        case 'cp01144':
 
9763
                        case 'ccsid1144':
 
9764
                        case 'cp1144':
9426
9765
                        case 'ebcdicit280euro':
9427
 
                        case 'ibm01144':
 
9766
                        case 'ibm1144':
9428
9767
                                return 'IBM01144';
9429
9768
 
9430
 
                        case 'ccsid01145':
9431
 
                        case 'cp01145':
 
9769
                        case 'ccsid1145':
 
9770
                        case 'cp1145':
9432
9771
                        case 'ebcdices284euro':
9433
 
                        case 'ibm01145':
 
9772
                        case 'ibm1145':
9434
9773
                                return 'IBM01145';
9435
9774
 
9436
 
                        case 'ccsid01146':
9437
 
                        case 'cp01146':
 
9775
                        case 'ccsid1146':
 
9776
                        case 'cp1146':
9438
9777
                        case 'ebcdicgb285euro':
9439
 
                        case 'ibm01146':
 
9778
                        case 'ibm1146':
9440
9779
                                return 'IBM01146';
9441
9780
 
9442
 
                        case 'ccsid01147':
9443
 
                        case 'cp01147':
 
9781
                        case 'ccsid1147':
 
9782
                        case 'cp1147':
9444
9783
                        case 'ebcdicfr297euro':
9445
 
                        case 'ibm01147':
 
9784
                        case 'ibm1147':
9446
9785
                                return 'IBM01147';
9447
9786
 
9448
 
                        case 'ccsid01148':
9449
 
                        case 'cp01148':
 
9787
                        case 'ccsid1148':
 
9788
                        case 'cp1148':
9450
9789
                        case 'ebcdicinternational500euro':
9451
 
                        case 'ibm01148':
 
9790
                        case 'ibm1148':
9452
9791
                                return 'IBM01148';
9453
9792
 
9454
 
                        case 'ccsid01149':
9455
 
                        case 'cp01149':
 
9793
                        case 'ccsid1149':
 
9794
                        case 'cp1149':
9456
9795
                        case 'ebcdicis871euro':
9457
 
                        case 'ibm01149':
 
9796
                        case 'ibm1149':
9458
9797
                                return 'IBM01149';
9459
9798
 
9460
 
                        case 'cp037':
9461
 
                        case 'csibm037':
 
9799
                        case 'cp37':
 
9800
                        case 'csibm37':
9462
9801
                        case 'ebcdiccpca':
9463
9802
                        case 'ebcdiccpnl':
9464
9803
                        case 'ebcdiccpus':
9465
9804
                        case 'ebcdiccpwt':
9466
 
                        case 'ibm037':
 
9805
                        case 'ibm37':
9467
9806
                                return 'IBM037';
9468
9807
 
9469
 
                        case 'cp038':
9470
 
                        case 'csibm038':
 
9808
                        case 'cp38':
 
9809
                        case 'csibm38':
9471
9810
                        case 'ebcdicint':
9472
 
                        case 'ibm038':
 
9811
                        case 'ibm38':
9473
9812
                                return 'IBM038';
9474
9813
 
9475
9814
                        case 'cp273':
9611
9950
                                return 'IBM860';
9612
9951
 
9613
9952
                        case '861':
 
9953
                        case 'cp861':
9614
9954
                        case 'cpis':
9615
 
                        case 'cp861':
9616
9955
                        case 'csibm861':
9617
9956
                        case 'ibm861':
9618
9957
                                return 'IBM861';
9646
9985
                        case 'ibm866':
9647
9986
                                return 'IBM866';
9648
9987
 
 
9988
                        case 'cp868':
9649
9989
                        case 'cpar':
9650
 
                        case 'cp868':
9651
9990
                        case 'csibm868':
9652
9991
                        case 'ibm868':
9653
9992
                                return 'IBM868';
9654
9993
 
9655
9994
                        case '869':
 
9995
                        case 'cp869':
9656
9996
                        case 'cpgr':
9657
 
                        case 'cp869':
9658
9997
                        case 'csibm869':
9659
9998
                        case 'ibm869':
9660
9999
                                return 'IBM869';
9712
10051
                                return 'IBM1026';
9713
10052
 
9714
10053
                        case 'ibm1047':
9715
 
                        case 'ibm1047':
9716
10054
                                return 'IBM1047';
9717
10055
 
9718
10056
                        case 'csiso143iecp271':
9767
10105
 
9768
10106
                        case 'csisolatin2':
9769
10107
                        case 'iso88592':
 
10108
                        case 'iso885921987':
9770
10109
                        case 'isoir101':
9771
 
                        case 'iso88592':
9772
 
                        case 'iso885921987':
9773
10110
                        case 'l2':
9774
10111
                        case 'latin2':
9775
10112
                                return 'ISO-8859-2';
9780
10117
 
9781
10118
                        case 'csisolatin3':
9782
10119
                        case 'iso88593':
 
10120
                        case 'iso885931988':
9783
10121
                        case 'isoir109':
9784
 
                        case 'iso88593':
9785
 
                        case 'iso885931988':
9786
10122
                        case 'l3':
9787
10123
                        case 'latin3':
9788
10124
                                return 'ISO-8859-3';
9789
10125
 
9790
10126
                        case 'csisolatin4':
9791
10127
                        case 'iso88594':
 
10128
                        case 'iso885941988':
9792
10129
                        case 'isoir110':
9793
 
                        case 'iso88594':
9794
 
                        case 'iso885941988':
9795
10130
                        case 'l4':
9796
10131
                        case 'latin4':
9797
10132
                                return 'ISO-8859-4';
9799
10134
                        case 'csisolatincyrillic':
9800
10135
                        case 'cyrillic':
9801
10136
                        case 'iso88595':
 
10137
                        case 'iso885951988':
9802
10138
                        case 'isoir144':
9803
 
                        case 'iso88595':
9804
 
                        case 'iso885951988':
9805
10139
                                return 'ISO-8859-5';
9806
10140
 
9807
10141
                        case 'arabic':
9809
10143
                        case 'csisolatinarabic':
9810
10144
                        case 'ecma114':
9811
10145
                        case 'iso88596':
 
10146
                        case 'iso885961987':
9812
10147
                        case 'isoir127':
9813
 
                        case 'iso88596':
9814
 
                        case 'iso885961987':
9815
10148
                                return 'ISO-8859-6';
9816
10149
 
9817
10150
                        case 'csiso88596e':
9818
10151
                        case 'iso88596e':
9819
 
                        case 'iso88596e':
9820
10152
                                return 'ISO-8859-6-E';
9821
10153
 
9822
10154
                        case 'csiso88596i':
9823
10155
                        case 'iso88596i':
9824
 
                        case 'iso88596i':
9825
10156
                                return 'ISO-8859-6-I';
9826
10157
 
9827
10158
                        case 'csisolatingreek':
9830
10161
                        case 'greek':
9831
10162
                        case 'greek8':
9832
10163
                        case 'iso88597':
 
10164
                        case 'iso885971987':
9833
10165
                        case 'isoir126':
9834
 
                        case 'iso88597':
9835
 
                        case 'iso885971987':
9836
10166
                                return 'ISO-8859-7';
9837
10167
 
9838
10168
                        case 'csisolatinhebrew':
9839
10169
                        case 'hebrew':
9840
10170
                        case 'iso88598':
 
10171
                        case 'iso885981988':
9841
10172
                        case 'isoir138':
9842
 
                        case 'iso88598':
9843
 
                        case 'iso885981988':
9844
10173
                                return 'ISO-8859-8';
9845
10174
 
9846
10175
                        case 'csiso88598e':
9847
10176
                        case 'iso88598e':
9848
 
                        case 'iso88598e':
9849
10177
                                return 'ISO-8859-8-E';
9850
10178
 
9851
10179
                        case 'csiso88598i':
9852
10180
                        case 'iso88598i':
9853
 
                        case 'iso88598i':
9854
10181
                                return 'ISO-8859-8-I';
9855
10182
 
9856
10183
                        case 'cswindows31latin5':
9859
10186
 
9860
10187
                        case 'csisolatin6':
9861
10188
                        case 'iso885910':
 
10189
                        case 'iso8859101992':
9862
10190
                        case 'isoir157':
9863
 
                        case 'iso8859101992':
9864
10191
                        case 'l6':
9865
10192
                        case 'latin6':
9866
10193
                                return 'ISO-8859-10';
9869
10196
                                return 'ISO-8859-13';
9870
10197
 
9871
10198
                        case 'iso885914':
 
10199
                        case 'iso8859141998':
9872
10200
                        case 'isoceltic':
9873
10201
                        case 'isoir199':
9874
 
                        case 'iso885914':
9875
 
                        case 'iso8859141998':
9876
10202
                        case 'l8':
9877
10203
                        case 'latin8':
9878
10204
                                return 'ISO-8859-14';
9879
10205
 
9880
10206
                        case 'iso885915':
9881
 
                        case 'iso885915':
9882
10207
                        case 'latin9':
9883
10208
                                return 'ISO-8859-15';
9884
10209
 
9885
10210
                        case 'iso885916':
 
10211
                        case 'iso8859162001':
9886
10212
                        case 'isoir226':
9887
 
                        case 'iso885916':
9888
 
                        case 'iso8859162001':
9889
10213
                        case 'l10':
9890
10214
                        case 'latin10':
9891
10215
                                return 'ISO-8859-16';
9916
10240
 
9917
10241
                        case 'csiso115481':
9918
10242
                        case 'iso115481':
9919
 
                        case 'iso115481':
9920
10243
                        case 'isotr115481':
9921
10244
                                return 'ISO-11548-1';
9922
10245
 
9951
10274
 
9952
10275
                        case 'csiso2intlrefversion':
9953
10276
                        case 'irv':
 
10277
                        case 'iso646irv1983':
9954
10278
                        case 'isoir2':
9955
 
                        case 'iso646irv1983':
9956
10279
                                return 'ISO_646.irv:1983';
9957
10280
 
9958
10281
                        case 'csiso2033':
9959
10282
                        case 'e13b':
 
10283
                        case 'iso20331983':
9960
10284
                        case 'isoir98':
9961
 
                        case 'iso20331983':
9962
10285
                                return 'ISO_2033-1983';
9963
10286
 
9964
10287
                        case 'csiso5427cyrillic':
 
10288
                        case 'iso5427':
9965
10289
                        case 'isoir37':
9966
 
                        case 'iso5427':
9967
10290
                                return 'ISO_5427';
9968
10291
 
9969
 
                        case 'isoir54':
9970
10292
                        case 'iso5427cyrillic1981':
9971
10293
                        case 'iso54271981':
 
10294
                        case 'isoir54':
9972
10295
                                return 'ISO_5427:1981';
9973
10296
 
9974
10297
                        case 'csiso5428greek':
 
10298
                        case 'iso54281980':
9975
10299
                        case 'isoir55':
9976
 
                        case 'iso54281980':
9977
10300
                                return 'ISO_5428:1980';
9978
10301
 
9979
10302
                        case 'csiso6937add':
 
10303
                        case 'iso6937225':
9980
10304
                        case 'isoir152':
9981
 
                        case 'iso6937225':
9982
10305
                                return 'ISO_6937-2-25';
9983
10306
 
9984
10307
                        case 'csisotextcomm':
 
10308
                        case 'iso69372add':
9985
10309
                        case 'isoir142':
9986
 
                        case 'iso69372add':
9987
10310
                                return 'ISO_6937-2-add';
9988
10311
 
9989
10312
                        case 'csiso8859supp':
 
10313
                        case 'iso8859supp':
9990
10314
                        case 'isoir154':
9991
 
                        case 'iso8859supp':
9992
10315
                        case 'latin125':
9993
10316
                                return 'ISO_8859-supp';
9994
10317
 
9995
10318
                        case 'csiso10367box':
 
10319
                        case 'iso10367box':
9996
10320
                        case 'isoir155':
9997
 
                        case 'iso10367box':
9998
10321
                                return 'ISO_10367-box';
9999
10322
 
10000
10323
                        case 'csiso15italian':
 
10324
                        case 'iso646it':
10001
10325
                        case 'isoir15':
10002
 
                        case 'iso646it':
10003
10326
                        case 'it':
10004
10327
                                return 'IT';
10005
10328
 
10008
10331
                        case 'jisc62201969':
10009
10332
                        case 'jisc62201969jp':
10010
10333
                        case 'katakana':
10011
 
                        case 'x02017':
 
10334
                        case 'x2017':
10012
10335
                                return 'JIS_C6220-1969-jp';
10013
10336
 
10014
10337
                        case 'csiso14jisc6220ro':
 
10338
                        case 'iso646jp':
10015
10339
                        case 'isoir14':
10016
 
                        case 'iso646jp':
10017
10340
                        case 'jisc62201969ro':
10018
10341
                        case 'jp':
10019
10342
                                return 'JIS_C6220-1969-ro';
10023
10346
                        case 'jisc62261978':
10024
10347
                                return 'JIS_C6226-1978';
10025
10348
 
10026
 
                        case 'csiso87jisx0208':
 
10349
                        case 'csiso87jisx208':
10027
10350
                        case 'isoir87':
10028
10351
                        case 'jisc62261983':
10029
 
                        case 'jisx02081983':
10030
 
                        case 'x0208':
 
10352
                        case 'jisx2081983':
 
10353
                        case 'x208':
10031
10354
                                return 'JIS_C6226-1983';
10032
10355
 
10033
10356
                        case 'csiso91jisc62291984a':
10037
10360
                                return 'JIS_C6229-1984-a';
10038
10361
 
10039
10362
                        case 'csiso92jisc62991984b':
10040
 
                        case 'isoir92':
10041
10363
                        case 'iso646jpocrb':
 
10364
                        case 'isoir92':
10042
10365
                        case 'jisc62291984b':
10043
10366
                        case 'jpocrb':
10044
10367
                                return 'JIS_C6229-1984-b';
10071
10394
                                return 'JIS_Encoding';
10072
10395
 
10073
10396
                        case 'cshalfwidthkatakana':
10074
 
                        case 'jisx0201':
10075
 
                        case 'x0201':
 
10397
                        case 'jisx201':
 
10398
                        case 'x201':
10076
10399
                                return 'JIS_X0201';
10077
10400
 
10078
 
                        case 'csiso159jisx02121990':
 
10401
                        case 'csiso159jisx2121990':
10079
10402
                        case 'isoir159':
10080
 
                        case 'jisx02121990':
10081
 
                        case 'x0212':
 
10403
                        case 'jisx2121990':
 
10404
                        case 'x212':
10082
10405
                                return 'JIS_X0212-1990';
10083
10406
 
10084
10407
                        case 'csiso141jusib1002':
 
10408
                        case 'iso646yu':
10085
10409
                        case 'isoir141':
10086
 
                        case 'iso646yu':
10087
10410
                        case 'js':
10088
10411
                        case 'jusib1002':
10089
10412
                        case 'yu':
10157
10480
 
10158
10481
                        case 'csiso86hungarian':
10159
10482
                        case 'hu':
 
10483
                        case 'iso646hu':
10160
10484
                        case 'isoir86':
10161
 
                        case 'iso646hu':
10162
10485
                        case 'msz77953':
10163
10486
                                return 'MSZ_7795.3';
10164
10487
 
10184
10507
 
10185
10508
                        case 'csiso151cuba':
10186
10509
                        case 'cuba':
 
10510
                        case 'iso646cu':
10187
10511
                        case 'isoir151':
10188
 
                        case 'iso646cu':
10189
 
                        case 'ncnc001081':
 
10512
                        case 'ncnc1081':
10190
10513
                                return 'NC_NC00-10:81';
10191
10514
 
10192
10515
                        case 'csiso69french':
10193
10516
                        case 'fr':
 
10517
                        case 'iso646fr':
10194
10518
                        case 'isoir69':
10195
 
                        case 'iso646fr':
10196
10519
                        case 'nfz62010':
10197
10520
                                return 'NF_Z_62-010';
10198
10521
 
10199
10522
                        case 'csiso25french':
 
10523
                        case 'iso646fr1':
10200
10524
                        case 'isoir25':
10201
 
                        case 'iso646fr1':
10202
10525
                        case 'nfz620101973':
10203
10526
                                return 'NF_Z_62-010_(1973)';
10204
10527
 
10205
10528
                        case 'csiso60danishnorwegian':
10206
10529
                        case 'csiso60norwegian1':
 
10530
                        case 'iso646no':
10207
10531
                        case 'isoir60':
10208
 
                        case 'iso646no':
10209
10532
                        case 'no':
10210
10533
                        case 'ns45511':
10211
10534
                                return 'NS_4551-1';
10212
10535
 
10213
10536
                        case 'csiso61norwegian2':
 
10537
                        case 'iso646no2':
10214
10538
                        case 'isoir61':
10215
 
                        case 'iso646no2':
10216
10539
                        case 'no2':
10217
10540
                        case 'ns45512':
10218
10541
                                return 'NS_4551-2';
10219
10542
 
10220
 
                        case 'osdebcdicdf03irv':
 
10543
                        case 'osdebcdicdf3irv':
10221
10544
                                return 'OSD_EBCDIC_DF03_IRV';
10222
10545
 
10223
 
                        case 'osdebcdicdf041':
 
10546
                        case 'osdebcdicdf41':
10224
10547
                                return 'OSD_EBCDIC_DF04_1';
10225
10548
 
10226
 
                        case 'osdebcdicdf0415':
 
10549
                        case 'osdebcdicdf415':
10227
10550
                                return 'OSD_EBCDIC_DF04_15';
10228
10551
 
10229
10552
                        case 'cspc8danishnorwegian':
10235
10558
                                return 'PC8-Turkish';
10236
10559
 
10237
10560
                        case 'csiso16portuguese':
 
10561
                        case 'iso646pt':
10238
10562
                        case 'isoir16':
10239
 
                        case 'iso646pt':
10240
10563
                        case 'pt':
10241
10564
                                return 'PT';
10242
10565
 
10243
10566
                        case 'csiso84portuguese2':
 
10567
                        case 'iso646pt2':
10244
10568
                        case 'isoir84':
10245
 
                        case 'iso646pt2':
10246
10569
                        case 'pt2':
10247
10570
                                return 'PT2';
10248
10571
 
10258
10581
 
10259
10582
                        case 'csiso10swedish':
10260
10583
                        case 'fi':
10261
 
                        case 'isoir10':
10262
10584
                        case 'iso646fi':
10263
10585
                        case 'iso646se':
 
10586
                        case 'isoir10':
10264
10587
                        case 'se':
10265
10588
                        case 'sen850200b':
10266
10589
                                return 'SEN_850200_B';
10267
10590
 
10268
10591
                        case 'csiso11swedishfornames':
 
10592
                        case 'iso646se2':
10269
10593
                        case 'isoir11':
10270
 
                        case 'iso646se2':
10271
10594
                        case 'se2':
10272
10595
                        case 'sen850200c':
10273
10596
                                return 'SEN_850200_C';
10315
10638
                        case 'cp367':
10316
10639
                        case 'csascii':
10317
10640
                        case 'ibm367':
 
10641
                        case 'iso646irv1991':
 
10642
                        case 'iso646us':
10318
10643
                        case 'isoir6':
10319
 
                        case 'iso646us':
10320
 
                        case 'iso646irv1991':
10321
10644
                        case 'us':
10322
10645
                        case 'usascii':
10323
10646
                                return 'US-ASCII';
10381
10704
 
10382
10705
                        case 'iso885911':
10383
10706
                        case 'tis620':
10384
 
                                return 'Windows-874';
 
10707
                                return 'windows-874';
10385
10708
 
10386
10709
                        case 'cseuckr':
 
10710
                        case 'csksc56011987':
10387
10711
                        case 'euckr':
10388
 
                        case 'windows949':
10389
 
                        case 'csksc56011987':
10390
10712
                        case 'isoir149':
10391
10713
                        case 'korean':
10392
10714
                        case 'ksc5601':
10393
10715
                        case 'ksc56011987':
10394
10716
                        case 'ksc56011989':
10395
 
                                return 'Windows-949';
 
10717
                        case 'windows949':
 
10718
                                return 'windows-949';
10396
10719
 
10397
10720
                        case 'windows1250':
10398
10721
                                return 'windows-1250';
10404
10727
                        case 'csisolatin1':
10405
10728
                        case 'ibm819':
10406
10729
                        case 'iso88591':
 
10730
                        case 'iso885911987':
10407
10731
                        case 'isoir100':
10408
 
                        case 'iso885911987':
10409
10732
                        case 'l1':
10410
10733
                        case 'latin1':
10411
10734
                        case 'windows1252':
10412
 
                                return 'Windows-1252';
10413
 
 
10414
 
                        case 'windows1252':
10415
10735
                                return 'windows-1252';
10416
10736
 
10417
10737
                        case 'windows1253':
10419
10739
 
10420
10740
                        case 'csisolatin5':
10421
10741
                        case 'iso88599':
 
10742
                        case 'iso885991989':
10422
10743
                        case 'isoir148':
10423
 
                        case 'iso885991989':
10424
10744
                        case 'l5':
10425
10745
                        case 'latin5':
10426
10746
                        case 'windows1254':
10427
 
                                return 'Windows-1254';
10428
 
 
10429
 
                        case 'windows1254':
10430
10747
                                return 'windows-1254';
10431
10748
 
10432
10749
                        case 'windows1255':
10452
10769
                {
10453
10770
                        $curl = $curl['version'];
10454
10771
                }
10455
 
                elseif (substr($curl, 0, 5) == 'curl/')
 
10772
                elseif (substr($curl, 0, 5) === 'curl/')
10456
10773
                {
10457
10774
                        $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5));
10458
10775
                }
10459
 
                elseif (substr($curl, 0, 8) == 'libcurl/')
 
10776
                elseif (substr($curl, 0, 8) === 'libcurl/')
10460
10777
                {
10461
10778
                        $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8));
10462
10779
                }
10469
10786
 
10470
10787
        function is_subclass_of($class1, $class2)
10471
10788
        {
10472
 
                if (func_num_args() != 2)
 
10789
                if (func_num_args() !== 2)
10473
10790
                {
10474
10791
                        trigger_error('Wrong parameter count for SimplePie_Misc::is_subclass_of()', E_USER_WARNING);
10475
10792
                }
10486
10803
                                        $class2 = strtolower($class2);
10487
10804
                                        while ($class1 = strtolower(get_parent_class($class1)))
10488
10805
                                        {
10489
 
                                                if ($class1 == $class2)
 
10806
                                                if ($class1 === $class2)
10490
10807
                                                {
10491
10808
                                                        return true;
10492
10809
                                                }
10633
10950
 
10634
10951
        function atom_03_construct_type($attribs)
10635
10952
        {
10636
 
                if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) == 'base64'))
 
10953
                if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) === 'base64'))
10637
10954
                {
10638
10955
                        $mode = SIMPLEPIE_CONSTRUCT_BASE64;
10639
10956
                }
10705
11022
                                case 'xhtml':
10706
11023
                                        return SIMPLEPIE_CONSTRUCT_XHTML;
10707
11024
                        }
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/')
10709
11026
                        {
10710
11027
                                return SIMPLEPIE_CONSTRUCT_NONE;
10711
11028
                        }
11005
11322
                }
11006
11323
                return $encoding;
11007
11324
        }
 
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
                ?>
 
11336
function 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
 
 
11340
function 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
 
 
11349
function 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
 
 
11353
function 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
 
 
11357
function 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
        }
11008
11362
}
11009
11363
 
11010
11364
/**
11083
11437
                }
11084
11438
                else
11085
11439
                {
11086
 
                        $this->consumed = false;
11087
11440
                        return false;
11088
11441
                }
11089
11442
        }
11106
11459
                }
11107
11460
                else
11108
11461
                {
11109
 
                        $this->consumed = false;
11110
11462
                        return false;
11111
11463
                }
11112
11464
        }
11180
11532
                                                $replacement = SimplePie_Misc::codepoint_to_utf8($codepoint);
11181
11533
                                        }
11182
11534
 
11183
 
                                        if ($this->consume() != ';')
 
11535
                                        if (!in_array($this->consume(), array(';', false), true))
11184
11536
                                        {
11185
11537
                                                $this->unconsume();
11186
11538
                                        }
11214
11566
}
11215
11567
 
11216
11568
/**
 
11569
 * IRI parser/serialiser
 
11570
 *
 
11571
 * @package SimplePie
 
11572
 */
 
11573
class 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
 */
 
12321
class 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;
 
12517
                }
 
12518
        }
 
12519
}
 
12520
 
 
12521
/**
11217
12522
 * Date Parser
11218
12523
 *
11219
12524
 * @package SimplePie
12769
14074
                $this->content_type_sniffer_class = $content_type_sniffer_class;
12770
14075
        }
12771
14076
 
12772
 
        function find($type = SIMPLEPIE_LOCATOR_ALL)
 
14077
        function find($type = SIMPLEPIE_LOCATOR_ALL, &$working)
12773
14078
        {
12774
14079
                if ($this->is_feed($this->file))
12775
14080
                {
12792
14097
 
12793
14098
                if ($type & SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working = $this->autodiscovery())
12794
14099
                {
12795
 
                        return $working;
 
14100
                        return $working[0];
12796
14101
                }
12797
14102
 
12798
14103
                if ($type & (SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY | SIMPLEPIE_LOCATOR_REMOTE_EXTENSION | SIMPLEPIE_LOCATOR_REMOTE_BODY) && $this->get_links())
12865
14170
        {
12866
14171
                $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));
12867
14172
                $done = array();
 
14173
                $feeds = array();
12868
14174
                foreach ($links as $link)
12869
14175
                {
12870
 
                        if ($this->checked_feeds == $this->max_checked_feeds)
 
14176
                        if ($this->checked_feeds === $this->max_checked_feeds)
12871
14177
                        {
12872
14178
                                break;
12873
14179
                        }
12884
14190
                                        $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base);
12885
14191
                                }
12886
14192
 
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]))
12888
14194
                                {
12889
14195
                                        $this->checked_feeds++;
12890
14196
                                        $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))
12892
14198
                                        {
12893
 
                                                return $feed;
 
14199
                                                $feeds[$href] = $feed;
12894
14200
                                        }
12895
14201
                                }
12896
14202
                                $done[] = $href;
12897
14203
                        }
12898
14204
                }
12899
 
                return null;
 
14205
 
 
14206
                if (!empty($feeds))
 
14207
                {
 
14208
                        return array_values($feeds);
 
14209
                }
 
14210
                else {
 
14211
                        return null;
 
14212
                }
12900
14213
        }
12901
14214
 
12902
14215
        function get_links()
12921
14234
 
12922
14235
                                        $current = SimplePie_Misc::parse_url($this->file->url);
12923
14236
 
12924
 
                                        if ($parsed['authority'] === '' || $parsed['authority'] == $current['authority'])
 
14237
                                        if ($parsed['authority'] === '' || $parsed['authority'] === $current['authority'])
12925
14238
                                        {
12926
14239
                                                $this->local[] = $href;
12927
14240
                                        }
12945
14258
        {
12946
14259
                foreach ($array as $key => $value)
12947
14260
                {
12948
 
                        if ($this->checked_feeds == $this->max_checked_feeds)
 
14261
                        if ($this->checked_feeds === $this->max_checked_feeds)
12949
14262
                        {
12950
14263
                                break;
12951
14264
                        }
12953
14266
                        {
12954
14267
                                $this->checked_feeds++;
12955
14268
                                $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))
12957
14270
                                {
12958
14271
                                        return $feed;
12959
14272
                                }
12970
14283
        {
12971
14284
                foreach ($array as $key => $value)
12972
14285
                {
12973
 
                        if ($this->checked_feeds == $this->max_checked_feeds)
 
14286
                        if ($this->checked_feeds === $this->max_checked_feeds)
12974
14287
                        {
12975
14288
                                break;
12976
14289
                        }
12978
14291
                        {
12979
14292
                                $this->checked_feeds++;
12980
14293
                                $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))
12982
14295
                                {
12983
14296
                                        return $feed;
12984
14297
                                }
13000
14313
        var $current_column;
13001
14314
        var $current_byte;
13002
14315
        var $separator = ' ';
13003
 
        var $feed = false;
13004
14316
        var $namespace = array('');
13005
14317
        var $element = array('');
13006
14318
        var $xml_base = array('');
13014
14326
        function parse(&$data, $encoding)
13015
14327
        {
13016
14328
                // 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')
13018
14330
                {
13019
14331
                        $this->encoding = 'UTF-8';
13020
14332
                }
13065
14377
                        }
13066
14378
                }
13067
14379
 
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
 
 
13075
14380
                $return = true;
13076
14381
 
 
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
 
13077
14391
                // 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
                }
13097
14484
        }
13098
14485
 
13099
14486
        function get_error_code()
13128
14515
 
13129
14516
        function tag_open($parser, $tag, $attributes)
13130
14517
        {
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
 
 
13152
14518
                list($this->namespace[], $this->element[]) = $this->split_ns($tag);
13153
14519
 
13154
14520
                $attribs = array();
13181
14547
                if ($this->current_xhtml_construct >= 0)
13182
14548
                {
13183
14549
                        $this->current_xhtml_construct++;
13184
 
                        if (end($this->namespace) == SIMPLEPIE_NAMESPACE_XHTML)
 
14550
                        if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML)
13185
14551
                        {
13186
14552
                                $this->data['data'] .= '<' . end($this->element);
13187
14553
                                if (isset($attribs['']))
13199
14565
                        $this->datas[] =& $this->data;
13200
14566
                        $this->data =& $this->data['child'][end($this->namespace)][end($this->element)][];
13201
14567
                        $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'))
13204
14570
                        {
13205
14571
                                $this->current_xhtml_construct = 0;
13206
14572
                        }
13213
14579
                {
13214
14580
                        $this->data['data'] .= htmlspecialchars($cdata, ENT_QUOTES, $this->encoding);
13215
14581
                }
13216
 
                elseif ($this->feed > 1)
 
14582
                else
13217
14583
                {
13218
14584
                        $this->data['data'] .= $cdata;
13219
14585
                }
13221
14587
 
13222
14588
        function tag_close($parser, $tag)
13223
14589
        {
13224
 
                if (!$this->feed)
13225
 
                {
13226
 
                        return;
13227
 
                }
13228
 
 
13229
14590
                if ($this->current_xhtml_construct >= 0)
13230
14591
                {
13231
14592
                        $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')))
13233
14594
                        {
13234
14595
                                $this->data['data'] .= '</' . end($this->element) . '>';
13235
14596
                        }
13236
14597
                }
13237
 
                if ($this->current_xhtml_construct == -1)
 
14598
                if ($this->current_xhtml_construct === -1)
13238
14599
                {
13239
 
                        $this->data =& $this->datas[$this->feed];
 
14600
                        $this->data =& $this->datas[count($this->datas) - 1];
13240
14601
                        array_pop($this->datas);
13241
14602
                }
13242
14603
 
13245
14606
                array_pop($this->xml_base);
13246
14607
                array_pop($this->xml_base_explicit);
13247
14608
                array_pop($this->xml_lang);
13248
 
                $this->feed--;
13249
14609
        }
13250
14610
 
13251
14611
        function split_ns($string)
13543
14903
                                                                $file =& new $this->file_class($img['attribs']['src']['data'], $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen);
13544
14904
                                                                $headers = $file->headers;
13545
14905
 
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)))
13547
14907
                                                                {
13548
14908
                                                                        if ($cache->save(array('headers' => $file->headers, 'body' => $file->body)))
13549
14909
                                                                        {
13552
14912
                                                                        }
13553
14913
                                                                        else
13554
14914
                                                                        {
13555
 
                                                                                trigger_error("$cache->name is not writeable", E_USER_WARNING);
 
14915
                                                                                trigger_error("$this->cache_location is not writeable", E_USER_WARNING);
13556
14916
                                                                        }
13557
14917
                                                                }
13558
14918
                                                        }
13574
14934
                                $data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8');
13575
14935
                        }
13576
14936
 
13577
 
                        if ($this->output_encoding != 'UTF-8')
 
14937
                        if ($this->output_encoding !== 'UTF-8')
13578
14938
                        {
13579
14939
                                $data = SimplePie_Misc::change_encoding($data, 'UTF-8', $this->output_encoding);
13580
14940
                        }