Create a file named stats.php. insert the following lines:
PHP Code:
<?php
// Boardstatistics scripted by Znaper (e-mail: [email]webmaster@znapers-board.de[/email])
require('./global.php');
// get total members
$numbersmembers=$DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user');
$numbermembers=$numbersmembers['users'];
// get active members
$snonposters=$DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user WHERE posts=0');
$nonposters=$snonposters['users'];
$activemembers=$numbermembers-$nonposters;
$activityrate=sprintf("%.2f",(100*$activemembers/$numbermembers));
// get total posts
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts=$countposts['posts'];
// get total threads
$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');
$totalthreads=$countthreads['threads'];
// get total thread views
$boardviews = $DB_site->query_first("SELECT SUM(views) AS threadviews FROM thread");
$totalviews = $boardviews[threadviews];
// get total pms
$totalpms = $DB_site->query_first("SELECT count(*) as pmcount FROM privatemessage");
$totalpm = $totalpms[pmcount];
// thanks to AA for the following lines:
// get Top 10 Posters of the last 30 days
if (isset($days)==0 and $days==0) { $days=30; }
$datecut=time()-($days*86400);
$posts=$DB_site->query("SELECT DISTINCT(userid),COUNT(postid) AS posts
FROM post
WHERE userid > 0 AND post.dateline>=$datecut GROUP BY userid
ORDER BY posts DESC
LIMIT 10");
while ($user=$DB_site->fetch_array($posts)) {
$result=$DB_site->query_first("SELECT username
FROM user
WHERE userid=$user[userid]");
$topposters.="<tr><td><a href=\"member.php?action=getinfo&userid=$user[userid]\">$result[username]</a></td><td>$user[posts]</td></tr>";
}
// thanks to AA for the following lines:
// get Top 10 Posters of the last 24 hours
if (isset($days2)==0 and $days2==0) { $days2=1; }
$datecut2=time()-($days2*86400);
$posts2=$DB_site->query("SELECT DISTINCT(userid),COUNT(postid) AS posts
FROM post
WHERE userid > 0 AND post.dateline>=$datecut2 GROUP BY userid
ORDER BY posts DESC
LIMIT 10");
while ($user2=$DB_site->fetch_array($posts2)) {
$result2=$DB_site->query_first("SELECT username
FROM user
WHERE userid=$user2[userid]");
$toplastposters.="<tr><td><a href=\"member.php?action=getinfo&userid=$user2[userid]\">$result2[username]</a></td><td>$user2[posts]</td></tr>";
}
$co="Statistics-Hack ? 2001 by <a href=\"mailto:webmaster@znapers-board.de\">Znaper</a>, thanks to AA";
$templatesused = "";
// Only one template is used so load it when called
eval("dooutput(\"".gettemplate("boardstatistics")."\");");
// free used memory
unset($user);
$DB_site->free_result($posts);
unset($user2);
$DB_site->free_result($posts2);
?>
Save this file the root directory of your board.
Next create a template namend boardstatistics. Insert the following lines into the template:
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>