Advertisement
carbonize

New header checks

May 3rd, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.47 KB | None | 0 0
  1. <?php
  2.  
  3. function badHosts($theirIP)
  4. {
  5.   $badHosts = array('servinio.com', 'turnkeyinternet.net', 'kimsufi.com', 'steephost.com', 'starnet.md', 'asianet.co.th',
  6.   'bezeqint.net', '.server.de', 'ertelecom.ru', 'hostnoc.net', 'dedibox.fr', 'dimenoc.com', 'ukrtel.net', 'ubiquityservers.com');
  7.  
  8.   $theirHost = gethostbyaddr($theirIP);
  9.  
  10.   foreach($badHosts as $badHost)
  11.   {
  12.     if(strpos($theirHost, $badHost) !== false)
  13.     {
  14.       return true;
  15.     }
  16.   }
  17.   return false;
  18. }
  19.  
  20. function badBrowsers()
  21. {
  22.   $badBrowsers = array('Opera/9.80', 'bork-edition', 'Chrome/13.0.782.112', 'Firefox/4', 'Firefox/5', 'Firefox/13.0.1', ' MRA ', 'App3leWebKit');    
  23.  
  24.   foreach($badBrowsers as $badBrowser)
  25.   {
  26.     if(strpos($_SERVER['HTTP_USER_AGENT'], $badBrowser) !== false)
  27.     {
  28.       return true;
  29.     }
  30.   }
  31.   return false;
  32. }
  33.  
  34. // TOR exit point detection function from http://www.irongeek.com/i.php?page=security/detect-tor-exit-node-in-php
  35. // This will be under EXTREME header check setting with a warning it could block legitimate users
  36.  
  37. function IsTorExitPoint($theirIP)
  38. {
  39.   if (gethostbyname(ReverseIPOctets($theirIP) . '.' . $_SERVER['SERVER_PORT'] . '.' . ReverseIPOctets($_SERVER['SERVER_ADDR']) . '.ip-port.exitlist.torproject.org') == '127.0.0.2')
  40.   {
  41.     return true;
  42.   }
  43.   else
  44.   {
  45.     return false;
  46.   }
  47. }
  48.  
  49. function ReverseIPOctets($inputIP)
  50. {
  51.   $ipoc = explode('.', $inputIP);
  52.   return $ipoc[3] . '.' . $ipoc[2] . '.' . $ipoc[1] . '.' . $ipoc[0];
  53. }
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement