<?PHP
function Dot2LongIP ($IPaddr){
if ($IPaddr == ""){
return 0;
}
else{
$ips = split ("\.", "$IPaddr");
return ($ips[3] + $ips[2] * 256 + $ips[1] * 256 * 256 + $ips[0] * 256 * 256 * 256);
}
}
function getCountry ($addy){
$ipno = Dot2LongIP($addy);
$ipaddy = "SELECT country, high, low from countrycodes where low<=$ipno and high>=$ipno";
$getCountry = mysql_query($ipaddy);
while($myrow = mysql_fetch_array($getCountry)){
$userCountry=$myrow[country];
}
return $userCountry;
}
?>