#global $rss_ticker_array; #$rsslist = $rss_ticker_array; ////Beginners don't need to configure past here//////////////////// $rssid = $_GET['id']; $rssurl = isset($rsslist[$rssid]) ? $rsslist[$rssid] : die("Error: Can't find requested RSS in list."); // ------------------------------------------------------------------- // outputRSS_XML()- Outputs the "title", "link", "description", and "pubDate" elements of an RSS feed in XML format // ------------------------------------------------------------------- function outputRSS_XML($url) { global $rss; $cacheseconds = (int) $_GET["cachetime"]; //typecast "cachetime" parameter as integer (0 or greater) $rss->cache_time = $cacheseconds; if ($rs = $rss->get($url)) { echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<rss version=\"2.0\">\n<channel>\n"; foreach ($rs['items'] as $item) { echo "<item>\n<link>{$item['link']}</link>\n<title>{$item['title']}</title>\n<description>{$item['description']}</description>\n<pubDate>{$item['pubDate']}</pubDate>\n</item>\n\n"; } echo "</channel></rss>"; if ($rs['items_count'] <= 0) { echo "<li>Sorry, no items found in the RSS file :-(</li>"; } } else { echo "Sorry: It's not possible to reach RSS file {$url}\n<br />"; // you will probably hide this message in a live version } } // =============================================================================== outputRSS_XML($rssurl);
// outputRSS_XML()- Outputs the "title", "link", "description", and "pubDate" elements of an RSS feed in XML format // ------------------------------------------------------------------- function outputRSS_XML($url,$rss) { $cacheseconds=(int) $_GET["cachetime"]; //typecast "cachetime" parameter as integer (0 or greater) $rss->cache_time = $cacheseconds; if ($rs = $rss->get($url)) { $encoding = 'ISO-8859-1'; if ( !empty($rs['encoding']) ) { $encoding = $rs['encoding']; } echo "<?xml version=\"1.0\" encoding=\"".$encoding."\"?>\n<rss version=\"2.0\">\n<channel>\n"; foreach ($rs['items'] as $item) { if (isset($item['description'])){ echo "<item>\n<link>$item[link]</link>\n<title>$item[title]</title>\n<description>$item[description]</description>\n<pubDate>$item[pubDate]</pubDate>\n</item>\n\n"; }else{ echo "<item>\n<link>$item[link]</link>\n<title>$item[title]</title>\n<description>...</description>\n<pubDate>$item[pubDate]</pubDate>\n</item>\n\n"; } } echo "</channel></rss>"; if ($rs['items_count'] <= 0) { echo "<li>Sorry, no items found in the RSS file :-(</li>"; } } else { echo "Sorry: It's not possible to reach RSS file $url\n<br />"; // you will probably hide this message in a live version } } // =============================================================================== outputRSS_XML($rssurl,$rss); ?>