PHP Code:
/**
* @author Milomir
* @copyright 2008
*/
function GetCountry($IpAddr){ $APIUrl = "http://api.hostip.info/country.php?ip=" . $IpAdds . ""; $GetCID = fopen($APIUrl, "r");
while($CIData = fread($GetCID, 1024)){
**$ReadCID .= $CIData;
}
if(($ReadCID == "YU") or ($ReadCID == "RS")){
**$Country = "Serbia";
} elseif($ReadCID == "US"){
**$Country = "United States";
} else {
**$Country = "Unknown";
} fclose($GetCID);
return $Country;
}
?>
PHP Code:
echo "Ip: " . $_SERVER["REMOTE_ADDR"] . "
\n";
echo "Country: " . GetCountry($_SERVER["REMOTE_ADDR"]) . "\n"; ?>
No comments:
Post a Comment