Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.142.2

Version Description

Jul 29 2020 = * Fix: Issue with SpamFireWall logs.

Download this release

Release Info

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

Code changes from version 5.142.1 to 5.142.2

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.1
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
@@ -644,6 +644,7 @@ function apbct_sfw__check()
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
  'view_limit' => $apbct->settings['sfw__anti_flood__view_limit'],
648
  'apbct' => $apbct,
649
  )
@@ -673,7 +674,7 @@ function apbct_activation( $network = false ) {
673
  $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw_logs` (
674
  `id` VARCHAR(40) NOT NULL,
675
  `ip` VARCHAR(15) NOT NULL,
676
- `status` ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW_BY_WHITELIST\',\'PASS_SFW_BY_COOKIE\',\'DENY_ANTICRAWLER\',\'DENY_ANTIFLOOD\') NULL DEFAULT NULL,
677
  `all_entries` INT NOT NULL,
678
  `blocked_entries` INT NOT NULL,
679
  `entries_timestamp` INT NOT NULL,
@@ -776,7 +777,7 @@ function apbct_activation__new_blog($blog_id, $user_id, $domain, $path, $site_id
776
  $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw_logs` (
777
  `id` VARCHAR(40) NOT NULL,
778
  `ip` VARCHAR(15) NOT NULL,
779
- `status` ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW_BY_WHITELIST\',\'PASS_SFW_BY_COOKIE\',\'DENY_ANTICRAWLER\',\'DENY_ANTIFLOOD\') NULL DEFAULT NULL,
780
  `all_entries` INT NOT NULL,
781
  `blocked_entries` INT NOT NULL,
782
  `entries_timestamp` INT NOT NULL,
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
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'],
649
  'apbct' => $apbct,
650
  )
674
  $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw_logs` (
675
  `id` VARCHAR(40) NOT NULL,
676
  `ip` VARCHAR(15) NOT NULL,
677
+ `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,
678
  `all_entries` INT NOT NULL,
679
  `blocked_entries` INT NOT NULL,
680
  `entries_timestamp` INT NOT NULL,
777
  $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw_logs` (
778
  `id` VARCHAR(40) NOT NULL,
779
  `ip` VARCHAR(15) NOT NULL,
780
+ `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,
781
  `all_entries` INT NOT NULL,
782
  `blocked_entries` INT NOT NULL,
783
  `entries_timestamp` INT NOT NULL,
inc/cleantalk-updater.php CHANGED
@@ -547,4 +547,15 @@ function apbct_update_to_5_142_1() {
547
 
548
  apbct_activation__create_tables( $sqls );
549
 
 
 
 
 
 
 
 
 
 
 
 
550
  }
547
 
548
  apbct_activation__create_tables( $sqls );
549
 
550
+ }
551
+
552
+ function apbct_update_to_5_142_2() {
553
+
554
+ $sqls[] = 'DELETE FROM `%scleantalk_sfw_logs` WHERE 1=1';
555
+
556
+ $sqls[] = 'ALTER TABLE `%scleantalk_sfw_logs`
557
+ CHANGE `status` `status` ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW__BY_WHITELIST\',\'PASS_SFW__BY_COOKIE\',\'DENY_ANTICRAWLER\',\'PASS_ANTICRAWLER\',\'DENY_ANTIFLOOD\',\'PASS_ANTIFLOOD\') NOT NULL AFTER `ip`;';
558
+
559
+ apbct_activation__create_tables( $sqls );
560
+
561
  }
lib/Cleantalk/ApbctWP/Firewall/AntiCrawler.php CHANGED
@@ -3,6 +3,7 @@
3
  namespace Cleantalk\ApbctWP\Firewall;
4
 
5
 
 
6
  use Cleantalk\Variables\Cookie;
7
  use Cleantalk\Variables\Server;
8
 
@@ -13,6 +14,7 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule{
13
  private $db__table__ac_logs;
14
  private $api_key = '';
15
  private $apbct = false;
 
16
 
17
  /**
18
  * AntiBot constructor.
@@ -53,13 +55,32 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule{
53
  );
54
 
55
  if( ! empty( $result ) && isset( $result['ip'] ) ){
 
56
  if( Cookie::get('apbct_antibot') !== md5( $this->api_key . $current_ip ) ){
 
57
  $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'DENY_ANTICRAWLER', );
 
 
 
 
 
 
 
 
 
 
 
 
58
  }
 
59
  }else{
 
 
 
60
  add_action( 'wp_head', array( '\Cleantalk\ApbctWP\Firewall\AntiCrawler', 'set_cookie' ) );
61
  global $apbct_anticrawler_ip;
62
  $apbct_anticrawler_ip = $current_ip;
 
63
  }
64
  }
65
 
@@ -67,6 +88,30 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule{
67
 
68
  }
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  public static function set_cookie(){
71
  global $apbct, $apbct_anticrawler_ip;
72
  echo '<script>document.cookie = "apbct_antibot=' . md5( $apbct->api_key . $apbct_anticrawler_ip ) . '; path=/; expires=0; samesite=lax";</script>';
@@ -81,29 +126,25 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule{
81
  */
82
  public function update_log( $ip, $status ) {
83
 
84
- $blocked = ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' );
 
85
 
86
- if( $blocked ){
87
-
88
- $id = md5( $ip . $status );
89
- $time = time();
90
-
91
- $query = "INSERT INTO " . $this->db__table__logs . "
92
- SET
93
- id = '$id',
94
- ip = '$ip',
95
- status = '$status',
96
- all_entries = 1,
97
- blocked_entries = 1,
98
- entries_timestamp = '" . intval( $time ) . "'
99
- ON DUPLICATE KEY
100
- UPDATE
101
- all_entries = all_entries + 1,
102
- blocked_entries = blocked_entries" . strval( $blocked ) . ",
103
- entries_timestamp = '" . intval( $time ) . "'";
104
-
105
- $this->db->execute( $query );
106
- }
107
  }
108
 
109
  public function _die( $result ){
@@ -123,6 +164,7 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule{
123
  '{SERVICE_ID}' => $this->apbct->data['service_id'],
124
  '{HOST}' => Server::get( 'HTTP_HOST' ),
125
  '{COOKIE_ANTICRAWLER}' => md5( $this->api_key . $result['ip'] ),
 
126
  '{GENERATED}' => '<p>The page was generated at&nbsp;' . date( 'D, d M Y H:i:s' ) . "</p>",
127
  );
128
 
3
  namespace Cleantalk\ApbctWP\Firewall;
4
 
5
 
6
+ use Cleantalk\Common\Helper as Helper;
7
  use Cleantalk\Variables\Cookie;
8
  use Cleantalk\Variables\Server;
9
 
14
  private $db__table__ac_logs;
15
  private $api_key = '';
16
  private $apbct = false;
17
+ private $store_interval = 60;
18
 
19
  /**
20
  * AntiBot constructor.
55
  );
56
 
57
  if( ! empty( $result ) && isset( $result['ip'] ) ){
58
+
59
  if( Cookie::get('apbct_antibot') !== md5( $this->api_key . $current_ip ) ){
60
+
61
  $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'DENY_ANTICRAWLER', );
62
+
63
+ }else{
64
+
65
+ if( Cookie::get( 'apbct_anticrawler_passed' ) === '1' ){
66
+
67
+ if( ! headers_sent() )
68
+ \Cleantalk\Common\Helper::apbct_cookie__set( 'apbct_anticrawler_passed', '0', time() - 86400, '/', null, false, true, 'Lax' );
69
+
70
+ $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_ANTICRAWLER', );
71
+
72
+ return $results;
73
+ }
74
  }
75
+
76
  }else{
77
+
78
+ $this->update_ac_log();
79
+
80
  add_action( 'wp_head', array( '\Cleantalk\ApbctWP\Firewall\AntiCrawler', 'set_cookie' ) );
81
  global $apbct_anticrawler_ip;
82
  $apbct_anticrawler_ip = $current_ip;
83
+
84
  }
85
  }
86
 
88
 
89
  }
90
 
91
+ private function update_ac_log() {
92
+
93
+ $interval_time = Helper::time__get_interval_start( $this->store_interval );
94
+
95
+ // @todo Rename ip column to sign. Use IP + UserAgent for it.
96
+
97
+ foreach( $this->ip_array as $ip_origin => $current_ip ){
98
+ $id = md5( $current_ip . $interval_time );
99
+ $this->db->execute(
100
+ "INSERT INTO " . $this->db__table__ac_logs . " SET
101
+ id = '$id',
102
+ ip = '$current_ip',
103
+ entries = 1,
104
+ interval_start = $interval_time
105
+ ON DUPLICATE KEY UPDATE
106
+ ip = ip,
107
+ entries = entries + 1,
108
+ interval_start = $interval_time;"
109
+ );
110
+ }
111
+
112
+ }
113
+
114
+
115
  public static function set_cookie(){
116
  global $apbct, $apbct_anticrawler_ip;
117
  echo '<script>document.cookie = "apbct_antibot=' . md5( $apbct->api_key . $apbct_anticrawler_ip ) . '; path=/; expires=0; samesite=lax";</script>';
126
  */
127
  public function update_log( $ip, $status ) {
128
 
129
+ $id = md5( $ip );
130
+ $time = time();
131
 
132
+ $query = "INSERT INTO " . $this->db__table__logs . "
133
+ SET
134
+ id = '$id',
135
+ ip = '$ip',
136
+ status = '$status',
137
+ all_entries = 1,
138
+ blocked_entries = 1,
139
+ entries_timestamp = '" . intval( $time ) . "'
140
+ ON DUPLICATE KEY
141
+ UPDATE
142
+ status = '$status',
143
+ all_entries = all_entries + 1,
144
+ blocked_entries = blocked_entries" . ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' ) . ",
145
+ entries_timestamp = '" . intval( $time ) . "'";
146
+
147
+ $this->db->execute( $query );
 
 
 
 
 
148
  }
149
 
150
  public function _die( $result ){
164
  '{SERVICE_ID}' => $this->apbct->data['service_id'],
165
  '{HOST}' => Server::get( 'HTTP_HOST' ),
166
  '{COOKIE_ANTICRAWLER}' => md5( $this->api_key . $result['ip'] ),
167
+ '{COOKIE_ANTICRAWLER_PASSED}' => '1',
168
  '{GENERATED}' => '<p>The page was generated at&nbsp;' . date( 'D, d M Y H:i:s' ) . "</p>",
169
  );
170
 
lib/Cleantalk/ApbctWP/Firewall/AntiFlood.php CHANGED
@@ -3,6 +3,7 @@
3
  namespace Cleantalk\ApbctWP\Firewall;
4
 
5
  use Cleantalk\Common\Helper as Helper;
 
6
  use Cleantalk\Variables\Server;
7
 
8
  class AntiFlood extends \Cleantalk\Common\Firewall\FirewallModule{
@@ -11,11 +12,12 @@ class AntiFlood extends \Cleantalk\Common\Firewall\FirewallModule{
11
 
12
  private $db__table__ac_logs;
13
 
 
14
  private $view_limit = 10;
15
  private $apbct = array();
16
- private $store_interval = 30;
17
  private $block_period = 30;
18
- private $chance_to_clean = 100;
19
 
20
  /**
21
  * AntiCrawler constructor.
@@ -48,6 +50,19 @@ class AntiFlood extends \Cleantalk\Common\Firewall\FirewallModule{
48
 
49
  foreach( $this->ip_array as $ip_origin => $current_ip ){
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  // @todo Rename ip column to sign. Use IP + UserAgent for it.
52
 
53
  $result = $this->db->fetch_all(
@@ -99,7 +114,7 @@ class AntiFlood extends \Cleantalk\Common\Firewall\FirewallModule{
99
  private function clear_table() {
100
 
101
  if( rand( 0, 1000 ) < $this->chance_to_clean ){
102
- $interval_start = \Cleantalk\ApbctWP\Helper::time__get_interval_start( $this->block_period );
103
  $this->db->execute(
104
  'DELETE
105
  FROM ' . $this->db__table__ac_logs . '
@@ -118,8 +133,7 @@ class AntiFlood extends \Cleantalk\Common\Firewall\FirewallModule{
118
  */
119
  public function update_log( $ip, $status ) {
120
 
121
- $id = md5($ip.$status);
122
- $blocked = ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' );
123
  $time = time();
124
 
125
  $query = "INSERT INTO " . $this->db__table__logs . "
@@ -132,8 +146,9 @@ class AntiFlood extends \Cleantalk\Common\Firewall\FirewallModule{
132
  entries_timestamp = '" . intval( $time ) . "'
133
  ON DUPLICATE KEY
134
  UPDATE
 
135
  all_entries = all_entries + 1,
136
- blocked_entries = blocked_entries" . strval( $blocked ) . ",
137
  entries_timestamp = '" . intval( $time ) . "'";
138
 
139
  $this->db->execute( $query );
@@ -159,6 +174,7 @@ class AntiFlood extends \Cleantalk\Common\Firewall\FirewallModule{
159
  '{SERVICE_ID}' => $this->apbct->data['service_id'],
160
  '{HOST}' => Server::get( 'HTTP_HOST' ),
161
  '{GENERATED}' => '<p>The page was generated at&nbsp;' . date( 'D, d M Y H:i:s' ) . "</p>",
 
162
  );
163
 
164
  foreach( $replaces as $place_holder => $replace ){
3
  namespace Cleantalk\ApbctWP\Firewall;
4
 
5
  use Cleantalk\Common\Helper as Helper;
6
+ use Cleantalk\Variables\Cookie;
7
  use Cleantalk\Variables\Server;
8
 
9
  class AntiFlood extends \Cleantalk\Common\Firewall\FirewallModule{
12
 
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;
20
+ private $chance_to_clean = 200;
21
 
22
  /**
23
  * AntiCrawler constructor.
50
 
51
  foreach( $this->ip_array as $ip_origin => $current_ip ){
52
 
53
+ // Passed
54
+ if( Cookie::get( 'apbct_antiflood_passed' ) === md5( $current_ip . $this->api_key ) ){
55
+
56
+ if( ! headers_sent() ){
57
+ \Cleantalk\Common\Helper::apbct_cookie__set( 'apbct_antiflood_passed', '0', time() - 86400, '/', null, false, true, 'Lax' );
58
+ }
59
+
60
+ $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_ANTIFLOOD', );
61
+
62
+ return $results;
63
+ }
64
+
65
+
66
  // @todo Rename ip column to sign. Use IP + UserAgent for it.
67
 
68
  $result = $this->db->fetch_all(
114
  private function clear_table() {
115
 
116
  if( rand( 0, 1000 ) < $this->chance_to_clean ){
117
+ $interval_start = \Cleantalk\ApbctWP\Helper::time__get_interval_start( $this->store_interval );
118
  $this->db->execute(
119
  'DELETE
120
  FROM ' . $this->db__table__ac_logs . '
133
  */
134
  public function update_log( $ip, $status ) {
135
 
136
+ $id = md5( $ip );
 
137
  $time = time();
138
 
139
  $query = "INSERT INTO " . $this->db__table__logs . "
146
  entries_timestamp = '" . intval( $time ) . "'
147
  ON DUPLICATE KEY
148
  UPDATE
149
+ status = '$status',
150
  all_entries = all_entries + 1,
151
+ blocked_entries = blocked_entries" . ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' ) . ",
152
  entries_timestamp = '" . intval( $time ) . "'";
153
 
154
  $this->db->execute( $query );
174
  '{SERVICE_ID}' => $this->apbct->data['service_id'],
175
  '{HOST}' => Server::get( 'HTTP_HOST' ),
176
  '{GENERATED}' => '<p>The page was generated at&nbsp;' . date( 'D, d M Y H:i:s' ) . "</p>",
177
+ '{COOKIE_ANTIFLOOD_PASSED}' => md5( $this->api_key . $result['ip'] ),
178
  );
179
 
180
  foreach( $replaces as $place_holder => $replace ){
lib/Cleantalk/ApbctWP/Firewall/SFW.php CHANGED
@@ -80,22 +80,22 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
80
 
81
  if( Cookie::get( 'ct_sfw_pass_key' ) == md5( $current_ip . $this->api_key ) ){
82
 
83
- if( Cookie::get( 'ct_sfw_passed' ) ){
84
-
85
- if( ! headers_sent() ){
86
- \Cleantalk\Common\Helper::apbct_cookie__set( 'ct_sfw_passed', '0', time() + 86400 * 3, '/', null, false, true, 'Lax' );
87
- }
88
-
89
- $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_SFW_BY_COOKIE', );
90
-
91
- if( $this->sfw_counter ){
92
- $this->apbct->data['sfw_counter']['all'] ++;
93
- $this->apbct->saveData();
 
 
94
  }
95
 
96
- }
97
-
98
- return $results;
99
  }
100
  }
101
 
@@ -120,7 +120,7 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
120
  foreach( $db_results as $db_result ){
121
 
122
  if( $db_result['status'] == 1 )
123
- $results[] = array('ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_SFW_BY_WHITELIST',);
124
  else
125
  $results[] = array('ip' => $current_ip, 'is_personal' => false, 'status' => 'DENY_SFW',);
126
 
@@ -145,9 +145,12 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
145
  */
146
  public function update_log( $ip, $status ) {
147
 
148
- $id = md5($ip.$status);
149
- $blocked = ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' );
150
- $time = time();
 
 
 
151
 
152
  $query = "INSERT INTO " . $this->db__table__logs . "
153
  SET
@@ -159,8 +162,9 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
159
  entries_timestamp = '" . $time . "'
160
  ON DUPLICATE KEY
161
  UPDATE
 
162
  all_entries = all_entries + 1,
163
- blocked_entries = blocked_entries" . strval( $blocked ) . ",
164
  entries_timestamp = '" . intval( $time ) . "'";
165
 
166
  $this->db->execute( $query );
@@ -287,16 +291,28 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
287
  $data = array();
288
  foreach( $db->result as $key => $value ){
289
 
290
- $value['status'] = $value['status'] === 'DENY_ANTICRAWLER' ? 'BOT_PROTECTION' : $value['status'];
291
- $value['status'] = $value['status'] === 'DENY_ANTIFLOOD' ? 'FLOOD_PROTECTION' : $value['status'];
 
292
 
293
- $data[] = array(
 
 
 
 
 
 
294
  trim( $value['ip'] ),
295
  $value['all_entries'],
296
  $value['all_entries'] - $value['blocked_entries'],
297
  $value['entries_timestamp'],
298
- $value['status'],
299
  );
 
 
 
 
 
 
300
  }
301
  unset( $key, $value );
302
 
80
 
81
  if( Cookie::get( 'ct_sfw_pass_key' ) == md5( $current_ip . $this->api_key ) ){
82
 
83
+ if( Cookie::get( 'ct_sfw_passed' ) ){
84
+
85
+ if( ! headers_sent() ){
86
+ \Cleantalk\Common\Helper::apbct_cookie__set( 'ct_sfw_passed', '0', time() + 86400 * 3, '/', null, false, true, 'Lax' );
87
+ }
88
+
89
+ $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_SFW__BY_COOKIE', );
90
+
91
+ if( $this->sfw_counter ){
92
+ $this->apbct->data['sfw_counter']['all'] ++;
93
+ $this->apbct->saveData();
94
+ }
95
+
96
  }
97
 
98
+ return $results;
 
 
99
  }
100
  }
101
 
120
  foreach( $db_results as $db_result ){
121
 
122
  if( $db_result['status'] == 1 )
123
+ $results[] = array('ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_SFW__BY_WHITELIST',);
124
  else
125
  $results[] = array('ip' => $current_ip, 'is_personal' => false, 'status' => 'DENY_SFW',);
126
 
145
  */
146
  public function update_log( $ip, $status ) {
147
 
148
+ if( in_array( $status, array( 'PASS_SFW__BY_WHITELIST', 'PASS_SFW' ) ) ){
149
+ return;
150
+ }
151
+
152
+ $id = md5( $ip );
153
+ $time = time();
154
 
155
  $query = "INSERT INTO " . $this->db__table__logs . "
156
  SET
162
  entries_timestamp = '" . $time . "'
163
  ON DUPLICATE KEY
164
  UPDATE
165
+ status = '$status',
166
  all_entries = all_entries + 1,
167
+ blocked_entries = blocked_entries" . ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' ) . ",
168
  entries_timestamp = '" . intval( $time ) . "'";
169
 
170
  $this->db->execute( $query );
291
  $data = array();
292
  foreach( $db->result as $key => $value ){
293
 
294
+ // Converting statuses to API format
295
+ $value['status'] = $value['status'] === 'DENY_ANTICRAWLER' ? 'BOT_PROTECTION' : $value['status'];
296
+ $value['status'] = $value['status'] === 'PASS_ANTICRAWLER' ? 'BOT_PROTECTION' : $value['status'];
297
 
298
+ $value['status'] = $value['status'] === 'DENY_ANTIFLOOD' ? 'FLOOD_PROTECTION' : $value['status'];
299
+ $value['status'] = $value['status'] === 'PASS_ANTIFLOOD' ? 'FLOOD_PROTECTION' : $value['status'];
300
+
301
+ $value['status'] = $value['status'] === 'PASS_SFW__BY_COOKIE' ? null : $value['status'];
302
+ $value['status'] = $value['status'] === 'DENY_SFW' ? null : $value['status'];
303
+
304
+ $row = array(
305
  trim( $value['ip'] ),
306
  $value['all_entries'],
307
  $value['all_entries'] - $value['blocked_entries'],
308
  $value['entries_timestamp'],
 
309
  );
310
+
311
+ if( $value['status'] )
312
+ $row[] = $value['status'];
313
+
314
+ $data[] = $row;
315
+
316
  }
317
  unset( $key, $value );
318
 
lib/Cleantalk/ApbctWP/Firewall/die_page__AntiCrawler.html CHANGED
@@ -118,7 +118,12 @@
118
  document.getElementById('js_info').style.display = 'none';
119
  document.getElementById('js_passed').style.display = 'block';
120
  document.getElementById('curr_date').innerHTML = ct_date.toGMTString();
121
- set_spamFireWallCookie('apbct_antibot','{COOKIE_ANTICRAWLER}');
 
 
 
 
 
122
 
123
  if(location.search.search('debug=1') === -1) {
124
  setTimeout(function(){
118
  document.getElementById('js_info').style.display = 'none';
119
  document.getElementById('js_passed').style.display = 'block';
120
  document.getElementById('curr_date').innerHTML = ct_date.toGMTString();
121
+
122
+ setTimeout( function(){
123
+ console.log('do');
124
+ set_spamFireWallCookie('apbct_antibot', '{COOKIE_ANTICRAWLER}');
125
+ set_spamFireWallCookie('apbct_anticrawler_passed','{COOKIE_ANTICRAWLER_PASSED}');
126
+ }, 5000 );
127
 
128
  if(location.search.search('debug=1') === -1) {
129
  setTimeout(function(){
lib/Cleantalk/ApbctWP/Firewall/die_page__AntiFlood.html CHANGED
@@ -119,6 +119,10 @@
119
  document.getElementById('js_passed').style.display = 'block';
120
  document.getElementById('curr_date').innerHTML = ct_date.toGMTString();
121
 
 
 
 
 
122
  if(location.search.search('debug=1') === -1) {
123
  setTimeout(function(){
124
  window.location.href = window.location.origin + window.location.pathname + '?sfw=pass' + Math.round(ct_date.getTime()/1000);
119
  document.getElementById('js_passed').style.display = 'block';
120
  document.getElementById('curr_date').innerHTML = ct_date.toGMTString();
121
 
122
+ setTimeout( function(){
123
+ set_spamFireWallCookie('apbct_antiflood_passed', '{COOKIE_ANTIFLOOD_PASSED}');
124
+ }, 5000 );
125
+
126
  if(location.search.search('debug=1') === -1) {
127
  setTimeout(function(){
128
  window.location.href = window.location.origin + window.location.pathname + '?sfw=pass' + Math.round(ct_date.getTime()/1000);
lib/Cleantalk/ApbctWP/Firewall/die_page__SFW.html CHANGED
@@ -125,7 +125,7 @@
125
  document.getElementById('js_info').style.display = 'none';
126
  document.getElementById('js_passed').style.display = 'block';
127
  document.getElementById('curr_date').innerHTML = ct_date.toGMTString();
128
- set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_pass_key','{SFW_COOKIE}');
129
  set_spamFireWallCookie('{COOKIE_PREFIX}apbct_antibot','{COOKIE_ANTICRAWLER}');
130
  set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_passed','1');
131
 
125
  document.getElementById('js_info').style.display = 'none';
126
  document.getElementById('js_passed').style.display = 'block';
127
  document.getElementById('curr_date').innerHTML = ct_date.toGMTString();
128
+ set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_pass_key','{COOKIE_SFW}');
129
  set_spamFireWallCookie('{COOKIE_PREFIX}apbct_antibot','{COOKIE_ANTICRAWLER}');
130
  set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_passed','1');
131
 
lib/Cleantalk/ApbctWP/State.php CHANGED
@@ -117,15 +117,16 @@ 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
124
- 'store_urls' => 1,
125
- 'store_urls__sessions' => 1,
126
- 'comment_notify' => 1,
127
- 'comment_notify__roles' => array('administrator'),
128
- 'complete_deactivation' => 0,
 
129
  );
130
 
131
  public $def_data = array(
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
124
+ 'store_urls' => 1,
125
+ 'store_urls__sessions' => 1,
126
+ 'comment_notify' => 1,
127
+ 'comment_notify__roles' => array( 'administrator' ),
128
+ 'complete_deactivation' => 0,
129
+ 'dashboard_widget__show' => 1,
130
  );
131
 
132
  public $def_data = array(
lib/Cleantalk/Common/Firewall.php CHANGED
@@ -35,10 +35,12 @@ class Firewall
35
  // Lowest
36
  'PASS_SFW',
37
  'DENY_SFW',
38
- 'PASS_SFW_BY_COOKIE',
39
  'DENY_ANTIFLOOD',
 
40
  'DENY_ANTICRAWLER',
41
- 'PASS_SFW_BY_WHITELIST',
 
42
  // Highest
43
  );
44
 
35
  // Lowest
36
  'PASS_SFW',
37
  'DENY_SFW',
38
+ 'PASS_SFW__BY_COOKIE',
39
  'DENY_ANTIFLOOD',
40
+ 'PASS_ANTIFLOOD',
41
  'DENY_ANTICRAWLER',
42
+ 'PASS_ANTICRAWLER',
43
+ 'PASS_SFW__BY_WHITELIST',
44
  // Highest
45
  );
46
 
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.1
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
@@ -574,6 +574,9 @@ If your website has forms that send data to external sources, you can enable opt
574
 
575
  == Changelog ==
576
 
 
 
 
577
  = 5.142.1 Jul 28 2020 =
578
  * Fix: Blocking good bots.
579
 
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.
574
 
575
  == Changelog ==
576
 
577
+ = 5.142.2 Jul 29 2020 =
578
+ * Fix: Issue with SpamFireWall logs.
579
+
580
  = 5.142.1 Jul 28 2020 =
581
  * Fix: Blocking good bots.
582