Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.27-classes

Version Description

Download this release

Release Info

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

Code changes from version 5.25.2 to 5.27-classes

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.25.2
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
10
- $cleantalk_plugin_version='5.252';
11
  $cleantalk_executed=false;
12
 
13
  if(defined('CLEANTALK_AJAX_USE_BUFFER'))
@@ -33,10 +33,43 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
33
  global $ct_options, $ct_data;
34
 
35
 
36
- require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-common.php');
37
- require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-widget.php');
38
  $ct_options=ct_get_options();
39
  $ct_data=ct_get_data();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  $jigo_version=@get_option('jigoshop_db_version', '');
41
  if($jigo_version=='')
42
  {
@@ -121,7 +154,7 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
121
 
122
  if (is_admin() && !isset($_GET['P3_HIDE_ADMIN_BAR']) && !isset($_POST['P3_HIDE_ADMIN_BAR']) && !isset($_POST['P3_NOCACHE']) && !isset($_GET['P3_NOCACHE']))
123
  {
124
- require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-admin.php');
125
  if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
126
  add_action('admin_init', 'ct_admin_init', 1);
127
  add_action('admin_menu', 'ct_admin_add_page');
@@ -129,8 +162,8 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
129
  }
130
  if (defined( 'DOING_AJAX' ) && DOING_AJAX||isset($_POST['cma-action']))
131
  {
132
- require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
133
- require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-ajax.php');
134
  }
135
 
136
  add_action('admin_enqueue_scripts', 'ct_enqueue_scripts');
@@ -146,7 +179,7 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
146
  add_filter('plugin_action_links', 'ct_plugin_action_links', 10, 2);
147
  add_action('updated_option', 'ct_update_option'); // param - option name, i.e. 'cleantalk_settings'
148
  }else{
149
- require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
150
 
151
  // Init action.
152
  //add_action('init', 'ct_init', 1);
@@ -179,6 +212,18 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
179
  if (!function_exists ( 'ct_activation')) {
180
  function ct_activation() {
181
  wp_schedule_event(time(), 'hourly', 'ct_hourly_event_hook' );
 
 
 
 
 
 
 
 
 
 
 
 
182
  add_option('ct_plugin_do_activation_redirect', true);
183
  }
184
  }
@@ -188,6 +233,8 @@ if (!function_exists ( 'ct_activation')) {
188
  if (!function_exists ( 'ct_deactivation')) {
189
  function ct_deactivation() {
190
  wp_clear_scheduled_hook( 'ct_hourly_event_hook' );
 
 
191
  }
192
  }
193
 
@@ -263,11 +310,11 @@ function ct_add_nocache_script()
263
  function ct_add_nocache_script_footer()
264
  {
265
  global $test_external_forms, $cleantalk_plugin_version;
266
- print "<script async type='text/javascript' src='".plugins_url( '/cleantalk_nocache.js' , __FILE__ )."?random=".$cleantalk_plugin_version."'></script>\n";
267
  if($test_external_forms)
268
  {
269
  print "\n<script type='text/javascript'>var ct_blog_home = '".get_home_url()."';</script>\n";
270
- print "<script async type='text/javascript' src='".plugins_url( '/cleantalk_external.js' , __FILE__ )."?random=".$cleantalk_plugin_version."'></script>\n";
271
  }
272
  }
273
 
@@ -282,11 +329,11 @@ function ct_inject_nocache_script($html)
282
  if(!is_admin()&&stripos($html,"</body")!==false)
283
  {
284
  //$ct_replace.="\n<script type='text/javascript'>var ajaxurl = '".admin_url('admin-ajax.php')."';</script>\n";
285
- $ct_replace="<script async type='text/javascript' src='".plugins_url( '/cleantalk_nocache.js' , __FILE__ )."?random=".$cleantalk_plugin_version."'></script>\n";
286
  if($test_external_forms)
287
  {
288
  $ct_replace.="\n<script type='text/javascript'>var ct_blog_home = '".get_home_url()."';</script>\n";
289
- $ct_replace.="<script async type='text/javascript' src='".plugins_url( '/cleantalk_external.js' , __FILE__ )."?random=".$cleantalk_plugin_version."'></script>\n";
290
  }
291
 
292
  //$html=str_ireplace("</body",$ct_replace."</body",$html);
@@ -301,8 +348,8 @@ function ct_inject_nocache_script($html)
301
  }
302
  if(is_admin())
303
  {
304
- require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-comments.php');
305
- require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-users.php');
306
  }
307
  if(isset($_GET['ait-action'])&&$_GET['ait-action']=='register')
308
  {
@@ -314,9 +361,133 @@ if(isset($_GET['ait-action'])&&$_GET['ait-action']=='register')
314
 
315
  function ct_show_comment_link()
316
  {
317
- print "<div style='font-size:10pt;'><a href='https://cleantalk.org/wordpress-anti-spam-plugin' target='_blank'>WordPress spam</a> blocked by CleanTalk.</div>";
318
  }
319
 
320
  add_action( 'right_now_content_table_end', 'my_add_counts_to_dashboard' );
321
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
  ?>
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.26
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
10
+ $cleantalk_plugin_version='5.26.1';
11
  $cleantalk_executed=false;
12
 
13
  if(defined('CLEANTALK_AJAX_USE_BUFFER'))
33
  global $ct_options, $ct_data;
34
 
35
 
36
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-common.php');
37
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-widget.php');
38
  $ct_options=ct_get_options();
39
  $ct_data=ct_get_data();
40
+
41
+ if(isset($ct_options['spam_firewall']))
42
+ {
43
+ $value = @intval($ct_options['spam_firewall']);
44
+ }
45
+ else
46
+ {
47
+ $value=0;
48
+ }
49
+
50
+ if($value==1 && (!isset($_POST) || isset($_POST) && sizeof($_POST)==0) && !is_admin() && stripos($_SERVER['REQUEST_URI'],'/wp-admin/')===false)
51
+ {
52
+ $is_sfw_check=true;
53
+ if(isset($_COOKIE['ct_sfw_pass_key']) && $_COOKIE['ct_sfw_pass_key']==md5(cleantalk_get_ip().$ct_options['apikey']))
54
+ {
55
+ $is_sfw_check=false;
56
+ @$ct_data['sfw_log'][cleantalk_get_ip()]['all']++;
57
+ update_option('cleantalk_data', $ct_data);
58
+ }
59
+ if($is_sfw_check)
60
+ {
61
+ //include_once("cleantalk-sfw.php");
62
+ include_once("inc/cleantalk-sfw.class.php");
63
+ $sfw = new CleanTalkSFW();
64
+ $sfw->cleantalk_get_real_ip();
65
+ $sfw->check_ip();
66
+ if($sfw->result)
67
+ {
68
+ $sfw->sfw_die();
69
+ }
70
+ }
71
+ }
72
+
73
  $jigo_version=@get_option('jigoshop_db_version', '');
74
  if($jigo_version=='')
75
  {
154
 
155
  if (is_admin() && !isset($_GET['P3_HIDE_ADMIN_BAR']) && !isset($_POST['P3_HIDE_ADMIN_BAR']) && !isset($_POST['P3_NOCACHE']) && !isset($_GET['P3_NOCACHE']))
156
  {
157
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-admin.php');
158
  if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
159
  add_action('admin_init', 'ct_admin_init', 1);
160
  add_action('admin_menu', 'ct_admin_add_page');
162
  }
163
  if (defined( 'DOING_AJAX' ) && DOING_AJAX||isset($_POST['cma-action']))
164
  {
165
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
166
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-ajax.php');
167
  }
168
 
169
  add_action('admin_enqueue_scripts', 'ct_enqueue_scripts');
179
  add_filter('plugin_action_links', 'ct_plugin_action_links', 10, 2);
180
  add_action('updated_option', 'ct_update_option'); // param - option name, i.e. 'cleantalk_settings'
181
  }else{
182
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
183
 
184
  // Init action.
185
  //add_action('init', 'ct_init', 1);
212
  if (!function_exists ( 'ct_activation')) {
213
  function ct_activation() {
214
  wp_schedule_event(time(), 'hourly', 'ct_hourly_event_hook' );
215
+ wp_schedule_event(time(), 'hourly', 'ct_send_sfw_log' );
216
+ wp_schedule_event(time(), 'daily', 'cleantalk_update_sfw' );
217
+
218
+
219
+ global $wpdb;
220
+ $wpdb->query("drop table if exists `".$wpdb->base_prefix."cleantalk_sfw`;");
221
+ $wpdb->query("CREATE TABLE IF NOT EXISTS `".$wpdb->base_prefix."cleantalk_sfw` (
222
+ `network` int(11) unsigned NOT NULL,
223
+ `mask` int(11) unsigned NOT NULL,
224
+ INDEX ( `network` , `mask` )
225
+ ) ENGINE = MYISAM ;");
226
+ cleantalk_update_sfw();
227
  add_option('ct_plugin_do_activation_redirect', true);
228
  }
229
  }
233
  if (!function_exists ( 'ct_deactivation')) {
234
  function ct_deactivation() {
235
  wp_clear_scheduled_hook( 'ct_hourly_event_hook' );
236
+ wp_clear_scheduled_hook( 'ct_send_sfw_log' );
237
+ wp_clear_scheduled_hook( 'cleantalk_update_sfw' );
238
  }
239
  }
240
 
310
  function ct_add_nocache_script_footer()
311
  {
312
  global $test_external_forms, $cleantalk_plugin_version;
313
+ print "<script async type='text/javascript' src='".plugins_url( '/inc/cleantalk_nocache.js' , __FILE__ )."?random=".$cleantalk_plugin_version."'></script>\n";
314
  if($test_external_forms)
315
  {
316
  print "\n<script type='text/javascript'>var ct_blog_home = '".get_home_url()."';</script>\n";
317
+ print "<script async type='text/javascript' src='".plugins_url( '/inc/cleantalk_external.js' , __FILE__ )."?random=".$cleantalk_plugin_version."'></script>\n";
318
  }
319
  }
320
 
329
  if(!is_admin()&&stripos($html,"</body")!==false)
330
  {
331
  //$ct_replace.="\n<script type='text/javascript'>var ajaxurl = '".admin_url('admin-ajax.php')."';</script>\n";
332
+ $ct_replace="<script async type='text/javascript' src='".plugins_url( '/inc/cleantalk_nocache.js' , __FILE__ )."?random=".$cleantalk_plugin_version."'></script>\n";
333
  if($test_external_forms)
334
  {
335
  $ct_replace.="\n<script type='text/javascript'>var ct_blog_home = '".get_home_url()."';</script>\n";
336
+ $ct_replace.="<script async type='text/javascript' src='".plugins_url( '/inc/cleantalk_external.js' , __FILE__ )."?random=".$cleantalk_plugin_version."'></script>\n";
337
  }
338
 
339
  //$html=str_ireplace("</body",$ct_replace."</body",$html);
348
  }
349
  if(is_admin())
350
  {
351
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-comments.php');
352
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-users.php');
353
  }
354
  if(isset($_GET['ait-action'])&&$_GET['ait-action']=='register')
355
  {
361
 
362
  function ct_show_comment_link()
363
  {
364
+ print "<div style='font-size:10pt;'><a href='https://cleantalk.org/wordpress-anti-spam-plugin' target='_blank'>".__( 'WordPress spam', 'cleantalk' )."</a> ".__( 'blocked by', 'cleantalk' )." CleanTalk.</div>";
365
  }
366
 
367
  add_action( 'right_now_content_table_end', 'my_add_counts_to_dashboard' );
368
 
369
+ function cleantalk_update_sfw()
370
+ {
371
+ if(!function_exists('sendRawRequest'))
372
+ {
373
+ require_once('inc/cleantalk.class.php');
374
+ }
375
+ global $ct_options, $ct_data, $wpdb;
376
+ if(isset($ct_options['spam_firewall']))
377
+ {
378
+ $value = @intval($ct_options['spam_firewall']);
379
+ }
380
+ else
381
+ {
382
+ $value=0;
383
+ }
384
+
385
+ if($value==1)
386
+ {
387
+ $data = Array( 'auth_key' => $ct_options['apikey'],
388
+ 'method_name' => '2s_blacklists_db'
389
+ );
390
+
391
+ $result=sendRawRequest('https://api.cleantalk.org/2.1', $data);
392
+ $result=json_decode($result, true);
393
+ if(!isset($result['error_no']))
394
+ {
395
+ $result=$result['data'];
396
+ $query="INSERT INTO `".$wpdb->base_prefix."cleantalk_sfw` VALUES ";
397
+ if(sizeof($result)>2000)
398
+ {
399
+ $wpdb->query("TRUNCATE TABLE `".$wpdb->base_prefix."cleantalk_sfw`;");
400
+ for($i=0;$i<sizeof($result);$i++)
401
+ {
402
+ if($i==sizeof($result)-1)
403
+ {
404
+ $query.="(".$result[$i][0].",".$result[$i][1].");";
405
+ }
406
+ else
407
+ {
408
+ $query.="(".$result[$i][0].",".$result[$i][1]."), ";
409
+ }
410
+ }
411
+ $wpdb->query($query);
412
+ }
413
+ }
414
+ }
415
+ }
416
+
417
+ function cleantalk_get_ip()
418
+ {
419
+ if ( function_exists( 'apache_request_headers' ) )
420
+ {
421
+ $headers = apache_request_headers();
422
+ }
423
+ else
424
+ {
425
+ $headers = $_SERVER;
426
+ }
427
+ if ( array_key_exists( 'X-Forwarded-For', $headers ) )
428
+ {
429
+ $the_ip=explode(",", trim($headers['X-Forwarded-For']));
430
+ $the_ip = trim($the_ip[0]);
431
+ }
432
+ elseif ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $headers ))
433
+ {
434
+ $the_ip=explode(",", trim($headers['HTTP_X_FORWARDED_FOR']));
435
+ $the_ip = trim($the_ip[0]);
436
+ }
437
+ else
438
+ {
439
+ $the_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 );
440
+ }
441
+ if(isset($_GET['sfw_test_ip']))
442
+ {
443
+ $the_ip=$_GET['sfw_test_ip'];
444
+ }
445
+ return $the_ip;
446
+ }
447
+
448
+ function ct_send_sfw_log()
449
+ {
450
+ /*global $ct_options, $ct_data;
451
+ $ct_options = ct_get_options();
452
+ $ct_data = ct_get_data();
453
+
454
+ if(isset($ct_options['spam_firewall']))
455
+ {
456
+ $value = @intval($ct_options['spam_firewall']);
457
+ }
458
+ else
459
+ {
460
+ $value=0;
461
+ }
462
+
463
+ if($value==1 && isset($ct_data['sfw_log']))
464
+ {
465
+ $sfw_log=$ct_data['sfw_log'];
466
+ $data=Array();
467
+ foreach($sfw_log as $key=>$value)
468
+ {
469
+ $data[]=Array($key, $value['block'], $value['allow']);
470
+ }
471
+ $qdata = array (
472
+ 'data' => json_encode($data),
473
+ 'rows' => count($data),
474
+ 'timestamp' => time()
475
+ );
476
+
477
+ $result = sendRawRequest('https://api.cleantalk.org/?method_name=sfw_logs&auth_key='.$ct_options['apikey'],$qdata);
478
+ $result = json_decode($result);
479
+ if(isset($result->data) && isset($result->data->rows))
480
+ {
481
+ if($result->data->rows == count($data))
482
+ {
483
+ $ct_data['sfw_log']=Array();
484
+ update_option('cleantalk_data', $ct_data);
485
+ }
486
+ }
487
+
488
+ }*/
489
+ include_once("inc/cleantalk-sfw.class.php");
490
+ $sfw = new CleanTalkSFW();
491
+ $sfw->send_logs();
492
+ }
493
  ?>
JSON.php → inc/JSON.php RENAMED
File without changes
cleantalk-admin.js → inc/cleantalk-admin.js RENAMED
File without changes
inc/cleantalk-admin.php ADDED
@@ -0,0 +1,1211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $ct_plugin_basename = 'cleantalk-spam-protect/cleantalk.php';
4
+ $ct_options=ct_get_options();
5
+ $ct_data=ct_get_data();
6
+
7
+
8
+
9
+ class CleanTalkAdmin
10
+ {
11
+ public $ct_data=null;
12
+ public $ct_options=null;
13
+ function __construct()
14
+ {
15
+ $this->ct_data=ct_get_data();
16
+ $this->ct_options = ct_get_options();
17
+ add_filter( 'activity_box_end', Array($this, 'cleantalk_custom_glance_items'), 10, 1 );
18
+ add_action( 'admin_print_footer_scripts', Array($this, 'ct_add_stats_js') );
19
+ add_action( 'wp_ajax_ajax_get_timezone', Array($this, 'ct_ajax_get_timezone') );
20
+ add_action( 'admin_bar_menu', Array($this, 'ct_add_admin_menu'), 999 );
21
+ }
22
+
23
+ public function cleantalk_custom_glance_items( )
24
+ {
25
+ global $ct_data;
26
+ $ct_data=ct_get_data();
27
+ if(!isset($ct_data['admin_blocked']))
28
+ {
29
+ $blocked=0;
30
+ }
31
+ else
32
+ {
33
+ $blocked=$ct_data['admin_blocked'];
34
+ }
35
+ if($blocked>0)
36
+ {
37
+ $blocked = number_format($blocked, 0, ',', ' ');
38
+ print "<div style='height:24px;width:100%;display:table-cell; vertical-align:middle;'><img src='" . plugin_dir_url(__FILE__) . "images/logo_color.png' style='margin-right:1em;vertical-align:middle;'/><span><a href='options-general.php?page=cleantalk'>CleanTalk</a> ";
39
+ printf(
40
+ /* translators: %s: Number of spam messages */
41
+ __( 'has blocked %s spam', 'cleantalk' ),
42
+ $blocked
43
+ );
44
+ print "</span></div>";
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Admin action 'admin_print_footer_scripts' - Enqueue admin script for checking if timezone offset is saved in settings
50
+ */
51
+
52
+ function ct_add_stats_js()
53
+ {
54
+ echo "<script src='".plugins_url( 'cleantalk-stats.js', __FILE__ )."'></script>\n";
55
+ }
56
+
57
+ /**
58
+ * Admin action 'wp_ajax_ajax_get_timezone' - Ajax method for getting timezone offset
59
+ */
60
+
61
+ function ct_ajax_get_timezone()
62
+ {
63
+ global $ct_data;
64
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
65
+ $ct_data = ct_get_data();
66
+ if(isset($_POST['offset']))
67
+ {
68
+ $ct_data['timezone'] = intval($_POST['offset']);
69
+ update_option('cleantalk_data', $ct_data);
70
+ }
71
+ }
72
+
73
+
74
+ public function ct_add_admin_menu( $wp_admin_bar ) {
75
+ // add a parent item
76
+ global $ct_options, $ct_data;
77
+
78
+ $ct_options = ct_get_options();
79
+ $ct_data = ct_get_data();
80
+
81
+ if(isset($ct_options['show_adminbar']))
82
+ {
83
+ $value = @intval($ct_options['show_adminbar']);
84
+ }
85
+ else
86
+ {
87
+ $value=1;
88
+ }
89
+
90
+ if ( current_user_can('activate_plugins')&&$value==1 )
91
+ {
92
+ //$ct_data=ct_get_data();
93
+ $args = array(
94
+ 'id' => 'ct_parent_node',
95
+ '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" alt="allowed / blocked"><span class="ab-label" id="ct_stats"><span>0</span> / <span>0</span></span></a>'
96
+ );
97
+ $wp_admin_bar->add_node( $args );
98
+
99
+ // add a child item to our parent item
100
+ $args = array(
101
+ 'id' => 'ct_dashboard_link',
102
+ 'title' => '<a href="https://cleantalk.org/my/?user_token='.@$ct_data['user_token'].'&utm_source=wp-backend&utm_medium=admin-bar" target="_blank">CleanTalk '.__('dashboard', 'cleantalk').'</a>',
103
+ 'parent' => 'ct_parent_node'
104
+ );
105
+ $wp_admin_bar->add_node( $args );
106
+
107
+ // add another child item to our parent item (not to our first group)
108
+ $args = array(
109
+ 'id' => 'ct_settings_link',
110
+ 'title' => '<a href="options-general.php?page=cleantalk">'.__('Settings', 'cleantalk').'</a>',
111
+ 'parent' => 'ct_parent_node'
112
+ );
113
+ $wp_admin_bar->add_node( $args );
114
+ }
115
+ }
116
+
117
+ }
118
+
119
+
120
+ if(isset($_GET['close_notice']))
121
+ {
122
+ global $ct_data, $pagenow;
123
+ $ct_data=ct_get_data();
124
+ $ct_data['next_notice_show']=time()+86400;
125
+ update_option('cleantalk_data', $ct_data);
126
+ $_SERVER["QUERY_STRING"]=str_replace("close_notice=1","",$_SERVER["QUERY_STRING"]);
127
+ header("Location: $pagenow?".$_SERVER["QUERY_STRING"]);
128
+ }
129
+
130
+ // Timeout to get app server
131
+ $ct_server_timeout = 10;
132
+
133
+
134
+
135
+ /**
136
+ * Admin action 'admin_enqueue_scripts' - Enqueue admin script of reloading admin page after needed AJAX events
137
+ * @param string $hook URL of hooked page
138
+ */
139
+ function ct_enqueue_scripts($hook) {
140
+ if ($hook == 'edit-comments.php')
141
+ wp_enqueue_script('ct_reload_script', plugins_url('/cleantalk-rel.js', __FILE__));
142
+ }
143
+
144
+ /**
145
+ * Admin action 'admin_menu' - Add the admin options page
146
+ */
147
+ function ct_admin_add_page() {
148
+ add_options_page(__('CleanTalk settings', 'cleantalk'), 'CleanTalk', 'manage_options', 'cleantalk', 'ct_settings_page');
149
+ }
150
+
151
+ /**
152
+ * Admin action 'admin_init' - Add the admin settings and such
153
+ */
154
+ function ct_admin_init() {
155
+ global $ct_server_timeout, $show_ct_notice_autokey, $ct_notice_autokey_label, $ct_notice_autokey_value, $show_ct_notice_renew, $ct_notice_renew_label, $show_ct_notice_trial, $ct_notice_trial_label, $show_ct_notice_online, $ct_notice_online_label, $renew_notice_showtime, $trial_notice_showtime, $ct_plugin_name, $ct_options, $ct_data, $trial_notice_check_timeout, $account_notice_check_timeout, $ct_user_token_label, $cleantalk_plugin_version, $notice_check_timeout;
156
+
157
+ $ct_options = ct_get_options();
158
+ $ct_data = ct_get_data();
159
+
160
+ $current_version=@trim($ct_data['current_version']);
161
+ if($current_version!=$cleantalk_plugin_version)
162
+ {
163
+ $ct_data['current_version']=$cleantalk_plugin_version;
164
+ update_option('cleantalk_data', $ct_data);
165
+ }
166
+
167
+ if(@isset($_POST['cleantalk_settings']['spam_firewall']) && $_POST['cleantalk_settings']['spam_firewall']==1 || isset($ct_options['spam_firewall']) && intval($ct_options['spam_firewall'])==1)
168
+ {
169
+ cleantalk_update_sfw();
170
+ }
171
+
172
+ $show_ct_notice_trial = false;
173
+ if (isset($_COOKIE[$ct_notice_trial_label])) {
174
+ if ($_COOKIE[$ct_notice_trial_label] == 1) {
175
+ $show_ct_notice_trial = true;
176
+ }
177
+ }
178
+ $show_ct_notice_renew = false;
179
+ if (isset($_COOKIE[$ct_notice_renew_label])) {
180
+ if ($_COOKIE[$ct_notice_renew_label] == 1) {
181
+ $show_ct_notice_renew = true;
182
+ }
183
+ }
184
+ $show_ct_notice_autokey = false;
185
+ if (isset($_COOKIE[$ct_notice_autokey_label]) && !empty($_COOKIE[$ct_notice_autokey_label])) {
186
+ if (!empty($_COOKIE[$ct_notice_autokey_label])) {
187
+ $show_ct_notice_autokey = true;
188
+ $ct_notice_autokey_value = base64_decode($_COOKIE[$ct_notice_autokey_label]);
189
+ setcookie($ct_notice_autokey_label, '', 1, '/');
190
+ }
191
+ }
192
+
193
+ if (isset($_POST['get_apikey_auto'])){
194
+ $email = get_option('admin_email');
195
+ $website = parse_url(get_option('siteurl'),PHP_URL_HOST);
196
+ $platform = 'wordpress';
197
+
198
+ if(!function_exists('getAutoKey'))
199
+ {
200
+ require_once('cleantalk.class.php');
201
+ }
202
+
203
+ $result = getAutoKey($email, $website, $platform);
204
+
205
+ if ($result)
206
+ {
207
+ $ct_data['next_account_status_check']=0;
208
+ update_option('cleantalk_data', $ct_data);
209
+ $result = json_decode($result, true);
210
+ if (isset($result['data']) && is_array($result['data']))
211
+ {
212
+ $result = $result['data'];
213
+ }
214
+ if(isset($result['user_token']))
215
+ {
216
+ $ct_data['user_token'] = $result['user_token'];
217
+ update_option('cleantalk_data', $ct_data);
218
+ }
219
+ if (isset($result['auth_key']) && !empty($result['auth_key']))
220
+ {
221
+ $_POST['cleantalk_settings']['apikey'] = $result['auth_key'];
222
+ $ct_options['apikey']=$result['auth_key'];
223
+ update_option('cleantalk_settings', $ct_options);
224
+ /*$ct_base_call_result = ct_base_call(array(
225
+ 'message' => 'CleanTalk setup test',
226
+ 'example' => null,
227
+ 'sender_email' => 'good@cleantalk.org',
228
+ 'sender_nickname' => 'CleanTalk',
229
+ 'post_info' => '',
230
+ 'checkjs' => 1
231
+ )); */
232
+ } else {
233
+ setcookie($ct_notice_autokey_label, (string) base64_encode($result['error_message']), 0, '/');
234
+ }
235
+ } else {
236
+ setcookie($ct_notice_autokey_label, (string) base64_encode(sprintf(__('Unable to connect to %s.', 'cleantalk'), 'api.cleantalk.org')), 0, '/');
237
+ }
238
+ }
239
+
240
+ if (time() > $ct_data['next_account_status_check']||
241
+ isset($_POST['option_page'])&&$_POST['option_page']=='cleantalk_settings'&&$ct_options['apikey']!=$_POST['cleantalk_settings']['apikey']) {
242
+ $result = false;
243
+ if (function_exists('curl_init') && function_exists('json_decode') && ct_valid_key($ct_options['apikey'])) {
244
+ if(!function_exists('noticePaidTill'))
245
+ {
246
+ require_once('cleantalk.class.php');
247
+ }
248
+ if(@isset($_POST['cleantalk_settings']['apikey']))
249
+ {
250
+ $result=noticePaidTill($_POST['cleantalk_settings']['apikey']);
251
+ }
252
+ else
253
+ {
254
+ $result=noticePaidTill($ct_options['apikey']);
255
+ }
256
+
257
+ if ($result) {
258
+ $result = json_decode($result, true);
259
+ if (isset($result['data']) && is_array($result['data'])) {
260
+ $result = $result['data'];
261
+ }
262
+ if(isset($result['spam_count']))
263
+ {
264
+ $ct_data['admin_blocked']=$result['spam_count'];
265
+ }
266
+
267
+ if (isset($result['show_notice'])) {
268
+ if ($result['show_notice'] == 1 && isset($result['trial']) && $result['trial'] == 1) {
269
+ $notice_check_timeout = $trial_notice_check_timeout;
270
+ $show_ct_notice_trial = true;
271
+ }
272
+ if ($result['show_notice'] == 1 && isset($result['renew']) && $result['renew'] == 1) {
273
+ $notice_check_timeout = $account_notice_check_timeout;
274
+ $show_ct_notice_renew = true;
275
+ }
276
+
277
+ if ($result['show_notice'] == 0) {
278
+ $notice_check_timeout = $account_notice_check_timeout;
279
+ }
280
+ }
281
+
282
+ if (isset($result['user_token'])) {
283
+ $ct_data['user_token'] = $result['user_token'];
284
+ }
285
+ }
286
+
287
+ // Save next status request time
288
+ $ct_data['next_account_status_check'] = strtotime("+$notice_check_timeout hours", time());
289
+ update_option('cleantalk_data', $ct_data);
290
+ }
291
+
292
+ if ($result) {
293
+ if($show_ct_notice_trial == true){
294
+ setcookie($ct_notice_trial_label, (string) $show_ct_notice_trial, strtotime("+$trial_notice_showtime minutes"), '/');
295
+ }
296
+ if($show_ct_notice_renew == true){
297
+ setcookie($ct_notice_renew_label, (string) $show_ct_notice_renew, strtotime("+$renew_notice_showtime minutes"), '/');
298
+ }
299
+ }
300
+ }
301
+
302
+ $show_ct_notice_online = '';
303
+ if (isset($_COOKIE[$ct_notice_online_label])) {
304
+ if ($_COOKIE[$ct_notice_online_label] === 'BAD_KEY') {
305
+ $show_ct_notice_online = 'N';
306
+ } else if (time() - $_COOKIE[$ct_notice_online_label] <= 5) {
307
+ $show_ct_notice_online = 'Y';
308
+ }
309
+ }
310
+
311
+ //ct_init_session();
312
+
313
+ if(stripos($_SERVER['REQUEST_URI'],'options.php')!==false || stripos($_SERVER['REQUEST_URI'],'options-general.php')!==false)
314
+ {
315
+
316
+ if(isset($ct_data['testing_failed'])&&$ct_data['testing_failed']==1)
317
+ {
318
+ $buttons_html='
319
+ <style type="text/css">
320
+ #ct_button_check_comments, #ct_button_check_users {background: #999999;}
321
+
322
+ ';
323
+ }
324
+ else
325
+ {
326
+ $buttons_html='
327
+ <style type="text/css">
328
+ #ct_button_check_comments, #ct_button_check_users {background: #69dd69;}
329
+
330
+ ';
331
+ }
332
+
333
+ $buttons_html.='
334
+ #ct_button_check_comments, #ct_button_check_users {padding: 10px; color: #fff; border:0 none;
335
+ cursor:pointer;
336
+ -webkit-border-radius: 5px;
337
+ border-radius: 5px;
338
+ font-size: 12pt;
339
+ text-decoration:none;
340
+ margin-bottom:5px;
341
+ display:inline-block;
342
+ }
343
+
344
+ #ct_stats_banner
345
+ {
346
+ padding: 0px;
347
+ color: #000;
348
+ /*border:2px solid #e5e5e5;*/
349
+ font-size: 10pt;
350
+ text-decoration:none;
351
+ margin-bottom:5px;
352
+ display:inline-block;
353
+ }
354
+ </style>';
355
+ if(isset($ct_data['testing_failed'])&&$ct_data['testing_failed']==1)
356
+ {
357
+ $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>
358
+ <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>';
359
+ }
360
+ else
361
+ {
362
+ $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 />
363
+ <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>';
364
+ }
365
+
366
+ register_setting('cleantalk_settings', 'cleantalk_settings', 'ct_settings_validate');
367
+ add_settings_section('cleantalk_settings_main', __($ct_plugin_name, 'cleantalk'), 'ct_section_settings_main', 'cleantalk');
368
+ add_settings_section('cleantalk_settings_state', "<hr>".__('Protection is active', 'cleantalk'), 'ct_section_settings_state', 'cleantalk');
369
+ //add_settings_section('cleantalk_settings_autodel', "<hr>", 'ct_section_settings_autodel', 'cleantalk');
370
+ add_settings_section('cleantalk_settings_banner', "<hr>Check existing comments and users <br /><br />$buttons_html<hr></h3>", '', 'cleantalk');
371
+ add_settings_section('cleantalk_settings_anti_spam', "<a href='#' style='text-decoration:underline;font-size:10pt;font-weight:400;'>".__('Advanced settings', 'cleantalk')."</a>", 'ct_section_settings_anti_spam', 'cleantalk');
372
+
373
+ add_settings_field('cleantalk_apikey', __('Access key', 'cleantalk'), 'ct_input_apikey', 'cleantalk', 'cleantalk_settings_main');
374
+ add_settings_field('cleantalk_remove_old_spam', __('Automatically delete spam comments', 'cleantalk'), 'ct_input_remove_old_spam', 'cleantalk', 'cleantalk_settings_anti_spam');
375
+
376
+ add_settings_field('cleantalk_registrations_test', __('Registration forms', 'cleantalk'), 'ct_input_registrations_test', 'cleantalk', 'cleantalk_settings_anti_spam');
377
+ add_settings_field('cleantalk_comments_test', __('Comments form', 'cleantalk'), 'ct_input_comments_test', 'cleantalk', 'cleantalk_settings_anti_spam');
378
+ add_settings_field('cleantalk_contact_forms_test', __('Contact forms', 'cleantalk'), 'ct_input_contact_forms_test', 'cleantalk', 'cleantalk_settings_anti_spam');
379
+ add_settings_field('cleantalk_general_contact_forms_test', __('Custom contact forms', 'cleantalk'), 'ct_input_general_contact_forms_test', 'cleantalk', 'cleantalk_settings_anti_spam');
380
+ add_settings_field('cleantalk_general_postdata_test', __('Check all post data', 'cleantalk'), 'ct_input_general_postdata_test', 'cleantalk', 'cleantalk_settings_anti_spam');
381
+ add_settings_field('cleantalk_show_adminbar', __('Show statistics in admin bar', 'cleantalk'), 'ct_input_show_adminbar', 'cleantalk', 'cleantalk_settings_anti_spam');
382
+ add_settings_field('cleantalk_use_ajax', __('Use AJAX for JavaScript check', 'cleantalk'), 'ct_input_use_ajax', 'cleantalk', 'cleantalk_settings_anti_spam');
383
+ add_settings_field('cleantalk_check_external', __('Protect external forms', 'cleantalk'), 'ct_input_check_external', 'cleantalk', 'cleantalk_settings_anti_spam');
384
+ add_settings_field('cleantalk_check_comments_number', __("Don't check comments", 'cleantalk'), 'ct_input_check_comments_number', 'cleantalk', 'cleantalk_settings_anti_spam');
385
+ //add_settings_field('cleantalk_check_messages_number', __("Don't check messages", 'cleantalk'), 'ct_input_check_messages_number', 'cleantalk', 'cleantalk_settings_anti_spam');
386
+ add_settings_field('cleantalk_show_link', __('', 'cleantalk'), 'ct_input_show_link', 'cleantalk', 'cleantalk_settings_banner');
387
+ add_settings_field('cleantalk_spam_firewall', __('', 'cleantalk'), 'ct_input_spam_firewall', 'cleantalk', 'cleantalk_settings_banner');
388
+ }
389
+ }
390
+
391
+ /**
392
+ * Admin callback function - Displays description of 'main' plugin parameters section
393
+ */
394
+ function ct_section_settings_main() {
395
+ return true;
396
+ }
397
+
398
+ /**
399
+ * Admin callback function - Displays description of 'anti-spam' plugin parameters section
400
+ */
401
+ function ct_section_settings_anti_spam() {
402
+ return true;
403
+ }
404
+
405
+
406
+ /**
407
+ * Admin callback function - Displays description of 'state' plugin parameters section
408
+ */
409
+ function ct_section_settings_state() {
410
+ global $ct_options, $ct_data;
411
+
412
+ $ct_options = ct_get_options();
413
+ $ct_data = ct_get_data();
414
+
415
+ $img="yes.png";
416
+ $img_no="no.png";
417
+ $color="black";
418
+ $test_failed=false;
419
+ //if(isset($ct_data['testing_failed'])&&$ct_data['testing_failed']==1)
420
+ if(trim($ct_options['apikey'])=='')
421
+ {
422
+ $img="yes_gray.png";
423
+ $img_no="no_gray.png";
424
+ $color="gray";
425
+ }
426
+ if(isset($ct_data['testing_failed'])&&$ct_data['testing_failed']==1)
427
+ {
428
+ $img="no.png";
429
+ $img_no="no.png";
430
+ $color="black";
431
+ $test_failed=true;
432
+ }
433
+ print "<div style='color:$color'>";
434
+ if($ct_options['registrations_test']==1)
435
+ {
436
+ print '<img src="' . plugin_dir_url(__FILE__) . 'images/'.$img.'" alt="" height="" /> '.__('Registration forms', 'cleantalk');
437
+ }
438
+ else
439
+ {
440
+ print '<img src="' . plugin_dir_url(__FILE__) . 'images/'.$img_no.'" alt="" height="" /> '.__('Registration forms', 'cleantalk');
441
+ }
442
+
443
+ if($ct_options['comments_test']==1)
444
+ {
445
+ print ' &nbsp; <img src="' . plugin_dir_url(__FILE__) . 'images/'.$img.'" alt="" height="" /> '.__('Comments form', 'cleantalk');
446
+ }
447
+ else
448
+ {
449
+ print ' &nbsp; <img src="' . plugin_dir_url(__FILE__) . 'images/'.$img_no.'" alt="" height="" /> '.__('Comments form', 'cleantalk');
450
+ }
451
+
452
+ if($ct_options['contact_forms_test']==1)
453
+ {
454
+ print ' &nbsp; <img src="' . plugin_dir_url(__FILE__) . 'images/'.$img.'" alt="" height="" /> '.__('Contact forms', 'cleantalk');
455
+ }
456
+ else
457
+ {
458
+ print ' &nbsp; <img src="' . plugin_dir_url(__FILE__) . 'images/'.$img_no.'" alt="" height="" /> '.__('Contact forms', 'cleantalk');
459
+ }
460
+
461
+ if($ct_options['general_contact_forms_test']==1)
462
+ {
463
+ print ' &nbsp; <img src="' . plugin_dir_url(__FILE__) . 'images/'.$img.'" alt="" height="" /> '.__('Custom contact forms', 'cleantalk');
464
+ }
465
+ else
466
+ {
467
+ print ' &nbsp; <img src="' . plugin_dir_url(__FILE__) . 'images/'.$img_no.'" alt="" height="" /> '.__('Custom contact forms', 'cleantalk');
468
+ }
469
+
470
+ print "</div>";
471
+ if($test_failed)
472
+ {
473
+ //print "Testing is failed, check settings. Tech support <a target=_blank href='mailto:support@cleantalk.org'>support@cleantalk.org</a>";
474
+ print __("Testing is failed, check settings. Tech support <a target=_blank href='mailto:support@cleantalk.org'>support@cleantalk.org</a>", 'cleantalk');
475
+ }
476
+ return true;
477
+ }
478
+
479
+ /**
480
+ * Admin callback function - Displays description of 'autodel' plugin parameters section
481
+ */
482
+ function ct_section_settings_autodel() {
483
+ return true;
484
+ }
485
+
486
+ /**
487
+ * Admin callback function - Displays inputs of 'apikey' plugin parameter
488
+ */
489
+ function ct_input_apikey() {
490
+ global $ct_options, $ct_data, $ct_notice_online_label;
491
+ $ct_options=ct_get_options();
492
+ $ct_data=ct_get_data();
493
+
494
+ if(!isset($ct_data['admin_blocked']))
495
+ {
496
+ $blocked=0;
497
+ }
498
+ else
499
+ {
500
+ $blocked=$ct_data['admin_blocked'];
501
+ }
502
+
503
+ if($blocked>0)
504
+ {
505
+ $blocked = number_format($blocked, 0, ',', ' ');
506
+
507
+ echo "<script>var cleantalk_blocked_message=\"<div style='height:24px;width:100%;display:table-cell; vertical-align:middle;'><span>CleanTalk ";
508
+ printf(
509
+ /* translators: %s: Number of spam messages */
510
+ __( 'has blocked <b>%s</b> spam.', 'cleantalk' ),
511
+ $blocked
512
+ );
513
+ print "</span></div><br />\";\n";
514
+ }
515
+ else
516
+ {
517
+ echo "<script>var cleantalk_blocked_message=\"\";\n";
518
+ }
519
+ echo "var cleantalk_statistics_link=\"<a target='__blank' href='https://cleantalk.org/my?user_token=".@$ct_data['user_token']."'>".__('Click here to get anti-spam statistics', 'cleantalk')."</a>\";
520
+ </script>";
521
+
522
+ echo "<script src='".plugins_url( 'cleantalk-admin.js', __FILE__ )."'></script>\n";
523
+
524
+ $value = $ct_options['apikey'];
525
+ $def_value = '';
526
+ echo "<input id='cleantalk_apikey' name='cleantalk_settings[apikey]' size='20' type='text' value='$value' style=\"font-size: 14pt;\"/>";
527
+ if (ct_valid_key($value) === false) {
528
+ echo "<script>var cleantalk_good_key=false;</script>";
529
+ echo "<a target='__blank' style='margin-left: 10px' 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>";
530
+ if (function_exists('curl_init') && function_exists('json_decode')) {
531
+ echo '<br /><br /><input name="get_apikey_auto" type="submit" value="' . __('Get access key automatically', 'cleantalk') . '" />';
532
+ admin_addDescriptionsFields(sprintf(__('Admin e-mail (%s) will be used for registration', 'cleantalk'), get_option('admin_email')));
533
+ admin_addDescriptionsFields(sprintf('<a target="__blank" style="color:#BBB;" href="https://cleantalk.org/publicoffer">%s</a>', __('License agreement', 'cleantalk')));
534
+ }
535
+ } else {
536
+ echo "<script>var cleantalk_good_key=true;</script>";
537
+ if (isset($_COOKIE[$ct_notice_online_label]) && $_COOKIE[$ct_notice_online_label] > 0) {
538
+ //echo '&nbsp;&nbsp;<span style="text-decoration: underline;">The key accepted!</span>&nbsp;';
539
+ }
540
+ //echo "<br /><br /><a target='__blank' href='https://cleantalk.org/my?user_token=".@$ct_data['user_token']."'>".__('Click here to get anti-spam statistics', 'cleantalk')."</a>";
541
+ }
542
+ }
543
+
544
+ /**
545
+ * Admin callback function - Displays inputs of 'comments_test' plugin parameter
546
+ */
547
+ function ct_input_comments_test() {
548
+ global $ct_options, $ct_data;
549
+
550
+ $ct_options = ct_get_options();
551
+ $ct_data = ct_get_data();
552
+
553
+ $value = $ct_options['comments_test'];
554
+ echo "<input type='radio' id='cleantalk_comments_test1' name='cleantalk_settings[comments_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_comments_test1'> " . __('Yes') . "</label>";
555
+ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
556
+ echo "<input type='radio' id='cleantalk_comments_test0' name='cleantalk_settings[comments_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_comments_test0'> " . __('No') . "</label>";
557
+ admin_addDescriptionsFields(__('WordPress, JetPack, WooCommerce', 'cleantalk'));
558
+ }
559
+
560
+ /**
561
+ * Admin callback function - Displays inputs of 'comments_test' plugin parameter
562
+ */
563
+ function ct_input_registrations_test() {
564
+ global $ct_options, $ct_data;
565
+
566
+ $ct_options = ct_get_options();
567
+ $ct_data = ct_get_data();
568
+
569
+ $value = $ct_options['registrations_test'];
570
+ echo "<input type='radio' id='cleantalk_registrations_test1' name='cleantalk_settings[registrations_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_registrations_test1'> " . __('Yes') . "</label>";
571
+ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
572
+ echo "<input type='radio' id='cleantalk_registrations_test0' name='cleantalk_settings[registrations_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_registrations_test0'> " . __('No') . "</label>";
573
+ admin_addDescriptionsFields(__('WordPress, BuddyPress, bbPress, S2Member, WooCommerce', 'cleantalk'));
574
+ }
575
+
576
+ /**
577
+ * Admin callback function - Displays inputs of 'contact_forms_test' plugin parameter
578
+ */
579
+ function ct_input_contact_forms_test() {
580
+ global $ct_options, $ct_data;
581
+
582
+ $ct_options = ct_get_options();
583
+ $ct_data = ct_get_data();
584
+
585
+ $value = $ct_options['contact_forms_test'];
586
+ echo "<input type='radio' id='cleantalk_contact_forms_test1' name='cleantalk_settings[contact_forms_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_contact_forms_test1'> " . __('Yes') . "</label>";
587
+ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
588
+ echo "<input type='radio' id='cleantalk_contact_forms_test0' name='cleantalk_settings[contact_forms_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_contact_forms_test0'> " . __('No') . "</label>";
589
+ admin_addDescriptionsFields(__('Contact Form 7, Formiadble forms, JetPack, Fast Secure Contact Form, WordPress Landing Pages', 'cleantalk'));
590
+ }
591
+
592
+ /**
593
+ * Admin callback function - Displays inputs of 'general_contact_forms_test' plugin parameter
594
+ */
595
+ function ct_input_general_contact_forms_test() {
596
+ global $ct_options, $ct_data;
597
+
598
+ $ct_options = ct_get_options();
599
+ $ct_data = ct_get_data();
600
+
601
+ $value = $ct_options['general_contact_forms_test'];
602
+ echo "<input type='radio' id='cleantalk_general_contact_forms_test1' name='cleantalk_settings[general_contact_forms_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_general_contact_forms_test1'> " . __('Yes') . "</label>";
603
+ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
604
+ echo "<input type='radio' id='cleantalk_general_contact_forms_test0' name='cleantalk_settings[general_contact_forms_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_general_contact_forms_test0'> " . __('No') . "</label>";
605
+ admin_addDescriptionsFields(__('Anti spam test for any WordPress or themes contacts forms', 'cleantalk'));
606
+ }
607
+
608
+ /**
609
+ * @author Artem Leontiev
610
+ * Admin callback function - Displays inputs of 'Publicate relevant comments' plugin parameter
611
+ *
612
+ * @return null
613
+ */
614
+ function ct_input_remove_old_spam() {
615
+ global $ct_options, $ct_data;
616
+
617
+ $ct_options = ct_get_options();
618
+ $ct_data = ct_get_data();
619
+
620
+ $value = $ct_options['remove_old_spam'];
621
+ echo "<input type='radio' id='cleantalk_remove_old_spam1' name='cleantalk_settings[remove_old_spam]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_remove_old_spam1'> " . __('Yes') . "</label>";
622
+ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
623
+ echo "<input type='radio' id='cleantalk_remove_old_spam0' name='cleantalk_settings[remove_old_spam]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_remove_old_spam0'> " . __('No') . "</label>";
624
+ admin_addDescriptionsFields(sprintf(__('Delete spam comments older than %d days.', 'cleantalk'), $ct_options['spam_store_days']));
625
+ }
626
+
627
+ /**
628
+ * Admin callback function - Displays inputs of 'Show statistics in adminbar' plugin parameter
629
+ *
630
+ * @return null
631
+ */
632
+ function ct_input_show_adminbar() {
633
+ global $ct_options, $ct_data;
634
+
635
+ $ct_options = ct_get_options();
636
+ $ct_data = ct_get_data();
637
+
638
+ if(isset($ct_options['show_adminbar']))
639
+ {
640
+ $value = @intval($ct_options['show_adminbar']);
641
+ }
642
+ else
643
+ {
644
+ $value=1;
645
+ }
646
+ echo "<input type='radio' id='cleantalk_show_adminbar1' name='cleantalk_settings[show_adminbar]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_show_adminbar1'> " . __('Yes') . "</label>";
647
+ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
648
+ echo "<input type='radio' id='cleantalk_show_adminbar0' name='cleantalk_settings[show_adminbar]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_show_adminbar0'> " . __('No') . "</label>";
649
+ admin_addDescriptionsFields(sprintf(__('Show/hide CleanTalk icon in top level menu in WordPress backend.', 'cleantalk'), $ct_options['show_adminbar']));
650
+ }
651
+
652
+ /**
653
+ * Admin callback function - Displays inputs of 'Show statistics in adminbar' plugin parameter
654
+ *
655
+ * @return null
656
+ */
657
+ function ct_input_general_postdata_test() {
658
+ global $ct_options, $ct_data;
659
+
660
+ $ct_options = ct_get_options();
661
+ $ct_data = ct_get_data();
662
+
663
+ if(isset($ct_options['general_postdata_test']))
664
+ {
665
+ $value = @intval($ct_options['general_postdata_test']);
666
+ }
667
+ else
668
+ {
669
+ $value=0;
670
+ }
671
+ echo "<input type='radio' id='cleantalk_general_postdata_test1' name='cleantalk_settings[general_postdata_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_general_postdata_test1'> " . __('Yes') . "</label>";
672
+ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
673
+ echo "<input type='radio' id='cleantalk_general_postdata_test0' name='cleantalk_settings[general_postdata_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_general_postdata_test0'> " . __('No') . "</label>";
674
+ @admin_addDescriptionsFields(sprintf(__('Check all POST submissions from website visitors. Enable this option if you have spam misses on website or you don`t have records about missed spam in <a href="https://cleantalk.org/my/?user_token='.@$ct_data['user_token'].'&utm_source=wp-backend&utm_medium=admin-bar" target="_blank">CleanTalk dashboard</a>.', 'cleantalk'), $ct_options['general_postdata_test']));
675
+ }
676
+
677
+ function ct_input_use_ajax() {
678
+ global $ct_options, $ct_data;
679
+
680
+ $ct_options = ct_get_options();
681
+ $ct_data = ct_get_data();
682
+
683
+ if(isset($ct_options['use_ajax']))
684
+ {
685
+ $value = @intval($ct_options['use_ajax']);
686
+ }
687
+ else
688
+ {
689
+ $value=1;
690
+ }
691
+ echo "<input type='radio' id='cleantalk_use_ajax1' name='cleantalk_settings[use_ajax]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_use_ajax1'> " . __('Yes') . "</label>";
692
+ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
693
+ echo "<input type='radio' id='cleantalk_use_ajax0' name='cleantalk_settings[use_ajax]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_use_ajax0'> " . __('No') . "</label>";
694
+ @admin_addDescriptionsFields(sprintf(__('', 'cleantalk'), $ct_options['use_ajax']));
695
+ }
696
+
697
+ function ct_input_check_comments_number() {
698
+ global $ct_options, $ct_data;
699
+
700
+ $ct_options = ct_get_options();
701
+ $ct_data = ct_get_data();
702
+
703
+ if(isset($ct_options['check_comments_number']))
704
+ {
705
+ $value = @intval($ct_options['check_comments_number']);
706
+ }
707
+ else
708
+ {
709
+ $value=1;
710
+ }
711
+
712
+ if(defined('CLEANTALK_CHECK_COMMENTS_NUMBER'))
713
+ {
714
+ $comments_check_number = CLEANTALK_CHECK_COMMENTS_NUMBER;
715
+ }
716
+ else
717
+ {
718
+ $comments_check_number = 3;
719
+ }
720
+
721
+ echo "<input type='radio' id='cleantalk_check_comments_number1' name='cleantalk_settings[check_comments_number]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_check_comments_number1'> " . __('Yes') . "</label>";
722
+ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
723
+ echo "<input type='radio' id='cleantalk_check_comments_number0' name='cleantalk_settings[check_comments_number]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_check_comments_number0'> " . __('No') . "</label>";
724
+ @admin_addDescriptionsFields(sprintf(__("Dont't check comments for users with above $comments_check_number comments", 'cleantalk'), $ct_options['check_comments_number']));
725
+ }
726
+
727
+ function ct_input_check_messages_number() {
728
+ global $ct_options, $ct_data;
729
+
730
+ $ct_options = ct_get_options();
731
+ $ct_data = ct_get_data();
732
+
733
+ if(isset($ct_options['check_messages_number']))
734
+ {
735
+ $value = @intval($ct_options['check_messages_number']);
736
+ }
737
+ else
738
+ {
739
+ $value=0;
740
+ }
741
+
742
+ if(defined('CLEANTALK_CHECK_MESSAGES_NUMBER'))
743
+ {
744
+ $messages_check_number = CLEANTALK_CHECK_MESSAGES_NUMBER;
745
+ }
746
+ else
747
+ {
748
+ $messages_check_number = 3;
749
+ }
750
+
751
+ echo "<input type='radio' id='cleantalk_check_messages_number1' name='cleantalk_settings[check_messages_number]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_check_messages_number1'> " . __('Yes') . "</label>";
752
+ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
753
+ echo "<input type='radio' id='cleantalk_check_messages_number0' name='cleantalk_settings[check_messages_number]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_check_messages_number0'> " . __('No') . "</label>";
754
+ @admin_addDescriptionsFields(sprintf(__("Dont't check messages for users with above $messages_check_number messages", 'cleantalk'), $ct_options['check_messages_number']));
755
+ }
756
+
757
+ function ct_input_check_external() {
758
+ global $ct_options, $ct_data;
759
+
760
+ $ct_options = ct_get_options();
761
+ $ct_data = ct_get_data();
762
+
763
+ if(isset($ct_options['check_external']))
764
+ {
765
+ $value = @intval($ct_options['check_external']);
766
+ }
767
+ else
768
+ {
769
+ $value=0;
770
+ }
771
+ echo "<input type='radio' id='cleantalk_check_external1' name='cleantalk_settings[check_external]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_check_external1'> " . __('Yes') . "</label>";
772
+ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
773
+ echo "<input type='radio' id='cleantalk_check_external0' name='cleantalk_settings[check_external]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_check_external0'> " . __('No') . "</label>";
774
+ @admin_addDescriptionsFields(sprintf(__('', 'cleantalk'), $ct_options['check_external']));
775
+ }
776
+
777
+ function ct_input_show_link() {
778
+ global $ct_options, $ct_data;
779
+
780
+ $ct_options = ct_get_options();
781
+ $ct_data = ct_get_data();
782
+
783
+ if(isset($ct_options['show_link']))
784
+ {
785
+ $value = @intval($ct_options['show_link']);
786
+ }
787
+ else
788
+ {
789
+ $value=0;
790
+ }
791
+
792
+ /* echo "<input type='radio' id='cleantalk_show_link1' name='cleantalk_settings[show_link]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_show_link1'> " . __('Yes') . "</label>";
793
+ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
794
+ echo "<input type='radio' id='cleantalk_show_link0' name='cleantalk_settings[show_link]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_show_link0'> " . __('No') . "</label>";*/
795
+
796
+ echo "<div id='cleantalk_anchor' style='display:none'></div><input type=hidden name='cleantalk_settings[show_link]' value='0' />";
797
+ echo "<input type='checkbox' id='cleantalk_show_link1' name='cleantalk_settings[show_link]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_show_link1'> " . __('Tell others about CleanTalk') . "</label>";
798
+ @admin_addDescriptionsFields(sprintf(__("Checking this box places a small link under the comment form that lets others know what anti-spam tool protects your site.", 'cleantalk'), $ct_options['show_link']));
799
+ echo "<script>
800
+ jQuery(document).ready(function(){
801
+ jQuery('#cleantalk_anchor').parent().parent().children().first().hide();
802
+ jQuery('#cleantalk_anchor').parent().css('padding-left','0px');
803
+ });
804
+ </script>";
805
+ }
806
+
807
+ function ct_input_spam_firewall() {
808
+ global $ct_options, $ct_data;
809
+
810
+ $ct_options = ct_get_options();
811
+ $ct_data = ct_get_data();
812
+
813
+ if(isset($ct_options['spam_firewall']))
814
+ {
815
+ $value = @intval($ct_options['spam_firewall']);
816
+ }
817
+ else
818
+ {
819
+ $value=0;
820
+ }
821
+
822
+ echo "<div id='cleantalk_anchor1' style='display:none'></div><input type=hidden name='cleantalk_settings[spam_firewall]' value='0' />";
823
+ echo "<input type='checkbox' id='cleantalk_spam_firewall1' name='cleantalk_settings[spam_firewall]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_spam_firewall1'> " . __('SpamFireWall') . "</label>";
824
+ @admin_addDescriptionsFields(sprintf(__("This option allows to filter spam bots before they access website. Also reduces CPU usage on hosting server and accelerates pages load time.", 'cleantalk'), $ct_options['spam_firewall']));
825
+ echo "<script>
826
+ jQuery(document).ready(function(){
827
+ jQuery('#cleantalk_anchor1').parent().parent().children().first().hide();
828
+ jQuery('#cleantalk_anchor1').parent().css('padding-left','0px');
829
+ });
830
+ </script>";
831
+ }
832
+
833
+
834
+ /**
835
+ * Admin callback function - Plugin parameters validator
836
+ */
837
+ function ct_settings_validate($input) {
838
+ return $input;
839
+ }
840
+
841
+
842
+ /**
843
+ * Admin callback function - Displays plugin options page
844
+ */
845
+ function ct_settings_page() {
846
+ ?>
847
+ <style type="text/css">
848
+ input[type=submit] {padding: 10px; background: #3399FF; color: #fff; border:0 none;
849
+ cursor:pointer;
850
+ -webkit-border-radius: 5px;
851
+ border-radius: 5px;
852
+ font-size: 12pt;
853
+ }
854
+ </style>
855
+
856
+ <div>
857
+ <form action="options.php" method="post">
858
+ <?php settings_fields('cleantalk_settings'); ?>
859
+ <?php do_settings_sections('cleantalk'); ?>
860
+ <br>
861
+ <input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes'); ?>" />
862
+ </form>
863
+ </div>
864
+ <?php
865
+
866
+ if (ct_valid_key() === false)
867
+ return null;
868
+ ?>
869
+ <br />
870
+ <br />
871
+ <br />
872
+ <div>
873
+ <?php echo __('Plugin Homepage at', 'cleantalk'); ?> <a href="http://cleantalk.org" target="_blank">cleantalk.org</a>.<br />
874
+ <?php echo __('Tech support CleanTalk:', 'cleantalk'); ?> <a href="https://cleantalk.org/forum/viewforum.php?f=25" target="_blank"><?php echo __('CleanTalk tech forum', 'cleantalk'); ?></a>.<br /><?php echo __('Use s@cleantalk.org to test plugin in any WordPress form.', 'cleantalk'); ?><br />
875
+ </div>
876
+ <?php
877
+ }
878
+
879
+ /**
880
+ * Notice blog owner if plugin is used without Access key
881
+ * @return bool
882
+ */
883
+ function cleantalk_admin_notice_message(){
884
+ global $show_ct_notice_trial, $show_ct_notice_renew, $show_ct_notice_online, $show_ct_notice_autokey, $ct_notice_autokey_value, $ct_plugin_name, $ct_options, $ct_data;
885
+
886
+ $ct_options = ct_get_options();
887
+ $ct_data = ct_get_data();
888
+
889
+ $user_token = '';
890
+ if (isset($ct_data['user_token']) && $ct_data['user_token'] != '') {
891
+ $user_token = '&user_token=' . $ct_data['user_token'];
892
+ }
893
+
894
+ $show_notice = true;
895
+
896
+ if(current_user_can('activate_plugins'))
897
+ {
898
+ $value = 1;
899
+ }
900
+ else
901
+ {
902
+ $value = 0;
903
+ }
904
+
905
+ if ($show_notice && $show_ct_notice_autokey && $value==1) {
906
+ echo '<div class="error"><h3>' . sprintf(__("Unable to get Access key automatically: %s", 'cleantalk'), $ct_notice_autokey_value);
907
+ echo " <a target='__blank' style='margin-left: 10px' 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></h3></div>';
908
+ }
909
+
910
+ if ($show_notice && ct_valid_key($ct_options['apikey']) === false && $value==1) {
911
+ echo '<div class="error"><h3>' . sprintf(__("Please enter Access Key in %s settings to enable anti spam protection!", 'cleantalk'), "<a href=\"options-general.php?page=cleantalk\">CleanTalk plugin</a>") . '</h3></div>';
912
+ $show_notice = false;
913
+ }
914
+
915
+ if ($show_notice && $show_ct_notice_trial && $value==1) {
916
+ 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>';
917
+ $show_notice = false;
918
+ }
919
+
920
+ if(isset($ct_data['next_notice_show']))
921
+ {
922
+ $next_notice_show=$ct_data['next_notice_show'];
923
+ }
924
+ else
925
+ {
926
+ $next_notice_show=0;
927
+ }
928
+
929
+ $link=@$_SERVER["QUERY_STRING"];
930
+ if($link!='')
931
+ {
932
+ $link="?".$link."&close_notice=1";
933
+ }
934
+ else
935
+ {
936
+ $link="?close_notice=1";
937
+ }
938
+
939
+ if ($show_notice && $show_ct_notice_renew && $value==1 && time()>$next_notice_show) {
940
+ $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>";
941
+ 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>';
942
+ $show_notice = false;
943
+ }
944
+
945
+ if ($show_notice && $show_ct_notice_online != '' && $value==1) {
946
+ if($show_ct_notice_online === 'Y'){
947
+ echo '<div class="updated"><h3><b>';
948
+ //echo __("Don’t forget to disable CAPTCHA if you have it!", 'cleantalk');
949
+ echo __("Settings updated!", 'cleantalk');
950
+ echo '</b></h3></div>';
951
+ }
952
+
953
+ if($show_ct_notice_online === 'N' && $value==1){
954
+ echo '<div class="error"><h3><b>';
955
+ echo __("Wrong <a href=\"options-general.php?page=cleantalk\"><b style=\"color: #49C73B;\">Clean</b><b style=\"color: #349ebf;\">Talk</b> access key</a>! Please check it or ask <a target=\"_blank\" href=\"https://cleantalk.org/forum/\">support</a>.", 'cleantalk');
956
+ echo '</b></h3></div>';
957
+ }
958
+ }
959
+
960
+ //ct_send_feedback(); -- removed to ct_do_this_hourly()
961
+
962
+ return true;
963
+ }
964
+
965
+ /**
966
+ * @author Artem Leontiev
967
+ *
968
+ * Add descriptions for field
969
+ */
970
+ function admin_addDescriptionsFields($descr = '') {
971
+ echo "<div style='font-size: 10pt; color: #666 !important'>$descr</div>";
972
+ }
973
+
974
+ /**
975
+ * Test API key
976
+ */
977
+ function ct_valid_key($apikey = null) {
978
+ global $ct_options, $ct_data;
979
+
980
+ $ct_options = ct_get_options();
981
+ $ct_data = ct_get_data();
982
+
983
+ if ($apikey === null) {
984
+ $apikey = $ct_options['apikey'];
985
+ }
986
+
987
+ return ($apikey === 'enter key' || $apikey === '') ? false : true;
988
+ }
989
+
990
+ /**
991
+ * Admin action 'comment_unapproved_to_approved' - Approve comment, sends good feedback to cleantalk, removes cleantalk resume
992
+ * @param object $comment_object Comment object
993
+ * @return boolean TRUE
994
+ */
995
+ function ct_comment_approved($comment_object) {
996
+ $comment = get_comment($comment_object->comment_ID, 'ARRAY_A');
997
+ $hash = get_comment_meta($comment_object->comment_ID, 'ct_hash', true);
998
+
999
+ $comment['comment_content'] = ct_unmark_red($comment['comment_content']);
1000
+ $comment['comment_content'] = ct_feedback($hash, $comment['comment_content'], 1);
1001
+ $comment['comment_approved'] = 1;
1002
+ wp_update_comment($comment);
1003
+
1004
+ return true;
1005
+ }
1006
+
1007
+ /**
1008
+ * Admin action 'comment_approved_to_unapproved' - Unapprove comment, sends bad feedback to cleantalk
1009
+ * @param object $comment_object Comment object
1010
+ * @return boolean TRUE
1011
+ */
1012
+ function ct_comment_unapproved($comment_object) {
1013
+ $comment = get_comment($comment_object->comment_ID, 'ARRAY_A');
1014
+ $hash = get_comment_meta($comment_object->comment_ID, 'ct_hash', true);
1015
+ ct_feedback($hash, $comment['comment_content'], 0);
1016
+ $comment['comment_approved'] = 0;
1017
+ wp_update_comment($comment);
1018
+
1019
+ return true;
1020
+ }
1021
+
1022
+ /**
1023
+ * Admin actions 'comment_unapproved_to_spam', 'comment_approved_to_spam' - Mark comment as spam, sends bad feedback to cleantalk
1024
+ * @param object $comment_object Comment object
1025
+ * @return boolean TRUE
1026
+ */
1027
+ function ct_comment_spam($comment_object) {
1028
+ $comment = get_comment($comment_object->comment_ID, 'ARRAY_A');
1029
+ $hash = get_comment_meta($comment_object->comment_ID, 'ct_hash', true);
1030
+ ct_feedback($hash, $comment['comment_content'], 0);
1031
+ $comment['comment_approved'] = 'spam';
1032
+ wp_update_comment($comment);
1033
+
1034
+ return true;
1035
+ }
1036
+
1037
+
1038
+ /**
1039
+ * Unspam comment
1040
+ * @param type $comment_id
1041
+ */
1042
+ function ct_unspam_comment($comment_id) {
1043
+ update_comment_meta($comment_id, '_wp_trash_meta_status', 1);
1044
+ $comment = get_comment($comment_id, 'ARRAY_A');
1045
+ $hash = get_comment_meta($comment_id, 'ct_hash', true);
1046
+ $comment['comment_content'] = ct_unmark_red($comment['comment_content']);
1047
+ $comment['comment_content'] = ct_feedback($hash, $comment['comment_content'], 1);
1048
+
1049
+ wp_update_comment($comment);
1050
+ }
1051
+
1052
+ /**
1053
+ * Admin filter 'get_comment_text' - Adds some info to comment text to display
1054
+ * @param string $current_text Current comment text
1055
+ * @return string New comment text
1056
+ */
1057
+ function ct_get_comment_text($current_text) {
1058
+ global $comment;
1059
+ $new_text = $current_text;
1060
+ if (isset($comment) && is_object($comment)) {
1061
+ $hash = get_comment_meta($comment->comment_ID, 'ct_hash', true);
1062
+ if (!empty($hash)) {
1063
+ $new_text .= '<hr>Cleantalk ID = ' . $hash;
1064
+ }
1065
+ }
1066
+ return $new_text;
1067
+ }
1068
+
1069
+ /**
1070
+ * Send feedback for user deletion
1071
+ * @return null
1072
+ */
1073
+ function ct_delete_user($user_id) {
1074
+ $hash = get_user_meta($user_id, 'ct_hash', true);
1075
+ if ($hash !== '') {
1076
+ ct_feedback($hash, null, 0);
1077
+ }
1078
+ }
1079
+
1080
+ /**
1081
+ * Manage links and plugins page
1082
+ * @return array
1083
+ */
1084
+ if (!function_exists ( 'ct_register_plugin_links')) {
1085
+ function ct_register_plugin_links($links, $file) {
1086
+ global $ct_plugin_basename;
1087
+
1088
+ if ($file == $ct_plugin_basename) {
1089
+ $links[] = '<a href="options-general.php?page=cleantalk">' . __( 'Settings' ) . '</a>';
1090
+ $links[] = '<a href="http://wordpress.org/plugins/cleantalk-spam-protect/faq/" target="_blank">' . __( 'FAQ','cleantalk' ) . '</a>';
1091
+ $links[] = '<a href="http://cleantalk.org/forum" target="_blank">' . __( 'Support','cleantalk' ) . '</a>';
1092
+ }
1093
+ return $links;
1094
+ }
1095
+ }
1096
+
1097
+ /**
1098
+ * Manage links in plugins list
1099
+ * @return array
1100
+ */
1101
+ if (!function_exists ( 'ct_plugin_action_links')) {
1102
+ function ct_plugin_action_links($links, $file) {
1103
+ global $ct_plugin_basename;
1104
+
1105
+ if ($file == $ct_plugin_basename) {
1106
+ $settings_link = '<a href="options-general.php?page=cleantalk">' . __( 'Settings' ) . '</a>';
1107
+ array_unshift( $links, $settings_link ); // before other links
1108
+ }
1109
+ return $links;
1110
+ }
1111
+ }
1112
+
1113
+ /**
1114
+ * After options update
1115
+ * @return array
1116
+ */
1117
+ function ct_update_option($option_name) {
1118
+ global $show_ct_notice_online, $ct_notice_online_label, $ct_notice_trial_label, $trial_notice_showtime, $ct_options, $ct_data, $ct_server_timeout;
1119
+
1120
+ $ct_options = ct_get_options(true);
1121
+ $ct_data = ct_get_data(true);
1122
+
1123
+ if($option_name !== 'cleantalk_settings') {
1124
+ return;
1125
+ }
1126
+
1127
+ $api_key = $ct_options['apikey'];
1128
+ if (isset($_POST['cleantalk_settings']['apikey'])) {
1129
+ $api_key = trim($_POST['cleantalk_settings']['apikey']);
1130
+ $ct_options['apikey'] = $api_key;
1131
+ }
1132
+
1133
+ if(@isset($_POST['cleantalk_settings']['spam_firewall']) && $_POST['cleantalk_settings']['spam_firewall']==1 || isset($ct_options['spam_firewall']) && intval($ct_options['spam_firewall'])==1)
1134
+ {
1135
+ cleantalk_update_sfw();
1136
+ }
1137
+
1138
+ if (!ct_valid_key($api_key)) {
1139
+ return;
1140
+ }
1141
+
1142
+ /*$ct_base_call_result = ct_base_call(array(
1143
+ 'message' => 'CleanTalk setup test',
1144
+ 'example' => null,
1145
+ 'sender_email' => 'good@cleantalk.org',
1146
+ 'sender_nickname' => 'CleanTalk',
1147
+ 'post_info' => '',
1148
+ 'checkjs' => 1
1149
+ ));*/
1150
+
1151
+ $key_valid = true;
1152
+ $app_server_error = false;
1153
+ $ct_data['testing_failed']=0;
1154
+
1155
+
1156
+ if(!function_exists('sendRawRequest'))
1157
+ {
1158
+ require_once('cleantalk.class.php');
1159
+ }
1160
+
1161
+ $request=Array();
1162
+ $request['method_name'] = 'notice_validate_key';
1163
+ $request['auth_key'] = $api_key;
1164
+ $url='https://api.cleantalk.org';
1165
+ if(!function_exists('sendRawRequest'))
1166
+ {
1167
+ require_once('cleantalk.class.php');
1168
+ }
1169
+ $result=sendRawRequest($url, $request);
1170
+ if ($result)
1171
+ {
1172
+ $result = json_decode($result, true);
1173
+ if (isset($result['valid']) && $result['valid'] == 0) {
1174
+ $key_valid = false;
1175
+ $ct_data['testing_failed']=1;
1176
+ }
1177
+ }
1178
+ if (!$result || !isset($result['valid']))
1179
+ {
1180
+ $app_server_error = true;
1181
+ $ct_data['testing_failed']=1;
1182
+ }
1183
+
1184
+ update_option('cleantalk_data', $ct_data);
1185
+
1186
+ if ($key_valid) {
1187
+ // Removes cookie for server errors
1188
+ if ($app_server_error) {
1189
+ setcookie($ct_notice_online_label, '', 1, '/'); // time 1 is exactly in past even clients time() is wrong
1190
+ unset($_COOKIE[$ct_notice_online_label]);
1191
+ } else {
1192
+ setcookie($ct_notice_online_label, (string) time(), strtotime("+14 days"), '/');
1193
+ }
1194
+ setcookie($ct_notice_trial_label, '0', strtotime("+$trial_notice_showtime minutes"), '/');
1195
+ } else {
1196
+ setcookie($ct_notice_online_label, 'BAD_KEY', 0, '/');
1197
+ }
1198
+ }
1199
+
1200
+ /**
1201
+ * Unmark bad words
1202
+ * @param string $message
1203
+ * @return string Cleat comment
1204
+ */
1205
+ function ct_unmark_red($message) {
1206
+ $message = preg_replace("/\<font rel\=\"cleantalk\" color\=\"\#FF1000\"\>(\S+)\<\/font>/iu", '$1', $message);
1207
+
1208
+ return $message;
1209
+ }
1210
+
1211
+ ?>
cleantalk-admin.php → inc/cleantalk-admin_old.php RENAMED
@@ -20,11 +20,16 @@ function cleantalk_custom_glance_items( )
20
  if($blocked>0)
21
  {
22
  $blocked = number_format($blocked, 0, ',', ' ');
23
- print "<div style='height:24px;width:100%;display:table-cell; vertical-align:middle;'><img src='" . plugin_dir_url(__FILE__) . "inc/images/logo_color.png' style='margin-right:1em;vertical-align:middle;'/><span><a href='options-general.php?page=cleantalk'>CleanTalk</a> has blocked $blocked spam.</span></div>";
 
 
 
 
 
 
24
  }
25
  }
26
 
27
-
28
  if(isset($_GET['close_notice']))
29
  {
30
  global $ct_data, $pagenow;
@@ -122,6 +127,11 @@ function ct_admin_init() {
122
  'checkjs' => 1
123
  ));*/
124
  }
 
 
 
 
 
125
 
126
  $show_ct_notice_trial = false;
127
  if (isset($_COOKIE[$ct_notice_trial_label])) {
@@ -338,7 +348,7 @@ function ct_admin_init() {
338
  add_settings_field('cleantalk_check_comments_number', __("Don't check comments", 'cleantalk'), 'ct_input_check_comments_number', 'cleantalk', 'cleantalk_settings_anti_spam');
339
  //add_settings_field('cleantalk_check_messages_number', __("Don't check messages", 'cleantalk'), 'ct_input_check_messages_number', 'cleantalk', 'cleantalk_settings_anti_spam');
340
  add_settings_field('cleantalk_show_link', __('', 'cleantalk'), 'ct_input_show_link', 'cleantalk', 'cleantalk_settings_banner');
341
- //add_settings_field('cleantalk_spam_firewall', __('', 'cleantalk'), 'ct_input_spam_firewall', 'cleantalk', 'cleantalk_settings_banner');
342
  }
343
  }
344
 
@@ -379,14 +389,14 @@ function ct_add_admin_menu( $wp_admin_bar ) {
379
  //$ct_data=ct_get_data();
380
  $args = array(
381
  'id' => 'ct_parent_node',
382
- 'title' => '<img src="' . plugin_dir_url(__FILE__) . 'inc/images/logo_small1.png" alt="" height="" style="margin-top:9px;" /><a href="#" class="ab-item alignright" title="allowed / blocked" alt="allowed / blocked"><span class="ab-label" id="ct_stats"><span>0</span> / <span>0</span></span></a>'
383
  );
384
  $wp_admin_bar->add_node( $args );
385
 
386
  // add a child item to our parent item
387
  $args = array(
388
  'id' => 'ct_dashboard_link',
389
- 'title' => '<a href="https://cleantalk.org/my/?user_token='.@$ct_data['user_token'].'&utm_source=wp-backend&utm_medium=admin-bar" target="_blank">CleanTalk dashboard</a>',
390
  'parent' => 'ct_parent_node'
391
  );
392
  $wp_admin_bar->add_node( $args );
@@ -394,7 +404,7 @@ function ct_add_admin_menu( $wp_admin_bar ) {
394
  // add another child item to our parent item (not to our first group)
395
  $args = array(
396
  'id' => 'ct_settings_link',
397
- 'title' => '<a href="options-general.php?page=cleantalk">Settings</a>',
398
  'parent' => 'ct_parent_node'
399
  );
400
  $wp_admin_bar->add_node( $args );
@@ -431,38 +441,38 @@ function ct_section_settings_state() {
431
  print "<div style='color:$color'>";
432
  if($ct_options['registrations_test']==1)
433
  {
434
- print '<img src="' . plugin_dir_url(__FILE__) . 'inc/images/'.$img.'" alt="" height="" /> '.__('Registration forms', 'cleantalk');
435
  }
436
  else
437
  {
438
- print '<img src="' . plugin_dir_url(__FILE__) . 'inc/images/'.$img_no.'" alt="" height="" /> '.__('Registration forms', 'cleantalk');
439
  }
440
 
441
  if($ct_options['comments_test']==1)
442
  {
443
- print ' &nbsp; <img src="' . plugin_dir_url(__FILE__) . 'inc/images/'.$img.'" alt="" height="" /> '.__('Comments form', 'cleantalk');
444
  }
445
  else
446
  {
447
- print ' &nbsp; <img src="' . plugin_dir_url(__FILE__) . 'inc/images/'.$img_no.'" alt="" height="" /> '.__('Comments form', 'cleantalk');
448
  }
449
 
450
  if($ct_options['contact_forms_test']==1)
451
  {
452
- print ' &nbsp; <img src="' . plugin_dir_url(__FILE__) . 'inc/images/'.$img.'" alt="" height="" /> '.__('Contact forms', 'cleantalk');
453
  }
454
  else
455
  {
456
- print ' &nbsp; <img src="' . plugin_dir_url(__FILE__) . 'inc/images/'.$img_no.'" alt="" height="" /> '.__('Contact forms', 'cleantalk');
457
  }
458
 
459
  if($ct_options['general_contact_forms_test']==1)
460
  {
461
- print ' &nbsp; <img src="' . plugin_dir_url(__FILE__) . 'inc/images/'.$img.'" alt="" height="" /> '.__('Custom contact forms', 'cleantalk');
462
  }
463
  else
464
  {
465
- print ' &nbsp; <img src="' . plugin_dir_url(__FILE__) . 'inc/images/'.$img_no.'" alt="" height="" /> '.__('Custom contact forms', 'cleantalk');
466
  }
467
 
468
  print "</div>";
@@ -502,7 +512,13 @@ function ct_input_apikey() {
502
  {
503
  $blocked = number_format($blocked, 0, ',', ' ');
504
 
505
- echo "<script>var cleantalk_blocked_message=\"<div style='height:24px;width:100%;display:table-cell; vertical-align:middle;'><span>CleanTalk has blocked <b>$blocked</b> spam.</span></div><br />\";\n";
 
 
 
 
 
 
506
  }
507
  else
508
  {
@@ -786,8 +802,8 @@ function ct_input_show_link() {
786
  echo "<input type='radio' id='cleantalk_show_link0' name='cleantalk_settings[show_link]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_show_link0'> " . __('No') . "</label>";*/
787
 
788
  echo "<div id='cleantalk_anchor' style='display:none'></div><input type=hidden name='cleantalk_settings[show_link]' value='0' />";
789
- echo "<input type='checkbox' id='cleantalk_show_link1' name='cleantalk_settings[show_link]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_show_link1'> " . __('Help others known CleanTalk') . "</label>";
790
- @admin_addDescriptionsFields(sprintf(__("Place a small link under comments form, it lets know what's anti-spam tool protects your site", 'cleantalk'), $ct_options['show_link']));
791
  echo "<script>
792
  jQuery(document).ready(function(){
793
  jQuery('#cleantalk_anchor').parent().parent().children().first().hide();
@@ -863,7 +879,7 @@ input[type=submit] {padding: 10px; background: #3399FF; color: #fff; border:0 no
863
  <br />
864
  <div>
865
  <?php echo __('Plugin Homepage at', 'cleantalk'); ?> <a href="http://cleantalk.org" target="_blank">cleantalk.org</a>.<br />
866
- <?php echo __('Tech support CleanTalk:', 'cleantalk'); ?> <a href="https://cleantalk.org/forum/viewforum.php?f=25" target="_blank"><?php echo __('CleanTalk tech forum', 'cleantalk'); ?></a>.<br />Use s@cleantalk.org to test plugin in any WordPress form.<br />
867
  </div>
868
  <?php
869
  }
@@ -918,7 +934,7 @@ function cleantalk_admin_notice_message(){
918
  $next_notice_show=0;
919
  }
920
 
921
- $link=$_SERVER["QUERY_STRING"];
922
  if($link!='')
923
  {
924
  $link="?".$link."&close_notice=1";
@@ -937,7 +953,8 @@ function cleantalk_admin_notice_message(){
937
  if ($show_notice && $show_ct_notice_online != '' && $value==1) {
938
  if($show_ct_notice_online === 'Y'){
939
  echo '<div class="updated"><h3><b>';
940
- echo __("Don’t forget to disable CAPTCHA if you have it!", 'cleantalk');
 
941
  echo '</b></h3></div>';
942
  }
943
 
@@ -1120,6 +1137,12 @@ function ct_update_option($option_name) {
1120
  $api_key = trim($_POST['cleantalk_settings']['apikey']);
1121
  $ct_options['apikey'] = $api_key;
1122
  }
 
 
 
 
 
 
1123
  if (!ct_valid_key($api_key)) {
1124
  return;
1125
  }
@@ -1147,6 +1170,10 @@ function ct_update_option($option_name) {
1147
  $request['method_name'] = 'notice_validate_key';
1148
  $request['auth_key'] = $api_key;
1149
  $url='https://api.cleantalk.org';
 
 
 
 
1150
  $result=sendRawRequest($url, $request);
1151
  if ($result)
1152
  {
20
  if($blocked>0)
21
  {
22
  $blocked = number_format($blocked, 0, ',', ' ');
23
+ print "<div style='height:24px;width:100%;display:table-cell; vertical-align:middle;'><img src='" . plugin_dir_url(__FILE__) . "images/logo_color.png' style='margin-right:1em;vertical-align:middle;'/><span><a href='options-general.php?page=cleantalk'>CleanTalk</a> ";
24
+ printf(
25
+ /* translators: %s: Number of spam messages */
26
+ __( 'has blocked %s spam', 'cleantalk' ),
27
+ $blocked
28
+ );
29
+ print "</span></div>";
30
  }
31
  }
32
 
 
33
  if(isset($_GET['close_notice']))
34
  {
35
  global $ct_data, $pagenow;
127
  'checkjs' => 1
128
  ));*/
129
  }
130
+
131
+ if(@isset($_POST['cleantalk_settings']['spam_firewall']) && $_POST['cleantalk_settings']['spam_firewall']==1 || isset($ct_options['spam_firewall']) && intval($ct_options['spam_firewall'])==1)
132
+ {
133
+ cleantalk_update_sfw();
134
+ }
135
 
136
  $show_ct_notice_trial = false;
137
  if (isset($_COOKIE[$ct_notice_trial_label])) {
348
  add_settings_field('cleantalk_check_comments_number', __("Don't check comments", 'cleantalk'), 'ct_input_check_comments_number', 'cleantalk', 'cleantalk_settings_anti_spam');
349
  //add_settings_field('cleantalk_check_messages_number', __("Don't check messages", 'cleantalk'), 'ct_input_check_messages_number', 'cleantalk', 'cleantalk_settings_anti_spam');
350
  add_settings_field('cleantalk_show_link', __('', 'cleantalk'), 'ct_input_show_link', 'cleantalk', 'cleantalk_settings_banner');
351
+ add_settings_field('cleantalk_spam_firewall', __('', 'cleantalk'), 'ct_input_spam_firewall', 'cleantalk', 'cleantalk_settings_banner');
352
  }
353
  }
354
 
389
  //$ct_data=ct_get_data();
390
  $args = array(
391
  'id' => 'ct_parent_node',
392
+ '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" alt="allowed / blocked"><span class="ab-label" id="ct_stats"><span>0</span> / <span>0</span></span></a>'
393
  );
394
  $wp_admin_bar->add_node( $args );
395
 
396
  // add a child item to our parent item
397
  $args = array(
398
  'id' => 'ct_dashboard_link',
399
+ 'title' => '<a href="https://cleantalk.org/my/?user_token='.@$ct_data['user_token'].'&utm_source=wp-backend&utm_medium=admin-bar" target="_blank">CleanTalk '.__('dashboard', 'cleantalk').'</a>',
400
  'parent' => 'ct_parent_node'
401
  );
402
  $wp_admin_bar->add_node( $args );
404
  // add another child item to our parent item (not to our first group)
405
  $args = array(
406
  'id' => 'ct_settings_link',
407
+ 'title' => '<a href="options-general.php?page=cleantalk">'.__('Settings', 'cleantalk').'</a>',
408
  'parent' => 'ct_parent_node'
409
  );
410
  $wp_admin_bar->add_node( $args );
441
  print "<div style='color:$color'>";
442
  if($ct_options['registrations_test']==1)
443
  {
444
+ print '<img src="' . plugin_dir_url(__FILE__) . 'images/'.$img.'" alt="" height="" /> '.__('Registration forms', 'cleantalk');
445
  }
446
  else
447
  {
448
+ print '<img src="' . plugin_dir_url(__FILE__) . 'images/'.$img_no.'" alt="" height="" /> '.__('Registration forms', 'cleantalk');
449
  }
450
 
451
  if($ct_options['comments_test']==1)
452
  {
453
+ print ' &nbsp; <img src="' . plugin_dir_url(__FILE__) . 'images/'.$img.'" alt="" height="" /> '.__('Comments form', 'cleantalk');
454
  }
455
  else
456
  {
457
+ print ' &nbsp; <img src="' . plugin_dir_url(__FILE__) . 'images/'.$img_no.'" alt="" height="" /> '.__('Comments form', 'cleantalk');
458
  }
459
 
460
  if($ct_options['contact_forms_test']==1)
461
  {
462
+ print ' &nbsp; <img src="' . plugin_dir_url(__FILE__) . 'images/'.$img.'" alt="" height="" /> '.__('Contact forms', 'cleantalk');
463
  }
464
  else
465
  {
466
+ print ' &nbsp; <img src="' . plugin_dir_url(__FILE__) . 'images/'.$img_no.'" alt="" height="" /> '.__('Contact forms', 'cleantalk');
467
  }
468
 
469
  if($ct_options['general_contact_forms_test']==1)
470
  {
471
+ print ' &nbsp; <img src="' . plugin_dir_url(__FILE__) . 'images/'.$img.'" alt="" height="" /> '.__('Custom contact forms', 'cleantalk');
472
  }
473
  else
474
  {
475
+ print ' &nbsp; <img src="' . plugin_dir_url(__FILE__) . 'images/'.$img_no.'" alt="" height="" /> '.__('Custom contact forms', 'cleantalk');
476
  }
477
 
478
  print "</div>";
512
  {
513
  $blocked = number_format($blocked, 0, ',', ' ');
514
 
515
+ echo "<script>var cleantalk_blocked_message=\"<div style='height:24px;width:100%;display:table-cell; vertical-align:middle;'><span>CleanTalk ";
516
+ printf(
517
+ /* translators: %s: Number of spam messages */
518
+ __( 'has blocked <b>%s</b> spam.', 'cleantalk' ),
519
+ $blocked
520
+ );
521
+ print "</span></div><br />\";\n";
522
  }
523
  else
524
  {
802
  echo "<input type='radio' id='cleantalk_show_link0' name='cleantalk_settings[show_link]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_show_link0'> " . __('No') . "</label>";*/
803
 
804
  echo "<div id='cleantalk_anchor' style='display:none'></div><input type=hidden name='cleantalk_settings[show_link]' value='0' />";
805
+ echo "<input type='checkbox' id='cleantalk_show_link1' name='cleantalk_settings[show_link]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_show_link1'> " . __('Tell others about CleanTalk') . "</label>";
806
+ @admin_addDescriptionsFields(sprintf(__("Checking this box places a small link under the comment form that lets others know what anti-spam tool protects your site.", 'cleantalk'), $ct_options['show_link']));
807
  echo "<script>
808
  jQuery(document).ready(function(){
809
  jQuery('#cleantalk_anchor').parent().parent().children().first().hide();
879
  <br />
880
  <div>
881
  <?php echo __('Plugin Homepage at', 'cleantalk'); ?> <a href="http://cleantalk.org" target="_blank">cleantalk.org</a>.<br />
882
+ <?php echo __('Tech support CleanTalk:', 'cleantalk'); ?> <a href="https://cleantalk.org/forum/viewforum.php?f=25" target="_blank"><?php echo __('CleanTalk tech forum', 'cleantalk'); ?></a>.<br /><?php echo __('Use s@cleantalk.org to test plugin in any WordPress form.', 'cleantalk'); ?><br />
883
  </div>
884
  <?php
885
  }
934
  $next_notice_show=0;
935
  }
936
 
937
+ $link=@$_SERVER["QUERY_STRING"];
938
  if($link!='')
939
  {
940
  $link="?".$link."&close_notice=1";
953
  if ($show_notice && $show_ct_notice_online != '' && $value==1) {
954
  if($show_ct_notice_online === 'Y'){
955
  echo '<div class="updated"><h3><b>';
956
+ //echo __("Don’t forget to disable CAPTCHA if you have it!", 'cleantalk');
957
+ echo __("Settings updated!", 'cleantalk');
958
  echo '</b></h3></div>';
959
  }
960
 
1137
  $api_key = trim($_POST['cleantalk_settings']['apikey']);
1138
  $ct_options['apikey'] = $api_key;
1139
  }
1140
+
1141
+ if(@isset($_POST['cleantalk_settings']['spam_firewall']) && $_POST['cleantalk_settings']['spam_firewall']==1 || isset($ct_options['spam_firewall']) && intval($ct_options['spam_firewall'])==1)
1142
+ {
1143
+ cleantalk_update_sfw();
1144
+ }
1145
+
1146
  if (!ct_valid_key($api_key)) {
1147
  return;
1148
  }
1170
  $request['method_name'] = 'notice_validate_key';
1171
  $request['auth_key'] = $api_key;
1172
  $url='https://api.cleantalk.org';
1173
+ if(!function_exists('sendRawRequest'))
1174
+ {
1175
+ require_once('cleantalk.class.php');
1176
+ }
1177
  $result=sendRawRequest($url, $request);
1178
  if ($result)
1179
  {
cleantalk-ajax.php → inc/cleantalk-ajax.php RENAMED
File without changes
inc/cleantalk-ajax_old.php ADDED
@@ -0,0 +1,775 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ AJAX functions
5
+ */
6
+
7
+ /*hooks for AJAX Login & Register email validation*/
8
+ add_action( 'wp_ajax_nopriv_validate_email', 'ct_validate_email_ajaxlogin',1 );
9
+ add_action( 'wp_ajax_validate_email', 'ct_validate_email_ajaxlogin',1 );
10
+
11
+ /*hooks for user registration*/
12
+ add_action( 'user_register', 'ct_user_register_ajaxlogin',1 );
13
+
14
+ /*hooks for WPUF pro */
15
+ add_action( 'wp_ajax_nopriv_wpuf_submit_register', 'ct_wpuf_submit_register',1 );
16
+ add_action( 'wp_ajax_wpuf_submit_register', 'ct_wpuf_submit_register',1 );
17
+
18
+ /*hooks for MyMail */
19
+ add_action( 'wp_ajax_nopriv_mymail_form_submit', 'ct_mymail_form_submit',1 );
20
+ add_action( 'wp_ajax_mymail_form_submit', 'ct_mymail_form_submit',1 );
21
+
22
+ /*hooks for MailPoet */
23
+ add_action( 'wp_ajax_nopriv_wysija_ajax', 'ct_wysija_ajax',1 );
24
+ add_action( 'wp_ajax_wysija_ajax', 'ct_wysija_ajax',1 );
25
+
26
+ /*hooks for cs_registration_validation */
27
+ add_action( 'wp_ajax_nopriv_cs_registration_validation', 'ct_cs_registration_validation',1 );
28
+ add_action( 'wp_ajax_cs_registration_validation', 'ct_cs_registration_validation',1 );
29
+
30
+ /*hooks for cs_registration_validation */
31
+ add_action( 'wp_ajax_nopriv_cs_registration_validation', 'ct_cs_registration_validation',1 );
32
+ add_action( 'wp_ajax_cs_registration_validation', 'ct_cs_registration_validation',1 );
33
+
34
+ /*hooks for send_message and request_appointment */
35
+ add_action( 'wp_ajax_nopriv_send_message', 'ct_sm_ra',1 );
36
+ add_action( 'wp_ajax_send_message', 'ct_sm_ra',1 );
37
+ add_action( 'wp_ajax_nopriv_request_appointment', 'ct_sm_ra',1 );
38
+ add_action( 'wp_ajax_request_appointment', 'ct_sm_ra',1 );
39
+
40
+ /*hooks for zn_do_login */
41
+ add_action( 'wp_ajax_nopriv_zn_do_login', 'ct_zn_do_login',1 );
42
+ add_action( 'wp_ajax_zn_do_login', 'ct_zn_do_login',1 );
43
+
44
+ /*hooks for zn_do_login */
45
+ add_action( 'wp_ajax_nopriv_cscf-submitform', 'ct_cscf_submitform',1 );
46
+ add_action( 'wp_ajax_cscf-submitform', 'ct_cscf_submitform',1 );
47
+
48
+ /*hooks for stats */
49
+ add_action( 'wp_ajax_nopriv_ajax_get_stats', 'ct_get_stats',1 );
50
+ add_action( 'wp_ajax_ajax_get_stats', 'ct_get_stats',1 );
51
+
52
+ /*hooks for visual form builder */
53
+ add_action( 'wp_ajax_nopriv_vfb_submit', 'ct_vfb_submit',1 );
54
+ add_action( 'wp_ajax_vfb_submit', 'ct_vfb_submit',1 );
55
+
56
+ function ct_get_stats()
57
+ {
58
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
59
+ global $ct_data;
60
+ $ct_data=ct_get_data();
61
+ $t=time();
62
+
63
+ if(!isset($ct_data['stat_accepted']))
64
+ {
65
+ $ct_data['stat_accepted']=0;
66
+ $ct_data['stat_blocked']=0;
67
+ $ct_data['stat_all']=0;
68
+ $ct_data['last_time']=$t;
69
+ update_option('cleantalk_data', $ct_data);
70
+ }
71
+
72
+ $last_time=intval($ct_data['last_time']);
73
+ if($t-$last_time>86400)
74
+ {
75
+ $ct_data['stat_accepted']=0;
76
+ $ct_data['stat_blocked']=0;
77
+ $ct_data['stat_all']=0;
78
+ $ct_data['last_time']=$t;
79
+ update_option('cleantalk_data', $ct_data);
80
+ }
81
+
82
+ $ret=Array('stat_accepted'=>$ct_data['stat_accepted'],'stat_blocked'=>$ct_data['stat_blocked'],'stat_all'=>$ct_data['stat_all']);
83
+ print json_encode($ret);
84
+ die();
85
+ }
86
+
87
+ function ct_validate_email_ajaxlogin($email=null, $is_ajax=true)
88
+ {
89
+ require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
90
+ 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;
91
+
92
+ $ct_options=ct_get_options();
93
+ $ct_data=ct_get_data();
94
+
95
+ $email = is_null( $email ) ? $email : $_POST['email'];
96
+ $email=sanitize_email($email);
97
+ $is_good=true;
98
+ if ( ! filter_var( $email, FILTER_VALIDATE_EMAIL )||email_exists( $email ) )
99
+ {
100
+ $is_good=false;
101
+ }
102
+
103
+ if(class_exists('AjaxLogin')&&isset($_POST['action'])&&$_POST['action']=='validate_email')
104
+ {
105
+
106
+ $ct_options=ct_get_options();
107
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
108
+ $submit_time = submit_time_test();
109
+ $sender_info = get_sender_info();
110
+ $sender_info['post_checkjs_passed']=$checkjs;
111
+
112
+ if ($checkjs === null)
113
+ {
114
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
115
+ $sender_info['cookie_checkjs_passed'] = $checkjs;
116
+ }
117
+
118
+ $sender_info = json_encode($sender_info);
119
+ if ($sender_info === false)
120
+ {
121
+ $sender_info= '';
122
+ }
123
+
124
+ require_once('cleantalk.class.php');
125
+ $config = get_option('cleantalk_server');
126
+ $ct = new Cleantalk();
127
+ $ct->work_url = $config['ct_work_url'];
128
+ $ct->server_url = $ct_options['server'];
129
+
130
+ $ct->server_ttl = $config['ct_server_ttl'];
131
+ $ct->server_changed = $config['ct_server_changed'];
132
+ $ct->ssl_on = $ct_options['ssl_on'];
133
+
134
+ $ct_request = new CleantalkRequest();
135
+ $ct_request->auth_key = $ct_options['apikey'];
136
+ $ct_request->sender_email = $email;
137
+ $ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
138
+ $ct_request->sender_nickname = '';
139
+ $ct_request->agent = $ct_agent_version;
140
+ $ct_request->sender_info = $sender_info;
141
+ $ct_request->js_on = $checkjs;
142
+ $ct_request->submit_time = $submit_time;
143
+
144
+ $ct_result = $ct->isAllowUser($ct_request);
145
+
146
+ if ($ct->server_change)
147
+ {
148
+ update_option(
149
+ 'cleantalk_server', array(
150
+ 'ct_work_url' => $ct->work_url,
151
+ 'ct_server_ttl' => $ct->server_ttl,
152
+ 'ct_server_changed' => time()
153
+ )
154
+ );
155
+ }
156
+ if ($ct_result->allow===0)
157
+ {
158
+ $is_good=false;
159
+ }
160
+ }
161
+ if($is_good)
162
+ {
163
+ $ajaxresult=array(
164
+ 'description' => null,
165
+ 'cssClass' => 'noon',
166
+ 'code' => 'success'
167
+ );
168
+ }
169
+ else
170
+ {
171
+ $ajaxresult=array(
172
+ 'description' => 'Invalid Email',
173
+ 'cssClass' => 'error-container',
174
+ 'code' => 'error'
175
+ );
176
+ }
177
+ $ajaxresult=json_encode($ajaxresult);
178
+ print $ajaxresult;
179
+ wp_die();
180
+ }
181
+
182
+ function ct_user_register_ajaxlogin($user_id)
183
+ {
184
+ require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
185
+ 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;
186
+
187
+ $ct_options=ct_get_options();
188
+ $ct_data=ct_get_data();
189
+
190
+ if(class_exists('AjaxLogin')&&isset($_POST['action'])&&$_POST['action']=='register_submit')
191
+ {
192
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
193
+ $submit_time = submit_time_test();
194
+ $sender_info = get_sender_info();
195
+ $sender_info['post_checkjs_passed']=$checkjs;
196
+
197
+ if ($checkjs === null)
198
+ {
199
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
200
+ $sender_info['cookie_checkjs_passed'] = $checkjs;
201
+ }
202
+
203
+ $sender_info = json_encode($sender_info);
204
+ if ($sender_info === false)
205
+ {
206
+ $sender_info= '';
207
+ }
208
+
209
+ require_once('cleantalk.class.php');
210
+ $config = get_option('cleantalk_server');
211
+ $ct = new Cleantalk();
212
+ $ct->work_url = $config['ct_work_url'];
213
+ $ct->server_url = $ct_options['server'];
214
+
215
+ $ct->server_ttl = $config['ct_server_ttl'];
216
+ $ct->server_changed = $config['ct_server_changed'];
217
+ $ct->ssl_on = $ct_options['ssl_on'];
218
+
219
+ $ct_request = new CleantalkRequest();
220
+ $ct_request->auth_key = $ct_options['apikey'];
221
+ $ct_request->sender_email = sanitize_email($_POST['email']);
222
+ $ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
223
+ $ct_request->sender_nickname = sanitize_email($_POST['login']); ;
224
+ $ct_request->agent = $ct_agent_version;
225
+ $ct_request->sender_info = $sender_info;
226
+ $ct_request->js_on = $checkjs;
227
+ $ct_request->submit_time = $submit_time;
228
+
229
+ $ct_result = $ct->isAllowUser($ct_request);
230
+
231
+ if ($ct->server_change)
232
+ {
233
+ update_option(
234
+ 'cleantalk_server', array(
235
+ 'ct_work_url' => $ct->work_url,
236
+ 'ct_server_ttl' => $ct->server_ttl,
237
+ 'ct_server_changed' => time()
238
+ )
239
+ );
240
+ }
241
+ if ($ct_result->allow===0)
242
+ {
243
+ wp_delete_user($user_id);
244
+ }
245
+ }
246
+ return $user_id;
247
+ }
248
+
249
+ function ct_wpuf_submit_register()
250
+ {
251
+ require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
252
+ 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;
253
+
254
+ $ct_data=ct_get_data();
255
+
256
+ $ct_options=ct_get_options();
257
+
258
+ $sender_email = null;
259
+ $message = '';
260
+
261
+ foreach ($_POST as $key => $value)
262
+ {
263
+ if ($sender_email === null && preg_match("/^\S+@\S+\.\S+$/", $value))
264
+ {
265
+ $sender_email = $value;
266
+ }
267
+ else
268
+ {
269
+ $message.="$value\n";
270
+ }
271
+ }
272
+
273
+ if($sender_email!=null)
274
+ {
275
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
276
+ $submit_time = submit_time_test();
277
+ $sender_info = get_sender_info();
278
+ $sender_info['post_checkjs_passed']=$checkjs;
279
+
280
+ $sender_info = json_encode($sender_info);
281
+ if ($sender_info === false)
282
+ {
283
+ $sender_info= '';
284
+ }
285
+
286
+ $ct_base_call_result = ct_base_call(array(
287
+ 'message' => $message,
288
+ 'example' => null,
289
+ 'sender_email' => $sender_email,
290
+ 'sender_nickname' => null,
291
+ 'sender_info' => $sender_info,
292
+ 'post_info'=>null,
293
+ 'checkjs' => $checkjs));
294
+
295
+ $ct = $ct_base_call_result['ct'];
296
+ $ct_result = $ct_base_call_result['ct_result'];
297
+ if ($ct_result->allow == 0)
298
+ {
299
+ $result=Array('success'=>false,'error'=>$ct_result->comment);
300
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
301
+ print json_encode($result);
302
+ die();
303
+ }
304
+ }
305
+ }
306
+
307
+ function ct_mymail_form_submit()
308
+ {
309
+ require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
310
+ 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;
311
+
312
+ $ct_data=ct_get_data();
313
+
314
+ $ct_options=ct_get_options();
315
+
316
+ $sender_email = null;
317
+ $message = '';
318
+
319
+ ct_get_fields($sender_email,$message,$_POST);
320
+
321
+ if($sender_email!=null)
322
+ {
323
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
324
+ $submit_time = submit_time_test();
325
+ $sender_info = get_sender_info();
326
+ $sender_info['post_checkjs_passed']=$checkjs;
327
+
328
+ $sender_info = json_encode($sender_info);
329
+ if ($sender_info === false)
330
+ {
331
+ $sender_info= '';
332
+ }
333
+
334
+ $ct_base_call_result = ct_base_call(array(
335
+ 'message' => $message,
336
+ 'example' => null,
337
+ 'sender_email' => $sender_email,
338
+ 'sender_nickname' => null,
339
+ 'sender_info' => $sender_info,
340
+ 'post_info'=>null,
341
+ 'checkjs' => $checkjs));
342
+
343
+ $ct = $ct_base_call_result['ct'];
344
+ $ct_result = $ct_base_call_result['ct_result'];
345
+ if ($ct_result->allow == 0)
346
+ {
347
+ $result=Array('success'=>false,'html'=>$ct_result->comment);
348
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
349
+ print json_encode($result);
350
+ die();
351
+ }
352
+ }
353
+ }
354
+
355
+ function ct_wysija_ajax()
356
+ {
357
+ require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
358
+ 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;
359
+
360
+ $ct_data=ct_get_data();
361
+
362
+ $ct_options=ct_get_options();
363
+
364
+ $sender_email = null;
365
+ $message = '';
366
+
367
+ ct_get_fields($sender_email,$message,$_POST);
368
+
369
+
370
+ if($sender_email!=null&&isset($_GET['callback']))
371
+ {
372
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
373
+ $submit_time = submit_time_test();
374
+ $sender_info = get_sender_info();
375
+ $sender_info['post_checkjs_passed']=$checkjs;
376
+
377
+ $sender_info = json_encode($sender_info);
378
+ if ($sender_info === false)
379
+ {
380
+ $sender_info= '';
381
+ }
382
+
383
+ $ct_base_call_result = ct_base_call(array(
384
+ 'message' => $message,
385
+ 'example' => null,
386
+ 'sender_email' => $sender_email,
387
+ 'sender_nickname' => null,
388
+ 'sender_info' => $sender_info,
389
+ 'post_info'=>null,
390
+ 'checkjs' => $checkjs));
391
+
392
+ $ct = $ct_base_call_result['ct'];
393
+ $ct_result = $ct_base_call_result['ct_result'];
394
+ if ($ct_result->allow == 0)
395
+ {
396
+ $result=Array('result'=>false,'msgs'=>Array('updated'=>Array($ct_result->comment)));
397
+ //@header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
398
+ print $_GET['callback'].'('.json_encode($result).');';
399
+ die();
400
+ }
401
+ }
402
+ }
403
+
404
+ function ct_cs_registration_validation()
405
+ {
406
+
407
+ require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
408
+ 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;
409
+
410
+ $ct_data=ct_get_data();
411
+
412
+ $ct_options=ct_get_options();
413
+
414
+ $sender_email = null;
415
+ $message = '';
416
+
417
+ ct_get_fields($sender_email,$message,$_POST);
418
+
419
+ if($sender_email!=null)
420
+ {
421
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
422
+ $submit_time = submit_time_test();
423
+ $sender_info = get_sender_info();
424
+ $sender_info['post_checkjs_passed']=$checkjs;
425
+
426
+ $sender_info = json_encode($sender_info);
427
+ if ($sender_info === false)
428
+ {
429
+ $sender_info = '';
430
+ }
431
+ if(isset($_POST['user_login']))
432
+ {
433
+ $nickname=$_POST['user_login'];
434
+ }
435
+ else
436
+ {
437
+ $nickname='';
438
+ }
439
+ require_once('cleantalk.class.php');
440
+
441
+ $config = get_option('cleantalk_server');
442
+ $ct = new Cleantalk();
443
+ $ct->work_url = $config['ct_work_url'];
444
+ $ct->server_url = $ct_options['server'];
445
+
446
+ $ct->server_ttl = $config['ct_server_ttl'];
447
+ $ct->server_changed = $config['ct_server_changed'];
448
+ $ct->ssl_on = $ct_options['ssl_on'];
449
+
450
+
451
+ $ct_request = new CleantalkRequest();
452
+ $ct_request->auth_key = $ct_options['apikey'];
453
+ $ct_request->sender_email = $sender_email;
454
+ $ct_request->sender_ip = $_SERVER['REMOTE_ADDR'];
455
+ $ct_request->sender_nickname = $nickname;
456
+ $ct_request->agent = $ct_agent_version;
457
+ $ct_request->sender_info = $sender_info;
458
+ $ct_request->js_on = $checkjs;
459
+ $ct_request->submit_time = $submit_time;
460
+
461
+ $ct_result = $ct->isAllowUser($ct_request);
462
+
463
+ if ($ct_result->allow == 0)
464
+ {
465
+ $result=Array("type"=>"error","message"=>$ct_result->comment);
466
+ print json_encode($result);
467
+ die();
468
+ }
469
+ }
470
+ }
471
+
472
+ function ct_sm_ra()
473
+ {
474
+ require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
475
+ 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;
476
+
477
+ $ct_data=ct_get_data();
478
+
479
+ $ct_options=ct_get_options();
480
+
481
+ $sender_email = null;
482
+ $message = '';
483
+
484
+ if(isset($_POST['target']))
485
+ {
486
+ $tmp=$_POST['target'];
487
+ $_POST['target']=1;
488
+ }
489
+
490
+ ct_get_fields($sender_email,$message,$_POST);
491
+
492
+ if(isset($_POST['target']))
493
+ {
494
+ $_POST['target']=$tmp;
495
+ }
496
+
497
+
498
+ if($sender_email!=null)
499
+ {
500
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
501
+ $submit_time = submit_time_test();
502
+ $sender_info = get_sender_info();
503
+ $sender_info['post_checkjs_passed']=$checkjs;
504
+
505
+ $sender_info = json_encode($sender_info);
506
+ if ($sender_info === false)
507
+ {
508
+ $sender_info= '';
509
+ }
510
+
511
+ $ct_base_call_result = ct_base_call(array(
512
+ 'message' => $message,
513
+ 'example' => null,
514
+ 'sender_email' => $sender_email,
515
+ 'sender_nickname' => null,
516
+ 'sender_info' => $sender_info,
517
+ 'post_info'=>null,
518
+ 'checkjs' => $checkjs));
519
+
520
+ $ct = $ct_base_call_result['ct'];
521
+ $ct_result = $ct_base_call_result['ct_result'];
522
+ if ($ct_result->allow == 0)
523
+ {
524
+ print $ct_result->comment;
525
+ die();
526
+ }
527
+ }
528
+ }
529
+
530
+ function ct_zn_do_login()
531
+ {
532
+ require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
533
+ 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;
534
+
535
+ $ct_data=ct_get_data();
536
+
537
+ $ct_options=ct_get_options();
538
+
539
+ $sender_email = null;
540
+ $message = '';
541
+
542
+ ct_get_fields($sender_email,$message,$_POST);
543
+
544
+
545
+ if($sender_email!=null&&$_POST['zn_form_action']=='register')
546
+ {
547
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
548
+ $submit_time = submit_time_test();
549
+ $sender_info = get_sender_info();
550
+ $sender_info['post_checkjs_passed']=$checkjs;
551
+
552
+ $sender_info = json_encode($sender_info);
553
+ if ($sender_info === false)
554
+ {
555
+ $sender_info= '';
556
+ }
557
+
558
+ $ct_base_call_result = ct_base_call(array(
559
+ 'message' => $message,
560
+ 'example' => null,
561
+ 'sender_email' => $sender_email,
562
+ 'sender_nickname' => null,
563
+ 'sender_info' => $sender_info,
564
+ 'post_info'=>null,
565
+ 'checkjs' => $checkjs));
566
+
567
+ $ct = $ct_base_call_result['ct'];
568
+ $ct_result = $ct_base_call_result['ct_result'];
569
+ if ($ct_result->allow == 0)
570
+ {
571
+ print '<div id="login_error">'.$ct_result->comment.'</div>';
572
+ die();
573
+ }
574
+ }
575
+ }
576
+
577
+ function ct_vfb_submit()
578
+ {
579
+ require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
580
+ 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;
581
+
582
+ $ct_data=ct_get_data();
583
+
584
+ $ct_options=ct_get_options();
585
+
586
+ $sender_email = null;
587
+ $message = '';
588
+
589
+ foreach ($_POST as $key => $value)
590
+ {
591
+ if ($sender_email === null && preg_match("/^\S+@\S+\.\S+$/", $value))
592
+ {
593
+ $sender_email = $value;
594
+ }
595
+ else
596
+ {
597
+ $message.="$value\n";
598
+ }
599
+ }
600
+
601
+ if($sender_email!=null)
602
+ {
603
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
604
+ $submit_time = submit_time_test();
605
+ $sender_info = get_sender_info();
606
+ $sender_info['post_checkjs_passed']=$checkjs;
607
+
608
+ $sender_info = json_encode($sender_info);
609
+ if ($sender_info === false)
610
+ {
611
+ $sender_info= '';
612
+ }
613
+
614
+ $ct_base_call_result = ct_base_call(array(
615
+ 'message' => $message,
616
+ 'example' => null,
617
+ 'sender_email' => $sender_email,
618
+ 'sender_nickname' => null,
619
+ 'sender_info' => $sender_info,
620
+ 'post_info'=>null,
621
+ 'checkjs' => $checkjs));
622
+
623
+ $ct = $ct_base_call_result['ct'];
624
+ $ct_result = $ct_base_call_result['ct_result'];
625
+ if ($ct_result->allow == 0)
626
+ {
627
+ $result=Array('result'=>false,'message'=>$ct_result->comment);
628
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
629
+ print json_encode($result);
630
+ die();
631
+ }
632
+ }
633
+ }
634
+
635
+ function ct_cscf_submitform()
636
+ {
637
+ require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
638
+ 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;
639
+
640
+ $ct_data=ct_get_data();
641
+
642
+ $ct_options=ct_get_options();
643
+
644
+ $sender_email = null;
645
+ $message = '';
646
+
647
+ if(isset($_POST['cscf']['confirm-email']))
648
+ {
649
+ $tmp=$_POST['cscf']['confirm-email'];
650
+ $_POST['cscf']['confirm-email']=1;
651
+ }
652
+
653
+ ct_get_fields($sender_email,$message,$_POST);
654
+
655
+ if(isset($_POST['cscf']['confirm-email']))
656
+ {
657
+ $_POST['cscf']['confirm-email']=$tmp;
658
+ }
659
+
660
+
661
+ if($sender_email!=null)
662
+ {
663
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
664
+ $submit_time = submit_time_test();
665
+ $sender_info = get_sender_info();
666
+ $sender_info['post_checkjs_passed']=$checkjs;
667
+
668
+ $sender_info = json_encode($sender_info);
669
+ if ($sender_info === false)
670
+ {
671
+ $sender_info= '';
672
+ }
673
+
674
+ $ct_base_call_result = ct_base_call(array(
675
+ 'message' => $message,
676
+ 'example' => null,
677
+ 'sender_email' => $sender_email,
678
+ 'sender_nickname' => null,
679
+ 'sender_info' => $sender_info,
680
+ 'post_info'=>null,
681
+ 'checkjs' => $checkjs));
682
+
683
+ $ct = $ct_base_call_result['ct'];
684
+ $ct_result = $ct_base_call_result['ct_result'];
685
+ if ($ct_result->allow == 0)
686
+ {
687
+ $result=Array('sent'=>true,'valid'=>false,'errorlist'=>Array('name'=>$ct_result->comment));
688
+ print json_encode($result);
689
+ die();
690
+ }
691
+ }
692
+ }
693
+
694
+ function ct_theme_submit()
695
+ {
696
+ require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
697
+ 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;
698
+
699
+ $ct_data=ct_get_data();
700
+
701
+ $ct_options=ct_get_options();
702
+
703
+ $sender_email = null;
704
+ $message = '';
705
+
706
+ if(isset($_POST['cscf']['confirm-email']))
707
+ {
708
+ $tmp=$_POST['cscf']['confirm-email'];
709
+ $_POST['cscf']['confirm-email']=1;
710
+ }
711
+
712
+ ct_get_fields($sender_email,$message,$_POST);
713
+
714
+ if(isset($_POST['cscf']['confirm-email']))
715
+ {
716
+ $_POST['cscf']['confirm-email']=$tmp;
717
+ }
718
+
719
+
720
+ if($sender_email!=null)
721
+ {
722
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
723
+ $submit_time = submit_time_test();
724
+ $sender_info = get_sender_info();
725
+ $sender_info['post_checkjs_passed']=$checkjs;
726
+
727
+ $sender_info = json_encode($sender_info);
728
+ if ($sender_info === false)
729
+ {
730
+ $sender_info= '';
731
+ }
732
+
733
+ $ct_base_call_result = ct_base_call(array(
734
+ 'message' => $message,
735
+ 'example' => null,
736
+ 'sender_email' => $sender_email,
737
+ 'sender_nickname' => null,
738
+ 'sender_info' => $sender_info,
739
+ 'post_info'=>null,
740
+ 'checkjs' => $checkjs));
741
+
742
+ $ct = $ct_base_call_result['ct'];
743
+ $ct_result = $ct_base_call_result['ct_result'];
744
+ if ($ct_result->allow == 0)
745
+ {
746
+ $result=Array('sent'=>true,'valid'=>false,'errorlist'=>Array('name'=>$ct_result->comment));
747
+ print json_encode($result);
748
+ die();
749
+ }
750
+ }
751
+ }
752
+
753
+ function ct_get_fields(&$email,&$message,$arr)
754
+ {
755
+ foreach($arr as $key=>$value)
756
+ {
757
+ if(!is_array($value))
758
+ {
759
+ if ($email === null && preg_match("/^\S+@\S+\.\S+$/", $value))
760
+ {
761
+ $email = $value;
762
+ }
763
+ else
764
+ {
765
+ $message.="$value\n";
766
+ }
767
+ }
768
+ else
769
+ {
770
+ ct_get_fields($email,$message,$value);
771
+ }
772
+ }
773
+ }
774
+
775
+ ?>
cleantalk-comments-checkspam.js → inc/cleantalk-comments-checkspam.js RENAMED
File without changes
cleantalk-comments-editscreen.js → inc/cleantalk-comments-editscreen.js RENAMED
File without changes
cleantalk-comments.php → inc/cleantalk-comments.php RENAMED
File without changes
cleantalk-common.php → inc/cleantalk-common.php RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- $ct_agent_version = 'wordpress-5252';
4
  $ct_plugin_name = 'Anti-spam by CleanTalk';
5
  $ct_checkjs_frm = 'ct_checkjs_frm';
6
  $ct_checkjs_register_form = 'ct_checkjs_register_form';
@@ -669,7 +669,7 @@ function ct_get_fields_any(&$email,&$message,&$nickname,&$subject, &$contact,$ar
669
  }
670
  else if(!is_object($value)&&@get_class($value)!='WP_User')
671
  {
672
- ct_get_fields_any($email, $message, $nickname, $subject, $contact, $value);
673
  }
674
  }
675
  }
@@ -695,7 +695,7 @@ function ct_get_fields_any_postdata(&$message,$arr)
695
  }
696
  else
697
  {
698
- ct_get_fields_any_postdata($message, $value);
699
  }
700
  }
701
  }
1
  <?php
2
 
3
+ $ct_agent_version = 'wordpress-526';
4
  $ct_plugin_name = 'Anti-spam by CleanTalk';
5
  $ct_checkjs_frm = 'ct_checkjs_frm';
6
  $ct_checkjs_register_form = 'ct_checkjs_register_form';
669
  }
670
  else if(!is_object($value)&&@get_class($value)!='WP_User')
671
  {
672
+ @ct_get_fields_any($email, $message, $nickname, $subject, $contact, $value);
673
  }
674
  }
675
  }
695
  }
696
  else
697
  {
698
+ @ct_get_fields_any_postdata($message, $value);
699
  }
700
  }
701
  }
cleantalk-public.php → inc/cleantalk-public.php RENAMED
@@ -500,7 +500,7 @@ function ct_preprocess_comment($comment) {
500
  }
501
  }
502
 
503
- if (ct_is_user_enable() === false || $ct_options['comments_test'] == 0 || $ct_comment_done || (isset($_SERVER['HTTP_REFERER']) && stripos($_SERVER['HTTP_REFERER'],'page=wysija_campaigns&action=editTemplate')!==false) || $is_max_comments) {
504
  return $comment;
505
  }
506
 
@@ -1369,6 +1369,10 @@ function ct_wpcf7_spam($param) {
1369
  $message = '';
1370
  $subject = '';
1371
  foreach ($_POST as $k => $v) {
 
 
 
 
1372
  if ($sender_email === null && preg_match("/^\S+@\S+\.\S+$/", $v)) {
1373
  $sender_email = $v;
1374
  }
@@ -1672,7 +1676,11 @@ function ct_s2member_registration_test() {
1672
  * General test for any contact form
1673
  */
1674
  function ct_contact_form_validate () {
1675
- global $pagenow,$cleantalk_executed, $cleantalk_url_exclusions;
 
 
 
 
1676
  if($cleantalk_executed)
1677
  {
1678
  return null;
@@ -1695,10 +1703,13 @@ function ct_contact_form_validate () {
1695
  strpos($_SERVER['REQUEST_URI'],'wp-login.php')!==false||
1696
  strpos($_SERVER['REQUEST_URI'],'wp-comments-post.php')!==false ||
1697
  @strpos($_SERVER['HTTP_REFERER'],'/wp-admin/')!==false ||
 
 
1698
  check_url_exclusions() ||
1699
  ct_check_array_keys($_POST) ||
1700
  isset($_POST['ct_checkjs_register_form']) ||
1701
- (isset($_POST['signup_username']) && isset($_POST['signup_password_confirm']) && isset($_POST['signup_submit']) )
 
1702
  ) {
1703
  return null;
1704
  }
@@ -1721,7 +1732,7 @@ function ct_contact_form_validate () {
1721
  $message = '';
1722
  $contact_form = true;
1723
 
1724
- ct_get_fields_any($sender_email, $message, $sender_nickname, $subject, $contact_form, $_POST);
1725
 
1726
 
1727
  // Skip submission if no data found
@@ -1788,7 +1799,11 @@ function ct_contact_form_validate () {
1788
  * General test for any post data
1789
  */
1790
  function ct_contact_form_validate_postdata () {
1791
- global $pagenow,$cleantalk_executed, $cleantalk_url_exclusions;
 
 
 
 
1792
  if($cleantalk_executed)
1793
  {
1794
  return null;
@@ -1819,7 +1834,9 @@ function ct_contact_form_validate_postdata () {
1819
  strpos($_SERVER['REQUEST_URI'],'wp-comments-post.php')!==false ||
1820
  @strpos($_SERVER['HTTP_REFERER'],'/wp-admin/')!==false ||
1821
  check_url_exclusions() ||
1822
- isset($_POST['ct_checkjs_register_form'])
 
 
1823
  ) {
1824
  return null;
1825
  }
@@ -1836,7 +1853,7 @@ function ct_contact_form_validate_postdata () {
1836
 
1837
  $message = '';
1838
 
1839
- ct_get_fields_any_postdata($message, $_POST);
1840
 
1841
  if(strlen(trim($message))<10)
1842
  {
500
  }
501
  }
502
 
503
+ if (ct_is_user_enable() === false || $ct_options['comments_test'] == 0 || $ct_comment_done || (isset($_SERVER['HTTP_REFERER']) && stripos($_SERVER['HTTP_REFERER'],'page=wysija_campaigns&action=editTemplate')!==false) || $is_max_comments || strpos($_SERVER['REQUEST_URI'],'/wp-admin/')!==false) {
504
  return $comment;
505
  }
506
 
1369
  $message = '';
1370
  $subject = '';
1371
  foreach ($_POST as $k => $v) {
1372
+ if(is_array($v))
1373
+ {
1374
+ continue;
1375
+ }
1376
  if ($sender_email === null && preg_match("/^\S+@\S+\.\S+$/", $v)) {
1377
  $sender_email = $v;
1378
  }
1676
  * General test for any contact form
1677
  */
1678
  function ct_contact_form_validate () {
1679
+ global $pagenow,$cleantalk_executed, $cleantalk_url_exclusions,$ct_options, $ct_data;
1680
+
1681
+ $ct_options = ct_get_options();
1682
+ $ct_data = ct_get_data();
1683
+
1684
  if($cleantalk_executed)
1685
  {
1686
  return null;
1703
  strpos($_SERVER['REQUEST_URI'],'wp-login.php')!==false||
1704
  strpos($_SERVER['REQUEST_URI'],'wp-comments-post.php')!==false ||
1705
  @strpos($_SERVER['HTTP_REFERER'],'/wp-admin/')!==false ||
1706
+ strpos($_SERVER['REQUEST_URI'],'/login/')!==false||
1707
+ isset($_GET['ptype']) && $_GET['ptype']=='login' ||
1708
  check_url_exclusions() ||
1709
  ct_check_array_keys($_POST) ||
1710
  isset($_POST['ct_checkjs_register_form']) ||
1711
+ (isset($_POST['signup_username']) && isset($_POST['signup_password_confirm']) && isset($_POST['signup_submit']) ) ||
1712
+ @intval($ct_options['general_contact_forms_test'])==0
1713
  ) {
1714
  return null;
1715
  }
1732
  $message = '';
1733
  $contact_form = true;
1734
 
1735
+ @ct_get_fields_any($sender_email, $message, $sender_nickname, $subject, $contact_form, $_POST);
1736
 
1737
 
1738
  // Skip submission if no data found
1799
  * General test for any post data
1800
  */
1801
  function ct_contact_form_validate_postdata () {
1802
+ global $pagenow,$cleantalk_executed, $cleantalk_url_exclusions, $ct_options, $ct_data;
1803
+
1804
+ $ct_options = ct_get_options();
1805
+ $ct_data = ct_get_data();
1806
+
1807
  if($cleantalk_executed)
1808
  {
1809
  return null;
1834
  strpos($_SERVER['REQUEST_URI'],'wp-comments-post.php')!==false ||
1835
  @strpos($_SERVER['HTTP_REFERER'],'/wp-admin/')!==false ||
1836
  check_url_exclusions() ||
1837
+ strpos($_SERVER['REQUEST_URI'],'/login/')!==false ||
1838
+ isset($_POST['ct_checkjs_register_form']) ||
1839
+ @intval($ct_options['general_postdata_test'])==0
1840
  ) {
1841
  return null;
1842
  }
1853
 
1854
  $message = '';
1855
 
1856
+ @ct_get_fields_any_postdata($message, $_POST);
1857
 
1858
  if(strlen(trim($message))<10)
1859
  {
cleantalk-rel.js → inc/cleantalk-rel.js RENAMED
File without changes
inc/cleantalk-sfw.class.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class CleanTalkSFW
3
+ {
4
+ public $ip = 0;
5
+ public $ip_str = '';
6
+ public $result = false;
7
+
8
+ public function cleantalk_get_real_ip()
9
+ {
10
+ if ( function_exists( 'apache_request_headers' ) )
11
+ {
12
+ $headers = apache_request_headers();
13
+ }
14
+ else
15
+ {
16
+ $headers = $_SERVER;
17
+ }
18
+ if ( array_key_exists( 'X-Forwarded-For', $headers ) )
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('all' => 1, 'block' => 0);
63
+ }
64
+
65
+ if(sizeof($r)>0)
66
+ {
67
+ $sfw_log[$this->ip_str]['block']++;
68
+ $this->result=true;
69
+ }
70
+ else
71
+ {
72
+ setcookie ('ct_sfw_pass_key', md5($this->ip_str.$ct_options['apikey']), 0, "/");
73
+ }
74
+ $ct_data['sfw_log'] = $sfw_log;
75
+ update_option('cleantalk_data', $ct_data);
76
+ }
77
+
78
+ public function sfw_die()
79
+ {
80
+ global $ct_options, $ct_data;
81
+ $sfw_die_page=file_get_contents(dirname(__FILE__)."/sfw_die_page.html");
82
+ $sfw_die_page=str_replace("{REMOTE_ADDRESS}",$this->ip_str,$sfw_die_page);
83
+ $sfw_die_page=str_replace("{REQUEST_URI}",$_SERVER['REQUEST_URI'],$sfw_die_page);
84
+ $sfw_die_page=str_replace("{SFW_COOKIE}",md5($this->ip_str.$ct_options['apikey']),$sfw_die_page);
85
+ @header('HTTP/1.0 403 Forbidden');
86
+ wp_die( $sfw_die_page, "Blacklisted", Array('response'=>403) );
87
+ }
88
+
89
+ public function send_logs()
90
+ {
91
+ global $ct_options, $ct_data;
92
+ $ct_options = ct_get_options();
93
+ $ct_data = ct_get_data();
94
+
95
+ if(isset($ct_options['spam_firewall']))
96
+ {
97
+ $value = @intval($ct_options['spam_firewall']);
98
+ }
99
+ else
100
+ {
101
+ $value=0;
102
+ }
103
+
104
+ if($value==1 && isset($ct_data['sfw_log']))
105
+ {
106
+ $sfw_log=$ct_data['sfw_log'];
107
+ $data=Array();
108
+ foreach($sfw_log as $key=>$value)
109
+ {
110
+ $data[]=Array($key, $value['all'], $value['block']);
111
+ }
112
+ $qdata = array (
113
+ 'data' => json_encode($data),
114
+ 'rows' => count($data),
115
+ 'timestamp' => time()
116
+ );
117
+
118
+ $result = sendRawRequest('https://api.cleantalk.org/?method_name=sfw_logs&auth_key='.$ct_options['apikey'],$qdata);
119
+ $result = json_decode($result);
120
+ if(isset($result->data) && isset($result->data->rows))
121
+ {
122
+ if($result->data->rows == count($data))
123
+ {
124
+ $ct_data['sfw_log']=Array();
125
+ update_option('cleantalk_data', $ct_data);
126
+ }
127
+ }
128
+
129
+ }
130
+ }
131
+ }
inc/cleantalk-sfw.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $ip=(int)sprintf("%u", ip2long(cleantalk_get_ip()));
4
+ $ip_str=cleantalk_get_ip();
5
+ //$ip=(int)sprintf("%u", ip2long("2.11.242.8"));
6
+ if(isset($_GET['sfw_test_ip']))
7
+ {
8
+ $ip=(int)sprintf("%u", ip2long($_GET['sfw_test_ip']));
9
+ $ip_str=$_GET['sfw_test_ip'];
10
+ }
11
+
12
+ global $wpdb;
13
+ $r = $wpdb->get_results("select * from `".$wpdb->base_prefix."cleantalk_sfw` where $ip & mask = network & mask;", ARRAY_A);
14
+ if(sizeof($r)>0)
15
+ {
16
+ global $ct_options, $ct_data;
17
+ $sfw_die_page=file_get_contents(dirname(__FILE__)."/sfw_die_page.html");
18
+ $sfw_die_page=str_replace("{REMOTE_ADDRESS}",$ip_str,$sfw_die_page);
19
+ $sfw_die_page=str_replace("{REQUEST_URI}",$_SERVER['REQUEST_URI'],$sfw_die_page);
20
+ $sfw_die_page=str_replace("{SFW_COOKIE}",md5(cleantalk_get_ip().$ct_options['apikey']),$sfw_die_page);
21
+ if(isset($ct_data['sfw_log']))
22
+ {
23
+ $sfw_log=$ct_data['sfw_log'];
24
+ }
25
+ else
26
+ {
27
+ $sfw_log=array();
28
+ }
29
+ if(isset($sfw_log[$r[0]['network']]))
30
+ {
31
+ $sfw_log[$r[0]['network']]['block']++;
32
+ }
33
+ else
34
+ {
35
+ $sfw_log[$r[0]['network']] = Array('block' => 1, 'allow' => 0);
36
+ }
37
+ $ct_data['sfw_log'] = $sfw_log;
38
+ update_option('cleantalk_data', $ct_data);
39
+ wp_die( $sfw_die_page, "Blacklisted", Array('response'=>403) );
40
+ }
41
+
42
+ ?>
cleantalk-stats.js → inc/cleantalk-stats.js RENAMED
File without changes
cleantalk-users-checkspam.js → inc/cleantalk-users-checkspam.js RENAMED
File without changes
cleantalk-users-editscreen.js → inc/cleantalk-users-editscreen.js RENAMED
File without changes
cleantalk-users.php → inc/cleantalk-users.php RENAMED
File without changes
cleantalk-widget.php → inc/cleantalk-widget.php RENAMED
File without changes
cleantalk.class.php → inc/cleantalk.class.php RENAMED
File without changes
inc/cleantalk_api.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once("cleantalk.class.php");
3
+ require_once("JSON.php");
4
+
5
+
6
+ /**
7
+ * Get ct_get_checkjs_value
8
+ * @return string
9
+ */
10
+ function ct_get_checkjs_value_plugin($random_key = false) {
11
+
12
+ $ct_data=get_option("cleantalk_data");
13
+
14
+ if ($random_key) {
15
+ $keys = $ct_data['js_keys'];
16
+ $keys_checksum = md5(json_encode($keys));
17
+
18
+ $key = null;
19
+ $latest_key_time = 0;
20
+ foreach ($keys as $k => $t) {
21
+
22
+ // Removing key if it's to old
23
+ if (time() - $t > $ct_data['js_keys_store_days'] * 86400) {
24
+ unset($keys[$k]);
25
+ continue;
26
+ }
27
+
28
+ if ($t > $latest_key_time) {
29
+ $latest_key_time = $t;
30
+ $key = $k;
31
+ }
32
+ }
33
+
34
+ // Get new key if the latest key is too old
35
+ if (time() - $latest_key_time > $ct_data['js_key_lifetime']) {
36
+ $key = rand();
37
+ $keys[$key] = time();
38
+ }
39
+
40
+ if (md5(json_encode($keys)) != $keys_checksum) {
41
+ $ct_data['js_keys'] = $keys;
42
+ update_option('cleantalk_data', $ct_data);
43
+ }
44
+ } else {
45
+ $key = md5($ct_options['apikey'] . '+' . get_option('admin_email'));
46
+ }
47
+
48
+ return $key;
49
+ }
50
+
51
+ /**
52
+ * Validates JavaScript anti-spam test
53
+ *
54
+ */
55
+ function js_test_plugin($field_name = 'ct_checkjs', $data = null, $random_key = false) {
56
+
57
+ $ct_data=get_option("cleantalk_data");
58
+
59
+ $checkjs = null;
60
+ $js_post_value = null;
61
+
62
+ if (!$data)
63
+ return $checkjs;
64
+
65
+ if (isset($data[$field_name])) {
66
+ $js_post_value = $data[$field_name];
67
+ if (isset($keys[$js_post_value])) {
68
+
69
+ //
70
+ // Random key check
71
+ //
72
+ if ($random_key) {
73
+
74
+ $keys = $ct_data['js_keys'];
75
+ $checkjs = 1;
76
+ } else {
77
+ $checkjs = 0;
78
+ }
79
+ } else {
80
+ $ct_challenge = ct_get_checkjs_value();
81
+
82
+ if(preg_match("/$ct_challenge/", $js_post_value)) {
83
+ $checkjs = 1;
84
+ } else {
85
+ $checkjs = 0;
86
+ }
87
+ }
88
+
89
+
90
+ }
91
+
92
+ return $checkjs;
93
+ }
94
+
95
+ /**
96
+ * Check messages for external plugins
97
+ * @return array with checking result;
98
+ */
99
+
100
+ function ct_test_message($nickname, $email, $ip, $text){
101
+ $checkjs = js_test_plugin('ct_checkjs', $_COOKIE, true);
102
+
103
+ $post_info['comment_type'] = 'feedback_plugin_check';
104
+ $post_info = json_encode($post_info);
105
+
106
+ $ct_base_call_result = ct_base_call(array(
107
+ 'message' => $text,
108
+ 'example' => null,
109
+ 'sender_email' => $email,
110
+ 'sender_nickname' => $nickname,
111
+ 'post_info' => $post_info,
112
+ 'sender_info' => get_sender_info(),
113
+ 'checkjs' => $checkjs
114
+ ));
115
+
116
+ $ct_result = $ct_base_call_result['ct_result'];
117
+
118
+ $result=Array(
119
+ 'allow' => $ct_result->allow,
120
+ 'comment' => $ct_result->comment,
121
+ );
122
+ return $result;
123
+ }
124
+
125
+
126
+
127
+ ?>
cleantalk_external.js → inc/cleantalk_external.js RENAMED
File without changes
cleantalk_nocache.js → inc/cleantalk_nocache.js RENAMED
@@ -66,8 +66,8 @@ function ct_setCookie(name, value)
66
  var date = new Date;
67
  date.setDate(date.getDate() + 1);
68
  //setTimeout(function() { document.cookie = name+"=" + value + "; expires=" + date.toUTCString() + "; path = /; domain = " + domain}, 500)
69
- //setTimeout(function() { document.cookie = name+"=" + value + "; expires=" + date.toUTCString() + "; path = /;"}, 500);
70
- document.cookie = name+"=" + value + "; expires=" + date.toUTCString() + "; path = /;";
71
  }
72
 
73
  function ct_callback(req)
66
  var date = new Date;
67
  date.setDate(date.getDate() + 1);
68
  //setTimeout(function() { document.cookie = name+"=" + value + "; expires=" + date.toUTCString() + "; path = /; domain = " + domain}, 500)
69
+ setTimeout(function() { document.cookie = name+"=" + value + "; expires=" + date.toUTCString() + "; path = /;"}, 500);
70
+ //document.cookie = name+"=" + value + "; expires=" + date.toUTCString() + "; path = /;";
71
  }
72
 
73
  function ct_callback(req)
inc/sfw_die_page.html ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+
8
+ <!-- <title></title> -->
9
+
10
+ <!--[if lt IE 9]>
11
+ <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
12
+ <![endif]-->
13
+ <style>
14
+ html{font-size: 14pt;}
15
+ h1{text-align:center}
16
+ h1.main{margin-top: 1em;margin-bottom: 3em;}
17
+ div.container {text-align:center;}
18
+ div.container p.js_notice{width: 60%; display: inline-block;}
19
+ div.footer {color: #666; position: absolute; bottom: 1em; text-align: center; width: 100%;}
20
+ div.footer a {color: #666; vertical-align:bottom; text-align: center;}
21
+ div#js_passed {display:none;}
22
+
23
+ @media (max-width: 600px) {
24
+ }
25
+ </style>
26
+ <script>
27
+ var reload_timeout = 3000;
28
+ function set_spamFireWallCookie(cookie_name, cookie_value) {
29
+ document.cookie = cookie_name + "=" + escape(cookie_value) + "; path=/;";
30
+ return null;
31
+ }
32
+ function get_current_url() {
33
+ document.write(window.location.href);
34
+ return null;
35
+ }
36
+ </script>
37
+ </head>
38
+
39
+ <body>
40
+ <div class="container">
41
+ <h1 class="main">SpamFireWall is activated for your IP <a href="https://cleantalk.org/blacklists/{REMOTE_ADDRESS}" target="_blank">{REMOTE_ADDRESS}</a></h1>
42
+
43
+ <div id="js_info"><br />To continue working with web site, please make sure that you have enabled JavaScript.</div>
44
+
45
+ <div id="js_passed">
46
+ <h3>Please click bellow to pass protection,</h3>
47
+ <a href="{REQUEST_URI}"><script>get_current_url();</script></a>
48
+ <br /><br /><br />
49
+ <p class="js_notice">Or you will be automatically redirected to the requested page after 3 seconds.</p>
50
+ </div>
51
+ </div>
52
+ <div class="footer">
53
+ <a href="https://cleantalk.org" target="_blank">Anti-Spam by CleanTalk</a>
54
+ </div>
55
+ <script type="text/javascript">
56
+ document.getElementById('js_info').style.display = 'none';
57
+ document.getElementById('js_passed').style.display = 'block';
58
+ set_spamFireWallCookie('ct_sfw_pass_key','{SFW_COOKIE}');
59
+ setTimeout(function(){
60
+ window.location.reload(1);
61
+ }, reload_timeout);
62
+ </script>
63
+ </body>
64
+ </html>
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Anti-Spam by CleanTalk - No Captcha, no comments & registrations spam ===
2
  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
4
  Requires at least: 3.0
5
  Tested up to: 4.3
6
- Stable tag: 5.25.2
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -61,6 +61,23 @@ This plugin uses multiple anti-spam tests to filter spam bots with lower false/p
61
  = Spam attacks log =
62
  Service CleanTalk (this plugin is a client application for CleanTalk anti-spam service) records all filtered comments, registration and other spam attacks in the "Log of spam attacks" and stores the data in the log up to 45 days. Using the log, you can ensure reliable protection of your website from spam and no false/positive filtering.
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  = No spam comments, no spam registrations, no spam contact emails, no spam trackbacks. CAPTCHA less anti-spam for WordPress =
65
  Spam is one of the most irritating factors. Spam become every year more and conventional anti-spam can no longer handle all the spam bots. CleanTalk prevents spam and automatically blocks it. You'll be surprised of effective protection against spam.
66
 
@@ -105,7 +122,7 @@ Audience engagement plugin <a href="http://wordpress.org/plugins/feedweb/">Feedw
105
  = Setup anti spam plugin =
106
  1. Download, install and activate Anti-spam by CleanTalk.
107
  1. Get Access key <a href="https://cleantalk.org/register?platform=wordpress" target="_blank">https://cleantalk.org/register</a>
108
- 1. Enter Access key on the plugin settings,
109
 
110
  > WordPress console -> Settings -> CleanTalk
111
 
@@ -114,6 +131,7 @@ Audience engagement plugin <a href="http://wordpress.org/plugins/feedweb/">Feedw
114
  > *** Forbidden. Sender blacklisted. ***
115
 
116
  Done!
 
117
  = Manage and control spam protection =
118
  Go to <a href="https://cleantalk.org/my" target="_blank">Dashboard</a> at the cleantalk.org or use <a href="https://play.google.com/store/apps/details?id=org.cleantalk.app">Android</a>, <a href="https://itunes.apple.com/us/app/cleantalk/id825479913?mt=8">iPhone</a> anti-spam app to manage and control spam protection.
119
 
@@ -189,7 +207,7 @@ Yes, it does. Plugin protects web-forms on your websites which are send data to
189
  = Compatible with Cloudflare? =
190
  CleanTalk is fully compatible with CloudFlare. Service doesn't filter CloudFlares IP's (AS13335) over blacklists database, so in this way plugin/service filters spam bots uses other anti spam tests.
191
 
192
- = Can i use CleanTalk functionality in my plugins? =
193
  Yes, you can. Just use following snippet:
194
 
195
  <?php
@@ -215,20 +233,24 @@ or
215
 
216
  define('CLEANTALK_AJAX_USE_FOOTER_HEADER', false); //false - don't use wp_footer() and wp_header() for including AJAX script, true - use it
217
 
218
- = Can i add exclusions for some pages of my site? =
219
  Yes, you can. Add in you config.php file, before defining database constants, this string:
220
 
221
  $cleantalk_url_exclusions = Array('url1', 'url2', 'url3');
222
 
223
  Now, all pages containg strings 'url1', 'url2', or 'url3' will be excluded from anti-spam checking. Remember, that this option will be not applied in registrations and comment checking - they are always protected from spam.
224
 
225
- = Can i exclude personal data from sending to CleanTalk servers? =
226
  Yes, you can. Add in you config.php file, before defining database constants, this string:
227
 
228
  $cleantalk_key_exclusions = Array('key1', 'key2', 'key3');
229
 
230
  Now, all fields in your submissions with keys named 'key1', 'key2' or 'key3' will be excluded from spam checking.
231
 
 
 
 
 
232
 
233
  == Other notes ==
234
 
@@ -316,6 +338,11 @@ WordPress 3.0 at least. PHP 5 with CURL or file_get_contents() function and enab
316
  1. Setup Android/iOS app to have push notices when new legitiamte comments/registrations or contactcs appears on the website.
317
 
318
  == Changelog ==
 
 
 
 
 
319
  = 5.25.2 2015-09-28 =
320
  * Fixed backend bug
321
 
@@ -778,6 +805,11 @@ WordPress 3.0 at least. PHP 5 with CURL or file_get_contents() function and enab
778
  * First version
779
 
780
  == Upgrade Notice ==
 
 
 
 
 
781
  = 5.25.2 2015-09-28 =
782
  * Fixed backend bug
783
 
1
  === Anti-Spam by CleanTalk - No Captcha, no comments & registrations spam ===
2
  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
4
  Requires at least: 3.0
5
  Tested up to: 4.3
6
+ Stable tag: 5.26
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
61
  = Spam attacks log =
62
  Service CleanTalk (this plugin is a client application for CleanTalk anti-spam service) records all filtered comments, registration and other spam attacks in the "Log of spam attacks" and stores the data in the log up to 45 days. Using the log, you can ensure reliable protection of your website from spam and no false/positive filtering.
63
 
64
+ = Spam FireWall =
65
+ CleanTalk has got an advanced option "Spam FireWall", this option allows blocking the most active spam bots before they get access to web site. It prevents loading of pages of the web site by spam bots, so your web server doesn't need perform all scripts on these pages. Also it prevents scanning of pages of the web site spam bots.
66
+ Therefore Spam FireWall significantly can reduce the load on your web server.
67
+
68
+ Spam FireWall also makes CleanTalk the two-step protection from spam bots. Spam FireWall is the first step and it blocks the most active spam bots, CleanTalk Anti-Spam is the second step and it checks all other requests on the web site in the moment before submit comments/registers and etc.
69
+
70
+ = How Spam FireWall works? =
71
+ * The visitor enters to your web site.
72
+ * HTTP request data is checked of the nearly 5,8 million of certain IP spam bots.
73
+ * If it is an active spam bot, it gets a blank page, if it is a visitor then it gets a site page. This is completely transparent to the visitors.
74
+
75
+
76
+ All the CleanTalk Spam FireWall activity is being logged in the process of filtering. The logs will be available for viewing in CleanTalk Dashboard since 10/15/2015.
77
+
78
+ = Spam FireWall DDos Protection =
79
+ Spam FireWall can mitigate HTTP/HTTPS DDoS attacks. When an intruder makes GET requests to attack your website. Spam FireWall blocks all requests from bad IP addresses. Your website givies infringer a special page with description of DDoS rejection instead of the website pages. Therefore Spam FireWall can help to reduce of CPU usage on your server.
80
+
81
  = No spam comments, no spam registrations, no spam contact emails, no spam trackbacks. CAPTCHA less anti-spam for WordPress =
82
  Spam is one of the most irritating factors. Spam become every year more and conventional anti-spam can no longer handle all the spam bots. CleanTalk prevents spam and automatically blocks it. You'll be surprised of effective protection against spam.
83
 
122
  = Setup anti spam plugin =
123
  1. Download, install and activate Anti-spam by CleanTalk.
124
  1. Get Access key <a href="https://cleantalk.org/register?platform=wordpress" target="_blank">https://cleantalk.org/register</a>
125
+ 1. Enter Access key in the settings,
126
 
127
  > WordPress console -> Settings -> CleanTalk
128
 
131
  > *** Forbidden. Sender blacklisted. ***
132
 
133
  Done!
134
+
135
  = Manage and control spam protection =
136
  Go to <a href="https://cleantalk.org/my" target="_blank">Dashboard</a> at the cleantalk.org or use <a href="https://play.google.com/store/apps/details?id=org.cleantalk.app">Android</a>, <a href="https://itunes.apple.com/us/app/cleantalk/id825479913?mt=8">iPhone</a> anti-spam app to manage and control spam protection.
137
 
207
  = Compatible with Cloudflare? =
208
  CleanTalk is fully compatible with CloudFlare. Service doesn't filter CloudFlares IP's (AS13335) over blacklists database, so in this way plugin/service filters spam bots uses other anti spam tests.
209
 
210
+ = Can I use CleanTalk functionality in my plugins? =
211
  Yes, you can. Just use following snippet:
212
 
213
  <?php
233
 
234
  define('CLEANTALK_AJAX_USE_FOOTER_HEADER', false); //false - don't use wp_footer() and wp_header() for including AJAX script, true - use it
235
 
236
+ = Can I add exclusions for some pages of my site? =
237
  Yes, you can. Add in you config.php file, before defining database constants, this string:
238
 
239
  $cleantalk_url_exclusions = Array('url1', 'url2', 'url3');
240
 
241
  Now, all pages containg strings 'url1', 'url2', or 'url3' will be excluded from anti-spam checking. Remember, that this option will be not applied in registrations and comment checking - they are always protected from spam.
242
 
243
+ = Can I exclude personal data from sending to CleanTalk servers? =
244
  Yes, you can. Add in you config.php file, before defining database constants, this string:
245
 
246
  $cleantalk_key_exclusions = Array('key1', 'key2', 'key3');
247
 
248
  Now, all fields in your submissions with keys named 'key1', 'key2' or 'key3' will be excluded from spam checking.
249
 
250
+ = How to test Spam FireWall? =
251
+ Use special IP 10.10.10.10 in URL to test Spam FireWall. For example,
252
+
253
+ https://cleantalk.org/blog/?sfw_test_ip=10.10.10.10
254
 
255
  == Other notes ==
256
 
338
  1. Setup Android/iOS app to have push notices when new legitiamte comments/registrations or contactcs appears on the website.
339
 
340
  == Changelog ==
341
+ = 5.26 2015-10-05 =
342
+ * Added WordPress Language Pack support
343
+ * Removed spam checking for some autorisation plugins
344
+ * New experimental feature: Spam FireWall
345
+
346
  = 5.25.2 2015-09-28 =
347
  * Fixed backend bug
348
 
805
  * First version
806
 
807
  == Upgrade Notice ==
808
+ = 5.26 2015-10-05 =
809
+ * Added WordPress Language Pack support
810
+ * Removed spam checking for some autorisation plugins
811
+ * New experimental feature: Spam FireWall
812
+
813
  = 5.25.2 2015-09-28 =
814
  * Fixed backend bug
815