Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.103

Version Description

September 13 2018 = * Fix: Gravity Forms response message. * Fix: SpamFireWall redirect to 404 page. * Major anti-spam plugin improvement. * Recombined setting page. * Added error notification. * Mod: S2 Members integration. * Mod: Improved remote calls.

Download this release

Release Info

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

Code changes from version 5.102 to 5.103

cleantalk.php CHANGED
@@ -3,29 +3,45 @@
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.102
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
10
 
11
  $cleantalk_executed = false;
12
 
13
- define('APBCT_VERSION', '5.102');
14
- define('APBCT_AGENT', 'wordpress-5102');
15
-
16
- define('CLEANTALK_REMOTE_CALL_SLEEP', 10); // Minimum time between remote call
17
- define('APBCT_CASERT_PATH', file_exists(ABSPATH . WPINC . '/certificates/ca-bundle.crt')
18
- ? ABSPATH . WPINC . '/certificates/ca-bundle.crt'
19
- : ''
20
- ); // SSL SERTTIFICATE PATH
21
-
22
- define('APBCT_URL_PATH', plugins_url('', __FILE__)); //URL path to plugin.
23
- define('APBCT_DIR_PATH', plugin_dir_path(__FILE__)); //Filesystem path to plugin.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  if(!defined('CLEANTALK_PLUGIN_DIR')){
26
 
27
- global $ct_options, $ct_data, $pagenow;
28
-
29
  define('CLEANTALK_PLUGIN_DIR', plugin_dir_path(__FILE__));
30
 
31
  require_once( CLEANTALK_PLUGIN_DIR . 'lib/cleantalk-php-patch.php'); // Pathces fpr different functions which not exists
@@ -36,9 +52,19 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
36
  require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkCron.php'); // Cron handling
37
  require_once( CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-widget.php');
38
  require_once( CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-common.php');
39
-
40
- $ct_options=ct_get_options();
41
- $ct_data=ct_get_data();
 
 
 
 
 
 
 
 
 
 
42
 
43
  // Self cron
44
  if(!defined('DOING_CRON') || (defined('DOING_CRON') && DOING_CRON !== true)){
@@ -65,7 +91,7 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
65
 
66
  // Early checks
67
  // Facebook
68
- if (isset($ct_options['general_contact_forms_test']) && $ct_options['general_contact_forms_test'] == 1
69
  && (!empty($_POST['action']) && $_POST['action'] == 'fb_intialize')
70
  && !empty($_POST['FB_userdata'])
71
  ){
@@ -80,141 +106,17 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
80
  if(isset($_SERVER['REQUEST_URI']) && stripos($_SERVER['REQUEST_URI'],'admin-ajax.php') !== false && sizeof($_POST) > 0 && isset($_GET['action']) && $_GET['action']=='ninja_forms_ajax_submit')
81
  $_POST['action']='ninja_forms_ajax_submit';
82
 
83
- //*/ REMOTE CALLS
84
- if(isset($_GET['spbc_remote_call_token'], $_GET['spbc_remote_call_action'], $_GET['plugin_name']) && in_array($_GET['plugin_name'], array('antispam','anti-spam', 'apbct'))){
85
-
86
- // Comparing with cleantalk's IP
87
- $spbc_remote_ip = CleantalkHelper::ip_get(array('real'), false);
88
-
89
- if(!empty($spbc_remote_ip)){
90
-
91
- $resolved = gethostbyaddr($spbc_remote_ip);
92
-
93
- if($resolved !== false){
94
-
95
- if(preg_match('/cleantalk\.org$/', $resolved) === 1 || $resolved === 'back'){
96
-
97
- if(!isset($ct_data['last_remote_call']) || (isset($ct_data['last_remote_call']) && time() - $ct_data['last_remote_call'] > CLEANTALK_REMOTE_CALL_SLEEP)){
98
-
99
- $ct_data['last_remote_call'] = time();
100
- update_option('cleantalk_data', $ct_data);
101
-
102
- if(strtolower($_GET['spbc_remote_call_token']) == md5($ct_options['apikey'])){
103
-
104
- // Close renew banner
105
- if($_GET['spbc_remote_call_action'] == 'close_renew_banner'){
106
- $ct_data['show_ct_notice_trial'] = 0;
107
- $ct_data['show_ct_notice_renew'] = 0;
108
- update_option('cleantalk_data', $ct_data);
109
- CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 86400);
110
- die('OK');
111
- // SFW update
112
- }elseif($_GET['spbc_remote_call_action'] == 'sfw_update'){
113
- $result = ct_sfw_update();
114
- die(empty($result['error']) ? 'OK' : 'FAIL '.json_encode(array('error' => $result['error_string'])));
115
- // SFW send logs
116
- }elseif($_GET['spbc_remote_call_action'] == 'sfw_send_logs'){
117
- $rc_result = ct_sfw_send_logs();
118
- die(empty($result['error']) ? 'OK' : 'FAIL '.json_encode(array('error' => $result['error_string'])));
119
- // Update plugin
120
- }elseif($_GET['spbc_remote_call_action'] == 'update_plugin'){
121
- add_action('template_redirect', 'apbct_update', 1);
122
- }else
123
- die('FAIL '.json_encode(array('error' => 'UNKNOWN_ACTION')));
124
- }else
125
- die('FAIL '.json_encode(array('error' => 'WRONG_TOKEN')));
126
- }else
127
- die('FAIL '.json_encode(array('error' => 'TOO_MANY_ATTEMPTS')));
128
- }else
129
- die('FAIL '.json_encode(array('error' => 'WRONG_IP')));
130
- }else
131
- die('FAIL '.json_encode(array('error' => 'COULDNT_RESOLVE_IP')));
132
- }else
133
- die('FAIL '.json_encode(array('error' => 'COULDNT_RECONIZE_IP')));
134
- }
135
- //*/ END OF REMOTE CALLS
136
-
137
- // SFW start
138
- $value = (isset($ct_options['spam_firewall']) ? intval($ct_options['spam_firewall']) : 0);
139
- /*
140
- Turn off the SpamFireWall if current url in the exceptions list.
141
- */
142
- if ($value == 1 && isset($cleantalk_url_exclusions) && is_array($cleantalk_url_exclusions)) {
143
- foreach ($cleantalk_url_exclusions as $v) {
144
- if (stripos($_SERVER['REQUEST_URI'], $v) !== false) {
145
- $value = 0;
146
- break;
147
- }
148
- }
149
- }
150
-
151
- /*
152
- Turn off the SpamFireWall for WordPress core pages
153
- */
154
- $ct_wordpress_core_pages = array(
155
- '/wp-admin',
156
- '/feed'
157
- );
158
- if ($value == 1) {
159
- if(!empty($_SERVER['REQUEST_URI'])){
160
- foreach ($ct_wordpress_core_pages as $v) {
161
- if (stripos($_SERVER['REQUEST_URI'], $v) !== false) {
162
- $value = 0;
163
- break;
164
- }
165
- }
166
- }
167
- }
168
-
169
- // SpamFireWall check
170
- if($value==1 && !is_admin() || $value==1 && defined( 'DOING_AJAX' ) && DOING_AJAX && $_SERVER["REQUEST_METHOD"] == 'GET'){
171
-
172
- include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
173
 
174
- $is_sfw_check = true;
175
- $sfw = new CleantalkSFW();
176
- $sfw->ip_array = (array)CleantalkSFW::ip_get(array('real'), true);
177
-
178
- foreach($sfw->ip_array as $ct_cur_ip){
179
- if(isset($_COOKIE['ct_sfw_pass_key']) && $_COOKIE['ct_sfw_pass_key'] == md5($ct_cur_ip.$ct_options['apikey'])){
180
- $is_sfw_check=false;
181
- if(isset($_COOKIE['ct_sfw_passed'])){
182
- $sfw->sfw_update_logs($ct_cur_ip, 'passed');
183
- $ct_data['sfw_counter']['all']++;
184
- update_option('cleantalk_data', $ct_data);
185
- if(!headers_sent())
186
- setcookie ('ct_sfw_passed', '0', 1, "/");
187
- }
188
- }else{
189
- $is_sfw_check=true;
190
- }
191
- }
192
-
193
- // Skip the check
194
- if(!empty($_GET['access'])){
195
- $spbc_settings = get_option('spbc_settings');
196
- $spbc_key = !empty($spbc_settings['spbc_key']) ? $spbc_settings['spbc_key'] : false;
197
- if($_GET['access'] === $ct_options['apikey'] || ($spbc_key !== false && $_GET['access'] === $spbc_key)){
198
- $is_sfw_check = false;
199
- setcookie ('spbc_firewall_pass_key', md5($_SERVER['REMOTE_ADDR'].$spbc_key), time()+1200, '/');
200
- setcookie ('ct_sfw_pass_key', md5($_SERVER['REMOTE_ADDR'].$ct_options['apikey']), time()+1200, '/');
201
- }
202
- unset($spbc_settings, $spbc_key);
203
  }
 
204
 
205
- if($is_sfw_check){
206
- $sfw->check_ip();
207
- if($sfw->result){
208
- $sfw->sfw_update_logs($sfw->blocked_ip, 'blocked');
209
- $ct_data['sfw_counter']['blocked']++;
210
- update_option('cleantalk_data', $ct_data);
211
- $sfw->sfw_die($ct_options['apikey']);
212
- }else{
213
- if(!empty($ct_options['set_cookies']))
214
- setcookie ('ct_sfw_pass_key', md5($sfw->passed_ip.$ct_options['apikey']), 0, "/");
215
- }
216
- }
217
- unset($is_sfw_check, $sfw, $sfw_ip, $ct_cur_ip);
218
  }
219
 
220
  // Activation/deactivation functions must be in main plugin file.
@@ -232,7 +134,7 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
232
  // After plugin loaded - to load locale as described in manual
233
  add_action('plugins_loaded', 'apbct_plugin_loaded' );
234
 
235
- if( !empty($ct_options['use_ajax']) &&
236
  stripos($_SERVER['REQUEST_URI'],'.xml')===false &&
237
  stripos($_SERVER['REQUEST_URI'],'.xsl')===false)
238
  {
@@ -240,43 +142,43 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
240
  add_action( 'wp_ajax_ct_get_cookie', 'ct_get_cookie',1 );
241
  }
242
 
243
- if(isset($ct_options['show_link']) && intval($ct_options['show_link']) == 1)
244
  add_action('comment_form_after', 'ct_show_comment_link');
245
 
246
- if(is_admin()){
247
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-comments.php');
248
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-users.php');
249
  }
250
 
251
  // Admin panel actions
252
- if (is_admin()||is_network_admin()){
253
 
254
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-admin.php');
 
255
 
256
  if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)){
257
- add_action('admin_init', 'apbct_admin_init', 1);
258
- add_action('admin_menu', 'ct_admin_add_page');
259
- if(is_network_admin())
260
- add_action('network_admin_menu', 'ct_admin_add_page');
261
-
262
- add_action('admin_notices', 'cleantalk_admin_notice_message');
263
- add_action('network_admin_notices', 'cleantalk_admin_notice_message');
264
 
265
  //Show widget only if not IP license
266
- if(empty($ct_data['moderate_ip']))
267
  add_action('wp_dashboard_setup', 'ct_dashboard_statistics_widget' );
268
-
269
  }
 
270
  if (defined( 'DOING_AJAX' ) && DOING_AJAX||isset($_POST['cma-action'])){
271
 
272
  // Feedback for comments
273
  if(isset($_POST['action']) && $_POST['action'] == 'ct_feedback_comment'){
274
- add_action( 'wp_ajax_nopriv_ct_feedback_comment', 'ct_comment_send_feedback',1 );
275
- add_action( 'wp_ajax_ct_feedback_comment', 'ct_comment_send_feedback',1 );
276
  }
277
  if(isset($_POST['action']) && $_POST['action'] == 'ct_feedback_user'){
278
- add_action( 'wp_ajax_nopriv_ct_feedback_user', 'ct_user_send_feedback',1 );
279
- add_action( 'wp_ajax_ct_feedback_user', 'ct_user_send_feedback',1 );
280
  }
281
 
282
  $cleantalk_hooked_actions = array();
@@ -294,7 +196,7 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
294
  }
295
 
296
  //QAEngine Theme answers
297
- if (intval($ct_options['general_contact_forms_test']))
298
  add_filter('et_pre_insert_answer', 'ct_ajax_hook', 1, 1);
299
 
300
  //
@@ -311,7 +213,7 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
311
  //Bitrix24 contact form
312
  if (ct_is_user_enable()) {
313
 
314
- if (isset($ct_options['general_contact_forms_test']) && $ct_options['general_contact_forms_test'] == 1 &&
315
  !empty($_POST['your-phone']) &&
316
  !empty($_POST['your-email']) &&
317
  !empty($_POST['your-message'])
@@ -321,23 +223,23 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
321
  }
322
  }
323
 
324
- add_action('admin_enqueue_scripts', 'apbct_enqueue_scripts');
325
 
326
  // Sends feedback to the cloud about comments
327
  // add_action('wp_set_comment_status', 'ct_comment_send_feedback', 10, 2);
328
 
329
  // Sends feedback to the cloud about deleted users
 
330
  if($pagenow=='users.php')
331
- add_action('delete_user', 'ct_delete_user', 10, 2);
332
 
333
  if($pagenow=='plugins.php' || (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'],'plugins.php') !== false)){
334
 
335
- add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'apbct_plugin_action_links', 10, 2);
336
- add_filter('network_admin_plugin_action_links_'.plugin_basename(__FILE__), 'apbct_plugin_action_links', 10, 2);
337
 
338
- add_filter('plugin_row_meta', 'apbct_register_plugin_links', 10, 2);
339
  }
340
- add_action('updated_option', 'ct_update_option'); // param - option name, i.e. 'cleantalk_settings'
341
 
342
  // Public pages actions
343
  }else{
@@ -383,6 +285,135 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
383
 
384
  }
385
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
386
  /**
387
  * On activation, set a time, frequency and name of an action hook to be scheduled.
388
  */
@@ -450,7 +481,7 @@ function apbct_plugin_redirect()
450
 
451
  function ct_add_event($event_type)
452
  {
453
- global $ct_data,$cleantalk_executed;
454
 
455
  //
456
  // To migrate on the new version of ct_add_event().
@@ -460,29 +491,29 @@ function ct_add_event($event_type)
460
  case '1': $event_type = 'yes';break;
461
  }
462
 
463
- $ct_data = ct_get_data();
464
  $current_hour = intval(date('G'));
465
 
466
  // Updating current hour
467
- if($current_hour!=$ct_data['current_hour']){
468
- $ct_data['current_hour']=$current_hour;
469
- $ct_data['array_accepted'][$current_hour]=0;
470
- $ct_data['array_blocked'][$current_hour]=0;
471
  }
472
 
473
  //Add 1 to counters
474
  if($event_type=='yes'){
475
- $ct_data['array_accepted'][$current_hour]++;
476
- $ct_data['all_time_counter']['accepted']++;
477
- $ct_data['user_counter']['accepted']++;
478
  }
479
  if($event_type=='no'){
480
- $ct_data['array_blocked'][$current_hour]++;
481
- $ct_data['all_time_counter']['blocked']++;
482
- $ct_data['user_counter']['blocked']++;
483
  }
484
 
485
- update_option('cleantalk_data', $ct_data);
 
486
  $cleantalk_executed=true;
487
  }
488
 
@@ -507,14 +538,14 @@ add_action( 'right_now_content_table_end', 'my_add_counts_to_dashboard' );
507
 
508
  function ct_sfw_update(){
509
 
510
- global $ct_options;
511
 
512
- if(isset($ct_options['spam_firewall']) && intval($ct_options['spam_firewall']) == 1){
513
 
514
  include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
515
 
516
  $sfw = new CleantalkSFW();
517
- $result = $sfw->sfw_update($ct_options['apikey']);
518
  unset($sfw);
519
  return $result;
520
  }
@@ -525,17 +556,14 @@ function ct_sfw_update(){
525
 
526
  function ct_sfw_send_logs()
527
  {
528
- global $ct_options, $ct_data;
529
 
530
- $ct_options=ct_get_options();
531
- $ct_data=ct_get_data();
532
-
533
- if(isset($ct_options['spam_firewall']) && intval($ct_options['spam_firewall']) == 1){
534
 
535
  include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
536
 
537
  $sfw = new CleantalkSFW();
538
- $result = $sfw->send_logs($ct_options['apikey']);
539
  unset($sfw);
540
  return $result;
541
 
@@ -575,18 +603,18 @@ function apbct_update(){
575
  if($result === false)
576
  die('FAIL '. json_encode(array('error' => 'COULD_NOT_ACTIVATE')));
577
 
578
- $urlHeaders = get_headers(get_option('siteurl'));
579
 
580
- if(strpos($urlHeaders[0], '200') === false){
581
-
582
  // Rollback
583
  $rollback = new CleantalkUpgrader( new CleantalkUpgraderSkin( compact('title', 'nonce', 'url', 'plugin_slug', 'prev_version') ) );
584
  $rollback->rollback($plugin);
585
 
586
  $response = array(
587
  'error' => 'BAD_HTTP_CODE',
588
- 'http_code' => $urlHeaders[0],
589
- 'output' => substr(file_get_contents(get_option('siteurl')), 0, 4000),
590
  'rollback_result' => $rollback->apbct_result,
591
  );
592
 
@@ -606,12 +634,10 @@ function apbct_update(){
606
 
607
  function cleantalk_get_brief_data(){
608
 
609
- $ct_options = ct_get_options();
610
- $ct_data = ct_get_data();
611
-
612
- $ct_data['brief_data'] = CleantalkHelper::api_method__get_antispam_report_breif($ct_options['apikey']);
613
 
614
- update_option('cleantalk_data', $ct_data);
 
615
 
616
  return;
617
  }
@@ -629,20 +655,18 @@ function ct_wp_logout(){
629
  */
630
  function apbct_cookie(){
631
 
632
- global $ct_options, $ct_page_timer_setuped;
633
-
634
- $ct_options=ct_get_options();
635
 
636
  if(
637
- empty($ct_options['set_cookies']) || // Do not set cookies if option is disabled (for Varnish cache).
638
- !empty($ct_page_timer_setuped) // Cookies already set
639
  )
640
  return false;
641
 
642
  // Cookie names to validate
643
  $cookie_test_value = array(
644
  'cookies_names' => array(),
645
- 'check_value' => $ct_options['apikey'],
646
  );
647
 
648
  // Submit time
@@ -680,7 +704,7 @@ function apbct_cookie(){
680
  $cookie_test_value['check_value'] = md5($cookie_test_value['check_value']);
681
  setcookie('apbct_cookies_test', json_encode($cookie_test_value), 0, '/');
682
 
683
- $ct_page_timer_setuped = true; // Global. Not to set cookies twice.
684
 
685
  }
686
 
@@ -691,8 +715,7 @@ function apbct_cookie(){
691
  */
692
  function apbct_cookies_test()
693
  {
694
- global $ct_options;
695
- $ct_options=ct_get_options();
696
 
697
  if(isset($_COOKIE['apbct_cookies_test'])){
698
 
@@ -701,7 +724,7 @@ function apbct_cookies_test()
701
  if(!is_array($cookie_test))
702
  return 0;
703
 
704
- $check_srting = $ct_options['apikey'];
705
  foreach($cookie_test['cookies_names'] as $cookie_name){
706
  $check_srting .= isset($_COOKIE[$cookie_name]) ? $_COOKIE[$cookie_name] : '';
707
  } unset($cokie_name);
@@ -739,7 +762,7 @@ function apbct_cookies__delete_all(){
739
  */
740
  function apbct_get_submit_time()
741
  {
742
- return apbct_cookies_test() == 1 ? time() - $_COOKIE['apbct_timestamp'] : null;
743
  }
744
 
745
  function apbct_is_user_logged_in(){
@@ -751,4 +774,95 @@ function apbct_is_user_logged_in(){
751
  } unset($key, $val);
752
  }
753
  return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
754
  }
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.103
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
10
 
11
  $cleantalk_executed = false;
12
 
13
+ // Getting version form main file (look above)
14
+ $plugin_info = get_file_data(__FILE__, array('Version' => 'Version', 'Name' => 'Plugin Name',));
15
+
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.
29
+ define('APBCT_NETWORK_SETTINGS', 'cleantalk_network_settings'); //Option name with plugin network settings.
30
+ define('APBCT_DEBUG', 'cleantalk_debug'); //Option name with a debug data. Empty by default.
31
+
32
+ // Different params
33
+ define('APBCT_REMOTE_CALL_SLEEP', 10); // Minimum time between remote call
34
+
35
+ // Database parameters
36
+ global $wpdb;
37
+ define('APBCT_TBL_FIREWALL_DATA', $wpdb->base_prefix . 'cleantalk_sfw'); // Table with firewall data.
38
+ define('APBCT_TBL_FIREWALL_LOG', $wpdb->base_prefix . 'cleantalk_sfw_logs'); // Table with firewall logs.
39
+ define('APBCT_TBL_SESSIONS', $wpdb->base_prefix . 'cleantalk_sessions'); // Table with session data.
40
+ define('APBCT_SELECT_LIMIT', 5000); // Select limit for logs.
41
+ define('APBCT_WRITE_LIMIT', 5000); // Write limit for firewall data.
42
 
43
  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
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
 
69
  // Self cron
70
  if(!defined('DOING_CRON') || (defined('DOING_CRON') && DOING_CRON !== true)){
91
 
92
  // Early checks
93
  // Facebook
94
+ if ($apbct->settings['general_contact_forms_test'] == 1
95
  && (!empty($_POST['action']) && $_POST['action'] == 'fb_intialize')
96
  && !empty($_POST['FB_userdata'])
97
  ){
106
  if(isset($_SERVER['REQUEST_URI']) && stripos($_SERVER['REQUEST_URI'],'admin-ajax.php') !== false && sizeof($_POST) > 0 && isset($_GET['action']) && $_GET['action']=='ninja_forms_ajax_submit')
107
  $_POST['action']='ninja_forms_ajax_submit';
108
 
109
+ if(!is_admin() && !defined('DOING_AJAX')){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
+ // Remote calls
112
+ if(isset($_GET['spbc_remote_call_token'], $_GET['spbc_remote_call_action'], $_GET['plugin_name']) && in_array($_GET['plugin_name'], array('antispam','anti-spam', 'apbct'))){
113
+ apbct_remote_call__perform();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  }
115
+ }
116
 
117
+ // SpamFireWall check
118
+ if( $apbct->settings['spam_firewall'] == 1 && !is_admin() || $apbct->settings['spam_firewall'] ==1 && defined( 'DOING_AJAX' ) && DOING_AJAX && $_SERVER["REQUEST_METHOD"] == 'GET'){
119
+ apbct_sfw__check();
 
 
 
 
 
 
 
 
 
 
120
  }
121
 
122
  // Activation/deactivation functions must be in main plugin file.
134
  // After plugin loaded - to load locale as described in manual
135
  add_action('plugins_loaded', 'apbct_plugin_loaded' );
136
 
137
+ if( !empty($apbct->settings['use_ajax']) &&
138
  stripos($_SERVER['REQUEST_URI'],'.xml')===false &&
139
  stripos($_SERVER['REQUEST_URI'],'.xsl')===false)
140
  {
142
  add_action( 'wp_ajax_ct_get_cookie', 'ct_get_cookie',1 );
143
  }
144
 
145
+ if($apbct->settings['show_link'] == 1)
146
  add_action('comment_form_after', 'ct_show_comment_link');
147
 
148
+ if(is_admin() || is_network_admin()){
149
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-comments.php');
150
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-users.php');
151
  }
152
 
153
  // Admin panel actions
154
+ if (is_admin() || is_network_admin()){
155
 
156
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-admin.php');
157
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-settings.php');
158
 
159
  if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)){
160
+
161
+ add_action('admin_init', 'apbct_admin__init', 1);
162
+ add_action('admin_menu', 'apbct_settings__add_page');
163
+ add_action('network_admin_menu', 'apbct_settings__add_page');
164
+ add_action('admin_notices', 'apbct_admin__notice_message');
165
+ add_action('network_admin_notices', 'apbct_admin__notice_message');
 
166
 
167
  //Show widget only if not IP license
168
+ if(!$apbct->moderate_ip)
169
  add_action('wp_dashboard_setup', 'ct_dashboard_statistics_widget' );
 
170
  }
171
+
172
  if (defined( 'DOING_AJAX' ) && DOING_AJAX||isset($_POST['cma-action'])){
173
 
174
  // Feedback for comments
175
  if(isset($_POST['action']) && $_POST['action'] == 'ct_feedback_comment'){
176
+ add_action( 'wp_ajax_nopriv_ct_feedback_comment', 'apbct_comment__send_feedback',1 );
177
+ add_action( 'wp_ajax_ct_feedback_comment', 'apbct_comment__send_feedback',1 );
178
  }
179
  if(isset($_POST['action']) && $_POST['action'] == 'ct_feedback_user'){
180
+ add_action( 'wp_ajax_nopriv_ct_feedback_user', 'apbct_user__send_feedback',1 );
181
+ add_action( 'wp_ajax_ct_feedback_user', 'apbct_user__send_feedback',1 );
182
  }
183
 
184
  $cleantalk_hooked_actions = array();
196
  }
197
 
198
  //QAEngine Theme answers
199
+ if (intval($apbct->settings['general_contact_forms_test']))
200
  add_filter('et_pre_insert_answer', 'ct_ajax_hook', 1, 1);
201
 
202
  //
213
  //Bitrix24 contact form
214
  if (ct_is_user_enable()) {
215
 
216
+ if ($apbct->settings['general_contact_forms_test'] == 1 &&
217
  !empty($_POST['your-phone']) &&
218
  !empty($_POST['your-email']) &&
219
  !empty($_POST['your-message'])
223
  }
224
  }
225
 
226
+ add_action('admin_enqueue_scripts', 'apbct_admin__enqueue_scripts');
227
 
228
  // Sends feedback to the cloud about comments
229
  // add_action('wp_set_comment_status', 'ct_comment_send_feedback', 10, 2);
230
 
231
  // Sends feedback to the cloud about deleted users
232
+ global $pagenow;
233
  if($pagenow=='users.php')
234
+ add_action('delete_user', 'apbct_user__delete__hook', 10, 2);
235
 
236
  if($pagenow=='plugins.php' || (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'],'plugins.php') !== false)){
237
 
238
+ add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'apbct_admin__plugin_action_links', 10, 2);
239
+ add_filter('network_admin_plugin_action_links_'.plugin_basename(__FILE__), 'apbct_admin__plugin_action_links', 10, 2);
240
 
241
+ add_filter('plugin_row_meta', 'apbct_admin__register_plugin_links', 10, 2);
242
  }
 
243
 
244
  // Public pages actions
245
  }else{
285
 
286
  }
287
 
288
+ /**
289
+ * Function preforms remote call
290
+ */
291
+ function apbct_remote_call__perform()
292
+ {
293
+ global $apbct;
294
+
295
+ /**
296
+ * Temporary disabled IP check because of false blocks
297
+ * @date 04.09.2018
298
+ */
299
+ /*
300
+ // Comparing with cleantalk's IP
301
+ $spbc_remote_ip = CleantalkHelper::ip_get(array('real'), false);
302
+
303
+ if(!empty($spbc_remote_ip)){
304
+
305
+ $resolved = gethostbyaddr($spbc_remote_ip);
306
+
307
+ if($resolved !== false){
308
+
309
+ if(preg_match('/cleantalk\.org$/', $resolved) === 1 || $resolved === 'back'){
310
+ */
311
+ if(time() - $apbct->last_remote_call > APBCT_REMOTE_CALL_SLEEP){
312
+
313
+ $apbct->data['last_remote_call'] = time();
314
+ $apbct->saveData();
315
+
316
+ if(strtolower($_GET['spbc_remote_call_token']) == strtolower(md5($apbct->api_key))){
317
+
318
+ // Close renew banner
319
+ if($_GET['spbc_remote_call_action'] == 'close_renew_banner'){
320
+ $apbct->data['notice_trial'] = 0;
321
+ $apbct->data['notice_renew'] = 0;
322
+ $apbct->saveData();
323
+ CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 86400);
324
+ die('OK');
325
+ // SFW update
326
+ }elseif($_GET['spbc_remote_call_action'] == 'sfw_update'){
327
+ $result = ct_sfw_update();
328
+ die(empty($result['error']) ? 'OK' : 'FAIL '.json_encode(array('error' => $result['error_string'])));
329
+ // SFW send logs
330
+ }elseif($_GET['spbc_remote_call_action'] == 'sfw_send_logs'){
331
+ $rc_result = ct_sfw_send_logs();
332
+ die(empty($result['error']) ? 'OK' : 'FAIL '.json_encode(array('error' => $result['error_string'])));
333
+ // Update plugin
334
+ }elseif($_GET['spbc_remote_call_action'] == 'update_plugin'){
335
+ add_action('template_redirect', 'apbct_update', 1);
336
+ }else
337
+ die('FAIL '.json_encode(array('error' => 'UNKNOWN_ACTION')));
338
+ }else
339
+ die('FAIL '.json_encode(array('error' => 'WRONG_TOKEN')));
340
+ }else
341
+ die('FAIL '.json_encode(array('error' => 'TOO_MANY_ATTEMPTS')));
342
+ /*
343
+ }else
344
+ die('FAIL '.json_encode(array('error' => 'WRONG_IP')));
345
+ }else
346
+ die('FAIL '.json_encode(array('error' => 'COULDNT_RESOLVE_IP')));
347
+ }else
348
+ die('FAIL '.json_encode(array('error' => 'COULDNT_RECONIZE_IP')));
349
+ */
350
+ }
351
+
352
+ /**
353
+ * Function for SpamFireWall check
354
+ */
355
+ function apbct_sfw__check()
356
+ {
357
+ global $apbct, $cleantalk_url_exclusions;
358
+
359
+ // Turn off the SpamFireWall if current url in the exceptions list and WordPress core pages
360
+ if (!empty($cleantalk_url_exclusions) && is_array($cleantalk_url_exclusions)) {
361
+ $core_page_to_skip_check = array('/feed');
362
+ foreach (array_merge($cleantalk_url_exclusions, $core_page_to_skip_check) as $v) {
363
+ if (stripos($_SERVER['REQUEST_URI'], $v) !== false) {
364
+ return;
365
+ }
366
+ }
367
+ }
368
+
369
+ include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
370
+
371
+ $is_sfw_check = true;
372
+ $sfw = new CleantalkSFW();
373
+ $sfw->ip_array = (array)CleantalkSFW::ip_get(array('real'), true);
374
+
375
+ foreach($sfw->ip_array as $ct_cur_ip){
376
+ if(isset($_COOKIE['ct_sfw_pass_key']) && $_COOKIE['ct_sfw_pass_key'] == md5($ct_cur_ip.$apbct->api_key)){
377
+ $is_sfw_check=false;
378
+ if(isset($_COOKIE['ct_sfw_passed'])){
379
+ $sfw->sfw_update_logs($ct_cur_ip, 'passed');
380
+ $apbct->data['sfw_counter']['all']++;
381
+ $apbct->saveData();
382
+ if(!headers_sent())
383
+ setcookie ('ct_sfw_passed', '0', 1, "/");
384
+ }
385
+ }else{
386
+ $is_sfw_check=true;
387
+ }
388
+ }
389
+
390
+ // Skip the check
391
+ if(!empty($_GET['access'])){
392
+ $spbc_settings = get_option('spbc_settings');
393
+ $spbc_key = !empty($spbc_settings['spbc_key']) ? $spbc_settings['spbc_key'] : false;
394
+ if($_GET['access'] === $apbct->api_key || ($spbc_key !== false && $_GET['access'] === $spbc_key)){
395
+ $is_sfw_check = false;
396
+ setcookie ('spbc_firewall_pass_key', md5($_SERVER['REMOTE_ADDR'].$spbc_key), time()+1200, '/');
397
+ setcookie ('ct_sfw_pass_key', md5($_SERVER['REMOTE_ADDR'].$apbct->api_key), time()+1200, '/');
398
+ }
399
+ unset($spbc_settings, $spbc_key);
400
+ }
401
+
402
+ if($is_sfw_check){
403
+ $sfw->check_ip();
404
+ if($sfw->result){
405
+ $sfw->sfw_update_logs($sfw->blocked_ip, 'blocked');
406
+ $apbct->data['sfw_counter']['blocked']++;
407
+ $apbct->saveData();
408
+ $sfw->sfw_die($apbct->api_key);
409
+ }else{
410
+ if(!empty($apbct->settings['set_cookies']))
411
+ setcookie ('ct_sfw_pass_key', md5($sfw->passed_ip.$apbct->api_key), 0, "/");
412
+ }
413
+ }
414
+ unset($is_sfw_check, $sfw, $sfw_ip, $ct_cur_ip);
415
+ }
416
+
417
  /**
418
  * On activation, set a time, frequency and name of an action hook to be scheduled.
419
  */
481
 
482
  function ct_add_event($event_type)
483
  {
484
+ global $apbct, $cleantalk_executed;
485
 
486
  //
487
  // To migrate on the new version of ct_add_event().
491
  case '1': $event_type = 'yes';break;
492
  }
493
 
 
494
  $current_hour = intval(date('G'));
495
 
496
  // Updating current hour
497
+ if($current_hour!=$apbct->data['current_hour']){
498
+ $apbct->data['current_hour'] = $current_hour;
499
+ $apbct->data['array_accepted'][$current_hour] = 0;
500
+ $apbct->data['array_blocked'][$current_hour] = 0;
501
  }
502
 
503
  //Add 1 to counters
504
  if($event_type=='yes'){
505
+ $apbct->data['array_accepted'][$current_hour]++;
506
+ $apbct->data['all_time_counter']['accepted']++;
507
+ $apbct->data['user_counter']['accepted']++;
508
  }
509
  if($event_type=='no'){
510
+ $apbct->data['array_blocked'][$current_hour]++;
511
+ $apbct->data['all_time_counter']['blocked']++;
512
+ $apbct->data['user_counter']['blocked']++;
513
  }
514
 
515
+ $apbct->saveData();
516
+
517
  $cleantalk_executed=true;
518
  }
519
 
538
 
539
  function ct_sfw_update(){
540
 
541
+ global $apbct;
542
 
543
+ if($apbct->settings['spam_firewall'] == 1){
544
 
545
  include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
546
 
547
  $sfw = new CleantalkSFW();
548
+ $result = $sfw->sfw_update($apbct->api_key);
549
  unset($sfw);
550
  return $result;
551
  }
556
 
557
  function ct_sfw_send_logs()
558
  {
559
+ global $apbct;
560
 
561
+ if($apbct->settings['spam_firewall'] == 1){
 
 
 
562
 
563
  include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
564
 
565
  $sfw = new CleantalkSFW();
566
+ $result = $sfw->send_logs($apbct->api_key);
567
  unset($sfw);
568
  return $result;
569
 
603
  if($result === false)
604
  die('FAIL '. json_encode(array('error' => 'COULD_NOT_ACTIVATE')));
605
 
606
+ $httpResponseCode = CleantalkHelper::http__request(get_option('siteurl'), array(), 'get_code');
607
 
608
+ if( strpos($httpResponseCode, '200') === false ){
609
+
610
  // Rollback
611
  $rollback = new CleantalkUpgrader( new CleantalkUpgraderSkin( compact('title', 'nonce', 'url', 'plugin_slug', 'prev_version') ) );
612
  $rollback->rollback($plugin);
613
 
614
  $response = array(
615
  'error' => 'BAD_HTTP_CODE',
616
+ 'http_code' => $httpResponseCode,
617
+ 'output' => substr(file_get_contents(get_option('siteurl')), 0, 900),
618
  'rollback_result' => $rollback->apbct_result,
619
  );
620
 
634
 
635
  function cleantalk_get_brief_data(){
636
 
637
+ global $apbct;
 
 
 
638
 
639
+ $apbct->data['brief_data'] = CleantalkHelper::api_method__get_antispam_report_breif($apbct->api_key);
640
+ $apbct->saveData();
641
 
642
  return;
643
  }
655
  */
656
  function apbct_cookie(){
657
 
658
+ global $apbct;
 
 
659
 
660
  if(
661
+ empty($apbct->settings['set_cookies']) || // Do not set cookies if option is disabled (for Varnish cache).
662
+ !empty($apbct->flags__cookies_setuped) // Cookies already set
663
  )
664
  return false;
665
 
666
  // Cookie names to validate
667
  $cookie_test_value = array(
668
  'cookies_names' => array(),
669
+ 'check_value' => $apbct->api_key,
670
  );
671
 
672
  // Submit time
704
  $cookie_test_value['check_value'] = md5($cookie_test_value['check_value']);
705
  setcookie('apbct_cookies_test', json_encode($cookie_test_value), 0, '/');
706
 
707
+ $apbct->flags__cookies_setuped = true;
708
 
709
  }
710
 
715
  */
716
  function apbct_cookies_test()
717
  {
718
+ global $apbct;
 
719
 
720
  if(isset($_COOKIE['apbct_cookies_test'])){
721
 
724
  if(!is_array($cookie_test))
725
  return 0;
726
 
727
+ $check_srting = $apbct->api_key;
728
  foreach($cookie_test['cookies_names'] as $cookie_name){
729
  $check_srting .= isset($_COOKIE[$cookie_name]) ? $_COOKIE[$cookie_name] : '';
730
  } unset($cokie_name);
762
  */
763
  function apbct_get_submit_time()
764
  {
765
+ return apbct_cookies_test() == 1 ? time() - (int)$_COOKIE['apbct_timestamp'] : null;
766
  }
767
 
768
  function apbct_is_user_logged_in(){
774
  } unset($key, $val);
775
  }
776
  return false;
777
+ }
778
+
779
+ /*
780
+ * Inner function - Account status check
781
+ * Scheduled in 1800 seconds for default!
782
+ */
783
+ function ct_account_status_check($api_key = null){
784
+
785
+ global $apbct;
786
+
787
+ $api_key = $api_key ? $api_key : $apbct->api_key;
788
+
789
+ $result = CleantalkHelper::api_method__notice_paid_till($api_key);
790
+
791
+ if(empty($result['error'])){
792
+
793
+ // Notices
794
+ $apbct->data['notice_show'] = isset($result['show_notice']) ? (int)$result['show_notice'] : 0;
795
+ $apbct->data['notice_renew'] = isset($result['renew']) ? (int)$result['renew'] : 0;
796
+ $apbct->data['notice_trial'] = isset($result['trial']) ? (int)$result['trial'] : 0;
797
+ $apbct->data['notice_review'] = isset($result['show_review']) ? (int)$result['show_review'] : 0;
798
+ $apbct->data['notice_auto_update'] = isset($result['show_auto_update_notice']) ? (int)$result['show_auto_update_notice'] : 0;
799
+
800
+ // Other
801
+ $apbct->data['service_id'] = isset($result['service_id']) ? (int)$result['service_id'] : 0;
802
+ $apbct->data['valid'] = isset($result['valid']) ? (int)$result['valid'] : 0;
803
+ $apbct->data['moderate'] = isset($result['moderate']) ? (int)$result['moderate'] : 0;
804
+ $apbct->data['moderate_ip'] = isset($result['moderate_ip']) ? (int)$result['moderate_ip'] : 0;
805
+ $apbct->data['ip_license'] = isset($result['ip_license']) ? (int)$result['ip_license'] : 0;
806
+ $apbct->data['spam_count'] = isset($result['spam_count']) ? (int)$result['spam_count'] : 0;
807
+ $apbct->data['auto_update'] = isset($result['auto_update_app']) ? (int)$result['auto_update_app'] : 0;
808
+ $apbct->data['user_token'] = isset($result['user_token']) ? (string)$result['user_token'] : '';
809
+ $apbct->data['license_trial'] = isset($result['license_trial']) ? (int)$result['license_trial'] : 0;
810
+
811
+ if($apbct->data['notice_show'] == 1 && $apbct->data['notice_trial'] == 1)
812
+ CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 3600);
813
+
814
+ if($apbct->data['notice_show'] == 1 && $apbct->data['notice_renew'] == 1)
815
+ CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 1800);
816
+
817
+ if($apbct->data['notice_show'] == 0)
818
+ CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 86400);
819
+
820
+ $apbct->saveData();
821
+ $apbct->error_delete('account_check', 'save');
822
+
823
+ }else{
824
+ $apbct->error_add('account_check', $result);
825
+ }
826
+ }
827
+
828
+ function ct_mail_send_connection_report() {
829
+
830
+ global $apbct;
831
+
832
+ if (($apbct->settings['send_connection_reports'] == 1 && $apbct->connection_reports['negative'] > 0) || !empty($_GET['ct_send_connection_report']))
833
+ {
834
+ $to = "welcome@cleantalk.org" ;
835
+ $subject = "Connection report for ".$_SERVER['HTTP_HOST'];
836
+ $message = '
837
+ <html>
838
+ <head>
839
+ <title></title>
840
+ </head>
841
+ <body>
842
+ <p>From '.$apbct->connection_reports['since'].' to '.date('d M').' has been made '.($apbct->connection_reports['success']+$apbct->connection_reports['negative']).' calls, where '.$apbct->connection_reports['success'].' were success and '.$apbct->connection_reports['negative'].' were negative</p>
843
+ <p>Negative report:</p>
844
+ <table> <tr>
845
+ <td>&nbsp;</td>
846
+ <td><b>Date</b></td>
847
+ <td><b>Page URL</b></td>
848
+ <td><b>Library report</b></td>
849
+ </tr>
850
+ ';
851
+ foreach ($apbct->connection_reports['negative_report'] as $key=>$report)
852
+ {
853
+ $message.= "<tr><td>".($key+1).".</td><td>".$report['date']."</td><td>".$report['page_url']."</td><td>".$report['lib_report']."</td></tr>";
854
+ }
855
+ $message.='</table></body></html>';
856
+
857
+ $headers = "Content-type: text/html; charset=windows-1251 \r\n";
858
+ $headers .= "From: ".get_option('admin_email');
859
+ mail($to, $subject, $message, $headers);
860
+ }
861
+
862
+ $apbct->data['connection_reports']['success'] = 0;
863
+ $apbct->data['connection_reports']['negative'] = 0;
864
+ $apbct->data['connection_reports']['negative_report'] = array();
865
+ $apbct->data['connection_reports']['since'] = date('d M');
866
+ $apbct->saveData();
867
+ CleantalkCron::updateTask('send_connection_report', 'ct_mail_send_connection_report', 3600);
868
  }
css/cleantalk-admin-settings-page.css CHANGED
@@ -1,3 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  .apbct_status_icon{
2
  vertical-align: text-bottom;
3
  margin: 0 5px 0 8px;
@@ -13,7 +126,6 @@ a.ct_support_link{
13
  .ct-warning-test-failed {
14
  display: inline-block;
15
  position: relative;
16
- left: -130px;
17
  padding: 5px;
18
  margin: 4px;
19
  border: 3px solid rgba(240,50,50,1);
1
+ #apbctTopWarning {margin-bottom: 5px;}
2
+ #apbctTopWarning h3{margin: 10px 0 5px 0;}
3
+ #apbctTopWarning h4{margin: 10px;}
4
+ #apbctTopWarning h4 span{margin-top: 5px;}
5
+
6
+ .apbct_settings-title{ display: inline-block; }
7
+ .apbct_settings-subtitle{
8
+ position: relative;
9
+ top: -15px;
10
+ margin: 0;
11
+ }
12
+
13
+ .apbct_settings-field_wrapper{ margin: 15px 0; }
14
+ .apbct_settings-field_wrapper--sub{ margin-left: 30px !important; }
15
+
16
+ .apbct_settings-field_title{ }
17
+ .apbct_settings-field_title--checkbox{ }
18
+ .apbct_settings-field_title--radio{
19
+ display: inline-block;
20
+ margin: 0;
21
+ width: 210px;
22
+ padding-right: 10px;
23
+ font-size: 14px;
24
+ vertical-align: top;
25
+ }
26
+ .apbct_settings-field_content{ display: inline-block; }
27
+ .apbct_settings-field_content--checkbox{ }
28
+ .apbct_settings-field_content--radio{ width: 70%; }
29
+
30
+ .apbct_settings__label{
31
+ margin-right: 10px;
32
+ font-size: 17px;
33
+ vertical-align: text-bottom;
34
+ }
35
+
36
+ .apbct_settings__text_feld{
37
+ font-size: 14pt;
38
+ }
39
+
40
+ .apbct_settings-field--checkbox{
41
+ vertical-align: middle;
42
+ top: -1px;
43
+ }
44
+
45
+ .gray{ color: gray; }
46
+
47
+ .cleantalk_manual_link {padding: 10px; background: #3399FF; color: #fff; border:0 none;
48
+ cursor:pointer;
49
+ -webkit-border-radius: 5px;
50
+ border-radius: 5px;
51
+ font-size: 12pt;
52
+ }
53
+ .cleantalk_auto_link{
54
+ background: #ccc;
55
+ border-color: #999;
56
+ -webkit-box-shadow: inset 0 1px 0 rgba(200,200,200,.5),0 1px 0 rgba(0,0,0,.15);
57
+ box-shadow: inset 0 1px 0 rgba(200,200,200,.5),0 1px 0 rgba(0,0,0,.15);
58
+ color: #000;
59
+ text-decoration: none;
60
+ display: inline-block;
61
+ text-decoration: none;
62
+ font-size: 13px;
63
+ line-height: 26px;
64
+ height: 28px;
65
+ margin: 0;
66
+ padding: 0 10px 1px;
67
+ cursor: pointer;
68
+ border-width: 1px;
69
+ border-style: solid;
70
+ -webkit-appearance: none;
71
+ -webkit-border-radius: 2px;
72
+ border-radius: 2px;
73
+ white-space: nowrap;
74
+ -webkit-box-sizing: border-box;
75
+ -moz-box-sizing: border-box;
76
+ box-sizing: border-box;
77
+ }
78
+ .cleantalk_auto_link:hover{
79
+ color: #fff;
80
+ }
81
+ .cleantalk_manual_link
82
+ {
83
+ background: #2ea2cc;
84
+ border-color: #0074a2;
85
+ -webkit-box-shadow: inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);
86
+ box-shadow: inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);
87
+ color: #fff;
88
+ text-decoration: none;
89
+ display: inline-block;
90
+ text-decoration: none;
91
+ font-size: 13px;
92
+ line-height: 26px;
93
+ height: 28px;
94
+ margin: 0;
95
+ padding: 0 10px 1px;
96
+ cursor: pointer;
97
+ border-width: 1px;
98
+ border-style: solid;
99
+ -webkit-appearance: none;
100
+ -webkit-border-radius: 3px;
101
+ border-radius: 3px;
102
+ white-space: nowrap;
103
+ -webkit-box-sizing: border-box;
104
+ -moz-box-sizing: border-box;
105
+ box-sizing: border-box;
106
+ }
107
+ .cleantalk_manual_link:hover
108
+ {
109
+ color:black;
110
+ }
111
+
112
+
113
+
114
  .apbct_status_icon{
115
  vertical-align: text-bottom;
116
  margin: 0 5px 0 8px;
126
  .ct-warning-test-failed {
127
  display: inline-block;
128
  position: relative;
 
129
  padding: 5px;
130
  margin: 4px;
131
  border: 3px solid rgba(240,50,50,1);
inc/cleantalk-admin.php CHANGED
@@ -1,14 +1,8 @@
1
  <?php
2
 
3
- $ct_plugin_basename = 'cleantalk-spam-protect/cleantalk.php';
4
- $ct_options=ct_get_options();
5
- $ct_data=ct_get_data();
6
 
7
- // How many days we use an IP to detect spam.
8
- $ct_ip_penalty_days = 30;
9
-
10
- // Timeout to get app server
11
- $ct_server_timeout = 10;
12
 
13
  //Adding widjet
14
  function ct_dashboard_statistics_widget() {
@@ -30,12 +24,7 @@ function ct_dashboard_statistics_widget() {
30
  // Outputs statistics widget content
31
  function ct_dashboard_statistics_widget_output( $post, $callback_args ) {
32
 
33
- global $ct_data, $ct_options, $current_user;
34
-
35
- $ct_options = ct_get_options();
36
- $ct_data = ct_get_data();
37
-
38
- $brief_data = $ct_data['brief_data'];
39
 
40
  echo "<div id='ct_widget_wrapper'>";
41
  ?>
@@ -49,7 +38,7 @@ function ct_dashboard_statistics_widget_output( $post, $callback_args ) {
49
  <h4 class='ct_widget_block_header'><?php _e('Top 5 spam IPs blocked', 'cleantalk'); ?></h4>
50
  <hr class='ct_widget_hr'>
51
  <?php
52
- if(!ct_valid_key() || (isset($brief_data['error_no']) && $brief_data['error_no'] == 6)){
53
  $plugin_settings_link = (is_network_admin() ? "settings.php" : "options-general.php" )."?page=cleantalk";
54
  ?> <div class='ct_widget_block'>
55
  <form action='<? echo $plugin_settings_link; ?>' method='POST'>
@@ -58,23 +47,23 @@ function ct_dashboard_statistics_widget_output( $post, $callback_args ) {
58
  </form>
59
  </div>
60
  <?php
61
- }elseif(!empty($brief_data['error'])){
62
  echo '<div class="ct_widget_block">'
63
  .'<h2 class="ct_widget_activate_header">'
64
- .sprintf(__('Something went wrong! Error: "%s".', 'cleantalk'), "<u>{$brief_data['error_string']}</u>")
65
  .'</h2>';
66
- if(!empty($ct_data['user_token'])){
67
  echo '<h2 class="ct_widget_activate_header">'
68
  .__('Please, visit your dashboard.', 'cleantalk')
69
  .'</h2>'
70
- .'<a target="_blank" href="https://cleantalk.org/my?user_token='.$ct_data['user_token'].'&cp_mode=antispam">'
71
  .'<input class="ct_widget_button ct_widget_activate_button ct_widget_resolve_button" type="button" value="VISIT CONTROL PANEL">'
72
  .'</a>';
73
  }
74
  echo '</div>';
75
  }
76
 
77
- if(ct_valid_key() && empty($brief_data['error'])){
78
  ?>
79
  <div class='ct_widget_block'>
80
  <table cellspacing="0">
@@ -83,7 +72,7 @@ function ct_dashboard_statistics_widget_output( $post, $callback_args ) {
83
  <th><?php _e('Country', 'cleantalk'); ?></th>
84
  <th><?php _e('Block Count', 'cleantalk'); ?></th>
85
  </tr>
86
- <?php foreach($brief_data['top5_spam_ip'] as $val){ ?>
87
  <tr>
88
  <td><?php echo $val[0]; ?></td>
89
  <td><?php echo $val[1] ? "<img src='https://cleantalk.org/images/flags/".strtolower($val[1]).".png'>" : ''; ?>&nbsp;<?php
@@ -94,8 +83,8 @@ function ct_dashboard_statistics_widget_output( $post, $callback_args ) {
94
  </tr>
95
  <?php } ?>
96
  </table>
97
- <?php if(!empty($ct_data['user_token'])){ ?>
98
- <a target='_blank' href='https://cleantalk.org/my?user_token=<?php echo $ct_data['user_token']; ?>&cp_mode=antispam'>
99
  <input class='ct_widget_button' id='ct_widget_button_view_all' type='button' value='View all'>
100
  </a>
101
  <?php } ?>
@@ -105,9 +94,7 @@ function ct_dashboard_statistics_widget_output( $post, $callback_args ) {
105
  }
106
  // Notice at the bottom
107
  if(isset($current_user) && in_array('administrator', $current_user->roles)){
108
-
109
- $blocked = isset($ct_data['admin_blocked']) ? $ct_data['admin_blocked'] : 0;
110
-
111
  if($blocked > 0){
112
  echo '<div class="ct_widget_wprapper_total_blocked">'
113
  .'<img src="'.plugins_url('/cleantalk-spam-protect/inc/images/logo_color.png').'" class="ct_widget_small_logo"/>'
@@ -115,9 +102,9 @@ function ct_dashboard_statistics_widget_output( $post, $callback_args ) {
115
  .sprintf(
116
  /* translators: %s: Number of spam messages */
117
  __( '%sCleanTalk%s has blocked %s spam for all time. The statistics are automatically updated every 24 hours.', 'cleantalk'),
118
- '<a href="https://cleantalk.org/my/?user_token='.@$ct_data['user_token'].'&utm_source=wp-backend&utm_medium=dashboard_widget&cp_mode=antispam" target="_blank">',
119
  '</a>',
120
- number_format($blocked)
121
  )
122
  .'</span><br><br>'
123
  .'<b style="font-size: 16px;">'
@@ -134,37 +121,92 @@ function ct_dashboard_statistics_widget_output( $post, $callback_args ) {
134
  }
135
 
136
  /**
137
- * Admin action 'wp_ajax_ajax_get_timezone' - Ajax method for getting timezone offset
138
- */
139
- function ct_ajax_get_timezone()
140
- {
141
- global $ct_data;
142
- check_ajax_referer( 'ct_secret_nonce', 'security' );
143
- $ct_data = ct_get_data();
144
- if(isset($_POST['offset']))
145
- {
146
- $ct_data['timezone'] = intval($_POST['offset']);
147
- update_option('cleantalk_data', $ct_data);
 
 
 
 
 
 
 
148
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  }
150
-
151
- add_action( 'wp_ajax_ajax_get_timezone', 'ct_ajax_get_timezone' );
152
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
 
154
  /**
155
  * Admin action 'admin_enqueue_scripts' - Enqueue admin script of reloading admin page after needed AJAX events
156
  * @param string $hook URL of hooked page
157
  */
158
- function apbct_enqueue_scripts($hook) {
159
 
160
- global $ct_data, $ct_options;
161
-
162
- $ct_options = ct_get_options();
163
- $ct_data = ct_get_data();
164
 
165
  // Scripts to all admin pages
166
- wp_enqueue_script('ct_admin_js_notices', plugins_url('/cleantalk-spam-protect/js/cleantalk-admin.js'), array(), APBCT_VERSION);
167
- wp_enqueue_style ('ct_admin_css', plugins_url('/cleantalk-spam-protect/css/cleantalk-admin.css'), array(), APBCT_VERSION, 'all');
168
 
169
  wp_localize_script( 'jquery', 'ctAdminCommon', array(
170
  'logo_small_colored' => '<img src="' . plugin_dir_url(__FILE__) . 'images/logo_color.png" alt="" height="" style="width: 17px; vertical-align: text-bottom;" />'
@@ -173,7 +215,7 @@ function apbct_enqueue_scripts($hook) {
173
  // Scripts & Styles to main dashboard page
174
  if($hook == 'index.php' && current_user_can('activate_plugins')){
175
 
176
- wp_enqueue_style('ct_admin_css_widget_dashboard', plugins_url('/cleantalk-spam-protect/css/cleantalk-dashboard-widget.css'), array(), APBCT_VERSION, 'all');
177
 
178
  wp_enqueue_script('ct_gstatic_charts_loader', plugins_url('/cleantalk-spam-protect/js/cleantalk-dashboard-widget--google-charts.js'), array(), APBCT_VERSION);
179
  wp_enqueue_script('ct_admin_js_widget_dashboard', plugins_url('/cleantalk-spam-protect/js/cleantalk-dashboard-widget.js'), array('ct_gstatic_charts_loader'), APBCT_VERSION);
@@ -181,7 +223,7 @@ function apbct_enqueue_scripts($hook) {
181
  // Preparing widget data
182
  // 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"]]
183
  $to_chart = array();
184
- foreach( $ct_data['brief_data']['spam_stat'] as $key => $value ){
185
  $to_chart[] = array( $key, $value );
186
  } unset( $key, $value );
187
 
@@ -198,8 +240,8 @@ function apbct_enqueue_scripts($hook) {
198
  $ajax_nonce = wp_create_nonce( "ct_secret_nonce" );
199
  wp_localize_script( 'jquery', 'ctSettingsPage', array(
200
  'ct_ajax_nonce' => $ajax_nonce,
201
- 'ct_subtitle' => $ct_data['ip_license'] != 0 ? __('Hosting AntiSpam', 'cleantalk') : '',
202
- 'ip_license' => $ct_data['ip_license'] != 0 ? true : false,
203
  ));
204
  }
205
 
@@ -210,8 +252,6 @@ function apbct_enqueue_scripts($hook) {
210
  wp_enqueue_style('jqueryui_css', plugins_url('/cleantalk-spam-protect/css/jquery-ui.min.css'), array(), '1.21.1', 'all');
211
 
212
  $ajax_nonce = wp_create_nonce( "ct_secret_nonce" );
213
- $user_token = !empty($ct_data['user_token']) ? $ct_data['user_token'] : '';
214
- $show_check_links = !empty($ct_options['show_check_links']) ? $ct_options['show_check_links'] : 0;
215
  if(!empty($_COOKIE['ct_paused_comments_check']))
216
  $prev_check = json_decode(stripslashes($_COOKIE['ct_paused_comments_check']), true);
217
 
@@ -239,8 +279,8 @@ function apbct_enqueue_scripts($hook) {
239
  'spambutton_text' => __("Find spam-comments", 'cleantalk'),
240
  'ct_feedback_msg_whitelisted' => __("The sender has been whitelisted.", 'cleantalk'),
241
  'ct_feedback_msg_blacklisted' => __("The sender has been blacklisted.", 'cleantalk'),
242
- 'ct_feedback_msg' => sprintf(__("Feedback has been sent to %sCleanTalk Dashboard%s.", 'cleantalk'), $user_token ? "<a target='_blank' href=https://cleantalk.org/my?user_token={$user_token}&cp_mode=antispam>" : '', $user_token ? "</a>" : ''),
243
- 'ct_show_check_links' => $show_check_links,
244
  'ct_img_src_new_tab' => plugin_dir_url(__FILE__)."images/new_window.gif",
245
 
246
  ));
@@ -254,7 +294,6 @@ function apbct_enqueue_scripts($hook) {
254
 
255
  $current_user = wp_get_current_user();
256
  $ajax_nonce = wp_create_nonce( "ct_secret_nonce" );
257
- $show_check_links = !empty($ct_options['show_check_links']) ? $ct_options['show_check_links'] : 0;
258
  if(!empty($_COOKIE['ct_paused_users_check']))
259
  $prev_check = json_decode(stripslashes($_COOKIE['ct_paused_users_check']), true);
260
 
@@ -281,445 +320,117 @@ function apbct_enqueue_scripts($hook) {
281
  ));
282
  wp_localize_script( 'jquery', 'ctUsersScreen', array(
283
  'spambutton_text' => __("Find spam-users", 'cleantalk'),
284
- 'ct_show_check_links' => $show_check_links,
285
  'ct_img_src_new_tab' => plugin_dir_url(__FILE__)."images/new_window.gif"
286
  ));
287
  }
288
  }
289
 
290
  /**
291
- * Admin action 'admin_menu' - Add the admin options page
 
292
  */
293
- function ct_admin_add_page() {
294
- global $ct_plugin_name;
295
 
296
- if(is_network_admin())
297
- add_submenu_page("settings.php", __('CleanTalk settings', 'cleantalk'), $ct_plugin_name, 'manage_options', 'cleantalk', 'apbct_settings_page');
298
- else
299
- add_options_page(__('CleanTalk settings', 'cleantalk'), $ct_plugin_name, 'manage_options', 'cleantalk', 'apbct_settings_page');
300
 
301
- }
302
-
303
- /*
304
- * Inner function - Account status check
305
- * Scheduled in 1800 seconds for default!
306
- */
307
- function ct_account_status_check(){
308
 
309
- global $ct_options, $ct_data, $show_ct_notice_trial, $show_ct_notice_renew;
 
 
 
310
 
311
- $ct_options = ct_get_options();
312
- $ct_data = ct_get_data();
313
-
314
- $api_key = isset($_POST['cleantalk_settings']['apikey'])
315
- ? $_POST['cleantalk_settings']['apikey']
316
- : (!empty($ct_options['apikey'])
317
- ? $ct_options['apikey']
318
- : null);
319
 
320
- $result = CleantalkHelper::api_method__notice_paid_till($api_key);
321
-
322
- if(empty($result['error'])){
323
 
324
- if(isset($result['spam_count']))
325
- $ct_data['admin_blocked'] = $result['spam_count'];
326
-
327
- if (isset($result['show_notice'])){
328
-
329
- if ($result['show_notice'] == 1 && isset($result['trial']) && $result['trial'] == 1){
330
- CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 3600);
331
- $show_ct_notice_trial = true;
332
- $ct_data['show_ct_notice_trial']=1;
333
- }
334
-
335
- if ($result['show_notice'] == 1 && isset($result['renew']) && $result['renew'] == 1){
336
- CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 1800);
337
- $show_ct_notice_renew = true;
338
- $ct_data['show_ct_notice_renew']=1;
339
- }
340
-
341
- if (isset($result['show_review']) && $result['show_review'] == 1)
342
- $ct_data['show_ct_notice_review'] = 1;
343
-
344
- if ($result['show_notice'] == 0)
345
- CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 86400);
346
-
347
- $ct_data['show_ct_notice_trial'] = (int) $show_ct_notice_trial;
348
- $ct_data['show_ct_notice_renew'] = (int) $show_ct_notice_renew;
349
- $ct_data['show_ct_notice_auto_update'] = isset($result['show_auto_update_notice']) ? $result['show_auto_update_notice'] : 0;
350
- $ct_data['auto_update_app'] = isset($result['auto_update_app']) ? $result['auto_update_app'] : 0;
351
  }
352
-
353
- if (isset($result['service_id']))
354
- $ct_data['service_id'] = (int)$result['service_id'];
355
-
356
- if (isset($result['moderate']) && $result['moderate'] == 1)
357
- $ct_data['moderate'] = 1;
358
- else
359
- $ct_data['moderate'] = 0;
360
-
361
- if (isset($result['license_trial'])){
362
- $ct_data['license_trial'] = $result['license_trial'];
363
  }
364
 
365
- if (isset($result['moderate_ip']) && $result['moderate_ip'] == 1){
366
- $ct_data['moderate_ip'] = 1;
367
- $ct_data['ip_license'] = $result['ip_license'];
368
- }else{
369
- $ct_data['moderate_ip'] = 0;
370
- $ct_data['ip_license'] = 0;
 
 
371
  }
372
 
373
- if (isset($result['user_token']))
374
- $ct_data['user_token'] = $result['user_token'];
375
-
376
- update_option('cleantalk_data', $ct_data);
377
-
378
- }
379
- }
380
-
381
- /**
382
- * Admin action 'admin_init' - Add the admin settings and such
383
- */
384
- function apbct_admin_init(){
385
-
386
- global $ct_server_timeout, $show_ct_notice_autokey, $ct_notice_autokey_label, $ct_notice_autokey_value, $show_ct_notice_renew, $ct_notice_renew_label, $show_ct_notice_trial, $ct_notice_trial_label, $show_ct_notice_online, $ct_notice_online_label, $renew_notice_showtime, $trial_notice_showtime, $ct_plugin_name, $ct_options, $ct_data, $ct_user_token_label, $notice_check_timeout;
387
-
388
- $ct_options = ct_get_options();
389
- $ct_data = ct_get_data();
390
-
391
- // Update logic
392
- $current_version = (!empty($ct_data['plugin_version']) ? $ct_data['plugin_version'] : '1.0.0');
393
-
394
- if($current_version != APBCT_VERSION){
395
- if(is_main_site()){
396
- require_once('cleantalk-updater.php');
397
- $result = apbct_run_update_actions($current_version, APBCT_VERSION);
398
- //If update is successfull
399
- if($result === true){
400
- ct_send_feedback(
401
- '0:' . APBCT_AGENT // 0 - request_id, agent version.
402
- );
403
- $ct_data['plugin_version'] = APBCT_VERSION;
404
- update_option( 'cleantalk_data' , $ct_data);
405
  }
406
  }
407
- }
408
-
409
- // Drop debug data
410
- if(isset($_POST['ct_debug_reset']) && $_POST['ct_debug_reset']){
411
- $ct_data['ct_debug_reset'] = true;
412
- update_option('cleantalk_data', $ct_data);
413
- }
414
-
415
- // Feedback when saving settings
416
- if(isset($_POST['option_page']) && $_POST['option_page'] == 'cleantalk_settings' && isset($_POST['cleantalk_settings']['apikey'])){
417
- $ct_options['apikey']=$_POST['cleantalk_settings']['apikey'];
418
- update_option('cleantalk_settings', $ct_options);
419
- ct_send_feedback(
420
- '0:' . APBCT_AGENT // 0 - request_id, agent version.
421
- );
422
- }
423
-
424
- $show_ct_notice_autokey = false;
425
- if (isset($_COOKIE[$ct_notice_autokey_label]) && !empty($_COOKIE[$ct_notice_autokey_label]))
426
- {
427
- $show_ct_notice_autokey = true;
428
- $ct_notice_autokey_value = base64_decode($_COOKIE[$ct_notice_autokey_label]);
429
- setcookie($ct_notice_autokey_label, '', 1, '/');
430
- }
431
-
432
- //Auto getting key
433
- if (isset($_POST['get_apikey_auto']))
434
- {
435
- $website = parse_url(get_option('siteurl'),PHP_URL_HOST);
436
- $platform = 'wordpress';
437
- $timezone = $_POST['ct_admin_timezone'];
438
 
439
- $result = CleantalkHelper::api_method__get_api_key(ct_get_admin_email(), $website, $platform, $timezone);
440
-
441
- if ($result)
442
- {
443
- ct_account_status_check();
444
- $result = json_decode($result, true);
445
-
446
- if (isset($result['data']) && is_array($result['data']))
447
- $result = $result['data'];
448
-
449
- if(isset($result['user_token'])){
450
- $ct_data['user_token'] = $result['user_token'];
451
- update_option('cleantalk_data', $ct_data);
452
- }
453
 
454
- if (isset($result['auth_key']) && !empty($result['auth_key'])){
455
- $_POST['cleantalk_settings']['apikey'] = $result['auth_key'];
456
- $ct_options['apikey']=$result['auth_key'];
457
- update_option('cleantalk_settings', $ct_options);
458
- }else{
459
- setcookie($ct_notice_autokey_label, (string) base64_encode($result['error_message']), 0, '/');
460
- }
461
- }else{
462
- setcookie($ct_notice_autokey_label, (string) base64_encode(sprintf(__('Unable to connect to %s.', 'cleantalk'), 'api.cleantalk.org')), 0, '/');
463
- }
464
- }
465
-
466
- //Account's status check if settings saved
467
- if (isset($_POST['cleantalk_settings']['apikey'])){
468
- ct_account_status_check();
469
- }
470
-
471
- // Getting dashboard widget statistics
472
- if(!empty($_POST['ct_brief_refresh']) || empty($ct_data['brief_data'])){
473
- $brief_data = CleantalkHelper::api_method__get_antispam_report_breif($ct_options['apikey']);
474
- $ct_data['brief_data'] = $brief_data;
475
- update_option('cleantalk_data', $ct_data);
476
- }
477
-
478
- $show_ct_notice_online = '';
479
- if (isset($_COOKIE[$ct_notice_online_label]))
480
- {
481
- if ($_COOKIE[$ct_notice_online_label] === 'BAD_KEY')
482
- {
483
- $show_ct_notice_online = 'N';
484
- }
485
- else if (time() - $_COOKIE[$ct_notice_online_label] <= 5)
486
- {
487
- $show_ct_notice_online = 'Y';
488
  }
489
- }
490
-
491
- if(stripos($_SERVER['REQUEST_URI'],'options.php')!==false || stripos($_SERVER['REQUEST_URI'],'options-general.php')!==false || stripos($_SERVER['REQUEST_URI'],'network/settings.php')!==false)
492
- {
493
-
494
- register_setting('cleantalk_settings', 'cleantalk_settings', 'ct_settings_validate');
495
- add_settings_section('cleantalk_settings_main', __($ct_plugin_name, 'cleantalk'), 'ct_section_settings_main', 'cleantalk');
496
-
497
- if(!empty($ct_data['debug']))
498
- add_settings_section('cleantalk_debug_section', '<hr>Debug', 'ct_section_debug', 'cleantalk');
499
- add_settings_section('cleantalk_settings_state', "<hr>".__('Protection is active', 'cleantalk'), 'ct_section_settings_state', 'cleantalk');
500
- add_settings_section('cleantalk_settings_banner', "<hr>", '', 'cleantalk');
501
- add_settings_section('cleantalk_settings_anti_spam', "<a href='#' class='ct_support_link'>".__('Advanced settings', 'cleantalk')."</a>", 'ct_section_settings_anti_spam', 'cleantalk');
502
 
503
- if(!defined('CLEANTALK_ACCESS_KEY'))
504
- {
505
- add_settings_field('cleantalk_apikey', __('Access key', 'cleantalk'), 'ct_input_apikey', 'cleantalk', 'cleantalk_settings_main');
506
- }
507
- else
508
- {
509
- add_settings_field('cleantalk_apikey', '', 'ct_input_apikey', 'cleantalk', 'cleantalk_settings_main');
510
  }
511
-
512
- if(ct_valid_key())
513
- add_settings_field('cleantalk_connection_reports', '', 'ct_report_builder', 'cleantalk', 'cleantalk_settings_main');
514
-
515
- //Forms for protection
516
- add_settings_field('cleantalk_title_fiels_for_protect', "", 'ct_input_what_fields_should_be_protected', 'cleantalk', 'cleantalk_settings_anti_spam');//Title settings
517
- add_settings_field('cleantalk_registrations_test', __('Registration forms', 'cleantalk'), 'ct_input_registrations_test', 'cleantalk', 'cleantalk_settings_anti_spam');
518
- add_settings_field('cleantalk_comments_test', __('Comments form', 'cleantalk'), 'ct_input_comments_test', 'cleantalk', 'cleantalk_settings_anti_spam');
519
- add_settings_field('cleantalk_contact_forms_test', __('Contact forms', 'cleantalk'), 'ct_input_contact_forms_test', 'cleantalk', 'cleantalk_settings_anti_spam');
520
- add_settings_field('cleantalk_general_contact_forms_test', __('Custom contact forms', 'cleantalk'), 'ct_input_general_contact_forms_test', 'cleantalk', 'cleantalk_settings_anti_spam');
521
- add_settings_field('cleantalk_wc_checkout_test', __('WooCommerce checkout form', 'cleantalk'), 'ct_input_wc_chekout_test', 'cleantalk', 'cleantalk_settings_anti_spam');
522
- add_settings_field('cleantalk_check_external', __('Protect external forms', 'cleantalk'), 'ct_input_check_external', 'cleantalk', 'cleantalk_settings_anti_spam');
523
- add_settings_field('cleantalk_check_internal', __('Protect internal forms', 'cleantalk'), 'ct_input_check_internal', 'cleantalk', 'cleantalk_settings_anti_spam');
524
-
525
- //Comments and messages
526
- add_settings_field('cleantalk_title_comments_and_messages', "", 'ct_input_comments_and_messages', 'cleantalk', 'cleantalk_settings_anti_spam');//Title settings
527
- add_settings_field('cleantalk_bp_private_messages', __('buddyPress private messages', 'cleantalk'), 'ct_input_bp_private_messages', 'cleantalk', 'cleantalk_settings_anti_spam');
528
- add_settings_field('cleantalk_check_comments_number', __("Don't check trusted user's comments", 'cleantalk'), 'ct_input_check_comments_number', 'cleantalk', 'cleantalk_settings_anti_spam');
529
- add_settings_field('cleantalk_remove_old_spam', __('Automatically delete spam comments', 'cleantalk'), 'ct_input_remove_old_spam', 'cleantalk', 'cleantalk_settings_anti_spam');
530
- add_settings_field('cleantalk_remove_links_from_comments', __('Remove links from approved comments', 'cleantalk'), 'ct_input_remove_links_from_approved_comments', 'cleantalk', 'cleantalk_settings_anti_spam');
531
- add_settings_field('cleantalk_show_check_links', __('Show links to check Emails, IPs for spam.', 'cleantalk'), 'ct_input_show_check_links', 'cleantalk', 'cleantalk_settings_anti_spam');
532
-
533
- //Data processing
534
- add_settings_field('cleantalk_title_data_processing', "", 'ct_input_data_processing', 'cleantalk', 'cleantalk_settings_anti_spam');//Title settings
535
- add_settings_field('cleantalk_protect_logged_in', __("Protect logged in Users", 'cleantalk'), 'ct_input_protect_logged_in', 'cleantalk', 'cleantalk_settings_anti_spam');
536
- add_settings_field('cleantalk_use_ajax', __('Use AJAX for JavaScript check', 'cleantalk'), 'ct_input_use_ajax', 'cleantalk', 'cleantalk_settings_anti_spam');
537
- add_settings_field('cleantalk_general_postdata_test', __('Check all post data', 'cleantalk'), 'ct_input_general_postdata_test', 'cleantalk', 'cleantalk_settings_anti_spam');
538
- add_settings_field('cleantalk_set_cookies', __("Set cookies", 'cleantalk'), 'ct_input_set_cookies', 'cleantalk', 'cleantalk_settings_anti_spam');
539
- add_settings_field('cleantalk_ssl_on', __("Use SSL", 'cleantalk'), 'ct_input_ssl_on', 'cleantalk', 'cleantalk_settings_anti_spam');
540
-
541
- //Administrator Panel
542
- add_settings_field('cleantalk_title_administrator_panel', "", 'ct_input_administrator_panel', 'cleantalk', 'cleantalk_settings_anti_spam');//Title settings
543
- add_settings_field('cleantalk_show_adminbar', __('Show statistics in admin bar', 'cleantalk'), 'ct_input_show_adminbar', 'cleantalk', 'cleantalk_settings_anti_spam');
544
- add_settings_field('cleantalk_all_time_counter', "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".__('Show All-time counter', 'cleantalk'), 'ct_input_all_time_counter', 'cleantalk', 'cleantalk_settings_anti_spam');
545
- add_settings_field('cleantalk_daily_conter', "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".__('Show 24 hours counter', 'cleantalk'), 'ct_input_daily_counter', 'cleantalk', 'cleantalk_settings_anti_spam');
546
- add_settings_field('cleantalk_sfw_counter', "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".__('SpamFireWall counter', 'cleantalk'), 'ct_input_sfw_counter', 'cleantalk', 'cleantalk_settings_anti_spam');
547
-
548
- // GDPR
549
- // add_settings_field('cleantalk_collect_details', __('Collect details about browsers', 'cleantalk'), 'ct_input_collect_details', 'cleantalk', 'cleantalk_settings_anti_spam');
550
- // add_settings_field('cleantalk_connection_reports', __('Send connection reports', 'cleantalk'), 'ct_send_connection_reports', 'cleantalk', 'cleantalk_settings_anti_spam');
551
-
552
- // Misc
553
- add_settings_field('cleantalk_collect_details', __('Collect details about browsers', 'cleantalk'), 'ct_input_collect_details', 'cleantalk', 'cleantalk_settings_anti_spam');
554
- add_settings_field('cleantalk_connection_reports', __('Send connection reports', 'cleantalk'), 'ct_send_connection_reports', 'cleantalk', 'cleantalk_settings_anti_spam');
555
- add_settings_field('cleantalk_async_js', __('Async JavaScript loading', 'cleantalk'), 'ct_async_js', 'cleantalk', 'cleantalk_settings_anti_spam');
556
- add_settings_field('cleantalk_show_link', __('Tell others about CleanTalk', 'cleantalk'), 'ct_input_show_link', 'cleantalk', 'cleantalk_settings_banner');
557
- add_settings_field('cleantalk_spam_firewall', __('SpamFireWall', 'cleantalk'), 'ct_input_spam_firewall', 'cleantalk', 'cleantalk_settings_banner');
558
- }
559
- }
560
-
561
- /**
562
- * Admin callback function - Displays description of 'main' plugin parameters section
563
- */
564
- function ct_section_settings_main() {
565
- /*
566
- $ct_options=ct_get_options();
567
-
568
- $is_wpmu = false;
569
- if(defined('CLEANTALK_ACCESS_KEY')) {
570
- $is_wpmu = true;
571
  }
572
 
573
- if (ct_valid_key($ct_options['apikey']) !== false || $is_wpmu) {
574
- return true;
575
- }
576
- $message = "<p>Please wait we are registering account welcome@cleantalk.org to finish plugin setup...</p>";
577
- echo $message;
578
-
579
- ?>
580
- <script type="text/javascript">
581
- var api_url = 'https://localhost/test.php';
582
-
583
- var req ;
584
-
585
- // Browser compatibility check
586
- if (window.XMLHttpRequest) {
587
- req = new XMLHttpRequest();
588
- } else if (window.ActiveXObject) {
589
-
590
- try {
591
- req = new ActiveXObject("Msxml2.XMLHTTP");
592
- } catch (e) {
593
-
594
- try {
595
- req = new ActiveXObject("Microsoft.XMLHTTP");
596
- } catch (e) {}
597
- }
598
-
599
- }
600
-
601
-
602
- var req = new XMLHttpRequest();
603
- req.open("GET", api_url, true);
604
- req.onreadystatechange = function () {
605
- console.log(req.getResponseHeader('HTTP_COOKIE'));
606
- }
607
-
608
- req.send(null);
609
- </script>
610
-
611
- <?php
612
- */
613
- return true;
614
- }
615
-
616
- /**
617
- * Admin callback function - Displays description of 'anti-spam' plugin parameters section
618
- */
619
- function ct_section_settings_anti_spam() {
620
  return true;
621
  }
622
 
623
- add_action( 'admin_bar_menu', 'ct_add_admin_menu', 999 );
624
-
625
- function ct_input_all_time_counter() {
626
- global $ct_options, $ct_data;
627
-
628
- $ct_options = ct_get_options();
629
- $ct_data = ct_get_data();
630
-
631
- $value=(isset($ct_options['all_time_counter']) ? @intval($ct_options['all_time_counter']) : 0);
632
- $value2=(isset($ct_options['show_adminbar']) ? @intval($ct_options['show_adminbar']) : 0);
633
-
634
- echo "<input type='radio' class='ct-depends-of-show-adminbar' id='cleantalk_all_time_counter1' name='cleantalk_settings[all_time_counter]' value='1' ".($value=='1'?'checked':'').($value2=='0'?' disabled':'')." /><label for='cleantalk_all_time_counter1'> ".__('Yes')."</label>";
635
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
636
- echo "<input type='radio' class='ct-depends-of-show-adminbar' id='cleantalk_all_time_counter0' name='cleantalk_settings[all_time_counter]' value='0' ".($value=='0'?'checked':'').($value2=='0'?' disabled':'')." /><label for='cleantalk_all_time_counter0'> ".__('No')."</label>";
637
- ct_add_descriptions_to_fields(__('Display all-time requests counter in the admin bar. Counter displays number of requests since plugin installation.', 'cleantalk'));
638
- }
639
-
640
- function ct_input_daily_counter() {
641
- global $ct_options, $ct_data;
642
-
643
- $ct_options = ct_get_options();
644
- $ct_data = ct_get_data();
645
-
646
- $value=(isset($ct_options['daily_counter']) ? @intval($ct_options['daily_counter']) : 0);
647
- $value2=(isset($ct_options['show_adminbar']) ? @intval($ct_options['show_adminbar']) : 0);
648
-
649
- echo "<input type='radio' class='ct-depends-of-show-adminbar' id='cleantalk_daily_counter1' name='cleantalk_settings[daily_counter]' value='1' ".($value=='1'?'checked':'').($value2=='0'?' disabled':'')." /><label for='cleantalk_daily_counter1'> ".__('Yes')."</label>";
650
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
651
- echo "<input type='radio' class='ct-depends-of-show-adminbar' id='cleantalk_daily_counter0' name='cleantalk_settings[daily_counter]' value='0' ".($value=='0'?'checked':'').($value2=='0'?' disabled':'')." /><label for='cleantalk_daily_counter0'> ".__('No')."</label>";
652
- ct_add_descriptions_to_fields(__('Display daily requests counter in the admin bar. Counter displays number of requests of the past 24 hours.', 'cleantalk'));
653
- }
654
-
655
- function ct_input_sfw_counter() {
656
- global $ct_options, $ct_data;
657
-
658
- $ct_options = ct_get_options();
659
- $ct_data = ct_get_data();
660
-
661
- $value=(isset($ct_options['sfw_counter']) ? @intval($ct_options['sfw_counter']) : 0);
662
- $value2=(isset($ct_options['show_adminbar']) ? @intval($ct_options['show_adminbar']) : 0);
663
-
664
- echo "<input type='radio' class='ct-depends-of-show-adminbar' id='cleantalk_sfw_counter1' name='cleantalk_settings[sfw_counter]' value='1' ".($value=='1'?'checked':'').($value2=='0'?' disabled':'')." /><label for='cleantalk_sfw_counter1'> ".__('Yes')."</label>";
665
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
666
- echo "<input type='radio' class='ct-depends-of-show-adminbar' id='cleantalk_sfw_counter0' name='cleantalk_settings[sfw_counter]' value='0' ".($value=='0'?'checked':'').($value2=='0'?' disabled':'')." /><label for='cleantalk_sfw_counter0'> ".__('No')."</label>";
667
- ct_add_descriptions_to_fields(__('Display all-time requests counter in the admin bar. Counter displays number of requests since plugin installation.', 'cleantalk'));
668
- }
669
-
670
- function ct_send_connection_reports() {
671
- global $ct_options, $ct_data;
672
-
673
- $ct_options = ct_get_options();
674
- $ct_data = ct_get_data();
675
-
676
- $value = $value=(isset($ct_options['send_connection_reports']) ? @intval($ct_options['send_connection_reports']) : 0);
677
- echo "<div id='cleantalk_anchor3' style='display:none'></div>";
678
- echo "<input type='checkbox' id='connection_reports1' name='cleantalk_settings[send_connection_reports]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='connection_reports1'> " . __('Send connection reports', 'cleantalk') . "</label>";
679
- ct_add_descriptions_to_fields(__("Checking this box you allow plugin to send the information about your connection. The option in a beta state.", 'cleantalk'));
680
- echo "<script>
681
- jQuery(document).ready(function(){
682
- jQuery('#cleantalk_anchor3').parent().parent().children().first().hide();
683
- jQuery('#cleantalk_anchor3').parent().css('padding-left','0px');
684
- jQuery('#cleantalk_anchor3').parent().attr('colspan', '2');
685
- });
686
- </script>";
687
- }
688
-
689
- function ct_async_js() {
690
-
691
- global $ct_options, $ct_data;
692
-
693
- $ct_options = ct_get_options();
694
- $ct_data = ct_get_data();
695
-
696
- $value = $value=(isset($ct_options['async_js']) ? @intval($ct_options['async_js']) : 0);
697
- echo "<div id='cleantalk_anchor4' style='display:none'></div>";
698
- echo "<input type='checkbox' id='async_js' name='cleantalk_settings[async_js]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='async_js'> " . __('Async script loading', 'cleantalk') . "</label>";
699
- ct_add_descriptions_to_fields(__('Use async loading for CleanTalk\'s scripts. Warning: This could reduce filtration quality.', 'cleantalk'));
700
- echo "<script>
701
- jQuery(document).ready(function(){
702
- jQuery('#cleantalk_anchor4').parent().parent().children().first().hide();
703
- jQuery('#cleantalk_anchor4').parent().css('padding-left','0px');
704
- jQuery('#cleantalk_anchor4').parent().attr('colspan', '2');
705
- });
706
- </script>";
707
- }
708
-
709
- function ct_input_get_premium($print = true){
710
 
711
- global $ct_data;
712
 
713
- $ct_data = ct_get_data();
714
-
715
- $out = '';
716
-
717
- if(!empty($ct_data['license_trial']) && !empty($ct_data['user_token'])){
718
- $out = '<b style="display: inline-block; margin-top: 10px;">'
719
  .($print ? __('Make it right!', 'cleantalk').' ' : '')
720
  .sprintf(
721
  __('%sGet premium%s', 'cleantalk'),
722
- '<a href="https://cleantalk.org/my/bill/recharge?user_token='.$ct_data['user_token'].'" target="_blank">',
723
  '</a>'
724
  )
725
  .'</b>';
@@ -731,70 +442,62 @@ function ct_input_get_premium($print = true){
731
  return $out;
732
  }
733
 
734
- function ct_add_admin_menu( $wp_admin_bar ) {
735
- // add a parent item
736
- global $ct_options, $ct_data;
737
 
738
- $ct_options = ct_get_options();
739
 
740
- if (current_user_can('activate_plugins') && $ct_options['show_adminbar'] == 1 && (ct_valid_key($ct_options['apikey']) !== false || (defined('CLEANTALK_SHOW_ADMIN_BAR_FORCE') && CLEANTALK_SHOW_ADMIN_BAR_FORCE))) {
741
- $ct_data=ct_get_data();
742
-
743
  //Reset or create user counter
744
  if(!empty($_GET['ct_reset_user_counter'])){
745
- $ct_data['user_counter']['accepted'] = 0;
746
- $ct_data['user_counter']['blocked'] = 0;
747
- $ct_data['user_counter']['since'] = date('d M');
748
- update_option('cleantalk_data', $ct_data);
749
  }
750
  //Reset or create all counters
751
  if(!empty($_GET['ct_reset_all_counters'])){
752
- $ct_data['sfw_counter'] = array('all' => 0, 'blocked' => 0);
753
- $ct_data['all_time_counter'] = array('accepted' => 0, 'blocked' => 0);
754
- $ct_data['user_counter'] = array('all' => 0, 'accepted' => 0, 'blocked' => 0, 'since' => date('d M'));
755
- $ct_data['array_accepted'] = array();
756
- $ct_data['array_blocked'] = array();
757
- $ct_data['current_hour'] = '';
758
- update_option('cleantalk_data', $ct_data);
759
- }
760
- if (!empty($_GET['ct_send_connection_report'])){
761
- ct_mail_send_connection_report();
762
- }
763
  //Compile user's counter string
764
- $user_counter=Array('accepted'=>$ct_data['user_counter']['accepted'], 'blocked'=>$ct_data['user_counter']['blocked'], 'all'=>$ct_data['user_counter']['accepted'] + $ct_data['user_counter']['blocked'], 'since'=>$ct_data['user_counter']['since']);
765
  //Previous version $user_counter_str='<span style="color: white;">Since '.$user_counter['since'].': ' .$user_counter['all']*/. '</span> / <span style="color: green;">' .$user_counter['accepted']. '</span> / <span style="color: red;">' .$user_counter['blocked']. '</span>';
766
  $user_counter_str='<span style="color: white;">' . __('Since', 'cleantalk') . '&nbsp;' . $user_counter['since'].': </span><span style="color: green;">' .$user_counter['accepted']. '</span> / <span style="color: red;">' .$user_counter['blocked']. '</span>';
767
 
768
  $all_time_counter_str='';
769
  //Don't compile if all time counter disabled
770
- if(isset($ct_options['all_time_counter']) && $ct_options['all_time_counter']=='1'){
771
- $all_time_counter=Array('accepted'=>$ct_data['all_time_counter']['accepted'], 'blocked'=>$ct_data['all_time_counter']['blocked'], 'all'=>$ct_data['all_time_counter']['accepted'] + $ct_data['all_time_counter']['blocked']);
772
  $all_time_counter_str='<span style="color: white;" title="'.__('All / Allowed / Blocked submissions. The number of submissions is being counted since CleanTalk plugin installation.', 'cleantalk').'"><span style="color: white;"> | ' . __('All', 'cleantalk') . ': ' .$all_time_counter['all']. '</span> / <span style="color: green;">' .$all_time_counter['accepted']. '</span> / <span style="color: red;">' .$all_time_counter['blocked']. '</span></span>';
773
  }
774
 
775
  $daily_counter_str='';
776
  //Don't compile if daily counter disabled
777
- if(isset($ct_options['daily_counter']) && $ct_options['daily_counter']=='1'){
778
- $daily_counter=Array('accepted'=>array_sum($ct_data['array_accepted']), 'blocked'=>array_sum($ct_data['array_blocked']), 'all'=>array_sum($ct_data['array_accepted']) + array_sum($ct_data['array_blocked']));
779
  //Previous version $daily_counter_str='<span style="color: white;" title="'.__('All / Allowed / Blocked submissions. The number of submissions for past 24 hours. ', 'cleantalk').'"><span style="color: white;"> | Day: ' .$daily_counter['all']. '</span> / <span style="color: green;">' .$daily_counter['accepted']. '</span> / <span style="color: red;">' .$daily_counter['blocked']. '</span></span>';
780
  $daily_counter_str='<span style="color: white;" title="'.__('Allowed / Blocked submissions. The number of submissions for past 24 hours. ', 'cleantalk').'"><span style="color: white;"> | ' . __('Day', 'cleantalk') . ': </span><span style="color: green;">' .$daily_counter['accepted']. '</span> / <span style="color: red;">' .$daily_counter['blocked']. '</span></span>';
781
  }
782
  $sfw_counter_str='';
783
  //Don't compile if SFW counter disabled
784
- if(isset($ct_options['sfw_counter']) && intval($ct_options['sfw_counter']) == 1 && isset($ct_options['spam_firewall']) && intval($ct_options['spam_firewall']) == 1){
785
- $sfw_counter=Array('all'=>$ct_data['sfw_counter']['all'], 'blocked'=>$ct_data['sfw_counter']['blocked']);
786
  $sfw_counter_str='<span style="color: white;" title="'.__('All / Blocked events. Access attempts regitred by SpamFireWall counted since the last plugin activation.', 'cleantalk').'"><span style="color: white;"> | SpamFireWall: ' .$sfw_counter['all']. '</span> / <span style="color: red;">' .$sfw_counter['blocked']. '</span></span>';
787
  }
788
 
789
- $user_token = (isset($ct_data['user_token']) && $ct_data['user_token'] != '' ? "&user_token={$ct_data['user_token']}" : "");
790
-
791
  $args = array(
792
  'id' => 'ct_parent_node',
793
  'title' => '<img src="' . plugin_dir_url(__FILE__) . 'images/logo_small1.png" alt="" height="" style="margin-top:9px; float: left;" />'
794
  .'<div style="margin: auto 7px;" class="ab-item alignright">'
795
  .'<div class="ab-label" id="ct_stats">'
796
- .(isset($ct_data['show_ct_notice_trial']) && $ct_data['show_ct_notice_trial'] == 1
797
- ? "<span><a style='color: red;' 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\">Renew Anti-Spam</a></span>"
798
  : '<span style="color: white;" title="'.__('Allowed / Blocked submissions. The number of submissions is being counted since ', 'cleantalk').' '.$user_counter['since'].'">'.$user_counter_str.'</span> '.$daily_counter_str.$all_time_counter_str.$sfw_counter_str
799
  )
800
  .'</div>'
@@ -805,7 +508,7 @@ function ct_add_admin_menu( $wp_admin_bar ) {
805
  // add a child item to our parent item
806
  $args = array(
807
  'id' => 'ct_dashboard_link',
808
- 'title' => '<a href="https://cleantalk.org/my/?user_token='.@$ct_data['user_token'].'&utm_source=wp-backend&utm_medium=admin-bar&cp_mode=antispam " target="_blank">CleanTalk '.__('dashboard', 'cleantalk').'</a>',
809
  'parent' => 'ct_parent_node'
810
  );
811
  $wp_admin_bar->add_node( $args );
@@ -872,1003 +575,19 @@ function ct_add_admin_menu( $wp_admin_bar ) {
872
  }
873
  }
874
 
875
-
876
- // Prints debug information. Support function.
877
- function ct_section_debug(){
878
-
879
- $ct_options = ct_get_options();
880
- $ct_data = ct_get_data();
881
-
882
- if(isset($ct_data['ct_debug_reset']) && $ct_data['ct_debug_reset']){
883
- unset($ct_data['debug'], $ct_data['ct_debug_reset']);
884
- update_option('cleantalk_data', $ct_data);
885
- return;
886
- }
887
-
888
-
889
- echo "<h4>Constants:</h4>";
890
- echo 'CLEANTALK_AJAX_USE_BUFFER '. (defined('CLEANTALK_AJAX_USE_BUFFER') ? (CLEANTALK_AJAX_USE_BUFFER ? 'true' : 'flase') : 'NOT_DEFINED')."<br>";
891
- echo 'CLEANTALK_AJAX_USE_FOOTER_HEADER '. (defined('CLEANTALK_AJAX_USE_FOOTER_HEADER') ? (CLEANTALK_AJAX_USE_FOOTER_HEADER ? 'true' : 'flase') : 'NOT_DEFINED')."<br>";
892
- echo 'CLEANTALK_ACCESS_KEY '. (defined('CLEANTALK_ACCESS_KEY') ? (CLEANTALK_ACCESS_KEY ? CLEANTALK_ACCESS_KEY : 'flase') : 'NOT_DEFINED')."<br>";
893
- echo 'CLEANTALK_CHECK_COMMENTS_NUMBER '. (defined('CLEANTALK_CHECK_COMMENTS_NUMBER') ? (CLEANTALK_CHECK_COMMENTS_NUMBER ? CLEANTALK_CHECK_COMMENTS_NUMBER : 0) : 'NOT_DEFINED')."<br>";
894
- echo 'CLEANTALK_CHECK_MESSAGES_NUMBER '. (defined('CLEANTALK_CHECK_MESSAGES_NUMBER') ? (CLEANTALK_CHECK_MESSAGES_NUMBER ? CLEANTALK_CHECK_MESSAGES_NUMBER : 0) : 'NOT_DEFINED')."<br>";
895
- echo 'CLEANTALK_PLUGIN_DIR '. (defined('CLEANTALK_PLUGIN_DIR') ? (CLEANTALK_PLUGIN_DIR ? CLEANTALK_PLUGIN_DIR : 'flase') : 'NOT_DEFINED')."<br>";
896
- echo 'WP_ALLOW_MULTISITE '. (defined('WP_ALLOW_MULTISITE') ? (WP_ALLOW_MULTISITE ? 'true' : 'flase') : 'NOT_DEFINED');
897
-
898
- echo "<h4>Debug log: <input type='submit' value='Drop debug data' name='ct_debug_reset' style='font-size: 11px; padding: 1px;'></h4>";
899
- echo "<div style='height: 500px; width: 80%; overflow: auto;'>";
900
-
901
- $output = print_r($ct_data['debug'], true);
902
- $output = str_replace("\n", "<br>", $output);
903
- $output = preg_replace("/[^\S]{4}/", "&nbsp;&nbsp;&nbsp;&nbsp;", $output);
904
- echo "$output";
905
-
906
- echo "</div>";
907
- }
908
-
909
  /**
910
- * Admin callback function - Displays description of 'state' plugin parameters section
 
 
911
  */
912
- function ct_section_settings_state() {
913
- global $ct_options, $ct_data, $wpdb;
914
-
915
- $ct_options = ct_get_options();
916
- $ct_data = ct_get_data();
917
-
918
- $ct_data['moderate_ip'] = isset($ct_data['moderate_ip']) ? $ct_data['moderate_ip'] : 0;
919
 
920
- $path_to_img = plugin_dir_url(__FILE__) . "images/";
921
-
922
- $img = $path_to_img."yes.png";
923
- $img_no = $path_to_img."no.png";
924
- $img_no_gray = $path_to_img."no_gray.png";
925
- $color="black";
926
- $test_failed=false;
927
-
928
- if(trim($ct_options['apikey'])=='')
929
- {
930
- $img = $path_to_img."yes_gray.png";
931
- $img_no = $path_to_img."no_gray.png";
932
- $color="gray";
933
- }
934
- if(isset($ct_data['testing_failed'])&&$ct_data['testing_failed']==1)
935
- {
936
- $img=$path_to_img."no.png";
937
- $img_no=$path_to_img."no.png";
938
- $color="black";
939
- $test_failed=true;
940
- }
941
- if($ct_data['moderate_ip'] == 1)
942
- {
943
- $img = $path_to_img."yes.png";
944
- $img_no = $path_to_img."no.png";
945
- $color="black";
946
- $test_failed=false;
947
- }
948
- print "<div style='color:$color'>";
949
-
950
- $ct_moderate = isset($ct_data['moderate_ip']) && $ct_data['moderate_ip'] == 1 ? true : false;
951
- $show_ct_notice_auto_update = isset($ct_data['show_ct_notice_auto_update']) ? $ct_data['show_ct_notice_auto_update'] : 0;
952
- $auto_update_app = isset($ct_data['auto_update_app']) ? $ct_data['auto_update_app'] : 0;
953
-
954
- echo '<img class="apbct_status_icon" src="'.($ct_options['registrations_test']==1 || $ct_moderate ? $img : $img_no).'" />'.__('Registration forms', 'cleantalk');
955
- echo '<img class="apbct_status_icon" src="'.($ct_options['comments_test']==1 || $ct_moderate ? $img : $img_no).'"/>'.__('Comments forms', 'cleantalk');
956
- echo '<img class="apbct_status_icon" src="'.($ct_options['contact_forms_test']==1 || $ct_moderate ? $img : $img_no).'"/>'.__('Contact forms', 'cleantalk');
957
- echo '<img class="apbct_status_icon" src="'.($ct_options['general_contact_forms_test']==1 || $ct_moderate ? $img : $img_no).'"/>'.__('Custom contact forms', 'cleantalk');
958
-
959
- // SFW + current network count
960
- $sfw_netwoks_amount = $wpdb->get_results("SELECT count(*) AS cnt FROM `".$wpdb->base_prefix."cleantalk_sfw`", ARRAY_A);
961
- $alt_for_sfw = sprintf(__('Networks in database: %d.', 'cleantalk'), $sfw_netwoks_amount[0]['cnt']);
962
- echo '<img class="apbct_status_icon" src="'.($ct_options['spam_firewall']==1 || $ct_moderate ? $img : $img_no).'" title="'.($ct_options['spam_firewall']==1 || $ct_moderate ? $alt_for_sfw : '').'"/>'.__('SpamFireWall', 'cleantalk');
963
-
964
- // Autoupdate status
965
- if($show_ct_notice_auto_update == 1){
966
- echo '<img class="apbct_status_icon" src="'.($auto_update_app == 1 ? $img : ($auto_update_app == -1 ? $img_no : $img_no_gray)).'"/>'.__('Auto update', 'cleantalk')
967
- .' <sup><a href="http://cleantalk.org/help/cleantalk-auto-update" target="_blank">?</a></sup>';
968
- }
969
-
970
- // WooCommerce
971
- if(class_exists('WooCommerce'))
972
- echo '<img class="apbct_status_icon" src="'.($ct_options['wc_checkout_test']==1 || $ct_moderate ? $img : $img_no).'"/>'.__('WooCommerce checkout form', 'cleantalk');
973
-
974
- if($ct_data['moderate_ip'] == 1)
975
- print "<br /><br />The anti-spam service is paid by your hosting provider. License #".$ct_data['ip_license'].".<br />";
976
-
977
- print "</div>";
978
-
979
- return true;
980
- }
981
-
982
- /**
983
- * Admin callback function - Displays description of 'autodel' plugin parameters section
984
- */
985
- function ct_section_settings_autodel() {
986
- return true;
987
- }
988
-
989
- function ct_report_builder() {
990
-
991
- global $ct_options, $ct_data;
992
-
993
- $ct_options=ct_get_options();
994
- $ct_data=ct_get_data();
995
-
996
- if (isset($ct_data['connection_reports'])){
997
-
998
- if ($ct_data['connection_reports']['negative'] == 0){
999
- _e('There are no failed connections to CleanTalk servers.', 'cleantalk');
1000
- }else{
1001
-
1002
- echo "<table id='negative_reports_table' style='display: none;'>
1003
- <tr>
1004
- <td>#</td>
1005
- <td><b>Date</b></td>
1006
- <td><b>Page URL</b></td>
1007
- <td><b>Report</b></td>
1008
- </tr>";
1009
- foreach($ct_data['connection_reports']['negative_report'] as $key => $report){
1010
- echo "<tr><td>".($key+1).".</td><td>".$report['date']."</td><td>".$report['page_url']."</td><td>".$report['lib_report']."</td></tr>";
1011
- }
1012
- echo "</table>";
1013
- echo "<br/><a class='cleantalk_manual_link' href='?page=cleantalk&ct_send_connection_report=1'>".__('Send report', 'cleantalk')."</a>";
1014
- }
1015
-
1016
- }
1017
- echo "<script>
1018
- jQuery(document).ready(function(){
1019
- jQuery('.form-table tr').eq(1).children().first().hide();
1020
- });
1021
- </script>";
1022
- }
1023
-
1024
- function ct_mail_send_connection_report() {
1025
- global $ct_options, $ct_data;
1026
-
1027
- $ct_options = ct_get_options();
1028
- $ct_data=ct_get_data();
1029
- if ((isset($ct_options['send_connection_reports']) && @intval($ct_options['send_connection_reports']) == 1 && $ct_data['connection_reports']['negative']>0) || !empty($_GET['ct_send_connection_report']))
1030
- {
1031
- $to = "welcome@cleantalk.org" ;
1032
- $subject = "Connection report for ".$_SERVER['HTTP_HOST'];
1033
- $message = '
1034
- <html>
1035
- <head>
1036
- <title></title>
1037
- </head>
1038
- <body>
1039
- <p>From '.$ct_data['connection_reports']['since'].' to '.date('d M').' has been made '.($ct_data['connection_reports']['success']+$ct_data['connection_reports']['negative']).' calls, where '.$ct_data['connection_reports']['success'].' were success and '.$ct_data['connection_reports']['negative'].' were negative</p>
1040
- <p>Negative report:</p>
1041
- <table> <tr>
1042
- <td>&nbsp;</td>
1043
- <td><b>Date</b></td>
1044
- <td><b>Page URL</b></td>
1045
- <td><b>Library report</b></td>
1046
- </tr>
1047
- ';
1048
- foreach ($ct_data['connection_reports']['negative_report'] as $key=>$report)
1049
- {
1050
- $message.= "<tr><td>".($key+1).".</td><td>".$report['date']."</td><td>".$report['page_url']."</td><td>".$report['lib_report']."</td></tr>";
1051
- }
1052
- $message.='</table></body></html>';
1053
-
1054
- $headers = "Content-type: text/html; charset=windows-1251 \r\n";
1055
- $headers .= "From: ".get_option('admin_email');
1056
- mail($to, $subject, $message, $headers);
1057
- }
1058
-
1059
- $ct_data['connection_reports']['success'] = 0;
1060
- $ct_data['connection_reports']['negative'] = 0;
1061
- $ct_data['connection_reports']['negative_report'] = array();
1062
- $ct_data['connection_reports']['since'] = date('d M');
1063
- update_option('cleantalk_data', $ct_data);
1064
- CleantalkCron::updateTask('send_connection_report', 'ct_mail_send_connection_report', 3600);
1065
-
1066
- }
1067
- /**
1068
- * Admin callback function - Displays inputs of 'apikey' plugin parameter
1069
- */
1070
- function ct_input_apikey() {
1071
- global $ct_options, $ct_data, $ct_notice_online_label;
1072
-
1073
- $ct_options=ct_get_options();
1074
- $ct_data=ct_get_data();
1075
-
1076
- $blocked = isset($ct_data['admin_blocked']) ? $ct_data['admin_blocked'] : 0;
1077
-
1078
- if($blocked > 0){
1079
- echo "<script>var cleantalk_blocked_message=\"<div style='height:24px;width:100%;display:table-cell; vertical-align:middle;'><span>CleanTalk ";
1080
- printf(
1081
- /* translators: %s: Number of spam messages */
1082
- __( 'has blocked <b>%s</b> spam.', 'cleantalk' ),
1083
- number_format($blocked)
1084
- );
1085
- echo "</span></div><br />\";\n";
1086
- }else{
1087
- echo "<script>var cleantalk_blocked_message=\"\";\n";
1088
- }
1089
- echo "var cleantalk_statistics_link=\"<a class='cleantalk_manual_link' target='__blank' href='https://cleantalk.org/my?user_token=".@$ct_data['user_token']."&cp_mode=antispam'>".__('Click here to get anti-spam statistics', 'cleantalk')."</a>\";";
1090
- echo "var cleantalk_support_link=\"<a class='cleantalk_auto_link' target='__blank' href='https://wordpress.org/support/plugin/cleantalk-spam-protect'>".__('Support', 'cleantalk')."</a>\";
1091
- </script>";
1092
-
1093
- $value = $ct_options['apikey'];
1094
- $def_value = '';
1095
- $is_wpmu=false;
1096
- if(!defined('CLEANTALK_ACCESS_KEY')){
1097
- echo "<input id='cleantalk_apikey' name='cleantalk_settings[apikey]' size='20' type='text' value='$value' style=\"font-size: 14pt;\" placeholder='" . __('Enter the key', 'cleantalk') . "' />";
1098
- echo "<script>var cleantalk_wpmu=false;</script>";
1099
- }else{
1100
- echo "<script>var cleantalk_wpmu=true;</script>";
1101
- $is_wpmu = true;
1102
- }
1103
-
1104
- //echo "<script src='".plugins_url( 'cleantalk-admin.js', __FILE__ )."?ver=".$cleantalk_plugin_version."'></script>\n";
1105
- if (ct_valid_key($value) === false && !$is_wpmu){
1106
- echo "<script>var cleantalk_good_key=false;</script>";
1107
- if (function_exists('curl_init') && function_exists('json_decode')){
1108
- echo '<br /><br />';
1109
- echo "<a target='__blank' style='' href='https://cleantalk.org/register?platform=wordpress&email=".urlencode(ct_get_admin_email())."&website=".urlencode(parse_url(get_option('siteurl'),PHP_URL_HOST))."'><input type='button' class='cleantalk_auto_link' value='".__('Get access key manually', 'cleantalk')."' /></a>";
1110
- if($ct_data['ip_license'] == 0){
1111
- echo "&nbsp;" . __("or") . "&nbsp;";
1112
- echo '<input id="get_key_auto" name="get_apikey_auto" type="submit" class="cleantalk_manual_link" value="' . __('Get access key automatically', 'cleantalk') . '" />';
1113
- }
1114
- echo '<input type="hidden" id="ct_admin_timezone" name="ct_admin_timezone" value="null" />';
1115
- echo "<br />";
1116
- echo "<br />";
1117
-
1118
- ct_add_descriptions_to_fields(sprintf(__('Admin e-mail (%s) will be used for registration', 'cleantalk'), ct_get_admin_email()));
1119
- echo '<div>';
1120
- echo '<input checked type="checkbox" id="license_agreed" onclick="spbcSettingsDependencies(\'get_key_auto\');"/>';
1121
- echo '<label for="spbc_license_agreed">';
1122
- printf(
1123
- __('I agree with %sPrivacy Policy%s of %sLicense Agreement%s', 'security-malware-firewall'),
1124
- '<a href="https://cleantalk.org/publicoffer#privacy" target="_blank" style="color:#66b;">', '</a>',
1125
- '<a href="https://cleantalk.org/publicoffer" target="_blank" style="color:#66b;">', '</a>'
1126
- );
1127
- echo "</label>";
1128
- echo '</div>';
1129
- }
1130
- } else {
1131
- $cleantalk_support_links = "<br /><div>";
1132
- $cleantalk_support_links .= "<a href='#' id='cleantalk_access_key_link' class='ct_support_link'>" . __("Show the access key", 'cleantalk') . "</a>";
1133
- $cleantalk_support_links .= "&nbsp;&nbsp;";
1134
- $cleantalk_support_links .= "&nbsp;&nbsp;";
1135
- $cleantalk_support_links .= "<a href='edit-comments.php?page=ct_check_spam' class='ct_support_link'>" . __("Check comments for spam", 'cleantalk') . "</a>";
1136
- $cleantalk_support_links .= "<a href='users.php?page=ct_check_users' class='ct_support_link'>" . __("Check users for spam", 'cleantalk') . "</a>";
1137
- $cleantalk_support_links .= "&nbsp;&nbsp;";
1138
- $cleantalk_support_links .= "&nbsp;&nbsp;";
1139
- $cleantalk_support_links .= "<a href='#' id='cleantalk_negative_report_link' class='ct_support_link'>" . __("Negative report", 'cleantalk') . "</a>";
1140
- $cleantalk_support_links .= "</div>";
1141
- echo "<script type=\"text/javascript\">var cleantalk_good_key=true; var cleantalk_support_links = \"$cleantalk_support_links\";</script>";
1142
- }
1143
-
1144
- if($ct_data['ip_license']){
1145
- $cleantalk_support_links = "<br /><div>";
1146
- $cleantalk_support_links .= "<a href='#' id='cleantalk_access_key_link' class='ct_support_link'>" . __("Show the access key", 'cleantalk') . "</a>";
1147
- $cleantalk_support_links .= "</div>";
1148
- echo "<script type=\"text/javascript\">var cleantalk_good_key=true; var cleantalk_support_links = \"$cleantalk_support_links\";</script>";
1149
- }
1150
-
1151
- $test_failed = (!empty($ct_data['testing_failed']) ? true : false);
1152
- $moderate_ip = (!empty($ct_data['moderate_ip']) ? true : false);
1153
-
1154
- //Testing failed output
1155
- if($test_failed && !$moderate_ip){
1156
- echo "<script type=\"text/javascript\">var cleantalk_testing_failed = true;</script>";
1157
- echo "<br>";
1158
- echo "<div class='ct-warning-test-failed'>";
1159
- printf(__('Testing is failed, please, check the settings! Tech support %s%s%s.', 'cleantalk'), '<a target="_blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">', 'https://wordpress.org/support/plugin/cleantalk-spam-protect', '</a>');
1160
- echo "</div>";
1161
- }else{
1162
- echo "<script type=\"text/javascript\">var cleantalk_testing_failed = false;</script>";
1163
- }
1164
- }
1165
-
1166
- /**
1167
- * Admin callback function - Displays inputs of 'comments_test' plugin parameter
1168
- */
1169
- function ct_input_comments_test() {
1170
- global $ct_options, $ct_data;
1171
-
1172
- $ct_options = ct_get_options();
1173
- $ct_data = ct_get_data();
1174
-
1175
- $value = $ct_options['comments_test'];
1176
- echo "<input type='radio' id='cleantalk_comments_test1' name='cleantalk_settings[comments_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_comments_test1'> " . __('Yes') . "</label>";
1177
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1178
- echo "<input type='radio' id='cleantalk_comments_test0' name='cleantalk_settings[comments_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_comments_test0'> " . __('No') . "</label>";
1179
- ct_add_descriptions_to_fields(__('WordPress, JetPack, WooCommerce.', 'cleantalk'));
1180
- }
1181
-
1182
- //Titles for advanced settings.
1183
- function ct_input_what_fields_should_be_protected(){
1184
- echo "<h3>".__('Forms to protect', 'cleantalk')."</h3>";
1185
- }
1186
-
1187
- function ct_input_comments_and_messages(){
1188
- echo "<h3>".__('Comments and messages', 'cleantalk')."</h3>";
1189
- }
1190
-
1191
- function ct_input_data_processing(){
1192
- echo "<h3>".__('Data processing', 'cleantalk')."</h3>";
1193
- }
1194
-
1195
- function ct_input_administrator_panel(){
1196
- echo "<h3>".__('Admin bar', 'cleantalk')."</h3>";
1197
- }
1198
-
1199
- /**
1200
- * Admin callback function - Displays inputs of 'comments_test' plugin parameter
1201
- */
1202
- function ct_input_remove_links_from_approved_comments() {
1203
- global $ct_options, $ct_data;
1204
-
1205
- $ct_options = ct_get_options();
1206
- $ct_data = ct_get_data();
1207
-
1208
- $value = $ct_options['remove_comments_links'];
1209
- echo "<input type='radio' id='cleantalk_remove_links_from_comments1' name='cleantalk_settings[remove_comments_links]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_remove_links_from_comments1'> " . __('Yes') . "</label>";
1210
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1211
- echo "<input type='radio' id='cleantalk_remove_links_from_comments0' name='cleantalk_settings[remove_comments_links]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_remove_links_from_comments0'> " . __('No') . "</label>";
1212
- ct_add_descriptions_to_fields(__('Remove links from approved comments. Replace it with "[Link deleted]"', 'cleantalk'));
1213
- }
1214
-
1215
- /**
1216
- * Admin callback function - Displays inputs of 'comments_test' plugin parameter
1217
- */
1218
- function ct_input_show_check_links() {
1219
- global $ct_options, $ct_data;
1220
-
1221
- $ct_options = ct_get_options();
1222
- $ct_data = ct_get_data();
1223
-
1224
- $value = $ct_options['show_check_links'];
1225
-
1226
- echo "<input type='radio' id='cleantalk_show_check_links1' name='cleantalk_settings[show_check_links]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_show_check_links1'> " . __('Yes') . "</label>";
1227
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1228
- echo "<input type='radio' id='cleantalk_show_check_links1' name='cleantalk_settings[show_check_links]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_show_check_links1'> " . __('No') . "</label>";
1229
- ct_add_descriptions_to_fields(__('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'));
1230
- }
1231
-
1232
- /**
1233
- * Admin callback function - Displays inputs of 'comments_test' plugin parameter
1234
- */
1235
- function ct_input_registrations_test() {
1236
- global $ct_options, $ct_data;
1237
-
1238
- $ct_options = ct_get_options();
1239
- $ct_data = ct_get_data();
1240
-
1241
- $value = $ct_options['registrations_test'];
1242
- echo "<input type='radio' id='cleantalk_registrations_test1' name='cleantalk_settings[registrations_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_registrations_test1'> " . __('Yes') . "</label>";
1243
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1244
- echo "<input type='radio' id='cleantalk_registrations_test0' name='cleantalk_settings[registrations_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_registrations_test0'> " . __('No') . "</label>";
1245
- ct_add_descriptions_to_fields(__('WordPress, BuddyPress, bbPress, S2Member, WooCommerce.', 'cleantalk'));
1246
- }
1247
-
1248
- /**
1249
- * Admin callback function - Displays inputs of 'contact_forms_test' plugin parameter
1250
- */
1251
- function ct_input_contact_forms_test() {
1252
- global $ct_options, $ct_data;
1253
-
1254
- $ct_options = ct_get_options();
1255
- $ct_data = ct_get_data();
1256
-
1257
- $value = $ct_options['contact_forms_test'];
1258
- echo "<input type='radio' id='cleantalk_contact_forms_test1' name='cleantalk_settings[contact_forms_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_contact_forms_test1'> " . __('Yes') . "</label>";
1259
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1260
- echo "<input type='radio' id='cleantalk_contact_forms_test0' name='cleantalk_settings[contact_forms_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_contact_forms_test0'> " . __('No') . "</label>";
1261
- ct_add_descriptions_to_fields(__('Contact Form 7, Formidable forms, JetPack, Fast Secure Contact Form, WordPress Landing Pages, Gravity Forms.', 'cleantalk'));
1262
- }
1263
-
1264
- /**
1265
- * Admin callback function - Displays inputs of 'general_contact_forms_test' plugin parameter
1266
- */
1267
- function ct_input_general_contact_forms_test() {
1268
- global $ct_options, $ct_data;
1269
-
1270
- $ct_options = ct_get_options();
1271
- $ct_data = ct_get_data();
1272
-
1273
- $value = $ct_options['general_contact_forms_test'];
1274
- echo "<input type='radio' id='cleantalk_general_contact_forms_test1' name='cleantalk_settings[general_contact_forms_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_general_contact_forms_test1'> " . __('Yes') . "</label>";
1275
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1276
- echo "<input type='radio' id='cleantalk_general_contact_forms_test0' name='cleantalk_settings[general_contact_forms_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_general_contact_forms_test0'> " . __('No') . "</label>";
1277
- ct_add_descriptions_to_fields(__('Anti spam test for any WordPress themes or contacts forms.', 'cleantalk'));
1278
- }
1279
-
1280
- /**
1281
- * Admin callback function - Displays inputs of 'wc_checkout_test' plugin parameter
1282
- */
1283
- function ct_input_wc_chekout_test() {
1284
- global $ct_options, $ct_data;
1285
-
1286
- $ct_options = ct_get_options();
1287
- $ct_data = ct_get_data();
1288
-
1289
- $value = $ct_options['wc_checkout_test'];
1290
- echo "<input type='radio' id='cleantalk_wc_checkout_test1' name='cleantalk_settings[wc_checkout_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_wc_checkout_test1'> " . __('Yes') . "</label>";
1291
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1292
- echo "<input type='radio' id='cleantalk_wc_checkout_test0' name='cleantalk_settings[wc_checkout_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_wc_checkout_test0'> " . __('No') . "</label>";
1293
- ct_add_descriptions_to_fields(__('Anti spam test for WooCommerce checkout form.', 'cleantalk'));
1294
- }
1295
-
1296
- /**
1297
- * Admin callback function - Displays inputs of 'bp_private_messages' plugin parameter
1298
- */
1299
- function ct_input_bp_private_messages() {
1300
- global $ct_options, $ct_data;
1301
-
1302
- $ct_options = ct_get_options();
1303
- $ct_data = ct_get_data();
1304
-
1305
- $value = $ct_options['bp_private_messages'];
1306
- echo "<input type='radio' id='bp_private_messages1' name='cleantalk_settings[bp_private_messages]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='bp_private_messages1'> " . __('Yes') . "</label>";
1307
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1308
- echo "<input type='radio' id='bp_private_messages0' name='cleantalk_settings[bp_private_messages]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='bp_private_messages0'> " . __('No') . "</label>";
1309
- ct_add_descriptions_to_fields(__('Check buddyPress private messages.', 'cleantalk'));
1310
- }
1311
-
1312
- /**
1313
- * @author Artem Leontiev
1314
- * Admin callback function - Displays inputs of 'Publicate relevant comments' plugin parameter
1315
- *
1316
- * @return null
1317
- */
1318
- function ct_input_remove_old_spam() {
1319
- global $ct_options, $ct_data;
1320
-
1321
- $ct_options = ct_get_options();
1322
- $ct_data = ct_get_data();
1323
-
1324
- $value = $ct_options['remove_old_spam'];
1325
- echo "<input type='radio' id='cleantalk_remove_old_spam1' name='cleantalk_settings[remove_old_spam]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_remove_old_spam1'> " . __('Yes') . "</label>";
1326
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1327
- echo "<input type='radio' id='cleantalk_remove_old_spam0' name='cleantalk_settings[remove_old_spam]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_remove_old_spam0'> " . __('No') . "</label>";
1328
- ct_add_descriptions_to_fields(sprintf(__('Delete spam comments older than %d days.', 'cleantalk'), $ct_options['spam_store_days']));
1329
- }
1330
-
1331
- /**
1332
- * Admin callback function - Displays inputs of 'Show statistics in adminbar' plugin parameter
1333
- *
1334
- * @return null
1335
- */
1336
- function ct_input_show_adminbar() {
1337
- global $ct_options, $ct_data;
1338
-
1339
- $ct_options = ct_get_options();
1340
- $ct_data = ct_get_data();
1341
-
1342
- if(isset($ct_options['show_adminbar']))
1343
- {
1344
- $value = @intval($ct_options['show_adminbar']);
1345
- }
1346
- else
1347
- {
1348
- $value=1;
1349
- }
1350
- echo "<input type='radio' id='cleantalk_show_adminbar1' name='cleantalk_settings[show_adminbar]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_show_adminbar1'> " . __('Yes') . "</label>";
1351
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1352
- echo "<input type='radio' id='cleantalk_show_adminbar0' name='cleantalk_settings[show_adminbar]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_show_adminbar0'> " . __('No') . "</label>";
1353
- ct_add_descriptions_to_fields(sprintf(__('Show/hide CleanTalk icon in top level menu in WordPress backend. The number of submissions is being counted for past 24 hours.', 'cleantalk'), $ct_options['show_adminbar']));
1354
- }
1355
-
1356
- /**
1357
- * Admin callback function - Displays inputs of 'Show statistics in adminbar' plugin parameter
1358
- *
1359
- * @return null
1360
- */
1361
- function ct_input_general_postdata_test() {
1362
- global $ct_options, $ct_data;
1363
-
1364
- $ct_options = ct_get_options();
1365
- $ct_data = ct_get_data();
1366
-
1367
- if(isset($ct_options['general_postdata_test']))
1368
- {
1369
- $value = @intval($ct_options['general_postdata_test']);
1370
- }
1371
- else
1372
- {
1373
- $value=0;
1374
- }
1375
- echo "<input type='radio' id='cleantalk_general_postdata_test1' name='cleantalk_settings[general_postdata_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_general_postdata_test1'> " . __('Yes') . "</label>";
1376
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1377
- echo "<input type='radio' id='cleantalk_general_postdata_test0' name='cleantalk_settings[general_postdata_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_general_postdata_test0'> " . __('No') . "</label>";
1378
- ct_add_descriptions_to_fields(sprintf(__('Check all POST submissions from website visitors. Enable this option if you have spam misses on website or you don`t have records about missed spam here:', 'cleantalk') . '&nbsp;' . '<a href="https://cleantalk.org/my/?user_token='.@$ct_data['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'), $ct_options['general_postdata_test']));
1379
- }
1380
-
1381
- function ct_input_use_ajax() {
1382
- global $ct_options, $ct_data;
1383
-
1384
- $ct_options = ct_get_options();
1385
- $ct_data = ct_get_data();
1386
-
1387
- if(isset($ct_options['use_ajax']))
1388
- {
1389
- $value = @intval($ct_options['use_ajax']);
1390
- }
1391
- else
1392
- {
1393
- $value=1;
1394
- }
1395
- echo "<input type='radio' id='cleantalk_use_ajax1' name='cleantalk_settings[use_ajax]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_use_ajax1'> " . __('Yes') . "</label>";
1396
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1397
- echo "<input type='radio' id='cleantalk_use_ajax0' name='cleantalk_settings[use_ajax]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_use_ajax0'> " . __('No') . "</label>";
1398
- ct_add_descriptions_to_fields(sprintf(__('Options helps protect WordPress against spam with any caching plugins. Turn this option on to avoid issues with caching plugins.', 'cleantalk')."<strong> ".__('Attention! Incompatible with AMP plugins!', 'cleantalk')."</strong>", $ct_options['use_ajax']));
1399
- }
1400
-
1401
- function ct_input_check_comments_number() {
1402
- global $ct_options, $ct_data;
1403
-
1404
- $ct_options = ct_get_options();
1405
- $ct_data = ct_get_data();
1406
-
1407
- if(isset($ct_options['check_comments_number']))
1408
- {
1409
- $value = @intval($ct_options['check_comments_number']);
1410
- }
1411
- else
1412
- {
1413
- $value=1;
1414
- }
1415
-
1416
- if(defined('CLEANTALK_CHECK_COMMENTS_NUMBER'))
1417
- {
1418
- $comments_check_number = CLEANTALK_CHECK_COMMENTS_NUMBER;
1419
- }
1420
- else
1421
- {
1422
- $comments_check_number = 3;
1423
- }
1424
-
1425
- echo "<input type='radio' id='cleantalk_check_comments_number1' name='cleantalk_settings[check_comments_number]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_check_comments_number1'> " . __('Yes') . "</label>";
1426
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1427
- echo "<input type='radio' id='cleantalk_check_comments_number0' name='cleantalk_settings[check_comments_number]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_check_comments_number0'> " . __('No') . "</label>";
1428
- ct_add_descriptions_to_fields(sprintf(__("Dont't check comments for users with above", 'cleantalk') . $comments_check_number . __("comments.", 'cleantalk'), $ct_options['check_comments_number']));
1429
- }
1430
-
1431
- function ct_input_collect_details() {
1432
- global $ct_options, $ct_data;
1433
-
1434
- $ct_options = ct_get_options();
1435
- $ct_data = ct_get_data();
1436
-
1437
- if(isset($ct_options['collect_details']))
1438
- {
1439
- $value = @intval($ct_options['collect_details']);
1440
- }
1441
- else
1442
- {
1443
- $value=0;
1444
- }
1445
-
1446
- echo "<div id='cleantalk_anchor2' style='display:none'></div>";
1447
- echo "<input type='checkbox' id='collect_details1' name='cleantalk_settings[collect_details]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='collect_details1'> " . __('Collect details about browsers', 'cleantalk') . "</label>";
1448
- ct_add_descriptions_to_fields(sprintf(__("Checking this box you allow plugin store information about screen size and browser plugins of website visitors. The option in a beta state.", 'cleantalk'), $ct_options['spam_firewall']));
1449
- echo "<script>
1450
- jQuery(document).ready(function(){
1451
- jQuery('#cleantalk_anchor2').parent().parent().children().first().hide();
1452
- jQuery('#cleantalk_anchor2').parent().css('padding-left','0px');
1453
- jQuery('#cleantalk_anchor2').parent().attr('colspan', '2');
1454
- });
1455
- </script>";
1456
- }
1457
-
1458
- function ct_input_check_messages_number() {
1459
- global $ct_options, $ct_data;
1460
-
1461
- $ct_options = ct_get_options();
1462
- $ct_data = ct_get_data();
1463
-
1464
- if(isset($ct_options['check_messages_number']))
1465
- {
1466
- $value = @intval($ct_options['check_messages_number']);
1467
- }
1468
- else
1469
- {
1470
- $value=0;
1471
- }
1472
-
1473
- if(defined('CLEANTALK_CHECK_MESSAGES_NUMBER'))
1474
- {
1475
- $messages_check_number = CLEANTALK_CHECK_MESSAGES_NUMBER;
1476
- }
1477
- else
1478
- {
1479
- $messages_check_number = 3;
1480
- }
1481
-
1482
- echo "<input type='radio' id='cleantalk_check_messages_number1' name='cleantalk_settings[check_messages_number]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_check_messages_number1'> " . __('Yes') . "</label>";
1483
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1484
- echo "<input type='radio' id='cleantalk_check_messages_number0' name='cleantalk_settings[check_messages_number]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_check_messages_number0'> " . __('No') . "</label>";
1485
- ct_add_descriptions_to_fields(sprintf(__("Dont't check messages for users with above $messages_check_number messages", 'cleantalk'), $ct_options['check_messages_number']));
1486
- }
1487
-
1488
- function ct_input_check_external() {
1489
- global $ct_options, $ct_data;
1490
-
1491
- $ct_options = ct_get_options();
1492
- $ct_data = ct_get_data();
1493
-
1494
- if(isset($ct_options['check_external']))
1495
- {
1496
- $value = @intval($ct_options['check_external']);
1497
- }
1498
- else
1499
- {
1500
- $value=0;
1501
- }
1502
- echo "<input type='radio' id='cleantalk_check_external1' name='cleantalk_settings[check_external]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_check_external1'> " . __('Yes') . "</label>";
1503
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1504
- echo "<input type='radio' id='cleantalk_check_external0' name='cleantalk_settings[check_external]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_check_external0'> " . __('No') . "</label>";
1505
- ct_add_descriptions_to_fields(sprintf(__('Turn this option on to protect forms on your WordPress that send data to third-part servers (like MailChimp).', 'cleantalk'), $ct_options['check_external']));
1506
- }
1507
-
1508
- function ct_input_check_internal() {
1509
- global $ct_options, $ct_data;
1510
-
1511
- $ct_options = ct_get_options();
1512
- $ct_data = ct_get_data();
1513
-
1514
- if(isset($ct_options['check_internal']))
1515
- {
1516
- $value = @intval($ct_options['check_internal']);
1517
- }
1518
- else
1519
- {
1520
- $value=0;
1521
- }
1522
- echo "<input type='radio' id='cleantalk_check_internal1' name='cleantalk_settings[check_internal]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_check_internal1'> " . __('Yes') . "</label>";
1523
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1524
- echo "<input type='radio' id='cleantalk_check_internal0' name='cleantalk_settings[check_internal]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_check_internal0'> " . __('No') . "</label>";
1525
- ct_add_descriptions_to_fields(sprintf(__('This option will enable protection for custom (hand-made) AJAX forms with PHP scripts handlers on your WordPress.', 'cleantalk'), $ct_options['check_internal']));
1526
- }
1527
-
1528
- function ct_input_set_cookies() {
1529
- global $ct_options, $ct_data;
1530
-
1531
- $ct_options = ct_get_options();
1532
- $ct_data = ct_get_data();
1533
-
1534
- echo "<input type='radio' id='cleantalk_set_cookies1' name='cleantalk_settings[set_cookies]' value='1' " . (!empty($ct_options['set_cookies']) ? 'checked' : '') . " /><label for='cleantalk_set_cookies1'> " . __('Yes') . "</label>";
1535
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1536
- echo "<input type='radio' id='cleantalk_set_cookies0' name='cleantalk_settings[set_cookies]' value='0' " . (empty($ct_options['set_cookies']) ? 'checked' : '') . " /><label for='cleantalk_set_cookies0'> " . __('No') . "</label>";
1537
- ct_add_descriptions_to_fields(sprintf(__('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')));
1538
- }
1539
-
1540
- function ct_input_ssl_on() {
1541
- global $ct_options, $ct_data;
1542
-
1543
- $ct_options = ct_get_options();
1544
- $ct_data = ct_get_data();
1545
-
1546
- echo "<input type='radio' id='cleantalk_ssl_on1' name='cleantalk_settings[ssl_on]' value='1' " . (!empty($ct_options['ssl_on']) ? 'checked' : '') . " /><label for='cleantalk_ssl_on1'> " . __('Yes') . "</label>";
1547
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1548
- echo "<input type='radio' id='cleantalk_ssl_on0' name='cleantalk_settings[ssl_on]' value='0' " . (empty($ct_options['ssl_on']) ? 'checked' : '') . " /><label for='cleantalk_ssl_on0'> " . __('No') . "</label>";
1549
- ct_add_descriptions_to_fields(sprintf(__('Turn this option on to use encrypted (SSL) connection with CleanTalk servers.', 'cleantalk')));
1550
- }
1551
-
1552
- function ct_input_protect_logged_in() {
1553
- global $ct_options, $ct_data;
1554
-
1555
- $ct_options = ct_get_options();
1556
- $ct_data = ct_get_data();
1557
-
1558
- echo "<input type='radio' id='cleantalk_protect_logged_in1' name='cleantalk_settings[protect_logged_in]' value='1' " . (!empty($ct_options['protect_logged_in']) ? 'checked' : '') . " /><label for='cleantalk_protect_logged_in1'> " . __('Yes') . "</label>";
1559
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1560
- echo "<input type='radio' id='cleantalk_protect_logged_in0' name='cleantalk_settings[protect_logged_in]' value='0' " . (empty($ct_options['protect_logged_in']) ? 'checked' : '') . " /><label for='cleantalk_protect_logged_in0'> " . __('No') . "</label>";
1561
- ct_add_descriptions_to_fields(sprintf(__('Turn this option on to check for spam any submissions (comments, contact forms and etc.) from registered Users.', 'cleantalk')));
1562
-
1563
- return null;
1564
- }
1565
-
1566
- function ct_input_show_link() {
1567
- global $ct_options, $ct_data;
1568
-
1569
- $ct_options = ct_get_options();
1570
- $ct_data = ct_get_data();
1571
-
1572
- /* echo "<input type='radio' id='cleantalk_show_link1' name='cleantalk_settings[show_link]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_show_link1'> " . __('Yes') . "</label>";
1573
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1574
- echo "<input type='radio' id='cleantalk_show_link0' name='cleantalk_settings[show_link]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_show_link0'> " . __('No') . "</label>";*/
1575
-
1576
- echo "<div id='cleantalk_anchor' style='display:none'></div><input type=hidden name='cleantalk_settings[show_link]' value='0' />";
1577
- echo "<input type='checkbox' id='cleantalk_show_link1' name='cleantalk_settings[show_link]' value='1' " . (!empty($ct_options['show_link']) ? 'checked' : '') . " /><label for='cleantalk_show_link1'> " . __('Tell others about CleanTalk', 'cleantalk') . "</label>";
1578
- ct_add_descriptions_to_fields(sprintf(__("Checking this box places a small link under the comment form that lets others know what anti-spam tool protects your site.", 'cleantalk'), $ct_options['show_link']));
1579
- echo "<script>
1580
- jQuery(document).ready(function(){
1581
- jQuery('#cleantalk_anchor').parent().parent().children().first().hide();
1582
- jQuery('#cleantalk_anchor').parent().css('padding-left','0px');
1583
- });
1584
- </script>";
1585
- }
1586
-
1587
- function ct_input_spam_firewall() {
1588
- global $ct_options, $ct_data;
1589
-
1590
- $ct_options = ct_get_options();
1591
- $ct_data = ct_get_data();
1592
-
1593
- echo "<div id='cleantalk_anchor1' style='display:none'></div><input type=hidden name='cleantalk_settings[spam_firewall]' value='0' />";
1594
- echo "<input type='checkbox' id='cleantalk_spam_firewall1' name='cleantalk_settings[spam_firewall]' value='1' " . (!empty($ct_options['spam_firewall']) ? 'checked' : '') . " /><label for='cleantalk_spam_firewall1'> " . __('SpamFireWall') . "</label>";
1595
- ct_add_descriptions_to_fields(sprintf(__("This option allows to filter spam bots before they access website. Also reduces CPU usage on hosting server and accelerates pages load time.", 'cleantalk'), $ct_options['spam_firewall']) .
1596
- " " .
1597
- '<a href="https://cleantalk.org/cleantalk-spam-firewall" style="font-size: 10pt; color: #666 !important" target="_blank">' . __('Learn more', 'cleantalk') . '</a>.'
1598
- );
1599
- echo "<script>
1600
- jQuery(document).ready(function(){
1601
- jQuery('#cleantalk_anchor1').parent().parent().children().first().hide();
1602
- jQuery('#cleantalk_anchor1').parent().css('padding-left','0px');
1603
- jQuery('#cleantalk_anchor1').parent().attr('colspan', '2');
1604
- });
1605
- </script>";
1606
- }
1607
-
1608
-
1609
- /**
1610
- * Admin callback function - Plugin parameters validator
1611
- */
1612
- function ct_settings_validate($input) {
1613
- return $input;
1614
- }
1615
-
1616
-
1617
- /**
1618
- * Admin callback function - Displays plugin options page
1619
- */
1620
- function apbct_settings_page() {
1621
- ?>
1622
- <style type="text/css">
1623
- .cleantalk_manual_link {padding: 10px; background: #3399FF; color: #fff; border:0 none;
1624
- cursor:pointer;
1625
- -webkit-border-radius: 5px;
1626
- border-radius: 5px;
1627
- font-size: 12pt;
1628
- }
1629
- .cleantalk_auto_link{
1630
- background: #ccc;
1631
- border-color: #999;
1632
- -webkit-box-shadow: inset 0 1px 0 rgba(200,200,200,.5),0 1px 0 rgba(0,0,0,.15);
1633
- box-shadow: inset 0 1px 0 rgba(200,200,200,.5),0 1px 0 rgba(0,0,0,.15);
1634
- color: #000;
1635
- text-decoration: none;
1636
- display: inline-block;
1637
- text-decoration: none;
1638
- font-size: 13px;
1639
- line-height: 26px;
1640
- height: 28px;
1641
- margin: 0;
1642
- padding: 0 10px 1px;
1643
- cursor: pointer;
1644
- border-width: 1px;
1645
- border-style: solid;
1646
- -webkit-appearance: none;
1647
- -webkit-border-radius: 2px;
1648
- border-radius: 2px;
1649
- white-space: nowrap;
1650
- -webkit-box-sizing: border-box;
1651
- -moz-box-sizing: border-box;
1652
- box-sizing: border-box;
1653
- }
1654
- .cleantalk_auto_link:hover{
1655
- color: #fff;
1656
- }
1657
- .cleantalk_manual_link
1658
- {
1659
- background: #2ea2cc;
1660
- border-color: #0074a2;
1661
- -webkit-box-shadow: inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);
1662
- box-shadow: inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);
1663
- color: #fff;
1664
- text-decoration: none;
1665
- display: inline-block;
1666
- text-decoration: none;
1667
- font-size: 13px;
1668
- line-height: 26px;
1669
- height: 28px;
1670
- margin: 0;
1671
- padding: 0 10px 1px;
1672
- cursor: pointer;
1673
- border-width: 1px;
1674
- border-style: solid;
1675
- -webkit-appearance: none;
1676
- -webkit-border-radius: 3px;
1677
- border-radius: 3px;
1678
- white-space: nowrap;
1679
- -webkit-box-sizing: border-box;
1680
- -moz-box-sizing: border-box;
1681
- box-sizing: border-box;
1682
- }
1683
- .cleantalk_manual_link:hover
1684
- {
1685
- color:black;
1686
- }
1687
-
1688
- </style>
1689
-
1690
- <div>
1691
- <?php
1692
- if(is_network_admin())
1693
- {
1694
- print '<form method="post">';
1695
- if(defined('CLEANTALK_ACCESS_KEY'))
1696
- {
1697
- print "<br />Your CleanTalk access key is: <b>".CLEANTALK_ACCESS_KEY."</b><br />
1698
- You can change it in your wp-config.php file.<br />";
1699
- }
1700
- else
1701
- {
1702
- print "<br />To set up global CleanTalk access key for all websites, define constant in your wp-config.php file before defining database constants:<br />
1703
- <pre>define('CLEANTALK_ACCESS_KEY', 'place your key here');</pre>";
1704
- }
1705
- }
1706
- else
1707
- {
1708
- echo '<div style="float: right; padding: 0 15px; font-size: 13px;">';
1709
-
1710
- echo __('CleanTalk\'s tech support:', 'cleantalk')
1711
- .'&nbsp;'
1712
- .'<a target="_blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">Wordpress.org</a>.'
1713
- // .' <a href="https://community.cleantalk.org/viewforum.php?f=25" target="_blank">'.__("Tech forum", 'cleantalk').'</a>'
1714
- // .($user_token ? ", <a href='https://cleantalk.org/my/support?user_token=$user_token&cp_mode=antispam' target='_blank'>".__("Service support ", 'cleantalk').'</a>' : '').
1715
- .'<br>';
1716
- echo __('Plugin Homepage at', 'cleantalk').' <a href="http://cleantalk.org" target="_blank">cleantalk.org</a>.<br/>';
1717
- echo '<span id="apbct_gdpr_open_modal" style="text-decoration: underline;">'.__('GDPR compliance', 'cleantalk').'</span><br/>';
1718
- echo __('Use s@cleantalk.org to test plugin in any WordPress form.', 'cleantalk').'<br>';
1719
- echo __('CleanTalk is registered Trademark. All rights reserved.', 'cleantalk').'<br/>';
1720
- 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 />';
1721
- ct_input_get_premium();
1722
- echo '<div id="gdpr_dialog" style="display: none; padding: 7px;">';
1723
- apbct_show_GDPR_text();
1724
- echo '</div>';
1725
- echo '</div>';
1726
- echo '<form action="options.php" method="post">';
1727
- settings_fields('cleantalk_settings');
1728
- do_settings_sections('cleantalk');
1729
- echo '<br>';
1730
- echo '<input name="Submit" type="submit" class="cleantalk_manual_link" value="'.__('Save Changes').'" />';
1731
- }
1732
- echo "</form>";
1733
- echo "</div>";
1734
- // Translate banner for non EN locale
1735
- if(substr(get_locale(), 0, 2) != 'en'){
1736
- require_once(CLEANTALK_PLUGIN_DIR.'templates/translate_banner.php');
1737
- printf($ct_translate_banner_template, substr(get_locale(), 0, 2));
1738
- }
1739
- }
1740
-
1741
- /**
1742
- * Notice blog owner if plugin is used without Access key
1743
- * @return bool
1744
- */
1745
- function cleantalk_admin_notice_message(){
1746
- global $show_ct_notice_trial, $show_ct_notice_renew, $show_ct_notice_online, $show_ct_notice_autokey, $ct_notice_autokey_value, $ct_plugin_name, $ct_options, $ct_data;
1747
-
1748
- $ct_options = ct_get_options();
1749
- $ct_data = ct_get_data();
1750
- $page = get_current_screen();
1751
-
1752
- //General notice control flags
1753
- $moderate_ip = (empty($ct_data['moderate_ip']) ? 0 : $ct_data['moderate_ip']);
1754
- $self_owned_key = (!$moderate_ip && !defined('CLEANTALK_ACCESS_KEY') ? true : false);
1755
- $is_dashboard = (is_network_admin() || is_admin() ? true : false);
1756
- $is_admin = (current_user_can('activate_plugins') ? true : false);
1757
- $show_notice = true;
1758
-
1759
- //Notice control flags
1760
- $show_ct_notice_trial = (isset($ct_data['show_ct_notice_trial']) ? intval($ct_data['show_ct_notice_trial']) : 0);
1761
- $show_ct_notice_renew = (isset($ct_data['show_ct_notice_renew']) ? intval($ct_data['show_ct_notice_renew']) : 0);
1762
- $show_ct_notice_review = (isset($ct_data['show_ct_notice_review']) ? intval($ct_data['show_ct_notice_review']) : 0);
1763
- $next_notice_show = (isset($ct_data['next_notice_show']) ? intval($ct_data['next_notice_show']) : 0); //inactive
1764
-
1765
- $show_ct_notice_auto_update = (isset($ct_data['show_ct_notice_auto_update']) ? intval($ct_data['show_ct_notice_auto_update']) : 0);
1766
- $auto_update_app = (isset($ct_data['auto_update_app']) ? $ct_data['auto_update_app'] : 0);
1767
-
1768
- $page_is_ct_settings = ($page->id == 'settings_page_cleantalk' || $page->id == 'settings_page_cleantalk-network' ? true : false);
1769
-
1770
- //Misc
1771
- $user_token = (isset($ct_data['user_token']) && $ct_data['user_token'] != '' ? "&user_token={$ct_data['user_token']}" : "");
1772
- $settings_link = (is_network_admin() ? "settings.php?page=cleantalk" : "options-general.php?page=cleantalk");
1773
-
1774
- if($self_owned_key && $is_dashboard && $is_admin){
1775
- // Auto update notice
1776
- if($show_ct_notice_auto_update && $auto_update_app != -1 && empty($_COOKIE['apbct_update_banner_closed'])){
1777
- $link = '<a href="http://cleantalk.org/help/cleantalk-auto-update" target="_blank">%s</a>';
1778
- $button = sprintf($link, '<input type="button" class="button button-primary" value="'.__('Learn more', 'cleantalk').'" />');
1779
- echo '<div class="error notice is-dismissible apbct_update_notice">'
1780
- .'<h3>'
1781
- .__('Do you know that Anti-Spam by CleanTalk has auto update option?', 'cleantalk')
1782
- .'</br></br>'
1783
- .$button
1784
- .'</h3>'
1785
- .'</div>';
1786
- }
1787
-
1788
- //Unable to get key automatically (if apbct_admin_init().getAutoKey() returns error)
1789
- if ($show_notice && $show_ct_notice_autokey){
1790
- echo '<div class="error">
1791
- <h3>' . sprintf(__("Unable to get Access key automatically: %s", 'cleantalk'), $ct_notice_autokey_value).
1792
- "<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>
1793
- </h3>
1794
- </div>';
1795
- }
1796
-
1797
- //key == "" || "enter key"
1798
- if ($show_notice && !ct_valid_key() && empty($moderate_ip)){
1799
- echo "<div class='error'>"
1800
- ."<h3>"
1801
- .sprintf(__("Please enter Access Key in %s settings to enable anti spam protection!", 'cleantalk'), "<a href='{$settings_link}'>CleanTalk plugin</a>")
1802
- ."</h3>"
1803
- ."</div>";
1804
- $show_notice = false;
1805
- }
1806
-
1807
- //"Trial period ends" notice from apbct_admin_init().api_method__notice_paid_till()
1808
- if ($show_notice && $show_ct_notice_trial == 1 && empty($moderate_ip)) {
1809
- if(isset($_GET['page']) && in_array($_GET['page'], array('cleantalk', 'ct_check_spam', 'ct_check_users'))){
1810
- echo '<div class="error">
1811
- <h3>' . sprintf(__("%s trial period ends, please upgrade to %s!", 'cleantalk'),
1812
- "<a href='{$settings_link}'>$ct_plugin_name</a>",
1813
- "<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>") .
1814
- '</h3>
1815
- </div>';
1816
- $show_notice = false;
1817
- }
1818
- }
1819
-
1820
- //Renew notice from apbct_admin_init().api_method__notice_paid_till()
1821
- if ($show_notice && $show_ct_notice_renew == 1 && empty($moderate_ip)) {
1822
- $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>";
1823
- $button_html = sprintf($renew_link, '<input type="button" class="button button-primary" value="'.__('RENEW ANTI-SPAM', 'cleantalk').'" />');
1824
- $link_html = sprintf($renew_link, "<b>".__('next year', 'cleantalk')."</b>");
1825
-
1826
- echo '<div class="updated">
1827
- <h3>'.
1828
- sprintf(__("Please renew your anti-spam license for %s.", 'cleantalk'), $link_html). '<br /><br />' . $button_html .
1829
- '</h3>
1830
- </div>';
1831
- $show_notice = false;
1832
- }
1833
-
1834
- //"Wrong access key" notice (if ct_update_option().METHOD_notice_validate_key returns a error)
1835
- if ($show_notice && $show_ct_notice_online === 'N' && empty($moderate_ip)){
1836
- echo '<div class="error">
1837
- <h3><b>'.
1838
- __("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').
1839
- '</b></h3>
1840
- </div>';
1841
- }
1842
- }
1843
-
1844
- return true;
1845
- }
1846
-
1847
- /**
1848
- * @author Artem Leontiev
1849
- *
1850
- * Add descriptions for field
1851
- */
1852
- function ct_add_descriptions_to_fields($descr = '') {
1853
- echo "<div style='font-size: 10pt; color: #666 !important'>$descr</div>";
1854
- }
1855
-
1856
- /**
1857
- * Test API key
1858
- */
1859
- function ct_valid_key($apikey = null) {
1860
- global $ct_options, $ct_data;
1861
-
1862
- if ($apikey === null) {
1863
- $ct_options = ct_get_options();
1864
- $apikey = $ct_options['apikey'];
1865
- }
1866
-
1867
- return ($apikey === 'enter key' || $apikey === '') ? false : true;
1868
- }
1869
 
1870
  // Ajax action feedback form comments page.
1871
- function ct_comment_send_feedback($comment_id = null, $comment_status = null, $change_status = false, $direct_call = null){
1872
 
1873
  // For AJAX call
1874
  check_ajax_referer('ct_secret_nonce', 'security');
@@ -1889,7 +608,7 @@ function ct_comment_send_feedback($comment_id = null, $comment_status = null, $c
1889
  // Approving
1890
  if($comment_status == '1' || $comment_status == 'approve'){
1891
  $result = ct_send_feedback($hash.":1");
1892
- // $comment['comment_content'] = ct_unmark_red($comment['comment_content']);
1893
  // wp_update_comment($comment);
1894
  $result === true ? 1 : 0;
1895
  }
@@ -1916,7 +635,7 @@ function ct_comment_send_feedback($comment_id = null, $comment_status = null, $c
1916
  }
1917
 
1918
  // Ajax action feedback form user page.
1919
- function ct_user_send_feedback($user_id = null, $status = null, $direct_call = null){
1920
 
1921
  check_ajax_referer('ct_secret_nonce', 'security');
1922
 
@@ -1950,182 +669,14 @@ function ct_user_send_feedback($user_id = null, $status = null, $direct_call = n
1950
  }
1951
 
1952
  /**
1953
- * Admin filter 'get_comment_text' - Adds some info to comment text to display
1954
- * @param string $current_text Current comment text
1955
- * @return string New comment text
1956
- */
1957
- function ct_get_comment_text($current_text) {
1958
- global $comment;
1959
- $new_text = $current_text;
1960
- if (isset($comment) && is_object($comment)) {
1961
- $hash = get_comment_meta($comment->comment_ID, 'ct_hash', true);
1962
- if (!empty($hash)) {
1963
- $new_text .= '<hr>Cleantalk ID = ' . $hash;
1964
- }
1965
- }
1966
- return $new_text;
1967
- }
1968
-
1969
- /**
1970
- * Send feedback for user deletion
1971
  * @return null
1972
  */
1973
- function ct_delete_user($user_id, $reassign = null){
1974
 
1975
  $hash = get_user_meta($user_id, 'ct_hash', true);
1976
  if ($hash !== '') {
1977
  ct_feedback($hash, 0);
1978
  }
1979
  }
1980
-
1981
- /**
1982
- * Manage links in plugins list
1983
- * @return array
1984
- */
1985
- function apbct_plugin_action_links($links, $file) {
1986
-
1987
- $settings_link = is_network_admin()
1988
- ? '<a href="settings.php?page=cleantalk">' . __( 'Settings' ) . '</a>'
1989
- : '<a href="options-general.php?page=cleantalk">' . __( 'Settings' ) . '</a>';
1990
-
1991
- array_unshift( $links, $settings_link ); // before other links
1992
- return $links;
1993
- }
1994
-
1995
- /**
1996
- * Manage links and plugins page
1997
- * @return array
1998
- */
1999
- function apbct_register_plugin_links($links, $file) {
2000
- global $ct_plugin_basename;
2001
- //Return if it's not our plugin
2002
- if ($file != $ct_plugin_basename )
2003
- return $links;
2004
-
2005
- // $links[] = is_network_admin()
2006
- // ? '<a class="ct_meta_links ct_setting_links" href="settings.php?page=cleantalk">' . __( 'Settings' ) . '</a>'
2007
- // : '<a class="ct_meta_links ct_setting_links" href="options-general.php?page=cleantalk">' . __( 'Settings' ) . '</a>';
2008
-
2009
- if(substr(get_locale(), 0, 2) != 'en')
2010
- $links[] = '<a class="ct_meta_links ct_translate_links" href="'
2011
- .sprintf('https://translate.wordpress.org/locale/%s/default/wp-plugins/cleantalk-spam-protect', substr(get_locale(), 0, 2))
2012
- .'" target="_blank">'
2013
- .__('Translate', 'cleantalk')
2014
- .'</a>';
2015
-
2016
- $links[] = '<a class="ct_meta_links ct_faq_links" href="http://wordpress.org/plugins/cleantalk-spam-protect/faq/" target="_blank">' . __( 'FAQ','cleantalk' ) . '</a>';
2017
- $links[] = '<a class="ct_meta_links ct_support_links"href="https://wordpress.org/support/plugin/cleantalk-spam-protect" target="_blank">' . __( 'Support','cleantalk' ) . '</a>';
2018
- $trial = ct_input_get_premium(false);
2019
- if(!empty($trial))
2020
- $links[] = ct_input_get_premium(false);
2021
-
2022
- return $links;
2023
- }
2024
-
2025
- /**
2026
- * After options update
2027
- * @return array
2028
- */
2029
- function ct_update_option($option_name) {
2030
- global $show_ct_notice_online, $ct_notice_online_label, $ct_notice_trial_label, $trial_notice_showtime, $ct_options, $ct_data, $ct_server_timeout;
2031
- $ct_options = ct_get_options(true);
2032
- $ct_data = ct_get_data(true);
2033
-
2034
- if($option_name !== 'cleantalk_settings') {
2035
- return;
2036
- }
2037
-
2038
- $api_key = $ct_options['apikey'];
2039
- if (isset($_POST['cleantalk_settings']['apikey'])) {
2040
- $api_key = trim($_POST['cleantalk_settings']['apikey']);
2041
- $ct_options['apikey'] = $api_key;
2042
- }
2043
-
2044
- if (!ct_valid_key($api_key)) {
2045
- return;
2046
- }
2047
-
2048
- if (isset($_POST['cleantalk_settings']['spam_firewall'])) {
2049
- if ($_POST['cleantalk_settings']['spam_firewall'] == 1) {
2050
- ct_sfw_update();
2051
- ct_sfw_send_logs();
2052
- } else {
2053
- // Reseting SFW logs to do not keep huge ammount of data.
2054
- $ct_data['sfw_log']= array();
2055
- }
2056
- }
2057
-
2058
- $result = CleantalkHelper::api_method__notice_validate_key($api_key, preg_replace('/http[s]?:\/\//', '', get_option('siteurl'), 1));
2059
-
2060
- if (empty($result['error'])){
2061
- if($result['valid'] == 1){
2062
- $key_valid = true;
2063
- $app_server_error = false;
2064
- $ct_data['testing_failed']=0;
2065
- }else{
2066
- $key_valid = false;
2067
- $app_server_error = false;
2068
- $ct_data['testing_failed']=1;
2069
- }
2070
- }else{
2071
- $key_valid = true;
2072
- $app_server_error = true;
2073
- $ct_data['testing_failed']=1;
2074
- }
2075
-
2076
- if ($key_valid) {
2077
- // Removes cookie for server errors
2078
- if ($app_server_error) {
2079
- setcookie($ct_notice_online_label, '', 1, '/'); // time 1 is exactly in past even clients time() is wrong
2080
- unset($_COOKIE[$ct_notice_online_label]);
2081
- } else {
2082
- setcookie($ct_notice_online_label, (string) time(), strtotime("+14 days"), '/');
2083
- }
2084
- setcookie($ct_notice_trial_label, '0', strtotime("+$trial_notice_showtime minutes"), '/');
2085
-
2086
- } else {
2087
- setcookie($ct_notice_online_label, 'BAD_KEY', 0, '/');
2088
- }
2089
-
2090
- update_option('cleantalk_data', $ct_data);
2091
-
2092
- return null;
2093
- }
2094
-
2095
- /**
2096
- * Unmark bad words
2097
- * @param string $message
2098
- * @return string Cleat comment
2099
- */
2100
- function ct_unmark_red($message) {
2101
- $message = preg_replace("/\<font rel\=\"cleantalk\" color\=\"\#FF1000\"\>(\S+)\<\/font>/iu", '$1', $message);
2102
-
2103
- return $message;
2104
- }
2105
-
2106
- function apbct_show_GDPR_text(){
2107
- ?>
2108
- <p>The notice requirements remain and are expanded. They must include the retention time for personal data, and contact information for data controller and data protection officer has to be provided.</p>
2109
-
2110
- <p>Automated individual decision-making, including profiling (Article 22) is contestable, similarly to the Data Protection Directive (Article 15). Citizens have rights to question and fight significant decisions that affect them that have been made on a solely-algorithmic basis. Many media outlets have commented on the introduction of a "right to explanation" of algorithmic decisions, but legal scholars have since argued that the existence of such a right is highly unclear without judicial tests and is limited at best.</p>
2111
-
2112
- <p>To be able to demonstrate compliance with the GDPR, the data controller should implement measures, which meet the principles of data protection by design and data protection by default. Privacy by design and by default (Article 25) require data protection measures to be designed into the development of business processes for products and services. Such measures include pseudonymising personal data, by the controller, as soon as possible (Recital 78).</p>
2113
-
2114
- <p>It is the responsibility and the liability of the data controller to implement effective measures and be able to demonstrate the compliance of processing activities even if the processing is carried out by a data processor on behalf of the controller (Recital 74).</p>
2115
-
2116
- <p>Data Protection Impact Assessments (Article 35) have to be conducted when specific risks occur to the rights and freedoms of data subjects. Risk assessment and mitigation is required and prior approval of the national data protection authorities (DPAs) is required for high risks. Data protection officers (Articles 37–39) are required to ensure compliance within organisations.</p>
2117
-
2118
- <p>They have to be appointed:</p>
2119
- <ul style="padding: 0px 25px; list-style: disc;">
2120
- <li>for all public authorities, except for courts acting in their judicial capacity</li>
2121
- <li>if the core activities of the controller or the processor are:</li>
2122
- <ul style="padding: 0px 25px; list-style: disc;">
2123
- <li>processing operations, which, by virtue of their nature, their scope and/or their purposes, require regular and systematic monitoring of data subjects on a large scale</li>
2124
- <li>processing on a large scale of special categories of data pursuant to Article 9 and personal data relating to criminal convictions and offences referred to in Article 10';</li>
2125
- </ul>
2126
- </li>
2127
- </ul>
2128
- <?php
2129
- }
2130
-
2131
  ?>
1
  <?php
2
 
3
+ require_once('cleantalk-settings.php');
 
 
4
 
5
+ add_action( 'admin_bar_menu', 'apbct_admin__admin_bar__add', 999 );
 
 
 
 
6
 
7
  //Adding widjet
8
  function ct_dashboard_statistics_widget() {
24
  // Outputs statistics widget content
25
  function ct_dashboard_statistics_widget_output( $post, $callback_args ) {
26
 
27
+ global $apbct, $current_user;
 
 
 
 
 
28
 
29
  echo "<div id='ct_widget_wrapper'>";
30
  ?>
38
  <h4 class='ct_widget_block_header'><?php _e('Top 5 spam IPs blocked', 'cleantalk'); ?></h4>
39
  <hr class='ct_widget_hr'>
40
  <?php
41
+ if(!apbct_api_key__is_correct() || (isset($apbct->brief_data['error_no']) && $apbct->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'>
47
  </form>
48
  </div>
49
  <?php
50
+ }elseif(!empty($apbct->brief_data['error'])){
51
  echo '<div class="ct_widget_block">'
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>'
59
+ .'<a target="_blank" href="https://cleantalk.org/my?user_token='.$apbct->user_token.'&cp_mode=antispam">'
60
  .'<input class="ct_widget_button ct_widget_activate_button ct_widget_resolve_button" type="button" value="VISIT CONTROL PANEL">'
61
  .'</a>';
62
  }
63
  echo '</div>';
64
  }
65
 
66
+ if(apbct_api_key__is_correct() && empty($apbct->brief_data['error'])){
67
  ?>
68
  <div class='ct_widget_block'>
69
  <table cellspacing="0">
72
  <th><?php _e('Country', 'cleantalk'); ?></th>
73
  <th><?php _e('Block Count', 'cleantalk'); ?></th>
74
  </tr>
75
+ <?php foreach($apbct->brief_data['top5_spam_ip'] as $val){ ?>
76
  <tr>
77
  <td><?php echo $val[0]; ?></td>
78
  <td><?php echo $val[1] ? "<img src='https://cleantalk.org/images/flags/".strtolower($val[1]).".png'>" : ''; ?>&nbsp;<?php
83
  </tr>
84
  <?php } ?>
85
  </table>
86
+ <?php if($apbct->user_token){ ?>
87
+ <a target='_blank' href='https://cleantalk.org/my?user_token=<?php echo $apbct->user_token; ?>&cp_mode=antispam'>
88
  <input class='ct_widget_button' id='ct_widget_button_view_all' type='button' value='View all'>
89
  </a>
90
  <?php } ?>
94
  }
95
  // Notice at the bottom
96
  if(isset($current_user) && in_array('administrator', $current_user->roles)){
97
+
 
 
98
  if($blocked > 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"/>'
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;">'
121
  }
122
 
123
  /**
124
+ * Admin action 'admin_init' - Add the admin settings and such
125
+ */
126
+ function apbct_admin__init(){
127
+
128
+ global $apbct;
129
+
130
+ // Update logic
131
+ if($apbct->plugin_version != APBCT_VERSION){
132
+ if(is_main_site()){
133
+ require_once('cleantalk-updater.php');
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
+ }
141
+ }
142
  }
143
+
144
+ // Getting dashboard widget statistics
145
+ if(!empty($_POST['ct_brief_refresh']) || empty($apbct->brief_data)){
146
+ $apbct->data['brief_data'] = CleantalkHelper::api_method__get_antispam_report_breif($apbct->api_key);
147
+ $apbct->saveData();
148
+ }
149
+
150
+ }
151
+
152
+ /**
153
+ * Manage links in plugins list
154
+ * @return array
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;
164
  }
 
 
165
 
166
+ /**
167
+ * Manage links and plugins page
168
+ * @return array
169
+ */
170
+ function apbct_admin__register_plugin_links($links, $file){
171
+
172
+
173
+ global $apbct;
174
+
175
+ //Return if it's not our plugin
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="'
185
+ .sprintf('https://translate.wordpress.org/locale/%s/default/wp-plugins/cleantalk-spam-protect', substr(get_locale(), 0, 2))
186
+ .'" target="_blank">'
187
+ .__('Translate', 'cleantalk')
188
+ .'</a>';
189
+
190
+ $links[] = '<a class="ct_meta_links ct_faq_links" href="http://wordpress.org/plugins/cleantalk-spam-protect/faq/" target="_blank">' . __( 'FAQ','cleantalk' ) . '</a>';
191
+ $links[] = '<a class="ct_meta_links ct_support_links"href="https://wordpress.org/support/plugin/cleantalk-spam-protect" target="_blank">' . __( 'Support','cleantalk' ) . '</a>';
192
+ $trial = apbct_admin__badge__get_premium(false);
193
+ if(!empty($trial))
194
+ $links[] = apbct_admin__badge__get_premium(false);
195
+
196
+ return $links;
197
+ }
198
 
199
  /**
200
  * Admin action 'admin_enqueue_scripts' - Enqueue admin script of reloading admin page after needed AJAX events
201
  * @param string $hook URL of hooked page
202
  */
203
+ function apbct_admin__enqueue_scripts($hook){
204
 
205
+ global $apbct;
 
 
 
206
 
207
  // Scripts to all admin pages
208
+ wp_enqueue_script('ct_admin_js_notices', plugins_url('/cleantalk-spam-protect/js/cleantalk-admin.js'), array(), APBCT_VERSION);
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;" />'
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
 
220
  wp_enqueue_script('ct_gstatic_charts_loader', plugins_url('/cleantalk-spam-protect/js/cleantalk-dashboard-widget--google-charts.js'), array(), APBCT_VERSION);
221
  wp_enqueue_script('ct_admin_js_widget_dashboard', plugins_url('/cleantalk-spam-protect/js/cleantalk-dashboard-widget.js'), array('ct_gstatic_charts_loader'), APBCT_VERSION);
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
 
240
  $ajax_nonce = wp_create_nonce( "ct_secret_nonce" );
241
  wp_localize_script( 'jquery', 'ctSettingsPage', array(
242
  'ct_ajax_nonce' => $ajax_nonce,
243
+ 'ct_subtitle' => $apbct->ip_license ? __('Hosting AntiSpam', 'cleantalk') : '',
244
+ 'ip_license' => $apbct->ip_license ? true : false,
245
  ));
246
  }
247
 
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
 
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
  ));
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
 
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
  /**
330
+ * Notice blog owner if plugin is used without Access key
331
+ * @return bool
332
  */
333
+ function apbct_admin__notice_message(){
 
334
 
335
+ global $apbct;
 
 
 
336
 
337
+ $page = get_current_screen();
 
 
 
 
 
 
338
 
339
+ //General notice control flags
340
+ $self_owned_key = ($apbct->moderate_ip == 0 && !defined('CLEANTALK_ACCESS_KEY') ? true : false);
341
+ $is_dashboard = (is_network_admin() || is_admin() ? true : false);
342
+ $is_admin = (current_user_can('activate_plugins') ? true : false);
343
 
344
+ $page_is_ct_settings = ($page->id == 'settings_page_cleantalk' || $page->id == 'settings_page_cleantalk-network' ? true : false);
 
 
 
 
 
 
 
345
 
346
+ //Misc
347
+ $user_token = ($apbct->user_token ? '&user_token='.$apbct->user_token : '');
348
+ $settings_link = (is_network_admin() ? 'settings.php?page=cleantalk' : 'options-general.php?page=cleantalk');
349
 
350
+ if($self_owned_key && $is_dashboard && $is_admin){
351
+ // Auto update notice
352
+ /* Disabled at 09.09.2018
353
+ if($apbct->notice_auto_update == 1 && $apbct->auto_update != -1 && empty($_COOKIE['apbct_update_banner_closed'])){
354
+ $link = '<a href="http://cleantalk.org/help/cleantalk-auto-update" target="_blank">%s</a>';
355
+ $button = sprintf($link, '<input type="button" class="button button-primary" value="'.__('Learn more', 'cleantalk').'" />');
356
+ echo '<div class="error notice is-dismissible apbct_update_notice">'
357
+ .'<h3>'
358
+ .__('Do you know that Anti-Spam by CleanTalk has auto update option?', 'cleantalk')
359
+ .'</br></br>'
360
+ .$button
361
+ .'</h3>'
362
+ .'</div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>
370
+ </h3>
371
+ </div>';
 
 
 
372
  }
373
 
374
+ //key == "" || "enter key"
375
+ if (!apbct_api_key__is_correct() && $apbct->moderate_ip == 0){
376
+ echo "<div class='error'>"
377
+ ."<h3>"
378
+ .sprintf(__("Please enter Access Key in %s settings to enable anti spam protection!", 'cleantalk'), "<a href='{$settings_link}'>CleanTalk plugin</a>")
379
+ ."</h3>"
380
+ ."</div>";
381
+ $apbct->notice_show = false;
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>';
393
+ $apbct->notice_show = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
394
  }
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>");
 
 
 
 
 
 
 
 
 
402
 
403
+ echo '<div class="updated">
404
+ <h3>'.
405
+ sprintf(__("Please renew your anti-spam license for %s.", 'cleantalk'), $link_html). '<br /><br />' . $button_html .
406
+ '</h3>
407
+ </div>';
408
+ $apbct->notice_show = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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').
416
+ '</b></h3>
417
+ </div>';
418
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
419
  }
420
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
  return true;
422
  }
423
 
424
+ function apbct_admin__badge__get_premium($print = true, $out = ''){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
425
 
426
+ global $apbct;
427
 
428
+ if($apbct->license_trial == 1 && $apbct->user_token){
429
+ $out .= '<b style="display: inline-block; margin-top: 10px;">'
 
 
 
 
430
  .($print ? __('Make it right!', 'cleantalk').' ' : '')
431
  .sprintf(
432
  __('%sGet premium%s', 'cleantalk'),
433
+ '<a href="https://cleantalk.org/my/bill/recharge?user_token='.$apbct->user_token.'" target="_blank">',
434
  '</a>'
435
  )
436
  .'</b>';
442
  return $out;
443
  }
444
 
445
+ function apbct_admin__admin_bar__add( $wp_admin_bar ) {
 
 
446
 
447
+ global $apbct;
448
 
449
+ if (current_user_can('activate_plugins') && $apbct->settings['show_adminbar'] == 1 && (apbct_api_key__is_correct($apbct->api_key) !== false || (defined('CLEANTALK_SHOW_ADMIN_BAR_FORCE') && CLEANTALK_SHOW_ADMIN_BAR_FORCE))) {
450
+
 
451
  //Reset or create user counter
452
  if(!empty($_GET['ct_reset_user_counter'])){
453
+ $apbct->data['user_counter']['accepted'] = 0;
454
+ $apbct->data['user_counter']['blocked'] = 0;
455
+ $apbct->data['user_counter']['since'] = date('d M');
456
+ $apbct->saveData();
457
  }
458
  //Reset or create all counters
459
  if(!empty($_GET['ct_reset_all_counters'])){
460
+ $apbct->data['sfw_counter'] = array('all' => 0, 'blocked' => 0);
461
+ $apbct->data['all_time_counter'] = array('accepted' => 0, 'blocked' => 0);
462
+ $apbct->data['user_counter'] = array('all' => 0, 'accepted' => 0, 'blocked' => 0, 'since' => date('d M'));
463
+ $apbct->data['array_accepted'] = array();
464
+ $apbct->data['array_blocked'] = array();
465
+ $apbct->data['current_hour'] = '';
466
+ $apbct->saveData();
467
+ }
 
 
 
468
  //Compile user's counter string
469
+ $user_counter=Array('accepted'=>$apbct->data['user_counter']['accepted'], 'blocked'=>$apbct->data['user_counter']['blocked'], 'all'=>$apbct->data['user_counter']['accepted'] + $apbct->data['user_counter']['blocked'], 'since'=>$apbct->data['user_counter']['since']);
470
  //Previous version $user_counter_str='<span style="color: white;">Since '.$user_counter['since'].': ' .$user_counter['all']*/. '</span> / <span style="color: green;">' .$user_counter['accepted']. '</span> / <span style="color: red;">' .$user_counter['blocked']. '</span>';
471
  $user_counter_str='<span style="color: white;">' . __('Since', 'cleantalk') . '&nbsp;' . $user_counter['since'].': </span><span style="color: green;">' .$user_counter['accepted']. '</span> / <span style="color: red;">' .$user_counter['blocked']. '</span>';
472
 
473
  $all_time_counter_str='';
474
  //Don't compile if all time counter disabled
475
+ if($apbct->settings['all_time_counter'] == 1){
476
+ $all_time_counter=Array('accepted'=>$apbct->data['all_time_counter']['accepted'], 'blocked'=>$apbct->data['all_time_counter']['blocked'], 'all'=>$apbct->data['all_time_counter']['accepted'] + $apbct->data['all_time_counter']['blocked']);
477
  $all_time_counter_str='<span style="color: white;" title="'.__('All / Allowed / Blocked submissions. The number of submissions is being counted since CleanTalk plugin installation.', 'cleantalk').'"><span style="color: white;"> | ' . __('All', 'cleantalk') . ': ' .$all_time_counter['all']. '</span> / <span style="color: green;">' .$all_time_counter['accepted']. '</span> / <span style="color: red;">' .$all_time_counter['blocked']. '</span></span>';
478
  }
479
 
480
  $daily_counter_str='';
481
  //Don't compile if daily counter disabled
482
+ if( $apbct->settings['daily_counter'] == 1){
483
+ $daily_counter=Array('accepted'=>array_sum($apbct->data['array_accepted']), 'blocked'=>array_sum($apbct->data['array_blocked']), 'all'=>array_sum($apbct->data['array_accepted']) + array_sum($apbct->data['array_blocked']));
484
  //Previous version $daily_counter_str='<span style="color: white;" title="'.__('All / Allowed / Blocked submissions. The number of submissions for past 24 hours. ', 'cleantalk').'"><span style="color: white;"> | Day: ' .$daily_counter['all']. '</span> / <span style="color: green;">' .$daily_counter['accepted']. '</span> / <span style="color: red;">' .$daily_counter['blocked']. '</span></span>';
485
  $daily_counter_str='<span style="color: white;" title="'.__('Allowed / Blocked submissions. The number of submissions for past 24 hours. ', 'cleantalk').'"><span style="color: white;"> | ' . __('Day', 'cleantalk') . ': </span><span style="color: green;">' .$daily_counter['accepted']. '</span> / <span style="color: red;">' .$daily_counter['blocked']. '</span></span>';
486
  }
487
  $sfw_counter_str='';
488
  //Don't compile if SFW counter disabled
489
+ if( $apbct->settings['sfw_counter'] == 1 && $apbct->settings['spam_firewall'] == 1){
490
+ $sfw_counter=Array('all'=>$apbct->data['sfw_counter']['all'], 'blocked'=>$apbct->data['sfw_counter']['blocked']);
491
  $sfw_counter_str='<span style="color: white;" title="'.__('All / Blocked events. Access attempts regitred by SpamFireWall counted since the last plugin activation.', 'cleantalk').'"><span style="color: white;"> | SpamFireWall: ' .$sfw_counter['all']. '</span> / <span style="color: red;">' .$sfw_counter['blocked']. '</span></span>';
492
  }
493
 
 
 
494
  $args = array(
495
  'id' => 'ct_parent_node',
496
  'title' => '<img src="' . plugin_dir_url(__FILE__) . 'images/logo_small1.png" alt="" height="" style="margin-top:9px; float: left;" />'
497
  .'<div style="margin: auto 7px;" class="ab-item alignright">'
498
  .'<div class="ab-label" id="ct_stats">'
499
+ .($apbct->notice_trial == 1
500
+ ? "<span><a style='color: red;' href=\"http://cleantalk.org/my/bill/recharge?utm_source=wp-backend&utm_medium=cpc&utm_campaign=WP%20backend%20trial&user_token={$apbct->user_token}&cp_mode=antispam\" target=\"_blank\">Renew Anti-Spam</a></span>"
501
  : '<span style="color: white;" title="'.__('Allowed / Blocked submissions. The number of submissions is being counted since ', 'cleantalk').' '.$user_counter['since'].'">'.$user_counter_str.'</span> '.$daily_counter_str.$all_time_counter_str.$sfw_counter_str
502
  )
503
  .'</div>'
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 );
575
  }
576
  }
577
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
578
  /**
579
+ * Unmark bad words
580
+ * @param string $message
581
+ * @return string Cleat comment
582
  */
583
+ function apbct_comment__unmark_red($message) {
584
+ $message = preg_replace("/\<font rel\=\"cleantalk\" color\=\"\#FF1000\"\>(\S+)\<\/font>/iu", '$1', $message);
 
 
 
 
 
585
 
586
+ return $message;
587
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
588
 
589
  // Ajax action feedback form comments page.
590
+ function apbct_comment__send_feedback($comment_id = null, $comment_status = null, $change_status = false, $direct_call = null){
591
 
592
  // For AJAX call
593
  check_ajax_referer('ct_secret_nonce', 'security');
608
  // Approving
609
  if($comment_status == '1' || $comment_status == 'approve'){
610
  $result = ct_send_feedback($hash.":1");
611
+ // $comment['comment_content'] = apbct_comment__unmark_red($comment['comment_content']);
612
  // wp_update_comment($comment);
613
  $result === true ? 1 : 0;
614
  }
635
  }
636
 
637
  // Ajax action feedback form user page.
638
+ function apbct_user__send_feedback($user_id = null, $status = null, $direct_call = null){
639
 
640
  check_ajax_referer('ct_secret_nonce', 'security');
641
 
669
  }
670
 
671
  /**
672
+ * Send feedback when user deleted
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
673
  * @return null
674
  */
675
+ function apbct_user__delete__hook($user_id, $reassign = null){
676
 
677
  $hash = get_user_meta($user_id, 'ct_hash', true);
678
  if ($hash !== '') {
679
  ct_feedback($hash, 0);
680
  }
681
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
682
  ?>
inc/cleantalk-ajax.php CHANGED
@@ -248,10 +248,8 @@ function ct_mc4wp_ajax_hook( array $errors )
248
  function ct_ajax_hook($message_obj = false, $additional = false)
249
  {
250
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
251
- global $ct_checkjs_register_form, $bp, $ct_signup_done, $ct_negative_comment, $ct_options, $ct_data, $current_user;
252
-
253
- $ct_options = ct_get_options();
254
- $ct_data = ct_get_data();
255
  $sender_email = null;
256
  $message = '';
257
  $sender_nickname = null;
@@ -261,7 +259,7 @@ function ct_ajax_hook($message_obj = false, $additional = false)
261
  //
262
  // Skip test if Custom contact forms is disabled.
263
  //
264
- if (intval($ct_options['general_contact_forms_test'])==0 ) {
265
  return false;
266
  }
267
 
248
  function ct_ajax_hook($message_obj = false, $additional = false)
249
  {
250
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
251
+ global $apbct, $ct_checkjs_register_form, $bp, $ct_signup_done, $ct_negative_comment, $current_user;
252
+
 
 
253
  $sender_email = null;
254
  $message = '';
255
  $sender_nickname = null;
259
  //
260
  // Skip test if Custom contact forms is disabled.
261
  //
262
+ if (!$apbct->settings['general_contact_forms_test']) {
263
  return false;
264
  }
265
 
inc/cleantalk-comments.php CHANGED
@@ -16,18 +16,14 @@ function ct_add_comments_menu(){
16
 
17
  function ct_show_checkspam_page(){
18
 
19
- global $ct_plugin_name;
20
-
21
  ?>
22
  <div class="wrap">
23
- <h2><img src="<?php echo plugin_dir_url(__FILE__) ?>/images/logo_color.png" /> <?php echo $ct_plugin_name; ?></h2><br />
24
  <?php
25
 
26
  // If access key is unset in
27
- if(!ct_valid_key()){
28
- global $ct_data;
29
- $ct_data = ct_get_data();
30
- if($ct_data['moderate_ip'] = 1){
31
  echo '<h3>'
32
  .sprintf(
33
  __('Antispam hosting tariff does not allow you to use this feature. To do so, you need to enter an Access Key in the %splugin settings%s.', 'cleantalk'),
@@ -89,7 +85,7 @@ function ct_show_checkspam_page(){
89
  <input class="ct_date" type="text" id="ct_date_range_till" value="<?php echo isset($_GET['till']) ? $_GET['till'] : ''; ?>" disabled readonly />
90
  </div>
91
  <br>
92
- <?php ct_input_get_premium(); ?>
93
  </div>
94
 
95
  <!-- Cooling notice -->
@@ -279,9 +275,7 @@ function ct_ajax_check_comments(){
279
 
280
  check_ajax_referer( 'ct_secret_nonce', 'security' );
281
 
282
- global $wpdb, $ct_options, $ct_ip_penalty_days;
283
-
284
- $ct_options = ct_get_options();
285
 
286
  if(isset($_POST['from'], $_POST['till'])){
287
  $from_date = date('Y-m-d', intval(strtotime($_POST['from'])));
@@ -401,7 +395,7 @@ function ct_ajax_check_comments(){
401
  die();
402
  }
403
 
404
- $result = CleantalkHelper::api_method__spam_check_cms($ct_options['apikey'], $data, !empty($_POST['accurate_check']) ? $curr_date : null);
405
 
406
  if(empty($result['error'])){
407
 
@@ -650,7 +644,7 @@ function ct_comment_check_approve_comment(){
650
 
651
  $id=$_POST['id'];
652
  $comment = get_comment($id, 'ARRAY_A');
653
- $comment['comment_content'] = ct_unmark_red($comment['comment_content']);
654
  $comment['comment_approved'] = 1;
655
  update_comment_meta($id, 'ct_marked_as_spam', 0);
656
  wp_update_comment($comment);
16
 
17
  function ct_show_checkspam_page(){
18
 
 
 
19
  ?>
20
  <div class="wrap">
21
+ <h2><img src="<?php echo plugin_dir_url(__FILE__) ?>/images/logo_color.png" /> <?php echo APBCT_NAME; ?></h2><br />
22
  <?php
23
 
24
  // If access key is unset in
25
+ if(!apbct_api_key__is_correct()){
26
+ if($apbct->moderate_ip == 1){
 
 
27
  echo '<h3>'
28
  .sprintf(
29
  __('Antispam hosting tariff does not allow you to use this feature. To do so, you need to enter an Access Key in the %splugin settings%s.', 'cleantalk'),
85
  <input class="ct_date" type="text" id="ct_date_range_till" value="<?php echo isset($_GET['till']) ? $_GET['till'] : ''; ?>" disabled readonly />
86
  </div>
87
  <br>
88
+ <?php apbct_admin__badge__get_premium(); ?>
89
  </div>
90
 
91
  <!-- Cooling notice -->
275
 
276
  check_ajax_referer( 'ct_secret_nonce', 'security' );
277
 
278
+ global $wpdb, $apbct;
 
 
279
 
280
  if(isset($_POST['from'], $_POST['till'])){
281
  $from_date = date('Y-m-d', intval(strtotime($_POST['from'])));
395
  die();
396
  }
397
 
398
+ $result = CleantalkHelper::api_method__spam_check_cms($apbct->api_key, $data, !empty($_POST['accurate_check']) ? $curr_date : null);
399
 
400
  if(empty($result['error'])){
401
 
644
 
645
  $id=$_POST['id'];
646
  $comment = get_comment($id, 'ARRAY_A');
647
+ $comment['comment_content'] = apbct_comment__unmark_red($comment['comment_content']);
648
  $comment['comment_approved'] = 1;
649
  update_comment_meta($id, 'ct_marked_as_spam', 0);
650
  wp_update_comment($comment);
inc/cleantalk-common.php CHANGED
@@ -1,6 +1,5 @@
1
  <?php
2
 
3
- $ct_plugin_name = 'Antispam by CleanTalk';
4
  $ct_checkjs_frm = 'ct_checkjs_frm';
5
  $ct_checkjs_register_form = 'ct_checkjs_register_form';
6
 
@@ -32,24 +31,6 @@ $ct_approved_request_id_label = 'ct_approved_request_id';
32
  // Last request id approved for publication
33
  $ct_approved_request_id = null;
34
 
35
- // COOKIE label for trial notice flag
36
- $ct_notice_trial_label = 'ct_notice_trial';
37
-
38
- // Flag to show trial notice
39
- $show_ct_notice_trial = false;
40
-
41
- // COOKIE label for renew notice flag
42
- $ct_notice_renew_label = 'ct_notice_renew';
43
-
44
- // Flag to show renew notice
45
- $show_ct_notice_renew = false;
46
-
47
- // COOKIE label for online notice flag
48
- $ct_notice_online_label = 'ct_notice_online';
49
-
50
- // Flag to show online notice - 'Y' or 'N'
51
- $show_ct_notice_online = '';
52
-
53
  // Trial notice show time in minutes
54
  $trial_notice_showtime = 10;
55
 
@@ -62,12 +43,6 @@ $ct_wplp_result_label = 'ct_wplp_result';
62
  // Flag indicates active JetPack comments
63
  $ct_jp_comments = false;
64
 
65
- // S2member PayPal post data label
66
- $ct_post_data_label = 's2member_pro_paypal_registration';
67
-
68
- // S2member Auth.Net post data label
69
- $ct_post_data_authnet_label = 's2member_pro_authnet_registration';
70
-
71
  // WP admin email notice interval in seconds
72
  $ct_admin_notoice_period = 21600;
73
 
@@ -75,24 +50,10 @@ $ct_admin_notoice_period = 21600;
75
  // It uses for BuddyPress registrations to avoid double checks
76
  $ct_negative_comment = null;
77
 
78
- // Flag to show apikey automatic getting error
79
- $show_ct_notice_autokey = false;
80
-
81
- // Apikey automatic getting label
82
- $ct_notice_autokey_label = 'ct_autokey';
83
-
84
- // Apikey automatic getting error text
85
- $ct_notice_autokey_value = '';
86
-
87
  // Set globals to NULL to avoid massive DB requests. Globals will be set when needed only and by accessors only.
88
- $ct_options = NULL;
89
- $ct_data = NULL;
90
  $ct_server = NULL;
91
  $admin_email = NULL;
92
 
93
- // Timer in PHP sessions state.
94
- $ct_page_timer_setuped = false;
95
-
96
  /**
97
  * Public action 'plugins_loaded' - Loads locale, see http://codex.wordpress.org/Function_Reference/load_plugin_textdomain
98
  */
@@ -115,10 +76,7 @@ function apbct_plugin_loaded() {
115
  */
116
  function apbct_base_call($params = array(), $reg_flag = false){
117
 
118
- global $ct_options, $ct_data;
119
-
120
- $ct_options = ct_get_options();
121
- $ct_data = ct_get_data();
122
 
123
  $sender_info = !empty($params['sender_info'])
124
  ? array_merge(apbct_get_sender_info(), (array) $params['sender_info'])
@@ -134,7 +92,7 @@ function apbct_base_call($params = array(), $reg_flag = false){
134
  $ct_request->x_real_ip = CleantalkHelper::ip_get(array('x_real_ip'), false);
135
 
136
  // Misc
137
- $ct_request->auth_key = $ct_options['apikey'];
138
  $ct_request->message = !empty($params['message']) ? serialize(ct_filter_array($params['message'])) : null;
139
  $ct_request->example = !empty($params['example']) ? $params['example'] : null;
140
  $ct_request->sender_email = !empty($params['sender_email']) ? $params['sender_email'] : null;
@@ -147,11 +105,12 @@ function apbct_base_call($params = array(), $reg_flag = false){
147
 
148
  $ct = new Cleantalk();
149
 
150
- $ct->ssl_on = $ct_options['ssl_on'];
151
  $ct->ssl_path = APBCT_CASERT_PATH;
152
- $ct->server_url = $ct_options['server'];
153
  $ct->server_ttl = $config['ct_server_ttl'];
154
- $ct->work_url = $config['ct_work_url'];
 
155
  $ct->server_changed = $config['ct_server_changed'];
156
 
157
  if($reg_flag){
@@ -161,21 +120,21 @@ function apbct_base_call($params = array(), $reg_flag = false){
161
  }
162
 
163
  if ($ct_result->errno === 0 && empty($ct_result->errstr))
164
- $ct_data['connection_reports']['success']++;
165
  else
166
  {
167
- $ct_data['connection_reports']['negative']++;
168
- $ct_data['connection_reports']['negative_report'][] = array('date'=>date("Y-m-d H:i:s"),'page_url'=>$_SERVER['REQUEST_URI'],'lib_report'=>$ct_result->errstr);
169
 
170
- if(count($ct_data['connection_reports']['negative_report']) > 20)
171
- $ct_data['connection_reports']['negative_report'] = array_slice($ct_data['connection_reports']['negative_report'], -20, 20);
172
 
173
  }
174
  if ($ct->server_change) {
175
  update_option(
176
  'cleantalk_server',
177
  array(
178
- 'ct_work_url' => $ct->work_url,
179
  'ct_server_ttl' => $ct->server_ttl,
180
  'ct_server_changed' => time(),
181
  )
@@ -201,7 +160,9 @@ function apbct_base_call($params = array(), $reg_flag = false){
201
  * @return array
202
  */
203
  function apbct_get_sender_info() {
204
-
 
 
205
  // Validate cookie from the backend
206
  $cookie_is_ok = apbct_cookies_test();
207
 
@@ -226,7 +187,7 @@ function apbct_get_sender_info() {
226
  'USER_AGENT' => isset($_SERVER['HTTP_USER_AGENT']) ? htmlspecialchars($_SERVER['HTTP_USER_AGENT']) : null,
227
  'page_url' => isset($_SERVER['SERVER_NAME'], $_SERVER['REQUEST_URI']) ? htmlspecialchars($_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']) : null,
228
  'cms_lang' => substr(get_locale(), 0, 2),
229
- 'ct_options' => json_encode(ct_get_options()),
230
  'fields_number' => sizeof($_POST),
231
  'direct_post' => $cookie_is_ok === null && $_SERVER['REQUEST_METHOD'] == 'POST' ? 1 : 0,
232
  // Raw data to validated JavaScript test in the cloud
@@ -255,12 +216,11 @@ function apbct_get_sender_info() {
255
  * @return string
256
  */
257
  function ct_get_checkjs_value($random_key = false) {
258
- global $ct_options, $ct_data;
259
- $ct_options = ct_get_options();
260
- $ct_data = ct_get_data();
261
-
262
  if ($random_key) {
263
- $keys = $ct_data['js_keys'];
264
  $keys_checksum = md5(json_encode($keys));
265
 
266
  $key = null;
@@ -268,7 +228,7 @@ function ct_get_checkjs_value($random_key = false) {
268
  foreach ($keys as $k => $t) {
269
 
270
  // Removing key if it's to old
271
- if (time() - $t > $ct_data['js_keys_store_days'] * 86400) {
272
  unset($keys[$k]);
273
  continue;
274
  }
@@ -280,17 +240,17 @@ function ct_get_checkjs_value($random_key = false) {
280
  }
281
 
282
  // Get new key if the latest key is too old
283
- if (time() - $latest_key_time > $ct_data['js_key_lifetime']) {
284
  $key = rand();
285
  $keys[$key] = time();
286
  }
287
 
288
  if (md5(json_encode($keys)) != $keys_checksum) {
289
- $ct_data['js_keys'] = $keys;
290
- update_option('cleantalk_data', $ct_data);
291
  }
292
  } else {
293
- $key = md5($ct_options['apikey'] . '+' . ct_get_admin_email());
294
  }
295
 
296
  return $key;
@@ -333,154 +293,6 @@ function ct_get_server($force=false) {
333
  }
334
  }
335
 
336
- /**
337
- * Inner function - Current Cleantalk options
338
- * @return mixed[] Array of options
339
- */
340
- function ct_get_options($force=false) {
341
- global $ct_options;
342
- if(!$force && isset($ct_options) && isset($ct_options['apikey']) && strlen($ct_options['apikey'])>3)
343
- {
344
- //
345
- // Skip query to get options because we already have options.
346
- //
347
- if(defined('CLEANTALK_ACCESS_KEY'))
348
- {
349
- $options['apikey']=CLEANTALK_ACCESS_KEY;
350
- }
351
- return $ct_options;
352
- }
353
- else
354
- {
355
- $options = get_option('cleantalk_settings');
356
- if (!is_array($options)){
357
- $options = array();
358
- }else{
359
- if(array_key_exists('apikey', $options))
360
- $options['apikey'] = trim($options['apikey']);
361
- }
362
- if(defined('CLEANTALK_ACCESS_KEY'))
363
- {
364
- $options['apikey']=CLEANTALK_ACCESS_KEY;
365
- }
366
- $options = array_merge(ct_def_options(), (array) $options);
367
-
368
- if ($options['apikey'] === 'enter key' || $options['apikey'] === '') {
369
- if ($options['protect_logged_in'] == -1) {
370
- $options['protect_logged_in'] = 1;
371
- }
372
- }
373
-
374
- return $options;
375
- }
376
- }
377
-
378
- /**
379
- * Inner function - Default Cleantalk options
380
- * @return mixed[] Array of default options
381
- */
382
- function ct_def_options() {
383
- return array(
384
- 'spam_firewall' => '0',
385
- 'server' => 'http://moderate.cleantalk.org',
386
- 'apikey' => '',
387
- 'autoPubRevelantMess' => '0',
388
- //Forms for protection
389
- 'registrations_test' => '1',
390
- 'comments_test' => '1',
391
- 'contact_forms_test' => '1',
392
- 'general_contact_forms_test' => '1', // Antispam test for unsupported and untested contact forms
393
- 'wc_checkout_test' => '0', //WooCommerce checkout default test => OFF
394
- 'check_external' => '0',
395
- 'check_internal' => '0',
396
- //Comments and messages
397
- 'bp_private_messages' => '1', //buddyPress private messages test => ON
398
- 'check_comments_number' => '1',
399
- 'remove_old_spam' => '0',
400
- 'remove_comments_links' => '0', //Removes links from approved comments
401
- 'show_check_links' => '1', //Shows check link to Cleantalk's DB. And allowing to control comments form public page.
402
- //Data processing
403
- 'protect_logged_in' => '1', // Do anit-spam tests to for logged in users.
404
- 'use_ajax' => '1',
405
- 'general_postdata_test' => '0', //CAPD
406
- 'set_cookies'=> '1', // Disable cookies generatation to be compatible with Varnish.
407
- 'ssl_on' => '0', // Secure connection to servers
408
- //Administrator Panel
409
- 'show_adminbar' => '1', // Show the admin bar.
410
- 'all_time_counter' => '0',
411
- 'daily_counter' => '0',
412
- //Others
413
- 'spam_store_days' => '15', // Days before delete comments from folder Spam
414
- 'relevance_test' => 0, // Test comment for relevance
415
- 'notice_api_errors' => 0, // Send API error notices to WP admin
416
- 'user_token'=>'', //user token for auto login into spam statistics
417
- 'collect_details' => 0, // Collect details about browser of the visitor.
418
- 'send_connection_reports' => 0, //Send connection reports to Cleantalk servers
419
- 'show_link' => 0,
420
- 'async_js' => 0,
421
- );
422
- }
423
-
424
- /**
425
- * Inner function - Current Cleantalk data
426
- * @return mixed[] Array of options
427
- */
428
- function ct_get_data($force=false) {
429
- global $ct_data;
430
- if(!$force && isset($ct_data) && isset($ct_data['js_keys']))
431
- {
432
- return $ct_data;
433
- }
434
- else
435
- {
436
- $data = get_option('cleantalk_data');
437
- if (!is_array($data)){
438
- $data = array();
439
- }
440
- return array_merge(ct_def_data(), (array) $data);
441
- }
442
- }
443
-
444
- /**
445
- * Inner function - Default Cleantalk data
446
- * @return mixed[] Array of default options
447
- */
448
- function ct_def_data() {
449
-
450
- return array(
451
- 'start_version' => APBCT_VERSION,
452
- 'user_token' => '', // User token
453
- 'js_keys' => array(), // Keys to do JavaScript antispam test
454
- 'js_keys_store_days' => 14, // JavaScript keys store days - 8 days now
455
- 'js_key_lifetime' => 86400, // JavaScript key life time in seconds - 1 day now
456
- 'ip_license' => 0,
457
- 'service_id' => 0,
458
- 'moderate' => 0,
459
- 'sfw_counter' => array(
460
- 'all' => 0,
461
- 'blocked' => 0
462
- ),
463
- 'array_accepted' => array(),
464
- 'array_blocked' => array(),
465
- 'current_hour' => '',
466
- 'all_time_counter' => array(
467
- 'accepted' => 0,
468
- 'blocked' => 0
469
- ),
470
- 'user_counter' => array(
471
- 'accepted' => 0,
472
- 'blocked' => 0,
473
- 'since' => date('d M')
474
- ),
475
- 'connection_reports' => array(
476
- 'success' => 0,
477
- 'negative' => 0,
478
- 'negative_report' => array(),
479
- 'since' => date('d M')
480
- )
481
- );
482
- }
483
-
484
  /**
485
  * Inner function - Stores ang returns cleantalk hash of current comment
486
  * @param string New hash or NULL
@@ -507,17 +319,13 @@ function ct_hash($new_hash = '') {
507
  */
508
  function ct_feedback($hash, $allow) {
509
 
510
- global $ct_data;
511
-
512
- $ct_data = ct_get_data();
513
-
514
  $ct_feedback = $hash . ':' . $allow . ';';
515
- if(empty($ct_data['feedback_request']))
516
- $ct_data['feedback_request'] = $ct_feedback;
517
  else
518
- $ct_data['feedback_request'] .= $ct_feedback;
519
 
520
- update_option('cleantalk_data', $ct_data);
521
  }
522
 
523
  /**
@@ -528,39 +336,42 @@ function ct_feedback($hash, $allow) {
528
  */
529
  function ct_send_feedback($feedback_request = null) {
530
 
531
- global $ct_options, $ct_data;
532
-
533
- $ct_options = ct_get_options();
534
- $ct_data = ct_get_data();
535
-
536
- if (empty($feedback_request) && isset($ct_data['feedback_request']) && preg_match("/^[a-z0-9\;\:]+$/", $ct_data['feedback_request'])){
537
- $feedback_request = $ct_data['feedback_request'];
538
- unset($ct_data['feedback_request']);
539
- update_option('cleantalk_data', $ct_data);
540
  }
541
-
542
  if ($feedback_request !== null) {
543
 
544
  $config = ct_get_server();
545
-
546
  $ct = new Cleantalk();
547
- $ct->work_url = $config['ct_work_url'];
548
- $ct->server_url = $ct_options['server'];
 
 
549
  $ct->server_ttl = $config['ct_server_ttl'];
550
  $ct->server_changed = $config['ct_server_changed'];
551
-
552
  $ct_request = new CleantalkRequest();
553
- $ct_request->auth_key = $ct_options['apikey'];
554
  $ct_request->feedback = $feedback_request;
555
-
556
  $ct->sendFeedback($ct_request);
557
-
 
 
 
558
  if ($ct->server_change) {
559
  update_option(
560
- 'cleantalk_server', array(
561
- 'ct_work_url' => $ct->work_url,
562
- 'ct_server_ttl' => $ct->server_ttl,
563
- 'ct_server_changed' => time()
 
564
  )
565
  );
566
  }
@@ -576,15 +387,13 @@ function ct_send_feedback($feedback_request = null) {
576
  * @return null
577
  */
578
  function ct_delete_spam_comments() {
579
- global $pagenow, $ct_options, $ct_data;
580
-
581
- $ct_options = ct_get_options();
582
- $ct_data = ct_get_data();
583
 
584
- if ($ct_options['remove_old_spam'] == 1) {
585
  $last_comments = get_comments(array('status' => 'spam', 'number' => 1000, 'order' => 'ASC'));
586
  foreach ($last_comments as $c) {
587
- if (time() - strtotime($c->comment_date_gmt) > 86400 * $ct_options['spam_store_days']) {
588
  // Force deletion old spam comments
589
  wp_delete_comment($c->comment_ID, true);
590
  }
@@ -939,8 +748,7 @@ function cleantalk_debug($key,$value)
939
  * @return object
940
  */
941
  function ct_change_plugin_resonse($ct_result = null, $checkjs = null) {
942
- global $ct_plugin_name;
943
-
944
  if (!$ct_result) {
945
  return $ct_result;
946
  }
@@ -953,7 +761,7 @@ function ct_change_plugin_resonse($ct_result = null, $checkjs = null) {
953
  $ct_result->spam = 1;
954
  $ct_result->comment = sprintf('We\'ve got an issue: %s. Forbidden. Please, enable Javascript. %s.',
955
  $ct_result->comment,
956
- $ct_plugin_name
957
  );
958
  }
959
  else
@@ -966,4 +774,16 @@ function ct_change_plugin_resonse($ct_result = null, $checkjs = null) {
966
  return $ct_result;
967
  }
968
 
 
 
 
 
 
 
 
 
 
 
 
 
969
  ?>
1
  <?php
2
 
 
3
  $ct_checkjs_frm = 'ct_checkjs_frm';
4
  $ct_checkjs_register_form = 'ct_checkjs_register_form';
5
 
31
  // Last request id approved for publication
32
  $ct_approved_request_id = null;
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  // Trial notice show time in minutes
35
  $trial_notice_showtime = 10;
36
 
43
  // Flag indicates active JetPack comments
44
  $ct_jp_comments = false;
45
 
 
 
 
 
 
 
46
  // WP admin email notice interval in seconds
47
  $ct_admin_notoice_period = 21600;
48
 
50
  // It uses for BuddyPress registrations to avoid double checks
51
  $ct_negative_comment = null;
52
 
 
 
 
 
 
 
 
 
 
53
  // Set globals to NULL to avoid massive DB requests. Globals will be set when needed only and by accessors only.
 
 
54
  $ct_server = NULL;
55
  $admin_email = NULL;
56
 
 
 
 
57
  /**
58
  * Public action 'plugins_loaded' - Loads locale, see http://codex.wordpress.org/Function_Reference/load_plugin_textdomain
59
  */
76
  */
77
  function apbct_base_call($params = array(), $reg_flag = false){
78
 
79
+ global $apbct;
 
 
 
80
 
81
  $sender_info = !empty($params['sender_info'])
82
  ? array_merge(apbct_get_sender_info(), (array) $params['sender_info'])
92
  $ct_request->x_real_ip = CleantalkHelper::ip_get(array('x_real_ip'), false);
93
 
94
  // Misc
95
+ $ct_request->auth_key = $apbct->api_key;
96
  $ct_request->message = !empty($params['message']) ? serialize(ct_filter_array($params['message'])) : null;
97
  $ct_request->example = !empty($params['example']) ? $params['example'] : null;
98
  $ct_request->sender_email = !empty($params['sender_email']) ? $params['sender_email'] : null;
105
 
106
  $ct = new Cleantalk();
107
 
108
+ $ct->ssl_on = $apbct->settings['ssl_on'];
109
  $ct->ssl_path = APBCT_CASERT_PATH;
110
+ $ct->server_url = $apbct->settings['server'];
111
  $ct->server_ttl = $config['ct_server_ttl'];
112
+ // Options store url without shceme because of DB error with ''://'
113
+ $ct->work_url = preg_match('/http/', $config['ct_work_url']) ? $config['ct_work_url'] : 'http://'.$config['ct_work_url'];
114
  $ct->server_changed = $config['ct_server_changed'];
115
 
116
  if($reg_flag){
120
  }
121
 
122
  if ($ct_result->errno === 0 && empty($ct_result->errstr))
123
+ $apbct->data['connection_reports']['success']++;
124
  else
125
  {
126
+ $apbct->data['connection_reports']['negative']++;
127
+ $apbct->data['connection_reports']['negative_report'][] = array('date'=>date("Y-m-d H:i:s"),'page_url'=>$_SERVER['REQUEST_URI'],'lib_report'=>$ct_result->errstr);
128
 
129
+ if(count($apbct->data['connection_reports']['negative_report']) > 20)
130
+ $apbct->data['connection_reports']['negative_report'] = array_slice($apbct->data['connection_reports']['negative_report'], -20, 20);
131
 
132
  }
133
  if ($ct->server_change) {
134
  update_option(
135
  'cleantalk_server',
136
  array(
137
+ 'ct_work_url' => preg_replace('/http[s]?:\/\/(.*)/', '$1', $ct->work_url),
138
  'ct_server_ttl' => $ct->server_ttl,
139
  'ct_server_changed' => time(),
140
  )
160
  * @return array
161
  */
162
  function apbct_get_sender_info() {
163
+
164
+ global $apbct;
165
+
166
  // Validate cookie from the backend
167
  $cookie_is_ok = apbct_cookies_test();
168
 
187
  'USER_AGENT' => isset($_SERVER['HTTP_USER_AGENT']) ? htmlspecialchars($_SERVER['HTTP_USER_AGENT']) : null,
188
  'page_url' => isset($_SERVER['SERVER_NAME'], $_SERVER['REQUEST_URI']) ? htmlspecialchars($_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']) : null,
189
  'cms_lang' => substr(get_locale(), 0, 2),
190
+ 'ct_options' => json_encode($apbct->settings),
191
  'fields_number' => sizeof($_POST),
192
  'direct_post' => $cookie_is_ok === null && $_SERVER['REQUEST_METHOD'] == 'POST' ? 1 : 0,
193
  // Raw data to validated JavaScript test in the cloud
216
  * @return string
217
  */
218
  function ct_get_checkjs_value($random_key = false) {
219
+
220
+ global $apbct;
221
+
 
222
  if ($random_key) {
223
+ $keys = $apbct->data['js_keys'];
224
  $keys_checksum = md5(json_encode($keys));
225
 
226
  $key = null;
228
  foreach ($keys as $k => $t) {
229
 
230
  // Removing key if it's to old
231
+ if (time() - $t > $apbct->data['js_keys_store_days'] * 86400) {
232
  unset($keys[$k]);
233
  continue;
234
  }
240
  }
241
 
242
  // Get new key if the latest key is too old
243
+ if (time() - $latest_key_time > $apbct->data['js_key_lifetime']) {
244
  $key = rand();
245
  $keys[$key] = time();
246
  }
247
 
248
  if (md5(json_encode($keys)) != $keys_checksum) {
249
+ $apbct->data['js_keys'] = $keys;
250
+ $apbct->saveData();
251
  }
252
  } else {
253
+ $key = md5($apbct->api_key . '+' . ct_get_admin_email());
254
  }
255
 
256
  return $key;
293
  }
294
  }
295
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  /**
297
  * Inner function - Stores ang returns cleantalk hash of current comment
298
  * @param string New hash or NULL
319
  */
320
  function ct_feedback($hash, $allow) {
321
 
 
 
 
 
322
  $ct_feedback = $hash . ':' . $allow . ';';
323
+ if($apbct->data['feedback_request'])
324
+ $apbct->data['feedback_request'] = $ct_feedback;
325
  else
326
+ $apbct->data['feedback_request'] .= $ct_feedback;
327
 
328
+ $apbct->saveData();
329
  }
330
 
331
  /**
336
  */
337
  function ct_send_feedback($feedback_request = null) {
338
 
339
+ global $apbct;
340
+
341
+ if (empty($feedback_request) && isset($apbct->data['feedback_request']) && preg_match("/^[a-z0-9\;\:]+$/", $apbct->data['feedback_request'])){
342
+ $feedback_request = $apbct->data['feedback_request'];
343
+ $apbct->data['feedback_request'] = '';
344
+ $apbct->saveData();
 
 
 
345
  }
346
+
347
  if ($feedback_request !== null) {
348
 
349
  $config = ct_get_server();
350
+
351
  $ct = new Cleantalk();
352
+
353
+ // Options store url without shceme because of DB error with ''://'
354
+ $ct->work_url = preg_match('/http/', $config['ct_work_url']) ? $config['ct_work_url'] : 'http://'.$config['ct_work_url'];
355
+ $ct->server_url = $apbct->settings['server'];
356
  $ct->server_ttl = $config['ct_server_ttl'];
357
  $ct->server_changed = $config['ct_server_changed'];
358
+
359
  $ct_request = new CleantalkRequest();
360
+ $ct_request->auth_key = $apbct->api_key;
361
  $ct_request->feedback = $feedback_request;
362
+
363
  $ct->sendFeedback($ct_request);
364
+
365
+ $ct->work_url = '162.243.144.2';
366
+ $ct->server_change = true;
367
+
368
  if ($ct->server_change) {
369
  update_option(
370
+ 'cleantalk_server',
371
+ array(
372
+ 'ct_work_url' => preg_replace('/http[s]?:\/\/(.*)/', '$1', $ct->work_url),
373
+ 'ct_server_ttl' => $ct->server_ttl,
374
+ 'ct_server_changed' => time()
375
  )
376
  );
377
  }
387
  * @return null
388
  */
389
  function ct_delete_spam_comments() {
390
+
391
+ global $apbct;
 
 
392
 
393
+ if ($apbct->settings['remove_old_spam'] == 1) {
394
  $last_comments = get_comments(array('status' => 'spam', 'number' => 1000, 'order' => 'ASC'));
395
  foreach ($last_comments as $c) {
396
+ if (time() - strtotime($c->comment_date_gmt) > 86400 * $apbct->settings['spam_store_days']) {
397
  // Force deletion old spam comments
398
  wp_delete_comment($c->comment_ID, true);
399
  }
748
  * @return object
749
  */
750
  function ct_change_plugin_resonse($ct_result = null, $checkjs = null) {
751
+
 
752
  if (!$ct_result) {
753
  return $ct_result;
754
  }
761
  $ct_result->spam = 1;
762
  $ct_result->comment = sprintf('We\'ve got an issue: %s. Forbidden. Please, enable Javascript. %s.',
763
  $ct_result->comment,
764
+ APBCT_NAME
765
  );
766
  }
767
  else
774
  return $ct_result;
775
  }
776
 
777
+ /**
778
+ * Does key has correct symbols? Checks against regexp ^[a-z\d]{3,15}$
779
+ * @param api_key
780
+ * @return bool
781
+ */
782
+ function apbct_api_key__is_correct($api_key = null)
783
+ {
784
+ global $apbct;
785
+ $api_key = $api_key !== null ? $api_key : $apbct->api_key;
786
+ return $api_key && preg_match('/^[a-z\d]{3,15}$/', $api_key) ? true : false;
787
+ }
788
+
789
  ?>
inc/cleantalk-public.php CHANGED
@@ -5,14 +5,14 @@
5
  * @return mixed[] Array of options
6
  */
7
  function apbct_init() {
8
- global $ct_wplp_result_label, $ct_jp_comments, $ct_post_data_label, $ct_post_data_authnet_label, $ct_options, $ct_data, $ct_check_post_result, $test_external_forms, $cleantalk_executed, $wpdb;
9
 
10
- $ct_options = ct_get_options();
11
- $ct_data=ct_get_data();
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
- (isset($ct_options['check_internal']) && intval($ct_options['check_internal']))
16
  ){
17
  $ct_result = ct_contact_form_validate();
18
  if($ct_result == null){
@@ -35,7 +35,7 @@ function apbct_init() {
35
  add_shortcode( 'et_pb_contact_form', 'ct_contact_form_validate' );
36
  }
37
 
38
- if(!empty($ct_options['check_external'])
39
  && isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST'
40
  && isset($_POST['cleantalk_hidden_method'])
41
  && isset($_POST['cleantalk_hidden_action'])
@@ -61,19 +61,11 @@ function apbct_init() {
61
  }
62
  }
63
 
64
- if(isset($ct_options['general_postdata_test']) && $ct_options['general_postdata_test'] == 1 && !@isset($_POST['ct_checkjs_cf7']))
65
- {
66
- $ct_general_postdata_test = @intval($ct_options['general_postdata_test']);
67
- //hook for Anonymous Post
68
  add_action('template_redirect','ct_contact_form_validate_postdata',1);
69
- }
70
- else
71
- {
72
- $ct_general_postdata_test=0;
73
- }
74
 
75
- if (isset($ct_options['general_contact_forms_test']) && $ct_options['general_contact_forms_test'] == 1&&!@isset($_POST['ct_checkjs_cf7']))
76
- {
77
  add_action('CMA_custom_post_type_nav','ct_contact_form_validate_postdata',1);
78
  add_action('template_redirect','ct_contact_form_validate',1);
79
  if(isset($_POST['reg_redirect_link'])&&isset($_POST['tmpl_registration_nonce_field']))
@@ -90,10 +82,8 @@ function apbct_init() {
90
  }*/
91
  }
92
 
93
- if($ct_general_postdata_test==1&&!@isset($_POST['ct_checkjs_cf7']))
94
- {
95
  add_action('CMA_custom_post_type_nav','ct_contact_form_validate_postdata',1);
96
- }
97
 
98
  //add_action('wp_footer','ct_ajaxurl');
99
 
@@ -194,9 +184,15 @@ function apbct_init() {
194
  }
195
 
196
  // intercept S2member POST
197
- if (defined('WS_PLUGIN__S2MEMBER_PRO_VERSION') && (isset($_POST[$ct_post_data_label]['email']) || isset($_POST[$ct_post_data_authnet_label]['email']))){
198
- ct_s2member_registration_test();
199
- }
 
 
 
 
 
 
200
 
201
  //
202
  // New user approve hack
@@ -230,18 +226,18 @@ function apbct_init() {
230
  add_action('wp_footer', 'ct_footer_add_cookie', 1);
231
  }
232
 
233
- if ($ct_options['protect_logged_in'] != 1 && is_user_logged_in()) {
234
  $ct_check_post_result=false;
235
  ct_contact_form_validate();
236
  }
237
 
238
  if (ct_is_user_enable()) {
239
 
240
- if (isset($ct_options['general_contact_forms_test']) && $ct_options['general_contact_forms_test'] == 1 && !isset($_POST['comment_post_ID']) && !isset($_GET['for'])){
241
  $ct_check_post_result=false;
242
  ct_contact_form_validate();
243
  }
244
- if(isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST' && $ct_general_postdata_test==1 && !is_admin() && !@isset($_POST['ct_checkjs_cf7'])){
245
  $ct_check_post_result=false;
246
  ct_contact_form_validate_postdata();
247
  }
@@ -282,15 +278,15 @@ function ct_ccf($callback, $value, $field_id, $type){
282
  */
283
  $ct_global_temporary_data = array();
284
  function ct_validate_ccf_submission($value, $field_id, $required){
285
- global $ct_global_temporary_data, $ct_options;
 
286
 
287
- $ct_options = ct_get_options();
288
 
289
  //If the check for contact forms enabled
290
- if(isset($ct_options['contact_forms_test']) && intval($ct_options['contact_forms_test']) == '0')
291
  return true;
292
  //If the check for logged in users enabled
293
- if(isset($ct_options['protect_logged_in']) && intval($ct_options['protect_logged_in']) == 1 && is_user_logged_in())
294
  return true;
295
 
296
  //Accumulate data
@@ -342,13 +338,13 @@ function ct_validate_ccf_submission($value, $field_id, $required){
342
  }
343
 
344
  function ct_woocommerce_wishlist_check($args){
345
- global $ct_options;
 
346
 
347
- $ct_options = ct_get_options();
348
 
349
  //Protect logged in users
350
  if($args['wishlist_status'])
351
- if(isset($ct_options['protect_logged_in']) && $ct_options['protect_logged_in'] == 0)
352
  return $args;
353
 
354
  //If the IP is a Google bot
@@ -398,12 +394,12 @@ function ct_woocommerce_wishlist_check($args){
398
  */
399
 
400
  function ct_bp_private_msg_check( $bp_message_obj){
401
- global $ct_options;
 
402
 
403
- $ct_options = ct_get_options();
404
 
405
  //Check for enabled option
406
- if($ct_options['bp_private_messages'] == 0)
407
  return;
408
 
409
  //Check for quantity of comments
@@ -412,13 +408,8 @@ function ct_bp_private_msg_check( $bp_message_obj){
412
  $comments_check_number = CLEANTALK_CHECK_COMMENTS_NUMBER;
413
  else
414
  $comments_check_number = 3;
415
-
416
- if(isset($ct_options['check_comments_number']))
417
- $value = @intval($ct_options['check_comments_number']);
418
- else
419
- $value=1;
420
-
421
- if($value == 1){
422
  $args = array(
423
  'user_id' => $bp_message_obj->sender_id,
424
  'box' => 'sentbox',
@@ -479,12 +470,11 @@ function ct_bp_private_msg_check( $bp_message_obj){
479
  * return NULL
480
  */
481
  function ct_pirate_forms_check(){
482
- global $ct_options;
483
 
484
- $ct_options = ct_get_options();
485
 
486
  //Check for enabled option
487
- if($ct_options['contact_forms_test'] == 0)
488
  return;
489
 
490
  //Getting request params
@@ -532,16 +522,15 @@ function ct_ajaxurl() {
532
  /**
533
  * Adds hidden filed to comment form
534
  */
535
- function ct_comment_form($post_id) {
536
- global $ct_options, $ct_data;
537
- $ct_options = ct_get_options();
538
- $ct_data = ct_get_data();
539
 
540
  if (ct_is_user_enable() === false) {
541
  return false;
542
  }
543
 
544
- if ($ct_options['comments_test'] == 0) {
545
  return false;
546
  }
547
 
@@ -566,14 +555,14 @@ function ct_footer_add_cookie() {
566
  */
567
  function ct_add_hidden_fields($random_key = false, $field_name = 'ct_checkjs', $return_string = false, $cookie_check = false, $no_print = false) {
568
 
569
- global $ct_checkjs_def, $ct_plugin_name, $ct_options, $ct_data;
570
 
571
- $ct_options = ct_get_options();
572
 
573
  $ct_checkjs_key = ct_get_checkjs_value($random_key);
574
  $field_id_hash = md5(rand(0, 1000));
575
 
576
- if ($cookie_check && isset($ct_options['set_cookies']) && $ct_options['set_cookies'] == 1) {
577
  $html = "<script type='text/javascript'>
578
  function ctSetCookie(c_name, value, def_value){
579
  document.cookie = c_name + '=' + escape(value) + '; path=/';
@@ -636,9 +625,9 @@ function ct_is_user_enable() {
636
  * return null;
637
  */
638
  function ct_frm_entries_footer_scripts($fields, $form) {
639
- global $ct_options, $ct_checkjs_frm;
640
 
641
- if ($ct_options['contact_forms_test'] == 0)
642
  return false;
643
 
644
  $ct_checkjs_key = ct_get_checkjs_value();
@@ -667,17 +656,17 @@ function ct_frm_entries_footer_scripts($fields, $form) {
667
  * return @array with errors if spam has found
668
  */
669
  function ct_frm_validate_entry ($errors, $values) {
670
- global $wpdb, $current_user, $ct_checkjs_frm, $ct_options, $ct_data;
671
 
672
- $ct_options = ct_get_options();
673
- $ct_data = ct_get_data();
674
 
675
- if ($ct_options['contact_forms_test'] == 0) {
 
 
676
  return $errors;
677
  }
678
 
679
  // Skip processing for logged in users.
680
- if ($ct_options['protect_logged_in'] != 1 && is_user_logged_in()) {
681
  return $errors;
682
  }
683
 
@@ -737,17 +726,17 @@ function ct_bbp_get_topic($topic){
737
  * @return mixed[] $comment Comment string
738
  */
739
  function ct_bbp_new_pre_content ($comment) {
740
- global $ct_options, $ct_data, $current_user, $ct_bbp_topic;
 
 
741
 
742
- $ct_options = ct_get_options();
743
- $ct_data = ct_get_data();
744
 
745
- if ($ct_options['comments_test'] == 0 ) {
746
  return $comment;
747
  }
748
 
749
  // Skip processing for logged in users and admin.
750
- if ($ct_options['protect_logged_in'] != 1 && is_user_logged_in() ||
751
  in_array("administrator", $current_user->roles))
752
  return $comment;
753
 
@@ -791,19 +780,18 @@ function ct_preprocess_comment($comment) {
791
  // this action is called just when WP process POST request (adds new comment)
792
  // this action is called by wp-comments-post.php
793
  // after processing WP makes redirect to post page with comment's form by GET request (see above)
794
- global $wpdb, $current_user, $comment_post_id, $ct_comment_done, $ct_approved_request_id_label, $ct_jp_comments, $ct_options, $ct_data;
 
 
795
 
796
- $ct_options = ct_get_options();
797
- $ct_data = ct_get_data();
798
 
799
  // Skip processing admin.
800
  if (in_array("administrator", $current_user->roles))
801
  return $comment;
802
 
803
  $comments_check_number = defined('CLEANTALK_CHECK_COMMENTS_NUMBER') ? CLEANTALK_CHECK_COMMENTS_NUMBER : 3;
804
- $value = isset($ct_options['check_comments_number']) ? intval($ct_options['check_comments_number']) : 1;
805
 
806
- if($value == 1){
807
  $args = array(
808
  'author_email' => $comment['comment_author_email'],
809
  'status' => 'approve',
@@ -818,7 +806,7 @@ function ct_preprocess_comment($comment) {
818
  ($comment['comment_type']!='trackback') &&
819
  (
820
  ct_is_user_enable() === false ||
821
- $ct_options['comments_test'] == 0 ||
822
  $ct_comment_done ||
823
  (isset($_SERVER['HTTP_REFERER']) && stripos($_SERVER['HTTP_REFERER'],'page=wysija_campaigns&action=editTemplate')!==false) ||
824
  (isset($is_max_comments) && $is_max_comments) ||
@@ -864,7 +852,7 @@ function ct_preprocess_comment($comment) {
864
 
865
 
866
  $example = null;
867
- if ($ct_options['relevance_test']) {
868
  $post = get_post($comment_post_id);
869
  if ($post !== null){
870
  $example['title'] = $post->post_title;
@@ -946,7 +934,7 @@ function ct_preprocess_comment($comment) {
946
  add_action('comment_post', 'ct_die', 999, 2);
947
  }
948
 
949
- if(isset($ct_options['remove_comments_links']) && $ct_options['remove_comments_links'] == '1'){
950
  $comment = preg_replace("~(http|https|ftp|ftps)://(.*?)(\s|\n|[,.?!](\s|\n)|$)~", '[Link deleted]', $comment);
951
  }
952
 
@@ -989,10 +977,10 @@ function ct_die_extended($comment_body) {
989
  *
990
  */
991
  function apbct_js_test($field_name = 'ct_checkjs', $data = null, $random_key = false) {
992
- global $ct_options, $ct_data;
 
 
993
 
994
- $ct_options = ct_get_options();
995
- $ct_data = ct_get_data();
996
 
997
  $checkjs = null;
998
  $js_post_value = null;
@@ -1008,7 +996,7 @@ function apbct_js_test($field_name = 'ct_checkjs', $data = null, $random_key = f
1008
  //
1009
  if ($random_key) {
1010
 
1011
- $keys = $ct_data['js_keys'];
1012
  if (isset($keys[$js_post_value])) {
1013
  $checkjs = 1;
1014
  } else {
@@ -1150,12 +1138,12 @@ function ct_plugin_active($plugin_name){
1150
  * @return null
1151
  */
1152
  function ct_register_form() {
1153
- global $ct_checkjs_register_form, $ct_options, $ct_data;
 
 
1154
 
1155
- $ct_options = ct_get_options();
1156
- $ct_data = ct_get_data();
1157
 
1158
- if ($ct_options['registrations_test'] == 0) {
1159
  return false;
1160
  }
1161
 
@@ -1170,11 +1158,11 @@ function ct_register_form() {
1170
  */
1171
  function ct_login_message($message) {
1172
 
1173
- global $errors, $ct_options, $apbct_cookie_register_ok_label;
1174
 
1175
- $ct_options = ct_get_options();
1176
 
1177
- if ($ct_options['registrations_test'] != 0){
1178
  if( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ){
1179
  if (isset($_COOKIE[$apbct_cookie_register_ok_label])){
1180
  if(is_wp_error($errors)){
@@ -1275,9 +1263,9 @@ function ct_test_message($nickname, $email, $ip, $text){
1275
  * @return array with checking result;
1276
  */
1277
  function ct_test_registration($nickname, $email, $ip){
1278
- global $ct_checkjs_register_form, $ct_options;
 
1279
 
1280
- $ct_options = ct_get_options();
1281
 
1282
  $checkjs = apbct_js_test($ct_checkjs_register_form, $_POST, true);
1283
  $sender_info['post_checkjs_passed'] = $checkjs;
@@ -1312,17 +1300,17 @@ function ct_test_registration($nickname, $email, $ip){
1312
  * @return array with errors
1313
  */
1314
  function ct_registration_errors($errors, $sanitized_user_login = null, $user_email = null) {
1315
- global $ct_checkjs_register_form, $apbct_cookie_request_id_label, $apbct_cookie_register_ok_label, $bp, $ct_signup_done, $ct_negative_comment, $ct_options, $ct_data, $ct_registration_error_comment;
1316
 
1317
- $ct_options=ct_get_options();
1318
- $ct_data=ct_get_data();
1319
 
1320
  // Go out if a registrered user action
1321
  if (ct_is_user_enable() === false) {
1322
  return $errors;
1323
  }
1324
 
1325
- if ($ct_options['registrations_test'] == 0) {
1326
  return $errors;
1327
  }
1328
 
@@ -1463,12 +1451,12 @@ function ct_user_register($user_id) {
1463
  * Test for JetPack contact form
1464
  */
1465
  function ct_grunion_contact_form_field_html($r, $field_label) {
1466
- global $ct_checkjs_jpcf, $ct_jpcf_patched, $ct_jpcf_fields, $ct_options, $ct_data;
 
 
1467
 
1468
- $ct_options = ct_get_options();
1469
- $ct_data = ct_get_data();
1470
 
1471
- if ($ct_options['contact_forms_test'] == 1 && $ct_jpcf_patched === false && preg_match("/[text|email]/i", $r)) {
1472
 
1473
  // Looking for element name prefix
1474
  $name_patched = false;
@@ -1489,12 +1477,12 @@ function ct_grunion_contact_form_field_html($r, $field_label) {
1489
  * Test for JetPack contact form
1490
  */
1491
  function ct_contact_form_is_spam($form) {
1492
- global $ct_checkjs_jpcf, $ct_options, $ct_data;
 
 
1493
 
1494
- $ct_options = ct_get_options();
1495
- $ct_data = ct_get_data();
1496
 
1497
- if ($ct_options['contact_forms_test'] == 0) {
1498
  return null;
1499
  }
1500
 
@@ -1539,12 +1527,12 @@ function ct_contact_form_is_spam($form) {
1539
  }
1540
 
1541
  function ct_contact_form_is_spam_jetpack($is_spam,$form) {
1542
- global $ct_checkjs_jpcf, $ct_options, $ct_data;
 
 
1543
 
1544
- $ct_options = ct_get_options();
1545
- $ct_data = ct_get_data();
1546
 
1547
- if ($ct_options['contact_forms_test'] == 0) {
1548
  return null;
1549
  }
1550
 
@@ -1593,11 +1581,11 @@ function ct_contact_form_is_spam_jetpack($is_spam,$form) {
1593
  * Inserts anti-spam hidden to CF7
1594
  */
1595
  function apbct_form__contactForm7__addField($html) {
1596
- global $ct_checkjs_cf7, $ct_options;
 
1597
 
1598
- $ct_options = ct_get_options();
1599
 
1600
- if ($ct_options['contact_forms_test'] == 0) {
1601
  return $html;
1602
  }
1603
 
@@ -1610,15 +1598,15 @@ function apbct_form__contactForm7__addField($html) {
1610
  * Test CF7 message for spam
1611
  */
1612
  function apbct_form__contactForm7__testSpam($param) {
1613
- global $ct_checkjs_cf7, $ct_cf7_comment, $ct_options;
 
1614
 
1615
- $ct_options = ct_get_options();
1616
 
1617
  if(
1618
- $ct_options['contact_forms_test'] == 0 ||
1619
  $param == false && WPCF7_VERSION < '3.0.0' ||
1620
  $param === true && WPCF7_VERSION >= '3.0.0' ||
1621
- $ct_options['protect_logged_in'] != 1 && is_user_logged_in() // Skip processing for logged in users.
1622
  ){
1623
  return $param;
1624
  }
@@ -1689,15 +1677,12 @@ function ct_si_contact_display_after_fields($string = '', $style = '', $form_err
1689
  * Test for Fast Secure contact form
1690
  */
1691
  function ct_si_contact_form_validate($form_errors = array(), $form_id_num = 0) {
1692
- global $ct_options, $ct_data, $cleantalk_executed;
1693
 
1694
- $ct_options = ct_get_options();
1695
- $ct_data = ct_get_data();
1696
-
1697
  if (!empty($form_errors))
1698
  return $form_errors;
1699
 
1700
- if ($ct_options['contact_forms_test'] == 0)
1701
  return $form_errors;
1702
 
1703
  // Skip processing because data already processed.
@@ -1765,14 +1750,11 @@ function ct_comment_text($comment_text) {
1765
  */
1766
  function ct_check_wplp(){
1767
 
1768
- global $ct_wplp_result_label, $ct_options, $ct_data;
1769
-
1770
- $ct_options = ct_get_options();
1771
- $ct_data = ct_get_data();
1772
 
1773
  if (!isset($_COOKIE[$ct_wplp_result_label])) {
1774
  // First AJAX submit of WPLP form
1775
- if ($ct_options['contact_forms_test'] == 0)
1776
  return;
1777
 
1778
  $post_info['comment_type'] = 'feedback';
@@ -1853,13 +1835,13 @@ function apbct_form__gravityForms__addField($form_string, $form){
1853
  */
1854
  function apbct_form__gravityForms__testSpam($is_spam, $form, $entry) {
1855
 
1856
- global $ct_options, $ct_data, $cleantalk_executed, $ct_gform_is_spam, $ct_gform_response;
 
 
1857
 
1858
- $ct_options = ct_get_options();
1859
- $ct_data = ct_get_data();
1860
 
1861
  if (
1862
- $ct_options['contact_forms_test'] == 0 ||
1863
  $is_spam ||
1864
  $cleantalk_executed // Return unchanged result if the submission was already tested.
1865
  )
@@ -1917,7 +1899,7 @@ function apbct_form__gravityForms__showResponse( $confirmation, $form, $entry, $
1917
  global $ct_gform_is_spam, $ct_gform_response;
1918
 
1919
  if(!empty($ct_gform_is_spam)){
1920
- $confirmation = "<div id='gform_confirmation_wrapper_2' class='gform_confirmation_wrapper '><div id='gform_confirmation_message_2' class='gform_confirmation_message_2 gform_confirmation_message'><font style='color: red'>$ct_gform_response</font></div></div>";
1921
  }
1922
 
1923
  return $confirmation;
@@ -1927,27 +1909,18 @@ function apbct_form__gravityForms__showResponse( $confirmation, $form, $entry, $
1927
  * Test S2member registration
1928
  * @return array with errors
1929
  */
1930
- function ct_s2member_registration_test() {
1931
- global $ct_post_data_label, $ct_post_data_authnet_label, $ct_options;
 
1932
 
1933
- $ct_options = ct_get_options();
1934
 
1935
- if ($ct_options['registrations_test'] == 0) {
1936
  return null;
1937
  }
1938
-
1939
- $sender_email = null;
1940
- if (isset($_POST[$ct_post_data_label]['email']))
1941
- $sender_email = $_POST[$ct_post_data_label]['email'];
1942
- if (isset($_POST[$ct_post_data_authnet_label]['email']))
1943
- $sender_email = $_POST[$ct_post_data_authnet_label]['email'];
1944
-
1945
- $sender_nickname = null;
1946
- if (isset($_POST[$ct_post_data_label]['username']))
1947
- $sender_nickname = $_POST[$ct_post_data_label]['username'];
1948
- if (isset($_POST[$ct_post_data_authnet_label]['username']))
1949
- $sender_nickname = $_POST[$ct_post_data_authnet_label]['username'];
1950
-
1951
  //Making a call
1952
  $base_call_result = apbct_base_call(
1953
  array(
@@ -1971,10 +1944,8 @@ function ct_s2member_registration_test() {
1971
  * General test for any contact form
1972
  */
1973
  function ct_contact_form_validate() {
1974
- global $pagenow,$cleantalk_executed, $cleantalk_url_exclusions,$ct_options, $ct_data, $ct_checkjs_frm;
1975
-
1976
- $ct_options = ct_get_options();
1977
- $ct_data = ct_get_data();
1978
 
1979
  if($cleantalk_executed)
1980
  return null;
@@ -1997,13 +1968,13 @@ function ct_contact_form_validate() {
1997
  ct_check_array_keys($_POST) ||
1998
  isset($_POST['ct_checkjs_register_form']) ||
1999
  (isset($_POST['signup_username']) && isset($_POST['signup_password_confirm']) && isset($_POST['signup_submit']) ) ||
2000
- @intval($ct_options['general_contact_forms_test'])==0 ||
2001
  isset($_POST['bbp_topic_content']) ||
2002
  isset($_POST['bbp_reply_content']) ||
2003
  isset($_POST['fscf_submitted']) ||
2004
  strpos($_SERVER['REQUEST_URI'],'/wc-api/')!==false ||
2005
  isset($_POST['log']) && isset($_POST['pwd']) && isset($_POST['wp-submit']) ||
2006
- isset($_POST[$ct_checkjs_frm]) && (@intval($ct_options['contact_forms_test']) == 1) ||// Formidable forms
2007
  isset($_POST['comment_post_ID']) || // The comment form
2008
  isset($_GET['for']) ||
2009
  (isset($_POST['log'], $_POST['pwd'])) || //WooCommerce Sensei login form fix
@@ -2022,7 +1993,7 @@ function ct_contact_form_validate() {
2022
  }
2023
 
2024
  // Do not execute anti-spam test for logged in users.
2025
- if (isset($_COOKIE[LOGGED_IN_COOKIE]) && $ct_options['protect_logged_in'] != 1)
2026
  return null;
2027
 
2028
  $post_info['comment_type'] = 'feedback_general_contact_form';
@@ -2034,7 +2005,7 @@ function ct_contact_form_validate() {
2034
  !empty($_POST['woocommerce_checkout_place_order'])
2035
  ){
2036
  $post_info['comment_type'] = 'order';
2037
- if($ct_options['wc_checkout_test'] == 0){
2038
  return null;
2039
  }
2040
  }
@@ -2170,11 +2141,9 @@ function ct_contact_form_validate() {
2170
  * General test for any post data
2171
  */
2172
  function ct_contact_form_validate_postdata() {
2173
- global $pagenow,$cleantalk_executed, $cleantalk_url_exclusions, $ct_options, $ct_data;
2174
-
2175
- $ct_options = ct_get_options();
2176
- $ct_data = ct_get_data();
2177
-
2178
  if($cleantalk_executed)
2179
  return null;
2180
 
@@ -2198,7 +2167,7 @@ function ct_contact_form_validate_postdata() {
2198
  ct_check_array_keys($_POST) ||
2199
  isset($_POST['ct_checkjs_register_form']) ||
2200
  (isset($_POST['signup_username']) && isset($_POST['signup_password_confirm']) && isset($_POST['signup_submit']) ) ||
2201
- @intval($ct_options['general_contact_forms_test'])==0 ||
2202
  isset($_POST['bbp_topic_content']) ||
2203
  isset($_POST['bbp_reply_content']) ||
2204
  isset($_POST['fscf_submitted']) ||
@@ -2282,7 +2251,7 @@ function ct_get_data_from_submit($value = null, $field_name = null) {
2282
  * @return null
2283
  */
2284
  function ct_send_error_notice ($comment = '') {
2285
- global $ct_plugin_name, $ct_admin_notoice_period;
2286
 
2287
  $timelabel_reg = intval( get_option('cleantalk_timelabel_reg') );
2288
  if(time() - $ct_admin_notoice_period > $timelabel_reg){
@@ -2290,9 +2259,9 @@ function ct_send_error_notice ($comment = '') {
2290
 
2291
  $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
2292
  $message = __('Attention, please!', 'cleantalk') . "\r\n\r\n";
2293
- $message .= sprintf(__('"%s" plugin error on your site %s:', 'cleantalk'), $ct_plugin_name, $blogname) . "\r\n\r\n";
2294
  $message .= $comment . "\r\n\r\n";
2295
- @wp_mail(ct_get_admin_email(), sprintf(__('[%s] %s error!', 'cleantalk'), $ct_plugin_name, $blogname), $message);
2296
  }
2297
 
2298
  return null;
@@ -2332,12 +2301,12 @@ function ct_print_form($arr,$k)
2332
  */
2333
  function ct_enqueue_scripts_public($hook){
2334
 
2335
- global $current_user, $ct_data, $ct_options;
2336
 
2337
- $ct_options = ct_get_options();
2338
- $ct_data = ct_get_data();
2339
 
2340
- if(!empty($ct_options['registrations_test']) || !empty($ct_options['comments_test']) || !empty($ct_options['contact_forms_test']) || !empty($ct_options['general_contact_forms_test']) || !empty($ct_options['wc_checkout_test']) || !empty($ct_options['check_external']) || !empty($ct_options['check_internal']) || !empty($ct_options['bp_private_messages']) || !empty($ct_options['general_postdata_test'])){
 
 
2341
 
2342
  // Differnt JS params
2343
  wp_enqueue_script('ct_public', APBCT_URL_PATH.'/js/apbct-public.js', array(), APBCT_VERSION, 'in_footer');
@@ -2348,35 +2317,35 @@ function ct_enqueue_scripts_public($hook){
2348
  wp_enqueue_script('ct_public_gdpr', APBCT_URL_PATH.'/js/apbct-public--gdpr.js', array('jquery'), APBCT_VERSION);
2349
 
2350
  wp_localize_script('ct_public_gdpr', 'ctPublic', array(
2351
- 'gdpr_forms' => isset($ct_options['gdpr_forms_id']) ? explode(', ', $ct_options['gdpr_forms_id']) : array(),
2352
- 'gdpr_text' => isset($ct_options['gdpr_text']) ? $ct_options['gdpr_text'] : __('By using this form you agree with the storage and processing of your data by using the Privacy Policy on this website.', 'cleantalk'),
2353
  ));
2354
  }
2355
 
2356
  }
2357
 
2358
  if(!defined('CLEANTALK_AJAX_USE_FOOTER_HEADER') || (defined('CLEANTALK_AJAX_USE_FOOTER_HEADER') && CLEANTALK_AJAX_USE_FOOTER_HEADER)){
2359
- if(!empty($ct_options['use_ajax']) && stripos($_SERVER['REQUEST_URI'],'.xml') === false && stripos($_SERVER['REQUEST_URI'],'.xsl') === false){
2360
  if(strpos($_SERVER['REQUEST_URI'],'jm-ajax') === false){
2361
 
2362
  // Use AJAX for JavaScript check
2363
- if(!empty($ct_options['use_ajax'])){
2364
  wp_enqueue_script('ct_nocache', plugins_url('/cleantalk-spam-protect/inc/cleantalk_nocache.js'), array(), APBCT_VERSION, 'in_footer');
2365
-
2366
- wp_localize_script('ct_nocache', 'ctNocache', array(
2367
- 'ajaxurl' => admin_url('admin-ajax.php'),
2368
- 'info_flag' => !empty($ct_options['collect_details']) && !empty($ct_options['set_cookies']) ? true : false,
2369
- 'set_cookies_flag' => empty($ct_options['set_cookies']) ? false : true,
2370
- 'blog_home' => get_home_url().'/',
2371
- ));
2372
  }
2373
 
2374
  // External forms check
2375
- if(!empty($ct_options['check_external']))
2376
  wp_enqueue_script('ct_external', plugins_url('/cleantalk-spam-protect/js/cleantalk_external.js'), array('jquery'), APBCT_VERSION, 'in_footer');
2377
 
2378
  // Internal forms check
2379
- if(!empty($ct_options['check_internal']))
2380
  wp_enqueue_script('ct_internal', plugins_url('/cleantalk-spam-protect/js/cleantalk_internal.js'), array('jquery'), APBCT_VERSION, 'in_footer');
2381
 
2382
  }
@@ -2386,10 +2355,9 @@ function ct_enqueue_scripts_public($hook){
2386
  // Show controls for commentaies
2387
  if(in_array("administrator", $current_user->roles)){
2388
 
2389
- if(!empty($ct_options['show_check_links'])){
2390
 
2391
  $ajax_nonce = wp_create_nonce( "ct_secret_nonce" );
2392
- $user_token = !empty($ct_data['user_token']) ? $ct_data['user_token'] : null;
2393
 
2394
  wp_enqueue_style ('ct_public_admin_css', plugins_url('/cleantalk-spam-protect/css/cleantalk-public-admin.css'), array(), APBCT_VERSION, 'all');
2395
  wp_enqueue_script('ct_public_admin_js', plugins_url('/cleantalk-spam-protect/js/cleantalk-public-admin.js'), array('jquery'), APBCT_VERSION, true);
@@ -2399,14 +2367,14 @@ function ct_enqueue_scripts_public($hook){
2399
  'ajaxurl' => admin_url('admin-ajax.php'),
2400
  'ct_feedback_error' => __('Error occured while sending feedback.', 'cleantalk'),
2401
  'ct_feedback_no_hash' => __('Feedback wasn\'t sent. There is no associated request.', 'cleantalk'),
2402
- 'ct_feedback_msg' => sprintf(__("Feedback has been sent to %sCleanTalk Dashboard%s.", 'cleantalk'), $user_token ? "<a target='_blank' href=https://cleantalk.org/my/show_requests?user_token={$user_token}&cp_mode=antispam>" : '', $user_token ? "</a>" : ''),
2403
  ));
2404
 
2405
  }
2406
  }
2407
 
2408
  // Debug
2409
- if(!empty($ct_options['debug_ajax'])){
2410
  wp_enqueue_script('ct_debug_js', plugins_url('/cleantalk-spam-protect/js/cleantalk-debug-ajax.js'), array('jquery'), APBCT_VERSION, true);
2411
 
2412
  wp_localize_script('ct_debug_js', 'apbctDebug', array(
@@ -2418,12 +2386,12 @@ function ct_enqueue_scripts_public($hook){
2418
 
2419
  function apbct_add_async_attribute($tag, $handle, $src) {
2420
 
2421
- global $ct_options;
 
2422
 
2423
- $ct_options = ct_get_options();
2424
 
2425
  if(
2426
- !empty($ct_options['async_js']) &&
2427
  (
2428
  $handle === 'ct_public'
2429
  || $handle === 'ct_public_gdpr'
@@ -2444,10 +2412,10 @@ function apbct_add_async_attribute($tag, $handle, $src) {
2444
  */
2445
  function ct_wp_list_comments_args($options){
2446
 
2447
- global $current_user, $ct_options;
2448
 
2449
  if(in_array("administrator", $current_user->roles))
2450
- if(!empty($ct_options['show_check_links']))
2451
  $options['end-callback'] = 'ct_comments_output';
2452
 
2453
  return $options;
5
  * @return mixed[] Array of options
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']
16
  ){
17
  $ct_result = ct_contact_form_validate();
18
  if($ct_result == null){
35
  add_shortcode( 'et_pb_contact_form', 'ct_contact_form_validate' );
36
  }
37
 
38
+ if($apbct->settings['check_external']
39
  && isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST'
40
  && isset($_POST['cleantalk_hidden_method'])
41
  && isset($_POST['cleantalk_hidden_action'])
61
  }
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']))
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');
89
 
184
  }
185
 
186
  // intercept S2member POST
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
+ }
194
+ }
195
+ }
196
 
197
  //
198
  // New user approve hack
226
  add_action('wp_footer', 'ct_footer_add_cookie', 1);
227
  }
228
 
229
+ if ($apbct->settings['protect_logged_in'] != 1 && is_user_logged_in()) {
230
  $ct_check_post_result=false;
231
  ct_contact_form_validate();
232
  }
233
 
234
  if (ct_is_user_enable()) {
235
 
236
+ if ($apbct->settings['general_contact_forms_test'] == 1 && !isset($_POST['comment_post_ID']) && !isset($_GET['for'])){
237
  $ct_check_post_result=false;
238
  ct_contact_form_validate();
239
  }
240
+ if(isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST' && $apbct->settings['general_postdata_test'] == 1 && !@isset($_POST['ct_checkjs_cf7']) && !is_admin() && !@isset($_POST['ct_checkjs_cf7'])){
241
  $ct_check_post_result=false;
242
  ct_contact_form_validate_postdata();
243
  }
278
  */
279
  $ct_global_temporary_data = array();
280
  function ct_validate_ccf_submission($value, $field_id, $required){
281
+ global $ct_global_temporary_data, $apbct;
282
+
283
 
 
284
 
285
  //If the check for contact forms enabled
286
+ if(!$apbct->settings['contact_forms_test'])
287
  return true;
288
  //If the check for logged in users enabled
289
+ if($apbct->settings['protect_logged_in'] == 1 && is_user_logged_in())
290
  return true;
291
 
292
  //Accumulate data
338
  }
339
 
340
  function ct_woocommerce_wishlist_check($args){
341
+ global $apbct;
342
+
343
 
 
344
 
345
  //Protect logged in users
346
  if($args['wishlist_status'])
347
+ if($apbct->settings['protect_logged_in'] == 0)
348
  return $args;
349
 
350
  //If the IP is a Google bot
394
  */
395
 
396
  function ct_bp_private_msg_check( $bp_message_obj){
397
+ global $apbct;
398
+
399
 
 
400
 
401
  //Check for enabled option
402
+ if($apbct->settings['bp_private_messages'] == 0)
403
  return;
404
 
405
  //Check for quantity of comments
408
  $comments_check_number = CLEANTALK_CHECK_COMMENTS_NUMBER;
409
  else
410
  $comments_check_number = 3;
411
+
412
+ if($apbct->settings['check_comments_number']){
 
 
 
 
 
413
  $args = array(
414
  'user_id' => $bp_message_obj->sender_id,
415
  'box' => 'sentbox',
470
  * return NULL
471
  */
472
  function ct_pirate_forms_check(){
 
473
 
474
+ global $apbct;
475
 
476
  //Check for enabled option
477
+ if( !$apbct->settings['contact_forms_test'])
478
  return;
479
 
480
  //Getting request params
522
  /**
523
  * Adds hidden filed to comment form
524
  */
525
+ function ct_comment_form($post_id){
526
+
527
+ global $apbct;
 
528
 
529
  if (ct_is_user_enable() === false) {
530
  return false;
531
  }
532
 
533
+ if ( !$apbct->settings['comments_test']) {
534
  return false;
535
  }
536
 
555
  */
556
  function ct_add_hidden_fields($random_key = false, $field_name = 'ct_checkjs', $return_string = false, $cookie_check = false, $no_print = false) {
557
 
558
+ global $ct_checkjs_def, $apbct;
559
 
560
+
561
 
562
  $ct_checkjs_key = ct_get_checkjs_value($random_key);
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=/';
625
  * return null;
626
  */
627
  function ct_frm_entries_footer_scripts($fields, $form) {
628
+ global $apbct, $ct_checkjs_frm;
629
 
630
+ if ( !$apbct->settings['contact_forms_test'])
631
  return false;
632
 
633
  $ct_checkjs_key = ct_get_checkjs_value();
656
  * return @array with errors if spam has found
657
  */
658
  function ct_frm_validate_entry ($errors, $values) {
659
+ global $wpdb, $current_user, $ct_checkjs_frm, $apbct;
660
 
 
 
661
 
662
+
663
+
664
+ if ( !$apbct->settings['contact_forms_test']) {
665
  return $errors;
666
  }
667
 
668
  // Skip processing for logged in users.
669
+ if ( !$apbct->settings['protect_logged_in'] && is_user_logged_in()) {
670
  return $errors;
671
  }
672
 
726
  * @return mixed[] $comment Comment string
727
  */
728
  function ct_bbp_new_pre_content ($comment) {
729
+ global $apbct, $current_user, $ct_bbp_topic;
730
+
731
+
732
 
 
 
733
 
734
+ if ( !$apbct->settings['comments_test']) {
735
  return $comment;
736
  }
737
 
738
  // Skip processing for logged in users and admin.
739
+ if ( !$apbct->settings['protect_logged_in'] && is_user_logged_in() ||
740
  in_array("administrator", $current_user->roles))
741
  return $comment;
742
 
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))
790
  return $comment;
791
 
792
  $comments_check_number = defined('CLEANTALK_CHECK_COMMENTS_NUMBER') ? CLEANTALK_CHECK_COMMENTS_NUMBER : 3;
 
793
 
794
+ if($apbct->settings['check_comments_number']){
795
  $args = array(
796
  'author_email' => $comment['comment_author_email'],
797
  'status' => 'approve',
806
  ($comment['comment_type']!='trackback') &&
807
  (
808
  ct_is_user_enable() === false ||
809
+ $apbct->settings['comments_test'] == 0 ||
810
  $ct_comment_done ||
811
  (isset($_SERVER['HTTP_REFERER']) && stripos($_SERVER['HTTP_REFERER'],'page=wysija_campaigns&action=editTemplate')!==false) ||
812
  (isset($is_max_comments) && $is_max_comments) ||
852
 
853
 
854
  $example = null;
855
+ if ($apbct->settings['relevance_test']) {
856
  $post = get_post($comment_post_id);
857
  if ($post !== null){
858
  $example['title'] = $post->post_title;
934
  add_action('comment_post', 'ct_die', 999, 2);
935
  }
936
 
937
+ if($apbct->settings['remove_comments_links'] == 1){
938
  $comment = preg_replace("~(http|https|ftp|ftps)://(.*?)(\s|\n|[,.?!](\s|\n)|$)~", '[Link deleted]', $comment);
939
  }
940
 
977
  *
978
  */
979
  function apbct_js_test($field_name = 'ct_checkjs', $data = null, $random_key = false) {
980
+ global $apbct;
981
+
982
+
983
 
 
 
984
 
985
  $checkjs = null;
986
  $js_post_value = null;
996
  //
997
  if ($random_key) {
998
 
999
+ $keys = $apbct->js_keys;
1000
  if (isset($keys[$js_post_value])) {
1001
  $checkjs = 1;
1002
  } else {
1138
  * @return null
1139
  */
1140
  function ct_register_form() {
1141
+ global $ct_checkjs_register_form, $apbct;
1142
+
1143
+
1144
 
 
 
1145
 
1146
+ if ($apbct->settings['registrations_test'] == 0) {
1147
  return false;
1148
  }
1149
 
1158
  */
1159
  function ct_login_message($message) {
1160
 
1161
+ global $errors, $apbct, $apbct_cookie_register_ok_label;
1162
 
1163
+
1164
 
1165
+ if ($apbct->settings['registrations_test'] != 0){
1166
  if( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ){
1167
  if (isset($_COOKIE[$apbct_cookie_register_ok_label])){
1168
  if(is_wp_error($errors)){
1263
  * @return array with checking result;
1264
  */
1265
  function ct_test_registration($nickname, $email, $ip){
1266
+ global $ct_checkjs_register_form, $apbct;
1267
+
1268
 
 
1269
 
1270
  $checkjs = apbct_js_test($ct_checkjs_register_form, $_POST, true);
1271
  $sender_info['post_checkjs_passed'] = $checkjs;
1300
  * @return array with errors
1301
  */
1302
  function ct_registration_errors($errors, $sanitized_user_login = null, $user_email = null) {
1303
+ global $ct_checkjs_register_form, $apbct_cookie_request_id_label, $apbct_cookie_register_ok_label, $bp, $ct_signup_done, $ct_negative_comment, $apbct, $ct_registration_error_comment;
1304
 
1305
+
1306
+
1307
 
1308
  // Go out if a registrered user action
1309
  if (ct_is_user_enable() === false) {
1310
  return $errors;
1311
  }
1312
 
1313
+ if ($apbct->settings['registrations_test'] == 0) {
1314
  return $errors;
1315
  }
1316
 
1451
  * Test for JetPack contact form
1452
  */
1453
  function ct_grunion_contact_form_field_html($r, $field_label) {
1454
+ global $ct_checkjs_jpcf, $ct_jpcf_patched, $ct_jpcf_fields, $apbct;
1455
+
1456
+
1457
 
 
 
1458
 
1459
+ if ($apbct->settings['contact_forms_test'] == 1 && $ct_jpcf_patched === false && preg_match("/[text|email]/i", $r)) {
1460
 
1461
  // Looking for element name prefix
1462
  $name_patched = false;
1477
  * Test for JetPack contact form
1478
  */
1479
  function ct_contact_form_is_spam($form) {
1480
+ global $ct_checkjs_jpcf, $apbct;
1481
+
1482
+
1483
 
 
 
1484
 
1485
+ if ($apbct->settings['contact_forms_test'] == 0) {
1486
  return null;
1487
  }
1488
 
1527
  }
1528
 
1529
  function ct_contact_form_is_spam_jetpack($is_spam,$form) {
1530
+ global $ct_checkjs_jpcf, $apbct;
1531
+
1532
+
1533
 
 
 
1534
 
1535
+ if ($apbct->settings['contact_forms_test'] == 0) {
1536
  return null;
1537
  }
1538
 
1581
  * Inserts anti-spam hidden to CF7
1582
  */
1583
  function apbct_form__contactForm7__addField($html) {
1584
+ global $ct_checkjs_cf7, $apbct;
1585
+
1586
 
 
1587
 
1588
+ if ($apbct->settings['contact_forms_test'] == 0) {
1589
  return $html;
1590
  }
1591
 
1598
  * Test CF7 message for spam
1599
  */
1600
  function apbct_form__contactForm7__testSpam($param) {
1601
+ global $ct_checkjs_cf7, $ct_cf7_comment, $apbct;
1602
+
1603
 
 
1604
 
1605
  if(
1606
+ $apbct->settings['contact_forms_test'] == 0 ||
1607
  $param == false && WPCF7_VERSION < '3.0.0' ||
1608
  $param === true && WPCF7_VERSION >= '3.0.0' ||
1609
+ $apbct->settings['protect_logged_in'] != 1 && is_user_logged_in() // Skip processing for logged in users.
1610
  ){
1611
  return $param;
1612
  }
1677
  * Test for Fast Secure contact form
1678
  */
1679
  function ct_si_contact_form_validate($form_errors = array(), $form_id_num = 0) {
1680
+ global $apbct, $cleantalk_executed;
1681
 
 
 
 
1682
  if (!empty($form_errors))
1683
  return $form_errors;
1684
 
1685
+ if ($apbct->settings['contact_forms_test'] == 0)
1686
  return $form_errors;
1687
 
1688
  // Skip processing because data already processed.
1750
  */
1751
  function ct_check_wplp(){
1752
 
1753
+ global $ct_wplp_result_label, $apbct;
 
 
 
1754
 
1755
  if (!isset($_COOKIE[$ct_wplp_result_label])) {
1756
  // First AJAX submit of WPLP form
1757
+ if ($apbct->settings['contact_forms_test'] == 0)
1758
  return;
1759
 
1760
  $post_info['comment_type'] = 'feedback';
1835
  */
1836
  function apbct_form__gravityForms__testSpam($is_spam, $form, $entry) {
1837
 
1838
+ global $apbct, $cleantalk_executed, $ct_gform_is_spam, $ct_gform_response;
1839
+
1840
+
1841
 
 
 
1842
 
1843
  if (
1844
+ $apbct->settings['contact_forms_test'] == 0 ||
1845
  $is_spam ||
1846
  $cleantalk_executed // Return unchanged result if the submission was already tested.
1847
  )
1899
  global $ct_gform_is_spam, $ct_gform_response;
1900
 
1901
  if(!empty($ct_gform_is_spam)){
1902
+ $confirmation = '<a id="gf_'.$form['id'].'" class="gform_anchor" ></a><div id="gform_confirmation_wrapper_'.$form['id'].'" class="gform_confirmation_wrapper "><div id="gform_confirmation_message_'.$form['id'].'" class="gform_confirmation_message_'.$form['id'].' gform_confirmation_message"><font style="color: red">'.$ct_gform_response.'</font></div></div>';
1903
  }
1904
 
1905
  return $confirmation;
1909
  * Test S2member registration
1910
  * @return array with errors
1911
  */
1912
+ function ct_s2member_registration_test($post_key) {
1913
+ global $ct_post_data_label, $ct_post_data_authnet_label, $apbct;
1914
+
1915
 
 
1916
 
1917
+ if ($apbct->settings['registrations_test'] == 0) {
1918
  return null;
1919
  }
1920
+
1921
+ $sender_email = isset($_POST[$post_key]['email']) ? $_POST[$post_key]['email'] : null;
1922
+ $sender_nickname = isset($_POST[$post_key]['username']) ? $_POST[$post_key]['username'] : null;
1923
+
 
 
 
 
 
 
 
 
 
1924
  //Making a call
1925
  $base_call_result = apbct_base_call(
1926
  array(
1944
  * General test for any contact form
1945
  */
1946
  function ct_contact_form_validate() {
1947
+
1948
+ global $pagenow,$cleantalk_executed, $cleantalk_url_exclusions,$apbct, $ct_checkjs_frm;
 
 
1949
 
1950
  if($cleantalk_executed)
1951
  return null;
1968
  ct_check_array_keys($_POST) ||
1969
  isset($_POST['ct_checkjs_register_form']) ||
1970
  (isset($_POST['signup_username']) && isset($_POST['signup_password_confirm']) && isset($_POST['signup_submit']) ) ||
1971
+ $apbct->settings['general_contact_forms_test'] == 0 ||
1972
  isset($_POST['bbp_topic_content']) ||
1973
  isset($_POST['bbp_reply_content']) ||
1974
  isset($_POST['fscf_submitted']) ||
1975
  strpos($_SERVER['REQUEST_URI'],'/wc-api/')!==false ||
1976
  isset($_POST['log']) && isset($_POST['pwd']) && isset($_POST['wp-submit']) ||
1977
+ isset($_POST[$ct_checkjs_frm]) && $apbct->settings['contact_forms_test'] == 1 ||// Formidable forms
1978
  isset($_POST['comment_post_ID']) || // The comment form
1979
  isset($_GET['for']) ||
1980
  (isset($_POST['log'], $_POST['pwd'])) || //WooCommerce Sensei login form fix
1993
  }
1994
 
1995
  // Do not execute anti-spam test for logged in users.
1996
+ if (isset($_COOKIE[LOGGED_IN_COOKIE]) && $apbct->settings['protect_logged_in'] != 1)
1997
  return null;
1998
 
1999
  $post_info['comment_type'] = 'feedback_general_contact_form';
2005
  !empty($_POST['woocommerce_checkout_place_order'])
2006
  ){
2007
  $post_info['comment_type'] = 'order';
2008
+ if($apbct->settings['wc_checkout_test'] == 0){
2009
  return null;
2010
  }
2011
  }
2141
  * General test for any post data
2142
  */
2143
  function ct_contact_form_validate_postdata() {
2144
+
2145
+ global $pagenow,$cleantalk_executed, $cleantalk_url_exclusions, $apbct;
2146
+
 
 
2147
  if($cleantalk_executed)
2148
  return null;
2149
 
2167
  ct_check_array_keys($_POST) ||
2168
  isset($_POST['ct_checkjs_register_form']) ||
2169
  (isset($_POST['signup_username']) && isset($_POST['signup_password_confirm']) && isset($_POST['signup_submit']) ) ||
2170
+ $apbct->settings['general_contact_forms_test']==0 ||
2171
  isset($_POST['bbp_topic_content']) ||
2172
  isset($_POST['bbp_reply_content']) ||
2173
  isset($_POST['fscf_submitted']) ||
2251
  * @return null
2252
  */
2253
  function ct_send_error_notice ($comment = '') {
2254
+ global $ct_admin_notoice_period;
2255
 
2256
  $timelabel_reg = intval( get_option('cleantalk_timelabel_reg') );
2257
  if(time() - $ct_admin_notoice_period > $timelabel_reg){
2259
 
2260
  $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
2261
  $message = __('Attention, please!', 'cleantalk') . "\r\n\r\n";
2262
+ $message .= sprintf(__('"%s" plugin error on your site %s:', 'cleantalk'), APBCT_NAME, $blogname) . "\r\n\r\n";
2263
  $message .= $comment . "\r\n\r\n";
2264
+ @wp_mail(ct_get_admin_email(), sprintf(__('[%s] %s error!', 'cleantalk'), APBCT_NAME, $blogname), $message);
2265
  }
2266
 
2267
  return null;
2301
  */
2302
  function ct_enqueue_scripts_public($hook){
2303
 
2304
+ global $current_user, $apbct;
2305
 
 
 
2306
 
2307
+
2308
+
2309
+ 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']){
2310
 
2311
  // Differnt JS params
2312
  wp_enqueue_script('ct_public', APBCT_URL_PATH.'/js/apbct-public.js', array(), APBCT_VERSION, 'in_footer');
2317
  wp_enqueue_script('ct_public_gdpr', APBCT_URL_PATH.'/js/apbct-public--gdpr.js', array('jquery'), APBCT_VERSION);
2318
 
2319
  wp_localize_script('ct_public_gdpr', 'ctPublic', array(
2320
+ 'gdpr_forms' => $apbct->settings['gdpr_forms_id'] ? explode(', ', $apbct->settings['gdpr_forms_id']) : array(),
2321
+ 'gdpr_text' => $apbct->settings['gdpr_text'] ? $apbct->settings['gdpr_text'] : __('By using this form you agree with the storage and processing of your data by using the Privacy Policy on this website.', 'cleantalk'),
2322
  ));
2323
  }
2324
 
2325
  }
2326
 
2327
  if(!defined('CLEANTALK_AJAX_USE_FOOTER_HEADER') || (defined('CLEANTALK_AJAX_USE_FOOTER_HEADER') && CLEANTALK_AJAX_USE_FOOTER_HEADER)){
2328
+ if($apbct->settings['use_ajax'] && stripos($_SERVER['REQUEST_URI'],'.xml') === false && stripos($_SERVER['REQUEST_URI'],'.xsl') === false){
2329
  if(strpos($_SERVER['REQUEST_URI'],'jm-ajax') === false){
2330
 
2331
  // Use AJAX for JavaScript check
2332
+ if($apbct->settings['use_ajax']){
2333
  wp_enqueue_script('ct_nocache', plugins_url('/cleantalk-spam-protect/inc/cleantalk_nocache.js'), array(), APBCT_VERSION, 'in_footer');
2334
+
2335
+ wp_localize_script('ct_nocache', 'ctNocache', array(
2336
+ 'ajaxurl' => admin_url('admin-ajax.php'),
2337
+ 'info_flag' => $apbct->settings['collect_details'] && $apbct->settings['set_cookies'] ? true : false,
2338
+ 'set_cookies_flag' => $apbct->settings['set_cookies'] ? false : true,
2339
+ 'blog_home' => get_home_url().'/',
2340
+ ));
2341
  }
2342
 
2343
  // External forms check
2344
+ if($apbct->settings['check_external'])
2345
  wp_enqueue_script('ct_external', plugins_url('/cleantalk-spam-protect/js/cleantalk_external.js'), array('jquery'), APBCT_VERSION, 'in_footer');
2346
 
2347
  // Internal forms check
2348
+ if($apbct->settings['check_internal'])
2349
  wp_enqueue_script('ct_internal', plugins_url('/cleantalk-spam-protect/js/cleantalk_internal.js'), array('jquery'), APBCT_VERSION, 'in_footer');
2350
 
2351
  }
2355
  // Show controls for commentaies
2356
  if(in_array("administrator", $current_user->roles)){
2357
 
2358
+ if($apbct->settings['show_check_links']){
2359
 
2360
  $ajax_nonce = wp_create_nonce( "ct_secret_nonce" );
 
2361
 
2362
  wp_enqueue_style ('ct_public_admin_css', plugins_url('/cleantalk-spam-protect/css/cleantalk-public-admin.css'), array(), APBCT_VERSION, 'all');
2363
  wp_enqueue_script('ct_public_admin_js', plugins_url('/cleantalk-spam-protect/js/cleantalk-public-admin.js'), array('jquery'), APBCT_VERSION, true);
2367
  'ajaxurl' => admin_url('admin-ajax.php'),
2368
  'ct_feedback_error' => __('Error occured while sending feedback.', 'cleantalk'),
2369
  'ct_feedback_no_hash' => __('Feedback wasn\'t sent. There is no associated request.', 'cleantalk'),
2370
+ 'ct_feedback_msg' => sprintf(__("Feedback has been sent to %sCleanTalk Dashboard%s.", 'cleantalk'), $apbct->user_token ? "<a target='_blank' href=https://cleantalk.org/my/show_requests?user_token={$apbct->user_token}&cp_mode=antispam>" : '', $apbct->user_token ? "</a>" : ''),
2371
  ));
2372
 
2373
  }
2374
  }
2375
 
2376
  // Debug
2377
+ if($apbct->settings['debug_ajax']){
2378
  wp_enqueue_script('ct_debug_js', plugins_url('/cleantalk-spam-protect/js/cleantalk-debug-ajax.js'), array('jquery'), APBCT_VERSION, true);
2379
 
2380
  wp_localize_script('ct_debug_js', 'apbctDebug', array(
2386
 
2387
  function apbct_add_async_attribute($tag, $handle, $src) {
2388
 
2389
+ global $apbct;
2390
+
2391
 
 
2392
 
2393
  if(
2394
+ $apbct->settings['async_js'] &&
2395
  (
2396
  $handle === 'ct_public'
2397
  || $handle === 'ct_public_gdpr'
2412
  */
2413
  function ct_wp_list_comments_args($options){
2414
 
2415
+ global $current_user, $apbct;
2416
 
2417
  if(in_array("administrator", $current_user->roles))
2418
+ if($apbct->settings['show_check_links'])
2419
  $options['end-callback'] = 'ct_comments_output';
2420
 
2421
  return $options;
inc/cleantalk-settings.php ADDED
@@ -0,0 +1,809 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Admin action 'admin_menu' - Add the admin options page
5
+ */
6
+ function apbct_settings__add_page() {
7
+
8
+ global $apbct;
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
+ register_setting('cleantalk_settings', 'cleantalk_settings', 'apbct_settings__validate');
17
+
18
+ add_settings_section('cleantalk_section_settings_main', '', 'apbct_section__settings_main', 'cleantalk');
19
+ add_settings_section('cleantalk_section_debug', '', 'apbct_section__debug', 'cleantalk');
20
+ add_settings_section('cleantalk_section_state', '', 'apbct_section__settings_state', 'cleantalk');
21
+ add_settings_section('cleantalk_settings_banner', '<hr>', '', 'cleantalk');
22
+
23
+ // DEBUG
24
+ add_settings_field('apbct_debug_field', '', 'apbct_settings__field__debug', 'cleantalk', 'cleantalk_section_debug');
25
+
26
+ // STATE
27
+ add_settings_field('apbct_state_field', '', 'apbct_settings__field__state', 'cleantalk', 'cleantalk_section_state');
28
+
29
+ // KEY
30
+ add_settings_field('apbct_action_butons', '', 'apbct_settings__field__action_buttons', 'cleantalk', 'cleantalk_section_settings_main');
31
+ add_settings_field('cleantalk_api_key', '', 'apbct_settings__field__api_key', 'cleantalk', 'cleantalk_section_settings_main');
32
+ if(apbct_api_key__is_correct())
33
+ add_settings_field('cleantalk_connection_reports', '', 'apbct_settings__field__connection_reports', 'cleantalk', 'cleantalk_section_settings_main');
34
+
35
+ $field_default_params = array(
36
+ 'callback' => 'apbct_settings__field__draw',
37
+ 'type' => 'radio',
38
+ 'def_class' => 'apbct_settings-field_wrapper',
39
+ 'class' => '',
40
+ 'parent' => '',
41
+ 'childrens' => '',
42
+ 'title' => 'Default title',
43
+ 'description' => 'Default description',
44
+ );
45
+
46
+ $apbct->settings_fields_in_groups = array(
47
+
48
+ // Different
49
+ 'different' => array(
50
+ 'title' => '',
51
+ 'default_params' => array(),
52
+ 'description' => '',
53
+ 'html_before' => '<hr>',
54
+ 'html_after' => '',
55
+ 'fields' => array(
56
+ 'show_link' => array(
57
+ 'type' => 'checkbox',
58
+ 'title' => __('Tell others about CleanTalk', 'cleantalk'),
59
+ 'description' => __("Checking this box places a small link under the comment form that lets others know what anti-spam tool protects your site.", 'cleantalk'),
60
+ ),
61
+ 'spam_firewall' => array(
62
+ 'type' => 'checkbox',
63
+ 'title' => __('SpamFireWall', 'cleantalk'),
64
+ 'description' => __("This option allows to filter spam bots before they access website. Also reduces CPU usage on hosting server and accelerates pages load time.", 'cleantalk'),
65
+ ),
66
+ ),
67
+ ),
68
+
69
+ // Forms protection
70
+ 'forms_protection' => array(
71
+ 'title' => __('Forms to protect', 'cleantalk'),
72
+ 'default_params' => array(),
73
+ 'description' => '',
74
+ 'html_before' => '<hr><br><span id="ct_adv_showhide">'
75
+ .'<a href="#" style="color: gray;" onclick="event.preventDefault(); apbct_show_hide_elem(\'#apbct_settings__davanced_settings\');">'
76
+ .__('Advanced settings', 'cleantalk')
77
+ .'</a>'
78
+ .'</span>'
79
+ .'<div id="apbct_settings__davanced_settings" style="display: none;">',
80
+ 'html_after' => '',
81
+ 'fields' => array(
82
+ 'registrations_test' => array(
83
+ 'title' => __('Registration Forms', 'cleantalk'),
84
+ 'description' => __('WordPress, BuddyPress, bbPress, S2Member, WooCommerce.', 'cleantalk'),
85
+ ),
86
+ 'comments_test' => array(
87
+ 'title' => __('Comments form', 'cleantalk'),
88
+ 'description' => __('WordPress, JetPack, WooCommerce.', 'cleantalk'),
89
+ ),
90
+ 'contact_forms_test' => array(
91
+ 'title' => __('Contact forms', 'cleantalk'),
92
+ 'description' => __('Contact Form 7, Formidable forms, JetPack, Fast Secure Contact Form, WordPress Landing Pages, Gravity Forms.', 'cleantalk'),
93
+ ),
94
+ 'general_contact_forms_test' => array(
95
+ 'title' => __('Custom contact forms', 'cleantalk'),
96
+ 'description' => __('Anti spam test for any WordPress themes or contacts forms.', 'cleantalk'),
97
+ ),
98
+ 'wc_checkout_test' => array(
99
+ 'title' => __('WooCommerce checkout form', 'cleantalk'),
100
+ 'description' => __('Anti spam test for WooCommerce checkout form.', 'cleantalk'),
101
+ ),
102
+ 'check_external' => array(
103
+ 'title' => __('Protect external forms', 'cleantalk'),
104
+ 'description' => __('Turn this option on to protect forms on your WordPress that send data to third-part servers (like MailChimp).', 'cleantalk'),
105
+ ),
106
+ 'check_internal' => array(
107
+ 'title' => __('Protect internal forms', 'cleantalk'),
108
+ 'description' => __('This option will enable protection for custom (hand-made) AJAX forms with PHP scripts handlers on your WordPress.', 'cleantalk'),
109
+ ),
110
+ ),
111
+ ),
112
+
113
+ // Comments and Messages
114
+ 'comments_and_messages' => array(
115
+ 'title' => __('Comments and Messages', 'cleantalk'),
116
+ 'fields' => array(
117
+ 'bp_private_messages' => array(
118
+ 'title' => __('BuddyPress Private Messages', 'cleantalk'),
119
+ 'description' => __('Check buddyPress private messages.', 'cleantalk'),
120
+ ),
121
+ 'check_comments_number' => array(
122
+ 'title' => __("Don't check trusted user's comments", 'cleantalk'),
123
+ 'description' => sprintf(__("Dont't check comments for users with above % comments.", 'cleantalk'), defined('CLEANTALK_CHECK_COMMENTS_NUMBER') ? CLEANTALK_CHECK_COMMENTS_NUMBER : 3),
124
+ ),
125
+ 'remove_old_spam' => array(
126
+ 'title' => __('Automatically delete spam comments', 'cleantalk'),
127
+ 'description' => sprintf(__('Delete spam comments older than %d days.', 'cleantalk'), $apbct->settings['spam_store_days']),
128
+ ),
129
+ 'remove_comments_links' => array(
130
+ 'title' => __('Remove links from approved comments', 'cleantalk'),
131
+ 'description' => __('Remove links from approved comments. Replace it with "[Link deleted]"', 'cleantalk'),
132
+ ),
133
+ 'show_check_links' => array(
134
+ 'title' => __('Show links to check Emails, IPs for spam.', 'cleantalk'),
135
+ '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'),
136
+ ),
137
+ ),
138
+ ),
139
+
140
+ // Data Processing
141
+ 'data_processing' => array(
142
+ 'title' => __('Data Processing', 'cleantalk'),
143
+ 'fields' => array(
144
+ 'protect_logged_in' => array(
145
+ 'title' => __("Protect logged in Users", 'cleantalk'),
146
+ 'description' => __('Turn this option on to check for spam any submissions (comments, contact forms and etc.) from registered Users.', 'cleantalk'),
147
+ ),
148
+ 'use_ajax' => array(
149
+ 'title' => __('Use AJAX for JavaScript check', 'cleantalk'),
150
+ 'description' => __('Options helps protect WordPress against spam with any caching plugins. Turn this option on to avoid issues with caching plugins.', 'cleantalk')."<strong> ".__('Attention! Incompatible with AMP plugins!', 'cleantalk')."</strong>",
151
+ ),
152
+ 'general_postdata_test' => array(
153
+ 'title' => __('Check all post data', 'cleantalk'),
154
+ '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'),
155
+ ),
156
+ 'set_cookies' => array(
157
+ 'title' => __("Set cookies", 'cleantalk'),
158
+ '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'),
159
+ ),
160
+ 'ssl_on' => array(
161
+ 'title' => __("Use SSL", 'cleantalk'),
162
+ 'description' => __('Turn this option on to use encrypted (SSL) connection with CleanTalk servers.', 'cleantalk'),
163
+ ),
164
+ ),
165
+ ),
166
+
167
+ // Admin bar
168
+ 'admin_bar' => array(
169
+ 'title' => __('Admin bar', 'cleantalk'),
170
+ 'default_params' => array(),
171
+ 'description' => '',
172
+ 'html_before' => '',
173
+ 'html_after' => '',
174
+ 'fields' => array(
175
+ 'show_adminbar' => array(
176
+ 'title' => __('Show statistics in admin bar', 'cleantalk'),
177
+ 'description' => __('Show/hide CleanTalk icon in top level menu in WordPress backend. The number of submissions is being counted for past 24 hours.', 'cleantalk'),
178
+ 'childrens' => array('all_time_counter','daily_counter','sfw_counter'),
179
+ ),
180
+ 'all_time_counter' => array(
181
+ 'title' => __('Show All-time counter', 'cleantalk'),
182
+ 'description' => __('Display all-time requests counter in the admin bar. Counter displays number of requests since plugin installation.', 'cleantalk'),
183
+ 'parent' => 'show_adminbar',
184
+ 'class' => 'apbct_settings-field_wrapper--sub',
185
+ ),
186
+ 'daily_counter' => array(
187
+ 'title' => __('Show 24 hours counter', 'cleantalk'),
188
+ 'description' => __('Display daily requests counter in the admin bar. Counter displays number of requests of the past 24 hours.', 'cleantalk'),
189
+ 'parent' => 'show_adminbar',
190
+ 'class' => 'apbct_settings-field_wrapper--sub',
191
+ ),
192
+ 'sfw_counter' => array(
193
+ 'title' => __('SpamFireWall counter', 'cleantalk'),
194
+ 'description' => __('Display SpamFireWall requests in the admin bar. Counter displays number of requests since plugin installation.', 'cleantalk'),
195
+ 'parent' => 'show_adminbar',
196
+ 'class' => 'apbct_settings-field_wrapper--sub',
197
+ ),
198
+ ),
199
+ ),
200
+
201
+ // Misc
202
+ 'misc' => array(
203
+ 'html_after' => '</div><br>',
204
+ 'fields' => array(
205
+ 'collect_details' => array(
206
+ 'type' => 'checkbox',
207
+ 'title' => __('Collect details about browsers', 'cleantalk'),
208
+ 'description' => __("Checking this box you allow plugin store information about screen size and browser plugins of website visitors. The option in a beta state.", 'cleantalk'),
209
+ ),
210
+ 'send_connection_reports' => array(
211
+ 'type' => 'checkbox',
212
+ 'title' => __('Send connection reports', 'cleantalk'),
213
+ 'description' => __("Checking this box you allow plugin to send the information about your connection. The option in a beta state.", 'cleantalk'),
214
+ ),
215
+ 'async_js' => array(
216
+ 'type' => 'checkbox',
217
+ 'title' => __('Async JavaScript loading', 'cleantalk'),
218
+ 'description' => __('Use async loading for CleanTalk\'s scripts. Warning: This could reduce filtration quality.', 'cleantalk'),
219
+ ),
220
+ ),
221
+ ),
222
+ );
223
+
224
+ foreach($apbct->settings_fields_in_groups as $group_name => $group){
225
+
226
+ add_settings_section('apbct_section__'.$group_name, '', 'apbct_section__'.$group_name, 'cleantalk');
227
+
228
+ foreach($group['fields'] as $field_name => $field){
229
+
230
+ $params = !empty($group['default_params'])
231
+ ? array_merge($group['default_params'], $field)
232
+ : array_merge($field_default_params, $field);
233
+
234
+ $params['name'] = $field_name;
235
+
236
+ add_settings_field(
237
+ 'apbct_field__'.$field_name,
238
+ '',
239
+ $params['callback'],
240
+ 'cleantalk',
241
+ 'apbct_section__'.$group_name,
242
+ $params
243
+ );
244
+
245
+ }
246
+
247
+ }
248
+
249
+ // GDPR
250
+ // add_settings_field('cleantalk_collect_details', __('Collect details about browsers', 'cleantalk'), 'ct_input_collect_details', 'cleantalk', 'apbct_secton_antispam');
251
+ // add_settings_field('cleantalk_connection_reports', __('Send connection reports', 'cleantalk'), 'ct_send_connection_reports', 'cleantalk', 'apbct_secton_antispam');
252
+ }
253
+
254
+ /**
255
+ * Admin callback function - Displays plugin options page
256
+ */
257
+ function apbct_settings_page() {
258
+
259
+ global $apbct;
260
+
261
+ // Title
262
+ echo '<h2 class="apbct_settings-title">'.__($apbct->plugin_name, 'cleantalk').'</h2>';
263
+ // Subtitle for IP license
264
+ if($apbct->moderate_ip)
265
+ echo '<h4 class="apbct_settings-subtitle gray">'. __('Hosting AntiSpam', 'cleantalk').'</h4>';
266
+
267
+ apbct_settings__error__output();
268
+
269
+ // Top info
270
+ echo '<div style="float: right; padding: 15px 15px 0 15px; font-size: 13px;">';
271
+
272
+ echo __('CleanTalk\'s tech support:', 'cleantalk')
273
+ .'&nbsp;'
274
+ .'<a target="_blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">Wordpress.org</a>.'
275
+ // .' <a href="https://community.cleantalk.org/viewforum.php?f=25" target="_blank">'.__("Tech forum", 'cleantalk').'</a>'
276
+ // .($user_token ? ", <a href='https://cleantalk.org/my/support?user_token=$user_token&cp_mode=antispam' target='_blank'>".__("Service support ", 'cleantalk').'</a>' : '').
277
+ .'<br>';
278
+ echo __('Plugin Homepage at', 'cleantalk').' <a href="http://cleantalk.org" target="_blank">cleantalk.org</a>.<br/>';
279
+ echo '<span id="apbct_gdpr_open_modal" style="text-decoration: underline;">'.__('GDPR compliance', 'cleantalk').'</span><br/>';
280
+ echo __('Use s@cleantalk.org to test plugin in any WordPress form.', 'cleantalk').'<br>';
281
+ echo __('CleanTalk is registered Trademark. All rights reserved.', 'cleantalk').'<br/>';
282
+ 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 />';
283
+ apbct_admin__badge__get_premium();
284
+ echo '<div id="gdpr_dialog" style="display: none; padding: 7px;">';
285
+ apbct_gdpr__show_text();
286
+ echo '</div>';
287
+ echo '</div>';
288
+
289
+ echo '<form action="options.php" method="post">';
290
+
291
+ // If it's network admin dashboard
292
+ if(is_network_admin()){
293
+ if(defined('CLEANTALK_ACCESS_KEY')){
294
+ print '<br />'
295
+ .sprintf(__('Your CleanTalk access key is: <b>%s</b>.', 'cleantalk'), CLEANTALK_ACCESS_KEY)
296
+ .'<br />'
297
+ .'You can change it in your wp-config.php file.'
298
+ .'<br />';
299
+ }else{
300
+ print '<br />'
301
+ .__('To set up global CleanTalk access key for all websites, define constant in your wp-config.php file before defining database constants: <br/><pre>define("CLEANTALK_ACCESS_KEY", "place your key here");</pre>', 'cleantalk');
302
+ }
303
+ return;
304
+ }
305
+
306
+ // Output spam count
307
+ if($apbct->key_is_ok && apbct_api_key__is_correct()){
308
+ if($apbct->spam_count > 0){
309
+ echo '<div class="apbct_settings-subtitle" style="top: 0; margin-bottom: 10px; width: 200px;">'
310
+ .'<br>'
311
+ .'<span>'
312
+ .sprintf(
313
+ __( 'CleanTalk has blocked <b>%s</b> spam.', 'cleantalk' ),
314
+ number_format($apbct->spam_count, 0, ',', ' ')
315
+ )
316
+ .'</span>'
317
+ .'<br>'
318
+ .'<br>'
319
+ .'</div>';
320
+ }
321
+ // CP button
322
+ 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>';
323
+ echo '&nbsp;&nbsp;';
324
+ // Support button
325
+ echo '<a class="cleantalk_auto_link" target="__blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">'.__('Support', 'cleantalk').'</a>';
326
+ echo '<br>'
327
+ .'<br>';
328
+ }
329
+
330
+ settings_fields('cleantalk_settings');
331
+ do_settings_fields('cleantalk', 'cleantalk_section_settings_main');
332
+ if($apbct->debug){
333
+ echo '<hr>';
334
+ do_settings_fields('cleantalk', 'cleantalk_section_debug');
335
+ }
336
+ echo '<hr>';
337
+ do_settings_fields('cleantalk', 'cleantalk_section_state');
338
+
339
+ foreach($apbct->settings_fields_in_groups as $group_name => $group){
340
+
341
+ echo !empty($group['html_before']) ? $group['html_before'] : '';
342
+ echo !empty($group['title']) ? '<h3 style="margin-left: 220px;">'.$group['title'].'</h3>' : '';
343
+
344
+ do_settings_fields('cleantalk', 'apbct_section__'.$group_name);
345
+
346
+ echo !empty($group['html_after']) ? $group['html_after'] : '';
347
+
348
+ }
349
+
350
+ echo '<br>';
351
+ echo '<button name="submit" class="cleantalk_manual_link" value="save_changes">'.__('Save Changes').'</button>';
352
+
353
+ echo "</form>";
354
+
355
+ // Translate banner for non EN locale
356
+ if(substr(get_locale(), 0, 2) != 'en'){
357
+ require_once(CLEANTALK_PLUGIN_DIR.'templates/translate_banner.php');
358
+ printf($ct_translate_banner_template, substr(get_locale(), 0, 2));
359
+ }
360
+ }
361
+
362
+ function apbct_settings__error__output($return = false){
363
+
364
+ global $apbct;
365
+
366
+ // If have error message output error block.
367
+
368
+ if(!empty($apbct->errors)){
369
+
370
+ $errors = $apbct->errors;
371
+
372
+ $error_texts = array(
373
+ // Misc
374
+ 'key_invalid' => __('Error occured while API key validating. Error: ', 'security-malware-firewall'),
375
+ 'key_get' => __('Error occured while automatically gettings access key. Error: ', 'security-malware-firewall'),
376
+ 'sfw_send_logs' => __('Error occured while sending sending SpamFireWall logs. Error: ', 'security-malware-firewall'),
377
+ 'sfw_update' => __('Error occured while updating SpamFireWall local base. Error: ' , 'security-malware-firewall'),
378
+ 'account_check' => __('Error occured while checking account status. Error: ', 'security-malware-firewall'),
379
+ 'api' => __('Error occured while excuting API call. Error: ', 'security-malware-firewall'),
380
+ // Unknown
381
+ 'unknown' => __('Unknown error. Error: ', 'security-malware-firewall'),
382
+ );
383
+
384
+ $errors_out = array();
385
+
386
+ foreach($errors as $type => $error){
387
+
388
+ if(!empty($error)){
389
+
390
+ if(is_array(current($error))){
391
+
392
+ foreach($error as $sub_type => $sub_error){
393
+ $errors_out[$sub_type] = '';
394
+ if(isset($sub_error['error_time']))
395
+ $errors_out[$sub_type] .= date('Y-m-d H:i:s', $sub_error['error_time']) . ': ';
396
+ $errors_out[$sub_type] .= ucfirst($type).': ';
397
+ $errors_out[$sub_type] .= (isset($error_texts[$sub_type]) ? $error_texts[$sub_type] : $error_texts['unknown']) . $sub_error['error_string'];
398
+ }
399
+ continue;
400
+ }
401
+
402
+ $errors_out[$type] = '';
403
+ if(isset($error['error_time']))
404
+ $errors_out[$type] .= date('Y-m-d H:i:s', $error['error_time']) . ': ';
405
+ $errors_out[$type] .= (isset($error_texts[$type]) ? $error_texts[$type] : $error_texts['unknown']) . (isset($error['error_string']) ? $error['error_string'] : '');
406
+
407
+ }
408
+ }
409
+
410
+ $out = '';
411
+ if(!empty($errors_out)){
412
+ $out .= '<div id="apbctTopWarning" class="error" style="position: relative;">'
413
+ .'<h3 style="display: inline-block;">'.__('Errors:', 'security-malware-firewall').'</h3>';
414
+ foreach($errors_out as $value)
415
+ $out .= '<h4>'.$value.'</h4>';
416
+ $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>';
417
+ $out .= '</div>';
418
+ }
419
+ }
420
+
421
+ if($return) return $out; else echo $out;
422
+ }
423
+
424
+ function apbct_settings__field__debug(){
425
+
426
+ global $apbct;
427
+
428
+ echo '<hr /><h2>Debug:</h2>';
429
+ echo '<h4>Constants:</h4>';
430
+ echo 'CLEANTALK_AJAX_USE_BUFFER '. (defined('CLEANTALK_AJAX_USE_BUFFER') ? (CLEANTALK_AJAX_USE_BUFFER ? 'true' : 'flase') : 'NOT_DEFINED')."<br>";
431
+ echo 'CLEANTALK_AJAX_USE_FOOTER_HEADER '. (defined('CLEANTALK_AJAX_USE_FOOTER_HEADER') ? (CLEANTALK_AJAX_USE_FOOTER_HEADER ? 'true' : 'flase') : 'NOT_DEFINED')."<br>";
432
+ echo 'CLEANTALK_ACCESS_KEY '. (defined('CLEANTALK_ACCESS_KEY') ? (CLEANTALK_ACCESS_KEY ? CLEANTALK_ACCESS_KEY : 'flase') : 'NOT_DEFINED')."<br>";
433
+ echo 'CLEANTALK_CHECK_COMMENTS_NUMBER '. (defined('CLEANTALK_CHECK_COMMENTS_NUMBER') ? (CLEANTALK_CHECK_COMMENTS_NUMBER ? CLEANTALK_CHECK_COMMENTS_NUMBER : 0) : 'NOT_DEFINED')."<br>";
434
+ echo 'CLEANTALK_CHECK_MESSAGES_NUMBER '. (defined('CLEANTALK_CHECK_MESSAGES_NUMBER') ? (CLEANTALK_CHECK_MESSAGES_NUMBER ? CLEANTALK_CHECK_MESSAGES_NUMBER : 0) : 'NOT_DEFINED')."<br>";
435
+ echo 'CLEANTALK_PLUGIN_DIR '. (defined('CLEANTALK_PLUGIN_DIR') ? (CLEANTALK_PLUGIN_DIR ? CLEANTALK_PLUGIN_DIR : 'flase') : 'NOT_DEFINED')."<br>";
436
+ echo 'WP_ALLOW_MULTISITE '. (defined('WP_ALLOW_MULTISITE') ? (WP_ALLOW_MULTISITE ? 'true' : 'flase') : 'NOT_DEFINED');
437
+
438
+ echo "<h4>Debug log: <button type='submit' value='debug_drop' name='submit' style='font-size: 11px; padding: 1px;'>Drop debug data</button></h4>";
439
+ echo "<div style='height: 500px; width: 80%; overflow: auto;'>";
440
+
441
+ $output = print_r($apbct->debug, true);
442
+ $output = str_replace("\n", "<br>", $output);
443
+ $output = preg_replace("/[^\S]{4}/", "&nbsp;&nbsp;&nbsp;&nbsp;", $output);
444
+ echo "$output";
445
+
446
+ echo "</div>";
447
+ }
448
+
449
+ function apbct_settings__field__state(){
450
+
451
+ global $apbct, $wpdb;
452
+
453
+ $path_to_img = plugin_dir_url(__FILE__) . "images/";
454
+
455
+ $img = $path_to_img."yes.png";
456
+ $img_no = $path_to_img."no.png";
457
+ $img_no_gray = $path_to_img."no_gray.png";
458
+ $color="black";
459
+
460
+ if(!$apbct->key_is_ok){
461
+ $img=$path_to_img."no.png";
462
+ $img_no=$path_to_img."no.png";
463
+ $color="black";
464
+ }
465
+
466
+ if(!apbct_api_key__is_correct($apbct->api_key)){
467
+ $img = $path_to_img."yes_gray.png";
468
+ $img_no = $path_to_img."no_gray.png";
469
+ $color="gray";
470
+ }
471
+
472
+ if($apbct->moderate_ip)
473
+ {
474
+ $img = $path_to_img."yes.png";
475
+ $img_no = $path_to_img."no.png";
476
+ $color="black";
477
+ }
478
+
479
+ print '<div class="apbct_settings-field_wrapper" style="color:'.$color.'">';
480
+
481
+ print '<h2>'.__('Protection is active', 'cleantalk').'</h2>';
482
+
483
+ echo '<img class="apbct_status_icon" src="'.($apbct->settings['registrations_test'] == 1 || $apbct->moderate_ip ? $img : $img_no).'"/>'
484
+ .__('Registration forms', 'cleantalk');
485
+ echo '<img class="apbct_status_icon" src="'.($apbct->settings['comments_test']==1 || $apbct->moderate_ip ? $img : $img_no).'"/>'
486
+ .__('Comments forms', 'cleantalk');
487
+ echo '<img class="apbct_status_icon" src="'.($apbct->settings['contact_forms_test']==1 || $apbct->moderate_ip ? $img : $img_no).'"/>'
488
+ .__('Contact forms', 'cleantalk');
489
+ echo '<img class="apbct_status_icon" src="'.($apbct->settings['general_contact_forms_test']==1 || $apbct->moderate_ip ? $img : $img_no).'"/>'
490
+ .__('Custom contact forms', 'cleantalk');
491
+
492
+ // SFW + current network count
493
+ /*
494
+ $sfw_netwoks_amount = $wpdb->get_results("SELECT count(*) AS cnt FROM `".$wpdb->base_prefix."cleantalk_sfw`", ARRAY_A);
495
+ $alt_for_sfw = sprintf(__('Networks in database: %d.', 'cleantalk'), $sfw_netwoks_amount[0]['cnt']);
496
+ echo '<img class="apbct_status_icon" src="'.($apbct->settings['spam_firewall']==1 || $apbct->moderate_ip ? $img : $img_no).'" title="'.($apbct->settings['spam_firewall']==1 || $apbct->moderate_ip ? $alt_for_sfw : '').'"/>'.__('SpamFireWall', 'cleantalk');
497
+ */
498
+
499
+ // Autoupdate status
500
+ if($apbct->notice_auto_update){
501
+ echo '<img class="apbct_status_icon" src="'.($apbct->auto_update == 1 ? $img : ($apbct->auto_update == -1 ? $img_no : $img_no_gray)).'"/>'.__('Auto update', 'cleantalk')
502
+ .' <sup><a href="http://cleantalk.org/help/cleantalk-auto-update" target="_blank">?</a></sup>';
503
+ }
504
+
505
+ // WooCommerce
506
+ if(class_exists('WooCommerce'))
507
+ echo '<img class="apbct_status_icon" src="'.($apbct->options['wc_checkout_test']==1 || $apbct->moderate_ip ? $img : $img_no).'"/>'.__('WooCommerce checkout form', 'cleantalk');
508
+
509
+ if($apbct->moderate_ip)
510
+ print "<br /><br />The anti-spam service is paid by your hosting provider. License #".$apbct->data['ip_license'].".<br />";
511
+
512
+ print "</div>";
513
+ }
514
+
515
+ /**
516
+ * Admin callback function - Displays inputs of 'apikey' plugin parameter
517
+ */
518
+ function apbct_settings__field__api_key(){
519
+
520
+ global $apbct;
521
+
522
+ 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"' : '').'>';
523
+
524
+ if(!is_multisite()){
525
+
526
+ echo '<label class="apbct_settings__label" for="cleantalk_apkey">'.__('Access key', 'cleantalk').'</label>'
527
+ .'<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') . '" />';
528
+
529
+ // Key is correct
530
+ if(!apbct_api_key__is_correct($apbct->api_key) || !$apbct->key_is_ok){
531
+ echo '<script>var cleantalk_good_key=false;</script>';
532
+ echo '<br /><br />';
533
+
534
+ // Auto get key
535
+ if(!$apbct->ip_license){
536
+ echo '<button id="apbct_setting_get_key_auto" name="submit" type="submit" class="cleantalk_manual_link" value="get_key_auto">'
537
+ .__('Get access key automatically', 'cleantalk')
538
+ .'</button>';
539
+ echo '<input type="hidden" id="ct_admin_timezone" name="ct_admin_timezone" value="null" />';
540
+ echo '&nbsp;' . __('or') . '&nbsp;';
541
+ }
542
+
543
+ // Manual get key
544
+ echo '<a style="color: gray;" target="__blank" href="https://cleantalk.org/register?platform=wordpress&email='.urlencode(ct_get_admin_email()).'&website='.urlencode(parse_url(get_option('siteurl'),PHP_URL_HOST)).'">'.__('Get access key manually', 'cleantalk').'</a>';
545
+ echo '<br />';
546
+ echo '<br />';
547
+
548
+ // Warnings and GDPR
549
+ printf(__('Admin e-mail (%s) will be used for registration', 'cleantalk'), ct_get_admin_email());
550
+ echo '<div>';
551
+ echo '<input checked type="checkbox" id="license_agreed" onclick="apbctSettingsDependencies(\'get_key_auto\');"/>';
552
+ echo '<label for="spbc_license_agreed">';
553
+ printf(
554
+ __('I agree with %sPrivacy Policy%s of %sLicense Agreement%s', 'security-malware-firewall'),
555
+ '<a href="https://cleantalk.org/publicoffer#privacy" target="_blank" style="color:#66b;">', '</a>',
556
+ '<a href="https://cleantalk.org/publicoffer" target="_blank" style="color:#66b;">', '</a>'
557
+ );
558
+ echo "</label>";
559
+ echo '</div>';
560
+ }
561
+
562
+ }else{
563
+ _e('<h3>Key is provided by Super Admin.<h3>', 'cleantalk');
564
+ }
565
+
566
+ echo '</div>';
567
+
568
+ if($apbct->ip_license){
569
+ $cleantalk_support_links = "<br /><div>";
570
+ $cleantalk_support_links .= "<a href='#' class='ct_support_link'>" . __("Show the access key", 'cleantalk') . "</a>";
571
+ $cleantalk_support_links .= "</div>";
572
+ echo "<script type=\"text/javascript\">var cleantalk_good_key=true; var cleantalk_support_links = \"$cleantalk_support_links\";</script>";
573
+ }
574
+ }
575
+
576
+ function apbct_settings__field__action_buttons(){
577
+
578
+ global $apbct;
579
+
580
+ echo '<div class="apbct_settings-field_wrapper">';
581
+
582
+ if(apbct_api_key__is_correct($apbct->api_key) && $apbct->key_is_ok){
583
+ echo '<div>'
584
+ .'<a href="#" class="ct_support_link" onclick="apbct_show_hide_elem(\'#cleantalk_apkey_wrapper\')">' . __('Show the access key', 'cleantalk') . '</a>'
585
+ .'&nbsp;&nbsp;'
586
+ .'&nbsp;&nbsp;'
587
+ .'<a href="edit-comments.php?page=ct_check_spam" class="ct_support_link">' . __('Check comments for spam', 'cleantalk') . '</a>'
588
+ .'&nbsp;&nbsp;'
589
+ .'&nbsp;&nbsp;'
590
+ .'<a href="users.php?page=ct_check_users" class="ct_support_link">' . __('Check users for spam', 'cleantalk') . '</a>'
591
+ .'&nbsp;&nbsp;'
592
+ .'&nbsp;&nbsp;'
593
+ .'<a href="#" class="ct_support_link" onclick="apbct_show_hide_elem(\'#apbct_connection_reports\')">' . __('Negative report', 'cleantalk') . '</a>'
594
+ .'</div>';
595
+
596
+ }
597
+
598
+ echo '</div>';
599
+ }
600
+
601
+ function apbct_settings__field__connection_reports() {
602
+
603
+ global $apbct;
604
+
605
+ echo '<div id="apbct_connection_reports" class="apbct_settings-field_wrapper" style="display: none;">';
606
+
607
+ if ($apbct->connection_reports){
608
+
609
+ if ($apbct->connection_reports['negative'] == 0){
610
+ _e('There are no failed connections to CleanTalk servers.', 'cleantalk');
611
+ }else{
612
+ echo "<table id='negative_reports_table' style='display: none;'>
613
+ <tr>
614
+ <td>#</td>
615
+ <td><b>Date</b></td>
616
+ <td><b>Page URL</b></td>
617
+ <td><b>Report</b></td>
618
+ </tr>";
619
+ foreach($apbct->connection_reports['negative_report'] as $key => $report){
620
+ echo "<tr><td>".($key+1).".</td><td>".$report['date']."</td><td>".$report['page_url']."</td><td>".$report['lib_report']."</td></tr>";
621
+ }
622
+ echo "</table>";
623
+ echo '<br/>'
624
+ .'<button name="submit" class="cleantalk_manual_link" value="ct_send_connection_report">'.__('Send report', 'cleantalk').'</button>';
625
+ }
626
+
627
+ }
628
+
629
+ echo '</div>';
630
+ }
631
+
632
+ function apbct_settings__field__draw($params = array()){
633
+
634
+ global $apbct;
635
+
636
+ echo '<div class="'.$params['def_class'].(isset($params['class']) ? ' '.$params['class'] : '').'">';
637
+ switch($params['type']){
638
+ case 'checkbox':
639
+ echo '<input type="checkbox" id="apbct_setting_'.$params['name'].'" name="cleantalk_settings['.$params['name'].']" value="1" '
640
+ .($apbct->settings[$params['name']] == '1' ? ' checked' : '')
641
+ .($params['parent'] && !$apbct->settings[$params['parent']] ? ' disabled="disabled"' : '')
642
+ .(!$params['childrens'] ? '' : ' onchange="apbctSettingsDependencies([\''.implode("','",$params['children']).'\'])"')
643
+ .' />'
644
+ .'<label for="apbct_setting_'.$params['name'].'" class="apbct_setting-field_title--'.$params['type'].'">'
645
+ .$params['title']
646
+ .'</label>';
647
+ echo '<div class="apbct_settings-field_description">'
648
+ .$params['description']
649
+ .'</div>';
650
+ break;
651
+ case 'radio':
652
+ echo '<h4 class="apbct_settings-field_title apbct_settings-field_title--'.$params['type'].'">'
653
+ .$params['title']
654
+ .'</h4>';
655
+
656
+ echo '<div class="apbct_settings-field_content apbct_settings-field_content--'.$params['type'].'">';
657
+
658
+ echo '<input type="radio" id="apbct_setting_'.$params['name'].'_yes" name="cleantalk_settings['.$params['name'].']" value="1" '
659
+ .($params['parent'] && !$apbct->settings[$params['parent']] ? ' disabled="disabled"' : '')
660
+ .(!$params['childrens'] ? '' : ' onchange="apbctSettingsDependencies([\''.implode("','",$params['childrens']).'\'])"')
661
+ .($apbct->settings[$params['name']] ? ' checked' : '').' />'
662
+ .'<label for="apbct_setting_'.$params['name'].'_yes"> ' . __('Yes') . '</label>';
663
+
664
+ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
665
+
666
+ echo '<input type="radio" id="apbct_setting_'.$params['name'].'_no" name="cleantalk_settings['.$params['name'].']" value="0" '
667
+ .($params['parent'] && !$apbct->settings[$params['parent']] ? ' disabled="disabled"' : '')
668
+ .(!$params['childrens'] ? '' : ' onchange="apbctSettingsDependencies([\''.implode("','",$params['childrens']).'\'])"')
669
+ .(!$apbct->settings[$params['name']] ? ' checked' : '').' />'
670
+ .'<label for="apbct_setting_'.$params['name'].'_no">'. __('No') . '</label>';
671
+
672
+ echo '<div class="apbct_settings-field_description">'
673
+ .$params['description']
674
+ .'</div>';
675
+
676
+ echo '</div>';
677
+ break;
678
+ }
679
+
680
+ echo '</div>';
681
+ }
682
+
683
+ /**
684
+ * Admin callback function - Plugin parameters validator
685
+ */
686
+ function apbct_settings__validate($settings) {
687
+
688
+ global $apbct;
689
+
690
+ // Drop debug data
691
+ if (isset($_POST['submit']) && $_POST['submit'] == 'debug_drop'){
692
+ $apbct->debug = false;
693
+ delete_option('cleantalk_debug');
694
+ return $settings;
695
+ }
696
+
697
+ // Send connection reports
698
+ if (isset($_POST['submit']) && $_POST['submit'] == 'ct_send_connection_report'){
699
+ ct_mail_send_connection_report();
700
+ return $settings;
701
+ }
702
+
703
+ // Auto getting key
704
+ if (isset($_POST['submit']) && $_POST['submit'] == 'get_key_auto')
705
+ {
706
+ $website = parse_url(get_option('siteurl'),PHP_URL_HOST);
707
+ $platform = 'wordpress';
708
+ $timezone = $_POST['ct_admin_timezone'];
709
+
710
+ $result = CleantalkHelper::api_method__get_api_key(ct_get_admin_email(), $website, $platform, $timezone);
711
+
712
+ if(empty($result['error'])){
713
+
714
+ if(isset($result['user_token'])){
715
+ $apbct->data['user_token'] = $result['user_token'];
716
+ $apbct->saveData();
717
+ }
718
+
719
+ if(!empty($result['auth_key'])){
720
+ $settings['apikey'] = $result['auth_key'];
721
+ }
722
+
723
+ }else{
724
+ $apbct->error_add('key_get', $result);
725
+ }
726
+ }
727
+
728
+ $settings['apikey'] = isset($settings['apikey']) ? trim($settings['apikey']) : '';
729
+
730
+ // Key is good by default
731
+ $apbct->data['key_is_ok'] = true;
732
+
733
+ // Is key correct?
734
+ if(apbct_api_key__is_correct($settings['apikey'])){
735
+
736
+ $result = CleantalkHelper::api_method__notice_validate_key($settings['apikey'], preg_replace('/http[s]?:\/\//', '', get_option('siteurl'), 1));
737
+
738
+ // Is key valid?
739
+ if (empty($result['error'])){
740
+
741
+ if($result['valid'] == 1){
742
+
743
+ // Deleting errors about invalid key
744
+ $apbct->error_delete('key_invalid', 'save');
745
+
746
+ // TO DO // Feedback with app_agent
747
+ ct_send_feedback('0:' . APBCT_AGENT); // 0 - request_id, agent version.
748
+
749
+ // Check account status
750
+ ct_account_status_check($settings['apikey']);
751
+
752
+ // Key is not valid
753
+ }else{
754
+ $apbct->data['key_is_ok'] = false;
755
+ $apbct->error_add('key_invalid', __('Testing is failed. Please check the Access key.', 'cleantalk'));
756
+ }
757
+
758
+ // Server error when notice_validate_key
759
+ }else{
760
+ $apbct->error_add('key_invalid', $result);
761
+ }
762
+
763
+ // Key is not correct
764
+ }else{
765
+ if(empty($settings['apikey'])){
766
+ $apbct->error_delete('key_invalid account_check', 'save');
767
+ }else
768
+ $apbct->error_add('key_invalid', __('Key is not correct', 'cleantalk'));
769
+ }
770
+
771
+ // A-B test with SFW
772
+ if(!$apcbt->data['ab_test']['sfw_enabled']){
773
+ if($apbct->service_id % 2 == 1)
774
+ $settings['spam_firewall'] = 0;
775
+ else
776
+ $settings['spam_firewall'] = 1;
777
+ $apcbt->data['ab_test']['sfw_enabled'] = true;
778
+ }
779
+
780
+ $apbct->saveData();
781
+
782
+
783
+ return $settings;
784
+ }
785
+
786
+ function apbct_gdpr__show_text(){
787
+ ?>
788
+ <p>The notice requirements remain and are expanded. They must include the retention time for personal data, and contact information for data controller and data protection officer has to be provided.</p>
789
+
790
+ <p>Automated individual decision-making, including profiling (Article 22) is contestable, similarly to the Data Protection Directive (Article 15). Citizens have rights to question and fight significant decisions that affect them that have been made on a solely-algorithmic basis. Many media outlets have commented on the introduction of a "right to explanation" of algorithmic decisions, but legal scholars have since argued that the existence of such a right is highly unclear without judicial tests and is limited at best.</p>
791
+
792
+ <p>To be able to demonstrate compliance with the GDPR, the data controller should implement measures, which meet the principles of data protection by design and data protection by default. Privacy by design and by default (Article 25) require data protection measures to be designed into the development of business processes for products and services. Such measures include pseudonymising personal data, by the controller, as soon as possible (Recital 78).</p>
793
+
794
+ <p>It is the responsibility and the liability of the data controller to implement effective measures and be able to demonstrate the compliance of processing activities even if the processing is carried out by a data processor on behalf of the controller (Recital 74).</p>
795
+
796
+ <p>Data Protection Impact Assessments (Article 35) have to be conducted when specific risks occur to the rights and freedoms of data subjects. Risk assessment and mitigation is required and prior approval of the national data protection authorities (DPAs) is required for high risks. Data protection officers (Articles 37–39) are required to ensure compliance within organisations.</p>
797
+
798
+ <p>They have to be appointed:</p>
799
+ <ul style="padding: 0px 25px; list-style: disc;">
800
+ <li>for all public authorities, except for courts acting in their judicial capacity</li>
801
+ <li>if the core activities of the controller or the processor are:</li>
802
+ <ul style="padding: 0px 25px; list-style: disc;">
803
+ <li>processing operations, which, by virtue of their nature, their scope and/or their purposes, require regular and systematic monitoring of data subjects on a large scale</li>
804
+ <li>processing on a large scale of special categories of data pursuant to Article 9 and personal data relating to criminal convictions and offences referred to in Article 10';</li>
805
+ </ul>
806
+ </li>
807
+ </ul>
808
+ <?php
809
+ }
inc/cleantalk-updater.php CHANGED
@@ -67,9 +67,7 @@ function apbct_update_to_5_56_0(){
67
  }
68
  function apbct_update_to_5_70_0(){
69
 
70
- global $wpdb, $ct_data;
71
-
72
- $ct_data = ct_get_data();
73
 
74
  if(!in_array('all_entries', $wpdb->get_col("DESC " . $wpdb->base_prefix."cleantalk_sfw_logs", 0))){
75
  $wpdb->query("ALTER TABLE `".$wpdb->base_prefix."cleantalk_sfw_logs`
@@ -80,8 +78,6 @@ function apbct_update_to_5_70_0(){
80
  }
81
 
82
  // Deleting usless data
83
- unset($ct_data['db_refreshed'], $ct_data['last_sfw_send'], $ct_data['next_account_status_check']);
84
- update_option('cleantalk_data', $ct_data);
85
  delete_option('cleantalk_sends_reports_till');
86
  delete_option('cleantalk_activation_timestamp');
87
 
@@ -106,12 +102,10 @@ function apbct_update_to_5_74_0(){
106
 
107
  function apbct_update_to_5_97_0(){
108
 
109
- global $ct_data;
110
-
111
- $ct_data = ct_get_data();
112
 
113
- if(count($ct_data['connection_reports']['negative_report']) >= 20)
114
- $ct_data['connection_reports']['negative_report'] = array_slice($ct_data['connection_reports']['negative_report'], -20, 20);
115
 
116
- update_option('cleantalk_data', $ct_data);
117
  }
67
  }
68
  function apbct_update_to_5_70_0(){
69
 
70
+ global $wpdb;
 
 
71
 
72
  if(!in_array('all_entries', $wpdb->get_col("DESC " . $wpdb->base_prefix."cleantalk_sfw_logs", 0))){
73
  $wpdb->query("ALTER TABLE `".$wpdb->base_prefix."cleantalk_sfw_logs`
78
  }
79
 
80
  // Deleting usless data
 
 
81
  delete_option('cleantalk_sends_reports_till');
82
  delete_option('cleantalk_activation_timestamp');
83
 
102
 
103
  function apbct_update_to_5_97_0(){
104
 
105
+ global $apbct;
 
 
106
 
107
+ if(count($abpct->data['connection_reports']['negative_report']) >= 20)
108
+ $abpct->data['connection_reports']['negative_report'] = array_slice($abpct->data['connection_reports']['negative_report'], -20, 20);
109
 
110
+ $abpct->saveData();
111
  }
inc/cleantalk-users.php CHANGED
@@ -17,18 +17,16 @@ function ct_add_users_menu(){
17
 
18
  function ct_show_users_page(){
19
 
20
- global $ct_plugin_name, $wpdb;
21
 
22
  ?>
23
  <div class="wrap">
24
- <h2><img src="<?php echo plugin_dir_url(__FILE__) ?>/images/logo_color.png" /> <?php echo $ct_plugin_name; ?></h2><br />
25
  <?php
26
 
27
  // If access key is unset in
28
- if(!ct_valid_key()){
29
- global $ct_data;
30
- $ct_data = ct_get_data();
31
- if($ct_data['moderate_ip'] = 1){
32
  echo '<h3>'
33
  .sprintf(
34
  __('Antispam hosting tariff does not allow you to use this feature. To do so, you need to enter an Access Key in the %splugin settings%s.', 'cleantalk'),
@@ -91,7 +89,7 @@ function ct_show_users_page(){
91
  <input class="ct_date" type="text" id="ct_date_range_till" value="<?php echo isset($_GET['till']) ? $_GET['till'] : ''; ?>" disabled readonly />
92
  </div>
93
  <br>
94
- <?php ct_input_get_premium(); ?>
95
  </div>
96
 
97
  <!-- Cooling notice -->
@@ -285,9 +283,7 @@ function ct_ajax_check_users(){
285
 
286
  check_ajax_referer('ct_secret_nonce', 'security');
287
 
288
- global $ct_options,$ct_ip_penalty_days;
289
-
290
- $ct_options = ct_get_options();
291
 
292
  $skip_roles = array(
293
  'administrator'
@@ -396,7 +392,7 @@ function ct_ajax_check_users(){
396
  die();
397
  }
398
 
399
- $result = CleantalkHelper::api_method__spam_check_cms($ct_options['apikey'], $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;
21
 
22
  ?>
23
  <div class="wrap">
24
+ <h2><img src="<?php echo plugin_dir_url(__FILE__) ?>/images/logo_color.png" /> <?php echo APBCT_NAME; ?></h2><br />
25
  <?php
26
 
27
  // If access key is unset in
28
+ if(!apbct_api_key__is_correct()){
29
+ if($apbct->moderate_ip == 1){
 
 
30
  echo '<h3>'
31
  .sprintf(
32
  __('Antispam hosting tariff does not allow you to use this feature. To do so, you need to enter an Access Key in the %splugin settings%s.', 'cleantalk'),
89
  <input class="ct_date" type="text" id="ct_date_range_till" value="<?php echo isset($_GET['till']) ? $_GET['till'] : ''; ?>" disabled readonly />
90
  </div>
91
  <br>
92
+ <?php apbct_admin__badge__get_premium(); ?>
93
  </div>
94
 
95
  <!-- Cooling notice -->
283
 
284
  check_ajax_referer('ct_secret_nonce', 'security');
285
 
286
+ global $apbct;
 
 
287
 
288
  $skip_roles = array(
289
  'administrator'
392
  die();
393
  }
394
 
395
+ $result = CleantalkHelper::api_method__spam_check_cms($apbct->api_key, $data, !empty($_POST['accurate_check']) ? $curr_date : null);
396
 
397
  if(empty($result['error'])){
398
 
inc/cleantalk-widget.php CHANGED
@@ -20,9 +20,7 @@ class cleantalk_widget extends WP_Widget
20
  // This is where the action happens
21
  public function widget( $args, $instance )
22
  {
23
- global $ct_data;
24
-
25
- $ct_data = ct_get_data();
26
 
27
  $title = apply_filters( 'widget_title', $instance['title'] );
28
  echo $args['before_widget'];
@@ -31,8 +29,7 @@ class cleantalk_widget extends WP_Widget
31
  if ( ! empty( $title ) ){ echo $args['before_title'] . $title . $args['after_title']; }
32
 
33
  // Parsing incoming params
34
- $blocked = isset( $ct_data['admin_blocked'] ) ? $ct_data['admin_blocked'] : 0;
35
- $blocked = number_format($blocked, 0, ',', ' ');
36
 
37
  $a_style = 'cursor: pointer; display: block; padding: 5px 0 5px; text-align: center; text-decoration: none; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; font-weight: normal; height: 100%; width: 100%; ';
38
  $strong_style = 'display: block; font-size: 15px; line-height: 16px; padding: 0 13px; white-space: nowrap; ';
20
  // This is where the action happens
21
  public function widget( $args, $instance )
22
  {
23
+ global $apbct;
 
 
24
 
25
  $title = apply_filters( 'widget_title', $instance['title'] );
26
  echo $args['before_widget'];
29
  if ( ! empty( $title ) ){ echo $args['before_title'] . $title . $args['after_title']; }
30
 
31
  // Parsing incoming params
32
+ $blocked = number_format($apbct->data['spam_count'], 0, ',', ' ');
 
33
 
34
  $a_style = 'cursor: pointer; display: block; padding: 5px 0 5px; text-align: center; text-decoration: none; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; font-weight: normal; height: 100%; width: 100%; ';
35
  $strong_style = 'display: block; font-size: 15px; line-height: 16px; padding: 0 13px; white-space: nowrap; ';
inc/sfw_die_page.html CHANGED
@@ -60,7 +60,7 @@ function get_current_url() {
60
  }, 50);
61
  setTimeout(function(){
62
  var ct_date = new Date;
63
- window.location.href=window.location.origin + window.location.pathname + (window.location.search === '' ? '?sfw=pass' : '&sfw=pass') + Math.round(ct_date.getTime()/1000);
64
  }, reload_timeout);
65
  </script>
66
  </body>
60
  }, 50);
61
  setTimeout(function(){
62
  var ct_date = new Date;
63
+ window.location.href = window.location.origin + window.location.pathname + '?sfw=pass' + Math.round(ct_date.getTime()/1000);
64
  }, reload_timeout);
65
  </script>
66
  </body>
js/cleantalk-admin-settings-page.js CHANGED
@@ -1,89 +1,61 @@
1
- var ct_adv_settings=null;
2
- var ct_adv_settings_title=null;
3
- var ct_adv_settings_show=false;
4
  jQuery(document).ready(function(){
5
  var d = new Date();
6
- var n = d.getTimezoneOffset();
7
- var data = {
8
- 'action': 'ajax_get_timezone',
9
- 'security': ctSettingsPage.ct_ajax_nonce,
10
- 'offset': n
11
- };
12
- jQuery.ajax({
13
- type: "POST",
14
- url: ajaxurl,
15
- data: data,
16
- success: function(msg){
17
- //
18
- }
19
- });
20
-
21
- if(cleantalk_good_key || ctSettingsPage.ip_license)
22
- {
23
- if(cleantalk_testing_failed !== true || ctSettingsPage.ip_license)
24
- jQuery('.form-table').first().find('tr').hide();
25
-
26
- banner_html="<div id='ct_stats_banner'>"+cleantalk_blocked_message;
27
- banner_html+=cleantalk_statistics_link+"&nbsp;&nbsp;"+cleantalk_support_link+'</div>';
28
- jQuery('.form-table').first().before(banner_html);
29
- if(!cleantalk_wpmu)
30
- {
31
- // jQuery('.form-table').first().before("<br /><a href='#' style='font-size:10pt;' id='cleantalk_access_key_link'>Show the access key</a>");
32
- jQuery('.form-table').first().before(cleantalk_support_links);
33
- }
34
- }else{
35
- jQuery('#ct_admin_timezone').val(d.getTimezoneOffset()/60*(-1));
36
- }
37
 
38
- jQuery('#cleantalk_access_key_link').click(function(){
39
- if(jQuery('.form-table').first().find('tr').eq(0).is(":visible"))
40
- jQuery('.form-table').first().find('tr').eq(0).hide();
41
- else
42
- jQuery('.form-table').first().find('tr').eq(0).show();
 
 
 
 
 
 
 
 
43
  });
44
 
45
- jQuery('#cleantalk_negative_report_link').click(function(){
46
- if(jQuery('.form-table').first().find('tr').eq(1).is(":visible")){
47
- jQuery('.form-table').first().find('tr').eq(1).hide();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }else{
49
- jQuery('.form-table').first().find('tr').eq(1).show();
 
50
  }
51
  });
52
-
53
- // Adding subtitle
54
- jQuery("#ct_stats_banner").prev().after('<h4 style="color: gray; position: relative; margin: 0; top: -15px;">'+ctSettingsPage.ct_subtitle+'</h4>');
55
-
56
- ct_adv_settings=jQuery('#cleantalk_registrations_test1').parent().parent().parent().parent();
57
- ct_adv_settings.hide();
58
- ct_adv_settings_title=ct_adv_settings.prev();
59
- ct_adv_settings.wrap("<div id='ct_advsettings_hide'>");
60
- ct_adv_settings_title.append(" <span id='ct_adv_showhide' style='cursor:pointer'><b><a href='#' style='text-decoration:none;'></a></b></span>");
61
- ct_adv_settings_title.css('cursor','pointer');
62
- ct_adv_settings_title.click(function(){
63
- if(ct_adv_settings_show)
64
- {
65
- ct_adv_settings.hide();
66
- ct_adv_settings_show=false;
67
- jQuery('#ct_adv_showhide').html("<b><a href='#' style='text-decoration:none;'></a></b>");
68
- }
69
- else
70
- {
71
- ct_adv_settings.show();
72
- ct_adv_settings_show=true;
73
- jQuery('#ct_adv_showhide').html("<b><a href='#' style='text-decoration:none;'></a></b>");
74
- }
75
-
76
- });
77
-
78
- //For counters settings.
79
- jQuery('#ct_advsettings_hide').on('click', '#cleantalk_show_adminbar1', function(){
80
- jQuery('.ct-depends-of-show-adminbar').each(function(){
81
- jQuery(this).removeAttr('disabled');
82
- });
83
- });
84
- jQuery('#ct_advsettings_hide').on('click', '#cleantalk_show_adminbar0', function(){
85
- jQuery('.ct-depends-of-show-adminbar').each(function(){
86
- jQuery(this).attr('disabled', 'disabled');
87
- });
88
- });
89
- });
 
 
 
1
  jQuery(document).ready(function(){
2
  var d = new Date();
3
+ jQuery('#ct_admin_timezone').val(d.getTimezoneOffset()/60*(-1));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
+ // GDPR modal window
6
+ jQuery('#apbct_gdpr_open_modal').on('click', function(){
7
+ jQuery('#gdpr_dialog').dialog({
8
+ modal:true,
9
+ show: true,
10
+ position: { my: "center", at: "center", of: window },
11
+ width: +(jQuery('#wpbody').width() / 100 * 70), // 70% of #wpbody
12
+ height: 'auto',
13
+ title: 'GDPR compliance',
14
+ draggable: false,
15
+ resizable: false,
16
+ closeText: "Close",
17
+ });
18
  });
19
 
20
+ });
21
+
22
+ function apbct_show_hide_elem(elem){
23
+ elem = jQuery(elem);
24
+ var label = elem.next('label') || elem.prev('label') || null;
25
+ if(elem.is(":visible")){
26
+ elem.hide();
27
+ if(label) label.hide();
28
+ }else{
29
+ elem.show();
30
+ if(label) label.show();
31
+ }
32
+ }
33
+
34
+ // Settings dependences
35
+ function apbctSettingsDependencies(settingsIDs){
36
+ console.log(settingsIDs);
37
+ if(typeof settingsIDs === 'string'){
38
+ tmp = [];
39
+ tmp.push(settingsIDs);
40
+ settingsIDs = tmp;
41
+ }
42
+ console.log(settingsIDs);
43
+ settingsIDs.forEach(function(settingID, i, arr){
44
+ console.log(settingID);
45
+ var elem = document.getElementById('apbct_setting_'+settingID) || null;
46
+ console.log(elem);
47
+ if(elem){
48
+ apbctSwitchDisabledAttr(elem);
49
  }else{
50
+ apbctSwitchDisabledAttr(document.getElementById('apbct_setting_'+settingID+'_yes'));
51
+ apbctSwitchDisabledAttr(document.getElementById('apbct_setting_'+settingID+'_no'));
52
  }
53
  });
54
+ }
55
+
56
+ function apbctSwitchDisabledAttr(elem){
57
+ if(elem.getAttribute('disabled') === null)
58
+ elem.setAttribute('disabled', 'disabled');
59
+ else
60
+ elem.removeAttribute('disabled');
61
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/cleantalk-admin.js CHANGED
@@ -6,28 +6,4 @@ jQuery(document).ready(function(){
6
  document.cookie = "apbct_update_banner_closed=1; path=/; expires=" + ct_date.toUTCString();
7
  });
8
 
9
- // GDPR modal window
10
- jQuery('#apbct_gdpr_open_modal').on('click', function(){
11
- jQuery('#gdpr_dialog').dialog({
12
- modal:true,
13
- show: true,
14
- position: { my: "center", at: "center", of: window },
15
- width: +(jQuery('#wpbody').width() / 100 * 70), // 70% of #wpbody
16
- height: 'auto',
17
- title: 'GDPR compliance',
18
- draggable: false,
19
- resizable: false,
20
- closeText: "Close",
21
- });
22
- });
23
-
24
- });
25
-
26
- // Settings dependences
27
- function spbcSettingsDependencies(spbcSettingSwitchId){
28
- var spbcSettingToSwitch = document.getElementById(spbcSettingSwitchId);
29
- if(spbcSettingToSwitch.getAttribute('disabled') === null)
30
- spbcSettingToSwitch.setAttribute('disabled', 'disabled');
31
- else
32
- spbcSettingToSwitch.removeAttribute('disabled');
33
- }
6
  document.cookie = "apbct_update_banner_closed=1; path=/; expires=" + ct_date.toUTCString();
7
  });
8
 
9
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/CleantalkCron.php CHANGED
@@ -55,6 +55,7 @@ class CleantalkCron
55
  static public function removeTask($task)
56
  {
57
  $tasks = get_option(self::CRON_OPTION_NAME);
 
58
  $tasks = empty($tasks) ? array() : $tasks;
59
 
60
  if(!isset($tasks[$task]))
55
  static public function removeTask($task)
56
  {
57
  $tasks = get_option(self::CRON_OPTION_NAME);
58
+
59
  $tasks = empty($tasks) ? array() : $tasks;
60
 
61
  if(!isset($tasks[$task]))
lib/CleantalkHelper.php CHANGED
@@ -166,9 +166,10 @@ class CleantalkHelper
166
  return false; // Unknown
167
  }
168
 
169
- /*
170
  * Wrapper for sfw_logs API method
171
- *
 
172
  * returns mixed STRING || array('error' => true, 'error_string' => STRING)
173
  */
174
  static public function api_method__sfw_logs($api_key, $data, $do_check = true){
@@ -228,7 +229,7 @@ class CleantalkHelper
228
  );
229
 
230
  $result = self::api_send_request($request);
231
- // $result = $do_check ? self::api_check_response($result, 'get_api_key') : $result;
232
 
233
  return $result;
234
  }
@@ -558,12 +559,106 @@ class CleantalkHelper
558
  $apbct->save('data');
559
  }
560
 
561
- //* Write $message to the plugin's debug option
562
- static public function ct_log($message = 'empty', $func = null, $params = array())
 
 
 
 
 
 
 
 
 
 
 
 
563
  {
564
- global $ct_data;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
565
 
566
- $ct_data = ct_get_data();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
567
 
568
  $function = $func ? $func : '';
569
  $cron = in_array('cron', $params) ? true : false;
@@ -573,12 +668,12 @@ class CleantalkHelper
573
  if(is_array($message) or is_object($message))
574
  $message = print_r($message, true);
575
 
576
- if($message) $ct_data['debug'][date("H:i:s", microtime(true))."_ACTION_".strval(current_action())."_FUNCTION_".strval($func)] = $message;
577
- if($cron) $ct_data['debug'][date("H:i:s", microtime(true))."_ACTION_".strval(current_action())."_FUNCTION_".strval($func).'_cron'] = get_option('cleantalk_cron');
578
- if($data) $ct_data['debug'][date("H:i:s", microtime(true))."_ACTION_".strval(current_action())."_FUNCTION_".strval($func).'_data'] = get_option('cleantalk_data');
579
- if($settings) $ct_data['debug'][date("H:i:s", microtime(true))."_ACTION_".strval(current_action())."_FUNCTION_".strval($func).'_settings'] = get_option('cleantalk_settings');
580
 
581
- update_option('cleantalk_data', $ct_data);
582
  }
583
 
584
  static public function is_json($string)
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){
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
  }
559
  $apbct->save('data');
560
  }
561
 
562
+ /**
563
+ * Function sends raw http request
564
+ *
565
+ * May use 4 presets(combining possible):
566
+ * get_code - getting only HTTP response code
567
+ * dont_wait_for_answer - async requests
568
+ * get - GET-request
569
+ * ssl - use SSL
570
+ *
571
+ * @param string result
572
+ * @param string request_method
573
+ * @return mixed (array || array('error' => true))
574
+ */
575
+ static public function http__request($url, $data = array(), $presets = null, $opts = array())
576
  {
577
+ if(function_exists('curl_init')){
578
+
579
+ $ch = curl_init();
580
+
581
+ // Obligatory options
582
+ $opts = array(
583
+ CURLOPT_URL => $url,
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,
591
+ CURLOPT_SSL_VERIFYHOST => 0,
592
+ CURLOPT_HTTPHEADER => array('Expect:'), // Fix for large data and old servers http://php.net/manual/ru/function.curl-setopt.php#82418
593
+ );
594
+
595
+ // Use presets
596
+ $presets = is_array($presets) ? $presets : array($presets);
597
+ foreach($presets as $preset){
598
+
599
+ switch($preset){
600
+
601
+ // Get headers only
602
+ case 'get_code':
603
+ $opts[CURLOPT_HEADER] = true;
604
+ $opts[CURLOPT_NOBODY] = true;
605
+ break;
606
+
607
+ // Make a request, don't wait for an answer
608
+ case 'dont_wait_for_answer':
609
+ $opts[CURLOPT_CONNECTTIMEOUT_MS] = 1000;
610
+ $opts[CURLOPT_TIMEOUT_MS] = 1;
611
+ break;
612
+
613
+ case 'get':
614
+ $opts[CURLOPT_URL] .= '?'.str_replace("&amp;", "&", http_build_query($data));
615
+ $opts[CURLOPT_POST] = false;
616
+ $opts[CURLOPT_POSTFIELDS] = null;
617
+ break;
618
+
619
+ case 'ssl':
620
+ $opts[CURLOPT_SSL_VERIFYPEER] = true;
621
+ $opts[CURLOPT_SSL_VERIFYHOST] = 2;
622
+ $opts[CURLOPT_CAINFO] = APBCT_CASERT_PATH;
623
+ break;
624
+
625
+ default:
626
+
627
+ break;
628
+ }
629
 
630
+ } unset($preset);
631
+
632
+ curl_setopt_array($ch, $opts);
633
+ $result = @curl_exec($ch);
634
+
635
+ if(in_array('dont_wait_for_answer', $presets)) return true;
636
+
637
+ if($result){
638
+ $result = explode(PHP_EOL, $result);
639
+ if(in_array('get_code', $presets)) $result = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
640
+ curl_close($ch);
641
+ return $result;
642
+ }else
643
+ $error = array('error' => true, 'error_string' => curl_error($ch));
644
+ }else
645
+ $error = array('error' => true, 'error_string' => 'CURL_NOT_INSTALLED');
646
+
647
+ /** Fix for get_code preset */
648
+ if($presets && ($presets == 'get_code' || (is_array($presets) && in_array($presets, 'get_code') ) )
649
+ && (isset($error) && $error['error_string'] == 'CURL_NOT_INSTALLED')
650
+ ){
651
+ $headers = get_headers($url);
652
+ $out = (int)preg_replace('/.*(\d{3}).*/', '$1', $headers[0]);
653
+ }
654
+
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;
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)
lib/CleantalkState.php ADDED
@@ -0,0 +1,336 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ *
5
+ * CleanTalk Antispam State class
6
+ *
7
+ * @package Antiospam Plugin by CleanTalk
8
+ * @subpackage State
9
+ * @Version 1.0
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
+ *
14
+ */
15
+
16
+ class CleantalkState
17
+ {
18
+ public $option_prefix = '';
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 */
28
+ 'registrations_test' => 1,
29
+ 'comments_test' => 1,
30
+ 'contact_forms_test' => 1,
31
+ 'general_contact_forms_test' => 1, // Antispam test for unsupported and untested contact forms
32
+ 'wc_checkout_test' => 0, //WooCommerce checkout default test => OFF
33
+ 'check_external' => 0,
34
+ 'check_internal' => 0,
35
+
36
+ /* Comments and messages */
37
+ 'bp_private_messages' => 1, //buddyPress private messages test => ON
38
+ 'check_comments_number' => 1,
39
+ 'remove_old_spam' => 0,
40
+ 'remove_comments_links' => 0, //Removes links from approved comments
41
+ 'show_check_links' => 1, //Shows check link to Cleantalk's DB. And allowing to control comments form public page.
42
+
43
+ // Data processing
44
+ 'protect_logged_in' => 1, // Do anit-spam tests to for logged in users.
45
+ 'use_ajax' => 1,
46
+ 'general_postdata_test' => 0, //CAPD
47
+ 'set_cookies'=> 1, // Disable cookies generatation to be compatible with Varnish.
48
+ 'ssl_on' => 0, // Secure connection to servers
49
+
50
+ // Administrator Panel
51
+ 'show_adminbar' => 1, // Show the admin bar.
52
+ 'all_time_counter' => 0,
53
+ 'daily_counter' => 0,
54
+
55
+ //Others
56
+ 'spam_store_days' => '15', // Days before delete comments from folder Spam
57
+ 'relevance_test' => 0, // Test comment for relevance
58
+ 'notice_api_errors' => 0, // Send API error notices to WP admin
59
+ 'user_token' => '', //user token for auto login into spam statistics
60
+ 'collect_details' => 0, // Collect details about browser of the visitor.
61
+ 'send_connection_reports' => 0, //Send connection reports to Cleantalk servers
62
+ 'show_link' => 0,
63
+ 'async_js' => 0,
64
+
65
+ // GDPR
66
+ 'gdpr_forms_id' => '',
67
+ 'gdpr_text' => '',
68
+ );
69
+
70
+ public $settings_fields_description = array();
71
+
72
+ public $settings_groups_description = array();
73
+
74
+ public $def_data = array(
75
+
76
+ // Plugin data
77
+ 'start_version' => APBCT_VERSION,
78
+ 'plugin_version' => '1.0.0',
79
+ 'user_token' => '', // User token
80
+ 'js_keys' => array(), // Keys to do JavaScript antispam test
81
+ 'js_keys_store_days' => 14, // JavaScript keys store days - 8 days now
82
+ 'js_key_lifetime' => 86400, // JavaScript key life time in seconds - 1 day now
83
+ 'last_remote_call' => 0, //Timestam of last remote call
84
+
85
+ // Account data
86
+ 'service_id' => 0,
87
+ 'moderate' => 0,
88
+ 'moderate_ip' => 0,
89
+ 'ip_license' => 0,
90
+ 'spam_count' => 0,
91
+ 'auto_update' => 0,
92
+ 'user_token' => '',
93
+ 'license_trial' => 0,
94
+
95
+ // Notices
96
+ 'notice_show' => 0,
97
+ 'notice_trial' => 0,
98
+ 'notice_renew' => 0,
99
+ 'notice_review' => 0,
100
+ 'notice_auto_update' => 0,
101
+
102
+ 'array_accepted' => array(),
103
+ 'array_blocked' => array(),
104
+ 'current_hour' => '',
105
+ 'sfw_counter' => array(
106
+ 'all' => 0,
107
+ 'blocked' => 0,
108
+ ),
109
+ 'all_time_counter' => array(
110
+ 'accepted' => 0,
111
+ 'blocked' => 0,
112
+ ),
113
+ 'user_counter' => array(
114
+ 'accepted' => 0,
115
+ 'blocked' => 0,
116
+ // 'since' => date('d M'),
117
+ ),
118
+ 'connection_reports' => array(
119
+ 'success' => 0,
120
+ 'negative' => 0,
121
+ 'negative_report' => array(),
122
+ // 'since' => date('d M'),
123
+ ),
124
+
125
+ // A-B tests
126
+ 'ab_test' => array(
127
+ 'sfw_enabled' => false,
128
+ ),
129
+
130
+ // Misc
131
+ 'feedback_request' => '',
132
+ );
133
+
134
+ public $def_network_settings = array(
135
+ 'allow_custom_key' => 0,
136
+ 'allow_cleantalk_cp' => 0,
137
+ 'key_is_ok' => 0,
138
+ 'spbc_key' => '',
139
+ 'user_token' => '',
140
+ 'service_id' => '',
141
+ );
142
+
143
+ public function __construct($option_prefix, $options = array('settings'), $wpms = false)
144
+ {
145
+ $this->option_prefix = $option_prefix;
146
+
147
+ if($wpms){
148
+ $option = get_site_option($this->option_prefix.'_network_settings');
149
+ $option = is_array($option) ? $option : $this->def_network_settings;
150
+ $this->network_settings = new ArrayObject($option);
151
+ }
152
+
153
+ foreach($options as $option_name){
154
+
155
+ $option = get_option($this->option_prefix.'_'.$option_name);
156
+
157
+ // Setting default options
158
+ if($this->option_prefix.'_'.$option_name === 'cleantalk_settings'){
159
+ $option = is_array($option) ? array_merge($this->def_settings, $option) : $this->def_settings;
160
+ }
161
+
162
+ // Setting default data
163
+ if($this->option_prefix.'_'.$option_name === 'cleantalk_data'){
164
+ $option = is_array($option) ? array_merge($this->def_data, $option) : $this->def_data;
165
+ }
166
+
167
+ // Setting default errors
168
+ if($this->option_prefix.'_'.$option_name === 'cleantalk_errors'){
169
+ $option = $option ? $option : array();
170
+ }
171
+
172
+ $this->$option_name = is_array($option) ? new ArrayObject($option) : $option;
173
+ }
174
+ }
175
+
176
+ private function getOption($option_name)
177
+ {
178
+ $option = get_option('cleantalk_'.$option_name, null);
179
+
180
+ if(gettype($option) === 'array')
181
+ $this->$option_name = new ArrayObject($option);
182
+ else
183
+ $this->$option_name = $option;
184
+ }
185
+
186
+ public function save($option_name, $use_perfix = true, $autoload = true)
187
+ {
188
+ $option_name_to_save = $use_perfix ? $this->option_prefix.'_'.$option_name : $option_name;
189
+ $arr = array();
190
+ foreach($this->$option_name as $key => $value){
191
+ $arr[$key] = $value;
192
+ }
193
+ update_option($option_name_to_save, $arr, $autoload);
194
+ }
195
+
196
+ public function saveSettings()
197
+ {
198
+ update_option($this->option_prefix.'_settins', (array)$this->settings);
199
+ }
200
+
201
+ public function saveData()
202
+ {
203
+ update_option($this->option_prefix.'_data', (array)$this->data);
204
+ }
205
+
206
+ public function saveErrors()
207
+ {
208
+ update_option($this->option_prefix.'_errors', (array)$this->errors);
209
+ }
210
+
211
+ public function saveNetworkSettings()
212
+ {
213
+ update_site_option($this->option_prefix.'_network_settings', $this->network_settings);
214
+ }
215
+
216
+ public function deleteOption($option_name, $use_prefix = false)
217
+ {
218
+ if($this->__isset($option_name)){
219
+ $this->__unset($option_name);
220
+ delete_option( ($use_prefix ? $this->option_prefix.'_' : '') . $option_name);
221
+ }
222
+ }
223
+
224
+ /**
225
+ * Prepares an adds an error to the plugin's data
226
+ *
227
+ * @param string type
228
+ * @param mixed array || string
229
+ * @returns null
230
+ */
231
+ public function error_add($type, $error, $major_type = null, $set_time = true)
232
+ {
233
+ $error = is_array($error)
234
+ ? $error['error_string']
235
+ : $error;
236
+
237
+ $error = array(
238
+ 'error_string' => $error,
239
+ 'error_time' => $set_time ? current_time('timestamp') : null,
240
+ );
241
+
242
+ if(!empty($major_type)){
243
+ $this->errors[$major_type][$type] = $error;
244
+ }else{
245
+ $this->errors[$type] = $error;
246
+ }
247
+
248
+ $this->saveErrors();
249
+ }
250
+
251
+ /**
252
+ * Deletes an error from the plugin's data
253
+ *
254
+ * @param mixed (array of strings || string 'elem1 elem2...' || string 'elem') type
255
+ * @param delay saving
256
+ * @returns null
257
+ */
258
+ public function error_delete($type, $save_flag = false, $major_type = null)
259
+ {
260
+ if(is_string($type))
261
+ $type = explode(' ', $type);
262
+
263
+ foreach($type as $val){
264
+ if($major_type){
265
+ if(isset($this->errors[$major_type][$val]))
266
+ unset($this->errors[$major_type][$val]);
267
+ }else{
268
+ if(isset($this->errors[$val]))
269
+ unset($this->errors[$val]);
270
+ }
271
+ }
272
+
273
+ // Save if flag is set and there are changes
274
+ if($save_flag)
275
+ $this->saveErrors();
276
+ }
277
+
278
+ /**
279
+ * Deletes all errors from the plugin's data
280
+ *
281
+ * @param delay saving
282
+ * @returns null
283
+ */
284
+ public function error_delete_all($save_flag = false)
285
+ {
286
+ $this->errors = array();
287
+ if($save_flag)
288
+ $this->saveErrors();
289
+ }
290
+
291
+ public function __set($name, $value)
292
+ {
293
+ $this->storage[$name] = $value;
294
+ if(isset($this->storage['data']) && array_key_exists($name, $this->storage['data'])){
295
+ $this->storage['data'][$name] = $value;
296
+ }
297
+ }
298
+
299
+ public function __get($name)
300
+ {
301
+ if (array_key_exists($name, $this->storage)){
302
+ return $this->storage[$name];
303
+ }elseif(array_key_exists($name, $this->storage['data'])){
304
+ $this->$name = $this->storage['data'][$name];
305
+ return $this->storage['data'][$name];
306
+ }elseif($name == 'api_key'){
307
+ $this->$name = $this->storage['settings']['apikey'];
308
+ return $this->storage['settings']['apikey'];
309
+ }else{
310
+ $this->getOption($name);
311
+ return $this->storage[$name];
312
+ }
313
+
314
+ // return !empty($this->storage[$name]) ? $this->storage[$name] : null;
315
+ }
316
+
317
+ public function __isset($name)
318
+ {
319
+ return isset($this->storage[$name]);
320
+ }
321
+
322
+ public function __unset($name)
323
+ {
324
+ unset($this->storage[$name]);
325
+ }
326
+
327
+ public function __call($name, $arguments)
328
+ {
329
+ error_log ("Calling method '$name' with arguments: " . implode(', ', $arguments). "\n");
330
+ }
331
+
332
+ public static function __callStatic($name, $arguments)
333
+ {
334
+ error_log("Calling static method '$name' with arguments: " . implode(', ', $arguments). "\n");
335
+ }
336
+ }
readme.txt CHANGED
@@ -516,6 +516,15 @@ Yes, it is. Please read this article,
516
  10. Website's options.
517
 
518
  == Changelog ==
 
 
 
 
 
 
 
 
 
519
  = 5.102 August 29 2018 =
520
  * Fix: Users and comments check.
521
  * Fix: Update from 5.70 or previous versions.
@@ -1633,6 +1642,15 @@ Yes, it is. Please read this article,
1633
  * First version
1634
 
1635
  == Upgrade Notice ==
 
 
 
 
 
 
 
 
 
1636
  = 5.102 August 29 2018 =
1637
  * Fix: Users and comments check.
1638
  * Fix: Update from 5.70 or previous versions.
516
  10. Website's options.
517
 
518
  == Changelog ==
519
+ = 5.103 September 13 2018 =
520
+ * Fix: Gravity Forms response message.
521
+ * Fix: SpamFireWall redirect to 404 page.
522
+ * Major anti-spam plugin improvement.
523
+ * Recombined setting page.
524
+ * Added error notification.
525
+ * Mod: S2 Members integration.
526
+ * Mod: Improved remote calls.
527
+
528
  = 5.102 August 29 2018 =
529
  * Fix: Users and comments check.
530
  * Fix: Update from 5.70 or previous versions.
1642
  * First version
1643
 
1644
  == Upgrade Notice ==
1645
+ = 5.103 September 13 2018 =
1646
+ * Fix: Gravity Forms response message.
1647
+ * Fix: SpamFireWall redirect to 404 page.
1648
+ * Major anti-spam plugin improvement.
1649
+ * Recombined setting page.
1650
+ * Added error notification.
1651
+ * Mod: S2 Members integration.
1652
+ * Mod: Improved remote calls.
1653
+
1654
  = 5.102 August 29 2018 =
1655
  * Fix: Users and comments check.
1656
  * Fix: Update from 5.70 or previous versions.