are you interested to find country for your website visitor freely?
I have a optimized simple PHP code to do this.
you should copy and paste anywhere in your web page, find how is working fine.
<?php
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
if(empty($ip))
$ip=$_SERVER['REMOTE_ADDR'];
$url="http://api.wipmania.com/".$ip."?google.com";
$ccode=@file_get_contents($url);
if(!empty($ccode) && strlen($ccode)<3){
$cflag=" <img src=\"flags/".$ccode.".png\" />";
$str=file_get_contents("countries.txt");
$pattern="/".$ccode."\s(.+)\n/";
preg_match($pattern,$str,$match);
echo $match[1].$cflag."<br/>";
}
?>
Before that you should download flags images and countries list from the below website.
It is absolutely free of cost.
Flags =
http://static.wipmania.com/static/flags.zip (extract to same directory)
Countries =
http://static.wipmania.com/static/countries.txt (place in same directory)