web/wp-includes/class-simplepie.php
changeset 194 32102edaa81b
parent 136 bde1974c263b
child 204 09a1c134465b
equal deleted inserted replaced
193:2f6f6f7551ca 194:32102edaa81b
     1 <?php
     1 <?php
       
     2 if ( ! class_exists( 'SimplePie' ) ) :
     2 /**
     3 /**
     3  * SimplePie
     4  * SimplePie
     4  *
     5  *
     5  * A PHP-Based RSS and Atom Feed Framework.
     6  * A PHP-Based RSS and Atom Feed Framework.
     6  * Takes the hard work out of managing a complete RSS/Atom solution.
     7  * Takes the hard work out of managing a complete RSS/Atom solution.
     7  *
     8  *
     8  * Copyright (c) 2004-2009, Ryan Parman and Geoffrey Sneddon
     9  * Copyright (c) 2004-2011, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     9  * All rights reserved.
    10  * All rights reserved.
    10  *
    11  *
    11  * Redistribution and use in source and binary forms, with or without modification, are
    12  * Redistribution and use in source and binary forms, with or without modification, are
    12  * permitted provided that the following conditions are met:
    13  * permitted provided that the following conditions are met:
    13  *
    14  *
    31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    32  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    33  * POSSIBILITY OF SUCH DAMAGE.
    34  * POSSIBILITY OF SUCH DAMAGE.
    34  *
    35  *
    35  * @package SimplePie
    36  * @package SimplePie
    36  * @version 1.2
    37  * @version 1.2.1
    37  * @copyright 2004-2009 Ryan Parman, Geoffrey Sneddon
    38  * @copyright 2004-2011 Ryan Parman, Geoffrey Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Ryan Parman
    39  * @author Geoffrey Sneddon
    40  * @author Geoffrey Sneddon
       
    41  * @author Ryan McCue
    40  * @link http://simplepie.org/ SimplePie
    42  * @link http://simplepie.org/ SimplePie
    41  * @link http://simplepie.org/support/ Please submit all bug reports and feature requests to the SimplePie forums
    43  * @link http://simplepie.org/support/ Please submit all bug reports and feature requests to the SimplePie forums
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    44  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  * @todo phpDoc comments
    45  * @todo phpDoc comments
    44  */
    46  */
    49 define('SIMPLEPIE_NAME', 'SimplePie');
    51 define('SIMPLEPIE_NAME', 'SimplePie');
    50 
    52 
    51 /**
    53 /**
    52  * SimplePie Version
    54  * SimplePie Version
    53  */
    55  */
    54 define('SIMPLEPIE_VERSION', '1.2');
    56 define('SIMPLEPIE_VERSION', '1.2.1');
    55 
    57 
    56 /**
    58 /**
    57  * SimplePie Build
    59  * SimplePie Build
    58  */
    60  */
    59 define('SIMPLEPIE_BUILD', '20090627192103');
    61 define('SIMPLEPIE_BUILD', '20111015034325');
    60 
    62 
    61 /**
    63 /**
    62  * SimplePie Website URL
    64  * SimplePie Website URL
    63  */
    65  */
    64 define('SIMPLEPIE_URL', 'http://simplepie.org');
    66 define('SIMPLEPIE_URL', 'http://simplepie.org');
  1669 							if ($cache)
  1671 							if ($cache)
  1670 							{
  1672 							{
  1671 								$this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
  1673 								$this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
  1672 								if (!$cache->save($this))
  1674 								if (!$cache->save($this))
  1673 								{
  1675 								{
  1674 									trigger_error("$this->cache_location is not writeable", E_USER_WARNING);
  1676 									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);
  1675 								}
  1677 								}
  1676 								$cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc');
  1678 								$cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc');
  1677 							}
  1679 							}
  1678 							$this->feed_url = $file->url;
  1680 							$this->feed_url = $file->url;
  1679 						}
  1681 						}
  1680 						else
  1682 						else
  1681 						{
  1683 						{
  1682 							$this->error = "A feed could not be found at $this->feed_url";
  1684 							$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.";
  1683 							SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
  1685 							SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
  1684 							return false;
  1686 							return false;
  1685 						}
  1687 						}
  1686 					}
  1688 					}
  1687 					$locate = null;
  1689 					$locate = null;
  1774 							$this->data['build'] = SIMPLEPIE_BUILD;
  1776 							$this->data['build'] = SIMPLEPIE_BUILD;
  1775 
  1777 
  1776 							// Cache the file if caching is enabled
  1778 							// Cache the file if caching is enabled
  1777 							if ($cache && !$cache->save($this))
  1779 							if ($cache && !$cache->save($this))
  1778 							{
  1780 							{
  1779 								trigger_error("$cache->name is not writeable", E_USER_WARNING);
  1781 								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);
  1780 							}
  1782 							}
  1781 							return true;
  1783 							return true;
  1782 						}
  1784 						}
  1783 						else
  1785 						else
  1784 						{
  1786 						{
  1785 							$this->error = "A feed could not be found at $this->feed_url";
  1787 							$this->error = "A feed could not be found at $this->feed_url. This does not appear to be a valid RSS or Atom feed.";
  1786 							SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
  1788 							SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
  1787 							return false;
  1789 							return false;
  1788 						}
  1790 						}
  1789 					}
  1791 					}
  1790 				}
  1792 				}
  1791 			}
  1793 			}
  1792 			if(isset($parser))
  1794 			if (isset($parser))
  1793 			{
  1795 			{
  1794 				// We have an error, just set SimplePie_Misc::error to it and quit
  1796 				// We have an error, just set SimplePie_Misc::error to it and quit
  1795 				$this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
  1797 				$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());
  1796 			}
  1798 			}
  1797 			else
  1799 			else
  1798 			{
  1800 			{
  1799 				$this->error = 'The data could not be converted to UTF-8';
  1801 				$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.';
  1800 			}
  1802 			}
  1801 			SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
  1803 			SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
  1802 			return false;
  1804 			return false;
  1803 		}
  1805 		}
  1804 		elseif (!empty($this->multifeed_url))
  1806 		elseif (!empty($this->multifeed_url))
  1981 							{
  1983 							{
  1982 								return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI);
  1984 								return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI);
  1983 							}
  1985 							}
  1984 							else
  1986 							else
  1985 							{
  1987 							{
  1986 								trigger_error("$cache->name is not writeable", E_USER_WARNING);
  1988 								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);
  1987 								return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
  1989 								return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
  1988 							}
  1990 							}
  1989 						}
  1991 						}
  1990 						// not an image
  1992 						// not an image
  1991 						else
  1993 						else
  2771 		}
  2773 		}
  2772 	}
  2774 	}
  2773 
  2775 
  2774 	function get_latitude()
  2776 	function get_latitude()
  2775 	{
  2777 	{
       
  2778 
  2776 		if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
  2779 		if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
  2777 		{
  2780 		{
  2778 			return (float) $return[0]['data'];
  2781 			return (float) $return[0]['data'];
  2779 		}
  2782 		}
  2780 		elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
  2783 		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))
  2781 		{
  2784 		{
  2782 			return (float) $match[1];
  2785 			return (float) $match[1];
  2783 		}
  2786 		}
  2784 		else
  2787 		else
  2785 		{
  2788 		{
  2795 		}
  2798 		}
  2796 		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
  2799 		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
  2797 		{
  2800 		{
  2798 			return (float) $return[0]['data'];
  2801 			return (float) $return[0]['data'];
  2799 		}
  2802 		}
  2800 		elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
  2803 		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))
  2801 		{
  2804 		{
  2802 			return (float) $match[2];
  2805 			return (float) $match[2];
  2803 		}
  2806 		}
  2804 		else
  2807 		else
  2805 		{
  2808 		{
  3275 		}
  3278 		}
  3276 		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
  3279 		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
  3277 		{
  3280 		{
  3278 			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
  3281 			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
  3279 		}
  3282 		}
       
  3283 		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
       
  3284 		{
       
  3285 			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML);
       
  3286 		}
       
  3287 
  3280 		elseif (!$description_only)
  3288 		elseif (!$description_only)
  3281 		{
  3289 		{
  3282 			return $this->get_content(true);
  3290 			return $this->get_content(true);
  3283 		}
  3291 		}
  3284 		else
  3292 		else
  3639 	{
  3647 	{
  3640 		if (!$date_format)
  3648 		if (!$date_format)
  3641 		{
  3649 		{
  3642 			return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT);
  3650 			return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT);
  3643 		}
  3651 		}
  3644 		elseif (($date = $this->get_date('U')) !== null)
  3652 		elseif (($date = $this->get_date('U')) !== null && $date !== false)
  3645 		{
  3653 		{
  3646 			return strftime($date_format, $date);
  3654 			return strftime($date_format, $date);
  3647 		}
  3655 		}
  3648 		else
  3656 		else
  3649 		{
  3657 		{
  4064 				if (isset($duration_parent[0]['data']))
  4072 				if (isset($duration_parent[0]['data']))
  4065 				{
  4073 				{
  4066 					$temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
  4074 					$temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
  4067 					if (sizeof($temp) > 0)
  4075 					if (sizeof($temp) > 0)
  4068 					{
  4076 					{
  4069 						(int) $seconds = array_pop($temp);
  4077 						$seconds = (int) array_pop($temp);
  4070 					}
  4078 					}
  4071 					if (sizeof($temp) > 0)
  4079 					if (sizeof($temp) > 0)
  4072 					{
  4080 					{
  4073 						(int) $minutes = array_pop($temp);
  4081 						$minutes = (int) array_pop($temp);
  4074 						$seconds += $minutes * 60;
  4082 						$seconds += $minutes * 60;
  4075 					}
  4083 					}
  4076 					if (sizeof($temp) > 0)
  4084 					if (sizeof($temp) > 0)
  4077 					{
  4085 					{
  4078 						(int) $hours = array_pop($temp);
  4086 						$hours = (int) array_pop($temp);
  4079 						$seconds += $hours * 3600;
  4087 						$seconds += $hours * 3600;
  4080 					}
  4088 					}
  4081 					unset($temp);
  4089 					unset($temp);
  4082 					$duration_parent = $seconds;
  4090 					$duration_parent = $seconds;
  4083 				}
  4091 				}
  4425 			$title = null;
  4433 			$title = null;
  4426 
  4434 
  4427 			// If we have media:group tags, loop through them.
  4435 			// If we have media:group tags, loop through them.
  4428 			foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group)
  4436 			foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group)
  4429 			{
  4437 			{
  4430 				// If we have media:content tags, loop through them.
  4438 				if(isset($group['child']) && isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
  4431 				foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
  4439 				{
  4432 				{
  4440 					// If we have media:content tags, loop through them.
  4433 					if (isset($content['attribs']['']['url']))
  4441 					foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
       
  4442 					{
       
  4443 						if (isset($content['attribs']['']['url']))
       
  4444 						{
       
  4445 							// Attributes
       
  4446 							$bitrate = null;
       
  4447 							$channels = null;
       
  4448 							$duration = null;
       
  4449 							$expression = null;
       
  4450 							$framerate = null;
       
  4451 							$height = null;
       
  4452 							$javascript = null;
       
  4453 							$lang = null;
       
  4454 							$length = null;
       
  4455 							$medium = null;
       
  4456 							$samplingrate = null;
       
  4457 							$type = null;
       
  4458 							$url = null;
       
  4459 							$width = null;
       
  4460 
       
  4461 							// Elements
       
  4462 							$captions = null;
       
  4463 							$categories = null;
       
  4464 							$copyrights = null;
       
  4465 							$credits = null;
       
  4466 							$description = null;
       
  4467 							$hashes = null;
       
  4468 							$keywords = null;
       
  4469 							$player = null;
       
  4470 							$ratings = null;
       
  4471 							$restrictions = null;
       
  4472 							$thumbnails = null;
       
  4473 							$title = null;
       
  4474 
       
  4475 							// Start checking the attributes of media:content
       
  4476 							if (isset($content['attribs']['']['bitrate']))
       
  4477 							{
       
  4478 								$bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4479 							}
       
  4480 							if (isset($content['attribs']['']['channels']))
       
  4481 							{
       
  4482 								$channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4483 							}
       
  4484 							if (isset($content['attribs']['']['duration']))
       
  4485 							{
       
  4486 								$duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4487 							}
       
  4488 							else
       
  4489 							{
       
  4490 								$duration = $duration_parent;
       
  4491 							}
       
  4492 							if (isset($content['attribs']['']['expression']))
       
  4493 							{
       
  4494 								$expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4495 							}
       
  4496 							if (isset($content['attribs']['']['framerate']))
       
  4497 							{
       
  4498 								$framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4499 							}
       
  4500 							if (isset($content['attribs']['']['height']))
       
  4501 							{
       
  4502 								$height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4503 							}
       
  4504 							if (isset($content['attribs']['']['lang']))
       
  4505 							{
       
  4506 								$lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4507 							}
       
  4508 							if (isset($content['attribs']['']['fileSize']))
       
  4509 							{
       
  4510 								$length = ceil($content['attribs']['']['fileSize']);
       
  4511 							}
       
  4512 							if (isset($content['attribs']['']['medium']))
       
  4513 							{
       
  4514 								$medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4515 							}
       
  4516 							if (isset($content['attribs']['']['samplingrate']))
       
  4517 							{
       
  4518 								$samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4519 							}
       
  4520 							if (isset($content['attribs']['']['type']))
       
  4521 							{
       
  4522 								$type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4523 							}
       
  4524 							if (isset($content['attribs']['']['width']))
       
  4525 							{
       
  4526 								$width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4527 							}
       
  4528 							$url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
       
  4529 
       
  4530 							// Checking the other optional media: elements. Priority: media:content, media:group, item, channel
       
  4531 
       
  4532 							// CAPTIONS
       
  4533 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
       
  4534 							{
       
  4535 								foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
       
  4536 								{
       
  4537 									$caption_type = null;
       
  4538 									$caption_lang = null;
       
  4539 									$caption_startTime = null;
       
  4540 									$caption_endTime = null;
       
  4541 									$caption_text = null;
       
  4542 									if (isset($caption['attribs']['']['type']))
       
  4543 									{
       
  4544 										$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4545 									}
       
  4546 									if (isset($caption['attribs']['']['lang']))
       
  4547 									{
       
  4548 										$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4549 									}
       
  4550 									if (isset($caption['attribs']['']['start']))
       
  4551 									{
       
  4552 										$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4553 									}
       
  4554 									if (isset($caption['attribs']['']['end']))
       
  4555 									{
       
  4556 										$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4557 									}
       
  4558 									if (isset($caption['data']))
       
  4559 									{
       
  4560 										$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4561 									}
       
  4562 									$captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
       
  4563 								}
       
  4564 								if (is_array($captions))
       
  4565 								{
       
  4566 									$captions = array_values(SimplePie_Misc::array_unique($captions));
       
  4567 								}
       
  4568 							}
       
  4569 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
       
  4570 							{
       
  4571 								foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
       
  4572 								{
       
  4573 									$caption_type = null;
       
  4574 									$caption_lang = null;
       
  4575 									$caption_startTime = null;
       
  4576 									$caption_endTime = null;
       
  4577 									$caption_text = null;
       
  4578 									if (isset($caption['attribs']['']['type']))
       
  4579 									{
       
  4580 										$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4581 									}
       
  4582 									if (isset($caption['attribs']['']['lang']))
       
  4583 									{
       
  4584 										$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4585 									}
       
  4586 									if (isset($caption['attribs']['']['start']))
       
  4587 									{
       
  4588 										$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4589 									}
       
  4590 									if (isset($caption['attribs']['']['end']))
       
  4591 									{
       
  4592 										$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4593 									}
       
  4594 									if (isset($caption['data']))
       
  4595 									{
       
  4596 										$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4597 									}
       
  4598 									$captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
       
  4599 								}
       
  4600 								if (is_array($captions))
       
  4601 								{
       
  4602 									$captions = array_values(SimplePie_Misc::array_unique($captions));
       
  4603 								}
       
  4604 							}
       
  4605 							else
       
  4606 							{
       
  4607 								$captions = $captions_parent;
       
  4608 							}
       
  4609 
       
  4610 							// CATEGORIES
       
  4611 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
       
  4612 							{
       
  4613 								foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
       
  4614 								{
       
  4615 									$term = null;
       
  4616 									$scheme = null;
       
  4617 									$label = null;
       
  4618 									if (isset($category['data']))
       
  4619 									{
       
  4620 										$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4621 									}
       
  4622 									if (isset($category['attribs']['']['scheme']))
       
  4623 									{
       
  4624 										$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4625 									}
       
  4626 									else
       
  4627 									{
       
  4628 										$scheme = 'http://search.yahoo.com/mrss/category_schema';
       
  4629 									}
       
  4630 									if (isset($category['attribs']['']['label']))
       
  4631 									{
       
  4632 										$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4633 									}
       
  4634 									$categories[] =& new $this->feed->category_class($term, $scheme, $label);
       
  4635 								}
       
  4636 							}
       
  4637 							if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
       
  4638 							{
       
  4639 								foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
       
  4640 								{
       
  4641 									$term = null;
       
  4642 									$scheme = null;
       
  4643 									$label = null;
       
  4644 									if (isset($category['data']))
       
  4645 									{
       
  4646 										$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4647 									}
       
  4648 									if (isset($category['attribs']['']['scheme']))
       
  4649 									{
       
  4650 										$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4651 									}
       
  4652 									else
       
  4653 									{
       
  4654 										$scheme = 'http://search.yahoo.com/mrss/category_schema';
       
  4655 									}
       
  4656 									if (isset($category['attribs']['']['label']))
       
  4657 									{
       
  4658 										$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4659 									}
       
  4660 									$categories[] =& new $this->feed->category_class($term, $scheme, $label);
       
  4661 								}
       
  4662 							}
       
  4663 							if (is_array($categories) && is_array($categories_parent))
       
  4664 							{
       
  4665 								$categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent)));
       
  4666 							}
       
  4667 							elseif (is_array($categories))
       
  4668 							{
       
  4669 								$categories = array_values(SimplePie_Misc::array_unique($categories));
       
  4670 							}
       
  4671 							elseif (is_array($categories_parent))
       
  4672 							{
       
  4673 								$categories = array_values(SimplePie_Misc::array_unique($categories_parent));
       
  4674 							}
       
  4675 
       
  4676 							// COPYRIGHTS
       
  4677 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
       
  4678 							{
       
  4679 								$copyright_url = null;
       
  4680 								$copyright_label = null;
       
  4681 								if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
       
  4682 								{
       
  4683 									$copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4684 								}
       
  4685 								if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
       
  4686 								{
       
  4687 									$copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4688 								}
       
  4689 								$copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
       
  4690 							}
       
  4691 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
       
  4692 							{
       
  4693 								$copyright_url = null;
       
  4694 								$copyright_label = null;
       
  4695 								if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
       
  4696 								{
       
  4697 									$copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4698 								}
       
  4699 								if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
       
  4700 								{
       
  4701 									$copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4702 								}
       
  4703 								$copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
       
  4704 							}
       
  4705 							else
       
  4706 							{
       
  4707 								$copyrights = $copyrights_parent;
       
  4708 							}
       
  4709 
       
  4710 							// CREDITS
       
  4711 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
       
  4712 							{
       
  4713 								foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
       
  4714 								{
       
  4715 									$credit_role = null;
       
  4716 									$credit_scheme = null;
       
  4717 									$credit_name = null;
       
  4718 									if (isset($credit['attribs']['']['role']))
       
  4719 									{
       
  4720 										$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4721 									}
       
  4722 									if (isset($credit['attribs']['']['scheme']))
       
  4723 									{
       
  4724 										$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4725 									}
       
  4726 									else
       
  4727 									{
       
  4728 										$credit_scheme = 'urn:ebu';
       
  4729 									}
       
  4730 									if (isset($credit['data']))
       
  4731 									{
       
  4732 										$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4733 									}
       
  4734 									$credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
       
  4735 								}
       
  4736 								if (is_array($credits))
       
  4737 								{
       
  4738 									$credits = array_values(SimplePie_Misc::array_unique($credits));
       
  4739 								}
       
  4740 							}
       
  4741 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
       
  4742 							{
       
  4743 								foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
       
  4744 								{
       
  4745 									$credit_role = null;
       
  4746 									$credit_scheme = null;
       
  4747 									$credit_name = null;
       
  4748 									if (isset($credit['attribs']['']['role']))
       
  4749 									{
       
  4750 										$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4751 									}
       
  4752 									if (isset($credit['attribs']['']['scheme']))
       
  4753 									{
       
  4754 										$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4755 									}
       
  4756 									else
       
  4757 									{
       
  4758 										$credit_scheme = 'urn:ebu';
       
  4759 									}
       
  4760 									if (isset($credit['data']))
       
  4761 									{
       
  4762 										$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4763 									}
       
  4764 									$credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
       
  4765 								}
       
  4766 								if (is_array($credits))
       
  4767 								{
       
  4768 									$credits = array_values(SimplePie_Misc::array_unique($credits));
       
  4769 								}
       
  4770 							}
       
  4771 							else
       
  4772 							{
       
  4773 								$credits = $credits_parent;
       
  4774 							}
       
  4775 
       
  4776 							// DESCRIPTION
       
  4777 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
       
  4778 							{
       
  4779 								$description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4780 							}
       
  4781 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
       
  4782 							{
       
  4783 								$description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4784 							}
       
  4785 							else
       
  4786 							{
       
  4787 								$description = $description_parent;
       
  4788 							}
       
  4789 
       
  4790 							// HASHES
       
  4791 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
       
  4792 							{
       
  4793 								foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
       
  4794 								{
       
  4795 									$value = null;
       
  4796 									$algo = null;
       
  4797 									if (isset($hash['data']))
       
  4798 									{
       
  4799 										$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4800 									}
       
  4801 									if (isset($hash['attribs']['']['algo']))
       
  4802 									{
       
  4803 										$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4804 									}
       
  4805 									else
       
  4806 									{
       
  4807 										$algo = 'md5';
       
  4808 									}
       
  4809 									$hashes[] = $algo.':'.$value;
       
  4810 								}
       
  4811 								if (is_array($hashes))
       
  4812 								{
       
  4813 									$hashes = array_values(SimplePie_Misc::array_unique($hashes));
       
  4814 								}
       
  4815 							}
       
  4816 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
       
  4817 							{
       
  4818 								foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
       
  4819 								{
       
  4820 									$value = null;
       
  4821 									$algo = null;
       
  4822 									if (isset($hash['data']))
       
  4823 									{
       
  4824 										$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4825 									}
       
  4826 									if (isset($hash['attribs']['']['algo']))
       
  4827 									{
       
  4828 										$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4829 									}
       
  4830 									else
       
  4831 									{
       
  4832 										$algo = 'md5';
       
  4833 									}
       
  4834 									$hashes[] = $algo.':'.$value;
       
  4835 								}
       
  4836 								if (is_array($hashes))
       
  4837 								{
       
  4838 									$hashes = array_values(SimplePie_Misc::array_unique($hashes));
       
  4839 								}
       
  4840 							}
       
  4841 							else
       
  4842 							{
       
  4843 								$hashes = $hashes_parent;
       
  4844 							}
       
  4845 
       
  4846 							// KEYWORDS
       
  4847 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
       
  4848 							{
       
  4849 								if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
       
  4850 								{
       
  4851 									$temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
       
  4852 									foreach ($temp as $word)
       
  4853 									{
       
  4854 										$keywords[] = trim($word);
       
  4855 									}
       
  4856 									unset($temp);
       
  4857 								}
       
  4858 								if (is_array($keywords))
       
  4859 								{
       
  4860 									$keywords = array_values(SimplePie_Misc::array_unique($keywords));
       
  4861 								}
       
  4862 							}
       
  4863 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
       
  4864 							{
       
  4865 								if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
       
  4866 								{
       
  4867 									$temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
       
  4868 									foreach ($temp as $word)
       
  4869 									{
       
  4870 										$keywords[] = trim($word);
       
  4871 									}
       
  4872 									unset($temp);
       
  4873 								}
       
  4874 								if (is_array($keywords))
       
  4875 								{
       
  4876 									$keywords = array_values(SimplePie_Misc::array_unique($keywords));
       
  4877 								}
       
  4878 							}
       
  4879 							else
       
  4880 							{
       
  4881 								$keywords = $keywords_parent;
       
  4882 							}
       
  4883 
       
  4884 							// PLAYER
       
  4885 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
       
  4886 							{
       
  4887 								$player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
       
  4888 							}
       
  4889 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
       
  4890 							{
       
  4891 								$player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
       
  4892 							}
       
  4893 							else
       
  4894 							{
       
  4895 								$player = $player_parent;
       
  4896 							}
       
  4897 
       
  4898 							// RATINGS
       
  4899 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
       
  4900 							{
       
  4901 								foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
       
  4902 								{
       
  4903 									$rating_scheme = null;
       
  4904 									$rating_value = null;
       
  4905 									if (isset($rating['attribs']['']['scheme']))
       
  4906 									{
       
  4907 										$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4908 									}
       
  4909 									else
       
  4910 									{
       
  4911 										$rating_scheme = 'urn:simple';
       
  4912 									}
       
  4913 									if (isset($rating['data']))
       
  4914 									{
       
  4915 										$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4916 									}
       
  4917 									$ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
       
  4918 								}
       
  4919 								if (is_array($ratings))
       
  4920 								{
       
  4921 									$ratings = array_values(SimplePie_Misc::array_unique($ratings));
       
  4922 								}
       
  4923 							}
       
  4924 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
       
  4925 							{
       
  4926 								foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
       
  4927 								{
       
  4928 									$rating_scheme = null;
       
  4929 									$rating_value = null;
       
  4930 									if (isset($rating['attribs']['']['scheme']))
       
  4931 									{
       
  4932 										$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4933 									}
       
  4934 									else
       
  4935 									{
       
  4936 										$rating_scheme = 'urn:simple';
       
  4937 									}
       
  4938 									if (isset($rating['data']))
       
  4939 									{
       
  4940 										$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4941 									}
       
  4942 									$ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
       
  4943 								}
       
  4944 								if (is_array($ratings))
       
  4945 								{
       
  4946 									$ratings = array_values(SimplePie_Misc::array_unique($ratings));
       
  4947 								}
       
  4948 							}
       
  4949 							else
       
  4950 							{
       
  4951 								$ratings = $ratings_parent;
       
  4952 							}
       
  4953 
       
  4954 							// RESTRICTIONS
       
  4955 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
       
  4956 							{
       
  4957 								foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
       
  4958 								{
       
  4959 									$restriction_relationship = null;
       
  4960 									$restriction_type = null;
       
  4961 									$restriction_value = null;
       
  4962 									if (isset($restriction['attribs']['']['relationship']))
       
  4963 									{
       
  4964 										$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4965 									}
       
  4966 									if (isset($restriction['attribs']['']['type']))
       
  4967 									{
       
  4968 										$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4969 									}
       
  4970 									if (isset($restriction['data']))
       
  4971 									{
       
  4972 										$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4973 									}
       
  4974 									$restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
       
  4975 								}
       
  4976 								if (is_array($restrictions))
       
  4977 								{
       
  4978 									$restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
       
  4979 								}
       
  4980 							}
       
  4981 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
       
  4982 							{
       
  4983 								foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
       
  4984 								{
       
  4985 									$restriction_relationship = null;
       
  4986 									$restriction_type = null;
       
  4987 									$restriction_value = null;
       
  4988 									if (isset($restriction['attribs']['']['relationship']))
       
  4989 									{
       
  4990 										$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4991 									}
       
  4992 									if (isset($restriction['attribs']['']['type']))
       
  4993 									{
       
  4994 										$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4995 									}
       
  4996 									if (isset($restriction['data']))
       
  4997 									{
       
  4998 										$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4999 									}
       
  5000 									$restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
       
  5001 								}
       
  5002 								if (is_array($restrictions))
       
  5003 								{
       
  5004 									$restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
       
  5005 								}
       
  5006 							}
       
  5007 							else
       
  5008 							{
       
  5009 								$restrictions = $restrictions_parent;
       
  5010 							}
       
  5011 
       
  5012 							// THUMBNAILS
       
  5013 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
       
  5014 							{
       
  5015 								foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
       
  5016 								{
       
  5017 									$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
       
  5018 								}
       
  5019 								if (is_array($thumbnails))
       
  5020 								{
       
  5021 									$thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
       
  5022 								}
       
  5023 							}
       
  5024 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
       
  5025 							{
       
  5026 								foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
       
  5027 								{
       
  5028 									$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
       
  5029 								}
       
  5030 								if (is_array($thumbnails))
       
  5031 								{
       
  5032 									$thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
       
  5033 								}
       
  5034 							}
       
  5035 							else
       
  5036 							{
       
  5037 								$thumbnails = $thumbnails_parent;
       
  5038 							}
       
  5039 
       
  5040 							// TITLES
       
  5041 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
       
  5042 							{
       
  5043 								$title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  5044 							}
       
  5045 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
       
  5046 							{
       
  5047 								$title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  5048 							}
       
  5049 							else
       
  5050 							{
       
  5051 								$title = $title_parent;
       
  5052 							}
       
  5053 
       
  5054 							$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);
       
  5055 						}
       
  5056 					}
       
  5057 				}
       
  5058 			}
       
  5059 
       
  5060 			// If we have standalone media:content tags, loop through them.
       
  5061 			if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
       
  5062 			{
       
  5063 				foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
       
  5064 				{
       
  5065 					if (isset($content['attribs']['']['url']) || isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
  4434 					{
  5066 					{
  4435 						// Attributes
  5067 						// Attributes
  4436 						$bitrate = null;
  5068 						$bitrate = null;
  4437 						$channels = null;
  5069 						$channels = null;
  4438 						$duration = null;
  5070 						$duration = null;
  4513 						}
  5145 						}
  4514 						if (isset($content['attribs']['']['width']))
  5146 						if (isset($content['attribs']['']['width']))
  4515 						{
  5147 						{
  4516 							$width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
  5148 							$width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
  4517 						}
  5149 						}
  4518 						$url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
  5150 						if (isset($content['attribs']['']['url']))
  4519 
       
  4520 						// Checking the other optional media: elements. Priority: media:content, media:group, item, channel
       
  4521 
       
  4522 						// CAPTIONS
       
  4523 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
       
  4524 						{
  5151 						{
  4525 							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
  5152 							$url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
  4526 							{
       
  4527 								$caption_type = null;
       
  4528 								$caption_lang = null;
       
  4529 								$caption_startTime = null;
       
  4530 								$caption_endTime = null;
       
  4531 								$caption_text = null;
       
  4532 								if (isset($caption['attribs']['']['type']))
       
  4533 								{
       
  4534 									$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4535 								}
       
  4536 								if (isset($caption['attribs']['']['lang']))
       
  4537 								{
       
  4538 									$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4539 								}
       
  4540 								if (isset($caption['attribs']['']['start']))
       
  4541 								{
       
  4542 									$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4543 								}
       
  4544 								if (isset($caption['attribs']['']['end']))
       
  4545 								{
       
  4546 									$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4547 								}
       
  4548 								if (isset($caption['data']))
       
  4549 								{
       
  4550 									$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4551 								}
       
  4552 								$captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
       
  4553 							}
       
  4554 							if (is_array($captions))
       
  4555 							{
       
  4556 								$captions = array_values(SimplePie_Misc::array_unique($captions));
       
  4557 							}
       
  4558 						}
  5153 						}
  4559 						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
       
  4560 						{
       
  4561 							foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
       
  4562 							{
       
  4563 								$caption_type = null;
       
  4564 								$caption_lang = null;
       
  4565 								$caption_startTime = null;
       
  4566 								$caption_endTime = null;
       
  4567 								$caption_text = null;
       
  4568 								if (isset($caption['attribs']['']['type']))
       
  4569 								{
       
  4570 									$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4571 								}
       
  4572 								if (isset($caption['attribs']['']['lang']))
       
  4573 								{
       
  4574 									$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4575 								}
       
  4576 								if (isset($caption['attribs']['']['start']))
       
  4577 								{
       
  4578 									$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4579 								}
       
  4580 								if (isset($caption['attribs']['']['end']))
       
  4581 								{
       
  4582 									$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4583 								}
       
  4584 								if (isset($caption['data']))
       
  4585 								{
       
  4586 									$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4587 								}
       
  4588 								$captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
       
  4589 							}
       
  4590 							if (is_array($captions))
       
  4591 							{
       
  4592 								$captions = array_values(SimplePie_Misc::array_unique($captions));
       
  4593 							}
       
  4594 						}
       
  4595 						else
       
  4596 						{
       
  4597 							$captions = $captions_parent;
       
  4598 						}
       
  4599 
       
  4600 						// CATEGORIES
       
  4601 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
       
  4602 						{
       
  4603 							foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
       
  4604 							{
       
  4605 								$term = null;
       
  4606 								$scheme = null;
       
  4607 								$label = null;
       
  4608 								if (isset($category['data']))
       
  4609 								{
       
  4610 									$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4611 								}
       
  4612 								if (isset($category['attribs']['']['scheme']))
       
  4613 								{
       
  4614 									$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4615 								}
       
  4616 								else
       
  4617 								{
       
  4618 									$scheme = 'http://search.yahoo.com/mrss/category_schema';
       
  4619 								}
       
  4620 								if (isset($category['attribs']['']['label']))
       
  4621 								{
       
  4622 									$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4623 								}
       
  4624 								$categories[] =& new $this->feed->category_class($term, $scheme, $label);
       
  4625 							}
       
  4626 						}
       
  4627 						if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
       
  4628 						{
       
  4629 							foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
       
  4630 							{
       
  4631 								$term = null;
       
  4632 								$scheme = null;
       
  4633 								$label = null;
       
  4634 								if (isset($category['data']))
       
  4635 								{
       
  4636 									$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4637 								}
       
  4638 								if (isset($category['attribs']['']['scheme']))
       
  4639 								{
       
  4640 									$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4641 								}
       
  4642 								else
       
  4643 								{
       
  4644 									$scheme = 'http://search.yahoo.com/mrss/category_schema';
       
  4645 								}
       
  4646 								if (isset($category['attribs']['']['label']))
       
  4647 								{
       
  4648 									$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4649 								}
       
  4650 								$categories[] =& new $this->feed->category_class($term, $scheme, $label);
       
  4651 							}
       
  4652 						}
       
  4653 						if (is_array($categories) && is_array($categories_parent))
       
  4654 						{
       
  4655 							$categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent)));
       
  4656 						}
       
  4657 						elseif (is_array($categories))
       
  4658 						{
       
  4659 							$categories = array_values(SimplePie_Misc::array_unique($categories));
       
  4660 						}
       
  4661 						elseif (is_array($categories_parent))
       
  4662 						{
       
  4663 							$categories = array_values(SimplePie_Misc::array_unique($categories_parent));
       
  4664 						}
       
  4665 
       
  4666 						// COPYRIGHTS
       
  4667 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
       
  4668 						{
       
  4669 							$copyright_url = null;
       
  4670 							$copyright_label = null;
       
  4671 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
       
  4672 							{
       
  4673 								$copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4674 							}
       
  4675 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
       
  4676 							{
       
  4677 								$copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4678 							}
       
  4679 							$copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
       
  4680 						}
       
  4681 						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
       
  4682 						{
       
  4683 							$copyright_url = null;
       
  4684 							$copyright_label = null;
       
  4685 							if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
       
  4686 							{
       
  4687 								$copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4688 							}
       
  4689 							if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
       
  4690 							{
       
  4691 								$copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4692 							}
       
  4693 							$copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
       
  4694 						}
       
  4695 						else
       
  4696 						{
       
  4697 							$copyrights = $copyrights_parent;
       
  4698 						}
       
  4699 
       
  4700 						// CREDITS
       
  4701 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
       
  4702 						{
       
  4703 							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
       
  4704 							{
       
  4705 								$credit_role = null;
       
  4706 								$credit_scheme = null;
       
  4707 								$credit_name = null;
       
  4708 								if (isset($credit['attribs']['']['role']))
       
  4709 								{
       
  4710 									$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4711 								}
       
  4712 								if (isset($credit['attribs']['']['scheme']))
       
  4713 								{
       
  4714 									$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4715 								}
       
  4716 								else
       
  4717 								{
       
  4718 									$credit_scheme = 'urn:ebu';
       
  4719 								}
       
  4720 								if (isset($credit['data']))
       
  4721 								{
       
  4722 									$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4723 								}
       
  4724 								$credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
       
  4725 							}
       
  4726 							if (is_array($credits))
       
  4727 							{
       
  4728 								$credits = array_values(SimplePie_Misc::array_unique($credits));
       
  4729 							}
       
  4730 						}
       
  4731 						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
       
  4732 						{
       
  4733 							foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
       
  4734 							{
       
  4735 								$credit_role = null;
       
  4736 								$credit_scheme = null;
       
  4737 								$credit_name = null;
       
  4738 								if (isset($credit['attribs']['']['role']))
       
  4739 								{
       
  4740 									$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4741 								}
       
  4742 								if (isset($credit['attribs']['']['scheme']))
       
  4743 								{
       
  4744 									$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4745 								}
       
  4746 								else
       
  4747 								{
       
  4748 									$credit_scheme = 'urn:ebu';
       
  4749 								}
       
  4750 								if (isset($credit['data']))
       
  4751 								{
       
  4752 									$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4753 								}
       
  4754 								$credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
       
  4755 							}
       
  4756 							if (is_array($credits))
       
  4757 							{
       
  4758 								$credits = array_values(SimplePie_Misc::array_unique($credits));
       
  4759 							}
       
  4760 						}
       
  4761 						else
       
  4762 						{
       
  4763 							$credits = $credits_parent;
       
  4764 						}
       
  4765 
       
  4766 						// DESCRIPTION
       
  4767 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
       
  4768 						{
       
  4769 							$description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4770 						}
       
  4771 						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
       
  4772 						{
       
  4773 							$description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4774 						}
       
  4775 						else
       
  4776 						{
       
  4777 							$description = $description_parent;
       
  4778 						}
       
  4779 
       
  4780 						// HASHES
       
  4781 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
       
  4782 						{
       
  4783 							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
       
  4784 							{
       
  4785 								$value = null;
       
  4786 								$algo = null;
       
  4787 								if (isset($hash['data']))
       
  4788 								{
       
  4789 									$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4790 								}
       
  4791 								if (isset($hash['attribs']['']['algo']))
       
  4792 								{
       
  4793 									$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4794 								}
       
  4795 								else
       
  4796 								{
       
  4797 									$algo = 'md5';
       
  4798 								}
       
  4799 								$hashes[] = $algo.':'.$value;
       
  4800 							}
       
  4801 							if (is_array($hashes))
       
  4802 							{
       
  4803 								$hashes = array_values(SimplePie_Misc::array_unique($hashes));
       
  4804 							}
       
  4805 						}
       
  4806 						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
       
  4807 						{
       
  4808 							foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
       
  4809 							{
       
  4810 								$value = null;
       
  4811 								$algo = null;
       
  4812 								if (isset($hash['data']))
       
  4813 								{
       
  4814 									$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4815 								}
       
  4816 								if (isset($hash['attribs']['']['algo']))
       
  4817 								{
       
  4818 									$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4819 								}
       
  4820 								else
       
  4821 								{
       
  4822 									$algo = 'md5';
       
  4823 								}
       
  4824 								$hashes[] = $algo.':'.$value;
       
  4825 							}
       
  4826 							if (is_array($hashes))
       
  4827 							{
       
  4828 								$hashes = array_values(SimplePie_Misc::array_unique($hashes));
       
  4829 							}
       
  4830 						}
       
  4831 						else
       
  4832 						{
       
  4833 							$hashes = $hashes_parent;
       
  4834 						}
       
  4835 
       
  4836 						// KEYWORDS
       
  4837 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
       
  4838 						{
       
  4839 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
       
  4840 							{
       
  4841 								$temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
       
  4842 								foreach ($temp as $word)
       
  4843 								{
       
  4844 									$keywords[] = trim($word);
       
  4845 								}
       
  4846 								unset($temp);
       
  4847 							}
       
  4848 							if (is_array($keywords))
       
  4849 							{
       
  4850 								$keywords = array_values(SimplePie_Misc::array_unique($keywords));
       
  4851 							}
       
  4852 						}
       
  4853 						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
       
  4854 						{
       
  4855 							if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
       
  4856 							{
       
  4857 								$temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
       
  4858 								foreach ($temp as $word)
       
  4859 								{
       
  4860 									$keywords[] = trim($word);
       
  4861 								}
       
  4862 								unset($temp);
       
  4863 							}
       
  4864 							if (is_array($keywords))
       
  4865 							{
       
  4866 								$keywords = array_values(SimplePie_Misc::array_unique($keywords));
       
  4867 							}
       
  4868 						}
       
  4869 						else
       
  4870 						{
       
  4871 							$keywords = $keywords_parent;
       
  4872 						}
       
  4873 
       
  4874 						// PLAYER
       
  4875 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
       
  4876 						{
       
  4877 							$player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
       
  4878 						}
       
  4879 						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
       
  4880 						{
       
  4881 							$player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
       
  4882 						}
       
  4883 						else
       
  4884 						{
       
  4885 							$player = $player_parent;
       
  4886 						}
       
  4887 
       
  4888 						// RATINGS
       
  4889 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
       
  4890 						{
       
  4891 							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
       
  4892 							{
       
  4893 								$rating_scheme = null;
       
  4894 								$rating_value = null;
       
  4895 								if (isset($rating['attribs']['']['scheme']))
       
  4896 								{
       
  4897 									$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4898 								}
       
  4899 								else
       
  4900 								{
       
  4901 									$rating_scheme = 'urn:simple';
       
  4902 								}
       
  4903 								if (isset($rating['data']))
       
  4904 								{
       
  4905 									$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4906 								}
       
  4907 								$ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
       
  4908 							}
       
  4909 							if (is_array($ratings))
       
  4910 							{
       
  4911 								$ratings = array_values(SimplePie_Misc::array_unique($ratings));
       
  4912 							}
       
  4913 						}
       
  4914 						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
       
  4915 						{
       
  4916 							foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
       
  4917 							{
       
  4918 								$rating_scheme = null;
       
  4919 								$rating_value = null;
       
  4920 								if (isset($rating['attribs']['']['scheme']))
       
  4921 								{
       
  4922 									$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4923 								}
       
  4924 								else
       
  4925 								{
       
  4926 									$rating_scheme = 'urn:simple';
       
  4927 								}
       
  4928 								if (isset($rating['data']))
       
  4929 								{
       
  4930 									$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4931 								}
       
  4932 								$ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
       
  4933 							}
       
  4934 							if (is_array($ratings))
       
  4935 							{
       
  4936 								$ratings = array_values(SimplePie_Misc::array_unique($ratings));
       
  4937 							}
       
  4938 						}
       
  4939 						else
       
  4940 						{
       
  4941 							$ratings = $ratings_parent;
       
  4942 						}
       
  4943 
       
  4944 						// RESTRICTIONS
       
  4945 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
       
  4946 						{
       
  4947 							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
       
  4948 							{
       
  4949 								$restriction_relationship = null;
       
  4950 								$restriction_type = null;
       
  4951 								$restriction_value = null;
       
  4952 								if (isset($restriction['attribs']['']['relationship']))
       
  4953 								{
       
  4954 									$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4955 								}
       
  4956 								if (isset($restriction['attribs']['']['type']))
       
  4957 								{
       
  4958 									$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4959 								}
       
  4960 								if (isset($restriction['data']))
       
  4961 								{
       
  4962 									$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4963 								}
       
  4964 								$restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
       
  4965 							}
       
  4966 							if (is_array($restrictions))
       
  4967 							{
       
  4968 								$restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
       
  4969 							}
       
  4970 						}
       
  4971 						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
       
  4972 						{
       
  4973 							foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
       
  4974 							{
       
  4975 								$restriction_relationship = null;
       
  4976 								$restriction_type = null;
       
  4977 								$restriction_value = null;
       
  4978 								if (isset($restriction['attribs']['']['relationship']))
       
  4979 								{
       
  4980 									$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4981 								}
       
  4982 								if (isset($restriction['attribs']['']['type']))
       
  4983 								{
       
  4984 									$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4985 								}
       
  4986 								if (isset($restriction['data']))
       
  4987 								{
       
  4988 									$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  4989 								}
       
  4990 								$restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
       
  4991 							}
       
  4992 							if (is_array($restrictions))
       
  4993 							{
       
  4994 								$restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
       
  4995 							}
       
  4996 						}
       
  4997 						else
       
  4998 						{
       
  4999 							$restrictions = $restrictions_parent;
       
  5000 						}
       
  5001 
       
  5002 						// THUMBNAILS
       
  5003 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
       
  5004 						{
       
  5005 							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
       
  5006 							{
       
  5007 								$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
       
  5008 							}
       
  5009 							if (is_array($thumbnails))
       
  5010 							{
       
  5011 								$thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
       
  5012 							}
       
  5013 						}
       
  5014 						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
       
  5015 						{
       
  5016 							foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
       
  5017 							{
       
  5018 								$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
       
  5019 							}
       
  5020 							if (is_array($thumbnails))
       
  5021 							{
       
  5022 								$thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
       
  5023 							}
       
  5024 						}
       
  5025 						else
       
  5026 						{
       
  5027 							$thumbnails = $thumbnails_parent;
       
  5028 						}
       
  5029 
       
  5030 						// TITLES
       
  5031 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
       
  5032 						{
       
  5033 							$title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  5034 						}
       
  5035 						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
       
  5036 						{
       
  5037 							$title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  5038 						}
       
  5039 						else
       
  5040 						{
       
  5041 							$title = $title_parent;
       
  5042 						}
       
  5043 
       
  5044 						$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);
       
  5045 					}
       
  5046 				}
       
  5047 			}
       
  5048 
       
  5049 			// If we have standalone media:content tags, loop through them.
       
  5050 			if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
       
  5051 			{
       
  5052 				foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
       
  5053 				{
       
  5054 					if (isset($content['attribs']['']['url']))
       
  5055 					{
       
  5056 						// Attributes
       
  5057 						$bitrate = null;
       
  5058 						$channels = null;
       
  5059 						$duration = null;
       
  5060 						$expression = null;
       
  5061 						$framerate = null;
       
  5062 						$height = null;
       
  5063 						$javascript = null;
       
  5064 						$lang = null;
       
  5065 						$length = null;
       
  5066 						$medium = null;
       
  5067 						$samplingrate = null;
       
  5068 						$type = null;
       
  5069 						$url = null;
       
  5070 						$width = null;
       
  5071 
       
  5072 						// Elements
       
  5073 						$captions = null;
       
  5074 						$categories = null;
       
  5075 						$copyrights = null;
       
  5076 						$credits = null;
       
  5077 						$description = null;
       
  5078 						$hashes = null;
       
  5079 						$keywords = null;
       
  5080 						$player = null;
       
  5081 						$ratings = null;
       
  5082 						$restrictions = null;
       
  5083 						$thumbnails = null;
       
  5084 						$title = null;
       
  5085 
       
  5086 						// Start checking the attributes of media:content
       
  5087 						if (isset($content['attribs']['']['bitrate']))
       
  5088 						{
       
  5089 							$bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  5090 						}
       
  5091 						if (isset($content['attribs']['']['channels']))
       
  5092 						{
       
  5093 							$channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  5094 						}
       
  5095 						if (isset($content['attribs']['']['duration']))
       
  5096 						{
       
  5097 							$duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  5098 						}
       
  5099 						else
       
  5100 						{
       
  5101 							$duration = $duration_parent;
       
  5102 						}
       
  5103 						if (isset($content['attribs']['']['expression']))
       
  5104 						{
       
  5105 							$expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  5106 						}
       
  5107 						if (isset($content['attribs']['']['framerate']))
       
  5108 						{
       
  5109 							$framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  5110 						}
       
  5111 						if (isset($content['attribs']['']['height']))
       
  5112 						{
       
  5113 							$height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  5114 						}
       
  5115 						if (isset($content['attribs']['']['lang']))
       
  5116 						{
       
  5117 							$lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  5118 						}
       
  5119 						if (isset($content['attribs']['']['fileSize']))
       
  5120 						{
       
  5121 							$length = ceil($content['attribs']['']['fileSize']);
       
  5122 						}
       
  5123 						if (isset($content['attribs']['']['medium']))
       
  5124 						{
       
  5125 							$medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  5126 						}
       
  5127 						if (isset($content['attribs']['']['samplingrate']))
       
  5128 						{
       
  5129 							$samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  5130 						}
       
  5131 						if (isset($content['attribs']['']['type']))
       
  5132 						{
       
  5133 							$type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  5134 						}
       
  5135 						if (isset($content['attribs']['']['width']))
       
  5136 						{
       
  5137 							$width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
       
  5138 						}
       
  5139 						$url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
       
  5140 
       
  5141 						// Checking the other optional media: elements. Priority: media:content, media:group, item, channel
  5154 						// Checking the other optional media: elements. Priority: media:content, media:group, item, channel
  5142 
  5155 
  5143 						// CAPTIONS
  5156 						// CAPTIONS
  5144 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
  5157 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
  5145 						{
  5158 						{
  5577 	{
  5590 	{
  5578 		if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
  5591 		if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
  5579 		{
  5592 		{
  5580 			return (float) $return[0]['data'];
  5593 			return (float) $return[0]['data'];
  5581 		}
  5594 		}
  5582 		elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
  5595 		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))
  5583 		{
  5596 		{
  5584 			return (float) $match[1];
  5597 			return (float) $match[1];
  5585 		}
  5598 		}
  5586 		else
  5599 		else
  5587 		{
  5600 		{
  5597 		}
  5610 		}
  5598 		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
  5611 		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
  5599 		{
  5612 		{
  5600 			return (float) $return[0]['data'];
  5613 			return (float) $return[0]['data'];
  5601 		}
  5614 		}
  5602 		elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
  5615 		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))
  5603 		{
  5616 		{
  5604 			return (float) $match[2];
  5617 			return (float) $match[2];
  5605 		}
  5618 		}
  5606 		else
  5619 		else
  5607 		{
  5620 		{
  6220 	{
  6233 	{
  6221 		if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
  6234 		if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
  6222 		{
  6235 		{
  6223 			return (float) $return[0]['data'];
  6236 			return (float) $return[0]['data'];
  6224 		}
  6237 		}
  6225 		elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
  6238 		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))
  6226 		{
  6239 		{
  6227 			return (float) $match[1];
  6240 			return (float) $match[1];
  6228 		}
  6241 		}
  6229 		else
  6242 		else
  6230 		{
  6243 		{
  6240 		}
  6253 		}
  6241 		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
  6254 		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
  6242 		{
  6255 		{
  6243 			return (float) $return[0]['data'];
  6256 			return (float) $return[0]['data'];
  6244 		}
  6257 		}
  6245 		elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
  6258 		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))
  6246 		{
  6259 		{
  6247 			return (float) $match[2];
  6260 			return (float) $match[2];
  6248 		}
  6261 		}
  6249 		else
  6262 		else
  6250 		{
  6263 		{
  7724 			}
  7737 			}
  7725 			else
  7738 			else
  7726 			{
  7739 			{
  7727 				$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
  7740 				$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
  7728 				$url_parts = parse_url($url);
  7741 				$url_parts = parse_url($url);
       
  7742 				$socket_host = $url_parts['host'];
  7729 				if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https')
  7743 				if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https')
  7730 				{
  7744 				{
  7731 					$url_parts['host'] = "ssl://$url_parts[host]";
  7745 					$socket_host = "ssl://$url_parts[host]";
  7732 					$url_parts['port'] = 443;
  7746 					$url_parts['port'] = 443;
  7733 				}
  7747 				}
  7734 				if (!isset($url_parts['port']))
  7748 				if (!isset($url_parts['port']))
  7735 				{
  7749 				{
  7736 					$url_parts['port'] = 80;
  7750 					$url_parts['port'] = 80;
  7737 				}
  7751 				}
  7738 				$fp = @fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout);
  7752 				$fp = @fsockopen($socket_host, $url_parts['port'], $errno, $errstr, $timeout);
  7739 				if (!$fp)
  7753 				if (!$fp)
  7740 				{
  7754 				{
  7741 					$this->error = 'fsockopen error: ' . $errstr;
  7755 					$this->error = 'fsockopen error: ' . $errstr;
  7742 					$this->success = false;
  7756 					$this->success = false;
  7743 				}
  7757 				}
  8479 					return false;
  8493 					return false;
  8480 				}
  8494 				}
  8481 
  8495 
  8482 				// Get the length of the extra field
  8496 				// Get the length of the extra field
  8483 				$len = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
  8497 				$len = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
  8484 				$position += 2;
  8498 				$this->position += 2;
  8485 
  8499 
  8486 				// Check the length of the string is still valid
  8500 				// Check the length of the string is still valid
  8487 				$this->min_compressed_size += $len + 4;
  8501 				$this->min_compressed_size += $len + 4;
  8488 				if ($this->compressed_size >= $this->min_compressed_size)
  8502 				if ($this->compressed_size >= $this->min_compressed_size)
  8489 				{
  8503 				{
  9231 					break;
  9245 					break;
  9232 				default:
  9246 				default:
  9233 					$note = 'Unknown Error';
  9247 					$note = 'Unknown Error';
  9234 					break;
  9248 					break;
  9235 			}
  9249 			}
  9236 			error_log("$note: $message in $file on line $line", 0);
  9250 
  9237 		}
  9251 			$log_error = true;
       
  9252 			if (!function_exists('error_log'))
       
  9253 			{
       
  9254 				$log_error = false;
       
  9255 			}
       
  9256 
       
  9257 			$log_file = @ini_get('error_log');
       
  9258 			if (!empty($log_file) && ('syslog' != $log_file) && !@is_writable($log_file))
       
  9259 			{
       
  9260 				$log_error = false;
       
  9261 			}
       
  9262 
       
  9263 			if ($log_error)
       
  9264 			{
       
  9265 				@error_log("$note: $message in $file on line $line", 0);
       
  9266 			}
       
  9267 		}
       
  9268 
  9238 		return $message;
  9269 		return $message;
  9239 	}
  9270 	}
  9240 
  9271 
  9241 	/**
  9272 	/**
  9242 	 * If a file has been cached, retrieve and display it.
  9273 	 * If a file has been cached, retrieve and display it.
  9429 		if ($input === 'windows-1252' && $output === 'UTF-8')
  9460 		if ($input === 'windows-1252' && $output === 'UTF-8')
  9430 		{
  9461 		{
  9431 			return SimplePie_Misc::windows_1252_to_utf8($data);
  9462 			return SimplePie_Misc::windows_1252_to_utf8($data);
  9432 		}
  9463 		}
  9433 		// This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported).
  9464 		// This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported).
  9434 		elseif (function_exists('mb_convert_encoding') && @mb_convert_encoding("\x80", 'UTF-16BE', $input) !== "\x00\x80" && ($return = @mb_convert_encoding($data, $output, $input)))
  9465 		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)))
  9435 		{
  9466 		{
  9436 			return $return;
  9467 			return $return;
  9437 		}
  9468 		}
  9438 		// This is last, as behaviour of this varies with OS userland and PHP version
  9469 		// This is last, as behaviour of this varies with OS userland and PHP version
  9439 		elseif (function_exists('iconv') && ($return = @iconv($input, $output, $data)))
  9470 		elseif (function_exists('iconv') && ($return = @iconv($input, $output, $data)))
  9445 		{
  9476 		{
  9446 			return false;
  9477 			return false;
  9447 		}
  9478 		}
  9448 	}
  9479 	}
  9449 
  9480 
       
  9481 	/**
       
  9482 	 * Normalize an encoding name
       
  9483 	 *
       
  9484 	 * This is automatically generated by create.php
       
  9485 	 *
       
  9486 	 * To generate it, run `php create.php` on the command line, and copy the
       
  9487 	 * output to replace this function.
       
  9488 	 *
       
  9489 	 * @param string $charset Character set to standardise
       
  9490 	 * @return string Standardised name
       
  9491 	 */
  9450 	function encoding($charset)
  9492 	function encoding($charset)
  9451 	{
  9493 	{
  9452 		// Normalization from UTS #22
  9494 		// Normalization from UTS #22
  9453 		switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset)))
  9495 		switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset)))
  9454 		{
  9496 		{
  9478 			case 'isoir89':
  9520 			case 'isoir89':
  9479 				return 'ASMO_449';
  9521 				return 'ASMO_449';
  9480 
  9522 
  9481 			case 'big5':
  9523 			case 'big5':
  9482 			case 'csbig5':
  9524 			case 'csbig5':
  9483 			case 'xxbig5':
       
  9484 				return 'Big5';
  9525 				return 'Big5';
  9485 
  9526 
  9486 			case 'big5hkscs':
  9527 			case 'big5hkscs':
  9487 				return 'Big5-HKSCS';
  9528 				return 'Big5-HKSCS';
  9488 
  9529 
  9634 			case 'es2':
  9675 			case 'es2':
  9635 			case 'iso646es2':
  9676 			case 'iso646es2':
  9636 			case 'isoir85':
  9677 			case 'isoir85':
  9637 				return 'ES2';
  9678 				return 'ES2';
  9638 
  9679 
       
  9680 			case 'cseucpkdfmtjapanese':
       
  9681 			case 'eucjp':
       
  9682 			case 'extendedunixcodepackedformatforjapanese':
       
  9683 				return 'EUC-JP';
       
  9684 
  9639 			case 'cseucfixwidjapanese':
  9685 			case 'cseucfixwidjapanese':
  9640 			case 'extendedunixcodefixedwidthforjapanese':
  9686 			case 'extendedunixcodefixedwidthforjapanese':
  9641 				return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
  9687 				return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
  9642 
       
  9643 			case 'cseucpkdfmtjapanese':
       
  9644 			case 'eucjp':
       
  9645 			case 'extendedunixcodepackedformatforjapanese':
       
  9646 				return 'Extended_UNIX_Code_Packed_Format_for_Japanese';
       
  9647 
  9688 
  9648 			case 'gb18030':
  9689 			case 'gb18030':
  9649 				return 'GB18030';
  9690 				return 'GB18030';
  9650 
  9691 
  9651 			case 'chinese':
  9692 			case 'chinese':
  9720 
  9761 
  9721 			case 'csibmthai':
  9762 			case 'csibmthai':
  9722 			case 'ibmthai':
  9763 			case 'ibmthai':
  9723 				return 'IBM-Thai';
  9764 				return 'IBM-Thai';
  9724 
  9765 
  9725 			case 'ccsid858':
       
  9726 			case 'cp858':
       
  9727 			case 'ibm858':
       
  9728 			case 'pcmultilingual850euro':
       
  9729 				return 'IBM00858';
       
  9730 
       
  9731 			case 'ccsid924':
       
  9732 			case 'cp924':
       
  9733 			case 'ebcdiclatin9euro':
       
  9734 			case 'ibm924':
       
  9735 				return 'IBM00924';
       
  9736 
       
  9737 			case 'ccsid1140':
       
  9738 			case 'cp1140':
       
  9739 			case 'ebcdicus37euro':
       
  9740 			case 'ibm1140':
       
  9741 				return 'IBM01140';
       
  9742 
       
  9743 			case 'ccsid1141':
       
  9744 			case 'cp1141':
       
  9745 			case 'ebcdicde273euro':
       
  9746 			case 'ibm1141':
       
  9747 				return 'IBM01141';
       
  9748 
       
  9749 			case 'ccsid1142':
       
  9750 			case 'cp1142':
       
  9751 			case 'ebcdicdk277euro':
       
  9752 			case 'ebcdicno277euro':
       
  9753 			case 'ibm1142':
       
  9754 				return 'IBM01142';
       
  9755 
       
  9756 			case 'ccsid1143':
       
  9757 			case 'cp1143':
       
  9758 			case 'ebcdicfi278euro':
       
  9759 			case 'ebcdicse278euro':
       
  9760 			case 'ibm1143':
       
  9761 				return 'IBM01143';
       
  9762 
       
  9763 			case 'ccsid1144':
       
  9764 			case 'cp1144':
       
  9765 			case 'ebcdicit280euro':
       
  9766 			case 'ibm1144':
       
  9767 				return 'IBM01144';
       
  9768 
       
  9769 			case 'ccsid1145':
       
  9770 			case 'cp1145':
       
  9771 			case 'ebcdices284euro':
       
  9772 			case 'ibm1145':
       
  9773 				return 'IBM01145';
       
  9774 
       
  9775 			case 'ccsid1146':
       
  9776 			case 'cp1146':
       
  9777 			case 'ebcdicgb285euro':
       
  9778 			case 'ibm1146':
       
  9779 				return 'IBM01146';
       
  9780 
       
  9781 			case 'ccsid1147':
       
  9782 			case 'cp1147':
       
  9783 			case 'ebcdicfr297euro':
       
  9784 			case 'ibm1147':
       
  9785 				return 'IBM01147';
       
  9786 
       
  9787 			case 'ccsid1148':
       
  9788 			case 'cp1148':
       
  9789 			case 'ebcdicinternational500euro':
       
  9790 			case 'ibm1148':
       
  9791 				return 'IBM01148';
       
  9792 
       
  9793 			case 'ccsid1149':
       
  9794 			case 'cp1149':
       
  9795 			case 'ebcdicis871euro':
       
  9796 			case 'ibm1149':
       
  9797 				return 'IBM01149';
       
  9798 
       
  9799 			case 'cp37':
  9766 			case 'cp37':
  9800 			case 'csibm37':
  9767 			case 'csibm37':
  9801 			case 'ebcdiccpca':
  9768 			case 'ebcdiccpca':
  9802 			case 'ebcdiccpnl':
  9769 			case 'ebcdiccpnl':
  9803 			case 'ebcdiccpus':
  9770 			case 'ebcdiccpus':
  9941 			case 'cp857':
  9908 			case 'cp857':
  9942 			case 'csibm857':
  9909 			case 'csibm857':
  9943 			case 'ibm857':
  9910 			case 'ibm857':
  9944 				return 'IBM857';
  9911 				return 'IBM857';
  9945 
  9912 
       
  9913 			case 'ccsid858':
       
  9914 			case 'cp858':
       
  9915 			case 'ibm858':
       
  9916 			case 'pcmultilingual850euro':
       
  9917 				return 'IBM00858';
       
  9918 
  9946 			case '860':
  9919 			case '860':
  9947 			case 'cp860':
  9920 			case 'cp860':
  9948 			case 'csibm860':
  9921 			case 'csibm860':
  9949 			case 'ibm860':
  9922 			case 'ibm860':
  9950 				return 'IBM860';
  9923 				return 'IBM860';
 10043 			case 'csibm918':
 10016 			case 'csibm918':
 10044 			case 'ebcdiccpar2':
 10017 			case 'ebcdiccpar2':
 10045 			case 'ibm918':
 10018 			case 'ibm918':
 10046 				return 'IBM918';
 10019 				return 'IBM918';
 10047 
 10020 
       
 10021 			case 'ccsid924':
       
 10022 			case 'cp924':
       
 10023 			case 'ebcdiclatin9euro':
       
 10024 			case 'ibm924':
       
 10025 				return 'IBM00924';
       
 10026 
 10048 			case 'cp1026':
 10027 			case 'cp1026':
 10049 			case 'csibm1026':
 10028 			case 'csibm1026':
 10050 			case 'ibm1026':
 10029 			case 'ibm1026':
 10051 				return 'IBM1026';
 10030 				return 'IBM1026';
 10052 
 10031 
 10053 			case 'ibm1047':
 10032 			case 'ibm1047':
 10054 				return 'IBM1047';
 10033 				return 'IBM1047';
       
 10034 
       
 10035 			case 'ccsid1140':
       
 10036 			case 'cp1140':
       
 10037 			case 'ebcdicus37euro':
       
 10038 			case 'ibm1140':
       
 10039 				return 'IBM01140';
       
 10040 
       
 10041 			case 'ccsid1141':
       
 10042 			case 'cp1141':
       
 10043 			case 'ebcdicde273euro':
       
 10044 			case 'ibm1141':
       
 10045 				return 'IBM01141';
       
 10046 
       
 10047 			case 'ccsid1142':
       
 10048 			case 'cp1142':
       
 10049 			case 'ebcdicdk277euro':
       
 10050 			case 'ebcdicno277euro':
       
 10051 			case 'ibm1142':
       
 10052 				return 'IBM01142';
       
 10053 
       
 10054 			case 'ccsid1143':
       
 10055 			case 'cp1143':
       
 10056 			case 'ebcdicfi278euro':
       
 10057 			case 'ebcdicse278euro':
       
 10058 			case 'ibm1143':
       
 10059 				return 'IBM01143';
       
 10060 
       
 10061 			case 'ccsid1144':
       
 10062 			case 'cp1144':
       
 10063 			case 'ebcdicit280euro':
       
 10064 			case 'ibm1144':
       
 10065 				return 'IBM01144';
       
 10066 
       
 10067 			case 'ccsid1145':
       
 10068 			case 'cp1145':
       
 10069 			case 'ebcdices284euro':
       
 10070 			case 'ibm1145':
       
 10071 				return 'IBM01145';
       
 10072 
       
 10073 			case 'ccsid1146':
       
 10074 			case 'cp1146':
       
 10075 			case 'ebcdicgb285euro':
       
 10076 			case 'ibm1146':
       
 10077 				return 'IBM01146';
       
 10078 
       
 10079 			case 'ccsid1147':
       
 10080 			case 'cp1147':
       
 10081 			case 'ebcdicfr297euro':
       
 10082 			case 'ibm1147':
       
 10083 				return 'IBM01147';
       
 10084 
       
 10085 			case 'ccsid1148':
       
 10086 			case 'cp1148':
       
 10087 			case 'ebcdicinternational500euro':
       
 10088 			case 'ibm1148':
       
 10089 				return 'IBM01148';
       
 10090 
       
 10091 			case 'ccsid1149':
       
 10092 			case 'cp1149':
       
 10093 			case 'ebcdicis871euro':
       
 10094 			case 'ibm1149':
       
 10095 				return 'IBM01149';
 10055 
 10096 
 10056 			case 'csiso143iecp271':
 10097 			case 'csiso143iecp271':
 10057 			case 'iecp271':
 10098 			case 'iecp271':
 10058 			case 'isoir143':
 10099 			case 'isoir143':
 10059 				return 'IEC_P27-1';
 10100 				return 'IEC_P27-1';
 10592 			case 'iso646se2':
 10633 			case 'iso646se2':
 10593 			case 'isoir11':
 10634 			case 'isoir11':
 10594 			case 'se2':
 10635 			case 'se2':
 10595 			case 'sen850200c':
 10636 			case 'sen850200c':
 10596 				return 'SEN_850200_C';
 10637 				return 'SEN_850200_C';
 10597 
       
 10598 			case 'csshiftjis':
       
 10599 			case 'mskanji':
       
 10600 			case 'shiftjis':
       
 10601 				return 'Shift_JIS';
       
 10602 
 10638 
 10603 			case 'csiso102t617bit':
 10639 			case 'csiso102t617bit':
 10604 			case 'isoir102':
 10640 			case 'isoir102':
 10605 			case 't617bit':
 10641 			case 't617bit':
 10606 				return 'T.61-7bit';
 10642 				return 'T.61-7bit';
 10696 
 10732 
 10697 			case 'csviscii':
 10733 			case 'csviscii':
 10698 			case 'viscii':
 10734 			case 'viscii':
 10699 				return 'VISCII';
 10735 				return 'VISCII';
 10700 
 10736 
       
 10737 			case 'csshiftjis':
 10701 			case 'cswindows31j':
 10738 			case 'cswindows31j':
       
 10739 			case 'mskanji':
       
 10740 			case 'shiftjis':
 10702 			case 'windows31j':
 10741 			case 'windows31j':
 10703 				return 'Windows-31J';
 10742 				return 'Windows-31J';
 10704 
 10743 
 10705 			case 'iso885911':
 10744 			case 'iso885911':
 10706 			case 'tis620':
 10745 			case 'tis620':
 11356 
 11395 
 11357 function embed_wmedia(width, height, link) {
 11396 function embed_wmedia(width, height, link) {
 11358 	document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
 11397 	document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
 11359 }
 11398 }
 11360 		<?php
 11399 		<?php
       
 11400 	}
       
 11401 
       
 11402 
       
 11403 
       
 11404 	/**
       
 11405 	 * Format debugging information
       
 11406 	 */
       
 11407 	function debug($sp)
       
 11408 	{
       
 11409 		$info = 'SimplePie ' . SIMPLEPIE_VERSION . ' Build ' . SIMPLEPIE_BUILD . "\n";
       
 11410 		$info .= 'PHP ' . PHP_VERSION . "\n";
       
 11411 		if ($sp->error() !== null)
       
 11412 		{
       
 11413 			$info .= 'Error occurred: ' . $sp->error() . "\n";
       
 11414 		}
       
 11415 		else
       
 11416 		{
       
 11417 			$info .= "No error found.\n";
       
 11418 		}
       
 11419 		$info .= "Extensions:\n";
       
 11420 		$extensions = array('pcre', 'curl', 'zlib', 'mbstring', 'iconv', 'xmlreader', 'xml');
       
 11421 		foreach ($extensions as $ext)
       
 11422 		{
       
 11423 			if (extension_loaded($ext))
       
 11424 			{
       
 11425 				$info .= "    $ext loaded\n";
       
 11426 				switch ($ext)
       
 11427 				{
       
 11428 					case 'pcre':
       
 11429 						$info .= '      Version ' . PCRE_VERSION . "\n";
       
 11430 						break;
       
 11431 					case 'curl':
       
 11432 						$version = curl_version();
       
 11433 						$info .= '      Version ' . $version['version'] . "\n";
       
 11434 						break;
       
 11435 					case 'mbstring':
       
 11436 						$info .= '      Overloading: ' . mb_get_info('func_overload') . "\n";
       
 11437 						break;
       
 11438 					case 'iconv':
       
 11439 						$info .= '      Version ' . ICONV_VERSION . "\n";
       
 11440 						break;
       
 11441 					case 'xml':
       
 11442 						$info .= '      Version ' . LIBXML_DOTTED_VERSION . "\n";
       
 11443 						break;
       
 11444 				}
       
 11445 			}
       
 11446 			else
       
 11447 			{
       
 11448 				$info .= "    $ext not loaded\n";
       
 11449 			}
       
 11450 		}
       
 11451 		return $info;
 11361 	}
 11452 	}
 11362 }
 11453 }
 11363 
 11454 
 11364 /**
 11455 /**
 11365  * Decode HTML Entities
 11456  * Decode HTML Entities
 11828 	}
 11919 	}
 11829 
 11920 
 11830 	/**
 11921 	/**
 11831 	 * Replace invalid character with percent encoding
 11922 	 * Replace invalid character with percent encoding
 11832 	 *
 11923 	 *
 11833 	 * @access private
       
 11834 	 * @param string $string Input string
 11924 	 * @param string $string Input string
 11835 	 * @param string $valid_chars Valid characters
 11925 	 * @param string $valid_chars Valid characters
 11836 	 * @param int $case Normalise case
 11926 	 * @param int $case Normalise case
 11837 	 * @return string
 11927 	 * @return string
 11838 	 */
 11928 	 */
 11839 	function replace_invalid_with_pct_encoding($string, $valid_chars, $case = SIMPLEPIE_SAME_CASE)
 11929 	function replace_invalid_with_pct_encoding($string, $valid_chars, $case = SIMPLEPIE_SAME_CASE, $iprivate = false)
 11840 	{
 11930 	{
       
 11931 		// Normalize as many pct-encoded sections as possible
       
 11932 		$string = preg_replace_callback('/(?:%[A-Fa-f0-9]{2})+/', array(&$this, 'remove_iunreserved_percent_encoded'), $string);
       
 11933 
       
 11934 		// Replace invalid percent characters
       
 11935 		$string = preg_replace('/%(?![A-Fa-f0-9]{2})/', '%25', $string);
       
 11936 
       
 11937 		// Add unreserved and % to $valid_chars (the latter is safe because all
       
 11938 		// pct-encoded sections are now valid).
       
 11939 		$valid_chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~%';
       
 11940 
       
 11941 		// Now replace any bytes that aren't allowed with their pct-encoded versions
       
 11942 		$position = 0;
       
 11943 		$strlen = strlen($string);
       
 11944 		while (($position += strspn($string, $valid_chars, $position)) < $strlen)
       
 11945 		{
       
 11946 			$value = ord($string[$position]);
       
 11947 
       
 11948 			// Start position
       
 11949 			$start = $position;
       
 11950 
       
 11951 			// By default we are valid
       
 11952 			$valid = true;
       
 11953 
       
 11954 			// No one byte sequences are valid due to the while.
       
 11955 			// Two byte sequence:
       
 11956 			if (($value & 0xE0) === 0xC0)
       
 11957 			{
       
 11958 				$character = ($value & 0x1F) << 6;
       
 11959 				$length = 2;
       
 11960 				$remaining = 1;
       
 11961 			}
       
 11962 			// Three byte sequence:
       
 11963 			elseif (($value & 0xF0) === 0xE0)
       
 11964 			{
       
 11965 				$character = ($value & 0x0F) << 12;
       
 11966 				$length = 3;
       
 11967 				$remaining = 2;
       
 11968 			}
       
 11969 			// Four byte sequence:
       
 11970 			elseif (($value & 0xF8) === 0xF0)
       
 11971 			{
       
 11972 				$character = ($value & 0x07) << 18;
       
 11973 				$length = 4;
       
 11974 				$remaining = 3;
       
 11975 			}
       
 11976 			// Invalid byte:
       
 11977 			else
       
 11978 			{
       
 11979 				$valid = false;
       
 11980 				$length = 1;
       
 11981 				$remaining = 0;
       
 11982 			}
       
 11983 
       
 11984 			if ($remaining)
       
 11985 			{
       
 11986 				if ($position + $length <= $strlen)
       
 11987 				{
       
 11988 					for ($position++; $remaining; $position++)
       
 11989 					{
       
 11990 						$value = ord($string[$position]);
       
 11991 
       
 11992 						// Check that the byte is valid, then add it to the character:
       
 11993 						if (($value & 0xC0) === 0x80)
       
 11994 						{
       
 11995 							$character |= ($value & 0x3F) << (--$remaining * 6);
       
 11996 						}
       
 11997 						// If it is invalid, count the sequence as invalid and reprocess the current byte:
       
 11998 						else
       
 11999 						{
       
 12000 							$valid = false;
       
 12001 							$position--;
       
 12002 							break;
       
 12003 						}
       
 12004 					}
       
 12005 				}
       
 12006 				else
       
 12007 				{
       
 12008 					$position = $strlen - 1;
       
 12009 					$valid = false;
       
 12010 				}
       
 12011 			}
       
 12012 
       
 12013 			// Percent encode anything invalid or not in ucschar
       
 12014 			if (
       
 12015 				// Invalid sequences
       
 12016 				!$valid
       
 12017 				// Non-shortest form sequences are invalid
       
 12018 				|| $length > 1 && $character <= 0x7F
       
 12019 				|| $length > 2 && $character <= 0x7FF
       
 12020 				|| $length > 3 && $character <= 0xFFFF
       
 12021 				// Outside of range of ucschar codepoints
       
 12022 				// Noncharacters
       
 12023 				|| ($character & 0xFFFE) === 0xFFFE
       
 12024 				|| $character >= 0xFDD0 && $character <= 0xFDEF
       
 12025 				|| (
       
 12026 					// Everything else not in ucschar
       
 12027 					   $character > 0xD7FF && $character < 0xF900
       
 12028 					|| $character < 0xA0
       
 12029 					|| $character > 0xEFFFD
       
 12030 				)
       
 12031 				&& (
       
 12032 					// Everything not in iprivate, if it applies
       
 12033 					   !$iprivate
       
 12034 					|| $character < 0xE000
       
 12035 					|| $character > 0x10FFFD
       
 12036 				)
       
 12037 			)
       
 12038 			{
       
 12039 				// If we were a character, pretend we weren't, but rather an error.
       
 12040 				if ($valid)
       
 12041 					$position--;
       
 12042 
       
 12043 				for ($j = $start; $j <= $position; $j++)
       
 12044 				{
       
 12045 					$string = substr_replace($string, sprintf('%%%02X', ord($string[$j])), $j, 1);
       
 12046 					$j += 2;
       
 12047 					$position += 2;
       
 12048 					$strlen += 2;
       
 12049 				}
       
 12050 			}
       
 12051 		}
       
 12052 
 11841 		// Normalise case
 12053 		// Normalise case
 11842 		if ($case & SIMPLEPIE_LOWERCASE)
 12054 		if ($case & SIMPLEPIE_LOWERCASE)
 11843 		{
 12055 		{
 11844 			$string = strtolower($string);
 12056 			$string = strtolower($string);
 11845 		}
 12057 		}
 11846 		elseif ($case & SIMPLEPIE_UPPERCASE)
 12058 		elseif ($case & SIMPLEPIE_UPPERCASE)
 11847 		{
 12059 		{
 11848 			$string = strtoupper($string);
 12060 			$string = strtoupper($string);
 11849 		}
 12061 		}
 11850 
 12062 
 11851 		// Store position and string length (to avoid constantly recalculating this)
 12063 		return $string;
 11852 		$position = 0;
 12064 	}
 11853 		$strlen = strlen($string);
 12065 
 11854 
 12066 	/**
 11855 		// Loop as long as we have invalid characters, advancing the position to the next invalid character
 12067 	 * Callback function for preg_replace_callback.
 11856 		while (($position += strspn($string, $valid_chars, $position)) < $strlen)
 12068 	 *
 11857 		{
 12069 	 * Removes sequences of percent encoded bytes that represent UTF-8
 11858 			// If we have a % character
 12070 	 * encoded characters in iunreserved
 11859 			if ($string[$position] === '%')
 12071 	 *
 11860 			{
 12072 	 * @access private
 11861 				// If we have a pct-encoded section
 12073 	 * @param array $match PCRE match
 11862 				if ($position + 2 < $strlen && strspn($string, '0123456789ABCDEFabcdef', $position + 1, 2) === 2)
 12074 	 * @return string Replacement
 11863 				{
 12075 	 */
 11864 					// Get the the represented character
 12076 	function remove_iunreserved_percent_encoded($match)
 11865 					$chr = chr(hexdec(substr($string, $position + 1, 2)));
 12077 	{
 11866 
 12078 		// As we just have valid percent encoded sequences we can just explode
 11867 					// If the character is valid, replace the pct-encoded with the actual character while normalising case
 12079 		// and ignore the first member of the returned array (an empty string).
 11868 					if (strpos($valid_chars, $chr) !== false)
 12080 		$bytes = explode('%', $match[0]);
       
 12081 
       
 12082 		// Initialize the new string (this is what will be returned) and that
       
 12083 		// there are no bytes remaining in the current sequence (unsurprising
       
 12084 		// at the first byte!).
       
 12085 		$string = '';
       
 12086 		$remaining = 0;
       
 12087 
       
 12088 		// Loop over each and every byte, and set $value to its value
       
 12089 		for ($i = 1, $len = count($bytes); $i < $len; $i++)
       
 12090 		{
       
 12091 			$value = hexdec($bytes[$i]);
       
 12092 
       
 12093 			// If we're the first byte of sequence:
       
 12094 			if (!$remaining)
       
 12095 			{
       
 12096 				// Start position
       
 12097 				$start = $i;
       
 12098 
       
 12099 				// By default we are valid
       
 12100 				$valid = true;
       
 12101 
       
 12102 				// One byte sequence:
       
 12103 				if ($value <= 0x7F)
       
 12104 				{
       
 12105 					$character = $value;
       
 12106 					$length = 1;
       
 12107 				}
       
 12108 				// Two byte sequence:
       
 12109 				elseif (($value & 0xE0) === 0xC0)
       
 12110 				{
       
 12111 					$character = ($value & 0x1F) << 6;
       
 12112 					$length = 2;
       
 12113 					$remaining = 1;
       
 12114 				}
       
 12115 				// Three byte sequence:
       
 12116 				elseif (($value & 0xF0) === 0xE0)
       
 12117 				{
       
 12118 					$character = ($value & 0x0F) << 12;
       
 12119 					$length = 3;
       
 12120 					$remaining = 2;
       
 12121 				}
       
 12122 				// Four byte sequence:
       
 12123 				elseif (($value & 0xF8) === 0xF0)
       
 12124 				{
       
 12125 					$character = ($value & 0x07) << 18;
       
 12126 					$length = 4;
       
 12127 					$remaining = 3;
       
 12128 				}
       
 12129 				// Invalid byte:
       
 12130 				else
       
 12131 				{
       
 12132 					$valid = false;
       
 12133 					$remaining = 0;
       
 12134 				}
       
 12135 			}
       
 12136 			// Continuation byte:
       
 12137 			else
       
 12138 			{
       
 12139 				// Check that the byte is valid, then add it to the character:
       
 12140 				if (($value & 0xC0) === 0x80)
       
 12141 				{
       
 12142 					$remaining--;
       
 12143 					$character |= ($value & 0x3F) << ($remaining * 6);
       
 12144 				}
       
 12145 				// If it is invalid, count the sequence as invalid and reprocess the current byte as the start of a sequence:
       
 12146 				else
       
 12147 				{
       
 12148 					$valid = false;
       
 12149 					$remaining = 0;
       
 12150 					$i--;
       
 12151 				}
       
 12152 			}
       
 12153 
       
 12154 			// If we've reached the end of the current byte sequence, append it to Unicode::$data
       
 12155 			if (!$remaining)
       
 12156 			{
       
 12157 				// Percent encode anything invalid or not in iunreserved
       
 12158 				if (
       
 12159 					// Invalid sequences
       
 12160 					!$valid
       
 12161 					// Non-shortest form sequences are invalid
       
 12162 					|| $length > 1 && $character <= 0x7F
       
 12163 					|| $length > 2 && $character <= 0x7FF
       
 12164 					|| $length > 3 && $character <= 0xFFFF
       
 12165 					// Outside of range of iunreserved codepoints
       
 12166 					|| $character < 0x2D
       
 12167 					|| $character > 0xEFFFD
       
 12168 					// Noncharacters
       
 12169 					|| ($character & 0xFFFE) === 0xFFFE
       
 12170 					|| $character >= 0xFDD0 && $character <= 0xFDEF
       
 12171 					// Everything else not in iunreserved (this is all BMP)
       
 12172 					|| $character === 0x2F
       
 12173 					|| $character > 0x39 && $character < 0x41
       
 12174 					|| $character > 0x5A && $character < 0x61
       
 12175 					|| $character > 0x7A && $character < 0x7E
       
 12176 					|| $character > 0x7E && $character < 0xA0
       
 12177 					|| $character > 0xD7FF && $character < 0xF900
       
 12178 				)
       
 12179 				{
       
 12180 					for ($j = $start; $j <= $i; $j++)
 11869 					{
 12181 					{
 11870 						if ($case & SIMPLEPIE_LOWERCASE)
 12182 						$string .= '%' . strtoupper($bytes[$j]);
 11871 						{
       
 11872 							$chr = strtolower($chr);
       
 11873 						}
       
 11874 						elseif ($case & SIMPLEPIE_UPPERCASE)
       
 11875 						{
       
 11876 							$chr = strtoupper($chr);
       
 11877 						}
       
 11878 						$string = substr_replace($string, $chr, $position, 3);
       
 11879 						$strlen -= 2;
       
 11880 						$position++;
       
 11881 					}
 12183 					}
 11882 
 12184 				}
 11883 					// Otherwise just normalise the pct-encoded to uppercase
 12185 				else
 11884 					else
 12186 				{
       
 12187 					for ($j = $start; $j <= $i; $j++)
 11885 					{
 12188 					{
 11886 						$string = substr_replace($string, strtoupper(substr($string, $position + 1, 2)), $position + 1, 2);
 12189 						$string .= chr(hexdec($bytes[$j]));
 11887 						$position += 3;
       
 11888 					}
 12190 					}
 11889 				}
 12191 				}
 11890 				// If we don't have a pct-encoded section, just replace the % with its own esccaped form
 12192 			}
 11891 				else
 12193 		}
 11892 				{
 12194 
 11893 					$string = substr_replace($string, '%25', $position, 1);
 12195 		// If we have any bytes left over they are invalid (i.e., we are
 11894 					$strlen += 2;
 12196 		// mid-way through a multi-byte sequence)
 11895 					$position += 3;
 12197 		if ($remaining)
 11896 				}
 12198 		{
 11897 			}
 12199 			for ($j = $start; $j < $len; $j++)
 11898 			// If we have an invalid character, change into its pct-encoded form
 12200 			{
 11899 			else
 12201 				$string .= '%' . strtoupper($bytes[$j]);
 11900 			{
 12202 			}
 11901 				$replacement = sprintf("%%%02X", ord($string[$position]));
 12203 		}
 11902 				$string = str_replace($string[$position], $replacement, $string);
 12204 
 11903 				$strlen = strlen($string);
       
 11904 			}
       
 11905 		}
       
 11906 		return $string;
 12205 		return $string;
 11907 	}
 12206 	}
 11908 
 12207 
 11909 	/**
 12208 	/**
 11910 	 * Check if the object represents a valid IRI
 12209 	 * Check if the object represents a valid IRI
 12028 			$this->valid[__FUNCTION__] = true;
 12327 			$this->valid[__FUNCTION__] = true;
 12029 			return true;
 12328 			return true;
 12030 		}
 12329 		}
 12031 		elseif ($host[0] === '[' && substr($host, -1) === ']')
 12330 		elseif ($host[0] === '[' && substr($host, -1) === ']')
 12032 		{
 12331 		{
 12033 			if (Net_IPv6::checkIPv6(substr($host, 1, -1)))
 12332 			if (SimplePie_Net_IPv6::checkIPv6(substr($host, 1, -1)))
 12034 			{
 12333 			{
 12035 				$this->host = $host;
 12334 				$this->host = $host;
 12036 				$this->valid[__FUNCTION__] = true;
 12335 				$this->valid[__FUNCTION__] = true;
 12037 				return true;
 12336 				return true;
 12038 			}
 12337 			}
 12127 		{
 12426 		{
 12128 			$this->query = null;
 12427 			$this->query = null;
 12129 		}
 12428 		}
 12130 		else
 12429 		else
 12131 		{
 12430 		{
 12132 			$this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:@/?');
 12431 			$this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$\'()*+,;:@/?&=');
 12133 		}
 12432 		}
 12134 		$this->valid[__FUNCTION__] = true;
 12433 		$this->valid[__FUNCTION__] = true;
 12135 		return true;
 12434 		return true;
 12136 	}
 12435 	}
 12137 
 12436 
 13930 				$this->state = 'emit';
 14229 				$this->state = 'emit';
 13931 			}
 14230 			}
 13932 		}
 14231 		}
 13933 		else
 14232 		else
 13934 		{
 14233 		{
 13935 			$this->state = 'standalone_name';
 14234 			$this->state = false;
 13936 		}
 14235 		}
 13937 	}
 14236 	}
 13938 
 14237 
 13939 	function encoding_name()
 14238 	function encoding_name()
 13940 	{
 14239 	{
 13944 			$this->skip_whitespace();
 14243 			$this->skip_whitespace();
 13945 			$this->state = 'encoding_equals';
 14244 			$this->state = 'encoding_equals';
 13946 		}
 14245 		}
 13947 		else
 14246 		else
 13948 		{
 14247 		{
 13949 			$this->state = false;
 14248 			$this->state = 'standalone_name';
 13950 		}
 14249 		}
 13951 	}
 14250 	}
 13952 
 14251 
 13953 	function encoding_equals()
 14252 	function encoding_equals()
 13954 	{
 14253 	{
 14422 				{
 14721 				{
 14423 
 14722 
 14424 					case constant('XMLReader::END_ELEMENT'):
 14723 					case constant('XMLReader::END_ELEMENT'):
 14425 						if ($xml->namespaceURI !== '')
 14724 						if ($xml->namespaceURI !== '')
 14426 						{
 14725 						{
 14427 							$tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
 14726 							$tagName = $xml->namespaceURI . $this->separator . $xml->localName;
 14428 						}
 14727 						}
 14429 						else
 14728 						else
 14430 						{
 14729 						{
 14431 							$tagName = $xml->localName;
 14730 							$tagName = $xml->localName;
 14432 						}
 14731 						}
 14434 						break;
 14733 						break;
 14435 					case constant('XMLReader::ELEMENT'):
 14734 					case constant('XMLReader::ELEMENT'):
 14436 						$empty = $xml->isEmptyElement;
 14735 						$empty = $xml->isEmptyElement;
 14437 						if ($xml->namespaceURI !== '')
 14736 						if ($xml->namespaceURI !== '')
 14438 						{
 14737 						{
 14439 							$tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
 14738 							$tagName = $xml->namespaceURI . $this->separator . $xml->localName;
 14440 						}
 14739 						}
 14441 						else
 14740 						else
 14442 						{
 14741 						{
 14443 							$tagName = $xml->localName;
 14742 							$tagName = $xml->localName;
 14444 						}
 14743 						}
 14445 						$attributes = array();
 14744 						$attributes = array();
 14446 						while ($xml->moveToNextAttribute())
 14745 						while ($xml->moveToNextAttribute())
 14447 						{
 14746 						{
 14448 							if ($xml->namespaceURI !== '')
 14747 							if ($xml->namespaceURI !== '')
 14449 							{
 14748 							{
 14450 								$attrName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
 14749 								$attrName = $xml->namespaceURI . $this->separator . $xml->localName;
 14451 							}
 14750 							}
 14452 							else
 14751 							else
 14453 							{
 14752 							{
 14454 								$attrName = $xml->localName;
 14753 								$attrName = $xml->localName;
 14455 							}
 14754 							}
 14910 										$img['attribs']['src']['data'] = $this->image_handler . $image_url;
 15209 										$img['attribs']['src']['data'] = $this->image_handler . $image_url;
 14911 										$data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data);
 15210 										$data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data);
 14912 									}
 15211 									}
 14913 									else
 15212 									else
 14914 									{
 15213 									{
 14915 										trigger_error("$this->cache_location is not writeable", E_USER_WARNING);
 15214 										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);
 14916 									}
 15215 									}
 14917 								}
 15216 								}
 14918 							}
 15217 							}
 14919 						}
 15218 						}
 14920 					}
 15219 					}
 14995 		{
 15294 		{
 14996 			return '';
 15295 			return '';
 14997 		}
 15296 		}
 14998 	}
 15297 	}
 14999 }
 15298 }
 15000 
 15299 endif;
 15001 ?>
 15300 ?>