Skip to content

Instantly share code, notes, and snippets.

@j3j5
Created April 13, 2015 14:34
Show Gist options
  • Save j3j5/4c0bdfe7b13bf10121c4 to your computer and use it in GitHub Desktop.
Save j3j5/4c0bdfe7b13bf10121c4 to your computer and use it in GitHub Desktop.
How to tell if someone is coming from a Tor exit node
// http://www.irongeek.com/i.php?page=security/detect-tor-exit-node-in-php
public function IsTorExitPoint(){
if(gethostbyname(ReverseIPOctets($_SERVER['REMOTE_ADDR']).".".$_SERVER['SERVER_PORT'].".".ReverseIPOctets($_SERVER['SERVER_ADDR']).".ip-port.exitlist.torproject.org")=="127.0.0.2") {
return true;
} else {
return false;
}
}
private function ReverseIPOctets($inputip){
$ipoc = explode(".",$inputip);
return $ipoc[3].".".$ipoc[2].".".$ipoc[1].".".$ipoc[0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment