Skip to content

Instantly share code, notes, and snippets.

@alixaxel
Last active October 1, 2015 15:37
Show Gist options
  • Save alixaxel/2016707 to your computer and use it in GitHub Desktop.
Save alixaxel/2016707 to your computer and use it in GitHub Desktop.
<?php
function isTor()
{
$host = array
(
$_SERVER['REMOTE_ADDR'],
$_SERVER['SERVER_PORT'],
$_SERVER['SERVER_ADDR'],
'ip-port.exitlist.torproject.org',
);
foreach ($host as $key => $value)
{
if (filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false)
{
$host[$key] = implode('.', array_reverse(explode('.', $value)));
}
}
return gethostbyname(implode('.', $host)) == '127.0.0.2';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment