Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.43

Version Description

June 22 2016 = * Added spam protection for registrations via 'Login with AJAX' plug-in. * Added a new counter to Admin bar that allows to count spam and approved submissions since last reset. * Update the code that tests a connection between a website and CleanTalk's servers. New version doesn't generate submissions with email good@cleantalk.org. * Fixed issue with spam protection for nested forms by Formidable plug-in.

Download this release

Release Info

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

Code changes from version 5.42 to 5.43

cleantalk.php CHANGED
@@ -3,12 +3,12 @@
3
  Plugin Name: Spam Protection by CleanTalk
4
  Plugin URI: http://cleantalk.org
5
  Description: Max power, all-in-one, captcha less, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms. Formerly Anti-Spam by CleanTalk.
6
- Version: 5.42
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
10
- $cleantalk_plugin_version='5.42';
11
- $ct_agent_version = 'wordpress-542';
12
  $cleantalk_executed=false;
13
  $ct_sfw_updated = false;
14
 
@@ -215,7 +215,6 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
215
  add_action('comment_form_after', 'ct_show_comment_link');
216
  }
217
 
218
-
219
  if (is_admin()||is_network_admin())
220
  {
221
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-admin.php');
@@ -238,6 +237,13 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
238
  {
239
  ct_ajax_hook();
240
  }
 
 
 
 
 
 
 
241
  }
242
 
243
  add_action('admin_enqueue_scripts', 'ct_enqueue_scripts');
@@ -294,12 +300,12 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
294
  */
295
  if (!function_exists ( 'ct_activation')) {
296
  function ct_activation() {
297
- wp_schedule_event(time(), 'hourly', 'ct_hourly_event_hook' );
298
- //wp_schedule_event(time(), 'hourly', 'ct_send_sfw_log' );
299
- wp_schedule_event(time(), 'daily', 'cleantalk_update_sfw' );
300
-
301
- cleantalk_update_sfw();
302
- add_option('ct_plugin_do_activation_redirect', true);
303
  }
304
  }
305
  /**
@@ -334,32 +340,49 @@ function ct_add_event($event_type)
334
  {
335
  global $ct_data,$cleantalk_executed;
336
  $ct_data = ct_get_data();
 
 
337
 
 
338
  if(!isset($ct_data['array_accepted']))
339
- {
340
  $ct_data['array_accepted']=Array();
 
341
  $ct_data['array_blocked']=Array();
 
 
342
  $ct_data['current_hour']=0;
343
- }
344
 
345
- $current_hour=intval(date('G'));
346
- if($current_hour!=$ct_data['current_hour'])
347
- {
348
  $ct_data['current_hour']=$current_hour;
349
  $ct_data['array_accepted'][$current_hour]=0;
350
  $ct_data['array_blocked'][$current_hour]=0;
351
  }
352
 
353
- if($event_type=='yes')
354
- {
 
 
 
 
 
 
 
 
 
 
 
 
 
355
  @$ct_data['array_accepted'][$current_hour]++;
 
 
356
  }
357
- if($event_type=='no')
358
- {
359
  @$ct_data['array_blocked'][$current_hour]++;
 
 
360
  }
361
 
362
-
363
  update_option('cleantalk_data', $ct_data);
364
  $cleantalk_executed=true;
365
  }
3
  Plugin Name: Spam Protection by CleanTalk
4
  Plugin URI: http://cleantalk.org
5
  Description: Max power, all-in-one, captcha less, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms. Formerly Anti-Spam by CleanTalk.
6
+ Version: 5.43
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
10
+ $cleantalk_plugin_version='5.43';
11
+ $ct_agent_version = 'wordpress-543';
12
  $cleantalk_executed=false;
13
  $ct_sfw_updated = false;
14
 
215
  add_action('comment_form_after', 'ct_show_comment_link');
216
  }
217
 
 
218
  if (is_admin()||is_network_admin())
219
  {
220
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-admin.php');
237
  {
238
  ct_ajax_hook();
239
  }
240
+
241
+ //
242
+ // Some of plugins to register a users use AJAX context.
243
+ //
244
+ add_filter('registration_errors', 'ct_registration_errors', 1, 3);
245
+ add_action('user_register', 'ct_user_register');
246
+
247
  }
248
 
249
  add_action('admin_enqueue_scripts', 'ct_enqueue_scripts');
300
  */
301
  if (!function_exists ( 'ct_activation')) {
302
  function ct_activation() {
303
+ wp_schedule_event(time(), 'hourly', 'ct_hourly_event_hook' );
304
+ //wp_schedule_event(time(), 'hourly', 'ct_send_sfw_log' );
305
+ wp_schedule_event(time(), 'daily', 'cleantalk_update_sfw' );
306
+
307
+ cleantalk_update_sfw();
308
+ add_option('ct_plugin_do_activation_redirect', true);
309
  }
310
  }
311
  /**
340
  {
341
  global $ct_data,$cleantalk_executed;
342
  $ct_data = ct_get_data();
343
+ $current_hour=intval(date('G'));
344
+ $current_date=date('d M');
345
 
346
+ //24 hour counter
347
  if(!isset($ct_data['array_accepted']))
 
348
  $ct_data['array_accepted']=Array();
349
+ if(!isset($ct_data['array_blocked']))
350
  $ct_data['array_blocked']=Array();
351
+
352
+ if(!isset($ct_data['current_hour']))
353
  $ct_data['current_hour']=0;
 
354
 
355
+ if($current_hour!=$ct_data['current_hour']){
 
 
356
  $ct_data['current_hour']=$current_hour;
357
  $ct_data['array_accepted'][$current_hour]=0;
358
  $ct_data['array_blocked'][$current_hour]=0;
359
  }
360
 
361
+ //All-time counter
362
+ if(!isset($ct_data['all_time_counter'])){
363
+ $ct_data['all_time_counter']['accepted']=0;
364
+ $ct_data['all_time_counter']['blocked']=0;
365
+ }
366
+
367
+ //User counter
368
+ if(!isset($ct_data['user_counter'])){
369
+ $ct_data['user_counter']['accepted']=0;
370
+ $ct_data['user_counter']['blocked']=0;
371
+ $ct_data['user_counter']['since']=$current_date;
372
+ }
373
+
374
+ //Add 1 to counters
375
+ if($event_type=='yes'){
376
  @$ct_data['array_accepted'][$current_hour]++;
377
+ @$ct_data['all_time_counter']['accepted']++;
378
+ @$ct_data['user_counter']['accepted']++;
379
  }
380
+ if($event_type=='no'){
 
381
  @$ct_data['array_blocked'][$current_hour]++;
382
+ @$ct_data['all_time_counter']['blocked']++;
383
+ @$ct_data['user_counter']['blocked']++;
384
  }
385
 
 
386
  update_option('cleantalk_data', $ct_data);
387
  $cleantalk_executed=true;
388
  }
inc/cleantalk-admin.php CHANGED
@@ -86,35 +86,25 @@ function ct_admin_init()
86
 
87
  $ct_options = ct_get_options();
88
  $ct_data = ct_get_data();
89
-
90
  $current_version=@trim($ct_data['current_version']);
91
  if($current_version!=$cleantalk_plugin_version)
92
  {
93
  $ct_data['current_version']=$cleantalk_plugin_version;
94
  update_option('cleantalk_data', $ct_data);
95
- $ct_base_call_result = ct_base_call(array(
96
- 'message' => 'This message is a test to check the connection to the CleanTalk servers. ',
97
- 'example' => null,
98
- 'sender_email' => 'good@cleantalk.org',
99
- 'sender_nickname' => 'CleanTalk',
100
- 'post_info' => '',
101
- 'checkjs' => 1
102
- ));
103
  }
104
  if(isset($_POST['option_page'])&&$_POST['option_page']=='cleantalk_settings'&&isset($_POST['cleantalk_settings']['apikey']))
105
  {
106
  $ct_options['apikey']=$_POST['cleantalk_settings']['apikey'];
107
  update_option('cleantalk_settings', $ct_options);
108
- $ct_base_call_result = ct_base_call(array(
109
- 'message' => 'This message is a test to check the connection to the CleanTalk servers. ',
110
- 'example' => null,
111
- 'sender_email' => 'good@cleantalk.org',
112
- 'sender_nickname' => 'CleanTalk',
113
- 'post_info' => '',
114
- 'checkjs' => 1
115
- ));
116
  }
117
-
118
  if(@isset($_POST['cleantalk_settings']['spam_firewall']) && $_POST['cleantalk_settings']['spam_firewall']==1)
119
  {
120
  cleantalk_update_sfw();
@@ -179,14 +169,6 @@ function ct_admin_init()
179
  $_POST['cleantalk_settings']['apikey'] = $result['auth_key'];
180
  $ct_options['apikey']=$result['auth_key'];
181
  update_option('cleantalk_settings', $ct_options);
182
- /*$ct_base_call_result = ct_base_call(array(
183
- 'message' => 'CleanTalk setup test',
184
- 'example' => null,
185
- 'sender_email' => 'good@cleantalk.org',
186
- 'sender_nickname' => 'CleanTalk',
187
- 'post_info' => '',
188
- 'checkjs' => 1
189
- )); */
190
  }
191
  else
192
  {
@@ -306,57 +288,9 @@ function ct_admin_init()
306
  if(stripos($_SERVER['REQUEST_URI'],'options.php')!==false || stripos($_SERVER['REQUEST_URI'],'options-general.php')!==false || stripos($_SERVER['REQUEST_URI'],'network/settings.php')!==false)
307
  {
308
 
309
- if(isset($ct_data['testing_failed'])&&$ct_data['testing_failed']==1)
310
- {
311
- $buttons_html='
312
- <style type="text/css">
313
- #ct_button_check_comments, #ct_button_check_users {background: #999999;}
314
-
315
- ';
316
- }
317
- else
318
- {
319
- $buttons_html='
320
- <style type="text/css">
321
- #ct_button_check_comments, #ct_button_check_users {background: #69dd69;}
322
-
323
- ';
324
- }
325
-
326
- $buttons_html.='
327
- #ct_button_check_comments, #ct_button_check_users {padding: 10px; color: #fff; border:0 none;
328
- cursor:pointer;
329
- -webkit-border-radius: 5px;
330
- border-radius: 5px;
331
- font-size: 12pt;
332
- text-decoration:none;
333
- margin-bottom:5px;
334
- display:inline-block;
335
- }
336
-
337
- #ct_stats_banner
338
- {
339
- padding: 0px;
340
- color: #000;
341
- /*border:2px solid #e5e5e5;*/
342
- font-size: 10pt;
343
- text-decoration:none;
344
- margin-bottom:5px;
345
- display:inline-block;
346
- }
347
- </style>';
348
- if(isset($ct_data['testing_failed'])&&$ct_data['testing_failed']==1)
349
- {
350
- /*$buttons_html.='<a href="#" id="ct_button_check_comments" onclick="alert('."'".__('Feature is disabled, because testing of access key is failed!', 'cleantalk')."'".')">'.__('Check comments', 'cleantalk').'</a>
351
- <a href="#" id="ct_button_check_users" onclick="alert('."'".__('Feature is disabled, because testing of access key is failed!', 'cleantalk')."'".')">'.__('Check users', 'cleantalk').'</a><div class="clear"></div>';*/
352
- }
353
- else
354
- {
355
- /*$buttons_html.='<a href="edit-comments.php?page=ct_check_spam&do_check=1" style="font-size:10pt;font-weight:400;">'.__('Check comments', 'cleantalk').'</a><br />
356
- <a href="users.php?page=ct_check_users&do_check=1" style="font-size:10pt;font-weight:400;">'.__('Check users', 'cleantalk').'</a><div class="clear"></div>';*/
357
- }
358
  register_setting('cleantalk_settings', 'cleantalk_settings', 'ct_settings_validate');
359
  add_settings_section('cleantalk_settings_main', __($ct_plugin_name, 'cleantalk'), 'ct_section_settings_main', 'cleantalk');
 
360
  add_settings_section('cleantalk_settings_state', "<hr>".__('Protection is active', 'cleantalk'), 'ct_section_settings_state', 'cleantalk');
361
  //add_settings_section('cleantalk_settings_autodel', "<hr>", 'ct_section_settings_autodel', 'cleantalk');
362
  add_settings_section('cleantalk_settings_banner', "<hr></h3>", '', 'cleantalk');
@@ -394,7 +328,55 @@ function ct_admin_init()
394
  * Admin callback function - Displays description of 'main' plugin parameters section
395
  */
396
  function ct_section_settings_main() {
397
- return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
398
  }
399
 
400
  /**
@@ -411,8 +393,6 @@ function ct_add_admin_menu( $wp_admin_bar ) {
411
  global $ct_options, $ct_data;
412
 
413
  $ct_options = ct_get_options();
414
- $ct_data = ct_get_data();
415
-
416
  if(isset($ct_options['show_adminbar']))
417
  {
418
  $value = @intval($ct_options['show_adminbar']);
@@ -422,23 +402,48 @@ function ct_add_admin_menu( $wp_admin_bar ) {
422
  $value=1;
423
  }
424
 
425
- if ( current_user_can('activate_plugins')&&$value==1 )
426
- {
427
- //$ct_data=ct_get_data();
428
  $ct_data=ct_get_data();
429
 
430
- if(!isset($ct_data['array_accepted']))
431
- {
432
  $ct_data['array_accepted']=Array();
433
  $ct_data['array_blocked']=Array();
434
  $ct_data['current_hour']=0;
435
  update_option('cleantalk_data', $ct_data);
436
  }
437
-
438
- $ret=Array('stat_accepted'=>@array_sum($ct_data['array_accepted']), 'stat_blocked'=>@array_sum($ct_data['array_blocked']), 'stat_all'=>@array_sum($ct_data['array_accepted']) + @array_sum($ct_data['array_blocked']));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
439
  $args = array(
440
  'id' => 'ct_parent_node',
441
- 'title' => '<img src="' . plugin_dir_url(__FILE__) . 'images/logo_small1.png" alt="" height="" style="margin-top:9px;" /><a href="#" class="ab-item alignright" title="Allowed/Blocked submissions. The number of submissions is being counted for past 24 hours." alt="allowed / blocked"><span class="ab-label" id="ct_stats"><span>' . $ret['stat_accepted'] . '</span> / <span>' . $ret['stat_blocked'] . '</span></span></a>'
 
442
  );
443
  $wp_admin_bar->add_node( $args );
444
 
@@ -457,9 +462,18 @@ function ct_add_admin_menu( $wp_admin_bar ) {
457
  'parent' => 'ct_parent_node'
458
  );
459
  $wp_admin_bar->add_node( $args );
 
 
 
 
 
 
 
 
460
  }
461
  }
462
 
 
463
  /**
464
  * Admin callback function - Displays description of 'state' plugin parameters section
465
  */
@@ -609,8 +623,11 @@ function ct_input_apikey() {
609
  if (ct_valid_key($value) === false && !$is_wpmu) {
610
  echo "<script>var cleantalk_good_key=false;</script>";
611
  if (function_exists('curl_init') && function_exists('json_decode')) {
612
- echo "<a target='__blank' style='' href='https://cleantalk.org/register?platform=wordpress&email=".urlencode(get_option('admin_email'))."&website=".urlencode(parse_url(get_option('siteurl'),PHP_URL_HOST))."'>".__('Click here to get access key manually', 'cleantalk')."</a>";
613
  echo '<br /><br /><input name="get_apikey_auto" type="submit" class="cleantalk_manual_link" value="' . __('Get access key automatically', 'cleantalk') . '" />';
 
 
 
 
614
 
615
  admin_addDescriptionsFields(sprintf(__('Admin e-mail (%s) will be used for registration', 'cleantalk'), get_option('admin_email')));
616
  admin_addDescriptionsFields(sprintf('<a target="__blank" style="color:#BBB;" href="https://cleantalk.org/publicoffer">%s</a>', __('License agreement', 'cleantalk')));
@@ -1191,14 +1208,12 @@ function admin_addDescriptionsFields($descr = '') {
1191
  function ct_valid_key($apikey = null) {
1192
  global $ct_options, $ct_data;
1193
 
1194
- $ct_options = ct_get_options();
1195
- $ct_data = ct_get_data();
1196
-
1197
  if ($apikey === null) {
 
1198
  $apikey = $ct_options['apikey'];
1199
  }
1200
-
1201
- return ($apikey === 'enter key' || $apikey === '') ? false : true;
1202
  }
1203
 
1204
  /**
@@ -1367,15 +1382,6 @@ function ct_update_option($option_name) {
1367
  return;
1368
  }
1369
 
1370
- /*$ct_base_call_result = ct_base_call(array(
1371
- 'message' => 'CleanTalk setup test',
1372
- 'example' => null,
1373
- 'sender_email' => 'good@cleantalk.org',
1374
- 'sender_nickname' => 'CleanTalk',
1375
- 'post_info' => '',
1376
- 'checkjs' => 1
1377
- ));*/
1378
-
1379
  $key_valid = true;
1380
  $app_server_error = false;
1381
  $ct_data['testing_failed']=0;
86
 
87
  $ct_options = ct_get_options();
88
  $ct_data = ct_get_data();
89
+
90
  $current_version=@trim($ct_data['current_version']);
91
  if($current_version!=$cleantalk_plugin_version)
92
  {
93
  $ct_data['current_version']=$cleantalk_plugin_version;
94
  update_option('cleantalk_data', $ct_data);
95
+ ct_send_feedback(
96
+ '0:-1' // 0 - request_id, -1 - number of operation.
97
+ );
 
 
 
 
 
98
  }
99
  if(isset($_POST['option_page'])&&$_POST['option_page']=='cleantalk_settings'&&isset($_POST['cleantalk_settings']['apikey']))
100
  {
101
  $ct_options['apikey']=$_POST['cleantalk_settings']['apikey'];
102
  update_option('cleantalk_settings', $ct_options);
103
+ ct_send_feedback(
104
+ '0:-1' // 0 - request_id, -1 - number of operation.
105
+ );
 
 
 
 
 
106
  }
107
+
108
  if(@isset($_POST['cleantalk_settings']['spam_firewall']) && $_POST['cleantalk_settings']['spam_firewall']==1)
109
  {
110
  cleantalk_update_sfw();
169
  $_POST['cleantalk_settings']['apikey'] = $result['auth_key'];
170
  $ct_options['apikey']=$result['auth_key'];
171
  update_option('cleantalk_settings', $ct_options);
 
 
 
 
 
 
 
 
172
  }
173
  else
174
  {
288
  if(stripos($_SERVER['REQUEST_URI'],'options.php')!==false || stripos($_SERVER['REQUEST_URI'],'options-general.php')!==false || stripos($_SERVER['REQUEST_URI'],'network/settings.php')!==false)
289
  {
290
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
  register_setting('cleantalk_settings', 'cleantalk_settings', 'ct_settings_validate');
292
  add_settings_section('cleantalk_settings_main', __($ct_plugin_name, 'cleantalk'), 'ct_section_settings_main', 'cleantalk');
293
+
294
  add_settings_section('cleantalk_settings_state', "<hr>".__('Protection is active', 'cleantalk'), 'ct_section_settings_state', 'cleantalk');
295
  //add_settings_section('cleantalk_settings_autodel', "<hr>", 'ct_section_settings_autodel', 'cleantalk');
296
  add_settings_section('cleantalk_settings_banner', "<hr></h3>", '', 'cleantalk');
328
  * Admin callback function - Displays description of 'main' plugin parameters section
329
  */
330
  function ct_section_settings_main() {
331
+ /*
332
+ $ct_options=ct_get_options();
333
+
334
+ $is_wpmu = false;
335
+ if(defined('CLEANTALK_ACCESS_KEY')) {
336
+ $is_wpmu = true;
337
+ }
338
+
339
+ if (ct_valid_key($ct_options['apikey']) !== false || $is_wpmu) {
340
+ return true;
341
+ }
342
+ $message = "<p>Please wait we are registering account welcome@cleantalk.org to finish plugin setup...</p>";
343
+ echo $message;
344
+
345
+ ?>
346
+ <script type="text/javascript">
347
+ var api_url = 'https://localhost/test.php';
348
+
349
+ var req ;
350
+
351
+ // Browser compatibility check
352
+ if (window.XMLHttpRequest) {
353
+ req = new XMLHttpRequest();
354
+ } else if (window.ActiveXObject) {
355
+
356
+ try {
357
+ req = new ActiveXObject("Msxml2.XMLHTTP");
358
+ } catch (e) {
359
+
360
+ try {
361
+ req = new ActiveXObject("Microsoft.XMLHTTP");
362
+ } catch (e) {}
363
+ }
364
+
365
+ }
366
+
367
+
368
+ var req = new XMLHttpRequest();
369
+ req.open("GET", api_url, true);
370
+ req.onreadystatechange = function () {
371
+ console.log(req.getResponseHeader('HTTP_COOKIE'));
372
+ }
373
+
374
+ req.send(null);
375
+ </script>
376
+
377
+ <?php
378
+ */
379
+ return true;
380
  }
381
 
382
  /**
393
  global $ct_options, $ct_data;
394
 
395
  $ct_options = ct_get_options();
 
 
396
  if(isset($ct_options['show_adminbar']))
397
  {
398
  $value = @intval($ct_options['show_adminbar']);
402
  $value=1;
403
  }
404
 
405
+ if (current_user_can('activate_plugins')&&$value==1 && ct_valid_key($ct_options['apikey']) !== false) {
 
 
406
  $ct_data=ct_get_data();
407
 
408
+ //Create counter
409
+ if(!isset($ct_data['array_accepted'])){
410
  $ct_data['array_accepted']=Array();
411
  $ct_data['array_blocked']=Array();
412
  $ct_data['current_hour']=0;
413
  update_option('cleantalk_data', $ct_data);
414
  }
415
+ //Create counter
416
+ if(!isset($ct_data['all_time_counter'])){
417
+ $ct_data['all_time_counter']['accepted']=0;
418
+ $ct_data['all_time_counter']['blocked']=0;
419
+ update_option('cleantalk_data', $ct_data);
420
+ }
421
+ //Reset or create counter
422
+ if(!isset($ct_data['user_counter']) || $_GET['ct_reset_user_counter']==1){
423
+ $ct_data['user_counter']['accepted']=0;
424
+ $ct_data['user_counter']['blocked']=0;
425
+ $ct_data['user_counter']['since']=date('d M');
426
+ update_option('cleantalk_data', $ct_data);
427
+ }
428
+
429
+ $daily_counter=Array('accepted'=>@array_sum($ct_data['array_accepted']), 'blocked'=>@array_sum($ct_data['array_blocked']), 'all'=>@array_sum($ct_data['array_accepted']) + @array_sum($ct_data['array_blocked']));
430
+
431
+ $all_time_counter=Array('accepted'=>$ct_data['all_time_counter']['accepted'], 'blocked'=>$ct_data['all_time_counter']['blocked'], 'all'=>$ct_data['all_time_counter']['accepted'] + $ct_data['all_time_counter']['blocked']);
432
+
433
+ $user_counter=Array('accepted'=>$ct_data['user_counter']['accepted'], 'blocked'=>$ct_data['user_counter']['blocked'], 'all'=>$ct_data['user_counter']['accepted'] + $ct_data['user_counter']['blocked'], 'since'=>$ct_data['user_counter']['since']);
434
+
435
+ foreach($ct_data['array_blocked'] as $key => $val){
436
+ $mass.=$key.":".$val.' | ';
437
+ }unset($key, $val);
438
+
439
+ $user_counter_str='<span style="color: #49c73b; color: #349ebf;">'.__('User', 'cleantalk').': </span> <span style="color: white;">' .$user_counter['all']. '</span> / <span style="color: green;">' .$user_counter['accepted']. '</span> / <span style="color: red;">' .$user_counter['blocked']. '</span>';
440
+ $all_time_counter_str='<span style="color: #49c73b; color: #349ebf;">'.__('All time', 'cleantalk').':</span> <span style="color: white;">' .$all_time_counter['all']. '</span> / <span style="color: green;">' . $all_time_counter['accepted']. '</span> / <span style="color: red;">' .$all_time_counter['blocked']. '</span>';
441
+ $daily_counter_str='<span style="color: #49c73b; color: #349ebf;">'.__('Daily', 'cleantalk').':</span> <span style="color: white;">' .$daily_counter['all']. '</span> / <span style="color: green;">' . $daily_counter['accepted']. '</span> / <span style="color: red;">' .$daily_counter['blocked']. '</span>';
442
+
443
  $args = array(
444
  'id' => 'ct_parent_node',
445
+ 'title' => '<img src="' . plugin_dir_url(__FILE__) . 'images/logo_small1.png" alt="" height="" style="margin-top:9px;" /><div style="margin: auto 7px;" class="ab-item alignright"><span class="ab-label" id="ct_stats"><span style="color: white;" title="'.__('All / Allowed / Blocked submissions. The number of submissions is being counted for past 24 hours.', 'cleantalk').'">'.$daily_counter_str.'
446
+ | </span><span style="color: white;" title="'.__('All / Allowed / Blocked submissions. The number of submissions is being counted since ', 'cleantalk').' '.$user_counter['since'].'">'.$user_counter_str.' | </span><span style="color: white;" title="'.__('All / Allowed / Blocked submissions. The number of submissions is being counted for all time since installation.', 'cleantalk').'">'.$all_time_counter_str.'</span></span></div>' //You could change widget string here by simply deleting variables
447
  );
448
  $wp_admin_bar->add_node( $args );
449
 
462
  'parent' => 'ct_parent_node'
463
  );
464
  $wp_admin_bar->add_node( $args );
465
+
466
+ // add a child item to our parent item. Counter reset.
467
+ $args = array(
468
+ 'id' => 'ct_reset_counter',
469
+ 'title' => '<hr style="margin-top: 7px;"><a href="'.$_SERVER['PATH_INFO'].'?ct_reset_user_counter=1" title="Reset yor personal counter.">'.__('Reset User counter', 'cleantalk').'</a>',
470
+ 'parent' => 'ct_parent_node'
471
+ );
472
+ $wp_admin_bar->add_node( $args );
473
  }
474
  }
475
 
476
+
477
  /**
478
  * Admin callback function - Displays description of 'state' plugin parameters section
479
  */
623
  if (ct_valid_key($value) === false && !$is_wpmu) {
624
  echo "<script>var cleantalk_good_key=false;</script>";
625
  if (function_exists('curl_init') && function_exists('json_decode')) {
 
626
  echo '<br /><br /><input name="get_apikey_auto" type="submit" class="cleantalk_manual_link" value="' . __('Get access key automatically', 'cleantalk') . '" />';
627
+ echo "&nbsp;" . __("or") . "&nbsp;";
628
+ echo "<a target='__blank' style='' href='https://cleantalk.org/register?platform=wordpress&email=".urlencode(get_option('admin_email'))."&website=".urlencode(parse_url(get_option('siteurl'),PHP_URL_HOST))."'>".__('Click here to get access key manually', 'cleantalk')."</a>";
629
+ echo "<br />";
630
+ echo "<br />";
631
 
632
  admin_addDescriptionsFields(sprintf(__('Admin e-mail (%s) will be used for registration', 'cleantalk'), get_option('admin_email')));
633
  admin_addDescriptionsFields(sprintf('<a target="__blank" style="color:#BBB;" href="https://cleantalk.org/publicoffer">%s</a>', __('License agreement', 'cleantalk')));
1208
  function ct_valid_key($apikey = null) {
1209
  global $ct_options, $ct_data;
1210
 
 
 
 
1211
  if ($apikey === null) {
1212
+ $ct_options = ct_get_options();
1213
  $apikey = $ct_options['apikey'];
1214
  }
1215
+
1216
+ return ($apikey === 'enter key' || $apikey === '') ? false : true;
1217
  }
1218
 
1219
  /**
1382
  return;
1383
  }
1384
 
 
 
 
 
 
 
 
 
 
1385
  $key_valid = true;
1386
  $app_server_error = false;
1387
  $ct_data['testing_failed']=0;
inc/cleantalk-ajax.php CHANGED
@@ -1,5 +1,6 @@
1
  <?php
2
  global $cleantalk_hooked_actions;
 
3
  /*
4
  AJAX functions
5
  */
@@ -272,7 +273,7 @@ function ct_ajax_hook()
272
  {
273
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
274
  global $ct_agent_version, $ct_checkjs_register_form, $ct_session_request_id_label, $ct_session_register_ok_label, $bp, $ct_signup_done, $ct_formtime_label, $ct_negative_comment, $ct_options, $ct_data, $current_user;
275
-
276
  $ct_options = ct_get_options();
277
  $ct_data = ct_get_data();
278
  $sender_email = null;
1
  <?php
2
  global $cleantalk_hooked_actions;
3
+
4
  /*
5
  AJAX functions
6
  */
273
  {
274
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
275
  global $ct_agent_version, $ct_checkjs_register_form, $ct_session_request_id_label, $ct_session_register_ok_label, $bp, $ct_signup_done, $ct_formtime_label, $ct_negative_comment, $ct_options, $ct_data, $current_user;
276
+
277
  $ct_options = ct_get_options();
278
  $ct_data = ct_get_data();
279
  $sender_email = null;
inc/cleantalk-common.php CHANGED
@@ -95,6 +95,8 @@ $ct_notice_autokey_label = 'ct_autokey';
95
  // Apikey automatic getting error text
96
  $ct_notice_autokey_value = '';
97
 
 
 
98
  $ct_options=ct_get_options();
99
  $ct_data=ct_get_data();
100
 
@@ -517,7 +519,7 @@ function ct_feedback($hash, $message = null, $allow) {
517
  * @return bool
518
  */
519
  function ct_send_feedback($feedback_request = null) {
520
- global $ct_options, $ct_data;
521
 
522
  $ct_options = ct_get_options();
523
  $ct_data = ct_get_data();
@@ -530,31 +532,37 @@ function ct_send_feedback($feedback_request = null) {
530
  }
531
 
532
  if ($feedback_request !== null) {
533
- require_once('cleantalk.class.php');
534
- $config = get_option('cleantalk_server');
535
-
536
- $ct = new Cleantalk();
537
- $ct->work_url = $config['ct_work_url'];
538
- $ct->server_url = $ct_options['server'];
539
- $ct->server_ttl = $config['ct_server_ttl'];
540
- $ct->server_changed = $config['ct_server_changed'];
541
-
542
- $ct_request = new CleantalkRequest();
543
- $ct_request->auth_key = $ct_options['apikey'];
544
- $ct_request->feedback = $feedback_request;
545
-
546
- $ct->sendFeedback($ct_request);
547
-
548
- if ($ct->server_change) {
549
- update_option(
550
- 'cleantalk_server', array(
551
- 'ct_work_url' => $ct->work_url,
552
- 'ct_server_ttl' => $ct->server_ttl,
553
- 'ct_server_changed' => time()
554
- )
555
- );
556
- }
557
- return true;
 
 
 
 
 
 
558
  }
559
 
560
  return false;
@@ -738,7 +746,7 @@ function ct_get_fields_any2($arr, $message=array(), $email=NULL, $nickname=NULL,
738
  }
739
  else if(!is_object($value)&&@get_class($value)!='WP_User')
740
  {
741
- $temp = ct_get_fields_any2($value, $message, $email, $nickname, $subject, $contact);
742
 
743
  $email = ($temp['email'] ? $temp['email'] : '');
744
  $nickname = ($temp['nickname'] ? $temp['nickname'] : '');
@@ -759,7 +767,6 @@ function ct_get_fields_any2($arr, $message=array(), $email=NULL, $nickname=NULL,
759
  break;
760
  }
761
  }
762
-
763
  $return_param = array(
764
  'email' => $email,
765
  'nickname' => $nickname,
@@ -776,7 +783,7 @@ function ct_get_fields_any2($arr, $message=array(), $email=NULL, $nickname=NULL,
776
  * @return string
777
  */
778
  function ct_obfuscate_param ($value = null) {
779
- if ($value && is_string($value)) {
780
  $length = strlen($value);
781
  $value = str_repeat('*', $length);
782
  }
95
  // Apikey automatic getting error text
96
  $ct_notice_autokey_value = '';
97
 
98
+ $ct_feedback_requests_pool = array();
99
+
100
  $ct_options=ct_get_options();
101
  $ct_data=ct_get_data();
102
 
519
  * @return bool
520
  */
521
  function ct_send_feedback($feedback_request = null) {
522
+ global $ct_options, $ct_data, $ct_feedback_requests_pool;
523
 
524
  $ct_options = ct_get_options();
525
  $ct_data = ct_get_data();
532
  }
533
 
534
  if ($feedback_request !== null) {
535
+ if (in_array($feedback_request, $ct_feedback_requests_pool)) { // The request already sent.
536
+ return false;
537
+ } else {
538
+ $ct_feedback_requests_pool[] = $feedback_request;
539
+ }
540
+
541
+ require_once('cleantalk.class.php');
542
+ $config = get_option('cleantalk_server');
543
+
544
+ $ct = new Cleantalk();
545
+ $ct->work_url = $config['ct_work_url'];
546
+ $ct->server_url = $ct_options['server'];
547
+ $ct->server_ttl = $config['ct_server_ttl'];
548
+ $ct->server_changed = $config['ct_server_changed'];
549
+
550
+ $ct_request = new CleantalkRequest();
551
+ $ct_request->auth_key = $ct_options['apikey'];
552
+ $ct_request->feedback = $feedback_request;
553
+
554
+ $ct->sendFeedback($ct_request);
555
+
556
+ if ($ct->server_change) {
557
+ update_option(
558
+ 'cleantalk_server', array(
559
+ 'ct_work_url' => $ct->work_url,
560
+ 'ct_server_ttl' => $ct->server_ttl,
561
+ 'ct_server_changed' => time()
562
+ )
563
+ );
564
+ }
565
+ return true;
566
  }
567
 
568
  return false;
746
  }
747
  else if(!is_object($value)&&@get_class($value)!='WP_User')
748
  {
749
+ $temp = ct_get_fields_any2($value);
750
 
751
  $email = ($temp['email'] ? $temp['email'] : '');
752
  $nickname = ($temp['nickname'] ? $temp['nickname'] : '');
767
  break;
768
  }
769
  }
 
770
  $return_param = array(
771
  'email' => $email,
772
  'nickname' => $nickname,
783
  * @return string
784
  */
785
  function ct_obfuscate_param ($value = null) {
786
+ if ($value && (!is_object($value) || !is_array($value))) {
787
  $length = strlen($value);
788
  $value = str_repeat('*', $length);
789
  }
inc/cleantalk-public.php CHANGED
@@ -384,7 +384,7 @@ function ct_frm_validate_entry ($errors, $values) {
384
  $post_info = '';
385
 
386
  $temp = ct_get_fields_any2($values['item_meta']);
387
-
388
  $sender_email = ($temp['email'] ? $temp['email'] : '');
389
  $sender_nickname = ($temp['nickname'] ? $temp['nickname'] : '');
390
  $subject = ($temp['subject'] ? $temp['subject'] : '');
@@ -1960,7 +1960,7 @@ function ct_contact_form_validate () {
1960
  */
1961
  function ct_contact_form_validate_postdata () {
1962
  global $pagenow,$cleantalk_executed, $cleantalk_url_exclusions, $ct_options, $ct_data;
1963
-
1964
  $ct_options = ct_get_options();
1965
  $ct_data = ct_get_data();
1966
 
384
  $post_info = '';
385
 
386
  $temp = ct_get_fields_any2($values['item_meta']);
387
+
388
  $sender_email = ($temp['email'] ? $temp['email'] : '');
389
  $sender_nickname = ($temp['nickname'] ? $temp['nickname'] : '');
390
  $subject = ($temp['subject'] ? $temp['subject'] : '');
1960
  */
1961
  function ct_contact_form_validate_postdata () {
1962
  global $pagenow,$cleantalk_executed, $cleantalk_url_exclusions, $ct_options, $ct_data;
1963
+
1964
  $ct_options = ct_get_options();
1965
  $ct_data = ct_get_data();
1966
 
inc/cleantalk-users-checkspam.js CHANGED
@@ -197,7 +197,7 @@ jQuery(".cleantalk_delete_user_button").click(function(){
197
  jQuery("#comment-"+id).remove();
198
  close_animate=true;
199
  },
200
- timeout: 15000
201
  });
202
  });
203
  jQuery(".cleantalk_delete_user_button").click(function(){
197
  jQuery("#comment-"+id).remove();
198
  close_animate=true;
199
  },
200
+ timeout: 180000
201
  });
202
  });
203
  jQuery(".cleantalk_delete_user_button").click(function(){
inc/cleantalk-users.php CHANGED
@@ -374,7 +374,7 @@ function ct_ajax_insert_users()
374
 
375
  $inserted = 0;
376
  $use_id = 0;
377
- for($i=0; $i<5000 ;$i++)
378
  {
379
  $rnd=mt_rand(1,10000000);
380
 
@@ -412,34 +412,21 @@ function ct_ajax_delete_checked_users()
412
  add_action( 'wp_ajax_ajax_delete_all_users', 'ct_ajax_delete_all_users' );
413
  function ct_ajax_delete_all_users()
414
  {
415
- check_ajax_referer( 'ct_secret_nonce', 'security' );
416
- $args_spam = array(
417
- 'number' => 100,
418
- 'meta_query' => array(
419
- Array(
420
- 'key' => 'ct_marked_as_spam',
421
- 'value' => '1',
422
- 'compare' => 'NUMERIC'
423
- )
424
- )
425
- );
426
- $c_spam=get_users($args_spam);
427
- $cnt=sizeof($c_spam);
428
-
429
- $args = array(
430
- 'meta_key' => 'ct_marked_as_spam',
431
- 'meta_value' => '1',
432
- 'meta_comparecompare' => 'NUMERIC'
433
- );
434
 
435
- $user_query = new WP_User_Query( $args );
436
- $cnt_all = $user_query->get_total();
 
 
 
437
 
438
- for($i=0;$i<sizeof($c_spam);$i++)
439
- {
440
- wp_delete_user($c_spam[$i]->ID);
441
- usleep(5000);
442
- }
 
 
443
  print $cnt_all;
444
  die();
445
  }
374
 
375
  $inserted = 0;
376
  $use_id = 0;
377
+ for($i=0; $i<500 ;$i++)
378
  {
379
  $rnd=mt_rand(1,10000000);
380
 
412
  add_action( 'wp_ajax_ajax_delete_all_users', 'ct_ajax_delete_all_users' );
413
  function ct_ajax_delete_all_users()
414
  {
415
+ global $wpdb;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
 
417
+ $r=$wpdb->get_results("select distinct $wpdb->users.ID from $wpdb->users inner join $wpdb->usermeta on $wpdb->users.ID=$wpdb->usermeta.user_id where $wpdb->usermeta.meta_key='ct_marked_as_spam';", ARRAY_A);
418
+ $cnt_all = 0;
419
+ if ($r) {
420
+ $cnt_all = count($r);
421
+ }
422
 
423
+ $r=$wpdb->get_results("select distinct $wpdb->users.ID from $wpdb->users inner join $wpdb->usermeta on $wpdb->users.ID=$wpdb->usermeta.user_id where $wpdb->usermeta.meta_key='ct_marked_as_spam' limit 50;", ARRAY_A);
424
+ if ($r) {
425
+ for($i = 0; $i < count($r); $i++) {
426
+ wp_delete_user($r[$i]['ID']);
427
+ usleep(5000);
428
+ }
429
+ }
430
  print $cnt_all;
431
  die();
432
  }
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: znaeff, shagimuratov, serge00
3
  Tags: spam, anti-spam, antispam, anti spam, bbpress, buddypress, captcha, capcha, captha, catcha, cf7 spam, comments, contact form spam, signup, spammers, spammy, woocommerce, wordpress spam, booking, order, subscription, gravity spam, jetpack, bots, contact form 7, contact form, registrations, ninja, Fast Secure Contact, Gravity forms, formidable, mailchimp, s2member, protection, protect, email, akismet, plugin, contact, recaptcha, google captcha, google recaptcha, math, security, login, blacklist, prevent spam comments, wordpress, User Frontend, bulk delete, bulk remove, cloudflare, widget, review, auth forms, firewall, ddos, cleantalk, mailpoet, profile builder, comment spam, registration spam, spam comments, comment moderation, spam bots, block spam, signup spam, spam blocker, spam filter, user registration spam,pingback,trackback, anti-spam plugin, varnish, amp, spam free, userpro
4
  Requires at least: 3.0
5
- Tested up to: 4.5.2
6
- Stable tag: 5.42
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -467,6 +467,12 @@ WordPress 3.0 at least. PHP 5 with CURL or file_get_contents() function and enab
467
  1. CleanTalk works faster than most of other anti-spam plugins.
468
 
469
  == Changelog ==
 
 
 
 
 
 
470
  = 5.42 2016-06-15 =
471
  * Added anti-spam protection for UserPro.
472
  * Improved protection for Formidable forms + Varnish.
@@ -1067,6 +1073,12 @@ WordPress 3.0 at least. PHP 5 with CURL or file_get_contents() function and enab
1067
  * First version
1068
 
1069
  == Upgrade Notice ==
 
 
 
 
 
 
1070
  = 5.42 2016-06-15 =
1071
  * Added anti-spam protection for UserPro.
1072
  * Improved protection for Formidable forms + Varnish.
2
  Contributors: znaeff, shagimuratov, serge00
3
  Tags: spam, anti-spam, antispam, anti spam, bbpress, buddypress, captcha, capcha, captha, catcha, cf7 spam, comments, contact form spam, signup, spammers, spammy, woocommerce, wordpress spam, booking, order, subscription, gravity spam, jetpack, bots, contact form 7, contact form, registrations, ninja, Fast Secure Contact, Gravity forms, formidable, mailchimp, s2member, protection, protect, email, akismet, plugin, contact, recaptcha, google captcha, google recaptcha, math, security, login, blacklist, prevent spam comments, wordpress, User Frontend, bulk delete, bulk remove, cloudflare, widget, review, auth forms, firewall, ddos, cleantalk, mailpoet, profile builder, comment spam, registration spam, spam comments, comment moderation, spam bots, block spam, signup spam, spam blocker, spam filter, user registration spam,pingback,trackback, anti-spam plugin, varnish, amp, spam free, userpro
4
  Requires at least: 3.0
5
+ Tested up to: 4.5.3
6
+ Stable tag: 5.43
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
467
  1. CleanTalk works faster than most of other anti-spam plugins.
468
 
469
  == Changelog ==
470
+ = 5.43 June 22 2016 =
471
+ * Added spam protection for registrations via 'Login with AJAX' plug-in.
472
+ * Added a new counter to Admin bar that allows to count spam and approved submissions since last reset.
473
+ * Update the code that tests a connection between a website and CleanTalk's servers. New version doesn't generate submissions with email good@cleantalk.org.
474
+ * Fixed issue with spam protection for nested forms by Formidable plug-in.
475
+
476
  = 5.42 2016-06-15 =
477
  * Added anti-spam protection for UserPro.
478
  * Improved protection for Formidable forms + Varnish.
1073
  * First version
1074
 
1075
  == Upgrade Notice ==
1076
+ = 5.43 June 22 2016 =
1077
+ * Added spam protection for registrations via 'Login with AJAX' plug-in.
1078
+ * Added a new counter to Admin bar that allows to count spam and approved submissions since last reset.
1079
+ * Update the code that tests a connection between a website and CleanTalk's servers. New version doesn't generate submissions with email good@cleantalk.org.
1080
+ * Fixed issue with spam protection for nested forms by Formidable plug-in.
1081
+
1082
  = 5.42 2016-06-15 =
1083
  * Added anti-spam protection for UserPro.
1084
  * Improved protection for Formidable forms + Varnish.