我正变得非常垃圾,并试图阻止它……我有与此类似的代码来获取IP,然后阻止它们,还试图添加此代码以阻止任何以主机名开头的主机访问我的网站。字符串“ tor”。之后发生的变化很大,因此只想匹配前三个字母然后阻止…
<?php
// The function to get the visitor's IP Host info.
function getUserHostIP(){
//check ip host from share internet
$blackListHost=gethostbyaddr($_SERVER['REMOTE_ADDR']);
if (strpos($blackListHost, 'tor') === 0) {
header("Location: unauthorized.php");
die();
}
}
//The user
getUserHostIP();
?>