With this PHP code you may allow selected countries to view your site.
All other users will be show blank page with message that they cant access site.
You may set any number of countries by adding && $country != "XY"
where XY is code of country which you allow view your site.
It below example Korea and US may view the site while others not.
With a little modification, you may also block or allow selected IP's if you want
$userIP = get_ipxx(false);
$country = file_get_contents('http://api.hostip.info/country.php?ip=' . $userIP);
if ($country != "KR" && $country != "US") {
die ('ERROR : SITE IS UNAVAILABLE');
}
function get_ipxx($ip2long = true) {
if($_SERVER['HTTP_CLIENT_IP']) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
}else if($_SERVER['HTTP_X_FORWARDED_FOR']) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$ip = $_SERVER['REMOTE_ADDR'];
}
if($ip2long) {
$ip = ip2long($ip);
}
return $ip;
}