SHARE
TWEET

Untitled

Racco42 Jan 12th, 2017 252 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $bad_ips = array('23.103.144.', '23.103.149.', '23.103.155.', '69.167.');
  4. $bad_uas = array('Wget', 'python', 'Python', 'Go-http-client', 'Twisted', "'", "{", 'Microsoft', 'Java');
  5. $bad_ccs = array('CN');
  6.  
  7. function BlockByIp($ip)
  8. {
  9.     global $bad_ips;
  10.     foreach ($bad_ips as $bip)
  11.     {
  12.         if (strpos($ip, $bip) === 0) die();
  13.     }
  14.     return;
  15. }
  16.  
  17. function BlockByUserAgent($ua)
  18. {
  19.     global $bad_uas;
  20.     foreach ($bad_uas as $bua)
  21.     {
  22.         if (strpos($ua, $bua) === 0) die();
  23.     }
  24.     return;
  25. }
  26.  
  27. function BlockByCountryCode($cc)
  28. {
  29.     global $bad_ccs;
  30.     foreach ($bad_ccs as $cci)
  31.     {
  32.         if (strpos($cc, $cci) === 0) die();
  33.     }
  34.     return;
  35. }
  36.  
  37. function GetIp()
  38. {
  39.     if (isset($_SERVER['X_FORWARDED_FOR']))
  40.     {
  41.         $ip = $_SERVER['X_FORWARDED_FOR'];
  42.     } else {
  43.         $ip = $_SERVER['REMOTE_ADDR'];
  44.     }
  45.     return $ip;
  46. }
  47.  
  48. function GetUserAgent()
  49. {
  50.     return $_SERVER['HTTP_USER_AGENT'];
  51. }
  52.  
  53. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top