Archive for August, 2010
mendeteksi negara lewat ip address
August 8, 2010
Leave a comment
source : http://www.phptutorial.info/iptocountry/the_script.html
Mendeteksi asal negara pengunjung website kita melalui ip address.
berikut ini adalah codenya:
download ip_files.
<?php
$two_letter_country_code=iptocountry($_SERVER[“REMOTE_ADDR”]);
function iptocountry($ip) {
$numbers = preg_split( “/\./”, $ip);
include(“ip_files/”.$numbers[0].”.php”);
$code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]);
foreach($ranges as $key => $value){
if($key<=$code){
if($ranges[$key][0]>=$code){$country=$ranges[$key][1];break;}
}
}
if ($country==””)
{
$country=”unkown”;}
return $country;
}
if ($two_letter_country_code== “ID”)
{ echo “Hi Indonesia”; }
?>
Categories: Uncategorized
PHP