Magazento_Sociallifestream - Version 0.1.0

Version Notes

0.1.0

Download this release

Release Info

Developer Magento Core Team
Extension Magazento_Sociallifestream
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/community/Magazento/SocialLifestream/Block/Developer.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magazento_Sociallifestream_Block_Developer extends Mage_Adminhtml_Block_System_Config_Form_Fieldset {
4
+
5
+ public function render(Varien_Data_Form_Element_Abstract $element) {
6
+ $content = '<p></p>';
7
+ $content.= '<style>
8
+ .developer {
9
+ background: #FAFAFA;
10
+ border: 1px solid #CCCCCC;
11
+ margin-bottom: 10px;
12
+ padding: 10px;
13
+ height: auto;
14
+ }
15
+
16
+ .developer h3 {
17
+ color: #444;
18
+ }
19
+
20
+ .contact-type {
21
+ color: #EA7601;
22
+ font-weight: bold;
23
+ }
24
+
25
+ .developer img {
26
+ float: left;
27
+ }
28
+
29
+ .developer .info {
30
+ background: #E7EFEF;
31
+ padding: 5px 10px 0 5px;
32
+ margin-left: 210px;
33
+ height: 195px;
34
+ }
35
+ </style>
36
+
37
+ <div class="developer">
38
+ <a href="http://www.magazento.com/english/magento-ext/magazento-extensions/navigation-menu-megamenu"
39
+ target="_blank"><img
40
+ src="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'frontend/base/default/magazento/mostpopular/menu_box.jpg"
41
+ >
42
+ </a>
43
+
44
+ <div class="info">
45
+ <h3>MEGAMENU - Band new Magento navigation menu</h3>
46
+ <p>
47
+ Menu - is a key navigation element for customers on your website. It is particularly important that the menu would contain a maximum of all information,
48
+ namely that which is needed by your potential customers. Alas, based on analysis of user behavior on large portals, the attention of given only for the first
49
+ 10% - 20% of all categories of the store directories.<br>
50
+ The remaining elements are simply not visible to users and are not used. Store can increase profits by changing the sitemenu - users should see all items of your catalog products immediately.
51
+ </p>
52
+
53
+ <a href="http://www.magazento.com/english/magento-ext/magazento-extensions/navigation-menu-megamenu" target="_blank"><img src="http://magazento.com/promo/extension_page.png" alt=""></a>
54
+ <br>
55
+ </div>
56
+
57
+ </div>
58
+
59
+ <div class="developer">
60
+ <a href="http://www.magazento.com/english/magento-ext/magazento-extensions/magento-one-step-page-checkout"
61
+ target="_blank"><img
62
+ src="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'frontend/base/default/magazento/mostpopular/logo_onecheckout.jpg"
63
+ >
64
+ </a>
65
+
66
+ <div class="info">
67
+ <h3>ONE STEP CHECKOUT</h3>
68
+ <p>
69
+ Complicated checkout process with many forms to fill in can make customers run away and increase cart abandonment. Magento One Step Checkout offers simplified checkout for your customers\' positive shopping experience. The module shortens the process into one single page. Logged in customers already have their information on the page; they need to make just a few clicks to confirm the order.
70
+ </p>
71
+
72
+ <a href="http://www.magazento.com/english/magento-ext/magazento-extensions/magento-one-step-page-checkout" target="_blank"><img src="http://magazento.com/promo/extension_page.png" alt=""></a>
73
+ <br>
74
+ </div>
75
+ </div>
76
+
77
+ <div class="developer">
78
+ <a href="http://www.magazento.com/english/magento-ext/magazento-extensions/pdf-export"
79
+ target="_blank"><img
80
+ src="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'frontend/base/default/magazento/mostpopular/logo_pdf.jpg"
81
+ >
82
+ </a>
83
+
84
+ <div class="info">
85
+ <h3>PDF CATALOG</h3>
86
+ <p>
87
+ PDF CATALOG for Magento is a professional solution that lets you generate printable copy of all store products! It also lets your customers to generate PDF\'s of products and categories they view directly from your website without other 3rd party website or applications. All store products in PDF in few clicks!
88
+ </p>
89
+
90
+ <a href="http://www.magazento.com/english/magento-ext/magazento-extensions/pdf-export" target="_blank"><img src="http://magazento.com/promo/extension_page.png" alt=""></a>
91
+ <br>
92
+ </div>
93
+ </div>
94
+
95
+ <div class="developer">
96
+ <a href="http://www.magazento.com/english/magento-ext/magazento-extensions/extension-html-sitemap"
97
+ target="_blank"><img
98
+ src="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'frontend/base/default/magazento/mostpopular/logo_sitemap.jpg"
99
+ >
100
+ </a>
101
+
102
+ <div class="info">
103
+ <h3>SITEMAP</h3>
104
+ <p>
105
+ With Sitemap you can easily create the site map page on your site with the clear hierarchical structure of all the products, categories and pages. Sure that such a page will be highly appreciated by those of your customers who would like not to spend a lot of time to find the product they are interested in. And the search spiders and crawlers will get through this magento sitemap the clear direction to all your site pages, no matter how numerous they are. Moreover, with Magento Html Sitemap extension you will receive the bundle of bright additional advantages making the google sitemap creation even easier and more convenient.
106
+ </p>
107
+
108
+ <a href="http://www.magazento.com/english/magento-ext/magazento-extensions/extension-html-sitemap" target="_blank"><img src="http://magazento.com/promo/extension_page.png" alt=""></a>
109
+ <br>
110
+ </div>
111
+ </div>'
112
+
113
+
114
+
115
+
116
+
117
+ ;
118
+
119
+ return $content;
120
+
121
+
122
+ }
123
+
124
+
125
+ }
app/code/community/Magazento/SocialLifestream/Block/Soclife.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Sep 15, 2012
4
+ * Author Kate Mironova - ktmironova@gmail.com - Magazento.com
5
+ * Copyright Proskuryakov Ivan. Magazento.com © 2011. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+
10
+ <?php
11
+ class Magazento_SocialLifestream_Block_Soclife extends Mage_Core_Block_Template
12
+ {
13
+
14
+ protected function _construct() {
15
+ $this->addData(array(
16
+ 'cache_lifetime' => 86400,
17
+ 'cache_tags' => array("magazento_sociallifestream_".Mage::app()->getStore()->getId()),
18
+ 'cache_key' => "magazento_sociallifestream_".Mage::app()->getStore()->getId(),
19
+ ));
20
+ }
21
+
22
+
23
+ public function getSocialData() {
24
+ return Mage::getModel('sociallifestream/data')->getSocData();
25
+ }
26
+
27
+ }
28
+ ?>
app/code/community/Magazento/SocialLifestream/Helper/Data.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magazento_SocialLifestream_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ public function includeLivestreamLib() {
7
+ $directory = dirname(dirname(__FILE__));
8
+ $directory = $directory .'/lib/';
9
+ require_once($directory . "simplepie.inc");
10
+ require_once($directory . "lifestream.class.php");
11
+ }
12
+
13
+
14
+
15
+ }
app/code/community/Magazento/SocialLifestream/Model/Data.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Created on Sep 15, 2012
5
+ * Author Kate Mironova - ktmironova@gmail.com - Magazento.com
6
+ * Copyright Proskuryakov Ivan. Magazento.com © 2012. All Rights Reserved.
7
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
8
+ */
9
+ ?>
10
+ <?php
11
+
12
+ Class Magazento_SocialLifestream_Model_Data {
13
+
14
+ private $records_limit = null;
15
+ private $life = null;
16
+ private $flag = false;
17
+
18
+ protected function __setup() {
19
+
20
+ Mage::helper('sociallifestream/data')->includeLivestreamLib();
21
+ $this->life->records_limit = Mage::getStoreConfig('sociallifestream/homepage/cnt');
22
+ $this->life = new LifeStream($this->life->records_limit);
23
+ }
24
+
25
+ public function getSocData() {
26
+ $this->__setup();
27
+
28
+ foreach (explode(',', Mage::getStoreConfig('sociallifestream/datasource/twitter')) as $twacc) {
29
+ if ($twacc != '') {
30
+ $this->life->addTwitter($twacc);
31
+ $this->flag = true;
32
+ }
33
+ }
34
+ foreach (explode(',', Mage::getStoreConfig('sociallifestream/datasource/delicious')) as $deliciousacc) {
35
+ if ($deliciousacc != '') {
36
+ $this->life->addDelicious($deliciousacc);
37
+ $this->flag = true;
38
+ }
39
+ }
40
+ foreach (explode(',', Mage::getStoreConfig('sociallifestream/datasource/flickr')) as $flickracc) {
41
+ if ($flickracc != '') {
42
+ $this->life->addFlickr($flickracc);
43
+ $this->flag = true;
44
+ }
45
+ }
46
+ foreach (explode(',', Mage::getStoreConfig('sociallifestream/datasource/tumblr')) as $tumblracc) {
47
+ if ($tumblracc != '') {
48
+ $this->life->addTumblr($tumblracc);
49
+ $this->flag = true;
50
+ }
51
+ }
52
+ foreach (explode(',', Mage::getStoreConfig('sociallifestream/datasource/youtube')) as $youtubeacc) {
53
+ if ($youtubeacc != '') {
54
+ $this->life->addYouTube($youtubeacc);
55
+ $this->flag = true;
56
+ }
57
+ }
58
+ foreach (explode(',', Mage::getStoreConfig('sociallifestream/datasource/dribbble')) as $dribbbleacc) {
59
+ if ($dribbbleacc != '') {
60
+ $this->life->addDribbble($dribbbleacc);
61
+ $this->flag = true;
62
+ }
63
+ }
64
+ foreach (explode(',', Mage::getStoreConfig('sociallifestream/datasource/digg')) as $diggacc) {
65
+ if ($diggacc != '') {
66
+ $this->life->addDigg($diggacc);
67
+ $this->flag = true;
68
+ }
69
+ }
70
+ foreach (explode(',', Mage::getStoreConfig('sociallifestream/datasource/vimeo')) as $vimeoacc) {
71
+ if ($vimeoacc != '') {
72
+ $this->life->addVimeo($vimeoacc);
73
+ $this->flag = true;
74
+ }
75
+ }
76
+ foreach (explode(',', Mage::getStoreConfig('sociallifestream/datasource/custom')) as $custom) {
77
+ if ($custom != '') {
78
+ $this->life->addCustomFeed($custom);
79
+ $this->flag = true;
80
+ }
81
+ }
82
+
83
+ $return = false;
84
+ if ($this->flag) {
85
+ $feed = $this->life->build();
86
+ $return = $feed;
87
+ }
88
+
89
+ return $return;
90
+ }
91
+
92
+ }
93
+
94
+ ?>
app/code/community/Magazento/SocialLifestream/etc/config.xml ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /*
4
+ * Created on Sep 10, 2012
5
+ * Author Kate Mironova - ktmironova@gmail.com - Magazento.com
6
+ * Copyright Proskuryakov Ivan. Magazento.com © 2012. All Rights Reserved.
7
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Magazento_SocialLifestream>
13
+ <version>0.1.0</version>
14
+ </Magazento_SocialLifestream>
15
+ </modules>
16
+ <frontend>
17
+ <routers>
18
+ <sociallifestream>
19
+ <use>standard</use>
20
+ <args>
21
+ <module>Magazento_SocialLifestream</module>
22
+ <frontName>sociallifestream</frontName>
23
+ </args>
24
+ </sociallifestream>
25
+ </routers>
26
+ <layout>
27
+ <updates>
28
+ <sociallifestream>
29
+ <file>magazento_sociallifestream.xml</file>
30
+ </sociallifestream>
31
+ </updates>
32
+ </layout>
33
+ </frontend>
34
+ <admin>
35
+ <routers>
36
+ <sociallifestream>
37
+ <use>admin</use>
38
+ <args>
39
+ <module>Magazento_SocialLifestream</module>
40
+ <frontName>sociallifestream</frontName>
41
+ </args>
42
+ </sociallifestream>
43
+ </routers>
44
+ </admin>
45
+ <adminhtml>
46
+ <acl>
47
+ <resources>
48
+ <all>
49
+ <title>Allow Everything</title>
50
+ </all>
51
+ <admin>
52
+ <children>
53
+ <system>
54
+ <children>
55
+ <config>
56
+ <children>
57
+ <sociallifestream translate="title" module="sociallifestream">
58
+ <title>sociallifestream</title>
59
+ </sociallifestream>
60
+ </children>
61
+ </config>
62
+ </children>
63
+ </system>
64
+
65
+ </children>
66
+ </admin>
67
+ </resources>
68
+ </acl>
69
+ <layout>
70
+ <updates>
71
+ <sociallifestream>
72
+ <file>sociallifestream.xml</file>
73
+ </sociallifestream>
74
+ </updates>
75
+ </layout>
76
+ </adminhtml>
77
+ <global>
78
+ <models>
79
+ <sociallifestream>
80
+ <class>Magazento_SocialLifestream_Model</class>
81
+ <resourceModel>sociallifestream_resource</resourceModel>
82
+ </sociallifestream>
83
+ <sociallifestream_resource>
84
+ <class>Magazento_SocialLifestream_Model_Resource</class>
85
+ <entities>
86
+ <sociallifestream>
87
+ <table>sociallifestream</table>
88
+ </sociallifestream>
89
+ </entities>
90
+ </sociallifestream_resource>
91
+ </models>
92
+ <resources>
93
+ <sociallifestream_setup>
94
+ <setup>
95
+ <module>Magazento_SocialLifestream</module>
96
+ </setup>
97
+ <connection>
98
+ <use>core_setup</use>
99
+ </connection>
100
+ </sociallifestream_setup>
101
+ <sociallifestream_write>
102
+ <connection>
103
+ <use>core_write</use>
104
+ </connection>
105
+ </sociallifestream_write>
106
+ <sociallifestream_read>
107
+ <connection>
108
+ <use>core_read</use>
109
+ </connection>
110
+ </sociallifestream_read>
111
+ </resources>
112
+ <blocks>
113
+ <sociallifestream>
114
+ <class>Magazento_SocialLifestream_Block</class>
115
+ </sociallifestream>
116
+ </blocks>
117
+ <helpers>
118
+ <sociallifestream>
119
+ <class>Magazento_SocialLifestream_Helper</class>
120
+ </sociallifestream>
121
+ </helpers>
122
+ </global>
123
+ <default>
124
+ <sociallifestream>
125
+ <options>
126
+ <enable>1</enable>
127
+ <blocktitle>Social Life Stream</blocktitle>
128
+ <empty>No data available</empty>
129
+ </options>
130
+ <homepage>
131
+ <cnt>7</cnt>
132
+ <sbleft>0</sbleft>
133
+ <sbright>1</sbright>
134
+ </homepage>
135
+ <datasource>
136
+ <twitter>ecommerceoffice</twitter>
137
+ <delicious>hrheingold</delicious>
138
+ <flickr>miggslives</flickr>
139
+ </datasource>
140
+ </sociallifestream>
141
+ </default>
142
+ </config>
app/code/community/Magazento/SocialLifestream/etc/system.xml ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /*
4
+ * Created on Sep 10, 2012
5
+ * Author Kate Mironova - ktmironova@gmail.com - Magazento.com
6
+ * Copyright Proskuryakov Ivan. Magazento.com © 2012. All Rights Reserved.
7
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
8
+ */
9
+ -->
10
+ <config>
11
+ <tabs>
12
+ <magazento translate="label">
13
+ <label>Magazento.com</label>
14
+ <sort_order>250</sort_order>
15
+ </magazento>
16
+ </tabs>
17
+ <sections>
18
+ <sociallifestream translate="label" module="sociallifestream">
19
+ <label>Social Life Stream</label>
20
+ <tab>magazento</tab>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>100</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <groups>
27
+ <developer>
28
+ <frontend_model>sociallifestream/developer</frontend_model>
29
+ <sort_order>999</sort_order>
30
+ <show_in_default>1</show_in_default>
31
+ <show_in_website>1</show_in_website>
32
+ <show_in_store>1</show_in_store>
33
+ </developer>
34
+ <options translate="label">
35
+ <label>Options</label>
36
+ <frontend_type>text</frontend_type>
37
+ <sort_order>1</sort_order>
38
+ <show_in_default>1</show_in_default>
39
+ <show_in_website>1</show_in_website>
40
+ <show_in_store>1</show_in_store>
41
+ <fields>
42
+ <enable translate="label">
43
+ <label>Enable</label>
44
+ <frontend_type>select</frontend_type>
45
+ <source_model>adminhtml/system_config_source_yesno</source_model>
46
+ <sort_order>11</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>1</show_in_website>
49
+ <show_in_store>1</show_in_store>
50
+ </enable>
51
+ <title translate="label">
52
+ <label>Block title</label>
53
+ <frontend_type>text</frontend_type>
54
+ <sort_order>12</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ </title>
59
+ <empty translate="label">
60
+ <label>Empty Text</label>
61
+ <frontend_type>text</frontend_type>
62
+ <sort_order>13</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>1</show_in_store>
66
+ </empty>
67
+ </fields>
68
+ </options>
69
+ <homepage translate="label">
70
+ <label>Homepage</label>
71
+ <frontend_type>text</frontend_type>
72
+ <sort_order>2</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ <fields>
77
+ <cnt translate="label">
78
+ <label>Lines count</label>
79
+ <frontend_type>text</frontend_type>
80
+ <sort_order>14</sort_order>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>1</show_in_website>
83
+ <show_in_store>1</show_in_store>
84
+ </cnt>
85
+ <sbleft translate="label">
86
+ <label>Left Sidebar</label>
87
+ <frontend_type>select</frontend_type>
88
+ <source_model>adminhtml/system_config_source_yesno</source_model>
89
+ <sort_order>14</sort_order>
90
+ <show_in_default>1</show_in_default>
91
+ <show_in_website>1</show_in_website>
92
+ <show_in_store>1</show_in_store>
93
+ </sbleft>
94
+ <sbright translate="label">
95
+ <label>Right Sidebar</label>
96
+ <frontend_type>select</frontend_type>
97
+ <source_model>adminhtml/system_config_source_yesno</source_model>
98
+ <sort_order>15</sort_order>
99
+ <show_in_default>1</show_in_default>
100
+ <show_in_website>1</show_in_website>
101
+ <show_in_store>1</show_in_store>
102
+ </sbright>
103
+ </fields>
104
+ </homepage>
105
+
106
+
107
+ <datasource>
108
+ <label>DataSource</label>
109
+ <frontend_type>text</frontend_type>
110
+ <sort_order>3</sort_order>
111
+ <show_in_default>2</show_in_default>
112
+ <show_in_website>2</show_in_website>
113
+ <show_in_store>2</show_in_store>
114
+ <fields>
115
+ <twitter translate="label">
116
+ <label>Twitter accounts</label>
117
+ <frontend_type>text</frontend_type>
118
+ <comment>use comma "," to separate multiple accounts</comment>
119
+ <sort_order>12</sort_order>
120
+ <show_in_default>1</show_in_default>
121
+ <show_in_website>1</show_in_website>
122
+ <show_in_store>1</show_in_store>
123
+ </twitter>
124
+ <delicious>
125
+ <label>Delicious accounts</label>
126
+ <frontend_type>text</frontend_type>
127
+ <sort_order>13</sort_order>
128
+ <show_in_default>1</show_in_default>
129
+ <show_in_website>1</show_in_website>
130
+ <show_in_store>1</show_in_store>
131
+ </delicious>
132
+ <flickr>
133
+ <label>Flickr accounts</label>
134
+ <frontend_type>text</frontend_type>
135
+ <sort_order>14</sort_order>
136
+ <show_in_default>1</show_in_default>
137
+ <show_in_website>1</show_in_website>
138
+ <show_in_store>1</show_in_store>
139
+ </flickr>
140
+ <tumblr>
141
+ <label>Tumblr accounts</label>
142
+ <frontend_type>text</frontend_type>
143
+ <sort_order>15</sort_order>
144
+ <show_in_default>1</show_in_default>
145
+ <show_in_website>1</show_in_website>
146
+ <show_in_store>1</show_in_store>
147
+ </tumblr>
148
+ <youtube>
149
+ <label>YouTube accounts</label>
150
+ <frontend_type>text</frontend_type>
151
+ <sort_order>16</sort_order>
152
+ <show_in_default>1</show_in_default>
153
+ <show_in_website>1</show_in_website>
154
+ <show_in_store>1</show_in_store>
155
+ </youtube>
156
+ <dribbble>
157
+ <label>Dribbble accounts</label>
158
+ <frontend_type>text</frontend_type>
159
+ <sort_order>17</sort_order>
160
+ <show_in_default>1</show_in_default>
161
+ <show_in_website>1</show_in_website>
162
+ <show_in_store>1</show_in_store>
163
+ </dribbble>
164
+ <digg>
165
+ <label>Digg accounts</label>
166
+ <frontend_type>text</frontend_type>
167
+ <sort_order>18</sort_order>
168
+ <show_in_default>1</show_in_default>
169
+ <show_in_website>1</show_in_website>
170
+ <show_in_store>1</show_in_store>
171
+ </digg>
172
+ <vimeo>
173
+ <label>Vimeo accounts</label>
174
+ <frontend_type>text</frontend_type>
175
+ <sort_order>19</sort_order>
176
+ <show_in_default>1</show_in_default>
177
+ <show_in_website>1</show_in_website>
178
+ <show_in_store>1</show_in_store>
179
+ </vimeo>
180
+ <custom>
181
+ <label>Custom feeds</label>
182
+ <frontend_type>text</frontend_type>
183
+ <sort_order>20</sort_order>
184
+ <show_in_default>1</show_in_default>
185
+ <show_in_website>1</show_in_website>
186
+ <show_in_store>1</show_in_store>
187
+ </custom>
188
+ </fields>
189
+ </datasource>
190
+ </groups>
191
+ </sociallifestream>
192
+ </sections>
193
+ </config>
app/code/community/Magazento/SocialLifestream/lib/idna_convert.class.php ADDED
@@ -0,0 +1,1605 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // {{{ license
3
+
4
+ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
5
+ //
6
+ // +----------------------------------------------------------------------+
7
+ // | This library is free software; you can redistribute it and/or modify |
8
+ // | it under the terms of the GNU Lesser General Public License as |
9
+ // | published by the Free Software Foundation; either version 2.1 of the |
10
+ // | License, or (at your option) any later version. |
11
+ // | |
12
+ // | This library is distributed in the hope that it will be useful, but |
13
+ // | WITHOUT ANY WARRANTY; without even the implied warranty of |
14
+ // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15
+ // | Lesser General Public License for more details. |
16
+ // | |
17
+ // | You should have received a copy of the GNU Lesser General Public |
18
+ // | License along with this library; if not, write to the Free Software |
19
+ // | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
20
+ // | USA. |
21
+ // +----------------------------------------------------------------------+
22
+ //
23
+
24
+ // }}}
25
+
26
+ /**
27
+ * Encode/decode Internationalized Domain Names.
28
+ *
29
+ * The class allows to convert internationalized domain names
30
+ * (see RFC 3490 for details) as they can be used with various registries worldwide
31
+ * to be translated between their original (localized) form and their encoded form
32
+ * as it will be used in the DNS (Domain Name System).
33
+ *
34
+ * The class provides two public methods, encode() and decode(), which do exactly
35
+ * what you would expect them to do. You are allowed to use complete domain names,
36
+ * simple strings and complete email addresses as well. That means, that you might
37
+ * use any of the following notations:
38
+ *
39
+ * - www.n�rgler.com
40
+ * - xn--nrgler-wxa
41
+ * - xn--brse-5qa.xn--knrz-1ra.info
42
+ *
43
+ * Unicode input might be given as either UTF-8 string, UCS-4 string or UCS-4 array.
44
+ * Unicode output is available in the same formats.
45
+ * You can select your preferred format via {@link set_paramter()}.
46
+ *
47
+ * ACE input and output is always expected to be ASCII.
48
+ *
49
+ * @author Matthias Sommerfeld <mso@phlylabs.de>
50
+ * @copyright 2004-2011 phlyLabs Berlin, http://phlylabs.de
51
+ * @version 0.8.0 2011-03-11
52
+ */
53
+ class idna_convert
54
+ {
55
+ // NP See below
56
+
57
+ // Internal settings, do not mess with them
58
+ protected $_punycode_prefix = 'xn--';
59
+ protected $_invalid_ucs = 0x80000000;
60
+ protected $_max_ucs = 0x10FFFF;
61
+ protected $_base = 36;
62
+ protected $_tmin = 1;
63
+ protected $_tmax = 26;
64
+ protected $_skew = 38;
65
+ protected $_damp = 700;
66
+ protected $_initial_bias = 72;
67
+ protected $_initial_n = 0x80;
68
+ protected $_sbase = 0xAC00;
69
+ protected $_lbase = 0x1100;
70
+ protected $_vbase = 0x1161;
71
+ protected $_tbase = 0x11A7;
72
+ protected $_lcount = 19;
73
+ protected $_vcount = 21;
74
+ protected $_tcount = 28;
75
+ protected $_ncount = 588; // _vcount * _tcount
76
+ protected $_scount = 11172; // _lcount * _tcount * _vcount
77
+ protected $_error = false;
78
+
79
+ protected static $_mb_string_overload = null;
80
+
81
+ // See {@link set_paramter()} for details of how to change the following
82
+ // settings from within your script / application
83
+ protected $_api_encoding = 'utf8'; // Default input charset is UTF-8
84
+ protected $_allow_overlong = false; // Overlong UTF-8 encodings are forbidden
85
+ protected $_strict_mode = false; // Behave strict or not
86
+ protected $_idn_version = 2003; // Can be either 2003 (old, default) or 2008
87
+
88
+ /**
89
+ * the constructor
90
+ *
91
+ * @param array $options
92
+ * @return boolean
93
+ * @since 0.5.2
94
+ */
95
+ public function __construct($options = false)
96
+ {
97
+ $this->slast = $this->_sbase + $this->_lcount * $this->_vcount * $this->_tcount;
98
+ // If parameters are given, pass these to the respective method
99
+ if (is_array($options)) {
100
+ $this->set_parameter($options);
101
+ }
102
+
103
+ // populate mbstring overloading cache if not set
104
+ if (self::$_mb_string_overload === null) {
105
+ self::$_mb_string_overload = (extension_loaded('mbstring')
106
+ && (ini_get('mbstring.func_overload') & 0x02) === 0x02);
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Sets a new option value. Available options and values:
112
+ * [encoding - Use either UTF-8, UCS4 as array or UCS4 as string as input ('utf8' for UTF-8,
113
+ * 'ucs4_string' and 'ucs4_array' respectively for UCS4); The output is always UTF-8]
114
+ * [overlong - Unicode does not allow unnecessarily long encodings of chars,
115
+ * to allow this, set this parameter to true, else to false;
116
+ * default is false.]
117
+ * [strict - true: strict mode, good for registration purposes - Causes errors
118
+ * on failures; false: loose mode, ideal for "wildlife" applications
119
+ * by silently ignoring errors and returning the original input instead
120
+ *
121
+ * @param mixed Parameter to set (string: single parameter; array of Parameter => Value pairs)
122
+ * @param string Value to use (if parameter 1 is a string)
123
+ * @return boolean true on success, false otherwise
124
+ */
125
+ public function set_parameter($option, $value = false)
126
+ {
127
+ if (!is_array($option)) {
128
+ $option = array($option => $value);
129
+ }
130
+ foreach ($option as $k => $v) {
131
+ switch ($k) {
132
+ case 'encoding':
133
+ switch ($v) {
134
+ case 'utf8':
135
+ case 'ucs4_string':
136
+ case 'ucs4_array':
137
+ $this->_api_encoding = $v;
138
+ break;
139
+ default:
140
+ $this->_error('Set Parameter: Unknown parameter '.$v.' for option '.$k);
141
+ return false;
142
+ }
143
+ break;
144
+ case 'overlong':
145
+ $this->_allow_overlong = ($v) ? true : false;
146
+ break;
147
+ case 'strict':
148
+ $this->_strict_mode = ($v) ? true : false;
149
+ break;
150
+ case 'idn_version':
151
+ if (in_array($v, array('2003', '2008'))) {
152
+ $this->_idn_version = $v;
153
+ } else {
154
+ $this->_error('Set Parameter: Unknown parameter '.$v.' for option '.$k);
155
+ }
156
+ break;
157
+ case 'encode_german_sz': // Deprecated
158
+ if (!$v) {
159
+ self::$NP['replacemaps'][0xDF] = array(0x73, 0x73);
160
+ } else {
161
+ unset(self::$NP['replacemaps'][0xDF]);
162
+ }
163
+ break;
164
+ default:
165
+ $this->_error('Set Parameter: Unknown option '.$k);
166
+ return false;
167
+ }
168
+ }
169
+ return true;
170
+ }
171
+
172
+ /**
173
+ * Decode a given ACE domain name
174
+ * @param string Domain name (ACE string)
175
+ * [@param string Desired output encoding, see {@link set_parameter}]
176
+ * @return string Decoded Domain name (UTF-8 or UCS-4)
177
+ */
178
+ public function decode($input, $one_time_encoding = false)
179
+ {
180
+ // Optionally set
181
+ if ($one_time_encoding) {
182
+ switch ($one_time_encoding) {
183
+ case 'utf8':
184
+ case 'ucs4_string':
185
+ case 'ucs4_array':
186
+ break;
187
+ default:
188
+ $this->_error('Unknown encoding '.$one_time_encoding);
189
+ return false;
190
+ }
191
+ }
192
+ // Make sure to drop any newline characters around
193
+ $input = trim($input);
194
+
195
+ // Negotiate input and try to determine, whether it is a plain string,
196
+ // an email address or something like a complete URL
197
+ if (strpos($input, '@')) { // Maybe it is an email address
198
+ // No no in strict mode
199
+ if ($this->_strict_mode) {
200
+ $this->_error('Only simple domain name parts can be handled in strict mode');
201
+ return false;
202
+ }
203
+ list ($email_pref, $input) = explode('@', $input, 2);
204
+ $arr = explode('.', $input);
205
+ foreach ($arr as $k => $v) {
206
+ if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) {
207
+ $conv = $this->_decode($v);
208
+ if ($conv) $arr[$k] = $conv;
209
+ }
210
+ }
211
+ $input = join('.', $arr);
212
+ $arr = explode('.', $email_pref);
213
+ foreach ($arr as $k => $v) {
214
+ if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) {
215
+ $conv = $this->_decode($v);
216
+ if ($conv) $arr[$k] = $conv;
217
+ }
218
+ }
219
+ $email_pref = join('.', $arr);
220
+ $return = $email_pref . '@' . $input;
221
+ } elseif (preg_match('![:\./]!', $input)) { // Or a complete domain name (with or without paths / parameters)
222
+ // No no in strict mode
223
+ if ($this->_strict_mode) {
224
+ $this->_error('Only simple domain name parts can be handled in strict mode');
225
+ return false;
226
+ }
227
+ $parsed = parse_url($input);
228
+ if (isset($parsed['host'])) {
229
+ $arr = explode('.', $parsed['host']);
230
+ foreach ($arr as $k => $v) {
231
+ $conv = $this->_decode($v);
232
+ if ($conv) $arr[$k] = $conv;
233
+ }
234
+ $parsed['host'] = join('.', $arr);
235
+ $return =
236
+ (empty($parsed['scheme']) ? '' : $parsed['scheme'].(strtolower($parsed['scheme']) == 'mailto' ? ':' : '://'))
237
+ .(empty($parsed['user']) ? '' : $parsed['user'].(empty($parsed['pass']) ? '' : ':'.$parsed['pass']).'@')
238
+ .$parsed['host']
239
+ .(empty($parsed['port']) ? '' : ':'.$parsed['port'])
240
+ .(empty($parsed['path']) ? '' : $parsed['path'])
241
+ .(empty($parsed['query']) ? '' : '?'.$parsed['query'])
242
+ .(empty($parsed['fragment']) ? '' : '#'.$parsed['fragment']);
243
+ } else { // parse_url seems to have failed, try without it
244
+ $arr = explode('.', $input);
245
+ foreach ($arr as $k => $v) {
246
+ $conv = $this->_decode($v);
247
+ $arr[$k] = ($conv) ? $conv : $v;
248
+ }
249
+ $return = join('.', $arr);
250
+ }
251
+ } else { // Otherwise we consider it being a pure domain name string
252
+ $return = $this->_decode($input);
253
+ if (!$return) $return = $input;
254
+ }
255
+ // The output is UTF-8 by default, other output formats need conversion here
256
+ // If one time encoding is given, use this, else the objects property
257
+ switch (($one_time_encoding) ? $one_time_encoding : $this->_api_encoding) {
258
+ case 'utf8':
259
+ return $return;
260
+ break;
261
+ case 'ucs4_string':
262
+ return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return));
263
+ break;
264
+ case 'ucs4_array':
265
+ return $this->_utf8_to_ucs4($return);
266
+ break;
267
+ default:
268
+ $this->_error('Unsupported output format');
269
+ return false;
270
+ }
271
+ }
272
+
273
+ /**
274
+ * Encode a given UTF-8 domain name
275
+ * @param string Domain name (UTF-8 or UCS-4)
276
+ * [@param string Desired input encoding, see {@link set_parameter}]
277
+ * @return string Encoded Domain name (ACE string)
278
+ */
279
+ public function encode($decoded, $one_time_encoding = false)
280
+ {
281
+ // Forcing conversion of input to UCS4 array
282
+ // If one time encoding is given, use this, else the objects property
283
+ switch ($one_time_encoding ? $one_time_encoding : $this->_api_encoding) {
284
+ case 'utf8':
285
+ $decoded = $this->_utf8_to_ucs4($decoded);
286
+ break;
287
+ case 'ucs4_string':
288
+ $decoded = $this->_ucs4_string_to_ucs4($decoded);
289
+ case 'ucs4_array':
290
+ break;
291
+ default:
292
+ $this->_error('Unsupported input format: '.($one_time_encoding ? $one_time_encoding : $this->_api_encoding));
293
+ return false;
294
+ }
295
+
296
+ // No input, no output, what else did you expect?
297
+ if (empty($decoded)) return '';
298
+
299
+ // Anchors for iteration
300
+ $last_begin = 0;
301
+ // Output string
302
+ $output = '';
303
+ foreach ($decoded as $k => $v) {
304
+ // Make sure to use just the plain dot
305
+ switch($v) {
306
+ case 0x3002:
307
+ case 0xFF0E:
308
+ case 0xFF61:
309
+ $decoded[$k] = 0x2E;
310
+ // Right, no break here, the above are converted to dots anyway
311
+ // Stumbling across an anchoring character
312
+ case 0x2E:
313
+ case 0x2F:
314
+ case 0x3A:
315
+ case 0x3F:
316
+ case 0x40:
317
+ // Neither email addresses nor URLs allowed in strict mode
318
+ if ($this->_strict_mode) {
319
+ $this->_error('Neither email addresses nor URLs are allowed in strict mode.');
320
+ return false;
321
+ } else {
322
+ // Skip first char
323
+ if ($k) {
324
+ $encoded = '';
325
+ $encoded = $this->_encode(array_slice($decoded, $last_begin, (($k)-$last_begin)));
326
+ if ($encoded) {
327
+ $output .= $encoded;
328
+ } else {
329
+ $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($k)-$last_begin)));
330
+ }
331
+ $output .= chr($decoded[$k]);
332
+ }
333
+ $last_begin = $k + 1;
334
+ }
335
+ }
336
+ }
337
+ // Catch the rest of the string
338
+ if ($last_begin) {
339
+ $inp_len = sizeof($decoded);
340
+ $encoded = '';
341
+ $encoded = $this->_encode(array_slice($decoded, $last_begin, (($inp_len)-$last_begin)));
342
+ if ($encoded) {
343
+ $output .= $encoded;
344
+ } else {
345
+ $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($inp_len)-$last_begin)));
346
+ }
347
+ return $output;
348
+ } else {
349
+ if ($output = $this->_encode($decoded)) {
350
+ return $output;
351
+ } else {
352
+ return $this->_ucs4_to_utf8($decoded);
353
+ }
354
+ }
355
+ }
356
+
357
+ /**
358
+ * Removes a weakness of encode(), which cannot properly handle URIs but instead encodes their
359
+ * path or query components, too.
360
+ * @param string $uri Expects the URI as a UTF-8 (or ASCII) string
361
+ * @return string The URI encoded to Punycode, everything but the host component is left alone
362
+ * @since 0.6.4
363
+ */
364
+ public function encode_uri($uri)
365
+ {
366
+ $parsed = parse_url($uri);
367
+ if (!isset($parsed['host'])) {
368
+ $this->_error('The given string does not look like a URI');
369
+ return false;
370
+ }
371
+ $arr = explode('.', $parsed['host']);
372
+ foreach ($arr as $k => $v) {
373
+ $conv = $this->encode($v, 'utf8');
374
+ if ($conv) $arr[$k] = $conv;
375
+ }
376
+ $parsed['host'] = join('.', $arr);
377
+ $return =
378
+ (empty($parsed['scheme']) ? '' : $parsed['scheme'].(strtolower($parsed['scheme']) == 'mailto' ? ':' : '://'))
379
+ .(empty($parsed['user']) ? '' : $parsed['user'].(empty($parsed['pass']) ? '' : ':'.$parsed['pass']).'@')
380
+ .$parsed['host']
381
+ .(empty($parsed['port']) ? '' : ':'.$parsed['port'])
382
+ .(empty($parsed['path']) ? '' : $parsed['path'])
383
+ .(empty($parsed['query']) ? '' : '?'.$parsed['query'])
384
+ .(empty($parsed['fragment']) ? '' : '#'.$parsed['fragment']);
385
+ return $return;
386
+ }
387
+
388
+ /**
389
+ * Use this method to get the last error ocurred
390
+ * @param void
391
+ * @return string The last error, that occured
392
+ */
393
+ public function get_last_error()
394
+ {
395
+ return $this->_error;
396
+ }
397
+
398
+ /**
399
+ * The actual decoding algorithm
400
+ * @param string
401
+ * @return mixed
402
+ */
403
+ protected function _decode($encoded)
404
+ {
405
+ $decoded = array();
406
+ // find the Punycode prefix
407
+ if (!preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $encoded)) {
408
+ $this->_error('This is not a punycode string');
409
+ return false;
410
+ }
411
+ $encode_test = preg_replace('!^'.preg_quote($this->_punycode_prefix, '!').'!', '', $encoded);
412
+ // If nothing left after removing the prefix, it is hopeless
413
+ if (!$encode_test) {
414
+ $this->_error('The given encoded string was empty');
415
+ return false;
416
+ }
417
+ // Find last occurence of the delimiter
418
+ $delim_pos = strrpos($encoded, '-');
419
+ if ($delim_pos > self::byteLength($this->_punycode_prefix)) {
420
+ for ($k = self::byteLength($this->_punycode_prefix); $k < $delim_pos; ++$k) {
421
+ $decoded[] = ord($encoded{$k});
422
+ }
423
+ }
424
+ $deco_len = count($decoded);
425
+ $enco_len = self::byteLength($encoded);
426
+
427
+ // Wandering through the strings; init
428
+ $is_first = true;
429
+ $bias = $this->_initial_bias;
430
+ $idx = 0;
431
+ $char = $this->_initial_n;
432
+
433
+ for ($enco_idx = ($delim_pos) ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) {
434
+ for ($old_idx = $idx, $w = 1, $k = $this->_base; 1 ; $k += $this->_base) {
435
+ $digit = $this->_decode_digit($encoded{$enco_idx++});
436
+ $idx += $digit * $w;
437
+ $t = ($k <= $bias) ? $this->_tmin :
438
+ (($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias));
439
+ if ($digit < $t) break;
440
+ $w = (int) ($w * ($this->_base - $t));
441
+ }
442
+ $bias = $this->_adapt($idx - $old_idx, $deco_len + 1, $is_first);
443
+ $is_first = false;
444
+ $char += (int) ($idx / ($deco_len + 1));
445
+ $idx %= ($deco_len + 1);
446
+ if ($deco_len > 0) {
447
+ // Make room for the decoded char
448
+ for ($i = $deco_len; $i > $idx; $i--) $decoded[$i] = $decoded[($i - 1)];
449
+ }
450
+ $decoded[$idx++] = $char;
451
+ }
452
+ return $this->_ucs4_to_utf8($decoded);
453
+ }
454
+
455
+ /**
456
+ * The actual encoding algorithm
457
+ * @param string
458
+ * @return mixed
459
+ */
460
+ protected function _encode($decoded)
461
+ {
462
+ // We cannot encode a domain name containing the Punycode prefix
463
+ $extract = self::byteLength($this->_punycode_prefix);
464
+ $check_pref = $this->_utf8_to_ucs4($this->_punycode_prefix);
465
+ $check_deco = array_slice($decoded, 0, $extract);
466
+
467
+ if ($check_pref == $check_deco) {
468
+ $this->_error('This is already a punycode string');
469
+ return false;
470
+ }
471
+ // We will not try to encode strings consisting of basic code points only
472
+ $encodable = false;
473
+ foreach ($decoded as $k => $v) {
474
+ if ($v > 0x7a) {
475
+ $encodable = true;
476
+ break;
477
+ }
478
+ }
479
+ if (!$encodable) {
480
+ $this->_error('The given string does not contain encodable chars');
481
+ return false;
482
+ }
483
+ // Do NAMEPREP
484
+ $decoded = $this->_nameprep($decoded);
485
+ if (!$decoded || !is_array($decoded)) return false; // NAMEPREP failed
486
+ $deco_len = count($decoded);
487
+ if (!$deco_len) return false; // Empty array
488
+ $codecount = 0; // How many chars have been consumed
489
+ $encoded = '';
490
+ // Copy all basic code points to output
491
+ for ($i = 0; $i < $deco_len; ++$i) {
492
+ $test = $decoded[$i];
493
+ // Will match [-0-9a-zA-Z]
494
+ if ((0x2F < $test && $test < 0x40) || (0x40 < $test && $test < 0x5B)
495
+ || (0x60 < $test && $test <= 0x7B) || (0x2D == $test)) {
496
+ $encoded .= chr($decoded[$i]);
497
+ $codecount++;
498
+ }
499
+ }
500
+ if ($codecount == $deco_len) return $encoded; // All codepoints were basic ones
501
+
502
+ // Start with the prefix; copy it to output
503
+ $encoded = $this->_punycode_prefix.$encoded;
504
+ // If we have basic code points in output, add an hyphen to the end
505
+ if ($codecount) $encoded .= '-';
506
+ // Now find and encode all non-basic code points
507
+ $is_first = true;
508
+ $cur_code = $this->_initial_n;
509
+ $bias = $this->_initial_bias;
510
+ $delta = 0;
511
+ while ($codecount < $deco_len) {
512
+ // Find the smallest code point >= the current code point and
513
+ // remember the last ouccrence of it in the input
514
+ for ($i = 0, $next_code = $this->_max_ucs; $i < $deco_len; $i++) {
515
+ if ($decoded[$i] >= $cur_code && $decoded[$i] <= $next_code) {
516
+ $next_code = $decoded[$i];
517
+ }
518
+ }
519
+ $delta += ($next_code - $cur_code) * ($codecount + 1);
520
+ $cur_code = $next_code;
521
+
522
+ // Scan input again and encode all characters whose code point is $cur_code
523
+ for ($i = 0; $i < $deco_len; $i++) {
524
+ if ($decoded[$i] < $cur_code) {
525
+ $delta++;
526
+ } elseif ($decoded[$i] == $cur_code) {
527
+ for ($q = $delta, $k = $this->_base; 1; $k += $this->_base) {
528
+ $t = ($k <= $bias) ? $this->_tmin :
529
+ (($k >= $bias + $this->_tmax) ? $this->_tmax : $k - $bias);
530
+ if ($q < $t) break;
531
+ $encoded .= $this->_encode_digit(intval($t + (($q - $t) % ($this->_base - $t)))); //v0.4.5 Changed from ceil() to intval()
532
+ $q = (int) (($q - $t) / ($this->_base - $t));
533
+ }
534
+ $encoded .= $this->_encode_digit($q);
535
+ $bias = $this->_adapt($delta, $codecount+1, $is_first);
536
+ $codecount++;
537
+ $delta = 0;
538
+ $is_first = false;
539
+ }
540
+ }
541
+ $delta++;
542
+ $cur_code++;
543
+ }
544
+ return $encoded;
545
+ }
546
+
547
+ /**
548
+ * Adapt the bias according to the current code point and position
549
+ * @param int $delta
550
+ * @param int $npoints
551
+ * @param int $is_first
552
+ * @return int
553
+ */
554
+ protected function _adapt($delta, $npoints, $is_first)
555
+ {
556
+ $delta = intval($is_first ? ($delta / $this->_damp) : ($delta / 2));
557
+ $delta += intval($delta / $npoints);
558
+ for ($k = 0; $delta > (($this->_base - $this->_tmin) * $this->_tmax) / 2; $k += $this->_base) {
559
+ $delta = intval($delta / ($this->_base - $this->_tmin));
560
+ }
561
+ return intval($k + ($this->_base - $this->_tmin + 1) * $delta / ($delta + $this->_skew));
562
+ }
563
+
564
+ /**
565
+ * Encoding a certain digit
566
+ * @param int $d
567
+ * @return string
568
+ */
569
+ protected function _encode_digit($d)
570
+ {
571
+ return chr($d + 22 + 75 * ($d < 26));
572
+ }
573
+
574
+ /**
575
+ * Decode a certain digit
576
+ * @param int $cp
577
+ * @return int
578
+ */
579
+ protected function _decode_digit($cp)
580
+ {
581
+ $cp = ord($cp);
582
+ return ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $this->_base));
583
+ }
584
+
585
+ /**
586
+ * Internal error handling method
587
+ * @param string $error
588
+ */
589
+ protected function _error($error = '')
590
+ {
591
+ $this->_error = $error;
592
+ }
593
+
594
+ /**
595
+ * Do Nameprep according to RFC3491 and RFC3454
596
+ * @param array Unicode Characters
597
+ * @return string Unicode Characters, Nameprep'd
598
+ */
599
+ protected function _nameprep($input)
600
+ {
601
+ $output = array();
602
+ $error = false;
603
+ //
604
+ // Mapping
605
+ // Walking through the input array, performing the required steps on each of
606
+ // the input chars and putting the result into the output array
607
+ // While mapping required chars we apply the cannonical ordering
608
+ foreach ($input as $v) {
609
+ // Map to nothing == skip that code point
610
+ if (in_array($v, self::$NP['map_nothing'])) continue;
611
+ // Try to find prohibited input
612
+ if (in_array($v, self::$NP['prohibit']) || in_array($v, self::$NP['general_prohibited'])) {
613
+ $this->_error('NAMEPREP: Prohibited input U+'.sprintf('%08X', $v));
614
+ return false;
615
+ }
616
+ foreach (self::$NP['prohibit_ranges'] as $range) {
617
+ if ($range[0] <= $v && $v <= $range[1]) {
618
+ $this->_error('NAMEPREP: Prohibited input U+'.sprintf('%08X', $v));
619
+ return false;
620
+ }
621
+ }
622
+
623
+ if (0xAC00 <= $v && $v <= 0xD7AF) {
624
+ // Hangul syllable decomposition
625
+ foreach ($this->_hangul_decompose($v) as $out) {
626
+ $output[] = (int) $out;
627
+ }
628
+ } elseif (($this->_idn_version == '2003') && isset(self::$NP['replacemaps'][$v])) {
629
+ // There's a decomposition mapping for that code point
630
+ // Decompositions only in version 2003 (original) of IDNA
631
+ foreach ($this->_apply_cannonical_ordering(self::$NP['replacemaps'][$v]) as $out) {
632
+ $output[] = (int) $out;
633
+ }
634
+ } else {
635
+ $output[] = (int) $v;
636
+ }
637
+ }
638
+ // Before applying any Combining, try to rearrange any Hangul syllables
639
+ $output = $this->_hangul_compose($output);
640
+ //
641
+ // Combine code points
642
+ //
643
+ $last_class = 0;
644
+ $last_starter = 0;
645
+ $out_len = count($output);
646
+ for ($i = 0; $i < $out_len; ++$i) {
647
+ $class = $this->_get_combining_class($output[$i]);
648
+ if ((!$last_class || $last_class > $class) && $class) {
649
+ // Try to match
650
+ $seq_len = $i - $last_starter;
651
+ $out = $this->_combine(array_slice($output, $last_starter, $seq_len));
652
+ // On match: Replace the last starter with the composed character and remove
653
+ // the now redundant non-starter(s)
654
+ if ($out) {
655
+ $output[$last_starter] = $out;
656
+ if (count($out) != $seq_len) {
657
+ for ($j = $i+1; $j < $out_len; ++$j) $output[$j-1] = $output[$j];
658
+ unset($output[$out_len]);
659
+ }
660
+ // Rewind the for loop by one, since there can be more possible compositions
661
+ $i--;
662
+ $out_len--;
663
+ $last_class = ($i == $last_starter) ? 0 : $this->_get_combining_class($output[$i-1]);
664
+ continue;
665
+ }
666
+ }
667
+ // The current class is 0
668
+ if (!$class) $last_starter = $i;
669
+ $last_class = $class;
670
+ }
671
+ return $output;
672
+ }
673
+
674
+ /**
675
+ * Decomposes a Hangul syllable
676
+ * (see http://www.unicode.org/unicode/reports/tr15/#Hangul
677
+ * @param integer 32bit UCS4 code point
678
+ * @return array Either Hangul Syllable decomposed or original 32bit value as one value array
679
+ */
680
+ protected function _hangul_decompose($char)
681
+ {
682
+ $sindex = (int) $char - $this->_sbase;
683
+ if ($sindex < 0 || $sindex >= $this->_scount) return array($char);
684
+ $result = array();
685
+ $result[] = (int) $this->_lbase + $sindex / $this->_ncount;
686
+ $result[] = (int) $this->_vbase + ($sindex % $this->_ncount) / $this->_tcount;
687
+ $T = intval($this->_tbase + $sindex % $this->_tcount);
688
+ if ($T != $this->_tbase) $result[] = $T;
689
+ return $result;
690
+ }
691
+ /**
692
+ * Ccomposes a Hangul syllable
693
+ * (see http://www.unicode.org/unicode/reports/tr15/#Hangul
694
+ * @param array Decomposed UCS4 sequence
695
+ * @return array UCS4 sequence with syllables composed
696
+ */
697
+ protected function _hangul_compose($input)
698
+ {
699
+ $inp_len = count($input);
700
+ if (!$inp_len) return array();
701
+ $result = array();
702
+ $last = (int) $input[0];
703
+ $result[] = $last; // copy first char from input to output
704
+
705
+ for ($i = 1; $i < $inp_len; ++$i) {
706
+ $char = (int) $input[$i];
707
+ $sindex = $last - $this->_sbase;
708
+ $lindex = $last - $this->_lbase;
709
+ $vindex = $char - $this->_vbase;
710
+ $tindex = $char - $this->_tbase;
711
+ // Find out, whether two current characters are LV and T
712
+ if (0 <= $sindex && $sindex < $this->_scount && ($sindex % $this->_tcount == 0)
713
+ && 0 <= $tindex && $tindex <= $this->_tcount) {
714
+ // create syllable of form LVT
715
+ $last += $tindex;
716
+ $result[(count($result) - 1)] = $last; // reset last
717
+ continue; // discard char
718
+ }
719
+ // Find out, whether two current characters form L and V
720
+ if (0 <= $lindex && $lindex < $this->_lcount && 0 <= $vindex && $vindex < $this->_vcount) {
721
+ // create syllable of form LV
722
+ $last = (int) $this->_sbase + ($lindex * $this->_vcount + $vindex) * $this->_tcount;
723
+ $result[(count($result) - 1)] = $last; // reset last
724
+ continue; // discard char
725
+ }
726
+ // if neither case was true, just add the character
727
+ $last = $char;
728
+ $result[] = $char;
729
+ }
730
+ return $result;
731
+ }
732
+
733
+ /**
734
+ * Returns the combining class of a certain wide char
735
+ * @param integer Wide char to check (32bit integer)
736
+ * @return integer Combining class if found, else 0
737
+ */
738
+ protected function _get_combining_class($char)
739
+ {
740
+ return isset(self::$NP['norm_combcls'][$char]) ? self::$NP['norm_combcls'][$char] : 0;
741
+ }
742
+
743
+ /**
744
+ * Applies the cannonical ordering of a decomposed UCS4 sequence
745
+ * @param array Decomposed UCS4 sequence
746
+ * @return array Ordered USC4 sequence
747
+ */
748
+ protected function _apply_cannonical_ordering($input)
749
+ {
750
+ $swap = true;
751
+ $size = count($input);
752
+ while ($swap) {
753
+ $swap = false;
754
+ $last = $this->_get_combining_class(intval($input[0]));
755
+ for ($i = 0; $i < $size-1; ++$i) {
756
+ $next = $this->_get_combining_class(intval($input[$i+1]));
757
+ if ($next != 0 && $last > $next) {
758
+ // Move item leftward until it fits
759
+ for ($j = $i + 1; $j > 0; --$j) {
760
+ if ($this->_get_combining_class(intval($input[$j-1])) <= $next) break;
761
+ $t = intval($input[$j]);
762
+ $input[$j] = intval($input[$j-1]);
763
+ $input[$j-1] = $t;
764
+ $swap = true;
765
+ }
766
+ // Reentering the loop looking at the old character again
767
+ $next = $last;
768
+ }
769
+ $last = $next;
770
+ }
771
+ }
772
+ return $input;
773
+ }
774
+
775
+ /**
776
+ * Do composition of a sequence of starter and non-starter
777
+ * @param array UCS4 Decomposed sequence
778
+ * @return array Ordered USC4 sequence
779
+ */
780
+ protected function _combine($input)
781
+ {
782
+ $inp_len = count($input);
783
+ foreach (self::$NP['replacemaps'] as $np_src => $np_target) {
784
+ if ($np_target[0] != $input[0]) continue;
785
+ if (count($np_target) != $inp_len) continue;
786
+ $hit = false;
787
+ foreach ($input as $k2 => $v2) {
788
+ if ($v2 == $np_target[$k2]) {
789
+ $hit = true;
790
+ } else {
791
+ $hit = false;
792
+ break;
793
+ }
794
+ }
795
+ if ($hit) return $np_src;
796
+ }
797
+ return false;
798
+ }
799
+
800
+ /**
801
+ * This converts an UTF-8 encoded string to its UCS-4 representation
802
+ * By talking about UCS-4 "strings" we mean arrays of 32bit integers representing
803
+ * each of the "chars". This is due to PHP not being able to handle strings with
804
+ * bit depth different from 8. This apllies to the reverse method _ucs4_to_utf8(), too.
805
+ * The following UTF-8 encodings are supported:
806
+ * bytes bits representation
807
+ * 1 7 0xxxxxxx
808
+ * 2 11 110xxxxx 10xxxxxx
809
+ * 3 16 1110xxxx 10xxxxxx 10xxxxxx
810
+ * 4 21 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
811
+ * 5 26 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
812
+ * 6 31 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
813
+ * Each x represents a bit that can be used to store character data.
814
+ * The five and six byte sequences are part of Annex D of ISO/IEC 10646-1:2000
815
+ * @param string $input
816
+ * @return string
817
+ */
818
+ protected function _utf8_to_ucs4($input)
819
+ {
820
+ $output = array();
821
+ $out_len = 0;
822
+ $inp_len = self::byteLength($input);
823
+ $mode = 'next';
824
+ $test = 'none';
825
+ for ($k = 0; $k < $inp_len; ++$k) {
826
+ $v = ord($input{$k}); // Extract byte from input string
827
+ if ($v < 128) { // We found an ASCII char - put into stirng as is
828
+ $output[$out_len] = $v;
829
+ ++$out_len;
830
+ if ('add' == $mode) {
831
+ $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k);
832
+ return false;
833
+ }
834
+ continue;
835
+ }
836
+ if ('next' == $mode) { // Try to find the next start byte; determine the width of the Unicode char
837
+ $start_byte = $v;
838
+ $mode = 'add';
839
+ $test = 'range';
840
+ if ($v >> 5 == 6) { // &110xxxxx 10xxxxx
841
+ $next_byte = 0; // Tells, how many times subsequent bitmasks must rotate 6bits to the left
842
+ $v = ($v - 192) << 6;
843
+ } elseif ($v >> 4 == 14) { // &1110xxxx 10xxxxxx 10xxxxxx
844
+ $next_byte = 1;
845
+ $v = ($v - 224) << 12;
846
+ } elseif ($v >> 3 == 30) { // &11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
847
+ $next_byte = 2;
848
+ $v = ($v - 240) << 18;
849
+ } elseif ($v >> 2 == 62) { // &111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
850
+ $next_byte = 3;
851
+ $v = ($v - 248) << 24;
852
+ } elseif ($v >> 1 == 126) { // &1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
853
+ $next_byte = 4;
854
+ $v = ($v - 252) << 30;
855
+ } else {
856
+ $this->_error('This might be UTF-8, but I don\'t understand it at byte '.$k);
857
+ return false;
858
+ }
859
+ if ('add' == $mode) {
860
+ $output[$out_len] = (int) $v;
861
+ ++$out_len;
862
+ continue;
863
+ }
864
+ }
865
+ if ('add' == $mode) {
866
+ if (!$this->_allow_overlong && $test == 'range') {
867
+ $test = 'none';
868
+ if (($v < 0xA0 && $start_byte == 0xE0) || ($v < 0x90 && $start_byte == 0xF0) || ($v > 0x8F && $start_byte == 0xF4)) {
869
+ $this->_error('Bogus UTF-8 character detected (out of legal range) at byte '.$k);
870
+ return false;
871
+ }
872
+ }
873
+ if ($v >> 6 == 2) { // Bit mask must be 10xxxxxx
874
+ $v = ($v - 128) << ($next_byte * 6);
875
+ $output[($out_len - 1)] += $v;
876
+ --$next_byte;
877
+ } else {
878
+ $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k);
879
+ return false;
880
+ }
881
+ if ($next_byte < 0) {
882
+ $mode = 'next';
883
+ }
884
+ }
885
+ } // for
886
+ return $output;
887
+ }
888
+
889
+ /**
890
+ * Convert UCS-4 string into UTF-8 string
891
+ * See _utf8_to_ucs4() for details
892
+ * @param string $input
893
+ * @return string
894
+ */
895
+ protected function _ucs4_to_utf8($input)
896
+ {
897
+ $output = '';
898
+ foreach ($input as $k => $v) {
899
+ if ($v < 128) { // 7bit are transferred literally
900
+ $output .= chr($v);
901
+ } elseif ($v < (1 << 11)) { // 2 bytes
902
+ $output .= chr(192+($v >> 6)).chr(128+($v & 63));
903
+ } elseif ($v < (1 << 16)) { // 3 bytes
904
+ $output .= chr(224+($v >> 12)).chr(128+(($v >> 6) & 63)).chr(128+($v & 63));
905
+ } elseif ($v < (1 << 21)) { // 4 bytes
906
+ $output .= chr(240+($v >> 18)).chr(128+(($v >> 12) & 63)).chr(128+(($v >> 6) & 63)).chr(128+($v & 63));
907
+ } elseif (self::$safe_mode) {
908
+ $output .= self::$safe_char;
909
+ } else {
910
+ $this->_error('Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k);
911
+ return false;
912
+ }
913
+ }
914
+ return $output;
915
+ }
916
+
917
+ /**
918
+ * Convert UCS-4 array into UCS-4 string
919
+ *
920
+ * @param array $input
921
+ * @return string
922
+ */
923
+ protected function _ucs4_to_ucs4_string($input)
924
+ {
925
+ $output = '';
926
+ // Take array values and split output to 4 bytes per value
927
+ // The bit mask is 255, which reads &11111111
928
+ foreach ($input as $v) {
929
+ $output .= chr(($v >> 24) & 255).chr(($v >> 16) & 255).chr(($v >> 8) & 255).chr($v & 255);
930
+ }
931
+ return $output;
932
+ }
933
+
934
+ /**
935
+ * Convert UCS-4 strin into UCS-4 garray
936
+ *
937
+ * @param string $input
938
+ * @return array
939
+ */
940
+ protected function _ucs4_string_to_ucs4($input)
941
+ {
942
+ $output = array();
943
+ $inp_len = self::byteLength($input);
944
+ // Input length must be dividable by 4
945
+ if ($inp_len % 4) {
946
+ $this->_error('Input UCS4 string is broken');
947
+ return false;
948
+ }
949
+ // Empty input - return empty output
950
+ if (!$inp_len) return $output;
951
+ for ($i = 0, $out_len = -1; $i < $inp_len; ++$i) {
952
+ // Increment output position every 4 input bytes
953
+ if (!($i % 4)) {
954
+ $out_len++;
955
+ $output[$out_len] = 0;
956
+ }
957
+ $output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4) ) );
958
+ }
959
+ return $output;
960
+ }
961
+
962
+ /**
963
+ * Gets the length of a string in bytes even if mbstring function
964
+ * overloading is turned on
965
+ *
966
+ * @param string $string the string for which to get the length.
967
+ * @return integer the length of the string in bytes.
968
+ */
969
+ protected static function byteLength($string)
970
+ {
971
+ if (self::$_mb_string_overload) {
972
+ return mb_strlen($string, '8bit');
973
+ }
974
+ return strlen((binary) $string);
975
+ }
976
+
977
+ /**
978
+ * Attempts to return a concrete IDNA instance.
979
+ *
980
+ * @param array $params Set of paramaters
981
+ * @return idna_convert
982
+ * @access public
983
+ */
984
+ public function getInstance($params = array())
985
+ {
986
+ return new idna_convert($params);
987
+ }
988
+
989
+ /**
990
+ * Attempts to return a concrete IDNA instance for either php4 or php5,
991
+ * only creating a new instance if no IDNA instance with the same
992
+ * parameters currently exists.
993
+ *
994
+ * @param array $params Set of paramaters
995
+ *
996
+ * @return object idna_convert
997
+ * @access public
998
+ */
999
+ public function singleton($params = array())
1000
+ {
1001
+ static $instances;
1002
+ if (!isset($instances)) {
1003
+ $instances = array();
1004
+ }
1005
+ $signature = serialize($params);
1006
+ if (!isset($instances[$signature])) {
1007
+ $instances[$signature] = idna_convert::getInstance($params);
1008
+ }
1009
+ return $instances[$signature];
1010
+ }
1011
+
1012
+ /**
1013
+ * Holds all relevant mapping tables
1014
+ * See RFC3454 for details
1015
+ *
1016
+ * @private array
1017
+ * @since 0.5.2
1018
+ */
1019
+ protected static $NP = array
1020
+ ('map_nothing' => array(0xAD, 0x34F, 0x1806, 0x180B, 0x180C, 0x180D, 0x200B, 0x200C
1021
+ ,0x200D, 0x2060, 0xFE00, 0xFE01, 0xFE02, 0xFE03, 0xFE04, 0xFE05, 0xFE06, 0xFE07
1022
+ ,0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C, 0xFE0D, 0xFE0E, 0xFE0F, 0xFEFF
1023
+ )
1024
+ ,'general_prohibited' => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
1025
+ ,20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 ,33, 34, 35, 36, 37, 38, 39, 40, 41, 42
1026
+ ,43, 44, 47, 59, 60, 61, 62, 63, 64, 91, 92, 93, 94, 95, 96, 123, 124, 125, 126, 127, 0x3002
1027
+ )
1028
+ ,'prohibit' => array(0xA0, 0x340, 0x341, 0x6DD, 0x70F, 0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003
1029
+ ,0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x200B, 0x200C, 0x200D, 0x200E, 0x200F
1030
+ ,0x2028, 0x2029, 0x202A, 0x202B, 0x202C, 0x202D, 0x202E, 0x202F, 0x205F, 0x206A, 0x206B, 0x206C
1031
+ ,0x206D, 0x206E, 0x206F, 0x3000, 0xFEFF, 0xFFF9, 0xFFFA, 0xFFFB, 0xFFFC, 0xFFFD, 0xFFFE, 0xFFFF
1032
+ ,0x1FFFE, 0x1FFFF, 0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE, 0x5FFFF, 0x6FFFE
1033
+ ,0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE, 0x8FFFF, 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF
1034
+ ,0xCFFFE, 0xCFFFF, 0xDFFFE, 0xDFFFF, 0xE0001, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF, 0x10FFFE, 0x10FFFF
1035
+ )
1036
+ ,'prohibit_ranges' => array(array(0x80, 0x9F), array(0x2060, 0x206F), array(0x1D173, 0x1D17A)
1037
+ ,array(0xE000, 0xF8FF) ,array(0xF0000, 0xFFFFD), array(0x100000, 0x10FFFD)
1038
+ ,array(0xFDD0, 0xFDEF), array(0xD800, 0xDFFF), array(0x2FF0, 0x2FFB), array(0xE0020, 0xE007F)
1039
+ )
1040
+ ,'replacemaps' => array(0x41 => array(0x61), 0x42 => array(0x62), 0x43 => array(0x63)
1041
+ ,0x44 => array(0x64), 0x45 => array(0x65), 0x46 => array(0x66), 0x47 => array(0x67)
1042
+ ,0x48 => array(0x68), 0x49 => array(0x69), 0x4A => array(0x6A), 0x4B => array(0x6B)
1043
+ ,0x4C => array(0x6C), 0x4D => array(0x6D), 0x4E => array(0x6E), 0x4F => array(0x6F)
1044
+ ,0x50 => array(0x70), 0x51 => array(0x71), 0x52 => array(0x72), 0x53 => array(0x73)
1045
+ ,0x54 => array(0x74), 0x55 => array(0x75), 0x56 => array(0x76), 0x57 => array(0x77)
1046
+ ,0x58 => array(0x78), 0x59 => array(0x79), 0x5A => array(0x7A), 0xB5 => array(0x3BC)
1047
+ ,0xC0 => array(0xE0), 0xC1 => array(0xE1), 0xC2 => array(0xE2), 0xC3 => array(0xE3)
1048
+ ,0xC4 => array(0xE4), 0xC5 => array(0xE5), 0xC6 => array(0xE6), 0xC7 => array(0xE7)
1049
+ ,0xC8 => array(0xE8), 0xC9 => array(0xE9), 0xCA => array(0xEA), 0xCB => array(0xEB)
1050
+ ,0xCC => array(0xEC), 0xCD => array(0xED), 0xCE => array(0xEE), 0xCF => array(0xEF)
1051
+ ,0xD0 => array(0xF0), 0xD1 => array(0xF1), 0xD2 => array(0xF2), 0xD3 => array(0xF3)
1052
+ ,0xD4 => array(0xF4), 0xD5 => array(0xF5), 0xD6 => array(0xF6), 0xD8 => array(0xF8)
1053
+ ,0xD9 => array(0xF9), 0xDA => array(0xFA), 0xDB => array(0xFB), 0xDC => array(0xFC)
1054
+ ,0xDD => array(0xFD), 0xDE => array(0xFE), 0xDF => array(0x73, 0x73)
1055
+ ,0x100 => array(0x101), 0x102 => array(0x103), 0x104 => array(0x105)
1056
+ ,0x106 => array(0x107), 0x108 => array(0x109), 0x10A => array(0x10B)
1057
+ ,0x10C => array(0x10D), 0x10E => array(0x10F), 0x110 => array(0x111)
1058
+ ,0x112 => array(0x113), 0x114 => array(0x115), 0x116 => array(0x117)
1059
+ ,0x118 => array(0x119), 0x11A => array(0x11B), 0x11C => array(0x11D)
1060
+ ,0x11E => array(0x11F), 0x120 => array(0x121), 0x122 => array(0x123)
1061
+ ,0x124 => array(0x125), 0x126 => array(0x127), 0x128 => array(0x129)
1062
+ ,0x12A => array(0x12B), 0x12C => array(0x12D), 0x12E => array(0x12F)
1063
+ ,0x130 => array(0x69, 0x307), 0x132 => array(0x133), 0x134 => array(0x135)
1064
+ ,0x136 => array(0x137), 0x139 => array(0x13A), 0x13B => array(0x13C)
1065
+ ,0x13D => array(0x13E), 0x13F => array(0x140), 0x141 => array(0x142)
1066
+ ,0x143 => array(0x144), 0x145 => array(0x146), 0x147 => array(0x148)
1067
+ ,0x149 => array(0x2BC, 0x6E), 0x14A => array(0x14B), 0x14C => array(0x14D)
1068
+ ,0x14E => array(0x14F), 0x150 => array(0x151), 0x152 => array(0x153)
1069
+ ,0x154 => array(0x155), 0x156 => array(0x157), 0x158 => array(0x159)
1070
+ ,0x15A => array(0x15B), 0x15C => array(0x15D), 0x15E => array(0x15F)
1071
+ ,0x160 => array(0x161), 0x162 => array(0x163), 0x164 => array(0x165)
1072
+ ,0x166 => array(0x167), 0x168 => array(0x169), 0x16A => array(0x16B)
1073
+ ,0x16C => array(0x16D), 0x16E => array(0x16F), 0x170 => array(0x171)
1074
+ ,0x172 => array(0x173), 0x174 => array(0x175), 0x176 => array(0x177)
1075
+ ,0x178 => array(0xFF), 0x179 => array(0x17A), 0x17B => array(0x17C)
1076
+ ,0x17D => array(0x17E), 0x17F => array(0x73), 0x181 => array(0x253)
1077
+ ,0x182 => array(0x183), 0x184 => array(0x185), 0x186 => array(0x254)
1078
+ ,0x187 => array(0x188), 0x189 => array(0x256), 0x18A => array(0x257)
1079
+ ,0x18B => array(0x18C), 0x18E => array(0x1DD), 0x18F => array(0x259)
1080
+ ,0x190 => array(0x25B), 0x191 => array(0x192), 0x193 => array(0x260)
1081
+ ,0x194 => array(0x263), 0x196 => array(0x269), 0x197 => array(0x268)
1082
+ ,0x198 => array(0x199), 0x19C => array(0x26F), 0x19D => array(0x272)
1083
+ ,0x19F => array(0x275), 0x1A0 => array(0x1A1), 0x1A2 => array(0x1A3)
1084
+ ,0x1A4 => array(0x1A5), 0x1A6 => array(0x280), 0x1A7 => array(0x1A8)
1085
+ ,0x1A9 => array(0x283), 0x1AC => array(0x1AD), 0x1AE => array(0x288)
1086
+ ,0x1AF => array(0x1B0), 0x1B1 => array(0x28A), 0x1B2 => array(0x28B)
1087
+ ,0x1B3 => array(0x1B4), 0x1B5 => array(0x1B6), 0x1B7 => array(0x292)
1088
+ ,0x1B8 => array(0x1B9), 0x1BC => array(0x1BD), 0x1C4 => array(0x1C6)
1089
+ ,0x1C5 => array(0x1C6), 0x1C7 => array(0x1C9), 0x1C8 => array(0x1C9)
1090
+ ,0x1CA => array(0x1CC), 0x1CB => array(0x1CC), 0x1CD => array(0x1CE)
1091
+ ,0x1CF => array(0x1D0), 0x1D1 => array(0x1D2), 0x1D3 => array(0x1D4)
1092
+ ,0x1D5 => array(0x1D6), 0x1D7 => array(0x1D8), 0x1D9 => array(0x1DA)
1093
+ ,0x1DB => array(0x1DC), 0x1DE => array(0x1DF), 0x1E0 => array(0x1E1)
1094
+ ,0x1E2 => array(0x1E3), 0x1E4 => array(0x1E5), 0x1E6 => array(0x1E7)
1095
+ ,0x1E8 => array(0x1E9), 0x1EA => array(0x1EB), 0x1EC => array(0x1ED)
1096
+ ,0x1EE => array(0x1EF), 0x1F0 => array(0x6A, 0x30C), 0x1F1 => array(0x1F3)
1097
+ ,0x1F2 => array(0x1F3), 0x1F4 => array(0x1F5), 0x1F6 => array(0x195)
1098
+ ,0x1F7 => array(0x1BF), 0x1F8 => array(0x1F9), 0x1FA => array(0x1FB)
1099
+ ,0x1FC => array(0x1FD), 0x1FE => array(0x1FF), 0x200 => array(0x201)
1100
+ ,0x202 => array(0x203), 0x204 => array(0x205), 0x206 => array(0x207)
1101
+ ,0x208 => array(0x209), 0x20A => array(0x20B), 0x20C => array(0x20D)
1102
+ ,0x20E => array(0x20F), 0x210 => array(0x211), 0x212 => array(0x213)
1103
+ ,0x214 => array(0x215), 0x216 => array(0x217), 0x218 => array(0x219)
1104
+ ,0x21A => array(0x21B), 0x21C => array(0x21D), 0x21E => array(0x21F)
1105
+ ,0x220 => array(0x19E), 0x222 => array(0x223), 0x224 => array(0x225)
1106
+ ,0x226 => array(0x227), 0x228 => array(0x229), 0x22A => array(0x22B)
1107
+ ,0x22C => array(0x22D), 0x22E => array(0x22F), 0x230 => array(0x231)
1108
+ ,0x232 => array(0x233), 0x345 => array(0x3B9), 0x37A => array(0x20, 0x3B9)
1109
+ ,0x386 => array(0x3AC), 0x388 => array(0x3AD), 0x389 => array(0x3AE)
1110
+ ,0x38A => array(0x3AF), 0x38C => array(0x3CC), 0x38E => array(0x3CD)
1111
+ ,0x38F => array(0x3CE), 0x390 => array(0x3B9, 0x308, 0x301)
1112
+ ,0x391 => array(0x3B1), 0x392 => array(0x3B2), 0x393 => array(0x3B3)
1113
+ ,0x394 => array(0x3B4), 0x395 => array(0x3B5), 0x396 => array(0x3B6)
1114
+ ,0x397 => array(0x3B7), 0x398 => array(0x3B8), 0x399 => array(0x3B9)
1115
+ ,0x39A => array(0x3BA), 0x39B => array(0x3BB), 0x39C => array(0x3BC)
1116
+ ,0x39D => array(0x3BD), 0x39E => array(0x3BE), 0x39F => array(0x3BF)
1117
+ ,0x3A0 => array(0x3C0), 0x3A1 => array(0x3C1), 0x3A3 => array(0x3C3)
1118
+ ,0x3A4 => array(0x3C4), 0x3A5 => array(0x3C5), 0x3A6 => array(0x3C6)
1119
+ ,0x3A7 => array(0x3C7), 0x3A8 => array(0x3C8), 0x3A9 => array(0x3C9)
1120
+ ,0x3AA => array(0x3CA), 0x3AB => array(0x3CB), 0x3B0 => array(0x3C5, 0x308, 0x301)
1121
+ ,0x3C2 => array(0x3C3), 0x3D0 => array(0x3B2), 0x3D1 => array(0x3B8)
1122
+ ,0x3D2 => array(0x3C5), 0x3D3 => array(0x3CD), 0x3D4 => array(0x3CB)
1123
+ ,0x3D5 => array(0x3C6), 0x3D6 => array(0x3C0), 0x3D8 => array(0x3D9)
1124
+ ,0x3DA => array(0x3DB), 0x3DC => array(0x3DD), 0x3DE => array(0x3DF)
1125
+ ,0x3E0 => array(0x3E1), 0x3E2 => array(0x3E3), 0x3E4 => array(0x3E5)
1126
+ ,0x3E6 => array(0x3E7), 0x3E8 => array(0x3E9), 0x3EA => array(0x3EB)
1127
+ ,0x3EC => array(0x3ED), 0x3EE => array(0x3EF), 0x3F0 => array(0x3BA)
1128
+ ,0x3F1 => array(0x3C1), 0x3F2 => array(0x3C3), 0x3F4 => array(0x3B8)
1129
+ ,0x3F5 => array(0x3B5), 0x400 => array(0x450), 0x401 => array(0x451)
1130
+ ,0x402 => array(0x452), 0x403 => array(0x453), 0x404 => array(0x454)
1131
+ ,0x405 => array(0x455), 0x406 => array(0x456), 0x407 => array(0x457)
1132
+ ,0x408 => array(0x458), 0x409 => array(0x459), 0x40A => array(0x45A)
1133
+ ,0x40B => array(0x45B), 0x40C => array(0x45C), 0x40D => array(0x45D)
1134
+ ,0x40E => array(0x45E), 0x40F => array(0x45F), 0x410 => array(0x430)
1135
+ ,0x411 => array(0x431), 0x412 => array(0x432), 0x413 => array(0x433)
1136
+ ,0x414 => array(0x434), 0x415 => array(0x435), 0x416 => array(0x436)
1137
+ ,0x417 => array(0x437), 0x418 => array(0x438), 0x419 => array(0x439)
1138
+ ,0x41A => array(0x43A), 0x41B => array(0x43B), 0x41C => array(0x43C)
1139
+ ,0x41D => array(0x43D), 0x41E => array(0x43E), 0x41F => array(0x43F)
1140
+ ,0x420 => array(0x440), 0x421 => array(0x441), 0x422 => array(0x442)
1141
+ ,0x423 => array(0x443), 0x424 => array(0x444), 0x425 => array(0x445)
1142
+ ,0x426 => array(0x446), 0x427 => array(0x447), 0x428 => array(0x448)
1143
+ ,0x429 => array(0x449), 0x42A => array(0x44A), 0x42B => array(0x44B)
1144
+ ,0x42C => array(0x44C), 0x42D => array(0x44D), 0x42E => array(0x44E)
1145
+ ,0x42F => array(0x44F), 0x460 => array(0x461), 0x462 => array(0x463)
1146
+ ,0x464 => array(0x465), 0x466 => array(0x467), 0x468 => array(0x469)
1147
+ ,0x46A => array(0x46B), 0x46C => array(0x46D), 0x46E => array(0x46F)
1148
+ ,0x470 => array(0x471), 0x472 => array(0x473), 0x474 => array(0x475)
1149
+ ,0x476 => array(0x477), 0x478 => array(0x479), 0x47A => array(0x47B)
1150
+ ,0x47C => array(0x47D), 0x47E => array(0x47F), 0x480 => array(0x481)
1151
+ ,0x48A => array(0x48B), 0x48C => array(0x48D), 0x48E => array(0x48F)
1152
+ ,0x490 => array(0x491), 0x492 => array(0x493), 0x494 => array(0x495)
1153
+ ,0x496 => array(0x497), 0x498 => array(0x499), 0x49A => array(0x49B)
1154
+ ,0x49C => array(0x49D), 0x49E => array(0x49F), 0x4A0 => array(0x4A1)
1155
+ ,0x4A2 => array(0x4A3), 0x4A4 => array(0x4A5), 0x4A6 => array(0x4A7)
1156
+ ,0x4A8 => array(0x4A9), 0x4AA => array(0x4AB), 0x4AC => array(0x4AD)
1157
+ ,0x4AE => array(0x4AF), 0x4B0 => array(0x4B1), 0x4B2 => array(0x4B3)
1158
+ ,0x4B4 => array(0x4B5), 0x4B6 => array(0x4B7), 0x4B8 => array(0x4B9)
1159
+ ,0x4BA => array(0x4BB), 0x4BC => array(0x4BD), 0x4BE => array(0x4BF)
1160
+ ,0x4C1 => array(0x4C2), 0x4C3 => array(0x4C4), 0x4C5 => array(0x4C6)
1161
+ ,0x4C7 => array(0x4C8), 0x4C9 => array(0x4CA), 0x4CB => array(0x4CC)
1162
+ ,0x4CD => array(0x4CE), 0x4D0 => array(0x4D1), 0x4D2 => array(0x4D3)
1163
+ ,0x4D4 => array(0x4D5), 0x4D6 => array(0x4D7), 0x4D8 => array(0x4D9)
1164
+ ,0x4DA => array(0x4DB), 0x4DC => array(0x4DD), 0x4DE => array(0x4DF)
1165
+ ,0x4E0 => array(0x4E1), 0x4E2 => array(0x4E3), 0x4E4 => array(0x4E5)
1166
+ ,0x4E6 => array(0x4E7), 0x4E8 => array(0x4E9), 0x4EA => array(0x4EB)
1167
+ ,0x4EC => array(0x4ED), 0x4EE => array(0x4EF), 0x4F0 => array(0x4F1)
1168
+ ,0x4F2 => array(0x4F3), 0x4F4 => array(0x4F5), 0x4F8 => array(0x4F9)
1169
+ ,0x500 => array(0x501), 0x502 => array(0x503), 0x504 => array(0x505)
1170
+ ,0x506 => array(0x507), 0x508 => array(0x509), 0x50A => array(0x50B)
1171
+ ,0x50C => array(0x50D), 0x50E => array(0x50F), 0x531 => array(0x561)
1172
+ ,0x532 => array(0x562), 0x533 => array(0x563), 0x534 => array(0x564)
1173
+ ,0x535 => array(0x565), 0x536 => array(0x566), 0x537 => array(0x567)
1174
+ ,0x538 => array(0x568), 0x539 => array(0x569), 0x53A => array(0x56A)
1175
+ ,0x53B => array(0x56B), 0x53C => array(0x56C), 0x53D => array(0x56D)
1176
+ ,0x53E => array(0x56E), 0x53F => array(0x56F), 0x540 => array(0x570)
1177
+ ,0x541 => array(0x571), 0x542 => array(0x572), 0x543 => array(0x573)
1178
+ ,0x544 => array(0x574), 0x545 => array(0x575), 0x546 => array(0x576)
1179
+ ,0x547 => array(0x577), 0x548 => array(0x578), 0x549 => array(0x579)
1180
+ ,0x54A => array(0x57A), 0x54B => array(0x57B), 0x54C => array(0x57C)
1181
+ ,0x54D => array(0x57D), 0x54E => array(0x57E), 0x54F => array(0x57F)
1182
+ ,0x550 => array(0x580), 0x551 => array(0x581), 0x552 => array(0x582)
1183
+ ,0x553 => array(0x583), 0x554 => array(0x584), 0x555 => array(0x585)
1184
+ ,0x556 => array(0x586), 0x587 => array(0x565, 0x582), 0xE33 => array(0xE4D, 0xE32)
1185
+ ,0x1E00 => array(0x1E01), 0x1E02 => array(0x1E03), 0x1E04 => array(0x1E05)
1186
+ ,0x1E06 => array(0x1E07), 0x1E08 => array(0x1E09), 0x1E0A => array(0x1E0B)
1187
+ ,0x1E0C => array(0x1E0D), 0x1E0E => array(0x1E0F), 0x1E10 => array(0x1E11)
1188
+ ,0x1E12 => array(0x1E13), 0x1E14 => array(0x1E15), 0x1E16 => array(0x1E17)
1189
+ ,0x1E18 => array(0x1E19), 0x1E1A => array(0x1E1B), 0x1E1C => array(0x1E1D)
1190
+ ,0x1E1E => array(0x1E1F), 0x1E20 => array(0x1E21), 0x1E22 => array(0x1E23)
1191
+ ,0x1E24 => array(0x1E25), 0x1E26 => array(0x1E27), 0x1E28 => array(0x1E29)
1192
+ ,0x1E2A => array(0x1E2B), 0x1E2C => array(0x1E2D), 0x1E2E => array(0x1E2F)
1193
+ ,0x1E30 => array(0x1E31), 0x1E32 => array(0x1E33), 0x1E34 => array(0x1E35)
1194
+ ,0x1E36 => array(0x1E37), 0x1E38 => array(0x1E39), 0x1E3A => array(0x1E3B)
1195
+ ,0x1E3C => array(0x1E3D), 0x1E3E => array(0x1E3F), 0x1E40 => array(0x1E41)
1196
+ ,0x1E42 => array(0x1E43), 0x1E44 => array(0x1E45), 0x1E46 => array(0x1E47)
1197
+ ,0x1E48 => array(0x1E49), 0x1E4A => array(0x1E4B), 0x1E4C => array(0x1E4D)
1198
+ ,0x1E4E => array(0x1E4F), 0x1E50 => array(0x1E51), 0x1E52 => array(0x1E53)
1199
+ ,0x1E54 => array(0x1E55), 0x1E56 => array(0x1E57), 0x1E58 => array(0x1E59)
1200
+ ,0x1E5A => array(0x1E5B), 0x1E5C => array(0x1E5D), 0x1E5E => array(0x1E5F)
1201
+ ,0x1E60 => array(0x1E61), 0x1E62 => array(0x1E63), 0x1E64 => array(0x1E65)
1202
+ ,0x1E66 => array(0x1E67), 0x1E68 => array(0x1E69), 0x1E6A => array(0x1E6B)
1203
+ ,0x1E6C => array(0x1E6D), 0x1E6E => array(0x1E6F), 0x1E70 => array(0x1E71)
1204
+ ,0x1E72 => array(0x1E73), 0x1E74 => array(0x1E75), 0x1E76 => array(0x1E77)
1205
+ ,0x1E78 => array(0x1E79), 0x1E7A => array(0x1E7B), 0x1E7C => array(0x1E7D)
1206
+ ,0x1E7E => array(0x1E7F), 0x1E80 => array(0x1E81), 0x1E82 => array(0x1E83)
1207
+ ,0x1E84 => array(0x1E85), 0x1E86 => array(0x1E87), 0x1E88 => array(0x1E89)
1208
+ ,0x1E8A => array(0x1E8B), 0x1E8C => array(0x1E8D), 0x1E8E => array(0x1E8F)
1209
+ ,0x1E90 => array(0x1E91), 0x1E92 => array(0x1E93), 0x1E94 => array(0x1E95)
1210
+ ,0x1E96 => array(0x68, 0x331), 0x1E97 => array(0x74, 0x308), 0x1E98 => array(0x77, 0x30A)
1211
+ ,0x1E99 => array(0x79, 0x30A), 0x1E9A => array(0x61, 0x2BE), 0x1E9B => array(0x1E61)
1212
+ ,0x1EA0 => array(0x1EA1), 0x1EA2 => array(0x1EA3), 0x1EA4 => array(0x1EA5)
1213
+ ,0x1EA6 => array(0x1EA7), 0x1EA8 => array(0x1EA9), 0x1EAA => array(0x1EAB)
1214
+ ,0x1EAC => array(0x1EAD), 0x1EAE => array(0x1EAF), 0x1EB0 => array(0x1EB1)
1215
+ ,0x1EB2 => array(0x1EB3), 0x1EB4 => array(0x1EB5), 0x1EB6 => array(0x1EB7)
1216
+ ,0x1EB8 => array(0x1EB9), 0x1EBA => array(0x1EBB), 0x1EBC => array(0x1EBD)
1217
+ ,0x1EBE => array(0x1EBF), 0x1EC0 => array(0x1EC1), 0x1EC2 => array(0x1EC3)
1218
+ ,0x1EC4 => array(0x1EC5), 0x1EC6 => array(0x1EC7), 0x1EC8 => array(0x1EC9)
1219
+ ,0x1ECA => array(0x1ECB), 0x1ECC => array(0x1ECD), 0x1ECE => array(0x1ECF)
1220
+ ,0x1ED0 => array(0x1ED1), 0x1ED2 => array(0x1ED3), 0x1ED4 => array(0x1ED5)
1221
+ ,0x1ED6 => array(0x1ED7), 0x1ED8 => array(0x1ED9), 0x1EDA => array(0x1EDB)
1222
+ ,0x1EDC => array(0x1EDD), 0x1EDE => array(0x1EDF), 0x1EE0 => array(0x1EE1)
1223
+ ,0x1EE2 => array(0x1EE3), 0x1EE4 => array(0x1EE5), 0x1EE6 => array(0x1EE7)
1224
+ ,0x1EE8 => array(0x1EE9), 0x1EEA => array(0x1EEB), 0x1EEC => array(0x1EED)
1225
+ ,0x1EEE => array(0x1EEF), 0x1EF0 => array(0x1EF1), 0x1EF2 => array(0x1EF3)
1226
+ ,0x1EF4 => array(0x1EF5), 0x1EF6 => array(0x1EF7), 0x1EF8 => array(0x1EF9)
1227
+ ,0x1F08 => array(0x1F00), 0x1F09 => array(0x1F01), 0x1F0A => array(0x1F02)
1228
+ ,0x1F0B => array(0x1F03), 0x1F0C => array(0x1F04), 0x1F0D => array(0x1F05)
1229
+ ,0x1F0E => array(0x1F06), 0x1F0F => array(0x1F07), 0x1F18 => array(0x1F10)
1230
+ ,0x1F19 => array(0x1F11), 0x1F1A => array(0x1F12), 0x1F1B => array(0x1F13)
1231
+ ,0x1F1C => array(0x1F14), 0x1F1D => array(0x1F15), 0x1F28 => array(0x1F20)
1232
+ ,0x1F29 => array(0x1F21), 0x1F2A => array(0x1F22), 0x1F2B => array(0x1F23)
1233
+ ,0x1F2C => array(0x1F24), 0x1F2D => array(0x1F25), 0x1F2E => array(0x1F26)
1234
+ ,0x1F2F => array(0x1F27), 0x1F38 => array(0x1F30), 0x1F39 => array(0x1F31)
1235
+ ,0x1F3A => array(0x1F32), 0x1F3B => array(0x1F33), 0x1F3C => array(0x1F34)
1236
+ ,0x1F3D => array(0x1F35), 0x1F3E => array(0x1F36), 0x1F3F => array(0x1F37)
1237
+ ,0x1F48 => array(0x1F40), 0x1F49 => array(0x1F41), 0x1F4A => array(0x1F42)
1238
+ ,0x1F4B => array(0x1F43), 0x1F4C => array(0x1F44), 0x1F4D => array(0x1F45)
1239
+ ,0x1F50 => array(0x3C5, 0x313), 0x1F52 => array(0x3C5, 0x313, 0x300)
1240
+ ,0x1F54 => array(0x3C5, 0x313, 0x301), 0x1F56 => array(0x3C5, 0x313, 0x342)
1241
+ ,0x1F59 => array(0x1F51), 0x1F5B => array(0x1F53), 0x1F5D => array(0x1F55)
1242
+ ,0x1F5F => array(0x1F57), 0x1F68 => array(0x1F60), 0x1F69 => array(0x1F61)
1243
+ ,0x1F6A => array(0x1F62), 0x1F6B => array(0x1F63), 0x1F6C => array(0x1F64)
1244
+ ,0x1F6D => array(0x1F65), 0x1F6E => array(0x1F66), 0x1F6F => array(0x1F67)
1245
+ ,0x1F80 => array(0x1F00, 0x3B9), 0x1F81 => array(0x1F01, 0x3B9)
1246
+ ,0x1F82 => array(0x1F02, 0x3B9), 0x1F83 => array(0x1F03, 0x3B9)
1247
+ ,0x1F84 => array(0x1F04, 0x3B9), 0x1F85 => array(0x1F05, 0x3B9)
1248
+ ,0x1F86 => array(0x1F06, 0x3B9), 0x1F87 => array(0x1F07, 0x3B9)
1249
+ ,0x1F88 => array(0x1F00, 0x3B9), 0x1F89 => array(0x1F01, 0x3B9)
1250
+ ,0x1F8A => array(0x1F02, 0x3B9), 0x1F8B => array(0x1F03, 0x3B9)
1251
+ ,0x1F8C => array(0x1F04, 0x3B9), 0x1F8D => array(0x1F05, 0x3B9)
1252
+ ,0x1F8E => array(0x1F06, 0x3B9), 0x1F8F => array(0x1F07, 0x3B9)
1253
+ ,0x1F90 => array(0x1F20, 0x3B9), 0x1F91 => array(0x1F21, 0x3B9)
1254
+ ,0x1F92 => array(0x1F22, 0x3B9), 0x1F93 => array(0x1F23, 0x3B9)
1255
+ ,0x1F94 => array(0x1F24, 0x3B9), 0x1F95 => array(0x1F25, 0x3B9)
1256
+ ,0x1F96 => array(0x1F26, 0x3B9), 0x1F97 => array(0x1F27, 0x3B9)
1257
+ ,0x1F98 => array(0x1F20, 0x3B9), 0x1F99 => array(0x1F21, 0x3B9)
1258
+ ,0x1F9A => array(0x1F22, 0x3B9), 0x1F9B => array(0x1F23, 0x3B9)
1259
+ ,0x1F9C => array(0x1F24, 0x3B9), 0x1F9D => array(0x1F25, 0x3B9)
1260
+ ,0x1F9E => array(0x1F26, 0x3B9), 0x1F9F => array(0x1F27, 0x3B9)
1261
+ ,0x1FA0 => array(0x1F60, 0x3B9), 0x1FA1 => array(0x1F61, 0x3B9)
1262
+ ,0x1FA2 => array(0x1F62, 0x3B9), 0x1FA3 => array(0x1F63, 0x3B9)
1263
+ ,0x1FA4 => array(0x1F64, 0x3B9), 0x1FA5 => array(0x1F65, 0x3B9)
1264
+ ,0x1FA6 => array(0x1F66, 0x3B9), 0x1FA7 => array(0x1F67, 0x3B9)
1265
+ ,0x1FA8 => array(0x1F60, 0x3B9), 0x1FA9 => array(0x1F61, 0x3B9)
1266
+ ,0x1FAA => array(0x1F62, 0x3B9), 0x1FAB => array(0x1F63, 0x3B9)
1267
+ ,0x1FAC => array(0x1F64, 0x3B9), 0x1FAD => array(0x1F65, 0x3B9)
1268
+ ,0x1FAE => array(0x1F66, 0x3B9), 0x1FAF => array(0x1F67, 0x3B9)
1269
+ ,0x1FB2 => array(0x1F70, 0x3B9), 0x1FB3 => array(0x3B1, 0x3B9)
1270
+ ,0x1FB4 => array(0x3AC, 0x3B9), 0x1FB6 => array(0x3B1, 0x342)
1271
+ ,0x1FB7 => array(0x3B1, 0x342, 0x3B9), 0x1FB8 => array(0x1FB0)
1272
+ ,0x1FB9 => array(0x1FB1), 0x1FBA => array(0x1F70), 0x1FBB => array(0x1F71)
1273
+ ,0x1FBC => array(0x3B1, 0x3B9), 0x1FBE => array(0x3B9)
1274
+ ,0x1FC2 => array(0x1F74, 0x3B9), 0x1FC3 => array(0x3B7, 0x3B9)
1275
+ ,0x1FC4 => array(0x3AE, 0x3B9), 0x1FC6 => array(0x3B7, 0x342)
1276
+ ,0x1FC7 => array(0x3B7, 0x342, 0x3B9), 0x1FC8 => array(0x1F72)
1277
+ ,0x1FC9 => array(0x1F73), 0x1FCA => array(0x1F74), 0x1FCB => array(0x1F75)
1278
+ ,0x1FCC => array(0x3B7, 0x3B9), 0x1FD2 => array(0x3B9, 0x308, 0x300)
1279
+ ,0x1FD3 => array(0x3B9, 0x308, 0x301), 0x1FD6 => array(0x3B9, 0x342)
1280
+ ,0x1FD7 => array(0x3B9, 0x308, 0x342), 0x1FD8 => array(0x1FD0)
1281
+ ,0x1FD9 => array(0x1FD1), 0x1FDA => array(0x1F76)
1282
+ ,0x1FDB => array(0x1F77), 0x1FE2 => array(0x3C5, 0x308, 0x300)
1283
+ ,0x1FE3 => array(0x3C5, 0x308, 0x301), 0x1FE4 => array(0x3C1, 0x313)
1284
+ ,0x1FE6 => array(0x3C5, 0x342), 0x1FE7 => array(0x3C5, 0x308, 0x342)
1285
+ ,0x1FE8 => array(0x1FE0), 0x1FE9 => array(0x1FE1)
1286
+ ,0x1FEA => array(0x1F7A), 0x1FEB => array(0x1F7B)
1287
+ ,0x1FEC => array(0x1FE5), 0x1FF2 => array(0x1F7C, 0x3B9)
1288
+ ,0x1FF3 => array(0x3C9, 0x3B9), 0x1FF4 => array(0x3CE, 0x3B9)
1289
+ ,0x1FF6 => array(0x3C9, 0x342), 0x1FF7 => array(0x3C9, 0x342, 0x3B9)
1290
+ ,0x1FF8 => array(0x1F78), 0x1FF9 => array(0x1F79), 0x1FFA => array(0x1F7C)
1291
+ ,0x1FFB => array(0x1F7D), 0x1FFC => array(0x3C9, 0x3B9)
1292
+ ,0x20A8 => array(0x72, 0x73), 0x2102 => array(0x63), 0x2103 => array(0xB0, 0x63)
1293
+ ,0x2107 => array(0x25B), 0x2109 => array(0xB0, 0x66), 0x210B => array(0x68)
1294
+ ,0x210C => array(0x68), 0x210D => array(0x68), 0x2110 => array(0x69)
1295
+ ,0x2111 => array(0x69), 0x2112 => array(0x6C), 0x2115 => array(0x6E)
1296
+ ,0x2116 => array(0x6E, 0x6F), 0x2119 => array(0x70), 0x211A => array(0x71)
1297
+ ,0x211B => array(0x72), 0x211C => array(0x72), 0x211D => array(0x72)
1298
+ ,0x2120 => array(0x73, 0x6D), 0x2121 => array(0x74, 0x65, 0x6C)
1299
+ ,0x2122 => array(0x74, 0x6D), 0x2124 => array(0x7A), 0x2126 => array(0x3C9)
1300
+ ,0x2128 => array(0x7A), 0x212A => array(0x6B), 0x212B => array(0xE5)
1301
+ ,0x212C => array(0x62), 0x212D => array(0x63), 0x2130 => array(0x65)
1302
+ ,0x2131 => array(0x66), 0x2133 => array(0x6D), 0x213E => array(0x3B3)
1303
+ ,0x213F => array(0x3C0), 0x2145 => array(0x64) ,0x2160 => array(0x2170)
1304
+ ,0x2161 => array(0x2171), 0x2162 => array(0x2172), 0x2163 => array(0x2173)
1305
+ ,0x2164 => array(0x2174), 0x2165 => array(0x2175), 0x2166 => array(0x2176)
1306
+ ,0x2167 => array(0x2177), 0x2168 => array(0x2178), 0x2169 => array(0x2179)
1307
+ ,0x216A => array(0x217A), 0x216B => array(0x217B), 0x216C => array(0x217C)
1308
+ ,0x216D => array(0x217D), 0x216E => array(0x217E), 0x216F => array(0x217F)
1309
+ ,0x24B6 => array(0x24D0), 0x24B7 => array(0x24D1), 0x24B8 => array(0x24D2)
1310
+ ,0x24B9 => array(0x24D3), 0x24BA => array(0x24D4), 0x24BB => array(0x24D5)
1311
+ ,0x24BC => array(0x24D6), 0x24BD => array(0x24D7), 0x24BE => array(0x24D8)
1312
+ ,0x24BF => array(0x24D9), 0x24C0 => array(0x24DA), 0x24C1 => array(0x24DB)
1313
+ ,0x24C2 => array(0x24DC), 0x24C3 => array(0x24DD), 0x24C4 => array(0x24DE)
1314
+ ,0x24C5 => array(0x24DF), 0x24C6 => array(0x24E0), 0x24C7 => array(0x24E1)
1315
+ ,0x24C8 => array(0x24E2), 0x24C9 => array(0x24E3), 0x24CA => array(0x24E4)
1316
+ ,0x24CB => array(0x24E5), 0x24CC => array(0x24E6), 0x24CD => array(0x24E7)
1317
+ ,0x24CE => array(0x24E8), 0x24CF => array(0x24E9), 0x3371 => array(0x68, 0x70, 0x61)
1318
+ ,0x3373 => array(0x61, 0x75), 0x3375 => array(0x6F, 0x76)
1319
+ ,0x3380 => array(0x70, 0x61), 0x3381 => array(0x6E, 0x61)
1320
+ ,0x3382 => array(0x3BC, 0x61), 0x3383 => array(0x6D, 0x61)
1321
+ ,0x3384 => array(0x6B, 0x61), 0x3385 => array(0x6B, 0x62)
1322
+ ,0x3386 => array(0x6D, 0x62), 0x3387 => array(0x67, 0x62)
1323
+ ,0x338A => array(0x70, 0x66), 0x338B => array(0x6E, 0x66)
1324
+ ,0x338C => array(0x3BC, 0x66), 0x3390 => array(0x68, 0x7A)
1325
+ ,0x3391 => array(0x6B, 0x68, 0x7A), 0x3392 => array(0x6D, 0x68, 0x7A)
1326
+ ,0x3393 => array(0x67, 0x68, 0x7A), 0x3394 => array(0x74, 0x68, 0x7A)
1327
+ ,0x33A9 => array(0x70, 0x61), 0x33AA => array(0x6B, 0x70, 0x61)
1328
+ ,0x33AB => array(0x6D, 0x70, 0x61), 0x33AC => array(0x67, 0x70, 0x61)
1329
+ ,0x33B4 => array(0x70, 0x76), 0x33B5 => array(0x6E, 0x76)
1330
+ ,0x33B6 => array(0x3BC, 0x76), 0x33B7 => array(0x6D, 0x76)
1331
+ ,0x33B8 => array(0x6B, 0x76), 0x33B9 => array(0x6D, 0x76)
1332
+ ,0x33BA => array(0x70, 0x77), 0x33BB => array(0x6E, 0x77)
1333
+ ,0x33BC => array(0x3BC, 0x77), 0x33BD => array(0x6D, 0x77)
1334
+ ,0x33BE => array(0x6B, 0x77), 0x33BF => array(0x6D, 0x77)
1335
+ ,0x33C0 => array(0x6B, 0x3C9), 0x33C1 => array(0x6D, 0x3C9) /*
1336
+ ,0x33C2 => array(0x61, 0x2E, 0x6D, 0x2E) */
1337
+ ,0x33C3 => array(0x62, 0x71), 0x33C6 => array(0x63, 0x2215, 0x6B, 0x67)
1338
+ ,0x33C7 => array(0x63, 0x6F, 0x2E), 0x33C8 => array(0x64, 0x62)
1339
+ ,0x33C9 => array(0x67, 0x79), 0x33CB => array(0x68, 0x70)
1340
+ ,0x33CD => array(0x6B, 0x6B), 0x33CE => array(0x6B, 0x6D)
1341
+ ,0x33D7 => array(0x70, 0x68), 0x33D9 => array(0x70, 0x70, 0x6D)
1342
+ ,0x33DA => array(0x70, 0x72), 0x33DC => array(0x73, 0x76)
1343
+ ,0x33DD => array(0x77, 0x62), 0xFB00 => array(0x66, 0x66)
1344
+ ,0xFB01 => array(0x66, 0x69), 0xFB02 => array(0x66, 0x6C)
1345
+ ,0xFB03 => array(0x66, 0x66, 0x69), 0xFB04 => array(0x66, 0x66, 0x6C)
1346
+ ,0xFB05 => array(0x73, 0x74), 0xFB06 => array(0x73, 0x74)
1347
+ ,0xFB13 => array(0x574, 0x576), 0xFB14 => array(0x574, 0x565)
1348
+ ,0xFB15 => array(0x574, 0x56B), 0xFB16 => array(0x57E, 0x576)
1349
+ ,0xFB17 => array(0x574, 0x56D), 0xFF21 => array(0xFF41)
1350
+ ,0xFF22 => array(0xFF42), 0xFF23 => array(0xFF43), 0xFF24 => array(0xFF44)
1351
+ ,0xFF25 => array(0xFF45), 0xFF26 => array(0xFF46), 0xFF27 => array(0xFF47)
1352
+ ,0xFF28 => array(0xFF48), 0xFF29 => array(0xFF49), 0xFF2A => array(0xFF4A)
1353
+ ,0xFF2B => array(0xFF4B), 0xFF2C => array(0xFF4C), 0xFF2D => array(0xFF4D)
1354
+ ,0xFF2E => array(0xFF4E), 0xFF2F => array(0xFF4F), 0xFF30 => array(0xFF50)
1355
+ ,0xFF31 => array(0xFF51), 0xFF32 => array(0xFF52), 0xFF33 => array(0xFF53)
1356
+ ,0xFF34 => array(0xFF54), 0xFF35 => array(0xFF55), 0xFF36 => array(0xFF56)
1357
+ ,0xFF37 => array(0xFF57), 0xFF38 => array(0xFF58), 0xFF39 => array(0xFF59)
1358
+ ,0xFF3A => array(0xFF5A), 0x10400 => array(0x10428), 0x10401 => array(0x10429)
1359
+ ,0x10402 => array(0x1042A), 0x10403 => array(0x1042B), 0x10404 => array(0x1042C)
1360
+ ,0x10405 => array(0x1042D), 0x10406 => array(0x1042E), 0x10407 => array(0x1042F)
1361
+ ,0x10408 => array(0x10430), 0x10409 => array(0x10431), 0x1040A => array(0x10432)
1362
+ ,0x1040B => array(0x10433), 0x1040C => array(0x10434), 0x1040D => array(0x10435)
1363
+ ,0x1040E => array(0x10436), 0x1040F => array(0x10437), 0x10410 => array(0x10438)
1364
+ ,0x10411 => array(0x10439), 0x10412 => array(0x1043A), 0x10413 => array(0x1043B)
1365
+ ,0x10414 => array(0x1043C), 0x10415 => array(0x1043D), 0x10416 => array(0x1043E)
1366
+ ,0x10417 => array(0x1043F), 0x10418 => array(0x10440), 0x10419 => array(0x10441)
1367
+ ,0x1041A => array(0x10442), 0x1041B => array(0x10443), 0x1041C => array(0x10444)
1368
+ ,0x1041D => array(0x10445), 0x1041E => array(0x10446), 0x1041F => array(0x10447)
1369
+ ,0x10420 => array(0x10448), 0x10421 => array(0x10449), 0x10422 => array(0x1044A)
1370
+ ,0x10423 => array(0x1044B), 0x10424 => array(0x1044C), 0x10425 => array(0x1044D)
1371
+ ,0x1D400 => array(0x61), 0x1D401 => array(0x62), 0x1D402 => array(0x63)
1372
+ ,0x1D403 => array(0x64), 0x1D404 => array(0x65), 0x1D405 => array(0x66)
1373
+ ,0x1D406 => array(0x67), 0x1D407 => array(0x68), 0x1D408 => array(0x69)
1374
+ ,0x1D409 => array(0x6A), 0x1D40A => array(0x6B), 0x1D40B => array(0x6C)
1375
+ ,0x1D40C => array(0x6D), 0x1D40D => array(0x6E), 0x1D40E => array(0x6F)
1376
+ ,0x1D40F => array(0x70), 0x1D410 => array(0x71), 0x1D411 => array(0x72)
1377
+ ,0x1D412 => array(0x73), 0x1D413 => array(0x74), 0x1D414 => array(0x75)
1378
+ ,0x1D415 => array(0x76), 0x1D416 => array(0x77), 0x1D417 => array(0x78)
1379
+ ,0x1D418 => array(0x79), 0x1D419 => array(0x7A), 0x1D434 => array(0x61)
1380
+ ,0x1D435 => array(0x62), 0x1D436 => array(0x63), 0x1D437 => array(0x64)
1381
+ ,0x1D438 => array(0x65), 0x1D439 => array(0x66), 0x1D43A => array(0x67)
1382
+ ,0x1D43B => array(0x68), 0x1D43C => array(0x69), 0x1D43D => array(0x6A)
1383
+ ,0x1D43E => array(0x6B), 0x1D43F => array(0x6C), 0x1D440 => array(0x6D)
1384
+ ,0x1D441 => array(0x6E), 0x1D442 => array(0x6F), 0x1D443 => array(0x70)
1385
+ ,0x1D444 => array(0x71), 0x1D445 => array(0x72), 0x1D446 => array(0x73)
1386
+ ,0x1D447 => array(0x74), 0x1D448 => array(0x75), 0x1D449 => array(0x76)
1387
+ ,0x1D44A => array(0x77), 0x1D44B => array(0x78), 0x1D44C => array(0x79)
1388
+ ,0x1D44D => array(0x7A), 0x1D468 => array(0x61), 0x1D469 => array(0x62)
1389
+ ,0x1D46A => array(0x63), 0x1D46B => array(0x64), 0x1D46C => array(0x65)
1390
+ ,0x1D46D => array(0x66), 0x1D46E => array(0x67), 0x1D46F => array(0x68)
1391
+ ,0x1D470 => array(0x69), 0x1D471 => array(0x6A), 0x1D472 => array(0x6B)
1392
+ ,0x1D473 => array(0x6C), 0x1D474 => array(0x6D), 0x1D475 => array(0x6E)
1393
+ ,0x1D476 => array(0x6F), 0x1D477 => array(0x70), 0x1D478 => array(0x71)
1394
+ ,0x1D479 => array(0x72), 0x1D47A => array(0x73), 0x1D47B => array(0x74)
1395
+ ,0x1D47C => array(0x75), 0x1D47D => array(0x76), 0x1D47E => array(0x77)
1396
+ ,0x1D47F => array(0x78), 0x1D480 => array(0x79), 0x1D481 => array(0x7A)
1397
+ ,0x1D49C => array(0x61), 0x1D49E => array(0x63), 0x1D49F => array(0x64)
1398
+ ,0x1D4A2 => array(0x67), 0x1D4A5 => array(0x6A), 0x1D4A6 => array(0x6B)
1399
+ ,0x1D4A9 => array(0x6E), 0x1D4AA => array(0x6F), 0x1D4AB => array(0x70)
1400
+ ,0x1D4AC => array(0x71), 0x1D4AE => array(0x73), 0x1D4AF => array(0x74)
1401
+ ,0x1D4B0 => array(0x75), 0x1D4B1 => array(0x76), 0x1D4B2 => array(0x77)
1402
+ ,0x1D4B3 => array(0x78), 0x1D4B4 => array(0x79), 0x1D4B5 => array(0x7A)
1403
+ ,0x1D4D0 => array(0x61), 0x1D4D1 => array(0x62), 0x1D4D2 => array(0x63)
1404
+ ,0x1D4D3 => array(0x64), 0x1D4D4 => array(0x65), 0x1D4D5 => array(0x66)
1405
+ ,0x1D4D6 => array(0x67), 0x1D4D7 => array(0x68), 0x1D4D8 => array(0x69)
1406
+ ,0x1D4D9 => array(0x6A), 0x1D4DA => array(0x6B), 0x1D4DB => array(0x6C)
1407
+ ,0x1D4DC => array(0x6D), 0x1D4DD => array(0x6E), 0x1D4DE => array(0x6F)
1408
+ ,0x1D4DF => array(0x70), 0x1D4E0 => array(0x71), 0x1D4E1 => array(0x72)
1409
+ ,0x1D4E2 => array(0x73), 0x1D4E3 => array(0x74), 0x1D4E4 => array(0x75)
1410
+ ,0x1D4E5 => array(0x76), 0x1D4E6 => array(0x77), 0x1D4E7 => array(0x78)
1411
+ ,0x1D4E8 => array(0x79), 0x1D4E9 => array(0x7A), 0x1D504 => array(0x61)
1412
+ ,0x1D505 => array(0x62), 0x1D507 => array(0x64), 0x1D508 => array(0x65)
1413
+ ,0x1D509 => array(0x66), 0x1D50A => array(0x67), 0x1D50D => array(0x6A)
1414
+ ,0x1D50E => array(0x6B), 0x1D50F => array(0x6C), 0x1D510 => array(0x6D)
1415
+ ,0x1D511 => array(0x6E), 0x1D512 => array(0x6F), 0x1D513 => array(0x70)
1416
+ ,0x1D514 => array(0x71), 0x1D516 => array(0x73), 0x1D517 => array(0x74)
1417
+ ,0x1D518 => array(0x75), 0x1D519 => array(0x76), 0x1D51A => array(0x77)
1418
+ ,0x1D51B => array(0x78), 0x1D51C => array(0x79), 0x1D538 => array(0x61)
1419
+ ,0x1D539 => array(0x62), 0x1D53B => array(0x64), 0x1D53C => array(0x65)
1420
+ ,0x1D53D => array(0x66), 0x1D53E => array(0x67), 0x1D540 => array(0x69)
1421
+ ,0x1D541 => array(0x6A), 0x1D542 => array(0x6B), 0x1D543 => array(0x6C)
1422
+ ,0x1D544 => array(0x6D), 0x1D546 => array(0x6F), 0x1D54A => array(0x73)
1423
+ ,0x1D54B => array(0x74), 0x1D54C => array(0x75), 0x1D54D => array(0x76)
1424
+ ,0x1D54E => array(0x77), 0x1D54F => array(0x78), 0x1D550 => array(0x79)
1425
+ ,0x1D56C => array(0x61), 0x1D56D => array(0x62), 0x1D56E => array(0x63)
1426
+ ,0x1D56F => array(0x64), 0x1D570 => array(0x65), 0x1D571 => array(0x66)
1427
+ ,0x1D572 => array(0x67), 0x1D573 => array(0x68), 0x1D574 => array(0x69)
1428
+ ,0x1D575 => array(0x6A), 0x1D576 => array(0x6B), 0x1D577 => array(0x6C)
1429
+ ,0x1D578 => array(0x6D), 0x1D579 => array(0x6E), 0x1D57A => array(0x6F)
1430
+ ,0x1D57B => array(0x70), 0x1D57C => array(0x71), 0x1D57D => array(0x72)
1431
+ ,0x1D57E => array(0x73), 0x1D57F => array(0x74), 0x1D580 => array(0x75)
1432
+ ,0x1D581 => array(0x76), 0x1D582 => array(0x77), 0x1D583 => array(0x78)
1433
+ ,0x1D584 => array(0x79), 0x1D585 => array(0x7A), 0x1D5A0 => array(0x61)
1434
+ ,0x1D5A1 => array(0x62), 0x1D5A2 => array(0x63), 0x1D5A3 => array(0x64)
1435
+ ,0x1D5A4 => array(0x65), 0x1D5A5 => array(0x66), 0x1D5A6 => array(0x67)
1436
+ ,0x1D5A7 => array(0x68), 0x1D5A8 => array(0x69), 0x1D5A9 => array(0x6A)
1437
+ ,0x1D5AA => array(0x6B), 0x1D5AB => array(0x6C), 0x1D5AC => array(0x6D)
1438
+ ,0x1D5AD => array(0x6E), 0x1D5AE => array(0x6F), 0x1D5AF => array(0x70)
1439
+ ,0x1D5B0 => array(0x71), 0x1D5B1 => array(0x72), 0x1D5B2 => array(0x73)
1440
+ ,0x1D5B3 => array(0x74), 0x1D5B4 => array(0x75), 0x1D5B5 => array(0x76)
1441
+ ,0x1D5B6 => array(0x77), 0x1D5B7 => array(0x78), 0x1D5B8 => array(0x79)
1442
+ ,0x1D5B9 => array(0x7A), 0x1D5D4 => array(0x61), 0x1D5D5 => array(0x62)
1443
+ ,0x1D5D6 => array(0x63), 0x1D5D7 => array(0x64), 0x1D5D8 => array(0x65)
1444
+ ,0x1D5D9 => array(0x66), 0x1D5DA => array(0x67), 0x1D5DB => array(0x68)
1445
+ ,0x1D5DC => array(0x69), 0x1D5DD => array(0x6A), 0x1D5DE => array(0x6B)
1446
+ ,0x1D5DF => array(0x6C), 0x1D5E0 => array(0x6D), 0x1D5E1 => array(0x6E)
1447
+ ,0x1D5E2 => array(0x6F), 0x1D5E3 => array(0x70), 0x1D5E4 => array(0x71)
1448
+ ,0x1D5E5 => array(0x72), 0x1D5E6 => array(0x73), 0x1D5E7 => array(0x74)
1449
+ ,0x1D5E8 => array(0x75), 0x1D5E9 => array(0x76), 0x1D5EA => array(0x77)
1450
+ ,0x1D5EB => array(0x78), 0x1D5EC => array(0x79), 0x1D5ED => array(0x7A)
1451
+ ,0x1D608 => array(0x61), 0x1D609 => array(0x62) ,0x1D60A => array(0x63)
1452
+ ,0x1D60B => array(0x64), 0x1D60C => array(0x65), 0x1D60D => array(0x66)
1453
+ ,0x1D60E => array(0x67), 0x1D60F => array(0x68), 0x1D610 => array(0x69)
1454
+ ,0x1D611 => array(0x6A), 0x1D612 => array(0x6B), 0x1D613 => array(0x6C)
1455
+ ,0x1D614 => array(0x6D), 0x1D615 => array(0x6E), 0x1D616 => array(0x6F)
1456
+ ,0x1D617 => array(0x70), 0x1D618 => array(0x71), 0x1D619 => array(0x72)
1457
+ ,0x1D61A => array(0x73), 0x1D61B => array(0x74), 0x1D61C => array(0x75)
1458
+ ,0x1D61D => array(0x76), 0x1D61E => array(0x77), 0x1D61F => array(0x78)
1459
+ ,0x1D620 => array(0x79), 0x1D621 => array(0x7A), 0x1D63C => array(0x61)
1460
+ ,0x1D63D => array(0x62), 0x1D63E => array(0x63), 0x1D63F => array(0x64)
1461
+ ,0x1D640 => array(0x65), 0x1D641 => array(0x66), 0x1D642 => array(0x67)
1462
+ ,0x1D643 => array(0x68), 0x1D644 => array(0x69), 0x1D645 => array(0x6A)
1463
+ ,0x1D646 => array(0x6B), 0x1D647 => array(0x6C), 0x1D648 => array(0x6D)
1464
+ ,0x1D649 => array(0x6E), 0x1D64A => array(0x6F), 0x1D64B => array(0x70)
1465
+ ,0x1D64C => array(0x71), 0x1D64D => array(0x72), 0x1D64E => array(0x73)
1466
+ ,0x1D64F => array(0x74), 0x1D650 => array(0x75), 0x1D651 => array(0x76)
1467
+ ,0x1D652 => array(0x77), 0x1D653 => array(0x78), 0x1D654 => array(0x79)
1468
+ ,0x1D655 => array(0x7A), 0x1D670 => array(0x61), 0x1D671 => array(0x62)
1469
+ ,0x1D672 => array(0x63), 0x1D673 => array(0x64), 0x1D674 => array(0x65)
1470
+ ,0x1D675 => array(0x66), 0x1D676 => array(0x67), 0x1D677 => array(0x68)
1471
+ ,0x1D678 => array(0x69), 0x1D679 => array(0x6A), 0x1D67A => array(0x6B)
1472
+ ,0x1D67B => array(0x6C), 0x1D67C => array(0x6D), 0x1D67D => array(0x6E)
1473
+ ,0x1D67E => array(0x6F), 0x1D67F => array(0x70), 0x1D680 => array(0x71)
1474
+ ,0x1D681 => array(0x72), 0x1D682 => array(0x73), 0x1D683 => array(0x74)
1475
+ ,0x1D684 => array(0x75), 0x1D685 => array(0x76), 0x1D686 => array(0x77)
1476
+ ,0x1D687 => array(0x78), 0x1D688 => array(0x79), 0x1D689 => array(0x7A)
1477
+ ,0x1D6A8 => array(0x3B1), 0x1D6A9 => array(0x3B2), 0x1D6AA => array(0x3B3)
1478
+ ,0x1D6AB => array(0x3B4), 0x1D6AC => array(0x3B5), 0x1D6AD => array(0x3B6)
1479
+ ,0x1D6AE => array(0x3B7), 0x1D6AF => array(0x3B8), 0x1D6B0 => array(0x3B9)
1480
+ ,0x1D6B1 => array(0x3BA), 0x1D6B2 => array(0x3BB), 0x1D6B3 => array(0x3BC)
1481
+ ,0x1D6B4 => array(0x3BD), 0x1D6B5 => array(0x3BE), 0x1D6B6 => array(0x3BF)
1482
+ ,0x1D6B7 => array(0x3C0), 0x1D6B8 => array(0x3C1), 0x1D6B9 => array(0x3B8)
1483
+ ,0x1D6BA => array(0x3C3), 0x1D6BB => array(0x3C4), 0x1D6BC => array(0x3C5)
1484
+ ,0x1D6BD => array(0x3C6), 0x1D6BE => array(0x3C7), 0x1D6BF => array(0x3C8)
1485
+ ,0x1D6C0 => array(0x3C9), 0x1D6D3 => array(0x3C3), 0x1D6E2 => array(0x3B1)
1486
+ ,0x1D6E3 => array(0x3B2), 0x1D6E4 => array(0x3B3), 0x1D6E5 => array(0x3B4)
1487
+ ,0x1D6E6 => array(0x3B5), 0x1D6E7 => array(0x3B6), 0x1D6E8 => array(0x3B7)
1488
+ ,0x1D6E9 => array(0x3B8), 0x1D6EA => array(0x3B9), 0x1D6EB => array(0x3BA)
1489
+ ,0x1D6EC => array(0x3BB), 0x1D6ED => array(0x3BC), 0x1D6EE => array(0x3BD)
1490
+ ,0x1D6EF => array(0x3BE), 0x1D6F0 => array(0x3BF), 0x1D6F1 => array(0x3C0)
1491
+ ,0x1D6F2 => array(0x3C1), 0x1D6F3 => array(0x3B8) ,0x1D6F4 => array(0x3C3)
1492
+ ,0x1D6F5 => array(0x3C4), 0x1D6F6 => array(0x3C5), 0x1D6F7 => array(0x3C6)
1493
+ ,0x1D6F8 => array(0x3C7), 0x1D6F9 => array(0x3C8) ,0x1D6FA => array(0x3C9)
1494
+ ,0x1D70D => array(0x3C3), 0x1D71C => array(0x3B1), 0x1D71D => array(0x3B2)
1495
+ ,0x1D71E => array(0x3B3), 0x1D71F => array(0x3B4), 0x1D720 => array(0x3B5)
1496
+ ,0x1D721 => array(0x3B6), 0x1D722 => array(0x3B7), 0x1D723 => array(0x3B8)
1497
+ ,0x1D724 => array(0x3B9), 0x1D725 => array(0x3BA), 0x1D726 => array(0x3BB)
1498
+ ,0x1D727 => array(0x3BC), 0x1D728 => array(0x3BD), 0x1D729 => array(0x3BE)
1499
+ ,0x1D72A => array(0x3BF), 0x1D72B => array(0x3C0), 0x1D72C => array(0x3C1)
1500
+ ,0x1D72D => array(0x3B8), 0x1D72E => array(0x3C3), 0x1D72F => array(0x3C4)
1501
+ ,0x1D730 => array(0x3C5), 0x1D731 => array(0x3C6), 0x1D732 => array(0x3C7)
1502
+ ,0x1D733 => array(0x3C8), 0x1D734 => array(0x3C9), 0x1D747 => array(0x3C3)
1503
+ ,0x1D756 => array(0x3B1), 0x1D757 => array(0x3B2), 0x1D758 => array(0x3B3)
1504
+ ,0x1D759 => array(0x3B4), 0x1D75A => array(0x3B5), 0x1D75B => array(0x3B6)
1505
+ ,0x1D75C => array(0x3B7), 0x1D75D => array(0x3B8), 0x1D75E => array(0x3B9)
1506
+ ,0x1D75F => array(0x3BA), 0x1D760 => array(0x3BB), 0x1D761 => array(0x3BC)
1507
+ ,0x1D762 => array(0x3BD), 0x1D763 => array(0x3BE), 0x1D764 => array(0x3BF)
1508
+ ,0x1D765 => array(0x3C0), 0x1D766 => array(0x3C1), 0x1D767 => array(0x3B8)
1509
+ ,0x1D768 => array(0x3C3), 0x1D769 => array(0x3C4), 0x1D76A => array(0x3C5)
1510
+ ,0x1D76B => array(0x3C6), 0x1D76C => array(0x3C7), 0x1D76D => array(0x3C8)
1511
+ ,0x1D76E => array(0x3C9), 0x1D781 => array(0x3C3), 0x1D790 => array(0x3B1)
1512
+ ,0x1D791 => array(0x3B2), 0x1D792 => array(0x3B3), 0x1D793 => array(0x3B4)
1513
+ ,0x1D794 => array(0x3B5), 0x1D795 => array(0x3B6), 0x1D796 => array(0x3B7)
1514
+ ,0x1D797 => array(0x3B8), 0x1D798 => array(0x3B9), 0x1D799 => array(0x3BA)
1515
+ ,0x1D79A => array(0x3BB), 0x1D79B => array(0x3BC), 0x1D79C => array(0x3BD)
1516
+ ,0x1D79D => array(0x3BE), 0x1D79E => array(0x3BF), 0x1D79F => array(0x3C0)
1517
+ ,0x1D7A0 => array(0x3C1), 0x1D7A1 => array(0x3B8), 0x1D7A2 => array(0x3C3)
1518
+ ,0x1D7A3 => array(0x3C4), 0x1D7A4 => array(0x3C5), 0x1D7A5 => array(0x3C6)
1519
+ ,0x1D7A6 => array(0x3C7), 0x1D7A7 => array(0x3C8), 0x1D7A8 => array(0x3C9)
1520
+ ,0x1D7BB => array(0x3C3), 0x3F9 => array(0x3C3), 0x1D2C => array(0x61)
1521
+ ,0x1D2D => array(0xE6), 0x1D2E => array(0x62), 0x1D30 => array(0x64)
1522
+ ,0x1D31 => array(0x65), 0x1D32 => array(0x1DD), 0x1D33 => array(0x67)
1523
+ ,0x1D34 => array(0x68), 0x1D35 => array(0x69), 0x1D36 => array(0x6A)
1524
+ ,0x1D37 => array(0x6B), 0x1D38 => array(0x6C), 0x1D39 => array(0x6D)
1525
+ ,0x1D3A => array(0x6E), 0x1D3C => array(0x6F), 0x1D3D => array(0x223)
1526
+ ,0x1D3E => array(0x70), 0x1D3F => array(0x72), 0x1D40 => array(0x74)
1527
+ ,0x1D41 => array(0x75), 0x1D42 => array(0x77), 0x213B => array(0x66, 0x61, 0x78)
1528
+ ,0x3250 => array(0x70, 0x74, 0x65), 0x32CC => array(0x68, 0x67)
1529
+ ,0x32CE => array(0x65, 0x76), 0x32CF => array(0x6C, 0x74, 0x64)
1530
+ ,0x337A => array(0x69, 0x75), 0x33DE => array(0x76, 0x2215, 0x6D)
1531
+ ,0x33DF => array(0x61, 0x2215, 0x6D)
1532
+ )
1533
+ ,'norm_combcls' => array(0x334 => 1, 0x335 => 1, 0x336 => 1, 0x337 => 1
1534
+ ,0x338 => 1, 0x93C => 7, 0x9BC => 7, 0xA3C => 7, 0xABC => 7
1535
+ ,0xB3C => 7, 0xCBC => 7, 0x1037 => 7, 0x3099 => 8, 0x309A => 8
1536
+ ,0x94D => 9, 0x9CD => 9, 0xA4D => 9, 0xACD => 9, 0xB4D => 9
1537
+ ,0xBCD => 9, 0xC4D => 9, 0xCCD => 9, 0xD4D => 9, 0xDCA => 9
1538
+ ,0xE3A => 9, 0xF84 => 9, 0x1039 => 9, 0x1714 => 9, 0x1734 => 9
1539
+ ,0x17D2 => 9, 0x5B0 => 10, 0x5B1 => 11, 0x5B2 => 12, 0x5B3 => 13
1540
+ ,0x5B4 => 14, 0x5B5 => 15, 0x5B6 => 16, 0x5B7 => 17, 0x5B8 => 18
1541
+ ,0x5B9 => 19, 0x5BB => 20, 0x5Bc => 21, 0x5BD => 22, 0x5BF => 23
1542
+ ,0x5C1 => 24, 0x5C2 => 25, 0xFB1E => 26, 0x64B => 27, 0x64C => 28
1543
+ ,0x64D => 29, 0x64E => 30, 0x64F => 31, 0x650 => 32, 0x651 => 33
1544
+ ,0x652 => 34, 0x670 => 35, 0x711 => 36, 0xC55 => 84, 0xC56 => 91
1545
+ ,0xE38 => 103, 0xE39 => 103, 0xE48 => 107, 0xE49 => 107, 0xE4A => 107
1546
+ ,0xE4B => 107, 0xEB8 => 118, 0xEB9 => 118, 0xEC8 => 122, 0xEC9 => 122
1547
+ ,0xECA => 122, 0xECB => 122, 0xF71 => 129, 0xF72 => 130, 0xF7A => 130
1548
+ ,0xF7B => 130, 0xF7C => 130, 0xF7D => 130, 0xF80 => 130, 0xF74 => 132
1549
+ ,0x321 => 202, 0x322 => 202, 0x327 => 202, 0x328 => 202, 0x31B => 216
1550
+ ,0xF39 => 216, 0x1D165 => 216, 0x1D166 => 216, 0x1D16E => 216, 0x1D16F => 216
1551
+ ,0x1D170 => 216, 0x1D171 => 216, 0x1D172 => 216, 0x302A => 218, 0x316 => 220
1552
+ ,0x317 => 220, 0x318 => 220, 0x319 => 220, 0x31C => 220, 0x31D => 220
1553
+ ,0x31E => 220, 0x31F => 220, 0x320 => 220, 0x323 => 220, 0x324 => 220
1554
+ ,0x325 => 220, 0x326 => 220, 0x329 => 220, 0x32A => 220, 0x32B => 220
1555
+ ,0x32C => 220, 0x32D => 220, 0x32E => 220, 0x32F => 220, 0x330 => 220
1556
+ ,0x331 => 220, 0x332 => 220, 0x333 => 220, 0x339 => 220, 0x33A => 220
1557
+ ,0x33B => 220, 0x33C => 220, 0x347 => 220, 0x348 => 220, 0x349 => 220
1558
+ ,0x34D => 220, 0x34E => 220, 0x353 => 220, 0x354 => 220, 0x355 => 220
1559
+ ,0x356 => 220, 0x591 => 220, 0x596 => 220, 0x59B => 220, 0x5A3 => 220
1560
+ ,0x5A4 => 220, 0x5A5 => 220, 0x5A6 => 220, 0x5A7 => 220, 0x5AA => 220
1561
+ ,0x655 => 220, 0x656 => 220, 0x6E3 => 220, 0x6EA => 220, 0x6ED => 220
1562
+ ,0x731 => 220, 0x734 => 220, 0x737 => 220, 0x738 => 220, 0x739 => 220
1563
+ ,0x73B => 220, 0x73C => 220, 0x73E => 220, 0x742 => 220, 0x744 => 220
1564
+ ,0x746 => 220, 0x748 => 220, 0x952 => 220, 0xF18 => 220, 0xF19 => 220
1565
+ ,0xF35 => 220, 0xF37 => 220, 0xFC6 => 220, 0x193B => 220, 0x20E8 => 220
1566
+ ,0x1D17B => 220, 0x1D17C => 220, 0x1D17D => 220, 0x1D17E => 220, 0x1D17F => 220
1567
+ ,0x1D180 => 220, 0x1D181 => 220, 0x1D182 => 220, 0x1D18A => 220, 0x1D18B => 220
1568
+ ,0x59A => 222, 0x5AD => 222, 0x1929 => 222, 0x302D => 222, 0x302E => 224
1569
+ ,0x302F => 224, 0x1D16D => 226, 0x5AE => 228, 0x18A9 => 228, 0x302B => 228
1570
+ ,0x300 => 230, 0x301 => 230, 0x302 => 230, 0x303 => 230, 0x304 => 230
1571
+ ,0x305 => 230, 0x306 => 230, 0x307 => 230, 0x308 => 230, 0x309 => 230
1572
+ ,0x30A => 230, 0x30B => 230, 0x30C => 230, 0x30D => 230, 0x30E => 230
1573
+ ,0x30F => 230, 0x310 => 230, 0x311 => 230, 0x312 => 230, 0x313 => 230
1574
+ ,0x314 => 230, 0x33D => 230, 0x33E => 230, 0x33F => 230, 0x340 => 230
1575
+ ,0x341 => 230, 0x342 => 230, 0x343 => 230, 0x344 => 230, 0x346 => 230
1576
+ ,0x34A => 230, 0x34B => 230, 0x34C => 230, 0x350 => 230, 0x351 => 230
1577
+ ,0x352 => 230, 0x357 => 230, 0x363 => 230, 0x364 => 230, 0x365 => 230
1578
+ ,0x366 => 230, 0x367 => 230, 0x368 => 230, 0x369 => 230, 0x36A => 230
1579
+ ,0x36B => 230, 0x36C => 230, 0x36D => 230, 0x36E => 230, 0x36F => 230
1580
+ ,0x483 => 230, 0x484 => 230, 0x485 => 230, 0x486 => 230, 0x592 => 230
1581
+ ,0x593 => 230, 0x594 => 230, 0x595 => 230, 0x597 => 230, 0x598 => 230
1582
+ ,0x599 => 230, 0x59C => 230, 0x59D => 230, 0x59E => 230, 0x59F => 230
1583
+ ,0x5A0 => 230, 0x5A1 => 230, 0x5A8 => 230, 0x5A9 => 230, 0x5AB => 230
1584
+ ,0x5AC => 230, 0x5AF => 230, 0x5C4 => 230, 0x610 => 230, 0x611 => 230
1585
+ ,0x612 => 230, 0x613 => 230, 0x614 => 230, 0x615 => 230, 0x653 => 230
1586
+ ,0x654 => 230, 0x657 => 230, 0x658 => 230, 0x6D6 => 230, 0x6D7 => 230
1587
+ ,0x6D8 => 230, 0x6D9 => 230, 0x6DA => 230, 0x6DB => 230, 0x6DC => 230
1588
+ ,0x6DF => 230, 0x6E0 => 230, 0x6E1 => 230, 0x6E2 => 230, 0x6E4 => 230
1589
+ ,0x6E7 => 230, 0x6E8 => 230, 0x6EB => 230, 0x6EC => 230, 0x730 => 230
1590
+ ,0x732 => 230, 0x733 => 230, 0x735 => 230, 0x736 => 230, 0x73A => 230
1591
+ ,0x73D => 230, 0x73F => 230, 0x740 => 230, 0x741 => 230, 0x743 => 230
1592
+ ,0x745 => 230, 0x747 => 230, 0x749 => 230, 0x74A => 230, 0x951 => 230
1593
+ ,0x953 => 230, 0x954 => 230, 0xF82 => 230, 0xF83 => 230, 0xF86 => 230
1594
+ ,0xF87 => 230, 0x170D => 230, 0x193A => 230, 0x20D0 => 230, 0x20D1 => 230
1595
+ ,0x20D4 => 230, 0x20D5 => 230, 0x20D6 => 230, 0x20D7 => 230, 0x20DB => 230
1596
+ ,0x20DC => 230, 0x20E1 => 230, 0x20E7 => 230, 0x20E9 => 230, 0xFE20 => 230
1597
+ ,0xFE21 => 230, 0xFE22 => 230, 0xFE23 => 230, 0x1D185 => 230, 0x1D186 => 230
1598
+ ,0x1D187 => 230, 0x1D189 => 230, 0x1D188 => 230, 0x1D1AA => 230, 0x1D1AB => 230
1599
+ ,0x1D1AC => 230, 0x1D1AD => 230, 0x315 => 232, 0x31A => 232, 0x302C => 232
1600
+ ,0x35F => 233, 0x362 => 233, 0x35D => 234, 0x35E => 234, 0x360 => 234
1601
+ ,0x361 => 234, 0x345 => 240
1602
+ )
1603
+ );
1604
+ }
1605
+ ?>
app/code/community/Magazento/SocialLifestream/lib/lifestream.class.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //error_reporting(-1);
4
+ //
5
+ //require_once './simplepie.inc';
6
+
7
+ class LifeStream extends SimplePie {
8
+
9
+ private $instance;
10
+ private $urls;
11
+ private $rows;
12
+ private $twitter = array();
13
+ private $favicon = '';
14
+ private $output = '';
15
+ private $i = 1;
16
+
17
+ function LifeStream($rows = 10) {
18
+ $this->rows = $rows > 200 ? 200 : $rows;
19
+ $this->instance = new SimplePie(NULL, './cache/', 1800);
20
+ }
21
+
22
+ function addTwitter($username) {
23
+ $this->twitter[] = $username;
24
+ $this->urls[] = 'http://api.twitter.com/1/statuses/user_timeline/' . $username . '.rss?count=' . $this->rows;
25
+ }
26
+
27
+ function addDelicious($username) {
28
+ $this->urls[] = 'http://feeds.delicious.com/v2/rss/' . $username . '?count=' . $this->rows;
29
+ }
30
+
31
+ function addFlickr($username) {
32
+ $this->urls[] = 'http://api.flickr.com/services/feeds/photos_public.gne?id=' . $username . '&format=rss_200';
33
+ }
34
+
35
+ function addTumblr($username) {
36
+ $this->urls[] = 'http://' . $username . '.tumblr.com/rss';
37
+ }
38
+
39
+ function addYouTube($username) {
40
+ $this->urls[] = 'http://gdata.youtube.com/feeds/base/users/' . $username . '/uploads';
41
+ }
42
+
43
+ function addDribbble($username) {
44
+ $this->urls[] = 'http://dribbble.com/players/' . $username . '/shots.rss';
45
+ }
46
+
47
+ function addDigg($username) {
48
+ $this->urls[] = 'http://digg.com/users/' . $username . '/history.rss';
49
+ }
50
+
51
+ function addVimeo($username) {
52
+ $this->urls[] = 'http://vimeo.com/' . $username . '/videos/rss';
53
+ }
54
+
55
+ function addCustomFeed($feedurl,$icon = NULL) {
56
+ $this->urls[] = $feedurl;
57
+ $this->icon[$feedurl] = $icon;
58
+ }
59
+
60
+ function build() {
61
+ $this->instance->set_feed_url($this->urls);
62
+ $this->instance->init();
63
+ $this->instance->handle_content_type();
64
+
65
+ if($this->instance->error) {
66
+ $this->output .= $this->instance->error;
67
+ }
68
+ else {
69
+ $this->output .= "<ul class='lifestream'>\n";
70
+ foreach ($this->instance->get_items() as $item) {
71
+ if($this->i > $this->rows) break;
72
+ $feed = $item->get_feed();
73
+ $this->favicon = $feed->get_favicon();
74
+ if(isset($this->icon[$feed->subscribe_url()])) {
75
+ if($this->icon[$feed->subscribe_url()]!='')
76
+ $this->favicon = $this->icon[$feed->subscribe_url()];
77
+ }
78
+ $this->output .= "<li style='background-image:url(" . $this->favicon . ");'>\n";
79
+ $itemTitle = $item->get_title();
80
+ foreach($this->twitter as $twitterUsername) {
81
+ if($feed->get_link() == 'http://twitter.com/' . $twitterUsername) {
82
+ $itemTitle = substr($item->get_title(),strlen($twitterUsername)+2);
83
+ }
84
+ }
85
+ $this->output .= $this->makeUrls($itemTitle);
86
+ if(substr($item->get_permalink(),0,28)=='http://www.youtube.com/watch') {
87
+ $this->output .= "<object width='560' height='340'><param name='movie' value='" . $this->youtubeEmbed($item->get_permalink()) . "'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='" . $this->youtubeEmbed($item->get_permalink()) . "' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='560' height='340'></embed></object>";
88
+ }
89
+ $this->output .= "<br /><span><a href='" . $item->get_permalink() . "'>" . $this->timeAgo(strtotime($item->get_date())) . "</a></span>";
90
+ $this->output .= "</li>\n";
91
+ $this->i++;
92
+ }
93
+ $this->output .= "</ul>\n";
94
+ }
95
+ return $this->output;
96
+ }
97
+
98
+ function youtubeEmbed($text) {
99
+ return preg_replace('/http:\/\/(www.)?(youtu.be\/|youtube.com\/watch\?v=)([a-zA-Z0-9?%.;:\\/=+_-]+)([&]*([a-zA-Z0-9?&%.;:\\/=+_-]*))/i', 'http://www.youtube.com/v/$3?fs=1&amp;hl=en_US', $text);
100
+ }
101
+
102
+ function timeAgo($timestamp,$output = 'less than a minute ago') {
103
+ $timestamp = time() - $timestamp;
104
+ $units = array(604800=>'week',86400=>'day',3600=>'hour',60=>'minute');
105
+ foreach($units as $seconds => $unit) {
106
+ if($seconds<=$timestamp) {
107
+ $value = floor($timestamp/$seconds);
108
+ $output = 'about '.$value.' '.$unit.($value == 1 ? NULL : 's').' ago';
109
+ break;
110
+ }
111
+ }
112
+ return $output;
113
+ }
114
+
115
+ function shortenUrl($url,$length) {
116
+ $output = substr($url, 0, $length);
117
+ if(isset($url[$length]))
118
+ $output .= '...';
119
+ return $output;
120
+ }
121
+
122
+ function makeUrls($text) {
123
+ $text = preg_replace("/((http(s?):\/\/)|(www\.))([\w\.]+)([a-zA-Z0-9?&%.;:\/=+_-]+)/ie", "'<a href=\"http$3://$4$5$6\" target=\"_blank\">' . \$this->shortenUrl(\"$2$4$5$6\",25) . '</a>'", $text);
124
+ $text = preg_replace("/(?<=\A|[^A-Za-z0-9_])@([A-Za-z0-9_]+)(?=\Z|[^A-Za-z0-9_])/", "<a href='http://twitter.com/$1' target='_blank'>$0</a>", $text);
125
+ $text = preg_replace("/(?<=\A|[^A-Za-z0-9_])#([A-Za-z0-9_]+)(?=\Z|[^A-Za-z0-9_])/", "<a href='http://twitter.com/search?q=%23$1' target='_blank'>$0</a>", $text);
126
+ return $text;
127
+ }
128
+
129
+ }
130
+
131
+ ?>
app/code/community/Magazento/SocialLifestream/lib/simplepie.inc ADDED
@@ -0,0 +1,15025 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SimplePie
4
+ *
5
+ * A PHP-Based RSS and Atom Feed Framework.
6
+ * Takes the hard work out of managing a complete RSS/Atom solution.
7
+ *
8
+ * Copyright (c) 2004-2009, Ryan Parman and Geoffrey Sneddon
9
+ * All rights reserved.
10
+ *
11
+ * Redistribution and use in source and binary forms, with or without modification, are
12
+ * permitted provided that the following conditions are met:
13
+ *
14
+ * * Redistributions of source code must retain the above copyright notice, this list of
15
+ * conditions and the following disclaimer.
16
+ *
17
+ * * Redistributions in binary form must reproduce the above copyright notice, this list
18
+ * of conditions and the following disclaimer in the documentation and/or other materials
19
+ * provided with the distribution.
20
+ *
21
+ * * Neither the name of the SimplePie Team nor the names of its contributors may be used
22
+ * to endorse or promote products derived from this software without specific prior
23
+ * written permission.
24
+ *
25
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
26
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
27
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
28
+ * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
+ * POSSIBILITY OF SUCH DAMAGE.
34
+ *
35
+ * @package SimplePie
36
+ * @version 1.2.1-dev
37
+ * @copyright 2004-2009 Ryan Parman, Geoffrey Sneddon
38
+ * @author Ryan Parman
39
+ * @author Geoffrey Sneddon
40
+ * @link http://simplepie.org/ SimplePie
41
+ * @link http://simplepie.org/support/ Please submit all bug reports and feature requests to the SimplePie forums
42
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
43
+ * @todo phpDoc comments
44
+ */
45
+ /**
46
+ * SimplePie Name
47
+ */
48
+ define('SIMPLEPIE_NAME', 'SimplePie');
49
+
50
+ /**
51
+ * SimplePie Version
52
+ */
53
+ define('SIMPLEPIE_VERSION', '1.2.1-dev');
54
+
55
+ /**
56
+ * SimplePie Build
57
+ * @todo Hardcode for release (there's no need to have to call SimplePie_Misc::parse_date() only every load of simplepie.inc)
58
+ */
59
+ define('SIMPLEPIE_BUILD', gmdate('YmdHis', SimplePie_Misc::parse_date(substr('$Date$', 7, 25)) ? SimplePie_Misc::parse_date(substr('$Date$', 7, 25)) : filemtime(__FILE__)));
60
+
61
+ /**
62
+ * SimplePie Website URL
63
+ */
64
+ define('SIMPLEPIE_URL', 'http://simplepie.org');
65
+
66
+ /**
67
+ * SimplePie Useragent
68
+ * @see SimplePie::set_useragent()
69
+ */
70
+ define('SIMPLEPIE_USERAGENT', SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION . ' (Feed Parser; ' . SIMPLEPIE_URL . '; Allow like Gecko) Build/' . SIMPLEPIE_BUILD);
71
+
72
+ /**
73
+ * SimplePie Linkback
74
+ */
75
+ define('SIMPLEPIE_LINKBACK', '<a href="' . SIMPLEPIE_URL . '" title="' . SIMPLEPIE_NAME . ' ' . SIMPLEPIE_VERSION . '">' . SIMPLEPIE_NAME . '</a>');
76
+
77
+ /**
78
+ * No Autodiscovery
79
+ * @see SimplePie::set_autodiscovery_level()
80
+ */
81
+ define('SIMPLEPIE_LOCATOR_NONE', 0);
82
+
83
+ /**
84
+ * Feed Link Element Autodiscovery
85
+ * @see SimplePie::set_autodiscovery_level()
86
+ */
87
+ define('SIMPLEPIE_LOCATOR_AUTODISCOVERY', 1);
88
+
89
+ /**
90
+ * Local Feed Extension Autodiscovery
91
+ * @see SimplePie::set_autodiscovery_level()
92
+ */
93
+ define('SIMPLEPIE_LOCATOR_LOCAL_EXTENSION', 2);
94
+
95
+ /**
96
+ * Local Feed Body Autodiscovery
97
+ * @see SimplePie::set_autodiscovery_level()
98
+ */
99
+ define('SIMPLEPIE_LOCATOR_LOCAL_BODY', 4);
100
+
101
+ /**
102
+ * Remote Feed Extension Autodiscovery
103
+ * @see SimplePie::set_autodiscovery_level()
104
+ */
105
+ define('SIMPLEPIE_LOCATOR_REMOTE_EXTENSION', 8);
106
+
107
+ /**
108
+ * Remote Feed Body Autodiscovery
109
+ * @see SimplePie::set_autodiscovery_level()
110
+ */
111
+ define('SIMPLEPIE_LOCATOR_REMOTE_BODY', 16);
112
+
113
+ /**
114
+ * All Feed Autodiscovery
115
+ * @see SimplePie::set_autodiscovery_level()
116
+ */
117
+ define('SIMPLEPIE_LOCATOR_ALL', 31);
118
+
119
+ /**
120
+ * No known feed type
121
+ */
122
+ define('SIMPLEPIE_TYPE_NONE', 0);
123
+
124
+ /**
125
+ * RSS 0.90
126
+ */
127
+ define('SIMPLEPIE_TYPE_RSS_090', 1);
128
+
129
+ /**
130
+ * RSS 0.91 (Netscape)
131
+ */
132
+ define('SIMPLEPIE_TYPE_RSS_091_NETSCAPE', 2);
133
+
134
+ /**
135
+ * RSS 0.91 (Userland)
136
+ */
137
+ define('SIMPLEPIE_TYPE_RSS_091_USERLAND', 4);
138
+
139
+ /**
140
+ * RSS 0.91 (both Netscape and Userland)
141
+ */
142
+ define('SIMPLEPIE_TYPE_RSS_091', 6);
143
+
144
+ /**
145
+ * RSS 0.92
146
+ */
147
+ define('SIMPLEPIE_TYPE_RSS_092', 8);
148
+
149
+ /**
150
+ * RSS 0.93
151
+ */
152
+ define('SIMPLEPIE_TYPE_RSS_093', 16);
153
+
154
+ /**
155
+ * RSS 0.94
156
+ */
157
+ define('SIMPLEPIE_TYPE_RSS_094', 32);
158
+
159
+ /**
160
+ * RSS 1.0
161
+ */
162
+ define('SIMPLEPIE_TYPE_RSS_10', 64);
163
+
164
+ /**
165
+ * RSS 2.0
166
+ */
167
+ define('SIMPLEPIE_TYPE_RSS_20', 128);
168
+
169
+ /**
170
+ * RDF-based RSS
171
+ */
172
+ define('SIMPLEPIE_TYPE_RSS_RDF', 65);
173
+
174
+ /**
175
+ * Non-RDF-based RSS (truly intended as syndication format)
176
+ */
177
+ define('SIMPLEPIE_TYPE_RSS_SYNDICATION', 190);
178
+
179
+ /**
180
+ * All RSS
181
+ */
182
+ define('SIMPLEPIE_TYPE_RSS_ALL', 255);
183
+
184
+ /**
185
+ * Atom 0.3
186
+ */
187
+ define('SIMPLEPIE_TYPE_ATOM_03', 256);
188
+
189
+ /**
190
+ * Atom 1.0
191
+ */
192
+ define('SIMPLEPIE_TYPE_ATOM_10', 512);
193
+
194
+ /**
195
+ * All Atom
196
+ */
197
+ define('SIMPLEPIE_TYPE_ATOM_ALL', 768);
198
+
199
+ /**
200
+ * All feed types
201
+ */
202
+ define('SIMPLEPIE_TYPE_ALL', 1023);
203
+
204
+ /**
205
+ * No construct
206
+ */
207
+ define('SIMPLEPIE_CONSTRUCT_NONE', 0);
208
+
209
+ /**
210
+ * Text construct
211
+ */
212
+ define('SIMPLEPIE_CONSTRUCT_TEXT', 1);
213
+
214
+ /**
215
+ * HTML construct
216
+ */
217
+ define('SIMPLEPIE_CONSTRUCT_HTML', 2);
218
+
219
+ /**
220
+ * XHTML construct
221
+ */
222
+ define('SIMPLEPIE_CONSTRUCT_XHTML', 4);
223
+
224
+ /**
225
+ * base64-encoded construct
226
+ */
227
+ define('SIMPLEPIE_CONSTRUCT_BASE64', 8);
228
+
229
+ /**
230
+ * IRI construct
231
+ */
232
+ define('SIMPLEPIE_CONSTRUCT_IRI', 16);
233
+
234
+ /**
235
+ * A construct that might be HTML
236
+ */
237
+ define('SIMPLEPIE_CONSTRUCT_MAYBE_HTML', 32);
238
+
239
+ /**
240
+ * All constructs
241
+ */
242
+ define('SIMPLEPIE_CONSTRUCT_ALL', 63);
243
+
244
+ /**
245
+ * Don't change case
246
+ */
247
+ define('SIMPLEPIE_SAME_CASE', 1);
248
+
249
+ /**
250
+ * Change to lowercase
251
+ */
252
+ define('SIMPLEPIE_LOWERCASE', 2);
253
+
254
+ /**
255
+ * Change to uppercase
256
+ */
257
+ define('SIMPLEPIE_UPPERCASE', 4);
258
+
259
+ /**
260
+ * PCRE for HTML attributes
261
+ */
262
+ define('SIMPLEPIE_PCRE_HTML_ATTRIBUTE', '((?:[\x09\x0A\x0B\x0C\x0D\x20]+[^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?)*)[\x09\x0A\x0B\x0C\x0D\x20]*');
263
+
264
+ /**
265
+ * PCRE for XML attributes
266
+ */
267
+ define('SIMPLEPIE_PCRE_XML_ATTRIBUTE', '((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'))*)\s*');
268
+
269
+ /**
270
+ * XML Namespace
271
+ */
272
+ define('SIMPLEPIE_NAMESPACE_XML', 'http://www.w3.org/XML/1998/namespace');
273
+
274
+ /**
275
+ * Atom 1.0 Namespace
276
+ */
277
+ define('SIMPLEPIE_NAMESPACE_ATOM_10', 'http://www.w3.org/2005/Atom');
278
+
279
+ /**
280
+ * Atom 0.3 Namespace
281
+ */
282
+ define('SIMPLEPIE_NAMESPACE_ATOM_03', 'http://purl.org/atom/ns#');
283
+
284
+ /**
285
+ * RDF Namespace
286
+ */
287
+ define('SIMPLEPIE_NAMESPACE_RDF', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
288
+
289
+ /**
290
+ * RSS 0.90 Namespace
291
+ */
292
+ define('SIMPLEPIE_NAMESPACE_RSS_090', 'http://my.netscape.com/rdf/simple/0.9/');
293
+
294
+ /**
295
+ * RSS 1.0 Namespace
296
+ */
297
+ define('SIMPLEPIE_NAMESPACE_RSS_10', 'http://purl.org/rss/1.0/');
298
+
299
+ /**
300
+ * RSS 1.0 Content Module Namespace
301
+ */
302
+ define('SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT', 'http://purl.org/rss/1.0/modules/content/');
303
+
304
+ /**
305
+ * RSS 2.0 Namespace
306
+ * (Stupid, I know, but I'm certain it will confuse people less with support.)
307
+ */
308
+ define('SIMPLEPIE_NAMESPACE_RSS_20', '');
309
+
310
+ /**
311
+ * DC 1.0 Namespace
312
+ */
313
+ define('SIMPLEPIE_NAMESPACE_DC_10', 'http://purl.org/dc/elements/1.0/');
314
+
315
+ /**
316
+ * DC 1.1 Namespace
317
+ */
318
+ define('SIMPLEPIE_NAMESPACE_DC_11', 'http://purl.org/dc/elements/1.1/');
319
+
320
+ /**
321
+ * W3C Basic Geo (WGS84 lat/long) Vocabulary Namespace
322
+ */
323
+ define('SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO', 'http://www.w3.org/2003/01/geo/wgs84_pos#');
324
+
325
+ /**
326
+ * GeoRSS Namespace
327
+ */
328
+ define('SIMPLEPIE_NAMESPACE_GEORSS', 'http://www.georss.org/georss');
329
+
330
+ /**
331
+ * Media RSS Namespace
332
+ */
333
+ define('SIMPLEPIE_NAMESPACE_MEDIARSS', 'http://search.yahoo.com/mrss/');
334
+
335
+ /**
336
+ * Wrong Media RSS Namespace
337
+ */
338
+ define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG', 'http://search.yahoo.com/mrss');
339
+
340
+ /**
341
+ * iTunes RSS Namespace
342
+ */
343
+ define('SIMPLEPIE_NAMESPACE_ITUNES', 'http://www.itunes.com/dtds/podcast-1.0.dtd');
344
+
345
+ /**
346
+ * XHTML Namespace
347
+ */
348
+ define('SIMPLEPIE_NAMESPACE_XHTML', 'http://www.w3.org/1999/xhtml');
349
+
350
+ /**
351
+ * IANA Link Relations Registry
352
+ */
353
+ define('SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY', 'http://www.iana.org/assignments/relation/');
354
+
355
+ /**
356
+ * Whether we're running on PHP5
357
+ */
358
+ define('SIMPLEPIE_PHP5', version_compare(PHP_VERSION, '5.0.0', '>='));
359
+
360
+ /**
361
+ * No file source
362
+ */
363
+ define('SIMPLEPIE_FILE_SOURCE_NONE', 0);
364
+
365
+ /**
366
+ * Remote file source
367
+ */
368
+ define('SIMPLEPIE_FILE_SOURCE_REMOTE', 1);
369
+
370
+ /**
371
+ * Local file source
372
+ */
373
+ define('SIMPLEPIE_FILE_SOURCE_LOCAL', 2);
374
+
375
+ /**
376
+ * fsockopen() file source
377
+ */
378
+ define('SIMPLEPIE_FILE_SOURCE_FSOCKOPEN', 4);
379
+
380
+ /**
381
+ * cURL file source
382
+ */
383
+ define('SIMPLEPIE_FILE_SOURCE_CURL', 8);
384
+
385
+ /**
386
+ * file_get_contents() file source
387
+ */
388
+ define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16);
389
+
390
+ /**
391
+ * SimplePie
392
+ *
393
+ * @package SimplePie
394
+ */
395
+ class SimplePie
396
+ {
397
+ /**
398
+ * @var array Raw data
399
+ * @access private
400
+ */
401
+ var $data = array();
402
+
403
+ /**
404
+ * @var mixed Error string
405
+ * @access private
406
+ */
407
+ var $error;
408
+
409
+ /**
410
+ * @var object Instance of SimplePie_Sanitize (or other class)
411
+ * @see SimplePie::set_sanitize_class()
412
+ * @access private
413
+ */
414
+ var $sanitize;
415
+
416
+ /**
417
+ * @var string SimplePie Useragent
418
+ * @see SimplePie::set_useragent()
419
+ * @access private
420
+ */
421
+ var $useragent = SIMPLEPIE_USERAGENT;
422
+
423
+ /**
424
+ * @var string Feed URL
425
+ * @see SimplePie::set_feed_url()
426
+ * @access private
427
+ */
428
+ var $feed_url;
429
+
430
+ /**
431
+ * @var object Instance of SimplePie_File to use as a feed
432
+ * @see SimplePie::set_file()
433
+ * @access private
434
+ */
435
+ var $file;
436
+
437
+ /**
438
+ * @var string Raw feed data
439
+ * @see SimplePie::set_raw_data()
440
+ * @access private
441
+ */
442
+ var $raw_data;
443
+
444
+ /**
445
+ * @var int Timeout for fetching remote files
446
+ * @see SimplePie::set_timeout()
447
+ * @access private
448
+ */
449
+ var $timeout = 10;
450
+
451
+ /**
452
+ * @var bool Forces fsockopen() to be used for remote files instead
453
+ * of cURL, even if a new enough version is installed
454
+ * @see SimplePie::force_fsockopen()
455
+ * @access private
456
+ */
457
+ var $force_fsockopen = false;
458
+
459
+ /**
460
+ * @var bool Force the given data/URL to be treated as a feed no matter what
461
+ * it appears like
462
+ * @see SimplePie::force_feed()
463
+ * @access private
464
+ */
465
+ var $force_feed = false;
466
+
467
+ /**
468
+ * @var bool Enable/Disable XML dump
469
+ * @see SimplePie::enable_xml_dump()
470
+ * @access private
471
+ */
472
+ var $xml_dump = false;
473
+
474
+ /**
475
+ * @var bool Enable/Disable Caching
476
+ * @see SimplePie::enable_cache()
477
+ * @access private
478
+ */
479
+ var $cache = true;
480
+
481
+ /**
482
+ * @var int Cache duration (in seconds)
483
+ * @see SimplePie::set_cache_duration()
484
+ * @access private
485
+ */
486
+ var $cache_duration = 3600;
487
+
488
+ /**
489
+ * @var int Auto-discovery cache duration (in seconds)
490
+ * @see SimplePie::set_autodiscovery_cache_duration()
491
+ * @access private
492
+ */
493
+ var $autodiscovery_cache_duration = 604800; // 7 Days.
494
+
495
+ /**
496
+ * @var string Cache location (relative to executing script)
497
+ * @see SimplePie::set_cache_location()
498
+ * @access private
499
+ */
500
+ var $cache_location = './cache';
501
+
502
+ /**
503
+ * @var string Function that creates the cache filename
504
+ * @see SimplePie::set_cache_name_function()
505
+ * @access private
506
+ */
507
+ var $cache_name_function = 'md5';
508
+
509
+ /**
510
+ * @var bool Reorder feed by date descending
511
+ * @see SimplePie::enable_order_by_date()
512
+ * @access private
513
+ */
514
+ var $order_by_date = true;
515
+
516
+ /**
517
+ * @var mixed Force input encoding to be set to the follow value
518
+ * (false, or anything type-cast to false, disables this feature)
519
+ * @see SimplePie::set_input_encoding()
520
+ * @access private
521
+ */
522
+ var $input_encoding = false;
523
+
524
+ /**
525
+ * @var int Feed Autodiscovery Level
526
+ * @see SimplePie::set_autodiscovery_level()
527
+ * @access private
528
+ */
529
+ var $autodiscovery = SIMPLEPIE_LOCATOR_ALL;
530
+
531
+ /**
532
+ * @var string Class used for caching feeds
533
+ * @see SimplePie::set_cache_class()
534
+ * @access private
535
+ */
536
+ var $cache_class = 'SimplePie_Cache';
537
+
538
+ /**
539
+ * @var string Class used for locating feeds
540
+ * @see SimplePie::set_locator_class()
541
+ * @access private
542
+ */
543
+ var $locator_class = 'SimplePie_Locator';
544
+
545
+ /**
546
+ * @var string Class used for parsing feeds
547
+ * @see SimplePie::set_parser_class()
548
+ * @access private
549
+ */
550
+ var $parser_class = 'SimplePie_Parser';
551
+
552
+ /**
553
+ * @var string Class used for fetching feeds
554
+ * @see SimplePie::set_file_class()
555
+ * @access private
556
+ */
557
+ var $file_class = 'SimplePie_File';
558
+
559
+ /**
560
+ * @var string Class used for items
561
+ * @see SimplePie::set_item_class()
562
+ * @access private
563
+ */
564
+ var $item_class = 'SimplePie_Item';
565
+
566
+ /**
567
+ * @var string Class used for authors
568
+ * @see SimplePie::set_author_class()
569
+ * @access private
570
+ */
571
+ var $author_class = 'SimplePie_Author';
572
+
573
+ /**
574
+ * @var string Class used for categories
575
+ * @see SimplePie::set_category_class()
576
+ * @access private
577
+ */
578
+ var $category_class = 'SimplePie_Category';
579
+
580
+ /**
581
+ * @var string Class used for enclosures
582
+ * @see SimplePie::set_enclosures_class()
583
+ * @access private
584
+ */
585
+ var $enclosure_class = 'SimplePie_Enclosure';
586
+
587
+ /**
588
+ * @var string Class used for Media RSS <media:text> captions
589
+ * @see SimplePie::set_caption_class()
590
+ * @access private
591
+ */
592
+ var $caption_class = 'SimplePie_Caption';
593
+
594
+ /**
595
+ * @var string Class used for Media RSS <media:copyright>
596
+ * @see SimplePie::set_copyright_class()
597
+ * @access private
598
+ */
599
+ var $copyright_class = 'SimplePie_Copyright';
600
+
601
+ /**
602
+ * @var string Class used for Media RSS <media:credit>
603
+ * @see SimplePie::set_credit_class()
604
+ * @access private
605
+ */
606
+ var $credit_class = 'SimplePie_Credit';
607
+
608
+ /**
609
+ * @var string Class used for Media RSS <media:rating>
610
+ * @see SimplePie::set_rating_class()
611
+ * @access private
612
+ */
613
+ var $rating_class = 'SimplePie_Rating';
614
+
615
+ /**
616
+ * @var string Class used for Media RSS <media:restriction>
617
+ * @see SimplePie::set_restriction_class()
618
+ * @access private
619
+ */
620
+ var $restriction_class = 'SimplePie_Restriction';
621
+
622
+ /**
623
+ * @var string Class used for content-type sniffing
624
+ * @see SimplePie::set_content_type_sniffer_class()
625
+ * @access private
626
+ */
627
+ var $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer';
628
+
629
+ /**
630
+ * @var string Class used for item sources.
631
+ * @see SimplePie::set_source_class()
632
+ * @access private
633
+ */
634
+ var $source_class = 'SimplePie_Source';
635
+
636
+ /**
637
+ * @var mixed Set javascript query string parameter (false, or
638
+ * anything type-cast to false, disables this feature)
639
+ * @see SimplePie::set_javascript()
640
+ * @access private
641
+ */
642
+ var $javascript = 'js';
643
+
644
+ /**
645
+ * @var int Maximum number of feeds to check with autodiscovery
646
+ * @see SimplePie::set_max_checked_feeds()
647
+ * @access private
648
+ */
649
+ var $max_checked_feeds = 10;
650
+
651
+ /**
652
+ * @var array All the feeds found during the autodiscovery process
653
+ * @see SimplePie::get_all_discovered_feeds()
654
+ * @access private
655
+ */
656
+ var $all_discovered_feeds = array();
657
+
658
+ /**
659
+ * @var string Web-accessible path to the handler_favicon.php file.
660
+ * @see SimplePie::set_favicon_handler()
661
+ * @access private
662
+ */
663
+ var $favicon_handler = '';
664
+
665
+ /**
666
+ * @var string Web-accessible path to the handler_image.php file.
667
+ * @see SimplePie::set_image_handler()
668
+ * @access private
669
+ */
670
+ var $image_handler = '';
671
+
672
+ /**
673
+ * @var array Stores the URLs when multiple feeds are being initialized.
674
+ * @see SimplePie::set_feed_url()
675
+ * @access private
676
+ */
677
+ var $multifeed_url = array();
678
+
679
+ /**
680
+ * @var array Stores SimplePie objects when multiple feeds initialized.
681
+ * @access private
682
+ */
683
+ var $multifeed_objects = array();
684
+
685
+ /**
686
+ * @var array Stores the get_object_vars() array for use with multifeeds.
687
+ * @see SimplePie::set_feed_url()
688
+ * @access private
689
+ */
690
+ var $config_settings = null;
691
+
692
+ /**
693
+ * @var integer Stores the number of items to return per-feed with multifeeds.
694
+ * @see SimplePie::set_item_limit()
695
+ * @access private
696
+ */
697
+ var $item_limit = 0;
698
+
699
+ /**
700
+ * @var array Stores the default attributes to be stripped by strip_attributes().
701
+ * @see SimplePie::strip_attributes()
702
+ * @access private
703
+ */
704
+ var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc');
705
+
706
+ /**
707
+ * @var array Stores the default tags to be stripped by strip_htmltags().
708
+ * @see SimplePie::strip_htmltags()
709
+ * @access private
710
+ */
711
+ var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style');
712
+
713
+ /**
714
+ * The SimplePie class contains feed level data and options
715
+ *
716
+ * There are two ways that you can create a new SimplePie object. The first
717
+ * is by passing a feed URL as a parameter to the SimplePie constructor
718
+ * (as well as optionally setting the cache location and cache expiry). This
719
+ * will initialise the whole feed with all of the default settings, and you
720
+ * can begin accessing methods and properties immediately.
721
+ *
722
+ * The second way is to create the SimplePie object with no parameters
723
+ * at all. This will enable you to set configuration options. After setting
724
+ * them, you must initialise the feed using $feed->init(). At that point the
725
+ * object's methods and properties will be available to you. This format is
726
+ * what is used throughout this documentation.
727
+ *
728
+ * @access public
729
+ * @since 1.0 Preview Release
730
+ * @param string $feed_url This is the URL you want to parse.
731
+ * @param string $cache_location This is where you want the cache to be stored.
732
+ * @param int $cache_duration This is the number of seconds that you want to store the cache file for.
733
+ */
734
+ function SimplePie($feed_url = null, $cache_location = null, $cache_duration = null)
735
+ {
736
+ // Other objects, instances created here so we can set options on them
737
+ // $this->sanitize = new SimplePie_Sanitize;
738
+ $this->sanitize = new SimplePie_Sanitize;
739
+
740
+ // Set options if they're passed to the constructor
741
+ if ($cache_location !== null)
742
+ {
743
+ $this->set_cache_location($cache_location);
744
+ }
745
+
746
+ if ($cache_duration !== null)
747
+ {
748
+ $this->set_cache_duration($cache_duration);
749
+ }
750
+
751
+ // Only init the script if we're passed a feed URL
752
+ if ($feed_url !== null)
753
+ {
754
+ $this->set_feed_url($feed_url);
755
+ $this->init();
756
+ }
757
+ }
758
+
759
+ /**
760
+ * Used for converting object to a string
761
+ */
762
+ function __toString()
763
+ {
764
+ return md5(serialize($this->data));
765
+ }
766
+
767
+ /**
768
+ * Remove items that link back to this before destroying this object
769
+ */
770
+ function __destruct()
771
+ {
772
+ if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))
773
+ {
774
+ if (!empty($this->data['items']))
775
+ {
776
+ foreach ($this->data['items'] as $item)
777
+ {
778
+ $item->__destruct();
779
+ }
780
+ unset($item, $this->data['items']);
781
+ }
782
+ if (!empty($this->data['ordered_items']))
783
+ {
784
+ foreach ($this->data['ordered_items'] as $item)
785
+ {
786
+ $item->__destruct();
787
+ }
788
+ unset($item, $this->data['ordered_items']);
789
+ }
790
+ }
791
+ }
792
+
793
+ /**
794
+ * Force the given data/URL to be treated as a feed no matter what it
795
+ * appears like
796
+ *
797
+ * @access public
798
+ * @since 1.1
799
+ * @param bool $enable Force the given data/URL to be treated as a feed
800
+ */
801
+ function force_feed($enable = false)
802
+ {
803
+ $this->force_feed = (bool) $enable;
804
+ }
805
+
806
+ /**
807
+ * This is the URL of the feed you want to parse.
808
+ *
809
+ * This allows you to enter the URL of the feed you want to parse, or the
810
+ * website you want to try to use auto-discovery on. This takes priority
811
+ * over any set raw data.
812
+ *
813
+ * You can set multiple feeds to mash together by passing an array instead
814
+ * of a string for the $url. Remember that with each additional feed comes
815
+ * additional processing and resources.
816
+ *
817
+ * @access public
818
+ * @since 1.0 Preview Release
819
+ * @param mixed $url This is the URL (or array of URLs) that you want to parse.
820
+ * @see SimplePie::set_raw_data()
821
+ */
822
+ function set_feed_url($url)
823
+ {
824
+ if (is_array($url))
825
+ {
826
+ $this->multifeed_url = array();
827
+ foreach ($url as $value)
828
+ {
829
+ $this->multifeed_url[] = SimplePie_Misc::fix_protocol($value, 1);
830
+ }
831
+ }
832
+ else
833
+ {
834
+ $this->feed_url = SimplePie_Misc::fix_protocol($url, 1);
835
+ }
836
+ }
837
+
838
+ /**
839
+ * Provides an instance of SimplePie_File to use as a feed
840
+ *
841
+ * @access public
842
+ * @param object &$file Instance of SimplePie_File (or subclass)
843
+ * @return bool True on success, false on failure
844
+ */
845
+ function set_file(&$file)
846
+ {
847
+ if (is_a($file, 'SimplePie_File'))
848
+ {
849
+ $this->feed_url = $file->url;
850
+ $this->file =& $file;
851
+ return true;
852
+ }
853
+ return false;
854
+ }
855
+
856
+ /**
857
+ * Allows you to use a string of RSS/Atom data instead of a remote feed.
858
+ *
859
+ * If you have a feed available as a string in PHP, you can tell SimplePie
860
+ * to parse that data string instead of a remote feed. Any set feed URL
861
+ * takes precedence.
862
+ *
863
+ * @access public
864
+ * @since 1.0 Beta 3
865
+ * @param string $data RSS or Atom data as a string.
866
+ * @see SimplePie::set_feed_url()
867
+ */
868
+ function set_raw_data($data)
869
+ {
870
+ $this->raw_data = $data;
871
+ }
872
+
873
+ /**
874
+ * Allows you to override the default timeout for fetching remote feeds.
875
+ *
876
+ * This allows you to change the maximum time the feed's server to respond
877
+ * and send the feed back.
878
+ *
879
+ * @access public
880
+ * @since 1.0 Beta 3
881
+ * @param int $timeout The maximum number of seconds to spend waiting to retrieve a feed.
882
+ */
883
+ function set_timeout($timeout = 10)
884
+ {
885
+ $this->timeout = (int) $timeout;
886
+ }
887
+
888
+ /**
889
+ * Forces SimplePie to use fsockopen() instead of the preferred cURL
890
+ * functions.
891
+ *
892
+ * @access public
893
+ * @since 1.0 Beta 3
894
+ * @param bool $enable Force fsockopen() to be used
895
+ */
896
+ function force_fsockopen($enable = false)
897
+ {
898
+ $this->force_fsockopen = (bool) $enable;
899
+ }
900
+
901
+ /**
902
+ * Outputs the raw XML content of the feed, after it has gone through
903
+ * SimplePie's filters.
904
+ *
905
+ * Used only for debugging, this function will output the XML content as
906
+ * text/xml. When SimplePie reads in a feed, it does a bit of cleaning up
907
+ * before trying to parse it. Many parts of the feed are re-written in
908
+ * memory, and in the end, you have a parsable feed. XML dump shows you the
909
+ * actual XML that SimplePie tries to parse, which may or may not be very
910
+ * different from the original feed.
911
+ *
912
+ * @access public
913
+ * @since 1.0 Preview Release
914
+ * @param bool $enable Enable XML dump
915
+ */
916
+ function enable_xml_dump($enable = false)
917
+ {
918
+ $this->xml_dump = (bool) $enable;
919
+ }
920
+
921
+ /**
922
+ * Enables/disables caching in SimplePie.
923
+ *
924
+ * This option allows you to disable caching all-together in SimplePie.
925
+ * However, disabling the cache can lead to longer load times.
926
+ *
927
+ * @access public
928
+ * @since 1.0 Preview Release
929
+ * @param bool $enable Enable caching
930
+ */
931
+ function enable_cache($enable = true)
932
+ {
933
+ $this->cache = (bool) $enable;
934
+ }
935
+
936
+ /**
937
+ * Set the length of time (in seconds) that the contents of a feed
938
+ * will be cached.
939
+ *
940
+ * @access public
941
+ * @param int $seconds The feed content cache duration.
942
+ */
943
+ function set_cache_duration($seconds = 3600)
944
+ {
945
+ $this->cache_duration = (int) $seconds;
946
+ }
947
+
948
+ /**
949
+ * Set the length of time (in seconds) that the autodiscovered feed
950
+ * URL will be cached.
951
+ *
952
+ * @access public
953
+ * @param int $seconds The autodiscovered feed URL cache duration.
954
+ */
955
+ function set_autodiscovery_cache_duration($seconds = 604800)
956
+ {
957
+ $this->autodiscovery_cache_duration = (int) $seconds;
958
+ }
959
+
960
+ /**
961
+ * Set the file system location where the cached files should be stored.
962
+ *
963
+ * @access public
964
+ * @param string $location The file system location.
965
+ */
966
+ function set_cache_location($location = './cache')
967
+ {
968
+ $this->cache_location = (string) $location;
969
+ }
970
+
971
+ /**
972
+ * Determines whether feed items should be sorted into reverse chronological order.
973
+ *
974
+ * @access public
975
+ * @param bool $enable Sort as reverse chronological order.
976
+ */
977
+ function enable_order_by_date($enable = true)
978
+ {
979
+ $this->order_by_date = (bool) $enable;
980
+ }
981
+
982
+ /**
983
+ * Allows you to override the character encoding reported by the feed.
984
+ *
985
+ * @access public
986
+ * @param string $encoding Character encoding.
987
+ */
988
+ function set_input_encoding($encoding = false)
989
+ {
990
+ if ($encoding)
991
+ {
992
+ $this->input_encoding = (string) $encoding;
993
+ }
994
+ else
995
+ {
996
+ $this->input_encoding = false;
997
+ }
998
+ }
999
+
1000
+ /**
1001
+ * Set how much feed autodiscovery to do
1002
+ *
1003
+ * @access public
1004
+ * @see SIMPLEPIE_LOCATOR_NONE
1005
+ * @see SIMPLEPIE_LOCATOR_AUTODISCOVERY
1006
+ * @see SIMPLEPIE_LOCATOR_LOCAL_EXTENSION
1007
+ * @see SIMPLEPIE_LOCATOR_LOCAL_BODY
1008
+ * @see SIMPLEPIE_LOCATOR_REMOTE_EXTENSION
1009
+ * @see SIMPLEPIE_LOCATOR_REMOTE_BODY
1010
+ * @see SIMPLEPIE_LOCATOR_ALL
1011
+ * @param int $level Feed Autodiscovery Level (level can be a
1012
+ * combination of the above constants, see bitwise OR operator)
1013
+ */
1014
+ function set_autodiscovery_level($level = SIMPLEPIE_LOCATOR_ALL)
1015
+ {
1016
+ $this->autodiscovery = (int) $level;
1017
+ }
1018
+
1019
+ /**
1020
+ * Allows you to change which class SimplePie uses for caching.
1021
+ * Useful when you are overloading or extending SimplePie's default classes.
1022
+ *
1023
+ * @access public
1024
+ * @param string $class Name of custom class.
1025
+ * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1026
+ * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1027
+ */
1028
+ function set_cache_class($class = 'SimplePie_Cache')
1029
+ {
1030
+ if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Cache'))
1031
+ {
1032
+ $this->cache_class = $class;
1033
+ return true;
1034
+ }
1035
+ return false;
1036
+ }
1037
+
1038
+ /**
1039
+ * Allows you to change which class SimplePie uses for auto-discovery.
1040
+ * Useful when you are overloading or extending SimplePie's default classes.
1041
+ *
1042
+ * @access public
1043
+ * @param string $class Name of custom class.
1044
+ * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1045
+ * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1046
+ */
1047
+ function set_locator_class($class = 'SimplePie_Locator')
1048
+ {
1049
+ if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Locator'))
1050
+ {
1051
+ $this->locator_class = $class;
1052
+ return true;
1053
+ }
1054
+ return false;
1055
+ }
1056
+
1057
+ /**
1058
+ * Allows you to change which class SimplePie uses for XML parsing.
1059
+ * Useful when you are overloading or extending SimplePie's default classes.
1060
+ *
1061
+ * @access public
1062
+ * @param string $class Name of custom class.
1063
+ * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1064
+ * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1065
+ */
1066
+ function set_parser_class($class = 'SimplePie_Parser')
1067
+ {
1068
+ if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Parser'))
1069
+ {
1070
+ $this->parser_class = $class;
1071
+ return true;
1072
+ }
1073
+ return false;
1074
+ }
1075
+
1076
+ /**
1077
+ * Allows you to change which class SimplePie uses for remote file fetching.
1078
+ * Useful when you are overloading or extending SimplePie's default classes.
1079
+ *
1080
+ * @access public
1081
+ * @param string $class Name of custom class.
1082
+ * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1083
+ * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1084
+ */
1085
+ function set_file_class($class = 'SimplePie_File')
1086
+ {
1087
+ if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_File'))
1088
+ {
1089
+ $this->file_class = $class;
1090
+ return true;
1091
+ }
1092
+ return false;
1093
+ }
1094
+
1095
+ /**
1096
+ * Allows you to change which class SimplePie uses for data sanitization.
1097
+ * Useful when you are overloading or extending SimplePie's default classes.
1098
+ *
1099
+ * @access public
1100
+ * @param string $class Name of custom class.
1101
+ * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1102
+ * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1103
+ */
1104
+ function set_sanitize_class($class = 'SimplePie_Sanitize')
1105
+ {
1106
+ if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Sanitize'))
1107
+ {
1108
+ $this->sanitize = new $class;
1109
+ return true;
1110
+ }
1111
+ return false;
1112
+ }
1113
+
1114
+ /**
1115
+ * Allows you to change which class SimplePie uses for handling feed items.
1116
+ * Useful when you are overloading or extending SimplePie's default classes.
1117
+ *
1118
+ * @access public
1119
+ * @param string $class Name of custom class.
1120
+ * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1121
+ * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1122
+ */
1123
+ function set_item_class($class = 'SimplePie_Item')
1124
+ {
1125
+ if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Item'))
1126
+ {
1127
+ $this->item_class = $class;
1128
+ return true;
1129
+ }
1130
+ return false;
1131
+ }
1132
+
1133
+ /**
1134
+ * Allows you to change which class SimplePie uses for handling author data.
1135
+ * Useful when you are overloading or extending SimplePie's default classes.
1136
+ *
1137
+ * @access public
1138
+ * @param string $class Name of custom class.
1139
+ * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1140
+ * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1141
+ */
1142
+ function set_author_class($class = 'SimplePie_Author')
1143
+ {
1144
+ if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Author'))
1145
+ {
1146
+ $this->author_class = $class;
1147
+ return true;
1148
+ }
1149
+ return false;
1150
+ }
1151
+
1152
+ /**
1153
+ * Allows you to change which class SimplePie uses for handling category data.
1154
+ * Useful when you are overloading or extending SimplePie's default classes.
1155
+ *
1156
+ * @access public
1157
+ * @param string $class Name of custom class.
1158
+ * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1159
+ * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1160
+ */
1161
+ function set_category_class($class = 'SimplePie_Category')
1162
+ {
1163
+ if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Category'))
1164
+ {
1165
+ $this->category_class = $class;
1166
+ return true;
1167
+ }
1168
+ return false;
1169
+ }
1170
+
1171
+ /**
1172
+ * Allows you to change which class SimplePie uses for feed enclosures.
1173
+ * Useful when you are overloading or extending SimplePie's default classes.
1174
+ *
1175
+ * @access public
1176
+ * @param string $class Name of custom class.
1177
+ * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1178
+ * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1179
+ */
1180
+ function set_enclosure_class($class = 'SimplePie_Enclosure')
1181
+ {
1182
+ if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Enclosure'))
1183
+ {
1184
+ $this->enclosure_class = $class;
1185
+ return true;
1186
+ }
1187
+ return false;
1188
+ }
1189
+
1190
+ /**
1191
+ * Allows you to change which class SimplePie uses for <media:text> captions
1192
+ * Useful when you are overloading or extending SimplePie's default classes.
1193
+ *
1194
+ * @access public
1195
+ * @param string $class Name of custom class.
1196
+ * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1197
+ * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1198
+ */
1199
+ function set_caption_class($class = 'SimplePie_Caption')
1200
+ {
1201
+ if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Caption'))
1202
+ {
1203
+ $this->caption_class = $class;
1204
+ return true;
1205
+ }
1206
+ return false;
1207
+ }
1208
+
1209
+ /**
1210
+ * Allows you to change which class SimplePie uses for <media:copyright>
1211
+ * Useful when you are overloading or extending SimplePie's default classes.
1212
+ *
1213
+ * @access public
1214
+ * @param string $class Name of custom class.
1215
+ * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1216
+ * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1217
+ */
1218
+ function set_copyright_class($class = 'SimplePie_Copyright')
1219
+ {
1220
+ if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Copyright'))
1221
+ {
1222
+ $this->copyright_class = $class;
1223
+ return true;
1224
+ }
1225
+ return false;
1226
+ }
1227
+
1228
+ /**
1229
+ * Allows you to change which class SimplePie uses for <media:credit>
1230
+ * Useful when you are overloading or extending SimplePie's default classes.
1231
+ *
1232
+ * @access public
1233
+ * @param string $class Name of custom class.
1234
+ * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1235
+ * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1236
+ */
1237
+ function set_credit_class($class = 'SimplePie_Credit')
1238
+ {
1239
+ if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Credit'))
1240
+ {
1241
+ $this->credit_class = $class;
1242
+ return true;
1243
+ }
1244
+ return false;
1245
+ }
1246
+
1247
+ /**
1248
+ * Allows you to change which class SimplePie uses for <media:rating>
1249
+ * Useful when you are overloading or extending SimplePie's default classes.
1250
+ *
1251
+ * @access public
1252
+ * @param string $class Name of custom class.
1253
+ * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1254
+ * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1255
+ */
1256
+ function set_rating_class($class = 'SimplePie_Rating')
1257
+ {
1258
+ if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Rating'))
1259
+ {
1260
+ $this->rating_class = $class;
1261
+ return true;
1262
+ }
1263
+ return false;
1264
+ }
1265
+
1266
+ /**
1267
+ * Allows you to change which class SimplePie uses for <media:restriction>
1268
+ * Useful when you are overloading or extending SimplePie's default classes.
1269
+ *
1270
+ * @access public
1271
+ * @param string $class Name of custom class.
1272
+ * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1273
+ * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1274
+ */
1275
+ function set_restriction_class($class = 'SimplePie_Restriction')
1276
+ {
1277
+ if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Restriction'))
1278
+ {
1279
+ $this->restriction_class = $class;
1280
+ return true;
1281
+ }
1282
+ return false;
1283
+ }
1284
+
1285
+ /**
1286
+ * Allows you to change which class SimplePie uses for content-type sniffing.
1287
+ * Useful when you are overloading or extending SimplePie's default classes.
1288
+ *
1289
+ * @access public
1290
+ * @param string $class Name of custom class.
1291
+ * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1292
+ * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1293
+ */
1294
+ function set_content_type_sniffer_class($class = 'SimplePie_Content_Type_Sniffer')
1295
+ {
1296
+ if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Content_Type_Sniffer'))
1297
+ {
1298
+ $this->content_type_sniffer_class = $class;
1299
+ return true;
1300
+ }
1301
+ return false;
1302
+ }
1303
+
1304
+ /**
1305
+ * Allows you to change which class SimplePie uses item sources.
1306
+ * Useful when you are overloading or extending SimplePie's default classes.
1307
+ *
1308
+ * @access public
1309
+ * @param string $class Name of custom class.
1310
+ * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1311
+ * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1312
+ */
1313
+ function set_source_class($class = 'SimplePie_Source')
1314
+ {
1315
+ if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Source'))
1316
+ {
1317
+ $this->source_class = $class;
1318
+ return true;
1319
+ }
1320
+ return false;
1321
+ }
1322
+
1323
+ /**
1324
+ * Allows you to override the default user agent string.
1325
+ *
1326
+ * @access public
1327
+ * @param string $ua New user agent string.
1328
+ */
1329
+ function set_useragent($ua = SIMPLEPIE_USERAGENT)
1330
+ {
1331
+ $this->useragent = (string) $ua;
1332
+ }
1333
+
1334
+ /**
1335
+ * Set callback function to create cache filename with
1336
+ *
1337
+ * @access public
1338
+ * @param mixed $function Callback function
1339
+ */
1340
+ function set_cache_name_function($function = 'md5')
1341
+ {
1342
+ if (is_callable($function))
1343
+ {
1344
+ $this->cache_name_function = $function;
1345
+ }
1346
+ }
1347
+
1348
+ /**
1349
+ * Set javascript query string parameter
1350
+ *
1351
+ * @access public
1352
+ * @param mixed $get Javascript query string parameter
1353
+ */
1354
+ function set_javascript($get = 'js')
1355
+ {
1356
+ if ($get)
1357
+ {
1358
+ $this->javascript = (string) $get;
1359
+ }
1360
+ else
1361
+ {
1362
+ $this->javascript = false;
1363
+ }
1364
+ }
1365
+
1366
+ /**
1367
+ * Set options to make SP as fast as possible. Forgoes a
1368
+ * substantial amount of data sanitization in favor of speed.
1369
+ *
1370
+ * @access public
1371
+ * @param bool $set Whether to set them or not
1372
+ */
1373
+ function set_stupidly_fast($set = false)
1374
+ {
1375
+ if ($set)
1376
+ {
1377
+ $this->enable_order_by_date(false);
1378
+ $this->remove_div(false);
1379
+ $this->strip_comments(false);
1380
+ $this->strip_htmltags(false);
1381
+ $this->strip_attributes(false);
1382
+ $this->set_image_handler(false);
1383
+ }
1384
+ }
1385
+
1386
+ /**
1387
+ * Set maximum number of feeds to check with autodiscovery
1388
+ *
1389
+ * @access public
1390
+ * @param int $max Maximum number of feeds to check
1391
+ */
1392
+ function set_max_checked_feeds($max = 10)
1393
+ {
1394
+ $this->max_checked_feeds = (int) $max;
1395
+ }
1396
+
1397
+ function remove_div($enable = true)
1398
+ {
1399
+ $this->sanitize->remove_div($enable);
1400
+ }
1401
+
1402
+ function strip_htmltags($tags = '', $encode = null)
1403
+ {
1404
+ if ($tags === '')
1405
+ {
1406
+ $tags = $this->strip_htmltags;
1407
+ }
1408
+ $this->sanitize->strip_htmltags($tags);
1409
+ if ($encode !== null)
1410
+ {
1411
+ $this->sanitize->encode_instead_of_strip($tags);
1412
+ }
1413
+ }
1414
+
1415
+ function encode_instead_of_strip($enable = true)
1416
+ {
1417
+ $this->sanitize->encode_instead_of_strip($enable);
1418
+ }
1419
+
1420
+ function strip_attributes($attribs = '')
1421
+ {
1422
+ if ($attribs === '')
1423
+ {
1424
+ $attribs = $this->strip_attributes;
1425
+ }
1426
+ $this->sanitize->strip_attributes($attribs);
1427
+ }
1428
+
1429
+ function set_output_encoding($encoding = 'UTF-8')
1430
+ {
1431
+ $this->sanitize->set_output_encoding($encoding);
1432
+ }
1433
+
1434
+ function strip_comments($strip = false)
1435
+ {
1436
+ $this->sanitize->strip_comments($strip);
1437
+ }
1438
+
1439
+ /**
1440
+ * Set element/attribute key/value pairs of HTML attributes
1441
+ * containing URLs that need to be resolved relative to the feed
1442
+ *
1443
+ * @access public
1444
+ * @since 1.0
1445
+ * @param array $element_attribute Element/attribute key/value pairs
1446
+ */
1447
+ function set_url_replacements($element_attribute = array('a' => 'href', 'area' => 'href', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite'))
1448
+ {
1449
+ $this->sanitize->set_url_replacements($element_attribute);
1450
+ }
1451
+
1452
+ /**
1453
+ * Set the handler to enable the display of cached favicons.
1454
+ *
1455
+ * @access public
1456
+ * @param str $page Web-accessible path to the handler_favicon.php file.
1457
+ * @param str $qs The query string that the value should be passed to.
1458
+ */
1459
+ function set_favicon_handler($page = false, $qs = 'i')
1460
+ {
1461
+ if ($page !== false)
1462
+ {
1463
+ $this->favicon_handler = $page . '?' . $qs . '=';
1464
+ }
1465
+ else
1466
+ {
1467
+ $this->favicon_handler = '';
1468
+ }
1469
+ }
1470
+
1471
+ /**
1472
+ * Set the handler to enable the display of cached images.
1473
+ *
1474
+ * @access public
1475
+ * @param str $page Web-accessible path to the handler_image.php file.
1476
+ * @param str $qs The query string that the value should be passed to.
1477
+ */
1478
+ function set_image_handler($page = false, $qs = 'i')
1479
+ {
1480
+ if ($page !== false)
1481
+ {
1482
+ $this->sanitize->set_image_handler($page . '?' . $qs . '=');
1483
+ }
1484
+ else
1485
+ {
1486
+ $this->image_handler = '';
1487
+ }
1488
+ }
1489
+
1490
+ /**
1491
+ * Set the limit for items returned per-feed with multifeeds.
1492
+ *
1493
+ * @access public
1494
+ * @param integer $limit The maximum number of items to return.
1495
+ */
1496
+ function set_item_limit($limit = 0)
1497
+ {
1498
+ $this->item_limit = (int) $limit;
1499
+ }
1500
+
1501
+ function init()
1502
+ {
1503
+ // Check absolute bare minimum requirements.
1504
+ if ((function_exists('version_compare') && version_compare(PHP_VERSION, '4.3.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre'))
1505
+ {
1506
+ return false;
1507
+ }
1508
+ // Then check the xml extension is sane (i.e., libxml 2.7.x issue on PHP < 5.2.9 and libxml 2.7.0 to 2.7.2 on any version) if we don't have xmlreader.
1509
+ elseif (!extension_loaded('xmlreader'))
1510
+ {
1511
+ static $xml_is_sane = null;
1512
+ if ($xml_is_sane === null)
1513
+ {
1514
+ $parser_check = xml_parser_create();
1515
+ xml_parse_into_struct($parser_check, '<foo>&amp;</foo>', $values);
1516
+ xml_parser_free($parser_check);
1517
+ $xml_is_sane = isset($values[0]['value']);
1518
+ }
1519
+ if (!$xml_is_sane)
1520
+ {
1521
+ return false;
1522
+ }
1523
+ }
1524
+
1525
+ if (isset($_GET[$this->javascript]))
1526
+ {
1527
+ SimplePie_Misc::output_javascript();
1528
+ exit;
1529
+ }
1530
+
1531
+ // Pass whatever was set with config options over to the sanitizer.
1532
+ $this->sanitize->pass_cache_data($this->cache, $this->cache_location, $this->cache_name_function, $this->cache_class);
1533
+ $this->sanitize->pass_file_data($this->file_class, $this->timeout, $this->useragent, $this->force_fsockopen);
1534
+
1535
+ if ($this->feed_url !== null || $this->raw_data !== null)
1536
+ {
1537
+ $this->data = array();
1538
+ $this->multifeed_objects = array();
1539
+ $cache = false;
1540
+
1541
+ if ($this->feed_url !== null)
1542
+ {
1543
+ $parsed_feed_url = SimplePie_Misc::parse_url($this->feed_url);
1544
+ // Decide whether to enable caching
1545
+ if ($this->cache && $parsed_feed_url['scheme'] !== '')
1546
+ {
1547
+ $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc');
1548
+ }
1549
+ // If it's enabled and we don't want an XML dump, use the cache
1550
+ if ($cache && !$this->xml_dump)
1551
+ {
1552
+ // Load the Cache
1553
+ $this->data = $cache->load();
1554
+ if (!empty($this->data))
1555
+ {
1556
+ // If the cache is for an outdated build of SimplePie
1557
+ if (!isset($this->data['build']) || $this->data['build'] !== SIMPLEPIE_BUILD)
1558
+ {
1559
+ $cache->unlink();
1560
+ $this->data = array();
1561
+ }
1562
+ // If we've hit a collision just rerun it with caching disabled
1563
+ elseif (isset($this->data['url']) && $this->data['url'] !== $this->feed_url)
1564
+ {
1565
+ $cache = false;
1566
+ $this->data = array();
1567
+ }
1568
+ // If we've got a non feed_url stored (if the page isn't actually a feed, or is a redirect) use that URL.
1569
+ elseif (isset($this->data['feed_url']))
1570
+ {
1571
+ // If the autodiscovery cache is still valid use it.
1572
+ if ($cache->mtime() + $this->autodiscovery_cache_duration > time())
1573
+ {
1574
+ // Do not need to do feed autodiscovery yet.
1575
+ if ($this->data['feed_url'] === $this->data['url'])
1576
+ {
1577
+ $cache->unlink();
1578
+ $this->data = array();
1579
+ }
1580
+ else
1581
+ {
1582
+ $this->set_feed_url($this->data['feed_url']);
1583
+ return $this->init();
1584
+ }
1585
+ }
1586
+ }
1587
+ // Check if the cache has been updated
1588
+ elseif ($cache->mtime() + $this->cache_duration < time())
1589
+ {
1590
+ // If we have last-modified and/or etag set
1591
+ if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag']))
1592
+ {
1593
+ $headers = array();
1594
+ if (isset($this->data['headers']['last-modified']))
1595
+ {
1596
+ $headers['if-modified-since'] = $this->data['headers']['last-modified'];
1597
+ }
1598
+ if (isset($this->data['headers']['etag']))
1599
+ {
1600
+ $headers['if-none-match'] = '"' . $this->data['headers']['etag'] . '"';
1601
+ }
1602
+ $file = new $this->file_class($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen);
1603
+ if ($file->success)
1604
+ {
1605
+ if ($file->status_code === 304)
1606
+ {
1607
+ $cache->touch();
1608
+ return true;
1609
+ }
1610
+ else
1611
+ {
1612
+ $headers = $file->headers;
1613
+ }
1614
+ }
1615
+ else
1616
+ {
1617
+ unset($file);
1618
+ }
1619
+ }
1620
+ }
1621
+ // If the cache is still valid, just return true
1622
+ else
1623
+ {
1624
+ return true;
1625
+ }
1626
+ }
1627
+ // If the cache is empty, delete it
1628
+ else
1629
+ {
1630
+ $cache->unlink();
1631
+ $this->data = array();
1632
+ }
1633
+ }
1634
+ // If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it.
1635
+ if (!isset($file))
1636
+ {
1637
+ if (is_a($this->file, 'SimplePie_File') && $this->file->url === $this->feed_url)
1638
+ {
1639
+ $file =& $this->file;
1640
+ }
1641
+ else
1642
+ {
1643
+ $file = new $this->file_class($this->feed_url, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen);
1644
+ }
1645
+ }
1646
+ // If the file connection has an error, set SimplePie::error to that and quit
1647
+ if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)))
1648
+ {
1649
+ $this->error = $file->error;
1650
+ if (!empty($this->data))
1651
+ {
1652
+ return true;
1653
+ }
1654
+ else
1655
+ {
1656
+ return false;
1657
+ }
1658
+ }
1659
+
1660
+ if (!$this->force_feed)
1661
+ {
1662
+ // Check if the supplied URL is a feed, if it isn't, look for it.
1663
+ $locate = new $this->locator_class($file, $this->timeout, $this->useragent, $this->file_class, $this->max_checked_feeds, $this->content_type_sniffer_class);
1664
+ if (!$locate->is_feed($file))
1665
+ {
1666
+ // We need to unset this so that if SimplePie::set_file() has been called that object is untouched
1667
+ unset($file);
1668
+ if ($file = $locate->find($this->autodiscovery, $this->all_discovered_feeds))
1669
+ {
1670
+ if ($cache)
1671
+ {
1672
+ $this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
1673
+ if (!$cache->save($this))
1674
+ {
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
+ }
1677
+ $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc');
1678
+ }
1679
+ $this->feed_url = $file->url;
1680
+ }
1681
+ else
1682
+ {
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
+ SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
1685
+ return false;
1686
+ }
1687
+ }
1688
+ $locate = null;
1689
+ }
1690
+
1691
+ $headers = $file->headers;
1692
+ $data = $file->body;
1693
+ $sniffer = new $this->content_type_sniffer_class($file);
1694
+ $sniffed = $sniffer->get_type();
1695
+ }
1696
+ else
1697
+ {
1698
+ $data = $this->raw_data;
1699
+ }
1700
+
1701
+ // Set up array of possible encodings
1702
+ $encodings = array();
1703
+
1704
+ // First check to see if input has been overridden.
1705
+ if ($this->input_encoding !== false)
1706
+ {
1707
+ $encodings[] = $this->input_encoding;
1708
+ }
1709
+
1710
+ $application_types = array('application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity');
1711
+ $text_types = array('text/xml', 'text/xml-external-parsed-entity');
1712
+
1713
+ // RFC 3023 (only applies to sniffed content)
1714
+ if (isset($sniffed))
1715
+ {
1716
+ if (in_array($sniffed, $application_types) || substr($sniffed, 0, 12) === 'application/' && substr($sniffed, -4) === '+xml')
1717
+ {
1718
+ if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset))
1719
+ {
1720
+ $encodings[] = strtoupper($charset[1]);
1721
+ }
1722
+ $encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data));
1723
+ $encodings[] = 'UTF-8';
1724
+ }
1725
+ elseif (in_array($sniffed, $text_types) || substr($sniffed, 0, 5) === 'text/' && substr($sniffed, -4) === '+xml')
1726
+ {
1727
+ if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset))
1728
+ {
1729
+ $encodings[] = $charset[1];
1730
+ }
1731
+ $encodings[] = 'US-ASCII';
1732
+ }
1733
+ // Text MIME-type default
1734
+ elseif (substr($sniffed, 0, 5) === 'text/')
1735
+ {
1736
+ $encodings[] = 'US-ASCII';
1737
+ }
1738
+ }
1739
+
1740
+ // Fallback to XML 1.0 Appendix F.1/UTF-8/ISO-8859-1
1741
+ $encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data));
1742
+ $encodings[] = 'UTF-8';
1743
+ $encodings[] = 'ISO-8859-1';
1744
+
1745
+ // There's no point in trying an encoding twice
1746
+ $encodings = array_unique($encodings);
1747
+
1748
+ // If we want the XML, just output that with the most likely encoding and quit
1749
+ if ($this->xml_dump)
1750
+ {
1751
+ header('Content-type: text/xml; charset=' . $encodings[0]);
1752
+ echo $data;
1753
+ exit;
1754
+ }
1755
+
1756
+ // Loop through each possible encoding, till we return something, or run out of possibilities
1757
+ foreach ($encodings as $encoding)
1758
+ {
1759
+ // Change the encoding to UTF-8 (as we always use UTF-8 internally)
1760
+ if ($utf8_data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8'))
1761
+ {
1762
+ // Create new parser
1763
+ $parser = new $this->parser_class();
1764
+
1765
+ // If it's parsed fine
1766
+ if ($parser->parse($utf8_data, 'UTF-8'))
1767
+ {
1768
+ $this->data = $parser->get_data();
1769
+ if ($this->get_type() & ~SIMPLEPIE_TYPE_NONE)
1770
+ {
1771
+ if (isset($headers))
1772
+ {
1773
+ $this->data['headers'] = $headers;
1774
+ }
1775
+ $this->data['build'] = SIMPLEPIE_BUILD;
1776
+
1777
+ // Cache the file if caching is enabled
1778
+ if ($cache && !$cache->save($this))
1779
+ {
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
+ }
1782
+ return true;
1783
+ }
1784
+ else
1785
+ {
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
+ SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
1788
+ return false;
1789
+ }
1790
+ }
1791
+ }
1792
+ }
1793
+ if (isset($parser))
1794
+ {
1795
+ // We have an error, just set SimplePie_Misc::error to it and quit
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
+ }
1798
+ else
1799
+ {
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
+ }
1802
+ SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
1803
+ return false;
1804
+ }
1805
+ elseif (!empty($this->multifeed_url))
1806
+ {
1807
+ $i = 0;
1808
+ $success = 0;
1809
+ $this->multifeed_objects = array();
1810
+ foreach ($this->multifeed_url as $url)
1811
+ {
1812
+ if (SIMPLEPIE_PHP5)
1813
+ {
1814
+ // This keyword needs to defy coding standards for PHP4 compatibility
1815
+ $this->multifeed_objects[$i] = clone($this);
1816
+ }
1817
+ else
1818
+ {
1819
+ $this->multifeed_objects[$i] = $this;
1820
+ }
1821
+ $this->multifeed_objects[$i]->set_feed_url($url);
1822
+ $success |= $this->multifeed_objects[$i]->init();
1823
+ $i++;
1824
+ }
1825
+ return (bool) $success;
1826
+ }
1827
+ else
1828
+ {
1829
+ return false;
1830
+ }
1831
+ }
1832
+
1833
+ /**
1834
+ * Return the error message for the occured error
1835
+ *
1836
+ * @access public
1837
+ * @return string Error message
1838
+ */
1839
+ function error()
1840
+ {
1841
+ return $this->error;
1842
+ }
1843
+
1844
+ function get_encoding()
1845
+ {
1846
+ return $this->sanitize->output_encoding;
1847
+ }
1848
+
1849
+ function handle_content_type($mime = 'text/html')
1850
+ {
1851
+ if (!headers_sent())
1852
+ {
1853
+ $header = "Content-type: $mime;";
1854
+ if ($this->get_encoding())
1855
+ {
1856
+ $header .= ' charset=' . $this->get_encoding();
1857
+ }
1858
+ else
1859
+ {
1860
+ $header .= ' charset=UTF-8';
1861
+ }
1862
+ header($header);
1863
+ }
1864
+ }
1865
+
1866
+ function get_type()
1867
+ {
1868
+ if (!isset($this->data['type']))
1869
+ {
1870
+ $this->data['type'] = SIMPLEPIE_TYPE_ALL;
1871
+ if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed']))
1872
+ {
1873
+ $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_10;
1874
+ }
1875
+ elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed']))
1876
+ {
1877
+ $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_03;
1878
+ }
1879
+ elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF']))
1880
+ {
1881
+ if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['channel'])
1882
+ || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['image'])
1883
+ || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item'])
1884
+ || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['textinput']))
1885
+ {
1886
+ $this->data['type'] &= SIMPLEPIE_TYPE_RSS_10;
1887
+ }
1888
+ if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['channel'])
1889
+ || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['image'])
1890
+ || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item'])
1891
+ || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['textinput']))
1892
+ {
1893
+ $this->data['type'] &= SIMPLEPIE_TYPE_RSS_090;
1894
+ }
1895
+ }
1896
+ elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss']))
1897
+ {
1898
+ $this->data['type'] &= SIMPLEPIE_TYPE_RSS_ALL;
1899
+ if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version']))
1900
+ {
1901
+ switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version']))
1902
+ {
1903
+ case '0.91':
1904
+ $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091;
1905
+ if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data']))
1906
+ {
1907
+ switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data']))
1908
+ {
1909
+ case '0':
1910
+ $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE;
1911
+ break;
1912
+
1913
+ case '24':
1914
+ $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_USERLAND;
1915
+ break;
1916
+ }
1917
+ }
1918
+ break;
1919
+
1920
+ case '0.92':
1921
+ $this->data['type'] &= SIMPLEPIE_TYPE_RSS_092;
1922
+ break;
1923
+
1924
+ case '0.93':
1925
+ $this->data['type'] &= SIMPLEPIE_TYPE_RSS_093;
1926
+ break;
1927
+
1928
+ case '0.94':
1929
+ $this->data['type'] &= SIMPLEPIE_TYPE_RSS_094;
1930
+ break;
1931
+
1932
+ case '2.0':
1933
+ $this->data['type'] &= SIMPLEPIE_TYPE_RSS_20;
1934
+ break;
1935
+ }
1936
+ }
1937
+ }
1938
+ else
1939
+ {
1940
+ $this->data['type'] = SIMPLEPIE_TYPE_NONE;
1941
+ }
1942
+ }
1943
+ return $this->data['type'];
1944
+ }
1945
+
1946
+ /**
1947
+ * Returns the URL for the favicon of the feed's website.
1948
+ *
1949
+ * @todo Cache atom:icon
1950
+ * @access public
1951
+ * @since 1.0
1952
+ */
1953
+ function get_favicon()
1954
+ {
1955
+ if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
1956
+ {
1957
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
1958
+ }
1959
+ elseif (($url = $this->get_link()) !== null && preg_match('/^http(s)?:\/\//i', $url))
1960
+ {
1961
+ $favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $url);
1962
+
1963
+ if ($this->cache && $this->favicon_handler)
1964
+ {
1965
+ $favicon_filename = call_user_func($this->cache_name_function, $favicon);
1966
+ $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, $favicon_filename, 'spi');
1967
+
1968
+ if ($cache->load())
1969
+ {
1970
+ return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI);
1971
+ }
1972
+ else
1973
+ {
1974
+ $file = new $this->file_class($favicon, $this->timeout / 10, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen);
1975
+
1976
+ if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0)
1977
+ {
1978
+ $sniffer = new $this->content_type_sniffer_class($file);
1979
+ if (substr($sniffer->get_type(), 0, 6) === 'image/')
1980
+ {
1981
+ if ($cache->save(array('headers' => $file->headers, 'body' => $file->body)))
1982
+ {
1983
+ return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI);
1984
+ }
1985
+ else
1986
+ {
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
+ return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
1989
+ }
1990
+ }
1991
+ // not an image
1992
+ else
1993
+ {
1994
+ return false;
1995
+ }
1996
+ }
1997
+ }
1998
+ }
1999
+ else
2000
+ {
2001
+ return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
2002
+ }
2003
+ }
2004
+ return false;
2005
+ }
2006
+
2007
+ /**
2008
+ * @todo If we have a perm redirect we should return the new URL
2009
+ * @todo When we make the above change, let's support <itunes:new-feed-url> as well
2010
+ * @todo Also, |atom:link|@rel=self
2011
+ */
2012
+ function subscribe_url()
2013
+ {
2014
+ if ($this->feed_url !== null)
2015
+ {
2016
+ return $this->sanitize($this->feed_url, SIMPLEPIE_CONSTRUCT_IRI);
2017
+ }
2018
+ else
2019
+ {
2020
+ return null;
2021
+ }
2022
+ }
2023
+
2024
+ function subscribe_feed()
2025
+ {
2026
+ if ($this->feed_url !== null)
2027
+ {
2028
+ return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI);
2029
+ }
2030
+ else
2031
+ {
2032
+ return null;
2033
+ }
2034
+ }
2035
+
2036
+ function subscribe_outlook()
2037
+ {
2038
+ if ($this->feed_url !== null)
2039
+ {
2040
+ return $this->sanitize('outlook' . SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI);
2041
+ }
2042
+ else
2043
+ {
2044
+ return null;
2045
+ }
2046
+ }
2047
+
2048
+ function subscribe_podcast()
2049
+ {
2050
+ if ($this->feed_url !== null)
2051
+ {
2052
+ return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 3), SIMPLEPIE_CONSTRUCT_IRI);
2053
+ }
2054
+ else
2055
+ {
2056
+ return null;
2057
+ }
2058
+ }
2059
+
2060
+ function subscribe_itunes()
2061
+ {
2062
+ if ($this->feed_url !== null)
2063
+ {
2064
+ return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 4), SIMPLEPIE_CONSTRUCT_IRI);
2065
+ }
2066
+ else
2067
+ {
2068
+ return null;
2069
+ }
2070
+ }
2071
+
2072
+ /**
2073
+ * Creates the subscribe_* methods' return data
2074
+ *
2075
+ * @access private
2076
+ * @param string $feed_url String to prefix to the feed URL
2077
+ * @param string $site_url String to prefix to the site URL (and
2078
+ * suffix to the feed URL)
2079
+ * @return mixed URL if feed exists, false otherwise
2080
+ */
2081
+ function subscribe_service($feed_url, $site_url = null)
2082
+ {
2083
+ if ($this->subscribe_url())
2084
+ {
2085
+ $return = $feed_url . rawurlencode($this->feed_url);
2086
+ if ($site_url !== null && $this->get_link() !== null)
2087
+ {
2088
+ $return .= $site_url . rawurlencode($this->get_link());
2089
+ }
2090
+ return $this->sanitize($return, SIMPLEPIE_CONSTRUCT_IRI);
2091
+ }
2092
+ else
2093
+ {
2094
+ return null;
2095
+ }
2096
+ }
2097
+
2098
+ function subscribe_aol()
2099
+ {
2100
+ return $this->subscribe_service('http://feeds.my.aol.com/add.jsp?url=');
2101
+ }
2102
+
2103
+ function subscribe_bloglines()
2104
+ {
2105
+ return $this->subscribe_service('http://www.bloglines.com/sub/');
2106
+ }
2107
+
2108
+ function subscribe_eskobo()
2109
+ {
2110
+ return $this->subscribe_service('http://www.eskobo.com/?AddToMyPage=');
2111
+ }
2112
+
2113
+ function subscribe_feedfeeds()
2114
+ {
2115
+ return $this->subscribe_service('http://www.feedfeeds.com/add?feed=');
2116
+ }
2117
+
2118
+ function subscribe_feedster()
2119
+ {
2120
+ return $this->subscribe_service('http://www.feedster.com/myfeedster.php?action=addrss&confirm=no&rssurl=');
2121
+ }
2122
+
2123
+ function subscribe_google()
2124
+ {
2125
+ return $this->subscribe_service('http://fusion.google.com/add?feedurl=');
2126
+ }
2127
+
2128
+ function subscribe_gritwire()
2129
+ {
2130
+ return $this->subscribe_service('http://my.gritwire.com/feeds/addExternalFeed.aspx?FeedUrl=');
2131
+ }
2132
+
2133
+ function subscribe_msn()
2134
+ {
2135
+ return $this->subscribe_service('http://my.msn.com/addtomymsn.armx?id=rss&ut=', '&ru=');
2136
+ }
2137
+
2138
+ function subscribe_netvibes()
2139
+ {
2140
+ return $this->subscribe_service('http://www.netvibes.com/subscribe.php?url=');
2141
+ }
2142
+
2143
+ function subscribe_newsburst()
2144
+ {
2145
+ return $this->subscribe_service('http://www.newsburst.com/Source/?add=');
2146
+ }
2147
+
2148
+ function subscribe_newsgator()
2149
+ {
2150
+ return $this->subscribe_service('http://www.newsgator.com/ngs/subscriber/subext.aspx?url=');
2151
+ }
2152
+
2153
+ function subscribe_odeo()
2154
+ {
2155
+ return $this->subscribe_service('http://www.odeo.com/listen/subscribe?feed=');
2156
+ }
2157
+
2158
+ function subscribe_podnova()
2159
+ {
2160
+ return $this->subscribe_service('http://www.podnova.com/index_your_podcasts.srf?action=add&url=');
2161
+ }
2162
+
2163
+ function subscribe_rojo()
2164
+ {
2165
+ return $this->subscribe_service('http://www.rojo.com/add-subscription?resource=');
2166
+ }
2167
+
2168
+ function subscribe_yahoo()
2169
+ {
2170
+ return $this->subscribe_service('http://add.my.yahoo.com/rss?url=');
2171
+ }
2172
+
2173
+ function get_feed_tags($namespace, $tag)
2174
+ {
2175
+ $type = $this->get_type();
2176
+ if ($type & SIMPLEPIE_TYPE_ATOM_10)
2177
+ {
2178
+ if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag]))
2179
+ {
2180
+ return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag];
2181
+ }
2182
+ }
2183
+ if ($type & SIMPLEPIE_TYPE_ATOM_03)
2184
+ {
2185
+ if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag]))
2186
+ {
2187
+ return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag];
2188
+ }
2189
+ }
2190
+ if ($type & SIMPLEPIE_TYPE_RSS_RDF)
2191
+ {
2192
+ if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag]))
2193
+ {
2194
+ return $this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag];
2195
+ }
2196
+ }
2197
+ if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
2198
+ {
2199
+ if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag]))
2200
+ {
2201
+ return $this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag];
2202
+ }
2203
+ }
2204
+ return null;
2205
+ }
2206
+
2207
+ function get_channel_tags($namespace, $tag)
2208
+ {
2209
+ $type = $this->get_type();
2210
+ if ($type & SIMPLEPIE_TYPE_ATOM_ALL)
2211
+ {
2212
+ if ($return = $this->get_feed_tags($namespace, $tag))
2213
+ {
2214
+ return $return;
2215
+ }
2216
+ }
2217
+ if ($type & SIMPLEPIE_TYPE_RSS_10)
2218
+ {
2219
+ if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'channel'))
2220
+ {
2221
+ if (isset($channel[0]['child'][$namespace][$tag]))
2222
+ {
2223
+ return $channel[0]['child'][$namespace][$tag];
2224
+ }
2225
+ }
2226
+ }
2227
+ if ($type & SIMPLEPIE_TYPE_RSS_090)
2228
+ {
2229
+ if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'channel'))
2230
+ {
2231
+ if (isset($channel[0]['child'][$namespace][$tag]))
2232
+ {
2233
+ return $channel[0]['child'][$namespace][$tag];
2234
+ }
2235
+ }
2236
+ }
2237
+ if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
2238
+ {
2239
+ if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'channel'))
2240
+ {
2241
+ if (isset($channel[0]['child'][$namespace][$tag]))
2242
+ {
2243
+ return $channel[0]['child'][$namespace][$tag];
2244
+ }
2245
+ }
2246
+ }
2247
+ return null;
2248
+ }
2249
+
2250
+ function get_image_tags($namespace, $tag)
2251
+ {
2252
+ $type = $this->get_type();
2253
+ if ($type & SIMPLEPIE_TYPE_RSS_10)
2254
+ {
2255
+ if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'image'))
2256
+ {
2257
+ if (isset($image[0]['child'][$namespace][$tag]))
2258
+ {
2259
+ return $image[0]['child'][$namespace][$tag];
2260
+ }
2261
+ }
2262
+ }
2263
+ if ($type & SIMPLEPIE_TYPE_RSS_090)
2264
+ {
2265
+ if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'image'))
2266
+ {
2267
+ if (isset($image[0]['child'][$namespace][$tag]))
2268
+ {
2269
+ return $image[0]['child'][$namespace][$tag];
2270
+ }
2271
+ }
2272
+ }
2273
+ if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
2274
+ {
2275
+ if ($image = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'image'))
2276
+ {
2277
+ if (isset($image[0]['child'][$namespace][$tag]))
2278
+ {
2279
+ return $image[0]['child'][$namespace][$tag];
2280
+ }
2281
+ }
2282
+ }
2283
+ return null;
2284
+ }
2285
+
2286
+ function get_base($element = array())
2287
+ {
2288
+ if (!($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION) && !empty($element['xml_base_explicit']) && isset($element['xml_base']))
2289
+ {
2290
+ return $element['xml_base'];
2291
+ }
2292
+ elseif ($this->get_link() !== null)
2293
+ {
2294
+ return $this->get_link();
2295
+ }
2296
+ else
2297
+ {
2298
+ return $this->subscribe_url();
2299
+ }
2300
+ }
2301
+
2302
+ function sanitize($data, $type, $base = '')
2303
+ {
2304
+ return $this->sanitize->sanitize($data, $type, $base);
2305
+ }
2306
+
2307
+ function get_title()
2308
+ {
2309
+ if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
2310
+ {
2311
+ return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2312
+ }
2313
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
2314
+ {
2315
+ return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2316
+ }
2317
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
2318
+ {
2319
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2320
+ }
2321
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
2322
+ {
2323
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2324
+ }
2325
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
2326
+ {
2327
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2328
+ }
2329
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
2330
+ {
2331
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2332
+ }
2333
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
2334
+ {
2335
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2336
+ }
2337
+ else
2338
+ {
2339
+ return null;
2340
+ }
2341
+ }
2342
+
2343
+ function get_category($key = 0)
2344
+ {
2345
+ $categories = $this->get_categories();
2346
+ if (isset($categories[$key]))
2347
+ {
2348
+ return $categories[$key];
2349
+ }
2350
+ else
2351
+ {
2352
+ return null;
2353
+ }
2354
+ }
2355
+
2356
+ function get_categories()
2357
+ {
2358
+ $categories = array();
2359
+
2360
+ foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
2361
+ {
2362
+ $term = null;
2363
+ $scheme = null;
2364
+ $label = null;
2365
+ if (isset($category['attribs']['']['term']))
2366
+ {
2367
+ $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
2368
+ }
2369
+ if (isset($category['attribs']['']['scheme']))
2370
+ {
2371
+ $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2372
+ }
2373
+ if (isset($category['attribs']['']['label']))
2374
+ {
2375
+ $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
2376
+ }
2377
+ $categories[] = new $this->category_class($term, $scheme, $label);
2378
+ }
2379
+ foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
2380
+ {
2381
+ // This is really the label, but keep this as the term also for BC.
2382
+ // Label will also work on retrieving because that falls back to term.
2383
+ $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2384
+ if (isset($category['attribs']['']['domain']))
2385
+ {
2386
+ $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
2387
+ }
2388
+ else
2389
+ {
2390
+ $scheme = null;
2391
+ }
2392
+ $categories[] = new $this->category_class($term, $scheme, null);
2393
+ }
2394
+ foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
2395
+ {
2396
+ $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2397
+ }
2398
+ foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
2399
+ {
2400
+ $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2401
+ }
2402
+
2403
+ if (!empty($categories))
2404
+ {
2405
+ return SimplePie_Misc::array_unique($categories);
2406
+ }
2407
+ else
2408
+ {
2409
+ return null;
2410
+ }
2411
+ }
2412
+
2413
+ function get_author($key = 0)
2414
+ {
2415
+ $authors = $this->get_authors();
2416
+ if (isset($authors[$key]))
2417
+ {
2418
+ return $authors[$key];
2419
+ }
2420
+ else
2421
+ {
2422
+ return null;
2423
+ }
2424
+ }
2425
+
2426
+ function get_authors()
2427
+ {
2428
+ $authors = array();
2429
+ foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
2430
+ {
2431
+ $name = null;
2432
+ $uri = null;
2433
+ $email = null;
2434
+ if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
2435
+ {
2436
+ $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2437
+ }
2438
+ if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
2439
+ {
2440
+ $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
2441
+ }
2442
+ if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
2443
+ {
2444
+ $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2445
+ }
2446
+ if ($name !== null || $email !== null || $uri !== null)
2447
+ {
2448
+ $authors[] = new $this->author_class($name, $uri, $email);
2449
+ }
2450
+ }
2451
+ if ($author = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
2452
+ {
2453
+ $name = null;
2454
+ $url = null;
2455
+ $email = null;
2456
+ if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
2457
+ {
2458
+ $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2459
+ }
2460
+ if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
2461
+ {
2462
+ $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
2463
+ }
2464
+ if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
2465
+ {
2466
+ $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2467
+ }
2468
+ if ($name !== null || $email !== null || $url !== null)
2469
+ {
2470
+ $authors[] = new $this->author_class($name, $url, $email);
2471
+ }
2472
+ }
2473
+ foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
2474
+ {
2475
+ $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2476
+ }
2477
+ foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
2478
+ {
2479
+ $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2480
+ }
2481
+ foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
2482
+ {
2483
+ $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2484
+ }
2485
+
2486
+ if (!empty($authors))
2487
+ {
2488
+ return SimplePie_Misc::array_unique($authors);
2489
+ }
2490
+ else
2491
+ {
2492
+ return null;
2493
+ }
2494
+ }
2495
+
2496
+ function get_contributor($key = 0)
2497
+ {
2498
+ $contributors = $this->get_contributors();
2499
+ if (isset($contributors[$key]))
2500
+ {
2501
+ return $contributors[$key];
2502
+ }
2503
+ else
2504
+ {
2505
+ return null;
2506
+ }
2507
+ }
2508
+
2509
+ function get_contributors()
2510
+ {
2511
+ $contributors = array();
2512
+ foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
2513
+ {
2514
+ $name = null;
2515
+ $uri = null;
2516
+ $email = null;
2517
+ if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
2518
+ {
2519
+ $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2520
+ }
2521
+ if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
2522
+ {
2523
+ $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
2524
+ }
2525
+ if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
2526
+ {
2527
+ $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2528
+ }
2529
+ if ($name !== null || $email !== null || $uri !== null)
2530
+ {
2531
+ $contributors[] = new $this->author_class($name, $uri, $email);
2532
+ }
2533
+ }
2534
+ foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
2535
+ {
2536
+ $name = null;
2537
+ $url = null;
2538
+ $email = null;
2539
+ if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
2540
+ {
2541
+ $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2542
+ }
2543
+ if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
2544
+ {
2545
+ $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
2546
+ }
2547
+ if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
2548
+ {
2549
+ $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2550
+ }
2551
+ if ($name !== null || $email !== null || $url !== null)
2552
+ {
2553
+ $contributors[] = new $this->author_class($name, $url, $email);
2554
+ }
2555
+ }
2556
+
2557
+ if (!empty($contributors))
2558
+ {
2559
+ return SimplePie_Misc::array_unique($contributors);
2560
+ }
2561
+ else
2562
+ {
2563
+ return null;
2564
+ }
2565
+ }
2566
+
2567
+ function get_link($key = 0, $rel = 'alternate')
2568
+ {
2569
+ $links = $this->get_links($rel);
2570
+ if (isset($links[$key]))
2571
+ {
2572
+ return $links[$key];
2573
+ }
2574
+ else
2575
+ {
2576
+ return null;
2577
+ }
2578
+ }
2579
+
2580
+ /**
2581
+ * Added for parity between the parent-level and the item/entry-level.
2582
+ */
2583
+ function get_permalink()
2584
+ {
2585
+ return $this->get_link(0);
2586
+ }
2587
+
2588
+ function get_links($rel = 'alternate')
2589
+ {
2590
+ if (!isset($this->data['links']))
2591
+ {
2592
+ $this->data['links'] = array();
2593
+ if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link'))
2594
+ {
2595
+ foreach ($links as $link)
2596
+ {
2597
+ if (isset($link['attribs']['']['href']))
2598
+ {
2599
+ $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
2600
+ $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
2601
+ }
2602
+ }
2603
+ }
2604
+ if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link'))
2605
+ {
2606
+ foreach ($links as $link)
2607
+ {
2608
+ if (isset($link['attribs']['']['href']))
2609
+ {
2610
+ $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
2611
+ $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
2612
+
2613
+ }
2614
+ }
2615
+ }
2616
+ if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
2617
+ {
2618
+ $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2619
+ }
2620
+ if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
2621
+ {
2622
+ $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2623
+ }
2624
+ if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
2625
+ {
2626
+ $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2627
+ }
2628
+
2629
+ $keys = array_keys($this->data['links']);
2630
+ foreach ($keys as $key)
2631
+ {
2632
+ if (SimplePie_Misc::is_isegment_nz_nc($key))
2633
+ {
2634
+ if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
2635
+ {
2636
+ $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
2637
+ $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
2638
+ }
2639
+ else
2640
+ {
2641
+ $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
2642
+ }
2643
+ }
2644
+ elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
2645
+ {
2646
+ $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
2647
+ }
2648
+ $this->data['links'][$key] = array_unique($this->data['links'][$key]);
2649
+ }
2650
+ }
2651
+
2652
+ if (isset($this->data['links'][$rel]))
2653
+ {
2654
+ return $this->data['links'][$rel];
2655
+ }
2656
+ else
2657
+ {
2658
+ return null;
2659
+ }
2660
+ }
2661
+
2662
+ function get_all_discovered_feeds()
2663
+ {
2664
+ return $this->all_discovered_feeds;
2665
+ }
2666
+
2667
+ function get_description()
2668
+ {
2669
+ if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle'))
2670
+ {
2671
+ return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2672
+ }
2673
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline'))
2674
+ {
2675
+ return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2676
+ }
2677
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
2678
+ {
2679
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2680
+ }
2681
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
2682
+ {
2683
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2684
+ }
2685
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
2686
+ {
2687
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
2688
+ }
2689
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
2690
+ {
2691
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2692
+ }
2693
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
2694
+ {
2695
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2696
+ }
2697
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
2698
+ {
2699
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
2700
+ }
2701
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
2702
+ {
2703
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
2704
+ }
2705
+ else
2706
+ {
2707
+ return null;
2708
+ }
2709
+ }
2710
+
2711
+ function get_copyright()
2712
+ {
2713
+ if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
2714
+ {
2715
+ return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2716
+ }
2717
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright'))
2718
+ {
2719
+ return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2720
+ }
2721
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright'))
2722
+ {
2723
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2724
+ }
2725
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
2726
+ {
2727
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2728
+ }
2729
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
2730
+ {
2731
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2732
+ }
2733
+ else
2734
+ {
2735
+ return null;
2736
+ }
2737
+ }
2738
+
2739
+ function get_language()
2740
+ {
2741
+ if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language'))
2742
+ {
2743
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2744
+ }
2745
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language'))
2746
+ {
2747
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2748
+ }
2749
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language'))
2750
+ {
2751
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2752
+ }
2753
+ elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang']))
2754
+ {
2755
+ return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
2756
+ }
2757
+ elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang']))
2758
+ {
2759
+ return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
2760
+ }
2761
+ elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang']))
2762
+ {
2763
+ return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
2764
+ }
2765
+ elseif (isset($this->data['headers']['content-language']))
2766
+ {
2767
+ return $this->sanitize($this->data['headers']['content-language'], SIMPLEPIE_CONSTRUCT_TEXT);
2768
+ }
2769
+ else
2770
+ {
2771
+ return null;
2772
+ }
2773
+ }
2774
+
2775
+ function get_latitude()
2776
+ {
2777
+
2778
+ if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
2779
+ {
2780
+ return (float) $return[0]['data'];
2781
+ }
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))
2783
+ {
2784
+ return (float) $match[1];
2785
+ }
2786
+ else
2787
+ {
2788
+ return null;
2789
+ }
2790
+ }
2791
+
2792
+ function get_longitude()
2793
+ {
2794
+ if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
2795
+ {
2796
+ return (float) $return[0]['data'];
2797
+ }
2798
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
2799
+ {
2800
+ return (float) $return[0]['data'];
2801
+ }
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))
2803
+ {
2804
+ return (float) $match[2];
2805
+ }
2806
+ else
2807
+ {
2808
+ return null;
2809
+ }
2810
+ }
2811
+
2812
+ function get_image_title()
2813
+ {
2814
+ if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
2815
+ {
2816
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2817
+ }
2818
+ elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
2819
+ {
2820
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2821
+ }
2822
+ elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
2823
+ {
2824
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2825
+ }
2826
+ elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
2827
+ {
2828
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2829
+ }
2830
+ elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
2831
+ {
2832
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2833
+ }
2834
+ else
2835
+ {
2836
+ return null;
2837
+ }
2838
+ }
2839
+
2840
+ function get_image_url()
2841
+ {
2842
+ if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image'))
2843
+ {
2844
+ return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI);
2845
+ }
2846
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo'))
2847
+ {
2848
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2849
+ }
2850
+ elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
2851
+ {
2852
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2853
+ }
2854
+ elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'url'))
2855
+ {
2856
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2857
+ }
2858
+ elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'url'))
2859
+ {
2860
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2861
+ }
2862
+ elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url'))
2863
+ {
2864
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2865
+ }
2866
+ else
2867
+ {
2868
+ return null;
2869
+ }
2870
+ }
2871
+
2872
+ function get_image_link()
2873
+ {
2874
+ if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
2875
+ {
2876
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2877
+ }
2878
+ elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
2879
+ {
2880
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2881
+ }
2882
+ elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
2883
+ {
2884
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2885
+ }
2886
+ else
2887
+ {
2888
+ return null;
2889
+ }
2890
+ }
2891
+
2892
+ function get_image_width()
2893
+ {
2894
+ if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'width'))
2895
+ {
2896
+ return round($return[0]['data']);
2897
+ }
2898
+ elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url'))
2899
+ {
2900
+ return 88.0;
2901
+ }
2902
+ else
2903
+ {
2904
+ return null;
2905
+ }
2906
+ }
2907
+
2908
+ function get_image_height()
2909
+ {
2910
+ if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'height'))
2911
+ {
2912
+ return round($return[0]['data']);
2913
+ }
2914
+ elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url'))
2915
+ {
2916
+ return 31.0;
2917
+ }
2918
+ else
2919
+ {
2920
+ return null;
2921
+ }
2922
+ }
2923
+
2924
+ function get_item_quantity($max = 0)
2925
+ {
2926
+ $max = (int) $max;
2927
+ $qty = count($this->get_items());
2928
+ if ($max === 0)
2929
+ {
2930
+ return $qty;
2931
+ }
2932
+ else
2933
+ {
2934
+ return ($qty > $max) ? $max : $qty;
2935
+ }
2936
+ }
2937
+
2938
+ function get_item($key = 0)
2939
+ {
2940
+ $items = $this->get_items();
2941
+ if (isset($items[$key]))
2942
+ {
2943
+ return $items[$key];
2944
+ }
2945
+ else
2946
+ {
2947
+ return null;
2948
+ }
2949
+ }
2950
+
2951
+ function get_items($start = 0, $end = 0)
2952
+ {
2953
+ if (!isset($this->data['items']))
2954
+ {
2955
+ if (!empty($this->multifeed_objects))
2956
+ {
2957
+ $this->data['items'] = SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit);
2958
+ }
2959
+ else
2960
+ {
2961
+ $this->data['items'] = array();
2962
+ if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry'))
2963
+ {
2964
+ $keys = array_keys($items);
2965
+ foreach ($keys as $key)
2966
+ {
2967
+ $this->data['items'][] = new $this->item_class($this, $items[$key]);
2968
+ }
2969
+ }
2970
+ if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry'))
2971
+ {
2972
+ $keys = array_keys($items);
2973
+ foreach ($keys as $key)
2974
+ {
2975
+ $this->data['items'][] = new $this->item_class($this, $items[$key]);
2976
+ }
2977
+ }
2978
+ if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item'))
2979
+ {
2980
+ $keys = array_keys($items);
2981
+ foreach ($keys as $key)
2982
+ {
2983
+ $this->data['items'][] = new $this->item_class($this, $items[$key]);
2984
+ }
2985
+ }
2986
+ if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item'))
2987
+ {
2988
+ $keys = array_keys($items);
2989
+ foreach ($keys as $key)
2990
+ {
2991
+ $this->data['items'][] = new $this->item_class($this, $items[$key]);
2992
+ }
2993
+ }
2994
+ if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item'))
2995
+ {
2996
+ $keys = array_keys($items);
2997
+ foreach ($keys as $key)
2998
+ {
2999
+ $this->data['items'][] = new $this->item_class($this, $items[$key]);
3000
+ }
3001
+ }
3002
+ }
3003
+ }
3004
+
3005
+ if (!empty($this->data['items']))
3006
+ {
3007
+ // If we want to order it by date, check if all items have a date, and then sort it
3008
+ if ($this->order_by_date && empty($this->multifeed_objects))
3009
+ {
3010
+ if (!isset($this->data['ordered_items']))
3011
+ {
3012
+ $do_sort = true;
3013
+ foreach ($this->data['items'] as $item)
3014
+ {
3015
+ if (!$item->get_date('U'))
3016
+ {
3017
+ $do_sort = false;
3018
+ break;
3019
+ }
3020
+ }
3021
+ $item = null;
3022
+ $this->data['ordered_items'] = $this->data['items'];
3023
+ if ($do_sort)
3024
+ {
3025
+ usort($this->data['ordered_items'], array(&$this, 'sort_items'));
3026
+ }
3027
+ }
3028
+ $items = $this->data['ordered_items'];
3029
+ }
3030
+ else
3031
+ {
3032
+ $items = $this->data['items'];
3033
+ }
3034
+
3035
+ // Slice the data as desired
3036
+ if ($end === 0)
3037
+ {
3038
+ return array_slice($items, $start);
3039
+ }
3040
+ else
3041
+ {
3042
+ return array_slice($items, $start, $end);
3043
+ }
3044
+ }
3045
+ else
3046
+ {
3047
+ return array();
3048
+ }
3049
+ }
3050
+
3051
+ /**
3052
+ * @static
3053
+ */
3054
+ function sort_items($a, $b)
3055
+ {
3056
+ return $a->get_date('U') <= $b->get_date('U');
3057
+ }
3058
+
3059
+ /**
3060
+ * @static
3061
+ */
3062
+ function merge_items($urls, $start = 0, $end = 0, $limit = 0)
3063
+ {
3064
+ if (is_array($urls) && sizeof($urls) > 0)
3065
+ {
3066
+ $items = array();
3067
+ foreach ($urls as $arg)
3068
+ {
3069
+ if (is_a($arg, 'SimplePie'))
3070
+ {
3071
+ $items = array_merge($items, $arg->get_items(0, $limit));
3072
+ }
3073
+ else
3074
+ {
3075
+ trigger_error('Arguments must be SimplePie objects', E_USER_WARNING);
3076
+ }
3077
+ }
3078
+
3079
+ $do_sort = true;
3080
+ foreach ($items as $item)
3081
+ {
3082
+ if (!$item->get_date('U'))
3083
+ {
3084
+ $do_sort = false;
3085
+ break;
3086
+ }
3087
+ }
3088
+ $item = null;
3089
+ if ($do_sort)
3090
+ {
3091
+ usort($items, array('SimplePie', 'sort_items'));
3092
+ }
3093
+
3094
+ if ($end === 0)
3095
+ {
3096
+ return array_slice($items, $start);
3097
+ }
3098
+ else
3099
+ {
3100
+ return array_slice($items, $start, $end);
3101
+ }
3102
+ }
3103
+ else
3104
+ {
3105
+ trigger_error('Cannot merge zero SimplePie objects', E_USER_WARNING);
3106
+ return array();
3107
+ }
3108
+ }
3109
+ }
3110
+
3111
+ class SimplePie_Item
3112
+ {
3113
+ var $feed;
3114
+ var $data = array();
3115
+
3116
+ function SimplePie_Item($feed, $data)
3117
+ {
3118
+ $this->feed = $feed;
3119
+ $this->data = $data;
3120
+ }
3121
+
3122
+ function __toString()
3123
+ {
3124
+ return md5(serialize($this->data));
3125
+ }
3126
+
3127
+ /**
3128
+ * Remove items that link back to this before destroying this object
3129
+ */
3130
+ function __destruct()
3131
+ {
3132
+ if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))
3133
+ {
3134
+ unset($this->feed);
3135
+ }
3136
+ }
3137
+
3138
+ function get_item_tags($namespace, $tag)
3139
+ {
3140
+ if (isset($this->data['child'][$namespace][$tag]))
3141
+ {
3142
+ return $this->data['child'][$namespace][$tag];
3143
+ }
3144
+ else
3145
+ {
3146
+ return null;
3147
+ }
3148
+ }
3149
+
3150
+ function get_base($element = array())
3151
+ {
3152
+ return $this->feed->get_base($element);
3153
+ }
3154
+
3155
+ function sanitize($data, $type, $base = '')
3156
+ {
3157
+ return $this->feed->sanitize($data, $type, $base);
3158
+ }
3159
+
3160
+ function get_feed()
3161
+ {
3162
+ return $this->feed;
3163
+ }
3164
+
3165
+ function get_id($hash = false)
3166
+ {
3167
+ if (!$hash)
3168
+ {
3169
+ if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id'))
3170
+ {
3171
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3172
+ }
3173
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id'))
3174
+ {
3175
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3176
+ }
3177
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
3178
+ {
3179
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3180
+ }
3181
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier'))
3182
+ {
3183
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3184
+ }
3185
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier'))
3186
+ {
3187
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3188
+ }
3189
+ elseif (($return = $this->get_permalink()) !== null)
3190
+ {
3191
+ return $return;
3192
+ }
3193
+ elseif (($return = $this->get_title()) !== null)
3194
+ {
3195
+ return $return;
3196
+ }
3197
+ }
3198
+ if ($this->get_permalink() !== null || $this->get_title() !== null)
3199
+ {
3200
+ return md5($this->get_permalink() . $this->get_title());
3201
+ }
3202
+ else
3203
+ {
3204
+ return md5(serialize($this->data));
3205
+ }
3206
+ }
3207
+
3208
+ function get_title()
3209
+ {
3210
+ if (!isset($this->data['title']))
3211
+ {
3212
+ if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
3213
+ {
3214
+ $this->data['title'] = $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3215
+ }
3216
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
3217
+ {
3218
+ $this->data['title'] = $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3219
+ }
3220
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
3221
+ {
3222
+ $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
3223
+ }
3224
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
3225
+ {
3226
+ $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
3227
+ }
3228
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
3229
+ {
3230
+ $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
3231
+ }
3232
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
3233
+ {
3234
+ $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3235
+ }
3236
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
3237
+ {
3238
+ $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3239
+ }
3240
+ else
3241
+ {
3242
+ $this->data['title'] = null;
3243
+ }
3244
+ }
3245
+ return $this->data['title'];
3246
+ }
3247
+
3248
+ function get_description($description_only = false)
3249
+ {
3250
+ if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary'))
3251
+ {
3252
+ return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3253
+ }
3254
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary'))
3255
+ {
3256
+ return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3257
+ }
3258
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
3259
+ {
3260
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
3261
+ }
3262
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
3263
+ {
3264
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
3265
+ }
3266
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
3267
+ {
3268
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3269
+ }
3270
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
3271
+ {
3272
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3273
+ }
3274
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
3275
+ {
3276
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
3277
+ }
3278
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
3279
+ {
3280
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3281
+ }
3282
+ elseif (!$description_only)
3283
+ {
3284
+ return $this->get_content(true);
3285
+ }
3286
+ else
3287
+ {
3288
+ return null;
3289
+ }
3290
+ }
3291
+
3292
+ function get_content($content_only = false)
3293
+ {
3294
+ if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content'))
3295
+ {
3296
+ return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_content_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3297
+ }
3298
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content'))
3299
+ {
3300
+ return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3301
+ }
3302
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded'))
3303
+ {
3304
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
3305
+ }
3306
+ elseif (!$content_only)
3307
+ {
3308
+ return $this->get_description(true);
3309
+ }
3310
+ else
3311
+ {
3312
+ return null;
3313
+ }
3314
+ }
3315
+
3316
+ function get_category($key = 0)
3317
+ {
3318
+ $categories = $this->get_categories();
3319
+ if (isset($categories[$key]))
3320
+ {
3321
+ return $categories[$key];
3322
+ }
3323
+ else
3324
+ {
3325
+ return null;
3326
+ }
3327
+ }
3328
+
3329
+ function get_categories()
3330
+ {
3331
+ $categories = array();
3332
+
3333
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
3334
+ {
3335
+ $term = null;
3336
+ $scheme = null;
3337
+ $label = null;
3338
+ if (isset($category['attribs']['']['term']))
3339
+ {
3340
+ $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
3341
+ }
3342
+ if (isset($category['attribs']['']['scheme']))
3343
+ {
3344
+ $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
3345
+ }
3346
+ if (isset($category['attribs']['']['label']))
3347
+ {
3348
+ $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
3349
+ }
3350
+ $categories[] = new $this->feed->category_class($term, $scheme, $label);
3351
+ }
3352
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
3353
+ {
3354
+ // This is really the label, but keep this as the term also for BC.
3355
+ // Label will also work on retrieving because that falls back to term.
3356
+ $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3357
+ if (isset($category['attribs']['']['domain']))
3358
+ {
3359
+ $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
3360
+ }
3361
+ else
3362
+ {
3363
+ $scheme = null;
3364
+ }
3365
+ $categories[] = new $this->feed->category_class($term, $scheme, null);
3366
+ }
3367
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
3368
+ {
3369
+ $categories[] = new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
3370
+ }
3371
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
3372
+ {
3373
+ $categories[] = new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
3374
+ }
3375
+
3376
+ if (!empty($categories))
3377
+ {
3378
+ return SimplePie_Misc::array_unique($categories);
3379
+ }
3380
+ else
3381
+ {
3382
+ return null;
3383
+ }
3384
+ }
3385
+
3386
+ function get_author($key = 0)
3387
+ {
3388
+ $authors = $this->get_authors();
3389
+ if (isset($authors[$key]))
3390
+ {
3391
+ return $authors[$key];
3392
+ }
3393
+ else
3394
+ {
3395
+ return null;
3396
+ }
3397
+ }
3398
+
3399
+ function get_contributor($key = 0)
3400
+ {
3401
+ $contributors = $this->get_contributors();
3402
+ if (isset($contributors[$key]))
3403
+ {
3404
+ return $contributors[$key];
3405
+ }
3406
+ else
3407
+ {
3408
+ return null;
3409
+ }
3410
+ }
3411
+
3412
+ function get_contributors()
3413
+ {
3414
+ $contributors = array();
3415
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
3416
+ {
3417
+ $name = null;
3418
+ $uri = null;
3419
+ $email = null;
3420
+ if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
3421
+ {
3422
+ $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3423
+ }
3424
+ if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
3425
+ {
3426
+ $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
3427
+ }
3428
+ if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
3429
+ {
3430
+ $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3431
+ }
3432
+ if ($name !== null || $email !== null || $uri !== null)
3433
+ {
3434
+ $contributors[] = new $this->feed->author_class($name, $uri, $email);
3435
+ }
3436
+ }
3437
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
3438
+ {
3439
+ $name = null;
3440
+ $url = null;
3441
+ $email = null;
3442
+ if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
3443
+ {
3444
+ $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3445
+ }
3446
+ if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
3447
+ {
3448
+ $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
3449
+ }
3450
+ if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
3451
+ {
3452
+ $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3453
+ }
3454
+ if ($name !== null || $email !== null || $url !== null)
3455
+ {
3456
+ $contributors[] = new $this->feed->author_class($name, $url, $email);
3457
+ }
3458
+ }
3459
+
3460
+ if (!empty($contributors))
3461
+ {
3462
+ return SimplePie_Misc::array_unique($contributors);
3463
+ }
3464
+ else
3465
+ {
3466
+ return null;
3467
+ }
3468
+ }
3469
+
3470
+ function get_authors()
3471
+ {
3472
+ $authors = array();
3473
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
3474
+ {
3475
+ $name = null;
3476
+ $uri = null;
3477
+ $email = null;
3478
+ if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
3479
+ {
3480
+ $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3481
+ }
3482
+ if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
3483
+ {
3484
+ $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
3485
+ }
3486
+ if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
3487
+ {
3488
+ $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3489
+ }
3490
+ if ($name !== null || $email !== null || $uri !== null)
3491
+ {
3492
+ $authors[] = new $this->feed->author_class($name, $uri, $email);
3493
+ }
3494
+ }
3495
+ if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
3496
+ {
3497
+ $name = null;
3498
+ $url = null;
3499
+ $email = null;
3500
+ if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
3501
+ {
3502
+ $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3503
+ }
3504
+ if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
3505
+ {
3506
+ $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
3507
+ }
3508
+ if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
3509
+ {
3510
+ $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3511
+ }
3512
+ if ($name !== null || $email !== null || $url !== null)
3513
+ {
3514
+ $authors[] = new $this->feed->author_class($name, $url, $email);
3515
+ }
3516
+ }
3517
+ if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author'))
3518
+ {
3519
+ $authors[] = new $this->feed->author_class(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
3520
+ }
3521
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
3522
+ {
3523
+ $authors[] = new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
3524
+ }
3525
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
3526
+ {
3527
+ $authors[] = new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
3528
+ }
3529
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
3530
+ {
3531
+ $authors[] = new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
3532
+ }
3533
+
3534
+ if (!empty($authors))
3535
+ {
3536
+ return SimplePie_Misc::array_unique($authors);
3537
+ }
3538
+ elseif (($source = $this->get_source()) && ($authors = $source->get_authors()))
3539
+ {
3540
+ return $authors;
3541
+ }
3542
+ elseif ($authors = $this->feed->get_authors())
3543
+ {
3544
+ return $authors;
3545
+ }
3546
+ else
3547
+ {
3548
+ return null;
3549
+ }
3550
+ }
3551
+
3552
+ function get_copyright()
3553
+ {
3554
+ if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
3555
+ {
3556
+ return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3557
+ }
3558
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
3559
+ {
3560
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3561
+ }
3562
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
3563
+ {
3564
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3565
+ }
3566
+ else
3567
+ {
3568
+ return null;
3569
+ }
3570
+ }
3571
+
3572
+ function get_date($date_format = 'j F Y, g:i a')
3573
+ {
3574
+ if (!isset($this->data['date']))
3575
+ {
3576
+ if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published'))
3577
+ {
3578
+ $this->data['date']['raw'] = $return[0]['data'];
3579
+ }
3580
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated'))
3581
+ {
3582
+ $this->data['date']['raw'] = $return[0]['data'];
3583
+ }
3584
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued'))
3585
+ {
3586
+ $this->data['date']['raw'] = $return[0]['data'];
3587
+ }
3588
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created'))
3589
+ {
3590
+ $this->data['date']['raw'] = $return[0]['data'];
3591
+ }
3592
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified'))
3593
+ {
3594
+ $this->data['date']['raw'] = $return[0]['data'];
3595
+ }
3596
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate'))
3597
+ {
3598
+ $this->data['date']['raw'] = $return[0]['data'];
3599
+ }
3600
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date'))
3601
+ {
3602
+ $this->data['date']['raw'] = $return[0]['data'];
3603
+ }
3604
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date'))
3605
+ {
3606
+ $this->data['date']['raw'] = $return[0]['data'];
3607
+ }
3608
+
3609
+ if (!empty($this->data['date']['raw']))
3610
+ {
3611
+ $parser = SimplePie_Parse_Date::get();
3612
+ $this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']);
3613
+ }
3614
+ else
3615
+ {
3616
+ $this->data['date'] = null;
3617
+ }
3618
+ }
3619
+ if ($this->data['date'])
3620
+ {
3621
+ $date_format = (string) $date_format;
3622
+ switch ($date_format)
3623
+ {
3624
+ case '':
3625
+ return $this->sanitize($this->data['date']['raw'], SIMPLEPIE_CONSTRUCT_TEXT);
3626
+
3627
+ case 'U':
3628
+ return $this->data['date']['parsed'];
3629
+
3630
+ default:
3631
+ return date($date_format, $this->data['date']['parsed']);
3632
+ }
3633
+ }
3634
+ else
3635
+ {
3636
+ return null;
3637
+ }
3638
+ }
3639
+
3640
+ function get_local_date($date_format = '%c')
3641
+ {
3642
+ if (!$date_format)
3643
+ {
3644
+ return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT);
3645
+ }
3646
+ elseif (($date = $this->get_date('U')) !== null)
3647
+ {
3648
+ return strftime($date_format, $date);
3649
+ }
3650
+ else
3651
+ {
3652
+ return null;
3653
+ }
3654
+ }
3655
+
3656
+ function get_permalink()
3657
+ {
3658
+ $link = $this->get_link();
3659
+ $enclosure = $this->get_enclosure(0);
3660
+ if ($link !== null)
3661
+ {
3662
+ return $link;
3663
+ }
3664
+ elseif ($enclosure !== null)
3665
+ {
3666
+ return $enclosure->get_link();
3667
+ }
3668
+ else
3669
+ {
3670
+ return null;
3671
+ }
3672
+ }
3673
+
3674
+ function get_link($key = 0, $rel = 'alternate')
3675
+ {
3676
+ $links = $this->get_links($rel);
3677
+ if ($links[$key] !== null)
3678
+ {
3679
+ return $links[$key];
3680
+ }
3681
+ else
3682
+ {
3683
+ return null;
3684
+ }
3685
+ }
3686
+
3687
+ function get_links($rel = 'alternate')
3688
+ {
3689
+ if (!isset($this->data['links']))
3690
+ {
3691
+ $this->data['links'] = array();
3692
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link)
3693
+ {
3694
+ if (isset($link['attribs']['']['href']))
3695
+ {
3696
+ $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
3697
+ $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
3698
+
3699
+ }
3700
+ }
3701
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link)
3702
+ {
3703
+ if (isset($link['attribs']['']['href']))
3704
+ {
3705
+ $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
3706
+ $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
3707
+ }
3708
+ }
3709
+ if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
3710
+ {
3711
+ $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
3712
+ }
3713
+ if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
3714
+ {
3715
+ $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
3716
+ }
3717
+ if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
3718
+ {
3719
+ $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
3720
+ }
3721
+ if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
3722
+ {
3723
+ if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true')
3724
+ {
3725
+ $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
3726
+ }
3727
+ }
3728
+
3729
+ $keys = array_keys($this->data['links']);
3730
+ foreach ($keys as $key)
3731
+ {
3732
+ if (SimplePie_Misc::is_isegment_nz_nc($key))
3733
+ {
3734
+ if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
3735
+ {
3736
+ $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
3737
+ $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
3738
+ }
3739
+ else
3740
+ {
3741
+ $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
3742
+ }
3743
+ }
3744
+ elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
3745
+ {
3746
+ $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
3747
+ }
3748
+ $this->data['links'][$key] = array_unique($this->data['links'][$key]);
3749
+ }
3750
+ }
3751
+ if (isset($this->data['links'][$rel]))
3752
+ {
3753
+ return $this->data['links'][$rel];
3754
+ }
3755
+ else
3756
+ {
3757
+ return null;
3758
+ }
3759
+ }
3760
+
3761
+ /**
3762
+ * @todo Add ability to prefer one type of content over another (in a media group).
3763
+ */
3764
+ function get_enclosure($key = 0, $prefer = null)
3765
+ {
3766
+ $enclosures = $this->get_enclosures();
3767
+ if (isset($enclosures[$key]))
3768
+ {
3769
+ return $enclosures[$key];
3770
+ }
3771
+ else
3772
+ {
3773
+ return null;
3774
+ }
3775
+ }
3776
+
3777
+ /**
3778
+ * Grabs all available enclosures (podcasts, etc.)
3779
+ *
3780
+ * Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS.
3781
+ *
3782
+ * At this point, we're pretty much assuming that all enclosures for an item are the same content. Anything else is too complicated to properly support.
3783
+ *
3784
+ * @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4).
3785
+ * @todo If an element exists at a level, but it's value is empty, we should fall back to the value from the parent (if it exists).
3786
+ */
3787
+ function get_enclosures()
3788
+ {
3789
+ if (!isset($this->data['enclosures']))
3790
+ {
3791
+ $this->data['enclosures'] = array();
3792
+
3793
+ // Elements
3794
+ $captions_parent = null;
3795
+ $categories_parent = null;
3796
+ $copyrights_parent = null;
3797
+ $credits_parent = null;
3798
+ $description_parent = null;
3799
+ $duration_parent = null;
3800
+ $hashes_parent = null;
3801
+ $keywords_parent = null;
3802
+ $player_parent = null;
3803
+ $ratings_parent = null;
3804
+ $restrictions_parent = null;
3805
+ $thumbnails_parent = null;
3806
+ $title_parent = null;
3807
+
3808
+ // Let's do the channel and item-level ones first, and just re-use them if we need to.
3809
+ $parent = $this->get_feed();
3810
+
3811
+ // CAPTIONS
3812
+ if ($captions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text'))
3813
+ {
3814
+ foreach ($captions as $caption)
3815
+ {
3816
+ $caption_type = null;
3817
+ $caption_lang = null;
3818
+ $caption_startTime = null;
3819
+ $caption_endTime = null;
3820
+ $caption_text = null;
3821
+ if (isset($caption['attribs']['']['type']))
3822
+ {
3823
+ $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
3824
+ }
3825
+ if (isset($caption['attribs']['']['lang']))
3826
+ {
3827
+ $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
3828
+ }
3829
+ if (isset($caption['attribs']['']['start']))
3830
+ {
3831
+ $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
3832
+ }
3833
+ if (isset($caption['attribs']['']['end']))
3834
+ {
3835
+ $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
3836
+ }
3837
+ if (isset($caption['data']))
3838
+ {
3839
+ $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3840
+ }
3841
+ $captions_parent[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
3842
+ }
3843
+ }
3844
+ elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text'))
3845
+ {
3846
+ foreach ($captions as $caption)
3847
+ {
3848
+ $caption_type = null;
3849
+ $caption_lang = null;
3850
+ $caption_startTime = null;
3851
+ $caption_endTime = null;
3852
+ $caption_text = null;
3853
+ if (isset($caption['attribs']['']['type']))
3854
+ {
3855
+ $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
3856
+ }
3857
+ if (isset($caption['attribs']['']['lang']))
3858
+ {
3859
+ $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
3860
+ }
3861
+ if (isset($caption['attribs']['']['start']))
3862
+ {
3863
+ $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
3864
+ }
3865
+ if (isset($caption['attribs']['']['end']))
3866
+ {
3867
+ $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
3868
+ }
3869
+ if (isset($caption['data']))
3870
+ {
3871
+ $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3872
+ }
3873
+ $captions_parent[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
3874
+ }
3875
+ }
3876
+ if (is_array($captions_parent))
3877
+ {
3878
+ $captions_parent = array_values(SimplePie_Misc::array_unique($captions_parent));
3879
+ }
3880
+
3881
+ // CATEGORIES
3882
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category)
3883
+ {
3884
+ $term = null;
3885
+ $scheme = null;
3886
+ $label = null;
3887
+ if (isset($category['data']))
3888
+ {
3889
+ $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3890
+ }
3891
+ if (isset($category['attribs']['']['scheme']))
3892
+ {
3893
+ $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
3894
+ }
3895
+ else
3896
+ {
3897
+ $scheme = 'http://search.yahoo.com/mrss/category_schema';
3898
+ }
3899
+ if (isset($category['attribs']['']['label']))
3900
+ {
3901
+ $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
3902
+ }
3903
+ $categories_parent[] = new $this->feed->category_class($term, $scheme, $label);
3904
+ }
3905
+ foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category)
3906
+ {
3907
+ $term = null;
3908
+ $scheme = null;
3909
+ $label = null;
3910
+ if (isset($category['data']))
3911
+ {
3912
+ $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3913
+ }
3914
+ if (isset($category['attribs']['']['scheme']))
3915
+ {
3916
+ $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
3917
+ }
3918
+ else
3919
+ {
3920
+ $scheme = 'http://search.yahoo.com/mrss/category_schema';
3921
+ }
3922
+ if (isset($category['attribs']['']['label']))
3923
+ {
3924
+ $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
3925
+ }
3926
+ $categories_parent[] = new $this->feed->category_class($term, $scheme, $label);
3927
+ }
3928
+ foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'category') as $category)
3929
+ {
3930
+ $term = null;
3931
+ $scheme = 'http://www.itunes.com/dtds/podcast-1.0.dtd';
3932
+ $label = null;
3933
+ if (isset($category['attribs']['']['text']))
3934
+ {
3935
+ $label = $this->sanitize($category['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT);
3936
+ }
3937
+ $categories_parent[] = new $this->feed->category_class($term, $scheme, $label);
3938
+
3939
+ if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category']))
3940
+ {
3941
+ foreach ((array) $category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'] as $subcategory)
3942
+ {
3943
+ if (isset($subcategory['attribs']['']['text']))
3944
+ {
3945
+ $label = $this->sanitize($subcategory['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT);
3946
+ }
3947
+ $categories_parent[] = new $this->feed->category_class($term, $scheme, $label);
3948
+ }
3949
+ }
3950
+ }
3951
+ if (is_array($categories_parent))
3952
+ {
3953
+ $categories_parent = array_values(SimplePie_Misc::array_unique($categories_parent));
3954
+ }
3955
+
3956
+ // COPYRIGHT
3957
+ if ($copyright = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright'))
3958
+ {
3959
+ $copyright_url = null;
3960
+ $copyright_label = null;
3961
+ if (isset($copyright[0]['attribs']['']['url']))
3962
+ {
3963
+ $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
3964
+ }
3965
+ if (isset($copyright[0]['data']))
3966
+ {
3967
+ $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3968
+ }
3969
+ $copyrights_parent = new $this->feed->copyright_class($copyright_url, $copyright_label);
3970
+ }
3971
+ elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright'))
3972
+ {
3973
+ $copyright_url = null;
3974
+ $copyright_label = null;
3975
+ if (isset($copyright[0]['attribs']['']['url']))
3976
+ {
3977
+ $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
3978
+ }
3979
+ if (isset($copyright[0]['data']))
3980
+ {
3981
+ $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3982
+ }
3983
+ $copyrights_parent = new $this->feed->copyright_class($copyright_url, $copyright_label);
3984
+ }
3985
+
3986
+ // CREDITS
3987
+ if ($credits = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit'))
3988
+ {
3989
+ foreach ($credits as $credit)
3990
+ {
3991
+ $credit_role = null;
3992
+ $credit_scheme = null;
3993
+ $credit_name = null;
3994
+ if (isset($credit['attribs']['']['role']))
3995
+ {
3996
+ $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
3997
+ }
3998
+ if (isset($credit['attribs']['']['scheme']))
3999
+ {
4000
+ $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4001
+ }
4002
+ else
4003
+ {
4004
+ $credit_scheme = 'urn:ebu';
4005
+ }
4006
+ if (isset($credit['data']))
4007
+ {
4008
+ $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4009
+ }
4010
+ $credits_parent[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
4011
+ }
4012
+ }
4013
+ elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit'))
4014
+ {
4015
+ foreach ($credits as $credit)
4016
+ {
4017
+ $credit_role = null;
4018
+ $credit_scheme = null;
4019
+ $credit_name = null;
4020
+ if (isset($credit['attribs']['']['role']))
4021
+ {
4022
+ $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
4023
+ }
4024
+ if (isset($credit['attribs']['']['scheme']))
4025
+ {
4026
+ $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4027
+ }
4028
+ else
4029
+ {
4030
+ $credit_scheme = 'urn:ebu';
4031
+ }
4032
+ if (isset($credit['data']))
4033
+ {
4034
+ $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4035
+ }
4036
+ $credits_parent[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
4037
+ }
4038
+ }
4039
+ if (is_array($credits_parent))
4040
+ {
4041
+ $credits_parent = array_values(SimplePie_Misc::array_unique($credits_parent));
4042
+ }
4043
+
4044
+ // DESCRIPTION
4045
+ if ($description_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description'))
4046
+ {
4047
+ if (isset($description_parent[0]['data']))
4048
+ {
4049
+ $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4050
+ }
4051
+ }
4052
+ elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description'))
4053
+ {
4054
+ if (isset($description_parent[0]['data']))
4055
+ {
4056
+ $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4057
+ }
4058
+ }
4059
+
4060
+ // DURATION
4061
+ if ($duration_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'duration'))
4062
+ {
4063
+ $seconds = null;
4064
+ $minutes = null;
4065
+ $hours = null;
4066
+ if (isset($duration_parent[0]['data']))
4067
+ {
4068
+ $temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
4069
+ if (sizeof($temp) > 0)
4070
+ {
4071
+ (int) $seconds = array_pop($temp);
4072
+ }
4073
+ if (sizeof($temp) > 0)
4074
+ {
4075
+ (int) $minutes = array_pop($temp);
4076
+ $seconds += $minutes * 60;
4077
+ }
4078
+ if (sizeof($temp) > 0)
4079
+ {
4080
+ (int) $hours = array_pop($temp);
4081
+ $seconds += $hours * 3600;
4082
+ }
4083
+ unset($temp);
4084
+ $duration_parent = $seconds;
4085
+ }
4086
+ }
4087
+
4088
+ // HASHES
4089
+ if ($hashes_iterator = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash'))
4090
+ {
4091
+ foreach ($hashes_iterator as $hash)
4092
+ {
4093
+ $value = null;
4094
+ $algo = null;
4095
+ if (isset($hash['data']))
4096
+ {
4097
+ $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4098
+ }
4099
+ if (isset($hash['attribs']['']['algo']))
4100
+ {
4101
+ $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
4102
+ }
4103
+ else
4104
+ {
4105
+ $algo = 'md5';
4106
+ }
4107
+ $hashes_parent[] = $algo.':'.$value;
4108
+ }
4109
+ }
4110
+ elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash'))
4111
+ {
4112
+ foreach ($hashes_iterator as $hash)
4113
+ {
4114
+ $value = null;
4115
+ $algo = null;
4116
+ if (isset($hash['data']))
4117
+ {
4118
+ $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4119
+ }
4120
+ if (isset($hash['attribs']['']['algo']))
4121
+ {
4122
+ $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
4123
+ }
4124
+ else
4125
+ {
4126
+ $algo = 'md5';
4127
+ }
4128
+ $hashes_parent[] = $algo.':'.$value;
4129
+ }
4130
+ }
4131
+ if (is_array($hashes_parent))
4132
+ {
4133
+ $hashes_parent = array_values(SimplePie_Misc::array_unique($hashes_parent));
4134
+ }
4135
+
4136
+ // KEYWORDS
4137
+ if ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords'))
4138
+ {
4139
+ if (isset($keywords[0]['data']))
4140
+ {
4141
+ $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
4142
+ foreach ($temp as $word)
4143
+ {
4144
+ $keywords_parent[] = trim($word);
4145
+ }
4146
+ }
4147
+ unset($temp);
4148
+ }
4149
+ elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords'))
4150
+ {
4151
+ if (isset($keywords[0]['data']))
4152
+ {
4153
+ $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
4154
+ foreach ($temp as $word)
4155
+ {
4156
+ $keywords_parent[] = trim($word);
4157
+ }
4158
+ }
4159
+ unset($temp);
4160
+ }
4161
+ elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords'))
4162
+ {
4163
+ if (isset($keywords[0]['data']))
4164
+ {
4165
+ $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
4166
+ foreach ($temp as $word)
4167
+ {
4168
+ $keywords_parent[] = trim($word);
4169
+ }
4170
+ }
4171
+ unset($temp);
4172
+ }
4173
+ elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords'))
4174
+ {
4175
+ if (isset($keywords[0]['data']))
4176
+ {
4177
+ $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
4178
+ foreach ($temp as $word)
4179
+ {
4180
+ $keywords_parent[] = trim($word);
4181
+ }
4182
+ }
4183
+ unset($temp);
4184
+ }
4185
+ if (is_array($keywords_parent))
4186
+ {
4187
+ $keywords_parent = array_values(SimplePie_Misc::array_unique($keywords_parent));
4188
+ }
4189
+
4190
+ // PLAYER
4191
+ if ($player_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player'))
4192
+ {
4193
+ if (isset($player_parent[0]['attribs']['']['url']))
4194
+ {
4195
+ $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
4196
+ }
4197
+ }
4198
+ elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player'))
4199
+ {
4200
+ if (isset($player_parent[0]['attribs']['']['url']))
4201
+ {
4202
+ $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
4203
+ }
4204
+ }
4205
+
4206
+ // RATINGS
4207
+ if ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating'))
4208
+ {
4209
+ foreach ($ratings as $rating)
4210
+ {
4211
+ $rating_scheme = null;
4212
+ $rating_value = null;
4213
+ if (isset($rating['attribs']['']['scheme']))
4214
+ {
4215
+ $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4216
+ }
4217
+ else
4218
+ {
4219
+ $rating_scheme = 'urn:simple';
4220
+ }
4221
+ if (isset($rating['data']))
4222
+ {
4223
+ $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4224
+ }
4225
+ $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value);
4226
+ }
4227
+ }
4228
+ elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit'))
4229
+ {
4230
+ foreach ($ratings as $rating)
4231
+ {
4232
+ $rating_scheme = 'urn:itunes';
4233
+ $rating_value = null;
4234
+ if (isset($rating['data']))
4235
+ {
4236
+ $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4237
+ }
4238
+ $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value);
4239
+ }
4240
+ }
4241
+ elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating'))
4242
+ {
4243
+ foreach ($ratings as $rating)
4244
+ {
4245
+ $rating_scheme = null;
4246
+ $rating_value = null;
4247
+ if (isset($rating['attribs']['']['scheme']))
4248
+ {
4249
+ $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4250
+ }
4251
+ else
4252
+ {
4253
+ $rating_scheme = 'urn:simple';
4254
+ }
4255
+ if (isset($rating['data']))
4256
+ {
4257
+ $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4258
+ }
4259
+ $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value);
4260
+ }
4261
+ }
4262
+ elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit'))
4263
+ {
4264
+ foreach ($ratings as $rating)
4265
+ {
4266
+ $rating_scheme = 'urn:itunes';
4267
+ $rating_value = null;
4268
+ if (isset($rating['data']))
4269
+ {
4270
+ $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4271
+ }
4272
+ $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value);
4273
+ }
4274
+ }
4275
+ if (is_array($ratings_parent))
4276
+ {
4277
+ $ratings_parent = array_values(SimplePie_Misc::array_unique($ratings_parent));
4278
+ }
4279
+
4280
+ // RESTRICTIONS
4281
+ if ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction'))
4282
+ {
4283
+ foreach ($restrictions as $restriction)
4284
+ {
4285
+ $restriction_relationship = null;
4286
+ $restriction_type = null;
4287
+ $restriction_value = null;
4288
+ if (isset($restriction['attribs']['']['relationship']))
4289
+ {
4290
+ $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
4291
+ }
4292
+ if (isset($restriction['attribs']['']['type']))
4293
+ {
4294
+ $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4295
+ }
4296
+ if (isset($restriction['data']))
4297
+ {
4298
+ $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4299
+ }
4300
+ $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
4301
+ }
4302
+ }
4303
+ elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block'))
4304
+ {
4305
+ foreach ($restrictions as $restriction)
4306
+ {
4307
+ $restriction_relationship = 'allow';
4308
+ $restriction_type = null;
4309
+ $restriction_value = 'itunes';
4310
+ if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes')
4311
+ {
4312
+ $restriction_relationship = 'deny';
4313
+ }
4314
+ $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
4315
+ }
4316
+ }
4317
+ elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction'))
4318
+ {
4319
+ foreach ($restrictions as $restriction)
4320
+ {
4321
+ $restriction_relationship = null;
4322
+ $restriction_type = null;
4323
+ $restriction_value = null;
4324
+ if (isset($restriction['attribs']['']['relationship']))
4325
+ {
4326
+ $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
4327
+ }
4328
+ if (isset($restriction['attribs']['']['type']))
4329
+ {
4330
+ $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4331
+ }
4332
+ if (isset($restriction['data']))
4333
+ {
4334
+ $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4335
+ }
4336
+ $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
4337
+ }
4338
+ }
4339
+ elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block'))
4340
+ {
4341
+ foreach ($restrictions as $restriction)
4342
+ {
4343
+ $restriction_relationship = 'allow';
4344
+ $restriction_type = null;
4345
+ $restriction_value = 'itunes';
4346
+ if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes')
4347
+ {
4348
+ $restriction_relationship = 'deny';
4349
+ }
4350
+ $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
4351
+ }
4352
+ }
4353
+ if (is_array($restrictions_parent))
4354
+ {
4355
+ $restrictions_parent = array_values(SimplePie_Misc::array_unique($restrictions_parent));
4356
+ }
4357
+
4358
+ // THUMBNAILS
4359
+ if ($thumbnails = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))
4360
+ {
4361
+ foreach ($thumbnails as $thumbnail)
4362
+ {
4363
+ if (isset($thumbnail['attribs']['']['url']))
4364
+ {
4365
+ $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
4366
+ }
4367
+ }
4368
+ }
4369
+ elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))
4370
+ {
4371
+ foreach ($thumbnails as $thumbnail)
4372
+ {
4373
+ if (isset($thumbnail['attribs']['']['url']))
4374
+ {
4375
+ $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
4376
+ }
4377
+ }
4378
+ }
4379
+
4380
+ // TITLES
4381
+ if ($title_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title'))
4382
+ {
4383
+ if (isset($title_parent[0]['data']))
4384
+ {
4385
+ $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4386
+ }
4387
+ }
4388
+ elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title'))
4389
+ {
4390
+ if (isset($title_parent[0]['data']))
4391
+ {
4392
+ $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4393
+ }
4394
+ }
4395
+
4396
+ // Clear the memory
4397
+ unset($parent);
4398
+
4399
+ // Attributes
4400
+ $bitrate = null;
4401
+ $channels = null;
4402
+ $duration = null;
4403
+ $expression = null;
4404
+ $framerate = null;
4405
+ $height = null;
4406
+ $javascript = null;
4407
+ $lang = null;
4408
+ $length = null;
4409
+ $medium = null;
4410
+ $samplingrate = null;
4411
+ $type = null;
4412
+ $url = null;
4413
+ $width = null;
4414
+
4415
+ // Elements
4416
+ $captions = null;
4417
+ $categories = null;
4418
+ $copyrights = null;
4419
+ $credits = null;
4420
+ $description = null;
4421
+ $hashes = null;
4422
+ $keywords = null;
4423
+ $player = null;
4424
+ $ratings = null;
4425
+ $restrictions = null;
4426
+ $thumbnails = null;
4427
+ $title = null;
4428
+
4429
+ // If we have media:group tags, loop through them.
4430
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group)
4431
+ {
4432
+ if(isset($group['child']) && isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
4433
+ {
4434
+ // If we have media:content tags, loop through them.
4435
+ foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
4436
+ {
4437
+ if (isset($content['attribs']['']['url']))
4438
+ {
4439
+ // Attributes
4440
+ $bitrate = null;
4441
+ $channels = null;
4442
+ $duration = null;
4443
+ $expression = null;
4444
+ $framerate = null;
4445
+ $height = null;
4446
+ $javascript = null;
4447
+ $lang = null;
4448
+ $length = null;
4449
+ $medium = null;
4450
+ $samplingrate = null;
4451
+ $type = null;
4452
+ $url = null;
4453
+ $width = null;
4454
+
4455
+ // Elements
4456
+ $captions = null;
4457
+ $categories = null;
4458
+ $copyrights = null;
4459
+ $credits = null;
4460
+ $description = null;
4461
+ $hashes = null;
4462
+ $keywords = null;
4463
+ $player = null;
4464
+ $ratings = null;
4465
+ $restrictions = null;
4466
+ $thumbnails = null;
4467
+ $title = null;
4468
+
4469
+ // Start checking the attributes of media:content
4470
+ if (isset($content['attribs']['']['bitrate']))
4471
+ {
4472
+ $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
4473
+ }
4474
+ if (isset($content['attribs']['']['channels']))
4475
+ {
4476
+ $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
4477
+ }
4478
+ if (isset($content['attribs']['']['duration']))
4479
+ {
4480
+ $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
4481
+ }
4482
+ else
4483
+ {
4484
+ $duration = $duration_parent;
4485
+ }
4486
+ if (isset($content['attribs']['']['expression']))
4487
+ {
4488
+ $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
4489
+ }
4490
+ if (isset($content['attribs']['']['framerate']))
4491
+ {
4492
+ $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
4493
+ }
4494
+ if (isset($content['attribs']['']['height']))
4495
+ {
4496
+ $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
4497
+ }
4498
+ if (isset($content['attribs']['']['lang']))
4499
+ {
4500
+ $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
4501
+ }
4502
+ if (isset($content['attribs']['']['fileSize']))
4503
+ {
4504
+ $length = ceil($content['attribs']['']['fileSize']);
4505
+ }
4506
+ if (isset($content['attribs']['']['medium']))
4507
+ {
4508
+ $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
4509
+ }
4510
+ if (isset($content['attribs']['']['samplingrate']))
4511
+ {
4512
+ $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
4513
+ }
4514
+ if (isset($content['attribs']['']['type']))
4515
+ {
4516
+ $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4517
+ }
4518
+ if (isset($content['attribs']['']['width']))
4519
+ {
4520
+ $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
4521
+ }
4522
+ $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
4523
+
4524
+ // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
4525
+
4526
+ // CAPTIONS
4527
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
4528
+ {
4529
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
4530
+ {
4531
+ $caption_type = null;
4532
+ $caption_lang = null;
4533
+ $caption_startTime = null;
4534
+ $caption_endTime = null;
4535
+ $caption_text = null;
4536
+ if (isset($caption['attribs']['']['type']))
4537
+ {
4538
+ $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4539
+ }
4540
+ if (isset($caption['attribs']['']['lang']))
4541
+ {
4542
+ $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
4543
+ }
4544
+ if (isset($caption['attribs']['']['start']))
4545
+ {
4546
+ $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
4547
+ }
4548
+ if (isset($caption['attribs']['']['end']))
4549
+ {
4550
+ $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
4551
+ }
4552
+ if (isset($caption['data']))
4553
+ {
4554
+ $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4555
+ }
4556
+ $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
4557
+ }
4558
+ if (is_array($captions))
4559
+ {
4560
+ $captions = array_values(SimplePie_Misc::array_unique($captions));
4561
+ }
4562
+ }
4563
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
4564
+ {
4565
+ foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
4566
+ {
4567
+ $caption_type = null;
4568
+ $caption_lang = null;
4569
+ $caption_startTime = null;
4570
+ $caption_endTime = null;
4571
+ $caption_text = null;
4572
+ if (isset($caption['attribs']['']['type']))
4573
+ {
4574
+ $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4575
+ }
4576
+ if (isset($caption['attribs']['']['lang']))
4577
+ {
4578
+ $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
4579
+ }
4580
+ if (isset($caption['attribs']['']['start']))
4581
+ {
4582
+ $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
4583
+ }
4584
+ if (isset($caption['attribs']['']['end']))
4585
+ {
4586
+ $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
4587
+ }
4588
+ if (isset($caption['data']))
4589
+ {
4590
+ $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4591
+ }
4592
+ $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
4593
+ }
4594
+ if (is_array($captions))
4595
+ {
4596
+ $captions = array_values(SimplePie_Misc::array_unique($captions));
4597
+ }
4598
+ }
4599
+ else
4600
+ {
4601
+ $captions = $captions_parent;
4602
+ }
4603
+
4604
+ // CATEGORIES
4605
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
4606
+ {
4607
+ foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
4608
+ {
4609
+ $term = null;
4610
+ $scheme = null;
4611
+ $label = null;
4612
+ if (isset($category['data']))
4613
+ {
4614
+ $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4615
+ }
4616
+ if (isset($category['attribs']['']['scheme']))
4617
+ {
4618
+ $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4619
+ }
4620
+ else
4621
+ {
4622
+ $scheme = 'http://search.yahoo.com/mrss/category_schema';
4623
+ }
4624
+ if (isset($category['attribs']['']['label']))
4625
+ {
4626
+ $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
4627
+ }
4628
+ $categories[] = new $this->feed->category_class($term, $scheme, $label);
4629
+ }
4630
+ }
4631
+ if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
4632
+ {
4633
+ foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
4634
+ {
4635
+ $term = null;
4636
+ $scheme = null;
4637
+ $label = null;
4638
+ if (isset($category['data']))
4639
+ {
4640
+ $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4641
+ }
4642
+ if (isset($category['attribs']['']['scheme']))
4643
+ {
4644
+ $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4645
+ }
4646
+ else
4647
+ {
4648
+ $scheme = 'http://search.yahoo.com/mrss/category_schema';
4649
+ }
4650
+ if (isset($category['attribs']['']['label']))
4651
+ {
4652
+ $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
4653
+ }
4654
+ $categories[] = new $this->feed->category_class($term, $scheme, $label);
4655
+ }
4656
+ }
4657
+ if (is_array($categories) && is_array($categories_parent))
4658
+ {
4659
+ $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent)));
4660
+ }
4661
+ elseif (is_array($categories))
4662
+ {
4663
+ $categories = array_values(SimplePie_Misc::array_unique($categories));
4664
+ }
4665
+ elseif (is_array($categories_parent))
4666
+ {
4667
+ $categories = array_values(SimplePie_Misc::array_unique($categories_parent));
4668
+ }
4669
+
4670
+ // COPYRIGHTS
4671
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
4672
+ {
4673
+ $copyright_url = null;
4674
+ $copyright_label = null;
4675
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
4676
+ {
4677
+ $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
4678
+ }
4679
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
4680
+ {
4681
+ $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4682
+ }
4683
+ $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label);
4684
+ }
4685
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
4686
+ {
4687
+ $copyright_url = null;
4688
+ $copyright_label = null;
4689
+ if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
4690
+ {
4691
+ $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
4692
+ }
4693
+ if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
4694
+ {
4695
+ $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4696
+ }
4697
+ $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label);
4698
+ }
4699
+ else
4700
+ {
4701
+ $copyrights = $copyrights_parent;
4702
+ }
4703
+
4704
+ // CREDITS
4705
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
4706
+ {
4707
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
4708
+ {
4709
+ $credit_role = null;
4710
+ $credit_scheme = null;
4711
+ $credit_name = null;
4712
+ if (isset($credit['attribs']['']['role']))
4713
+ {
4714
+ $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
4715
+ }
4716
+ if (isset($credit['attribs']['']['scheme']))
4717
+ {
4718
+ $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4719
+ }
4720
+ else
4721
+ {
4722
+ $credit_scheme = 'urn:ebu';
4723
+ }
4724
+ if (isset($credit['data']))
4725
+ {
4726
+ $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4727
+ }
4728
+ $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
4729
+ }
4730
+ if (is_array($credits))
4731
+ {
4732
+ $credits = array_values(SimplePie_Misc::array_unique($credits));
4733
+ }
4734
+ }
4735
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
4736
+ {
4737
+ foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
4738
+ {
4739
+ $credit_role = null;
4740
+ $credit_scheme = null;
4741
+ $credit_name = null;
4742
+ if (isset($credit['attribs']['']['role']))
4743
+ {
4744
+ $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
4745
+ }
4746
+ if (isset($credit['attribs']['']['scheme']))
4747
+ {
4748
+ $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4749
+ }
4750
+ else
4751
+ {
4752
+ $credit_scheme = 'urn:ebu';
4753
+ }
4754
+ if (isset($credit['data']))
4755
+ {
4756
+ $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4757
+ }
4758
+ $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
4759
+ }
4760
+ if (is_array($credits))
4761
+ {
4762
+ $credits = array_values(SimplePie_Misc::array_unique($credits));
4763
+ }
4764
+ }
4765
+ else
4766
+ {
4767
+ $credits = $credits_parent;
4768
+ }
4769
+
4770
+ // DESCRIPTION
4771
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
4772
+ {
4773
+ $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4774
+ }
4775
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
4776
+ {
4777
+ $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4778
+ }
4779
+ else
4780
+ {
4781
+ $description = $description_parent;
4782
+ }
4783
+
4784
+ // HASHES
4785
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
4786
+ {
4787
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
4788
+ {
4789
+ $value = null;
4790
+ $algo = null;
4791
+ if (isset($hash['data']))
4792
+ {
4793
+ $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4794
+ }
4795
+ if (isset($hash['attribs']['']['algo']))
4796
+ {
4797
+ $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
4798
+ }
4799
+ else
4800
+ {
4801
+ $algo = 'md5';
4802
+ }
4803
+ $hashes[] = $algo.':'.$value;
4804
+ }
4805
+ if (is_array($hashes))
4806
+ {
4807
+ $hashes = array_values(SimplePie_Misc::array_unique($hashes));
4808
+ }
4809
+ }
4810
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
4811
+ {
4812
+ foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
4813
+ {
4814
+ $value = null;
4815
+ $algo = null;
4816
+ if (isset($hash['data']))
4817
+ {
4818
+ $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4819
+ }
4820
+ if (isset($hash['attribs']['']['algo']))
4821
+ {
4822
+ $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
4823
+ }
4824
+ else
4825
+ {
4826
+ $algo = 'md5';
4827
+ }
4828
+ $hashes[] = $algo.':'.$value;
4829
+ }
4830
+ if (is_array($hashes))
4831
+ {
4832
+ $hashes = array_values(SimplePie_Misc::array_unique($hashes));
4833
+ }
4834
+ }
4835
+ else
4836
+ {
4837
+ $hashes = $hashes_parent;
4838
+ }
4839
+
4840
+ // KEYWORDS
4841
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
4842
+ {
4843
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
4844
+ {
4845
+ $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
4846
+ foreach ($temp as $word)
4847
+ {
4848
+ $keywords[] = trim($word);
4849
+ }
4850
+ unset($temp);
4851
+ }
4852
+ if (is_array($keywords))
4853
+ {
4854
+ $keywords = array_values(SimplePie_Misc::array_unique($keywords));
4855
+ }
4856
+ }
4857
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
4858
+ {
4859
+ if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
4860
+ {
4861
+ $temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
4862
+ foreach ($temp as $word)
4863
+ {
4864
+ $keywords[] = trim($word);
4865
+ }
4866
+ unset($temp);
4867
+ }
4868
+ if (is_array($keywords))
4869
+ {
4870
+ $keywords = array_values(SimplePie_Misc::array_unique($keywords));
4871
+ }
4872
+ }
4873
+ else
4874
+ {
4875
+ $keywords = $keywords_parent;
4876
+ }
4877
+
4878
+ // PLAYER
4879
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
4880
+ {
4881
+ $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
4882
+ }
4883
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
4884
+ {
4885
+ $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
4886
+ }
4887
+ else
4888
+ {
4889
+ $player = $player_parent;
4890
+ }
4891
+
4892
+ // RATINGS
4893
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
4894
+ {
4895
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
4896
+ {
4897
+ $rating_scheme = null;
4898
+ $rating_value = null;
4899
+ if (isset($rating['attribs']['']['scheme']))
4900
+ {
4901
+ $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4902
+ }
4903
+ else
4904
+ {
4905
+ $rating_scheme = 'urn:simple';
4906
+ }
4907
+ if (isset($rating['data']))
4908
+ {
4909
+ $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4910
+ }
4911
+ $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value);
4912
+ }
4913
+ if (is_array($ratings))
4914
+ {
4915
+ $ratings = array_values(SimplePie_Misc::array_unique($ratings));
4916
+ }
4917
+ }
4918
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
4919
+ {
4920
+ foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
4921
+ {
4922
+ $rating_scheme = null;
4923
+ $rating_value = null;
4924
+ if (isset($rating['attribs']['']['scheme']))
4925
+ {
4926
+ $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
4927
+ }
4928
+ else
4929
+ {
4930
+ $rating_scheme = 'urn:simple';
4931
+ }
4932
+ if (isset($rating['data']))
4933
+ {
4934
+ $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4935
+ }
4936
+ $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value);
4937
+ }
4938
+ if (is_array($ratings))
4939
+ {
4940
+ $ratings = array_values(SimplePie_Misc::array_unique($ratings));
4941
+ }
4942
+ }
4943
+ else
4944
+ {
4945
+ $ratings = $ratings_parent;
4946
+ }
4947
+
4948
+ // RESTRICTIONS
4949
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
4950
+ {
4951
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
4952
+ {
4953
+ $restriction_relationship = null;
4954
+ $restriction_type = null;
4955
+ $restriction_value = null;
4956
+ if (isset($restriction['attribs']['']['relationship']))
4957
+ {
4958
+ $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
4959
+ }
4960
+ if (isset($restriction['attribs']['']['type']))
4961
+ {
4962
+ $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4963
+ }
4964
+ if (isset($restriction['data']))
4965
+ {
4966
+ $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4967
+ }
4968
+ $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
4969
+ }
4970
+ if (is_array($restrictions))
4971
+ {
4972
+ $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
4973
+ }
4974
+ }
4975
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
4976
+ {
4977
+ foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
4978
+ {
4979
+ $restriction_relationship = null;
4980
+ $restriction_type = null;
4981
+ $restriction_value = null;
4982
+ if (isset($restriction['attribs']['']['relationship']))
4983
+ {
4984
+ $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
4985
+ }
4986
+ if (isset($restriction['attribs']['']['type']))
4987
+ {
4988
+ $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
4989
+ }
4990
+ if (isset($restriction['data']))
4991
+ {
4992
+ $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
4993
+ }
4994
+ $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
4995
+ }
4996
+ if (is_array($restrictions))
4997
+ {
4998
+ $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
4999
+ }
5000
+ }
5001
+ else
5002
+ {
5003
+ $restrictions = $restrictions_parent;
5004
+ }
5005
+
5006
+ // THUMBNAILS
5007
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
5008
+ {
5009
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
5010
+ {
5011
+ $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
5012
+ }
5013
+ if (is_array($thumbnails))
5014
+ {
5015
+ $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
5016
+ }
5017
+ }
5018
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
5019
+ {
5020
+ foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
5021
+ {
5022
+ $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
5023
+ }
5024
+ if (is_array($thumbnails))
5025
+ {
5026
+ $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
5027
+ }
5028
+ }
5029
+ else
5030
+ {
5031
+ $thumbnails = $thumbnails_parent;
5032
+ }
5033
+
5034
+ // TITLES
5035
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
5036
+ {
5037
+ $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5038
+ }
5039
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
5040
+ {
5041
+ $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5042
+ }
5043
+ else
5044
+ {
5045
+ $title = $title_parent;
5046
+ }
5047
+
5048
+ $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);
5049
+ }
5050
+ }
5051
+ }
5052
+ }
5053
+
5054
+ // If we have standalone media:content tags, loop through them.
5055
+ if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
5056
+ {
5057
+ foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
5058
+ {
5059
+ if (isset($content['attribs']['']['url']))
5060
+ {
5061
+ // Attributes
5062
+ $bitrate = null;
5063
+ $channels = null;
5064
+ $duration = null;
5065
+ $expression = null;
5066
+ $framerate = null;
5067
+ $height = null;
5068
+ $javascript = null;
5069
+ $lang = null;
5070
+ $length = null;
5071
+ $medium = null;
5072
+ $samplingrate = null;
5073
+ $type = null;
5074
+ $url = null;
5075
+ $width = null;
5076
+
5077
+ // Elements
5078
+ $captions = null;
5079
+ $categories = null;
5080
+ $copyrights = null;
5081
+ $credits = null;
5082
+ $description = null;
5083
+ $hashes = null;
5084
+ $keywords = null;
5085
+ $player = null;
5086
+ $ratings = null;
5087
+ $restrictions = null;
5088
+ $thumbnails = null;
5089
+ $title = null;
5090
+
5091
+ // Start checking the attributes of media:content
5092
+ if (isset($content['attribs']['']['bitrate']))
5093
+ {
5094
+ $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
5095
+ }
5096
+ if (isset($content['attribs']['']['channels']))
5097
+ {
5098
+ $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
5099
+ }
5100
+ if (isset($content['attribs']['']['duration']))
5101
+ {
5102
+ $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
5103
+ }
5104
+ else
5105
+ {
5106
+ $duration = $duration_parent;
5107
+ }
5108
+ if (isset($content['attribs']['']['expression']))
5109
+ {
5110
+ $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
5111
+ }
5112
+ if (isset($content['attribs']['']['framerate']))
5113
+ {
5114
+ $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
5115
+ }
5116
+ if (isset($content['attribs']['']['height']))
5117
+ {
5118
+ $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
5119
+ }
5120
+ if (isset($content['attribs']['']['lang']))
5121
+ {
5122
+ $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
5123
+ }
5124
+ if (isset($content['attribs']['']['fileSize']))
5125
+ {
5126
+ $length = ceil($content['attribs']['']['fileSize']);
5127
+ }
5128
+ if (isset($content['attribs']['']['medium']))
5129
+ {
5130
+ $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
5131
+ }
5132
+ if (isset($content['attribs']['']['samplingrate']))
5133
+ {
5134
+ $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
5135
+ }
5136
+ if (isset($content['attribs']['']['type']))
5137
+ {
5138
+ $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
5139
+ }
5140
+ if (isset($content['attribs']['']['width']))
5141
+ {
5142
+ $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
5143
+ }
5144
+ $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
5145
+
5146
+ // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
5147
+
5148
+ // CAPTIONS
5149
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
5150
+ {
5151
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
5152
+ {
5153
+ $caption_type = null;
5154
+ $caption_lang = null;
5155
+ $caption_startTime = null;
5156
+ $caption_endTime = null;
5157
+ $caption_text = null;
5158
+ if (isset($caption['attribs']['']['type']))
5159
+ {
5160
+ $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
5161
+ }
5162
+ if (isset($caption['attribs']['']['lang']))
5163
+ {
5164
+ $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
5165
+ }
5166
+ if (isset($caption['attribs']['']['start']))
5167
+ {
5168
+ $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
5169
+ }
5170
+ if (isset($caption['attribs']['']['end']))
5171
+ {
5172
+ $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
5173
+ }
5174
+ if (isset($caption['data']))
5175
+ {
5176
+ $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5177
+ }
5178
+ $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
5179
+ }
5180
+ if (is_array($captions))
5181
+ {
5182
+ $captions = array_values(SimplePie_Misc::array_unique($captions));
5183
+ }
5184
+ }
5185
+ else
5186
+ {
5187
+ $captions = $captions_parent;
5188
+ }
5189
+
5190
+ // CATEGORIES
5191
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
5192
+ {
5193
+ foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
5194
+ {
5195
+ $term = null;
5196
+ $scheme = null;
5197
+ $label = null;
5198
+ if (isset($category['data']))
5199
+ {
5200
+ $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5201
+ }
5202
+ if (isset($category['attribs']['']['scheme']))
5203
+ {
5204
+ $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
5205
+ }
5206
+ else
5207
+ {
5208
+ $scheme = 'http://search.yahoo.com/mrss/category_schema';
5209
+ }
5210
+ if (isset($category['attribs']['']['label']))
5211
+ {
5212
+ $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
5213
+ }
5214
+ $categories[] = new $this->feed->category_class($term, $scheme, $label);
5215
+ }
5216
+ }
5217
+ if (is_array($categories) && is_array($categories_parent))
5218
+ {
5219
+ $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent)));
5220
+ }
5221
+ elseif (is_array($categories))
5222
+ {
5223
+ $categories = array_values(SimplePie_Misc::array_unique($categories));
5224
+ }
5225
+ elseif (is_array($categories_parent))
5226
+ {
5227
+ $categories = array_values(SimplePie_Misc::array_unique($categories_parent));
5228
+ }
5229
+ else
5230
+ {
5231
+ $categories = null;
5232
+ }
5233
+
5234
+ // COPYRIGHTS
5235
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
5236
+ {
5237
+ $copyright_url = null;
5238
+ $copyright_label = null;
5239
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
5240
+ {
5241
+ $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
5242
+ }
5243
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
5244
+ {
5245
+ $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5246
+ }
5247
+ $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label);
5248
+ }
5249
+ else
5250
+ {
5251
+ $copyrights = $copyrights_parent;
5252
+ }
5253
+
5254
+ // CREDITS
5255
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
5256
+ {
5257
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
5258
+ {
5259
+ $credit_role = null;
5260
+ $credit_scheme = null;
5261
+ $credit_name = null;
5262
+ if (isset($credit['attribs']['']['role']))
5263
+ {
5264
+ $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
5265
+ }
5266
+ if (isset($credit['attribs']['']['scheme']))
5267
+ {
5268
+ $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
5269
+ }
5270
+ else
5271
+ {
5272
+ $credit_scheme = 'urn:ebu';
5273
+ }
5274
+ if (isset($credit['data']))
5275
+ {
5276
+ $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5277
+ }
5278
+ $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
5279
+ }
5280
+ if (is_array($credits))
5281
+ {
5282
+ $credits = array_values(SimplePie_Misc::array_unique($credits));
5283
+ }
5284
+ }
5285
+ else
5286
+ {
5287
+ $credits = $credits_parent;
5288
+ }
5289
+
5290
+ // DESCRIPTION
5291
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
5292
+ {
5293
+ $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5294
+ }
5295
+ else
5296
+ {
5297
+ $description = $description_parent;
5298
+ }
5299
+
5300
+ // HASHES
5301
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
5302
+ {
5303
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
5304
+ {
5305
+ $value = null;
5306
+ $algo = null;
5307
+ if (isset($hash['data']))
5308
+ {
5309
+ $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5310
+ }
5311
+ if (isset($hash['attribs']['']['algo']))
5312
+ {
5313
+ $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
5314
+ }
5315
+ else
5316
+ {
5317
+ $algo = 'md5';
5318
+ }
5319
+ $hashes[] = $algo.':'.$value;
5320
+ }
5321
+ if (is_array($hashes))
5322
+ {
5323
+ $hashes = array_values(SimplePie_Misc::array_unique($hashes));
5324
+ }
5325
+ }
5326
+ else
5327
+ {
5328
+ $hashes = $hashes_parent;
5329
+ }
5330
+
5331
+ // KEYWORDS
5332
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
5333
+ {
5334
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
5335
+ {
5336
+ $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
5337
+ foreach ($temp as $word)
5338
+ {
5339
+ $keywords[] = trim($word);
5340
+ }
5341
+ unset($temp);
5342
+ }
5343
+ if (is_array($keywords))
5344
+ {
5345
+ $keywords = array_values(SimplePie_Misc::array_unique($keywords));
5346
+ }
5347
+ }
5348
+ else
5349
+ {
5350
+ $keywords = $keywords_parent;
5351
+ }
5352
+
5353
+ // PLAYER
5354
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
5355
+ {
5356
+ $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
5357
+ }
5358
+ else
5359
+ {
5360
+ $player = $player_parent;
5361
+ }
5362
+
5363
+ // RATINGS
5364
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
5365
+ {
5366
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
5367
+ {
5368
+ $rating_scheme = null;
5369
+ $rating_value = null;
5370
+ if (isset($rating['attribs']['']['scheme']))
5371
+ {
5372
+ $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
5373
+ }
5374
+ else
5375
+ {
5376
+ $rating_scheme = 'urn:simple';
5377
+ }
5378
+ if (isset($rating['data']))
5379
+ {
5380
+ $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5381
+ }
5382
+ $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value);
5383
+ }
5384
+ if (is_array($ratings))
5385
+ {
5386
+ $ratings = array_values(SimplePie_Misc::array_unique($ratings));
5387
+ }
5388
+ }
5389
+ else
5390
+ {
5391
+ $ratings = $ratings_parent;
5392
+ }
5393
+
5394
+ // RESTRICTIONS
5395
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
5396
+ {
5397
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
5398
+ {
5399
+ $restriction_relationship = null;
5400
+ $restriction_type = null;
5401
+ $restriction_value = null;
5402
+ if (isset($restriction['attribs']['']['relationship']))
5403
+ {
5404
+ $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
5405
+ }
5406
+ if (isset($restriction['attribs']['']['type']))
5407
+ {
5408
+ $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
5409
+ }
5410
+ if (isset($restriction['data']))
5411
+ {
5412
+ $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5413
+ }
5414
+ $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
5415
+ }
5416
+ if (is_array($restrictions))
5417
+ {
5418
+ $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
5419
+ }
5420
+ }
5421
+ else
5422
+ {
5423
+ $restrictions = $restrictions_parent;
5424
+ }
5425
+
5426
+ // THUMBNAILS
5427
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
5428
+ {
5429
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
5430
+ {
5431
+ $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
5432
+ }
5433
+ if (is_array($thumbnails))
5434
+ {
5435
+ $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
5436
+ }
5437
+ }
5438
+ else
5439
+ {
5440
+ $thumbnails = $thumbnails_parent;
5441
+ }
5442
+
5443
+ // TITLES
5444
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
5445
+ {
5446
+ $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5447
+ }
5448
+ else
5449
+ {
5450
+ $title = $title_parent;
5451
+ }
5452
+
5453
+ $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);
5454
+ }
5455
+ }
5456
+ }
5457
+
5458
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link)
5459
+ {
5460
+ if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure')
5461
+ {
5462
+ // Attributes
5463
+ $bitrate = null;
5464
+ $channels = null;
5465
+ $duration = null;
5466
+ $expression = null;
5467
+ $framerate = null;
5468
+ $height = null;
5469
+ $javascript = null;
5470
+ $lang = null;
5471
+ $length = null;
5472
+ $medium = null;
5473
+ $samplingrate = null;
5474
+ $type = null;
5475
+ $url = null;
5476
+ $width = null;
5477
+
5478
+ $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
5479
+ if (isset($link['attribs']['']['type']))
5480
+ {
5481
+ $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
5482
+ }
5483
+ if (isset($link['attribs']['']['length']))
5484
+ {
5485
+ $length = ceil($link['attribs']['']['length']);
5486
+ }
5487
+
5488
+ // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
5489
+ $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width);
5490
+ }
5491
+ }
5492
+
5493
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link)
5494
+ {
5495
+ if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure')
5496
+ {
5497
+ // Attributes
5498
+ $bitrate = null;
5499
+ $channels = null;
5500
+ $duration = null;
5501
+ $expression = null;
5502
+ $framerate = null;
5503
+ $height = null;
5504
+ $javascript = null;
5505
+ $lang = null;
5506
+ $length = null;
5507
+ $medium = null;
5508
+ $samplingrate = null;
5509
+ $type = null;
5510
+ $url = null;
5511
+ $width = null;
5512
+
5513
+ $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
5514
+ if (isset($link['attribs']['']['type']))
5515
+ {
5516
+ $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
5517
+ }
5518
+ if (isset($link['attribs']['']['length']))
5519
+ {
5520
+ $length = ceil($link['attribs']['']['length']);
5521
+ }
5522
+
5523
+ // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
5524
+ $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width);
5525
+ }
5526
+ }
5527
+
5528
+ if ($enclosure = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure'))
5529
+ {
5530
+ if (isset($enclosure[0]['attribs']['']['url']))
5531
+ {
5532
+ // Attributes
5533
+ $bitrate = null;
5534
+ $channels = null;
5535
+ $duration = null;
5536
+ $expression = null;
5537
+ $framerate = null;
5538
+ $height = null;
5539
+ $javascript = null;
5540
+ $lang = null;
5541
+ $length = null;
5542
+ $medium = null;
5543
+ $samplingrate = null;
5544
+ $type = null;
5545
+ $url = null;
5546
+ $width = null;
5547
+
5548
+ $url = $this->sanitize($enclosure[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($enclosure[0]));
5549
+ if (isset($enclosure[0]['attribs']['']['type']))
5550
+ {
5551
+ $type = $this->sanitize($enclosure[0]['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
5552
+ }
5553
+ if (isset($enclosure[0]['attribs']['']['length']))
5554
+ {
5555
+ $length = ceil($enclosure[0]['attribs']['']['length']);
5556
+ }
5557
+
5558
+ // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
5559
+ $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width);
5560
+ }
5561
+ }
5562
+
5563
+ if (sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width))
5564
+ {
5565
+ // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
5566
+ $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width);
5567
+ }
5568
+
5569
+ $this->data['enclosures'] = array_values(SimplePie_Misc::array_unique($this->data['enclosures']));
5570
+ }
5571
+ if (!empty($this->data['enclosures']))
5572
+ {
5573
+ return $this->data['enclosures'];
5574
+ }
5575
+ else
5576
+ {
5577
+ return null;
5578
+ }
5579
+ }
5580
+
5581
+ function get_latitude()
5582
+ {
5583
+ if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
5584
+ {
5585
+ return (float) $return[0]['data'];
5586
+ }
5587
+ 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))
5588
+ {
5589
+ return (float) $match[1];
5590
+ }
5591
+ else
5592
+ {
5593
+ return null;
5594
+ }
5595
+ }
5596
+
5597
+ function get_longitude()
5598
+ {
5599
+ if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
5600
+ {
5601
+ return (float) $return[0]['data'];
5602
+ }
5603
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
5604
+ {
5605
+ return (float) $return[0]['data'];
5606
+ }
5607
+ 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))
5608
+ {
5609
+ return (float) $match[2];
5610
+ }
5611
+ else
5612
+ {
5613
+ return null;
5614
+ }
5615
+ }
5616
+
5617
+ function get_source()
5618
+ {
5619
+ if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source'))
5620
+ {
5621
+ return new $this->feed->source_class($this, $return[0]);
5622
+ }
5623
+ else
5624
+ {
5625
+ return null;
5626
+ }
5627
+ }
5628
+
5629
+ /**
5630
+ * Creates the add_to_* methods' return data
5631
+ *
5632
+ * @access private
5633
+ * @param string $item_url String to prefix to the item permalink
5634
+ * @param string $title_url String to prefix to the item title
5635
+ * (and suffix to the item permalink)
5636
+ * @return mixed URL if feed exists, false otherwise
5637
+ */
5638
+ function add_to_service($item_url, $title_url = null, $summary_url = null)
5639
+ {
5640
+ if ($this->get_permalink() !== null)
5641
+ {
5642
+ $return = $item_url . rawurlencode($this->get_permalink());
5643
+ if ($title_url !== null && $this->get_title() !== null)
5644
+ {
5645
+ $return .= $title_url . rawurlencode($this->get_title());
5646
+ }
5647
+ if ($summary_url !== null && $this->get_description() !== null)
5648
+ {
5649
+ $return .= $summary_url . rawurlencode($this->get_description());
5650
+ }
5651
+ return $this->sanitize($return, SIMPLEPIE_CONSTRUCT_IRI);
5652
+ }
5653
+ else
5654
+ {
5655
+ return null;
5656
+ }
5657
+ }
5658
+
5659
+ function add_to_blinklist()
5660
+ {
5661
+ return $this->add_to_service('http://www.blinklist.com/index.php?Action=Blink/addblink.php&Description=&Url=', '&Title=');
5662
+ }
5663
+
5664
+ function add_to_blogmarks()
5665
+ {
5666
+ return $this->add_to_service('http://blogmarks.net/my/new.php?mini=1&simple=1&url=', '&title=');
5667
+ }
5668
+
5669
+ function add_to_delicious()
5670
+ {
5671
+ return $this->add_to_service('http://del.icio.us/post/?v=4&url=', '&title=');
5672
+ }
5673
+
5674
+ function add_to_digg()
5675
+ {
5676
+ return $this->add_to_service('http://digg.com/submit?url=', '&title=', '&bodytext=');
5677
+ }
5678
+
5679
+ function add_to_furl()
5680
+ {
5681
+ return $this->add_to_service('http://www.furl.net/storeIt.jsp?u=', '&t=');
5682
+ }
5683
+
5684
+ function add_to_magnolia()
5685
+ {
5686
+ return $this->add_to_service('http://ma.gnolia.com/bookmarklet/add?url=', '&title=');
5687
+ }
5688
+
5689
+ function add_to_myweb20()
5690
+ {
5691
+ return $this->add_to_service('http://myweb2.search.yahoo.com/myresults/bookmarklet?u=', '&t=');
5692
+ }
5693
+
5694
+ function add_to_newsvine()
5695
+ {
5696
+ return $this->add_to_service('http://www.newsvine.com/_wine/save?u=', '&h=');
5697
+ }
5698
+
5699
+ function add_to_reddit()
5700
+ {
5701
+ return $this->add_to_service('http://reddit.com/submit?url=', '&title=');
5702
+ }
5703
+
5704
+ function add_to_segnalo()
5705
+ {
5706
+ return $this->add_to_service('http://segnalo.com/post.html.php?url=', '&title=');
5707
+ }
5708
+
5709
+ function add_to_simpy()
5710
+ {
5711
+ return $this->add_to_service('http://www.simpy.com/simpy/LinkAdd.do?href=', '&title=');
5712
+ }
5713
+
5714
+ function add_to_spurl()
5715
+ {
5716
+ return $this->add_to_service('http://www.spurl.net/spurl.php?v=3&url=', '&title=');
5717
+ }
5718
+
5719
+ function add_to_wists()
5720
+ {
5721
+ return $this->add_to_service('http://wists.com/r.php?c=&r=', '&title=');
5722
+ }
5723
+
5724
+ function search_technorati()
5725
+ {
5726
+ return $this->add_to_service('http://www.technorati.com/search/');
5727
+ }
5728
+ }
5729
+
5730
+ class SimplePie_Source
5731
+ {
5732
+ var $item;
5733
+ var $data = array();
5734
+
5735
+ function SimplePie_Source($item, $data)
5736
+ {
5737
+ $this->item = $item;
5738
+ $this->data = $data;
5739
+ }
5740
+
5741
+ function __toString()
5742
+ {
5743
+ return md5(serialize($this->data));
5744
+ }
5745
+
5746
+ function get_source_tags($namespace, $tag)
5747
+ {
5748
+ if (isset($this->data['child'][$namespace][$tag]))
5749
+ {
5750
+ return $this->data['child'][$namespace][$tag];
5751
+ }
5752
+ else
5753
+ {
5754
+ return null;
5755
+ }
5756
+ }
5757
+
5758
+ function get_base($element = array())
5759
+ {
5760
+ return $this->item->get_base($element);
5761
+ }
5762
+
5763
+ function sanitize($data, $type, $base = '')
5764
+ {
5765
+ return $this->item->sanitize($data, $type, $base);
5766
+ }
5767
+
5768
+ function get_item()
5769
+ {
5770
+ return $this->item;
5771
+ }
5772
+
5773
+ function get_title()
5774
+ {
5775
+ if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
5776
+ {
5777
+ return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
5778
+ }
5779
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
5780
+ {
5781
+ return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
5782
+ }
5783
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
5784
+ {
5785
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
5786
+ }
5787
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
5788
+ {
5789
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
5790
+ }
5791
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
5792
+ {
5793
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
5794
+ }
5795
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
5796
+ {
5797
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5798
+ }
5799
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
5800
+ {
5801
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5802
+ }
5803
+ else
5804
+ {
5805
+ return null;
5806
+ }
5807
+ }
5808
+
5809
+ function get_category($key = 0)
5810
+ {
5811
+ $categories = $this->get_categories();
5812
+ if (isset($categories[$key]))
5813
+ {
5814
+ return $categories[$key];
5815
+ }
5816
+ else
5817
+ {
5818
+ return null;
5819
+ }
5820
+ }
5821
+
5822
+ function get_categories()
5823
+ {
5824
+ $categories = array();
5825
+
5826
+ foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
5827
+ {
5828
+ $term = null;
5829
+ $scheme = null;
5830
+ $label = null;
5831
+ if (isset($category['attribs']['']['term']))
5832
+ {
5833
+ $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
5834
+ }
5835
+ if (isset($category['attribs']['']['scheme']))
5836
+ {
5837
+ $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
5838
+ }
5839
+ if (isset($category['attribs']['']['label']))
5840
+ {
5841
+ $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
5842
+ }
5843
+ $categories[] = new $this->item->feed->category_class($term, $scheme, $label);
5844
+ }
5845
+ foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
5846
+ {
5847
+ // This is really the label, but keep this as the term also for BC.
5848
+ // Label will also work on retrieving because that falls back to term.
5849
+ $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5850
+ if (isset($category['attribs']['']['domain']))
5851
+ {
5852
+ $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
5853
+ }
5854
+ else
5855
+ {
5856
+ $scheme = null;
5857
+ }
5858
+ $categories[] = new $this->item->feed->category_class($term, $scheme, null);
5859
+ }
5860
+ foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
5861
+ {
5862
+ $categories[] = new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
5863
+ }
5864
+ foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
5865
+ {
5866
+ $categories[] = new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
5867
+ }
5868
+
5869
+ if (!empty($categories))
5870
+ {
5871
+ return SimplePie_Misc::array_unique($categories);
5872
+ }
5873
+ else
5874
+ {
5875
+ return null;
5876
+ }
5877
+ }
5878
+
5879
+ function get_author($key = 0)
5880
+ {
5881
+ $authors = $this->get_authors();
5882
+ if (isset($authors[$key]))
5883
+ {
5884
+ return $authors[$key];
5885
+ }
5886
+ else
5887
+ {
5888
+ return null;
5889
+ }
5890
+ }
5891
+
5892
+ function get_authors()
5893
+ {
5894
+ $authors = array();
5895
+ foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
5896
+ {
5897
+ $name = null;
5898
+ $uri = null;
5899
+ $email = null;
5900
+ if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
5901
+ {
5902
+ $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5903
+ }
5904
+ if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
5905
+ {
5906
+ $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
5907
+ }
5908
+ if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
5909
+ {
5910
+ $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5911
+ }
5912
+ if ($name !== null || $email !== null || $uri !== null)
5913
+ {
5914
+ $authors[] = new $this->item->feed->author_class($name, $uri, $email);
5915
+ }
5916
+ }
5917
+ if ($author = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
5918
+ {
5919
+ $name = null;
5920
+ $url = null;
5921
+ $email = null;
5922
+ if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
5923
+ {
5924
+ $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5925
+ }
5926
+ if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
5927
+ {
5928
+ $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
5929
+ }
5930
+ if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
5931
+ {
5932
+ $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5933
+ }
5934
+ if ($name !== null || $email !== null || $url !== null)
5935
+ {
5936
+ $authors[] = new $this->item->feed->author_class($name, $url, $email);
5937
+ }
5938
+ }
5939
+ foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
5940
+ {
5941
+ $authors[] = new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
5942
+ }
5943
+ foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
5944
+ {
5945
+ $authors[] = new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
5946
+ }
5947
+ foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
5948
+ {
5949
+ $authors[] = new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
5950
+ }
5951
+
5952
+ if (!empty($authors))
5953
+ {
5954
+ return SimplePie_Misc::array_unique($authors);
5955
+ }
5956
+ else
5957
+ {
5958
+ return null;
5959
+ }
5960
+ }
5961
+
5962
+ function get_contributor($key = 0)
5963
+ {
5964
+ $contributors = $this->get_contributors();
5965
+ if (isset($contributors[$key]))
5966
+ {
5967
+ return $contributors[$key];
5968
+ }
5969
+ else
5970
+ {
5971
+ return null;
5972
+ }
5973
+ }
5974
+
5975
+ function get_contributors()
5976
+ {
5977
+ $contributors = array();
5978
+ foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
5979
+ {
5980
+ $name = null;
5981
+ $uri = null;
5982
+ $email = null;
5983
+ if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
5984
+ {
5985
+ $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5986
+ }
5987
+ if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
5988
+ {
5989
+ $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
5990
+ }
5991
+ if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
5992
+ {
5993
+ $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
5994
+ }
5995
+ if ($name !== null || $email !== null || $uri !== null)
5996
+ {
5997
+ $contributors[] = new $this->item->feed->author_class($name, $uri, $email);
5998
+ }
5999
+ }
6000
+ foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
6001
+ {
6002
+ $name = null;
6003
+ $url = null;
6004
+ $email = null;
6005
+ if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
6006
+ {
6007
+ $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6008
+ }
6009
+ if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
6010
+ {
6011
+ $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
6012
+ }
6013
+ if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
6014
+ {
6015
+ $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6016
+ }
6017
+ if ($name !== null || $email !== null || $url !== null)
6018
+ {
6019
+ $contributors[] = new $this->item->feed->author_class($name, $url, $email);
6020
+ }
6021
+ }
6022
+
6023
+ if (!empty($contributors))
6024
+ {
6025
+ return SimplePie_Misc::array_unique($contributors);
6026
+ }
6027
+ else
6028
+ {
6029
+ return null;
6030
+ }
6031
+ }
6032
+
6033
+ function get_link($key = 0, $rel = 'alternate')
6034
+ {
6035
+ $links = $this->get_links($rel);
6036
+ if (isset($links[$key]))
6037
+ {
6038
+ return $links[$key];
6039
+ }
6040
+ else
6041
+ {
6042
+ return null;
6043
+ }
6044
+ }
6045
+
6046
+ /**
6047
+ * Added for parity between the parent-level and the item/entry-level.
6048
+ */
6049
+ function get_permalink()
6050
+ {
6051
+ return $this->get_link(0);
6052
+ }
6053
+
6054
+ function get_links($rel = 'alternate')
6055
+ {
6056
+ if (!isset($this->data['links']))
6057
+ {
6058
+ $this->data['links'] = array();
6059
+ if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link'))
6060
+ {
6061
+ foreach ($links as $link)
6062
+ {
6063
+ if (isset($link['attribs']['']['href']))
6064
+ {
6065
+ $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
6066
+ $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
6067
+ }
6068
+ }
6069
+ }
6070
+ if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link'))
6071
+ {
6072
+ foreach ($links as $link)
6073
+ {
6074
+ if (isset($link['attribs']['']['href']))
6075
+ {
6076
+ $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
6077
+ $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
6078
+
6079
+ }
6080
+ }
6081
+ }
6082
+ if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
6083
+ {
6084
+ $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
6085
+ }
6086
+ if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
6087
+ {
6088
+ $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
6089
+ }
6090
+ if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
6091
+ {
6092
+ $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
6093
+ }
6094
+
6095
+ $keys = array_keys($this->data['links']);
6096
+ foreach ($keys as $key)
6097
+ {
6098
+ if (SimplePie_Misc::is_isegment_nz_nc($key))
6099
+ {
6100
+ if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
6101
+ {
6102
+ $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
6103
+ $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
6104
+ }
6105
+ else
6106
+ {
6107
+ $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
6108
+ }
6109
+ }
6110
+ elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
6111
+ {
6112
+ $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
6113
+ }
6114
+ $this->data['links'][$key] = array_unique($this->data['links'][$key]);
6115
+ }
6116
+ }
6117
+
6118
+ if (isset($this->data['links'][$rel]))
6119
+ {
6120
+ return $this->data['links'][$rel];
6121
+ }
6122
+ else
6123
+ {
6124
+ return null;
6125
+ }
6126
+ }
6127
+
6128
+ function get_description()
6129
+ {
6130
+ if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle'))
6131
+ {
6132
+ return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
6133
+ }
6134
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline'))
6135
+ {
6136
+ return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
6137
+ }
6138
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
6139
+ {
6140
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
6141
+ }
6142
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
6143
+ {
6144
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
6145
+ }
6146
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
6147
+ {
6148
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
6149
+ }
6150
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
6151
+ {
6152
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6153
+ }
6154
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
6155
+ {
6156
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6157
+ }
6158
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
6159
+ {
6160
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
6161
+ }
6162
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
6163
+ {
6164
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
6165
+ }
6166
+ else
6167
+ {
6168
+ return null;
6169
+ }
6170
+ }
6171
+
6172
+ function get_copyright()
6173
+ {
6174
+ if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
6175
+ {
6176
+ return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
6177
+ }
6178
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright'))
6179
+ {
6180
+ return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
6181
+ }
6182
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright'))
6183
+ {
6184
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6185
+ }
6186
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
6187
+ {
6188
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6189
+ }
6190
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
6191
+ {
6192
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6193
+ }
6194
+ else
6195
+ {
6196
+ return null;
6197
+ }
6198
+ }
6199
+
6200
+ function get_language()
6201
+ {
6202
+ if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language'))
6203
+ {
6204
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6205
+ }
6206
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language'))
6207
+ {
6208
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6209
+ }
6210
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language'))
6211
+ {
6212
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
6213
+ }
6214
+ elseif (isset($this->data['xml_lang']))
6215
+ {
6216
+ return $this->sanitize($this->data['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
6217
+ }
6218
+ else
6219
+ {
6220
+ return null;
6221
+ }
6222
+ }
6223
+
6224
+ function get_latitude()
6225
+ {
6226
+ if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
6227
+ {
6228
+ return (float) $return[0]['data'];
6229
+ }
6230
+ 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))
6231
+ {
6232
+ return (float) $match[1];
6233
+ }
6234
+ else
6235
+ {
6236
+ return null;
6237
+ }
6238
+ }
6239
+
6240
+ function get_longitude()
6241
+ {
6242
+ if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
6243
+ {
6244
+ return (float) $return[0]['data'];
6245
+ }
6246
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
6247
+ {
6248
+ return (float) $return[0]['data'];
6249
+ }
6250
+ 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))
6251
+ {
6252
+ return (float) $match[2];
6253
+ }
6254
+ else
6255
+ {
6256
+ return null;
6257
+ }
6258
+ }
6259
+
6260
+ function get_image_url()
6261
+ {
6262
+ if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image'))
6263
+ {
6264
+ return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI);
6265
+ }
6266
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo'))
6267
+ {
6268
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
6269
+ }
6270
+ elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
6271
+ {
6272
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
6273
+ }
6274
+ else
6275
+ {
6276
+ return null;
6277
+ }
6278
+ }
6279
+ }
6280
+
6281
+ class SimplePie_Author
6282
+ {
6283
+ var $name;
6284
+ var $link;
6285
+ var $email;
6286
+
6287
+ // Constructor, used to input the data
6288
+ function SimplePie_Author($name = null, $link = null, $email = null)
6289
+ {
6290
+ $this->name = $name;
6291
+ $this->link = $link;
6292
+ $this->email = $email;
6293
+ }
6294
+
6295
+ function __toString()
6296
+ {
6297
+ // There is no $this->data here
6298
+ return md5(serialize($this));
6299
+ }
6300
+
6301
+ function get_name()
6302
+ {
6303
+ if ($this->name !== null)
6304
+ {
6305
+ return $this->name;
6306
+ }
6307
+ else
6308
+ {
6309
+ return null;
6310
+ }
6311
+ }
6312
+
6313
+ function get_link()
6314
+ {
6315
+ if ($this->link !== null)
6316
+ {
6317
+ return $this->link;
6318
+ }
6319
+ else
6320
+ {
6321
+ return null;
6322
+ }
6323
+ }
6324
+
6325
+ function get_email()
6326
+ {
6327
+ if ($this->email !== null)
6328
+ {
6329
+ return $this->email;
6330
+ }
6331
+ else
6332
+ {
6333
+ return null;
6334
+ }
6335
+ }
6336
+ }
6337
+
6338
+ class SimplePie_Category
6339
+ {
6340
+ var $term;
6341
+ var $scheme;
6342
+ var $label;
6343
+
6344
+ // Constructor, used to input the data
6345
+ function SimplePie_Category($term = null, $scheme = null, $label = null)
6346
+ {
6347
+ $this->term = $term;
6348
+ $this->scheme = $scheme;
6349
+ $this->label = $label;
6350
+ }
6351
+
6352
+ function __toString()
6353
+ {
6354
+ // There is no $this->data here
6355
+ return md5(serialize($this));
6356
+ }
6357
+
6358
+ function get_term()
6359
+ {
6360
+ if ($this->term !== null)
6361
+ {
6362
+ return $this->term;
6363
+ }
6364
+ else
6365
+ {
6366
+ return null;
6367
+ }
6368
+ }
6369
+
6370
+ function get_scheme()
6371
+ {
6372
+ if ($this->scheme !== null)
6373
+ {
6374
+ return $this->scheme;
6375
+ }
6376
+ else
6377
+ {
6378
+ return null;
6379
+ }
6380
+ }
6381
+
6382
+ function get_label()
6383
+ {
6384
+ if ($this->label !== null)
6385
+ {
6386
+ return $this->label;
6387
+ }
6388
+ else
6389
+ {
6390
+ return $this->get_term();
6391
+ }
6392
+ }
6393
+ }
6394
+
6395
+ class SimplePie_Enclosure
6396
+ {
6397
+ var $bitrate;
6398
+ var $captions;
6399
+ var $categories;
6400
+ var $channels;
6401
+ var $copyright;
6402
+ var $credits;
6403
+ var $description;
6404
+ var $duration;
6405
+ var $expression;
6406
+ var $framerate;
6407
+ var $handler;
6408
+ var $hashes;
6409
+ var $height;
6410
+ var $javascript;
6411
+ var $keywords;
6412
+ var $lang;
6413
+ var $length;
6414
+ var $link;
6415
+ var $medium;
6416
+ var $player;
6417
+ var $ratings;
6418
+ var $restrictions;
6419
+ var $samplingrate;
6420
+ var $thumbnails;
6421
+ var $title;
6422
+ var $type;
6423
+ var $width;
6424
+
6425
+ // Constructor, used to input the data
6426
+ function SimplePie_Enclosure($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null)
6427
+ {
6428
+ $this->bitrate = $bitrate;
6429
+ $this->captions = $captions;
6430
+ $this->categories = $categories;
6431
+ $this->channels = $channels;
6432
+ $this->copyright = $copyright;
6433
+ $this->credits = $credits;
6434
+ $this->description = $description;
6435
+ $this->duration = $duration;
6436
+ $this->expression = $expression;
6437
+ $this->framerate = $framerate;
6438
+ $this->hashes = $hashes;
6439
+ $this->height = $height;
6440
+ $this->javascript = $javascript;
6441
+ $this->keywords = $keywords;
6442
+ $this->lang = $lang;
6443
+ $this->length = $length;
6444
+ $this->link = $link;
6445
+ $this->medium = $medium;
6446
+ $this->player = $player;
6447
+ $this->ratings = $ratings;
6448
+ $this->restrictions = $restrictions;
6449
+ $this->samplingrate = $samplingrate;
6450
+ $this->thumbnails = $thumbnails;
6451
+ $this->title = $title;
6452
+ $this->type = $type;
6453
+ $this->width = $width;
6454
+ if (class_exists('idna_convert'))
6455
+ {
6456
+ $idn = new idna_convert;
6457
+ $parsed = SimplePie_Misc::parse_url($link);
6458
+ $this->link = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
6459
+ }
6460
+ $this->handler = $this->get_handler(); // Needs to load last
6461
+ }
6462
+
6463
+ function __toString()
6464
+ {
6465
+ // There is no $this->data here
6466
+ return md5(serialize($this));
6467
+ }
6468
+
6469
+ function get_bitrate()
6470
+ {
6471
+ if ($this->bitrate !== null)
6472
+ {
6473
+ return $this->bitrate;
6474
+ }
6475
+ else
6476
+ {
6477
+ return null;
6478
+ }
6479
+ }
6480
+
6481
+ function get_caption($key = 0)
6482
+ {
6483
+ $captions = $this->get_captions();
6484
+ if (isset($captions[$key]))
6485
+ {
6486
+ return $captions[$key];
6487
+ }
6488
+ else
6489
+ {
6490
+ return null;
6491
+ }
6492
+ }
6493
+
6494
+ function get_captions()
6495
+ {
6496
+ if ($this->captions !== null)
6497
+ {
6498
+ return $this->captions;
6499
+ }
6500
+ else
6501
+ {
6502
+ return null;
6503
+ }
6504
+ }
6505
+
6506
+ function get_category($key = 0)
6507
+ {
6508
+ $categories = $this->get_categories();
6509
+ if (isset($categories[$key]))
6510
+ {
6511
+ return $categories[$key];
6512
+ }
6513
+ else
6514
+ {
6515
+ return null;
6516
+ }
6517
+ }
6518
+
6519
+ function get_categories()
6520
+ {
6521
+ if ($this->categories !== null)
6522
+ {
6523
+ return $this->categories;
6524
+ }
6525
+ else
6526
+ {
6527
+ return null;
6528
+ }
6529
+ }
6530
+
6531
+ function get_channels()
6532
+ {
6533
+ if ($this->channels !== null)
6534
+ {
6535
+ return $this->channels;
6536
+ }
6537
+ else
6538
+ {
6539
+ return null;
6540
+ }
6541
+ }
6542
+
6543
+ function get_copyright()
6544
+ {
6545
+ if ($this->copyright !== null)
6546
+ {
6547
+ return $this->copyright;
6548
+ }
6549
+ else
6550
+ {
6551
+ return null;
6552
+ }
6553
+ }
6554
+
6555
+ function get_credit($key = 0)
6556
+ {
6557
+ $credits = $this->get_credits();
6558
+ if (isset($credits[$key]))
6559
+ {
6560
+ return $credits[$key];
6561
+ }
6562
+ else
6563
+ {
6564
+ return null;
6565
+ }
6566
+ }
6567
+
6568
+ function get_credits()
6569
+ {
6570
+ if ($this->credits !== null)
6571
+ {
6572
+ return $this->credits;
6573
+ }
6574
+ else
6575
+ {
6576
+ return null;
6577
+ }
6578
+ }
6579
+
6580
+ function get_description()
6581
+ {
6582
+ if ($this->description !== null)
6583
+ {
6584
+ return $this->description;
6585
+ }
6586
+ else
6587
+ {
6588
+ return null;
6589
+ }
6590
+ }
6591
+
6592
+ function get_duration($convert = false)
6593
+ {
6594
+ if ($this->duration !== null)
6595
+ {
6596
+ if ($convert)
6597
+ {
6598
+ $time = SimplePie_Misc::time_hms($this->duration);
6599
+ return $time;
6600
+ }
6601
+ else
6602
+ {
6603
+ return $this->duration;
6604
+ }
6605
+ }
6606
+ else
6607
+ {
6608
+ return null;
6609
+ }
6610
+ }
6611
+
6612
+ function get_expression()
6613
+ {
6614
+ if ($this->expression !== null)
6615
+ {
6616
+ return $this->expression;
6617
+ }
6618
+ else
6619
+ {
6620
+ return 'full';
6621
+ }
6622
+ }
6623
+
6624
+ function get_extension()
6625
+ {
6626
+ if ($this->link !== null)
6627
+ {
6628
+ $url = SimplePie_Misc::parse_url($this->link);
6629
+ if ($url['path'] !== '')
6630
+ {
6631
+ return pathinfo($url['path'], PATHINFO_EXTENSION);
6632
+ }
6633
+ }
6634
+ return null;
6635
+ }
6636
+
6637
+ function get_framerate()
6638
+ {
6639
+ if ($this->framerate !== null)
6640
+ {
6641
+ return $this->framerate;
6642
+ }
6643
+ else
6644
+ {
6645
+ return null;
6646
+ }
6647
+ }
6648
+
6649
+ function get_handler()
6650
+ {
6651
+ return $this->get_real_type(true);
6652
+ }
6653
+
6654
+ function get_hash($key = 0)
6655
+ {
6656
+ $hashes = $this->get_hashes();
6657
+ if (isset($hashes[$key]))
6658
+ {
6659
+ return $hashes[$key];
6660
+ }
6661
+ else
6662
+ {
6663
+ return null;
6664
+ }
6665
+ }
6666
+
6667
+ function get_hashes()
6668
+ {
6669
+ if ($this->hashes !== null)
6670
+ {
6671
+ return $this->hashes;
6672
+ }
6673
+ else
6674
+ {
6675
+ return null;
6676
+ }
6677
+ }
6678
+
6679
+ function get_height()
6680
+ {
6681
+ if ($this->height !== null)
6682
+ {
6683
+ return $this->height;
6684
+ }
6685
+ else
6686
+ {
6687
+ return null;
6688
+ }
6689
+ }
6690
+
6691
+ function get_language()
6692
+ {
6693
+ if ($this->lang !== null)
6694
+ {
6695
+ return $this->lang;
6696
+ }
6697
+ else
6698
+ {
6699
+ return null;
6700
+ }
6701
+ }
6702
+
6703
+ function get_keyword($key = 0)
6704
+ {
6705
+ $keywords = $this->get_keywords();
6706
+ if (isset($keywords[$key]))
6707
+ {
6708
+ return $keywords[$key];
6709
+ }
6710
+ else
6711
+ {
6712
+ return null;
6713
+ }
6714
+ }
6715
+
6716
+ function get_keywords()
6717
+ {
6718
+ if ($this->keywords !== null)
6719
+ {
6720
+ return $this->keywords;
6721
+ }
6722
+ else
6723
+ {
6724
+ return null;
6725
+ }
6726
+ }
6727
+
6728
+ function get_length()
6729
+ {
6730
+ if ($this->length !== null)
6731
+ {
6732
+ return $this->length;
6733
+ }
6734
+ else
6735
+ {
6736
+ return null;
6737
+ }
6738
+ }
6739
+
6740
+ function get_link()
6741
+ {
6742
+ if ($this->link !== null)
6743
+ {
6744
+ return urldecode($this->link);
6745
+ }
6746
+ else
6747
+ {
6748
+ return null;
6749
+ }
6750
+ }
6751
+
6752
+ function get_medium()
6753
+ {
6754
+ if ($this->medium !== null)
6755
+ {
6756
+ return $this->medium;
6757
+ }
6758
+ else
6759
+ {
6760
+ return null;
6761
+ }
6762
+ }
6763
+
6764
+ function get_player()
6765
+ {
6766
+ if ($this->player !== null)
6767
+ {
6768
+ return $this->player;
6769
+ }
6770
+ else
6771
+ {
6772
+ return null;
6773
+ }
6774
+ }
6775
+
6776
+ function get_rating($key = 0)
6777
+ {
6778
+ $ratings = $this->get_ratings();
6779
+ if (isset($ratings[$key]))
6780
+ {
6781
+ return $ratings[$key];
6782
+ }
6783
+ else
6784
+ {
6785
+ return null;
6786
+ }
6787
+ }
6788
+
6789
+ function get_ratings()
6790
+ {
6791
+ if ($this->ratings !== null)
6792
+ {
6793
+ return $this->ratings;
6794
+ }
6795
+ else
6796
+ {
6797
+ return null;
6798
+ }
6799
+ }
6800
+
6801
+ function get_restriction($key = 0)
6802
+ {
6803
+ $restrictions = $this->get_restrictions();
6804
+ if (isset($restrictions[$key]))
6805
+ {
6806
+ return $restrictions[$key];
6807
+ }
6808
+ else
6809
+ {
6810
+ return null;
6811
+ }
6812
+ }
6813
+
6814
+ function get_restrictions()
6815
+ {
6816
+ if ($this->restrictions !== null)
6817
+ {
6818
+ return $this->restrictions;
6819
+ }
6820
+ else
6821
+ {
6822
+ return null;
6823
+ }
6824
+ }
6825
+
6826
+ function get_sampling_rate()
6827
+ {
6828
+ if ($this->samplingrate !== null)
6829
+ {
6830
+ return $this->samplingrate;
6831
+ }
6832
+ else
6833
+ {
6834
+ return null;
6835
+ }
6836
+ }
6837
+
6838
+ function get_size()
6839
+ {
6840
+ $length = $this->get_length();
6841
+ if ($length !== null)
6842
+ {
6843
+ return round($length/1048576, 2);
6844
+ }
6845
+ else
6846
+ {
6847
+ return null;
6848
+ }
6849
+ }
6850
+
6851
+ function get_thumbnail($key = 0)
6852
+ {
6853
+ $thumbnails = $this->get_thumbnails();
6854
+ if (isset($thumbnails[$key]))
6855
+ {
6856
+ return $thumbnails[$key];
6857
+ }
6858
+ else
6859
+ {
6860
+ return null;
6861
+ }
6862
+ }
6863
+
6864
+ function get_thumbnails()
6865
+ {
6866
+ if ($this->thumbnails !== null)
6867
+ {
6868
+ return $this->thumbnails;
6869
+ }
6870
+ else
6871
+ {
6872
+ return null;
6873
+ }
6874
+ }
6875
+
6876
+ function get_title()
6877
+ {
6878
+ if ($this->title !== null)
6879
+ {
6880
+ return $this->title;
6881
+ }
6882
+ else
6883
+ {
6884
+ return null;
6885
+ }
6886
+ }
6887
+
6888
+ function get_type()
6889
+ {
6890
+ if ($this->type !== null)
6891
+ {
6892
+ return $this->type;
6893
+ }
6894
+ else
6895
+ {
6896
+ return null;
6897
+ }
6898
+ }
6899
+
6900
+ function get_width()
6901
+ {
6902
+ if ($this->width !== null)
6903
+ {
6904
+ return $this->width;
6905
+ }
6906
+ else
6907
+ {
6908
+ return null;
6909
+ }
6910
+ }
6911
+
6912
+ function native_embed($options='')
6913
+ {
6914
+ return $this->embed($options, true);
6915
+ }
6916
+
6917
+ /**
6918
+ * @todo If the dimensions for media:content are defined, use them when width/height are set to 'auto'.
6919
+ */
6920
+ function embed($options = '', $native = false)
6921
+ {
6922
+ // Set up defaults
6923
+ $audio = '';
6924
+ $video = '';
6925
+ $alt = '';
6926
+ $altclass = '';
6927
+ $loop = 'false';
6928
+ $width = 'auto';
6929
+ $height = 'auto';
6930
+ $bgcolor = '#ffffff';
6931
+ $mediaplayer = '';
6932
+ $widescreen = false;
6933
+ $handler = $this->get_handler();
6934
+ $type = $this->get_real_type();
6935
+
6936
+ // Process options and reassign values as necessary
6937
+ if (is_array($options))
6938
+ {
6939
+ extract($options);
6940
+ }
6941
+ else
6942
+ {
6943
+ $options = explode(',', $options);
6944
+ foreach($options as $option)
6945
+ {
6946
+ $opt = explode(':', $option, 2);
6947
+ if (isset($opt[0], $opt[1]))
6948
+ {
6949
+ $opt[0] = trim($opt[0]);
6950
+ $opt[1] = trim($opt[1]);
6951
+ switch ($opt[0])
6952
+ {
6953
+ case 'audio':
6954
+ $audio = $opt[1];
6955
+ break;
6956
+
6957
+ case 'video':
6958
+ $video = $opt[1];
6959
+ break;
6960
+
6961
+ case 'alt':
6962
+ $alt = $opt[1];
6963
+ break;
6964
+
6965
+ case 'altclass':
6966
+ $altclass = $opt[1];
6967
+ break;
6968
+
6969
+ case 'loop':
6970
+ $loop = $opt[1];
6971
+ break;
6972
+
6973
+ case 'width':
6974
+ $width = $opt[1];
6975
+ break;
6976
+
6977
+ case 'height':
6978
+ $height = $opt[1];
6979
+ break;
6980
+
6981
+ case 'bgcolor':
6982
+ $bgcolor = $opt[1];
6983
+ break;
6984
+
6985
+ case 'mediaplayer':
6986
+ $mediaplayer = $opt[1];
6987
+ break;
6988
+
6989
+ case 'widescreen':
6990
+ $widescreen = $opt[1];
6991
+ break;
6992
+ }
6993
+ }
6994
+ }
6995
+ }
6996
+
6997
+ $mime = explode('/', $type, 2);
6998
+ $mime = $mime[0];
6999
+
7000
+ // Process values for 'auto'
7001
+ if ($width === 'auto')
7002
+ {
7003
+ if ($mime === 'video')
7004
+ {
7005
+ if ($height === 'auto')
7006
+ {
7007
+ $width = 480;
7008
+ }
7009
+ elseif ($widescreen)
7010
+ {
7011
+ $width = round((intval($height)/9)*16);
7012
+ }
7013
+ else
7014
+ {
7015
+ $width = round((intval($height)/3)*4);
7016
+ }
7017
+ }
7018
+ else
7019
+ {
7020
+ $width = '100%';
7021
+ }
7022
+ }
7023
+
7024
+ if ($height === 'auto')
7025
+ {
7026
+ if ($mime === 'audio')
7027
+ {
7028
+ $height = 0;
7029
+ }
7030
+ elseif ($mime === 'video')
7031
+ {
7032
+ if ($width === 'auto')
7033
+ {
7034
+ if ($widescreen)
7035
+ {
7036
+ $height = 270;
7037
+ }
7038
+ else
7039
+ {
7040
+ $height = 360;
7041
+ }
7042
+ }
7043
+ elseif ($widescreen)
7044
+ {
7045
+ $height = round((intval($width)/16)*9);
7046
+ }
7047
+ else
7048
+ {
7049
+ $height = round((intval($width)/4)*3);
7050
+ }
7051
+ }
7052
+ else
7053
+ {
7054
+ $height = 376;
7055
+ }
7056
+ }
7057
+ elseif ($mime === 'audio')
7058
+ {
7059
+ $height = 0;
7060
+ }
7061
+
7062
+ // Set proper placeholder value
7063
+ if ($mime === 'audio')
7064
+ {
7065
+ $placeholder = $audio;
7066
+ }
7067
+ elseif ($mime === 'video')
7068
+ {
7069
+ $placeholder = $video;
7070
+ }
7071
+
7072
+ $embed = '';
7073
+
7074
+ // Make sure the JS library is included
7075
+ if (!$native)
7076
+ {
7077
+ static $javascript_outputted = null;
7078
+ if (!$javascript_outputted && $this->javascript)
7079
+ {
7080
+ $embed .= '<script type="text/javascript" src="?' . htmlspecialchars($this->javascript) . '"></script>';
7081
+ $javascript_outputted = true;
7082
+ }
7083
+ }
7084
+
7085
+ // Odeo Feed MP3's
7086
+ if ($handler === 'odeo')
7087
+ {
7088
+ if ($native)
7089
+ {
7090
+ $embed .= '<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://adobe.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url=' . $this->get_link() . '"></embed>';
7091
+ }
7092
+ else
7093
+ {
7094
+ $embed .= '<script type="text/javascript">embed_odeo("' . $this->get_link() . '");</script>';
7095
+ }
7096
+ }
7097
+
7098
+ // Flash
7099
+ elseif ($handler === 'flash')
7100
+ {
7101
+ if ($native)
7102
+ {
7103
+ $embed .= "<embed src=\"" . $this->get_link() . "\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"$type\" quality=\"high\" width=\"$width\" height=\"$height\" bgcolor=\"$bgcolor\" loop=\"$loop\"></embed>";
7104
+ }
7105
+ else
7106
+ {
7107
+ $embed .= "<script type='text/javascript'>embed_flash('$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$loop', '$type');</script>";
7108
+ }
7109
+ }
7110
+
7111
+ // Flash Media Player file types.
7112
+ // Preferred handler for MP3 file types.
7113
+ elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== ''))
7114
+ {
7115
+ $height += 20;
7116
+ if ($native)
7117
+ {
7118
+ $embed .= "<embed src=\"$mediaplayer\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" quality=\"high\" width=\"$width\" height=\"$height\" wmode=\"transparent\" flashvars=\"file=" . rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) . "&autostart=false&repeat=$loop&showdigits=true&showfsbutton=false\"></embed>";
7119
+ }
7120
+ else
7121
+ {
7122
+ $embed .= "<script type='text/javascript'>embed_flv('$width', '$height', '" . rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) . "', '$placeholder', '$loop', '$mediaplayer');</script>";
7123
+ }
7124
+ }
7125
+
7126
+ // QuickTime 7 file types. Need to test with QuickTime 6.
7127
+ // Only handle MP3's if the Flash Media Player is not present.
7128
+ elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === ''))
7129
+ {
7130
+ $height += 16;
7131
+ if ($native)
7132
+ {
7133
+ if ($placeholder !== '')
7134
+ {
7135
+ $embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" href=\"" . $this->get_link() . "\" src=\"$placeholder\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"false\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>";
7136
+ }
7137
+ else
7138
+ {
7139
+ $embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" src=\"" . $this->get_link() . "\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"true\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>";
7140
+ }
7141
+ }
7142
+ else
7143
+ {
7144
+ $embed .= "<script type='text/javascript'>embed_quicktime('$type', '$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$placeholder', '$loop');</script>";
7145
+ }
7146
+ }
7147
+
7148
+ // Windows Media
7149
+ elseif ($handler === 'wmedia')
7150
+ {
7151
+ $height += 45;
7152
+ if ($native)
7153
+ {
7154
+ $embed .= "<embed type=\"application/x-mplayer2\" src=\"" . $this->get_link() . "\" autosize=\"1\" width=\"$width\" height=\"$height\" showcontrols=\"1\" showstatusbar=\"0\" showdisplay=\"0\" autostart=\"0\"></embed>";
7155
+ }
7156
+ else
7157
+ {
7158
+ $embed .= "<script type='text/javascript'>embed_wmedia('$width', '$height', '" . $this->get_link() . "');</script>";
7159
+ }
7160
+ }
7161
+
7162
+ // Everything else
7163
+ else $embed .= '<a href="' . $this->get_link() . '" class="' . $altclass . '">' . $alt . '</a>';
7164
+
7165
+ return $embed;
7166
+ }
7167
+
7168
+ function get_real_type($find_handler = false)
7169
+ {
7170
+ // If it's Odeo, let's get it out of the way.
7171
+ if (substr(strtolower($this->get_link()), 0, 15) === 'http://odeo.com')
7172
+ {
7173
+ return 'odeo';
7174
+ }
7175
+
7176
+ // Mime-types by handler.
7177
+ $types_flash = array('application/x-shockwave-flash', 'application/futuresplash'); // Flash
7178
+ $types_fmedia = array('video/flv', 'video/x-flv','flv-application/octet-stream'); // Flash Media Player
7179
+ $types_quicktime = array('audio/3gpp', 'audio/3gpp2', 'audio/aac', 'audio/x-aac', 'audio/aiff', 'audio/x-aiff', 'audio/mid', 'audio/midi', 'audio/x-midi', 'audio/mp4', 'audio/m4a', 'audio/x-m4a', 'audio/wav', 'audio/x-wav', 'video/3gpp', 'video/3gpp2', 'video/m4v', 'video/x-m4v', 'video/mp4', 'video/mpeg', 'video/x-mpeg', 'video/quicktime', 'video/sd-video'); // QuickTime
7180
+ $types_wmedia = array('application/asx', 'application/x-mplayer2', 'audio/x-ms-wma', 'audio/x-ms-wax', 'video/x-ms-asf-plugin', 'video/x-ms-asf', 'video/x-ms-wm', 'video/x-ms-wmv', 'video/x-ms-wvx'); // Windows Media
7181
+ $types_mp3 = array('audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg'); // MP3
7182
+
7183
+ if ($this->get_type() !== null)
7184
+ {
7185
+ $type = strtolower($this->type);
7186
+ }
7187
+ else
7188
+ {
7189
+ $type = null;
7190
+ }
7191
+
7192
+ // If we encounter an unsupported mime-type, check the file extension and guess intelligently.
7193
+ if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3)))
7194
+ {
7195
+ switch (strtolower($this->get_extension()))
7196
+ {
7197
+ // Audio mime-types
7198
+ case 'aac':
7199
+ case 'adts':
7200
+ $type = 'audio/acc';
7201
+ break;
7202
+
7203
+ case 'aif':
7204
+ case 'aifc':
7205
+ case 'aiff':
7206
+ case 'cdda':
7207
+ $type = 'audio/aiff';
7208
+ break;
7209
+
7210
+ case 'bwf':
7211
+ $type = 'audio/wav';
7212
+ break;
7213
+
7214
+ case 'kar':
7215
+ case 'mid':
7216
+ case 'midi':
7217
+ case 'smf':
7218
+ $type = 'audio/midi';
7219
+ break;
7220
+
7221
+ case 'm4a':
7222
+ $type = 'audio/x-m4a';
7223
+ break;
7224
+
7225
+ case 'mp3':
7226
+ case 'swa':
7227
+ $type = 'audio/mp3';
7228
+ break;
7229
+
7230
+ case 'wav':
7231
+ $type = 'audio/wav';
7232
+ break;
7233
+
7234
+ case 'wax':
7235
+ $type = 'audio/x-ms-wax';
7236
+ break;
7237
+
7238
+ case 'wma':
7239
+ $type = 'audio/x-ms-wma';
7240
+ break;
7241
+
7242
+ // Video mime-types
7243
+ case '3gp':
7244
+ case '3gpp':
7245
+ $type = 'video/3gpp';
7246
+ break;
7247
+
7248
+ case '3g2':
7249
+ case '3gp2':
7250
+ $type = 'video/3gpp2';
7251
+ break;
7252
+
7253
+ case 'asf':
7254
+ $type = 'video/x-ms-asf';
7255
+ break;
7256
+
7257
+ case 'flv':
7258
+ $type = 'video/x-flv';
7259
+ break;
7260
+
7261
+ case 'm1a':
7262
+ case 'm1s':
7263
+ case 'm1v':
7264
+ case 'm15':
7265
+ case 'm75':
7266
+ case 'mp2':
7267
+ case 'mpa':
7268
+ case 'mpeg':
7269
+ case 'mpg':
7270
+ case 'mpm':
7271
+ case 'mpv':
7272
+ $type = 'video/mpeg';
7273
+ break;
7274
+
7275
+ case 'm4v':
7276
+ $type = 'video/x-m4v';
7277
+ break;
7278
+
7279
+ case 'mov':
7280
+ case 'qt':
7281
+ $type = 'video/quicktime';
7282
+ break;
7283
+
7284
+ case 'mp4':
7285
+ case 'mpg4':
7286
+ $type = 'video/mp4';
7287
+ break;
7288
+
7289
+ case 'sdv':
7290
+ $type = 'video/sd-video';
7291
+ break;
7292
+
7293
+ case 'wm':
7294
+ $type = 'video/x-ms-wm';
7295
+ break;
7296
+
7297
+ case 'wmv':
7298
+ $type = 'video/x-ms-wmv';
7299
+ break;
7300
+
7301
+ case 'wvx':
7302
+ $type = 'video/x-ms-wvx';
7303
+ break;
7304
+
7305
+ // Flash mime-types
7306
+ case 'spl':
7307
+ $type = 'application/futuresplash';
7308
+ break;
7309
+
7310
+ case 'swf':
7311
+ $type = 'application/x-shockwave-flash';
7312
+ break;
7313
+ }
7314
+ }
7315
+
7316
+ if ($find_handler)
7317
+ {
7318
+ if (in_array($type, $types_flash))
7319
+ {
7320
+ return 'flash';
7321
+ }
7322
+ elseif (in_array($type, $types_fmedia))
7323
+ {
7324
+ return 'fmedia';
7325
+ }
7326
+ elseif (in_array($type, $types_quicktime))
7327
+ {
7328
+ return 'quicktime';
7329
+ }
7330
+ elseif (in_array($type, $types_wmedia))
7331
+ {
7332
+ return 'wmedia';
7333
+ }
7334
+ elseif (in_array($type, $types_mp3))
7335
+ {
7336
+ return 'mp3';
7337
+ }
7338
+ else
7339
+ {
7340
+ return null;
7341
+ }
7342
+ }
7343
+ else
7344
+ {
7345
+ return $type;
7346
+ }
7347
+ }
7348
+ }
7349
+
7350
+ class SimplePie_Caption
7351
+ {
7352
+ var $type;
7353
+ var $lang;
7354
+ var $startTime;
7355
+ var $endTime;
7356
+ var $text;
7357
+
7358
+ // Constructor, used to input the data
7359
+ function SimplePie_Caption($type = null, $lang = null, $startTime = null, $endTime = null, $text = null)
7360
+ {
7361
+ $this->type = $type;
7362
+ $this->lang = $lang;
7363
+ $this->startTime = $startTime;
7364
+ $this->endTime = $endTime;
7365
+ $this->text = $text;
7366
+ }
7367
+
7368
+ function __toString()
7369
+ {
7370
+ // There is no $this->data here
7371
+ return md5(serialize($this));
7372
+ }
7373
+
7374
+ function get_endtime()
7375
+ {
7376
+ if ($this->endTime !== null)
7377
+ {
7378
+ return $this->endTime;
7379
+ }
7380
+ else
7381
+ {
7382
+ return null;
7383
+ }
7384
+ }
7385
+
7386
+ function get_language()
7387
+ {
7388
+ if ($this->lang !== null)
7389
+ {
7390
+ return $this->lang;
7391
+ }
7392
+ else
7393
+ {
7394
+ return null;
7395
+ }
7396
+ }
7397
+
7398
+ function get_starttime()
7399
+ {
7400
+ if ($this->startTime !== null)
7401
+ {
7402
+ return $this->startTime;
7403
+ }
7404
+ else
7405
+ {
7406
+ return null;
7407
+ }
7408
+ }
7409
+
7410
+ function get_text()
7411
+ {
7412
+ if ($this->text !== null)
7413
+ {
7414
+ return $this->text;
7415
+ }
7416
+ else
7417
+ {
7418
+ return null;
7419
+ }
7420
+ }
7421
+
7422
+ function get_type()
7423
+ {
7424
+ if ($this->type !== null)
7425
+ {
7426
+ return $this->type;
7427
+ }
7428
+ else
7429
+ {
7430
+ return null;
7431
+ }
7432
+ }
7433
+ }
7434
+
7435
+ class SimplePie_Credit
7436
+ {
7437
+ var $role;
7438
+ var $scheme;
7439
+ var $name;
7440
+
7441
+ // Constructor, used to input the data
7442
+ function SimplePie_Credit($role = null, $scheme = null, $name = null)
7443
+ {
7444
+ $this->role = $role;
7445
+ $this->scheme = $scheme;
7446
+ $this->name = $name;
7447
+ }
7448
+
7449
+ function __toString()
7450
+ {
7451
+ // There is no $this->data here
7452
+ return md5(serialize($this));
7453
+ }
7454
+
7455
+ function get_role()
7456
+ {
7457
+ if ($this->role !== null)
7458
+ {
7459
+ return $this->role;
7460
+ }
7461
+ else
7462
+ {
7463
+ return null;
7464
+ }
7465
+ }
7466
+
7467
+ function get_scheme()
7468
+ {
7469
+ if ($this->scheme !== null)
7470
+ {
7471
+ return $this->scheme;
7472
+ }
7473
+ else
7474
+ {
7475
+ return null;
7476
+ }
7477
+ }
7478
+
7479
+ function get_name()
7480
+ {
7481
+ if ($this->name !== null)
7482
+ {
7483
+ return $this->name;
7484
+ }
7485
+ else
7486
+ {
7487
+ return null;
7488
+ }
7489
+ }
7490
+ }
7491
+
7492
+ class SimplePie_Copyright
7493
+ {
7494
+ var $url;
7495
+ var $label;
7496
+
7497
+ // Constructor, used to input the data
7498
+ function SimplePie_Copyright($url = null, $label = null)
7499
+ {
7500
+ $this->url = $url;
7501
+ $this->label = $label;
7502
+ }
7503
+
7504
+ function __toString()
7505
+ {
7506
+ // There is no $this->data here
7507
+ return md5(serialize($this));
7508
+ }
7509
+
7510
+ function get_url()
7511
+ {
7512
+ if ($this->url !== null)
7513
+ {
7514
+ return $this->url;
7515
+ }
7516
+ else
7517
+ {
7518
+ return null;
7519
+ }
7520
+ }
7521
+
7522
+ function get_attribution()
7523
+ {
7524
+ if ($this->label !== null)
7525
+ {
7526
+ return $this->label;
7527
+ }
7528
+ else
7529
+ {
7530
+ return null;
7531
+ }
7532
+ }
7533
+ }
7534
+
7535
+ class SimplePie_Rating
7536
+ {
7537
+ var $scheme;
7538
+ var $value;
7539
+
7540
+ // Constructor, used to input the data
7541
+ function SimplePie_Rating($scheme = null, $value = null)
7542
+ {
7543
+ $this->scheme = $scheme;
7544
+ $this->value = $value;
7545
+ }
7546
+
7547
+ function __toString()
7548
+ {
7549
+ // There is no $this->data here
7550
+ return md5(serialize($this));
7551
+ }
7552
+
7553
+ function get_scheme()
7554
+ {
7555
+ if ($this->scheme !== null)
7556
+ {
7557
+ return $this->scheme;
7558
+ }
7559
+ else
7560
+ {
7561
+ return null;
7562
+ }
7563
+ }
7564
+
7565
+ function get_value()
7566
+ {
7567
+ if ($this->value !== null)
7568
+ {
7569
+ return $this->value;
7570
+ }
7571
+ else
7572
+ {
7573
+ return null;
7574
+ }
7575
+ }
7576
+ }
7577
+
7578
+ class SimplePie_Restriction
7579
+ {
7580
+ var $relationship;
7581
+ var $type;
7582
+ var $value;
7583
+
7584
+ // Constructor, used to input the data
7585
+ function SimplePie_Restriction($relationship = null, $type = null, $value = null)
7586
+ {
7587
+ $this->relationship = $relationship;
7588
+ $this->type = $type;
7589
+ $this->value = $value;
7590
+ }
7591
+
7592
+ function __toString()
7593
+ {
7594
+ // There is no $this->data here
7595
+ return md5(serialize($this));
7596
+ }
7597
+
7598
+ function get_relationship()
7599
+ {
7600
+ if ($this->relationship !== null)
7601
+ {
7602
+ return $this->relationship;
7603
+ }
7604
+ else
7605
+ {
7606
+ return null;
7607
+ }
7608
+ }
7609
+
7610
+ function get_type()
7611
+ {
7612
+ if ($this->type !== null)
7613
+ {
7614
+ return $this->type;
7615
+ }
7616
+ else
7617
+ {
7618
+ return null;
7619
+ }
7620
+ }
7621
+
7622
+ function get_value()
7623
+ {
7624
+ if ($this->value !== null)
7625
+ {
7626
+ return $this->value;
7627
+ }
7628
+ else
7629
+ {
7630
+ return null;
7631
+ }
7632
+ }
7633
+ }
7634
+
7635
+ /**
7636
+ * @todo Move to properly supporting RFC2616 (HTTP/1.1)
7637
+ */
7638
+ class SimplePie_File
7639
+ {
7640
+ var $url;
7641
+ var $useragent;
7642
+ var $success = true;
7643
+ var $headers = array();
7644
+ var $body;
7645
+ var $status_code;
7646
+ var $redirects = 0;
7647
+ var $error;
7648
+ var $method = SIMPLEPIE_FILE_SOURCE_NONE;
7649
+
7650
+ function SimplePie_File($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false)
7651
+ {
7652
+ if (class_exists('idna_convert'))
7653
+ {
7654
+ $idn = new idna_convert;
7655
+ $parsed = SimplePie_Misc::parse_url($url);
7656
+ $url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
7657
+ }
7658
+ $this->url = $url;
7659
+ $this->useragent = $useragent;
7660
+ if (preg_match('/^http(s)?:\/\//i', $url))
7661
+ {
7662
+ if ($useragent === null)
7663
+ {
7664
+ $useragent = ini_get('user_agent');
7665
+ $this->useragent = $useragent;
7666
+ }
7667
+ if (!is_array($headers))
7668
+ {
7669
+ $headers = array();
7670
+ }
7671
+ if (!$force_fsockopen && function_exists('curl_exec'))
7672
+ {
7673
+ $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL;
7674
+ $fp = curl_init();
7675
+ $headers2 = array();
7676
+ foreach ($headers as $key => $value)
7677
+ {
7678
+ $headers2[] = "$key: $value";
7679
+ }
7680
+ if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>='))
7681
+ {
7682
+ curl_setopt($fp, CURLOPT_ENCODING, '');
7683
+ }
7684
+ curl_setopt($fp, CURLOPT_URL, $url);
7685
+ curl_setopt($fp, CURLOPT_HEADER, 1);
7686
+ curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);
7687
+ curl_setopt($fp, CURLOPT_TIMEOUT, $timeout);
7688
+ curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout);
7689
+ curl_setopt($fp, CURLOPT_REFERER, $url);
7690
+ curl_setopt($fp, CURLOPT_USERAGENT, $useragent);
7691
+ curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);
7692
+ if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>='))
7693
+ {
7694
+ curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1);
7695
+ curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects);
7696
+ }
7697
+
7698
+ $this->headers = curl_exec($fp);
7699
+ if (curl_errno($fp) === 23 || curl_errno($fp) === 61)
7700
+ {
7701
+ curl_setopt($fp, CURLOPT_ENCODING, 'none');
7702
+ $this->headers = curl_exec($fp);
7703
+ }
7704
+ if (curl_errno($fp))
7705
+ {
7706
+ $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp);
7707
+ $this->success = false;
7708
+ }
7709
+ else
7710
+ {
7711
+ $info = curl_getinfo($fp);
7712
+ curl_close($fp);
7713
+ $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1);
7714
+ $this->headers = array_pop($this->headers);
7715
+ $parser = new SimplePie_HTTP_Parser($this->headers);
7716
+ if ($parser->parse())
7717
+ {
7718
+ $this->headers = $parser->headers;
7719
+ $this->body = $parser->body;
7720
+ $this->status_code = $parser->status_code;
7721
+ if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
7722
+ {
7723
+ $this->redirects++;
7724
+ $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
7725
+ return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
7726
+ }
7727
+ }
7728
+ }
7729
+ }
7730
+ else
7731
+ {
7732
+ $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
7733
+ $url_parts = parse_url($url);
7734
+ if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https')
7735
+ {
7736
+ $url_parts['host'] = "ssl://$url_parts[host]";
7737
+ $url_parts['port'] = 443;
7738
+ }
7739
+ if (!isset($url_parts['port']))
7740
+ {
7741
+ $url_parts['port'] = 80;
7742
+ }
7743
+ $fp = @fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout);
7744
+ if (!$fp)
7745
+ {
7746
+ $this->error = 'fsockopen error: ' . $errstr;
7747
+ $this->success = false;
7748
+ }
7749
+ else
7750
+ {
7751
+ stream_set_timeout($fp, $timeout);
7752
+ if (isset($url_parts['path']))
7753
+ {
7754
+ if (isset($url_parts['query']))
7755
+ {
7756
+ $get = "$url_parts[path]?$url_parts[query]";
7757
+ }
7758
+ else
7759
+ {
7760
+ $get = $url_parts['path'];
7761
+ }
7762
+ }
7763
+ else
7764
+ {
7765
+ $get = '/';
7766
+ }
7767
+ $out = "GET $get HTTP/1.0\r\n";
7768
+ $out .= "Host: $url_parts[host]\r\n";
7769
+ $out .= "User-Agent: $useragent\r\n";
7770
+ if (extension_loaded('zlib'))
7771
+ {
7772
+ $out .= "Accept-Encoding: x-gzip,gzip,deflate\r\n";
7773
+ }
7774
+
7775
+ if (isset($url_parts['user']) && isset($url_parts['pass']))
7776
+ {
7777
+ $out .= "Authorization: Basic " . base64_encode("$url_parts[user]:$url_parts[pass]") . "\r\n";
7778
+ }
7779
+ foreach ($headers as $key => $value)
7780
+ {
7781
+ $out .= "$key: $value\r\n";
7782
+ }
7783
+ $out .= "Connection: Close\r\n\r\n";
7784
+ fwrite($fp, $out);
7785
+
7786
+ $info = stream_get_meta_data($fp);
7787
+
7788
+ $this->headers = '';
7789
+ while (!$info['eof'] && !$info['timed_out'])
7790
+ {
7791
+ $this->headers .= fread($fp, 1160);
7792
+ $info = stream_get_meta_data($fp);
7793
+ }
7794
+ if (!$info['timed_out'])
7795
+ {
7796
+ $parser = new SimplePie_HTTP_Parser($this->headers);
7797
+ if ($parser->parse())
7798
+ {
7799
+ $this->headers = $parser->headers;
7800
+ $this->body = $parser->body;
7801
+ $this->status_code = $parser->status_code;
7802
+ if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
7803
+ {
7804
+ $this->redirects++;
7805
+ $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
7806
+ return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
7807
+ }
7808
+ if (isset($this->headers['content-encoding']))
7809
+ {
7810
+ // Hey, we act dumb elsewhere, so let's do that here too
7811
+ switch (strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20")))
7812
+ {
7813
+ case 'gzip':
7814
+ case 'x-gzip':
7815
+ $decoder = new SimplePie_gzdecode($this->body);
7816
+ if (!$decoder->parse())
7817
+ {
7818
+ $this->error = 'Unable to decode HTTP "gzip" stream';
7819
+ $this->success = false;
7820
+ }
7821
+ else
7822
+ {
7823
+ $this->body = $decoder->data;
7824
+ }
7825
+ break;
7826
+
7827
+ case 'deflate':
7828
+ if (($body = gzuncompress($this->body)) === false)
7829
+ {
7830
+ if (($body = gzinflate($this->body)) === false)
7831
+ {
7832
+ $this->error = 'Unable to decode HTTP "deflate" stream';
7833
+ $this->success = false;
7834
+ }
7835
+ }
7836
+ $this->body = $body;
7837
+ break;
7838
+
7839
+ default:
7840
+ $this->error = 'Unknown content coding';
7841
+ $this->success = false;
7842
+ }
7843
+ }
7844
+ }
7845
+ }
7846
+ else
7847
+ {
7848
+ $this->error = 'fsocket timed out';
7849
+ $this->success = false;
7850
+ }
7851
+ fclose($fp);
7852
+ }
7853
+ }
7854
+ }
7855
+ else
7856
+ {
7857
+ $this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS;
7858
+ // $url='http://twitter.com/codecanyon';
7859
+ if (!$this->body = file_get_contents($url))
7860
+ {
7861
+ $this->error = 'file_get_contents could not read the file'.$url;
7862
+ $this->success = false;
7863
+ }
7864
+ }
7865
+ }
7866
+ }
7867
+
7868
+ /**
7869
+ * HTTP Response Parser
7870
+ *
7871
+ * @package SimplePie
7872
+ */
7873
+ class SimplePie_HTTP_Parser
7874
+ {
7875
+ /**
7876
+ * HTTP Version
7877
+ *
7878
+ * @access public
7879
+ * @var float
7880
+ */
7881
+ var $http_version = 0.0;
7882
+
7883
+ /**
7884
+ * Status code
7885
+ *
7886
+ * @access public
7887
+ * @var int
7888
+ */
7889
+ var $status_code = 0;
7890
+
7891
+ /**
7892
+ * Reason phrase
7893
+ *
7894
+ * @access public
7895
+ * @var string
7896
+ */
7897
+ var $reason = '';
7898
+
7899
+ /**
7900
+ * Key/value pairs of the headers
7901
+ *
7902
+ * @access public
7903
+ * @var array
7904
+ */
7905
+ var $headers = array();
7906
+
7907
+ /**
7908
+ * Body of the response
7909
+ *
7910
+ * @access public
7911
+ * @var string
7912
+ */
7913
+ var $body = '';
7914
+
7915
+ /**
7916
+ * Current state of the state machine
7917
+ *
7918
+ * @access private
7919
+ * @var string
7920
+ */
7921
+ var $state = 'http_version';
7922
+
7923
+ /**
7924
+ * Input data
7925
+ *
7926
+ * @access private
7927
+ * @var string
7928
+ */
7929
+ var $data = '';
7930
+
7931
+ /**
7932
+ * Input data length (to avoid calling strlen() everytime this is needed)
7933
+ *
7934
+ * @access private
7935
+ * @var int
7936
+ */
7937
+ var $data_length = 0;
7938
+
7939
+ /**
7940
+ * Current position of the pointer
7941
+ *
7942
+ * @var int
7943
+ * @access private
7944
+ */
7945
+ var $position = 0;
7946
+
7947
+ /**
7948
+ * Name of the hedaer currently being parsed
7949
+ *
7950
+ * @access private
7951
+ * @var string
7952
+ */
7953
+ var $name = '';
7954
+
7955
+ /**
7956
+ * Value of the hedaer currently being parsed
7957
+ *
7958
+ * @access private
7959
+ * @var string
7960
+ */
7961
+ var $value = '';
7962
+
7963
+ /**
7964
+ * Create an instance of the class with the input data
7965
+ *
7966
+ * @access public
7967
+ * @param string $data Input data
7968
+ */
7969
+ function SimplePie_HTTP_Parser($data)
7970
+ {
7971
+ $this->data = $data;
7972
+ $this->data_length = strlen($this->data);
7973
+ }
7974
+
7975
+ /**
7976
+ * Parse the input data
7977
+ *
7978
+ * @access public
7979
+ * @return bool true on success, false on failure
7980
+ */
7981
+ function parse()
7982
+ {
7983
+ while ($this->state && $this->state !== 'emit' && $this->has_data())
7984
+ {
7985
+ $state = $this->state;
7986
+ $this->$state();
7987
+ }
7988
+ $this->data = '';
7989
+ if ($this->state === 'emit' || $this->state === 'body')
7990
+ {
7991
+ return true;
7992
+ }
7993
+ else
7994
+ {
7995
+ $this->http_version = '';
7996
+ $this->status_code = '';
7997
+ $this->reason = '';
7998
+ $this->headers = array();
7999
+ $this->body = '';
8000
+ return false;
8001
+ }
8002
+ }
8003
+
8004
+ /**
8005
+ * Check whether there is data beyond the pointer
8006
+ *
8007
+ * @access private
8008
+ * @return bool true if there is further data, false if not
8009
+ */
8010
+ function has_data()
8011
+ {
8012
+ return (bool) ($this->position < $this->data_length);
8013
+ }
8014
+
8015
+ /**
8016
+ * See if the next character is LWS
8017
+ *
8018
+ * @access private
8019
+ * @return bool true if the next character is LWS, false if not
8020
+ */
8021
+ function is_linear_whitespace()
8022
+ {
8023
+ return (bool) ($this->data[$this->position] === "\x09"
8024
+ || $this->data[$this->position] === "\x20"
8025
+ || ($this->data[$this->position] === "\x0A"
8026
+ && isset($this->data[$this->position + 1])
8027
+ && ($this->data[$this->position + 1] === "\x09" || $this->data[$this->position + 1] === "\x20")));
8028
+ }
8029
+
8030
+ /**
8031
+ * Parse the HTTP version
8032
+ *
8033
+ * @access private
8034
+ */
8035
+ function http_version()
8036
+ {
8037
+ if (strpos($this->data, "\x0A") !== false && strtoupper(substr($this->data, 0, 5)) === 'HTTP/')
8038
+ {
8039
+ $len = strspn($this->data, '0123456789.', 5);
8040
+ $this->http_version = substr($this->data, 5, $len);
8041
+ $this->position += 5 + $len;
8042
+ if (substr_count($this->http_version, '.') <= 1)
8043
+ {
8044
+ $this->http_version = (float) $this->http_version;
8045
+ $this->position += strspn($this->data, "\x09\x20", $this->position);
8046
+ $this->state = 'status';
8047
+ }
8048
+ else
8049
+ {
8050
+ $this->state = false;
8051
+ }
8052
+ }
8053
+ else
8054
+ {
8055
+ $this->state = false;
8056
+ }
8057
+ }
8058
+
8059
+ /**
8060
+ * Parse the status code
8061
+ *
8062
+ * @access private
8063
+ */
8064
+ function status()
8065
+ {
8066
+ if ($len = strspn($this->data, '0123456789', $this->position))
8067
+ {
8068
+ $this->status_code = (int) substr($this->data, $this->position, $len);
8069
+ $this->position += $len;
8070
+ $this->state = 'reason';
8071
+ }
8072
+ else
8073
+ {
8074
+ $this->state = false;
8075
+ }
8076
+ }
8077
+
8078
+ /**
8079
+ * Parse the reason phrase
8080
+ *
8081
+ * @access private
8082
+ */
8083
+ function reason()
8084
+ {
8085
+ $len = strcspn($this->data, "\x0A", $this->position);
8086
+ $this->reason = trim(substr($this->data, $this->position, $len), "\x09\x0D\x20");
8087
+ $this->position += $len + 1;
8088
+ $this->state = 'new_line';
8089
+ }
8090
+
8091
+ /**
8092
+ * Deal with a new line, shifting data around as needed
8093
+ *
8094
+ * @access private
8095
+ */
8096
+ function new_line()
8097
+ {
8098
+ $this->value = trim($this->value, "\x0D\x20");
8099
+ if ($this->name !== '' && $this->value !== '')
8100
+ {
8101
+ $this->name = strtolower($this->name);
8102
+ if (isset($this->headers[$this->name]))
8103
+ {
8104
+ $this->headers[$this->name] .= ', ' . $this->value;
8105
+ }
8106
+ else
8107
+ {
8108
+ $this->headers[$this->name] = $this->value;
8109
+ }
8110
+ }
8111
+ $this->name = '';
8112
+ $this->value = '';
8113
+ if (substr($this->data[$this->position], 0, 2) === "\x0D\x0A")
8114
+ {
8115
+ $this->position += 2;
8116
+ $this->state = 'body';
8117
+ }
8118
+ elseif ($this->data[$this->position] === "\x0A")
8119
+ {
8120
+ $this->position++;
8121
+ $this->state = 'body';
8122
+ }
8123
+ else
8124
+ {
8125
+ $this->state = 'name';
8126
+ }
8127
+ }
8128
+
8129
+ /**
8130
+ * Parse a header name
8131
+ *
8132
+ * @access private
8133
+ */
8134
+ function name()
8135
+ {
8136
+ $len = strcspn($this->data, "\x0A:", $this->position);
8137
+ if (isset($this->data[$this->position + $len]))
8138
+ {
8139
+ if ($this->data[$this->position + $len] === "\x0A")
8140
+ {
8141
+ $this->position += $len;
8142
+ $this->state = 'new_line';
8143
+ }
8144
+ else
8145
+ {
8146
+ $this->name = substr($this->data, $this->position, $len);
8147
+ $this->position += $len + 1;
8148
+ $this->state = 'value';
8149
+ }
8150
+ }
8151
+ else
8152
+ {
8153
+ $this->state = false;
8154
+ }
8155
+ }
8156
+
8157
+ /**
8158
+ * Parse LWS, replacing consecutive LWS characters with a single space
8159
+ *
8160
+ * @access private
8161
+ */
8162
+ function linear_whitespace()
8163
+ {
8164
+ do
8165
+ {
8166
+ if (substr($this->data, $this->position, 2) === "\x0D\x0A")
8167
+ {
8168
+ $this->position += 2;
8169
+ }
8170
+ elseif ($this->data[$this->position] === "\x0A")
8171
+ {
8172
+ $this->position++;
8173
+ }
8174
+ $this->position += strspn($this->data, "\x09\x20", $this->position);
8175
+ } while ($this->has_data() && $this->is_linear_whitespace());
8176
+ $this->value .= "\x20";
8177
+ }
8178
+
8179
+ /**
8180
+ * See what state to move to while within non-quoted header values
8181
+ *
8182
+ * @access private
8183
+ */
8184
+ function value()
8185
+ {
8186
+ if ($this->is_linear_whitespace())
8187
+ {
8188
+ $this->linear_whitespace();
8189
+ }
8190
+ else
8191
+ {
8192
+ switch ($this->data[$this->position])
8193
+ {
8194
+ case '"':
8195
+ $this->position++;
8196
+ $this->state = 'quote';
8197
+ break;
8198
+
8199
+ case "\x0A":
8200
+ $this->position++;
8201
+ $this->state = 'new_line';
8202
+ break;
8203
+
8204
+ default:
8205
+ $this->state = 'value_char';
8206
+ break;
8207
+ }
8208
+ }
8209
+ }
8210
+
8211
+ /**
8212
+ * Parse a header value while outside quotes
8213
+ *
8214
+ * @access private
8215
+ */
8216
+ function value_char()
8217
+ {
8218
+ $len = strcspn($this->data, "\x09\x20\x0A\"", $this->position);
8219
+ $this->value .= substr($this->data, $this->position, $len);
8220
+ $this->position += $len;
8221
+ $this->state = 'value';
8222
+ }
8223
+
8224
+ /**
8225
+ * See what state to move to while within quoted header values
8226
+ *
8227
+ * @access private
8228
+ */
8229
+ function quote()
8230
+ {
8231
+ if ($this->is_linear_whitespace())
8232
+ {
8233
+ $this->linear_whitespace();
8234
+ }
8235
+ else
8236
+ {
8237
+ switch ($this->data[$this->position])
8238
+ {
8239
+ case '"':
8240
+ $this->position++;
8241
+ $this->state = 'value';
8242
+ break;
8243
+
8244
+ case "\x0A":
8245
+ $this->position++;
8246
+ $this->state = 'new_line';
8247
+ break;
8248
+
8249
+ case '\\':
8250
+ $this->position++;
8251
+ $this->state = 'quote_escaped';
8252
+ break;
8253
+
8254
+ default:
8255
+ $this->state = 'quote_char';
8256
+ break;
8257
+ }
8258
+ }
8259
+ }
8260
+
8261
+ /**
8262
+ * Parse a header value while within quotes
8263
+ *
8264
+ * @access private
8265
+ */
8266
+ function quote_char()
8267
+ {
8268
+ $len = strcspn($this->data, "\x09\x20\x0A\"\\", $this->position);
8269
+ $this->value .= substr($this->data, $this->position, $len);
8270
+ $this->position += $len;
8271
+ $this->state = 'value';
8272
+ }
8273
+
8274
+ /**
8275
+ * Parse an escaped character within quotes
8276
+ *
8277
+ * @access private
8278
+ */
8279
+ function quote_escaped()
8280
+ {
8281
+ $this->value .= $this->data[$this->position];
8282
+ $this->position++;
8283
+ $this->state = 'quote';
8284
+ }
8285
+
8286
+ /**
8287
+ * Parse the body
8288
+ *
8289
+ * @access private
8290
+ */
8291
+ function body()
8292
+ {
8293
+ $this->body = substr($this->data, $this->position);
8294
+ $this->state = 'emit';
8295
+ }
8296
+ }
8297
+
8298
+ /**
8299
+ * gzdecode
8300
+ *
8301
+ * @package SimplePie
8302
+ */
8303
+ class SimplePie_gzdecode
8304
+ {
8305
+ /**
8306
+ * Compressed data
8307
+ *
8308
+ * @access private
8309
+ * @see gzdecode::$data
8310
+ */
8311
+ var $compressed_data;
8312
+
8313
+ /**
8314
+ * Size of compressed data
8315
+ *
8316
+ * @access private
8317
+ */
8318
+ var $compressed_size;
8319
+
8320
+ /**
8321
+ * Minimum size of a valid gzip string
8322
+ *
8323
+ * @access private
8324
+ */
8325
+ var $min_compressed_size = 18;
8326
+
8327
+ /**
8328
+ * Current position of pointer
8329
+ *
8330
+ * @access private
8331
+ */
8332
+ var $position = 0;
8333
+
8334
+ /**
8335
+ * Flags (FLG)
8336
+ *
8337
+ * @access private
8338
+ */
8339
+ var $flags;
8340
+
8341
+ /**
8342
+ * Uncompressed data
8343
+ *
8344
+ * @access public
8345
+ * @see gzdecode::$compressed_data
8346
+ */
8347
+ var $data;
8348
+
8349
+ /**
8350
+ * Modified time
8351
+ *
8352
+ * @access public
8353
+ */
8354
+ var $MTIME;
8355
+
8356
+ /**
8357
+ * Extra Flags
8358
+ *
8359
+ * @access public
8360
+ */
8361
+ var $XFL;
8362
+
8363
+ /**
8364
+ * Operating System
8365
+ *
8366
+ * @access public
8367
+ */
8368
+ var $OS;
8369
+
8370
+ /**
8371
+ * Subfield ID 1
8372
+ *
8373
+ * @access public
8374
+ * @see gzdecode::$extra_field
8375
+ * @see gzdecode::$SI2
8376
+ */
8377
+ var $SI1;
8378
+
8379
+ /**
8380
+ * Subfield ID 2
8381
+ *
8382
+ * @access public
8383
+ * @see gzdecode::$extra_field
8384
+ * @see gzdecode::$SI1
8385
+ */
8386
+ var $SI2;
8387
+
8388
+ /**
8389
+ * Extra field content
8390
+ *
8391
+ * @access public
8392
+ * @see gzdecode::$SI1
8393
+ * @see gzdecode::$SI2
8394
+ */
8395
+ var $extra_field;
8396
+
8397
+ /**
8398
+ * Original filename
8399
+ *
8400
+ * @access public
8401
+ */
8402
+ var $filename;
8403
+
8404
+ /**
8405
+ * Human readable comment
8406
+ *
8407
+ * @access public
8408
+ */
8409
+ var $comment;
8410
+
8411
+ /**
8412
+ * Don't allow anything to be set
8413
+ *
8414
+ * @access public
8415
+ */
8416
+ function __set($name, $value)
8417
+ {
8418
+ trigger_error("Cannot write property $name", E_USER_ERROR);
8419
+ }
8420
+
8421
+ /**
8422
+ * Set the compressed string and related properties
8423
+ *
8424
+ * @access public
8425
+ */
8426
+ function SimplePie_gzdecode($data)
8427
+ {
8428
+ $this->compressed_data = $data;
8429
+ $this->compressed_size = strlen($data);
8430
+ }
8431
+
8432
+ /**
8433
+ * Decode the GZIP stream
8434
+ *
8435
+ * @access public
8436
+ */
8437
+ function parse()
8438
+ {
8439
+ if ($this->compressed_size >= $this->min_compressed_size)
8440
+ {
8441
+ // Check ID1, ID2, and CM
8442
+ if (substr($this->compressed_data, 0, 3) !== "\x1F\x8B\x08")
8443
+ {
8444
+ return false;
8445
+ }
8446
+
8447
+ // Get the FLG (FLaGs)
8448
+ $this->flags = ord($this->compressed_data[3]);
8449
+
8450
+ // FLG bits above (1 << 4) are reserved
8451
+ if ($this->flags > 0x1F)
8452
+ {
8453
+ return false;
8454
+ }
8455
+
8456
+ // Advance the pointer after the above
8457
+ $this->position += 4;
8458
+
8459
+ // MTIME
8460
+ $mtime = substr($this->compressed_data, $this->position, 4);
8461
+ // Reverse the string if we're on a big-endian arch because l is the only signed long and is machine endianness
8462
+ if (current(unpack('S', "\x00\x01")) === 1)
8463
+ {
8464
+ $mtime = strrev($mtime);
8465
+ }
8466
+ $this->MTIME = current(unpack('l', $mtime));
8467
+ $this->position += 4;
8468
+
8469
+ // Get the XFL (eXtra FLags)
8470
+ $this->XFL = ord($this->compressed_data[$this->position++]);
8471
+
8472
+ // Get the OS (Operating System)
8473
+ $this->OS = ord($this->compressed_data[$this->position++]);
8474
+
8475
+ // Parse the FEXTRA
8476
+ if ($this->flags & 4)
8477
+ {
8478
+ // Read subfield IDs
8479
+ $this->SI1 = $this->compressed_data[$this->position++];
8480
+ $this->SI2 = $this->compressed_data[$this->position++];
8481
+
8482
+ // SI2 set to zero is reserved for future use
8483
+ if ($this->SI2 === "\x00")
8484
+ {
8485
+ return false;
8486
+ }
8487
+
8488
+ // Get the length of the extra field
8489
+ $len = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
8490
+ $position += 2;
8491
+
8492
+ // Check the length of the string is still valid
8493
+ $this->min_compressed_size += $len + 4;
8494
+ if ($this->compressed_size >= $this->min_compressed_size)
8495
+ {
8496
+ // Set the extra field to the given data
8497
+ $this->extra_field = substr($this->compressed_data, $this->position, $len);
8498
+ $this->position += $len;
8499
+ }
8500
+ else
8501
+ {
8502
+ return false;
8503
+ }
8504
+ }
8505
+
8506
+ // Parse the FNAME
8507
+ if ($this->flags & 8)
8508
+ {
8509
+ // Get the length of the filename
8510
+ $len = strcspn($this->compressed_data, "\x00", $this->position);
8511
+
8512
+ // Check the length of the string is still valid
8513
+ $this->min_compressed_size += $len + 1;
8514
+ if ($this->compressed_size >= $this->min_compressed_size)
8515
+ {
8516
+ // Set the original filename to the given string
8517
+ $this->filename = substr($this->compressed_data, $this->position, $len);
8518
+ $this->position += $len + 1;
8519
+ }
8520
+ else
8521
+ {
8522
+ return false;
8523
+ }
8524
+ }
8525
+
8526
+ // Parse the FCOMMENT
8527
+ if ($this->flags & 16)
8528
+ {
8529
+ // Get the length of the comment
8530
+ $len = strcspn($this->compressed_data, "\x00", $this->position);
8531
+
8532
+ // Check the length of the string is still valid
8533
+ $this->min_compressed_size += $len + 1;
8534
+ if ($this->compressed_size >= $this->min_compressed_size)
8535
+ {
8536
+ // Set the original comment to the given string
8537
+ $this->comment = substr($this->compressed_data, $this->position, $len);
8538
+ $this->position += $len + 1;
8539
+ }
8540
+ else
8541
+ {
8542
+ return false;
8543
+ }
8544
+ }
8545
+
8546
+ // Parse the FHCRC
8547
+ if ($this->flags & 2)
8548
+ {
8549
+ // Check the length of the string is still valid
8550
+ $this->min_compressed_size += $len + 2;
8551
+ if ($this->compressed_size >= $this->min_compressed_size)
8552
+ {
8553
+ // Read the CRC
8554
+ $crc = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
8555
+
8556
+ // Check the CRC matches
8557
+ if ((crc32(substr($this->compressed_data, 0, $this->position)) & 0xFFFF) === $crc)
8558
+ {
8559
+ $this->position += 2;
8560
+ }
8561
+ else
8562
+ {
8563
+ return false;
8564
+ }
8565
+ }
8566
+ else
8567
+ {
8568
+ return false;
8569
+ }
8570
+ }
8571
+
8572
+ // Decompress the actual data
8573
+ if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false)
8574
+ {
8575
+ return false;
8576
+ }
8577
+ else
8578
+ {
8579
+ $this->position = $this->compressed_size - 8;
8580
+ }
8581
+
8582
+ // Check CRC of data
8583
+ $crc = current(unpack('V', substr($this->compressed_data, $this->position, 4)));
8584
+ $this->position += 4;
8585
+ /*if (extension_loaded('hash') && sprintf('%u', current(unpack('V', hash('crc32b', $this->data)))) !== sprintf('%u', $crc))
8586
+ {
8587
+ return false;
8588
+ }*/
8589
+
8590
+ // Check ISIZE of data
8591
+ $isize = current(unpack('V', substr($this->compressed_data, $this->position, 4)));
8592
+ $this->position += 4;
8593
+ if (sprintf('%u', strlen($this->data) & 0xFFFFFFFF) !== sprintf('%u', $isize))
8594
+ {
8595
+ return false;
8596
+ }
8597
+
8598
+ // Wow, against all odds, we've actually got a valid gzip string
8599
+ return true;
8600
+ }
8601
+ else
8602
+ {
8603
+ return false;
8604
+ }
8605
+ }
8606
+ }
8607
+
8608
+ class SimplePie_Cache
8609
+ {
8610
+ /**
8611
+ * Don't call the constructor. Please.
8612
+ *
8613
+ * @access private
8614
+ */
8615
+ function SimplePie_Cache()
8616
+ {
8617
+ trigger_error('Please call SimplePie_Cache::create() instead of the constructor', E_USER_ERROR);
8618
+ }
8619
+
8620
+ /**
8621
+ * Create a new SimplePie_Cache object
8622
+ *
8623
+ * @static
8624
+ * @access public
8625
+ */
8626
+ function create($location, $filename, $extension)
8627
+ {
8628
+ $location_iri = new SimplePie_IRI($location);
8629
+ switch ($location_iri->get_scheme())
8630
+ {
8631
+ case 'mysql':
8632
+ if (extension_loaded('mysql'))
8633
+ {
8634
+ return new SimplePie_Cache_MySQL($location_iri, $filename, $extension);
8635
+ }
8636
+ break;
8637
+
8638
+ default:
8639
+ return new SimplePie_Cache_File($location, $filename, $extension);
8640
+ }
8641
+ }
8642
+ }
8643
+
8644
+ class SimplePie_Cache_File
8645
+ {
8646
+ var $location;
8647
+ var $filename;
8648
+ var $extension;
8649
+ var $name;
8650
+
8651
+ function SimplePie_Cache_File($location, $filename, $extension)
8652
+ {
8653
+ $this->location = $location;
8654
+ $this->filename = $filename;
8655
+ $this->extension = $extension;
8656
+ $this->name = "$this->location/$this->filename.$this->extension";
8657
+ }
8658
+
8659
+ function save($data)
8660
+ {
8661
+ if (file_exists($this->name) && is_writeable($this->name) || file_exists($this->location) && is_writeable($this->location))
8662
+ {
8663
+ if (is_a($data, 'SimplePie'))
8664
+ {
8665
+ $data = $data->data;
8666
+ }
8667
+
8668
+ $data = serialize($data);
8669
+
8670
+ if (function_exists('file_put_contents'))
8671
+ {
8672
+ return (bool) file_put_contents($this->name, $data);
8673
+ }
8674
+ else
8675
+ {
8676
+ $fp = fopen($this->name, 'wb');
8677
+ if ($fp)
8678
+ {
8679
+ fwrite($fp, $data);
8680
+ fclose($fp);
8681
+ return true;
8682
+ }
8683
+ }
8684
+ }
8685
+ return false;
8686
+ }
8687
+
8688
+ function load()
8689
+ {
8690
+ if (file_exists($this->name) && is_readable($this->name))
8691
+ {
8692
+ return unserialize(file_get_contents($this->name));
8693
+ }
8694
+ return false;
8695
+ }
8696
+
8697
+ function mtime()
8698
+ {
8699
+ if (file_exists($this->name))
8700
+ {
8701
+ return filemtime($this->name);
8702
+ }
8703
+ return false;
8704
+ }
8705
+
8706
+ function touch()
8707
+ {
8708
+ if (file_exists($this->name))
8709
+ {
8710
+ return touch($this->name);
8711
+ }
8712
+ return false;
8713
+ }
8714
+
8715
+ function unlink()
8716
+ {
8717
+ if (file_exists($this->name))
8718
+ {
8719
+ return unlink($this->name);
8720
+ }
8721
+ return false;
8722
+ }
8723
+ }
8724
+
8725
+ class SimplePie_Cache_DB
8726
+ {
8727
+ function prepare_simplepie_object_for_cache($data)
8728
+ {
8729
+ $items = $data->get_items();
8730
+ $items_by_id = array();
8731
+
8732
+ if (!empty($items))
8733
+ {
8734
+ foreach ($items as $item)
8735
+ {
8736
+ $items_by_id[$item->get_id()] = $item;
8737
+ }
8738
+
8739
+ if (count($items_by_id) !== count($items))
8740
+ {
8741
+ $items_by_id = array();
8742
+ foreach ($items as $item)
8743
+ {
8744
+ $items_by_id[$item->get_id(true)] = $item;
8745
+ }
8746
+ }
8747
+
8748
+ if (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]))
8749
+ {
8750
+ $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0];
8751
+ }
8752
+ elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]))
8753
+ {
8754
+ $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0];
8755
+ }
8756
+ elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]))
8757
+ {
8758
+ $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0];
8759
+ }
8760
+ elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0]))
8761
+ {
8762
+ $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0];
8763
+ }
8764
+ else
8765
+ {
8766
+ $channel = null;
8767
+ }
8768
+
8769
+ if ($channel !== null)
8770
+ {
8771
+ if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry']))
8772
+ {
8773
+ unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry']);
8774
+ }
8775
+ if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry']))
8776
+ {
8777
+ unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry']);
8778
+ }
8779
+ if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']))
8780
+ {
8781
+ unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']);
8782
+ }
8783
+ if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']))
8784
+ {
8785
+ unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']);
8786
+ }
8787
+ if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item']))
8788
+ {
8789
+ unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item']);
8790
+ }
8791
+ }
8792
+ if (isset($data->data['items']))
8793
+ {
8794
+ unset($data->data['items']);
8795
+ }
8796
+ if (isset($data->data['ordered_items']))
8797
+ {
8798
+ unset($data->data['ordered_items']);
8799
+ }
8800
+ }
8801
+ return array(serialize($data->data), $items_by_id);
8802
+ }
8803
+ }
8804
+
8805
+ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB
8806
+ {
8807
+ var $mysql;
8808
+ var $options;
8809
+ var $id;
8810
+
8811
+ function SimplePie_Cache_MySQL($mysql_location, $name, $extension)
8812
+ {
8813
+ $host = $mysql_location->get_host();
8814
+ if (SimplePie_Misc::stripos($host, 'unix(') === 0 && substr($host, -1) === ')')
8815
+ {
8816
+ $server = ':' . substr($host, 5, -1);
8817
+ }
8818
+ else
8819
+ {
8820
+ $server = $host;
8821
+ if ($mysql_location->get_port() !== null)
8822
+ {
8823
+ $server .= ':' . $mysql_location->get_port();
8824
+ }
8825
+ }
8826
+
8827
+ if (strpos($mysql_location->get_userinfo(), ':') !== false)
8828
+ {
8829
+ list($username, $password) = explode(':', $mysql_location->get_userinfo(), 2);
8830
+ }
8831
+ else
8832
+ {
8833
+ $username = $mysql_location->get_userinfo();
8834
+ $password = null;
8835
+ }
8836
+
8837
+ if ($this->mysql = mysql_connect($server, $username, $password))
8838
+ {
8839
+ $this->id = $name . $extension;
8840
+ $this->options = SimplePie_Misc::parse_str($mysql_location->get_query());
8841
+ if (!isset($this->options['prefix'][0]))
8842
+ {
8843
+ $this->options['prefix'][0] = '';
8844
+ }
8845
+
8846
+ if (mysql_select_db(ltrim($mysql_location->get_path(), '/'))
8847
+ && mysql_query('SET NAMES utf8')
8848
+ && ($query = mysql_unbuffered_query('SHOW TABLES')))
8849
+ {
8850
+ $db = array();
8851
+ while ($row = mysql_fetch_row($query))
8852
+ {
8853
+ $db[] = $row[0];
8854
+ }
8855
+
8856
+ if (!in_array($this->options['prefix'][0] . 'cache_data', $db))
8857
+ {
8858
+ if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . 'cache_data` (`id` TEXT CHARACTER SET utf8 NOT NULL, `items` SMALLINT NOT NULL DEFAULT 0, `data` BLOB NOT NULL, `mtime` INT UNSIGNED NOT NULL, UNIQUE (`id`(125)))'))
8859
+ {
8860
+ $this->mysql = null;
8861
+ }
8862
+ }
8863
+
8864
+ if (!in_array($this->options['prefix'][0] . 'items', $db))
8865
+ {
8866
+ if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` TEXT CHARACTER SET utf8 NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))'))
8867
+ {
8868
+ $this->mysql = null;
8869
+ }
8870
+ }
8871
+ }
8872
+ else
8873
+ {
8874
+ $this->mysql = null;
8875
+ }
8876
+ }
8877
+ }
8878
+
8879
+ function save($data)
8880
+ {
8881
+ if ($this->mysql)
8882
+ {
8883
+ $feed_id = "'" . mysql_real_escape_string($this->id) . "'";
8884
+
8885
+ if (is_a($data, 'SimplePie'))
8886
+ {
8887
+ if (SIMPLEPIE_PHP5)
8888
+ {
8889
+ // This keyword needs to defy coding standards for PHP4 compatibility
8890
+ $data = clone($data);
8891
+ }
8892
+
8893
+ $prepared = $this->prepare_simplepie_object_for_cache($data);
8894
+
8895
+ if ($query = mysql_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = ' . $feed_id, $this->mysql))
8896
+ {
8897
+ if (mysql_num_rows($query))
8898
+ {
8899
+ $items = count($prepared[1]);
8900
+ if ($items)
8901
+ {
8902
+ $sql = 'UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `items` = ' . $items . ', `data` = \'' . mysql_real_escape_string($prepared[0]) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id;
8903
+ }
8904
+ else
8905
+ {
8906
+ $sql = 'UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `data` = \'' . mysql_real_escape_string($prepared[0]) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id;
8907
+ }
8908
+
8909
+ if (!mysql_query($sql, $this->mysql))
8910
+ {
8911
+ return false;
8912
+ }
8913
+ }
8914
+ elseif (!mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(' . $feed_id . ', ' . count($prepared[1]) . ', \'' . mysql_real_escape_string($prepared[0]) . '\', ' . time() . ')', $this->mysql))
8915
+ {
8916
+ return false;
8917
+ }
8918
+
8919
+ $ids = array_keys($prepared[1]);
8920
+ if (!empty($ids))
8921
+ {
8922
+ foreach ($ids as $id)
8923
+ {
8924
+ $database_ids[] = mysql_real_escape_string($id);
8925
+ }
8926
+
8927
+ if ($query = mysql_unbuffered_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'items` WHERE `id` = \'' . implode('\' OR `id` = \'', $database_ids) . '\' AND `feed_id` = ' . $feed_id, $this->mysql))
8928
+ {
8929
+ $existing_ids = array();
8930
+ while ($row = mysql_fetch_row($query))
8931
+ {
8932
+ $existing_ids[] = $row[0];
8933
+ }
8934
+
8935
+ $new_ids = array_diff($ids, $existing_ids);
8936
+
8937
+ foreach ($new_ids as $new_id)
8938
+ {
8939
+ if (!($date = $prepared[1][$new_id]->get_date('U')))
8940
+ {
8941
+ $date = time();
8942
+ }
8943
+
8944
+ if (!mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'items` (`feed_id`, `id`, `data`, `posted`) VALUES(' . $feed_id . ', \'' . mysql_real_escape_string($new_id) . '\', \'' . mysql_real_escape_string(serialize($prepared[1][$new_id]->data)) . '\', ' . $date . ')', $this->mysql))
8945
+ {
8946
+ return false;
8947
+ }
8948
+ }
8949
+ return true;
8950
+ }
8951
+ }
8952
+ else
8953
+ {
8954
+ return true;
8955
+ }
8956
+ }
8957
+ }
8958
+ elseif ($query = mysql_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = ' . $feed_id, $this->mysql))
8959
+ {
8960
+ if (mysql_num_rows($query))
8961
+ {
8962
+ if (mysql_query('UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `items` = 0, `data` = \'' . mysql_real_escape_string(serialize($data)) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id, $this->mysql))
8963
+ {
8964
+ return true;
8965
+ }
8966
+ }
8967
+ elseif (mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(\'' . mysql_real_escape_string($this->id) . '\', 0, \'' . mysql_real_escape_string(serialize($data)) . '\', ' . time() . ')', $this->mysql))
8968
+ {
8969
+ return true;
8970
+ }
8971
+ }
8972
+ }
8973
+ return false;
8974
+ }
8975
+
8976
+ function load()
8977
+ {
8978
+ if ($this->mysql && ($query = mysql_query('SELECT `items`, `data` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($row = mysql_fetch_row($query)))
8979
+ {
8980
+ $data = unserialize($row[1]);
8981
+
8982
+ if (isset($this->options['items'][0]))
8983
+ {
8984
+ $items = (int) $this->options['items'][0];
8985
+ }
8986
+ else
8987
+ {
8988
+ $items = (int) $row[0];
8989
+ }
8990
+
8991
+ if ($items !== 0)
8992
+ {
8993
+ if (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]))
8994
+ {
8995
+ $feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0];
8996
+ }
8997
+ elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]))
8998
+ {
8999
+ $feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0];
9000
+ }
9001
+ elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]))
9002
+ {
9003
+ $feed =& $data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0];
9004
+ }
9005
+ elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]))
9006
+ {
9007
+ $feed =& $data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0];
9008
+ }
9009
+ else
9010
+ {
9011
+ $feed = null;
9012
+ }
9013
+
9014
+ if ($feed !== null)
9015
+ {
9016
+ $sql = 'SELECT `data` FROM `' . $this->options['prefix'][0] . 'items` WHERE `feed_id` = \'' . mysql_real_escape_string($this->id) . '\' ORDER BY `posted` DESC';
9017
+ if ($items > 0)
9018
+ {
9019
+ $sql .= ' LIMIT ' . $items;
9020
+ }
9021
+
9022
+ if ($query = mysql_unbuffered_query($sql, $this->mysql))
9023
+ {
9024
+ while ($row = mysql_fetch_row($query))
9025
+ {
9026
+ $feed['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'][] = unserialize($row[0]);
9027
+ }
9028
+ }
9029
+ else
9030
+ {
9031
+ return false;
9032
+ }
9033
+ }
9034
+ }
9035
+ return $data;
9036
+ }
9037
+ return false;
9038
+ }
9039
+
9040
+ function mtime()
9041
+ {
9042
+ if ($this->mysql && ($query = mysql_query('SELECT `mtime` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($row = mysql_fetch_row($query)))
9043
+ {
9044
+ return $row[0];
9045
+ }
9046
+ else
9047
+ {
9048
+ return false;
9049
+ }
9050
+ }
9051
+
9052
+ function touch()
9053
+ {
9054
+ if ($this->mysql && ($query = mysql_query('UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `mtime` = ' . time() . ' WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && mysql_affected_rows($this->mysql))
9055
+ {
9056
+ return true;
9057
+ }
9058
+ else
9059
+ {
9060
+ return false;
9061
+ }
9062
+ }
9063
+
9064
+ function unlink()
9065
+ {
9066
+ if ($this->mysql && ($query = mysql_query('DELETE FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($query2 = mysql_query('DELETE FROM `' . $this->options['prefix'][0] . 'items` WHERE `feed_id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)))
9067
+ {
9068
+ return true;
9069
+ }
9070
+ else
9071
+ {
9072
+ return false;
9073
+ }
9074
+ }
9075
+ }
9076
+
9077
+ class SimplePie_Misc
9078
+ {
9079
+ function time_hms($seconds)
9080
+ {
9081
+ $time = '';
9082
+
9083
+ $hours = floor($seconds / 3600);
9084
+ $remainder = $seconds % 3600;
9085
+ if ($hours > 0)
9086
+ {
9087
+ $time .= $hours.':';
9088
+ }
9089
+
9090
+ $minutes = floor($remainder / 60);
9091
+ $seconds = $remainder % 60;
9092
+ if ($minutes < 10 && $hours > 0)
9093
+ {
9094
+ $minutes = '0' . $minutes;
9095
+ }
9096
+ if ($seconds < 10)
9097
+ {
9098
+ $seconds = '0' . $seconds;
9099
+ }
9100
+
9101
+ $time .= $minutes.':';
9102
+ $time .= $seconds;
9103
+
9104
+ return $time;
9105
+ }
9106
+
9107
+ function absolutize_url($relative, $base)
9108
+ {
9109
+ $iri = SimplePie_IRI::absolutize(new SimplePie_IRI($base), $relative);
9110
+ return $iri->get_iri();
9111
+ }
9112
+
9113
+ function remove_dot_segments($input)
9114
+ {
9115
+ $output = '';
9116
+ while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..')
9117
+ {
9118
+ // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise,
9119
+ if (strpos($input, '../') === 0)
9120
+ {
9121
+ $input = substr($input, 3);
9122
+ }
9123
+ elseif (strpos($input, './') === 0)
9124
+ {
9125
+ $input = substr($input, 2);
9126
+ }
9127
+ // B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise,
9128
+ elseif (strpos($input, '/./') === 0)
9129
+ {
9130
+ $input = substr_replace($input, '/', 0, 3);
9131
+ }
9132
+ elseif ($input === '/.')
9133
+ {
9134
+ $input = '/';
9135
+ }
9136
+ // C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise,
9137
+ elseif (strpos($input, '/../') === 0)
9138
+ {
9139
+ $input = substr_replace($input, '/', 0, 4);
9140
+ $output = substr_replace($output, '', strrpos($output, '/'));
9141
+ }
9142
+ elseif ($input === '/..')
9143
+ {
9144
+ $input = '/';
9145
+ $output = substr_replace($output, '', strrpos($output, '/'));
9146
+ }
9147
+ // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise,
9148
+ elseif ($input === '.' || $input === '..')
9149
+ {
9150
+ $input = '';
9151
+ }
9152
+ // E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer
9153
+ elseif (($pos = strpos($input, '/', 1)) !== false)
9154
+ {
9155
+ $output .= substr($input, 0, $pos);
9156
+ $input = substr_replace($input, '', 0, $pos);
9157
+ }
9158
+ else
9159
+ {
9160
+ $output .= $input;
9161
+ $input = '';
9162
+ }
9163
+ }
9164
+ return $output . $input;
9165
+ }
9166
+
9167
+ function get_element($realname, $string)
9168
+ {
9169
+ $return = array();
9170
+ $name = preg_quote($realname, '/');
9171
+ if (preg_match_all("/<($name)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE))
9172
+ {
9173
+ for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++)
9174
+ {
9175
+ $return[$i]['tag'] = $realname;
9176
+ $return[$i]['full'] = $matches[$i][0][0];
9177
+ $return[$i]['offset'] = $matches[$i][0][1];
9178
+ if (strlen($matches[$i][3][0]) <= 2)
9179
+ {
9180
+ $return[$i]['self_closing'] = true;
9181
+ }
9182
+ else
9183
+ {
9184
+ $return[$i]['self_closing'] = false;
9185
+ $return[$i]['content'] = $matches[$i][4][0];
9186
+ }
9187
+ $return[$i]['attribs'] = array();
9188
+ if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER))
9189
+ {
9190
+ for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++)
9191
+ {
9192
+ if (count($attribs[$j]) === 2)
9193
+ {
9194
+ $attribs[$j][2] = $attribs[$j][1];
9195
+ }
9196
+ $return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = SimplePie_Misc::entities_decode(end($attribs[$j]), 'UTF-8');
9197
+ }
9198
+ }
9199
+ }
9200
+ }
9201
+ return $return;
9202
+ }
9203
+
9204
+ function element_implode($element)
9205
+ {
9206
+ $full = "<$element[tag]";
9207
+ foreach ($element['attribs'] as $key => $value)
9208
+ {
9209
+ $key = strtolower($key);
9210
+ $full .= " $key=\"" . htmlspecialchars($value['data']) . '"';
9211
+ }
9212
+ if ($element['self_closing'])
9213
+ {
9214
+ $full .= ' />';
9215
+ }
9216
+ else
9217
+ {
9218
+ $full .= ">$element[content]</$element[tag]>";
9219
+ }
9220
+ return $full;
9221
+ }
9222
+
9223
+ function error($message, $level, $file, $line)
9224
+ {
9225
+ if ((ini_get('error_reporting') & $level) > 0)
9226
+ {
9227
+ switch ($level)
9228
+ {
9229
+ case E_USER_ERROR:
9230
+ $note = 'PHP Error';
9231
+ break;
9232
+ case E_USER_WARNING:
9233
+ $note = 'PHP Warning';
9234
+ break;
9235
+ case E_USER_NOTICE:
9236
+ $note = 'PHP Notice';
9237
+ break;
9238
+ default:
9239
+ $note = 'Unknown Error';
9240
+ break;
9241
+ }
9242
+
9243
+ $log_error = true;
9244
+ if (!function_exists('error_log'))
9245
+ {
9246
+ $log_error = false;
9247
+ }
9248
+
9249
+ $log_file = @ini_get('error_log');
9250
+ if (!empty($log_file) && ('syslog' != $log_file) && !@is_writable($log_file))
9251
+ {
9252
+ $log_error = false;
9253
+ }
9254
+
9255
+ if ($log_error)
9256
+ {
9257
+ @error_log("$note: $message in $file on line $line", 0);
9258
+ }
9259
+ }
9260
+
9261
+ return $message;
9262
+ }
9263
+
9264
+ /**
9265
+ * If a file has been cached, retrieve and display it.
9266
+ *
9267
+ * This is most useful for caching images (get_favicon(), etc.),
9268
+ * however it works for all cached files. This WILL NOT display ANY
9269
+ * file/image/page/whatever, but rather only display what has already
9270
+ * been cached by SimplePie.
9271
+ *
9272
+ * @access public
9273
+ * @see SimplePie::get_favicon()
9274
+ * @param str $identifier_url URL that is used to identify the content.
9275
+ * This may or may not be the actual URL of the live content.
9276
+ * @param str $cache_location Location of SimplePie's cache. Defaults
9277
+ * to './cache'.
9278
+ * @param str $cache_extension The file extension that the file was
9279
+ * cached with. Defaults to 'spc'.
9280
+ * @param str $cache_class Name of the cache-handling class being used
9281
+ * in SimplePie. Defaults to 'SimplePie_Cache', and should be left
9282
+ * as-is unless you've overloaded the class.
9283
+ * @param str $cache_name_function Obsolete. Exists for backwards
9284
+ * compatibility reasons only.
9285
+ */
9286
+ function display_cached_file($identifier_url, $cache_location = './cache', $cache_extension = 'spc', $cache_class = 'SimplePie_Cache', $cache_name_function = 'md5')
9287
+ {
9288
+ $cache = call_user_func(array($cache_class, 'create'), $cache_location, $identifier_url, $cache_extension);
9289
+
9290
+ if ($file = $cache->load())
9291
+ {
9292
+ if (isset($file['headers']['content-type']))
9293
+ {
9294
+ header('Content-type:' . $file['headers']['content-type']);
9295
+ }
9296
+ else
9297
+ {
9298
+ header('Content-type: application/octet-stream');
9299
+ }
9300
+ header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
9301
+ echo $file['body'];
9302
+ exit;
9303
+ }
9304
+
9305
+ die('Cached file for ' . $identifier_url . ' cannot be found.');
9306
+ }
9307
+
9308
+ function fix_protocol($url, $http = 1)
9309
+ {
9310
+ $url = SimplePie_Misc::normalize_url($url);
9311
+ $parsed = SimplePie_Misc::parse_url($url);
9312
+ if ($parsed['scheme'] !== '' && $parsed['scheme'] !== 'http' && $parsed['scheme'] !== 'https')
9313
+ {
9314
+ return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http);
9315
+ }
9316
+
9317
+ if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url))
9318
+ {
9319
+ return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http);
9320
+ }
9321
+
9322
+ if ($http === 2 && $parsed['scheme'] !== '')
9323
+ {
9324
+ return "feed:$url";
9325
+ }
9326
+ elseif ($http === 3 && strtolower($parsed['scheme']) === 'http')
9327
+ {
9328
+ return substr_replace($url, 'podcast', 0, 4);
9329
+ }
9330
+ elseif ($http === 4 && strtolower($parsed['scheme']) === 'http')
9331
+ {
9332
+ return substr_replace($url, 'itpc', 0, 4);
9333
+ }
9334
+ else
9335
+ {
9336
+ return $url;
9337
+ }
9338
+ }
9339
+
9340
+ function parse_url($url)
9341
+ {
9342
+ $iri = new SimplePie_IRI($url);
9343
+ return array(
9344
+ 'scheme' => (string) $iri->get_scheme(),
9345
+ 'authority' => (string) $iri->get_authority(),
9346
+ 'path' => (string) $iri->get_path(),
9347
+ 'query' => (string) $iri->get_query(),
9348
+ 'fragment' => (string) $iri->get_fragment()
9349
+ );
9350
+ }
9351
+
9352
+ function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '')
9353
+ {
9354
+ $iri = new SimplePie_IRI('');
9355
+ $iri->set_scheme($scheme);
9356
+ $iri->set_authority($authority);
9357
+ $iri->set_path($path);
9358
+ $iri->set_query($query);
9359
+ $iri->set_fragment($fragment);
9360
+ return $iri->get_iri();
9361
+ }
9362
+
9363
+ function normalize_url($url)
9364
+ {
9365
+ $iri = new SimplePie_IRI($url);
9366
+ return $iri->get_iri();
9367
+ }
9368
+
9369
+ function percent_encoding_normalization($match)
9370
+ {
9371
+ $integer = hexdec($match[1]);
9372
+ if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E)
9373
+ {
9374
+ return chr($integer);
9375
+ }
9376
+ else
9377
+ {
9378
+ return strtoupper($match[0]);
9379
+ }
9380
+ }
9381
+
9382
+ /**
9383
+ * Remove bad UTF-8 bytes
9384
+ *
9385
+ * PCRE Pattern to locate bad bytes in a UTF-8 string comes from W3C
9386
+ * FAQ: Multilingual Forms (modified to include full ASCII range)
9387
+ *
9388
+ * @author Geoffrey Sneddon
9389
+ * @see http://www.w3.org/International/questions/qa-forms-utf-8
9390
+ * @param string $str String to remove bad UTF-8 bytes from
9391
+ * @return string UTF-8 string
9392
+ */
9393
+ function utf8_bad_replace($str)
9394
+ {
9395
+ if (function_exists('iconv') && ($return = @iconv('UTF-8', 'UTF-8//IGNORE', $str)))
9396
+ {
9397
+ return $return;
9398
+ }
9399
+ elseif (function_exists('mb_convert_encoding') && ($return = @mb_convert_encoding($str, 'UTF-8', 'UTF-8')))
9400
+ {
9401
+ return $return;
9402
+ }
9403
+ elseif (preg_match_all('/(?:[\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})+/', $str, $matches))
9404
+ {
9405
+ return implode("\xEF\xBF\xBD", $matches[0]);
9406
+ }
9407
+ elseif ($str !== '')
9408
+ {
9409
+ return "\xEF\xBF\xBD";
9410
+ }
9411
+ else
9412
+ {
9413
+ return '';
9414
+ }
9415
+ }
9416
+
9417
+ /**
9418
+ * Converts a Windows-1252 encoded string to a UTF-8 encoded string
9419
+ *
9420
+ * @static
9421
+ * @access public
9422
+ * @param string $string Windows-1252 encoded string
9423
+ * @return string UTF-8 encoded string
9424
+ */
9425
+ function windows_1252_to_utf8($string)
9426
+ {
9427
+ static $convert_table = array("\x80" => "\xE2\x82\xAC", "\x81" => "\xEF\xBF\xBD", "\x82" => "\xE2\x80\x9A", "\x83" => "\xC6\x92", "\x84" => "\xE2\x80\x9E", "\x85" => "\xE2\x80\xA6", "\x86" => "\xE2\x80\xA0", "\x87" => "\xE2\x80\xA1", "\x88" => "\xCB\x86", "\x89" => "\xE2\x80\xB0", "\x8A" => "\xC5\xA0", "\x8B" => "\xE2\x80\xB9", "\x8C" => "\xC5\x92", "\x8D" => "\xEF\xBF\xBD", "\x8E" => "\xC5\xBD", "\x8F" => "\xEF\xBF\xBD", "\x90" => "\xEF\xBF\xBD", "\x91" => "\xE2\x80\x98", "\x92" => "\xE2\x80\x99", "\x93" => "\xE2\x80\x9C", "\x94" => "\xE2\x80\x9D", "\x95" => "\xE2\x80\xA2", "\x96" => "\xE2\x80\x93", "\x97" => "\xE2\x80\x94", "\x98" => "\xCB\x9C", "\x99" => "\xE2\x84\xA2", "\x9A" => "\xC5\xA1", "\x9B" => "\xE2\x80\xBA", "\x9C" => "\xC5\x93", "\x9D" => "\xEF\xBF\xBD", "\x9E" => "\xC5\xBE", "\x9F" => "\xC5\xB8", "\xA0" => "\xC2\xA0", "\xA1" => "\xC2\xA1", "\xA2" => "\xC2\xA2", "\xA3" => "\xC2\xA3", "\xA4" => "\xC2\xA4", "\xA5" => "\xC2\xA5", "\xA6" => "\xC2\xA6", "\xA7" => "\xC2\xA7", "\xA8" => "\xC2\xA8", "\xA9" => "\xC2\xA9", "\xAA" => "\xC2\xAA", "\xAB" => "\xC2\xAB", "\xAC" => "\xC2\xAC", "\xAD" => "\xC2\xAD", "\xAE" => "\xC2\xAE", "\xAF" => "\xC2\xAF", "\xB0" => "\xC2\xB0", "\xB1" => "\xC2\xB1", "\xB2" => "\xC2\xB2", "\xB3" => "\xC2\xB3", "\xB4" => "\xC2\xB4", "\xB5" => "\xC2\xB5", "\xB6" => "\xC2\xB6", "\xB7" => "\xC2\xB7", "\xB8" => "\xC2\xB8", "\xB9" => "\xC2\xB9", "\xBA" => "\xC2\xBA", "\xBB" => "\xC2\xBB", "\xBC" => "\xC2\xBC", "\xBD" => "\xC2\xBD", "\xBE" => "\xC2\xBE", "\xBF" => "\xC2\xBF", "\xC0" => "\xC3\x80", "\xC1" => "\xC3\x81", "\xC2" => "\xC3\x82", "\xC3" => "\xC3\x83", "\xC4" => "\xC3\x84", "\xC5" => "\xC3\x85", "\xC6" => "\xC3\x86", "\xC7" => "\xC3\x87", "\xC8" => "\xC3\x88", "\xC9" => "\xC3\x89", "\xCA" => "\xC3\x8A", "\xCB" => "\xC3\x8B", "\xCC" => "\xC3\x8C", "\xCD" => "\xC3\x8D", "\xCE" => "\xC3\x8E", "\xCF" => "\xC3\x8F", "\xD0" => "\xC3\x90", "\xD1" => "\xC3\x91", "\xD2" => "\xC3\x92", "\xD3" => "\xC3\x93", "\xD4" => "\xC3\x94", "\xD5" => "\xC3\x95", "\xD6" => "\xC3\x96", "\xD7" => "\xC3\x97", "\xD8" => "\xC3\x98", "\xD9" => "\xC3\x99", "\xDA" => "\xC3\x9A", "\xDB" => "\xC3\x9B", "\xDC" => "\xC3\x9C", "\xDD" => "\xC3\x9D", "\xDE" => "\xC3\x9E", "\xDF" => "\xC3\x9F", "\xE0" => "\xC3\xA0", "\xE1" => "\xC3\xA1", "\xE2" => "\xC3\xA2", "\xE3" => "\xC3\xA3", "\xE4" => "\xC3\xA4", "\xE5" => "\xC3\xA5", "\xE6" => "\xC3\xA6", "\xE7" => "\xC3\xA7", "\xE8" => "\xC3\xA8", "\xE9" => "\xC3\xA9", "\xEA" => "\xC3\xAA", "\xEB" => "\xC3\xAB", "\xEC" => "\xC3\xAC", "\xED" => "\xC3\xAD", "\xEE" => "\xC3\xAE", "\xEF" => "\xC3\xAF", "\xF0" => "\xC3\xB0", "\xF1" => "\xC3\xB1", "\xF2" => "\xC3\xB2", "\xF3" => "\xC3\xB3", "\xF4" => "\xC3\xB4", "\xF5" => "\xC3\xB5", "\xF6" => "\xC3\xB6", "\xF7" => "\xC3\xB7", "\xF8" => "\xC3\xB8", "\xF9" => "\xC3\xB9", "\xFA" => "\xC3\xBA", "\xFB" => "\xC3\xBB", "\xFC" => "\xC3\xBC", "\xFD" => "\xC3\xBD", "\xFE" => "\xC3\xBE", "\xFF" => "\xC3\xBF");
9428
+
9429
+ return strtr($string, $convert_table);
9430
+ }
9431
+
9432
+ function change_encoding($data, $input, $output)
9433
+ {
9434
+ $input = SimplePie_Misc::encoding($input);
9435
+ $output = SimplePie_Misc::encoding($output);
9436
+
9437
+ // We fail to fail on non US-ASCII bytes
9438
+ if ($input === 'US-ASCII')
9439
+ {
9440
+ static $non_ascii_octects = '';
9441
+ if (!$non_ascii_octects)
9442
+ {
9443
+ for ($i = 0x80; $i <= 0xFF; $i++)
9444
+ {
9445
+ $non_ascii_octects .= chr($i);
9446
+ }
9447
+ }
9448
+ $data = substr($data, 0, strcspn($data, $non_ascii_octects));
9449
+ }
9450
+
9451
+ // This is first, as behaviour of this is completely predictable
9452
+ if ($input === 'Windows-1252' && $output === 'UTF-8')
9453
+ {
9454
+ return SimplePie_Misc::windows_1252_to_utf8($data);
9455
+ }
9456
+ // This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported).
9457
+ elseif (function_exists('mb_convert_encoding') && @mb_convert_encoding("\x80", 'UTF-16BE', $input) !== "\x00\x80" && ($return = @mb_convert_encoding($data, $output, $input)))
9458
+ {
9459
+ return $return;
9460
+ }
9461
+ // This is last, as behaviour of this varies with OS userland and PHP version
9462
+ elseif (function_exists('iconv') && ($return = @iconv($input, $output, $data)))
9463
+ {
9464
+ return $return;
9465
+ }
9466
+ // If we can't do anything, just fail
9467
+ else
9468
+ {
9469
+ return false;
9470
+ }
9471
+ }
9472
+
9473
+ function encoding($charset)
9474
+ {
9475
+ // Normalization from UTS #22
9476
+ switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset)))
9477
+ {
9478
+ case 'adobestandardencoding':
9479
+ case 'csadobestandardencoding':
9480
+ return 'Adobe-Standard-Encoding';
9481
+
9482
+ case 'adobesymbolencoding':
9483
+ case 'cshppsmath':
9484
+ return 'Adobe-Symbol-Encoding';
9485
+
9486
+ case 'ami1251':
9487
+ case 'amiga1251':
9488
+ return 'Amiga-1251';
9489
+
9490
+ case 'ansix31101983':
9491
+ case 'csat5001983':
9492
+ case 'csiso99naplps':
9493
+ case 'isoir99':
9494
+ case 'naplps':
9495
+ return 'ANSI_X3.110-1983';
9496
+
9497
+ case 'arabic7':
9498
+ case 'asmo449':
9499
+ case 'csiso89asmo449':
9500
+ case 'iso9036':
9501
+ case 'isoir89':
9502
+ return 'ASMO_449';
9503
+
9504
+ case 'big5':
9505
+ case 'csbig5':
9506
+ case 'xxbig5':
9507
+ return 'Big5';
9508
+
9509
+ case 'big5hkscs':
9510
+ return 'Big5-HKSCS';
9511
+
9512
+ case 'bocu1':
9513
+ case 'csbocu1':
9514
+ return 'BOCU-1';
9515
+
9516
+ case 'brf':
9517
+ case 'csbrf':
9518
+ return 'BRF';
9519
+
9520
+ case 'bs4730':
9521
+ case 'csiso4unitedkingdom':
9522
+ case 'gb':
9523
+ case 'iso646gb':
9524
+ case 'isoir4':
9525
+ case 'uk':
9526
+ return 'BS_4730';
9527
+
9528
+ case 'bsviewdata':
9529
+ case 'csiso47bsviewdata':
9530
+ case 'isoir47':
9531
+ return 'BS_viewdata';
9532
+
9533
+ case 'cesu8':
9534
+ case 'cscesu8':
9535
+ return 'CESU-8';
9536
+
9537
+ case 'ca':
9538
+ case 'csa71':
9539
+ case 'csaz243419851':
9540
+ case 'csiso121canadian1':
9541
+ case 'iso646ca':
9542
+ case 'isoir121':
9543
+ return 'CSA_Z243.4-1985-1';
9544
+
9545
+ case 'csa72':
9546
+ case 'csaz243419852':
9547
+ case 'csiso122canadian2':
9548
+ case 'iso646ca2':
9549
+ case 'isoir122':
9550
+ return 'CSA_Z243.4-1985-2';
9551
+
9552
+ case 'csaz24341985gr':
9553
+ case 'csiso123csaz24341985gr':
9554
+ case 'isoir123':
9555
+ return 'CSA_Z243.4-1985-gr';
9556
+
9557
+ case 'csiso139csn369103':
9558
+ case 'csn369103':
9559
+ case 'isoir139':
9560
+ return 'CSN_369103';
9561
+
9562
+ case 'csdecmcs':
9563
+ case 'dec':
9564
+ case 'decmcs':
9565
+ return 'DEC-MCS';
9566
+
9567
+ case 'csiso21german':
9568
+ case 'de':
9569
+ case 'din66003':
9570
+ case 'iso646de':
9571
+ case 'isoir21':
9572
+ return 'DIN_66003';
9573
+
9574
+ case 'csdkus':
9575
+ case 'dkus':
9576
+ return 'dk-us';
9577
+
9578
+ case 'csiso646danish':
9579
+ case 'dk':
9580
+ case 'ds2089':
9581
+ case 'iso646dk':
9582
+ return 'DS_2089';
9583
+
9584
+ case 'csibmebcdicatde':
9585
+ case 'ebcdicatde':
9586
+ return 'EBCDIC-AT-DE';
9587
+
9588
+ case 'csebcdicatdea':
9589
+ case 'ebcdicatdea':
9590
+ return 'EBCDIC-AT-DE-A';
9591
+
9592
+ case 'csebcdiccafr':
9593
+ case 'ebcdiccafr':
9594
+ return 'EBCDIC-CA-FR';
9595
+
9596
+ case 'csebcdicdkno':
9597
+ case 'ebcdicdkno':
9598
+ return 'EBCDIC-DK-NO';
9599
+
9600
+ case 'csebcdicdknoa':
9601
+ case 'ebcdicdknoa':
9602
+ return 'EBCDIC-DK-NO-A';
9603
+
9604
+ case 'csebcdices':
9605
+ case 'ebcdices':
9606
+ return 'EBCDIC-ES';
9607
+
9608
+ case 'csebcdicesa':
9609
+ case 'ebcdicesa':
9610
+ return 'EBCDIC-ES-A';
9611
+
9612
+ case 'csebcdicess':
9613
+ case 'ebcdicess':
9614
+ return 'EBCDIC-ES-S';
9615
+
9616
+ case 'csebcdicfise':
9617
+ case 'ebcdicfise':
9618
+ return 'EBCDIC-FI-SE';
9619
+
9620
+ case 'csebcdicfisea':
9621
+ case 'ebcdicfisea':
9622
+ return 'EBCDIC-FI-SE-A';
9623
+
9624
+ case 'csebcdicfr':
9625
+ case 'ebcdicfr':
9626
+ return 'EBCDIC-FR';
9627
+
9628
+ case 'csebcdicit':
9629
+ case 'ebcdicit':
9630
+ return 'EBCDIC-IT';
9631
+
9632
+ case 'csebcdicpt':
9633
+ case 'ebcdicpt':
9634
+ return 'EBCDIC-PT';
9635
+
9636
+ case 'csebcdicuk':
9637
+ case 'ebcdicuk':
9638
+ return 'EBCDIC-UK';
9639
+
9640
+ case 'csebcdicus':
9641
+ case 'ebcdicus':
9642
+ return 'EBCDIC-US';
9643
+
9644
+ case 'csiso111ecmacyrillic':
9645
+ case 'ecmacyrillic':
9646
+ case 'isoir111':
9647
+ case 'koi8e':
9648
+ return 'ECMA-cyrillic';
9649
+
9650
+ case 'csiso17spanish':
9651
+ case 'es':
9652
+ case 'iso646es':
9653
+ case 'isoir17':
9654
+ return 'ES';
9655
+
9656
+ case 'csiso85spanish2':
9657
+ case 'es2':
9658
+ case 'iso646es2':
9659
+ case 'isoir85':
9660
+ return 'ES2';
9661
+
9662
+ case 'cseucfixwidjapanese':
9663
+ case 'extendedunixcodefixedwidthforjapanese':
9664
+ return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
9665
+
9666
+ case 'cseucpkdfmtjapanese':
9667
+ case 'eucjp':
9668
+ case 'extendedunixcodepackedformatforjapanese':
9669
+ return 'Extended_UNIX_Code_Packed_Format_for_Japanese';
9670
+
9671
+ case 'gb18030':
9672
+ return 'GB18030';
9673
+
9674
+ case 'chinese':
9675
+ case 'cp936':
9676
+ case 'csgb2312':
9677
+ case 'csiso58gb231280':
9678
+ case 'gb2312':
9679
+ case 'gb231280':
9680
+ case 'gbk':
9681
+ case 'isoir58':
9682
+ case 'ms936':
9683
+ case 'windows936':
9684
+ return 'GBK';
9685
+
9686
+ case 'cn':
9687
+ case 'csiso57gb1988':
9688
+ case 'gb198880':
9689
+ case 'iso646cn':
9690
+ case 'isoir57':
9691
+ return 'GB_1988-80';
9692
+
9693
+ case 'csiso153gost1976874':
9694
+ case 'gost1976874':
9695
+ case 'isoir153':
9696
+ case 'stsev35888':
9697
+ return 'GOST_19768-74';
9698
+
9699
+ case 'csiso150':
9700
+ case 'csiso150greekccitt':
9701
+ case 'greekccitt':
9702
+ case 'isoir150':
9703
+ return 'greek-ccitt';
9704
+
9705
+ case 'csiso88greek7':
9706
+ case 'greek7':
9707
+ case 'isoir88':
9708
+ return 'greek7';
9709
+
9710
+ case 'csiso18greek7old':
9711
+ case 'greek7old':
9712
+ case 'isoir18':
9713
+ return 'greek7-old';
9714
+
9715
+ case 'cshpdesktop':
9716
+ case 'hpdesktop':
9717
+ return 'HP-DeskTop';
9718
+
9719
+ case 'cshplegal':
9720
+ case 'hplegal':
9721
+ return 'HP-Legal';
9722
+
9723
+ case 'cshpmath8':
9724
+ case 'hpmath8':
9725
+ return 'HP-Math8';
9726
+
9727
+ case 'cshppifont':
9728
+ case 'hppifont':
9729
+ return 'HP-Pi-font';
9730
+
9731
+ case 'cshproman8':
9732
+ case 'hproman8':
9733
+ case 'r8':
9734
+ case 'roman8':
9735
+ return 'hp-roman8';
9736
+
9737
+ case 'hzgb2312':
9738
+ return 'HZ-GB-2312';
9739
+
9740
+ case 'csibmsymbols':
9741
+ case 'ibmsymbols':
9742
+ return 'IBM-Symbols';
9743
+
9744
+ case 'csibmthai':
9745
+ case 'ibmthai':
9746
+ return 'IBM-Thai';
9747
+
9748
+ case 'ccsid858':
9749
+ case 'cp858':
9750
+ case 'ibm858':
9751
+ case 'pcmultilingual850euro':
9752
+ return 'IBM00858';
9753
+
9754
+ case 'ccsid924':
9755
+ case 'cp924':
9756
+ case 'ebcdiclatin9euro':
9757
+ case 'ibm924':
9758
+ return 'IBM00924';
9759
+
9760
+ case 'ccsid1140':
9761
+ case 'cp1140':
9762
+ case 'ebcdicus37euro':
9763
+ case 'ibm1140':
9764
+ return 'IBM01140';
9765
+
9766
+ case 'ccsid1141':
9767
+ case 'cp1141':
9768
+ case 'ebcdicde273euro':
9769
+ case 'ibm1141':
9770
+ return 'IBM01141';
9771
+
9772
+ case 'ccsid1142':
9773
+ case 'cp1142':
9774
+ case 'ebcdicdk277euro':
9775
+ case 'ebcdicno277euro':
9776
+ case 'ibm1142':
9777
+ return 'IBM01142';
9778
+
9779
+ case 'ccsid1143':
9780
+ case 'cp1143':
9781
+ case 'ebcdicfi278euro':
9782
+ case 'ebcdicse278euro':
9783
+ case 'ibm1143':
9784
+ return 'IBM01143';
9785
+
9786
+ case 'ccsid1144':
9787
+ case 'cp1144':
9788
+ case 'ebcdicit280euro':
9789
+ case 'ibm1144':
9790
+ return 'IBM01144';
9791
+
9792
+ case 'ccsid1145':
9793
+ case 'cp1145':
9794
+ case 'ebcdices284euro':
9795
+ case 'ibm1145':
9796
+ return 'IBM01145';
9797
+
9798
+ case 'ccsid1146':
9799
+ case 'cp1146':
9800
+ case 'ebcdicgb285euro':
9801
+ case 'ibm1146':
9802
+ return 'IBM01146';
9803
+
9804
+ case 'ccsid1147':
9805
+ case 'cp1147':
9806
+ case 'ebcdicfr297euro':
9807
+ case 'ibm1147':
9808
+ return 'IBM01147';
9809
+
9810
+ case 'ccsid1148':
9811
+ case 'cp1148':
9812
+ case 'ebcdicinternational500euro':
9813
+ case 'ibm1148':
9814
+ return 'IBM01148';
9815
+
9816
+ case 'ccsid1149':
9817
+ case 'cp1149':
9818
+ case 'ebcdicis871euro':
9819
+ case 'ibm1149':
9820
+ return 'IBM01149';
9821
+
9822
+ case 'cp37':
9823
+ case 'csibm37':
9824
+ case 'ebcdiccpca':
9825
+ case 'ebcdiccpnl':
9826
+ case 'ebcdiccpus':
9827
+ case 'ebcdiccpwt':
9828
+ case 'ibm37':
9829
+ return 'IBM037';
9830
+
9831
+ case 'cp38':
9832
+ case 'csibm38':
9833
+ case 'ebcdicint':
9834
+ case 'ibm38':
9835
+ return 'IBM038';
9836
+
9837
+ case 'cp273':
9838
+ case 'csibm273':
9839
+ case 'ibm273':
9840
+ return 'IBM273';
9841
+
9842
+ case 'cp274':
9843
+ case 'csibm274':
9844
+ case 'ebcdicbe':
9845
+ case 'ibm274':
9846
+ return 'IBM274';
9847
+
9848
+ case 'cp275':
9849
+ case 'csibm275':
9850
+ case 'ebcdicbr':
9851
+ case 'ibm275':
9852
+ return 'IBM275';
9853
+
9854
+ case 'csibm277':
9855
+ case 'ebcdiccpdk':
9856
+ case 'ebcdiccpno':
9857
+ case 'ibm277':
9858
+ return 'IBM277';
9859
+
9860
+ case 'cp278':
9861
+ case 'csibm278':
9862
+ case 'ebcdiccpfi':
9863
+ case 'ebcdiccpse':
9864
+ case 'ibm278':
9865
+ return 'IBM278';
9866
+
9867
+ case 'cp280':
9868
+ case 'csibm280':
9869
+ case 'ebcdiccpit':
9870
+ case 'ibm280':
9871
+ return 'IBM280';
9872
+
9873
+ case 'cp281':
9874
+ case 'csibm281':
9875
+ case 'ebcdicjpe':
9876
+ case 'ibm281':
9877
+ return 'IBM281';
9878
+
9879
+ case 'cp284':
9880
+ case 'csibm284':
9881
+ case 'ebcdiccpes':
9882
+ case 'ibm284':
9883
+ return 'IBM284';
9884
+
9885
+ case 'cp285':
9886
+ case 'csibm285':
9887
+ case 'ebcdiccpgb':
9888
+ case 'ibm285':
9889
+ return 'IBM285';
9890
+
9891
+ case 'cp290':
9892
+ case 'csibm290':
9893
+ case 'ebcdicjpkana':
9894
+ case 'ibm290':
9895
+ return 'IBM290';
9896
+
9897
+ case 'cp297':
9898
+ case 'csibm297':
9899
+ case 'ebcdiccpfr':
9900
+ case 'ibm297':
9901
+ return 'IBM297';
9902
+
9903
+ case 'cp420':
9904
+ case 'csibm420':
9905
+ case 'ebcdiccpar1':
9906
+ case 'ibm420':
9907
+ return 'IBM420';
9908
+
9909
+ case 'cp423':
9910
+ case 'csibm423':
9911
+ case 'ebcdiccpgr':
9912
+ case 'ibm423':
9913
+ return 'IBM423';
9914
+
9915
+ case 'cp424':
9916
+ case 'csibm424':
9917
+ case 'ebcdiccphe':
9918
+ case 'ibm424':
9919
+ return 'IBM424';
9920
+
9921
+ case '437':
9922
+ case 'cp437':
9923
+ case 'cspc8codepage437':
9924
+ case 'ibm437':
9925
+ return 'IBM437';
9926
+
9927
+ case 'cp500':
9928
+ case 'csibm500':
9929
+ case 'ebcdiccpbe':
9930
+ case 'ebcdiccpch':
9931
+ case 'ibm500':
9932
+ return 'IBM500';
9933
+
9934
+ case 'cp775':
9935
+ case 'cspc775baltic':
9936
+ case 'ibm775':
9937
+ return 'IBM775';
9938
+
9939
+ case '850':
9940
+ case 'cp850':
9941
+ case 'cspc850multilingual':
9942
+ case 'ibm850':
9943
+ return 'IBM850';
9944
+
9945
+ case '851':
9946
+ case 'cp851':
9947
+ case 'csibm851':
9948
+ case 'ibm851':
9949
+ return 'IBM851';
9950
+
9951
+ case '852':
9952
+ case 'cp852':
9953
+ case 'cspcp852':
9954
+ case 'ibm852':
9955
+ return 'IBM852';
9956
+
9957
+ case '855':
9958
+ case 'cp855':
9959
+ case 'csibm855':
9960
+ case 'ibm855':
9961
+ return 'IBM855';
9962
+
9963
+ case '857':
9964
+ case 'cp857':
9965
+ case 'csibm857':
9966
+ case 'ibm857':
9967
+ return 'IBM857';
9968
+
9969
+ case '860':
9970
+ case 'cp860':
9971
+ case 'csibm860':
9972
+ case 'ibm860':
9973
+ return 'IBM860';
9974
+
9975
+ case '861':
9976
+ case 'cp861':
9977
+ case 'cpis':
9978
+ case 'csibm861':
9979
+ case 'ibm861':
9980
+ return 'IBM861';
9981
+
9982
+ case '862':
9983
+ case 'cp862':
9984
+ case 'cspc862latinhebrew':
9985
+ case 'ibm862':
9986
+ return 'IBM862';
9987
+
9988
+ case '863':
9989
+ case 'cp863':
9990
+ case 'csibm863':
9991
+ case 'ibm863':
9992
+ return 'IBM863';
9993
+
9994
+ case 'cp864':
9995
+ case 'csibm864':
9996
+ case 'ibm864':
9997
+ return 'IBM864';
9998
+
9999
+ case '865':
10000
+ case 'cp865':
10001
+ case 'csibm865':
10002
+ case 'ibm865':
10003
+ return 'IBM865';
10004
+
10005
+ case '866':
10006
+ case 'cp866':
10007
+ case 'csibm866':
10008
+ case 'ibm866':
10009
+ return 'IBM866';
10010
+
10011
+ case 'cp868':
10012
+ case 'cpar':
10013
+ case 'csibm868':
10014
+ case 'ibm868':
10015
+ return 'IBM868';
10016
+
10017
+ case '869':
10018
+ case 'cp869':
10019
+ case 'cpgr':
10020
+ case 'csibm869':
10021
+ case 'ibm869':
10022
+ return 'IBM869';
10023
+
10024
+ case 'cp870':
10025
+ case 'csibm870':
10026
+ case 'ebcdiccproece':
10027
+ case 'ebcdiccpyu':
10028
+ case 'ibm870':
10029
+ return 'IBM870';
10030
+
10031
+ case 'cp871':
10032
+ case 'csibm871':
10033
+ case 'ebcdiccpis':
10034
+ case 'ibm871':
10035
+ return 'IBM871';
10036
+
10037
+ case 'cp880':
10038
+ case 'csibm880':
10039
+ case 'ebcdiccyrillic':
10040
+ case 'ibm880':
10041
+ return 'IBM880';
10042
+
10043
+ case 'cp891':
10044
+ case 'csibm891':
10045
+ case 'ibm891':
10046
+ return 'IBM891';
10047
+
10048
+ case 'cp903':
10049
+ case 'csibm903':
10050
+ case 'ibm903':
10051
+ return 'IBM903';
10052
+
10053
+ case '904':
10054
+ case 'cp904':
10055
+ case 'csibbm904':
10056
+ case 'ibm904':
10057
+ return 'IBM904';
10058
+
10059
+ case 'cp905':
10060
+ case 'csibm905':
10061
+ case 'ebcdiccptr':
10062
+ case 'ibm905':
10063
+ return 'IBM905';
10064
+
10065
+ case 'cp918':
10066
+ case 'csibm918':
10067
+ case 'ebcdiccpar2':
10068
+ case 'ibm918':
10069
+ return 'IBM918';
10070
+
10071
+ case 'cp1026':
10072
+ case 'csibm1026':
10073
+ case 'ibm1026':
10074
+ return 'IBM1026';
10075
+
10076
+ case 'ibm1047':
10077
+ return 'IBM1047';
10078
+
10079
+ case 'csiso143iecp271':
10080
+ case 'iecp271':
10081
+ case 'isoir143':
10082
+ return 'IEC_P27-1';
10083
+
10084
+ case 'csiso49inis':
10085
+ case 'inis':
10086
+ case 'isoir49':
10087
+ return 'INIS';
10088
+
10089
+ case 'csiso50inis8':
10090
+ case 'inis8':
10091
+ case 'isoir50':
10092
+ return 'INIS-8';
10093
+
10094
+ case 'csiso51iniscyrillic':
10095
+ case 'iniscyrillic':
10096
+ case 'isoir51':
10097
+ return 'INIS-cyrillic';
10098
+
10099
+ case 'csinvariant':
10100
+ case 'invariant':
10101
+ return 'INVARIANT';
10102
+
10103
+ case 'iso2022cn':
10104
+ return 'ISO-2022-CN';
10105
+
10106
+ case 'iso2022cnext':
10107
+ return 'ISO-2022-CN-EXT';
10108
+
10109
+ case 'csiso2022jp':
10110
+ case 'iso2022jp':
10111
+ return 'ISO-2022-JP';
10112
+
10113
+ case 'csiso2022jp2':
10114
+ case 'iso2022jp2':
10115
+ return 'ISO-2022-JP-2';
10116
+
10117
+ case 'csiso2022kr':
10118
+ case 'iso2022kr':
10119
+ return 'ISO-2022-KR';
10120
+
10121
+ case 'cswindows30latin1':
10122
+ case 'iso88591windows30latin1':
10123
+ return 'ISO-8859-1-Windows-3.0-Latin-1';
10124
+
10125
+ case 'cswindows31latin1':
10126
+ case 'iso88591windows31latin1':
10127
+ return 'ISO-8859-1-Windows-3.1-Latin-1';
10128
+
10129
+ case 'csisolatin2':
10130
+ case 'iso88592':
10131
+ case 'iso885921987':
10132
+ case 'isoir101':
10133
+ case 'l2':
10134
+ case 'latin2':
10135
+ return 'ISO-8859-2';
10136
+
10137
+ case 'cswindows31latin2':
10138
+ case 'iso88592windowslatin2':
10139
+ return 'ISO-8859-2-Windows-Latin-2';
10140
+
10141
+ case 'csisolatin3':
10142
+ case 'iso88593':
10143
+ case 'iso885931988':
10144
+ case 'isoir109':
10145
+ case 'l3':
10146
+ case 'latin3':
10147
+ return 'ISO-8859-3';
10148
+
10149
+ case 'csisolatin4':
10150
+ case 'iso88594':
10151
+ case 'iso885941988':
10152
+ case 'isoir110':
10153
+ case 'l4':
10154
+ case 'latin4':
10155
+ return 'ISO-8859-4';
10156
+
10157
+ case 'csisolatincyrillic':
10158
+ case 'cyrillic':
10159
+ case 'iso88595':
10160
+ case 'iso885951988':
10161
+ case 'isoir144':
10162
+ return 'ISO-8859-5';
10163
+
10164
+ case 'arabic':
10165
+ case 'asmo708':
10166
+ case 'csisolatinarabic':
10167
+ case 'ecma114':
10168
+ case 'iso88596':
10169
+ case 'iso885961987':
10170
+ case 'isoir127':
10171
+ return 'ISO-8859-6';
10172
+
10173
+ case 'csiso88596e':
10174
+ case 'iso88596e':
10175
+ return 'ISO-8859-6-E';
10176
+
10177
+ case 'csiso88596i':
10178
+ case 'iso88596i':
10179
+ return 'ISO-8859-6-I';
10180
+
10181
+ case 'csisolatingreek':
10182
+ case 'ecma118':
10183
+ case 'elot928':
10184
+ case 'greek':
10185
+ case 'greek8':
10186
+ case 'iso88597':
10187
+ case 'iso885971987':
10188
+ case 'isoir126':
10189
+ return 'ISO-8859-7';
10190
+
10191
+ case 'csisolatinhebrew':
10192
+ case 'hebrew':
10193
+ case 'iso88598':
10194
+ case 'iso885981988':
10195
+ case 'isoir138':
10196
+ return 'ISO-8859-8';
10197
+
10198
+ case 'csiso88598e':
10199
+ case 'iso88598e':
10200
+ return 'ISO-8859-8-E';
10201
+
10202
+ case 'csiso88598i':
10203
+ case 'iso88598i':
10204
+ return 'ISO-8859-8-I';
10205
+
10206
+ case 'cswindows31latin5':
10207
+ case 'iso88599windowslatin5':
10208
+ return 'ISO-8859-9-Windows-Latin-5';
10209
+
10210
+ case 'csisolatin6':
10211
+ case 'iso885910':
10212
+ case 'iso8859101992':
10213
+ case 'isoir157':
10214
+ case 'l6':
10215
+ case 'latin6':
10216
+ return 'ISO-8859-10';
10217
+
10218
+ case 'iso885913':
10219
+ return 'ISO-8859-13';
10220
+
10221
+ case 'iso885914':
10222
+ case 'iso8859141998':
10223
+ case 'isoceltic':
10224
+ case 'isoir199':
10225
+ case 'l8':
10226
+ case 'latin8':
10227
+ return 'ISO-8859-14';
10228
+
10229
+ case 'iso885915':
10230
+ case 'latin9':
10231
+ return 'ISO-8859-15';
10232
+
10233
+ case 'iso885916':
10234
+ case 'iso8859162001':
10235
+ case 'isoir226':
10236
+ case 'l10':
10237
+ case 'latin10':
10238
+ return 'ISO-8859-16';
10239
+
10240
+ case 'iso10646j1':
10241
+ return 'ISO-10646-J-1';
10242
+
10243
+ case 'csunicode':
10244
+ case 'iso10646ucs2':
10245
+ return 'ISO-10646-UCS-2';
10246
+
10247
+ case 'csucs4':
10248
+ case 'iso10646ucs4':
10249
+ return 'ISO-10646-UCS-4';
10250
+
10251
+ case 'csunicodeascii':
10252
+ case 'iso10646ucsbasic':
10253
+ return 'ISO-10646-UCS-Basic';
10254
+
10255
+ case 'csunicodelatin1':
10256
+ case 'iso10646':
10257
+ case 'iso10646unicodelatin1':
10258
+ return 'ISO-10646-Unicode-Latin1';
10259
+
10260
+ case 'csiso10646utf1':
10261
+ case 'iso10646utf1':
10262
+ return 'ISO-10646-UTF-1';
10263
+
10264
+ case 'csiso115481':
10265
+ case 'iso115481':
10266
+ case 'isotr115481':
10267
+ return 'ISO-11548-1';
10268
+
10269
+ case 'csiso90':
10270
+ case 'isoir90':
10271
+ return 'iso-ir-90';
10272
+
10273
+ case 'csunicodeibm1261':
10274
+ case 'isounicodeibm1261':
10275
+ return 'ISO-Unicode-IBM-1261';
10276
+
10277
+ case 'csunicodeibm1264':
10278
+ case 'isounicodeibm1264':
10279
+ return 'ISO-Unicode-IBM-1264';
10280
+
10281
+ case 'csunicodeibm1265':
10282
+ case 'isounicodeibm1265':
10283
+ return 'ISO-Unicode-IBM-1265';
10284
+
10285
+ case 'csunicodeibm1268':
10286
+ case 'isounicodeibm1268':
10287
+ return 'ISO-Unicode-IBM-1268';
10288
+
10289
+ case 'csunicodeibm1276':
10290
+ case 'isounicodeibm1276':
10291
+ return 'ISO-Unicode-IBM-1276';
10292
+
10293
+ case 'csiso646basic1983':
10294
+ case 'iso646basic1983':
10295
+ case 'ref':
10296
+ return 'ISO_646.basic:1983';
10297
+
10298
+ case 'csiso2intlrefversion':
10299
+ case 'irv':
10300
+ case 'iso646irv1983':
10301
+ case 'isoir2':
10302
+ return 'ISO_646.irv:1983';
10303
+
10304
+ case 'csiso2033':
10305
+ case 'e13b':
10306
+ case 'iso20331983':
10307
+ case 'isoir98':
10308
+ return 'ISO_2033-1983';
10309
+
10310
+ case 'csiso5427cyrillic':
10311
+ case 'iso5427':
10312
+ case 'isoir37':
10313
+ return 'ISO_5427';
10314
+
10315
+ case 'iso5427cyrillic1981':
10316
+ case 'iso54271981':
10317
+ case 'isoir54':
10318
+ return 'ISO_5427:1981';
10319
+
10320
+ case 'csiso5428greek':
10321
+ case 'iso54281980':
10322
+ case 'isoir55':
10323
+ return 'ISO_5428:1980';
10324
+
10325
+ case 'csiso6937add':
10326
+ case 'iso6937225':
10327
+ case 'isoir152':
10328
+ return 'ISO_6937-2-25';
10329
+
10330
+ case 'csisotextcomm':
10331
+ case 'iso69372add':
10332
+ case 'isoir142':
10333
+ return 'ISO_6937-2-add';
10334
+
10335
+ case 'csiso8859supp':
10336
+ case 'iso8859supp':
10337
+ case 'isoir154':
10338
+ case 'latin125':
10339
+ return 'ISO_8859-supp';
10340
+
10341
+ case 'csiso10367box':
10342
+ case 'iso10367box':
10343
+ case 'isoir155':
10344
+ return 'ISO_10367-box';
10345
+
10346
+ case 'csiso15italian':
10347
+ case 'iso646it':
10348
+ case 'isoir15':
10349
+ case 'it':
10350
+ return 'IT';
10351
+
10352
+ case 'csiso13jisc6220jp':
10353
+ case 'isoir13':
10354
+ case 'jisc62201969':
10355
+ case 'jisc62201969jp':
10356
+ case 'katakana':
10357
+ case 'x2017':
10358
+ return 'JIS_C6220-1969-jp';
10359
+
10360
+ case 'csiso14jisc6220ro':
10361
+ case 'iso646jp':
10362
+ case 'isoir14':
10363
+ case 'jisc62201969ro':
10364
+ case 'jp':
10365
+ return 'JIS_C6220-1969-ro';
10366
+
10367
+ case 'csiso42jisc62261978':
10368
+ case 'isoir42':
10369
+ case 'jisc62261978':
10370
+ return 'JIS_C6226-1978';
10371
+
10372
+ case 'csiso87jisx208':
10373
+ case 'isoir87':
10374
+ case 'jisc62261983':
10375
+ case 'jisx2081983':
10376
+ case 'x208':
10377
+ return 'JIS_C6226-1983';
10378
+
10379
+ case 'csiso91jisc62291984a':
10380
+ case 'isoir91':
10381
+ case 'jisc62291984a':
10382
+ case 'jpocra':
10383
+ return 'JIS_C6229-1984-a';
10384
+
10385
+ case 'csiso92jisc62991984b':
10386
+ case 'iso646jpocrb':
10387
+ case 'isoir92':
10388
+ case 'jisc62291984b':
10389
+ case 'jpocrb':
10390
+ return 'JIS_C6229-1984-b';
10391
+
10392
+ case 'csiso93jis62291984badd':
10393
+ case 'isoir93':
10394
+ case 'jisc62291984badd':
10395
+ case 'jpocrbadd':
10396
+ return 'JIS_C6229-1984-b-add';
10397
+
10398
+ case 'csiso94jis62291984hand':
10399
+ case 'isoir94':
10400
+ case 'jisc62291984hand':
10401
+ case 'jpocrhand':
10402
+ return 'JIS_C6229-1984-hand';
10403
+
10404
+ case 'csiso95jis62291984handadd':
10405
+ case 'isoir95':
10406
+ case 'jisc62291984handadd':
10407
+ case 'jpocrhandadd':
10408
+ return 'JIS_C6229-1984-hand-add';
10409
+
10410
+ case 'csiso96jisc62291984kana':
10411
+ case 'isoir96':
10412
+ case 'jisc62291984kana':
10413
+ return 'JIS_C6229-1984-kana';
10414
+
10415
+ case 'csjisencoding':
10416
+ case 'jisencoding':
10417
+ return 'JIS_Encoding';
10418
+
10419
+ case 'cshalfwidthkatakana':
10420
+ case 'jisx201':
10421
+ case 'x201':
10422
+ return 'JIS_X0201';
10423
+
10424
+ case 'csiso159jisx2121990':
10425
+ case 'isoir159':
10426
+ case 'jisx2121990':
10427
+ case 'x212':
10428
+ return 'JIS_X0212-1990';
10429
+
10430
+ case 'csiso141jusib1002':
10431
+ case 'iso646yu':
10432
+ case 'isoir141':
10433
+ case 'js':
10434
+ case 'jusib1002':
10435
+ case 'yu':
10436
+ return 'JUS_I.B1.002';
10437
+
10438
+ case 'csiso147macedonian':
10439
+ case 'isoir147':
10440
+ case 'jusib1003mac':
10441
+ case 'macedonian':
10442
+ return 'JUS_I.B1.003-mac';
10443
+
10444
+ case 'csiso146serbian':
10445
+ case 'isoir146':
10446
+ case 'jusib1003serb':
10447
+ case 'serbian':
10448
+ return 'JUS_I.B1.003-serb';
10449
+
10450
+ case 'koi7switched':
10451
+ return 'KOI7-switched';
10452
+
10453
+ case 'cskoi8r':
10454
+ case 'koi8r':
10455
+ return 'KOI8-R';
10456
+
10457
+ case 'koi8u':
10458
+ return 'KOI8-U';
10459
+
10460
+ case 'csksc5636':
10461
+ case 'iso646kr':
10462
+ case 'ksc5636':
10463
+ return 'KSC5636';
10464
+
10465
+ case 'cskz1048':
10466
+ case 'kz1048':
10467
+ case 'rk1048':
10468
+ case 'strk10482002':
10469
+ return 'KZ-1048';
10470
+
10471
+ case 'csiso19latingreek':
10472
+ case 'isoir19':
10473
+ case 'latingreek':
10474
+ return 'latin-greek';
10475
+
10476
+ case 'csiso27latingreek1':
10477
+ case 'isoir27':
10478
+ case 'latingreek1':
10479
+ return 'Latin-greek-1';
10480
+
10481
+ case 'csiso158lap':
10482
+ case 'isoir158':
10483
+ case 'lap':
10484
+ case 'latinlap':
10485
+ return 'latin-lap';
10486
+
10487
+ case 'csmacintosh':
10488
+ case 'mac':
10489
+ case 'macintosh':
10490
+ return 'macintosh';
10491
+
10492
+ case 'csmicrosoftpublishing':
10493
+ case 'microsoftpublishing':
10494
+ return 'Microsoft-Publishing';
10495
+
10496
+ case 'csmnem':
10497
+ case 'mnem':
10498
+ return 'MNEM';
10499
+
10500
+ case 'csmnemonic':
10501
+ case 'mnemonic':
10502
+ return 'MNEMONIC';
10503
+
10504
+ case 'csiso86hungarian':
10505
+ case 'hu':
10506
+ case 'iso646hu':
10507
+ case 'isoir86':
10508
+ case 'msz77953':
10509
+ return 'MSZ_7795.3';
10510
+
10511
+ case 'csnatsdano':
10512
+ case 'isoir91':
10513
+ case 'natsdano':
10514
+ return 'NATS-DANO';
10515
+
10516
+ case 'csnatsdanoadd':
10517
+ case 'isoir92':
10518
+ case 'natsdanoadd':
10519
+ return 'NATS-DANO-ADD';
10520
+
10521
+ case 'csnatssefi':
10522
+ case 'isoir81':
10523
+ case 'natssefi':
10524
+ return 'NATS-SEFI';
10525
+
10526
+ case 'csnatssefiadd':
10527
+ case 'isoir82':
10528
+ case 'natssefiadd':
10529
+ return 'NATS-SEFI-ADD';
10530
+
10531
+ case 'csiso151cuba':
10532
+ case 'cuba':
10533
+ case 'iso646cu':
10534
+ case 'isoir151':
10535
+ case 'ncnc1081':
10536
+ return 'NC_NC00-10:81';
10537
+
10538
+ case 'csiso69french':
10539
+ case 'fr':
10540
+ case 'iso646fr':
10541
+ case 'isoir69':
10542
+ case 'nfz62010':
10543
+ return 'NF_Z_62-010';
10544
+
10545
+ case 'csiso25french':
10546
+ case 'iso646fr1':
10547
+ case 'isoir25':
10548
+ case 'nfz620101973':
10549
+ return 'NF_Z_62-010_(1973)';
10550
+
10551
+ case 'csiso60danishnorwegian':
10552
+ case 'csiso60norwegian1':
10553
+ case 'iso646no':
10554
+ case 'isoir60':
10555
+ case 'no':
10556
+ case 'ns45511':
10557
+ return 'NS_4551-1';
10558
+
10559
+ case 'csiso61norwegian2':
10560
+ case 'iso646no2':
10561
+ case 'isoir61':
10562
+ case 'no2':
10563
+ case 'ns45512':
10564
+ return 'NS_4551-2';
10565
+
10566
+ case 'osdebcdicdf3irv':
10567
+ return 'OSD_EBCDIC_DF03_IRV';
10568
+
10569
+ case 'osdebcdicdf41':
10570
+ return 'OSD_EBCDIC_DF04_1';
10571
+
10572
+ case 'osdebcdicdf415':
10573
+ return 'OSD_EBCDIC_DF04_15';
10574
+
10575
+ case 'cspc8danishnorwegian':
10576
+ case 'pc8danishnorwegian':
10577
+ return 'PC8-Danish-Norwegian';
10578
+
10579
+ case 'cspc8turkish':
10580
+ case 'pc8turkish':
10581
+ return 'PC8-Turkish';
10582
+
10583
+ case 'csiso16portuguese':
10584
+ case 'iso646pt':
10585
+ case 'isoir16':
10586
+ case 'pt':
10587
+ return 'PT';
10588
+
10589
+ case 'csiso84portuguese2':
10590
+ case 'iso646pt2':
10591
+ case 'isoir84':
10592
+ case 'pt2':
10593
+ return 'PT2';
10594
+
10595
+ case 'cp154':
10596
+ case 'csptcp154':
10597
+ case 'cyrillicasian':
10598
+ case 'pt154':
10599
+ case 'ptcp154':
10600
+ return 'PTCP154';
10601
+
10602
+ case 'scsu':
10603
+ return 'SCSU';
10604
+
10605
+ case 'csiso10swedish':
10606
+ case 'fi':
10607
+ case 'iso646fi':
10608
+ case 'iso646se':
10609
+ case 'isoir10':
10610
+ case 'se':
10611
+ case 'sen850200b':
10612
+ return 'SEN_850200_B';
10613
+
10614
+ case 'csiso11swedishfornames':
10615
+ case 'iso646se2':
10616
+ case 'isoir11':
10617
+ case 'se2':
10618
+ case 'sen850200c':
10619
+ return 'SEN_850200_C';
10620
+
10621
+ case 'csshiftjis':
10622
+ case 'mskanji':
10623
+ case 'shiftjis':
10624
+ return 'Shift_JIS';
10625
+
10626
+ case 'csiso102t617bit':
10627
+ case 'isoir102':
10628
+ case 't617bit':
10629
+ return 'T.61-7bit';
10630
+
10631
+ case 'csiso103t618bit':
10632
+ case 'isoir103':
10633
+ case 't61':
10634
+ case 't618bit':
10635
+ return 'T.61-8bit';
10636
+
10637
+ case 'csiso128t101g2':
10638
+ case 'isoir128':
10639
+ case 't101g2':
10640
+ return 'T.101-G2';
10641
+
10642
+ case 'cstscii':
10643
+ case 'tscii':
10644
+ return 'TSCII';
10645
+
10646
+ case 'csunicode11':
10647
+ case 'unicode11':
10648
+ return 'UNICODE-1-1';
10649
+
10650
+ case 'csunicode11utf7':
10651
+ case 'unicode11utf7':
10652
+ return 'UNICODE-1-1-UTF-7';
10653
+
10654
+ case 'csunknown8bit':
10655
+ case 'unknown8bit':
10656
+ return 'UNKNOWN-8BIT';
10657
+
10658
+ case 'ansix341968':
10659
+ case 'ansix341986':
10660
+ case 'ascii':
10661
+ case 'cp367':
10662
+ case 'csascii':
10663
+ case 'ibm367':
10664
+ case 'iso646irv1991':
10665
+ case 'iso646us':
10666
+ case 'isoir6':
10667
+ case 'us':
10668
+ case 'usascii':
10669
+ return 'US-ASCII';
10670
+
10671
+ case 'csusdk':
10672
+ case 'usdk':
10673
+ return 'us-dk';
10674
+
10675
+ case 'utf7':
10676
+ return 'UTF-7';
10677
+
10678
+ case 'utf8':
10679
+ return 'UTF-8';
10680
+
10681
+ case 'utf16':
10682
+ return 'UTF-16';
10683
+
10684
+ case 'utf16be':
10685
+ return 'UTF-16BE';
10686
+
10687
+ case 'utf16le':
10688
+ return 'UTF-16LE';
10689
+
10690
+ case 'utf32':
10691
+ return 'UTF-32';
10692
+
10693
+ case 'utf32be':
10694
+ return 'UTF-32BE';
10695
+
10696
+ case 'utf32le':
10697
+ return 'UTF-32LE';
10698
+
10699
+ case 'csventurainternational':
10700
+ case 'venturainternational':
10701
+ return 'Ventura-International';
10702
+
10703
+ case 'csventuramath':
10704
+ case 'venturamath':
10705
+ return 'Ventura-Math';
10706
+
10707
+ case 'csventuraus':
10708
+ case 'venturaus':
10709
+ return 'Ventura-US';
10710
+
10711
+ case 'csiso70videotexsupp1':
10712
+ case 'isoir70':
10713
+ case 'videotexsuppl':
10714
+ return 'videotex-suppl';
10715
+
10716
+ case 'csviqr':
10717
+ case 'viqr':
10718
+ return 'VIQR';
10719
+
10720
+ case 'csviscii':
10721
+ case 'viscii':
10722
+ return 'VISCII';
10723
+
10724
+ case 'cswindows31j':
10725
+ case 'windows31j':
10726
+ return 'Windows-31J';
10727
+
10728
+ case 'iso885911':
10729
+ case 'tis620':
10730
+ return 'windows-874';
10731
+
10732
+ case 'cseuckr':
10733
+ case 'csksc56011987':
10734
+ case 'euckr':
10735
+ case 'isoir149':
10736
+ case 'korean':
10737
+ case 'ksc5601':
10738
+ case 'ksc56011987':
10739
+ case 'ksc56011989':
10740
+ case 'windows949':
10741
+ return 'windows-949';
10742
+
10743
+ case 'windows1250':
10744
+ return 'windows-1250';
10745
+
10746
+ case 'windows1251':
10747
+ return 'windows-1251';
10748
+
10749
+ case 'cp819':
10750
+ case 'csisolatin1':
10751
+ case 'ibm819':
10752
+ case 'iso88591':
10753
+ case 'iso885911987':
10754
+ case 'isoir100':
10755
+ case 'l1':
10756
+ case 'latin1':
10757
+ case 'windows1252':
10758
+ return 'windows-1252';
10759
+
10760
+ case 'windows1253':
10761
+ return 'windows-1253';
10762
+
10763
+ case 'csisolatin5':
10764
+ case 'iso88599':
10765
+ case 'iso885991989':
10766
+ case 'isoir148':
10767
+ case 'l5':
10768
+ case 'latin5':
10769
+ case 'windows1254':
10770
+ return 'windows-1254';
10771
+
10772
+ case 'windows1255':
10773
+ return 'windows-1255';
10774
+
10775
+ case 'windows1256':
10776
+ return 'windows-1256';
10777
+
10778
+ case 'windows1257':
10779
+ return 'windows-1257';
10780
+
10781
+ case 'windows1258':
10782
+ return 'windows-1258';
10783
+
10784
+ default:
10785
+ return $charset;
10786
+ }
10787
+ }
10788
+
10789
+ function get_curl_version()
10790
+ {
10791
+ if (is_array($curl = curl_version()))
10792
+ {
10793
+ $curl = $curl['version'];
10794
+ }
10795
+ elseif (substr($curl, 0, 5) === 'curl/')
10796
+ {
10797
+ $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5));
10798
+ }
10799
+ elseif (substr($curl, 0, 8) === 'libcurl/')
10800
+ {
10801
+ $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8));
10802
+ }
10803
+ else
10804
+ {
10805
+ $curl = 0;
10806
+ }
10807
+ return $curl;
10808
+ }
10809
+
10810
+ function is_subclass_of($class1, $class2)
10811
+ {
10812
+ if (func_num_args() !== 2)
10813
+ {
10814
+ trigger_error('Wrong parameter count for SimplePie_Misc::is_subclass_of()', E_USER_WARNING);
10815
+ }
10816
+ elseif (version_compare(PHP_VERSION, '5.0.3', '>=') || is_object($class1))
10817
+ {
10818
+ return is_subclass_of($class1, $class2);
10819
+ }
10820
+ elseif (is_string($class1) && is_string($class2))
10821
+ {
10822
+ if (class_exists($class1))
10823
+ {
10824
+ if (class_exists($class2))
10825
+ {
10826
+ $class2 = strtolower($class2);
10827
+ while ($class1 = strtolower(get_parent_class($class1)))
10828
+ {
10829
+ if ($class1 === $class2)
10830
+ {
10831
+ return true;
10832
+ }
10833
+ }
10834
+ }
10835
+ }
10836
+ else
10837
+ {
10838
+ trigger_error('Unknown class passed as parameter', E_USER_WARNNG);
10839
+ }
10840
+ }
10841
+ return false;
10842
+ }
10843
+
10844
+ /**
10845
+ * Strip HTML comments
10846
+ *
10847
+ * @access public
10848
+ * @param string $data Data to strip comments from
10849
+ * @return string Comment stripped string
10850
+ */
10851
+ function strip_comments($data)
10852
+ {
10853
+ $output = '';
10854
+ while (($start = strpos($data, '<!--')) !== false)
10855
+ {
10856
+ $output .= substr($data, 0, $start);
10857
+ if (($end = strpos($data, '-->', $start)) !== false)
10858
+ {
10859
+ $data = substr_replace($data, '', 0, $end + 3);
10860
+ }
10861
+ else
10862
+ {
10863
+ $data = '';
10864
+ }
10865
+ }
10866
+ return $output . $data;
10867
+ }
10868
+
10869
+ function parse_date($dt)
10870
+ {
10871
+ $parser = SimplePie_Parse_Date::get();
10872
+ return $parser->parse($dt);
10873
+ }
10874
+
10875
+ /**
10876
+ * Decode HTML entities
10877
+ *
10878
+ * @static
10879
+ * @access public
10880
+ * @param string $data Input data
10881
+ * @return string Output data
10882
+ */
10883
+ function entities_decode($data)
10884
+ {
10885
+ $decoder = new SimplePie_Decode_HTML_Entities($data);
10886
+ return $decoder->parse();
10887
+ }
10888
+
10889
+ /**
10890
+ * Remove RFC822 comments
10891
+ *
10892
+ * @access public
10893
+ * @param string $data Data to strip comments from
10894
+ * @return string Comment stripped string
10895
+ */
10896
+ function uncomment_rfc822($string)
10897
+ {
10898
+ $string = (string) $string;
10899
+ $position = 0;
10900
+ $length = strlen($string);
10901
+ $depth = 0;
10902
+
10903
+ $output = '';
10904
+
10905
+ while ($position < $length && ($pos = strpos($string, '(', $position)) !== false)
10906
+ {
10907
+ $output .= substr($string, $position, $pos - $position);
10908
+ $position = $pos + 1;
10909
+ if ($string[$pos - 1] !== '\\')
10910
+ {
10911
+ $depth++;
10912
+ while ($depth && $position < $length)
10913
+ {
10914
+ $position += strcspn($string, '()', $position);
10915
+ if ($string[$position - 1] === '\\')
10916
+ {
10917
+ $position++;
10918
+ continue;
10919
+ }
10920
+ elseif (isset($string[$position]))
10921
+ {
10922
+ switch ($string[$position])
10923
+ {
10924
+ case '(':
10925
+ $depth++;
10926
+ break;
10927
+
10928
+ case ')':
10929
+ $depth--;
10930
+ break;
10931
+ }
10932
+ $position++;
10933
+ }
10934
+ else
10935
+ {
10936
+ break;
10937
+ }
10938
+ }
10939
+ }
10940
+ else
10941
+ {
10942
+ $output .= '(';
10943
+ }
10944
+ }
10945
+ $output .= substr($string, $position);
10946
+
10947
+ return $output;
10948
+ }
10949
+
10950
+ function parse_mime($mime)
10951
+ {
10952
+ if (($pos = strpos($mime, ';')) === false)
10953
+ {
10954
+ return trim($mime);
10955
+ }
10956
+ else
10957
+ {
10958
+ return trim(substr($mime, 0, $pos));
10959
+ }
10960
+ }
10961
+
10962
+ function htmlspecialchars_decode($string, $quote_style)
10963
+ {
10964
+ if (function_exists('htmlspecialchars_decode'))
10965
+ {
10966
+ return htmlspecialchars_decode($string, $quote_style);
10967
+ }
10968
+ else
10969
+ {
10970
+ return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)));
10971
+ }
10972
+ }
10973
+
10974
+ function atom_03_construct_type($attribs)
10975
+ {
10976
+ if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) === 'base64'))
10977
+ {
10978
+ $mode = SIMPLEPIE_CONSTRUCT_BASE64;
10979
+ }
10980
+ else
10981
+ {
10982
+ $mode = SIMPLEPIE_CONSTRUCT_NONE;
10983
+ }
10984
+ if (isset($attribs['']['type']))
10985
+ {
10986
+ switch (strtolower(trim($attribs['']['type'])))
10987
+ {
10988
+ case 'text':
10989
+ case 'text/plain':
10990
+ return SIMPLEPIE_CONSTRUCT_TEXT | $mode;
10991
+
10992
+ case 'html':
10993
+ case 'text/html':
10994
+ return SIMPLEPIE_CONSTRUCT_HTML | $mode;
10995
+
10996
+ case 'xhtml':
10997
+ case 'application/xhtml+xml':
10998
+ return SIMPLEPIE_CONSTRUCT_XHTML | $mode;
10999
+
11000
+ default:
11001
+ return SIMPLEPIE_CONSTRUCT_NONE | $mode;
11002
+ }
11003
+ }
11004
+ else
11005
+ {
11006
+ return SIMPLEPIE_CONSTRUCT_TEXT | $mode;
11007
+ }
11008
+ }
11009
+
11010
+ function atom_10_construct_type($attribs)
11011
+ {
11012
+ if (isset($attribs['']['type']))
11013
+ {
11014
+ switch (strtolower(trim($attribs['']['type'])))
11015
+ {
11016
+ case 'text':
11017
+ return SIMPLEPIE_CONSTRUCT_TEXT;
11018
+
11019
+ case 'html':
11020
+ return SIMPLEPIE_CONSTRUCT_HTML;
11021
+
11022
+ case 'xhtml':
11023
+ return SIMPLEPIE_CONSTRUCT_XHTML;
11024
+
11025
+ default:
11026
+ return SIMPLEPIE_CONSTRUCT_NONE;
11027
+ }
11028
+ }
11029
+ return SIMPLEPIE_CONSTRUCT_TEXT;
11030
+ }
11031
+
11032
+ function atom_10_content_construct_type($attribs)
11033
+ {
11034
+ if (isset($attribs['']['type']))
11035
+ {
11036
+ $type = strtolower(trim($attribs['']['type']));
11037
+ switch ($type)
11038
+ {
11039
+ case 'text':
11040
+ return SIMPLEPIE_CONSTRUCT_TEXT;
11041
+
11042
+ case 'html':
11043
+ return SIMPLEPIE_CONSTRUCT_HTML;
11044
+
11045
+ case 'xhtml':
11046
+ return SIMPLEPIE_CONSTRUCT_XHTML;
11047
+ }
11048
+ if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) === 'text/')
11049
+ {
11050
+ return SIMPLEPIE_CONSTRUCT_NONE;
11051
+ }
11052
+ else
11053
+ {
11054
+ return SIMPLEPIE_CONSTRUCT_BASE64;
11055
+ }
11056
+ }
11057
+ else
11058
+ {
11059
+ return SIMPLEPIE_CONSTRUCT_TEXT;
11060
+ }
11061
+ }
11062
+
11063
+ function is_isegment_nz_nc($string)
11064
+ {
11065
+ return (bool) preg_match('/^([A-Za-z0-9\-._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!$&\'()*+,;=@]|(%[0-9ABCDEF]{2}))+$/u', $string);
11066
+ }
11067
+
11068
+ function space_seperated_tokens($string)
11069
+ {
11070
+ $space_characters = "\x20\x09\x0A\x0B\x0C\x0D";
11071
+ $string_length = strlen($string);
11072
+
11073
+ $position = strspn($string, $space_characters);
11074
+ $tokens = array();
11075
+
11076
+ while ($position < $string_length)
11077
+ {
11078
+ $len = strcspn($string, $space_characters, $position);
11079
+ $tokens[] = substr($string, $position, $len);
11080
+ $position += $len;
11081
+ $position += strspn($string, $space_characters, $position);
11082
+ }
11083
+
11084
+ return $tokens;
11085
+ }
11086
+
11087
+ function array_unique($array)
11088
+ {
11089
+ if (version_compare(PHP_VERSION, '5.2', '>='))
11090
+ {
11091
+ return array_unique($array);
11092
+ }
11093
+ else
11094
+ {
11095
+ $array = (array) $array;
11096
+ $new_array = array();
11097
+ $new_array_strings = array();
11098
+ foreach ($array as $key => $value)
11099
+ {
11100
+ if (is_object($value))
11101
+ {
11102
+ if (method_exists($value, '__toString'))
11103
+ {
11104
+ $cmp = $value->__toString();
11105
+ }
11106
+ else
11107
+ {
11108
+ trigger_error('Object of class ' . get_class($value) . ' could not be converted to string', E_USER_ERROR);
11109
+ }
11110
+ }
11111
+ elseif (is_array($value))
11112
+ {
11113
+ $cmp = (string) reset($value);
11114
+ }
11115
+ else
11116
+ {
11117
+ $cmp = (string) $value;
11118
+ }
11119
+ if (!in_array($cmp, $new_array_strings))
11120
+ {
11121
+ $new_array[$key] = $value;
11122
+ $new_array_strings[] = $cmp;
11123
+ }
11124
+ }
11125
+ return $new_array;
11126
+ }
11127
+ }
11128
+
11129
+ /**
11130
+ * Converts a unicode codepoint to a UTF-8 character
11131
+ *
11132
+ * @static
11133
+ * @access public
11134
+ * @param int $codepoint Unicode codepoint
11135
+ * @return string UTF-8 character
11136
+ */
11137
+ function codepoint_to_utf8($codepoint)
11138
+ {
11139
+ $codepoint = (int) $codepoint;
11140
+ if ($codepoint < 0)
11141
+ {
11142
+ return false;
11143
+ }
11144
+ else if ($codepoint <= 0x7f)
11145
+ {
11146
+ return chr($codepoint);
11147
+ }
11148
+ else if ($codepoint <= 0x7ff)
11149
+ {
11150
+ return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f));
11151
+ }
11152
+ else if ($codepoint <= 0xffff)
11153
+ {
11154
+ return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
11155
+ }
11156
+ else if ($codepoint <= 0x10ffff)
11157
+ {
11158
+ return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
11159
+ }
11160
+ else
11161
+ {
11162
+ // U+FFFD REPLACEMENT CHARACTER
11163
+ return "\xEF\xBF\xBD";
11164
+ }
11165
+ }
11166
+
11167
+ /**
11168
+ * Re-implementation of PHP 5's stripos()
11169
+ *
11170
+ * Returns the numeric position of the first occurrence of needle in the
11171
+ * haystack string.
11172
+ *
11173
+ * @static
11174
+ * @access string
11175
+ * @param object $haystack
11176
+ * @param string $needle Note that the needle may be a string of one or more
11177
+ * characters. If needle is not a string, it is converted to an integer
11178
+ * and applied as the ordinal value of a character.
11179
+ * @param int $offset The optional offset parameter allows you to specify which
11180
+ * character in haystack to start searching. The position returned is still
11181
+ * relative to the beginning of haystack.
11182
+ * @return bool If needle is not found, stripos() will return boolean false.
11183
+ */
11184
+ function stripos($haystack, $needle, $offset = 0)
11185
+ {
11186
+ if (function_exists('stripos'))
11187
+ {
11188
+ return stripos($haystack, $needle, $offset);
11189
+ }
11190
+ else
11191
+ {
11192
+ if (is_string($needle))
11193
+ {
11194
+ $needle = strtolower($needle);
11195
+ }
11196
+ elseif (is_int($needle) || is_bool($needle) || is_double($needle))
11197
+ {
11198
+ $needle = strtolower(chr($needle));
11199
+ }
11200
+ else
11201
+ {
11202
+ trigger_error('needle is not a string or an integer', E_USER_WARNING);
11203
+ return false;
11204
+ }
11205
+
11206
+ return strpos(strtolower($haystack), $needle, $offset);
11207
+ }
11208
+ }
11209
+
11210
+ /**
11211
+ * Similar to parse_str()
11212
+ *
11213
+ * Returns an associative array of name/value pairs, where the value is an
11214
+ * array of values that have used the same name
11215
+ *
11216
+ * @static
11217
+ * @access string
11218
+ * @param string $str The input string.
11219
+ * @return array
11220
+ */
11221
+ function parse_str($str)
11222
+ {
11223
+ $return = array();
11224
+ $str = explode('&', $str);
11225
+
11226
+ foreach ($str as $section)
11227
+ {
11228
+ if (strpos($section, '=') !== false)
11229
+ {
11230
+ list($name, $value) = explode('=', $section, 2);
11231
+ $return[urldecode($name)][] = urldecode($value);
11232
+ }
11233
+ else
11234
+ {
11235
+ $return[urldecode($section)][] = null;
11236
+ }
11237
+ }
11238
+
11239
+ return $return;
11240
+ }
11241
+
11242
+ /**
11243
+ * Detect XML encoding, as per XML 1.0 Appendix F.1
11244
+ *
11245
+ * @todo Add support for EBCDIC
11246
+ * @param string $data XML data
11247
+ * @return array Possible encodings
11248
+ */
11249
+ function xml_encoding($data)
11250
+ {
11251
+ // UTF-32 Big Endian BOM
11252
+ if (substr($data, 0, 4) === "\x00\x00\xFE\xFF")
11253
+ {
11254
+ $encoding[] = 'UTF-32BE';
11255
+ }
11256
+ // UTF-32 Little Endian BOM
11257
+ elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00")
11258
+ {
11259
+ $encoding[] = 'UTF-32LE';
11260
+ }
11261
+ // UTF-16 Big Endian BOM
11262
+ elseif (substr($data, 0, 2) === "\xFE\xFF")
11263
+ {
11264
+ $encoding[] = 'UTF-16BE';
11265
+ }
11266
+ // UTF-16 Little Endian BOM
11267
+ elseif (substr($data, 0, 2) === "\xFF\xFE")
11268
+ {
11269
+ $encoding[] = 'UTF-16LE';
11270
+ }
11271
+ // UTF-8 BOM
11272
+ elseif (substr($data, 0, 3) === "\xEF\xBB\xBF")
11273
+ {
11274
+ $encoding[] = 'UTF-8';
11275
+ }
11276
+ // UTF-32 Big Endian Without BOM
11277
+ elseif (substr($data, 0, 20) === "\x00\x00\x00\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C")
11278
+ {
11279
+ if ($pos = strpos($data, "\x00\x00\x00\x3F\x00\x00\x00\x3E"))
11280
+ {
11281
+ $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32BE', 'UTF-8'));
11282
+ if ($parser->parse())
11283
+ {
11284
+ $encoding[] = $parser->encoding;
11285
+ }
11286
+ }
11287
+ $encoding[] = 'UTF-32BE';
11288
+ }
11289
+ // UTF-32 Little Endian Without BOM
11290
+ elseif (substr($data, 0, 20) === "\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C\x00\x00\x00")
11291
+ {
11292
+ if ($pos = strpos($data, "\x3F\x00\x00\x00\x3E\x00\x00\x00"))
11293
+ {
11294
+ $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32LE', 'UTF-8'));
11295
+ if ($parser->parse())
11296
+ {
11297
+ $encoding[] = $parser->encoding;
11298
+ }
11299
+ }
11300
+ $encoding[] = 'UTF-32LE';
11301
+ }
11302
+ // UTF-16 Big Endian Without BOM
11303
+ elseif (substr($data, 0, 10) === "\x00\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C")
11304
+ {
11305
+ if ($pos = strpos($data, "\x00\x3F\x00\x3E"))
11306
+ {
11307
+ $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16BE', 'UTF-8'));
11308
+ if ($parser->parse())
11309
+ {
11310
+ $encoding[] = $parser->encoding;
11311
+ }
11312
+ }
11313
+ $encoding[] = 'UTF-16BE';
11314
+ }
11315
+ // UTF-16 Little Endian Without BOM
11316
+ elseif (substr($data, 0, 10) === "\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C\x00")
11317
+ {
11318
+ if ($pos = strpos($data, "\x3F\x00\x3E\x00"))
11319
+ {
11320
+ $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16LE', 'UTF-8'));
11321
+ if ($parser->parse())
11322
+ {
11323
+ $encoding[] = $parser->encoding;
11324
+ }
11325
+ }
11326
+ $encoding[] = 'UTF-16LE';
11327
+ }
11328
+ // US-ASCII (or superset)
11329
+ elseif (substr($data, 0, 5) === "\x3C\x3F\x78\x6D\x6C")
11330
+ {
11331
+ if ($pos = strpos($data, "\x3F\x3E"))
11332
+ {
11333
+ $parser = new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5));
11334
+ if ($parser->parse())
11335
+ {
11336
+ $encoding[] = $parser->encoding;
11337
+ }
11338
+ }
11339
+ $encoding[] = 'UTF-8';
11340
+ }
11341
+ // Fallback to UTF-8
11342
+ else
11343
+ {
11344
+ $encoding[] = 'UTF-8';
11345
+ }
11346
+ return $encoding;
11347
+ }
11348
+
11349
+ function output_javascript()
11350
+ {
11351
+ if (function_exists('ob_gzhandler'))
11352
+ {
11353
+ ob_start('ob_gzhandler');
11354
+ }
11355
+ header('Content-type: text/javascript; charset: UTF-8');
11356
+ header('Cache-Control: must-revalidate');
11357
+ header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
11358
+ ?>
11359
+ function embed_odeo(link) {
11360
+ document.writeln('<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url='+link+'"></embed>');
11361
+ }
11362
+
11363
+ function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
11364
+ if (placeholder != '') {
11365
+ document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
11366
+ }
11367
+ else {
11368
+ document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="true" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
11369
+ }
11370
+ }
11371
+
11372
+ function embed_flash(bgcolor, width, height, link, loop, type) {
11373
+ document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>');
11374
+ }
11375
+
11376
+ function embed_flv(width, height, link, placeholder, loop, player) {
11377
+ document.writeln('<embed src="'+player+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="'+width+'" height="'+height+'" wmode="transparent" flashvars="file='+link+'&autostart=false&repeat='+loop+'&showdigits=true&showfsbutton=false"></embed>');
11378
+ }
11379
+
11380
+ function embed_wmedia(width, height, link) {
11381
+ document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
11382
+ }
11383
+ <?php
11384
+ }
11385
+ }
11386
+
11387
+ /**
11388
+ * Decode HTML Entities
11389
+ *
11390
+ * This implements HTML5 as of revision 967 (2007-06-28)
11391
+ *
11392
+ * @package SimplePie
11393
+ */
11394
+ class SimplePie_Decode_HTML_Entities
11395
+ {
11396
+ /**
11397
+ * Data to be parsed
11398
+ *
11399
+ * @access private
11400
+ * @var string
11401
+ */
11402
+ var $data = '';
11403
+
11404
+ /**
11405
+ * Currently consumed bytes
11406
+ *
11407
+ * @access private
11408
+ * @var string
11409
+ */
11410
+ var $consumed = '';
11411
+
11412
+ /**
11413
+ * Position of the current byte being parsed
11414
+ *
11415
+ * @access private
11416
+ * @var int
11417
+ */
11418
+ var $position = 0;
11419
+
11420
+ /**
11421
+ * Create an instance of the class with the input data
11422
+ *
11423
+ * @access public
11424
+ * @param string $data Input data
11425
+ */
11426
+ function SimplePie_Decode_HTML_Entities($data)
11427
+ {
11428
+ $this->data = $data;
11429
+ }
11430
+
11431
+ /**
11432
+ * Parse the input data
11433
+ *
11434
+ * @access public
11435
+ * @return string Output data
11436
+ */
11437
+ function parse()
11438
+ {
11439
+ while (($this->position = strpos($this->data, '&', $this->position)) !== false)
11440
+ {
11441
+ $this->consume();
11442
+ $this->entity();
11443
+ $this->consumed = '';
11444
+ }
11445
+ return $this->data;
11446
+ }
11447
+
11448
+ /**
11449
+ * Consume the next byte
11450
+ *
11451
+ * @access private
11452
+ * @return mixed The next byte, or false, if there is no more data
11453
+ */
11454
+ function consume()
11455
+ {
11456
+ if (isset($this->data[$this->position]))
11457
+ {
11458
+ $this->consumed .= $this->data[$this->position];
11459
+ return $this->data[$this->position++];
11460
+ }
11461
+ else
11462
+ {
11463
+ return false;
11464
+ }
11465
+ }
11466
+
11467
+ /**
11468
+ * Consume a range of characters
11469
+ *
11470
+ * @access private
11471
+ * @param string $chars Characters to consume
11472
+ * @return mixed A series of characters that match the range, or false
11473
+ */
11474
+ function consume_range($chars)
11475
+ {
11476
+ if ($len = strspn($this->data, $chars, $this->position))
11477
+ {
11478
+ $data = substr($this->data, $this->position, $len);
11479
+ $this->consumed .= $data;
11480
+ $this->position += $len;
11481
+ return $data;
11482
+ }
11483
+ else
11484
+ {
11485
+ return false;
11486
+ }
11487
+ }
11488
+
11489
+ /**
11490
+ * Unconsume one byte
11491
+ *
11492
+ * @access private
11493
+ */
11494
+ function unconsume()
11495
+ {
11496
+ $this->consumed = substr($this->consumed, 0, -1);
11497
+ $this->position--;
11498
+ }
11499
+
11500
+ /**
11501
+ * Decode an entity
11502
+ *
11503
+ * @access private
11504
+ */
11505
+ function entity()
11506
+ {
11507
+ switch ($this->consume())
11508
+ {
11509
+ case "\x09":
11510
+ case "\x0A":
11511
+ case "\x0B":
11512
+ case "\x0B":
11513
+ case "\x0C":
11514
+ case "\x20":
11515
+ case "\x3C":
11516
+ case "\x26":
11517
+ case false:
11518
+ break;
11519
+
11520
+ case "\x23":
11521
+ switch ($this->consume())
11522
+ {
11523
+ case "\x78":
11524
+ case "\x58":
11525
+ $range = '0123456789ABCDEFabcdef';
11526
+ $hex = true;
11527
+ break;
11528
+
11529
+ default:
11530
+ $range = '0123456789';
11531
+ $hex = false;
11532
+ $this->unconsume();
11533
+ break;
11534
+ }
11535
+
11536
+ if ($codepoint = $this->consume_range($range))
11537
+ {
11538
+ static $windows_1252_specials = array(0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8");
11539
+
11540
+ if ($hex)
11541
+ {
11542
+ $codepoint = hexdec($codepoint);
11543
+ }
11544
+ else
11545
+ {
11546
+ $codepoint = intval($codepoint);
11547
+ }
11548
+
11549
+ if (isset($windows_1252_specials[$codepoint]))
11550
+ {
11551
+ $replacement = $windows_1252_specials[$codepoint];
11552
+ }
11553
+ else
11554
+ {
11555
+ $replacement = SimplePie_Misc::codepoint_to_utf8($codepoint);
11556
+ }
11557
+
11558
+ if (!in_array($this->consume(), array(';', false), true))
11559
+ {
11560
+ $this->unconsume();
11561
+ }
11562
+
11563
+ $consumed_length = strlen($this->consumed);
11564
+ $this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length);
11565
+ $this->position += strlen($replacement) - $consumed_length;
11566
+ }
11567
+ break;
11568
+
11569
+ default:
11570
+ static $entities = array('Aacute' => "\xC3\x81", 'aacute' => "\xC3\xA1", 'Aacute;' => "\xC3\x81", 'aacute;' => "\xC3\xA1", 'Acirc' => "\xC3\x82", 'acirc' => "\xC3\xA2", 'Acirc;' => "\xC3\x82", 'acirc;' => "\xC3\xA2", 'acute' => "\xC2\xB4", 'acute;' => "\xC2\xB4", 'AElig' => "\xC3\x86", 'aelig' => "\xC3\xA6", 'AElig;' => "\xC3\x86", 'aelig;' => "\xC3\xA6", 'Agrave' => "\xC3\x80", 'agrave' => "\xC3\xA0", 'Agrave;' => "\xC3\x80", 'agrave;' => "\xC3\xA0", 'alefsym;' => "\xE2\x84\xB5", 'Alpha;' => "\xCE\x91", 'alpha;' => "\xCE\xB1", 'AMP' => "\x26", 'amp' => "\x26", 'AMP;' => "\x26", 'amp;' => "\x26", 'and;' => "\xE2\x88\xA7", 'ang;' => "\xE2\x88\xA0", 'apos;' => "\x27", 'Aring' => "\xC3\x85", 'aring' => "\xC3\xA5", 'Aring;' => "\xC3\x85", 'aring;' => "\xC3\xA5", 'asymp;' => "\xE2\x89\x88", 'Atilde' => "\xC3\x83", 'atilde' => "\xC3\xA3", 'Atilde;' => "\xC3\x83", 'atilde;' => "\xC3\xA3", 'Auml' => "\xC3\x84", 'auml' => "\xC3\xA4", 'Auml;' => "\xC3\x84", 'auml;' => "\xC3\xA4", 'bdquo;' => "\xE2\x80\x9E", 'Beta;' => "\xCE\x92", 'beta;' => "\xCE\xB2", 'brvbar' => "\xC2\xA6", 'brvbar;' => "\xC2\xA6", 'bull;' => "\xE2\x80\xA2", 'cap;' => "\xE2\x88\xA9", 'Ccedil' => "\xC3\x87", 'ccedil' => "\xC3\xA7", 'Ccedil;' => "\xC3\x87", 'ccedil;' => "\xC3\xA7", 'cedil' => "\xC2\xB8", 'cedil;' => "\xC2\xB8", 'cent' => "\xC2\xA2", 'cent;' => "\xC2\xA2", 'Chi;' => "\xCE\xA7", 'chi;' => "\xCF\x87", 'circ;' => "\xCB\x86", 'clubs;' => "\xE2\x99\xA3", 'cong;' => "\xE2\x89\x85", 'COPY' => "\xC2\xA9", 'copy' => "\xC2\xA9", 'COPY;' => "\xC2\xA9", 'copy;' => "\xC2\xA9", 'crarr;' => "\xE2\x86\xB5", 'cup;' => "\xE2\x88\xAA", 'curren' => "\xC2\xA4", 'curren;' => "\xC2\xA4", 'Dagger;' => "\xE2\x80\xA1", 'dagger;' => "\xE2\x80\xA0", 'dArr;' => "\xE2\x87\x93", 'darr;' => "\xE2\x86\x93", 'deg' => "\xC2\xB0", 'deg;' => "\xC2\xB0", 'Delta;' => "\xCE\x94", 'delta;' => "\xCE\xB4", 'diams;' => "\xE2\x99\xA6", 'divide' => "\xC3\xB7", 'divide;' => "\xC3\xB7", 'Eacute' => "\xC3\x89", 'eacute' => "\xC3\xA9", 'Eacute;' => "\xC3\x89", 'eacute;' => "\xC3\xA9", 'Ecirc' => "\xC3\x8A", 'ecirc' => "\xC3\xAA", 'Ecirc;' => "\xC3\x8A", 'ecirc;' => "\xC3\xAA", 'Egrave' => "\xC3\x88", 'egrave' => "\xC3\xA8", 'Egrave;' => "\xC3\x88", 'egrave;' => "\xC3\xA8", 'empty;' => "\xE2\x88\x85", 'emsp;' => "\xE2\x80\x83", 'ensp;' => "\xE2\x80\x82", 'Epsilon;' => "\xCE\x95", 'epsilon;' => "\xCE\xB5", 'equiv;' => "\xE2\x89\xA1", 'Eta;' => "\xCE\x97", 'eta;' => "\xCE\xB7", 'ETH' => "\xC3\x90", 'eth' => "\xC3\xB0", 'ETH;' => "\xC3\x90", 'eth;' => "\xC3\xB0", 'Euml' => "\xC3\x8B", 'euml' => "\xC3\xAB", 'Euml;' => "\xC3\x8B", 'euml;' => "\xC3\xAB", 'euro;' => "\xE2\x82\xAC", 'exist;' => "\xE2\x88\x83", 'fnof;' => "\xC6\x92", 'forall;' => "\xE2\x88\x80", 'frac12' => "\xC2\xBD", 'frac12;' => "\xC2\xBD", 'frac14' => "\xC2\xBC", 'frac14;' => "\xC2\xBC", 'frac34' => "\xC2\xBE", 'frac34;' => "\xC2\xBE", 'frasl;' => "\xE2\x81\x84", 'Gamma;' => "\xCE\x93", 'gamma;' => "\xCE\xB3", 'ge;' => "\xE2\x89\xA5", 'GT' => "\x3E", 'gt' => "\x3E", 'GT;' => "\x3E", 'gt;' => "\x3E", 'hArr;' => "\xE2\x87\x94", 'harr;' => "\xE2\x86\x94", 'hearts;' => "\xE2\x99\xA5", 'hellip;' => "\xE2\x80\xA6", 'Iacute' => "\xC3\x8D", 'iacute' => "\xC3\xAD", 'Iacute;' => "\xC3\x8D", 'iacute;' => "\xC3\xAD", 'Icirc' => "\xC3\x8E", 'icirc' => "\xC3\xAE", 'Icirc;' => "\xC3\x8E", 'icirc;' => "\xC3\xAE", 'iexcl' => "\xC2\xA1", 'iexcl;' => "\xC2\xA1", 'Igrave' => "\xC3\x8C", 'igrave' => "\xC3\xAC", 'Igrave;' => "\xC3\x8C", 'igrave;' => "\xC3\xAC", 'image;' => "\xE2\x84\x91", 'infin;' => "\xE2\x88\x9E", 'int;' => "\xE2\x88\xAB", 'Iota;' => "\xCE\x99", 'iota;' => "\xCE\xB9", 'iquest' => "\xC2\xBF", 'iquest;' => "\xC2\xBF", 'isin;' => "\xE2\x88\x88", 'Iuml' => "\xC3\x8F", 'iuml' => "\xC3\xAF", 'Iuml;' => "\xC3\x8F", 'iuml;' => "\xC3\xAF", 'Kappa;' => "\xCE\x9A", 'kappa;' => "\xCE\xBA", 'Lambda;' => "\xCE\x9B", 'lambda;' => "\xCE\xBB", 'lang;' => "\xE3\x80\x88", 'laquo' => "\xC2\xAB", 'laquo;' => "\xC2\xAB", 'lArr;' => "\xE2\x87\x90", 'larr;' => "\xE2\x86\x90", 'lceil;' => "\xE2\x8C\x88", 'ldquo;' => "\xE2\x80\x9C", 'le;' => "\xE2\x89\xA4", 'lfloor;' => "\xE2\x8C\x8A", 'lowast;' => "\xE2\x88\x97", 'loz;' => "\xE2\x97\x8A", 'lrm;' => "\xE2\x80\x8E", 'lsaquo;' => "\xE2\x80\xB9", 'lsquo;' => "\xE2\x80\x98", 'LT' => "\x3C", 'lt' => "\x3C", 'LT;' => "\x3C", 'lt;' => "\x3C", 'macr' => "\xC2\xAF", 'macr;' => "\xC2\xAF", 'mdash;' => "\xE2\x80\x94", 'micro' => "\xC2\xB5", 'micro;' => "\xC2\xB5", 'middot' => "\xC2\xB7", 'middot;' => "\xC2\xB7", 'minus;' => "\xE2\x88\x92", 'Mu;' => "\xCE\x9C", 'mu;' => "\xCE\xBC", 'nabla;' => "\xE2\x88\x87", 'nbsp' => "\xC2\xA0", 'nbsp;' => "\xC2\xA0", 'ndash;' => "\xE2\x80\x93", 'ne;' => "\xE2\x89\xA0", 'ni;' => "\xE2\x88\x8B", 'not' => "\xC2\xAC", 'not;' => "\xC2\xAC", 'notin;' => "\xE2\x88\x89", 'nsub;' => "\xE2\x8A\x84", 'Ntilde' => "\xC3\x91", 'ntilde' => "\xC3\xB1", 'Ntilde;' => "\xC3\x91", 'ntilde;' => "\xC3\xB1", 'Nu;' => "\xCE\x9D", 'nu;' => "\xCE\xBD", 'Oacute' => "\xC3\x93", 'oacute' => "\xC3\xB3", 'Oacute;' => "\xC3\x93", 'oacute;' => "\xC3\xB3", 'Ocirc' => "\xC3\x94", 'ocirc' => "\xC3\xB4", 'Ocirc;' => "\xC3\x94", 'ocirc;' => "\xC3\xB4", 'OElig;' => "\xC5\x92", 'oelig;' => "\xC5\x93", 'Ograve' => "\xC3\x92", 'ograve' => "\xC3\xB2", 'Ograve;' => "\xC3\x92", 'ograve;' => "\xC3\xB2", 'oline;' => "\xE2\x80\xBE", 'Omega;' => "\xCE\xA9", 'omega;' => "\xCF\x89", 'Omicron;' => "\xCE\x9F", 'omicron;' => "\xCE\xBF", 'oplus;' => "\xE2\x8A\x95", 'or;' => "\xE2\x88\xA8", 'ordf' => "\xC2\xAA", 'ordf;' => "\xC2\xAA", 'ordm' => "\xC2\xBA", 'ordm;' => "\xC2\xBA", 'Oslash' => "\xC3\x98", 'oslash' => "\xC3\xB8", 'Oslash;' => "\xC3\x98", 'oslash;' => "\xC3\xB8", 'Otilde' => "\xC3\x95", 'otilde' => "\xC3\xB5", 'Otilde;' => "\xC3\x95", 'otilde;' => "\xC3\xB5", 'otimes;' => "\xE2\x8A\x97", 'Ouml' => "\xC3\x96", 'ouml' => "\xC3\xB6", 'Ouml;' => "\xC3\x96", 'ouml;' => "\xC3\xB6", 'para' => "\xC2\xB6", 'para;' => "\xC2\xB6", 'part;' => "\xE2\x88\x82", 'permil;' => "\xE2\x80\xB0", 'perp;' => "\xE2\x8A\xA5", 'Phi;' => "\xCE\xA6", 'phi;' => "\xCF\x86", 'Pi;' => "\xCE\xA0", 'pi;' => "\xCF\x80", 'piv;' => "\xCF\x96", 'plusmn' => "\xC2\xB1", 'plusmn;' => "\xC2\xB1", 'pound' => "\xC2\xA3", 'pound;' => "\xC2\xA3", 'Prime;' => "\xE2\x80\xB3", 'prime;' => "\xE2\x80\xB2", 'prod;' => "\xE2\x88\x8F", 'prop;' => "\xE2\x88\x9D", 'Psi;' => "\xCE\xA8", 'psi;' => "\xCF\x88", 'QUOT' => "\x22", 'quot' => "\x22", 'QUOT;' => "\x22", 'quot;' => "\x22", 'radic;' => "\xE2\x88\x9A", 'rang;' => "\xE3\x80\x89", 'raquo' => "\xC2\xBB", 'raquo;' => "\xC2\xBB", 'rArr;' => "\xE2\x87\x92", 'rarr;' => "\xE2\x86\x92", 'rceil;' => "\xE2\x8C\x89", 'rdquo;' => "\xE2\x80\x9D", 'real;' => "\xE2\x84\x9C", 'REG' => "\xC2\xAE", 'reg' => "\xC2\xAE", 'REG;' => "\xC2\xAE", 'reg;' => "\xC2\xAE", 'rfloor;' => "\xE2\x8C\x8B", 'Rho;' => "\xCE\xA1", 'rho;' => "\xCF\x81", 'rlm;' => "\xE2\x80\x8F", 'rsaquo;' => "\xE2\x80\xBA", 'rsquo;' => "\xE2\x80\x99", 'sbquo;' => "\xE2\x80\x9A", 'Scaron;' => "\xC5\xA0", 'scaron;' => "\xC5\xA1", 'sdot;' => "\xE2\x8B\x85", 'sect' => "\xC2\xA7", 'sect;' => "\xC2\xA7", 'shy' => "\xC2\xAD", 'shy;' => "\xC2\xAD", 'Sigma;' => "\xCE\xA3", 'sigma;' => "\xCF\x83", 'sigmaf;' => "\xCF\x82", 'sim;' => "\xE2\x88\xBC", 'spades;' => "\xE2\x99\xA0", 'sub;' => "\xE2\x8A\x82", 'sube;' => "\xE2\x8A\x86", 'sum;' => "\xE2\x88\x91", 'sup;' => "\xE2\x8A\x83", 'sup1' => "\xC2\xB9", 'sup1;' => "\xC2\xB9", 'sup2' => "\xC2\xB2", 'sup2;' => "\xC2\xB2", 'sup3' => "\xC2\xB3", 'sup3;' => "\xC2\xB3", 'supe;' => "\xE2\x8A\x87", 'szlig' => "\xC3\x9F", 'szlig;' => "\xC3\x9F", 'Tau;' => "\xCE\xA4", 'tau;' => "\xCF\x84", 'there4;' => "\xE2\x88\xB4", 'Theta;' => "\xCE\x98", 'theta;' => "\xCE\xB8", 'thetasym;' => "\xCF\x91", 'thinsp;' => "\xE2\x80\x89", 'THORN' => "\xC3\x9E", 'thorn' => "\xC3\xBE", 'THORN;' => "\xC3\x9E", 'thorn;' => "\xC3\xBE", 'tilde;' => "\xCB\x9C", 'times' => "\xC3\x97", 'times;' => "\xC3\x97", 'TRADE;' => "\xE2\x84\xA2", 'trade;' => "\xE2\x84\xA2", 'Uacute' => "\xC3\x9A", 'uacute' => "\xC3\xBA", 'Uacute;' => "\xC3\x9A", 'uacute;' => "\xC3\xBA", 'uArr;' => "\xE2\x87\x91", 'uarr;' => "\xE2\x86\x91", 'Ucirc' => "\xC3\x9B", 'ucirc' => "\xC3\xBB", 'Ucirc;' => "\xC3\x9B", 'ucirc;' => "\xC3\xBB", 'Ugrave' => "\xC3\x99", 'ugrave' => "\xC3\xB9", 'Ugrave;' => "\xC3\x99", 'ugrave;' => "\xC3\xB9", 'uml' => "\xC2\xA8", 'uml;' => "\xC2\xA8", 'upsih;' => "\xCF\x92", 'Upsilon;' => "\xCE\xA5", 'upsilon;' => "\xCF\x85", 'Uuml' => "\xC3\x9C", 'uuml' => "\xC3\xBC", 'Uuml;' => "\xC3\x9C", 'uuml;' => "\xC3\xBC", 'weierp;' => "\xE2\x84\x98", 'Xi;' => "\xCE\x9E", 'xi;' => "\xCE\xBE", 'Yacute' => "\xC3\x9D", 'yacute' => "\xC3\xBD", 'Yacute;' => "\xC3\x9D", 'yacute;' => "\xC3\xBD", 'yen' => "\xC2\xA5", 'yen;' => "\xC2\xA5", 'yuml' => "\xC3\xBF", 'Yuml;' => "\xC5\xB8", 'yuml;' => "\xC3\xBF", 'Zeta;' => "\xCE\x96", 'zeta;' => "\xCE\xB6", 'zwj;' => "\xE2\x80\x8D", 'zwnj;' => "\xE2\x80\x8C");
11571
+
11572
+ for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++)
11573
+ {
11574
+ $consumed = substr($this->consumed, 1);
11575
+ if (isset($entities[$consumed]))
11576
+ {
11577
+ $match = $consumed;
11578
+ }
11579
+ }
11580
+
11581
+ if ($match !== null)
11582
+ {
11583
+ $this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1);
11584
+ $this->position += strlen($entities[$match]) - strlen($consumed) - 1;
11585
+ }
11586
+ break;
11587
+ }
11588
+ }
11589
+ }
11590
+
11591
+ /**
11592
+ * IRI parser/serialiser
11593
+ *
11594
+ * @package SimplePie
11595
+ */
11596
+ class SimplePie_IRI
11597
+ {
11598
+ /**
11599
+ * Scheme
11600
+ *
11601
+ * @access private
11602
+ * @var string
11603
+ */
11604
+ var $scheme;
11605
+
11606
+ /**
11607
+ * User Information
11608
+ *
11609
+ * @access private
11610
+ * @var string
11611
+ */
11612
+ var $userinfo;
11613
+
11614
+ /**
11615
+ * Host
11616
+ *
11617
+ * @access private
11618
+ * @var string
11619
+ */
11620
+ var $host;
11621
+
11622
+ /**
11623
+ * Port
11624
+ *
11625
+ * @access private
11626
+ * @var string
11627
+ */
11628
+ var $port;
11629
+
11630
+ /**
11631
+ * Path
11632
+ *
11633
+ * @access private
11634
+ * @var string
11635
+ */
11636
+ var $path;
11637
+
11638
+ /**
11639
+ * Query
11640
+ *
11641
+ * @access private
11642
+ * @var string
11643
+ */
11644
+ var $query;
11645
+
11646
+ /**
11647
+ * Fragment
11648
+ *
11649
+ * @access private
11650
+ * @var string
11651
+ */
11652
+ var $fragment;
11653
+
11654
+ /**
11655
+ * Whether the object represents a valid IRI
11656
+ *
11657
+ * @access private
11658
+ * @var array
11659
+ */
11660
+ var $valid = array();
11661
+
11662
+ /**
11663
+ * Return the entire IRI when you try and read the object as a string
11664
+ *
11665
+ * @access public
11666
+ * @return string
11667
+ */
11668
+ function __toString()
11669
+ {
11670
+ return $this->get_iri();
11671
+ }
11672
+
11673
+ /**
11674
+ * Create a new IRI object, from a specified string
11675
+ *
11676
+ * @access public
11677
+ * @param string $iri
11678
+ * @return SimplePie_IRI
11679
+ */
11680
+ function SimplePie_IRI($iri)
11681
+ {
11682
+ $iri = (string) $iri;
11683
+ if ($iri !== '')
11684
+ {
11685
+ $parsed = $this->parse_iri($iri);
11686
+ $this->set_scheme($parsed['scheme']);
11687
+ $this->set_authority($parsed['authority']);
11688
+ $this->set_path($parsed['path']);
11689
+ $this->set_query($parsed['query']);
11690
+ $this->set_fragment($parsed['fragment']);
11691
+ }
11692
+ }
11693
+
11694
+ /**
11695
+ * Create a new IRI object by resolving a relative IRI
11696
+ *
11697
+ * @static
11698
+ * @access public
11699
+ * @param SimplePie_IRI $base Base IRI
11700
+ * @param string $relative Relative IRI
11701
+ * @return SimplePie_IRI
11702
+ */
11703
+ function absolutize($base, $relative)
11704
+ {
11705
+ $relative = (string) $relative;
11706
+ if ($relative !== '')
11707
+ {
11708
+ $relative = new SimplePie_IRI($relative);
11709
+ if ($relative->get_scheme() !== null)
11710
+ {
11711
+ $target = $relative;
11712
+ }
11713
+ elseif ($base->get_iri() !== null)
11714
+ {
11715
+ if ($relative->get_authority() !== null)
11716
+ {
11717
+ $target = $relative;
11718
+ $target->set_scheme($base->get_scheme());
11719
+ }
11720
+ else
11721
+ {
11722
+ $target = new SimplePie_IRI('');
11723
+ $target->set_scheme($base->get_scheme());
11724
+ $target->set_userinfo($base->get_userinfo());
11725
+ $target->set_host($base->get_host());
11726
+ $target->set_port($base->get_port());
11727
+ if ($relative->get_path() !== null)
11728
+ {
11729
+ if (strpos($relative->get_path(), '/') === 0)
11730
+ {
11731
+ $target->set_path($relative->get_path());
11732
+ }
11733
+ elseif (($base->get_userinfo() !== null || $base->get_host() !== null || $base->get_port() !== null) && $base->get_path() === null)
11734
+ {
11735
+ $target->set_path('/' . $relative->get_path());
11736
+ }
11737
+ elseif (($last_segment = strrpos($base->get_path(), '/')) !== false)
11738
+ {
11739
+ $target->set_path(substr($base->get_path(), 0, $last_segment + 1) . $relative->get_path());
11740
+ }
11741
+ else
11742
+ {
11743
+ $target->set_path($relative->get_path());
11744
+ }
11745
+ $target->set_query($relative->get_query());
11746
+ }
11747
+ else
11748
+ {
11749
+ $target->set_path($base->get_path());
11750
+ if ($relative->get_query() !== null)
11751
+ {
11752
+ $target->set_query($relative->get_query());
11753
+ }
11754
+ elseif ($base->get_query() !== null)
11755
+ {
11756
+ $target->set_query($base->get_query());
11757
+ }
11758
+ }
11759
+ }
11760
+ $target->set_fragment($relative->get_fragment());
11761
+ }
11762
+ else
11763
+ {
11764
+ // No base URL, just return the relative URL
11765
+ $target = $relative;
11766
+ }
11767
+ }
11768
+ else
11769
+ {
11770
+ $target = $base;
11771
+ }
11772
+ return $target;
11773
+ }
11774
+
11775
+ /**
11776
+ * Parse an IRI into scheme/authority/path/query/fragment segments
11777
+ *
11778
+ * @access private
11779
+ * @param string $iri
11780
+ * @return array
11781
+ */
11782
+ function parse_iri($iri)
11783
+ {
11784
+ preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/', $iri, $match);
11785
+ for ($i = count($match); $i <= 9; $i++)
11786
+ {
11787
+ $match[$i] = '';
11788
+ }
11789
+ return array('scheme' => $match[2], 'authority' => $match[4], 'path' => $match[5], 'query' => $match[7], 'fragment' => $match[9]);
11790
+ }
11791
+
11792
+ /**
11793
+ * Remove dot segments from a path
11794
+ *
11795
+ * @access private
11796
+ * @param string $input
11797
+ * @return string
11798
+ */
11799
+ function remove_dot_segments($input)
11800
+ {
11801
+ $output = '';
11802
+ while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..')
11803
+ {
11804
+ // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise,
11805
+ if (strpos($input, '../') === 0)
11806
+ {
11807
+ $input = substr($input, 3);
11808
+ }
11809
+ elseif (strpos($input, './') === 0)
11810
+ {
11811
+ $input = substr($input, 2);
11812
+ }
11813
+ // B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise,
11814
+ elseif (strpos($input, '/./') === 0)
11815
+ {
11816
+ $input = substr_replace($input, '/', 0, 3);
11817
+ }
11818
+ elseif ($input === '/.')
11819
+ {
11820
+ $input = '/';
11821
+ }
11822
+ // C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise,
11823
+ elseif (strpos($input, '/../') === 0)
11824
+ {
11825
+ $input = substr_replace($input, '/', 0, 4);
11826
+ $output = substr_replace($output, '', strrpos($output, '/'));
11827
+ }
11828
+ elseif ($input === '/..')
11829
+ {
11830
+ $input = '/';
11831
+ $output = substr_replace($output, '', strrpos($output, '/'));
11832
+ }
11833
+ // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise,
11834
+ elseif ($input === '.' || $input === '..')
11835
+ {
11836
+ $input = '';
11837
+ }
11838
+ // E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer
11839
+ elseif (($pos = strpos($input, '/', 1)) !== false)
11840
+ {
11841
+ $output .= substr($input, 0, $pos);
11842
+ $input = substr_replace($input, '', 0, $pos);
11843
+ }
11844
+ else
11845
+ {
11846
+ $output .= $input;
11847
+ $input = '';
11848
+ }
11849
+ }
11850
+ return $output . $input;
11851
+ }
11852
+
11853
+ /**
11854
+ * Replace invalid character with percent encoding
11855
+ *
11856
+ * @access private
11857
+ * @param string $string Input string
11858
+ * @param string $valid_chars Valid characters
11859
+ * @param int $case Normalise case
11860
+ * @return string
11861
+ */
11862
+ function replace_invalid_with_pct_encoding($string, $valid_chars, $case = SIMPLEPIE_SAME_CASE)
11863
+ {
11864
+ // Normalise case
11865
+ if ($case & SIMPLEPIE_LOWERCASE)
11866
+ {
11867
+ $string = strtolower($string);
11868
+ }
11869
+ elseif ($case & SIMPLEPIE_UPPERCASE)
11870
+ {
11871
+ $string = strtoupper($string);
11872
+ }
11873
+
11874
+ // Store position and string length (to avoid constantly recalculating this)
11875
+ $position = 0;
11876
+ $strlen = strlen($string);
11877
+
11878
+ // Loop as long as we have invalid characters, advancing the position to the next invalid character
11879
+ while (($position += strspn($string, $valid_chars, $position)) < $strlen)
11880
+ {
11881
+ // If we have a % character
11882
+ if ($string[$position] === '%')
11883
+ {
11884
+ // If we have a pct-encoded section
11885
+ if ($position + 2 < $strlen && strspn($string, '0123456789ABCDEFabcdef', $position + 1, 2) === 2)
11886
+ {
11887
+ // Get the the represented character
11888
+ $chr = chr(hexdec(substr($string, $position + 1, 2)));
11889
+
11890
+ // If the character is valid, replace the pct-encoded with the actual character while normalising case
11891
+ if (strpos($valid_chars, $chr) !== false)
11892
+ {
11893
+ if ($case & SIMPLEPIE_LOWERCASE)
11894
+ {
11895
+ $chr = strtolower($chr);
11896
+ }
11897
+ elseif ($case & SIMPLEPIE_UPPERCASE)
11898
+ {
11899
+ $chr = strtoupper($chr);
11900
+ }
11901
+ $string = substr_replace($string, $chr, $position, 3);
11902
+ $strlen -= 2;
11903
+ $position++;
11904
+ }
11905
+
11906
+ // Otherwise just normalise the pct-encoded to uppercase
11907
+ else
11908
+ {
11909
+ $string = substr_replace($string, strtoupper(substr($string, $position + 1, 2)), $position + 1, 2);
11910
+ $position += 3;
11911
+ }
11912
+ }
11913
+ // If we don't have a pct-encoded section, just replace the % with its own esccaped form
11914
+ else
11915
+ {
11916
+ $string = substr_replace($string, '%25', $position, 1);
11917
+ $strlen += 2;
11918
+ $position += 3;
11919
+ }
11920
+ }
11921
+ // If we have an invalid character, change into its pct-encoded form
11922
+ else
11923
+ {
11924
+ $replacement = sprintf("%%%02X", ord($string[$position]));
11925
+ $string = str_replace($string[$position], $replacement, $string);
11926
+ $strlen = strlen($string);
11927
+ }
11928
+ }
11929
+ return $string;
11930
+ }
11931
+
11932
+ /**
11933
+ * Check if the object represents a valid IRI
11934
+ *
11935
+ * @access public
11936
+ * @return bool
11937
+ */
11938
+ function is_valid()
11939
+ {
11940
+ return array_sum($this->valid) === count($this->valid);
11941
+ }
11942
+
11943
+ /**
11944
+ * Set the scheme. Returns true on success, false on failure (if there are
11945
+ * any invalid characters).
11946
+ *
11947
+ * @access public
11948
+ * @param string $scheme
11949
+ * @return bool
11950
+ */
11951
+ function set_scheme($scheme)
11952
+ {
11953
+ if ($scheme === null || $scheme === '')
11954
+ {
11955
+ $this->scheme = null;
11956
+ }
11957
+ else
11958
+ {
11959
+ $len = strlen($scheme);
11960
+ switch (true)
11961
+ {
11962
+ case $len > 1:
11963
+ if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-.', 1))
11964
+ {
11965
+ $this->scheme = null;
11966
+ $this->valid[__FUNCTION__] = false;
11967
+ return false;
11968
+ }
11969
+
11970
+ case $len > 0:
11971
+ if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 0, 1))
11972
+ {
11973
+ $this->scheme = null;
11974
+ $this->valid[__FUNCTION__] = false;
11975
+ return false;
11976
+ }
11977
+ }
11978
+ $this->scheme = strtolower($scheme);
11979
+ }
11980
+ $this->valid[__FUNCTION__] = true;
11981
+ return true;
11982
+ }
11983
+
11984
+ /**
11985
+ * Set the authority. Returns true on success, false on failure (if there are
11986
+ * any invalid characters).
11987
+ *
11988
+ * @access public
11989
+ * @param string $authority
11990
+ * @return bool
11991
+ */
11992
+ function set_authority($authority)
11993
+ {
11994
+ if (($userinfo_end = strrpos($authority, '@')) !== false)
11995
+ {
11996
+ $userinfo = substr($authority, 0, $userinfo_end);
11997
+ $authority = substr($authority, $userinfo_end + 1);
11998
+ }
11999
+ else
12000
+ {
12001
+ $userinfo = null;
12002
+ }
12003
+
12004
+ if (($port_start = strpos($authority, ':')) !== false)
12005
+ {
12006
+ $port = substr($authority, $port_start + 1);
12007
+ $authority = substr($authority, 0, $port_start);
12008
+ }
12009
+ else
12010
+ {
12011
+ $port = null;
12012
+ }
12013
+
12014
+ return $this->set_userinfo($userinfo) && $this->set_host($authority) && $this->set_port($port);
12015
+ }
12016
+
12017
+ /**
12018
+ * Set the userinfo.
12019
+ *
12020
+ * @access public
12021
+ * @param string $userinfo
12022
+ * @return bool
12023
+ */
12024
+ function set_userinfo($userinfo)
12025
+ {
12026
+ if ($userinfo === null || $userinfo === '')
12027
+ {
12028
+ $this->userinfo = null;
12029
+ }
12030
+ else
12031
+ {
12032
+ $this->userinfo = $this->replace_invalid_with_pct_encoding($userinfo, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:');
12033
+ }
12034
+ $this->valid[__FUNCTION__] = true;
12035
+ return true;
12036
+ }
12037
+
12038
+ /**
12039
+ * Set the host. Returns true on success, false on failure (if there are
12040
+ * any invalid characters).
12041
+ *
12042
+ * @access public
12043
+ * @param string $host
12044
+ * @return bool
12045
+ */
12046
+ function set_host($host)
12047
+ {
12048
+ if ($host === null || $host === '')
12049
+ {
12050
+ $this->host = null;
12051
+ $this->valid[__FUNCTION__] = true;
12052
+ return true;
12053
+ }
12054
+ elseif ($host[0] === '[' && substr($host, -1) === ']')
12055
+ {
12056
+ if (Net_IPv6::checkIPv6(substr($host, 1, -1)))
12057
+ {
12058
+ $this->host = $host;
12059
+ $this->valid[__FUNCTION__] = true;
12060
+ return true;
12061
+ }
12062
+ else
12063
+ {
12064
+ $this->host = null;
12065
+ $this->valid[__FUNCTION__] = false;
12066
+ return false;
12067
+ }
12068
+ }
12069
+ else
12070
+ {
12071
+ $this->host = $this->replace_invalid_with_pct_encoding($host, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=', SIMPLEPIE_LOWERCASE);
12072
+ $this->valid[__FUNCTION__] = true;
12073
+ return true;
12074
+ }
12075
+ }
12076
+
12077
+ /**
12078
+ * Set the port. Returns true on success, false on failure (if there are
12079
+ * any invalid characters).
12080
+ *
12081
+ * @access public
12082
+ * @param string $port
12083
+ * @return bool
12084
+ */
12085
+ function set_port($port)
12086
+ {
12087
+ if ($port === null || $port === '')
12088
+ {
12089
+ $this->port = null;
12090
+ $this->valid[__FUNCTION__] = true;
12091
+ return true;
12092
+ }
12093
+ elseif (strspn($port, '0123456789') === strlen($port))
12094
+ {
12095
+ $this->port = (int) $port;
12096
+ $this->valid[__FUNCTION__] = true;
12097
+ return true;
12098
+ }
12099
+ else
12100
+ {
12101
+ $this->port = null;
12102
+ $this->valid[__FUNCTION__] = false;
12103
+ return false;
12104
+ }
12105
+ }
12106
+
12107
+ /**
12108
+ * Set the path.
12109
+ *
12110
+ * @access public
12111
+ * @param string $path
12112
+ * @return bool
12113
+ */
12114
+ function set_path($path)
12115
+ {
12116
+ if ($path === null || $path === '')
12117
+ {
12118
+ $this->path = null;
12119
+ $this->valid[__FUNCTION__] = true;
12120
+ return true;
12121
+ }
12122
+ elseif (substr($path, 0, 2) === '//' && $this->userinfo === null && $this->host === null && $this->port === null)
12123
+ {
12124
+ $this->path = null;
12125
+ $this->valid[__FUNCTION__] = false;
12126
+ return false;
12127
+ }
12128
+ else
12129
+ {
12130
+ $this->path = $this->replace_invalid_with_pct_encoding($path, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=@/');
12131
+ if ($this->scheme !== null)
12132
+ {
12133
+ $this->path = $this->remove_dot_segments($this->path);
12134
+ }
12135
+ $this->valid[__FUNCTION__] = true;
12136
+ return true;
12137
+ }
12138
+ }
12139
+
12140
+ /**
12141
+ * Set the query.
12142
+ *
12143
+ * @access public
12144
+ * @param string $query
12145
+ * @return bool
12146
+ */
12147
+ function set_query($query)
12148
+ {
12149
+ if ($query === null || $query === '')
12150
+ {
12151
+ $this->query = null;
12152
+ }
12153
+ else
12154
+ {
12155
+ $this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$\'()*+,;:@/?');
12156
+ $this->query = $query;
12157
+ }
12158
+ $this->valid[__FUNCTION__] = true;
12159
+ return true;
12160
+ }
12161
+
12162
+ /**
12163
+ * Set the fragment.
12164
+ *
12165
+ * @access public
12166
+ * @param string $fragment
12167
+ * @return bool
12168
+ */
12169
+ function set_fragment($fragment)
12170
+ {
12171
+ if ($fragment === null || $fragment === '')
12172
+ {
12173
+ $this->fragment = null;
12174
+ }
12175
+ else
12176
+ {
12177
+ $this->fragment = $this->replace_invalid_with_pct_encoding($fragment, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:@/?');
12178
+ }
12179
+ $this->valid[__FUNCTION__] = true;
12180
+ return true;
12181
+ }
12182
+
12183
+ /**
12184
+ * Get the complete IRI
12185
+ *
12186
+ * @access public
12187
+ * @return string
12188
+ */
12189
+ function get_iri()
12190
+ {
12191
+ $iri = '';
12192
+ if ($this->scheme !== null)
12193
+ {
12194
+ $iri .= $this->scheme . ':';
12195
+ }
12196
+ if (($authority = $this->get_authority()) !== null)
12197
+ {
12198
+ $iri .= '//' . $authority;
12199
+ }
12200
+ if ($this->path !== null)
12201
+ {
12202
+ $iri .= $this->path;
12203
+ }
12204
+ if ($this->query !== null)
12205
+ {
12206
+ $iri .= '?' . $this->query;
12207
+ }
12208
+ if ($this->fragment !== null)
12209
+ {
12210
+ $iri .= '#' . $this->fragment;
12211
+ }
12212
+
12213
+ if ($iri !== '')
12214
+ {
12215
+ return $iri;
12216
+ }
12217
+ else
12218
+ {
12219
+ return null;
12220
+ }
12221
+ }
12222
+
12223
+ /**
12224
+ * Get the scheme
12225
+ *
12226
+ * @access public
12227
+ * @return string
12228
+ */
12229
+ function get_scheme()
12230
+ {
12231
+ return $this->scheme;
12232
+ }
12233
+
12234
+ /**
12235
+ * Get the complete authority
12236
+ *
12237
+ * @access public
12238
+ * @return string
12239
+ */
12240
+ function get_authority()
12241
+ {
12242
+ $authority = '';
12243
+ if ($this->userinfo !== null)
12244
+ {
12245
+ $authority .= $this->userinfo . '@';
12246
+ }
12247
+ if ($this->host !== null)
12248
+ {
12249
+ $authority .= $this->host;
12250
+ }
12251
+ if ($this->port !== null)
12252
+ {
12253
+ $authority .= ':' . $this->port;
12254
+ }
12255
+
12256
+ if ($authority !== '')
12257
+ {
12258
+ return $authority;
12259
+ }
12260
+ else
12261
+ {
12262
+ return null;
12263
+ }
12264
+ }
12265
+
12266
+ /**
12267
+ * Get the user information
12268
+ *
12269
+ * @access public
12270
+ * @return string
12271
+ */
12272
+ function get_userinfo()
12273
+ {
12274
+ return $this->userinfo;
12275
+ }
12276
+
12277
+ /**
12278
+ * Get the host
12279
+ *
12280
+ * @access public
12281
+ * @return string
12282
+ */
12283
+ function get_host()
12284
+ {
12285
+ return $this->host;
12286
+ }
12287
+
12288
+ /**
12289
+ * Get the port
12290
+ *
12291
+ * @access public
12292
+ * @return string
12293
+ */
12294
+ function get_port()
12295
+ {
12296
+ return $this->port;
12297
+ }
12298
+
12299
+ /**
12300
+ * Get the path
12301
+ *
12302
+ * @access public
12303
+ * @return string
12304
+ */
12305
+ function get_path()
12306
+ {
12307
+ return $this->path;
12308
+ }
12309
+
12310
+ /**
12311
+ * Get the query
12312
+ *
12313
+ * @access public
12314
+ * @return string
12315
+ */
12316
+ function get_query()
12317
+ {
12318
+ return $this->query;
12319
+ }
12320
+
12321
+ /**
12322
+ * Get the fragment
12323
+ *
12324
+ * @access public
12325
+ * @return string
12326
+ */
12327
+ function get_fragment()
12328
+ {
12329
+ return $this->fragment;
12330
+ }
12331
+ }
12332
+
12333
+ /**
12334
+ * Class to validate and to work with IPv6 addresses.
12335
+ *
12336
+ * @package SimplePie
12337
+ * @copyright 2003-2005 The PHP Group
12338
+ * @license http://www.opensource.org/licenses/bsd-license.php
12339
+ * @link http://pear.php.net/package/Net_IPv6
12340
+ * @author Alexander Merz <alexander.merz@web.de>
12341
+ * @author elfrink at introweb dot nl
12342
+ * @author Josh Peck <jmp at joshpeck dot org>
12343
+ * @author Geoffrey Sneddon <geoffers@gmail.com>
12344
+ */
12345
+ class SimplePie_Net_IPv6
12346
+ {
12347
+ /**
12348
+ * Removes a possible existing netmask specification of an IP address.
12349
+ *
12350
+ * @param string $ip the (compressed) IP as Hex representation
12351
+ * @return string the IP the without netmask
12352
+ * @since 1.1.0
12353
+ * @access public
12354
+ * @static
12355
+ */
12356
+ function removeNetmaskSpec($ip)
12357
+ {
12358
+ if (strpos($ip, '/') !== false)
12359
+ {
12360
+ list($addr, $nm) = explode('/', $ip);
12361
+ }
12362
+ else
12363
+ {
12364
+ $addr = $ip;
12365
+ }
12366
+ return $addr;
12367
+ }
12368
+
12369
+ /**
12370
+ * Uncompresses an IPv6 address
12371
+ *
12372
+ * RFC 2373 allows you to compress zeros in an address to '::'. This
12373
+ * function expects an valid IPv6 address and expands the '::' to
12374
+ * the required zeros.
12375
+ *
12376
+ * Example: FF01::101 -> FF01:0:0:0:0:0:0:101
12377
+ * ::1 -> 0:0:0:0:0:0:0:1
12378
+ *
12379
+ * @access public
12380
+ * @static
12381
+ * @param string $ip a valid IPv6-address (hex format)
12382
+ * @return string the uncompressed IPv6-address (hex format)
12383
+ */
12384
+ function Uncompress($ip)
12385
+ {
12386
+ $uip = SimplePie_Net_IPv6::removeNetmaskSpec($ip);
12387
+ $c1 = -1;
12388
+ $c2 = -1;
12389
+ if (strpos($ip, '::') !== false)
12390
+ {
12391
+ list($ip1, $ip2) = explode('::', $ip);
12392
+ if ($ip1 === '')
12393
+ {
12394
+ $c1 = -1;
12395
+ }
12396
+ else
12397
+ {
12398
+ $pos = 0;
12399
+ if (($pos = substr_count($ip1, ':')) > 0)
12400
+ {
12401
+ $c1 = $pos;
12402
+ }
12403
+ else
12404
+ {
12405
+ $c1 = 0;
12406
+ }
12407
+ }
12408
+ if ($ip2 === '')
12409
+ {
12410
+ $c2 = -1;
12411
+ }
12412
+ else
12413
+ {
12414
+ $pos = 0;
12415
+ if (($pos = substr_count($ip2, ':')) > 0)
12416
+ {
12417
+ $c2 = $pos;
12418
+ }
12419
+ else
12420
+ {
12421
+ $c2 = 0;
12422
+ }
12423
+ }
12424
+ if (strstr($ip2, '.'))
12425
+ {
12426
+ $c2++;
12427
+ }
12428
+ // ::
12429
+ if ($c1 === -1 && $c2 === -1)
12430
+ {
12431
+ $uip = '0:0:0:0:0:0:0:0';
12432
+ }
12433
+ // ::xxx
12434
+ else if ($c1 === -1)
12435
+ {
12436
+ $fill = str_repeat('0:', 7 - $c2);
12437
+ $uip = str_replace('::', $fill, $uip);
12438
+ }
12439
+ // xxx::
12440
+ else if ($c2 === -1)
12441
+ {
12442
+ $fill = str_repeat(':0', 7 - $c1);
12443
+ $uip = str_replace('::', $fill, $uip);
12444
+ }
12445
+ // xxx::xxx
12446
+ else
12447
+ {
12448
+ $fill = str_repeat(':0:', 6 - $c2 - $c1);
12449
+ $uip = str_replace('::', $fill, $uip);
12450
+ $uip = str_replace('::', ':', $uip);
12451
+ }
12452
+ }
12453
+ return $uip;
12454
+ }
12455
+
12456
+ /**
12457
+ * Splits an IPv6 address into the IPv6 and a possible IPv4 part
12458
+ *
12459
+ * RFC 2373 allows you to note the last two parts of an IPv6 address as
12460
+ * an IPv4 compatible address
12461
+ *
12462
+ * Example: 0:0:0:0:0:0:13.1.68.3
12463
+ * 0:0:0:0:0:FFFF:129.144.52.38
12464
+ *
12465
+ * @access public
12466
+ * @static
12467
+ * @param string $ip a valid IPv6-address (hex format)
12468
+ * @return array [0] contains the IPv6 part, [1] the IPv4 part (hex format)
12469
+ */
12470
+ function SplitV64($ip)
12471
+ {
12472
+ $ip = SimplePie_Net_IPv6::Uncompress($ip);
12473
+ if (strstr($ip, '.'))
12474
+ {
12475
+ $pos = strrpos($ip, ':');
12476
+ $ip[$pos] = '_';
12477
+ $ipPart = explode('_', $ip);
12478
+ return $ipPart;
12479
+ }
12480
+ else
12481
+ {
12482
+ return array($ip, '');
12483
+ }
12484
+ }
12485
+
12486
+ /**
12487
+ * Checks an IPv6 address
12488
+ *
12489
+ * Checks if the given IP is IPv6-compatible
12490
+ *
12491
+ * @access public
12492
+ * @static
12493
+ * @param string $ip a valid IPv6-address
12494
+ * @return bool true if $ip is an IPv6 address
12495
+ */
12496
+ function checkIPv6($ip)
12497
+ {
12498
+ $ipPart = SimplePie_Net_IPv6::SplitV64($ip);
12499
+ $count = 0;
12500
+ if (!empty($ipPart[0]))
12501
+ {
12502
+ $ipv6 = explode(':', $ipPart[0]);
12503
+ for ($i = 0; $i < count($ipv6); $i++)
12504
+ {
12505
+ $dec = hexdec($ipv6[$i]);
12506
+ $hex = strtoupper(preg_replace('/^[0]{1,3}(.*[0-9a-fA-F])$/', '\\1', $ipv6[$i]));
12507
+ if ($ipv6[$i] >= 0 && $dec <= 65535 && $hex === strtoupper(dechex($dec)))
12508
+ {
12509
+ $count++;
12510
+ }
12511
+ }
12512
+ if ($count === 8)
12513
+ {
12514
+ return true;
12515
+ }
12516
+ elseif ($count === 6 && !empty($ipPart[1]))
12517
+ {
12518
+ $ipv4 = explode('.', $ipPart[1]);
12519
+ $count = 0;
12520
+ foreach ($ipv4 as $ipv4_part)
12521
+ {
12522
+ if ($ipv4_part >= 0 && $ipv4_part <= 255 && preg_match('/^\d{1,3}$/', $ipv4_part))
12523
+ {
12524
+ $count++;
12525
+ }
12526
+ }
12527
+ if ($count === 4)
12528
+ {
12529
+ return true;
12530
+ }
12531
+ }
12532
+ else
12533
+ {
12534
+ return false;
12535
+ }
12536
+
12537
+ }
12538
+ else
12539
+ {
12540
+ return false;
12541
+ }
12542
+ }
12543
+ }
12544
+
12545
+ /**
12546
+ * Date Parser
12547
+ *
12548
+ * @package SimplePie
12549
+ */
12550
+ class SimplePie_Parse_Date
12551
+ {
12552
+ /**
12553
+ * Input data
12554
+ *
12555
+ * @access protected
12556
+ * @var string
12557
+ */
12558
+ var $date;
12559
+
12560
+ /**
12561
+ * List of days, calendar day name => ordinal day number in the week
12562
+ *
12563
+ * @access protected
12564
+ * @var array
12565
+ */
12566
+ var $day = array(
12567
+ // English
12568
+ 'mon' => 1,
12569
+ 'monday' => 1,
12570
+ 'tue' => 2,
12571
+ 'tuesday' => 2,
12572
+ 'wed' => 3,
12573
+ 'wednesday' => 3,
12574
+ 'thu' => 4,
12575
+ 'thursday' => 4,
12576
+ 'fri' => 5,
12577
+ 'friday' => 5,
12578
+ 'sat' => 6,
12579
+ 'saturday' => 6,
12580
+ 'sun' => 7,
12581
+ 'sunday' => 7,
12582
+ // Dutch
12583
+ 'maandag' => 1,
12584
+ 'dinsdag' => 2,
12585
+ 'woensdag' => 3,
12586
+ 'donderdag' => 4,
12587
+ 'vrijdag' => 5,
12588
+ 'zaterdag' => 6,
12589
+ 'zondag' => 7,
12590
+ // French
12591
+ 'lundi' => 1,
12592
+ 'mardi' => 2,
12593
+ 'mercredi' => 3,
12594
+ 'jeudi' => 4,
12595
+ 'vendredi' => 5,
12596
+ 'samedi' => 6,
12597
+ 'dimanche' => 7,
12598
+ // German
12599
+ 'montag' => 1,
12600
+ 'dienstag' => 2,
12601
+ 'mittwoch' => 3,
12602
+ 'donnerstag' => 4,
12603
+ 'freitag' => 5,
12604
+ 'samstag' => 6,
12605
+ 'sonnabend' => 6,
12606
+ 'sonntag' => 7,
12607
+ // Italian
12608
+ 'lunedì' => 1,
12609
+ 'martedì' => 2,
12610
+ 'mercoledì' => 3,
12611
+ 'giovedì' => 4,
12612
+ 'venerdì' => 5,
12613
+ 'sabato' => 6,
12614
+ 'domenica' => 7,
12615
+ // Spanish
12616
+ 'lunes' => 1,
12617
+ 'martes' => 2,
12618
+ 'miércoles' => 3,
12619
+ 'jueves' => 4,
12620
+ 'viernes' => 5,
12621
+ 'sábado' => 6,
12622
+ 'domingo' => 7,
12623
+ // Finnish
12624
+ 'maanantai' => 1,
12625
+ 'tiistai' => 2,
12626
+ 'keskiviikko' => 3,
12627
+ 'torstai' => 4,
12628
+ 'perjantai' => 5,
12629
+ 'lauantai' => 6,
12630
+ 'sunnuntai' => 7,
12631
+ // Hungarian
12632
+ 'hétfő' => 1,
12633
+ 'kedd' => 2,
12634
+ 'szerda' => 3,
12635
+ 'csütörtok' => 4,
12636
+ 'péntek' => 5,
12637
+ 'szombat' => 6,
12638
+ 'vasárnap' => 7,
12639
+ // Greek
12640
+ 'Δευ' => 1,
12641
+ 'Τρι' => 2,
12642
+ 'Τετ' => 3,
12643
+ 'Πεμ' => 4,
12644
+ 'Παρ' => 5,
12645
+ 'Σαβ' => 6,
12646
+ 'Κυρ' => 7,
12647
+ );
12648
+
12649
+ /**
12650
+ * List of months, calendar month name => calendar month number
12651
+ *
12652
+ * @access protected
12653
+ * @var array
12654
+ */
12655
+ var $month = array(
12656
+ // English
12657
+ 'jan' => 1,
12658
+ 'january' => 1,
12659
+ 'feb' => 2,
12660
+ 'february' => 2,
12661
+ 'mar' => 3,
12662
+ 'march' => 3,
12663
+ 'apr' => 4,
12664
+ 'april' => 4,
12665
+ 'may' => 5,
12666
+ // No long form of May
12667
+ 'jun' => 6,
12668
+ 'june' => 6,
12669
+ 'jul' => 7,
12670
+ 'july' => 7,
12671
+ 'aug' => 8,
12672
+ 'august' => 8,
12673
+ 'sep' => 9,
12674
+ 'september' => 8,
12675
+ 'oct' => 10,
12676
+ 'october' => 10,
12677
+ 'nov' => 11,
12678
+ 'november' => 11,
12679
+ 'dec' => 12,
12680
+ 'december' => 12,
12681
+ // Dutch
12682
+ 'januari' => 1,
12683
+ 'februari' => 2,
12684
+ 'maart' => 3,
12685
+ 'april' => 4,
12686
+ 'mei' => 5,
12687
+ 'juni' => 6,
12688
+ 'juli' => 7,
12689
+ 'augustus' => 8,
12690
+ 'september' => 9,
12691
+ 'oktober' => 10,
12692
+ 'november' => 11,
12693
+ 'december' => 12,
12694
+ // French
12695
+ 'janvier' => 1,
12696
+ 'février' => 2,
12697
+ 'mars' => 3,
12698
+ 'avril' => 4,
12699
+ 'mai' => 5,
12700
+ 'juin' => 6,
12701
+ 'juillet' => 7,
12702
+ 'août' => 8,
12703
+ 'septembre' => 9,
12704
+ 'octobre' => 10,
12705
+ 'novembre' => 11,
12706
+ 'décembre' => 12,
12707
+ // German
12708
+ 'januar' => 1,
12709
+ 'februar' => 2,
12710
+ 'märz' => 3,
12711
+ 'april' => 4,
12712
+ 'mai' => 5,
12713
+ 'juni' => 6,
12714
+ 'juli' => 7,
12715
+ 'august' => 8,
12716
+ 'september' => 9,
12717
+ 'oktober' => 10,
12718
+ 'november' => 11,
12719
+ 'dezember' => 12,
12720
+ // Italian
12721
+ 'gennaio' => 1,
12722
+ 'febbraio' => 2,
12723
+ 'marzo' => 3,
12724
+ 'aprile' => 4,
12725
+ 'maggio' => 5,
12726
+ 'giugno' => 6,
12727
+ 'luglio' => 7,
12728
+ 'agosto' => 8,
12729
+ 'settembre' => 9,
12730
+ 'ottobre' => 10,
12731
+ 'novembre' => 11,
12732
+ 'dicembre' => 12,
12733
+ // Spanish
12734
+ 'enero' => 1,
12735
+ 'febrero' => 2,
12736
+ 'marzo' => 3,
12737
+ 'abril' => 4,
12738
+ 'mayo' => 5,
12739
+ 'junio' => 6,
12740
+ 'julio' => 7,
12741
+ 'agosto' => 8,
12742
+ 'septiembre' => 9,
12743
+ 'setiembre' => 9,
12744
+ 'octubre' => 10,
12745
+ 'noviembre' => 11,
12746
+ 'diciembre' => 12,
12747
+ // Finnish
12748
+ 'tammikuu' => 1,
12749
+ 'helmikuu' => 2,
12750
+ 'maaliskuu' => 3,
12751
+ 'huhtikuu' => 4,
12752
+ 'toukokuu' => 5,
12753
+ 'kesäkuu' => 6,
12754
+ 'heinäkuu' => 7,
12755
+ 'elokuu' => 8,
12756
+ 'suuskuu' => 9,
12757
+ 'lokakuu' => 10,
12758
+ 'marras' => 11,
12759
+ 'joulukuu' => 12,
12760
+ // Hungarian
12761
+ 'január' => 1,
12762
+ 'február' => 2,
12763
+ 'március' => 3,
12764
+ 'április' => 4,
12765
+ 'május' => 5,
12766
+ 'június' => 6,
12767
+ 'július' => 7,
12768
+ 'augusztus' => 8,
12769
+ 'szeptember' => 9,
12770
+ 'október' => 10,
12771
+ 'november' => 11,
12772
+ 'december' => 12,
12773
+ // Greek
12774
+ 'Ιαν' => 1,
12775
+ 'Φεβ' => 2,
12776
+ 'Μάώ' => 3,
12777
+ 'Μαώ' => 3,
12778
+ 'Απρ' => 4,
12779
+ 'Μάι' => 5,
12780
+ 'Μαϊ' => 5,
12781
+ 'Μαι' => 5,
12782
+ 'Ιούν' => 6,
12783
+ 'Ιον' => 6,
12784
+ 'Ιούλ' => 7,
12785
+ 'Ιολ' => 7,
12786
+ 'Αύγ' => 8,
12787
+ 'Αυγ' => 8,
12788
+ 'Σεπ' => 9,
12789
+ 'Οκτ' => 10,
12790
+ 'Νοέ' => 11,
12791
+ 'Δεκ' => 12,
12792
+ );
12793
+
12794
+ /**
12795
+ * List of timezones, abbreviation => offset from UTC
12796
+ *
12797
+ * @access protected
12798
+ * @var array
12799
+ */
12800
+ var $timezone = array(
12801
+ 'ACDT' => 37800,
12802
+ 'ACIT' => 28800,
12803
+ 'ACST' => 34200,
12804
+ 'ACT' => -18000,
12805
+ 'ACWDT' => 35100,
12806
+ 'ACWST' => 31500,
12807
+ 'AEDT' => 39600,
12808
+ 'AEST' => 36000,
12809
+ 'AFT' => 16200,
12810
+ 'AKDT' => -28800,
12811
+ 'AKST' => -32400,
12812
+ 'AMDT' => 18000,
12813
+ 'AMT' => -14400,
12814
+ 'ANAST' => 46800,
12815
+ 'ANAT' => 43200,
12816
+ 'ART' => -10800,
12817
+ 'AZOST' => -3600,
12818
+ 'AZST' => 18000,
12819
+ 'AZT' => 14400,
12820
+ 'BIOT' => 21600,
12821
+ 'BIT' => -43200,
12822
+ 'BOT' => -14400,
12823
+ 'BRST' => -7200,
12824
+ 'BRT' => -10800,
12825
+ 'BST' => 3600,
12826
+ 'BTT' => 21600,
12827
+ 'CAST' => 18000,
12828
+ 'CAT' => 7200,
12829
+ 'CCT' => 23400,
12830
+ 'CDT' => -18000,
12831
+ 'CEDT' => 7200,
12832
+ 'CET' => 3600,
12833
+ 'CGST' => -7200,
12834
+ 'CGT' => -10800,
12835
+ 'CHADT' => 49500,
12836
+ 'CHAST' => 45900,
12837
+ 'CIST' => -28800,
12838
+ 'CKT' => -36000,
12839
+ 'CLDT' => -10800,
12840
+ 'CLST' => -14400,
12841
+ 'COT' => -18000,
12842
+ 'CST' => -21600,
12843
+ 'CVT' => -3600,
12844
+ 'CXT' => 25200,
12845
+ 'DAVT' => 25200,
12846
+ 'DTAT' => 36000,
12847
+ 'EADT' => -18000,
12848
+ 'EAST' => -21600,
12849
+ 'EAT' => 10800,
12850
+ 'ECT' => -18000,
12851
+ 'EDT' => -14400,
12852
+ 'EEST' => 10800,
12853
+ 'EET' => 7200,
12854
+ 'EGT' => -3600,
12855
+ 'EKST' => 21600,
12856
+ 'EST' => -18000,
12857
+ 'FJT' => 43200,
12858
+ 'FKDT' => -10800,
12859
+ 'FKST' => -14400,
12860
+ 'FNT' => -7200,
12861
+ 'GALT' => -21600,
12862
+ 'GEDT' => 14400,
12863
+ 'GEST' => 10800,
12864
+ 'GFT' => -10800,
12865
+ 'GILT' => 43200,
12866
+ 'GIT' => -32400,
12867
+ 'GST' => 14400,
12868
+ 'GST' => -7200,
12869
+ 'GYT' => -14400,
12870
+ 'HAA' => -10800,
12871
+ 'HAC' => -18000,
12872
+ 'HADT' => -32400,
12873
+ 'HAE' => -14400,
12874
+ 'HAP' => -25200,
12875
+ 'HAR' => -21600,
12876
+ 'HAST' => -36000,
12877
+ 'HAT' => -9000,
12878
+ 'HAY' => -28800,
12879
+ 'HKST' => 28800,
12880
+ 'HMT' => 18000,
12881
+ 'HNA' => -14400,
12882
+ 'HNC' => -21600,
12883
+ 'HNE' => -18000,
12884
+ 'HNP' => -28800,
12885
+ 'HNR' => -25200,
12886
+ 'HNT' => -12600,
12887
+ 'HNY' => -32400,
12888
+ 'IRDT' => 16200,
12889
+ 'IRKST' => 32400,
12890
+ 'IRKT' => 28800,
12891
+ 'IRST' => 12600,
12892
+ 'JFDT' => -10800,
12893
+ 'JFST' => -14400,
12894
+ 'JST' => 32400,
12895
+ 'KGST' => 21600,
12896
+ 'KGT' => 18000,
12897
+ 'KOST' => 39600,
12898
+ 'KOVST' => 28800,
12899
+ 'KOVT' => 25200,
12900
+ 'KRAST' => 28800,
12901
+ 'KRAT' => 25200,
12902
+ 'KST' => 32400,
12903
+ 'LHDT' => 39600,
12904
+ 'LHST' => 37800,
12905
+ 'LINT' => 50400,
12906
+ 'LKT' => 21600,
12907
+ 'MAGST' => 43200,
12908
+ 'MAGT' => 39600,
12909
+ 'MAWT' => 21600,
12910
+ 'MDT' => -21600,
12911
+ 'MESZ' => 7200,
12912
+ 'MEZ' => 3600,
12913
+ 'MHT' => 43200,
12914
+ 'MIT' => -34200,
12915
+ 'MNST' => 32400,
12916
+ 'MSDT' => 14400,
12917
+ 'MSST' => 10800,
12918
+ 'MST' => -25200,
12919
+ 'MUT' => 14400,
12920
+ 'MVT' => 18000,
12921
+ 'MYT' => 28800,
12922
+ 'NCT' => 39600,
12923
+ 'NDT' => -9000,
12924
+ 'NFT' => 41400,
12925
+ 'NMIT' => 36000,
12926
+ 'NOVST' => 25200,
12927
+ 'NOVT' => 21600,
12928
+ 'NPT' => 20700,
12929
+ 'NRT' => 43200,
12930
+ 'NST' => -12600,
12931
+ 'NUT' => -39600,
12932
+ 'NZDT' => 46800,
12933
+ 'NZST' => 43200,
12934
+ 'OMSST' => 25200,
12935
+ 'OMST' => 21600,
12936
+ 'PDT' => -25200,
12937
+ 'PET' => -18000,
12938
+ 'PETST' => 46800,
12939
+ 'PETT' => 43200,
12940
+ 'PGT' => 36000,
12941
+ 'PHOT' => 46800,
12942
+ 'PHT' => 28800,
12943
+ 'PKT' => 18000,
12944
+ 'PMDT' => -7200,
12945
+ 'PMST' => -10800,
12946
+ 'PONT' => 39600,
12947
+ 'PST' => -28800,
12948
+ 'PWT' => 32400,
12949
+ 'PYST' => -10800,
12950
+ 'PYT' => -14400,
12951
+ 'RET' => 14400,
12952
+ 'ROTT' => -10800,
12953
+ 'SAMST' => 18000,
12954
+ 'SAMT' => 14400,
12955
+ 'SAST' => 7200,
12956
+ 'SBT' => 39600,
12957
+ 'SCDT' => 46800,
12958
+ 'SCST' => 43200,
12959
+ 'SCT' => 14400,
12960
+ 'SEST' => 3600,
12961
+ 'SGT' => 28800,
12962
+ 'SIT' => 28800,
12963
+ 'SRT' => -10800,
12964
+ 'SST' => -39600,
12965
+ 'SYST' => 10800,
12966
+ 'SYT' => 7200,
12967
+ 'TFT' => 18000,
12968
+ 'THAT' => -36000,
12969
+ 'TJT' => 18000,
12970
+ 'TKT' => -36000,
12971
+ 'TMT' => 18000,
12972
+ 'TOT' => 46800,
12973
+ 'TPT' => 32400,
12974
+ 'TRUT' => 36000,
12975
+ 'TVT' => 43200,
12976
+ 'TWT' => 28800,
12977
+ 'UYST' => -7200,
12978
+ 'UYT' => -10800,
12979
+ 'UZT' => 18000,
12980
+ 'VET' => -14400,
12981
+ 'VLAST' => 39600,
12982
+ 'VLAT' => 36000,
12983
+ 'VOST' => 21600,
12984
+ 'VUT' => 39600,
12985
+ 'WAST' => 7200,
12986
+ 'WAT' => 3600,
12987
+ 'WDT' => 32400,
12988
+ 'WEST' => 3600,
12989
+ 'WFT' => 43200,
12990
+ 'WIB' => 25200,
12991
+ 'WIT' => 32400,
12992
+ 'WITA' => 28800,
12993
+ 'WKST' => 18000,
12994
+ 'WST' => 28800,
12995
+ 'YAKST' => 36000,
12996
+ 'YAKT' => 32400,
12997
+ 'YAPT' => 36000,
12998
+ 'YEKST' => 21600,
12999
+ 'YEKT' => 18000,
13000
+ );
13001
+
13002
+ /**
13003
+ * Cached PCRE for SimplePie_Parse_Date::$day
13004
+ *
13005
+ * @access protected
13006
+ * @var string
13007
+ */
13008
+ var $day_pcre;
13009
+
13010
+ /**
13011
+ * Cached PCRE for SimplePie_Parse_Date::$month
13012
+ *
13013
+ * @access protected
13014
+ * @var string
13015
+ */
13016
+ var $month_pcre;
13017
+
13018
+ /**
13019
+ * Array of user-added callback methods
13020
+ *
13021
+ * @access private
13022
+ * @var array
13023
+ */
13024
+ var $built_in = array();
13025
+
13026
+ /**
13027
+ * Array of user-added callback methods
13028
+ *
13029
+ * @access private
13030
+ * @var array
13031
+ */
13032
+ var $user = array();
13033
+
13034
+ /**
13035
+ * Create new SimplePie_Parse_Date object, and set self::day_pcre,
13036
+ * self::month_pcre, and self::built_in
13037
+ *
13038
+ * @access private
13039
+ */
13040
+ function SimplePie_Parse_Date()
13041
+ {
13042
+ $this->day_pcre = '(' . implode(array_keys($this->day), '|') . ')';
13043
+ $this->month_pcre = '(' . implode(array_keys($this->month), '|') . ')';
13044
+
13045
+ static $cache;
13046
+ if (!isset($cache[get_class($this)]))
13047
+ {
13048
+ $all_methods = get_class_methods($this);
13049
+
13050
+ foreach ($all_methods as $method)
13051
+ {
13052
+ if (strtolower(substr($method, 0, 5)) === 'date_')
13053
+ {
13054
+ $cache[get_class($this)][] = $method;
13055
+ }
13056
+ }
13057
+ }
13058
+
13059
+ foreach ($cache[get_class($this)] as $method)
13060
+ {
13061
+ $this->built_in[] = $method;
13062
+ }
13063
+ }
13064
+
13065
+ /**
13066
+ * Get the object
13067
+ *
13068
+ * @access public
13069
+ */
13070
+ function get()
13071
+ {
13072
+ static $object;
13073
+ if (!$object)
13074
+ {
13075
+ $object = new SimplePie_Parse_Date;
13076
+ }
13077
+ return $object;
13078
+ }
13079
+
13080
+ /**
13081
+ * Parse a date
13082
+ *
13083
+ * @final
13084
+ * @access public
13085
+ * @param string $date Date to parse
13086
+ * @return int Timestamp corresponding to date string, or false on failure
13087
+ */
13088
+ function parse($date)
13089
+ {
13090
+ foreach ($this->user as $method)
13091
+ {
13092
+ if (($returned = call_user_func($method, $date)) !== false)
13093
+ {
13094
+ return $returned;
13095
+ }
13096
+ }
13097
+
13098
+ foreach ($this->built_in as $method)
13099
+ {
13100
+ if (($returned = call_user_func(array(&$this, $method), $date)) !== false)
13101
+ {
13102
+ return $returned;
13103
+ }
13104
+ }
13105
+
13106
+ return false;
13107
+ }
13108
+
13109
+ /**
13110
+ * Add a callback method to parse a date
13111
+ *
13112
+ * @final
13113
+ * @access public
13114
+ * @param callback $callback
13115
+ */
13116
+ function add_callback($callback)
13117
+ {
13118
+ if (is_callable($callback))
13119
+ {
13120
+ $this->user[] = $callback;
13121
+ }
13122
+ else
13123
+ {
13124
+ trigger_error('User-supplied function must be a valid callback', E_USER_WARNING);
13125
+ }
13126
+ }
13127
+
13128
+ /**
13129
+ * Parse a superset of W3C-DTF (allows hyphens and colons to be omitted, as
13130
+ * well as allowing any of upper or lower case "T", horizontal tabs, or
13131
+ * spaces to be used as the time seperator (including more than one))
13132
+ *
13133
+ * @access protected
13134
+ * @return int Timestamp
13135
+ */
13136
+ function date_w3cdtf($date)
13137
+ {
13138
+ static $pcre;
13139
+ if (!$pcre)
13140
+ {
13141
+ $year = '([0-9]{4})';
13142
+ $month = $day = $hour = $minute = $second = '([0-9]{2})';
13143
+ $decimal = '([0-9]*)';
13144
+ $zone = '(?:(Z)|([+\-])([0-9]{1,2}):?([0-9]{1,2}))';
13145
+ $pcre = '/^' . $year . '(?:-?' . $month . '(?:-?' . $day . '(?:[Tt\x09\x20]+' . $hour . '(?::?' . $minute . '(?::?' . $second . '(?:.' . $decimal . ')?)?)?' . $zone . ')?)?)?$/';
13146
+ }
13147
+ if (preg_match($pcre, $date, $match))
13148
+ {
13149
+ /*
13150
+ Capturing subpatterns:
13151
+ 1: Year
13152
+ 2: Month
13153
+ 3: Day
13154
+ 4: Hour
13155
+ 5: Minute
13156
+ 6: Second
13157
+ 7: Decimal fraction of a second
13158
+ 8: Zulu
13159
+ 9: Timezone ±
13160
+ 10: Timezone hours
13161
+ 11: Timezone minutes
13162
+ */
13163
+
13164
+ // Fill in empty matches
13165
+ for ($i = count($match); $i <= 3; $i++)
13166
+ {
13167
+ $match[$i] = '1';
13168
+ }
13169
+
13170
+ for ($i = count($match); $i <= 7; $i++)
13171
+ {
13172
+ $match[$i] = '0';
13173
+ }
13174
+
13175
+ // Numeric timezone
13176
+ if (isset($match[9]) && $match[9] !== '')
13177
+ {
13178
+ $timezone = $match[10] * 3600;
13179
+ $timezone += $match[11] * 60;
13180
+ if ($match[9] === '-')
13181
+ {
13182
+ $timezone = 0 - $timezone;
13183
+ }
13184
+ }
13185
+ else
13186
+ {
13187
+ $timezone = 0;
13188
+ }
13189
+
13190
+ // Convert the number of seconds to an integer, taking decimals into account
13191
+ $second = round($match[6] + $match[7] / pow(10, strlen($match[7])));
13192
+
13193
+ return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone;
13194
+ }
13195
+ else
13196
+ {
13197
+ return false;
13198
+ }
13199
+ }
13200
+
13201
+ /**
13202
+ * Remove RFC822 comments
13203
+ *
13204
+ * @access protected
13205
+ * @param string $data Data to strip comments from
13206
+ * @return string Comment stripped string
13207
+ */
13208
+ function remove_rfc2822_comments($string)
13209
+ {
13210
+ $string = (string) $string;
13211
+ $position = 0;
13212
+ $length = strlen($string);
13213
+ $depth = 0;
13214
+
13215
+ $output = '';
13216
+
13217
+ while ($position < $length && ($pos = strpos($string, '(', $position)) !== false)
13218
+ {
13219
+ $output .= substr($string, $position, $pos - $position);
13220
+ $position = $pos + 1;
13221
+ if ($string[$pos - 1] !== '\\')
13222
+ {
13223
+ $depth++;
13224
+ while ($depth && $position < $length)
13225
+ {
13226
+ $position += strcspn($string, '()', $position);
13227
+ if ($string[$position - 1] === '\\')
13228
+ {
13229
+ $position++;
13230
+ continue;
13231
+ }
13232
+ elseif (isset($string[$position]))
13233
+ {
13234
+ switch ($string[$position])
13235
+ {
13236
+ case '(':
13237
+ $depth++;
13238
+ break;
13239
+
13240
+ case ')':
13241
+ $depth--;
13242
+ break;
13243
+ }
13244
+ $position++;
13245
+ }
13246
+ else
13247
+ {
13248
+ break;
13249
+ }
13250
+ }
13251
+ }
13252
+ else
13253
+ {
13254
+ $output .= '(';
13255
+ }
13256
+ }
13257
+ $output .= substr($string, $position);
13258
+
13259
+ return $output;
13260
+ }
13261
+
13262
+ /**
13263
+ * Parse RFC2822's date format
13264
+ *
13265
+ * @access protected
13266
+ * @return int Timestamp
13267
+ */
13268
+ function date_rfc2822($date)
13269
+ {
13270
+ static $pcre;
13271
+ if (!$pcre)
13272
+ {
13273
+ $wsp = '[\x09\x20]';
13274
+ $fws = '(?:' . $wsp . '+|' . $wsp . '*(?:\x0D\x0A' . $wsp . '+)+)';
13275
+ $optional_fws = $fws . '?';
13276
+ $day_name = $this->day_pcre;
13277
+ $month = $this->month_pcre;
13278
+ $day = '([0-9]{1,2})';
13279
+ $hour = $minute = $second = '([0-9]{2})';
13280
+ $year = '([0-9]{2,4})';
13281
+ $num_zone = '([+\-])([0-9]{2})([0-9]{2})';
13282
+ $character_zone = '([A-Z]{1,5})';
13283
+ $zone = '(?:' . $num_zone . '|' . $character_zone . ')';
13284
+ $pcre = '/(?:' . $optional_fws . $day_name . $optional_fws . ',)?' . $optional_fws . $day . $fws . $month . $fws . $year . $fws . $hour . $optional_fws . ':' . $optional_fws . $minute . '(?:' . $optional_fws . ':' . $optional_fws . $second . ')?' . $fws . $zone . '/i';
13285
+ }
13286
+ if (preg_match($pcre, $this->remove_rfc2822_comments($date), $match))
13287
+ {
13288
+ /*
13289
+ Capturing subpatterns:
13290
+ 1: Day name
13291
+ 2: Day
13292
+ 3: Month
13293
+ 4: Year
13294
+ 5: Hour
13295
+ 6: Minute
13296
+ 7: Second
13297
+ 8: Timezone ±
13298
+ 9: Timezone hours
13299
+ 10: Timezone minutes
13300
+ 11: Alphabetic timezone
13301
+ */
13302
+
13303
+ // Find the month number
13304
+ $month = $this->month[strtolower($match[3])];
13305
+
13306
+ // Numeric timezone
13307
+ if ($match[8] !== '')
13308
+ {
13309
+ $timezone = $match[9] * 3600;
13310
+ $timezone += $match[10] * 60;
13311
+ if ($match[8] === '-')
13312
+ {
13313
+ $timezone = 0 - $timezone;
13314
+ }
13315
+ }
13316
+ // Character timezone
13317
+ elseif (isset($this->timezone[strtoupper($match[11])]))
13318
+ {
13319
+ $timezone = $this->timezone[strtoupper($match[11])];
13320
+ }
13321
+ // Assume everything else to be -0000
13322
+ else
13323
+ {
13324
+ $timezone = 0;
13325
+ }
13326
+
13327
+ // Deal with 2/3 digit years
13328
+ if ($match[4] < 50)
13329
+ {
13330
+ $match[4] += 2000;
13331
+ }
13332
+ elseif ($match[4] < 1000)
13333
+ {
13334
+ $match[4] += 1900;
13335
+ }
13336
+
13337
+ // Second is optional, if it is empty set it to zero
13338
+ if ($match[7] !== '')
13339
+ {
13340
+ $second = $match[7];
13341
+ }
13342
+ else
13343
+ {
13344
+ $second = 0;
13345
+ }
13346
+
13347
+ return gmmktime($match[5], $match[6], $second, $month, $match[2], $match[4]) - $timezone;
13348
+ }
13349
+ else
13350
+ {
13351
+ return false;
13352
+ }
13353
+ }
13354
+
13355
+ /**
13356
+ * Parse RFC850's date format
13357
+ *
13358
+ * @access protected
13359
+ * @return int Timestamp
13360
+ */
13361
+ function date_rfc850($date)
13362
+ {
13363
+ static $pcre;
13364
+ if (!$pcre)
13365
+ {
13366
+ $space = '[\x09\x20]+';
13367
+ $day_name = $this->day_pcre;
13368
+ $month = $this->month_pcre;
13369
+ $day = '([0-9]{1,2})';
13370
+ $year = $hour = $minute = $second = '([0-9]{2})';
13371
+ $zone = '([A-Z]{1,5})';
13372
+ $pcre = '/^' . $day_name . ',' . $space . $day . '-' . $month . '-' . $year . $space . $hour . ':' . $minute . ':' . $second . $space . $zone . '$/i';
13373
+ }
13374
+ if (preg_match($pcre, $date, $match))
13375
+ {
13376
+ /*
13377
+ Capturing subpatterns:
13378
+ 1: Day name
13379
+ 2: Day
13380
+ 3: Month
13381
+ 4: Year
13382
+ 5: Hour
13383
+ 6: Minute
13384
+ 7: Second
13385
+ 8: Timezone
13386
+ */
13387
+
13388
+ // Month
13389
+ $month = $this->month[strtolower($match[3])];
13390
+
13391
+ // Character timezone
13392
+ if (isset($this->timezone[strtoupper($match[8])]))
13393
+ {
13394
+ $timezone = $this->timezone[strtoupper($match[8])];
13395
+ }
13396
+ // Assume everything else to be -0000
13397
+ else
13398
+ {
13399
+ $timezone = 0;
13400
+ }
13401
+
13402
+ // Deal with 2 digit year
13403
+ if ($match[4] < 50)
13404
+ {
13405
+ $match[4] += 2000;
13406
+ }
13407
+ else
13408
+ {
13409
+ $match[4] += 1900;
13410
+ }
13411
+
13412
+ return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone;
13413
+ }
13414
+ else
13415
+ {
13416
+ return false;
13417
+ }
13418
+ }
13419
+
13420
+ /**
13421
+ * Parse C99's asctime()'s date format
13422
+ *
13423
+ * @access protected
13424
+ * @return int Timestamp
13425
+ */
13426
+ function date_asctime($date)
13427
+ {
13428
+ static $pcre;
13429
+ if (!$pcre)
13430
+ {
13431
+ $space = '[\x09\x20]+';
13432
+ $wday_name = $this->day_pcre;
13433
+ $mon_name = $this->month_pcre;
13434
+ $day = '([0-9]{1,2})';
13435
+ $hour = $sec = $min = '([0-9]{2})';
13436
+ $year = '([0-9]{4})';
13437
+ $terminator = '\x0A?\x00?';
13438
+ $pcre = '/^' . $wday_name . $space . $mon_name . $space . $day . $space . $hour . ':' . $min . ':' . $sec . $space . $year . $terminator . '$/i';
13439
+ }
13440
+ if (preg_match($pcre, $date, $match))
13441
+ {
13442
+ /*
13443
+ Capturing subpatterns:
13444
+ 1: Day name
13445
+ 2: Month
13446
+ 3: Day
13447
+ 4: Hour
13448
+ 5: Minute
13449
+ 6: Second
13450
+ 7: Year
13451
+ */
13452
+
13453
+ $month = $this->month[strtolower($match[2])];
13454
+ return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]);
13455
+ }
13456
+ else
13457
+ {
13458
+ return false;
13459
+ }
13460
+ }
13461
+
13462
+ /**
13463
+ * Parse dates using strtotime()
13464
+ *
13465
+ * @access protected
13466
+ * @return int Timestamp
13467
+ */
13468
+ function date_strtotime($date)
13469
+ {
13470
+ $strtotime = strtotime($date);
13471
+ if ($strtotime === -1 || $strtotime === false)
13472
+ {
13473
+ return false;
13474
+ }
13475
+ else
13476
+ {
13477
+ return $strtotime;
13478
+ }
13479
+ }
13480
+ }
13481
+
13482
+ /**
13483
+ * Content-type sniffing
13484
+ *
13485
+ * @package SimplePie
13486
+ */
13487
+ class SimplePie_Content_Type_Sniffer
13488
+ {
13489
+ /**
13490
+ * File object
13491
+ *
13492
+ * @var SimplePie_File
13493
+ * @access private
13494
+ */
13495
+ var $file;
13496
+
13497
+ /**
13498
+ * Create an instance of the class with the input file
13499
+ *
13500
+ * @access public
13501
+ * @param SimplePie_Content_Type_Sniffer $file Input file
13502
+ */
13503
+ function SimplePie_Content_Type_Sniffer($file)
13504
+ {
13505
+ $this->file = $file;
13506
+ }
13507
+
13508
+ /**
13509
+ * Get the Content-Type of the specified file
13510
+ *
13511
+ * @access public
13512
+ * @return string Actual Content-Type
13513
+ */
13514
+ function get_type()
13515
+ {
13516
+ if (isset($this->file->headers['content-type']))
13517
+ {
13518
+ if (!isset($this->file->headers['content-encoding'])
13519
+ && ($this->file->headers['content-type'] === 'text/plain'
13520
+ || $this->file->headers['content-type'] === 'text/plain; charset=ISO-8859-1'
13521
+ || $this->file->headers['content-type'] === 'text/plain; charset=iso-8859-1'))
13522
+ {
13523
+ return $this->text_or_binary();
13524
+ }
13525
+
13526
+ if (($pos = strpos($this->file->headers['content-type'], ';')) !== false)
13527
+ {
13528
+ $official = substr($this->file->headers['content-type'], 0, $pos);
13529
+ }
13530
+ else
13531
+ {
13532
+ $official = $this->file->headers['content-type'];
13533
+ }
13534
+ $official = strtolower($official);
13535
+
13536
+ if ($official === 'unknown/unknown'
13537
+ || $official === 'application/unknown')
13538
+ {
13539
+ return $this->unknown();
13540
+ }
13541
+ elseif (substr($official, -4) === '+xml'
13542
+ || $official === 'text/xml'
13543
+ || $official === 'application/xml')
13544
+ {
13545
+ return $official;
13546
+ }
13547
+ elseif (substr($official, 0, 6) === 'image/')
13548
+ {
13549
+ if ($return = $this->image())
13550
+ {
13551
+ return $return;
13552
+ }
13553
+ else
13554
+ {
13555
+ return $official;
13556
+ }
13557
+ }
13558
+ elseif ($official === 'text/html')
13559
+ {
13560
+ return $this->feed_or_html();
13561
+ }
13562
+ else
13563
+ {
13564
+ return $official;
13565
+ }
13566
+ }
13567
+ else
13568
+ {
13569
+ return $this->unknown();
13570
+ }
13571
+ }
13572
+
13573
+ /**
13574
+ * Sniff text or binary
13575
+ *
13576
+ * @access private
13577
+ * @return string Actual Content-Type
13578
+ */
13579
+ function text_or_binary()
13580
+ {
13581
+ if (substr($this->file->body, 0, 2) === "\xFE\xFF"
13582
+ || substr($this->file->body, 0, 2) === "\xFF\xFE"
13583
+ || substr($this->file->body, 0, 4) === "\x00\x00\xFE\xFF"
13584
+ || substr($this->file->body, 0, 3) === "\xEF\xBB\xBF")
13585
+ {
13586
+ return 'text/plain';
13587
+ }
13588
+ elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $this->file->body))
13589
+ {
13590
+ return 'application/octect-stream';
13591
+ }
13592
+ else
13593
+ {
13594
+ return 'text/plain';
13595
+ }
13596
+ }
13597
+
13598
+ /**
13599
+ * Sniff unknown
13600
+ *
13601
+ * @access private
13602
+ * @return string Actual Content-Type
13603
+ */
13604
+ function unknown()
13605
+ {
13606
+ $ws = strspn($this->file->body, "\x09\x0A\x0B\x0C\x0D\x20");
13607
+ if (strtolower(substr($this->file->body, $ws, 14)) === '<!doctype html'
13608
+ || strtolower(substr($this->file->body, $ws, 5)) === '<html'
13609
+ || strtolower(substr($this->file->body, $ws, 7)) === '<script')
13610
+ {
13611
+ return 'text/html';
13612
+ }
13613
+ elseif (substr($this->file->body, 0, 5) === '%PDF-')
13614
+ {
13615
+ return 'application/pdf';
13616
+ }
13617
+ elseif (substr($this->file->body, 0, 11) === '%!PS-Adobe-')
13618
+ {
13619
+ return 'application/postscript';
13620
+ }
13621
+ elseif (substr($this->file->body, 0, 6) === 'GIF87a'
13622
+ || substr($this->file->body, 0, 6) === 'GIF89a')
13623
+ {
13624
+ return 'image/gif';
13625
+ }
13626
+ elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")
13627
+ {
13628
+ return 'image/png';
13629
+ }
13630
+ elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF")
13631
+ {
13632
+ return 'image/jpeg';
13633
+ }
13634
+ elseif (substr($this->file->body, 0, 2) === "\x42\x4D")
13635
+ {
13636
+ return 'image/bmp';
13637
+ }
13638
+ else
13639
+ {
13640
+ return $this->text_or_binary();
13641
+ }
13642
+ }
13643
+
13644
+ /**
13645
+ * Sniff images
13646
+ *
13647
+ * @access private
13648
+ * @return string Actual Content-Type
13649
+ */
13650
+ function image()
13651
+ {
13652
+ if (substr($this->file->body, 0, 6) === 'GIF87a'
13653
+ || substr($this->file->body, 0, 6) === 'GIF89a')
13654
+ {
13655
+ return 'image/gif';
13656
+ }
13657
+ elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")
13658
+ {
13659
+ return 'image/png';
13660
+ }
13661
+ elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF")
13662
+ {
13663
+ return 'image/jpeg';
13664
+ }
13665
+ elseif (substr($this->file->body, 0, 2) === "\x42\x4D")
13666
+ {
13667
+ return 'image/bmp';
13668
+ }
13669
+ else
13670
+ {
13671
+ return false;
13672
+ }
13673
+ }
13674
+
13675
+ /**
13676
+ * Sniff HTML
13677
+ *
13678
+ * @access private
13679
+ * @return string Actual Content-Type
13680
+ */
13681
+ function feed_or_html()
13682
+ {
13683
+ $len = strlen($this->file->body);
13684
+ $pos = strspn($this->file->body, "\x09\x0A\x0D\x20");
13685
+
13686
+ while ($pos < $len)
13687
+ {
13688
+ switch ($this->file->body[$pos])
13689
+ {
13690
+ case "\x09":
13691
+ case "\x0A":
13692
+ case "\x0D":
13693
+ case "\x20":
13694
+ $pos += strspn($this->file->body, "\x09\x0A\x0D\x20", $pos);
13695
+ continue 2;
13696
+
13697
+ case '<':
13698
+ $pos++;
13699
+ break;
13700
+
13701
+ default:
13702
+ return 'text/html';
13703
+ }
13704
+
13705
+ if (substr($this->file->body, $pos, 3) === '!--')
13706
+ {
13707
+ $pos += 3;
13708
+ if ($pos < $len && ($pos = strpos($this->file->body, '-->', $pos)) !== false)
13709
+ {
13710
+ $pos += 3;
13711
+ }
13712
+ else
13713
+ {
13714
+ return 'text/html';
13715
+ }
13716
+ }
13717
+ elseif (substr($this->file->body, $pos, 1) === '!')
13718
+ {
13719
+ if ($pos < $len && ($pos = strpos($this->file->body, '>', $pos)) !== false)
13720
+ {
13721
+ $pos++;
13722
+ }
13723
+ else
13724
+ {
13725
+ return 'text/html';
13726
+ }
13727
+ }
13728
+ elseif (substr($this->file->body, $pos, 1) === '?')
13729
+ {
13730
+ if ($pos < $len && ($pos = strpos($this->file->body, '?>', $pos)) !== false)
13731
+ {
13732
+ $pos += 2;
13733
+ }
13734
+ else
13735
+ {
13736
+ return 'text/html';
13737
+ }
13738
+ }
13739
+ elseif (substr($this->file->body, $pos, 3) === 'rss'
13740
+ || substr($this->file->body, $pos, 7) === 'rdf:RDF')
13741
+ {
13742
+ return 'application/rss+xml';
13743
+ }
13744
+ elseif (substr($this->file->body, $pos, 4) === 'feed')
13745
+ {
13746
+ return 'application/atom+xml';
13747
+ }
13748
+ else
13749
+ {
13750
+ return 'text/html';
13751
+ }
13752
+ }
13753
+
13754
+ return 'text/html';
13755
+ }
13756
+ }
13757
+
13758
+ /**
13759
+ * Parses the XML Declaration
13760
+ *
13761
+ * @package SimplePie
13762
+ */
13763
+ class SimplePie_XML_Declaration_Parser
13764
+ {
13765
+ /**
13766
+ * XML Version
13767
+ *
13768
+ * @access public
13769
+ * @var string
13770
+ */
13771
+ var $version = '1.0';
13772
+
13773
+ /**
13774
+ * Encoding
13775
+ *
13776
+ * @access public
13777
+ * @var string
13778
+ */
13779
+ var $encoding = 'UTF-8';
13780
+
13781
+ /**
13782
+ * Standalone
13783
+ *
13784
+ * @access public
13785
+ * @var bool
13786
+ */
13787
+ var $standalone = false;
13788
+
13789
+ /**
13790
+ * Current state of the state machine
13791
+ *
13792
+ * @access private
13793
+ * @var string
13794
+ */
13795
+ var $state = 'before_version_name';
13796
+
13797
+ /**
13798
+ * Input data
13799
+ *
13800
+ * @access private
13801
+ * @var string
13802
+ */
13803
+ var $data = '';
13804
+
13805
+ /**
13806
+ * Input data length (to avoid calling strlen() everytime this is needed)
13807
+ *
13808
+ * @access private
13809
+ * @var int
13810
+ */
13811
+ var $data_length = 0;
13812
+
13813
+ /**
13814
+ * Current position of the pointer
13815
+ *
13816
+ * @var int
13817
+ * @access private
13818
+ */
13819
+ var $position = 0;
13820
+
13821
+ /**
13822
+ * Create an instance of the class with the input data
13823
+ *
13824
+ * @access public
13825
+ * @param string $data Input data
13826
+ */
13827
+ function SimplePie_XML_Declaration_Parser($data)
13828
+ {
13829
+ $this->data = $data;
13830
+ $this->data_length = strlen($this->data);
13831
+ }
13832
+
13833
+ /**
13834
+ * Parse the input data
13835
+ *
13836
+ * @access public
13837
+ * @return bool true on success, false on failure
13838
+ */
13839
+ function parse()
13840
+ {
13841
+ while ($this->state && $this->state !== 'emit' && $this->has_data())
13842
+ {
13843
+ $state = $this->state;
13844
+ $this->$state();
13845
+ }
13846
+ $this->data = '';
13847
+ if ($this->state === 'emit')
13848
+ {
13849
+ return true;
13850
+ }
13851
+ else
13852
+ {
13853
+ $this->version = '';
13854
+ $this->encoding = '';
13855
+ $this->standalone = '';
13856
+ return false;
13857
+ }
13858
+ }
13859
+
13860
+ /**
13861
+ * Check whether there is data beyond the pointer
13862
+ *
13863
+ * @access private
13864
+ * @return bool true if there is further data, false if not
13865
+ */
13866
+ function has_data()
13867
+ {
13868
+ return (bool) ($this->position < $this->data_length);
13869
+ }
13870
+
13871
+ /**
13872
+ * Advance past any whitespace
13873
+ *
13874
+ * @return int Number of whitespace characters passed
13875
+ */
13876
+ function skip_whitespace()
13877
+ {
13878
+ $whitespace = strspn($this->data, "\x09\x0A\x0D\x20", $this->position);
13879
+ $this->position += $whitespace;
13880
+ return $whitespace;
13881
+ }
13882
+
13883
+ /**
13884
+ * Read value
13885
+ */
13886
+ function get_value()
13887
+ {
13888
+ $quote = substr($this->data, $this->position, 1);
13889
+ if ($quote === '"' || $quote === "'")
13890
+ {
13891
+ $this->position++;
13892
+ $len = strcspn($this->data, $quote, $this->position);
13893
+ if ($this->has_data())
13894
+ {
13895
+ $value = substr($this->data, $this->position, $len);
13896
+ $this->position += $len + 1;
13897
+ return $value;
13898
+ }
13899
+ }
13900
+ return false;
13901
+ }
13902
+
13903
+ function before_version_name()
13904
+ {
13905
+ if ($this->skip_whitespace())
13906
+ {
13907
+ $this->state = 'version_name';
13908
+ }
13909
+ else
13910
+ {
13911
+ $this->state = false;
13912
+ }
13913
+ }
13914
+
13915
+ function version_name()
13916
+ {
13917
+ if (substr($this->data, $this->position, 7) === 'version')
13918
+ {
13919
+ $this->position += 7;
13920
+ $this->skip_whitespace();
13921
+ $this->state = 'version_equals';
13922
+ }
13923
+ else
13924
+ {
13925
+ $this->state = false;
13926
+ }
13927
+ }
13928
+
13929
+ function version_equals()
13930
+ {
13931
+ if (substr($this->data, $this->position, 1) === '=')
13932
+ {
13933
+ $this->position++;
13934
+ $this->skip_whitespace();
13935
+ $this->state = 'version_value';
13936
+ }
13937
+ else
13938
+ {
13939
+ $this->state = false;
13940
+ }
13941
+ }
13942
+
13943
+ function version_value()
13944
+ {
13945
+ if ($this->version = $this->get_value())
13946
+ {
13947
+ $this->skip_whitespace();
13948
+ if ($this->has_data())
13949
+ {
13950
+ $this->state = 'encoding_name';
13951
+ }
13952
+ else
13953
+ {
13954
+ $this->state = 'emit';
13955
+ }
13956
+ }
13957
+ else
13958
+ {
13959
+ $this->state = false;
13960
+ }
13961
+ }
13962
+
13963
+ function encoding_name()
13964
+ {
13965
+ if (substr($this->data, $this->position, 8) === 'encoding')
13966
+ {
13967
+ $this->position += 8;
13968
+ $this->skip_whitespace();
13969
+ $this->state = 'encoding_equals';
13970
+ }
13971
+ else
13972
+ {
13973
+ $this->state = 'standalone_name';
13974
+ }
13975
+ }
13976
+
13977
+ function encoding_equals()
13978
+ {
13979
+ if (substr($this->data, $this->position, 1) === '=')
13980
+ {
13981
+ $this->position++;
13982
+ $this->skip_whitespace();
13983
+ $this->state = 'encoding_value';
13984
+ }
13985
+ else
13986
+ {
13987
+ $this->state = false;
13988
+ }
13989
+ }
13990
+
13991
+ function encoding_value()
13992
+ {
13993
+ if ($this->encoding = $this->get_value())
13994
+ {
13995
+ $this->skip_whitespace();
13996
+ if ($this->has_data())
13997
+ {
13998
+ $this->state = 'standalone_name';
13999
+ }
14000
+ else
14001
+ {
14002
+ $this->state = 'emit';
14003
+ }
14004
+ }
14005
+ else
14006
+ {
14007
+ $this->state = false;
14008
+ }
14009
+ }
14010
+
14011
+ function standalone_name()
14012
+ {
14013
+ if (substr($this->data, $this->position, 10) === 'standalone')
14014
+ {
14015
+ $this->position += 10;
14016
+ $this->skip_whitespace();
14017
+ $this->state = 'standalone_equals';
14018
+ }
14019
+ else
14020
+ {
14021
+ $this->state = false;
14022
+ }
14023
+ }
14024
+
14025
+ function standalone_equals()
14026
+ {
14027
+ if (substr($this->data, $this->position, 1) === '=')
14028
+ {
14029
+ $this->position++;
14030
+ $this->skip_whitespace();
14031
+ $this->state = 'standalone_value';
14032
+ }
14033
+ else
14034
+ {
14035
+ $this->state = false;
14036
+ }
14037
+ }
14038
+
14039
+ function standalone_value()
14040
+ {
14041
+ if ($standalone = $this->get_value())
14042
+ {
14043
+ switch ($standalone)
14044
+ {
14045
+ case 'yes':
14046
+ $this->standalone = true;
14047
+ break;
14048
+
14049
+ case 'no':
14050
+ $this->standalone = false;
14051
+ break;
14052
+
14053
+ default:
14054
+ $this->state = false;
14055
+ return;
14056
+ }
14057
+
14058
+ $this->skip_whitespace();
14059
+ if ($this->has_data())
14060
+ {
14061
+ $this->state = false;
14062
+ }
14063
+ else
14064
+ {
14065
+ $this->state = 'emit';
14066
+ }
14067
+ }
14068
+ else
14069
+ {
14070
+ $this->state = false;
14071
+ }
14072
+ }
14073
+ }
14074
+
14075
+ class SimplePie_Locator
14076
+ {
14077
+ var $useragent;
14078
+ var $timeout;
14079
+ var $file;
14080
+ var $local = array();
14081
+ var $elsewhere = array();
14082
+ var $file_class = 'SimplePie_File';
14083
+ var $cached_entities = array();
14084
+ var $http_base;
14085
+ var $base;
14086
+ var $base_location = 0;
14087
+ var $checked_feeds = 0;
14088
+ var $max_checked_feeds = 10;
14089
+ var $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer';
14090
+
14091
+ function SimplePie_Locator(&$file, $timeout = 10, $useragent = null, $file_class = 'SimplePie_File', $max_checked_feeds = 10, $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer')
14092
+ {
14093
+ $this->file =& $file;
14094
+ $this->file_class = $file_class;
14095
+ $this->useragent = $useragent;
14096
+ $this->timeout = $timeout;
14097
+ $this->max_checked_feeds = $max_checked_feeds;
14098
+ $this->content_type_sniffer_class = $content_type_sniffer_class;
14099
+ }
14100
+
14101
+ function find($type = SIMPLEPIE_LOCATOR_ALL, &$working)
14102
+ {
14103
+ if ($this->is_feed($this->file))
14104
+ {
14105
+ return $this->file;
14106
+ }
14107
+
14108
+ if ($this->file->method & SIMPLEPIE_FILE_SOURCE_REMOTE)
14109
+ {
14110
+ $sniffer = new $this->content_type_sniffer_class($this->file);
14111
+ if ($sniffer->get_type() !== 'text/html')
14112
+ {
14113
+ return null;
14114
+ }
14115
+ }
14116
+
14117
+ if ($type & ~SIMPLEPIE_LOCATOR_NONE)
14118
+ {
14119
+ $this->get_base();
14120
+ }
14121
+
14122
+ if ($type & SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working = $this->autodiscovery())
14123
+ {
14124
+ return $working[0];
14125
+ }
14126
+
14127
+ if ($type & (SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY | SIMPLEPIE_LOCATOR_REMOTE_EXTENSION | SIMPLEPIE_LOCATOR_REMOTE_BODY) && $this->get_links())
14128
+ {
14129
+ if ($type & SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working = $this->extension($this->local))
14130
+ {
14131
+ return $working;
14132
+ }
14133
+
14134
+ if ($type & SIMPLEPIE_LOCATOR_LOCAL_BODY && $working = $this->body($this->local))
14135
+ {
14136
+ return $working;
14137
+ }
14138
+
14139
+ if ($type & SIMPLEPIE_LOCATOR_REMOTE_EXTENSION && $working = $this->extension($this->elsewhere))
14140
+ {
14141
+ return $working;
14142
+ }
14143
+
14144
+ if ($type & SIMPLEPIE_LOCATOR_REMOTE_BODY && $working = $this->body($this->elsewhere))
14145
+ {
14146
+ return $working;
14147
+ }
14148
+ }
14149
+ return null;
14150
+ }
14151
+
14152
+ function is_feed(&$file)
14153
+ {
14154
+ if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE)
14155
+ {
14156
+ $sniffer = new $this->content_type_sniffer_class($file);
14157
+ $sniffed = $sniffer->get_type();
14158
+ if (in_array($sniffed, array('application/rss+xml', 'application/rdf+xml', 'text/rdf', 'application/atom+xml', 'text/xml', 'application/xml')))
14159
+ {
14160
+ return true;
14161
+ }
14162
+ else
14163
+ {
14164
+ return false;
14165
+ }
14166
+ }
14167
+ elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL)
14168
+ {
14169
+ return true;
14170
+ }
14171
+ else
14172
+ {
14173
+ return false;
14174
+ }
14175
+ }
14176
+
14177
+ function get_base()
14178
+ {
14179
+ $this->http_base = $this->file->url;
14180
+ $this->base = $this->http_base;
14181
+ $elements = SimplePie_Misc::get_element('base', $this->file->body);
14182
+ foreach ($elements as $element)
14183
+ {
14184
+ if ($element['attribs']['href']['data'] !== '')
14185
+ {
14186
+ $this->base = SimplePie_Misc::absolutize_url(trim($element['attribs']['href']['data']), $this->http_base);
14187
+ $this->base_location = $element['offset'];
14188
+ break;
14189
+ }
14190
+ }
14191
+ }
14192
+
14193
+ function autodiscovery()
14194
+ {
14195
+ $links = array_merge(SimplePie_Misc::get_element('link', $this->file->body), SimplePie_Misc::get_element('a', $this->file->body), SimplePie_Misc::get_element('area', $this->file->body));
14196
+ $done = array();
14197
+ $feeds = array();
14198
+ foreach ($links as $link)
14199
+ {
14200
+ if ($this->checked_feeds === $this->max_checked_feeds)
14201
+ {
14202
+ break;
14203
+ }
14204
+ if (isset($link['attribs']['href']['data']) && isset($link['attribs']['rel']['data']))
14205
+ {
14206
+ $rel = array_unique(SimplePie_Misc::space_seperated_tokens(strtolower($link['attribs']['rel']['data'])));
14207
+
14208
+ if ($this->base_location < $link['offset'])
14209
+ {
14210
+ $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->base);
14211
+ }
14212
+ else
14213
+ {
14214
+ $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base);
14215
+ }
14216
+
14217
+ if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !empty($link['attribs']['type']['data']) && in_array(strtolower(SimplePie_Misc::parse_mime($link['attribs']['type']['data'])), array('application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href]))
14218
+ {
14219
+ $this->checked_feeds++;
14220
+ $feed = new $this->file_class($href, $this->timeout, 5, null, $this->useragent);
14221
+ if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
14222
+ {
14223
+ $feeds[$href] = $feed;
14224
+ }
14225
+ }
14226
+ $done[] = $href;
14227
+ }
14228
+ }
14229
+
14230
+ if (!empty($feeds))
14231
+ {
14232
+ return array_values($feeds);
14233
+ }
14234
+ else {
14235
+ return null;
14236
+ }
14237
+ }
14238
+
14239
+ function get_links()
14240
+ {
14241
+ $links = SimplePie_Misc::get_element('a', $this->file->body);
14242
+ foreach ($links as $link)
14243
+ {
14244
+ if (isset($link['attribs']['href']['data']))
14245
+ {
14246
+ $href = trim($link['attribs']['href']['data']);
14247
+ $parsed = SimplePie_Misc::parse_url($href);
14248
+ if ($parsed['scheme'] === '' || preg_match('/^(http(s)|feed)?$/i', $parsed['scheme']))
14249
+ {
14250
+ if ($this->base_location < $link['offset'])
14251
+ {
14252
+ $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->base);
14253
+ }
14254
+ else
14255
+ {
14256
+ $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base);
14257
+ }
14258
+
14259
+ $current = SimplePie_Misc::parse_url($this->file->url);
14260
+
14261
+ if ($parsed['authority'] === '' || $parsed['authority'] === $current['authority'])
14262
+ {
14263
+ $this->local[] = $href;
14264
+ }
14265
+ else
14266
+ {
14267
+ $this->elsewhere[] = $href;
14268
+ }
14269
+ }
14270
+ }
14271
+ }
14272
+ $this->local = array_unique($this->local);
14273
+ $this->elsewhere = array_unique($this->elsewhere);
14274
+ if (!empty($this->local) || !empty($this->elsewhere))
14275
+ {
14276
+ return true;
14277
+ }
14278
+ return null;
14279
+ }
14280
+
14281
+ function extension(&$array)
14282
+ {
14283
+ foreach ($array as $key => $value)
14284
+ {
14285
+ if ($this->checked_feeds === $this->max_checked_feeds)
14286
+ {
14287
+ break;
14288
+ }
14289
+ if (in_array(strtolower(strrchr($value, '.')), array('.rss', '.rdf', '.atom', '.xml')))
14290
+ {
14291
+ $this->checked_feeds++;
14292
+ $feed = new $this->file_class($value, $this->timeout, 5, null, $this->useragent);
14293
+ if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
14294
+ {
14295
+ return $feed;
14296
+ }
14297
+ else
14298
+ {
14299
+ unset($array[$key]);
14300
+ }
14301
+ }
14302
+ }
14303
+ return null;
14304
+ }
14305
+
14306
+ function body(&$array)
14307
+ {
14308
+ foreach ($array as $key => $value)
14309
+ {
14310
+ if ($this->checked_feeds === $this->max_checked_feeds)
14311
+ {
14312
+ break;
14313
+ }
14314
+ if (preg_match('/(rss|rdf|atom|xml)/i', $value))
14315
+ {
14316
+ $this->checked_feeds++;
14317
+ $feed = new $this->file_class($value, $this->timeout, 5, null, $this->useragent);
14318
+ if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
14319
+ {
14320
+ return $feed;
14321
+ }
14322
+ else
14323
+ {
14324
+ unset($array[$key]);
14325
+ }
14326
+ }
14327
+ }
14328
+ return null;
14329
+ }
14330
+ }
14331
+
14332
+ class SimplePie_Parser
14333
+ {
14334
+ var $error_code;
14335
+ var $error_string;
14336
+ var $current_line;
14337
+ var $current_column;
14338
+ var $current_byte;
14339
+ var $separator = ' ';
14340
+ var $namespace = array('');
14341
+ var $element = array('');
14342
+ var $xml_base = array('');
14343
+ var $xml_base_explicit = array(false);
14344
+ var $xml_lang = array('');
14345
+ var $data = array();
14346
+ var $datas = array(array());
14347
+ var $current_xhtml_construct = -1;
14348
+ var $encoding;
14349
+
14350
+ function parse(&$data, $encoding)
14351
+ {
14352
+ // Use UTF-8 if we get passed US-ASCII, as every US-ASCII character is a UTF-8 character
14353
+ if (strtoupper($encoding) === 'US-ASCII')
14354
+ {
14355
+ $this->encoding = 'UTF-8';
14356
+ }
14357
+ else
14358
+ {
14359
+ $this->encoding = $encoding;
14360
+ }
14361
+
14362
+ // Strip BOM:
14363
+ // UTF-32 Big Endian BOM
14364
+ if (substr($data, 0, 4) === "\x00\x00\xFE\xFF")
14365
+ {
14366
+ $data = substr($data, 4);
14367
+ }
14368
+ // UTF-32 Little Endian BOM
14369
+ elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00")
14370
+ {
14371
+ $data = substr($data, 4);
14372
+ }
14373
+ // UTF-16 Big Endian BOM
14374
+ elseif (substr($data, 0, 2) === "\xFE\xFF")
14375
+ {
14376
+ $data = substr($data, 2);
14377
+ }
14378
+ // UTF-16 Little Endian BOM
14379
+ elseif (substr($data, 0, 2) === "\xFF\xFE")
14380
+ {
14381
+ $data = substr($data, 2);
14382
+ }
14383
+ // UTF-8 BOM
14384
+ elseif (substr($data, 0, 3) === "\xEF\xBB\xBF")
14385
+ {
14386
+ $data = substr($data, 3);
14387
+ }
14388
+
14389
+ if (substr($data, 0, 5) === '<?xml' && strspn(substr($data, 5, 1), "\x09\x0A\x0D\x20") && ($pos = strpos($data, '?>')) !== false)
14390
+ {
14391
+ $declaration = new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5));
14392
+ if ($declaration->parse())
14393
+ {
14394
+ $data = substr($data, $pos + 2);
14395
+ $data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . $data;
14396
+ }
14397
+ else
14398
+ {
14399
+ $this->error_string = 'SimplePie bug! Please report this!';
14400
+ return false;
14401
+ }
14402
+ }
14403
+
14404
+ $return = true;
14405
+
14406
+ static $xml_is_sane = null;
14407
+ if ($xml_is_sane === null)
14408
+ {
14409
+ $parser_check = xml_parser_create();
14410
+ xml_parse_into_struct($parser_check, '<foo>&amp;</foo>', $values);
14411
+ xml_parser_free($parser_check);
14412
+ $xml_is_sane = isset($values[0]['value']);
14413
+ }
14414
+
14415
+ // Create the parser
14416
+ if ($xml_is_sane)
14417
+ {
14418
+ $xml = xml_parser_create_ns($this->encoding, $this->separator);
14419
+ xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1);
14420
+ xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 0);
14421
+ xml_set_object($xml, $this);
14422
+ xml_set_character_data_handler($xml, 'cdata');
14423
+ xml_set_element_handler($xml, 'tag_open', 'tag_close');
14424
+
14425
+ // Parse!
14426
+ if (!xml_parse($xml, $data, true))
14427
+ {
14428
+ $this->error_code = xml_get_error_code($xml);
14429
+ $this->error_string = xml_error_string($this->error_code);
14430
+ $return = false;
14431
+ }
14432
+ $this->current_line = xml_get_current_line_number($xml);
14433
+ $this->current_column = xml_get_current_column_number($xml);
14434
+ $this->current_byte = xml_get_current_byte_index($xml);
14435
+ xml_parser_free($xml);
14436
+ return $return;
14437
+ }
14438
+ else
14439
+ {
14440
+ libxml_clear_errors();
14441
+ $xml = new XMLReader();
14442
+ $xml->xml($data);
14443
+ while (@$xml->read())
14444
+ {
14445
+ switch ($xml->nodeType)
14446
+ {
14447
+
14448
+ case constant('XMLReader::END_ELEMENT'):
14449
+ if ($xml->namespaceURI !== '')
14450
+ {
14451
+ $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
14452
+ }
14453
+ else
14454
+ {
14455
+ $tagName = $xml->localName;
14456
+ }
14457
+ $this->tag_close(null, $tagName);
14458
+ break;
14459
+ case constant('XMLReader::ELEMENT'):
14460
+ $empty = $xml->isEmptyElement;
14461
+ if ($xml->namespaceURI !== '')
14462
+ {
14463
+ $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
14464
+ }
14465
+ else
14466
+ {
14467
+ $tagName = $xml->localName;
14468
+ }
14469
+ $attributes = array();
14470
+ while ($xml->moveToNextAttribute())
14471
+ {
14472
+ if ($xml->namespaceURI !== '')
14473
+ {
14474
+ $attrName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
14475
+ }
14476
+ else
14477
+ {
14478
+ $attrName = $xml->localName;
14479
+ }
14480
+ $attributes[$attrName] = $xml->value;
14481
+ }
14482
+ $this->tag_open(null, $tagName, $attributes);
14483
+ if ($empty)
14484
+ {
14485
+ $this->tag_close(null, $tagName);
14486
+ }
14487
+ break;
14488
+ case constant('XMLReader::TEXT'):
14489
+
14490
+ case constant('XMLReader::CDATA'):
14491
+ $this->cdata(null, $xml->value);
14492
+ break;
14493
+ }
14494
+ }
14495
+ if ($error = libxml_get_last_error())
14496
+ {
14497
+ $this->error_code = $error->code;
14498
+ $this->error_string = $error->message;
14499
+ $this->current_line = $error->line;
14500
+ $this->current_column = $error->column;
14501
+ return false;
14502
+ }
14503
+ else
14504
+ {
14505
+ return true;
14506
+ }
14507
+ }
14508
+ }
14509
+
14510
+ function get_error_code()
14511
+ {
14512
+ return $this->error_code;
14513
+ }
14514
+
14515
+ function get_error_string()
14516
+ {
14517
+ return $this->error_string;
14518
+ }
14519
+
14520
+ function get_current_line()
14521
+ {
14522
+ return $this->current_line;
14523
+ }
14524
+
14525
+ function get_current_column()
14526
+ {
14527
+ return $this->current_column;
14528
+ }
14529
+
14530
+ function get_current_byte()
14531
+ {
14532
+ return $this->current_byte;
14533
+ }
14534
+
14535
+ function get_data()
14536
+ {
14537
+ return $this->data;
14538
+ }
14539
+
14540
+ function tag_open($parser, $tag, $attributes)
14541
+ {
14542
+ list($this->namespace[], $this->element[]) = $this->split_ns($tag);
14543
+
14544
+ $attribs = array();
14545
+ foreach ($attributes as $name => $value)
14546
+ {
14547
+ list($attrib_namespace, $attribute) = $this->split_ns($name);
14548
+ $attribs[$attrib_namespace][$attribute] = $value;
14549
+ }
14550
+
14551
+ if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['base']))
14552
+ {
14553
+ $this->xml_base[] = SimplePie_Misc::absolutize_url($attribs[SIMPLEPIE_NAMESPACE_XML]['base'], end($this->xml_base));
14554
+ $this->xml_base_explicit[] = true;
14555
+ }
14556
+ else
14557
+ {
14558
+ $this->xml_base[] = end($this->xml_base);
14559
+ $this->xml_base_explicit[] = end($this->xml_base_explicit);
14560
+ }
14561
+
14562
+ if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['lang']))
14563
+ {
14564
+ $this->xml_lang[] = $attribs[SIMPLEPIE_NAMESPACE_XML]['lang'];
14565
+ }
14566
+ else
14567
+ {
14568
+ $this->xml_lang[] = end($this->xml_lang);
14569
+ }
14570
+
14571
+ if ($this->current_xhtml_construct >= 0)
14572
+ {
14573
+ $this->current_xhtml_construct++;
14574
+ if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML)
14575
+ {
14576
+ $this->data['data'] .= '<' . end($this->element);
14577
+ if (isset($attribs['']))
14578
+ {
14579
+ foreach ($attribs[''] as $name => $value)
14580
+ {
14581
+ $this->data['data'] .= ' ' . $name . '="' . htmlspecialchars($value, ENT_COMPAT, $this->encoding) . '"';
14582
+ }
14583
+ }
14584
+ $this->data['data'] .= '>';
14585
+ }
14586
+ }
14587
+ else
14588
+ {
14589
+ $this->datas[] =& $this->data;
14590
+ $this->data =& $this->data['child'][end($this->namespace)][end($this->element)][];
14591
+ $this->data = array('data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang));
14592
+ if ((end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] === 'xml')
14593
+ || (end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml'))
14594
+ {
14595
+ $this->current_xhtml_construct = 0;
14596
+ }
14597
+ }
14598
+ }
14599
+
14600
+ function cdata($parser, $cdata)
14601
+ {
14602
+ if ($this->current_xhtml_construct >= 0)
14603
+ {
14604
+ $this->data['data'] .= htmlspecialchars($cdata, ENT_QUOTES, $this->encoding);
14605
+ }
14606
+ else
14607
+ {
14608
+ $this->data['data'] .= $cdata;
14609
+ }
14610
+ }
14611
+
14612
+ function tag_close($parser, $tag)
14613
+ {
14614
+ if ($this->current_xhtml_construct >= 0)
14615
+ {
14616
+ $this->current_xhtml_construct--;
14617
+ if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param')))
14618
+ {
14619
+ $this->data['data'] .= '</' . end($this->element) . '>';
14620
+ }
14621
+ }
14622
+ if ($this->current_xhtml_construct === -1)
14623
+ {
14624
+ $this->data =& $this->datas[count($this->datas) - 1];
14625
+ array_pop($this->datas);
14626
+ }
14627
+
14628
+ array_pop($this->element);
14629
+ array_pop($this->namespace);
14630
+ array_pop($this->xml_base);
14631
+ array_pop($this->xml_base_explicit);
14632
+ array_pop($this->xml_lang);
14633
+ }
14634
+
14635
+ function split_ns($string)
14636
+ {
14637
+ static $cache = array();
14638
+ if (!isset($cache[$string]))
14639
+ {
14640
+ if ($pos = strpos($string, $this->separator))
14641
+ {
14642
+ static $separator_length;
14643
+ if (!$separator_length)
14644
+ {
14645
+ $separator_length = strlen($this->separator);
14646
+ }
14647
+ $namespace = substr($string, 0, $pos);
14648
+ $local_name = substr($string, $pos + $separator_length);
14649
+ if (strtolower($namespace) === SIMPLEPIE_NAMESPACE_ITUNES)
14650
+ {
14651
+ $namespace = SIMPLEPIE_NAMESPACE_ITUNES;
14652
+ }
14653
+
14654
+ // Normalize the Media RSS namespaces
14655
+ if ($namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG)
14656
+ {
14657
+ $namespace = SIMPLEPIE_NAMESPACE_MEDIARSS;
14658
+ }
14659
+ $cache[$string] = array($namespace, $local_name);
14660
+ }
14661
+ else
14662
+ {
14663
+ $cache[$string] = array('', $string);
14664
+ }
14665
+ }
14666
+ return $cache[$string];
14667
+ }
14668
+ }
14669
+
14670
+ /**
14671
+ * @todo Move to using an actual HTML parser (this will allow tags to be properly stripped, and to switch between HTML and XHTML), this will also make it easier to shorten a string while preserving HTML tags
14672
+ */
14673
+ class SimplePie_Sanitize
14674
+ {
14675
+ // Private vars
14676
+ var $base;
14677
+
14678
+ // Options
14679
+ var $remove_div = true;
14680
+ var $image_handler = '';
14681
+ var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style');
14682
+ var $encode_instead_of_strip = false;
14683
+ var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc');
14684
+ var $strip_comments = false;
14685
+ var $output_encoding = 'UTF-8';
14686
+ var $enable_cache = true;
14687
+ var $cache_location = './cache';
14688
+ var $cache_name_function = 'md5';
14689
+ var $cache_class = 'SimplePie_Cache';
14690
+ var $file_class = 'SimplePie_File';
14691
+ var $timeout = 10;
14692
+ var $useragent = '';
14693
+ var $force_fsockopen = false;
14694
+
14695
+ var $replace_url_attributes = array(
14696
+ 'a' => 'href',
14697
+ 'area' => 'href',
14698
+ 'blockquote' => 'cite',
14699
+ 'del' => 'cite',
14700
+ 'form' => 'action',
14701
+ 'img' => array('longdesc', 'src'),
14702
+ 'input' => 'src',
14703
+ 'ins' => 'cite',
14704
+ 'q' => 'cite'
14705
+ );
14706
+
14707
+ function remove_div($enable = true)
14708
+ {
14709
+ $this->remove_div = (bool) $enable;
14710
+ }
14711
+
14712
+ function set_image_handler($page = false)
14713
+ {
14714
+ if ($page)
14715
+ {
14716
+ $this->image_handler = (string) $page;
14717
+ }
14718
+ else
14719
+ {
14720
+ $this->image_handler = false;
14721
+ }
14722
+ }
14723
+
14724
+ function pass_cache_data($enable_cache = true, $cache_location = './cache', $cache_name_function = 'md5', $cache_class = 'SimplePie_Cache')
14725
+ {
14726
+ if (isset($enable_cache))
14727
+ {
14728
+ $this->enable_cache = (bool) $enable_cache;
14729
+ }
14730
+
14731
+ if ($cache_location)
14732
+ {
14733
+ $this->cache_location = (string) $cache_location;
14734
+ }
14735
+
14736
+ if ($cache_name_function)
14737
+ {
14738
+ $this->cache_name_function = (string) $cache_name_function;
14739
+ }
14740
+
14741
+ if ($cache_class)
14742
+ {
14743
+ $this->cache_class = (string) $cache_class;
14744
+ }
14745
+ }
14746
+
14747
+ function pass_file_data($file_class = 'SimplePie_File', $timeout = 10, $useragent = '', $force_fsockopen = false)
14748
+ {
14749
+ if ($file_class)
14750
+ {
14751
+ $this->file_class = (string) $file_class;
14752
+ }
14753
+
14754
+ if ($timeout)
14755
+ {
14756
+ $this->timeout = (string) $timeout;
14757
+ }
14758
+
14759
+ if ($useragent)
14760
+ {
14761
+ $this->useragent = (string) $useragent;
14762
+ }
14763
+
14764
+ if ($force_fsockopen)
14765
+ {
14766
+ $this->force_fsockopen = (string) $force_fsockopen;
14767
+ }
14768
+ }
14769
+
14770
+ function strip_htmltags($tags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'))
14771
+ {
14772
+ if ($tags)
14773
+ {
14774
+ if (is_array($tags))
14775
+ {
14776
+ $this->strip_htmltags = $tags;
14777
+ }
14778
+ else
14779
+ {
14780
+ $this->strip_htmltags = explode(',', $tags);
14781
+ }
14782
+ }
14783
+ else
14784
+ {
14785
+ $this->strip_htmltags = false;
14786
+ }
14787
+ }
14788
+
14789
+ function encode_instead_of_strip($encode = false)
14790
+ {
14791
+ $this->encode_instead_of_strip = (bool) $encode;
14792
+ }
14793
+
14794
+ function strip_attributes($attribs = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'))
14795
+ {
14796
+ if ($attribs)
14797
+ {
14798
+ if (is_array($attribs))
14799
+ {
14800
+ $this->strip_attributes = $attribs;
14801
+ }
14802
+ else
14803
+ {
14804
+ $this->strip_attributes = explode(',', $attribs);
14805
+ }
14806
+ }
14807
+ else
14808
+ {
14809
+ $this->strip_attributes = false;
14810
+ }
14811
+ }
14812
+
14813
+ function strip_comments($strip = false)
14814
+ {
14815
+ $this->strip_comments = (bool) $strip;
14816
+ }
14817
+
14818
+ function set_output_encoding($encoding = 'UTF-8')
14819
+ {
14820
+ $this->output_encoding = (string) $encoding;
14821
+ }
14822
+
14823
+ /**
14824
+ * Set element/attribute key/value pairs of HTML attributes
14825
+ * containing URLs that need to be resolved relative to the feed
14826
+ *
14827
+ * @access public
14828
+ * @since 1.0
14829
+ * @param array $element_attribute Element/attribute key/value pairs
14830
+ */
14831
+ function set_url_replacements($element_attribute = array('a' => 'href', 'area' => 'href', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite'))
14832
+ {
14833
+ $this->replace_url_attributes = (array) $element_attribute;
14834
+ }
14835
+
14836
+ function sanitize($data, $type, $base = '')
14837
+ {
14838
+ $data = trim($data);
14839
+ if ($data !== '' || $type & SIMPLEPIE_CONSTRUCT_IRI)
14840
+ {
14841
+ if ($type & SIMPLEPIE_CONSTRUCT_MAYBE_HTML)
14842
+ {
14843
+ if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>)/', $data))
14844
+ {
14845
+ $type |= SIMPLEPIE_CONSTRUCT_HTML;
14846
+ }
14847
+ else
14848
+ {
14849
+ $type |= SIMPLEPIE_CONSTRUCT_TEXT;
14850
+ }
14851
+ }
14852
+
14853
+ if ($type & SIMPLEPIE_CONSTRUCT_BASE64)
14854
+ {
14855
+ $data = base64_decode($data);
14856
+ }
14857
+
14858
+ if ($type & SIMPLEPIE_CONSTRUCT_XHTML)
14859
+ {
14860
+ if ($this->remove_div)
14861
+ {
14862
+ $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '', $data);
14863
+ $data = preg_replace('/<\/div>$/', '', $data);
14864
+ }
14865
+ else
14866
+ {
14867
+ $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '<div>', $data);
14868
+ }
14869
+ }
14870
+
14871
+ if ($type & (SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML))
14872
+ {
14873
+ // Strip comments
14874
+ if ($this->strip_comments)
14875
+ {
14876
+ $data = SimplePie_Misc::strip_comments($data);
14877
+ }
14878
+
14879
+ // Strip out HTML tags and attributes that might cause various security problems.
14880
+ // Based on recommendations by Mark Pilgrim at:
14881
+ // http://diveintomark.org/archives/2003/06/12/how_to_consume_rss_safely
14882
+ if ($this->strip_htmltags)
14883
+ {
14884
+ foreach ($this->strip_htmltags as $tag)
14885
+ {
14886
+ $pcre = "/<($tag)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$tag" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>|(\/)?>)/siU';
14887
+ while (preg_match($pcre, $data))
14888
+ {
14889
+ $data = preg_replace_callback($pcre, array(&$this, 'do_strip_htmltags'), $data);
14890
+ }
14891
+ }
14892
+ }
14893
+
14894
+ if ($this->strip_attributes)
14895
+ {
14896
+ foreach ($this->strip_attributes as $attrib)
14897
+ {
14898
+ $data = preg_replace('/(<[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*)' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . trim($attrib) . '(?:\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>/', '\1\2\3>', $data);
14899
+ }
14900
+ }
14901
+
14902
+ // Replace relative URLs
14903
+ $this->base = $base;
14904
+ foreach ($this->replace_url_attributes as $element => $attributes)
14905
+ {
14906
+ $data = $this->replace_urls($data, $element, $attributes);
14907
+ }
14908
+
14909
+ // If image handling (caching, etc.) is enabled, cache and rewrite all the image tags.
14910
+ if (isset($this->image_handler) && ((string) $this->image_handler) !== '' && $this->enable_cache)
14911
+ {
14912
+ $images = SimplePie_Misc::get_element('img', $data);
14913
+ foreach ($images as $img)
14914
+ {
14915
+ if (isset($img['attribs']['src']['data']))
14916
+ {
14917
+ $image_url = call_user_func($this->cache_name_function, $img['attribs']['src']['data']);
14918
+ $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, $image_url, 'spi');
14919
+
14920
+ if ($cache->load())
14921
+ {
14922
+ $img['attribs']['src']['data'] = $this->image_handler . $image_url;
14923
+ $data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data);
14924
+ }
14925
+ else
14926
+ {
14927
+ $file = new $this->file_class($img['attribs']['src']['data'], $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen);
14928
+ $headers = $file->headers;
14929
+
14930
+ if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)))
14931
+ {
14932
+ if ($cache->save(array('headers' => $file->headers, 'body' => $file->body)))
14933
+ {
14934
+ $img['attribs']['src']['data'] = $this->image_handler . $image_url;
14935
+ $data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data);
14936
+ }
14937
+ else
14938
+ {
14939
+ 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);
14940
+ }
14941
+ }
14942
+ }
14943
+ }
14944
+ }
14945
+ }
14946
+
14947
+ // Having (possibly) taken stuff out, there may now be whitespace at the beginning/end of the data
14948
+ $data = trim($data);
14949
+ }
14950
+
14951
+ if ($type & SIMPLEPIE_CONSTRUCT_IRI)
14952
+ {
14953
+ $data = SimplePie_Misc::absolutize_url($data, $base);
14954
+ }
14955
+
14956
+ if ($type & (SIMPLEPIE_CONSTRUCT_TEXT | SIMPLEPIE_CONSTRUCT_IRI))
14957
+ {
14958
+ $data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8');
14959
+ }
14960
+
14961
+ if ($this->output_encoding !== 'UTF-8')
14962
+ {
14963
+ $data = SimplePie_Misc::change_encoding($data, 'UTF-8', $this->output_encoding);
14964
+ }
14965
+ }
14966
+ return $data;
14967
+ }
14968
+
14969
+ function replace_urls($data, $tag, $attributes)
14970
+ {
14971
+ if (!is_array($this->strip_htmltags) || !in_array($tag, $this->strip_htmltags))
14972
+ {
14973
+ $elements = SimplePie_Misc::get_element($tag, $data);
14974
+ foreach ($elements as $element)
14975
+ {
14976
+ if (is_array($attributes))
14977
+ {
14978
+ foreach ($attributes as $attribute)
14979
+ {
14980
+ if (isset($element['attribs'][$attribute]['data']))
14981
+ {
14982
+ $element['attribs'][$attribute]['data'] = SimplePie_Misc::absolutize_url($element['attribs'][$attribute]['data'], $this->base);
14983
+ $new_element = SimplePie_Misc::element_implode($element);
14984
+ $data = str_replace($element['full'], $new_element, $data);
14985
+ $element['full'] = $new_element;
14986
+ }
14987
+ }
14988
+ }
14989
+ elseif (isset($element['attribs'][$attributes]['data']))
14990
+ {
14991
+ $element['attribs'][$attributes]['data'] = SimplePie_Misc::absolutize_url($element['attribs'][$attributes]['data'], $this->base);
14992
+ $data = str_replace($element['full'], SimplePie_Misc::element_implode($element), $data);
14993
+ }
14994
+ }
14995
+ }
14996
+ return $data;
14997
+ }
14998
+
14999
+ function do_strip_htmltags($match)
15000
+ {
15001
+ if ($this->encode_instead_of_strip)
15002
+ {
15003
+ if (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
15004
+ {
15005
+ $match[1] = htmlspecialchars($match[1], ENT_COMPAT, 'UTF-8');
15006
+ $match[2] = htmlspecialchars($match[2], ENT_COMPAT, 'UTF-8');
15007
+ return "&lt;$match[1]$match[2]&gt;$match[3]&lt;/$match[1]&gt;";
15008
+ }
15009
+ else
15010
+ {
15011
+ return htmlspecialchars($match[0], ENT_COMPAT, 'UTF-8');
15012
+ }
15013
+ }
15014
+ elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
15015
+ {
15016
+ return $match[4];
15017
+ }
15018
+ else
15019
+ {
15020
+ return '';
15021
+ }
15022
+ }
15023
+ }
15024
+
15025
+ ?>
app/design/frontend/base/default/layout/magazento_sociallifestream.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addCss"><stylesheet>magazento_sociallifestream/style.css</stylesheet></action>
6
+ </reference>
7
+ <reference name="left">
8
+ <block type="sociallifestream/soclife" name="sociallifestream.home.left">
9
+ <action method="setTemplate">
10
+ <template>magazento_sociallifestream/home_left.phtml</template>
11
+ </action>
12
+ </block>
13
+ </reference>
14
+
15
+ <reference name="right">
16
+ <block type="sociallifestream/soclife" name="sociallifestream.home.right" >
17
+ <action method="setTemplate">
18
+ <template>magazento_sociallifestream/home_right.phtml</template>
19
+ </action>
20
+ </block>
21
+ </reference>
22
+
23
+ <reference name="before_body_end">
24
+ <block type="core/template" template="magazento_sociallifestream/magazento.phtml" />
25
+ </reference>
26
+ </default>
27
+
28
+
29
+ </layout>
30
+
31
+
app/design/frontend/base/default/template/magazento_sociallifestream/home_left.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ((Mage::getStoreConfig('sociallifestream/options/enable')) && (Mage::getStoreConfig('sociallifestream/homepage/sbleft'))):?>
2
+ <div class="magazento-soclifestream">
3
+ <div class="block block-soclifestream">
4
+ <div class="block-title title-soclifestream">
5
+ <strong> <?php echo Mage::getStoreConfig('sociallifestream/options/blocktitle'); ?> </strong>
6
+ </div>
7
+ <div class="block-content">
8
+ <?php if ($data = $this->getSocialData()): ?>
9
+ <?php echo $data; ?>
10
+ <?php else: ?>
11
+ <div class="social-noitems">
12
+ <?php echo Mage::getStoreConfig('sociallifestream/options/empty'); ?>
13
+ </div>
14
+ <?php endif; ?>
15
+ <div class="magazento-powered">Powered by
16
+ <a href="http://www.magazento.com/english/magento-ext/magazento-extensions" target="_blank">Magento extensions</a>
17
+ </div>
18
+ </div>
19
+ </div>
20
+ </div>
21
+ <?php endif; ?>
app/design/frontend/base/default/template/magazento_sociallifestream/home_right.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ((Mage::getStoreConfig('sociallifestream/options/enable')) && (Mage::getStoreConfig('sociallifestream/homepage/sbright'))): ?>
2
+ <div class="magazento-soclifestream">
3
+ <div class="block block-soclifestream">
4
+ <div class="block-title title-soclifestream">
5
+ <strong> <?php echo Mage::getStoreConfig('sociallifestream/options/blocktitle'); ?> </strong>
6
+ </div>
7
+ <div class="block-content">
8
+ <?php if ($data = $this->getSocialData()): ?>
9
+ <?php echo $data; ?>
10
+ <?php else: ?>
11
+ <div class="social-noitems">
12
+ <?php echo Mage::getStoreConfig('sociallifestream/options/empty'); ?>
13
+ </div>
14
+ <?php endif; ?>
15
+ <div class="magazento-powered">Powered by
16
+ <a href="http://www.magazento.com/english/magento-ext/magazento-extensions" target="_blank">Magento extensions</a>
17
+ </div>
18
+ </div>
19
+ </div>
20
+ </div>
21
+ <?php endif; ?>
app/design/frontend/base/default/template/magazento_sociallifestream/magazento.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ $default_description = Mage::getStoreConfig('design/head/default_description');
3
+ ?>
4
+
5
+ <p class="magazento-powered"><?php echo $default_description; ?> - Powered by
6
+ <a href="http://www.magazento.com/english/magento-ext/magazento-extensions/magento-one-step-page-checkout" target="_blank"> Magento checkout</a>
7
+ </p>
app/etc/modules/Magazento_SocialLifestream.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Magazento
5
+ * @package Magazento_SocialLifestream
6
+ * @author ModuleCreator
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Magazento_SocialLifestream>
13
+ <active>true</active>
14
+ <codePool>community</codePool>
15
+ </Magazento_SocialLifestream>
16
+ </modules>
17
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Magazento_Sociallifestream</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Display in sidebars feeds from Twitter, Delicious, Flickr, Tumblr, YouTube, Dribbble, Digg and Vimeo.</summary>
10
+ <description>This module allows you to combine all of your favorite social networks profiles and feeds and show it in store sidebars.</description>
11
+ <notes>0.1.0</notes>
12
+ <authors><author><name>volgodark</name><user>auto-converted</user><email>volgodark@gmail.com</email></author></authors>
13
+ <date>2012-10-06</date>
14
+ <time>08:08:40</time>
15
+ <contents><target name="magecommunity"><dir name="Magazento"><dir name="SocialLifestream"><dir name="Block"><file name="Developer.php" hash="ab501874b6e2890aaafd8915bb617830"/><file name="Soclife.php" hash="82e6211b70a6b394a0bd23b0e35e88d8"/></dir><dir name="Helper"><file name="Data.php" hash="3880b95eff026a474efaf729683e6841"/></dir><dir name="Model"><file name="Data.php" hash="5b41cb18012f9c503d3b70d95442ebe0"/></dir><dir name="etc"><file name="config.xml" hash="f88ddf52c14a87184e58efa66baf3e72"/><file name="system.xml" hash="1c7c62ea82d565bd3f9f1648e2e559f3"/></dir><dir name="lib"><file name="idna_convert.class.php" hash="b32d89aa283e51ace042cf6422cbea99"/><file name="lifestream.class.php" hash="dfef5b44ee6c8144b13eb0b78491a002"/><file name="simplepie.inc" hash="ddb50d791da7459008bf2415b201281d"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="magazento_sociallifestream"><file name="home_left.phtml" hash="924c0fde06cf3d9f1294a5fd91e8e8bd"/><file name="home_right.phtml" hash="4febc4ade7c18bce7bff581ec5970e5f"/><file name="magazento.phtml" hash="06d7c479cbc492715deb5b003f814974"/></dir></dir><dir name="layout"><file name="magazento_sociallifestream.xml" hash="0c4af4f34edf7fc28e73e8e575e49738"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magazento_SocialLifestream.xml" hash="ea7727632cef5dc9e8fb0cd1bafd0d1c"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="magazento_sociallifestream"><file name="style.css" hash="1b017f415eb1e7630ce902d235a881e7"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>
skin/frontend/base/default/magazento_sociallifestream/style.css ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .lifestream {
2
+ margin:0;
3
+ padding:0;
4
+ list-style:none;
5
+ border-top:1px solid #eee;
6
+ }
7
+ .lifestream li {
8
+ margin:2px 0;
9
+ padding:4px 4px 4px 28px;
10
+ list-style:none;
11
+ background-color:transparent;
12
+ background-repeat:no-repeat;
13
+ background-position:5px 5px;
14
+ border-bottom:1px solid #eee;
15
+ font-weight:bold;
16
+ }
17
+ .lifestream li a {
18
+ text-decoration:none;
19
+ color:#e90a0a;
20
+ font-weight:bold;
21
+ }
22
+ .lifestream li span a {
23
+ text-decoration:none;
24
+ font-size:0.8em;
25
+ color:#888;
26
+ }
27
+
28
+
29
+ /* DEFAULT THEME STYLES */
30
+ .magazento-soclifestream .block .block-title {
31
+ background: #df5432;
32
+ border-bottom: 1px solid #DDD;
33
+ padding: 2px 9px;
34
+ }
35
+
36
+ .magazento-soclifestream .block {
37
+ border: 1px solid #df5432;
38
+ margin: 0 0 15px;
39
+ }
40
+
41
+ .magazento-soclifestream .block .block-title strong {
42
+ display: block;
43
+ font: bold 12px/16px Arial, Helvetica, sans-serif;
44
+ min-height: 16px;
45
+ padding: 1px 0 1px;
46
+ text-transform: uppercase;
47
+ color: #fff;
48
+ }
49
+
50
+ .magazento-soclifestream .social-noitems {
51
+ padding: 10px;
52
+ }
53
+
54
+ /* POWERED */
55
+ .magazento-powered {
56
+ font-size: 9px;
57
+ color: #888;
58
+ padding: 0 2px;
59
+ text-decoration: none;
60
+ }
61
+ .magazento-powered a {
62
+ font-size: 9px;
63
+ color: #888;
64
+ text-decoration: none;
65
+ }