2017 © Pedro Peláez
 

library spammers

Simple package to prevent accessing of spammers to Laravel application

image

andrey-helldar/spammers

Simple package to prevent accessing of spammers to Laravel application

  • Friday, July 6, 2018
  • by Helldar
  • Repository
  • 1 Watchers
  • 0 Stars
  • 105 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 12 Versions
  • 50 % Grown

The README.md

Spammers for Laravel 5.4+

Simple package to prevent accessing of spammers to Laravel application., (*1)

spammers, (*2)

StyleCI Total Downloads Latest Stable Version Latest Unstable Version License , (*3)

Installation

To get the latest version of this package, simply require the project using Composer:, (*4)

$ composer require andrey-helldar/spammers

Instead, you may of course manually update your require block and run composer update if you so choose:, (*5)

{
    "require": {
        "andrey-helldar/spammers": "^1.0"
    }
}

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php:, (*6)

Helldar\Spammers\ServiceProvider::class,

Next, call php artisan vendor:publish and php artisan migrate commands after set up config/spammers.php file and install the migrations by running php artisan migrate command., (*7)

Now, use spammer() helper and Artisan commands., (*8)

Documentation

Helpers Store

Store IP-address in a spam-table:, (*9)

spammer()
    ->ip('1.2.3.4')
    ->store();

// or

spammer('1.2.3.4')->store();

Delete IP-address from a spam-table:, (*10)

spammer()
    ->ip('1.2.3.4')
    ->delete();

// or

spammer('1.2.3.4')->delete();

Restore IP-address from a spam-table:, (*11)

spammer()
    ->ip('1.2.3.4')
    ->restore();

// or

spammer('1.2.3.4')->restore();

Check exists IP-address in a spam-table:, (*12)

spammer()
    ->ip('1.2.3.4')
    ->exists();

// or

spammer('1.2.3.4')->exists();

Helpers Accessing

To save an IP address with the URL in the database, use the helper spammer()->access():, (*13)

spammer()
    ->access()
    ->ip('1.2.3.4')
    ->url('/foo/bar')
    ->store();

// or

spammer('1.2.3.4')
    ->access()
    ->url('/foo/bar')
    ->store();

Ban when attempts to get pages with errors exceed a given number., (*14)

Example:, (*15)

  • When the number of attempts reaches 100 - ban for 24 hours.
  • When the number of attempts reaches 300 - ban for 72 hours.
  • When the number of attempts reaches 500 - permanent ban.

Default, permanent ban., (*16)

Middleware

Next, add link to middleware in $routeMiddleware block in app/Http/Kernel.php file, and use him in $middlewareGroups blocks:, (*17)

protected $middlewareGroups = [
    'web' => [
        // ...
        'spammers'
    ],

    'api' => [
        // ...
        'spammers'
    ],
];

protected $routeMiddleware = [
    // ...
    'spammers' => Helldar\Spammers\Middleware\Spammers::class
];

Or you can specify globally in the attribute $middleware of the Http/Kernel.php file:, (*18)

protected $middleware = [
    // ...
    \Helldar\Spammers\Middleware\Spammers::class,    
];

Console Command

This package maybe called in a console:, (*19)

spam:amnesty
spam:store 1.2.3.4
spam:delete 1.2.3.4
spam:restore 1.2.3.4
spam:exists 1.2.3.4

The spam:amnesty command allows you to delete IP-addresses that have expired., (*20)

Additional

You can use a Helldar\Spammers\Models\Spammer model. His extended Illuminate\Database\Eloquent\Model., (*21)

Simple Using

You can specify globally in the attribute $middleware of the Http/Kernel.php file:, (*22)

protected $middleware = [
    // ...
    \Helldar\Spammers\Middleware\Spammers::class,    
];

Next, in the report() method of file app\Exceptions\Handler.php, add the call to the spammer()->access() helper:, (*23)

public function report(Exception $exception)
{
    spammer(request()->ip())
        ->access()
        ->url(request()->fullUrl())
        ->store();

    parent::report($exception);
}

And add a rule to the schedule() method of the app/Console/Kernel.php file:, (*24)

protected function schedule(Schedule $schedule)
{
    $schedule->command('spam:amnesty')
        ->everyThirtyMinutes();
}

Execute the commands:, (*25)

php artisan vendor:publish
php artisan migrate

Customize the file config/spammers.php for your purposes., (*26)

Profit!, (*27)

Laravel Spammers was written by Andrey Helldar for the Laravel framework 5.4 or later, and is released under the MIT License. See the LICENSE file for details., (*28)

Translation

Translations of text and comment by Google Translate. Help with translation +1 in karma :), (*29)

The Versions

06/07 2018

dev-master

9999999-dev

Simple package to prevent accessing of spammers to Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel spammers

06/07 2018

dev-analysis-qyV93o

dev-analysis-qyV93o

Simple package to prevent accessing of spammers to Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel spammers

02/03 2018
20/02 2018
20/02 2018

dev-analysis-zGNN9l

dev-analysis-zGNN9l

Simple package to prevent accessing of spammers to Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel spammers

20/02 2018

1.0.6

1.0.6.0

Simple package to prevent accessing of spammers to Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel spammers

17/01 2018

1.0.5

1.0.5.0

Simple package to prevent accessing of spammers to Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel spammers

07/12 2017

1.0.4

1.0.4.0

Simple package to prevent accessing of spammers to Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel spammers

04/12 2017

1.0.3

1.0.3.0

Simple package to prevent accessing of spammers to Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel spammers

04/12 2017

1.0.2

1.0.2.0

Simple package to prevent accessing of spammers to Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel spammers

04/12 2017

1.0.1

1.0.1.0

Simple package to prevent accessing of spammers to Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel spammers

04/12 2017

1.0.0

1.0.0.0

Simple package to prevent accessing of spammers to Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel spammers