PHP Classes

CleanTalk PHP Spam Filter Class: Detect spam in comments using the CleanTalk API

Recommend this page to a friend!

  Author Author  
Picture of Alexey Znaev
Name: Alexey Znaev is available for providing paid consulting. Contact Alexey Znaev .
Classes: 3 packages by
Country: Russian Federation Russian Federation
Age: 50
All time rank: 198156 in Russian Federation Russian Federation
Week rank: 496 Up24 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 1x


  Detailed description   Download Download .zip .tar.gz   Install with Composer Install with Composer  
This class can detect spam in comments using the CleanTalk API.

It can send HTTP requests to the CleanTalk API Web server to determine if the text of given comments is considered spam.

The class can send requests to check a given message, check the user IP address and user agent, give feedback of manually moderated message.

Details
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 4.3 and above * CURL support ## Sample SPAM test for user signup ```php <?php require_once (dirname(__FILE__) . '/cleantalk.class.php'); // Take params from config $config_url = 'http://moderate.cleantalk.ru/api2.0/'; $auth_key = 'enter key'; // Set Cleantalk auth key if (count($_POST)) { $sender_nickname = 'John Dow'; if (isset($_POST['login']) && $_POST['login'] != '') $sender_nickname = $_POST['login']; $sender_email = 'stop_email@example.com'; if (isset($_POST['email']) && $_POST['email'] != '') $sender_email = $_POST['email']; $sender_ip = null; if (isset($_SERVER['REMOTE_ADDR'])) $sender_ip = $_SERVER['REMOTE_ADDR']; $js_on = 0; if (isset($_POST['js_on']) && $_POST['js_on'] == date("Y")) $js_on = 1; // The facility in which to store the query parameters $ct_request = new CleantalkRequest(); $ct_request->auth_key = $auth_key; $ct_request->agent = 'php-api'; $ct_request->sender_email = $sender_email; $ct_request->sender_ip = $sender_ip; $ct_request->sender_nickname = $sender_nickname; $ct_request->js_on = $js_on; $ct = new Cleantalk(); $ct->server_url = $config_url; // Check $ct_result = $ct->isAllowUser($ct_request); if ($ct_result->allow == 1) { echo 'User allowed. Reason ' . $ct_result->comment; } else { echo 'User forbidden. Reason ' . $ct_result->comment; } echo '<br /><br />'; } ?> <form method="post"> <label for="login">Login:<label> <input type="text" name="login" id="login" /> <br /> <label for="email">Email:<label> <input type="text" name="email" id="email" value="" /> <br /> <input type="hidden" name="js_on" id="js_on" value="0" /> <input type="submit" /> </form> <script type="text/javascript"> var date = new Date(); document.getElementById("js_on").value = date.getFullYear(); </script> ``` ## Sample SPAM test for text comment ```php <?php require_once (dirname(__FILE__) . '/cleantalk.class.php'); // Take params from config $config_url = 'http://moderate.cleantalk.ru/api2.0/'; $auth_key = 'enter key'; // Set Cleantalk auth key if (count($_POST)) { $sender_nickname = 'John Dow'; if (isset($_POST['login']) && $_POST['login'] != '') $sender_nickname = $_POST['login']; $sender_email = 'stop_email@example.com'; if (isset($_POST['email']) && $_POST['email'] != '') $sender_email = $_POST['email']; $sender_ip = null; if (isset($_SERVER['REMOTE_ADDR'])) $sender_ip = $_SERVER['REMOTE_ADDR']; $js_on = 0; if (isset($_POST['js_on']) && $_POST['js_on'] == date("Y")) $js_on = 1; $message = null; if (isset($_POST['message']) && $_POST['message'] != '') $message = $_POST['message']; // The facility in which to store the query parameters $ct_request = new CleantalkRequest(); $ct_request->auth_key = $auth_key; $ct_request->agent = 'php-api'; $ct_request->sender_email = $sender_email; $ct_request->sender_ip = $sender_ip; $ct_request->sender_nickname = $sender_nickname; $ct_request->js_on = $js_on; $ct_request->message = $message; $ct_request->example = str_repeat('Just example text ', 10); $ct = new Cleantalk(); $ct->server_url = $config_url; // Check $ct_result = $ct->isAllowMessage($ct_request); if ($ct_result->allow == 1) { echo 'Message allowed. Reason ' . $ct_result->comment; } else { echo 'Message forbidden. Reason ' . $ct_result->comment; } echo '<br /><br />'; } ?> <form method="post"> <label for="login">Login:<label> <input type="text" name="login" id="login" /> <br /> <label for="email">Email:<label> <input type="text" name="email" id="email" value="" /> <br /> <label for="message">Message:<label> <textarea name="message" id="message"></textarea> <br /> <input type="hidden" name="js_on" id="js_on" value="0" /> <input type="submit" /> </form> <script type="text/javascript"> var date = new Date(); document.getElementById("js_on").value = date.getFullYear(); </script> ``` ## API Response description API returns 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. * errtstr (string) - comment for error issue, errstr == null if requests successfull. * account_status - 0 account disabled, 1 account enabled, -1 unknown status.

  Classes of Alexey Znaev  >  CleanTalk PHP Spam Filter Class  >  Download Download .zip .tar.gz  >  Support forum Support forum (3)  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: CleanTalk PHP Spam Filter Class
Base name: cleantalk
Description: Detect spam in comments using the CleanTalk API
Version: 1.23
PHP version: 4.3
License: BSD License
All time users: 416 users
All time rank: 6409
Week users: 0 users
Week rank: 149 Equal
 
  Groups   Rate classes User ratings   Applications   Files Files  

  Groups  
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Content management Components and tools to manage content View top rated classes
Group folder image Web services Web data clipping, SOAP or XML-RPC clients and servers View top rated classes
Group folder image Blogs Managing and publishing blogs View top rated classes


  User ratings  
Not enough user ratings

  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Accessible without login Plain text file cleantalk.class.php Class Base class
Accessible without login Plain text file JSON.php Class Required JSON library
Accessible without login Plain text file example.php Example Example to work with CleanTalk
Accessible without login Plain text file readme.txt Doc. Short description of CleanTalk

Install with Composer Install with Composer - Download Download all files: cleantalk.tar.gz cleantalk.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
  Files folder image Files  
File Role Description
Accessible without login Plain text file cleantalk.class.php Class Base class
Accessible without login Plain text file JSON.php Class Required JSON library
Accessible without login Plain text file example.php Example Example to work with CleanTalk
Accessible without login Plain text file readme.txt Doc. Short description of CleanTalk

Install with Composer Install with Composer - Download Download all files: cleantalk.tar.gz cleantalk.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.