簡體   English   中英

可能使用PHP阻止整個美國州訪問我的網站?

[英]Might it be possible to block an entire US state from accessing my site, using PHP?

我有一個客戶希望阻止整個美國州訪問他的網站。 他認為這不是完美的。 這可能嗎?

我找到了這項服務: http//www.maxmind.com/en/home

沒有任何良好的准確性。 通過IP進行地理定位可能對一般概念有所幫助,但它通常是不正確的,特別是對於具有國家或地區足跡的大型ISP。

我住在紐約州,但我的手機顯示為堪薩斯州,該地區的一些ISP出現在德克薩斯州。

PHP-Ip-Block使用您提到的Maxmind服務。

您需要在index.php中更改以下行; (可以更改的行)

$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.

對此; (新線)

$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.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM