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
没找到您需要的内容? 联系我们的技术支持团队以获取帮助.
您可能也会感兴趣
- CleanTalk API 方法CleanTalk API 方法 本文介绍 CleanTalk 提供的公共 API 方法,用于垃圾信息和机器人检测、访问黑名单数据库以及客户数据管理。 我们的云端每天处理海量数据以识别垃圾信息发送者,这些能力可通过多种...