secondtruth / gatekeeper
防止垃圾邮件发送者读取您的网站
Requires
- php: >=8.1
- psr/http-message: ^1.0
- psr/log: ~1.0
- symfony/http-foundation: ^5.4
- symfony/psr-http-message-bridge: ^2.1
Requires (Dev)
- nyholm/psr7: ^1.5
- phpunit/phpunit: ^9.0
- symplify/easy-coding-standard: ^10.2
This package is auto-updated.
Last update: 2024-09-18 01:28:27 UTC
README
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.
使用
包含供应商自动加载器并使用类
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
对象并添加您想使用的 Check
对象(s)
$screener = new Screener(); $check = new UrlCheck(); $screener->addCheck($check);
创建一个 Gatekeeper
对象并使用筛选器运行它
$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);
安装
通过 Composer 安装
安装 Composer 如果您的系统上还没有的话。
要安装库,请运行以下命令,您将获得最新的开发版本
composer require secondtruth/gatekeeper:dev-master
要求
- 您必须在系统上至少安装 PHP 版本 8.1。
作者、致谢和许可证
This project was created by Christian Neff (@secondtruth) and is licensed under the MIT License.
基于以下工作
- Michael Hampton
感谢 所有其他贡献者!