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
2 Answers
Reset to default 7Not 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.
本文标签:
版权声明:本文标题:javascript - Might it be possible to block an entire US state from accessing my site, using PHP? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744100331a2533470.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论