middlewares/referrer-spam

Middleware to block referrer spammers

v2.0.0 2019-12-07 09:44 UTC

This package is auto-updated.

Last update: 2020-05-07 10:55:08 UTC


README

Latest Version on Packagist Software License Build Status Quality Score Total Downloads

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

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.