Make WordPress Core

Ticket #18309: simplepie-1-2-1.diff

File simplepie-1-2-1.diff, 72.6 KB (added by nacin, 13 years ago)
  • class-simplepie.php

     
    11<?php
    2 if ( !class_exists( 'SimplePie' ) ) :
    32/**
    43 * SimplePie
    54 *
    65 * A PHP-Based RSS and Atom Feed Framework.
    76 * Takes the hard work out of managing a complete RSS/Atom solution.
    87 *
    9  * Copyright (c) 2004-2009, Ryan Parman and Geoffrey Sneddon
     8 * Copyright (c) 2004-2011, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
    109 * All rights reserved.
    1110 *
    1211 * Redistribution and use in source and binary forms, with or without modification, are
     
    3433 * POSSIBILITY OF SUCH DAMAGE.
    3534 *
    3635 * @package SimplePie
    37  * @version 1.2
    38  * @copyright 2004-2009 Ryan Parman, Geoffrey Sneddon
     36 * @version 1.2.1
     37 * @copyright 2004-2011 Ryan Parman, Geoffrey Sneddon, Ryan McCue
    3938 * @author Ryan Parman
    4039 * @author Geoffrey Sneddon
     40 * @author Ryan McCue
    4141 * @link http://simplepie.org/ SimplePie
    4242 * @link http://simplepie.org/support/ Please submit all bug reports and feature requests to the SimplePie forums
    4343 * @license http://www.opensource.org/licenses/bsd-license.php BSD License
     
    5252/**
    5353 * SimplePie Version
    5454 */
    55 define('SIMPLEPIE_VERSION', '1.2');
     55define('SIMPLEPIE_VERSION', '1.2.1-dev');
    5656
    5757/**
    5858 * SimplePie Build
    5959 */
    60 define('SIMPLEPIE_BUILD', '20090627192103');
     60define('SIMPLEPIE_BUILD', '20111015034325');
    6161
    6262/**
    6363 * SimplePie Website URL
     
    16721672                                                                $this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
    16731673                                                                if (!$cache->save($this))
    16741674                                                                {
    1675                                                                         trigger_error("$this->cache_location is not writeable", E_USER_WARNING);
     1675                                                                        trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
    16761676                                                                }
    16771677                                                                $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc');
    16781678                                                        }
     
    16801680                                                }
    16811681                                                else
    16821682                                                {
    1683                                                         $this->error = "A feed could not be found at $this->feed_url";
     1683                                                        $this->error = "A feed could not be found at $this->feed_url. A feed with an invalid mime type may fall victim to this error, or " . SIMPLEPIE_NAME . " was unable to auto-discover it.. Use force_feed() if you are certain this URL is a real feed.";
    16841684                                                        SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
    16851685                                                        return false;
    16861686                                                }
     
    17771777                                                        // Cache the file if caching is enabled
    17781778                                                        if ($cache && !$cache->save($this))
    17791779                                                        {
    1780                                                                 trigger_error("$cache->name is not writeable", E_USER_WARNING);
     1780                                                                trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
    17811781                                                        }
    17821782                                                        return true;
    17831783                                                }
    17841784                                                else
    17851785                                                {
    1786                                                         $this->error = "A feed could not be found at $this->feed_url";
     1786                                                        $this->error = "A feed could not be found at $this->feed_url. This does not appear to be a valid RSS or Atom feed.";
    17871787                                                        SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
    17881788                                                        return false;
    17891789                                                }
    17901790                                        }
    17911791                                }
    17921792                        }
    1793                         if(isset($parser))
     1793                        if (isset($parser))
    17941794                        {
    17951795                                // We have an error, just set SimplePie_Misc::error to it and quit
    1796                                 $this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
     1796                                $this->error = sprintf('This XML document is invalid, likely due to invalid characters. XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
    17971797                        }
    17981798                        else
    17991799                        {
    1800                                 $this->error = 'The data could not be converted to UTF-8';
     1800                                $this->error = 'The data could not be converted to UTF-8. You MUST have either the iconv or mbstring extension installed. Upgrading to PHP 5.x (which includes iconv) is highly recommended.';
    18011801                        }
    18021802                        SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
    18031803                        return false;
     
    18311831        }
    18321832
    18331833        /**
    1834          * Return the error message for the occurred error
     1834         * Return the error message for the occured error
    18351835         *
    18361836         * @access public
    18371837         * @return string Error message
     
    19841984                                                        }
    19851985                                                        else
    19861986                                                        {
    1987                                                                 trigger_error("$cache->name is not writeable", E_USER_WARNING);
     1987                                                                trigger_error("$cache->name is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
    19881988                                                                return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
    19891989                                                        }
    19901990                                                }
     
    27742774
    27752775        function get_latitude()
    27762776        {
     2777               
    27772778                if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
    27782779                {
    27792780                        return (float) $return[0]['data'];
    27802781                }
    2781                 elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
     2782                elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
    27822783                {
    27832784                        return (float) $match[1];
    27842785                }
     
    27982799                {
    27992800                        return (float) $return[0]['data'];
    28002801                }
    2801                 elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
     2802                elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
    28022803                {
    28032804                        return (float) $match[2];
    28042805                }
     
    32783279                {
    32793280                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    32803281                }
     3282                elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
     3283                {
     3284                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML);
     3285                }
     3286
    32813287                elseif (!$description_only)
    32823288                {
    32833289                        return $this->get_content(true);
     
    36423648                {
    36433649                        return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT);
    36443650                }
    3645                 elseif (($date = $this->get_date('U')) !== null)
     3651                elseif (($date = $this->get_date('U')) !== null && $date !== false)
    36463652                {
    36473653                        return strftime($date_format, $date);
    36483654                }
     
    44284434                        // If we have media:group tags, loop through them.
    44294435                        foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group)
    44304436                        {
    4431                                 // If we have media:content tags, loop through them.
    4432                                 foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
     4437                                if(isset($group['child']) && isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
    44334438                                {
    4434                                         if (isset($content['attribs']['']['url']))
     4439                                        // If we have media:content tags, loop through them.
     4440                                        foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
    44354441                                        {
    4436                                                 // Attributes
    4437                                                 $bitrate = null;
    4438                                                 $channels = null;
    4439                                                 $duration = null;
    4440                                                 $expression = null;
    4441                                                 $framerate = null;
    4442                                                 $height = null;
    4443                                                 $javascript = null;
    4444                                                 $lang = null;
    4445                                                 $length = null;
    4446                                                 $medium = null;
    4447                                                 $samplingrate = null;
    4448                                                 $type = null;
    4449                                                 $url = null;
    4450                                                 $width = null;
     4442                                                if (isset($content['attribs']['']['url']))
     4443                                                {
     4444                                                        // Attributes
     4445                                                        $bitrate = null;
     4446                                                        $channels = null;
     4447                                                        $duration = null;
     4448                                                        $expression = null;
     4449                                                        $framerate = null;
     4450                                                        $height = null;
     4451                                                        $javascript = null;
     4452                                                        $lang = null;
     4453                                                        $length = null;
     4454                                                        $medium = null;
     4455                                                        $samplingrate = null;
     4456                                                        $type = null;
     4457                                                        $url = null;
     4458                                                        $width = null;
    44514459
    4452                                                 // Elements
    4453                                                 $captions = null;
    4454                                                 $categories = null;
    4455                                                 $copyrights = null;
    4456                                                 $credits = null;
    4457                                                 $description = null;
    4458                                                 $hashes = null;
    4459                                                 $keywords = null;
    4460                                                 $player = null;
    4461                                                 $ratings = null;
    4462                                                 $restrictions = null;
    4463                                                 $thumbnails = null;
    4464                                                 $title = null;
     4460                                                        // Elements
     4461                                                        $captions = null;
     4462                                                        $categories = null;
     4463                                                        $copyrights = null;
     4464                                                        $credits = null;
     4465                                                        $description = null;
     4466                                                        $hashes = null;
     4467                                                        $keywords = null;
     4468                                                        $player = null;
     4469                                                        $ratings = null;
     4470                                                        $restrictions = null;
     4471                                                        $thumbnails = null;
     4472                                                        $title = null;
    44654473
    4466                                                 // Start checking the attributes of media:content
    4467                                                 if (isset($content['attribs']['']['bitrate']))
    4468                                                 {
    4469                                                         $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
    4470                                                 }
    4471                                                 if (isset($content['attribs']['']['channels']))
    4472                                                 {
    4473                                                         $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
    4474                                                 }
    4475                                                 if (isset($content['attribs']['']['duration']))
    4476                                                 {
    4477                                                         $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
    4478                                                 }
    4479                                                 else
    4480                                                 {
    4481                                                         $duration = $duration_parent;
    4482                                                 }
    4483                                                 if (isset($content['attribs']['']['expression']))
    4484                                                 {
    4485                                                         $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
    4486                                                 }
    4487                                                 if (isset($content['attribs']['']['framerate']))
    4488                                                 {
    4489                                                         $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
    4490                                                 }
    4491                                                 if (isset($content['attribs']['']['height']))
    4492                                                 {
    4493                                                         $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
    4494                                                 }
    4495                                                 if (isset($content['attribs']['']['lang']))
    4496                                                 {
    4497                                                         $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
    4498                                                 }
    4499                                                 if (isset($content['attribs']['']['fileSize']))
    4500                                                 {
    4501                                                         $length = ceil($content['attribs']['']['fileSize']);
    4502                                                 }
    4503                                                 if (isset($content['attribs']['']['medium']))
    4504                                                 {
    4505                                                         $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
    4506                                                 }
    4507                                                 if (isset($content['attribs']['']['samplingrate']))
    4508                                                 {
    4509                                                         $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
    4510                                                 }
    4511                                                 if (isset($content['attribs']['']['type']))
    4512                                                 {
    4513                                                         $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
    4514                                                 }
    4515                                                 if (isset($content['attribs']['']['width']))
    4516                                                 {
    4517                                                         $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
    4518                                                 }
    4519                                                 $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
     4474                                                        // Start checking the attributes of media:content
     4475                                                        if (isset($content['attribs']['']['bitrate']))
     4476                                                        {
     4477                                                                $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
     4478                                                        }
     4479                                                        if (isset($content['attribs']['']['channels']))
     4480                                                        {
     4481                                                                $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
     4482                                                        }
     4483                                                        if (isset($content['attribs']['']['duration']))
     4484                                                        {
     4485                                                                $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
     4486                                                        }
     4487                                                        else
     4488                                                        {
     4489                                                                $duration = $duration_parent;
     4490                                                        }
     4491                                                        if (isset($content['attribs']['']['expression']))
     4492                                                        {
     4493                                                                $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
     4494                                                        }
     4495                                                        if (isset($content['attribs']['']['framerate']))
     4496                                                        {
     4497                                                                $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
     4498                                                        }
     4499                                                        if (isset($content['attribs']['']['height']))
     4500                                                        {
     4501                                                                $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
     4502                                                        }
     4503                                                        if (isset($content['attribs']['']['lang']))
     4504                                                        {
     4505                                                                $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
     4506                                                        }
     4507                                                        if (isset($content['attribs']['']['fileSize']))
     4508                                                        {
     4509                                                                $length = ceil($content['attribs']['']['fileSize']);
     4510                                                        }
     4511                                                        if (isset($content['attribs']['']['medium']))
     4512                                                        {
     4513                                                                $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
     4514                                                        }
     4515                                                        if (isset($content['attribs']['']['samplingrate']))
     4516                                                        {
     4517                                                                $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
     4518                                                        }
     4519                                                        if (isset($content['attribs']['']['type']))
     4520                                                        {
     4521                                                                $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
     4522                                                        }
     4523                                                        if (isset($content['attribs']['']['width']))
     4524                                                        {
     4525                                                                $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
     4526                                                        }
     4527                                                        $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
    45204528
    4521                                                 // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
     4529                                                        // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
    45224530
    4523                                                 // CAPTIONS
    4524                                                 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
    4525                                                 {
    4526                                                         foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
     4531                                                        // CAPTIONS
     4532                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
    45274533                                                        {
    4528                                                                 $caption_type = null;
    4529                                                                 $caption_lang = null;
    4530                                                                 $caption_startTime = null;
    4531                                                                 $caption_endTime = null;
    4532                                                                 $caption_text = null;
    4533                                                                 if (isset($caption['attribs']['']['type']))
     4534                                                                foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
    45344535                                                                {
    4535                                                                         $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
     4536                                                                        $caption_type = null;
     4537                                                                        $caption_lang = null;
     4538                                                                        $caption_startTime = null;
     4539                                                                        $caption_endTime = null;
     4540                                                                        $caption_text = null;
     4541                                                                        if (isset($caption['attribs']['']['type']))
     4542                                                                        {
     4543                                                                                $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
     4544                                                                        }
     4545                                                                        if (isset($caption['attribs']['']['lang']))
     4546                                                                        {
     4547                                                                                $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
     4548                                                                        }
     4549                                                                        if (isset($caption['attribs']['']['start']))
     4550                                                                        {
     4551                                                                                $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
     4552                                                                        }
     4553                                                                        if (isset($caption['attribs']['']['end']))
     4554                                                                        {
     4555                                                                                $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
     4556                                                                        }
     4557                                                                        if (isset($caption['data']))
     4558                                                                        {
     4559                                                                                $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4560                                                                        }
     4561                                                                        $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
    45364562                                                                }
    4537                                                                 if (isset($caption['attribs']['']['lang']))
     4563                                                                if (is_array($captions))
    45384564                                                                {
    4539                                                                         $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
     4565                                                                        $captions = array_values(SimplePie_Misc::array_unique($captions));
    45404566                                                                }
    4541                                                                 if (isset($caption['attribs']['']['start']))
     4567                                                        }
     4568                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
     4569                                                        {
     4570                                                                foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
    45424571                                                                {
    4543                                                                         $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
     4572                                                                        $caption_type = null;
     4573                                                                        $caption_lang = null;
     4574                                                                        $caption_startTime = null;
     4575                                                                        $caption_endTime = null;
     4576                                                                        $caption_text = null;
     4577                                                                        if (isset($caption['attribs']['']['type']))
     4578                                                                        {
     4579                                                                                $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
     4580                                                                        }
     4581                                                                        if (isset($caption['attribs']['']['lang']))
     4582                                                                        {
     4583                                                                                $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
     4584                                                                        }
     4585                                                                        if (isset($caption['attribs']['']['start']))
     4586                                                                        {
     4587                                                                                $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
     4588                                                                        }
     4589                                                                        if (isset($caption['attribs']['']['end']))
     4590                                                                        {
     4591                                                                                $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
     4592                                                                        }
     4593                                                                        if (isset($caption['data']))
     4594                                                                        {
     4595                                                                                $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4596                                                                        }
     4597                                                                        $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
    45444598                                                                }
    4545                                                                 if (isset($caption['attribs']['']['end']))
     4599                                                                if (is_array($captions))
    45464600                                                                {
    4547                                                                         $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
     4601                                                                        $captions = array_values(SimplePie_Misc::array_unique($captions));
    45484602                                                                }
    4549                                                                 if (isset($caption['data']))
    4550                                                                 {
    4551                                                                         $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    4552                                                                 }
    4553                                                                 $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
    45544603                                                        }
    4555                                                         if (is_array($captions))
     4604                                                        else
    45564605                                                        {
    4557                                                                 $captions = array_values(SimplePie_Misc::array_unique($captions));
     4606                                                                $captions = $captions_parent;
    45584607                                                        }
    4559                                                 }
    4560                                                 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
    4561                                                 {
    4562                                                         foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
     4608
     4609                                                        // CATEGORIES
     4610                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
    45634611                                                        {
    4564                                                                 $caption_type = null;
    4565                                                                 $caption_lang = null;
    4566                                                                 $caption_startTime = null;
    4567                                                                 $caption_endTime = null;
    4568                                                                 $caption_text = null;
    4569                                                                 if (isset($caption['attribs']['']['type']))
     4612                                                                foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
    45704613                                                                {
    4571                                                                         $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
     4614                                                                        $term = null;
     4615                                                                        $scheme = null;
     4616                                                                        $label = null;
     4617                                                                        if (isset($category['data']))
     4618                                                                        {
     4619                                                                                $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4620                                                                        }
     4621                                                                        if (isset($category['attribs']['']['scheme']))
     4622                                                                        {
     4623                                                                                $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
     4624                                                                        }
     4625                                                                        else
     4626                                                                        {
     4627                                                                                $scheme = 'http://search.yahoo.com/mrss/category_schema';
     4628                                                                        }
     4629                                                                        if (isset($category['attribs']['']['label']))
     4630                                                                        {
     4631                                                                                $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
     4632                                                                        }
     4633                                                                        $categories[] =& new $this->feed->category_class($term, $scheme, $label);
    45724634                                                                }
    4573                                                                 if (isset($caption['attribs']['']['lang']))
     4635                                                        }
     4636                                                        if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
     4637                                                        {
     4638                                                                foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
    45744639                                                                {
    4575                                                                         $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
     4640                                                                        $term = null;
     4641                                                                        $scheme = null;
     4642                                                                        $label = null;
     4643                                                                        if (isset($category['data']))
     4644                                                                        {
     4645                                                                                $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4646                                                                        }
     4647                                                                        if (isset($category['attribs']['']['scheme']))
     4648                                                                        {
     4649                                                                                $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
     4650                                                                        }
     4651                                                                        else
     4652                                                                        {
     4653                                                                                $scheme = 'http://search.yahoo.com/mrss/category_schema';
     4654                                                                        }
     4655                                                                        if (isset($category['attribs']['']['label']))
     4656                                                                        {
     4657                                                                                $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
     4658                                                                        }
     4659                                                                        $categories[] =& new $this->feed->category_class($term, $scheme, $label);
    45764660                                                                }
    4577                                                                 if (isset($caption['attribs']['']['start']))
    4578                                                                 {
    4579                                                                         $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
    4580                                                                 }
    4581                                                                 if (isset($caption['attribs']['']['end']))
    4582                                                                 {
    4583                                                                         $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
    4584                                                                 }
    4585                                                                 if (isset($caption['data']))
    4586                                                                 {
    4587                                                                         $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    4588                                                                 }
    4589                                                                 $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
    45904661                                                        }
    4591                                                         if (is_array($captions))
     4662                                                        if (is_array($categories) && is_array($categories_parent))
    45924663                                                        {
    4593                                                                 $captions = array_values(SimplePie_Misc::array_unique($captions));
     4664                                                                $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent)));
    45944665                                                        }
    4595                                                 }
    4596                                                 else
    4597                                                 {
    4598                                                         $captions = $captions_parent;
    4599                                                 }
     4666                                                        elseif (is_array($categories))
     4667                                                        {
     4668                                                                $categories = array_values(SimplePie_Misc::array_unique($categories));
     4669                                                        }
     4670                                                        elseif (is_array($categories_parent))
     4671                                                        {
     4672                                                                $categories = array_values(SimplePie_Misc::array_unique($categories_parent));
     4673                                                        }
    46004674
    4601                                                 // CATEGORIES
    4602                                                 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
    4603                                                 {
    4604                                                         foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
     4675                                                        // COPYRIGHTS
     4676                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
    46054677                                                        {
    4606                                                                 $term = null;
    4607                                                                 $scheme = null;
    4608                                                                 $label = null;
    4609                                                                 if (isset($category['data']))
     4678                                                                $copyright_url = null;
     4679                                                                $copyright_label = null;
     4680                                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
    46104681                                                                {
    4611                                                                         $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4682                                                                        $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
    46124683                                                                }
    4613                                                                 if (isset($category['attribs']['']['scheme']))
     4684                                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
    46144685                                                                {
    4615                                                                         $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
     4686                                                                        $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    46164687                                                                }
    4617                                                                 else
     4688                                                                $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
     4689                                                        }
     4690                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
     4691                                                        {
     4692                                                                $copyright_url = null;
     4693                                                                $copyright_label = null;
     4694                                                                if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
    46184695                                                                {
    4619                                                                         $scheme = 'http://search.yahoo.com/mrss/category_schema';
     4696                                                                        $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
    46204697                                                                }
    4621                                                                 if (isset($category['attribs']['']['label']))
     4698                                                                if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
    46224699                                                                {
    4623                                                                         $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
     4700                                                                        $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    46244701                                                                }
    4625                                                                 $categories[] =& new $this->feed->category_class($term, $scheme, $label);
     4702                                                                $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
    46264703                                                        }
    4627                                                 }
    4628                                                 if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
    4629                                                 {
    4630                                                         foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
     4704                                                        else
    46314705                                                        {
    4632                                                                 $term = null;
    4633                                                                 $scheme = null;
    4634                                                                 $label = null;
    4635                                                                 if (isset($category['data']))
     4706                                                                $copyrights = $copyrights_parent;
     4707                                                        }
     4708
     4709                                                        // CREDITS
     4710                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
     4711                                                        {
     4712                                                                foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
    46364713                                                                {
    4637                                                                         $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4714                                                                        $credit_role = null;
     4715                                                                        $credit_scheme = null;
     4716                                                                        $credit_name = null;
     4717                                                                        if (isset($credit['attribs']['']['role']))
     4718                                                                        {
     4719                                                                                $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
     4720                                                                        }
     4721                                                                        if (isset($credit['attribs']['']['scheme']))
     4722                                                                        {
     4723                                                                                $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
     4724                                                                        }
     4725                                                                        else
     4726                                                                        {
     4727                                                                                $credit_scheme = 'urn:ebu';
     4728                                                                        }
     4729                                                                        if (isset($credit['data']))
     4730                                                                        {
     4731                                                                                $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4732                                                                        }
     4733                                                                        $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
    46384734                                                                }
    4639                                                                 if (isset($category['attribs']['']['scheme']))
     4735                                                                if (is_array($credits))
    46404736                                                                {
    4641                                                                         $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
     4737                                                                        $credits = array_values(SimplePie_Misc::array_unique($credits));
    46424738                                                                }
    4643                                                                 else
     4739                                                        }
     4740                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
     4741                                                        {
     4742                                                                foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
    46444743                                                                {
    4645                                                                         $scheme = 'http://search.yahoo.com/mrss/category_schema';
     4744                                                                        $credit_role = null;
     4745                                                                        $credit_scheme = null;
     4746                                                                        $credit_name = null;
     4747                                                                        if (isset($credit['attribs']['']['role']))
     4748                                                                        {
     4749                                                                                $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
     4750                                                                        }
     4751                                                                        if (isset($credit['attribs']['']['scheme']))
     4752                                                                        {
     4753                                                                                $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
     4754                                                                        }
     4755                                                                        else
     4756                                                                        {
     4757                                                                                $credit_scheme = 'urn:ebu';
     4758                                                                        }
     4759                                                                        if (isset($credit['data']))
     4760                                                                        {
     4761                                                                                $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4762                                                                        }
     4763                                                                        $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
    46464764                                                                }
    4647                                                                 if (isset($category['attribs']['']['label']))
     4765                                                                if (is_array($credits))
    46484766                                                                {
    4649                                                                         $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
     4767                                                                        $credits = array_values(SimplePie_Misc::array_unique($credits));
    46504768                                                                }
    4651                                                                 $categories[] =& new $this->feed->category_class($term, $scheme, $label);
    46524769                                                        }
    4653                                                 }
    4654                                                 if (is_array($categories) && is_array($categories_parent))
    4655                                                 {
    4656                                                         $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent)));
    4657                                                 }
    4658                                                 elseif (is_array($categories))
    4659                                                 {
    4660                                                         $categories = array_values(SimplePie_Misc::array_unique($categories));
    4661                                                 }
    4662                                                 elseif (is_array($categories_parent))
    4663                                                 {
    4664                                                         $categories = array_values(SimplePie_Misc::array_unique($categories_parent));
    4665                                                 }
    4666 
    4667                                                 // COPYRIGHTS
    4668                                                 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
    4669                                                 {
    4670                                                         $copyright_url = null;
    4671                                                         $copyright_label = null;
    4672                                                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
     4770                                                        else
    46734771                                                        {
    4674                                                                 $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
     4772                                                                $credits = $credits_parent;
    46754773                                                        }
    4676                                                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
     4774
     4775                                                        // DESCRIPTION
     4776                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
    46774777                                                        {
    4678                                                                 $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4778                                                                $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    46794779                                                        }
    4680                                                         $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
    4681                                                 }
    4682                                                 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
    4683                                                 {
    4684                                                         $copyright_url = null;
    4685                                                         $copyright_label = null;
    4686                                                         if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
     4780                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
    46874781                                                        {
    4688                                                                 $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
     4782                                                                $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    46894783                                                        }
    4690                                                         if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
     4784                                                        else
    46914785                                                        {
    4692                                                                 $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4786                                                                $description = $description_parent;
    46934787                                                        }
    4694                                                         $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
    4695                                                 }
    4696                                                 else
    4697                                                 {
    4698                                                         $copyrights = $copyrights_parent;
    4699                                                 }
    47004788
    4701                                                 // CREDITS
    4702                                                 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
    4703                                                 {
    4704                                                         foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
     4789                                                        // HASHES
     4790                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
    47054791                                                        {
    4706                                                                 $credit_role = null;
    4707                                                                 $credit_scheme = null;
    4708                                                                 $credit_name = null;
    4709                                                                 if (isset($credit['attribs']['']['role']))
     4792                                                                foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
    47104793                                                                {
    4711                                                                         $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
     4794                                                                        $value = null;
     4795                                                                        $algo = null;
     4796                                                                        if (isset($hash['data']))
     4797                                                                        {
     4798                                                                                $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4799                                                                        }
     4800                                                                        if (isset($hash['attribs']['']['algo']))
     4801                                                                        {
     4802                                                                                $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
     4803                                                                        }
     4804                                                                        else
     4805                                                                        {
     4806                                                                                $algo = 'md5';
     4807                                                                        }
     4808                                                                        $hashes[] = $algo.':'.$value;
    47124809                                                                }
    4713                                                                 if (isset($credit['attribs']['']['scheme']))
     4810                                                                if (is_array($hashes))
    47144811                                                                {
    4715                                                                         $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
     4812                                                                        $hashes = array_values(SimplePie_Misc::array_unique($hashes));
    47164813                                                                }
    4717                                                                 else
     4814                                                        }
     4815                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
     4816                                                        {
     4817                                                                foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
    47184818                                                                {
    4719                                                                         $credit_scheme = 'urn:ebu';
     4819                                                                        $value = null;
     4820                                                                        $algo = null;
     4821                                                                        if (isset($hash['data']))
     4822                                                                        {
     4823                                                                                $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4824                                                                        }
     4825                                                                        if (isset($hash['attribs']['']['algo']))
     4826                                                                        {
     4827                                                                                $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
     4828                                                                        }
     4829                                                                        else
     4830                                                                        {
     4831                                                                                $algo = 'md5';
     4832                                                                        }
     4833                                                                        $hashes[] = $algo.':'.$value;
    47204834                                                                }
    4721                                                                 if (isset($credit['data']))
     4835                                                                if (is_array($hashes))
    47224836                                                                {
    4723                                                                         $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4837                                                                        $hashes = array_values(SimplePie_Misc::array_unique($hashes));
    47244838                                                                }
    4725                                                                 $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
    47264839                                                        }
    4727                                                         if (is_array($credits))
     4840                                                        else
    47284841                                                        {
    4729                                                                 $credits = array_values(SimplePie_Misc::array_unique($credits));
     4842                                                                $hashes = $hashes_parent;
    47304843                                                        }
    4731                                                 }
    4732                                                 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
    4733                                                 {
    4734                                                         foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
     4844
     4845                                                        // KEYWORDS
     4846                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
    47354847                                                        {
    4736                                                                 $credit_role = null;
    4737                                                                 $credit_scheme = null;
    4738                                                                 $credit_name = null;
    4739                                                                 if (isset($credit['attribs']['']['role']))
     4848                                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
    47404849                                                                {
    4741                                                                         $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
     4850                                                                        $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
     4851                                                                        foreach ($temp as $word)
     4852                                                                        {
     4853                                                                                $keywords[] = trim($word);
     4854                                                                        }
     4855                                                                        unset($temp);
    47424856                                                                }
    4743                                                                 if (isset($credit['attribs']['']['scheme']))
     4857                                                                if (is_array($keywords))
    47444858                                                                {
    4745                                                                         $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
     4859                                                                        $keywords = array_values(SimplePie_Misc::array_unique($keywords));
    47464860                                                                }
    4747                                                                 else
     4861                                                        }
     4862                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
     4863                                                        {
     4864                                                                if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
    47484865                                                                {
    4749                                                                         $credit_scheme = 'urn:ebu';
     4866                                                                        $temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
     4867                                                                        foreach ($temp as $word)
     4868                                                                        {
     4869                                                                                $keywords[] = trim($word);
     4870                                                                        }
     4871                                                                        unset($temp);
    47504872                                                                }
    4751                                                                 if (isset($credit['data']))
     4873                                                                if (is_array($keywords))
    47524874                                                                {
    4753                                                                         $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4875                                                                        $keywords = array_values(SimplePie_Misc::array_unique($keywords));
    47544876                                                                }
    4755                                                                 $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
    47564877                                                        }
    4757                                                         if (is_array($credits))
     4878                                                        else
    47584879                                                        {
    4759                                                                 $credits = array_values(SimplePie_Misc::array_unique($credits));
     4880                                                                $keywords = $keywords_parent;
    47604881                                                        }
    4761                                                 }
    4762                                                 else
    4763                                                 {
    4764                                                         $credits = $credits_parent;
    4765                                                 }
    47664882
    4767                                                 // DESCRIPTION
    4768                                                 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
    4769                                                 {
    4770                                                         $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    4771                                                 }
    4772                                                 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
    4773                                                 {
    4774                                                         $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    4775                                                 }
    4776                                                 else
    4777                                                 {
    4778                                                         $description = $description_parent;
    4779                                                 }
    4780 
    4781                                                 // HASHES
    4782                                                 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
    4783                                                 {
    4784                                                         foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
     4883                                                        // PLAYER
     4884                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
    47854885                                                        {
    4786                                                                 $value = null;
    4787                                                                 $algo = null;
    4788                                                                 if (isset($hash['data']))
    4789                                                                 {
    4790                                                                         $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    4791                                                                 }
    4792                                                                 if (isset($hash['attribs']['']['algo']))
    4793                                                                 {
    4794                                                                         $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
    4795                                                                 }
    4796                                                                 else
    4797                                                                 {
    4798                                                                         $algo = 'md5';
    4799                                                                 }
    4800                                                                 $hashes[] = $algo.':'.$value;
     4886                                                                $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
    48014887                                                        }
    4802                                                         if (is_array($hashes))
     4888                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
    48034889                                                        {
    4804                                                                 $hashes = array_values(SimplePie_Misc::array_unique($hashes));
     4890                                                                $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
    48054891                                                        }
    4806                                                 }
    4807                                                 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
    4808                                                 {
    4809                                                         foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
     4892                                                        else
    48104893                                                        {
    4811                                                                 $value = null;
    4812                                                                 $algo = null;
    4813                                                                 if (isset($hash['data']))
     4894                                                                $player = $player_parent;
     4895                                                        }
     4896
     4897                                                        // RATINGS
     4898                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
     4899                                                        {
     4900                                                                foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
    48144901                                                                {
    4815                                                                         $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4902                                                                        $rating_scheme = null;
     4903                                                                        $rating_value = null;
     4904                                                                        if (isset($rating['attribs']['']['scheme']))
     4905                                                                        {
     4906                                                                                $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
     4907                                                                        }
     4908                                                                        else
     4909                                                                        {
     4910                                                                                $rating_scheme = 'urn:simple';
     4911                                                                        }
     4912                                                                        if (isset($rating['data']))
     4913                                                                        {
     4914                                                                                $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4915                                                                        }
     4916                                                                        $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
    48164917                                                                }
    4817                                                                 if (isset($hash['attribs']['']['algo']))
     4918                                                                if (is_array($ratings))
    48184919                                                                {
    4819                                                                         $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
     4920                                                                        $ratings = array_values(SimplePie_Misc::array_unique($ratings));
    48204921                                                                }
    4821                                                                 else
    4822                                                                 {
    4823                                                                         $algo = 'md5';
    4824                                                                 }
    4825                                                                 $hashes[] = $algo.':'.$value;
    48264922                                                        }
    4827                                                         if (is_array($hashes))
     4923                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
    48284924                                                        {
    4829                                                                 $hashes = array_values(SimplePie_Misc::array_unique($hashes));
    4830                                                         }
    4831                                                 }
    4832                                                 else
    4833                                                 {
    4834                                                         $hashes = $hashes_parent;
    4835                                                 }
    4836 
    4837                                                 // KEYWORDS
    4838                                                 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
    4839                                                 {
    4840                                                         if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
    4841                                                         {
    4842                                                                 $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
    4843                                                                 foreach ($temp as $word)
     4925                                                                foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
    48444926                                                                {
    4845                                                                         $keywords[] = trim($word);
     4927                                                                        $rating_scheme = null;
     4928                                                                        $rating_value = null;
     4929                                                                        if (isset($rating['attribs']['']['scheme']))
     4930                                                                        {
     4931                                                                                $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
     4932                                                                        }
     4933                                                                        else
     4934                                                                        {
     4935                                                                                $rating_scheme = 'urn:simple';
     4936                                                                        }
     4937                                                                        if (isset($rating['data']))
     4938                                                                        {
     4939                                                                                $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4940                                                                        }
     4941                                                                        $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
    48464942                                                                }
    4847                                                                 unset($temp);
    4848                                                         }
    4849                                                         if (is_array($keywords))
    4850                                                         {
    4851                                                                 $keywords = array_values(SimplePie_Misc::array_unique($keywords));
    4852                                                         }
    4853                                                 }
    4854                                                 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
    4855                                                 {
    4856                                                         if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
    4857                                                         {
    4858                                                                 $temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
    4859                                                                 foreach ($temp as $word)
     4943                                                                if (is_array($ratings))
    48604944                                                                {
    4861                                                                         $keywords[] = trim($word);
     4945                                                                        $ratings = array_values(SimplePie_Misc::array_unique($ratings));
    48624946                                                                }
    4863                                                                 unset($temp);
    48644947                                                        }
    4865                                                         if (is_array($keywords))
     4948                                                        else
    48664949                                                        {
    4867                                                                 $keywords = array_values(SimplePie_Misc::array_unique($keywords));
     4950                                                                $ratings = $ratings_parent;
    48684951                                                        }
    4869                                                 }
    4870                                                 else
    4871                                                 {
    4872                                                         $keywords = $keywords_parent;
    4873                                                 }
    48744952
    4875                                                 // PLAYER
    4876                                                 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
    4877                                                 {
    4878                                                         $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
    4879                                                 }
    4880                                                 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
    4881                                                 {
    4882                                                         $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
    4883                                                 }
    4884                                                 else
    4885                                                 {
    4886                                                         $player = $player_parent;
    4887                                                 }
    4888 
    4889                                                 // RATINGS
    4890                                                 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
    4891                                                 {
    4892                                                         foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
     4953                                                        // RESTRICTIONS
     4954                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
    48934955                                                        {
    4894                                                                 $rating_scheme = null;
    4895                                                                 $rating_value = null;
    4896                                                                 if (isset($rating['attribs']['']['scheme']))
     4956                                                                foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
    48974957                                                                {
    4898                                                                         $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
     4958                                                                        $restriction_relationship = null;
     4959                                                                        $restriction_type = null;
     4960                                                                        $restriction_value = null;
     4961                                                                        if (isset($restriction['attribs']['']['relationship']))
     4962                                                                        {
     4963                                                                                $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
     4964                                                                        }
     4965                                                                        if (isset($restriction['attribs']['']['type']))
     4966                                                                        {
     4967                                                                                $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
     4968                                                                        }
     4969                                                                        if (isset($restriction['data']))
     4970                                                                        {
     4971                                                                                $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4972                                                                        }
     4973                                                                        $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
    48994974                                                                }
    4900                                                                 else
     4975                                                                if (is_array($restrictions))
    49014976                                                                {
    4902                                                                         $rating_scheme = 'urn:simple';
     4977                                                                        $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
    49034978                                                                }
    4904                                                                 if (isset($rating['data']))
    4905                                                                 {
    4906                                                                         $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    4907                                                                 }
    4908                                                                 $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
    49094979                                                        }
    4910                                                         if (is_array($ratings))
     4980                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
    49114981                                                        {
    4912                                                                 $ratings = array_values(SimplePie_Misc::array_unique($ratings));
    4913                                                         }
    4914                                                 }
    4915                                                 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
    4916                                                 {
    4917                                                         foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
    4918                                                         {
    4919                                                                 $rating_scheme = null;
    4920                                                                 $rating_value = null;
    4921                                                                 if (isset($rating['attribs']['']['scheme']))
     4982                                                                foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
    49224983                                                                {
    4923                                                                         $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
     4984                                                                        $restriction_relationship = null;
     4985                                                                        $restriction_type = null;
     4986                                                                        $restriction_value = null;
     4987                                                                        if (isset($restriction['attribs']['']['relationship']))
     4988                                                                        {
     4989                                                                                $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
     4990                                                                        }
     4991                                                                        if (isset($restriction['attribs']['']['type']))
     4992                                                                        {
     4993                                                                                $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
     4994                                                                        }
     4995                                                                        if (isset($restriction['data']))
     4996                                                                        {
     4997                                                                                $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     4998                                                                        }
     4999                                                                        $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
    49245000                                                                }
    4925                                                                 else
     5001                                                                if (is_array($restrictions))
    49265002                                                                {
    4927                                                                         $rating_scheme = 'urn:simple';
     5003                                                                        $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
    49285004                                                                }
    4929                                                                 if (isset($rating['data']))
    4930                                                                 {
    4931                                                                         $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    4932                                                                 }
    4933                                                                 $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
    49345005                                                        }
    4935                                                         if (is_array($ratings))
     5006                                                        else
    49365007                                                        {
    4937                                                                 $ratings = array_values(SimplePie_Misc::array_unique($ratings));
     5008                                                                $restrictions = $restrictions_parent;
    49385009                                                        }
    4939                                                 }
    4940                                                 else
    4941                                                 {
    4942                                                         $ratings = $ratings_parent;
    4943                                                 }
    49445010
    4945                                                 // RESTRICTIONS
    4946                                                 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
    4947                                                 {
    4948                                                         foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
     5011                                                        // THUMBNAILS
     5012                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
    49495013                                                        {
    4950                                                                 $restriction_relationship = null;
    4951                                                                 $restriction_type = null;
    4952                                                                 $restriction_value = null;
    4953                                                                 if (isset($restriction['attribs']['']['relationship']))
     5014                                                                foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
    49545015                                                                {
    4955                                                                         $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
     5016                                                                        $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
    49565017                                                                }
    4957                                                                 if (isset($restriction['attribs']['']['type']))
     5018                                                                if (is_array($thumbnails))
    49585019                                                                {
    4959                                                                         $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
     5020                                                                        $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
    49605021                                                                }
    4961                                                                 if (isset($restriction['data']))
    4962                                                                 {
    4963                                                                         $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    4964                                                                 }
    4965                                                                 $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
    49665022                                                        }
    4967                                                         if (is_array($restrictions))
     5023                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
    49685024                                                        {
    4969                                                                 $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
    4970                                                         }
    4971                                                 }
    4972                                                 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
    4973                                                 {
    4974                                                         foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
    4975                                                         {
    4976                                                                 $restriction_relationship = null;
    4977                                                                 $restriction_type = null;
    4978                                                                 $restriction_value = null;
    4979                                                                 if (isset($restriction['attribs']['']['relationship']))
     5025                                                                foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
    49805026                                                                {
    4981                                                                         $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
     5027                                                                        $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
    49825028                                                                }
    4983                                                                 if (isset($restriction['attribs']['']['type']))
     5029                                                                if (is_array($thumbnails))
    49845030                                                                {
    4985                                                                         $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
     5031                                                                        $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
    49865032                                                                }
    4987                                                                 if (isset($restriction['data']))
    4988                                                                 {
    4989                                                                         $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    4990                                                                 }
    4991                                                                 $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
    49925033                                                        }
    4993                                                         if (is_array($restrictions))
     5034                                                        else
    49945035                                                        {
    4995                                                                 $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
     5036                                                                $thumbnails = $thumbnails_parent;
    49965037                                                        }
    4997                                                 }
    4998                                                 else
    4999                                                 {
    5000                                                         $restrictions = $restrictions_parent;
    5001                                                 }
    50025038
    5003                                                 // THUMBNAILS
    5004                                                 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
    5005                                                 {
    5006                                                         foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
     5039                                                        // TITLES
     5040                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
    50075041                                                        {
    5008                                                                 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
     5042                                                                $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    50095043                                                        }
    5010                                                         if (is_array($thumbnails))
     5044                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
    50115045                                                        {
    5012                                                                 $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
     5046                                                                $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    50135047                                                        }
    5014                                                 }
    5015                                                 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
    5016                                                 {
    5017                                                         foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
     5048                                                        else
    50185049                                                        {
    5019                                                                 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
     5050                                                                $title = $title_parent;
    50205051                                                        }
    5021                                                         if (is_array($thumbnails))
    5022                                                         {
    5023                                                                 $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
    5024                                                         }
    5025                                                 }
    5026                                                 else
    5027                                                 {
    5028                                                         $thumbnails = $thumbnails_parent;
    5029                                                 }
    50305052
    5031                                                 // TITLES
    5032                                                 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
    5033                                                 {
    5034                                                         $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
     5053                                                        $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width);
    50355054                                                }
    5036                                                 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
    5037                                                 {
    5038                                                         $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    5039                                                 }
    5040                                                 else
    5041                                                 {
    5042                                                         $title = $title_parent;
    5043                                                 }
    5044 
    5045                                                 $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width);
    50465055                                        }
    50475056                                }
    50485057                        }
     
    50525061                        {
    50535062                                foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
    50545063                                {
    5055                                         if (isset($content['attribs']['']['url']))
     5064                                        if (isset($content['attribs']['']['url']) || isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
    50565065                                        {
    50575066                                                // Attributes
    50585067                                                $bitrate = null;
     
    51375146                                                {
    51385147                                                        $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
    51395148                                                }
    5140                                                 $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
    5141 
     5149                                                if (isset($content['attribs']['']['url']))
     5150                                                {
     5151                                                        $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
     5152                                                }
    51425153                                                // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
    51435154
    51445155                                                // CAPTIONS
     
    55805591                {
    55815592                        return (float) $return[0]['data'];
    55825593                }
    5583                 elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
     5594                elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
    55845595                {
    55855596                        return (float) $match[1];
    55865597                }
     
    56005611                {
    56015612                        return (float) $return[0]['data'];
    56025613                }
    5603                 elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
     5614                elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
    56045615                {
    56055616                        return (float) $match[2];
    56065617                }
     
    62236234                {
    62246235                        return (float) $return[0]['data'];
    62256236                }
    6226                 elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
     6237                elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
    62276238                {
    62286239                        return (float) $match[1];
    62296240                }
     
    62436254                {
    62446255                        return (float) $return[0]['data'];
    62456256                }
    6246                 elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
     6257                elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
    62476258                {
    62486259                        return (float) $match[2];
    62496260                }
     
    77277738                        {
    77287739                                $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
    77297740                                $url_parts = parse_url($url);
     7741                                $socket_host = $url_parts['host'];
    77307742                                if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https')
    77317743                                {
    7732                                         $url_parts['host'] = "ssl://$url_parts[host]";
     7744                                        $socket_host = "ssl://$url_parts[host]";
    77337745                                        $url_parts['port'] = 443;
    77347746                                }
    77357747                                if (!isset($url_parts['port']))
    77367748                                {
    77377749                                        $url_parts['port'] = 80;
    77387750                                }
    7739                                 $fp = @fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout);
     7751                                $fp = @fsockopen($socket_host, $url_parts['port'], $errno, $errstr, $timeout);
    77407752                                if (!$fp)
    77417753                                {
    77427754                                        $this->error = 'fsockopen error: ' . $errstr;
     
    84828494
    84838495                                // Get the length of the extra field
    84848496                                $len = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
    8485                                 $position += 2;
     8497                                $this->position += 2;
    84868498
    84878499                                // Check the length of the string is still valid
    84888500                                $this->min_compressed_size += $len + 4;
     
    92349246                                        $note = 'Unknown Error';
    92359247                                        break;
    92369248                        }
    9237                         error_log("$note: $message in $file on line $line", 0);
     9249
     9250                        $log_error = true;
     9251                        if (!function_exists('error_log'))
     9252                        {
     9253                                $log_error = false;
     9254                        }
     9255
     9256                        $log_file = @ini_get('error_log');
     9257                        if (!empty($log_file) && ('syslog' != $log_file) && !@is_writable($log_file))
     9258                        {
     9259                                $log_error = false;
     9260                        }
     9261
     9262                        if ($log_error)
     9263                        {
     9264                                @error_log("$note: $message in $file on line $line", 0);
     9265                        }
    92389266                }
     9267
    92399268                return $message;
    92409269        }
    92419270
     
    94329461                        return SimplePie_Misc::windows_1252_to_utf8($data);
    94339462                }
    94349463                // This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported).
    9435                 elseif (function_exists('mb_convert_encoding') && @mb_convert_encoding("\x80", 'UTF-16BE', $input) !== "\x00\x80" && ($return = @mb_convert_encoding($data, $output, $input)))
     9464                elseif (function_exists('mb_convert_encoding') && @mb_convert_encoding("\x80", 'UTF-16BE', $input) !== "\x00\x80" && in_array($input, mb_list_encodings()) && ($return = @mb_convert_encoding($data, $output, $input)))
    94369465                {
    94379466                        return $return;
    94389467                }
     
    94489477                }
    94499478        }
    94509479
     9480        /**
     9481         * Normalize an encoding name
     9482         *
     9483         * This is automatically generated by create.php
     9484         *
     9485         * To generate it, run `php create.php` on the command line, and copy the
     9486         * output to replace this function.
     9487         *
     9488         * @param string $charset Character set to standardise
     9489         * @return string Standardised name
     9490         */
    94519491        function encoding($charset)
    94529492        {
    94539493                // Normalization from UTS #22
     
    94819521
    94829522                        case 'big5':
    94839523                        case 'csbig5':
    9484                         case 'xxbig5':
    94859524                                return 'Big5';
    94869525
    94879526                        case 'big5hkscs':
     
    96379676                        case 'isoir85':
    96389677                                return 'ES2';
    96399678
     9679                        case 'cseucpkdfmtjapanese':
     9680                        case 'eucjp':
     9681                        case 'extendedunixcodepackedformatforjapanese':
     9682                                return 'EUC-JP';
     9683
    96409684                        case 'cseucfixwidjapanese':
    96419685                        case 'extendedunixcodefixedwidthforjapanese':
    96429686                                return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
    96439687
    9644                         case 'cseucpkdfmtjapanese':
    9645                         case 'eucjp':
    9646                         case 'extendedunixcodepackedformatforjapanese':
    9647                                 return 'Extended_UNIX_Code_Packed_Format_for_Japanese';
    9648 
    96499688                        case 'gb18030':
    96509689                                return 'GB18030';
    96519690
     
    97239762                        case 'ibmthai':
    97249763                                return 'IBM-Thai';
    97259764
    9726                         case 'ccsid858':
    9727                         case 'cp858':
    9728                         case 'ibm858':
    9729                         case 'pcmultilingual850euro':
    9730                                 return 'IBM00858';
    9731 
    9732                         case 'ccsid924':
    9733                         case 'cp924':
    9734                         case 'ebcdiclatin9euro':
    9735                         case 'ibm924':
    9736                                 return 'IBM00924';
    9737 
    9738                         case 'ccsid1140':
    9739                         case 'cp1140':
    9740                         case 'ebcdicus37euro':
    9741                         case 'ibm1140':
    9742                                 return 'IBM01140';
    9743 
    9744                         case 'ccsid1141':
    9745                         case 'cp1141':
    9746                         case 'ebcdicde273euro':
    9747                         case 'ibm1141':
    9748                                 return 'IBM01141';
    9749 
    9750                         case 'ccsid1142':
    9751                         case 'cp1142':
    9752                         case 'ebcdicdk277euro':
    9753                         case 'ebcdicno277euro':
    9754                         case 'ibm1142':
    9755                                 return 'IBM01142';
    9756 
    9757                         case 'ccsid1143':
    9758                         case 'cp1143':
    9759                         case 'ebcdicfi278euro':
    9760                         case 'ebcdicse278euro':
    9761                         case 'ibm1143':
    9762                                 return 'IBM01143';
    9763 
    9764                         case 'ccsid1144':
    9765                         case 'cp1144':
    9766                         case 'ebcdicit280euro':
    9767                         case 'ibm1144':
    9768                                 return 'IBM01144';
    9769 
    9770                         case 'ccsid1145':
    9771                         case 'cp1145':
    9772                         case 'ebcdices284euro':
    9773                         case 'ibm1145':
    9774                                 return 'IBM01145';
    9775 
    9776                         case 'ccsid1146':
    9777                         case 'cp1146':
    9778                         case 'ebcdicgb285euro':
    9779                         case 'ibm1146':
    9780                                 return 'IBM01146';
    9781 
    9782                         case 'ccsid1147':
    9783                         case 'cp1147':
    9784                         case 'ebcdicfr297euro':
    9785                         case 'ibm1147':
    9786                                 return 'IBM01147';
    9787 
    9788                         case 'ccsid1148':
    9789                         case 'cp1148':
    9790                         case 'ebcdicinternational500euro':
    9791                         case 'ibm1148':
    9792                                 return 'IBM01148';
    9793 
    9794                         case 'ccsid1149':
    9795                         case 'cp1149':
    9796                         case 'ebcdicis871euro':
    9797                         case 'ibm1149':
    9798                                 return 'IBM01149';
    9799 
    98009765                        case 'cp37':
    98019766                        case 'csibm37':
    98029767                        case 'ebcdiccpca':
     
    99449909                        case 'ibm857':
    99459910                                return 'IBM857';
    99469911
     9912                        case 'ccsid858':
     9913                        case 'cp858':
     9914                        case 'ibm858':
     9915                        case 'pcmultilingual850euro':
     9916                                return 'IBM00858';
     9917
    99479918                        case '860':
    99489919                        case 'cp860':
    99499920                        case 'csibm860':
     
    1004610017                        case 'ibm918':
    1004710018                                return 'IBM918';
    1004810019
     10020                        case 'ccsid924':
     10021                        case 'cp924':
     10022                        case 'ebcdiclatin9euro':
     10023                        case 'ibm924':
     10024                                return 'IBM00924';
     10025
    1004910026                        case 'cp1026':
    1005010027                        case 'csibm1026':
    1005110028                        case 'ibm1026':
     
    1005410031                        case 'ibm1047':
    1005510032                                return 'IBM1047';
    1005610033
     10034                        case 'ccsid1140':
     10035                        case 'cp1140':
     10036                        case 'ebcdicus37euro':
     10037                        case 'ibm1140':
     10038                                return 'IBM01140';
     10039
     10040                        case 'ccsid1141':
     10041                        case 'cp1141':
     10042                        case 'ebcdicde273euro':
     10043                        case 'ibm1141':
     10044                                return 'IBM01141';
     10045
     10046                        case 'ccsid1142':
     10047                        case 'cp1142':
     10048                        case 'ebcdicdk277euro':
     10049                        case 'ebcdicno277euro':
     10050                        case 'ibm1142':
     10051                                return 'IBM01142';
     10052
     10053                        case 'ccsid1143':
     10054                        case 'cp1143':
     10055                        case 'ebcdicfi278euro':
     10056                        case 'ebcdicse278euro':
     10057                        case 'ibm1143':
     10058                                return 'IBM01143';
     10059
     10060                        case 'ccsid1144':
     10061                        case 'cp1144':
     10062                        case 'ebcdicit280euro':
     10063                        case 'ibm1144':
     10064                                return 'IBM01144';
     10065
     10066                        case 'ccsid1145':
     10067                        case 'cp1145':
     10068                        case 'ebcdices284euro':
     10069                        case 'ibm1145':
     10070                                return 'IBM01145';
     10071
     10072                        case 'ccsid1146':
     10073                        case 'cp1146':
     10074                        case 'ebcdicgb285euro':
     10075                        case 'ibm1146':
     10076                                return 'IBM01146';
     10077
     10078                        case 'ccsid1147':
     10079                        case 'cp1147':
     10080                        case 'ebcdicfr297euro':
     10081                        case 'ibm1147':
     10082                                return 'IBM01147';
     10083
     10084                        case 'ccsid1148':
     10085                        case 'cp1148':
     10086                        case 'ebcdicinternational500euro':
     10087                        case 'ibm1148':
     10088                                return 'IBM01148';
     10089
     10090                        case 'ccsid1149':
     10091                        case 'cp1149':
     10092                        case 'ebcdicis871euro':
     10093                        case 'ibm1149':
     10094                                return 'IBM01149';
     10095
    1005710096                        case 'csiso143iecp271':
    1005810097                        case 'iecp271':
    1005910098                        case 'isoir143':
     
    1059610635                        case 'sen850200c':
    1059710636                                return 'SEN_850200_C';
    1059810637
    10599                         case 'csshiftjis':
    10600                         case 'mskanji':
    10601                         case 'shiftjis':
    10602                                 return 'Shift_JIS';
    10603 
    1060410638                        case 'csiso102t617bit':
    1060510639                        case 'isoir102':
    1060610640                        case 't617bit':
     
    1069910733                        case 'viscii':
    1070010734                                return 'VISCII';
    1070110735
     10736                        case 'csshiftjis':
    1070210737                        case 'cswindows31j':
     10738                        case 'mskanji':
     10739                        case 'shiftjis':
    1070310740                        case 'windows31j':
    1070410741                                return 'Windows-31J';
    1070510742
     
    1136011397}
    1136111398                <?php
    1136211399        }
     11400
     11401
     11402
     11403        /**
     11404         * Format debugging information
     11405         */
     11406        function debug($sp)
     11407        {
     11408                $info = 'SimplePie ' . SIMPLEPIE_VERSION . ' Build ' . SIMPLEPIE_BUILD . "\n";
     11409                $info .= 'PHP ' . PHP_VERSION . "\n";
     11410                if ($sp->error() !== null)
     11411                {
     11412                        $info .= 'Error occurred: ' . $sp->error() . "\n";
     11413                }
     11414                else
     11415                {
     11416                        $info .= "No error found.\n";
     11417                }
     11418                $info .= "Extensions:\n";
     11419                $extensions = array('pcre', 'curl', 'zlib', 'mbstring', 'iconv', 'xmlreader', 'xml');
     11420                foreach ($extensions as $ext)
     11421                {
     11422                        if (extension_loaded($ext))
     11423                        {
     11424                                $info .= "    $ext loaded\n";
     11425                                switch ($ext)
     11426                                {
     11427                                        case 'pcre':
     11428                                                $info .= '      Version ' . PCRE_VERSION . "\n";
     11429                                                break;
     11430                                        case 'curl':
     11431                                                $version = curl_version();
     11432                                                $info .= '      Version ' . $version['version'] . "\n";
     11433                                                break;
     11434                                        case 'mbstring':
     11435                                                $info .= '      Overloading: ' . mb_get_info('func_overload') . "\n";
     11436                                                break;
     11437                                        case 'iconv':
     11438                                                $info .= '      Version ' . ICONV_VERSION . "\n";
     11439                                                break;
     11440                                        case 'xml':
     11441                                                $info .= '      Version ' . LIBXML_DOTTED_VERSION . "\n";
     11442                                                break;
     11443                                }
     11444                        }
     11445                        else
     11446                        {
     11447                                $info .= "    $ext not loaded\n";
     11448                        }
     11449                }
     11450                return $info;
     11451        }
    1136311452}
    1136411453
    1136511454/**
     
    1183111920        /**
    1183211921         * Replace invalid character with percent encoding
    1183311922         *
    11834          * @access private
    1183511923         * @param string $string Input string
    1183611924         * @param string $valid_chars Valid characters
    1183711925         * @param int $case Normalise case
    1183811926         * @return string
    1183911927         */
    11840         function replace_invalid_with_pct_encoding($string, $valid_chars, $case = SIMPLEPIE_SAME_CASE)
     11928        function replace_invalid_with_pct_encoding($string, $valid_chars, $case = SIMPLEPIE_SAME_CASE, $iprivate = false)
    1184111929        {
     11930                // Normalize as many pct-encoded sections as possible
     11931                $string = preg_replace_callback('/(?:%[A-Fa-f0-9]{2})+/', array(&$this, 'remove_iunreserved_percent_encoded'), $string);
     11932
     11933                // Replace invalid percent characters
     11934                $string = preg_replace('/%(?![A-Fa-f0-9]{2})/', '%25', $string);
     11935
     11936                // Add unreserved and % to $valid_chars (the latter is safe because all
     11937                // pct-encoded sections are now valid).
     11938                $valid_chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~%';
     11939
     11940                // Now replace any bytes that aren't allowed with their pct-encoded versions
     11941                $position = 0;
     11942                $strlen = strlen($string);
     11943                while (($position += strspn($string, $valid_chars, $position)) < $strlen)
     11944                {
     11945                        $value = ord($string[$position]);
     11946
     11947                        // Start position
     11948                        $start = $position;
     11949
     11950                        // By default we are valid
     11951                        $valid = true;
     11952
     11953                        // No one byte sequences are valid due to the while.
     11954                        // Two byte sequence:
     11955                        if (($value & 0xE0) === 0xC0)
     11956                        {
     11957                                $character = ($value & 0x1F) << 6;
     11958                                $length = 2;
     11959                                $remaining = 1;
     11960                        }
     11961                        // Three byte sequence:
     11962                        elseif (($value & 0xF0) === 0xE0)
     11963                        {
     11964                                $character = ($value & 0x0F) << 12;
     11965                                $length = 3;
     11966                                $remaining = 2;
     11967                        }
     11968                        // Four byte sequence:
     11969                        elseif (($value & 0xF8) === 0xF0)
     11970                        {
     11971                                $character = ($value & 0x07) << 18;
     11972                                $length = 4;
     11973                                $remaining = 3;
     11974                        }
     11975                        // Invalid byte:
     11976                        else
     11977                        {
     11978                                $valid = false;
     11979                                $length = 1;
     11980                                $remaining = 0;
     11981                        }
     11982
     11983                        if ($remaining)
     11984                        {
     11985                                if ($position + $length <= $strlen)
     11986                                {
     11987                                        for ($position++; $remaining; $position++)
     11988                                        {
     11989                                                $value = ord($string[$position]);
     11990
     11991                                                // Check that the byte is valid, then add it to the character:
     11992                                                if (($value & 0xC0) === 0x80)
     11993                                                {
     11994                                                        $character |= ($value & 0x3F) << (--$remaining * 6);
     11995                                                }
     11996                                                // If it is invalid, count the sequence as invalid and reprocess the current byte:
     11997                                                else
     11998                                                {
     11999                                                        $valid = false;
     12000                                                        $position--;
     12001                                                        break;
     12002                                                }
     12003                                        }
     12004                                }
     12005                                else
     12006                                {
     12007                                        $position = $strlen - 1;
     12008                                        $valid = false;
     12009                                }
     12010                        }
     12011
     12012                        // Percent encode anything invalid or not in ucschar
     12013                        if (
     12014                                // Invalid sequences
     12015                                !$valid
     12016                                // Non-shortest form sequences are invalid
     12017                                || $length > 1 && $character <= 0x7F
     12018                                || $length > 2 && $character <= 0x7FF
     12019                                || $length > 3 && $character <= 0xFFFF
     12020                                // Outside of range of ucschar codepoints
     12021                                // Noncharacters
     12022                                || ($character & 0xFFFE) === 0xFFFE
     12023                                || $character >= 0xFDD0 && $character <= 0xFDEF
     12024                                || (
     12025                                        // Everything else not in ucschar
     12026                                           $character > 0xD7FF && $character < 0xF900
     12027                                        || $character < 0xA0
     12028                                        || $character > 0xEFFFD
     12029                                )
     12030                                && (
     12031                                        // Everything not in iprivate, if it applies
     12032                                           !$iprivate
     12033                                        || $character < 0xE000
     12034                                        || $character > 0x10FFFD
     12035                                )
     12036                        )
     12037                        {
     12038                                // If we were a character, pretend we weren't, but rather an error.
     12039                                if ($valid)
     12040                                        $position--;
     12041
     12042                                for ($j = $start; $j <= $position; $j++)
     12043                                {
     12044                                        $string = substr_replace($string, sprintf('%%%02X', ord($string[$j])), $j, 1);
     12045                                        $j += 2;
     12046                                        $position += 2;
     12047                                        $strlen += 2;
     12048                                }
     12049                        }
     12050                }
     12051
    1184212052                // Normalise case
    1184312053                if ($case & SIMPLEPIE_LOWERCASE)
    1184412054                {
     
    1184912059                        $string = strtoupper($string);
    1185012060                }
    1185112061
    11852                 // Store position and string length (to avoid constantly recalculating this)
    11853                 $position = 0;
    11854                 $strlen = strlen($string);
     12062                return $string;
     12063        }
    1185512064
    11856                 // Loop as long as we have invalid characters, advancing the position to the next invalid character
    11857                 while (($position += strspn($string, $valid_chars, $position)) < $strlen)
     12065        /**
     12066         * Callback function for preg_replace_callback.
     12067         *
     12068         * Removes sequences of percent encoded bytes that represent UTF-8
     12069         * encoded characters in iunreserved
     12070         *
     12071         * @access private
     12072         * @param array $match PCRE match
     12073         * @return string Replacement
     12074         */
     12075        function remove_iunreserved_percent_encoded($match)
     12076        {
     12077                // As we just have valid percent encoded sequences we can just explode
     12078                // and ignore the first member of the returned array (an empty string).
     12079                $bytes = explode('%', $match[0]);
     12080
     12081                // Initialize the new string (this is what will be returned) and that
     12082                // there are no bytes remaining in the current sequence (unsurprising
     12083                // at the first byte!).
     12084                $string = '';
     12085                $remaining = 0;
     12086
     12087                // Loop over each and every byte, and set $value to its value
     12088                for ($i = 1, $len = count($bytes); $i < $len; $i++)
    1185812089                {
    11859                         // If we have a % character
    11860                         if ($string[$position] === '%')
     12090                        $value = hexdec($bytes[$i]);
     12091
     12092                        // If we're the first byte of sequence:
     12093                        if (!$remaining)
    1186112094                        {
    11862                                 // If we have a pct-encoded section
    11863                                 if ($position + 2 < $strlen && strspn($string, '0123456789ABCDEFabcdef', $position + 1, 2) === 2)
     12095                                // Start position
     12096                                $start = $i;
     12097
     12098                                // By default we are valid
     12099                                $valid = true;
     12100
     12101                                // One byte sequence:
     12102                                if ($value <= 0x7F)
    1186412103                                {
    11865                                         // Get the the represented character
    11866                                         $chr = chr(hexdec(substr($string, $position + 1, 2)));
     12104                                        $character = $value;
     12105                                        $length = 1;
     12106                                }
     12107                                // Two byte sequence:
     12108                                elseif (($value & 0xE0) === 0xC0)
     12109                                {
     12110                                        $character = ($value & 0x1F) << 6;
     12111                                        $length = 2;
     12112                                        $remaining = 1;
     12113                                }
     12114                                // Three byte sequence:
     12115                                elseif (($value & 0xF0) === 0xE0)
     12116                                {
     12117                                        $character = ($value & 0x0F) << 12;
     12118                                        $length = 3;
     12119                                        $remaining = 2;
     12120                                }
     12121                                // Four byte sequence:
     12122                                elseif (($value & 0xF8) === 0xF0)
     12123                                {
     12124                                        $character = ($value & 0x07) << 18;
     12125                                        $length = 4;
     12126                                        $remaining = 3;
     12127                                }
     12128                                // Invalid byte:
     12129                                else
     12130                                {
     12131                                        $valid = false;
     12132                                        $remaining = 0;
     12133                                }
     12134                        }
     12135                        // Continuation byte:
     12136                        else
     12137                        {
     12138                                // Check that the byte is valid, then add it to the character:
     12139                                if (($value & 0xC0) === 0x80)
     12140                                {
     12141                                        $remaining--;
     12142                                        $character |= ($value & 0x3F) << ($remaining * 6);
     12143                                }
     12144                                // If it is invalid, count the sequence as invalid and reprocess the current byte as the start of a sequence:
     12145                                else
     12146                                {
     12147                                        $valid = false;
     12148                                        $remaining = 0;
     12149                                        $i--;
     12150                                }
     12151                        }
    1186712152
    11868                                         // If the character is valid, replace the pct-encoded with the actual character while normalising case
    11869                                         if (strpos($valid_chars, $chr) !== false)
     12153                        // If we've reached the end of the current byte sequence, append it to Unicode::$data
     12154                        if (!$remaining)
     12155                        {
     12156                                // Percent encode anything invalid or not in iunreserved
     12157                                if (
     12158                                        // Invalid sequences
     12159                                        !$valid
     12160                                        // Non-shortest form sequences are invalid
     12161                                        || $length > 1 && $character <= 0x7F
     12162                                        || $length > 2 && $character <= 0x7FF
     12163                                        || $length > 3 && $character <= 0xFFFF
     12164                                        // Outside of range of iunreserved codepoints
     12165                                        || $character < 0x2D
     12166                                        || $character > 0xEFFFD
     12167                                        // Noncharacters
     12168                                        || ($character & 0xFFFE) === 0xFFFE
     12169                                        || $character >= 0xFDD0 && $character <= 0xFDEF
     12170                                        // Everything else not in iunreserved (this is all BMP)
     12171                                        || $character === 0x2F
     12172                                        || $character > 0x39 && $character < 0x41
     12173                                        || $character > 0x5A && $character < 0x61
     12174                                        || $character > 0x7A && $character < 0x7E
     12175                                        || $character > 0x7E && $character < 0xA0
     12176                                        || $character > 0xD7FF && $character < 0xF900
     12177                                )
     12178                                {
     12179                                        for ($j = $start; $j <= $i; $j++)
    1187012180                                        {
    11871                                                 if ($case & SIMPLEPIE_LOWERCASE)
    11872                                                 {
    11873                                                         $chr = strtolower($chr);
    11874                                                 }
    11875                                                 elseif ($case & SIMPLEPIE_UPPERCASE)
    11876                                                 {
    11877                                                         $chr = strtoupper($chr);
    11878                                                 }
    11879                                                 $string = substr_replace($string, $chr, $position, 3);
    11880                                                 $strlen -= 2;
    11881                                                 $position++;
     12181                                                $string .= '%' . strtoupper($bytes[$j]);
    1188212182                                        }
    11883 
    11884                                         // Otherwise just normalise the pct-encoded to uppercase
    11885                                         else
    11886                                         {
    11887                                                 $string = substr_replace($string, strtoupper(substr($string, $position + 1, 2)), $position + 1, 2);
    11888                                                 $position += 3;
    11889                                         }
    1189012183                                }
    11891                                 // If we don't have a pct-encoded section, just replace the % with its own esccaped form
    1189212184                                else
    1189312185                                {
    11894                                         $string = substr_replace($string, '%25', $position, 1);
    11895                                         $strlen += 2;
    11896                                         $position += 3;
     12186                                        for ($j = $start; $j <= $i; $j++)
     12187                                        {
     12188                                                $string .= chr(hexdec($bytes[$j]));
     12189                                        }
    1189712190                                }
    1189812191                        }
    11899                         // If we have an invalid character, change into its pct-encoded form
    11900                         else
     12192                }
     12193
     12194                // If we have any bytes left over they are invalid (i.e., we are
     12195                // mid-way through a multi-byte sequence)
     12196                if ($remaining)
     12197                {
     12198                        for ($j = $start; $j < $len; $j++)
    1190112199                        {
    11902                                 $replacement = sprintf("%%%02X", ord($string[$position]));
    11903                                 $string = str_replace($string[$position], $replacement, $string);
    11904                                 $strlen = strlen($string);
     12200                                $string .= '%' . strtoupper($bytes[$j]);
    1190512201                        }
    1190612202                }
     12203
    1190712204                return $string;
    1190812205        }
    1190912206
     
    1213012427                }
    1213112428                else
    1213212429                {
    12133                         $this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:@/?');
     12430                        $this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$\'()*+,;:@/?&=');
    1213412431                }
    1213512432                $this->valid[__FUNCTION__] = true;
    1213612433                return true;
     
    1393314230                }
    1393414231                else
    1393514232                {
    13936                         $this->state = 'standalone_name';
     14233                        $this->state = false;
    1393714234                }
    1393814235        }
    1393914236
     
    1394714244                }
    1394814245                else
    1394914246                {
    13950                         $this->state = false;
     14247                        $this->state = 'standalone_name';
    1395114248                }
    1395214249        }
    1395314250
     
    1442514722                                        case constant('XMLReader::END_ELEMENT'):
    1442614723                                                if ($xml->namespaceURI !== '')
    1442714724                                                {
    14428                                                         $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
     14725                                                        $tagName = $xml->namespaceURI . $this->separator . $xml->localName;
    1442914726                                                }
    1443014727                                                else
    1443114728                                                {
     
    1443714734                                                $empty = $xml->isEmptyElement;
    1443814735                                                if ($xml->namespaceURI !== '')
    1443914736                                                {
    14440                                                         $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
     14737                                                        $tagName = $xml->namespaceURI . $this->separator . $xml->localName;
    1444114738                                                }
    1444214739                                                else
    1444314740                                                {
     
    1444814745                                                {
    1444914746                                                        if ($xml->namespaceURI !== '')
    1445014747                                                        {
    14451                                                                 $attrName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
     14748                                                                $attrName = $xml->namespaceURI . $this->separator . $xml->localName;
    1445214749                                                        }
    1445314750                                                        else
    1445414751                                                        {
     
    1491315210                                                                        }
    1491415211                                                                        else
    1491515212                                                                        {
    14916                                                                                 trigger_error("$this->cache_location is not writeable", E_USER_WARNING);
     15213                                                                                trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
    1491715214                                                                        }
    1491815215                                                                }
    1491915216                                                        }
     
    1499815295                }
    1499915296        }
    1500015297}
    15001 endif;
     15298
    1500215299?>