<?php
$ip = $_SERVER["REMOTE_ADDR"];
function curl($url, $post=false)
{
$user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, $post ? true : false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post ? $post : false);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
$icerik = curl_exec($ch);
curl_close($ch);
return $icerik;
}
$gelen = curl("http://www.whereisip.net/index.php", "target=".$ip);
$parcala = explode('</b><BR>Country / Region: <b>',$gelen);
$parcala = explode('</b><BR><p>',$parcala[1]);
preg_match('~(.*?), ~', $parcala[0], $pregsil);
if($pregsil[1] == "Turkey"){
echo "<br>Türkiyeden girenlerin görmesini istediginiz alan.";
}else{
echo "<br>Diğer ziyaretçilerin görmesini istediginiz alan.";
}
?>Bu kodları kendinize göre uyarlayarak kullanabilirsiniz.Bu kodlarda işini görmezse, http://blog.cliaweb.com/php-ile-geoip-kullanimi.html