/lib/simplepie/simplepie.inc
PHP | 5449 lines | 4979 code | 345 blank | 125 comment | 677 complexity | 7500722bf0d1fd3d854e277dabdd4d36 MD5 | raw file
Possible License(s): LGPL-2.1
Large files files are truncated, but you can click here to view the full file
- <?php
- /****************************************************
- SIMPLEPIE
- A PHP-Based RSS and Atom Feed Framework
- Takes the hard work out of managing a complete RSS/Atom solution.
- Version: "Lemon Meringue"
- Updated: 24 November 2006
- Copyright: 2004-2006 Ryan Parman, Geoffrey Sneddon
- http://simplepie.org
- *****************************************************
- LICENSE:
- GNU Lesser General Public License 2.1 (LGPL)
- http://creativecommons.org/licenses/LGPL/2.1/
- *****************************************************
- Please submit all bug reports and feature requests to the SimplePie forums.
- http://simplepie.org/support/
- ****************************************************/
- class SimplePie
- {
- // SimplePie Info
- var $name = 'SimplePie';
- var $version = '1.0 b3.2';
- var $build = '20061124';
- var $url = 'http://simplepie.org/';
- var $useragent;
- var $linkback;
-
- // Other objects, instances created here so we can set options on them
- var $sanitize;
-
- // Options
- var $rss_url;
- var $file;
- var $timeout = 10;
- var $xml_dump = false;
- var $enable_cache = true;
- var $max_minutes = 60;
- var $cache_location = './cache';
- var $order_by_date = true;
- var $input_encoding = false;
- var $cache_class = 'SimplePie_Cache';
- var $locator_class = 'SimplePie_Locator';
- var $parser_class = 'SimplePie_Parser';
- var $file_class = 'SimplePie_File';
- var $force_fsockopen = false;
- var $cache_name_type = 'sha1';
-
- // Misc. variables
- var $data;
- var $error;
-
- function SimplePie($feed_url = null, $cache_location = null, $cache_max_minutes = null)
- {
- // Couple of variables built up from other variables
- $this->useragent = $this->name . '/' . $this->version . ' (Feed Parser; ' . $this->url . '; Allow like Gecko) Build/' . $this->build;
- $this->linkback = '<a href="' . $this->url . '" title="' . $this->name . ' ' . $this->version . '">' . $this->name . '</a>';
-
- // Other objects, instances created here so we can set options on them
- $this->sanitize = new SimplePie_Sanitize;
-
- // Set options if they're passed to the constructor
- if (!is_null($feed_url))
- {
- $this->feed_url($feed_url);
- }
- if (!is_null($cache_location))
- {
- $this->cache_location($cache_location);
- }
- if (!is_null($cache_max_minutes))
- {
- $this->cache_max_minutes($cache_max_minutes);
- }
- // If we've passed an xmldump variable in the URL, snap into XMLdump mode
- if (isset($_GET['xmldump']))
- {
- $this->enable_xmldump(true);
- }
-
- // Only init the script if we're passed a feed URL
- if (!is_null($feed_url))
- {
- return $this->init();
- }
- }
-
- function feed_url($url)
- {
- $this->rss_url = SimplePie_Misc::fix_protocol($url, 1);
- }
-
- function set_file(&$file)
- {
- if (is_a($file, 'SimplePie_File'))
- {
- $this->rss_url = $file->url;
- $this->file =& $file;
- }
- }
-
- function set_timeout($timeout = 10)
- {
- $this->timeout = (int) $timeout;
- }
-
- function set_raw_data($data)
- {
- $this->raw_data = trim((string) $data);
- }
-
- function enable_xmldump($enable = false)
- {
- $this->xml_dump = (bool) $enable;
- }
-
- function enable_caching($enable = true)
- {
- $this->enable_cache = (bool) $enable;
- }
-
- function cache_max_minutes($minutes = 60)
- {
- $this->max_minutes = (float) $minutes;
- }
-
- function cache_location($location = './cache')
- {
- $this->cache_location = (string) $location;
- }
-
- function order_by_date($enable = true)
- {
- $this->order_by_date = (bool) $enable;
- }
-
- function input_encoding($encoding = false)
- {
- if ($encoding)
- {
- $this->input_encoding = (string) $encoding;
- }
- else
- {
- $this->input_encoding = false;
- }
- }
-
- function set_cache_class($class = 'SimplePie_Cache')
- {
- if (SimplePie_Misc::is_a_class($class, 'SimplePie_Cache'))
- {
- $this->cache_class = $class;
- return true;
- }
- return false;
- }
-
- function set_locator_class($class = 'SimplePie_Locator')
- {
- if (SimplePie_Misc::is_a_class($class, 'SimplePie_Locator'))
- {
- $this->locator_class = $class;
- return true;
- }
- return false;
- }
-
- function set_parser_class($class = 'SimplePie_Parser')
- {
- if (SimplePie_Misc::is_a_class($class, 'SimplePie_Parser'))
- {
- $this->parser_class = $class;
- return true;
- }
- return false;
- }
-
- function set_file_class($class = 'SimplePie_File')
- {
- if (SimplePie_Misc::is_a_class($class, 'SimplePie_File'))
- {
- $this->file_class = $class;
- return true;
- }
- return false;
- }
-
- function set_sanitize_class($object = 'SimplePie_Sanitize')
- {
- if (class_exists($object))
- {
- $this->sanitize = new $object;
- return true;
- }
- return false;
- }
-
- function set_useragent($ua)
- {
- $this->useragent = (string) $ua;
- }
-
- function force_fsockopen($enable = false)
- {
- $this->force_fsockopen = (bool) $enable;
- }
-
- function set_cache_name_type($type = 'sha1')
- {
- $type = strtolower(trim($type));
- switch ($type)
- {
- case 'crc32':
- $this->cache_name_type = 'crc32';
- break;
-
- case 'md5':
- $this->cache_name_type = 'md5';
- break;
-
- case 'rawurlencode':
- $this->cache_name_type = 'rawurlencode';
- break;
-
- case 'urlencode':
- $this->cache_name_type = 'urlencode';
- break;
-
- default:
- $this->cache_name_type = 'sha1';
- break;
- }
- }
-
- function bypass_image_hotlink($get = false)
- {
- $this->sanitize->bypass_image_hotlink($get);
- }
-
- function bypass_image_hotlink_page($page = false)
- {
- $this->sanitize->bypass_image_hotlink_page($page);
- }
-
- function replace_headers($enable = false)
- {
- $this->sanitize->replace_headers($enable);
- }
-
- function remove_div($enable = true)
- {
- $this->sanitize->remove_div($enable);
- }
-
- function strip_ads($enable = false)
- {
- $this->sanitize->strip_ads($enable);
- }
-
- 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)
- {
- $this->sanitize->strip_htmltags($tags);
- if (!is_null($encode))
- {
- $this->sanitize->encode_instead_of_strip($tags);
- }
- }
-
- function encode_instead_of_strip($enable = true)
- {
- $this->sanitize->encode_instead_of_strip($enable);
- }
-
- function strip_attributes($attribs = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur'))
- {
- $this->sanitize->strip_attributes($attribs);
- }
-
- function output_encoding($encoding = 'UTF-8')
- {
- $this->sanitize->output_encoding($encoding);
- }
-
- function set_item_class($class = 'SimplePie_Item')
- {
- return $this->sanitize->set_item_class($class);
- }
-
- function set_author_class($class = 'SimplePie_Author')
- {
- return $this->sanitize->set_author_class($class);
- }
-
- function set_enclosure_class($class = 'SimplePie_Enclosure')
- {
- return $this->sanitize->set_enclosure_class($class);
- }
-
- function init()
- {
- 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'))
- {
- return false;
- }
- if ($this->sanitize->bypass_image_hotlink && !empty($_GET[$this->sanitize->bypass_image_hotlink]))
- {
- if (get_magic_quotes_gpc())
- {
- $_GET[$this->sanitize->bypass_image_hotlink] = stripslashes($_GET[$this->sanitize->bypass_image_hotlink]);
- }
- SimplePie_Misc::display_file($_GET[$this->sanitize->bypass_image_hotlink], 10, $this->useragent);
- }
-
- if (isset($_GET['js']))
- {
- $embed = <<<EOT
- function embed_odeo(link) {
- 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>');
- }
- function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
- if (placeholder != '') {
- 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>');
- }
- else {
- 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>');
- }
- }
- function embed_flash(bgcolor, width, height, link, loop, type) {
- 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>');
- }
- function embed_wmedia(width, height, link) {
- document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
- }
- EOT;
- if (function_exists('ob_gzhandler'))
- {
- ob_start('ob_gzhandler');
- }
- header('Content-type: text/javascript; charset: UTF-8');
- header('Cache-Control: must-revalidate');
- header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 86400) . ' GMT');
- echo $embed;
- exit;
- }
-
- if (!empty($this->rss_url) || !empty($this->raw_data))
- {
- $this->data = array();
- $cache = false;
-
- if (!empty($this->rss_url))
- {
- // Decide whether to enable caching
- if ($this->enable_cache && preg_match('/^http(s)?:\/\//i', $this->rss_url))
- {
- $cache = new $this->cache_class($this->cache_location, call_user_func($this->cache_name_type, $this->rss_url), 'spc');
- }
- // If it's enabled and we don't want an XML dump, use the cache
- if ($cache && !$this->xml_dump)
- {
- // Load the Cache
- $this->data = $cache->load();
- if (!empty($this->data))
- {
- // If we've hit a collision just rerun it with caching disabled
- if (isset($this->data['url']) && $this->data['url'] != $this->rss_url)
- {
- $cache = false;
- }
- // If we've got a feed_url stored (if the page isn't actually a feed, or is a redirect) use that URL
- else if (!empty($this->data['feed_url']))
- {
- if ($this->data['feed_url'] == $this->data['url'])
- {
- $cache->unlink();
- }
- else
- {
- $this->feed_url($this->data['feed_url']);
- return $this->init();
- }
- }
- // If the cache is new enough
- else if ($cache->mtime() + $this->max_minutes * 60 < time())
- {
- // If we have last-modified and/or etag set
- if (!empty($this->data['last-modified']) || !empty($this->data['etag']))
- {
- $headers = array();
- if (!empty($this->data['last-modified']))
- {
- $headers['if-modified-since'] = $this->data['last-modified'];
- }
- if (!empty($this->data['etag']))
- {
- $headers['if-none-match'] = $this->data['etag'];
- }
- $file = new $this->file_class($this->rss_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen);
- if ($file->success)
- {
- $headers = $file->headers();
- if ($headers['status']['code'] == 304)
- {
- $cache->touch();
- return true;
- }
- }
- else
- {
- unset($file);
- }
- }
- // If we don't have last-modified or etag set, just clear the cache
- else
- {
- $cache->unlink();
- }
- }
- // If the cache is still valid, just return true
- else
- {
- return true;
- }
- }
- // If the cache is empty, delete it
- else
- {
- $cache->unlink();
- }
- }
- $this->data = array();
- // If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it.
- if (!isset($file))
- {
- if (is_a($this->file, 'SimplePie_File') && $this->file->url == $this->rss_url)
- {
- $file =& $this->file;
- }
- else
- {
- $file = new $this->file_class($this->rss_url, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen);
- }
- }
- // If the file connection has an error, set SimplePie::error to that and quit
- if (!$file->success)
- {
- $this->error = $file->error;
- return false;
- }
-
- // Check if the supplied URL is a feed, if it isn't, look for it.
- $locate = new $this->locator_class($file, $this->timeout, $this->useragent);
- if (!$locate->is_feed($file))
- {
- $feed = $locate->find();
- if ($feed)
- {
- if ($cache && !$cache->save(array('url' => $this->rss_url, 'feed_url' => $feed)))
- {
- $this->error = "$cache->name is not writeable";
- SimplePie_Misc::error($this->error, E_USER_WARNING, __FILE__, __LINE__);
- }
- $this->rss_url = $feed;
- return $this->init();
- }
- else
- {
- $this->error = "A feed could not be found at $this->rss_url";
- SimplePie_Misc::error($this->error, E_USER_WARNING, __FILE__, __LINE__);
- return false;
- }
- }
-
- $headers = $file->headers();
- $data = trim($file->body());
- $file->close();
- unset($file);
- }
- else
- {
- $data = $this->raw_data;
- }
-
- // First check to see if input has been overridden.
- if (!empty($this->input_encoding))
- {
- $encoding = $this->input_encoding;
- }
- // Second try HTTP headers
- else if (!empty($headers['content-type']) && preg_match('/charset\s*=\s*([^;]*)/i', $headers['content-type'], $charset))
- {
- $encoding = $charset[1];
- }
- // Then prolog, if at the very start of the document
- else if (preg_match('/^<\?xml(.*)?>/msiU', $data, $prolog) && preg_match('/encoding\s*=\s*("([^"]*)"|\'([^\']*)\')/Ui', $prolog[1], $encoding))
- {
- $encoding = substr($encoding[1], 1, -1);
- }
- // UTF-32 Big Endian BOM
- else if (strpos($data, sprintf('%c%c%c%c', 0x00, 0x00, 0xFE, 0xFF)) === 0)
- {
- $encoding = 'UTF-32be';
- }
- // UTF-32 Little Endian BOM
- else if (strpos($data, sprintf('%c%c%c%c', 0xFF, 0xFE, 0x00, 0x00)) === 0)
- {
- $encoding = 'UTF-32';
- }
- // UTF-16 Big Endian BOM
- else if (strpos($data, sprintf('%c%c', 0xFE, 0xFF)) === 0)
- {
- $encoding = 'UTF-16be';
- }
- // UTF-16 Little Endian BOM
- else if (strpos($data, sprintf('%c%c', 0xFF, 0xFE)) === 0)
- {
- $encoding = 'UTF-16le';
- }
- // UTF-8 BOM
- else if (strpos($data, sprintf('%c%c%c', 0xEF, 0xBB, 0xBF)) === 0)
- {
- $encoding = 'UTF-8';
- }
- // Fallback to the default
- else
- {
- $encoding = null;
- }
-
- // Change the encoding to UTF-8 (as we always use UTF-8 internally)
- $data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8');
-
- // Strip illegal characters (if on less than PHP5, as on PHP5 expat can manage fine)
- if (version_compare(phpversion(), '5', '<'))
- {
- if (function_exists('iconv'))
- {
- $data = iconv('UTF-8', 'UTF-8//IGNORE', $data);
- }
- else if (function_exists('mb_convert_encoding'))
- {
- $data = mb_convert_encoding($data, 'UTF-8', 'UTF-8');
- }
- else
- {
- $data = SimplePie_Misc::utf8_bad_replace($data);
- }
- }
- // Start parsing
- $data = new $this->parser_class($data, 'UTF-8', $this->xml_dump);
- // If we want the XML, just output that and quit
- if ($this->xml_dump)
- {
- header('Content-type: text/xml; charset=UTF-8');
- echo $data->data;
- exit;
- }
- // If it's parsed fine
- else if (!$data->error_code)
- {
- // Parse the data, and make it sane
- $this->sanitize->parse_data_array($data->data, $this->rss_url);
- unset($data);
- // Get the sane data
- $this->data['feedinfo'] = $this->sanitize->feedinfo;
- unset($this->sanitize->feedinfo);
- $this->data['info'] = $this->sanitize->info;
- unset($this->sanitize->info);
- $this->data['items'] = $this->sanitize->items;
- unset($this->sanitize->items);
- $this->data['feedinfo']['encoding'] = $this->sanitize->output_encoding;
- $this->data['url'] = $this->rss_url;
-
- // Store the headers that we need
- if (!empty($headers['last-modified']))
- {
- $this->data['last-modified'] = $headers['last-modified'];
- }
- if (!empty($headers['etag']))
- {
- $this->data['etag'] = $headers['etag'];
- }
-
- // If we want to order it by date, check if all items have a date, and then sort it
- if ($this->order_by_date && !empty($this->data['items']))
- {
- $do_sort = true;
- foreach ($this->data['items'] as $item)
- {
- if (!$item->get_date('U'))
- {
- $do_sort = false;
- break;
- }
- }
- if ($do_sort)
- {
- 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;'));
- }
- }
-
- // Cache the file if caching is enabled
- if ($cache && !$cache->save($this->data))
- {
- $this->error = "$cache->name is not writeable";
- SimplePie_Misc::error($this->error, E_USER_WARNING, __FILE__, __LINE__);
- }
- return true;
- }
- // If we have an error, just set SimplePie::error to it and quit
- else
- {
- $this->error = "XML error: $data->error_string at line $data->current_line, column $data->current_column";
- SimplePie_Misc::error($this->error, E_USER_WARNING, __FILE__, __LINE__);
- return false;
- }
- }
- }
-
- function get_encoding()
- {
- if (!empty($this->data['feedinfo']['encoding']))
- {
- return $this->data['feedinfo']['encoding'];
- }
- else
- {
- return false;
- }
- }
-
- function handle_content_type($mime = 'text/html')
- {
- if (!headers_sent())
- {
- $header = "Content-type: $mime;";
- if ($this->get_encoding())
- {
- $header .= ' charset=' . $this->get_encoding();
- }
- else
- {
- $header .= ' charset=UTF-8';
- }
- header($header);
- }
- }
-
- function get_type()
- {
- if (!empty($this->data['feedinfo']['type']))
- {
- return $this->data['feedinfo']['type'];
- }
- else
- {
- return false;
- }
- }
-
- function get_version()
- {
- if (!empty($this->data['feedinfo']['version']))
- {
- return $this->data['feedinfo']['version'];
- }
- else
- {
- return false;
- }
- }
-
- function get_favicon($check = false, $alternate = null)
- {
- if (!empty($this->data['info']['link']['alternate'][0]))
- {
- $favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $this->get_feed_link());
- if ($check)
- {
- $file = new $this->file_class($favicon, $this->timeout/10, 5, null, $this->useragent, $this->force_fsockopen);
- $headers = $file->headers();
- $file->close();
- if ($headers['status']['code'] == 200)
- {
- return $favicon;
- }
- }
- else
- {
- return $favicon;
- }
- }
- if (!is_null($alternate))
- {
- return $alternate;
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_url()
- {
- if (!empty($this->rss_url))
- {
- return $this->rss_url;
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_feed()
- {
- if (!empty($this->rss_url))
- {
- return SimplePie_Misc::fix_protocol($this->rss_url, 2);
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_outlook()
- {
- if (!empty($this->rss_url))
- {
- return 'outlook' . SimplePie_Misc::fix_protocol($this->rss_url, 2);
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_podcast()
- {
- if (!empty($this->rss_url))
- {
- return SimplePie_Misc::fix_protocol($this->rss_url, 3);
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_aol()
- {
- if ($this->subscribe_url())
- {
- return 'http://feeds.my.aol.com/add.jsp?url=' . rawurlencode($this->subscribe_url());
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_bloglines()
- {
- if ($this->subscribe_url())
- {
- return 'http://www.bloglines.com/sub/' . rawurlencode($this->subscribe_url());
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_eskobo()
- {
- if ($this->subscribe_url())
- {
- return 'http://www.eskobo.com/?AddToMyPage=' . rawurlencode($this->subscribe_url());
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_feedfeeds()
- {
- if ($this->subscribe_url())
- {
- return 'http://www.feedfeeds.com/add?feed=' . rawurlencode($this->subscribe_url());
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_feedlounge()
- {
- if ($this->subscribe_url())
- {
- return 'http://my.feedlounge.com/external/subscribe?url=' . rawurlencode($this->subscribe_url());
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_feedster()
- {
- if ($this->subscribe_url())
- {
- return 'http://www.feedster.com/myfeedster.php?action=addrss&confirm=no&rssurl=' . rawurlencode($this->subscribe_url());
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_google()
- {
- if ($this->subscribe_url())
- {
- return 'http://fusion.google.com/add?feedurl=' . rawurlencode($this->subscribe_url());
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_gritwire()
- {
- if ($this->subscribe_url())
- {
- return 'http://my.gritwire.com/feeds/addExternalFeed.aspx?FeedUrl=' . rawurlencode($this->subscribe_url());
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_msn()
- {
- if ($this->subscribe_url())
- {
- $url = 'http://my.msn.com/addtomymsn.armx?id=rss&ut=' . rawurlencode($this->subscribe_url());
- if ($this->get_feed_link())
- {
- $url .= '&ru=' . rawurlencode($this->get_feed_link());
- }
- return $url;
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_netvibes()
- {
- if ($this->subscribe_url())
- {
- return 'http://www.netvibes.com/subscribe.php?url=' . rawurlencode($this->subscribe_url());
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_newsburst()
- {
- if ($this->subscribe_url())
- {
- return 'http://www.newsburst.com/Source/?add=' . rawurlencode($this->subscribe_url());
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_newsgator()
- {
- if ($this->subscribe_url())
- {
- return 'http://www.newsgator.com/ngs/subscriber/subext.aspx?url=' . rawurlencode($this->subscribe_url());
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_odeo()
- {
- if ($this->subscribe_url())
- {
- return 'http://www.odeo.com/listen/subscribe?feed=' . rawurlencode($this->subscribe_url());
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_pluck()
- {
- if ($this->subscribe_url())
- {
- return 'http://client.pluck.com/pluckit/prompt.aspx?GCID=C12286x053&a=' . rawurlencode($this->subscribe_url());
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_podnova()
- {
- if ($this->subscribe_url())
- {
- return 'http://www.podnova.com/index_your_podcasts.srf?action=add&url=' . rawurlencode($this->subscribe_url());
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_rojo()
- {
- if ($this->subscribe_url())
- {
- return 'http://www.rojo.com/add-subscription?resource=' . rawurlencode($this->subscribe_url());
- }
- else
- {
- return false;
- }
- }
-
- function subscribe_yahoo()
- {
- if ($this->subscribe_url())
- {
- return 'http://add.my.yahoo.com/rss?url=' . rawurlencode($this->subscribe_url());
- }
- else
- {
- return false;
- }
- }
-
- function get_feed_title()
- {
- if (!empty($this->data['info']['title']))
- {
- return $this->data['info']['title'];
- }
- else
- {
- return false;
- }
- }
-
- function get_feed_link()
- {
- if (!empty($this->data['info']['link']['alternate'][0]))
- {
- return $this->data['info']['link']['alternate'][0];
- }
- else
- {
- return false;
- }
- }
-
- function get_feed_links()
- {
- if (!empty($this->data['info']['link']))
- {
- return $this->data['info']['link'];
- }
- else
- {
- return false;
- }
- }
-
- function get_feed_description()
- {
- if (!empty($this->data['info']['description']))
- {
- return $this->data['info']['description'];
- }
- else if (!empty($this->data['info']['dc:description']))
- {
- return $this->data['info']['dc:description'];
- }
- else if (!empty($this->data['info']['tagline']))
- {
- return $this->data['info']['tagline'];
- }
- else if (!empty($this->data['info']['subtitle']))
- {
- return $this->data['info']['subtitle'];
- }
- else
- {
- return false;
- }
- }
-
- function get_feed_copyright()
- {
- if (!empty($this->data['info']['copyright']))
- {
- return $this->data['info']['copyright'];
- }
- else
- {
- return false;
- }
- }
-
- function get_feed_language()
- {
- if (!empty($this->data['info']['language']))
- {
- return $this->data['info']['language'];
- }
- else if (!empty($this->data['info']['xml:lang']))
- {
- return $this->data['info']['xml:lang'];
- }
- else
- {
- return false;
- }
- }
-
- function get_image_exist()
- {
- if (!empty($this->data['info']['image']['url']) || !empty($this->data['info']['image']['logo']))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
- function get_image_title()
- {
- if (!empty($this->data['info']['image']['title']))
- {
- return $this->data['info']['image']['title'];
- }
- else
- {
- return false;
- }
- }
-
- function get_image_url()
- {
- if (!empty($this->data['info']['image']['url']))
- {
- return $this->data['info']['image']['url'];
- }
- else if (!empty($this->data['info']['image']['logo']))
- {
- return $this->data['info']['image']['logo'];
- }
- else
- {
- return false;
- }
- }
-
- function get_image_link()
- {
- if (!empty($this->data['info']['image']['link']))
- {
- return $this->data['info']['image']['link'];
- }
- else
- {
- return false;
- }
- }
-
- function get_image_width()
- {
- if (!empty($this->data['info']['image']['width']))
- {
- return $this->data['info']['image']['width'];
- }
- else
- {
- return false;
- }
- }
-
- function get_image_height()
- {
- if (!empty($this->data['info']['image']['height']))
- {
- return $this->data['info']['image']['height'];
- }
- else
- {
- return false;
- }
- }
-
- function get_item_quantity($max = 0)
- {
- if (!empty($this->data['items']))
- {
- $qty = sizeof($this->data['items']);
- }
- else
- {
- $qty = 0;
- }
- if ($max == 0)
- {
- return $qty;
- }
- else
- {
- return ($qty > $max) ? $max : $qty;
- }
- }
-
- function get_item($key = 0)
- {
- if (!empty($this->data['items'][$key]))
- {
- return $this->data['items'][$key];
- }
- else
- {
- return false;
- }
- }
-
- function get_items($start = 0, $end = 0)
- {
- if ($this->get_item_quantity() > 0)
- {
- if ($end == 0)
- {
- return array_slice($this->data['items'], $start);
- }
- else
- {
- return array_slice($this->data['items'], $start, $end);
- }
- }
- else
- {
- return false;
- }
- }
- }
- class SimplePie_Item
- {
- var $data;
-
- function SimplePie_Item($data)
- {
- $this->data =& $data;
- }
-
- function get_id()
- {
- if (!empty($this->data['guid']['data']))
- {
- return $this->data['guid']['data'];
- }
- else if (!empty($this->data['id']))
- {
- return $this->data['id'];
- }
- else
- {
- return false;
- }
- }
-
- function get_title()
- {
- if (!empty($this->data['title']))
- {
- return $this->data['title'];
- }
- else if (!empty($this->data['dc:title']))
- {
- return $this->data['dc:title'];
- }
- else
- {
- return false;
- }
- }
-
- function get_description()
- {
- if (!empty($this->data['content']))
- {
- return $this->data['content'];
- }
- else if (!empty($this->data['encoded']))
- {
- return $this->data['encoded'];
- }
- else if (!empty($this->data['summary']))
- {
- return $this->data['summary'];
- }
- else if (!empty($this->data['description']))
- {
- return $this->data['description'];
- }
- else if (!empty($this->data['dc:description']))
- {
- return $this->data['dc:description'];
- }
- else if (!empty($this->data['longdesc']))
- {
- return $this->data['longdesc'];
- }
- else
- {
- return false;
- }
- }
-
- function get_category($key = 0)
- {
- $categories = $this->get_categories();
- if (!empty($categories[$key]))
- {
- return $categories[$key];
- }
- else
- {
- return false;
- }
- }
-
- function get_categories()
- {
- $categories = array();
- if (!empty($this->data['category']))
- {
- $categories = array_merge($categories, $this->data['category']);
- }
- if (!empty($this->data['subject']))
- {
- $categories = array_merge($categories, $this->data['subject']);
- }
- if (!empty($this->data['term']))
- {
- $categories = array_merge($categories, $this->data['term']);
- }
- if (!empty($categories))
- {
- return array_unique($categories);
- }
- else
- {
- return false;
- }
- }
-
- function get_author($key = 0)
- {
- $authors = $this->get_authors();
- if (!empty($authors[$key]))
- {
- return $authors[$key];
- }
- else
- {
- return false;
- }
- }
-
- function get_authors()
- {
- $authors = array();
- if (!empty($this->data['author']))
- {
- $authors = array_merge($authors, $this->data['author']);
- }
- if (!empty($this->data['creator']))
- {
- $authors = array_merge($authors, $this->data['creator']);
- }
- if (!empty($authors))
- {
- return array_unique($authors);
- }
- else
- {
- return false;
- }
- }
-
- function get_date($date_format = 'j F Y, g:i a')
- {
- if (!empty($this->data['pubdate']))
- {
- return date($date_format, $this->data['pubdate']);
- }
- else if (!empty($this->data['dc:date']))
- {
- return date($date_format, $this->data['dc:date']);
- }
- else if (!empty($this->data['issued']))
- {
- return date($date_format, $this->data['issued']);
- }
- else if (!empty($this->data['published']))
- {
- return date($date_format, $this->data['published']);
- }
- else if (!empty($this->data['modified']))
- {
- return date($date_format, $this->data['modified']);
- }
- else if (!empty($this->data['updated']))
- {
- return date($date_format, $this->data['updated']);
- }
- else
- {
- return false;
- }
- }
-
- function get_permalink()
- {
- $link = $this->get_link(0);
- $enclosure = $this->get_enclosure(0);
- if (!empty($link))
- {
- return $link;
- }
- else if (!empty($enclosure))
- {
- return $enclosure->get_link();
- }
- else
- {
- return false;
- }
- }
-
- function get_link($key = 0, $rel = 'alternate')
- {
- $links = $this->get_links($rel);
- if (!empty($links[$key]))
- {
- return $links[$key];
- }
- else
- {
- return false;
- }
- }
-
- function get_links($rel = 'alternate')
- {
- if ($rel == 'alternate')
- {
- $links = array();
- if (!empty($this->data['link'][$rel]))
- {
- $links = $this->data['link'][$rel];
- }
- if (!empty($this->data['guid']['data']) && $this->data['guid']['permalink'] == true)
- {
- $links[] = $this->data['guid']['data'];
- }
- return $links;
- }
- else if (!empty($this->data['link'][$rel]))
- {
- return $this->data['link'][$rel];
- }
- else
- {
- return false;
- }
- }
-
- function get_enclosure($key = 0)
- {
- $enclosures = $this->get_enclosures();
- if (!empty($enclosures[$key]))
- {
- return $enclosures[$key];
- }
- else
- {
- return false;
- }
- }
-
- function get_enclosures()
- {
- $enclosures = array();
- $links = $this->get_links('enclosure');
- if (!empty($this->data['enclosures']))
- {
- $enclosures = array_merge($enclosures, $this->data['enclosures']);
- }
- if (!empty($links))
- {
- $enclosures = array_merge($enclosures, $links);
- }
- if (!empty($enclosures))
- {
- return array_unique($enclosures);
- }
- else
- {
- return false;
- }
- }
-
- function add_to_blinklist()
- {
- if ($this->get_permalink())
- {
- $url = 'http://www.blinklist.com/index.php?Action=Blink/addblink.php&Description=&Url=' . rawurlencode($this->get_permalink());
- if ($this->get_title())
- {
- $url .= '&Title=' . rawurlencode($this->get_title());
- }
- return $url;
- }
- else
- {
- return false;
- }
- }
-
- function add_to_blogmarks()
- {
- if ($this->get_permalink())
- {
- $url = 'http://blogmarks.net/my/new.php?mini=1&simple=1&url=' . rawurlencode($this->get_permalink());
- if ($this->get_title())
- {
- $url .= '&title=' . rawurlencode($this->get_title());
- }
- return $url;
- }
- else
- {
- return false;
- }
- }
-
- function add_to_delicious()
- {
- if ($this->get_permalink())
- {
- $url = 'http://del.icio.us/post/?v=3&url=' . rawurlencode($this->get_permalink());
- if ($this->get_title())
- {
- $url .= '&title=' . rawurlencode($this->get_title());
- }
- return $url;
- }
- else
- {
- return false;
- }
- }
-
- function add_to_digg()
- {
- if ($this->get_permalink())
- {
- return 'http://digg.com/submit?phase=2&URL=' . rawurlencode($this->get_permalink());
- }
- else
- {
- return false;
- }
- }
-
- function add_to_furl()
- {
- if ($this->get_permalink())
- {
- $url = 'http://www.furl.net/storeIt.jsp?u=' . rawurlencode($this->get_permalink());
- if ($this->get_title())
- {
- $url .= '&t=' . rawurlencode($this->get_title());
- }
- return $url;
- }
- else
- {
- return false;
- }
- }
-
- function add_to_magnolia()
- {
- if ($this->get_permalink())
- {
- $url = 'http://ma.gnolia.com/bookmarklet/add?url=' . rawurlencode($this->get_permalink());
- if ($this->get_title())
- {
- $url .= '&title=' . rawurlencode($this->get_title());
- }
- return $url;
- }
- else
- {
- return false;
- }
- }
-
- function add_to_myweb20()
- {
- if ($this->get_permalink())
- {
- $url = 'http://myweb2.search.yahoo.com/myresults/bookmarklet?u=' . rawurlencode($this->get_permalink());
- if ($this->get_title())
- {
- $url .= '&t=' . rawurlencode($this->get_title());
- }
- return $url;
- }
- else
- {
- return false;
- }
- }
-
- function add_to_newsvine()
- {
- if ($this->get_permalink())
- {
- $url = 'http://www.newsvine.com/_wine/save?u=' . rawurlencode($this->get_permalink());
- if ($this->get_title())
- {
- $url .= '&h=' . rawurlencode($this->get_title());
- }
- return $url;
- }
- else
- {
- return false;
- }
- }
-
- function add_to_reddit()
- {
- if ($this->get_permalink())
- {
- $url = 'http://reddit.com/submit?url=' . rawurlencode($this->get_permalink());
- if ($this->get_title())
- {
- $url .= '&title=' . rawurlencode($this->get_title());
- }
- return $url;
- }
- else
- {
- return false;
- }
- }
-
- function add_to_segnalo()
- {
- if ($this->get_permalink())
- {
- $url = 'http://segnalo.com/post.html.php?url=' . rawurlencode($this->get_permalink());
- if ($this->get_title())
- {
- $url .= '&title=' . rawurlencode($this->get_title());
- }
- return $url;
- }
- else
- {
- return false;
- }
- }
-
- function add_to_simpy()
- {
- if ($this->get_permalink())
- {
- $url = 'http://www.simpy.com/simpy/LinkAdd.do?href=' . rawurlencode($this->get_permalink());
- if ($this->get_title())
- {
- $url .= '&title=' . rawurlencode($this->get_title());
- }
- return $url;
- }
- else
- {
- return false;
- }
- }
-
- function add_to_smarking()
- {
- if ($this->get_permalink())
- {
- return 'http://smarking.com/editbookmark/?url=' . rawurlencode($this->get_permalink());
- }
- else
- {
- return false;
- }
- }
-
- function add_to_spurl()
- {
- if ($this->get_permalink())
- {
- $url = 'http://www.spurl.net/spurl.php?v=3&url=' . rawurlencode($this->get_permalink());
- if ($this->get_title())
- {
- $url .= '&title=' . rawurlencode($this->get_title());
- }
- return $url;
- }
- else
- {
- return false;
- }
- }
-
- function add_to_wists()
- {
- if ($this->get_permalink())
- {
- $url = 'http://wists.com/r.php?c=&r=' . rawurlencode($this->get_permalink());
- if ($this->get_title())
- {
- $url .= '&title=' . rawurlencode($this->get_title());
- }
- return $url;
- }
- else
- {
- return false;
- }
- }
-
- function search_technorati()
- {
- if ($this->get_permalink())
- {
- return 'http://www.technorati.com/search/' . rawurlencode($this->get_permalink());
- }
- else
- {
- return false;
- }
- }
- }
- class SimplePie_Author
- {
- var $name;
- var $link;
- var $email;
-
- // Constructor, used to input the data
- function SimplePie_Author($name, $link, $email)
- {
- $this->name = $name;
- $this->link = $link;
- $this->email = $email;
- }
-
- function get_name()
- {
- if (!empty($this->name))
- {
- return $this->name;
- }
- else
- {
- return false;
- }
- }
-
- function get_link()
- {
- if (!empty($this->link))
- {
- return $this->link;
- }
- else
- {
- return false;
- }
- }
-
- function get_email()
- {
- if (!empty($this->email))
- {
- return $this->email;
- }
- else
- {
- return false;
- }
- }
- }
- class SimplePie_Enclosure
- {
- var $link;
- var $type;
- var $length;
- // Constructor, used to input the data
- function SimplePie_Enclosure($link, $type, $length)
- {
- $this->link = $link;
- $this->type = $type;
- $this->length = $length;
- }
- function get_link()
- {
- if (!empty($this->link))
- {
- if (class_exists('idna_convert'))
- {
- $idn = new idna_convert;
- $this->link = $idn->encode($this->link);
- }
- return $this->link;
- }
- else
- {
- return false;
- }
- }
- function get_extension()
- {
- if (!empty($this->link))
- {
- return pathinfo($this->link, PATHINFO_EXTENSION);
- }
- else
- {
- return false;
- }
- }
- function get_type()
- {
- if (!empty($this->type))
- {
- return $this->type;
- }
- else
- {
- return false;
- }
- }
- function get_length()
- {
- if (!empty($this->length))
- {
- return $this->length;
- }
- else
- {
- return false;
- }
- }
- function get_size()
- {
- $length = $this->get_length();
- if (!empty($length))
- {
- return round($length/1048576, 2);
- }
- else
- {
- return false;
- }
- }
- function native_embed($options='')
- {
- return $this->embed($options, true);
- }
- function embed($options = '', $native = false)
- {
- // Set up defaults
- $audio = '';
- $video = '';
- $alt = '';
- $altclass = '';
- $loop = 'false';
- $width = 'auto';
- $height = 'auto';
- $bgcolor = '#ffffff';
- // Process options and reassign values as necessary
- if (is_array($options))
- {
- extract($options);
- }
- else
- {
- $options = explode(',', $options);
- foreach($options as $option)
- {
- $opt = explode(':', $option, 2);
- if (isset($opt[0], $opt[1]))
- {
- $opt[0] = trim($opt[0]);
- $opt[1] = trim($opt[1]);
- switch ($opt[0])
- {
- case 'audio':
- $audio = $opt[1];
- break;
-
- case 'video':
- $video = $opt[1];
- break;
-
- case 'alt':
- $alt = $opt[1];
- break;
-
- case 'altclass':
- $altclass = $opt[1];
- break;
-
- case 'loop':
- $loop = $opt[1];
- break;
-
- case 'width':
- $width = $opt[1];
- break;
-
- case 'height':
- $height = $opt[1];
- break;
-
- case 'bgcolor':
- $bgcolor = $opt[1];
- break;
- }
- }
- }
- }
-
- $type = strtolower($this->get_type());
- // If we encounter an unsupported mime-type, check the file extension and guess intelligently.
- 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')))
- {
- switch (strtolower($this->get_extension()))
- {
- // Audio mime-types
- case 'aac':
- case 'adts':
- $type = 'audio/acc';
- break;
-
- case 'aif':
- case 'aifc':
- case 'aiff':
- case 'cdda':
- $type = 'audio/aiff';
- break;
-
- case 'bwf':
- $type = 'audio/wav';
- break;
-
- case 'kar':
- case 'mid':
- case 'midi':
- case 'smf':
- $type = 'audio/midi';
- break;
-
- case 'm4a':
- $type = 'audio/x-m4a';
- break;
-
- case 'mp3':
- case 'swa':
- $type = 'audio/mp3';
- break;
-
- case 'wav':
- $type = 'audio/wav';
- break;
-
- case 'wax':
- $type = 'audio/x-ms-wax';
- break;
-
- case 'wma':
- $type = 'audio/x-ms-wma';
- break;
-
- // Video mime-types
- case '3gp':
- case '3gpp':
- $type = 'video/3gpp';
- break;
- case '3g2':
- case '3gp2':
- $type = 'video/3gpp2';
- break;
- case 'asf':
- $type = 'video/x-ms-asf';
- break;
- case 'm1a':
- case 'm1s':
- case 'm1v':
- case 'm15':
- case 'm75':
- case 'mp2':
- case 'mpa':
- case 'mpeg':
- case 'mpg':
- case 'mpm':
- case 'mpv':
- $type = 'video/mpeg';
- break;
- case 'm4v':
- $type = 'video/x-m4v';
- break;
- case 'mov':
- case 'qt':
- $type = 'video/quicktime';
- break;
- case 'mp4':
- case 'mpg4':
- $type = 'video/mp4';
- break;
- case 'sdv':
- $type = 'video/sd-video';
- break;
- case 'wm':
- $type = 'video/x-ms-wm';
- break;
- case 'wmv':
- $type = 'video/x-ms-wmv';
- break;
- case 'wvx':
- $type = 'video/x-ms-wvx';
- break;
-
- // Flash mime-types
- case 'spl':
- $type = 'application/futuresplash';
- break;
- case 'swf':
- $type = 'application/x-shockwave-flash';
- break;
- }
- }
- $mime = explode('/', $type, 2);
- $mime = $mime[0];
-
- // Process values for 'auto'
- if ($width == 'auto')
- {
- if ($mime == 'video')
- {
- $width = '320';
- }
- else
- {
- $width = '100%';
- }
- }
- if ($height == 'auto')
- {
- if ($mime == 'audio')
- {
- $height = 0;
- }
- else if ($mime == 'video')
- {
- $height = 240;
- }
- else
- {
- $height = 256;
- }
- }
- // Set proper placeholder value
- if ($mime == 'audio')
- {
- $placeholder = $audio;
- }
- else if ($mime == 'video')
- {
- $placeholder = $video;
- }
- $embed = '';
- // Make sure the JS library is included
- // (I know it'll be included multiple times, but I can't think of a better way to do this automatically)
- if (!$native)
- {
- $embed .= '<script type="text/javascript" src="?js"></script>';
- }
- // Odeo Feed MP3's
- if (substr(strtolower($this->get_link()), 0, 15) == 'http://odeo.com') {
- if ($native)
- {
- $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>';
- }
- else
- {
- $embed .= '<script type="text/javascript">embed_odeo("' . $this->get_link() . '");</script>';
- }
- }
- // QuickTime 7 file types. Need to test with QuickTime 6.
- 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')))
- {
- $height += 16;
- if ($native)
- {
- if ($placeholder != "") {
- $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>";
- }
- else {
- $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>";
- }
- }
- else
- {
- $embed .= "<script type='text/javascript'>embed_quicktime('$type', '$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$placeholder', '$loop');</script>";
- }
- }
- // Flash
- else if (in_array($type, array('application/x-shockwave-flash', 'application/futuresplash')))
- {
- if ($native)
- {
- $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>";
- }
- else
- {
- $embed .= "<script type='text/javascript'>embed_flash('$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$loop', '$type');</script>";
- }
- }
- // Windows Media
- 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')))
- {
- $height += 45;
- if ($native)
- {
- $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>";
- }
- else
- {
- $embed .= "<script type='text/javascript'>embed_wmedia('$width', '$height', '" . $this->get_link() . "');</script>";
- }
- }
- // Everything else
- else $embed .= '<a href="' . $this->get_link() . '" class="' . $altclass . '">' . $alt . '</a>';
- return $embed;
- }
- }
- class SimplePie_File
- {
- var $url;
- var $useragent;
- var $success = true;
- var $headers = array();
- var $body;
- var $fp;
- var $redirects = 0;
- var $error;
- var $method;
-
- function SimplePie_File($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false)
- {
- if (class_exists('idna_convert'))
- {
- $idn = new idna_convert;
- $url = $idn->encode($url);
- }
- $this->url = $url;
- $this->useragent = $useragent;
- if (preg_match('/^http(s)?:\/\//i', $url))
- {
- if (empty($useragent))
- {
- $useragent = ini_get('user_agent');
- $this->useragent = $useragent;
- }
- if (!is_array($headers))
- {
- $headers = array();
- }
- if (extension_loaded('curl') && version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>=') && !$force_fsockopen)
- {
- $this->method = 'curl';
- $fp = curl_init();
- $headers2 = array();
- foreach ($headers as $key => $value)
- {
- $headers2[] = "$key: $value";
- }
- curl_setopt($fp, CURLOPT_ENCODING, '');
- curl_setopt($fp, CURLOPT_URL, $url);
- curl_setopt($fp, CURLOPT_HEADER, 1);
- curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($fp, CURLOPT_TIMEOUT, $timeout);
- curl_setopt($fp, CURLOPT_REFERER, $url);
- curl_setopt($fp, CURLOPT_USERAGENT, $useragent);
- curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);
- if (!ini_get('open_basedir') && !ini_get('safe_mode'))
- {
- curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects);
- }
- $this->headers = trim(curl_exec($fp));
- if (curl_errno($fp) == 23 || curl_errno($fp) == 61)
- {
- curl_setopt($fp, CURLOPT_ENCODING, 'none');
- $this->headers = trim(curl_exec($fp));
- }
- if (curl_errno($fp))
- {
- $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp);
- $this->success = false;
- return false;
- }
- $info = curl_getinfo($fp);
- $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 2);
- if (count($this->headers) == $info['redirect_count'] + 1)
- {
- $this->headers = array_pop($this->headers);
- $this->body = '';
- }
- else
- {
- $this->body = array_pop($this->headers);
- $this->headers = array_pop($this->headers);
- }
- $this->headers = $this->parse_headers($this->headers);
- 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)
- {
- $this->redirects++;
- return $this->SimplePie_File($this->headers['location'], $timeout, $redirects, $headers, $useragent, $force_fsockopen);
- }
- }
- else
- {
- $this->method = 'fsockopen';
- $url_parts = parse_url($url);
- if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) == 'https')
- {
- $url_parts['host'] = "ssl://$url_parts[host]";
- $url_parts['port'] = 443;
- }
- if (!isset($url_parts['port']))
- {
- $url_parts['port'] = 80;
- }
- $this->fp = fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout);
- if (!$this->fp)
- {
- $this->error = 'fsockopen error: ' . $errstr;
- $this->success = false;
- return false;
- }
- else
- {
- stream_set_timeout($this->fp, $timeout);
- $get = (isset($url_parts['query'])) ? "$url_parts[path]?$url_parts[query]" : $url_parts['path'];
- $out = "GET $get HTTP/1.0\r\n";
- $out .= "Host: $url_parts[host]\r\n";
- $out .= "User-Agent: $useragent\r\n";
- if (function_exists('gzinflate'))
- {
- $out .= "Accept-Encoding: gzip,deflate\r\n";
- }
- if (!empty($url_parts['user']) && !empty($url_parts['pass']))
- {
- $out .= "Authorization: Basic " . base64_encode("$url_parts[user]:$url_parts[pass]") . "\r\n";
- }
- foreach ($headers as $key => $value)
- {
- $out .= "$key: $value\r\n";
- }
- $out .= "Connection: Close\r\n\r\n";
- fwrite($this->fp, $out);
-
- $info = stream_get_meta_data($this->fp);
- $data = '';
- while (strpos($data, "\r\n\r\n") === false && !$info['timed_out'])
- {
- $data .= fgets($this->fp, 128);
- $info = stream_get_meta_data($this->fp);
- }
- if (!$info['timed_out'])
- {
- $this->headers = $this->parse_headers($data);
- 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)
- {
- $this->r…
Large files files are truncated, but you can click here to view the full file