<?php
include_once('db.php');

//Fetch Time
$timestamp = time();
$timeout = $timestamp - 300;
$SELF=strip_tags($_SERVER['PHP_SELF']);
$QUERY=strip_tags($_SERVER['QUERY_STRING']);
$ADDR=strip_tags($_SERVER['REMOTE_ADDR']);
//Insert User
$insert = mysql_query("INSERT INTO online (timestamp, ip, file) VALUES('$timestamp','".$ADDR."','".$SELF.'?'.$QUERY."')") or die("HATA3!");
//Delete Users
$delete = mysql_query("DELETE FROM online WHERE timestamp<$timeout") or die("HATA4!");
//Fetch Users Online
$result = mysql_query("SELECT DISTINCT ip FROM online") or die("HATA5");
$users = mysql_num_rows($result);

//Show Who's Online
if($users == 1) {
print("$users\n");
} else {
print("$users\n");
}
?> 