01-06-2001, 11:57 PM
Hello everyone,
I built a PHP RSS library to include headlines from popular website into my homepage, it worked great and I used it to include my favourite sites slashdot, linuxtoday, and freshmeat of course ;)
but I needed to add my favourite bulletin board site that uses VB, and I searched for RSS support in VB, but I didn't find any, so I downloaded the lite version of VB and installed it, and after 3 hours I have my RSS hack for VB, and it works great, I tested it for the full version and it works fine there :)
I thought someone might be intersted on it, here is the code, it is a stripped down "forumdisplay.php" file with little changes to make it produce RSS file.
Put it in the same directory with "forumdisplay.php", and you call it in the same way "rss.php?forumid=1"
Hope you like it and use it :)
<?php echo '<?xml version="1.0"?>'; ?>
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"
"http://my.netscape.com/publish/formats/rss-0.91.dtd">
<rss version="0.91">
<channel>
<?php
echo "<!--\n";
require("global.php");
echo "-->\n";
echo "<title>$bbtitle</title>\n";
echo "<link>$bburl</link>\n";
// set defaults
if (isset($perpage)==0 or $perpage==0) {
$perpage=$maxthreads;
}
$forumid = verifyid("forum",$forumid);
$foruminfo=$DB_site->query_first("SELECT title,description,active FROM forum WHERE forumid=$forumid");
$forumtitle=htmlspecialchars($foruminfo[title]);
if ($foruminfo[active]==0) {
echo "<item><title>Forum Not Active</title></item></channel></rss>";
exit;
}
$description=htmlspecialchars($foruminfo[description]);
$forumtitle=htmlspecialchars($foruminfo[title]);
$threads=$DB_site->query("SELECT threadid,title,lastpost,replycount,postusername FROM thread WHERE forumid=$forumid ORDER BY lastpost DESC LIMIT 0,$perpage");
while ($thread=$DB_site->fetch_array($threads)) {
$threadtitle=htmlspecialchars($thread[title]);
$threadid=$thread[threadid];
$notes=htmlspecialchars($thread[notes]);
$replies=$thread[replycount];
$firstposter=htmlspecialchars($thread[postusername]);
$lastreplydate=date($dateformat,$thread[lastpost]+($timeoffset*3600));
$lastreplytime=date($timeformat,$thread[lastpost]+($timeoffset*3600));
echo "<item>\n";
echo "<title>$threadtitle</title>\n";
echo "<link>". $bburl ."/showthread.php?threadid=$threadid</link>\n";
echo "<description> $firstposter - $replies - $lastreplytime </description>\n";
echo "</item>\n";
}
?>
</channel>
</rss>
I built a PHP RSS library to include headlines from popular website into my homepage, it worked great and I used it to include my favourite sites slashdot, linuxtoday, and freshmeat of course ;)
but I needed to add my favourite bulletin board site that uses VB, and I searched for RSS support in VB, but I didn't find any, so I downloaded the lite version of VB and installed it, and after 3 hours I have my RSS hack for VB, and it works great, I tested it for the full version and it works fine there :)
I thought someone might be intersted on it, here is the code, it is a stripped down "forumdisplay.php" file with little changes to make it produce RSS file.
Put it in the same directory with "forumdisplay.php", and you call it in the same way "rss.php?forumid=1"
Hope you like it and use it :)
<?php echo '<?xml version="1.0"?>'; ?>
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"
"http://my.netscape.com/publish/formats/rss-0.91.dtd">
<rss version="0.91">
<channel>
<?php
echo "<!--\n";
require("global.php");
echo "-->\n";
echo "<title>$bbtitle</title>\n";
echo "<link>$bburl</link>\n";
// set defaults
if (isset($perpage)==0 or $perpage==0) {
$perpage=$maxthreads;
}
$forumid = verifyid("forum",$forumid);
$foruminfo=$DB_site->query_first("SELECT title,description,active FROM forum WHERE forumid=$forumid");
$forumtitle=htmlspecialchars($foruminfo[title]);
if ($foruminfo[active]==0) {
echo "<item><title>Forum Not Active</title></item></channel></rss>";
exit;
}
$description=htmlspecialchars($foruminfo[description]);
$forumtitle=htmlspecialchars($foruminfo[title]);
$threads=$DB_site->query("SELECT threadid,title,lastpost,replycount,postusername FROM thread WHERE forumid=$forumid ORDER BY lastpost DESC LIMIT 0,$perpage");
while ($thread=$DB_site->fetch_array($threads)) {
$threadtitle=htmlspecialchars($thread[title]);
$threadid=$thread[threadid];
$notes=htmlspecialchars($thread[notes]);
$replies=$thread[replycount];
$firstposter=htmlspecialchars($thread[postusername]);
$lastreplydate=date($dateformat,$thread[lastpost]+($timeoffset*3600));
$lastreplytime=date($timeformat,$thread[lastpost]+($timeoffset*3600));
echo "<item>\n";
echo "<title>$threadtitle</title>\n";
echo "<link>". $bburl ."/showthread.php?threadid=$threadid</link>\n";
echo "<description> $firstposter - $replies - $lastreplytime </description>\n";
echo "</item>\n";
}
?>
</channel>
</rss>