How to protect osTicket from spambots
-
Download CleanTalk API from Github.com
-
Unzip the downloaded archive to your root directory. You will see the folder with the name "php-antispam-master". Rename it to "cleantalk"
-
Edit "open.php" script in your osTicket folder
In order to start using the CleanTalk Anti-Spam API you need to connect it to your site. You can paste this code at the top of your script:
session_start(); //Session
require_once (dirname(__FILE__) . '/cleantalk/cleantalk-antispam.php');
Replace the following code:
if(($ticket=Ticket::create($vars, $errors, SOURCE))) {
$msg=__('Support ticket request created');
// Drop session-backed form data
unset($_SESSION[':form-data']);
//Logged in...simply view the newly created ticket.
if($thisclient && $thisclient->isValid()) {
session_write_close();
session_regenerate_id();
@header('Location: tickets.php?id='.$ticket->getId());
}
}
else {
$errors['err']=$errors['err']?$errors['err']:__('Unable to create a ticket. Please correct errors below and try again!');
}
With this one:
$uform = UserForm::getUserForm()->getForm($_POST);
$config_url = 'http://moderate.cleantalk.org'; //Server address
$auth_key = '000000000'; // Your access key
$ct_request = new CleantalkRequest();
$ct_request->auth_key = $auth_key; //access key variable
$ct_request->message = $tform->getField('message'); //message to check
$ct_request->method_name = 'check_message'; //method
$ct_request->sender_email = $uform->getClean()['email']; //e-mail to check
$ct_request->sender_nickname = $uform->getClean()['name']; //name to check
$ct_request->agent = 'php-api'; //extension name
$ct_request->sender_ip = $_SERVER["REMOTE_ADDR"]; //ip to check
$ct = new Cleantalk();
$ct->server_url = $config_url;
$ct_result = $ct->isAllowMessage($ct_request);
if ($ct_result->allow == 1) {
if(($ticket=Ticket::create($vars, $errors, SOURCE))) {
$msg=__('Support ticket request created');
// Drop session-backed form data
unset($_SESSION[':form-data']);
//Logged in...simply view the newly created ticket.
if($thisclient && $thisclient->isValid()) {
session_write_close();
session_regenerate_id();
@header('Location: tickets.php?id='.$ticket->getId());
}
}
else {
$errors['err']=$errors['err']?$errors['err']:__('Unable to create a ticket. Please correct errors below and try again!');
}
}
else {
echo 'Comment blocked. Reason ' . $ct_result->comment;
}
The following line can be replaced with your custom warning page:
echo 'Comment blocked. Reason ' . $ct_result->comment;
For example:
@header('Location: blocked.php');
Use the blacklisted e-mail s@cleantalk.org to create a ticket. As a result, you will see the blocking message at the top of the page
Couldn't find what you were looking for? Contact our technical support team for assistance.
It would also be interesting
- All Installation Manuals of CleanTalk Anti-Spam ServiceCleanTalk Anti-Spam Installation Guides Here you can find our plugin installation guides for popular...
- Block Lists Database APIBlock Lists API Method "spam_check" API backlinks_check How to Check IPs and Emails...
- Spam detection API method check_newuser()Anti-Spam "check_newuser" API method This API method is best suited to detect spam registrations, subscriptions,...