Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.143

Version Description

Aug 05 2020 = * New: Synchronize button. New way of synchronize with the Cleantalk Cloud. * Fix: SpamFireWall (firewall against spam) update, storing system. * Fix: Skip Woocomerce metorik send cart. * Spam protection improved. * Minor fixes.

Download this release

Release Info

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

Code changes from version 5.142.2 to 5.143

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.142.2
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
@@ -286,7 +286,9 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
286
  require_once( CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-find-spam.php' );
287
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-admin.php');
288
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-settings.php');
289
-
 
 
290
  if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)){
291
 
292
  add_action('admin_enqueue_scripts', 'apbct_admin__enqueue_scripts');
@@ -297,8 +299,8 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
297
  add_action('admin_notices', 'apbct_admin__notice_message');
298
  add_action('network_admin_notices', 'apbct_admin__notice_message');
299
 
300
- //Show widget only if not IP license
301
- if(!$apbct->moderate_ip)
302
  add_action('wp_dashboard_setup', 'ct_dashboard_statistics_widget' );
303
  }
304
 
@@ -617,8 +619,8 @@ function apbct_sfw__check()
617
  );
618
 
619
  $firewall->load_fw_module( new \Cleantalk\ApbctWP\Firewall\SFW(
620
- defined( 'APBCT_TBL_FIREWALL_LOG' ) ? APBCT_TBL_FIREWALL_LOG : $this->db->prefix . 'cleantalk_sfw_logs',
621
- defined( 'APBCT_TBL_FIREWALL_DATA' ) ? APBCT_TBL_FIREWALL_DATA : $this->db->prefix . 'cleantalk_sfw',
622
  array(
623
  'sfw_counter' => $apbct->settings['sfw_counter'],
624
  'api_key' => $apbct->api_key,
@@ -630,8 +632,8 @@ function apbct_sfw__check()
630
 
631
  if( $apbct->settings['sfw__anti_crawler'] ){
632
  $firewall->load_fw_module( new \Cleantalk\ApbctWP\Firewall\AntiCrawler(
633
- defined( 'APBCT_TBL_FIREWALL_LOG' ) ? APBCT_TBL_FIREWALL_LOG : $this->db->prefix . 'cleantalk_sfw_logs',
634
- defined( 'APBCT_TBL_AC_LOG' ) ? APBCT_TBL_AC_LOG : $this->db->prefix . 'cleantalk_ac_log',
635
  array(
636
  'api_key' => $apbct->api_key,
637
  'apbct' => $apbct,
@@ -641,8 +643,8 @@ function apbct_sfw__check()
641
 
642
  if( $apbct->settings['sfw__anti_flood'] ){
643
  $firewall->load_fw_module( new \Cleantalk\ApbctWP\Firewall\AntiFlood(
644
- defined( 'APBCT_TBL_FIREWALL_LOG' ) ? APBCT_TBL_FIREWALL_LOG : $this->db->prefix . 'cleantalk_sfw_logs',
645
- defined( 'APBCT_TBL_AC_LOG' ) ? APBCT_TBL_AC_LOG : $this->db->prefix . 'cleantalk_ac_log',
646
  array(
647
  'api_key' => $apbct->api_key,
648
  'view_limit' => $apbct->settings['sfw__anti_flood__view_limit'],
@@ -727,7 +729,7 @@ function apbct_activation( $network = false ) {
727
  Cron::addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // Checks account status
728
  Cron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
729
  Cron::addTask('send_feedback', 'ct_send_feedback', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
730
- Cron::addTask('sfw_update', 'ct_sfw_update', 86400, time() + 43200); // SFW update
731
  Cron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time() + 1800); // SFW send logs
732
  Cron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
733
  Cron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
@@ -741,11 +743,15 @@ function apbct_activation( $network = false ) {
741
  add_option('ct_plugin_do_activation_redirect', true);
742
  }
743
 
744
- function apbct_activation__create_tables($sqls) {
 
745
  global $wpdb;
 
 
 
746
  $wpdb->show_errors = false;
747
  foreach($sqls as $sql){
748
- $sql = sprintf($sql, $wpdb->prefix); // Adding current blog prefix
749
  $result = $wpdb->query($sql);
750
  if($result === false)
751
  $errors[] = "Failed.\nQuery: {$wpdb->last_query}\nError: {$wpdb->last_error}";
@@ -812,7 +818,7 @@ function apbct_activation__new_blog($blog_id, $user_id, $domain, $path, $site_id
812
  Cron::addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // Checks account status
813
  Cron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
814
  Cron::addTask('send_feedback', 'ct_send_feedback', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
815
- Cron::addTask('sfw_update', 'ct_sfw_update', 86400, time() + 43200); // SFW update
816
  Cron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time() + 1800); // SFW send logs
817
  Cron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
818
  Cron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
@@ -1006,7 +1012,7 @@ function ct_sfw_update($api_key = '', $immediate = false){
1006
 
1007
  $result = \Cleantalk\ApbctWP\Firewall\SFW::update(
1008
  \Cleantalk\ApbctWP\DB::getInstance(),
1009
- defined( 'APBCT_TBL_FIREWALL_DATA' ) ? APBCT_TBL_FIREWALL_DATA : $this->db->prefix . 'cleantalk_sfw',
1010
  $api_key,
1011
  null,
1012
  $immediate
@@ -1020,7 +1026,7 @@ function ct_sfw_update($api_key = '', $immediate = false){
1020
 
1021
  $result = \Cleantalk\ApbctWP\Firewall\SFW::update(
1022
  \Cleantalk\ApbctWP\DB::getInstance(),
1023
- defined( 'APBCT_TBL_FIREWALL_DATA' ) ? APBCT_TBL_FIREWALL_DATA : $this->db->prefix . 'cleantalk_sfw',
1024
  $api_key,
1025
  $file_urls[0],
1026
  $immediate
@@ -1073,7 +1079,7 @@ function ct_sfw_send_logs($api_key = '')
1073
 
1074
  $result = \Cleantalk\ApbctWP\Firewall\SFW::send_log(
1075
  \Cleantalk\ApbctWP\DB::getInstance(),
1076
- defined('APBCT_TBL_FIREWALL_LOG') ? APBCT_TBL_FIREWALL_LOG : $this->db->prefix . 'cleantalk_sfw_logs',
1077
  $api_key
1078
  );
1079
 
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.143
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
286
  require_once( CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-find-spam.php' );
287
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-admin.php');
288
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-settings.php');
289
+
290
+ add_action( 'admin_init', 'apbct_admin__init___ajax_actions' );
291
+
292
  if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)){
293
 
294
  add_action('admin_enqueue_scripts', 'apbct_admin__enqueue_scripts');
299
  add_action('admin_notices', 'apbct_admin__notice_message');
300
  add_action('network_admin_notices', 'apbct_admin__notice_message');
301
 
302
+ //Show widget only if enables and not IP license
303
+ if( $apbct->settings['dashboard_widget__show'] && ! $apbct->moderate_ip )
304
  add_action('wp_dashboard_setup', 'ct_dashboard_statistics_widget' );
305
  }
306
 
619
  );
620
 
621
  $firewall->load_fw_module( new \Cleantalk\ApbctWP\Firewall\SFW(
622
+ APBCT_TBL_FIREWALL_LOG,
623
+ APBCT_TBL_FIREWALL_DATA,
624
  array(
625
  'sfw_counter' => $apbct->settings['sfw_counter'],
626
  'api_key' => $apbct->api_key,
632
 
633
  if( $apbct->settings['sfw__anti_crawler'] ){
634
  $firewall->load_fw_module( new \Cleantalk\ApbctWP\Firewall\AntiCrawler(
635
+ APBCT_TBL_FIREWALL_LOG,
636
+ APBCT_TBL_AC_LOG,
637
  array(
638
  'api_key' => $apbct->api_key,
639
  'apbct' => $apbct,
643
 
644
  if( $apbct->settings['sfw__anti_flood'] ){
645
  $firewall->load_fw_module( new \Cleantalk\ApbctWP\Firewall\AntiFlood(
646
+ APBCT_TBL_FIREWALL_LOG,
647
+ APBCT_TBL_AC_LOG,
648
  array(
649
  'api_key' => $apbct->api_key,
650
  'view_limit' => $apbct->settings['sfw__anti_flood__view_limit'],
729
  Cron::addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // Checks account status
730
  Cron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
731
  Cron::addTask('send_feedback', 'ct_send_feedback', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
732
+ Cron::addTask('sfw_update', 'ct_sfw_update', 86400, time() + 600); // SFW update
733
  Cron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time() + 1800); // SFW send logs
734
  Cron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
735
  Cron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
743
  add_option('ct_plugin_do_activation_redirect', true);
744
  }
745
 
746
+ function apbct_activation__create_tables( $sqls, $db_prefix = '' ) {
747
+
748
  global $wpdb;
749
+
750
+ $db_prefix = $db_prefix ? $db_prefix : $wpdb->prefix;
751
+
752
  $wpdb->show_errors = false;
753
  foreach($sqls as $sql){
754
+ $sql = sprintf($sql, $db_prefix); // Adding current blog prefix
755
  $result = $wpdb->query($sql);
756
  if($result === false)
757
  $errors[] = "Failed.\nQuery: {$wpdb->last_query}\nError: {$wpdb->last_error}";
818
  Cron::addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // Checks account status
819
  Cron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
820
  Cron::addTask('send_feedback', 'ct_send_feedback', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
821
+ Cron::addTask('sfw_update', 'ct_sfw_update', 86400, time() + 600); // SFW update
822
  Cron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time() + 1800); // SFW send logs
823
  Cron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
824
  Cron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
1012
 
1013
  $result = \Cleantalk\ApbctWP\Firewall\SFW::update(
1014
  \Cleantalk\ApbctWP\DB::getInstance(),
1015
+ APBCT_TBL_FIREWALL_DATA,
1016
  $api_key,
1017
  null,
1018
  $immediate
1026
 
1027
  $result = \Cleantalk\ApbctWP\Firewall\SFW::update(
1028
  \Cleantalk\ApbctWP\DB::getInstance(),
1029
+ APBCT_TBL_FIREWALL_DATA,
1030
  $api_key,
1031
  $file_urls[0],
1032
  $immediate
1079
 
1080
  $result = \Cleantalk\ApbctWP\Firewall\SFW::send_log(
1081
  \Cleantalk\ApbctWP\DB::getInstance(),
1082
+ APBCT_TBL_FIREWALL_LOG,
1083
  $api_key
1084
  );
1085
 
css/cleantalk-admin-settings-page.min.css CHANGED
@@ -1 +1 @@
1
- .apbct_settings-field_content,.apbct_settings-field_title--radio,.cleantalk_link-auto,.cleantalk_link-manual,.ct-warning-test-failed,.ct_rate_block,.ct_settings_banner,i.animate-spin{display:inline-block}#apbctTopWarning{margin-bottom:5px}#apbctTopWarning h3{margin:10px 0 5px}#apbctTopWarning h4{margin:10px}#apbctTopWarning h4 span{margin-top:5px}.apbct_settings-subtitle{position:relative;top:-15px;margin:0}.apbct_settings-field_wrapper{margin:15px 0}.apbct_settings-field_wrapper--sub{margin-left:30px!important}.apbct_settings__label{margin-right:10px;font-size:17px;vertical-align:text-bottom}.apbct_settings-field_content--radio{width:70%}.apbct_settings-field_title--radio{margin:0;width:210px;padding-right:10px;font-size:14px;vertical-align:top}.apbct_input_text{min-width:255px;width:400px}.apbct_settings-field--api_key{font-size:14pt}.apbct_settings-long_description---show:hover{color:#aaa;cursor:pointer}.cleantalk_link{text-decoration:none;font-size:13px;line-height:26px;margin:0;padding:0 10px 1px;cursor:pointer;border-width:1px;border-style:solid;-webkit-appearance:none;white-space:nowrap;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.cleantalk_link-auto{background:#ccc;border-color:#999;-webkit-box-shadow:inset 0 1px 0 rgba(200,200,200,.5),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(200,200,200,.5),0 1px 0 rgba(0,0,0,.15);color:#000;height:28px;-webkit-border-radius:2px;border-radius:2px}.cleantalk_link-auto:hover{color:#fff}.cleantalk_link-manual{background:#2ea2cc;border-color:#0074a2;-webkit-box-shadow:inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);color:#fff;-webkit-border-radius:3px;border-radius:3px;text-align:center}.cleantalk_link-manual:hover{color:#000}.cleantalk_link[disabled=disabled]{background:#5d9db5;color:#000}.apbct_status_icon{vertical-align:text-bottom;margin:0 5px 0 8px}a.ct_support_link{color:#666;margin-right:.5em;font-size:10pt;font-weight:400}.ct-warning-test-failed{position:relative;padding:5px;margin:4px;border:3px solid rgba(240,50,50,1);border-radius:5px;background-color:rgba(255,200,200,1)}.ct_settings_banner{text-align:right;width:100%;margin:1em 0;vertical-align:top}#ct_translate_plugin{margin-left:0}.ct_rate_block{width:370px;margin-right:3em;padding:.8em .8em 15px;text-align:center;border:1px dashed #666}#ct_translate_plugin .apbct_button_rate{margin-bottom:10px}.apbct_long_desc{position:absolute;background:#5a5a5a;min-width:80px;min-height:80px;max-width:500px;padding:10px;color:#fff;z-index:10}i.animate-spin{-moz-animation:spin 2s infinite linear;-o-animation:spin 2s infinite linear;-webkit-animation:spin 2s infinite linear;animation:spin 2s infinite linear;font-size:25px;line-height:20px;color:rgba(120,200,230,1);margin:25px}@keyframes spin{to{transform:rotate(359deg)}}.apbct_long_desc__cancel{position:absolute;top:5px;right:5px;color:rgba(255,255,255,.5)}.apbct_long_desc__cancel:hover{color:#fff}.apbct_long_desc__angle{position:absolute;top:5px;left:-17px;width:10px;height:10px;background:#5a5a5a;-webkit-transform:rotate(135deg);-ms-transform:rotate(135deg);transform:rotate(135deg);-webkit-transform-origin:100% 100%;-ms-transform-origin:100% 100%;transform-origin:100% 100%}.apbct_long_desc__title{color:rgba(120,200,230,1);margin:0}
1
+ .apbct_settings-field_content,.apbct_settings-field_title--radio,.cleantalk_link-auto,.cleantalk_link-manual,.ct-warning-test-failed,.ct_rate_block,.ct_settings_banner,i.animate-spin{display:inline-block}#apbctTopWarning{margin-bottom:5px}#apbctTopWarning h3{margin:10px 0 5px}#apbctTopWarning h4{margin:10px}#apbctTopWarning h4 span{margin-top:5px}.apbct_settings-subtitle{position:relative;top:-15px;margin:0}.apbct_settings-field_wrapper{margin:15px 0}.apbct_settings-field_wrapper--sub{margin-left:30px!important}.apbct_settings__label{margin-right:10px;font-size:17px;vertical-align:text-bottom}.apbct_settings-field_content--radio{width:70%}.apbct_settings-field_title--radio{margin:0;width:210px;padding-right:10px;font-size:14px;vertical-align:top}.apbct_input_text{min-width:255px;width:400px}.apbct_settings-field--api_key{font-size:14pt}.apbct_settings-long_description---show:hover{color:#aaa;cursor:pointer}.cleantalk_link{text-decoration:none;font-size:13px;line-height:26px;margin:0;padding:0 10px 1px;cursor:pointer;border-width:1px;border-style:solid;-webkit-appearance:none;white-space:nowrap;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.cleantalk_link-auto{background:#ccc;border-color:#999;-webkit-box-shadow:inset 0 1px 0 rgba(200,200,200,.5),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(200,200,200,.5),0 1px 0 rgba(0,0,0,.15);color:#000;height:28px;-webkit-border-radius:2px;border-radius:2px}.cleantalk_link-auto:hover{color:#fff}.cleantalk_link-manual{background:#2ea2cc;border-color:#0074a2;-webkit-box-shadow:inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);color:#fff;-webkit-border-radius:3px;border-radius:3px;text-align:center}.cleantalk_link-manual:hover{color:#000}.cleantalk_link[disabled=disabled]{background:#5d9db5;color:#000}.apbct_status_icon{vertical-align:text-bottom;margin:0 5px 0 8px}a.ct_support_link{color:#666;margin-right:.5em;font-size:10pt;font-weight:400}.ct-warning-test-failed{position:relative;padding:5px;margin:4px;border:3px solid rgba(240,50,50,1);border-radius:5px;background-color:rgba(255,200,200,1)}.ct_settings_banner{text-align:right;width:100%;margin:1em 0;vertical-align:top}#ct_translate_plugin{margin-left:0}.ct_rate_block{width:370px;margin-right:3em;padding:.8em .8em 15px;text-align:center;border:1px dashed #666}#ct_translate_plugin .apbct_button_rate{margin-bottom:10px}.apbct_long_desc{position:absolute;background:#5a5a5a;min-width:80px;min-height:80px;max-width:500px;padding:10px;color:#fff;z-index:10}i.animate-spin{-moz-animation:spin 2s infinite linear;-o-animation:spin 2s infinite linear;-webkit-animation:spin 2s infinite linear;animation:spin 2s infinite linear;font-size:25px;line-height:20px;color:rgba(120,200,230,1);margin:25px}@keyframes spin{to{transform:rotate(359deg)}}.apbct_long_desc__cancel{position:absolute;top:5px;right:5px;color:rgba(255,255,255,.5)}.apbct_long_desc__cancel:hover{color:#fff}.apbct_long_desc__angle{position:absolute;top:5px;left:-17px;width:10px;height:10px;background:#5a5a5a;-webkit-transform:rotate(135deg);-ms-transform:rotate(135deg);transform:rotate(135deg);-webkit-transform-origin:100% 100%;-ms-transform-origin:100% 100%;transform-origin:100% 100%}.apbct_long_desc__title{color:rgba(120,200,230,1);margin:0}.--hide{display:none}.apbct_preloader_button{height:15px;margin-left:5px;vertical-align:text-top;display:none}
inc/cleantalk-admin.php CHANGED
@@ -73,7 +73,7 @@ function ct_dashboard_statistics_widget() {
73
  }
74
 
75
  // Outputs statistics widget content
76
- function ct_dashboard_statistics_widget_output( $post, $callback_args ) {
77
 
78
  global $apbct, $current_user;
79
 
@@ -198,11 +198,14 @@ function apbct_admin__init(){
198
  unset($_POST['submit']);
199
 
200
  }
201
-
202
- // AJAX actions
 
203
 
204
  // Settings
205
  add_action('wp_ajax_apbct_settings__get__long_description', 'apbct_settings__get__long_description'); // Long description
 
 
206
  }
207
 
208
  /**
@@ -318,6 +321,7 @@ function apbct_admin__enqueue_scripts($hook){
318
  wp_localize_script( 'jquery', 'ctSettingsPage', array(
319
  'ct_subtitle' => $apbct->ip_license ? __('Hosting AntiSpam', 'cleantalk-spam-protect') : '',
320
  'ip_license' => $apbct->ip_license ? true : false,
 
321
  ));
322
  }
323
 
73
  }
74
 
75
  // Outputs statistics widget content
76
+ function ct_dashboard_statistics_widget_output( $post, $callback_args ) {
77
 
78
  global $apbct, $current_user;
79
 
198
  unset($_POST['submit']);
199
 
200
  }
201
+ }
202
+
203
+ function apbct_admin__init___ajax_actions(){
204
 
205
  // Settings
206
  add_action('wp_ajax_apbct_settings__get__long_description', 'apbct_settings__get__long_description'); // Long description
207
+
208
+ add_action( 'wp_ajax_apbct_sync', 'apbct_settings__sync' );
209
  }
210
 
211
  /**
321
  wp_localize_script( 'jquery', 'ctSettingsPage', array(
322
  'ct_subtitle' => $apbct->ip_license ? __('Hosting AntiSpam', 'cleantalk-spam-protect') : '',
323
  'ip_license' => $apbct->ip_license ? true : false,
324
+ 'key_changed' => ! empty( $apbct->data['key_changed'] ) ? true : false,
325
  ));
326
  }
327
 
inc/cleantalk-ajax.php CHANGED
@@ -306,6 +306,7 @@ function ct_ajax_hook($message_obj = false, $additional = false)
306
  'postmark_test', //Avocet
307
  'postmark_save', //Avocet
308
  'ck_get_subscriber', //ConvertKit checking the subscriber
 
309
  );
310
 
311
  // Skip test if
@@ -400,6 +401,7 @@ function ct_ajax_hook($message_obj = false, $additional = false)
400
  }
401
  }
402
  if (isset($_POST['action']) && $_POST['action'] == 'ufbl_front_form_action'){
 
403
  foreach ($ct_post_temp as $key => $value) {
404
  if (preg_match('/form_data_\d_name/', $key))
405
  unset($ct_post_temp[$key]);
306
  'postmark_test', //Avocet
307
  'postmark_save', //Avocet
308
  'ck_get_subscriber', //ConvertKit checking the subscriber
309
+ 'metorik_send_cart', //Metorik skip
310
  );
311
 
312
  // Skip test if
401
  }
402
  }
403
  if (isset($_POST['action']) && $_POST['action'] == 'ufbl_front_form_action'){
404
+ $ct_post_temp = $_POST;
405
  foreach ($ct_post_temp as $key => $value) {
406
  if (preg_match('/form_data_\d_name/', $key))
407
  unset($ct_post_temp[$key]);
inc/cleantalk-public.php CHANGED
@@ -573,17 +573,18 @@ function apbct_integration__buddyPres__activityWall( $is_spam, $activity_obj = n
573
 
574
  global $apbct;
575
 
576
- if( $activity_obj === null ||
577
- !isset($_POST['action']) ||
 
 
 
578
  $activity_obj->privacy == 'media' ||
579
- ( ! empty( $_POST['action'] ) && $_POST['action'] !== 'post_update' ) ||
580
  apbct_exclusions_check()
581
  ) {
582
  do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, $_POST );
583
  return false;
584
  }
585
 
586
-
587
  $curr_user = get_user_by('id', $activity_obj->user_id);
588
 
589
  //Making a call
@@ -3348,7 +3349,7 @@ function ct_contact_form_validate() {
3348
  }
3349
  }
3350
  //Skip system fields for divi
3351
- if (strpos($param, 'et_pb_contactform_submit') === 0) {
3352
  foreach ($_POST as $key => $value) {
3353
  if (strpos($key, 'et_pb_contact_email_fields') === 0) {
3354
  unset($_POST[$key]);
573
 
574
  global $apbct;
575
 
576
+ $allowed_post_actions = array('post_update', 'new_activity_comment');
577
+
578
+ if( ! in_array(\Cleantalk\Variables\Post::get('action'), $allowed_post_actions) ||
579
+ $activity_obj === null ||
580
+ ! \Cleantalk\Variables\Post::get('action') ||
581
  $activity_obj->privacy == 'media' ||
 
582
  apbct_exclusions_check()
583
  ) {
584
  do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, $_POST );
585
  return false;
586
  }
587
 
 
588
  $curr_user = get_user_by('id', $activity_obj->user_id);
589
 
590
  //Making a call
3349
  }
3350
  }
3351
  //Skip system fields for divi
3352
+ if (strpos( \Cleantalk\Variables\Post::get('action'), 'et_pb_contactform_submit') === 0) {
3353
  foreach ($_POST as $key => $value) {
3354
  if (strpos($key, 'et_pb_contact_email_fields') === 0) {
3355
  unset($_POST[$key]);
inc/cleantalk-settings.php CHANGED
@@ -441,6 +441,10 @@ function apbct_settings__set_fileds( $fields ){
441
  'parent' => 'sfw__anti_flood',
442
  'description' => __('Count of page view per 1 minute before plugin shows SpamFireWall page. SpamFireWall page active for 30 second after that valid visitor (with JavaScript) passes the page to the demanded page of the site.', 'cleantalk-spam-protect'),
443
  ),
 
 
 
 
444
  'complete_deactivation' => array(
445
  'type' => 'checkbox',
446
  'title' => __('Complete deactivation', 'cleantalk-spam-protect'),
@@ -661,30 +665,56 @@ function apbct_settings__display() {
661
 
662
  // Output spam count
663
  if($apbct->key_is_ok && apbct_api_key__is_correct()){
664
- if($apbct->spam_count > 0){
665
  echo '<div class="apbct_settings-subtitle" style="top: 0; margin-bottom: 10px; width: 200px;">'
666
- .'<br>'
667
- .'<span>'
668
- .sprintf(
669
- __( '%s has blocked <b>%s</b> spam.', 'cleantalk-spam-protect'),
670
- $apbct->plugin_name,
671
- number_format($apbct->spam_count, 0, ',', ' ')
672
- )
673
- .'</span>'
674
- .'<br>'
675
- .'<br>'
676
- .'</div>';
677
  }
 
 
 
 
 
678
  if(!$apbct->white_label){
 
679
  // CP button
680
  echo '<a class="cleantalk_link cleantalk_link-manual" target="__blank" href="https://cleantalk.org/my?user_token='.$apbct->user_token.'&cp_mode=antispam">'
681
  .__('Click here to get anti-spam statistics', 'cleantalk-spam-protect')
682
  .'</a>';
683
  echo '&nbsp;&nbsp;';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
684
  // Support button
685
  echo '<a class="cleantalk_link cleantalk_link-auto" target="__blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">'.__('Support', 'cleantalk-spam-protect').'</a>';
 
686
  echo '<br>'
687
- .'<br>';
688
  }
689
  }
690
 
@@ -1338,13 +1368,63 @@ function apbct_settings__validate($settings) {
1338
  $settings['sfw__anti_flood__view_limit'] = ( $settings['sfw__anti_flood__view_limit'] == 0 ? 10 : $settings['sfw__anti_flood__view_limit'] ); // Default if 0 passed
1339
  $settings['sfw__anti_flood__view_limit'] = ( $settings['sfw__anti_flood__view_limit'] < 5 ? 5 : $settings['sfw__anti_flood__view_limit'] ); //
1340
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1341
  // Validating API key
 
 
 
 
1342
  $settings['apikey'] = !empty($settings['apikey']) ? trim($settings['apikey']) : '';
1343
  $settings['apikey'] = defined( 'CLEANTALK_ACCESS_KEY') ? CLEANTALK_ACCESS_KEY : $settings['apikey'];
1344
  $settings['apikey'] = ! is_main_site() && $apbct->white_label ? $apbct->settings['apikey'] : $settings['apikey'];
1345
  $settings['apikey'] = is_main_site() || $apbct->allow_custom_key || $apbct->white_label ? $settings['apikey'] : $apbct->network_settings['apikey'];
1346
  $settings['apikey'] = is_main_site() || !$settings['white_label'] ? $settings['apikey'] : $apbct->settings['apikey'];
1347
- $settings['apikey'] = strpos($settings['apikey'], '*') === false ? $settings['apikey'] : $apbct->settings['apikey'];
1348
 
1349
  // Sanitize setting values
1350
  foreach ($settings as &$setting ){
@@ -1396,52 +1476,17 @@ function apbct_settings__validate($settings) {
1396
  return $settings;
1397
  }
1398
 
1399
- // Auto getting key
1400
- if (isset($_POST['submit']) && $_POST['submit'] == 'get_key_auto'){
1401
-
1402
- $website = parse_url(get_option('siteurl'), PHP_URL_HOST).parse_url(get_option('siteurl'), PHP_URL_PATH);
1403
- $platform = 'wordpress';
1404
- $user_ip = \Cleantalk\ApbctWP\Helper::ip__get(array('real'), false);
1405
- $timezone = filter_input(INPUT_POST, 'ct_admin_timezone');
1406
- $language = apbct_get_server_variable( 'HTTP_ACCEPT_LANGUAGE' );
1407
- $wpms = APBCT_WPMS && defined('SUBDOMAIN_INSTALL') && !SUBDOMAIN_INSTALL ? true : false;
1408
- $white_label = $apbct->network_settings['white_label'] ? 1 : 0;
1409
- $hoster_api_key = $apbct->network_settings['white_label__hoster_key'] ? $apbct->network_settings['white_label__hoster_key'] : '';
1410
-
1411
- $result = \Cleantalk\ApbctWP\API::method__get_api_key(
1412
- ! is_main_site() && $apbct->white_label ? 'anti-spam-hosting' : 'antispam',
1413
- ct_get_admin_email(),
1414
- $website,
1415
- $platform,
1416
- $timezone,
1417
- $language,
1418
- $user_ip,
1419
- $wpms,
1420
- $white_label,
1421
- $hoster_api_key
1422
- );
1423
-
1424
- if(empty($result['error'])){
1425
-
1426
- if(isset($result['user_token'])){
1427
- $apbct->data['user_token'] = $result['user_token'];
1428
- }
1429
-
1430
- if(!empty($result['auth_key'])){
1431
- $settings['apikey'] = $result['auth_key'];
1432
- }
1433
-
1434
- }else{
1435
- $apbct->error_add(
1436
- 'key_get',
1437
- $result['error']
1438
- . ($apbct->white_label
1439
- ? ' <button name="submit" type="submit" class="cleantalk_link cleantalk_link-manual" value="get_key_auto">'
1440
- : ''
1441
- )
1442
- );
1443
- }
1444
- }
1445
 
1446
  // Feedback with app_agent
1447
  ct_send_feedback('0:' . APBCT_AGENT); // 0 - request_id, agent version.
@@ -1449,31 +1494,35 @@ function apbct_settings__validate($settings) {
1449
  // Key is good by default
1450
  $apbct->data['key_is_ok'] = true;
1451
 
1452
- // Check account status and validate key. Even if it's not correct because of IP license.
1453
- $result = ct_account_status_check($settings['apikey']);
1454
 
1455
  // Is key valid?
1456
- if($result){
1457
-
1458
  // Deleting errors about invalid key
1459
- $apbct->error_delete('key_invalid key_get', 'save');
1460
 
1461
  // SFW actions
1462
- if($apbct->settings['spam_firewall'] == 1){
1463
- $result = ct_sfw_update($settings['apikey']);
 
1464
  if( ! empty( $result['error'] ) )
1465
- $apbct->error_add('sfw_update', $result['error']);
1466
- $result = ct_sfw_send_logs($settings['apikey']);
 
1467
  if( ! empty( $result['error'] ) )
1468
- $apbct->error_add('sfw_send_logs', $result['error']);
 
1469
  }
 
1470
  // Updating brief data for dashboard widget
1471
- $apbct->data['brief_data'] = \Cleantalk\ApbctWP\API::method__get_antispam_report_breif($settings['apikey']);
1472
-
1473
- // Key is not valid
1474
  }else{
1475
  $apbct->data['key_is_ok'] = false;
1476
- $apbct->error_add('key_invalid', __('Testing is failed. Please check the Access key.', 'cleantalk-spam-protect'));
1477
  }
1478
 
1479
  // WPMS Logic.
@@ -1481,7 +1530,7 @@ function apbct_settings__validate($settings) {
1481
  if(is_main_site()){
1482
 
1483
  // Network settings
1484
- $network_settings['apikey'] = $settings['apikey'];
1485
  $apbct->network_settings = $network_settings;
1486
  $apbct->saveNetworkSettings();
1487
 
@@ -1525,14 +1574,17 @@ function apbct_settings__validate($settings) {
1525
  $apbct->data['license_trial'] = 0;
1526
  $apbct->data['account_name_ob'] = '';
1527
  }
1528
-
1529
- if (get_option('cleantalk_settings') && get_option('cleantalk_settings') == $settings) {
1530
- do_action('updated_option', 'cleantalk_settings', get_option('cleantalk_settings'), $settings);
1531
- }
1532
-
 
 
 
1533
  $apbct->saveData();
1534
 
1535
- return $settings;
1536
  }
1537
 
1538
  function apbct_update_blogs_options ($blog_names = array(), $settings) {
441
  'parent' => 'sfw__anti_flood',
442
  'description' => __('Count of page view per 1 minute before plugin shows SpamFireWall page. SpamFireWall page active for 30 second after that valid visitor (with JavaScript) passes the page to the demanded page of the site.', 'cleantalk-spam-protect'),
443
  ),
444
+ 'dashboard_widget__show' => array(
445
+ 'type' => 'checkbox',
446
+ 'title' => __('Show Dashboard Widget', 'cleantalk-spam-protect'),
447
+ ),
448
  'complete_deactivation' => array(
449
  'type' => 'checkbox',
450
  'title' => __('Complete deactivation', 'cleantalk-spam-protect'),
665
 
666
  // Output spam count
667
  if($apbct->key_is_ok && apbct_api_key__is_correct()){
668
+ if( $apbct->spam_count > 0 ){
669
  echo '<div class="apbct_settings-subtitle" style="top: 0; margin-bottom: 10px; width: 200px;">'
670
+ . '<br>'
671
+ . '<span>'
672
+ . sprintf(
673
+ __( '%s has blocked <b>%s</b> spam.', 'cleantalk-spam-protect' ),
674
+ $apbct->plugin_name,
675
+ number_format( $apbct->spam_count, 0, ',', ' ' )
676
+ )
677
+ . '</span>'
678
+ . '<br>'
679
+ . '<br>'
680
+ . '</div>';
681
  }
682
+ }
683
+
684
+
685
+ // Output spam count
686
+ if($apbct->key_is_ok && apbct_api_key__is_correct()){
687
  if(!$apbct->white_label){
688
+
689
  // CP button
690
  echo '<a class="cleantalk_link cleantalk_link-manual" target="__blank" href="https://cleantalk.org/my?user_token='.$apbct->user_token.'&cp_mode=antispam">'
691
  .__('Click here to get anti-spam statistics', 'cleantalk-spam-protect')
692
  .'</a>';
693
  echo '&nbsp;&nbsp;';
694
+
695
+ }
696
+ }
697
+
698
+ if( apbct_api_key__is_correct() && ! $apbct->white_label ){
699
+ // Sync button
700
+ echo '<button type="button" class="cleantalk_link cleantalk_link-auto" id="apbct_button__sync" title="Synchronizing account status, SpamFireWall database, all kind of journals.">'
701
+ . '<i class="icon-upload-cloud"></i>&nbsp;&nbsp;'
702
+ . __( 'Synchronize with Cloud', 'security-malware-firewall' )
703
+ . '<img style="margin-left: 10px;" class="apbct_preloader_button" src="' . APBCT_URL_PATH . '/inc/images/preloader2.gif" />'
704
+ . '<img style="margin-left: 10px;" class="apbct_success --hide" src="' . APBCT_URL_PATH . '/inc/images/yes.png" />'
705
+ . '</button>';
706
+ echo '&nbsp;&nbsp;';
707
+ }
708
+
709
+ // Output spam count
710
+ if($apbct->key_is_ok && apbct_api_key__is_correct()){
711
+ if(!$apbct->white_label){
712
+
713
  // Support button
714
  echo '<a class="cleantalk_link cleantalk_link-auto" target="__blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">'.__('Support', 'cleantalk-spam-protect').'</a>';
715
+ echo '&nbsp;&nbsp;';
716
  echo '<br>'
717
+ . '<br>';
718
  }
719
  }
720
 
1368
  $settings['sfw__anti_flood__view_limit'] = ( $settings['sfw__anti_flood__view_limit'] == 0 ? 10 : $settings['sfw__anti_flood__view_limit'] ); // Default if 0 passed
1369
  $settings['sfw__anti_flood__view_limit'] = ( $settings['sfw__anti_flood__view_limit'] < 5 ? 5 : $settings['sfw__anti_flood__view_limit'] ); //
1370
 
1371
+ // Auto getting key
1372
+ if (isset($_POST['submit']) && $_POST['submit'] == 'get_key_auto'){
1373
+
1374
+ $website = parse_url(get_option('siteurl'), PHP_URL_HOST).parse_url(get_option('siteurl'), PHP_URL_PATH);
1375
+ $platform = 'wordpress';
1376
+ $user_ip = \Cleantalk\ApbctWP\Helper::ip__get(array('real'), false);
1377
+ $timezone = filter_input(INPUT_POST, 'ct_admin_timezone');
1378
+ $language = apbct_get_server_variable( 'HTTP_ACCEPT_LANGUAGE' );
1379
+ $wpms = APBCT_WPMS && defined('SUBDOMAIN_INSTALL') && !SUBDOMAIN_INSTALL ? true : false;
1380
+ $white_label = $apbct->network_settings['white_label'] ? 1 : 0;
1381
+ $hoster_api_key = $apbct->network_settings['white_label__hoster_key'] ? $apbct->network_settings['white_label__hoster_key'] : '';
1382
+
1383
+ $result = \Cleantalk\ApbctWP\API::method__get_api_key(
1384
+ ! is_main_site() && $apbct->white_label ? 'anti-spam-hosting' : 'antispam',
1385
+ ct_get_admin_email(),
1386
+ $website,
1387
+ $platform,
1388
+ $timezone,
1389
+ $language,
1390
+ $user_ip,
1391
+ $wpms,
1392
+ $white_label,
1393
+ $hoster_api_key
1394
+ );
1395
+
1396
+ if(empty($result['error'])){
1397
+
1398
+ if(isset($result['user_token'])){
1399
+ $apbct->data['user_token'] = $result['user_token'];
1400
+ }
1401
+
1402
+ if(!empty($result['auth_key'])){
1403
+ $settings['apikey'] = $result['auth_key'];
1404
+ }
1405
+
1406
+ }else{
1407
+ $apbct->error_add(
1408
+ 'key_get',
1409
+ $result['error']
1410
+ . ($apbct->white_label
1411
+ ? ' <button name="submit" type="submit" class="cleantalk_link cleantalk_link-manual" value="get_key_auto">'
1412
+ : ''
1413
+ )
1414
+ );
1415
+ }
1416
+ }
1417
+
1418
  // Validating API key
1419
+ $settings['apikey'] = strpos($settings['apikey'], '*') === false ? $settings['apikey'] : $apbct->settings['apikey'];
1420
+
1421
+ $apbct->data['key_changed'] = $settings['apikey'] !== $apbct->settings['apikey'];
1422
+
1423
  $settings['apikey'] = !empty($settings['apikey']) ? trim($settings['apikey']) : '';
1424
  $settings['apikey'] = defined( 'CLEANTALK_ACCESS_KEY') ? CLEANTALK_ACCESS_KEY : $settings['apikey'];
1425
  $settings['apikey'] = ! is_main_site() && $apbct->white_label ? $apbct->settings['apikey'] : $settings['apikey'];
1426
  $settings['apikey'] = is_main_site() || $apbct->allow_custom_key || $apbct->white_label ? $settings['apikey'] : $apbct->network_settings['apikey'];
1427
  $settings['apikey'] = is_main_site() || !$settings['white_label'] ? $settings['apikey'] : $apbct->settings['apikey'];
 
1428
 
1429
  // Sanitize setting values
1430
  foreach ($settings as &$setting ){
1476
  return $settings;
1477
  }
1478
 
1479
+ $apbct->saveData();
1480
+
1481
+ return $settings;
1482
+ }
1483
+
1484
+ function apbct_settings__sync( $direct_call = false ){
1485
+
1486
+ if( ! $direct_call )
1487
+ check_ajax_referer('ct_secret_nonce' );
1488
+
1489
+ global $apbct;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1490
 
1491
  // Feedback with app_agent
1492
  ct_send_feedback('0:' . APBCT_AGENT); // 0 - request_id, agent version.
1494
  // Key is good by default
1495
  $apbct->data['key_is_ok'] = true;
1496
 
1497
+ // Checking account status
1498
+ $result = ct_account_status_check( $apbct->settings['apikey'] );
1499
 
1500
  // Is key valid?
1501
+ if( $result ){
1502
+
1503
  // Deleting errors about invalid key
1504
+ $apbct->error_delete( 'key_invalid key_get', 'save' );
1505
 
1506
  // SFW actions
1507
+ if( $apbct->settings['spam_firewall'] == 1 ){
1508
+
1509
+ $result = ct_sfw_update( $apbct->settings['apikey'] );
1510
  if( ! empty( $result['error'] ) )
1511
+ $apbct->error_add( 'sfw_update', $result['error'] );
1512
+
1513
+ $result = ct_sfw_send_logs( $apbct->settings['apikey'] );
1514
  if( ! empty( $result['error'] ) )
1515
+ $apbct->error_add( 'sfw_send_logs', $result['error'] );
1516
+
1517
  }
1518
+
1519
  // Updating brief data for dashboard widget
1520
+ $apbct->data['brief_data'] = \Cleantalk\ApbctWP\API::method__get_antispam_report_breif( $apbct->settings['apikey'] );
1521
+
1522
+ // Key is not valid
1523
  }else{
1524
  $apbct->data['key_is_ok'] = false;
1525
+ $apbct->error_add( 'key_invalid', __( 'Testing is failed. Please check the Access key.', 'cleantalk-spam-protect' ) );
1526
  }
1527
 
1528
  // WPMS Logic.
1530
  if(is_main_site()){
1531
 
1532
  // Network settings
1533
+ $network_settings['apikey'] = $apbct->settings['apikey'];
1534
  $apbct->network_settings = $network_settings;
1535
  $apbct->saveNetworkSettings();
1536
 
1574
  $apbct->data['license_trial'] = 0;
1575
  $apbct->data['account_name_ob'] = '';
1576
  }
1577
+
1578
+ $out = array(
1579
+ 'success' => true,
1580
+ 'reload' => $apbct->data['key_changed'],
1581
+ );
1582
+
1583
+ $apbct->data['key_changed'] = false;
1584
+
1585
  $apbct->saveData();
1586
 
1587
+ die( json_encode( $out ) );
1588
  }
1589
 
1590
  function apbct_update_blogs_options ($blog_names = array(), $settings) {
inc/cleantalk-updater.php CHANGED
@@ -558,4 +558,21 @@ function apbct_update_to_5_142_2() {
558
 
559
  apbct_activation__create_tables( $sqls );
560
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
561
  }
558
 
559
  apbct_activation__create_tables( $sqls );
560
 
561
+ }
562
+
563
+ function apbct_update_to_5_142_3() {
564
+
565
+ global $apbct;
566
+
567
+ $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw_logs` (
568
+ `id` VARCHAR(40) NOT NULL,
569
+ `ip` VARCHAR(15) NOT NULL,
570
+ `status` ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW__BY_WHITELIST\',\'PASS_SFW__BY_COOKIE\',\'DENY_ANTICRAWLER\',\'PASS_ANTICRAWLER\',\'DENY_ANTIFLOOD\',\'PASS_ANTIFLOOD\') NULL DEFAULT NULL,
571
+ `all_entries` INT NOT NULL,
572
+ `blocked_entries` INT NOT NULL,
573
+ `entries_timestamp` INT NOT NULL,
574
+ PRIMARY KEY (`id`));';
575
+
576
+ apbct_activation__create_tables( $sqls, $apbct->db_prefix );
577
+
578
  }
inc/images/preloader2.gif ADDED
Binary file
js/cleantalk-admin-settings-page.min.js CHANGED
@@ -1,2 +1,2 @@
1
- function apbct_banner_check(){var i=setInterval(function(){apbct_admin_sendAJAX({action:"apbct_settings__check_renew_banner"},{callback:function(e,t,n,c){e.close_renew_banner&&(jQuery("#apbct_renew_notice").length&&jQuery("#apbct_renew_notice").hide("slow"),jQuery("#apbct_trial_notice").length&&jQuery("#apbct_trial_notice").hide("slow"),clearInterval(i))}})},9e5)}function apbct_get_elems(e){for(var t,n=0,c=(e=e.split(",")).length;n<c;n++)t=jQuery("#"+e[n]),e[n]=0===t.length?jQuery("."+e[n]):t;return e}function apbct_get_elems__native(e){"string"==typeof e&&(e=e.split(","));var i=[];return e.forEach(function(e,t,n){var c=document.getElementById(e);if(null===c){if(null!==(c=document.getElementsByClassName(e))&&0!==c.length)for(key in c)0<=+key&&i.push(c[key])}else i.push(c[key])}),i}function apbct_show_hide_elem(e){for(var t=0,n=(e=apbct_get_elems(e)).length;t<n;t++)e[t].each(function(e,t){var n=(t=jQuery(t)).next("label")||t.prev("label")||null;t.is(":visible")?(t.hide(),n&&n.hide()):(t.show(),n&&n.show())})}function apbctSettingsDependencies(e,i){i=isNaN(i)?null:i,apbct_get_elems__native(e).forEach(function(e,t,n){console.log(e.getAttribute("id"));if(null===i&&(i=null===e.getAttribute("disabled")?0:1),1===i?e.removeAttribute("disabled"):e.setAttribute("disabled","disabled"),null!==e.getAttribute("apbct_children")){var c=apbctSettingsDependencies_getState(e)&&i;null!==c&&apbctSettingsDependencies(e.getAttribute("apbct_children"),c)}})}function apbctSettingsDependencies_getState(e){var t;switch(e.getAttribute("type")){case"checkbox":t=+e.checked;break;case"radio":t=+(1==+e.getAttribute("value"));break;default:t=null}return t}function apbct_settings__showDescription(e,t){var i=function(e){void 0!==e&&(0!=jQuery(e.target).parent(".apbct_long_desc").length&&!jQuery(e.target).hasClass("apbct_long_desc__cancel")||jQuery(e.target).hasClass("apbct_long_description__show"))||(jQuery(".apbct_long_desc").remove(),jQuery(document).off("click",i))};i(),e.after("<div id='apbct_long_desc__"+t+"' class='apbct_long_desc'></div>");var n=jQuery("#apbct_long_desc__"+t);n.append("<i class='icon-spin1 animate-spin'></i>").append("<div class='apbct_long_desc__angle'></div>").css({top:e.position().top-5,left:e.position().left+25}),apbct_admin_sendAJAX({action:"apbct_settings__get_description",setting_id:t},{spinner:n.children("img"),callback:function(e,t,n,c){c.empty().append("<div class='apbct_long_desc__angle'></div>").append("<i class='apbct_long_desc__cancel icon-cancel'></i>").append("<h3 class='apbct_long_desc__title'>"+e.title+"</h3>").append("<p>"+e.desc+"</p>"),jQuery(document).on("click",i)}},n)}jQuery(document).ready(function(){"rtl"===getComputedStyle(document.getElementsByClassName("apbct_settings-title")[0]).direction&&jQuery(".apbct_switchers").css("text-align","right"),jQuery("#apbct_showApiKey").on("click",function(){jQuery(".apbct_setting---apikey").val(jQuery(".apbct_setting---apikey").attr("key")),jQuery(".apbct_setting---apikey+div").show(),jQuery(this).fadeOut(300)});var e=new Date;jQuery("#ct_admin_timezone").val(e.getTimezoneOffset()/60*-1),jQuery("#apbct_gdpr_open_modal").on("click",function(){jQuery("#gdpr_dialog").dialog({modal:!0,show:!0,position:{my:"center",at:"center",of:window},width:+jQuery("#wpbody").width()/100*70,height:"auto",title:"GDPR compliance",draggable:!1,resizable:!1,closeText:"Close"})}),jQuery(document).on("click",".apbct_settings-long_description---show",function(){self=jQuery(this),apbct_settings__showDescription(self,self.attr("setting"))}),(jQuery("#apbct_renew_notice").length||jQuery("#apbct_trial_notice").length)&&apbct_banner_check()});
2
  //# sourceMappingURL=cleantalk-admin-settings-page.min.js.map
1
+ function apbct_banner_check(){var a=setInterval(function(){apbct_admin_sendAJAX({action:"apbct_settings__check_renew_banner"},{callback:function(e,t,n,c){e.close_renew_banner&&(jQuery("#apbct_renew_notice").length&&jQuery("#apbct_renew_notice").hide("slow"),jQuery("#apbct_trial_notice").length&&jQuery("#apbct_trial_notice").hide("slow"),clearInterval(a))}})},9e5)}function apbct_get_elems(e){for(var t,n=0,c=(e=e.split(",")).length;n<c;n++)t=jQuery("#"+e[n]),e[n]=0===t.length?jQuery("."+e[n]):t;return e}function apbct_get_elems__native(e){"string"==typeof e&&(e=e.split(","));var a=[];return e.forEach(function(e,t,n){var c=document.getElementById(e);if(null===c){if(null!==(c=document.getElementsByClassName(e))&&0!==c.length)for(key in c)0<=+key&&a.push(c[key])}else a.push(c[key])}),a}function apbct_show_hide_elem(e){for(var t=0,n=(e=apbct_get_elems(e)).length;t<n;t++)e[t].each(function(e,t){var n=(t=jQuery(t)).next("label")||t.prev("label")||null;t.is(":visible")?(t.hide(),n&&n.hide()):(t.show(),n&&n.show())})}function apbctSettingsDependencies(e,a){a=isNaN(a)?null:a,apbct_get_elems__native(e).forEach(function(e,t,n){console.log(e.getAttribute("id"));if(null===a&&(a=null===e.getAttribute("disabled")?0:1),1===a?e.removeAttribute("disabled"):e.setAttribute("disabled","disabled"),null!==e.getAttribute("apbct_children")){var c=apbctSettingsDependencies_getState(e)&&a;null!==c&&apbctSettingsDependencies(e.getAttribute("apbct_children"),c)}})}function apbctSettingsDependencies_getState(e){var t;switch(e.getAttribute("type")){case"checkbox":t=+e.checked;break;case"radio":t=+(1==+e.getAttribute("value"));break;default:t=null}return t}function apbct_settings__showDescription(e,t){var a=function(e){void 0!==e&&(0!=jQuery(e.target).parent(".apbct_long_desc").length&&!jQuery(e.target).hasClass("apbct_long_desc__cancel")||jQuery(e.target).hasClass("apbct_long_description__show"))||(jQuery(".apbct_long_desc").remove(),jQuery(document).off("click",a))};a(),e.after("<div id='apbct_long_desc__"+t+"' class='apbct_long_desc'></div>");var n=jQuery("#apbct_long_desc__"+t);n.append("<i class='icon-spin1 animate-spin'></i>").append("<div class='apbct_long_desc__angle'></div>").css({top:e.position().top-5,left:e.position().left+25}),apbct_admin_sendAJAX({action:"apbct_settings__get_description",setting_id:t},{spinner:n.children("img"),callback:function(e,t,n,c){c.empty().append("<div class='apbct_long_desc__angle'></div>").append("<i class='apbct_long_desc__cancel icon-cancel'></i>").append("<h3 class='apbct_long_desc__title'>"+e.title+"</h3>").append("<p>"+e.desc+"</p>"),jQuery(document).on("click",a)}},n)}jQuery(document).ready(function(){"rtl"===getComputedStyle(document.getElementsByClassName("apbct_settings-title")[0]).direction&&jQuery(".apbct_switchers").css("text-align","right"),jQuery("#apbct_showApiKey").on("click",function(){jQuery(".apbct_setting---apikey").val(jQuery(".apbct_setting---apikey").attr("key")),jQuery(".apbct_setting---apikey+div").show(),jQuery(this).fadeOut(300)});var e=new Date;jQuery("#ct_admin_timezone").val(e.getTimezoneOffset()/60*-1),jQuery("#apbct_gdpr_open_modal").on("click",function(){jQuery("#gdpr_dialog").dialog({modal:!0,show:!0,position:{my:"center",at:"center",of:window},width:+jQuery("#wpbody").width()/100*70,height:"auto",title:"GDPR compliance",draggable:!1,resizable:!1,closeText:"Close"})}),jQuery("#apbct_button__sync").on("click",function(){apbct_admin_sendAJAX({action:"apbct_sync"},{button:document.getElementById("apbct_button__sync"),spinner:jQuery("#apbct_button__sync .apbct_preloader_button"),callback:function(e,t,n,c){jQuery(".apbct_success").show(300),setTimeout(function(){jQuery(".apbct_success").hide(300)},2e3),e.reload&&document.location.reload()}})}),ctSettingsPage.key_changed&&jQuery("#apbct_button__sync").click(),jQuery(document).on("click",".apbct_settings-long_description---show",function(){self=jQuery(this),apbct_settings__showDescription(self,self.attr("setting"))}),(jQuery("#apbct_renew_notice").length||jQuery("#apbct_trial_notice").length)&&apbct_banner_check()});
2
  //# sourceMappingURL=cleantalk-admin-settings-page.min.js.map
js/cleantalk-admin-settings-page.min.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["cleantalk-admin-settings-page.js"],"names":["apbct_banner_check","bannerChecker","setInterval","apbct_admin_sendAJAX","action","callback","result","data","params","obj","close_renew_banner","jQuery","length","hide","clearInterval","apbct_get_elems","elems","tmp","i","len","split","apbct_get_elems__native","out","forEach","elem","arr","document","getElementById","getElementsByClassName","key","push","apbct_show_hide_elem","each","label","next","prev","is","show","apbctSettingsDependencies","ids","enable","isNaN","console","log","getAttribute","removeAttribute","setAttribute","state","apbctSettingsDependencies_getState","checked","apbct_settings__showDescription","setting_id","remove_desc_func","e","target","parent","hasClass","remove","off","after","append","css","top","position","left","spinner","children","empty","title","desc","on","ready","getComputedStyle","direction","val","attr","this","fadeOut","d","Date","getTimezoneOffset","dialog","modal","my","at","of","window","width","height","draggable","resizable","closeText","self"],"mappings":"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","file":"cleantalk-admin-settings-page.min.js","sourcesContent":["jQuery(document).ready(function(){\n\n\t// Crunch for Right to Left direction languages\n\tif(getComputedStyle(document.getElementsByClassName('apbct_settings-title')[0]).direction === 'rtl'){\n\t\tjQuery('.apbct_switchers').css('text-align', 'right');\n\t}\n\n\t// Show/Hide access key\n jQuery('#apbct_showApiKey').on('click', function(){\n jQuery('.apbct_setting---apikey').val(jQuery('.apbct_setting---apikey').attr('key'));\n jQuery('.apbct_setting---apikey+div').show();\n jQuery(this).fadeOut(300);\n });\n\n\tvar d = new Date();\n\tjQuery('#ct_admin_timezone').val(d.getTimezoneOffset()/60*(-1));\n\t\n\t// GDPR modal window\n\tjQuery('#apbct_gdpr_open_modal').on('click', function(){\n\t\tjQuery('#gdpr_dialog').dialog({\n\t\t\tmodal:true, \n\t\t\tshow: true,\n\t\t\tposition: { my: \"center\", at: \"center\", of: window },\n\t\t\twidth: +(jQuery('#wpbody').width() / 100 * 70), // 70% of #wpbody\n\t\t\theight: 'auto',\n\t\t\ttitle: 'GDPR compliance',\n\t\t\tdraggable: false,\n\t\t\tresizable: false,\n\t\t\tcloseText: \"Close\",\n\t\t});\n\t});\n\n\tjQuery(document).on('click', '.apbct_settings-long_description---show', function(){\n\t\tself = jQuery(this);\n\t\tapbct_settings__showDescription(self, self.attr('setting'));\n\t});\n\n\tif (jQuery('#apbct_renew_notice').length || jQuery('#apbct_trial_notice').length) \n\t\tapbct_banner_check();\n\t\n});\n\n/**\n * Checking current account status for renew notice\n */\nfunction apbct_banner_check() {\n\tvar bannerChecker = setInterval( function() {\n\t\tapbct_admin_sendAJAX(\n\t\t\t{action: 'apbct_settings__check_renew_banner'},\n\t\t\t{\n\t\t\t\tcallback: function(result, data, params, obj){\n\t\t\t\t\tif (result.close_renew_banner) {\n\t\t\t\t\t\tif (jQuery('#apbct_renew_notice').length)\n\t\t\t\t\t\t\tjQuery('#apbct_renew_notice').hide('slow');\n\t\t\t\t\t\tif (jQuery('#apbct_trial_notice').length)\n\t\t\t\t\t\t\tjQuery('#apbct_trial_notice').hide('slow');\n\t\t\t\t\t\tclearInterval(bannerChecker);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}, 900000);\n}\n\n/**\n * Select elems like #{selector} or .{selector}\n * Selector passed in string separated by ,\n *\n * @param elems\n * @returns {*}\n */\nfunction apbct_get_elems(elems){\n elems = elems.split(',');\n for( var i=0, len = elems.length, tmp; i < len; i++){\n tmp = jQuery('#'+elems[i]);\n elems[i] = tmp.length === 0 ? jQuery('.'+elems[i]) : tmp;\n }\n return elems;\n}\n\n/**\n * Select elems like #{selector} or .{selector}\n * Selector could be passed in a string ( separated by comma ) or in array ( [ elem1, elem2, ... ] )\n *\n * @param elems string|array\n * @returns array\n */\nfunction apbct_get_elems__native(elems){\n\n\t// Make array from a string\n\tif(typeof elems === 'string')\n\t\telems = elems.split(',');\n\n\tvar out = [];\n\n\telems.forEach(function(elem, i, arr) {\n\n\t\t// try to get elements with such IDs\n\t\tvar tmp = document.getElementById(elem);\n\t\tif (tmp !== null){\n\t\t\tout.push( tmp[key] );\n\t\t\treturn;\n\t\t}\n\n\t\t// try to get elements with such class name\n\t\t// write each elem from collection to new element of output array\n\t\ttmp = document.getElementsByClassName(elem);\n\t\tif (tmp !== null && tmp.length !==0 ){\n\t\t\tfor(key in tmp){\n\t\t\t\tif( +key >= 0 ){\n\t\t\t\t\tout.push( tmp[key] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\treturn out;\n}\n\nfunction apbct_show_hide_elem(elems){\n\telems = apbct_get_elems(elems);\n for( var i=0, len = elems.length; i < len; i++){\n elems[i].each(function (i, elem) {\n elem = jQuery(elem);\n var label = elem.next('label') || elem.prev('label') || null;\n if (elem.is(\":visible\")) {\n elem.hide();\n if (label) label.hide();\n } else {\n elem.show();\n if (label) label.show();\n }\n });\n }\n}\n\n/**\n * Settings dependences. Switch|toggle depended elements state (disabled|enabled)\n * Recieve list of selectors ( without class mark (.) or id mark (#) )\n *\n * @param ids string|array Selectors\n * @param enable\n */\nfunction apbctSettingsDependencies(ids, enable){\n\n\n\tenable = ! isNaN(enable) ? enable : null;\n\n\t// Get elements\n\tvar elems = apbct_get_elems__native( ids );\n\n\telems.forEach(function(elem, i, arr){\n\n\t\tconsole.log( elem.getAttribute('id') );\n\n\t\tvar do_disable = function(){elem.setAttribute('disabled', 'disabled');},\n\t\t\tdo_enable = function(){elem.removeAttribute('disabled');};\n\n\t\t// Set defined state\n\t\tif(enable === null) // Set\n\t\t\tenable = elem.getAttribute('disabled') === null ? 0 : 1;\n\n\t\tenable === 1 ? do_enable() : do_disable();\n\n\t\tif( elem.getAttribute('apbct_children') !== null){\n\t\t\tvar state = apbctSettingsDependencies_getState( elem ) && enable;\n\t\t\tif( state !== null ) {\n\t\t\t\tapbctSettingsDependencies( elem.getAttribute('apbct_children'), state );\n\t\t\t}\n\t\t}\n\n\t});\n}\n\nfunction apbctSettingsDependencies_getState( elem ){\n\n\tvar state;\n\n\tswitch ( elem.getAttribute( 'type' ) ){\n\t\tcase 'checkbox':\n\t\t\tstate = +elem.checked;\n\t\t\tbreak;\n\t\tcase 'radio':\n\t\t\tstate = +(+elem.getAttribute('value') === 1);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tstate = null;\n\t}\n\n\treturn state;\n}\n\nfunction apbct_settings__showDescription(label, setting_id){\n\n\tvar remove_desc_func = function(e){\n\t\tif(typeof e === 'undefined' || ((jQuery(e.target).parent('.apbct_long_desc').length == 0 || jQuery(e.target).hasClass('apbct_long_desc__cancel')) && !jQuery(e.target).hasClass('apbct_long_description__show'))){\n\t\t\tjQuery('.apbct_long_desc').remove();\n\t\t\tjQuery(document).off('click', remove_desc_func);\n\t\t}\n\t};\n\n\tremove_desc_func();\n\n\tlabel.after(\"<div id='apbct_long_desc__\"+setting_id+\"' class='apbct_long_desc'></div>\");\n\tvar obj = jQuery('#apbct_long_desc__'+setting_id);\n\tobj.append(\"<i class='icon-spin1 animate-spin'></i>\")\n\t\t.append(\"<div class='apbct_long_desc__angle'></div>\")\n\t\t.css({\n\t\t\ttop: label.position().top - 5,\n\t\t\tleft: label.position().left + 25\n\t\t});\n\n\n\tapbct_admin_sendAJAX(\n\t\t{action: 'apbct_settings__get_description', setting_id: setting_id},\n\t\t{\n\t\t\tspinner: obj.children('img'),\n\t\t\tcallback: function(result, data, params, obj){\n\n\t\t\t\tobj.empty()\n\t\t\t\t\t.append(\"<div class='apbct_long_desc__angle'></div>\")\n\t\t\t\t\t.append(\"<i class='apbct_long_desc__cancel icon-cancel'></i>\")\n\t\t\t\t\t.append(\"<h3 class='apbct_long_desc__title'>\"+result.title+\"</h3>\")\n\t\t\t\t\t.append(\"<p>\"+result.desc+\"</p>\");\n\n\t\t\t\tjQuery(document).on('click', remove_desc_func);\n\t\t\t}\n\t\t},\n\t\tobj\n\t);\n}"]}
1
+ {"version":3,"sources":["cleantalk-admin-settings-page.js"],"names":["apbct_banner_check","bannerChecker","setInterval","apbct_admin_sendAJAX","action","callback","result","data","params","obj","close_renew_banner","jQuery","length","hide","clearInterval","apbct_get_elems","elems","tmp","i","len","split","apbct_get_elems__native","out","forEach","elem","arr","document","getElementById","getElementsByClassName","key","push","apbct_show_hide_elem","each","label","next","prev","is","show","apbctSettingsDependencies","ids","enable","isNaN","console","log","getAttribute","removeAttribute","setAttribute","state","apbctSettingsDependencies_getState","checked","apbct_settings__showDescription","setting_id","remove_desc_func","e","target","parent","hasClass","remove","off","after","append","css","top","position","left","spinner","children","empty","title","desc","on","ready","getComputedStyle","direction","val","attr","this","fadeOut","d","Date","getTimezoneOffset","dialog","modal","my","at","of","window","width","height","draggable","resizable","closeText","button","setTimeout","reload","location","ctSettingsPage","key_changed","click","self"],"mappings":"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","file":"cleantalk-admin-settings-page.min.js","sourcesContent":["jQuery(document).ready(function(){\n\n\t// Crunch for Right to Left direction languages\n\tif(getComputedStyle(document.getElementsByClassName('apbct_settings-title')[0]).direction === 'rtl'){\n\t\tjQuery('.apbct_switchers').css('text-align', 'right');\n\t}\n\n\t// Show/Hide access key\n jQuery('#apbct_showApiKey').on('click', function(){\n jQuery('.apbct_setting---apikey').val(jQuery('.apbct_setting---apikey').attr('key'));\n jQuery('.apbct_setting---apikey+div').show();\n jQuery(this).fadeOut(300);\n });\n\n\tvar d = new Date();\n\tjQuery('#ct_admin_timezone').val(d.getTimezoneOffset()/60*(-1));\n\t\n\t// GDPR modal window\n\tjQuery('#apbct_gdpr_open_modal').on('click', function(){\n\t\tjQuery('#gdpr_dialog').dialog({\n\t\t\tmodal:true, \n\t\t\tshow: true,\n\t\t\tposition: { my: \"center\", at: \"center\", of: window },\n\t\t\twidth: +(jQuery('#wpbody').width() / 100 * 70), // 70% of #wpbody\n\t\t\theight: 'auto',\n\t\t\ttitle: 'GDPR compliance',\n\t\t\tdraggable: false,\n\t\t\tresizable: false,\n\t\t\tcloseText: \"Close\",\n\t\t});\n\t});\n\n\t// Sync button\n\tjQuery('#apbct_button__sync').on('click', function(){\n\t\tapbct_admin_sendAJAX(\n\t\t\t{action: 'apbct_sync'},\n\t\t\t{\n\t\t\t\tbutton: document.getElementById('apbct_button__sync' ),\n\t\t\t\tspinner: jQuery('#apbct_button__sync .apbct_preloader_button' ),\n\t\t\t\tcallback: function(result, data, params, obj){\n\t\t\t\t\tjQuery('.apbct_success').show(300);\n\t\t\t\t\tsetTimeout(function(){jQuery('.apbct_success').hide(300);}, 2000)\n\t\t\t\t\tif(result.reload)\n\t\t\t\t\t\tdocument.location.reload();\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t});\n\n\tif( ctSettingsPage.key_changed )\n\t\tjQuery('#apbct_button__sync').click();\n\n\tjQuery(document).on('click', '.apbct_settings-long_description---show', function(){\n\t\tself = jQuery(this);\n\t\tapbct_settings__showDescription(self, self.attr('setting'));\n\t});\n\n\tif (jQuery('#apbct_renew_notice').length || jQuery('#apbct_trial_notice').length) \n\t\tapbct_banner_check();\n\t\n});\n\n/**\n * Checking current account status for renew notice\n */\nfunction apbct_banner_check() {\n\tvar bannerChecker = setInterval( function() {\n\t\tapbct_admin_sendAJAX(\n\t\t\t{action: 'apbct_settings__check_renew_banner'},\n\t\t\t{\n\t\t\t\tcallback: function(result, data, params, obj){\n\t\t\t\t\tif (result.close_renew_banner) {\n\t\t\t\t\t\tif (jQuery('#apbct_renew_notice').length)\n\t\t\t\t\t\t\tjQuery('#apbct_renew_notice').hide('slow');\n\t\t\t\t\t\tif (jQuery('#apbct_trial_notice').length)\n\t\t\t\t\t\t\tjQuery('#apbct_trial_notice').hide('slow');\n\t\t\t\t\t\tclearInterval(bannerChecker);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}, 900000);\n}\n\n/**\n * Select elems like #{selector} or .{selector}\n * Selector passed in string separated by ,\n *\n * @param elems\n * @returns {*}\n */\nfunction apbct_get_elems(elems){\n elems = elems.split(',');\n for( var i=0, len = elems.length, tmp; i < len; i++){\n tmp = jQuery('#'+elems[i]);\n elems[i] = tmp.length === 0 ? jQuery('.'+elems[i]) : tmp;\n }\n return elems;\n}\n\n/**\n * Select elems like #{selector} or .{selector}\n * Selector could be passed in a string ( separated by comma ) or in array ( [ elem1, elem2, ... ] )\n *\n * @param elems string|array\n * @returns array\n */\nfunction apbct_get_elems__native(elems){\n\n\t// Make array from a string\n\tif(typeof elems === 'string')\n\t\telems = elems.split(',');\n\n\tvar out = [];\n\n\telems.forEach(function(elem, i, arr) {\n\n\t\t// try to get elements with such IDs\n\t\tvar tmp = document.getElementById(elem);\n\t\tif (tmp !== null){\n\t\t\tout.push( tmp[key] );\n\t\t\treturn;\n\t\t}\n\n\t\t// try to get elements with such class name\n\t\t// write each elem from collection to new element of output array\n\t\ttmp = document.getElementsByClassName(elem);\n\t\tif (tmp !== null && tmp.length !==0 ){\n\t\t\tfor(key in tmp){\n\t\t\t\tif( +key >= 0 ){\n\t\t\t\t\tout.push( tmp[key] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\treturn out;\n}\n\nfunction apbct_show_hide_elem(elems){\n\telems = apbct_get_elems(elems);\n for( var i=0, len = elems.length; i < len; i++){\n elems[i].each(function (i, elem) {\n elem = jQuery(elem);\n var label = elem.next('label') || elem.prev('label') || null;\n if (elem.is(\":visible\")) {\n elem.hide();\n if (label) label.hide();\n } else {\n elem.show();\n if (label) label.show();\n }\n });\n }\n}\n\n/**\n * Settings dependences. Switch|toggle depended elements state (disabled|enabled)\n * Recieve list of selectors ( without class mark (.) or id mark (#) )\n *\n * @param ids string|array Selectors\n * @param enable\n */\nfunction apbctSettingsDependencies(ids, enable){\n\n\n\tenable = ! isNaN(enable) ? enable : null;\n\n\t// Get elements\n\tvar elems = apbct_get_elems__native( ids );\n\n\telems.forEach(function(elem, i, arr){\n\n\t\tconsole.log( elem.getAttribute('id') );\n\n\t\tvar do_disable = function(){elem.setAttribute('disabled', 'disabled');},\n\t\t\tdo_enable = function(){elem.removeAttribute('disabled');};\n\n\t\t// Set defined state\n\t\tif(enable === null) // Set\n\t\t\tenable = elem.getAttribute('disabled') === null ? 0 : 1;\n\n\t\tenable === 1 ? do_enable() : do_disable();\n\n\t\tif( elem.getAttribute('apbct_children') !== null){\n\t\t\tvar state = apbctSettingsDependencies_getState( elem ) && enable;\n\t\t\tif( state !== null ) {\n\t\t\t\tapbctSettingsDependencies( elem.getAttribute('apbct_children'), state );\n\t\t\t}\n\t\t}\n\n\t});\n}\n\nfunction apbctSettingsDependencies_getState( elem ){\n\n\tvar state;\n\n\tswitch ( elem.getAttribute( 'type' ) ){\n\t\tcase 'checkbox':\n\t\t\tstate = +elem.checked;\n\t\t\tbreak;\n\t\tcase 'radio':\n\t\t\tstate = +(+elem.getAttribute('value') === 1);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tstate = null;\n\t}\n\n\treturn state;\n}\n\nfunction apbct_settings__showDescription(label, setting_id){\n\n\tvar remove_desc_func = function(e){\n\t\tif(typeof e === 'undefined' || ((jQuery(e.target).parent('.apbct_long_desc').length == 0 || jQuery(e.target).hasClass('apbct_long_desc__cancel')) && !jQuery(e.target).hasClass('apbct_long_description__show'))){\n\t\t\tjQuery('.apbct_long_desc').remove();\n\t\t\tjQuery(document).off('click', remove_desc_func);\n\t\t}\n\t};\n\n\tremove_desc_func();\n\n\tlabel.after(\"<div id='apbct_long_desc__\"+setting_id+\"' class='apbct_long_desc'></div>\");\n\tvar obj = jQuery('#apbct_long_desc__'+setting_id);\n\tobj.append(\"<i class='icon-spin1 animate-spin'></i>\")\n\t\t.append(\"<div class='apbct_long_desc__angle'></div>\")\n\t\t.css({\n\t\t\ttop: label.position().top - 5,\n\t\t\tleft: label.position().left + 25\n\t\t});\n\n\n\tapbct_admin_sendAJAX(\n\t\t{action: 'apbct_settings__get_description', setting_id: setting_id},\n\t\t{\n\t\t\tspinner: obj.children('img'),\n\t\t\tcallback: function(result, data, params, obj){\n\n\t\t\t\tobj.empty()\n\t\t\t\t\t.append(\"<div class='apbct_long_desc__angle'></div>\")\n\t\t\t\t\t.append(\"<i class='apbct_long_desc__cancel icon-cancel'></i>\")\n\t\t\t\t\t.append(\"<h3 class='apbct_long_desc__title'>\"+result.title+\"</h3>\")\n\t\t\t\t\t.append(\"<p>\"+result.desc+\"</p>\");\n\n\t\t\t\tjQuery(document).on('click', remove_desc_func);\n\t\t\t}\n\t\t},\n\t\tobj\n\t);\n}"]}
lib/Cleantalk/ApbctWP/Firewall/SFW.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  namespace Cleantalk\ApbctWP\Firewall;
4
 
5
- use Cleantalk\Common\Helper as Helper;
6
  use Cleantalk\Variables\Cookie;
7
  use Cleantalk\Variables\Get;
8
  use Cleantalk\Variables\Server;
@@ -53,7 +53,7 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
53
  */
54
  public function ip__append_additional( &$ips ){
55
 
56
- $this->real_ip = $ips['real'];
57
 
58
  if( Get::get( 'sfw_test_ip' ) ){
59
  if( Helper::ip__validate( Get::get( 'sfw_test_ip' ) ) !== false ){
@@ -353,114 +353,172 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
353
  // Getting remote file name
354
  if(!$file_url){
355
 
356
- sleep(6);
357
-
358
  $result = \Cleantalk\Common\API::method__get_2s_blacklists_db($ct_key, 'multifiles', '2_0');
359
 
360
- if(empty($result['error'])){
 
 
361
 
362
- if( !empty($result['file_url']) ){
 
 
 
 
363
 
364
- if(Helper::http__request($result['file_url'], array(), 'get_code') === 200) {
365
 
366
- if(ini_get('allow_url_fopen')) {
367
-
368
- $patterns = array();
369
- $patterns[] = 'get';
370
-
371
- if(!$immediate) $patterns[] = 'async';
372
-
373
- // Clear SFW table
374
- $db->execute("TRUNCATE TABLE {$db__table__data};");
375
- $db->set_query("SELECT COUNT(network) as cnt FROM {$db__table__data};")->fetch(); // Check if it is clear
376
- if($db->result['cnt'] != 0){
377
- $db->execute("DELETE FROM {$db__table__data};"); // Truncate table
378
- $db->set_query("SELECT COUNT(network) as cnt FROM {$db__table__data};")->fetch(); // Check if it is clear
379
- if($db->result['cnt'] != 0){
380
- return array('error' => 'COULD_NOT_CLEAR_SFW_TABLE'); // throw an error
381
- }
382
- }
383
 
384
- $gf = \gzopen($result['file_url'], 'rb');
385
 
386
- if ($gf) {
387
 
388
- $file_urls = array();
389
-
390
- while( ! \gzeof($gf) )
391
- $file_urls[] = trim( \gzgets($gf, 1024) );
392
-
393
- \gzclose($gf);
394
-
395
- return Helper::http__request(
396
- get_option('siteurl'),
397
- array(
398
- 'spbc_remote_call_token' => md5($ct_key),
399
- 'spbc_remote_call_action' => 'sfw_update',
400
- 'plugin_name' => 'apbct',
401
- 'file_urls' => implode(',', $file_urls),
402
- ),
403
- $patterns
404
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
405
  }else
406
- return array('error' => 'COULD_NOT_OPEN_REMOTE_FILE_SFW');
407
  }else
408
- return array('error' => 'ERROR_ALLOW_URL_FOPEN_DISABLED');
409
  }else
410
- return array('error' => 'NO_FILE_URL_PROVIDED');
411
  }else
412
- return array('error' => 'BAD_RESPONSE');
413
  }else
414
  return $result;
415
  }else{
416
 
417
- if(Helper::http__request($file_url, array(), 'get_code') === 200){ // Check if it's there
418
-
419
- $gf = \gzopen($file_url, 'rb');
420
-
421
- if($gf){
422
 
423
- if( ! \gzeof($gf) ){
 
 
424
 
425
- for( $count_result = 0; ! \gzeof($gf); ){
426
-
427
- $query = "INSERT INTO ".$db__table__data." VALUES %s";
428
 
429
- for($i=0, $values = array(); APBCT_WRITE_LIMIT !== $i && ! \gzeof($gf); $i++, $count_result++){
430
 
431
- $entry = trim( \gzgets($gf, 1024) );
432
 
433
- if(empty($entry)) continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
434
 
435
- $entry = explode(',', $entry);
436
 
437
- // Cast result to int
438
- $ip = preg_replace('/[^\d]*/', '', $entry[0]);
439
- $mask = preg_replace('/[^\d]*/', '', $entry[1]);
440
- $private = isset($entry[2]) ? $entry[2] : 0;
441
 
442
- if(!$ip || !$mask) continue;
 
 
 
 
 
 
 
443
 
444
  $values[] = '('. $ip .','. $mask .','. $private .')';
445
 
446
  }
447
 
448
- if(!empty($values)){
449
- $query = sprintf($query, implode(',', $values).';');
450
- $db->execute($query);
451
  }
452
 
453
  }
454
 
455
- \gzclose($gf);
456
  return $count_result;
457
 
458
  }else
459
- return array('error' => 'ERROR_GZ_EMPTY');
460
  }else
461
- return array('error' => 'ERROR_OPEN_GZ_FILE');
462
  }else
463
- return array('error' => 'NO_REMOTE_FILE_FOUND');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
464
  }
465
  }
466
  }
2
 
3
  namespace Cleantalk\ApbctWP\Firewall;
4
 
5
+ use Cleantalk\ApbctWP\Helper as Helper;
6
  use Cleantalk\Variables\Cookie;
7
  use Cleantalk\Variables\Get;
8
  use Cleantalk\Variables\Server;
53
  */
54
  public function ip__append_additional( &$ips ){
55
 
56
+ $this->real_ip = isset($ips['real']) ? $ips['real'] : null;
57
 
58
  if( Get::get( 'sfw_test_ip' ) ){
59
  if( Helper::ip__validate( Get::get( 'sfw_test_ip' ) ) !== false ){
353
  // Getting remote file name
354
  if(!$file_url){
355
 
 
 
356
  $result = \Cleantalk\Common\API::method__get_2s_blacklists_db($ct_key, 'multifiles', '2_0');
357
 
358
+ sleep(4);
359
+
360
+ if( empty( $result['error'] ) ){
361
 
362
+ if( ! empty( $result['file_url'] ) ){
363
+
364
+ $file_url = trim( $result['file_url'] );
365
+
366
+ $response_code = Helper::http__request__get_response_code( $file_url );
367
 
368
+ if( empty( $response_code['error'] ) ){
369
 
370
+ if( $response_code == 200 ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
371
 
372
+ $gz_data = Helper::http__request__get_content( $file_url );
373
 
374
+ if( empty( $gz_data['error'] ) ){
375
 
376
+ if( Helper::get_mime_type( $gz_data, 'application/x-gzip' ) ){
377
+
378
+ if( function_exists( 'gzdecode' ) ){
379
+
380
+ $data = gzdecode( $gz_data );
381
+
382
+ if( $data !== false ){
383
+
384
+ $result__clear_db = self::clear_data_table( $db, $db__table__data );
385
+
386
+ if( empty( $result__clear_db['error'] ) ){
387
+
388
+ $lines = Helper::buffer__parse__csv( $data );
389
+
390
+ $file_urls = array();
391
+
392
+ while( current( $lines ) !== false ){
393
+ $file_urls[] = current( $lines )[0];
394
+ next( $lines );
395
+ }
396
+
397
+ $patterns = array();
398
+ $patterns[] = 'get';
399
+
400
+ if( ! $immediate ){
401
+ $patterns[] = 'async';
402
+ }
403
+
404
+ return Helper::http__request(
405
+ get_option( 'siteurl' ),
406
+ array(
407
+ 'spbc_remote_call_token' => md5( $ct_key ),
408
+ 'spbc_remote_call_action' => 'sfw_update',
409
+ 'plugin_name' => 'apbct',
410
+ 'file_urls' => implode( ',', $file_urls ),
411
+ ),
412
+ $patterns
413
+ );
414
+
415
+ }else
416
+ return $result__clear_db;
417
+ }else
418
+ return array('error' => 'COULD_DECODE_MULTIFILE');
419
+ }else
420
+ return array('error' => 'FUNCTION_GZ_DECODE_DOES_NOT_EXIST');
421
+ }else
422
+ return array('error' => 'WRONG_MULTIFILE_MIME_TYPE');
423
  }else
424
+ return array('error' => 'COULD_NOT_GET_MULTIFILE: ' . $gz_data['error'] );
425
  }else
426
+ return array('error' => 'MULTIFILE_BAD_RESPONSE_CODE: '. (int) $response_code );
427
  }else
428
+ return array('error' => 'MULTIFILE_COULD_NOT_GET_RESPONSE_CODE: '. $response_code['error'] );
429
  }else
430
+ return array('error' => 'NO_REMOTE_MULTIFILE_FOUND: ' . $result['file_url'] );
431
  }else
432
  return $result;
433
  }else{
434
 
435
+ $response_code = Helper::http__request($file_url, array(), 'get_code');
436
+
437
+ if( empty( $response_code['error'] ) ){
438
+
439
+ if($response_code == 200){ // Check if it's there
440
 
441
+ $gz_data = Helper::http__request__get_content( $file_url );
442
+
443
+ if( empty( $gz_data['error'] ) ){
444
 
445
+ if( Helper::get_mime_type( $gz_data, 'application/x-gzip' ) ){
 
 
446
 
447
+ if( function_exists( 'gzdecode' ) ){
448
 
449
+ $data = gzdecode( $gz_data );
450
 
451
+ if( $data !== false ){
452
+
453
+ $lines = Helper::buffer__parse__csv( $data );
454
+
455
+ }else
456
+ return array('error' => 'COULD_DECODE_FILE');
457
+ }else
458
+ return array('error' => 'FUNCTION_GZ_DECODE_DOES_NOT_EXIST');
459
+ }else
460
+ return array('error' => 'WRONG_FILE_MIME_TYPE');
461
+
462
+ for( $count_result = 0; current($lines) !== false; ) {
463
+
464
+ $query = "INSERT INTO ".$db__table__data." VALUES ";
465
+
466
+ for( $i = 0, $values = array(); APBCT_WRITE_LIMIT !== $i && current( $lines ) !== false; $i ++, $count_result ++, next( $lines ) ){
467
 
468
+ $entry = current($lines);
469
 
470
+ if(empty($entry))
471
+ continue;
 
 
472
 
473
+ if ( APBCT_WRITE_LIMIT !== $i ) {
474
+
475
+ // Cast result to int
476
+ $ip = preg_replace('/[^\d]*/', '', $entry[0]);
477
+ $mask = preg_replace('/[^\d]*/', '', $entry[1]);
478
+ $private = isset($entry[2]) ? $entry[2] : 0;
479
+
480
+ }
481
 
482
  $values[] = '('. $ip .','. $mask .','. $private .')';
483
 
484
  }
485
 
486
+ if( ! empty( $values ) ){
487
+ $query = $query . implode( ',', $values ) . ';';
488
+ $db->execute( $query );
489
  }
490
 
491
  }
492
 
 
493
  return $count_result;
494
 
495
  }else
496
+ return array('error' => 'COULD_NOT_GET_FILE: ' . $gz_data['error'] );
497
  }else
498
+ return array('error' => 'FILE_BAD_RESPONSE_CODE: '. (int) $response_code );
499
  }else
500
+ return array('error' => 'FILE_COULD_NOT_GET_RESPONSE_CODE: '. $response_code['error'] );
501
+ }
502
+ }
503
+
504
+ /**
505
+ * Clear SFW table
506
+ *
507
+ * @param $db
508
+ * @param $db__table__data
509
+ *
510
+ * @return string[]
511
+ */
512
+ public static function clear_data_table( $db, $db__table__data ) {
513
+
514
+ $db->execute( "TRUNCATE TABLE {$db__table__data};" );
515
+ $db->set_query( "SELECT COUNT(network) as cnt FROM {$db__table__data};" )->fetch(); // Check if it is clear
516
+ if( $db->result['cnt'] != 0 ){
517
+ $db->execute( "DELETE FROM {$db__table__data};" ); // Truncate table
518
+ $db->set_query( "SELECT COUNT(network) as cnt FROM {$db__table__data};" )->fetch(); // Check if it is clear
519
+ if( $db->result['cnt'] != 0 ){
520
+ return array( 'error' => 'COULD_NOT_CLEAR_SFW_TABLE' ); // throw an error
521
+ }
522
  }
523
  }
524
  }
lib/Cleantalk/ApbctWP/Helper.php CHANGED
@@ -47,4 +47,28 @@ class Helper extends \Cleantalk\Common\Helper
47
 
48
  return parent::http__request($url, $data, $presets, $opts);
49
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
47
 
48
  return parent::http__request($url, $data, $presets, $opts);
49
  }
50
+
51
+ /**
52
+ * Wrapper for http_request
53
+ * Requesting HTTP response code for $url
54
+ *
55
+ * @param string $url
56
+ *
57
+ * @return array|mixed|string
58
+ */
59
+ static public function http__request__get_response_code( $url ){
60
+ return static::http__request( $url, array(), 'get_code');
61
+ }
62
+
63
+ /**
64
+ * Wrapper for http_request
65
+ * Requesting data via HTTP request with GET method
66
+ *
67
+ * @param string $url
68
+ *
69
+ * @return array|mixed|string
70
+ */
71
+ static public function http__request__get_content( $url ){
72
+ return static::http__request( $url, array(), 'get dont_split_to_array');
73
+ }
74
  }
lib/Cleantalk/ApbctWP/State.php CHANGED
@@ -117,7 +117,7 @@ class State
117
  'debug_ajax' => 0,
118
 
119
  // GDPR
120
- 'gdpr_enabled' => 0,
121
  'gdpr_text' => 'By using this form you agree with the storage and processing of your data by using the Privacy Policy on this website.',
122
 
123
  // Msic
117
  'debug_ajax' => 0,
118
 
119
  // GDPR
120
+ 'gdpr_enabled' => 0,
121
  'gdpr_text' => 'By using this form you agree with the storage and processing of your data by using the Privacy Policy on this website.',
122
 
123
  // Msic
lib/Cleantalk/Common/API.php CHANGED
@@ -664,6 +664,17 @@ class API
664
  if($ssl === false){
665
  return self::send_request($data, $url, $timeout, true, $ssl_path);
666
  }
 
 
 
 
 
 
 
 
 
 
 
667
  }
668
 
669
  }else{
664
  if($ssl === false){
665
  return self::send_request($data, $url, $timeout, true, $ssl_path);
666
  }
667
+ if (function_exists('gethostbynamel')) {
668
+ $server_ips = gethostbynamel('api.cleantalk.org');
669
+ if ($server_ips !== false && is_array($server_ips) && count($server_ips)) {
670
+ foreach ($server_ips as $ip) {
671
+ $allowed = @fsockopen ($ip, 80, $errno, $errstr, $timeout / 2);
672
+ if ($allowed) {
673
+ return self::send_request($data, 'https://'.$ip, $timeout, true);
674
+ }
675
+ }
676
+ }
677
+ }
678
  }
679
 
680
  }else{
lib/Cleantalk/Common/Helper.php CHANGED
@@ -745,4 +745,88 @@ class Helper
745
  return time() - ( ( time() - strtotime( date( 'd F Y' ) ) ) % $interval );
746
  }
747
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
748
  }
745
  return time() - ( ( time() - strtotime( date( 'd F Y' ) ) ) % $interval );
746
  }
747
 
748
+ /**
749
+ * Get mime type from file or data
750
+ *
751
+ * @param string $data Path to file or data
752
+ * @param string $type Default mime type. Returns if we failed to detect type
753
+ *
754
+ * @return string
755
+ */
756
+ static function get_mime_type( $data, $type = '' )
757
+ {
758
+ if( @file_exists( $data )){
759
+ $type = mime_content_type( $data );
760
+ }elseif( function_exists('finfo_open' ) ){
761
+ $finfo = finfo_open(FILEINFO_MIME_TYPE);
762
+ $type = finfo_buffer($finfo, $data);
763
+ finfo_close($finfo);
764
+ }
765
+ return $type;
766
+ }
767
+
768
+ static function buffer__trim_and_clear_from_empty_lines( $buffer ){
769
+ $buffer = (array) $buffer;
770
+ foreach( $buffer as $indx => &$line ){
771
+ $line = trim( $line );
772
+ if($line === '')
773
+ unset( $buffer[$indx] );
774
+ }
775
+ return $buffer;
776
+ }
777
+
778
+ static function buffer__parse__csv( $buffer ){
779
+ $buffer = explode( "\n", $buffer );
780
+ $buffer = self::buffer__trim_and_clear_from_empty_lines( $buffer );
781
+ foreach($buffer as &$line){
782
+ $line = str_getcsv($line, ',', '\'');
783
+ }
784
+ return $buffer;
785
+ }
786
+
787
+ /**
788
+ * Pops line from buffer without formatting
789
+ *
790
+ * @param $csv
791
+ *
792
+ * @return false|string
793
+ */
794
+ static public function buffer__csv__pop_line( &$csv ){
795
+ $pos = strpos( $csv, "\n" );
796
+ $line = substr( $csv, 0, $pos );
797
+ $csv = substr_replace( $csv, '', 0, $pos + 1 );
798
+ return $line;
799
+ }
800
+
801
+ /**
802
+ * Pops line from the csv buffer and fromat it by map to array
803
+ *
804
+ * @param $csv
805
+ * @param array $map
806
+ *
807
+ * @return array|false
808
+ */
809
+ static public function buffer__csv__get_map( &$csv ){
810
+ $line = static::buffer__csv__pop_line( $csv );
811
+ return explode( ',', $line );
812
+ }
813
+
814
+ /**
815
+ * Pops line from the csv buffer and fromat it by map to array
816
+ *
817
+ * @param $csv
818
+ * @param array $map
819
+ *
820
+ * @return array|false
821
+ */
822
+ static public function buffer__csv__pop_line_to_array( &$csv, $map = array() ){
823
+ $line = trim( static::buffer__csv__pop_line( $csv ) );
824
+ $line = strpos( $line, '\'' ) === 0
825
+ ? str_getcsv($line, ',', '\'')
826
+ : explode( ',', $line );
827
+ if( $map )
828
+ $line = array_combine( $map, $line );
829
+ return $line;
830
+ }
831
+
832
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: spam, antispam, woocommerce, comments, firewall
4
  Requires at least: 3.0
5
  Tested up to: 5.5
6
  Requires PHP: 5.4
7
- Stable tag: 5.142.2
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
@@ -34,6 +34,8 @@ No CAPTCHA, no questions, no animal counting, no puzzles, no math and no spam bo
34
  16. Mobile friendly Anti Spam & FireWall.
35
  17. Stops spam in Search Form.
36
  18. Disable comments.
 
 
37
 
38
  = Public reviews =
39
  > CleanTalk - Cloud-Based Anti-Spam Service to Keep Your Site Bot-Free.
@@ -157,6 +159,9 @@ All the CleanTalk Spam FireWall activity is being logged in the process of filte
157
  Spam FireWall can mitigate HTTP/HTTPS DDoS attacks. When an intruder makes GET requests to attack your website, Spam FireWall blocks all requests from bad IP addresses. Your website gives the intruder a special page with the description of DDoS rejection instead of the website pages. Therefore Spam FireWall helps to reduce CPU usage of your server.
158
  [youtube https://www.youtube.com/watch?v=Eu5Zqryvj4k]
159
 
 
 
 
160
  = XML-RPC brute force protection =
161
  Spam FireWall can mitigate XML-RPC brute force attacks. It blocks XML-RPC attacks from bad IP addresses. This helps to prevent bruteforce attacks by a Remote Procedure Call.
162
 
@@ -574,6 +579,13 @@ If your website has forms that send data to external sources, you can enable opt
574
 
575
  == Changelog ==
576
 
 
 
 
 
 
 
 
577
  = 5.142.2 Jul 29 2020 =
578
  * Fix: Issue with SpamFireWall logs.
579
 
@@ -763,4 +775,4 @@ If your website has forms that send data to external sources, you can enable opt
763
  * Minor fixes.
764
  * Spam protection improved.
765
 
766
- = Early changelogs look in changelog.txt =
4
  Requires at least: 3.0
5
  Tested up to: 5.5
6
  Requires PHP: 5.4
7
+ Stable tag: 5.143
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
34
  16. Mobile friendly Anti Spam & FireWall.
35
  17. Stops spam in Search Form.
36
  18. Disable comments.
37
+ 19. Spam FireWall: Anti-Flood
38
+ 20. Spam FireWall: Anti-Crawler
39
 
40
  = Public reviews =
41
  > CleanTalk - Cloud-Based Anti-Spam Service to Keep Your Site Bot-Free.
159
  Spam FireWall can mitigate HTTP/HTTPS DDoS attacks. When an intruder makes GET requests to attack your website, Spam FireWall blocks all requests from bad IP addresses. Your website gives the intruder a special page with the description of DDoS rejection instead of the website pages. Therefore Spam FireWall helps to reduce CPU usage of your server.
160
  [youtube https://www.youtube.com/watch?v=Eu5Zqryvj4k]
161
 
162
+ = Spam FireWall: Anti-Flood & Anti-Crawler =
163
+ Spam FireWall: Anti-Flood and Anti-Crawler options are intended for blocking unwanted bots, content parsing, shop goods prices parsing or aggressive website scanning bots. Learn more https://cleantalk.org/help/anti-flood-and-anti-crawler
164
+
165
  = XML-RPC brute force protection =
166
  Spam FireWall can mitigate XML-RPC brute force attacks. It blocks XML-RPC attacks from bad IP addresses. This helps to prevent bruteforce attacks by a Remote Procedure Call.
167
 
579
 
580
  == Changelog ==
581
 
582
+ = 5.143 Aug 05 2020 =
583
+ * New: Synchronize button. New way of synchronize with the Cleantalk Cloud.
584
+ * Fix: SpamFireWall (firewall against spam) update, storing system.
585
+ * Fix: Skip Woocomerce metorik send cart.
586
+ * Spam protection improved.
587
+ * Minor fixes.
588
+
589
  = 5.142.2 Jul 29 2020 =
590
  * Fix: Issue with SpamFireWall logs.
591
 
775
  * Minor fixes.
776
  * Spam protection improved.
777
 
778
+ = Early changelogs look in changelog.txt =