Hello,
I am currently trying to syndicate news from a certain forum. Take a look at my script (yes, I do have my own db class):
PHP Code:
include './functions.php';
// start connection
$db_host = "localhost";
$db_user = "haha";
$db_pass = "haha";
$db_name = "haha";
$db = new db;
$db->connect($db_host, $db_user, $db_pass, $db_name);
// which forum id should news be displayed from?
define("FORUMID", "2");
// enter prefix of your tables here (blank by default)
define("PREFIX", "", true);
// define how many number of articles you wish to display
define("AMOUNT", "10");
// run the query
$query_sel_news = $db->query("select t.*,p.pagetext from ".PREFIX."thread t left join ".PREFIX."post p on(p.postid=t.firstpostid) where t.forumid = ".FORUMID." order by dateline desc limit 0,".AMOUNT."");
// display the results and replace a few things... err.
while($r = $db->fetch_array($query_sel_news)) {
// our (simple) bbcode
$bbcode = array("[B]", "[/B]", "[b]", "[/b]", "[I]", "[/I]", "[i]", "[/i]", "[U]", "[/U]", "[u]", "[/u]", "[img]https://vborg.vbsupport.ru/[/img]", "[img]https://vborg.vbsupport.ru/[/img]", "[center]", "[/center]", "[CENTER]", "[/CENTER]");
// our html code :D
$htmlcode = array("<B>", "</B>", "<b>", "</b>", "<I>", "</I>", "<i>", "</i>", "<U>", "</U>", "<U>", "</U>", "<img src=\"", "\">", "<img src=\"", "\">", "</p><p align=center>", "</p><p>", "</p><p align=center>", "</p><p>");
// do the replacing
$pagetext = str_replace($bbcode, $htmlcode, $r[pagetext]);
// make it so there are LINE BREAKS ;o
$pagetext = nl2br($pagetext);
echo "<h2>".$r[title]."</h2><h3>".date("F jS, g:i A, Y", $r[dateline])."</h3><p>".$pagetext."</p><div id=\"content_left_news\">posted by ".$r[postusername]." | <a href=/forums/showthread.php?t=".$r[threadid].">comments (".$r[replycount].")</a> | <a href=/forums/showthread.php?t=".$r[threadid].">permalink</a></div>";
}
$db->close();
Ergh, but it's absolutely insane working with the freakin' bbcode. I've looked at
this tutorial, but you see, I am selecting news from an "out-of-vbulletin" page (my main site index page). So, how can I get vB's bbcode parser on my index page to parse this text ($row[pagetext]).