https://github.com/cleantalk/php-antispam
A PHP API for antispam service cleantalk.org. Invisible protection from spam, no captches, no puzzles, no animals and no math.
https://github.com/cleantalk/php-antispam
antispam php php-api spam spam-protection
Last synced: 11 months ago
JSON representation
A PHP API for antispam service cleantalk.org. Invisible protection from spam, no captches, no puzzles, no animals and no math.
- Host: GitHub
- URL: https://github.com/cleantalk/php-antispam
- Owner: CleanTalk
- Created: 2013-09-01T10:54:39.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2025-05-13T07:09:35.000Z (11 months ago)
- Last Synced: 2025-05-16T06:04:20.323Z (11 months ago)
- Topics: antispam, php, php-api, spam, spam-protection
- Language: PHP
- Homepage: http://cleantalk.org
- Size: 282 KB
- Stars: 62
- Watchers: 17
- Forks: 31
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
php-antispam
============

[](https://packagist.org/packages/cleantalk/php-antispam)
A PHP API for antispam service cleantalk.org. Invisible protection from spam, no captches, no puzzles, no animals and no math.
## How API stops spam?
API uses several simple tests to stop spammers.
* Spam bots signatures.
* Blacklists checks by Email, IP, web-sites domain names.
* JavaScript availability.
* Relevance test for the comment.
## How API works?
API sends a comment's text and several previous approved comments to the servers. Servers evaluates the relevance of the comment's text on the topic, tests on spam and finaly provides a solution - to publish or put on manual moderation of comments. If a comment is placed on manual moderation, the plugin adds to the text of a comment explaining the reason for the ban server publishing.
## Requirements
* PHP 5.6 and above
* CURL support
You can unpack the archive with the plugin to the root of the site or install it using the composer
```php
composer require cleantalk/php-antispam
```
### Sample SPAM test for text comment
Notice: You can use the example PHP file from ./examples/form_with_handler
```php
handle();
if ($api_result) { // the check fired
if ($api_result->account_status !== 1) {
// something wrong with your key or license, to know why read $api_result->codes
echo 'Allowed. Spam protection disabled.'; // or do nothing
} else {
if ($api_result->allow === 1) {
echo 'Allowed. Spam protection OK.'; // or do nothing
} else {
die('Blocked. Spam protection OK. Reason: ' . $api_result->comment); // or make your own handler
}
}
}
// your further code flow here
?>
Login:
Email:
Message:
frontendScript(); ?>
```
## API Response description
API returns (`$api_result`) PHP object:
* allow (0|1) - allow to publish or not, in other words spam or ham
* comment (string) - server comment for requests.
* id (string MD5 HEX hash) - unique request idenifier.
* errno (int) - error number. errno == 0 if requests successfull.
* errstr (string) - comment for error issue, errstr == null if requests successfull.
* account_status - 0 account disabled, 1 account enabled, -1 unknown status.
## Don't want to deal with all this?
Universal solution for any CMS or custom website: https://github.com/CleanTalk/php-uni