Home > Uncategorized > mendeteksi negara lewat ip address

mendeteksi negara lewat ip address

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 Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: