PHP |包含check.PHP来检查用户是否有vpn



所以我有一个网站的加载页面,我在某个地方得到了一个脚本,它使用getipintel来查看用户是否在使用vpn。我想知道如何将其包含在我的加载页面中,这样当我的加载页第一次加载时,它就会运行php文件,如果用户有vpn,则清除页面并显示403拒绝访问

这是校验码http://pastebin.com/DXKmebvd

到目前为止,我已经尝试过:包括"check.php"需要"check.php"所有这些,我似乎无法让它工作

<?php
function checkProxy($ip){
        $ip=$_SERVER['REMOTE_ADDR'];
        global $ip;
        $contactEmail="4horsemen@hitler.rocks"; //you must change this to your own email address
        $timeout=5; //by default, wait no longer than 5 secs for a response
        $banOnProability=0.99; //if getIPIntel returns a value higher than this, function returns true, set to 0.99 by default
        //init and set cURL options
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
        //if you're using custom flags (like flags=m), change the URL below
        curl_setopt($ch, CURLOPT_URL, "http://check.getipintel.net/check.php?ip=$ip&contact=$contactEmail");
        $response=curl_exec($ch);
        curl_close($ch);

        if ($response > $banOnProability) {
                return true;
        } else {
            if ($response < 0 || strcmp($response, "") == 0 ) {
                //The server returned an error, you might want to do something
                //like write to a log file or email yourself
                //This could be true due to an invalid input or you've exceeded
                //the number of allowed queries. Figure out why this is happening
                //because you aren't protected by the system anymore
                //Leaving this section blank is dangerous because you assume
                //that you're still protected, which is incorrect
                //and you might think GetIPIntel isn't accurate anymore
                //which is also incorrect.
                //failure to implement error handling is bad for the both of us
            }
                return false;
        }
}
$ip=$_SERVER['REMOTE_ADDR'];
if (checkProxy($ip)) {
    /* A proxy has been detected based on your criteria
     * Do whatever you want to here
     */
    echo "[403 Forbidden Error] - Access Denied<br />";
}
?>

您无法通过PHP代码检测用户是否使用VPN服务。您只能在web浏览器设置中检测用户是否使用代理服务器,即使这样也无法一直检测到。您也可以检测TOR节点IP,但不是VPN!

最新更新