[英]Might it be possible to block an entire US state from accessing my site, using PHP?
沒有任何良好的准確性。 通過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.