The GeoIP database uses the following format for Iran's country name :
Code:
Iran, Islamic Republic of
It'd probably just be easier if you used country codes versus country names, I use country code in all my GeoIP stuff, and haven't noticed any problems with it.
To modify your GeoIP code to use country_codes instead of country_names is below :
PHP Code:
include('geoip/geoip.inc'); //this file must exist in your directory
// Uncomment if querying against GeoIP/Lite City.
// include('geoip/geoip.inc');
$gi = geoip_open('geoip/geoip.dat',GEOIP_STANDARD);
// get the ip of the visitor
$addr = getenv('REMOTE_ADDR');
// translate his ip to a country code
$country = geoip_country_code_by_addr($gi, $addr);
// close the geo database
geoip_close($gi);
$badcountry = array('IR','CN','RU','SA');
if(in_array($country, $badcountry))
header('Location: http://www.proxlists.com'); //enter a url or page on your site
see if that helps. best way to test it is to momentarily block your own country, i.e. if your in the United States, add 'US' in the bad country array and make sure you get redirected. Then of course remove 'US' from the array once you confirm it's working.
Bookmarks