=$ipn LIMIT 1");
// Executing above query
$resultrow=mysql_fetch_array($result);
$countrycode=$resultrow['COUNTRY_CODE2'];
return $countrycode; //only giving back 2 character country code
}
function checkTime(){
global $dbname, $dbprefix;
//check inactive time for logged users and logout after x minutes of inactivity
global $dbprefix;
$session=session_id();
//to be placed in configuration file
$maxinactivemin=100;
require ("./include/connect_db.php");
mysql_select_db($dbname, $link) or die("couldn't select database");
$result=mysql_query("SELECT UNIX_TIMESTAMP(updated) as lastlog, UNIX_TIMESTAMP(posted) as firstlog FROM ".$dbprefix."sessions WHERE session='$session'");
$resultrow=mysql_fetch_array($result);
$lastlog=$resultrow[lastlog];
$firstlog=$resultrow[firstlog];
$nowtime=time();
$inactiveSec=$nowtime-$lastlog;
$inactivesec2min=$inactiveSec/60;
$loggedinsec=$nowtime-$firstlog;
$loggedinmin=intval(($nowtime-$firstlog)/60);
mysql_query("UPDATE ".$dbprefix."sessions SET duration='$loggedinsec' WHERE session='$session'");
if ($inactivesec2min>$maxinactivemin) {
//echo "timout
";
$fg="logout";
return $fg;
}
else {
//no timeout
//echo "for $loggedinmin minutes";
}
}
function DoHostIp($ip){
global $dbname, $dbprefix;
require('./classes/geosourceip/geosourceip.php');
$geoDetails = GeoIPInformation($ip);
//sample output of the (complete) returned array "geoDetails"
//general output by
// echo $geoDetails['longitude'];
// for example
while(list($key, $val) = each($geoDetails)) {
if($key=="city_and_state"){
if($val=="(Unknown city)"){
$city="";
}else{
$city=$val;
}
}
if($key=="latitude"){$N_lat=$val;}
if($key=="longitude"){$W_long=$val;}
if($key=="country_code"){$country=$val;}
//echo $key . ": " . $val . '
';
}
$session=session_id();
mysql_query("UPDATE ".$dbprefix."sessions SET country='$country', city='$city', N_lat='$N_lat', W_long='$W_long' WHERE session='$session'");
}
?>