Log in

View Full Version : Online in the Header


speedway
02-01-2006, 04:06 AM
Hi all

I am lookign for updated code to display online info in the header. Prior to uprgading to 3.5, I had this code in phpinclude_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];
$headeronline=$headerguests+$headerusers;

This code fails in 3.5.

Can anyone point me to the correct implementation now the code base has changed. My users are missing this...

Thanks

Cheers

Figured it out...

Created a plugin using the global_start hook and out this in the plugin code:

$hdr_datecut = TIMENOW - $vbulletin->options['cookietimeout'];
$hdr_guestsarry = $db->query_first("SELECT COUNT(host) AS sessions FROM " . TABLE_PREFIX . "session WHERE userid = 0 AND lastactivity > $hdr_datecut");
$hdr_membersarry = $db->query_read("SELECT DISTINCT userid FROM " . TABLE_PREFIX . "session WHERE userid <> 0 AND lastactivity > $hdr_datecut");
$hdr_guests = intval($hdr_guestsarry['sessions']);
$hdr_members = intval($db->num_rows($hdr_membersarry));
$hdr_online = ($hdr_guests + $hdr_members);

I then called the 3 $hdr_ variables in my header and bingo! Online Users in the header.

Cheers
Bruce

Edit: What's this "auto merge" thing? I replied to my own post, why was it merged? For some reason the "auto merge" thingie called it a double up