Guest User

Untitled

a guest
Aug 5th, 2016
885
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.68 KB | None | 0 0
  1. <?php
  2. function checkProxy($ip){
  3.         $ip=$_SERVER['REMOTE_ADDR'];
  4.         global $ip;
  5.         $contactEmail="[email protected]"; //you must change this to your own email address
  6.         $timeout=5; //by default, wait no longer than 5 secs for a response
  7.         $banOnProability=0.99; //if getIPIntel returns a value higher than this, function returns true, set to 0.99 by default
  8.        
  9.         //init and set cURL options
  10.         $ch = curl_init();
  11.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  12.         curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
  13.         //if you're using custom flags (like flags=m), change the URL below
  14.         curl_setopt($ch, CURLOPT_URL, "http://check.getipintel.net/check.php?ip=$ip&contact=$contactEmail");
  15.         $response=curl_exec($ch);
  16.        
  17.         curl_close($ch);
  18.        
  19.        
  20.         if ($response > $banOnProability) {
  21.                 return true;
  22.         } else {
  23.             if ($response < 0 || strcmp($response, "") == 0 ) {
  24.                 //The server returned an error, you might want to do something
  25.                 //like write to a log file or email yourself
  26.                 //This could be true due to an invalid input or you've exceeded
  27.                 //the number of allowed queries. Figure out why this is happening
  28.                 //because you aren't protected by the system anymore
  29.                 //Leaving this section blank is dangerous because you assume
  30.                 //that you're still protected, which is incorrect
  31.                 //and you might think GetIPIntel isn't accurate anymore
  32.                 //which is also incorrect.
  33.                 //failure to implement error handling is bad for the both of us
  34.             }
  35.                 return false;
  36.         }
  37. }
  38. $ip=$_SERVER['REMOTE_ADDR'];
  39. if (checkProxy($ip)) {
  40.     /* A proxy has been detected based on your criteria
  41.      * Do whatever you want to here
  42.      */
  43.     echo "[403 Forbidden Error] - Access Denied<br />";
  44. }
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment