Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.58

Version Description

February 15 2017 = * Work without access key * Bitrix24 contact integration * Issues fixes

Download this release

Release Info

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

Code changes from version 5.57.1 to 5.58

cleantalk.php CHANGED
@@ -3,12 +3,12 @@
3
  Plugin Name: Spam Protection by CleanTalk
4
  Plugin URI: http://cleantalk.org
5
  Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms. Formerly Anti-Spam by CleanTalk.
6
- Version: 5.57.1
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
10
- $cleantalk_plugin_version='5.57.1';
11
- $ct_agent_version = 'wordpress-5571';
12
  $cleantalk_executed=false;
13
  $ct_sfw_updated = false;
14
 
@@ -30,7 +30,7 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
30
  $ct_data=ct_get_data();
31
 
32
  //Cron jobs
33
- //add_action('cleantalk_send_daily_report_hook', 'cleantalk_send_daily_report'); //Sending daily report // Inactive
34
 
35
  if(!isset($ct_data['db_refreshed'])){
36
 
@@ -131,7 +131,7 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
131
  }
132
  //cron end
133
  }
134
-
135
  if(isset($ct_options['check_external']) && @intval($ct_options['check_external']) == 1)
136
  $test_external_forms=true;
137
  else
@@ -193,6 +193,7 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
193
  add_action('network_admin_menu', 'ct_admin_add_page');
194
 
195
  add_action('admin_notices', 'cleantalk_admin_notice_message');
 
196
  }
197
  if (defined( 'DOING_AJAX' ) && DOING_AJAX||isset($_POST['cma-action'])){
198
  $cleantalk_hooked_actions = array();
@@ -272,6 +273,19 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
272
  ct_contact_form_validate();
273
  $_POST['redirect_to']=$tmp;
274
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
275
  }
276
  }
277
 
@@ -308,12 +322,11 @@ if (!function_exists ( 'ct_activation')) {
308
  //wp_schedule_event(time(), 'hourly', 'ct_send_sfw_log' );
309
  wp_schedule_event(time(), 'daily', 'cleantalk_update_sfw_hook' );
310
  //Sends log every day
311
- //wp_schedule_event(time()+85400 , 'daily', 'cleantalk_send_daily_report_hook' );
312
 
313
  cleantalk_update_sfw();
314
 
315
  add_option('ct_plugin_do_activation_redirect', true);
316
- //add_option('cleantalk_sends_reports_till', time()+7*24*3600);
317
  }
318
  }
319
  /**
@@ -331,9 +344,8 @@ if (!function_exists ( 'ct_deactivation')) {
331
  wp_clear_scheduled_hook( 'ct_send_sfw_log' );
332
  wp_clear_scheduled_hook( 'cleantalk_update_sfw' );
333
  wp_clear_scheduled_hook( 'cleantalk_update_sfw_hook' );
334
- //wp_clear_scheduled_hook( 'cleantalk_send_daily_report_hook' );
335
 
336
- //delete_option('cleantalk_sends_reports_till');
337
  }
338
  }
339
 
@@ -357,7 +369,10 @@ function ct_plugin_redirect()
357
  function ct_add_event($event_type)
358
  {
359
  global $ct_data,$cleantalk_executed;
360
-
 
 
 
361
  //
362
  // To migrate on the new version of ct_add_event().
363
  //
@@ -610,13 +625,12 @@ function ct_send_sfw_log()
610
 
611
  // Sends daily report from get_antispam_report method
612
  function cleantalk_send_daily_report(){
613
-
614
  $do_send = get_option('cleantalk_sends_reports_till');
615
 
616
  // If 7 days is over
617
- if(!$do_send || $do_send < time()){
618
 
619
- delete_option('cleantalk_sends_reports_till');
620
  wp_clear_scheduled_hook( 'cleantalk_send_daily_report_hook' );
621
 
622
  return;
@@ -628,25 +642,27 @@ function cleantalk_send_daily_report(){
628
  $ct_options = ct_get_options();
629
  $ct_data = ct_get_data();
630
  $site_url = get_option('siteurl');
631
-
 
 
632
  if($ct_options['apikey'] == ''){
633
 
634
  if(!function_exists('getAntispamReport'))
635
  include_once("inc/cleantalk.class.php");
636
 
637
- $result = getAntispamReport($site_url);
638
  $result = json_decode($result, true);
639
-
640
  //Connection failed
641
  if(!$result){
642
 
643
  $ct_data['errors'][__FUNCTION__] = array(
644
  'time' => date("M d Y H:i:s", time()),
645
  'error_no' => (-1),
646
- 'error' => false
647
  );
648
  update_option('cleantalk_data', $ct_data);
649
- return;
650
  } //Error returned
651
  elseif(isset($result['error_message']) && isset($result['error_no']))
652
  {
@@ -656,7 +672,7 @@ function cleantalk_send_daily_report(){
656
  'error' => $result['error_message']
657
  );
658
  update_option('cleantalk_data', $ct_data);
659
- return;
660
  } //OK
661
  elseif(!empty($result['data']))
662
  {
@@ -670,11 +686,11 @@ function cleantalk_send_daily_report(){
670
  //Comple mail
671
  include_once("templates/daily_report.php");
672
 
673
- $title = sprintf(__('%d spam attacks have been blocked', 'cleantalk'), $result['Deny_comments'] + $result['Deny_registrations'] + $result['Deny_contacts']);
674
  $events = sprintf($events,
675
- $result['Allow_comments'], $result['Deny_comments'],
676
- $result['Allow_registrations'], $result['Deny_registrations'],
677
- $result['Allow_contacts'], $result['Deny_contacts']
678
  );
679
 
680
  $href_for_network_admin = (is_network_admin() ? "settings" : "options-general");
@@ -684,24 +700,27 @@ function cleantalk_send_daily_report(){
684
  $title, //Title
685
  $events, //Result table
686
  $site_url, $href_for_network_admin, __('Complete setup', 'cleantalk'), //Right link to cleantalk's settings
687
- __('To see the anti-spam log and complete the setup, please get the Access key.', 'cleantalk'),
688
- 'Antispam by CleanTalk'
689
  );
690
 
691
  $admin_email = get_option('admin_email');
692
- $site_url = preg_replace('/http[s]?:\/\//', '', $site_url, 1);
693
- $subject = sprintf(__("%s spam attacks report", "cleantalk"), $site_url);
694
  $headers[] = 'content-type: text/html';
695
- $headers[] = 'From: Antispam by CleanTalk <info@'.preg_replace('/\/[\S]*$/', '', $site_url, 1).'>';
696
 
697
- $send_mail_result = wp_mail(
698
  $admin_email,
699
  $subject,
700
  $message,
701
  $headers
702
  );
 
 
 
703
  }
704
 
 
 
705
  }
706
 
707
  /*
3
  Plugin Name: Spam Protection by CleanTalk
4
  Plugin URI: http://cleantalk.org
5
  Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms. Formerly Anti-Spam by CleanTalk.
6
+ Version: 5.58
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
10
+ $cleantalk_plugin_version='5.58';
11
+ $ct_agent_version = 'wordpress-558';
12
  $cleantalk_executed=false;
13
  $ct_sfw_updated = false;
14
 
30
  $ct_data=ct_get_data();
31
 
32
  //Cron jobs
33
+ add_action('cleantalk_send_daily_report_hook', 'cleantalk_send_daily_report'); //Sending daily report
34
 
35
  if(!isset($ct_data['db_refreshed'])){
36
 
131
  }
132
  //cron end
133
  }
134
+
135
  if(isset($ct_options['check_external']) && @intval($ct_options['check_external']) == 1)
136
  $test_external_forms=true;
137
  else
193
  add_action('network_admin_menu', 'ct_admin_add_page');
194
 
195
  add_action('admin_notices', 'cleantalk_admin_notice_message');
196
+ add_action('network_admin_notices', 'cleantalk_admin_notice_message');
197
  }
198
  if (defined( 'DOING_AJAX' ) && DOING_AJAX||isset($_POST['cma-action'])){
199
  $cleantalk_hooked_actions = array();
273
  ct_contact_form_validate();
274
  $_POST['redirect_to']=$tmp;
275
  }
276
+ //Bitrix24 contact form
277
+ if (ct_is_user_enable()) {
278
+ ct_cookies_test();
279
+
280
+ if (isset($ct_options['general_contact_forms_test']) && $ct_options['general_contact_forms_test'] == 1 &&
281
+ !empty($_POST['your-phone']) &&
282
+ !empty($_POST['your-email']) &&
283
+ !empty($_POST['your-message'])
284
+ ){
285
+ $ct_check_post_result=false;
286
+ ct_contact_form_validate();
287
+ }
288
+ }
289
  }
290
  }
291
 
322
  //wp_schedule_event(time(), 'hourly', 'ct_send_sfw_log' );
323
  wp_schedule_event(time(), 'daily', 'cleantalk_update_sfw_hook' );
324
  //Sends log every day
325
+ wp_schedule_event(time()+85400 , 'daily', 'cleantalk_send_daily_report_hook' );
326
 
327
  cleantalk_update_sfw();
328
 
329
  add_option('ct_plugin_do_activation_redirect', true);
 
330
  }
331
  }
332
  /**
344
  wp_clear_scheduled_hook( 'ct_send_sfw_log' );
345
  wp_clear_scheduled_hook( 'cleantalk_update_sfw' );
346
  wp_clear_scheduled_hook( 'cleantalk_update_sfw_hook' );
347
+ wp_clear_scheduled_hook( 'cleantalk_send_daily_report_hook' );
348
 
 
349
  }
350
  }
351
 
369
  function ct_add_event($event_type)
370
  {
371
  global $ct_data,$cleantalk_executed;
372
+
373
+ if(!get_option('cleantalk_sends_reports_till'));
374
+ add_option('cleantalk_sends_reports_till', time()+7*24*3600);
375
+
376
  //
377
  // To migrate on the new version of ct_add_event().
378
  //
625
 
626
  // Sends daily report from get_antispam_report method
627
  function cleantalk_send_daily_report(){
628
+
629
  $do_send = get_option('cleantalk_sends_reports_till');
630
 
631
  // If 7 days is over
632
+ if((int)$do_send < time()){
633
 
 
634
  wp_clear_scheduled_hook( 'cleantalk_send_daily_report_hook' );
635
 
636
  return;
642
  $ct_options = ct_get_options();
643
  $ct_data = ct_get_data();
644
  $site_url = get_option('siteurl');
645
+ $site_url = preg_replace('/http[s]?:\/\//', '', $site_url, 1);
646
+ $site_domain = preg_replace('/\/.*$/', '', $site_url, 1);
647
+
648
  if($ct_options['apikey'] == ''){
649
 
650
  if(!function_exists('getAntispamReport'))
651
  include_once("inc/cleantalk.class.php");
652
 
653
+ $result = getAntispamReport($site_domain);
654
  $result = json_decode($result, true);
655
+
656
  //Connection failed
657
  if(!$result){
658
 
659
  $ct_data['errors'][__FUNCTION__] = array(
660
  'time' => date("M d Y H:i:s", time()),
661
  'error_no' => (-1),
662
+ 'error' => 'Request method returns FALSE'
663
  );
664
  update_option('cleantalk_data', $ct_data);
665
+ return $ct_data['errors'][__FUNCTION__];
666
  } //Error returned
667
  elseif(isset($result['error_message']) && isset($result['error_no']))
668
  {
672
  'error' => $result['error_message']
673
  );
674
  update_option('cleantalk_data', $ct_data);
675
+ return $ct_data['errors'][__FUNCTION__];
676
  } //OK
677
  elseif(!empty($result['data']))
678
  {
686
  //Comple mail
687
  include_once("templates/daily_report.php");
688
 
689
+ $title = sprintf(__('%d spam attacks have been blocked', 'cleantalk'), $result['deny_comments'] + $result['deny_registrations'] + $result['deny_contacts']);
690
  $events = sprintf($events,
691
+ $result['allow_comments'], $result['deny_comments'],
692
+ $result['allow_registrations'], $result['deny_registrations'],
693
+ $result['allow_contacts'], $result['deny_contacts']
694
  );
695
 
696
  $href_for_network_admin = (is_network_admin() ? "settings" : "options-general");
700
  $title, //Title
701
  $events, //Result table
702
  $site_url, $href_for_network_admin, __('Complete setup', 'cleantalk'), //Right link to cleantalk's settings
703
+ __('To see the anti-spam log and complete the setup, please get the Access key.', 'cleantalk'),
704
+ $site_url, $href_for_network_admin, 'Antispam by CleanTalk' //Right link to cleantalk's settings
705
  );
706
 
707
  $admin_email = get_option('admin_email');
708
+ $subject = sprintf(__("%s spam attacks report", "cleantalk"), $site_domain);
 
709
  $headers[] = 'content-type: text/html';
 
710
 
711
+ $result = $send_mail_result = wp_mail(
712
  $admin_email,
713
  $subject,
714
  $message,
715
  $headers
716
  );
717
+
718
+ return ($result ? true : false);
719
+
720
  }
721
 
722
+ return;
723
+
724
  }
725
 
726
  /*
inc/cleantalk-admin.php CHANGED
@@ -137,10 +137,10 @@ function ct_admin_init()
137
  $ct_options = ct_get_options();
138
  $ct_data = ct_get_data();
139
 
140
- // if(isset($_GET['from_report']) && $_GET['from_report']){
141
- // $ct_data['ct_show_notice_from_report'] = true;
142
- // update_option('cleantalk_data', $ct_data);
143
- // }
144
 
145
  if(isset($_POST['ct_debug_reset']) && $_POST['ct_debug_reset']){
146
  $ct_data['ct_debug_reset'] = true;
@@ -701,7 +701,10 @@ function ct_section_settings_state() {
701
  print ' &nbsp; <img src="'.(($ct_options['comments_test']==1 || $ct_moderate) ? $img : $img_no).'" alt="" height="" /> '.__('Comments forms', 'cleantalk');
702
  print ' &nbsp; <img src="'.(($ct_options['contact_forms_test']==1 || $ct_moderate) ? $img : $img_no).'" alt="" height="" /> '.__('Contact forms', 'cleantalk');
703
  print ' &nbsp; <img src="'.(($ct_options['general_contact_forms_test']==1 || $ct_moderate) ? $img : $img_no).'" alt="" height="" /> '.__('Custom contact forms', 'cleantalk');
704
- print ' &nbsp; <img src="'.(($ct_options['wc_checkout_test']==1 || $ct_moderate) ? $img : $img_no).'" alt="" height="" /> '.__('WooCommerce checkout form', 'cleantalk');
 
 
 
705
  if($ct_options['spam_firewall']==1 || $ct_moderate)
706
  print ' &nbsp; <img src="'.$img.'" alt="" height="" /> '.__('SpamFireWall', 'cleantalk');
707
 
@@ -1389,17 +1392,17 @@ function ct_settings_page() {
1389
 
1390
  if (ct_valid_key() === false){
1391
 
1392
- // $page = get_current_screen();
1393
- // $trial_time = get_option('cleantalk_sends_reports_till');
1394
- // $trial_days_left = ($trial_time ? ceil(($trial_time - time()) / 86400) : false);
1395
 
1396
  // Trial days
1397
- // if ((is_network_admin() || is_admin()) && $trial_days_left && $page->id == 'settings_page_cleantalk' && $ct_data['moderate_ip'] == 0){
1398
- // $trial_days_left = 7;
1399
- // echo ($trial_days_left == 1 ? "<span style='color:red;'>" : "");
1400
- // echo '<br>' . sprintf(__("You have <b>%d</b> days free trial to test the anti-spam protection.", 'cleantalk'), $trial_days_left) . '';
1401
- // echo ($trial_days_left == 1 ? "</span>" : "");
1402
- // }
1403
 
1404
  }else{
1405
 
@@ -1428,87 +1431,95 @@ function cleantalk_admin_notice_message(){
1428
 
1429
  $ct_options = ct_get_options();
1430
  $ct_data = ct_get_data();
 
1431
 
1432
  if(!isset($ct_data['moderate_ip']))
1433
- {
1434
  $ct_data['moderate_ip'] = 0;
1435
- }
1436
-
1437
- $user_token = '';
1438
- if (isset($ct_data['user_token']) && $ct_data['user_token'] != '') {
1439
- $user_token = '&user_token=' . $ct_data['user_token'];
1440
- }
1441
-
1442
- $show_notice = true;
1443
 
1444
- if(current_user_can('activate_plugins'))
1445
- {
1446
- $value = 1;
1447
- }
1448
- else
1449
- {
1450
- $value = 0;
1451
- }
1452
-
1453
- if ($show_notice && $show_ct_notice_autokey && $value==1 && (is_network_admin() || (!defined('WP_ALLOW_MULTISITE')||defined('WP_ALLOW_MULTISITE')&&WP_ALLOW_MULTISITE==false) && is_admin())) {
1454
- echo '<div class="error"><h3>' . sprintf(__("Unable to get Access key automatically: %s", 'cleantalk'), $ct_notice_autokey_value);
1455
- echo " <a target='__blank' style='margin-left: 10px' href='https://cleantalk.org/register?platform=wordpress&email=".urlencode(ct_get_admin_email())."&website=".urlencode(parse_url(get_option('siteurl'),PHP_URL_HOST))."'>".__('Get the Access key', 'cleantalk').'</a></h3></div>';
1456
- }
1457
-
1458
- if ($ct_data['moderate_ip'] == 0 && $show_notice && ct_valid_key($ct_options['apikey']) === false && $value==1 &&
1459
- (is_network_admin() || (!defined('WP_ALLOW_MULTISITE')||defined('WP_ALLOW_MULTISITE')&&WP_ALLOW_MULTISITE==false) && is_admin()) ) {
1460
- 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>';
1461
- $show_notice = false;
1462
- }
1463
-
1464
- if(isset($ct_data['show_ct_notice_trial']))
1465
- {
1466
- $show_ct_notice_trial = intval($ct_data['show_ct_notice_trial']);
1467
- }
1468
- else
1469
- {
1470
- $show_ct_notice_trial = 0;
1471
- }
1472
 
1473
- if ($show_notice && $show_ct_notice_trial ==1 && $value==1 && (is_network_admin() || is_admin()) && $ct_data['moderate_ip'] == 0) {
1474
- 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&cp_mode=antispam\" target=\"_blank\"><b>premium version</b></a>") . '</h3></div>';
1475
- $show_notice = false;
1476
- }
 
 
1477
 
1478
- if(isset($ct_data['next_notice_show']))
1479
- {
1480
- $next_notice_show=$ct_data['next_notice_show'];
1481
- }
1482
- else
1483
- {
1484
- $next_notice_show=0;
1485
- }
1486
-
1487
- if(isset($ct_data['show_ct_notice_renew']))
1488
- {
1489
- $show_ct_notice_renew = intval($ct_data['show_ct_notice_renew']);
1490
- }
1491
- else
1492
- {
1493
- $show_ct_notice_renew = 0;
1494
- }
1495
-
1496
- if ($show_notice && $show_ct_notice_renew == 1 && $value==1 && (is_network_admin() || is_admin()) && $ct_data['moderate_ip'] != 1) {
1497
- $button_html = "<a href=\"http://cleantalk.org/my/bill/recharge?utm_source=wp-backend&utm_medium=cpc&utm_campaign=WP%20backend%20renew$user_token&cp_mode=antispam\" target=\"_blank\">" . '<input type="button" class="button button-primary" value="' . __('RENEW ANTI-SPAM', 'cleantalk') . '" />' . "</a>";
1498
- echo '<div class="updated"><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&cp_mode=antispam\" target=\"_blank\"><b>" . __('next year', 'cleantalk') ."</b></a>") . '<br /><br />' . $button_html . '</h3></div>';
1499
- $show_notice = false;
1500
- }
1501
-
1502
- if ($show_notice && $show_ct_notice_online != '' && $value==1 && (is_network_admin() || is_admin()) && $ct_data['moderate_ip'] != 1) {
1503
- if($show_ct_notice_online === 'N' && $value==1 && (is_network_admin() || (!defined('WP_ALLOW_MULTISITE')||defined('WP_ALLOW_MULTISITE')&&WP_ALLOW_MULTISITE==false) && is_admin()) && $ct_data['moderate_ip'] != 1){
1504
- echo '<div class="error"><h3><b>';
1505
- 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');
1506
- echo '</b></h3></div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1507
  }
1508
  }
1509
 
1510
- //ct_send_feedback(); -- removed to ct_do_this_hourly()
1511
-
1512
  return true;
1513
  }
1514
 
@@ -1712,6 +1723,7 @@ function ct_update_option($option_name) {
1712
  $request=Array();
1713
  $request['method_name'] = 'notice_validate_key';
1714
  $request['auth_key'] = $api_key;
 
1715
  $url='https://api.cleantalk.org';
1716
  if(!function_exists('sendRawRequest'))
1717
  {
137
  $ct_options = ct_get_options();
138
  $ct_data = ct_get_data();
139
 
140
+ if(isset($_GET['from_report']) && $_GET['from_report']){
141
+ $ct_data['ct_show_notice_from_report'] = true;
142
+ update_option('cleantalk_data', $ct_data);
143
+ }
144
 
145
  if(isset($_POST['ct_debug_reset']) && $_POST['ct_debug_reset']){
146
  $ct_data['ct_debug_reset'] = true;
701
  print ' &nbsp; <img src="'.(($ct_options['comments_test']==1 || $ct_moderate) ? $img : $img_no).'" alt="" height="" /> '.__('Comments forms', 'cleantalk');
702
  print ' &nbsp; <img src="'.(($ct_options['contact_forms_test']==1 || $ct_moderate) ? $img : $img_no).'" alt="" height="" /> '.__('Contact forms', 'cleantalk');
703
  print ' &nbsp; <img src="'.(($ct_options['general_contact_forms_test']==1 || $ct_moderate) ? $img : $img_no).'" alt="" height="" /> '.__('Custom contact forms', 'cleantalk');
704
+
705
+ if(class_exists('WooCommerce'))
706
+ print ' &nbsp; <img src="'.(($ct_options['wc_checkout_test']==1 || $ct_moderate) ? $img : $img_no).'" alt="" height="" /> '.__('WooCommerce checkout form', 'cleantalk');
707
+
708
  if($ct_options['spam_firewall']==1 || $ct_moderate)
709
  print ' &nbsp; <img src="'.$img.'" alt="" height="" /> '.__('SpamFireWall', 'cleantalk');
710
 
1392
 
1393
  if (ct_valid_key() === false){
1394
 
1395
+ $page = get_current_screen();
1396
+ $trial_time = get_option('cleantalk_sends_reports_till');
1397
+ $trial_days_left = ($trial_time ? ceil(($trial_time - time()) / 86400) : false);
1398
 
1399
  // Trial days
1400
+ if ((is_network_admin() || is_admin()) && $trial_days_left && $page->id == 'settings_page_cleantalk' && $ct_data['moderate_ip'] == 0){
1401
+ $trial_days_left = 7; //Magic number!
1402
+ echo ($trial_days_left == 1 ? "<span style='color:red;'>" : "");
1403
+ echo '<br>' . sprintf(__("You have <b>%d</b> days free trial to test the anti-spam protection.", 'cleantalk'), $trial_days_left) . '';
1404
+ echo ($trial_days_left == 1 ? "</span>" : "");
1405
+ }
1406
 
1407
  }else{
1408
 
1431
 
1432
  $ct_options = ct_get_options();
1433
  $ct_data = ct_get_data();
1434
+ $page = get_current_screen();
1435
 
1436
  if(!isset($ct_data['moderate_ip']))
 
1437
  $ct_data['moderate_ip'] = 0;
 
 
 
 
 
 
 
 
1438
 
1439
+ //General notice control flags
1440
+ $self_owned_key = (!$ct_data['moderate_ip'] && !defined('CLEANTALK_ACCESS_KEY') ? true : false);
1441
+ $is_admin = (is_network_admin() || is_admin() ? true : false);
1442
+ $value = 1; //(current_user_can('activate_plugins') ? 1 : 0); //inactive
1443
+ $show_notice = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1444
 
1445
+ //Notice control flags
1446
+ $show_ct_notice_trial = (isset($ct_data['show_ct_notice_trial']) ? intval($ct_data['show_ct_notice_trial']) : 0);
1447
+ $show_ct_notice_renew = (isset($ct_data['show_ct_notice_renew']) ? intval($ct_data['show_ct_notice_renew']) : 0);
1448
+ $next_notice_show = (isset($ct_data['next_notice_show']) ? intval($ct_data['next_notice_show']) : 0); //inactive
1449
+ $notice_from_report = (isset($ct_data['ct_show_notice_from_report']) ? intval($ct_data['ct_show_notice_from_report']) : 0);
1450
+ $page_is_ct_settings = ($page->id == 'settings_page_cleantalk' || $page->id == 'settings_page_cleantalk-network' ? true : false);
1451
 
1452
+ //Misc
1453
+ $user_token = (isset($ct_data['user_token']) && $ct_data['user_token'] != '' ? "&user_token={$ct_data['user_token']}" : "");
1454
+
1455
+ if($self_owned_key && $is_admin && $value == 1){
1456
+
1457
+ //Notice when users came from the daily report letter
1458
+ if ($show_notice && $notice_from_report && !ct_valid_key()){
1459
+
1460
+ if($page_is_ct_settings)
1461
+ echo '<div class="error">
1462
+ <h3>' .__("To see the anti-spam log and complete the setup, please get the Access key.", 'cleantalk'). '</h3>
1463
+ </div>';
1464
+ $show_notice = false;
1465
+ }
1466
+
1467
+ //Unable to get key automatically (if ct_admin_init().getAutoKey() returns error)
1468
+ if ($show_notice && $show_ct_notice_autokey){
1469
+ echo '<div class="error">
1470
+ <h3>' . sprintf(__("Unable to get Access key automatically: %s", 'cleantalk'), $ct_notice_autokey_value).
1471
+ "<a target='__blank' style='margin-left: 10px' href='https://cleantalk.org/register?platform=wordpress&email=" . urlencode(ct_get_admin_email())."&website=" . urlencode(parse_url(get_option('siteurl'),PHP_URL_HOST))."'>".__('Get the Access key', 'cleantalk').'</a>
1472
+ </h3>
1473
+ </div>';
1474
+ }
1475
+
1476
+ //key == "" || "enter key"
1477
+ if ($show_notice && !ct_valid_key()){
1478
+
1479
+ if($page_is_ct_settings)
1480
+ echo '<div class="error">
1481
+ <h3>' . sprintf(__("Please enter Access Key in %s settings to enable anti spam protection!", 'cleantalk'), "
1482
+ <a href=\"options-general.php?page=cleantalk\">CleanTalk plugin</a>") .
1483
+ '</h3>
1484
+ </div>';
1485
+ $show_notice = false;
1486
+ }
1487
+
1488
+ //"Trial period ends" notice from ct_admin_init().noticePaidTill()
1489
+ if ($show_notice && $show_ct_notice_trial == 1) {
1490
+ echo '<div class="error">
1491
+ <h3>' . sprintf(__("%s trial period ends, please upgrade to %s!", 'cleantalk'),
1492
+ "<a href=\"options-general.php?page=cleantalk\">$ct_plugin_name</a>",
1493
+ "<a href=\"http://cleantalk.org/my/bill/recharge?utm_source=wp-backend&utm_medium=cpc&utm_campaign=WP%20backend%20trial$user_token&cp_mode=antispam\" target=\"_blank\"><b>premium version</b></a>") .
1494
+ '</h3>
1495
+ </div>';
1496
+ $show_notice = false;
1497
+ }
1498
+
1499
+ //Renew notice from ct_admin_init().noticePaidTill()
1500
+ if ($show_notice && $show_ct_notice_renew == 1) {
1501
+ $renew_link = "<a href=\"http://cleantalk.org/my/bill/recharge?utm_source=wp-backend&utm_medium=cpc&utm_campaign=WP%%20backend%%20renew$user_token&cp_mode=antispam\" target=\"_blank\">%s</a>";
1502
+ $button_html = sprintf($renew_link, '<input type="button" class="button button-primary" value="'.__('RENEW ANTI-SPAM', 'cleantalk').'" />');
1503
+ $link_html = sprintf($renew_link, "<b>".__('next year', 'cleantalk')."</b>");
1504
+
1505
+ echo '<div class="updated">
1506
+ <h3>'.
1507
+ sprintf(__("Please renew your anti-spam license for %s.", 'cleantalk'), $link_html). '<br /><br />' . $button_html .
1508
+ '</h3>
1509
+ </div>';
1510
+ $show_notice = false;
1511
+ }
1512
+
1513
+ //"Wrong access key" notice (if ct_update_option().METHOD_notice_validate_key returns a error)
1514
+ if ($show_notice && $show_ct_notice_online === 'N'){
1515
+ echo '<div class="error">
1516
+ <h3><b>'.
1517
+ __("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').
1518
+ '</b></h3>
1519
+ </div>';
1520
  }
1521
  }
1522
 
 
 
1523
  return true;
1524
  }
1525
 
1723
  $request=Array();
1724
  $request['method_name'] = 'notice_validate_key';
1725
  $request['auth_key'] = $api_key;
1726
+ $request['path_to_cms'] = preg_replace('/http[s]?:\/\//', '', get_option('siteurl'), 1);
1727
  $url='https://api.cleantalk.org';
1728
  if(!function_exists('sendRawRequest'))
1729
  {
inc/cleantalk-ajax.php CHANGED
@@ -15,7 +15,7 @@ $cleantalk_ajax_actions_to_check[] = 'amoforms_submit'; //amoForms
15
  $cleantalk_hooked_actions[] = 'rwp_ajax_action_rating'; //Don't check Reviewer plugin
16
 
17
  /* MailChimp Premium*/
18
- add_filter('mc4wp_form_errors', 'ct_ajax_hook', 1, 2);
19
 
20
  /*hooks for Usernoise Form*/
21
  add_action('un_feedback_form_body', 'ct_add_hidden_fields',1);
@@ -291,6 +291,24 @@ function ct_user_register_ajaxlogin($user_id)
291
  return $user_id;
292
  }
293
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
  function ct_ajax_hook($message_obj = false, $additional = false)
295
  {
296
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
@@ -574,10 +592,10 @@ function ct_ajax_hook($message_obj = false, $additional = false)
574
  print json_encode($result);
575
  die();
576
  }
577
- elseif(isset($_POST['_mc4wp_timestamp']) && isset($_POST['_mc4wp_form_id']))
 
578
  {
579
- $message_obj[] = 'ct_mc4wp_response';
580
- return $message_obj;
581
  }
582
  else
583
  {
15
  $cleantalk_hooked_actions[] = 'rwp_ajax_action_rating'; //Don't check Reviewer plugin
16
 
17
  /* MailChimp Premium*/
18
+ add_filter('mc4wp_form_errors', 'ct_mc4wp_ajax_hook');
19
 
20
  /*hooks for Usernoise Form*/
21
  add_action('un_feedback_form_body', 'ct_add_hidden_fields',1);
291
  return $user_id;
292
  }
293
 
294
+ /**
295
+ * Hook into MailChimp for WordPress `mc4wp_form_errors` filter.
296
+ *
297
+ * @param array $errors
298
+ * @return array
299
+ */
300
+ function ct_mc4wp_ajax_hook( array $errors )
301
+ {
302
+ $result = ct_ajax_hook();
303
+
304
+ // only return modified errors array when function returned a string value (the message key)
305
+ if( is_string( $result ) ) {
306
+ $errors[] = $result;
307
+ }
308
+
309
+ return $errors;
310
+ }
311
+
312
  function ct_ajax_hook($message_obj = false, $additional = false)
313
  {
314
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
592
  print json_encode($result);
593
  die();
594
  }
595
+ //MailChimp for Wordpress Premium
596
+ elseif(!empty($_POST['_mc4wp_form_id']))
597
  {
598
+ return 'ct_mc4wp_response';
 
599
  }
600
  else
601
  {
inc/cleantalk-public.php CHANGED
@@ -629,12 +629,11 @@ function ct_footer_add_cookie() {
629
  return null;
630
  }
631
 
632
- function ct_page_count(){
633
-
634
- ct_init_session();
635
-
636
- $_SESSION['ct_page_hits'] = (!isset($_SESSION['ct_page_hits']) ? 1 : $_SESSION['ct_page_hits'] + 1);
637
-
638
  }
639
 
640
  /**
@@ -2586,7 +2585,7 @@ function ct_contact_form_validate () {
2586
  /**
2587
  * General test for any post data
2588
  */
2589
- function ct_contact_form_validate_postdata () {
2590
  global $pagenow,$cleantalk_executed, $cleantalk_url_exclusions, $ct_options, $ct_data;
2591
 
2592
  $ct_options = ct_get_options();
@@ -2626,7 +2625,9 @@ function ct_contact_form_validate_postdata () {
2626
  isset($_POST['bbp_reply_content']) ||
2627
  isset($_POST['fscf_submitted']) ||
2628
  isset($_POST['log']) && isset($_POST['pwd']) && isset($_POST['wp-submit'])||
2629
- strpos($_SERVER['REQUEST_URI'],'/wc-api/')!==false
 
 
2630
  ) {
2631
  return null;
2632
  }
629
  return null;
630
  }
631
 
632
+ /**
633
+ * Adds initiates and ++ page counter
634
+ */
635
+ function ct_page_count(){
636
+ $_SESSION['ct_page_hits'] = (!isset($_SESSION['ct_page_hits']) ? 1 : $_SESSION['ct_page_hits'] + 1);
 
637
  }
638
 
639
  /**
2585
  /**
2586
  * General test for any post data
2587
  */
2588
+ function ct_contact_form_validate_postdata() {
2589
  global $pagenow,$cleantalk_executed, $cleantalk_url_exclusions, $ct_options, $ct_data;
2590
 
2591
  $ct_options = ct_get_options();
2625
  isset($_POST['bbp_reply_content']) ||
2626
  isset($_POST['fscf_submitted']) ||
2627
  isset($_POST['log']) && isset($_POST['pwd']) && isset($_POST['wp-submit'])||
2628
+ strpos($_SERVER['REQUEST_URI'],'/wc-api/')!==false ||
2629
+ (isset($_POST['wc_reset_password'], $_POST['_wpnonce'], $_POST['_wp_http_referer'])) || //WooCommerce recovery password form
2630
+ (isset($_POST['woocommerce-login-nonce'], $_POST['login'], $_POST['password'], $_POST['_wp_http_referer'])) //WooCommerce login form
2631
  ) {
2632
  return null;
2633
  }
inc/cleantalk.class.php CHANGED
@@ -752,22 +752,11 @@ class Cleantalk {
752
  //$msg->remote_addr=$_SERVER['REMOTE_ADDR'];
753
  //$msg->sender_info['remote_addr']=$_SERVER['REMOTE_ADDR'];
754
  $si=(array)json_decode($msg->sender_info,true);
755
- if(defined('IN_PHPBB'))
756
- {
757
- global $request;
758
- if(method_exists($request,'server'))
759
- {
760
- $si['remote_addr']=$request->server('REMOTE_ADDR');
761
- $msg->x_forwarded_for=$request->server('X_FORWARDED_FOR');
762
- $msg->x_real_ip=$request->server('X_REAL_IP');
763
- }
764
- }
765
- else
766
- {
767
- $si['remote_addr']=$_SERVER['REMOTE_ADDR'];
768
- $msg->x_forwarded_for=@$_SERVER['X_FORWARDED_FOR'];
769
- $msg->x_real_ip=@$_SERVER['X_REAL_IP'];
770
- }
771
  $msg->sender_info=json_encode($si);
772
  if (((isset($this->work_url) && $this->work_url !== '') && ($this->server_changed + $this->server_ttl > time()))
773
  || $this->stay_on_server == true) {
@@ -1214,11 +1203,6 @@ if( !function_exists('apache_request_headers') )
1214
  {
1215
  $arh = array();
1216
  $rx_http = '/\AHTTP_/';
1217
- if(defined('IN_PHPBB'))
1218
- {
1219
- global $request;
1220
- $request->enable_super_globals();
1221
- }
1222
  foreach($_SERVER as $key => $val)
1223
  {
1224
  if( preg_match($rx_http, $key) )
@@ -1234,22 +1218,12 @@ if( !function_exists('apache_request_headers') )
1234
  $arh[$arh_key] = $val;
1235
  }
1236
  }
1237
- if(defined('IN_PHPBB'))
1238
- {
1239
- global $request;
1240
- $request->disable_super_globals();
1241
- }
1242
  return( $arh );
1243
  }
1244
  }
1245
 
1246
  function cleantalk_get_real_ip()
1247
  {
1248
- if(defined('IN_PHPBB'))
1249
- {
1250
- global $request;
1251
- $request->enable_super_globals();
1252
- }
1253
  if ( function_exists( 'apache_request_headers' ) )
1254
  {
1255
  $headers = apache_request_headers();
@@ -1273,11 +1247,6 @@ function cleantalk_get_real_ip()
1273
  {
1274
  $the_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 );
1275
  }
1276
- if(defined('IN_PHPBB'))
1277
- {
1278
- global $request;
1279
- $request->disable_super_globals();
1280
- }
1281
  return $the_ip;
1282
  }
1283
 
752
  //$msg->remote_addr=$_SERVER['REMOTE_ADDR'];
753
  //$msg->sender_info['remote_addr']=$_SERVER['REMOTE_ADDR'];
754
  $si=(array)json_decode($msg->sender_info,true);
755
+
756
+ $si['remote_addr']=$_SERVER['REMOTE_ADDR'];
757
+ $msg->x_forwarded_for=@$_SERVER['X_FORWARDED_FOR'];
758
+ $msg->x_real_ip=@$_SERVER['X_REAL_IP'];
759
+
 
 
 
 
 
 
 
 
 
 
 
760
  $msg->sender_info=json_encode($si);
761
  if (((isset($this->work_url) && $this->work_url !== '') && ($this->server_changed + $this->server_ttl > time()))
762
  || $this->stay_on_server == true) {
1203
  {
1204
  $arh = array();
1205
  $rx_http = '/\AHTTP_/';
 
 
 
 
 
1206
  foreach($_SERVER as $key => $val)
1207
  {
1208
  if( preg_match($rx_http, $key) )
1218
  $arh[$arh_key] = $val;
1219
  }
1220
  }
 
 
 
 
 
1221
  return( $arh );
1222
  }
1223
  }
1224
 
1225
  function cleantalk_get_real_ip()
1226
  {
 
 
 
 
 
1227
  if ( function_exists( 'apache_request_headers' ) )
1228
  {
1229
  $headers = apache_request_headers();
1247
  {
1248
  $the_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 );
1249
  }
 
 
 
 
 
1250
  return $the_ip;
1251
  }
1252
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: znaeff, shagimuratov, serge00, sartemd174
3
  Tags: spam, anti-spam, antispam, anti spam, bbpress, buddypress, captcha, capcha, captha, catcha, cf7 spam, comments, contact form spam, signup, spammers, spammy, woocommerce, wordpress spam, subscription, gravity spam, jetpack, bots, contact form 7, contact form, registrations, ninja, Fast Secure Contact, Gravity forms, formidable, mailchimp, s2member, protection, protect, email, plugin, contact, recaptcha, google captcha, google recaptcha, blacklist, prevent spam comments, wordpress, User Frontend, bulk delete, bulk remove, widget, review, firewall, cleantalk, mailpoet, profile builder, comment spam, registration spam, spam comments, comment moderation, spam bots, block spam, signup spam, spam blocker, spam filter, user registration spam,pingback,trackback, anti-spam plugin, varnish, amp, spam free, userpro,honeypot,puzzle,quiz,survey,poll,security, amo forms, caldera forms, visual form builder, contact form clean and simple
4
  Requires at least: 3.0
5
- Tested up to: 4.7.1
6
- Stable tag: 5.57.1
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -486,6 +486,11 @@ WordPress 3.0 at least. PHP 5 with CURL or file_get_contents() function and enab
486
  1. The Dashboard with a map of most spam active countries per your account.
487
 
488
  == Changelog ==
 
 
 
 
 
489
  = 5.57.1 February 8 2017 =
490
  * Fix for notice logic.
491
 
@@ -1238,6 +1243,11 @@ WordPress 3.0 at least. PHP 5 with CURL or file_get_contents() function and enab
1238
  * First version
1239
 
1240
  == Upgrade Notice ==
 
 
 
 
 
1241
  = 5.57.1 February 8 2017 =
1242
  * Fix for notice logic.
1243
 
2
  Contributors: znaeff, shagimuratov, serge00, sartemd174
3
  Tags: spam, anti-spam, antispam, anti spam, bbpress, buddypress, captcha, capcha, captha, catcha, cf7 spam, comments, contact form spam, signup, spammers, spammy, woocommerce, wordpress spam, subscription, gravity spam, jetpack, bots, contact form 7, contact form, registrations, ninja, Fast Secure Contact, Gravity forms, formidable, mailchimp, s2member, protection, protect, email, plugin, contact, recaptcha, google captcha, google recaptcha, blacklist, prevent spam comments, wordpress, User Frontend, bulk delete, bulk remove, widget, review, firewall, cleantalk, mailpoet, profile builder, comment spam, registration spam, spam comments, comment moderation, spam bots, block spam, signup spam, spam blocker, spam filter, user registration spam,pingback,trackback, anti-spam plugin, varnish, amp, spam free, userpro,honeypot,puzzle,quiz,survey,poll,security, amo forms, caldera forms, visual form builder, contact form clean and simple
4
  Requires at least: 3.0
5
+ Tested up to: 4.7.2
6
+ Stable tag: 5.58
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
486
  1. The Dashboard with a map of most spam active countries per your account.
487
 
488
  == Changelog ==
489
+ = 5.58 February 15 2017 =
490
+ * Work without access key
491
+ * Bitrix24 contact integration
492
+ * Issues fixes
493
+
494
  = 5.57.1 February 8 2017 =
495
  * Fix for notice logic.
496
 
1243
  * First version
1244
 
1245
  == Upgrade Notice ==
1246
+ = 5.58 February 15 2017 =
1247
+ * Work without access key
1248
+ * Bitrix24 contact integration
1249
+ * Issues fixes
1250
+
1251
  = 5.57.1 February 8 2017 =
1252
  * Fix for notice logic.
1253
 
templates/daily_report.php CHANGED
@@ -9,18 +9,18 @@ $msg_template = <<<EOT
9
  <div>
10
  <h1>%s</h1>
11
  </div>
12
- <div>
13
  %s
14
  </div>
15
  <br />
16
  <div>
17
- <a class='ct_settings_button' href='%s/wp-admin/%s.php?page=cleantalk&from_report=1' target="_blank">%s</a>.
18
  </div>
19
  <span>%s</span>
20
  <br />
21
  <br />
22
  <div style="color: #666;">
23
- The report is provided by <a href="https://wordpress.org/plugins/cleantalk-spam-protect/">%s</a>.
24
  </div>
25
  </center>
26
  </body>
@@ -145,7 +145,7 @@ $style = <<<EOT
145
  EOT;
146
 
147
  $events = <<<EOT
148
- <table width="400px" border="1" padding="1">
149
  <thead>
150
  <tr>
151
  <th class="ct_hat">
9
  <div>
10
  <h1>%s</h1>
11
  </div>
12
+ <div style="text-align: center">
13
  %s
14
  </div>
15
  <br />
16
  <div>
17
+ <a class='ct_settings_button' href='http://%s/wp-admin/%s.php?page=cleantalk&from_report=1' target="_blank">%s</a>
18
  </div>
19
  <span>%s</span>
20
  <br />
21
  <br />
22
  <div style="color: #666;">
23
+ The report is provided by <a href="http://%s/wp-admin/%s.php?page=cleantalk&from_report=1">%s</a>.
24
  </div>
25
  </center>
26
  </body>
145
  EOT;
146
 
147
  $events = <<<EOT
148
+ <table width="400px" border="1" padding="1" style="margin: 0 auto;">
149
  <thead>
150
  <tr>
151
  <th class="ct_hat">