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