PHP Classes

PHP Detect Tor IP: Detect if the current request uses the Tor network

Recommend this page to a friend!
  Info   View files Example   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 98 All time: 9,704 This week: 151Up
Version License PHP version Categories
php-tor-detector 1.0.0Custom (specified...7Networking, PHP 7
Description Author

This class can detect if the current request uses the Tor network.

It can take the current user request IP address and checks if it is one of those used by the Tor network as exit address.

The class retrieves and maintains a file with the list of Tor exit nodes to lookup faster.

Picture of Enrico Sola
Name: Enrico Sola <contact>
Classes: 5 packages by
Country: Italy Italy
Age: 29
All time rank: 3206122 in Italy Italy
Week rank: 563 Up23 in Italy Italy Up


Tor detector

A very simple library to detect Tor connections using PHP 7 without any dependency.


Before using the library, you have to set the path to the file that contains the list of all Tor exit points, if you don't have the list you can set an arbitrary file name instead. To set the library path, use this method:


If the file doesn't exist or is empty or you just want to update its content, you can use this method to download the updated list and overwrite new list in the file:


Once you have the list, you can check if an IP address is part of the Tor network by using this method:

$result = PHPTorDetector\PHPTorDetector::isTor('IP ADDRESS HERE');

If you want to get the IP address of the client you can use this method:

$address = PHPTorDetector\PHPTorDetector::getClientIPAddress();

By default, check result is cached within session (if session is enabled and if the script is not executed in CLI), you can disable this feature by using this method:


If you want to change the index where the results will be cached you can use this method:


Note that if you want to set multiple indexes within the session array you can separate indexes with a "@" like this:


In this way, cache will be stored in $_SESSION['tor']['cache'].

Are you looking for the Node.js version? Give a look here.

  Files folder image Files  
File Role Description
Accessible without login Plain text file Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file demo.php Example Example script
Accessible without login Plain text file Lic. License text
Accessible without login Plain text file nodes.txt Doc. Documentation
Plain text file php-tor-detector.php Class Class source
Accessible without login Plain text file Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:9,704
This week:151Up