PageRenderTime 720ms CodeModel.GetById 45ms RepoModel.GetById 9ms app.codeStats 0ms

/lib/simplepie/simplepie_060828.inc

https://github.com/komagata/plnet
PHP | 4982 lines | 2182 code | 202 blank | 2598 comment | 325 complexity | b3c867e494b5080c2b9c08639e47beb0 MD5 | raw file
Possible License(s): LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /****************************************************
  3. SIMPLEPIE
  4. A PHP-Based RSS and Atom Feed Framework
  5. Takes the hard work out of managing a complete RSS/Atom solution.
  6. Version: "Lemon Meringue"
  7. Updated: 28 August 2006
  8. Copyright: 2004-2006 Ryan Parman, Geoffrey Sneddon
  9. http://simplepie.org
  10. *****************************************************
  11. LICENSE:
  12. GNU Lesser General Public License 2.1 (LGPL)
  13. http://creativecommons.org/licenses/LGPL/2.1/
  14. *****************************************************
  15. Please submit all bug reports and feature requests to the SimplePie forums.
  16. http://simplepie.org/support/
  17. ****************************************************/
  18. class SimplePie
  19. {
  20. // SimplePie Info
  21. var $name = 'SimplePie';
  22. var $version = 'Lemon Meringue';
  23. var $build = '20060828';
  24. var $url = 'http://simplepie.org/';
  25. var $useragent;
  26. var $linkback;
  27. // Other objects, instances created here so we can set options on them
  28. var $sanitize;
  29. // Options
  30. var $rss_url;
  31. var $file;
  32. var $xml_dump = false;
  33. var $enable_cache = true;
  34. var $max_minutes = 60;
  35. var $cache_location = './cache';
  36. var $order_by_date = true;
  37. var $input_encoding = false;
  38. // Misc. variables
  39. var $data;
  40. var $error;
  41. function SimplePie($feed_url = null, $cache_location = null, $cache_max_minutes = null)
  42. {
  43. $this->useragent = $this->name . '/' . $this->version . ' (Feed Parser; ' . $this->url . '; Allow like Gecko) Build/' . $this->build;
  44. $this->linkback = '<a href="' . $this->url . '" title="' . $this->name . ' ' . $this->version . '">' . $this->name . '</a>';
  45. // Other objects, instances created here so we can set options on them
  46. $this->sanitize = new SimplePie_Sanitize;
  47. // Parse the feed, if we get the data sent directly here
  48. if (!is_null($feed_url))
  49. {
  50. $this->feed_url($feed_url);
  51. }
  52. if (!is_null($cache_location))
  53. {
  54. $this->cache_location($cache_location);
  55. }
  56. if (!is_null($cache_max_minutes))
  57. {
  58. $this->cache_max_minutes($cache_max_minutes);
  59. }
  60. // If we've passed an xmldump variable in the URL, snap into XMLdump mode
  61. if (isset($_GET['xmldump']))
  62. {
  63. $this->enable_xmldump(true);
  64. }
  65. if (!is_null($feed_url))
  66. {
  67. return $this->init();
  68. }
  69. }
  70. function feed_url($url)
  71. {
  72. $this->rss_url = SimplePie_Misc::fix_protocol($url, 1);
  73. }
  74. function set_file(&$file)
  75. {
  76. if (is_a($file, 'SimplePie_File'))
  77. {
  78. $this->rss_url = $file->url;
  79. $this->file =& $file;
  80. }
  81. }
  82. function enable_xmldump($enable = false)
  83. {
  84. $this->xml_dump = (bool) $enable;
  85. }
  86. function enable_caching($enable = true)
  87. {
  88. $this->enable_cache = (bool) $enable;
  89. }
  90. function cache_max_minutes($minutes = 60)
  91. {
  92. $this->max_minutes = (float) $minutes;
  93. }
  94. function cache_location($location = './cache')
  95. {
  96. $this->cache_location = (string) $location;
  97. }
  98. function order_by_date($enable = true)
  99. {
  100. $this->order_by_date = (bool) $enable;
  101. }
  102. function input_encoding($encoding = false)
  103. {
  104. if ($encoding)
  105. {
  106. $this->input_encoding = (string) $encoding;
  107. }
  108. else
  109. {
  110. $this->input_encoding = false;
  111. }
  112. }
  113. function bypass_image_hotlink($get = false)
  114. {
  115. $this->sanitize->bypass_image_hotlink($get);
  116. }
  117. function bypass_image_hotlink_page($page = false)
  118. {
  119. $this->sanitize->bypass_image_hotlink_page($page);
  120. }
  121. function replace_headers($enable = false)
  122. {
  123. $this->sanitize->replace_headers($enable);
  124. }
  125. function remove_div($enable = true)
  126. {
  127. $this->sanitize->remove_div($enable);
  128. }
  129. function strip_ads($enable = true)
  130. {
  131. $this->sanitize->strip_ads($enable);
  132. }
  133. function strip_htmltags($tags = array('blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'), $encode = null)
  134. {
  135. $this->sanitize->strip_htmltags($tags);
  136. if (!is_null($encode))
  137. {
  138. $this->sanitize->encode_instead_of_strip($tags);
  139. }
  140. }
  141. function encode_instead_of_strip($enable = true)
  142. {
  143. $this->sanitize->encode_instead_of_strip($enable);
  144. }
  145. function strip_attributes($attribs = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur'))
  146. {
  147. $this->sanitize->strip_attributes($attribs);
  148. }
  149. function output_encoding($encoding = 'UTF-8')
  150. {
  151. $this->sanitize->output_encoding($encoding);
  152. }
  153. function init()
  154. {
  155. if ($this->sanitize->bypass_image_hotlink && !empty($_GET[$this->sanitize->bypass_image_hotlink]))
  156. {
  157. if (get_magic_quotes_gpc())
  158. {
  159. $_GET[$this->sanitize->bypass_image_hotlink] = stripslashes($_GET[$this->sanitize->bypass_image_hotlink]);
  160. }
  161. SimplePie_Misc::display_file($_GET[$this->sanitize->bypass_image_hotlink], 10, $this->useragent);
  162. }
  163. if (isset($_GET['js']))
  164. {
  165. $embed = <<<EOT
  166. function embed_odeo(link) {document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="440" height="80" align="middle"><param name="movie" value="http://odeo.com/flash/audio_player_fullsize.swf" /><param name="allowScriptAccess" value="any" /><param name="quality" value="high"><param name="wmode" value="transparent"><param name="flashvars" value="valid_sample_rate=true&external_url='+link+'" /><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></object>');}
  167. function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {document.writeln('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" style="cursor:hand; cursor:pointer;" type="'+type+'" codebase="http://www.apple.com/qtactivex/qtplugin.cab" bgcolor="'+bgcolor+'" width="'+width+'" height="'+height+'"><param name="href" value="'+link+'" /><param name="src" value="'+placeholder+'" /><param name="autoplay" value="false" /><param name="target" value="myself" /><param name="controller" value="false" /><param name="loop" value="'+loop+'" /><param name="scale" value="aspect" /><param name="bgcolor" value="'+bgcolor+'"><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></object>');}
  168. function embed_flash(bgcolor, width, height, link, loop, type) {document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" bgcolor="'+bgcolor+'" width="'+width+'" height="'+height+'"><param name="movie" value="'+link+'"><param name="quality" value="high"><param name="loop" value="'+loop+'"><param name="bgcolor" value="'+bgcolor+'"><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></object>');}
  169. function embed_wmedia(width, height, link) {document.writeln('<object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" type="application/x-oleobject" width="'+width+'" height="'+height+'" standby="Loading Windows Media Player..."><param name="FileName" value="'+link+'"><param name="autosize" value="true"><param name="ShowControls" value="true"><param name="ShowStatusBar" value="false"><param name="ShowDisplay" value="false"><param name="autostart" value="false"><embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed></object>');}
  170. EOT;
  171. if (function_exists('ob_gzhandler'))
  172. {
  173. ob_start('ob_gzhandler');
  174. }
  175. header('Content-type: text/javascript; charset: UTF-8');
  176. header('Cache-Control: must-revalidate');
  177. header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 86400) . ' GMT');
  178. echo $embed;
  179. exit;
  180. }
  181. if (!empty($this->rss_url))
  182. {
  183. $this->data = array();
  184. if ($this->enable_cache && preg_match('/^http(s)?:\/\//i', $this->rss_url))
  185. {
  186. $cache = new SimplePie_Cache($this->cache_location, sha1($this->rss_url), 'spc');
  187. }
  188. else
  189. {
  190. $cache = false;
  191. }
  192. if ($cache && !$this->xml_dump)
  193. {
  194. $this->data = $cache->load();
  195. if (!empty($this->data))
  196. {
  197. if (isset($this->data['url']) && $this->data['url'] != $this->rss_url)
  198. {
  199. $this->enable_caching(false);
  200. return $this->init();
  201. }
  202. else if (!empty($this->data['feed_url']))
  203. {
  204. $this->rss_url = $this->data['feed_url'];
  205. return $this->init();
  206. }
  207. else if ($cache->mtime() + $this->max_minutes * 60 < time())
  208. {
  209. if (!empty($this->data['last-modified']) || !empty($this->data['etag']))
  210. {
  211. $headers = array();
  212. if (!empty($this->data['last-modified']))
  213. {
  214. $headers['if-modified-since'] = $this->data['last-modified'];
  215. }
  216. if (!empty($this->data['etag']))
  217. {
  218. $headers['if-none-match'] = $this->data['etag'];
  219. }
  220. $file = new SimplePie_File($this->rss_url, 1, 5, $headers, $this->useragent);
  221. if ($file->success)
  222. {
  223. $headers = $file->headers();
  224. if ($headers['status']['code'] == 304)
  225. {
  226. $cache->touch();
  227. return true;
  228. }
  229. }
  230. unset($file);
  231. }
  232. else
  233. {
  234. $cache->unlink();
  235. }
  236. }
  237. else
  238. {
  239. return true;
  240. }
  241. }
  242. else
  243. {
  244. $cache->unlink();
  245. }
  246. }
  247. $this->data = array();
  248. if (!isset($file))
  249. {
  250. if (is_a($this->file, 'SimplePie_File') && $this->file->url == $this->rss_url)
  251. {
  252. $file =& $this->file;
  253. }
  254. else
  255. {
  256. $file = new SimplePie_File($this->rss_url, 10, 5, null, $this->useragent);
  257. }
  258. }
  259. if (!$file->success)
  260. {
  261. $this->error = $file->error;
  262. return false;
  263. }
  264. if (!SimplePie_Locator::is_feed($file))
  265. {
  266. $locate = new SimplePie_Locator($file);
  267. $feed = $locate->find();
  268. if ($feed)
  269. {
  270. if ($cache && !$cache->save(array('url' => $this->rss_url, 'feed_url' => $feed)))
  271. {
  272. $this->error = "$cache->name is not writeable";
  273. SimplePie_Misc::error($this->error, E_USER_WARNING, __FILE__, __LINE__);
  274. }
  275. $this->rss_url = $feed;
  276. return $this->init();
  277. }
  278. else
  279. {
  280. $this->error = "A feed could not be found at $this->rss_url";
  281. SimplePie_Misc::error($this->error, E_USER_WARNING, __FILE__, __LINE__);
  282. return false;
  283. }
  284. }
  285. $headers = $file->headers();
  286. $data = trim($file->body());
  287. $file->close();
  288. unset($file);
  289. // First check to see if input has been overridden.
  290. if (!empty($this->input_encoding))
  291. {
  292. $encoding = $this->input_encoding;
  293. }
  294. // Second try HTTP headers
  295. else if (!empty($headers['content-type']) && preg_match('/charset\s*=\s*([^;]*)/i', $headers['content-type'], $charset))
  296. {
  297. $encoding = $charset[1];
  298. }
  299. // Then prolog, if at the very start of the document
  300. else if (preg_match('/^<\?xml(.*)?>/msiU', $data, $prolog) && preg_match('/encoding\s*=\s*("([^"]*)"|\'([^\']*)\')/Ui', $prolog[1], $encoding))
  301. {
  302. $encoding = substr($encoding[1], 1, -1);
  303. }
  304. // UTF-32 Big Endian BOM
  305. else if (strpos($data, sprintf('%c%c%c%c', 0x00, 0x00, 0xFE, 0xFF)) === 0)
  306. {
  307. $encoding = 'UTF-32be';
  308. }
  309. // UTF-32 Little Endian BOM
  310. else if (strpos($data, sprintf('%c%c%c%c', 0xFF, 0xFE, 0x00, 0x00)) === 0)
  311. {
  312. $encoding = 'UTF-32';
  313. }
  314. // UTF-16 Big Endian BOM
  315. else if (strpos($data, sprintf('%c%c', 0xFE, 0xFF)) === 0)
  316. {
  317. $encoding = 'UTF-16be';
  318. }
  319. // UTF-16 Little Endian BOM
  320. else if (strpos($data, sprintf('%c%c', 0xFF, 0xFE)) === 0)
  321. {
  322. $encoding = 'UTF-16le';
  323. }
  324. // UTF-8 BOM
  325. else if (strpos($data, sprintf('%c%c%c', 0xEF, 0xBB, 0xBF)) === 0)
  326. {
  327. $encoding = 'UTF-8';
  328. }
  329. // Fallback to the default
  330. else
  331. {
  332. $encoding = null;
  333. }
  334. $data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8');
  335. $data = new SimplePie_Parser($data, 'UTF-8', $this->xml_dump);
  336. if ($this->xml_dump)
  337. {
  338. header('Content-type: text/xml; charset=UTF-8');
  339. echo $data->data;
  340. exit;
  341. }
  342. else if (!$data->error_code)
  343. {
  344. $this->sanitize->parse_data_array($data->data, $this->rss_url);
  345. unset($data);
  346. $this->data['feedinfo'] = $this->sanitize->feedinfo;
  347. $this->data['info'] = $this->sanitize->info;
  348. $this->data['items'] = $this->sanitize->items;
  349. $this->data['feedinfo']['encoding'] = $this->sanitize->output_encoding;
  350. unset($this->sanitize);
  351. $this->data['url'] = $this->rss_url;
  352. if (!empty($headers['last-modified']))
  353. {
  354. $this->data['last-modified'] = $headers['last-modified'];
  355. }
  356. if (!empty($headers['etag']))
  357. {
  358. $this->data['etag'] = $headers['etag'];
  359. }
  360. if ($this->order_by_date && !empty($this->data['items']))
  361. {
  362. $do_sort = true;
  363. foreach ($this->data['items'] as $item)
  364. {
  365. if (!isset($item->date))
  366. {
  367. $do_sort = false;
  368. break;
  369. }
  370. }
  371. if ($do_sort)
  372. {
  373. usort($this->data['items'], create_function('$a,$b', 'if ($a->date == $b->date) return 0; return ($a->date < $b->date) ? 1 : -1;'));
  374. }
  375. }
  376. if ($cache && !$cache->save($this->data))
  377. {
  378. $this->error = "$cache->name is not writeable";
  379. SimplePie_Misc::error($this->error, E_USER_WARNING, __FILE__, __LINE__);
  380. }
  381. return true;
  382. }
  383. else
  384. {
  385. $this->error = "XML error: $data->error_string at line $data->current_line, column $data->current_column";
  386. SimplePie_Misc::error($this->error, E_USER_WARNING, __FILE__, __LINE__);
  387. return false;
  388. }
  389. }
  390. }
  391. function get_encoding()
  392. {
  393. if (!empty($this->data['feedinfo']['encoding']))
  394. {
  395. return $this->data['feedinfo']['encoding'];
  396. }
  397. else
  398. {
  399. return false;
  400. }
  401. }
  402. function handle_content_type($mime='text/html')
  403. {
  404. if (!headers_sent())
  405. {
  406. $header = "Content-type: $mime;";
  407. if ($this->get_encoding())
  408. {
  409. $header .= ' charset=' . $this->get_encoding();
  410. }
  411. else
  412. {
  413. $header .= ' charset=UTF-8';
  414. }
  415. header($header);
  416. }
  417. }
  418. function get_type()
  419. {
  420. if (!empty($this->data['feedinfo']['type']))
  421. {
  422. return $this->data['feedinfo']['type'];
  423. }
  424. else
  425. {
  426. return false;
  427. }
  428. }
  429. function get_version()
  430. {
  431. if (!empty($this->data['feedinfo']['version']))
  432. {
  433. return $this->data['feedinfo']['version'];
  434. }
  435. else
  436. {
  437. return false;
  438. }
  439. }
  440. function get_favicon($check = false, $alternate = false)
  441. {
  442. if (!empty($this->data['info']['link']['alternate'][0]))
  443. {
  444. $favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $this->data['info']['link']['alternate'][0]);
  445. if ($check)
  446. {
  447. $file = new SimplePie_File($favicon);
  448. $headers = $file->headers();
  449. $file->close();
  450. if ($headers['status']['code'] == 200)
  451. {
  452. return $favicon;
  453. }
  454. }
  455. else
  456. {
  457. return $favicon;
  458. }
  459. }
  460. if ($alternate)
  461. {
  462. return $alternate;
  463. }
  464. else
  465. {
  466. return false;
  467. }
  468. }
  469. function subscribe_url()
  470. {
  471. if (!empty($this->rss_url))
  472. {
  473. return $this->rss_url;
  474. }
  475. else
  476. {
  477. return false;
  478. }
  479. }
  480. function subscribe_feed()
  481. {
  482. if (!empty($this->rss_url))
  483. {
  484. return SimplePie_Misc::fix_protocol($this->rss_url, 2);
  485. }
  486. else
  487. {
  488. return false;
  489. }
  490. }
  491. function subscribe_outlook()
  492. {
  493. if (!empty($this->rss_url))
  494. {
  495. return 'outlook' . SimplePie_Misc::fix_protocol($this->rss_url, 2);
  496. }
  497. else
  498. {
  499. return false;
  500. }
  501. }
  502. function subscribe_podcast()
  503. {
  504. if (!empty($this->rss_url))
  505. {
  506. return SimplePie_Misc::fix_protocol($this->rss_url, 3);
  507. }
  508. else
  509. {
  510. return false;
  511. }
  512. }
  513. function subscribe_aol()
  514. {
  515. if ($this->subscribe_url())
  516. {
  517. return 'http://feeds.my.aol.com/add.jsp?url=' . rawurlencode($this->subscribe_url());
  518. }
  519. else
  520. {
  521. return false;
  522. }
  523. }
  524. function subscribe_bloglines()
  525. {
  526. if ($this->subscribe_url())
  527. {
  528. return 'http://www.bloglines.com/sub/' . rawurlencode($this->subscribe_url());
  529. }
  530. else
  531. {
  532. return false;
  533. }
  534. }
  535. function subscribe_eskobo()
  536. {
  537. if ($this->subscribe_url())
  538. {
  539. return 'http://www.eskobo.com/?AddToMyPage=' . rawurlencode($this->subscribe_url());
  540. }
  541. else
  542. {
  543. return false;
  544. }
  545. }
  546. function subscribe_feedfeeds()
  547. {
  548. if ($this->subscribe_url())
  549. {
  550. return 'http://www.feedfeeds.com/add?feed=' . rawurlencode($this->subscribe_url());
  551. }
  552. else
  553. {
  554. return false;
  555. }
  556. }
  557. function subscribe_feedlounge()
  558. {
  559. if ($this->subscribe_url())
  560. {
  561. return 'http://my.feedlounge.com/external/subscribe?url=' . rawurlencode($this->subscribe_url());
  562. }
  563. else
  564. {
  565. return false;
  566. }
  567. }
  568. function subscribe_feedster()
  569. {
  570. if ($this->subscribe_url())
  571. {
  572. return 'http://www.feedster.com/myfeedster.php?action=addrss&amp;confirm=no&amp;rssurl=' . rawurlencode($this->subscribe_url());
  573. }
  574. else
  575. {
  576. return false;
  577. }
  578. }
  579. function subscribe_google()
  580. {
  581. if ($this->subscribe_url())
  582. {
  583. return 'http://fusion.google.com/add?feedurl=' . rawurlencode($this->subscribe_url());
  584. }
  585. else
  586. {
  587. return false;
  588. }
  589. }
  590. function subscribe_gritwire()
  591. {
  592. if ($this->subscribe_url())
  593. {
  594. return 'http://my.gritwire.com/feeds/addExternalFeed.aspx?FeedUrl=' . rawurlencode($this->subscribe_url());
  595. }
  596. else
  597. {
  598. return false;
  599. }
  600. }
  601. function subscribe_msn()
  602. {
  603. if ($this->subscribe_url())
  604. {
  605. $url = 'http://my.msn.com/addtomymsn.armx?id=rss&amp;ut=' . rawurlencode($this->subscribe_url());
  606. if ($this->get_feed_link())
  607. {
  608. $url .= '&amp;ru=' . rawurlencode($this->get_feed_link());
  609. }
  610. return $url;
  611. }
  612. else
  613. {
  614. return false;
  615. }
  616. }
  617. function subscribe_netvibes()
  618. {
  619. if ($this->subscribe_url())
  620. {
  621. return 'http://www.netvibes.com/subscribe.php?url=' . rawurlencode($this->subscribe_url());
  622. }
  623. else
  624. {
  625. return false;
  626. }
  627. }
  628. function subscribe_newsburst()
  629. {
  630. if ($this->subscribe_url())
  631. {
  632. return 'http://www.newsburst.com/Source/?add=' . rawurlencode($this->subscribe_url());
  633. }
  634. else
  635. {
  636. return false;
  637. }
  638. }
  639. function subscribe_newsgator()
  640. {
  641. if ($this->subscribe_url())
  642. {
  643. return 'http://www.newsgator.com/ngs/subscriber/subext.aspx?url=' . rawurlencode($this->subscribe_url());
  644. }
  645. else
  646. {
  647. return false;
  648. }
  649. }
  650. function subscribe_odeo()
  651. {
  652. if ($this->subscribe_url())
  653. {
  654. return 'http://www.odeo.com/listen/subscribe?feed=' . rawurlencode($this->subscribe_url());
  655. }
  656. else
  657. {
  658. return false;
  659. }
  660. }
  661. function subscribe_pluck()
  662. {
  663. if ($this->subscribe_url())
  664. {
  665. return 'http://client.pluck.com/pluckit/prompt.aspx?GCID=C12286x053&amp;a=' . rawurlencode($this->subscribe_url());
  666. }
  667. else
  668. {
  669. return false;
  670. }
  671. }
  672. function subscribe_podnova()
  673. {
  674. if ($this->subscribe_url())
  675. {
  676. return 'http://www.podnova.com/index_your_podcasts.srf?action=add&amp;url=' . rawurlencode($this->subscribe_url());
  677. }
  678. else
  679. {
  680. return false;
  681. }
  682. }
  683. function subscribe_rojo()
  684. {
  685. if ($this->subscribe_url())
  686. {
  687. return 'http://www.rojo.com/add-subscription?resource=' . rawurlencode($this->subscribe_url());
  688. }
  689. else
  690. {
  691. return false;
  692. }
  693. }
  694. function subscribe_yahoo()
  695. {
  696. if ($this->subscribe_url())
  697. {
  698. return 'http://add.my.yahoo.com/rss?url=' . rawurlencode($this->subscribe_url());
  699. }
  700. else
  701. {
  702. return false;
  703. }
  704. }
  705. function get_feed_title()
  706. {
  707. if (!empty($this->data['info']['title']))
  708. {
  709. return $this->data['info']['title'];
  710. }
  711. else
  712. {
  713. return false;
  714. }
  715. }
  716. function get_feed_link()
  717. {
  718. if (!empty($this->data['info']['link']['alternate'][0]))
  719. {
  720. return $this->data['info']['link']['alternate'][0];
  721. }
  722. else
  723. {
  724. return false;
  725. }
  726. }
  727. function get_feed_links()
  728. {
  729. if (!empty($this->data['info']['link']))
  730. {
  731. return $this->data['info']['link'];
  732. }
  733. else
  734. {
  735. return false;
  736. }
  737. }
  738. function get_feed_description()
  739. {
  740. if (!empty($this->data['info']['description']))
  741. {
  742. return $this->data['info']['description'];
  743. }
  744. else if (!empty($this->data['info']['dc:description']))
  745. {
  746. return $this->data['info']['dc:description'];
  747. }
  748. else if (!empty($this->data['info']['tagline']))
  749. {
  750. return $this->data['info']['tagline'];
  751. }
  752. else if (!empty($this->data['info']['subtitle']))
  753. {
  754. return $this->data['info']['subtitle'];
  755. }
  756. else
  757. {
  758. return false;
  759. }
  760. }
  761. function get_feed_copyright()
  762. {
  763. if (!empty($this->data['info']['copyright']))
  764. {
  765. return $this->data['info']['copyright'];
  766. }
  767. else
  768. {
  769. return false;
  770. }
  771. }
  772. function get_feed_language()
  773. {
  774. if (!empty($this->data['info']['language']))
  775. {
  776. return $this->data['info']['language'];
  777. }
  778. else if (!empty($this->data['info']['xml:lang']))
  779. {
  780. return $this->data['info']['xml:lang'];
  781. }
  782. else
  783. {
  784. return false;
  785. }
  786. }
  787. function get_image_exist()
  788. {
  789. if (!empty($this->data['info']['image']['url']) || !empty($this->data['info']['image']['logo']))
  790. {
  791. return true;
  792. }
  793. else
  794. {
  795. return false;
  796. }
  797. }
  798. function get_image_title()
  799. {
  800. if (!empty($this->data['info']['image']['title']))
  801. {
  802. return $this->data['info']['image']['title'];
  803. }
  804. else
  805. {
  806. return false;
  807. }
  808. }
  809. function get_image_url()
  810. {
  811. if (!empty($this->data['info']['image']['url']))
  812. {
  813. return $this->data['info']['image']['url'];
  814. }
  815. else if (!empty($this->data['info']['image']['logo']))
  816. {
  817. return $this->data['info']['image']['logo'];
  818. }
  819. else
  820. {
  821. return false;
  822. }
  823. }
  824. function get_image_link()
  825. {
  826. if (!empty($this->data['info']['image']['link']))
  827. {
  828. return $this->data['info']['image']['link'];
  829. }
  830. else
  831. {
  832. return false;
  833. }
  834. }
  835. function get_image_width()
  836. {
  837. if (!empty($this->data['info']['image']['width']))
  838. {
  839. return $this->data['info']['image']['width'];
  840. }
  841. else
  842. {
  843. return false;
  844. }
  845. }
  846. function get_image_height()
  847. {
  848. if (!empty($this->data['info']['image']['height']))
  849. {
  850. return $this->data['info']['image']['height'];
  851. }
  852. else
  853. {
  854. return false;
  855. }
  856. }
  857. function get_item_quantity($max = 0)
  858. {
  859. if (!empty($this->data['items']))
  860. {
  861. $qty = sizeof($this->data['items']);
  862. }
  863. else
  864. {
  865. $qty = 0;
  866. }
  867. if ($max == 0)
  868. {
  869. return $qty;
  870. }
  871. else
  872. {
  873. return ($qty > $max) ? $max : $qty;
  874. }
  875. }
  876. function get_item($key = 0)
  877. {
  878. if (!empty($this->data['items'][$key]))
  879. {
  880. return $this->data['items'][$key];
  881. }
  882. else
  883. {
  884. return false;
  885. }
  886. }
  887. function get_items($start = 0, $end = 0)
  888. {
  889. if ($end == 0)
  890. {
  891. return array_slice($this->data['items'], $start);
  892. }
  893. else
  894. {
  895. return array_slice($this->data['items'], $start, $end);
  896. }
  897. }
  898. }
  899. class SimplePie_Item
  900. {
  901. var $data;
  902. function SimplePie_Item($data)
  903. {
  904. $this->data =& $data;
  905. }
  906. function get_id()
  907. {
  908. if (!empty($this->data['guid']['data']))
  909. {
  910. return $this->data['guid']['data'];
  911. }
  912. else if (!empty($this->data['id']))
  913. {
  914. return $this->data['id'];
  915. }
  916. else
  917. {
  918. return false;
  919. }
  920. }
  921. function get_title()
  922. {
  923. if (!empty($this->data['title']))
  924. {
  925. return $this->data['title'];
  926. }
  927. else if (!empty($this->data['dc:title']))
  928. {
  929. return $this->data['dc:title'];
  930. }
  931. else
  932. {
  933. return false;
  934. }
  935. }
  936. function get_description()
  937. {
  938. if (!empty($this->data['content']))
  939. {
  940. return $this->data['content'];
  941. }
  942. else if (!empty($this->data['encoded']))
  943. {
  944. return $this->data['encoded'];
  945. }
  946. else if (!empty($this->data['summary']))
  947. {
  948. return $this->data['summary'];
  949. }
  950. else if (!empty($this->data['description']))
  951. {
  952. return $this->data['description'];
  953. }
  954. else if (!empty($this->data['dc:description']))
  955. {
  956. return $this->data['dc:description'];
  957. }
  958. else if (!empty($this->data['longdesc']))
  959. {
  960. return $this->data['longdesc'];
  961. }
  962. else
  963. {
  964. return false;
  965. }
  966. }
  967. function get_category($key = 0)
  968. {
  969. $categories = $this->get_categories();
  970. if (!empty($categories[$key]))
  971. {
  972. return $categories[$key];
  973. }
  974. else
  975. {
  976. return false;
  977. }
  978. }
  979. function get_categories()
  980. {
  981. $categories = array();
  982. if (!empty($this->data['category']))
  983. {
  984. $categories = array_merge($categories, $this->data['category']);
  985. }
  986. if (!empty($this->data['subject']))
  987. {
  988. $categories = array_merge($categories, $this->data['subject']);
  989. }
  990. if (!empty($categories))
  991. {
  992. return array_unique($categories);
  993. }
  994. else
  995. {
  996. return false;
  997. }
  998. }
  999. function get_author($key = 0)
  1000. {
  1001. $authors = $this->get_authors();
  1002. if (!empty($authors[$key]))
  1003. {
  1004. return $authors[$key];
  1005. }
  1006. else
  1007. {
  1008. return false;
  1009. }
  1010. }
  1011. function get_authors()
  1012. {
  1013. $authors = array();
  1014. if (!empty($this->data['author']))
  1015. {
  1016. $authors = array_merge($authors, $this->data['author']);
  1017. }
  1018. if (!empty($this->data['creator']))
  1019. {
  1020. $authors = array_merge($authors, $this->data['creator']);
  1021. }
  1022. if (!empty($authors))
  1023. {
  1024. return array_unique($authors);
  1025. }
  1026. else
  1027. {
  1028. return false;
  1029. }
  1030. }
  1031. function get_date($date_format = 'j F Y, g:i a')
  1032. {
  1033. if (!empty($this->data['pubdate']))
  1034. {
  1035. return date($date_format, $this->data['pubdate']);
  1036. }
  1037. else if (!empty($this->data['dc:date']))
  1038. {
  1039. return date($date_format, $this->data['dc:date']);
  1040. }
  1041. else if (!empty($this->data['issued']))
  1042. {
  1043. return date($date_format, $this->data['issued']);
  1044. }
  1045. else if (!empty($this->data['published']))
  1046. {
  1047. return date($date_format, $this->data['published']);
  1048. }
  1049. else if (!empty($this->data['modified']))
  1050. {
  1051. return date($date_format, $this->data['modified']);
  1052. }
  1053. else if (!empty($this->data['updated']))
  1054. {
  1055. return date($date_format, $this->data['updated']);
  1056. }
  1057. else
  1058. {
  1059. return false;
  1060. }
  1061. }
  1062. function get_permalink()
  1063. {
  1064. $link = $this->get_link(0);
  1065. $enclosure = $this->get_enclosure(0);
  1066. if (!empty($link))
  1067. {
  1068. return $link;
  1069. }
  1070. else if (!empty($enclosure))
  1071. {
  1072. return $enclosure->get_link();
  1073. }
  1074. else
  1075. {
  1076. return false;
  1077. }
  1078. }
  1079. function get_link($key = 0, $rel = 'alternate')
  1080. {
  1081. $links = $this->get_links($rel);
  1082. if (!empty($links[$key]))
  1083. {
  1084. return $links[$key];
  1085. }
  1086. else
  1087. {
  1088. return false;
  1089. }
  1090. }
  1091. function get_links($rel = 'alternate')
  1092. {
  1093. if (!empty($this->data['link'][$rel]))
  1094. {
  1095. return $this->data['link'][$rel];
  1096. }
  1097. else
  1098. {
  1099. return false;
  1100. }
  1101. }
  1102. function get_enclosure($key = 0)
  1103. {
  1104. $enclosures = $this->get_enclosures();
  1105. if (!empty($enclosures[$key]))
  1106. {
  1107. return $enclosures[$key];
  1108. }
  1109. else
  1110. {
  1111. return false;
  1112. }
  1113. }
  1114. function get_enclosures()
  1115. {
  1116. $enclosures = array();
  1117. $links = $this->get_links('enclosure');
  1118. if (!empty($this->data['enclosures']))
  1119. {
  1120. $enclosures = array_merge($enclosures, $this->data['enclosures']);
  1121. }
  1122. if (!empty($links))
  1123. {
  1124. $enclosures = array_merge($enclosures, $links);
  1125. }
  1126. if (!empty($enclosures))
  1127. {
  1128. return array_unique($enclosures);
  1129. }
  1130. else
  1131. {
  1132. return false;
  1133. }
  1134. }
  1135. function add_to_blinklist()
  1136. {
  1137. if ($this->get_permalink())
  1138. {
  1139. $url = 'http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=' . rawurlencode($this->get_permalink());
  1140. if ($this->get_title())
  1141. {
  1142. $url .= '&amp;Title=' . rawurlencode($this->get_title());
  1143. }
  1144. return $url;
  1145. }
  1146. else
  1147. {
  1148. return false;
  1149. }
  1150. }
  1151. function add_to_blogmarks()
  1152. {
  1153. if ($this->get_permalink())
  1154. {
  1155. $url = 'http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=' . rawurlencode($this->get_permalink());
  1156. if ($this->get_title())
  1157. {
  1158. $url .= '&amp;title=' . rawurlencode($this->get_title());
  1159. }
  1160. return $url;
  1161. }
  1162. else
  1163. {
  1164. return false;
  1165. }
  1166. }
  1167. function add_to_delicious()
  1168. {
  1169. if ($this->get_permalink())
  1170. {
  1171. $url = 'http://del.icio.us/post/?v=3&amp;url=' . rawurlencode($this->get_permalink());
  1172. if ($this->get_title())
  1173. {
  1174. $url .= '&amp;title=' . rawurlencode($this->get_title());
  1175. }
  1176. return $url;
  1177. }
  1178. else
  1179. {
  1180. return false;
  1181. }
  1182. }
  1183. function add_to_digg()
  1184. {
  1185. if ($this->get_permalink())
  1186. {
  1187. return 'http://digg.com/submit?phase=2&amp;URL=' . rawurlencode($this->get_permalink());
  1188. }
  1189. else
  1190. {
  1191. return false;
  1192. }
  1193. }
  1194. function add_to_furl()
  1195. {
  1196. if ($this->get_permalink())
  1197. {
  1198. $url = 'http://www.furl.net/storeIt.jsp?u=' . rawurlencode($this->get_permalink());
  1199. if ($this->get_title())
  1200. {
  1201. $url .= '&amp;t=' . rawurlencode($this->get_title());
  1202. }
  1203. return $url;
  1204. }
  1205. else
  1206. {
  1207. return false;
  1208. }
  1209. }
  1210. function add_to_magnolia()
  1211. {
  1212. if ($this->get_permalink())
  1213. {
  1214. $url = 'http://ma.gnolia.com/bookmarklet/add?url=' . rawurlencode($this->get_permalink());
  1215. if ($this->get_title())
  1216. {
  1217. $url .= '&amp;title=' . rawurlencode($this->get_title());
  1218. }
  1219. return $url;
  1220. }
  1221. else
  1222. {
  1223. return false;
  1224. }
  1225. }
  1226. function add_to_myweb20()
  1227. {
  1228. if ($this->get_permalink())
  1229. {
  1230. $url = 'http://myweb2.search.yahoo.com/myresults/bookmarklet?u=' . rawurlencode($this->get_permalink());
  1231. if ($this->get_title())
  1232. {
  1233. $url .= '&amp;t=' . rawurlencode($this->get_title());
  1234. }
  1235. return $url;
  1236. }
  1237. else
  1238. {
  1239. return false;
  1240. }
  1241. }
  1242. function add_to_newsvine()
  1243. {
  1244. if ($this->get_permalink())
  1245. {
  1246. $url = 'http://www.newsvine.com/_wine/save?u=' . rawurlencode($this->get_permalink());
  1247. if ($this->get_title())
  1248. {
  1249. $url .= '&amp;h=' . rawurlencode($this->get_title());
  1250. }
  1251. return $url;
  1252. }
  1253. else
  1254. {
  1255. return false;
  1256. }
  1257. }
  1258. function add_to_reddit()
  1259. {
  1260. if ($this->get_permalink())
  1261. {
  1262. $url = 'http://reddit.com/submit?url=' . rawurlencode($this->get_permalink());
  1263. if ($this->get_title())
  1264. {
  1265. $url .= '&amp;title=' . rawurlencode($this->get_title());
  1266. }
  1267. return $url;
  1268. }
  1269. else
  1270. {
  1271. return false;
  1272. }
  1273. }
  1274. function add_to_segnalo()
  1275. {
  1276. if ($this->get_permalink())
  1277. {
  1278. $url = 'http://segnalo.com/post.html.php?url=' . rawurlencode($this->get_permalink());
  1279. if ($this->get_title())
  1280. {
  1281. $url .= '&amp;title=' . rawurlencode($this->get_title());
  1282. }
  1283. return $url;
  1284. }
  1285. else
  1286. {
  1287. return false;
  1288. }
  1289. }
  1290. function add_to_simpy()
  1291. {
  1292. if ($this->get_permalink())
  1293. {
  1294. $url = 'http://www.simpy.com/simpy/LinkAdd.do?href=' . rawurlencode($this->get_permalink());
  1295. if ($this->get_title())
  1296. {
  1297. $url .= '&amp;title=' . rawurlencode($this->get_title());
  1298. }
  1299. return $url;
  1300. }
  1301. else
  1302. {
  1303. return false;
  1304. }
  1305. }
  1306. function add_to_smarking()
  1307. {
  1308. if ($this->get_permalink())
  1309. {
  1310. return 'http://smarking.com/editbookmark/?url=' . rawurlencode($this->get_permalink());
  1311. }
  1312. else
  1313. {
  1314. return false;
  1315. }
  1316. }
  1317. function add_to_spurl()
  1318. {
  1319. if ($this->get_permalink())
  1320. {
  1321. $url = 'http://www.spurl.net/spurl.php?v=3&amp;url=' . rawurlencode($this->get_permalink());
  1322. if ($this->get_title())
  1323. {
  1324. $url .= '&amp;title=' . rawurlencode($this->get_title());
  1325. }
  1326. return $url;
  1327. }
  1328. else
  1329. {
  1330. return false;
  1331. }
  1332. }
  1333. function add_to_wists()
  1334. {
  1335. if ($this->get_permalink())
  1336. {
  1337. $url = 'http://wists.com/r.php?c=&amp;r=' . rawurlencode($this->get_permalink());
  1338. if ($this->get_title())
  1339. {
  1340. $url .= '&amp;title=' . rawurlencode($this->get_title());
  1341. }
  1342. return $url;
  1343. }
  1344. else
  1345. {
  1346. return false;
  1347. }
  1348. }
  1349. function search_technorati()
  1350. {
  1351. if ($this->get_permalink())
  1352. {
  1353. return 'http://www.technorati.com/search/' . rawurlencode($this->get_permalink());
  1354. }
  1355. else
  1356. {
  1357. return false;
  1358. }
  1359. }
  1360. }
  1361. class SimplePie_Author
  1362. {
  1363. var $name;
  1364. var $link;
  1365. var $email;
  1366. // Constructor, used to input the data
  1367. function SimplePie_Author($name, $link, $email)
  1368. {
  1369. $this->name = $name;
  1370. $this->link = $link;
  1371. $this->email = $email;
  1372. }
  1373. function get_name()
  1374. {
  1375. if (!empty($this->name))
  1376. {
  1377. return $this->name;
  1378. }
  1379. else
  1380. {
  1381. return false;
  1382. }
  1383. }
  1384. function get_link()
  1385. {
  1386. if (!empty($this->link))
  1387. {
  1388. return $this->link;
  1389. }
  1390. else
  1391. {
  1392. return false;
  1393. }
  1394. }
  1395. function get_email()
  1396. {
  1397. if (!empty($this->email))
  1398. {
  1399. return $this->email;
  1400. }
  1401. else
  1402. {
  1403. return false;
  1404. }
  1405. }
  1406. }
  1407. class SimplePie_Enclosure
  1408. {
  1409. var $link;
  1410. var $type;
  1411. var $length;
  1412. // Constructor, used to input the data
  1413. function SimplePie_Enclosure($link, $type, $length)
  1414. {
  1415. $this->link = $link;
  1416. $this->type = $type;
  1417. $this->length = $length;
  1418. }
  1419. function get_link()
  1420. {
  1421. if (!empty($this->link))
  1422. {
  1423. return $this->link;
  1424. }
  1425. else
  1426. {
  1427. return false;
  1428. }
  1429. }
  1430. function get_extension()
  1431. {
  1432. if (!empty($this->link))
  1433. {
  1434. return pathinfo($this->link, PATHINFO_EXTENSION);
  1435. }
  1436. else
  1437. {
  1438. return false;
  1439. }
  1440. }
  1441. function get_type()
  1442. {
  1443. if (!empty($this->type))
  1444. {
  1445. return $this->type;
  1446. }
  1447. else
  1448. {
  1449. return false;
  1450. }
  1451. }
  1452. function get_length()
  1453. {
  1454. if (!empty($this->length))
  1455. {
  1456. return $this->length;
  1457. }
  1458. else
  1459. {
  1460. return false;
  1461. }
  1462. }
  1463. function get_size()
  1464. {
  1465. $length = $this->get_length();
  1466. if (!empty($length))
  1467. {
  1468. return round($length/1048576, 2);
  1469. }
  1470. else
  1471. {
  1472. return false;
  1473. }
  1474. }
  1475. function embed($options)
  1476. {
  1477. // Set up defaults
  1478. $audio = '';
  1479. $video = '';
  1480. $alt = '';
  1481. $altclass = '';
  1482. $loop = 'false';
  1483. $width = 'auto';
  1484. $height = 'auto';
  1485. $bgcolor = '#ffffff';
  1486. // Process options and reassign values as necessary
  1487. if (is_array($options))
  1488. {
  1489. extract($options);
  1490. }
  1491. else
  1492. {
  1493. $options = explode(',', $options);
  1494. foreach($options as $option)
  1495. {
  1496. $opt = explode(':', $option, 2);
  1497. if (isset($opt[0], $opt[1]))
  1498. {
  1499. $opt[0] = trim($opt[0]);
  1500. $opt[1] = trim($opt[1]);
  1501. switch ($opt[0])
  1502. {
  1503. case 'audio':
  1504. $audio = $opt[1];
  1505. break;
  1506. case 'video':
  1507. $video = $opt[1];
  1508. break;
  1509. case 'alt':
  1510. $alt = $opt[1];
  1511. break;
  1512. case 'altclass':
  1513. $altclass = $opt[1];
  1514. break;
  1515. case 'loop':
  1516. $loop = $opt[1];
  1517. break;
  1518. case 'width':
  1519. $width = $opt[1];
  1520. break;
  1521. case 'height':
  1522. $height = $opt[1];
  1523. break;
  1524. case 'bgcolor':
  1525. $bgcolor = $opt[1];
  1526. break;
  1527. }
  1528. }
  1529. }
  1530. }
  1531. $type = strtolower($this->get_type());
  1532. // If we encounter an unsupported mime-type, check the file extension and guess intelligently.
  1533. 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')))
  1534. {
  1535. switch (strtolower($this->get_extension()))
  1536. {
  1537. // Audio mime-types
  1538. case 'aac':
  1539. case 'adts':
  1540. $type = 'audio/acc';
  1541. break;
  1542. case 'aif':
  1543. case 'aifc':
  1544. case 'aiff':
  1545. case 'cdda':
  1546. $type = 'audio/aiff';
  1547. break;
  1548. case 'bwf':
  1549. $type = 'audio/wav';
  1550. break;
  1551. case 'kar':
  1552. case 'mid':
  1553. case 'midi':
  1554. case 'smf':
  1555. $type = 'audio/midi';
  1556. break;
  1557. case 'm4a':
  1558. $type = 'audio/x-m4a';
  1559. break;
  1560. case 'mp3':
  1561. case 'swa':
  1562. $type = 'audio/mp3';
  1563. break;
  1564. case 'wav':
  1565. $type = 'audio/wav';
  1566. break;
  1567. case 'wax':
  1568. $type = 'audio/x-ms-wax';
  1569. break;
  1570. case 'wma':
  1571. $type = 'audio/x-ms-wma';
  1572. break;
  1573. // Video mime-types
  1574. case '3gp':
  1575. case '3gpp':
  1576. $type = 'video/3gpp';
  1577. break;
  1578. case '3g2':
  1579. case '3gp2':
  1580. $type = 'video/3gpp2';
  1581. break;
  1582. case 'asf':
  1583. $type = 'video/x-ms-asf';
  1584. break;
  1585. case 'm1a':
  1586. case 'm1s':
  1587. case 'm1v':
  1588. case 'm15':
  1589. case 'm75':
  1590. case 'mp2':
  1591. case 'mpa':
  1592. case 'mpeg':
  1593. case 'mpg':
  1594. case 'mpm':
  1595. case 'mpv':
  1596. $type = 'video/mpeg';
  1597. break;
  1598. case 'm4v':
  1599. $type = 'video/x-m4v';
  1600. break;
  1601. case 'mov':
  1602. case 'qt':
  1603. $type = 'video/quicktime';
  1604. break;
  1605. case 'mp4':
  1606. case 'mpg4':
  1607. $type = 'video/mp4';
  1608. break;
  1609. case 'sdv':
  1610. $type = 'video/sd-video';
  1611. break;
  1612. case 'wm':
  1613. $type = 'video/x-ms-wm';
  1614. break;
  1615. case 'wmv':
  1616. $type = 'video/x-ms-wmv';
  1617. break;
  1618. case 'wvx':
  1619. $type = 'video/x-ms-wvx';
  1620. break;
  1621. // Flash mime-types
  1622. case 'spl':
  1623. $type = 'application/futuresplash';
  1624. break;
  1625. case 'swf':
  1626. $type = 'application/x-shockwave-flash';
  1627. break;
  1628. }
  1629. }
  1630. $mime = explode('/', $type, 2);
  1631. $mime = $mime[0];
  1632. // Process values for 'auto'
  1633. if ($width == 'auto')
  1634. {
  1635. if ($mime == 'video')
  1636. {
  1637. $width = '320';
  1638. }
  1639. else
  1640. {
  1641. $width = '100%';
  1642. }
  1643. }
  1644. if ($height == 'auto')
  1645. {
  1646. if ($mime == 'audio')
  1647. {
  1648. $height = 0;
  1649. }
  1650. else if ($mime == 'video')
  1651. {
  1652. $height = 240;
  1653. }
  1654. else
  1655. {
  1656. $height = 256;
  1657. }
  1658. }
  1659. // Set proper placeholder value
  1660. if ($mime == 'audio')
  1661. {
  1662. $placeholder = $audio;
  1663. }
  1664. else if ($mime == 'video')
  1665. {
  1666. $placeholder = $video;
  1667. }
  1668. // Make sure the JS library is included
  1669. // (I know it'll be included multiple times, but I can't think of a better way to do this automatically)
  1670. $embed = '<script type="text/javascript" src="?js"></script>';
  1671. // Odeo Feed MP3's
  1672. if (substr(strtolower($this->get_link()), 0, 15) == 'http://odeo.com') {
  1673. $embed .= '<script type="text/javascript">embed_odeo("' . $this->get_link() . '");</script>';
  1674. }
  1675. // QuickTime 7 file types. Need to test with QuickTime 6.
  1676. 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')))
  1677. {
  1678. $height += 16;
  1679. $embed .= "<script type='text/javascript'>embed_quicktime('$type', '$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$placeholder', '$loop');</script>";
  1680. }
  1681. // Flash
  1682. else if (in_array($type, array('application/x-shockwave-flash', 'application/futuresplash')))
  1683. {
  1684. $embed .= "<script type='text/javascript'>embed_flash('$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$loop', '$type');</script>";
  1685. }
  1686. // Windows Media
  1687. 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')))
  1688. {
  1689. $height += 45;
  1690. $embed .= "<script type='text/javascript'>embed_wmedia('$width', '$height', '" . $this->get_link() . "');</script>";
  1691. }
  1692. // Everything else
  1693. else $embed .= '<a href="' . $this->get_link() . '" class="' . $altclass . '">' . $alt . '</a>';
  1694. return $embed;
  1695. }
  1696. }
  1697. class SimplePie_File
  1698. {
  1699. var $url;
  1700. var $useragent;
  1701. var $success = true;
  1702. var $headers = array();
  1703. var $body;
  1704. var $fp;
  1705. var $redirects = 0;
  1706. var $error;
  1707. var $method;
  1708. function SimplePie_File($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null)
  1709. {
  1710. if (class_exists('idna_convert'))
  1711. {
  1712. $idn = new idna_convert;
  1713. $url = $idn->encode($url);
  1714. }
  1715. $this->url = $url;
  1716. $this->useragent = $useragent;
  1717. if (preg_match('/^http(s)?:\/\//i', $url))
  1718. {
  1719. if (empty($useragent))
  1720. {
  1721. $useragent = ini_get('user_agent');
  1722. $this->useragent = $useragent;
  1723. }
  1724. if (!is_array($headers))
  1725. {
  1726. $headers = array();
  1727. }
  1728. if (extension_loaded('curl') && version_compare(SimplePie_Misc::get_curl_version(), '7.10', '>='))
  1729. {
  1730. $fp = curl_init();
  1731. $headers2 = array();
  1732. foreach ($headers as $key => $value)
  1733. {
  1734. $headers2[] = "$key: $value";
  1735. }
  1736. curl_setopt($fp, CURLOPT_ENCODING, '');
  1737. curl_setopt($fp, CURLOPT_URL, $url);
  1738. curl_setopt($fp, CURLOPT_HEADER, 1);
  1739. curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);
  1740. curl_setopt($fp, CURLOPT_TIMEOUT, $timeout);
  1741. curl_setopt($fp, CURLOPT_REFERER, $url);
  1742. curl_setopt($fp, CURLOPT_USERAGENT, $useragent);
  1743. curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1);
  1744. curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects);
  1745. curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);
  1746. $this->headers = trim(curl_exec($fp));
  1747. if (curl_errno($fp))
  1748. {
  1749. $this->error = curl_error($fp);
  1750. $this->success = false;
  1751. return false;
  1752. }
  1753. else
  1754. {
  1755. $info = curl_getinfo($fp);
  1756. $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 2);
  1757. $this->body = array_pop($this->headers);
  1758. $this->headers = array_pop($this->headers);
  1759. $this->headers = $this->parse_headers($this->headers);
  1760. $this->method = 'curl';
  1761. }
  1762. }
  1763. else
  1764. {
  1765. $url_parts = parse_url($url);
  1766. if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) == 'https')
  1767. {
  1768. $url_parts['host'] = "ssl://$url_parts[host]";
  1769. $url_parts['port'] = 443;
  1770. }
  1771. if (!isset($url_parts['port']))
  1772. {
  1773. $url_parts['port'] = 80;
  1774. }
  1775. $this->fp = fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout);
  1776. if (!$this->fp)
  1777. {
  1778. $this->error = $errstr;
  1779. $this->success = false;
  1780. return false;
  1781. }
  1782. else
  1783. {
  1784. $this->method = 'fsockopen';
  1785. stream_set_timeout($this->fp, $timeout);
  1786. $get = (isset($url_parts['query'])) ? "$url_parts[path]?$url_parts[query]" : $url_parts['path'];
  1787. $out = "GET $get HTTP/1.0\r\n";
  1788. $out .= "Host: $url_parts[host]\r\n";
  1789. $out .= "User-Agent: $useragent\r\n";
  1790. if (extension_loaded('zlib') && function_exists('gzinflate'))
  1791. {
  1792. $out .= "Accept-Encoding: gzip,deflate\r\n";
  1793. }
  1794. if (!empty($url_parts['user']) && !empty($url_parts['pass']))
  1795. {
  1796. $out .= "Authorization: Basic " . base64_encode("$url_parts[user]:$url_parts[pass]") . "\r\n";
  1797. }
  1798. foreach ($headers as $key => $value)
  1799. {
  1800. $out .= "$key: $value\r\n";
  1801. }
  1802. $out .= "Connection: Close\r\n\r\n";
  1803. fwrite($this->fp, $out);
  1804. $info = stream_get_meta_data($this->fp);
  1805. $data = '';
  1806. while (strpos($data, "\r\n\r\n") === false && $info['timed_out'] === false)
  1807. {
  1808. $data .= fgets($this->fp, 128);
  1809. $info = stream_get_meta_data($this->fp);
  1810. }
  1811. if ($info['timed_out'] === false)
  1812. {
  1813. $this->headers = $this->parse_headers($data);
  1814. 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)
  1815. {
  1816. $this->redirects++;
  1817. return $this->__construct($this->headers['location'], $timeout, $redirects, $headers, $useragent);
  1818. }
  1819. }
  1820. else
  1821. {
  1822. $this->close();
  1823. $this->error = 'Timeout';
  1824. $this->success = false;
  1825. return false;
  1826. }
  1827. }
  1828. }
  1829. return $this->headers['status']['code'];
  1830. }
  1831. else
  1832. {
  1833. if ($this->fp = fopen($url, 'r'))
  1834. {
  1835. $this->method = 'fopen';
  1836. return true;
  1837. }
  1838. else
  1839. {
  1840. $this->error = 'Could not open the file';
  1841. $this->success = false;
  1842. return false;
  1843. }
  1844. }
  1845. }
  1846. function headers()
  1847. {
  1848. return $this->headers;
  1849. }
  1850. function body()
  1851. {
  1852. if (is_null($this->body))
  1853. {
  1854. if ($this->fp)
  1855. {
  1856. $this->body = '';
  1857. while (!feof($this->fp))
  1858. {
  1859. $this->body .= fread($this->fp, 1024);
  1860. }
  1861. $this->body = trim($this->body);
  1862. if ($this->method == 'fsockopen' && !empty($this->headers['content-encoding']) && $this->headers['content-encoding'] == 'gzip')
  1863. {
  1864. $this->body = substr($this->body, 10);
  1865. $this->body = gzinflate($this->body);
  1866. }
  1867. $this->close();
  1868. }
  1869. else
  1870. {
  1871. return false;
  1872. }
  1873. }
  1874. return $this->body;
  1875. }
  1876. function close()
  1877. {
  1878. if (!is_null($this->fp))
  1879. {
  1880. if (fclose($this->fp))
  1881. {
  1882. $this->fp = null;
  1883. return true;
  1884. }
  1885. else
  1886. {
  1887. return false;
  1888. }
  1889. }
  1890. else
  1891. {
  1892. return false;
  1893. }
  1894. }
  1895. function parse_headers($headers)
  1896. {
  1897. $headers = explode("\r\n", trim($headers));
  1898. $status = array_shift($headers);
  1899. foreach ($headers as $header)
  1900. {
  1901. $data = explode(':', $header, 2);
  1902. $head[strtolower(trim($data[0]))] = trim($data[1]);
  1903. }
  1904. if (preg_match('/HTTP\/[0-9\.]+ ([0-9]+)(.*)$/i', $status, $matches))
  1905. {
  1906. if (isset($head['status']))
  1907. {
  1908. unset($head['status']);
  1909. }
  1910. $head['status']['code'] = $matches[1];
  1911. $head['status']['name'] = trim($matches[2]);
  1912. }
  1913. return $head;
  1914. }
  1915. }
  1916. class SimplePie_Cache
  1917. {
  1918. var $location;
  1919. var $filename;
  1920. var $extension;
  1921. var $name;
  1922. function SimplePie_Cache($location, $filename, $extension)
  1923. {
  1924. $this->location = $location;
  1925. $this->filename = rawurlencode($filename);
  1926. $this->extension = rawurlencode($extension);
  1927. $this->name = "$location/$this->filename.$this->extension";
  1928. }
  1929. function save($data)
  1930. {
  1931. if (file_exists($this->name) && is_writeable($this->name) || file_exists($this->location) && is_writeable($this->location))
  1932. {
  1933. $fp = fopen($this->name, 'w');
  1934. if ($fp)
  1935. {
  1936. fwrite($fp, serialize($data));
  1937. fclose($fp);
  1938. return true;
  1939. }
  1940. }
  1941. return false;
  1942. }
  1943. function load()
  1944. {
  1945. if (file_exists($this->name) && is_readable($this->name))
  1946. {
  1947. return unserialize(file_get_contents($this->name));
  1948. }
  1949. return false;
  1950. }
  1951. function atime()
  1952. {
  1953. if (file_exists($this->name))
  1954. {
  1955. return fileatime($this->name);
  1956. }
  1957. return false;
  1958. }
  1959. function ctime()
  1960. {
  1961. if (file_exists($this->name))
  1962. {
  1963. return filectime($this->name);
  1964. }
  1965. return false;
  1966. }
  1967. function mtime()
  1968. {
  1969. if (file_exists($this->name))
  1970. {
  1971. return filemtime($this->name);
  1972. }
  1973. return false;
  1974. }
  1975. function touch()
  1976. {
  1977. if (file_exists($this->name))
  1978. {
  1979. return touch($this->name);
  1980. }
  1981. return false;
  1982. }
  1983. function unlink()
  1984. {
  1985. if (file_exists($this->name))
  1986. {
  1987. return unlink($this->name);
  1988. }
  1989. return false;
  1990. }
  1991. function clear($expire)
  1992. {
  1993. foreach (glob("$this->location/*.$this->extension") as $file)
  1994. {
  1995. if (time() - filemtime($file) > $expire)
  1996. {
  1997. unlink($file);
  1998. }
  1999. }
  2000. }
  2001. }
  2002. class SimplePie_Misc
  2003. {
  2004. function absolutize_url($relative, $base)
  2005. {
  2006. $relative = trim($relative);
  2007. $base = trim($base);
  2008. if (!empty($relative))
  2009. {
  2010. $relative = SimplePie_Misc::parse_url($relative, false);
  2011. $relative = array('scheme' => $relative[2], 'authority' => $relative[3], 'path' => $relative[5], 'query' => $relative[7], 'fragment' => $relative[9]);
  2012. if (!empty($relative['scheme']))
  2013. {
  2014. $target = $relative;
  2015. }
  2016. else if (!empty($base))
  2017. {
  2018. $base = SimplePie_Misc::parse_url($base, false);
  2019. $base = array('scheme' => $base[2], 'authority' => $base[3], 'path' => $base[5], 'query' => $base[7], 'fragment' => $base[9]);
  2020. $target['scheme'] = $base['scheme'];
  2021. if (!empty($relative['authority']))
  2022. {
  2023. $target = array_merge($relative, $target);
  2024. }
  2025. else
  2026. {
  2027. $target['authority'] = $base['authority'];
  2028. if (!empty($relative['path']))
  2029. {
  2030. if (strpos($relative['path'], '/') === 0)
  2031. {
  2032. $target['path'] = $relative['path'];
  2033. }
  2034. else
  2035. {
  2036. if (!empty($base['path']))
  2037. {
  2038. $target['path'] = dirname("$base[path].") . '/' . $relative['path'];
  2039. }
  2040. else
  2041. {
  2042. $target['path'] = '/' . $relative['path'];
  2043. }
  2044. }
  2045. if (!empty($relative['query']))
  2046. {
  2047. $target['query'] = $relative['query'];
  2048. }
  2049. $input = $target['path'];
  2050. $target['path'] = '';
  2051. while (!empty($input))
  2052. {
  2053. if (strpos($input, '../') === 0)
  2054. {
  2055. $input = substr($input, 3);
  2056. }
  2057. else if (strpos($input, './') === 0)
  2058. {
  2059. $input = substr($input, 2);
  2060. }
  2061. else if (strpos($input, '/./') === 0)
  2062. {
  2063. $input = substr_replace($input, '/', 0, 3);
  2064. }
  2065. else if (strpos($input, '/.') === 0 && SimplePie_Misc::strendpos($input, '/.') === 0)
  2066. {
  2067. $input = substr_replace($input, '/', -2);
  2068. }
  2069. else if (strpos($input, '/../') === 0)
  2070. {
  2071. $input = substr_replace($input, '/', 0, 4);
  2072. $target['path'] = preg_replace('/(\/)?([^\/]+)$/U', '', $target['path']);
  2073. }
  2074. else if (strpos($input, '/..') === 0 && SimplePie_Misc::strendpos($input, '/..') === 0)
  2075. {
  2076. $input = substr_replace($input, '/', 0, 3);
  2077. $target['path'] = preg_replace('/(\/)?([^\/]+)$/U', '', $target['path']);
  2078. }
  2079. else if ($input == '.' || $input == '..')
  2080. {
  2081. $input = '';
  2082. }
  2083. else
  2084. {
  2085. if (preg_match('/^(.+)(\/|$)/U', $input, $match))
  2086. {
  2087. $target['path'] .= $match[1];
  2088. $input = substr_replace($input, '', 0, strlen($match[1]));
  2089. }
  2090. }
  2091. }
  2092. }
  2093. else
  2094. {
  2095. if (!empty($base['path']))
  2096. {
  2097. $target['path'] = $base['path'];
  2098. }
  2099. else
  2100. {
  2101. $target['path'] = '/';
  2102. }
  2103. if (!empty($relative['query']))
  2104. {
  2105. $target['query'] = $relative['query'];
  2106. }
  2107. else if (!empty($base['query']))
  2108. {
  2109. $target['query'] = $base['query'];
  2110. }
  2111. }
  2112. }
  2113. if (!empty($relative['fragment']))
  2114. {
  2115. $target['fragment'] = $relative['fragment'];
  2116. }
  2117. }
  2118. else
  2119. {
  2120. return false;
  2121. }
  2122. $return = "$target[scheme]:$target[authority]$target[path]";
  2123. if (!empty($target['query']))
  2124. {
  2125. $return .= "?$target[query]";
  2126. }
  2127. if (!empty($target['fragment']))
  2128. {
  2129. $return .= "#$target[fragment]";
  2130. }
  2131. }
  2132. else
  2133. {
  2134. $return = $base;
  2135. }
  2136. return $return;
  2137. }
  2138. function strendpos($haystack, $needle)
  2139. {
  2140. return strlen($haystack) - strpos($haystack, $needle) - strlen($needle);
  2141. }
  2142. function get_element($realname, $string)
  2143. {
  2144. $return = array();
  2145. $nam

Large files files are truncated, but you can click here to view the full file