View Full Version : How to get whos online and stats on forum pages
JohnBee
05-11-2005, 07:58 PM
I know this is a weird request...
And I won't go into a long (long) story on why I would want to do this so
heres the short version.
Custom footer accross my entire site, in the footer are my who's online and
membership stats showing on ever page CMS, FORUM, POSTBIT etc..
I have the footer designed and the default bits from vBa sort of work
but when I get into the posting forumdisplay area etc. the functionality
is lost.
What would I have to do to get those features to display anywheres on
my forum/ site?
* Could I use a PHP includes function?
Brian
05-11-2005, 08:40 PM
Your probably going to have to copy the relevant code from each file into your forum/global.php file in order for it to be executed.
JohnBee
05-11-2005, 08:55 PM
Okay.
If I did that then I could then use the variables in my footer anywheres
within my forum pages?
JohnBee
05-12-2005, 07:20 AM
Where do I place the code in global.php
Do I put the entire thing? (minus) the <?php and ?>
I have an external who's online and statistics .php file that seems to work
nicely but when I tried to use and include function <include> it would
not work :(
Is there a special function to include a .php files output in vBul.?
JohnBee
05-12-2005, 07:51 AM
Someone over at vb.org has this idea.
Do this:
In template "phpinclude_start"
Add:
// forum stats start
$numbersmembers=$DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user');
$numbermembers=number_format($numbersmembers['users']);
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts=number_format($countposts['posts']);
$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');
$totalthreads=number_format($countthreads['threads']);
// forum stats end
// total online start
$datecut = TIMENOW - $vboptions['cookietimeout'];
$headerguests=$DB_site->query_first("SELECT COUNT(*) AS count FROM session WHERE userid=0 AND lastactivity>$datecut");
$headerusers=$DB_site->query_first("SELECT COUNT(DISTINCT(userid)) AS count FROM session WHERE session.userid>0 AND session.lastactivity>$datecut");
$headerguests=$headerguests[count];
$headerusers=$headerusers[count];
$totalonline=$headerguests+$headerusers;
// total online end
Then use $numbermembers, $totalposts, $totalthreads, $totalonline in the header template for the Total Number of post, threads, members, and total number of who is online.
This does seem to work but it doesn't show:
members name in the who's online list, latest registered member and top poster.
JohnBee
05-12-2005, 09:21 AM
alright, I have found these queries I believe they will display the missing information
to complete the footer online/stats hack.
$topposters=$DB_site->query_first("SELECT username,posts,userid FROM user ORDER BY posts desc LIMIT 1");
$toptstarter=$DB_site->query_first("SELECT COUNT(*) AS count,postuserid,postusername FROM thread GROUP BY postuserid ORDER BY count DESC LIMIT 1");
$getnewestusers=$DB_site->query_first("SELECT userid,username FROM user ORDER BY joindate DESC LIMIT 1");
$newusername=$getnewestusers['username'];
However in there current state they do not work, can someone help me
make them work along with the php_include_start code block?
cdembek
02-11-2006, 11:09 PM
I am looking how to do this also.. anyone?
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.