<?php
require("global.php");
$datecut=time()-900;
$loggedins=$DB_site->query_first("SELECT COUNT(sessionhash) AS sessions FROM ses
sion");
$totalonline=$loggedins[sessions];
$loggedins=$DB_site->query_first("SELECT COUNT(sessionhash) AS sessions FROM ses
sion WHERE userid=0 AND lastactivity>$datecut");
$numberguest=$loggedins[sessions];
$loggedins=$DB_site->query_first("SELECT COUNT(sessionhash) AS sessions FROM ses
sion WHERE userid<>0 AND lastactivity>$datecut");
$numberregistered=$loggedins[sessions];
$numbervisible=0;
$loggedins=$DB_site->query("SELECT DISTINCT session.userid,username,invisible FR
OM session LEFT JOIN user ON (user.userid = session.userid) WHERE session.userid
<> 0 AND session.lastactivity>$datecut order by invisible ASC, username ASC");
if ($loggedin=$DB_site->fetch_array($loggedins)) {
$numbervisible++;
$userid=$loggedin[userid];
$username=$loggedin[username];
$location=$loggedin[location];
eval("\$activeusers .= \"".gettemplate("forumhome_loggedinuser")."\";" );
while ($loggedin=$DB_site->fetch_array($loggedins)) {
$numbervisible++;
$userid=$loggedin[userid];
$username=$loggedin[username];
$location=$loggedin[location];
eval("\$activeusers .= \", ".gettemplate("forumhome_loggedinuser")."\";") ;
}
}
$numberinvisible=$numberregistered-$numbervisible;
eval("\$loggedinfront = \"".gettemplate("forumhome_loggedinusers")."\"; ");
echo "<div align=\"center\">";
echo "<table border=\"1\" width=\"100%\" bgcolor=\"#FFFF99\"><tr><td bgcolor=\"#
FFFF99\">";
echo "<p align=\"center\"><font color=\"black\" size=\"-1\"> Visit our <a hr
ef=\"forums/index.php\">forums!</a> Currently logged in users: ";
echo $activeusers;
echo ", and $numberguest guests. ";
echo "</td></tr></table></div>";
This -may not work-. I've tried it on my site, and I thought it worked, but it interfered with other areas of my site and I took it down until I can find the problem. I used that code on 1.1.x with no problems and did some quick/nasty hacks to get it to 2.0, I'm sure it could be better and there's probably some redundant code there, but hopefully it's a start for someone.
|