2017 © Pedro Peláez
 

library spamprotection

A Spam Protection class for use in contact forms and comment fields, uses the StopForumSpam API.

image

helgesverre/spamprotection

A Spam Protection class for use in contact forms and comment fields, uses the StopForumSpam API.

  • Friday, October 23, 2015
  • by HelgeSverre
  • Repository
  • 5 Watchers
  • 19 Stars
  • 1,009 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 2 Open issues
  • 2 Versions
  • 15 % Grown

The README.md

SpamProtection

Latest Version on Packagist ![Software License][ico-license] Total Downloads, (*1)

PHP Spam Protection Class for use in Contact forms and Comment Fields, (*2)

API Keys to use with this class can be obtained here: http://www.stopforumspam.com/signup, (*3)

Having an API Key is only necessary if you are going to use the submitReport() function., (*4)

Install

``` bash $ composer require helgesverre/spamprotection, (*5)




## Usage Example.php ```php <?php use Helge\SpamProtection\SpamProtection; use Helge\SpamProtection\Types; require 'vendor/autoload.php'; $spamProtector = new SpamProtection(); /** * All checks can be called from the check() method, * first param is the type of check, second is the value (ip, email, username) */ var_dump($spamProtector->check(Types::EMAIL, "helge.sverre@gmail.com")); var_dump($spamProtector->check(Types::IP, "8.8.8.8")); var_dump($spamProtector->check(Types::USERNAME, "helgesverre")); /** * For convenience some wrapper methods are provided, * they simply pass the data long to check() */ var_dump($spamProtector->checkEmail("helge.sverre@gmail.com")); var_dump($spamProtector->checkIP("8.8.8.8")); var_dump($spamProtector->checkUsername("spammer"));

the check methods returns a bool, where TRUE means the IP/Email/Username has been flagged as spam., (*6)

If you want to specify a "threshold" of how many spam reports are needed before something is flagged as spam you can use the setFrequencyThreshold() method or specify a threshold in the constructor:, (*7)

<?php
use Helge\SpamProtection\SpamProtection;
use Helge\SpamProtection\Types;

require 'vendor/autoload.php';

/*
    The following constants are available in the spamprotection class for convenience
    const THRESHOLD_STRICT = 1;
    const THRESHOLD_HIGH = 3;
    const THRESHOLD_MEDIUM = 5;
    const THRESHOLD_LOW = 10;
*/

$spamProtector = new SpamProtection(SpamProtection::THRESHOLD_STRICT);

// or 

$spamProtector = new SpamProtection();
$spamProtector->setFrequencyThreshold(SpamProtection::THRESHOLD_HIGH);

The library can also flag Tor Exit Nodes as spam when they are encountered., (*8)

To enable this use the setAllowTorNodes($allowTorNodes) to true or false, or specify it as the second param in the constructor:, (*9)

<?php
use Helge\SpamProtection\SpamProtection;
use Helge\SpamProtection\Types;

require 'vendor/autoload.php';

/*
    The following constants are available in the spamprotection class for convenience
    const TOR_ALLOW = true;
    const TOR_DISALLOW = false;
*/

$spamProtector = new SpamProtection(SpamProtection::THRESHOLD_STRICT, SpamProtection::TOR_DISALLOW);

// or 

$spamProtector = new SpamProtection();
$spamProtector->setAllowTorNodes(false);

License

The MIT License (MIT). Please see License File for more information., (*10)

The Versions

23/10 2015

dev-master

9999999-dev https://helgesverre.com/products/spamprotection

A Spam Protection class for use in contact forms and comment fields, uses the StopForumSpam API.

  Sources   Download

MIT

api spam protection anti-spam stopforumspam

23/10 2015

1.0.0

1.0.0.0 https://helgesverre.com/products/spamprotection

A Spam Protection class for use in contact forms and comment fields, uses the StopForumSpam API.

  Sources   Download

MIT

api spam protection anti-spam stopforumspam