Skip to content

Instantly share code, notes, and snippets.

@Rivkah
Created January 21, 2012 07:01
Show Gist options
  • Save Rivkah/1651843 to your computer and use it in GitHub Desktop.
Save Rivkah/1651843 to your computer and use it in GitHub Desktop.
Latest Posts for phpBB 3
<?php
//Config for Connection and Reporting Limit
$Config['Host'] = 'localhost'; // MySQL Host
$Config['User'] = 'root'; // MySQL Username
$Config['Pass'] = ''; // MySQL Password
$Config['Data'] = 'forums'; // MySQL Forum Database
$Config['Pfix'] = 'phpbb_'; // Prefix of the forums tables (Default: phpbb_)
$Config['LimN'] = 5; // Maximum Report Limit
$Config['Link'] = '../../forums'; // Folder where the forums are
$Config['Date'] = 'M j, Y @ g:i a'; // Default: 'M j, Y @ g:i a'
// For a list of how the date/time can be formatted, go here: http://php.net/manual/en/function.date.php
// Disable error reporting, to keep error message clean.
error_reporting(0);
// Connect to MySQL Server
mysql_connect($Config['Host'], $Config['User'], $Config['Pass']) or die ("Error 1, Please report this to the dev team!");
// Query the Server's Database for Post ID, Forum ID, and Post Subject. Ordered by Post time (Descending). Limit is set through $Config['LimN']
$result = mysql_query('SELECT post_id, topic_id, forum_id, poster_id, post_time, post_subject FROM '.$Config['Data'].'.'.$Config['Pfix'].'posts ORDER BY post_time DESC LIMIT '.$Config['LimN']) or die ("Error 3, Please report this to the dev team!");
// Print out the Results, 1 by 1.
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $user_q = mysql_query('SELECT username FROM '.$Config['Data'].'.'.$Config['Pfix'].'users WHERE user_id = '.$row['poster_id']) or die("Error 4, Please report this to the dev team!");
$user_r = mysql_fetch_assoc($user_q) or die("Error 5, Please report this to the dev team!");
$Output['Topc'] = '<a href="'.$Config['Link'].'/viewtopic.php?f='.$row['forum_id'].'&t='.$row['topic_id'].'&p='.$row['post_id'].'#p'.$row['post_id'].'">'.$row['post_subject'].'</a>';
$Output['User'] = '<a href="'.$Config['Link'].'/memberlist.php?mode=viewprofile&u='.$row['poster_id'].'">'.$user_r['username'].'</a>';
$Output['Date'] = gmdate($Config['Date'],$row['post_time']);
// Please edit from here untill it says stop to change how it looks.
echo $Output['Topc'].'<br />';
echo ' Posted by '.$Output['User'].' on '.$Output['Date'];
echo '<br /><br />';
// Stop here :)
}
// Close the MySQL Connection, duh!
mysql_close($mysql_conn);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment