middlewares / referrer-spam
Middleware to block referrer spammers
Installs: 24 109
Dependents: 1
Suggesters: 0
Security: 0
Stars: 12
Watchers: 2
Forks: 2
Open Issues: 1
Requires
- php: ^7.2 || ^8.0
- matomo/referrer-spam-blacklist: *
- middlewares/utils: ^3.0
- psr/http-server-middleware: ^1.0
- symfony/polyfill-intl-idn: ^1.26
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0
- laminas/laminas-diactoros: ^2.2
- oscarotero/php-cs-fixer-config: ^1.0
- phpstan/phpstan: ^0.12
- phpunit/phpunit: ^8|^9
- squizlabs/php_codesniffer: ^3.0
Suggests
- ext-intl: *
README
Middleware to block referrer spammers using matomo/referrer-spam-blacklist. It returns a 403
response if the url host in the Referer
header is in the blacklist.
Requirements
- PHP >= 7.2
- A PSR-7 http library
- A PSR-15 middleware dispatcher
ext-intl
PHP extension is recommended otherwise symfony/polyfill-intl-idn is used.
Installation
This package is installable and autoloadable via Composer as middlewares/referrer-spam.
composer require middlewares/referrer-spam
Usage
By default, use matomo/referrer-spam-blacklist
as a list of spammers
$spam = new Middlewares\ReferrerSpam();
But you can configure a custom spam list if you don't want to use the default:
$spammers = [ 'http://www.0n-line.tv', 'http://холодныйобзвон.рф', ]; $spam = new Middlewares\ReferrerSpam($spammers);
Optionally, you can provide a Psr\Http\Message\ResponseFactoryInterface
as the second argument to create the error responses (403
). If it's not defined, Middleware\Utils\Factory will be used to detect it automatically.
$responseFactory = new MyOwnResponseFactory(); $spam = new Middlewares\ReferrerSpam($spammers, $responseFactory);
Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.
The MIT License (MIT). Please see LICENSE for more information.