Giter Site home page Giter Site logo

cleantalk / php-antispam Goto Github PK

View Code? Open in Web Editor NEW
55.0 17.0 29.0 235 KB

A PHP API for antispam service cleantalk.org. Invisible protection from spam, no captches, no puzzles, no animals and no math.

Home Page: http://cleantalk.org

PHP 96.87% HTML 3.13%
php antispam spam php-api spam-protection

php-antispam's Introduction

php-antispam

Build Status

Latest Stable Version

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

composer require cleantalk/php-antispam

Sample SPAM test for text comment and user signup

<?php
session_start();

$apikey = 'your_cleantalk_api_key';
$email_field = 'name_email_form_field';
$user_name_field = 'name_user_name_form_field';
$message_field = 'name_message_form_field';
$type_form = 'contact'; // use 'signup' for user signup form

// if downloaded, unzip and include the app:
require_once 'php-antispam/cleantalk-antispam.php';
// if install the app by composer package:
use Cleantalk\CleantalkAntispam;

//require_once "lib/cleantalk-php-patch.php"; -- PHP-FPM

$cleantalk_antispam = new CleantalkAntispam($apikey, $email_field, $user_name_field, $message_field, $type_form);
$api_result = $cleantalk_antispam->handle();
?>

<form method="post">
    <label for="login">Login:</label>
    <input type="text" name="name_user_name_form_field" id="login" />
    <br />
    <label for="email">Email:</label>
    <input type="text" name="name_email_form_field" id="email" value="" />
    <br />
    <label for="message">Message:</label>
    <textarea name="name_message_form_field" id="message"></textarea>
    <br />
    <input type="submit" />
</form>

<?php $cleantalk_antispam->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

php-antispam's People

Contributors

alexandergull avatar ardavydov avatar artemanoshin avatar bechir avatar dada-amater avatar glomberg avatar goodot avatar jimwins avatar psrustik avatar safronik avatar shagimuratov avatar svfcode avatar vladcleantalk avatar znaeff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-antispam's Issues

apache_request_headers doesn't exists on PHP-FPM

Subj.
In the previous version (without classes), you controlled function_exists and applied custom functions.

But in the current version, the cleantalk-php-patch file doesn't include and doesn't work.

As a solution, I recommend using the php getallheaders () function, an analogue of apache_request_headers, but operating in fpm mode.

P.S. tested on php 7.2.6 FPM/FastCGI

New release?

Hello,

I use the latest release and now i can see, it is 3 years old. Please make new releases, so we can see it in composer and update the library to latest version.

Error response when checking a message with less than three characters

I encounter the following error, *** Unknown response from http://88.198.153.60/api2.0. Error 2: Illegal division by zero at /usr/local/cleantalk/lib/Cleantalk/Moderate.pm line 5214. Antispam service cleantalk.org ***, when I make a call to isAllowMessage with a message with less than three characters.

Case-Sensitivity - Namespace (CleanTalk vs Cleantalk)

I'm a firm believer in honouring and respecting a name with its proper case, and this project is clearly called "CleanTalk", with a capital "T".

Throughout this codebase, the class namespaces are written "Cleantalk", whereas other references in the project have the name written as "CleanTalk". This is confusing, and also interferes with PSR-4 autoloading. A developer would need to know to always write Cleantalk for the namespace for autoloading to work.

I know many developers adhere strictly to Abcdefgh case, where only the first letter is uppercased, but I think exceptions should be made for the case of proper names.

The PSR-4: Autoloading gives the following example:
\<NamespaceName>(\<SubNamespaceNames>)*\<ClassName>

You can clearly see that they have a capital "N" partway through the namespace names.

They also state this:

  • Alphabetic characters in the fully qualified class name MAY be any combination of lower case and upper case.

I would like to see this library adhere stricktly to "CleanTalk" case throughout the code and documentation. That is the project's name, after all. This consistency removes the confusion about how the namespace must be written just for the autoloader to work.

Thoughts?

Сделайте компонент для ICMS 2

Добрый вечер, сделайте пожалуйста компонент Анти_СПАМ для ICMS 2. Искал у Вас готовое решение, но именно этой CMS не нашёл. Спасибо.

New release

Hi,

Can you please make a new release? There are some nice changes and fixes, but I am not able to merge them until you release them. Thank you.

New release

Hi,

Can you please make a new release. There are some nice minor changes, but I am not able to merge until you release it. Thank you.

Rename namespace from "lib" to be more precise

Currently the namespace for the classes used is lib so a consumer of this package will use lib\Cleantalk;

Namespaces should be unique across the ecosystem and I don't think that something as generic as lib is sufficiently unique to assign to CleanTalk.

I propose that the namespace should be renamed to Cleantalk:

use Cleantalk\CleanTalk;

This will be a breaking change so the major version should be bumped accordingly.

Cheers

Undefined variable: $servers

Hi,
I was testing my Symfony app to use this library but when i call theisAllowMessage function, i get this error:
Undefined variable: servers

In fact this variable doesn't exists in the function:

private function get_servers_ip($host)
{
if (!isset($host))
return null;
// Get DNS records about URL
if (function_exists('dns_get_record')) {
$records = dns_get_record($host, DNS_A);
if ($records !== FALSE) {
foreach ($records as $server) {
$servers[] = $server;
}
}
}
// Another try if first failed
if (count($servers) == 0 && function_exists('gethostbynamel')) {
$records = gethostbynamel($host);
if ($records !== FALSE) {
foreach ($records as $server) {
$servers[] = array(
"ip" => $server,
"host" => $host,
"ttl" => $this->server_ttl
);

PHP version requirements

In README, the PHP version requirements are php-4.3+.

At this moment, the official PHP team still support the PHP versions are php-5.6, php-7.0, php-7.1, php-7.2 and php-7.3.

The php-5.6 and php-7.0 will be end of life at recent time.

IMHO, we should consider let this PHP package require php-7.1 version at least.

Missing includes

Your example code from readme does not work without additionally including:

/cleantalk-php/lib/cleantalk-php-patch.php

and

/cleantalk-php/lib/CleantalkResponse.php

PHP 8.1 Errors

When trying to execute a call, the following errors are coming up:

Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /vendor/cleantalk/php-antispam/lib/CleantalkHelper.php on line 328

Deprecated: Implicit conversion from float 207.1 to int loses precision in /vendor/cleantalk/php-antispam/lib/Cleantalk.php on line 543

Deprecated: Implicit conversion from float 332.2 to int loses precision in /vendor/cleantalk/php-antispam/lib/Cleantalk.php on line 543

Deprecated: Implicit conversion from float 147.2 to int loses precision in /vendor/cleantalk/php-antispam/lib/Cleantalk.php on line 543

Deprecated: Implicit conversion from float 296.09999999999997 to int loses precision in /vendor/cleantalk/php-antispam/lib/Cleantalk.php on line 543

Deprecated: Implicit conversion from float 296.20000000000005 to int loses precision in /vendor/cleantalk/php-antispam/lib/Cleantalk.php on line 543

Deprecated: Implicit conversion from float 294.4 to int loses precision in /vendor/cleantalk/php-antispam/lib/Cleantalk.php on line 543

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /vendor/cleantalk/php-antispam/lib/CleantalkResponse.php on line 149

ct_tmp COOKIE ErrorException

Hi,
We had this ErrorException for a dodgy registration request. I suspect it was a bot or something similar.

exception 'ErrorException' with message 'Undefined index: COOKIE' in cleantalk.class.php:748

Can you please cover the situation when there is no "Cookie", "cookie" or "COOKIE" index on ct_tmp ?

Thanks!

Readme 'use' path is wrong

I'm using composer for the install. The Readme example which reads

use lib\Cleantalk;
use lib\CleantalkRequest;

does't work with composer.

If I use the path from the example.php it works:

use Cleantalk\CleantalkRequest;
use Cleantalk\Cleantalk;

CURL ошибка: "SSL: certificate subject name

Регулярно сыпится на почту сообщения с сервера

CURL ошибка: "SSL: certificate subject name '*.cleantalk.org' does not
match target host name '88.198.153.60'" или выключена настройка
allow_url_fopen в php.ini.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.