Blocker V2

Assisting you in identifying whether a user is a bot or not, this feature can also help you perform simple Ad Cloaking by checking which search engine and advertising service the traffic originates from. It can also identify the headers and URLs opened by visitors. You can create multiple configurations, not limited to just one.

INTEGRATION GUIDE

Please follow the instruction as shown in the video or documentation provided.

VIDEO

Here is a video guide on integrating BlockerV2 into your server.

DOCUMENTATION

Here is the documentation guide on integrating BlockerV2 into your server.

BITVISE

  • Login into your server

  • Open New SFTP window

  • Open your main web dir "/var/www/" or the directory that you already specified

  • Create a file named blockerv2.php and then fill it with the following code:

blocker.php
<?php
/*
     _              _           _                _   
    | |            | |         | |              | |  
 ___| |_ ___  _ __ | |__   ___ | |_   _ __   ___| |_ 
/ __| __/ _ \| '_ \| '_ \ / _ \| __| | '_ \ / _ \ __|
\__ \ || (_) | |_) | |_) | (_) | |_ _| | | |  __/ |_ 
|___/\__\___/| .__/|_.__/ \___/ \__(_)_| |_|\___|\__|
             | |                                     
             |_|                                     
                      [Example Code BlockerV2]

Guide   : https://docs.stopbot.net/service-guides/stopbot/blockerv2
Website : stopbot.net
contact : t.me @stopbotnet
*/

/* START CONFIGURATION */

#Put your Apikey here.
$api = "________________________________";

# Blockerv2 Configuration Name
# You can view it at https://stopbot.net/blockerv2-list.
# If you haven't created your configuration yet,
# you can do so at https://stopbot.net/blockerv2-add.

#Put your Config Name here.
$configName = "________________________________"; /*  */


stopbot($api, $configName);

function stopbot($api, $configName){
    $return = array("stat"=>0);
    for($a = 1; $a <= 10; $a++){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'https://stopbot.net/api/v2/blockerv2?apikey='.$api.'&ip='.GetIp().'&ua='.urlencode($_SERVER['HTTP_USER_AGENT']).'&url='.urlencode($_SERVER['REQUEST_URI']).'&confname='.$configName.'&params='.urlencode(json_encode($_GET)).'&headers='.urlencode(json_encode(getallheaders())).'&'.rand());
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
        curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
        $result = curl_exec($ch);
        if($result){
            $resultJson = json_decode($result, TRUE);
            if($resultJson['status'] == "success"){
                $return['stat'] = 1;
                if($resultJson['PageResponse']['Type'] == "RedirectURL"){
                    header("Location: ".$resultJson['PageResponse']['Contents']);
                    die();
                }elseif($resultJson['PageResponse']['Type'] == "HTTPStatusCode"){
                    header("HTTP/1.1 ".httpcodetostatus($resultJson['PageResponse']['Contents']));
                    die();
                }
                
            }else{
                file_put_contents("errorsApi.txt", "[".date("H:i:s d/m/Y")."]".$resultJson['message']."\r\n", FILE_APPEND);
            }
            $a += 10;
        }
    }
    if($a === 10){
        file_put_contents("errorsApi.txt", "[".date("H:i:s d/m/Y")."]Problem with your connection.\r\n", FILE_APPEND);
    }
}
function GetIp(){
    if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
        $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
        $_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
    }
    $client  = @$_SERVER['HTTP_CLIENT_IP'];
    $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
    $remote  = $_SERVER['REMOTE_ADDR'];
            
    switch(true){
        case (filter_var($client, FILTER_VALIDATE_IP)):
            $Ip = $client;
            break;
        case(filter_var($forward, FILTER_VALIDATE_IP)):
            $Ip = $forward;
            break;
        default:
            $Ip = $remote;
            break;
    }
    return $Ip;
}
function httpcodetostatus($http_code){
    $status_messages = array(
        "204" => "204 No Content",
        "400" => "400 Bad Request",
        "401" => "401 Unauthorized",
        "403" => "403 Forbidden",
        "404" => "404 Not Found",
        "405" => "405 Method Not Allowed",
        "406" => "406 Not Acceptable",
        "408" => "408 Request Timeout",
        "409" => "409 Conflict",
        "411" => "411 Length Required",
        "412" => "412 Precondition Failed",
        "413" => "413 Payload Too Large",
        "414" => "414 URI Too Long",
        "415" => "415 Unsupported Media Type",
        "416" => "416 Range Not Satisfiable",
        "417" => "417 Expectation Failed",
        "418" => "418 I'm a teapot",
        "421" => "421 Misdirected Request",
        "422" => "422 Unprocessable Entity",
        "423" => "423 Locked",
        "424" => "424 Failed Dependency",
        "425" => "425 Too Early",
        "426" => "426 Upgrade Required",
        "428" => "428 Precondition Required",
        "429" => "429 Too Many Requests",
        "431" => "431 Request Header Fields Too Large",
        "451" => "451 Unavailable For Legal Reasons",
        "500" => "500 Internal Server Error",
        "501" => "501 Not Implemented",
        "502" => "502 Bad Gateway",
        "503" => "503 Service Unavailable",
        "504" => "504 Gateway Timeout",
        "505" => "505 HTTP Version Not Supported",
        "507" => "507 Insufficient Storage",
        "508" => "508 Loop Detected",
        "511" => "511 Network Authentication Required"
    );
    if(empty($http_code) || $http_code == "0"){
        $d = array();
        foreach($status_messages as $code=>$detail){
            $d[] = $detail;
        }
        $return = $d[rand(0, count($d))];
    }else{
        $return = isset($status_messages[$http_code]) ? $status_messages[$http_code] : '404 Not Found';
    }
    
    return $return;
}
  • Replace apikey with your API key (Click here for APIKey)

#Put your Apikey here.
$Apikey = "________________________________";
  • And, replace configName with your Config Name (Click here for Config Name), then save.

#Put your Config Name here.
$configName = "________________________________";
  • Open your index.php file, then add this code on the first line, then save.

<?php include_once "blockerv2.php"; ?>
  • For information regarding visitor statistics, click here for details.

If you're still having trouble installing BlockerV2, please contact us for assistance.

Last updated