thasmo / honeypot-blacklist
一个简单的PHP库,用于查询Project Honeypot Http:BL API。
v0.1.2
2016-03-21 20:17 UTC
Requires
- php: >=5.5.0
Requires (Dev)
- phpunit/phpunit: 4.7.*
- satooshi/php-coveralls: 0.6.*
This package is auto-updated.
Last update: 2024-09-08 21:11:48 UTC
README
一个简单的PHP库,用于查询Project Honeypot Http:BL API。
使用方法
创建新的实例
use Thasmo\ProjectHoneypot\Blacklist; $client = new Blacklist('127.0.0.1', 'api-key');
创建多个实例
use Thasmo\ProjectHoneypot\Blacklist; # Set default API key. Blacklist::setDefaultKey('api-key'); # Use the default API key. $clientOne = new Blacklist('127.0.0.1'); # Use a specific API key. $clientTwo = new Blacklist('127.0.0.2', 'other-api-key'); # Use the default API key, again. $clientThree = new Blacklist('127.0.0.3');
检查各种类型的客户端
# Client is a search engine. $client->isSearchEngine(); # Client is suspicious. $client->isSuspicious(); # Client is a harvester. $client->isHarvester() # Client is a spammer. $client->isSpammer(); # Client is blacklisted. # Which means it is suspicious, a harvester or a spammer but not a search engine. $client->isListed();
获取最后活动
# Get the last activity for the client in days. $lastActivity = $client->getActivity();
获取威胁分数
# Get the threat score of the client. $threatScore = $client->getThreat();
检查最后活动
# Check if the client was active in the last 10 days. $isActive = $client->isActive(10);
检查威胁分数
# Check if the threat score is within the limit of 100. $isThreat = $client->isThreat(100);
获取搜索引擎的名称
# Get the name of the search engine. if($client->isSearchEngine()) { $name = $client->getName(); }
获取API结果
# Return an array holding the result from the API call $result = $client->getResult();
更改地址
use Thasmo\ProjectHoneypot\Blacklist; # Create an instance $client = new Blacklist('127.0.0.1', 'api-key'); # Get the result $result1 = $client->getResult(); # Set a new address which resets the object $client->setAddress('127.0.0.2'); # Get the new result $result2 = $client->getResult();
查询API
use Thasmo\ProjectHoneypot\Blacklist; # Create an instance $client = new Blacklist('127.0.0.1', 'api-key'); # Query the API immediately $client->query(); # Use other methods if($client->isSearchEngine()) { $name = $client->getName(); }
实现细节
- 对API的请求将在您首次调用类似于
isSearchEngine
等 method 或显式调用query
之前被延迟。 - 同一实例上同一IP地址的API响应将被缓存,API只会查询一次。
- 通过
setAddress
更改IP地址时,缓存将被清除,并将再次查询API。