admin 管理员组

文章数量: 1086019

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:

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./en/home

Share Improve this question asked Jan 2, 2013 at 16:01 user1040259user1040259 6,51913 gold badges46 silver badges62 bronze badges 5
  • 1 Not directly related, but why does he want to block a specific state from his site? – Frank B Commented Jan 2, 2013 at 16:04
  • Wouldn't it be better to just ask the user? I've seen major sites (e.g. healthcare) that clearly say their services are only available in certain states, and then they ask the user where they live (and make it clear what is/is not applicable). – Tim M. Commented Jan 2, 2013 at 16:05
  • 1 @TimMedora The problem may be that this client doesn't want certain users to see their site, and your solution allows them to lie to get in. If the client is trying to block them for some reason, he probably doesn't want them to have a loophole in. Although if he's willing for it to be imperfect, he might be OK with the loophole. So I guess my ment is related. Why the client wants this block affects how this could and should be implemented. – Frank B Commented Jan 2, 2013 at 16:10
  • @FrankB - I understand that, and your ment is related. It's often possible to lie to get into a site (e.g. age verification, spoofing an IP, fake email address, etc.) But if you put the responsibility on the user, you can disclaim most of the liability. – Tim M. Commented Jan 2, 2013 at 16:13
  • Specifically, my client owns a franchise business and is grandfathered in for some specifics. Basically, he doesn't want to cause any trouble with other franchises. Meaning.. I'd present a different site/page/etc to them. I know it's not perfect, but this is something he wants. – user1040259 Commented Jan 2, 2013 at 16:48
Add a ment  | 

2 Answers 2

Reset to default 7

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./' );//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./' );//this is where to send countries matched.

本文标签:

Error[2]: Invalid argument supplied for foreach(), File: /www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm, Line: 58
File: /www/wwwroot/roclinux.cn/tmp/route_read.php, Line: 205, include(/www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm)
File: /www/wwwroot/roclinux.cn/tmp/index.inc.php, Line: 129, include(/www/wwwroot/roclinux.cn/tmp/route_read.php)
File: /www/wwwroot/roclinux.cn/index.php, Line: 29, include(/www/wwwroot/roclinux.cn/tmp/index.inc.php)