|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* SimplePie |
|
5
|
|
|
* |
|
6
|
|
|
* A PHP-Based RSS and Atom Feed Framework. |
|
7
|
|
|
* Takes the hard work out of managing a complete RSS/Atom solution. |
|
8
|
|
|
* |
|
9
|
|
|
* Please note: This file is automatically generated by a build script. The |
|
10
|
|
|
* full original source is always available from http://simplepie.org/ |
|
11
|
|
|
* |
|
12
|
|
|
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors |
|
13
|
|
|
* All rights reserved. |
|
14
|
|
|
* |
|
15
|
|
|
* Redistribution and use in source and binary forms, with or without modification, are |
|
16
|
|
|
* permitted provided that the following conditions are met: |
|
17
|
|
|
* |
|
18
|
|
|
* * Redistributions of source code must retain the above copyright notice, this list of |
|
19
|
|
|
* conditions and the following disclaimer. |
|
20
|
|
|
* |
|
21
|
|
|
* * Redistributions in binary form must reproduce the above copyright notice, this list |
|
22
|
|
|
* of conditions and the following disclaimer in the documentation and/or other materials |
|
23
|
|
|
* provided with the distribution. |
|
24
|
|
|
* |
|
25
|
|
|
* * Neither the name of the SimplePie Team nor the names of its contributors may be used |
|
26
|
|
|
* to endorse or promote products derived from this software without specific prior |
|
27
|
|
|
* written permission. |
|
28
|
|
|
* |
|
29
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS |
|
30
|
|
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
|
31
|
|
|
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS |
|
32
|
|
|
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
33
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
|
34
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
35
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
|
36
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
37
|
|
|
* POSSIBILITY OF SUCH DAMAGE. |
|
38
|
|
|
* |
|
39
|
|
|
* @package SimplePie |
|
40
|
|
|
* @version 1.3.1 |
|
41
|
|
|
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue |
|
42
|
|
|
* @author Ryan Parman |
|
43
|
|
|
* @author Geoffrey Sneddon |
|
44
|
|
|
* @author Ryan McCue |
|
45
|
|
|
* @link http://simplepie.org/ SimplePie |
|
46
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
|
47
|
|
|
*/ |
|
48
|
|
|
|
|
49
|
|
|
define('SIMPLEPIE_NAME', 'SimplePie'); |
|
50
|
|
|
define('SIMPLEPIE_VERSION', '1.3.1'); |
|
51
|
|
|
define('SIMPLEPIE_BUILD', '20121030175911'); |
|
52
|
|
|
define('SIMPLEPIE_URL', 'http://simplepie.org'); |
|
53
|
|
|
define('SIMPLEPIE_USERAGENT', SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION . ' (Feed Parser; ' . SIMPLEPIE_URL . '; Allow like Gecko) Build/' . SIMPLEPIE_BUILD); |
|
54
|
|
|
define('SIMPLEPIE_LINKBACK', '<a href="' . SIMPLEPIE_URL . '" title="' . SIMPLEPIE_NAME . ' ' . SIMPLEPIE_VERSION . '">' . SIMPLEPIE_NAME . '</a>'); |
|
55
|
|
|
define('SIMPLEPIE_LOCATOR_NONE', 0); |
|
56
|
|
|
define('SIMPLEPIE_LOCATOR_AUTODISCOVERY', 1); |
|
57
|
|
|
define('SIMPLEPIE_LOCATOR_LOCAL_EXTENSION', 2); |
|
58
|
|
|
define('SIMPLEPIE_LOCATOR_LOCAL_BODY', 4); |
|
59
|
|
|
define('SIMPLEPIE_LOCATOR_REMOTE_EXTENSION', 8); |
|
60
|
|
|
define('SIMPLEPIE_LOCATOR_REMOTE_BODY', 16); |
|
61
|
|
|
define('SIMPLEPIE_LOCATOR_ALL', 31); |
|
62
|
|
|
define('SIMPLEPIE_TYPE_NONE', 0); |
|
63
|
|
|
define('SIMPLEPIE_TYPE_RSS_090', 1); |
|
64
|
|
|
define('SIMPLEPIE_TYPE_RSS_091_NETSCAPE', 2); |
|
65
|
|
|
define('SIMPLEPIE_TYPE_RSS_091_USERLAND', 4); |
|
66
|
|
|
define('SIMPLEPIE_TYPE_RSS_091', 6); |
|
67
|
|
|
define('SIMPLEPIE_TYPE_RSS_092', 8); |
|
68
|
|
|
define('SIMPLEPIE_TYPE_RSS_093', 16); |
|
69
|
|
|
define('SIMPLEPIE_TYPE_RSS_094', 32); |
|
70
|
|
|
define('SIMPLEPIE_TYPE_RSS_10', 64); |
|
71
|
|
|
define('SIMPLEPIE_TYPE_RSS_20', 128); |
|
72
|
|
|
define('SIMPLEPIE_TYPE_RSS_RDF', 65); |
|
73
|
|
|
define('SIMPLEPIE_TYPE_RSS_SYNDICATION', 190); |
|
74
|
|
|
define('SIMPLEPIE_TYPE_RSS_ALL', 255); |
|
75
|
|
|
define('SIMPLEPIE_TYPE_ATOM_03', 256); |
|
76
|
|
|
define('SIMPLEPIE_TYPE_ATOM_10', 512); |
|
77
|
|
|
define('SIMPLEPIE_TYPE_ATOM_ALL', 768); |
|
78
|
|
|
define('SIMPLEPIE_TYPE_ALL', 1023); |
|
79
|
|
|
define('SIMPLEPIE_CONSTRUCT_NONE', 0); |
|
80
|
|
|
define('SIMPLEPIE_CONSTRUCT_TEXT', 1); |
|
81
|
|
|
define('SIMPLEPIE_CONSTRUCT_HTML', 2); |
|
82
|
|
|
define('SIMPLEPIE_CONSTRUCT_XHTML', 4); |
|
83
|
|
|
define('SIMPLEPIE_CONSTRUCT_BASE64', 8); |
|
84
|
|
|
define('SIMPLEPIE_CONSTRUCT_IRI', 16); |
|
85
|
|
|
define('SIMPLEPIE_CONSTRUCT_MAYBE_HTML', 32); |
|
86
|
|
|
define('SIMPLEPIE_CONSTRUCT_ALL', 63); |
|
87
|
|
|
define('SIMPLEPIE_SAME_CASE', 1); |
|
88
|
|
|
define('SIMPLEPIE_LOWERCASE', 2); |
|
89
|
|
|
define('SIMPLEPIE_UPPERCASE', 4); |
|
90
|
|
|
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]*'); |
|
91
|
|
|
define('SIMPLEPIE_PCRE_XML_ATTRIBUTE', '((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'))*)\s*'); |
|
92
|
|
|
define('SIMPLEPIE_NAMESPACE_XML', 'http://www.w3.org/XML/1998/namespace'); |
|
93
|
|
|
define('SIMPLEPIE_NAMESPACE_ATOM_10', 'http://www.w3.org/2005/Atom'); |
|
94
|
|
|
define('SIMPLEPIE_NAMESPACE_ATOM_03', 'http://purl.org/atom/ns#'); |
|
95
|
|
|
define('SIMPLEPIE_NAMESPACE_RDF', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'); |
|
96
|
|
|
define('SIMPLEPIE_NAMESPACE_RSS_090', 'http://my.netscape.com/rdf/simple/0.9/'); |
|
97
|
|
|
define('SIMPLEPIE_NAMESPACE_RSS_10', 'http://purl.org/rss/1.0/'); |
|
98
|
|
|
define('SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT', 'http://purl.org/rss/1.0/modules/content/'); |
|
99
|
|
|
define('SIMPLEPIE_NAMESPACE_RSS_20', ''); |
|
100
|
|
|
define('SIMPLEPIE_NAMESPACE_DC_10', 'http://purl.org/dc/elements/1.0/'); |
|
101
|
|
|
define('SIMPLEPIE_NAMESPACE_DC_11', 'http://purl.org/dc/elements/1.1/'); |
|
102
|
|
|
define('SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO', 'http://www.w3.org/2003/01/geo/wgs84_pos#'); |
|
103
|
|
|
define('SIMPLEPIE_NAMESPACE_GEORSS', 'http://www.georss.org/georss'); |
|
104
|
|
|
define('SIMPLEPIE_NAMESPACE_MEDIARSS', 'http://search.yahoo.com/mrss/'); |
|
105
|
|
|
define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG', 'http://search.yahoo.com/mrss'); |
|
106
|
|
|
define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG2', 'http://video.search.yahoo.com/mrss'); |
|
107
|
|
|
define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG3', 'http://video.search.yahoo.com/mrss/'); |
|
108
|
|
|
define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG4', 'http://www.rssboard.org/media-rss'); |
|
109
|
|
|
define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG5', 'http://www.rssboard.org/media-rss/'); |
|
110
|
|
|
define('SIMPLEPIE_NAMESPACE_ITUNES', 'http://www.itunes.com/dtds/podcast-1.0.dtd'); |
|
111
|
|
|
define('SIMPLEPIE_NAMESPACE_XHTML', 'http://www.w3.org/1999/xhtml'); |
|
112
|
|
|
define('SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY', 'http://www.iana.org/assignments/relation/'); |
|
113
|
|
|
define('SIMPLEPIE_FILE_SOURCE_NONE', 0); |
|
114
|
|
|
define('SIMPLEPIE_FILE_SOURCE_REMOTE', 1); |
|
115
|
|
|
define('SIMPLEPIE_FILE_SOURCE_LOCAL', 2); |
|
116
|
|
|
define('SIMPLEPIE_FILE_SOURCE_FSOCKOPEN', 4); |
|
117
|
|
|
define('SIMPLEPIE_FILE_SOURCE_CURL', 8); |
|
118
|
|
|
define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16); |
|
119
|
|
|
class SimplePie |
|
120
|
|
|
{ |
|
121
|
|
|
|
|
122
|
|
|
public $data = array(); |
|
123
|
|
|
|
|
124
|
|
|
public $error; |
|
125
|
|
|
|
|
126
|
|
|
public $sanitize; |
|
127
|
|
|
|
|
128
|
|
|
public $useragent = SIMPLEPIE_USERAGENT; |
|
129
|
|
|
|
|
130
|
|
|
public $feed_url; |
|
131
|
|
|
|
|
132
|
|
|
public $file; |
|
133
|
|
|
|
|
134
|
|
|
public $raw_data; |
|
135
|
|
|
|
|
136
|
|
|
public $timeout = 10; |
|
137
|
|
|
|
|
138
|
|
|
public $force_fsockopen = false; |
|
139
|
|
|
|
|
140
|
|
|
public $force_feed = false; |
|
141
|
|
|
|
|
142
|
|
|
public $cache = true; |
|
143
|
|
|
|
|
144
|
|
|
public $cache_duration = 3600; |
|
145
|
|
|
|
|
146
|
|
|
public $autodiscovery_cache_duration = 604800; // 7 Days. |
|
147
|
|
|
|
|
148
|
|
|
public $cache_location = './cache'; |
|
149
|
|
|
|
|
150
|
|
|
public $cache_name_function = 'md5'; |
|
151
|
|
|
|
|
152
|
|
|
public $order_by_date = true; |
|
153
|
|
|
|
|
154
|
|
|
public $input_encoding = false; |
|
155
|
|
|
|
|
156
|
|
|
public $autodiscovery = SIMPLEPIE_LOCATOR_ALL; |
|
157
|
|
|
|
|
158
|
|
|
public $registry; |
|
159
|
|
|
|
|
160
|
|
|
public $max_checked_feeds = 10; |
|
161
|
|
|
|
|
162
|
|
|
public $all_discovered_feeds = array(); |
|
163
|
|
|
|
|
164
|
|
|
public $image_handler = ''; |
|
165
|
|
|
|
|
166
|
|
|
public $multifeed_url = array(); |
|
167
|
|
|
|
|
168
|
|
|
public $multifeed_objects = array(); |
|
169
|
|
|
|
|
170
|
|
|
public $config_settings = null; |
|
171
|
|
|
|
|
172
|
|
|
public $item_limit = 0; |
|
173
|
|
|
|
|
174
|
|
|
public $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'); |
|
175
|
|
|
|
|
176
|
|
|
public $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'); |
|
177
|
|
|
|
|
178
|
|
|
public function __construct() |
|
179
|
|
|
{ |
|
180
|
|
|
if (version_compare(PHP_VERSION, '5.2', '<')) |
|
181
|
|
|
{ |
|
182
|
|
|
trigger_error('PHP 4.x, 5.0 and 5.1 are no longer supported. Please upgrade to PHP 5.2 or newer.'); |
|
183
|
|
|
die(); |
|
184
|
|
|
} |
|
185
|
|
|
// Other objects, instances created here so we can set options on them |
|
186
|
|
|
$this->sanitize = new SimplePie_Sanitize(); |
|
187
|
|
|
$this->registry = new SimplePie_Registry(); |
|
188
|
|
|
if (func_num_args() > 0) |
|
189
|
|
|
{ |
|
190
|
|
|
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; |
|
191
|
|
|
trigger_error('Passing parameters to the constructor is no longer supported. Please use set_feed_url(), set_cache_location(), and set_cache_location() directly.', $level); |
|
192
|
|
|
$args = func_get_args(); |
|
193
|
|
|
switch (count($args)) { |
|
194
|
|
|
case 3: |
|
195
|
|
|
$this->set_cache_duration($args[2]); |
|
196
|
|
|
case 2: |
|
197
|
|
|
$this->set_cache_location($args[1]); |
|
198
|
|
|
case 1: |
|
199
|
|
|
$this->set_feed_url($args[0]); |
|
200
|
|
|
$this->init(); |
|
201
|
|
|
} |
|
202
|
|
|
} |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
public function __toString() |
|
206
|
|
|
{ |
|
207
|
|
|
return md5(serialize($this->data)); |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
public function __destruct() |
|
211
|
|
|
{ |
|
212
|
|
|
if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) |
|
213
|
|
|
{ |
|
214
|
|
|
if (!empty($this->data['items'])) |
|
215
|
|
|
{ |
|
216
|
|
|
foreach ($this->data['items'] as $item) |
|
217
|
|
|
{ |
|
218
|
|
|
$item->__destruct(); |
|
219
|
|
|
} |
|
220
|
|
|
unset($item, $this->data['items']); |
|
221
|
|
|
} |
|
222
|
|
|
if (!empty($this->data['ordered_items'])) |
|
223
|
|
|
{ |
|
224
|
|
|
foreach ($this->data['ordered_items'] as $item) |
|
225
|
|
|
{ |
|
226
|
|
|
$item->__destruct(); |
|
227
|
|
|
} |
|
228
|
|
|
unset($item, $this->data['ordered_items']); |
|
229
|
|
|
} |
|
230
|
|
|
} |
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
|
|
public function force_feed($enable = false) |
|
234
|
|
|
{ |
|
235
|
|
|
$this->force_feed = (bool) $enable; |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
public function set_feed_url($url) |
|
239
|
|
|
{ |
|
240
|
|
|
$this->multifeed_url = array(); |
|
241
|
|
|
if (is_array($url)) |
|
242
|
|
|
{ |
|
243
|
|
|
foreach ($url as $value) |
|
244
|
|
|
{ |
|
245
|
|
|
$this->multifeed_url[] = $this->registry->call('Misc', 'fix_protocol', array($value, 1)); |
|
246
|
|
|
} |
|
247
|
|
|
} |
|
248
|
|
|
else |
|
249
|
|
|
{ |
|
250
|
|
|
$this->feed_url = $this->registry->call('Misc', 'fix_protocol', array($url, 1)); |
|
251
|
|
|
} |
|
252
|
|
|
} |
|
253
|
|
|
|
|
254
|
|
|
public function set_file(&$file) |
|
255
|
|
|
{ |
|
256
|
|
|
if ($file instanceof SimplePie_File) |
|
257
|
|
|
{ |
|
258
|
|
|
$this->feed_url = $file->url; |
|
259
|
|
|
$this->file =& $file; |
|
260
|
|
|
return true; |
|
261
|
|
|
} |
|
262
|
|
|
return false; |
|
263
|
|
|
} |
|
264
|
|
|
|
|
265
|
|
|
public function set_raw_data($data) |
|
266
|
|
|
{ |
|
267
|
|
|
$this->raw_data = $data; |
|
268
|
|
|
} |
|
269
|
|
|
|
|
270
|
|
|
public function set_timeout($timeout = 10) |
|
271
|
|
|
{ |
|
272
|
|
|
$this->timeout = (int) $timeout; |
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
|
|
public function force_fsockopen($enable = false) |
|
276
|
|
|
{ |
|
277
|
|
|
$this->force_fsockopen = (bool) $enable; |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
public function enable_cache($enable = true) |
|
281
|
|
|
{ |
|
282
|
|
|
$this->cache = (bool) $enable; |
|
283
|
|
|
} |
|
284
|
|
|
|
|
285
|
|
|
public function set_cache_duration($seconds = 3600) |
|
286
|
|
|
{ |
|
287
|
|
|
$this->cache_duration = (int) $seconds; |
|
288
|
|
|
} |
|
289
|
|
|
|
|
290
|
|
|
public function set_autodiscovery_cache_duration($seconds = 604800) |
|
291
|
|
|
{ |
|
292
|
|
|
$this->autodiscovery_cache_duration = (int) $seconds; |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
public function set_cache_location($location = './cache') |
|
296
|
|
|
{ |
|
297
|
|
|
$this->cache_location = (string) $location; |
|
298
|
|
|
} |
|
299
|
|
|
|
|
300
|
|
|
public function enable_order_by_date($enable = true) |
|
301
|
|
|
{ |
|
302
|
|
|
$this->order_by_date = (bool) $enable; |
|
303
|
|
|
} |
|
304
|
|
|
|
|
305
|
|
|
public function set_input_encoding($encoding = false) |
|
306
|
|
|
{ |
|
307
|
|
|
if ($encoding) |
|
308
|
|
|
{ |
|
309
|
|
|
$this->input_encoding = (string) $encoding; |
|
310
|
|
|
} |
|
311
|
|
|
else |
|
312
|
|
|
{ |
|
313
|
|
|
$this->input_encoding = false; |
|
314
|
|
|
} |
|
315
|
|
|
} |
|
316
|
|
|
|
|
317
|
|
|
public function set_autodiscovery_level($level = SIMPLEPIE_LOCATOR_ALL) |
|
318
|
|
|
{ |
|
319
|
|
|
$this->autodiscovery = (int) $level; |
|
320
|
|
|
} |
|
321
|
|
|
|
|
322
|
|
|
public function &get_registry() |
|
323
|
|
|
{ |
|
324
|
|
|
return $this->registry; |
|
325
|
|
|
} |
|
326
|
|
|
|
|
327
|
|
|
|
|
328
|
|
|
public function set_cache_class($class = 'SimplePie_Cache') |
|
329
|
|
|
{ |
|
330
|
|
|
return $this->registry->register('Cache', $class, true); |
|
331
|
|
|
} |
|
332
|
|
|
|
|
333
|
|
|
public function set_locator_class($class = 'SimplePie_Locator') |
|
334
|
|
|
{ |
|
335
|
|
|
return $this->registry->register('Locator', $class, true); |
|
336
|
|
|
} |
|
337
|
|
|
|
|
338
|
|
|
public function set_parser_class($class = 'SimplePie_Parser') |
|
339
|
|
|
{ |
|
340
|
|
|
return $this->registry->register('Parser', $class, true); |
|
341
|
|
|
} |
|
342
|
|
|
|
|
343
|
|
|
public function set_file_class($class = 'SimplePie_File') |
|
344
|
|
|
{ |
|
345
|
|
|
return $this->registry->register('File', $class, true); |
|
346
|
|
|
} |
|
347
|
|
|
|
|
348
|
|
|
public function set_sanitize_class($class = 'SimplePie_Sanitize') |
|
349
|
|
|
{ |
|
350
|
|
|
return $this->registry->register('Sanitize', $class, true); |
|
351
|
|
|
} |
|
352
|
|
|
|
|
353
|
|
|
public function set_item_class($class = 'SimplePie_Item') |
|
354
|
|
|
{ |
|
355
|
|
|
return $this->registry->register('Item', $class, true); |
|
356
|
|
|
} |
|
357
|
|
|
|
|
358
|
|
|
public function set_author_class($class = 'SimplePie_Author') |
|
359
|
|
|
{ |
|
360
|
|
|
return $this->registry->register('Author', $class, true); |
|
361
|
|
|
} |
|
362
|
|
|
|
|
363
|
|
|
public function set_category_class($class = 'SimplePie_Category') |
|
364
|
|
|
{ |
|
365
|
|
|
return $this->registry->register('Category', $class, true); |
|
366
|
|
|
} |
|
367
|
|
|
|
|
368
|
|
|
public function set_enclosure_class($class = 'SimplePie_Enclosure') |
|
369
|
|
|
{ |
|
370
|
|
|
return $this->registry->register('Enclosure', $class, true); |
|
371
|
|
|
} |
|
372
|
|
|
|
|
373
|
|
|
public function set_caption_class($class = 'SimplePie_Caption') |
|
374
|
|
|
{ |
|
375
|
|
|
return $this->registry->register('Caption', $class, true); |
|
376
|
|
|
} |
|
377
|
|
|
|
|
378
|
|
|
public function set_copyright_class($class = 'SimplePie_Copyright') |
|
379
|
|
|
{ |
|
380
|
|
|
return $this->registry->register('Copyright', $class, true); |
|
381
|
|
|
} |
|
382
|
|
|
|
|
383
|
|
|
public function set_credit_class($class = 'SimplePie_Credit') |
|
384
|
|
|
{ |
|
385
|
|
|
return $this->registry->register('Credit', $class, true); |
|
386
|
|
|
} |
|
387
|
|
|
|
|
388
|
|
|
public function set_rating_class($class = 'SimplePie_Rating') |
|
389
|
|
|
{ |
|
390
|
|
|
return $this->registry->register('Rating', $class, true); |
|
391
|
|
|
} |
|
392
|
|
|
|
|
393
|
|
|
public function set_restriction_class($class = 'SimplePie_Restriction') |
|
394
|
|
|
{ |
|
395
|
|
|
return $this->registry->register('Restriction', $class, true); |
|
396
|
|
|
} |
|
397
|
|
|
|
|
398
|
|
|
public function set_content_type_sniffer_class($class = 'SimplePie_Content_Type_Sniffer') |
|
399
|
|
|
{ |
|
400
|
|
|
return $this->registry->register('Content_Type_Sniffer', $class, true); |
|
401
|
|
|
} |
|
402
|
|
|
|
|
403
|
|
|
public function set_source_class($class = 'SimplePie_Source') |
|
404
|
|
|
{ |
|
405
|
|
|
return $this->registry->register('Source', $class, true); |
|
406
|
|
|
} |
|
407
|
|
|
|
|
408
|
|
|
|
|
409
|
|
|
public function set_useragent($ua = SIMPLEPIE_USERAGENT) |
|
410
|
|
|
{ |
|
411
|
|
|
$this->useragent = (string) $ua; |
|
412
|
|
|
} |
|
413
|
|
|
|
|
414
|
|
|
public function set_cache_name_function($function = 'md5') |
|
415
|
|
|
{ |
|
416
|
|
|
if (is_callable($function)) |
|
417
|
|
|
{ |
|
418
|
|
|
$this->cache_name_function = $function; |
|
419
|
|
|
} |
|
420
|
|
|
} |
|
421
|
|
|
|
|
422
|
|
|
public function set_stupidly_fast($set = false) |
|
423
|
|
|
{ |
|
424
|
|
|
if ($set) |
|
425
|
|
|
{ |
|
426
|
|
|
$this->enable_order_by_date(false); |
|
427
|
|
|
$this->remove_div(false); |
|
428
|
|
|
$this->strip_comments(false); |
|
429
|
|
|
$this->strip_htmltags(false); |
|
430
|
|
|
$this->strip_attributes(false); |
|
431
|
|
|
$this->set_image_handler(false); |
|
432
|
|
|
} |
|
433
|
|
|
} |
|
434
|
|
|
|
|
435
|
|
|
public function set_max_checked_feeds($max = 10) |
|
436
|
|
|
{ |
|
437
|
|
|
$this->max_checked_feeds = (int) $max; |
|
438
|
|
|
} |
|
439
|
|
|
public function remove_div($enable = true) |
|
440
|
|
|
{ |
|
441
|
|
|
$this->sanitize->remove_div($enable); |
|
442
|
|
|
} |
|
443
|
|
|
public function strip_htmltags($tags = '', $encode = null) |
|
444
|
|
|
{ |
|
445
|
|
|
if ($tags === '') |
|
446
|
|
|
{ |
|
447
|
|
|
$tags = $this->strip_htmltags; |
|
448
|
|
|
} |
|
449
|
|
|
$this->sanitize->strip_htmltags($tags); |
|
450
|
|
|
if ($encode !== null) |
|
451
|
|
|
{ |
|
452
|
|
|
$this->sanitize->encode_instead_of_strip($tags); |
|
453
|
|
|
} |
|
454
|
|
|
} |
|
455
|
|
|
public function encode_instead_of_strip($enable = true) |
|
456
|
|
|
{ |
|
457
|
|
|
$this->sanitize->encode_instead_of_strip($enable); |
|
458
|
|
|
} |
|
459
|
|
|
public function strip_attributes($attribs = '') |
|
460
|
|
|
{ |
|
461
|
|
|
if ($attribs === '') |
|
462
|
|
|
{ |
|
463
|
|
|
$attribs = $this->strip_attributes; |
|
464
|
|
|
} |
|
465
|
|
|
$this->sanitize->strip_attributes($attribs); |
|
466
|
|
|
} |
|
467
|
|
|
|
|
468
|
|
|
public function set_output_encoding($encoding = 'UTF-8') |
|
469
|
|
|
{ |
|
470
|
|
|
$this->sanitize->set_output_encoding($encoding); |
|
471
|
|
|
} |
|
472
|
|
|
public function strip_comments($strip = false) |
|
473
|
|
|
{ |
|
474
|
|
|
$this->sanitize->strip_comments($strip); |
|
475
|
|
|
} |
|
476
|
|
|
|
|
477
|
|
|
public function set_url_replacements($element_attribute = null) |
|
478
|
|
|
{ |
|
479
|
|
|
$this->sanitize->set_url_replacements($element_attribute); |
|
480
|
|
|
} |
|
481
|
|
|
|
|
482
|
|
|
public function set_image_handler($page = false, $qs = 'i') |
|
483
|
|
|
{ |
|
484
|
|
|
if ($page !== false) |
|
485
|
|
|
{ |
|
486
|
|
|
$this->sanitize->set_image_handler($page . '?' . $qs . '='); |
|
487
|
|
|
} |
|
488
|
|
|
else |
|
489
|
|
|
{ |
|
490
|
|
|
$this->image_handler = ''; |
|
491
|
|
|
} |
|
492
|
|
|
} |
|
493
|
|
|
|
|
494
|
|
|
public function set_item_limit($limit = 0) |
|
495
|
|
|
{ |
|
496
|
|
|
$this->item_limit = (int) $limit; |
|
497
|
|
|
} |
|
498
|
|
|
|
|
499
|
|
|
public function init() |
|
500
|
|
|
{ |
|
501
|
|
|
// Check absolute bare minimum requirements. |
|
502
|
|
|
if (!extension_loaded('xml') || !extension_loaded('pcre')) |
|
503
|
|
|
{ |
|
504
|
|
|
return false; |
|
505
|
|
|
} |
|
506
|
|
|
// 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. |
|
507
|
|
|
elseif (!extension_loaded('xmlreader')) |
|
508
|
|
|
{ |
|
509
|
|
|
static $xml_is_sane = null; |
|
510
|
|
|
if ($xml_is_sane === null) |
|
511
|
|
|
{ |
|
512
|
|
|
$parser_check = xml_parser_create(); |
|
513
|
|
|
xml_parse_into_struct($parser_check, '<foo>&</foo>', $values); |
|
514
|
|
|
xml_parser_free($parser_check); |
|
515
|
|
|
$xml_is_sane = isset($values[0]['value']); |
|
516
|
|
|
} |
|
517
|
|
|
if (!$xml_is_sane) |
|
518
|
|
|
{ |
|
519
|
|
|
return false; |
|
520
|
|
|
} |
|
521
|
|
|
} |
|
522
|
|
|
if (method_exists($this->sanitize, 'set_registry')) |
|
523
|
|
|
{ |
|
524
|
|
|
$this->sanitize->set_registry($this->registry); |
|
525
|
|
|
} |
|
526
|
|
|
// Pass whatever was set with config options over to the sanitizer. |
|
527
|
|
|
// Pass the classes in for legacy support; new classes should use the registry instead |
|
528
|
|
|
$this->sanitize->pass_cache_data($this->cache, $this->cache_location, $this->cache_name_function, $this->registry->get_class('Cache')); |
|
529
|
|
|
$this->sanitize->pass_file_data($this->registry->get_class('File'), $this->timeout, $this->useragent, $this->force_fsockopen); |
|
530
|
|
|
if (!empty($this->multifeed_url)) |
|
531
|
|
|
{ |
|
532
|
|
|
$i = 0; |
|
533
|
|
|
$success = 0; |
|
534
|
|
|
$this->multifeed_objects = array(); |
|
535
|
|
|
$this->error = array(); |
|
536
|
|
|
foreach ($this->multifeed_url as $url) |
|
537
|
|
|
{ |
|
538
|
|
|
$this->multifeed_objects[$i] = clone $this; |
|
539
|
|
|
$this->multifeed_objects[$i]->set_feed_url($url); |
|
540
|
|
|
$single_success = $this->multifeed_objects[$i]->init(); |
|
541
|
|
|
$success |= $single_success; |
|
542
|
|
|
if (!$single_success) |
|
543
|
|
|
{ |
|
544
|
|
|
$this->error[$i] = $this->multifeed_objects[$i]->error(); |
|
545
|
|
|
} |
|
546
|
|
|
$i++; |
|
547
|
|
|
} |
|
548
|
|
|
return (bool) $success; |
|
549
|
|
|
} |
|
550
|
|
|
elseif ($this->feed_url === null && $this->raw_data === null) |
|
551
|
|
|
{ |
|
552
|
|
|
return false; |
|
553
|
|
|
} |
|
554
|
|
|
$this->error = null; |
|
555
|
|
|
$this->data = array(); |
|
556
|
|
|
$this->multifeed_objects = array(); |
|
557
|
|
|
$cache = false; |
|
558
|
|
|
if ($this->feed_url !== null) |
|
559
|
|
|
{ |
|
560
|
|
|
$parsed_feed_url = $this->registry->call('Misc', 'parse_url', array($this->feed_url)); |
|
561
|
|
|
// Decide whether to enable caching |
|
562
|
|
|
if ($this->cache && $parsed_feed_url['scheme'] !== '') |
|
563
|
|
|
{ |
|
564
|
|
|
$cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc')); |
|
565
|
|
|
} |
|
566
|
|
|
// Fetch the data via SimplePie_File into $this->raw_data |
|
567
|
|
|
if (($fetched = $this->fetch_data($cache)) === true) |
|
568
|
|
|
{ |
|
569
|
|
|
return true; |
|
570
|
|
|
} |
|
571
|
|
|
elseif ($fetched === false) { |
|
572
|
|
|
return false; |
|
573
|
|
|
} |
|
574
|
|
|
list($headers, $sniffed) = $fetched; |
|
575
|
|
|
} |
|
576
|
|
|
// Set up array of possible encodings |
|
577
|
|
|
$encodings = array(); |
|
578
|
|
|
// First check to see if input has been overridden. |
|
579
|
|
|
if ($this->input_encoding !== false) |
|
580
|
|
|
{ |
|
581
|
|
|
$encodings[] = $this->input_encoding; |
|
582
|
|
|
} |
|
583
|
|
|
$application_types = array('application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity'); |
|
584
|
|
|
$text_types = array('text/xml', 'text/xml-external-parsed-entity'); |
|
585
|
|
|
// RFC 3023 (only applies to sniffed content) |
|
586
|
|
|
if (isset($sniffed)) |
|
587
|
|
|
{ |
|
588
|
|
|
if (in_array($sniffed, $application_types) || substr($sniffed, 0, 12) === 'application/' && substr($sniffed, -4) === '+xml') |
|
589
|
|
|
{ |
|
590
|
|
|
if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset)) |
|
591
|
|
|
{ |
|
592
|
|
|
$encodings[] = strtoupper($charset[1]); |
|
593
|
|
|
} |
|
594
|
|
|
$encodings = array_merge($encodings, $this->registry->call('Misc', 'xml_encoding', array($this->raw_data, &$this->registry))); |
|
595
|
|
|
$encodings[] = 'UTF-8'; |
|
596
|
|
|
} |
|
597
|
|
|
elseif (in_array($sniffed, $text_types) || substr($sniffed, 0, 5) === 'text/' && substr($sniffed, -4) === '+xml') |
|
598
|
|
|
{ |
|
599
|
|
|
if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset)) |
|
600
|
|
|
{ |
|
601
|
|
|
$encodings[] = $charset[1]; |
|
602
|
|
|
} |
|
603
|
|
|
$encodings[] = 'US-ASCII'; |
|
604
|
|
|
} |
|
605
|
|
|
// Text MIME-type default |
|
606
|
|
|
elseif (substr($sniffed, 0, 5) === 'text/') |
|
607
|
|
|
{ |
|
608
|
|
|
$encodings[] = 'US-ASCII'; |
|
609
|
|
|
} |
|
610
|
|
|
} |
|
611
|
|
|
// Fallback to XML 1.0 Appendix F.1/UTF-8/ISO-8859-1 |
|
612
|
|
|
$encodings = array_merge($encodings, $this->registry->call('Misc', 'xml_encoding', array($this->raw_data, &$this->registry))); |
|
613
|
|
|
$encodings[] = 'UTF-8'; |
|
614
|
|
|
$encodings[] = 'ISO-8859-1'; |
|
615
|
|
|
// There's no point in trying an encoding twice |
|
616
|
|
|
$encodings = array_unique($encodings); |
|
617
|
|
|
// Loop through each possible encoding, till we return something, or run out of possibilities |
|
618
|
|
|
foreach ($encodings as $encoding) |
|
619
|
|
|
{ |
|
620
|
|
|
// Change the encoding to UTF-8 (as we always use UTF-8 internally) |
|
621
|
|
|
if ($utf8_data = $this->registry->call('Misc', 'change_encoding', array($this->raw_data, $encoding, 'UTF-8'))) |
|
622
|
|
|
{ |
|
623
|
|
|
// Create new parser |
|
624
|
|
|
$parser = $this->registry->create('Parser'); |
|
625
|
|
|
// If it's parsed fine |
|
626
|
|
|
if ($parser->parse($utf8_data, 'UTF-8')) |
|
627
|
|
|
{ |
|
628
|
|
|
$this->data = $parser->get_data(); |
|
629
|
|
|
if (!($this->get_type() & ~SIMPLEPIE_TYPE_NONE)) |
|
630
|
|
|
{ |
|
631
|
|
|
$this->error = "A feed could not be found at $this->feed_url. This does not appear to be a valid RSS or Atom feed."; |
|
632
|
|
|
$this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); |
|
633
|
|
|
return false; |
|
634
|
|
|
} |
|
635
|
|
|
if (isset($headers)) |
|
636
|
|
|
{ |
|
637
|
|
|
$this->data['headers'] = $headers; |
|
638
|
|
|
} |
|
639
|
|
|
$this->data['build'] = SIMPLEPIE_BUILD; |
|
640
|
|
|
// Cache the file if caching is enabled |
|
641
|
|
|
if ($cache && !$cache->save($this)) |
|
642
|
|
|
{ |
|
643
|
|
|
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); |
|
644
|
|
|
} |
|
645
|
|
|
return true; |
|
646
|
|
|
} |
|
647
|
|
|
} |
|
648
|
|
|
} |
|
649
|
|
|
if (isset($parser)) |
|
650
|
|
|
{ |
|
651
|
|
|
// We have an error, just set SimplePie_Misc::error to it and quit |
|
652
|
|
|
$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()); |
|
653
|
|
|
} |
|
654
|
|
|
else |
|
655
|
|
|
{ |
|
656
|
|
|
$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.'; |
|
657
|
|
|
} |
|
658
|
|
|
$this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); |
|
659
|
|
|
return false; |
|
660
|
|
|
} |
|
661
|
|
|
|
|
662
|
|
|
protected function fetch_data(&$cache) |
|
663
|
|
|
{ |
|
664
|
|
|
// If it's enabled, use the cache |
|
665
|
|
|
if ($cache) |
|
666
|
|
|
{ |
|
667
|
|
|
// Load the Cache |
|
668
|
|
|
$this->data = $cache->load(); |
|
669
|
|
|
if (!empty($this->data)) |
|
670
|
|
|
{ |
|
671
|
|
|
// If the cache is for an outdated build of SimplePie |
|
672
|
|
|
if (!isset($this->data['build']) || $this->data['build'] !== SIMPLEPIE_BUILD) |
|
673
|
|
|
{ |
|
674
|
|
|
$cache->unlink(); |
|
675
|
|
|
$this->data = array(); |
|
676
|
|
|
} |
|
677
|
|
|
// If we've hit a collision just rerun it with caching disabled |
|
678
|
|
|
elseif (isset($this->data['url']) && $this->data['url'] !== $this->feed_url) |
|
679
|
|
|
{ |
|
680
|
|
|
$cache = false; |
|
681
|
|
|
$this->data = array(); |
|
682
|
|
|
} |
|
683
|
|
|
// If we've got a non feed_url stored (if the page isn't actually a feed, or is a redirect) use that URL. |
|
684
|
|
|
elseif (isset($this->data['feed_url'])) |
|
685
|
|
|
{ |
|
686
|
|
|
// If the autodiscovery cache is still valid use it. |
|
687
|
|
|
if ($cache->mtime() + $this->autodiscovery_cache_duration > time()) |
|
688
|
|
|
{ |
|
689
|
|
|
// Do not need to do feed autodiscovery yet. |
|
690
|
|
|
if ($this->data['feed_url'] !== $this->data['url']) |
|
691
|
|
|
{ |
|
692
|
|
|
$this->set_feed_url($this->data['feed_url']); |
|
693
|
|
|
return $this->init(); |
|
694
|
|
|
} |
|
695
|
|
|
$cache->unlink(); |
|
696
|
|
|
$this->data = array(); |
|
697
|
|
|
} |
|
698
|
|
|
} |
|
699
|
|
|
// Check if the cache has been updated |
|
700
|
|
|
elseif ($cache->mtime() + $this->cache_duration < time()) |
|
701
|
|
|
{ |
|
702
|
|
|
// If we have last-modified and/or etag set |
|
703
|
|
|
if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag'])) |
|
704
|
|
|
{ |
|
705
|
|
|
$headers = array( |
|
706
|
|
|
'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', |
|
707
|
|
|
); |
|
708
|
|
|
if (isset($this->data['headers']['last-modified'])) |
|
709
|
|
|
{ |
|
710
|
|
|
$headers['if-modified-since'] = $this->data['headers']['last-modified']; |
|
711
|
|
|
} |
|
712
|
|
|
if (isset($this->data['headers']['etag'])) |
|
713
|
|
|
{ |
|
714
|
|
|
$headers['if-none-match'] = $this->data['headers']['etag']; |
|
715
|
|
|
} |
|
716
|
|
|
$file = $this->registry->create('File', array($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen)); |
|
717
|
|
|
if ($file->success) |
|
718
|
|
|
{ |
|
719
|
|
|
if ($file->status_code === 304) |
|
720
|
|
|
{ |
|
721
|
|
|
$cache->touch(); |
|
722
|
|
|
return true; |
|
723
|
|
|
} |
|
724
|
|
|
} |
|
725
|
|
|
else |
|
726
|
|
|
{ |
|
727
|
|
|
unset($file); |
|
728
|
|
|
} |
|
729
|
|
|
} |
|
730
|
|
|
} |
|
731
|
|
|
// If the cache is still valid, just return true |
|
732
|
|
|
else |
|
733
|
|
|
{ |
|
734
|
|
|
$this->raw_data = false; |
|
735
|
|
|
return true; |
|
736
|
|
|
} |
|
737
|
|
|
} |
|
738
|
|
|
// If the cache is empty, delete it |
|
739
|
|
|
else |
|
740
|
|
|
{ |
|
741
|
|
|
$cache->unlink(); |
|
742
|
|
|
$this->data = array(); |
|
743
|
|
|
} |
|
744
|
|
|
} |
|
745
|
|
|
// 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. |
|
746
|
|
|
if (!isset($file)) |
|
747
|
|
|
{ |
|
748
|
|
|
if ($this->file instanceof SimplePie_File && $this->file->url === $this->feed_url) |
|
749
|
|
|
{ |
|
750
|
|
|
$file =& $this->file; |
|
751
|
|
|
} |
|
752
|
|
|
else |
|
753
|
|
|
{ |
|
754
|
|
|
$headers = array( |
|
755
|
|
|
'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', |
|
756
|
|
|
); |
|
757
|
|
|
$file = $this->registry->create('File', array($this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen)); |
|
758
|
|
|
} |
|
759
|
|
|
} |
|
760
|
|
|
// If the file connection has an error, set SimplePie::error to that and quit |
|
761
|
|
|
if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) |
|
762
|
|
|
{ |
|
763
|
|
|
$this->error = $file->error; |
|
764
|
|
|
return !empty($this->data); |
|
765
|
|
|
} |
|
766
|
|
|
if (!$this->force_feed) |
|
767
|
|
|
{ |
|
768
|
|
|
// Check if the supplied URL is a feed, if it isn't, look for it. |
|
769
|
|
|
$locate = $this->registry->create('Locator', array(&$file, $this->timeout, $this->useragent, $this->max_checked_feeds)); |
|
770
|
|
|
if (!$locate->is_feed($file)) |
|
771
|
|
|
{ |
|
772
|
|
|
// We need to unset this so that if SimplePie::set_file() has been called that object is untouched |
|
773
|
|
|
unset($file); |
|
774
|
|
|
try |
|
775
|
|
|
{ |
|
776
|
|
|
if (!($file = $locate->find($this->autodiscovery, $this->all_discovered_feeds))) |
|
777
|
|
|
{ |
|
778
|
|
|
$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."; |
|
779
|
|
|
$this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); |
|
780
|
|
|
return false; |
|
781
|
|
|
} |
|
782
|
|
|
} |
|
783
|
|
|
catch (SimplePie_Exception $e) |
|
784
|
|
|
{ |
|
785
|
|
|
// This is usually because DOMDocument doesn't exist |
|
786
|
|
|
$this->error = $e->getMessage(); |
|
787
|
|
|
$this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, $e->getFile(), $e->getLine())); |
|
788
|
|
|
return false; |
|
789
|
|
|
} |
|
790
|
|
|
if ($cache) |
|
791
|
|
|
{ |
|
792
|
|
|
$this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD); |
|
793
|
|
|
if (!$cache->save($this)) |
|
794
|
|
|
{ |
|
795
|
|
|
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); |
|
796
|
|
|
} |
|
797
|
|
|
$cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc')); |
|
798
|
|
|
} |
|
799
|
|
|
$this->feed_url = $file->url; |
|
800
|
|
|
} |
|
801
|
|
|
$locate = null; |
|
802
|
|
|
} |
|
803
|
|
|
$this->raw_data = $file->body; |
|
804
|
|
|
$headers = $file->headers; |
|
805
|
|
|
$sniffer = $this->registry->create('Content_Type_Sniffer', array(&$file)); |
|
806
|
|
|
$sniffed = $sniffer->get_type(); |
|
807
|
|
|
return array($headers, $sniffed); |
|
808
|
|
|
} |
|
809
|
|
|
|
|
810
|
|
|
public function error() |
|
811
|
|
|
{ |
|
812
|
|
|
return $this->error; |
|
813
|
|
|
} |
|
814
|
|
|
|
|
815
|
|
|
public function get_raw_data() |
|
816
|
|
|
{ |
|
817
|
|
|
return $this->raw_data; |
|
818
|
|
|
} |
|
819
|
|
|
|
|
820
|
|
|
public function get_encoding() |
|
821
|
|
|
{ |
|
822
|
|
|
return $this->sanitize->output_encoding; |
|
823
|
|
|
} |
|
824
|
|
|
|
|
825
|
|
|
public function handle_content_type($mime = 'text/html') |
|
826
|
|
|
{ |
|
827
|
|
|
if (!headers_sent()) |
|
828
|
|
|
{ |
|
829
|
|
|
$header = "Content-type: $mime;"; |
|
830
|
|
|
if ($this->get_encoding()) |
|
831
|
|
|
{ |
|
832
|
|
|
$header .= ' charset=' . $this->get_encoding(); |
|
833
|
|
|
} |
|
834
|
|
|
else |
|
835
|
|
|
{ |
|
836
|
|
|
$header .= ' charset=UTF-8'; |
|
837
|
|
|
} |
|
838
|
|
|
header($header); |
|
839
|
|
|
} |
|
840
|
|
|
} |
|
841
|
|
|
|
|
842
|
|
|
public function get_type() |
|
843
|
|
|
{ |
|
844
|
|
|
if (!isset($this->data['type'])) |
|
845
|
|
|
{ |
|
846
|
|
|
$this->data['type'] = SIMPLEPIE_TYPE_ALL; |
|
847
|
|
|
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'])) |
|
848
|
|
|
{ |
|
849
|
|
|
$this->data['type'] &= SIMPLEPIE_TYPE_ATOM_10; |
|
850
|
|
|
} |
|
851
|
|
|
elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'])) |
|
852
|
|
|
{ |
|
853
|
|
|
$this->data['type'] &= SIMPLEPIE_TYPE_ATOM_03; |
|
854
|
|
|
} |
|
855
|
|
|
elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'])) |
|
856
|
|
|
{ |
|
857
|
|
|
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['channel']) |
|
858
|
|
|
|| isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['image']) |
|
859
|
|
|
|| isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']) |
|
860
|
|
|
|| isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['textinput'])) |
|
861
|
|
|
{ |
|
862
|
|
|
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_10; |
|
863
|
|
|
} |
|
864
|
|
|
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['channel']) |
|
865
|
|
|
|| isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['image']) |
|
866
|
|
|
|| isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']) |
|
867
|
|
|
|| isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['textinput'])) |
|
868
|
|
|
{ |
|
869
|
|
|
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_090; |
|
870
|
|
|
} |
|
871
|
|
|
} |
|
872
|
|
|
elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'])) |
|
873
|
|
|
{ |
|
874
|
|
|
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_ALL; |
|
875
|
|
|
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) |
|
876
|
|
|
{ |
|
877
|
|
|
switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) |
|
878
|
|
|
{ |
|
879
|
|
|
case '0.91': |
|
880
|
|
|
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_091; |
|
881
|
|
|
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) |
|
882
|
|
|
{ |
|
883
|
|
|
switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) |
|
884
|
|
|
{ |
|
885
|
|
|
case '0': |
|
886
|
|
|
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE; |
|
887
|
|
|
break; |
|
888
|
|
|
case '24': |
|
889
|
|
|
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_USERLAND; |
|
890
|
|
|
break; |
|
891
|
|
|
} |
|
892
|
|
|
} |
|
893
|
|
|
break; |
|
894
|
|
|
case '0.92': |
|
895
|
|
|
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_092; |
|
896
|
|
|
break; |
|
897
|
|
|
case '0.93': |
|
898
|
|
|
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_093; |
|
899
|
|
|
break; |
|
900
|
|
|
case '0.94': |
|
901
|
|
|
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_094; |
|
902
|
|
|
break; |
|
903
|
|
|
case '2.0': |
|
904
|
|
|
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_20; |
|
905
|
|
|
break; |
|
906
|
|
|
} |
|
907
|
|
|
} |
|
908
|
|
|
} |
|
909
|
|
|
else |
|
910
|
|
|
{ |
|
911
|
|
|
$this->data['type'] = SIMPLEPIE_TYPE_NONE; |
|
912
|
|
|
} |
|
913
|
|
|
} |
|
914
|
|
|
return $this->data['type']; |
|
915
|
|
|
} |
|
916
|
|
|
|
|
917
|
|
|
public function subscribe_url() |
|
918
|
|
|
{ |
|
919
|
|
|
if ($this->feed_url !== null) |
|
920
|
|
|
{ |
|
921
|
|
|
return $this->sanitize($this->feed_url, SIMPLEPIE_CONSTRUCT_IRI); |
|
922
|
|
|
} |
|
923
|
|
|
else |
|
924
|
|
|
{ |
|
925
|
|
|
return null; |
|
926
|
|
|
} |
|
927
|
|
|
} |
|
928
|
|
|
|
|
929
|
|
|
public function get_feed_tags($namespace, $tag) |
|
930
|
|
|
{ |
|
931
|
|
|
$type = $this->get_type(); |
|
932
|
|
|
if ($type & SIMPLEPIE_TYPE_ATOM_10) |
|
933
|
|
|
{ |
|
934
|
|
|
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag])) |
|
935
|
|
|
{ |
|
936
|
|
|
return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag]; |
|
937
|
|
|
} |
|
938
|
|
|
} |
|
939
|
|
|
if ($type & SIMPLEPIE_TYPE_ATOM_03) |
|
940
|
|
|
{ |
|
941
|
|
|
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag])) |
|
942
|
|
|
{ |
|
943
|
|
|
return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag]; |
|
944
|
|
|
} |
|
945
|
|
|
} |
|
946
|
|
|
if ($type & SIMPLEPIE_TYPE_RSS_RDF) |
|
947
|
|
|
{ |
|
948
|
|
|
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag])) |
|
949
|
|
|
{ |
|
950
|
|
|
return $this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag]; |
|
951
|
|
|
} |
|
952
|
|
|
} |
|
953
|
|
|
if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) |
|
954
|
|
|
{ |
|
955
|
|
|
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag])) |
|
956
|
|
|
{ |
|
957
|
|
|
return $this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag]; |
|
958
|
|
|
} |
|
959
|
|
|
} |
|
960
|
|
|
return null; |
|
961
|
|
|
} |
|
962
|
|
|
|
|
963
|
|
|
public function get_channel_tags($namespace, $tag) |
|
964
|
|
|
{ |
|
965
|
|
|
$type = $this->get_type(); |
|
966
|
|
|
if ($type & SIMPLEPIE_TYPE_ATOM_ALL) |
|
967
|
|
|
{ |
|
968
|
|
|
if ($return = $this->get_feed_tags($namespace, $tag)) |
|
969
|
|
|
{ |
|
970
|
|
|
return $return; |
|
971
|
|
|
} |
|
972
|
|
|
} |
|
973
|
|
|
if ($type & SIMPLEPIE_TYPE_RSS_10) |
|
974
|
|
|
{ |
|
975
|
|
|
if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'channel')) |
|
976
|
|
|
{ |
|
977
|
|
|
if (isset($channel[0]['child'][$namespace][$tag])) |
|
978
|
|
|
{ |
|
979
|
|
|
return $channel[0]['child'][$namespace][$tag]; |
|
980
|
|
|
} |
|
981
|
|
|
} |
|
982
|
|
|
} |
|
983
|
|
|
if ($type & SIMPLEPIE_TYPE_RSS_090) |
|
984
|
|
|
{ |
|
985
|
|
|
if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'channel')) |
|
986
|
|
|
{ |
|
987
|
|
|
if (isset($channel[0]['child'][$namespace][$tag])) |
|
988
|
|
|
{ |
|
989
|
|
|
return $channel[0]['child'][$namespace][$tag]; |
|
990
|
|
|
} |
|
991
|
|
|
} |
|
992
|
|
|
} |
|
993
|
|
|
if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) |
|
994
|
|
|
{ |
|
995
|
|
|
if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'channel')) |
|
996
|
|
|
{ |
|
997
|
|
|
if (isset($channel[0]['child'][$namespace][$tag])) |
|
998
|
|
|
{ |
|
999
|
|
|
return $channel[0]['child'][$namespace][$tag]; |
|
1000
|
|
|
} |
|
1001
|
|
|
} |
|
1002
|
|
|
} |
|
1003
|
|
|
return null; |
|
1004
|
|
|
} |
|
1005
|
|
|
|
|
1006
|
|
|
public function get_image_tags($namespace, $tag) |
|
1007
|
|
|
{ |
|
1008
|
|
|
$type = $this->get_type(); |
|
1009
|
|
|
if ($type & SIMPLEPIE_TYPE_RSS_10) |
|
1010
|
|
|
{ |
|
1011
|
|
|
if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'image')) |
|
1012
|
|
|
{ |
|
1013
|
|
|
if (isset($image[0]['child'][$namespace][$tag])) |
|
1014
|
|
|
{ |
|
1015
|
|
|
return $image[0]['child'][$namespace][$tag]; |
|
1016
|
|
|
} |
|
1017
|
|
|
} |
|
1018
|
|
|
} |
|
1019
|
|
|
if ($type & SIMPLEPIE_TYPE_RSS_090) |
|
1020
|
|
|
{ |
|
1021
|
|
|
if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'image')) |
|
1022
|
|
|
{ |
|
1023
|
|
|
if (isset($image[0]['child'][$namespace][$tag])) |
|
1024
|
|
|
{ |
|
1025
|
|
|
return $image[0]['child'][$namespace][$tag]; |
|
1026
|
|
|
} |
|
1027
|
|
|
} |
|
1028
|
|
|
} |
|
1029
|
|
|
if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) |
|
1030
|
|
|
{ |
|
1031
|
|
|
if ($image = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'image')) |
|
1032
|
|
|
{ |
|
1033
|
|
|
if (isset($image[0]['child'][$namespace][$tag])) |
|
1034
|
|
|
{ |
|
1035
|
|
|
return $image[0]['child'][$namespace][$tag]; |
|
1036
|
|
|
} |
|
1037
|
|
|
} |
|
1038
|
|
|
} |
|
1039
|
|
|
return null; |
|
1040
|
|
|
} |
|
1041
|
|
|
|
|
1042
|
|
|
public function get_base($element = array()) |
|
1043
|
|
|
{ |
|
1044
|
|
|
if (!($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION) && !empty($element['xml_base_explicit']) && isset($element['xml_base'])) |
|
1045
|
|
|
{ |
|
1046
|
|
|
return $element['xml_base']; |
|
1047
|
|
|
} |
|
1048
|
|
|
elseif ($this->get_link() !== null) |
|
1049
|
|
|
{ |
|
1050
|
|
|
return $this->get_link(); |
|
1051
|
|
|
} |
|
1052
|
|
|
else |
|
1053
|
|
|
{ |
|
1054
|
|
|
return $this->subscribe_url(); |
|
1055
|
|
|
} |
|
1056
|
|
|
} |
|
1057
|
|
|
|
|
1058
|
|
|
public function sanitize($data, $type, $base = '') |
|
1059
|
|
|
{ |
|
1060
|
|
|
return $this->sanitize->sanitize($data, $type, $base); |
|
1061
|
|
|
} |
|
1062
|
|
|
|
|
1063
|
|
|
public function get_title() |
|
1064
|
|
|
{ |
|
1065
|
|
|
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) |
|
1066
|
|
|
{ |
|
1067
|
|
|
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
1068
|
|
|
} |
|
1069
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) |
|
1070
|
|
|
{ |
|
1071
|
|
|
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
1072
|
|
|
} |
|
1073
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) |
|
1074
|
|
|
{ |
|
1075
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
1076
|
|
|
} |
|
1077
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) |
|
1078
|
|
|
{ |
|
1079
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
1080
|
|
|
} |
|
1081
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) |
|
1082
|
|
|
{ |
|
1083
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
1084
|
|
|
} |
|
1085
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) |
|
1086
|
|
|
{ |
|
1087
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1088
|
|
|
} |
|
1089
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) |
|
1090
|
|
|
{ |
|
1091
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1092
|
|
|
} |
|
1093
|
|
|
else |
|
1094
|
|
|
{ |
|
1095
|
|
|
return null; |
|
1096
|
|
|
} |
|
1097
|
|
|
} |
|
1098
|
|
|
|
|
1099
|
|
|
public function get_category($key = 0) |
|
1100
|
|
|
{ |
|
1101
|
|
|
$categories = $this->get_categories(); |
|
1102
|
|
|
if (isset($categories[$key])) |
|
1103
|
|
|
{ |
|
1104
|
|
|
return $categories[$key]; |
|
1105
|
|
|
} |
|
1106
|
|
|
else |
|
1107
|
|
|
{ |
|
1108
|
|
|
return null; |
|
1109
|
|
|
} |
|
1110
|
|
|
} |
|
1111
|
|
|
|
|
1112
|
|
|
public function get_categories() |
|
1113
|
|
|
{ |
|
1114
|
|
|
$categories = array(); |
|
1115
|
|
|
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) |
|
1116
|
|
|
{ |
|
1117
|
|
|
$term = null; |
|
1118
|
|
|
$scheme = null; |
|
1119
|
|
|
$label = null; |
|
1120
|
|
|
if (isset($category['attribs']['']['term'])) |
|
1121
|
|
|
{ |
|
1122
|
|
|
$term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1123
|
|
|
} |
|
1124
|
|
|
if (isset($category['attribs']['']['scheme'])) |
|
1125
|
|
|
{ |
|
1126
|
|
|
$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1127
|
|
|
} |
|
1128
|
|
|
if (isset($category['attribs']['']['label'])) |
|
1129
|
|
|
{ |
|
1130
|
|
|
$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1131
|
|
|
} |
|
1132
|
|
|
$categories[] = $this->registry->create('Category', array($term, $scheme, $label)); |
|
1133
|
|
|
} |
|
1134
|
|
|
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) |
|
1135
|
|
|
{ |
|
1136
|
|
|
// This is really the label, but keep this as the term also for BC. |
|
1137
|
|
|
// Label will also work on retrieving because that falls back to term. |
|
1138
|
|
|
$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1139
|
|
|
if (isset($category['attribs']['']['domain'])) |
|
1140
|
|
|
{ |
|
1141
|
|
|
$scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1142
|
|
|
} |
|
1143
|
|
|
else |
|
1144
|
|
|
{ |
|
1145
|
|
|
$scheme = null; |
|
1146
|
|
|
} |
|
1147
|
|
|
$categories[] = $this->registry->create('Category', array($term, $scheme, null)); |
|
1148
|
|
|
} |
|
1149
|
|
|
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) |
|
1150
|
|
|
{ |
|
1151
|
|
|
$categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
|
1152
|
|
|
} |
|
1153
|
|
|
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) |
|
1154
|
|
|
{ |
|
1155
|
|
|
$categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
|
1156
|
|
|
} |
|
1157
|
|
|
if (!empty($categories)) |
|
1158
|
|
|
{ |
|
1159
|
|
|
return array_unique($categories); |
|
1160
|
|
|
} |
|
1161
|
|
|
else |
|
1162
|
|
|
{ |
|
1163
|
|
|
return null; |
|
1164
|
|
|
} |
|
1165
|
|
|
} |
|
1166
|
|
|
|
|
1167
|
|
|
public function get_author($key = 0) |
|
1168
|
|
|
{ |
|
1169
|
|
|
$authors = $this->get_authors(); |
|
1170
|
|
|
if (isset($authors[$key])) |
|
1171
|
|
|
{ |
|
1172
|
|
|
return $authors[$key]; |
|
1173
|
|
|
} |
|
1174
|
|
|
else |
|
1175
|
|
|
{ |
|
1176
|
|
|
return null; |
|
1177
|
|
|
} |
|
1178
|
|
|
} |
|
1179
|
|
|
|
|
1180
|
|
|
public function get_authors() |
|
1181
|
|
|
{ |
|
1182
|
|
|
$authors = array(); |
|
1183
|
|
|
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) |
|
1184
|
|
|
{ |
|
1185
|
|
|
$name = null; |
|
1186
|
|
|
$uri = null; |
|
1187
|
|
|
$email = null; |
|
1188
|
|
|
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) |
|
1189
|
|
|
{ |
|
1190
|
|
|
$name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1191
|
|
|
} |
|
1192
|
|
|
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) |
|
1193
|
|
|
{ |
|
1194
|
|
|
$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])); |
|
1195
|
|
|
} |
|
1196
|
|
|
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) |
|
1197
|
|
|
{ |
|
1198
|
|
|
$email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1199
|
|
|
} |
|
1200
|
|
|
if ($name !== null || $email !== null || $uri !== null) |
|
1201
|
|
|
{ |
|
1202
|
|
|
$authors[] = $this->registry->create('Author', array($name, $uri, $email)); |
|
1203
|
|
|
} |
|
1204
|
|
|
} |
|
1205
|
|
|
if ($author = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) |
|
1206
|
|
|
{ |
|
1207
|
|
|
$name = null; |
|
1208
|
|
|
$url = null; |
|
1209
|
|
|
$email = null; |
|
1210
|
|
|
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) |
|
1211
|
|
|
{ |
|
1212
|
|
|
$name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1213
|
|
|
} |
|
1214
|
|
|
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) |
|
1215
|
|
|
{ |
|
1216
|
|
|
$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])); |
|
1217
|
|
|
} |
|
1218
|
|
|
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) |
|
1219
|
|
|
{ |
|
1220
|
|
|
$email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1221
|
|
|
} |
|
1222
|
|
|
if ($name !== null || $email !== null || $url !== null) |
|
1223
|
|
|
{ |
|
1224
|
|
|
$authors[] = $this->registry->create('Author', array($name, $url, $email)); |
|
1225
|
|
|
} |
|
1226
|
|
|
} |
|
1227
|
|
|
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) |
|
1228
|
|
|
{ |
|
1229
|
|
|
$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
|
1230
|
|
|
} |
|
1231
|
|
|
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) |
|
1232
|
|
|
{ |
|
1233
|
|
|
$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
|
1234
|
|
|
} |
|
1235
|
|
|
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) |
|
1236
|
|
|
{ |
|
1237
|
|
|
$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
|
1238
|
|
|
} |
|
1239
|
|
|
if (!empty($authors)) |
|
1240
|
|
|
{ |
|
1241
|
|
|
return array_unique($authors); |
|
1242
|
|
|
} |
|
1243
|
|
|
else |
|
1244
|
|
|
{ |
|
1245
|
|
|
return null; |
|
1246
|
|
|
} |
|
1247
|
|
|
} |
|
1248
|
|
|
|
|
1249
|
|
|
public function get_contributor($key = 0) |
|
1250
|
|
|
{ |
|
1251
|
|
|
$contributors = $this->get_contributors(); |
|
1252
|
|
|
if (isset($contributors[$key])) |
|
1253
|
|
|
{ |
|
1254
|
|
|
return $contributors[$key]; |
|
1255
|
|
|
} |
|
1256
|
|
|
else |
|
1257
|
|
|
{ |
|
1258
|
|
|
return null; |
|
1259
|
|
|
} |
|
1260
|
|
|
} |
|
1261
|
|
|
|
|
1262
|
|
|
public function get_contributors() |
|
1263
|
|
|
{ |
|
1264
|
|
|
$contributors = array(); |
|
1265
|
|
|
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) |
|
1266
|
|
|
{ |
|
1267
|
|
|
$name = null; |
|
1268
|
|
|
$uri = null; |
|
1269
|
|
|
$email = null; |
|
1270
|
|
|
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) |
|
1271
|
|
|
{ |
|
1272
|
|
|
$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1273
|
|
|
} |
|
1274
|
|
|
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) |
|
1275
|
|
|
{ |
|
1276
|
|
|
$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])); |
|
1277
|
|
|
} |
|
1278
|
|
|
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) |
|
1279
|
|
|
{ |
|
1280
|
|
|
$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1281
|
|
|
} |
|
1282
|
|
|
if ($name !== null || $email !== null || $uri !== null) |
|
1283
|
|
|
{ |
|
1284
|
|
|
$contributors[] = $this->registry->create('Author', array($name, $uri, $email)); |
|
1285
|
|
|
} |
|
1286
|
|
|
} |
|
1287
|
|
|
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) |
|
1288
|
|
|
{ |
|
1289
|
|
|
$name = null; |
|
1290
|
|
|
$url = null; |
|
1291
|
|
|
$email = null; |
|
1292
|
|
|
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) |
|
1293
|
|
|
{ |
|
1294
|
|
|
$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1295
|
|
|
} |
|
1296
|
|
|
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) |
|
1297
|
|
|
{ |
|
1298
|
|
|
$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])); |
|
1299
|
|
|
} |
|
1300
|
|
|
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) |
|
1301
|
|
|
{ |
|
1302
|
|
|
$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1303
|
|
|
} |
|
1304
|
|
|
if ($name !== null || $email !== null || $url !== null) |
|
1305
|
|
|
{ |
|
1306
|
|
|
$contributors[] = $this->registry->create('Author', array($name, $url, $email)); |
|
1307
|
|
|
} |
|
1308
|
|
|
} |
|
1309
|
|
|
if (!empty($contributors)) |
|
1310
|
|
|
{ |
|
1311
|
|
|
return array_unique($contributors); |
|
1312
|
|
|
} |
|
1313
|
|
|
else |
|
1314
|
|
|
{ |
|
1315
|
|
|
return null; |
|
1316
|
|
|
} |
|
1317
|
|
|
} |
|
1318
|
|
|
|
|
1319
|
|
|
public function get_link($key = 0, $rel = 'alternate') |
|
1320
|
|
|
{ |
|
1321
|
|
|
$links = $this->get_links($rel); |
|
1322
|
|
|
if (isset($links[$key])) |
|
1323
|
|
|
{ |
|
1324
|
|
|
return $links[$key]; |
|
1325
|
|
|
} |
|
1326
|
|
|
else |
|
1327
|
|
|
{ |
|
1328
|
|
|
return null; |
|
1329
|
|
|
} |
|
1330
|
|
|
} |
|
1331
|
|
|
|
|
1332
|
|
|
public function get_permalink() |
|
1333
|
|
|
{ |
|
1334
|
|
|
return $this->get_link(0); |
|
1335
|
|
|
} |
|
1336
|
|
|
|
|
1337
|
|
|
public function get_links($rel = 'alternate') |
|
1338
|
|
|
{ |
|
1339
|
|
|
if (!isset($this->data['links'])) |
|
1340
|
|
|
{ |
|
1341
|
|
|
$this->data['links'] = array(); |
|
1342
|
|
|
if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link')) |
|
1343
|
|
|
{ |
|
1344
|
|
|
foreach ($links as $link) |
|
1345
|
|
|
{ |
|
1346
|
|
|
if (isset($link['attribs']['']['href'])) |
|
1347
|
|
|
{ |
|
1348
|
|
|
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; |
|
1349
|
|
|
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); |
|
1350
|
|
|
} |
|
1351
|
|
|
} |
|
1352
|
|
|
} |
|
1353
|
|
|
if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link')) |
|
1354
|
|
|
{ |
|
1355
|
|
|
foreach ($links as $link) |
|
1356
|
|
|
{ |
|
1357
|
|
|
if (isset($link['attribs']['']['href'])) |
|
1358
|
|
|
{ |
|
1359
|
|
|
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; |
|
1360
|
|
|
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); |
|
1361
|
|
|
} |
|
1362
|
|
|
} |
|
1363
|
|
|
} |
|
1364
|
|
|
if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) |
|
1365
|
|
|
{ |
|
1366
|
|
|
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); |
|
1367
|
|
|
} |
|
1368
|
|
|
if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) |
|
1369
|
|
|
{ |
|
1370
|
|
|
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); |
|
1371
|
|
|
} |
|
1372
|
|
|
if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) |
|
1373
|
|
|
{ |
|
1374
|
|
|
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); |
|
1375
|
|
|
} |
|
1376
|
|
|
$keys = array_keys($this->data['links']); |
|
1377
|
|
|
foreach ($keys as $key) |
|
1378
|
|
|
{ |
|
1379
|
|
|
if ($this->registry->call('Misc', 'is_isegment_nz_nc', array($key))) |
|
1380
|
|
|
{ |
|
1381
|
|
|
if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) |
|
1382
|
|
|
{ |
|
1383
|
|
|
$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); |
|
1384
|
|
|
$this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; |
|
1385
|
|
|
} |
|
1386
|
|
|
else |
|
1387
|
|
|
{ |
|
1388
|
|
|
$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; |
|
1389
|
|
|
} |
|
1390
|
|
|
} |
|
1391
|
|
|
elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) |
|
1392
|
|
|
{ |
|
1393
|
|
|
$this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; |
|
1394
|
|
|
} |
|
1395
|
|
|
$this->data['links'][$key] = array_unique($this->data['links'][$key]); |
|
1396
|
|
|
} |
|
1397
|
|
|
} |
|
1398
|
|
|
if (isset($this->data['links'][$rel])) |
|
1399
|
|
|
{ |
|
1400
|
|
|
return $this->data['links'][$rel]; |
|
1401
|
|
|
} |
|
1402
|
|
|
else |
|
1403
|
|
|
{ |
|
1404
|
|
|
return null; |
|
1405
|
|
|
} |
|
1406
|
|
|
} |
|
1407
|
|
|
public function get_all_discovered_feeds() |
|
1408
|
|
|
{ |
|
1409
|
|
|
return $this->all_discovered_feeds; |
|
1410
|
|
|
} |
|
1411
|
|
|
|
|
1412
|
|
|
public function get_description() |
|
1413
|
|
|
{ |
|
1414
|
|
|
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) |
|
1415
|
|
|
{ |
|
1416
|
|
|
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
1417
|
|
|
} |
|
1418
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline')) |
|
1419
|
|
|
{ |
|
1420
|
|
|
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
1421
|
|
|
} |
|
1422
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) |
|
1423
|
|
|
{ |
|
1424
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
1425
|
|
|
} |
|
1426
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) |
|
1427
|
|
|
{ |
|
1428
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
1429
|
|
|
} |
|
1430
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) |
|
1431
|
|
|
{ |
|
1432
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
|
1433
|
|
|
} |
|
1434
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) |
|
1435
|
|
|
{ |
|
1436
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1437
|
|
|
} |
|
1438
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) |
|
1439
|
|
|
{ |
|
1440
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1441
|
|
|
} |
|
1442
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) |
|
1443
|
|
|
{ |
|
1444
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
|
1445
|
|
|
} |
|
1446
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) |
|
1447
|
|
|
{ |
|
1448
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
|
1449
|
|
|
} |
|
1450
|
|
|
else |
|
1451
|
|
|
{ |
|
1452
|
|
|
return null; |
|
1453
|
|
|
} |
|
1454
|
|
|
} |
|
1455
|
|
|
|
|
1456
|
|
|
public function get_copyright() |
|
1457
|
|
|
{ |
|
1458
|
|
|
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) |
|
1459
|
|
|
{ |
|
1460
|
|
|
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
1461
|
|
|
} |
|
1462
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright')) |
|
1463
|
|
|
{ |
|
1464
|
|
|
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
1465
|
|
|
} |
|
1466
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright')) |
|
1467
|
|
|
{ |
|
1468
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1469
|
|
|
} |
|
1470
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) |
|
1471
|
|
|
{ |
|
1472
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1473
|
|
|
} |
|
1474
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) |
|
1475
|
|
|
{ |
|
1476
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1477
|
|
|
} |
|
1478
|
|
|
else |
|
1479
|
|
|
{ |
|
1480
|
|
|
return null; |
|
1481
|
|
|
} |
|
1482
|
|
|
} |
|
1483
|
|
|
|
|
1484
|
|
|
public function get_language() |
|
1485
|
|
|
{ |
|
1486
|
|
|
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) |
|
1487
|
|
|
{ |
|
1488
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1489
|
|
|
} |
|
1490
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language')) |
|
1491
|
|
|
{ |
|
1492
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1493
|
|
|
} |
|
1494
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language')) |
|
1495
|
|
|
{ |
|
1496
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1497
|
|
|
} |
|
1498
|
|
|
elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'])) |
|
1499
|
|
|
{ |
|
1500
|
|
|
return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1501
|
|
|
} |
|
1502
|
|
|
elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'])) |
|
1503
|
|
|
{ |
|
1504
|
|
|
return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1505
|
|
|
} |
|
1506
|
|
|
elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'])) |
|
1507
|
|
|
{ |
|
1508
|
|
|
return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1509
|
|
|
} |
|
1510
|
|
|
elseif (isset($this->data['headers']['content-language'])) |
|
1511
|
|
|
{ |
|
1512
|
|
|
return $this->sanitize($this->data['headers']['content-language'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1513
|
|
|
} |
|
1514
|
|
|
else |
|
1515
|
|
|
{ |
|
1516
|
|
|
return null; |
|
1517
|
|
|
} |
|
1518
|
|
|
} |
|
1519
|
|
|
|
|
1520
|
|
|
public function get_latitude() |
|
1521
|
|
|
{ |
|
1522
|
|
|
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) |
|
1523
|
|
|
{ |
|
1524
|
|
|
return (float) $return[0]['data']; |
|
1525
|
|
|
} |
|
1526
|
|
|
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)) |
|
1527
|
|
|
{ |
|
1528
|
|
|
return (float) $match[1]; |
|
1529
|
|
|
} |
|
1530
|
|
|
else |
|
1531
|
|
|
{ |
|
1532
|
|
|
return null; |
|
1533
|
|
|
} |
|
1534
|
|
|
} |
|
1535
|
|
|
|
|
1536
|
|
|
public function get_longitude() |
|
1537
|
|
|
{ |
|
1538
|
|
|
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) |
|
1539
|
|
|
{ |
|
1540
|
|
|
return (float) $return[0]['data']; |
|
1541
|
|
|
} |
|
1542
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) |
|
1543
|
|
|
{ |
|
1544
|
|
|
return (float) $return[0]['data']; |
|
1545
|
|
|
} |
|
1546
|
|
|
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)) |
|
1547
|
|
|
{ |
|
1548
|
|
|
return (float) $match[2]; |
|
1549
|
|
|
} |
|
1550
|
|
|
else |
|
1551
|
|
|
{ |
|
1552
|
|
|
return null; |
|
1553
|
|
|
} |
|
1554
|
|
|
} |
|
1555
|
|
|
|
|
1556
|
|
|
public function get_image_title() |
|
1557
|
|
|
{ |
|
1558
|
|
|
if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) |
|
1559
|
|
|
{ |
|
1560
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1561
|
|
|
} |
|
1562
|
|
|
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) |
|
1563
|
|
|
{ |
|
1564
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1565
|
|
|
} |
|
1566
|
|
|
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) |
|
1567
|
|
|
{ |
|
1568
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1569
|
|
|
} |
|
1570
|
|
|
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) |
|
1571
|
|
|
{ |
|
1572
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1573
|
|
|
} |
|
1574
|
|
|
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) |
|
1575
|
|
|
{ |
|
1576
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
1577
|
|
|
} |
|
1578
|
|
|
else |
|
1579
|
|
|
{ |
|
1580
|
|
|
return null; |
|
1581
|
|
|
} |
|
1582
|
|
|
} |
|
1583
|
|
|
|
|
1584
|
|
|
public function get_image_url() |
|
1585
|
|
|
{ |
|
1586
|
|
|
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) |
|
1587
|
|
|
{ |
|
1588
|
|
|
return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI); |
|
1589
|
|
|
} |
|
1590
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo')) |
|
1591
|
|
|
{ |
|
1592
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
|
1593
|
|
|
} |
|
1594
|
|
|
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) |
|
1595
|
|
|
{ |
|
1596
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
|
1597
|
|
|
} |
|
1598
|
|
|
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'url')) |
|
1599
|
|
|
{ |
|
1600
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
|
1601
|
|
|
} |
|
1602
|
|
|
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'url')) |
|
1603
|
|
|
{ |
|
1604
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
|
1605
|
|
|
} |
|
1606
|
|
|
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) |
|
1607
|
|
|
{ |
|
1608
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
|
1609
|
|
|
} |
|
1610
|
|
|
else |
|
1611
|
|
|
{ |
|
1612
|
|
|
return null; |
|
1613
|
|
|
} |
|
1614
|
|
|
} |
|
1615
|
|
|
|
|
1616
|
|
|
public function get_image_link() |
|
1617
|
|
|
{ |
|
1618
|
|
|
if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) |
|
1619
|
|
|
{ |
|
1620
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
|
1621
|
|
|
} |
|
1622
|
|
|
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) |
|
1623
|
|
|
{ |
|
1624
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
|
1625
|
|
|
} |
|
1626
|
|
|
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) |
|
1627
|
|
|
{ |
|
1628
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
|
1629
|
|
|
} |
|
1630
|
|
|
else |
|
1631
|
|
|
{ |
|
1632
|
|
|
return null; |
|
1633
|
|
|
} |
|
1634
|
|
|
} |
|
1635
|
|
|
|
|
1636
|
|
|
public function get_image_width() |
|
1637
|
|
|
{ |
|
1638
|
|
|
if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'width')) |
|
1639
|
|
|
{ |
|
1640
|
|
|
return round($return[0]['data']); |
|
1641
|
|
|
} |
|
1642
|
|
|
elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) |
|
1643
|
|
|
{ |
|
1644
|
|
|
return 88.0; |
|
1645
|
|
|
} |
|
1646
|
|
|
else |
|
1647
|
|
|
{ |
|
1648
|
|
|
return null; |
|
1649
|
|
|
} |
|
1650
|
|
|
} |
|
1651
|
|
|
|
|
1652
|
|
|
public function get_image_height() |
|
1653
|
|
|
{ |
|
1654
|
|
|
if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'height')) |
|
1655
|
|
|
{ |
|
1656
|
|
|
return round($return[0]['data']); |
|
1657
|
|
|
} |
|
1658
|
|
|
elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) |
|
1659
|
|
|
{ |
|
1660
|
|
|
return 31.0; |
|
1661
|
|
|
} |
|
1662
|
|
|
else |
|
1663
|
|
|
{ |
|
1664
|
|
|
return null; |
|
1665
|
|
|
} |
|
1666
|
|
|
} |
|
1667
|
|
|
|
|
1668
|
|
|
public function get_item_quantity($max = 0) |
|
1669
|
|
|
{ |
|
1670
|
|
|
$max = (int) $max; |
|
1671
|
|
|
$qty = count($this->get_items()); |
|
1672
|
|
|
if ($max === 0) |
|
1673
|
|
|
{ |
|
1674
|
|
|
return $qty; |
|
1675
|
|
|
} |
|
1676
|
|
|
else |
|
1677
|
|
|
{ |
|
1678
|
|
|
return ($qty > $max) ? $max : $qty; |
|
1679
|
|
|
} |
|
1680
|
|
|
} |
|
1681
|
|
|
|
|
1682
|
|
|
public function get_item($key = 0) |
|
1683
|
|
|
{ |
|
1684
|
|
|
$items = $this->get_items(); |
|
1685
|
|
|
if (isset($items[$key])) |
|
1686
|
|
|
{ |
|
1687
|
|
|
return $items[$key]; |
|
1688
|
|
|
} |
|
1689
|
|
|
else |
|
1690
|
|
|
{ |
|
1691
|
|
|
return null; |
|
1692
|
|
|
} |
|
1693
|
|
|
} |
|
1694
|
|
|
|
|
1695
|
|
|
public function get_items($start = 0, $end = 0) |
|
1696
|
|
|
{ |
|
1697
|
|
|
if (!isset($this->data['items'])) |
|
1698
|
|
|
{ |
|
1699
|
|
|
if (!empty($this->multifeed_objects)) |
|
1700
|
|
|
{ |
|
1701
|
|
|
$this->data['items'] = SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit); |
|
1702
|
|
|
} |
|
1703
|
|
|
else |
|
1704
|
|
|
{ |
|
1705
|
|
|
$this->data['items'] = array(); |
|
1706
|
|
|
if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry')) |
|
1707
|
|
|
{ |
|
1708
|
|
|
$keys = array_keys($items); |
|
1709
|
|
|
foreach ($keys as $key) |
|
1710
|
|
|
{ |
|
1711
|
|
|
$this->data['items'][] = $this->registry->create('Item', array($this, $items[$key])); |
|
1712
|
|
|
} |
|
1713
|
|
|
} |
|
1714
|
|
|
if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry')) |
|
1715
|
|
|
{ |
|
1716
|
|
|
$keys = array_keys($items); |
|
1717
|
|
|
foreach ($keys as $key) |
|
1718
|
|
|
{ |
|
1719
|
|
|
$this->data['items'][] = $this->registry->create('Item', array($this, $items[$key])); |
|
1720
|
|
|
} |
|
1721
|
|
|
} |
|
1722
|
|
|
if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item')) |
|
1723
|
|
|
{ |
|
1724
|
|
|
$keys = array_keys($items); |
|
1725
|
|
|
foreach ($keys as $key) |
|
1726
|
|
|
{ |
|
1727
|
|
|
$this->data['items'][] = $this->registry->create('Item', array($this, $items[$key])); |
|
1728
|
|
|
} |
|
1729
|
|
|
} |
|
1730
|
|
|
if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item')) |
|
1731
|
|
|
{ |
|
1732
|
|
|
$keys = array_keys($items); |
|
1733
|
|
|
foreach ($keys as $key) |
|
1734
|
|
|
{ |
|
1735
|
|
|
$this->data['items'][] = $this->registry->create('Item', array($this, $items[$key])); |
|
1736
|
|
|
} |
|
1737
|
|
|
} |
|
1738
|
|
|
if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item')) |
|
1739
|
|
|
{ |
|
1740
|
|
|
$keys = array_keys($items); |
|
1741
|
|
|
foreach ($keys as $key) |
|
1742
|
|
|
{ |
|
1743
|
|
|
$this->data['items'][] = $this->registry->create('Item', array($this, $items[$key])); |
|
1744
|
|
|
} |
|
1745
|
|
|
} |
|
1746
|
|
|
} |
|
1747
|
|
|
} |
|
1748
|
|
|
if (!empty($this->data['items'])) |
|
1749
|
|
|
{ |
|
1750
|
|
|
// If we want to order it by date, check if all items have a date, and then sort it |
|
1751
|
|
|
if ($this->order_by_date && empty($this->multifeed_objects)) |
|
1752
|
|
|
{ |
|
1753
|
|
|
if (!isset($this->data['ordered_items'])) |
|
1754
|
|
|
{ |
|
1755
|
|
|
$do_sort = true; |
|
1756
|
|
|
foreach ($this->data['items'] as $item) |
|
1757
|
|
|
{ |
|
1758
|
|
|
if (!$item->get_date('U')) |
|
1759
|
|
|
{ |
|
1760
|
|
|
$do_sort = false; |
|
1761
|
|
|
break; |
|
1762
|
|
|
} |
|
1763
|
|
|
} |
|
1764
|
|
|
$item = null; |
|
1765
|
|
|
$this->data['ordered_items'] = $this->data['items']; |
|
1766
|
|
|
if ($do_sort) |
|
1767
|
|
|
{ |
|
1768
|
|
|
usort($this->data['ordered_items'], array(get_class($this), 'sort_items')); |
|
1769
|
|
|
} |
|
1770
|
|
|
} |
|
1771
|
|
|
$items = $this->data['ordered_items']; |
|
1772
|
|
|
} |
|
1773
|
|
|
else |
|
1774
|
|
|
{ |
|
1775
|
|
|
$items = $this->data['items']; |
|
1776
|
|
|
} |
|
1777
|
|
|
// Slice the data as desired |
|
1778
|
|
|
if ($end === 0) |
|
1779
|
|
|
{ |
|
1780
|
|
|
return array_slice($items, $start); |
|
1781
|
|
|
} |
|
1782
|
|
|
else |
|
1783
|
|
|
{ |
|
1784
|
|
|
return array_slice($items, $start, $end); |
|
1785
|
|
|
} |
|
1786
|
|
|
} |
|
1787
|
|
|
else |
|
1788
|
|
|
{ |
|
1789
|
|
|
return array(); |
|
1790
|
|
|
} |
|
1791
|
|
|
} |
|
1792
|
|
|
|
|
1793
|
|
|
public function set_favicon_handler($page = false, $qs = 'i') |
|
1794
|
|
|
{ |
|
1795
|
|
|
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; |
|
1796
|
|
|
trigger_error('Favicon handling has been removed, please use your own handling', $level); |
|
1797
|
|
|
return false; |
|
1798
|
|
|
} |
|
1799
|
|
|
|
|
1800
|
|
|
public function get_favicon() |
|
1801
|
|
|
{ |
|
1802
|
|
|
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; |
|
1803
|
|
|
trigger_error('Favicon handling has been removed, please use your own handling', $level); |
|
1804
|
|
|
if (($url = $this->get_link()) !== null) |
|
1805
|
|
|
{ |
|
1806
|
|
|
return 'http://g.etfv.co/' . urlencode($url); |
|
1807
|
|
|
} |
|
1808
|
|
|
return false; |
|
1809
|
|
|
} |
|
1810
|
|
|
|
|
1811
|
|
|
public function __call($method, $args) |
|
1812
|
|
|
{ |
|
1813
|
|
|
if (strpos($method, 'subscribe_') === 0) |
|
1814
|
|
|
{ |
|
1815
|
|
|
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; |
|
1816
|
|
|
trigger_error('subscribe_*() has been deprecated, implement the callback yourself', $level); |
|
1817
|
|
|
return ''; |
|
1818
|
|
|
} |
|
1819
|
|
|
if ($method === 'enable_xml_dump') |
|
1820
|
|
|
{ |
|
1821
|
|
|
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; |
|
1822
|
|
|
trigger_error('enable_xml_dump() has been deprecated, use get_raw_data() instead', $level); |
|
1823
|
|
|
return false; |
|
1824
|
|
|
} |
|
1825
|
|
|
$class = get_class($this); |
|
1826
|
|
|
$trace = debug_backtrace(); |
|
1827
|
|
|
$file = $trace[0]['file']; |
|
1828
|
|
|
$line = $trace[0]['line']; |
|
1829
|
|
|
trigger_error("Call to undefined method $class::$method() in $file on line $line", E_USER_ERROR); |
|
1830
|
|
|
} |
|
1831
|
|
|
|
|
1832
|
|
|
public static function sort_items($a, $b) |
|
1833
|
|
|
{ |
|
1834
|
|
|
return $a->get_date('U') <= $b->get_date('U'); |
|
1835
|
|
|
} |
|
1836
|
|
|
|
|
1837
|
|
|
public static function merge_items($urls, $start = 0, $end = 0, $limit = 0) |
|
1838
|
|
|
{ |
|
1839
|
|
|
if (is_array($urls) && sizeof($urls) > 0) |
|
1840
|
|
|
{ |
|
1841
|
|
|
$items = array(); |
|
1842
|
|
|
foreach ($urls as $arg) |
|
1843
|
|
|
{ |
|
1844
|
|
|
if ($arg instanceof SimplePie) |
|
1845
|
|
|
{ |
|
1846
|
|
|
$items = array_merge($items, $arg->get_items(0, $limit)); |
|
1847
|
|
|
} |
|
1848
|
|
|
else |
|
1849
|
|
|
{ |
|
1850
|
|
|
trigger_error('Arguments must be SimplePie objects', E_USER_WARNING); |
|
1851
|
|
|
} |
|
1852
|
|
|
} |
|
1853
|
|
|
$do_sort = true; |
|
1854
|
|
|
foreach ($items as $item) |
|
1855
|
|
|
{ |
|
1856
|
|
|
if (!$item->get_date('U')) |
|
1857
|
|
|
{ |
|
1858
|
|
|
$do_sort = false; |
|
1859
|
|
|
break; |
|
1860
|
|
|
} |
|
1861
|
|
|
} |
|
1862
|
|
|
$item = null; |
|
1863
|
|
|
if ($do_sort) |
|
1864
|
|
|
{ |
|
1865
|
|
|
usort($items, array(get_class($urls[0]), 'sort_items')); |
|
1866
|
|
|
} |
|
1867
|
|
|
if ($end === 0) |
|
1868
|
|
|
{ |
|
1869
|
|
|
return array_slice($items, $start); |
|
1870
|
|
|
} |
|
1871
|
|
|
else |
|
1872
|
|
|
{ |
|
1873
|
|
|
return array_slice($items, $start, $end); |
|
1874
|
|
|
} |
|
1875
|
|
|
} |
|
1876
|
|
|
else |
|
1877
|
|
|
{ |
|
1878
|
|
|
trigger_error('Cannot merge zero SimplePie objects', E_USER_WARNING); |
|
1879
|
|
|
return array(); |
|
1880
|
|
|
} |
|
1881
|
|
|
} |
|
1882
|
|
|
} |
|
1883
|
|
|
class SimplePie_Author |
|
1884
|
|
|
{ |
|
1885
|
|
|
|
|
1886
|
|
|
var $name; |
|
1887
|
|
|
|
|
1888
|
|
|
var $link; |
|
1889
|
|
|
|
|
1890
|
|
|
var $email; |
|
1891
|
|
|
|
|
1892
|
|
|
public function __construct($name = null, $link = null, $email = null) |
|
1893
|
|
|
{ |
|
1894
|
|
|
$this->name = $name; |
|
1895
|
|
|
$this->link = $link; |
|
1896
|
|
|
$this->email = $email; |
|
1897
|
|
|
} |
|
1898
|
|
|
|
|
1899
|
|
|
public function __toString() |
|
1900
|
|
|
{ |
|
1901
|
|
|
// There is no $this->data here |
|
1902
|
|
|
return md5(serialize($this)); |
|
1903
|
|
|
} |
|
1904
|
|
|
|
|
1905
|
|
|
public function get_name() |
|
1906
|
|
|
{ |
|
1907
|
|
|
if ($this->name !== null) |
|
1908
|
|
|
{ |
|
1909
|
|
|
return $this->name; |
|
1910
|
|
|
} |
|
1911
|
|
|
else |
|
1912
|
|
|
{ |
|
1913
|
|
|
return null; |
|
1914
|
|
|
} |
|
1915
|
|
|
} |
|
1916
|
|
|
|
|
1917
|
|
|
public function get_link() |
|
1918
|
|
|
{ |
|
1919
|
|
|
if ($this->link !== null) |
|
1920
|
|
|
{ |
|
1921
|
|
|
return $this->link; |
|
1922
|
|
|
} |
|
1923
|
|
|
else |
|
1924
|
|
|
{ |
|
1925
|
|
|
return null; |
|
1926
|
|
|
} |
|
1927
|
|
|
} |
|
1928
|
|
|
|
|
1929
|
|
|
public function get_email() |
|
1930
|
|
|
{ |
|
1931
|
|
|
if ($this->email !== null) |
|
1932
|
|
|
{ |
|
1933
|
|
|
return $this->email; |
|
1934
|
|
|
} |
|
1935
|
|
|
else |
|
1936
|
|
|
{ |
|
1937
|
|
|
return null; |
|
1938
|
|
|
} |
|
1939
|
|
|
} |
|
1940
|
|
|
} |
|
1941
|
|
|
interface SimplePie_Cache_Base |
|
1942
|
|
|
{ |
|
1943
|
|
|
|
|
1944
|
|
|
const TYPE_FEED = 'spc'; |
|
1945
|
|
|
|
|
1946
|
|
|
const TYPE_IMAGE = 'spi'; |
|
1947
|
|
|
|
|
1948
|
|
|
public function __construct($location, $name, $type); |
|
1949
|
|
|
|
|
1950
|
|
|
public function save($data); |
|
1951
|
|
|
|
|
1952
|
|
|
public function load(); |
|
1953
|
|
|
|
|
1954
|
|
|
public function mtime(); |
|
1955
|
|
|
|
|
1956
|
|
|
public function touch(); |
|
1957
|
|
|
|
|
1958
|
|
|
public function unlink(); |
|
1959
|
|
|
} |
|
1960
|
|
|
abstract class SimplePie_Cache_DB implements SimplePie_Cache_Base |
|
1961
|
|
|
{ |
|
1962
|
|
|
|
|
1963
|
|
|
protected static function prepare_simplepie_object_for_cache($data) |
|
1964
|
|
|
{ |
|
1965
|
|
|
$items = $data->get_items(); |
|
1966
|
|
|
$items_by_id = array(); |
|
1967
|
|
|
if (!empty($items)) |
|
1968
|
|
|
{ |
|
1969
|
|
|
foreach ($items as $item) |
|
1970
|
|
|
{ |
|
1971
|
|
|
$items_by_id[$item->get_id()] = $item; |
|
1972
|
|
|
} |
|
1973
|
|
|
if (count($items_by_id) !== count($items)) |
|
1974
|
|
|
{ |
|
1975
|
|
|
$items_by_id = array(); |
|
1976
|
|
|
foreach ($items as $item) |
|
1977
|
|
|
{ |
|
1978
|
|
|
|
|
1979
|
|
|
$items_by_id[$item->get_id(true)] = $item; |
|
1980
|
|
|
} |
|
1981
|
|
|
} |
|
1982
|
|
|
if (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0])) |
|
1983
|
|
|
{ |
|
1984
|
|
|
$channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]; |
|
1985
|
|
|
} |
|
1986
|
|
|
elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0])) |
|
1987
|
|
|
{ |
|
1988
|
|
|
$channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]; |
|
1989
|
|
|
} |
|
1990
|
|
|
elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0])) |
|
1991
|
|
|
{ |
|
1992
|
|
|
$channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]; |
|
1993
|
|
|
} |
|
1994
|
|
|
elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0])) |
|
1995
|
|
|
{ |
|
1996
|
|
|
$channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0]; |
|
1997
|
|
|
} |
|
1998
|
|
|
else |
|
1999
|
|
|
{ |
|
2000
|
|
|
$channel = null; |
|
2001
|
|
|
} |
|
2002
|
|
|
if ($channel !== null) |
|
2003
|
|
|
{ |
|
2004
|
|
|
if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'])) |
|
2005
|
|
|
{ |
|
2006
|
|
|
unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry']); |
|
2007
|
|
|
} |
|
2008
|
|
|
if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry'])) |
|
2009
|
|
|
{ |
|
2010
|
|
|
unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry']); |
|
2011
|
|
|
} |
|
2012
|
|
|
if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item'])) |
|
2013
|
|
|
{ |
|
2014
|
|
|
unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']); |
|
2015
|
|
|
} |
|
2016
|
|
|
if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item'])) |
|
2017
|
|
|
{ |
|
2018
|
|
|
unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']); |
|
2019
|
|
|
} |
|
2020
|
|
|
if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item'])) |
|
2021
|
|
|
{ |
|
2022
|
|
|
unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item']); |
|
2023
|
|
|
} |
|
2024
|
|
|
} |
|
2025
|
|
|
if (isset($data->data['items'])) |
|
2026
|
|
|
{ |
|
2027
|
|
|
unset($data->data['items']); |
|
2028
|
|
|
} |
|
2029
|
|
|
if (isset($data->data['ordered_items'])) |
|
2030
|
|
|
{ |
|
2031
|
|
|
unset($data->data['ordered_items']); |
|
2032
|
|
|
} |
|
2033
|
|
|
} |
|
2034
|
|
|
return array(serialize($data->data), $items_by_id); |
|
2035
|
|
|
} |
|
2036
|
|
|
} |
|
2037
|
|
|
class SimplePie_Cache_File implements SimplePie_Cache_Base |
|
2038
|
|
|
{ |
|
2039
|
|
|
|
|
2040
|
|
|
protected $location; |
|
2041
|
|
|
|
|
2042
|
|
|
protected $filename; |
|
2043
|
|
|
|
|
2044
|
|
|
protected $extension; |
|
2045
|
|
|
|
|
2046
|
|
|
protected $name; |
|
2047
|
|
|
|
|
2048
|
|
|
public function __construct($location, $name, $type) |
|
2049
|
|
|
{ |
|
2050
|
|
|
$this->location = $location; |
|
2051
|
|
|
$this->filename = $name; |
|
2052
|
|
|
$this->extension = $type; |
|
2053
|
|
|
$this->name = "$this->location/$this->filename.$this->extension"; |
|
2054
|
|
|
} |
|
2055
|
|
|
|
|
2056
|
|
|
public function save($data) |
|
2057
|
|
|
{ |
|
2058
|
|
|
if (file_exists($this->name) && is_writeable($this->name) || file_exists($this->location) && is_writeable($this->location)) |
|
2059
|
|
|
{ |
|
2060
|
|
|
if ($data instanceof SimplePie) |
|
2061
|
|
|
{ |
|
2062
|
|
|
$data = $data->data; |
|
2063
|
|
|
} |
|
2064
|
|
|
$data = serialize($data); |
|
2065
|
|
|
return (bool) file_put_contents($this->name, $data); |
|
2066
|
|
|
} |
|
2067
|
|
|
return false; |
|
2068
|
|
|
} |
|
2069
|
|
|
|
|
2070
|
|
|
public function load() |
|
2071
|
|
|
{ |
|
2072
|
|
|
if (file_exists($this->name) && is_readable($this->name)) |
|
2073
|
|
|
{ |
|
2074
|
|
|
return unserialize(file_get_contents($this->name)); |
|
2075
|
|
|
} |
|
2076
|
|
|
return false; |
|
2077
|
|
|
} |
|
2078
|
|
|
|
|
2079
|
|
|
public function mtime() |
|
2080
|
|
|
{ |
|
2081
|
|
|
if (file_exists($this->name)) |
|
2082
|
|
|
{ |
|
2083
|
|
|
return filemtime($this->name); |
|
2084
|
|
|
} |
|
2085
|
|
|
return false; |
|
2086
|
|
|
} |
|
2087
|
|
|
|
|
2088
|
|
|
public function touch() |
|
2089
|
|
|
{ |
|
2090
|
|
|
if (file_exists($this->name)) |
|
2091
|
|
|
{ |
|
2092
|
|
|
return touch($this->name); |
|
2093
|
|
|
} |
|
2094
|
|
|
return false; |
|
2095
|
|
|
} |
|
2096
|
|
|
|
|
2097
|
|
|
public function unlink() |
|
2098
|
|
|
{ |
|
2099
|
|
|
if (file_exists($this->name)) |
|
2100
|
|
|
{ |
|
2101
|
|
|
return unlink($this->name); |
|
2102
|
|
|
} |
|
2103
|
|
|
return false; |
|
2104
|
|
|
} |
|
2105
|
|
|
} |
|
2106
|
|
|
class SimplePie_Cache_Memcache implements SimplePie_Cache_Base |
|
2107
|
|
|
{ |
|
2108
|
|
|
|
|
2109
|
|
|
protected $cache; |
|
2110
|
|
|
|
|
2111
|
|
|
protected $options; |
|
2112
|
|
|
|
|
2113
|
|
|
protected $name; |
|
2114
|
|
|
|
|
2115
|
|
|
public function __construct($location, $name, $type) |
|
2116
|
|
|
{ |
|
2117
|
|
|
$this->options = array( |
|
2118
|
|
|
'host' => '127.0.0.1', |
|
2119
|
|
|
'port' => 11211, |
|
2120
|
|
|
'extras' => array( |
|
2121
|
|
|
'timeout' => 3600, // one hour |
|
2122
|
|
|
'prefix' => 'simplepie_', |
|
2123
|
|
|
), |
|
2124
|
|
|
); |
|
2125
|
|
|
$parsed = SimplePie_Cache::parse_URL($location); |
|
2126
|
|
|
$this->options['host'] = empty($parsed['host']) ? $this->options['host'] : $parsed['host']; |
|
2127
|
|
|
$this->options['port'] = empty($parsed['port']) ? $this->options['port'] : $parsed['port']; |
|
2128
|
|
|
$this->options['extras'] = array_merge($this->options['extras'], $parsed['extras']); |
|
2129
|
|
|
$this->name = $this->options['extras']['prefix'] . md5("$name:$type"); |
|
2130
|
|
|
$this->cache = new Memcache(); |
|
2131
|
|
|
$this->cache->addServer($this->options['host'], (int) $this->options['port']); |
|
2132
|
|
|
} |
|
2133
|
|
|
|
|
2134
|
|
|
public function save($data) |
|
2135
|
|
|
{ |
|
2136
|
|
|
if ($data instanceof SimplePie) |
|
2137
|
|
|
{ |
|
2138
|
|
|
$data = $data->data; |
|
2139
|
|
|
} |
|
2140
|
|
|
return $this->cache->set($this->name, serialize($data), MEMCACHE_COMPRESSED, (int) $this->options['extras']['timeout']); |
|
2141
|
|
|
} |
|
2142
|
|
|
|
|
2143
|
|
|
public function load() |
|
2144
|
|
|
{ |
|
2145
|
|
|
$data = $this->cache->get($this->name); |
|
2146
|
|
|
if ($data !== false) |
|
2147
|
|
|
{ |
|
2148
|
|
|
return unserialize($data); |
|
2149
|
|
|
} |
|
2150
|
|
|
return false; |
|
2151
|
|
|
} |
|
2152
|
|
|
|
|
2153
|
|
|
public function mtime() |
|
2154
|
|
|
{ |
|
2155
|
|
|
$data = $this->cache->get($this->name); |
|
2156
|
|
|
if ($data !== false) |
|
2157
|
|
|
{ |
|
2158
|
|
|
// essentially ignore the mtime because Memcache expires on it's own |
|
2159
|
|
|
return time(); |
|
2160
|
|
|
} |
|
2161
|
|
|
return false; |
|
2162
|
|
|
} |
|
2163
|
|
|
|
|
2164
|
|
|
public function touch() |
|
2165
|
|
|
{ |
|
2166
|
|
|
$data = $this->cache->get($this->name); |
|
2167
|
|
|
if ($data !== false) |
|
2168
|
|
|
{ |
|
2169
|
|
|
return $this->cache->set($this->name, $data, MEMCACHE_COMPRESSED, (int) $this->duration); |
|
2170
|
|
|
} |
|
2171
|
|
|
return false; |
|
2172
|
|
|
} |
|
2173
|
|
|
|
|
2174
|
|
|
public function unlink() |
|
2175
|
|
|
{ |
|
2176
|
|
|
return $this->cache->delete($this->name, 0); |
|
2177
|
|
|
} |
|
2178
|
|
|
} |
|
2179
|
|
|
class SimplePie_Cache_MySQL extends SimplePie_Cache_DB |
|
2180
|
|
|
{ |
|
2181
|
|
|
|
|
2182
|
|
|
protected $mysql; |
|
2183
|
|
|
|
|
2184
|
|
|
protected $options; |
|
2185
|
|
|
|
|
2186
|
|
|
protected $id; |
|
2187
|
|
|
|
|
2188
|
|
|
public function __construct($location, $name, $type) |
|
2189
|
|
|
{ |
|
2190
|
|
|
$this->options = array( |
|
2191
|
|
|
'user' => null, |
|
2192
|
|
|
'pass' => null, |
|
2193
|
|
|
'host' => '127.0.0.1', |
|
2194
|
|
|
'port' => '3306', |
|
2195
|
|
|
'path' => '', |
|
2196
|
|
|
'extras' => array( |
|
2197
|
|
|
'prefix' => '', |
|
2198
|
|
|
), |
|
2199
|
|
|
); |
|
2200
|
|
|
$this->options = array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location)); |
|
2201
|
|
|
// Path is prefixed with a "/" |
|
2202
|
|
|
$this->options['dbname'] = substr($this->options['path'], 1); |
|
2203
|
|
|
try |
|
2204
|
|
|
{ |
|
2205
|
|
|
$this->mysql = new PDO("mysql:dbname={$this->options['dbname']};host={$this->options['host']};port={$this->options['port']}", $this->options['user'], $this->options['pass'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); |
|
2206
|
|
|
} |
|
2207
|
|
|
catch (PDOException $e) |
|
2208
|
|
|
{ |
|
2209
|
|
|
$this->mysql = null; |
|
2210
|
|
|
return; |
|
2211
|
|
|
} |
|
2212
|
|
|
$this->id = $name . $type; |
|
2213
|
|
|
if (!$query = $this->mysql->query('SHOW TABLES')) |
|
2214
|
|
|
{ |
|
2215
|
|
|
$this->mysql = null; |
|
2216
|
|
|
return; |
|
2217
|
|
|
} |
|
2218
|
|
|
$db = array(); |
|
2219
|
|
|
while ($row = $query->fetchColumn()) |
|
2220
|
|
|
{ |
|
2221
|
|
|
$db[] = $row; |
|
2222
|
|
|
} |
|
2223
|
|
|
if (!in_array($this->options['extras']['prefix'] . 'cache_data', $db)) |
|
2224
|
|
|
{ |
|
2225
|
|
|
$query = $this->mysql->exec('CREATE TABLE `' . $this->options['extras']['prefix'] . '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)))'); |
|
2226
|
|
|
if ($query === false) |
|
2227
|
|
|
{ |
|
2228
|
|
|
$this->mysql = null; |
|
2229
|
|
|
} |
|
2230
|
|
|
} |
|
2231
|
|
|
if (!in_array($this->options['extras']['prefix'] . 'items', $db)) |
|
2232
|
|
|
{ |
|
2233
|
|
|
$query = $this->mysql->exec('CREATE TABLE `' . $this->options['extras']['prefix'] . '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)))'); |
|
2234
|
|
|
if ($query === false) |
|
2235
|
|
|
{ |
|
2236
|
|
|
$this->mysql = null; |
|
2237
|
|
|
} |
|
2238
|
|
|
} |
|
2239
|
|
|
} |
|
2240
|
|
|
|
|
2241
|
|
|
public function save($data) |
|
2242
|
|
|
{ |
|
2243
|
|
|
if ($this->mysql === null) |
|
2244
|
|
|
{ |
|
2245
|
|
|
return false; |
|
2246
|
|
|
} |
|
2247
|
|
|
if ($data instanceof SimplePie) |
|
2248
|
|
|
{ |
|
2249
|
|
|
$data = clone $data; |
|
2250
|
|
|
$prepared = self::prepare_simplepie_object_for_cache($data); |
|
2251
|
|
|
$query = $this->mysql->prepare('SELECT COUNT(*) FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :feed'); |
|
2252
|
|
|
$query->bindValue(':feed', $this->id); |
|
2253
|
|
|
if ($query->execute()) |
|
2254
|
|
|
{ |
|
2255
|
|
|
if ($query->fetchColumn() > 0) |
|
2256
|
|
|
{ |
|
2257
|
|
|
$items = count($prepared[1]); |
|
2258
|
|
|
if ($items) |
|
2259
|
|
|
{ |
|
2260
|
|
|
$sql = 'UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `items` = :items, `data` = :data, `mtime` = :time WHERE `id` = :feed'; |
|
2261
|
|
|
$query = $this->mysql->prepare($sql); |
|
2262
|
|
|
$query->bindValue(':items', $items); |
|
2263
|
|
|
} |
|
2264
|
|
|
else |
|
2265
|
|
|
{ |
|
2266
|
|
|
$sql = 'UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `data` = :data, `mtime` = :time WHERE `id` = :feed'; |
|
2267
|
|
|
$query = $this->mysql->prepare($sql); |
|
2268
|
|
|
} |
|
2269
|
|
|
$query->bindValue(':data', $prepared[0]); |
|
2270
|
|
|
$query->bindValue(':time', time()); |
|
2271
|
|
|
$query->bindValue(':feed', $this->id); |
|
2272
|
|
|
if (!$query->execute()) |
|
2273
|
|
|
{ |
|
2274
|
|
|
return false; |
|
2275
|
|
|
} |
|
2276
|
|
|
} |
|
2277
|
|
|
else |
|
2278
|
|
|
{ |
|
2279
|
|
|
$query = $this->mysql->prepare('INSERT INTO `' . $this->options['extras']['prefix'] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(:feed, :count, :data, :time)'); |
|
2280
|
|
|
$query->bindValue(':feed', $this->id); |
|
2281
|
|
|
$query->bindValue(':count', count($prepared[1])); |
|
2282
|
|
|
$query->bindValue(':data', $prepared[0]); |
|
2283
|
|
|
$query->bindValue(':time', time()); |
|
2284
|
|
|
if (!$query->execute()) |
|
2285
|
|
|
{ |
|
2286
|
|
|
return false; |
|
2287
|
|
|
} |
|
2288
|
|
|
} |
|
2289
|
|
|
$ids = array_keys($prepared[1]); |
|
2290
|
|
|
if (!empty($ids)) |
|
2291
|
|
|
{ |
|
2292
|
|
|
foreach ($ids as $id) |
|
2293
|
|
|
{ |
|
2294
|
|
|
$database_ids[] = $this->mysql->quote($id); |
|
2295
|
|
|
} |
|
2296
|
|
|
$query = $this->mysql->prepare('SELECT `id` FROM `' . $this->options['extras']['prefix'] . 'items` WHERE `id` = ' . implode(' OR `id` = ', $database_ids) . ' AND `feed_id` = :feed'); |
|
2297
|
|
|
$query->bindValue(':feed', $this->id); |
|
2298
|
|
|
if ($query->execute()) |
|
2299
|
|
|
{ |
|
2300
|
|
|
$existing_ids = array(); |
|
2301
|
|
|
while ($row = $query->fetchColumn()) |
|
2302
|
|
|
{ |
|
2303
|
|
|
$existing_ids[] = $row; |
|
2304
|
|
|
} |
|
2305
|
|
|
$new_ids = array_diff($ids, $existing_ids); |
|
2306
|
|
|
foreach ($new_ids as $new_id) |
|
2307
|
|
|
{ |
|
2308
|
|
|
if (!($date = $prepared[1][$new_id]->get_date('U'))) |
|
2309
|
|
|
{ |
|
2310
|
|
|
$date = time(); |
|
2311
|
|
|
} |
|
2312
|
|
|
$query = $this->mysql->prepare('INSERT INTO `' . $this->options['extras']['prefix'] . 'items` (`feed_id`, `id`, `data`, `posted`) VALUES(:feed, :id, :data, :date)'); |
|
2313
|
|
|
$query->bindValue(':feed', $this->id); |
|
2314
|
|
|
$query->bindValue(':id', $new_id); |
|
2315
|
|
|
$query->bindValue(':data', serialize($prepared[1][$new_id]->data)); |
|
2316
|
|
|
$query->bindValue(':date', $date); |
|
2317
|
|
|
if (!$query->execute()) |
|
2318
|
|
|
{ |
|
2319
|
|
|
return false; |
|
2320
|
|
|
} |
|
2321
|
|
|
} |
|
2322
|
|
|
return true; |
|
2323
|
|
|
} |
|
2324
|
|
|
} |
|
2325
|
|
|
else |
|
2326
|
|
|
{ |
|
2327
|
|
|
return true; |
|
2328
|
|
|
} |
|
2329
|
|
|
} |
|
2330
|
|
|
} |
|
2331
|
|
|
else |
|
2332
|
|
|
{ |
|
2333
|
|
|
$query = $this->mysql->prepare('SELECT `id` FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :feed'); |
|
2334
|
|
|
$query->bindValue(':feed', $this->id); |
|
2335
|
|
|
if ($query->execute()) |
|
2336
|
|
|
{ |
|
2337
|
|
|
if ($query->rowCount() > 0) |
|
2338
|
|
|
{ |
|
2339
|
|
|
$query = $this->mysql->prepare('UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `items` = 0, `data` = :data, `mtime` = :time WHERE `id` = :feed'); |
|
2340
|
|
|
$query->bindValue(':data', serialize($data)); |
|
2341
|
|
|
$query->bindValue(':time', time()); |
|
2342
|
|
|
$query->bindValue(':feed', $this->id); |
|
2343
|
|
|
if ($this->execute()) |
|
2344
|
|
|
{ |
|
2345
|
|
|
return true; |
|
2346
|
|
|
} |
|
2347
|
|
|
} |
|
2348
|
|
|
else |
|
2349
|
|
|
{ |
|
2350
|
|
|
$query = $this->mysql->prepare('INSERT INTO `' . $this->options['extras']['prefix'] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(:id, 0, :data, :time)'); |
|
2351
|
|
|
$query->bindValue(':id', $this->id); |
|
2352
|
|
|
$query->bindValue(':data', serialize($data)); |
|
2353
|
|
|
$query->bindValue(':time', time()); |
|
2354
|
|
|
if ($query->execute()) |
|
2355
|
|
|
{ |
|
2356
|
|
|
return true; |
|
2357
|
|
|
} |
|
2358
|
|
|
} |
|
2359
|
|
|
} |
|
2360
|
|
|
} |
|
2361
|
|
|
return false; |
|
2362
|
|
|
} |
|
2363
|
|
|
|
|
2364
|
|
|
public function load() |
|
2365
|
|
|
{ |
|
2366
|
|
|
if ($this->mysql === null) |
|
2367
|
|
|
{ |
|
2368
|
|
|
return false; |
|
2369
|
|
|
} |
|
2370
|
|
|
$query = $this->mysql->prepare('SELECT `items`, `data` FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :id'); |
|
2371
|
|
|
$query->bindValue(':id', $this->id); |
|
2372
|
|
|
if ($query->execute() && ($row = $query->fetch())) |
|
2373
|
|
|
{ |
|
2374
|
|
|
$data = unserialize($row[1]); |
|
2375
|
|
|
if (isset($this->options['items'][0])) |
|
2376
|
|
|
{ |
|
2377
|
|
|
$items = (int) $this->options['items'][0]; |
|
2378
|
|
|
} |
|
2379
|
|
|
else |
|
2380
|
|
|
{ |
|
2381
|
|
|
$items = (int) $row[0]; |
|
2382
|
|
|
} |
|
2383
|
|
|
if ($items !== 0) |
|
2384
|
|
|
{ |
|
2385
|
|
|
if (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0])) |
|
2386
|
|
|
{ |
|
2387
|
|
|
$feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]; |
|
2388
|
|
|
} |
|
2389
|
|
|
elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0])) |
|
2390
|
|
|
{ |
|
2391
|
|
|
$feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]; |
|
2392
|
|
|
} |
|
2393
|
|
|
elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0])) |
|
2394
|
|
|
{ |
|
2395
|
|
|
$feed =& $data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]; |
|
2396
|
|
|
} |
|
2397
|
|
|
elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0])) |
|
2398
|
|
|
{ |
|
2399
|
|
|
$feed =& $data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]; |
|
2400
|
|
|
} |
|
2401
|
|
|
else |
|
2402
|
|
|
{ |
|
2403
|
|
|
$feed = null; |
|
2404
|
|
|
} |
|
2405
|
|
|
if ($feed !== null) |
|
2406
|
|
|
{ |
|
2407
|
|
|
$sql = 'SELECT `data` FROM `' . $this->options['extras']['prefix'] . 'items` WHERE `feed_id` = :feed ORDER BY `posted` DESC'; |
|
2408
|
|
|
if ($items > 0) |
|
2409
|
|
|
{ |
|
2410
|
|
|
$sql .= ' LIMIT ' . $items; |
|
2411
|
|
|
} |
|
2412
|
|
|
$query = $this->mysql->prepare($sql); |
|
2413
|
|
|
$query->bindValue(':feed', $this->id); |
|
2414
|
|
|
if ($query->execute()) |
|
2415
|
|
|
{ |
|
2416
|
|
|
while ($row = $query->fetchColumn()) |
|
2417
|
|
|
{ |
|
2418
|
|
|
$feed['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'][] = unserialize($row); |
|
2419
|
|
|
} |
|
2420
|
|
|
} |
|
2421
|
|
|
else |
|
2422
|
|
|
{ |
|
2423
|
|
|
return false; |
|
2424
|
|
|
} |
|
2425
|
|
|
} |
|
2426
|
|
|
} |
|
2427
|
|
|
return $data; |
|
2428
|
|
|
} |
|
2429
|
|
|
return false; |
|
2430
|
|
|
} |
|
2431
|
|
|
|
|
2432
|
|
|
public function mtime() |
|
2433
|
|
|
{ |
|
2434
|
|
|
if ($this->mysql === null) |
|
2435
|
|
|
{ |
|
2436
|
|
|
return false; |
|
2437
|
|
|
} |
|
2438
|
|
|
$query = $this->mysql->prepare('SELECT `mtime` FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :id'); |
|
2439
|
|
|
$query->bindValue(':id', $this->id); |
|
2440
|
|
|
if ($query->execute() && ($time = $query->fetchColumn())) |
|
2441
|
|
|
{ |
|
2442
|
|
|
return $time; |
|
2443
|
|
|
} |
|
2444
|
|
|
else |
|
2445
|
|
|
{ |
|
2446
|
|
|
return false; |
|
2447
|
|
|
} |
|
2448
|
|
|
} |
|
2449
|
|
|
|
|
2450
|
|
|
public function touch() |
|
2451
|
|
|
{ |
|
2452
|
|
|
if ($this->mysql === null) |
|
2453
|
|
|
{ |
|
2454
|
|
|
return false; |
|
2455
|
|
|
} |
|
2456
|
|
|
$query = $this->mysql->prepare('UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `mtime` = :time WHERE `id` = :id'); |
|
2457
|
|
|
$query->bindValue(':time', time()); |
|
2458
|
|
|
$query->bindValue(':id', $this->id); |
|
2459
|
|
|
if ($query->execute() && $query->rowCount() > 0) |
|
2460
|
|
|
{ |
|
2461
|
|
|
return true; |
|
2462
|
|
|
} |
|
2463
|
|
|
else |
|
2464
|
|
|
{ |
|
2465
|
|
|
return false; |
|
2466
|
|
|
} |
|
2467
|
|
|
} |
|
2468
|
|
|
|
|
2469
|
|
|
public function unlink() |
|
2470
|
|
|
{ |
|
2471
|
|
|
if ($this->mysql === null) |
|
2472
|
|
|
{ |
|
2473
|
|
|
return false; |
|
2474
|
|
|
} |
|
2475
|
|
|
$query = $this->mysql->prepare('DELETE FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :id'); |
|
2476
|
|
|
$query->bindValue(':id', $this->id); |
|
2477
|
|
|
$query2 = $this->mysql->prepare('DELETE FROM `' . $this->options['extras']['prefix'] . 'items` WHERE `feed_id` = :id'); |
|
2478
|
|
|
$query2->bindValue(':id', $this->id); |
|
2479
|
|
|
if ($query->execute() && $query2->execute()) |
|
2480
|
|
|
{ |
|
2481
|
|
|
return true; |
|
2482
|
|
|
} |
|
2483
|
|
|
else |
|
2484
|
|
|
{ |
|
2485
|
|
|
return false; |
|
2486
|
|
|
} |
|
2487
|
|
|
} |
|
2488
|
|
|
} |
|
2489
|
|
|
class SimplePie_Cache |
|
2490
|
|
|
{ |
|
2491
|
|
|
|
|
2492
|
|
|
protected static $handlers = array( |
|
2493
|
|
|
'mysql' => 'SimplePie_Cache_MySQL', |
|
2494
|
|
|
'memcache' => 'SimplePie_Cache_Memcache', |
|
2495
|
|
|
); |
|
2496
|
|
|
|
|
2497
|
|
|
private function __construct() { } |
|
2498
|
|
|
|
|
2499
|
|
|
public static function get_handler($location, $filename, $extension) |
|
2500
|
|
|
{ |
|
2501
|
|
|
$type = explode(':', $location, 2); |
|
2502
|
|
|
$type = $type[0]; |
|
2503
|
|
|
if (!empty(self::$handlers[$type])) |
|
2504
|
|
|
{ |
|
2505
|
|
|
$class = self::$handlers[$type]; |
|
2506
|
|
|
return new $class($location, $filename, $extension); |
|
2507
|
|
|
} |
|
2508
|
|
|
return new SimplePie_Cache_File($location, $filename, $extension); |
|
2509
|
|
|
} |
|
2510
|
|
|
|
|
2511
|
|
|
public function create($location, $filename, $extension) |
|
2512
|
|
|
{ |
|
2513
|
|
|
trigger_error('Cache::create() has been replaced with Cache::get_handler(). Switch to the registry system to use this.', E_USER_DEPRECATED); |
|
2514
|
|
|
return self::get_handler($location, $filename, $extension); |
|
2515
|
|
|
} |
|
2516
|
|
|
|
|
2517
|
|
|
public static function register($type, $class) |
|
2518
|
|
|
{ |
|
2519
|
|
|
self::$handlers[$type] = $class; |
|
2520
|
|
|
} |
|
2521
|
|
|
|
|
2522
|
|
|
public static function parse_URL($url) |
|
2523
|
|
|
{ |
|
2524
|
|
|
$params = parse_url($url); |
|
2525
|
|
|
$params['extras'] = array(); |
|
2526
|
|
|
if (isset($params['query'])) |
|
2527
|
|
|
{ |
|
2528
|
|
|
parse_str($params['query'], $params['extras']); |
|
2529
|
|
|
} |
|
2530
|
|
|
return $params; |
|
2531
|
|
|
} |
|
2532
|
|
|
} |
|
2533
|
|
|
class SimplePie_Caption |
|
2534
|
|
|
{ |
|
2535
|
|
|
|
|
2536
|
|
|
var $type; |
|
2537
|
|
|
|
|
2538
|
|
|
var $lang; |
|
2539
|
|
|
|
|
2540
|
|
|
var $startTime; |
|
2541
|
|
|
|
|
2542
|
|
|
var $endTime; |
|
2543
|
|
|
|
|
2544
|
|
|
var $text; |
|
2545
|
|
|
|
|
2546
|
|
|
public function __construct($type = null, $lang = null, $startTime = null, $endTime = null, $text = null) |
|
2547
|
|
|
{ |
|
2548
|
|
|
$this->type = $type; |
|
2549
|
|
|
$this->lang = $lang; |
|
2550
|
|
|
$this->startTime = $startTime; |
|
2551
|
|
|
$this->endTime = $endTime; |
|
2552
|
|
|
$this->text = $text; |
|
2553
|
|
|
} |
|
2554
|
|
|
|
|
2555
|
|
|
public function __toString() |
|
2556
|
|
|
{ |
|
2557
|
|
|
// There is no $this->data here |
|
2558
|
|
|
return md5(serialize($this)); |
|
2559
|
|
|
} |
|
2560
|
|
|
|
|
2561
|
|
|
public function get_endtime() |
|
2562
|
|
|
{ |
|
2563
|
|
|
if ($this->endTime !== null) |
|
2564
|
|
|
{ |
|
2565
|
|
|
return $this->endTime; |
|
2566
|
|
|
} |
|
2567
|
|
|
else |
|
2568
|
|
|
{ |
|
2569
|
|
|
return null; |
|
2570
|
|
|
} |
|
2571
|
|
|
} |
|
2572
|
|
|
|
|
2573
|
|
|
public function get_language() |
|
2574
|
|
|
{ |
|
2575
|
|
|
if ($this->lang !== null) |
|
2576
|
|
|
{ |
|
2577
|
|
|
return $this->lang; |
|
2578
|
|
|
} |
|
2579
|
|
|
else |
|
2580
|
|
|
{ |
|
2581
|
|
|
return null; |
|
2582
|
|
|
} |
|
2583
|
|
|
} |
|
2584
|
|
|
|
|
2585
|
|
|
public function get_starttime() |
|
2586
|
|
|
{ |
|
2587
|
|
|
if ($this->startTime !== null) |
|
2588
|
|
|
{ |
|
2589
|
|
|
return $this->startTime; |
|
2590
|
|
|
} |
|
2591
|
|
|
else |
|
2592
|
|
|
{ |
|
2593
|
|
|
return null; |
|
2594
|
|
|
} |
|
2595
|
|
|
} |
|
2596
|
|
|
|
|
2597
|
|
|
public function get_text() |
|
2598
|
|
|
{ |
|
2599
|
|
|
if ($this->text !== null) |
|
2600
|
|
|
{ |
|
2601
|
|
|
return $this->text; |
|
2602
|
|
|
} |
|
2603
|
|
|
else |
|
2604
|
|
|
{ |
|
2605
|
|
|
return null; |
|
2606
|
|
|
} |
|
2607
|
|
|
} |
|
2608
|
|
|
|
|
2609
|
|
|
public function get_type() |
|
2610
|
|
|
{ |
|
2611
|
|
|
if ($this->type !== null) |
|
2612
|
|
|
{ |
|
2613
|
|
|
return $this->type; |
|
2614
|
|
|
} |
|
2615
|
|
|
else |
|
2616
|
|
|
{ |
|
2617
|
|
|
return null; |
|
2618
|
|
|
} |
|
2619
|
|
|
} |
|
2620
|
|
|
} |
|
2621
|
|
|
class SimplePie_Category |
|
2622
|
|
|
{ |
|
2623
|
|
|
|
|
2624
|
|
|
var $term; |
|
2625
|
|
|
|
|
2626
|
|
|
var $scheme; |
|
2627
|
|
|
|
|
2628
|
|
|
var $label; |
|
2629
|
|
|
|
|
2630
|
|
|
public function __construct($term = null, $scheme = null, $label = null) |
|
2631
|
|
|
{ |
|
2632
|
|
|
$this->term = $term; |
|
2633
|
|
|
$this->scheme = $scheme; |
|
2634
|
|
|
$this->label = $label; |
|
2635
|
|
|
} |
|
2636
|
|
|
|
|
2637
|
|
|
public function __toString() |
|
2638
|
|
|
{ |
|
2639
|
|
|
// There is no $this->data here |
|
2640
|
|
|
return md5(serialize($this)); |
|
2641
|
|
|
} |
|
2642
|
|
|
|
|
2643
|
|
|
public function get_term() |
|
2644
|
|
|
{ |
|
2645
|
|
|
if ($this->term !== null) |
|
2646
|
|
|
{ |
|
2647
|
|
|
return $this->term; |
|
2648
|
|
|
} |
|
2649
|
|
|
else |
|
2650
|
|
|
{ |
|
2651
|
|
|
return null; |
|
2652
|
|
|
} |
|
2653
|
|
|
} |
|
2654
|
|
|
|
|
2655
|
|
|
public function get_scheme() |
|
2656
|
|
|
{ |
|
2657
|
|
|
if ($this->scheme !== null) |
|
2658
|
|
|
{ |
|
2659
|
|
|
return $this->scheme; |
|
2660
|
|
|
} |
|
2661
|
|
|
else |
|
2662
|
|
|
{ |
|
2663
|
|
|
return null; |
|
2664
|
|
|
} |
|
2665
|
|
|
} |
|
2666
|
|
|
|
|
2667
|
|
|
public function get_label() |
|
2668
|
|
|
{ |
|
2669
|
|
|
if ($this->label !== null) |
|
2670
|
|
|
{ |
|
2671
|
|
|
return $this->label; |
|
2672
|
|
|
} |
|
2673
|
|
|
else |
|
2674
|
|
|
{ |
|
2675
|
|
|
return $this->get_term(); |
|
2676
|
|
|
} |
|
2677
|
|
|
} |
|
2678
|
|
|
} |
|
2679
|
|
|
class SimplePie_Content_Type_Sniffer |
|
2680
|
|
|
{ |
|
2681
|
|
|
|
|
2682
|
|
|
var $file; |
|
2683
|
|
|
|
|
2684
|
|
|
public function __construct($file) |
|
2685
|
|
|
{ |
|
2686
|
|
|
$this->file = $file; |
|
2687
|
|
|
} |
|
2688
|
|
|
|
|
2689
|
|
|
public function get_type() |
|
2690
|
|
|
{ |
|
2691
|
|
|
if (isset($this->file->headers['content-type'])) |
|
2692
|
|
|
{ |
|
2693
|
|
|
if (!isset($this->file->headers['content-encoding']) |
|
2694
|
|
|
&& ($this->file->headers['content-type'] === 'text/plain' |
|
2695
|
|
|
|| $this->file->headers['content-type'] === 'text/plain; charset=ISO-8859-1' |
|
2696
|
|
|
|| $this->file->headers['content-type'] === 'text/plain; charset=iso-8859-1' |
|
2697
|
|
|
|| $this->file->headers['content-type'] === 'text/plain; charset=UTF-8')) |
|
2698
|
|
|
{ |
|
2699
|
|
|
return $this->text_or_binary(); |
|
2700
|
|
|
} |
|
2701
|
|
|
if (($pos = strpos($this->file->headers['content-type'], ';')) !== false) |
|
2702
|
|
|
{ |
|
2703
|
|
|
$official = substr($this->file->headers['content-type'], 0, $pos); |
|
2704
|
|
|
} |
|
2705
|
|
|
else |
|
2706
|
|
|
{ |
|
2707
|
|
|
$official = $this->file->headers['content-type']; |
|
2708
|
|
|
} |
|
2709
|
|
|
$official = trim(strtolower($official)); |
|
2710
|
|
|
if ($official === 'unknown/unknown' |
|
2711
|
|
|
|| $official === 'application/unknown') |
|
2712
|
|
|
{ |
|
2713
|
|
|
return $this->unknown(); |
|
2714
|
|
|
} |
|
2715
|
|
|
elseif (substr($official, -4) === '+xml' |
|
2716
|
|
|
|| $official === 'text/xml' |
|
2717
|
|
|
|| $official === 'application/xml') |
|
2718
|
|
|
{ |
|
2719
|
|
|
return $official; |
|
2720
|
|
|
} |
|
2721
|
|
|
elseif (substr($official, 0, 6) === 'image/') |
|
2722
|
|
|
{ |
|
2723
|
|
|
if ($return = $this->image()) |
|
2724
|
|
|
{ |
|
2725
|
|
|
return $return; |
|
2726
|
|
|
} |
|
2727
|
|
|
else |
|
2728
|
|
|
{ |
|
2729
|
|
|
return $official; |
|
2730
|
|
|
} |
|
2731
|
|
|
} |
|
2732
|
|
|
elseif ($official === 'text/html') |
|
2733
|
|
|
{ |
|
2734
|
|
|
return $this->feed_or_html(); |
|
2735
|
|
|
} |
|
2736
|
|
|
else |
|
2737
|
|
|
{ |
|
2738
|
|
|
return $official; |
|
2739
|
|
|
} |
|
2740
|
|
|
} |
|
2741
|
|
|
else |
|
2742
|
|
|
{ |
|
2743
|
|
|
return $this->unknown(); |
|
2744
|
|
|
} |
|
2745
|
|
|
} |
|
2746
|
|
|
|
|
2747
|
|
|
public function text_or_binary() |
|
2748
|
|
|
{ |
|
2749
|
|
|
if (substr($this->file->body, 0, 2) === "\xFE\xFF" |
|
2750
|
|
|
|| substr($this->file->body, 0, 2) === "\xFF\xFE" |
|
2751
|
|
|
|| substr($this->file->body, 0, 4) === "\x00\x00\xFE\xFF" |
|
2752
|
|
|
|| substr($this->file->body, 0, 3) === "\xEF\xBB\xBF") |
|
2753
|
|
|
{ |
|
2754
|
|
|
return 'text/plain'; |
|
2755
|
|
|
} |
|
2756
|
|
|
elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $this->file->body)) |
|
2757
|
|
|
{ |
|
2758
|
|
|
return 'application/octect-stream'; |
|
2759
|
|
|
} |
|
2760
|
|
|
else |
|
2761
|
|
|
{ |
|
2762
|
|
|
return 'text/plain'; |
|
2763
|
|
|
} |
|
2764
|
|
|
} |
|
2765
|
|
|
|
|
2766
|
|
|
public function unknown() |
|
2767
|
|
|
{ |
|
2768
|
|
|
$ws = strspn($this->file->body, "\x09\x0A\x0B\x0C\x0D\x20"); |
|
2769
|
|
|
if (strtolower(substr($this->file->body, $ws, 14)) === '<!doctype html' |
|
2770
|
|
|
|| strtolower(substr($this->file->body, $ws, 5)) === '<html' |
|
2771
|
|
|
|| strtolower(substr($this->file->body, $ws, 7)) === '<script') |
|
2772
|
|
|
{ |
|
2773
|
|
|
return 'text/html'; |
|
2774
|
|
|
} |
|
2775
|
|
|
elseif (substr($this->file->body, 0, 5) === '%PDF-') |
|
2776
|
|
|
{ |
|
2777
|
|
|
return 'application/pdf'; |
|
2778
|
|
|
} |
|
2779
|
|
|
elseif (substr($this->file->body, 0, 11) === '%!PS-Adobe-') |
|
2780
|
|
|
{ |
|
2781
|
|
|
return 'application/postscript'; |
|
2782
|
|
|
} |
|
2783
|
|
|
elseif (substr($this->file->body, 0, 6) === 'GIF87a' |
|
2784
|
|
|
|| substr($this->file->body, 0, 6) === 'GIF89a') |
|
2785
|
|
|
{ |
|
2786
|
|
|
return 'image/gif'; |
|
2787
|
|
|
} |
|
2788
|
|
|
elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") |
|
2789
|
|
|
{ |
|
2790
|
|
|
return 'image/png'; |
|
2791
|
|
|
} |
|
2792
|
|
|
elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF") |
|
2793
|
|
|
{ |
|
2794
|
|
|
return 'image/jpeg'; |
|
2795
|
|
|
} |
|
2796
|
|
|
elseif (substr($this->file->body, 0, 2) === "\x42\x4D") |
|
2797
|
|
|
{ |
|
2798
|
|
|
return 'image/bmp'; |
|
2799
|
|
|
} |
|
2800
|
|
|
elseif (substr($this->file->body, 0, 4) === "\x00\x00\x01\x00") |
|
2801
|
|
|
{ |
|
2802
|
|
|
return 'image/vnd.microsoft.icon'; |
|
2803
|
|
|
} |
|
2804
|
|
|
else |
|
2805
|
|
|
{ |
|
2806
|
|
|
return $this->text_or_binary(); |
|
2807
|
|
|
} |
|
2808
|
|
|
} |
|
2809
|
|
|
|
|
2810
|
|
|
public function image() |
|
2811
|
|
|
{ |
|
2812
|
|
|
if (substr($this->file->body, 0, 6) === 'GIF87a' |
|
2813
|
|
|
|| substr($this->file->body, 0, 6) === 'GIF89a') |
|
2814
|
|
|
{ |
|
2815
|
|
|
return 'image/gif'; |
|
2816
|
|
|
} |
|
2817
|
|
|
elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") |
|
2818
|
|
|
{ |
|
2819
|
|
|
return 'image/png'; |
|
2820
|
|
|
} |
|
2821
|
|
|
elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF") |
|
2822
|
|
|
{ |
|
2823
|
|
|
return 'image/jpeg'; |
|
2824
|
|
|
} |
|
2825
|
|
|
elseif (substr($this->file->body, 0, 2) === "\x42\x4D") |
|
2826
|
|
|
{ |
|
2827
|
|
|
return 'image/bmp'; |
|
2828
|
|
|
} |
|
2829
|
|
|
elseif (substr($this->file->body, 0, 4) === "\x00\x00\x01\x00") |
|
2830
|
|
|
{ |
|
2831
|
|
|
return 'image/vnd.microsoft.icon'; |
|
2832
|
|
|
} |
|
2833
|
|
|
else |
|
2834
|
|
|
{ |
|
2835
|
|
|
return false; |
|
2836
|
|
|
} |
|
2837
|
|
|
} |
|
2838
|
|
|
|
|
2839
|
|
|
public function feed_or_html() |
|
2840
|
|
|
{ |
|
2841
|
|
|
$len = strlen($this->file->body); |
|
2842
|
|
|
$pos = strspn($this->file->body, "\x09\x0A\x0D\x20"); |
|
2843
|
|
|
while ($pos < $len) |
|
2844
|
|
|
{ |
|
2845
|
|
|
switch ($this->file->body[$pos]) |
|
2846
|
|
|
{ |
|
2847
|
|
|
case "\x09": |
|
2848
|
|
|
case "\x0A": |
|
2849
|
|
|
case "\x0D": |
|
2850
|
|
|
case "\x20": |
|
2851
|
|
|
$pos += strspn($this->file->body, "\x09\x0A\x0D\x20", $pos); |
|
2852
|
|
|
continue 2; |
|
2853
|
|
|
case '<': |
|
2854
|
|
|
$pos++; |
|
2855
|
|
|
break; |
|
2856
|
|
|
default: |
|
2857
|
|
|
return 'text/html'; |
|
2858
|
|
|
} |
|
2859
|
|
|
if (substr($this->file->body, $pos, 3) === '!--') |
|
2860
|
|
|
{ |
|
2861
|
|
|
$pos += 3; |
|
2862
|
|
|
if ($pos < $len && ($pos = strpos($this->file->body, '-->', $pos)) !== false) |
|
2863
|
|
|
{ |
|
2864
|
|
|
$pos += 3; |
|
2865
|
|
|
} |
|
2866
|
|
|
else |
|
2867
|
|
|
{ |
|
2868
|
|
|
return 'text/html'; |
|
2869
|
|
|
} |
|
2870
|
|
|
} |
|
2871
|
|
|
elseif (substr($this->file->body, $pos, 1) === '!') |
|
2872
|
|
|
{ |
|
2873
|
|
|
if ($pos < $len && ($pos = strpos($this->file->body, '>', $pos)) !== false) |
|
2874
|
|
|
{ |
|
2875
|
|
|
$pos++; |
|
2876
|
|
|
} |
|
2877
|
|
|
else |
|
2878
|
|
|
{ |
|
2879
|
|
|
return 'text/html'; |
|
2880
|
|
|
} |
|
2881
|
|
|
} |
|
2882
|
|
|
elseif (substr($this->file->body, $pos, 1) === '?') |
|
2883
|
|
|
{ |
|
2884
|
|
|
if ($pos < $len && ($pos = strpos($this->file->body, '?>', $pos)) !== false) |
|
2885
|
|
|
{ |
|
2886
|
|
|
$pos += 2; |
|
2887
|
|
|
} |
|
2888
|
|
|
else |
|
2889
|
|
|
{ |
|
2890
|
|
|
return 'text/html'; |
|
2891
|
|
|
} |
|
2892
|
|
|
} |
|
2893
|
|
|
elseif (substr($this->file->body, $pos, 3) === 'rss' |
|
2894
|
|
|
|| substr($this->file->body, $pos, 7) === 'rdf:RDF') |
|
2895
|
|
|
{ |
|
2896
|
|
|
return 'application/rss+xml'; |
|
2897
|
|
|
} |
|
2898
|
|
|
elseif (substr($this->file->body, $pos, 4) === 'feed') |
|
2899
|
|
|
{ |
|
2900
|
|
|
return 'application/atom+xml'; |
|
2901
|
|
|
} |
|
2902
|
|
|
else |
|
2903
|
|
|
{ |
|
2904
|
|
|
return 'text/html'; |
|
2905
|
|
|
} |
|
2906
|
|
|
} |
|
2907
|
|
|
return 'text/html'; |
|
2908
|
|
|
} |
|
2909
|
|
|
} |
|
2910
|
|
|
class SimplePie_Copyright |
|
2911
|
|
|
{ |
|
2912
|
|
|
|
|
2913
|
|
|
var $url; |
|
2914
|
|
|
|
|
2915
|
|
|
var $label; |
|
2916
|
|
|
|
|
2917
|
|
|
public function __construct($url = null, $label = null) |
|
2918
|
|
|
{ |
|
2919
|
|
|
$this->url = $url; |
|
2920
|
|
|
$this->label = $label; |
|
2921
|
|
|
} |
|
2922
|
|
|
|
|
2923
|
|
|
public function __toString() |
|
2924
|
|
|
{ |
|
2925
|
|
|
// There is no $this->data here |
|
2926
|
|
|
return md5(serialize($this)); |
|
2927
|
|
|
} |
|
2928
|
|
|
|
|
2929
|
|
|
public function get_url() |
|
2930
|
|
|
{ |
|
2931
|
|
|
if ($this->url !== null) |
|
2932
|
|
|
{ |
|
2933
|
|
|
return $this->url; |
|
2934
|
|
|
} |
|
2935
|
|
|
else |
|
2936
|
|
|
{ |
|
2937
|
|
|
return null; |
|
2938
|
|
|
} |
|
2939
|
|
|
} |
|
2940
|
|
|
|
|
2941
|
|
|
public function get_attribution() |
|
2942
|
|
|
{ |
|
2943
|
|
|
if ($this->label !== null) |
|
2944
|
|
|
{ |
|
2945
|
|
|
return $this->label; |
|
2946
|
|
|
} |
|
2947
|
|
|
else |
|
2948
|
|
|
{ |
|
2949
|
|
|
return null; |
|
2950
|
|
|
} |
|
2951
|
|
|
} |
|
2952
|
|
|
} |
|
2953
|
|
|
class SimplePie_Core extends SimplePie |
|
2954
|
|
|
{ |
|
2955
|
|
|
} |
|
2956
|
|
|
class SimplePie_Credit |
|
2957
|
|
|
{ |
|
2958
|
|
|
|
|
2959
|
|
|
var $role; |
|
2960
|
|
|
|
|
2961
|
|
|
var $scheme; |
|
2962
|
|
|
|
|
2963
|
|
|
var $name; |
|
2964
|
|
|
|
|
2965
|
|
|
public function __construct($role = null, $scheme = null, $name = null) |
|
2966
|
|
|
{ |
|
2967
|
|
|
$this->role = $role; |
|
2968
|
|
|
$this->scheme = $scheme; |
|
2969
|
|
|
$this->name = $name; |
|
2970
|
|
|
} |
|
2971
|
|
|
|
|
2972
|
|
|
public function __toString() |
|
2973
|
|
|
{ |
|
2974
|
|
|
// There is no $this->data here |
|
2975
|
|
|
return md5(serialize($this)); |
|
2976
|
|
|
} |
|
2977
|
|
|
|
|
2978
|
|
|
public function get_role() |
|
2979
|
|
|
{ |
|
2980
|
|
|
if ($this->role !== null) |
|
2981
|
|
|
{ |
|
2982
|
|
|
return $this->role; |
|
2983
|
|
|
} |
|
2984
|
|
|
else |
|
2985
|
|
|
{ |
|
2986
|
|
|
return null; |
|
2987
|
|
|
} |
|
2988
|
|
|
} |
|
2989
|
|
|
|
|
2990
|
|
|
public function get_scheme() |
|
2991
|
|
|
{ |
|
2992
|
|
|
if ($this->scheme !== null) |
|
2993
|
|
|
{ |
|
2994
|
|
|
return $this->scheme; |
|
2995
|
|
|
} |
|
2996
|
|
|
else |
|
2997
|
|
|
{ |
|
2998
|
|
|
return null; |
|
2999
|
|
|
} |
|
3000
|
|
|
} |
|
3001
|
|
|
|
|
3002
|
|
|
public function get_name() |
|
3003
|
|
|
{ |
|
3004
|
|
|
if ($this->name !== null) |
|
3005
|
|
|
{ |
|
3006
|
|
|
return $this->name; |
|
3007
|
|
|
} |
|
3008
|
|
|
else |
|
3009
|
|
|
{ |
|
3010
|
|
|
return null; |
|
3011
|
|
|
} |
|
3012
|
|
|
} |
|
3013
|
|
|
} |
|
3014
|
|
|
class SimplePie_Decode_HTML_Entities |
|
3015
|
|
|
{ |
|
3016
|
|
|
|
|
3017
|
|
|
var $data = ''; |
|
3018
|
|
|
|
|
3019
|
|
|
var $consumed = ''; |
|
3020
|
|
|
|
|
3021
|
|
|
var $position = 0; |
|
3022
|
|
|
|
|
3023
|
|
|
public function __construct($data) |
|
3024
|
|
|
{ |
|
3025
|
|
|
$this->data = $data; |
|
3026
|
|
|
} |
|
3027
|
|
|
|
|
3028
|
|
|
public function parse() |
|
3029
|
|
|
{ |
|
3030
|
|
|
while (($this->position = strpos($this->data, '&', $this->position)) !== false) |
|
3031
|
|
|
{ |
|
3032
|
|
|
$this->consume(); |
|
3033
|
|
|
$this->entity(); |
|
3034
|
|
|
$this->consumed = ''; |
|
3035
|
|
|
} |
|
3036
|
|
|
return $this->data; |
|
3037
|
|
|
} |
|
3038
|
|
|
|
|
3039
|
|
|
public function consume() |
|
3040
|
|
|
{ |
|
3041
|
|
|
if (isset($this->data[$this->position])) |
|
3042
|
|
|
{ |
|
3043
|
|
|
$this->consumed .= $this->data[$this->position]; |
|
3044
|
|
|
return $this->data[$this->position++]; |
|
3045
|
|
|
} |
|
3046
|
|
|
else |
|
3047
|
|
|
{ |
|
3048
|
|
|
return false; |
|
3049
|
|
|
} |
|
3050
|
|
|
} |
|
3051
|
|
|
|
|
3052
|
|
|
public function consume_range($chars) |
|
3053
|
|
|
{ |
|
3054
|
|
|
if ($len = strspn($this->data, $chars, $this->position)) |
|
3055
|
|
|
{ |
|
3056
|
|
|
$data = substr($this->data, $this->position, $len); |
|
3057
|
|
|
$this->consumed .= $data; |
|
3058
|
|
|
$this->position += $len; |
|
3059
|
|
|
return $data; |
|
3060
|
|
|
} |
|
3061
|
|
|
else |
|
3062
|
|
|
{ |
|
3063
|
|
|
return false; |
|
3064
|
|
|
} |
|
3065
|
|
|
} |
|
3066
|
|
|
|
|
3067
|
|
|
public function unconsume() |
|
3068
|
|
|
{ |
|
3069
|
|
|
$this->consumed = substr($this->consumed, 0, -1); |
|
3070
|
|
|
$this->position--; |
|
3071
|
|
|
} |
|
3072
|
|
|
|
|
3073
|
|
|
public function entity() |
|
3074
|
|
|
{ |
|
3075
|
|
|
switch ($this->consume()) |
|
3076
|
|
|
{ |
|
3077
|
|
|
case "\x09": |
|
3078
|
|
|
case "\x0A": |
|
3079
|
|
|
case "\x0B": |
|
3080
|
|
|
case "\x0B": |
|
3081
|
|
|
case "\x0C": |
|
3082
|
|
|
case "\x20": |
|
3083
|
|
|
case "\x3C": |
|
3084
|
|
|
case "\x26": |
|
3085
|
|
|
case false: |
|
3086
|
|
|
break; |
|
3087
|
|
|
case "\x23": |
|
3088
|
|
|
switch ($this->consume()) |
|
3089
|
|
|
{ |
|
3090
|
|
|
case "\x78": |
|
3091
|
|
|
case "\x58": |
|
3092
|
|
|
$range = '0123456789ABCDEFabcdef'; |
|
3093
|
|
|
$hex = true; |
|
3094
|
|
|
break; |
|
3095
|
|
|
default: |
|
3096
|
|
|
$range = '0123456789'; |
|
3097
|
|
|
$hex = false; |
|
3098
|
|
|
$this->unconsume(); |
|
3099
|
|
|
break; |
|
3100
|
|
|
} |
|
3101
|
|
|
if ($codepoint = $this->consume_range($range)) |
|
3102
|
|
|
{ |
|
3103
|
|
|
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"); |
|
3104
|
|
|
if ($hex) |
|
3105
|
|
|
{ |
|
3106
|
|
|
$codepoint = hexdec($codepoint); |
|
3107
|
|
|
} |
|
3108
|
|
|
else |
|
3109
|
|
|
{ |
|
3110
|
|
|
$codepoint = intval($codepoint); |
|
3111
|
|
|
} |
|
3112
|
|
|
if (isset($windows_1252_specials[$codepoint])) |
|
3113
|
|
|
{ |
|
3114
|
|
|
$replacement = $windows_1252_specials[$codepoint]; |
|
3115
|
|
|
} |
|
3116
|
|
|
else |
|
3117
|
|
|
{ |
|
3118
|
|
|
$replacement = SimplePie_Misc::codepoint_to_utf8($codepoint); |
|
3119
|
|
|
} |
|
3120
|
|
|
if (!in_array($this->consume(), array(';', false), true)) |
|
3121
|
|
|
{ |
|
3122
|
|
|
$this->unconsume(); |
|
3123
|
|
|
} |
|
3124
|
|
|
$consumed_length = strlen($this->consumed); |
|
3125
|
|
|
$this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length); |
|
3126
|
|
|
$this->position += strlen($replacement) - $consumed_length; |
|
3127
|
|
|
} |
|
3128
|
|
|
break; |
|
3129
|
|
|
default: |
|
3130
|
|
|
static $entities = array( |
|
3131
|
|
|
'Aacute' => "\xC3\x81", |
|
3132
|
|
|
'aacute' => "\xC3\xA1", |
|
3133
|
|
|
'Aacute;' => "\xC3\x81", |
|
3134
|
|
|
'aacute;' => "\xC3\xA1", |
|
3135
|
|
|
'Acirc' => "\xC3\x82", |
|
3136
|
|
|
'acirc' => "\xC3\xA2", |
|
3137
|
|
|
'Acirc;' => "\xC3\x82", |
|
3138
|
|
|
'acirc;' => "\xC3\xA2", |
|
3139
|
|
|
'acute' => "\xC2\xB4", |
|
3140
|
|
|
'acute;' => "\xC2\xB4", |
|
3141
|
|
|
'AElig' => "\xC3\x86", |
|
3142
|
|
|
'aelig' => "\xC3\xA6", |
|
3143
|
|
|
'AElig;' => "\xC3\x86", |
|
3144
|
|
|
'aelig;' => "\xC3\xA6", |
|
3145
|
|
|
'Agrave' => "\xC3\x80", |
|
3146
|
|
|
'agrave' => "\xC3\xA0", |
|
3147
|
|
|
'Agrave;' => "\xC3\x80", |
|
3148
|
|
|
'agrave;' => "\xC3\xA0", |
|
3149
|
|
|
'alefsym;' => "\xE2\x84\xB5", |
|
3150
|
|
|
'Alpha;' => "\xCE\x91", |
|
3151
|
|
|
'alpha;' => "\xCE\xB1", |
|
3152
|
|
|
'AMP' => "\x26", |
|
3153
|
|
|
'amp' => "\x26", |
|
3154
|
|
|
'AMP;' => "\x26", |
|
3155
|
|
|
'amp;' => "\x26", |
|
3156
|
|
|
'and;' => "\xE2\x88\xA7", |
|
3157
|
|
|
'ang;' => "\xE2\x88\xA0", |
|
3158
|
|
|
'apos;' => "\x27", |
|
3159
|
|
|
'Aring' => "\xC3\x85", |
|
3160
|
|
|
'aring' => "\xC3\xA5", |
|
3161
|
|
|
'Aring;' => "\xC3\x85", |
|
3162
|
|
|
'aring;' => "\xC3\xA5", |
|
3163
|
|
|
'asymp;' => "\xE2\x89\x88", |
|
3164
|
|
|
'Atilde' => "\xC3\x83", |
|
3165
|
|
|
'atilde' => "\xC3\xA3", |
|
3166
|
|
|
'Atilde;' => "\xC3\x83", |
|
3167
|
|
|
'atilde;' => "\xC3\xA3", |
|
3168
|
|
|
'Auml' => "\xC3\x84", |
|
3169
|
|
|
'auml' => "\xC3\xA4", |
|
3170
|
|
|
'Auml;' => "\xC3\x84", |
|
3171
|
|
|
'auml;' => "\xC3\xA4", |
|
3172
|
|
|
'bdquo;' => "\xE2\x80\x9E", |
|
3173
|
|
|
'Beta;' => "\xCE\x92", |
|
3174
|
|
|
'beta;' => "\xCE\xB2", |
|
3175
|
|
|
'brvbar' => "\xC2\xA6", |
|
3176
|
|
|
'brvbar;' => "\xC2\xA6", |
|
3177
|
|
|
'bull;' => "\xE2\x80\xA2", |
|
3178
|
|
|
'cap;' => "\xE2\x88\xA9", |
|
3179
|
|
|
'Ccedil' => "\xC3\x87", |
|
3180
|
|
|
'ccedil' => "\xC3\xA7", |
|
3181
|
|
|
'Ccedil;' => "\xC3\x87", |
|
3182
|
|
|
'ccedil;' => "\xC3\xA7", |
|
3183
|
|
|
'cedil' => "\xC2\xB8", |
|
3184
|
|
|
'cedil;' => "\xC2\xB8", |
|
3185
|
|
|
'cent' => "\xC2\xA2", |
|
3186
|
|
|
'cent;' => "\xC2\xA2", |
|
3187
|
|
|
'Chi;' => "\xCE\xA7", |
|
3188
|
|
|
'chi;' => "\xCF\x87", |
|
3189
|
|
|
'circ;' => "\xCB\x86", |
|
3190
|
|
|
'clubs;' => "\xE2\x99\xA3", |
|
3191
|
|
|
'cong;' => "\xE2\x89\x85", |
|
3192
|
|
|
'COPY' => "\xC2\xA9", |
|
3193
|
|
|
'copy' => "\xC2\xA9", |
|
3194
|
|
|
'COPY;' => "\xC2\xA9", |
|
3195
|
|
|
'copy;' => "\xC2\xA9", |
|
3196
|
|
|
'crarr;' => "\xE2\x86\xB5", |
|
3197
|
|
|
'cup;' => "\xE2\x88\xAA", |
|
3198
|
|
|
'curren' => "\xC2\xA4", |
|
3199
|
|
|
'curren;' => "\xC2\xA4", |
|
3200
|
|
|
'Dagger;' => "\xE2\x80\xA1", |
|
3201
|
|
|
'dagger;' => "\xE2\x80\xA0", |
|
3202
|
|
|
'dArr;' => "\xE2\x87\x93", |
|
3203
|
|
|
'darr;' => "\xE2\x86\x93", |
|
3204
|
|
|
'deg' => "\xC2\xB0", |
|
3205
|
|
|
'deg;' => "\xC2\xB0", |
|
3206
|
|
|
'Delta;' => "\xCE\x94", |
|
3207
|
|
|
'delta;' => "\xCE\xB4", |
|
3208
|
|
|
'diams;' => "\xE2\x99\xA6", |
|
3209
|
|
|
'divide' => "\xC3\xB7", |
|
3210
|
|
|
'divide;' => "\xC3\xB7", |
|
3211
|
|
|
'Eacute' => "\xC3\x89", |
|
3212
|
|
|
'eacute' => "\xC3\xA9", |
|
3213
|
|
|
'Eacute;' => "\xC3\x89", |
|
3214
|
|
|
'eacute;' => "\xC3\xA9", |
|
3215
|
|
|
'Ecirc' => "\xC3\x8A", |
|
3216
|
|
|
'ecirc' => "\xC3\xAA", |
|
3217
|
|
|
'Ecirc;' => "\xC3\x8A", |
|
3218
|
|
|
'ecirc;' => "\xC3\xAA", |
|
3219
|
|
|
'Egrave' => "\xC3\x88", |
|
3220
|
|
|
'egrave' => "\xC3\xA8", |
|
3221
|
|
|
'Egrave;' => "\xC3\x88", |
|
3222
|
|
|
'egrave;' => "\xC3\xA8", |
|
3223
|
|
|
'empty;' => "\xE2\x88\x85", |
|
3224
|
|
|
'emsp;' => "\xE2\x80\x83", |
|
3225
|
|
|
'ensp;' => "\xE2\x80\x82", |
|
3226
|
|
|
'Epsilon;' => "\xCE\x95", |
|
3227
|
|
|
'epsilon;' => "\xCE\xB5", |
|
3228
|
|
|
'equiv;' => "\xE2\x89\xA1", |
|
3229
|
|
|
'Eta;' => "\xCE\x97", |
|
3230
|
|
|
'eta;' => "\xCE\xB7", |
|
3231
|
|
|
'ETH' => "\xC3\x90", |
|
3232
|
|
|
'eth' => "\xC3\xB0", |
|
3233
|
|
|
'ETH;' => "\xC3\x90", |
|
3234
|
|
|
'eth;' => "\xC3\xB0", |
|
3235
|
|
|
'Euml' => "\xC3\x8B", |
|
3236
|
|
|
'euml' => "\xC3\xAB", |
|
3237
|
|
|
'Euml;' => "\xC3\x8B", |
|
3238
|
|
|
'euml;' => "\xC3\xAB", |
|
3239
|
|
|
'euro;' => "\xE2\x82\xAC", |
|
3240
|
|
|
'exist;' => "\xE2\x88\x83", |
|
3241
|
|
|
'fnof;' => "\xC6\x92", |
|
3242
|
|
|
'forall;' => "\xE2\x88\x80", |
|
3243
|
|
|
'frac12' => "\xC2\xBD", |
|
3244
|
|
|
'frac12;' => "\xC2\xBD", |
|
3245
|
|
|
'frac14' => "\xC2\xBC", |
|
3246
|
|
|
'frac14;' => "\xC2\xBC", |
|
3247
|
|
|
'frac34' => "\xC2\xBE", |
|
3248
|
|
|
'frac34;' => "\xC2\xBE", |
|
3249
|
|
|
'frasl;' => "\xE2\x81\x84", |
|
3250
|
|
|
'Gamma;' => "\xCE\x93", |
|
3251
|
|
|
'gamma;' => "\xCE\xB3", |
|
3252
|
|
|
'ge;' => "\xE2\x89\xA5", |
|
3253
|
|
|
'GT' => "\x3E", |
|
3254
|
|
|
'gt' => "\x3E", |
|
3255
|
|
|
'GT;' => "\x3E", |
|
3256
|
|
|
'gt;' => "\x3E", |
|
3257
|
|
|
'hArr;' => "\xE2\x87\x94", |
|
3258
|
|
|
'harr;' => "\xE2\x86\x94", |
|
3259
|
|
|
'hearts;' => "\xE2\x99\xA5", |
|
3260
|
|
|
'hellip;' => "\xE2\x80\xA6", |
|
3261
|
|
|
'Iacute' => "\xC3\x8D", |
|
3262
|
|
|
'iacute' => "\xC3\xAD", |
|
3263
|
|
|
'Iacute;' => "\xC3\x8D", |
|
3264
|
|
|
'iacute;' => "\xC3\xAD", |
|
3265
|
|
|
'Icirc' => "\xC3\x8E", |
|
3266
|
|
|
'icirc' => "\xC3\xAE", |
|
3267
|
|
|
'Icirc;' => "\xC3\x8E", |
|
3268
|
|
|
'icirc;' => "\xC3\xAE", |
|
3269
|
|
|
'iexcl' => "\xC2\xA1", |
|
3270
|
|
|
'iexcl;' => "\xC2\xA1", |
|
3271
|
|
|
'Igrave' => "\xC3\x8C", |
|
3272
|
|
|
'igrave' => "\xC3\xAC", |
|
3273
|
|
|
'Igrave;' => "\xC3\x8C", |
|
3274
|
|
|
'igrave;' => "\xC3\xAC", |
|
3275
|
|
|
'image;' => "\xE2\x84\x91", |
|
3276
|
|
|
'infin;' => "\xE2\x88\x9E", |
|
3277
|
|
|
'int;' => "\xE2\x88\xAB", |
|
3278
|
|
|
'Iota;' => "\xCE\x99", |
|
3279
|
|
|
'iota;' => "\xCE\xB9", |
|
3280
|
|
|
'iquest' => "\xC2\xBF", |
|
3281
|
|
|
'iquest;' => "\xC2\xBF", |
|
3282
|
|
|
'isin;' => "\xE2\x88\x88", |
|
3283
|
|
|
'Iuml' => "\xC3\x8F", |
|
3284
|
|
|
'iuml' => "\xC3\xAF", |
|
3285
|
|
|
'Iuml;' => "\xC3\x8F", |
|
3286
|
|
|
'iuml;' => "\xC3\xAF", |
|
3287
|
|
|
'Kappa;' => "\xCE\x9A", |
|
3288
|
|
|
'kappa;' => "\xCE\xBA", |
|
3289
|
|
|
'Lambda;' => "\xCE\x9B", |
|
3290
|
|
|
'lambda;' => "\xCE\xBB", |
|
3291
|
|
|
'lang;' => "\xE3\x80\x88", |
|
3292
|
|
|
'laquo' => "\xC2\xAB", |
|
3293
|
|
|
'laquo;' => "\xC2\xAB", |
|
3294
|
|
|
'lArr;' => "\xE2\x87\x90", |
|
3295
|
|
|
'larr;' => "\xE2\x86\x90", |
|
3296
|
|
|
'lceil;' => "\xE2\x8C\x88", |
|
3297
|
|
|
'ldquo;' => "\xE2\x80\x9C", |
|
3298
|
|
|
'le;' => "\xE2\x89\xA4", |
|
3299
|
|
|
'lfloor;' => "\xE2\x8C\x8A", |
|
3300
|
|
|
'lowast;' => "\xE2\x88\x97", |
|
3301
|
|
|
'loz;' => "\xE2\x97\x8A", |
|
3302
|
|
|
'lrm;' => "\xE2\x80\x8E", |
|
3303
|
|
|
'lsaquo;' => "\xE2\x80\xB9", |
|
3304
|
|
|
'lsquo;' => "\xE2\x80\x98", |
|
3305
|
|
|
'LT' => "\x3C", |
|
3306
|
|
|
'lt' => "\x3C", |
|
3307
|
|
|
'LT;' => "\x3C", |
|
3308
|
|
|
'lt;' => "\x3C", |
|
3309
|
|
|
'macr' => "\xC2\xAF", |
|
3310
|
|
|
'macr;' => "\xC2\xAF", |
|
3311
|
|
|
'mdash;' => "\xE2\x80\x94", |
|
3312
|
|
|
'micro' => "\xC2\xB5", |
|
3313
|
|
|
'micro;' => "\xC2\xB5", |
|
3314
|
|
|
'middot' => "\xC2\xB7", |
|
3315
|
|
|
'middot;' => "\xC2\xB7", |
|
3316
|
|
|
'minus;' => "\xE2\x88\x92", |
|
3317
|
|
|
'Mu;' => "\xCE\x9C", |
|
3318
|
|
|
'mu;' => "\xCE\xBC", |
|
3319
|
|
|
'nabla;' => "\xE2\x88\x87", |
|
3320
|
|
|
'nbsp' => "\xC2\xA0", |
|
3321
|
|
|
'nbsp;' => "\xC2\xA0", |
|
3322
|
|
|
'ndash;' => "\xE2\x80\x93", |
|
3323
|
|
|
'ne;' => "\xE2\x89\xA0", |
|
3324
|
|
|
'ni;' => "\xE2\x88\x8B", |
|
3325
|
|
|
'not' => "\xC2\xAC", |
|
3326
|
|
|
'not;' => "\xC2\xAC", |
|
3327
|
|
|
'notin;' => "\xE2\x88\x89", |
|
3328
|
|
|
'nsub;' => "\xE2\x8A\x84", |
|
3329
|
|
|
'Ntilde' => "\xC3\x91", |
|
3330
|
|
|
'ntilde' => "\xC3\xB1", |
|
3331
|
|
|
'Ntilde;' => "\xC3\x91", |
|
3332
|
|
|
'ntilde;' => "\xC3\xB1", |
|
3333
|
|
|
'Nu;' => "\xCE\x9D", |
|
3334
|
|
|
'nu;' => "\xCE\xBD", |
|
3335
|
|
|
'Oacute' => "\xC3\x93", |
|
3336
|
|
|
'oacute' => "\xC3\xB3", |
|
3337
|
|
|
'Oacute;' => "\xC3\x93", |
|
3338
|
|
|
'oacute;' => "\xC3\xB3", |
|
3339
|
|
|
'Ocirc' => "\xC3\x94", |
|
3340
|
|
|
'ocirc' => "\xC3\xB4", |
|
3341
|
|
|
'Ocirc;' => "\xC3\x94", |
|
3342
|
|
|
'ocirc;' => "\xC3\xB4", |
|
3343
|
|
|
'OElig;' => "\xC5\x92", |
|
3344
|
|
|
'oelig;' => "\xC5\x93", |
|
3345
|
|
|
'Ograve' => "\xC3\x92", |
|
3346
|
|
|
'ograve' => "\xC3\xB2", |
|
3347
|
|
|
'Ograve;' => "\xC3\x92", |
|
3348
|
|
|
'ograve;' => "\xC3\xB2", |
|
3349
|
|
|
'oline;' => "\xE2\x80\xBE", |
|
3350
|
|
|
'Omega;' => "\xCE\xA9", |
|
3351
|
|
|
'omega;' => "\xCF\x89", |
|
3352
|
|
|
'Omicron;' => "\xCE\x9F", |
|
3353
|
|
|
'omicron;' => "\xCE\xBF", |
|
3354
|
|
|
'oplus;' => "\xE2\x8A\x95", |
|
3355
|
|
|
'or;' => "\xE2\x88\xA8", |
|
3356
|
|
|
'ordf' => "\xC2\xAA", |
|
3357
|
|
|
'ordf;' => "\xC2\xAA", |
|
3358
|
|
|
'ordm' => "\xC2\xBA", |
|
3359
|
|
|
'ordm;' => "\xC2\xBA", |
|
3360
|
|
|
'Oslash' => "\xC3\x98", |
|
3361
|
|
|
'oslash' => "\xC3\xB8", |
|
3362
|
|
|
'Oslash;' => "\xC3\x98", |
|
3363
|
|
|
'oslash;' => "\xC3\xB8", |
|
3364
|
|
|
'Otilde' => "\xC3\x95", |
|
3365
|
|
|
'otilde' => "\xC3\xB5", |
|
3366
|
|
|
'Otilde;' => "\xC3\x95", |
|
3367
|
|
|
'otilde;' => "\xC3\xB5", |
|
3368
|
|
|
'otimes;' => "\xE2\x8A\x97", |
|
3369
|
|
|
'Ouml' => "\xC3\x96", |
|
3370
|
|
|
'ouml' => "\xC3\xB6", |
|
3371
|
|
|
'Ouml;' => "\xC3\x96", |
|
3372
|
|
|
'ouml;' => "\xC3\xB6", |
|
3373
|
|
|
'para' => "\xC2\xB6", |
|
3374
|
|
|
'para;' => "\xC2\xB6", |
|
3375
|
|
|
'part;' => "\xE2\x88\x82", |
|
3376
|
|
|
'permil;' => "\xE2\x80\xB0", |
|
3377
|
|
|
'perp;' => "\xE2\x8A\xA5", |
|
3378
|
|
|
'Phi;' => "\xCE\xA6", |
|
3379
|
|
|
'phi;' => "\xCF\x86", |
|
3380
|
|
|
'Pi;' => "\xCE\xA0", |
|
3381
|
|
|
'pi;' => "\xCF\x80", |
|
3382
|
|
|
'piv;' => "\xCF\x96", |
|
3383
|
|
|
'plusmn' => "\xC2\xB1", |
|
3384
|
|
|
'plusmn;' => "\xC2\xB1", |
|
3385
|
|
|
'pound' => "\xC2\xA3", |
|
3386
|
|
|
'pound;' => "\xC2\xA3", |
|
3387
|
|
|
'Prime;' => "\xE2\x80\xB3", |
|
3388
|
|
|
'prime;' => "\xE2\x80\xB2", |
|
3389
|
|
|
'prod;' => "\xE2\x88\x8F", |
|
3390
|
|
|
'prop;' => "\xE2\x88\x9D", |
|
3391
|
|
|
'Psi;' => "\xCE\xA8", |
|
3392
|
|
|
'psi;' => "\xCF\x88", |
|
3393
|
|
|
'QUOT' => "\x22", |
|
3394
|
|
|
'quot' => "\x22", |
|
3395
|
|
|
'QUOT;' => "\x22", |
|
3396
|
|
|
'quot;' => "\x22", |
|
3397
|
|
|
'radic;' => "\xE2\x88\x9A", |
|
3398
|
|
|
'rang;' => "\xE3\x80\x89", |
|
3399
|
|
|
'raquo' => "\xC2\xBB", |
|
3400
|
|
|
'raquo;' => "\xC2\xBB", |
|
3401
|
|
|
'rArr;' => "\xE2\x87\x92", |
|
3402
|
|
|
'rarr;' => "\xE2\x86\x92", |
|
3403
|
|
|
'rceil;' => "\xE2\x8C\x89", |
|
3404
|
|
|
'rdquo;' => "\xE2\x80\x9D", |
|
3405
|
|
|
'real;' => "\xE2\x84\x9C", |
|
3406
|
|
|
'REG' => "\xC2\xAE", |
|
3407
|
|
|
'reg' => "\xC2\xAE", |
|
3408
|
|
|
'REG;' => "\xC2\xAE", |
|
3409
|
|
|
'reg;' => "\xC2\xAE", |
|
3410
|
|
|
'rfloor;' => "\xE2\x8C\x8B", |
|
3411
|
|
|
'Rho;' => "\xCE\xA1", |
|
3412
|
|
|
'rho;' => "\xCF\x81", |
|
3413
|
|
|
'rlm;' => "\xE2\x80\x8F", |
|
3414
|
|
|
'rsaquo;' => "\xE2\x80\xBA", |
|
3415
|
|
|
'rsquo;' => "\xE2\x80\x99", |
|
3416
|
|
|
'sbquo;' => "\xE2\x80\x9A", |
|
3417
|
|
|
'Scaron;' => "\xC5\xA0", |
|
3418
|
|
|
'scaron;' => "\xC5\xA1", |
|
3419
|
|
|
'sdot;' => "\xE2\x8B\x85", |
|
3420
|
|
|
'sect' => "\xC2\xA7", |
|
3421
|
|
|
'sect;' => "\xC2\xA7", |
|
3422
|
|
|
'shy' => "\xC2\xAD", |
|
3423
|
|
|
'shy;' => "\xC2\xAD", |
|
3424
|
|
|
'Sigma;' => "\xCE\xA3", |
|
3425
|
|
|
'sigma;' => "\xCF\x83", |
|
3426
|
|
|
'sigmaf;' => "\xCF\x82", |
|
3427
|
|
|
'sim;' => "\xE2\x88\xBC", |
|
3428
|
|
|
'spades;' => "\xE2\x99\xA0", |
|
3429
|
|
|
'sub;' => "\xE2\x8A\x82", |
|
3430
|
|
|
'sube;' => "\xE2\x8A\x86", |
|
3431
|
|
|
'sum;' => "\xE2\x88\x91", |
|
3432
|
|
|
'sup;' => "\xE2\x8A\x83", |
|
3433
|
|
|
'sup1' => "\xC2\xB9", |
|
3434
|
|
|
'sup1;' => "\xC2\xB9", |
|
3435
|
|
|
'sup2' => "\xC2\xB2", |
|
3436
|
|
|
'sup2;' => "\xC2\xB2", |
|
3437
|
|
|
'sup3' => "\xC2\xB3", |
|
3438
|
|
|
'sup3;' => "\xC2\xB3", |
|
3439
|
|
|
'supe;' => "\xE2\x8A\x87", |
|
3440
|
|
|
'szlig' => "\xC3\x9F", |
|
3441
|
|
|
'szlig;' => "\xC3\x9F", |
|
3442
|
|
|
'Tau;' => "\xCE\xA4", |
|
3443
|
|
|
'tau;' => "\xCF\x84", |
|
3444
|
|
|
'there4;' => "\xE2\x88\xB4", |
|
3445
|
|
|
'Theta;' => "\xCE\x98", |
|
3446
|
|
|
'theta;' => "\xCE\xB8", |
|
3447
|
|
|
'thetasym;' => "\xCF\x91", |
|
3448
|
|
|
'thinsp;' => "\xE2\x80\x89", |
|
3449
|
|
|
'THORN' => "\xC3\x9E", |
|
3450
|
|
|
'thorn' => "\xC3\xBE", |
|
3451
|
|
|
'THORN;' => "\xC3\x9E", |
|
3452
|
|
|
'thorn;' => "\xC3\xBE", |
|
3453
|
|
|
'tilde;' => "\xCB\x9C", |
|
3454
|
|
|
'times' => "\xC3\x97", |
|
3455
|
|
|
'times;' => "\xC3\x97", |
|
3456
|
|
|
'TRADE;' => "\xE2\x84\xA2", |
|
3457
|
|
|
'trade;' => "\xE2\x84\xA2", |
|
3458
|
|
|
'Uacute' => "\xC3\x9A", |
|
3459
|
|
|
'uacute' => "\xC3\xBA", |
|
3460
|
|
|
'Uacute;' => "\xC3\x9A", |
|
3461
|
|
|
'uacute;' => "\xC3\xBA", |
|
3462
|
|
|
'uArr;' => "\xE2\x87\x91", |
|
3463
|
|
|
'uarr;' => "\xE2\x86\x91", |
|
3464
|
|
|
'Ucirc' => "\xC3\x9B", |
|
3465
|
|
|
'ucirc' => "\xC3\xBB", |
|
3466
|
|
|
'Ucirc;' => "\xC3\x9B", |
|
3467
|
|
|
'ucirc;' => "\xC3\xBB", |
|
3468
|
|
|
'Ugrave' => "\xC3\x99", |
|
3469
|
|
|
'ugrave' => "\xC3\xB9", |
|
3470
|
|
|
'Ugrave;' => "\xC3\x99", |
|
3471
|
|
|
'ugrave;' => "\xC3\xB9", |
|
3472
|
|
|
'uml' => "\xC2\xA8", |
|
3473
|
|
|
'uml;' => "\xC2\xA8", |
|
3474
|
|
|
'upsih;' => "\xCF\x92", |
|
3475
|
|
|
'Upsilon;' => "\xCE\xA5", |
|
3476
|
|
|
'upsilon;' => "\xCF\x85", |
|
3477
|
|
|
'Uuml' => "\xC3\x9C", |
|
3478
|
|
|
'uuml' => "\xC3\xBC", |
|
3479
|
|
|
'Uuml;' => "\xC3\x9C", |
|
3480
|
|
|
'uuml;' => "\xC3\xBC", |
|
3481
|
|
|
'weierp;' => "\xE2\x84\x98", |
|
3482
|
|
|
'Xi;' => "\xCE\x9E", |
|
3483
|
|
|
'xi;' => "\xCE\xBE", |
|
3484
|
|
|
'Yacute' => "\xC3\x9D", |
|
3485
|
|
|
'yacute' => "\xC3\xBD", |
|
3486
|
|
|
'Yacute;' => "\xC3\x9D", |
|
3487
|
|
|
'yacute;' => "\xC3\xBD", |
|
3488
|
|
|
'yen' => "\xC2\xA5", |
|
3489
|
|
|
'yen;' => "\xC2\xA5", |
|
3490
|
|
|
'yuml' => "\xC3\xBF", |
|
3491
|
|
|
'Yuml;' => "\xC5\xB8", |
|
3492
|
|
|
'yuml;' => "\xC3\xBF", |
|
3493
|
|
|
'Zeta;' => "\xCE\x96", |
|
3494
|
|
|
'zeta;' => "\xCE\xB6", |
|
3495
|
|
|
'zwj;' => "\xE2\x80\x8D", |
|
3496
|
|
|
'zwnj;' => "\xE2\x80\x8C" |
|
3497
|
|
|
); |
|
3498
|
|
|
for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++) |
|
3499
|
|
|
{ |
|
3500
|
|
|
$consumed = substr($this->consumed, 1); |
|
3501
|
|
|
if (isset($entities[$consumed])) |
|
3502
|
|
|
{ |
|
3503
|
|
|
$match = $consumed; |
|
3504
|
|
|
} |
|
3505
|
|
|
} |
|
3506
|
|
|
if ($match !== null) |
|
3507
|
|
|
{ |
|
3508
|
|
|
$this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1); |
|
3509
|
|
|
$this->position += strlen($entities[$match]) - strlen($consumed) - 1; |
|
3510
|
|
|
} |
|
3511
|
|
|
break; |
|
3512
|
|
|
} |
|
3513
|
|
|
} |
|
3514
|
|
|
} |
|
3515
|
|
|
class SimplePie_Enclosure |
|
3516
|
|
|
{ |
|
3517
|
|
|
|
|
3518
|
|
|
var $bitrate; |
|
3519
|
|
|
|
|
3520
|
|
|
var $captions; |
|
3521
|
|
|
|
|
3522
|
|
|
var $categories; |
|
3523
|
|
|
|
|
3524
|
|
|
var $channels; |
|
3525
|
|
|
|
|
3526
|
|
|
var $copyright; |
|
3527
|
|
|
|
|
3528
|
|
|
var $credits; |
|
3529
|
|
|
|
|
3530
|
|
|
var $description; |
|
3531
|
|
|
|
|
3532
|
|
|
var $duration; |
|
3533
|
|
|
|
|
3534
|
|
|
var $expression; |
|
3535
|
|
|
|
|
3536
|
|
|
var $framerate; |
|
3537
|
|
|
|
|
3538
|
|
|
var $handler; |
|
3539
|
|
|
|
|
3540
|
|
|
var $hashes; |
|
3541
|
|
|
|
|
3542
|
|
|
var $height; |
|
3543
|
|
|
|
|
3544
|
|
|
var $javascript; |
|
3545
|
|
|
|
|
3546
|
|
|
var $keywords; |
|
3547
|
|
|
|
|
3548
|
|
|
var $lang; |
|
3549
|
|
|
|
|
3550
|
|
|
var $length; |
|
3551
|
|
|
|
|
3552
|
|
|
var $link; |
|
3553
|
|
|
|
|
3554
|
|
|
var $medium; |
|
3555
|
|
|
|
|
3556
|
|
|
var $player; |
|
3557
|
|
|
|
|
3558
|
|
|
var $ratings; |
|
3559
|
|
|
|
|
3560
|
|
|
var $restrictions; |
|
3561
|
|
|
|
|
3562
|
|
|
var $samplingrate; |
|
3563
|
|
|
|
|
3564
|
|
|
var $thumbnails; |
|
3565
|
|
|
|
|
3566
|
|
|
var $title; |
|
3567
|
|
|
|
|
3568
|
|
|
var $type; |
|
3569
|
|
|
|
|
3570
|
|
|
var $width; |
|
3571
|
|
|
|
|
3572
|
|
|
public function __construct($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) |
|
3573
|
|
|
{ |
|
3574
|
|
|
$this->bitrate = $bitrate; |
|
3575
|
|
|
$this->captions = $captions; |
|
3576
|
|
|
$this->categories = $categories; |
|
3577
|
|
|
$this->channels = $channels; |
|
3578
|
|
|
$this->copyright = $copyright; |
|
3579
|
|
|
$this->credits = $credits; |
|
3580
|
|
|
$this->description = $description; |
|
3581
|
|
|
$this->duration = $duration; |
|
3582
|
|
|
$this->expression = $expression; |
|
3583
|
|
|
$this->framerate = $framerate; |
|
3584
|
|
|
$this->hashes = $hashes; |
|
3585
|
|
|
$this->height = $height; |
|
3586
|
|
|
$this->keywords = $keywords; |
|
3587
|
|
|
$this->lang = $lang; |
|
3588
|
|
|
$this->length = $length; |
|
3589
|
|
|
$this->link = $link; |
|
3590
|
|
|
$this->medium = $medium; |
|
3591
|
|
|
$this->player = $player; |
|
3592
|
|
|
$this->ratings = $ratings; |
|
3593
|
|
|
$this->restrictions = $restrictions; |
|
3594
|
|
|
$this->samplingrate = $samplingrate; |
|
3595
|
|
|
$this->thumbnails = $thumbnails; |
|
3596
|
|
|
$this->title = $title; |
|
3597
|
|
|
$this->type = $type; |
|
3598
|
|
|
$this->width = $width; |
|
3599
|
|
|
if (class_exists('idna_convert')) |
|
3600
|
|
|
{ |
|
3601
|
|
|
$idn = new idna_convert(); |
|
3602
|
|
|
$parsed = SimplePie_Misc::parse_url($link); |
|
3603
|
|
|
$this->link = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']); |
|
3604
|
|
|
} |
|
3605
|
|
|
$this->handler = $this->get_handler(); // Needs to load last |
|
3606
|
|
|
} |
|
3607
|
|
|
|
|
3608
|
|
|
public function __toString() |
|
3609
|
|
|
{ |
|
3610
|
|
|
// There is no $this->data here |
|
3611
|
|
|
return md5(serialize($this)); |
|
3612
|
|
|
} |
|
3613
|
|
|
|
|
3614
|
|
|
public function get_bitrate() |
|
3615
|
|
|
{ |
|
3616
|
|
|
if ($this->bitrate !== null) |
|
3617
|
|
|
{ |
|
3618
|
|
|
return $this->bitrate; |
|
3619
|
|
|
} |
|
3620
|
|
|
else |
|
3621
|
|
|
{ |
|
3622
|
|
|
return null; |
|
3623
|
|
|
} |
|
3624
|
|
|
} |
|
3625
|
|
|
|
|
3626
|
|
|
public function get_caption($key = 0) |
|
3627
|
|
|
{ |
|
3628
|
|
|
$captions = $this->get_captions(); |
|
3629
|
|
|
if (isset($captions[$key])) |
|
3630
|
|
|
{ |
|
3631
|
|
|
return $captions[$key]; |
|
3632
|
|
|
} |
|
3633
|
|
|
else |
|
3634
|
|
|
{ |
|
3635
|
|
|
return null; |
|
3636
|
|
|
} |
|
3637
|
|
|
} |
|
3638
|
|
|
|
|
3639
|
|
|
public function get_captions() |
|
3640
|
|
|
{ |
|
3641
|
|
|
if ($this->captions !== null) |
|
3642
|
|
|
{ |
|
3643
|
|
|
return $this->captions; |
|
3644
|
|
|
} |
|
3645
|
|
|
else |
|
3646
|
|
|
{ |
|
3647
|
|
|
return null; |
|
3648
|
|
|
} |
|
3649
|
|
|
} |
|
3650
|
|
|
|
|
3651
|
|
|
public function get_category($key = 0) |
|
3652
|
|
|
{ |
|
3653
|
|
|
$categories = $this->get_categories(); |
|
3654
|
|
|
if (isset($categories[$key])) |
|
3655
|
|
|
{ |
|
3656
|
|
|
return $categories[$key]; |
|
3657
|
|
|
} |
|
3658
|
|
|
else |
|
3659
|
|
|
{ |
|
3660
|
|
|
return null; |
|
3661
|
|
|
} |
|
3662
|
|
|
} |
|
3663
|
|
|
|
|
3664
|
|
|
public function get_categories() |
|
3665
|
|
|
{ |
|
3666
|
|
|
if ($this->categories !== null) |
|
3667
|
|
|
{ |
|
3668
|
|
|
return $this->categories; |
|
3669
|
|
|
} |
|
3670
|
|
|
else |
|
3671
|
|
|
{ |
|
3672
|
|
|
return null; |
|
3673
|
|
|
} |
|
3674
|
|
|
} |
|
3675
|
|
|
|
|
3676
|
|
|
public function get_channels() |
|
3677
|
|
|
{ |
|
3678
|
|
|
if ($this->channels !== null) |
|
3679
|
|
|
{ |
|
3680
|
|
|
return $this->channels; |
|
3681
|
|
|
} |
|
3682
|
|
|
else |
|
3683
|
|
|
{ |
|
3684
|
|
|
return null; |
|
3685
|
|
|
} |
|
3686
|
|
|
} |
|
3687
|
|
|
|
|
3688
|
|
|
public function get_copyright() |
|
3689
|
|
|
{ |
|
3690
|
|
|
if ($this->copyright !== null) |
|
3691
|
|
|
{ |
|
3692
|
|
|
return $this->copyright; |
|
3693
|
|
|
} |
|
3694
|
|
|
else |
|
3695
|
|
|
{ |
|
3696
|
|
|
return null; |
|
3697
|
|
|
} |
|
3698
|
|
|
} |
|
3699
|
|
|
|
|
3700
|
|
|
public function get_credit($key = 0) |
|
3701
|
|
|
{ |
|
3702
|
|
|
$credits = $this->get_credits(); |
|
3703
|
|
|
if (isset($credits[$key])) |
|
3704
|
|
|
{ |
|
3705
|
|
|
return $credits[$key]; |
|
3706
|
|
|
} |
|
3707
|
|
|
else |
|
3708
|
|
|
{ |
|
3709
|
|
|
return null; |
|
3710
|
|
|
} |
|
3711
|
|
|
} |
|
3712
|
|
|
|
|
3713
|
|
|
public function get_credits() |
|
3714
|
|
|
{ |
|
3715
|
|
|
if ($this->credits !== null) |
|
3716
|
|
|
{ |
|
3717
|
|
|
return $this->credits; |
|
3718
|
|
|
} |
|
3719
|
|
|
else |
|
3720
|
|
|
{ |
|
3721
|
|
|
return null; |
|
3722
|
|
|
} |
|
3723
|
|
|
} |
|
3724
|
|
|
|
|
3725
|
|
|
public function get_description() |
|
3726
|
|
|
{ |
|
3727
|
|
|
if ($this->description !== null) |
|
3728
|
|
|
{ |
|
3729
|
|
|
return $this->description; |
|
3730
|
|
|
} |
|
3731
|
|
|
else |
|
3732
|
|
|
{ |
|
3733
|
|
|
return null; |
|
3734
|
|
|
} |
|
3735
|
|
|
} |
|
3736
|
|
|
|
|
3737
|
|
|
public function get_duration($convert = false) |
|
3738
|
|
|
{ |
|
3739
|
|
|
if ($this->duration !== null) |
|
3740
|
|
|
{ |
|
3741
|
|
|
if ($convert) |
|
3742
|
|
|
{ |
|
3743
|
|
|
$time = SimplePie_Misc::time_hms($this->duration); |
|
3744
|
|
|
return $time; |
|
3745
|
|
|
} |
|
3746
|
|
|
else |
|
3747
|
|
|
{ |
|
3748
|
|
|
return $this->duration; |
|
3749
|
|
|
} |
|
3750
|
|
|
} |
|
3751
|
|
|
else |
|
3752
|
|
|
{ |
|
3753
|
|
|
return null; |
|
3754
|
|
|
} |
|
3755
|
|
|
} |
|
3756
|
|
|
|
|
3757
|
|
|
public function get_expression() |
|
3758
|
|
|
{ |
|
3759
|
|
|
if ($this->expression !== null) |
|
3760
|
|
|
{ |
|
3761
|
|
|
return $this->expression; |
|
3762
|
|
|
} |
|
3763
|
|
|
else |
|
3764
|
|
|
{ |
|
3765
|
|
|
return 'full'; |
|
3766
|
|
|
} |
|
3767
|
|
|
} |
|
3768
|
|
|
|
|
3769
|
|
|
public function get_extension() |
|
3770
|
|
|
{ |
|
3771
|
|
|
if ($this->link !== null) |
|
3772
|
|
|
{ |
|
3773
|
|
|
$url = SimplePie_Misc::parse_url($this->link); |
|
3774
|
|
|
if ($url['path'] !== '') |
|
3775
|
|
|
{ |
|
3776
|
|
|
return pathinfo($url['path'], PATHINFO_EXTENSION); |
|
3777
|
|
|
} |
|
3778
|
|
|
} |
|
3779
|
|
|
return null; |
|
3780
|
|
|
} |
|
3781
|
|
|
|
|
3782
|
|
|
public function get_framerate() |
|
3783
|
|
|
{ |
|
3784
|
|
|
if ($this->framerate !== null) |
|
3785
|
|
|
{ |
|
3786
|
|
|
return $this->framerate; |
|
3787
|
|
|
} |
|
3788
|
|
|
else |
|
3789
|
|
|
{ |
|
3790
|
|
|
return null; |
|
3791
|
|
|
} |
|
3792
|
|
|
} |
|
3793
|
|
|
|
|
3794
|
|
|
public function get_handler() |
|
3795
|
|
|
{ |
|
3796
|
|
|
return $this->get_real_type(true); |
|
3797
|
|
|
} |
|
3798
|
|
|
|
|
3799
|
|
|
public function get_hash($key = 0) |
|
3800
|
|
|
{ |
|
3801
|
|
|
$hashes = $this->get_hashes(); |
|
3802
|
|
|
if (isset($hashes[$key])) |
|
3803
|
|
|
{ |
|
3804
|
|
|
return $hashes[$key]; |
|
3805
|
|
|
} |
|
3806
|
|
|
else |
|
3807
|
|
|
{ |
|
3808
|
|
|
return null; |
|
3809
|
|
|
} |
|
3810
|
|
|
} |
|
3811
|
|
|
|
|
3812
|
|
|
public function get_hashes() |
|
3813
|
|
|
{ |
|
3814
|
|
|
if ($this->hashes !== null) |
|
3815
|
|
|
{ |
|
3816
|
|
|
return $this->hashes; |
|
3817
|
|
|
} |
|
3818
|
|
|
else |
|
3819
|
|
|
{ |
|
3820
|
|
|
return null; |
|
3821
|
|
|
} |
|
3822
|
|
|
} |
|
3823
|
|
|
|
|
3824
|
|
|
public function get_height() |
|
3825
|
|
|
{ |
|
3826
|
|
|
if ($this->height !== null) |
|
3827
|
|
|
{ |
|
3828
|
|
|
return $this->height; |
|
3829
|
|
|
} |
|
3830
|
|
|
else |
|
3831
|
|
|
{ |
|
3832
|
|
|
return null; |
|
3833
|
|
|
} |
|
3834
|
|
|
} |
|
3835
|
|
|
|
|
3836
|
|
|
public function get_language() |
|
3837
|
|
|
{ |
|
3838
|
|
|
if ($this->lang !== null) |
|
3839
|
|
|
{ |
|
3840
|
|
|
return $this->lang; |
|
3841
|
|
|
} |
|
3842
|
|
|
else |
|
3843
|
|
|
{ |
|
3844
|
|
|
return null; |
|
3845
|
|
|
} |
|
3846
|
|
|
} |
|
3847
|
|
|
|
|
3848
|
|
|
public function get_keyword($key = 0) |
|
3849
|
|
|
{ |
|
3850
|
|
|
$keywords = $this->get_keywords(); |
|
3851
|
|
|
if (isset($keywords[$key])) |
|
3852
|
|
|
{ |
|
3853
|
|
|
return $keywords[$key]; |
|
3854
|
|
|
} |
|
3855
|
|
|
else |
|
3856
|
|
|
{ |
|
3857
|
|
|
return null; |
|
3858
|
|
|
} |
|
3859
|
|
|
} |
|
3860
|
|
|
|
|
3861
|
|
|
public function get_keywords() |
|
3862
|
|
|
{ |
|
3863
|
|
|
if ($this->keywords !== null) |
|
3864
|
|
|
{ |
|
3865
|
|
|
return $this->keywords; |
|
3866
|
|
|
} |
|
3867
|
|
|
else |
|
3868
|
|
|
{ |
|
3869
|
|
|
return null; |
|
3870
|
|
|
} |
|
3871
|
|
|
} |
|
3872
|
|
|
|
|
3873
|
|
|
public function get_length() |
|
3874
|
|
|
{ |
|
3875
|
|
|
if ($this->length !== null) |
|
3876
|
|
|
{ |
|
3877
|
|
|
return $this->length; |
|
3878
|
|
|
} |
|
3879
|
|
|
else |
|
3880
|
|
|
{ |
|
3881
|
|
|
return null; |
|
3882
|
|
|
} |
|
3883
|
|
|
} |
|
3884
|
|
|
|
|
3885
|
|
|
public function get_link() |
|
3886
|
|
|
{ |
|
3887
|
|
|
if ($this->link !== null) |
|
3888
|
|
|
{ |
|
3889
|
|
|
return urldecode($this->link); |
|
3890
|
|
|
} |
|
3891
|
|
|
else |
|
3892
|
|
|
{ |
|
3893
|
|
|
return null; |
|
3894
|
|
|
} |
|
3895
|
|
|
} |
|
3896
|
|
|
|
|
3897
|
|
|
public function get_medium() |
|
3898
|
|
|
{ |
|
3899
|
|
|
if ($this->medium !== null) |
|
3900
|
|
|
{ |
|
3901
|
|
|
return $this->medium; |
|
3902
|
|
|
} |
|
3903
|
|
|
else |
|
3904
|
|
|
{ |
|
3905
|
|
|
return null; |
|
3906
|
|
|
} |
|
3907
|
|
|
} |
|
3908
|
|
|
|
|
3909
|
|
|
public function get_player() |
|
3910
|
|
|
{ |
|
3911
|
|
|
if ($this->player !== null) |
|
3912
|
|
|
{ |
|
3913
|
|
|
return $this->player; |
|
3914
|
|
|
} |
|
3915
|
|
|
else |
|
3916
|
|
|
{ |
|
3917
|
|
|
return null; |
|
3918
|
|
|
} |
|
3919
|
|
|
} |
|
3920
|
|
|
|
|
3921
|
|
|
public function get_rating($key = 0) |
|
3922
|
|
|
{ |
|
3923
|
|
|
$ratings = $this->get_ratings(); |
|
3924
|
|
|
if (isset($ratings[$key])) |
|
3925
|
|
|
{ |
|
3926
|
|
|
return $ratings[$key]; |
|
3927
|
|
|
} |
|
3928
|
|
|
else |
|
3929
|
|
|
{ |
|
3930
|
|
|
return null; |
|
3931
|
|
|
} |
|
3932
|
|
|
} |
|
3933
|
|
|
|
|
3934
|
|
|
public function get_ratings() |
|
3935
|
|
|
{ |
|
3936
|
|
|
if ($this->ratings !== null) |
|
3937
|
|
|
{ |
|
3938
|
|
|
return $this->ratings; |
|
3939
|
|
|
} |
|
3940
|
|
|
else |
|
3941
|
|
|
{ |
|
3942
|
|
|
return null; |
|
3943
|
|
|
} |
|
3944
|
|
|
} |
|
3945
|
|
|
|
|
3946
|
|
|
public function get_restriction($key = 0) |
|
3947
|
|
|
{ |
|
3948
|
|
|
$restrictions = $this->get_restrictions(); |
|
3949
|
|
|
if (isset($restrictions[$key])) |
|
3950
|
|
|
{ |
|
3951
|
|
|
return $restrictions[$key]; |
|
3952
|
|
|
} |
|
3953
|
|
|
else |
|
3954
|
|
|
{ |
|
3955
|
|
|
return null; |
|
3956
|
|
|
} |
|
3957
|
|
|
} |
|
3958
|
|
|
|
|
3959
|
|
|
public function get_restrictions() |
|
3960
|
|
|
{ |
|
3961
|
|
|
if ($this->restrictions !== null) |
|
3962
|
|
|
{ |
|
3963
|
|
|
return $this->restrictions; |
|
3964
|
|
|
} |
|
3965
|
|
|
else |
|
3966
|
|
|
{ |
|
3967
|
|
|
return null; |
|
3968
|
|
|
} |
|
3969
|
|
|
} |
|
3970
|
|
|
|
|
3971
|
|
|
public function get_sampling_rate() |
|
3972
|
|
|
{ |
|
3973
|
|
|
if ($this->samplingrate !== null) |
|
3974
|
|
|
{ |
|
3975
|
|
|
return $this->samplingrate; |
|
3976
|
|
|
} |
|
3977
|
|
|
else |
|
3978
|
|
|
{ |
|
3979
|
|
|
return null; |
|
3980
|
|
|
} |
|
3981
|
|
|
} |
|
3982
|
|
|
|
|
3983
|
|
|
public function get_size() |
|
3984
|
|
|
{ |
|
3985
|
|
|
$length = $this->get_length(); |
|
3986
|
|
|
if ($length !== null) |
|
3987
|
|
|
{ |
|
3988
|
|
|
return round($length/1048576, 2); |
|
3989
|
|
|
} |
|
3990
|
|
|
else |
|
3991
|
|
|
{ |
|
3992
|
|
|
return null; |
|
3993
|
|
|
} |
|
3994
|
|
|
} |
|
3995
|
|
|
|
|
3996
|
|
|
public function get_thumbnail($key = 0) |
|
3997
|
|
|
{ |
|
3998
|
|
|
$thumbnails = $this->get_thumbnails(); |
|
3999
|
|
|
if (isset($thumbnails[$key])) |
|
4000
|
|
|
{ |
|
4001
|
|
|
return $thumbnails[$key]; |
|
4002
|
|
|
} |
|
4003
|
|
|
else |
|
4004
|
|
|
{ |
|
4005
|
|
|
return null; |
|
4006
|
|
|
} |
|
4007
|
|
|
} |
|
4008
|
|
|
|
|
4009
|
|
|
public function get_thumbnails() |
|
4010
|
|
|
{ |
|
4011
|
|
|
if ($this->thumbnails !== null) |
|
4012
|
|
|
{ |
|
4013
|
|
|
return $this->thumbnails; |
|
4014
|
|
|
} |
|
4015
|
|
|
else |
|
4016
|
|
|
{ |
|
4017
|
|
|
return null; |
|
4018
|
|
|
} |
|
4019
|
|
|
} |
|
4020
|
|
|
|
|
4021
|
|
|
public function get_title() |
|
4022
|
|
|
{ |
|
4023
|
|
|
if ($this->title !== null) |
|
4024
|
|
|
{ |
|
4025
|
|
|
return $this->title; |
|
4026
|
|
|
} |
|
4027
|
|
|
else |
|
4028
|
|
|
{ |
|
4029
|
|
|
return null; |
|
4030
|
|
|
} |
|
4031
|
|
|
} |
|
4032
|
|
|
|
|
4033
|
|
|
public function get_type() |
|
4034
|
|
|
{ |
|
4035
|
|
|
if ($this->type !== null) |
|
4036
|
|
|
{ |
|
4037
|
|
|
return $this->type; |
|
4038
|
|
|
} |
|
4039
|
|
|
else |
|
4040
|
|
|
{ |
|
4041
|
|
|
return null; |
|
4042
|
|
|
} |
|
4043
|
|
|
} |
|
4044
|
|
|
|
|
4045
|
|
|
public function get_width() |
|
4046
|
|
|
{ |
|
4047
|
|
|
if ($this->width !== null) |
|
4048
|
|
|
{ |
|
4049
|
|
|
return $this->width; |
|
4050
|
|
|
} |
|
4051
|
|
|
else |
|
4052
|
|
|
{ |
|
4053
|
|
|
return null; |
|
4054
|
|
|
} |
|
4055
|
|
|
} |
|
4056
|
|
|
|
|
4057
|
|
|
public function native_embed($options='') |
|
4058
|
|
|
{ |
|
4059
|
|
|
return $this->embed($options, true); |
|
4060
|
|
|
} |
|
4061
|
|
|
|
|
4062
|
|
|
public function embed($options = '', $native = false) |
|
4063
|
|
|
{ |
|
4064
|
|
|
// Set up defaults |
|
4065
|
|
|
$audio = ''; |
|
4066
|
|
|
$video = ''; |
|
4067
|
|
|
$alt = ''; |
|
4068
|
|
|
$altclass = ''; |
|
4069
|
|
|
$loop = 'false'; |
|
4070
|
|
|
$width = 'auto'; |
|
4071
|
|
|
$height = 'auto'; |
|
4072
|
|
|
$bgcolor = '#ffffff'; |
|
4073
|
|
|
$mediaplayer = ''; |
|
4074
|
|
|
$widescreen = false; |
|
4075
|
|
|
$handler = $this->get_handler(); |
|
4076
|
|
|
$type = $this->get_real_type(); |
|
4077
|
|
|
// Process options and reassign values as necessary |
|
4078
|
|
|
if (is_array($options)) |
|
4079
|
|
|
{ |
|
4080
|
|
|
extract($options); |
|
4081
|
|
|
} |
|
4082
|
|
|
else |
|
4083
|
|
|
{ |
|
4084
|
|
|
$options = explode(',', $options); |
|
4085
|
|
|
foreach($options as $option) |
|
4086
|
|
|
{ |
|
4087
|
|
|
$opt = explode(':', $option, 2); |
|
4088
|
|
|
if (isset($opt[0], $opt[1])) |
|
4089
|
|
|
{ |
|
4090
|
|
|
$opt[0] = trim($opt[0]); |
|
4091
|
|
|
$opt[1] = trim($opt[1]); |
|
4092
|
|
|
switch ($opt[0]) |
|
4093
|
|
|
{ |
|
4094
|
|
|
case 'audio': |
|
4095
|
|
|
$audio = $opt[1]; |
|
4096
|
|
|
break; |
|
4097
|
|
|
case 'video': |
|
4098
|
|
|
$video = $opt[1]; |
|
4099
|
|
|
break; |
|
4100
|
|
|
case 'alt': |
|
4101
|
|
|
$alt = $opt[1]; |
|
4102
|
|
|
break; |
|
4103
|
|
|
case 'altclass': |
|
4104
|
|
|
$altclass = $opt[1]; |
|
4105
|
|
|
break; |
|
4106
|
|
|
case 'loop': |
|
4107
|
|
|
$loop = $opt[1]; |
|
4108
|
|
|
break; |
|
4109
|
|
|
case 'width': |
|
4110
|
|
|
$width = $opt[1]; |
|
4111
|
|
|
break; |
|
4112
|
|
|
case 'height': |
|
4113
|
|
|
$height = $opt[1]; |
|
4114
|
|
|
break; |
|
4115
|
|
|
case 'bgcolor': |
|
4116
|
|
|
$bgcolor = $opt[1]; |
|
4117
|
|
|
break; |
|
4118
|
|
|
case 'mediaplayer': |
|
4119
|
|
|
$mediaplayer = $opt[1]; |
|
4120
|
|
|
break; |
|
4121
|
|
|
case 'widescreen': |
|
4122
|
|
|
$widescreen = $opt[1]; |
|
4123
|
|
|
break; |
|
4124
|
|
|
} |
|
4125
|
|
|
} |
|
4126
|
|
|
} |
|
4127
|
|
|
} |
|
4128
|
|
|
$mime = explode('/', $type, 2); |
|
4129
|
|
|
$mime = $mime[0]; |
|
4130
|
|
|
// Process values for 'auto' |
|
4131
|
|
|
if ($width === 'auto') |
|
4132
|
|
|
{ |
|
4133
|
|
|
if ($mime === 'video') |
|
4134
|
|
|
{ |
|
4135
|
|
|
if ($height === 'auto') |
|
4136
|
|
|
{ |
|
4137
|
|
|
$width = 480; |
|
4138
|
|
|
} |
|
4139
|
|
|
elseif ($widescreen) |
|
4140
|
|
|
{ |
|
4141
|
|
|
$width = round((intval($height)/9)*16); |
|
4142
|
|
|
} |
|
4143
|
|
|
else |
|
4144
|
|
|
{ |
|
4145
|
|
|
$width = round((intval($height)/3)*4); |
|
4146
|
|
|
} |
|
4147
|
|
|
} |
|
4148
|
|
|
else |
|
4149
|
|
|
{ |
|
4150
|
|
|
$width = '100%'; |
|
4151
|
|
|
} |
|
4152
|
|
|
} |
|
4153
|
|
|
if ($height === 'auto') |
|
4154
|
|
|
{ |
|
4155
|
|
|
if ($mime === 'audio') |
|
4156
|
|
|
{ |
|
4157
|
|
|
$height = 0; |
|
4158
|
|
|
} |
|
4159
|
|
|
elseif ($mime === 'video') |
|
4160
|
|
|
{ |
|
4161
|
|
|
if ($width === 'auto') |
|
4162
|
|
|
{ |
|
4163
|
|
|
if ($widescreen) |
|
4164
|
|
|
{ |
|
4165
|
|
|
$height = 270; |
|
4166
|
|
|
} |
|
4167
|
|
|
else |
|
4168
|
|
|
{ |
|
4169
|
|
|
$height = 360; |
|
4170
|
|
|
} |
|
4171
|
|
|
} |
|
4172
|
|
|
elseif ($widescreen) |
|
4173
|
|
|
{ |
|
4174
|
|
|
$height = round((intval($width)/16)*9); |
|
4175
|
|
|
} |
|
4176
|
|
|
else |
|
4177
|
|
|
{ |
|
4178
|
|
|
$height = round((intval($width)/4)*3); |
|
4179
|
|
|
} |
|
4180
|
|
|
} |
|
4181
|
|
|
else |
|
4182
|
|
|
{ |
|
4183
|
|
|
$height = 376; |
|
4184
|
|
|
} |
|
4185
|
|
|
} |
|
4186
|
|
|
elseif ($mime === 'audio') |
|
4187
|
|
|
{ |
|
4188
|
|
|
$height = 0; |
|
4189
|
|
|
} |
|
4190
|
|
|
// Set proper placeholder value |
|
4191
|
|
|
if ($mime === 'audio') |
|
4192
|
|
|
{ |
|
4193
|
|
|
$placeholder = $audio; |
|
4194
|
|
|
} |
|
4195
|
|
|
elseif ($mime === 'video') |
|
4196
|
|
|
{ |
|
4197
|
|
|
$placeholder = $video; |
|
4198
|
|
|
} |
|
4199
|
|
|
$embed = ''; |
|
4200
|
|
|
// Flash |
|
4201
|
|
|
if ($handler === 'flash') |
|
4202
|
|
|
{ |
|
4203
|
|
|
if ($native) |
|
4204
|
|
|
{ |
|
4205
|
|
|
$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>"; |
|
4206
|
|
|
} |
|
4207
|
|
|
else |
|
4208
|
|
|
{ |
|
4209
|
|
|
$embed .= "<script type='text/javascript'>embed_flash('$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$loop', '$type');</script>"; |
|
4210
|
|
|
} |
|
4211
|
|
|
} |
|
4212
|
|
|
// Flash Media Player file types. |
|
4213
|
|
|
// Preferred handler for MP3 file types. |
|
4214
|
|
|
elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== '')) |
|
4215
|
|
|
{ |
|
4216
|
|
|
$height += 20; |
|
4217
|
|
|
if ($native) |
|
4218
|
|
|
{ |
|
4219
|
|
|
$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>"; |
|
4220
|
|
|
} |
|
4221
|
|
|
else |
|
4222
|
|
|
{ |
|
4223
|
|
|
$embed .= "<script type='text/javascript'>embed_flv('$width', '$height', '" . rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) . "', '$placeholder', '$loop', '$mediaplayer');</script>"; |
|
4224
|
|
|
} |
|
4225
|
|
|
} |
|
4226
|
|
|
// QuickTime 7 file types. Need to test with QuickTime 6. |
|
4227
|
|
|
// Only handle MP3's if the Flash Media Player is not present. |
|
4228
|
|
|
elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === '')) |
|
4229
|
|
|
{ |
|
4230
|
|
|
$height += 16; |
|
4231
|
|
|
if ($native) |
|
4232
|
|
|
{ |
|
4233
|
|
|
if ($placeholder !== '') |
|
4234
|
|
|
{ |
|
4235
|
|
|
$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>"; |
|
4236
|
|
|
} |
|
4237
|
|
|
else |
|
4238
|
|
|
{ |
|
4239
|
|
|
$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>"; |
|
4240
|
|
|
} |
|
4241
|
|
|
} |
|
4242
|
|
|
else |
|
4243
|
|
|
{ |
|
4244
|
|
|
$embed .= "<script type='text/javascript'>embed_quicktime('$type', '$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$placeholder', '$loop');</script>"; |
|
4245
|
|
|
} |
|
4246
|
|
|
} |
|
4247
|
|
|
// Windows Media |
|
4248
|
|
|
elseif ($handler === 'wmedia') |
|
4249
|
|
|
{ |
|
4250
|
|
|
$height += 45; |
|
4251
|
|
|
if ($native) |
|
4252
|
|
|
{ |
|
4253
|
|
|
$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>"; |
|
4254
|
|
|
} |
|
4255
|
|
|
else |
|
4256
|
|
|
{ |
|
4257
|
|
|
$embed .= "<script type='text/javascript'>embed_wmedia('$width', '$height', '" . $this->get_link() . "');</script>"; |
|
4258
|
|
|
} |
|
4259
|
|
|
} |
|
4260
|
|
|
// Everything else |
|
4261
|
|
|
else $embed .= '<a href="' . $this->get_link() . '" class="' . $altclass . '">' . $alt . '</a>'; |
|
4262
|
|
|
return $embed; |
|
4263
|
|
|
} |
|
4264
|
|
|
|
|
4265
|
|
|
public function get_real_type($find_handler = false) |
|
4266
|
|
|
{ |
|
4267
|
|
|
// Mime-types by handler. |
|
4268
|
|
|
$types_flash = array('application/x-shockwave-flash', 'application/futuresplash'); // Flash |
|
4269
|
|
|
$types_fmedia = array('video/flv', 'video/x-flv','flv-application/octet-stream'); // Flash Media Player |
|
4270
|
|
|
$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 |
|
4271
|
|
|
$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 |
|
4272
|
|
|
$types_mp3 = array('audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg'); // MP3 |
|
4273
|
|
|
if ($this->get_type() !== null) |
|
4274
|
|
|
{ |
|
4275
|
|
|
$type = strtolower($this->type); |
|
4276
|
|
|
} |
|
4277
|
|
|
else |
|
4278
|
|
|
{ |
|
4279
|
|
|
$type = null; |
|
4280
|
|
|
} |
|
4281
|
|
|
// If we encounter an unsupported mime-type, check the file extension and guess intelligently. |
|
4282
|
|
|
if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3))) |
|
4283
|
|
|
{ |
|
4284
|
|
|
switch (strtolower($this->get_extension())) |
|
4285
|
|
|
{ |
|
4286
|
|
|
// Audio mime-types |
|
4287
|
|
|
case 'aac': |
|
4288
|
|
|
case 'adts': |
|
4289
|
|
|
$type = 'audio/acc'; |
|
4290
|
|
|
break; |
|
4291
|
|
|
case 'aif': |
|
4292
|
|
|
case 'aifc': |
|
4293
|
|
|
case 'aiff': |
|
4294
|
|
|
case 'cdda': |
|
4295
|
|
|
$type = 'audio/aiff'; |
|
4296
|
|
|
break; |
|
4297
|
|
|
case 'bwf': |
|
4298
|
|
|
$type = 'audio/wav'; |
|
4299
|
|
|
break; |
|
4300
|
|
|
case 'kar': |
|
4301
|
|
|
case 'mid': |
|
4302
|
|
|
case 'midi': |
|
4303
|
|
|
case 'smf': |
|
4304
|
|
|
$type = 'audio/midi'; |
|
4305
|
|
|
break; |
|
4306
|
|
|
case 'm4a': |
|
4307
|
|
|
$type = 'audio/x-m4a'; |
|
4308
|
|
|
break; |
|
4309
|
|
|
case 'mp3': |
|
4310
|
|
|
case 'swa': |
|
4311
|
|
|
$type = 'audio/mp3'; |
|
4312
|
|
|
break; |
|
4313
|
|
|
case 'wav': |
|
4314
|
|
|
$type = 'audio/wav'; |
|
4315
|
|
|
break; |
|
4316
|
|
|
case 'wax': |
|
4317
|
|
|
$type = 'audio/x-ms-wax'; |
|
4318
|
|
|
break; |
|
4319
|
|
|
case 'wma': |
|
4320
|
|
|
$type = 'audio/x-ms-wma'; |
|
4321
|
|
|
break; |
|
4322
|
|
|
// Video mime-types |
|
4323
|
|
|
case '3gp': |
|
4324
|
|
|
case '3gpp': |
|
4325
|
|
|
$type = 'video/3gpp'; |
|
4326
|
|
|
break; |
|
4327
|
|
|
case '3g2': |
|
4328
|
|
|
case '3gp2': |
|
4329
|
|
|
$type = 'video/3gpp2'; |
|
4330
|
|
|
break; |
|
4331
|
|
|
case 'asf': |
|
4332
|
|
|
$type = 'video/x-ms-asf'; |
|
4333
|
|
|
break; |
|
4334
|
|
|
case 'flv': |
|
4335
|
|
|
$type = 'video/x-flv'; |
|
4336
|
|
|
break; |
|
4337
|
|
|
case 'm1a': |
|
4338
|
|
|
case 'm1s': |
|
4339
|
|
|
case 'm1v': |
|
4340
|
|
|
case 'm15': |
|
4341
|
|
|
case 'm75': |
|
4342
|
|
|
case 'mp2': |
|
4343
|
|
|
case 'mpa': |
|
4344
|
|
|
case 'mpeg': |
|
4345
|
|
|
case 'mpg': |
|
4346
|
|
|
case 'mpm': |
|
4347
|
|
|
case 'mpv': |
|
4348
|
|
|
$type = 'video/mpeg'; |
|
4349
|
|
|
break; |
|
4350
|
|
|
case 'm4v': |
|
4351
|
|
|
$type = 'video/x-m4v'; |
|
4352
|
|
|
break; |
|
4353
|
|
|
case 'mov': |
|
4354
|
|
|
case 'qt': |
|
4355
|
|
|
$type = 'video/quicktime'; |
|
4356
|
|
|
break; |
|
4357
|
|
|
case 'mp4': |
|
4358
|
|
|
case 'mpg4': |
|
4359
|
|
|
$type = 'video/mp4'; |
|
4360
|
|
|
break; |
|
4361
|
|
|
case 'sdv': |
|
4362
|
|
|
$type = 'video/sd-video'; |
|
4363
|
|
|
break; |
|
4364
|
|
|
case 'wm': |
|
4365
|
|
|
$type = 'video/x-ms-wm'; |
|
4366
|
|
|
break; |
|
4367
|
|
|
case 'wmv': |
|
4368
|
|
|
$type = 'video/x-ms-wmv'; |
|
4369
|
|
|
break; |
|
4370
|
|
|
case 'wvx': |
|
4371
|
|
|
$type = 'video/x-ms-wvx'; |
|
4372
|
|
|
break; |
|
4373
|
|
|
// Flash mime-types |
|
4374
|
|
|
case 'spl': |
|
4375
|
|
|
$type = 'application/futuresplash'; |
|
4376
|
|
|
break; |
|
4377
|
|
|
case 'swf': |
|
4378
|
|
|
$type = 'application/x-shockwave-flash'; |
|
4379
|
|
|
break; |
|
4380
|
|
|
} |
|
4381
|
|
|
} |
|
4382
|
|
|
if ($find_handler) |
|
4383
|
|
|
{ |
|
4384
|
|
|
if (in_array($type, $types_flash)) |
|
4385
|
|
|
{ |
|
4386
|
|
|
return 'flash'; |
|
4387
|
|
|
} |
|
4388
|
|
|
elseif (in_array($type, $types_fmedia)) |
|
4389
|
|
|
{ |
|
4390
|
|
|
return 'fmedia'; |
|
4391
|
|
|
} |
|
4392
|
|
|
elseif (in_array($type, $types_quicktime)) |
|
4393
|
|
|
{ |
|
4394
|
|
|
return 'quicktime'; |
|
4395
|
|
|
} |
|
4396
|
|
|
elseif (in_array($type, $types_wmedia)) |
|
4397
|
|
|
{ |
|
4398
|
|
|
return 'wmedia'; |
|
4399
|
|
|
} |
|
4400
|
|
|
elseif (in_array($type, $types_mp3)) |
|
4401
|
|
|
{ |
|
4402
|
|
|
return 'mp3'; |
|
4403
|
|
|
} |
|
4404
|
|
|
else |
|
4405
|
|
|
{ |
|
4406
|
|
|
return null; |
|
4407
|
|
|
} |
|
4408
|
|
|
} |
|
4409
|
|
|
else |
|
4410
|
|
|
{ |
|
4411
|
|
|
return $type; |
|
4412
|
|
|
} |
|
4413
|
|
|
} |
|
4414
|
|
|
} |
|
4415
|
|
|
class SimplePie_Exception extends Exception |
|
4416
|
|
|
{ |
|
4417
|
|
|
} |
|
4418
|
|
|
class SimplePie_File |
|
4419
|
|
|
{ |
|
4420
|
|
|
var $url; |
|
4421
|
|
|
var $useragent; |
|
4422
|
|
|
var $success = true; |
|
4423
|
|
|
var $headers = array(); |
|
4424
|
|
|
var $body; |
|
4425
|
|
|
var $status_code; |
|
4426
|
|
|
var $redirects = 0; |
|
4427
|
|
|
var $error; |
|
4428
|
|
|
var $method = SIMPLEPIE_FILE_SOURCE_NONE; |
|
4429
|
|
|
public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) |
|
4430
|
|
|
{ |
|
4431
|
|
|
if (class_exists('idna_convert')) |
|
4432
|
|
|
{ |
|
4433
|
|
|
$idn = new idna_convert(); |
|
4434
|
|
|
$parsed = SimplePie_Misc::parse_url($url); |
|
4435
|
|
|
$url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']); |
|
4436
|
|
|
} |
|
4437
|
|
|
$this->url = $url; |
|
4438
|
|
|
$this->useragent = $useragent; |
|
4439
|
|
|
if (preg_match('/^http(s)?:\/\//i', $url)) |
|
4440
|
|
|
{ |
|
4441
|
|
|
if ($useragent === null) |
|
4442
|
|
|
{ |
|
4443
|
|
|
$useragent = ini_get('user_agent'); |
|
4444
|
|
|
$this->useragent = $useragent; |
|
4445
|
|
|
} |
|
4446
|
|
|
if (!is_array($headers)) |
|
4447
|
|
|
{ |
|
4448
|
|
|
$headers = array(); |
|
4449
|
|
|
} |
|
4450
|
|
|
if (!$force_fsockopen && function_exists('curl_exec')) |
|
4451
|
|
|
{ |
|
4452
|
|
|
$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL; |
|
4453
|
|
|
$fp = curl_init(); |
|
4454
|
|
|
$headers2 = array(); |
|
4455
|
|
|
foreach ($headers as $key => $value) |
|
4456
|
|
|
{ |
|
4457
|
|
|
$headers2[] = "$key: $value"; |
|
4458
|
|
|
} |
|
4459
|
|
|
if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>=')) |
|
4460
|
|
|
{ |
|
4461
|
|
|
curl_setopt($fp, CURLOPT_ENCODING, ''); |
|
4462
|
|
|
} |
|
4463
|
|
|
curl_setopt($fp, CURLOPT_URL, $url); |
|
4464
|
|
|
curl_setopt($fp, CURLOPT_HEADER, 1); |
|
4465
|
|
|
curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1); |
|
4466
|
|
|
curl_setopt($fp, CURLOPT_TIMEOUT, $timeout); |
|
4467
|
|
|
curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout); |
|
4468
|
|
|
curl_setopt($fp, CURLOPT_REFERER, $url); |
|
4469
|
|
|
curl_setopt($fp, CURLOPT_USERAGENT, $useragent); |
|
4470
|
|
|
curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2); |
|
4471
|
|
|
if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>=')) |
|
4472
|
|
|
{ |
|
4473
|
|
|
curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1); |
|
4474
|
|
|
curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects); |
|
4475
|
|
|
} |
|
4476
|
|
|
$this->headers = curl_exec($fp); |
|
4477
|
|
|
if (curl_errno($fp) === 23 || curl_errno($fp) === 61) |
|
4478
|
|
|
{ |
|
4479
|
|
|
curl_setopt($fp, CURLOPT_ENCODING, 'none'); |
|
4480
|
|
|
$this->headers = curl_exec($fp); |
|
4481
|
|
|
} |
|
4482
|
|
|
if (curl_errno($fp)) |
|
4483
|
|
|
{ |
|
4484
|
|
|
$this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp); |
|
4485
|
|
|
$this->success = false; |
|
4486
|
|
|
} |
|
4487
|
|
|
else |
|
4488
|
|
|
{ |
|
4489
|
|
|
$info = curl_getinfo($fp); |
|
4490
|
|
|
curl_close($fp); |
|
4491
|
|
|
$this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1); |
|
4492
|
|
|
$this->headers = array_pop($this->headers); |
|
4493
|
|
|
$parser = new SimplePie_HTTP_Parser($this->headers); |
|
4494
|
|
|
if ($parser->parse()) |
|
4495
|
|
|
{ |
|
4496
|
|
|
$this->headers = $parser->headers; |
|
4497
|
|
|
$this->body = $parser->body; |
|
4498
|
|
|
$this->status_code = $parser->status_code; |
|
4499
|
|
|
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) |
|
4500
|
|
|
|
|
4501
|
|
|
{ |
|
4502
|
|
|
$this->redirects++; |
|
4503
|
|
|
$location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); |
|
4504
|
|
|
return $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); |
|
4505
|
|
|
} |
|
4506
|
|
|
} |
|
4507
|
|
|
} |
|
4508
|
|
|
} |
|
4509
|
|
|
else |
|
4510
|
|
|
{ |
|
4511
|
|
|
$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN; |
|
4512
|
|
|
$url_parts = parse_url($url); |
|
4513
|
|
|
$socket_host = $url_parts['host']; |
|
4514
|
|
|
if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') |
|
4515
|
|
|
{ |
|
4516
|
|
|
$socket_host = "ssl://$url_parts[host]"; |
|
4517
|
|
|
$url_parts['port'] = 443; |
|
4518
|
|
|
} |
|
4519
|
|
|
if (!isset($url_parts['port'])) |
|
4520
|
|
|
{ |
|
4521
|
|
|
$url_parts['port'] = 80; |
|
4522
|
|
|
} |
|
4523
|
|
|
$fp = @fsockopen($socket_host, $url_parts['port'], $errno, $errstr, $timeout); |
|
4524
|
|
|
if (!$fp) |
|
4525
|
|
|
{ |
|
4526
|
|
|
$this->error = 'fsockopen error: ' . $errstr; |
|
4527
|
|
|
$this->success = false; |
|
4528
|
|
|
} |
|
4529
|
|
|
else |
|
4530
|
|
|
{ |
|
4531
|
|
|
stream_set_timeout($fp, $timeout); |
|
4532
|
|
|
if (isset($url_parts['path'])) |
|
4533
|
|
|
{ |
|
4534
|
|
|
if (isset($url_parts['query'])) |
|
4535
|
|
|
{ |
|
4536
|
|
|
$get = "$url_parts[path]?$url_parts[query]"; |
|
4537
|
|
|
} |
|
4538
|
|
|
else |
|
4539
|
|
|
{ |
|
4540
|
|
|
$get = $url_parts['path']; |
|
4541
|
|
|
} |
|
4542
|
|
|
} |
|
4543
|
|
|
else |
|
4544
|
|
|
{ |
|
4545
|
|
|
$get = '/'; |
|
4546
|
|
|
} |
|
4547
|
|
|
$out = "GET $get HTTP/1.1\r\n"; |
|
4548
|
|
|
$out .= "Host: $url_parts[host]\r\n"; |
|
4549
|
|
|
$out .= "User-Agent: $useragent\r\n"; |
|
4550
|
|
|
if (extension_loaded('zlib')) |
|
4551
|
|
|
{ |
|
4552
|
|
|
$out .= "Accept-Encoding: x-gzip,gzip,deflate\r\n"; |
|
4553
|
|
|
} |
|
4554
|
|
|
if (isset($url_parts['user']) && isset($url_parts['pass'])) |
|
4555
|
|
|
{ |
|
4556
|
|
|
$out .= "Authorization: Basic " . base64_encode("$url_parts[user]:$url_parts[pass]") . "\r\n"; |
|
4557
|
|
|
} |
|
4558
|
|
|
foreach ($headers as $key => $value) |
|
4559
|
|
|
{ |
|
4560
|
|
|
$out .= "$key: $value\r\n"; |
|
4561
|
|
|
} |
|
4562
|
|
|
$out .= "Connection: Close\r\n\r\n"; |
|
4563
|
|
|
fwrite($fp, $out); |
|
4564
|
|
|
$info = stream_get_meta_data($fp); |
|
4565
|
|
|
$this->headers = ''; |
|
4566
|
|
|
while (!$info['eof'] && !$info['timed_out']) |
|
4567
|
|
|
{ |
|
4568
|
|
|
$this->headers .= fread($fp, 1160); |
|
4569
|
|
|
$info = stream_get_meta_data($fp); |
|
4570
|
|
|
} |
|
4571
|
|
|
if (!$info['timed_out']) |
|
4572
|
|
|
{ |
|
4573
|
|
|
$parser = new SimplePie_HTTP_Parser($this->headers); |
|
4574
|
|
|
if ($parser->parse()) |
|
4575
|
|
|
{ |
|
4576
|
|
|
$this->headers = $parser->headers; |
|
4577
|
|
|
$this->body = $parser->body; |
|
4578
|
|
|
$this->status_code = $parser->status_code; |
|
4579
|
|
|
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) |
|
4580
|
|
|
{ |
|
4581
|
|
|
$this->redirects++; |
|
4582
|
|
|
$location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); |
|
4583
|
|
|
return $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); |
|
4584
|
|
|
} |
|
4585
|
|
|
if (isset($this->headers['content-encoding'])) |
|
4586
|
|
|
{ |
|
4587
|
|
|
// Hey, we act dumb elsewhere, so let's do that here too |
|
4588
|
|
|
switch (strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20"))) |
|
4589
|
|
|
{ |
|
4590
|
|
|
case 'gzip': |
|
4591
|
|
|
case 'x-gzip': |
|
4592
|
|
|
$decoder = new SimplePie_gzdecode($this->body); |
|
4593
|
|
|
if (!$decoder->parse()) |
|
4594
|
|
|
{ |
|
4595
|
|
|
$this->error = 'Unable to decode HTTP "gzip" stream'; |
|
4596
|
|
|
$this->success = false; |
|
4597
|
|
|
} |
|
4598
|
|
|
else |
|
4599
|
|
|
{ |
|
4600
|
|
|
$this->body = $decoder->data; |
|
4601
|
|
|
} |
|
4602
|
|
|
break; |
|
4603
|
|
|
case 'deflate': |
|
4604
|
|
|
if (($decompressed = gzinflate($this->body)) !== false) |
|
4605
|
|
|
{ |
|
4606
|
|
|
$this->body = $decompressed; |
|
4607
|
|
|
} |
|
4608
|
|
|
else if (($decompressed = gzuncompress($this->body)) !== false) |
|
4609
|
|
|
{ |
|
4610
|
|
|
$this->body = $decompressed; |
|
4611
|
|
|
} |
|
4612
|
|
|
else if (function_exists('gzdecode') && ($decompressed = gzdecode($this->body)) !== false) |
|
4613
|
|
|
{ |
|
4614
|
|
|
$this->body = $decompressed; |
|
4615
|
|
|
} |
|
4616
|
|
|
else |
|
4617
|
|
|
{ |
|
4618
|
|
|
$this->error = 'Unable to decode HTTP "deflate" stream'; |
|
4619
|
|
|
$this->success = false; |
|
4620
|
|
|
} |
|
4621
|
|
|
break; |
|
4622
|
|
|
default: |
|
4623
|
|
|
$this->error = 'Unknown content coding'; |
|
4624
|
|
|
$this->success = false; |
|
4625
|
|
|
} |
|
4626
|
|
|
} |
|
4627
|
|
|
} |
|
4628
|
|
|
} |
|
4629
|
|
|
else |
|
4630
|
|
|
{ |
|
4631
|
|
|
$this->error = 'fsocket timed out'; |
|
4632
|
|
|
$this->success = false; |
|
4633
|
|
|
} |
|
4634
|
|
|
fclose($fp); |
|
4635
|
|
|
} |
|
4636
|
|
|
} |
|
4637
|
|
|
} |
|
4638
|
|
|
else |
|
4639
|
|
|
{ |
|
4640
|
|
|
$this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS; |
|
4641
|
|
|
if (!$this->body = file_get_contents($url)) |
|
4642
|
|
|
{ |
|
4643
|
|
|
$this->error = 'file_get_contents could not read the file'; |
|
4644
|
|
|
$this->success = false; |
|
4645
|
|
|
} |
|
4646
|
|
|
} |
|
4647
|
|
|
} |
|
4648
|
|
|
} |
|
4649
|
|
|
class SimplePie_gzdecode |
|
4650
|
|
|
{ |
|
4651
|
|
|
|
|
4652
|
|
|
var $compressed_data; |
|
4653
|
|
|
|
|
4654
|
|
|
var $compressed_size; |
|
4655
|
|
|
|
|
4656
|
|
|
var $min_compressed_size = 18; |
|
4657
|
|
|
|
|
4658
|
|
|
var $position = 0; |
|
4659
|
|
|
|
|
4660
|
|
|
var $flags; |
|
4661
|
|
|
|
|
4662
|
|
|
var $data; |
|
4663
|
|
|
|
|
4664
|
|
|
var $MTIME; |
|
4665
|
|
|
|
|
4666
|
|
|
var $XFL; |
|
4667
|
|
|
|
|
4668
|
|
|
var $OS; |
|
4669
|
|
|
|
|
4670
|
|
|
var $SI1; |
|
4671
|
|
|
|
|
4672
|
|
|
var $SI2; |
|
4673
|
|
|
|
|
4674
|
|
|
var $extra_field; |
|
4675
|
|
|
|
|
4676
|
|
|
var $filename; |
|
4677
|
|
|
|
|
4678
|
|
|
var $comment; |
|
4679
|
|
|
|
|
4680
|
|
|
public function __set($name, $value) |
|
4681
|
|
|
{ |
|
4682
|
|
|
trigger_error("Cannot write property $name", E_USER_ERROR); |
|
4683
|
|
|
} |
|
4684
|
|
|
|
|
4685
|
|
|
public function __construct($data) |
|
4686
|
|
|
{ |
|
4687
|
|
|
$this->compressed_data = $data; |
|
4688
|
|
|
$this->compressed_size = strlen($data); |
|
4689
|
|
|
} |
|
4690
|
|
|
|
|
4691
|
|
|
public function parse() |
|
4692
|
|
|
{ |
|
4693
|
|
|
if ($this->compressed_size >= $this->min_compressed_size) |
|
4694
|
|
|
{ |
|
4695
|
|
|
// Check ID1, ID2, and CM |
|
4696
|
|
|
if (substr($this->compressed_data, 0, 3) !== "\x1F\x8B\x08") |
|
4697
|
|
|
{ |
|
4698
|
|
|
return false; |
|
4699
|
|
|
} |
|
4700
|
|
|
// Get the FLG (FLaGs) |
|
4701
|
|
|
$this->flags = ord($this->compressed_data[3]); |
|
4702
|
|
|
// FLG bits above (1 << 4) are reserved |
|
4703
|
|
|
if ($this->flags > 0x1F) |
|
4704
|
|
|
{ |
|
4705
|
|
|
return false; |
|
4706
|
|
|
} |
|
4707
|
|
|
// Advance the pointer after the above |
|
4708
|
|
|
$this->position += 4; |
|
4709
|
|
|
// MTIME |
|
4710
|
|
|
$mtime = substr($this->compressed_data, $this->position, 4); |
|
4711
|
|
|
// Reverse the string if we're on a big-endian arch because l is the only signed long and is machine endianness |
|
4712
|
|
|
if (current(unpack('S', "\x00\x01")) === 1) |
|
4713
|
|
|
{ |
|
4714
|
|
|
$mtime = strrev($mtime); |
|
4715
|
|
|
} |
|
4716
|
|
|
$this->MTIME = current(unpack('l', $mtime)); |
|
4717
|
|
|
$this->position += 4; |
|
4718
|
|
|
// Get the XFL (eXtra FLags) |
|
4719
|
|
|
$this->XFL = ord($this->compressed_data[$this->position++]); |
|
4720
|
|
|
// Get the OS (Operating System) |
|
4721
|
|
|
$this->OS = ord($this->compressed_data[$this->position++]); |
|
4722
|
|
|
// Parse the FEXTRA |
|
4723
|
|
|
if ($this->flags & 4) |
|
4724
|
|
|
{ |
|
4725
|
|
|
// Read subfield IDs |
|
4726
|
|
|
$this->SI1 = $this->compressed_data[$this->position++]; |
|
4727
|
|
|
$this->SI2 = $this->compressed_data[$this->position++]; |
|
4728
|
|
|
// SI2 set to zero is reserved for future use |
|
4729
|
|
|
if ($this->SI2 === "\x00") |
|
4730
|
|
|
{ |
|
4731
|
|
|
return false; |
|
4732
|
|
|
} |
|
4733
|
|
|
// Get the length of the extra field |
|
4734
|
|
|
$len = current(unpack('v', substr($this->compressed_data, $this->position, 2))); |
|
4735
|
|
|
$this->position += 2; |
|
4736
|
|
|
// Check the length of the string is still valid |
|
4737
|
|
|
$this->min_compressed_size += $len + 4; |
|
4738
|
|
|
if ($this->compressed_size >= $this->min_compressed_size) |
|
4739
|
|
|
{ |
|
4740
|
|
|
// Set the extra field to the given data |
|
4741
|
|
|
$this->extra_field = substr($this->compressed_data, $this->position, $len); |
|
4742
|
|
|
$this->position += $len; |
|
4743
|
|
|
} |
|
4744
|
|
|
else |
|
4745
|
|
|
{ |
|
4746
|
|
|
return false; |
|
4747
|
|
|
} |
|
4748
|
|
|
} |
|
4749
|
|
|
// Parse the FNAME |
|
4750
|
|
|
if ($this->flags & 8) |
|
4751
|
|
|
{ |
|
4752
|
|
|
// Get the length of the filename |
|
4753
|
|
|
$len = strcspn($this->compressed_data, "\x00", $this->position); |
|
4754
|
|
|
// Check the length of the string is still valid |
|
4755
|
|
|
$this->min_compressed_size += $len + 1; |
|
4756
|
|
|
if ($this->compressed_size >= $this->min_compressed_size) |
|
4757
|
|
|
{ |
|
4758
|
|
|
// Set the original filename to the given string |
|
4759
|
|
|
$this->filename = substr($this->compressed_data, $this->position, $len); |
|
4760
|
|
|
$this->position += $len + 1; |
|
4761
|
|
|
} |
|
4762
|
|
|
else |
|
4763
|
|
|
{ |
|
4764
|
|
|
return false; |
|
4765
|
|
|
} |
|
4766
|
|
|
} |
|
4767
|
|
|
// Parse the FCOMMENT |
|
4768
|
|
|
if ($this->flags & 16) |
|
4769
|
|
|
{ |
|
4770
|
|
|
// Get the length of the comment |
|
4771
|
|
|
$len = strcspn($this->compressed_data, "\x00", $this->position); |
|
4772
|
|
|
// Check the length of the string is still valid |
|
4773
|
|
|
$this->min_compressed_size += $len + 1; |
|
4774
|
|
|
if ($this->compressed_size >= $this->min_compressed_size) |
|
4775
|
|
|
{ |
|
4776
|
|
|
// Set the original comment to the given string |
|
4777
|
|
|
$this->comment = substr($this->compressed_data, $this->position, $len); |
|
4778
|
|
|
$this->position += $len + 1; |
|
4779
|
|
|
} |
|
4780
|
|
|
else |
|
4781
|
|
|
{ |
|
4782
|
|
|
return false; |
|
4783
|
|
|
} |
|
4784
|
|
|
} |
|
4785
|
|
|
// Parse the FHCRC |
|
4786
|
|
|
if ($this->flags & 2) |
|
4787
|
|
|
{ |
|
4788
|
|
|
// Check the length of the string is still valid |
|
4789
|
|
|
$this->min_compressed_size += $len + 2; |
|
4790
|
|
|
if ($this->compressed_size >= $this->min_compressed_size) |
|
4791
|
|
|
{ |
|
4792
|
|
|
// Read the CRC |
|
4793
|
|
|
$crc = current(unpack('v', substr($this->compressed_data, $this->position, 2))); |
|
4794
|
|
|
// Check the CRC matches |
|
4795
|
|
|
if ((crc32(substr($this->compressed_data, 0, $this->position)) & 0xFFFF) === $crc) |
|
4796
|
|
|
{ |
|
4797
|
|
|
$this->position += 2; |
|
4798
|
|
|
} |
|
4799
|
|
|
else |
|
4800
|
|
|
{ |
|
4801
|
|
|
return false; |
|
4802
|
|
|
} |
|
4803
|
|
|
} |
|
4804
|
|
|
else |
|
4805
|
|
|
{ |
|
4806
|
|
|
return false; |
|
4807
|
|
|
} |
|
4808
|
|
|
} |
|
4809
|
|
|
// Decompress the actual data |
|
4810
|
|
|
if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false) |
|
4811
|
|
|
{ |
|
4812
|
|
|
return false; |
|
4813
|
|
|
} |
|
4814
|
|
|
else |
|
4815
|
|
|
{ |
|
4816
|
|
|
$this->position = $this->compressed_size - 8; |
|
4817
|
|
|
} |
|
4818
|
|
|
// Check CRC of data |
|
4819
|
|
|
$crc = current(unpack('V', substr($this->compressed_data, $this->position, 4))); |
|
4820
|
|
|
$this->position += 4; |
|
4821
|
|
|
/*if (extension_loaded('hash') && sprintf('%u', current(unpack('V', hash('crc32b', $this->data)))) !== sprintf('%u', $crc)) |
|
4822
|
|
|
{ |
|
4823
|
|
|
return false; |
|
4824
|
|
|
}*/ |
|
4825
|
|
|
// Check ISIZE of data |
|
4826
|
|
|
$isize = current(unpack('V', substr($this->compressed_data, $this->position, 4))); |
|
4827
|
|
|
$this->position += 4; |
|
4828
|
|
|
if (sprintf('%u', strlen($this->data) & 0xFFFFFFFF) !== sprintf('%u', $isize)) |
|
4829
|
|
|
{ |
|
4830
|
|
|
return false; |
|
4831
|
|
|
} |
|
4832
|
|
|
// Wow, against all odds, we've actually got a valid gzip string |
|
4833
|
|
|
return true; |
|
4834
|
|
|
} |
|
4835
|
|
|
else |
|
4836
|
|
|
{ |
|
4837
|
|
|
return false; |
|
4838
|
|
|
} |
|
4839
|
|
|
} |
|
4840
|
|
|
} |
|
4841
|
|
|
class SimplePie_HTTP_Parser |
|
4842
|
|
|
{ |
|
4843
|
|
|
|
|
4844
|
|
|
public $http_version = 0.0; |
|
4845
|
|
|
|
|
4846
|
|
|
public $status_code = 0; |
|
4847
|
|
|
|
|
4848
|
|
|
public $reason = ''; |
|
4849
|
|
|
|
|
4850
|
|
|
public $headers = array(); |
|
4851
|
|
|
|
|
4852
|
|
|
public $body = ''; |
|
4853
|
|
|
|
|
4854
|
|
|
protected $state = 'http_version'; |
|
4855
|
|
|
|
|
4856
|
|
|
protected $data = ''; |
|
4857
|
|
|
|
|
4858
|
|
|
protected $data_length = 0; |
|
4859
|
|
|
|
|
4860
|
|
|
protected $position = 0; |
|
4861
|
|
|
|
|
4862
|
|
|
protected $name = ''; |
|
4863
|
|
|
|
|
4864
|
|
|
protected $value = ''; |
|
4865
|
|
|
|
|
4866
|
|
|
public function __construct($data) |
|
4867
|
|
|
{ |
|
4868
|
|
|
$this->data = $data; |
|
4869
|
|
|
$this->data_length = strlen($this->data); |
|
4870
|
|
|
} |
|
4871
|
|
|
|
|
4872
|
|
|
public function parse() |
|
4873
|
|
|
{ |
|
4874
|
|
|
while ($this->state && $this->state !== 'emit' && $this->has_data()) |
|
4875
|
|
|
{ |
|
4876
|
|
|
$state = $this->state; |
|
4877
|
|
|
$this->$state(); |
|
4878
|
|
|
} |
|
4879
|
|
|
$this->data = ''; |
|
4880
|
|
|
if ($this->state === 'emit' || $this->state === 'body') |
|
4881
|
|
|
{ |
|
4882
|
|
|
return true; |
|
4883
|
|
|
} |
|
4884
|
|
|
else |
|
4885
|
|
|
{ |
|
4886
|
|
|
$this->http_version = ''; |
|
4887
|
|
|
$this->status_code = ''; |
|
4888
|
|
|
$this->reason = ''; |
|
4889
|
|
|
$this->headers = array(); |
|
4890
|
|
|
$this->body = ''; |
|
4891
|
|
|
return false; |
|
4892
|
|
|
} |
|
4893
|
|
|
} |
|
4894
|
|
|
|
|
4895
|
|
|
protected function has_data() |
|
4896
|
|
|
{ |
|
4897
|
|
|
return (bool) ($this->position < $this->data_length); |
|
4898
|
|
|
} |
|
4899
|
|
|
|
|
4900
|
|
|
protected function is_linear_whitespace() |
|
4901
|
|
|
{ |
|
4902
|
|
|
return (bool) ($this->data[$this->position] === "\x09" |
|
4903
|
|
|
|| $this->data[$this->position] === "\x20" |
|
4904
|
|
|
|| ($this->data[$this->position] === "\x0A" |
|
4905
|
|
|
&& isset($this->data[$this->position + 1]) |
|
4906
|
|
|
&& ($this->data[$this->position + 1] === "\x09" || $this->data[$this->position + 1] === "\x20"))); |
|
4907
|
|
|
} |
|
4908
|
|
|
|
|
4909
|
|
|
protected function http_version() |
|
4910
|
|
|
{ |
|
4911
|
|
|
if (strpos($this->data, "\x0A") !== false && strtoupper(substr($this->data, 0, 5)) === 'HTTP/') |
|
4912
|
|
|
{ |
|
4913
|
|
|
$len = strspn($this->data, '0123456789.', 5); |
|
4914
|
|
|
$this->http_version = substr($this->data, 5, $len); |
|
4915
|
|
|
$this->position += 5 + $len; |
|
4916
|
|
|
if (substr_count($this->http_version, '.') <= 1) |
|
4917
|
|
|
{ |
|
4918
|
|
|
$this->http_version = (float) $this->http_version; |
|
4919
|
|
|
$this->position += strspn($this->data, "\x09\x20", $this->position); |
|
4920
|
|
|
$this->state = 'status'; |
|
4921
|
|
|
} |
|
4922
|
|
|
else |
|
4923
|
|
|
{ |
|
4924
|
|
|
$this->state = false; |
|
4925
|
|
|
} |
|
4926
|
|
|
} |
|
4927
|
|
|
else |
|
4928
|
|
|
{ |
|
4929
|
|
|
$this->state = false; |
|
4930
|
|
|
} |
|
4931
|
|
|
} |
|
4932
|
|
|
|
|
4933
|
|
|
protected function status() |
|
4934
|
|
|
{ |
|
4935
|
|
|
if ($len = strspn($this->data, '0123456789', $this->position)) |
|
4936
|
|
|
{ |
|
4937
|
|
|
$this->status_code = (int) substr($this->data, $this->position, $len); |
|
4938
|
|
|
$this->position += $len; |
|
4939
|
|
|
$this->state = 'reason'; |
|
4940
|
|
|
} |
|
4941
|
|
|
else |
|
4942
|
|
|
{ |
|
4943
|
|
|
$this->state = false; |
|
4944
|
|
|
} |
|
4945
|
|
|
} |
|
4946
|
|
|
|
|
4947
|
|
|
protected function reason() |
|
4948
|
|
|
{ |
|
4949
|
|
|
$len = strcspn($this->data, "\x0A", $this->position); |
|
4950
|
|
|
$this->reason = trim(substr($this->data, $this->position, $len), "\x09\x0D\x20"); |
|
4951
|
|
|
$this->position += $len + 1; |
|
4952
|
|
|
$this->state = 'new_line'; |
|
4953
|
|
|
} |
|
4954
|
|
|
|
|
4955
|
|
|
protected function new_line() |
|
4956
|
|
|
{ |
|
4957
|
|
|
$this->value = trim($this->value, "\x0D\x20"); |
|
4958
|
|
|
if ($this->name !== '' && $this->value !== '') |
|
4959
|
|
|
{ |
|
4960
|
|
|
$this->name = strtolower($this->name); |
|
4961
|
|
|
// We should only use the last Content-Type header. c.f. issue #1 |
|
4962
|
|
|
if (isset($this->headers[$this->name]) && $this->name !== 'content-type') |
|
4963
|
|
|
{ |
|
4964
|
|
|
$this->headers[$this->name] .= ', ' . $this->value; |
|
4965
|
|
|
} |
|
4966
|
|
|
else |
|
4967
|
|
|
{ |
|
4968
|
|
|
$this->headers[$this->name] = $this->value; |
|
4969
|
|
|
} |
|
4970
|
|
|
} |
|
4971
|
|
|
$this->name = ''; |
|
4972
|
|
|
$this->value = ''; |
|
4973
|
|
|
if (substr($this->data[$this->position], 0, 2) === "\x0D\x0A") |
|
4974
|
|
|
{ |
|
4975
|
|
|
$this->position += 2; |
|
4976
|
|
|
$this->state = 'body'; |
|
4977
|
|
|
} |
|
4978
|
|
|
elseif ($this->data[$this->position] === "\x0A") |
|
4979
|
|
|
{ |
|
4980
|
|
|
$this->position++; |
|
4981
|
|
|
$this->state = 'body'; |
|
4982
|
|
|
} |
|
4983
|
|
|
else |
|
4984
|
|
|
{ |
|
4985
|
|
|
$this->state = 'name'; |
|
4986
|
|
|
} |
|
4987
|
|
|
} |
|
4988
|
|
|
|
|
4989
|
|
|
protected function name() |
|
4990
|
|
|
{ |
|
4991
|
|
|
$len = strcspn($this->data, "\x0A:", $this->position); |
|
4992
|
|
|
if (isset($this->data[$this->position + $len])) |
|
4993
|
|
|
{ |
|
4994
|
|
|
if ($this->data[$this->position + $len] === "\x0A") |
|
4995
|
|
|
{ |
|
4996
|
|
|
$this->position += $len; |
|
4997
|
|
|
$this->state = 'new_line'; |
|
4998
|
|
|
} |
|
4999
|
|
|
else |
|
5000
|
|
|
{ |
|
5001
|
|
|
$this->name = substr($this->data, $this->position, $len); |
|
5002
|
|
|
$this->position += $len + 1; |
|
5003
|
|
|
$this->state = 'value'; |
|
5004
|
|
|
} |
|
5005
|
|
|
} |
|
5006
|
|
|
else |
|
5007
|
|
|
{ |
|
5008
|
|
|
$this->state = false; |
|
5009
|
|
|
} |
|
5010
|
|
|
} |
|
5011
|
|
|
|
|
5012
|
|
|
protected function linear_whitespace() |
|
5013
|
|
|
{ |
|
5014
|
|
|
do |
|
5015
|
|
|
{ |
|
5016
|
|
|
if (substr($this->data, $this->position, 2) === "\x0D\x0A") |
|
5017
|
|
|
{ |
|
5018
|
|
|
$this->position += 2; |
|
5019
|
|
|
} |
|
5020
|
|
|
elseif ($this->data[$this->position] === "\x0A") |
|
5021
|
|
|
{ |
|
5022
|
|
|
$this->position++; |
|
5023
|
|
|
} |
|
5024
|
|
|
$this->position += strspn($this->data, "\x09\x20", $this->position); |
|
5025
|
|
|
} while ($this->has_data() && $this->is_linear_whitespace()); |
|
5026
|
|
|
$this->value .= "\x20"; |
|
5027
|
|
|
} |
|
5028
|
|
|
|
|
5029
|
|
|
protected function value() |
|
5030
|
|
|
{ |
|
5031
|
|
|
if ($this->is_linear_whitespace()) |
|
5032
|
|
|
{ |
|
5033
|
|
|
$this->linear_whitespace(); |
|
5034
|
|
|
} |
|
5035
|
|
|
else |
|
5036
|
|
|
{ |
|
5037
|
|
|
switch ($this->data[$this->position]) |
|
5038
|
|
|
{ |
|
5039
|
|
|
case '"': |
|
5040
|
|
|
// Workaround for ETags: we have to include the quotes as |
|
5041
|
|
|
// part of the tag. |
|
5042
|
|
|
if (strtolower($this->name) === 'etag') |
|
5043
|
|
|
{ |
|
5044
|
|
|
$this->value .= '"'; |
|
5045
|
|
|
$this->position++; |
|
5046
|
|
|
$this->state = 'value_char'; |
|
5047
|
|
|
break; |
|
5048
|
|
|
} |
|
5049
|
|
|
$this->position++; |
|
5050
|
|
|
$this->state = 'quote'; |
|
5051
|
|
|
break; |
|
5052
|
|
|
case "\x0A": |
|
5053
|
|
|
$this->position++; |
|
5054
|
|
|
$this->state = 'new_line'; |
|
5055
|
|
|
break; |
|
5056
|
|
|
default: |
|
5057
|
|
|
$this->state = 'value_char'; |
|
5058
|
|
|
break; |
|
5059
|
|
|
} |
|
5060
|
|
|
} |
|
5061
|
|
|
} |
|
5062
|
|
|
|
|
5063
|
|
|
protected function value_char() |
|
5064
|
|
|
{ |
|
5065
|
|
|
$len = strcspn($this->data, "\x09\x20\x0A\"", $this->position); |
|
5066
|
|
|
$this->value .= substr($this->data, $this->position, $len); |
|
5067
|
|
|
$this->position += $len; |
|
5068
|
|
|
$this->state = 'value'; |
|
5069
|
|
|
} |
|
5070
|
|
|
|
|
5071
|
|
|
protected function quote() |
|
5072
|
|
|
{ |
|
5073
|
|
|
if ($this->is_linear_whitespace()) |
|
5074
|
|
|
{ |
|
5075
|
|
|
$this->linear_whitespace(); |
|
5076
|
|
|
} |
|
5077
|
|
|
else |
|
5078
|
|
|
{ |
|
5079
|
|
|
switch ($this->data[$this->position]) |
|
5080
|
|
|
{ |
|
5081
|
|
|
case '"': |
|
5082
|
|
|
$this->position++; |
|
5083
|
|
|
$this->state = 'value'; |
|
5084
|
|
|
break; |
|
5085
|
|
|
case "\x0A": |
|
5086
|
|
|
$this->position++; |
|
5087
|
|
|
$this->state = 'new_line'; |
|
5088
|
|
|
break; |
|
5089
|
|
|
case '\\': |
|
5090
|
|
|
$this->position++; |
|
5091
|
|
|
$this->state = 'quote_escaped'; |
|
5092
|
|
|
break; |
|
5093
|
|
|
default: |
|
5094
|
|
|
$this->state = 'quote_char'; |
|
5095
|
|
|
break; |
|
5096
|
|
|
} |
|
5097
|
|
|
} |
|
5098
|
|
|
} |
|
5099
|
|
|
|
|
5100
|
|
|
protected function quote_char() |
|
5101
|
|
|
{ |
|
5102
|
|
|
$len = strcspn($this->data, "\x09\x20\x0A\"\\", $this->position); |
|
5103
|
|
|
$this->value .= substr($this->data, $this->position, $len); |
|
5104
|
|
|
$this->position += $len; |
|
5105
|
|
|
$this->state = 'value'; |
|
5106
|
|
|
} |
|
5107
|
|
|
|
|
5108
|
|
|
protected function quote_escaped() |
|
5109
|
|
|
{ |
|
5110
|
|
|
$this->value .= $this->data[$this->position]; |
|
5111
|
|
|
$this->position++; |
|
5112
|
|
|
$this->state = 'quote'; |
|
5113
|
|
|
} |
|
5114
|
|
|
|
|
5115
|
|
|
protected function body() |
|
5116
|
|
|
{ |
|
5117
|
|
|
$this->body = substr($this->data, $this->position); |
|
5118
|
|
|
if (!empty($this->headers['transfer-encoding'])) |
|
5119
|
|
|
{ |
|
5120
|
|
|
unset($this->headers['transfer-encoding']); |
|
5121
|
|
|
$this->state = 'chunked'; |
|
5122
|
|
|
} |
|
5123
|
|
|
else |
|
5124
|
|
|
{ |
|
5125
|
|
|
$this->state = 'emit'; |
|
5126
|
|
|
} |
|
5127
|
|
|
} |
|
5128
|
|
|
|
|
5129
|
|
|
protected function chunked() |
|
5130
|
|
|
{ |
|
5131
|
|
|
if (!preg_match('/^([0-9a-f]+)[^\r\n]*\r\n/i', trim($this->body))) |
|
5132
|
|
|
{ |
|
5133
|
|
|
$this->state = 'emit'; |
|
5134
|
|
|
return; |
|
5135
|
|
|
} |
|
5136
|
|
|
$decoded = ''; |
|
5137
|
|
|
$encoded = $this->body; |
|
5138
|
|
|
while (true) |
|
5139
|
|
|
{ |
|
5140
|
|
|
$is_chunked = (bool) preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', $encoded, $matches ); |
|
5141
|
|
|
if (!$is_chunked) |
|
5142
|
|
|
{ |
|
5143
|
|
|
// Looks like it's not chunked after all |
|
5144
|
|
|
$this->state = 'emit'; |
|
5145
|
|
|
return; |
|
5146
|
|
|
} |
|
5147
|
|
|
$length = hexdec(trim($matches[1])); |
|
5148
|
|
|
if ($length === 0) |
|
5149
|
|
|
{ |
|
5150
|
|
|
// Ignore trailer headers |
|
5151
|
|
|
$this->state = 'emit'; |
|
5152
|
|
|
$this->body = $decoded; |
|
5153
|
|
|
return; |
|
5154
|
|
|
} |
|
5155
|
|
|
$chunk_length = strlen($matches[0]); |
|
5156
|
|
|
$decoded .= $part = substr($encoded, $chunk_length, $length); |
|
5157
|
|
|
$encoded = substr($encoded, $chunk_length + $length + 2); |
|
5158
|
|
|
if (trim($encoded) === '0' || empty($encoded)) |
|
5159
|
|
|
{ |
|
5160
|
|
|
$this->state = 'emit'; |
|
5161
|
|
|
$this->body = $decoded; |
|
5162
|
|
|
return; |
|
5163
|
|
|
} |
|
5164
|
|
|
} |
|
5165
|
|
|
} |
|
5166
|
|
|
} |
|
5167
|
|
|
class SimplePie_IRI |
|
5168
|
|
|
{ |
|
5169
|
|
|
|
|
5170
|
|
|
protected $scheme = null; |
|
5171
|
|
|
|
|
5172
|
|
|
protected $iuserinfo = null; |
|
5173
|
|
|
|
|
5174
|
|
|
protected $ihost = null; |
|
5175
|
|
|
|
|
5176
|
|
|
protected $port = null; |
|
5177
|
|
|
|
|
5178
|
|
|
protected $ipath = ''; |
|
5179
|
|
|
|
|
5180
|
|
|
protected $iquery = null; |
|
5181
|
|
|
|
|
5182
|
|
|
protected $ifragment = null; |
|
5183
|
|
|
|
|
5184
|
|
|
protected $normalization = array( |
|
5185
|
|
|
'acap' => array( |
|
5186
|
|
|
'port' => 674 |
|
5187
|
|
|
), |
|
5188
|
|
|
'dict' => array( |
|
5189
|
|
|
'port' => 2628 |
|
5190
|
|
|
), |
|
5191
|
|
|
'file' => array( |
|
5192
|
|
|
'ihost' => 'localhost' |
|
5193
|
|
|
), |
|
5194
|
|
|
'http' => array( |
|
5195
|
|
|
'port' => 80, |
|
5196
|
|
|
'ipath' => '/' |
|
5197
|
|
|
), |
|
5198
|
|
|
'https' => array( |
|
5199
|
|
|
'port' => 443, |
|
5200
|
|
|
'ipath' => '/' |
|
5201
|
|
|
), |
|
5202
|
|
|
); |
|
5203
|
|
|
|
|
5204
|
|
|
public function __toString() |
|
5205
|
|
|
{ |
|
5206
|
|
|
return $this->get_iri(); |
|
5207
|
|
|
} |
|
5208
|
|
|
|
|
5209
|
|
|
public function __set($name, $value) |
|
5210
|
|
|
{ |
|
5211
|
|
|
if (method_exists($this, 'set_' . $name)) |
|
5212
|
|
|
{ |
|
5213
|
|
|
call_user_func(array($this, 'set_' . $name), $value); |
|
5214
|
|
|
} |
|
5215
|
|
|
elseif ( |
|
5216
|
|
|
$name === 'iauthority' |
|
5217
|
|
|
|| $name === 'iuserinfo' |
|
5218
|
|
|
|| $name === 'ihost' |
|
5219
|
|
|
|| $name === 'ipath' |
|
5220
|
|
|
|| $name === 'iquery' |
|
5221
|
|
|
|| $name === 'ifragment' |
|
5222
|
|
|
) |
|
5223
|
|
|
{ |
|
5224
|
|
|
call_user_func(array($this, 'set_' . substr($name, 1)), $value); |
|
5225
|
|
|
} |
|
5226
|
|
|
} |
|
5227
|
|
|
|
|
5228
|
|
|
public function __get($name) |
|
5229
|
|
|
{ |
|
5230
|
|
|
// isset() returns false for null, we don't want to do that |
|
5231
|
|
|
// Also why we use array_key_exists below instead of isset() |
|
5232
|
|
|
$props = get_object_vars($this); |
|
5233
|
|
|
if ( |
|
5234
|
|
|
$name === 'iri' || |
|
5235
|
|
|
$name === 'uri' || |
|
5236
|
|
|
$name === 'iauthority' || |
|
5237
|
|
|
$name === 'authority' |
|
5238
|
|
|
) |
|
5239
|
|
|
{ |
|
5240
|
|
|
$return = $this->{"get_$name"}(); |
|
5241
|
|
|
} |
|
5242
|
|
|
elseif (array_key_exists($name, $props)) |
|
5243
|
|
|
{ |
|
5244
|
|
|
$return = $this->$name; |
|
5245
|
|
|
} |
|
5246
|
|
|
// host -> ihost |
|
5247
|
|
|
elseif (($prop = 'i' . $name) && array_key_exists($prop, $props)) |
|
5248
|
|
|
{ |
|
5249
|
|
|
$name = $prop; |
|
5250
|
|
|
$return = $this->$prop; |
|
5251
|
|
|
} |
|
5252
|
|
|
// ischeme -> scheme |
|
5253
|
|
|
elseif (($prop = substr($name, 1)) && array_key_exists($prop, $props)) |
|
5254
|
|
|
{ |
|
5255
|
|
|
$name = $prop; |
|
5256
|
|
|
$return = $this->$prop; |
|
5257
|
|
|
} |
|
5258
|
|
|
else |
|
5259
|
|
|
{ |
|
5260
|
|
|
trigger_error('Undefined property: ' . get_class($this) . '::' . $name, E_USER_NOTICE); |
|
5261
|
|
|
$return = null; |
|
5262
|
|
|
} |
|
5263
|
|
|
if ($return === null && isset($this->normalization[$this->scheme][$name])) |
|
5264
|
|
|
{ |
|
5265
|
|
|
return $this->normalization[$this->scheme][$name]; |
|
5266
|
|
|
} |
|
5267
|
|
|
else |
|
5268
|
|
|
{ |
|
5269
|
|
|
return $return; |
|
5270
|
|
|
} |
|
5271
|
|
|
} |
|
5272
|
|
|
|
|
5273
|
|
|
public function __isset($name) |
|
5274
|
|
|
{ |
|
5275
|
|
|
if (method_exists($this, 'get_' . $name) || isset($this->$name)) |
|
5276
|
|
|
{ |
|
5277
|
|
|
return true; |
|
5278
|
|
|
} |
|
5279
|
|
|
else |
|
5280
|
|
|
{ |
|
5281
|
|
|
return false; |
|
5282
|
|
|
} |
|
5283
|
|
|
} |
|
5284
|
|
|
|
|
5285
|
|
|
public function __unset($name) |
|
5286
|
|
|
{ |
|
5287
|
|
|
if (method_exists($this, 'set_' . $name)) |
|
5288
|
|
|
{ |
|
5289
|
|
|
call_user_func(array($this, 'set_' . $name), ''); |
|
5290
|
|
|
} |
|
5291
|
|
|
} |
|
5292
|
|
|
|
|
5293
|
|
|
public function __construct($iri = null) |
|
5294
|
|
|
{ |
|
5295
|
|
|
$this->set_iri($iri); |
|
5296
|
|
|
} |
|
5297
|
|
|
|
|
5298
|
|
|
public static function absolutize($base, $relative) |
|
5299
|
|
|
{ |
|
5300
|
|
|
if (!($relative instanceof SimplePie_IRI)) |
|
5301
|
|
|
{ |
|
5302
|
|
|
$relative = new SimplePie_IRI($relative); |
|
5303
|
|
|
} |
|
5304
|
|
|
if (!$relative->is_valid()) |
|
5305
|
|
|
{ |
|
5306
|
|
|
return false; |
|
5307
|
|
|
} |
|
5308
|
|
|
elseif ($relative->scheme !== null) |
|
5309
|
|
|
{ |
|
5310
|
|
|
return clone $relative; |
|
5311
|
|
|
} |
|
5312
|
|
|
else |
|
5313
|
|
|
{ |
|
5314
|
|
|
if (!($base instanceof SimplePie_IRI)) |
|
5315
|
|
|
{ |
|
5316
|
|
|
$base = new SimplePie_IRI($base); |
|
5317
|
|
|
} |
|
5318
|
|
|
if ($base->scheme !== null && $base->is_valid()) |
|
5319
|
|
|
{ |
|
5320
|
|
|
if ($relative->get_iri() !== '') |
|
5321
|
|
|
{ |
|
5322
|
|
|
if ($relative->iuserinfo !== null || $relative->ihost !== null || $relative->port !== null) |
|
5323
|
|
|
{ |
|
5324
|
|
|
$target = clone $relative; |
|
5325
|
|
|
$target->scheme = $base->scheme; |
|
5326
|
|
|
} |
|
5327
|
|
|
else |
|
5328
|
|
|
{ |
|
5329
|
|
|
$target = new SimplePie_IRI; |
|
5330
|
|
|
$target->scheme = $base->scheme; |
|
5331
|
|
|
$target->iuserinfo = $base->iuserinfo; |
|
5332
|
|
|
$target->ihost = $base->ihost; |
|
5333
|
|
|
$target->port = $base->port; |
|
5334
|
|
|
if ($relative->ipath !== '') |
|
5335
|
|
|
{ |
|
5336
|
|
|
if ($relative->ipath[0] === '/') |
|
5337
|
|
|
{ |
|
5338
|
|
|
$target->ipath = $relative->ipath; |
|
5339
|
|
|
} |
|
5340
|
|
|
elseif (($base->iuserinfo !== null || $base->ihost !== null || $base->port !== null) && $base->ipath === '') |
|
5341
|
|
|
{ |
|
5342
|
|
|
$target->ipath = '/' . $relative->ipath; |
|
5343
|
|
|
} |
|
5344
|
|
|
elseif (($last_segment = strrpos($base->ipath, '/')) !== false) |
|
5345
|
|
|
{ |
|
5346
|
|
|
$target->ipath = substr($base->ipath, 0, $last_segment + 1) . $relative->ipath; |
|
5347
|
|
|
} |
|
5348
|
|
|
else |
|
5349
|
|
|
{ |
|
5350
|
|
|
$target->ipath = $relative->ipath; |
|
5351
|
|
|
} |
|
5352
|
|
|
$target->ipath = $target->remove_dot_segments($target->ipath); |
|
5353
|
|
|
$target->iquery = $relative->iquery; |
|
5354
|
|
|
} |
|
5355
|
|
|
else |
|
5356
|
|
|
{ |
|
5357
|
|
|
$target->ipath = $base->ipath; |
|
5358
|
|
|
if ($relative->iquery !== null) |
|
5359
|
|
|
{ |
|
5360
|
|
|
$target->iquery = $relative->iquery; |
|
5361
|
|
|
} |
|
5362
|
|
|
elseif ($base->iquery !== null) |
|
5363
|
|
|
{ |
|
5364
|
|
|
$target->iquery = $base->iquery; |
|
5365
|
|
|
} |
|
5366
|
|
|
} |
|
5367
|
|
|
$target->ifragment = $relative->ifragment; |
|
5368
|
|
|
} |
|
5369
|
|
|
} |
|
5370
|
|
|
else |
|
5371
|
|
|
{ |
|
5372
|
|
|
$target = clone $base; |
|
5373
|
|
|
$target->ifragment = null; |
|
5374
|
|
|
} |
|
5375
|
|
|
$target->scheme_normalization(); |
|
5376
|
|
|
return $target; |
|
5377
|
|
|
} |
|
5378
|
|
|
else |
|
5379
|
|
|
{ |
|
5380
|
|
|
return false; |
|
5381
|
|
|
} |
|
5382
|
|
|
} |
|
5383
|
|
|
} |
|
5384
|
|
|
|
|
5385
|
|
|
protected function parse_iri($iri) |
|
5386
|
|
|
{ |
|
5387
|
|
|
$iri = trim($iri, "\x20\x09\x0A\x0C\x0D"); |
|
5388
|
|
|
if (preg_match('/^((?P<scheme>[^:\/?#]+):)?(\/\/(?P<authority>[^\/?#]*))?(?P<path>[^?#]*)(\?(?P<query>[^#]*))?(#(?P<fragment>.*))?$/', $iri, $match)) |
|
5389
|
|
|
{ |
|
5390
|
|
|
if ($match[1] === '') |
|
5391
|
|
|
{ |
|
5392
|
|
|
$match['scheme'] = null; |
|
5393
|
|
|
} |
|
5394
|
|
|
if (!isset($match[3]) || $match[3] === '') |
|
5395
|
|
|
{ |
|
5396
|
|
|
$match['authority'] = null; |
|
5397
|
|
|
} |
|
5398
|
|
|
if (!isset($match[5])) |
|
5399
|
|
|
{ |
|
5400
|
|
|
$match['path'] = ''; |
|
5401
|
|
|
} |
|
5402
|
|
|
if (!isset($match[6]) || $match[6] === '') |
|
5403
|
|
|
{ |
|
5404
|
|
|
$match['query'] = null; |
|
5405
|
|
|
} |
|
5406
|
|
|
if (!isset($match[8]) || $match[8] === '') |
|
5407
|
|
|
{ |
|
5408
|
|
|
$match['fragment'] = null; |
|
5409
|
|
|
} |
|
5410
|
|
|
return $match; |
|
5411
|
|
|
} |
|
5412
|
|
|
else |
|
5413
|
|
|
{ |
|
5414
|
|
|
// This can occur when a paragraph is accidentally parsed as a URI |
|
5415
|
|
|
return false; |
|
5416
|
|
|
} |
|
5417
|
|
|
} |
|
5418
|
|
|
|
|
5419
|
|
|
protected function remove_dot_segments($input) |
|
5420
|
|
|
{ |
|
5421
|
|
|
$output = ''; |
|
5422
|
|
|
while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..') |
|
5423
|
|
|
{ |
|
5424
|
|
|
// A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise, |
|
5425
|
|
|
if (strpos($input, '../') === 0) |
|
5426
|
|
|
{ |
|
5427
|
|
|
$input = substr($input, 3); |
|
5428
|
|
|
} |
|
5429
|
|
|
elseif (strpos($input, './') === 0) |
|
5430
|
|
|
{ |
|
5431
|
|
|
$input = substr($input, 2); |
|
5432
|
|
|
} |
|
5433
|
|
|
// 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, |
|
5434
|
|
|
elseif (strpos($input, '/./') === 0) |
|
5435
|
|
|
{ |
|
5436
|
|
|
$input = substr($input, 2); |
|
5437
|
|
|
} |
|
5438
|
|
|
elseif ($input === '/.') |
|
5439
|
|
|
{ |
|
5440
|
|
|
$input = '/'; |
|
5441
|
|
|
} |
|
5442
|
|
|
// 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, |
|
5443
|
|
|
elseif (strpos($input, '/../') === 0) |
|
5444
|
|
|
{ |
|
5445
|
|
|
$input = substr($input, 3); |
|
5446
|
|
|
$output = substr_replace($output, '', strrpos($output, '/')); |
|
5447
|
|
|
} |
|
5448
|
|
|
elseif ($input === '/..') |
|
5449
|
|
|
{ |
|
5450
|
|
|
$input = '/'; |
|
5451
|
|
|
$output = substr_replace($output, '', strrpos($output, '/')); |
|
5452
|
|
|
} |
|
5453
|
|
|
// D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise, |
|
5454
|
|
|
elseif ($input === '.' || $input === '..') |
|
5455
|
|
|
{ |
|
5456
|
|
|
$input = ''; |
|
5457
|
|
|
} |
|
5458
|
|
|
// 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 |
|
5459
|
|
|
elseif (($pos = strpos($input, '/', 1)) !== false) |
|
5460
|
|
|
{ |
|
5461
|
|
|
$output .= substr($input, 0, $pos); |
|
5462
|
|
|
$input = substr_replace($input, '', 0, $pos); |
|
5463
|
|
|
} |
|
5464
|
|
|
else |
|
5465
|
|
|
{ |
|
5466
|
|
|
$output .= $input; |
|
5467
|
|
|
$input = ''; |
|
5468
|
|
|
} |
|
5469
|
|
|
} |
|
5470
|
|
|
return $output . $input; |
|
5471
|
|
|
} |
|
5472
|
|
|
|
|
5473
|
|
|
protected function replace_invalid_with_pct_encoding($string, $extra_chars, $iprivate = false) |
|
5474
|
|
|
{ |
|
5475
|
|
|
// Normalize as many pct-encoded sections as possible |
|
5476
|
|
|
$string = preg_replace_callback('/(?:%[A-Fa-f0-9]{2})+/', array($this, 'remove_iunreserved_percent_encoded'), $string); |
|
5477
|
|
|
// Replace invalid percent characters |
|
5478
|
|
|
$string = preg_replace('/%(?![A-Fa-f0-9]{2})/', '%25', $string); |
|
5479
|
|
|
// Add unreserved and % to $extra_chars (the latter is safe because all |
|
5480
|
|
|
// pct-encoded sections are now valid). |
|
5481
|
|
|
$extra_chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~%'; |
|
5482
|
|
|
// Now replace any bytes that aren't allowed with their pct-encoded versions |
|
5483
|
|
|
$position = 0; |
|
5484
|
|
|
$strlen = strlen($string); |
|
5485
|
|
|
while (($position += strspn($string, $extra_chars, $position)) < $strlen) |
|
5486
|
|
|
{ |
|
5487
|
|
|
$value = ord($string[$position]); |
|
5488
|
|
|
// Start position |
|
5489
|
|
|
$start = $position; |
|
5490
|
|
|
// By default we are valid |
|
5491
|
|
|
$valid = true; |
|
5492
|
|
|
// No one byte sequences are valid due to the while. |
|
5493
|
|
|
// Two byte sequence: |
|
5494
|
|
|
if (($value & 0xE0) === 0xC0) |
|
5495
|
|
|
{ |
|
5496
|
|
|
$character = ($value & 0x1F) << 6; |
|
5497
|
|
|
$length = 2; |
|
5498
|
|
|
$remaining = 1; |
|
5499
|
|
|
} |
|
5500
|
|
|
// Three byte sequence: |
|
5501
|
|
|
elseif (($value & 0xF0) === 0xE0) |
|
5502
|
|
|
{ |
|
5503
|
|
|
$character = ($value & 0x0F) << 12; |
|
5504
|
|
|
$length = 3; |
|
5505
|
|
|
$remaining = 2; |
|
5506
|
|
|
} |
|
5507
|
|
|
// Four byte sequence: |
|
5508
|
|
|
elseif (($value & 0xF8) === 0xF0) |
|
5509
|
|
|
{ |
|
5510
|
|
|
$character = ($value & 0x07) << 18; |
|
5511
|
|
|
$length = 4; |
|
5512
|
|
|
$remaining = 3; |
|
5513
|
|
|
} |
|
5514
|
|
|
// Invalid byte: |
|
5515
|
|
|
else |
|
5516
|
|
|
{ |
|
5517
|
|
|
$valid = false; |
|
5518
|
|
|
$length = 1; |
|
5519
|
|
|
$remaining = 0; |
|
5520
|
|
|
} |
|
5521
|
|
|
if ($remaining) |
|
5522
|
|
|
{ |
|
5523
|
|
|
if ($position + $length <= $strlen) |
|
5524
|
|
|
{ |
|
5525
|
|
|
for ($position++; $remaining; $position++) |
|
5526
|
|
|
{ |
|
5527
|
|
|
$value = ord($string[$position]); |
|
5528
|
|
|
// Check that the byte is valid, then add it to the character: |
|
5529
|
|
|
if (($value & 0xC0) === 0x80) |
|
5530
|
|
|
{ |
|
5531
|
|
|
$character |= ($value & 0x3F) << (--$remaining * 6); |
|
5532
|
|
|
} |
|
5533
|
|
|
// If it is invalid, count the sequence as invalid and reprocess the current byte: |
|
5534
|
|
|
else |
|
5535
|
|
|
{ |
|
5536
|
|
|
$valid = false; |
|
5537
|
|
|
$position--; |
|
5538
|
|
|
|
|
5539
|
|
|
break; |
|
5540
|
|
|
} |
|
5541
|
|
|
} |
|
5542
|
|
|
} |
|
5543
|
|
|
else |
|
5544
|
|
|
{ |
|
5545
|
|
|
$position = $strlen - 1; |
|
5546
|
|
|
$valid = false; |
|
5547
|
|
|
} |
|
5548
|
|
|
} |
|
5549
|
|
|
// Percent encode anything invalid or not in ucschar |
|
5550
|
|
|
if ( |
|
5551
|
|
|
// Invalid sequences |
|
5552
|
|
|
!$valid |
|
5553
|
|
|
// Non-shortest form sequences are invalid |
|
5554
|
|
|
|| $length > 1 && $character <= 0x7F |
|
5555
|
|
|
|| $length > 2 && $character <= 0x7FF |
|
5556
|
|
|
|| $length > 3 && $character <= 0xFFFF |
|
5557
|
|
|
// Outside of range of ucschar codepoints |
|
5558
|
|
|
// Noncharacters |
|
5559
|
|
|
|| ($character & 0xFFFE) === 0xFFFE |
|
5560
|
|
|
|| $character >= 0xFDD0 && $character <= 0xFDEF |
|
5561
|
|
|
|| ( |
|
5562
|
|
|
// Everything else not in ucschar |
|
5563
|
|
|
$character > 0xD7FF && $character < 0xF900 |
|
5564
|
|
|
|| $character < 0xA0 |
|
5565
|
|
|
|| $character > 0xEFFFD |
|
5566
|
|
|
) |
|
5567
|
|
|
&& ( |
|
5568
|
|
|
// Everything not in iprivate, if it applies |
|
5569
|
|
|
!$iprivate |
|
5570
|
|
|
|| $character < 0xE000 |
|
5571
|
|
|
|| $character > 0x10FFFD |
|
5572
|
|
|
) |
|
5573
|
|
|
) |
|
5574
|
|
|
{ |
|
5575
|
|
|
// If we were a character, pretend we weren't, but rather an error. |
|
5576
|
|
|
if ($valid) |
|
5577
|
|
|
$position--; |
|
5578
|
|
|
for ($j = $start; $j <= $position; $j++) |
|
5579
|
|
|
{ |
|
5580
|
|
|
$string = substr_replace($string, sprintf('%%%02X', ord($string[$j])), $j, 1); |
|
5581
|
|
|
$j += 2; |
|
5582
|
|
|
$position += 2; |
|
5583
|
|
|
$strlen += 2; |
|
5584
|
|
|
} |
|
5585
|
|
|
} |
|
5586
|
|
|
} |
|
5587
|
|
|
return $string; |
|
5588
|
|
|
} |
|
5589
|
|
|
|
|
5590
|
|
|
protected function remove_iunreserved_percent_encoded($match) |
|
5591
|
|
|
{ |
|
5592
|
|
|
// As we just have valid percent encoded sequences we can just explode |
|
5593
|
|
|
// and ignore the first member of the returned array (an empty string). |
|
5594
|
|
|
$bytes = explode('%', $match[0]); |
|
5595
|
|
|
// Initialize the new string (this is what will be returned) and that |
|
5596
|
|
|
// there are no bytes remaining in the current sequence (unsurprising |
|
5597
|
|
|
// at the first byte!). |
|
5598
|
|
|
$string = ''; |
|
5599
|
|
|
$remaining = 0; |
|
5600
|
|
|
// Loop over each and every byte, and set $value to its value |
|
5601
|
|
|
for ($i = 1, $len = count($bytes); $i < $len; $i++) |
|
5602
|
|
|
{ |
|
5603
|
|
|
$value = hexdec($bytes[$i]); |
|
5604
|
|
|
// If we're the first byte of sequence: |
|
5605
|
|
|
if (!$remaining) |
|
5606
|
|
|
{ |
|
5607
|
|
|
// Start position |
|
5608
|
|
|
$start = $i; |
|
5609
|
|
|
// By default we are valid |
|
5610
|
|
|
$valid = true; |
|
5611
|
|
|
// One byte sequence: |
|
5612
|
|
|
if ($value <= 0x7F) |
|
5613
|
|
|
{ |
|
5614
|
|
|
$character = $value; |
|
5615
|
|
|
$length = 1; |
|
5616
|
|
|
} |
|
5617
|
|
|
// Two byte sequence: |
|
5618
|
|
|
elseif (($value & 0xE0) === 0xC0) |
|
5619
|
|
|
{ |
|
5620
|
|
|
$character = ($value & 0x1F) << 6; |
|
5621
|
|
|
$length = 2; |
|
5622
|
|
|
$remaining = 1; |
|
5623
|
|
|
} |
|
5624
|
|
|
// Three byte sequence: |
|
5625
|
|
|
elseif (($value & 0xF0) === 0xE0) |
|
5626
|
|
|
{ |
|
5627
|
|
|
$character = ($value & 0x0F) << 12; |
|
5628
|
|
|
$length = 3; |
|
5629
|
|
|
$remaining = 2; |
|
5630
|
|
|
} |
|
5631
|
|
|
// Four byte sequence: |
|
5632
|
|
|
elseif (($value & 0xF8) === 0xF0) |
|
5633
|
|
|
{ |
|
5634
|
|
|
$character = ($value & 0x07) << 18; |
|
5635
|
|
|
$length = 4; |
|
5636
|
|
|
$remaining = 3; |
|
5637
|
|
|
} |
|
5638
|
|
|
// Invalid byte: |
|
5639
|
|
|
else |
|
5640
|
|
|
{ |
|
5641
|
|
|
$valid = false; |
|
5642
|
|
|
$remaining = 0; |
|
5643
|
|
|
} |
|
5644
|
|
|
} |
|
5645
|
|
|
// Continuation byte: |
|
5646
|
|
|
else |
|
5647
|
|
|
{ |
|
5648
|
|
|
// Check that the byte is valid, then add it to the character: |
|
5649
|
|
|
if (($value & 0xC0) === 0x80) |
|
5650
|
|
|
{ |
|
5651
|
|
|
$remaining--; |
|
5652
|
|
|
$character |= ($value & 0x3F) << ($remaining * 6); |
|
5653
|
|
|
} |
|
5654
|
|
|
// If it is invalid, count the sequence as invalid and reprocess the current byte as the start of a sequence: |
|
5655
|
|
|
else |
|
5656
|
|
|
{ |
|
5657
|
|
|
$valid = false; |
|
5658
|
|
|
$remaining = 0; |
|
5659
|
|
|
$i--; |
|
5660
|
|
|
} |
|
5661
|
|
|
} |
|
5662
|
|
|
// If we've reached the end of the current byte sequence, append it to Unicode::$data |
|
5663
|
|
|
if (!$remaining) |
|
5664
|
|
|
{ |
|
5665
|
|
|
// Percent encode anything invalid or not in iunreserved |
|
5666
|
|
|
if ( |
|
5667
|
|
|
// Invalid sequences |
|
5668
|
|
|
!$valid |
|
5669
|
|
|
// Non-shortest form sequences are invalid |
|
5670
|
|
|
|| $length > 1 && $character <= 0x7F |
|
5671
|
|
|
|| $length > 2 && $character <= 0x7FF |
|
5672
|
|
|
|| $length > 3 && $character <= 0xFFFF |
|
5673
|
|
|
// Outside of range of iunreserved codepoints |
|
5674
|
|
|
|| $character < 0x2D |
|
5675
|
|
|
|| $character > 0xEFFFD |
|
5676
|
|
|
// Noncharacters |
|
5677
|
|
|
|| ($character & 0xFFFE) === 0xFFFE |
|
5678
|
|
|
|| $character >= 0xFDD0 && $character <= 0xFDEF |
|
5679
|
|
|
// Everything else not in iunreserved (this is all BMP) |
|
5680
|
|
|
|| $character === 0x2F |
|
5681
|
|
|
|| $character > 0x39 && $character < 0x41 |
|
5682
|
|
|
|| $character > 0x5A && $character < 0x61 |
|
5683
|
|
|
|| $character > 0x7A && $character < 0x7E |
|
5684
|
|
|
|| $character > 0x7E && $character < 0xA0 |
|
5685
|
|
|
|| $character > 0xD7FF && $character < 0xF900 |
|
5686
|
|
|
) |
|
5687
|
|
|
{ |
|
5688
|
|
|
for ($j = $start; $j <= $i; $j++) |
|
5689
|
|
|
{ |
|
5690
|
|
|
$string .= '%' . strtoupper($bytes[$j]); |
|
5691
|
|
|
} |
|
5692
|
|
|
} |
|
5693
|
|
|
else |
|
5694
|
|
|
{ |
|
5695
|
|
|
for ($j = $start; $j <= $i; $j++) |
|
5696
|
|
|
{ |
|
5697
|
|
|
$string .= chr(hexdec($bytes[$j])); |
|
5698
|
|
|
} |
|
5699
|
|
|
} |
|
5700
|
|
|
} |
|
5701
|
|
|
} |
|
5702
|
|
|
// If we have any bytes left over they are invalid (i.e., we are |
|
5703
|
|
|
// mid-way through a multi-byte sequence) |
|
5704
|
|
|
if ($remaining) |
|
5705
|
|
|
{ |
|
5706
|
|
|
for ($j = $start; $j < $len; $j++) |
|
5707
|
|
|
{ |
|
5708
|
|
|
$string .= '%' . strtoupper($bytes[$j]); |
|
5709
|
|
|
} |
|
5710
|
|
|
} |
|
5711
|
|
|
return $string; |
|
5712
|
|
|
} |
|
5713
|
|
|
protected function scheme_normalization() |
|
5714
|
|
|
{ |
|
5715
|
|
|
if (isset($this->normalization[$this->scheme]['iuserinfo']) && $this->iuserinfo === $this->normalization[$this->scheme]['iuserinfo']) |
|
5716
|
|
|
{ |
|
5717
|
|
|
$this->iuserinfo = null; |
|
5718
|
|
|
} |
|
5719
|
|
|
if (isset($this->normalization[$this->scheme]['ihost']) && $this->ihost === $this->normalization[$this->scheme]['ihost']) |
|
5720
|
|
|
{ |
|
5721
|
|
|
$this->ihost = null; |
|
5722
|
|
|
} |
|
5723
|
|
|
if (isset($this->normalization[$this->scheme]['port']) && $this->port === $this->normalization[$this->scheme]['port']) |
|
5724
|
|
|
{ |
|
5725
|
|
|
$this->port = null; |
|
5726
|
|
|
} |
|
5727
|
|
|
if (isset($this->normalization[$this->scheme]['ipath']) && $this->ipath === $this->normalization[$this->scheme]['ipath']) |
|
5728
|
|
|
{ |
|
5729
|
|
|
$this->ipath = ''; |
|
5730
|
|
|
} |
|
5731
|
|
|
if (isset($this->normalization[$this->scheme]['iquery']) && $this->iquery === $this->normalization[$this->scheme]['iquery']) |
|
5732
|
|
|
{ |
|
5733
|
|
|
$this->iquery = null; |
|
5734
|
|
|
} |
|
5735
|
|
|
if (isset($this->normalization[$this->scheme]['ifragment']) && $this->ifragment === $this->normalization[$this->scheme]['ifragment']) |
|
5736
|
|
|
{ |
|
5737
|
|
|
$this->ifragment = null; |
|
5738
|
|
|
} |
|
5739
|
|
|
} |
|
5740
|
|
|
|
|
5741
|
|
|
public function is_valid() |
|
5742
|
|
|
{ |
|
5743
|
|
|
$isauthority = $this->iuserinfo !== null || $this->ihost !== null || $this->port !== null; |
|
5744
|
|
|
if ($this->ipath !== '' && |
|
5745
|
|
|
( |
|
5746
|
|
|
$isauthority && ( |
|
5747
|
|
|
$this->ipath[0] !== '/' || |
|
5748
|
|
|
substr($this->ipath, 0, 2) === '//' |
|
5749
|
|
|
) || |
|
5750
|
|
|
( |
|
5751
|
|
|
$this->scheme === null && |
|
5752
|
|
|
!$isauthority && |
|
5753
|
|
|
strpos($this->ipath, ':') !== false && |
|
5754
|
|
|
(strpos($this->ipath, '/') === false ? true : strpos($this->ipath, ':') < strpos($this->ipath, '/')) |
|
5755
|
|
|
) |
|
5756
|
|
|
) |
|
5757
|
|
|
) |
|
5758
|
|
|
{ |
|
5759
|
|
|
return false; |
|
5760
|
|
|
} |
|
5761
|
|
|
return true; |
|
5762
|
|
|
} |
|
5763
|
|
|
|
|
5764
|
|
|
public function set_iri($iri) |
|
5765
|
|
|
{ |
|
5766
|
|
|
static $cache; |
|
5767
|
|
|
if (!$cache) |
|
5768
|
|
|
{ |
|
5769
|
|
|
$cache = array(); |
|
5770
|
|
|
} |
|
5771
|
|
|
if ($iri === null) |
|
5772
|
|
|
{ |
|
5773
|
|
|
return true; |
|
5774
|
|
|
} |
|
5775
|
|
|
elseif (isset($cache[$iri])) |
|
5776
|
|
|
{ |
|
5777
|
|
|
list($this->scheme, |
|
5778
|
|
|
$this->iuserinfo, |
|
5779
|
|
|
$this->ihost, |
|
5780
|
|
|
$this->port, |
|
5781
|
|
|
$this->ipath, |
|
5782
|
|
|
$this->iquery, |
|
5783
|
|
|
$this->ifragment, |
|
5784
|
|
|
$return) = $cache[$iri]; |
|
5785
|
|
|
return $return; |
|
5786
|
|
|
} |
|
5787
|
|
|
else |
|
5788
|
|
|
{ |
|
5789
|
|
|
$parsed = $this->parse_iri((string) $iri); |
|
5790
|
|
|
if (!$parsed) |
|
5791
|
|
|
{ |
|
5792
|
|
|
return false; |
|
5793
|
|
|
} |
|
5794
|
|
|
$return = $this->set_scheme($parsed['scheme']) |
|
5795
|
|
|
&& $this->set_authority($parsed['authority']) |
|
5796
|
|
|
&& $this->set_path($parsed['path']) |
|
5797
|
|
|
&& $this->set_query($parsed['query']) |
|
5798
|
|
|
&& $this->set_fragment($parsed['fragment']); |
|
5799
|
|
|
$cache[$iri] = array($this->scheme, |
|
5800
|
|
|
$this->iuserinfo, |
|
5801
|
|
|
$this->ihost, |
|
5802
|
|
|
$this->port, |
|
5803
|
|
|
$this->ipath, |
|
5804
|
|
|
$this->iquery, |
|
5805
|
|
|
$this->ifragment, |
|
5806
|
|
|
$return); |
|
5807
|
|
|
return $return; |
|
5808
|
|
|
} |
|
5809
|
|
|
} |
|
5810
|
|
|
|
|
5811
|
|
|
public function set_scheme($scheme) |
|
5812
|
|
|
{ |
|
5813
|
|
|
if ($scheme === null) |
|
5814
|
|
|
{ |
|
5815
|
|
|
$this->scheme = null; |
|
5816
|
|
|
} |
|
5817
|
|
|
elseif (!preg_match('/^[A-Za-z][0-9A-Za-z+\-.]*$/', $scheme)) |
|
5818
|
|
|
{ |
|
5819
|
|
|
$this->scheme = null; |
|
5820
|
|
|
return false; |
|
5821
|
|
|
} |
|
5822
|
|
|
else |
|
5823
|
|
|
{ |
|
5824
|
|
|
$this->scheme = strtolower($scheme); |
|
5825
|
|
|
} |
|
5826
|
|
|
return true; |
|
5827
|
|
|
} |
|
5828
|
|
|
|
|
5829
|
|
|
public function set_authority($authority) |
|
5830
|
|
|
{ |
|
5831
|
|
|
static $cache; |
|
5832
|
|
|
if (!$cache) |
|
5833
|
|
|
$cache = array(); |
|
5834
|
|
|
if ($authority === null) |
|
5835
|
|
|
{ |
|
5836
|
|
|
$this->iuserinfo = null; |
|
5837
|
|
|
$this->ihost = null; |
|
5838
|
|
|
$this->port = null; |
|
5839
|
|
|
return true; |
|
5840
|
|
|
} |
|
5841
|
|
|
elseif (isset($cache[$authority])) |
|
5842
|
|
|
{ |
|
5843
|
|
|
list($this->iuserinfo, |
|
5844
|
|
|
$this->ihost, |
|
5845
|
|
|
$this->port, |
|
5846
|
|
|
$return) = $cache[$authority]; |
|
5847
|
|
|
return $return; |
|
5848
|
|
|
} |
|
5849
|
|
|
else |
|
5850
|
|
|
{ |
|
5851
|
|
|
$remaining = $authority; |
|
5852
|
|
|
if (($iuserinfo_end = strrpos($remaining, '@')) !== false) |
|
5853
|
|
|
{ |
|
5854
|
|
|
$iuserinfo = substr($remaining, 0, $iuserinfo_end); |
|
5855
|
|
|
$remaining = substr($remaining, $iuserinfo_end + 1); |
|
5856
|
|
|
} |
|
5857
|
|
|
else |
|
5858
|
|
|
{ |
|
5859
|
|
|
$iuserinfo = null; |
|
5860
|
|
|
} |
|
5861
|
|
|
if (($port_start = strpos($remaining, ':', strpos($remaining, ']'))) !== false) |
|
5862
|
|
|
{ |
|
5863
|
|
|
if (($port = substr($remaining, $port_start + 1)) === false) |
|
5864
|
|
|
{ |
|
5865
|
|
|
$port = null; |
|
5866
|
|
|
} |
|
5867
|
|
|
$remaining = substr($remaining, 0, $port_start); |
|
5868
|
|
|
} |
|
5869
|
|
|
else |
|
5870
|
|
|
{ |
|
5871
|
|
|
$port = null; |
|
5872
|
|
|
} |
|
5873
|
|
|
$return = $this->set_userinfo($iuserinfo) && |
|
5874
|
|
|
$this->set_host($remaining) && |
|
5875
|
|
|
$this->set_port($port); |
|
5876
|
|
|
$cache[$authority] = array($this->iuserinfo, |
|
5877
|
|
|
$this->ihost, |
|
5878
|
|
|
$this->port, |
|
5879
|
|
|
$return); |
|
5880
|
|
|
return $return; |
|
5881
|
|
|
} |
|
5882
|
|
|
} |
|
5883
|
|
|
|
|
5884
|
|
|
public function set_userinfo($iuserinfo) |
|
5885
|
|
|
{ |
|
5886
|
|
|
if ($iuserinfo === null) |
|
5887
|
|
|
{ |
|
5888
|
|
|
$this->iuserinfo = null; |
|
5889
|
|
|
} |
|
5890
|
|
|
else |
|
5891
|
|
|
{ |
|
5892
|
|
|
$this->iuserinfo = $this->replace_invalid_with_pct_encoding($iuserinfo, '!$&\'()*+,;=:'); |
|
5893
|
|
|
$this->scheme_normalization(); |
|
5894
|
|
|
} |
|
5895
|
|
|
return true; |
|
5896
|
|
|
} |
|
5897
|
|
|
|
|
5898
|
|
|
public function set_host($ihost) |
|
5899
|
|
|
{ |
|
5900
|
|
|
if ($ihost === null) |
|
5901
|
|
|
{ |
|
5902
|
|
|
$this->ihost = null; |
|
5903
|
|
|
return true; |
|
5904
|
|
|
} |
|
5905
|
|
|
elseif (substr($ihost, 0, 1) === '[' && substr($ihost, -1) === ']') |
|
5906
|
|
|
{ |
|
5907
|
|
|
if (SimplePie_Net_IPv6::check_ipv6(substr($ihost, 1, -1))) |
|
5908
|
|
|
{ |
|
5909
|
|
|
$this->ihost = '[' . SimplePie_Net_IPv6::compress(substr($ihost, 1, -1)) . ']'; |
|
5910
|
|
|
} |
|
5911
|
|
|
else |
|
5912
|
|
|
{ |
|
5913
|
|
|
$this->ihost = null; |
|
5914
|
|
|
return false; |
|
5915
|
|
|
} |
|
5916
|
|
|
} |
|
5917
|
|
|
else |
|
5918
|
|
|
{ |
|
5919
|
|
|
$ihost = $this->replace_invalid_with_pct_encoding($ihost, '!$&\'()*+,;='); |
|
5920
|
|
|
// Lowercase, but ignore pct-encoded sections (as they should |
|
5921
|
|
|
// remain uppercase). This must be done after the previous step |
|
5922
|
|
|
// as that can add unescaped characters. |
|
5923
|
|
|
$position = 0; |
|
5924
|
|
|
$strlen = strlen($ihost); |
|
5925
|
|
|
while (($position += strcspn($ihost, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ%', $position)) < $strlen) |
|
5926
|
|
|
{ |
|
5927
|
|
|
if ($ihost[$position] === '%') |
|
5928
|
|
|
{ |
|
5929
|
|
|
$position += 3; |
|
5930
|
|
|
} |
|
5931
|
|
|
else |
|
5932
|
|
|
{ |
|
5933
|
|
|
$ihost[$position] = strtolower($ihost[$position]); |
|
5934
|
|
|
$position++; |
|
5935
|
|
|
} |
|
5936
|
|
|
} |
|
5937
|
|
|
$this->ihost = $ihost; |
|
5938
|
|
|
} |
|
5939
|
|
|
$this->scheme_normalization(); |
|
5940
|
|
|
return true; |
|
5941
|
|
|
} |
|
5942
|
|
|
|
|
5943
|
|
|
public function set_port($port) |
|
5944
|
|
|
{ |
|
5945
|
|
|
if ($port === null) |
|
5946
|
|
|
{ |
|
5947
|
|
|
$this->port = null; |
|
5948
|
|
|
return true; |
|
5949
|
|
|
} |
|
5950
|
|
|
elseif (strspn($port, '0123456789') === strlen($port)) |
|
5951
|
|
|
{ |
|
5952
|
|
|
$this->port = (int) $port; |
|
5953
|
|
|
$this->scheme_normalization(); |
|
5954
|
|
|
return true; |
|
5955
|
|
|
} |
|
5956
|
|
|
else |
|
5957
|
|
|
{ |
|
5958
|
|
|
$this->port = null; |
|
5959
|
|
|
return false; |
|
5960
|
|
|
} |
|
5961
|
|
|
} |
|
5962
|
|
|
|
|
5963
|
|
|
public function set_path($ipath) |
|
5964
|
|
|
{ |
|
5965
|
|
|
static $cache; |
|
5966
|
|
|
if (!$cache) |
|
5967
|
|
|
{ |
|
5968
|
|
|
$cache = array(); |
|
5969
|
|
|
} |
|
5970
|
|
|
$ipath = (string) $ipath; |
|
5971
|
|
|
if (isset($cache[$ipath])) |
|
5972
|
|
|
{ |
|
5973
|
|
|
$this->ipath = $cache[$ipath][(int) ($this->scheme !== null)]; |
|
5974
|
|
|
} |
|
5975
|
|
|
else |
|
5976
|
|
|
{ |
|
5977
|
|
|
$valid = $this->replace_invalid_with_pct_encoding($ipath, '!$&\'()*+,;=@:/'); |
|
5978
|
|
|
$removed = $this->remove_dot_segments($valid); |
|
5979
|
|
|
$cache[$ipath] = array($valid, $removed); |
|
5980
|
|
|
$this->ipath = ($this->scheme !== null) ? $removed : $valid; |
|
5981
|
|
|
} |
|
5982
|
|
|
$this->scheme_normalization(); |
|
5983
|
|
|
return true; |
|
5984
|
|
|
} |
|
5985
|
|
|
|
|
5986
|
|
|
public function set_query($iquery) |
|
5987
|
|
|
{ |
|
5988
|
|
|
if ($iquery === null) |
|
5989
|
|
|
{ |
|
5990
|
|
|
$this->iquery = null; |
|
5991
|
|
|
} |
|
5992
|
|
|
else |
|
5993
|
|
|
{ |
|
5994
|
|
|
$this->iquery = $this->replace_invalid_with_pct_encoding($iquery, '!$&\'()*+,;=:@/?', true); |
|
5995
|
|
|
$this->scheme_normalization(); |
|
5996
|
|
|
} |
|
5997
|
|
|
return true; |
|
5998
|
|
|
} |
|
5999
|
|
|
|
|
6000
|
|
|
public function set_fragment($ifragment) |
|
6001
|
|
|
{ |
|
6002
|
|
|
if ($ifragment === null) |
|
6003
|
|
|
{ |
|
6004
|
|
|
$this->ifragment = null; |
|
6005
|
|
|
} |
|
6006
|
|
|
else |
|
6007
|
|
|
{ |
|
6008
|
|
|
$this->ifragment = $this->replace_invalid_with_pct_encoding($ifragment, '!$&\'()*+,;=:@/?'); |
|
6009
|
|
|
$this->scheme_normalization(); |
|
6010
|
|
|
} |
|
6011
|
|
|
return true; |
|
6012
|
|
|
} |
|
6013
|
|
|
|
|
6014
|
|
|
public function to_uri($string) |
|
6015
|
|
|
{ |
|
6016
|
|
|
static $non_ascii; |
|
6017
|
|
|
if (!$non_ascii) |
|
6018
|
|
|
{ |
|
6019
|
|
|
$non_ascii = implode('', range("\x80", "\xFF")); |
|
6020
|
|
|
} |
|
6021
|
|
|
$position = 0; |
|
6022
|
|
|
$strlen = strlen($string); |
|
6023
|
|
|
while (($position += strcspn($string, $non_ascii, $position)) < $strlen) |
|
6024
|
|
|
{ |
|
6025
|
|
|
$string = substr_replace($string, sprintf('%%%02X', ord($string[$position])), $position, 1); |
|
6026
|
|
|
$position += 3; |
|
6027
|
|
|
$strlen += 2; |
|
6028
|
|
|
} |
|
6029
|
|
|
return $string; |
|
6030
|
|
|
} |
|
6031
|
|
|
|
|
6032
|
|
|
public function get_iri() |
|
6033
|
|
|
{ |
|
6034
|
|
|
if (!$this->is_valid()) |
|
6035
|
|
|
{ |
|
6036
|
|
|
return false; |
|
6037
|
|
|
} |
|
6038
|
|
|
$iri = ''; |
|
6039
|
|
|
if ($this->scheme !== null) |
|
6040
|
|
|
{ |
|
6041
|
|
|
$iri .= $this->scheme . ':'; |
|
6042
|
|
|
} |
|
6043
|
|
|
if (($iauthority = $this->get_iauthority()) !== null) |
|
6044
|
|
|
{ |
|
6045
|
|
|
$iri .= '//' . $iauthority; |
|
6046
|
|
|
} |
|
6047
|
|
|
if ($this->ipath !== '') |
|
6048
|
|
|
{ |
|
6049
|
|
|
$iri .= $this->ipath; |
|
6050
|
|
|
} |
|
6051
|
|
|
elseif (!empty($this->normalization[$this->scheme]['ipath']) && $iauthority !== null && $iauthority !== '') |
|
6052
|
|
|
{ |
|
6053
|
|
|
$iri .= $this->normalization[$this->scheme]['ipath']; |
|
6054
|
|
|
} |
|
6055
|
|
|
if ($this->iquery !== null) |
|
6056
|
|
|
{ |
|
6057
|
|
|
$iri .= '?' . $this->iquery; |
|
6058
|
|
|
} |
|
6059
|
|
|
if ($this->ifragment !== null) |
|
6060
|
|
|
{ |
|
6061
|
|
|
$iri .= '#' . $this->ifragment; |
|
6062
|
|
|
} |
|
6063
|
|
|
return $iri; |
|
6064
|
|
|
} |
|
6065
|
|
|
|
|
6066
|
|
|
public function get_uri() |
|
6067
|
|
|
{ |
|
6068
|
|
|
return $this->to_uri($this->get_iri()); |
|
6069
|
|
|
} |
|
6070
|
|
|
|
|
6071
|
|
|
protected function get_iauthority() |
|
6072
|
|
|
{ |
|
6073
|
|
|
if ($this->iuserinfo !== null || $this->ihost !== null || $this->port !== null) |
|
6074
|
|
|
{ |
|
6075
|
|
|
$iauthority = ''; |
|
6076
|
|
|
if ($this->iuserinfo !== null) |
|
6077
|
|
|
{ |
|
6078
|
|
|
$iauthority .= $this->iuserinfo . '@'; |
|
6079
|
|
|
} |
|
6080
|
|
|
if ($this->ihost !== null) |
|
6081
|
|
|
{ |
|
6082
|
|
|
$iauthority .= $this->ihost; |
|
6083
|
|
|
} |
|
6084
|
|
|
if ($this->port !== null) |
|
6085
|
|
|
{ |
|
6086
|
|
|
$iauthority .= ':' . $this->port; |
|
6087
|
|
|
} |
|
6088
|
|
|
return $iauthority; |
|
6089
|
|
|
} |
|
6090
|
|
|
else |
|
6091
|
|
|
{ |
|
6092
|
|
|
return null; |
|
6093
|
|
|
} |
|
6094
|
|
|
} |
|
6095
|
|
|
|
|
6096
|
|
|
protected function get_authority() |
|
6097
|
|
|
{ |
|
6098
|
|
|
$iauthority = $this->get_iauthority(); |
|
6099
|
|
|
if (is_string($iauthority)) |
|
6100
|
|
|
return $this->to_uri($iauthority); |
|
6101
|
|
|
else |
|
6102
|
|
|
return $iauthority; |
|
6103
|
|
|
} |
|
6104
|
|
|
} |
|
6105
|
|
|
class SimplePie_Item |
|
6106
|
|
|
{ |
|
6107
|
|
|
|
|
6108
|
|
|
var $feed; |
|
6109
|
|
|
|
|
6110
|
|
|
var $data = array(); |
|
6111
|
|
|
|
|
6112
|
|
|
protected $registry; |
|
6113
|
|
|
|
|
6114
|
|
|
public function __construct($feed, $data) |
|
6115
|
|
|
{ |
|
6116
|
|
|
$this->feed = $feed; |
|
6117
|
|
|
$this->data = $data; |
|
6118
|
|
|
} |
|
6119
|
|
|
|
|
6120
|
|
|
public function set_registry(SimplePie_Registry $registry) |
|
6121
|
|
|
{ |
|
6122
|
|
|
$this->registry = $registry; |
|
6123
|
|
|
} |
|
6124
|
|
|
|
|
6125
|
|
|
public function __toString() |
|
6126
|
|
|
{ |
|
6127
|
|
|
return md5(serialize($this->data)); |
|
6128
|
|
|
} |
|
6129
|
|
|
|
|
6130
|
|
|
public function __destruct() |
|
6131
|
|
|
{ |
|
6132
|
|
|
if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) |
|
6133
|
|
|
{ |
|
6134
|
|
|
unset($this->feed); |
|
6135
|
|
|
} |
|
6136
|
|
|
} |
|
6137
|
|
|
|
|
6138
|
|
|
public function get_item_tags($namespace, $tag) |
|
6139
|
|
|
{ |
|
6140
|
|
|
if (isset($this->data['child'][$namespace][$tag])) |
|
6141
|
|
|
{ |
|
6142
|
|
|
return $this->data['child'][$namespace][$tag]; |
|
6143
|
|
|
} |
|
6144
|
|
|
else |
|
6145
|
|
|
{ |
|
6146
|
|
|
return null; |
|
6147
|
|
|
} |
|
6148
|
|
|
} |
|
6149
|
|
|
|
|
6150
|
|
|
public function get_base($element = array()) |
|
6151
|
|
|
{ |
|
6152
|
|
|
return $this->feed->get_base($element); |
|
6153
|
|
|
} |
|
6154
|
|
|
|
|
6155
|
|
|
public function sanitize($data, $type, $base = '') |
|
6156
|
|
|
{ |
|
6157
|
|
|
return $this->feed->sanitize($data, $type, $base); |
|
6158
|
|
|
} |
|
6159
|
|
|
|
|
6160
|
|
|
public function get_feed() |
|
6161
|
|
|
{ |
|
6162
|
|
|
return $this->feed; |
|
6163
|
|
|
} |
|
6164
|
|
|
|
|
6165
|
|
|
public function get_id($hash = false) |
|
6166
|
|
|
{ |
|
6167
|
|
|
if (!$hash) |
|
6168
|
|
|
{ |
|
6169
|
|
|
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id')) |
|
6170
|
|
|
{ |
|
6171
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6172
|
|
|
} |
|
6173
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id')) |
|
6174
|
|
|
{ |
|
6175
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6176
|
|
|
} |
|
6177
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) |
|
6178
|
|
|
{ |
|
6179
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6180
|
|
|
} |
|
6181
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier')) |
|
6182
|
|
|
{ |
|
6183
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6184
|
|
|
} |
|
6185
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier')) |
|
6186
|
|
|
{ |
|
6187
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6188
|
|
|
} |
|
6189
|
|
|
elseif (isset($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'])) |
|
6190
|
|
|
{ |
|
6191
|
|
|
return $this->sanitize($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6192
|
|
|
} |
|
6193
|
|
|
elseif (($return = $this->get_permalink()) !== null) |
|
6194
|
|
|
{ |
|
6195
|
|
|
return $return; |
|
6196
|
|
|
} |
|
6197
|
|
|
elseif (($return = $this->get_title()) !== null) |
|
6198
|
|
|
{ |
|
6199
|
|
|
return $return; |
|
6200
|
|
|
} |
|
6201
|
|
|
} |
|
6202
|
|
|
if ($this->get_permalink() !== null || $this->get_title() !== null) |
|
6203
|
|
|
{ |
|
6204
|
|
|
return md5($this->get_permalink() . $this->get_title()); |
|
6205
|
|
|
} |
|
6206
|
|
|
else |
|
6207
|
|
|
{ |
|
6208
|
|
|
return md5(serialize($this->data)); |
|
6209
|
|
|
} |
|
6210
|
|
|
} |
|
6211
|
|
|
|
|
6212
|
|
|
public function get_title() |
|
6213
|
|
|
{ |
|
6214
|
|
|
if (!isset($this->data['title'])) |
|
6215
|
|
|
{ |
|
6216
|
|
|
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) |
|
6217
|
|
|
{ |
|
6218
|
|
|
$this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
6219
|
|
|
} |
|
6220
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) |
|
6221
|
|
|
{ |
|
6222
|
|
|
$this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
6223
|
|
|
} |
|
6224
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) |
|
6225
|
|
|
{ |
|
6226
|
|
|
$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
6227
|
|
|
} |
|
6228
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) |
|
6229
|
|
|
{ |
|
6230
|
|
|
$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
6231
|
|
|
} |
|
6232
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) |
|
6233
|
|
|
{ |
|
6234
|
|
|
$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
6235
|
|
|
} |
|
6236
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) |
|
6237
|
|
|
{ |
|
6238
|
|
|
$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6239
|
|
|
} |
|
6240
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) |
|
6241
|
|
|
{ |
|
6242
|
|
|
$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6243
|
|
|
} |
|
6244
|
|
|
else |
|
6245
|
|
|
{ |
|
6246
|
|
|
$this->data['title'] = null; |
|
6247
|
|
|
} |
|
6248
|
|
|
} |
|
6249
|
|
|
return $this->data['title']; |
|
6250
|
|
|
} |
|
6251
|
|
|
|
|
6252
|
|
|
public function get_description($description_only = false) |
|
6253
|
|
|
{ |
|
6254
|
|
|
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) |
|
6255
|
|
|
{ |
|
6256
|
|
|
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
6257
|
|
|
} |
|
6258
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary')) |
|
6259
|
|
|
{ |
|
6260
|
|
|
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
6261
|
|
|
} |
|
6262
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) |
|
6263
|
|
|
{ |
|
6264
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
6265
|
|
|
} |
|
6266
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) |
|
6267
|
|
|
{ |
|
6268
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
|
6269
|
|
|
} |
|
6270
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) |
|
6271
|
|
|
{ |
|
6272
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6273
|
|
|
} |
|
6274
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) |
|
6275
|
|
|
{ |
|
6276
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6277
|
|
|
} |
|
6278
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) |
|
6279
|
|
|
{ |
|
6280
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
|
6281
|
|
|
} |
|
6282
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) |
|
6283
|
|
|
{ |
|
6284
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6285
|
|
|
} |
|
6286
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) |
|
6287
|
|
|
{ |
|
6288
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML); |
|
6289
|
|
|
} |
|
6290
|
|
|
elseif (!$description_only) |
|
6291
|
|
|
{ |
|
6292
|
|
|
return $this->get_content(true); |
|
6293
|
|
|
} |
|
6294
|
|
|
else |
|
6295
|
|
|
{ |
|
6296
|
|
|
return null; |
|
6297
|
|
|
} |
|
6298
|
|
|
} |
|
6299
|
|
|
|
|
6300
|
|
|
public function get_content($content_only = false) |
|
6301
|
|
|
{ |
|
6302
|
|
|
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) |
|
6303
|
|
|
{ |
|
6304
|
|
|
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
6305
|
|
|
} |
|
6306
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content')) |
|
6307
|
|
|
{ |
|
6308
|
|
|
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
6309
|
|
|
} |
|
6310
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) |
|
6311
|
|
|
{ |
|
6312
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
|
6313
|
|
|
} |
|
6314
|
|
|
elseif (!$content_only) |
|
6315
|
|
|
{ |
|
6316
|
|
|
return $this->get_description(true); |
|
6317
|
|
|
} |
|
6318
|
|
|
else |
|
6319
|
|
|
{ |
|
6320
|
|
|
return null; |
|
6321
|
|
|
} |
|
6322
|
|
|
} |
|
6323
|
|
|
|
|
6324
|
|
|
public function get_category($key = 0) |
|
6325
|
|
|
{ |
|
6326
|
|
|
$categories = $this->get_categories(); |
|
6327
|
|
|
if (isset($categories[$key])) |
|
6328
|
|
|
{ |
|
6329
|
|
|
return $categories[$key]; |
|
6330
|
|
|
} |
|
6331
|
|
|
else |
|
6332
|
|
|
{ |
|
6333
|
|
|
return null; |
|
6334
|
|
|
} |
|
6335
|
|
|
} |
|
6336
|
|
|
|
|
6337
|
|
|
public function get_categories() |
|
6338
|
|
|
{ |
|
6339
|
|
|
$categories = array(); |
|
6340
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) |
|
6341
|
|
|
{ |
|
6342
|
|
|
$term = null; |
|
6343
|
|
|
$scheme = null; |
|
6344
|
|
|
$label = null; |
|
6345
|
|
|
if (isset($category['attribs']['']['term'])) |
|
6346
|
|
|
{ |
|
6347
|
|
|
$term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6348
|
|
|
} |
|
6349
|
|
|
if (isset($category['attribs']['']['scheme'])) |
|
6350
|
|
|
{ |
|
6351
|
|
|
$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6352
|
|
|
} |
|
6353
|
|
|
if (isset($category['attribs']['']['label'])) |
|
6354
|
|
|
{ |
|
6355
|
|
|
$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6356
|
|
|
} |
|
6357
|
|
|
$categories[] = $this->registry->create('Category', array($term, $scheme, $label)); |
|
6358
|
|
|
} |
|
6359
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) |
|
6360
|
|
|
{ |
|
6361
|
|
|
// This is really the label, but keep this as the term also for BC. |
|
6362
|
|
|
// Label will also work on retrieving because that falls back to term. |
|
6363
|
|
|
$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6364
|
|
|
if (isset($category['attribs']['']['domain'])) |
|
6365
|
|
|
{ |
|
6366
|
|
|
$scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6367
|
|
|
} |
|
6368
|
|
|
else |
|
6369
|
|
|
{ |
|
6370
|
|
|
$scheme = null; |
|
6371
|
|
|
} |
|
6372
|
|
|
$categories[] = $this->registry->create('Category', array($term, $scheme, null)); |
|
6373
|
|
|
} |
|
6374
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) |
|
6375
|
|
|
{ |
|
6376
|
|
|
$categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
|
6377
|
|
|
} |
|
6378
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) |
|
6379
|
|
|
{ |
|
6380
|
|
|
$categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
|
6381
|
|
|
} |
|
6382
|
|
|
if (!empty($categories)) |
|
6383
|
|
|
{ |
|
6384
|
|
|
return array_unique($categories); |
|
6385
|
|
|
} |
|
6386
|
|
|
else |
|
6387
|
|
|
{ |
|
6388
|
|
|
return null; |
|
6389
|
|
|
} |
|
6390
|
|
|
} |
|
6391
|
|
|
|
|
6392
|
|
|
public function get_author($key = 0) |
|
6393
|
|
|
{ |
|
6394
|
|
|
$authors = $this->get_authors(); |
|
6395
|
|
|
if (isset($authors[$key])) |
|
6396
|
|
|
{ |
|
6397
|
|
|
return $authors[$key]; |
|
6398
|
|
|
} |
|
6399
|
|
|
else |
|
6400
|
|
|
{ |
|
6401
|
|
|
return null; |
|
6402
|
|
|
} |
|
6403
|
|
|
} |
|
6404
|
|
|
|
|
6405
|
|
|
public function get_contributor($key = 0) |
|
6406
|
|
|
{ |
|
6407
|
|
|
$contributors = $this->get_contributors(); |
|
6408
|
|
|
if (isset($contributors[$key])) |
|
6409
|
|
|
{ |
|
6410
|
|
|
return $contributors[$key]; |
|
6411
|
|
|
} |
|
6412
|
|
|
else |
|
6413
|
|
|
{ |
|
6414
|
|
|
return null; |
|
6415
|
|
|
} |
|
6416
|
|
|
} |
|
6417
|
|
|
|
|
6418
|
|
|
public function get_contributors() |
|
6419
|
|
|
{ |
|
6420
|
|
|
$contributors = array(); |
|
6421
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) |
|
6422
|
|
|
{ |
|
6423
|
|
|
$name = null; |
|
6424
|
|
|
$uri = null; |
|
6425
|
|
|
$email = null; |
|
6426
|
|
|
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) |
|
6427
|
|
|
{ |
|
6428
|
|
|
$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6429
|
|
|
} |
|
6430
|
|
|
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) |
|
6431
|
|
|
{ |
|
6432
|
|
|
$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])); |
|
6433
|
|
|
} |
|
6434
|
|
|
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) |
|
6435
|
|
|
{ |
|
6436
|
|
|
$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6437
|
|
|
} |
|
6438
|
|
|
if ($name !== null || $email !== null || $uri !== null) |
|
6439
|
|
|
{ |
|
6440
|
|
|
$contributors[] = $this->registry->create('Author', array($name, $uri, $email)); |
|
6441
|
|
|
} |
|
6442
|
|
|
} |
|
6443
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) |
|
6444
|
|
|
{ |
|
6445
|
|
|
$name = null; |
|
6446
|
|
|
$url = null; |
|
6447
|
|
|
$email = null; |
|
6448
|
|
|
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) |
|
6449
|
|
|
{ |
|
6450
|
|
|
$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6451
|
|
|
} |
|
6452
|
|
|
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) |
|
6453
|
|
|
{ |
|
6454
|
|
|
$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])); |
|
6455
|
|
|
} |
|
6456
|
|
|
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) |
|
6457
|
|
|
{ |
|
6458
|
|
|
$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6459
|
|
|
} |
|
6460
|
|
|
if ($name !== null || $email !== null || $url !== null) |
|
6461
|
|
|
{ |
|
6462
|
|
|
$contributors[] = $this->registry->create('Author', array($name, $url, $email)); |
|
6463
|
|
|
} |
|
6464
|
|
|
} |
|
6465
|
|
|
if (!empty($contributors)) |
|
6466
|
|
|
{ |
|
6467
|
|
|
return array_unique($contributors); |
|
6468
|
|
|
} |
|
6469
|
|
|
else |
|
6470
|
|
|
{ |
|
6471
|
|
|
return null; |
|
6472
|
|
|
} |
|
6473
|
|
|
} |
|
6474
|
|
|
|
|
6475
|
|
|
public function get_authors() |
|
6476
|
|
|
{ |
|
6477
|
|
|
$authors = array(); |
|
6478
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) |
|
6479
|
|
|
{ |
|
6480
|
|
|
$name = null; |
|
6481
|
|
|
$uri = null; |
|
6482
|
|
|
$email = null; |
|
6483
|
|
|
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) |
|
6484
|
|
|
{ |
|
6485
|
|
|
$name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6486
|
|
|
} |
|
6487
|
|
|
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) |
|
6488
|
|
|
{ |
|
6489
|
|
|
$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])); |
|
6490
|
|
|
} |
|
6491
|
|
|
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) |
|
6492
|
|
|
{ |
|
6493
|
|
|
$email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6494
|
|
|
} |
|
6495
|
|
|
if ($name !== null || $email !== null || $uri !== null) |
|
6496
|
|
|
{ |
|
6497
|
|
|
$authors[] = $this->registry->create('Author', array($name, $uri, $email)); |
|
6498
|
|
|
} |
|
6499
|
|
|
} |
|
6500
|
|
|
if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) |
|
6501
|
|
|
{ |
|
6502
|
|
|
$name = null; |
|
6503
|
|
|
$url = null; |
|
6504
|
|
|
$email = null; |
|
6505
|
|
|
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) |
|
6506
|
|
|
{ |
|
6507
|
|
|
$name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6508
|
|
|
} |
|
6509
|
|
|
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) |
|
6510
|
|
|
{ |
|
6511
|
|
|
$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])); |
|
6512
|
|
|
} |
|
6513
|
|
|
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) |
|
6514
|
|
|
{ |
|
6515
|
|
|
$email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6516
|
|
|
} |
|
6517
|
|
|
if ($name !== null || $email !== null || $url !== null) |
|
6518
|
|
|
{ |
|
6519
|
|
|
$authors[] = $this->registry->create('Author', array($name, $url, $email)); |
|
6520
|
|
|
} |
|
6521
|
|
|
} |
|
6522
|
|
|
if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author')) |
|
6523
|
|
|
{ |
|
6524
|
|
|
$authors[] = $this->registry->create('Author', array(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT))); |
|
6525
|
|
|
} |
|
6526
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) |
|
6527
|
|
|
{ |
|
6528
|
|
|
$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
|
6529
|
|
|
} |
|
6530
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) |
|
6531
|
|
|
{ |
|
6532
|
|
|
$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
|
6533
|
|
|
} |
|
6534
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) |
|
6535
|
|
|
{ |
|
6536
|
|
|
$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
|
6537
|
|
|
} |
|
6538
|
|
|
if (!empty($authors)) |
|
6539
|
|
|
{ |
|
6540
|
|
|
return array_unique($authors); |
|
6541
|
|
|
} |
|
6542
|
|
|
elseif (($source = $this->get_source()) && ($authors = $source->get_authors())) |
|
6543
|
|
|
{ |
|
6544
|
|
|
return $authors; |
|
6545
|
|
|
} |
|
6546
|
|
|
elseif ($authors = $this->feed->get_authors()) |
|
6547
|
|
|
{ |
|
6548
|
|
|
return $authors; |
|
6549
|
|
|
} |
|
6550
|
|
|
else |
|
6551
|
|
|
{ |
|
6552
|
|
|
return null; |
|
6553
|
|
|
} |
|
6554
|
|
|
} |
|
6555
|
|
|
|
|
6556
|
|
|
public function get_copyright() |
|
6557
|
|
|
{ |
|
6558
|
|
|
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) |
|
6559
|
|
|
{ |
|
6560
|
|
|
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
6561
|
|
|
} |
|
6562
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) |
|
6563
|
|
|
{ |
|
6564
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6565
|
|
|
} |
|
6566
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) |
|
6567
|
|
|
{ |
|
6568
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6569
|
|
|
} |
|
6570
|
|
|
else |
|
6571
|
|
|
{ |
|
6572
|
|
|
return null; |
|
6573
|
|
|
} |
|
6574
|
|
|
} |
|
6575
|
|
|
|
|
6576
|
|
|
public function get_date($date_format = 'j F Y, g:i a') |
|
6577
|
|
|
{ |
|
6578
|
|
|
if (!isset($this->data['date'])) |
|
6579
|
|
|
{ |
|
6580
|
|
|
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published')) |
|
6581
|
|
|
{ |
|
6582
|
|
|
$this->data['date']['raw'] = $return[0]['data']; |
|
6583
|
|
|
} |
|
6584
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated')) |
|
6585
|
|
|
{ |
|
6586
|
|
|
$this->data['date']['raw'] = $return[0]['data']; |
|
6587
|
|
|
} |
|
6588
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued')) |
|
6589
|
|
|
{ |
|
6590
|
|
|
$this->data['date']['raw'] = $return[0]['data']; |
|
6591
|
|
|
} |
|
6592
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created')) |
|
6593
|
|
|
{ |
|
6594
|
|
|
$this->data['date']['raw'] = $return[0]['data']; |
|
6595
|
|
|
} |
|
6596
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified')) |
|
6597
|
|
|
{ |
|
6598
|
|
|
$this->data['date']['raw'] = $return[0]['data']; |
|
6599
|
|
|
} |
|
6600
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate')) |
|
6601
|
|
|
{ |
|
6602
|
|
|
$this->data['date']['raw'] = $return[0]['data']; |
|
6603
|
|
|
} |
|
6604
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date')) |
|
6605
|
|
|
{ |
|
6606
|
|
|
$this->data['date']['raw'] = $return[0]['data']; |
|
6607
|
|
|
} |
|
6608
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date')) |
|
6609
|
|
|
{ |
|
6610
|
|
|
$this->data['date']['raw'] = $return[0]['data']; |
|
6611
|
|
|
} |
|
6612
|
|
|
if (!empty($this->data['date']['raw'])) |
|
6613
|
|
|
{ |
|
6614
|
|
|
$parser = $this->registry->call('Parse_Date', 'get'); |
|
6615
|
|
|
$this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']); |
|
6616
|
|
|
} |
|
6617
|
|
|
else |
|
6618
|
|
|
{ |
|
6619
|
|
|
$this->data['date'] = null; |
|
6620
|
|
|
} |
|
6621
|
|
|
} |
|
6622
|
|
|
if ($this->data['date']) |
|
6623
|
|
|
{ |
|
6624
|
|
|
$date_format = (string) $date_format; |
|
6625
|
|
|
switch ($date_format) |
|
6626
|
|
|
{ |
|
6627
|
|
|
case '': |
|
6628
|
|
|
return $this->sanitize($this->data['date']['raw'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6629
|
|
|
case 'U': |
|
6630
|
|
|
return $this->data['date']['parsed']; |
|
6631
|
|
|
default: |
|
6632
|
|
|
return date($date_format, $this->data['date']['parsed']); |
|
6633
|
|
|
} |
|
6634
|
|
|
} |
|
6635
|
|
|
else |
|
6636
|
|
|
{ |
|
6637
|
|
|
return null; |
|
6638
|
|
|
} |
|
6639
|
|
|
} |
|
6640
|
|
|
|
|
6641
|
|
|
public function get_updated_date($date_format = 'j F Y, g:i a') |
|
6642
|
|
|
{ |
|
6643
|
|
|
if (!isset($this->data['updated'])) |
|
6644
|
|
|
{ |
|
6645
|
|
|
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated')) |
|
6646
|
|
|
{ |
|
6647
|
|
|
$this->data['updated']['raw'] = $return[0]['data']; |
|
6648
|
|
|
} |
|
6649
|
|
|
if (!empty($this->data['updated']['raw'])) |
|
6650
|
|
|
{ |
|
6651
|
|
|
$parser = $this->registry->call('Parse_Date', 'get'); |
|
6652
|
|
|
$this->data['updated']['parsed'] = $parser->parse($this->data['date']['raw']); |
|
6653
|
|
|
} |
|
6654
|
|
|
else |
|
6655
|
|
|
{ |
|
6656
|
|
|
$this->data['updated'] = null; |
|
6657
|
|
|
} |
|
6658
|
|
|
} |
|
6659
|
|
|
if ($this->data['updated']) |
|
6660
|
|
|
{ |
|
6661
|
|
|
$date_format = (string) $date_format; |
|
6662
|
|
|
switch ($date_format) |
|
6663
|
|
|
{ |
|
6664
|
|
|
case '': |
|
6665
|
|
|
return $this->sanitize($this->data['updated']['raw'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6666
|
|
|
case 'U': |
|
6667
|
|
|
return $this->data['updated']['parsed']; |
|
6668
|
|
|
default: |
|
6669
|
|
|
return date($date_format, $this->data['updated']['parsed']); |
|
6670
|
|
|
} |
|
6671
|
|
|
} |
|
6672
|
|
|
else |
|
6673
|
|
|
{ |
|
6674
|
|
|
return null; |
|
6675
|
|
|
} |
|
6676
|
|
|
} |
|
6677
|
|
|
|
|
6678
|
|
|
public function get_local_date($date_format = '%c') |
|
6679
|
|
|
{ |
|
6680
|
|
|
if (!$date_format) |
|
6681
|
|
|
{ |
|
6682
|
|
|
return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT); |
|
6683
|
|
|
} |
|
6684
|
|
|
elseif (($date = $this->get_date('U')) !== null && $date !== false) |
|
6685
|
|
|
{ |
|
6686
|
|
|
return strftime($date_format, $date); |
|
6687
|
|
|
} |
|
6688
|
|
|
else |
|
6689
|
|
|
{ |
|
6690
|
|
|
return null; |
|
6691
|
|
|
} |
|
6692
|
|
|
} |
|
6693
|
|
|
|
|
6694
|
|
|
public function get_gmdate($date_format = 'j F Y, g:i a') |
|
6695
|
|
|
{ |
|
6696
|
|
|
$date = $this->get_date('U'); |
|
6697
|
|
|
if ($date === null) |
|
6698
|
|
|
{ |
|
6699
|
|
|
return null; |
|
6700
|
|
|
} |
|
6701
|
|
|
return gmdate($date_format, $date); |
|
6702
|
|
|
} |
|
6703
|
|
|
|
|
6704
|
|
|
public function get_updated_gmdate($date_format = 'j F Y, g:i a') |
|
6705
|
|
|
{ |
|
6706
|
|
|
$date = $this->get_updated_date('U'); |
|
6707
|
|
|
if ($date === null) |
|
6708
|
|
|
{ |
|
6709
|
|
|
return null; |
|
6710
|
|
|
} |
|
6711
|
|
|
return gmdate($date_format, $date); |
|
6712
|
|
|
} |
|
6713
|
|
|
|
|
6714
|
|
|
public function get_permalink() |
|
6715
|
|
|
{ |
|
6716
|
|
|
$link = $this->get_link(); |
|
6717
|
|
|
$enclosure = $this->get_enclosure(0); |
|
6718
|
|
|
if ($link !== null) |
|
6719
|
|
|
{ |
|
6720
|
|
|
return $link; |
|
6721
|
|
|
} |
|
6722
|
|
|
elseif ($enclosure !== null) |
|
6723
|
|
|
{ |
|
6724
|
|
|
return $enclosure->get_link(); |
|
6725
|
|
|
} |
|
6726
|
|
|
else |
|
6727
|
|
|
{ |
|
6728
|
|
|
return null; |
|
6729
|
|
|
} |
|
6730
|
|
|
} |
|
6731
|
|
|
|
|
6732
|
|
|
public function get_link($key = 0, $rel = 'alternate') |
|
6733
|
|
|
{ |
|
6734
|
|
|
$links = $this->get_links($rel); |
|
6735
|
|
|
if ($links[$key] !== null) |
|
6736
|
|
|
{ |
|
6737
|
|
|
return $links[$key]; |
|
6738
|
|
|
} |
|
6739
|
|
|
else |
|
6740
|
|
|
{ |
|
6741
|
|
|
return null; |
|
6742
|
|
|
} |
|
6743
|
|
|
} |
|
6744
|
|
|
|
|
6745
|
|
|
public function get_links($rel = 'alternate') |
|
6746
|
|
|
{ |
|
6747
|
|
|
if (!isset($this->data['links'])) |
|
6748
|
|
|
{ |
|
6749
|
|
|
$this->data['links'] = array(); |
|
6750
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) |
|
6751
|
|
|
{ |
|
6752
|
|
|
if (isset($link['attribs']['']['href'])) |
|
6753
|
|
|
{ |
|
6754
|
|
|
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; |
|
6755
|
|
|
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); |
|
6756
|
|
|
} |
|
6757
|
|
|
} |
|
6758
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) |
|
6759
|
|
|
{ |
|
6760
|
|
|
if (isset($link['attribs']['']['href'])) |
|
6761
|
|
|
{ |
|
6762
|
|
|
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; |
|
6763
|
|
|
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); |
|
6764
|
|
|
} |
|
6765
|
|
|
} |
|
6766
|
|
|
if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) |
|
6767
|
|
|
{ |
|
6768
|
|
|
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); |
|
6769
|
|
|
} |
|
6770
|
|
|
if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) |
|
6771
|
|
|
{ |
|
6772
|
|
|
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); |
|
6773
|
|
|
} |
|
6774
|
|
|
if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) |
|
6775
|
|
|
{ |
|
6776
|
|
|
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); |
|
6777
|
|
|
} |
|
6778
|
|
|
if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) |
|
6779
|
|
|
{ |
|
6780
|
|
|
if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true') |
|
6781
|
|
|
{ |
|
6782
|
|
|
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); |
|
6783
|
|
|
} |
|
6784
|
|
|
} |
|
6785
|
|
|
$keys = array_keys($this->data['links']); |
|
6786
|
|
|
foreach ($keys as $key) |
|
6787
|
|
|
{ |
|
6788
|
|
|
if ($this->registry->call('Misc', 'is_isegment_nz_nc', array($key))) |
|
6789
|
|
|
{ |
|
6790
|
|
|
if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) |
|
6791
|
|
|
{ |
|
6792
|
|
|
$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); |
|
6793
|
|
|
$this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; |
|
6794
|
|
|
} |
|
6795
|
|
|
else |
|
6796
|
|
|
{ |
|
6797
|
|
|
$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; |
|
6798
|
|
|
} |
|
6799
|
|
|
} |
|
6800
|
|
|
elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) |
|
6801
|
|
|
{ |
|
6802
|
|
|
$this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; |
|
6803
|
|
|
} |
|
6804
|
|
|
$this->data['links'][$key] = array_unique($this->data['links'][$key]); |
|
6805
|
|
|
} |
|
6806
|
|
|
} |
|
6807
|
|
|
if (isset($this->data['links'][$rel])) |
|
6808
|
|
|
{ |
|
6809
|
|
|
return $this->data['links'][$rel]; |
|
6810
|
|
|
} |
|
6811
|
|
|
else |
|
6812
|
|
|
{ |
|
6813
|
|
|
return null; |
|
6814
|
|
|
} |
|
6815
|
|
|
} |
|
6816
|
|
|
|
|
6817
|
|
|
public function get_enclosure($key = 0, $prefer = null) |
|
6818
|
|
|
{ |
|
6819
|
|
|
$enclosures = $this->get_enclosures(); |
|
6820
|
|
|
if (isset($enclosures[$key])) |
|
6821
|
|
|
{ |
|
6822
|
|
|
return $enclosures[$key]; |
|
6823
|
|
|
} |
|
6824
|
|
|
else |
|
6825
|
|
|
{ |
|
6826
|
|
|
return null; |
|
6827
|
|
|
} |
|
6828
|
|
|
} |
|
6829
|
|
|
|
|
6830
|
|
|
public function get_enclosures() |
|
6831
|
|
|
{ |
|
6832
|
|
|
if (!isset($this->data['enclosures'])) |
|
6833
|
|
|
{ |
|
6834
|
|
|
$this->data['enclosures'] = array(); |
|
6835
|
|
|
// Elements |
|
6836
|
|
|
$captions_parent = null; |
|
6837
|
|
|
$categories_parent = null; |
|
6838
|
|
|
$copyrights_parent = null; |
|
6839
|
|
|
$credits_parent = null; |
|
6840
|
|
|
$description_parent = null; |
|
6841
|
|
|
$duration_parent = null; |
|
6842
|
|
|
$hashes_parent = null; |
|
6843
|
|
|
$keywords_parent = null; |
|
6844
|
|
|
$player_parent = null; |
|
6845
|
|
|
$ratings_parent = null; |
|
6846
|
|
|
$restrictions_parent = null; |
|
6847
|
|
|
$thumbnails_parent = null; |
|
6848
|
|
|
$title_parent = null; |
|
6849
|
|
|
// Let's do the channel and item-level ones first, and just re-use them if we need to. |
|
6850
|
|
|
$parent = $this->get_feed(); |
|
6851
|
|
|
// CAPTIONS |
|
6852
|
|
|
if ($captions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) |
|
6853
|
|
|
{ |
|
6854
|
|
|
foreach ($captions as $caption) |
|
6855
|
|
|
{ |
|
6856
|
|
|
$caption_type = null; |
|
6857
|
|
|
$caption_lang = null; |
|
6858
|
|
|
$caption_startTime = null; |
|
6859
|
|
|
$caption_endTime = null; |
|
6860
|
|
|
$caption_text = null; |
|
6861
|
|
|
if (isset($caption['attribs']['']['type'])) |
|
6862
|
|
|
{ |
|
6863
|
|
|
$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6864
|
|
|
} |
|
6865
|
|
|
if (isset($caption['attribs']['']['lang'])) |
|
6866
|
|
|
{ |
|
6867
|
|
|
$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6868
|
|
|
} |
|
6869
|
|
|
if (isset($caption['attribs']['']['start'])) |
|
6870
|
|
|
{ |
|
6871
|
|
|
$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6872
|
|
|
} |
|
6873
|
|
|
if (isset($caption['attribs']['']['end'])) |
|
6874
|
|
|
{ |
|
6875
|
|
|
$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6876
|
|
|
} |
|
6877
|
|
|
if (isset($caption['data'])) |
|
6878
|
|
|
{ |
|
6879
|
|
|
$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6880
|
|
|
} |
|
6881
|
|
|
$captions_parent[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); |
|
6882
|
|
|
} |
|
6883
|
|
|
} |
|
6884
|
|
|
elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) |
|
6885
|
|
|
{ |
|
6886
|
|
|
foreach ($captions as $caption) |
|
6887
|
|
|
{ |
|
6888
|
|
|
$caption_type = null; |
|
6889
|
|
|
$caption_lang = null; |
|
6890
|
|
|
$caption_startTime = null; |
|
6891
|
|
|
$caption_endTime = null; |
|
6892
|
|
|
$caption_text = null; |
|
6893
|
|
|
if (isset($caption['attribs']['']['type'])) |
|
6894
|
|
|
{ |
|
6895
|
|
|
$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6896
|
|
|
} |
|
6897
|
|
|
if (isset($caption['attribs']['']['lang'])) |
|
6898
|
|
|
{ |
|
6899
|
|
|
$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6900
|
|
|
} |
|
6901
|
|
|
if (isset($caption['attribs']['']['start'])) |
|
6902
|
|
|
{ |
|
6903
|
|
|
$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6904
|
|
|
} |
|
6905
|
|
|
if (isset($caption['attribs']['']['end'])) |
|
6906
|
|
|
{ |
|
6907
|
|
|
$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6908
|
|
|
} |
|
6909
|
|
|
if (isset($caption['data'])) |
|
6910
|
|
|
{ |
|
6911
|
|
|
$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6912
|
|
|
} |
|
6913
|
|
|
$captions_parent[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); |
|
6914
|
|
|
} |
|
6915
|
|
|
} |
|
6916
|
|
|
if (is_array($captions_parent)) |
|
6917
|
|
|
{ |
|
6918
|
|
|
$captions_parent = array_values(array_unique($captions_parent)); |
|
6919
|
|
|
} |
|
6920
|
|
|
// CATEGORIES |
|
6921
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category) |
|
6922
|
|
|
{ |
|
6923
|
|
|
$term = null; |
|
6924
|
|
|
$scheme = null; |
|
6925
|
|
|
$label = null; |
|
6926
|
|
|
if (isset($category['data'])) |
|
6927
|
|
|
{ |
|
6928
|
|
|
$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6929
|
|
|
} |
|
6930
|
|
|
if (isset($category['attribs']['']['scheme'])) |
|
6931
|
|
|
{ |
|
6932
|
|
|
$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6933
|
|
|
} |
|
6934
|
|
|
else |
|
6935
|
|
|
{ |
|
6936
|
|
|
$scheme = 'http://search.yahoo.com/mrss/category_schema'; |
|
6937
|
|
|
} |
|
6938
|
|
|
if (isset($category['attribs']['']['label'])) |
|
6939
|
|
|
{ |
|
6940
|
|
|
$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6941
|
|
|
} |
|
6942
|
|
|
$categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label)); |
|
6943
|
|
|
} |
|
6944
|
|
|
foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category) |
|
6945
|
|
|
{ |
|
6946
|
|
|
$term = null; |
|
6947
|
|
|
$scheme = null; |
|
6948
|
|
|
$label = null; |
|
6949
|
|
|
if (isset($category['data'])) |
|
6950
|
|
|
{ |
|
6951
|
|
|
$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6952
|
|
|
} |
|
6953
|
|
|
if (isset($category['attribs']['']['scheme'])) |
|
6954
|
|
|
{ |
|
6955
|
|
|
$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6956
|
|
|
} |
|
6957
|
|
|
else |
|
6958
|
|
|
{ |
|
6959
|
|
|
$scheme = 'http://search.yahoo.com/mrss/category_schema'; |
|
6960
|
|
|
} |
|
6961
|
|
|
if (isset($category['attribs']['']['label'])) |
|
6962
|
|
|
{ |
|
6963
|
|
|
$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6964
|
|
|
} |
|
6965
|
|
|
$categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label)); |
|
6966
|
|
|
} |
|
6967
|
|
|
foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'category') as $category) |
|
6968
|
|
|
{ |
|
6969
|
|
|
$term = null; |
|
6970
|
|
|
$scheme = 'http://www.itunes.com/dtds/podcast-1.0.dtd'; |
|
6971
|
|
|
$label = null; |
|
6972
|
|
|
if (isset($category['attribs']['']['text'])) |
|
6973
|
|
|
{ |
|
6974
|
|
|
$label = $this->sanitize($category['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6975
|
|
|
} |
|
6976
|
|
|
$categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label)); |
|
6977
|
|
|
if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'])) |
|
6978
|
|
|
{ |
|
6979
|
|
|
foreach ((array) $category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'] as $subcategory) |
|
6980
|
|
|
{ |
|
6981
|
|
|
if (isset($subcategory['attribs']['']['text'])) |
|
6982
|
|
|
{ |
|
6983
|
|
|
$label = $this->sanitize($subcategory['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
6984
|
|
|
} |
|
6985
|
|
|
$categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label)); |
|
6986
|
|
|
} |
|
6987
|
|
|
} |
|
6988
|
|
|
} |
|
6989
|
|
|
if (is_array($categories_parent)) |
|
6990
|
|
|
{ |
|
6991
|
|
|
$categories_parent = array_values(array_unique($categories_parent)); |
|
6992
|
|
|
} |
|
6993
|
|
|
// COPYRIGHT |
|
6994
|
|
|
if ($copyright = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) |
|
6995
|
|
|
{ |
|
6996
|
|
|
$copyright_url = null; |
|
6997
|
|
|
$copyright_label = null; |
|
6998
|
|
|
if (isset($copyright[0]['attribs']['']['url'])) |
|
6999
|
|
|
{ |
|
7000
|
|
|
$copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7001
|
|
|
} |
|
7002
|
|
|
if (isset($copyright[0]['data'])) |
|
7003
|
|
|
{ |
|
7004
|
|
|
$copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7005
|
|
|
} |
|
7006
|
|
|
$copyrights_parent = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); |
|
7007
|
|
|
} |
|
7008
|
|
|
elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) |
|
7009
|
|
|
{ |
|
7010
|
|
|
$copyright_url = null; |
|
7011
|
|
|
$copyright_label = null; |
|
7012
|
|
|
if (isset($copyright[0]['attribs']['']['url'])) |
|
7013
|
|
|
{ |
|
7014
|
|
|
$copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7015
|
|
|
} |
|
7016
|
|
|
if (isset($copyright[0]['data'])) |
|
7017
|
|
|
{ |
|
7018
|
|
|
$copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7019
|
|
|
} |
|
7020
|
|
|
$copyrights_parent = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); |
|
7021
|
|
|
} |
|
7022
|
|
|
// CREDITS |
|
7023
|
|
|
if ($credits = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) |
|
7024
|
|
|
{ |
|
7025
|
|
|
foreach ($credits as $credit) |
|
7026
|
|
|
{ |
|
7027
|
|
|
$credit_role = null; |
|
7028
|
|
|
$credit_scheme = null; |
|
7029
|
|
|
$credit_name = null; |
|
7030
|
|
|
if (isset($credit['attribs']['']['role'])) |
|
7031
|
|
|
{ |
|
7032
|
|
|
$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7033
|
|
|
} |
|
7034
|
|
|
if (isset($credit['attribs']['']['scheme'])) |
|
7035
|
|
|
{ |
|
7036
|
|
|
$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7037
|
|
|
} |
|
7038
|
|
|
else |
|
7039
|
|
|
{ |
|
7040
|
|
|
$credit_scheme = 'urn:ebu'; |
|
7041
|
|
|
} |
|
7042
|
|
|
if (isset($credit['data'])) |
|
7043
|
|
|
{ |
|
7044
|
|
|
$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7045
|
|
|
} |
|
7046
|
|
|
$credits_parent[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); |
|
7047
|
|
|
} |
|
7048
|
|
|
} |
|
7049
|
|
|
elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) |
|
7050
|
|
|
{ |
|
7051
|
|
|
foreach ($credits as $credit) |
|
7052
|
|
|
{ |
|
7053
|
|
|
$credit_role = null; |
|
7054
|
|
|
$credit_scheme = null; |
|
7055
|
|
|
$credit_name = null; |
|
7056
|
|
|
if (isset($credit['attribs']['']['role'])) |
|
7057
|
|
|
{ |
|
7058
|
|
|
$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7059
|
|
|
} |
|
7060
|
|
|
if (isset($credit['attribs']['']['scheme'])) |
|
7061
|
|
|
{ |
|
7062
|
|
|
$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7063
|
|
|
} |
|
7064
|
|
|
else |
|
7065
|
|
|
{ |
|
7066
|
|
|
$credit_scheme = 'urn:ebu'; |
|
7067
|
|
|
} |
|
7068
|
|
|
if (isset($credit['data'])) |
|
7069
|
|
|
{ |
|
7070
|
|
|
$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7071
|
|
|
} |
|
7072
|
|
|
$credits_parent[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); |
|
7073
|
|
|
} |
|
7074
|
|
|
} |
|
7075
|
|
|
if (is_array($credits_parent)) |
|
7076
|
|
|
{ |
|
7077
|
|
|
$credits_parent = array_values(array_unique($credits_parent)); |
|
7078
|
|
|
} |
|
7079
|
|
|
// DESCRIPTION |
|
7080
|
|
|
if ($description_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) |
|
7081
|
|
|
{ |
|
7082
|
|
|
if (isset($description_parent[0]['data'])) |
|
7083
|
|
|
{ |
|
7084
|
|
|
$description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7085
|
|
|
} |
|
7086
|
|
|
} |
|
7087
|
|
|
elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) |
|
7088
|
|
|
{ |
|
7089
|
|
|
if (isset($description_parent[0]['data'])) |
|
7090
|
|
|
{ |
|
7091
|
|
|
$description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7092
|
|
|
} |
|
7093
|
|
|
} |
|
7094
|
|
|
// DURATION |
|
7095
|
|
|
if ($duration_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'duration')) |
|
7096
|
|
|
{ |
|
7097
|
|
|
$seconds = null; |
|
7098
|
|
|
$minutes = null; |
|
7099
|
|
|
$hours = null; |
|
7100
|
|
|
if (isset($duration_parent[0]['data'])) |
|
7101
|
|
|
{ |
|
7102
|
|
|
$temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); |
|
7103
|
|
|
if (sizeof($temp) > 0) |
|
7104
|
|
|
{ |
|
7105
|
|
|
$seconds = (int) array_pop($temp); |
|
7106
|
|
|
} |
|
7107
|
|
|
if (sizeof($temp) > 0) |
|
7108
|
|
|
{ |
|
7109
|
|
|
$minutes = (int) array_pop($temp); |
|
7110
|
|
|
$seconds += $minutes * 60; |
|
7111
|
|
|
} |
|
7112
|
|
|
if (sizeof($temp) > 0) |
|
7113
|
|
|
{ |
|
7114
|
|
|
$hours = (int) array_pop($temp); |
|
7115
|
|
|
$seconds += $hours * 3600; |
|
7116
|
|
|
} |
|
7117
|
|
|
unset($temp); |
|
7118
|
|
|
$duration_parent = $seconds; |
|
7119
|
|
|
} |
|
7120
|
|
|
} |
|
7121
|
|
|
// HASHES |
|
7122
|
|
|
if ($hashes_iterator = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) |
|
7123
|
|
|
{ |
|
7124
|
|
|
foreach ($hashes_iterator as $hash) |
|
7125
|
|
|
{ |
|
7126
|
|
|
$value = null; |
|
7127
|
|
|
$algo = null; |
|
7128
|
|
|
if (isset($hash['data'])) |
|
7129
|
|
|
{ |
|
7130
|
|
|
$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7131
|
|
|
} |
|
7132
|
|
|
if (isset($hash['attribs']['']['algo'])) |
|
7133
|
|
|
{ |
|
7134
|
|
|
$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7135
|
|
|
} |
|
7136
|
|
|
else |
|
7137
|
|
|
{ |
|
7138
|
|
|
$algo = 'md5'; |
|
7139
|
|
|
} |
|
7140
|
|
|
$hashes_parent[] = $algo.':'.$value; |
|
7141
|
|
|
} |
|
7142
|
|
|
} |
|
7143
|
|
|
elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) |
|
7144
|
|
|
{ |
|
7145
|
|
|
foreach ($hashes_iterator as $hash) |
|
7146
|
|
|
{ |
|
7147
|
|
|
$value = null; |
|
7148
|
|
|
$algo = null; |
|
7149
|
|
|
if (isset($hash['data'])) |
|
7150
|
|
|
{ |
|
7151
|
|
|
$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7152
|
|
|
} |
|
7153
|
|
|
if (isset($hash['attribs']['']['algo'])) |
|
7154
|
|
|
{ |
|
7155
|
|
|
$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7156
|
|
|
} |
|
7157
|
|
|
else |
|
7158
|
|
|
{ |
|
7159
|
|
|
$algo = 'md5'; |
|
7160
|
|
|
} |
|
7161
|
|
|
$hashes_parent[] = $algo.':'.$value; |
|
7162
|
|
|
} |
|
7163
|
|
|
} |
|
7164
|
|
|
if (is_array($hashes_parent)) |
|
7165
|
|
|
{ |
|
7166
|
|
|
$hashes_parent = array_values(array_unique($hashes_parent)); |
|
7167
|
|
|
} |
|
7168
|
|
|
// KEYWORDS |
|
7169
|
|
|
if ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) |
|
7170
|
|
|
{ |
|
7171
|
|
|
if (isset($keywords[0]['data'])) |
|
7172
|
|
|
{ |
|
7173
|
|
|
$temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); |
|
7174
|
|
|
foreach ($temp as $word) |
|
7175
|
|
|
{ |
|
7176
|
|
|
$keywords_parent[] = trim($word); |
|
7177
|
|
|
} |
|
7178
|
|
|
} |
|
7179
|
|
|
unset($temp); |
|
7180
|
|
|
} |
|
7181
|
|
|
elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) |
|
7182
|
|
|
{ |
|
7183
|
|
|
if (isset($keywords[0]['data'])) |
|
7184
|
|
|
{ |
|
7185
|
|
|
$temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); |
|
7186
|
|
|
foreach ($temp as $word) |
|
7187
|
|
|
{ |
|
7188
|
|
|
$keywords_parent[] = trim($word); |
|
7189
|
|
|
} |
|
7190
|
|
|
} |
|
7191
|
|
|
unset($temp); |
|
7192
|
|
|
} |
|
7193
|
|
|
elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) |
|
7194
|
|
|
{ |
|
7195
|
|
|
if (isset($keywords[0]['data'])) |
|
7196
|
|
|
{ |
|
7197
|
|
|
$temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); |
|
7198
|
|
|
foreach ($temp as $word) |
|
7199
|
|
|
{ |
|
7200
|
|
|
$keywords_parent[] = trim($word); |
|
7201
|
|
|
} |
|
7202
|
|
|
} |
|
7203
|
|
|
unset($temp); |
|
7204
|
|
|
} |
|
7205
|
|
|
elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) |
|
7206
|
|
|
{ |
|
7207
|
|
|
if (isset($keywords[0]['data'])) |
|
7208
|
|
|
{ |
|
7209
|
|
|
$temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); |
|
7210
|
|
|
foreach ($temp as $word) |
|
7211
|
|
|
{ |
|
7212
|
|
|
$keywords_parent[] = trim($word); |
|
7213
|
|
|
} |
|
7214
|
|
|
} |
|
7215
|
|
|
unset($temp); |
|
7216
|
|
|
} |
|
7217
|
|
|
if (is_array($keywords_parent)) |
|
7218
|
|
|
{ |
|
7219
|
|
|
$keywords_parent = array_values(array_unique($keywords_parent)); |
|
7220
|
|
|
} |
|
7221
|
|
|
// PLAYER |
|
7222
|
|
|
if ($player_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) |
|
7223
|
|
|
{ |
|
7224
|
|
|
if (isset($player_parent[0]['attribs']['']['url'])) |
|
7225
|
|
|
{ |
|
7226
|
|
|
$player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
|
7227
|
|
|
} |
|
7228
|
|
|
} |
|
7229
|
|
|
elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) |
|
7230
|
|
|
{ |
|
7231
|
|
|
if (isset($player_parent[0]['attribs']['']['url'])) |
|
7232
|
|
|
{ |
|
7233
|
|
|
$player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
|
7234
|
|
|
} |
|
7235
|
|
|
} |
|
7236
|
|
|
// RATINGS |
|
7237
|
|
|
if ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) |
|
7238
|
|
|
{ |
|
7239
|
|
|
foreach ($ratings as $rating) |
|
7240
|
|
|
{ |
|
7241
|
|
|
$rating_scheme = null; |
|
7242
|
|
|
$rating_value = null; |
|
7243
|
|
|
if (isset($rating['attribs']['']['scheme'])) |
|
7244
|
|
|
{ |
|
7245
|
|
|
$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7246
|
|
|
} |
|
7247
|
|
|
else |
|
7248
|
|
|
{ |
|
7249
|
|
|
$rating_scheme = 'urn:simple'; |
|
7250
|
|
|
} |
|
7251
|
|
|
if (isset($rating['data'])) |
|
7252
|
|
|
{ |
|
7253
|
|
|
$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7254
|
|
|
} |
|
7255
|
|
|
$ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); |
|
7256
|
|
|
} |
|
7257
|
|
|
} |
|
7258
|
|
|
elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) |
|
7259
|
|
|
{ |
|
7260
|
|
|
foreach ($ratings as $rating) |
|
7261
|
|
|
{ |
|
7262
|
|
|
$rating_scheme = 'urn:itunes'; |
|
7263
|
|
|
$rating_value = null; |
|
7264
|
|
|
if (isset($rating['data'])) |
|
7265
|
|
|
{ |
|
7266
|
|
|
$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7267
|
|
|
} |
|
7268
|
|
|
$ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); |
|
7269
|
|
|
} |
|
7270
|
|
|
} |
|
7271
|
|
|
elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) |
|
7272
|
|
|
{ |
|
7273
|
|
|
foreach ($ratings as $rating) |
|
7274
|
|
|
{ |
|
7275
|
|
|
$rating_scheme = null; |
|
7276
|
|
|
$rating_value = null; |
|
7277
|
|
|
if (isset($rating['attribs']['']['scheme'])) |
|
7278
|
|
|
{ |
|
7279
|
|
|
$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7280
|
|
|
} |
|
7281
|
|
|
else |
|
7282
|
|
|
{ |
|
7283
|
|
|
$rating_scheme = 'urn:simple'; |
|
7284
|
|
|
} |
|
7285
|
|
|
if (isset($rating['data'])) |
|
7286
|
|
|
{ |
|
7287
|
|
|
$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7288
|
|
|
} |
|
7289
|
|
|
$ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); |
|
7290
|
|
|
} |
|
7291
|
|
|
} |
|
7292
|
|
|
elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) |
|
7293
|
|
|
{ |
|
7294
|
|
|
foreach ($ratings as $rating) |
|
7295
|
|
|
{ |
|
7296
|
|
|
$rating_scheme = 'urn:itunes'; |
|
7297
|
|
|
$rating_value = null; |
|
7298
|
|
|
if (isset($rating['data'])) |
|
7299
|
|
|
{ |
|
7300
|
|
|
$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7301
|
|
|
} |
|
7302
|
|
|
$ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); |
|
7303
|
|
|
} |
|
7304
|
|
|
} |
|
7305
|
|
|
if (is_array($ratings_parent)) |
|
7306
|
|
|
{ |
|
7307
|
|
|
$ratings_parent = array_values(array_unique($ratings_parent)); |
|
7308
|
|
|
} |
|
7309
|
|
|
// RESTRICTIONS |
|
7310
|
|
|
if ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) |
|
7311
|
|
|
{ |
|
7312
|
|
|
foreach ($restrictions as $restriction) |
|
7313
|
|
|
{ |
|
7314
|
|
|
$restriction_relationship = null; |
|
7315
|
|
|
$restriction_type = null; |
|
7316
|
|
|
$restriction_value = null; |
|
7317
|
|
|
if (isset($restriction['attribs']['']['relationship'])) |
|
7318
|
|
|
{ |
|
7319
|
|
|
$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7320
|
|
|
} |
|
7321
|
|
|
if (isset($restriction['attribs']['']['type'])) |
|
7322
|
|
|
{ |
|
7323
|
|
|
$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7324
|
|
|
} |
|
7325
|
|
|
if (isset($restriction['data'])) |
|
7326
|
|
|
{ |
|
7327
|
|
|
$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7328
|
|
|
} |
|
7329
|
|
|
$restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); |
|
7330
|
|
|
} |
|
7331
|
|
|
} |
|
7332
|
|
|
elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) |
|
7333
|
|
|
{ |
|
7334
|
|
|
foreach ($restrictions as $restriction) |
|
7335
|
|
|
{ |
|
7336
|
|
|
$restriction_relationship = 'allow'; |
|
7337
|
|
|
$restriction_type = null; |
|
7338
|
|
|
$restriction_value = 'itunes'; |
|
7339
|
|
|
if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') |
|
7340
|
|
|
{ |
|
7341
|
|
|
$restriction_relationship = 'deny'; |
|
7342
|
|
|
} |
|
7343
|
|
|
$restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); |
|
7344
|
|
|
} |
|
7345
|
|
|
} |
|
7346
|
|
|
elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) |
|
7347
|
|
|
{ |
|
7348
|
|
|
foreach ($restrictions as $restriction) |
|
7349
|
|
|
{ |
|
7350
|
|
|
$restriction_relationship = null; |
|
7351
|
|
|
$restriction_type = null; |
|
7352
|
|
|
$restriction_value = null; |
|
7353
|
|
|
if (isset($restriction['attribs']['']['relationship'])) |
|
7354
|
|
|
{ |
|
7355
|
|
|
$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7356
|
|
|
} |
|
7357
|
|
|
if (isset($restriction['attribs']['']['type'])) |
|
7358
|
|
|
{ |
|
7359
|
|
|
$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7360
|
|
|
} |
|
7361
|
|
|
if (isset($restriction['data'])) |
|
7362
|
|
|
{ |
|
7363
|
|
|
$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7364
|
|
|
} |
|
7365
|
|
|
$restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); |
|
7366
|
|
|
} |
|
7367
|
|
|
} |
|
7368
|
|
|
elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) |
|
7369
|
|
|
{ |
|
7370
|
|
|
foreach ($restrictions as $restriction) |
|
7371
|
|
|
{ |
|
7372
|
|
|
$restriction_relationship = 'allow'; |
|
7373
|
|
|
$restriction_type = null; |
|
7374
|
|
|
$restriction_value = 'itunes'; |
|
7375
|
|
|
if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') |
|
7376
|
|
|
{ |
|
7377
|
|
|
$restriction_relationship = 'deny'; |
|
7378
|
|
|
} |
|
7379
|
|
|
$restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); |
|
7380
|
|
|
} |
|
7381
|
|
|
} |
|
7382
|
|
|
if (is_array($restrictions_parent)) |
|
7383
|
|
|
{ |
|
7384
|
|
|
$restrictions_parent = array_values(array_unique($restrictions_parent)); |
|
7385
|
|
|
} |
|
7386
|
|
|
else |
|
7387
|
|
|
{ |
|
7388
|
|
|
$restrictions_parent = array(new SimplePie_Restriction('allow', null, 'default')); |
|
7389
|
|
|
} |
|
7390
|
|
|
// THUMBNAILS |
|
7391
|
|
|
if ($thumbnails = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) |
|
7392
|
|
|
{ |
|
7393
|
|
|
foreach ($thumbnails as $thumbnail) |
|
7394
|
|
|
{ |
|
7395
|
|
|
if (isset($thumbnail['attribs']['']['url'])) |
|
7396
|
|
|
{ |
|
7397
|
|
|
$thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
|
7398
|
|
|
} |
|
7399
|
|
|
} |
|
7400
|
|
|
} |
|
7401
|
|
|
elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) |
|
7402
|
|
|
{ |
|
7403
|
|
|
foreach ($thumbnails as $thumbnail) |
|
7404
|
|
|
{ |
|
7405
|
|
|
if (isset($thumbnail['attribs']['']['url'])) |
|
7406
|
|
|
{ |
|
7407
|
|
|
$thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
|
7408
|
|
|
} |
|
7409
|
|
|
} |
|
7410
|
|
|
} |
|
7411
|
|
|
// TITLES |
|
7412
|
|
|
if ($title_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) |
|
7413
|
|
|
{ |
|
7414
|
|
|
if (isset($title_parent[0]['data'])) |
|
7415
|
|
|
{ |
|
7416
|
|
|
$title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7417
|
|
|
} |
|
7418
|
|
|
} |
|
7419
|
|
|
elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) |
|
7420
|
|
|
{ |
|
7421
|
|
|
if (isset($title_parent[0]['data'])) |
|
7422
|
|
|
{ |
|
7423
|
|
|
$title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7424
|
|
|
} |
|
7425
|
|
|
} |
|
7426
|
|
|
// Clear the memory |
|
7427
|
|
|
unset($parent); |
|
7428
|
|
|
// Attributes |
|
7429
|
|
|
$bitrate = null; |
|
7430
|
|
|
$channels = null; |
|
7431
|
|
|
$duration = null; |
|
7432
|
|
|
$expression = null; |
|
7433
|
|
|
$framerate = null; |
|
7434
|
|
|
$height = null; |
|
7435
|
|
|
$javascript = null; |
|
7436
|
|
|
$lang = null; |
|
7437
|
|
|
$length = null; |
|
7438
|
|
|
$medium = null; |
|
7439
|
|
|
$samplingrate = null; |
|
7440
|
|
|
$type = null; |
|
7441
|
|
|
$url = null; |
|
7442
|
|
|
$width = null; |
|
7443
|
|
|
// Elements |
|
7444
|
|
|
$captions = null; |
|
7445
|
|
|
$categories = null; |
|
7446
|
|
|
$copyrights = null; |
|
7447
|
|
|
$credits = null; |
|
7448
|
|
|
$description = null; |
|
7449
|
|
|
$hashes = null; |
|
7450
|
|
|
$keywords = null; |
|
7451
|
|
|
$player = null; |
|
7452
|
|
|
$ratings = null; |
|
7453
|
|
|
$restrictions = null; |
|
7454
|
|
|
$thumbnails = null; |
|
7455
|
|
|
$title = null; |
|
7456
|
|
|
// If we have media:group tags, loop through them. |
|
7457
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group) |
|
7458
|
|
|
{ |
|
7459
|
|
|
if(isset($group['child']) && isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'])) |
|
7460
|
|
|
{ |
|
7461
|
|
|
// If we have media:content tags, loop through them. |
|
7462
|
|
|
foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) |
|
7463
|
|
|
{ |
|
7464
|
|
|
if (isset($content['attribs']['']['url'])) |
|
7465
|
|
|
{ |
|
7466
|
|
|
// Attributes |
|
7467
|
|
|
$bitrate = null; |
|
7468
|
|
|
$channels = null; |
|
7469
|
|
|
$duration = null; |
|
7470
|
|
|
$expression = null; |
|
7471
|
|
|
$framerate = null; |
|
7472
|
|
|
$height = null; |
|
7473
|
|
|
$javascript = null; |
|
7474
|
|
|
$lang = null; |
|
7475
|
|
|
$length = null; |
|
7476
|
|
|
$medium = null; |
|
7477
|
|
|
$samplingrate = null; |
|
7478
|
|
|
$type = null; |
|
7479
|
|
|
$url = null; |
|
7480
|
|
|
$width = null; |
|
7481
|
|
|
// Elements |
|
7482
|
|
|
$captions = null; |
|
7483
|
|
|
$categories = null; |
|
7484
|
|
|
$copyrights = null; |
|
7485
|
|
|
$credits = null; |
|
7486
|
|
|
$description = null; |
|
7487
|
|
|
$hashes = null; |
|
7488
|
|
|
$keywords = null; |
|
7489
|
|
|
$player = null; |
|
7490
|
|
|
$ratings = null; |
|
7491
|
|
|
$restrictions = null; |
|
7492
|
|
|
$thumbnails = null; |
|
7493
|
|
|
$title = null; |
|
7494
|
|
|
// Start checking the attributes of media:content |
|
7495
|
|
|
if (isset($content['attribs']['']['bitrate'])) |
|
7496
|
|
|
{ |
|
7497
|
|
|
$bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7498
|
|
|
} |
|
7499
|
|
|
if (isset($content['attribs']['']['channels'])) |
|
7500
|
|
|
{ |
|
7501
|
|
|
$channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7502
|
|
|
} |
|
7503
|
|
|
if (isset($content['attribs']['']['duration'])) |
|
7504
|
|
|
{ |
|
7505
|
|
|
$duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7506
|
|
|
} |
|
7507
|
|
|
else |
|
7508
|
|
|
{ |
|
7509
|
|
|
$duration = $duration_parent; |
|
7510
|
|
|
} |
|
7511
|
|
|
if (isset($content['attribs']['']['expression'])) |
|
7512
|
|
|
{ |
|
7513
|
|
|
$expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7514
|
|
|
} |
|
7515
|
|
|
if (isset($content['attribs']['']['framerate'])) |
|
7516
|
|
|
{ |
|
7517
|
|
|
$framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7518
|
|
|
} |
|
7519
|
|
|
if (isset($content['attribs']['']['height'])) |
|
7520
|
|
|
{ |
|
7521
|
|
|
$height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7522
|
|
|
} |
|
7523
|
|
|
if (isset($content['attribs']['']['lang'])) |
|
7524
|
|
|
{ |
|
7525
|
|
|
$lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7526
|
|
|
} |
|
7527
|
|
|
if (isset($content['attribs']['']['fileSize'])) |
|
7528
|
|
|
{ |
|
7529
|
|
|
$length = ceil($content['attribs']['']['fileSize']); |
|
7530
|
|
|
} |
|
7531
|
|
|
if (isset($content['attribs']['']['medium'])) |
|
7532
|
|
|
{ |
|
7533
|
|
|
$medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7534
|
|
|
} |
|
7535
|
|
|
if (isset($content['attribs']['']['samplingrate'])) |
|
7536
|
|
|
{ |
|
7537
|
|
|
$samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7538
|
|
|
} |
|
7539
|
|
|
if (isset($content['attribs']['']['type'])) |
|
7540
|
|
|
{ |
|
7541
|
|
|
$type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7542
|
|
|
} |
|
7543
|
|
|
if (isset($content['attribs']['']['width'])) |
|
7544
|
|
|
{ |
|
7545
|
|
|
$width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7546
|
|
|
} |
|
7547
|
|
|
$url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
|
7548
|
|
|
// Checking the other optional media: elements. Priority: media:content, media:group, item, channel |
|
7549
|
|
|
// CAPTIONS |
|
7550
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) |
|
7551
|
|
|
{ |
|
7552
|
|
|
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) |
|
7553
|
|
|
{ |
|
7554
|
|
|
$caption_type = null; |
|
7555
|
|
|
$caption_lang = null; |
|
7556
|
|
|
$caption_startTime = null; |
|
7557
|
|
|
$caption_endTime = null; |
|
7558
|
|
|
$caption_text = null; |
|
7559
|
|
|
if (isset($caption['attribs']['']['type'])) |
|
7560
|
|
|
{ |
|
7561
|
|
|
$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7562
|
|
|
} |
|
7563
|
|
|
if (isset($caption['attribs']['']['lang'])) |
|
7564
|
|
|
{ |
|
7565
|
|
|
$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7566
|
|
|
} |
|
7567
|
|
|
if (isset($caption['attribs']['']['start'])) |
|
7568
|
|
|
{ |
|
7569
|
|
|
$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7570
|
|
|
} |
|
7571
|
|
|
if (isset($caption['attribs']['']['end'])) |
|
7572
|
|
|
{ |
|
7573
|
|
|
$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7574
|
|
|
} |
|
7575
|
|
|
if (isset($caption['data'])) |
|
7576
|
|
|
{ |
|
7577
|
|
|
$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7578
|
|
|
} |
|
7579
|
|
|
$captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); |
|
7580
|
|
|
} |
|
7581
|
|
|
if (is_array($captions)) |
|
7582
|
|
|
{ |
|
7583
|
|
|
$captions = array_values(array_unique($captions)); |
|
7584
|
|
|
} |
|
7585
|
|
|
} |
|
7586
|
|
|
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) |
|
7587
|
|
|
{ |
|
7588
|
|
|
foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) |
|
7589
|
|
|
{ |
|
7590
|
|
|
$caption_type = null; |
|
7591
|
|
|
$caption_lang = null; |
|
7592
|
|
|
$caption_startTime = null; |
|
7593
|
|
|
$caption_endTime = null; |
|
7594
|
|
|
$caption_text = null; |
|
7595
|
|
|
if (isset($caption['attribs']['']['type'])) |
|
7596
|
|
|
{ |
|
7597
|
|
|
$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7598
|
|
|
} |
|
7599
|
|
|
if (isset($caption['attribs']['']['lang'])) |
|
7600
|
|
|
{ |
|
7601
|
|
|
$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7602
|
|
|
} |
|
7603
|
|
|
if (isset($caption['attribs']['']['start'])) |
|
7604
|
|
|
{ |
|
7605
|
|
|
$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7606
|
|
|
} |
|
7607
|
|
|
if (isset($caption['attribs']['']['end'])) |
|
7608
|
|
|
{ |
|
7609
|
|
|
$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7610
|
|
|
} |
|
7611
|
|
|
if (isset($caption['data'])) |
|
7612
|
|
|
{ |
|
7613
|
|
|
$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7614
|
|
|
} |
|
7615
|
|
|
$captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); |
|
7616
|
|
|
} |
|
7617
|
|
|
if (is_array($captions)) |
|
7618
|
|
|
{ |
|
7619
|
|
|
$captions = array_values(array_unique($captions)); |
|
7620
|
|
|
} |
|
7621
|
|
|
} |
|
7622
|
|
|
else |
|
7623
|
|
|
{ |
|
7624
|
|
|
$captions = $captions_parent; |
|
7625
|
|
|
} |
|
7626
|
|
|
// CATEGORIES |
|
7627
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) |
|
7628
|
|
|
{ |
|
7629
|
|
|
foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) |
|
7630
|
|
|
{ |
|
7631
|
|
|
$term = null; |
|
7632
|
|
|
$scheme = null; |
|
7633
|
|
|
$label = null; |
|
7634
|
|
|
if (isset($category['data'])) |
|
7635
|
|
|
{ |
|
7636
|
|
|
$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7637
|
|
|
} |
|
7638
|
|
|
if (isset($category['attribs']['']['scheme'])) |
|
7639
|
|
|
{ |
|
7640
|
|
|
$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7641
|
|
|
} |
|
7642
|
|
|
else |
|
7643
|
|
|
{ |
|
7644
|
|
|
$scheme = 'http://search.yahoo.com/mrss/category_schema'; |
|
7645
|
|
|
} |
|
7646
|
|
|
if (isset($category['attribs']['']['label'])) |
|
7647
|
|
|
{ |
|
7648
|
|
|
$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7649
|
|
|
} |
|
7650
|
|
|
$categories[] = $this->registry->create('Category', array($term, $scheme, $label)); |
|
7651
|
|
|
} |
|
7652
|
|
|
} |
|
7653
|
|
|
if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) |
|
7654
|
|
|
{ |
|
7655
|
|
|
foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) |
|
7656
|
|
|
{ |
|
7657
|
|
|
$term = null; |
|
7658
|
|
|
$scheme = null; |
|
7659
|
|
|
$label = null; |
|
7660
|
|
|
if (isset($category['data'])) |
|
7661
|
|
|
{ |
|
7662
|
|
|
$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7663
|
|
|
} |
|
7664
|
|
|
if (isset($category['attribs']['']['scheme'])) |
|
7665
|
|
|
{ |
|
7666
|
|
|
$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7667
|
|
|
} |
|
7668
|
|
|
else |
|
7669
|
|
|
{ |
|
7670
|
|
|
$scheme = 'http://search.yahoo.com/mrss/category_schema'; |
|
7671
|
|
|
} |
|
7672
|
|
|
if (isset($category['attribs']['']['label'])) |
|
7673
|
|
|
{ |
|
7674
|
|
|
$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7675
|
|
|
} |
|
7676
|
|
|
$categories[] = $this->registry->create('Category', array($term, $scheme, $label)); |
|
7677
|
|
|
} |
|
7678
|
|
|
} |
|
7679
|
|
|
if (is_array($categories) && is_array($categories_parent)) |
|
7680
|
|
|
{ |
|
7681
|
|
|
$categories = array_values(array_unique(array_merge($categories, $categories_parent))); |
|
7682
|
|
|
} |
|
7683
|
|
|
elseif (is_array($categories)) |
|
7684
|
|
|
{ |
|
7685
|
|
|
$categories = array_values(array_unique($categories)); |
|
7686
|
|
|
} |
|
7687
|
|
|
elseif (is_array($categories_parent)) |
|
7688
|
|
|
{ |
|
7689
|
|
|
$categories = array_values(array_unique($categories_parent)); |
|
7690
|
|
|
} |
|
7691
|
|
|
// COPYRIGHTS |
|
7692
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) |
|
7693
|
|
|
{ |
|
7694
|
|
|
$copyright_url = null; |
|
7695
|
|
|
$copyright_label = null; |
|
7696
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) |
|
7697
|
|
|
{ |
|
7698
|
|
|
$copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7699
|
|
|
} |
|
7700
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) |
|
7701
|
|
|
{ |
|
7702
|
|
|
$copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7703
|
|
|
} |
|
7704
|
|
|
$copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); |
|
7705
|
|
|
} |
|
7706
|
|
|
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) |
|
7707
|
|
|
{ |
|
7708
|
|
|
$copyright_url = null; |
|
7709
|
|
|
$copyright_label = null; |
|
7710
|
|
|
if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) |
|
7711
|
|
|
{ |
|
7712
|
|
|
$copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7713
|
|
|
} |
|
7714
|
|
|
if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) |
|
7715
|
|
|
{ |
|
7716
|
|
|
$copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7717
|
|
|
} |
|
7718
|
|
|
$copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); |
|
7719
|
|
|
} |
|
7720
|
|
|
else |
|
7721
|
|
|
{ |
|
7722
|
|
|
$copyrights = $copyrights_parent; |
|
7723
|
|
|
} |
|
7724
|
|
|
// CREDITS |
|
7725
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) |
|
7726
|
|
|
{ |
|
7727
|
|
|
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) |
|
7728
|
|
|
{ |
|
7729
|
|
|
$credit_role = null; |
|
7730
|
|
|
$credit_scheme = null; |
|
7731
|
|
|
$credit_name = null; |
|
7732
|
|
|
if (isset($credit['attribs']['']['role'])) |
|
7733
|
|
|
{ |
|
7734
|
|
|
$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7735
|
|
|
} |
|
7736
|
|
|
if (isset($credit['attribs']['']['scheme'])) |
|
7737
|
|
|
{ |
|
7738
|
|
|
$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7739
|
|
|
} |
|
7740
|
|
|
else |
|
7741
|
|
|
{ |
|
7742
|
|
|
$credit_scheme = 'urn:ebu'; |
|
7743
|
|
|
} |
|
7744
|
|
|
if (isset($credit['data'])) |
|
7745
|
|
|
{ |
|
7746
|
|
|
$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7747
|
|
|
} |
|
7748
|
|
|
$credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); |
|
7749
|
|
|
} |
|
7750
|
|
|
if (is_array($credits)) |
|
7751
|
|
|
{ |
|
7752
|
|
|
$credits = array_values(array_unique($credits)); |
|
7753
|
|
|
} |
|
7754
|
|
|
} |
|
7755
|
|
|
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) |
|
7756
|
|
|
{ |
|
7757
|
|
|
foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) |
|
7758
|
|
|
{ |
|
7759
|
|
|
$credit_role = null; |
|
7760
|
|
|
$credit_scheme = null; |
|
7761
|
|
|
$credit_name = null; |
|
7762
|
|
|
if (isset($credit['attribs']['']['role'])) |
|
7763
|
|
|
{ |
|
7764
|
|
|
$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7765
|
|
|
} |
|
7766
|
|
|
if (isset($credit['attribs']['']['scheme'])) |
|
7767
|
|
|
{ |
|
7768
|
|
|
$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7769
|
|
|
} |
|
7770
|
|
|
else |
|
7771
|
|
|
{ |
|
7772
|
|
|
$credit_scheme = 'urn:ebu'; |
|
7773
|
|
|
} |
|
7774
|
|
|
if (isset($credit['data'])) |
|
7775
|
|
|
{ |
|
7776
|
|
|
$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7777
|
|
|
} |
|
7778
|
|
|
$credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); |
|
7779
|
|
|
} |
|
7780
|
|
|
if (is_array($credits)) |
|
7781
|
|
|
{ |
|
7782
|
|
|
$credits = array_values(array_unique($credits)); |
|
7783
|
|
|
} |
|
7784
|
|
|
} |
|
7785
|
|
|
else |
|
7786
|
|
|
{ |
|
7787
|
|
|
$credits = $credits_parent; |
|
7788
|
|
|
} |
|
7789
|
|
|
// DESCRIPTION |
|
7790
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) |
|
7791
|
|
|
{ |
|
7792
|
|
|
$description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7793
|
|
|
} |
|
7794
|
|
|
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) |
|
7795
|
|
|
{ |
|
7796
|
|
|
$description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7797
|
|
|
} |
|
7798
|
|
|
else |
|
7799
|
|
|
{ |
|
7800
|
|
|
$description = $description_parent; |
|
7801
|
|
|
} |
|
7802
|
|
|
// HASHES |
|
7803
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) |
|
7804
|
|
|
{ |
|
7805
|
|
|
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) |
|
7806
|
|
|
{ |
|
7807
|
|
|
$value = null; |
|
7808
|
|
|
$algo = null; |
|
7809
|
|
|
if (isset($hash['data'])) |
|
7810
|
|
|
{ |
|
7811
|
|
|
$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7812
|
|
|
} |
|
7813
|
|
|
if (isset($hash['attribs']['']['algo'])) |
|
7814
|
|
|
{ |
|
7815
|
|
|
$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7816
|
|
|
} |
|
7817
|
|
|
else |
|
7818
|
|
|
{ |
|
7819
|
|
|
$algo = 'md5'; |
|
7820
|
|
|
} |
|
7821
|
|
|
$hashes[] = $algo.':'.$value; |
|
7822
|
|
|
} |
|
7823
|
|
|
if (is_array($hashes)) |
|
7824
|
|
|
{ |
|
7825
|
|
|
$hashes = array_values(array_unique($hashes)); |
|
7826
|
|
|
} |
|
7827
|
|
|
} |
|
7828
|
|
|
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) |
|
7829
|
|
|
{ |
|
7830
|
|
|
foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) |
|
7831
|
|
|
{ |
|
7832
|
|
|
$value = null; |
|
7833
|
|
|
$algo = null; |
|
7834
|
|
|
if (isset($hash['data'])) |
|
7835
|
|
|
{ |
|
7836
|
|
|
$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7837
|
|
|
} |
|
7838
|
|
|
if (isset($hash['attribs']['']['algo'])) |
|
7839
|
|
|
{ |
|
7840
|
|
|
$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7841
|
|
|
} |
|
7842
|
|
|
else |
|
7843
|
|
|
{ |
|
7844
|
|
|
$algo = 'md5'; |
|
7845
|
|
|
} |
|
7846
|
|
|
$hashes[] = $algo.':'.$value; |
|
7847
|
|
|
} |
|
7848
|
|
|
if (is_array($hashes)) |
|
7849
|
|
|
{ |
|
7850
|
|
|
$hashes = array_values(array_unique($hashes)); |
|
7851
|
|
|
} |
|
7852
|
|
|
} |
|
7853
|
|
|
else |
|
7854
|
|
|
{ |
|
7855
|
|
|
$hashes = $hashes_parent; |
|
7856
|
|
|
} |
|
7857
|
|
|
// KEYWORDS |
|
7858
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) |
|
7859
|
|
|
{ |
|
7860
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) |
|
7861
|
|
|
{ |
|
7862
|
|
|
$temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); |
|
7863
|
|
|
foreach ($temp as $word) |
|
7864
|
|
|
{ |
|
7865
|
|
|
$keywords[] = trim($word); |
|
7866
|
|
|
} |
|
7867
|
|
|
unset($temp); |
|
7868
|
|
|
} |
|
7869
|
|
|
if (is_array($keywords)) |
|
7870
|
|
|
{ |
|
7871
|
|
|
$keywords = array_values(array_unique($keywords)); |
|
7872
|
|
|
} |
|
7873
|
|
|
} |
|
7874
|
|
|
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) |
|
7875
|
|
|
{ |
|
7876
|
|
|
if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) |
|
7877
|
|
|
{ |
|
7878
|
|
|
$temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); |
|
7879
|
|
|
foreach ($temp as $word) |
|
7880
|
|
|
{ |
|
7881
|
|
|
$keywords[] = trim($word); |
|
7882
|
|
|
} |
|
7883
|
|
|
unset($temp); |
|
7884
|
|
|
} |
|
7885
|
|
|
if (is_array($keywords)) |
|
7886
|
|
|
{ |
|
7887
|
|
|
$keywords = array_values(array_unique($keywords)); |
|
7888
|
|
|
} |
|
7889
|
|
|
} |
|
7890
|
|
|
else |
|
7891
|
|
|
{ |
|
7892
|
|
|
$keywords = $keywords_parent; |
|
7893
|
|
|
} |
|
7894
|
|
|
// PLAYER |
|
7895
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) |
|
7896
|
|
|
{ |
|
7897
|
|
|
$player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
|
7898
|
|
|
} |
|
7899
|
|
|
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) |
|
7900
|
|
|
{ |
|
7901
|
|
|
$player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
|
7902
|
|
|
} |
|
7903
|
|
|
else |
|
7904
|
|
|
{ |
|
7905
|
|
|
$player = $player_parent; |
|
7906
|
|
|
} |
|
7907
|
|
|
// RATINGS |
|
7908
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) |
|
7909
|
|
|
{ |
|
7910
|
|
|
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) |
|
7911
|
|
|
{ |
|
7912
|
|
|
$rating_scheme = null; |
|
7913
|
|
|
$rating_value = null; |
|
7914
|
|
|
if (isset($rating['attribs']['']['scheme'])) |
|
7915
|
|
|
{ |
|
7916
|
|
|
$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7917
|
|
|
} |
|
7918
|
|
|
else |
|
7919
|
|
|
{ |
|
7920
|
|
|
$rating_scheme = 'urn:simple'; |
|
7921
|
|
|
} |
|
7922
|
|
|
if (isset($rating['data'])) |
|
7923
|
|
|
{ |
|
7924
|
|
|
$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7925
|
|
|
} |
|
7926
|
|
|
$ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); |
|
7927
|
|
|
} |
|
7928
|
|
|
if (is_array($ratings)) |
|
7929
|
|
|
{ |
|
7930
|
|
|
$ratings = array_values(array_unique($ratings)); |
|
7931
|
|
|
} |
|
7932
|
|
|
} |
|
7933
|
|
|
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) |
|
7934
|
|
|
{ |
|
7935
|
|
|
foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) |
|
7936
|
|
|
{ |
|
7937
|
|
|
$rating_scheme = null; |
|
7938
|
|
|
$rating_value = null; |
|
7939
|
|
|
if (isset($rating['attribs']['']['scheme'])) |
|
7940
|
|
|
{ |
|
7941
|
|
|
$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7942
|
|
|
} |
|
7943
|
|
|
else |
|
7944
|
|
|
{ |
|
7945
|
|
|
$rating_scheme = 'urn:simple'; |
|
7946
|
|
|
} |
|
7947
|
|
|
if (isset($rating['data'])) |
|
7948
|
|
|
{ |
|
7949
|
|
|
$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7950
|
|
|
} |
|
7951
|
|
|
$ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); |
|
7952
|
|
|
} |
|
7953
|
|
|
if (is_array($ratings)) |
|
7954
|
|
|
{ |
|
7955
|
|
|
$ratings = array_values(array_unique($ratings)); |
|
7956
|
|
|
} |
|
7957
|
|
|
} |
|
7958
|
|
|
else |
|
7959
|
|
|
{ |
|
7960
|
|
|
$ratings = $ratings_parent; |
|
7961
|
|
|
} |
|
7962
|
|
|
// RESTRICTIONS |
|
7963
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) |
|
7964
|
|
|
{ |
|
7965
|
|
|
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) |
|
7966
|
|
|
{ |
|
7967
|
|
|
$restriction_relationship = null; |
|
7968
|
|
|
$restriction_type = null; |
|
7969
|
|
|
$restriction_value = null; |
|
7970
|
|
|
if (isset($restriction['attribs']['']['relationship'])) |
|
7971
|
|
|
{ |
|
7972
|
|
|
$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7973
|
|
|
} |
|
7974
|
|
|
if (isset($restriction['attribs']['']['type'])) |
|
7975
|
|
|
{ |
|
7976
|
|
|
$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7977
|
|
|
} |
|
7978
|
|
|
if (isset($restriction['data'])) |
|
7979
|
|
|
{ |
|
7980
|
|
|
$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7981
|
|
|
} |
|
7982
|
|
|
$restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); |
|
7983
|
|
|
} |
|
7984
|
|
|
if (is_array($restrictions)) |
|
7985
|
|
|
{ |
|
7986
|
|
|
$restrictions = array_values(array_unique($restrictions)); |
|
7987
|
|
|
} |
|
7988
|
|
|
} |
|
7989
|
|
|
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) |
|
7990
|
|
|
{ |
|
7991
|
|
|
foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) |
|
7992
|
|
|
{ |
|
7993
|
|
|
$restriction_relationship = null; |
|
7994
|
|
|
$restriction_type = null; |
|
7995
|
|
|
$restriction_value = null; |
|
7996
|
|
|
if (isset($restriction['attribs']['']['relationship'])) |
|
7997
|
|
|
{ |
|
7998
|
|
|
$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
7999
|
|
|
} |
|
8000
|
|
|
if (isset($restriction['attribs']['']['type'])) |
|
8001
|
|
|
{ |
|
8002
|
|
|
$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8003
|
|
|
} |
|
8004
|
|
|
if (isset($restriction['data'])) |
|
8005
|
|
|
{ |
|
8006
|
|
|
$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8007
|
|
|
} |
|
8008
|
|
|
$restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); |
|
8009
|
|
|
} |
|
8010
|
|
|
if (is_array($restrictions)) |
|
8011
|
|
|
{ |
|
8012
|
|
|
$restrictions = array_values(array_unique($restrictions)); |
|
8013
|
|
|
} |
|
8014
|
|
|
} |
|
8015
|
|
|
else |
|
8016
|
|
|
{ |
|
8017
|
|
|
$restrictions = $restrictions_parent; |
|
8018
|
|
|
} |
|
8019
|
|
|
// THUMBNAILS |
|
8020
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) |
|
8021
|
|
|
{ |
|
8022
|
|
|
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) |
|
8023
|
|
|
{ |
|
8024
|
|
|
$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
|
8025
|
|
|
} |
|
8026
|
|
|
if (is_array($thumbnails)) |
|
8027
|
|
|
{ |
|
8028
|
|
|
$thumbnails = array_values(array_unique($thumbnails)); |
|
8029
|
|
|
} |
|
8030
|
|
|
} |
|
8031
|
|
|
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) |
|
8032
|
|
|
{ |
|
8033
|
|
|
foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) |
|
8034
|
|
|
{ |
|
8035
|
|
|
$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
|
8036
|
|
|
} |
|
8037
|
|
|
if (is_array($thumbnails)) |
|
8038
|
|
|
{ |
|
8039
|
|
|
$thumbnails = array_values(array_unique($thumbnails)); |
|
8040
|
|
|
} |
|
8041
|
|
|
} |
|
8042
|
|
|
else |
|
8043
|
|
|
{ |
|
8044
|
|
|
$thumbnails = $thumbnails_parent; |
|
8045
|
|
|
} |
|
8046
|
|
|
// TITLES |
|
8047
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) |
|
8048
|
|
|
{ |
|
8049
|
|
|
$title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8050
|
|
|
} |
|
8051
|
|
|
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) |
|
8052
|
|
|
{ |
|
8053
|
|
|
$title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8054
|
|
|
} |
|
8055
|
|
|
else |
|
8056
|
|
|
{ |
|
8057
|
|
|
$title = $title_parent; |
|
8058
|
|
|
} |
|
8059
|
|
|
$this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width)); |
|
8060
|
|
|
} |
|
8061
|
|
|
} |
|
8062
|
|
|
} |
|
8063
|
|
|
} |
|
8064
|
|
|
// If we have standalone media:content tags, loop through them. |
|
8065
|
|
|
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'])) |
|
8066
|
|
|
{ |
|
8067
|
|
|
foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) |
|
8068
|
|
|
{ |
|
8069
|
|
|
if (isset($content['attribs']['']['url']) || isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) |
|
8070
|
|
|
{ |
|
8071
|
|
|
// Attributes |
|
8072
|
|
|
$bitrate = null; |
|
8073
|
|
|
$channels = null; |
|
8074
|
|
|
$duration = null; |
|
8075
|
|
|
$expression = null; |
|
8076
|
|
|
$framerate = null; |
|
8077
|
|
|
$height = null; |
|
8078
|
|
|
$javascript = null; |
|
8079
|
|
|
$lang = null; |
|
8080
|
|
|
$length = null; |
|
8081
|
|
|
$medium = null; |
|
8082
|
|
|
$samplingrate = null; |
|
8083
|
|
|
$type = null; |
|
8084
|
|
|
$url = null; |
|
8085
|
|
|
$width = null; |
|
8086
|
|
|
// Elements |
|
8087
|
|
|
$captions = null; |
|
8088
|
|
|
$categories = null; |
|
8089
|
|
|
$copyrights = null; |
|
8090
|
|
|
$credits = null; |
|
8091
|
|
|
$description = null; |
|
8092
|
|
|
$hashes = null; |
|
8093
|
|
|
$keywords = null; |
|
8094
|
|
|
$player = null; |
|
8095
|
|
|
$ratings = null; |
|
8096
|
|
|
$restrictions = null; |
|
8097
|
|
|
$thumbnails = null; |
|
8098
|
|
|
$title = null; |
|
8099
|
|
|
// Start checking the attributes of media:content |
|
8100
|
|
|
if (isset($content['attribs']['']['bitrate'])) |
|
8101
|
|
|
{ |
|
8102
|
|
|
$bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8103
|
|
|
} |
|
8104
|
|
|
if (isset($content['attribs']['']['channels'])) |
|
8105
|
|
|
{ |
|
8106
|
|
|
$channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8107
|
|
|
} |
|
8108
|
|
|
if (isset($content['attribs']['']['duration'])) |
|
8109
|
|
|
{ |
|
8110
|
|
|
$duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8111
|
|
|
} |
|
8112
|
|
|
else |
|
8113
|
|
|
{ |
|
8114
|
|
|
$duration = $duration_parent; |
|
8115
|
|
|
} |
|
8116
|
|
|
if (isset($content['attribs']['']['expression'])) |
|
8117
|
|
|
{ |
|
8118
|
|
|
$expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8119
|
|
|
} |
|
8120
|
|
|
if (isset($content['attribs']['']['framerate'])) |
|
8121
|
|
|
{ |
|
8122
|
|
|
$framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8123
|
|
|
} |
|
8124
|
|
|
if (isset($content['attribs']['']['height'])) |
|
8125
|
|
|
{ |
|
8126
|
|
|
$height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8127
|
|
|
} |
|
8128
|
|
|
if (isset($content['attribs']['']['lang'])) |
|
8129
|
|
|
{ |
|
8130
|
|
|
$lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8131
|
|
|
} |
|
8132
|
|
|
if (isset($content['attribs']['']['fileSize'])) |
|
8133
|
|
|
{ |
|
8134
|
|
|
$length = ceil($content['attribs']['']['fileSize']); |
|
8135
|
|
|
} |
|
8136
|
|
|
if (isset($content['attribs']['']['medium'])) |
|
8137
|
|
|
{ |
|
8138
|
|
|
$medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8139
|
|
|
} |
|
8140
|
|
|
if (isset($content['attribs']['']['samplingrate'])) |
|
8141
|
|
|
{ |
|
8142
|
|
|
$samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8143
|
|
|
} |
|
8144
|
|
|
if (isset($content['attribs']['']['type'])) |
|
8145
|
|
|
{ |
|
8146
|
|
|
$type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8147
|
|
|
} |
|
8148
|
|
|
if (isset($content['attribs']['']['width'])) |
|
8149
|
|
|
{ |
|
8150
|
|
|
$width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8151
|
|
|
} |
|
8152
|
|
|
if (isset($content['attribs']['']['url'])) |
|
8153
|
|
|
{ |
|
8154
|
|
|
$url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
|
8155
|
|
|
} |
|
8156
|
|
|
// Checking the other optional media: elements. Priority: media:content, media:group, item, channel |
|
8157
|
|
|
// CAPTIONS |
|
8158
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) |
|
8159
|
|
|
{ |
|
8160
|
|
|
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) |
|
8161
|
|
|
{ |
|
8162
|
|
|
$caption_type = null; |
|
8163
|
|
|
$caption_lang = null; |
|
8164
|
|
|
$caption_startTime = null; |
|
8165
|
|
|
$caption_endTime = null; |
|
8166
|
|
|
$caption_text = null; |
|
8167
|
|
|
if (isset($caption['attribs']['']['type'])) |
|
8168
|
|
|
{ |
|
8169
|
|
|
$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8170
|
|
|
} |
|
8171
|
|
|
if (isset($caption['attribs']['']['lang'])) |
|
8172
|
|
|
{ |
|
8173
|
|
|
$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8174
|
|
|
} |
|
8175
|
|
|
if (isset($caption['attribs']['']['start'])) |
|
8176
|
|
|
{ |
|
8177
|
|
|
$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8178
|
|
|
} |
|
8179
|
|
|
if (isset($caption['attribs']['']['end'])) |
|
8180
|
|
|
{ |
|
8181
|
|
|
$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8182
|
|
|
} |
|
8183
|
|
|
if (isset($caption['data'])) |
|
8184
|
|
|
{ |
|
8185
|
|
|
$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8186
|
|
|
} |
|
8187
|
|
|
$captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); |
|
8188
|
|
|
} |
|
8189
|
|
|
if (is_array($captions)) |
|
8190
|
|
|
{ |
|
8191
|
|
|
$captions = array_values(array_unique($captions)); |
|
8192
|
|
|
} |
|
8193
|
|
|
} |
|
8194
|
|
|
else |
|
8195
|
|
|
{ |
|
8196
|
|
|
$captions = $captions_parent; |
|
8197
|
|
|
} |
|
8198
|
|
|
// CATEGORIES |
|
8199
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) |
|
8200
|
|
|
{ |
|
8201
|
|
|
foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) |
|
8202
|
|
|
{ |
|
8203
|
|
|
$term = null; |
|
8204
|
|
|
$scheme = null; |
|
8205
|
|
|
$label = null; |
|
8206
|
|
|
if (isset($category['data'])) |
|
8207
|
|
|
{ |
|
8208
|
|
|
$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8209
|
|
|
} |
|
8210
|
|
|
if (isset($category['attribs']['']['scheme'])) |
|
8211
|
|
|
{ |
|
8212
|
|
|
$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8213
|
|
|
} |
|
8214
|
|
|
else |
|
8215
|
|
|
{ |
|
8216
|
|
|
$scheme = 'http://search.yahoo.com/mrss/category_schema'; |
|
8217
|
|
|
} |
|
8218
|
|
|
if (isset($category['attribs']['']['label'])) |
|
8219
|
|
|
{ |
|
8220
|
|
|
$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8221
|
|
|
} |
|
8222
|
|
|
$categories[] = $this->registry->create('Category', array($term, $scheme, $label)); |
|
8223
|
|
|
} |
|
8224
|
|
|
} |
|
8225
|
|
|
if (is_array($categories) && is_array($categories_parent)) |
|
8226
|
|
|
{ |
|
8227
|
|
|
$categories = array_values(array_unique(array_merge($categories, $categories_parent))); |
|
8228
|
|
|
} |
|
8229
|
|
|
elseif (is_array($categories)) |
|
8230
|
|
|
{ |
|
8231
|
|
|
$categories = array_values(array_unique($categories)); |
|
8232
|
|
|
} |
|
8233
|
|
|
elseif (is_array($categories_parent)) |
|
8234
|
|
|
{ |
|
8235
|
|
|
$categories = array_values(array_unique($categories_parent)); |
|
8236
|
|
|
} |
|
8237
|
|
|
else |
|
8238
|
|
|
{ |
|
8239
|
|
|
$categories = null; |
|
8240
|
|
|
} |
|
8241
|
|
|
// COPYRIGHTS |
|
8242
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) |
|
8243
|
|
|
{ |
|
8244
|
|
|
$copyright_url = null; |
|
8245
|
|
|
$copyright_label = null; |
|
8246
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) |
|
8247
|
|
|
{ |
|
8248
|
|
|
$copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8249
|
|
|
} |
|
8250
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) |
|
8251
|
|
|
{ |
|
8252
|
|
|
$copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8253
|
|
|
} |
|
8254
|
|
|
$copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); |
|
8255
|
|
|
} |
|
8256
|
|
|
else |
|
8257
|
|
|
{ |
|
8258
|
|
|
$copyrights = $copyrights_parent; |
|
8259
|
|
|
} |
|
8260
|
|
|
// CREDITS |
|
8261
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) |
|
8262
|
|
|
{ |
|
8263
|
|
|
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) |
|
8264
|
|
|
{ |
|
8265
|
|
|
$credit_role = null; |
|
8266
|
|
|
$credit_scheme = null; |
|
8267
|
|
|
$credit_name = null; |
|
8268
|
|
|
if (isset($credit['attribs']['']['role'])) |
|
8269
|
|
|
{ |
|
8270
|
|
|
$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8271
|
|
|
} |
|
8272
|
|
|
if (isset($credit['attribs']['']['scheme'])) |
|
8273
|
|
|
{ |
|
8274
|
|
|
$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8275
|
|
|
} |
|
8276
|
|
|
else |
|
8277
|
|
|
{ |
|
8278
|
|
|
$credit_scheme = 'urn:ebu'; |
|
8279
|
|
|
} |
|
8280
|
|
|
if (isset($credit['data'])) |
|
8281
|
|
|
{ |
|
8282
|
|
|
$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8283
|
|
|
} |
|
8284
|
|
|
$credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); |
|
8285
|
|
|
} |
|
8286
|
|
|
if (is_array($credits)) |
|
8287
|
|
|
{ |
|
8288
|
|
|
$credits = array_values(array_unique($credits)); |
|
8289
|
|
|
} |
|
8290
|
|
|
} |
|
8291
|
|
|
else |
|
8292
|
|
|
{ |
|
8293
|
|
|
$credits = $credits_parent; |
|
8294
|
|
|
} |
|
8295
|
|
|
// DESCRIPTION |
|
8296
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) |
|
8297
|
|
|
{ |
|
8298
|
|
|
$description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8299
|
|
|
} |
|
8300
|
|
|
else |
|
8301
|
|
|
{ |
|
8302
|
|
|
$description = $description_parent; |
|
8303
|
|
|
} |
|
8304
|
|
|
// HASHES |
|
8305
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) |
|
8306
|
|
|
{ |
|
8307
|
|
|
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) |
|
8308
|
|
|
{ |
|
8309
|
|
|
$value = null; |
|
8310
|
|
|
$algo = null; |
|
8311
|
|
|
if (isset($hash['data'])) |
|
8312
|
|
|
{ |
|
8313
|
|
|
$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8314
|
|
|
} |
|
8315
|
|
|
if (isset($hash['attribs']['']['algo'])) |
|
8316
|
|
|
{ |
|
8317
|
|
|
$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8318
|
|
|
} |
|
8319
|
|
|
else |
|
8320
|
|
|
{ |
|
8321
|
|
|
$algo = 'md5'; |
|
8322
|
|
|
} |
|
8323
|
|
|
$hashes[] = $algo.':'.$value; |
|
8324
|
|
|
} |
|
8325
|
|
|
if (is_array($hashes)) |
|
8326
|
|
|
{ |
|
8327
|
|
|
$hashes = array_values(array_unique($hashes)); |
|
8328
|
|
|
} |
|
8329
|
|
|
} |
|
8330
|
|
|
else |
|
8331
|
|
|
{ |
|
8332
|
|
|
$hashes = $hashes_parent; |
|
8333
|
|
|
} |
|
8334
|
|
|
// KEYWORDS |
|
8335
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) |
|
8336
|
|
|
{ |
|
8337
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) |
|
8338
|
|
|
{ |
|
8339
|
|
|
$temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); |
|
8340
|
|
|
foreach ($temp as $word) |
|
8341
|
|
|
{ |
|
8342
|
|
|
$keywords[] = trim($word); |
|
8343
|
|
|
} |
|
8344
|
|
|
unset($temp); |
|
8345
|
|
|
} |
|
8346
|
|
|
if (is_array($keywords)) |
|
8347
|
|
|
{ |
|
8348
|
|
|
$keywords = array_values(array_unique($keywords)); |
|
8349
|
|
|
} |
|
8350
|
|
|
} |
|
8351
|
|
|
else |
|
8352
|
|
|
{ |
|
8353
|
|
|
$keywords = $keywords_parent; |
|
8354
|
|
|
} |
|
8355
|
|
|
// PLAYER |
|
8356
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) |
|
8357
|
|
|
{ |
|
8358
|
|
|
$player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
|
8359
|
|
|
} |
|
8360
|
|
|
else |
|
8361
|
|
|
{ |
|
8362
|
|
|
$player = $player_parent; |
|
8363
|
|
|
} |
|
8364
|
|
|
// RATINGS |
|
8365
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) |
|
8366
|
|
|
{ |
|
8367
|
|
|
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) |
|
8368
|
|
|
{ |
|
8369
|
|
|
$rating_scheme = null; |
|
8370
|
|
|
$rating_value = null; |
|
8371
|
|
|
if (isset($rating['attribs']['']['scheme'])) |
|
8372
|
|
|
{ |
|
8373
|
|
|
$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8374
|
|
|
} |
|
8375
|
|
|
else |
|
8376
|
|
|
{ |
|
8377
|
|
|
$rating_scheme = 'urn:simple'; |
|
8378
|
|
|
} |
|
8379
|
|
|
if (isset($rating['data'])) |
|
8380
|
|
|
{ |
|
8381
|
|
|
$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8382
|
|
|
} |
|
8383
|
|
|
$ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); |
|
8384
|
|
|
} |
|
8385
|
|
|
if (is_array($ratings)) |
|
8386
|
|
|
{ |
|
8387
|
|
|
$ratings = array_values(array_unique($ratings)); |
|
8388
|
|
|
} |
|
8389
|
|
|
} |
|
8390
|
|
|
else |
|
8391
|
|
|
{ |
|
8392
|
|
|
$ratings = $ratings_parent; |
|
8393
|
|
|
} |
|
8394
|
|
|
// RESTRICTIONS |
|
8395
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) |
|
8396
|
|
|
{ |
|
8397
|
|
|
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) |
|
8398
|
|
|
{ |
|
8399
|
|
|
$restriction_relationship = null; |
|
8400
|
|
|
$restriction_type = null; |
|
8401
|
|
|
$restriction_value = null; |
|
8402
|
|
|
if (isset($restriction['attribs']['']['relationship'])) |
|
8403
|
|
|
{ |
|
8404
|
|
|
$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8405
|
|
|
} |
|
8406
|
|
|
if (isset($restriction['attribs']['']['type'])) |
|
8407
|
|
|
{ |
|
8408
|
|
|
$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8409
|
|
|
} |
|
8410
|
|
|
if (isset($restriction['data'])) |
|
8411
|
|
|
{ |
|
8412
|
|
|
$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8413
|
|
|
} |
|
8414
|
|
|
$restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); |
|
8415
|
|
|
} |
|
8416
|
|
|
if (is_array($restrictions)) |
|
8417
|
|
|
{ |
|
8418
|
|
|
$restrictions = array_values(array_unique($restrictions)); |
|
8419
|
|
|
} |
|
8420
|
|
|
} |
|
8421
|
|
|
else |
|
8422
|
|
|
{ |
|
8423
|
|
|
$restrictions = $restrictions_parent; |
|
8424
|
|
|
} |
|
8425
|
|
|
// THUMBNAILS |
|
8426
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) |
|
8427
|
|
|
{ |
|
8428
|
|
|
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) |
|
8429
|
|
|
{ |
|
8430
|
|
|
$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
|
8431
|
|
|
} |
|
8432
|
|
|
if (is_array($thumbnails)) |
|
8433
|
|
|
{ |
|
8434
|
|
|
$thumbnails = array_values(array_unique($thumbnails)); |
|
8435
|
|
|
} |
|
8436
|
|
|
} |
|
8437
|
|
|
else |
|
8438
|
|
|
{ |
|
8439
|
|
|
$thumbnails = $thumbnails_parent; |
|
8440
|
|
|
} |
|
8441
|
|
|
// TITLES |
|
8442
|
|
|
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) |
|
8443
|
|
|
{ |
|
8444
|
|
|
$title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8445
|
|
|
} |
|
8446
|
|
|
else |
|
8447
|
|
|
{ |
|
8448
|
|
|
$title = $title_parent; |
|
8449
|
|
|
} |
|
8450
|
|
|
$this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width)); |
|
8451
|
|
|
} |
|
8452
|
|
|
} |
|
8453
|
|
|
} |
|
8454
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) |
|
8455
|
|
|
{ |
|
8456
|
|
|
if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') |
|
8457
|
|
|
{ |
|
8458
|
|
|
// Attributes |
|
8459
|
|
|
$bitrate = null; |
|
8460
|
|
|
$channels = null; |
|
8461
|
|
|
$duration = null; |
|
8462
|
|
|
$expression = null; |
|
8463
|
|
|
$framerate = null; |
|
8464
|
|
|
$height = null; |
|
8465
|
|
|
$javascript = null; |
|
8466
|
|
|
$lang = null; |
|
8467
|
|
|
$length = null; |
|
8468
|
|
|
$medium = null; |
|
8469
|
|
|
$samplingrate = null; |
|
8470
|
|
|
$type = null; |
|
8471
|
|
|
$url = null; |
|
8472
|
|
|
$width = null; |
|
8473
|
|
|
$url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); |
|
8474
|
|
|
if (isset($link['attribs']['']['type'])) |
|
8475
|
|
|
{ |
|
8476
|
|
|
$type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8477
|
|
|
} |
|
8478
|
|
|
if (isset($link['attribs']['']['length'])) |
|
8479
|
|
|
{ |
|
8480
|
|
|
$length = ceil($link['attribs']['']['length']); |
|
8481
|
|
|
} |
|
8482
|
|
|
// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor |
|
8483
|
|
|
$this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $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)); |
|
8484
|
|
|
} |
|
8485
|
|
|
} |
|
8486
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) |
|
8487
|
|
|
{ |
|
8488
|
|
|
if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') |
|
8489
|
|
|
{ |
|
8490
|
|
|
// Attributes |
|
8491
|
|
|
$bitrate = null; |
|
8492
|
|
|
$channels = null; |
|
8493
|
|
|
$duration = null; |
|
8494
|
|
|
$expression = null; |
|
8495
|
|
|
$framerate = null; |
|
8496
|
|
|
$height = null; |
|
8497
|
|
|
$javascript = null; |
|
8498
|
|
|
$lang = null; |
|
8499
|
|
|
$length = null; |
|
8500
|
|
|
$medium = null; |
|
8501
|
|
|
$samplingrate = null; |
|
8502
|
|
|
$type = null; |
|
8503
|
|
|
$url = null; |
|
8504
|
|
|
$width = null; |
|
8505
|
|
|
$url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); |
|
8506
|
|
|
if (isset($link['attribs']['']['type'])) |
|
8507
|
|
|
{ |
|
8508
|
|
|
$type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8509
|
|
|
} |
|
8510
|
|
|
if (isset($link['attribs']['']['length'])) |
|
8511
|
|
|
{ |
|
8512
|
|
|
$length = ceil($link['attribs']['']['length']); |
|
8513
|
|
|
} |
|
8514
|
|
|
// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor |
|
8515
|
|
|
$this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $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)); |
|
8516
|
|
|
} |
|
8517
|
|
|
} |
|
8518
|
|
|
if ($enclosure = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure')) |
|
8519
|
|
|
{ |
|
8520
|
|
|
if (isset($enclosure[0]['attribs']['']['url'])) |
|
8521
|
|
|
{ |
|
8522
|
|
|
// Attributes |
|
8523
|
|
|
$bitrate = null; |
|
8524
|
|
|
$channels = null; |
|
8525
|
|
|
$duration = null; |
|
8526
|
|
|
$expression = null; |
|
8527
|
|
|
$framerate = null; |
|
8528
|
|
|
$height = null; |
|
8529
|
|
|
$javascript = null; |
|
8530
|
|
|
$lang = null; |
|
8531
|
|
|
$length = null; |
|
8532
|
|
|
$medium = null; |
|
8533
|
|
|
$samplingrate = null; |
|
8534
|
|
|
$type = null; |
|
8535
|
|
|
$url = null; |
|
8536
|
|
|
$width = null; |
|
8537
|
|
|
$url = $this->sanitize($enclosure[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($enclosure[0])); |
|
8538
|
|
|
if (isset($enclosure[0]['attribs']['']['type'])) |
|
8539
|
|
|
{ |
|
8540
|
|
|
$type = $this->sanitize($enclosure[0]['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
8541
|
|
|
} |
|
8542
|
|
|
if (isset($enclosure[0]['attribs']['']['length'])) |
|
8543
|
|
|
{ |
|
8544
|
|
|
$length = ceil($enclosure[0]['attribs']['']['length']); |
|
8545
|
|
|
} |
|
8546
|
|
|
// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor |
|
8547
|
|
|
$this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $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)); |
|
8548
|
|
|
} |
|
8549
|
|
|
} |
|
8550
|
|
|
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)) |
|
8551
|
|
|
{ |
|
8552
|
|
|
// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor |
|
8553
|
|
|
$this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $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)); |
|
8554
|
|
|
} |
|
8555
|
|
|
$this->data['enclosures'] = array_values(array_unique($this->data['enclosures'])); |
|
8556
|
|
|
} |
|
8557
|
|
|
if (!empty($this->data['enclosures'])) |
|
8558
|
|
|
{ |
|
8559
|
|
|
return $this->data['enclosures']; |
|
8560
|
|
|
} |
|
8561
|
|
|
else |
|
8562
|
|
|
{ |
|
8563
|
|
|
return null; |
|
8564
|
|
|
} |
|
8565
|
|
|
} |
|
8566
|
|
|
|
|
8567
|
|
|
public function get_latitude() |
|
8568
|
|
|
{ |
|
8569
|
|
|
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) |
|
8570
|
|
|
{ |
|
8571
|
|
|
return (float) $return[0]['data']; |
|
8572
|
|
|
} |
|
8573
|
|
|
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)) |
|
8574
|
|
|
{ |
|
8575
|
|
|
return (float) $match[1]; |
|
8576
|
|
|
} |
|
8577
|
|
|
else |
|
8578
|
|
|
{ |
|
8579
|
|
|
return null; |
|
8580
|
|
|
} |
|
8581
|
|
|
} |
|
8582
|
|
|
|
|
8583
|
|
|
public function get_longitude() |
|
8584
|
|
|
{ |
|
8585
|
|
|
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) |
|
8586
|
|
|
{ |
|
8587
|
|
|
return (float) $return[0]['data']; |
|
8588
|
|
|
} |
|
8589
|
|
|
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) |
|
8590
|
|
|
{ |
|
8591
|
|
|
return (float) $return[0]['data']; |
|
8592
|
|
|
} |
|
8593
|
|
|
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)) |
|
8594
|
|
|
{ |
|
8595
|
|
|
return (float) $match[2]; |
|
8596
|
|
|
} |
|
8597
|
|
|
else |
|
8598
|
|
|
{ |
|
8599
|
|
|
return null; |
|
8600
|
|
|
} |
|
8601
|
|
|
} |
|
8602
|
|
|
|
|
8603
|
|
|
public function get_source() |
|
8604
|
|
|
{ |
|
8605
|
|
|
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source')) |
|
8606
|
|
|
{ |
|
8607
|
|
|
return $this->registry->create('Source', array($this, $return[0])); |
|
8608
|
|
|
} |
|
8609
|
|
|
else |
|
8610
|
|
|
{ |
|
8611
|
|
|
return null; |
|
8612
|
|
|
} |
|
8613
|
|
|
} |
|
8614
|
|
|
} |
|
8615
|
|
|
class SimplePie_Locator |
|
8616
|
|
|
{ |
|
8617
|
|
|
var $useragent; |
|
8618
|
|
|
var $timeout; |
|
8619
|
|
|
var $file; |
|
8620
|
|
|
var $local = array(); |
|
8621
|
|
|
var $elsewhere = array(); |
|
8622
|
|
|
var $cached_entities = array(); |
|
8623
|
|
|
var $http_base; |
|
8624
|
|
|
var $base; |
|
8625
|
|
|
var $base_location = 0; |
|
8626
|
|
|
var $checked_feeds = 0; |
|
8627
|
|
|
var $max_checked_feeds = 10; |
|
8628
|
|
|
protected $registry; |
|
8629
|
|
|
public function __construct(SimplePie_File $file, $timeout = 10, $useragent = null, $max_checked_feeds = 10) |
|
8630
|
|
|
{ |
|
8631
|
|
|
$this->file = $file; |
|
8632
|
|
|
$this->useragent = $useragent; |
|
8633
|
|
|
$this->timeout = $timeout; |
|
8634
|
|
|
$this->max_checked_feeds = $max_checked_feeds; |
|
8635
|
|
|
if (class_exists('DOMDocument')) |
|
8636
|
|
|
{ |
|
8637
|
|
|
$this->dom = new DOMDocument(); |
|
8638
|
|
|
set_error_handler(array('SimplePie_Misc', 'silence_errors')); |
|
8639
|
|
|
$this->dom->loadHTML($this->file->body); |
|
8640
|
|
|
restore_error_handler(); |
|
8641
|
|
|
} |
|
8642
|
|
|
else |
|
8643
|
|
|
{ |
|
8644
|
|
|
$this->dom = null; |
|
8645
|
|
|
} |
|
8646
|
|
|
} |
|
8647
|
|
|
public function set_registry(SimplePie_Registry $registry) |
|
8648
|
|
|
{ |
|
8649
|
|
|
$this->registry = $registry; |
|
8650
|
|
|
} |
|
8651
|
|
|
public function find($type = SIMPLEPIE_LOCATOR_ALL, &$working) |
|
8652
|
|
|
{ |
|
8653
|
|
|
if ($this->is_feed($this->file)) |
|
8654
|
|
|
{ |
|
8655
|
|
|
return $this->file; |
|
8656
|
|
|
} |
|
8657
|
|
|
if ($this->file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) |
|
8658
|
|
|
{ |
|
8659
|
|
|
$sniffer = $this->registry->create('Content_Type_Sniffer', array($this->file)); |
|
8660
|
|
|
if ($sniffer->get_type() !== 'text/html') |
|
8661
|
|
|
{ |
|
8662
|
|
|
return null; |
|
8663
|
|
|
} |
|
8664
|
|
|
} |
|
8665
|
|
|
if ($type & ~SIMPLEPIE_LOCATOR_NONE) |
|
8666
|
|
|
{ |
|
8667
|
|
|
$this->get_base(); |
|
8668
|
|
|
} |
|
8669
|
|
|
if ($type & SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working = $this->autodiscovery()) |
|
8670
|
|
|
{ |
|
8671
|
|
|
return $working[0]; |
|
8672
|
|
|
} |
|
8673
|
|
|
if ($type & (SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY | SIMPLEPIE_LOCATOR_REMOTE_EXTENSION | SIMPLEPIE_LOCATOR_REMOTE_BODY) && $this->get_links()) |
|
8674
|
|
|
{ |
|
8675
|
|
|
if ($type & SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working = $this->extension($this->local)) |
|
8676
|
|
|
{ |
|
8677
|
|
|
return $working; |
|
8678
|
|
|
} |
|
8679
|
|
|
if ($type & SIMPLEPIE_LOCATOR_LOCAL_BODY && $working = $this->body($this->local)) |
|
8680
|
|
|
{ |
|
8681
|
|
|
return $working; |
|
8682
|
|
|
} |
|
8683
|
|
|
if ($type & SIMPLEPIE_LOCATOR_REMOTE_EXTENSION && $working = $this->extension($this->elsewhere)) |
|
8684
|
|
|
{ |
|
8685
|
|
|
return $working; |
|
8686
|
|
|
} |
|
8687
|
|
|
if ($type & SIMPLEPIE_LOCATOR_REMOTE_BODY && $working = $this->body($this->elsewhere)) |
|
8688
|
|
|
{ |
|
8689
|
|
|
return $working; |
|
8690
|
|
|
} |
|
8691
|
|
|
} |
|
8692
|
|
|
return null; |
|
8693
|
|
|
} |
|
8694
|
|
|
public function is_feed($file) |
|
8695
|
|
|
{ |
|
8696
|
|
|
if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) |
|
8697
|
|
|
{ |
|
8698
|
|
|
$sniffer = $this->registry->create('Content_Type_Sniffer', array($file)); |
|
8699
|
|
|
$sniffed = $sniffer->get_type(); |
|
8700
|
|
|
if (in_array($sniffed, array('application/rss+xml', 'application/rdf+xml', 'text/rdf', 'application/atom+xml', 'text/xml', 'application/xml'))) |
|
8701
|
|
|
{ |
|
8702
|
|
|
return true; |
|
8703
|
|
|
} |
|
8704
|
|
|
else |
|
8705
|
|
|
{ |
|
8706
|
|
|
return false; |
|
8707
|
|
|
} |
|
8708
|
|
|
} |
|
8709
|
|
|
elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL) |
|
8710
|
|
|
{ |
|
8711
|
|
|
return true; |
|
8712
|
|
|
} |
|
8713
|
|
|
else |
|
8714
|
|
|
{ |
|
8715
|
|
|
return false; |
|
8716
|
|
|
} |
|
8717
|
|
|
} |
|
8718
|
|
|
public function get_base() |
|
8719
|
|
|
{ |
|
8720
|
|
|
if ($this->dom === null) |
|
8721
|
|
|
{ |
|
8722
|
|
|
throw new SimplePie_Exception('DOMDocument not found, unable to use locator'); |
|
8723
|
|
|
} |
|
8724
|
|
|
$this->http_base = $this->file->url; |
|
8725
|
|
|
$this->base = $this->http_base; |
|
8726
|
|
|
$elements = $this->dom->getElementsByTagName('base'); |
|
8727
|
|
|
foreach ($elements as $element) |
|
8728
|
|
|
{ |
|
8729
|
|
|
if ($element->hasAttribute('href')) |
|
8730
|
|
|
{ |
|
8731
|
|
|
$base = $this->registry->call('Misc', 'absolutize_url', array(trim($element->getAttribute('href')), $this->http_base)); |
|
8732
|
|
|
if ($base === false) |
|
8733
|
|
|
{ |
|
8734
|
|
|
continue; |
|
8735
|
|
|
} |
|
8736
|
|
|
$this->base = $base; |
|
8737
|
|
|
$this->base_location = method_exists($element, 'getLineNo') ? $element->getLineNo() : 0; |
|
8738
|
|
|
break; |
|
8739
|
|
|
} |
|
8740
|
|
|
} |
|
8741
|
|
|
} |
|
8742
|
|
|
public function autodiscovery() |
|
8743
|
|
|
{ |
|
8744
|
|
|
$done = array(); |
|
8745
|
|
|
$feeds = array(); |
|
8746
|
|
|
$feeds = array_merge($feeds, $this->search_elements_by_tag('link', $done, $feeds)); |
|
8747
|
|
|
$feeds = array_merge($feeds, $this->search_elements_by_tag('a', $done, $feeds)); |
|
8748
|
|
|
$feeds = array_merge($feeds, $this->search_elements_by_tag('area', $done, $feeds)); |
|
8749
|
|
|
if (!empty($feeds)) |
|
8750
|
|
|
{ |
|
8751
|
|
|
return array_values($feeds); |
|
8752
|
|
|
} |
|
8753
|
|
|
else |
|
8754
|
|
|
{ |
|
8755
|
|
|
return null; |
|
8756
|
|
|
} |
|
8757
|
|
|
} |
|
8758
|
|
|
protected function search_elements_by_tag($name, &$done, $feeds) |
|
8759
|
|
|
{ |
|
8760
|
|
|
if ($this->dom === null) |
|
8761
|
|
|
{ |
|
8762
|
|
|
throw new SimplePie_Exception('DOMDocument not found, unable to use locator'); |
|
8763
|
|
|
} |
|
8764
|
|
|
$links = $this->dom->getElementsByTagName($name); |
|
8765
|
|
|
foreach ($links as $link) |
|
8766
|
|
|
{ |
|
8767
|
|
|
if ($this->checked_feeds === $this->max_checked_feeds) |
|
8768
|
|
|
{ |
|
8769
|
|
|
break; |
|
8770
|
|
|
} |
|
8771
|
|
|
if ($link->hasAttribute('href') && $link->hasAttribute('rel')) |
|
8772
|
|
|
{ |
|
8773
|
|
|
$rel = array_unique($this->registry->call('Misc', 'space_seperated_tokens', array(strtolower($link->getAttribute('rel'))))); |
|
8774
|
|
|
$line = method_exists($link, 'getLineNo') ? $link->getLineNo() : 1; |
|
8775
|
|
|
if ($this->base_location < $line) |
|
8776
|
|
|
{ |
|
8777
|
|
|
$href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->base)); |
|
8778
|
|
|
} |
|
8779
|
|
|
else |
|
8780
|
|
|
{ |
|
8781
|
|
|
$href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->http_base)); |
|
8782
|
|
|
} |
|
8783
|
|
|
if ($href === false) |
|
8784
|
|
|
{ |
|
8785
|
|
|
continue; |
|
8786
|
|
|
} |
|
8787
|
|
|
if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !in_array('stylesheet', $rel) && $link->hasAttribute('type') && in_array(strtolower($this->registry->call('Misc', 'parse_mime', array($link->getAttribute('type')))), array('application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href])) |
|
8788
|
|
|
{ |
|
8789
|
|
|
$this->checked_feeds++; |
|
8790
|
|
|
$headers = array( |
|
8791
|
|
|
'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', |
|
8792
|
|
|
); |
|
8793
|
|
|
$feed = $this->registry->create('File', array($href, $this->timeout, 5, $headers, $this->useragent)); |
|
8794
|
|
|
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)) |
|
8795
|
|
|
{ |
|
8796
|
|
|
$feeds[$href] = $feed; |
|
8797
|
|
|
} |
|
8798
|
|
|
} |
|
8799
|
|
|
$done[] = $href; |
|
8800
|
|
|
} |
|
8801
|
|
|
} |
|
8802
|
|
|
return $feeds; |
|
8803
|
|
|
} |
|
8804
|
|
|
public function get_links() |
|
8805
|
|
|
{ |
|
8806
|
|
|
if ($this->dom === null) |
|
8807
|
|
|
{ |
|
8808
|
|
|
throw new SimplePie_Exception('DOMDocument not found, unable to use locator'); |
|
8809
|
|
|
} |
|
8810
|
|
|
$links = $this->dom->getElementsByTagName('a'); |
|
8811
|
|
|
foreach ($links as $link) |
|
8812
|
|
|
{ |
|
8813
|
|
|
if ($link->hasAttribute('href')) |
|
8814
|
|
|
{ |
|
8815
|
|
|
$href = trim($link->getAttribute('href')); |
|
8816
|
|
|
$parsed = $this->registry->call('Misc', 'parse_url', array($href)); |
|
8817
|
|
|
if ($parsed['scheme'] === '' || preg_match('/^(http(s)|feed)?$/i', $parsed['scheme'])) |
|
8818
|
|
|
{ |
|
8819
|
|
|
if ($this->base_location < $link->getLineNo()) |
|
8820
|
|
|
{ |
|
8821
|
|
|
$href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->base)); |
|
8822
|
|
|
} |
|
8823
|
|
|
else |
|
8824
|
|
|
{ |
|
8825
|
|
|
$href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->http_base)); |
|
8826
|
|
|
} |
|
8827
|
|
|
if ($href === false) |
|
8828
|
|
|
{ |
|
8829
|
|
|
continue; |
|
8830
|
|
|
} |
|
8831
|
|
|
$current = $this->registry->call('Misc', 'parse_url', array($this->file->url)); |
|
8832
|
|
|
if ($parsed['authority'] === '' || $parsed['authority'] === $current['authority']) |
|
8833
|
|
|
{ |
|
8834
|
|
|
$this->local[] = $href; |
|
8835
|
|
|
} |
|
8836
|
|
|
else |
|
8837
|
|
|
{ |
|
8838
|
|
|
$this->elsewhere[] = $href; |
|
8839
|
|
|
} |
|
8840
|
|
|
} |
|
8841
|
|
|
} |
|
8842
|
|
|
} |
|
8843
|
|
|
$this->local = array_unique($this->local); |
|
8844
|
|
|
$this->elsewhere = array_unique($this->elsewhere); |
|
8845
|
|
|
if (!empty($this->local) || !empty($this->elsewhere)) |
|
8846
|
|
|
{ |
|
8847
|
|
|
return true; |
|
8848
|
|
|
} |
|
8849
|
|
|
return null; |
|
8850
|
|
|
} |
|
8851
|
|
|
public function extension(&$array) |
|
8852
|
|
|
{ |
|
8853
|
|
|
foreach ($array as $key => $value) |
|
8854
|
|
|
{ |
|
8855
|
|
|
if ($this->checked_feeds === $this->max_checked_feeds) |
|
8856
|
|
|
{ |
|
8857
|
|
|
break; |
|
8858
|
|
|
} |
|
8859
|
|
|
if (in_array(strtolower(strrchr($value, '.')), array('.rss', '.rdf', '.atom', '.xml'))) |
|
8860
|
|
|
{ |
|
8861
|
|
|
$this->checked_feeds++; |
|
8862
|
|
|
$headers = array( |
|
8863
|
|
|
'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', |
|
8864
|
|
|
); |
|
8865
|
|
|
$feed = $this->registry->create('File', array($value, $this->timeout, 5, $headers, $this->useragent)); |
|
8866
|
|
|
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)) |
|
8867
|
|
|
{ |
|
8868
|
|
|
return $feed; |
|
8869
|
|
|
} |
|
8870
|
|
|
else |
|
8871
|
|
|
{ |
|
8872
|
|
|
unset($array[$key]); |
|
8873
|
|
|
} |
|
8874
|
|
|
} |
|
8875
|
|
|
} |
|
8876
|
|
|
return null; |
|
8877
|
|
|
} |
|
8878
|
|
|
public function body(&$array) |
|
8879
|
|
|
{ |
|
8880
|
|
|
foreach ($array as $key => $value) |
|
8881
|
|
|
{ |
|
8882
|
|
|
if ($this->checked_feeds === $this->max_checked_feeds) |
|
8883
|
|
|
{ |
|
8884
|
|
|
break; |
|
8885
|
|
|
} |
|
8886
|
|
|
if (preg_match('/(rss|rdf|atom|xml)/i', $value)) |
|
8887
|
|
|
{ |
|
8888
|
|
|
$this->checked_feeds++; |
|
8889
|
|
|
$headers = array( |
|
8890
|
|
|
'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', |
|
8891
|
|
|
); |
|
8892
|
|
|
$feed = $this->registry->create('File', array($value, $this->timeout, 5, null, $this->useragent)); |
|
8893
|
|
|
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)) |
|
8894
|
|
|
{ |
|
8895
|
|
|
return $feed; |
|
8896
|
|
|
} |
|
8897
|
|
|
else |
|
8898
|
|
|
{ |
|
8899
|
|
|
unset($array[$key]); |
|
8900
|
|
|
} |
|
8901
|
|
|
} |
|
8902
|
|
|
} |
|
8903
|
|
|
return null; |
|
8904
|
|
|
} |
|
8905
|
|
|
} |
|
8906
|
|
|
class SimplePie_Misc |
|
8907
|
|
|
{ |
|
8908
|
|
|
public static function time_hms($seconds) |
|
8909
|
|
|
{ |
|
8910
|
|
|
$time = ''; |
|
8911
|
|
|
$hours = floor($seconds / 3600); |
|
8912
|
|
|
$remainder = $seconds % 3600; |
|
8913
|
|
|
if ($hours > 0) |
|
8914
|
|
|
{ |
|
8915
|
|
|
$time .= $hours.':'; |
|
8916
|
|
|
} |
|
8917
|
|
|
$minutes = floor($remainder / 60); |
|
8918
|
|
|
$seconds = $remainder % 60; |
|
8919
|
|
|
if ($minutes < 10 && $hours > 0) |
|
8920
|
|
|
{ |
|
8921
|
|
|
$minutes = '0' . $minutes; |
|
8922
|
|
|
} |
|
8923
|
|
|
if ($seconds < 10) |
|
8924
|
|
|
{ |
|
8925
|
|
|
$seconds = '0' . $seconds; |
|
8926
|
|
|
} |
|
8927
|
|
|
$time .= $minutes.':'; |
|
8928
|
|
|
$time .= $seconds; |
|
8929
|
|
|
return $time; |
|
8930
|
|
|
} |
|
8931
|
|
|
public static function absolutize_url($relative, $base) |
|
8932
|
|
|
{ |
|
8933
|
|
|
$iri = SimplePie_IRI::absolutize(new SimplePie_IRI($base), $relative); |
|
8934
|
|
|
if ($iri === false) |
|
8935
|
|
|
{ |
|
8936
|
|
|
return false; |
|
8937
|
|
|
} |
|
8938
|
|
|
return $iri->get_uri(); |
|
8939
|
|
|
} |
|
8940
|
|
|
|
|
8941
|
|
|
public static function get_element($realname, $string) |
|
8942
|
|
|
{ |
|
8943
|
|
|
$return = array(); |
|
8944
|
|
|
$name = preg_quote($realname, '/'); |
|
8945
|
|
|
if (preg_match_all("/<($name)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) |
|
8946
|
|
|
{ |
|
8947
|
|
|
for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++) |
|
8948
|
|
|
{ |
|
8949
|
|
|
$return[$i]['tag'] = $realname; |
|
8950
|
|
|
$return[$i]['full'] = $matches[$i][0][0]; |
|
8951
|
|
|
$return[$i]['offset'] = $matches[$i][0][1]; |
|
8952
|
|
|
if (strlen($matches[$i][3][0]) <= 2) |
|
8953
|
|
|
{ |
|
8954
|
|
|
$return[$i]['self_closing'] = true; |
|
8955
|
|
|
} |
|
8956
|
|
|
else |
|
8957
|
|
|
{ |
|
8958
|
|
|
$return[$i]['self_closing'] = false; |
|
8959
|
|
|
$return[$i]['content'] = $matches[$i][4][0]; |
|
8960
|
|
|
} |
|
8961
|
|
|
$return[$i]['attribs'] = array(); |
|
8962
|
|
|
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)) |
|
8963
|
|
|
{ |
|
8964
|
|
|
for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++) |
|
8965
|
|
|
{ |
|
8966
|
|
|
if (count($attribs[$j]) === 2) |
|
8967
|
|
|
{ |
|
8968
|
|
|
$attribs[$j][2] = $attribs[$j][1]; |
|
8969
|
|
|
} |
|
8970
|
|
|
$return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = SimplePie_Misc::entities_decode(end($attribs[$j]), 'UTF-8'); |
|
8971
|
|
|
} |
|
8972
|
|
|
} |
|
8973
|
|
|
} |
|
8974
|
|
|
} |
|
8975
|
|
|
return $return; |
|
8976
|
|
|
} |
|
8977
|
|
|
public static function element_implode($element) |
|
8978
|
|
|
{ |
|
8979
|
|
|
$full = "<$element[tag]"; |
|
8980
|
|
|
foreach ($element['attribs'] as $key => $value) |
|
8981
|
|
|
{ |
|
8982
|
|
|
$key = strtolower($key); |
|
8983
|
|
|
$full .= " $key=\"" . htmlspecialchars($value['data']) . '"'; |
|
8984
|
|
|
} |
|
8985
|
|
|
if ($element['self_closing']) |
|
8986
|
|
|
{ |
|
8987
|
|
|
$full .= ' />'; |
|
8988
|
|
|
} |
|
8989
|
|
|
else |
|
8990
|
|
|
{ |
|
8991
|
|
|
$full .= ">$element[content]</$element[tag]>"; |
|
8992
|
|
|
} |
|
8993
|
|
|
return $full; |
|
8994
|
|
|
} |
|
8995
|
|
|
public static function error($message, $level, $file, $line) |
|
8996
|
|
|
{ |
|
8997
|
|
|
if ((ini_get('error_reporting') & $level) > 0) |
|
8998
|
|
|
{ |
|
8999
|
|
|
switch ($level) |
|
9000
|
|
|
{ |
|
9001
|
|
|
case E_USER_ERROR: |
|
9002
|
|
|
$note = 'PHP Error'; |
|
9003
|
|
|
break; |
|
9004
|
|
|
case E_USER_WARNING: |
|
9005
|
|
|
$note = 'PHP Warning'; |
|
9006
|
|
|
break; |
|
9007
|
|
|
case E_USER_NOTICE: |
|
9008
|
|
|
$note = 'PHP Notice'; |
|
9009
|
|
|
break; |
|
9010
|
|
|
default: |
|
9011
|
|
|
$note = 'Unknown Error'; |
|
9012
|
|
|
break; |
|
9013
|
|
|
} |
|
9014
|
|
|
$log_error = true; |
|
9015
|
|
|
if (!function_exists('error_log')) |
|
9016
|
|
|
{ |
|
9017
|
|
|
$log_error = false; |
|
9018
|
|
|
} |
|
9019
|
|
|
$log_file = @ini_get('error_log'); |
|
9020
|
|
|
if (!empty($log_file) && ('syslog' !== $log_file) && !@is_writable($log_file)) |
|
9021
|
|
|
{ |
|
9022
|
|
|
$log_error = false; |
|
9023
|
|
|
} |
|
9024
|
|
|
if ($log_error) |
|
9025
|
|
|
{ |
|
9026
|
|
|
@error_log("$note: $message in $file on line $line", 0); |
|
9027
|
|
|
} |
|
9028
|
|
|
} |
|
9029
|
|
|
return $message; |
|
9030
|
|
|
} |
|
9031
|
|
|
public static function fix_protocol($url, $http = 1) |
|
9032
|
|
|
{ |
|
9033
|
|
|
$url = SimplePie_Misc::normalize_url($url); |
|
9034
|
|
|
$parsed = SimplePie_Misc::parse_url($url); |
|
9035
|
|
|
if ($parsed['scheme'] !== '' && $parsed['scheme'] !== 'http' && $parsed['scheme'] !== 'https') |
|
9036
|
|
|
{ |
|
9037
|
|
|
return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http); |
|
9038
|
|
|
} |
|
9039
|
|
|
if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url)) |
|
9040
|
|
|
{ |
|
9041
|
|
|
return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http); |
|
9042
|
|
|
} |
|
9043
|
|
|
if ($http === 2 && $parsed['scheme'] !== '') |
|
9044
|
|
|
{ |
|
9045
|
|
|
return "feed:$url"; |
|
9046
|
|
|
} |
|
9047
|
|
|
elseif ($http === 3 && strtolower($parsed['scheme']) === 'http') |
|
9048
|
|
|
{ |
|
9049
|
|
|
return substr_replace($url, 'podcast', 0, 4); |
|
9050
|
|
|
} |
|
9051
|
|
|
elseif ($http === 4 && strtolower($parsed['scheme']) === 'http') |
|
9052
|
|
|
{ |
|
9053
|
|
|
return substr_replace($url, 'itpc', 0, 4); |
|
9054
|
|
|
} |
|
9055
|
|
|
else |
|
9056
|
|
|
{ |
|
9057
|
|
|
return $url; |
|
9058
|
|
|
} |
|
9059
|
|
|
} |
|
9060
|
|
|
public static function parse_url($url) |
|
9061
|
|
|
{ |
|
9062
|
|
|
$iri = new SimplePie_IRI($url); |
|
9063
|
|
|
return array( |
|
9064
|
|
|
'scheme' => (string) $iri->scheme, |
|
9065
|
|
|
'authority' => (string) $iri->authority, |
|
9066
|
|
|
'path' => (string) $iri->path, |
|
9067
|
|
|
'query' => (string) $iri->query, |
|
9068
|
|
|
'fragment' => (string) $iri->fragment |
|
9069
|
|
|
); |
|
9070
|
|
|
} |
|
9071
|
|
|
public static function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '') |
|
9072
|
|
|
{ |
|
9073
|
|
|
$iri = new SimplePie_IRI(''); |
|
9074
|
|
|
$iri->scheme = $scheme; |
|
9075
|
|
|
$iri->authority = $authority; |
|
9076
|
|
|
$iri->path = $path; |
|
9077
|
|
|
$iri->query = $query; |
|
9078
|
|
|
$iri->fragment = $fragment; |
|
9079
|
|
|
return $iri->get_uri(); |
|
9080
|
|
|
} |
|
9081
|
|
|
public static function normalize_url($url) |
|
9082
|
|
|
{ |
|
9083
|
|
|
$iri = new SimplePie_IRI($url); |
|
9084
|
|
|
return $iri->get_uri(); |
|
9085
|
|
|
} |
|
9086
|
|
|
public static function percent_encoding_normalization($match) |
|
9087
|
|
|
{ |
|
9088
|
|
|
$integer = hexdec($match[1]); |
|
9089
|
|
|
if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E) |
|
9090
|
|
|
{ |
|
9091
|
|
|
return chr($integer); |
|
9092
|
|
|
} |
|
9093
|
|
|
else |
|
9094
|
|
|
{ |
|
9095
|
|
|
return strtoupper($match[0]); |
|
9096
|
|
|
} |
|
9097
|
|
|
} |
|
9098
|
|
|
|
|
9099
|
|
|
public static function windows_1252_to_utf8($string) |
|
9100
|
|
|
{ |
|
9101
|
|
|
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"); |
|
9102
|
|
|
return strtr($string, $convert_table); |
|
9103
|
|
|
} |
|
9104
|
|
|
|
|
9105
|
|
|
public static function change_encoding($data, $input, $output) |
|
9106
|
|
|
{ |
|
9107
|
|
|
$input = SimplePie_Misc::encoding($input); |
|
9108
|
|
|
$output = SimplePie_Misc::encoding($output); |
|
9109
|
|
|
// We fail to fail on non US-ASCII bytes |
|
9110
|
|
|
if ($input === 'US-ASCII') |
|
9111
|
|
|
{ |
|
9112
|
|
|
static $non_ascii_octects = ''; |
|
9113
|
|
|
if (!$non_ascii_octects) |
|
9114
|
|
|
{ |
|
9115
|
|
|
for ($i = 0x80; $i <= 0xFF; $i++) |
|
9116
|
|
|
{ |
|
9117
|
|
|
$non_ascii_octects .= chr($i); |
|
9118
|
|
|
} |
|
9119
|
|
|
} |
|
9120
|
|
|
$data = substr($data, 0, strcspn($data, $non_ascii_octects)); |
|
9121
|
|
|
} |
|
9122
|
|
|
// This is first, as behaviour of this is completely predictable |
|
9123
|
|
|
if ($input === 'windows-1252' && $output === 'UTF-8') |
|
9124
|
|
|
{ |
|
9125
|
|
|
return SimplePie_Misc::windows_1252_to_utf8($data); |
|
9126
|
|
|
} |
|
9127
|
|
|
// This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported). |
|
9128
|
|
|
elseif (function_exists('mb_convert_encoding') && ($return = SimplePie_Misc::change_encoding_mbstring($data, $input, $output))) |
|
9129
|
|
|
{ |
|
9130
|
|
|
return $return; |
|
9131
|
|
|
} |
|
9132
|
|
|
// This is last, as behaviour of this varies with OS userland and PHP version |
|
9133
|
|
|
elseif (function_exists('iconv') && ($return = SimplePie_Misc::change_encoding_iconv($data, $input, $output))) |
|
9134
|
|
|
{ |
|
9135
|
|
|
return $return; |
|
9136
|
|
|
} |
|
9137
|
|
|
// If we can't do anything, just fail |
|
9138
|
|
|
else |
|
9139
|
|
|
{ |
|
9140
|
|
|
return false; |
|
9141
|
|
|
} |
|
9142
|
|
|
} |
|
9143
|
|
|
protected static function change_encoding_mbstring($data, $input, $output) |
|
9144
|
|
|
{ |
|
9145
|
|
|
if ($input === 'windows-949') |
|
9146
|
|
|
{ |
|
9147
|
|
|
$input = 'EUC-KR'; |
|
9148
|
|
|
} |
|
9149
|
|
|
if ($output === 'windows-949') |
|
9150
|
|
|
{ |
|
9151
|
|
|
$output = 'EUC-KR'; |
|
9152
|
|
|
} |
|
9153
|
|
|
if ($input === 'Windows-31J') |
|
9154
|
|
|
{ |
|
9155
|
|
|
$input = 'SJIS'; |
|
9156
|
|
|
} |
|
9157
|
|
|
if ($output === 'Windows-31J') |
|
9158
|
|
|
{ |
|
9159
|
|
|
$output = 'SJIS'; |
|
9160
|
|
|
} |
|
9161
|
|
|
// Check that the encoding is supported |
|
9162
|
|
|
if (@mb_convert_encoding("\x80", 'UTF-16BE', $input) === "\x00\x80") |
|
9163
|
|
|
{ |
|
9164
|
|
|
return false; |
|
9165
|
|
|
} |
|
9166
|
|
|
if (!in_array($input, mb_list_encodings())) |
|
9167
|
|
|
{ |
|
9168
|
|
|
return false; |
|
9169
|
|
|
} |
|
9170
|
|
|
// Let's do some conversion |
|
9171
|
|
|
if ($return = @mb_convert_encoding($data, $output, $input)) |
|
9172
|
|
|
{ |
|
9173
|
|
|
return $return; |
|
9174
|
|
|
} |
|
9175
|
|
|
return false; |
|
9176
|
|
|
} |
|
9177
|
|
|
protected static function change_encoding_iconv($data, $input, $output) |
|
9178
|
|
|
{ |
|
9179
|
|
|
return @iconv($input, $output, $data); |
|
9180
|
|
|
} |
|
9181
|
|
|
|
|
9182
|
|
|
public static function encoding($charset) |
|
9183
|
|
|
{ |
|
9184
|
|
|
// Normalization from UTS #22 |
|
9185
|
|
|
switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset))) |
|
9186
|
|
|
{ |
|
9187
|
|
|
case 'adobestandardencoding': |
|
9188
|
|
|
case 'csadobestandardencoding': |
|
9189
|
|
|
return 'Adobe-Standard-Encoding'; |
|
9190
|
|
|
case 'adobesymbolencoding': |
|
9191
|
|
|
case 'cshppsmath': |
|
9192
|
|
|
return 'Adobe-Symbol-Encoding'; |
|
9193
|
|
|
case 'ami1251': |
|
9194
|
|
|
case 'amiga1251': |
|
9195
|
|
|
return 'Amiga-1251'; |
|
9196
|
|
|
case 'ansix31101983': |
|
9197
|
|
|
case 'csat5001983': |
|
9198
|
|
|
case 'csiso99naplps': |
|
9199
|
|
|
case 'isoir99': |
|
9200
|
|
|
case 'naplps': |
|
9201
|
|
|
return 'ANSI_X3.110-1983'; |
|
9202
|
|
|
case 'arabic7': |
|
9203
|
|
|
case 'asmo449': |
|
9204
|
|
|
case 'csiso89asmo449': |
|
9205
|
|
|
case 'iso9036': |
|
9206
|
|
|
case 'isoir89': |
|
9207
|
|
|
return 'ASMO_449'; |
|
9208
|
|
|
case 'big5': |
|
9209
|
|
|
case 'csbig5': |
|
9210
|
|
|
return 'Big5'; |
|
9211
|
|
|
case 'big5hkscs': |
|
9212
|
|
|
return 'Big5-HKSCS'; |
|
9213
|
|
|
case 'bocu1': |
|
9214
|
|
|
case 'csbocu1': |
|
9215
|
|
|
return 'BOCU-1'; |
|
9216
|
|
|
case 'brf': |
|
9217
|
|
|
case 'csbrf': |
|
9218
|
|
|
return 'BRF'; |
|
9219
|
|
|
case 'bs4730': |
|
9220
|
|
|
case 'csiso4unitedkingdom': |
|
9221
|
|
|
case 'gb': |
|
9222
|
|
|
case 'iso646gb': |
|
9223
|
|
|
case 'isoir4': |
|
9224
|
|
|
case 'uk': |
|
9225
|
|
|
return 'BS_4730'; |
|
9226
|
|
|
case 'bsviewdata': |
|
9227
|
|
|
case 'csiso47bsviewdata': |
|
9228
|
|
|
case 'isoir47': |
|
9229
|
|
|
return 'BS_viewdata'; |
|
9230
|
|
|
case 'cesu8': |
|
9231
|
|
|
case 'cscesu8': |
|
9232
|
|
|
return 'CESU-8'; |
|
9233
|
|
|
case 'ca': |
|
9234
|
|
|
case 'csa71': |
|
9235
|
|
|
case 'csaz243419851': |
|
9236
|
|
|
case 'csiso121canadian1': |
|
9237
|
|
|
case 'iso646ca': |
|
9238
|
|
|
case 'isoir121': |
|
9239
|
|
|
return 'CSA_Z243.4-1985-1'; |
|
9240
|
|
|
case 'csa72': |
|
9241
|
|
|
case 'csaz243419852': |
|
9242
|
|
|
case 'csiso122canadian2': |
|
9243
|
|
|
case 'iso646ca2': |
|
9244
|
|
|
case 'isoir122': |
|
9245
|
|
|
return 'CSA_Z243.4-1985-2'; |
|
9246
|
|
|
case 'csaz24341985gr': |
|
9247
|
|
|
case 'csiso123csaz24341985gr': |
|
9248
|
|
|
case 'isoir123': |
|
9249
|
|
|
return 'CSA_Z243.4-1985-gr'; |
|
9250
|
|
|
case 'csiso139csn369103': |
|
9251
|
|
|
case 'csn369103': |
|
9252
|
|
|
case 'isoir139': |
|
9253
|
|
|
return 'CSN_369103'; |
|
9254
|
|
|
case 'csdecmcs': |
|
9255
|
|
|
case 'dec': |
|
9256
|
|
|
case 'decmcs': |
|
9257
|
|
|
return 'DEC-MCS'; |
|
9258
|
|
|
case 'csiso21german': |
|
9259
|
|
|
case 'de': |
|
9260
|
|
|
case 'din66003': |
|
9261
|
|
|
case 'iso646de': |
|
9262
|
|
|
case 'isoir21': |
|
9263
|
|
|
return 'DIN_66003'; |
|
9264
|
|
|
case 'csdkus': |
|
9265
|
|
|
case 'dkus': |
|
9266
|
|
|
return 'dk-us'; |
|
9267
|
|
|
case 'csiso646danish': |
|
9268
|
|
|
case 'dk': |
|
9269
|
|
|
case 'ds2089': |
|
9270
|
|
|
case 'iso646dk': |
|
9271
|
|
|
return 'DS_2089'; |
|
9272
|
|
|
case 'csibmebcdicatde': |
|
9273
|
|
|
case 'ebcdicatde': |
|
9274
|
|
|
return 'EBCDIC-AT-DE'; |
|
9275
|
|
|
case 'csebcdicatdea': |
|
9276
|
|
|
case 'ebcdicatdea': |
|
9277
|
|
|
return 'EBCDIC-AT-DE-A'; |
|
9278
|
|
|
case 'csebcdiccafr': |
|
9279
|
|
|
case 'ebcdiccafr': |
|
9280
|
|
|
return 'EBCDIC-CA-FR'; |
|
9281
|
|
|
case 'csebcdicdkno': |
|
9282
|
|
|
case 'ebcdicdkno': |
|
9283
|
|
|
return 'EBCDIC-DK-NO'; |
|
9284
|
|
|
case 'csebcdicdknoa': |
|
9285
|
|
|
case 'ebcdicdknoa': |
|
9286
|
|
|
return 'EBCDIC-DK-NO-A'; |
|
9287
|
|
|
case 'csebcdices': |
|
9288
|
|
|
case 'ebcdices': |
|
9289
|
|
|
return 'EBCDIC-ES'; |
|
9290
|
|
|
case 'csebcdicesa': |
|
9291
|
|
|
case 'ebcdicesa': |
|
9292
|
|
|
return 'EBCDIC-ES-A'; |
|
9293
|
|
|
case 'csebcdicess': |
|
9294
|
|
|
case 'ebcdicess': |
|
9295
|
|
|
return 'EBCDIC-ES-S'; |
|
9296
|
|
|
case 'csebcdicfise': |
|
9297
|
|
|
case 'ebcdicfise': |
|
9298
|
|
|
return 'EBCDIC-FI-SE'; |
|
9299
|
|
|
case 'csebcdicfisea': |
|
9300
|
|
|
case 'ebcdicfisea': |
|
9301
|
|
|
return 'EBCDIC-FI-SE-A'; |
|
9302
|
|
|
case 'csebcdicfr': |
|
9303
|
|
|
case 'ebcdicfr': |
|
9304
|
|
|
return 'EBCDIC-FR'; |
|
9305
|
|
|
case 'csebcdicit': |
|
9306
|
|
|
case 'ebcdicit': |
|
9307
|
|
|
return 'EBCDIC-IT'; |
|
9308
|
|
|
case 'csebcdicpt': |
|
9309
|
|
|
case 'ebcdicpt': |
|
9310
|
|
|
return 'EBCDIC-PT'; |
|
9311
|
|
|
case 'csebcdicuk': |
|
9312
|
|
|
case 'ebcdicuk': |
|
9313
|
|
|
return 'EBCDIC-UK'; |
|
9314
|
|
|
case 'csebcdicus': |
|
9315
|
|
|
case 'ebcdicus': |
|
9316
|
|
|
return 'EBCDIC-US'; |
|
9317
|
|
|
case 'csiso111ecmacyrillic': |
|
9318
|
|
|
case 'ecmacyrillic': |
|
9319
|
|
|
case 'isoir111': |
|
9320
|
|
|
case 'koi8e': |
|
9321
|
|
|
return 'ECMA-cyrillic'; |
|
9322
|
|
|
case 'csiso17spanish': |
|
9323
|
|
|
case 'es': |
|
9324
|
|
|
case 'iso646es': |
|
9325
|
|
|
case 'isoir17': |
|
9326
|
|
|
return 'ES'; |
|
9327
|
|
|
case 'csiso85spanish2': |
|
9328
|
|
|
case 'es2': |
|
9329
|
|
|
case 'iso646es2': |
|
9330
|
|
|
case 'isoir85': |
|
9331
|
|
|
return 'ES2'; |
|
9332
|
|
|
case 'cseucpkdfmtjapanese': |
|
9333
|
|
|
case 'eucjp': |
|
9334
|
|
|
case 'extendedunixcodepackedformatforjapanese': |
|
9335
|
|
|
return 'EUC-JP'; |
|
9336
|
|
|
case 'cseucfixwidjapanese': |
|
9337
|
|
|
case 'extendedunixcodefixedwidthforjapanese': |
|
9338
|
|
|
return 'Extended_UNIX_Code_Fixed_Width_for_Japanese'; |
|
9339
|
|
|
case 'gb18030': |
|
9340
|
|
|
return 'GB18030'; |
|
9341
|
|
|
case 'chinese': |
|
9342
|
|
|
case 'cp936': |
|
9343
|
|
|
case 'csgb2312': |
|
9344
|
|
|
case 'csiso58gb231280': |
|
9345
|
|
|
case 'gb2312': |
|
9346
|
|
|
case 'gb231280': |
|
9347
|
|
|
case 'gbk': |
|
9348
|
|
|
case 'isoir58': |
|
9349
|
|
|
case 'ms936': |
|
9350
|
|
|
case 'windows936': |
|
9351
|
|
|
return 'GBK'; |
|
9352
|
|
|
case 'cn': |
|
9353
|
|
|
case 'csiso57gb1988': |
|
9354
|
|
|
case 'gb198880': |
|
9355
|
|
|
case 'iso646cn': |
|
9356
|
|
|
case 'isoir57': |
|
9357
|
|
|
return 'GB_1988-80'; |
|
9358
|
|
|
case 'csiso153gost1976874': |
|
9359
|
|
|
case 'gost1976874': |
|
9360
|
|
|
case 'isoir153': |
|
9361
|
|
|
case 'stsev35888': |
|
9362
|
|
|
return 'GOST_19768-74'; |
|
9363
|
|
|
case 'csiso150': |
|
9364
|
|
|
case 'csiso150greekccitt': |
|
9365
|
|
|
case 'greekccitt': |
|
9366
|
|
|
case 'isoir150': |
|
9367
|
|
|
return 'greek-ccitt'; |
|
9368
|
|
|
case 'csiso88greek7': |
|
9369
|
|
|
case 'greek7': |
|
9370
|
|
|
case 'isoir88': |
|
9371
|
|
|
return 'greek7'; |
|
9372
|
|
|
case 'csiso18greek7old': |
|
9373
|
|
|
case 'greek7old': |
|
9374
|
|
|
case 'isoir18': |
|
9375
|
|
|
return 'greek7-old'; |
|
9376
|
|
|
case 'cshpdesktop': |
|
9377
|
|
|
case 'hpdesktop': |
|
9378
|
|
|
return 'HP-DeskTop'; |
|
9379
|
|
|
case 'cshplegal': |
|
9380
|
|
|
case 'hplegal': |
|
9381
|
|
|
return 'HP-Legal'; |
|
9382
|
|
|
case 'cshpmath8': |
|
9383
|
|
|
case 'hpmath8': |
|
9384
|
|
|
return 'HP-Math8'; |
|
9385
|
|
|
case 'cshppifont': |
|
9386
|
|
|
case 'hppifont': |
|
9387
|
|
|
return 'HP-Pi-font'; |
|
9388
|
|
|
case 'cshproman8': |
|
9389
|
|
|
case 'hproman8': |
|
9390
|
|
|
case 'r8': |
|
9391
|
|
|
case 'roman8': |
|
9392
|
|
|
return 'hp-roman8'; |
|
9393
|
|
|
case 'hzgb2312': |
|
9394
|
|
|
return 'HZ-GB-2312'; |
|
9395
|
|
|
case 'csibmsymbols': |
|
9396
|
|
|
case 'ibmsymbols': |
|
9397
|
|
|
return 'IBM-Symbols'; |
|
9398
|
|
|
case 'csibmthai': |
|
9399
|
|
|
case 'ibmthai': |
|
9400
|
|
|
return 'IBM-Thai'; |
|
9401
|
|
|
case 'cp37': |
|
9402
|
|
|
case 'csibm37': |
|
9403
|
|
|
case 'ebcdiccpca': |
|
9404
|
|
|
case 'ebcdiccpnl': |
|
9405
|
|
|
case 'ebcdiccpus': |
|
9406
|
|
|
case 'ebcdiccpwt': |
|
9407
|
|
|
case 'ibm37': |
|
9408
|
|
|
return 'IBM037'; |
|
9409
|
|
|
case 'cp38': |
|
9410
|
|
|
case 'csibm38': |
|
9411
|
|
|
case 'ebcdicint': |
|
9412
|
|
|
case 'ibm38': |
|
9413
|
|
|
return 'IBM038'; |
|
9414
|
|
|
case 'cp273': |
|
9415
|
|
|
case 'csibm273': |
|
9416
|
|
|
case 'ibm273': |
|
9417
|
|
|
return 'IBM273'; |
|
9418
|
|
|
case 'cp274': |
|
9419
|
|
|
case 'csibm274': |
|
9420
|
|
|
case 'ebcdicbe': |
|
9421
|
|
|
case 'ibm274': |
|
9422
|
|
|
return 'IBM274'; |
|
9423
|
|
|
case 'cp275': |
|
9424
|
|
|
case 'csibm275': |
|
9425
|
|
|
case 'ebcdicbr': |
|
9426
|
|
|
case 'ibm275': |
|
9427
|
|
|
return 'IBM275'; |
|
9428
|
|
|
case 'csibm277': |
|
9429
|
|
|
case 'ebcdiccpdk': |
|
9430
|
|
|
case 'ebcdiccpno': |
|
9431
|
|
|
case 'ibm277': |
|
9432
|
|
|
return 'IBM277'; |
|
9433
|
|
|
case 'cp278': |
|
9434
|
|
|
case 'csibm278': |
|
9435
|
|
|
case 'ebcdiccpfi': |
|
9436
|
|
|
case 'ebcdiccpse': |
|
9437
|
|
|
case 'ibm278': |
|
9438
|
|
|
return 'IBM278'; |
|
9439
|
|
|
case 'cp280': |
|
9440
|
|
|
case 'csibm280': |
|
9441
|
|
|
case 'ebcdiccpit': |
|
9442
|
|
|
case 'ibm280': |
|
9443
|
|
|
return 'IBM280'; |
|
9444
|
|
|
case 'cp281': |
|
9445
|
|
|
case 'csibm281': |
|
9446
|
|
|
case 'ebcdicjpe': |
|
9447
|
|
|
case 'ibm281': |
|
9448
|
|
|
return 'IBM281'; |
|
9449
|
|
|
case 'cp284': |
|
9450
|
|
|
case 'csibm284': |
|
9451
|
|
|
case 'ebcdiccpes': |
|
9452
|
|
|
case 'ibm284': |
|
9453
|
|
|
return 'IBM284'; |
|
9454
|
|
|
case 'cp285': |
|
9455
|
|
|
case 'csibm285': |
|
9456
|
|
|
case 'ebcdiccpgb': |
|
9457
|
|
|
case 'ibm285': |
|
9458
|
|
|
return 'IBM285'; |
|
9459
|
|
|
case 'cp290': |
|
9460
|
|
|
case 'csibm290': |
|
9461
|
|
|
case 'ebcdicjpkana': |
|
9462
|
|
|
case 'ibm290': |
|
9463
|
|
|
return 'IBM290'; |
|
9464
|
|
|
case 'cp297': |
|
9465
|
|
|
case 'csibm297': |
|
9466
|
|
|
case 'ebcdiccpfr': |
|
9467
|
|
|
case 'ibm297': |
|
9468
|
|
|
return 'IBM297'; |
|
9469
|
|
|
case 'cp420': |
|
9470
|
|
|
case 'csibm420': |
|
9471
|
|
|
case 'ebcdiccpar1': |
|
9472
|
|
|
case 'ibm420': |
|
9473
|
|
|
return 'IBM420'; |
|
9474
|
|
|
case 'cp423': |
|
9475
|
|
|
case 'csibm423': |
|
9476
|
|
|
case 'ebcdiccpgr': |
|
9477
|
|
|
case 'ibm423': |
|
9478
|
|
|
return 'IBM423'; |
|
9479
|
|
|
case 'cp424': |
|
9480
|
|
|
case 'csibm424': |
|
9481
|
|
|
case 'ebcdiccphe': |
|
9482
|
|
|
case 'ibm424': |
|
9483
|
|
|
return 'IBM424'; |
|
9484
|
|
|
case '437': |
|
9485
|
|
|
case 'cp437': |
|
9486
|
|
|
case 'cspc8codepage437': |
|
9487
|
|
|
case 'ibm437': |
|
9488
|
|
|
return 'IBM437'; |
|
9489
|
|
|
case 'cp500': |
|
9490
|
|
|
case 'csibm500': |
|
9491
|
|
|
case 'ebcdiccpbe': |
|
9492
|
|
|
case 'ebcdiccpch': |
|
9493
|
|
|
case 'ibm500': |
|
9494
|
|
|
return 'IBM500'; |
|
9495
|
|
|
case 'cp775': |
|
9496
|
|
|
case 'cspc775baltic': |
|
9497
|
|
|
case 'ibm775': |
|
9498
|
|
|
return 'IBM775'; |
|
9499
|
|
|
case '850': |
|
9500
|
|
|
case 'cp850': |
|
9501
|
|
|
case 'cspc850multilingual': |
|
9502
|
|
|
case 'ibm850': |
|
9503
|
|
|
return 'IBM850'; |
|
9504
|
|
|
case '851': |
|
9505
|
|
|
case 'cp851': |
|
9506
|
|
|
case 'csibm851': |
|
9507
|
|
|
case 'ibm851': |
|
9508
|
|
|
return 'IBM851'; |
|
9509
|
|
|
case '852': |
|
9510
|
|
|
case 'cp852': |
|
9511
|
|
|
case 'cspcp852': |
|
9512
|
|
|
case 'ibm852': |
|
9513
|
|
|
return 'IBM852'; |
|
9514
|
|
|
case '855': |
|
9515
|
|
|
case 'cp855': |
|
9516
|
|
|
case 'csibm855': |
|
9517
|
|
|
case 'ibm855': |
|
9518
|
|
|
return 'IBM855'; |
|
9519
|
|
|
case '857': |
|
9520
|
|
|
case 'cp857': |
|
9521
|
|
|
case 'csibm857': |
|
9522
|
|
|
case 'ibm857': |
|
9523
|
|
|
return 'IBM857'; |
|
9524
|
|
|
case 'ccsid858': |
|
9525
|
|
|
case 'cp858': |
|
9526
|
|
|
case 'ibm858': |
|
9527
|
|
|
case 'pcmultilingual850euro': |
|
9528
|
|
|
return 'IBM00858'; |
|
9529
|
|
|
case '860': |
|
9530
|
|
|
case 'cp860': |
|
9531
|
|
|
case 'csibm860': |
|
9532
|
|
|
case 'ibm860': |
|
9533
|
|
|
return 'IBM860'; |
|
9534
|
|
|
case '861': |
|
9535
|
|
|
case 'cp861': |
|
9536
|
|
|
case 'cpis': |
|
9537
|
|
|
case 'csibm861': |
|
9538
|
|
|
case 'ibm861': |
|
9539
|
|
|
return 'IBM861'; |
|
9540
|
|
|
case '862': |
|
9541
|
|
|
case 'cp862': |
|
9542
|
|
|
case 'cspc862latinhebrew': |
|
9543
|
|
|
case 'ibm862': |
|
9544
|
|
|
return 'IBM862'; |
|
9545
|
|
|
case '863': |
|
9546
|
|
|
case 'cp863': |
|
9547
|
|
|
case 'csibm863': |
|
9548
|
|
|
case 'ibm863': |
|
9549
|
|
|
return 'IBM863'; |
|
9550
|
|
|
case 'cp864': |
|
9551
|
|
|
case 'csibm864': |
|
9552
|
|
|
case 'ibm864': |
|
9553
|
|
|
return 'IBM864'; |
|
9554
|
|
|
case '865': |
|
9555
|
|
|
case 'cp865': |
|
9556
|
|
|
case 'csibm865': |
|
9557
|
|
|
case 'ibm865': |
|
9558
|
|
|
return 'IBM865'; |
|
9559
|
|
|
case '866': |
|
9560
|
|
|
case 'cp866': |
|
9561
|
|
|
case 'csibm866': |
|
9562
|
|
|
case 'ibm866': |
|
9563
|
|
|
return 'IBM866'; |
|
9564
|
|
|
case 'cp868': |
|
9565
|
|
|
case 'cpar': |
|
9566
|
|
|
case 'csibm868': |
|
9567
|
|
|
case 'ibm868': |
|
9568
|
|
|
return 'IBM868'; |
|
9569
|
|
|
case '869': |
|
9570
|
|
|
case 'cp869': |
|
9571
|
|
|
case 'cpgr': |
|
9572
|
|
|
case 'csibm869': |
|
9573
|
|
|
case 'ibm869': |
|
9574
|
|
|
return 'IBM869'; |
|
9575
|
|
|
case 'cp870': |
|
9576
|
|
|
case 'csibm870': |
|
9577
|
|
|
case 'ebcdiccproece': |
|
9578
|
|
|
case 'ebcdiccpyu': |
|
9579
|
|
|
case 'ibm870': |
|
9580
|
|
|
return 'IBM870'; |
|
9581
|
|
|
case 'cp871': |
|
9582
|
|
|
case 'csibm871': |
|
9583
|
|
|
case 'ebcdiccpis': |
|
9584
|
|
|
case 'ibm871': |
|
9585
|
|
|
return 'IBM871'; |
|
9586
|
|
|
case 'cp880': |
|
9587
|
|
|
case 'csibm880': |
|
9588
|
|
|
case 'ebcdiccyrillic': |
|
9589
|
|
|
case 'ibm880': |
|
9590
|
|
|
return 'IBM880'; |
|
9591
|
|
|
case 'cp891': |
|
9592
|
|
|
case 'csibm891': |
|
9593
|
|
|
case 'ibm891': |
|
9594
|
|
|
return 'IBM891'; |
|
9595
|
|
|
case 'cp903': |
|
9596
|
|
|
case 'csibm903': |
|
9597
|
|
|
case 'ibm903': |
|
9598
|
|
|
return 'IBM903'; |
|
9599
|
|
|
case '904': |
|
9600
|
|
|
case 'cp904': |
|
9601
|
|
|
case 'csibbm904': |
|
9602
|
|
|
case 'ibm904': |
|
9603
|
|
|
return 'IBM904'; |
|
9604
|
|
|
case 'cp905': |
|
9605
|
|
|
case 'csibm905': |
|
9606
|
|
|
case 'ebcdiccptr': |
|
9607
|
|
|
case 'ibm905': |
|
9608
|
|
|
return 'IBM905'; |
|
9609
|
|
|
case 'cp918': |
|
9610
|
|
|
case 'csibm918': |
|
9611
|
|
|
case 'ebcdiccpar2': |
|
9612
|
|
|
case 'ibm918': |
|
9613
|
|
|
return 'IBM918'; |
|
9614
|
|
|
case 'ccsid924': |
|
9615
|
|
|
case 'cp924': |
|
9616
|
|
|
case 'ebcdiclatin9euro': |
|
9617
|
|
|
case 'ibm924': |
|
9618
|
|
|
return 'IBM00924'; |
|
9619
|
|
|
case 'cp1026': |
|
9620
|
|
|
case 'csibm1026': |
|
9621
|
|
|
case 'ibm1026': |
|
9622
|
|
|
return 'IBM1026'; |
|
9623
|
|
|
case 'ibm1047': |
|
9624
|
|
|
return 'IBM1047'; |
|
9625
|
|
|
case 'ccsid1140': |
|
9626
|
|
|
case 'cp1140': |
|
9627
|
|
|
case 'ebcdicus37euro': |
|
9628
|
|
|
case 'ibm1140': |
|
9629
|
|
|
return 'IBM01140'; |
|
9630
|
|
|
case 'ccsid1141': |
|
9631
|
|
|
case 'cp1141': |
|
9632
|
|
|
case 'ebcdicde273euro': |
|
9633
|
|
|
case 'ibm1141': |
|
9634
|
|
|
return 'IBM01141'; |
|
9635
|
|
|
case 'ccsid1142': |
|
9636
|
|
|
case 'cp1142': |
|
9637
|
|
|
case 'ebcdicdk277euro': |
|
9638
|
|
|
case 'ebcdicno277euro': |
|
9639
|
|
|
case 'ibm1142': |
|
9640
|
|
|
return 'IBM01142'; |
|
9641
|
|
|
case 'ccsid1143': |
|
9642
|
|
|
case 'cp1143': |
|
9643
|
|
|
case 'ebcdicfi278euro': |
|
9644
|
|
|
case 'ebcdicse278euro': |
|
9645
|
|
|
case 'ibm1143': |
|
9646
|
|
|
return 'IBM01143'; |
|
9647
|
|
|
case 'ccsid1144': |
|
9648
|
|
|
case 'cp1144': |
|
9649
|
|
|
case 'ebcdicit280euro': |
|
9650
|
|
|
case 'ibm1144': |
|
9651
|
|
|
return 'IBM01144'; |
|
9652
|
|
|
case 'ccsid1145': |
|
9653
|
|
|
case 'cp1145': |
|
9654
|
|
|
case 'ebcdices284euro': |
|
9655
|
|
|
case 'ibm1145': |
|
9656
|
|
|
return 'IBM01145'; |
|
9657
|
|
|
case 'ccsid1146': |
|
9658
|
|
|
case 'cp1146': |
|
9659
|
|
|
case 'ebcdicgb285euro': |
|
9660
|
|
|
case 'ibm1146': |
|
9661
|
|
|
return 'IBM01146'; |
|
9662
|
|
|
case 'ccsid1147': |
|
9663
|
|
|
case 'cp1147': |
|
9664
|
|
|
case 'ebcdicfr297euro': |
|
9665
|
|
|
case 'ibm1147': |
|
9666
|
|
|
return 'IBM01147'; |
|
9667
|
|
|
case 'ccsid1148': |
|
9668
|
|
|
case 'cp1148': |
|
9669
|
|
|
case 'ebcdicinternational500euro': |
|
9670
|
|
|
case 'ibm1148': |
|
9671
|
|
|
return 'IBM01148'; |
|
9672
|
|
|
case 'ccsid1149': |
|
9673
|
|
|
case 'cp1149': |
|
9674
|
|
|
case 'ebcdicis871euro': |
|
9675
|
|
|
case 'ibm1149': |
|
9676
|
|
|
return 'IBM01149'; |
|
9677
|
|
|
case 'csiso143iecp271': |
|
9678
|
|
|
case 'iecp271': |
|
9679
|
|
|
case 'isoir143': |
|
9680
|
|
|
return 'IEC_P27-1'; |
|
9681
|
|
|
case 'csiso49inis': |
|
9682
|
|
|
case 'inis': |
|
9683
|
|
|
case 'isoir49': |
|
9684
|
|
|
return 'INIS'; |
|
9685
|
|
|
case 'csiso50inis8': |
|
9686
|
|
|
case 'inis8': |
|
9687
|
|
|
case 'isoir50': |
|
9688
|
|
|
return 'INIS-8'; |
|
9689
|
|
|
case 'csiso51iniscyrillic': |
|
9690
|
|
|
case 'iniscyrillic': |
|
9691
|
|
|
case 'isoir51': |
|
9692
|
|
|
return 'INIS-cyrillic'; |
|
9693
|
|
|
case 'csinvariant': |
|
9694
|
|
|
case 'invariant': |
|
9695
|
|
|
return 'INVARIANT'; |
|
9696
|
|
|
case 'iso2022cn': |
|
9697
|
|
|
return 'ISO-2022-CN'; |
|
9698
|
|
|
case 'iso2022cnext': |
|
9699
|
|
|
return 'ISO-2022-CN-EXT'; |
|
9700
|
|
|
case 'csiso2022jp': |
|
9701
|
|
|
case 'iso2022jp': |
|
9702
|
|
|
return 'ISO-2022-JP'; |
|
9703
|
|
|
case 'csiso2022jp2': |
|
9704
|
|
|
case 'iso2022jp2': |
|
9705
|
|
|
return 'ISO-2022-JP-2'; |
|
9706
|
|
|
case 'csiso2022kr': |
|
9707
|
|
|
case 'iso2022kr': |
|
9708
|
|
|
return 'ISO-2022-KR'; |
|
9709
|
|
|
case 'cswindows30latin1': |
|
9710
|
|
|
case 'iso88591windows30latin1': |
|
9711
|
|
|
return 'ISO-8859-1-Windows-3.0-Latin-1'; |
|
9712
|
|
|
case 'cswindows31latin1': |
|
9713
|
|
|
case 'iso88591windows31latin1': |
|
9714
|
|
|
return 'ISO-8859-1-Windows-3.1-Latin-1'; |
|
9715
|
|
|
case 'csisolatin2': |
|
9716
|
|
|
case 'iso88592': |
|
9717
|
|
|
case 'iso885921987': |
|
9718
|
|
|
case 'isoir101': |
|
9719
|
|
|
case 'l2': |
|
9720
|
|
|
case 'latin2': |
|
9721
|
|
|
return 'ISO-8859-2'; |
|
9722
|
|
|
case 'cswindows31latin2': |
|
9723
|
|
|
case 'iso88592windowslatin2': |
|
9724
|
|
|
return 'ISO-8859-2-Windows-Latin-2'; |
|
9725
|
|
|
case 'csisolatin3': |
|
9726
|
|
|
case 'iso88593': |
|
9727
|
|
|
case 'iso885931988': |
|
9728
|
|
|
case 'isoir109': |
|
9729
|
|
|
case 'l3': |
|
9730
|
|
|
case 'latin3': |
|
9731
|
|
|
return 'ISO-8859-3'; |
|
9732
|
|
|
case 'csisolatin4': |
|
9733
|
|
|
case 'iso88594': |
|
9734
|
|
|
case 'iso885941988': |
|
9735
|
|
|
case 'isoir110': |
|
9736
|
|
|
case 'l4': |
|
9737
|
|
|
case 'latin4': |
|
9738
|
|
|
return 'ISO-8859-4'; |
|
9739
|
|
|
case 'csisolatincyrillic': |
|
9740
|
|
|
case 'cyrillic': |
|
9741
|
|
|
case 'iso88595': |
|
9742
|
|
|
case 'iso885951988': |
|
9743
|
|
|
case 'isoir144': |
|
9744
|
|
|
return 'ISO-8859-5'; |
|
9745
|
|
|
case 'arabic': |
|
9746
|
|
|
case 'asmo708': |
|
9747
|
|
|
case 'csisolatinarabic': |
|
9748
|
|
|
case 'ecma114': |
|
9749
|
|
|
case 'iso88596': |
|
9750
|
|
|
case 'iso885961987': |
|
9751
|
|
|
case 'isoir127': |
|
9752
|
|
|
return 'ISO-8859-6'; |
|
9753
|
|
|
case 'csiso88596e': |
|
9754
|
|
|
case 'iso88596e': |
|
9755
|
|
|
return 'ISO-8859-6-E'; |
|
9756
|
|
|
case 'csiso88596i': |
|
9757
|
|
|
case 'iso88596i': |
|
9758
|
|
|
return 'ISO-8859-6-I'; |
|
9759
|
|
|
case 'csisolatingreek': |
|
9760
|
|
|
case 'ecma118': |
|
9761
|
|
|
case 'elot928': |
|
9762
|
|
|
case 'greek': |
|
9763
|
|
|
case 'greek8': |
|
9764
|
|
|
case 'iso88597': |
|
9765
|
|
|
case 'iso885971987': |
|
9766
|
|
|
case 'isoir126': |
|
9767
|
|
|
return 'ISO-8859-7'; |
|
9768
|
|
|
case 'csisolatinhebrew': |
|
9769
|
|
|
case 'hebrew': |
|
9770
|
|
|
case 'iso88598': |
|
9771
|
|
|
case 'iso885981988': |
|
9772
|
|
|
case 'isoir138': |
|
9773
|
|
|
return 'ISO-8859-8'; |
|
9774
|
|
|
case 'csiso88598e': |
|
9775
|
|
|
case 'iso88598e': |
|
9776
|
|
|
return 'ISO-8859-8-E'; |
|
9777
|
|
|
case 'csiso88598i': |
|
9778
|
|
|
case 'iso88598i': |
|
9779
|
|
|
return 'ISO-8859-8-I'; |
|
9780
|
|
|
case 'cswindows31latin5': |
|
9781
|
|
|
case 'iso88599windowslatin5': |
|
9782
|
|
|
return 'ISO-8859-9-Windows-Latin-5'; |
|
9783
|
|
|
case 'csisolatin6': |
|
9784
|
|
|
case 'iso885910': |
|
9785
|
|
|
case 'iso8859101992': |
|
9786
|
|
|
case 'isoir157': |
|
9787
|
|
|
case 'l6': |
|
9788
|
|
|
case 'latin6': |
|
9789
|
|
|
return 'ISO-8859-10'; |
|
9790
|
|
|
case 'iso885913': |
|
9791
|
|
|
return 'ISO-8859-13'; |
|
9792
|
|
|
case 'iso885914': |
|
9793
|
|
|
case 'iso8859141998': |
|
9794
|
|
|
case 'isoceltic': |
|
9795
|
|
|
case 'isoir199': |
|
9796
|
|
|
case 'l8': |
|
9797
|
|
|
case 'latin8': |
|
9798
|
|
|
return 'ISO-8859-14'; |
|
9799
|
|
|
case 'iso885915': |
|
9800
|
|
|
case 'latin9': |
|
9801
|
|
|
return 'ISO-8859-15'; |
|
9802
|
|
|
case 'iso885916': |
|
9803
|
|
|
case 'iso8859162001': |
|
9804
|
|
|
case 'isoir226': |
|
9805
|
|
|
case 'l10': |
|
9806
|
|
|
case 'latin10': |
|
9807
|
|
|
return 'ISO-8859-16'; |
|
9808
|
|
|
case 'iso10646j1': |
|
9809
|
|
|
return 'ISO-10646-J-1'; |
|
9810
|
|
|
case 'csunicode': |
|
9811
|
|
|
case 'iso10646ucs2': |
|
9812
|
|
|
return 'ISO-10646-UCS-2'; |
|
9813
|
|
|
case 'csucs4': |
|
9814
|
|
|
case 'iso10646ucs4': |
|
9815
|
|
|
return 'ISO-10646-UCS-4'; |
|
9816
|
|
|
case 'csunicodeascii': |
|
9817
|
|
|
case 'iso10646ucsbasic': |
|
9818
|
|
|
return 'ISO-10646-UCS-Basic'; |
|
9819
|
|
|
case 'csunicodelatin1': |
|
9820
|
|
|
case 'iso10646': |
|
9821
|
|
|
case 'iso10646unicodelatin1': |
|
9822
|
|
|
return 'ISO-10646-Unicode-Latin1'; |
|
9823
|
|
|
case 'csiso10646utf1': |
|
9824
|
|
|
case 'iso10646utf1': |
|
9825
|
|
|
return 'ISO-10646-UTF-1'; |
|
9826
|
|
|
case 'csiso115481': |
|
9827
|
|
|
case 'iso115481': |
|
9828
|
|
|
case 'isotr115481': |
|
9829
|
|
|
return 'ISO-11548-1'; |
|
9830
|
|
|
case 'csiso90': |
|
9831
|
|
|
case 'isoir90': |
|
9832
|
|
|
return 'iso-ir-90'; |
|
9833
|
|
|
case 'csunicodeibm1261': |
|
9834
|
|
|
case 'isounicodeibm1261': |
|
9835
|
|
|
return 'ISO-Unicode-IBM-1261'; |
|
9836
|
|
|
case 'csunicodeibm1264': |
|
9837
|
|
|
case 'isounicodeibm1264': |
|
9838
|
|
|
return 'ISO-Unicode-IBM-1264'; |
|
9839
|
|
|
case 'csunicodeibm1265': |
|
9840
|
|
|
case 'isounicodeibm1265': |
|
9841
|
|
|
return 'ISO-Unicode-IBM-1265'; |
|
9842
|
|
|
case 'csunicodeibm1268': |
|
9843
|
|
|
case 'isounicodeibm1268': |
|
9844
|
|
|
return 'ISO-Unicode-IBM-1268'; |
|
9845
|
|
|
case 'csunicodeibm1276': |
|
9846
|
|
|
case 'isounicodeibm1276': |
|
9847
|
|
|
return 'ISO-Unicode-IBM-1276'; |
|
9848
|
|
|
case 'csiso646basic1983': |
|
9849
|
|
|
case 'iso646basic1983': |
|
9850
|
|
|
case 'ref': |
|
9851
|
|
|
return 'ISO_646.basic:1983'; |
|
9852
|
|
|
case 'csiso2intlrefversion': |
|
9853
|
|
|
case 'irv': |
|
9854
|
|
|
case 'iso646irv1983': |
|
9855
|
|
|
case 'isoir2': |
|
9856
|
|
|
return 'ISO_646.irv:1983'; |
|
9857
|
|
|
case 'csiso2033': |
|
9858
|
|
|
case 'e13b': |
|
9859
|
|
|
case 'iso20331983': |
|
9860
|
|
|
case 'isoir98': |
|
9861
|
|
|
return 'ISO_2033-1983'; |
|
9862
|
|
|
case 'csiso5427cyrillic': |
|
9863
|
|
|
case 'iso5427': |
|
9864
|
|
|
case 'isoir37': |
|
9865
|
|
|
return 'ISO_5427'; |
|
9866
|
|
|
case 'iso5427cyrillic1981': |
|
9867
|
|
|
case 'iso54271981': |
|
9868
|
|
|
case 'isoir54': |
|
9869
|
|
|
return 'ISO_5427:1981'; |
|
9870
|
|
|
case 'csiso5428greek': |
|
9871
|
|
|
case 'iso54281980': |
|
9872
|
|
|
case 'isoir55': |
|
9873
|
|
|
return 'ISO_5428:1980'; |
|
9874
|
|
|
case 'csiso6937add': |
|
9875
|
|
|
case 'iso6937225': |
|
9876
|
|
|
case 'isoir152': |
|
9877
|
|
|
return 'ISO_6937-2-25'; |
|
9878
|
|
|
case 'csisotextcomm': |
|
9879
|
|
|
case 'iso69372add': |
|
9880
|
|
|
case 'isoir142': |
|
9881
|
|
|
return 'ISO_6937-2-add'; |
|
9882
|
|
|
case 'csiso8859supp': |
|
9883
|
|
|
case 'iso8859supp': |
|
9884
|
|
|
case 'isoir154': |
|
9885
|
|
|
case 'latin125': |
|
9886
|
|
|
return 'ISO_8859-supp'; |
|
9887
|
|
|
case 'csiso10367box': |
|
9888
|
|
|
case 'iso10367box': |
|
9889
|
|
|
case 'isoir155': |
|
9890
|
|
|
return 'ISO_10367-box'; |
|
9891
|
|
|
case 'csiso15italian': |
|
9892
|
|
|
case 'iso646it': |
|
9893
|
|
|
case 'isoir15': |
|
9894
|
|
|
case 'it': |
|
9895
|
|
|
return 'IT'; |
|
9896
|
|
|
case 'csiso13jisc6220jp': |
|
9897
|
|
|
case 'isoir13': |
|
9898
|
|
|
case 'jisc62201969': |
|
9899
|
|
|
case 'jisc62201969jp': |
|
9900
|
|
|
case 'katakana': |
|
9901
|
|
|
case 'x2017': |
|
9902
|
|
|
return 'JIS_C6220-1969-jp'; |
|
9903
|
|
|
case 'csiso14jisc6220ro': |
|
9904
|
|
|
case 'iso646jp': |
|
9905
|
|
|
case 'isoir14': |
|
9906
|
|
|
case 'jisc62201969ro': |
|
9907
|
|
|
case 'jp': |
|
9908
|
|
|
return 'JIS_C6220-1969-ro'; |
|
9909
|
|
|
case 'csiso42jisc62261978': |
|
9910
|
|
|
case 'isoir42': |
|
9911
|
|
|
case 'jisc62261978': |
|
9912
|
|
|
return 'JIS_C6226-1978'; |
|
9913
|
|
|
case 'csiso87jisx208': |
|
9914
|
|
|
case 'isoir87': |
|
9915
|
|
|
case 'jisc62261983': |
|
9916
|
|
|
case 'jisx2081983': |
|
9917
|
|
|
case 'x208': |
|
9918
|
|
|
return 'JIS_C6226-1983'; |
|
9919
|
|
|
case 'csiso91jisc62291984a': |
|
9920
|
|
|
case 'isoir91': |
|
9921
|
|
|
case 'jisc62291984a': |
|
9922
|
|
|
case 'jpocra': |
|
9923
|
|
|
return 'JIS_C6229-1984-a'; |
|
9924
|
|
|
case 'csiso92jisc62991984b': |
|
9925
|
|
|
case 'iso646jpocrb': |
|
9926
|
|
|
case 'isoir92': |
|
9927
|
|
|
case 'jisc62291984b': |
|
9928
|
|
|
case 'jpocrb': |
|
9929
|
|
|
return 'JIS_C6229-1984-b'; |
|
9930
|
|
|
case 'csiso93jis62291984badd': |
|
9931
|
|
|
case 'isoir93': |
|
9932
|
|
|
case 'jisc62291984badd': |
|
9933
|
|
|
case 'jpocrbadd': |
|
9934
|
|
|
return 'JIS_C6229-1984-b-add'; |
|
9935
|
|
|
case 'csiso94jis62291984hand': |
|
9936
|
|
|
case 'isoir94': |
|
9937
|
|
|
case 'jisc62291984hand': |
|
9938
|
|
|
case 'jpocrhand': |
|
9939
|
|
|
return 'JIS_C6229-1984-hand'; |
|
9940
|
|
|
case 'csiso95jis62291984handadd': |
|
9941
|
|
|
case 'isoir95': |
|
9942
|
|
|
case 'jisc62291984handadd': |
|
9943
|
|
|
case 'jpocrhandadd': |
|
9944
|
|
|
return 'JIS_C6229-1984-hand-add'; |
|
9945
|
|
|
case 'csiso96jisc62291984kana': |
|
9946
|
|
|
case 'isoir96': |
|
9947
|
|
|
case 'jisc62291984kana': |
|
9948
|
|
|
return 'JIS_C6229-1984-kana'; |
|
9949
|
|
|
case 'csjisencoding': |
|
9950
|
|
|
case 'jisencoding': |
|
9951
|
|
|
return 'JIS_Encoding'; |
|
9952
|
|
|
case 'cshalfwidthkatakana': |
|
9953
|
|
|
case 'jisx201': |
|
9954
|
|
|
case 'x201': |
|
9955
|
|
|
return 'JIS_X0201'; |
|
9956
|
|
|
case 'csiso159jisx2121990': |
|
9957
|
|
|
case 'isoir159': |
|
9958
|
|
|
case 'jisx2121990': |
|
9959
|
|
|
case 'x212': |
|
9960
|
|
|
return 'JIS_X0212-1990'; |
|
9961
|
|
|
case 'csiso141jusib1002': |
|
9962
|
|
|
case 'iso646yu': |
|
9963
|
|
|
case 'isoir141': |
|
9964
|
|
|
case 'js': |
|
9965
|
|
|
case 'jusib1002': |
|
9966
|
|
|
case 'yu': |
|
9967
|
|
|
return 'JUS_I.B1.002'; |
|
9968
|
|
|
case 'csiso147macedonian': |
|
9969
|
|
|
case 'isoir147': |
|
9970
|
|
|
case 'jusib1003mac': |
|
9971
|
|
|
case 'macedonian': |
|
9972
|
|
|
return 'JUS_I.B1.003-mac'; |
|
9973
|
|
|
case 'csiso146serbian': |
|
9974
|
|
|
case 'isoir146': |
|
9975
|
|
|
case 'jusib1003serb': |
|
9976
|
|
|
case 'serbian': |
|
9977
|
|
|
return 'JUS_I.B1.003-serb'; |
|
9978
|
|
|
case 'koi7switched': |
|
9979
|
|
|
return 'KOI7-switched'; |
|
9980
|
|
|
case 'cskoi8r': |
|
9981
|
|
|
case 'koi8r': |
|
9982
|
|
|
return 'KOI8-R'; |
|
9983
|
|
|
case 'koi8u': |
|
9984
|
|
|
return 'KOI8-U'; |
|
9985
|
|
|
case 'csksc5636': |
|
9986
|
|
|
case 'iso646kr': |
|
9987
|
|
|
case 'ksc5636': |
|
9988
|
|
|
return 'KSC5636'; |
|
9989
|
|
|
case 'cskz1048': |
|
9990
|
|
|
case 'kz1048': |
|
9991
|
|
|
case 'rk1048': |
|
9992
|
|
|
case 'strk10482002': |
|
9993
|
|
|
return 'KZ-1048'; |
|
9994
|
|
|
case 'csiso19latingreek': |
|
9995
|
|
|
case 'isoir19': |
|
9996
|
|
|
case 'latingreek': |
|
9997
|
|
|
return 'latin-greek'; |
|
9998
|
|
|
case 'csiso27latingreek1': |
|
9999
|
|
|
case 'isoir27': |
|
10000
|
|
|
case 'latingreek1': |
|
10001
|
|
|
return 'Latin-greek-1'; |
|
10002
|
|
|
case 'csiso158lap': |
|
10003
|
|
|
case 'isoir158': |
|
10004
|
|
|
case 'lap': |
|
10005
|
|
|
case 'latinlap': |
|
10006
|
|
|
return 'latin-lap'; |
|
10007
|
|
|
case 'csmacintosh': |
|
10008
|
|
|
case 'mac': |
|
10009
|
|
|
case 'macintosh': |
|
10010
|
|
|
return 'macintosh'; |
|
10011
|
|
|
case 'csmicrosoftpublishing': |
|
10012
|
|
|
case 'microsoftpublishing': |
|
10013
|
|
|
return 'Microsoft-Publishing'; |
|
10014
|
|
|
case 'csmnem': |
|
10015
|
|
|
case 'mnem': |
|
10016
|
|
|
return 'MNEM'; |
|
10017
|
|
|
case 'csmnemonic': |
|
10018
|
|
|
case 'mnemonic': |
|
10019
|
|
|
return 'MNEMONIC'; |
|
10020
|
|
|
case 'csiso86hungarian': |
|
10021
|
|
|
case 'hu': |
|
10022
|
|
|
case 'iso646hu': |
|
10023
|
|
|
case 'isoir86': |
|
10024
|
|
|
case 'msz77953': |
|
10025
|
|
|
return 'MSZ_7795.3'; |
|
10026
|
|
|
case 'csnatsdano': |
|
10027
|
|
|
case 'isoir91': |
|
10028
|
|
|
case 'natsdano': |
|
10029
|
|
|
return 'NATS-DANO'; |
|
10030
|
|
|
case 'csnatsdanoadd': |
|
10031
|
|
|
case 'isoir92': |
|
10032
|
|
|
case 'natsdanoadd': |
|
10033
|
|
|
return 'NATS-DANO-ADD'; |
|
10034
|
|
|
case 'csnatssefi': |
|
10035
|
|
|
case 'isoir81': |
|
10036
|
|
|
case 'natssefi': |
|
10037
|
|
|
return 'NATS-SEFI'; |
|
10038
|
|
|
case 'csnatssefiadd': |
|
10039
|
|
|
case 'isoir82': |
|
10040
|
|
|
case 'natssefiadd': |
|
10041
|
|
|
return 'NATS-SEFI-ADD'; |
|
10042
|
|
|
case 'csiso151cuba': |
|
10043
|
|
|
case 'cuba': |
|
10044
|
|
|
case 'iso646cu': |
|
10045
|
|
|
case 'isoir151': |
|
10046
|
|
|
case 'ncnc1081': |
|
10047
|
|
|
return 'NC_NC00-10:81'; |
|
10048
|
|
|
case 'csiso69french': |
|
10049
|
|
|
case 'fr': |
|
10050
|
|
|
case 'iso646fr': |
|
10051
|
|
|
case 'isoir69': |
|
10052
|
|
|
case 'nfz62010': |
|
10053
|
|
|
return 'NF_Z_62-010'; |
|
10054
|
|
|
case 'csiso25french': |
|
10055
|
|
|
case 'iso646fr1': |
|
10056
|
|
|
case 'isoir25': |
|
10057
|
|
|
case 'nfz620101973': |
|
10058
|
|
|
return 'NF_Z_62-010_(1973)'; |
|
10059
|
|
|
case 'csiso60danishnorwegian': |
|
10060
|
|
|
case 'csiso60norwegian1': |
|
10061
|
|
|
case 'iso646no': |
|
10062
|
|
|
case 'isoir60': |
|
10063
|
|
|
case 'no': |
|
10064
|
|
|
case 'ns45511': |
|
10065
|
|
|
return 'NS_4551-1'; |
|
10066
|
|
|
case 'csiso61norwegian2': |
|
10067
|
|
|
case 'iso646no2': |
|
10068
|
|
|
case 'isoir61': |
|
10069
|
|
|
case 'no2': |
|
10070
|
|
|
case 'ns45512': |
|
10071
|
|
|
return 'NS_4551-2'; |
|
10072
|
|
|
case 'osdebcdicdf3irv': |
|
10073
|
|
|
return 'OSD_EBCDIC_DF03_IRV'; |
|
10074
|
|
|
case 'osdebcdicdf41': |
|
10075
|
|
|
return 'OSD_EBCDIC_DF04_1'; |
|
10076
|
|
|
case 'osdebcdicdf415': |
|
10077
|
|
|
return 'OSD_EBCDIC_DF04_15'; |
|
10078
|
|
|
case 'cspc8danishnorwegian': |
|
10079
|
|
|
case 'pc8danishnorwegian': |
|
10080
|
|
|
return 'PC8-Danish-Norwegian'; |
|
10081
|
|
|
case 'cspc8turkish': |
|
10082
|
|
|
case 'pc8turkish': |
|
10083
|
|
|
return 'PC8-Turkish'; |
|
10084
|
|
|
case 'csiso16portuguese': |
|
10085
|
|
|
case 'iso646pt': |
|
10086
|
|
|
case 'isoir16': |
|
10087
|
|
|
case 'pt': |
|
10088
|
|
|
return 'PT'; |
|
10089
|
|
|
case 'csiso84portuguese2': |
|
10090
|
|
|
case 'iso646pt2': |
|
10091
|
|
|
case 'isoir84': |
|
10092
|
|
|
case 'pt2': |
|
10093
|
|
|
return 'PT2'; |
|
10094
|
|
|
case 'cp154': |
|
10095
|
|
|
case 'csptcp154': |
|
10096
|
|
|
case 'cyrillicasian': |
|
10097
|
|
|
case 'pt154': |
|
10098
|
|
|
case 'ptcp154': |
|
10099
|
|
|
return 'PTCP154'; |
|
10100
|
|
|
case 'scsu': |
|
10101
|
|
|
return 'SCSU'; |
|
10102
|
|
|
case 'csiso10swedish': |
|
10103
|
|
|
case 'fi': |
|
10104
|
|
|
case 'iso646fi': |
|
10105
|
|
|
case 'iso646se': |
|
10106
|
|
|
case 'isoir10': |
|
10107
|
|
|
case 'se': |
|
10108
|
|
|
case 'sen850200b': |
|
10109
|
|
|
return 'SEN_850200_B'; |
|
10110
|
|
|
case 'csiso11swedishfornames': |
|
10111
|
|
|
case 'iso646se2': |
|
10112
|
|
|
case 'isoir11': |
|
10113
|
|
|
case 'se2': |
|
10114
|
|
|
case 'sen850200c': |
|
10115
|
|
|
return 'SEN_850200_C'; |
|
10116
|
|
|
case 'csiso102t617bit': |
|
10117
|
|
|
case 'isoir102': |
|
10118
|
|
|
case 't617bit': |
|
10119
|
|
|
return 'T.61-7bit'; |
|
10120
|
|
|
case 'csiso103t618bit': |
|
10121
|
|
|
case 'isoir103': |
|
10122
|
|
|
case 't61': |
|
10123
|
|
|
case 't618bit': |
|
10124
|
|
|
return 'T.61-8bit'; |
|
10125
|
|
|
case 'csiso128t101g2': |
|
10126
|
|
|
case 'isoir128': |
|
10127
|
|
|
case 't101g2': |
|
10128
|
|
|
return 'T.101-G2'; |
|
10129
|
|
|
case 'cstscii': |
|
10130
|
|
|
case 'tscii': |
|
10131
|
|
|
return 'TSCII'; |
|
10132
|
|
|
case 'csunicode11': |
|
10133
|
|
|
case 'unicode11': |
|
10134
|
|
|
return 'UNICODE-1-1'; |
|
10135
|
|
|
case 'csunicode11utf7': |
|
10136
|
|
|
case 'unicode11utf7': |
|
10137
|
|
|
return 'UNICODE-1-1-UTF-7'; |
|
10138
|
|
|
case 'csunknown8bit': |
|
10139
|
|
|
case 'unknown8bit': |
|
10140
|
|
|
return 'UNKNOWN-8BIT'; |
|
10141
|
|
|
case 'ansix341968': |
|
10142
|
|
|
case 'ansix341986': |
|
10143
|
|
|
case 'ascii': |
|
10144
|
|
|
case 'cp367': |
|
10145
|
|
|
case 'csascii': |
|
10146
|
|
|
case 'ibm367': |
|
10147
|
|
|
case 'iso646irv1991': |
|
10148
|
|
|
case 'iso646us': |
|
10149
|
|
|
case 'isoir6': |
|
10150
|
|
|
case 'us': |
|
10151
|
|
|
case 'usascii': |
|
10152
|
|
|
return 'US-ASCII'; |
|
10153
|
|
|
case 'csusdk': |
|
10154
|
|
|
case 'usdk': |
|
10155
|
|
|
return 'us-dk'; |
|
10156
|
|
|
case 'utf7': |
|
10157
|
|
|
return 'UTF-7'; |
|
10158
|
|
|
case 'utf8': |
|
10159
|
|
|
return 'UTF-8'; |
|
10160
|
|
|
case 'utf16': |
|
10161
|
|
|
return 'UTF-16'; |
|
10162
|
|
|
case 'utf16be': |
|
10163
|
|
|
return 'UTF-16BE'; |
|
10164
|
|
|
case 'utf16le': |
|
10165
|
|
|
return 'UTF-16LE'; |
|
10166
|
|
|
case 'utf32': |
|
10167
|
|
|
return 'UTF-32'; |
|
10168
|
|
|
case 'utf32be': |
|
10169
|
|
|
return 'UTF-32BE'; |
|
10170
|
|
|
case 'utf32le': |
|
10171
|
|
|
return 'UTF-32LE'; |
|
10172
|
|
|
case 'csventurainternational': |
|
10173
|
|
|
case 'venturainternational': |
|
10174
|
|
|
return 'Ventura-International'; |
|
10175
|
|
|
case 'csventuramath': |
|
10176
|
|
|
case 'venturamath': |
|
10177
|
|
|
return 'Ventura-Math'; |
|
10178
|
|
|
case 'csventuraus': |
|
10179
|
|
|
case 'venturaus': |
|
10180
|
|
|
return 'Ventura-US'; |
|
10181
|
|
|
case 'csiso70videotexsupp1': |
|
10182
|
|
|
case 'isoir70': |
|
10183
|
|
|
case 'videotexsuppl': |
|
10184
|
|
|
return 'videotex-suppl'; |
|
10185
|
|
|
case 'csviqr': |
|
10186
|
|
|
case 'viqr': |
|
10187
|
|
|
return 'VIQR'; |
|
10188
|
|
|
case 'csviscii': |
|
10189
|
|
|
case 'viscii': |
|
10190
|
|
|
return 'VISCII'; |
|
10191
|
|
|
case 'csshiftjis': |
|
10192
|
|
|
case 'cswindows31j': |
|
10193
|
|
|
case 'mskanji': |
|
10194
|
|
|
case 'shiftjis': |
|
10195
|
|
|
case 'windows31j': |
|
10196
|
|
|
return 'Windows-31J'; |
|
10197
|
|
|
case 'iso885911': |
|
10198
|
|
|
case 'tis620': |
|
10199
|
|
|
return 'windows-874'; |
|
10200
|
|
|
case 'cseuckr': |
|
10201
|
|
|
case 'csksc56011987': |
|
10202
|
|
|
case 'euckr': |
|
10203
|
|
|
case 'isoir149': |
|
10204
|
|
|
case 'korean': |
|
10205
|
|
|
case 'ksc5601': |
|
10206
|
|
|
case 'ksc56011987': |
|
10207
|
|
|
case 'ksc56011989': |
|
10208
|
|
|
case 'windows949': |
|
10209
|
|
|
return 'windows-949'; |
|
10210
|
|
|
case 'windows1250': |
|
10211
|
|
|
return 'windows-1250'; |
|
10212
|
|
|
case 'windows1251': |
|
10213
|
|
|
return 'windows-1251'; |
|
10214
|
|
|
case 'cp819': |
|
10215
|
|
|
case 'csisolatin1': |
|
10216
|
|
|
case 'ibm819': |
|
10217
|
|
|
case 'iso88591': |
|
10218
|
|
|
case 'iso885911987': |
|
10219
|
|
|
case 'isoir100': |
|
10220
|
|
|
case 'l1': |
|
10221
|
|
|
case 'latin1': |
|
10222
|
|
|
case 'windows1252': |
|
10223
|
|
|
return 'windows-1252'; |
|
10224
|
|
|
case 'windows1253': |
|
10225
|
|
|
return 'windows-1253'; |
|
10226
|
|
|
case 'csisolatin5': |
|
10227
|
|
|
case 'iso88599': |
|
10228
|
|
|
case 'iso885991989': |
|
10229
|
|
|
case 'isoir148': |
|
10230
|
|
|
case 'l5': |
|
10231
|
|
|
case 'latin5': |
|
10232
|
|
|
case 'windows1254': |
|
10233
|
|
|
return 'windows-1254'; |
|
10234
|
|
|
case 'windows1255': |
|
10235
|
|
|
return 'windows-1255'; |
|
10236
|
|
|
case 'windows1256': |
|
10237
|
|
|
return 'windows-1256'; |
|
10238
|
|
|
case 'windows1257': |
|
10239
|
|
|
return 'windows-1257'; |
|
10240
|
|
|
case 'windows1258': |
|
10241
|
|
|
return 'windows-1258'; |
|
10242
|
|
|
default: |
|
10243
|
|
|
return $charset; |
|
10244
|
|
|
} |
|
10245
|
|
|
} |
|
10246
|
|
|
public static function get_curl_version() |
|
10247
|
|
|
{ |
|
10248
|
|
|
if (is_array($curl = curl_version())) |
|
10249
|
|
|
{ |
|
10250
|
|
|
$curl = $curl['version']; |
|
10251
|
|
|
} |
|
10252
|
|
|
elseif (substr($curl, 0, 5) === 'curl/') |
|
10253
|
|
|
{ |
|
10254
|
|
|
$curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5)); |
|
10255
|
|
|
} |
|
10256
|
|
|
elseif (substr($curl, 0, 8) === 'libcurl/') |
|
10257
|
|
|
{ |
|
10258
|
|
|
$curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8)); |
|
10259
|
|
|
} |
|
10260
|
|
|
else |
|
10261
|
|
|
{ |
|
10262
|
|
|
$curl = 0; |
|
10263
|
|
|
} |
|
10264
|
|
|
return $curl; |
|
10265
|
|
|
} |
|
10266
|
|
|
|
|
10267
|
|
|
public static function strip_comments($data) |
|
10268
|
|
|
{ |
|
10269
|
|
|
$output = ''; |
|
10270
|
|
|
while (($start = strpos($data, '<!--')) !== false) |
|
10271
|
|
|
{ |
|
10272
|
|
|
$output .= substr($data, 0, $start); |
|
10273
|
|
|
if (($end = strpos($data, '-->', $start)) !== false) |
|
10274
|
|
|
{ |
|
10275
|
|
|
$data = substr_replace($data, '', 0, $end + 3); |
|
10276
|
|
|
} |
|
10277
|
|
|
else |
|
10278
|
|
|
{ |
|
10279
|
|
|
$data = ''; |
|
10280
|
|
|
} |
|
10281
|
|
|
} |
|
10282
|
|
|
return $output . $data; |
|
10283
|
|
|
} |
|
10284
|
|
|
public static function parse_date($dt) |
|
10285
|
|
|
{ |
|
10286
|
|
|
$parser = SimplePie_Parse_Date::get(); |
|
10287
|
|
|
return $parser->parse($dt); |
|
10288
|
|
|
} |
|
10289
|
|
|
|
|
10290
|
|
|
public static function entities_decode($data) |
|
10291
|
|
|
{ |
|
10292
|
|
|
$decoder = new SimplePie_Decode_HTML_Entities($data); |
|
10293
|
|
|
return $decoder->parse(); |
|
10294
|
|
|
} |
|
10295
|
|
|
|
|
10296
|
|
|
public static function uncomment_rfc822($string) |
|
10297
|
|
|
{ |
|
10298
|
|
|
$string = (string) $string; |
|
10299
|
|
|
$position = 0; |
|
10300
|
|
|
$length = strlen($string); |
|
10301
|
|
|
$depth = 0; |
|
10302
|
|
|
$output = ''; |
|
10303
|
|
|
while ($position < $length && ($pos = strpos($string, '(', $position)) !== false) |
|
10304
|
|
|
{ |
|
10305
|
|
|
$output .= substr($string, $position, $pos - $position); |
|
10306
|
|
|
$position = $pos + 1; |
|
10307
|
|
|
if ($string[$pos - 1] !== '\\') |
|
10308
|
|
|
{ |
|
10309
|
|
|
$depth++; |
|
10310
|
|
|
while ($depth && $position < $length) |
|
10311
|
|
|
{ |
|
10312
|
|
|
$position += strcspn($string, '()', $position); |
|
10313
|
|
|
if ($string[$position - 1] === '\\') |
|
10314
|
|
|
{ |
|
10315
|
|
|
$position++; |
|
10316
|
|
|
continue; |
|
10317
|
|
|
} |
|
10318
|
|
|
elseif (isset($string[$position])) |
|
10319
|
|
|
{ |
|
10320
|
|
|
switch ($string[$position]) |
|
10321
|
|
|
{ |
|
10322
|
|
|
case '(': |
|
10323
|
|
|
$depth++; |
|
10324
|
|
|
break; |
|
10325
|
|
|
case ')': |
|
10326
|
|
|
$depth--; |
|
10327
|
|
|
break; |
|
10328
|
|
|
} |
|
10329
|
|
|
$position++; |
|
10330
|
|
|
} |
|
10331
|
|
|
else |
|
10332
|
|
|
{ |
|
10333
|
|
|
break; |
|
10334
|
|
|
} |
|
10335
|
|
|
} |
|
10336
|
|
|
} |
|
10337
|
|
|
else |
|
10338
|
|
|
{ |
|
10339
|
|
|
$output .= '('; |
|
10340
|
|
|
} |
|
10341
|
|
|
} |
|
10342
|
|
|
$output .= substr($string, $position); |
|
10343
|
|
|
return $output; |
|
10344
|
|
|
} |
|
10345
|
|
|
public static function parse_mime($mime) |
|
10346
|
|
|
{ |
|
10347
|
|
|
if (($pos = strpos($mime, ';')) === false) |
|
10348
|
|
|
{ |
|
10349
|
|
|
return trim($mime); |
|
10350
|
|
|
} |
|
10351
|
|
|
else |
|
10352
|
|
|
{ |
|
10353
|
|
|
return trim(substr($mime, 0, $pos)); |
|
10354
|
|
|
} |
|
10355
|
|
|
} |
|
10356
|
|
|
public static function atom_03_construct_type($attribs) |
|
10357
|
|
|
{ |
|
10358
|
|
|
if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) === 'base64')) |
|
10359
|
|
|
{ |
|
10360
|
|
|
$mode = SIMPLEPIE_CONSTRUCT_BASE64; |
|
10361
|
|
|
} |
|
10362
|
|
|
else |
|
10363
|
|
|
{ |
|
10364
|
|
|
$mode = SIMPLEPIE_CONSTRUCT_NONE; |
|
10365
|
|
|
} |
|
10366
|
|
|
if (isset($attribs['']['type'])) |
|
10367
|
|
|
{ |
|
10368
|
|
|
switch (strtolower(trim($attribs['']['type']))) |
|
10369
|
|
|
{ |
|
10370
|
|
|
case 'text': |
|
10371
|
|
|
case 'text/plain': |
|
10372
|
|
|
return SIMPLEPIE_CONSTRUCT_TEXT | $mode; |
|
10373
|
|
|
case 'html': |
|
10374
|
|
|
case 'text/html': |
|
10375
|
|
|
return SIMPLEPIE_CONSTRUCT_HTML | $mode; |
|
10376
|
|
|
case 'xhtml': |
|
10377
|
|
|
case 'application/xhtml+xml': |
|
10378
|
|
|
return SIMPLEPIE_CONSTRUCT_XHTML | $mode; |
|
10379
|
|
|
default: |
|
10380
|
|
|
return SIMPLEPIE_CONSTRUCT_NONE | $mode; |
|
10381
|
|
|
} |
|
10382
|
|
|
} |
|
10383
|
|
|
else |
|
10384
|
|
|
{ |
|
10385
|
|
|
return SIMPLEPIE_CONSTRUCT_TEXT | $mode; |
|
10386
|
|
|
} |
|
10387
|
|
|
} |
|
10388
|
|
|
public static function atom_10_construct_type($attribs) |
|
10389
|
|
|
{ |
|
10390
|
|
|
if (isset($attribs['']['type'])) |
|
10391
|
|
|
{ |
|
10392
|
|
|
switch (strtolower(trim($attribs['']['type']))) |
|
10393
|
|
|
{ |
|
10394
|
|
|
case 'text': |
|
10395
|
|
|
return SIMPLEPIE_CONSTRUCT_TEXT; |
|
10396
|
|
|
case 'html': |
|
10397
|
|
|
return SIMPLEPIE_CONSTRUCT_HTML; |
|
10398
|
|
|
case 'xhtml': |
|
10399
|
|
|
return SIMPLEPIE_CONSTRUCT_XHTML; |
|
10400
|
|
|
default: |
|
10401
|
|
|
return SIMPLEPIE_CONSTRUCT_NONE; |
|
10402
|
|
|
} |
|
10403
|
|
|
} |
|
10404
|
|
|
return SIMPLEPIE_CONSTRUCT_TEXT; |
|
10405
|
|
|
} |
|
10406
|
|
|
public static function atom_10_content_construct_type($attribs) |
|
10407
|
|
|
{ |
|
10408
|
|
|
if (isset($attribs['']['type'])) |
|
10409
|
|
|
{ |
|
10410
|
|
|
$type = strtolower(trim($attribs['']['type'])); |
|
10411
|
|
|
switch ($type) |
|
10412
|
|
|
{ |
|
10413
|
|
|
case 'text': |
|
10414
|
|
|
return SIMPLEPIE_CONSTRUCT_TEXT; |
|
10415
|
|
|
case 'html': |
|
10416
|
|
|
return SIMPLEPIE_CONSTRUCT_HTML; |
|
10417
|
|
|
case 'xhtml': |
|
10418
|
|
|
return SIMPLEPIE_CONSTRUCT_XHTML; |
|
10419
|
|
|
} |
|
10420
|
|
|
if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) === 'text/') |
|
10421
|
|
|
{ |
|
10422
|
|
|
return SIMPLEPIE_CONSTRUCT_NONE; |
|
10423
|
|
|
} |
|
10424
|
|
|
else |
|
10425
|
|
|
{ |
|
10426
|
|
|
return SIMPLEPIE_CONSTRUCT_BASE64; |
|
10427
|
|
|
} |
|
10428
|
|
|
} |
|
10429
|
|
|
else |
|
10430
|
|
|
{ |
|
10431
|
|
|
return SIMPLEPIE_CONSTRUCT_TEXT; |
|
10432
|
|
|
} |
|
10433
|
|
|
} |
|
10434
|
|
|
public static function is_isegment_nz_nc($string) |
|
10435
|
|
|
{ |
|
10436
|
|
|
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); |
|
10437
|
|
|
} |
|
10438
|
|
|
public static function space_seperated_tokens($string) |
|
10439
|
|
|
{ |
|
10440
|
|
|
$space_characters = "\x20\x09\x0A\x0B\x0C\x0D"; |
|
10441
|
|
|
$string_length = strlen($string); |
|
10442
|
|
|
$position = strspn($string, $space_characters); |
|
10443
|
|
|
$tokens = array(); |
|
10444
|
|
|
while ($position < $string_length) |
|
10445
|
|
|
{ |
|
10446
|
|
|
$len = strcspn($string, $space_characters, $position); |
|
10447
|
|
|
$tokens[] = substr($string, $position, $len); |
|
10448
|
|
|
$position += $len; |
|
10449
|
|
|
$position += strspn($string, $space_characters, $position); |
|
10450
|
|
|
} |
|
10451
|
|
|
return $tokens; |
|
10452
|
|
|
} |
|
10453
|
|
|
|
|
10454
|
|
|
public static function codepoint_to_utf8($codepoint) |
|
10455
|
|
|
{ |
|
10456
|
|
|
$codepoint = (int) $codepoint; |
|
10457
|
|
|
if ($codepoint < 0) |
|
10458
|
|
|
{ |
|
10459
|
|
|
return false; |
|
10460
|
|
|
} |
|
10461
|
|
|
else if ($codepoint <= 0x7f) |
|
10462
|
|
|
{ |
|
10463
|
|
|
return chr($codepoint); |
|
10464
|
|
|
} |
|
10465
|
|
|
else if ($codepoint <= 0x7ff) |
|
10466
|
|
|
{ |
|
10467
|
|
|
return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f)); |
|
10468
|
|
|
} |
|
10469
|
|
|
else if ($codepoint <= 0xffff) |
|
10470
|
|
|
{ |
|
10471
|
|
|
return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); |
|
10472
|
|
|
} |
|
10473
|
|
|
else if ($codepoint <= 0x10ffff) |
|
10474
|
|
|
{ |
|
10475
|
|
|
return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); |
|
10476
|
|
|
} |
|
10477
|
|
|
else |
|
10478
|
|
|
{ |
|
10479
|
|
|
// U+FFFD REPLACEMENT CHARACTER |
|
10480
|
|
|
return "\xEF\xBF\xBD"; |
|
10481
|
|
|
} |
|
10482
|
|
|
} |
|
10483
|
|
|
|
|
10484
|
|
|
public static function parse_str($str) |
|
10485
|
|
|
{ |
|
10486
|
|
|
$return = array(); |
|
10487
|
|
|
$str = explode('&', $str); |
|
10488
|
|
|
foreach ($str as $section) |
|
10489
|
|
|
{ |
|
10490
|
|
|
if (strpos($section, '=') !== false) |
|
10491
|
|
|
{ |
|
10492
|
|
|
list($name, $value) = explode('=', $section, 2); |
|
10493
|
|
|
$return[urldecode($name)][] = urldecode($value); |
|
10494
|
|
|
} |
|
10495
|
|
|
else |
|
10496
|
|
|
{ |
|
10497
|
|
|
$return[urldecode($section)][] = null; |
|
10498
|
|
|
} |
|
10499
|
|
|
} |
|
10500
|
|
|
return $return; |
|
10501
|
|
|
} |
|
10502
|
|
|
|
|
10503
|
|
|
public static function xml_encoding($data, $registry) |
|
10504
|
|
|
{ |
|
10505
|
|
|
// UTF-32 Big Endian BOM |
|
10506
|
|
|
if (substr($data, 0, 4) === "\x00\x00\xFE\xFF") |
|
10507
|
|
|
{ |
|
10508
|
|
|
$encoding[] = 'UTF-32BE'; |
|
10509
|
|
|
} |
|
10510
|
|
|
// UTF-32 Little Endian BOM |
|
10511
|
|
|
elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00") |
|
10512
|
|
|
{ |
|
10513
|
|
|
$encoding[] = 'UTF-32LE'; |
|
10514
|
|
|
} |
|
10515
|
|
|
// UTF-16 Big Endian BOM |
|
10516
|
|
|
elseif (substr($data, 0, 2) === "\xFE\xFF") |
|
10517
|
|
|
{ |
|
10518
|
|
|
$encoding[] = 'UTF-16BE'; |
|
10519
|
|
|
} |
|
10520
|
|
|
// UTF-16 Little Endian BOM |
|
10521
|
|
|
elseif (substr($data, 0, 2) === "\xFF\xFE") |
|
10522
|
|
|
{ |
|
10523
|
|
|
$encoding[] = 'UTF-16LE'; |
|
10524
|
|
|
} |
|
10525
|
|
|
// UTF-8 BOM |
|
10526
|
|
|
elseif (substr($data, 0, 3) === "\xEF\xBB\xBF") |
|
10527
|
|
|
{ |
|
10528
|
|
|
$encoding[] = 'UTF-8'; |
|
10529
|
|
|
} |
|
10530
|
|
|
// UTF-32 Big Endian Without BOM |
|
10531
|
|
|
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") |
|
10532
|
|
|
{ |
|
10533
|
|
|
if ($pos = strpos($data, "\x00\x00\x00\x3F\x00\x00\x00\x3E")) |
|
10534
|
|
|
{ |
|
10535
|
|
|
$parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32BE', 'UTF-8'))); |
|
10536
|
|
|
if ($parser->parse()) |
|
10537
|
|
|
{ |
|
10538
|
|
|
$encoding[] = $parser->encoding; |
|
10539
|
|
|
} |
|
10540
|
|
|
} |
|
10541
|
|
|
$encoding[] = 'UTF-32BE'; |
|
10542
|
|
|
} |
|
10543
|
|
|
// UTF-32 Little Endian Without BOM |
|
10544
|
|
|
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") |
|
10545
|
|
|
{ |
|
10546
|
|
|
if ($pos = strpos($data, "\x3F\x00\x00\x00\x3E\x00\x00\x00")) |
|
10547
|
|
|
{ |
|
10548
|
|
|
$parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32LE', 'UTF-8'))); |
|
10549
|
|
|
if ($parser->parse()) |
|
10550
|
|
|
{ |
|
10551
|
|
|
$encoding[] = $parser->encoding; |
|
10552
|
|
|
} |
|
10553
|
|
|
} |
|
10554
|
|
|
$encoding[] = 'UTF-32LE'; |
|
10555
|
|
|
} |
|
10556
|
|
|
// UTF-16 Big Endian Without BOM |
|
10557
|
|
|
elseif (substr($data, 0, 10) === "\x00\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C") |
|
10558
|
|
|
{ |
|
10559
|
|
|
if ($pos = strpos($data, "\x00\x3F\x00\x3E")) |
|
10560
|
|
|
{ |
|
10561
|
|
|
$parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16BE', 'UTF-8'))); |
|
10562
|
|
|
if ($parser->parse()) |
|
10563
|
|
|
{ |
|
10564
|
|
|
$encoding[] = $parser->encoding; |
|
10565
|
|
|
} |
|
10566
|
|
|
} |
|
10567
|
|
|
$encoding[] = 'UTF-16BE'; |
|
10568
|
|
|
} |
|
10569
|
|
|
// UTF-16 Little Endian Without BOM |
|
10570
|
|
|
elseif (substr($data, 0, 10) === "\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C\x00") |
|
10571
|
|
|
{ |
|
10572
|
|
|
if ($pos = strpos($data, "\x3F\x00\x3E\x00")) |
|
10573
|
|
|
{ |
|
10574
|
|
|
$parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16LE', 'UTF-8'))); |
|
10575
|
|
|
if ($parser->parse()) |
|
10576
|
|
|
{ |
|
10577
|
|
|
$encoding[] = $parser->encoding; |
|
10578
|
|
|
} |
|
10579
|
|
|
} |
|
10580
|
|
|
$encoding[] = 'UTF-16LE'; |
|
10581
|
|
|
} |
|
10582
|
|
|
// US-ASCII (or superset) |
|
10583
|
|
|
elseif (substr($data, 0, 5) === "\x3C\x3F\x78\x6D\x6C") |
|
10584
|
|
|
{ |
|
10585
|
|
|
if ($pos = strpos($data, "\x3F\x3E")) |
|
10586
|
|
|
{ |
|
10587
|
|
|
$parser = $registry->create('XML_Declaration_Parser', array(substr($data, 5, $pos - 5))); |
|
10588
|
|
|
if ($parser->parse()) |
|
10589
|
|
|
{ |
|
10590
|
|
|
$encoding[] = $parser->encoding; |
|
10591
|
|
|
} |
|
10592
|
|
|
} |
|
10593
|
|
|
$encoding[] = 'UTF-8'; |
|
10594
|
|
|
} |
|
10595
|
|
|
// Fallback to UTF-8 |
|
10596
|
|
|
else |
|
10597
|
|
|
{ |
|
10598
|
|
|
$encoding[] = 'UTF-8'; |
|
10599
|
|
|
} |
|
10600
|
|
|
return $encoding; |
|
10601
|
|
|
} |
|
10602
|
|
|
public static function output_javascript() |
|
10603
|
|
|
{ |
|
10604
|
|
|
if (function_exists('ob_gzhandler')) |
|
10605
|
|
|
{ |
|
10606
|
|
|
ob_start('ob_gzhandler'); |
|
10607
|
|
|
} |
|
10608
|
|
|
header('Content-type: text/javascript; charset: UTF-8'); |
|
10609
|
|
|
header('Cache-Control: must-revalidate'); |
|
10610
|
|
|
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days |
|
10611
|
|
|
?> |
|
10612
|
|
|
function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) { |
|
10613
|
|
|
if (placeholder != '') { |
|
10614
|
|
|
document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="../../../miax/crssfeed/scr/simplepie/'+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>'); |
|
10615
|
|
|
} |
|
10616
|
|
|
else { |
|
10617
|
|
|
document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="../../../miax/crssfeed/scr/simplepie/'+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>'); |
|
10618
|
|
|
} |
|
10619
|
|
|
} |
|
10620
|
|
|
function embed_flash(bgcolor, width, height, link, loop, type) { |
|
10621
|
|
|
document.writeln('<embed src="../../../miax/crssfeed/scr/simplepie/'+link+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>'); |
|
10622
|
|
|
} |
|
10623
|
|
|
function embed_flv(width, height, link, placeholder, loop, player) { |
|
10624
|
|
|
document.writeln('<embed src="../../../miax/crssfeed/scr/simplepie/'+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>'); |
|
10625
|
|
|
} |
|
10626
|
|
|
function embed_wmedia(width, height, link) { |
|
10627
|
|
|
document.writeln('<embed type="application/x-mplayer2" src="../../../miax/crssfeed/scr/simplepie/'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>'); |
|
10628
|
|
|
} |
|
10629
|
|
|
<?php |
|
10630
|
|
|
} |
|
10631
|
|
|
|
|
10632
|
|
|
public static function get_build() |
|
10633
|
|
|
{ |
|
10634
|
|
|
$root = dirname(dirname(__FILE__)); |
|
10635
|
|
|
if (file_exists($root . '/.git/index')) |
|
10636
|
|
|
{ |
|
10637
|
|
|
return filemtime($root . '/.git/index'); |
|
10638
|
|
|
} |
|
10639
|
|
|
elseif (file_exists($root . '/SimplePie')) |
|
10640
|
|
|
{ |
|
10641
|
|
|
$time = 0; |
|
10642
|
|
|
foreach (glob($root . '/SimplePie/*.php') as $file) |
|
10643
|
|
|
{ |
|
10644
|
|
|
if (($mtime = filemtime($file)) > $time) |
|
10645
|
|
|
{ |
|
10646
|
|
|
$time = $mtime; |
|
10647
|
|
|
} |
|
10648
|
|
|
} |
|
10649
|
|
|
return $time; |
|
10650
|
|
|
} |
|
10651
|
|
|
elseif (file_exists(dirname(__FILE__) . '/Core.php')) |
|
10652
|
|
|
{ |
|
10653
|
|
|
return filemtime(dirname(__FILE__) . '/Core.php'); |
|
10654
|
|
|
} |
|
10655
|
|
|
else |
|
10656
|
|
|
{ |
|
10657
|
|
|
return filemtime(__FILE__); |
|
10658
|
|
|
} |
|
10659
|
|
|
} |
|
10660
|
|
|
|
|
10661
|
|
|
public static function debug(&$sp) |
|
10662
|
|
|
{ |
|
10663
|
|
|
$info = 'SimplePie ' . SIMPLEPIE_VERSION . ' Build ' . SIMPLEPIE_BUILD . "\n"; |
|
10664
|
|
|
$info .= 'PHP ' . PHP_VERSION . "\n"; |
|
10665
|
|
|
if ($sp->error() !== null) |
|
10666
|
|
|
{ |
|
10667
|
|
|
$info .= 'Error occurred: ' . $sp->error() . "\n"; |
|
10668
|
|
|
} |
|
10669
|
|
|
else |
|
10670
|
|
|
{ |
|
10671
|
|
|
$info .= "No error found.\n"; |
|
10672
|
|
|
} |
|
10673
|
|
|
$info .= "Extensions:\n"; |
|
10674
|
|
|
$extensions = array('pcre', 'curl', 'zlib', 'mbstring', 'iconv', 'xmlreader', 'xml'); |
|
10675
|
|
|
foreach ($extensions as $ext) |
|
10676
|
|
|
{ |
|
10677
|
|
|
if (extension_loaded($ext)) |
|
10678
|
|
|
{ |
|
10679
|
|
|
$info .= " $ext loaded\n"; |
|
10680
|
|
|
switch ($ext) |
|
10681
|
|
|
{ |
|
10682
|
|
|
case 'pcre': |
|
10683
|
|
|
$info .= ' Version ' . PCRE_VERSION . "\n"; |
|
10684
|
|
|
break; |
|
10685
|
|
|
case 'curl': |
|
10686
|
|
|
$version = curl_version(); |
|
10687
|
|
|
$info .= ' Version ' . $version['version'] . "\n"; |
|
10688
|
|
|
break; |
|
10689
|
|
|
case 'mbstring': |
|
10690
|
|
|
$info .= ' Overloading: ' . mb_get_info('func_overload') . "\n"; |
|
10691
|
|
|
break; |
|
10692
|
|
|
case 'iconv': |
|
10693
|
|
|
$info .= ' Version ' . ICONV_VERSION . "\n"; |
|
10694
|
|
|
break; |
|
10695
|
|
|
case 'xml': |
|
10696
|
|
|
$info .= ' Version ' . LIBXML_DOTTED_VERSION . "\n"; |
|
10697
|
|
|
break; |
|
10698
|
|
|
} |
|
10699
|
|
|
} |
|
10700
|
|
|
else |
|
10701
|
|
|
{ |
|
10702
|
|
|
$info .= " $ext not loaded\n"; |
|
10703
|
|
|
} |
|
10704
|
|
|
} |
|
10705
|
|
|
return $info; |
|
10706
|
|
|
} |
|
10707
|
|
|
public static function silence_errors($num, $str) |
|
10708
|
|
|
{ |
|
10709
|
|
|
// No-op |
|
10710
|
|
|
} |
|
10711
|
|
|
} |
|
10712
|
|
|
class SimplePie_Net_IPv6 |
|
10713
|
|
|
{ |
|
10714
|
|
|
|
|
10715
|
|
|
public static function uncompress($ip) |
|
10716
|
|
|
{ |
|
10717
|
|
|
$c1 = -1; |
|
10718
|
|
|
$c2 = -1; |
|
10719
|
|
|
if (substr_count($ip, '::') === 1) |
|
10720
|
|
|
{ |
|
10721
|
|
|
list($ip1, $ip2) = explode('::', $ip); |
|
10722
|
|
|
if ($ip1 === '') |
|
10723
|
|
|
{ |
|
10724
|
|
|
$c1 = -1; |
|
10725
|
|
|
} |
|
10726
|
|
|
else |
|
10727
|
|
|
{ |
|
10728
|
|
|
$c1 = substr_count($ip1, ':'); |
|
10729
|
|
|
} |
|
10730
|
|
|
if ($ip2 === '') |
|
10731
|
|
|
{ |
|
10732
|
|
|
$c2 = -1; |
|
10733
|
|
|
} |
|
10734
|
|
|
else |
|
10735
|
|
|
{ |
|
10736
|
|
|
$c2 = substr_count($ip2, ':'); |
|
10737
|
|
|
} |
|
10738
|
|
|
if (strpos($ip2, '.') !== false) |
|
10739
|
|
|
{ |
|
10740
|
|
|
$c2++; |
|
10741
|
|
|
} |
|
10742
|
|
|
// :: |
|
10743
|
|
|
if ($c1 === -1 && $c2 === -1) |
|
10744
|
|
|
{ |
|
10745
|
|
|
$ip = '0:0:0:0:0:0:0:0'; |
|
10746
|
|
|
} |
|
10747
|
|
|
// ::xxx |
|
10748
|
|
|
else if ($c1 === -1) |
|
10749
|
|
|
{ |
|
10750
|
|
|
$fill = str_repeat('0:', 7 - $c2); |
|
10751
|
|
|
$ip = str_replace('::', $fill, $ip); |
|
10752
|
|
|
} |
|
10753
|
|
|
// xxx:: |
|
10754
|
|
|
else if ($c2 === -1) |
|
10755
|
|
|
{ |
|
10756
|
|
|
$fill = str_repeat(':0', 7 - $c1); |
|
10757
|
|
|
$ip = str_replace('::', $fill, $ip); |
|
10758
|
|
|
} |
|
10759
|
|
|
// xxx::xxx |
|
10760
|
|
|
else |
|
10761
|
|
|
{ |
|
10762
|
|
|
$fill = ':' . str_repeat('0:', 6 - $c2 - $c1); |
|
10763
|
|
|
$ip = str_replace('::', $fill, $ip); |
|
10764
|
|
|
} |
|
10765
|
|
|
} |
|
10766
|
|
|
return $ip; |
|
10767
|
|
|
} |
|
10768
|
|
|
|
|
10769
|
|
|
public static function compress($ip) |
|
10770
|
|
|
{ |
|
10771
|
|
|
// Prepare the IP to be compressed |
|
10772
|
|
|
$ip = self::uncompress($ip); |
|
10773
|
|
|
$ip_parts = self::split_v6_v4($ip); |
|
10774
|
|
|
// Replace all leading zeros |
|
10775
|
|
|
$ip_parts[0] = preg_replace('/(^|:)0+([0-9])/', '\1\2', $ip_parts[0]); |
|
10776
|
|
|
// Find bunches of zeros |
|
10777
|
|
|
if (preg_match_all('/(?:^|:)(?:0(?::|$))+/', $ip_parts[0], $matches, PREG_OFFSET_CAPTURE)) |
|
10778
|
|
|
{ |
|
10779
|
|
|
$max = 0; |
|
10780
|
|
|
$pos = null; |
|
10781
|
|
|
foreach ($matches[0] as $match) |
|
10782
|
|
|
{ |
|
10783
|
|
|
if (strlen($match[0]) > $max) |
|
10784
|
|
|
{ |
|
10785
|
|
|
$max = strlen($match[0]); |
|
10786
|
|
|
$pos = $match[1]; |
|
10787
|
|
|
} |
|
10788
|
|
|
} |
|
10789
|
|
|
$ip_parts[0] = substr_replace($ip_parts[0], '::', $pos, $max); |
|
10790
|
|
|
} |
|
10791
|
|
|
if ($ip_parts[1] !== '') |
|
10792
|
|
|
{ |
|
10793
|
|
|
return implode(':', $ip_parts); |
|
10794
|
|
|
} |
|
10795
|
|
|
else |
|
10796
|
|
|
{ |
|
10797
|
|
|
return $ip_parts[0]; |
|
10798
|
|
|
} |
|
10799
|
|
|
} |
|
10800
|
|
|
|
|
10801
|
|
|
private static function split_v6_v4($ip) |
|
10802
|
|
|
{ |
|
10803
|
|
|
if (strpos($ip, '.') !== false) |
|
10804
|
|
|
{ |
|
10805
|
|
|
$pos = strrpos($ip, ':'); |
|
10806
|
|
|
$ipv6_part = substr($ip, 0, $pos); |
|
10807
|
|
|
$ipv4_part = substr($ip, $pos + 1); |
|
10808
|
|
|
return array($ipv6_part, $ipv4_part); |
|
10809
|
|
|
} |
|
10810
|
|
|
else |
|
10811
|
|
|
{ |
|
10812
|
|
|
return array($ip, ''); |
|
10813
|
|
|
} |
|
10814
|
|
|
} |
|
10815
|
|
|
|
|
10816
|
|
|
public static function check_ipv6($ip) |
|
10817
|
|
|
{ |
|
10818
|
|
|
$ip = self::uncompress($ip); |
|
10819
|
|
|
list($ipv6, $ipv4) = self::split_v6_v4($ip); |
|
10820
|
|
|
$ipv6 = explode(':', $ipv6); |
|
10821
|
|
|
$ipv4 = explode('.', $ipv4); |
|
10822
|
|
|
if (count($ipv6) === 8 && count($ipv4) === 1 || count($ipv6) === 6 && count($ipv4) === 4) |
|
10823
|
|
|
{ |
|
10824
|
|
|
foreach ($ipv6 as $ipv6_part) |
|
10825
|
|
|
{ |
|
10826
|
|
|
// The section can't be empty |
|
10827
|
|
|
if ($ipv6_part === '') |
|
10828
|
|
|
return false; |
|
10829
|
|
|
// Nor can it be over four characters |
|
10830
|
|
|
if (strlen($ipv6_part) > 4) |
|
10831
|
|
|
return false; |
|
10832
|
|
|
// Remove leading zeros (this is safe because of the above) |
|
10833
|
|
|
$ipv6_part = ltrim($ipv6_part, '0'); |
|
10834
|
|
|
if ($ipv6_part === '') |
|
10835
|
|
|
$ipv6_part = '0'; |
|
10836
|
|
|
// Check the value is valid |
|
10837
|
|
|
$value = hexdec($ipv6_part); |
|
10838
|
|
|
if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF) |
|
10839
|
|
|
return false; |
|
10840
|
|
|
} |
|
10841
|
|
|
if (count($ipv4) === 4) |
|
10842
|
|
|
{ |
|
10843
|
|
|
foreach ($ipv4 as $ipv4_part) |
|
10844
|
|
|
{ |
|
10845
|
|
|
$value = (int) $ipv4_part; |
|
10846
|
|
|
if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF) |
|
10847
|
|
|
return false; |
|
10848
|
|
|
} |
|
10849
|
|
|
} |
|
10850
|
|
|
return true; |
|
10851
|
|
|
} |
|
10852
|
|
|
else |
|
10853
|
|
|
{ |
|
10854
|
|
|
return false; |
|
10855
|
|
|
} |
|
10856
|
|
|
} |
|
10857
|
|
|
|
|
10858
|
|
|
public static function checkIPv6($ip) |
|
10859
|
|
|
{ |
|
10860
|
|
|
return self::check_ipv6($ip); |
|
10861
|
|
|
} |
|
10862
|
|
|
} |
|
10863
|
|
|
class SimplePie_Parse_Date |
|
10864
|
|
|
{ |
|
10865
|
|
|
|
|
10866
|
|
|
var $date; |
|
10867
|
|
|
|
|
10868
|
|
|
var $day = array( |
|
10869
|
|
|
// English |
|
10870
|
|
|
'mon' => 1, |
|
10871
|
|
|
'monday' => 1, |
|
10872
|
|
|
'tue' => 2, |
|
10873
|
|
|
'tuesday' => 2, |
|
10874
|
|
|
'wed' => 3, |
|
10875
|
|
|
'wednesday' => 3, |
|
10876
|
|
|
'thu' => 4, |
|
10877
|
|
|
'thursday' => 4, |
|
10878
|
|
|
'fri' => 5, |
|
10879
|
|
|
'friday' => 5, |
|
10880
|
|
|
'sat' => 6, |
|
10881
|
|
|
'saturday' => 6, |
|
10882
|
|
|
'sun' => 7, |
|
10883
|
|
|
'sunday' => 7, |
|
10884
|
|
|
// Dutch |
|
10885
|
|
|
'maandag' => 1, |
|
10886
|
|
|
'dinsdag' => 2, |
|
10887
|
|
|
'woensdag' => 3, |
|
10888
|
|
|
'donderdag' => 4, |
|
10889
|
|
|
'vrijdag' => 5, |
|
10890
|
|
|
'zaterdag' => 6, |
|
10891
|
|
|
'zondag' => 7, |
|
10892
|
|
|
// French |
|
10893
|
|
|
'lundi' => 1, |
|
10894
|
|
|
'mardi' => 2, |
|
10895
|
|
|
'mercredi' => 3, |
|
10896
|
|
|
'jeudi' => 4, |
|
10897
|
|
|
'vendredi' => 5, |
|
10898
|
|
|
'samedi' => 6, |
|
10899
|
|
|
'dimanche' => 7, |
|
10900
|
|
|
// German |
|
10901
|
|
|
'montag' => 1, |
|
10902
|
|
|
'dienstag' => 2, |
|
10903
|
|
|
'mittwoch' => 3, |
|
10904
|
|
|
'donnerstag' => 4, |
|
10905
|
|
|
'freitag' => 5, |
|
10906
|
|
|
'samstag' => 6, |
|
10907
|
|
|
'sonnabend' => 6, |
|
10908
|
|
|
'sonntag' => 7, |
|
10909
|
|
|
// Italian |
|
10910
|
|
|
'lunedì' => 1, |
|
10911
|
|
|
'martedì' => 2, |
|
10912
|
|
|
'mercoledì' => 3, |
|
10913
|
|
|
'giovedì' => 4, |
|
10914
|
|
|
'venerdì' => 5, |
|
10915
|
|
|
'sabato' => 6, |
|
10916
|
|
|
'domenica' => 7, |
|
10917
|
|
|
// Spanish |
|
10918
|
|
|
'lunes' => 1, |
|
10919
|
|
|
'martes' => 2, |
|
10920
|
|
|
'miércoles' => 3, |
|
10921
|
|
|
'jueves' => 4, |
|
10922
|
|
|
'viernes' => 5, |
|
10923
|
|
|
'sábado' => 6, |
|
10924
|
|
|
'domingo' => 7, |
|
10925
|
|
|
// Finnish |
|
10926
|
|
|
'maanantai' => 1, |
|
10927
|
|
|
'tiistai' => 2, |
|
10928
|
|
|
'keskiviikko' => 3, |
|
10929
|
|
|
'torstai' => 4, |
|
10930
|
|
|
'perjantai' => 5, |
|
10931
|
|
|
'lauantai' => 6, |
|
10932
|
|
|
'sunnuntai' => 7, |
|
10933
|
|
|
// Hungarian |
|
10934
|
|
|
'hétfő' => 1, |
|
10935
|
|
|
'kedd' => 2, |
|
10936
|
|
|
'szerda' => 3, |
|
10937
|
|
|
'csütörtok' => 4, |
|
10938
|
|
|
'péntek' => 5, |
|
10939
|
|
|
'szombat' => 6, |
|
10940
|
|
|
'vasárnap' => 7, |
|
10941
|
|
|
// Greek |
|
10942
|
|
|
'Δευ' => 1, |
|
10943
|
|
|
'Τρι' => 2, |
|
10944
|
|
|
'Τετ' => 3, |
|
10945
|
|
|
'Πεμ' => 4, |
|
10946
|
|
|
'Παρ' => 5, |
|
10947
|
|
|
'Σαβ' => 6, |
|
10948
|
|
|
'Κυρ' => 7, |
|
10949
|
|
|
); |
|
10950
|
|
|
|
|
10951
|
|
|
var $month = array( |
|
10952
|
|
|
// English |
|
10953
|
|
|
'jan' => 1, |
|
10954
|
|
|
'january' => 1, |
|
10955
|
|
|
'feb' => 2, |
|
10956
|
|
|
'february' => 2, |
|
10957
|
|
|
'mar' => 3, |
|
10958
|
|
|
'march' => 3, |
|
10959
|
|
|
'apr' => 4, |
|
10960
|
|
|
'april' => 4, |
|
10961
|
|
|
'may' => 5, |
|
10962
|
|
|
// No long form of May |
|
10963
|
|
|
'jun' => 6, |
|
10964
|
|
|
'june' => 6, |
|
10965
|
|
|
'jul' => 7, |
|
10966
|
|
|
'july' => 7, |
|
10967
|
|
|
'aug' => 8, |
|
10968
|
|
|
'august' => 8, |
|
10969
|
|
|
'sep' => 9, |
|
10970
|
|
|
'september' => 8, |
|
10971
|
|
|
'oct' => 10, |
|
10972
|
|
|
'october' => 10, |
|
10973
|
|
|
'nov' => 11, |
|
10974
|
|
|
'november' => 11, |
|
10975
|
|
|
'dec' => 12, |
|
10976
|
|
|
'december' => 12, |
|
10977
|
|
|
// Dutch |
|
10978
|
|
|
'januari' => 1, |
|
10979
|
|
|
'februari' => 2, |
|
10980
|
|
|
'maart' => 3, |
|
10981
|
|
|
'april' => 4, |
|
10982
|
|
|
'mei' => 5, |
|
10983
|
|
|
'juni' => 6, |
|
10984
|
|
|
'juli' => 7, |
|
10985
|
|
|
'augustus' => 8, |
|
10986
|
|
|
'september' => 9, |
|
10987
|
|
|
'oktober' => 10, |
|
10988
|
|
|
'november' => 11, |
|
10989
|
|
|
'december' => 12, |
|
10990
|
|
|
// French |
|
10991
|
|
|
'janvier' => 1, |
|
10992
|
|
|
'février' => 2, |
|
10993
|
|
|
'mars' => 3, |
|
10994
|
|
|
'avril' => 4, |
|
10995
|
|
|
'mai' => 5, |
|
10996
|
|
|
'juin' => 6, |
|
10997
|
|
|
'juillet' => 7, |
|
10998
|
|
|
'août' => 8, |
|
10999
|
|
|
'septembre' => 9, |
|
11000
|
|
|
'octobre' => 10, |
|
11001
|
|
|
'novembre' => 11, |
|
11002
|
|
|
'décembre' => 12, |
|
11003
|
|
|
// German |
|
11004
|
|
|
'januar' => 1, |
|
11005
|
|
|
'februar' => 2, |
|
11006
|
|
|
'märz' => 3, |
|
11007
|
|
|
'april' => 4, |
|
11008
|
|
|
'mai' => 5, |
|
11009
|
|
|
'juni' => 6, |
|
11010
|
|
|
'juli' => 7, |
|
11011
|
|
|
'august' => 8, |
|
11012
|
|
|
'september' => 9, |
|
11013
|
|
|
'oktober' => 10, |
|
11014
|
|
|
'november' => 11, |
|
11015
|
|
|
'dezember' => 12, |
|
11016
|
|
|
// Italian |
|
11017
|
|
|
'gennaio' => 1, |
|
11018
|
|
|
'febbraio' => 2, |
|
11019
|
|
|
'marzo' => 3, |
|
11020
|
|
|
'aprile' => 4, |
|
11021
|
|
|
'maggio' => 5, |
|
11022
|
|
|
'giugno' => 6, |
|
11023
|
|
|
'luglio' => 7, |
|
11024
|
|
|
'agosto' => 8, |
|
11025
|
|
|
'settembre' => 9, |
|
11026
|
|
|
'ottobre' => 10, |
|
11027
|
|
|
'novembre' => 11, |
|
11028
|
|
|
'dicembre' => 12, |
|
11029
|
|
|
// Spanish |
|
11030
|
|
|
'enero' => 1, |
|
11031
|
|
|
'febrero' => 2, |
|
11032
|
|
|
'marzo' => 3, |
|
11033
|
|
|
'abril' => 4, |
|
11034
|
|
|
'mayo' => 5, |
|
11035
|
|
|
'junio' => 6, |
|
11036
|
|
|
'julio' => 7, |
|
11037
|
|
|
'agosto' => 8, |
|
11038
|
|
|
'septiembre' => 9, |
|
11039
|
|
|
'setiembre' => 9, |
|
11040
|
|
|
'octubre' => 10, |
|
11041
|
|
|
'noviembre' => 11, |
|
11042
|
|
|
'diciembre' => 12, |
|
11043
|
|
|
// Finnish |
|
11044
|
|
|
'tammikuu' => 1, |
|
11045
|
|
|
'helmikuu' => 2, |
|
11046
|
|
|
'maaliskuu' => 3, |
|
11047
|
|
|
'huhtikuu' => 4, |
|
11048
|
|
|
'toukokuu' => 5, |
|
11049
|
|
|
'kesäkuu' => 6, |
|
11050
|
|
|
'heinäkuu' => 7, |
|
11051
|
|
|
'elokuu' => 8, |
|
11052
|
|
|
'suuskuu' => 9, |
|
11053
|
|
|
'lokakuu' => 10, |
|
11054
|
|
|
'marras' => 11, |
|
11055
|
|
|
'joulukuu' => 12, |
|
11056
|
|
|
// Hungarian |
|
11057
|
|
|
'január' => 1, |
|
11058
|
|
|
'február' => 2, |
|
11059
|
|
|
'március' => 3, |
|
11060
|
|
|
'április' => 4, |
|
11061
|
|
|
'május' => 5, |
|
11062
|
|
|
'június' => 6, |
|
11063
|
|
|
'július' => 7, |
|
11064
|
|
|
'augusztus' => 8, |
|
11065
|
|
|
'szeptember' => 9, |
|
11066
|
|
|
'október' => 10, |
|
11067
|
|
|
'november' => 11, |
|
11068
|
|
|
'december' => 12, |
|
11069
|
|
|
// Greek |
|
11070
|
|
|
'Ιαν' => 1, |
|
11071
|
|
|
'Φεβ' => 2, |
|
11072
|
|
|
'Μάώ' => 3, |
|
11073
|
|
|
'Μαώ' => 3, |
|
11074
|
|
|
'Απρ' => 4, |
|
11075
|
|
|
'Μάι' => 5, |
|
11076
|
|
|
'Μαϊ' => 5, |
|
11077
|
|
|
'Μαι' => 5, |
|
11078
|
|
|
'Ιούν' => 6, |
|
11079
|
|
|
'Ιον' => 6, |
|
11080
|
|
|
'Ιούλ' => 7, |
|
11081
|
|
|
'Ιολ' => 7, |
|
11082
|
|
|
'Αύγ' => 8, |
|
11083
|
|
|
'Αυγ' => 8, |
|
11084
|
|
|
'Σεπ' => 9, |
|
11085
|
|
|
'Οκτ' => 10, |
|
11086
|
|
|
'Νοέ' => 11, |
|
11087
|
|
|
'Δεκ' => 12, |
|
11088
|
|
|
); |
|
11089
|
|
|
|
|
11090
|
|
|
var $timezone = array( |
|
11091
|
|
|
'ACDT' => 37800, |
|
11092
|
|
|
'ACIT' => 28800, |
|
11093
|
|
|
'ACST' => 34200, |
|
11094
|
|
|
'ACT' => -18000, |
|
11095
|
|
|
'ACWDT' => 35100, |
|
11096
|
|
|
'ACWST' => 31500, |
|
11097
|
|
|
'AEDT' => 39600, |
|
11098
|
|
|
'AEST' => 36000, |
|
11099
|
|
|
'AFT' => 16200, |
|
11100
|
|
|
'AKDT' => -28800, |
|
11101
|
|
|
'AKST' => -32400, |
|
11102
|
|
|
'AMDT' => 18000, |
|
11103
|
|
|
'AMT' => -14400, |
|
11104
|
|
|
'ANAST' => 46800, |
|
11105
|
|
|
'ANAT' => 43200, |
|
11106
|
|
|
'ART' => -10800, |
|
11107
|
|
|
'AZOST' => -3600, |
|
11108
|
|
|
'AZST' => 18000, |
|
11109
|
|
|
'AZT' => 14400, |
|
11110
|
|
|
'BIOT' => 21600, |
|
11111
|
|
|
'BIT' => -43200, |
|
11112
|
|
|
'BOT' => -14400, |
|
11113
|
|
|
'BRST' => -7200, |
|
11114
|
|
|
'BRT' => -10800, |
|
11115
|
|
|
'BST' => 3600, |
|
11116
|
|
|
'BTT' => 21600, |
|
11117
|
|
|
'CAST' => 18000, |
|
11118
|
|
|
'CAT' => 7200, |
|
11119
|
|
|
'CCT' => 23400, |
|
11120
|
|
|
'CDT' => -18000, |
|
11121
|
|
|
'CEDT' => 7200, |
|
11122
|
|
|
'CET' => 3600, |
|
11123
|
|
|
'CGST' => -7200, |
|
11124
|
|
|
'CGT' => -10800, |
|
11125
|
|
|
'CHADT' => 49500, |
|
11126
|
|
|
'CHAST' => 45900, |
|
11127
|
|
|
'CIST' => -28800, |
|
11128
|
|
|
'CKT' => -36000, |
|
11129
|
|
|
'CLDT' => -10800, |
|
11130
|
|
|
'CLST' => -14400, |
|
11131
|
|
|
'COT' => -18000, |
|
11132
|
|
|
'CST' => -21600, |
|
11133
|
|
|
'CVT' => -3600, |
|
11134
|
|
|
'CXT' => 25200, |
|
11135
|
|
|
'DAVT' => 25200, |
|
11136
|
|
|
'DTAT' => 36000, |
|
11137
|
|
|
'EADT' => -18000, |
|
11138
|
|
|
'EAST' => -21600, |
|
11139
|
|
|
'EAT' => 10800, |
|
11140
|
|
|
'ECT' => -18000, |
|
11141
|
|
|
'EDT' => -14400, |
|
11142
|
|
|
'EEST' => 10800, |
|
11143
|
|
|
'EET' => 7200, |
|
11144
|
|
|
'EGT' => -3600, |
|
11145
|
|
|
'EKST' => 21600, |
|
11146
|
|
|
'EST' => -18000, |
|
11147
|
|
|
'FJT' => 43200, |
|
11148
|
|
|
'FKDT' => -10800, |
|
11149
|
|
|
'FKST' => -14400, |
|
11150
|
|
|
'FNT' => -7200, |
|
11151
|
|
|
'GALT' => -21600, |
|
11152
|
|
|
'GEDT' => 14400, |
|
11153
|
|
|
'GEST' => 10800, |
|
11154
|
|
|
'GFT' => -10800, |
|
11155
|
|
|
'GILT' => 43200, |
|
11156
|
|
|
'GIT' => -32400, |
|
11157
|
|
|
'GST' => 14400, |
|
11158
|
|
|
'GST' => -7200, |
|
11159
|
|
|
'GYT' => -14400, |
|
11160
|
|
|
'HAA' => -10800, |
|
11161
|
|
|
'HAC' => -18000, |
|
11162
|
|
|
'HADT' => -32400, |
|
11163
|
|
|
'HAE' => -14400, |
|
11164
|
|
|
'HAP' => -25200, |
|
11165
|
|
|
'HAR' => -21600, |
|
11166
|
|
|
'HAST' => -36000, |
|
11167
|
|
|
'HAT' => -9000, |
|
11168
|
|
|
'HAY' => -28800, |
|
11169
|
|
|
'HKST' => 28800, |
|
11170
|
|
|
'HMT' => 18000, |
|
11171
|
|
|
'HNA' => -14400, |
|
11172
|
|
|
'HNC' => -21600, |
|
11173
|
|
|
'HNE' => -18000, |
|
11174
|
|
|
'HNP' => -28800, |
|
11175
|
|
|
'HNR' => -25200, |
|
11176
|
|
|
'HNT' => -12600, |
|
11177
|
|
|
'HNY' => -32400, |
|
11178
|
|
|
'IRDT' => 16200, |
|
11179
|
|
|
'IRKST' => 32400, |
|
11180
|
|
|
'IRKT' => 28800, |
|
11181
|
|
|
'IRST' => 12600, |
|
11182
|
|
|
'JFDT' => -10800, |
|
11183
|
|
|
'JFST' => -14400, |
|
11184
|
|
|
'JST' => 32400, |
|
11185
|
|
|
'KGST' => 21600, |
|
11186
|
|
|
'KGT' => 18000, |
|
11187
|
|
|
'KOST' => 39600, |
|
11188
|
|
|
'KOVST' => 28800, |
|
11189
|
|
|
'KOVT' => 25200, |
|
11190
|
|
|
'KRAST' => 28800, |
|
11191
|
|
|
'KRAT' => 25200, |
|
11192
|
|
|
'KST' => 32400, |
|
11193
|
|
|
'LHDT' => 39600, |
|
11194
|
|
|
'LHST' => 37800, |
|
11195
|
|
|
'LINT' => 50400, |
|
11196
|
|
|
'LKT' => 21600, |
|
11197
|
|
|
'MAGST' => 43200, |
|
11198
|
|
|
'MAGT' => 39600, |
|
11199
|
|
|
'MAWT' => 21600, |
|
11200
|
|
|
'MDT' => -21600, |
|
11201
|
|
|
'MESZ' => 7200, |
|
11202
|
|
|
'MEZ' => 3600, |
|
11203
|
|
|
'MHT' => 43200, |
|
11204
|
|
|
'MIT' => -34200, |
|
11205
|
|
|
'MNST' => 32400, |
|
11206
|
|
|
'MSDT' => 14400, |
|
11207
|
|
|
'MSST' => 10800, |
|
11208
|
|
|
'MST' => -25200, |
|
11209
|
|
|
'MUT' => 14400, |
|
11210
|
|
|
'MVT' => 18000, |
|
11211
|
|
|
'MYT' => 28800, |
|
11212
|
|
|
'NCT' => 39600, |
|
11213
|
|
|
'NDT' => -9000, |
|
11214
|
|
|
'NFT' => 41400, |
|
11215
|
|
|
'NMIT' => 36000, |
|
11216
|
|
|
'NOVST' => 25200, |
|
11217
|
|
|
'NOVT' => 21600, |
|
11218
|
|
|
'NPT' => 20700, |
|
11219
|
|
|
'NRT' => 43200, |
|
11220
|
|
|
'NST' => -12600, |
|
11221
|
|
|
'NUT' => -39600, |
|
11222
|
|
|
'NZDT' => 46800, |
|
11223
|
|
|
'NZST' => 43200, |
|
11224
|
|
|
'OMSST' => 25200, |
|
11225
|
|
|
'OMST' => 21600, |
|
11226
|
|
|
'PDT' => -25200, |
|
11227
|
|
|
'PET' => -18000, |
|
11228
|
|
|
'PETST' => 46800, |
|
11229
|
|
|
'PETT' => 43200, |
|
11230
|
|
|
'PGT' => 36000, |
|
11231
|
|
|
'PHOT' => 46800, |
|
11232
|
|
|
'PHT' => 28800, |
|
11233
|
|
|
'PKT' => 18000, |
|
11234
|
|
|
'PMDT' => -7200, |
|
11235
|
|
|
'PMST' => -10800, |
|
11236
|
|
|
'PONT' => 39600, |
|
11237
|
|
|
'PST' => -28800, |
|
11238
|
|
|
'PWT' => 32400, |
|
11239
|
|
|
'PYST' => -10800, |
|
11240
|
|
|
'PYT' => -14400, |
|
11241
|
|
|
'RET' => 14400, |
|
11242
|
|
|
'ROTT' => -10800, |
|
11243
|
|
|
'SAMST' => 18000, |
|
11244
|
|
|
'SAMT' => 14400, |
|
11245
|
|
|
'SAST' => 7200, |
|
11246
|
|
|
'SBT' => 39600, |
|
11247
|
|
|
'SCDT' => 46800, |
|
11248
|
|
|
'SCST' => 43200, |
|
11249
|
|
|
'SCT' => 14400, |
|
11250
|
|
|
'SEST' => 3600, |
|
11251
|
|
|
'SGT' => 28800, |
|
11252
|
|
|
'SIT' => 28800, |
|
11253
|
|
|
'SRT' => -10800, |
|
11254
|
|
|
'SST' => -39600, |
|
11255
|
|
|
'SYST' => 10800, |
|
11256
|
|
|
'SYT' => 7200, |
|
11257
|
|
|
'TFT' => 18000, |
|
11258
|
|
|
'THAT' => -36000, |
|
11259
|
|
|
'TJT' => 18000, |
|
11260
|
|
|
'TKT' => -36000, |
|
11261
|
|
|
'TMT' => 18000, |
|
11262
|
|
|
'TOT' => 46800, |
|
11263
|
|
|
'TPT' => 32400, |
|
11264
|
|
|
'TRUT' => 36000, |
|
11265
|
|
|
'TVT' => 43200, |
|
11266
|
|
|
'TWT' => 28800, |
|
11267
|
|
|
'UYST' => -7200, |
|
11268
|
|
|
'UYT' => -10800, |
|
11269
|
|
|
'UZT' => 18000, |
|
11270
|
|
|
'VET' => -14400, |
|
11271
|
|
|
'VLAST' => 39600, |
|
11272
|
|
|
'VLAT' => 36000, |
|
11273
|
|
|
'VOST' => 21600, |
|
11274
|
|
|
'VUT' => 39600, |
|
11275
|
|
|
'WAST' => 7200, |
|
11276
|
|
|
'WAT' => 3600, |
|
11277
|
|
|
'WDT' => 32400, |
|
11278
|
|
|
'WEST' => 3600, |
|
11279
|
|
|
'WFT' => 43200, |
|
11280
|
|
|
'WIB' => 25200, |
|
11281
|
|
|
'WIT' => 32400, |
|
11282
|
|
|
'WITA' => 28800, |
|
11283
|
|
|
'WKST' => 18000, |
|
11284
|
|
|
'WST' => 28800, |
|
11285
|
|
|
'YAKST' => 36000, |
|
11286
|
|
|
'YAKT' => 32400, |
|
11287
|
|
|
'YAPT' => 36000, |
|
11288
|
|
|
'YEKST' => 21600, |
|
11289
|
|
|
'YEKT' => 18000, |
|
11290
|
|
|
); |
|
11291
|
|
|
|
|
11292
|
|
|
var $day_pcre; |
|
11293
|
|
|
|
|
11294
|
|
|
var $month_pcre; |
|
11295
|
|
|
|
|
11296
|
|
|
var $built_in = array(); |
|
11297
|
|
|
|
|
11298
|
|
|
var $user = array(); |
|
11299
|
|
|
|
|
11300
|
|
|
public function __construct() |
|
11301
|
|
|
{ |
|
11302
|
|
|
$this->day_pcre = '(' . implode(array_keys($this->day), '|') . ')'; |
|
11303
|
|
|
$this->month_pcre = '(' . implode(array_keys($this->month), '|') . ')'; |
|
11304
|
|
|
static $cache; |
|
11305
|
|
|
if (!isset($cache[get_class($this)])) |
|
11306
|
|
|
{ |
|
11307
|
|
|
$all_methods = get_class_methods($this); |
|
11308
|
|
|
foreach ($all_methods as $method) |
|
11309
|
|
|
{ |
|
11310
|
|
|
if (strtolower(substr($method, 0, 5)) === 'date_') |
|
11311
|
|
|
{ |
|
11312
|
|
|
$cache[get_class($this)][] = $method; |
|
11313
|
|
|
} |
|
11314
|
|
|
} |
|
11315
|
|
|
} |
|
11316
|
|
|
foreach ($cache[get_class($this)] as $method) |
|
11317
|
|
|
{ |
|
11318
|
|
|
$this->built_in[] = $method; |
|
11319
|
|
|
} |
|
11320
|
|
|
} |
|
11321
|
|
|
|
|
11322
|
|
|
public static function get() |
|
11323
|
|
|
{ |
|
11324
|
|
|
static $object; |
|
11325
|
|
|
if (!$object) |
|
11326
|
|
|
{ |
|
11327
|
|
|
$object = new SimplePie_Parse_Date; |
|
11328
|
|
|
} |
|
11329
|
|
|
return $object; |
|
11330
|
|
|
} |
|
11331
|
|
|
|
|
11332
|
|
|
public function parse($date) |
|
11333
|
|
|
{ |
|
11334
|
|
|
foreach ($this->user as $method) |
|
11335
|
|
|
{ |
|
11336
|
|
|
if (($returned = call_user_func($method, $date)) !== false) |
|
11337
|
|
|
{ |
|
11338
|
|
|
return $returned; |
|
11339
|
|
|
} |
|
11340
|
|
|
} |
|
11341
|
|
|
foreach ($this->built_in as $method) |
|
11342
|
|
|
{ |
|
11343
|
|
|
if (($returned = call_user_func(array($this, $method), $date)) !== false) |
|
11344
|
|
|
{ |
|
11345
|
|
|
return $returned; |
|
11346
|
|
|
} |
|
11347
|
|
|
} |
|
11348
|
|
|
return false; |
|
11349
|
|
|
} |
|
11350
|
|
|
|
|
11351
|
|
|
public function add_callback($callback) |
|
11352
|
|
|
{ |
|
11353
|
|
|
if (is_callable($callback)) |
|
11354
|
|
|
{ |
|
11355
|
|
|
$this->user[] = $callback; |
|
11356
|
|
|
} |
|
11357
|
|
|
else |
|
11358
|
|
|
{ |
|
11359
|
|
|
trigger_error('User-supplied function must be a valid callback', E_USER_WARNING); |
|
11360
|
|
|
} |
|
11361
|
|
|
} |
|
11362
|
|
|
|
|
11363
|
|
|
public function date_w3cdtf($date) |
|
11364
|
|
|
{ |
|
11365
|
|
|
static $pcre; |
|
11366
|
|
|
if (!$pcre) |
|
11367
|
|
|
{ |
|
11368
|
|
|
$year = '([0-9]{4})'; |
|
11369
|
|
|
$month = $day = $hour = $minute = $second = '([0-9]{2})'; |
|
11370
|
|
|
$decimal = '([0-9]*)'; |
|
11371
|
|
|
$zone = '(?:(Z)|([+\-])([0-9]{1,2}):?([0-9]{1,2}))'; |
|
11372
|
|
|
$pcre = '/^' . $year . '(?:-?' . $month . '(?:-?' . $day . '(?:[Tt\x09\x20]+' . $hour . '(?::?' . $minute . '(?::?' . $second . '(?:.' . $decimal . ')?)?)?' . $zone . ')?)?)?$/'; |
|
11373
|
|
|
} |
|
11374
|
|
|
if (preg_match($pcre, $date, $match)) |
|
11375
|
|
|
{ |
|
11376
|
|
|
/* |
|
11377
|
|
|
Capturing subpatterns: |
|
11378
|
|
|
1: Year |
|
11379
|
|
|
2: Month |
|
11380
|
|
|
3: Day |
|
11381
|
|
|
4: Hour |
|
11382
|
|
|
5: Minute |
|
11383
|
|
|
6: Second |
|
11384
|
|
|
7: Decimal fraction of a second |
|
11385
|
|
|
8: Zulu |
|
11386
|
|
|
9: Timezone ± |
|
11387
|
|
|
10: Timezone hours |
|
11388
|
|
|
11: Timezone minutes |
|
11389
|
|
|
*/ |
|
11390
|
|
|
// Fill in empty matches |
|
11391
|
|
|
for ($i = count($match); $i <= 3; $i++) |
|
11392
|
|
|
{ |
|
11393
|
|
|
$match[$i] = '1'; |
|
11394
|
|
|
} |
|
11395
|
|
|
for ($i = count($match); $i <= 7; $i++) |
|
11396
|
|
|
{ |
|
11397
|
|
|
$match[$i] = '0'; |
|
11398
|
|
|
} |
|
11399
|
|
|
// Numeric timezone |
|
11400
|
|
|
if (isset($match[9]) && $match[9] !== '') |
|
11401
|
|
|
{ |
|
11402
|
|
|
$timezone = $match[10] * 3600; |
|
11403
|
|
|
$timezone += $match[11] * 60; |
|
11404
|
|
|
if ($match[9] === '-') |
|
11405
|
|
|
{ |
|
11406
|
|
|
$timezone = 0 - $timezone; |
|
11407
|
|
|
} |
|
11408
|
|
|
} |
|
11409
|
|
|
else |
|
11410
|
|
|
{ |
|
11411
|
|
|
$timezone = 0; |
|
11412
|
|
|
} |
|
11413
|
|
|
// Convert the number of seconds to an integer, taking decimals into account |
|
11414
|
|
|
$second = round($match[6] + $match[7] / pow(10, strlen($match[7]))); |
|
11415
|
|
|
return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone; |
|
11416
|
|
|
} |
|
11417
|
|
|
else |
|
11418
|
|
|
{ |
|
11419
|
|
|
return false; |
|
11420
|
|
|
} |
|
11421
|
|
|
} |
|
11422
|
|
|
|
|
11423
|
|
|
public function remove_rfc2822_comments($string) |
|
11424
|
|
|
{ |
|
11425
|
|
|
$string = (string) $string; |
|
11426
|
|
|
$position = 0; |
|
11427
|
|
|
$length = strlen($string); |
|
11428
|
|
|
$depth = 0; |
|
11429
|
|
|
$output = ''; |
|
11430
|
|
|
while ($position < $length && ($pos = strpos($string, '(', $position)) !== false) |
|
11431
|
|
|
{ |
|
11432
|
|
|
$output .= substr($string, $position, $pos - $position); |
|
11433
|
|
|
$position = $pos + 1; |
|
11434
|
|
|
if ($string[$pos - 1] !== '\\') |
|
11435
|
|
|
{ |
|
11436
|
|
|
$depth++; |
|
11437
|
|
|
while ($depth && $position < $length) |
|
11438
|
|
|
{ |
|
11439
|
|
|
$position += strcspn($string, '()', $position); |
|
11440
|
|
|
if ($string[$position - 1] === '\\') |
|
11441
|
|
|
{ |
|
11442
|
|
|
$position++; |
|
11443
|
|
|
continue; |
|
11444
|
|
|
} |
|
11445
|
|
|
elseif (isset($string[$position])) |
|
11446
|
|
|
{ |
|
11447
|
|
|
switch ($string[$position]) |
|
11448
|
|
|
{ |
|
11449
|
|
|
case '(': |
|
11450
|
|
|
$depth++; |
|
11451
|
|
|
break; |
|
11452
|
|
|
case ')': |
|
11453
|
|
|
$depth--; |
|
11454
|
|
|
break; |
|
11455
|
|
|
} |
|
11456
|
|
|
$position++; |
|
11457
|
|
|
} |
|
11458
|
|
|
else |
|
11459
|
|
|
{ |
|
11460
|
|
|
break; |
|
11461
|
|
|
} |
|
11462
|
|
|
} |
|
11463
|
|
|
} |
|
11464
|
|
|
else |
|
11465
|
|
|
{ |
|
11466
|
|
|
$output .= '('; |
|
11467
|
|
|
} |
|
11468
|
|
|
} |
|
11469
|
|
|
$output .= substr($string, $position); |
|
11470
|
|
|
return $output; |
|
11471
|
|
|
} |
|
11472
|
|
|
|
|
11473
|
|
|
public function date_rfc2822($date) |
|
11474
|
|
|
{ |
|
11475
|
|
|
static $pcre; |
|
11476
|
|
|
if (!$pcre) |
|
11477
|
|
|
{ |
|
11478
|
|
|
$wsp = '[\x09\x20]'; |
|
11479
|
|
|
$fws = '(?:' . $wsp . '+|' . $wsp . '*(?:\x0D\x0A' . $wsp . '+)+)'; |
|
11480
|
|
|
$optional_fws = $fws . '?'; |
|
11481
|
|
|
$day_name = $this->day_pcre; |
|
11482
|
|
|
$month = $this->month_pcre; |
|
11483
|
|
|
$day = '([0-9]{1,2})'; |
|
11484
|
|
|
$hour = $minute = $second = '([0-9]{2})'; |
|
11485
|
|
|
$year = '([0-9]{2,4})'; |
|
11486
|
|
|
$num_zone = '([+\-])([0-9]{2})([0-9]{2})'; |
|
11487
|
|
|
$character_zone = '([A-Z]{1,5})'; |
|
11488
|
|
|
$zone = '(?:' . $num_zone . '|' . $character_zone . ')'; |
|
11489
|
|
|
$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'; |
|
11490
|
|
|
} |
|
11491
|
|
|
if (preg_match($pcre, $this->remove_rfc2822_comments($date), $match)) |
|
11492
|
|
|
{ |
|
11493
|
|
|
/* |
|
11494
|
|
|
Capturing subpatterns: |
|
11495
|
|
|
1: Day name |
|
11496
|
|
|
2: Day |
|
11497
|
|
|
3: Month |
|
11498
|
|
|
4: Year |
|
11499
|
|
|
5: Hour |
|
11500
|
|
|
6: Minute |
|
11501
|
|
|
7: Second |
|
11502
|
|
|
8: Timezone ± |
|
11503
|
|
|
9: Timezone hours |
|
11504
|
|
|
10: Timezone minutes |
|
11505
|
|
|
11: Alphabetic timezone |
|
11506
|
|
|
*/ |
|
11507
|
|
|
// Find the month number |
|
11508
|
|
|
$month = $this->month[strtolower($match[3])]; |
|
11509
|
|
|
// Numeric timezone |
|
11510
|
|
|
if ($match[8] !== '') |
|
11511
|
|
|
{ |
|
11512
|
|
|
$timezone = $match[9] * 3600; |
|
11513
|
|
|
$timezone += $match[10] * 60; |
|
11514
|
|
|
if ($match[8] === '-') |
|
11515
|
|
|
{ |
|
11516
|
|
|
$timezone = 0 - $timezone; |
|
11517
|
|
|
} |
|
11518
|
|
|
} |
|
11519
|
|
|
// Character timezone |
|
11520
|
|
|
elseif (isset($this->timezone[strtoupper($match[11])])) |
|
11521
|
|
|
{ |
|
11522
|
|
|
$timezone = $this->timezone[strtoupper($match[11])]; |
|
11523
|
|
|
} |
|
11524
|
|
|
// Assume everything else to be -0000 |
|
11525
|
|
|
else |
|
11526
|
|
|
{ |
|
11527
|
|
|
$timezone = 0; |
|
11528
|
|
|
} |
|
11529
|
|
|
// Deal with 2/3 digit years |
|
11530
|
|
|
if ($match[4] < 50) |
|
11531
|
|
|
{ |
|
11532
|
|
|
$match[4] += 2000; |
|
11533
|
|
|
} |
|
11534
|
|
|
elseif ($match[4] < 1000) |
|
11535
|
|
|
{ |
|
11536
|
|
|
$match[4] += 1900; |
|
11537
|
|
|
} |
|
11538
|
|
|
// Second is optional, if it is empty set it to zero |
|
11539
|
|
|
if ($match[7] !== '') |
|
11540
|
|
|
{ |
|
11541
|
|
|
$second = $match[7]; |
|
11542
|
|
|
} |
|
11543
|
|
|
else |
|
11544
|
|
|
{ |
|
11545
|
|
|
$second = 0; |
|
11546
|
|
|
} |
|
11547
|
|
|
return gmmktime($match[5], $match[6], $second, $month, $match[2], $match[4]) - $timezone; |
|
11548
|
|
|
} |
|
11549
|
|
|
else |
|
11550
|
|
|
{ |
|
11551
|
|
|
return false; |
|
11552
|
|
|
} |
|
11553
|
|
|
} |
|
11554
|
|
|
|
|
11555
|
|
|
public function date_rfc850($date) |
|
11556
|
|
|
{ |
|
11557
|
|
|
static $pcre; |
|
11558
|
|
|
if (!$pcre) |
|
11559
|
|
|
{ |
|
11560
|
|
|
$space = '[\x09\x20]+'; |
|
11561
|
|
|
$day_name = $this->day_pcre; |
|
11562
|
|
|
$month = $this->month_pcre; |
|
11563
|
|
|
$day = '([0-9]{1,2})'; |
|
11564
|
|
|
$year = $hour = $minute = $second = '([0-9]{2})'; |
|
11565
|
|
|
$zone = '([A-Z]{1,5})'; |
|
11566
|
|
|
$pcre = '/^' . $day_name . ',' . $space . $day . '-' . $month . '-' . $year . $space . $hour . ':' . $minute . ':' . $second . $space . $zone . '$/i'; |
|
11567
|
|
|
} |
|
11568
|
|
|
if (preg_match($pcre, $date, $match)) |
|
11569
|
|
|
{ |
|
11570
|
|
|
/* |
|
11571
|
|
|
Capturing subpatterns: |
|
11572
|
|
|
1: Day name |
|
11573
|
|
|
2: Day |
|
11574
|
|
|
3: Month |
|
11575
|
|
|
4: Year |
|
11576
|
|
|
5: Hour |
|
11577
|
|
|
6: Minute |
|
11578
|
|
|
7: Second |
|
11579
|
|
|
8: Timezone |
|
11580
|
|
|
*/ |
|
11581
|
|
|
// Month |
|
11582
|
|
|
$month = $this->month[strtolower($match[3])]; |
|
11583
|
|
|
// Character timezone |
|
11584
|
|
|
if (isset($this->timezone[strtoupper($match[8])])) |
|
11585
|
|
|
{ |
|
11586
|
|
|
$timezone = $this->timezone[strtoupper($match[8])]; |
|
11587
|
|
|
} |
|
11588
|
|
|
// Assume everything else to be -0000 |
|
11589
|
|
|
else |
|
11590
|
|
|
{ |
|
11591
|
|
|
$timezone = 0; |
|
11592
|
|
|
} |
|
11593
|
|
|
// Deal with 2 digit year |
|
11594
|
|
|
if ($match[4] < 50) |
|
11595
|
|
|
{ |
|
11596
|
|
|
$match[4] += 2000; |
|
11597
|
|
|
} |
|
11598
|
|
|
else |
|
11599
|
|
|
{ |
|
11600
|
|
|
$match[4] += 1900; |
|
11601
|
|
|
} |
|
11602
|
|
|
return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone; |
|
11603
|
|
|
} |
|
11604
|
|
|
else |
|
11605
|
|
|
{ |
|
11606
|
|
|
return false; |
|
11607
|
|
|
} |
|
11608
|
|
|
} |
|
11609
|
|
|
|
|
11610
|
|
|
public function date_asctime($date) |
|
11611
|
|
|
{ |
|
11612
|
|
|
static $pcre; |
|
11613
|
|
|
if (!$pcre) |
|
11614
|
|
|
{ |
|
11615
|
|
|
$space = '[\x09\x20]+'; |
|
11616
|
|
|
$wday_name = $this->day_pcre; |
|
11617
|
|
|
$mon_name = $this->month_pcre; |
|
11618
|
|
|
$day = '([0-9]{1,2})'; |
|
11619
|
|
|
$hour = $sec = $min = '([0-9]{2})'; |
|
11620
|
|
|
$year = '([0-9]{4})'; |
|
11621
|
|
|
$terminator = '\x0A?\x00?'; |
|
11622
|
|
|
$pcre = '/^' . $wday_name . $space . $mon_name . $space . $day . $space . $hour . ':' . $min . ':' . $sec . $space . $year . $terminator . '$/i'; |
|
11623
|
|
|
} |
|
11624
|
|
|
if (preg_match($pcre, $date, $match)) |
|
11625
|
|
|
{ |
|
11626
|
|
|
/* |
|
11627
|
|
|
Capturing subpatterns: |
|
11628
|
|
|
1: Day name |
|
11629
|
|
|
2: Month |
|
11630
|
|
|
3: Day |
|
11631
|
|
|
4: Hour |
|
11632
|
|
|
5: Minute |
|
11633
|
|
|
6: Second |
|
11634
|
|
|
7: Year |
|
11635
|
|
|
*/ |
|
11636
|
|
|
$month = $this->month[strtolower($match[2])]; |
|
11637
|
|
|
return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]); |
|
11638
|
|
|
} |
|
11639
|
|
|
else |
|
11640
|
|
|
{ |
|
11641
|
|
|
return false; |
|
11642
|
|
|
} |
|
11643
|
|
|
} |
|
11644
|
|
|
|
|
11645
|
|
|
public function date_strtotime($date) |
|
11646
|
|
|
{ |
|
11647
|
|
|
$strtotime = strtotime($date); |
|
11648
|
|
|
if ($strtotime === -1 || $strtotime === false) |
|
11649
|
|
|
{ |
|
11650
|
|
|
return false; |
|
11651
|
|
|
} |
|
11652
|
|
|
else |
|
11653
|
|
|
{ |
|
11654
|
|
|
return $strtotime; |
|
11655
|
|
|
} |
|
11656
|
|
|
} |
|
11657
|
|
|
} |
|
11658
|
|
|
class SimplePie_Parser |
|
11659
|
|
|
{ |
|
11660
|
|
|
var $error_code; |
|
11661
|
|
|
var $error_string; |
|
11662
|
|
|
var $current_line; |
|
11663
|
|
|
var $current_column; |
|
11664
|
|
|
var $current_byte; |
|
11665
|
|
|
var $separator = ' '; |
|
11666
|
|
|
var $namespace = array(''); |
|
11667
|
|
|
var $element = array(''); |
|
11668
|
|
|
var $xml_base = array(''); |
|
11669
|
|
|
var $xml_base_explicit = array(false); |
|
11670
|
|
|
var $xml_lang = array(''); |
|
11671
|
|
|
var $data = array(); |
|
11672
|
|
|
var $datas = array(array()); |
|
11673
|
|
|
var $current_xhtml_construct = -1; |
|
11674
|
|
|
var $encoding; |
|
11675
|
|
|
protected $registry; |
|
11676
|
|
|
public function set_registry(SimplePie_Registry $registry) |
|
11677
|
|
|
{ |
|
11678
|
|
|
$this->registry = $registry; |
|
11679
|
|
|
} |
|
11680
|
|
|
public function parse(&$data, $encoding) |
|
11681
|
|
|
{ |
|
11682
|
|
|
// Use UTF-8 if we get passed US-ASCII, as every US-ASCII character is a UTF-8 character |
|
11683
|
|
|
if (strtoupper($encoding) === 'US-ASCII') |
|
11684
|
|
|
{ |
|
11685
|
|
|
$this->encoding = 'UTF-8'; |
|
11686
|
|
|
} |
|
11687
|
|
|
else |
|
11688
|
|
|
{ |
|
11689
|
|
|
$this->encoding = $encoding; |
|
11690
|
|
|
} |
|
11691
|
|
|
// Strip BOM: |
|
11692
|
|
|
// UTF-32 Big Endian BOM |
|
11693
|
|
|
if (substr($data, 0, 4) === "\x00\x00\xFE\xFF") |
|
11694
|
|
|
{ |
|
11695
|
|
|
$data = substr($data, 4); |
|
11696
|
|
|
} |
|
11697
|
|
|
// UTF-32 Little Endian BOM |
|
11698
|
|
|
elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00") |
|
11699
|
|
|
{ |
|
11700
|
|
|
$data = substr($data, 4); |
|
11701
|
|
|
} |
|
11702
|
|
|
// UTF-16 Big Endian BOM |
|
11703
|
|
|
elseif (substr($data, 0, 2) === "\xFE\xFF") |
|
11704
|
|
|
{ |
|
11705
|
|
|
$data = substr($data, 2); |
|
11706
|
|
|
} |
|
11707
|
|
|
// UTF-16 Little Endian BOM |
|
11708
|
|
|
elseif (substr($data, 0, 2) === "\xFF\xFE") |
|
11709
|
|
|
{ |
|
11710
|
|
|
$data = substr($data, 2); |
|
11711
|
|
|
} |
|
11712
|
|
|
// UTF-8 BOM |
|
11713
|
|
|
elseif (substr($data, 0, 3) === "\xEF\xBB\xBF") |
|
11714
|
|
|
{ |
|
11715
|
|
|
$data = substr($data, 3); |
|
11716
|
|
|
} |
|
11717
|
|
|
if (substr($data, 0, 5) === '<?xml' && strspn(substr($data, 5, 1), "\x09\x0A\x0D\x20") && ($pos = strpos($data, '?>')) !== false) |
|
11718
|
|
|
{ |
|
11719
|
|
|
$declaration = $this->registry->create('XML_Declaration_Parser', array(substr($data, 5, $pos - 5))); |
|
11720
|
|
|
if ($declaration->parse()) |
|
11721
|
|
|
{ |
|
11722
|
|
|
$data = substr($data, $pos + 2); |
|
11723
|
|
|
$data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . $data; |
|
11724
|
|
|
} |
|
11725
|
|
|
else |
|
11726
|
|
|
{ |
|
11727
|
|
|
$this->error_string = 'SimplePie bug! Please report this!'; |
|
11728
|
|
|
return false; |
|
11729
|
|
|
} |
|
11730
|
|
|
} |
|
11731
|
|
|
$return = true; |
|
11732
|
|
|
static $xml_is_sane = null; |
|
11733
|
|
|
if ($xml_is_sane === null) |
|
11734
|
|
|
{ |
|
11735
|
|
|
$parser_check = xml_parser_create(); |
|
11736
|
|
|
xml_parse_into_struct($parser_check, '<foo>&</foo>', $values); |
|
11737
|
|
|
xml_parser_free($parser_check); |
|
11738
|
|
|
$xml_is_sane = isset($values[0]['value']); |
|
11739
|
|
|
} |
|
11740
|
|
|
// Create the parser |
|
11741
|
|
|
if ($xml_is_sane) |
|
11742
|
|
|
{ |
|
11743
|
|
|
$xml = xml_parser_create_ns($this->encoding, $this->separator); |
|
11744
|
|
|
xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1); |
|
11745
|
|
|
xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 0); |
|
11746
|
|
|
xml_set_object($xml, $this); |
|
11747
|
|
|
xml_set_character_data_handler($xml, 'cdata'); |
|
11748
|
|
|
xml_set_element_handler($xml, 'tag_open', 'tag_close'); |
|
11749
|
|
|
// Parse! |
|
11750
|
|
|
if (!xml_parse($xml, $data, true)) |
|
11751
|
|
|
{ |
|
11752
|
|
|
$this->error_code = xml_get_error_code($xml); |
|
11753
|
|
|
$this->error_string = xml_error_string($this->error_code); |
|
11754
|
|
|
$return = false; |
|
11755
|
|
|
} |
|
11756
|
|
|
$this->current_line = xml_get_current_line_number($xml); |
|
11757
|
|
|
$this->current_column = xml_get_current_column_number($xml); |
|
11758
|
|
|
$this->current_byte = xml_get_current_byte_index($xml); |
|
11759
|
|
|
xml_parser_free($xml); |
|
11760
|
|
|
return $return; |
|
11761
|
|
|
} |
|
11762
|
|
|
else |
|
11763
|
|
|
{ |
|
11764
|
|
|
libxml_clear_errors(); |
|
11765
|
|
|
$xml = new XMLReader(); |
|
11766
|
|
|
$xml->xml($data); |
|
11767
|
|
|
while (@$xml->read()) |
|
11768
|
|
|
{ |
|
11769
|
|
|
switch ($xml->nodeType) |
|
11770
|
|
|
{ |
|
11771
|
|
|
case constant('XMLReader::END_ELEMENT'): |
|
11772
|
|
|
if ($xml->namespaceURI !== '') |
|
11773
|
|
|
{ |
|
11774
|
|
|
$tagName = $xml->namespaceURI . $this->separator . $xml->localName; |
|
11775
|
|
|
} |
|
11776
|
|
|
else |
|
11777
|
|
|
{ |
|
11778
|
|
|
$tagName = $xml->localName; |
|
11779
|
|
|
} |
|
11780
|
|
|
$this->tag_close(null, $tagName); |
|
11781
|
|
|
break; |
|
11782
|
|
|
case constant('XMLReader::ELEMENT'): |
|
11783
|
|
|
$empty = $xml->isEmptyElement; |
|
11784
|
|
|
if ($xml->namespaceURI !== '') |
|
11785
|
|
|
{ |
|
11786
|
|
|
$tagName = $xml->namespaceURI . $this->separator . $xml->localName; |
|
11787
|
|
|
} |
|
11788
|
|
|
else |
|
11789
|
|
|
{ |
|
11790
|
|
|
$tagName = $xml->localName; |
|
11791
|
|
|
} |
|
11792
|
|
|
$attributes = array(); |
|
11793
|
|
|
while ($xml->moveToNextAttribute()) |
|
11794
|
|
|
{ |
|
11795
|
|
|
if ($xml->namespaceURI !== '') |
|
11796
|
|
|
{ |
|
11797
|
|
|
$attrName = $xml->namespaceURI . $this->separator . $xml->localName; |
|
11798
|
|
|
} |
|
11799
|
|
|
else |
|
11800
|
|
|
{ |
|
11801
|
|
|
$attrName = $xml->localName; |
|
11802
|
|
|
} |
|
11803
|
|
|
$attributes[$attrName] = $xml->value; |
|
11804
|
|
|
} |
|
11805
|
|
|
$this->tag_open(null, $tagName, $attributes); |
|
11806
|
|
|
if ($empty) |
|
11807
|
|
|
{ |
|
11808
|
|
|
$this->tag_close(null, $tagName); |
|
11809
|
|
|
} |
|
11810
|
|
|
break; |
|
11811
|
|
|
case constant('XMLReader::TEXT'): |
|
11812
|
|
|
case constant('XMLReader::CDATA'): |
|
11813
|
|
|
$this->cdata(null, $xml->value); |
|
11814
|
|
|
break; |
|
11815
|
|
|
} |
|
11816
|
|
|
} |
|
11817
|
|
|
if ($error = libxml_get_last_error()) |
|
11818
|
|
|
{ |
|
11819
|
|
|
$this->error_code = $error->code; |
|
11820
|
|
|
$this->error_string = $error->message; |
|
11821
|
|
|
$this->current_line = $error->line; |
|
11822
|
|
|
$this->current_column = $error->column; |
|
11823
|
|
|
return false; |
|
11824
|
|
|
} |
|
11825
|
|
|
else |
|
11826
|
|
|
{ |
|
11827
|
|
|
return true; |
|
11828
|
|
|
} |
|
11829
|
|
|
} |
|
11830
|
|
|
} |
|
11831
|
|
|
public function get_error_code() |
|
11832
|
|
|
{ |
|
11833
|
|
|
return $this->error_code; |
|
11834
|
|
|
} |
|
11835
|
|
|
public function get_error_string() |
|
11836
|
|
|
{ |
|
11837
|
|
|
return $this->error_string; |
|
11838
|
|
|
} |
|
11839
|
|
|
public function get_current_line() |
|
11840
|
|
|
{ |
|
11841
|
|
|
return $this->current_line; |
|
11842
|
|
|
} |
|
11843
|
|
|
public function get_current_column() |
|
11844
|
|
|
{ |
|
11845
|
|
|
return $this->current_column; |
|
11846
|
|
|
} |
|
11847
|
|
|
public function get_current_byte() |
|
11848
|
|
|
{ |
|
11849
|
|
|
return $this->current_byte; |
|
11850
|
|
|
} |
|
11851
|
|
|
public function get_data() |
|
11852
|
|
|
{ |
|
11853
|
|
|
return $this->data; |
|
11854
|
|
|
} |
|
11855
|
|
|
public function tag_open($parser, $tag, $attributes) |
|
11856
|
|
|
{ |
|
11857
|
|
|
list($this->namespace[], $this->element[]) = $this->split_ns($tag); |
|
11858
|
|
|
$attribs = array(); |
|
11859
|
|
|
foreach ($attributes as $name => $value) |
|
11860
|
|
|
{ |
|
11861
|
|
|
list($attrib_namespace, $attribute) = $this->split_ns($name); |
|
11862
|
|
|
$attribs[$attrib_namespace][$attribute] = $value; |
|
11863
|
|
|
} |
|
11864
|
|
|
if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['base'])) |
|
11865
|
|
|
{ |
|
11866
|
|
|
$base = $this->registry->call('Misc', 'absolutize_url', array($attribs[SIMPLEPIE_NAMESPACE_XML]['base'], end($this->xml_base))); |
|
11867
|
|
|
if ($base !== false) |
|
11868
|
|
|
{ |
|
11869
|
|
|
$this->xml_base[] = $base; |
|
11870
|
|
|
$this->xml_base_explicit[] = true; |
|
11871
|
|
|
} |
|
11872
|
|
|
} |
|
11873
|
|
|
else |
|
11874
|
|
|
{ |
|
11875
|
|
|
$this->xml_base[] = end($this->xml_base); |
|
11876
|
|
|
$this->xml_base_explicit[] = end($this->xml_base_explicit); |
|
11877
|
|
|
} |
|
11878
|
|
|
if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['lang'])) |
|
11879
|
|
|
{ |
|
11880
|
|
|
$this->xml_lang[] = $attribs[SIMPLEPIE_NAMESPACE_XML]['lang']; |
|
11881
|
|
|
} |
|
11882
|
|
|
else |
|
11883
|
|
|
{ |
|
11884
|
|
|
$this->xml_lang[] = end($this->xml_lang); |
|
11885
|
|
|
} |
|
11886
|
|
|
if ($this->current_xhtml_construct >= 0) |
|
11887
|
|
|
{ |
|
11888
|
|
|
$this->current_xhtml_construct++; |
|
11889
|
|
|
if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML) |
|
11890
|
|
|
{ |
|
11891
|
|
|
$this->data['data'] .= '<' . end($this->element); |
|
11892
|
|
|
if (isset($attribs[''])) |
|
11893
|
|
|
{ |
|
11894
|
|
|
foreach ($attribs[''] as $name => $value) |
|
11895
|
|
|
{ |
|
11896
|
|
|
$this->data['data'] .= ' ' . $name . '="' . htmlspecialchars($value, ENT_COMPAT, $this->encoding) . '"'; |
|
11897
|
|
|
} |
|
11898
|
|
|
} |
|
11899
|
|
|
$this->data['data'] .= '>'; |
|
11900
|
|
|
} |
|
11901
|
|
|
} |
|
11902
|
|
|
else |
|
11903
|
|
|
{ |
|
11904
|
|
|
$this->datas[] =& $this->data; |
|
11905
|
|
|
$this->data =& $this->data['child'][end($this->namespace)][end($this->element)][]; |
|
11906
|
|
|
$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)); |
|
11907
|
|
|
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') |
|
11908
|
|
|
|| (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') |
|
11909
|
|
|
|| (end($this->namespace) === SIMPLEPIE_NAMESPACE_RSS_20 && in_array(end($this->element), array('title'))) |
|
11910
|
|
|
|| (end($this->namespace) === SIMPLEPIE_NAMESPACE_RSS_090 && in_array(end($this->element), array('title'))) |
|
11911
|
|
|
|| (end($this->namespace) === SIMPLEPIE_NAMESPACE_RSS_10 && in_array(end($this->element), array('title')))) |
|
11912
|
|
|
{ |
|
11913
|
|
|
$this->current_xhtml_construct = 0; |
|
11914
|
|
|
} |
|
11915
|
|
|
} |
|
11916
|
|
|
} |
|
11917
|
|
|
public function cdata($parser, $cdata) |
|
11918
|
|
|
{ |
|
11919
|
|
|
if ($this->current_xhtml_construct >= 0) |
|
11920
|
|
|
{ |
|
11921
|
|
|
$this->data['data'] .= htmlspecialchars($cdata, ENT_QUOTES, $this->encoding); |
|
11922
|
|
|
} |
|
11923
|
|
|
else |
|
11924
|
|
|
{ |
|
11925
|
|
|
$this->data['data'] .= $cdata; |
|
11926
|
|
|
} |
|
11927
|
|
|
} |
|
11928
|
|
|
public function tag_close($parser, $tag) |
|
11929
|
|
|
{ |
|
11930
|
|
|
if ($this->current_xhtml_construct >= 0) |
|
11931
|
|
|
{ |
|
11932
|
|
|
$this->current_xhtml_construct--; |
|
11933
|
|
|
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'))) |
|
11934
|
|
|
{ |
|
11935
|
|
|
$this->data['data'] .= '</' . end($this->element) . '>'; |
|
11936
|
|
|
} |
|
11937
|
|
|
} |
|
11938
|
|
|
if ($this->current_xhtml_construct === -1) |
|
11939
|
|
|
{ |
|
11940
|
|
|
$this->data =& $this->datas[count($this->datas) - 1]; |
|
11941
|
|
|
array_pop($this->datas); |
|
11942
|
|
|
} |
|
11943
|
|
|
array_pop($this->element); |
|
11944
|
|
|
array_pop($this->namespace); |
|
11945
|
|
|
array_pop($this->xml_base); |
|
11946
|
|
|
array_pop($this->xml_base_explicit); |
|
11947
|
|
|
array_pop($this->xml_lang); |
|
11948
|
|
|
} |
|
11949
|
|
|
public function split_ns($string) |
|
11950
|
|
|
{ |
|
11951
|
|
|
static $cache = array(); |
|
11952
|
|
|
if (!isset($cache[$string])) |
|
11953
|
|
|
{ |
|
11954
|
|
|
if ($pos = strpos($string, $this->separator)) |
|
11955
|
|
|
{ |
|
11956
|
|
|
static $separator_length; |
|
11957
|
|
|
if (!$separator_length) |
|
11958
|
|
|
{ |
|
11959
|
|
|
$separator_length = strlen($this->separator); |
|
11960
|
|
|
} |
|
11961
|
|
|
$namespace = substr($string, 0, $pos); |
|
11962
|
|
|
$local_name = substr($string, $pos + $separator_length); |
|
11963
|
|
|
if (strtolower($namespace) === SIMPLEPIE_NAMESPACE_ITUNES) |
|
11964
|
|
|
{ |
|
11965
|
|
|
$namespace = SIMPLEPIE_NAMESPACE_ITUNES; |
|
11966
|
|
|
} |
|
11967
|
|
|
// Normalize the Media RSS namespaces |
|
11968
|
|
|
if ($namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG || |
|
11969
|
|
|
$namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG2 || |
|
11970
|
|
|
$namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG3 || |
|
11971
|
|
|
$namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG4 || |
|
11972
|
|
|
$namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG5 ) |
|
11973
|
|
|
{ |
|
11974
|
|
|
$namespace = SIMPLEPIE_NAMESPACE_MEDIARSS; |
|
11975
|
|
|
} |
|
11976
|
|
|
$cache[$string] = array($namespace, $local_name); |
|
11977
|
|
|
} |
|
11978
|
|
|
else |
|
11979
|
|
|
{ |
|
11980
|
|
|
$cache[$string] = array('', $string); |
|
11981
|
|
|
} |
|
11982
|
|
|
} |
|
11983
|
|
|
return $cache[$string]; |
|
11984
|
|
|
} |
|
11985
|
|
|
} |
|
11986
|
|
|
class SimplePie_Rating |
|
11987
|
|
|
{ |
|
11988
|
|
|
|
|
11989
|
|
|
var $scheme; |
|
11990
|
|
|
|
|
11991
|
|
|
var $value; |
|
11992
|
|
|
|
|
11993
|
|
|
public function __construct($scheme = null, $value = null) |
|
11994
|
|
|
{ |
|
11995
|
|
|
$this->scheme = $scheme; |
|
11996
|
|
|
$this->value = $value; |
|
11997
|
|
|
} |
|
11998
|
|
|
|
|
11999
|
|
|
public function __toString() |
|
12000
|
|
|
{ |
|
12001
|
|
|
// There is no $this->data here |
|
12002
|
|
|
return md5(serialize($this)); |
|
12003
|
|
|
} |
|
12004
|
|
|
|
|
12005
|
|
|
public function get_scheme() |
|
12006
|
|
|
{ |
|
12007
|
|
|
if ($this->scheme !== null) |
|
12008
|
|
|
{ |
|
12009
|
|
|
return $this->scheme; |
|
12010
|
|
|
} |
|
12011
|
|
|
else |
|
12012
|
|
|
{ |
|
12013
|
|
|
return null; |
|
12014
|
|
|
} |
|
12015
|
|
|
} |
|
12016
|
|
|
|
|
12017
|
|
|
public function get_value() |
|
12018
|
|
|
{ |
|
12019
|
|
|
if ($this->value !== null) |
|
12020
|
|
|
{ |
|
12021
|
|
|
return $this->value; |
|
12022
|
|
|
} |
|
12023
|
|
|
else |
|
12024
|
|
|
{ |
|
12025
|
|
|
return null; |
|
12026
|
|
|
} |
|
12027
|
|
|
} |
|
12028
|
|
|
} |
|
12029
|
|
|
class SimplePie_Registry |
|
12030
|
|
|
{ |
|
12031
|
|
|
|
|
12032
|
|
|
protected $default = array( |
|
12033
|
|
|
'Cache' => 'SimplePie_Cache', |
|
12034
|
|
|
'Locator' => 'SimplePie_Locator', |
|
12035
|
|
|
'Parser' => 'SimplePie_Parser', |
|
12036
|
|
|
'File' => 'SimplePie_File', |
|
12037
|
|
|
'Sanitize' => 'SimplePie_Sanitize', |
|
12038
|
|
|
'Item' => 'SimplePie_Item', |
|
12039
|
|
|
'Author' => 'SimplePie_Author', |
|
12040
|
|
|
'Category' => 'SimplePie_Category', |
|
12041
|
|
|
'Enclosure' => 'SimplePie_Enclosure', |
|
12042
|
|
|
'Caption' => 'SimplePie_Caption', |
|
12043
|
|
|
'Copyright' => 'SimplePie_Copyright', |
|
12044
|
|
|
'Credit' => 'SimplePie_Credit', |
|
12045
|
|
|
'Rating' => 'SimplePie_Rating', |
|
12046
|
|
|
'Restriction' => 'SimplePie_Restriction', |
|
12047
|
|
|
'Content_Type_Sniffer' => 'SimplePie_Content_Type_Sniffer', |
|
12048
|
|
|
'Source' => 'SimplePie_Source', |
|
12049
|
|
|
'Misc' => 'SimplePie_Misc', |
|
12050
|
|
|
'XML_Declaration_Parser' => 'SimplePie_XML_Declaration_Parser', |
|
12051
|
|
|
'Parse_Date' => 'SimplePie_Parse_Date', |
|
12052
|
|
|
); |
|
12053
|
|
|
|
|
12054
|
|
|
protected $classes = array(); |
|
12055
|
|
|
|
|
12056
|
|
|
protected $legacy = array(); |
|
12057
|
|
|
|
|
12058
|
|
|
public function __construct() { } |
|
12059
|
|
|
|
|
12060
|
|
|
public function register($type, $class, $legacy = false) |
|
12061
|
|
|
{ |
|
12062
|
|
|
if (!is_subclass_of($class, $this->default[$type])) |
|
12063
|
|
|
{ |
|
12064
|
|
|
return false; |
|
12065
|
|
|
} |
|
12066
|
|
|
$this->classes[$type] = $class; |
|
12067
|
|
|
if ($legacy) |
|
12068
|
|
|
{ |
|
12069
|
|
|
$this->legacy[] = $class; |
|
12070
|
|
|
} |
|
12071
|
|
|
return true; |
|
12072
|
|
|
} |
|
12073
|
|
|
|
|
12074
|
|
|
public function get_class($type) |
|
12075
|
|
|
{ |
|
12076
|
|
|
if (!empty($this->classes[$type])) |
|
12077
|
|
|
{ |
|
12078
|
|
|
return $this->classes[$type]; |
|
12079
|
|
|
} |
|
12080
|
|
|
if (!empty($this->default[$type])) |
|
12081
|
|
|
{ |
|
12082
|
|
|
return $this->default[$type]; |
|
12083
|
|
|
} |
|
12084
|
|
|
return null; |
|
12085
|
|
|
} |
|
12086
|
|
|
|
|
12087
|
|
|
public function &create($type, $parameters = array()) |
|
12088
|
|
|
{ |
|
12089
|
|
|
$class = $this->get_class($type); |
|
12090
|
|
|
if (in_array($class, $this->legacy)) |
|
12091
|
|
|
{ |
|
12092
|
|
|
switch ($type) |
|
12093
|
|
|
{ |
|
12094
|
|
|
case 'locator': |
|
12095
|
|
|
// Legacy: file, timeout, useragent, file_class, max_checked_feeds, content_type_sniffer_class |
|
12096
|
|
|
// Specified: file, timeout, useragent, max_checked_feeds |
|
12097
|
|
|
$replacement = array($this->get_class('file'), $parameters[3], $this->get_class('content_type_sniffer')); |
|
12098
|
|
|
array_splice($parameters, 3, 1, $replacement); |
|
12099
|
|
|
break; |
|
12100
|
|
|
} |
|
12101
|
|
|
} |
|
12102
|
|
|
if (!method_exists($class, '__construct')) |
|
12103
|
|
|
{ |
|
12104
|
|
|
$instance = new $class; |
|
12105
|
|
|
} |
|
12106
|
|
|
else |
|
12107
|
|
|
{ |
|
12108
|
|
|
$reflector = new ReflectionClass($class); |
|
12109
|
|
|
$instance = $reflector->newInstanceArgs($parameters); |
|
12110
|
|
|
} |
|
12111
|
|
|
if (method_exists($instance, 'set_registry')) |
|
12112
|
|
|
{ |
|
12113
|
|
|
$instance->set_registry($this); |
|
12114
|
|
|
} |
|
12115
|
|
|
return $instance; |
|
12116
|
|
|
} |
|
12117
|
|
|
|
|
12118
|
|
|
public function &call($type, $method, $parameters = array()) |
|
12119
|
|
|
{ |
|
12120
|
|
|
$class = $this->get_class($type); |
|
12121
|
|
|
if (in_array($class, $this->legacy)) |
|
12122
|
|
|
{ |
|
12123
|
|
|
switch ($type) |
|
12124
|
|
|
{ |
|
12125
|
|
|
case 'Cache': |
|
12126
|
|
|
// For backwards compatibility with old non-static |
|
12127
|
|
|
// Cache::create() methods |
|
12128
|
|
|
if ($method === 'get_handler') |
|
12129
|
|
|
{ |
|
12130
|
|
|
$result = @call_user_func_array(array($class, 'create'), $parameters); |
|
12131
|
|
|
return $result; |
|
12132
|
|
|
} |
|
12133
|
|
|
break; |
|
12134
|
|
|
} |
|
12135
|
|
|
} |
|
12136
|
|
|
$result = call_user_func_array(array($class, $method), $parameters); |
|
12137
|
|
|
return $result; |
|
12138
|
|
|
} |
|
12139
|
|
|
} |
|
12140
|
|
|
class SimplePie_Restriction |
|
12141
|
|
|
{ |
|
12142
|
|
|
|
|
12143
|
|
|
var $relationship; |
|
12144
|
|
|
|
|
12145
|
|
|
var $type; |
|
12146
|
|
|
|
|
12147
|
|
|
var $value; |
|
12148
|
|
|
|
|
12149
|
|
|
public function __construct($relationship = null, $type = null, $value = null) |
|
12150
|
|
|
{ |
|
12151
|
|
|
$this->relationship = $relationship; |
|
12152
|
|
|
$this->type = $type; |
|
12153
|
|
|
$this->value = $value; |
|
12154
|
|
|
} |
|
12155
|
|
|
|
|
12156
|
|
|
public function __toString() |
|
12157
|
|
|
{ |
|
12158
|
|
|
// There is no $this->data here |
|
12159
|
|
|
return md5(serialize($this)); |
|
12160
|
|
|
} |
|
12161
|
|
|
|
|
12162
|
|
|
public function get_relationship() |
|
12163
|
|
|
{ |
|
12164
|
|
|
if ($this->relationship !== null) |
|
12165
|
|
|
{ |
|
12166
|
|
|
return $this->relationship; |
|
12167
|
|
|
} |
|
12168
|
|
|
else |
|
12169
|
|
|
{ |
|
12170
|
|
|
return null; |
|
12171
|
|
|
} |
|
12172
|
|
|
} |
|
12173
|
|
|
|
|
12174
|
|
|
public function get_type() |
|
12175
|
|
|
{ |
|
12176
|
|
|
if ($this->type !== null) |
|
12177
|
|
|
{ |
|
12178
|
|
|
return $this->type; |
|
12179
|
|
|
} |
|
12180
|
|
|
else |
|
12181
|
|
|
{ |
|
12182
|
|
|
return null; |
|
12183
|
|
|
} |
|
12184
|
|
|
} |
|
12185
|
|
|
|
|
12186
|
|
|
public function get_value() |
|
12187
|
|
|
{ |
|
12188
|
|
|
if ($this->value !== null) |
|
12189
|
|
|
{ |
|
12190
|
|
|
return $this->value; |
|
12191
|
|
|
} |
|
12192
|
|
|
else |
|
12193
|
|
|
{ |
|
12194
|
|
|
return null; |
|
12195
|
|
|
} |
|
12196
|
|
|
} |
|
12197
|
|
|
} |
|
12198
|
|
|
class SimplePie_Sanitize |
|
12199
|
|
|
{ |
|
12200
|
|
|
// Private vars |
|
12201
|
|
|
var $base; |
|
12202
|
|
|
// Options |
|
12203
|
|
|
var $remove_div = true; |
|
12204
|
|
|
var $image_handler = ''; |
|
12205
|
|
|
var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'); |
|
12206
|
|
|
var $encode_instead_of_strip = false; |
|
12207
|
|
|
var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'); |
|
12208
|
|
|
var $strip_comments = false; |
|
12209
|
|
|
var $output_encoding = 'UTF-8'; |
|
12210
|
|
|
var $enable_cache = true; |
|
12211
|
|
|
var $cache_location = './cache'; |
|
12212
|
|
|
var $cache_name_function = 'md5'; |
|
12213
|
|
|
var $timeout = 10; |
|
12214
|
|
|
var $useragent = ''; |
|
12215
|
|
|
var $force_fsockopen = false; |
|
12216
|
|
|
var $replace_url_attributes = null; |
|
12217
|
|
|
public function __construct() |
|
12218
|
|
|
{ |
|
12219
|
|
|
// Set defaults |
|
12220
|
|
|
$this->set_url_replacements(null); |
|
12221
|
|
|
} |
|
12222
|
|
|
public function remove_div($enable = true) |
|
12223
|
|
|
{ |
|
12224
|
|
|
$this->remove_div = (bool) $enable; |
|
12225
|
|
|
} |
|
12226
|
|
|
public function set_image_handler($page = false) |
|
12227
|
|
|
{ |
|
12228
|
|
|
if ($page) |
|
12229
|
|
|
{ |
|
12230
|
|
|
$this->image_handler = (string) $page; |
|
12231
|
|
|
} |
|
12232
|
|
|
else |
|
12233
|
|
|
{ |
|
12234
|
|
|
$this->image_handler = false; |
|
12235
|
|
|
} |
|
12236
|
|
|
} |
|
12237
|
|
|
public function set_registry(SimplePie_Registry $registry) |
|
12238
|
|
|
{ |
|
12239
|
|
|
$this->registry = $registry; |
|
12240
|
|
|
} |
|
12241
|
|
|
public function pass_cache_data($enable_cache = true, $cache_location = './cache', $cache_name_function = 'md5', $cache_class = 'SimplePie_Cache') |
|
12242
|
|
|
{ |
|
12243
|
|
|
if (isset($enable_cache)) |
|
12244
|
|
|
{ |
|
12245
|
|
|
$this->enable_cache = (bool) $enable_cache; |
|
12246
|
|
|
} |
|
12247
|
|
|
if ($cache_location) |
|
12248
|
|
|
{ |
|
12249
|
|
|
$this->cache_location = (string) $cache_location; |
|
12250
|
|
|
} |
|
12251
|
|
|
if ($cache_name_function) |
|
12252
|
|
|
{ |
|
12253
|
|
|
$this->cache_name_function = (string) $cache_name_function; |
|
12254
|
|
|
} |
|
12255
|
|
|
} |
|
12256
|
|
|
public function pass_file_data($file_class = 'SimplePie_File', $timeout = 10, $useragent = '', $force_fsockopen = false) |
|
12257
|
|
|
{ |
|
12258
|
|
|
if ($timeout) |
|
12259
|
|
|
{ |
|
12260
|
|
|
$this->timeout = (string) $timeout; |
|
12261
|
|
|
} |
|
12262
|
|
|
if ($useragent) |
|
12263
|
|
|
{ |
|
12264
|
|
|
$this->useragent = (string) $useragent; |
|
12265
|
|
|
} |
|
12266
|
|
|
if ($force_fsockopen) |
|
12267
|
|
|
{ |
|
12268
|
|
|
$this->force_fsockopen = (string) $force_fsockopen; |
|
12269
|
|
|
} |
|
12270
|
|
|
} |
|
12271
|
|
|
public function strip_htmltags($tags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style')) |
|
12272
|
|
|
{ |
|
12273
|
|
|
if ($tags) |
|
12274
|
|
|
{ |
|
12275
|
|
|
if (is_array($tags)) |
|
12276
|
|
|
{ |
|
12277
|
|
|
$this->strip_htmltags = $tags; |
|
12278
|
|
|
} |
|
12279
|
|
|
else |
|
12280
|
|
|
{ |
|
12281
|
|
|
$this->strip_htmltags = explode(',', $tags); |
|
12282
|
|
|
} |
|
12283
|
|
|
} |
|
12284
|
|
|
else |
|
12285
|
|
|
{ |
|
12286
|
|
|
$this->strip_htmltags = false; |
|
12287
|
|
|
} |
|
12288
|
|
|
} |
|
12289
|
|
|
public function encode_instead_of_strip($encode = false) |
|
12290
|
|
|
{ |
|
12291
|
|
|
$this->encode_instead_of_strip = (bool) $encode; |
|
12292
|
|
|
} |
|
12293
|
|
|
public function strip_attributes($attribs = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc')) |
|
12294
|
|
|
{ |
|
12295
|
|
|
if ($attribs) |
|
12296
|
|
|
{ |
|
12297
|
|
|
if (is_array($attribs)) |
|
12298
|
|
|
{ |
|
12299
|
|
|
$this->strip_attributes = $attribs; |
|
12300
|
|
|
} |
|
12301
|
|
|
else |
|
12302
|
|
|
{ |
|
12303
|
|
|
$this->strip_attributes = explode(',', $attribs); |
|
12304
|
|
|
} |
|
12305
|
|
|
} |
|
12306
|
|
|
else |
|
12307
|
|
|
{ |
|
12308
|
|
|
$this->strip_attributes = false; |
|
12309
|
|
|
} |
|
12310
|
|
|
} |
|
12311
|
|
|
public function strip_comments($strip = false) |
|
12312
|
|
|
{ |
|
12313
|
|
|
$this->strip_comments = (bool) $strip; |
|
12314
|
|
|
} |
|
12315
|
|
|
public function set_output_encoding($encoding = 'UTF-8') |
|
12316
|
|
|
{ |
|
12317
|
|
|
$this->output_encoding = (string) $encoding; |
|
12318
|
|
|
} |
|
12319
|
|
|
|
|
12320
|
|
|
public function set_url_replacements($element_attribute = null) |
|
12321
|
|
|
{ |
|
12322
|
|
|
if ($element_attribute === null) |
|
12323
|
|
|
{ |
|
12324
|
|
|
$element_attribute = array( |
|
12325
|
|
|
'a' => 'href', |
|
12326
|
|
|
'area' => 'href', |
|
12327
|
|
|
'blockquote' => 'cite', |
|
12328
|
|
|
'del' => 'cite', |
|
12329
|
|
|
'form' => 'action', |
|
12330
|
|
|
'img' => array( |
|
12331
|
|
|
'longdesc', |
|
12332
|
|
|
'src' |
|
12333
|
|
|
), |
|
12334
|
|
|
'input' => 'src', |
|
12335
|
|
|
'ins' => 'cite', |
|
12336
|
|
|
'q' => 'cite' |
|
12337
|
|
|
); |
|
12338
|
|
|
} |
|
12339
|
|
|
$this->replace_url_attributes = (array) $element_attribute; |
|
12340
|
|
|
} |
|
12341
|
|
|
public function sanitize($data, $type, $base = '') |
|
12342
|
|
|
{ |
|
12343
|
|
|
$data = trim($data); |
|
12344
|
|
|
if ($data !== '' || $type & SIMPLEPIE_CONSTRUCT_IRI) |
|
12345
|
|
|
{ |
|
12346
|
|
|
if ($type & SIMPLEPIE_CONSTRUCT_MAYBE_HTML) |
|
12347
|
|
|
{ |
|
12348
|
|
|
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)) |
|
12349
|
|
|
{ |
|
12350
|
|
|
$type |= SIMPLEPIE_CONSTRUCT_HTML; |
|
12351
|
|
|
} |
|
12352
|
|
|
else |
|
12353
|
|
|
{ |
|
12354
|
|
|
$type |= SIMPLEPIE_CONSTRUCT_TEXT; |
|
12355
|
|
|
} |
|
12356
|
|
|
} |
|
12357
|
|
|
if ($type & SIMPLEPIE_CONSTRUCT_BASE64) |
|
12358
|
|
|
{ |
|
12359
|
|
|
$data = base64_decode($data); |
|
12360
|
|
|
} |
|
12361
|
|
|
if ($type & (SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML)) |
|
12362
|
|
|
{ |
|
12363
|
|
|
$document = new DOMDocument(); |
|
12364
|
|
|
$document->encoding = 'UTF-8'; |
|
12365
|
|
|
$data = $this->preprocess($data, $type); |
|
12366
|
|
|
set_error_handler(array('SimplePie_Misc', 'silence_errors')); |
|
12367
|
|
|
$document->loadHTML($data); |
|
12368
|
|
|
restore_error_handler(); |
|
12369
|
|
|
// Strip comments |
|
12370
|
|
|
if ($this->strip_comments) |
|
12371
|
|
|
{ |
|
12372
|
|
|
$xpath = new DOMXPath($document); |
|
12373
|
|
|
$comments = $xpath->query('//comment()'); |
|
12374
|
|
|
foreach ($comments as $comment) |
|
12375
|
|
|
{ |
|
12376
|
|
|
$comment->parentNode->removeChild($comment); |
|
12377
|
|
|
} |
|
12378
|
|
|
} |
|
12379
|
|
|
// Strip out HTML tags and attributes that might cause various security problems. |
|
12380
|
|
|
// Based on recommendations by Mark Pilgrim at: |
|
12381
|
|
|
// http://diveintomark.org/archives/2003/06/12/how_to_consume_rss_safely |
|
12382
|
|
|
if ($this->strip_htmltags) |
|
12383
|
|
|
{ |
|
12384
|
|
|
foreach ($this->strip_htmltags as $tag) |
|
12385
|
|
|
{ |
|
12386
|
|
|
$this->strip_tag($tag, $document, $type); |
|
12387
|
|
|
} |
|
12388
|
|
|
} |
|
12389
|
|
|
if ($this->strip_attributes) |
|
12390
|
|
|
{ |
|
12391
|
|
|
foreach ($this->strip_attributes as $attrib) |
|
12392
|
|
|
{ |
|
12393
|
|
|
$this->strip_attr($attrib, $document); |
|
12394
|
|
|
} |
|
12395
|
|
|
} |
|
12396
|
|
|
// Replace relative URLs |
|
12397
|
|
|
$this->base = $base; |
|
12398
|
|
|
foreach ($this->replace_url_attributes as $element => $attributes) |
|
12399
|
|
|
{ |
|
12400
|
|
|
$this->replace_urls($document, $element, $attributes); |
|
12401
|
|
|
} |
|
12402
|
|
|
// If image handling (caching, etc.) is enabled, cache and rewrite all the image tags. |
|
12403
|
|
|
if (isset($this->image_handler) && ((string) $this->image_handler) !== '' && $this->enable_cache) |
|
12404
|
|
|
{ |
|
12405
|
|
|
$images = $document->getElementsByTagName('img'); |
|
12406
|
|
|
foreach ($images as $img) |
|
12407
|
|
|
{ |
|
12408
|
|
|
if ($img->hasAttribute('src')) |
|
12409
|
|
|
{ |
|
12410
|
|
|
$image_url = call_user_func($this->cache_name_function, $img->getAttribute('src')); |
|
12411
|
|
|
$cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, $image_url, 'spi')); |
|
12412
|
|
|
if ($cache->load()) |
|
12413
|
|
|
{ |
|
12414
|
|
|
$img->setAttribute('src', $this->image_handler . $image_url); |
|
12415
|
|
|
} |
|
12416
|
|
|
else |
|
12417
|
|
|
{ |
|
12418
|
|
|
$file = $this->registry->create('File', array($img['attribs']['src']['data'], $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen)); |
|
12419
|
|
|
$headers = $file->headers; |
|
12420
|
|
|
if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) |
|
12421
|
|
|
{ |
|
12422
|
|
|
if ($cache->save(array('headers' => $file->headers, 'body' => $file->body))) |
|
12423
|
|
|
{ |
|
12424
|
|
|
$img->setAttribute('src', $this->image_handler . $image_url); |
|
12425
|
|
|
} |
|
12426
|
|
|
else |
|
12427
|
|
|
{ |
|
12428
|
|
|
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); |
|
12429
|
|
|
} |
|
12430
|
|
|
} |
|
12431
|
|
|
} |
|
12432
|
|
|
} |
|
12433
|
|
|
} |
|
12434
|
|
|
} |
|
12435
|
|
|
// Remove the DOCTYPE |
|
12436
|
|
|
// Seems to cause segfaulting if we don't do this |
|
12437
|
|
|
if ($document->firstChild instanceof DOMDocumentType) |
|
12438
|
|
|
{ |
|
12439
|
|
|
$document->removeChild($document->firstChild); |
|
12440
|
|
|
} |
|
12441
|
|
|
// Move everything from the body to the root |
|
12442
|
|
|
$real_body = $document->getElementsByTagName('body')->item(0)->childNodes->item(0); |
|
12443
|
|
|
$document->replaceChild($real_body, $document->firstChild); |
|
12444
|
|
|
// Finally, convert to a HTML string |
|
12445
|
|
|
$data = trim($document->saveHTML()); |
|
12446
|
|
|
if ($this->remove_div) |
|
12447
|
|
|
{ |
|
12448
|
|
|
$data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '', $data); |
|
12449
|
|
|
$data = preg_replace('/<\/div>$/', '', $data); |
|
12450
|
|
|
} |
|
12451
|
|
|
else |
|
12452
|
|
|
{ |
|
12453
|
|
|
$data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '<div>', $data); |
|
12454
|
|
|
} |
|
12455
|
|
|
} |
|
12456
|
|
|
if ($type & SIMPLEPIE_CONSTRUCT_IRI) |
|
12457
|
|
|
{ |
|
12458
|
|
|
$absolute = $this->registry->call('Misc', 'absolutize_url', array($data, $base)); |
|
12459
|
|
|
if ($absolute !== false) |
|
12460
|
|
|
{ |
|
12461
|
|
|
$data = $absolute; |
|
12462
|
|
|
} |
|
12463
|
|
|
} |
|
12464
|
|
|
if ($type & (SIMPLEPIE_CONSTRUCT_TEXT | SIMPLEPIE_CONSTRUCT_IRI)) |
|
12465
|
|
|
{ |
|
12466
|
|
|
$data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8'); |
|
12467
|
|
|
} |
|
12468
|
|
|
if ($this->output_encoding !== 'UTF-8') |
|
12469
|
|
|
{ |
|
12470
|
|
|
$data = $this->registry->call('Misc', 'change_encoding', array($data, 'UTF-8', $this->output_encoding)); |
|
12471
|
|
|
} |
|
12472
|
|
|
} |
|
12473
|
|
|
return $data; |
|
12474
|
|
|
} |
|
12475
|
|
|
protected function preprocess($html, $type) |
|
12476
|
|
|
{ |
|
12477
|
|
|
$ret = ''; |
|
12478
|
|
|
if ($type & ~SIMPLEPIE_CONSTRUCT_XHTML) |
|
12479
|
|
|
{ |
|
12480
|
|
|
// Atom XHTML constructs are wrapped with a div by default |
|
12481
|
|
|
// Note: No protection if $html contains a stray </div>! |
|
12482
|
|
|
$html = '<div>' . $html . '</div>'; |
|
12483
|
|
|
$ret .= '<!DOCTYPE html>'; |
|
12484
|
|
|
$content_type = 'text/html'; |
|
12485
|
|
|
} |
|
12486
|
|
|
else |
|
12487
|
|
|
{ |
|
12488
|
|
|
$ret .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'; |
|
12489
|
|
|
$content_type = 'application/xhtml+xml'; |
|
12490
|
|
|
} |
|
12491
|
|
|
$ret .= '<html><head>'; |
|
12492
|
|
|
$ret .= '<meta http-equiv="Content-Type" content="' . $content_type . '; charset=utf-8" />'; |
|
12493
|
|
|
$ret .= '</head><body>' . $html . '</body></html>'; |
|
12494
|
|
|
return $ret; |
|
12495
|
|
|
} |
|
12496
|
|
|
public function replace_urls($document, $tag, $attributes) |
|
12497
|
|
|
{ |
|
12498
|
|
|
if (!is_array($attributes)) |
|
12499
|
|
|
{ |
|
12500
|
|
|
$attributes = array($attributes); |
|
12501
|
|
|
} |
|
12502
|
|
|
if (!is_array($this->strip_htmltags) || !in_array($tag, $this->strip_htmltags)) |
|
12503
|
|
|
{ |
|
12504
|
|
|
$elements = $document->getElementsByTagName($tag); |
|
12505
|
|
|
foreach ($elements as $element) |
|
12506
|
|
|
{ |
|
12507
|
|
|
foreach ($attributes as $attribute) |
|
12508
|
|
|
{ |
|
12509
|
|
|
if ($element->hasAttribute($attribute)) |
|
12510
|
|
|
{ |
|
12511
|
|
|
$value = $this->registry->call('Misc', 'absolutize_url', array($element->getAttribute($attribute), $this->base)); |
|
12512
|
|
|
if ($value !== false) |
|
12513
|
|
|
{ |
|
12514
|
|
|
$element->setAttribute($attribute, $value); |
|
12515
|
|
|
} |
|
12516
|
|
|
} |
|
12517
|
|
|
} |
|
12518
|
|
|
} |
|
12519
|
|
|
} |
|
12520
|
|
|
} |
|
12521
|
|
|
public function do_strip_htmltags($match) |
|
12522
|
|
|
{ |
|
12523
|
|
|
if ($this->encode_instead_of_strip) |
|
12524
|
|
|
{ |
|
12525
|
|
|
if (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style'))) |
|
12526
|
|
|
{ |
|
12527
|
|
|
$match[1] = htmlspecialchars($match[1], ENT_COMPAT, 'UTF-8'); |
|
12528
|
|
|
$match[2] = htmlspecialchars($match[2], ENT_COMPAT, 'UTF-8'); |
|
12529
|
|
|
return "<$match[1]$match[2]>$match[3]</$match[1]>"; |
|
12530
|
|
|
} |
|
12531
|
|
|
else |
|
12532
|
|
|
{ |
|
12533
|
|
|
return htmlspecialchars($match[0], ENT_COMPAT, 'UTF-8'); |
|
12534
|
|
|
} |
|
12535
|
|
|
} |
|
12536
|
|
|
elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style'))) |
|
12537
|
|
|
{ |
|
12538
|
|
|
return $match[4]; |
|
12539
|
|
|
} |
|
12540
|
|
|
else |
|
12541
|
|
|
{ |
|
12542
|
|
|
return ''; |
|
12543
|
|
|
} |
|
12544
|
|
|
} |
|
12545
|
|
|
protected function strip_tag($tag, $document, $type) |
|
12546
|
|
|
{ |
|
12547
|
|
|
$xpath = new DOMXPath($document); |
|
12548
|
|
|
$elements = $xpath->query('body//' . $tag); |
|
12549
|
|
|
if ($this->encode_instead_of_strip) |
|
12550
|
|
|
{ |
|
12551
|
|
|
foreach ($elements as $element) |
|
12552
|
|
|
{ |
|
12553
|
|
|
$fragment = $document->createDocumentFragment(); |
|
12554
|
|
|
// For elements which aren't script or style, include the tag itself |
|
12555
|
|
|
if (!in_array($tag, array('script', 'style'))) |
|
12556
|
|
|
{ |
|
12557
|
|
|
$text = '<' . $tag; |
|
12558
|
|
|
if ($element->hasAttributes()) |
|
12559
|
|
|
{ |
|
12560
|
|
|
$attrs = array(); |
|
12561
|
|
|
foreach ($element->attributes as $name => $attr) |
|
12562
|
|
|
{ |
|
12563
|
|
|
$value = $attr->value; |
|
12564
|
|
|
// In XHTML, empty values should never exist, so we repeat the value |
|
12565
|
|
|
if (empty($value) && ($type & SIMPLEPIE_CONSTRUCT_XHTML)) |
|
12566
|
|
|
{ |
|
12567
|
|
|
$value = $name; |
|
12568
|
|
|
} |
|
12569
|
|
|
// For HTML, empty is fine |
|
12570
|
|
|
elseif (empty($value) && ($type & SIMPLEPIE_CONSTRUCT_HTML)) |
|
12571
|
|
|
{ |
|
12572
|
|
|
$attrs[] = $name; |
|
12573
|
|
|
continue; |
|
12574
|
|
|
} |
|
12575
|
|
|
// Standard attribute text |
|
12576
|
|
|
$attrs[] = $name . '="' . $attr->value . '"'; |
|
12577
|
|
|
} |
|
12578
|
|
|
$text .= ' ' . implode(' ', $attrs); |
|
12579
|
|
|
} |
|
12580
|
|
|
$text .= '>'; |
|
12581
|
|
|
$fragment->appendChild(new DOMText($text)); |
|
12582
|
|
|
} |
|
12583
|
|
|
$number = $element->childNodes->length; |
|
12584
|
|
|
for ($i = $number; $i > 0; $i--) |
|
12585
|
|
|
{ |
|
12586
|
|
|
$child = $element->childNodes->item(0); |
|
12587
|
|
|
$fragment->appendChild($child); |
|
12588
|
|
|
} |
|
12589
|
|
|
if (!in_array($tag, array('script', 'style'))) |
|
12590
|
|
|
{ |
|
12591
|
|
|
$fragment->appendChild(new DOMText('</' . $tag . '>')); |
|
12592
|
|
|
} |
|
12593
|
|
|
$element->parentNode->replaceChild($fragment, $element); |
|
12594
|
|
|
} |
|
12595
|
|
|
return; |
|
12596
|
|
|
} |
|
12597
|
|
|
elseif (in_array($tag, array('script', 'style'))) |
|
12598
|
|
|
{ |
|
12599
|
|
|
foreach ($elements as $element) |
|
12600
|
|
|
{ |
|
12601
|
|
|
$element->parentNode->removeChild($element); |
|
12602
|
|
|
} |
|
12603
|
|
|
return; |
|
12604
|
|
|
} |
|
12605
|
|
|
else |
|
12606
|
|
|
{ |
|
12607
|
|
|
foreach ($elements as $element) |
|
12608
|
|
|
{ |
|
12609
|
|
|
$fragment = $document->createDocumentFragment(); |
|
12610
|
|
|
$number = $element->childNodes->length; |
|
12611
|
|
|
for ($i = $number; $i > 0; $i--) |
|
12612
|
|
|
{ |
|
12613
|
|
|
$child = $element->childNodes->item(0); |
|
12614
|
|
|
$fragment->appendChild($child); |
|
12615
|
|
|
} |
|
12616
|
|
|
$element->parentNode->replaceChild($fragment, $element); |
|
12617
|
|
|
} |
|
12618
|
|
|
} |
|
12619
|
|
|
} |
|
12620
|
|
|
protected function strip_attr($attrib, $document) |
|
12621
|
|
|
{ |
|
12622
|
|
|
$xpath = new DOMXPath($document); |
|
12623
|
|
|
$elements = $xpath->query('//*[@' . $attrib . ']'); |
|
12624
|
|
|
foreach ($elements as $element) |
|
12625
|
|
|
{ |
|
12626
|
|
|
$element->removeAttribute($attrib); |
|
12627
|
|
|
} |
|
12628
|
|
|
} |
|
12629
|
|
|
} |
|
12630
|
|
|
class SimplePie_Source |
|
12631
|
|
|
{ |
|
12632
|
|
|
var $item; |
|
12633
|
|
|
var $data = array(); |
|
12634
|
|
|
protected $registry; |
|
12635
|
|
|
public function __construct($item, $data) |
|
12636
|
|
|
{ |
|
12637
|
|
|
$this->item = $item; |
|
12638
|
|
|
$this->data = $data; |
|
12639
|
|
|
} |
|
12640
|
|
|
public function set_registry(SimplePie_Registry $registry) |
|
12641
|
|
|
{ |
|
12642
|
|
|
$this->registry = $registry; |
|
12643
|
|
|
} |
|
12644
|
|
|
public function __toString() |
|
12645
|
|
|
{ |
|
12646
|
|
|
return md5(serialize($this->data)); |
|
12647
|
|
|
} |
|
12648
|
|
|
public function get_source_tags($namespace, $tag) |
|
12649
|
|
|
{ |
|
12650
|
|
|
if (isset($this->data['child'][$namespace][$tag])) |
|
12651
|
|
|
{ |
|
12652
|
|
|
return $this->data['child'][$namespace][$tag]; |
|
12653
|
|
|
} |
|
12654
|
|
|
else |
|
12655
|
|
|
{ |
|
12656
|
|
|
return null; |
|
12657
|
|
|
} |
|
12658
|
|
|
} |
|
12659
|
|
|
public function get_base($element = array()) |
|
12660
|
|
|
{ |
|
12661
|
|
|
return $this->item->get_base($element); |
|
12662
|
|
|
} |
|
12663
|
|
|
public function sanitize($data, $type, $base = '') |
|
12664
|
|
|
{ |
|
12665
|
|
|
return $this->item->sanitize($data, $type, $base); |
|
12666
|
|
|
} |
|
12667
|
|
|
public function get_item() |
|
12668
|
|
|
{ |
|
12669
|
|
|
return $this->item; |
|
12670
|
|
|
} |
|
12671
|
|
|
public function get_title() |
|
12672
|
|
|
{ |
|
12673
|
|
|
if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) |
|
12674
|
|
|
{ |
|
12675
|
|
|
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
12676
|
|
|
} |
|
12677
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) |
|
12678
|
|
|
{ |
|
12679
|
|
|
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
12680
|
|
|
} |
|
12681
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) |
|
12682
|
|
|
{ |
|
12683
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
12684
|
|
|
} |
|
12685
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) |
|
12686
|
|
|
{ |
|
12687
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
12688
|
|
|
} |
|
12689
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) |
|
12690
|
|
|
{ |
|
12691
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
12692
|
|
|
} |
|
12693
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) |
|
12694
|
|
|
{ |
|
12695
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
12696
|
|
|
} |
|
12697
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) |
|
12698
|
|
|
{ |
|
12699
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
12700
|
|
|
} |
|
12701
|
|
|
else |
|
12702
|
|
|
{ |
|
12703
|
|
|
return null; |
|
12704
|
|
|
} |
|
12705
|
|
|
} |
|
12706
|
|
|
public function get_category($key = 0) |
|
12707
|
|
|
{ |
|
12708
|
|
|
$categories = $this->get_categories(); |
|
12709
|
|
|
if (isset($categories[$key])) |
|
12710
|
|
|
{ |
|
12711
|
|
|
return $categories[$key]; |
|
12712
|
|
|
} |
|
12713
|
|
|
else |
|
12714
|
|
|
{ |
|
12715
|
|
|
return null; |
|
12716
|
|
|
} |
|
12717
|
|
|
} |
|
12718
|
|
|
public function get_categories() |
|
12719
|
|
|
{ |
|
12720
|
|
|
$categories = array(); |
|
12721
|
|
|
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) |
|
12722
|
|
|
{ |
|
12723
|
|
|
$term = null; |
|
12724
|
|
|
$scheme = null; |
|
12725
|
|
|
$label = null; |
|
12726
|
|
|
if (isset($category['attribs']['']['term'])) |
|
12727
|
|
|
{ |
|
12728
|
|
|
$term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
12729
|
|
|
} |
|
12730
|
|
|
if (isset($category['attribs']['']['scheme'])) |
|
12731
|
|
|
{ |
|
12732
|
|
|
$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
12733
|
|
|
} |
|
12734
|
|
|
if (isset($category['attribs']['']['label'])) |
|
12735
|
|
|
{ |
|
12736
|
|
|
$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
12737
|
|
|
} |
|
12738
|
|
|
$categories[] = $this->registry->create('Category', array($term, $scheme, $label)); |
|
12739
|
|
|
} |
|
12740
|
|
|
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) |
|
12741
|
|
|
{ |
|
12742
|
|
|
// This is really the label, but keep this as the term also for BC. |
|
12743
|
|
|
// Label will also work on retrieving because that falls back to term. |
|
12744
|
|
|
$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
12745
|
|
|
if (isset($category['attribs']['']['domain'])) |
|
12746
|
|
|
{ |
|
12747
|
|
|
$scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
12748
|
|
|
} |
|
12749
|
|
|
else |
|
12750
|
|
|
{ |
|
12751
|
|
|
$scheme = null; |
|
12752
|
|
|
} |
|
12753
|
|
|
$categories[] = $this->registry->create('Category', array($term, $scheme, null)); |
|
12754
|
|
|
} |
|
12755
|
|
|
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) |
|
12756
|
|
|
{ |
|
12757
|
|
|
$categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
|
12758
|
|
|
} |
|
12759
|
|
|
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) |
|
12760
|
|
|
{ |
|
12761
|
|
|
$categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
|
12762
|
|
|
} |
|
12763
|
|
|
if (!empty($categories)) |
|
12764
|
|
|
{ |
|
12765
|
|
|
return array_unique($categories); |
|
12766
|
|
|
} |
|
12767
|
|
|
else |
|
12768
|
|
|
{ |
|
12769
|
|
|
return null; |
|
12770
|
|
|
} |
|
12771
|
|
|
} |
|
12772
|
|
|
public function get_author($key = 0) |
|
12773
|
|
|
{ |
|
12774
|
|
|
$authors = $this->get_authors(); |
|
12775
|
|
|
if (isset($authors[$key])) |
|
12776
|
|
|
{ |
|
12777
|
|
|
return $authors[$key]; |
|
12778
|
|
|
} |
|
12779
|
|
|
else |
|
12780
|
|
|
{ |
|
12781
|
|
|
return null; |
|
12782
|
|
|
} |
|
12783
|
|
|
} |
|
12784
|
|
|
public function get_authors() |
|
12785
|
|
|
{ |
|
12786
|
|
|
$authors = array(); |
|
12787
|
|
|
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) |
|
12788
|
|
|
{ |
|
12789
|
|
|
$name = null; |
|
12790
|
|
|
$uri = null; |
|
12791
|
|
|
$email = null; |
|
12792
|
|
|
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) |
|
12793
|
|
|
{ |
|
12794
|
|
|
$name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
12795
|
|
|
} |
|
12796
|
|
|
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) |
|
12797
|
|
|
{ |
|
12798
|
|
|
$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])); |
|
12799
|
|
|
} |
|
12800
|
|
|
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) |
|
12801
|
|
|
{ |
|
12802
|
|
|
$email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
12803
|
|
|
} |
|
12804
|
|
|
if ($name !== null || $email !== null || $uri !== null) |
|
12805
|
|
|
{ |
|
12806
|
|
|
$authors[] = $this->registry->create('Author', array($name, $uri, $email)); |
|
12807
|
|
|
} |
|
12808
|
|
|
} |
|
12809
|
|
|
if ($author = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) |
|
12810
|
|
|
{ |
|
12811
|
|
|
$name = null; |
|
12812
|
|
|
$url = null; |
|
12813
|
|
|
$email = null; |
|
12814
|
|
|
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) |
|
12815
|
|
|
{ |
|
12816
|
|
|
$name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
12817
|
|
|
} |
|
12818
|
|
|
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) |
|
12819
|
|
|
{ |
|
12820
|
|
|
$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])); |
|
12821
|
|
|
} |
|
12822
|
|
|
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) |
|
12823
|
|
|
{ |
|
12824
|
|
|
$email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
12825
|
|
|
} |
|
12826
|
|
|
if ($name !== null || $email !== null || $url !== null) |
|
12827
|
|
|
{ |
|
12828
|
|
|
$authors[] = $this->registry->create('Author', array($name, $url, $email)); |
|
12829
|
|
|
} |
|
12830
|
|
|
} |
|
12831
|
|
|
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) |
|
12832
|
|
|
{ |
|
12833
|
|
|
$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
|
12834
|
|
|
} |
|
12835
|
|
|
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) |
|
12836
|
|
|
{ |
|
12837
|
|
|
$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
|
12838
|
|
|
} |
|
12839
|
|
|
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) |
|
12840
|
|
|
{ |
|
12841
|
|
|
$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
|
12842
|
|
|
} |
|
12843
|
|
|
if (!empty($authors)) |
|
12844
|
|
|
{ |
|
12845
|
|
|
return array_unique($authors); |
|
12846
|
|
|
} |
|
12847
|
|
|
else |
|
12848
|
|
|
{ |
|
12849
|
|
|
return null; |
|
12850
|
|
|
} |
|
12851
|
|
|
} |
|
12852
|
|
|
public function get_contributor($key = 0) |
|
12853
|
|
|
{ |
|
12854
|
|
|
$contributors = $this->get_contributors(); |
|
12855
|
|
|
if (isset($contributors[$key])) |
|
12856
|
|
|
{ |
|
12857
|
|
|
return $contributors[$key]; |
|
12858
|
|
|
} |
|
12859
|
|
|
else |
|
12860
|
|
|
{ |
|
12861
|
|
|
return null; |
|
12862
|
|
|
} |
|
12863
|
|
|
} |
|
12864
|
|
|
public function get_contributors() |
|
12865
|
|
|
{ |
|
12866
|
|
|
$contributors = array(); |
|
12867
|
|
|
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) |
|
12868
|
|
|
{ |
|
12869
|
|
|
$name = null; |
|
12870
|
|
|
$uri = null; |
|
12871
|
|
|
$email = null; |
|
12872
|
|
|
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) |
|
12873
|
|
|
{ |
|
12874
|
|
|
$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
12875
|
|
|
} |
|
12876
|
|
|
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) |
|
12877
|
|
|
{ |
|
12878
|
|
|
$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])); |
|
12879
|
|
|
} |
|
12880
|
|
|
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) |
|
12881
|
|
|
{ |
|
12882
|
|
|
$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
12883
|
|
|
} |
|
12884
|
|
|
if ($name !== null || $email !== null || $uri !== null) |
|
12885
|
|
|
{ |
|
12886
|
|
|
$contributors[] = $this->registry->create('Author', array($name, $uri, $email)); |
|
12887
|
|
|
} |
|
12888
|
|
|
} |
|
12889
|
|
|
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) |
|
12890
|
|
|
{ |
|
12891
|
|
|
$name = null; |
|
12892
|
|
|
$url = null; |
|
12893
|
|
|
$email = null; |
|
12894
|
|
|
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) |
|
12895
|
|
|
{ |
|
12896
|
|
|
$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
12897
|
|
|
} |
|
12898
|
|
|
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) |
|
12899
|
|
|
{ |
|
12900
|
|
|
$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])); |
|
12901
|
|
|
} |
|
12902
|
|
|
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) |
|
12903
|
|
|
{ |
|
12904
|
|
|
$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
12905
|
|
|
} |
|
12906
|
|
|
if ($name !== null || $email !== null || $url !== null) |
|
12907
|
|
|
{ |
|
12908
|
|
|
$contributors[] = $this->registry->create('Author', array($name, $url, $email)); |
|
12909
|
|
|
} |
|
12910
|
|
|
} |
|
12911
|
|
|
if (!empty($contributors)) |
|
12912
|
|
|
{ |
|
12913
|
|
|
return array_unique($contributors); |
|
12914
|
|
|
} |
|
12915
|
|
|
else |
|
12916
|
|
|
{ |
|
12917
|
|
|
return null; |
|
12918
|
|
|
} |
|
12919
|
|
|
} |
|
12920
|
|
|
public function get_link($key = 0, $rel = 'alternate') |
|
12921
|
|
|
{ |
|
12922
|
|
|
$links = $this->get_links($rel); |
|
12923
|
|
|
if (isset($links[$key])) |
|
12924
|
|
|
{ |
|
12925
|
|
|
return $links[$key]; |
|
12926
|
|
|
} |
|
12927
|
|
|
else |
|
12928
|
|
|
{ |
|
12929
|
|
|
return null; |
|
12930
|
|
|
} |
|
12931
|
|
|
} |
|
12932
|
|
|
|
|
12933
|
|
|
public function get_permalink() |
|
12934
|
|
|
{ |
|
12935
|
|
|
return $this->get_link(0); |
|
12936
|
|
|
} |
|
12937
|
|
|
public function get_links($rel = 'alternate') |
|
12938
|
|
|
{ |
|
12939
|
|
|
if (!isset($this->data['links'])) |
|
12940
|
|
|
{ |
|
12941
|
|
|
$this->data['links'] = array(); |
|
12942
|
|
|
if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link')) |
|
12943
|
|
|
{ |
|
12944
|
|
|
foreach ($links as $link) |
|
12945
|
|
|
{ |
|
12946
|
|
|
if (isset($link['attribs']['']['href'])) |
|
12947
|
|
|
{ |
|
12948
|
|
|
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; |
|
12949
|
|
|
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); |
|
12950
|
|
|
} |
|
12951
|
|
|
} |
|
12952
|
|
|
} |
|
12953
|
|
|
if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link')) |
|
12954
|
|
|
{ |
|
12955
|
|
|
foreach ($links as $link) |
|
12956
|
|
|
{ |
|
12957
|
|
|
if (isset($link['attribs']['']['href'])) |
|
12958
|
|
|
{ |
|
12959
|
|
|
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; |
|
12960
|
|
|
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); |
|
12961
|
|
|
} |
|
12962
|
|
|
} |
|
12963
|
|
|
} |
|
12964
|
|
|
if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) |
|
12965
|
|
|
{ |
|
12966
|
|
|
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); |
|
12967
|
|
|
} |
|
12968
|
|
|
if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) |
|
12969
|
|
|
{ |
|
12970
|
|
|
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); |
|
12971
|
|
|
} |
|
12972
|
|
|
if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) |
|
12973
|
|
|
{ |
|
12974
|
|
|
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); |
|
12975
|
|
|
} |
|
12976
|
|
|
$keys = array_keys($this->data['links']); |
|
12977
|
|
|
foreach ($keys as $key) |
|
12978
|
|
|
{ |
|
12979
|
|
|
if ($this->registry->call('Misc', 'is_isegment_nz_nc', array($key))) |
|
12980
|
|
|
{ |
|
12981
|
|
|
if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) |
|
12982
|
|
|
{ |
|
12983
|
|
|
$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); |
|
12984
|
|
|
$this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; |
|
12985
|
|
|
} |
|
12986
|
|
|
else |
|
12987
|
|
|
{ |
|
12988
|
|
|
$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; |
|
12989
|
|
|
} |
|
12990
|
|
|
} |
|
12991
|
|
|
elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) |
|
12992
|
|
|
{ |
|
12993
|
|
|
$this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; |
|
12994
|
|
|
} |
|
12995
|
|
|
$this->data['links'][$key] = array_unique($this->data['links'][$key]); |
|
12996
|
|
|
} |
|
12997
|
|
|
} |
|
12998
|
|
|
if (isset($this->data['links'][$rel])) |
|
12999
|
|
|
{ |
|
13000
|
|
|
return $this->data['links'][$rel]; |
|
13001
|
|
|
} |
|
13002
|
|
|
else |
|
13003
|
|
|
{ |
|
13004
|
|
|
return null; |
|
13005
|
|
|
} |
|
13006
|
|
|
} |
|
13007
|
|
|
public function get_description() |
|
13008
|
|
|
{ |
|
13009
|
|
|
if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) |
|
13010
|
|
|
{ |
|
13011
|
|
|
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
13012
|
|
|
} |
|
13013
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline')) |
|
13014
|
|
|
{ |
|
13015
|
|
|
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
13016
|
|
|
} |
|
13017
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) |
|
13018
|
|
|
{ |
|
13019
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
13020
|
|
|
} |
|
13021
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) |
|
13022
|
|
|
{ |
|
13023
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
13024
|
|
|
} |
|
13025
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) |
|
13026
|
|
|
{ |
|
13027
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
13028
|
|
|
} |
|
13029
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) |
|
13030
|
|
|
{ |
|
13031
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
13032
|
|
|
} |
|
13033
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) |
|
13034
|
|
|
{ |
|
13035
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
13036
|
|
|
} |
|
13037
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) |
|
13038
|
|
|
{ |
|
13039
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
|
13040
|
|
|
} |
|
13041
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) |
|
13042
|
|
|
{ |
|
13043
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
|
13044
|
|
|
} |
|
13045
|
|
|
else |
|
13046
|
|
|
{ |
|
13047
|
|
|
return null; |
|
13048
|
|
|
} |
|
13049
|
|
|
} |
|
13050
|
|
|
public function get_copyright() |
|
13051
|
|
|
{ |
|
13052
|
|
|
if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) |
|
13053
|
|
|
{ |
|
13054
|
|
|
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
13055
|
|
|
} |
|
13056
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright')) |
|
13057
|
|
|
{ |
|
13058
|
|
|
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
|
13059
|
|
|
} |
|
13060
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright')) |
|
13061
|
|
|
{ |
|
13062
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
13063
|
|
|
} |
|
13064
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) |
|
13065
|
|
|
{ |
|
13066
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
13067
|
|
|
} |
|
13068
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) |
|
13069
|
|
|
{ |
|
13070
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
13071
|
|
|
} |
|
13072
|
|
|
else |
|
13073
|
|
|
{ |
|
13074
|
|
|
return null; |
|
13075
|
|
|
} |
|
13076
|
|
|
} |
|
13077
|
|
|
public function get_language() |
|
13078
|
|
|
{ |
|
13079
|
|
|
if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) |
|
13080
|
|
|
{ |
|
13081
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
13082
|
|
|
} |
|
13083
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language')) |
|
13084
|
|
|
{ |
|
13085
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
13086
|
|
|
} |
|
13087
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language')) |
|
13088
|
|
|
{ |
|
13089
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
13090
|
|
|
} |
|
13091
|
|
|
elseif (isset($this->data['xml_lang'])) |
|
13092
|
|
|
{ |
|
13093
|
|
|
return $this->sanitize($this->data['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
13094
|
|
|
} |
|
13095
|
|
|
else |
|
13096
|
|
|
{ |
|
13097
|
|
|
return null; |
|
13098
|
|
|
} |
|
13099
|
|
|
} |
|
13100
|
|
|
public function get_latitude() |
|
13101
|
|
|
{ |
|
13102
|
|
|
if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) |
|
13103
|
|
|
{ |
|
13104
|
|
|
return (float) $return[0]['data']; |
|
13105
|
|
|
} |
|
13106
|
|
|
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)) |
|
13107
|
|
|
{ |
|
13108
|
|
|
return (float) $match[1]; |
|
13109
|
|
|
} |
|
13110
|
|
|
else |
|
13111
|
|
|
{ |
|
13112
|
|
|
return null; |
|
13113
|
|
|
} |
|
13114
|
|
|
} |
|
13115
|
|
|
public function get_longitude() |
|
13116
|
|
|
{ |
|
13117
|
|
|
if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) |
|
13118
|
|
|
{ |
|
13119
|
|
|
return (float) $return[0]['data']; |
|
13120
|
|
|
} |
|
13121
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) |
|
13122
|
|
|
{ |
|
13123
|
|
|
return (float) $return[0]['data']; |
|
13124
|
|
|
} |
|
13125
|
|
|
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)) |
|
13126
|
|
|
{ |
|
13127
|
|
|
return (float) $match[2]; |
|
13128
|
|
|
} |
|
13129
|
|
|
else |
|
13130
|
|
|
{ |
|
13131
|
|
|
return null; |
|
13132
|
|
|
} |
|
13133
|
|
|
} |
|
13134
|
|
|
public function get_image_url() |
|
13135
|
|
|
{ |
|
13136
|
|
|
if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) |
|
13137
|
|
|
{ |
|
13138
|
|
|
return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI); |
|
13139
|
|
|
} |
|
13140
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo')) |
|
13141
|
|
|
{ |
|
13142
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
|
13143
|
|
|
} |
|
13144
|
|
|
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) |
|
13145
|
|
|
{ |
|
13146
|
|
|
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
|
13147
|
|
|
} |
|
13148
|
|
|
else |
|
13149
|
|
|
{ |
|
13150
|
|
|
return null; |
|
13151
|
|
|
} |
|
13152
|
|
|
} |
|
13153
|
|
|
} |
|
13154
|
|
|
class SimplePie_XML_Declaration_Parser |
|
13155
|
|
|
{ |
|
13156
|
|
|
|
|
13157
|
|
|
var $version = '1.0'; |
|
13158
|
|
|
|
|
13159
|
|
|
var $encoding = 'UTF-8'; |
|
13160
|
|
|
|
|
13161
|
|
|
var $standalone = false; |
|
13162
|
|
|
|
|
13163
|
|
|
var $state = 'before_version_name'; |
|
13164
|
|
|
|
|
13165
|
|
|
var $data = ''; |
|
13166
|
|
|
|
|
13167
|
|
|
var $data_length = 0; |
|
13168
|
|
|
|
|
13169
|
|
|
var $position = 0; |
|
13170
|
|
|
|
|
13171
|
|
|
public function __construct($data) |
|
13172
|
|
|
{ |
|
13173
|
|
|
$this->data = $data; |
|
13174
|
|
|
$this->data_length = strlen($this->data); |
|
13175
|
|
|
} |
|
13176
|
|
|
|
|
13177
|
|
|
public function parse() |
|
13178
|
|
|
{ |
|
13179
|
|
|
while ($this->state && $this->state !== 'emit' && $this->has_data()) |
|
13180
|
|
|
{ |
|
13181
|
|
|
$state = $this->state; |
|
13182
|
|
|
$this->$state(); |
|
13183
|
|
|
} |
|
13184
|
|
|
$this->data = ''; |
|
13185
|
|
|
if ($this->state === 'emit') |
|
13186
|
|
|
{ |
|
13187
|
|
|
return true; |
|
13188
|
|
|
} |
|
13189
|
|
|
else |
|
13190
|
|
|
{ |
|
13191
|
|
|
$this->version = ''; |
|
13192
|
|
|
$this->encoding = ''; |
|
13193
|
|
|
$this->standalone = ''; |
|
13194
|
|
|
return false; |
|
13195
|
|
|
} |
|
13196
|
|
|
} |
|
13197
|
|
|
|
|
13198
|
|
|
public function has_data() |
|
13199
|
|
|
{ |
|
13200
|
|
|
return (bool) ($this->position < $this->data_length); |
|
13201
|
|
|
} |
|
13202
|
|
|
|
|
13203
|
|
|
public function skip_whitespace() |
|
13204
|
|
|
{ |
|
13205
|
|
|
$whitespace = strspn($this->data, "\x09\x0A\x0D\x20", $this->position); |
|
13206
|
|
|
$this->position += $whitespace; |
|
13207
|
|
|
return $whitespace; |
|
13208
|
|
|
} |
|
13209
|
|
|
|
|
13210
|
|
|
public function get_value() |
|
13211
|
|
|
{ |
|
13212
|
|
|
$quote = substr($this->data, $this->position, 1); |
|
13213
|
|
|
if ($quote === '"' || $quote === "'") |
|
13214
|
|
|
{ |
|
13215
|
|
|
$this->position++; |
|
13216
|
|
|
$len = strcspn($this->data, $quote, $this->position); |
|
13217
|
|
|
if ($this->has_data()) |
|
13218
|
|
|
{ |
|
13219
|
|
|
$value = substr($this->data, $this->position, $len); |
|
13220
|
|
|
$this->position += $len + 1; |
|
13221
|
|
|
return $value; |
|
13222
|
|
|
} |
|
13223
|
|
|
} |
|
13224
|
|
|
return false; |
|
13225
|
|
|
} |
|
13226
|
|
|
public function before_version_name() |
|
13227
|
|
|
{ |
|
13228
|
|
|
if ($this->skip_whitespace()) |
|
13229
|
|
|
{ |
|
13230
|
|
|
$this->state = 'version_name'; |
|
13231
|
|
|
} |
|
13232
|
|
|
else |
|
13233
|
|
|
{ |
|
13234
|
|
|
$this->state = false; |
|
13235
|
|
|
} |
|
13236
|
|
|
} |
|
13237
|
|
|
public function version_name() |
|
13238
|
|
|
{ |
|
13239
|
|
|
if (substr($this->data, $this->position, 7) === 'version') |
|
13240
|
|
|
{ |
|
13241
|
|
|
$this->position += 7; |
|
13242
|
|
|
$this->skip_whitespace(); |
|
13243
|
|
|
$this->state = 'version_equals'; |
|
13244
|
|
|
} |
|
13245
|
|
|
else |
|
13246
|
|
|
{ |
|
13247
|
|
|
$this->state = false; |
|
13248
|
|
|
} |
|
13249
|
|
|
} |
|
13250
|
|
|
public function version_equals() |
|
13251
|
|
|
{ |
|
13252
|
|
|
if (substr($this->data, $this->position, 1) === '=') |
|
13253
|
|
|
{ |
|
13254
|
|
|
$this->position++; |
|
13255
|
|
|
$this->skip_whitespace(); |
|
13256
|
|
|
$this->state = 'version_value'; |
|
13257
|
|
|
} |
|
13258
|
|
|
else |
|
13259
|
|
|
{ |
|
13260
|
|
|
$this->state = false; |
|
13261
|
|
|
} |
|
13262
|
|
|
} |
|
13263
|
|
|
public function version_value() |
|
13264
|
|
|
{ |
|
13265
|
|
|
if ($this->version = $this->get_value()) |
|
13266
|
|
|
{ |
|
13267
|
|
|
$this->skip_whitespace(); |
|
13268
|
|
|
if ($this->has_data()) |
|
13269
|
|
|
{ |
|
13270
|
|
|
$this->state = 'encoding_name'; |
|
13271
|
|
|
} |
|
13272
|
|
|
else |
|
13273
|
|
|
{ |
|
13274
|
|
|
$this->state = 'emit'; |
|
13275
|
|
|
} |
|
13276
|
|
|
} |
|
13277
|
|
|
else |
|
13278
|
|
|
{ |
|
13279
|
|
|
$this->state = false; |
|
13280
|
|
|
} |
|
13281
|
|
|
} |
|
13282
|
|
|
public function encoding_name() |
|
13283
|
|
|
{ |
|
13284
|
|
|
if (substr($this->data, $this->position, 8) === 'encoding') |
|
13285
|
|
|
{ |
|
13286
|
|
|
$this->position += 8; |
|
13287
|
|
|
$this->skip_whitespace(); |
|
13288
|
|
|
$this->state = 'encoding_equals'; |
|
13289
|
|
|
} |
|
13290
|
|
|
else |
|
13291
|
|
|
{ |
|
13292
|
|
|
$this->state = 'standalone_name'; |
|
13293
|
|
|
} |
|
13294
|
|
|
} |
|
13295
|
|
|
public function encoding_equals() |
|
13296
|
|
|
{ |
|
13297
|
|
|
if (substr($this->data, $this->position, 1) === '=') |
|
13298
|
|
|
{ |
|
13299
|
|
|
$this->position++; |
|
13300
|
|
|
$this->skip_whitespace(); |
|
13301
|
|
|
$this->state = 'encoding_value'; |
|
13302
|
|
|
} |
|
13303
|
|
|
else |
|
13304
|
|
|
{ |
|
13305
|
|
|
$this->state = false; |
|
13306
|
|
|
} |
|
13307
|
|
|
} |
|
13308
|
|
|
public function encoding_value() |
|
13309
|
|
|
{ |
|
13310
|
|
|
if ($this->encoding = $this->get_value()) |
|
13311
|
|
|
{ |
|
13312
|
|
|
$this->skip_whitespace(); |
|
13313
|
|
|
if ($this->has_data()) |
|
13314
|
|
|
{ |
|
13315
|
|
|
$this->state = 'standalone_name'; |
|
13316
|
|
|
} |
|
13317
|
|
|
else |
|
13318
|
|
|
{ |
|
13319
|
|
|
$this->state = 'emit'; |
|
13320
|
|
|
} |
|
13321
|
|
|
} |
|
13322
|
|
|
else |
|
13323
|
|
|
{ |
|
13324
|
|
|
$this->state = false; |
|
13325
|
|
|
} |
|
13326
|
|
|
} |
|
13327
|
|
|
public function standalone_name() |
|
13328
|
|
|
{ |
|
13329
|
|
|
if (substr($this->data, $this->position, 10) === 'standalone') |
|
13330
|
|
|
{ |
|
13331
|
|
|
$this->position += 10; |
|
13332
|
|
|
$this->skip_whitespace(); |
|
13333
|
|
|
$this->state = 'standalone_equals'; |
|
13334
|
|
|
} |
|
13335
|
|
|
else |
|
13336
|
|
|
{ |
|
13337
|
|
|
$this->state = false; |
|
13338
|
|
|
} |
|
13339
|
|
|
} |
|
13340
|
|
|
public function standalone_equals() |
|
13341
|
|
|
{ |
|
13342
|
|
|
if (substr($this->data, $this->position, 1) === '=') |
|
13343
|
|
|
{ |
|
13344
|
|
|
$this->position++; |
|
13345
|
|
|
$this->skip_whitespace(); |
|
13346
|
|
|
$this->state = 'standalone_value'; |
|
13347
|
|
|
} |
|
13348
|
|
|
else |
|
13349
|
|
|
{ |
|
13350
|
|
|
$this->state = false; |
|
13351
|
|
|
} |
|
13352
|
|
|
} |
|
13353
|
|
|
public function standalone_value() |
|
13354
|
|
|
{ |
|
13355
|
|
|
if ($standalone = $this->get_value()) |
|
13356
|
|
|
{ |
|
13357
|
|
|
switch ($standalone) |
|
13358
|
|
|
{ |
|
13359
|
|
|
case 'yes': |
|
13360
|
|
|
$this->standalone = true; |
|
13361
|
|
|
break; |
|
13362
|
|
|
case 'no': |
|
13363
|
|
|
$this->standalone = false; |
|
13364
|
|
|
break; |
|
13365
|
|
|
default: |
|
13366
|
|
|
$this->state = false; |
|
13367
|
|
|
return; |
|
13368
|
|
|
} |
|
13369
|
|
|
$this->skip_whitespace(); |
|
13370
|
|
|
if ($this->has_data()) |
|
13371
|
|
|
{ |
|
13372
|
|
|
$this->state = false; |
|
13373
|
|
|
} |
|
13374
|
|
|
else |
|
13375
|
|
|
{ |
|
13376
|
|
|
$this->state = 'emit'; |
|
13377
|
|
|
} |
|
13378
|
|
|
} |
|
13379
|
|
|
else |
|
13380
|
|
|
{ |
|
13381
|
|
|
$this->state = false; |
|
13382
|
|
|
} |
|
13383
|
|
|
} |
|
13384
|
|
|
} |