Well people here are searching this script.I have coded for them.You can get guest number and details who has visited last 5 minitues.You can change the session time.
Make a guest.php file.Copy and paste this codes
Then make online.php file copy and paste this codes
SQL table
Make a guest.php file.Copy and paste this codes
Code:
<?php
$server = "";
$table = "visitors";
$database = "";
$username = "";
$password = "";
$connection = mysql_connect($server,$username,$password);
mysql_select_db($database,$connection);
$minutes = 5;
$seconds = $minutes*60;
$past = time()-$seconds;
$now = time();
if($_SERVER["REMOTE_ADDR"]){$ip=$_SERVER["REMOTE_ADDR"];}
else{$ip=$_SERVER["HTTP_X_FORWARDED_FOR"];}
$brws = explode("(",$_SERVER["HTTP_USER_AGENT"]);
$browser = $brws[0];
mysql_query("INSERT INTO $table SET ip='".$ip."', browser='".$browser."',date='".$now."'");
mysql_query("DELETE FROM $table WHERE date < '".$past."'");
$count = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM $table"));
echo "
<a href=\"online.php\">Users Online($count[0])</a>
";
?>
Code:
<?php
$server = "";
$database = "";
$username = "";
$password = "";
$connection = mysql_connect($server,$username,$password);
mysql_select_db($database,$connection);
$result = mysql_query("SELECT ip ,browser,date FROM visitors ORDER BY date ")or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo "[b]$row[1][/b]";
$newtime =$row[2]+(6 *60 *60);
echo "[b]".date("D d M y - H:i:s",$newtime)."[/b]
";
echo "------------
";
}
?>
Code:
CREATE TABLE visitors ( ip varchar(20) NOT NULL, browser varchar(20) NOT NULL, date int(10) DEFAULT '0' NOT NULL )ENGINE=MyISAM DEFAULT CHARSET=latin1;



Comment