Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.106

Version Description

October 11 2018 = * Spam filtration improved. * New: White Label mode. * Modification: Warning message about test on SpamFireWall die page. * Integration: WP Maintenance Mode. * Fix: S2Member. * Fix: JavaScript attachments reconsidered. * Fix: Admin banners layout. * Fix: Minor layout fixes.

Download this release

Release Info

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

Code changes from version 5.105 to 5.106

cleantalk.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Anti-Spam by CleanTalk
4
  Plugin URI: http://cleantalk.org
5
  Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
6
- Version: 5.105
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
@@ -16,13 +16,16 @@ $plugin_info = get_file_data(__FILE__, array('Version' => 'Version', 'Name' => '
16
  // Common params
17
  define('APBCT_NAME', $plugin_info['Name']);
18
  define('APBCT_VERSION', $plugin_info['Version']);
19
- define('APBCT_AGENT', 'wordpress-'.str_replace('.', '', $plugin_info['Version']));
20
- define('APBCT_API_URL', 'https://api.cleantalk.org'); //Api URL
21
  define('APBCT_URL_PATH', plugins_url('', __FILE__)); //HTTP path. Plugin root folder without '/'.
22
  define('APBCT_DIR_PATH', plugin_dir_path(__FILE__)); //System path. Plugin root folder with '/'.
23
  define('APBCT_PLUGIN_BASE_NAME', plugin_basename(__FILE__)); //Plugin base name.
24
  define('APBCT_CASERT_PATH', file_exists(ABSPATH.WPINC.'/certificates/ca-bundle.crt') ? ABSPATH.WPINC.'/certificates/ca-bundle.crt' : ''); // SSL Serttificate path
25
 
 
 
 
 
 
26
  // Option names
27
  define('APBCT_DATA', 'cleantalk_data'); //Option name with different plugin data.
28
  define('APBCT_SETTINGS', 'cleantalk_settings'); //Option name with plugin settings.
@@ -44,33 +47,67 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
44
 
45
  define('CLEANTALK_PLUGIN_DIR', plugin_dir_path(__FILE__));
46
 
 
 
47
  require_once( CLEANTALK_PLUGIN_DIR . 'lib/cleantalk-php-patch.php'); // Pathces fpr different functions which not exists
48
  require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkHelper.php'); // Helper class. Different useful functions
 
49
  require_once( CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk.php'); // Main class for request
50
  require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkRequest.php'); // Holds request data
51
  require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkResponse.php'); // Holds response data
52
  require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkCron.php'); // Cron handling
53
- require_once( CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-widget.php');
54
- require_once( CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-common.php');
55
  require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkState.php'); // State class
56
-
57
 
58
  // Global ArrayObject with settings and other global varables
59
  global $apbct;
60
- $apbct = new CleantalkState('cleantalk', array('settings', 'data', 'debug', 'errors'));
61
 
62
  // Customize CleantalkState
63
  // Account status
64
  $apbct->plugin_name = APBCT_NAME;
65
  $apbct->base_name = 'cleantalk-spam-protect/cleantalk.php';
66
 
67
- $apbct->settings['apikey'] = defined('CLEANTALK_ACCESS_KEY') ? CLEANTALK_ACCESS_KEY : $apbct->settings['apikey'];
 
 
 
68
  $apbct->key_is_ok = !empty($apbct->data['key_is_ok']) ? $apbct->data['key_is_ok'] : 0;
69
  $apbct->key_is_ok = isset($apbct->data['testing_failed']) && $apbct->data['testing_failed'] == 0 ? 1 : $apbct->key_is_ok;
70
 
71
  $apbct->data['user_counter']['since'] = isset($apbct->data['user_counter']['since']) ? $apbct->data['user_counter']['since'] : date('d M');
72
  $apbct->data['connection_reports']['since'] = isset($apbct->data['connection_reports']['since']) ? $apbct->data['user_counter']['since'] : date('d M');
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  // Self cron
75
  if(!defined('DOING_CRON') || (defined('DOING_CRON') && DOING_CRON !== true)){
76
 
@@ -87,11 +124,11 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
87
  }
88
 
89
  //Delete cookie for admin trial notice
90
- add_action('wp_logout', 'ct_wp_logout');
91
 
92
  // Set cookie only for unauthorized users and for non-AJAX requests
93
- if (!is_admin() && (!defined('DOING_AJAX') || (defined('DOING_AJAX') && !DOING_AJAX))){
94
- add_action('template_redirect','apbct_cookie', 2);
95
  }
96
 
97
  // Early checks
@@ -338,7 +375,7 @@ function apbct_remote_call__perform()
338
  die(empty($result['error']) ? 'OK' : 'FAIL '.json_encode(array('error' => $result['error_string'])));
339
  // Update plugin
340
  }elseif($_GET['spbc_remote_call_action'] == 'update_plugin'){
341
- add_action('template_redirect', 'apbct_update', 1);
342
  }else
343
  die('FAIL '.json_encode(array('error' => 'UNKNOWN_ACTION')));
344
  }else
@@ -372,17 +409,18 @@ function apbct_sfw__check()
372
  }
373
  }
374
 
 
375
  include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
376
 
377
  $is_sfw_check = true;
378
  $sfw = new CleantalkSFW();
379
- $sfw->ip_array = (array)CleantalkSFW::ip_get(array('real'), true);
380
 
381
  foreach($sfw->ip_array as $ct_cur_ip){
382
  if(isset($_COOKIE['ct_sfw_pass_key']) && $_COOKIE['ct_sfw_pass_key'] == md5($ct_cur_ip.$apbct->api_key)){
383
  $is_sfw_check=false;
384
  if(isset($_COOKIE['ct_sfw_passed'])){
385
- $sfw->sfw_update_logs($ct_cur_ip, 'passed');
386
  $apbct->data['sfw_counter']['all']++;
387
  $apbct->saveData();
388
  if(!headers_sent())
@@ -406,9 +444,9 @@ function apbct_sfw__check()
406
  }
407
 
408
  if($is_sfw_check){
409
- $sfw->check_ip();
410
  if($sfw->result){
411
- $sfw->sfw_update_logs($sfw->blocked_ip, 'blocked');
412
  $apbct->data['sfw_counter']['blocked']++;
413
  $apbct->saveData();
414
  $sfw->sfw_die($apbct->api_key);
@@ -548,6 +586,7 @@ function ct_sfw_update(){
548
 
549
  if($apbct->settings['spam_firewall'] == 1){
550
 
 
551
  include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
552
 
553
  $sfw = new CleantalkSFW();
@@ -566,10 +605,11 @@ function ct_sfw_send_logs()
566
 
567
  if($apbct->settings['spam_firewall'] == 1){
568
 
 
569
  include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
570
 
571
  $sfw = new CleantalkSFW();
572
- $result = $sfw->send_logs($apbct->api_key);
573
  unset($sfw);
574
  return $result;
575
 
@@ -642,14 +682,14 @@ function cleantalk_get_brief_data(){
642
 
643
  global $apbct;
644
 
645
- $apbct->data['brief_data'] = CleantalkHelper::api_method__get_antispam_report_breif($apbct->api_key);
646
  $apbct->saveData();
647
 
648
  return;
649
  }
650
 
651
  //Delete cookie for admin trial notice
652
- function ct_wp_logout(){
653
  if(!headers_sent())
654
  setcookie('ct_trial_banner_closed', '', time()-3600);
655
  }
@@ -676,7 +716,7 @@ function apbct_cookie(){
676
  );
677
 
678
  // Submit time
679
- if(empty($_POST['ct_multipage_form'])){ // Do not start reset page timer if it is multipage form (Gravitiy forms))
680
  $apbct_timestamp = time();
681
  setcookie('apbct_timestamp', $apbct_timestamp, 0, '/');
682
  $cookie_test_value['cookies_names'][] = 'apbct_timestamp';
@@ -792,7 +832,7 @@ function ct_account_status_check($api_key = null){
792
 
793
  $api_key = $api_key ? $api_key : $apbct->api_key;
794
 
795
- $result = CleantalkHelper::api_method__notice_paid_till($api_key);
796
 
797
  if(empty($result['error'])){
798
 
@@ -829,6 +869,8 @@ function ct_account_status_check($api_key = null){
829
  }else{
830
  $apbct->error_add('account_check', $result);
831
  }
 
 
832
  }
833
 
834
  function ct_mail_send_connection_report() {
@@ -870,4 +912,25 @@ function ct_mail_send_connection_report() {
870
  $apbct->data['connection_reports']['negative_report'] = array();
871
  $apbct->data['connection_reports']['since'] = date('d M');
872
  $apbct->saveData();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
873
  }
3
  Plugin Name: Anti-Spam by CleanTalk
4
  Plugin URI: http://cleantalk.org
5
  Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
6
+ Version: 5.106
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
16
  // Common params
17
  define('APBCT_NAME', $plugin_info['Name']);
18
  define('APBCT_VERSION', $plugin_info['Version']);
 
 
19
  define('APBCT_URL_PATH', plugins_url('', __FILE__)); //HTTP path. Plugin root folder without '/'.
20
  define('APBCT_DIR_PATH', plugin_dir_path(__FILE__)); //System path. Plugin root folder with '/'.
21
  define('APBCT_PLUGIN_BASE_NAME', plugin_basename(__FILE__)); //Plugin base name.
22
  define('APBCT_CASERT_PATH', file_exists(ABSPATH.WPINC.'/certificates/ca-bundle.crt') ? ABSPATH.WPINC.'/certificates/ca-bundle.crt' : ''); // SSL Serttificate path
23
 
24
+ // API params
25
+ define('CLEANTALK_AGENT', 'wordpress-'.str_replace('.', '', $plugin_info['Version']));
26
+ define('CLEANTALK_API_URL', 'https://api.cleantalk.org'); //Api URL
27
+ define('CLEANTALK_MODERATE_URL', 'https://moderate.cleantalk.org'); //Api URL
28
+
29
  // Option names
30
  define('APBCT_DATA', 'cleantalk_data'); //Option name with different plugin data.
31
  define('APBCT_SETTINGS', 'cleantalk_settings'); //Option name with plugin settings.
47
 
48
  define('CLEANTALK_PLUGIN_DIR', plugin_dir_path(__FILE__));
49
 
50
+ require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkDB_Wordpress.php'); // State class
51
+
52
  require_once( CLEANTALK_PLUGIN_DIR . 'lib/cleantalk-php-patch.php'); // Pathces fpr different functions which not exists
53
  require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkHelper.php'); // Helper class. Different useful functions
54
+ require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkAPI.php'); // Helper class. Different useful functions
55
  require_once( CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk.php'); // Main class for request
56
  require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkRequest.php'); // Holds request data
57
  require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkResponse.php'); // Holds response data
58
  require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkCron.php'); // Cron handling
 
 
59
  require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkState.php'); // State class
60
+ require_once( CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-common.php');
61
 
62
  // Global ArrayObject with settings and other global varables
63
  global $apbct;
64
+ $apbct = new CleantalkState('cleantalk', array('settings', 'data', 'debug', 'errors'), is_multisite());
65
 
66
  // Customize CleantalkState
67
  // Account status
68
  $apbct->plugin_name = APBCT_NAME;
69
  $apbct->base_name = 'cleantalk-spam-protect/cleantalk.php';
70
 
71
+ $apbct->logo = plugin_dir_url(__FILE__) . '/inc/images/logo.png';
72
+ $apbct->logo__small = plugin_dir_url(__FILE__) . '/inc/images/logo_small.png';
73
+ $apbct->logo__small__colored = plugin_dir_url(__FILE__) . '/inc/images/logo_color.png';
74
+
75
  $apbct->key_is_ok = !empty($apbct->data['key_is_ok']) ? $apbct->data['key_is_ok'] : 0;
76
  $apbct->key_is_ok = isset($apbct->data['testing_failed']) && $apbct->data['testing_failed'] == 0 ? 1 : $apbct->key_is_ok;
77
 
78
  $apbct->data['user_counter']['since'] = isset($apbct->data['user_counter']['since']) ? $apbct->data['user_counter']['since'] : date('d M');
79
  $apbct->data['connection_reports']['since'] = isset($apbct->data['connection_reports']['since']) ? $apbct->data['user_counter']['since'] : date('d M');
80
 
81
+ // START OF White label reassignments
82
+ $apbct->white_label = defined('APBCT_WHITELABLE') && APBCT_WHITELABLE == true ? true : false;
83
+
84
+ if($apbct->white_label){
85
+
86
+ // New plugin name
87
+ // $apbct->plugin_name = $apcbt->data['white_label_data']['plugin_name'];
88
+ $apbct->plugin_name = defined('APBCT_WL_NAME') ? APBCT_WL_NAME : $apbct->plugin_name; // For test purposes
89
+
90
+ // Logotypes
91
+ // $apbct->logo = $apcbt->data['white_label_data']['logo']
92
+ // $apbct->logo__small = $apcbt->data['white_label_data']['logo__small']
93
+ // $apbct->logo__small__colored = $apcbt->data['white_label_data']['logo__small__colored']
94
+
95
+ // $apbct->settings_link = 'admin.php?page=apbct_menu';
96
+
97
+ $apbct->settings_link = is_network_admin()
98
+ ? 'settings.php?page=cleantalk'
99
+ : 'options-general.php?page=cleantalk';
100
+
101
+ }else{
102
+ require_once( CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-widget.php');
103
+ $apbct->settings['apikey'] = defined('CLEANTALK_ACCESS_KEY') ? CLEANTALK_ACCESS_KEY : $apbct->settings['apikey'];
104
+
105
+ $apbct->settings_link = is_network_admin()
106
+ ? 'settings.php?page=cleantalk'
107
+ : 'options-general.php?page=cleantalk';
108
+ }
109
+ // END OF White label
110
+
111
  // Self cron
112
  if(!defined('DOING_CRON') || (defined('DOING_CRON') && DOING_CRON !== true)){
113
 
124
  }
125
 
126
  //Delete cookie for admin trial notice
127
+ add_action('wp_logout', 'apbct__hook__wp_logout__delete_trial_notice_cookie');
128
 
129
  // Set cookie only for unauthorized users and for non-AJAX requests
130
+ if (!is_admin()){
131
+ add_action('wp','apbct_cookie', 2);
132
  }
133
 
134
  // Early checks
375
  die(empty($result['error']) ? 'OK' : 'FAIL '.json_encode(array('error' => $result['error_string'])));
376
  // Update plugin
377
  }elseif($_GET['spbc_remote_call_action'] == 'update_plugin'){
378
+ add_action('wp', 'apbct_update', 1);
379
  }else
380
  die('FAIL '.json_encode(array('error' => 'UNKNOWN_ACTION')));
381
  }else
409
  }
410
  }
411
 
412
+ include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW_Base.php");
413
  include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
414
 
415
  $is_sfw_check = true;
416
  $sfw = new CleantalkSFW();
417
+ $sfw->ip_array = (array)$sfw->ip_get(array('real'), true);
418
 
419
  foreach($sfw->ip_array as $ct_cur_ip){
420
  if(isset($_COOKIE['ct_sfw_pass_key']) && $_COOKIE['ct_sfw_pass_key'] == md5($ct_cur_ip.$apbct->api_key)){
421
  $is_sfw_check=false;
422
  if(isset($_COOKIE['ct_sfw_passed'])){
423
+ $sfw->logs__update($ct_cur_ip, 'passed');
424
  $apbct->data['sfw_counter']['all']++;
425
  $apbct->saveData();
426
  if(!headers_sent())
444
  }
445
 
446
  if($is_sfw_check){
447
+ $sfw->ip_check();
448
  if($sfw->result){
449
+ $sfw->logs__update($sfw->blocked_ip, 'blocked');
450
  $apbct->data['sfw_counter']['blocked']++;
451
  $apbct->saveData();
452
  $sfw->sfw_die($apbct->api_key);
586
 
587
  if($apbct->settings['spam_firewall'] == 1){
588
 
589
+ include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW_Base.php");
590
  include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
591
 
592
  $sfw = new CleantalkSFW();
605
 
606
  if($apbct->settings['spam_firewall'] == 1){
607
 
608
+ include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW_Base.php");
609
  include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
610
 
611
  $sfw = new CleantalkSFW();
612
+ $result = $sfw->logs__send($apbct->api_key);
613
  unset($sfw);
614
  return $result;
615
 
682
 
683
  global $apbct;
684
 
685
+ $apbct->data['brief_data'] = CleantalkAPI::method__get_antispam_report_breif($apbct->api_key);
686
  $apbct->saveData();
687
 
688
  return;
689
  }
690
 
691
  //Delete cookie for admin trial notice
692
+ function apbct__hook__wp_logout__delete_trial_notice_cookie(){
693
  if(!headers_sent())
694
  setcookie('ct_trial_banner_closed', '', time()-3600);
695
  }
716
  );
717
 
718
  // Submit time
719
+ if(empty($_POST['ct_multipage_form'])){ // Do not start/reset page timer if it is multipage form (Gravitiy forms))
720
  $apbct_timestamp = time();
721
  setcookie('apbct_timestamp', $apbct_timestamp, 0, '/');
722
  $cookie_test_value['cookies_names'][] = 'apbct_timestamp';
832
 
833
  $api_key = $api_key ? $api_key : $apbct->api_key;
834
 
835
+ $result = CleantalkAPI::method__notice_paid_till($api_key);
836
 
837
  if(empty($result['error'])){
838
 
869
  }else{
870
  $apbct->error_add('account_check', $result);
871
  }
872
+
873
+
874
  }
875
 
876
  function ct_mail_send_connection_report() {
912
  $apbct->data['connection_reports']['negative_report'] = array();
913
  $apbct->data['connection_reports']['since'] = date('d M');
914
  $apbct->saveData();
915
+ }
916
+
917
+ //* Write $message to the plugin's debug option
918
+ function apbct_log($message = 'empty', $func = null, $params = array())
919
+ {
920
+ $debug = get_option( APBCT_DEBUG );
921
+
922
+ $function = $func ? $func : '';
923
+ $cron = in_array('cron', $params) ? true : false;
924
+ $data = in_array('data', $params) ? true : false;
925
+ $settings = in_array('settings', $params) ? true : false;
926
+
927
+ if(is_array($message) or is_object($message))
928
+ $message = print_r($message, true);
929
+
930
+ if($message) $debug[date("H:i:s", microtime(true))."_ACTION_".strval(current_action())."_FUNCTION_".strval($func)] = $message;
931
+ if($cron) $debug[date("H:i:s", microtime(true))."_ACTION_".strval(current_action())."_FUNCTION_".strval($func).'_cron'] = $apbct->cron;
932
+ if($data) $debug[date("H:i:s", microtime(true))."_ACTION_".strval(current_action())."_FUNCTION_".strval($func).'_data'] = $apbct->data;
933
+ if($settings) $debug[date("H:i:s", microtime(true))."_ACTION_".strval(current_action())."_FUNCTION_".strval($func).'_settings'] = $apbct->settings;
934
+
935
+ update_option(APBCT_DEBUG, $debug);
936
  }
inc/cleantalk-admin.php CHANGED
@@ -6,15 +6,17 @@ add_action( 'admin_bar_menu', 'apbct_admin__admin_bar__add', 999 );
6
 
7
  //Adding widjet
8
  function ct_dashboard_statistics_widget() {
9
- if(current_user_can('activate_plugins')){
10
- $plugin_settings_link = (is_network_admin() ? "settings.php" : "options-general.php" )."?page=cleantalk";
 
 
11
  wp_add_dashboard_widget(
12
  'ct_dashboard_statistics_widget',
13
- __("CleanTalk Anti-Spam Statistics", 'cleantalk')
14
  ."<div class='ct_widget_top_links'>"
15
  ."<img src='".plugins_url('/cleantalk-spam-protect/inc/images/preloader.gif')."' class='ct_preloader'>"
16
  .sprintf(__("%sRefresh%s", 'cleantalk'), "<a href='#ct_widget' class='ct_widget_refresh_link'>", "</a>")
17
- .sprintf(__("%sConfigure%s", 'cleantalk'), "<a href='$plugin_settings_link' class='ct_widget_settings_link'>", "</a>")
18
  ."</div>",
19
  'ct_dashboard_statistics_widget_output'
20
  );
@@ -39,9 +41,8 @@ function ct_dashboard_statistics_widget_output( $post, $callback_args ) {
39
  <hr class='ct_widget_hr'>
40
  <?php
41
  if(!apbct_api_key__is_correct() || (isset($apbct->data['brief_data']['error_no']) && $apbct->data['brief_data']['error_no'] == 6)){
42
- $plugin_settings_link = (is_network_admin() ? "settings.php" : "options-general.php" )."?page=cleantalk";
43
  ?> <div class='ct_widget_block'>
44
- <form action='<? echo $plugin_settings_link; ?>' method='POST'>
45
  <h2 class='ct_widget_activate_header'><?php _e('Get Access key to activate Anti-Spam protection!', 'cleantalk'); ?></h2>
46
  <input class='ct_widget_button ct_widget_activate_button' type='submit' name='get_apikey_auto' value='ACTIVATE' />
47
  </form>
@@ -52,7 +53,7 @@ function ct_dashboard_statistics_widget_output( $post, $callback_args ) {
52
  .'<h2 class="ct_widget_activate_header">'
53
  .sprintf(__('Something went wrong! Error: "%s".', 'cleantalk'), "<u>{$apbct->brief_data['error_string']}</u>")
54
  .'</h2>';
55
- if($apbct->user_token){
56
  echo '<h2 class="ct_widget_activate_header">'
57
  .__('Please, visit your dashboard.', 'cleantalk')
58
  .'</h2>'
@@ -97,16 +98,19 @@ function ct_dashboard_statistics_widget_output( $post, $callback_args ) {
97
 
98
  if($apbct->spam_count && $apbct->spam_count > 0){
99
  echo '<div class="ct_widget_wprapper_total_blocked">'
100
- .'<img src="'.plugins_url('/cleantalk-spam-protect/inc/images/logo_color.png').'" class="ct_widget_small_logo"/>'
101
- .'<span title="'.__('This is the count from the CleanTalk\'s cloud and could be different to admin bar counters', 'cleantalk').'">'
102
  .sprintf(
103
  /* translators: %s: Number of spam messages */
104
- __( '%sCleanTalk%s has blocked %s spam for all time. The statistics are automatically updated every 24 hours.', 'cleantalk'),
105
- '<a href="https://cleantalk.org/my/?user_token='.$apbct->user_token.'&utm_source=wp-backend&utm_medium=dashboard_widget&cp_mode=antispam" target="_blank">',
106
- '</a>',
 
107
  number_format($apbct->data['spam_count'], 0, ',', ' ')
108
  )
109
- .'</span><br><br>'
 
 
110
  .'<b style="font-size: 16px;">'
111
  .sprintf(
112
  __('Do you like CleanTalk?%s Post your feedback here%s.', 'cleantalk'),
@@ -114,6 +118,8 @@ function ct_dashboard_statistics_widget_output( $post, $callback_args ) {
114
  '</a></u>'
115
  )
116
  .'</b>'
 
 
117
  .'</div>';
118
  }
119
  }
@@ -134,7 +140,7 @@ function apbct_admin__init(){
134
  $result = apbct_run_update_actions($apbct->plugin_version, APBCT_VERSION);
135
  //If update is successfull
136
  if($result === true){
137
- ct_send_feedback('0:' . APBCT_AGENT ); // Send feedback to let cloud know about updated version.
138
  $apbct->data['plugin_version'] = APBCT_VERSION;
139
  $apbct->saveData();
140
  }
@@ -142,9 +148,28 @@ function apbct_admin__init(){
142
  }
143
 
144
  // Getting dashboard widget statistics
145
- if(!empty($_POST['ct_brief_refresh']) || empty($apbct->data['brief_data'])){
146
- $apbct->data['brief_data'] = CleantalkHelper::api_method__get_antispam_report_breif($apbct->api_key);
 
 
 
 
 
 
 
 
 
 
 
 
147
  $apbct->saveData();
 
 
 
 
 
 
 
148
  }
149
 
150
  }
@@ -155,9 +180,9 @@ function apbct_admin__init(){
155
  */
156
  function apbct_admin__plugin_action_links($links, $file) {
157
 
158
- $settings_link = is_network_admin()
159
- ? '<a href="settings.php?page=cleantalk">' . __( 'Settings' ) . '</a>'
160
- : '<a href="options-general.php?page=cleantalk">' . __( 'Settings' ) . '</a>';
161
 
162
  array_unshift( $links, $settings_link ); // before other links
163
  return $links;
@@ -176,9 +201,14 @@ function apbct_admin__register_plugin_links($links, $file){
176
  if ($file != $apbct->base_name)
177
  return $links;
178
 
179
- // $links[] = is_network_admin()
180
- // ? '<a class="ct_meta_links ct_setting_links" href="settings.php?page=cleantalk">' . __( 'Settings' ) . '</a>'
181
- // : '<a class="ct_meta_links ct_setting_links" href="options-general.php?page=cleantalk">' . __( 'Settings' ) . '</a>';
 
 
 
 
 
182
 
183
  if(substr(get_locale(), 0, 2) != 'en')
184
  $links[] = '<a class="ct_meta_links ct_translate_links" href="'
@@ -209,11 +239,14 @@ function apbct_admin__enqueue_scripts($hook){
209
  wp_enqueue_style ('ct_admin_css', plugins_url('/cleantalk-spam-protect/css/cleantalk-admin.css'), array(), APBCT_VERSION, 'all');
210
 
211
  wp_localize_script( 'jquery', 'ctAdminCommon', array(
212
- 'logo_small_colored' => '<img src="' . plugin_dir_url(__FILE__) . 'images/logo_color.png" alt="" height="" style="width: 17px; vertical-align: text-bottom;" />'
 
 
 
213
  ));
214
 
215
- // Scripts & Styles to main dashboard page
216
- if($hook == 'index.php' && current_user_can('activate_plugins')){
217
 
218
  wp_enqueue_style('ct_admin_css_widget_dashboard', plugins_url('/cleantalk-spam-protect/css/cleantalk-dashboard-widget.css'), array(), APBCT_VERSION, 'all');
219
 
@@ -223,7 +256,7 @@ function apbct_admin__enqueue_scripts($hook){
223
  // Preparing widget data
224
  // Parsing brief data 'spam_stat' {"yyyy-mm-dd": spam_count, "yyyy-mm-dd": spam_count} to [["yyyy-mm-dd", "spam_count"], ["yyyy-mm-dd", "spam_count"]]
225
  $to_chart = array();
226
- foreach( $apbct->brief_data['spam_stat'] as $key => $value ){
227
  $to_chart[] = array( $key, $value );
228
  } unset( $key, $value );
229
 
@@ -232,8 +265,13 @@ function apbct_admin__enqueue_scripts($hook){
232
  ));
233
  }
234
 
235
- // Scripts & Styles for CleanTalk's settings page
236
  if( $hook == 'settings_page_cleantalk' ){
 
 
 
 
 
237
  wp_enqueue_script('cleantalk_admin_js_settings_page', plugins_url('/cleantalk-spam-protect/js/cleantalk-admin-settings-page.js'), array(), APBCT_VERSION);
238
  wp_enqueue_style('cleantalk_admin_css_settings_page', plugins_url('/cleantalk-spam-protect/css/cleantalk-admin-settings-page.css'), array(), APBCT_VERSION, 'all');
239
 
@@ -245,22 +283,25 @@ function apbct_admin__enqueue_scripts($hook){
245
  ));
246
  }
247
 
248
- // Scripts for comments check
249
- if( $hook == 'comments_page_ct_check_spam' || $hook == 'edit-comments.php' || $hook == 'settings_page_cleantalk'){
250
-
251
- wp_enqueue_style('cleantalk_admin_css_settings_page', plugins_url('/cleantalk-spam-protect/css/cleantalk-spam-check.css'), array(), APBCT_VERSION, 'all');
252
- wp_enqueue_style('jqueryui_css', plugins_url('/cleantalk-spam-protect/css/jquery-ui.min.css'), array(), '1.21.1', 'all');
253
 
254
- $ajax_nonce = wp_create_nonce( "ct_secret_nonce" );
255
  if(!empty($_COOKIE['ct_paused_comments_check']))
256
  $prev_check = json_decode(stripslashes($_COOKIE['ct_paused_comments_check']), true);
257
 
258
- wp_enqueue_script('ct_comments_checkspam', plugins_url('/cleantalk-spam-protect/js/cleantalk-comments-checkspam.js'), array(), APBCT_VERSION);
259
- wp_enqueue_script('ct_comments_editscreen', plugins_url('/cleantalk-spam-protect/js/cleantalk-comments-editscreen.js'), array(), APBCT_VERSION);
260
  wp_enqueue_script('jqueryui', plugins_url('/cleantalk-spam-protect/js/jquery-ui.min.js'), array('jquery'), '1.12.1');
 
 
 
 
261
 
 
 
 
262
  wp_localize_script( 'jquery', 'ctCommentsCheck', array(
263
- 'ct_ajax_nonce' => $ajax_nonce,
264
  'ct_prev_accurate' => !empty($prev_check['accurate']) ? true : false,
265
  'ct_prev_from' => !empty($prev_check['from']) ? $prev_check['from'] : false,
266
  'ct_prev_till' => !empty($prev_check['till']) ? $prev_check['till'] : false,
@@ -274,35 +315,43 @@ function apbct_admin__enqueue_scripts($hook){
274
  'ct_status_string_warning' => '<p>'.__('Please do backup of WordPress database before delete any accounts!', 'cleantalk').'</p>',
275
  'start' => !empty($_COOKIE['ct_comments_start_check']) ? true : false,
276
  ));
 
 
 
 
 
277
  wp_localize_script( 'jquery', 'ctCommentsScreen', array(
278
- 'ct_ajax_nonce' => $ajax_nonce,
279
  'spambutton_text' => __("Find spam-comments", 'cleantalk'),
280
  'ct_feedback_msg_whitelisted' => __("The sender has been whitelisted.", 'cleantalk'),
281
  'ct_feedback_msg_blacklisted' => __("The sender has been blacklisted.", 'cleantalk'),
282
  'ct_feedback_msg' => sprintf(__("Feedback has been sent to %sCleanTalk Dashboard%s.", 'cleantalk'), $apbct->user_token ? "<a target='_blank' href=https://cleantalk.org/my?user_token={$apbct->user_token}&cp_mode=antispam>" : '', $apbct->user_token ? "</a>" : ''),
283
  'ct_show_check_links' => (bool)$apbct->settings['show_check_links'],
284
  'ct_img_src_new_tab' => plugin_dir_url(__FILE__)."images/new_window.gif",
285
-
286
  ));
287
  }
 
288
 
289
- // Scripts for users check
290
  if( $hook == 'users_page_ct_check_users' || $hook == 'users.php'){
291
 
292
- wp_enqueue_style('cleantalk_admin_css_settings_page', plugins_url().'/cleantalk-spam-protect/css/cleantalk-spam-check.css', array(), APBCT_VERSION, 'all');
293
- wp_enqueue_style('jqueryui_css', plugins_url().'/cleantalk-spam-protect/css/jquery-ui.min.css', array(), '1.21.1', 'all');
294
-
295
  $current_user = wp_get_current_user();
296
- $ajax_nonce = wp_create_nonce( "ct_secret_nonce" );
297
  if(!empty($_COOKIE['ct_paused_users_check']))
298
  $prev_check = json_decode(stripslashes($_COOKIE['ct_paused_users_check']), true);
299
 
300
- wp_enqueue_script('ct_users_checkspam', plugins_url('/cleantalk-spam-protect/js/cleantalk-users-checkspam.js'), array(), APBCT_VERSION);
301
- wp_enqueue_script('ct_users_editscreen', plugins_url('/cleantalk-spam-protect/js/cleantalk-users-editscreen.js'), array(), APBCT_VERSION);
302
  wp_enqueue_script('jqueryui', plugins_url('/cleantalk-spam-protect/js/jquery-ui.min.js'), array('jquery'), '1.12.1');
 
 
 
 
303
 
 
 
 
304
  wp_localize_script( 'jquery', 'ctUsersCheck', array(
305
- 'ct_ajax_nonce' => $ajax_nonce,
306
  'ct_prev_accurate' => !empty($prev_check['accurate']) ? true : false,
307
  'ct_prev_from' => !empty($prev_check['from']) ? $prev_check['from'] : false,
308
  'ct_prev_till' => !empty($prev_check['till']) ? $prev_check['till'] : false,
@@ -318,12 +367,19 @@ function apbct_admin__enqueue_scripts($hook){
318
  'ct_status_string' => __("Total users %s, checked %s, found %s spam users and %s bad users (without IP or email)", 'cleantalk'),
319
  'ct_status_string_warning' => "<p>".__("Please do backup of WordPress database before delete any accounts!", 'cleantalk')."</p>"
320
  ));
 
 
 
 
 
321
  wp_localize_script( 'jquery', 'ctUsersScreen', array(
322
  'spambutton_text' => __("Find spam-users", 'cleantalk'),
323
  'ct_show_check_links' => (bool)$apbct->settings['show_check_links'],
324
  'ct_img_src_new_tab' => plugin_dir_url(__FILE__)."images/new_window.gif"
325
  ));
326
  }
 
 
327
  }
328
 
329
  /**
@@ -363,7 +419,7 @@ function apbct_admin__notice_message(){
363
  }
364
  */
365
  //Unable to get key automatically (if apbct_admin__init().getAutoKey() returns error)
366
- if ($apbct->notice_show && !empty($apbct->errors['get_key'])){
367
  echo '<div class="error">
368
  <h3>' . sprintf(__("Unable to get Access key automatically: %s", 'cleantalk'), $apbct->api_key).
369
  "<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>
@@ -382,11 +438,11 @@ function apbct_admin__notice_message(){
382
  }
383
 
384
  //"Trial period ends" notice from apbct_admin__init().api_method__notice_paid_till()
385
- if ($apbct->notice_show && $apbct->notice_trial == 1 && $apbct->moderate_ip = 0) {
386
  if(isset($_GET['page']) && in_array($_GET['page'], array('cleantalk', 'ct_check_spam', 'ct_check_users'))){
387
  echo '<div class="error">
388
  <h3>' . sprintf(__("%s trial period ends, please upgrade to %s!", 'cleantalk'),
389
- "<a href='{$settings_link}'>".APBCT_NAME."</a>",
390
  "<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>") .
391
  '</h3>
392
  </div>';
@@ -395,7 +451,7 @@ function apbct_admin__notice_message(){
395
  }
396
 
397
  //Renew notice from apbct_admin_init().api_method__notice_paid_till()
398
- if ($apbct->notice_show && $apbct->notice_renew == 1 && $apbct->moderate_ip == 0) {
399
  $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>";
400
  $button_html = sprintf($renew_link, '<input type="button" class="button button-primary" value="'.__('RENEW ANTI-SPAM', 'cleantalk').'" />');
401
  $link_html = sprintf($renew_link, "<b>".__('next year', 'cleantalk')."</b>");
@@ -409,7 +465,7 @@ function apbct_admin__notice_message(){
409
  }
410
 
411
  //"Wrong access key" notice (if ct_update_option().METHOD_notice_validate_key returns a error)
412
- if ($apbct->notice_show && !$apbct->data['key_is_ok'] && $apbct->moderate_ip = 0){
413
  echo '<div class="error">
414
  <h3><b>'.
415
  __("Wrong <a href='{$settings_link}'><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').
@@ -505,29 +561,20 @@ function apbct_admin__admin_bar__add( $wp_admin_bar ) {
505
  );
506
  $wp_admin_bar->add_node( $args );
507
 
508
- // add a child item to our parent item
509
- $args = array(
 
510
  'id' => 'ct_dashboard_link',
511
  'title' => '<a href="https://cleantalk.org/my/?user_token='.$apbct->user_token.'&utm_source=wp-backend&utm_medium=admin-bar&cp_mode=antispam " target="_blank">CleanTalk '.__('dashboard', 'cleantalk').'</a>',
512
  'parent' => 'ct_parent_node'
513
- );
514
- $wp_admin_bar->add_node( $args );
515
 
516
- // add another child item to our parent item (not to our first group)
517
- if(!is_network_admin()){
518
- $args = array(
519
- 'id' => 'ct_settings_link',
520
- 'title' => '<a href="options-general.php?page=cleantalk">'.__('Settings', 'cleantalk').'</a>',
521
- 'parent' => 'ct_parent_node'
522
- );
523
- }else{
524
- $args = array(
525
  'id' => 'ct_settings_link',
526
- 'title' => '<a href="settings.php?page=cleantalk">'.__('Settings', 'cleantalk').'</a>',
527
  'parent' => 'ct_parent_node'
528
- );
529
- }
530
- $wp_admin_bar->add_node( $args );
531
 
532
  // add a child item to our parent item. Bulk checks.
533
  if(!is_network_admin()){
@@ -566,12 +613,13 @@ function apbct_admin__admin_bar__add( $wp_admin_bar ) {
566
  $wp_admin_bar->add_node( $args );
567
 
568
  // Support link
569
- $args = array(
 
570
  'id' => 'ct_admin_bar_support_link',
571
  'title' => '<hr style="margin-top: 7px;" /><a target="_blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">'.__('Support', 'cleantalk').'</a>',
572
  'parent' => 'ct_parent_node'
573
- );
574
- $wp_admin_bar->add_node( $args );
575
  }
576
  }
577
 
@@ -679,4 +727,26 @@ function apbct_user__delete__hook($user_id, $reassign = null){
679
  ct_feedback($hash, 0);
680
  }
681
  }
682
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  //Adding widjet
8
  function ct_dashboard_statistics_widget() {
9
+
10
+ global $apbct;
11
+
12
+ if(apbct_is_user_role_in(array('administrator'))){
13
  wp_add_dashboard_widget(
14
  'ct_dashboard_statistics_widget',
15
+ $apbct->plugin_name
16
  ."<div class='ct_widget_top_links'>"
17
  ."<img src='".plugins_url('/cleantalk-spam-protect/inc/images/preloader.gif')."' class='ct_preloader'>"
18
  .sprintf(__("%sRefresh%s", 'cleantalk'), "<a href='#ct_widget' class='ct_widget_refresh_link'>", "</a>")
19
+ .sprintf(__("%sConfigure%s", 'cleantalk'), "<a href='{$apbct->settings_link}' class='ct_widget_settings_link'>", "</a>")
20
  ."</div>",
21
  'ct_dashboard_statistics_widget_output'
22
  );
41
  <hr class='ct_widget_hr'>
42
  <?php
43
  if(!apbct_api_key__is_correct() || (isset($apbct->data['brief_data']['error_no']) && $apbct->data['brief_data']['error_no'] == 6)){
 
44
  ?> <div class='ct_widget_block'>
45
+ <form action='<? echo $apbct->settings_link; ?>' method='POST'>
46
  <h2 class='ct_widget_activate_header'><?php _e('Get Access key to activate Anti-Spam protection!', 'cleantalk'); ?></h2>
47
  <input class='ct_widget_button ct_widget_activate_button' type='submit' name='get_apikey_auto' value='ACTIVATE' />
48
  </form>
53
  .'<h2 class="ct_widget_activate_header">'
54
  .sprintf(__('Something went wrong! Error: "%s".', 'cleantalk'), "<u>{$apbct->brief_data['error_string']}</u>")
55
  .'</h2>';
56
+ if($apbct->user_token && !$apbct->white_label){
57
  echo '<h2 class="ct_widget_activate_header">'
58
  .__('Please, visit your dashboard.', 'cleantalk')
59
  .'</h2>'
98
 
99
  if($apbct->spam_count && $apbct->spam_count > 0){
100
  echo '<div class="ct_widget_wprapper_total_blocked">'
101
+ .'<img src="'.$apbct->logo__small__colored.'" class="ct_widget_small_logo"/>'
102
+ .'<span title="'.sprintf(__('This is the count from the %s\'s cloud and could be different to admin bar counters', 'cleantalk').'">', $apbct->plugin_name)
103
  .sprintf(
104
  /* translators: %s: Number of spam messages */
105
+ __( '%s%s%s has blocked %s spam for all time. The statistics are automatically updated every 24 hours.', 'cleantalk'),
106
+ !$apbct->white_label ? '<a href="https://cleantalk.org/my/?user_token='.$apbct->user_token.'&utm_source=wp-backend&utm_medium=dashboard_widget&cp_mode=antispam" target="_blank">' : '',
107
+ $apbct->plugin_name,
108
+ !$apbct->white_label ? '</a>' : '',
109
  number_format($apbct->data['spam_count'], 0, ',', ' ')
110
  )
111
+ .'</span>'
112
+ .(!$apbct->white_label
113
+ ? '<br><br>'
114
  .'<b style="font-size: 16px;">'
115
  .sprintf(
116
  __('Do you like CleanTalk?%s Post your feedback here%s.', 'cleantalk'),
118
  '</a></u>'
119
  )
120
  .'</b>'
121
+ : ''
122
+ )
123
  .'</div>';
124
  }
125
  }
140
  $result = apbct_run_update_actions($apbct->plugin_version, APBCT_VERSION);
141
  //If update is successfull
142
  if($result === true){
143
+ ct_send_feedback('0:' . CLEANTALK_AGENT ); // Send feedback to let cloud know about updated version.
144
  $apbct->data['plugin_version'] = APBCT_VERSION;
145
  $apbct->saveData();
146
  }
148
  }
149
 
150
  // Getting dashboard widget statistics
151
+ if(!empty($_POST['ct_brief_refresh'])){
152
+ $apbct->data['brief_data'] = CleantalkAPI::method__get_antispam_report_breif($apbct->api_key);
153
+ $apbct->saveData();
154
+ }
155
+
156
+ // Getting key like hoster. Only once!
157
+ if($apbct->white_label && empty($apbct->data['white_label_data']['is_key_recieved']) && !is_network_admin()){
158
+
159
+ $_POST['submit'] = 'get_key_auto';
160
+
161
+ $settings = apbct_settings__validate(array());
162
+
163
+ unset($_POST['submit']);
164
+ $apbct->data['white_label_data']['is_key_recieved'] = true;
165
  $apbct->saveData();
166
+
167
+ if(!empty($settings['apikey'])){
168
+ $apbct->settings['apikey'] = $settings['apikey'];
169
+ $apbct->api_key = $settings['apikey'];
170
+ $apbct->saveSettings();
171
+ }
172
+
173
  }
174
 
175
  }
180
  */
181
  function apbct_admin__plugin_action_links($links, $file) {
182
 
183
+ global $apbct;
184
+
185
+ $settings_link = '<a href="' . $apbct->settings_link . '">' . __( 'Settings' ) . '</a>';
186
 
187
  array_unshift( $links, $settings_link ); // before other links
188
  return $links;
201
  if ($file != $apbct->base_name)
202
  return $links;
203
 
204
+ if($apbct->white_label){
205
+ $links = array_slice($links, 0, 1);
206
+ $links[] = "<script>jQuery('.plugin-title strong').each(function(i, item){
207
+ if(jQuery(item).html() == 'Anti-Spam by CleanTalk')
208
+ jQuery(item).html('{$apbct->plugin_name}');
209
+ });</script>";
210
+ return $links;
211
+ }
212
 
213
  if(substr(get_locale(), 0, 2) != 'en')
214
  $links[] = '<a class="ct_meta_links ct_translate_links" href="'
239
  wp_enqueue_style ('ct_admin_css', plugins_url('/cleantalk-spam-protect/css/cleantalk-admin.css'), array(), APBCT_VERSION, 'all');
240
 
241
  wp_localize_script( 'jquery', 'ctAdminCommon', array(
242
+ 'plugin_name' => $apbct->plugin_name,
243
+ 'logo' => '<img src="' . $apbct->logo . '" alt="" height="" style="width: 17px; vertical-align: text-bottom;" />',
244
+ 'logo_small' => '<img src="' . $apbct->logo__small . '" alt="" height="" style="width: 17px; vertical-align: text-bottom;" />',
245
+ 'logo_small_colored' => '<img src="' . $apbct->logo__small__colored . '" alt="" height="" style="width: 17px; vertical-align: text-bottom;" />',
246
  ));
247
 
248
+ // DASHBOARD page JavaScript and CSS
249
+ if($hook == 'index.php' && apbct_is_user_role_in(array('administrator'))){
250
 
251
  wp_enqueue_style('ct_admin_css_widget_dashboard', plugins_url('/cleantalk-spam-protect/css/cleantalk-dashboard-widget.css'), array(), APBCT_VERSION, 'all');
252
 
256
  // Preparing widget data
257
  // Parsing brief data 'spam_stat' {"yyyy-mm-dd": spam_count, "yyyy-mm-dd": spam_count} to [["yyyy-mm-dd", "spam_count"], ["yyyy-mm-dd", "spam_count"]]
258
  $to_chart = array();
259
+ foreach( $apbct->data['brief_data']['spam_stat'] as $key => $value ){
260
  $to_chart[] = array( $key, $value );
261
  } unset( $key, $value );
262
 
265
  ));
266
  }
267
 
268
+ // SETTINGS's page JavaScript and CSS
269
  if( $hook == 'settings_page_cleantalk' ){
270
+
271
+ // jQueryUI
272
+ wp_enqueue_script('jqueryui', plugins_url('/cleantalk-spam-protect/js/jquery-ui.min.js'), array('jquery'), '1.12.1' );
273
+ wp_enqueue_style('jqueryui_css', plugins_url('/cleantalk-spam-protect/css/jquery-ui.min.css'),array(), '1.21.1', 'all');
274
+
275
  wp_enqueue_script('cleantalk_admin_js_settings_page', plugins_url('/cleantalk-spam-protect/js/cleantalk-admin-settings-page.js'), array(), APBCT_VERSION);
276
  wp_enqueue_style('cleantalk_admin_css_settings_page', plugins_url('/cleantalk-spam-protect/css/cleantalk-admin-settings-page.css'), array(), APBCT_VERSION, 'all');
277
 
283
  ));
284
  }
285
 
286
+ // COMMENTS's page JavaScript and CSS
287
+ if( $hook == 'comments_page_ct_check_spam' || $hook == 'edit-comments.php'){
 
 
 
288
 
289
+ // Preparing data
290
  if(!empty($_COOKIE['ct_paused_comments_check']))
291
  $prev_check = json_decode(stripslashes($_COOKIE['ct_paused_comments_check']), true);
292
 
293
+ // jQueryUI
 
294
  wp_enqueue_script('jqueryui', plugins_url('/cleantalk-spam-protect/js/jquery-ui.min.js'), array('jquery'), '1.12.1');
295
+ wp_enqueue_style('jqueryui_css', plugins_url('/cleantalk-spam-protect/css/jquery-ui.min.css'),array(), '1.21.1', 'all');
296
+
297
+ // CSS
298
+ wp_enqueue_style('cleantalk_admin_css_settings_page', plugins_url('/cleantalk-spam-protect/css/cleantalk-spam-check.css'), array(), APBCT_VERSION, 'all');
299
 
300
+ // CHECK COMMENTS page JavaScript
301
+ if($hook == 'comments_page_ct_check_spam'){
302
+ wp_enqueue_script('ct_comments_checkspam', plugins_url('/cleantalk-spam-protect/js/cleantalk-comments-checkspam.js'), array(), APBCT_VERSION);
303
  wp_localize_script( 'jquery', 'ctCommentsCheck', array(
304
+ 'ct_ajax_nonce' => wp_create_nonce('ct_secret_nonce'),
305
  'ct_prev_accurate' => !empty($prev_check['accurate']) ? true : false,
306
  'ct_prev_from' => !empty($prev_check['from']) ? $prev_check['from'] : false,
307
  'ct_prev_till' => !empty($prev_check['till']) ? $prev_check['till'] : false,
315
  'ct_status_string_warning' => '<p>'.__('Please do backup of WordPress database before delete any accounts!', 'cleantalk').'</p>',
316
  'start' => !empty($_COOKIE['ct_comments_start_check']) ? true : false,
317
  ));
318
+ }
319
+
320
+ // COMMENTS page JavaScript
321
+ if($hook == 'edit-comments.php'){
322
+ wp_enqueue_script('ct_comments_editscreen', plugins_url('/cleantalk-spam-protect/js/cleantalk-comments-editscreen.js'), array(), APBCT_VERSION);
323
  wp_localize_script( 'jquery', 'ctCommentsScreen', array(
324
+ 'ct_ajax_nonce' => wp_create_nonce('ct_secret_nonce'),
325
  'spambutton_text' => __("Find spam-comments", 'cleantalk'),
326
  'ct_feedback_msg_whitelisted' => __("The sender has been whitelisted.", 'cleantalk'),
327
  'ct_feedback_msg_blacklisted' => __("The sender has been blacklisted.", 'cleantalk'),
328
  'ct_feedback_msg' => sprintf(__("Feedback has been sent to %sCleanTalk Dashboard%s.", 'cleantalk'), $apbct->user_token ? "<a target='_blank' href=https://cleantalk.org/my?user_token={$apbct->user_token}&cp_mode=antispam>" : '', $apbct->user_token ? "</a>" : ''),
329
  'ct_show_check_links' => (bool)$apbct->settings['show_check_links'],
330
  'ct_img_src_new_tab' => plugin_dir_url(__FILE__)."images/new_window.gif",
 
331
  ));
332
  }
333
+ }
334
 
335
+ // USERS's page JavaScript and CSS
336
  if( $hook == 'users_page_ct_check_users' || $hook == 'users.php'){
337
 
338
+ // Preparing data
 
 
339
  $current_user = wp_get_current_user();
 
340
  if(!empty($_COOKIE['ct_paused_users_check']))
341
  $prev_check = json_decode(stripslashes($_COOKIE['ct_paused_users_check']), true);
342
 
343
+ // jQueryUI
 
344
  wp_enqueue_script('jqueryui', plugins_url('/cleantalk-spam-protect/js/jquery-ui.min.js'), array('jquery'), '1.12.1');
345
+ wp_enqueue_style('jqueryui_css', plugins_url('/cleantalk-spam-protect/css/jquery-ui.min.css'),array(), '1.21.1', 'all');
346
+
347
+ // CSS
348
+ wp_enqueue_style('cleantalk_admin_css_settings_page', plugins_url().'/cleantalk-spam-protect/css/cleantalk-spam-check.css', array(), APBCT_VERSION, 'all');
349
 
350
+ // CHECK USERS page JavaScript
351
+ if($hook == 'users_page_ct_check_users'){
352
+ wp_enqueue_script('ct_users_checkspam', plugins_url('/cleantalk-spam-protect/js/cleantalk-users-checkspam.js'), array(), APBCT_VERSION);
353
  wp_localize_script( 'jquery', 'ctUsersCheck', array(
354
+ 'ct_ajax_nonce' => wp_create_nonce('ct_secret_nonce'),
355
  'ct_prev_accurate' => !empty($prev_check['accurate']) ? true : false,
356
  'ct_prev_from' => !empty($prev_check['from']) ? $prev_check['from'] : false,
357
  'ct_prev_till' => !empty($prev_check['till']) ? $prev_check['till'] : false,
367
  'ct_status_string' => __("Total users %s, checked %s, found %s spam users and %s bad users (without IP or email)", 'cleantalk'),
368
  'ct_status_string_warning' => "<p>".__("Please do backup of WordPress database before delete any accounts!", 'cleantalk')."</p>"
369
  ));
370
+ }
371
+
372
+ // USERS page JavaScript
373
+ if($hook == 'users.php'){
374
+ wp_enqueue_script('ct_users_editscreen', plugins_url('/cleantalk-spam-protect/js/cleantalk-users-editscreen.js'), array(), APBCT_VERSION);
375
  wp_localize_script( 'jquery', 'ctUsersScreen', array(
376
  'spambutton_text' => __("Find spam-users", 'cleantalk'),
377
  'ct_show_check_links' => (bool)$apbct->settings['show_check_links'],
378
  'ct_img_src_new_tab' => plugin_dir_url(__FILE__)."images/new_window.gif"
379
  ));
380
  }
381
+
382
+ }
383
  }
384
 
385
  /**
419
  }
420
  */
421
  //Unable to get key automatically (if apbct_admin__init().getAutoKey() returns error)
422
+ if ($apbct->notice_show && !empty($apbct->errors['get_key']) && !$apbct->white_label){
423
  echo '<div class="error">
424
  <h3>' . sprintf(__("Unable to get Access key automatically: %s", 'cleantalk'), $apbct->api_key).
425
  "<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>
438
  }
439
 
440
  //"Trial period ends" notice from apbct_admin__init().api_method__notice_paid_till()
441
+ if ($apbct->notice_show && $apbct->notice_trial == 1 && $apbct->moderate_ip == 0 && !$apbct->white_label) {
442
  if(isset($_GET['page']) && in_array($_GET['page'], array('cleantalk', 'ct_check_spam', 'ct_check_users'))){
443
  echo '<div class="error">
444
  <h3>' . sprintf(__("%s trial period ends, please upgrade to %s!", 'cleantalk'),
445
+ "<a href='{$settings_link}'>".$apbct->plugin_name."</a>",
446
  "<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>") .
447
  '</h3>
448
  </div>';
451
  }
452
 
453
  //Renew notice from apbct_admin_init().api_method__notice_paid_till()
454
+ if ($apbct->notice_show && $apbct->notice_renew == 1 && $apbct->moderate_ip == 0 && !$apbct->white_label) {
455
  $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>";
456
  $button_html = sprintf($renew_link, '<input type="button" class="button button-primary" value="'.__('RENEW ANTI-SPAM', 'cleantalk').'" />');
457
  $link_html = sprintf($renew_link, "<b>".__('next year', 'cleantalk')."</b>");
465
  }
466
 
467
  //"Wrong access key" notice (if ct_update_option().METHOD_notice_validate_key returns a error)
468
+ if ($apbct->notice_show && !$apbct->data['key_is_ok'] && $apbct->moderate_ip == 0 && !$apbct->white_label){
469
  echo '<div class="error">
470
  <h3><b>'.
471
  __("Wrong <a href='{$settings_link}'><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').
561
  );
562
  $wp_admin_bar->add_node( $args );
563
 
564
+ // DASHBOARD LINK
565
+ if(!$apbct->white_label){
566
+ $wp_admin_bar->add_node( array(
567
  'id' => 'ct_dashboard_link',
568
  'title' => '<a href="https://cleantalk.org/my/?user_token='.$apbct->user_token.'&utm_source=wp-backend&utm_medium=admin-bar&cp_mode=antispam " target="_blank">CleanTalk '.__('dashboard', 'cleantalk').'</a>',
569
  'parent' => 'ct_parent_node'
570
+ ));
571
+ }
572
 
573
+ $wp_admin_bar->add_node( array(
 
 
 
 
 
 
 
 
574
  'id' => 'ct_settings_link',
575
+ 'title' => '<a href="'.$apbct->settings_link.'">'.__('Settings', 'cleantalk').'</a>',
576
  'parent' => 'ct_parent_node'
577
+ ));
 
 
578
 
579
  // add a child item to our parent item. Bulk checks.
580
  if(!is_network_admin()){
613
  $wp_admin_bar->add_node( $args );
614
 
615
  // Support link
616
+ if(!$apbct->white_label){
617
+ $wp_admin_bar->add_node( array(
618
  'id' => 'ct_admin_bar_support_link',
619
  'title' => '<hr style="margin-top: 7px;" /><a target="_blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">'.__('Support', 'cleantalk').'</a>',
620
  'parent' => 'ct_parent_node'
621
+ ));
622
+ }
623
  }
624
  }
625
 
727
  ct_feedback($hash, 0);
728
  }
729
  }
730
+
731
+ /**
732
+ * Checks if the current user has role
733
+ *
734
+ * @param array $roles
735
+ * @param int $user User ID to check
736
+ * @return boolean Does the user has this role|roles
737
+ */
738
+ function apbct_is_user_role_in( $roles, $user = false ){
739
+
740
+ if( is_numeric($user) ) $user = get_userdata( $user );
741
+ if( ! $user ) $user = wp_get_current_user();
742
+
743
+ if( empty($user->ID) )
744
+ return false;
745
+
746
+ foreach( (array) $roles as $role ){
747
+ if( isset($user->caps[ $role ]) || in_array($role, $user->roles) )
748
+ return true;
749
+ }
750
+
751
+ return false;
752
+ }
inc/cleantalk-ajax.php CHANGED
@@ -122,7 +122,7 @@ $cleantalk_hooked_actions[]='tevolution_submit_from_preview';
122
  $cleantalk_hooked_actions[]='submit_form_recaptcha_validation';
123
 
124
  /**hooks for cm answers pro */
125
- add_action( 'template_redirect', 'ct_ajax_hook',1 );
126
 
127
  /* hooks for ninja forms ajax*/
128
  add_action( 'wp_ajax_nopriv_ninja_forms_ajax_submit', 'ct_ajax_hook',1 );
122
  $cleantalk_hooked_actions[]='submit_form_recaptcha_validation';
123
 
124
  /**hooks for cm answers pro */
125
+ add_action( 'wp', 'ct_ajax_hook',1 );
126
 
127
  /* hooks for ninja forms ajax*/
128
  add_action( 'wp_ajax_nopriv_ninja_forms_ajax_submit', 'ct_ajax_hook',1 );
inc/cleantalk-comments.php CHANGED
@@ -16,12 +16,12 @@ function ct_add_comments_menu(){
16
 
17
  function ct_show_checkspam_page(){
18
 
19
- $settings_link = (is_network_admin() ? 'settings.php?page=cleantalk' : 'options-general.php?page=cleantalk');
20
 
21
  ?>
22
  <div class="wrap">
23
- <h2><img src="<?php echo plugin_dir_url(__FILE__) ?>/images/logo_color.png" /> <?php echo APBCT_NAME; ?></h2>
24
- <a style="color: gray; margin-left: 23px;" href="<?php echo $settings_link; ?>">Plugin Settings</a>
25
  <br />
26
  <?php
27
 
@@ -177,7 +177,12 @@ function ct_show_checkspam_page(){
177
 
178
  // Outputs email if exists
179
  if($email)
180
- echo "<a href='mailto:$email'>$email</a>";
 
 
 
 
 
181
  else
182
  echo "No email";
183
  echo "<br/>";
@@ -185,9 +190,11 @@ function ct_show_checkspam_page(){
185
  // Outputs IP if exists
186
  if($ip)
187
  echo "<a href='edit-comments.php?s=$ip&mode=detail'>$ip </a>"
188
- ."<a href='https://cleantalk.org/blacklists/$ip ' target='_blank'>"
 
189
  ."&nbsp;<img src='".plugin_dir_url(__FILE__)."images/new_window.gif' border='0' style='float:none'/>"
190
- ."</a>";
 
191
  else
192
  echo "No IP adress";
193
  echo "</td>";
@@ -396,7 +403,7 @@ function ct_ajax_check_comments(){
396
  die();
397
  }
398
 
399
- $result = CleantalkHelper::api_method__spam_check_cms($apbct->api_key, $data, !empty($_POST['accurate_check']) ? $curr_date : null);
400
 
401
  if(empty($result['error'])){
402
 
16
 
17
  function ct_show_checkspam_page(){
18
 
19
+ global $apbct;
20
 
21
  ?>
22
  <div class="wrap">
23
+ <h2><img src="<?php echo $apbct->logo__small__colored; ?>" /> <?php echo $apbct->plugin_name; ?></h2>
24
+ <a style="color: gray; margin-left: 23px;" href="<?php echo $apbct->settings_link; ?>"><?php _e('Plugin Settings', 'cleantalk'); ?></a>
25
  <br />
26
  <?php
27
 
177
 
178
  // Outputs email if exists
179
  if($email)
180
+ echo "<a href='mailto:$email'>$email</a>"
181
+ .(!$apbct->white_label
182
+ ? "<a href='https://cleantalk.org/blacklists/$email' target='_blank'>"
183
+ ."&nbsp;<img src='".plugin_dir_url(__FILE__)."images/new_window.gif' border='0' style='float:none' />"
184
+ ."</a>"
185
+ : '');
186
  else
187
  echo "No email";
188
  echo "<br/>";
190
  // Outputs IP if exists
191
  if($ip)
192
  echo "<a href='edit-comments.php?s=$ip&mode=detail'>$ip </a>"
193
+ .(!$apbct->white_label
194
+ ?"<a href='https://cleantalk.org/blacklists/$ip ' target='_blank'>"
195
  ."&nbsp;<img src='".plugin_dir_url(__FILE__)."images/new_window.gif' border='0' style='float:none'/>"
196
+ ."</a>"
197
+ : '');
198
  else
199
  echo "No IP adress";
200
  echo "</td>";
403
  die();
404
  }
405
 
406
+ $result = CleantalkAPI::method__spam_check_cms($apbct->api_key, $data, !empty($_POST['accurate_check']) ? $curr_date : null);
407
 
408
  if(empty($result['error'])){
409
 
inc/cleantalk-common.php CHANGED
@@ -99,7 +99,7 @@ function apbct_base_call($params = array(), $reg_flag = false){
99
  $ct_request->sender_nickname = !empty($params['sender_nickname']) ? $params['sender_nickname'] : null;
100
  $ct_request->post_info = isset($params['post_info']) ? json_encode($params['post_info']) : null;
101
  $ct_request->js_on = isset($params['checkjs']) ? $params['checkjs'] : apbct_js_test('ct_checkjs', $_COOKIE, true);
102
- $ct_request->agent = APBCT_AGENT;
103
  $ct_request->sender_info = json_encode($sender_info);
104
  $ct_request->submit_time = apbct_get_submit_time();
105
 
@@ -759,7 +759,7 @@ function ct_change_plugin_resonse($ct_result = null, $checkjs = null) {
759
  $ct_result->spam = 1;
760
  $ct_result->comment = sprintf('We\'ve got an issue: %s. Forbidden. Please, enable Javascript. %s.',
761
  $ct_result->comment,
762
- APBCT_NAME
763
  );
764
  }
765
  else
99
  $ct_request->sender_nickname = !empty($params['sender_nickname']) ? $params['sender_nickname'] : null;
100
  $ct_request->post_info = isset($params['post_info']) ? json_encode($params['post_info']) : null;
101
  $ct_request->js_on = isset($params['checkjs']) ? $params['checkjs'] : apbct_js_test('ct_checkjs', $_COOKIE, true);
102
+ $ct_request->agent = CLEANTALK_AGENT;
103
  $ct_request->sender_info = json_encode($sender_info);
104
  $ct_request->submit_time = apbct_get_submit_time();
105
 
759
  $ct_result->spam = 1;
760
  $ct_result->comment = sprintf('We\'ve got an issue: %s. Forbidden. Please, enable Javascript. %s.',
761
  $ct_result->comment,
762
+ $apbct->plugin_name
763
  );
764
  }
765
  else
inc/cleantalk-public.php CHANGED
@@ -7,9 +7,6 @@
7
  function apbct_init() {
8
  global $ct_wplp_result_label, $ct_jp_comments, $ct_post_data_label, $ct_post_data_authnet_label, $apbct, $ct_check_post_result, $test_external_forms, $cleantalk_executed, $wpdb;
9
 
10
-
11
-
12
-
13
  //Check internal forms with such "action" http://wordpress.loc/contact-us/some_script.php
14
  if((isset($_POST['action']) && $_POST['action'] == 'ct_check_internal') &&
15
  $apbct->settings['check_internal']
@@ -62,12 +59,12 @@ function apbct_init() {
62
  }
63
 
64
  //hook for Anonymous Post
65
- if($apbct->settings['general_postdata_test'] == 1 && !@isset($_POST['ct_checkjs_cf7']))
66
- add_action('template_redirect','ct_contact_form_validate_postdata',1);
67
 
68
- if($apbct->settings['general_contact_forms_test'] == 1&&!@isset($_POST['ct_checkjs_cf7'])){
69
  add_action('CMA_custom_post_type_nav','ct_contact_form_validate_postdata',1);
70
- add_action('template_redirect','ct_contact_form_validate',1);
71
  if(isset($_POST['reg_redirect_link'])&&isset($_POST['tmpl_registration_nonce_field']))
72
  {
73
  unset($_POST['ct_checkjs_register_form']);
@@ -82,7 +79,7 @@ function apbct_init() {
82
  }*/
83
  }
84
 
85
- if($apbct->settings['general_postdata_test'] == 1 && !@isset($_POST['ct_checkjs_cf7']))
86
  add_action('CMA_custom_post_type_nav','ct_contact_form_validate_postdata',1);
87
 
88
  //add_action('wp_footer','ct_ajaxurl');
@@ -128,6 +125,9 @@ function apbct_init() {
128
  add_filter('grunion_contact_form_field_html', 'ct_grunion_contact_form_field_html', 10, 2);
129
  }
130
 
 
 
 
131
  // Contact Form7
132
  if(defined('WPCF7_VERSION')){
133
  add_filter('wpcf7_form_elements', 'apbct_form__contactForm7__addField');
@@ -187,7 +187,9 @@ function apbct_init() {
187
  if (defined('WS_PLUGIN__S2MEMBER_PRO_VERSION')){
188
  $post_keys = array_keys($_POST);
189
  foreach($post_keys as $post_key){
190
- if(strpos($post_key, 's2member_pro_') !== false && preg_match('/s2member_pro_.*_registration/', $post_key) == 1){
 
 
191
  ct_s2member_registration_test($post_key);
192
  break;
193
  }
@@ -223,7 +225,8 @@ function apbct_init() {
223
  // Load JS code to website footer
224
  //
225
  if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
226
- add_action('wp_footer', 'ct_footer_add_cookie', 1);
 
227
  }
228
 
229
  if ($apbct->settings['protect_logged_in'] != 1 && is_user_logged_in()) {
@@ -540,15 +543,25 @@ function ct_comment_form($post_id){
540
  }
541
 
542
  /**
543
- * Adds cookie script filed to footer
544
  */
545
- function ct_footer_add_cookie() {
546
 
547
  ct_add_hidden_fields(true, 'ct_checkjs', false, true, true);
548
 
549
  return null;
550
  }
551
 
 
 
 
 
 
 
 
 
 
 
552
  /**
553
  * Adds hidden filed to define avaialbility of client's JavaScript
554
  * @param bool $random_key switch on generation random key for every page load
@@ -563,15 +576,17 @@ function ct_add_hidden_fields($random_key = false, $field_name = 'ct_checkjs', $
563
  $field_id_hash = md5(rand(0, 1000));
564
 
565
  if ($cookie_check && $apbct->settings['set_cookies'] == 1) {
 
566
  $html = "<script type='text/javascript'>
567
  function ctSetCookie(c_name, value, def_value){
568
  document.cookie = c_name + '=' + escape(value) + '; path=/';
569
  }
570
  ctSetCookie('{$field_name}', '{$ct_checkjs_key}', '{$ct_checkjs_def}');
571
  </script>";
 
572
  } else {
573
 
574
- // Fix only for wp_footer -> ct_footer_add_cookie()
575
  if($no_print)
576
  return;
577
 
@@ -780,10 +795,7 @@ function ct_preprocess_comment($comment) {
780
  // this action is called just when WP process POST request (adds new comment)
781
  // this action is called by wp-comments-post.php
782
  // after processing WP makes redirect to post page with comment's form by GET request (see above)
783
- global $wpdb, $current_user, $comment_post_id, $ct_comment_done, $ct_approved_request_id_label, $ct_jp_comments, $apbct;
784
-
785
-
786
-
787
 
788
  // Skip processing admin.
789
  if (in_array("administrator", $current_user->roles))
@@ -907,8 +919,10 @@ function ct_preprocess_comment($comment) {
907
  }else{
908
 
909
  global $ct_comment, $ct_stop_words;
 
910
  $ct_comment = $ct_result->comment;
911
  $ct_stop_words = $ct_result->stop_words;
 
912
  $err_text = '<center><b style="color: #49C73B;">Clean</b><b style="color: #349ebf;">Talk.</b> ' . __('Spam protection', 'cleantalk') . "</center><br><br>\n" . $ct_result->comment;
913
  $err_text .= '<script>setTimeout("history.back()", 5000);</script>';
914
 
@@ -1580,7 +1594,12 @@ function ct_contact_form_is_spam_jetpack($is_spam,$form) {
1580
  return (bool) !$ct_result->allow;
1581
  }
1582
 
1583
-
 
 
 
 
 
1584
 
1585
  /**
1586
  * Inserts anti-spam hidden to CF7
@@ -1603,9 +1622,8 @@ function apbct_form__contactForm7__addField($html) {
1603
  * Test CF7 message for spam
1604
  */
1605
  function apbct_form__contactForm7__testSpam($param) {
1606
- global $ct_checkjs_cf7, $ct_cf7_comment, $apbct;
1607
-
1608
 
 
1609
 
1610
  if(
1611
  $apbct->settings['contact_forms_test'] == 0 ||
@@ -1642,15 +1660,25 @@ function apbct_form__contactForm7__testSpam($param) {
1642
  );
1643
  $ct_result = $base_call_result['ct_result'];
1644
 
1645
- if ($ct_result->allow == 0) {
 
 
 
 
 
 
 
1646
 
1647
- if (WPCF7_VERSION >= '3.0.0')
1648
- $param = true;
1649
- else
1650
- $param = false;
1651
 
 
 
 
1652
  $ct_cf7_comment = $ct_result->comment;
 
1653
  add_filter('wpcf7_display_message', 'apbct_form__contactForm7__showResponse', 10, 2);
 
 
 
1654
  }
1655
 
1656
  return $param;
@@ -1670,6 +1698,31 @@ function apbct_form__contactForm7__showResponse($message, $status = 'spam') {
1670
  return $message;
1671
  }
1672
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1673
  /**
1674
  * Inserts anti-spam hidden to Fast Secure contact form
1675
  */
@@ -1912,24 +1965,21 @@ function apbct_form__gravityForms__showResponse( $confirmation, $form, $entry, $
1912
  * @return array with errors
1913
  */
1914
  function ct_s2member_registration_test($post_key) {
1915
- global $ct_post_data_label, $ct_post_data_authnet_label, $apbct;
1916
-
1917
-
1918
 
1919
  if ($apbct->settings['registrations_test'] == 0) {
1920
  return null;
1921
  }
1922
 
1923
- $sender_email = isset($_POST[$post_key]['email']) ? $_POST[$post_key]['email'] : null;
1924
- $sender_nickname = isset($_POST[$post_key]['username']) ? $_POST[$post_key]['username'] : null;
1925
 
1926
  //Making a call
1927
  $base_call_result = apbct_base_call(
1928
  array(
1929
- 'sender_email' => sanitize_email($_POST['email']),
1930
- 'sender_nickname' => sanitize_email($_POST['login']),
1931
- 'sender_info' => $sender_info,
1932
- 'checkjs' => $checkjs,
1933
  ),
1934
  true
1935
  );
@@ -1989,7 +2039,8 @@ function ct_contact_form_validate() {
1989
  (isset($_POST['ccf_form']) && intval($_POST['ccf_form']) == 1) ||
1990
  (isset($_POST['contact_tags']) && strpos($_POST['contact_tags'], 'MBR:') !== false) ||
1991
  (strpos($_SERVER['REQUEST_URI'], 'bizuno.php') && !empty($_POST['bizPass'])) ||
1992
- (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'],'my-dashboard/') !== false) // ticket_id=7885
 
1993
  ) {
1994
  return null;
1995
  }
@@ -2261,9 +2312,9 @@ function ct_send_error_notice ($comment = '') {
2261
 
2262
  $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
2263
  $message = __('Attention, please!', 'cleantalk') . "\r\n\r\n";
2264
- $message .= sprintf(__('"%s" plugin error on your site %s:', 'cleantalk'), APBCT_NAME, $blogname) . "\r\n\r\n";
2265
  $message .= $comment . "\r\n\r\n";
2266
- @wp_mail(ct_get_admin_email(), sprintf(__('[%s] %s error!', 'cleantalk'), APBCT_NAME, $blogname), $message);
2267
  }
2268
 
2269
  return null;
@@ -2308,7 +2359,7 @@ function ct_enqueue_scripts_public($hook){
2308
  if($apbct->settings['registrations_test'] || $apbct->settings['comments_test'] || $apbct->settings['contact_forms_test'] || $apbct->settings['general_contact_forms_test'] || $apbct->settings['wc_checkout_test'] || $apbct->settings['check_external'] || $apbct->settings['check_internal'] || $apbct->settings['bp_private_messages'] || $apbct->settings['general_postdata_test']){
2309
 
2310
  // Differnt JS params
2311
- wp_enqueue_script('ct_public', APBCT_URL_PATH.'/js/apbct-public.js', array(), APBCT_VERSION, 'in_footer');
2312
 
2313
  // GDPR script
2314
  if(shortcode_exists( 'cleantalk_gdpr_form')){
@@ -2329,7 +2380,8 @@ function ct_enqueue_scripts_public($hook){
2329
 
2330
  // Use AJAX for JavaScript check
2331
  if($apbct->settings['use_ajax']){
2332
- wp_enqueue_script('ct_nocache', plugins_url('/cleantalk-spam-protect/inc/cleantalk_nocache.js'), array(), APBCT_VERSION, 'in_footer');
 
2333
 
2334
  wp_localize_script('ct_nocache', 'ctNocache', array(
2335
  'ajaxurl' => admin_url('admin-ajax.php'),
@@ -2341,11 +2393,11 @@ function ct_enqueue_scripts_public($hook){
2341
 
2342
  // External forms check
2343
  if($apbct->settings['check_external'])
2344
- wp_enqueue_script('ct_external', plugins_url('/cleantalk-spam-protect/js/cleantalk_external.js'), array('jquery'), APBCT_VERSION, 'in_footer');
2345
 
2346
  // Internal forms check
2347
  if($apbct->settings['check_internal'])
2348
- wp_enqueue_script('ct_internal', plugins_url('/cleantalk-spam-protect/js/cleantalk_internal.js'), array('jquery'), APBCT_VERSION, 'in_footer');
2349
 
2350
  }
2351
  }
@@ -2359,7 +2411,7 @@ function ct_enqueue_scripts_public($hook){
2359
  $ajax_nonce = wp_create_nonce( "ct_secret_nonce" );
2360
 
2361
  wp_enqueue_style ('ct_public_admin_css', plugins_url('/cleantalk-spam-protect/css/cleantalk-public-admin.css'), array(), APBCT_VERSION, 'all');
2362
- wp_enqueue_script('ct_public_admin_js', plugins_url('/cleantalk-spam-protect/js/cleantalk-public-admin.js'), array('jquery'), APBCT_VERSION, true);
2363
 
2364
  wp_localize_script('ct_public_admin_js', 'ctPublicAdmin', array(
2365
  'ct_ajax_nonce' => $ajax_nonce,
@@ -2374,7 +2426,7 @@ function ct_enqueue_scripts_public($hook){
2374
 
2375
  // Debug
2376
  if($apbct->settings['debug_ajax']){
2377
- wp_enqueue_script('ct_debug_js', plugins_url('/cleantalk-spam-protect/js/cleantalk-debug-ajax.js'), array('jquery'), APBCT_VERSION, true);
2378
 
2379
  wp_localize_script('ct_debug_js', 'apbctDebug', array(
2380
  'reload' => false,
7
  function apbct_init() {
8
  global $ct_wplp_result_label, $ct_jp_comments, $ct_post_data_label, $ct_post_data_authnet_label, $apbct, $ct_check_post_result, $test_external_forms, $cleantalk_executed, $wpdb;
9
 
 
 
 
10
  //Check internal forms with such "action" http://wordpress.loc/contact-us/some_script.php
11
  if((isset($_POST['action']) && $_POST['action'] == 'ct_check_internal') &&
12
  $apbct->settings['check_internal']
59
  }
60
 
61
  //hook for Anonymous Post
62
+ if($apbct->settings['general_postdata_test'] == 1 && empty($_POST['ct_checkjs_cf7']))
63
+ add_action('wp','ct_contact_form_validate_postdata',1);
64
 
65
+ if($apbct->settings['general_contact_forms_test'] == 1 && empty($_POST['ct_checkjs_cf7'])){
66
  add_action('CMA_custom_post_type_nav','ct_contact_form_validate_postdata',1);
67
+ add_action('wp','ct_contact_form_validate',1);
68
  if(isset($_POST['reg_redirect_link'])&&isset($_POST['tmpl_registration_nonce_field']))
69
  {
70
  unset($_POST['ct_checkjs_register_form']);
79
  }*/
80
  }
81
 
82
+ if($apbct->settings['general_postdata_test'] == 1 && empty($_POST['ct_checkjs_cf7']))
83
  add_action('CMA_custom_post_type_nav','ct_contact_form_validate_postdata',1);
84
 
85
  //add_action('wp_footer','ct_ajaxurl');
125
  add_filter('grunion_contact_form_field_html', 'ct_grunion_contact_form_field_html', 10, 2);
126
  }
127
 
128
+ // WP Maintenance Mode (wpmm)
129
+ add_action('wpmm_head', 'apbct_form__wpmm__addField', 1);
130
+
131
  // Contact Form7
132
  if(defined('WPCF7_VERSION')){
133
  add_filter('wpcf7_form_elements', 'apbct_form__contactForm7__addField');
187
  if (defined('WS_PLUGIN__S2MEMBER_PRO_VERSION')){
188
  $post_keys = array_keys($_POST);
189
  foreach($post_keys as $post_key){
190
+
191
+ // Detect POST keys like /s2member_pro.*registration/
192
+ if(strpos($post_key, 's2member') !== false && strpos($post_key, 'registration') !== false){
193
  ct_s2member_registration_test($post_key);
194
  break;
195
  }
225
  // Load JS code to website footer
226
  //
227
  if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
228
+ add_action('wp_head', 'apbct_hook__wp_head__set_cookie__ct_checkjs', 1);
229
+ add_action('wp_footer', 'apbct_hook__wp_footer', 1);
230
  }
231
 
232
  if ($apbct->settings['protect_logged_in'] != 1 && is_user_logged_in()) {
543
  }
544
 
545
  /**
546
+ * Adds cookie script filed to head
547
  */
548
+ function apbct_hook__wp_head__set_cookie__ct_checkjs() {
549
 
550
  ct_add_hidden_fields(true, 'ct_checkjs', false, true, true);
551
 
552
  return null;
553
  }
554
 
555
+ /**
556
+ * Adds cookie script filed to footer
557
+ */
558
+ function apbct_hook__wp_footer() {
559
+
560
+ //ct_add_hidden_fields(true, 'ct_checkjs', false, true, true);
561
+
562
+ return null;
563
+ }
564
+
565
  /**
566
  * Adds hidden filed to define avaialbility of client's JavaScript
567
  * @param bool $random_key switch on generation random key for every page load
576
  $field_id_hash = md5(rand(0, 1000));
577
 
578
  if ($cookie_check && $apbct->settings['set_cookies'] == 1) {
579
+
580
  $html = "<script type='text/javascript'>
581
  function ctSetCookie(c_name, value, def_value){
582
  document.cookie = c_name + '=' + escape(value) + '; path=/';
583
  }
584
  ctSetCookie('{$field_name}', '{$ct_checkjs_key}', '{$ct_checkjs_def}');
585
  </script>";
586
+
587
  } else {
588
 
589
+ // Fix only for wp_footer -> apbct_hook__wp_head__set_cookie__ct_checkjs()
590
  if($no_print)
591
  return;
592
 
795
  // this action is called just when WP process POST request (adds new comment)
796
  // this action is called by wp-comments-post.php
797
  // after processing WP makes redirect to post page with comment's form by GET request (see above)
798
+ global $current_user, $comment_post_id, $ct_comment_done, $ct_jp_comments, $apbct;
 
 
 
799
 
800
  // Skip processing admin.
801
  if (in_array("administrator", $current_user->roles))
919
  }else{
920
 
921
  global $ct_comment, $ct_stop_words;
922
+
923
  $ct_comment = $ct_result->comment;
924
  $ct_stop_words = $ct_result->stop_words;
925
+
926
  $err_text = '<center><b style="color: #49C73B;">Clean</b><b style="color: #349ebf;">Talk.</b> ' . __('Spam protection', 'cleantalk') . "</center><br><br>\n" . $ct_result->comment;
927
  $err_text .= '<script>setTimeout("history.back()", 5000);</script>';
928
 
1594
  return (bool) !$ct_result->allow;
1595
  }
1596
 
1597
+ /**
1598
+ * Inserts anti-spam hidden to WP Maintenance Mode (wpmm)
1599
+ */
1600
+ function apbct_form__wpmm__addField(){
1601
+ ct_add_hidden_fields(true, 'ct_checkjs', false, true, true);
1602
+ }
1603
 
1604
  /**
1605
  * Inserts anti-spam hidden to CF7
1622
  * Test CF7 message for spam
1623
  */
1624
  function apbct_form__contactForm7__testSpam($param) {
 
 
1625
 
1626
+ global $ct_checkjs_cf7, $apbct;
1627
 
1628
  if(
1629
  $apbct->settings['contact_forms_test'] == 0 ||
1660
  );
1661
  $ct_result = $base_call_result['ct_result'];
1662
 
1663
+ // Change mail notification if license is out of date
1664
+ if($apbct->data['moderate'] === 0 &&
1665
+ ($ct_result->fast_submit === 0 || $ct_result->blacklisted === 0 || $ct_result->js_disabled === 0)
1666
+ ){
1667
+ $apbct->sender_email = $sender_email;
1668
+ $apbct->sender_ip = CleantalkHelper::ip_get(array('real'));
1669
+ add_filter('wpcf7_mail_components', 'apbct_form__contactForm7__changeMailNotification');
1670
+ }
1671
 
 
 
 
 
1672
 
1673
+ if ($ct_result->allow == 0) {
1674
+
1675
+ global $ct_cf7_comment;
1676
  $ct_cf7_comment = $ct_result->comment;
1677
+
1678
  add_filter('wpcf7_display_message', 'apbct_form__contactForm7__showResponse', 10, 2);
1679
+
1680
+ $param = WPCF7_VERSION >= '3.0.0' ? true : false;
1681
+
1682
  }
1683
 
1684
  return $param;
1698
  return $message;
1699
  }
1700
 
1701
+ /**
1702
+ * Changes email notification for succes subscription for Contact Form 7
1703
+ *
1704
+ * @param array $component Arguments for email notification
1705
+ * @return array Arguments for email notification
1706
+ */
1707
+ function apbct_form__contactForm7__changeMailNotification($component){
1708
+
1709
+ global $apbct;
1710
+
1711
+ $component['body'] .= PHP_EOL . '---'
1712
+ .PHP_EOL
1713
+ .__('CleanTalk AntiSpam: This message is spam.', 'cleantalk')
1714
+ .PHP_EOL . __('CleanTalk\'s anti-spam database:', 'cleantalk')
1715
+ .PHP_EOL . 'IP: ' . '<a href="https://cleantalk.org/blacklists/' . $apbct->sender_ip . '?utm_source=newsletter&utm_medium=email&utm_campaign=cf7_spam_passed" target="_blank">' . $apbct->sender_ip . '</a>'
1716
+ .PHP_EOL . 'Email: ' . '<a href="https://cleantalk.org/blacklists/' . $apbct->sender_email . '?utm_source=newsletter&utm_medium=email&utm_campaign=cf7_spam_passed" target="_blank">' . $apbct->sender_email . '</a>'
1717
+ .PHP_EOL . sprintf(
1718
+ __('Activate protection in your %sAnti-Spam Dashboard%s.', 'clentalk'),
1719
+ '<a href="https://cleantalk.org/my/?cp_mode=antispam&utm_source=newsletter&utm_medium=email&utm_campaign=cf7_activate_antispam" target="_blank">',
1720
+ '</a>'
1721
+ );
1722
+
1723
+ return (array) $component;
1724
+ }
1725
+
1726
  /**
1727
  * Inserts anti-spam hidden to Fast Secure contact form
1728
  */
1965
  * @return array with errors
1966
  */
1967
  function ct_s2member_registration_test($post_key) {
1968
+
1969
+ global $apbct;
 
1970
 
1971
  if ($apbct->settings['registrations_test'] == 0) {
1972
  return null;
1973
  }
1974
 
1975
+ $sender_email = isset($_POST[$post_key]['email']) ? sanitize_email($_POST[$post_key]['email']) : null;
1976
+ $sender_nickname = isset($_POST[$post_key]['username']) ? sanitize_email($_POST[$post_key]['username']) : null;
1977
 
1978
  //Making a call
1979
  $base_call_result = apbct_base_call(
1980
  array(
1981
+ 'sender_email' => $sender_email,
1982
+ 'sender_nickname' => $sender_nickname,
 
 
1983
  ),
1984
  true
1985
  );
2039
  (isset($_POST['ccf_form']) && intval($_POST['ccf_form']) == 1) ||
2040
  (isset($_POST['contact_tags']) && strpos($_POST['contact_tags'], 'MBR:') !== false) ||
2041
  (strpos($_SERVER['REQUEST_URI'], 'bizuno.php') && !empty($_POST['bizPass'])) ||
2042
+ (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'],'my-dashboard/') !== false) || // ticket_id=7885
2043
+ isset($_POST['slm_action'], $_POST['license_key'], $_POST['secret_key'], $_POST['registered_domain']) // ticket_id=9122
2044
  ) {
2045
  return null;
2046
  }
2312
 
2313
  $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
2314
  $message = __('Attention, please!', 'cleantalk') . "\r\n\r\n";
2315
+ $message .= sprintf(__('"%s" plugin error on your site %s:', 'cleantalk'), $apbct->plugin_name, $blogname) . "\r\n\r\n";
2316
  $message .= $comment . "\r\n\r\n";
2317
+ @wp_mail(ct_get_admin_email(), sprintf(__('[%s] %s error!', 'cleantalk'), $apbct->plugin_name, $blogname), $message);
2318
  }
2319
 
2320
  return null;
2359
  if($apbct->settings['registrations_test'] || $apbct->settings['comments_test'] || $apbct->settings['contact_forms_test'] || $apbct->settings['general_contact_forms_test'] || $apbct->settings['wc_checkout_test'] || $apbct->settings['check_external'] || $apbct->settings['check_internal'] || $apbct->settings['bp_private_messages'] || $apbct->settings['general_postdata_test']){
2360
 
2361
  // Differnt JS params
2362
+ wp_enqueue_script('ct_public', APBCT_URL_PATH.'/js/apbct-public.js', array(), APBCT_VERSION, false /*in header*/);
2363
 
2364
  // GDPR script
2365
  if(shortcode_exists( 'cleantalk_gdpr_form')){
2380
 
2381
  // Use AJAX for JavaScript check
2382
  if($apbct->settings['use_ajax']){
2383
+
2384
+ wp_enqueue_script('ct_nocache', plugins_url('/cleantalk-spam-protect/inc/cleantalk_nocache.js'), array(), APBCT_VERSION, false /*in header*/);
2385
 
2386
  wp_localize_script('ct_nocache', 'ctNocache', array(
2387
  'ajaxurl' => admin_url('admin-ajax.php'),
2393
 
2394
  // External forms check
2395
  if($apbct->settings['check_external'])
2396
+ wp_enqueue_script('ct_external', plugins_url('/cleantalk-spam-protect/js/cleantalk_external.js'), array('jquery'), APBCT_VERSION, false /*in header*/);
2397
 
2398
  // Internal forms check
2399
  if($apbct->settings['check_internal'])
2400
+ wp_enqueue_script('ct_internal', plugins_url('/cleantalk-spam-protect/js/cleantalk_internal.js'), array('jquery'), APBCT_VERSION, false /*in header*/);
2401
 
2402
  }
2403
  }
2411
  $ajax_nonce = wp_create_nonce( "ct_secret_nonce" );
2412
 
2413
  wp_enqueue_style ('ct_public_admin_css', plugins_url('/cleantalk-spam-protect/css/cleantalk-public-admin.css'), array(), APBCT_VERSION, 'all');
2414
+ wp_enqueue_script('ct_public_admin_js', plugins_url('/cleantalk-spam-protect/js/cleantalk-public-admin.js'), array('jquery'), APBCT_VERSION, false /*in header*/);
2415
 
2416
  wp_localize_script('ct_public_admin_js', 'ctPublicAdmin', array(
2417
  'ct_ajax_nonce' => $ajax_nonce,
2426
 
2427
  // Debug
2428
  if($apbct->settings['debug_ajax']){
2429
+ wp_enqueue_script('ct_debug_js', plugins_url('/cleantalk-spam-protect/js/cleantalk-debug-ajax.js'), array('jquery'), APBCT_VERSION, false /*in header*/);
2430
 
2431
  wp_localize_script('ct_debug_js', 'apbctDebug', array(
2432
  'reload' => false,
inc/cleantalk-settings.php CHANGED
@@ -5,35 +5,39 @@
5
  */
6
  function apbct_settings__add_page() {
7
 
8
- global $apbct, $pagenow;
9
-
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  // Adding settings page
11
- if(is_network_admin())
12
- add_submenu_page("settings.php", __('CleanTalk settings', 'cleantalk'), APBCT_NAME, 'manage_options', 'cleantalk', 'apbct_settings_page');
13
  else
14
- add_options_page(__('CleanTalk settings', 'cleantalk'), APBCT_NAME, 'manage_options', 'cleantalk', 'apbct_settings_page');
 
15
 
16
- if(!in_array($pagenow, array('options.php', 'options-general.php', 'settings.php')))
17
  return;
18
 
19
  register_setting('cleantalk_settings', 'cleantalk_settings', 'apbct_settings__validate');
20
 
21
- add_settings_section('cleantalk_section_settings_main', '', 'apbct_section__settings_main', 'cleantalk');
22
- add_settings_section('cleantalk_section_debug', '', 'apbct_section__debug', 'cleantalk');
23
- add_settings_section('cleantalk_section_state', '', 'apbct_section__settings_state', 'cleantalk');
24
- add_settings_section('cleantalk_settings_banner', '<hr>', '', 'cleantalk');
25
-
26
- // DEBUG
27
- add_settings_field('apbct_debug_field', '', 'apbct_settings__field__debug', 'cleantalk', 'cleantalk_section_debug');
28
-
29
- // STATE
30
- add_settings_field('apbct_state_field', '', 'apbct_settings__field__state', 'cleantalk', 'cleantalk_section_state');
31
 
32
  // KEY
33
- add_settings_field('apbct_action_butons', '', 'apbct_settings__field__action_buttons', 'cleantalk', 'cleantalk_section_settings_main');
34
- add_settings_field('cleantalk_api_key', '', 'apbct_settings__field__api_key', 'cleantalk', 'cleantalk_section_settings_main');
35
- if(apbct_api_key__is_correct())
36
- add_settings_field('cleantalk_connection_reports', '', 'apbct_settings__field__connection_reports', 'cleantalk', 'cleantalk_section_settings_main');
37
 
38
  $field_default_params = array(
39
  'callback' => 'apbct_settings__field__draw',
@@ -44,10 +48,56 @@ function apbct_settings__add_page() {
44
  'childrens' => '',
45
  'title' => 'Default title',
46
  'description' => 'Default description',
 
47
  );
48
 
49
  $apbct->settings_fields_in_groups = array(
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  // Different
52
  'different' => array(
53
  'title' => '',
@@ -60,6 +110,7 @@ function apbct_settings__add_page() {
60
  'type' => 'checkbox',
61
  'title' => __('Tell others about CleanTalk', 'cleantalk'),
62
  'description' => __("Checking this box places a small link under the comment form that lets others know what anti-spam tool protects your site.", 'cleantalk'),
 
63
  ),
64
  'spam_firewall' => array(
65
  'type' => 'checkbox',
@@ -136,6 +187,7 @@ function apbct_settings__add_page() {
136
  'show_check_links' => array(
137
  'title' => __('Show links to check Emails, IPs for spam.', 'cleantalk'),
138
  'description' => __('Shows little icon near IP addresses and Emails allowing you to check it via CleanTalk\'s database. Also allowing you to manage comments from the public post\'s page.', 'cleantalk'),
 
139
  ),
140
  ),
141
  ),
@@ -154,15 +206,20 @@ function apbct_settings__add_page() {
154
  ),
155
  'general_postdata_test' => array(
156
  'title' => __('Check all post data', 'cleantalk'),
157
- 'description' => __('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 here:', 'cleantalk') . '&nbsp;' . '<a href="https://cleantalk.org/my/?user_token='.$apbct->user_token.'&utm_source=wp-backend&utm_medium=admin-bar&cp_mode=antispam" target="_blank">' . __('CleanTalk dashboard', 'cleantalk') . '</a>.<br />' . __('СAUTION! Option can catch POST requests in WordPress backend', 'cleantalk'),
 
 
 
 
 
158
  ),
159
  'set_cookies' => array(
160
  'title' => __("Set cookies", 'cleantalk'),
161
- 'description' => __('Turn this option off to deny plugin generates any cookies on website front-end. This option is helpful if you use Varnish. But most of contact forms will not be protected by CleanTalk if the option is turned off! <b>Warning: We strongly recommend you to enable this otherwise it could cause false positives spam detection.</b>', 'cleantalk'),
162
  ),
163
  'ssl_on' => array(
164
  'title' => __("Use SSL", 'cleantalk'),
165
- 'description' => __('Turn this option on to use encrypted (SSL) connection with CleanTalk servers.', 'cleantalk'),
166
  ),
167
  ),
168
  ),
@@ -177,7 +234,7 @@ function apbct_settings__add_page() {
177
  'fields' => array(
178
  'show_adminbar' => array(
179
  'title' => __('Show statistics in admin bar', 'cleantalk'),
180
- 'description' => __('Show/hide CleanTalk icon in top level menu in WordPress backend. The number of submissions is being counted for past 24 hours.', 'cleantalk'),
181
  'childrens' => array('all_time_counter','daily_counter','sfw_counter'),
182
  ),
183
  'all_time_counter' => array(
@@ -218,7 +275,7 @@ function apbct_settings__add_page() {
218
  'async_js' => array(
219
  'type' => 'checkbox',
220
  'title' => __('Async JavaScript loading', 'cleantalk'),
221
- 'description' => __('Use async loading for CleanTalk\'s scripts. Warning: This could reduce filtration quality.', 'cleantalk'),
222
  ),
223
  ),
224
  ),
@@ -236,6 +293,9 @@ function apbct_settings__add_page() {
236
 
237
  $params['name'] = $field_name;
238
 
 
 
 
239
  add_settings_field(
240
  'apbct_field__'.$field_name,
241
  '',
@@ -263,35 +323,39 @@ function apbct_settings_page() {
263
 
264
  // Title
265
  echo '<h2 class="apbct_settings-title">'.__($apbct->plugin_name, 'cleantalk').'</h2>';
 
266
  // Subtitle for IP license
267
  if($apbct->moderate_ip)
268
  echo '<h4 class="apbct_settings-subtitle gray">'. __('Hosting AntiSpam', 'cleantalk').'</h4>';
269
-
270
- apbct_settings__error__output();
271
-
272
- // Top info
273
- echo '<div style="float: right; padding: 15px 15px 0 15px; font-size: 13px;">';
274
 
275
- echo __('CleanTalk\'s tech support:', 'cleantalk')
276
- .'&nbsp;'
277
- .'<a target="_blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">Wordpress.org</a>.'
278
- // .' <a href="https://community.cleantalk.org/viewforum.php?f=25" target="_blank">'.__("Tech forum", 'cleantalk').'</a>'
279
- // .($user_token ? ", <a href='https://cleantalk.org/my/support?user_token=$user_token&cp_mode=antispam' target='_blank'>".__("Service support ", 'cleantalk').'</a>' : '').
280
- .'<br>';
281
- echo __('Plugin Homepage at', 'cleantalk').' <a href="http://cleantalk.org" target="_blank">cleantalk.org</a>.<br/>';
282
- echo '<span id="apbct_gdpr_open_modal" style="text-decoration: underline;">'.__('GDPR compliance', 'cleantalk').'</span><br/>';
283
- echo __('Use s@cleantalk.org to test plugin in any WordPress form.', 'cleantalk').'<br>';
284
- echo __('CleanTalk is registered Trademark. All rights reserved.', 'cleantalk').'<br/>';
285
- if($apbct->key_is_ok)
286
- echo '<b style="display: inline-block; margin-top: 10px;">'.sprintf(__('Do you like CleanTalk? %sPost your feedback here%s.', 'cleantalk'), '<a href="https://wordpress.org/support/plugin/cleantalk-spam-protect/reviews/#new-post" target="_blank">', '</a>').'</b><br />';
287
- apbct_admin__badge__get_premium();
288
- echo '<div id="gdpr_dialog" style="display: none; padding: 7px;">';
289
- apbct_gdpr__show_text();
290
- echo '</div>';
291
- echo '</div>';
292
-
293
  echo '<form action="options.php" method="post">';
294
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  // If it's network admin dashboard
296
  if(is_network_admin()){
297
  if(defined('CLEANTALK_ACCESS_KEY')){
@@ -314,7 +378,8 @@ function apbct_settings_page() {
314
  .'<br>'
315
  .'<span>'
316
  .sprintf(
317
- __( 'CleanTalk has blocked <b>%s</b> spam.', 'cleantalk' ),
 
318
  number_format($apbct->spam_count, 0, ',', ' ')
319
  )
320
  .'</span>'
@@ -322,24 +387,21 @@ function apbct_settings_page() {
322
  .'<br>'
323
  .'</div>';
324
  }
325
- // CP button
326
- echo '<a class="cleantalk_manual_link" target="__blank" href="https://cleantalk.org/my?user_token='.$apbct->user_token.'&cp_mode=antispam">'.__('Click here to get anti-spam statistics', 'cleantalk').'</a>';
327
- echo '&nbsp;&nbsp;';
328
- // Support button
329
- echo '<a class="cleantalk_auto_link" target="__blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">'.__('Support', 'cleantalk').'</a>';
330
- echo '<br>'
331
- .'<br>';
 
 
 
332
  }
333
 
334
  settings_fields('cleantalk_settings');
335
  do_settings_fields('cleantalk', 'cleantalk_section_settings_main');
336
- if($apbct->debug){
337
- echo '<hr>';
338
- do_settings_fields('cleantalk', 'cleantalk_section_debug');
339
- }
340
- echo '<hr>';
341
- do_settings_fields('cleantalk', 'cleantalk_section_state');
342
-
343
  foreach($apbct->settings_fields_in_groups as $group_name => $group){
344
 
345
  echo !empty($group['html_before']) ? $group['html_before'] : '';
@@ -356,10 +418,12 @@ function apbct_settings_page() {
356
 
357
  echo "</form>";
358
 
359
- // Translate banner for non EN locale
360
- if(substr(get_locale(), 0, 2) != 'en'){
361
- require_once(CLEANTALK_PLUGIN_DIR.'templates/translate_banner.php');
362
- printf($ct_translate_banner_template, substr(get_locale(), 0, 2));
 
 
363
  }
364
  }
365
 
@@ -408,7 +472,7 @@ function apbct_settings__error__output($return = false){
408
  $errors_out[$type] = '';
409
  if(isset($error['error_time']))
410
  $errors_out[$type] .= date('Y-m-d H:i:s', $error['error_time']) . ': ';
411
- $errors_out[$type] .= (isset($error_texts[$type]) ? $error_texts[$type] : $error_texts['unknown']) . (isset($error['error_string']) ? $error['error_string'] : '');
412
 
413
  }
414
  }
@@ -416,9 +480,12 @@ function apbct_settings__error__output($return = false){
416
  if(!empty($errors_out)){
417
  $out .= '<div id="apbctTopWarning" class="error" style="position: relative;">'
418
  .'<h3 style="display: inline-block;">'.__('Errors:', 'security-malware-firewall').'</h3>';
419
- foreach($errors_out as $value)
420
  $out .= '<h4>'.$value.'</h4>';
421
- $out .= '<h4 style="text-align: none;">'.sprintf(__('You can get support any time here: %s.', 'cleantalk'), '<a target="blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">https://wordpress.org/support/plugin/cleantalk-spam-protect</a>').'</h4>';
 
 
 
422
  $out .= '</div>';
423
  }
424
  }
@@ -430,6 +497,8 @@ function apbct_settings__field__debug(){
430
 
431
  global $apbct;
432
 
 
 
433
  echo '<hr /><h2>Debug:</h2>';
434
  echo '<h4>Constants:</h4>';
435
  echo 'CLEANTALK_AJAX_USE_BUFFER '. (defined('CLEANTALK_AJAX_USE_BUFFER') ? (CLEANTALK_AJAX_USE_BUFFER ? 'true' : 'flase') : 'NOT_DEFINED')."<br>";
@@ -449,6 +518,8 @@ function apbct_settings__field__debug(){
449
  echo "$output";
450
 
451
  echo "</div>";
 
 
452
  }
453
 
454
  function apbct_settings__field__state(){
@@ -509,7 +580,7 @@ function apbct_settings__field__state(){
509
 
510
  // WooCommerce
511
  if(class_exists('WooCommerce'))
512
- echo '<img class="apbct_status_icon" src="'.($apbct->options['wc_checkout_test']==1 || $apbct->moderate_ip ? $img : $img_no).'"/>'.__('WooCommerce checkout form', 'cleantalk');
513
 
514
  if($apbct->moderate_ip)
515
  print "<br /><br />The anti-spam service is paid by your hosting provider. License #".$apbct->data['ip_license'].".<br />";
@@ -524,16 +595,32 @@ function apbct_settings__field__api_key(){
524
 
525
  global $apbct;
526
 
527
- echo '<div id="cleantalk_apkey_wrapper" class="apbct_settings-field_wrapper" '.(apbct_api_key__is_correct($apbct->api_key) && $apbct->key_is_ok ? 'style="display: none"' : '').'>';
 
 
 
528
 
529
- if(!defined('CLEANTALK_ACCESS_KEY') || !is_multisite()){
 
530
 
531
- echo '<label class="apbct_settings__label" for="cleantalk_apkey">'.__('Access key', 'cleantalk').'</label>'
532
- .'<input class="apbct_settings__text_feld" name="cleantalk_settings[apikey]" size="20" type="text" value="'.$apbct->api_key.'" style=\"font-size: 14pt;\" placeholder="' . __('Enter the key', 'cleantalk') . '" />';
 
 
 
 
 
 
 
 
 
 
 
 
 
533
 
534
  // Key is correct
535
  if(!apbct_api_key__is_correct($apbct->api_key) || !$apbct->key_is_ok){
536
- echo '<script>var cleantalk_good_key=false;</script>';
537
  echo '<br /><br />';
538
 
539
  // Auto get key
@@ -564,17 +651,15 @@ function apbct_settings__field__api_key(){
564
  echo '</div>';
565
  }
566
 
567
- }else{
568
- _e('<h3>Key is provided by Super Admin.<h3>', 'cleantalk');
569
  }
570
 
571
  echo '</div>';
572
 
573
  if($apbct->ip_license){
574
- $cleantalk_support_links = "<br /><div>";
575
- $cleantalk_support_links .= "<a href='#' class='ct_support_link'>" . __("Show the access key", 'cleantalk') . "</a>";
576
- $cleantalk_support_links .= "</div>";
577
- echo "<script type=\"text/javascript\">var cleantalk_good_key=true; var cleantalk_support_links = \"$cleantalk_support_links\";</script>";
578
  }
579
  }
580
 
@@ -586,9 +671,10 @@ function apbct_settings__field__action_buttons(){
586
 
587
  if(apbct_api_key__is_correct($apbct->api_key) && $apbct->key_is_ok){
588
  echo '<div>'
589
- .'<a href="#" class="ct_support_link" onclick="apbct_show_hide_elem(\'#cleantalk_apkey_wrapper\')">' . __('Show the access key', 'cleantalk') . '</a>'
590
- .'&nbsp;&nbsp;'
591
- .'&nbsp;&nbsp;'
 
592
  .'<a href="edit-comments.php?page=ct_check_spam" class="ct_support_link">' . __('Check comments for spam', 'cleantalk') . '</a>'
593
  .'&nbsp;&nbsp;'
594
  .'&nbsp;&nbsp;'
@@ -612,7 +698,7 @@ function apbct_settings__field__connection_reports() {
612
  if ($apbct->connection_reports){
613
 
614
  if ($apbct->connection_reports['negative'] == 0){
615
- _e('There are no failed connections to CleanTalk servers.', 'cleantalk');
616
  }else{
617
  echo "<table id='negative_reports_table' style='display: none;'>
618
  <tr>
@@ -640,6 +726,8 @@ function apbct_settings__field__draw($params = array()){
640
 
641
  echo '<div class="'.$params['def_class'].(isset($params['class']) ? ' '.$params['class'] : '').'">';
642
  switch($params['type']){
 
 
643
  case 'checkbox':
644
  echo '<input type="checkbox" id="apbct_setting_'.$params['name'].'" name="cleantalk_settings['.$params['name'].']" value="1" '
645
  .($apbct->settings[$params['name']] == '1' ? ' checked' : '')
@@ -653,6 +741,8 @@ function apbct_settings__field__draw($params = array()){
653
  .$params['description']
654
  .'</div>';
655
  break;
 
 
656
  case 'radio':
657
  echo '<h4 class="apbct_settings-field_title apbct_settings-field_title--'.$params['type'].'">'
658
  .$params['title']
@@ -687,11 +777,19 @@ function apbct_settings__field__draw($params = array()){
687
 
688
  /**
689
  * Admin callback function - Plugin parameters validator
 
 
 
 
690
  */
691
  function apbct_settings__validate($settings) {
692
 
693
  global $apbct;
694
 
 
 
 
 
695
  // Drop debug data
696
  if (isset($_POST['submit']) && $_POST['submit'] == 'debug_drop'){
697
  $apbct->debug = false;
@@ -710,9 +808,17 @@ function apbct_settings__validate($settings) {
710
 
711
  $website = parse_url(get_option('siteurl'),PHP_URL_HOST);
712
  $platform = 'wordpress';
713
- $timezone = $_POST['ct_admin_timezone'];
 
 
714
 
715
- $result = CleantalkHelper::api_method__get_api_key(ct_get_admin_email(), $website, $platform, $timezone);
 
 
 
 
 
 
716
 
717
  if(empty($result['error'])){
718
 
@@ -725,15 +831,16 @@ function apbct_settings__validate($settings) {
725
  }
726
 
727
  }else{
 
728
  $apbct->error_add('key_get', $result);
 
 
729
  return $settings;
730
  }
731
  }
732
 
733
  // Feedback with app_agent
734
- ct_send_feedback('0:' . APBCT_AGENT); // 0 - request_id, agent version.
735
-
736
- $settings['apikey'] = isset($settings['apikey']) ? trim($settings['apikey']) : '';
737
 
738
  // Key is good by default
739
  $apbct->data['key_is_ok'] = true;
@@ -741,7 +848,7 @@ function apbct_settings__validate($settings) {
741
  // Is key correct?
742
  if(apbct_api_key__is_correct($settings['apikey'])){
743
 
744
- $result = CleantalkHelper::api_method__notice_validate_key($settings['apikey'], preg_replace('/http[s]?:\/\//', '', get_option('siteurl'), 1));
745
 
746
  // Is key valid?
747
  if (empty($result['error'])){
@@ -754,11 +861,15 @@ function apbct_settings__validate($settings) {
754
  // Check account status
755
  ct_account_status_check($settings['apikey']);
756
 
 
757
  if($apbct->settings['spam_firewall'] == 1){
758
- ct_sfw_update();
759
- ct_sfw_send_logs();
760
  }
761
 
 
 
 
762
  // Key is not valid
763
  }else{
764
  $apbct->data['key_is_ok'] = false;
@@ -782,15 +893,6 @@ function apbct_settings__validate($settings) {
782
  $apbct->error_add('key_invalid', __('Key is not correct', 'cleantalk'));
783
  }
784
 
785
- // A-B test with SFW
786
- if(!$apbct->data['ab_test']['sfw_enabled']){
787
- if($apbct->service_id && $apbct->service_id % 2 == 1)
788
- $settings['spam_firewall'] = 0;
789
- else
790
- $settings['spam_firewall'] = 1;
791
- $apbct->data['ab_test']['sfw_enabled'] = true;
792
- }
793
-
794
  $apbct->saveData();
795
 
796
  return $settings;
5
  */
6
  function apbct_settings__add_page() {
7
 
8
+ global $apbct, $pagenow, $_wp_last_object_menu;
9
+
10
+ /*
11
+ if($apbct->white_label){
12
+ // Top menu
13
+ add_menu_page($apbct->plugin_name, $apbct->plugin_name, 'activate_plugins', 'apbct_menu', '',
14
+ // 'dashicons-cf-logo1'
15
+ APBCT_URL_PATH . '/inc/images/logo_small.png' // Menu icon
16
+ , '65.64');
17
+ // Submenus
18
+ // add_submenu_page('apbct_menu', __('Summary', 'cleantalk'), __('Summary', 'cleantalk'), 'activate_plugins', 'apbct_menu', 'function');
19
+ // add_submenu_page('apbct_menu', __('Anti-Spam log', 'cleantalk'), __('Anti-Spam log', 'cleantalk'), 'activate_plugins', 'apbct_menu__log', 'function');
20
+ add_submenu_page('apbct_menu', __('Settings', 'cleantalk'), __('Settings', 'cleantalk'), 'activate_plugins', 'apbct_menu', 'apbct_settings_page');
21
+ }else{
22
+ */
23
  // Adding settings page
24
+ if(is_network_admin() && !$apbct->white_label)
25
+ add_submenu_page("settings.php", __('CleanTalk settings', 'cleantalk'), $apbct->plugin_name, 'manage_options', 'cleantalk', 'apbct_settings_page');
26
  else
27
+ add_options_page(__('CleanTalk settings', 'cleantalk'), $apbct->plugin_name, 'manage_options', 'cleantalk', 'apbct_settings_page');
28
+ // }
29
 
30
+ if(!in_array($pagenow, array('options.php', 'options-general.php', 'settings.php', 'admin.php')))
31
  return;
32
 
33
  register_setting('cleantalk_settings', 'cleantalk_settings', 'apbct_settings__validate');
34
 
35
+ // add_settings_section('cleantalk_section_settings_main', '', 'apbct_section__settings_main', 'cleantalk');
 
 
 
 
 
 
 
 
 
36
 
37
  // KEY
38
+ // add_settings_field('apbct_action_butons', '', 'apbct_settings__field__action_buttons', 'cleantalk', 'cleantalk_section_settings_main');
39
+ // add_settings_field('cleantalk_api_key', '', 'apbct_settings__field__api_key', 'cleantalk', 'cleantalk_section_settings_main');
40
+ // add_settings_field('cleantalk_connection_reports', '', 'apbct_settings__field__connection_reports', 'cleantalk', 'cleantalk_section_settings_main');
 
41
 
42
  $field_default_params = array(
43
  'callback' => 'apbct_settings__field__draw',
48
  'childrens' => '',
49
  'title' => 'Default title',
50
  'description' => 'Default description',
51
+ 'display' => true, // Draw settings or not
52
  );
53
 
54
  $apbct->settings_fields_in_groups = array(
55
 
56
+ 'main' => array(
57
+ 'title' => '',
58
+ 'default_params' => array(),
59
+ 'description' => '',
60
+ 'html_before' => '',
61
+ 'html_after' => '',
62
+ 'fields' => array(
63
+ 'action_buttons' => array(
64
+ 'callback' => 'apbct_settings__field__action_buttons',
65
+ ),
66
+ 'api_key' => array(
67
+ 'callback' => 'apbct_settings__field__api_key',
68
+ ),
69
+ 'connection_reports' => array(
70
+ 'callback' => 'apbct_settings__field__connection_reports',
71
+ ),
72
+ ),
73
+ ),
74
+
75
+ 'state' => array(
76
+ 'title' => '',
77
+ 'default_params' => array(),
78
+ 'description' => '',
79
+ 'html_before' => '<hr>',
80
+ 'html_after' => '',
81
+ 'fields' => array(
82
+ 'state' => array(
83
+ 'callback' => 'apbct_settings__field__state',
84
+ ),
85
+ ),
86
+ ),
87
+
88
+ 'debug' => array(
89
+ 'title' => '',
90
+ 'default_params' => array(),
91
+ 'description' => '',
92
+ 'html_before' => '',
93
+ 'html_after' => '',
94
+ 'fields' => array(
95
+ 'state' => array(
96
+ 'callback' => 'apbct_settings__field__debug',
97
+ ),
98
+ ),
99
+ ),
100
+
101
  // Different
102
  'different' => array(
103
  'title' => '',
110
  'type' => 'checkbox',
111
  'title' => __('Tell others about CleanTalk', 'cleantalk'),
112
  'description' => __("Checking this box places a small link under the comment form that lets others know what anti-spam tool protects your site.", 'cleantalk'),
113
+ 'display' => !$apbct->white_label,
114
  ),
115
  'spam_firewall' => array(
116
  'type' => 'checkbox',
187
  'show_check_links' => array(
188
  'title' => __('Show links to check Emails, IPs for spam.', 'cleantalk'),
189
  'description' => __('Shows little icon near IP addresses and Emails allowing you to check it via CleanTalk\'s database. Also allowing you to manage comments from the public post\'s page.', 'cleantalk'),
190
+ 'display' => !$apbct->white_label,
191
  ),
192
  ),
193
  ),
206
  ),
207
  'general_postdata_test' => array(
208
  'title' => __('Check all post data', 'cleantalk'),
209
+ 'description' => __('Check all POST submissions from website visitors. Enable this option if you have spam misses on website.', 'cleantalk')
210
+ .(!$apbct->white_label
211
+ ? __(' Or you don`t have records about missed spam here:', 'cleantalk') . '&nbsp;' . '<a href="https://cleantalk.org/my/?user_token='.$apbct->user_token.'&utm_source=wp-backend&utm_medium=admin-bar&cp_mode=antispam" target="_blank">' . __('CleanTalk dashboard', 'cleantalk') . '</a>.'
212
+ : ''
213
+ )
214
+ .'<br />' . __('СAUTION! Option can catch POST requests in WordPress backend', 'cleantalk'),
215
  ),
216
  'set_cookies' => array(
217
  'title' => __("Set cookies", 'cleantalk'),
218
+ 'description' => __('Turn this option off to deny plugin generates any cookies on website front-end. This option is helpful if you use Varnish. But most of contact forms will not be protected if the option is turned off! <b>Warning: We strongly recommend you to enable this otherwise it could cause false positives spam detection.</b>', 'cleantalk'),
219
  ),
220
  'ssl_on' => array(
221
  'title' => __("Use SSL", 'cleantalk'),
222
+ 'description' => __('Turn this option on to use encrypted (SSL) connection with servers.', 'cleantalk'),
223
  ),
224
  ),
225
  ),
234
  'fields' => array(
235
  'show_adminbar' => array(
236
  'title' => __('Show statistics in admin bar', 'cleantalk'),
237
+ 'description' => __('Show/hide icon in top level menu in WordPress backend. The number of submissions is being counted for past 24 hours.', 'cleantalk'),
238
  'childrens' => array('all_time_counter','daily_counter','sfw_counter'),
239
  ),
240
  'all_time_counter' => array(
275
  'async_js' => array(
276
  'type' => 'checkbox',
277
  'title' => __('Async JavaScript loading', 'cleantalk'),
278
+ 'description' => __('Use async loading for scripts. Warning: This could reduce filtration quality.', 'cleantalk'),
279
  ),
280
  ),
281
  ),
293
 
294
  $params['name'] = $field_name;
295
 
296
+ if(!$params['display'])
297
+ continue;
298
+
299
  add_settings_field(
300
  'apbct_field__'.$field_name,
301
  '',
323
 
324
  // Title
325
  echo '<h2 class="apbct_settings-title">'.__($apbct->plugin_name, 'cleantalk').'</h2>';
326
+
327
  // Subtitle for IP license
328
  if($apbct->moderate_ip)
329
  echo '<h4 class="apbct_settings-subtitle gray">'. __('Hosting AntiSpam', 'cleantalk').'</h4>';
 
 
 
 
 
330
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  echo '<form action="options.php" method="post">';
332
 
333
+ if(!is_network_admin())
334
+ apbct_settings__error__output();
335
+
336
+ // Top info
337
+ if(!$apbct->white_label){
338
+ echo '<div style="float: right; padding: 15px 15px 0 15px; font-size: 13px;">';
339
+
340
+ echo __('CleanTalk\'s tech support:', 'cleantalk')
341
+ .'&nbsp;'
342
+ .'<a target="_blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">Wordpress.org</a>.'
343
+ // .' <a href="https://community.cleantalk.org/viewforum.php?f=25" target="_blank">'.__("Tech forum", 'cleantalk').'</a>'
344
+ // .($user_token ? ", <a href='https://cleantalk.org/my/support?user_token=$user_token&cp_mode=antispam' target='_blank'>".__("Service support ", 'cleantalk').'</a>' : '').
345
+ .'<br>';
346
+ echo __('Plugin Homepage at', 'cleantalk').' <a href="http://cleantalk.org" target="_blank">cleantalk.org</a>.<br/>';
347
+ echo '<span id="apbct_gdpr_open_modal" style="text-decoration: underline;">'.__('GDPR compliance', 'cleantalk').'</span><br/>';
348
+ echo __('Use s@cleantalk.org to test plugin in any WordPress form.', 'cleantalk').'<br>';
349
+ echo __('CleanTalk is registered Trademark. All rights reserved.', 'cleantalk').'<br/>';
350
+ if($apbct->key_is_ok)
351
+ echo '<b style="display: inline-block; margin-top: 10px;">'.sprintf(__('Do you like CleanTalk? %sPost your feedback here%s.', 'cleantalk'), '<a href="https://wordpress.org/support/plugin/cleantalk-spam-protect/reviews/#new-post" target="_blank">', '</a>').'</b><br />';
352
+ apbct_admin__badge__get_premium();
353
+ echo '<div id="gdpr_dialog" style="display: none; padding: 7px;">';
354
+ apbct_gdpr__show_text();
355
+ echo '</div>';
356
+ echo '</div>';
357
+ }
358
+
359
  // If it's network admin dashboard
360
  if(is_network_admin()){
361
  if(defined('CLEANTALK_ACCESS_KEY')){
378
  .'<br>'
379
  .'<span>'
380
  .sprintf(
381
+ __( '%s has blocked <b>%s</b> spam.', 'cleantalk' ),
382
+ $apbct->plugin_name,
383
  number_format($apbct->spam_count, 0, ',', ' ')
384
  )
385
  .'</span>'
387
  .'<br>'
388
  .'</div>';
389
  }
390
+ if(!$apbct->white_label){
391
+ // CP button
392
+ echo '<a class="cleantalk_manual_link" target="__blank" href="https://cleantalk.org/my?user_token='.$apbct->user_token.'&cp_mode=antispam">'.__('Click here to get anti-spam statistics', 'cleantalk').'</a>';
393
+ echo '&nbsp;&nbsp;';
394
+ // Support button
395
+ echo '<a class="cleantalk_auto_link" target="__blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">'.__('Support',
396
+ 'cleantalk').'</a>';
397
+ echo '<br>'
398
+ .'<br>';
399
+ }
400
  }
401
 
402
  settings_fields('cleantalk_settings');
403
  do_settings_fields('cleantalk', 'cleantalk_section_settings_main');
404
+
 
 
 
 
 
 
405
  foreach($apbct->settings_fields_in_groups as $group_name => $group){
406
 
407
  echo !empty($group['html_before']) ? $group['html_before'] : '';
418
 
419
  echo "</form>";
420
 
421
+ if(!$apbct->white_label){
422
+ // Translate banner for non EN locale
423
+ if(substr(get_locale(), 0, 2) != 'en'){
424
+ require_once(CLEANTALK_PLUGIN_DIR.'templates/translate_banner.php');
425
+ printf($ct_translate_banner_template, substr(get_locale(), 0, 2));
426
+ }
427
  }
428
  }
429
 
472
  $errors_out[$type] = '';
473
  if(isset($error['error_time']))
474
  $errors_out[$type] .= date('Y-m-d H:i:s', $error['error_time']) . ': ';
475
+ $errors_out[$type] .= (isset($error_texts[$type]) ? $error_texts[$type] : $error_texts['unknown']) . ' ' . (isset($error['error_string']) ? $error['error_string'] : '');
476
 
477
  }
478
  }
480
  if(!empty($errors_out)){
481
  $out .= '<div id="apbctTopWarning" class="error" style="position: relative;">'
482
  .'<h3 style="display: inline-block;">'.__('Errors:', 'security-malware-firewall').'</h3>';
483
+ foreach($errors_out as $value){
484
  $out .= '<h4>'.$value.'</h4>';
485
+ }
486
+ $out .= !$apbct->white_label
487
+ ? '<h4 style="text-align: none;">'.sprintf(__('You can get support any time here: %s.', 'cleantalk'), '<a target="blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">https://wordpress.org/support/plugin/cleantalk-spam-protect</a>').'</h4>'
488
+ : '';
489
  $out .= '</div>';
490
  }
491
  }
497
 
498
  global $apbct;
499
 
500
+ if($apbct->debug){
501
+
502
  echo '<hr /><h2>Debug:</h2>';
503
  echo '<h4>Constants:</h4>';
504
  echo 'CLEANTALK_AJAX_USE_BUFFER '. (defined('CLEANTALK_AJAX_USE_BUFFER') ? (CLEANTALK_AJAX_USE_BUFFER ? 'true' : 'flase') : 'NOT_DEFINED')."<br>";
518
  echo "$output";
519
 
520
  echo "</div>";
521
+
522
+ }
523
  }
524
 
525
  function apbct_settings__field__state(){
580
 
581
  // WooCommerce
582
  if(class_exists('WooCommerce'))
583
+ echo '<img class="apbct_status_icon" src="'.($apbct->settings['wc_checkout_test'] == 1 || $apbct->moderate_ip ? $img : $img_no).'"/>'.__('WooCommerce checkout form', 'cleantalk');
584
 
585
  if($apbct->moderate_ip)
586
  print "<br /><br />The anti-spam service is paid by your hosting provider. License #".$apbct->data['ip_license'].".<br />";
595
 
596
  global $apbct;
597
 
598
+ echo '<div id="cleantalk_apikey_wrapper" class="apbct_settings-field_wrapper" '.(apbct_api_key__is_correct($apbct->api_key) && $apbct->key_is_ok ? 'style="display: none"' : '').'>';
599
+
600
+ // White label
601
+ if($apbct->white_label){
602
 
603
+ // WPMS and key defined
604
+ }elseif(defined('CLEANTALK_ACCESS_KEY') && is_multisite()){
605
 
606
+ _e('<h3>Key is provided by Super Admin.<h3>', 'cleantalk');
607
+
608
+ // Normal flow
609
+ }elseif(true){
610
+
611
+ echo '<label class="apbct_settings__label" for="cleantalk_apkey">'
612
+ .__('Access key', 'cleantalk')
613
+ .'</label>'
614
+ .'<input
615
+ class="apbct_settings__text_feld"
616
+ name="cleantalk_settings[apikey]"
617
+ size="20" type="text"
618
+ value="'.$apbct->api_key.'"
619
+ style="font-size: 14pt;"
620
+ placeholder="' . __('Enter the key', 'cleantalk') . '" />';
621
 
622
  // Key is correct
623
  if(!apbct_api_key__is_correct($apbct->api_key) || !$apbct->key_is_ok){
 
624
  echo '<br /><br />';
625
 
626
  // Auto get key
651
  echo '</div>';
652
  }
653
 
 
 
654
  }
655
 
656
  echo '</div>';
657
 
658
  if($apbct->ip_license){
659
+ // $cleantalk_support_links = "<br /><div>";
660
+ // $cleantalk_support_links .= "<a href='#' class='ct_support_link'>" . __("Show the access key", 'cleantalk') . "</a>";
661
+ // $cleantalk_support_links .= "</div>";
662
+ // echo "<script type=\"text/javascript\">var cleantalk_good_key=true; var cleantalk_support_links = \"$cleantalk_support_links\";</script>";
663
  }
664
  }
665
 
671
 
672
  if(apbct_api_key__is_correct($apbct->api_key) && $apbct->key_is_ok){
673
  echo '<div>'
674
+ .(!$apbct->white_label
675
+ ?'<a href="#" class="ct_support_link" onclick="apbct_show_hide_elem(\'#cleantalk_apikey_wrapper\')">' . __('Show the access key', 'cleantalk') . '</a>' . '&nbsp;&nbsp;' . '&nbsp;&nbsp;'
676
+ : ''
677
+ )
678
  .'<a href="edit-comments.php?page=ct_check_spam" class="ct_support_link">' . __('Check comments for spam', 'cleantalk') . '</a>'
679
  .'&nbsp;&nbsp;'
680
  .'&nbsp;&nbsp;'
698
  if ($apbct->connection_reports){
699
 
700
  if ($apbct->connection_reports['negative'] == 0){
701
+ _e('There are no failed connections to server.', 'cleantalk');
702
  }else{
703
  echo "<table id='negative_reports_table' style='display: none;'>
704
  <tr>
726
 
727
  echo '<div class="'.$params['def_class'].(isset($params['class']) ? ' '.$params['class'] : '').'">';
728
  switch($params['type']){
729
+
730
+ // Checkbox type
731
  case 'checkbox':
732
  echo '<input type="checkbox" id="apbct_setting_'.$params['name'].'" name="cleantalk_settings['.$params['name'].']" value="1" '
733
  .($apbct->settings[$params['name']] == '1' ? ' checked' : '')
741
  .$params['description']
742
  .'</div>';
743
  break;
744
+
745
+ // Radio type
746
  case 'radio':
747
  echo '<h4 class="apbct_settings-field_title apbct_settings-field_title--'.$params['type'].'">'
748
  .$params['title']
777
 
778
  /**
779
  * Admin callback function - Plugin parameters validator
780
+ *
781
+ * @global CleantalkState $apbct
782
+ * @param array $settings Array with passed settings
783
+ * @return array Array with processed settings
784
  */
785
  function apbct_settings__validate($settings) {
786
 
787
  global $apbct;
788
 
789
+ // validating API key
790
+ $settings['apikey'] = isset($settings['apikey']) ? trim($settings['apikey']) : '';
791
+ $settings['apikey'] = $apbct->white_label ? $apbct->settings['apikey'] : $settings['apikey'];
792
+
793
  // Drop debug data
794
  if (isset($_POST['submit']) && $_POST['submit'] == 'debug_drop'){
795
  $apbct->debug = false;
808
 
809
  $website = parse_url(get_option('siteurl'),PHP_URL_HOST);
810
  $platform = 'wordpress';
811
+ $timezone = isset($_POST['ct_admin_timezone']) ? $_POST['ct_admin_timezone'] : null;
812
+ $language = !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : null;
813
+ $ip = CleantalkHelper::ip_get(array('real'), false);
814
 
815
+ if(!$apbct->white_label){
816
+ $result = CleantalkAPI::method__get_api_key(ct_get_admin_email(), $website, $platform, $timezone, $language, $ip);
817
+ }else{
818
+ $white_label = 1;
819
+ $hoster_api_key = defined('APBCT_HOSTER_API_KEY') ? APBCT_HOSTER_API_KEY : '';
820
+ $result = CleantalkAPI::method__get_api_key(ct_get_admin_email(), $website, $platform, $timezone, $language, $ip, $white_label, $hoster_api_key);
821
+ }
822
 
823
  if(empty($result['error'])){
824
 
831
  }
832
 
833
  }else{
834
+ if(!$apbct->white_label)
835
  $apbct->error_add('key_get', $result);
836
+ else
837
+ $apbct->error_add('key_get', $result['error_string'] . ' <button id="apbct_setting_get_key_auto" name="submit" type="submit" class="cleantalk_manual_link" value="get_key_auto">'.__('Get access key automatically', 'cleantalk').'</button>'.'<input type="hidden" id="ct_admin_timezone" name="ct_admin_timezone" value="null" />');
838
  return $settings;
839
  }
840
  }
841
 
842
  // Feedback with app_agent
843
+ ct_send_feedback('0:' . CLEANTALK_AGENT); // 0 - request_id, agent version.
 
 
844
 
845
  // Key is good by default
846
  $apbct->data['key_is_ok'] = true;
848
  // Is key correct?
849
  if(apbct_api_key__is_correct($settings['apikey'])){
850
 
851
+ $result = CleantalkAPI::method__notice_validate_key($settings['apikey'], preg_replace('/http[s]?:\/\//', '', get_option('siteurl'), 1));
852
 
853
  // Is key valid?
854
  if (empty($result['error'])){
861
  // Check account status
862
  ct_account_status_check($settings['apikey']);
863
 
864
+ // SFW actions
865
  if($apbct->settings['spam_firewall'] == 1){
866
+ ct_sfw_update($settings['apikey']);
867
+ ct_sfw_send_logs($settings['apikey']);
868
  }
869
 
870
+ // Updating brief data for dashboard widget
871
+ $apbct->data['brief_data'] = CleantalkAPI::method__get_antispam_report_breif($settings['apikey']);
872
+
873
  // Key is not valid
874
  }else{
875
  $apbct->data['key_is_ok'] = false;
893
  $apbct->error_add('key_invalid', __('Key is not correct', 'cleantalk'));
894
  }
895
 
 
 
 
 
 
 
 
 
 
896
  $apbct->saveData();
897
 
898
  return $settings;
inc/cleantalk-users.php CHANGED
@@ -17,14 +17,12 @@ function ct_add_users_menu(){
17
 
18
  function ct_show_users_page(){
19
 
20
- $settings_link = (is_network_admin() ? 'settings.php?page=cleantalk' : 'options-general.php?page=cleantalk');
21
-
22
- global $wpdb;
23
 
24
  ?>
25
  <div class="wrap">
26
- <h2><img src="<?php echo plugin_dir_url(__FILE__) ?>/images/logo_color.png" /> <?php echo APBCT_NAME; ?></h2>
27
- <a style="color: gray; margin-left: 23px;" href="<?php echo $settings_link; ?>">Plugin Settings</a>
28
  <br />
29
  <?php
30
 
@@ -184,9 +182,11 @@ function ct_show_users_page(){
184
  // Outputs email if exists
185
  if(!empty($email)){
186
  echo "<a href='mailto:$email'>$email</a>"
187
- ."<a href='https://cleantalk.org/blacklists/$email' target='_blank'>"
 
188
  ."&nbsp;<img src='".plugin_dir_url(__FILE__)."images/new_window.gif' border='0' style='float:none' />"
189
- ."</a>";
 
190
  }else{
191
  echo "No email";
192
  }
@@ -199,9 +199,11 @@ function ct_show_users_page(){
199
  if(!empty($user_meta[0]['ip'])){
200
  $ip = $user_meta[0]['ip'];
201
  echo "<a href='user-edit.php?user_id=$id'>$ip</a>"
202
- ."<a href='https://cleantalk.org/blacklists/$ip' target='_blank'>"
 
203
  ."&nbsp;<img src='".plugin_dir_url(__FILE__)."images/new_window.gif' border='0' style='float:none' />"
204
- ."</a>";
 
205
  }else
206
  echo "No IP adress";
207
  }else
@@ -396,7 +398,7 @@ function ct_ajax_check_users(){
396
  die();
397
  }
398
 
399
- $result = CleantalkHelper::api_method__spam_check_cms($apbct->api_key, $data, !empty($_POST['accurate_check']) ? $curr_date : null);
400
 
401
  if(empty($result['error'])){
402
 
17
 
18
  function ct_show_users_page(){
19
 
20
+ global $wpdb, $apbct;
 
 
21
 
22
  ?>
23
  <div class="wrap">
24
+ <h2><img src="<?php echo $apbct->logo__small__colored; ?>" /> <?php echo $apbct->plugin_name; ?></h2>
25
+ <a style="color: gray; margin-left: 23px;" href="<?php echo $apbct->settings_link; ?>"><?php _e('Plugin Settings', 'cleantalk'); ?></a>
26
  <br />
27
  <?php
28
 
182
  // Outputs email if exists
183
  if(!empty($email)){
184
  echo "<a href='mailto:$email'>$email</a>"
185
+ .(!$apbct->white_label
186
+ ? "<a href='https://cleantalk.org/blacklists/$email' target='_blank'>"
187
  ."&nbsp;<img src='".plugin_dir_url(__FILE__)."images/new_window.gif' border='0' style='float:none' />"
188
+ ."</a>"
189
+ : '');
190
  }else{
191
  echo "No email";
192
  }
199
  if(!empty($user_meta[0]['ip'])){
200
  $ip = $user_meta[0]['ip'];
201
  echo "<a href='user-edit.php?user_id=$id'>$ip</a>"
202
+ .(!$apbct->white_label
203
+ ?"<a href='https://cleantalk.org/blacklists/$ip ' target='_blank'>"
204
  ."&nbsp;<img src='".plugin_dir_url(__FILE__)."images/new_window.gif' border='0' style='float:none' />"
205
+ ."</a>"
206
+ : '');
207
  }else
208
  echo "No IP adress";
209
  }else
398
  die();
399
  }
400
 
401
+ $result = CleantalkAPI::method__spam_check_cms($apbct->api_key, $data, !empty($_POST['accurate_check']) ? $curr_date : null);
402
 
403
  if(empty($result['error'])){
404
 
inc/sfw_die_page.html CHANGED
@@ -38,6 +38,8 @@ function get_current_url() {
38
  <div class='container'>
39
  <h1 class='main'>{SFW_DIE_NOTICE_IP}<a href='https://cleantalk.org/blacklists/{REMOTE_ADDRESS}' target='_blank'>{REMOTE_ADDRESS}</a></h1>
40
 
 
 
41
  <div id='js_info'><br />{SFW_DIE_MAKE_SURE_JS_ENABLED}</div>
42
 
43
  <div id='js_passed'>
@@ -46,6 +48,7 @@ function get_current_url() {
46
  {GENERATED}
47
  <br /><br /><br />
48
  <p class='js_notice'>{SFW_DIE_YOU_WILL_BE_REDIRECTED}</p>
 
49
  </div>
50
  </div>
51
  <div class='footer'>
38
  <div class='container'>
39
  <h1 class='main'>{SFW_DIE_NOTICE_IP}<a href='https://cleantalk.org/blacklists/{REMOTE_ADDRESS}' target='_blank'>{REMOTE_ADDRESS}</a></h1>
40
 
41
+ <h2>{TEST_TITLE}</h2>
42
+
43
  <div id='js_info'><br />{SFW_DIE_MAKE_SURE_JS_ENABLED}</div>
44
 
45
  <div id='js_passed'>
48
  {GENERATED}
49
  <br /><br /><br />
50
  <p class='js_notice'>{SFW_DIE_YOU_WILL_BE_REDIRECTED}</p>
51
+ <br />
52
  </div>
53
  </div>
54
  <div class='footer'>
js/apbct-public.js CHANGED
@@ -9,12 +9,12 @@ function ctSetCookieSec(c_name, value) {
9
  }
10
 
11
  function apbct_attach_event_handler(elem, event, callback){
12
- if(typeof window.addEventListener == "function") elem.addEventListener(event, callback);
13
  else elem.attachEvent(event, callback);
14
  }
15
 
16
  function apbct_remove_event_handler(elem, event, callback){
17
- if(typeof window.removeEventListener == "function") elem.removeEventListener(event, callback);
18
  else elem.detachEvent(event, callback);
19
  }
20
 
@@ -32,7 +32,7 @@ var ctFunctionFirstKey = function output(event){
32
  var KeyTimestamp = Math.floor(new Date().getTime()/1000);
33
  ctSetCookieSec("ct_fkp_timestamp", KeyTimestamp);
34
  ctKeyStopStopListening();
35
- }
36
 
37
  //Reading interval
38
  var ctMouseReadInterval = setInterval(function(){
@@ -46,7 +46,7 @@ var ctMouseWriteDataInterval = setInterval(function(){
46
 
47
  //Logging mouse position each 150 ms
48
  var ctFunctionMouseMove = function output(event){
49
- if(ctMouseEventTimerFlag == true){
50
 
51
  ctMouseData.push([
52
  Math.round(event.pageY),
@@ -60,7 +60,7 @@ var ctFunctionMouseMove = function output(event){
60
  ctMouseStopData();
61
  }
62
  }
63
- }
64
 
65
  //Stop mouse observing function
66
  function ctMouseStopData(){
@@ -86,31 +86,68 @@ function apbct_ready(){
86
  setTimeout(function(){
87
  for(var i = 0; i < document.forms.length; i++){
88
  var form = document.forms[i];
 
89
  form.onsubmit_prev = form.onsubmit;
90
  form.onsubmit = function(event){
91
- this.visible_fields = '';
92
- this.visible_fields_count = this.elements.length;
93
- for(var j = 0; j < this.elements.length; j++){
94
- var elem = this.elements[j];
95
- if( getComputedStyle(elem).display == "none" ||
96
- getComputedStyle(elem).visibility == "hidden" ||
97
- getComputedStyle(elem).width == "0" ||
98
- getComputedStyle(elem).heigth == "0" ||
99
- getComputedStyle(elem).opacity == "0" ||
100
- elem.getAttribute("type") == "hidden" ||
101
- elem.getAttribute("type") == "submit"
 
 
 
 
 
 
 
 
 
 
 
102
  ){
103
- this.visible_fields_count--;
104
- }else{
105
- this.visible_fields += (this.visible_fields == "" ? "" : " ") + elem.getAttribute("name");
106
  }
 
 
 
 
 
 
 
107
  }
108
- ctSetCookieSec("apbct_visible_fields", this.visible_fields);
109
- ctSetCookieSec("apbct_visible_fields_count", this.visible_fields_count);
110
- if(this.onsubmit_prev instanceof Function){
111
- this.onsubmit_prev.call(this, event);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  }
113
- }
114
  }
115
  }, 1000);
116
  }
9
  }
10
 
11
  function apbct_attach_event_handler(elem, event, callback){
12
+ if(typeof window.addEventListener === "function") elem.addEventListener(event, callback);
13
  else elem.attachEvent(event, callback);
14
  }
15
 
16
  function apbct_remove_event_handler(elem, event, callback){
17
+ if(typeof window.removeEventListener === "function") elem.removeEventListener(event, callback);
18
  else elem.detachEvent(event, callback);
19
  }
20
 
32
  var KeyTimestamp = Math.floor(new Date().getTime()/1000);
33
  ctSetCookieSec("ct_fkp_timestamp", KeyTimestamp);
34
  ctKeyStopStopListening();
35
+ };
36
 
37
  //Reading interval
38
  var ctMouseReadInterval = setInterval(function(){
46
 
47
  //Logging mouse position each 150 ms
48
  var ctFunctionMouseMove = function output(event){
49
+ if(ctMouseEventTimerFlag === true){
50
 
51
  ctMouseData.push([
52
  Math.round(event.pageY),
60
  ctMouseStopData();
61
  }
62
  }
63
+ };
64
 
65
  //Stop mouse observing function
66
  function ctMouseStopData(){
86
  setTimeout(function(){
87
  for(var i = 0; i < document.forms.length; i++){
88
  var form = document.forms[i];
89
+
90
  form.onsubmit_prev = form.onsubmit;
91
  form.onsubmit = function(event){
92
+
93
+ // Get only fields
94
+ var elements = [];
95
+ for(var key in document.forms[0].elements){
96
+ if(!isNaN(+key))
97
+ elements[key] = document.forms[0].elements[key];
98
+ }
99
+
100
+ // Filter fields
101
+ elements = elements.filter(function(elem){
102
+
103
+ var pass = true;
104
+
105
+ // Filter fields
106
+ if( getComputedStyle(elem).display === "none" || // hidden
107
+ getComputedStyle(elem).visibility === "hidden" || // hidden
108
+ getComputedStyle(elem).width === "0" || // hidden
109
+ getComputedStyle(elem).heigth === "0" || // hidden
110
+ getComputedStyle(elem).opacity === "0" || // hidden
111
+ elem.getAttribute("type") === "hidden" || // type == hidden
112
+ elem.getAttribute("type") === "submit" || // type == submit
113
+ elem.value === "" // empty value
114
  ){
115
+ return false;
 
 
116
  }
117
+
118
+ // Filter elements with same names for type == radio
119
+ if(elem.getAttribute("type") === "radio"){
120
+ elements.forEach(function(el, j, els){
121
+ if(elem.getAttribute('name') === el.getAttribute('name')){
122
+ pass = false;
123
+ return;
124
  }
125
+ });
126
+ }
127
+
128
+ return true;
129
+ });
130
+
131
+ // Visible fields count
132
+ var visible_fields_count = elements.length;
133
+
134
+ // Visible fields
135
+ var visible_fields = '';
136
+ elements.forEach(function(elem, i, elements){
137
+ visible_fields += " " + elem.getAttribute("name");
138
+ });
139
+ visible_fields = visible_fields.trim();
140
+
141
+ ctSetCookieSec("apbct_visible_fields", visible_fields);
142
+ ctSetCookieSec("apbct_visible_fields_count", visible_fields_count);
143
+
144
+ // Call previous submit action
145
+ if(event.target.onsubmit_prev instanceof Function){
146
+ setTimeout(function(){
147
+ event.target.onsubmit_prev.call(event.target, event);
148
+ }, 500);
149
  }
150
+ };
151
  }
152
  }, 1000);
153
  }
js/cleantalk-admin.js CHANGED
@@ -6,6 +6,6 @@ jQuery(document).ready(function(){
6
  document.cookie = "apbct_update_banner_closed=1; path=/; expires=" + ct_date.toUTCString();
7
  });
8
 
9
- jQuery('a[href="options-general.php?page=cleantalk"]').css('padding','5px 8px');
10
 
11
  });
6
  document.cookie = "apbct_update_banner_closed=1; path=/; expires=" + ct_date.toUTCString();
7
  });
8
 
9
+ jQuery('li a[href="options-general.php?page=cleantalk"]').css('padding','5px 8px');
10
 
11
  });
lib/Cleantalk.php CHANGED
@@ -5,12 +5,6 @@
5
  */
6
  class Cleantalk {
7
 
8
- /**
9
- * Debug level
10
- * @var int
11
- */
12
- public $debug = 0;
13
-
14
  /**
15
  * Maximum data size in bytes
16
  * @var int
@@ -192,10 +186,10 @@ class Cleantalk {
192
  switch ($method) {
193
  case 'check_message':
194
  // Convert strings to UTF8
195
- $request->message = $this->arrayToUTF8( $request->message, $this->data_codepage);
196
- $request->example = $this->arrayToUTF8( $request->example, $this->data_codepage);
197
- $request->sender_email = $this->stringToUTF8($request->sender_email, $this->data_codepage);
198
- $request->sender_nickname = $this->stringToUTF8($request->sender_nickname, $this->data_codepage);
199
 
200
  // $request->message = $this->compressData($request->message);
201
  // $request->example = $this->compressData($request->example);
@@ -203,8 +197,8 @@ class Cleantalk {
203
 
204
  case 'check_newuser':
205
  // Convert strings to UTF8
206
- $request->sender_email = $this->stringToUTF8($request->sender_email, $this->data_codepage);
207
- $request->sender_nickname = $this->stringToUTF8($request->sender_nickname, $this->data_codepage);
208
  break;
209
 
210
  case 'send_feedback':
@@ -219,9 +213,9 @@ class Cleantalk {
219
  // Removing non UTF8 characters from request, because non UTF8 or malformed characters break json_encode().
220
  foreach ($request as $param => $value) {
221
  if(is_array($request->$param))
222
- $request->$param = $this->removeNonUTF8FromArray($value);
223
  if(is_string($request->$param) || is_int($request->$param))
224
- $request->$param = $this->removeNonUTF8FromString($value);
225
  }
226
 
227
  $request->message = unserialize($request->message);
@@ -543,86 +537,4 @@ class Cleantalk {
543
 
544
  return $status;
545
  }
546
-
547
-
548
- /**
549
- * Function removing non UTF8 characters from array||string
550
- * param mixed(array||string)
551
- * return mixed(array||string)
552
- */
553
- function removeNonUTF8FromArray($data)
554
- {
555
- foreach($data as $key => $val){
556
- if(is_array($val)){
557
- $data[$key] = $this->removeNonUTF8FromArray($val);
558
- }else{
559
- $data[$key] = $this->removeNonUTF8FromString($val);
560
- }
561
- }
562
- return $data;
563
- }
564
-
565
- /**
566
- * Function removing non UTF8 characters from array||string
567
- * param mixed(array||string)
568
- * return mixed(array||string)
569
- */
570
- function removeNonUTF8FromString($data)
571
- {
572
- if(!preg_match('//u', $data))
573
- $data = 'Nulled. Not UTF8 encoded or malformed.';
574
- return $data;
575
- }
576
-
577
- /**
578
- * Function convert array to UTF8 and removes non UTF8 characters
579
- * param array
580
- * param string
581
- * @return array
582
- */
583
- function arrayToUTF8($array, $data_codepage = null)
584
- {
585
- foreach($array as $key => $val){
586
-
587
- if(is_array($val))
588
- $array[$key] = $this->arrayToUTF8($val, $data_codepage);
589
- else
590
- $array[$key] = $this->stringToUTF8($val, $data_codepage);
591
- }
592
- return $array;
593
- }
594
-
595
- /**
596
- * Function convert string to UTF8 and removes non UTF8 characters
597
- * param string
598
- * param string
599
- * @return string
600
- */
601
- function stringToUTF8($str, $data_codepage = null)
602
- {
603
- if (!preg_match('//u', $str) && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')){
604
-
605
- if ($data_codepage !== null)
606
- return mb_convert_encoding($str, 'UTF-8', $data_codepage);
607
-
608
- $encoding = mb_detect_encoding($str);
609
-
610
- if ($encoding)
611
- return mb_convert_encoding($str, 'UTF-8', $encoding);
612
- }
613
- return $str;
614
- }
615
-
616
- /**
617
- * Function convert string from UTF8
618
- * param string
619
- * param string
620
- * @return string
621
- */
622
- function stringFromUTF8($str, $data_codepage = null)
623
- {
624
- if (preg_match('u', $str) && function_exists('mb_convert_encoding') && $data_codepage !== null)
625
- return mb_convert_encoding($str, $data_codepage, 'UTF-8');
626
- return $str;
627
- }
628
- }
5
  */
6
  class Cleantalk {
7
 
 
 
 
 
 
 
8
  /**
9
  * Maximum data size in bytes
10
  * @var int
186
  switch ($method) {
187
  case 'check_message':
188
  // Convert strings to UTF8
189
+ $request->message = CleantalkHelper::arrayToUTF8( $request->message, $this->data_codepage);
190
+ $request->example = CleantalkHelper::arrayToUTF8( $request->example, $this->data_codepage);
191
+ $request->sender_email = CleantalkHelper::stringToUTF8($request->sender_email, $this->data_codepage);
192
+ $request->sender_nickname = CleantalkHelper::stringToUTF8($request->sender_nickname, $this->data_codepage);
193
 
194
  // $request->message = $this->compressData($request->message);
195
  // $request->example = $this->compressData($request->example);
197
 
198
  case 'check_newuser':
199
  // Convert strings to UTF8
200
+ $request->sender_email = CleantalkHelper::stringToUTF8($request->sender_email, $this->data_codepage);
201
+ $request->sender_nickname = CleantalkHelper::stringToUTF8($request->sender_nickname, $this->data_codepage);
202
  break;
203
 
204
  case 'send_feedback':
213
  // Removing non UTF8 characters from request, because non UTF8 or malformed characters break json_encode().
214
  foreach ($request as $param => $value) {
215
  if(is_array($request->$param))
216
+ $request->$param = CleantalkHelper::removeNonUTF8FromArray($value);
217
  if(is_string($request->$param) || is_int($request->$param))
218
+ $request->$param = CleantalkHelper::removeNonUTF8FromString($value);
219
  }
220
 
221
  $request->message = unserialize($request->message);
537
 
538
  return $status;
539
  }
540
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/CleantalkAPI.php ADDED
@@ -0,0 +1,501 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CleantalkAPI
4
+ {
5
+ const URL = 'https://api.cleantalk.org';
6
+
7
+ /**
8
+ * Wrapper for sfw_logs API method
9
+ * @param integer connect timeout
10
+ * @return type
11
+ * returns mixed STRING || array('error' => true, 'error_string' => STRING)
12
+ */
13
+ static public function method__sfw_logs($api_key, $data, $do_check = true){
14
+
15
+ $request = array(
16
+ 'auth_key' => $api_key,
17
+ 'method_name' => 'sfw_logs',
18
+ 'data' => json_encode($data),
19
+ 'rows' => count($data),
20
+ 'timestamp' => time()
21
+ );
22
+
23
+ $result = self::send_request($request);
24
+ $result = $do_check ? self::check_response($result, 'sfw_logs') : $result;
25
+
26
+ return $result;
27
+ }
28
+
29
+ /**
30
+ * Function gets spam report
31
+ *
32
+ * @param string website host
33
+ * @param integer report days
34
+ * @return type
35
+ */
36
+ static public function method__spam_check_cms($api_key, $data, $date = null, $do_check = true)
37
+ {
38
+ $request=Array(
39
+ 'method_name' => 'spam_check_cms',
40
+ 'auth_key' => $api_key,
41
+ 'data' => is_array($data) ? implode(',',$data) : $data,
42
+ );
43
+
44
+ if($date) $request['date'] = $date;
45
+
46
+ $result = self::send_request($request);
47
+ $result = $do_check ? self::check_response($result, 'spam_check_cms') : $result;
48
+
49
+ return $result;
50
+ }
51
+
52
+ /*
53
+ * Wrapper for 2s_blacklists_db API method
54
+ *
55
+ * returns mixed STRING || array('error' => true, 'error_string' => STRING)
56
+ */
57
+ static public function method__get_2s_blacklists_db($api_key, $do_check = true){
58
+
59
+ $request = array(
60
+ 'method_name' => '2s_blacklists_db',
61
+ 'auth_key' => $api_key,
62
+ );
63
+
64
+ $result = self::send_request($request);
65
+ $result = $do_check ? self::check_response($result, '2s_blacklists_db') : $result;
66
+
67
+ return $result;
68
+ }
69
+
70
+ /**
71
+ * Function gets access key automatically
72
+ *
73
+ * @param string website admin email
74
+ * @param string website host
75
+ * @param string website platform
76
+ * @return type
77
+ */
78
+ static public function method__get_api_key($email, $host, $platform, $timezone = null, $language = null, $ip = null, $white_label = 0, $hoster_api_key = '', $do_check = true)
79
+ {
80
+ $request = array(
81
+ 'method_name' => 'get_api_key',
82
+ 'product_name' => 'antispam',
83
+ 'email' => $email,
84
+ 'website' => $host,
85
+ 'platform' => $platform,
86
+ 'timezone' => $timezone,
87
+ 'http_accept_language' => $language,
88
+ 'user_ip' => $ip,
89
+ 'hoster_whitelabel' => $white_label,
90
+ 'hoster_api_key' => $hoster_api_key,
91
+ );
92
+
93
+ $result = self::send_request($request);
94
+ $result = $do_check ? self::check_response($result, 'get_api_key') : $result;
95
+
96
+ return $result;
97
+ }
98
+
99
+ /**
100
+ * Function gets spam report
101
+ *
102
+ * @param string website host
103
+ * @param integer report days
104
+ * @return type
105
+ */
106
+ static public function method__get_antispam_report($host, $period = 1)
107
+ {
108
+ $request=Array(
109
+ 'method_name' => 'get_antispam_report',
110
+ 'hostname' => $host,
111
+ 'period' => $period
112
+ );
113
+
114
+ $result = self::send_request($request);
115
+ $result = $do_check ? self::check_response($result, 'get_antispam_report') : $result;
116
+
117
+ return $result;
118
+ }
119
+
120
+ /**
121
+ * Function gets spam statistics
122
+ *
123
+ * @param string website host
124
+ * @param integer report days
125
+ * @return type
126
+ */
127
+ static public function method__get_antispam_report_breif($api_key, $do_check = true)
128
+ {
129
+ $request = array(
130
+ 'method_name' => 'get_antispam_report_breif',
131
+ 'auth_key' => $api_key,
132
+ );
133
+
134
+ $result = self::send_request($request);
135
+ $result = $do_check ? self::check_response($result, 'get_antispam_report_breif') : $result;
136
+
137
+ return $result;
138
+ }
139
+
140
+ /**
141
+ * Function gets information about renew notice
142
+ *
143
+ * @param string api_key
144
+ * @return type
145
+ */
146
+ static public function method__notice_validate_key($api_key, $path_to_cms, $do_check = true)
147
+ {
148
+ $request = array(
149
+ 'method_name' => 'notice_validate_key',
150
+ 'auth_key' => $api_key,
151
+ 'path_to_cms' => $path_to_cms
152
+ );
153
+
154
+ $result = self::send_request($request);
155
+ $result = $do_check ? self::check_response($result, 'notice_validate_key') : $result;
156
+
157
+ return $result;
158
+ }
159
+
160
+ /**
161
+ * Function gets information about renew notice
162
+ *
163
+ * @param string api_key
164
+ * @return type
165
+ */
166
+ static public function method__notice_paid_till($api_key, $do_check = true)
167
+ {
168
+ $request = array(
169
+ 'method_name' => 'notice_paid_till',
170
+ 'auth_key' => $api_key
171
+ );
172
+
173
+ $result = self::send_request($request);
174
+ $result = $do_check ? self::check_response($result, 'notice_paid_till') : $result;
175
+
176
+ return $result;
177
+ }
178
+
179
+ static public function method__security_logs($api_key, $data, $do_check = true)
180
+ {
181
+ $request = array(
182
+ 'auth_key' => $api_key,
183
+ 'method_name' => 'security_logs',
184
+ 'timestamp' => current_time('timestamp'),
185
+ 'data' => json_encode($data),
186
+ 'rows' => count($data),
187
+ );
188
+
189
+ $result = self::send_request($request);
190
+ $result = $do_check ? self::check_response($result) : $result;
191
+
192
+ return $result;
193
+ }
194
+
195
+ static public function method__security_logs__sendFWData($api_key, $data, $do_check = true){
196
+
197
+ $request = array(
198
+ 'auth_key' => $api_key,
199
+ 'method_name' => 'security_logs',
200
+ 'timestamp' => current_time('timestamp'),
201
+ 'data_fw' => json_encode($data),
202
+ 'rows_fw' => count($data),
203
+ );
204
+
205
+ $result = self::send_request($request);
206
+ $result = $do_check ? self::check_response($result) : $result;
207
+
208
+ return $result;
209
+ }
210
+
211
+ static public function method__security_logs__feedback($api_key, $do_check = true)
212
+ {
213
+ $request = array(
214
+ 'auth_key' => $api_key,
215
+ 'method_name' => 'security_logs',
216
+ 'data' => '0',
217
+ );
218
+
219
+ $result = self::send_request($request);
220
+ $result = $do_check ? self::check_response($result) : $result;
221
+
222
+ return $result;
223
+ }
224
+
225
+ static public function method__security_firewall_data($api_key, $do_check = true){
226
+
227
+ $request = array(
228
+ 'auth_key' => $api_key,
229
+ 'method_name' => 'security_firewall_data',
230
+ );
231
+
232
+ $result = self::send_request($request);
233
+ $result = $do_check ? self::check_response($result) : $result;
234
+
235
+ return $result;
236
+ }
237
+
238
+ static public function method__security_firewall_data_file($api_key, $do_check = true){
239
+
240
+ $request = array(
241
+ 'auth_key' => $api_key,
242
+ 'method_name' => 'security_firewall_data_file',
243
+ );
244
+
245
+ $result = self::send_request($request);
246
+ $result = $do_check ? self::check_response($result) : $result;
247
+
248
+ return $result;
249
+ }
250
+
251
+ static public function method__security_linksscan_logs($api_key, $scan_time, $scan_result, $links_total, $links_list, $do_check = true)
252
+ {
253
+ $request = array(
254
+ 'auth_key' => $api_key,
255
+ 'method_name' => 'security_linksscan_logs',
256
+ 'started' => $scan_time,
257
+ 'result' => $scan_result,
258
+ 'total_links_found' => $links_total,
259
+ 'links_list' => $links_list,
260
+ );
261
+
262
+ $result = self::send_request($request);
263
+ $result = $do_check ? self::check_response($result) : $result;
264
+
265
+ return $result;
266
+ }
267
+
268
+ static public function method__security_mscan_logs($api_key, $service_id, $scan_time, $scan_result, $scanned_total, $modified, $unknown, $do_check = true)
269
+ {
270
+ $request = array(
271
+ 'method_name' => 'security_mscan_logs',
272
+ 'auth_key' => $api_key,
273
+ 'service_id' => $service_id,
274
+ 'started' => $scan_time,
275
+ 'result' => $scan_result,
276
+ 'total_core_files' => $scanned_total,
277
+ );
278
+
279
+ if(!empty($modified)){
280
+ $request['failed_files'] = json_encode($modified);
281
+ $request['failed_files_rows'] = count($modified);
282
+ }
283
+ if(!empty($unknown)){
284
+ $request['unknown_files'] = json_encode($unknown);
285
+ $request['unknown_files_rows'] = count($unknown);
286
+ }
287
+
288
+ $result = self::send_request($request);
289
+ $result = $do_check ? self::check_response($result) : $result;
290
+
291
+ return $result;
292
+ }
293
+
294
+ static public function method__security_mscan_files($api_key, $file_path, $file, $file_md5, $weak_spots, $do_check = true)
295
+ {
296
+ $request = array(
297
+ 'method_name' => 'security_mscan_files',
298
+ 'auth_key' => $api_key,
299
+ 'path_to_sfile' => $file_path,
300
+ 'attached_sfile' => $file,
301
+ 'md5sum_sfile' => $file_md5,
302
+ 'dangerous_code' => $weak_spots,
303
+ );
304
+
305
+ $result = self::send_request($request);
306
+ $result = $do_check ? self::check_response($result) : $result;
307
+
308
+ return $result;
309
+ }
310
+
311
+ /**
312
+ * Function gets spam domains report
313
+ *
314
+ * @param string api key
315
+ * @param integer report days
316
+ * @return type
317
+ */
318
+ static public function method__backlinks_check_cms($api_key, $data, $date = null, $do_check = true)
319
+ {
320
+ $request = array(
321
+ 'method_name' => 'backlinks_check_cms',
322
+ 'auth_key' => $api_key,
323
+ 'data' => is_array($data) ? implode(',',$data) : $data,
324
+ );
325
+
326
+ if($date) $request['date'] = $date;
327
+
328
+ $result = self::send_request($request);
329
+ $result = $do_check ? self::check_response($result, 'backlinks_check_cms') : $result;
330
+
331
+ return $result;
332
+ }
333
+
334
+ /**
335
+ * Function sends raw request to API server
336
+ *
337
+ * @param string url of API server
338
+ * @param array data to send
339
+ * @param boolean is data have to be JSON encoded or not
340
+ * @param integer connect timeout
341
+ * @return type
342
+ */
343
+ static public function send_request($data, $url = self::URL, $timeout = 5, $ssl = false)
344
+ {
345
+ // Possibility to switch API url
346
+ $url = defined('CLEANTALK_API_URL') ? CLEANTALK_API_URL : $url;
347
+
348
+ // Adding agent version to data
349
+ if(defined('CLEANTALK_AGENT'))
350
+ $data['agent'] = CLEANTALK_AGENT;
351
+
352
+ // Make URL string
353
+ $data_string = http_build_query($data);
354
+ $data_string = str_replace("&amp;", "&", $data_string);
355
+
356
+ // For debug purposes
357
+ global $apbct_debug;
358
+ $apbct_debug['sent_data'] = $data;
359
+ $apbct_debug['request_string'] = $data_string;
360
+
361
+ if (function_exists('curl_init')){
362
+
363
+ $ch = curl_init();
364
+
365
+ // Set diff options
366
+ curl_setopt($ch, CURLOPT_URL, $url);
367
+ curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
368
+ curl_setopt($ch, CURLOPT_POST, true);
369
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
370
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
371
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
372
+
373
+ // Switch on/off SSL
374
+ if ($ssl === true) {
375
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
376
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
377
+ curl_setopt($ch, CURLOPT_CAINFO, APBCT_CASERT_PATH);
378
+ }else{
379
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
380
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
381
+ }
382
+
383
+ // Make a request
384
+ $result = curl_exec($ch);
385
+ $errors = curl_error($ch);
386
+ curl_close($ch);
387
+
388
+ // Get cURL error if result failed
389
+ if($result === false){
390
+
391
+ // And retry with SSL enabled
392
+ if($ssl === false)
393
+ return self::send_request($data, $url, $timeout, true);
394
+
395
+ }
396
+
397
+ }else
398
+ $errors = 'CURL_NOT_INSTALLED';
399
+
400
+ // Trying to use file_get_contents() to make a API call
401
+ if(!empty($errors) && ini_get('allow_url_fopen')){
402
+
403
+ $opts = array(
404
+ 'http'=>array(
405
+ 'method' => "POST",
406
+ 'timeout' => $timeout,
407
+ 'content' => $data_string,
408
+ )
409
+ );
410
+ $context = stream_context_create($opts);
411
+ $result = file_get_contents($url, 0, $context);
412
+
413
+ }else
414
+ $errors .= '_AND_ALLOW_URL_FOPEN_IS_DISABLED';
415
+
416
+ if(empty($result) && !empty($errors))
417
+ return json_encode(array('error' => true, 'error_string' => $errors));
418
+
419
+ return $result;
420
+ }
421
+
422
+ /**
423
+ * Function checks server response
424
+ *
425
+ * @param string result
426
+ * @param string request_method
427
+ * @return mixed (array || array('error' => true))
428
+ */
429
+ static public function check_response($result, $method_name = null)
430
+ {
431
+
432
+ $out = array();
433
+
434
+ // Errors handling
435
+
436
+ // Bad connection
437
+ if(empty($result)){
438
+ $out = array(
439
+ 'error' => true,
440
+ 'error_string' => 'CONNECTION_ERROR'
441
+ );
442
+ }
443
+
444
+ // JSON decode errors
445
+ $result = json_decode($result, true);
446
+ if(empty($result)){
447
+ $out = array(
448
+ 'error' => true,
449
+ 'error_string' => 'JSON_DECODE_ERROR'
450
+ );
451
+ }
452
+
453
+ // cURL error
454
+ if(!empty($result['error'])){
455
+ $out = array(
456
+ 'error' => true,
457
+ 'error_string' => 'CONNECTION_ERROR: ' . $result['error_string'],
458
+ );
459
+ }
460
+
461
+ // Server errors
462
+ if($result && (isset($result['error_no']) || isset($result['error_message']))){
463
+ $out = array(
464
+ 'error' => true,
465
+ 'error_string' => "SERVER_ERROR NO: {$result['error_no']} MSG: {$result['error_message']}",
466
+ 'error_no' => $result['error_no'],
467
+ 'error_message' => $result['error_message']
468
+ );
469
+ }
470
+
471
+ // Pathces for different methods
472
+ if(empty($out['error'])){
473
+
474
+ // mehod_name = notice_validate_key
475
+ if($method_name == 'notice_validate_key' && isset($result['valid']))
476
+ $out = $result;
477
+
478
+ // Other methods
479
+ if(isset($result['data']) && is_array($result['data'])){
480
+ $out = $result['data'];
481
+ }
482
+ }
483
+
484
+ // mehod_name = get_antispam_report_breif
485
+ if($method_name == 'get_antispam_report_breif'){
486
+
487
+ if(empty($out['error']))
488
+ $result = $result['data'];
489
+
490
+ for( $tmp = array(), $i = 0; $i < 7; $i++ )
491
+ $tmp[ date( 'Y-m-d', time() - 86400 * 7 + 86400 * $i ) ] = 0;
492
+
493
+ $result['spam_stat'] = array_merge( $tmp, isset($result['spam_stat']) ? $result['spam_stat'] : array() );
494
+ $result['top5_spam_ip'] = isset($result['top5_spam_ip']) ? $result['top5_spam_ip'] : array();
495
+ $out = array_merge($result, $out);
496
+ }
497
+
498
+ return $out;
499
+
500
+ }
501
+ }
lib/CleantalkDB_Wordpress.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * CleanTalk Wordpress Data Base class
5
+ * Compatible only with Wordpress.
6
+ * Version 1.0
7
+ * author Cleantalk team (welcome@cleantalk.org)
8
+ * copyright (C) 2014 CleanTalk team (http://cleantalk.org)
9
+ * license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
10
+ * see https://github.com/CleanTalk/php-antispam
11
+ */
12
+
13
+ class CleantalkDB_Wordpress
14
+ {
15
+
16
+ public $table_prefix;
17
+ public $result = array();
18
+
19
+ private $db;
20
+ private $query;
21
+ private $db_result;
22
+
23
+ public function __construct()
24
+ {
25
+ global $wpdb;
26
+ $this->db = $wpdb;
27
+ $this->table_prefix = $wpdb->base_prefix;
28
+ }
29
+
30
+ public function query($query, $straight_query = false)
31
+ {
32
+ if($straight_query)
33
+ $this->db_result = $this->db->query($query);
34
+ else
35
+ $this->query = $query;
36
+
37
+ return $this;
38
+ }
39
+
40
+ public function fetch()
41
+ {
42
+ $this->result = $this->db->get_row($this->query, ARRAY_A);
43
+ }
44
+
45
+ public function fetch_all()
46
+ {
47
+ $this->result = $this->db->get_results($this->query, ARRAY_A);
48
+ }
49
+ }
lib/CleantalkHelper.php CHANGED
@@ -2,9 +2,7 @@
2
 
3
  class CleantalkHelper
4
  {
5
- const URL = 'https://api.cleantalk.org';
6
-
7
- public static $cdn_pool = array(
8
  'cloud_flare' => array(
9
  'ipv4' => array(
10
  '103.21.244.0/22',
@@ -36,7 +34,7 @@ class CleantalkHelper
36
  ),
37
  );
38
 
39
- public static $private_networks = array(
40
  '10.0.0.0/8',
41
  '100.64.0.0/10',
42
  '172.16.0.0/12',
@@ -166,399 +164,6 @@ class CleantalkHelper
166
  return false; // Unknown
167
  }
168
 
169
- /**
170
- * Wrapper for sfw_logs API method
171
- * @param integer connect timeout
172
- * @return type
173
- * returns mixed STRING || array('error' => true, 'error_string' => STRING)
174
- */
175
- static public function api_method__sfw_logs($api_key, $data, $do_check = true){
176
-
177
- $request = array(
178
- 'auth_key' => $api_key,
179
- 'method_name' => 'sfw_logs',
180
- 'data' => json_encode($data),
181
- 'rows' => count($data),
182
- 'timestamp' => time()
183
- );
184
- $result = self::api_send_request($request);
185
- $result = $do_check ? self::api_check_response($result, 'sfw_logs') : $result;
186
-
187
- return $result;
188
- }
189
-
190
- /*
191
- * Wrapper for 2s_blacklists_db API method
192
- *
193
- * returns mixed STRING || array('error' => true, 'error_string' => STRING)
194
- */
195
- static public function api_method__get_2s_blacklists_db($api_key, $do_check = true){
196
-
197
- $request = array(
198
- 'agent' => APBCT_AGENT,
199
- 'method_name' => '2s_blacklists_db',
200
- 'auth_key' => $api_key,
201
- );
202
-
203
- $result = self::api_send_request($request);
204
- $result = $do_check ? self::api_check_response($result, '2s_blacklists_db') : $result;
205
-
206
- return $result;
207
- }
208
-
209
- /**
210
- * Function gets access key automatically
211
- *
212
- * @param string website admin email
213
- * @param string website host
214
- * @param string website platform
215
- * @return type
216
- */
217
- static public function api_method__get_api_key($email, $host, $platform, $timezone = null, $language = null, $ip = null, $do_check = true)
218
- {
219
- $request = array(
220
- 'method_name' => 'get_api_key',
221
- 'product_name' => 'antispam',
222
- 'agent' => APBCT_AGENT,
223
- 'email' => $email,
224
- 'website' => $host,
225
- 'platform' => $platform,
226
- 'timezone' => $timezone,
227
- 'http_accept_language' => !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : null,
228
- 'user_ip' => $ip ? $ip : self::ip_get(array('real'), false),
229
- );
230
-
231
- $result = self::api_send_request($request);
232
- $result = $do_check ? self::api_check_response($result, 'get_api_key') : $result;
233
-
234
- return $result;
235
- }
236
-
237
- /**
238
- * Function gets information about renew notice
239
- *
240
- * @param string api_key
241
- * @return type
242
- */
243
- static public function api_method__notice_validate_key($api_key, $path_to_cms, $do_check = true)
244
- {
245
- $request = array(
246
- 'agent' => APBCT_AGENT,
247
- 'method_name' => 'notice_validate_key',
248
- 'auth_key' => $api_key,
249
- 'path_to_cms' => $path_to_cms
250
- );
251
-
252
- $result = self::api_send_request($request);
253
- $result = $do_check ? self::api_check_response($result, 'notice_validate_key') : $result;
254
-
255
- return $result;
256
- }
257
-
258
- /**
259
- * Function gets information about renew notice
260
- *
261
- * @param string api_key
262
- * @return type
263
- */
264
- static public function api_method__notice_paid_till($api_key, $do_check = true)
265
- {
266
- $request = array(
267
- 'agent' => APBCT_AGENT,
268
- 'method_name' => 'notice_paid_till',
269
- 'auth_key' => $api_key
270
- );
271
-
272
- $result = self::api_send_request($request);
273
- $result = $do_check ? self::api_check_response($result, 'notice_paid_till') : $result;
274
-
275
- return $result;
276
- }
277
-
278
- /**
279
- * Function gets spam report
280
- *
281
- * @param string website host
282
- * @param integer report days
283
- * @return type
284
- */
285
- static public function api_method__get_antispam_report($host, $period = 1)
286
- {
287
- $request=Array(
288
- 'agent' => APBCT_AGENT,
289
- 'method_name' => 'get_antispam_report',
290
- 'hostname' => $host,
291
- 'period' => $period
292
- );
293
-
294
- $result = self::api_send_request($request);
295
- // $result = $do_check ? self::api_check_response($result, 'get_antispam_report') : $result;
296
-
297
- return $result;
298
- }
299
-
300
- /**
301
- * Function gets spam statistics
302
- *
303
- * @param string website host
304
- * @param integer report days
305
- * @return type
306
- */
307
- static public function api_method__get_antispam_report_breif($api_key, $do_check = true)
308
- {
309
-
310
- $request = array(
311
- 'agent' => APBCT_AGENT,
312
- 'method_name' => 'get_antispam_report_breif',
313
- 'auth_key' => $api_key,
314
- );
315
-
316
- $result = self::api_send_request($request);
317
- $result = $do_check ? self::api_check_response($result, 'get_antispam_report_breif') : $result;
318
-
319
- $tmp = array();
320
- for( $i = 0; $i < 7; $i++ )
321
- $tmp[ date( 'Y-m-d', time() - 86400 * 7 + 86400 * $i ) ] = 0;
322
-
323
- $result['spam_stat'] = array_merge( $tmp, isset($result['spam_stat']) ? $result['spam_stat'] : array() );
324
- $result['top5_spam_ip'] = isset($result['top5_spam_ip']) ? $result['top5_spam_ip'] : array();
325
-
326
- return $result;
327
- }
328
-
329
- /**
330
- * Function gets spam report
331
- *
332
- * @param string website host
333
- * @param integer report days
334
- * @return type
335
- */
336
- static public function api_method__spam_check_cms($api_key, $data, $date = null, $do_check = true)
337
- {
338
- $request=Array(
339
- 'agent' => APBCT_AGENT,
340
- 'method_name' => 'spam_check_cms',
341
- 'auth_key' => $api_key,
342
- 'data' => is_array($data) ? implode(',',$data) : $data,
343
- );
344
-
345
- if($date) $request['date'] = $date;
346
-
347
- $result = self::api_send_request($request);
348
- $result = $do_check ? self::api_check_response($result, 'spam_check_cms') : $result;
349
-
350
- return $result;
351
- }
352
-
353
- /**
354
- * Function sends raw request to API server
355
- *
356
- * @param string url of API server
357
- * @param array data to send
358
- * @param boolean is data have to be JSON encoded or not
359
- * @param integer connect timeout
360
- * @return type
361
- */
362
- static public function api_send_request($data, $url = self::URL, $isJSON = false, $timeout=3, $ssl = false)
363
- {
364
-
365
- $result = null;
366
- $curl_error = false;
367
-
368
- $original_data = $data;
369
-
370
- if(!$isJSON){
371
- $data = http_build_query($data);
372
- $data = str_replace("&amp;", "&", $data);
373
- }else{
374
- $data = json_encode($data);
375
- }
376
-
377
- if (function_exists('curl_init') && function_exists('json_decode')){
378
-
379
- $ch = curl_init();
380
- curl_setopt($ch, CURLOPT_URL, $url);
381
- curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
382
- curl_setopt($ch, CURLOPT_POST, true);
383
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
384
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
385
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
386
-
387
- if ($ssl === true) {
388
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
389
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
390
- curl_setopt($ch, CURLOPT_CAINFO, APBCT_CASERT_PATH);
391
- }else{
392
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
393
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
394
- }
395
-
396
- $result = curl_exec($ch);
397
-
398
- if($result === false){
399
- if($ssl === false){
400
- return self::api_send_request($original_data, $url, $isJSON, $timeout, true);
401
- }
402
- $curl_error = curl_error($ch);
403
- }
404
-
405
- curl_close($ch);
406
-
407
- }else{
408
- $curl_error = 'CURL_NOT_INSTALLED';
409
- }
410
-
411
- if($curl_error){
412
-
413
- $opts = array(
414
- 'http'=>array(
415
- 'method' => "POST",
416
- 'timeout' => $timeout,
417
- 'content' => $data,
418
- )
419
- );
420
- $context = stream_context_create($opts);
421
- $result = @file_get_contents($url, 0, $context);
422
- }
423
-
424
- if(!$result && $curl_error)
425
- return json_encode(array('error' => true, 'error_string' => $curl_error));
426
-
427
- return $result;
428
- }
429
-
430
- /**
431
- * Function checks server response
432
- *
433
- * @param string result
434
- * @param string request_method
435
- * @return mixed (array || array('error' => true))
436
- */
437
- static public function api_check_response($result, $method_name = null)
438
- {
439
-
440
- // Errors handling
441
-
442
- // Bad connection
443
- if(empty($result)){
444
- return array(
445
- 'error' => true,
446
- 'error_string' => 'CONNECTION_ERROR'
447
- );
448
- }
449
-
450
- // JSON decode errors
451
- $result = json_decode($result, true);
452
- if(empty($result)){
453
- return array(
454
- 'error' => true,
455
- 'error_string' => 'JSON_DECODE_ERROR'
456
- );
457
- }
458
-
459
- // cURL error
460
- if(!empty($result['error'])){
461
- return array(
462
- 'error' => true,
463
- 'error_string' => 'CONNECTION_ERROR: ' . $result['error_string'],
464
- );
465
- }
466
-
467
- // Server errors
468
- if($result && (isset($result['error_no']) || isset($result['error_message']))){
469
- return array(
470
- 'error' => true,
471
- 'error_string' => "SERVER_ERROR NO: {$result['error_no']} MSG: {$result['error_message']}",
472
- 'error_no' => $result['error_no'],
473
- 'error_message' => $result['error_message']
474
- );
475
- }
476
-
477
- // Pathces for different methods
478
-
479
- // mehod_name = notice_validate_key
480
- if($method_name == 'notice_validate_key' && isset($result['valid'])){
481
- return $result;
482
- }
483
-
484
- // Other methods
485
- if(isset($result['data']) && is_array($result['data'])){
486
- return $result['data'];
487
- }
488
- }
489
-
490
- /**
491
- * Prepares an adds an error to the plugin's data
492
- *
493
- * @param string type
494
- * @param mixed array || string
495
- * @returns null
496
- */
497
- static public function addError($type, $error, $set_time = true)
498
- {
499
- global $apbct;
500
-
501
- $error_string = is_array($error)
502
- ? $error['error_string']
503
- : $error;
504
-
505
- // Exceptions
506
- if( ($type == 'send_logs' && $error_string == 'NO_LOGS_TO_SEND') ||
507
- ($type == 'send_firewall_logs' && $error_string == 'NO_LOGS_TO_SEND')
508
- )
509
- return;
510
-
511
- if($set_time == true)
512
- $apbct->data['errors'][$type]['error_time'] = current_time('timestamp');
513
- $apbct->data['errors'][$type]['error_string'] = $error_string;
514
- $apbct->save('data');
515
- }
516
-
517
- /**
518
- * Deletes an error from the plugin's data
519
- *
520
- * @param mixed (array of strings || string 'elem1 elem2...' || string 'elem') type
521
- * @param delay saving
522
- * @returns null
523
- */
524
- static public function deleteError($type, $save_flag = false)
525
- {
526
- global $apbct;
527
-
528
- $before = empty($apbct->data['errors']) ? 0 : count($apbct->data['errors']);
529
-
530
- if(is_string($type))
531
- $type = explode(' ', $type);
532
-
533
- foreach($type as $val){
534
- if(isset($apbct->data['errors'][$val])){
535
- unset($apbct->data['errors'][$val]);
536
- }
537
- }
538
-
539
- $after = empty($apbct->data['errors']) ? 0 : count($apbct->data['errors']);
540
- // Save if flag is set and there are changes
541
- if($save_flag && $before != $after)
542
- $apbct->save('data');
543
- }
544
-
545
- /**
546
- * Deletes all errors from the plugin's data
547
- *
548
- * @param delay saving
549
- * @returns null
550
- */
551
- static public function deleteAllErrors($save_flag = false)
552
- {
553
- global $apbct;
554
-
555
- if(isset($apbct->data['errors']))
556
- unset($apbct->data['errors']);
557
-
558
- if($save_flag)
559
- $apbct->save('data');
560
- }
561
-
562
  /**
563
  * Function sends raw http request
564
  *
@@ -584,7 +189,7 @@ class CleantalkHelper
584
  CURLOPT_RETURNTRANSFER => 1,
585
  CURLOPT_CONNECTTIMEOUT_MS => 3000,
586
  CURLOPT_FORBID_REUSE => true,
587
- CURLOPT_USERAGENT => 'Cleantalk Wordpress Antispam '.APBCT_AGENT,
588
  CURLOPT_POST => true,
589
  CURLOPT_POSTFIELDS => str_replace("&amp;", "&", http_build_query($data)),
590
  CURLOPT_SSL_VERIFYPEER => false,
@@ -655,29 +260,95 @@ class CleantalkHelper
655
  return $out;
656
  }
657
 
658
- //* Write $message to the plugin's debug option
659
- static public function log($message = 'empty', $func = null, $params = array())
 
 
 
 
660
  {
661
- $debug = get_option( APBCT_DEBUG );
662
-
663
- $function = $func ? $func : '';
664
- $cron = in_array('cron', $params) ? true : false;
665
- $data = in_array('data', $params) ? true : false;
666
- $settings = in_array('settings', $params) ? true : false;
667
-
668
- if(is_array($message) or is_object($message))
669
- $message = print_r($message, true);
670
 
671
- if($message) $debug[date("H:i:s", microtime(true))."_ACTION_".strval(current_action())."_FUNCTION_".strval($func)] = $message;
672
- if($cron) $debug[date("H:i:s", microtime(true))."_ACTION_".strval(current_action())."_FUNCTION_".strval($func).'_cron'] = $apbct->cron;
673
- if($data) $debug[date("H:i:s", microtime(true))."_ACTION_".strval(current_action())."_FUNCTION_".strval($func).'_data'] = $apbct->data;
674
- if($settings) $debug[date("H:i:s", microtime(true))."_ACTION_".strval(current_action())."_FUNCTION_".strval($func).'_settings'] = $apbct->settings;
 
 
 
 
 
 
 
 
 
 
 
 
675
 
676
- update_option(APBCT_DEBUG, $debug);
 
 
 
 
 
 
 
 
 
677
  }
678
 
679
- static public function is_json($string)
 
 
 
 
 
 
680
  {
681
- return is_string($string) && is_array(json_decode($string, true)) ? true : false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
682
  }
683
  }
2
 
3
  class CleantalkHelper
4
  {
5
+ private static $cdn_pool = array(
 
 
6
  'cloud_flare' => array(
7
  'ipv4' => array(
8
  '103.21.244.0/22',
34
  ),
35
  );
36
 
37
+ private static $private_networks = array(
38
  '10.0.0.0/8',
39
  '100.64.0.0/10',
40
  '172.16.0.0/12',
164
  return false; // Unknown
165
  }
166
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  /**
168
  * Function sends raw http request
169
  *
189
  CURLOPT_RETURNTRANSFER => 1,
190
  CURLOPT_CONNECTTIMEOUT_MS => 3000,
191
  CURLOPT_FORBID_REUSE => true,
192
+ CURLOPT_USERAGENT => 'Cleantalk Antispam ' . (defined('CLEANTALK_AGENT') ? CLEANTALK_AGENT : 'UNKNOWN_AGENT'),
193
  CURLOPT_POST => true,
194
  CURLOPT_POSTFIELDS => str_replace("&amp;", "&", http_build_query($data)),
195
  CURLOPT_SSL_VERIFYPEER => false,
260
  return $out;
261
  }
262
 
263
+ /**
264
+ * Checks if the string is JSON type
265
+ * @param string
266
+ * @return bool
267
+ */
268
+ static public function is_json($string)
269
  {
270
+ return is_string($string) && is_array(json_decode($string, true)) ? true : false;
271
+ }
 
 
 
 
 
 
 
272
 
273
+ /**
274
+ * Function removing non UTF8 characters from array||string
275
+ * @param mixed(array||string)
276
+ * @return mixed(array||string)
277
+ */
278
+ static public function removeNonUTF8FromArray($data)
279
+ {
280
+ foreach($data as $key => $val){
281
+ if(is_array($val)){
282
+ $data[$key] = self::removeNonUTF8FromArray($val);
283
+ }else{
284
+ $data[$key] = self::removeNonUTF8FromString($val);
285
+ }
286
+ }
287
+ return $data;
288
+ }
289
 
290
+ /**
291
+ * Function removing non UTF8 characters from array||string
292
+ * param mixed(array||string)
293
+ * return mixed(array||string)
294
+ */
295
+ public static function removeNonUTF8FromString($data)
296
+ {
297
+ if(!preg_match('//u', $data))
298
+ $data = 'Nulled. Not UTF8 encoded or malformed.';
299
+ return $data;
300
  }
301
 
302
+ /**
303
+ * Function convert array to UTF8 and removes non UTF8 characters
304
+ * param array
305
+ * param string
306
+ * @return array
307
+ */
308
+ public static function arrayToUTF8($array, $data_codepage = null)
309
  {
310
+ foreach($array as $key => $val){
311
+
312
+ if(is_array($val))
313
+ $array[$key] = self::arrayToUTF8($val, $data_codepage);
314
+ else
315
+ $array[$key] = self::stringToUTF8($val, $data_codepage);
316
+ }
317
+ return $array;
318
+ }
319
+
320
+ /**
321
+ * Function convert string to UTF8 and removes non UTF8 characters
322
+ * param string
323
+ * param string
324
+ * @return string
325
+ */
326
+ public static function stringToUTF8($str, $data_codepage = null)
327
+ {
328
+ if (!preg_match('//u', $str) && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')){
329
+
330
+ if ($data_codepage !== null)
331
+ return mb_convert_encoding($str, 'UTF-8', $data_codepage);
332
+
333
+ $encoding = mb_detect_encoding($str);
334
+
335
+ if ($encoding)
336
+ return mb_convert_encoding($str, 'UTF-8', $encoding);
337
+ }
338
+ return $str;
339
+ }
340
+
341
+ /**
342
+ * Function convert string from UTF8
343
+ * param string
344
+ * param string
345
+ * @return string
346
+ */
347
+ public static function stringFromUTF8($str, $data_codepage = null)
348
+ {
349
+ if(preg_match('u', $str) && function_exists('mb_convert_encoding') && $data_codepage !== null)
350
+ return mb_convert_encoding($str, $data_codepage, 'UTF-8');
351
+
352
+ return $str;
353
  }
354
  }
lib/CleantalkResponse.php CHANGED
@@ -151,5 +151,4 @@ class CleantalkResponse {
151
  $this->comment = '*** ' . $this->errstr . ' Antispam service cleantalk.org ***';
152
  }
153
  }
154
-
155
  }
151
  $this->comment = '*** ' . $this->errstr . ' Antispam service cleantalk.org ***';
152
  }
153
  }
 
154
  }
lib/CleantalkSFW.php CHANGED
@@ -1,200 +1,26 @@
1
  <?php
2
 
3
  /*
4
- * CleanTalk SpamFireWall base class
5
  * Compatible only with Wordpress.
6
- * Version 2.0-wp
7
  * author Cleantalk team (welcome@cleantalk.org)
8
  * copyright (C) 2014 CleanTalk team (http://cleantalk.org)
9
  * license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
10
  * see https://github.com/CleanTalk/php-antispam
11
  */
12
 
13
- class CleantalkSFW extends CleantalkHelper
14
  {
15
- public $ip = 0;
16
- public $ip_str = '';
17
- public $ip_array = Array();
18
- public $ip_str_array = Array();
19
- public $blocked_ip = '';
20
- public $passed_ip = '';
21
- public $result = false;
22
-
23
- //Database variables
24
- private $table_prefix;
25
- private $db;
26
- private $query;
27
- private $db_result;
28
- private $db_result_data = array();
29
 
30
  public function __construct()
31
  {
32
- global $wpdb;
33
- $this->table_prefix = $wpdb->base_prefix;
34
- $this->db = $wpdb;
35
- }
36
-
37
- public function unversal_query($query, $straight_query = false)
38
- {
39
- if($straight_query)
40
- $this->db_result = $this->db->query($query);
41
- else
42
- $this->query = $query;
43
- }
44
-
45
- public function unversal_fetch()
46
- {
47
- $this->db_result_data = $this->db->get_row($this->query, ARRAY_A);
48
- }
49
-
50
- public function unversal_fetch_all()
51
- {
52
- $this->db_result_data = $this->db->get_results($this->query, ARRAY_A);
53
- }
54
-
55
-
56
- /*
57
- * Getting arrays of IP (REMOTE_ADDR, X-Forwarded-For, X-Real-Ip, Cf_Connecting_Ip)
58
- * reutrns array('remote_addr' => 'val', ['x_forwarded_for' => 'val', ['x_real_ip' => 'val', ['cloud_flare' => 'val']]])
59
- */
60
- static public function ip_get($ips_input = array('real', 'remote_addr', 'x_forwarded_for', 'x_real_ip', 'cloud_flare'), $v4_only = true){
61
-
62
- $result = (array)parent::ip_get($ips_input, $v4_only);
63
-
64
- $result = !empty($result) ? $result : array();
65
-
66
- if(isset($_GET['sfw_test_ip'])){
67
- if(self::ip_validate($_GET['sfw_test_ip']) !== false)
68
- $result['sfw_test'] = $_GET['sfw_test_ip'];
69
- }
70
-
71
- return $result;
72
-
73
- }
74
-
75
- /*
76
- * Checks IP via Database
77
- */
78
- public function check_ip(){
79
-
80
- foreach($this->ip_array as $current_ip){
81
-
82
- $query = "SELECT
83
- COUNT(network) AS cnt
84
- FROM ".$this->table_prefix."cleantalk_sfw
85
- WHERE network = ".sprintf("%u", ip2long($current_ip))." & mask;";
86
- $this->unversal_query($query);
87
- $this->unversal_fetch();
88
-
89
- if($this->db_result_data['cnt']){
90
- $this->result = true;
91
- $this->blocked_ip = $current_ip;
92
- }else{
93
- $this->passed_ip = $current_ip;
94
- }
95
- }
96
- }
97
-
98
- /*
99
- * Add entry to SFW log
100
- */
101
- public function sfw_update_logs($ip, $result){
102
-
103
- if($ip === NULL || $result === NULL){
104
- return;
105
- }
106
-
107
- $blocked = ($result == 'blocked' ? ' + 1' : '');
108
- $time = time();
109
-
110
- $query = "INSERT INTO ".$this->table_prefix."cleantalk_sfw_logs
111
- SET
112
- ip = '$ip',
113
- all_entries = 1,
114
- blocked_entries = 1,
115
- entries_timestamp = '".intval($time)."'
116
- ON DUPLICATE KEY
117
- UPDATE
118
- all_entries = all_entries + 1,
119
- blocked_entries = blocked_entries".strval($blocked).",
120
- entries_timestamp = '".intval($time)."'";
121
 
122
- $this->unversal_query($query, true);
123
- }
124
-
125
- /*
126
- * Updates SFW local base
127
- *
128
- * return mixed true || array('error' => true, 'error_string' => STRING)
129
- */
130
- public function sfw_update($ct_key){
131
-
132
- $result = self::api_method__get_2s_blacklists_db($ct_key);
133
-
134
- if(empty($result['error'])){
135
-
136
- $this->unversal_query("DELETE FROM ".$this->table_prefix."cleantalk_sfw;", true);
137
-
138
- // Cast result to int
139
- foreach($result as $value){
140
- $value[0] = intval($value[0]);
141
- $value[1] = intval($value[1]);
142
- } unset($value);
143
-
144
- $query="INSERT INTO ".$this->table_prefix."cleantalk_sfw VALUES ";
145
- for($i=0, $arr_count = count($result); $i < $arr_count; $i++){
146
- if($i == count($result)-1){
147
- $query.="(".$result[$i][0].",".$result[$i][1].");";
148
- }else{
149
- $query.="(".$result[$i][0].",".$result[$i][1]."), ";
150
- }
151
- }
152
- $this->unversal_query($query, true);
153
-
154
- return true;
155
-
156
- }else{
157
- return $result;
158
- }
159
- }
160
-
161
- /*
162
- * Sends and wipe SFW log
163
- *
164
- * returns mixed true || array('error' => true, 'error_string' => STRING)
165
- */
166
- public function send_logs($ct_key){
167
-
168
- //Getting logs
169
- $query = "SELECT * FROM ".$this->table_prefix."cleantalk_sfw_logs";
170
- $this->unversal_query($query);
171
- $this->unversal_fetch_all();
172
-
173
- if(count($this->db_result_data)){
174
-
175
- //Compile logs
176
- $data = array();
177
- foreach($this->db_result_data as $key => $value){
178
- $data[] = array(trim($value['ip']), $value['all_entries'], $value['all_entries']-$value['blocked_entries'], $value['entries_timestamp']);
179
- }
180
- unset($key, $value);
181
-
182
- //Sending the request
183
- $result = self::api_method__sfw_logs($ct_key, $data);
184
-
185
- //Checking answer and deleting all lines from the table
186
- if(empty($result['error'])){
187
- if($result['rows'] == count($data)){
188
- $this->unversal_query("DELETE FROM ".$this->table_prefix."cleantalk_sfw_logs", true);
189
- return true;
190
- }
191
- }else{
192
- return $result;
193
- }
194
-
195
- }else{
196
- return array('error' => true, 'error_string' => 'NO_LOGS_TO_SEND');
197
- }
198
  }
199
 
200
  /*
@@ -218,6 +44,7 @@ class CleantalkSFW extends CleantalkHelper
218
  $sfw_die_page = str_replace('{SFW_DIE_CLICK_TO_PASS}', __('Please click below to pass protection,', 'cleantalk'), $sfw_die_page);
219
  $sfw_die_page = str_replace('{SFW_DIE_YOU_WILL_BE_REDIRECTED}', sprintf(__('Or you will be automatically redirected to the requested page after %d seconds.', 'cleantalk'), 1), $sfw_die_page);
220
  $sfw_die_page = str_replace('{CLEANTALK_TITLE}', __('Antispam by CleanTalk', 'cleantalk'), $sfw_die_page);
 
221
 
222
  // Service info
223
  $sfw_die_page = str_replace('{REMOTE_ADDRESS}', $this->blocked_ip, $sfw_die_page);
1
  <?php
2
 
3
  /*
4
+ * CleanTalk SpamFireWall Wordpress class
5
  * Compatible only with Wordpress.
6
+ * Version 3.0-wp
7
  * author Cleantalk team (welcome@cleantalk.org)
8
  * copyright (C) 2014 CleanTalk team (http://cleantalk.org)
9
  * license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
10
  * see https://github.com/CleanTalk/php-antispam
11
  */
12
 
13
+ class CleantalkSFW extends CleantalkSFW_Base
14
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  public function __construct()
17
  {
18
+ // Creating database object. Depends on current CMS.
19
+ $this->db = new CleantalkDB_Wordpress();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
+ // Use default tables if not specified
22
+ $this->data_table = defined('APBCT_TBL_FIREWALL_DATA') ? APBCT_TBL_FIREWALL_DATA : $this->db->table_prefix . 'cleantalk_sfw';
23
+ $this->log_table = defined('APBCT_TBL_FIREWALL_LOG') ? APBCT_TBL_FIREWALL_LOG : $this->db->table_prefix . 'cleantalk_sfw_logs';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  }
25
 
26
  /*
44
  $sfw_die_page = str_replace('{SFW_DIE_CLICK_TO_PASS}', __('Please click below to pass protection,', 'cleantalk'), $sfw_die_page);
45
  $sfw_die_page = str_replace('{SFW_DIE_YOU_WILL_BE_REDIRECTED}', sprintf(__('Or you will be automatically redirected to the requested page after %d seconds.', 'cleantalk'), 1), $sfw_die_page);
46
  $sfw_die_page = str_replace('{CLEANTALK_TITLE}', __('Antispam by CleanTalk', 'cleantalk'), $sfw_die_page);
47
+ $sfw_die_page = str_replace('{TEST_TITLE}', ($this->is_test ? __('This is the testing page for SpamFireWall', 'cleantalk') : ''), $sfw_die_page);
48
 
49
  // Service info
50
  $sfw_die_page = str_replace('{REMOTE_ADDRESS}', $this->blocked_ip, $sfw_die_page);
lib/CleantalkSFW_Base.php ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * CleanTalk SpamFireWall base class
5
+ * Compatible only with Wordpress.
6
+ * @depends on CleantalkHelper class
7
+ * @depends on CleantalkAPI class
8
+ * @depends on CleantalkDB class
9
+ * Version 3.0-base
10
+ * author Cleantalk team (welcome@cleantalk.org)
11
+ * copyright (C) 2014 CleanTalk team (http://cleantalk.org)
12
+ * license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
13
+ * see https://github.com/CleanTalk/php-antispam
14
+ */
15
+
16
+ class CleantalkSFW_Base
17
+ {
18
+ public $ip = 0;
19
+ public $ip_str = '';
20
+ public $ip_array = Array();
21
+ public $ip_str_array = Array();
22
+ public $blocked_ip = '';
23
+ public $passed_ip = '';
24
+ public $result = false;
25
+
26
+ public $is_test = false;
27
+
28
+ protected $data_table;
29
+ protected $log_table;
30
+
31
+ /**
32
+ * Creates connection to database
33
+ *
34
+ * @param array $params
35
+ * array((string)'hostname', (string)'db_name', (string)'charset', (array)PDO options)
36
+ * @param string $username
37
+ * @param string $password
38
+ *
39
+ * @return void
40
+ */
41
+ public function __construct($params, $username, $password)
42
+ {
43
+
44
+ // Creating database object
45
+ $this->db = new ClentalkDB();
46
+
47
+ // Use default tables if not specified
48
+ $this->data_table = $this->db->table_prefix . 'cleantalk_sfw';
49
+ $this->log_table = $this->db->table_prefix . 'cleantalk_sfw_logs';
50
+ }
51
+
52
+ /*
53
+ * Getting arrays of IP (REMOTE_ADDR, X-Forwarded-For, X-Real-Ip, Cf_Connecting_Ip)
54
+ * reutrns array('remote_addr' => 'val', ['x_forwarded_for' => 'val', ['x_real_ip' => 'val', ['cloud_flare' => 'val']]])
55
+ */
56
+ public function ip_get($ips_input = array('real', 'remote_addr', 'x_forwarded_for', 'x_real_ip', 'cloud_flare'), $v4_only = true){
57
+
58
+ $result = (array)CleantalkHelper::ip_get($ips_input, $v4_only);
59
+
60
+ $result = !empty($result) ? $result : array();
61
+
62
+ if(isset($_GET['sfw_test_ip'])){
63
+ if(CleantalkHelper::ip_validate($_GET['sfw_test_ip']) !== false){
64
+ $result['sfw_test'] = $_GET['sfw_test_ip'];
65
+ $this->is_test = true;
66
+ }
67
+ }
68
+
69
+ return $result;
70
+
71
+ }
72
+
73
+ /*
74
+ * Checks IP via Database
75
+ */
76
+ public function ip_check(){
77
+
78
+ foreach($this->ip_array as $current_ip){
79
+
80
+ $query = "SELECT
81
+ COUNT(network) AS cnt
82
+ FROM ".$this->data_table."
83
+ WHERE network = ".sprintf("%u", ip2long($current_ip))." & mask;";
84
+ $this->db->query($query)->fetch();
85
+ if($this->db->result['cnt']){
86
+ $this->result = true;
87
+ $this->blocked_ip = $current_ip;
88
+ }else{
89
+ $this->passed_ip = $current_ip;
90
+ }
91
+
92
+ }
93
+ }
94
+
95
+ /*
96
+ * Add entry to SFW log
97
+ */
98
+ public function logs__update($ip, $result){
99
+
100
+ if($ip === NULL || $result === NULL){
101
+ return;
102
+ }
103
+
104
+ $blocked = ($result == 'blocked' ? ' + 1' : '');
105
+ $time = time();
106
+
107
+ $query = "INSERT INTO ".$this->log_table."
108
+ SET
109
+ ip = '$ip',
110
+ all_entries = 1,
111
+ blocked_entries = 1,
112
+ entries_timestamp = '".intval($time)."'
113
+ ON DUPLICATE KEY
114
+ UPDATE
115
+ all_entries = all_entries + 1,
116
+ blocked_entries = blocked_entries".strval($blocked).",
117
+ entries_timestamp = '".intval($time)."'";
118
+
119
+ $this->db->query($query, true);
120
+ }
121
+
122
+ /*
123
+ * Sends and wipe SFW log
124
+ *
125
+ * returns mixed true || array('error' => true, 'error_string' => STRING)
126
+ */
127
+ public function logs__send($ct_key){
128
+
129
+ //Getting logs
130
+ $query = "SELECT * FROM ".$this->log_table.";";
131
+ $this->db->query($query)->fetch_all();
132
+
133
+ if(count($this->db->result)){
134
+
135
+ //Compile logs
136
+ $data = array();
137
+ foreach($this->db->result as $key => $value){
138
+ $data[] = array(trim($value['ip']), $value['all_entries'], $value['all_entries']-$value['blocked_entries'], $value['entries_timestamp']);
139
+ }
140
+ unset($key, $value);
141
+
142
+ //Sending the request
143
+ $result = CleantalkAPI::method__sfw_logs($ct_key, $data);
144
+
145
+ //Checking answer and deleting all lines from the table
146
+ if(empty($result['error'])){
147
+ if($result['rows'] == count($data)){
148
+ $this->db->query("DELETE FROM ".$this->log_table.";", true);
149
+ return true;
150
+ }
151
+ }else{
152
+ return $result;
153
+ }
154
+
155
+ }else{
156
+ return array('error' => true, 'error_string' => 'NO_LOGS_TO_SEND');
157
+ }
158
+ }
159
+
160
+ /*
161
+ * Updates SFW local base
162
+ *
163
+ * return mixed true || array('error' => true, 'error_string' => STRING)
164
+ */
165
+ public function sfw_update($ct_key){
166
+
167
+ $result = CleantalkAPI::method__get_2s_blacklists_db($ct_key);
168
+
169
+ if(empty($result['error'])){
170
+
171
+ $this->db->query("DELETE FROM ".$this->data_table.";", true);
172
+
173
+ // Cast result to int
174
+ foreach($result as $value){
175
+ $value[0] = intval($value[0]);
176
+ $value[1] = intval($value[1]);
177
+ } unset($value);
178
+
179
+ $query="INSERT INTO ".$this->data_table." VALUES ";
180
+ for($i=0, $arr_count = count($result); $i < $arr_count; $i++){
181
+ if($i == count($result)-1){
182
+ $query.="(".$result[$i][0].",".$result[$i][1].");";
183
+ }else{
184
+ $query.="(".$result[$i][0].",".$result[$i][1]."), ";
185
+ }
186
+ }
187
+ $this->db->query($query, true);
188
+
189
+ return true;
190
+
191
+ }else{
192
+ return $result;
193
+ }
194
+ }
195
+
196
+ /*
197
+ * Shows DIE page
198
+ *
199
+ * Stops script executing
200
+ */
201
+ public function sfw_die($api_key, $cookie_prefix = '', $cookie_domain = '')
202
+ {
203
+ die("IP {$this->blocked_ip} BLACKLISTED");
204
+ }
205
+ }
lib/CleantalkState.php CHANGED
@@ -19,9 +19,10 @@ class CleantalkState
19
  public $storage = array();
20
  public $def_settings = array(
21
 
22
- 'spam_firewall' => 0,
23
  'server' => 'http://moderate.cleantalk.org',
24
  'apikey' => '',
 
25
  'autoPubRevelantMess' => 0,
26
 
27
  /* Forms for protection */
@@ -101,6 +102,12 @@ class CleantalkState
101
  'notice_review' => 0,
102
  'notice_auto_update' => 0,
103
 
 
 
 
 
 
 
104
  'array_accepted' => array(),
105
  'array_blocked' => array(),
106
  'current_hour' => '',
@@ -129,16 +136,20 @@ class CleantalkState
129
  'sfw_enabled' => false,
130
  ),
131
 
 
 
 
 
 
132
  // Misc
133
  'feedback_request' => '',
134
  'key_is_ok' => 0,
135
  );
136
 
137
- public $def_network_settings = array(
138
  'allow_custom_key' => 0,
139
- 'allow_cleantalk_cp' => 0,
140
  'key_is_ok' => 0,
141
- 'spbc_key' => '',
142
  'user_token' => '',
143
  'service_id' => 0,
144
  );
@@ -148,9 +159,9 @@ class CleantalkState
148
  $this->option_prefix = $option_prefix;
149
 
150
  if($wpms){
151
- $option = get_site_option($this->option_prefix.'_network_settings');
152
- $option = is_array($option) ? $option : $this->def_network_settings;
153
- $this->network_settings = new ArrayObject($option);
154
  }
155
 
156
  foreach($options as $option_name){
@@ -198,7 +209,7 @@ class CleantalkState
198
 
199
  public function saveSettings()
200
  {
201
- update_option($this->option_prefix.'_settins', (array)$this->settings);
202
  }
203
 
204
  public function saveData()
@@ -211,9 +222,9 @@ class CleantalkState
211
  update_option($this->option_prefix.'_errors', (array)$this->errors);
212
  }
213
 
214
- public function saveNetworkSettings()
215
  {
216
- update_site_option($this->option_prefix.'_network_settings', $this->network_settings);
217
  }
218
 
219
  public function deleteOption($option_name, $use_prefix = false)
19
  public $storage = array();
20
  public $def_settings = array(
21
 
22
+ 'spam_firewall' => 1,
23
  'server' => 'http://moderate.cleantalk.org',
24
  'apikey' => '',
25
+ 'custom_key' => 0,
26
  'autoPubRevelantMess' => 0,
27
 
28
  /* Forms for protection */
102
  'notice_review' => 0,
103
  'notice_auto_update' => 0,
104
 
105
+ // Brief data
106
+ 'brief_data' => array(
107
+ 'spam_stat' => array(),
108
+ 'top5_spam_ip' => array(),
109
+ ),
110
+
111
  'array_accepted' => array(),
112
  'array_blocked' => array(),
113
  'current_hour' => '',
136
  'sfw_enabled' => false,
137
  ),
138
 
139
+ // White label
140
+ 'white_label_data' => array(
141
+ 'is_key_recieved' => false,
142
+ ),
143
+
144
  // Misc
145
  'feedback_request' => '',
146
  'key_is_ok' => 0,
147
  );
148
 
149
+ public $def_network_data = array(
150
  'allow_custom_key' => 0,
 
151
  'key_is_ok' => 0,
152
+ 'apikey' => '',
153
  'user_token' => '',
154
  'service_id' => 0,
155
  );
159
  $this->option_prefix = $option_prefix;
160
 
161
  if($wpms){
162
+ $option = get_site_option($this->option_prefix.'_network_data');
163
+ $option = is_array($option) ? $option : $this->def_network_data;
164
+ $this->network_data = new ArrayObject($option);
165
  }
166
 
167
  foreach($options as $option_name){
209
 
210
  public function saveSettings()
211
  {
212
+ update_option($this->option_prefix.'_settings', (array)$this->settings);
213
  }
214
 
215
  public function saveData()
222
  update_option($this->option_prefix.'_errors', (array)$this->errors);
223
  }
224
 
225
+ public function saveNetworkData()
226
  {
227
+ update_site_option($this->option_prefix.'_network_data', $this->network_data);
228
  }
229
 
230
  public function deleteOption($option_name, $use_prefix = false)
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: safronik
3
  Tags: spam, antispam, protection, comments, firewall
4
  Requires at least: 3.0
5
  Tested up to: 4.9
6
- Stable tag: 5.105
7
  License: GPLv2
8
 
9
  Spam protection, antispam, all-in-one, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
@@ -201,6 +201,17 @@ CleanTalk has an advanced option "Spam FireWall". This option allows you to bloc
201
 
202
  "CleanTalk team has been developing a cloud spam protection system for five years and has created a truly reliable anti-spam service designed for you to guarantee your safety".
203
 
 
 
 
 
 
 
 
 
 
 
 
204
  = Auto-Update CleanTalk AntiSpam =
205
 
206
  CleanTalk Dashboard allows you to set auto-update plugin and select several websites and update the plugin at once on all sites by one click or you can setup auto-update for all websites or separate websites.
@@ -516,6 +527,16 @@ Yes, it is. Please read this article,
516
  10. Website's options.
517
 
518
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
519
  = 5.105 September 26 2018 =
520
  * Integration: Now bloking spam for QAEngine questions.
521
  * Fix: Async http__request call.
@@ -1663,6 +1684,16 @@ Yes, it is. Please read this article,
1663
  * First version
1664
 
1665
  == Upgrade Notice ==
 
 
 
 
 
 
 
 
 
 
1666
  = 5.105 September 26 2018 =
1667
  * Integration: Now bloking spam for QAEngine questions.
1668
  * Fix: Async http__request call.
3
  Tags: spam, antispam, protection, comments, firewall
4
  Requires at least: 3.0
5
  Tested up to: 4.9
6
+ Stable tag: 5.106
7
  License: GPLv2
8
 
9
  Spam protection, antispam, all-in-one, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
201
 
202
  "CleanTalk team has been developing a cloud spam protection system for five years and has created a truly reliable anti-spam service designed for you to guarantee your safety".
203
 
204
+ = White Label Mode =
205
+
206
+ To switch the plugin work in the white-label mode you must insert this code to your wp-config.php:
207
+
208
+ define('APBCT_WHITELABLE', true);
209
+ define('APBCT_HOSTER_API_KEY', 'YOUR_HOSTER_API_KEY');
210
+
211
+ Where YOUR_HOSTER_API_KEY is a key from CleanTalk's hoster panel.
212
+
213
+ The plugin will do everything rest.
214
+
215
  = Auto-Update CleanTalk AntiSpam =
216
 
217
  CleanTalk Dashboard allows you to set auto-update plugin and select several websites and update the plugin at once on all sites by one click or you can setup auto-update for all websites or separate websites.
527
  10. Website's options.
528
 
529
  == Changelog ==
530
+ = 5.106 October 11 2018 =
531
+ * Spam filtration improved.
532
+ * New: White Label mode.
533
+ * Modification: Warning message about test on SpamFireWall die page.
534
+ * Integration: WP Maintenance Mode.
535
+ * Fix: S2Member.
536
+ * Fix: JavaScript attachments reconsidered.
537
+ * Fix: Admin banners layout.
538
+ * Fix: Minor layout fixes.
539
+
540
  = 5.105 September 26 2018 =
541
  * Integration: Now bloking spam for QAEngine questions.
542
  * Fix: Async http__request call.
1684
  * First version
1685
 
1686
  == Upgrade Notice ==
1687
+ = 5.106 October 11 2018 =
1688
+ * Spam filtration improved.
1689
+ * New: White Label mode.
1690
+ * Modification: Warning message about test on SpamFireWall die page.
1691
+ * Integration: WP Maintenance Mode.
1692
+ * Fix: S2Member.
1693
+ * Fix: JavaScript attachments reconsidered.
1694
+ * Fix: Admin banners layout.
1695
+ * Fix: Minor layout fixes.
1696
+
1697
  = 5.105 September 26 2018 =
1698
  * Integration: Now bloking spam for QAEngine questions.
1699
  * Fix: Async http__request call.