https://github.com/helgesverre/spamprotection
A Spam Protection class for use in contact forms and comment fields, uses the StopForumSpam API.
https://github.com/helgesverre/spamprotection
Last synced: 23 days ago
JSON representation
A Spam Protection class for use in contact forms and comment fields, uses the StopForumSpam API.
- Host: GitHub
- URL: https://github.com/helgesverre/spamprotection
- Owner: HelgeSverre
- License: mit
- Created: 2014-10-06T13:57:58.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2019-06-26T13:49:30.000Z (over 6 years ago)
- Last Synced: 2024-05-01T14:13:43.245Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 21.5 KB
- Stars: 24
- Watchers: 8
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# SpamProtection
[![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md)
[![Total Downloads][ico-downloads]][link-downloads]PHP Spam Protection Class for use in Contact forms and Comment Fields
API Keys to use with this class can be obtained here: http://www.stopforumspam.com/signup
Having an API Key is only necessary if you are going to use the submitReport() function.
## Install
``` bash
$ composer require helgesverre/spamprotection
```## Usage
Example.php
```php
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.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:
```php
setFrequencyThreshold(SpamProtection::THRESHOLD_HIGH);```
The library can also flag Tor Exit Nodes as spam when they are encountered.
To enable this use the ```setAllowTorNodes($allowTorNodes)``` to true or false, or specify it as the second param in the constructor:
```php
setAllowTorNodes(false);
```## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
[ico-version]: https://img.shields.io/packagist/v/helgesverre/spamprotection.svg?style=flat-square
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-downloads]: https://img.shields.io/packagist/dt/helgesverre/spamprotection.svg?style=flat-square[link-packagist]: https://packagist.org/packages/helgesverre/spamprotection
[link-downloads]: https://packagist.org/packages/helgesverre/spamprotection
[link-author]: https://github.com/helgesverre