vBulletin - Show Guests / Members / Total People On...

Templates, scripts for templates, scripts and requests for templates.

Moderators: Moderators, Developers

Post Reply
Author
Message
Jas0n

vBulletin - Show Guests / Members / Total People On...

#1 Post by Jas0n » Wed Jan 01, 2003 7:57 pm

This is kind of cool thing I wrote for vBulletin, basically you can graph the amount of guests / members / total online.

You will need to put in your username, password, and the database name. I think it is pretty self explanatory.....

Code: Select all

<?
$numberguests = 0;
$numberregistered = 0;

$hostname = "localhost";
$username = "user";
$password = "pass";
$dbname   = "vbulletin";

// 900sec / 15min Timeout Session (should be the same as your setting in the vB options)
$datecut=time()-900;

$connection = mysql_connect($hostname,$password,$password) or die ("Cannot connect to server.");
$db = mysql_select_db($dbname,$connection) or die ("Could not select database.");

$sql = "SELECT COUNT(userid) AS sessions FROM session WHERE userid=0 AND lastactivity>$datecut";
$numberguest = mysql_result(mysql_query($sql, $connection), 0, "sessions");

$sql = "SELECT COUNT(DISTINCT userid) AS sessions FROM session WHERE userid>0 AND lastactivity>$datecut";
$numberregistered = mysql_result(mysql_query($sql, $connection),0,"sessions");

$totalonline = $numberregistered + $numberguest;

mysql_close($connection);

print "$numberguest $numberregistered $totalonline";
?>

Guest

#2 Post by Guest » Wed Jan 01, 2003 7:59 pm

Oops.. Forgot to include the Data Input Lines... Though I'm sure you could figure them out... here's mine just to see:

Name:
Get Forum Active Users

Input String:
<path_php_binary> -q <path_cacti>/scripts/forumusers.php

Output String:
<vbguest> <vbreg> <vbtotal>

kevin
Posts: 3
Joined: Mon Oct 07, 2002 9:37 pm

#3 Post by kevin » Tue Jan 07, 2003 8:32 pm

How hard would it be to add something to graph posts and new topics?

Guest

#4 Post by Guest » Tue Jan 07, 2003 10:48 pm

Not hard, just a simple sql query for each.... Do you mean just for the day, or total?

Guest

Re: vBulletin - Show Guests / Members / Total People On...

#5 Post by Guest » Thu Jan 09, 2003 11:05 pm

Jas0n wrote:This is kind of cool thing I wrote for vBulletin, basically you can graph the amount of guests / members / total online.

You will need to put in your username, password, and the database name. I think it is pretty self explanatory.....
<?
$numberguests = 0;
$numberregistered = 0;

$hostname = "localhost";
$username = "user";
$password = "pass";
$dbname = "vbulletin";

// 900sec / 15min Timeout Session (should be the same as your setting in the vB options)
$datecut=time()-900;

$connection = mysql_connect($hostname,$password,$password) or die ("Cannot connect to server.");
$db = mysql_select_db($dbname,$connection) or die ("Could not select database.");

$sql = "SELECT COUNT(userid) AS sessions FROM session WHERE userid=0 AND lastactivity>$datecut";
$numberguest = mysql_result(mysql_query($sql, $connection), 0, "sessions");

$sql = "SELECT COUNT(DISTINCT userid) AS sessions FROM session WHERE userid>0 AND lastactivity>$datecut";
$numberregistered = mysql_result(mysql_query($sql, $connection),0,"sessions");

$totalonline = $numberregistered + $numberguest;

mysql_close($connection);

print "$numberguest $numberregistered $totalonline";
?>
The red line above should be $username, $password

fyi.

tdavis
Posts: 6
Joined: Fri Mar 22, 2002 7:00 pm
Location: Tulsa, OK

#6 Post by tdavis » Mon Jan 27, 2003 1:36 pm

Anonymous wrote:Not hard, just a simple sql query for each.... Do you mean just for the day, or total?
For the day would be great!]

DavidM

PHPBB

#7 Post by DavidM » Sat Feb 08, 2003 9:17 pm

Anyone have this that can be used for PHPBB?

adrianmak
Posts: 7
Joined: Thu Jul 17, 2003 6:31 pm

#8 Post by adrianmak » Sun Jul 20, 2003 3:15 am

Now we have the data input source, how do we config cacti to use that source put it on graph ?

Sam Salonen
Posts: 7
Joined: Mon Feb 14, 2005 1:28 pm

Re: PHPBB

#9 Post by Sam Salonen » Wed Feb 16, 2005 2:59 am

DavidM wrote:Anyone have this that can be used for PHPBB?
I am also looking for a similar script for phpBB, does enybody have one to share?

Sam Salonen
Posts: 7
Joined: Mon Feb 14, 2005 1:28 pm

Re: PHPBB

#10 Post by Sam Salonen » Wed Feb 16, 2005 7:37 am

Sam Salonen wrote:I am also looking for a similar script for phpBB, does enybody have one to share?
Heres what I came up with for phpBB2, the problem is now to get cacti to create a graph based on the input...

Code: Select all

<?
// reset guests, registered and total
$guests     = 0;
$registered = 0;
$total      = 0;

// db connection 
$hostname = "hostname";
$username = "username";
$password = "password";
$dbname   = "dbname";

// define now - 5min
$datecut=time()-300;

// connect to database
$connection = mysql_connect($hostname,$username,$password) or die ("Cannot connect to server.");
$db = mysql_select_db($dbname,$connection) or die ("Could not select database.");

//count guest users online
$sql = "SELECT COUNT(session_logged_in) AS sessions FROM phpbb_sessions WHERE session_logged_in=0 AND session_time>$datecut";
$guests = mysql_result(mysql_query($sql, $connection), 0,"sessions");

// count registered users online
$sql = "SELECT COUNT(session_logged_in) AS sessions FROM phpbb_sessions WHERE session_logged_in>0 AND session_time>$datecut";
$registered = mysql_result(mysql_query($sql, $connection),0,"sessions");

// calculate teh total of users online
$total = $registered + $guests;

// close the db-connection
mysql_close($connection);

// generate the output
$output="" . $guests . ":" . $registered . ":" . $total . "";

// print the output (guests:registered:total)
echo "$output";
?>

Post Reply