hi everyone
can anybody help me telling that how can we know number of users online
thanx alot
Gaurav
whos online
Moderator: General Moderators
-
gaurav_sting
- Forum Newbie
- Posts: 19
- Joined: Sat Mar 27, 2004 3:45 am
- Location: Delhi
phpnuke?
by the time he finds it in there, he can make his own
soemthing like this....
make a table with these fields:
ID int, auto inc
ip varchar 20
stamp int 20
then, make a function which checks if user ip is in the database or not, and also it should delete any records older then 5 or so mins, i.e.
include this function on everypage.
by the time he finds it in there, he can make his own
soemthing like this....
make a table with these fields:
ID int, auto inc
ip varchar 20
stamp int 20
then, make a function which checks if user ip is in the database or not, and also it should delete any records older then 5 or so mins, i.e.
Code: Select all
<?php
function users_online()
{
$ip = $_SERVER['REMOTE_ADDR'];
$time = time();
$num = mysql_num_rows(mysql_query("select `ID` from TABLENAME where `ip` = '$ip' LIMIT 1"));
if($num != 1)
{
$query = mysql_query("INSET INTO TABLENAME VALUES ('','$ip','$time')");
}
$old = $time - 300//5 mins
$delete = mysql_query("DELETE from tablename where `stamp` <= '$old'");
//check number of users online...
$num = mysql_num_rows(mysql_query("select `ID` from TABLENAME"));
return $num;
}
?>