Version: , by Marshalus
Developer Last Online: Jul 2020
Version: Unknown
Rating:
Released: 10-29-2002
Last Update: Never
Installs: 0
No support by the author.
OK, I digging though the bowels of the site, and stumbled apon a RSS feed hack that will pull the most recent threads from a forum you specify, and deliver them up in RSS format.
What I want to do, instead of having to specify the forum, is just have it dish out the latest threads from all forums.
Here is what I have to work with:
Code:
<?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>
This would be very useful for programs like Trillian that can pull RSS news feeds, or for syndicating your latest threads on other websites.
Any help would be appreciated.
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
I worked a little with you code Marshalus.
What had to be changed was the query to grab the latest active threads. My query shows only threads from non-private forums.
Then I added a replacement for german umlauts because Trillian doesn't show them correct.
You can tweak a lot to customize it further and for example insert some text from the latest post. But then you have to change the query.
PHP Code:
<?php
require("global.php");
//##############################################
// Variables used:
$description = "The latest active threads";
$replyword = "Replies";
$showthreadnumber = "15"; // show this many threads in the newsfeed
//##############################################
$threads=$DB_site->query("SELECT threadid,title,lastpost,replycount,postusername,thread.forumid
FROM thread
LEFT JOIN forumpermission USING(forumid)
WHERE visible=1
AND forumpermission.forumid IS NULL
ORDER BY lastpost DESC LIMIT ".$showthreadnumber);
while ($thread=$DB_site->fetch_array($threads)) {
I found out that Pogo's code has a weird bug: as soon as someone starts a poll thread, the RSS script shows already the threadtitle and link, which results in a url which does not exist, as long as the creation of the poll isn't finished
Originally posted by PeterNRG I found out that Pogo's code has a weird bug: as soon as someone starts a poll thread, the RSS script shows already the threadtitle and link, which results in a url which does not exist, as long as the creation of the poll isn't finished
It is not a weird bug it is just how vBulletin works. Just created threads with the option to add a poll are invisible as long as the poll is not set up.
Now I added visible=1 AND to the query and such threads are not shown anymore.
To not include the last reply line you can change the code like this:
Thanks for all your help so far pogo. I have another issue which is giving me headaches: I have an announcement forum, where only admins can start new posts (being custom set with vB's forum permissions), members can reply though.
For some reason, with your code, the new announcement headlines do not show up in our RSS feed. I guess it has to do with the forumpermission in the query. Can someone help me out on that?
SELECT threadid,title,lastpost,replycount,postusername,thread.forumid
FROM thread
LEFT JOIN forumpermission USING(forumid)
WHERE visible=1
AND (forumpermission.forumid IS NULL OR forumpermission.canview=1)
ORDER BY lastpost DESC LIMIT