Advertisement
Guest User

antibot.pw - auto block bot visitor

a guest
Sep 23rd, 2019
1,850
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.01 KB | None | 0 0
  1. <?php
  2. /**
  3.  * @Author: Nokia 1337
  4.  * @Date:   2019-09-24 03:32:53
  5.  * @Last Modified by:   Nokia 1337
  6.  * @Last Modified time: 2019-09-24 03:46:56
  7. */
  8. error_reporting(0);
  9. session_start();
  10.  
  11. $config['ApiKey']     = 'a87e79a6b77228382a97f534ed72d03e'; // get in https://antibot.pw/developers
  12. $config['blocktype']  = 3;
  13.  
  14.  
  15. function get_client_ip() {
  16.     $ipaddress = '';
  17.     if (getenv('HTTP_CLIENT_IP')){
  18.         $ipaddress = getenv('HTTP_CLIENT_IP');
  19.     }
  20.     if(getenv('HTTP_X_FORWARDED_FOR')){
  21.         $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
  22.     }
  23.     if(getenv('HTTP_X_FORWARDED')){
  24.         $ipaddress = getenv('HTTP_X_FORWARDED');
  25.     }
  26.     if(getenv('HTTP_FORWARDED_FOR')){
  27.         $ipaddress = getenv('HTTP_FORWARDED_FOR');
  28.     }
  29.     if(getenv('HTTP_FORWARDED')){
  30.        $ipaddress = getenv('HTTP_FORWARDED');
  31.     }
  32.     if(getenv('REMOTE_ADDR')){
  33.         $ipaddress = getenv('REMOTE_ADDR');
  34.     }
  35.     $ipaddress = explode(",",  $ipaddress);
  36.     return $ipaddress[0];
  37. }
  38.  
  39. if($_SESSION['check'] == false){
  40.  
  41.   $ipNe = get_client_ip();
  42.  
  43.     if($ipNe == '::1' || $ipNe == '127.0.0.1'){
  44.       $ipNe = '8.8.8.8';
  45.     }
  46.  
  47.   $curl = curl_init();
  48.   curl_setopt_array($curl, array(
  49.     CURLOPT_URL => "https://antibot.pw/api/check-visitor.php?ip=".$ipNe."&block=".$config['blocktype']."&apikey=".$config['ApiKey'],
  50.     CURLOPT_RETURNTRANSFER => true,
  51.     CURLOPT_ENCODING => "",
  52.     CURLOPT_MAXREDIRS => 10,
  53.     CURLOPT_TIMEOUT => 30,
  54.     CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  55.     CURLOPT_HTTPHEADER => array(
  56.       "content-type: application/x-www-form-urlencoded",
  57.     ),
  58.   ));
  59.  
  60.   $response = curl_exec($curl);
  61.   $err = curl_error($curl);
  62.  
  63.   curl_close($curl);
  64.  
  65.   $json = json_decode($response,true);
  66.   if($json['is_bot'] == 1){
  67.     $_SESSION['check']  = true;
  68.     $_SESSION['is_bot'] = true;
  69.     die( header("HTTP/1.1 401 Unauthorized") );
  70.       exit();
  71.   }
  72. }
  73.  
  74. if($_SESSION['check'] == true && $_SESSION['is_bot'] == true){
  75.   die( header("HTTP/1.1 401 Unauthorized") );
  76.     exit();
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement