Now I only want to block few countries instead of allowing few countries. I used the following but it doesn't work
// Redirect Bad Visitor
require_once 'includes/geoip.inc';
function getLocation($remoteurl) {
$remoteurl = str_replace("http://", "", $remoteurl);
$remoteip = gethostbyname($remoteurl);
$gi = geoip_open("GeoIP/GeoIP.dat",GEOIP_STANDARD);
$country = geoip_country_code_by_addr($gi, $remoteip);
geoip_close($gi);
$country = strtolower($country);
return $country;
}
$addr = getenv('REMOTE_ADDR');
$country = getLocation($addr);
$badcountry = array('ir','cn','ng');
if(in_array($country, $badcountry))
header('Location: https://www.redirected-pages.com');

