Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.31.1

Version Description

Download this release

Release Info

Developer Vlad Cleantalk
Plugin Icon 128x128 Spam protection, AntiSpam, FireWall by CleanTalk
Version 5.31.1
Comparing to
See all releases

Code changes from version 5.33 to 5.31.1

cleantalk.php CHANGED
@@ -3,11 +3,11 @@
3
  Plugin Name: Anti-Spam 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.
6
- Version: 5.33
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
10
- $cleantalk_plugin_version='5.33';
11
  $cleantalk_executed=false;
12
 
13
  if(defined('CLEANTALK_AJAX_USE_BUFFER'))
@@ -35,10 +35,6 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
35
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-widget.php');
36
  $ct_options=ct_get_options();
37
  $ct_data=ct_get_data();
38
- if(@stripos($_SERVER['REQUEST_URI'],'admin-ajax.php')!==false && sizeof($_POST)>0 && isset($_GET['action']) && $_GET['action']=='ninja_forms_ajax_submit')
39
- {
40
- $_POST['action']='ninja_forms_ajax_submit';
41
- }
42
 
43
  if(isset($ct_options['spam_firewall']))
44
  {
@@ -48,35 +44,32 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
48
  {
49
  $value=0;
50
  }
51
- if($value==1 && !is_admin() && stripos($_SERVER['REQUEST_URI'],'/wp-admin/')===false || stripos($_SERVER['REQUEST_URI'],basename(admin_url('admin-ajax.php')))!=false) //&& (!isset($_POST) || isset($_POST) && sizeof($_POST)==0)
 
52
  {
53
  $is_sfw_check=true;
54
- $ip=cleantalk_get_ip();
55
- for($i=0;$i<sizeof($ip);$i++)
56
- {
57
- if(isset($_COOKIE['ct_sfw_pass_key']) && $_COOKIE['ct_sfw_pass_key']==md5($ip[$i].$ct_options['apikey']))
58
- {
59
- $is_sfw_check=false;
60
- if(isset($_COOKIE['ct_sfw_passed']))
61
- {
62
- if(isset($ct_data['sfw_log']))
63
- {
64
- $sfw_log=$ct_data['sfw_log'];
65
- }
66
- else
67
- {
68
- $sfw_log=array();
69
- $sfw_log[$ip[$i]]=Array();
70
- }
71
- $sfw_log[$ip[$i]]['allow']++;
72
- $ct_data['sfw_log'] = $sfw_log;
73
- update_option('cleantalk_data', $ct_data);
74
- @setcookie ('ct_sfw_passed', '0', 1, "/");
75
- }
76
- //@$ct_data['sfw_log'][cleantalk_get_ip()]['all']++;
77
- //update_option('cleantalk_data', $ct_data);
78
- }
79
- }
80
  if($is_sfw_check)
81
  {
82
  //include_once("cleantalk-sfw.php");
@@ -176,43 +169,42 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
176
  if (is_admin()||is_network_admin())
177
  {
178
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-admin.php');
179
- if (!(defined( 'DOING_AJAX' ) && DOING_AJAX))
180
- {
181
- add_action('admin_init', 'ct_admin_init', 1);
182
- add_action('admin_menu', 'ct_admin_add_page');
183
- if(is_network_admin())
184
- {
185
- add_action('network_admin_menu', 'ct_admin_add_page');
186
- }
187
- add_action('admin_notices', 'cleantalk_admin_notice_message');
188
- }
189
- if (defined( 'DOING_AJAX' ) && DOING_AJAX||isset($_POST['cma-action']))
190
  {
191
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
192
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-ajax.php');
193
  }
194
 
195
- add_action('admin_enqueue_scripts', 'ct_enqueue_scripts');
196
- if($pagenow=='edit-comments.php')
197
- {
198
- add_action('comment_unapproved_to_approvecomment', 'ct_comment_approved'); // param - comment object
199
- add_action('comment_unapproved_to_approved', 'ct_comment_approved'); // param - comment object
200
- add_action('comment_approved_to_unapproved', 'ct_comment_unapproved'); // param - comment object
201
- add_action('comment_unapproved_to_spam', 'ct_comment_spam'); // param - comment object
202
- add_action('comment_approved_to_spam', 'ct_comment_spam'); // param - comment object
203
- //add_filter('get_comment_text', 'ct_get_comment_text'); // param - current comment text
204
- add_filter('unspam_comment', 'ct_unspam_comment');
205
- }
206
- if($pagenow=='users.php')
207
- {
208
- add_action('delete_user', 'ct_delete_user');
209
- }
210
- if($pagenow=='plugins.php' || @strpos($_SERVER['REQUEST_URI'],'plugins.php')!==false)
211
- {
212
- add_filter('plugin_row_meta', 'ct_register_plugin_links', 10, 2);
213
- add_filter('plugin_action_links', 'ct_plugin_action_links', 10, 2);
214
- }
215
- add_action('updated_option', 'ct_update_option'); // param - option name, i.e. 'cleantalk_settings'
216
  }else{
217
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
218
 
@@ -327,40 +319,19 @@ function ct_add_nocache_script_footer()
327
  print "\n<script type='text/javascript'>var ct_blog_home = '".get_home_url()."';</script>\n";
328
  print "<script async type='text/javascript' src='".plugins_url( '/inc/cleantalk_external.js' , __FILE__ )."?random=".$cleantalk_plugin_version."'></script>\n";
329
  }
330
- //print "<script async type='text/javascript' src='".plugins_url( '/inc/cleantalk-info.js' , __FILE__ )."?random=".$cleantalk_plugin_version."'></script>\n";
331
  }
332
 
333
  function ct_add_nocache_script_header()
334
  {
335
- global $ct_options;
336
- $ct_options=ct_get_options();
337
- if(substr($ct_options['apikey'],0,1)=='y')
338
- {
339
- $ct_info_flag="var ct_info_flag=true;\n";
340
- }
341
- else
342
- {
343
- $ct_info_flag="var ct_info_flag=false;\n";
344
- }
345
-
346
- print "\n<script type='text/javascript'>\nvar ct_ajaxurl = '".admin_url('admin-ajax.php')."';\n $ct_info_flag </script>\n";
347
  }
348
 
349
  function ct_inject_nocache_script($html)
350
  {
351
- global $test_external_forms, $cleantalk_plugin_version, $ct_options;
352
- $ct_options=ct_get_options();
353
- if(substr($ct_options['apikey'],0,1)=='y')
354
- {
355
- $ct_info_flag="var ct_info_flag=true;\n";
356
- }
357
- else
358
- {
359
- $ct_info_flag="var ct_info_flag=false;\n";
360
- }
361
  if(!is_admin()&&stripos($html,"</body")!==false)
362
  {
363
- //$ct_replace.="\n<script type='text/javascript'>var ajaxurl = '".admin_url('admin-ajax.php')."';\n $ct_info_flag </script>\n";
364
  $ct_replace="<script async type='text/javascript' src='".plugins_url( '/inc/cleantalk_nocache.js' , __FILE__ )."?random=".$cleantalk_plugin_version."'></script>\n";
365
  if($test_external_forms)
366
  {
@@ -373,7 +344,7 @@ function ct_inject_nocache_script($html)
373
  }
374
  if(!is_admin()&&preg_match("#<head[^>]*>#i",$html)==1)
375
  {
376
- $ct_replace="\n<script type='text/javascript'>\nvar ct_ajaxurl = '".admin_url('admin-ajax.php')."';\n $ct_info_flag </script>\n";
377
  $html=preg_replace("(<head[^>]*>)","$0".$ct_replace,$html,1);
378
  }
379
  return $html;
@@ -456,7 +427,6 @@ INDEX ( `network` , `mask` )
456
 
457
  function cleantalk_get_ip()
458
  {
459
- $result=Array();
460
  if ( function_exists( 'apache_request_headers' ) )
461
  {
462
  $headers = apache_request_headers();
@@ -468,20 +438,22 @@ function cleantalk_get_ip()
468
  if ( array_key_exists( 'X-Forwarded-For', $headers ) )
469
  {
470
  $the_ip=explode(",", trim($headers['X-Forwarded-For']));
471
- $result[] = trim($the_ip[0]);
472
  }
473
- if ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $headers ))
474
  {
475
  $the_ip=explode(",", trim($headers['HTTP_X_FORWARDED_FOR']));
476
- $result[] = trim($the_ip[0]);
 
 
 
 
477
  }
478
- $result[] = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 );
479
-
480
  if(isset($_GET['sfw_test_ip']))
481
  {
482
- $result[]=$_GET['sfw_test_ip'];
483
  }
484
- return $result;
485
  }
486
 
487
  function ct_send_sfw_log()
3
  Plugin Name: Anti-Spam 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.
6
+ Version: 5.31.1
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
10
+ $cleantalk_plugin_version='5.31.1';
11
  $cleantalk_executed=false;
12
 
13
  if(defined('CLEANTALK_AJAX_USE_BUFFER'))
35
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-widget.php');
36
  $ct_options=ct_get_options();
37
  $ct_data=ct_get_data();
 
 
 
 
38
 
39
  if(isset($ct_options['spam_firewall']))
40
  {
44
  {
45
  $value=0;
46
  }
47
+
48
+ if($value==1 && !is_admin() && stripos($_SERVER['REQUEST_URI'],'/wp-admin/')===false) //&& (!isset($_POST) || isset($_POST) && sizeof($_POST)==0)
49
  {
50
  $is_sfw_check=true;
51
+ if(isset($_COOKIE['ct_sfw_pass_key']) && $_COOKIE['ct_sfw_pass_key']==md5(cleantalk_get_ip().$ct_options['apikey']))
52
+ {
53
+ $is_sfw_check=false;
54
+ if(isset($_COOKIE['ct_sfw_passed']))
55
+ {
56
+ if(isset($ct_data['sfw_log']))
57
+ {
58
+ $sfw_log=$ct_data['sfw_log'];
59
+ }
60
+ else
61
+ {
62
+ $sfw_log=array();
63
+ $sfw_log[cleantalk_get_ip()]=Array();
64
+ }
65
+ $sfw_log[cleantalk_get_ip()]['allow']++;
66
+ $ct_data['sfw_log'] = $sfw_log;
67
+ update_option('cleantalk_data', $ct_data);
68
+ @setcookie ('ct_sfw_passed', '0', 1, "/");
69
+ }
70
+ //@$ct_data['sfw_log'][cleantalk_get_ip()]['all']++;
71
+ //update_option('cleantalk_data', $ct_data);
72
+ }
 
 
 
 
73
  if($is_sfw_check)
74
  {
75
  //include_once("cleantalk-sfw.php");
169
  if (is_admin()||is_network_admin())
170
  {
171
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-admin.php');
172
+ if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
173
+ add_action('admin_init', 'ct_admin_init', 1);
174
+ add_action('admin_menu', 'ct_admin_add_page');
175
+ if(is_network_admin())
176
+ {
177
+ add_action('network_admin_menu', 'ct_admin_add_page');
178
+ }
179
+ add_action('admin_notices', 'cleantalk_admin_notice_message');
180
+ }
181
+ if (defined( 'DOING_AJAX' ) && DOING_AJAX||isset($_POST['cma-action']))
 
182
  {
183
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
184
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-ajax.php');
185
  }
186
 
187
+ add_action('admin_enqueue_scripts', 'ct_enqueue_scripts');
188
+ if($pagenow=='edit-comments.php')
189
+ {
190
+ add_action('comment_unapproved_to_approvecomment', 'ct_comment_approved'); // param - comment object
191
+ add_action('comment_unapproved_to_approved', 'ct_comment_approved'); // param - comment object
192
+ add_action('comment_approved_to_unapproved', 'ct_comment_unapproved'); // param - comment object
193
+ add_action('comment_unapproved_to_spam', 'ct_comment_spam'); // param - comment object
194
+ add_action('comment_approved_to_spam', 'ct_comment_spam'); // param - comment object
195
+ //add_filter('get_comment_text', 'ct_get_comment_text'); // param - current comment text
196
+ add_filter('unspam_comment', 'ct_unspam_comment');
197
+ }
198
+ if($pagenow=='users.php')
199
+ {
200
+ add_action('delete_user', 'ct_delete_user');
201
+ }
202
+ if($pagenow=='plugins.php' || @strpos($_SERVER['REQUEST_URI'],'plugins.php')!==false)
203
+ {
204
+ add_filter('plugin_row_meta', 'ct_register_plugin_links', 10, 2);
205
+ add_filter('plugin_action_links', 'ct_plugin_action_links', 10, 2);
206
+ }
207
+ add_action('updated_option', 'ct_update_option'); // param - option name, i.e. 'cleantalk_settings'
208
  }else{
209
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
210
 
319
  print "\n<script type='text/javascript'>var ct_blog_home = '".get_home_url()."';</script>\n";
320
  print "<script async type='text/javascript' src='".plugins_url( '/inc/cleantalk_external.js' , __FILE__ )."?random=".$cleantalk_plugin_version."'></script>\n";
321
  }
 
322
  }
323
 
324
  function ct_add_nocache_script_header()
325
  {
326
+ print "\n<script type='text/javascript'>\nvar ct_ajaxurl = '".admin_url('admin-ajax.php')."';\n</script>\n";
 
 
 
 
 
 
 
 
 
 
 
327
  }
328
 
329
  function ct_inject_nocache_script($html)
330
  {
331
+ global $test_external_forms, $cleantalk_plugin_version;
 
 
 
 
 
 
 
 
 
332
  if(!is_admin()&&stripos($html,"</body")!==false)
333
  {
334
+ //$ct_replace.="\n<script type='text/javascript'>var ajaxurl = '".admin_url('admin-ajax.php')."';</script>\n";
335
  $ct_replace="<script async type='text/javascript' src='".plugins_url( '/inc/cleantalk_nocache.js' , __FILE__ )."?random=".$cleantalk_plugin_version."'></script>\n";
336
  if($test_external_forms)
337
  {
344
  }
345
  if(!is_admin()&&preg_match("#<head[^>]*>#i",$html)==1)
346
  {
347
+ $ct_replace="\n<script type='text/javascript'>\nvar ct_ajaxurl = '".admin_url('admin-ajax.php')."';\n</script>\n";
348
  $html=preg_replace("(<head[^>]*>)","$0".$ct_replace,$html,1);
349
  }
350
  return $html;
427
 
428
  function cleantalk_get_ip()
429
  {
 
430
  if ( function_exists( 'apache_request_headers' ) )
431
  {
432
  $headers = apache_request_headers();
438
  if ( array_key_exists( 'X-Forwarded-For', $headers ) )
439
  {
440
  $the_ip=explode(",", trim($headers['X-Forwarded-For']));
441
+ $the_ip = trim($the_ip[0]);
442
  }
443
+ elseif ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $headers ))
444
  {
445
  $the_ip=explode(",", trim($headers['HTTP_X_FORWARDED_FOR']));
446
+ $the_ip = trim($the_ip[0]);
447
+ }
448
+ else
449
+ {
450
+ $the_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 );
451
  }
 
 
452
  if(isset($_GET['sfw_test_ip']))
453
  {
454
+ $the_ip=$_GET['sfw_test_ip'];
455
  }
456
+ return $the_ip;
457
  }
458
 
459
  function ct_send_sfw_log()
inc/cleantalk-admin.php CHANGED
@@ -124,10 +124,8 @@ function ct_admin_init()
124
  'checkjs' => 1
125
  ));
126
  }
127
- if(isset($_POST['option_page'])&&$_POST['option_page']=='cleantalk_settings'&&isset($_POST['cleantalk_settings']['apikey']))
128
  {
129
- $ct_options['apikey']=$_POST['cleantalk_settings']['apikey'];
130
- update_option('cleantalk_settings', $ct_options);
131
  $ct_base_call_result = ct_base_call(array(
132
  'message' => 'This message is a test to check the connection to the CleanTalk servers. ',
133
  'example' => null,
@@ -138,7 +136,7 @@ function ct_admin_init()
138
  ));
139
  }
140
 
141
- if(@isset($_POST['cleantalk_settings']['spam_firewall']) && $_POST['cleantalk_settings']['spam_firewall']==1)
142
  {
143
  cleantalk_update_sfw();
144
  }
@@ -279,7 +277,7 @@ function ct_admin_init()
279
  }
280
 
281
  // Save next status request time
282
- $ct_data['next_account_status_check'] = time()+86400;
283
  update_option('cleantalk_data', $ct_data);
284
  }
285
 
@@ -586,12 +584,11 @@ function ct_input_apikey() {
586
  echo "<script src='".plugins_url( 'cleantalk-admin.js', __FILE__ )."'></script>\n";
587
  if (ct_valid_key($value) === false && !$is_wpmu) {
588
  echo "<script>var cleantalk_good_key=false;</script>";
 
589
  if (function_exists('curl_init') && function_exists('json_decode')) {
590
- 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>";
591
- echo '<br /><br /><input name="get_apikey_auto" type="submit" class="cleantalk_manual_link" value="' . __('Get access key automatically', 'cleantalk') . '" />';
592
-
593
- admin_addDescriptionsFields(sprintf(__('Admin e-mail (%s) will be used for registration', 'cleantalk'), get_option('admin_email')));
594
- admin_addDescriptionsFields(sprintf('<a target="__blank" style="color:#BBB;" href="https://cleantalk.org/publicoffer">%s</a>', __('License agreement', 'cleantalk')));
595
  }
596
  } else {
597
  echo "<script>var cleantalk_good_key=true;</script>";
@@ -1027,7 +1024,7 @@ function cleantalk_admin_notice_message(){
1027
  $show_notice = false;
1028
  }
1029
 
1030
- if ($show_notice && $show_ct_notice_trial && $value==1 && (is_network_admin() || is_admin())) {
1031
  echo '<div class="error"><h3>' . sprintf(__("%s trial period ends, please upgrade to %s!", 'cleantalk'), "<a href=\"options-general.php?page=cleantalk\">$ct_plugin_name</a>", "<a href=\"http://cleantalk.org/my/bill/recharge?utm_source=wp-backend&utm_medium=cpc&utm_campaign=WP%20backend%20trial$user_token\" target=\"_blank\"><b>premium version</b></a>") . '</h3></div>';
1032
  $show_notice = false;
1033
  }
@@ -1051,18 +1048,18 @@ function cleantalk_admin_notice_message(){
1051
  $link="?close_notice=1";
1052
  }
1053
 
1054
- if ($show_notice && $show_ct_notice_renew && $value==1 && time()>$next_notice_show && (is_network_admin() || is_admin())) {
1055
  $button_html = "<a href=\"http://cleantalk.org/my/bill/recharge?utm_source=wp-backend&utm_medium=cpc&utm_campaign=WP%20backend%20renew$user_token\" target=\"_blank\">" . '<input type="button" class="button button-primary" value="' . __('RENEW ANTI-SPAM', 'cleantalk') . '" />' . "</a>";
1056
  echo '<div class="updated"><a href="'.$link.'" style="text-decoration:none;float:right;font-size:16px;margin-top:5px;"><b>X</b></a><h3>' . sprintf(__("Please renew your anti-spam license for %s.", 'cleantalk'), "<a href=\"http://cleantalk.org/my/bill/recharge?utm_source=wp-backend&utm_medium=cpc&utm_campaign=WP%20backend%20renew$user_token\" target=\"_blank\"><b>" . __('next year', 'cleantalk') ."</b></a>") . '<br /><br />' . $button_html . '</h3></div>';
1057
  $show_notice = false;
1058
  }
1059
 
1060
- if ($show_notice && $show_ct_notice_online != '' && $value==1 && (is_network_admin() || is_admin())) {
1061
  if($show_ct_notice_online === 'Y'){
1062
- //echo '<div class="updated"><h3><b>';
1063
  //echo __("Don’t forget to disable CAPTCHA if you have it!", 'cleantalk');
1064
- //echo __("Settings updated!", 'cleantalk');
1065
- //echo '</b></h3></div>';
1066
  }
1067
 
1068
  if($show_ct_notice_online === 'N' && $value==1 && (is_network_admin() || (!defined('WP_ALLOW_MULTISITE')||defined('WP_ALLOW_MULTISITE')&&WP_ALLOW_MULTISITE==false) && is_admin())){
@@ -1259,7 +1256,7 @@ function ct_update_option($option_name) {
1259
  $ct_options['apikey'] = $api_key;
1260
  }
1261
 
1262
- if(@isset($_POST['cleantalk_settings']['spam_firewall']) && $_POST['cleantalk_settings']['spam_firewall']==1)
1263
  {
1264
  cleantalk_update_sfw();
1265
  }
@@ -1296,7 +1293,6 @@ function ct_update_option($option_name) {
1296
  require_once('cleantalk.class.php');
1297
  }
1298
  $result=sendRawRequest($url, $request);
1299
-
1300
  if ($result)
1301
  {
1302
  $result = json_decode($result, true);
124
  'checkjs' => 1
125
  ));
126
  }
127
+ if(isset($_POST['option_page'])&&$_POST['option_page']=='cleantalk_settings')
128
  {
 
 
129
  $ct_base_call_result = ct_base_call(array(
130
  'message' => 'This message is a test to check the connection to the CleanTalk servers. ',
131
  'example' => null,
136
  ));
137
  }
138
 
139
+ if(@isset($_POST['cleantalk_settings']['spam_firewall']) && $_POST['cleantalk_settings']['spam_firewall']==1 || isset($ct_options['spam_firewall']) && intval($ct_options['spam_firewall'])==1)
140
  {
141
  cleantalk_update_sfw();
142
  }
277
  }
278
 
279
  // Save next status request time
280
+ $ct_data['next_account_status_check'] = strtotime("+$notice_check_timeout hours", time());
281
  update_option('cleantalk_data', $ct_data);
282
  }
283
 
584
  echo "<script src='".plugins_url( 'cleantalk-admin.js', __FILE__ )."'></script>\n";
585
  if (ct_valid_key($value) === false && !$is_wpmu) {
586
  echo "<script>var cleantalk_good_key=false;</script>";
587
+ echo "<br /><br /><a target='__blank' class='cleantalk_manual_link' style='text-decoration:none;' href='https://cleantalk.org/register?platform=wordpress&email=".urlencode(get_option('admin_email'))."&website=".urlencode(parse_url(get_option('siteurl'),PHP_URL_HOST))."'>".__('Get the Access key', 'cleantalk')."</a>";
588
  if (function_exists('curl_init') && function_exists('json_decode')) {
589
+ //echo '<br /><br /><input name="get_apikey_auto" type="submit" class="cleantalk_manual_link" value="' . __('Get access key automatically', 'cleantalk') . '" />';
590
+ //admin_addDescriptionsFields(sprintf(__('Admin e-mail (%s) will be used for registration', 'cleantalk'), get_option('admin_email')));
591
+ //admin_addDescriptionsFields(sprintf('<a target="__blank" style="color:#BBB;" href="https://cleantalk.org/publicoffer">%s</a>', __('License agreement', 'cleantalk')));
 
 
592
  }
593
  } else {
594
  echo "<script>var cleantalk_good_key=true;</script>";
1024
  $show_notice = false;
1025
  }
1026
 
1027
+ if ($show_notice && $show_ct_notice_trial && $value==1 && (is_network_admin() || (!defined('WP_ALLOW_MULTISITE')||defined('WP_ALLOW_MULTISITE')&&WP_ALLOW_MULTISITE==false) && is_admin())) {
1028
  echo '<div class="error"><h3>' . sprintf(__("%s trial period ends, please upgrade to %s!", 'cleantalk'), "<a href=\"options-general.php?page=cleantalk\">$ct_plugin_name</a>", "<a href=\"http://cleantalk.org/my/bill/recharge?utm_source=wp-backend&utm_medium=cpc&utm_campaign=WP%20backend%20trial$user_token\" target=\"_blank\"><b>premium version</b></a>") . '</h3></div>';
1029
  $show_notice = false;
1030
  }
1048
  $link="?close_notice=1";
1049
  }
1050
 
1051
+ if ($show_notice && $show_ct_notice_renew && $value==1 && time()>$next_notice_show && (is_network_admin() || (!defined('WP_ALLOW_MULTISITE')||defined('WP_ALLOW_MULTISITE')&&WP_ALLOW_MULTISITE==false) && is_admin())) {
1052
  $button_html = "<a href=\"http://cleantalk.org/my/bill/recharge?utm_source=wp-backend&utm_medium=cpc&utm_campaign=WP%20backend%20renew$user_token\" target=\"_blank\">" . '<input type="button" class="button button-primary" value="' . __('RENEW ANTI-SPAM', 'cleantalk') . '" />' . "</a>";
1053
  echo '<div class="updated"><a href="'.$link.'" style="text-decoration:none;float:right;font-size:16px;margin-top:5px;"><b>X</b></a><h3>' . sprintf(__("Please renew your anti-spam license for %s.", 'cleantalk'), "<a href=\"http://cleantalk.org/my/bill/recharge?utm_source=wp-backend&utm_medium=cpc&utm_campaign=WP%20backend%20renew$user_token\" target=\"_blank\"><b>" . __('next year', 'cleantalk') ."</b></a>") . '<br /><br />' . $button_html . '</h3></div>';
1054
  $show_notice = false;
1055
  }
1056
 
1057
+ if ($show_notice && $show_ct_notice_online != '' && $value==1 && (is_network_admin() || (!defined('WP_ALLOW_MULTISITE')||defined('WP_ALLOW_MULTISITE')&&WP_ALLOW_MULTISITE==false) && is_admin())) {
1058
  if($show_ct_notice_online === 'Y'){
1059
+ echo '<div class="updated"><h3><b>';
1060
  //echo __("Don’t forget to disable CAPTCHA if you have it!", 'cleantalk');
1061
+ echo __("Settings updated!", 'cleantalk');
1062
+ echo '</b></h3></div>';
1063
  }
1064
 
1065
  if($show_ct_notice_online === 'N' && $value==1 && (is_network_admin() || (!defined('WP_ALLOW_MULTISITE')||defined('WP_ALLOW_MULTISITE')&&WP_ALLOW_MULTISITE==false) && is_admin())){
1256
  $ct_options['apikey'] = $api_key;
1257
  }
1258
 
1259
+ if(@isset($_POST['cleantalk_settings']['spam_firewall']) && $_POST['cleantalk_settings']['spam_firewall']==1 || isset($ct_options['spam_firewall']) && intval($ct_options['spam_firewall'])==1)
1260
  {
1261
  cleantalk_update_sfw();
1262
  }
1293
  require_once('cleantalk.class.php');
1294
  }
1295
  $result=sendRawRequest($url, $request);
 
1296
  if ($result)
1297
  {
1298
  $result = json_decode($result, true);
inc/cleantalk-ajax.php CHANGED
@@ -89,10 +89,6 @@ add_action( 'wp_ajax_tmpl_submit_form_recaptcha_validation', 'ct_ajax_hook',1 )
89
  /**hooks for cm answers pro */
90
  add_action( 'template_redirect', 'ct_ajax_hook',1 );
91
 
92
- /* hooks for ninja forms ajax*/
93
- add_action( 'wp_ajax_nopriv_ninja_forms_ajax_submit', 'ct_ajax_hook',1 );
94
- add_action( 'wp_ajax_ninja_forms_ajax_submit', 'ct_ajax_hook',1 );
95
-
96
  function ct_get_stats()
97
  {
98
  check_ajax_referer( 'ct_secret_nonce', 'security' );
@@ -450,11 +446,6 @@ function ct_ajax_hook()
450
  print $ct_result->comment;
451
  die();
452
  }
453
- else if($_POST['action']=='ninja_forms_ajax_submit')
454
- {
455
- print '{"form_id":'.$_POST['_form_id'].',"errors":false,"success":{"success_msg-Success":"'.$ct_result->comment.'"}}';
456
- die();
457
- }
458
  }
459
  }
460
  }
89
  /**hooks for cm answers pro */
90
  add_action( 'template_redirect', 'ct_ajax_hook',1 );
91
 
 
 
 
 
92
  function ct_get_stats()
93
  {
94
  check_ajax_referer( 'ct_secret_nonce', 'security' );
446
  print $ct_result->comment;
447
  die();
448
  }
 
 
 
 
 
449
  }
450
  }
451
  }
inc/cleantalk-comments-checkspam.js CHANGED
@@ -183,7 +183,6 @@ jQuery("#ct_check_spam_button").click(function(){
183
  jQuery('#ct_check_comments_table').hide();
184
  jQuery('#ct_delete_all').hide();
185
  jQuery('#ct_delete_checked').hide();
186
- jQuery('#ct_preloader').show();
187
  working=true;
188
  ct_show_info();
189
  });
183
  jQuery('#ct_check_comments_table').hide();
184
  jQuery('#ct_delete_all').hide();
185
  jQuery('#ct_delete_checked').hide();
 
186
  working=true;
187
  ct_show_info();
188
  });
inc/cleantalk-comments.php CHANGED
@@ -17,7 +17,6 @@ function ct_show_checkspam_page()
17
  <h2><?php _e("Anti-spam by CleanTalk", 'cleantalk'); ?></h2><br />
18
 
19
  <h3 id="ct_checking_status" style="text-align:center;width:90%;"></h3>
20
- <div style="text-align:center;width:100%;display:none;" id="ct_preloader"><img border=0 src="<?php print plugin_dir_url(__FILE__); ?>images/preloader.gif" /></div>
21
  <?php
22
  $args_spam = array(
23
  'meta_query' => array(
@@ -278,7 +277,6 @@ function ct_ajax_check_comments()
278
 
279
  $u=get_comments($args_unchecked);
280
  $u=array_slice($u,0,500);
281
- //$u=array_values($u);
282
  if(sizeof($u)>0)
283
  {
284
  //print_r($u);
@@ -301,6 +299,7 @@ function ct_ajax_check_comments()
301
  );
302
 
303
  $context = stream_context_create($opts);
 
304
  $result = @file_get_contents("https://api.cleantalk.org/?method_name=spam_check&auth_key=".$ct_options['apikey'], 0, $context);
305
  $result=json_decode($result);
306
  if(isset($result->error_message))
@@ -316,7 +315,7 @@ function ct_ajax_check_comments()
316
  if(empty($uip))continue;
317
  $uim=$u[$i]->comment_author_email;
318
  if(empty($uim))continue;
319
- if(isset($result->data->$uip) && $result->data->$uip->appears==1 || isset($result->data->$uim) && $result->data->$uim->appears==1)
320
  {
321
  add_comment_meta($u[$i]->comment_ID,'ct_marked_as_spam','1',true);
322
  }
17
  <h2><?php _e("Anti-spam by CleanTalk", 'cleantalk'); ?></h2><br />
18
 
19
  <h3 id="ct_checking_status" style="text-align:center;width:90%;"></h3>
 
20
  <?php
21
  $args_spam = array(
22
  'meta_query' => array(
277
 
278
  $u=get_comments($args_unchecked);
279
  $u=array_slice($u,0,500);
 
280
  if(sizeof($u)>0)
281
  {
282
  //print_r($u);
299
  );
300
 
301
  $context = stream_context_create($opts);
302
+
303
  $result = @file_get_contents("https://api.cleantalk.org/?method_name=spam_check&auth_key=".$ct_options['apikey'], 0, $context);
304
  $result=json_decode($result);
305
  if(isset($result->error_message))
315
  if(empty($uip))continue;
316
  $uim=$u[$i]->comment_author_email;
317
  if(empty($uim))continue;
318
+ if($result->data->$uip->appears==1||$result->data->$uim->appears==1)
319
  {
320
  add_comment_meta($u[$i]->comment_ID,'ct_marked_as_spam','1',true);
321
  }
inc/cleantalk-common.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- $ct_agent_version = 'wordpress-533';
4
  $ct_plugin_name = 'Anti-spam by CleanTalk';
5
  $ct_checkjs_frm = 'ct_checkjs_frm';
6
  $ct_checkjs_register_form = 'ct_checkjs_register_form';
@@ -143,7 +143,6 @@ function ct_base_call($params = array()) {
143
  if (array_key_exists('sender_info', $params)) {
144
  $sender_info = array_merge($sender_info, (array) $params['sender_info']);
145
  }
146
-
147
  $sender_info = json_encode($sender_info);
148
  if ($sender_info === false)
149
  $sender_info = '';
@@ -188,7 +187,7 @@ function ct_base_call($params = array()) {
188
  );
189
  }
190
 
191
- if(@intval($ct_result->errno) != 0)
192
  {
193
  if($params['checkjs']!=1)
194
  {
@@ -278,12 +277,6 @@ function get_sender_info() {
278
  'ssl_on' => $ct_options['ssl_on'],
279
  );*/
280
  $options2server=$ct_options;
281
- $js_info='';
282
- if(isset($_COOKIE['ct_user_info']))
283
- {
284
- $js_info=stripslashes(rawurldecode($_COOKIE['ct_user_info']));
285
- $js_info=mb_convert_encoding($js_info, "UTF-8", "Windows-1252");
286
- }
287
 
288
  return $sender_info = array(
289
  'page_url' => htmlspecialchars(@$_SERVER['SERVER_NAME'].@$_SERVER['REQUEST_URI']),
@@ -297,7 +290,6 @@ function get_sender_info() {
297
  'checkjs_data_cookies' => $checkjs_data_cookies,
298
  'ct_options' => json_encode($options2server),
299
  'fields_number' => sizeof($_POST),
300
- 'js_info' => $js_info,
301
  );
302
  }
303
 
1
  <?php
2
 
3
+ $ct_agent_version = 'wordpress-5311';
4
  $ct_plugin_name = 'Anti-spam by CleanTalk';
5
  $ct_checkjs_frm = 'ct_checkjs_frm';
6
  $ct_checkjs_register_form = 'ct_checkjs_register_form';
143
  if (array_key_exists('sender_info', $params)) {
144
  $sender_info = array_merge($sender_info, (array) $params['sender_info']);
145
  }
 
146
  $sender_info = json_encode($sender_info);
147
  if ($sender_info === false)
148
  $sender_info = '';
187
  );
188
  }
189
 
190
+ if($ct_result->errno != 0)
191
  {
192
  if($params['checkjs']!=1)
193
  {
277
  'ssl_on' => $ct_options['ssl_on'],
278
  );*/
279
  $options2server=$ct_options;
 
 
 
 
 
 
280
 
281
  return $sender_info = array(
282
  'page_url' => htmlspecialchars(@$_SERVER['SERVER_NAME'].@$_SERVER['REQUEST_URI']),
290
  'checkjs_data_cookies' => $checkjs_data_cookies,
291
  'ct_options' => json_encode($options2server),
292
  'fields_number' => sizeof($_POST),
 
293
  );
294
  }
295
 
inc/cleantalk-public.php CHANGED
@@ -1,5 +1,6 @@
1
  <?php
2
 
 
3
  /**
4
  * Init functions
5
  * @return mixed[] Array of options
@@ -316,7 +317,7 @@ setTimeout(function(){var ct_input_name = \'%s\';var ct_input_value = document.g
316
  function ct_is_user_enable() {
317
  global $current_user;
318
 
319
- /*if (!isset($current_user->roles)) {
320
  return true;
321
  }
322
 
@@ -326,8 +327,7 @@ function ct_is_user_enable() {
326
  return false;
327
  }
328
 
329
- return true;*/
330
- return !current_user_can('publish_posts');
331
  }
332
 
333
  /**
@@ -979,7 +979,6 @@ function ct_test_registration($nickname, $email, $ip){
979
  if ($sender_info === false) {
980
  $sender_info= '';
981
  }
982
-
983
 
984
  require_once('cleantalk.class.php');
985
  $config = get_option('cleantalk_server');
@@ -1118,7 +1117,7 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
1118
  )
1119
  );
1120
  }
1121
-
1122
  $ct_signup_done = true;
1123
 
1124
  if ($ct_result->errno != 0 && $ct_options['notice_api_errors']) {
@@ -1470,7 +1469,6 @@ function ct_si_contact_form_validate($form_errors = array(), $form_id_num = 0) {
1470
 
1471
  if ($ct_options['contact_forms_test'] == 0)
1472
  return $form_errors;
1473
- $sender_info='';
1474
 
1475
  $checkjs = js_test('ct_checkjs', $_POST, true);
1476
 
@@ -1494,7 +1492,6 @@ function ct_si_contact_form_validate($form_errors = array(), $form_id_num = 0) {
1494
 
1495
  if (isset($_POST['message']))
1496
  $message = $_POST['message'];
1497
-
1498
 
1499
  $ct_base_call_result = ct_base_call(array(
1500
  'message' => $subject . "\n\n" . $message,
@@ -1731,8 +1728,7 @@ function ct_contact_form_validate () {
1731
  isset($_POST['bbp_topic_content']) ||
1732
  isset($_POST['bbp_reply_content']) ||
1733
  isset($_COOKIE[LOGGED_IN_COOKIE]) ||
1734
- isset($_POST['fscf_submitted']) ||
1735
- strpos($_SERVER['REQUEST_URI'],'/wc-api/')!==false
1736
  ) {
1737
  return null;
1738
  }
@@ -1895,8 +1891,7 @@ function ct_contact_form_validate_postdata () {
1895
  @intval($ct_options['general_contact_forms_test'])==0 ||
1896
  isset($_POST['bbp_topic_content']) ||
1897
  isset($_POST['bbp_reply_content']) ||
1898
- isset($_POST['fscf_submitted']) ||
1899
- strpos($_SERVER['REQUEST_URI'],'/wc-api/')!==false
1900
  ) {
1901
  return null;
1902
  }
1
  <?php
2
 
3
+
4
  /**
5
  * Init functions
6
  * @return mixed[] Array of options
317
  function ct_is_user_enable() {
318
  global $current_user;
319
 
320
+ if (!isset($current_user->roles)) {
321
  return true;
322
  }
323
 
327
  return false;
328
  }
329
 
330
+ return true;
 
331
  }
332
 
333
  /**
979
  if ($sender_info === false) {
980
  $sender_info= '';
981
  }
 
982
 
983
  require_once('cleantalk.class.php');
984
  $config = get_option('cleantalk_server');
1117
  )
1118
  );
1119
  }
1120
+
1121
  $ct_signup_done = true;
1122
 
1123
  if ($ct_result->errno != 0 && $ct_options['notice_api_errors']) {
1469
 
1470
  if ($ct_options['contact_forms_test'] == 0)
1471
  return $form_errors;
 
1472
 
1473
  $checkjs = js_test('ct_checkjs', $_POST, true);
1474
 
1492
 
1493
  if (isset($_POST['message']))
1494
  $message = $_POST['message'];
 
1495
 
1496
  $ct_base_call_result = ct_base_call(array(
1497
  'message' => $subject . "\n\n" . $message,
1728
  isset($_POST['bbp_topic_content']) ||
1729
  isset($_POST['bbp_reply_content']) ||
1730
  isset($_COOKIE[LOGGED_IN_COOKIE]) ||
1731
+ isset($_POST['fscf_submitted'])
 
1732
  ) {
1733
  return null;
1734
  }
1891
  @intval($ct_options['general_contact_forms_test'])==0 ||
1892
  isset($_POST['bbp_topic_content']) ||
1893
  isset($_POST['bbp_reply_content']) ||
1894
+ isset($_POST['fscf_submitted'])
 
1895
  ) {
1896
  return null;
1897
  }
inc/cleantalk-sfw.class.php CHANGED
@@ -3,9 +3,6 @@ class CleanTalkSFW
3
  {
4
  public $ip = 0;
5
  public $ip_str = '';
6
- public $ip_array = Array();
7
- public $ip_str_array = Array();
8
- public $blocked_ip = '';
9
  public $result = false;
10
 
11
  public function cleantalk_get_real_ip()
@@ -22,74 +19,65 @@ class CleanTalkSFW
22
  {
23
  $the_ip=explode(",", trim($headers['X-Forwarded-For']));
24
  $the_ip = trim($the_ip[0]);
25
- $this->ip_str_array[]=$the_ip;
26
- $this->ip_array[]=sprintf("%u", ip2long($the_ip));
27
  }
28
- if ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $headers ))
29
  {
30
  $the_ip=explode(",", trim($headers['HTTP_X_FORWARDED_FOR']));
31
  $the_ip = trim($the_ip[0]);
32
- $this->ip_str_array[]=$the_ip;
33
- $this->ip_array[]=sprintf("%u", ip2long($the_ip));
34
  }
35
- $the_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 );
36
- $this->ip_str_array[]=$the_ip;
37
- $this->ip_array[]=sprintf("%u", ip2long($the_ip));
38
-
39
  if(isset($_GET['sfw_test_ip']))
40
  {
41
  $the_ip=$_GET['sfw_test_ip'];
42
- $this->ip_str_array[]=$the_ip;
43
- $this->ip_array[]=sprintf("%u", ip2long($the_ip));
44
  }
45
- //$this->ip_str=$the_ip;
46
- //$this->ip=sprintf("%u", ip2long($the_ip));
47
  //print sprintf("%u", ip2long($the_ip));
48
  }
49
 
50
  public function check_ip()
51
  {
52
  global $wpdb,$ct_options, $ct_data;
53
- $passed_ip='';
54
- for($i=0;$i<sizeof($this->ip_array);$i++)
 
 
 
 
 
 
55
  {
56
- //print "select network from `".$wpdb->base_prefix."cleantalk_sfw` where ".$this->ip." & mask = network;";
57
- //$r = $wpdb->get_results("select network from `".$wpdb->base_prefix."cleantalk_sfw` where network = ".$this->ip." & mask;", ARRAY_A);
58
- $r = $wpdb->get_results("select network from `".$wpdb->base_prefix."cleantalk_sfw` where network = ".$this->ip_array[$i]." & mask;", ARRAY_A);
59
 
60
- if(isset($ct_data['sfw_log']))
61
- {
62
- $sfw_log=$ct_data['sfw_log'];
63
- }
64
- else
65
- {
66
- $sfw_log=array();
67
- }
68
-
69
- if(sizeof($r)>0)
 
 
 
70
  {
71
- $this->result=true;
72
- $this->blocked_ip=$this->ip_str_array[$i];
73
- if(isset($sfw_log[$this->ip_str_array[$i]]))
74
- {
75
- $sfw_log[$this->ip_str_array[$i]]['all']++;
76
- }
77
- else
78
- {
79
- $sfw_log[$this->ip_str_array[$i]] = Array('datetime'=>time(), 'all' => 1, 'allow' => 0);
80
- }
81
  }
82
  else
83
  {
84
- //$sfw_log[$this->ip_str]['allow']++;
85
- //@setcookie ('ct_sfw_pass_key', md5($this->ip_str.$ct_options['apikey']), 0, "/");
86
- $passed_ip = $this->ip_str_array[$i];
87
  }
88
- //if($this->result)break;
89
  }
90
- if($passed_ip!='')
91
  {
92
- @setcookie ('ct_sfw_pass_key', md5($passed_ip.$ct_options['apikey']), 0, "/");
 
93
  }
94
  $ct_data['sfw_log'] = $sfw_log;
95
  update_option('cleantalk_data', $ct_data);
@@ -99,9 +87,9 @@ class CleanTalkSFW
99
  {
100
  global $ct_options, $ct_data;
101
  $sfw_die_page=file_get_contents(dirname(__FILE__)."/sfw_die_page.html");
102
- $sfw_die_page=str_replace("{REMOTE_ADDRESS}",$this->blocked_ip,$sfw_die_page);
103
  $sfw_die_page=str_replace("{REQUEST_URI}",$_SERVER['REQUEST_URI'],$sfw_die_page);
104
- $sfw_die_page=str_replace("{SFW_COOKIE}",md5($this->blocked_ip.$ct_options['apikey']),$sfw_die_page);
105
  @header('HTTP/1.0 403 Forbidden');
106
  wp_die( $sfw_die_page, "Blacklisted", Array('response'=>403) );
107
  }
3
  {
4
  public $ip = 0;
5
  public $ip_str = '';
 
 
 
6
  public $result = false;
7
 
8
  public function cleantalk_get_real_ip()
19
  {
20
  $the_ip=explode(",", trim($headers['X-Forwarded-For']));
21
  $the_ip = trim($the_ip[0]);
 
 
22
  }
23
+ elseif ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $headers ))
24
  {
25
  $the_ip=explode(",", trim($headers['HTTP_X_FORWARDED_FOR']));
26
  $the_ip = trim($the_ip[0]);
 
 
27
  }
28
+ else
29
+ {
30
+ $the_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 );
31
+ }
32
  if(isset($_GET['sfw_test_ip']))
33
  {
34
  $the_ip=$_GET['sfw_test_ip'];
 
 
35
  }
36
+ $this->ip_str=$the_ip;
37
+ $this->ip=sprintf("%u", ip2long($the_ip));
38
  //print sprintf("%u", ip2long($the_ip));
39
  }
40
 
41
  public function check_ip()
42
  {
43
  global $wpdb,$ct_options, $ct_data;
44
+ //print "select network from `".$wpdb->base_prefix."cleantalk_sfw` where ".$this->ip." & mask = network;";
45
+ $r = $wpdb->get_results("select network from `".$wpdb->base_prefix."cleantalk_sfw` where network = ".$this->ip." & mask;", ARRAY_A);
46
+
47
+ if(isset($ct_data['sfw_log']))
48
+ {
49
+ $sfw_log=$ct_data['sfw_log'];
50
+ }
51
+ else
52
  {
53
+ $sfw_log=array();
54
+ }
 
55
 
56
+ /*if(isset($sfw_log[$this->ip_str]))
57
+ {
58
+ $sfw_log[$this->ip_str]['all']++;
59
+ }
60
+ else
61
+ {
62
+ $sfw_log[$this->ip_str] = Array('datetime'=>time(), 'all' => 1, 'allow' => 0);
63
+ }*/
64
+
65
+ if(sizeof($r)>0)
66
+ {
67
+ $this->result=true;
68
+ if(isset($sfw_log[$this->ip_str]))
69
  {
70
+ $sfw_log[$this->ip_str]['all']++;
 
 
 
 
 
 
 
 
 
71
  }
72
  else
73
  {
74
+ $sfw_log[$this->ip_str] = Array('datetime'=>time(), 'all' => 1, 'allow' => 0);
 
 
75
  }
 
76
  }
77
+ else
78
  {
79
+ //$sfw_log[$this->ip_str]['allow']++;
80
+ @setcookie ('ct_sfw_pass_key', md5($this->ip_str.$ct_options['apikey']), 0, "/");
81
  }
82
  $ct_data['sfw_log'] = $sfw_log;
83
  update_option('cleantalk_data', $ct_data);
87
  {
88
  global $ct_options, $ct_data;
89
  $sfw_die_page=file_get_contents(dirname(__FILE__)."/sfw_die_page.html");
90
+ $sfw_die_page=str_replace("{REMOTE_ADDRESS}",$this->ip_str,$sfw_die_page);
91
  $sfw_die_page=str_replace("{REQUEST_URI}",$_SERVER['REQUEST_URI'],$sfw_die_page);
92
+ $sfw_die_page=str_replace("{SFW_COOKIE}",md5($this->ip_str.$ct_options['apikey']),$sfw_die_page);
93
  @header('HTTP/1.0 403 Forbidden');
94
  wp_die( $sfw_die_page, "Blacklisted", Array('response'=>403) );
95
  }
inc/cleantalk-users-checkspam.js CHANGED
@@ -212,7 +212,6 @@ jQuery("#ct_check_users_button").click(function(){
212
  jQuery('#ct_check_users_table').hide();
213
  jQuery('#ct_delete_all_users').hide();
214
  jQuery('#ct_delete_checked_users').hide();
215
- jQuery('#ct_preloader').show();
216
  working=true;
217
  ct_show_users_info();
218
  });
212
  jQuery('#ct_check_users_table').hide();
213
  jQuery('#ct_delete_all_users').hide();
214
  jQuery('#ct_delete_checked_users').hide();
 
215
  working=true;
216
  ct_show_users_info();
217
  });
inc/cleantalk-users.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  add_action('admin_menu', 'ct_add_users_menu');
3
 
4
  function ct_add_users_menu()
@@ -15,7 +16,7 @@ function ct_show_users_page()
15
  <div class="wrap">
16
  <h2><?php _e("Anti-spam by CleanTalk", 'cleantalk'); ?></h2><br />
17
  <?php
18
- /*$args_unchecked = array(
19
  'meta_query' => array(
20
  'relation' => 'AND',
21
  Array(
@@ -29,25 +30,28 @@ function ct_show_users_page()
29
  'compare' => 'NOT EXISTS'
30
  )
31
  )
32
- );*/
33
- global $wpdb;
34
- $r=$wpdb->get_results("select distinct count($wpdb->users.ID) as cnt from $wpdb->users inner join $wpdb->usermeta on $wpdb->users.ID=$wpdb->usermeta.user_id where $wpdb->usermeta.meta_key='ct_checked' or $wpdb->usermeta.meta_key='ct_hash';");
35
- $cnt_checked=$r[0]->cnt;
36
- $r=$wpdb->get_results("select count(ID) as cnt from $wpdb->users;");
37
- $cnt_all=$r[0]->cnt;
38
-
39
- $cnt_unchecked=$cnt_all-$cnt_checked;
40
- /*$args_spam = array(
41
  'meta_query' => array(
42
  Array(
43
  'key' => 'ct_marked_as_spam',
44
  'compare' => 'EXISTS'
45
  )
46
  )
47
- );*/
48
- $r=$wpdb->get_results("select distinct count($wpdb->users.ID) as cnt 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);
49
- $cnt_spam1=$r[0]['cnt'];
 
 
 
 
 
 
 
 
50
  ?>
 
51
  <div id="ct_working_message" style="margin:auto;padding:3px;width:70%;border:2px dotted gray;display:none;background:#ffff99;">
52
  <?php _e("Please wait for a while. CleanTalk is checking all users via blacklist database at cleantalk.org. You will have option to delete found spam users after plugin finish.", 'cleantalk'); ?>
53
  </div>
@@ -59,8 +63,18 @@ $cnt_spam1=$r[0]['cnt'];
59
  ?>
60
  </div>
61
  <h3 id="ct_checking_users_status" style="text-align:center;width:90%;"></h3>
62
- <div style="text-align:center;width:100%;display:none;" id="ct_preloader"><img border=0 src="<?php print plugin_dir_url(__FILE__); ?>images/preloader.gif" /></div>
63
  <?php
 
 
 
 
 
 
 
 
 
 
 
64
  $page=1;
65
  if(isset($_GET['spam_page']))
66
  {
@@ -79,7 +93,7 @@ $cnt_spam1=$r[0]['cnt'];
79
  );
80
 
81
  $c_spam=get_users($args_spam);
82
- if($cnt_spam1>0)
83
  {
84
  ?>
85
  <table class="widefat fixed comments" id="ct_check_users_table">
@@ -154,14 +168,25 @@ $cnt_spam1=$r[0]['cnt'];
154
  </tr>
155
  <?php
156
  }
157
- if($cnt_spam1>30)
 
 
 
 
 
 
 
 
 
 
 
158
  {
159
  ?>
160
  <tr class="comment even thread-even depth-1 approved">
161
  <td colspan="4">
162
  <?php
163
 
164
- $pages=ceil(intval($cnt_spam1)/30);
165
  for($i=1;$i<=$pages;$i++)
166
  {
167
  if($i==$page)
@@ -189,7 +214,7 @@ $cnt_spam1=$r[0]['cnt'];
189
  <br /><br />
190
  <div id="ct_info_message"><?php _e("Anti-spam by CleanTalk will check all users against blacklists database and show you senders that have spam activity on other websites. Just click 'Find spam users' to start.", 'cleantalk'); ?>
191
  <?php
192
- if($cnt_spam1>0)
193
  {
194
  print "<br />
195
  There is some differencies between blacklists database and our API mechanisms. Blacklists shows all history of spam activity, but our API (that used in spam checking) used another parameters, too: last day of activity, number of spam attacks during last days etc. This mechanisms help us to reduce number of false positivitie. So, there is nothing strange, if some emails/IPs will be not found by this checking.<br /><br />";
@@ -270,7 +295,7 @@ function ct_ajax_check_users()
270
  }
271
  else
272
  {
273
- $data[]='8.8.8.8';
274
  }
275
  $data[]=$u[$i]->data->user_email;
276
  }
@@ -311,12 +336,12 @@ function ct_ajax_check_users()
311
  {
312
  $uip='127.0.0.1';
313
  }
314
- if($uip=='127.0.0.1')continue;
315
  $uim=$u[$i]->data->user_email;
316
  if(empty($uim))continue;
317
 
318
  //print "uip: $uip, uim: $uim\n";
319
- if(isset($result->data->$uip) && $result->data->$uip->appears==1 || isset($result->data->$uim) && $result->data->$uim->appears==1)
320
  {
321
  update_user_meta($u[$i]->ID,'ct_marked_as_spam','1',true);
322
  }
@@ -336,18 +361,42 @@ add_action( 'wp_ajax_ajax_info_users', 'ct_ajax_info_users' );
336
  function ct_ajax_info_users()
337
  {
338
  check_ajax_referer( 'ct_secret_nonce', 'security' );
339
- global $wpdb;
340
- $r=$wpdb->get_results("select distinct count($wpdb->users.ID) as cnt from $wpdb->users inner join $wpdb->usermeta on $wpdb->users.ID=$wpdb->usermeta.user_id where $wpdb->usermeta.meta_key='ct_checked' or $wpdb->usermeta.meta_key='ct_hash';");
341
- $cnt_checked=$r[0]->cnt;
342
- $r=$wpdb->get_results("select count(ID) as cnt from $wpdb->users;");
343
- $cnt=$r[0]->cnt;
344
-
345
- $cnt_unchecked=$cnt_all-$cnt_checked;
346
-
347
- $r=$wpdb->get_results("select distinct count($wpdb->users.ID) as cnt 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);
348
- $cnt_spam1=$r[0]['cnt'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
 
350
- printf (__("Total users %s, checked %s, found %s spam users.", 'cleantalk'), $cnt, $cnt_checked, $cnt_spam1);
351
  die();
352
  }
353
 
@@ -434,5 +483,5 @@ function ct_ajax_clear_users()
434
  global $wpdb;
435
  $wpdb->query("delete from $wpdb->usermeta where meta_key='ct_hash' or meta_key='ct_checked' or meta_key='ct_marked_as_spam';");
436
  die();
437
- }
438
  ?>
1
  <?php
2
+
3
  add_action('admin_menu', 'ct_add_users_menu');
4
 
5
  function ct_add_users_menu()
16
  <div class="wrap">
17
  <h2><?php _e("Anti-spam by CleanTalk", 'cleantalk'); ?></h2><br />
18
  <?php
19
+ $args_unchecked = array(
20
  'meta_query' => array(
21
  'relation' => 'AND',
22
  Array(
30
  'compare' => 'NOT EXISTS'
31
  )
32
  )
33
+ );
34
+ $cnt_unchecked=sizeof(get_users($args_unchecked));
35
+ $args_spam = array(
 
 
 
 
 
 
36
  'meta_query' => array(
37
  Array(
38
  'key' => 'ct_marked_as_spam',
39
  'compare' => 'EXISTS'
40
  )
41
  )
42
+ );
43
+ $cnt_spam=sizeof(get_users($args_spam));
44
+ //if($cnt_unchecked>0)
45
+ {
46
+ ?>
47
+ </div>
48
+ <?php
49
+ }
50
+ ?>
51
+ <?php
52
+ //print '<button class="button" id="ct_insert_users">Insert users</button><br />';
53
  ?>
54
+
55
  <div id="ct_working_message" style="margin:auto;padding:3px;width:70%;border:2px dotted gray;display:none;background:#ffff99;">
56
  <?php _e("Please wait for a while. CleanTalk is checking all users via blacklist database at cleantalk.org. You will have option to delete found spam users after plugin finish.", 'cleantalk'); ?>
57
  </div>
63
  ?>
64
  </div>
65
  <h3 id="ct_checking_users_status" style="text-align:center;width:90%;"></h3>
 
66
  <?php
67
+ $args_spam = array(
68
+ 'meta_query' => array(
69
+ Array(
70
+ 'key' => 'ct_marked_as_spam',
71
+ 'compare' => 'EXISTS'
72
+ )
73
+ )
74
+ );
75
+ $cnt_spam=sizeof(get_users($args_spam));
76
+
77
+
78
  $page=1;
79
  if(isset($_GET['spam_page']))
80
  {
93
  );
94
 
95
  $c_spam=get_users($args_spam);
96
+ if($cnt_spam>0)
97
  {
98
  ?>
99
  <table class="widefat fixed comments" id="ct_check_users_table">
168
  </tr>
169
  <?php
170
  }
171
+ $args_spam = array(
172
+ 'meta_query' => array(
173
+ Array(
174
+ 'key' => 'ct_marked_as_spam',
175
+ 'value' => '1',
176
+ 'compare' => 'NUMERIC'
177
+ )
178
+
179
+ )
180
+ );
181
+ $cnt_spam=sizeof(get_users($args_spam));
182
+ if($cnt_spam>30)
183
  {
184
  ?>
185
  <tr class="comment even thread-even depth-1 approved">
186
  <td colspan="4">
187
  <?php
188
 
189
+ $pages=ceil(intval($cnt_spam)/30);
190
  for($i=1;$i<=$pages;$i++)
191
  {
192
  if($i==$page)
214
  <br /><br />
215
  <div id="ct_info_message"><?php _e("Anti-spam by CleanTalk will check all users against blacklists database and show you senders that have spam activity on other websites. Just click 'Find spam users' to start.", 'cleantalk'); ?>
216
  <?php
217
+ if($cnt_spam>0)
218
  {
219
  print "<br />
220
  There is some differencies between blacklists database and our API mechanisms. Blacklists shows all history of spam activity, but our API (that used in spam checking) used another parameters, too: last day of activity, number of spam attacks during last days etc. This mechanisms help us to reduce number of false positivitie. So, there is nothing strange, if some emails/IPs will be not found by this checking.<br /><br />";
295
  }
296
  else
297
  {
298
+ $data[]='127.0.0.1';
299
  }
300
  $data[]=$u[$i]->data->user_email;
301
  }
336
  {
337
  $uip='127.0.0.1';
338
  }
339
+ //if($uip=='127.0.0.1')continue;
340
  $uim=$u[$i]->data->user_email;
341
  if(empty($uim))continue;
342
 
343
  //print "uip: $uip, uim: $uim\n";
344
+ if($result->data->$uip->appears==1||$result->data->$uim->appears==1)
345
  {
346
  update_user_meta($u[$i]->ID,'ct_marked_as_spam','1',true);
347
  }
361
  function ct_ajax_info_users()
362
  {
363
  check_ajax_referer( 'ct_secret_nonce', 'security' );
364
+ $cnt=sizeof(get_users());
365
+
366
+ $args_spam = array(
367
+ 'meta_query' => array(
368
+ Array(
369
+ 'key' => 'ct_marked_as_spam',
370
+ //'value' => '1',
371
+ 'compare' => 'NUMERIC'
372
+ )
373
+ )
374
+ );
375
+
376
+ $cnt_spam=sizeof(get_users($args_spam));
377
+
378
+ $args_checked1=array(
379
+ 'meta_query' => array(
380
+ Array(
381
+ 'key' => 'ct_hash',
382
+ 'compare' => 'EXISTS'
383
+ )
384
+ )
385
+ );
386
+ $args_checked2=array(
387
+ 'meta_query' => array(
388
+ Array(
389
+ 'key' => 'ct_checked',
390
+ 'compare' => 'EXISTS'
391
+ )
392
+ )
393
+ );
394
+
395
+ $cnt_checked1=sizeof(get_users($args_checked1));
396
+ $cnt_checked2=sizeof(get_users($args_checked2));
397
+ $cnt_checked=$cnt_checked1+$cnt_checked2;
398
 
399
+ printf (__("Total users %s, checked %s, found %s spam users.", 'cleantalk'), $cnt, $cnt_checked, $cnt_spam);
400
  die();
401
  }
402
 
483
  global $wpdb;
484
  $wpdb->query("delete from $wpdb->usermeta where meta_key='ct_hash' or meta_key='ct_checked' or meta_key='ct_marked_as_spam';");
485
  die();
486
+ }
487
  ?>
inc/cleantalk_nocache.js CHANGED
@@ -130,80 +130,4 @@ if(ct_nocache_executed==undefined)
130
  //alert('set!');
131
  sendRequest(ct_ajaxurl+'?'+Math.random(),ct_callback,'action=ct_get_cookie');
132
  }
133
-
134
- if(ct_info_flag)
135
- {
136
-
137
- var cleantalk_user_info={};
138
-
139
- var cleantalk_screen_info={};
140
- for(var prop in screen)
141
- {
142
- if (navigator[prop] instanceof Object || screen[prop]==='') continue
143
- cleantalk_screen_info[prop]=screen[prop];
144
- }
145
-
146
- cleantalk_user_info.screen=cleantalk_screen_info;
147
-
148
- var cleantalk_plugins=Array();
149
- var prev
150
- var cnt=0;
151
- for(var i=0;i<navigator.plugins.length;i++)
152
- {
153
- var plugin = navigator.plugins[i];
154
- var plugin = plugin.name+" "+(plugin.version || '')
155
- if (prev == plugin ) continue;
156
- cleantalk_plugins[cnt]=plugin;
157
- cnt++;
158
- prev = plugin
159
- }
160
- cleantalk_user_info.plugins=cleantalk_plugins;
161
-
162
- cleantalk_user_info.timezone_offset = -new Date().getTimezoneOffset()/60;
163
- cleantalk_user_info.datetime = Math.round((new Date().getTime())/1000);
164
-
165
- cleantalk_user_info.browser_x=document.documentElement.clientWidth;
166
- cleantalk_user_info.browser_y=document.documentElement.clientHeight;
167
-
168
- var ua = navigator.userAgent.toLowerCase();
169
- var flashInstalled = 0;
170
- if (typeof(navigator.plugins)!="undefined"&&typeof(navigator.plugins["Shockwave Flash"])=="object")
171
- {
172
- flashInstalled = 1;
173
- }
174
- else if (typeof window.ActiveXObject != "undefined")
175
- {
176
- try
177
- {
178
- if (new ActiveXObject("ShockwaveFlash.ShockwaveFlash"))
179
- {
180
- flashInstalled = 1;
181
- }
182
- } catch(e) {};
183
- };
184
-
185
- cleantalk_user_info.is_flash=flashInstalled;
186
-
187
- isVisitedMain=-1;
188
- if(location.href=='http://'+location.hostname+'/' || location.href=='https://'+location.hostname+'/')
189
- {
190
- isVisitedMain=1;
191
- setTimeout(function() { document.cookie = "ct_visited_main = 1; path = /;"}, 500);
192
- }
193
-
194
-
195
- ct_visited_main = ct_getCookie('ct_visited_main');
196
- if(ct_visited_main==undefined && isVisitedMain==-1)
197
- {
198
- isVisitedMain=0;
199
- }
200
- else
201
- {
202
- isVisitedMain=1;
203
- }
204
-
205
- cleantalk_user_info.is_main=isVisitedMain;
206
-
207
- setTimeout(function() { document.cookie = "ct_user_info = "+escape(JSON.stringify(cleantalk_user_info))+"; path = /;"}, 500);
208
- }
209
  }
130
  //alert('set!');
131
  sendRequest(ct_ajaxurl+'?'+Math.random(),ct_callback,'action=ct_get_cookie');
132
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  }
inc/images/preloader.gif DELETED
Binary file
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: znaeff, shagimuratov, vlad-cleantalk
3
  Tags: anti-spam, antispam, bbpress, buddypress, captcha, capcha, captha, catcha, cf7 spam, comments, contact form spam, signup, spam, 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, math, security, login, blacklist, cache, prevent, 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
4
  Requires at least: 3.0
5
  Tested up to: 4.4
6
- Stable tag: 5.33
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -48,6 +48,7 @@ Plugin blocks spam emails via any themes (built-in) contact forms. With AJAX for
48
  * WordPress Landing Pages.
49
  * WP User Frontend.
50
  * Any WordPress form (option 'Custom contact forms'). 
 
51
 
52
  = Compatible with WordPress cache plugins =
53
  * W3 Total Cache, Quick Cache, WP Fastest Cache, Hyper Cache, WP Super cache and any other cache plugins.
@@ -373,6 +374,12 @@ WordPress 3.0 at least. PHP 5 with CURL or file_get_contents() function and enab
373
  1. CleanTalk works faster than most of the other anti-spam plugins.
374
 
375
  == Changelog ==
 
 
 
 
 
 
376
  = 5.33 2015-12-01 =
377
  * Backend interface fixes
378
  * Improved Spam FireWall efficiency
@@ -883,6 +890,12 @@ WordPress 3.0 at least. PHP 5 with CURL or file_get_contents() function and enab
883
  * First version
884
 
885
  == Upgrade Notice ==
 
 
 
 
 
 
886
  = 5.33 2015-12-01 =
887
  * Backend interface fixes
888
  * Improved Spam FireWall efficiency
3
  Tags: anti-spam, antispam, bbpress, buddypress, captcha, capcha, captha, catcha, cf7 spam, comments, contact form spam, signup, spam, 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, math, security, login, blacklist, cache, prevent, 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
4
  Requires at least: 3.0
5
  Tested up to: 4.4
6
+ Stable tag: 5.33.1
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
48
  * WordPress Landing Pages.
49
  * WP User Frontend.
50
  * Any WordPress form (option 'Custom contact forms'). 
51
+ * Any submission to site (option 'Check all POST data')
52
 
53
  = Compatible with WordPress cache plugins =
54
  * W3 Total Cache, Quick Cache, WP Fastest Cache, Hyper Cache, WP Super cache and any other cache plugins.
374
  1. CleanTalk works faster than most of the other anti-spam plugins.
375
 
376
  == Changelog ==
377
+ = 5.33.1 2015-12-04 =
378
+ * Fixed issue with BBPress
379
+ * Fixed anti-spam comments checking
380
+ * Fixed bulk checking
381
+ * Fixed trackback and pingback checking
382
+
383
  = 5.33 2015-12-01 =
384
  * Backend interface fixes
385
  * Improved Spam FireWall efficiency
890
  * First version
891
 
892
  == Upgrade Notice ==
893
+ = 5.33.1 2015-12-04 =
894
+ * Fixed issue with BBPress: restored old user permission checking mechanism
895
+ * Fixed anti-spam comments checking: sometimes get_comments returned wrong comments number
896
+ * Fixed bulk checking: made numeric indexes in users and comments arrays
897
+ * Fixed trackback and pingback checking: removed exception for checking
898
+
899
  = 5.33 2015-12-01 =
900
  * Backend interface fixes
901
  * Improved Spam FireWall efficiency