Location: PHPKode > scripts > Free Who is Online Script > who_is_online/online.php
<?php
// the date you are reading this(This will show the date from which thw counter is being installed)
$date = "31/01/2009";

//Don't change below this line
// database info
include("config.inc.php");

$timeout=time()-600;
$db_con = mysql_connect($hostname,$hostuser, $hostpass) or die("Connetion to database failed!");
    mysql_select_db($dbname);

$q = mysql_query("SELECT id FROM new_online WHERE IP='$REMOTE_ADDR'") or die(mysql_error());
$ins = mysql_fetch_row($q);
if ($ins >0) {  mysql_query("UPDATE new_online set time=UNIX_TIMESTAMP() WHERE IP like '$REMOTE_ADDR'") or die(mysql_error()); }
else { mysql_query("INSERT INTO new_online (time,IP) VALUES (UNIX_TIMESTAMP(),'$REMOTE_ADDR')") or die(mysql_error()); }
mysql_query("DELETE FROM new_online WHERE time<$timeout") or die(mysql_error());

$q = mysql_query("SELECT id FROM new_online ORDER BY ID DESC") or die(mysql_error());
$online = mysql_num_rows($q);
$total = mysql_fetch_row($q);
mysql_close();

echo "document.write('<font size=1 face=\"Verdana, Arial, Helvetica, sans-serif\">');";
if ($so ==1) {
	if($online==1) { echo "document.write('$online User online');"; }
	else { echo "document.write('$online Users online');"; }
}
if (($st==1) && ($so==1)) { echo "document.write('<br>');"; }
if ($st==1) { echo "document.write('$total[0] visitors since $date');"; }
echo "document.write('</font>');";
?>
Return current item: Free Who is Online Script