Skip to content

Instantly share code, notes, and snippets.

@ismailbaskin
Created February 23, 2014 17:02
Show Gist options
  • Save ismailbaskin/9174025 to your computer and use it in GitHub Desktop.
Save ismailbaskin/9174025 to your computer and use it in GitHub Desktop.
Detector for TOR user
function isTorRequest() {
$reverse_client_ip = implode('.', array_reverse(explode('.', $_SERVER['REMOTE_ADDR'])));
$reverse_server_ip = implode('.', array_reverse(explode('.', $_SERVER['SERVER_ADDR'])));
$hostname = $reverse_client_ip . "." . $_SERVER['SERVER_PORT'] . "." . $reverse_server_ip . ".ip-port.exitlist.torproject.org";
return gethostbyname($hostname) == "127.0.0.2";
}
print isTorRequest() ? "Yep" : "Nope";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment