View file online.php

File size: 552B
<?php
$ip=$_SERVER['REMOTE_ADDR'];
$ua=substr($_SERVER['HTTP_USER_AGENT'], 0, 50);
if (mysql_num_rows(mysql_query("SELECT * FROM inet_online WHERE ip='$ip' AND ua='$ua'"))) {
	mysql_query("UPDATE inet_online SET lastdate=NOW() WHERE ip='$ip' AND ua='$ua'");
} else {
	mysql_query("INSERT INTO inet_online SET ip='$ip', ua='$ua', lastdate=NOW()");
}
mysql_query("DELETE FROM inet_online WHERE lastdate < NOW() - INTERVAL 5 MINUTE");
list($online)=mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM inet_online"));
echo "На сайте: $online<br/>";
?>