/**
*
* TG WHO'S ONLINE
* Copyright 2005 - 2006 (c) TOXIC GOBLIN
* http://www.toxicgoblin.com
*
*/
require realpath(dirname(__FILE__) . '/../includes/basa/db_connect.php');
//Optional Database Connection Information
//**Uncomment the following 2 lines and edit the values if you do not already have an active database connection**
//
//$db = mysql_connect("localhost", "username", "password") or die("Could not connect");
//mysql_select_db("database_name");
//Fetch Time
$timestamp = time();
$timeout = $timestamp - 900;
$FN='m'.$_SERVER['PHP_SELF'];
//Insert User
$insert = $mysqli->query("INSERT INTO TG_whos_online (timestamp, ip, file) VALUES('$timestamp','".$_SERVER['REMOTE_ADDR']."','$FN')") or die("Error in who's online insert query!");
//Delete Users
$delete = $mysqli->query("DELETE FROM TG_whos_online WHERE timestamp<$timeout") or die("Error in who's online delete query!");
// Query for getting visitor countrycode
$country_query = "SELECT country_code2,country_name FROM iptocountry WHERE IP_FROM<=inet_aton('".$_SERVER['REMOTE_ADDR']."') AND IP_TO>=inet_aton('".$_SERVER['REMOTE_ADDR']."')";
// Executing above query
$country_result = $mysqli->query($country_query);
// Fetching the record set into an array
$ccode_array=$country_result->fetch_assoc($country_exec);
// getting the country code from the array
$country_code=$ccode_array['country_code2'];
// getting the country name from the array
$country_name=$ccode_array['country_name'];
$insert = $mysqli->query("INSERT INTO BASA_WEB_STATS (ip, page,country) VALUES('".$_SERVER['REMOTE_ADDR']."','$FN','$country_name')") or die("Error in who's online insert query!");
// }
$mysqli->close();
?>