I have a client that would like to block an entire US state from accessing his site. He is OK with the idea of it not being perfect. Is this possible?
I found this service: http://www.maxmind.com/en/home
Not with any sort of good accuracy. Geolocation via IP can be helpful for a general idea, but it's often incorrect, especially with larger ISPs that have a national or regional footprint.
I live in NYS, but my phone shows up as Kansas, and some ISPs in the area show up from Texas.
PHP-Ip-Block uses Maxmind service you mentioned.
You need to change following lines in index.php; (lines that sould be changed)
$okc = array('Canada', 'United States'); //array of countries you want to let in
// Decide what to do with your country arrays
if (in_array($userco,$okc))
echo " "; //allowed in
else
header( 'Location: http://www.google.com/' );//this is where to send countries not matched.
to this; (new lines)
$okc = array('United States'); //array of countries you want to NOT let in
// Decide what to do with your country arrays
if (!in_array($userco,$okc))
echo " "; //allowed in
else
header( 'Location: http://www.google.com/' );//this is where to send countries matched.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With