限制访问特定国家/地区的 PHP 网站
既然IP可以被欺骗,那么如何建立一个能够正确识别访问者所在国家的PHP网站呢?
Since IP can be spoofed, how can one build a PHP website that correctly identifies the visitor's country?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
鉴于互联网的匿名性,这本质上是一个问题,但无论如何,通过欺骗 IP 地址获取在您所在国家/地区不合法的内容在技术上在大多数地方都是犯罪行为。
您应尽一切合理努力确保您的网站遵守媒体和信息的分发限制,但有些事情是无法防范的。最接近的方法是进行实际的实际地址验证,例如信用卡上的帐单地址或向某人邮寄用于注册的 PIN 码,但这两种选择都会代表用户或您自己产生费用。
That's inherently a problem given the anonymity of the internet, but spoofing IP addresses to obtain content not legally available in your country is technically a crime in most places anyways.
It's up to you to make every reasonable effort to ensure your site follows distribution restrictions on media and information, but there are some things that are just impractical to guard against. The closest you could get is by doing an actual physical address verification such as a billing address on a credit card or physically mailing someone a pin number for registration, but both of those options incur expenses on behalf of either the user or yourself.
Joomla一直使用下面的函数来获取IP地址,这是一个非常通用的好函数,可以避免可能的作弊,你可以使用它:
Joomla has been using below function to get IP addresses, it is very versatile good function, that can avoid possible cheats, you can use it: