Showing posts with label et country by ip address. Show all posts
Showing posts with label et country by ip address. Show all posts

Saturday, August 7, 2010

et country by ip address, you need url_fopen enabled

get country by ip address, you need url_fopen enabled


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($GetCID1024)){
**
$ReadCID .= $CIData;
}
if((
$ReadCID == "YU") or ($ReadCID == "RS")){
**
$Country "Serbia";
} elseif(
$ReadCID == "US"){
**
$Country "United States";
} else {
**
$Country "Unknown";
fclose($GetCID);

return 
$Country;
}
?>
usage
PHP Code:
echo "Ip: " $_SERVER["REMOTE_ADDR"] . 
\n"
;
echo 
"Country: " GetCountry($_SERVER["REMOTE_ADDR"]) . "\n"?>
i have added only two countrys to this, you need to add others by yourself, follow my example..