Prevent spammers from ever reading your site
Fund package maintenance!
Open Issues: 0
- php: >=8.1
- psr/http-message: ^1.0
- psr/log: ~1.0
- symfony/http-foundation: ^5.4
- symfony/psr-http-message-bridge: ^2.1
- nyholm/psr7: ^1.5
- phpunit/phpunit: ^9.0
- symplify/easy-coding-standard: ^10.2
This package is auto-updated.
Last update: 2023-05-10 22:19:32 UTC
The Gatekeeper library protects websites from spam and other attacks. It prevents bad bots from delivering their junk, and in many cases, from ever reading your site in the first place.
Welcome to a whole new way of keeping your service, forum, wiki or content management system free of spam and other attacks. Gatekeeper is a PHP-based solution for blocking spam and the robots which deliver it. This keeps your site's load down, makes your site logs cleaner, and can help prevent denial of service conditions caused by spammers.
Gatekeeper also transcends other anti-spam solutions by working in a completely different, unique way. Instead of merely looking at the content of potential spam, Gatekeeper analyzes the delivery method as well as the software the spammer is using. In this way, Gatekeeper can stop spam attacks even when nobody has ever seen the particular spam before.
Gatekeeper is designed to work alongside existing spam prevention services to increase their effectiveness and efficiency. Whenever possible, you should run it in combination with a more traditional spam prevention service.
The library is inspired by the Bad Behavior anti-spam system by Michael Hampton.
Include the vendor autoloader and use the classes:
namespace Acme\MyApplication; use Secondtruth\Gatekeeper\Screener; use Secondtruth\Gatekeeper\Gatekeeper; use Secondtruth\Gatekeeper\ACL\IPAddressACL; use Secondtruth\Gatekeeper\Check\UrlCheck; use Secondtruth\Gatekeeper\Listing\IPList; use Laminas\Diactoros\ServerRequestFactory; // or any other PSR-7 ServerRequest factory require 'vendor/autoload.php';
Screener object and add the
Check object(s) you want to use:
$screener = new Screener(); $check = new UrlCheck(); $screener->addCheck($check);
Gatekeeper object and run it using the screener:
$request = ServerRequestFactory::fromGlobals(); // or a PSR-7 ServerRequest object you already have $gatekeeper = new Gatekeeper(); $allowed = new IPList('127.0.0.1'); $denied = new IPList(['127.0.0.2', '127.0.0.3/32']); $gatekeeper->addACL(new IPAddressACL($allowed, $denied)); $gatekeeper->run($request, $screener);
Install via Composer
Install Composer if you don't already have it present on your system.
To install the library, run the following command and you will get the latest development version:
$ php composer.phar require secondtruth/gatekeeper:dev-master
- You must have at least PHP version 8.1 installed on your system.
Author, Credits and License
This project was created by Christian Neff (@secondtruth) and is licensed under the MIT License.
Based on the work of:
- Michael Hampton
Thanks to all other Contributors!