Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.118.4

Version Description

May 13 2019 = * Fix: SFW cookie. Set correct domain for subdomains. * Fix: SFW update. * Fix: IP detection. * Fix: Triggering AJAX check in backend. * Fix: Zero submit time on few forms.

Download this release

Release Info

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

Code changes from version 5.118.3 to 5.118.4

cleantalk.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Anti-Spam by CleanTalk
4
  Plugin URI: http://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.118.3
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
@@ -131,8 +131,8 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
131
  if (!is_admin() && !apbct_is_ajax() && !defined('DOING_CRON') && !headers_sent()
132
  && empty($_POST['ct_checkjs_register_form']) // Buddy press registration fix
133
  ){
134
- add_action('wp','apbct_cookie', 2);
135
- add_action('wp','apbct_store__urls', 2);
136
  if (empty($_POST) && empty($_GET['action'])){
137
  apbct_cookie();
138
  apbct_store__urls();
@@ -318,9 +318,10 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
318
  add_filter('wp_die_handler', 'apbct_comment__sanitize_data__before_wp_die', 1); // Check comments after validation
319
 
320
  // Registrations
 
 
 
321
  add_action('login_enqueue_scripts', 'apbct_login__scripts');
322
- add_action('login_form_register', 'apbct_cookie');
323
- add_action('login_form_register', 'apbct_store__urls');
324
  add_action('register_form', 'ct_register_form');
325
  add_filter('registration_errors', 'ct_registration_errors', 1, 3);
326
  add_filter('registration_errors', 'ct_check_registration_erros', 999999, 3);
@@ -501,7 +502,7 @@ function apbct_sfw__check()
501
  $sfw->logs__update($sfw->blocked_ip, 'blocked');
502
  $apbct->data['sfw_counter']['blocked']++;
503
  $apbct->saveData();
504
- $sfw->sfw_die($apbct->api_key);
505
  }else{
506
  if(!empty($apbct->settings['set_cookies']) && !headers_sent())
507
  setcookie ('ct_sfw_pass_key', md5($sfw->passed_ip.$apbct->api_key), time()+86400*30, '/', parse_url(get_option('siteurl'),PHP_URL_HOST) ,false, true);
@@ -874,8 +875,8 @@ function apbct_alt_session__id__get(){
874
  $id = CleantalkHelper::ip__get(array('real'))
875
  .filter_input(INPUT_SERVER, 'HTTP_USER_AGENT')
876
  //.filter_input(INPUT_SERVER, 'HTTP_ACCEPT') // Could be different. Broke session id
877
- .filter_input(INPUT_SERVER, 'HTTP_ACCEPT_LANGUAGE')
878
- .filter_input(INPUT_SERVER, 'HTTP_ACCEPT_ENCODING');
879
  return hash('sha256', $id);
880
  }
881
 
3
  Plugin Name: Anti-Spam by CleanTalk
4
  Plugin URI: http://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.118.4
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
131
  if (!is_admin() && !apbct_is_ajax() && !defined('DOING_CRON') && !headers_sent()
132
  && empty($_POST['ct_checkjs_register_form']) // Buddy press registration fix
133
  ){
134
+ add_action('template_redirect','apbct_cookie', 2);
135
+ add_action('template_redirect','apbct_store__urls', 2);
136
  if (empty($_POST) && empty($_GET['action'])){
137
  apbct_cookie();
138
  apbct_store__urls();
318
  add_filter('wp_die_handler', 'apbct_comment__sanitize_data__before_wp_die', 1); // Check comments after validation
319
 
320
  // Registrations
321
+ if(!isset($_POST['wp-submit']))
322
+ add_action('login_form_register', 'apbct_cookie');
323
+ add_action('login_form_register', 'apbct_store__urls');
324
  add_action('login_enqueue_scripts', 'apbct_login__scripts');
 
 
325
  add_action('register_form', 'ct_register_form');
326
  add_filter('registration_errors', 'ct_registration_errors', 1, 3);
327
  add_filter('registration_errors', 'ct_check_registration_erros', 999999, 3);
502
  $sfw->logs__update($sfw->blocked_ip, 'blocked');
503
  $apbct->data['sfw_counter']['blocked']++;
504
  $apbct->saveData();
505
+ $sfw->sfw_die($apbct->api_key, '', parse_url(get_option('siteurl'),PHP_URL_HOST));
506
  }else{
507
  if(!empty($apbct->settings['set_cookies']) && !headers_sent())
508
  setcookie ('ct_sfw_pass_key', md5($sfw->passed_ip.$apbct->api_key), time()+86400*30, '/', parse_url(get_option('siteurl'),PHP_URL_HOST) ,false, true);
875
  $id = CleantalkHelper::ip__get(array('real'))
876
  .filter_input(INPUT_SERVER, 'HTTP_USER_AGENT')
877
  //.filter_input(INPUT_SERVER, 'HTTP_ACCEPT') // Could be different. Broke session id
878
+ .filter_input(INPUT_SERVER, 'HTTP_ACCEPT_LANGUAGE');
879
+ //.filter_input(INPUT_SERVER, 'HTTP_ACCEPT_ENCODING'); // Could be different. Broke session id
880
  return hash('sha256', $id);
881
  }
882
 
inc/cleantalk-ajax.php CHANGED
@@ -121,9 +121,6 @@ $cleantalk_hooked_actions[]='tmpl_ajax_check_user_email';
121
  $cleantalk_hooked_actions[]='tevolution_submit_from_preview';
122
  $cleantalk_hooked_actions[]='submit_form_recaptcha_validation';
123
 
124
- /**hooks for cm answers pro */
125
- add_action( 'wp', 'ct_ajax_hook',1 );
126
-
127
  /* hooks for contact forms by web settler ajax*/
128
  add_action( 'wp_ajax_nopriv_smuzform-storage', 'ct_ajax_hook',1 );
129
  $cleantalk_hooked_actions[]='smuzform_form_submit';
@@ -287,6 +284,9 @@ function ct_ajax_hook($message_obj = false, $additional = false)
287
  'upload-attachment', // Skip ulpload attachments
288
  'iwj_update_profile', //Skip profile page checker
289
  'st_partner_create_service', //Skip add hotel via admin
 
 
 
290
  );
291
 
292
  //General post_info for all ajax calls
@@ -298,8 +298,8 @@ function ct_ajax_hook($message_obj = false, $additional = false)
298
  }
299
 
300
  $checkjs = apbct_js_test('ct_checkjs', $_COOKIE, true);
301
- if ($checkjs && // Spammers usually fail the JS test
302
- (isset($_POST['action']) && in_array($_POST['action'], $skip_post))
303
  ) {
304
  return false;
305
  }
121
  $cleantalk_hooked_actions[]='tevolution_submit_from_preview';
122
  $cleantalk_hooked_actions[]='submit_form_recaptcha_validation';
123
 
 
 
 
124
  /* hooks for contact forms by web settler ajax*/
125
  add_action( 'wp_ajax_nopriv_smuzform-storage', 'ct_ajax_hook',1 );
126
  $cleantalk_hooked_actions[]='smuzform_form_submit';
284
  'upload-attachment', // Skip ulpload attachments
285
  'iwj_update_profile', //Skip profile page checker
286
  'st_partner_create_service', //Skip add hotel via admin
287
+ 'vp_ajax_vpt_option_save', // https://themeforest.net/item/motor-vehicles-parts-equipments-accessories-wordpress-woocommerce-theme/16829946
288
+ 'mailster_send_test', //Mailster send test admin
289
+ 'acf/validate_save_post', //ACF validate post admin
290
  );
291
 
292
  //General post_info for all ajax calls
298
  }
299
 
300
  $checkjs = apbct_js_test('ct_checkjs', $_COOKIE, true);
301
+ if( (isset($_POST['action']) && in_array($_POST['action'], $skip_post))
302
+ || (isset($_GET['action']) && in_array($_GET['action'], $skip_post))
303
  ) {
304
  return false;
305
  }
inc/cleantalk-common.php CHANGED
@@ -161,6 +161,10 @@ function apbct_base_call($params = array(), $reg_flag = false){
161
  ct_add_event('yes');
162
  }
163
 
 
 
 
 
164
  return array('ct' => $ct, 'ct_result' => $ct_result);
165
 
166
  }
@@ -241,6 +245,8 @@ function apbct_get_sender_info() {
241
  'source_url' => !empty($urls) ? json_encode($urls) : null,
242
  // Debug stuff
243
  'amp_detected' => $amp_detected,
 
 
244
  );
245
  }
246
 
161
  ct_add_event('yes');
162
  }
163
 
164
+ // Set cookies if it's not.
165
+ if(empty($apbct->flags__cookies_setuped))
166
+ apbct_cookie();
167
+
168
  return array('ct' => $ct, 'ct_result' => $ct_result);
169
 
170
  }
245
  'source_url' => !empty($urls) ? json_encode($urls) : null,
246
  // Debug stuff
247
  'amp_detected' => $amp_detected,
248
+ 'hook' => current_action(),
249
+ 'request_type' => isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'UNKNOWN',
250
  );
251
  }
252
 
inc/cleantalk-public.php CHANGED
@@ -67,6 +67,11 @@ function apbct_init() {
67
  ct_ajax_hook();
68
  }
69
 
 
 
 
 
 
70
  //hook for Anonymous Post
71
  if($apbct->settings['general_postdata_test'] == 1 && empty($_POST['ct_checkjs_cf7']))
72
  add_action('wp','ct_contact_form_validate_postdata',1);
@@ -2585,7 +2590,8 @@ function ct_contact_form_validate() {
2585
  (strpos($_SERVER['REQUEST_URI'],'researcher-log-in')!==false ) || // Skip login form
2586
  (strpos($_SERVER['REQUEST_URI'],'admin_aspcms/_system/AspCms_SiteSetting.asp?action=saves')!==false ) || // Skip admin save callback
2587
  (strpos($_SERVER['REQUEST_URI'],'?profile_tab=postjobs')!==false ) || // Skip post vacancies
2588
- (isset($_POST['btn_insert_post_type_hotel']) && $_POST['btn_insert_post_type_hotel'] == 'SUBMIT HOTEL') // Skip adding hotel
 
2589
  ) {
2590
  return null;
2591
  }
67
  ct_ajax_hook();
68
  }
69
 
70
+ /**hooks for cm answers pro */
71
+ if(defined('CMA_PLUGIN_FILE')){
72
+ add_action( 'wp', 'ct_ajax_hook',1 );
73
+ }
74
+
75
  //hook for Anonymous Post
76
  if($apbct->settings['general_postdata_test'] == 1 && empty($_POST['ct_checkjs_cf7']))
77
  add_action('wp','ct_contact_form_validate_postdata',1);
2590
  (strpos($_SERVER['REQUEST_URI'],'researcher-log-in')!==false ) || // Skip login form
2591
  (strpos($_SERVER['REQUEST_URI'],'admin_aspcms/_system/AspCms_SiteSetting.asp?action=saves')!==false ) || // Skip admin save callback
2592
  (strpos($_SERVER['REQUEST_URI'],'?profile_tab=postjobs')!==false ) || // Skip post vacancies
2593
+ (isset($_POST['btn_insert_post_type_hotel']) && $_POST['btn_insert_post_type_hotel'] == 'SUBMIT HOTEL') || // Skip adding hotel
2594
+ (isset($_POST['action']) && $_POST['action'] == 'updraft_savesettings') // Updraft save settings
2595
  ) {
2596
  return null;
2597
  }
inc/sfw_die_page.html CHANGED
@@ -1,40 +1,40 @@
1
  <!doctype html>
2
 
3
  <html lang='en'>
4
- <head>
5
- <meta charset='utf-8' />
6
- <meta name='viewport' content='width=device-width, initial-scale=1' />
7
 
8
- <!--[if lt IE 9]>
9
- <script src='http://html5shiv.googlecode.com/svn/trunk/html5.js'></script>
10
- <![endif]-->
11
- <style>
12
- html{font-size: 14pt;}
13
- h1{text-align:center}
14
- h1.main{margin-top: 1em;margin-bottom: 3em;}
15
- div.container {text-align:center;}
16
- div.container p.js_notice{width: 60%; display: inline-block;}
17
- div.footer {color: #666; position: absolute; bottom: 1em; text-align: center; width: 100%;}
18
- div.footer a {color: #666; vertical-align:bottom; text-align: center;}
19
- div#js_passed {display:none;}
20
 
21
- @media (max-width: 600px) {
22
- }
23
- </style>
24
- <script>
25
- var reload_timeout = 1000;
26
- var ct_date = new Date;
27
- function set_spamFireWallCookie(cookie_name, cookie_value) {
28
- var date = new Date;
29
- date.setDate(date.getDate() + 30);
30
- document.cookie = cookie_name + '=' + escape(cookie_value) + '; path=/;{COOKIE_DOMAIN}; expires=' + date.toUTCString();
31
- return null;
32
- }
33
- function get_current_url() {
34
- document.write(window.location.href);
35
- return null;
36
- }
37
- </script>
38
  </head>
39
 
40
  <body>
@@ -68,13 +68,16 @@ function get_current_url() {
68
 
69
  document.getElementById('curr_date').innerHTML = ct_date.toGMTString();
70
 
 
 
 
 
 
 
71
  setTimeout(function(){
72
  set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_pass_key','{SFW_COOKIE}');
73
  set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_passed','1');
74
  }, 50);
75
- setTimeout(function(){
76
- window.location.href = window.location.origin + window.location.pathname + '?sfw=pass' + Math.round(ct_date.getTime()/1000);
77
- }, reload_timeout);
78
  </script>
79
  {DEBUG}
80
  </body>
1
  <!doctype html>
2
 
3
  <html lang='en'>
4
+ <head>
5
+ <meta charset='utf-8' />
6
+ <meta name='viewport' content='width=device-width, initial-scale=1' />
7
 
8
+ <!--[if lt IE 9]>
9
+ <script src='http://html5shiv.googlecode.com/svn/trunk/html5.js'></script>
10
+ <![endif]-->
11
+ <style>
12
+ html{font-size: 14pt;}
13
+ h1{text-align:center}
14
+ h1.main{margin-top: 1em;margin-bottom: 3em;}
15
+ div.container {text-align:center;}
16
+ div.container p.js_notice{width: 60%; display: inline-block;}
17
+ div.footer {color: #666; position: absolute; bottom: 1em; text-align: center; width: 100%;}
18
+ div.footer a {color: #666; vertical-align:bottom; text-align: center;}
19
+ div#js_passed {display:none;}
20
 
21
+ @media (max-width: 600px) {
22
+ }
23
+ </style>
24
+ <script>
25
+ var reload_timeout = 1000;
26
+ var ct_date = new Date;
27
+ function set_spamFireWallCookie(cookie_name, cookie_value) {
28
+ var date = new Date;
29
+ date.setDate(date.getDate() + 30);
30
+ document.cookie = cookie_name + '=' + escape(cookie_value) + '; path=/; domain={COOKIE_DOMAIN}; expires=' + date.toUTCString();
31
+ return null;
32
+ }
33
+ function get_current_url() {
34
+ document.write(window.location.href);
35
+ return null;
36
+ }
37
+ </script>
38
  </head>
39
 
40
  <body>
68
 
69
  document.getElementById('curr_date').innerHTML = ct_date.toGMTString();
70
 
71
+ if(location.search.search('show_debug=1') === -1){
72
+ setTimeout(function(){
73
+ window.location.href = window.location.origin + window.location.pathname + '?sfw=pass' + Math.round(ct_date.getTime()/1000);
74
+ }, reload_timeout);
75
+ }
76
+
77
  setTimeout(function(){
78
  set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_pass_key','{SFW_COOKIE}');
79
  set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_passed','1');
80
  }, 50);
 
 
 
81
  </script>
82
  {DEBUG}
83
  </body>
lib/CleantalkHelper.php CHANGED
@@ -72,11 +72,12 @@ class CleantalkHelper
72
 
73
  // Cloud Flare
74
  if(isset($ips['cloud_flare'])){
75
- if(isset($headers['Cf-Connecting-Ip'], $headers['Cf-Ipcountry'], $headers['Cf-Ray'])){
76
- $ip_type = self::ip__validate($_SERVER['REMOTE_ADDR']);
 
 
77
  if($ip_type){
78
- // if(self::ip__mask_match($ips['remote_addr'], self::$cdn_pool['cloud_flare']['ipv4'])){
79
- $ips['cloud_flare'] = $headers['Cf-Connecting-Ip'];
80
  }
81
  }
82
  }
@@ -90,10 +91,12 @@ class CleantalkHelper
90
  $ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize($_SERVER['REMOTE_ADDR']) : $_SERVER['REMOTE_ADDR'];
91
 
92
  // Cloud Flare
93
- if(isset($headers['Cf-Connecting-Ip'], $headers['Cf-Ipcountry'], $headers['Cf-Ray'])){
94
- $ip_type = self::ip__validate($headers['Cf-Connecting-Ip']);
 
 
95
  if($ip_type)
96
- $ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize($headers['Cf-Connecting-Ip']) : $headers['Cf-Connecting-Ip'];
97
 
98
  // Sucury
99
  }elseif(isset($headers['X-Sucuri-Clientip'], $headers['X-Sucuri-Country'])){
@@ -119,7 +122,7 @@ class CleantalkHelper
119
 
120
  // X-Forwarded-For
121
  if(isset($headers['X-Forwarded-For'])){
122
- $tmp = explode(",", trim($headers['X-Forwarded-For']));
123
  $tmp = trim($tmp[0]);
124
  $ip_type = self::ip__validate($tmp);
125
  if($ip_type)
@@ -127,7 +130,7 @@ class CleantalkHelper
127
 
128
  // X-Real-Ip
129
  }elseif(isset($headers['X-Real-Ip'])){
130
- $tmp = explode(",", trim($headers['X-Real-Ip']));
131
  $tmp = trim($tmp[0]);
132
  $ip_type = self::ip__validate($tmp);
133
  if($ip_type)
72
 
73
  // Cloud Flare
74
  if(isset($ips['cloud_flare'])){
75
+ if(isset($headers['CF-Connecting-IP'], $headers['CF-IPСountry'], $headers['CF-RAY']) || isset($headers['Cf-Connecting-Ip'], $headers['Cf-Ipcountry'], $headers['Cf-Ray'])){
76
+ $tmp = isset($headers['CF-Connecting-IP']) ? $headers['CF-Connecting-IP'] : $headers['Cf-Connecting-Ip'];
77
+ $tmp = strpos($tmp, ',') !== false ? explode(',', $tmp) : (array)$tmp;
78
+ $ip_type = self::ip__validate(trim($tmp[0]));
79
  if($ip_type){
80
+ $ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize(trim($tmp[0])) : trim($tmp[0]);
 
81
  }
82
  }
83
  }
91
  $ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize($_SERVER['REMOTE_ADDR']) : $_SERVER['REMOTE_ADDR'];
92
 
93
  // Cloud Flare
94
+ if(isset($headers['CF-Connecting-IP'], $headers['CF-IPCountry'], $headers['CF-RAY']) || isset($headers['Cf-Connecting-Ip'], $headers['Cf-Ipcountry'], $headers['Cf-Ray'])){
95
+ $tmp = isset($headers['CF-Connecting-IP']) ? $headers['CF-Connecting-IP'] : $headers['Cf-Connecting-Ip'];
96
+ $tmp = strpos($tmp, ',') !== false ? explode(',', $tmp) : (array)$tmp;
97
+ $ip_type = self::ip__validate(trim($tmp[0]));
98
  if($ip_type)
99
+ $ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize(trim($tmp[0])) : trim($tmp[0]);
100
 
101
  // Sucury
102
  }elseif(isset($headers['X-Sucuri-Clientip'], $headers['X-Sucuri-Country'])){
122
 
123
  // X-Forwarded-For
124
  if(isset($headers['X-Forwarded-For'])){
125
+ $tmp = explode(',', trim($headers['X-Forwarded-For']));
126
  $tmp = trim($tmp[0]);
127
  $ip_type = self::ip__validate($tmp);
128
  if($ip_type)
130
 
131
  // X-Real-Ip
132
  }elseif(isset($headers['X-Real-Ip'])){
133
+ $tmp = explode(',', trim($headers['X-Real-Ip']));
134
  $tmp = trim($tmp[0]);
135
  $ip_type = self::ip__validate($tmp);
136
  if($ip_type)
lib/CleantalkSFW.php CHANGED
@@ -56,8 +56,8 @@ class CleantalkSFW extends CleantalkSFW_Base
56
  $sfw_die_page = str_replace('{COOKIE_PREFIX}', $cookie_prefix, $sfw_die_page);
57
  $sfw_die_page = str_replace('{COOKIE_DOMAIN}', $cookie_domain, $sfw_die_page);
58
  $sfw_die_page = str_replace('{SFW_COOKIE}', md5($this->blocked_ip.$api_key), $sfw_die_page);
59
- $sfw_die_page = str_replace( "{SERVICE_ID}", $apbct->data['service_id'], $sfw_die_page );
60
- $sfw_die_page = str_replace( "{HOST}", $_SERVER['HTTP_HOST'], $sfw_die_page );
61
 
62
  if($this->debug){
63
  $debug = '<h1>Networks</h1>'
56
  $sfw_die_page = str_replace('{COOKIE_PREFIX}', $cookie_prefix, $sfw_die_page);
57
  $sfw_die_page = str_replace('{COOKIE_DOMAIN}', $cookie_domain, $sfw_die_page);
58
  $sfw_die_page = str_replace('{SFW_COOKIE}', md5($this->blocked_ip.$api_key), $sfw_die_page);
59
+ $sfw_die_page = str_replace('{SERVICE_ID}', $apbct->data['service_id'], $sfw_die_page);
60
+ $sfw_die_page = str_replace('{HOST}', $_SERVER['HTTP_HOST'], $sfw_die_page);
61
 
62
  if($this->debug){
63
  $debug = '<h1>Networks</h1>'
lib/CleantalkSFW_Base.php CHANGED
@@ -88,7 +88,7 @@ class CleantalkSFW_Base
88
  if($this->db->result['cnt']){
89
  $this->result = true;
90
  $this->blocked_ip = $current_ip;
91
- $this->debug_networks[] = $this->db->result['network'].'/'.$this->db->result['mask'];
92
  }else{
93
  $this->passed_ip = $current_ip;
94
  }
@@ -206,39 +206,44 @@ class CleantalkSFW_Base
206
 
207
  if($gf){
208
 
209
- $this->db->query("DELETE FROM ".$this->data_table.";", true);
210
-
211
- for($count_result = 0; !gzeof($gf); ){
212
-
213
 
214
- $query = "INSERT INTO ".$this->data_table." VALUES %s";
215
 
216
- for($i=0, $values = array(); APBCT_WRITE_LIMIT !== $i && !gzeof($gf); $i++, $count_result++){
217
-
218
- $entry = trim(gzgets($gf, 1024));
219
-
220
- if(empty($entry)) continue;
221
-
222
- $entry = explode(',', $entry);
223
-
224
- // Cast result to int
225
- $ip = preg_replace('/[^\d]*/', '', $entry[0]);
226
- $mask = preg_replace('/[^\d]*/', '', $entry[1]);
227
-
228
- if(!$ip || !$mask) continue;
 
 
 
 
 
 
 
 
229
 
230
- $values[] = '('. $ip .','. $mask .')';
 
 
 
231
 
232
  }
233
 
234
- $query = sprintf($query, implode(',', $values).';');
235
- $this->db->query($query, true);
236
-
237
- }
238
-
239
- gzclose($gf);
240
- return $count_result;
241
-
242
  }else
243
  return array('error' => true, 'error_string' => 'ERROR_OPEN_GZ_FILE');
244
  }else
88
  if($this->db->result['cnt']){
89
  $this->result = true;
90
  $this->blocked_ip = $current_ip;
91
+ $this->debug_networks[] = long2ip($this->db->result['network']).'/'.$this->db->result['mask'];
92
  }else{
93
  $this->passed_ip = $current_ip;
94
  }
206
 
207
  if($gf){
208
 
209
+ if(!gzeof($gf)){
 
 
 
210
 
211
+ $this->db->query("DELETE FROM ".$this->data_table.";", true);
212
 
213
+ for($count_result = 0; !gzeof($gf); ){
214
+
215
+ $query = "INSERT INTO ".$this->data_table." VALUES %s";
216
+
217
+ for($i=0, $values = array(); APBCT_WRITE_LIMIT !== $i && !gzeof($gf); $i++, $count_result++){
218
+
219
+ $entry = trim(gzgets($gf, 1024));
220
+
221
+ if(empty($entry)) continue;
222
+
223
+ $entry = explode(',', $entry);
224
+
225
+ // Cast result to int
226
+ $ip = preg_replace('/[^\d]*/', '', $entry[0]);
227
+ $mask = preg_replace('/[^\d]*/', '', $entry[1]);
228
+
229
+ if(!$ip || !$mask) continue;
230
+
231
+ $values[] = '('. $ip .','. $mask .')';
232
+
233
+ }
234
 
235
+ if(!empty($values)){
236
+ $query = sprintf($query, implode(',', $values).';');
237
+ $this->db->query($query, true);
238
+ }
239
 
240
  }
241
 
242
+ gzclose($gf);
243
+ return $count_result;
244
+
245
+ }else
246
+ return array('error' => true, 'error_string' => 'ERROR_GZ_EMPTY');
 
 
 
247
  }else
248
  return array('error' => true, 'error_string' => 'ERROR_OPEN_GZ_FILE');
249
  }else
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: safronik
3
  Tags: spam, antispam, protection, comments, firewall
4
  Requires at least: 3.0
5
  Tested up to: 5.2
6
- Stable tag: 5.118.3
7
  License: GPLv2
8
 
9
  Spam protection, antispam, all-in-one, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
@@ -558,6 +558,13 @@ If your website has forms that send data to external sources, you can enable opt
558
  10. Website's options.
559
 
560
  == Changelog ==
 
 
 
 
 
 
 
561
  = 5.118.3 April 29 2019 =
562
  * Fix: Spam statistics in dashboard widget.
563
  * Fix: IP detection.
@@ -1871,6 +1878,13 @@ If your website has forms that send data to external sources, you can enable opt
1871
  * First version
1872
 
1873
  == Upgrade Notice ==
 
 
 
 
 
 
 
1874
  = 5.118.3 April 29 2019 =
1875
  * Fix: Spam statistics in dashboard widget.
1876
  * Fix: IP detection.
3
  Tags: spam, antispam, protection, comments, firewall
4
  Requires at least: 3.0
5
  Tested up to: 5.2
6
+ Stable tag: 5.118.4
7
  License: GPLv2
8
 
9
  Spam protection, antispam, all-in-one, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
558
  10. Website's options.
559
 
560
  == Changelog ==
561
+ = 5.118.4 May 13 2019 =
562
+ * Fix: SFW cookie. Set correct domain for subdomains.
563
+ * Fix: SFW update.
564
+ * Fix: IP detection.
565
+ * Fix: Triggering AJAX check in backend.
566
+ * Fix: Zero submit time on few forms.
567
+
568
  = 5.118.3 April 29 2019 =
569
  * Fix: Spam statistics in dashboard widget.
570
  * Fix: IP detection.
1878
  * First version
1879
 
1880
  == Upgrade Notice ==
1881
+ = 5.118.4 May 13 2019 =
1882
+ * Fix: SFW cookie. Set correct domain for subdomains.
1883
+ * Fix: SFW update.
1884
+ * Fix: IP detection.
1885
+ * Fix: Triggering AJAX check in backend.
1886
+ * Fix: Zero submit time on few forms.
1887
+
1888
  = 5.118.3 April 29 2019 =
1889
  * Fix: Spam statistics in dashboard widget.
1890
  * Fix: IP detection.