-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
1,678 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = tab | ||
end_of_line = lf | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
indent_style = space | ||
indent_size = 2 | ||
trim_trailing_whitespace = false | ||
|
||
[composer.json] | ||
indent_style = space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Change Log | ||
|
||
## [0.1.0] - 2015-06-25 | ||
|
||
Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Thomas "Thasmo" Deinhamer | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
# Project Honeypot Http:BL Library | ||
|
||
A simple PHP library for querying the [Project Honeypot Http:BL API](http://www.projecthoneypot.org/httpbl_api.php). | ||
|
||
## Usage | ||
|
||
### Create a new instance | ||
```php | ||
use Thasmo\ProjectHoneypot\Blacklist; | ||
$client = new Blacklist('127.0.0.1', 'api-key'); | ||
``` | ||
|
||
### Create multiple instances | ||
```php | ||
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'); | ||
``` | ||
|
||
### Check for various types of clients | ||
```php | ||
# 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 last activity | ||
```php | ||
# Get the last activity for the client in days. | ||
$lastActivity = $client->getActivity(); | ||
``` | ||
|
||
### Get threat score | ||
```php | ||
# Get the threat score of the client. | ||
$threatScore = $client->getThreat(); | ||
``` | ||
|
||
### Check last activity | ||
```php | ||
# Check if the client was active in the last 10 days. | ||
$isActive = $client->isActive(10); | ||
``` | ||
|
||
### Check threat score | ||
```php | ||
# Check if the threat score is within the limit of 100. | ||
$isThreat = $client->isThreat(100); | ||
``` | ||
|
||
### Get the name for a search engine | ||
```php | ||
# Get the name of the search engine. | ||
if($client->isSearchEngine()) { | ||
$name = $client->getName(); | ||
} | ||
``` | ||
|
||
### Get the API result | ||
```php | ||
# Return an array holding the result from the API call | ||
$result = $client->getResult(); | ||
``` | ||
|
||
### Change the address | ||
```php | ||
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(); | ||
``` | ||
|
||
### Query the API | ||
```php | ||
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(); | ||
} | ||
``` | ||
|
||
## Implementation Details | ||
|
||
* Requests to the API are delayed until you first call a method like `isSearchEngine` etc. or `query` explicitly. | ||
* API responses for the same IP address on the same instance will be cached, the API will be queried only once. | ||
* When changing the IP address via `setAddress` the cache is cleared and the API will be queried again. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "thasmo/honeypot-blacklist", | ||
"description": "", | ||
"type": "library", | ||
"keywords": ["honeypot", "blacklist", "spam", "api", "http"], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Thomas Deinhamer", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.5.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "4.7.*" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Thasmo\\ProjectHoneypot\\": "src/" | ||
} | ||
} | ||
} |
Oops, something went wrong.