Changeset 19890 for trunk/wp-includes/class-simplepie.php
- Timestamp:
- 02/09/2012 08:15:22 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-simplepie.php
r16699 r19890 1 1 <?php 2 if ( ! class_exists( 'SimplePie' ) ) :2 if ( ! class_exists( 'SimplePie' ) ) : 3 3 /** 4 4 * SimplePie … … 7 7 * Takes the hard work out of managing a complete RSS/Atom solution. 8 8 * 9 * Copyright (c) 2004-20 09, Ryan Parman and Geoffrey Sneddon9 * Copyright (c) 2004-2011, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 10 10 * All rights reserved. 11 11 * … … 35 35 * 36 36 * @package SimplePie 37 * @version 1.2 38 * @copyright 2004-20 09 Ryan Parman, Geoffrey Sneddon37 * @version 1.2.1 38 * @copyright 2004-2011 Ryan Parman, Geoffrey Sneddon, Ryan McCue 39 39 * @author Ryan Parman 40 40 * @author Geoffrey Sneddon 41 * @author Ryan McCue 41 42 * @link http://simplepie.org/ SimplePie 42 43 * @link http://simplepie.org/support/ Please submit all bug reports and feature requests to the SimplePie forums … … 53 54 * SimplePie Version 54 55 */ 55 define('SIMPLEPIE_VERSION', '1.2 ');56 define('SIMPLEPIE_VERSION', '1.2.1'); 56 57 57 58 /** 58 59 * SimplePie Build 59 60 */ 60 define('SIMPLEPIE_BUILD', '20 090627192103');61 define('SIMPLEPIE_BUILD', '20111015034325'); 61 62 62 63 /** … … 1673 1674 if (!$cache->save($this)) 1674 1675 { 1675 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); 1676 1677 } 1677 1678 $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc'); … … 1681 1682 else 1682 1683 { 1683 $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."; 1684 1685 SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); 1685 1686 return false; … … 1778 1779 if ($cache && !$cache->save($this)) 1779 1780 { 1780 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); 1781 1782 } 1782 1783 return true; … … 1784 1785 else 1785 1786 { 1786 $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."; 1787 1788 SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); 1788 1789 return false; … … 1791 1792 } 1792 1793 } 1793 if (isset($parser))1794 if (isset($parser)) 1794 1795 { 1795 1796 // 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());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()); 1797 1798 } 1798 1799 else 1799 1800 { 1800 $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.'; 1801 1802 } 1802 1803 SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); … … 1832 1833 1833 1834 /** 1834 * Return the error message for the occur red error1835 * Return the error message for the occured error 1835 1836 * 1836 1837 * @access public … … 1985 1986 else 1986 1987 { 1987 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); 1988 1989 return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI); 1989 1990 } … … 2775 2776 function get_latitude() 2776 2777 { 2778 2777 2779 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) 2778 2780 { 2779 2781 return (float) $return[0]['data']; 2780 2782 } 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))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)) 2782 2784 { 2783 2785 return (float) $match[1]; … … 2799 2801 return (float) $return[0]['data']; 2800 2802 } 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))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)) 2802 2804 { 2803 2805 return (float) $match[2]; … … 3279 3281 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3280 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 3281 3288 elseif (!$description_only) 3282 3289 { … … 3643 3650 return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT); 3644 3651 } 3645 elseif (($date = $this->get_date('U')) !== null )3652 elseif (($date = $this->get_date('U')) !== null && $date !== false) 3646 3653 { 3647 3654 return strftime($date_format, $date); … … 4429 4436 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group) 4430 4437 { 4431 // If we have media:content tags, loop through them. 4432 foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) 4433 { 4434 if (isset($content['attribs']['']['url'])) 4438 if(isset($group['child']) && isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'])) 4439 { 4440 // If we have media:content tags, loop through them. 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'])) 4435 5066 { 4436 5067 // Attributes … … 4517 5148 $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); 4518 5149 } 4519 $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 4520 4521 // Checking the other optional media: elements. Priority: media:content, media:group, item, channel 4522 4523 // CAPTIONS 4524 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) 5150 if (isset($content['attribs']['']['url'])) 4525 5151 { 4526 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) 4527 { 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 { 4535 $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 4536 } 4537 if (isset($caption['attribs']['']['lang'])) 4538 { 4539 $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); 4540 } 4541 if (isset($caption['attribs']['']['start'])) 4542 { 4543 $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); 4544 } 4545 if (isset($caption['attribs']['']['end'])) 4546 { 4547 $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); 4548 } 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 } 4555 if (is_array($captions)) 4556 { 4557 $captions = array_values(SimplePie_Misc::array_unique($captions)); 4558 } 5152 $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 4559 5153 } 4560 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))4561 {4562 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)4563 {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']))4570 {4571 $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);4572 }4573 if (isset($caption['attribs']['']['lang']))4574 {4575 $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);4576 }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 }4591 if (is_array($captions))4592 {4593 $captions = array_values(SimplePie_Misc::array_unique($captions));4594 }4595 }4596 else4597 {4598 $captions = $captions_parent;4599 }4600 4601 // CATEGORIES4602 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))4603 {4604 foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)4605 {4606 $term = null;4607 $scheme = null;4608 $label = null;4609 if (isset($category['data']))4610 {4611 $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);4612 }4613 if (isset($category['attribs']['']['scheme']))4614 {4615 $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);4616 }4617 else4618 {4619 $scheme = 'http://search.yahoo.com/mrss/category_schema';4620 }4621 if (isset($category['attribs']['']['label']))4622 {4623 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);4624 }4625 $categories[] =& new $this->feed->category_class($term, $scheme, $label);4626 }4627 }4628 if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))4629 {4630 foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)4631 {4632 $term = null;4633 $scheme = null;4634 $label = null;4635 if (isset($category['data']))4636 {4637 $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);4638 }4639 if (isset($category['attribs']['']['scheme']))4640 {4641 $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);4642 }4643 else4644 {4645 $scheme = 'http://search.yahoo.com/mrss/category_schema';4646 }4647 if (isset($category['attribs']['']['label']))4648 {4649 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);4650 }4651 $categories[] =& new $this->feed->category_class($term, $scheme, $label);4652 }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 // COPYRIGHTS4668 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']))4673 {4674 $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);4675 }4676 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))4677 {4678 $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);4679 }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']))4687 {4688 $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);4689 }4690 if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))4691 {4692 $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);4693 }4694 $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);4695 }4696 else4697 {4698 $copyrights = $copyrights_parent;4699 }4700 4701 // CREDITS4702 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))4703 {4704 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)4705 {4706 $credit_role = null;4707 $credit_scheme = null;4708 $credit_name = null;4709 if (isset($credit['attribs']['']['role']))4710 {4711 $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);4712 }4713 if (isset($credit['attribs']['']['scheme']))4714 {4715 $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);4716 }4717 else4718 {4719 $credit_scheme = 'urn:ebu';4720 }4721 if (isset($credit['data']))4722 {4723 $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);4724 }4725 $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);4726 }4727 if (is_array($credits))4728 {4729 $credits = array_values(SimplePie_Misc::array_unique($credits));4730 }4731 }4732 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))4733 {4734 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)4735 {4736 $credit_role = null;4737 $credit_scheme = null;4738 $credit_name = null;4739 if (isset($credit['attribs']['']['role']))4740 {4741 $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);4742 }4743 if (isset($credit['attribs']['']['scheme']))4744 {4745 $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);4746 }4747 else4748 {4749 $credit_scheme = 'urn:ebu';4750 }4751 if (isset($credit['data']))4752 {4753 $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);4754 }4755 $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);4756 }4757 if (is_array($credits))4758 {4759 $credits = array_values(SimplePie_Misc::array_unique($credits));4760 }4761 }4762 else4763 {4764 $credits = $credits_parent;4765 }4766 4767 // DESCRIPTION4768 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 else4777 {4778 $description = $description_parent;4779 }4780 4781 // HASHES4782 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))4783 {4784 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)4785 {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 else4797 {4798 $algo = 'md5';4799 }4800 $hashes[] = $algo.':'.$value;4801 }4802 if (is_array($hashes))4803 {4804 $hashes = array_values(SimplePie_Misc::array_unique($hashes));4805 }4806 }4807 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))4808 {4809 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)4810 {4811 $value = null;4812 $algo = null;4813 if (isset($hash['data']))4814 {4815 $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);4816 }4817 if (isset($hash['attribs']['']['algo']))4818 {4819 $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);4820 }4821 else4822 {4823 $algo = 'md5';4824 }4825 $hashes[] = $algo.':'.$value;4826 }4827 if (is_array($hashes))4828 {4829 $hashes = array_values(SimplePie_Misc::array_unique($hashes));4830 }4831 }4832 else4833 {4834 $hashes = $hashes_parent;4835 }4836 4837 // KEYWORDS4838 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)4844 {4845 $keywords[] = trim($word);4846 }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)4860 {4861 $keywords[] = trim($word);4862 }4863 unset($temp);4864 }4865 if (is_array($keywords))4866 {4867 $keywords = array_values(SimplePie_Misc::array_unique($keywords));4868 }4869 }4870 else4871 {4872 $keywords = $keywords_parent;4873 }4874 4875 // PLAYER4876 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 else4885 {4886 $player = $player_parent;4887 }4888 4889 // RATINGS4890 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))4891 {4892 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)4893 {4894 $rating_scheme = null;4895 $rating_value = null;4896 if (isset($rating['attribs']['']['scheme']))4897 {4898 $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);4899 }4900 else4901 {4902 $rating_scheme = 'urn:simple';4903 }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 }4910 if (is_array($ratings))4911 {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']))4922 {4923 $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);4924 }4925 else4926 {4927 $rating_scheme = 'urn:simple';4928 }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 }4935 if (is_array($ratings))4936 {4937 $ratings = array_values(SimplePie_Misc::array_unique($ratings));4938 }4939 }4940 else4941 {4942 $ratings = $ratings_parent;4943 }4944 4945 // RESTRICTIONS4946 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))4947 {4948 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)4949 {4950 $restriction_relationship = null;4951 $restriction_type = null;4952 $restriction_value = null;4953 if (isset($restriction['attribs']['']['relationship']))4954 {4955 $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);4956 }4957 if (isset($restriction['attribs']['']['type']))4958 {4959 $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);4960 }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 }4967 if (is_array($restrictions))4968 {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']))4980 {4981 $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);4982 }4983 if (isset($restriction['attribs']['']['type']))4984 {4985 $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);4986 }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 }4993 if (is_array($restrictions))4994 {4995 $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));4996 }4997 }4998 else4999 {5000 $restrictions = $restrictions_parent;5001 }5002 5003 // THUMBNAILS5004 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))5005 {5006 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)5007 {5008 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);5009 }5010 if (is_array($thumbnails))5011 {5012 $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));5013 }5014 }5015 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))5016 {5017 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)5018 {5019 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);5020 }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 5031 // TITLES5032 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))5033 {5034 $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);5035 }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 }5047 }5048 }5049 5050 // If we have standalone media:content tags, loop through them.5051 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))5052 {5053 foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)5054 {5055 if (isset($content['attribs']['']['url']))5056 {5057 // Attributes5058 $bitrate = null;5059 $channels = null;5060 $duration = null;5061 $expression = null;5062 $framerate = null;5063 $height = null;5064 $javascript = null;5065 $lang = null;5066 $length = null;5067 $medium = null;5068 $samplingrate = null;5069 $type = null;5070 $url = null;5071 $width = null;5072 5073 // Elements5074 $captions = null;5075 $categories = null;5076 $copyrights = null;5077 $credits = null;5078 $description = null;5079 $hashes = null;5080 $keywords = null;5081 $player = null;5082 $ratings = null;5083 $restrictions = null;5084 $thumbnails = null;5085 $title = null;5086 5087 // Start checking the attributes of media:content5088 if (isset($content['attribs']['']['bitrate']))5089 {5090 $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);5091 }5092 if (isset($content['attribs']['']['channels']))5093 {5094 $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);5095 }5096 if (isset($content['attribs']['']['duration']))5097 {5098 $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);5099 }5100 else5101 {5102 $duration = $duration_parent;5103 }5104 if (isset($content['attribs']['']['expression']))5105 {5106 $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);5107 }5108 if (isset($content['attribs']['']['framerate']))5109 {5110 $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);5111 }5112 if (isset($content['attribs']['']['height']))5113 {5114 $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);5115 }5116 if (isset($content['attribs']['']['lang']))5117 {5118 $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);5119 }5120 if (isset($content['attribs']['']['fileSize']))5121 {5122 $length = ceil($content['attribs']['']['fileSize']);5123 }5124 if (isset($content['attribs']['']['medium']))5125 {5126 $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);5127 }5128 if (isset($content['attribs']['']['samplingrate']))5129 {5130 $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);5131 }5132 if (isset($content['attribs']['']['type']))5133 {5134 $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);5135 }5136 if (isset($content['attribs']['']['width']))5137 {5138 $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);5139 }5140 $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);5141 5142 5154 // Checking the other optional media: elements. Priority: media:content, media:group, item, channel 5143 5155 … … 5581 5593 return (float) $return[0]['data']; 5582 5594 } 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))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)) 5584 5596 { 5585 5597 return (float) $match[1]; … … 5601 5613 return (float) $return[0]['data']; 5602 5614 } 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))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)) 5604 5616 { 5605 5617 return (float) $match[2]; … … 6224 6236 return (float) $return[0]['data']; 6225 6237 } 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))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)) 6227 6239 { 6228 6240 return (float) $match[1]; … … 6244 6256 return (float) $return[0]['data']; 6245 6257 } 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))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)) 6247 6259 { 6248 6260 return (float) $match[2]; … … 7728 7740 $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN; 7729 7741 $url_parts = parse_url($url); 7742 $socket_host = $url_parts['host']; 7730 7743 if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') 7731 7744 { 7732 $ url_parts['host']= "ssl://$url_parts[host]";7745 $socket_host = "ssl://$url_parts[host]"; 7733 7746 $url_parts['port'] = 443; 7734 7747 } … … 7737 7750 $url_parts['port'] = 80; 7738 7751 } 7739 $fp = @fsockopen($ url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout);7752 $fp = @fsockopen($socket_host, $url_parts['port'], $errno, $errstr, $timeout); 7740 7753 if (!$fp) 7741 7754 { … … 8483 8496 // Get the length of the extra field 8484 8497 $len = current(unpack('v', substr($this->compressed_data, $this->position, 2))); 8485 $ position += 2;8498 $this->position += 2; 8486 8499 8487 8500 // Check the length of the string is still valid … … 9235 9248 break; 9236 9249 } 9237 error_log("$note: $message in $file on line $line", 0); 9238 } 9250 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 9239 9269 return $message; 9240 9270 } … … 9433 9463 } 9434 9464 // 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)))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))) 9436 9466 { 9437 9467 return $return; … … 9449 9479 } 9450 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 */ 9451 9492 function encoding($charset) 9452 9493 { … … 9482 9523 case 'big5': 9483 9524 case 'csbig5': 9484 case 'xxbig5':9485 9525 return 'Big5'; 9486 9526 … … 9638 9678 return 'ES2'; 9639 9679 9680 case 'cseucpkdfmtjapanese': 9681 case 'eucjp': 9682 case 'extendedunixcodepackedformatforjapanese': 9683 return 'EUC-JP'; 9684 9640 9685 case 'cseucfixwidjapanese': 9641 9686 case 'extendedunixcodefixedwidthforjapanese': 9642 9687 return 'Extended_UNIX_Code_Fixed_Width_for_Japanese'; 9643 9644 case 'cseucpkdfmtjapanese':9645 case 'eucjp':9646 case 'extendedunixcodepackedformatforjapanese':9647 return 'Extended_UNIX_Code_Packed_Format_for_Japanese';9648 9688 9649 9689 case 'gb18030': … … 9724 9764 return 'IBM-Thai'; 9725 9765 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 9766 case 'cp37': 9801 9767 case 'csibm37': … … 9945 9911 return 'IBM857'; 9946 9912 9913 case 'ccsid858': 9914 case 'cp858': 9915 case 'ibm858': 9916 case 'pcmultilingual850euro': 9917 return 'IBM00858'; 9918 9947 9919 case '860': 9948 9920 case 'cp860': … … 10047 10019 return 'IBM918'; 10048 10020 10021 case 'ccsid924': 10022 case 'cp924': 10023 case 'ebcdiclatin9euro': 10024 case 'ibm924': 10025 return 'IBM00924'; 10026 10049 10027 case 'cp1026': 10050 10028 case 'csibm1026': … … 10054 10032 case 'ibm1047': 10055 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'; 10056 10096 10057 10097 case 'csiso143iecp271': … … 10596 10636 case 'sen850200c': 10597 10637 return 'SEN_850200_C'; 10598 10599 case 'csshiftjis':10600 case 'mskanji':10601 case 'shiftjis':10602 return 'Shift_JIS';10603 10638 10604 10639 case 'csiso102t617bit': … … 10700 10735 return 'VISCII'; 10701 10736 10737 case 'csshiftjis': 10702 10738 case 'cswindows31j': 10739 case 'mskanji': 10740 case 'shiftjis': 10703 10741 case 'windows31j': 10704 10742 return 'Windows-31J'; … … 11360 11398 } 11361 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; 11362 11452 } 11363 11453 } … … 11832 11922 * Replace invalid character with percent encoding 11833 11923 * 11834 * @access private11835 11924 * @param string $string Input string 11836 11925 * @param string $valid_chars Valid characters … … 11838 11927 * @return string 11839 11928 */ 11840 function replace_invalid_with_pct_encoding($string, $valid_chars, $case = SIMPLEPIE_SAME_CASE) 11841 { 11929 function replace_invalid_with_pct_encoding($string, $valid_chars, $case = SIMPLEPIE_SAME_CASE, $iprivate = false) 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 11842 12053 // Normalise case 11843 12054 if ($case & SIMPLEPIE_LOWERCASE) … … 11850 12061 } 11851 12062 11852 // Store position and string length (to avoid constantly recalculating this) 11853 $position = 0; 11854 $strlen = strlen($string); 11855 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) 11858 { 11859 // If we have a % character 11860 if ($string[$position] === '%') 11861 { 11862 // If we have a pct-encoded section 11863 if ($position + 2 < $strlen && strspn($string, '0123456789ABCDEFabcdef', $position + 1, 2) === 2) 11864 { 11865 // Get the the represented character 11866 $chr = chr(hexdec(substr($string, $position + 1, 2))); 11867 11868 // If the character is valid, replace the pct-encoded with the actual character while normalising case 11869 if (strpos($valid_chars, $chr) !== false) 12063 return $string; 12064 } 12065 12066 /** 12067 * Callback function for preg_replace_callback. 12068 * 12069 * Removes sequences of percent encoded bytes that represent UTF-8 12070 * encoded characters in iunreserved 12071 * 12072 * @access private 12073 * @param array $match PCRE match 12074 * @return string Replacement 12075 */ 12076 function remove_iunreserved_percent_encoded($match) 12077 { 12078 // As we just have valid percent encoded sequences we can just explode 12079 // and ignore the first member of the returned array (an empty string). 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++) 11870 12181 { 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++; 12182 $string .= '%' . strtoupper($bytes[$j]); 11882 12183 } 11883 11884 // Otherwise just normalise the pct-encoded to uppercase 11885 else 12184 } 12185 else 12186 { 12187 for ($j = $start; $j <= $i; $j++) 11886 12188 { 11887 $string = substr_replace($string, strtoupper(substr($string, $position + 1, 2)), $position + 1, 2); 11888 $position += 3; 12189 $string .= chr(hexdec($bytes[$j])); 11889 12190 } 11890 12191 } 11891 // If we don't have a pct-encoded section, just replace the % with its own esccaped form 11892 else 11893 { 11894 $string = substr_replace($string, '%25', $position, 1); 11895 $strlen += 2; 11896 $position += 3; 11897 } 11898 } 11899 // If we have an invalid character, change into its pct-encoded form 11900 else 11901 { 11902 $replacement = sprintf("%%%02X", ord($string[$position])); 11903 $string = str_replace($string[$position], $replacement, $string); 11904 $strlen = strlen($string); 11905 } 11906 } 12192 } 12193 } 12194 12195 // If we have any bytes left over they are invalid (i.e., we are 12196 // mid-way through a multi-byte sequence) 12197 if ($remaining) 12198 { 12199 for ($j = $start; $j < $len; $j++) 12200 { 12201 $string .= '%' . strtoupper($bytes[$j]); 12202 } 12203 } 12204 11907 12205 return $string; 11908 12206 } … … 12131 12429 else 12132 12430 { 12133 $this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$ &\'()*+,;=:@/?');12431 $this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$\'()*+,;:@/?&='); 12134 12432 } 12135 12433 $this->valid[__FUNCTION__] = true; … … 13934 14232 else 13935 14233 { 13936 $this->state = 'standalone_name';14234 $this->state = false; 13937 14235 } 13938 14236 } … … 13948 14246 else 13949 14247 { 13950 $this->state = false;14248 $this->state = 'standalone_name'; 13951 14249 } 13952 14250 } … … 14426 14724 if ($xml->namespaceURI !== '') 14427 14725 { 14428 $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";14726 $tagName = $xml->namespaceURI . $this->separator . $xml->localName; 14429 14727 } 14430 14728 else … … 14438 14736 if ($xml->namespaceURI !== '') 14439 14737 { 14440 $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";14738 $tagName = $xml->namespaceURI . $this->separator . $xml->localName; 14441 14739 } 14442 14740 else … … 14449 14747 if ($xml->namespaceURI !== '') 14450 14748 { 14451 $attrName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";14749 $attrName = $xml->namespaceURI . $this->separator . $xml->localName; 14452 14750 } 14453 14751 else … … 14914 15212 else 14915 15213 { 14916 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); 14917 15215 } 14918 15216 }
Note: See TracChangeset
for help on using the changeset viewer.