Quantcast
Channel: MyBB Community Forums - Tutorials
Viewing all articles
Browse latest Browse all 685

Today's Statistics

$
0
0
Just a simple tutorial on how to output the today's stats that's been made (posts, threads, registrations & active users).

1. Open up index.php and find this code

Code:
if($mybb->user['uid'] != 0)
{
   eval('$logoutlink = "'.$templates->get('index_logoutlink').'";');
}

2. After that code, add


Code:
//Gets new posts today.
   $timecut = TIME_NOW - 86400;

   $query = $db->simple_select("posts", "COUNT(*) AS newposts", "dateline > '$timecut' AND visible='1'");
   $newposts = my_number_format($db->fetch_field($query, "newposts"));

   
   //Gets new threads today.
   $timecut = TIME_NOW - 86400;

   $query = $db->simple_select("threads", "COUNT(*) AS newthreads", "dateline > '$timecut' AND visible='1' AND closed NOT LIKE 'moved|%'");
   $newthreads = my_number_format($db->fetch_field($query, "newthreads"));
   
   
   //Gets new users today.
   $timecut = TIME_NOW - 86400;

   $query = $db->simple_select("users", "COUNT(uid) AS newusers", "regdate > '$timecut'");
   $newusers = my_number_format($db->fetch_field($query, "newusers"));
   
   //Gets total active users today.
   $timecut = TIME_NOW - 86400;

   $query = $db->simple_select("users", "COUNT(uid) AS activeusers", "lastvisit > '$timecut'");
   $activeusers = my_number_format($db->fetch_field($query, "activeusers"));

3. Now you can output these in the index template like this:


Code:
{$newposts} New posts
{$newthreads} New threads
{$newusers} New users
{$activeusers} Active users


I hope you enjoyed the simple tutorial.  Toungue

Viewing all articles
Browse latest Browse all 685

Trending Articles