<?php Header('Content-type: text/xml');
include ('config.php');
$edate=gmdate("D,d M Y H:i:s T");
/*
/////////////////////// Installation ////////////////////////////////
1) Change the configuration settings below to match your requirements
2) Upload this file into your forum directory
3) The RSS Feedlink can be located anywhere on your site
<a href="http://www.yoursite.com/forumdirectory/xmb-rss.php">
///////////////////// Installation End //////////////////////////////
*/
///////////////// Configuration settings ////////////////////////////
// Required Parameters
$title=""; //The title of your newsfeed
$description=""; //The description of your newsfeed
$linkurl=""; // Link url to your site or forum
$webmaster=""; //e-mail address of site webmaster
$maxnews=10; //The maximum number of news items to display
$copyright=""; // RSS Feed Copyright notice
// Optional Parameters
$imageurl=""; // URL of News Logo/Forum Logo etc
$editor=""; //e-mail address of news editor
$feedstatus=1; //Feedstatus 1 for on 0 for off
$postorder="ASC"; //ASC show first post in thread DESC show last post in thread
$showtopics=0; // Show topics only in feed 1= on 0=off
$category=1; //use forum name as newsitem category 1= on 0 = off
// Custom Error message Configuration
$msgtitle="Forum Feed Is currently Offline";//The title if Newsfeed is offline
$msgdesc="The website administrator has temporarily turned off this RSS feed. Please check again later";//Message to display if feed is offline
$msgsql="The newsfeeed is currently offline. Please try again later"; //message to display if msyql connection fails
///////////////// Configuration End /////////////////////////////////
echo "<?xml version=\"1.0\"?>\n";
echo "<rss version=\"2.0\">\n";
echo " <channel>\n";
echo " <title>$title</title>\n";
echo " <link>$linkurl</link>\n";
echo " <description>$description</description>\n";
echo " <language>en-us</language>\n";
echo " <copyright>$copyright</copyright>\n";
echo " <generator>XMB Forum RSS Feeder - http://forums.xmbforum2.com</generator>\n";
echo " <webMaster>$webmaster</webMaster>\n";
// Additional options display
if ($editor==""){
}else{
echo " <managingEditor>$editor</managingEditor>\n";
}
if ($imageurl==""){
}else{
echo " <image>\n";
echo " <title>$title</title>\n";
echo" <url>$imageurl</url>\n";
echo" <link>$linkurl</link>\n";
echo" <description>$description</description>\n";
echo" </image>\n";
}
switch($feedstatus){
case 1:
// Connect to forum and retreive Last 10 Posts
@$dbh = mysql_connect ($dbhost, $dbuser, $dbpw)or die ("<item>\n<title>$msgtitle</title>\n<description>$msgsql</description>\n<pubdate>$edate</pubdate>\n</item>\n</channel>\n</rss>");
@$result = mysql_select_db ($dbname, $dbh) or die ("<item>\n<title>$msgtitle</title>\n<description>$msgsql</description>\n<pubdate>$edate</pubdate>\n</item>\n</channel>\n</rss>");
//Latest 10 posts Not showing Private forums
$x=0;
$query1 = mysql_query("SELECT lastpost, fid ,tid, subject FROM {$tablepre}threads ORDER BY lastpost DESC");
while($last = mysql_fetch_array($query1)) {
$query2 = mysql_query("SELECT name,userlist,private FROM {$tablepre}forums WHERE fid =$last[fid]");
$forum =mysql_fetch_array($query2);
//ignore private forums
if (($forum[userlist] == "")and($forum[private]==1)){
//retrieve first post for each thread being displayed
$query3 = mysql_query("SELECT message,author,dateline FROM {$tablepre}posts WHERE fid=$last[fid] AND tid=$last[tid] ORDER BY pid $postorder LIMIT 1");
$content = mysql_fetch_array($query3);
$rawnews= stripslashes($content[message]);
$newsbody=htmlentities($rawnews,ENT_COMPAT);
$pdate=gmdate("D,d M Y H:i:s T",$content[dateline]);
$rawtitle = stripslashes($last[subject]);
$newstitle=htmlentities($rawtitle,ENT_COMPAT);
$rawcat = stripslashes($forum[name]);
$newscat=htmlentities($rawcat,ENT_COMPAT);
$author=htmlentities($content[author],ENT_COMPAT);
//output each forum topic
echo " <item>\n";
if ($category==1){
echo" <category>$newscat</category>\n";
}
echo " <title><![CDATA[$newstitle]]></title>\n";
// }
echo " <link>$full_url";
echo"viewthread.php?tid=$last[tid]</link>\n";
echo " <pubDate>$pdate</pubDate>\n";
if($showtopic==0){
echo " <description>By: $author\n<![CDATA[$newsbody]]></description>\n";
}
echo " </item>\n";
$x++;
}
if ($x == $maxnews){
break;
}}
mysql_close();
break;
case 0:
// Offline output statement
echo"<item>\n";
echo" <title>$msgtitle</title>\n";
echo" <pubDate>$edate</pubDate>\n";
echo " <description>$msgdesc</description>\n";
echo"</item>\n";
break;
}
//Finally, close off your XML/RSS tags:
echo " </channel>\n";
echo "</rss> ";
/*
////////////////////// Changelog //////////////////////////////////////
1) included config.php to provide database connection settings
2) added newslogo image support
3) added script configuration settings including no of items to display and ability to turn feed on and off
4) added installation instructions and improved script comments
5)Check and remove all private forums from display
6) Added Copyright info for news
7) Using CDATA and htmlentities to Clean invalid characters from posts (ie £ & etc)
8) Added show first post or last post in thread option
9) Better sql error message now in rss format
10) Added option to Customize error messages
11) Put timestamp as <pubdate> in error feeds
12) Tidied up code and removed un-necessay items from script used during testing
13) Added option to show forum name in Newstitle
14) Using htmlentities to Clean invalid characters from newstitles (ie £ & etc)
15) Removed the forum name in Title infavour of the Item Category option
16) Added the display of the post author in the posd
17) Corrected Link display in each item
18) 24-05-05 Fix added to Topic Titles to correct illegal RSS characters
19) 25-05-04 Added option to Show topic titles only in feed
ToDo List
1) allow feedstatus and configuration to be altered from forum Admin
2) add option to use specific forum for newsfeeds?
3) Join queries like today.php
*/
?>
|