Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemAnoshin committed Aug 12, 2021
2 parents b419542 + a529385 commit bb85eb3
Show file tree
Hide file tree
Showing 8 changed files with 405 additions and 314 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bitrix-antispam
===============

1C Bitrix anti-spam mod. 3.11.16
1C Bitrix anti-spam mod. 3.11.17

Information page,
http://cleantalk.org/bitrix-antispam-module-bez-captcha
Expand Down
631 changes: 340 additions & 291 deletions cleantalk.antispam/include.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cleantalk.antispam/install/version.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$arModuleVersion = array(
"VERSION" => "3.11.16",
"VERSION" => "3.11.17",
"VERSION_DATE" => "2021-05-31 10:00:00"
);
2 changes: 2 additions & 0 deletions cleantalk.antispam/lang/en/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@
$MESS['CLEANTALK_EXCLUSIONS_FIELDS_DESCRIPTION'] = 'Exclude fields from spam check. List them separated by commas. Works on forms except for registration and comment forms.';
$MESS['CLEANTALK_EXCLUSIONS_WEBFORM'] = 'Web-form ID exclusion';
$MESS['CLEANTALK_EXCLUSIONS_WEBFORM_DESCRIPTION']= 'Exclude forms (Web-forms module) by provided IDs. List them separated by commas.';
$MESS['CLEANTALK_EXCLUSIONS_SITES'] = 'Sites exclusions';
$MESS['CLEANTALK_EXCLUSIONS_SITES_DESCRIPTION'] = 'Exclude sites from spam checking. You can select many';
$MESS['CLEANTALK_TRIAL_NOTIFY']= "<b>Anti-spam by CleanTalk</b> trial period ends, please, upgrade to <a href='https://cleantalk.org/my/bill/recharge?utm_source=bitrix-backend&utm_medium=cpc&utm_campaign=bitrix-backend-trial&user_token=".COption::GetOptionString('cleantalk.antispam', 'user_token', '')."&cp_mode=antispam' target='_blank'><b>premium version.</b></a>.";
$MESS['CLEANTALK_RENEW_NOTIFY']= "Please, <a href='https://cleantalk.org/my/bill/recharge?utm_source=bitrix-backend&utm_medium=cpc&utm_campaign=bitrix-backend-renew&user_token=".COption::GetOptionString('cleantalk.antispam', 'user_token', '')."&cp_mode=antispam' target='_blank'><b>renew</b></a> your anti-spam license for <b>Anti-spam by CleanTalk</b>!";
2 changes: 2 additions & 0 deletions cleantalk.antispam/lang/ru/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@
$MESS['CLEANTALK_EXCLUSIONS_FIELDS_DESCRIPTION'] = 'Исключение полей форм из спам-проверки. Перечислите через запятую. Это работает на формах, кроме форм регистрации и комментирования.';
$MESS['CLEANTALK_EXCLUSIONS_WEBFORM'] = 'Исключение Веб-форм по ID';
$MESS['CLEANTALK_EXCLUSIONS_WEBFORM_DESCRIPTION']= 'Исключение форм (модуль Веб-формы) из спам-проверки по ID. Перечислите через запятую.';
$MESS['CLEANTALK_EXCLUSIONS_SITES'] = 'Исключение сайтов';
$MESS['CLEANTALK_EXCLUSIONS_SITES_DESCRIPTION'] = 'Исключение сайтов из спам-проверки. Можно выбрать несколько';
$MESS['CLEANTALK_TRIAL_NOTIFY']= "Заканчивается ознакомительный срок пользования плагина <b>Антиспам без CAPTCHA от CleanTalk</b>. Пожалуйста, подключите тариф в <a href='https://cleantalk.org/my/bill/recharge?utm_source=bitrix-backend&utm_medium=cpc&utm_campaign=bitrix-backend-trial&user_token=".COption::GetOptionString('cleantalk.antispam', 'user_token', '')."&cp_mode=antispam' target='_blank'><b>панели управления</b></a>.";
$MESS['CLEANTALK_RENEW_NOTIFY']= "Пожалуйста, <a href='https://cleantalk.org/my/bill/recharge?utm_source=bitrix-backend&utm_medium=cpc&utm_campaign=bitrix-backend-renew&user_token=".COption::GetOptionString('cleantalk.antispam', 'user_token', '')."&cp_mode=antispam' target='_blank'><b>обновите</b></a> вашу анти-спам лицензию для <b>Антиспам без CAPTCHA от CleanTalk</b>!";
32 changes: 23 additions & 9 deletions cleantalk.antispam/lib/Cleantalk/Common/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,22 @@ public function addTask( $task, $handler, $period, $first_call = null, $params =
{
// First call time() + period
$first_call = ! $first_call ? time() + $period : $first_call;

if( isset( $this->tasks[ $task ] ) ){

$tasks = ! empty( $this->tasks ) ? $this->tasks : $this->getTasks();

if( isset( $tasks[ $task ] ) ){
return false;
}

// Task entry
$this->tasks[$task] = array(
$tasks[$task] = array(
'handler' => $handler,
'next_call' => $first_call,
'period' => $period,
'params' => $params,
);

return $this->saveTasks( $this->tasks );
return $this->saveTasks( $tasks );
}

/**
Expand All @@ -122,13 +124,15 @@ public function addTask( $task, $handler, $period, $first_call = null, $params =
*/
public function removeTask( $task )
{
if( ! isset( $this->tasks[ $task ] ) ){
$tasks = ! empty( $this->tasks ) ? $this->tasks : $this->getTasks();

if( ! isset( $tasks[ $task ] ) ){
return false;
}

unset( $this->tasks[ $task ] );
unset( $tasks[ $task ] );

return $this->saveTasks( $this->tasks );
return $this->saveTasks( $tasks );
}

/**
Expand All @@ -144,8 +148,18 @@ public function removeTask( $task )
*/
public function updateTask( $task, $handler, $period, $first_call = null, $params = array() )
{
$this->removeTask( $task );
return $this->addTask( $task, $handler, $period, $first_call, $params );
$tasks = ! empty( $this->tasks ) ? $this->tasks : $this->getTasks();
if( isset( $tasks[ $task ] ) ){
// Rewrite the task
$tasks[$task] = array(
'handler' => $handler,
'next_call' => is_null( $first_call ) ? time() + $period : $first_call,
'period' => $period,
'params' => $params,
);
return $this->saveTasks( $tasks );
}
return false;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions cleantalk.antispam/lib/Cleantalk/Common/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,9 @@ public static function http__get_headers(){
if(count($key_parts) > 0 and strlen($server_key) > 2){
foreach($key_parts as $part_index => $part){
$key_parts[$part_index] = function_exists('mb_strtolower') ? mb_strtolower($part) : strtolower($part);
$key_parts[$part_index][0] = strtoupper($key_parts[$part_index][0]);
if(!empty($key_parts[$part_index][0])) {
$key_parts[$part_index][0] = strtoupper($key_parts[$part_index][0]);
}
}
$server_key = implode('-', $key_parts);
}
Expand Down Expand Up @@ -1320,7 +1322,7 @@ public static function http__request__rc_to_host($rc_action, $request_params, $p

if( empty( $result__rc_check_website['error'] ) ){

if( preg_match( '@^.*?OK$@', $result__rc_check_website) ){
if( is_string($result__rc_check_website) && preg_match( '@^.*?OK$@', $result__rc_check_website) ){

static::http__request(
static::getSiteUrl(),
Expand Down
42 changes: 32 additions & 10 deletions cleantalk.antispam/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
use Cleantalk\Common\Helper as CleantalkHelper;

if( $REQUEST_METHOD == 'POST' && $_POST['Update'] == 'Y' ) {

$old_key = COption::GetOptionString( $sModuleId, 'key', '' );



$old_key = COption::GetOptionString( $sModuleId, 'key', '' );

//Getting key automatically
if(isset($_POST['getautokey'])){

Expand Down Expand Up @@ -100,6 +99,15 @@
COption::SetOptionInt( $sModuleId, 'form_global_check_without_email', $_POST['form_global_check_without_email'] == '1' ? 1 : 0 );
COption::SetOptionInt( $sModuleId, 'form_sfw', $_POST['form_sfw'] == '1' ? 1 : 0 );

if (isset($_POST['form_exclusions_sites']) && is_array($_POST['form_exclusions_sites'])) {
$exclusion_sites = array();
foreach ($_POST['form_exclusions_sites'] as $value) {
$exclusion_sites[] = $value;
}
COption::SetOptionString( $sModuleId, 'site_exclusions', implode(',', $exclusion_sites));
} else {
COption::SetOptionString( $sModuleId, 'site_exclusions', '');
}
COption::SetOptionString( $sModuleId, 'form_exclusions_url', isset($_POST['form_exclusions_url']) ? $_POST['form_exclusions_url'] : '' );
COption::SetOptionString( $sModuleId, 'form_exclusions_fields', isset($_POST['form_exclusions_fields']) ? $_POST['form_exclusions_fields'] : '' );
COption::SetOptionString( $sModuleId, 'form_exclusions_webform', isset($_POST['form_exclusions_webform']) ? $_POST['form_exclusions_webform'] : '' );
Expand All @@ -112,14 +120,13 @@
// SFW scheduled actions
if($_POST['form_sfw'] == 1) {

CAgent::RemoveModuleAgents( 'cleantalk.antispam' );
CleantalkAntispam::apbct_sfw_update( $new_key );
CleantalkAntispam::apbct_sfw_send_logs( $new_key );
CAgent::RemoveModuleAgents( 'cleantalk.antispam' );
CleantalkAntispam::apbct_sfw_update( $new_key );
CleantalkAntispam::apbct_sfw_send_logs( $new_key );

// Remove it if SFW is disabled
}else
CAgent::RemoveModuleAgents("cleantalk.antispam");

CAgent::RemoveModuleAgents("cleantalk.antispam");
}

/**
Expand Down Expand Up @@ -255,10 +262,25 @@ function ctDdisableInputLine(ct_input_line){
<tr class="heading">
<td colspan="2"><?=GetMessage( 'CLEANTALK_EXCLUSIONS' )?></td>
</tr>
<tr>
<td width="50%" valign="top"><label for="form_exclusions_webform"><?php echo GetMessage( 'CLEANTALK_EXCLUSIONS_SITES' );?>:</td>
<td valign="top">
<select name="form_exclusions_sites[]" id="form_exclusions_sites" multiple>
<?php $rsSites = CSite::GetList($by ="sort", $order="desc");
$excluded_sites = explode(",", COption::GetOptionString( $sModuleId, 'site_exclusions', ''));
while ($arSite = $rsSites->Fetch()) {
echo "<option value = \"".$arSite['ID']."\" " . (in_array($arSite['ID'], $excluded_sites) ? "selected" : "") . ">".$arSite['NAME']."</option>";
} ?>
</select>
<div><?php echo GetMessage( 'CLEANTALK_EXCLUSIONS_SITES_DESCRIPTION' ); ?></div>
</td>
</tr>
<tr>
<td width="50%" valign="top"><label for="form_exclusions_check"><?echo GetMessage( 'CLEANTALK_EXCLUSIONS_URL' );?>:</td>
<td valign="top">
<input type="text" name="form_exclusions_url" id="form_exclusions_url" value="<?php echo COption::GetOptionString( $sModuleId, 'form_exclusions_url', '' ); ?>" />
<div class="ui-ctl ui-ctl-textarea">
<textarea class="ui-ctl-element" name = "form_exclusions_url" id = "form_exclusions_url" cols = "45" rows = "10"><?php echo COption::GetOptionString( $sModuleId, 'form_exclusions_url', '' ); ?></textarea>
</div>
<div><?php echo GetMessage( 'CLEANTALK_EXCLUSIONS_URL_DESCRIPTION' ); ?></div>
</td>
</tr>
Expand Down

0 comments on commit bb85eb3

Please sign in to comment.