Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.151.3

Version Description

Jan 15 2020 = * Fix: Prevent logging false blocking for whitelisted networks. * Integration: Rafflepress integration implemented. * Fix: AF limit increased to 20 by default. * Fix: skip Sumo waitlist internal request. * Fix: skip raq internal request. * Fix: check comments number if comment email exists. * New: Schema class added. * Fix: SFW - Creation sfw table if not exist. * Fix: Updater - Creation sfw table if not exist. * New: Schema class used. * New: AC disabled if networks count is 0. * Fix: SFW updating id getting fixed. * Fix: SFW networks counter fixed. * Fix: Deleting options fixed.

Download this release

Release Info

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

Code changes from version 5.151.2 to 5.151.3

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.151.2
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
@@ -17,6 +17,7 @@ use Cleantalk\ApbctWP\Cron;
17
  use Cleantalk\ApbctWP\DB;
18
  use Cleantalk\ApbctWP\Firewall\SFW;
19
  use Cleantalk\ApbctWP\Helper;
 
20
  use Cleantalk\Variables\Get;
21
 
22
  $cleantalk_executed = false;
@@ -193,6 +194,7 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
193
  'EstimationForm' => array( 'hook' => 'send_email', 'ajax' => true ),
194
  'LandingPageBuilder' => array( 'hook' => 'ulpb_formBuilderEmail_ajax', 'ajax' => true ),
195
  'WpMembers' => array( 'hook' => 'wpmem_pre_register_data', 'ajax' => false ),
 
196
  );
197
  new \Cleantalk\Antispam\Integrations( $apbct_active_integrations );
198
 
@@ -657,7 +659,7 @@ function apbct_sfw__check()
657
  )
658
  ) );
659
 
660
- if( $apbct->settings['sfw__anti_crawler'] ){
661
  $firewall->load_fw_module( new \Cleantalk\ApbctWP\Firewall\AntiCrawler(
662
  APBCT_TBL_FIREWALL_LOG,
663
  APBCT_TBL_AC_LOG,
@@ -686,67 +688,13 @@ function apbct_sfw__check()
686
 
687
  /**
688
  * On activation, set a time, frequency and name of an action hook to be scheduled.
 
689
  */
690
  function apbct_activation( $network = false ) {
691
 
692
  global $wpdb;
693
-
694
- // SFW data
695
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw` (
696
- `id` INT(11) NOT NULL AUTO_INCREMENT,
697
- `network` int(11) unsigned NOT NULL,
698
- `mask` int(11) unsigned NOT NULL,
699
- `status` TINYINT(1) NOT NULL DEFAULT 0,
700
- PRIMARY KEY (`id`),
701
- INDEX ( `network` , `mask` )
702
- );';
703
-
704
- // UA BL
705
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_ua_bl` (
706
- `id` INT(11) NOT NULL,
707
- `ua_template` VARCHAR(255) NULL DEFAULT NULL,
708
- `ua_status` TINYINT(1) NULL DEFAULT NULL,
709
- PRIMARY KEY ( `id` ),
710
- INDEX ( `ua_template` )
711
- ) DEFAULT CHARSET=utf8;'; // Don't remove the default charset!
712
-
713
- // SFW log
714
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw_logs` (
715
- `id` VARCHAR(40) NOT NULL,
716
- `ip` VARCHAR(15) NOT NULL,
717
- `status` ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW__BY_WHITELIST\',\'PASS_SFW__BY_COOKIE\',\'DENY_ANTICRAWLER\',\'PASS_ANTICRAWLER\',\'DENY_ANTICRAWLER_UA\',\'PASS_ANTICRAWLER_UA\',\'DENY_ANTIFLOOD\',\'PASS_ANTIFLOOD\') NULL DEFAULT NULL,
718
- `all_entries` INT NOT NULL,
719
- `blocked_entries` INT NOT NULL,
720
- `entries_timestamp` INT NOT NULL,
721
- `ua_id` INT(11) NULL DEFAULT NULL,
722
- `ua_name` VARCHAR(1024) NOT NULL,
723
- PRIMARY KEY (`id`));';
724
-
725
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_ac_log` (
726
- `id` VARCHAR(40) NOT NULL,
727
- `ip` VARCHAR(40) NOT NULL,
728
- `ua` VARCHAR(40) NOT NULL,
729
- `entries` INT DEFAULT 0,
730
- `interval_start` INT NOT NULL,
731
- PRIMARY KEY (`id`));';
732
-
733
- // Sessions
734
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sessions` (
735
- `id` VARCHAR(64) NOT NULL,
736
- `name` VARCHAR(40) NOT NULL,
737
- `value` TEXT NULL DEFAULT NULL,
738
- `last_update` DATETIME NULL DEFAULT NULL,
739
- PRIMARY KEY (`name`(40), `id`(64)));';
740
-
741
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_spamscan_logs` (
742
- `id` int(11) NOT NULL AUTO_INCREMENT,
743
- `scan_type` varchar(11) NOT NULL,
744
- `start_time` datetime NOT NULL,
745
- `finish_time` datetime NOT NULL,
746
- `count_to_scan` int(11) DEFAULT NULL,
747
- `found_spam` int(11) DEFAULT NULL,
748
- `found_bad` int(11) DEFAULT NULL,
749
- PRIMARY KEY (`id`));';
750
 
751
  if($network && !defined('CLEANTALK_ACCESS_KEY')){
752
  $initial_blog = get_current_blog_id();
@@ -805,72 +753,18 @@ function apbct_activation__create_tables( $sqls, $db_prefix = '' ) {
805
  apbct_log($errors);
806
  }
807
 
 
 
 
 
808
  function apbct_activation__new_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
809
  if (apbct_is_plugin_active_for_network('cleantalk-spam-protect/cleantalk.php')){
810
 
811
  $settings = get_option('cleantalk_settings');
812
 
813
  switch_to_blog($blog_id);
814
-
815
- global $wpdb;
816
-
817
- // SFW data
818
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw` (
819
- `id` INT(11) NOT NULL AUTO_INCREMENT,
820
- `network` int(11) unsigned NOT NULL,
821
- `mask` int(11) unsigned NOT NULL,
822
- `status` TINYINT(1) NOT NULL DEFAULT 0,
823
- PRIMARY KEY (`id`),
824
- INDEX ( `network` , `mask` )
825
- );';
826
-
827
- // UA BL
828
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_ua_bl` (
829
- `id` INT(11) NOT NULL,
830
- `ua_template` VARCHAR(255) NULL DEFAULT NULL,
831
- `ua_status` TINYINT(1) NULL DEFAULT NULL,
832
- PRIMARY KEY ( `id` ),
833
- INDEX ( `ua_template` )
834
- ) DEFAULT CHARSET=utf8;'; // Don't remove the default charset!
835
-
836
-
837
- // SFW log
838
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw_logs` (
839
- `id` VARCHAR(40) NOT NULL,
840
- `ip` VARCHAR(15) NOT NULL,
841
- `status` ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW__BY_WHITELIST\',\'PASS_SFW__BY_COOKIE\',\'DENY_ANTICRAWLER\',\'PASS_ANTICRAWLER\',\'DENY_ANTICRAWLER_UA\',\'PASS_ANTICRAWLER_UA\',\'DENY_ANTIFLOOD\',\'PASS_ANTIFLOOD\') NULL DEFAULT NULL,
842
- `all_entries` INT NOT NULL,
843
- `blocked_entries` INT NOT NULL,
844
- `entries_timestamp` INT NOT NULL,
845
- `ua_id` INT(11) NULL DEFAULT NULL,
846
- `ua_name` VARCHAR(1024) NOT NULL,
847
- PRIMARY KEY (`id`));';
848
-
849
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_ac_log` (
850
- `id` VARCHAR(40) NOT NULL,
851
- `ip` VARCHAR(40) NOT NULL,
852
- `ua` VARCHAR(40) NOT NULL,
853
- `entries` INT DEFAULT 0,
854
- `interval_start` INT NOT NULL,
855
- PRIMARY KEY (`id`));';
856
-
857
- // Sessions
858
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sessions` (
859
- `id` VARCHAR(64) NOT NULL,
860
- `name` TEXT NOT NULL,
861
- `value` TEXT NULL DEFAULT NULL,
862
- `last_update` DATETIME NULL DEFAULT NULL,
863
- PRIMARY KEY (`id`(64), `name`(64)));';
864
-
865
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_spamscan_logs` (
866
- `id` int(11) NOT NULL AUTO_INCREMENT,
867
- `scan_type` varchar(11) NOT NULL,
868
- `start_time` datetime NOT NULL,
869
- `finish_time` datetime NOT NULL,
870
- `count_to_scan` int(11) DEFAULT NULL,
871
- `found_spam` int(11) DEFAULT NULL,
872
- `found_bad` int(11) DEFAULT NULL,
873
- PRIMARY KEY (`id`));';
874
 
875
  // Cron tasks
876
  Cron::addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // Checks account status
@@ -956,6 +850,8 @@ function apbct_deactivation__delete_all_options(){
956
  delete_option('cleantalk_stats');
957
  delete_option('cleantalk_timelabel_reg');
958
  delete_option('cleantalk_debug');
 
 
959
  }
960
 
961
  /**
@@ -974,6 +870,7 @@ function apbct_deactivation__delete_common_tables() {
974
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_sessions`;'); // Deleting session table
975
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_spamscan_logs`;'); // Deleting user/comments scan result table
976
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_ua_bl`;'); // Deleting AC UA black lists
 
977
  }
978
 
979
  function apbct_deactivation__delete_blog_tables() {
@@ -984,6 +881,7 @@ function apbct_deactivation__delete_blog_tables() {
984
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_sessions`;'); // Deleting session table
985
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_spamscan_logs`;'); // Deleting user/comments scan result table
986
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_ua_bl`;'); // Deleting AC UA black lists
 
987
  }
988
 
989
  function apbct_deactivation__delete_meta(){
@@ -1056,7 +954,7 @@ function ct_get_cookie()
1056
 
1057
  function ct_sfw_update( $api_key = '', $immediate = false ){
1058
 
1059
- global $apbct;
1060
 
1061
  // Prevent start another update at a time
1062
  if(
@@ -1074,17 +972,17 @@ function ct_sfw_update( $api_key = '', $immediate = false ){
1074
  return array( 'error' => 'FIREWALL_IS_UPDATING' );
1075
  }
1076
 
1077
- // Set new update ID
1078
- if( ! $apbct->fw_stats['firewall_updating_id'] || time() - $apbct->fw_stats['firewall_updating_last_start'] > 300 ){
1079
- $apbct->fw_stats['firewall_updating_id'] = md5( rand( 0, 100000 ) );
1080
- $apbct->fw_stats['firewall_updating_last_start'] = time();
1081
- $apbct->save( 'fw_stats' );
1082
- }
1083
-
1084
  $api_key = !empty($apbct->api_key) ? $apbct->api_key : $api_key;
1085
 
1086
  if( $apbct->settings['spam_firewall'] == 1 && ( ! empty($api_key) || $apbct->data['moderate_ip'] ) ) {
1087
 
 
 
 
 
 
 
 
1088
  if( apbct_is_remote_call() ) {
1089
  // Remote call is in process, do updating
1090
 
@@ -1094,10 +992,6 @@ function ct_sfw_update( $api_key = '', $immediate = false ){
1094
 
1095
  if( ! $file_urls ){
1096
 
1097
- //Reset previous entries count
1098
- $apbct->stats['sfw']['entries'] = 0;
1099
- $apbct->save('stats');
1100
-
1101
  // @todo We have to handle errors here
1102
  SFW::create_temp_tables( DB::getInstance() );
1103
 
@@ -1127,9 +1021,6 @@ function ct_sfw_update( $api_key = '', $immediate = false ){
1127
 
1128
  $current_url++;
1129
 
1130
- //Increment sfw entries
1131
- $apbct->stats['sfw']['entries'] += $result;
1132
- $apbct->save('stats');
1133
  $apbct->fw_stats['firewall_update_percent'] = round( ( ( (int) $current_url + 1 ) / (int) $url_count ), 2) * 100;
1134
  $apbct->save('fw_stats');
1135
 
@@ -1163,6 +1054,7 @@ function ct_sfw_update( $api_key = '', $immediate = false ){
1163
  $apbct->save( 'fw_stats' );
1164
 
1165
  //Files array is empty update sfw time
 
1166
  $apbct->stats['sfw']['last_update_time'] = time();
1167
  $apbct->save('stats');
1168
 
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.151.3
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
17
  use Cleantalk\ApbctWP\DB;
18
  use Cleantalk\ApbctWP\Firewall\SFW;
19
  use Cleantalk\ApbctWP\Helper;
20
+ use Cleantalk\Common\Schema;
21
  use Cleantalk\Variables\Get;
22
 
23
  $cleantalk_executed = false;
194
  'EstimationForm' => array( 'hook' => 'send_email', 'ajax' => true ),
195
  'LandingPageBuilder' => array( 'hook' => 'ulpb_formBuilderEmail_ajax', 'ajax' => true ),
196
  'WpMembers' => array( 'hook' => 'wpmem_pre_register_data', 'ajax' => false ),
197
+ 'Rafflepress' => array( 'hook' => 'rafflepress_lite_giveaway_api', 'ajax' => true ),
198
  );
199
  new \Cleantalk\Antispam\Integrations( $apbct_active_integrations );
200
 
659
  )
660
  ) );
661
 
662
+ if( $apbct->settings['sfw__anti_crawler'] && $apbct->stats['sfw']['entries'] ){
663
  $firewall->load_fw_module( new \Cleantalk\ApbctWP\Firewall\AntiCrawler(
664
  APBCT_TBL_FIREWALL_LOG,
665
  APBCT_TBL_AC_LOG,
688
 
689
  /**
690
  * On activation, set a time, frequency and name of an action hook to be scheduled.
691
+ * @throws Exception
692
  */
693
  function apbct_activation( $network = false ) {
694
 
695
  global $wpdb;
696
+
697
+ $sqls = Schema::getSchema();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
698
 
699
  if($network && !defined('CLEANTALK_ACCESS_KEY')){
700
  $initial_blog = get_current_blog_id();
753
  apbct_log($errors);
754
  }
755
 
756
+ /**
757
+ * On activation, set a time, frequency and name of an action hook to be scheduled for sub-sites.
758
+ * @throws Exception
759
+ */
760
  function apbct_activation__new_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
761
  if (apbct_is_plugin_active_for_network('cleantalk-spam-protect/cleantalk.php')){
762
 
763
  $settings = get_option('cleantalk_settings');
764
 
765
  switch_to_blog($blog_id);
766
+
767
+ $sqls = Schema::getSchema();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
768
 
769
  // Cron tasks
770
  Cron::addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // Checks account status
850
  delete_option('cleantalk_stats');
851
  delete_option('cleantalk_timelabel_reg');
852
  delete_option('cleantalk_debug');
853
+ delete_option('cleantalk_plugin_request_ids');
854
+ delete_option('cleantalk_fw_stats');
855
  }
856
 
857
  /**
870
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_sessions`;'); // Deleting session table
871
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_spamscan_logs`;'); // Deleting user/comments scan result table
872
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_ua_bl`;'); // Deleting AC UA black lists
873
+ $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_sfw_temp`;'); // Deleting temporary SFW data
874
  }
875
 
876
  function apbct_deactivation__delete_blog_tables() {
881
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_sessions`;'); // Deleting session table
882
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_spamscan_logs`;'); // Deleting user/comments scan result table
883
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_ua_bl`;'); // Deleting AC UA black lists
884
+ $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_sfw_temp`;'); // Deleting temporary SFW data
885
  }
886
 
887
  function apbct_deactivation__delete_meta(){
954
 
955
  function ct_sfw_update( $api_key = '', $immediate = false ){
956
 
957
+ global $apbct, $wpdb;
958
 
959
  // Prevent start another update at a time
960
  if(
972
  return array( 'error' => 'FIREWALL_IS_UPDATING' );
973
  }
974
 
 
 
 
 
 
 
 
975
  $api_key = !empty($apbct->api_key) ? $apbct->api_key : $api_key;
976
 
977
  if( $apbct->settings['spam_firewall'] == 1 && ( ! empty($api_key) || $apbct->data['moderate_ip'] ) ) {
978
 
979
+ // Set new update ID
980
+ if( ! $apbct->fw_stats['firewall_updating_id'] || time() - $apbct->fw_stats['firewall_updating_last_start'] > 300 ){
981
+ $apbct->fw_stats['firewall_updating_id'] = md5( rand( 0, 100000 ) );
982
+ $apbct->fw_stats['firewall_updating_last_start'] = time();
983
+ $apbct->save( 'fw_stats' );
984
+ }
985
+
986
  if( apbct_is_remote_call() ) {
987
  // Remote call is in process, do updating
988
 
992
 
993
  if( ! $file_urls ){
994
 
 
 
 
 
995
  // @todo We have to handle errors here
996
  SFW::create_temp_tables( DB::getInstance() );
997
 
1021
 
1022
  $current_url++;
1023
 
 
 
 
1024
  $apbct->fw_stats['firewall_update_percent'] = round( ( ( (int) $current_url + 1 ) / (int) $url_count ), 2) * 100;
1025
  $apbct->save('fw_stats');
1026
 
1054
  $apbct->save( 'fw_stats' );
1055
 
1056
  //Files array is empty update sfw time
1057
+ $apbct->stats['sfw']['entries'] = $wpdb->get_var('SELECT COUNT(*) FROM ' . APBCT_TBL_FIREWALL_DATA );
1058
  $apbct->stats['sfw']['last_update_time'] = time();
1059
  $apbct->save('stats');
1060
 
inc/cleantalk-ajax.php CHANGED
@@ -322,6 +322,8 @@ function ct_ajax_hook($message_obj = false, $additional = false)
322
  'ajaxlogin', //Skip ajax login redirect
323
  'heartbeat', //Gravity multipage
324
  'erforms_field_change_command', //ERForms internal request
 
 
325
  );
326
 
327
  // Skip test if
322
  'ajaxlogin', //Skip ajax login redirect
323
  'heartbeat', //Gravity multipage
324
  'erforms_field_change_command', //ERForms internal request
325
+ 'wl_out_of_stock_notify', // Sumo Waitlist
326
+ 'rac_preadd_guest', //Rac internal request
327
  );
328
 
329
  // Skip test if
inc/cleantalk-public.php CHANGED
@@ -1257,7 +1257,7 @@ function ct_preprocess_comment($comment) {
1257
 
1258
  $comments_check_number = defined('CLEANTALK_CHECK_COMMENTS_NUMBER') ? CLEANTALK_CHECK_COMMENTS_NUMBER : 3;
1259
 
1260
- if($apbct->settings['check_comments_number']){
1261
  $args = array(
1262
  'author_email' => $comment['comment_author_email'],
1263
  'status' => 'approve',
1257
 
1258
  $comments_check_number = defined('CLEANTALK_CHECK_COMMENTS_NUMBER') ? CLEANTALK_CHECK_COMMENTS_NUMBER : 3;
1259
 
1260
+ if($apbct->settings['check_comments_number'] && $comment['comment_author_email']){
1261
  $args = array(
1262
  'author_email' => $comment['comment_author_email'],
1263
  'status' => 'approve',
inc/cleantalk-settings.php CHANGED
@@ -34,7 +34,14 @@ function apbct_settings_add_page() {
34
 
35
  function apbct_settings__set_fileds( $fields ){
36
  global $apbct;
37
-
 
 
 
 
 
 
 
38
  $fields = array(
39
 
40
  'main' => array(
@@ -107,7 +114,7 @@ function apbct_settings__set_fileds( $fields ){
107
  ),
108
  'sfw__anti_crawler' => array(
109
  'type' => 'checkbox',
110
- 'title' => __('Anti-Crawler', 'cleantalk-spam-protect'),
111
  'class' => 'apbct_settings-field_wrapper--sub',
112
  'parent' => 'spam_firewall',
113
  'childrens' => array('sfw__anti_crawler_ua'),
@@ -1082,11 +1089,10 @@ function apbct_settings__field__statistics() {
1082
  echo '<br>';
1083
 
1084
  // SFW last update
1085
- $sfw_netwoks_amount = $wpdb->get_results("SELECT count(*) AS cnt FROM `".$wpdb->prefix."cleantalk_sfw`", ARRAY_A);
1086
  printf(
1087
  __('SpamFireWall was updated %s. Now contains %s entries.', 'cleantalk-spam-protect'),
1088
  $apbct->stats['sfw']['last_update_time'] ? date('M d Y H:i:s', $apbct->stats['sfw']['last_update_time']) : __('unknown', 'cleantalk-spam-protect'),
1089
- isset($sfw_netwoks_amount[0]['cnt']) ? $sfw_netwoks_amount[0]['cnt'] : __('unknown', 'cleantalk-spam-protect')
1090
  );
1091
  echo $apbct->fw_stats['firewall_updating_id'] ? ' ' . __('Under updating now:', 'cleantalk-spam-protect') . ' ' . $apbct->fw_stats['firewall_update_percent'] . '%' : '';
1092
  echo '<br>';
@@ -1398,7 +1404,7 @@ function apbct_settings__validate($settings) {
1398
 
1399
  //Sanitizing sfw__anti_flood__view_limit setting
1400
  $settings['sfw__anti_flood__view_limit'] = floor( intval( $settings['sfw__anti_flood__view_limit'] ) );
1401
- $settings['sfw__anti_flood__view_limit'] = ( $settings['sfw__anti_flood__view_limit'] == 0 ? 10 : $settings['sfw__anti_flood__view_limit'] ); // Default if 0 passed
1402
  $settings['sfw__anti_flood__view_limit'] = ( $settings['sfw__anti_flood__view_limit'] < 5 ? 5 : $settings['sfw__anti_flood__view_limit'] ); //
1403
 
1404
  // Auto getting key
34
 
35
  function apbct_settings__set_fileds( $fields ){
36
  global $apbct;
37
+
38
+ $additional_ac_title = '';
39
+ if( $apbct->api_key && is_null( $apbct->fw_stats['firewall_updating_id'] ) ) {
40
+ if( ! $apbct->stats['sfw']['entries'] ) {
41
+ $additional_ac_title = ' <span style="color:red">' . esc_html__( 'The functionality was disabled because SpamFireWall database is empty. Please, do the synchronization or', 'cleantalk-spam-protect' ) . ' ' . '<a href="https://cleantalk.org/my/support/open" target="_blank" style="color:red">'. esc_html__( 'contact to our support.', 'cleantalk-spam-protect' ) .'</a></span>';
42
+ }
43
+ }
44
+
45
  $fields = array(
46
 
47
  'main' => array(
114
  ),
115
  'sfw__anti_crawler' => array(
116
  'type' => 'checkbox',
117
+ 'title' => __('Anti-Crawler', 'cleantalk-spam-protect') . $additional_ac_title,
118
  'class' => 'apbct_settings-field_wrapper--sub',
119
  'parent' => 'spam_firewall',
120
  'childrens' => array('sfw__anti_crawler_ua'),
1089
  echo '<br>';
1090
 
1091
  // SFW last update
 
1092
  printf(
1093
  __('SpamFireWall was updated %s. Now contains %s entries.', 'cleantalk-spam-protect'),
1094
  $apbct->stats['sfw']['last_update_time'] ? date('M d Y H:i:s', $apbct->stats['sfw']['last_update_time']) : __('unknown', 'cleantalk-spam-protect'),
1095
+ $apbct->stats['sfw']['entries']
1096
  );
1097
  echo $apbct->fw_stats['firewall_updating_id'] ? ' ' . __('Under updating now:', 'cleantalk-spam-protect') . ' ' . $apbct->fw_stats['firewall_update_percent'] . '%' : '';
1098
  echo '<br>';
1404
 
1405
  //Sanitizing sfw__anti_flood__view_limit setting
1406
  $settings['sfw__anti_flood__view_limit'] = floor( intval( $settings['sfw__anti_flood__view_limit'] ) );
1407
+ $settings['sfw__anti_flood__view_limit'] = ( $settings['sfw__anti_flood__view_limit'] == 0 ? 20 : $settings['sfw__anti_flood__view_limit'] ); // Default if 0 passed
1408
  $settings['sfw__anti_flood__view_limit'] = ( $settings['sfw__anti_flood__view_limit'] < 5 ? 5 : $settings['sfw__anti_flood__view_limit'] ); //
1409
 
1410
  // Auto getting key
inc/cleantalk-updater.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
 
3
  use Cleantalk\ApbctWP\Cron;
 
4
 
5
  function apbct_run_update_actions($current_version, $new_version){
6
 
@@ -714,3 +715,19 @@ function apbct_update_to_5_151_1 () {
714
  $apbct->fw_stats['firewall_updating_last_start'] = $apbct->data['firewall_updating_last_start'];
715
  $apbct->save('fw_stats');
716
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
  use Cleantalk\ApbctWP\Cron;
4
+ use Cleantalk\Common\Schema;
5
 
6
  function apbct_run_update_actions($current_version, $new_version){
7
 
715
  $apbct->fw_stats['firewall_updating_last_start'] = $apbct->data['firewall_updating_last_start'];
716
  $apbct->save('fw_stats');
717
  }
718
+
719
+ function apbct_update_to_5_151_3 ()
720
+ {
721
+ global $wpdb, $apbct;
722
+ $sql = 'SHOW TABLES LIKE "%scleantalk_sfw";';
723
+ $sql = sprintf( $sql, $wpdb->prefix ); // Adding current blog prefix
724
+ $result = $wpdb->get_var( $sql );
725
+ if( ! $result ){
726
+ apbct_activation__create_tables( Schema::getSchema('sfw'), $apbct->db_prefix );
727
+ }
728
+ $apbct->fw_stats['firewall_updating_last_start'] = 0;
729
+ $apbct->save('fw_stats');
730
+ $apbct->stats['sfw']['entries'] = 0;
731
+ $apbct->save('stats');
732
+ ct_sfw_update();
733
+ }
lib/Cleantalk/Antispam/Integrations/Rafflepress.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ namespace Cleantalk\Antispam\Integrations;
5
+
6
+
7
+ class Rafflepress extends IntegrationBase
8
+ {
9
+
10
+ function getDataForChecking( $argument )
11
+ {
12
+ return ct_get_fields_any( $_POST );
13
+ }
14
+
15
+ function doBlock( $message )
16
+ {
17
+ wp_send_json(
18
+ array(
19
+ 'status' => false,
20
+ 'errors' => $message,
21
+ 'contestant' => array(),
22
+ )
23
+ );
24
+ }
25
+ }
lib/Cleantalk/ApbctWP/Firewall/AntiFlood.php CHANGED
@@ -13,7 +13,7 @@ class AntiFlood extends \Cleantalk\Common\Firewall\FirewallModule{
13
  private $db__table__ac_logs;
14
 
15
  private $api_key = '';
16
- private $view_limit = 10;
17
  private $apbct = array();
18
  private $store_interval = 60;
19
  private $block_period = 30;
13
  private $db__table__ac_logs;
14
 
15
  private $api_key = '';
16
+ private $view_limit = 20;
17
  private $apbct = array();
18
  private $store_interval = 60;
19
  private $block_period = 30;
lib/Cleantalk/ApbctWP/Firewall/SFW.php CHANGED
@@ -3,6 +3,7 @@
3
  namespace Cleantalk\ApbctWP\Firewall;
4
 
5
  use Cleantalk\ApbctWP\Helper;
 
6
  use Cleantalk\Variables\Cookie;
7
  use Cleantalk\Variables\Get;
8
  use Cleantalk\Variables\Server;
@@ -126,14 +127,16 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
126
  network, mask, status
127
  FROM " . $this->db__table__data . "
128
  WHERE network IN (". implode( ',', $needles ) .")
129
- AND network = " . $current_ip_v4 . " & mask");
130
 
131
  if( ! empty( $db_results ) ){
132
 
133
  foreach( $db_results as $db_result ){
134
 
135
- if( $db_result['status'] == 1 )
136
- $results[] = array('ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_SFW__BY_WHITELIST',);
 
 
137
  else
138
  $results[] = array('ip' => $current_ip, 'is_personal' => false, 'status' => 'DENY_SFW',);
139
 
@@ -532,6 +535,13 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
532
  * @param \wpdb $db database handler
533
  */
534
  public static function create_temp_tables( $db ){
 
 
 
 
 
 
 
535
  $db->execute( 'CREATE TABLE IF NOT EXISTS `' . APBCT_TBL_FIREWALL_DATA . '_temp` LIKE `' . APBCT_TBL_FIREWALL_DATA . '`;' );
536
  $db->execute( 'TRUNCATE TABLE `' . APBCT_TBL_FIREWALL_DATA . '_temp`;' );
537
  }
3
  namespace Cleantalk\ApbctWP\Firewall;
4
 
5
  use Cleantalk\ApbctWP\Helper;
6
+ use Cleantalk\Common\Schema;
7
  use Cleantalk\Variables\Cookie;
8
  use Cleantalk\Variables\Get;
9
  use Cleantalk\Variables\Server;
127
  network, mask, status
128
  FROM " . $this->db__table__data . "
129
  WHERE network IN (". implode( ',', $needles ) .")
130
+ AND network = " . $current_ip_v4 . " & mask ORDER BY status DESC");
131
 
132
  if( ! empty( $db_results ) ){
133
 
134
  foreach( $db_results as $db_result ){
135
 
136
+ if( $db_result['status'] == 1 ) {
137
+ $results[] = array('ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_SFW__BY_WHITELIST',);
138
+ break;
139
+ }
140
  else
141
  $results[] = array('ip' => $current_ip, 'is_personal' => false, 'status' => 'DENY_SFW',);
142
 
535
  * @param \wpdb $db database handler
536
  */
537
  public static function create_temp_tables( $db ){
538
+ global $wpdb, $apbct;
539
+ $sql = 'SHOW TABLES LIKE "%scleantalk_sfw";';
540
+ $sql = sprintf( $sql, $wpdb->prefix ); // Adding current blog prefix
541
+ $result = $wpdb->get_var( $sql );
542
+ if( ! $result ){
543
+ apbct_activation__create_tables( Schema::getSchema('sfw'), $apbct->db_prefix );
544
+ }
545
  $db->execute( 'CREATE TABLE IF NOT EXISTS `' . APBCT_TBL_FIREWALL_DATA . '_temp` LIKE `' . APBCT_TBL_FIREWALL_DATA . '`;' );
546
  $db->execute( 'TRUNCATE TABLE `' . APBCT_TBL_FIREWALL_DATA . '_temp`;' );
547
  }
lib/Cleantalk/ApbctWP/State.php CHANGED
@@ -59,7 +59,7 @@ class State
59
 
60
  'spam_firewall' => 1,
61
  'sfw__anti_flood' => 1,
62
- 'sfw__anti_flood__view_limit' => 10,
63
  'sfw__anti_crawler' => 1,
64
  'sfw__anti_crawler_ua' => 1,
65
  'apikey' => '',
59
 
60
  'spam_firewall' => 1,
61
  'sfw__anti_flood' => 1,
62
+ 'sfw__anti_flood__view_limit' => 20,
63
  'sfw__anti_crawler' => 1,
64
  'sfw__anti_crawler_ua' => 1,
65
  'apikey' => '',
lib/Cleantalk/Common/Schema.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Cleantalk\Common;
4
+
5
+ class Schema
6
+ {
7
+ /*
8
+ * Array of schemas
9
+ */
10
+ private static $schemas = array(
11
+ 'sfw' => 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw` (
12
+ `id` INT(11) NOT NULL AUTO_INCREMENT,
13
+ `network` int(11) unsigned NOT NULL,
14
+ `mask` int(11) unsigned NOT NULL,
15
+ `status` TINYINT(1) NOT NULL DEFAULT 0,
16
+ PRIMARY KEY (`id`),
17
+ INDEX ( `network` , `mask` )
18
+ );',
19
+ 'ua_bl' => 'CREATE TABLE IF NOT EXISTS `%scleantalk_ua_bl` (
20
+ `id` INT(11) NOT NULL,
21
+ `ua_template` VARCHAR(255) NULL DEFAULT NULL,
22
+ `ua_status` TINYINT(1) NULL DEFAULT NULL,
23
+ PRIMARY KEY ( `id` ),
24
+ INDEX ( `ua_template` )
25
+ ) DEFAULT CHARSET=utf8;', // Don't remove the default charset!
26
+ 'sfw_logs' => 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw_logs` (
27
+ `id` VARCHAR(40) NOT NULL,
28
+ `ip` VARCHAR(15) NOT NULL,
29
+ `status` ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW__BY_WHITELIST\',\'PASS_SFW__BY_COOKIE\',\'DENY_ANTICRAWLER\',\'PASS_ANTICRAWLER\',\'DENY_ANTICRAWLER_UA\',\'PASS_ANTICRAWLER_UA\',\'DENY_ANTIFLOOD\',\'PASS_ANTIFLOOD\') NULL DEFAULT NULL,
30
+ `all_entries` INT NOT NULL,
31
+ `blocked_entries` INT NOT NULL,
32
+ `entries_timestamp` INT NOT NULL,
33
+ `ua_id` INT(11) NULL DEFAULT NULL,
34
+ `ua_name` VARCHAR(1024) NOT NULL,
35
+ PRIMARY KEY (`id`));',
36
+ 'ac_logs' => 'CREATE TABLE IF NOT EXISTS `%scleantalk_ac_log` (
37
+ `id` VARCHAR(40) NOT NULL,
38
+ `ip` VARCHAR(40) NOT NULL,
39
+ `ua` VARCHAR(40) NOT NULL,
40
+ `entries` INT DEFAULT 0,
41
+ `interval_start` INT NOT NULL,
42
+ PRIMARY KEY (`id`));',
43
+ 'sessions' => 'CREATE TABLE IF NOT EXISTS `%scleantalk_sessions` (
44
+ `id` VARCHAR(64) NOT NULL,
45
+ `name` VARCHAR(40) NOT NULL,
46
+ `value` TEXT NULL DEFAULT NULL,
47
+ `last_update` DATETIME NULL DEFAULT NULL,
48
+ PRIMARY KEY (`name`(40), `id`(64)));',
49
+ 'spamscan_logs' => 'CREATE TABLE IF NOT EXISTS `%scleantalk_spamscan_logs` (
50
+ `id` int(11) NOT NULL AUTO_INCREMENT,
51
+ `scan_type` varchar(11) NOT NULL,
52
+ `start_time` datetime NOT NULL,
53
+ `finish_time` datetime NOT NULL,
54
+ `count_to_scan` int(11) DEFAULT NULL,
55
+ `found_spam` int(11) DEFAULT NULL,
56
+ `found_bad` int(11) DEFAULT NULL,
57
+ PRIMARY KEY (`id`));',
58
+ );
59
+
60
+ /**
61
+ * @param null|string $table Name of called table
62
+ * @return array Array of schemas
63
+ * @throws \Exception Throws if calling un-existed schema
64
+ */
65
+ public static function getSchema($table = null )
66
+ {
67
+ if( is_null( $table ) ) {
68
+ return self::$schemas;
69
+ }
70
+
71
+ if( array_key_exists( $table, self::$schemas ) ) {
72
+ return array( self::$schemas[$table] );
73
+ }
74
+
75
+ throw new \Exception( 'Called table scheme not exist.' );
76
+ }
77
+
78
+ }
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.6
6
  Requires PHP: 5.4
7
- Stable tag: 5.151.2
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
@@ -580,6 +580,22 @@ If your website has forms that send data to external sources, you can enable opt
580
 
581
  == Changelog ==
582
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
583
  = 5.151.2 Dec 30 2020 =
584
  * Fix: Prevent skip checking UltimateMember register.
585
  * Upd: SFW die pages updated - networks count added.
4
  Requires at least: 3.0
5
  Tested up to: 5.6
6
  Requires PHP: 5.4
7
+ Stable tag: 5.151.3
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
580
 
581
  == Changelog ==
582
 
583
+ = 5.151.3 Jan 15 2020 =
584
+ * Fix: Prevent logging false blocking for whitelisted networks.
585
+ * Integration: Rafflepress integration implemented.
586
+ * Fix: AF limit increased to 20 by default.
587
+ * Fix: skip Sumo waitlist internal request.
588
+ * Fix: skip raq internal request.
589
+ * Fix: check comments number if comment email exists.
590
+ * New: Schema class added.
591
+ * Fix: SFW - Creation sfw table if not exist.
592
+ * Fix: Updater - Creation sfw table if not exist.
593
+ * New: Schema class used.
594
+ * New: AC disabled if networks count is 0.
595
+ * Fix: SFW updating id getting fixed.
596
+ * Fix: SFW networks counter fixed.
597
+ * Fix: Deleting options fixed.
598
+
599
  = 5.151.2 Dec 30 2020 =
600
  * Fix: Prevent skip checking UltimateMember register.
601
  * Upd: SFW die pages updated - networks count added.