<?php
/*
veritabanına oluşturman gereken tablo
-----------------------------------------
CREATE TABLE `useronline` (
`on_id` int(20) NOT NULL auto_increment,
`timestamp` int(15) NOT NULL default '0',
`ip` varchar(100) NOT NULL default '',
`file` varchar(100) NOT NULL default '',
PRIMARY KEY (`on_id`)
) TYPE=MyISAM AUTO_INCREMENT=11251 ;
*/
//Önce MySQl'e bağlan ve veritabanını seç
@mysql_connect("localhost", "kullanici_adi", "parola") or die ("MySQL bağlantı hatası");
@mysql_select_db("veritabani_adi") or die ("Veritabanı bağlantı hatası");
$timeoutseconds = 60;
$timestamp = time();
$timeout = $timestamp-$timeoutseconds;
$insert = mysql_query("INSERT INTO useronline (timestamp,ip,file) VALUES ('$timestamp','$REMOTE_ADDR','$PHP_SELF')");
if(!($insert)) {
print "kayıt hatası";
}
$delete = mysql_query("DELETE FROM useronline WHERE timestamp<$timeout");
if(!($delete)) {
print "";
}
$result = mysql_query("SELECT DISTINCT ip FROM useronline");
if(!($result)) {
print "";
}
$user = mysql_num_rows($result);
?>
Aktif Ziyaretçi : <?=$user?>