/** * Checking Order forms for spam * @param &array Comment fields to check * @return null|boolean NULL when success or FALSE when spam detected */ function OnBeforeOrderAddHandler(&$arFields) { global $APPLICATION, $USER; $ct_status = COption::GetOptionString('cleantalk.antispam', 'status', '0'); $ct_order = COption::GetOptionString('cleantalk.antispam', 'form_order', '0'); if ($ct_status == 1 && $ct_order == 1) { $sender_email = null; $message = ''; foreach ($_POST as $key => $value) { if (strpos($key, 'ORDER_PROP_') !== false) { if ($sender_email === null && preg_match("/^\\S+@\\S+\\.\\S+\$/", $value)) { $sender_email = $value; } else { $message .= "{$value}\n"; } } } $message .= $_POST['ORDER_DESCRIPTION']; $arUser = array(); $arUser["type"] = "comment"; $arUser["sender_email"] = $sender_email; $arUser["sender_nickname"] = ''; $arUser["sender_ip"] = $_SERVER['REMOTE_ADDR']; $arUser["message_title"] = ""; $arUser["message_body"] = $message; $arUser["example_title"] = ""; $arUser["example_body"] = ""; $arUser["example_comments"] = ""; $aResult = CleantalkAntispam::CheckAllBefore($arUser, FALSE); if (isset($aResult) && is_array($aResult)) { if ($aResult['errno'] == 0) { if ($aResult['allow'] == 1) { //Not spammer - just return; return; } else { $APPLICATION->ThrowException($aResult['ct_result_comment']); return false; } } } } }
<div class="forum-signature-line"></div> <span><?=$res["SIGNATURE"]?></span> </div> <? endif; ?> </div> <? if ($arRes["USER"]["PERMISSION"] >= "Q"): ?> <div class="forum-post-entry forum-user-additional forum-user-moderate-info"> <!-- CLEANTALK template addon --> <?php if(CModule::IncludeModule("cleantalk.antispam")){ $aRes = CleantalkAntispam::GetCleanTalkResume("forum",$res["ID"]); if($aRes){ ?> <span>CleanTalk: <span><?php echo $aRes['ct_result_comment'];?></span></span> <?php } } ?> <!-- /CLEANTALK template addon --> <? if ($res["IP_IS_DIFFER"] == "Y"): ?> <span>IP<?=GetMessage("F_REAL_IP")?>: <span><?=$res["AUTHOR_IP"];?> / <?=$res["AUTHOR_REAL_IP"];?></span></span> <? else:
public function send_logs() { $is_sfw = COption::GetOptionString('cleantalk.antispam', 'form_sfw', 0); $sfw_log = COption::GetOptionString('cleantalk.antispam', 'sfw_log', ''); if ($is_sfw == 1 && $sfw_log != '') { $sfw_log = json_decode($sfw_log, true); $data = array(); foreach ($sfw_log as $key => $value) { $data[] = array($key, $value['all'], $value['allow'], $value['datetime']); } $qdata = array('data' => json_encode($data), 'rows' => count($data), 'timestamp' => time()); if (!function_exists('sendRawRequest')) { require_once 'classes/general/cleantalk.class.php'; } $result = sendRawRequest('https://api.cleantalk.org/?method_name=sfw_logs&auth_key=' . $ct_options['apikey'], $qdata); $result = CleantalkAntispam::CleantalkSendRequest('https://api.cleantalk.org/?method_name=sfw_logs&auth_key=' . $key, $qdata, false); $result = json_decode($result); if (isset($result->data) && isset($result->data->rows)) { if ($result->data->rows == count($data)) { COption::SetOptionString('cleantalk.antispam', 'sfw_log', ''); } } } }
*/ $sModuleId = 'cleantalk.antispam'; CModule::IncludeModule($sModuleId); global $MESS; IncludeModuleLangFile(__FILE__); if ($REQUEST_METHOD == 'POST' && $_POST['Update'] == 'Y') { /** * Set settings when submit */ $old_key = COption::GetOptionString($sModuleId, 'key', ''); $new_key = $_POST['key']; //if($old_key!=$new_key) //{ $url = 'http://moderate.cleantalk.org/api2.0'; $dt = array('auth_key' => $new_key, 'method_name' => 'check_message', 'message' => 'CleanTalk setup test', 'example' => null, 'agent' => 'bitrix-370', 'sender_ip' => $_SERVER['REMOTE_ADDR'], 'sender_email' => '*****@*****.**', 'sender_nickname' => 'CleanTalk', 'js_on' => 1); $result = CleantalkAntispam::CleantalkSendRequest($url, $dt, true); //} COption::SetOptionString($sModuleId, 'status', $_POST['status'] == '1' ? '1' : '0'); COption::SetOptionString($sModuleId, 'form_new_user', $_POST['form_new_user'] == '1' ? '1' : '0'); COption::SetOptionString($sModuleId, 'form_comment_blog', $_POST['form_comment_blog'] == '1' ? '1' : '0'); COption::SetOptionString($sModuleId, 'form_comment_forum', $_POST['form_comment_forum'] == '1' ? '1' : '0'); COption::SetOptionString($sModuleId, 'form_comment_treelike', $_POST['form_comment_treelike'] == '1' ? '1' : '0'); COption::SetOptionString($sModuleId, 'form_send_example', $_POST['form_send_example'] == '1' ? '1' : '0'); COption::SetOptionString($sModuleId, 'form_order', $_POST['form_order'] == '1' ? '1' : '0'); COption::SetOptionString($sModuleId, 'is_paid', $_POST['is_paid'] == '1' ? '1' : '0'); COption::SetOptionString($sModuleId, 'last_checked', $_POST['last_checked'] == '1' ? '1' : '0'); COption::SetOptionString($sModuleId, 'form_global_check', $_POST['form_global_check'] == '1' ? '1' : '0'); COption::SetOptionString($sModuleId, 'form_sfw', $_POST['form_sfw'] == '1' ? '1' : '0'); COption::SetOptionString($sModuleId, 'sfw_last_updated', $_POST['sfw_last_updated'] == '1' ? '1' : '0'); COption::SetOptionString($sModuleId, 'ip_license', $_POST['ip_license'] == '1' ? '1' : '0'); COption::SetOptionString($sModuleId, 'moderate_ip', $_POST['moderate_ip'] == '1' ? '1' : '0');