Home  >  Article  >  Backend Development  >  javascript - 外贸网站怎样屏蔽大陆ip?

javascript - 外贸网站怎样屏蔽大陆ip?

WBOY
WBOYOriginal
2016-06-06 20:21:211594browse

外贸站不想让中国大陆访问,想用JavaScript检测浏览器语言是中文的都屏蔽了,但会误伤到很多海外华侨,而且从统计来看网站海外华侨占比还很多,用后端PHP判断是否为大陆查找了半天也没头绪,这个应如何解决?前后端都行

回复内容:

外贸站不想让中国大陆访问,想用JavaScript检测浏览器语言是中文的都屏蔽了,但会误伤到很多海外华侨,而且从统计来看网站海外华侨占比还很多,用后端PHP判断是否为大陆查找了半天也没头绪,这个应如何解决?前后端都行

单纯想屏蔽IP的话,需要找到中国大陆的IP。而亚太地区的IP是由APNIC负责的,你可以下载:http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest

然后根据国家代码『CN』找出中国大陆的IP。

具体的可以在shell中执行:

<code>wget http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest
grep ipv4 delegated-apnic-latest | grep CN | awk -F'|' '{print $4}'
</code>

输出即为中国大陆的IP。

我有翻墙你怎么屏蔽......

PS: 不想让他们看有一点不太现实, 可以不让他们买. 比如ban掉注册邮箱, 手机号, 邮寄地址等等

看访问IP,如果是国内IP就屏蔽

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn