Check if your site visitor is using TOR network in PHP - rest7/api GitHub Wiki
Checking if given IP address is behind TOR in PHP using free API:
<?php
$ip = '123.45.67.89'; //IP of the visitor
$data = json_decode(file_get_contents('http://api.rest7.com/v1/detect_tor.php?ip=' . $ip));
if (@$data->success !== 1)
{
die('Failed');
}
if ($data->is_tor)
{
echo 'Visitor is using TOR';
}
else
{
echo 'Visitor is not using TOR';
}