My friend made this hack, he owns
http://www.liquidpro.net. Check him out.
You may contact him at
liquidpro@neo.rr.com. Or you can IM him on AIM at LiquidPro10.
An example is shown at
http://www.xtreme-forumz.net. Go to the Techno forum under the General category. Then the CNET News sub-forum.
RSS News Feed Hack for vB 3.0.0 - RC2. As long as vBulletin doesn't change the database structure much, this should be good for the next release also, and those to come.
Allows you to have a live RSS news feed (such as one from Google or CNET) in a forum. The user that posts it will basically be a bot, which *should* only be used for posting the news, but you can even make it for a regular user.
Comments are welcome!
Instructons:
Note: DON'T FORGET TO MAKE A BACKUP OF EACH FILE BEFORE YOU MODIFY IT!
The first thing that you have to do is upload the modifyTable.php file into the root directory (the directory that includes the forumdisplay.php) file. The next thing that you need to do is run the rss_modifyTable.php file, which will modify your SQL tables in order to make it complient with the RSS News Bot. Once you have successfully modified your tables, you should now open up the forumdisplay.php file in a regular text editor (such as Notepad).
Find the following in the forumdisplay.php file
Note: On an unmodified forumdisplay.php file this will be at line 416
PHP Code:
// get announcements
$announcebits = '';
$announcements = $DB_site->query("
SELECT
announcementid, startdate, title, announcement.views,
user.username, user.userid, user.usertitle, user.customtitle
FROM " . TABLE_PREFIX . "announcement AS announcement
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = announcement.userid)
WHERE startdate <= " . TIMENOW . "
AND enddate >= " . TIMENOW . "
AND " . fetch_forum_clause_sql($foruminfo['forumid'], 'forumid') . "
ORDER BY startdate DESC
" . iif($vboptions['oneannounce'], "LIMIT 1"));
while ($announcement = $DB_site->fetch_array($announcements))
{
if ($announcement['customtitle'] == 2)
{
$announcement['usertitle'] = htmlspecialchars_uni($announcement['usertitle']);
}
$announcement['postdate'] = vbdate($vboptions['dateformat'], $announcement['startdate']);
if ($announcement['startdate'] > $lastread)
{
$announcement['statusicon'] = 'new';
}
else
{
$announcement['statusicon'] = 'old';
}
$announcement['views'] = vb_number_format($announcement['views']);
$announcementidlink = iif(!$vboptions['oneannounce'] , "&announcementid=$announcement[announcementid]");
eval('$announcebits .= "' . fetch_template('forumdisplay_announcement') . '";');
}
Once you have found that, put this immediately following it.
PHP Code:
// RSS News Feed Hack
// ------------------------------
// By: Andrew Wickham of
// LiquidPro Inc.
//
// get the rss settings
include("includes/rss_config.php");
// get the bot`s username
$rss_user_query = $DB_site->query("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = '$rss_userid'");
$rss_user_data = $DB_site->fetch_array($rss_user_query);
$rss_username = $rss_user_data['username'];
$rss_posts = $rss_user_data['posts'];
// display threads
if($forumid == $rss_forumid) {
$rss_data = implode("",file($rss_source));
// include the RSS class
include($rss_pathToClass . "/class.RSS.php");
$rss = new RSS($rss_data, 1);
$rss_allItems = $rss->getAllItems();
// check and see what items are in the database, and mark the old ones as old
$rss_query = $DB_site->query("SELECT * FROM " . TABLE_PREFIX . "thread WHERE rss_feed = '1'");
for($i = 0; $i < count($rss_allItems); $i++) {
$rss_allItems[$i]['OLD'] = true;
}
// if there's no items in the database
if($DB_site->num_rows($rss_query) == 0) {
for($i = 0; $i < count($rss_allItems); $i++) {
$rss_allItems[$i]['OLD'] = false;
}
}
// filter out the old items
while($rss_thread_data = $DB_site->fetch_array($rss_query)) {
for($j = 0; $j < count($rss_allItems); $j++) {
if($rss_thread_data['title'] == $rss_allItems[$j]['TITLE'] &&
$rss_thread_data['rss_date'] == $rss_allItems[$j]['pubDate']) {
$rss_allItems[$j]['OLD'] = true;
}
}
}
// insert the new items into the database
for($j = 0; $j < count($rss_allItems); $j++) {
if(!$rss_allItems[$j]['OLD']) {
// update the user profile
$rss_posts++;
$rss_title = $rss_allItems[$j]['TITLE'];
$rss_dateline = $rss_allItems[$j]['pubDate'];
$current_dateline = time();
$rss_description = $rss_allItems[$j]['DESCRIPTION'];
$rss_description .= "<br><br>[url="http://.%20$rss_allitems[$j]['link']%20./"]View the Entire Article[/url]\n";
$rss_title = str_replace("'", "\'", $rss_title);
$rss_description = str_replace("'", "\'", $rss_description);
// get the next available threadid
$rss_threadid_query = $DB_site->query("SELECT * FROM " . TABLE_PREFIX . "thread ORDER BY threadid DESC");
$rss_threadid_data = $DB_site->fetch_array($rss_threadid_query);
$rss_threadid = $rss_threadid_data['threadid'] + 1;
// get the next available postid
$rss_postid_query = $DB_site->query("SELECT * FROM " . TABLE_PREFIX . "post ORDER By postid DESC");
$rss_postid_data = $DB_site->fetch_array($rss_postid_query);
$rss_postid = $rss_postid_data['postid'] + 1;
$DB_site->query("INSERT INTO " . TABLE_PREFIX . "post (`threadid`, `username`, `userid`, `title`, `dateline`, `pagetext`, `allowsmilie`, `showsignature`, `visible`) VALUES ('$rss_threadid', '$rss_username', '$rss_userid', '$rss_title', '$current_dateline', '$rss_description', '1', '1', '1')");
$DB_site->query("INSERT INTO " . TABLE_PREFIX . "thread (`title`, `forumid`, `firstpostid`, `lastpost`, `open`, `postusername`, `postuserid`, `lastposter`, `dateline`, `visible`, `rss_feed`, `rss_date`) VALUES ('$rss_title', '$rss_forumid', '$rss_postid', '$current_dateline', '1', '$rss_username', '$rss_userid', '$rss_username', '$current_dateline', '1', '1', '$rss_dateline')");
}
}
// update the posts in the database
$DB_site->query("UPDATE " . TABLE_PREFIX . "user SET posts = '$rss_posts' WHERE userid = '$rss_userid'");
}
//
// ------------------------------
// End of RSS News Hack
Save your forumdisplay.php file
Open the rss_config.php file included with this zip, and edit the settings to your likings. Make sure you create the specified user or you'll have some major problems.
Copy the rss_config.php file to the "includes" directory on your server.
That's it for the hacking! For the thread you put this hack on, I suggest that you have it so that users other than the bot can't post new threads, only post replies. That way they can post comments on the news feed.
Hack by: Andrew Wickham (
http://www.liquidpro.net)
Hack for: Xtreme-Forumz (
http://www.xtreme-forumz.net)