175 | | return true; |
176 | | } |
177 | | |
178 | | // Strip out certain well-known ads |
179 | | function strip_ads($enable) { |
180 | | $this->strip_ads = (bool) $enable; |
181 | | return true; |
182 | | } |
183 | | |
184 | | // Strip out potentially dangerous tags |
185 | | function strip_htmltags($tags, $encode=false) { |
186 | | $this->strip_htmltags = (string) $tags; |
187 | | $this->encode_instead_of_strip = (bool) $encode; |
188 | | return true; |
189 | | } |
190 | | |
191 | | // Encode dangerous tags instead of stripping them |
192 | | function encode_instead_of_strip($encode=true) { |
193 | | $this->encode_instead_of_strip = (bool) $encode; |
194 | | return true; |
195 | | } |
196 | | |
197 | | // Strip out potentially dangerous attributes |
198 | | function strip_attributes($attrib) { |
199 | | $this->strip_attributes = (string) $attrib; |
200 | | return true; |
201 | | } |
202 | | |
203 | | |
204 | | |
205 | | |
206 | | /**************************************************** |
207 | | MAIN INITIALIZATION FUNCTION |
208 | | Rewrites the feed so that it actually resembles XML, processes the XML, |
209 | | and builds an array from the feed. |
210 | | ****************************************************/ |
211 | | function init() { |
212 | | // If Bypass Image Hotlink is enabled, send image to the page and quit. |
213 | | if ($this->bypass_image_hotlink) { |
214 | | if (isset($_GET[$this->bypass_image_hotlink]) && !empty($_GET[$this->bypass_image_hotlink])) { |
215 | | $this->display_image($_GET[$this->bypass_image_hotlink]); |
216 | | exit; |
217 | | } |
218 | | } |
219 | | |
220 | | // If Bypass Image Hotlink is enabled, send image to the page and quit. |
221 | | if (isset($_GET['js'])) { |
222 | | |
223 | | // JavaScript for the Odeo Player |
224 | | $embed=''; |
225 | | $embed.='function embed_odeo(link) {'; |
226 | | $embed.='document.writeln(\''; |
227 | | $embed.='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '; |
228 | | $embed.=' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" '; |
229 | | $embed.=' width="440" '; |
230 | | $embed.=' height="80" '; |
231 | | $embed.=' align="middle">'; |
232 | | $embed.='<param name="movie" value="http://odeo.com/flash/audio_player_fullsize.swf" />'; |
233 | | $embed.='<param name="allowScriptAccess" value="any" />'; |
234 | | $embed.='<param name="quality" value="high">'; |
235 | | $embed.='<param name="wmode" value="transparent">'; |
236 | | $embed.='<param name="flashvars" value="valid_sample_rate=true&external_url=\'+link+\'" />'; |
237 | | $embed.='<embed src="http://odeo.com/flash/audio_player_fullsize.swf" '; |
238 | | $embed.=' pluginspage="http://www.macromedia.com/go/getflashplayer" '; |
239 | | $embed.=' type="application/x-shockwave-flash" '; |
240 | | $embed.=' quality="high" '; |
241 | | $embed.=' width="440" '; |
242 | | $embed.=' height="80" '; |
243 | | $embed.=' wmode="transparent" '; |
244 | | $embed.=' allowScriptAccess="any" '; |
245 | | $embed.=' flashvars="valid_sample_rate=true&external_url=\'+link+\'">'; |
246 | | $embed.='</embed>'; |
247 | | $embed.='</object>'; |
248 | | $embed.='\');'; |
249 | | $embed.='}'; |
250 | | |
251 | | $embed.="\r\n"; |
252 | | |
253 | | $embed.='function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {'; |
254 | | $embed.='document.writeln(\''; |
255 | | $embed.='<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" '; |
256 | | $embed.=' style="cursor:hand; cursor:pointer;" '; |
257 | | $embed.=' type="\'+type+\'" '; |
258 | | $embed.=' codebase="http://www.apple.com/qtactivex/qtplugin.cab" '; |
259 | | $embed.=' bgcolor="\'+bgcolor+\'" '; |
260 | | $embed.=' width="\'+width+\'" '; |
261 | | $embed.=' height="\'+height+\'">'; |
262 | | $embed.='<param name="href" value="\'+link+\'" />'; |
263 | | $embed.='<param name="src" value="\'+placeholder+\'" />'; |
264 | | $embed.='<param name="autoplay" value="false" />'; |
265 | | $embed.='<param name="target" value="myself" />'; |
266 | | $embed.='<param name="controller" value="false" />'; |
267 | | $embed.='<param name="loop" value="\'+loop+\'" />'; |
268 | | $embed.='<param name="scale" value="aspect" />'; |
269 | | $embed.='<param name="bgcolor" value="\'+bgcolor+\'">'; |
270 | | $embed.='<embed type="\'+type+\'" '; |
271 | | $embed.=' style="cursor:hand; cursor:pointer;" '; |
272 | | $embed.=' href="\'+link+\'" '; |
273 | | $embed.=' src="\'+placeholder+\'"'; |
274 | | $embed.=' width="\'+width+\'" '; |
275 | | $embed.=' height="\'+height+\'" '; |
276 | | $embed.=' autoplay="false" '; |
277 | | $embed.=' target="myself" '; |
278 | | $embed.=' controller="false" '; |
279 | | $embed.=' loop="\'+loop+\'" '; |
280 | | $embed.=' scale="aspect" '; |
281 | | $embed.=' bgcolor="\'+bgcolor+\'" '; |
282 | | $embed.=' pluginspage="http://www.apple.com/quicktime/download/">'; |
283 | | $embed.='</embed>'; |
284 | | $embed.='</object>'; |
285 | | $embed.='\');'; |
286 | | $embed.='}'; |
287 | | |
288 | | $embed.="\r\n"; |
289 | | |
290 | | $embed.='function embed_flash(bgcolor, width, height, link, loop, type) {'; |
291 | | $embed.='document.writeln(\''; |
292 | | $embed.='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '; |
293 | | $embed.=' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" '; |
294 | | $embed.=' bgcolor="\'+bgcolor+\'" '; |
295 | | $embed.=' width="\'+width+\'" '; |
296 | | $embed.=' height="\'+height+\'">'; |
297 | | $embed.='<param name="movie" value="\'+link+\'">'; |
298 | | $embed.='<param name="quality" value="high">'; |
299 | | $embed.='<param name="loop" value="\'+loop+\'">'; |
300 | | $embed.='<param name="bgcolor" value="\'+bgcolor+\'">'; |
301 | | $embed.='<embed src="\'+link+\'" '; |
302 | | $embed.=' pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" '; |
303 | | $embed.=' type="\'+type+\'" '; |
304 | | $embed.=' quality="high" '; |
305 | | $embed.=' width="\'+width+\'" '; |
306 | | $embed.=' height="\'+height+\'" '; |
307 | | $embed.=' bgcolor="\'+bgcolor+\'" '; |
308 | | $embed.=' loop="\'+loop+\'">'; |
309 | | $embed.='</embed>'; |
310 | | $embed.='</object>'; |
311 | | $embed.='\');'; |
312 | | $embed.='}'; |
313 | | |
314 | | $embed.="\r\n"; |
315 | | |
316 | | $embed.='function embed_wmedia(width, height, link) {'; |
317 | | $embed.='document.writeln(\''; |
318 | | $embed.='<object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"'; |
319 | | $embed.=' type="application/x-oleobject"'; |
320 | | $embed.=' width="\'+width+\'"'; |
321 | | $embed.=' height="\'+height+\'"'; |
322 | | $embed.=' standby="Loading Windows Media Player...">'; |
323 | | $embed.='<param name="FileName" value="\'+link+\'">'; |
324 | | $embed.='<param name="autosize" value="true">'; |
325 | | $embed.='<param name="ShowControls" value="true">'; |
326 | | $embed.='<param name="ShowStatusBar" value="false">'; |
327 | | $embed.='<param name="ShowDisplay" value="false">'; |
328 | | $embed.='<param name="autostart" value="false">'; |
329 | | $embed.='<embed type="application/x-mplayer2" '; |
330 | | $embed.=' src="\'+link+\'" '; |
331 | | $embed.=' autosize="1" '; |
332 | | $embed.=' width="\'+width+\'" '; |
333 | | $embed.=' height="\'+height+\'" '; |
334 | | $embed.=' showcontrols="1" '; |
335 | | $embed.=' showstatusbar="0" '; |
336 | | $embed.=' showdisplay="0" '; |
337 | | $embed.=' autostart="0">'; |
338 | | $embed.='</embed>'; |
339 | | $embed.='</object>'; |
340 | | $embed.='\');'; |
341 | | $embed.='}'; |
342 | | |
343 | | $embed.="\r\n"; |
344 | | |
345 | | // enable gzip compression |
346 | | ob_start ("ob_gzhandler"); |
347 | | header("Content-type: text/javascript; charset: UTF-8"); |
348 | | header("Cache-Control: must-revalidate"); |
349 | | header("Expires: " . gmdate("D, d M Y H:i:s", time() + 60*60*24) . " GMT"); |
| 143 | } |
| 144 | |
| 145 | function input_encoding($encoding = false) |
| 146 | { |
| 147 | if ($encoding) |
| 148 | { |
| 149 | $this->input_encoding = (string) $encoding; |
| 150 | } |
| 151 | else |
| 152 | { |
| 153 | $this->input_encoding = false; |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | function set_cache_class($class = 'SimplePie_Cache') |
| 158 | { |
| 159 | if (SimplePie_Misc::is_a_class($class, 'SimplePie_Cache')) |
| 160 | { |
| 161 | $this->cache_class = $class; |
| 162 | return true; |
| 163 | } |
| 164 | return false; |
| 165 | } |
| 166 | |
| 167 | function set_locator_class($class = 'SimplePie_Locator') |
| 168 | { |
| 169 | if (SimplePie_Misc::is_a_class($class, 'SimplePie_Locator')) |
| 170 | { |
| 171 | $this->locator_class = $class; |
| 172 | return true; |
| 173 | } |
| 174 | return false; |
| 175 | } |
| 176 | |
| 177 | function set_parser_class($class = 'SimplePie_Parser') |
| 178 | { |
| 179 | if (SimplePie_Misc::is_a_class($class, 'SimplePie_Parser')) |
| 180 | { |
| 181 | $this->parser_class = $class; |
| 182 | return true; |
| 183 | } |
| 184 | return false; |
| 185 | } |
| 186 | |
| 187 | function set_file_class($class = 'SimplePie_File') |
| 188 | { |
| 189 | if (SimplePie_Misc::is_a_class($class, 'SimplePie_File')) |
| 190 | { |
| 191 | $this->file_class = $class; |
| 192 | return true; |
| 193 | } |
| 194 | return false; |
| 195 | } |
| 196 | |
| 197 | function set_sanitize_class($object = 'SimplePie_Sanitize') |
| 198 | { |
| 199 | if (class_exists($object)) |
| 200 | { |
| 201 | $this->sanitize = new $object; |
| 202 | return true; |
| 203 | } |
| 204 | return false; |
| 205 | } |
| 206 | |
| 207 | function set_useragent($ua) |
| 208 | { |
| 209 | $this->useragent = (string) $ua; |
| 210 | } |
| 211 | |
| 212 | function force_fsockopen($enable = false) |
| 213 | { |
| 214 | $this->force_fsockopen = (bool) $enable; |
| 215 | } |
| 216 | |
| 217 | function set_cache_name_type($type = 'sha1') |
| 218 | { |
| 219 | $type = strtolower(trim($type)); |
| 220 | switch ($type) |
| 221 | { |
| 222 | case 'crc32': |
| 223 | $this->cache_name_type = 'crc32'; |
| 224 | break; |
| 225 | |
| 226 | case 'md5': |
| 227 | $this->cache_name_type = 'md5'; |
| 228 | break; |
| 229 | |
| 230 | case 'rawurlencode': |
| 231 | $this->cache_name_type = 'rawurlencode'; |
| 232 | break; |
| 233 | |
| 234 | case 'urlencode': |
| 235 | $this->cache_name_type = 'urlencode'; |
| 236 | break; |
| 237 | |
| 238 | default: |
| 239 | $this->cache_name_type = 'sha1'; |
| 240 | break; |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | function bypass_image_hotlink($get = false) |
| 245 | { |
| 246 | $this->sanitize->bypass_image_hotlink($get); |
| 247 | } |
| 248 | |
| 249 | function bypass_image_hotlink_page($page = false) |
| 250 | { |
| 251 | $this->sanitize->bypass_image_hotlink_page($page); |
| 252 | } |
| 253 | |
| 254 | function replace_headers($enable = false) |
| 255 | { |
| 256 | $this->sanitize->replace_headers($enable); |
| 257 | } |
| 258 | |
| 259 | function remove_div($enable = true) |
| 260 | { |
| 261 | $this->sanitize->remove_div($enable); |
| 262 | } |
| 263 | |
| 264 | function strip_ads($enable = false) |
| 265 | { |
| 266 | $this->sanitize->strip_ads($enable); |
| 267 | } |
| 268 | |
| 269 | function strip_htmltags($tags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'), $encode = null) |
| 270 | { |
| 271 | $this->sanitize->strip_htmltags($tags); |
| 272 | if (!is_null($encode)) |
| 273 | { |
| 274 | $this->sanitize->encode_instead_of_strip($tags); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | function encode_instead_of_strip($enable = true) |
| 279 | { |
| 280 | $this->sanitize->encode_instead_of_strip($enable); |
| 281 | } |
| 282 | |
| 283 | function strip_attributes($attribs = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur')) |
| 284 | { |
| 285 | $this->sanitize->strip_attributes($attribs); |
| 286 | } |
| 287 | |
| 288 | function output_encoding($encoding = 'UTF-8') |
| 289 | { |
| 290 | $this->sanitize->output_encoding($encoding); |
| 291 | } |
| 292 | |
| 293 | function set_item_class($class = 'SimplePie_Item') |
| 294 | { |
| 295 | return $this->sanitize->set_item_class($class); |
| 296 | } |
| 297 | |
| 298 | function set_author_class($class = 'SimplePie_Author') |
| 299 | { |
| 300 | return $this->sanitize->set_author_class($class); |
| 301 | } |
| 302 | |
| 303 | function set_enclosure_class($class = 'SimplePie_Enclosure') |
| 304 | { |
| 305 | return $this->sanitize->set_enclosure_class($class); |
| 306 | } |
| 307 | |
| 308 | function init() |
| 309 | { |
| 310 | if (!(function_exists('version_compare') && ((version_compare(phpversion(), '4.3.2', '>=') && version_compare(phpversion(), '5', '<')) || version_compare(phpversion(), '5.0.3', '>='))) || !extension_loaded('xml') || !extension_loaded('pcre')) |
| 311 | { |
| 312 | return false; |
| 313 | } |
| 314 | if ($this->sanitize->bypass_image_hotlink && !empty($_GET[$this->sanitize->bypass_image_hotlink])) |
| 315 | { |
| 316 | if (get_magic_quotes_gpc()) |
| 317 | { |
| 318 | $_GET[$this->sanitize->bypass_image_hotlink] = stripslashes($_GET[$this->sanitize->bypass_image_hotlink]); |
| 319 | } |
| 320 | SimplePie_Misc::display_file($_GET[$this->sanitize->bypass_image_hotlink], 10, $this->useragent); |
| 321 | } |
| 322 | |
| 323 | if (isset($_GET['js'])) |
| 324 | { |
| 325 | $embed = <<<EOT |
| 326 | function embed_odeo(link) { |
| 327 | document.writeln('<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url='+link+'"></embed>'); |
| 328 | } |
| 329 | |
| 330 | function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) { |
| 331 | if (placeholder != '') { |
| 332 | document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>'); |
| 333 | } |
| 334 | else { |
| 335 | document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="true" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>'); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | function embed_flash(bgcolor, width, height, link, loop, type) { |
| 340 | document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>'); |
| 341 | } |
| 342 | |
| 343 | function embed_wmedia(width, height, link) { |
| 344 | document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>'); |
| 345 | } |
| 346 | EOT; |
| 347 | |
| 348 | if (function_exists('ob_gzhandler')) |
| 349 | { |
| 350 | ob_start('ob_gzhandler'); |
| 351 | } |
| 352 | header('Content-type: text/javascript; charset: UTF-8'); |
| 353 | header('Cache-Control: must-revalidate'); |
| 354 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 86400) . ' GMT'); |
407 | | } else { |
408 | | $this->sp_error("A feed could not be found at $this->rss_url", E_USER_WARNING, __FILE__, __LINE__); |
409 | | return false; |
410 | | } |
411 | | |
412 | | // Trim out any whitespace at the beginning or the end of the file |
413 | | $mp_rss = trim($mp_rss); |
414 | | |
415 | | // Get encoding |
416 | | // Attempt to support everything from libiconv (http://www.gnu.org/software/libiconv/) |
417 | | // Support everything from mbstring (http://www.php.net/manual/en/ref.mbstring.php#mbstring.supported-encodings) |
418 | | $use_iconv = false; |
419 | | $use_mbstring = false; |
420 | | $utf8_fail = true; |
421 | | if (preg_match('/encoding=["|\'](.*)["|\']/Ui', $mp_rss, $encoding)) { |
422 | | $match = $encoding; |
423 | | switch (strtolower($encoding[1])) { |
424 | | |
425 | | // 7bit |
426 | | case '7bit': |
427 | | case '7-bit': |
428 | | $encoding = '7bit'; |
429 | | $use_mbstring = true; |
| 479 | else |
| 480 | { |
| 481 | $this->error = "A feed could not be found at $this->rss_url"; |
| 482 | SimplePie_Misc::error($this->error, E_USER_WARNING, __FILE__, __LINE__); |
| 483 | return false; |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | $headers = $file->headers(); |
| 488 | $data = trim($file->body()); |
| 489 | $file->close(); |
| 490 | unset($file); |
| 491 | } |
| 492 | else |
| 493 | { |
| 494 | $data = $this->raw_data; |
| 495 | } |
| 496 | |
| 497 | // First check to see if input has been overridden. |
| 498 | if (!empty($this->input_encoding)) |
| 499 | { |
| 500 | $encoding = $this->input_encoding; |
| 501 | } |
| 502 | // Second try HTTP headers |
| 503 | else if (!empty($headers['content-type']) && preg_match('/charset\s*=\s*([^;]*)/i', $headers['content-type'], $charset)) |
| 504 | { |
| 505 | $encoding = $charset[1]; |
| 506 | } |
| 507 | // Then prolog, if at the very start of the document |
| 508 | else if (preg_match('/^<\?xml(.*)?>/msiU', $data, $prolog) && preg_match('/encoding\s*=\s*("([^"]*)"|\'([^\']*)\')/Ui', $prolog[1], $encoding)) |
| 509 | { |
| 510 | $encoding = substr($encoding[1], 1, -1); |
| 511 | } |
| 512 | // UTF-32 Big Endian BOM |
| 513 | else if (strpos($data, sprintf('%c%c%c%c', 0x00, 0x00, 0xFE, 0xFF)) === 0) |
| 514 | { |
| 515 | $encoding = 'UTF-32be'; |
| 516 | } |
| 517 | // UTF-32 Little Endian BOM |
| 518 | else if (strpos($data, sprintf('%c%c%c%c', 0xFF, 0xFE, 0x00, 0x00)) === 0) |
| 519 | { |
| 520 | $encoding = 'UTF-32'; |
| 521 | } |
| 522 | // UTF-16 Big Endian BOM |
| 523 | else if (strpos($data, sprintf('%c%c', 0xFE, 0xFF)) === 0) |
| 524 | { |
| 525 | $encoding = 'UTF-16be'; |
| 526 | } |
| 527 | // UTF-16 Little Endian BOM |
| 528 | else if (strpos($data, sprintf('%c%c', 0xFF, 0xFE)) === 0) |
| 529 | { |
| 530 | $encoding = 'UTF-16le'; |
| 531 | } |
| 532 | // UTF-8 BOM |
| 533 | else if (strpos($data, sprintf('%c%c%c', 0xEF, 0xBB, 0xBF)) === 0) |
| 534 | { |
| 535 | $encoding = 'UTF-8'; |
| 536 | } |
| 537 | // Fallback to the default |
| 538 | else |
| 539 | { |
| 540 | $encoding = null; |
| 541 | } |
| 542 | |
| 543 | // Change the encoding to UTF-8 (as we always use UTF-8 internally) |
| 544 | $data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8'); |
| 545 | |
| 546 | // Strip illegal characters (if on less than PHP5, as on PHP5 expat can manage fine) |
| 547 | if (version_compare(phpversion(), '5', '<')) |
| 548 | { |
| 549 | if (function_exists('iconv')) |
| 550 | { |
| 551 | $data = iconv('UTF-8', 'UTF-8//IGNORE', $data); |
| 552 | } |
| 553 | else if (function_exists('mb_convert_encoding')) |
| 554 | { |
| 555 | $data = mb_convert_encoding($data, 'UTF-8', 'UTF-8'); |
| 556 | } |
| 557 | else |
| 558 | { |
| 559 | $data = SimplePie_Misc::utf8_bad_replace($data); |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | // Start parsing |
| 564 | $data = new $this->parser_class($data, 'UTF-8', $this->xml_dump); |
| 565 | // If we want the XML, just output that and quit |
| 566 | if ($this->xml_dump) |
| 567 | { |
| 568 | header('Content-type: text/xml; charset=UTF-8'); |
| 569 | echo $data->data; |
| 570 | exit; |
| 571 | } |
| 572 | // If it's parsed fine |
| 573 | else if (!$data->error_code) |
| 574 | { |
| 575 | // Parse the data, and make it sane |
| 576 | $this->sanitize->parse_data_array($data->data, $this->rss_url); |
| 577 | unset($data); |
| 578 | // Get the sane data |
| 579 | $this->data['feedinfo'] = $this->sanitize->feedinfo; |
| 580 | unset($this->sanitize->feedinfo); |
| 581 | $this->data['info'] = $this->sanitize->info; |
| 582 | unset($this->sanitize->info); |
| 583 | $this->data['items'] = $this->sanitize->items; |
| 584 | unset($this->sanitize->items); |
| 585 | $this->data['feedinfo']['encoding'] = $this->sanitize->output_encoding; |
| 586 | $this->data['url'] = $this->rss_url; |
| 587 | |
| 588 | // Store the headers that we need |
| 589 | if (!empty($headers['last-modified'])) |
| 590 | { |
| 591 | $this->data['last-modified'] = $headers['last-modified']; |
| 592 | } |
| 593 | if (!empty($headers['etag'])) |
| 594 | { |
| 595 | $this->data['etag'] = $headers['etag']; |
| 596 | } |
| 597 | |
| 598 | // If we want to order it by date, check if all items have a date, and then sort it |
| 599 | if ($this->order_by_date && !empty($this->data['items'])) |
| 600 | { |
| 601 | $do_sort = true; |
| 602 | foreach ($this->data['items'] as $item) |
| 603 | { |
| 604 | if (!$item->get_date('U')) |
| 605 | { |
| 606 | $do_sort = false; |
431 | | |
432 | | // 8bit |
433 | | case '8bit': |
434 | | case '8-bit': |
435 | | $encoding = '8bit'; |
436 | | $use_mbstring = true; |
| 608 | } |
| 609 | } |
| 610 | if ($do_sort) |
| 611 | { |
| 612 | usort($this->data['items'], create_function('$a, $b', 'if ($a->get_date(\'U\') == $b->get_date(\'U\')) return 1; return ($a->get_date(\'U\') < $b->get_date(\'U\')) ? 1 : -1;')); |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | // Cache the file if caching is enabled |
| 617 | if ($cache && !$cache->save($this->data)) |
| 618 | { |
| 619 | $this->error = "$cache->name is not writeable"; |
| 620 | SimplePie_Misc::error($this->error, E_USER_WARNING, __FILE__, __LINE__); |
| 621 | } |
| 622 | return true; |
| 623 | } |
| 624 | // If we have an error, just set SimplePie::error to it and quit |
| 625 | else |
| 626 | { |
| 627 | $this->error = "XML error: $data->error_string at line $data->current_line, column $data->current_column"; |
| 628 | SimplePie_Misc::error($this->error, E_USER_WARNING, __FILE__, __LINE__); |
| 629 | return false; |
| 630 | } |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | function get_encoding() |
| 635 | { |
| 636 | if (!empty($this->data['feedinfo']['encoding'])) |
| 637 | { |
| 638 | return $this->data['feedinfo']['encoding']; |
| 639 | } |
| 640 | else |
| 641 | { |
| 642 | return false; |
| 643 | } |
| 644 | } |
| 645 | |
| 646 | function handle_content_type($mime = 'text/html') |
| 647 | { |
| 648 | if (!headers_sent()) |
| 649 | { |
| 650 | $header = "Content-type: $mime;"; |
| 651 | if ($this->get_encoding()) |
| 652 | { |
| 653 | $header .= ' charset=' . $this->get_encoding(); |
| 654 | } |
| 655 | else |
| 656 | { |
| 657 | $header .= ' charset=UTF-8'; |
| 658 | } |
| 659 | header($header); |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | function get_type() |
| 664 | { |
| 665 | if (!empty($this->data['feedinfo']['type'])) |
| 666 | { |
| 667 | return $this->data['feedinfo']['type']; |
| 668 | } |
| 669 | else |
| 670 | { |
| 671 | return false; |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | function get_version() |
| 676 | { |
| 677 | if (!empty($this->data['feedinfo']['version'])) |
| 678 | { |
| 679 | return $this->data['feedinfo']['version']; |
| 680 | } |
| 681 | else |
| 682 | { |
| 683 | return false; |
| 684 | } |
| 685 | } |
| 686 | |
| 687 | function get_favicon($check = false, $alternate = null) |
| 688 | { |
| 689 | if (!empty($this->data['info']['link']['alternate'][0])) |
| 690 | { |
| 691 | $favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $this->get_feed_link()); |
| 692 | |
| 693 | if ($check) |
| 694 | { |
| 695 | $file = new $this->file_class($favicon, $this->timeout/10, 5, null, $this->useragent, $this->force_fsockopen); |
| 696 | $headers = $file->headers(); |
| 697 | $file->close(); |
| 698 | |
| 699 | if ($headers['status']['code'] == 200) |
| 700 | { |
| 701 | return $favicon; |
| 702 | } |
| 703 | } |
| 704 | else |
| 705 | { |
| 706 | return $favicon; |
| 707 | } |
| 708 | } |
| 709 | if (!is_null($alternate)) |
| 710 | { |
| 711 | return $alternate; |
| 712 | } |
| 713 | else |
| 714 | { |
| 715 | return false; |
| 716 | } |
| 717 | } |
| 718 | |
| 719 | function subscribe_url() |
| 720 | { |
| 721 | if (!empty($this->rss_url)) |
| 722 | { |
| 723 | return $this->rss_url; |
| 724 | } |
| 725 | else |
| 726 | { |
| 727 | return false; |
| 728 | } |
| 729 | } |
| 730 | |
| 731 | function subscribe_feed() |
| 732 | { |
| 733 | if (!empty($this->rss_url)) |
| 734 | { |
| 735 | return SimplePie_Misc::fix_protocol($this->rss_url, 2); |
| 736 | } |
| 737 | else |
| 738 | { |
| 739 | return false; |
| 740 | } |
| 741 | } |
| 742 | |
| 743 | function subscribe_outlook() |
| 744 | { |
| 745 | if (!empty($this->rss_url)) |
| 746 | { |
| 747 | return 'outlook' . SimplePie_Misc::fix_protocol($this->rss_url, 2); |
| 748 | } |
| 749 | else |
| 750 | { |
| 751 | return false; |
| 752 | } |
| 753 | } |
| 754 | |
| 755 | function subscribe_podcast() |
| 756 | { |
| 757 | if (!empty($this->rss_url)) |
| 758 | { |
| 759 | return SimplePie_Misc::fix_protocol($this->rss_url, 3); |
| 760 | } |
| 761 | else |
| 762 | { |
| 763 | return false; |
| 764 | } |
| 765 | } |
| 766 | |
| 767 | function subscribe_aol() |
| 768 | { |
| 769 | if ($this->subscribe_url()) |
| 770 | { |
| 771 | return 'http://feeds.my.aol.com/add.jsp?url=' . rawurlencode($this->subscribe_url()); |
| 772 | } |
| 773 | else |
| 774 | { |
| 775 | return false; |
| 776 | } |
| 777 | } |
| 778 | |
| 779 | function subscribe_bloglines() |
| 780 | { |
| 781 | if ($this->subscribe_url()) |
| 782 | { |
| 783 | return 'http://www.bloglines.com/sub/' . rawurlencode($this->subscribe_url()); |
| 784 | } |
| 785 | else |
| 786 | { |
| 787 | return false; |
| 788 | } |
| 789 | } |
| 790 | |
| 791 | function subscribe_eskobo() |
| 792 | { |
| 793 | if ($this->subscribe_url()) |
| 794 | { |
| 795 | return 'http://www.eskobo.com/?AddToMyPage=' . rawurlencode($this->subscribe_url()); |
| 796 | } |
| 797 | else |
| 798 | { |
| 799 | return false; |
| 800 | } |
| 801 | } |
| 802 | |
| 803 | function subscribe_feedfeeds() |
| 804 | { |
| 805 | if ($this->subscribe_url()) |
| 806 | { |
| 807 | return 'http://www.feedfeeds.com/add?feed=' . rawurlencode($this->subscribe_url()); |
| 808 | } |
| 809 | else |
| 810 | { |
| 811 | return false; |
| 812 | } |
| 813 | } |
| 814 | |
| 815 | function subscribe_feedlounge() |
| 816 | { |
| 817 | if ($this->subscribe_url()) |
| 818 | { |
| 819 | return 'http://my.feedlounge.com/external/subscribe?url=' . rawurlencode($this->subscribe_url()); |
| 820 | } |
| 821 | else |
| 822 | { |
| 823 | return false; |
| 824 | } |
| 825 | } |
| 826 | |
| 827 | function subscribe_feedster() |
| 828 | { |
| 829 | if ($this->subscribe_url()) |
| 830 | { |
| 831 | return 'http://www.feedster.com/myfeedster.php?action=addrss&confirm=no&rssurl=' . rawurlencode($this->subscribe_url()); |
| 832 | } |
| 833 | else |
| 834 | { |
| 835 | return false; |
| 836 | } |
| 837 | } |
| 838 | |
| 839 | function subscribe_google() |
| 840 | { |
| 841 | if ($this->subscribe_url()) |
| 842 | { |
| 843 | return 'http://fusion.google.com/add?feedurl=' . rawurlencode($this->subscribe_url()); |
| 844 | } |
| 845 | else |
| 846 | { |
| 847 | return false; |
| 848 | } |
| 849 | } |
| 850 | |
| 851 | function subscribe_gritwire() |
| 852 | { |
| 853 | if ($this->subscribe_url()) |
| 854 | { |
| 855 | return 'http://my.gritwire.com/feeds/addExternalFeed.aspx?FeedUrl=' . rawurlencode($this->subscribe_url()); |
| 856 | } |
| 857 | else |
| 858 | { |
| 859 | return false; |
| 860 | } |
| 861 | } |
| 862 | |
| 863 | function subscribe_msn() |
| 864 | { |
| 865 | if ($this->subscribe_url()) |
| 866 | { |
| 867 | $url = 'http://my.msn.com/addtomymsn.armx?id=rss&ut=' . rawurlencode($this->subscribe_url()); |
| 868 | if ($this->get_feed_link()) |
| 869 | { |
| 870 | $url .= '&ru=' . rawurlencode($this->get_feed_link()); |
| 871 | } |
| 872 | return $url; |
| 873 | } |
| 874 | else |
| 875 | { |
| 876 | return false; |
| 877 | } |
| 878 | } |
| 879 | |
| 880 | function subscribe_netvibes() |
| 881 | { |
| 882 | if ($this->subscribe_url()) |
| 883 | { |
| 884 | return 'http://www.netvibes.com/subscribe.php?url=' . rawurlencode($this->subscribe_url()); |
| 885 | } |
| 886 | else |
| 887 | { |
| 888 | return false; |
| 889 | } |
| 890 | } |
| 891 | |
| 892 | function subscribe_newsburst() |
| 893 | { |
| 894 | if ($this->subscribe_url()) |
| 895 | { |
| 896 | return 'http://www.newsburst.com/Source/?add=' . rawurlencode($this->subscribe_url()); |
| 897 | } |
| 898 | else |
| 899 | { |
| 900 | return false; |
| 901 | } |
| 902 | } |
| 903 | |
| 904 | function subscribe_newsgator() |
| 905 | { |
| 906 | if ($this->subscribe_url()) |
| 907 | { |
| 908 | return 'http://www.newsgator.com/ngs/subscriber/subext.aspx?url=' . rawurlencode($this->subscribe_url()); |
| 909 | } |
| 910 | else |
| 911 | { |
| 912 | return false; |
| 913 | } |
| 914 | } |
| 915 | |
| 916 | function subscribe_odeo() |
| 917 | { |
| 918 | if ($this->subscribe_url()) |
| 919 | { |
| 920 | return 'http://www.odeo.com/listen/subscribe?feed=' . rawurlencode($this->subscribe_url()); |
| 921 | } |
| 922 | else |
| 923 | { |
| 924 | return false; |
| 925 | } |
| 926 | } |
| 927 | |
| 928 | function subscribe_pluck() |
| 929 | { |
| 930 | if ($this->subscribe_url()) |
| 931 | { |
| 932 | return 'http://client.pluck.com/pluckit/prompt.aspx?GCID=C12286x053&a=' . rawurlencode($this->subscribe_url()); |
| 933 | } |
| 934 | else |
| 935 | { |
| 936 | return false; |
| 937 | } |
| 938 | } |
| 939 | |
| 940 | function subscribe_podnova() |
| 941 | { |
| 942 | if ($this->subscribe_url()) |
| 943 | { |
| 944 | return 'http://www.podnova.com/index_your_podcasts.srf?action=add&url=' . rawurlencode($this->subscribe_url()); |
| 945 | } |
| 946 | else |
| 947 | { |
| 948 | return false; |
| 949 | } |
| 950 | } |
| 951 | |
| 952 | function subscribe_rojo() |
| 953 | { |
| 954 | if ($this->subscribe_url()) |
| 955 | { |
| 956 | return 'http://www.rojo.com/add-subscription?resource=' . rawurlencode($this->subscribe_url()); |
| 957 | } |
| 958 | else |
| 959 | { |
| 960 | return false; |
| 961 | } |
| 962 | } |
| 963 | |
| 964 | function subscribe_yahoo() |
| 965 | { |
| 966 | if ($this->subscribe_url()) |
| 967 | { |
| 968 | return 'http://add.my.yahoo.com/rss?url=' . rawurlencode($this->subscribe_url()); |
| 969 | } |
| 970 | else |
| 971 | { |
| 972 | return false; |
| 973 | } |
| 974 | } |
| 975 | |
| 976 | function get_feed_title() |
| 977 | { |
| 978 | if (!empty($this->data['info']['title'])) |
| 979 | { |
| 980 | return $this->data['info']['title']; |
| 981 | } |
| 982 | else |
| 983 | { |
| 984 | return false; |
| 985 | } |
| 986 | } |
| 987 | |
| 988 | function get_feed_link() |
| 989 | { |
| 990 | if (!empty($this->data['info']['link']['alternate'][0])) |
| 991 | { |
| 992 | return $this->data['info']['link']['alternate'][0]; |
| 993 | } |
| 994 | else |
| 995 | { |
| 996 | return false; |
| 997 | } |
| 998 | } |
| 999 | |
| 1000 | function get_feed_links() |
| 1001 | { |
| 1002 | if (!empty($this->data['info']['link'])) |
| 1003 | { |
| 1004 | return $this->data['info']['link']; |
| 1005 | } |
| 1006 | else |
| 1007 | { |
| 1008 | return false; |
| 1009 | } |
| 1010 | } |
| 1011 | |
| 1012 | function get_feed_description() |
| 1013 | { |
| 1014 | if (!empty($this->data['info']['description'])) |
| 1015 | { |
| 1016 | return $this->data['info']['description']; |
| 1017 | } |
| 1018 | else if (!empty($this->data['info']['dc:description'])) |
| 1019 | { |
| 1020 | return $this->data['info']['dc:description']; |
| 1021 | } |
| 1022 | else if (!empty($this->data['info']['tagline'])) |
| 1023 | { |
| 1024 | return $this->data['info']['tagline']; |
| 1025 | } |
| 1026 | else if (!empty($this->data['info']['subtitle'])) |
| 1027 | { |
| 1028 | return $this->data['info']['subtitle']; |
| 1029 | } |
| 1030 | else |
| 1031 | { |
| 1032 | return false; |
| 1033 | } |
| 1034 | } |
| 1035 | |
| 1036 | function get_feed_copyright() |
| 1037 | { |
| 1038 | if (!empty($this->data['info']['copyright'])) |
| 1039 | { |
| 1040 | return $this->data['info']['copyright']; |
| 1041 | } |
| 1042 | else |
| 1043 | { |
| 1044 | return false; |
| 1045 | } |
| 1046 | } |
| 1047 | |
| 1048 | function get_feed_language() |
| 1049 | { |
| 1050 | if (!empty($this->data['info']['language'])) |
| 1051 | { |
| 1052 | return $this->data['info']['language']; |
| 1053 | } |
| 1054 | else if (!empty($this->data['info']['xml:lang'])) |
| 1055 | { |
| 1056 | return $this->data['info']['xml:lang']; |
| 1057 | } |
| 1058 | else |
| 1059 | { |
| 1060 | return false; |
| 1061 | } |
| 1062 | } |
| 1063 | |
| 1064 | function get_image_exist() |
| 1065 | { |
| 1066 | if (!empty($this->data['info']['image']['url']) || !empty($this->data['info']['image']['logo'])) |
| 1067 | { |
| 1068 | return true; |
| 1069 | } |
| 1070 | else |
| 1071 | { |
| 1072 | return false; |
| 1073 | } |
| 1074 | } |
| 1075 | |
| 1076 | function get_image_title() |
| 1077 | { |
| 1078 | if (!empty($this->data['info']['image']['title'])) |
| 1079 | { |
| 1080 | return $this->data['info']['image']['title']; |
| 1081 | } |
| 1082 | else |
| 1083 | { |
| 1084 | return false; |
| 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | function get_image_url() |
| 1089 | { |
| 1090 | if (!empty($this->data['info']['image']['url'])) |
| 1091 | { |
| 1092 | return $this->data['info']['image']['url']; |
| 1093 | } |
| 1094 | else if (!empty($this->data['info']['image']['logo'])) |
| 1095 | { |
| 1096 | return $this->data['info']['image']['logo']; |
| 1097 | } |
| 1098 | else |
| 1099 | { |
| 1100 | return false; |
| 1101 | } |
| 1102 | } |
| 1103 | |
| 1104 | function get_image_link() |
| 1105 | { |
| 1106 | if (!empty($this->data['info']['image']['link'])) |
| 1107 | { |
| 1108 | return $this->data['info']['image']['link']; |
| 1109 | } |
| 1110 | else |
| 1111 | { |
| 1112 | return false; |
| 1113 | } |
| 1114 | } |
| 1115 | |
| 1116 | function get_image_width() |
| 1117 | { |
| 1118 | if (!empty($this->data['info']['image']['width'])) |
| 1119 | { |
| 1120 | return $this->data['info']['image']['width']; |
| 1121 | } |
| 1122 | else |
| 1123 | { |
| 1124 | return false; |
| 1125 | } |
| 1126 | } |
| 1127 | |
| 1128 | function get_image_height() |
| 1129 | { |
| 1130 | if (!empty($this->data['info']['image']['height'])) |
| 1131 | { |
| 1132 | return $this->data['info']['image']['height']; |
| 1133 | } |
| 1134 | else |
| 1135 | { |
| 1136 | return false; |
| 1137 | } |
| 1138 | } |
| 1139 | |
| 1140 | function get_item_quantity($max = 0) |
| 1141 | { |
| 1142 | if (!empty($this->data['items'])) |
| 1143 | { |
| 1144 | $qty = sizeof($this->data['items']); |
| 1145 | } |
| 1146 | else |
| 1147 | { |
| 1148 | $qty = 0; |
| 1149 | } |
| 1150 | if ($max == 0) |
| 1151 | { |
| 1152 | return $qty; |
| 1153 | } |
| 1154 | else |
| 1155 | { |
| 1156 | return ($qty > $max) ? $max : $qty; |
| 1157 | } |
| 1158 | } |
| 1159 | |
| 1160 | function get_item($key = 0) |
| 1161 | { |
| 1162 | if (!empty($this->data['items'][$key])) |
| 1163 | { |
| 1164 | return $this->data['items'][$key]; |
| 1165 | } |
| 1166 | else |
| 1167 | { |
| 1168 | return false; |
| 1169 | } |
| 1170 | } |
| 1171 | |
| 1172 | function get_items($start = 0, $end = 0) |
| 1173 | { |
| 1174 | if ($this->get_item_quantity() > 0) |
| 1175 | { |
| 1176 | if ($end == 0) |
| 1177 | { |
| 1178 | return array_slice($this->data['items'], $start); |
| 1179 | } |
| 1180 | else |
| 1181 | { |
| 1182 | return array_slice($this->data['items'], $start, $end); |
| 1183 | } |
| 1184 | } |
| 1185 | else |
| 1186 | { |
| 1187 | return false; |
| 1188 | } |
| 1189 | } |
| 1190 | } |
| 1191 | |
| 1192 | class SimplePie_Item |
| 1193 | { |
| 1194 | var $data; |
| 1195 | |
| 1196 | function SimplePie_Item($data) |
| 1197 | { |
| 1198 | $this->data =& $data; |
| 1199 | } |
| 1200 | |
| 1201 | function get_id() |
| 1202 | { |
| 1203 | if (!empty($this->data['guid']['data'])) |
| 1204 | { |
| 1205 | return $this->data['guid']['data']; |
| 1206 | } |
| 1207 | else if (!empty($this->data['id'])) |
| 1208 | { |
| 1209 | return $this->data['id']; |
| 1210 | } |
| 1211 | else |
| 1212 | { |
| 1213 | return false; |
| 1214 | } |
| 1215 | } |
| 1216 | |
| 1217 | function get_title() |
| 1218 | { |
| 1219 | if (!empty($this->data['title'])) |
| 1220 | { |
| 1221 | return $this->data['title']; |
| 1222 | } |
| 1223 | else if (!empty($this->data['dc:title'])) |
| 1224 | { |
| 1225 | return $this->data['dc:title']; |
| 1226 | } |
| 1227 | else |
| 1228 | { |
| 1229 | return false; |
| 1230 | } |
| 1231 | } |
| 1232 | |
| 1233 | function get_description() |
| 1234 | { |
| 1235 | if (!empty($this->data['content'])) |
| 1236 | { |
| 1237 | return $this->data['content']; |
| 1238 | } |
| 1239 | else if (!empty($this->data['encoded'])) |
| 1240 | { |
| 1241 | return $this->data['encoded']; |
| 1242 | } |
| 1243 | else if (!empty($this->data['summary'])) |
| 1244 | { |
| 1245 | return $this->data['summary']; |
| 1246 | } |
| 1247 | else if (!empty($this->data['description'])) |
| 1248 | { |
| 1249 | return $this->data['description']; |
| 1250 | } |
| 1251 | else if (!empty($this->data['dc:description'])) |
| 1252 | { |
| 1253 | return $this->data['dc:description']; |
| 1254 | } |
| 1255 | else if (!empty($this->data['longdesc'])) |
| 1256 | { |
| 1257 | return $this->data['longdesc']; |
| 1258 | } |
| 1259 | else |
| 1260 | { |
| 1261 | return false; |
| 1262 | } |
| 1263 | } |
| 1264 | |
| 1265 | function get_category($key = 0) |
| 1266 | { |
| 1267 | $categories = $this->get_categories(); |
| 1268 | if (!empty($categories[$key])) |
| 1269 | { |
| 1270 | return $categories[$key]; |
| 1271 | } |
| 1272 | else |
| 1273 | { |
| 1274 | return false; |
| 1275 | } |
| 1276 | } |
| 1277 | |
| 1278 | function get_categories() |
| 1279 | { |
| 1280 | $categories = array(); |
| 1281 | if (!empty($this->data['category'])) |
| 1282 | { |
| 1283 | $categories = array_merge($categories, $this->data['category']); |
| 1284 | } |
| 1285 | if (!empty($this->data['subject'])) |
| 1286 | { |
| 1287 | $categories = array_merge($categories, $this->data['subject']); |
| 1288 | } |
| 1289 | if (!empty($this->data['term'])) |
| 1290 | { |
| 1291 | $categories = array_merge($categories, $this->data['term']); |
| 1292 | } |
| 1293 | if (!empty($categories)) |
| 1294 | { |
| 1295 | return array_unique($categories); |
| 1296 | } |
| 1297 | else |
| 1298 | { |
| 1299 | return false; |
| 1300 | } |
| 1301 | } |
| 1302 | |
| 1303 | function get_author($key = 0) |
| 1304 | { |
| 1305 | $authors = $this->get_authors(); |
| 1306 | if (!empty($authors[$key])) |
| 1307 | { |
| 1308 | return $authors[$key]; |
| 1309 | } |
| 1310 | else |
| 1311 | { |
| 1312 | return false; |
| 1313 | } |
| 1314 | } |
| 1315 | |
| 1316 | function get_authors() |
| 1317 | { |
| 1318 | $authors = array(); |
| 1319 | if (!empty($this->data['author'])) |
| 1320 | { |
| 1321 | $authors = array_merge($authors, $this->data['author']); |
| 1322 | } |
| 1323 | if (!empty($this->data['creator'])) |
| 1324 | { |
| 1325 | $authors = array_merge($authors, $this->data['creator']); |
| 1326 | } |
| 1327 | if (!empty($authors)) |
| 1328 | { |
| 1329 | return array_unique($authors); |
| 1330 | } |
| 1331 | else |
| 1332 | { |
| 1333 | return false; |
| 1334 | } |
| 1335 | } |
| 1336 | |
| 1337 | function get_date($date_format = 'j F Y, g:i a') |
| 1338 | { |
| 1339 | if (!empty($this->data['pubdate'])) |
| 1340 | { |
| 1341 | return date($date_format, $this->data['pubdate']); |
| 1342 | } |
| 1343 | else if (!empty($this->data['dc:date'])) |
| 1344 | { |
| 1345 | return date($date_format, $this->data['dc:date']); |
| 1346 | } |
| 1347 | else if (!empty($this->data['issued'])) |
| 1348 | { |
| 1349 | return date($date_format, $this->data['issued']); |
| 1350 | } |
| 1351 | else if (!empty($this->data['published'])) |
| 1352 | { |
| 1353 | return date($date_format, $this->data['published']); |
| 1354 | } |
| 1355 | else if (!empty($this->data['modified'])) |
| 1356 | { |
| 1357 | return date($date_format, $this->data['modified']); |
| 1358 | } |
| 1359 | else if (!empty($this->data['updated'])) |
| 1360 | { |
| 1361 | return date($date_format, $this->data['updated']); |
| 1362 | } |
| 1363 | else |
| 1364 | { |
| 1365 | return false; |
| 1366 | } |
| 1367 | } |
| 1368 | |
| 1369 | function get_permalink() |
| 1370 | { |
| 1371 | $link = $this->get_link(0); |
| 1372 | $enclosure = $this->get_enclosure(0); |
| 1373 | if (!empty($link)) |
| 1374 | { |
| 1375 | return $link; |
| 1376 | } |
| 1377 | else if (!empty($enclosure)) |
| 1378 | { |
| 1379 | return $enclosure->get_link(); |
| 1380 | } |
| 1381 | else |
| 1382 | { |
| 1383 | return false; |
| 1384 | } |
| 1385 | } |
| 1386 | |
| 1387 | function get_link($key = 0, $rel = 'alternate') |
| 1388 | { |
| 1389 | $links = $this->get_links($rel); |
| 1390 | if (!empty($links[$key])) |
| 1391 | { |
| 1392 | return $links[$key]; |
| 1393 | } |
| 1394 | else |
| 1395 | { |
| 1396 | return false; |
| 1397 | } |
| 1398 | } |
| 1399 | |
| 1400 | function get_links($rel = 'alternate') |
| 1401 | { |
| 1402 | if ($rel == 'alternate') |
| 1403 | { |
| 1404 | $links = array(); |
| 1405 | if (!empty($this->data['link'][$rel])) |
| 1406 | { |
| 1407 | $links = $this->data['link'][$rel]; |
| 1408 | } |
| 1409 | if (!empty($this->data['guid']['data']) && $this->data['guid']['permalink'] == true) |
| 1410 | { |
| 1411 | $links[] = $this->data['guid']['data']; |
| 1412 | } |
| 1413 | return $links; |
| 1414 | } |
| 1415 | else if (!empty($this->data['link'][$rel])) |
| 1416 | { |
| 1417 | return $this->data['link'][$rel]; |
| 1418 | } |
| 1419 | else |
| 1420 | { |
| 1421 | return false; |
| 1422 | } |
| 1423 | } |
| 1424 | |
| 1425 | function get_enclosure($key = 0) |
| 1426 | { |
| 1427 | $enclosures = $this->get_enclosures(); |
| 1428 | if (!empty($enclosures[$key])) |
| 1429 | { |
| 1430 | return $enclosures[$key]; |
| 1431 | } |
| 1432 | else |
| 1433 | { |
| 1434 | return false; |
| 1435 | } |
| 1436 | } |
| 1437 | |
| 1438 | function get_enclosures() |
| 1439 | { |
| 1440 | $enclosures = array(); |
| 1441 | $links = $this->get_links('enclosure'); |
| 1442 | if (!empty($this->data['enclosures'])) |
| 1443 | { |
| 1444 | $enclosures = array_merge($enclosures, $this->data['enclosures']); |
| 1445 | } |
| 1446 | if (!empty($links)) |
| 1447 | { |
| 1448 | $enclosures = array_merge($enclosures, $links); |
| 1449 | } |
| 1450 | if (!empty($enclosures)) |
| 1451 | { |
| 1452 | return array_unique($enclosures); |
| 1453 | } |
| 1454 | else |
| 1455 | { |
| 1456 | return false; |
| 1457 | } |
| 1458 | } |
| 1459 | |
| 1460 | function add_to_blinklist() |
| 1461 | { |
| 1462 | if ($this->get_permalink()) |
| 1463 | { |
| 1464 | $url = 'http://www.blinklist.com/index.php?Action=Blink/addblink.php&Description=&Url=' . rawurlencode($this->get_permalink()); |
| 1465 | if ($this->get_title()) |
| 1466 | { |
| 1467 | $url .= '&Title=' . rawurlencode($this->get_title()); |
| 1468 | } |
| 1469 | return $url; |
| 1470 | } |
| 1471 | else |
| 1472 | { |
| 1473 | return false; |
| 1474 | } |
| 1475 | } |
| 1476 | |
| 1477 | function add_to_blogmarks() |
| 1478 | { |
| 1479 | if ($this->get_permalink()) |
| 1480 | { |
| 1481 | $url = 'http://blogmarks.net/my/new.php?mini=1&simple=1&url=' . rawurlencode($this->get_permalink()); |
| 1482 | if ($this->get_title()) |
| 1483 | { |
| 1484 | $url .= '&title=' . rawurlencode($this->get_title()); |
| 1485 | } |
| 1486 | return $url; |
| 1487 | } |
| 1488 | else |
| 1489 | { |
| 1490 | return false; |
| 1491 | } |
| 1492 | } |
| 1493 | |
| 1494 | function add_to_delicious() |
| 1495 | { |
| 1496 | if ($this->get_permalink()) |
| 1497 | { |
| 1498 | $url = 'http://del.icio.us/post/?v=3&url=' . rawurlencode($this->get_permalink()); |
| 1499 | if ($this->get_title()) |
| 1500 | { |
| 1501 | $url .= '&title=' . rawurlencode($this->get_title()); |
| 1502 | } |
| 1503 | return $url; |
| 1504 | } |
| 1505 | else |
| 1506 | { |
| 1507 | return false; |
| 1508 | } |
| 1509 | } |
| 1510 | |
| 1511 | function add_to_digg() |
| 1512 | { |
| 1513 | if ($this->get_permalink()) |
| 1514 | { |
| 1515 | return 'http://digg.com/submit?phase=2&URL=' . rawurlencode($this->get_permalink()); |
| 1516 | } |
| 1517 | else |
| 1518 | { |
| 1519 | return false; |
| 1520 | } |
| 1521 | } |
| 1522 | |
| 1523 | function add_to_furl() |
| 1524 | { |
| 1525 | if ($this->get_permalink()) |
| 1526 | { |
| 1527 | $url = 'http://www.furl.net/storeIt.jsp?u=' . rawurlencode($this->get_permalink()); |
| 1528 | if ($this->get_title()) |
| 1529 | { |
| 1530 | $url .= '&t=' . rawurlencode($this->get_title()); |
| 1531 | } |
| 1532 | return $url; |
| 1533 | } |
| 1534 | else |
| 1535 | { |
| 1536 | return false; |
| 1537 | } |
| 1538 | } |
| 1539 | |
| 1540 | function add_to_magnolia() |
| 1541 | { |
| 1542 | if ($this->get_permalink()) |
| 1543 | { |
| 1544 | $url = 'http://ma.gnolia.com/bookmarklet/add?url=' . rawurlencode($this->get_permalink()); |
| 1545 | if ($this->get_title()) |
| 1546 | { |
| 1547 | $url .= '&title=' . rawurlencode($this->get_title()); |
| 1548 | } |
| 1549 | return $url; |
| 1550 | } |
| 1551 | else |
| 1552 | { |
| 1553 | return false; |
| 1554 | } |
| 1555 | } |
| 1556 | |
| 1557 | function add_to_myweb20() |
| 1558 | { |
| 1559 | if ($this->get_permalink()) |
| 1560 | { |
| 1561 | $url = 'http://myweb2.search.yahoo.com/myresults/bookmarklet?u=' . rawurlencode($this->get_permalink()); |
| 1562 | if ($this->get_title()) |
| 1563 | { |
| 1564 | $url .= '&t=' . rawurlencode($this->get_title()); |
| 1565 | } |
| 1566 | return $url; |
| 1567 | } |
| 1568 | else |
| 1569 | { |
| 1570 | return false; |
| 1571 | } |
| 1572 | } |
| 1573 | |
| 1574 | function add_to_newsvine() |
| 1575 | { |
| 1576 | if ($this->get_permalink()) |
| 1577 | { |
| 1578 | $url = 'http://www.newsvine.com/_wine/save?u=' . rawurlencode($this->get_permalink()); |
| 1579 | if ($this->get_title()) |
| 1580 | { |
| 1581 | $url .= '&h=' . rawurlencode($this->get_title()); |
| 1582 | } |
| 1583 | return $url; |
| 1584 | } |
| 1585 | else |
| 1586 | { |
| 1587 | return false; |
| 1588 | } |
| 1589 | } |
| 1590 | |
| 1591 | function add_to_reddit() |
| 1592 | { |
| 1593 | if ($this->get_permalink()) |
| 1594 | { |
| 1595 | $url = 'http://reddit.com/submit?url=' . rawurlencode($this->get_permalink()); |
| 1596 | if ($this->get_title()) |
| 1597 | { |
| 1598 | $url .= '&title=' . rawurlencode($this->get_title()); |
| 1599 | } |
| 1600 | return $url; |
| 1601 | } |
| 1602 | else |
| 1603 | { |
| 1604 | return false; |
| 1605 | } |
| 1606 | } |
| 1607 | |
| 1608 | function add_to_segnalo() |
| 1609 | { |
| 1610 | if ($this->get_permalink()) |
| 1611 | { |
| 1612 | $url = 'http://segnalo.com/post.html.php?url=' . rawurlencode($this->get_permalink()); |
| 1613 | if ($this->get_title()) |
| 1614 | { |
| 1615 | $url .= '&title=' . rawurlencode($this->get_title()); |
| 1616 | } |
| 1617 | return $url; |
| 1618 | } |
| 1619 | else |
| 1620 | { |
| 1621 | return false; |
| 1622 | } |
| 1623 | } |
| 1624 | |
| 1625 | function add_to_simpy() |
| 1626 | { |
| 1627 | if ($this->get_permalink()) |
| 1628 | { |
| 1629 | $url = 'http://www.simpy.com/simpy/LinkAdd.do?href=' . rawurlencode($this->get_permalink()); |
| 1630 | if ($this->get_title()) |
| 1631 | { |
| 1632 | $url .= '&title=' . rawurlencode($this->get_title()); |
| 1633 | } |
| 1634 | return $url; |
| 1635 | } |
| 1636 | else |
| 1637 | { |
| 1638 | return false; |
| 1639 | } |
| 1640 | } |
| 1641 | |
| 1642 | function add_to_smarking() |
| 1643 | { |
| 1644 | if ($this->get_permalink()) |
| 1645 | { |
| 1646 | return 'http://smarking.com/editbookmark/?url=' . rawurlencode($this->get_permalink()); |
| 1647 | } |
| 1648 | else |
| 1649 | { |
| 1650 | return false; |
| 1651 | } |
| 1652 | } |
| 1653 | |
| 1654 | function add_to_spurl() |
| 1655 | { |
| 1656 | if ($this->get_permalink()) |
| 1657 | { |
| 1658 | $url = 'http://www.spurl.net/spurl.php?v=3&url=' . rawurlencode($this->get_permalink()); |
| 1659 | if ($this->get_title()) |
| 1660 | { |
| 1661 | $url .= '&title=' . rawurlencode($this->get_title()); |
| 1662 | } |
| 1663 | return $url; |
| 1664 | } |
| 1665 | else |
| 1666 | { |
| 1667 | return false; |
| 1668 | } |
| 1669 | } |
| 1670 | |
| 1671 | function add_to_wists() |
| 1672 | { |
| 1673 | if ($this->get_permalink()) |
| 1674 | { |
| 1675 | $url = 'http://wists.com/r.php?c=&r=' . rawurlencode($this->get_permalink()); |
| 1676 | if ($this->get_title()) |
| 1677 | { |
| 1678 | $url .= '&title=' . rawurlencode($this->get_title()); |
| 1679 | } |
| 1680 | return $url; |
| 1681 | } |
| 1682 | else |
| 1683 | { |
| 1684 | return false; |
| 1685 | } |
| 1686 | } |
| 1687 | |
| 1688 | function search_technorati() |
| 1689 | { |
| 1690 | if ($this->get_permalink()) |
| 1691 | { |
| 1692 | return 'http://www.technorati.com/search/' . rawurlencode($this->get_permalink()); |
| 1693 | } |
| 1694 | else |
| 1695 | { |
| 1696 | return false; |
| 1697 | } |
| 1698 | } |
| 1699 | } |
| 1700 | |
| 1701 | class SimplePie_Author |
| 1702 | { |
| 1703 | var $name; |
| 1704 | var $link; |
| 1705 | var $email; |
| 1706 | |
| 1707 | // Constructor, used to input the data |
| 1708 | function SimplePie_Author($name, $link, $email) |
| 1709 | { |
| 1710 | $this->name = $name; |
| 1711 | $this->link = $link; |
| 1712 | $this->email = $email; |
| 1713 | } |
| 1714 | |
| 1715 | function get_name() |
| 1716 | { |
| 1717 | if (!empty($this->name)) |
| 1718 | { |
| 1719 | return $this->name; |
| 1720 | } |
| 1721 | else |
| 1722 | { |
| 1723 | return false; |
| 1724 | } |
| 1725 | } |
| 1726 | |
| 1727 | function get_link() |
| 1728 | { |
| 1729 | if (!empty($this->link)) |
| 1730 | { |
| 1731 | return $this->link; |
| 1732 | } |
| 1733 | else |
| 1734 | { |
| 1735 | return false; |
| 1736 | } |
| 1737 | } |
| 1738 | |
| 1739 | function get_email() |
| 1740 | { |
| 1741 | if (!empty($this->email)) |
| 1742 | { |
| 1743 | return $this->email; |
| 1744 | } |
| 1745 | else |
| 1746 | { |
| 1747 | return false; |
| 1748 | } |
| 1749 | } |
| 1750 | } |
| 1751 | |
| 1752 | class SimplePie_Enclosure |
| 1753 | { |
| 1754 | var $link; |
| 1755 | var $type; |
| 1756 | var $length; |
| 1757 | |
| 1758 | // Constructor, used to input the data |
| 1759 | function SimplePie_Enclosure($link, $type, $length) |
| 1760 | { |
| 1761 | $this->link = $link; |
| 1762 | $this->type = $type; |
| 1763 | $this->length = $length; |
| 1764 | } |
| 1765 | |
| 1766 | function get_link() |
| 1767 | { |
| 1768 | if (!empty($this->link)) |
| 1769 | { |
| 1770 | if (class_exists('idna_convert')) |
| 1771 | { |
| 1772 | $idn = new idna_convert; |
| 1773 | $this->link = $idn->encode($this->link); |
| 1774 | } |
| 1775 | return $this->link; |
| 1776 | } |
| 1777 | else |
| 1778 | { |
| 1779 | return false; |
| 1780 | } |
| 1781 | } |
| 1782 | |
| 1783 | function get_extension() |
| 1784 | { |
| 1785 | if (!empty($this->link)) |
| 1786 | { |
| 1787 | return pathinfo($this->link, PATHINFO_EXTENSION); |
| 1788 | } |
| 1789 | else |
| 1790 | { |
| 1791 | return false; |
| 1792 | } |
| 1793 | } |
| 1794 | |
| 1795 | function get_type() |
| 1796 | { |
| 1797 | if (!empty($this->type)) |
| 1798 | { |
| 1799 | return $this->type; |
| 1800 | } |
| 1801 | else |
| 1802 | { |
| 1803 | return false; |
| 1804 | } |
| 1805 | } |
| 1806 | |
| 1807 | function get_length() |
| 1808 | { |
| 1809 | if (!empty($this->length)) |
| 1810 | { |
| 1811 | return $this->length; |
| 1812 | } |
| 1813 | else |
| 1814 | { |
| 1815 | return false; |
| 1816 | } |
| 1817 | } |
| 1818 | |
| 1819 | function get_size() |
| 1820 | { |
| 1821 | $length = $this->get_length(); |
| 1822 | if (!empty($length)) |
| 1823 | { |
| 1824 | return round($length/1048576, 2); |
| 1825 | } |
| 1826 | else |
| 1827 | { |
| 1828 | return false; |
| 1829 | } |
| 1830 | } |
| 1831 | |
| 1832 | function native_embed($options='') |
| 1833 | { |
| 1834 | return $this->embed($options, true); |
| 1835 | } |
| 1836 | |
| 1837 | function embed($options = '', $native = false) |
| 1838 | { |
| 1839 | // Set up defaults |
| 1840 | $audio = ''; |
| 1841 | $video = ''; |
| 1842 | $alt = ''; |
| 1843 | $altclass = ''; |
| 1844 | $loop = 'false'; |
| 1845 | $width = 'auto'; |
| 1846 | $height = 'auto'; |
| 1847 | $bgcolor = '#ffffff'; |
| 1848 | |
| 1849 | // Process options and reassign values as necessary |
| 1850 | if (is_array($options)) |
| 1851 | { |
| 1852 | extract($options); |
| 1853 | } |
| 1854 | else |
| 1855 | { |
| 1856 | $options = explode(',', $options); |
| 1857 | foreach($options as $option) |
| 1858 | { |
| 1859 | $opt = explode(':', $option, 2); |
| 1860 | if (isset($opt[0], $opt[1])) |
| 1861 | { |
| 1862 | $opt[0] = trim($opt[0]); |
| 1863 | $opt[1] = trim($opt[1]); |
| 1864 | switch ($opt[0]) |
| 1865 | { |
| 1866 | case 'audio': |
| 1867 | $audio = $opt[1]; |
482 | | |
483 | | // byte2le |
484 | | case 'byte2le': |
485 | | $encoding = 'byte2le'; |
486 | | $use_mbstring = true; |
487 | | break; |
488 | | |
489 | | // byte4be |
490 | | case 'byte4be': |
491 | | $encoding = 'byte4be'; |
492 | | $use_mbstring = true; |
493 | | break; |
494 | | |
495 | | // byte4le |
496 | | case 'byte4le': |
497 | | $encoding = 'byte4le'; |
498 | | $use_mbstring = true; |
499 | | break; |
500 | | |
501 | | // EUC-CN |
502 | | case 'euc-cn': |
503 | | case 'euccn': |
504 | | $encoding = 'EUC-CN'; |
505 | | $use_iconv = true; |
506 | | $use_mbstring = true; |
507 | | break; |
508 | | |
509 | | // EUC-JISX0213 |
510 | | case 'euc-jisx0213': |
511 | | case 'eucjisx0213': |
512 | | $encoding = 'EUC-JISX0213'; |
513 | | $use_iconv = true; |
514 | | break; |
515 | | |
516 | | // EUC-JP |
517 | | case 'euc-jp': |
518 | | case 'eucjp': |
519 | | $encoding = 'EUC-JP'; |
520 | | $use_iconv = true; |
521 | | $use_mbstring = true; |
522 | | break; |
523 | | |
524 | | // EUCJP-win |
525 | | case 'euc-jp-win': |
526 | | case 'eucjp-win': |
527 | | case 'eucjpwin': |
528 | | $encoding = 'EUCJP-win'; |
529 | | $use_iconv = true; |
530 | | $use_mbstring = true; |
531 | | break; |
532 | | |
533 | | // EUC-KR |
534 | | case 'euc-kr': |
535 | | case 'euckr': |
536 | | $encoding = 'EUC-KR'; |
537 | | $use_iconv = true; |
538 | | $use_mbstring = true; |
539 | | break; |
540 | | |
541 | | // EUC-TW |
542 | | case 'euc-tw': |
543 | | case 'euctw': |
544 | | $encoding = 'EUC-TW'; |
545 | | $use_iconv = true; |
546 | | $use_mbstring = true; |
547 | | break; |
548 | | |
549 | | // GB18030 - Simplified Chinese, national standard character set |
550 | | case 'gb18030-2000': |
551 | | case 'gb18030': |
552 | | $encoding = 'GB18030'; |
553 | | $use_iconv = true; |
554 | | break; |
555 | | |
556 | | // GB2312 - Simplified Chinese, national standard character set |
557 | | case 'gb2312': |
558 | | case '936': |
559 | | $encoding = 'GB2312'; |
560 | | $use_mbstring = true; |
561 | | break; |
562 | | |
563 | | // GBK |
564 | | case 'gbk': |
565 | | $encoding = 'GBK'; |
566 | | $use_iconv = true; |
567 | | break; |
568 | | |
569 | | // Georgian-Academy |
570 | | case 'georgian-academy': |
571 | | $encoding = 'Georgian-Academy'; |
572 | | $use_iconv = true; |
573 | | break; |
574 | | |
575 | | // Georgian-PS |
576 | | case 'georgian-ps': |
577 | | $encoding = 'Georgian-PS'; |
578 | | $use_iconv = true; |
579 | | break; |
580 | | |
581 | | // HTML-ENTITIES |
582 | | case 'html-entities': |
583 | | case 'htmlentities': |
584 | | $encoding = 'HTML-ENTITIES'; |
585 | | $use_mbstring = true; |
586 | | break; |
587 | | |
588 | | // HZ |
589 | | case 'hz': |
590 | | $encoding = 'HZ'; |
591 | | $use_iconv = true; |
592 | | $use_mbstring = true; |
593 | | break; |
594 | | |
595 | | // ISO-2022-CN |
596 | | case 'iso-2022-cn': |
597 | | case 'iso2022-cn': |
598 | | case 'iso2022cn': |
599 | | $encoding = 'ISO-2022-CN'; |
600 | | $use_iconv = true; |
601 | | break; |
602 | | |
603 | | // ISO-2022-CN-EXT |
604 | | case 'iso-2022-cn-ext': |
605 | | case 'iso2022-cn-ext': |
606 | | case 'iso2022cn-ext': |
607 | | case 'iso2022cnext': |
608 | | $encoding = 'ISO-2022-CN'; |
609 | | $use_iconv = true; |
610 | | break; |
611 | | |
612 | | // ISO-2022-JP |
613 | | case 'iso-2022-jp': |
614 | | case 'iso2022-jp': |
615 | | case 'iso2022jp': |
616 | | $encoding = 'ISO-2022-JP'; |
617 | | $use_iconv = true; |
618 | | $use_mbstring = true; |
619 | | break; |
620 | | |
621 | | // ISO-2022-JP-1 |
622 | | case 'iso-2022-jp-1': |
623 | | case 'iso2022-jp-1': |
624 | | case 'iso2022jp-1': |
625 | | case 'iso2022jp1': |
626 | | $encoding = 'ISO-2022-JP-1'; |
627 | | $use_iconv = true; |
628 | | break; |
629 | | |
630 | | // ISO-2022-JP-2 |
631 | | case 'iso-2022-jp-2': |
632 | | case 'iso2022-jp-2': |
633 | | case 'iso2022jp-2': |
634 | | case 'iso2022jp2': |
635 | | $encoding = 'ISO-2022-JP-2'; |
636 | | $use_iconv = true; |
637 | | break; |
638 | | |
639 | | // ISO-2022-JP-3 |
640 | | case 'iso-2022-jp-3': |
641 | | case 'iso2022-jp-3': |
642 | | case 'iso2022jp-3': |
643 | | case 'iso2022jp3': |
644 | | $encoding = 'ISO-2022-JP-3'; |
645 | | $use_iconv = true; |
646 | | break; |
647 | | |
648 | | // ISO-2022-KR |
649 | | case 'iso-2022-kr': |
650 | | case 'iso2022-kr': |
651 | | case 'iso2022kr': |
652 | | $encoding = 'ISO-2022-KR'; |
653 | | $use_iconv = true; |
654 | | $use_mbstring = true; |
655 | | break; |
656 | | |
657 | | // ISO-8859-1 |
658 | | case 'iso-8859-1': |
659 | | case 'iso8859-1': |
660 | | $encoding = 'ISO-8859-1'; |
661 | | $use_iconv = true; |
662 | | $use_mbstring = true; |
663 | | $utf8_fail = false; |
664 | | break; |
665 | | |
666 | | // ISO-8859-2 |
667 | | case 'iso-8859-2': |
668 | | case 'iso8859-2': |
669 | | $encoding = 'ISO-8859-2'; |
670 | | $use_iconv = true; |
671 | | $use_mbstring = true; |
672 | | break; |
673 | | |
674 | | // ISO-8859-3 |
675 | | case 'iso-8859-3': |
676 | | case 'iso8859-3': |
677 | | $encoding = 'ISO-8859-3'; |
678 | | $use_iconv = true; |
679 | | $use_mbstring = true; |
680 | | break; |
681 | | |
682 | | // ISO-8859-4 |
683 | | case 'iso-8859-4': |
684 | | case 'iso8859-4': |
685 | | $encoding = 'ISO-8859-4'; |
686 | | $use_iconv = true; |
687 | | $use_mbstring = true; |
688 | | break; |
689 | | |
690 | | // ISO-8859-5 |
691 | | case 'iso-8859-5': |
692 | | case 'iso8859-5': |
693 | | $encoding = 'ISO-8859-5'; |
694 | | $use_iconv = true; |
695 | | $use_mbstring = true; |
696 | | break; |
697 | | |
698 | | // ISO-8859-6 |
699 | | case 'iso-8859-6': |
700 | | case 'iso8859-6': |
701 | | $encoding = 'ISO-8859-6'; |
702 | | $use_iconv = true; |
703 | | $use_mbstring = true; |
704 | | break; |
705 | | |
706 | | // ISO-8859-7 |
707 | | case 'iso-8859-7': |
708 | | case 'iso8859-7': |
709 | | $encoding = 'ISO-8859-7'; |
710 | | $use_iconv = true; |
711 | | $use_mbstring = true; |
712 | | break; |
713 | | |
714 | | // ISO-8859-8 |
715 | | case 'iso-8859-8': |
716 | | case 'iso8859-8': |
717 | | $encoding = 'ISO-8859-8'; |
718 | | $use_iconv = true; |
719 | | $use_mbstring = true; |
720 | | break; |
721 | | |
722 | | // ISO-8859-9 |
723 | | case 'iso-8859-9': |
724 | | case 'iso8859-9': |
725 | | $encoding = 'ISO-8859-9'; |
726 | | $use_iconv = true; |
727 | | $use_mbstring = true; |
728 | | break; |
729 | | |
730 | | // ISO-8859-10 |
731 | | case 'iso-8859-10': |
732 | | case 'iso8859-10': |
733 | | $encoding = 'ISO-8859-10'; |
734 | | $use_iconv = true; |
735 | | $use_mbstring = true; |
736 | | break; |
737 | | |
738 | | // mbstring/iconv functions don't appear to support 11 & 12 |
739 | | |
740 | | // ISO-8859-13 |
741 | | case 'iso-8859-13': |
742 | | case 'iso8859-13': |
743 | | $encoding = 'ISO-8859-13'; |
744 | | $use_iconv = true; |
745 | | $use_mbstring = true; |
746 | | break; |
747 | | |
748 | | // ISO-8859-14 |
749 | | case 'iso-8859-14': |
750 | | case 'iso8859-14': |
751 | | $encoding = 'ISO-8859-14'; |
752 | | $use_iconv = true; |
753 | | $use_mbstring = true; |
754 | | break; |
755 | | |
756 | | // ISO-8859-15 |
757 | | case 'iso-8859-15': |
758 | | case 'iso8859-15': |
759 | | $encoding = 'ISO-8859-15'; |
760 | | $use_iconv = true; |
761 | | $use_mbstring = true; |
762 | | break; |
763 | | |
764 | | // ISO-8859-16 |
765 | | case 'iso-8859-16': |
766 | | case 'iso8859-16': |
767 | | $encoding = 'ISO-8859-16'; |
768 | | $use_iconv = true; |
769 | | break; |
770 | | |
771 | | // JIS |
772 | | case 'jis': |
773 | | $encoding = 'JIS'; |
774 | | $use_mbstring = true; |
775 | | break; |
776 | | |
777 | | // JOHAB - Korean |
778 | | case 'johab': |
779 | | $encoding = 'JOHAB'; |
780 | | $use_iconv = true; |
781 | | break; |
782 | | |
783 | | // Russian |
784 | | case 'koi8-r': |
785 | | case 'koi8r': |
786 | | $encoding = 'KOI8-R'; |
787 | | $use_iconv = true; |
788 | | $use_mbstring = true; |
789 | | break; |
790 | | |
791 | | // Turkish |
792 | | case 'koi8-t': |
793 | | case 'koi8t': |
794 | | $encoding = 'KOI8-T'; |
795 | | $use_iconv = true; |
796 | | break; |
797 | | |
798 | | // Ukrainian |
799 | | case 'koi8-u': |
800 | | case 'koi8u': |
801 | | $encoding = 'KOI8-U'; |
802 | | $use_iconv = true; |
803 | | break; |
804 | | |
805 | | // Russian+Ukrainian |
806 | | case 'koi8-ru': |
807 | | case 'koi8ru': |
808 | | $encoding = 'KOI8-RU'; |
809 | | $use_iconv = true; |
810 | | break; |
811 | | |
812 | | // Macintosh (Mac OS Classic) |
813 | | case 'macintosh': |
814 | | $encoding = 'Macintosh'; |
815 | | $use_iconv = true; |
816 | | break; |
817 | | |
818 | | // MacArabic (Mac OS Classic) |
819 | | case 'macarabic': |
820 | | $encoding = 'MacArabic'; |
821 | | $use_iconv = true; |
822 | | break; |
823 | | |
824 | | // MacCentralEurope (Mac OS Classic) |
825 | | case 'maccentraleurope': |
826 | | $encoding = 'MacCentralEurope'; |
827 | | $use_iconv = true; |
828 | | break; |
829 | | |
830 | | // MacCroatian (Mac OS Classic) |
831 | | case 'maccroatian': |
832 | | $encoding = 'MacCroatian'; |
833 | | $use_iconv = true; |
834 | | break; |
835 | | |
836 | | // MacCyrillic (Mac OS Classic) |
837 | | case 'maccyrillic': |
838 | | $encoding = 'MacCyrillic'; |
839 | | $use_iconv = true; |
840 | | break; |
841 | | |
842 | | // MacGreek (Mac OS Classic) |
843 | | case 'macgreek': |
844 | | $encoding = 'MacGreek'; |
845 | | $use_iconv = true; |
846 | | break; |
847 | | |
848 | | // MacHebrew (Mac OS Classic) |
849 | | case 'machebrew': |
850 | | $encoding = 'MacHebrew'; |
851 | | $use_iconv = true; |
852 | | break; |
853 | | |
854 | | // MacIceland (Mac OS Classic) |
855 | | case 'maciceland': |
856 | | $encoding = 'MacIceland'; |
857 | | $use_iconv = true; |
858 | | break; |
859 | | |
860 | | // MacRoman (Mac OS Classic) |
861 | | case 'macroman': |
862 | | $encoding = 'MacRoman'; |
863 | | $use_iconv = true; |
864 | | break; |
865 | | |
866 | | // MacRomania (Mac OS Classic) |
867 | | case 'macromania': |
868 | | $encoding = 'MacRomania'; |
869 | | $use_iconv = true; |
870 | | break; |
871 | | |
872 | | // MacThai (Mac OS Classic) |
873 | | case 'macthai': |
874 | | $encoding = 'MacThai'; |
875 | | $use_iconv = true; |
876 | | break; |
877 | | |
878 | | // MacTurkish (Mac OS Classic) |
879 | | case 'macturkish': |
880 | | $encoding = 'MacTurkish'; |
881 | | $use_iconv = true; |
882 | | break; |
883 | | |
884 | | // MacUkraine (Mac OS Classic) |
885 | | case 'macukraine': |
886 | | $encoding = 'MacUkraine'; |
887 | | $use_iconv = true; |
888 | | break; |
889 | | |
890 | | // MuleLao-1 |
891 | | case 'mulelao-1': |
892 | | case 'mulelao1': |
893 | | $encoding = 'MuleLao-1'; |
894 | | $use_iconv = true; |
895 | | break; |
896 | | |
897 | | // Shift_JIS |
898 | | case 'shift_jis': |
899 | | case 'sjis': |
900 | | case '932': |
901 | | $encoding = 'Shift_JIS'; |
902 | | $use_iconv = true; |
903 | | $use_mbstring = true; |
904 | | break; |
905 | | |
906 | | // Shift_JISX0213 |
907 | | case 'shift-jisx0213': |
908 | | case 'shiftjisx0213': |
909 | | $encoding = 'Shift_JISX0213'; |
910 | | $use_iconv = true; |
911 | | break; |
912 | | |
913 | | // SJIS-win |
914 | | case 'sjis-win': |
915 | | case 'sjiswin': |
916 | | case 'shift_jis-win': |
917 | | $encoding = 'SJIS-win'; |
918 | | $use_iconv = true; |
919 | | $use_mbstring = true; |
920 | | break; |
921 | | |
922 | | // TCVN - Vietnamese |
923 | | case 'tcvn': |
924 | | $encoding = 'TCVN'; |
925 | | $use_iconv = true; |
926 | | break; |
927 | | |
928 | | // TDS565 - Turkish |
929 | | case 'tds565': |
930 | | $encoding = 'TDS565'; |
931 | | $use_iconv = true; |
932 | | break; |
933 | | |
934 | | // TIS-620 Thai |
935 | | case 'tis-620': |
936 | | case 'tis620': |
937 | | $encoding = 'TIS-620'; |
938 | | $use_iconv = true; |
939 | | $use_mbstring = true; |
940 | | break; |
941 | | |
942 | | // UCS-2 |
943 | | case 'ucs-2': |
944 | | case 'ucs2': |
945 | | case 'utf-16': |
946 | | case 'utf16': |
947 | | $encoding = 'UCS-2'; |
948 | | $use_iconv = true; |
949 | | $use_mbstring = true; |
950 | | break; |
951 | | |
952 | | // UCS-2BE |
953 | | case 'ucs-2be': |
954 | | case 'ucs2be': |
955 | | case 'utf-16be': |
956 | | case 'utf16be': |
957 | | $encoding = 'UCS-2BE'; |
958 | | $use_iconv = true; |
959 | | $use_mbstring = true; |
960 | | break; |
961 | | |
962 | | // UCS-2LE |
963 | | case 'ucs-2le': |
964 | | case 'ucs2le': |
965 | | case 'utf-16le': |
966 | | case 'utf16le': |
967 | | $encoding = 'UCS-2LE'; |
968 | | $use_iconv = true; |
969 | | $use_mbstring = true; |
970 | | break; |
971 | | |
972 | | // UCS-2-INTERNAL |
973 | | case 'ucs-2-internal': |
974 | | case 'ucs2internal': |
975 | | $encoding = 'UCS-2-INTERNAL'; |
976 | | $use_iconv = true; |
977 | | break; |
978 | | |
979 | | // UCS-4 |
980 | | case 'ucs-4': |
981 | | case 'ucs4': |
982 | | case 'utf-32': |
983 | | case 'utf32': |
984 | | $encoding = 'UCS-4'; |
985 | | $use_iconv = true; |
986 | | $use_mbstring = true; |
987 | | break; |
988 | | |
989 | | // UCS-4BE |
990 | | case 'ucs-4be': |
991 | | case 'ucs4be': |
992 | | case 'utf-32be': |
993 | | case 'utf32be': |
994 | | $encoding = 'UCS-4BE'; |
995 | | $use_iconv = true; |
996 | | $use_mbstring = true; |
997 | | break; |
998 | | |
999 | | // UCS-4LE |
1000 | | case 'ucs-4le': |
1001 | | case 'ucs4le': |
1002 | | case 'utf-32le': |
1003 | | case 'utf32le': |
1004 | | $encoding = 'UCS-4LE'; |
1005 | | $use_iconv = true; |
1006 | | $use_mbstring = true; |
1007 | | break; |
1008 | | |
1009 | | // UCS-4-INTERNAL |
1010 | | case 'ucs-4-internal': |
1011 | | case 'ucs4internal': |
1012 | | $encoding = 'UCS-4-INTERNAL'; |
1013 | | $use_iconv = true; |
1014 | | break; |
1015 | | |
1016 | | // UCS-16 |
1017 | | case 'ucs-16': |
1018 | | case 'ucs16': |
1019 | | $encoding = 'UCS-16'; |
1020 | | $use_iconv = true; |
1021 | | $use_mbstring = true; |
1022 | | break; |
1023 | | |
1024 | | // UCS-16BE |
1025 | | case 'ucs-16be': |
1026 | | case 'ucs16be': |
1027 | | $encoding = 'UCS-16BE'; |
1028 | | $use_iconv = true; |
1029 | | $use_mbstring = true; |
1030 | | break; |
1031 | | |
1032 | | // UCS-16LE |
1033 | | case 'ucs-16le': |
1034 | | case 'ucs16le': |
1035 | | $encoding = 'UCS-16LE'; |
1036 | | $use_iconv = true; |
1037 | | $use_mbstring = true; |
1038 | | break; |
1039 | | |
1040 | | // UCS-32 |
1041 | | case 'ucs-32': |
1042 | | case 'ucs32': |
1043 | | $encoding = 'UCS-32'; |
1044 | | $use_iconv = true; |
1045 | | $use_mbstring = true; |
1046 | | break; |
1047 | | |
1048 | | // UCS-32BE |
1049 | | case 'ucs-32be': |
1050 | | case 'ucs32be': |
1051 | | $encoding = 'UCS-32BE'; |
1052 | | $use_iconv = true; |
1053 | | $use_mbstring = true; |
1054 | | break; |
1055 | | |
1056 | | // UCS-32LE |
1057 | | case 'ucs-32le': |
1058 | | case 'ucs32le': |
1059 | | $encoding = 'UCS-32LE'; |
1060 | | $use_iconv = true; |
1061 | | $use_mbstring = true; |
1062 | | break; |
1063 | | |
1064 | | // UTF-7 |
1065 | | case 'utf-7': |
1066 | | case 'utf7': |
1067 | | $encoding = 'UTF-7'; |
1068 | | $use_iconv = true; |
1069 | | $use_mbstring = true; |
1070 | | break; |
1071 | | |
1072 | | // UTF7-IMAP |
1073 | | case 'utf-7-imap': |
1074 | | case 'utf7-imap': |
1075 | | case 'utf7imap': |
1076 | | $encoding = 'UTF7-IMAP'; |
1077 | | $use_mbstring = true; |
1078 | | break; |
1079 | | |
1080 | | // VISCII - Vietnamese ASCII |
1081 | | case 'viscii': |
1082 | | $encoding = 'VISCII'; |
1083 | | $use_iconv = true; |
1084 | | break; |
1085 | | |
1086 | | // Windows-specific Central & Eastern Europe |
1087 | | case 'cp1250': |
1088 | | case 'windows-1250': |
1089 | | case 'win-1250': |
1090 | | case '1250': |
1091 | | $encoding = 'Windows-1250'; |
1092 | | $use_iconv = true; |
1093 | | break; |
1094 | | |
1095 | | // Windows-specific Cyrillic |
1096 | | case 'cp1251': |
1097 | | case 'windows-1251': |
1098 | | case 'win-1251': |
1099 | | case '1251': |
1100 | | $encoding = 'Windows-1251'; |
1101 | | $use_iconv = true; |
1102 | | $use_mbstring = true; |
1103 | | break; |
1104 | | |
1105 | | // Windows-specific Western Europe |
1106 | | case 'cp1252': |
1107 | | case 'windows-1252': |
1108 | | case '1252': |
1109 | | $encoding = 'Windows-1252'; |
1110 | | $use_iconv = true; |
1111 | | $use_mbstring = true; |
1112 | | break; |
1113 | | |
1114 | | // Windows-specific Greek |
1115 | | case 'cp1253': |
1116 | | case 'windows-1253': |
1117 | | case '1253': |
1118 | | $encoding = 'Windows-1253'; |
1119 | | $use_iconv = true; |
1120 | | break; |
1121 | | |
1122 | | // Windows-specific Turkish |
1123 | | case 'cp1254': |
1124 | | case 'windows-1254': |
1125 | | case '1254': |
1126 | | $encoding = 'Windows-1254'; |
1127 | | $use_iconv = true; |
1128 | | break; |
1129 | | |
1130 | | // Windows-specific Hebrew |
1131 | | case 'cp1255': |
1132 | | case 'windows-1255': |
1133 | | case '1255': |
1134 | | $encoding = 'Windows-1255'; |
1135 | | $use_iconv = true; |
1136 | | break; |
1137 | | |
1138 | | // Windows-specific Arabic |
1139 | | case 'cp1256': |
1140 | | case 'windows-1256': |
1141 | | case '1256': |
1142 | | $encoding = 'Windows-1256'; |
1143 | | $use_iconv = true; |
1144 | | break; |
1145 | | |
1146 | | // Windows-specific Baltic |
1147 | | case 'cp1257': |
1148 | | case 'windows-1257': |
1149 | | case '1257': |
1150 | | $encoding = 'Windows-1257'; |
1151 | | $use_iconv = true; |
1152 | | break; |
1153 | | |
1154 | | // Windows-specific Vietnamese |
1155 | | case 'cp1258': |
1156 | | case 'windows-1258': |
1157 | | case '1258': |
1158 | | $encoding = 'Windows-1258'; |
1159 | | $use_iconv = true; |
1160 | | break; |
1161 | | |
1162 | | // Default to UTF-8 |
1163 | | default: |
1164 | | $encoding = 'UTF-8'; |
| 1893 | |
| 1894 | case 'bgcolor': |
| 1895 | $bgcolor = $opt[1]; |
1167 | | } else { |
1168 | | $mp_rss = preg_replace ('/<\?xml(.*)( standalone="no")(.*)\?>/msiU', '<?xml\\1\\3?>', $mp_rss, 1); |
1169 | | $mp_rss = preg_replace ('/<\?xml(.*)\?>/msiU', '<?xml\\1 encoding="UTF-8"?>', $mp_rss, 1); |
1170 | | preg_match('/encoding=["|\'](.*)["|\']/Ui', $mp_rss, $match); |
1171 | | $use_iconv = true; |
1172 | | $use_mbstring = true; |
1173 | | $utf8_fail = false; |
1174 | | $encoding = 'UTF-8'; |
1175 | | } |
1176 | | $this->encoding = $encoding; |
1177 | | |
1178 | | // If function is available and able, convert characters to UTF-8, and overwrite $this->encoding |
1179 | | if (function_exists('iconv') && $use_iconv && iconv($encoding, 'UTF-8', $mp_rss)) { |
1180 | | $mp_rss = iconv($encoding, 'UTF-8//TRANSLIT', $mp_rss); |
1181 | | $mp_rss = str_replace ($match[0], 'encoding="UTF-8"', $mp_rss); |
1182 | | $this->encoding = 'UTF-8'; |
1183 | | } |
1184 | | else if (function_exists('mb_convert_encoding') && $use_mbstring) { |
1185 | | $mp_rss = mb_convert_encoding($mp_rss, 'UTF-8', $encoding); |
1186 | | $mp_rss = str_replace ($match[0], 'encoding="UTF-8"', $mp_rss); |
1187 | | $this->encoding = 'UTF-8'; |
1188 | | } |
1189 | | else if (($use_mbstring || $use_iconv) && $utf8_fail) { |
1190 | | $this->encoding = 'UTF-8'; |
1191 | | $mp_rss = str_replace ($match[0], 'encoding="UTF-8"', $mp_rss); |
1192 | | } |
1193 | | $mp_rss = preg_replace('/<(.*)>[\s]*<\!\[CDATA\[/msiU', '<\\1 spencoded="false"><![CDATA[', $mp_rss); // Add an internal attribute to CDATA sections |
1194 | | $mp_rss = str_replace(']] spencoded="false">', ']]>', $mp_rss); // Remove it when we're on the end of a CDATA block (therefore making it ill-formed) |
1195 | | |
1196 | | // If we're RSS |
1197 | | if (preg_match('/<rdf:rdf/i', $mp_rss) || preg_match('/<rss/i', $mp_rss)) { |
1198 | | $sp_elements = array( |
1199 | | 'author', |
1200 | | 'link', |
1201 | | ); |
1202 | | // Or if we're Atom |
1203 | | } else { |
1204 | | $sp_elements = array( |
1205 | | 'content', |
1206 | | 'copyright', |
1207 | | 'name', |
1208 | | 'subtitle', |
1209 | | 'summary', |
1210 | | 'tagline', |
1211 | | 'title', |
1212 | | ); |
1213 | | } |
1214 | | foreach ($sp_elements as $full) { |
1215 | | // The (<\!\[CDATA\[)? never matches any CDATA block, therefore the CDATA gets added, but never replaced |
1216 | | $mp_rss = preg_replace("/<$full(.*)>[\s]*(<\!\[CDATA\[)?(.*)(]]>)?[\s]*<\/$full>/msiU", "<$full\\1><![CDATA[\\3]]></$full>", $mp_rss); |
1217 | | // The following line is a work-around for the above bug |
1218 | | $mp_rss = preg_replace("/<$full(.*)><\!\[CDATA\[[\s]*<\!\[CDATA\[/msiU", "<$full\\1><![CDATA[", $mp_rss); |
1219 | | // Deal with CDATA within CDATA (this can be caused by us inserting CDATA above) |
1220 | | $mp_rss = preg_replace_callback("/<($full)(.*)><!\[CDATA\[(.*)\]\]><\/$full>/msiU", array(&$this, 'cdata_in_cdata'), $mp_rss); |
1221 | | } |
1222 | | |
1223 | | // If XML Dump is enabled, send feed to the page and quit. |
1224 | | if ($this->xml_dump) { |
1225 | | header("Content-type: text/xml; charset=" . $this->encoding); |
1226 | | echo $mp_rss; |
1227 | | exit; |
1228 | | } |
1229 | | |
1230 | | $this->xml = xml_parser_create_ns($this->encoding); |
1231 | | $this->namespaces = array('xml' => 'HTTP://WWW.W3.ORG/XML/1998/NAMESPACE', 'atom' => 'ATOM', 'rss2' => 'RSS', 'rdf' => 'RDF', 'rss1' => 'RSS', 'dc' => 'DC', 'xhtml' => 'XHTML', 'content' => 'CONTENT'); |
1232 | | xml_parser_set_option($this->xml, XML_OPTION_SKIP_WHITE, 1); |
1233 | | xml_set_object($this->xml, $this); |
1234 | | xml_set_character_data_handler($this->xml, 'dataHandler'); |
1235 | | xml_set_element_handler($this->xml, 'startHandler', 'endHandler'); |
1236 | | xml_set_start_namespace_decl_handler($this->xml, 'startNameSpace'); |
1237 | | xml_set_end_namespace_decl_handler($this->xml, 'endNameSpace'); |
1238 | | if (xml_parse($this->xml, $mp_rss)) |
1239 | | { |
1240 | | xml_parser_free($this->xml); |
1241 | | $this->parse_xml_data_array(); |
1242 | | $this->data['feedinfo']['encoding'] = $this->encoding; |
1243 | | if ($this->order_by_date && !empty($this->data['items'])) { |
1244 | | usort($this->data['items'], create_function('$a,$b', 'if ($a->date == $b->date) return 0; return ($a->date < $b->date) ? 1 : -1;')); |
| 1898 | } |
| 1899 | } |
| 1900 | } |
| 1901 | |
| 1902 | $type = strtolower($this->get_type()); |
| 1903 | |
| 1904 | // If we encounter an unsupported mime-type, check the file extension and guess intelligently. |
| 1905 | if (!in_array($type, array('audio/3gpp', 'audio/3gpp2', 'audio/aac', 'audio/x-aac', 'audio/aiff', 'audio/x-aiff', 'audio/mid', 'audio/midi', 'audio/x-midi', 'audio/mpeg', 'audio/x-mpeg', 'audio/mp3', 'x-audio/mp3', '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', 'application/x-shockwave-flash', 'application/futuresplash', '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'))) |
| 1906 | { |
| 1907 | switch (strtolower($this->get_extension())) |
| 1908 | { |
| 1909 | // Audio mime-types |
| 1910 | case 'aac': |
| 1911 | case 'adts': |
| 1912 | $type = 'audio/acc'; |
| 1913 | break; |
| 1914 | |
| 1915 | case 'aif': |
| 1916 | case 'aifc': |
| 1917 | case 'aiff': |
| 1918 | case 'cdda': |
| 1919 | $type = 'audio/aiff'; |
| 1920 | break; |
| 1921 | |
| 1922 | case 'bwf': |
| 1923 | $type = 'audio/wav'; |
| 1924 | break; |
| 1925 | |
| 1926 | case 'kar': |
| 1927 | case 'mid': |
| 1928 | case 'midi': |
| 1929 | case 'smf': |
| 1930 | $type = 'audio/midi'; |
| 1931 | break; |
| 1932 | |
| 1933 | case 'm4a': |
| 1934 | $type = 'audio/x-m4a'; |
| 1935 | break; |
| 1936 | |
| 1937 | case 'mp3': |
| 1938 | case 'swa': |
| 1939 | $type = 'audio/mp3'; |
| 1940 | break; |
| 1941 | |
| 1942 | case 'wav': |
| 1943 | $type = 'audio/wav'; |
| 1944 | break; |
| 1945 | |
| 1946 | case 'wax': |
| 1947 | $type = 'audio/x-ms-wax'; |
| 1948 | break; |
| 1949 | |
| 1950 | case 'wma': |
| 1951 | $type = 'audio/x-ms-wma'; |
| 1952 | break; |
| 1953 | |
| 1954 | // Video mime-types |
| 1955 | case '3gp': |
| 1956 | case '3gpp': |
| 1957 | $type = 'video/3gpp'; |
| 1958 | break; |
| 1959 | |
| 1960 | case '3g2': |
| 1961 | case '3gp2': |
| 1962 | $type = 'video/3gpp2'; |
| 1963 | break; |
| 1964 | |
| 1965 | case 'asf': |
| 1966 | $type = 'video/x-ms-asf'; |
| 1967 | break; |
| 1968 | |
| 1969 | case 'm1a': |
| 1970 | case 'm1s': |
| 1971 | case 'm1v': |
| 1972 | case 'm15': |
| 1973 | case 'm75': |
| 1974 | case 'mp2': |
| 1975 | case 'mpa': |
| 1976 | case 'mpeg': |
| 1977 | case 'mpg': |
| 1978 | case 'mpm': |
| 1979 | case 'mpv': |
| 1980 | $type = 'video/mpeg'; |
| 1981 | break; |
| 1982 | |
| 1983 | case 'm4v': |
| 1984 | $type = 'video/x-m4v'; |
| 1985 | break; |
| 1986 | |
| 1987 | case 'mov': |
| 1988 | case 'qt': |
| 1989 | $type = 'video/quicktime'; |
| 1990 | break; |
| 1991 | |
| 1992 | case 'mp4': |
| 1993 | case 'mpg4': |
| 1994 | $type = 'video/mp4'; |
| 1995 | break; |
| 1996 | |
| 1997 | case 'sdv': |
| 1998 | $type = 'video/sd-video'; |
| 1999 | break; |
| 2000 | |
| 2001 | case 'wm': |
| 2002 | $type = 'video/x-ms-wm'; |
| 2003 | break; |
| 2004 | |
| 2005 | case 'wmv': |
| 2006 | $type = 'video/x-ms-wmv'; |
| 2007 | break; |
| 2008 | |
| 2009 | case 'wvx': |
| 2010 | $type = 'video/x-ms-wvx'; |
| 2011 | break; |
| 2012 | |
| 2013 | // Flash mime-types |
| 2014 | case 'spl': |
| 2015 | $type = 'application/futuresplash'; |
| 2016 | break; |
| 2017 | |
| 2018 | case 'swf': |
| 2019 | $type = 'application/x-shockwave-flash'; |
| 2020 | break; |
| 2021 | } |
| 2022 | } |
| 2023 | |
| 2024 | $mime = explode('/', $type, 2); |
| 2025 | $mime = $mime[0]; |
| 2026 | |
| 2027 | // Process values for 'auto' |
| 2028 | if ($width == 'auto') |
| 2029 | { |
| 2030 | if ($mime == 'video') |
| 2031 | { |
| 2032 | $width = '320'; |
| 2033 | } |
| 2034 | else |
| 2035 | { |
| 2036 | $width = '100%'; |
| 2037 | } |
| 2038 | } |
| 2039 | if ($height == 'auto') |
| 2040 | { |
| 2041 | if ($mime == 'audio') |
| 2042 | { |
| 2043 | $height = 0; |
| 2044 | } |
| 2045 | else if ($mime == 'video') |
| 2046 | { |
| 2047 | $height = 240; |
| 2048 | } |
| 2049 | else |
| 2050 | { |
| 2051 | $height = 256; |
| 2052 | } |
| 2053 | } |
| 2054 | |
| 2055 | // Set proper placeholder value |
| 2056 | if ($mime == 'audio') |
| 2057 | { |
| 2058 | $placeholder = $audio; |
| 2059 | } |
| 2060 | else if ($mime == 'video') |
| 2061 | { |
| 2062 | $placeholder = $video; |
| 2063 | } |
| 2064 | |
| 2065 | $embed = ''; |
| 2066 | |
| 2067 | // Make sure the JS library is included |
| 2068 | // (I know it'll be included multiple times, but I can't think of a better way to do this automatically) |
| 2069 | if (!$native) |
| 2070 | { |
| 2071 | $embed .= '<script type="text/javascript" src="?js"></script>'; |
| 2072 | } |
| 2073 | |
| 2074 | // Odeo Feed MP3's |
| 2075 | if (substr(strtolower($this->get_link()), 0, 15) == 'http://odeo.com') { |
| 2076 | if ($native) |
| 2077 | { |
| 2078 | $embed .= '<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url=' . $this->get_link() . '"></embed>'; |
| 2079 | } |
| 2080 | else |
| 2081 | { |
| 2082 | $embed .= '<script type="text/javascript">embed_odeo("' . $this->get_link() . '");</script>'; |
| 2083 | } |
| 2084 | } |
| 2085 | |
| 2086 | // QuickTime 7 file types. Need to test with QuickTime 6. |
| 2087 | else if (in_array($type, array('audio/3gpp', 'audio/3gpp2', 'audio/aac', 'audio/x-aac', 'audio/aiff', 'audio/x-aiff', 'audio/mid', 'audio/midi', 'audio/x-midi', 'audio/mpeg', 'audio/x-mpeg', 'audio/mp3', 'x-audio/mp3', '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'))) |
| 2088 | { |
| 2089 | $height += 16; |
| 2090 | if ($native) |
| 2091 | { |
| 2092 | if ($placeholder != "") { |
| 2093 | $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://www.apple.com/quicktime/download/\"></embed>"; |
| 2094 | } |
| 2095 | else { |
| 2096 | $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://www.apple.com/quicktime/download/\"></embed>"; |
| 2097 | } |
| 2098 | } |
| 2099 | else |
| 2100 | { |
| 2101 | $embed .= "<script type='text/javascript'>embed_quicktime('$type', '$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$placeholder', '$loop');</script>"; |
| 2102 | } |
| 2103 | } |
| 2104 | |
| 2105 | // Flash |
| 2106 | else if (in_array($type, array('application/x-shockwave-flash', 'application/futuresplash'))) |
| 2107 | { |
| 2108 | if ($native) |
| 2109 | { |
| 2110 | $embed .= "<embed src=\"" . $this->get_link() . "\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"$type\" quality=\"high\" width=\"$width\" height=\"$height\" bgcolor=\"$bgcolor\" loop=\"$loop\"></embed>"; |
| 2111 | } |
| 2112 | else |
| 2113 | { |
| 2114 | $embed .= "<script type='text/javascript'>embed_flash('$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$loop', '$type');</script>"; |
| 2115 | } |
| 2116 | } |
| 2117 | |
| 2118 | // Windows Media |
| 2119 | else if (in_array($type, 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'))) |
| 2120 | { |
| 2121 | $height += 45; |
| 2122 | if ($native) |
| 2123 | { |
| 2124 | $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>"; |
| 2125 | } |
| 2126 | else |
| 2127 | { |
| 2128 | $embed .= "<script type='text/javascript'>embed_wmedia('$width', '$height', '" . $this->get_link() . "');</script>"; |
| 2129 | } |
| 2130 | } |
| 2131 | |
| 2132 | // Everything else |
| 2133 | else $embed .= '<a href="' . $this->get_link() . '" class="' . $altclass . '">' . $alt . '</a>'; |
| 2134 | |
| 2135 | return $embed; |
| 2136 | } |
| 2137 | } |
| 2138 | |
| 2139 | class SimplePie_File |
| 2140 | { |
| 2141 | var $url; |
| 2142 | var $useragent; |
| 2143 | var $success = true; |
| 2144 | var $headers = array(); |
| 2145 | var $body; |
| 2146 | var $fp; |
| 2147 | var $redirects = 0; |
| 2148 | var $error; |
| 2149 | var $method; |
| 2150 | |
| 2151 | function SimplePie_File($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) |
| 2152 | { |
| 2153 | if (class_exists('idna_convert')) |
| 2154 | { |
| 2155 | $idn = new idna_convert; |
| 2156 | $url = $idn->encode($url); |
| 2157 | } |
| 2158 | $this->url = $url; |
| 2159 | $this->useragent = $useragent; |
| 2160 | if (preg_match('/^http(s)?:\/\//i', $url)) |
| 2161 | { |
| 2162 | if (empty($useragent)) |
| 2163 | { |
| 2164 | $useragent = ini_get('user_agent'); |
| 2165 | $this->useragent = $useragent; |
| 2166 | } |
| 2167 | if (!is_array($headers)) |
| 2168 | { |
| 2169 | $headers = array(); |
| 2170 | } |
| 2171 | if (extension_loaded('curl') && version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>=') && !$force_fsockopen) |
| 2172 | { |
| 2173 | $this->method = 'curl'; |
| 2174 | $fp = curl_init(); |
| 2175 | $headers2 = array(); |
| 2176 | foreach ($headers as $key => $value) |
| 2177 | { |
| 2178 | $headers2[] = "$key: $value"; |
| 2179 | } |
| 2180 | curl_setopt($fp, CURLOPT_ENCODING, ''); |
| 2181 | curl_setopt($fp, CURLOPT_URL, $url); |
| 2182 | curl_setopt($fp, CURLOPT_HEADER, 1); |
| 2183 | curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1); |
| 2184 | curl_setopt($fp, CURLOPT_TIMEOUT, $timeout); |
| 2185 | curl_setopt($fp, CURLOPT_REFERER, $url); |
| 2186 | curl_setopt($fp, CURLOPT_USERAGENT, $useragent); |
| 2187 | curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2); |
| 2188 | if (!ini_get('open_basedir') && !ini_get('safe_mode')) |
| 2189 | { |
| 2190 | curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1); |
| 2191 | curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects); |
| 2192 | } |
| 2193 | |
| 2194 | $this->headers = trim(curl_exec($fp)); |
| 2195 | if (curl_errno($fp) == 23 || curl_errno($fp) == 61) |
| 2196 | { |
| 2197 | curl_setopt($fp, CURLOPT_ENCODING, 'none'); |
| 2198 | $this->headers = trim(curl_exec($fp)); |
| 2199 | } |
| 2200 | if (curl_errno($fp)) |
| 2201 | { |
| 2202 | $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp); |
| 2203 | $this->success = false; |
| 2204 | return false; |
| 2205 | } |
| 2206 | $info = curl_getinfo($fp); |
| 2207 | $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 2); |
| 2208 | if (count($this->headers) == $info['redirect_count'] + 1) |
| 2209 | { |
| 2210 | $this->headers = array_pop($this->headers); |
| 2211 | $this->body = ''; |
| 2212 | } |
| 2213 | else |
| 2214 | { |
| 2215 | $this->body = array_pop($this->headers); |
| 2216 | $this->headers = array_pop($this->headers); |
| 2217 | } |
| 2218 | $this->headers = $this->parse_headers($this->headers); |
| 2219 | if (($this->headers['status']['code'] == 301 || $this->headers['status']['code'] == 302 || $this->headers['status']['code'] == 303 || $this->headers['status']['code'] == 307) && !empty($this->headers['location']) && $this->redirects < $redirects) |
| 2220 | { |
| 2221 | $this->redirects++; |
| 2222 | return $this->SimplePie_File($this->headers['location'], $timeout, $redirects, $headers, $useragent, $force_fsockopen); |
| 2223 | } |
| 2224 | } |
| 2225 | else |
| 2226 | { |
| 2227 | $this->method = 'fsockopen'; |
| 2228 | $url_parts = parse_url($url); |
| 2229 | if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) == 'https') |
| 2230 | { |
| 2231 | $url_parts['host'] = "ssl://$url_parts[host]"; |
| 2232 | $url_parts['port'] = 443; |
| 2233 | } |
| 2234 | if (!isset($url_parts['port'])) |
| 2235 | { |
| 2236 | $url_parts['port'] = 80; |
| 2237 | } |
| 2238 | $this->fp = fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout); |
| 2239 | if (!$this->fp) |
| 2240 | { |
| 2241 | $this->error = 'fsockopen error: ' . $errstr; |
| 2242 | $this->success = false; |
| 2243 | return false; |
| 2244 | } |
| 2245 | else |
| 2246 | { |
| 2247 | stream_set_timeout($this->fp, $timeout); |
| 2248 | $get = (isset($url_parts['query'])) ? "$url_parts[path]?$url_parts[query]" : $url_parts['path']; |
| 2249 | $out = "GET $get HTTP/1.0\r\n"; |
| 2250 | $out .= "Host: $url_parts[host]\r\n"; |
| 2251 | $out .= "User-Agent: $useragent\r\n"; |
| 2252 | if (function_exists('gzinflate')) |
| 2253 | { |
| 2254 | $out .= "Accept-Encoding: gzip,deflate\r\n"; |
1264 | | } |
1265 | | else { |
1266 | | return false; |
1267 | | } |
1268 | | } |
1269 | | |
1270 | | |
1271 | | |
1272 | | |
1273 | | /**************************************************** |
1274 | | SIMPLEPIE ERROR (internal function) |
1275 | | ****************************************************/ |
1276 | | function sp_error($message, $level, $file, $line) { |
1277 | | $this->error = $message; |
1278 | | switch ($level) { |
| 2347 | else |
| 2348 | { |
| 2349 | return false; |
| 2350 | } |
| 2351 | } |
| 2352 | return $this->body; |
| 2353 | } |
| 2354 | |
| 2355 | function close() |
| 2356 | { |
| 2357 | if (!is_null($this->fp)) |
| 2358 | { |
| 2359 | if (fclose($this->fp)) |
| 2360 | { |
| 2361 | $this->fp = null; |
| 2362 | return true; |
| 2363 | } |
| 2364 | else |
| 2365 | { |
| 2366 | return false; |
| 2367 | } |
| 2368 | } |
| 2369 | else |
| 2370 | { |
| 2371 | return false; |
| 2372 | } |
| 2373 | } |
| 2374 | |
| 2375 | function parse_headers($headers) |
| 2376 | { |
| 2377 | $headers = explode("\r\n", trim($headers)); |
| 2378 | $status = array_shift($headers); |
| 2379 | foreach ($headers as $header) |
| 2380 | { |
| 2381 | $data = explode(':', $header, 2); |
| 2382 | $head[strtolower(trim($data[0]))] = trim($data[1]); |
| 2383 | } |
| 2384 | if (preg_match('/HTTP\/[0-9\.]+ ([0-9]+)(.*)$/i', $status, $matches)) |
| 2385 | { |
| 2386 | if (isset($head['status'])) |
| 2387 | { |
| 2388 | unset($head['status']); |
| 2389 | } |
| 2390 | $head['status']['code'] = $matches[1]; |
| 2391 | $head['status']['name'] = trim($matches[2]); |
| 2392 | } |
| 2393 | return $head; |
| 2394 | } |
| 2395 | } |
| 2396 | |
| 2397 | class SimplePie_Cache |
| 2398 | { |
| 2399 | var $location; |
| 2400 | var $filename; |
| 2401 | var $extension; |
| 2402 | var $name; |
| 2403 | |
| 2404 | function SimplePie_Cache($location, $filename, $extension) |
| 2405 | { |
| 2406 | $this->location = $location; |
| 2407 | $this->filename = rawurlencode($filename); |
| 2408 | $this->extension = rawurlencode($extension); |
| 2409 | $this->name = "$location/$this->filename.$this->extension"; |
| 2410 | } |
| 2411 | |
| 2412 | function save($data) |
| 2413 | { |
| 2414 | if (file_exists($this->name) && is_writeable($this->name) || file_exists($this->location) && is_writeable($this->location)) |
| 2415 | { |
| 2416 | $fp = fopen($this->name, 'w'); |
| 2417 | if ($fp) |
| 2418 | { |
| 2419 | fwrite($fp, serialize($data)); |
| 2420 | fclose($fp); |
| 2421 | return true; |
| 2422 | } |
| 2423 | } |
| 2424 | return false; |
| 2425 | } |
| 2426 | |
| 2427 | function load() |
| 2428 | { |
| 2429 | if (file_exists($this->name) && is_readable($this->name)) |
| 2430 | { |
| 2431 | return unserialize(file_get_contents($this->name)); |
| 2432 | } |
| 2433 | return false; |
| 2434 | } |
| 2435 | |
| 2436 | function mtime() |
| 2437 | { |
| 2438 | if (file_exists($this->name)) |
| 2439 | { |
| 2440 | return filemtime($this->name); |
| 2441 | } |
| 2442 | return false; |
| 2443 | } |
| 2444 | |
| 2445 | function touch() |
| 2446 | { |
| 2447 | if (file_exists($this->name)) |
| 2448 | { |
| 2449 | return touch($this->name); |
| 2450 | } |
| 2451 | return false; |
| 2452 | } |
| 2453 | |
| 2454 | function unlink() |
| 2455 | { |
| 2456 | if (file_exists($this->name)) |
| 2457 | { |
| 2458 | return unlink($this->name); |
| 2459 | } |
| 2460 | return false; |
| 2461 | } |
| 2462 | } |
| 2463 | |
| 2464 | class SimplePie_Misc |
| 2465 | { |
| 2466 | function absolutize_url($relative, $base) |
| 2467 | { |
| 2468 | $relative = trim($relative); |
| 2469 | $base = trim($base); |
| 2470 | if (!empty($relative)) |
| 2471 | { |
| 2472 | $relative = SimplePie_Misc::parse_url($relative, false); |
| 2473 | $relative = array('scheme' => $relative[2], 'authority' => $relative[3], 'path' => $relative[5], 'query' => $relative[7], 'fragment' => $relative[9]); |
| 2474 | if (!empty($relative['scheme'])) |
| 2475 | { |
| 2476 | $target = $relative; |
| 2477 | } |
| 2478 | else if (!empty($base)) |
| 2479 | { |
| 2480 | $base = SimplePie_Misc::parse_url($base, false); |
| 2481 | $base = array('scheme' => $base[2], 'authority' => $base[3], 'path' => $base[5], 'query' => $base[7], 'fragment' => $base[9]); |
| 2482 | $target['scheme'] = $base['scheme']; |
| 2483 | if (!empty($relative['authority'])) |
| 2484 | { |
| 2485 | $target = array_merge($relative, $target); |
| 2486 | } |
| 2487 | else |
| 2488 | { |
| 2489 | $target['authority'] = $base['authority']; |
| 2490 | if (!empty($relative['path'])) |
| 2491 | { |
| 2492 | if (strpos($relative['path'], '/') === 0) |
| 2493 | { |
| 2494 | $target['path'] = $relative['path']; |
| 2495 | } |
| 2496 | else |
| 2497 | { |
| 2498 | if (!empty($base['path'])) |
| 2499 | { |
| 2500 | $target['path'] = dirname("$base[path].") . '/' . $relative['path']; |
| 2501 | } |
| 2502 | else |
| 2503 | { |
| 2504 | $target['path'] = '/' . $relative['path']; |
| 2505 | } |
| 2506 | } |
| 2507 | if (!empty($relative['query'])) |
| 2508 | { |
| 2509 | $target['query'] = $relative['query']; |
| 2510 | } |
| 2511 | $input = $target['path']; |
| 2512 | $target['path'] = ''; |
| 2513 | while (!empty($input)) |
| 2514 | { |
| 2515 | if (strpos($input, '../') === 0) |
| 2516 | { |
| 2517 | $input = substr($input, 3); |
| 2518 | } |
| 2519 | else if (strpos($input, './') === 0) |
| 2520 | { |
| 2521 | $input = substr($input, 2); |
| 2522 | } |
| 2523 | else if (strpos($input, '/./') === 0) |
| 2524 | { |
| 2525 | $input = substr_replace($input, '/', 0, 3); |
| 2526 | } |
| 2527 | else if (strpos($input, '/.') === 0 && SimplePie_Misc::strendpos($input, '/.') === 0) |
| 2528 | { |
| 2529 | $input = substr_replace($input, '/', -2); |
| 2530 | } |
| 2531 | else if (strpos($input, '/../') === 0) |
| 2532 | { |
| 2533 | $input = substr_replace($input, '/', 0, 4); |
| 2534 | $target['path'] = preg_replace('/(\/)?([^\/]+)$/msiU', '', $target['path']); |
| 2535 | } |
| 2536 | else if (strpos($input, '/..') === 0 && SimplePie_Misc::strendpos($input, '/..') === 0) |
| 2537 | { |
| 2538 | $input = substr_replace($input, '/', 0, 3); |
| 2539 | $target['path'] = preg_replace('/(\/)?([^\/]+)$/msiU', '', $target['path']); |
| 2540 | } |
| 2541 | else if ($input == '.' || $input == '..') |
| 2542 | { |
| 2543 | $input = ''; |
| 2544 | } |
| 2545 | else |
| 2546 | { |
| 2547 | if (preg_match('/^(.+)(\/|$)/msiU', $input, $match)) |
| 2548 | { |
| 2549 | $target['path'] .= $match[1]; |
| 2550 | $input = substr_replace($input, '', 0, strlen($match[1])); |
| 2551 | } |
| 2552 | } |
| 2553 | } |
| 2554 | } |
| 2555 | else |
| 2556 | { |
| 2557 | if (!empty($base['path'])) |
| 2558 | { |
| 2559 | $target['path'] = $base['path']; |
| 2560 | } |
| 2561 | else |
| 2562 | { |
| 2563 | $target['path'] = '/'; |
| 2564 | } |
| 2565 | if (!empty($relative['query'])) |
| 2566 | { |
| 2567 | $target['query'] = $relative['query']; |
| 2568 | } |
| 2569 | else if (!empty($base['query'])) |
| 2570 | { |
| 2571 | $target['query'] = $base['query']; |
| 2572 | } |
| 2573 | } |
| 2574 | } |
| 2575 | if (!empty($relative['fragment'])) |
| 2576 | { |
| 2577 | $target['fragment'] = $relative['fragment']; |
| 2578 | } |
| 2579 | } |
| 2580 | else |
| 2581 | { |
| 2582 | return false; |
| 2583 | } |
| 2584 | $return = ''; |
| 2585 | if (!empty($target['scheme'])) |
| 2586 | { |
| 2587 | $return .= "$target[scheme]:"; |
| 2588 | } |
| 2589 | if (!empty($target['authority'])) |
| 2590 | { |
| 2591 | $return .= $target['authority']; |
| 2592 | } |
| 2593 | if (!empty($target['path'])) |
| 2594 | { |
| 2595 | $return .= $target['path']; |
| 2596 | } |
| 2597 | if (!empty($target['query'])) |
| 2598 | { |
| 2599 | $return .= "?$target[query]"; |
| 2600 | } |
| 2601 | if (!empty($target['fragment'])) |
| 2602 | { |
| 2603 | $return .= "#$target[fragment]"; |
| 2604 | } |
| 2605 | } |
| 2606 | else |
| 2607 | { |
| 2608 | $return = $base; |
| 2609 | } |
| 2610 | return $return; |
| 2611 | } |
| 2612 | |
| 2613 | function strendpos($haystack, $needle) |
| 2614 | { |
| 2615 | return strlen($haystack) - strpos($haystack, $needle) - strlen($needle); |
| 2616 | } |
| 2617 | |
| 2618 | function get_element($realname, $string) |
| 2619 | { |
| 2620 | $return = array(); |
| 2621 | $name = preg_quote($realname, '/'); |
| 2622 | preg_match_all("/<($name)((\s*((\w+:)?\w+)\s*=\s*(\"([^\"]*)\"|'([^']*)'|(.*)))*)\s*((\/)?>|>(.*)<\/$name>)/msiU", $string, $matches, PREG_SET_ORDER); |
| 2623 | for ($i = 0; $i < count($matches); $i++) |
| 2624 | { |
| 2625 | $return[$i]['tag'] = $realname; |
| 2626 | $return[$i]['full'] = $matches[$i][0]; |
| 2627 | if (strlen($matches[$i][10]) <= 2) |
| 2628 | { |
| 2629 | $return[$i]['self_closing'] = true; |
| 2630 | } |
| 2631 | else |
| 2632 | { |
| 2633 | $return[$i]['self_closing'] = false; |
| 2634 | $return[$i]['content'] = $matches[$i][12]; |
| 2635 | } |
| 2636 | $return[$i]['attribs'] = array(); |
| 2637 | if (!empty($matches[$i][2])) |
| 2638 | { |
| 2639 | preg_match_all('/((\w+:)?\w+)\s*=\s*("([^"]*)"|\'([^\']*)\'|(\S+))\s/msiU', ' ' . $matches[$i][2] . ' ', $attribs, PREG_SET_ORDER); |
| 2640 | for ($j = 0; $j < count($attribs); $j++) |
| 2641 | { |
| 2642 | $return[$i]['attribs'][strtoupper($attribs[$j][1])]['data'] = $attribs[$j][count($attribs[$j])-1]; |
| 2643 | $first = substr($attribs[$j][2], 0, 1); |
| 2644 | $return[$i]['attribs'][strtoupper($attribs[$j][1])]['split'] = ($first == '"' || $first == "'") ? $first : '"'; |
| 2645 | } |
| 2646 | } |
| 2647 | } |
| 2648 | return $return; |
| 2649 | } |
| 2650 | |
| 2651 | function element_implode($element) |
| 2652 | { |
| 2653 | $full = "<$element[tag]"; |
| 2654 | foreach ($element['attribs'] as $key => $value) |
| 2655 | { |
| 2656 | $key = strtolower($key); |
| 2657 | $full .= " $key=$value[split]$value[data]$value[split]"; |
| 2658 | } |
| 2659 | if ($element['self_closing']) |
| 2660 | { |
| 2661 | $full .= ' />'; |
| 2662 | } |
| 2663 | else |
| 2664 | { |
| 2665 | $full .= ">$element[content]</$element[tag]>"; |
| 2666 | } |
| 2667 | return $full; |
| 2668 | } |
| 2669 | |
| 2670 | function error($message, $level, $file, $line) |
| 2671 | { |
| 2672 | switch ($level) |
| 2673 | { |
1293 | | } |
1294 | | |
1295 | | |
1296 | | |
1297 | | |
1298 | | /**************************************************** |
1299 | | GET FEED ENCODING |
1300 | | ****************************************************/ |
1301 | | function get_encoding() { |
1302 | | if (isset($this->encoding)) { |
1303 | | return $this->encoding; |
1304 | | } else if (isset($this->data['feedinfo']['encoding'])) { |
1305 | | return $this->data['feedinfo']['encoding']; |
1306 | | } else return false; |
1307 | | } |
1308 | | |
1309 | | function handle_content_type($mime='text/html') { |
1310 | | if (!headers_sent() && $this->get_encoding()) header('Content-type: ' . $mime . '; charset=' . $this->get_encoding()); |
1311 | | } |
1312 | | |
1313 | | |
1314 | | |
1315 | | |
1316 | | /**************************************************** |
1317 | | GET FEED VERSION NUMBER |
1318 | | ****************************************************/ |
1319 | | function get_version() { |
1320 | | if (isset($this->data['feedinfo'])) { |
1321 | | return (isset($this->data['feedinfo']['version'])) ? $this->data[feedinfo][type] . ' ' . $this->data[feedinfo][version] : $this->data['feedinfo']['type']; |
1322 | | } |
1323 | | else return false; |
1324 | | } |
1325 | | |
1326 | | |
1327 | | |
1328 | | |
1329 | | /**************************************************** |
1330 | | SUBSCRIPTION URLS |
1331 | | This allows people to subscribe to the feed in various services. |
1332 | | ****************************************************/ |
1333 | | function subscribe_url() { |
1334 | | return (empty($this->rss_url)) ? false : $this->fix_protocol($this->rss_url, 1); |
1335 | | } |
1336 | | |
1337 | | function subscribe_feed() { |
1338 | | return (empty($this->rss_url)) ? false : $this->fix_protocol($this->rss_url, 2); |
1339 | | } |
1340 | | |
1341 | | function subscribe_podcast() { |
1342 | | return (empty($this->rss_url)) ? false : $this->fix_protocol($this->rss_url, 3); |
1343 | | } |
1344 | | |
1345 | | function subscribe_aol() { |
1346 | | return (empty($this->rss_url)) ? false : 'http://feeds.my.aol.com/add.jsp?url=' . rawurlencode($this->subscribe_url()); |
1347 | | } |
1348 | | |
1349 | | function subscribe_bloglines() { |
1350 | | return (empty($this->rss_url)) ? false : 'http://www.bloglines.com/sub/' . rawurlencode($this->subscribe_url()); |
1351 | | } |
1352 | | |
1353 | | function subscribe_google() { |
1354 | | return (empty($this->rss_url)) ? false : 'http://fusion.google.com/add?feedurl=' . rawurlencode($this->subscribe_url()); |
1355 | | } |
1356 | | |
1357 | | function subscribe_msn() { |
1358 | | return (empty($this->rss_url)) ? false : 'http://my.msn.com/addtomymsn.armx?id=rss&ut=' . rawurlencode($this->subscribe_url()) . '&ru=' . rawurlencode($this->get_feed_link()); |
1359 | | } |
1360 | | |
1361 | | function subscribe_netvibes() { |
1362 | | return (empty($this->rss_url)) ? false : 'http://www.netvibes.com/subscribe.php?url=' . rawurlencode($this->subscribe_url()); |
1363 | | } |
1364 | | |
1365 | | function subscribe_newsburst() { |
1366 | | return (empty($this->rss_url)) ? false : 'http://www.newsburst.com/Source/?add=' . rawurlencode($this->subscribe_url()); |
1367 | | } |
1368 | | |
1369 | | function subscribe_newsgator() { |
1370 | | return (empty($this->rss_url)) ? false : 'http://www.newsgator.com/ngs/subscriber/subext.aspx?url=' . rawurlencode($this->subscribe_url()); |
1371 | | } |
1372 | | |
1373 | | function subscribe_odeo() { |
1374 | | return (empty($this->rss_url)) ? false : 'http://www.odeo.com/listen/subscribe?feed=' . rawurlencode($this->subscribe_url()); |
1375 | | } |
1376 | | |
1377 | | function subscribe_pluck() { |
1378 | | return (empty($this->rss_url)) ? false : 'http://client.pluck.com/pluckit/prompt.aspx?GCID=C12286x053&a=' . rawurlencode($this->subscribe_url()); |
1379 | | } |
1380 | | |
1381 | | function subscribe_podnova() { |
1382 | | return (empty($this->rss_url)) ? false : 'http://www.podnova.com/index_your_podcasts.srf?action=add&url=' . rawurlencode($this->subscribe_url()); |
1383 | | } |
1384 | | |
1385 | | function subscribe_rojo() { |
1386 | | return (empty($this->rss_url)) ? false : 'http://www.rojo.com/add-subscription?resource=' . rawurlencode($this->subscribe_url()); |
1387 | | } |
1388 | | |
1389 | | function subscribe_yahoo() { |
1390 | | return (empty($this->rss_url)) ? false : 'http://add.my.yahoo.com/rss?url=' . rawurlencode($this->subscribe_url()); |
1391 | | } |
1392 | | |
1393 | | |
1394 | | |
1395 | | |
1396 | | /**************************************************** |
1397 | | PARSE OUT GENERAL FEED-RELATED DATA |
1398 | | ****************************************************/ |
1399 | | // Reads the feed's title |
1400 | | function get_feed_title() { |
1401 | | return (isset($this->data['info']['title'])) ? $this->data['info']['title'] : false; |
1402 | | } |
1403 | | |
1404 | | // Reads the feed's link (URL) |
1405 | | function get_feed_link() { |
1406 | | return (isset($this->data['info']['link'][0])) ? $this->data['info']['link'][0] : false; |
1407 | | } |
1408 | | |
1409 | | // Reads the feed's link (URL) |
1410 | | function get_feed_links($key) { |
1411 | | return (isset($this->data['info']['link'][$key])) ? $this->data['info']['link'][$key] : false; |
1412 | | } |
1413 | | |
1414 | | // Reads the feed's description |
1415 | | function get_feed_description() { |
1416 | | return (isset($this->data['info']['description'])) ? $this->data['info']['description'] : false; |
1417 | | } |
1418 | | |
1419 | | // Reads the feed's copyright information. |
1420 | | function get_feed_copyright() { |
1421 | | return (isset($this->data['info']['copyright'])) ? $this->data['info']['copyright'] : false; |
1422 | | } |
1423 | | |
1424 | | // Reads the feed's language |
1425 | | function get_feed_language() { |
1426 | | return (isset($this->data['info']['language'])) ? $this->data['info']['language'] : false; |
1427 | | } |
1428 | | |
1429 | | |
1430 | | |
1431 | | |
1432 | | /**************************************************** |
1433 | | PARSE OUT IMAGE-RELATED DATA |
1434 | | Apparently Atom doesn't have feed images. |
1435 | | ****************************************************/ |
1436 | | // Check if an image element exists (returns true/false) |
1437 | | function get_image_exist() { |
1438 | | return (isset($this->data['info']['image']['url'])) ? true : false; |
1439 | | } |
1440 | | |
1441 | | // Get the image title (to be used in alt and/or title) |
1442 | | function get_image_title() { |
1443 | | return (isset($this->data['info']['image']['title'])) ? $this->data['info']['image']['title'] : false; |
1444 | | } |
1445 | | |
1446 | | // The path to the actual image |
1447 | | function get_image_url() { |
1448 | | return (isset($this->data['info']['image']['url'])) ? $this->data['info']['image']['url'] : false; |
1449 | | } |
1450 | | |
1451 | | // The URL that the image is supposed to link to. |
1452 | | function get_image_link() { |
1453 | | return (isset($this->data['info']['image']['link'])) ? $this->data['info']['image']['link'] : false; |
1454 | | } |
1455 | | |
1456 | | // Get the image width |
1457 | | function get_image_width() { |
1458 | | return (isset($this->data['info']['image']['width'])) ? $this->data['info']['image']['width'] : false; |
1459 | | } |
1460 | | |
1461 | | // Get the image height |
1462 | | function get_image_height() { |
1463 | | return (isset($this->data['info']['image']['height'])) ? $this->data['info']['image']['height'] : false; |
1464 | | } |
1465 | | |
1466 | | |
1467 | | |
1468 | | |
1469 | | /**************************************************** |
1470 | | PARSE OUT ITEM-RELATED DATA |
1471 | | ****************************************************/ |
1472 | | // Get the size of the array of items (for use in a for-loop) |
1473 | | function get_item_quantity($max=0) { |
1474 | | $qty = (isset($this->data['items'])) ? sizeof($this->data['items']) : 0; |
1475 | | if ($max != 0) return ($qty > $max) ? $max : $qty; |
1476 | | else return $qty; |
1477 | | } |
1478 | | |
1479 | | function get_item($key) { |
1480 | | return $this->data['items'][$key]; |
1481 | | } |
1482 | | |
1483 | | function get_items($start = 0, $end = 0) { |
1484 | | return ($end == 0) ? array_slice($this->data['items'], $start) : array_slice($this->data['items'], $start, $end); |
1485 | | } |
1486 | | |
1487 | | |
1488 | | |
1489 | | |
1490 | | /**************************************************** |
1491 | | FIX PROTOCOL |
1492 | | Convert feed:// and no-protocol URL's to http:// |
1493 | | Feed is allowed to have no protocol. Local files are toggled in init(). |
1494 | | This is an internal function and is not intended to be used publically. |
1495 | | |
1496 | | $http=1, http://www.domain.com/feed.xml (absolute) |
1497 | | $http=2, feed://www.domain.com/feed.xml (absolute) |
1498 | | $http=3, podcast://www.domain.com/feed.xml (absolute) |
1499 | | ****************************************************/ |
1500 | | function fix_protocol($mp_feed_proto, $http = 1) { |
1501 | | $url = $mp_feed_proto; |
1502 | | |
1503 | | $url = preg_replace('/feed:(\/\/)?(http:\/\/)?/i', 'http://', $url); |
1504 | | $url = preg_replace('/(feed:)?(\/\/)?https:\/\//i', 'https://', $url); |
1505 | | $url = preg_replace('/p(od)?cast:(\/\/)?(http:\/\/)?/i', 'http://', $url); |
1506 | | $url = preg_replace('/(p(od)?cast:)?(\/\/)?https:\/\//i', 'https://', $url); |
1507 | | if (!stristr($url, 'http://') && !stristr($url, 'https://') && !file_exists($url)) $url = "http://$url"; |
1508 | | |
1509 | | if ($http == 1) return $url; |
1510 | | else if ($http == 2) { |
1511 | | if (strstr($url, 'http://')) { |
1512 | | $url = substr_replace($url, 'feed', 0, 4); |
1513 | | return $url; |
1514 | | } |
1515 | | else return $url; |
1516 | | } |
1517 | | else if ($http == 3) { |
1518 | | if (strstr($url, 'http://')) { |
1519 | | $url = substr_replace($url, 'podcast', 0, 4); |
1520 | | return $url; |
1521 | | } |
1522 | | else return $url; |
1523 | | } |
1524 | | } |
1525 | | |
1526 | | |
1527 | | |
1528 | | |
1529 | | /**************************************************** |
1530 | | ULTRA-LIBERAL FEED LOCATOR |
1531 | | Based upon http://diveintomark.org/archives/2002/08/15/ultraliberal_rss_locator |
1532 | | This function enables support for RSS auto-discovery-on-crack. |
1533 | | ****************************************************/ |
1534 | | function rss_locator($data, $url) { |
1535 | | |
1536 | | $this->url = $url; |
1537 | | $this->parsed_url = parse_url($url); |
1538 | | if (!isset($this->parsed_url['path'])) { |
1539 | | $this->parsed_url['path'] = '/'; |
1540 | | } |
1541 | | |
1542 | | // Check is the URL we're given is a feed |
1543 | | if ($this->is_feed($data, false)) { |
| 2688 | return $message; |
| 2689 | } |
| 2690 | |
| 2691 | function display_file($url, $timeout = 10, $useragent = null) |
| 2692 | { |
| 2693 | $file = new SimplePie_File($url, $timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $useragent); |
| 2694 | $headers = $file->headers(); |
| 2695 | if ($file->body() !== false) |
| 2696 | { |
| 2697 | header('Content-type: ' . $headers['content-type']); |
| 2698 | echo $file->body(); |
| 2699 | exit; |
| 2700 | } |
| 2701 | } |
| 2702 | |
| 2703 | function fix_protocol($url, $http = 1) |
| 2704 | { |
| 2705 | $parsed = SimplePie_Misc::parse_url($url); |
| 2706 | if (!empty($parsed['scheme']) && strtolower($parsed['scheme']) != 'http' && strtolower($parsed['scheme']) != 'https') |
| 2707 | { |
| 2708 | return SimplePie_Misc::fix_protocol("$parsed[authority]$parsed[path]$parsed[query]$parsed[fragment]", $http); |
| 2709 | } |
| 2710 | if (!file_exists($url) && empty($parsed['scheme'])) |
| 2711 | { |
| 2712 | return SimplePie_Misc::fix_protocol("http://$url", $http); |
| 2713 | } |
| 2714 | |
| 2715 | if ($http == 2 && !empty($parsed['scheme'])) |
| 2716 | { |
| 2717 | return "feed:$url"; |
| 2718 | } |
| 2719 | else if ($http == 3 && strtolower($parsed['scheme']) == 'http') |
| 2720 | { |
| 2721 | return substr_replace($url, 'podcast', 0, 4); |
| 2722 | } |
| 2723 | else |
| 2724 | { |
1546 | | |
1547 | | // Feeds pointed to by LINK tags in the header of the page (autodiscovery) |
1548 | | $stage1 = $this->check_link_elements($data); |
1549 | | if ($stage1) { |
1550 | | return $stage1; |
1551 | | } |
1552 | | |
1553 | | // Grab all the links in the page, and put them into two arrays (local, and external) |
1554 | | if ($this->get_links($data)) { |
1555 | | |
1556 | | // <A> links to feeds on the same server ending in ".rss", ".rdf", ".xml", or ".atom" |
1557 | | $stage2 = $this->check_link_extension($this->local); |
1558 | | if ($stage2) { |
1559 | | return $stage2; |
1560 | | } |
1561 | | |
1562 | | // <A> links to feeds on the same server containing "rss", "rdf", "xml", or "atom" |
1563 | | $stage3 = $this->check_link_body($this->local); |
1564 | | if ($stage3) { |
1565 | | return $stage3; |
1566 | | } |
1567 | | |
1568 | | // <A> links to feeds on external servers ending in ".rss", ".rdf", ".xml", or ".atom" |
1569 | | $stage4 = $this->check_link_extension($this->elsewhere); |
1570 | | if ($stage4) { |
1571 | | return $stage4; |
1572 | | } |
1573 | | |
1574 | | // <A> links to feeds on external servers containing "rss", "rdf", "xml", or "atom" |
1575 | | $stage5 = $this->check_link_body($this->elsewhere); |
1576 | | if ($stage5) { |
1577 | | return $stage5; |
1578 | | } |
1579 | | } |
1580 | | |
| 2727 | } |
| 2728 | |
| 2729 | function parse_url($url, $parse_match = true) |
| 2730 | { |
| 2731 | preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/i', $url, $match); |
| 2732 | if (empty($match[0])) |
| 2733 | { |
| 2734 | return false; |
| 2735 | } |
| 2736 | else |
| 2737 | { |
| 2738 | for ($i = 6; $i < 10; $i++) |
| 2739 | { |
| 2740 | if (!isset($match[$i])) |
| 2741 | { |
| 2742 | $match[$i] = ''; |
| 2743 | } |
| 2744 | } |
| 2745 | if ($parse_match) |
| 2746 | { |
| 2747 | $match = array('scheme' => $match[2], 'authority' => $match[4], 'path' => $match[5], 'query' => $match[6], 'fragment' => $match[8]); |
| 2748 | } |
| 2749 | return $match; |
| 2750 | } |
| 2751 | } |
| 2752 | |
| 2753 | /** |
| 2754 | * Replace bad bytes |
| 2755 | * |
| 2756 | * PCRE Pattern to locate bad bytes in a UTF-8 string |
| 2757 | * Comes from W3 FAQ: Multilingual Forms |
| 2758 | * Note: modified to include full ASCII range including control chars |
| 2759 | * |
| 2760 | * Modified by Geoffrey Sneddon 2006-11-19 to remove functionality |
| 2761 | * to choose what the replace string is, and to use a variable for |
| 2762 | * the output instead of PHP's output buffer |
| 2763 | */ |
| 2764 | function utf8_bad_replace($str) |
| 2765 | { |
| 2766 | $UTF8_BAD = |
| 2767 | '([\x00-\x7F]' . # ASCII (including control chars) |
| 2768 | '|[\xC2-\xDF][\x80-\xBF]' . # non-overlong 2-byte |
| 2769 | '|\xE0[\xA0-\xBF][\x80-\xBF]' . # excluding overlongs |
| 2770 | '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}' . # straight 3-byte |
| 2771 | '|\xED[\x80-\x9F][\x80-\xBF]' . # excluding surrogates |
| 2772 | '|\xF0[\x90-\xBF][\x80-\xBF]{2}' . # planes 1-3 |
| 2773 | '|[\xF1-\xF3][\x80-\xBF]{3}' . # planes 4-15 |
| 2774 | '|\xF4[\x80-\x8F][\x80-\xBF]{2}' . # plane 16 |
| 2775 | '|(.{1}))'; # invalid byte |
| 2776 | $output = ''; |
| 2777 | while (preg_match('/' . $UTF8_BAD . '/S', $str, $matches)) |
| 2778 | { |
| 2779 | if (!isset($matches[2])) |
| 2780 | { |
| 2781 | $output .= $matches[0]; |
| 2782 | } |
| 2783 | $str = substr($str, strlen($matches[0])); |
| 2784 | } |
| 2785 | return $output; |
| 2786 | } |
| 2787 | |
| 2788 | function change_encoding($data, $input, $output) |
| 2789 | { |
| 2790 | $input = SimplePie_Misc::encoding($input); |
| 2791 | $output = SimplePie_Misc::encoding($output); |
| 2792 | |
| 2793 | if ($input != $output) |
| 2794 | { |
| 2795 | if (function_exists('iconv') && $input['use_iconv'] && $output['use_iconv'] && iconv($input['encoding'], "$output[encoding]//TRANSLIT", $data)) |
| 2796 | { |
| 2797 | return iconv($input['encoding'], "$output[encoding]//TRANSLIT", $data); |
| 2798 | } |
| 2799 | else if (function_exists('iconv') && $input['use_iconv'] && $output['use_iconv'] && iconv($input['encoding'], $output['encoding'], $data)) |
| 2800 | { |
| 2801 | return iconv($input['encoding'], $output['encoding'], $data); |
| 2802 | } |
| 2803 | else if (function_exists('mb_convert_encoding') && $input['use_mbstring'] && $output['use_mbstring']) |
| 2804 | { |
| 2805 | return mb_convert_encoding($data, $output['encoding'], $input['encoding']); |
| 2806 | } |
| 2807 | else if ($input['encoding'] == 'ISO-8859-1' && $output['encoding'] == 'UTF-8') |
| 2808 | { |
| 2809 | return utf8_encode($data); |
| 2810 | } |
| 2811 | else if ($input['encoding'] == 'UTF-8' && $output['encoding'] == 'ISO-8859-1') |
| 2812 | { |
| 2813 | return utf8_decode($data); |
| 2814 | } |
| 2815 | } |
| 2816 | return $data; |
| 2817 | } |
| 2818 | |
| 2819 | function encoding($encoding) |
| 2820 | { |
| 2821 | $return['use_mbstring'] = false; |
| 2822 | $return['use_iconv'] = false; |
| 2823 | switch (strtolower($encoding)) |
| 2824 | { |
| 2825 | |
| 2826 | // 7bit |
| 2827 | case '7bit': |
| 2828 | case '7-bit': |
| 2829 | $return['encoding'] = '7bit'; |
| 2830 | $return['use_mbstring'] = true; |
| 2831 | break; |
| 2832 | |
| 2833 | // 8bit |
| 2834 | case '8bit': |
| 2835 | case '8-bit': |
| 2836 | $return['encoding'] = '8bit'; |
| 2837 | $return['use_mbstring'] = true; |
| 2838 | break; |
| 2839 | |
| 2840 | // ARMSCII-8 |
| 2841 | case 'armscii-8': |
| 2842 | case 'armscii': |
| 2843 | $return['encoding'] = 'ARMSCII-8'; |
| 2844 | $return['use_iconv'] = true; |
| 2845 | break; |
| 2846 | |
| 2847 | // ASCII |
| 2848 | case 'us-ascii': |
| 2849 | case 'ascii': |
| 2850 | $return['encoding'] = 'US-ASCII'; |
| 2851 | $return['use_iconv'] = true; |
| 2852 | $return['use_mbstring'] = true; |
| 2853 | break; |
| 2854 | |
| 2855 | // BASE64 |
| 2856 | case 'base64': |
| 2857 | case 'base-64': |
| 2858 | $return['encoding'] = 'BASE64'; |
| 2859 | $return['use_mbstring'] = true; |
| 2860 | break; |
| 2861 | |
| 2862 | // Big5 - Traditional Chinese, mainly used in Taiwan |
| 2863 | case 'big5': |
| 2864 | case '950': |
| 2865 | $return['encoding'] = 'BIG5'; |
| 2866 | $return['use_iconv'] = true; |
| 2867 | $return['use_mbstring'] = true; |
| 2868 | break; |
| 2869 | |
| 2870 | // Big5 with Hong Kong extensions, Traditional Chinese |
| 2871 | case 'big5-hkscs': |
| 2872 | $return['encoding'] = 'BIG5-HKSCS'; |
| 2873 | $return['use_iconv'] = true; |
| 2874 | $return['use_mbstring'] = true; |
| 2875 | break; |
| 2876 | |
| 2877 | // byte2be |
| 2878 | case 'byte2be': |
| 2879 | $return['encoding'] = 'byte2be'; |
| 2880 | $return['use_mbstring'] = true; |
| 2881 | break; |
| 2882 | |
| 2883 | // byte2le |
| 2884 | case 'byte2le': |
| 2885 | $return['encoding'] = 'byte2le'; |
| 2886 | $return['use_mbstring'] = true; |
| 2887 | break; |
| 2888 | |
| 2889 | // byte4be |
| 2890 | case 'byte4be': |
| 2891 | $return['encoding'] = 'byte4be'; |
| 2892 | $return['use_mbstring'] = true; |
| 2893 | break; |
| 2894 | |
| 2895 | // byte4le |
| 2896 | case 'byte4le': |
| 2897 | $return['encoding'] = 'byte4le'; |
| 2898 | $return['use_mbstring'] = true; |
| 2899 | break; |
| 2900 | |
| 2901 | // EUC-CN |
| 2902 | case 'euc-cn': |
| 2903 | case 'euccn': |
| 2904 | $return['encoding'] = 'EUC-CN'; |
| 2905 | $return['use_iconv'] = true; |
| 2906 | $return['use_mbstring'] = true; |
| 2907 | break; |
| 2908 | |
| 2909 | // EUC-JISX0213 |
| 2910 | case 'euc-jisx0213': |
| 2911 | case 'eucjisx0213': |
| 2912 | $return['encoding'] = 'EUC-JISX0213'; |
| 2913 | $return['use_iconv'] = true; |
| 2914 | break; |
| 2915 | |
| 2916 | // EUC-JP |
| 2917 | case 'euc-jp': |
| 2918 | case 'eucjp': |
| 2919 | $return['encoding'] = 'EUC-JP'; |
| 2920 | $return['use_iconv'] = true; |
| 2921 | $return['use_mbstring'] = true; |
| 2922 | break; |
| 2923 | |
| 2924 | // EUCJP-win |
| 2925 | case 'euc-jp-win': |
| 2926 | case 'eucjp-win': |
| 2927 | case 'eucjpwin': |
| 2928 | $return['encoding'] = 'EUCJP-win'; |
| 2929 | $return['use_iconv'] = true; |
| 2930 | $return['use_mbstring'] = true; |
| 2931 | break; |
| 2932 | |
| 2933 | // EUC-KR |
| 2934 | case 'euc-kr': |
| 2935 | case 'euckr': |
| 2936 | $return['encoding'] = 'EUC-KR'; |
| 2937 | $return['use_iconv'] = true; |
| 2938 | $return['use_mbstring'] = true; |
| 2939 | break; |
| 2940 | |
| 2941 | // EUC-TW |
| 2942 | case 'euc-tw': |
| 2943 | case 'euctw': |
| 2944 | $return['encoding'] = 'EUC-TW'; |
| 2945 | $return['use_iconv'] = true; |
| 2946 | $return['use_mbstring'] = true; |
| 2947 | break; |
| 2948 | |
| 2949 | // GB18030 - Simplified Chinese, national standard character set |
| 2950 | case 'gb18030-2000': |
| 2951 | case 'gb18030': |
| 2952 | $return['encoding'] = 'GB18030'; |
| 2953 | $return['use_iconv'] = true; |
| 2954 | break; |
| 2955 | |
| 2956 | // GB2312 - Simplified Chinese, national standard character set |
| 2957 | case 'gb2312': |
| 2958 | case '936': |
| 2959 | $return['encoding'] = 'GB2312'; |
| 2960 | $return['use_mbstring'] = true; |
| 2961 | break; |
| 2962 | |
| 2963 | // GBK |
| 2964 | case 'gbk': |
| 2965 | $return['encoding'] = 'GBK'; |
| 2966 | $return['use_iconv'] = true; |
| 2967 | break; |
| 2968 | |
| 2969 | // Georgian-Academy |
| 2970 | case 'georgian-academy': |
| 2971 | $return['encoding'] = 'Georgian-Academy'; |
| 2972 | $return['use_iconv'] = true; |
| 2973 | break; |
| 2974 | |
| 2975 | // Georgian-PS |
| 2976 | case 'georgian-ps': |
| 2977 | $return['encoding'] = 'Georgian-PS'; |
| 2978 | $return['use_iconv'] = true; |
| 2979 | break; |
| 2980 | |
| 2981 | // HTML-ENTITIES |
| 2982 | case 'html-entities': |
| 2983 | case 'htmlentities': |
| 2984 | $return['encoding'] = 'HTML-ENTITIES'; |
| 2985 | $return['use_mbstring'] = true; |
| 2986 | break; |
| 2987 | |
| 2988 | // HZ |
| 2989 | case 'hz': |
| 2990 | $return['encoding'] = 'HZ'; |
| 2991 | $return['use_iconv'] = true; |
| 2992 | $return['use_mbstring'] = true; |
| 2993 | break; |
| 2994 | |
| 2995 | // ISO-2022-CN |
| 2996 | case 'iso-2022-cn': |
| 2997 | case 'iso2022-cn': |
| 2998 | case 'iso2022cn': |
| 2999 | $return['encoding'] = 'ISO-2022-CN'; |
| 3000 | $return['use_iconv'] = true; |
| 3001 | break; |
| 3002 | |
| 3003 | // ISO-2022-CN-EXT |
| 3004 | case 'iso-2022-cn-ext': |
| 3005 | case 'iso2022-cn-ext': |
| 3006 | case 'iso2022cn-ext': |
| 3007 | case 'iso2022cnext': |
| 3008 | $return['encoding'] = 'ISO-2022-CN'; |
| 3009 | $return['use_iconv'] = true; |
| 3010 | break; |
| 3011 | |
| 3012 | // ISO-2022-JP |
| 3013 | case 'iso-2022-jp': |
| 3014 | case 'iso2022-jp': |
| 3015 | case 'iso2022jp': |
| 3016 | $return['encoding'] = 'ISO-2022-JP'; |
| 3017 | $return['use_iconv'] = true; |
| 3018 | $return['use_mbstring'] = true; |
| 3019 | break; |
| 3020 | |
| 3021 | // ISO-2022-JP-1 |
| 3022 | case 'iso-2022-jp-1': |
| 3023 | case 'iso2022-jp-1': |
| 3024 | case 'iso2022jp-1': |
| 3025 | case 'iso2022jp1': |
| 3026 | $return['encoding'] = 'ISO-2022-JP-1'; |
| 3027 | $return['use_iconv'] = true; |
| 3028 | break; |
| 3029 | |
| 3030 | // ISO-2022-JP-2 |
| 3031 | case 'iso-2022-jp-2': |
| 3032 | case 'iso2022-jp-2': |
| 3033 | case 'iso2022jp-2': |
| 3034 | case 'iso2022jp2': |
| 3035 | $return['encoding'] = 'ISO-2022-JP-2'; |
| 3036 | $return['use_iconv'] = true; |
| 3037 | break; |
| 3038 | |
| 3039 | // ISO-2022-JP-3 |
| 3040 | case 'iso-2022-jp-3': |
| 3041 | case 'iso2022-jp-3': |
| 3042 | case 'iso2022jp-3': |
| 3043 | case 'iso2022jp3': |
| 3044 | $return['encoding'] = 'ISO-2022-JP-3'; |
| 3045 | $return['use_iconv'] = true; |
| 3046 | break; |
| 3047 | |
| 3048 | // ISO-2022-KR |
| 3049 | case 'iso-2022-kr': |
| 3050 | case 'iso2022-kr': |
| 3051 | case 'iso2022kr': |
| 3052 | $return['encoding'] = 'ISO-2022-KR'; |
| 3053 | $return['use_iconv'] = true; |
| 3054 | $return['use_mbstring'] = true; |
| 3055 | break; |
| 3056 | |
| 3057 | // ISO-8859-1 |
| 3058 | case 'iso-8859-1': |
| 3059 | case 'iso8859-1': |
| 3060 | $return['encoding'] = 'ISO-8859-1'; |
| 3061 | $return['use_iconv'] = true; |
| 3062 | $return['use_mbstring'] = true; |
| 3063 | break; |
| 3064 | |
| 3065 | // ISO-8859-2 |
| 3066 | case 'iso-8859-2': |
| 3067 | case 'iso8859-2': |
| 3068 | $return['encoding'] = 'ISO-8859-2'; |
| 3069 | $return['use_iconv'] = true; |
| 3070 | $return['use_mbstring'] = true; |
| 3071 | break; |
| 3072 | |
| 3073 | // ISO-8859-3 |
| 3074 | case 'iso-8859-3': |
| 3075 | case 'iso8859-3': |
| 3076 | $return['encoding'] = 'ISO-8859-3'; |
| 3077 | $return['use_iconv'] = true; |
| 3078 | $return['use_mbstring'] = true; |
| 3079 | break; |
| 3080 | |
| 3081 | // ISO-8859-4 |
| 3082 | case 'iso-8859-4': |
| 3083 | case 'iso8859-4': |
| 3084 | $return['encoding'] = 'ISO-8859-4'; |
| 3085 | $return['use_iconv'] = true; |
| 3086 | $return['use_mbstring'] = true; |
| 3087 | break; |
| 3088 | |
| 3089 | // ISO-8859-5 |
| 3090 | case 'iso-8859-5': |
| 3091 | case 'iso8859-5': |
| 3092 | $return['encoding'] = 'ISO-8859-5'; |
| 3093 | $return['use_iconv'] = true; |
| 3094 | $return['use_mbstring'] = true; |
| 3095 | break; |
| 3096 | |
| 3097 | // ISO-8859-6 |
| 3098 | case 'iso-8859-6': |
| 3099 | case 'iso8859-6': |
| 3100 | $return['encoding'] = 'ISO-8859-6'; |
| 3101 | $return['use_iconv'] = true; |
| 3102 | $return['use_mbstring'] = true; |
| 3103 | break; |
| 3104 | |
| 3105 | // ISO-8859-7 |
| 3106 | case 'iso-8859-7': |
| 3107 | case 'iso8859-7': |
| 3108 | $return['encoding'] = 'ISO-8859-7'; |
| 3109 | $return['use_iconv'] = true; |
| 3110 | $return['use_mbstring'] = true; |
| 3111 | break; |
| 3112 | |
| 3113 | // ISO-8859-8 |
| 3114 | case 'iso-8859-8': |
| 3115 | case 'iso8859-8': |
| 3116 | $return['encoding'] = 'ISO-8859-8'; |
| 3117 | $return['use_iconv'] = true; |
| 3118 | $return['use_mbstring'] = true; |
| 3119 | break; |
| 3120 | |
| 3121 | // ISO-8859-9 |
| 3122 | case 'iso-8859-9': |
| 3123 | case 'iso8859-9': |
| 3124 | $return['encoding'] = 'ISO-8859-9'; |
| 3125 | $return['use_iconv'] = true; |
| 3126 | $return['use_mbstring'] = true; |
| 3127 | break; |
| 3128 | |
| 3129 | // ISO-8859-10 |
| 3130 | case 'iso-8859-10': |
| 3131 | case 'iso8859-10': |
| 3132 | $return['encoding'] = 'ISO-8859-10'; |
| 3133 | $return['use_iconv'] = true; |
| 3134 | $return['use_mbstring'] = true; |
| 3135 | break; |
| 3136 | |
| 3137 | // mbstring/iconv functions don't appear to support 11 & 12 |
| 3138 | |
| 3139 | // ISO-8859-13 |
| 3140 | case 'iso-8859-13': |
| 3141 | case 'iso8859-13': |
| 3142 | $return['encoding'] = 'ISO-8859-13'; |
| 3143 | $return['use_iconv'] = true; |
| 3144 | $return['use_mbstring'] = true; |
| 3145 | break; |
| 3146 | |
| 3147 | // ISO-8859-14 |
| 3148 | case 'iso-8859-14': |
| 3149 | case 'iso8859-14': |
| 3150 | $return['encoding'] = 'ISO-8859-14'; |
| 3151 | $return['use_iconv'] = true; |
| 3152 | $return['use_mbstring'] = true; |
| 3153 | break; |
| 3154 | |
| 3155 | // ISO-8859-15 |
| 3156 | case 'iso-8859-15': |
| 3157 | case 'iso8859-15': |
| 3158 | $return['encoding'] = 'ISO-8859-15'; |
| 3159 | $return['use_iconv'] = true; |
| 3160 | $return['use_mbstring'] = true; |
| 3161 | break; |
| 3162 | |
| 3163 | // ISO-8859-16 |
| 3164 | case 'iso-8859-16': |
| 3165 | case 'iso8859-16': |
| 3166 | $return['encoding'] = 'ISO-8859-16'; |
| 3167 | $return['use_iconv'] = true; |
| 3168 | break; |
| 3169 | |
| 3170 | // JIS |
| 3171 | case 'jis': |
| 3172 | $return['encoding'] = 'JIS'; |
| 3173 | $return['use_mbstring'] = true; |
| 3174 | break; |
| 3175 | |
| 3176 | // JOHAB - Korean |
| 3177 | case 'johab': |
| 3178 | $return['encoding'] = 'JOHAB'; |
| 3179 | $return['use_iconv'] = true; |
| 3180 | break; |
| 3181 | |
| 3182 | // Russian |
| 3183 | case 'koi8-r': |
| 3184 | case 'koi8r': |
| 3185 | $return['encoding'] = 'KOI8-R'; |
| 3186 | $return['use_iconv'] = true; |
| 3187 | $return['use_mbstring'] = true; |
| 3188 | break; |
| 3189 | |
| 3190 | // Turkish |
| 3191 | case 'koi8-t': |
| 3192 | |