Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 06:09 pm EDT

A Major Recent Topics phpblock Fix :)

  • Wednesday, July 10 2002 @ 04:22 pm EDT
  • Contributed by: Anonymous
  • Views: 4,880
Announcements Recently someone posted on here that they had a phpblock that would display the recent topics of their mesabe board from phpBB...well, after much rewriting, and HUGE THANKS to MrFixit, a good friend from UOXDEV , we were able to crack it and make it work!!! Here is the updated code... the only things you really need to change are the host, database name, usually phpBB for phpBB boards by default, logically ;) , and the username and pass for the mysql server.

HERES THE CODE :)
//TESTING
function phpblock_phpbb2recent() {

// You MUST copy the following 4 variables from your config.php file in your phpbb2 install
$dhhost = \"localhost\";
$dbname = \"phpBB\";
$dbuser = \"name\";
$dbpasswd = \"pass\";

$urlPath = \"http://yoursitehere/phpBB2\";
$PostNumber = \"5\";
$type = \"posts\";
$length = \"12\";

$db = @mysql_connect($dbhost, $dbuser, $dbpasswd);

@mysql_select_db($dbname,$db);
if ($db == \"\") {
die(\"Failed to connect to server! YOUR SCREWED!!\");
}

// Get data
if($type == \"posts\") {
$sql = \"SELECT * FROM phpbb_topics ORDER BY topic_time DESC LIMIT 5;\"; //note phpbb_topics in this case worked for me seeing as how thats where the correct tables were...you will have to find and change this as necessary for it to work for you.

} else {
$sql = \"SELECT * FROM phpbb_topics ORDER BY topic_time DESC LIMIT 5;\";
}
$r = mysql_query($sql, $db);

if ($r == FALSE) {
die(\"Unable to get data!\");
}

// Display data
$rows = mysql_num_rows($r);


for ($row_number = 0; $row_number <= $rows - 1; $row_number++) {
$topic_title = mysql_result($r, $row_number, \"topic_title\");
$topic_title = stripslashes($topic_title);
$k = substr($topic_title, 0, $length) . \"...\";
$topic_id = mysql_result($r, $row_number, \"topic_id\");

$forum_id = mysql_result($r, $row_number, \"forum_id\");

$recent .= \"<li><a title=\'\" . $topic_title . \"\' class=\'forum\' href=\'\" . $urlPath . \"/viewtopic.php?t=\" . $topic_id . \"&sid=\" . $forum_id . \"\'>$k</a></li>\";

}

return $recent;

}
//end testing