PHP Classes

File: demo.php

Recommend this page to a friend!
  Classes of Enrico Sola   PHP Detect Tor IP   demo.php   Download  
File: demo.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Detect Tor IP
Detect if the current request uses the Tor network
Author: By
Last change:
Date: 4 years ago
Size: 556 bytes
 

Contents

Class file image Download
<?php
require dirname(__FILE__) . '/php-tor-detector.php';

$address = '89.234.157.254';

//Set the list path.
PHPTorDetector\PHPTorDetector::setListPath(dirname(__FILE__) . '/nodes.txt');

//Update the content fo the list (or create the list if the file doesn't exist or is empty).
PHPTorDetector\PHPTorDetector::updateFile();

//Check if this IP address is a Tor exit point.
$result = PHPTorDetector\PHPTorDetector::isTor($address);
echo
'Is this client (' . $address . ') part of the Tor network? ' . ( $result === true ? 'Yes' : 'No' ) . '.' . PHP_EOL;