PHP Code:
<?php
error_reporting(7);
chdir('/home/USERNAME/public_html/forums');
require('./global.php');
###########
## Stats ##
###########
////Get number of members
//$totalmembers
$numbersmembers=$DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user');
$totalmembers = number_format($numbersmembers['users']);
////Get total number of posts
//$totalposts
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts = number_format($countposts['posts']);
////Get total number of threads
//$totalthreads
$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');
$totalthreads = number_format($countthreads['threads']);
////Get username and id of newest member
//$newestuser[user]
//$newestuser[id]
$newestuser=$DB_site->query_first("SELECT userid,username FROM user WHERE userid=$numbersmembers[max]");
$newestuser[user] = unhtmlspecialchars($newestuser['username']);
$newestuser[id] = unhtmlspecialchars($newestuser['userid']);
////Get username, id, post count, and post percent of top poster
//$top[user]
//$top[id]
//$top[count]
$topposter=$DB_site->query_first('SELECT userid,username,posts FROM user ORDER BY posts DESC LIMIT 10');
$top[user] = unhtmlspecialchars($topposter['username']);
$top[id] = unhtmlspecialchars($topposter['userid']);
$top[count] = number_format($topposter['posts']);
###################
## Testing Stats ##
###################
echo "<font face=arial>";
echo "Total Members: "."<b>$totalmembers</b>";
echo "<BR>";
echo "Total Posts: "."<b>$totalposts</b>";
echo "<BR>";
echo "Total Threads "."<b>$totalthreads</b>";
echo "<p>";
echo "Newest User Username: "."<b>$newestuser[user]</b>";
echo "<BR>";
echo "Newest User ID: "."<b>$newestuser[id]</b>";
echo "<p>";
echo "Top Poster Username: "."<b>$top[user]</b>";
echo "<BR>";
echo "Top Poster ID: "."<b>$top[id]</b>";
echo "<BR>";
echo "Top Poster Count: "."<b>$top[count]</b>";
echo "<p><br>";
#########################
## Latest Forum Topics ##
#########################
echo "Last 5 Thread Postings:<p>"; //Seperate from Stat Display
$maxthreadchars = "30";
$threads=$DB_site->query("SELECT threadid,thread.title,replycount,postusername,postuserid,dateline,views,lastposter,lastpost FROM thread ORDER BY lastpost DESC LIMIT 5");
while ($thread=$DB_site->fetch_array($threads))
{
$lastposttime = vbdate("$timeformat $dateformat",$thread['lastpost']);
$title = unhtmlspecialchars($thread['title']);
if (strlen($thread['title'])>"$maxthreadchars" AND $maxthreadchars!='0')
{
$title = substr($thread['title'], 0, $maxthreadchars - 3) . '...';
}
$thread['date'] = vbdate("$dateformat $timeformat", $thread['dateline']);
?>
<table bordercolor="#000000" border="1" cellspacing="0" cellpadding="3">
<tr>
<td>
<B><? echo $title; ?></B>
</td>
</tr>
<tr>
<td>
<font size="-1">
Reply Count: <B><? echo $thread['replycount']; ?></B><br>
Thread Starter: <B><? echo $thread['postusername']; ?></B><br>
Total Views: <B><? echo $thread['views']; ?></B><br>
Last Poster: <B><? echo $thread['lastposter']; ?></B><br>
Thread Date: <B><? echo $thread['date']; ?></B><br>
</font>
</td>
</tr>
</table><p>
<?
}
$DB_site->free_result($threads);
unset($thread);
?>
Compatible with 2.x, Use whatever you'd like from it.. I was bored, output viewable at
http://www.mesopia.com/vbstats.php
Regards,
Patrick