Jump to content
xisto Community
jlhaslip

[phpbb] Member Last-visit Report Script for phpbb2 databases

Recommended Posts

One flaw in the phpbb2 administration section is a report to list out the 'last-visit' time/date of the membership.I wrote a script to do exactly that and will be sharing the script with you here.the first section defines the variables required for the Database connection, finding the right database, supplying passwords, etc.

<?phpDEFINE ('DB_USER', 'YOUR DB USER NAME'); // change these defined values to suit your own situationDEFINE ('DB_PASSWORD', 'YOUR DB PASSWORD');DEFINE ('DB_HOST', 'localhost');DEFINE ('DB_NAME', 'YOUR DB NAME');$dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() );// Select the database.mysql_select_db (DB_NAME) OR die ('Could not select the database: ' . mysql_error() );

This next section has to do with defining the Mysql Query to use the correct table and fields within the database.Note that this example includes the default 'prefix' for the datasets (tables), being "phpbb_".

// Make the query.$query = "SELECT `username` , FROM_UNIXTIME(`user_lastvisit`) as last FROM `phpbb_users` ORDER BY `user_lastvisit` ASC ";		// Run the query.$result = mysql_query ($query);

The following section outputs the information into a table and closes out the connection to the database. Since the data is 'table-based', ie: cames from a Database, a tabled output is semantically correct, so I will use it here.

// Table header.echo '<table align="center" cellspacing="0" cellpadding="5" summary="Table of Registered Users" ><tr>	<td align="left"><b>Name</b></td>	<td align="left"><b>Last Seen Date</a></b></td></tr>';// Fetch and print all the records.$bg = '#eeeeee'; // Set the background color.while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {	$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color.	echo '<tr bgcolor="' . $bg . '">		<td align="left">' . $row['username'] . '</td>		<td align="left">' . $row['last'] . '</td>	</tr>	';}echo '</table>';mysql_free_result ($result); // Free up the resources.	mysql_close(); // Close the database connection.?>

Simply Cut and Paste all of the above code snippets into one single file (ie: member_last.php), upload it to your Hosting service and visit the link to the file in your favourite browser to view the last-visited dates for all of your members.Pagination would be a nice feature to add to this script if you have lots of members. I will leave that to you.Also, the Database information could be seperated from thew script file and be placed 'above' the public_html folder so that it can not be referenced directly from the 'net, but those are best left to another Tutorial.I have a 'PRIVATE' phpbb2 Forum, so I do not have a Demo site available for you to test, but for those of you who do have a phpbb2 Forum, and want to see the Last-visit dates for the membership, this simple script will do that for you.Hope this helps someone, and pm me or reply to this thread if you need assistance.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.