Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.159.6

Version Description

Jun 30 2021 = * New. Rest API request detecting implemented. * Upd. SFW. AntiCrawler was disabled for the new installations. * Upd. SFW. AntiCrawler option moved to the advanced settings section. * Mod: email is taken only from visible fields * Mod: remove error message about firewall updating * Mod: excluded for test WC_Gateway_Tpay_Basic * Fix: Added exclude for happyforms.php in apbct_is_skip_request. * Fix: Added an error message in the form response * Fix: Skip wpforms general requests because of direct integration. * Fix. Integration. Autonami Marketing Automations service request kipped. * Fix. Cron. Update task method fixed. * Fix. SFW. Prevent updating while SFW is disabled. * Fix. Cron. Restoring cron tasks during plugin updating. * Fix. SFW. Logs sending used limit. * Fix: set correct api_key value for ajax calls. * Fix. Frontend widget. The widget layout fixed. * Fix. Integration. Formidable preparing data for checking.

Download this release

Release Info

Developer glomberg
Plugin Icon 128x128 Spam protection, AntiSpam, FireWall by CleanTalk
Version 5.159.6
Comparing to
See all releases

Code changes from version 5.159.5 to 5.159.6

cleantalk.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Anti-Spam by CleanTalk
4
  Plugin URI: https://cleantalk.org
5
  Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
6
- Version: 5.159.5
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
@@ -722,7 +722,7 @@ function apbct_deactivation__delete_all_options(){
722
  delete_option('cleantalk_plugin_request_ids');
723
  delete_option('cleantalk_fw_stats');
724
  delete_option( 'ct_plugin_do_activation_redirect' );
725
- foreach( AdminNotices::get_notices() as $notice ) {
726
  delete_option( 'cleantalk_' . $notice . '_dismissed' );
727
  }
728
  }
@@ -856,10 +856,11 @@ function apbct_sfw_update__init( $delay = 0 ){
856
 
857
  // Prevent start an update if update is already running and started less than 2 minutes ago
858
  if(
 
859
  $apbct->fw_stats['firewall_updating_id'] &&
860
  time() - $apbct->fw_stats['firewall_updating_last_start'] < 120
861
  ){
862
- return array( 'error' => 'SFW UPDATE INIT: FIREWALL_IS_ALREADY_UPDATING' );
863
  }
864
 
865
  // Key is empty
3
  Plugin Name: Anti-Spam by CleanTalk
4
  Plugin URI: https://cleantalk.org
5
  Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
6
+ Version: 5.159.6
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
722
  delete_option('cleantalk_plugin_request_ids');
723
  delete_option('cleantalk_fw_stats');
724
  delete_option( 'ct_plugin_do_activation_redirect' );
725
+ foreach( AdminNotices::NOTICES as $notice ) {
726
  delete_option( 'cleantalk_' . $notice . '_dismissed' );
727
  }
728
  }
856
 
857
  // Prevent start an update if update is already running and started less than 2 minutes ago
858
  if(
859
+ ! $apbct->settings['sfw__enabled'] &&
860
  $apbct->fw_stats['firewall_updating_id'] &&
861
  time() - $apbct->fw_stats['firewall_updating_last_start'] < 120
862
  ){
863
+ return false;
864
  }
865
 
866
  // Key is empty
inc/cleantalk-ajax-handlers.php CHANGED
@@ -15,6 +15,9 @@ if( !defined( 'APBCT_VERSION' ) ) {
15
 
16
  global $apbct;
17
  $apbct = new \Cleantalk\ApbctWP\State('cleantalk', array('settings', 'data'));
 
 
 
18
  \Cleantalk\ApbctWP\State::setDefinitions();
19
 
20
  /*******************************************************************/
15
 
16
  global $apbct;
17
  $apbct = new \Cleantalk\ApbctWP\State('cleantalk', array('settings', 'data'));
18
+ $apbct->white_label = $apbct->network_settings['multisite__white_label'];
19
+ $apbct->allow_custom_key = $apbct->network_settings['multisite__allow_custom_key'];
20
+ $apbct->api_key = ! is_multisite() || $apbct->allow_custom_key || $apbct->white_label ? $apbct->settings['apikey'] : $apbct->network_settings['apikey'];
21
  \Cleantalk\ApbctWP\State::setDefinitions();
22
 
23
  /*******************************************************************/
inc/cleantalk-pluggable.php CHANGED
@@ -235,6 +235,15 @@ function apbct_is_ajax() {
235
 
236
  }
237
 
 
 
 
 
 
 
 
 
 
238
  /**
239
  * Checks if the user is logged in
240
  *
@@ -545,7 +554,8 @@ function apbct_is_skip_request( $ajax = false ) {
545
  return 'mylisting_theme_service_requests_skip';
546
  }
547
  // HappyForms skip every requests. HappyForms have the direct integration
548
- if( apbct_is_plugin_active( 'happyforms-upgrade/happyforms-upgrade.php' ) &&
 
549
  ( Post::get('happyforms_message_nonce') !== '' ) )
550
  {
551
  return 'happyform_skipped';
@@ -558,6 +568,15 @@ function apbct_is_skip_request( $ajax = false ) {
558
  {
559
  return 'eael_login_skipped';
560
  }
 
 
 
 
 
 
 
 
 
561
 
562
  break;
563
 
235
 
236
  }
237
 
238
+ /**
239
+ * Checks if the request is REST
240
+ *
241
+ * @return boolean
242
+ */
243
+ function apbct_is_rest() {
244
+ return defined( 'REST_REQUEST' ) && REST_REQUEST;
245
+ }
246
+
247
  /**
248
  * Checks if the user is logged in
249
  *
554
  return 'mylisting_theme_service_requests_skip';
555
  }
556
  // HappyForms skip every requests. HappyForms have the direct integration
557
+ if( apbct_is_plugin_active( 'happyforms-upgrade/happyforms-upgrade.php' ) ||
558
+ apbct_is_plugin_active( 'happyforms/happyforms.php' ) &&
559
  ( Post::get('happyforms_message_nonce') !== '' ) )
560
  {
561
  return 'happyform_skipped';
568
  {
569
  return 'eael_login_skipped';
570
  }
571
+ // Autonami Marketing Automations service request
572
+ if( apbct_is_rest() && Post::get('automation_id') !== '' && Post::get('unique_key') !== '' )
573
+ {
574
+ return 'autonami-rest';
575
+ }
576
+ //Skip wforms because of direct integration
577
+ if ( apbct_is_plugin_active( 'wpforms/wpforms.php' ) && isset( $_POST['wpforms'] ) ) {
578
+ return 'wp_forms';
579
+ }
580
 
581
  break;
582
 
inc/cleantalk-public.php CHANGED
@@ -1224,7 +1224,12 @@ function apbct_rorm__formidable__testSpam ( $errors, $form ) {
1224
  return $errors;
1225
  }
1226
 
1227
- $ct_temp_msg_data = ct_get_fields_any($_POST['item_meta']);
 
 
 
 
 
1228
 
1229
  $sender_email = $ct_temp_msg_data['email'] ?: '';
1230
  $sender_nickname = $ct_temp_msg_data['nickname'] ?: '';
@@ -3644,6 +3649,7 @@ function ct_contact_form_validate() {
3644
  ((isset($_POST['woocommerce-login-nonce']) || isset($_POST['_wpnonce'])) && isset($_POST['login'], $_POST['password'], $_POST['_wp_http_referer'])) || // WooCommerce login form
3645
  (isset($_POST['wc-api']) && strtolower($_POST['wc-api']) == 'wc_gateway_systempay') || // Woo Systempay payment plugin
3646
  apbct_is_in_uri( 'wc-api=WC_Gateway_Realex_Redirect') || // Woo Realex payment Gateway plugin
 
3647
  (isset($_POST['_wpcf7'], $_POST['_wpcf7_version'], $_POST['_wpcf7_locale'])) || //CF7 fix)
3648
  (isset($_POST['hash'], $_POST['device_unique_id'], $_POST['device_name'])) ||//Mobile Assistant Connector fix
3649
  isset($_POST['gform_submit']) || //Gravity form
@@ -3720,7 +3726,7 @@ function ct_contact_form_validate() {
3720
  do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, $_POST );
3721
  return null;
3722
  }
3723
-
3724
  //Skip woocommerce add_to_cart
3725
  if( ! empty( $_POST['add-to-cart'] ) )
3726
  {
@@ -3925,6 +3931,7 @@ function ct_contact_form_validate_postdata() {
3925
  isset($_POST['fscf_submitted']) ||
3926
  isset($_POST['log']) && isset($_POST['pwd']) && isset($_POST['wp-submit'])||
3927
  apbct_is_in_uri('/wc-api') ||
 
3928
  (isset($_POST['wc_reset_password'], $_POST['_wpnonce'], $_POST['_wp_http_referer'])) || //WooCommerce recovery password form
3929
  (isset($_POST['woocommerce-login-nonce'], $_POST['login'], $_POST['password'], $_POST['_wp_http_referer'])) || //WooCommerce login form
3930
  (isset($_POST['provider'], $_POST['authcode']) && $_POST['provider'] == 'Two_Factor_Totp') || //TwoFactor authorization
@@ -4371,6 +4378,9 @@ function apbct_form_profile_builder__check_register ( $errors, $fields, $global_
4371
 
4372
  if( $ct_result->allow == 0 ) {
4373
  $errors['error'] = $ct_result->comment;
 
 
 
4374
  }
4375
 
4376
  }
@@ -4378,6 +4388,13 @@ function apbct_form_profile_builder__check_register ( $errors, $fields, $global_
4378
 
4379
  }
4380
 
 
 
 
 
 
 
 
4381
  // WP Foro register system integration
4382
  function wpforo_create_profile__check_register( $user_fields ) {
4383
 
1224
  return $errors;
1225
  }
1226
 
1227
+ $form_data = array();
1228
+ foreach( $_POST['item_meta'] as $key => $value ) {
1229
+ $form_data['item_meta[' . $key . ']'] = $value;
1230
+ }
1231
+
1232
+ $ct_temp_msg_data = ct_get_fields_any( $form_data );
1233
 
1234
  $sender_email = $ct_temp_msg_data['email'] ?: '';
1235
  $sender_nickname = $ct_temp_msg_data['nickname'] ?: '';
3649
  ((isset($_POST['woocommerce-login-nonce']) || isset($_POST['_wpnonce'])) && isset($_POST['login'], $_POST['password'], $_POST['_wp_http_referer'])) || // WooCommerce login form
3650
  (isset($_POST['wc-api']) && strtolower($_POST['wc-api']) == 'wc_gateway_systempay') || // Woo Systempay payment plugin
3651
  apbct_is_in_uri( 'wc-api=WC_Gateway_Realex_Redirect') || // Woo Realex payment Gateway plugin
3652
+ apbct_is_in_uri( 'wc-api=WC_Gateway_Tpay_Basic') || // Tpay payment Gateway plugin
3653
  (isset($_POST['_wpcf7'], $_POST['_wpcf7_version'], $_POST['_wpcf7_locale'])) || //CF7 fix)
3654
  (isset($_POST['hash'], $_POST['device_unique_id'], $_POST['device_name'])) ||//Mobile Assistant Connector fix
3655
  isset($_POST['gform_submit']) || //Gravity form
3726
  do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, $_POST );
3727
  return null;
3728
  }
3729
+
3730
  //Skip woocommerce add_to_cart
3731
  if( ! empty( $_POST['add-to-cart'] ) )
3732
  {
3931
  isset($_POST['fscf_submitted']) ||
3932
  isset($_POST['log']) && isset($_POST['pwd']) && isset($_POST['wp-submit'])||
3933
  apbct_is_in_uri('/wc-api') ||
3934
+ apbct_is_in_uri( 'wc-api=WC_Gateway_Tpay_Basic') || // Tpay payment Gateway plugin
3935
  (isset($_POST['wc_reset_password'], $_POST['_wpnonce'], $_POST['_wp_http_referer'])) || //WooCommerce recovery password form
3936
  (isset($_POST['woocommerce-login-nonce'], $_POST['login'], $_POST['password'], $_POST['_wp_http_referer'])) || //WooCommerce login form
3937
  (isset($_POST['provider'], $_POST['authcode']) && $_POST['provider'] == 'Two_Factor_Totp') || //TwoFactor authorization
4378
 
4379
  if( $ct_result->allow == 0 ) {
4380
  $errors['error'] = $ct_result->comment;
4381
+ $GLOBALS['global_profile_builder_error'] = $ct_result->comment;
4382
+
4383
+ add_filter( 'wppb_general_top_error_message', 'apbct_form_profile_builder__error_message', 1 );
4384
  }
4385
 
4386
  }
4388
 
4389
  }
4390
 
4391
+ /**
4392
+ * Profile Builder Integration - add error message in response
4393
+ */
4394
+ function apbct_form_profile_builder__error_message() {
4395
+ return '<p id="wppb_form_general_message" class="wppb-error">'. $GLOBALS['global_profile_builder_error'] .'</p>';
4396
+ }
4397
+
4398
  // WP Foro register system integration
4399
  function wpforo_create_profile__check_register( $user_fields ) {
4400
 
inc/cleantalk-settings.php CHANGED
@@ -114,15 +114,6 @@ function apbct_settings__set_fileds( $fields ){
114
  . $additional_sfw_description,
115
  'childrens' => array('sfw__anti_flood', 'sfw__anti_crawler', 'sfw__use_delete_to_clear_table'),
116
  ),
117
- 'sfw__anti_crawler' => array(
118
- 'type' => 'checkbox',
119
- 'title' => __('Anti-Crawler', 'cleantalk-spam-protect') . $additional_ac_title,
120
- 'class' => 'apbct_settings-field_wrapper--sub',
121
- 'parent' => 'sfw__enabled',
122
- 'description' => __('Plugin shows SpamFireWall stop page for any bot, except allowed bots (Google, Yahoo and etc).', 'cleantalk-spam-protect')
123
- . '<br>'
124
- . __( 'Anti-Crawler includes blocking bots by the User-Agent. Use Personal lists in the Dashboard to filter specific User-Agents.', 'cleantalk-spam-protect' ),
125
- ),
126
  ),
127
  ),
128
 
@@ -492,6 +483,15 @@ function apbct_settings__set_fileds( $fields ){
492
  'options_callback_params' => array(true),
493
  'class' => 'apbct_settings-field_wrapper--sub',
494
  ),
 
 
 
 
 
 
 
 
 
495
  'sfw__anti_flood' => array(
496
  'type' => 'checkbox',
497
  'title' => __('Anti-Flood', 'cleantalk-spam-protect'),
114
  . $additional_sfw_description,
115
  'childrens' => array('sfw__anti_flood', 'sfw__anti_crawler', 'sfw__use_delete_to_clear_table'),
116
  ),
 
 
 
 
 
 
 
 
 
117
  ),
118
  ),
119
 
483
  'options_callback_params' => array(true),
484
  'class' => 'apbct_settings-field_wrapper--sub',
485
  ),
486
+ 'sfw__anti_crawler' => array(
487
+ 'type' => 'checkbox',
488
+ 'title' => __('Anti-Crawler', 'cleantalk-spam-protect') . $additional_ac_title,
489
+ 'class' => 'apbct_settings-field_wrapper',
490
+ 'parent' => 'sfw__enabled',
491
+ 'description' => __('Plugin shows SpamFireWall stop page for any bot, except allowed bots (Google, Yahoo and etc).', 'cleantalk-spam-protect')
492
+ . '<br>'
493
+ . __( 'Anti-Crawler includes blocking bots by the User-Agent. Use Personal lists in the Dashboard to filter specific User-Agents.', 'cleantalk-spam-protect' ),
494
+ ),
495
  'sfw__anti_flood' => array(
496
  'type' => 'checkbox',
497
  'title' => __('Anti-Flood', 'cleantalk-spam-protect'),
inc/cleantalk-updater.php CHANGED
@@ -992,3 +992,38 @@ function apbct_update_to_5_158_2() {
992
  $apbct->stats['cron']['last_start'] = 0;
993
  $apbct->save('stats');
994
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
992
  $apbct->stats['cron']['last_start'] = 0;
993
  $apbct->save('stats');
994
  }
995
+
996
+ function apbct_update_to_5_159_6() {
997
+
998
+ global $wpdb;
999
+
1000
+ $ct_cron = new Cron();
1001
+
1002
+ if( is_multisite() ){
1003
+ $initial_blog = get_current_blog_id();
1004
+ $blogs = array_keys($wpdb->get_results('SELECT blog_id FROM '. $wpdb->blogs, OBJECT_K));
1005
+ foreach ($blogs as $blog) {
1006
+ switch_to_blog($blog);
1007
+ // Cron tasks
1008
+ $ct_cron->addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // Checks account status
1009
+ $ct_cron->addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
1010
+ $ct_cron->addTask('send_feedback', 'ct_send_feedback', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
1011
+ $ct_cron->addTask('sfw_update', 'apbct_sfw_update__init', 86400 ); // SFW update
1012
+ $ct_cron->addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time() + 1800); // SFW send logs
1013
+ $ct_cron->addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
1014
+ $ct_cron->addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
1015
+ $ct_cron->addTask('antiflood__clear_table', 'apbct_antiflood__clear_table', 86400, time() + 300); // Clear Anti-Flood table
1016
+ }
1017
+ switch_to_blog($initial_blog);
1018
+ }else{
1019
+ // Cron tasks
1020
+ $ct_cron->addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // Checks account status
1021
+ $ct_cron->addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
1022
+ $ct_cron->addTask('send_feedback', 'ct_send_feedback', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
1023
+ $ct_cron->addTask('sfw_update', 'apbct_sfw_update__init', 86400 ); // SFW update
1024
+ $ct_cron->addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time() + 1800); // SFW send logs
1025
+ $ct_cron->addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
1026
+ $ct_cron->addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
1027
+ $ct_cron->addTask('antiflood__clear_table', 'apbct_antiflood__clear_table', 86400, time() + 300); // Clear Anti-Flood table
1028
+ }
1029
+ }
inc/cleantalk-widget.php CHANGED
@@ -42,7 +42,7 @@ class cleantalk_widget extends WP_Widget
42
  // Parsing incoming params
43
  $blocked = number_format($apbct->data['spam_count'], 0, ',', ' ');
44
 
45
- $a_style = 'cursor: pointer; display: block; padding: 5px 0 5px; text-align: center; text-decoration: none; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; font-weight: normal; height: 100%; width: 100%; ';
46
  $strong_style = 'display: block; font-size: 15px; line-height: 16px; padding: 0 13px; white-space: nowrap; ';
47
 
48
  if(!isset($instance['style'])){
42
  // Parsing incoming params
43
  $blocked = number_format($apbct->data['spam_count'], 0, ',', ' ');
44
 
45
+ $a_style = 'cursor: pointer; display: block; padding: 5px 0 5px; text-align: center; text-decoration: none; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; font-weight: normal; width: 100%; ';
46
  $strong_style = 'display: block; font-size: 15px; line-height: 16px; padding: 0 13px; white-space: nowrap; ';
47
 
48
  if(!isset($instance['style'])){
lib/Cleantalk/Antispam/Integrations.php CHANGED
@@ -1,124 +1,124 @@
1
- <?php
2
-
3
-
4
- namespace Cleantalk\Antispam;
5
-
6
-
7
- class Integrations
8
- {
9
-
10
- private $integrations = array();
11
-
12
- private $integration;
13
-
14
- /**
15
- * Integrations constructor.
16
- *
17
- * @param array $integrations
18
- * @param array $settings
19
- */
20
- public function __construct( $integrations, $settings )
21
- {
22
- $this->integrations = $integrations;
23
-
24
- foreach( $this->integrations as $integration_name => $integration_info ){
25
-
26
- if( empty( $settings[ $integration_info['setting'] ] ) )
27
- continue;
28
-
29
- if( $integration_info['ajax'] ) {
30
- if( is_array( $integration_info['hook'] ) ) {
31
- foreach( $integration_info['hook'] as $hook ) {
32
- add_action( 'wp_ajax_' . $hook, array( $this, 'checkSpam' ), 1 );
33
- add_action( 'wp_ajax_nopriv_' . $hook, array( $this, 'checkSpam' ), 1 );
34
- }
35
- } else {
36
- add_action( 'wp_ajax_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
37
- add_action( 'wp_ajax_nopriv_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
38
- }
39
- } else {
40
- if( is_array( $integration_info['hook'] ) ) {
41
- foreach ( $integration_info['hook'] as $hook ) {
42
- add_action( $hook, array( $this, 'checkSpam' ) );
43
- }
44
- } else {
45
- add_action( $integration_info['hook'], array( $this, 'checkSpam' ) );
46
- }
47
-
48
- }
49
- }
50
- }
51
-
52
- public function checkSpam( $argument )
53
- {
54
- global $cleantalk_executed;
55
-
56
- // Getting current integration name
57
- $current_integration = $this->get_current_integration_triggered( current_filter() );
58
- if( $current_integration ) {
59
- // Instantiate the integration object
60
- $class = '\\Cleantalk\\Antispam\\Integrations\\' . $current_integration;
61
- if( class_exists( $class )) {
62
- $this->integration = new $class();
63
- if( ! ( $this->integration instanceof \Cleantalk\Antispam\Integrations\IntegrationBase ) ) {
64
- // @ToDo have to handle an error
65
- do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, array('Integration is not instanse of IntegrationBase class.') );
66
- return;
67
- }
68
- // Run data collecting for spam checking
69
- $data = $this->integration->getDataForChecking( $argument );
70
- if( ! is_null( $data ) ) {
71
- // Go spam checking
72
- $base_call_result = apbct_base_call(
73
- array(
74
- 'message' => !empty( $data['message'] ) ? json_encode( $data['message'] ) : '',
75
- 'sender_email' => !empty( $data['email'] ) ? $data['email'] : '',
76
- 'sender_nickname' => !empty( $data['nickname'] ) ? $data['nickname'] : '',
77
- 'post_info' => array(
78
- 'comment_type' => 'contact_form_wordpress_' . strtolower($current_integration),
79
- 'post_url' => apbct_get_server_variable( 'HTTP_REFERER' ), // Page URL must be an previous page
80
- ),
81
- ),
82
- isset( $data['register'] ) ? true : false
83
- );
84
-
85
- $ct_result = $base_call_result['ct_result'];
86
-
87
- $cleantalk_executed = true;
88
-
89
- if ($ct_result->allow == 0) {
90
- // Do blocking if it is a spam
91
- return $this->integration->doBlock( $ct_result->comment );
92
- }
93
-
94
- if($ct_result->allow != 0 && method_exists($this->integration, 'allow')) {
95
- return $this->integration->allow();
96
- }
97
- } else {
98
- // @ToDo have to handle an error
99
- return;
100
- }
101
- }
102
- }
103
- }
104
-
105
- private function get_current_integration_triggered( $hook )
106
- {
107
- if( $hook !== false ) {
108
- foreach( $this->integrations as $integration_name => $integration_info ) {
109
- if( is_array( $integration_info['hook'] ) ) {
110
- foreach( $integration_info['hook'] as $integration_hook ) {
111
- if( strpos( $hook, $integration_hook ) !== false ) {
112
- return $integration_name;
113
- }
114
- }
115
- } else {
116
- if( strpos( $hook, $integration_info['hook'] ) !== false ) {
117
- return $integration_name;
118
- }
119
- }
120
- }
121
- }
122
- return false;
123
- }
124
  }
1
+ <?php
2
+
3
+
4
+ namespace Cleantalk\Antispam;
5
+
6
+
7
+ class Integrations
8
+ {
9
+
10
+ private $integrations = array();
11
+
12
+ private $integration;
13
+
14
+ /**
15
+ * Integrations constructor.
16
+ *
17
+ * @param array $integrations
18
+ * @param array $settings
19
+ */
20
+ public function __construct( $integrations, $settings )
21
+ {
22
+ $this->integrations = $integrations;
23
+
24
+ foreach( $this->integrations as $integration_name => $integration_info ){
25
+
26
+ if( empty( $settings[ $integration_info['setting'] ] ) )
27
+ continue;
28
+
29
+ if( $integration_info['ajax'] ) {
30
+ if( is_array( $integration_info['hook'] ) ) {
31
+ foreach( $integration_info['hook'] as $hook ) {
32
+ add_action( 'wp_ajax_' . $hook, array( $this, 'checkSpam' ), 1 );
33
+ add_action( 'wp_ajax_nopriv_' . $hook, array( $this, 'checkSpam' ), 1 );
34
+ }
35
+ } else {
36
+ add_action( 'wp_ajax_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
37
+ add_action( 'wp_ajax_nopriv_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
38
+ }
39
+ } else {
40
+ if( is_array( $integration_info['hook'] ) ) {
41
+ foreach ( $integration_info['hook'] as $hook ) {
42
+ add_action( $hook, array( $this, 'checkSpam' ) );
43
+ }
44
+ } else {
45
+ add_action( $integration_info['hook'], array( $this, 'checkSpam' ) );
46
+ }
47
+
48
+ }
49
+ }
50
+ }
51
+
52
+ public function checkSpam( $argument )
53
+ {
54
+ global $cleantalk_executed;
55
+
56
+ // Getting current integration name
57
+ $current_integration = $this->get_current_integration_triggered( current_filter() );
58
+ if( $current_integration ) {
59
+ // Instantiate the integration object
60
+ $class = '\\Cleantalk\\Antispam\\Integrations\\' . $current_integration;
61
+ if( class_exists( $class )) {
62
+ $this->integration = new $class();
63
+ if( ! ( $this->integration instanceof \Cleantalk\Antispam\Integrations\IntegrationBase ) ) {
64
+ // @ToDo have to handle an error
65
+ do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, array('Integration is not instanse of IntegrationBase class.') );
66
+ return;
67
+ }
68
+ // Run data collecting for spam checking
69
+ $data = $this->integration->getDataForChecking( $argument );
70
+ if( ! is_null( $data ) ) {
71
+ // Go spam checking
72
+ $base_call_result = apbct_base_call(
73
+ array(
74
+ 'message' => !empty( $data['message'] ) ? json_encode( $data['message'] ) : '',
75
+ 'sender_email' => !empty( $data['email'] ) ? $data['email'] : '',
76
+ 'sender_nickname' => !empty( $data['nickname'] ) ? $data['nickname'] : '',
77
+ 'post_info' => array(
78
+ 'comment_type' => 'contact_form_wordpress_' . strtolower($current_integration),
79
+ 'post_url' => apbct_get_server_variable( 'HTTP_REFERER' ), // Page URL must be an previous page
80
+ ),
81
+ ),
82
+ isset( $data['register'] ) ? true : false
83
+ );
84
+
85
+ $ct_result = $base_call_result['ct_result'];
86
+
87
+ $cleantalk_executed = true;
88
+
89
+ if ($ct_result->allow == 0) {
90
+ // Do blocking if it is a spam
91
+ return $this->integration->doBlock( $ct_result->comment );
92
+ }
93
+
94
+ if($ct_result->allow != 0 && method_exists($this->integration, 'allow')) {
95
+ return $this->integration->allow();
96
+ }
97
+ } else {
98
+ // @ToDo have to handle an error
99
+ return;
100
+ }
101
+ }
102
+ }
103
+ }
104
+
105
+ private function get_current_integration_triggered( $hook )
106
+ {
107
+ if( $hook !== false ) {
108
+ foreach( $this->integrations as $integration_name => $integration_info ) {
109
+ if( is_array( $integration_info['hook'] ) ) {
110
+ foreach( $integration_info['hook'] as $integration_hook ) {
111
+ if( strpos( $hook, $integration_hook ) !== false ) {
112
+ return $integration_name;
113
+ }
114
+ }
115
+ } else {
116
+ if( strpos( $hook, $integration_info['hook'] ) !== false ) {
117
+ return $integration_name;
118
+ }
119
+ }
120
+ }
121
+ }
122
+ return false;
123
+ }
124
  }
lib/Cleantalk/ApbctWP/AdminNotices.php CHANGED
@@ -42,6 +42,9 @@ class AdminNotices {
42
  */
43
  private $user_token;
44
 
 
 
 
45
  private function __construct()
46
  {
47
  global $apbct;
@@ -76,6 +79,11 @@ class AdminNotices {
76
 
77
  }
78
 
 
 
 
 
 
79
  private static function get_instance()
80
  {
81
  if ( ! isset( self::$instance ) ) {
@@ -84,6 +92,9 @@ class AdminNotices {
84
  return self::$instance;
85
  }
86
 
 
 
 
87
  public static function show_admin_notices()
88
  {
89
  $admin_notices = self::get_instance();
@@ -97,11 +108,9 @@ class AdminNotices {
97
  }
98
  }
99
 
100
- public static function get_notices()
101
- {
102
- return self::NOTICES;
103
- }
104
-
105
  public function notice_get_key_error()
106
  {
107
  if( $this->apbct->notice_show && ! empty( $this->apbct->errors['key_get'] ) && ! $this->apbct->white_label ){
@@ -113,6 +122,9 @@ class AdminNotices {
113
  }
114
  }
115
 
 
 
 
116
  public function notice_key_is_incorrect()
117
  {
118
  if ( ( ! apbct_api_key__is_correct() && $this->apbct->moderate_ip == 0 ) && ! $this->apbct->white_label ){
@@ -123,6 +135,9 @@ class AdminNotices {
123
  }
124
  }
125
 
 
 
 
126
  public function notice_trial()
127
  {
128
  if ( $this->apbct->notice_show && $this->apbct->notice_trial == 1 && $this->apbct->moderate_ip == 0 && ! $this->apbct->white_label ) {
@@ -136,6 +151,10 @@ class AdminNotices {
136
  }
137
  }
138
 
 
 
 
 
139
  public function notice_renew()
140
  {
141
  if ( $this->apbct->notice_show && $this->apbct->notice_renew == 1 && $this->apbct->moderate_ip == 0 && ! $this->apbct->white_label ) {
@@ -151,6 +170,9 @@ class AdminNotices {
151
  }
152
  }
153
 
 
 
 
154
  public function notice_incompatibility()
155
  {
156
  if( ! empty( $this->apbct->data['notice_incompatibility'] ) && $this->is_cleantalk_page && $this->apbct->settings['sfw__enabled'] ){
@@ -211,6 +233,13 @@ class AdminNotices {
211
 
212
  }
213
 
 
 
 
 
 
 
 
214
  public function add_attention_mark( $after ) {
215
  if( $this->apbct->notice_show ) {
216
  return $after . '<i class="icon-attention-alt"></i>';
42
  */
43
  private $user_token;
44
 
45
+ /**
46
+ * AdminNotices constructor.
47
+ */
48
  private function __construct()
49
  {
50
  global $apbct;
79
 
80
  }
81
 
82
+ /**
83
+ * Get singleton instance of AdminNotices
84
+ *
85
+ * @return AdminNotices
86
+ */
87
  private static function get_instance()
88
  {
89
  if ( ! isset( self::$instance ) ) {
92
  return self::$instance;
93
  }
94
 
95
+ /**
96
+ * Initialize method
97
+ */
98
  public static function show_admin_notices()
99
  {
100
  $admin_notices = self::get_instance();
108
  }
109
  }
110
 
111
+ /**
112
+ * Callback for the notice hook
113
+ */
 
 
114
  public function notice_get_key_error()
115
  {
116
  if( $this->apbct->notice_show && ! empty( $this->apbct->errors['key_get'] ) && ! $this->apbct->white_label ){
122
  }
123
  }
124
 
125
+ /**
126
+ * Callback for the notice hook
127
+ */
128
  public function notice_key_is_incorrect()
129
  {
130
  if ( ( ! apbct_api_key__is_correct() && $this->apbct->moderate_ip == 0 ) && ! $this->apbct->white_label ){
135
  }
136
  }
137
 
138
+ /**
139
+ * Callback for the notice hook
140
+ */
141
  public function notice_trial()
142
  {
143
  if ( $this->apbct->notice_show && $this->apbct->notice_trial == 1 && $this->apbct->moderate_ip == 0 && ! $this->apbct->white_label ) {
151
  }
152
  }
153
 
154
+ /**
155
+ * Callback for the notice hook
156
+ * @deprecated
157
+ */
158
  public function notice_renew()
159
  {
160
  if ( $this->apbct->notice_show && $this->apbct->notice_renew == 1 && $this->apbct->moderate_ip == 0 && ! $this->apbct->white_label ) {
170
  }
171
  }
172
 
173
+ /**
174
+ * Callback for the notice hook
175
+ */
176
  public function notice_incompatibility()
177
  {
178
  if( ! empty( $this->apbct->data['notice_incompatibility'] ) && $this->is_cleantalk_page && $this->apbct->settings['sfw__enabled'] ){
233
 
234
  }
235
 
236
+ /**
237
+ * Callback for the admin-bar filtering hook
238
+ *
239
+ * @param string $after
240
+ *
241
+ * @return string
242
+ */
243
  public function add_attention_mark( $after ) {
244
  if( $this->apbct->notice_show ) {
245
  return $after . '<i class="icon-attention-alt"></i>';
lib/Cleantalk/ApbctWP/Firewall/SFW.php CHANGED
@@ -362,15 +362,20 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
362
  public static function send_log( $db, $log_table, $ct_key, $use_delete_command ) {
363
 
364
  //Getting logs
365
- $query = "SELECT * FROM " . $log_table . ";";
366
  $db->fetch_all( $query );
367
 
368
  if( count( $db->result ) ){
 
 
369
 
370
  //Compile logs
 
371
  $data = array();
372
- foreach( $db->result as $key => &$value ){
373
-
 
 
374
  // Converting statuses to API format
375
  $value['status'] = $value['status'] === 'DENY_ANTICRAWLER' ? 'BOT_PROTECTION' : $value['status'];
376
  $value['status'] = $value['status'] === 'PASS_ANTICRAWLER' ? 'BOT_PROTECTION' : $value['status'];
@@ -421,12 +426,8 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
421
  if( $result['rows'] == count( $data ) ){
422
 
423
  $db->execute( "BEGIN;" );
424
- if( $use_delete_command ){
425
- $db->execute( "DELETE FROM " . $log_table . ";" );
426
- }else{
427
- $db->execute( "TRUNCATE TABLE " . $log_table . ";" );
428
- }
429
- $db->execute( "COMMIT;" );
430
 
431
  return $result;
432
  }
362
  public static function send_log( $db, $log_table, $ct_key, $use_delete_command ) {
363
 
364
  //Getting logs
365
+ $query = "SELECT * FROM $log_table ORDER BY entries_timestamp DESC LIMIT 0," . APBCT_SFW_SEND_LOGS_LIMIT .";";
366
  $db->fetch_all( $query );
367
 
368
  if( count( $db->result ) ){
369
+
370
+ $logs = $db->result;
371
 
372
  //Compile logs
373
+ $ids_to_delete = array();
374
  $data = array();
375
+ foreach( $logs as $key => &$value ){
376
+
377
+ $ids_to_delete[] = $value['id'];
378
+
379
  // Converting statuses to API format
380
  $value['status'] = $value['status'] === 'DENY_ANTICRAWLER' ? 'BOT_PROTECTION' : $value['status'];
381
  $value['status'] = $value['status'] === 'PASS_ANTICRAWLER' ? 'BOT_PROTECTION' : $value['status'];
426
  if( $result['rows'] == count( $data ) ){
427
 
428
  $db->execute( "BEGIN;" );
429
+ $db->execute( "DELETE FROM $log_table WHERE id IN ( '" . implode( '\',\'', $ids_to_delete ) . "' );" );
430
+ $db->execute( "COMMIT;" );
 
 
 
 
431
 
432
  return $result;
433
  }
lib/Cleantalk/ApbctWP/GetFieldsAny.php CHANGED
@@ -280,7 +280,9 @@ class GetFieldsAny {
280
  $value = urldecode( trim( $this->strip_shortcodes( $value ) ) ); // Fully cleaned message
281
 
282
  // Email
283
- if ( preg_match( "/^\S+@\S+\.\S+$/", $value_for_email ) ) {
 
 
284
  // Bypass email collecting if it is set by attribute.
285
  if( $this->preprocessed_email ) {
286
  continue;
280
  $value = urldecode( trim( $this->strip_shortcodes( $value ) ) ); // Fully cleaned message
281
 
282
  // Email
283
+ if ( preg_match( "/^\S+@\S+\.\S+$/", $value_for_email ) &&
284
+ ( empty( $this->visible_fields_arr ) ||
285
+ in_array( $key, $this->visible_fields_arr, true ) ) ) {
286
  // Bypass email collecting if it is set by attribute.
287
  if( $this->preprocessed_email ) {
288
  continue;
lib/Cleantalk/ApbctWP/State.php CHANGED
@@ -67,7 +67,7 @@ class State
67
  'sfw__enabled' => 1,
68
  'sfw__anti_flood' => 0,
69
  'sfw__anti_flood__view_limit' => 20,
70
- 'sfw__anti_crawler' => 1,
71
  'sfw__use_delete_to_clear_table' => 0,
72
 
73
  // Forms for protection
@@ -414,6 +414,10 @@ class State
414
  // Write limit for firewall data.
415
  define( 'APBCT_WRITE_LIMIT', 5000 );
416
  }
 
 
 
 
417
  }
418
 
419
  /**
67
  'sfw__enabled' => 1,
68
  'sfw__anti_flood' => 0,
69
  'sfw__anti_flood__view_limit' => 20,
70
+ 'sfw__anti_crawler' => 0,
71
  'sfw__use_delete_to_clear_table' => 0,
72
 
73
  // Forms for protection
414
  // Write limit for firewall data.
415
  define( 'APBCT_WRITE_LIMIT', 5000 );
416
  }
417
+ if( ! defined( 'APBCT_SFW_SEND_LOGS_LIMIT' ) ) {
418
+ // Limit for firewall logs sending.
419
+ define( 'APBCT_SFW_SEND_LOGS_LIMIT', 1000 );
420
+ }
421
  }
422
 
423
  /**
lib/Cleantalk/Common/Cron.php CHANGED
@@ -148,8 +148,18 @@ abstract class Cron
148
  */
149
  public function updateTask( $task, $handler, $period, $first_call = null, $params = array() )
150
  {
151
- $this->removeTask( $task );
152
- return $this->addTask( $task, $handler, $period, $first_call, $params );
 
 
 
 
 
 
 
 
 
 
153
  }
154
 
155
  /**
148
  */
149
  public function updateTask( $task, $handler, $period, $first_call = null, $params = array() )
150
  {
151
+ $tasks = ! empty( $this->tasks ) ? $this->tasks : $this->getTasks();
152
+ if( isset( $tasks[ $task ] ) ){
153
+ // Rewrite the task
154
+ $tasks[$task] = array(
155
+ 'handler' => $handler,
156
+ 'next_call' => $first_call,
157
+ 'period' => $period,
158
+ 'params' => $params,
159
+ );
160
+ return $this->saveTasks( $tasks );
161
+ }
162
+ return false;
163
  }
164
 
165
  /**
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: spam, antispam, anti-spam, comments, firewall
4
  Requires at least: 3.0
5
  Tested up to: 5.7
6
  Requires PHP: 5.6
7
- Stable tag: 5.159.5
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
@@ -573,6 +573,25 @@ If your website has forms that send data to external sources, you can enable opt
573
 
574
  == Changelog ==
575
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
576
  = 5.159.5 Jun 24 2021 =
577
  * New: Admin bar. Attention mark added.
578
  * Upd: Admin notices have been rebuilt.
4
  Requires at least: 3.0
5
  Tested up to: 5.7
6
  Requires PHP: 5.6
7
+ Stable tag: 5.159.6
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
573
 
574
  == Changelog ==
575
 
576
+ = 5.159.6 Jun 30 2021 =
577
+ * New. Rest API request detecting implemented.
578
+ * Upd. SFW. AntiCrawler was disabled for the new installations.
579
+ * Upd. SFW. AntiCrawler option moved to the advanced settings section.
580
+ * Mod: email is taken only from visible fields
581
+ * Mod: remove error message about firewall updating
582
+ * Mod: excluded for test WC_Gateway_Tpay_Basic
583
+ * Fix: Added exclude for happyforms.php in apbct_is_skip_request.
584
+ * Fix: Added an error message in the form response
585
+ * Fix: Skip wpforms general requests because of direct integration.
586
+ * Fix. Integration. Autonami Marketing Automations service request kipped.
587
+ * Fix. Cron. Update task method fixed.
588
+ * Fix. SFW. Prevent updating while SFW is disabled.
589
+ * Fix. Cron. Restoring cron tasks during plugin updating.
590
+ * Fix. SFW. Logs sending used limit.
591
+ * Fix: set correct api_key value for ajax calls.
592
+ * Fix. Frontend widget. The widget layout fixed.
593
+ * Fix. Integration. Formidable preparing data for checking.
594
+
595
  = 5.159.5 Jun 24 2021 =
596
  * New: Admin bar. Attention mark added.
597
  * Upd: Admin notices have been rebuilt.