The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
News Feed
For 3.0.x I ran this script fine, however with my latest upgrade to 3.5.x it seemed to stop functioning. I'm hoping someone could update this script to work again. Basically it fetches all the latest posts made in a specific forum and then outputs the info onto a non-vb page.
Since upgrading I get this error: Quote:
Code:
<?php // See bottom for more instructions. // We need vB global for bbcode parsing. // This scripts needs to be in the forums directory or you need to uncomment the chdir // lines (and edit them). // chdir("/path/to/forums/"); require_once("./global.php"); // chdir("/path/to/this/script"); // VARIABLES TO SET // hostname or ip of server $servername="localhost"; // username and password to log onto db server $dbusername="***"; $dbpassword="***"; // name of database $dbname="***"; //path to your forums $forumspath = "***"; function writenews($cats, $filetw, $newsitems=7){ global $servername; global $dbusername; global $dbpassword; global $dbname; global $forumspath; //Connect to the database $connection = mysql_connect("$servername","$dbusername","$dbpassword") or die ("Cannot connect to server."); $db = mysql_select_db("$dbname", $connection) or die ("Could not select database."); //Create SQL statement this gets the title poster and other bits $sql = "SELECT threadid, title, forumid, replycount, postusername, postuserid, lastposter, dateline, iconid FROM thread WHERE forumid IN ($cats) AND sticky = '0' ORDER BY threadid DESC LIMIT $newsitems"; //execute sql query $sql_result = mysql_query($sql, $connection) or die ("Could not execute query."); if (!$sql_result) { echo "Could not get news."; } while ($row = mysql_fetch_array($sql_result)) { $threadid = $row["threadid"]; $title = $row["title"]; $forumid = $row["forumid"]; $replycount = $row["replycount"]; $postusername = $row["postusername"]; $postuserid = $row["postuserid"]; $lastposter = $row["lastposter"]; $iconid = $row["iconid"]; $dateline = $row["dateline"]; //create the second SQL statement to pull the post from the thread it resides in $sql2 = "SELECT postid, threadid, username, userid, title, dateline, pagetext, iconid FROM post WHERE threadid = \"$threadid\" ORDER BY postid ASC LIMIT 1"; //This gets the text of the post $sql_result2 = mysql_query($sql2, $connection) or die ("Could not execute query in second sql statement."); if (!$sql_result2) { echo "Could not get news."; } while ($row2 = mysql_fetch_array($sql_result2)) { $ptext = $row2["pagetext"]; //Convert time $dateposted = date("D j M Y, g:i A",$dateline); //Comments or comment depending on number of replies if ($replycount==1) { $commenttext = "Comment"; } else { $commenttext = "Comments"; } // This parses the bbcode require_once("./includes/functions_bbcodeparse.php"); $outxt=parse_bbcode2($ptext,"1","1","1","1","1"); // Uncomment next 4 lines if you want to limit the amount of text displayed to the first paragraph. // $trimmed = explode("<br />", $outxt); //$outxt=$trimmed[0]; //$trimmed = explode("</p>", $outxt); //$outxt=$trimmed[0]; $outxt=substr($outxt,0,100000); // This is optional. It strips out unecessary tags if you wish and leaves those specified behind // $outxt = strip_tags($outxt, '<a>,<b>,<strong>,<i>,<em>,<br />,<br>,<p>'); // This sql gets the title of the forum $sql3 = "SELECT title FROM forum WHERE forumid = \"$forumid\" LIMIT 1"; $sql_result3 = mysql_query($sql3, $connection) or die ("Could not execute query in second sql statement."); $row3 = mysql_fetch_array($sql_result3); $forumname = $row3["title"]; //EDIT the HTML OUTPUT HERE $towrite .= " <table width=\"474\" height=\"56\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"> <tr> <td height=\"33\" valign=\"top\" class=\"text\"><font class=\"news\">$title</font><br> <span class=\"text style5\">$dateposted | <span class=\"text style5\"><a href=\"$forumspath/member.php?s=&action=getinfo&userid=$postuserid\"><b>$postusername</b></a></span> | <span class=\"text style5\"><a href=\"$forumspath/showthread.php?s=&threadid=$threadid\">$replycount $commenttext</a></span></span></td> </tr> <tr> <td height=\"13\" class=\"text\">$outxt</td> </tr> <tr> <td height=\"10\" class=\"text\"> </td> </tr> </table> "; // END HTML EDIT } } //disconnect //mysql_free_result($sql_result); //mysql_close($connection); // If you want to wite out to a file - good idea to reduce db load // Then uncomment this section and edit appropriately. You need // to have a folder to stores the output file and they need to writeable (chmod 666) // $filetw is name of output file. // You may then want to call this file by cron so thing update reguarly. //$tmpfile = fopen("/path/to/storafe/folder/".$filetw."","w+"); //$fp = fwrite($tmpfile,$towrite); //fclose($tmpfile); //flush (); // If you are writing to a file comment the line below out. echo $towrite; } // This calls the writenews function. Done as a function so can be called multiple times. // First variable is forum id to get news from. One forum is like 1 and multiple forums // like 1,2,3. Output file onyl applies if you are outputting a file (see just above) // The last variable is the number of news itmes to grab / display. Deafults to 10. @writenews("2,60", "outputfile.txt","15"); // Want another write out (useful for files etc?) just call function again as below // @writenews("16,17", "outputfile.txt","10"); ?> |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|