View Single Post
Old 11-16-2010, 02:08 AM  
SmellyNose
Confirmed User
 
SmellyNose's Avatar
 
Industry Role:
Join Date: Aug 2009
Location: me at smellynose.com
Posts: 206
Code:
$bad_country_codes = Array('CN', 'JP', 'TW');

require_once("geoip.inc");

$gi = geoip_open("/usr/share/GeoIP/GeoIP.dat", GEOIP_STANDARD);
$cc = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
if(in_array($cc, $bad_country_codes)) {
        exit;
}
The above is what I use on one of my websites, so it looks like you're doing it correctly.

Have you checked you're not giving it a US ip all the time?

You can go to maxmind.com and enter the IP there and it will tell you the location of the IP so you will be able to see whether you've given it a US ip or your code is wrong.
__________________
I'm a PHP developer - 594086663 - [email protected]
SmellyNose is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote