function countryCityFromIP($ipAddr) {
ip2long($ipAddr)== -1 || ip2long($ipAddr) === false ? trigger_error("Invalid IP", E_USER_ERROR) : "";
$ipDetail=array();
$xml = file_get_contents("http://api.hostip.info/?ip=".$ipAddr);
preg_match("@<Hostip>(\s)*<gml:name>(.*?)</gml:name>@si",$xml,$match);
$ipDetail['city']=$match[2];
preg_match("@<countryName>(.*?)</countryName>@si",$xml,$matches);
$ipDetail['country']=$matches[1];
preg_match("@<countryAbbrev>(.*?)</countryAbbrev>@si",$xml,$cc_match);
$ipDetail['country_code']=$cc_match[1];
return $ipDetail;
}
$IPDetail=countryCityFromIP($_SERVER['REMOTE_ADDR']);
$salys = "LITHUANIA|GERMANY";
$listas=explode("|", $salys);
if (!in_array($IPDetail['country'], $listas)) {
redirect('http://google.com');
}