1<?php
2
3/*
4======================================================================
5LastRSS bridge script- By Dynamic Drive (http://www.dynamicdrive.com)
6Communicates between LastRSS.php to Advanced Ajax ticker script using Ajax. Returns RSS feed in XML format
7Created: Feb 9th, 2006. Updated: Feb 9th, 2006
8======================================================================
9*/
10
11header('Content-type: text/xml');
12
13// include lastRSS
14include "lastRSS.php"; //path to lastRSS.php on your server from this script ("bridge.php")
15
16// Create lastRSS object
17$rss = new lastRSS;
18$rss->cache_dir = 'cache'; //path to cache directory on your server from this script. Chmod 777!
19//$rss->date_format = 'M d, Y g:i:s A'; //date format of RSS item. See PHP date() function for possible input.
20$rss->date_format = $conf['dformat']; //date format of RSS item. See PHP date() function for possible input from Dokuwikidate
21
22////Beginners don't need to configure past here////////////////////
23
24$rssurl=$_GET['rss_url'];
25
26// -------------------------------------------------------------------
27// outputRSS_XML()- Outputs the "title", "link", "description", and "pubDate" elements of an RSS feed in XML format
28// -------------------------------------------------------------------
29
30function outputRSS_XML($url) {
31    global $rss;
32    $cacheseconds=(int) $_GET["cachetime"]; //typecast "cachetime" parameter as integer (0 or greater)
33    $rss->cache_time = $cacheseconds;
34    if ($rs = $rss->get($url)) {
35	    echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<rss version=\"2.0\">\n<channel>\n";
36            foreach ($rs['items'] as $item) {
37                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";
38            }
39	    echo "</channel></rss>";
40            if ($rs['items_count'] <= 0) { echo "<li>Sorry, no items found in the RSS file :-(</li>"; }
41    }
42    else {
43        echo "Sorry: It's not possible to reach RSS file $url\n<br />";
44        // you will probably hide this message in a live version
45    }
46}
47
48// ===============================================================================
49
50outputRSS_XML($rssurl);
51
52?>