Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.159

Version Description

Jun 10 2021 = * New. Admin Bar. Common admin bar implemented. * New: email check before post. * New: New admin bar style. * New. SFW. Updating integrity control implemented. * New. Custom Ajax. Email checking before post. * New. Custom Ajax. Getting JS key. * New. Custom Ajax. Alternative cookies. * Upd. Integrations. Support multiple non-ajax hooks. * Upd. Cron. Cron class and cron usage updated. * Upd. Pixel. Pixel setting is "auto" for the new installations. * Upd. Users checker. Users with completed WC orders no checked. * Upd. WPMS settings. * Mod. limiting the size of an array top5_spam_ip to five elements in widget. * Mod. update data_pixel title. * Mod. Update datause_static_js_key title. * Mod. add 'relative' parameter in admin_url() for getting ajaxurl. * Mod. update field name honeypot_field, reverse logic * Mod. changed website field from comments form: type text, display none. * Fix. resolve conflict with wiloke theme and unknown plugin, that removes standard authorization cookies. * Fix. moved the wiloke_theme options_ajax_save_skip check to apbct_is_skip_request function. * Fix. added a theme check along with a hook wiloke_themeoptions_ajax_save_skip. * Fix. Integration. Essentials addons for elementor integration fixed. * Fix. AC/AF. Clearing AC table via cron fixed. * Fix. SFW. Obtaining the count of the networks was fixed. * Fix. Cron. Last cron start fixed. * Fix. cookies for login page. * Fix. Firewall. Update. Filtering bad data. * Fix. Custom Ajax. Localized login scripts. * Fix. API. Cleantalk\ApbctWP\API fixed to work on SHORTINIT mode. * Fix. Custom Ajax. Getting JS key - removed WP ajax hooks. * Fix. GetFieldsAny. Bypassing collecting email and names logic fixed. * Fix. New admin bar style. Sorting plugins by Alphabet. * Fix. ctget_admin_email return network email if set. * Fix. Fixed the name of the key containing the file address to check the number of records. * Fix. Comments checker. Non-checkable users tab removed. * Fix. Visible fields. Formidable visible fields collecting fixed. * Fix. Get fields any fixed. * Fix. empty key error for hosting. * Fix. WPMS. Api key saving fixed. * Fix. WPMS. Network settings saving fixed. * Fix. WPMS. Plugin name setting field is not required now. * Fix. Alt sessions js fixed.

Download this release

Release Info

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

Code changes from version 5.158.1 to 5.159

Files changed (36) hide show
  1. cleantalk.php +137 -70
  2. css/cleantalk-admin.min.css +1 -1
  3. css/cleantalk-dashboard-widget.min.css +1 -1
  4. inc/cleantalk-admin.php +382 -127
  5. inc/cleantalk-ajax-handlers.php +47 -0
  6. inc/cleantalk-ajax.php +1 -0
  7. inc/cleantalk-autoloader.php +21 -21
  8. inc/cleantalk-common.php +54 -265
  9. inc/cleantalk-pluggable.php +21 -1
  10. inc/cleantalk-public.php +15 -9
  11. inc/cleantalk-settings.php +18 -25
  12. inc/cleantalk-updater.php +7 -3
  13. js/apbct-public.min.js +1 -1
  14. js/apbct-public.min.js.map +1 -1
  15. lib/Cleantalk/Antispam/CleantalkRequest.php +2 -2
  16. lib/Cleantalk/Antispam/Integrations.php +119 -112
  17. lib/Cleantalk/Antispam/Integrations/FluentForm.php +30 -30
  18. lib/Cleantalk/ApbctWP/API.php +5 -2
  19. lib/Cleantalk/ApbctWP/Ajax.php +154 -0
  20. lib/Cleantalk/ApbctWP/CleantalkSettingsTemplates.php +0 -4
  21. lib/Cleantalk/ApbctWP/Cron.php +46 -282
  22. lib/Cleantalk/ApbctWP/FindSpam/ListTable/Users.php +37 -9
  23. lib/Cleantalk/ApbctWP/FindSpam/ListTable/UsersScan.php +15 -9
  24. lib/Cleantalk/ApbctWP/FindSpam/Page.php +1 -1
  25. lib/Cleantalk/ApbctWP/FindSpam/UsersChecker.php +12 -0
  26. lib/Cleantalk/ApbctWP/Firewall/AntiCrawler.php +25 -4
  27. lib/Cleantalk/ApbctWP/Firewall/AntiFlood.php +2 -2
  28. lib/Cleantalk/ApbctWP/Firewall/SFW.php +13 -8
  29. lib/Cleantalk/ApbctWP/GetFieldsAny.php +397 -0
  30. lib/Cleantalk/ApbctWP/RemoteCalls.php +2 -1
  31. lib/Cleantalk/ApbctWP/State.php +61 -7
  32. lib/Cleantalk/ApbctWP/Variables/AltSessions.php +1 -6
  33. lib/Cleantalk/Common/API.php +33 -6
  34. lib/Cleantalk/Common/Compatibility.php +93 -0
  35. lib/Cleantalk/Common/Cron.php +269 -0
  36. readme.txt +45 -1
cleantalk.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Anti-Spam by CleanTalk
4
  Plugin URI: https://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.158.1
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
@@ -56,10 +56,6 @@ define('APBCT_DEBUG', 'cleantalk_debug'); //Option name wi
56
  // Multisite
57
  define('APBCT_WPMS', (is_multisite() ? true : false)); // WMPS is enabled
58
 
59
- // Sessions
60
- define('APBCT_SEESION__LIVE_TIME', 86400);
61
- define('APBCT_SEESION__CHANCE_TO_CLEAN', 100);
62
-
63
  // Different params
64
  define('APBCT_REMOTE_CALL_SLEEP', 5); // Minimum time between remote call
65
 
@@ -113,17 +109,7 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
113
  if($apbct->settings['comments__disable_comments__all'] || $apbct->settings['comments__disable_comments__posts'] || $apbct->settings['comments__disable_comments__pages'] || $apbct->settings['comments__disable_comments__media']){
114
  \Cleantalk\Antispam\DisableComments::getInstance();
115
  }
116
-
117
- // Passing JS key to frontend
118
- add_action('wp_ajax_apbct_js_keys__get', 'apbct_js_keys__get__ajax');
119
- add_action('wp_ajax_nopriv_apbct_js_keys__get', 'apbct_js_keys__get__ajax');
120
-
121
- // Using alternative sessions with ajax
122
- if( $apbct->settings['data__set_cookies'] == 2 && $apbct->settings['data__set_cookies__alt_sessions_type'] == 2 ){
123
- add_action( 'wp_ajax_nopriv_apbct_alt_session__get__AJAX', array( \Cleantalk\ApbctWP\Variables\AltSessions::class, 'get_fromRemote' ) );
124
- add_action( 'wp_ajax_nopriv_apbct_alt_session__save__AJAX', array( \Cleantalk\ApbctWP\Variables\AltSessions::class, 'set_fromRemote' ) );
125
- }
126
-
127
  add_action( 'rest_api_init', 'apbct_register_my_rest_routes' );
128
  function apbct_register_my_rest_routes() {
129
  $controller = new RestController();
@@ -134,37 +120,38 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
134
  global $wpdb;
135
  $apbct->db_prefix = !APBCT_WPMS || $apbct->allow_custom_key || $apbct->white_label ? $wpdb->prefix : $wpdb->base_prefix;
136
  $apbct->db_prefix = !$apbct->white_label && defined('CLEANTALK_ACCESS_KEY') ? $wpdb->base_prefix : $wpdb->prefix;
137
- // Database constants
138
- define('APBCT_TBL_FIREWALL_DATA', $apbct->db_prefix . 'cleantalk_sfw'); // Table with firewall data.
139
- define('APBCT_TBL_FIREWALL_LOG', $apbct->db_prefix . 'cleantalk_sfw_logs'); // Table with firewall logs.
140
- define('APBCT_TBL_AC_LOG', $apbct->db_prefix . 'cleantalk_ac_log'); // Table with firewall logs.
141
- define('APBCT_TBL_AC_UA_BL', $apbct->db_prefix . 'cleantalk_ua_bl'); // Table with User-Agents blacklist.
142
- define('APBCT_TBL_SESSIONS', $apbct->db_prefix . 'cleantalk_sessions'); // Table with session data.
143
- define('APBCT_SPAMSCAN_LOGS', $apbct->db_prefix . 'cleantalk_spamscan_logs'); // Table with session data.
144
- define('APBCT_SELECT_LIMIT', 5000); // Select limit for logs.
145
- define('APBCT_WRITE_LIMIT', 5000); // Write limit for firewall data.
146
-
147
  /** @todo HARDCODE FIX */
148
  if($apbct->plugin_version === '1.0.0')
149
  $apbct->plugin_version = '5.100';
150
 
151
  // Do update actions if version is changed
152
  apbct_update_actions();
153
-
154
  // Self cron
155
- $tasks_to_run = Cron::checkTasks(); // Check for current tasks. Drop tasks inner counters.
 
156
  if(
157
- ! empty( $tasks_to_run ) && // There is tasks to run
158
  ! RemoteCalls::check() && // Do not doing CRON in remote call action
159
  (
160
  ! defined( 'DOING_CRON' ) ||
161
  ( defined( 'DOING_CRON' ) && DOING_CRON !== true )
162
  )
163
  ){
164
- $ct_cron = new Cron();
165
- $ct_cron->setTasksToRun( $tasks_to_run );
166
- $ct_cron->runTasks();
167
- unset( $ct_cron );
 
 
 
 
 
 
168
  }
169
 
170
  //Delete cookie for admin trial notice
@@ -218,7 +205,7 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
218
  'Wpdiscuz' => array( 'hook' => array( 'wpdAddComment', 'wpdAddInlineComment' ), 'setting' => 'forms__comments_test', 'ajax' => true ),
219
  'Forminator' => array( 'hook' => 'forminator_submit_form_custom-forms', 'setting' => 'forms__contact_forms_test', 'ajax' => true ),
220
  'HappyForm' => array( 'hook' => 'happyforms_validate_submission', 'setting' => 'forms__contact_forms_test', 'ajax' => false ),
221
- 'EaelLoginRegister' => array( 'hook' => 'eael/login-register/before-register', 'setting' => 'forms__registrations_test', 'ajax' => false ),
222
  );
223
  new \Cleantalk\Antispam\Integrations( $apbct_active_integrations, (array) $apbct->settings );
224
 
@@ -570,7 +557,8 @@ function apbct_activation( $network = false ) {
570
  $apbct->save('stats');
571
 
572
  $sqls = Schema::getSchema();
573
-
 
574
  if($network && !defined('CLEANTALK_ACCESS_KEY')){
575
  $initial_blog = get_current_blog_id();
576
  $blogs = array_keys($wpdb->get_results('SELECT blog_id FROM '. $wpdb->blogs, OBJECT_K));
@@ -578,27 +566,28 @@ function apbct_activation( $network = false ) {
578
  switch_to_blog($blog);
579
  apbct_activation__create_tables($sqls);
580
  // Cron tasks
581
- Cron::addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // Checks account status
582
- Cron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
583
- Cron::addTask('send_feedback', 'ct_send_feedback', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
584
- Cron::addTask('sfw_update', 'apbct_sfw_update__init', 86400 ); // SFW update
585
- Cron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time() + 1800); // SFW send logs
586
- Cron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
587
- Cron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
588
- Cron::addTask('antiflood__clear_table', 'apbct_antiflood__clear_table', 86400, time() + 300); // Clear Anti-Flood table
 
589
  }
590
  switch_to_blog($initial_blog);
591
  }else{
592
 
593
  // Cron tasks
594
- Cron::addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // Checks account status
595
- Cron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
596
- Cron::addTask('send_feedback', 'ct_send_feedback', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
597
- Cron::addTask('sfw_update', 'apbct_sfw_update__init', 86400 ); // SFW update
598
- Cron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time() + 1800); // SFW send logs
599
- Cron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
600
- Cron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
601
- Cron::addTask('antiflood__clear_table', 'apbct_antiflood__clear_table', 86400, time() + 300); // Clear Anti-Flood table
602
 
603
  apbct_activation__create_tables($sqls);
604
  ct_account_status_check(null, false);
@@ -642,15 +631,17 @@ function apbct_activation__new_blog($blog_id, $user_id, $domain, $path, $site_id
642
  switch_to_blog($blog_id);
643
 
644
  $sqls = Schema::getSchema();
645
-
 
 
646
  // Cron tasks
647
- Cron::addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // Checks account status
648
- Cron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
649
- Cron::addTask('send_feedback', 'ct_send_feedback', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
650
- Cron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time() + 1800); // SFW send logs
651
- Cron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
652
- Cron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
653
- Cron::addTask('antiflood__clear_table', 'apbct_antiflood__clear_table', 86400, time() + 300); // Clear Anti-Flood table
654
  apbct_activation__create_tables($sqls);
655
  apbct_sfw_update__init( 3 ); // Updating SFW
656
  ct_account_status_check(null, false);
@@ -867,7 +858,7 @@ function apbct_sfw_update__init( $delay = 0 ){
867
  }
868
 
869
  // Key is empty
870
- if( ! $apbct->settings['apikey'] ){
871
  return array( 'error' => 'SFW UPDATE INIT: KEY_EMPTY' );
872
  }
873
 
@@ -922,9 +913,14 @@ function apbct_sfw_update__init( $delay = 0 ){
922
  * @return array|bool|int|string[]
923
  * @throws Exception
924
  */
925
- function apbct_sfw_update__worker( $updating_id = null, $multifile_url = null, $url_count = null, $current_url = null, $useragent_url = null ){
926
-
927
- global $apbct;
 
 
 
 
 
928
 
929
  sleep(1);
930
 
@@ -991,13 +987,38 @@ function apbct_sfw_update__worker( $updating_id = null, $multifile_url = null, $
991
  }
992
 
993
  function apbct_sfw_update__get_multifiles( $api_key, $updating_id ){
994
-
 
 
995
  $result = SFW::update__get_multifile( $api_key );
996
 
997
  if( ! empty( $result['error'] ) ){
998
  return array( 'error' => 'GET MULTIFILE: ' . $result['error'] );
999
  }
1000
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1001
  $rc_result = Helper::http__request__rc_to_host(
1002
  'sfw_update__worker',
1003
  array(
@@ -1118,7 +1139,8 @@ function apbct_sfw_update__process_file( $multifile_url, $url_count, $current_ur
1118
  }
1119
 
1120
  function apbct_sfw_update__process_exclusions( $multifile_url, $updating_id ){
1121
-
 
1122
  $result = SFW::update__write_to_db__exclusions(
1123
  DB::getInstance(),
1124
  APBCT_TBL_FIREWALL_DATA . '_temp'
@@ -1131,6 +1153,14 @@ function apbct_sfw_update__process_exclusions( $multifile_url, $updating_id ){
1131
  if( ! is_int( $result ) ){
1132
  return array( 'error' => 'EXCLUSIONS: WRONG_RESPONSE update__write_to_db__exclusions' );
1133
  }
 
 
 
 
 
 
 
 
1134
 
1135
  $rc_result = Helper::http__request__rc_to_host(
1136
  'sfw_update__worker',
@@ -1179,7 +1209,34 @@ function apbct_sfw_update__end_of_update() {
1179
  $apbct->stats['sfw']['last_update_time'] = time();
1180
  $apbct->save( 'stats' );
1181
 
1182
- $apbct->data['last_firewall_updated'] = current_time('timestamp');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1183
  $apbct->save('data'); // Unused
1184
 
1185
  // Running sfw update once again in 12 min if entries is < 4000
@@ -1195,7 +1252,16 @@ function apbct_sfw_update__end_of_update() {
1195
  // Get update period for server
1196
  $update_period = \Cleantalk\Common\DNS::getServerTTL( 'spamfirewall-ttl.cleantalk.org' );
1197
  $update_period = (int)$update_period > 14400 ? (int) $update_period : 14400;
1198
- Cron::updateTask('sfw_update', 'apbct_sfw_update__init', $update_period );
 
 
 
 
 
 
 
 
 
1199
 
1200
  return true;
1201
 
@@ -1250,7 +1316,7 @@ function apbct_antiflood__clear_table(){
1250
 
1251
  global $apbct;
1252
 
1253
- if( $apbct->settings['sfw__anti_flood'] ){
1254
 
1255
  $anti_flood = new \Cleantalk\ApbctWP\Firewall\AntiFlood(
1256
  APBCT_TBL_FIREWALL_LOG,
@@ -1926,8 +1992,9 @@ function ct_account_status_check($api_key = null, $process_errors = true){
1926
  $apbct->data['user_token'] = isset($result['user_token']) ? (string)$result['user_token'] : '';
1927
  $apbct->data['license_trial'] = isset($result['license_trial']) ? (int)$result['license_trial'] : 0;
1928
  $apbct->data['account_name_ob'] = isset($result['account_name_ob']) ? (string)$result['account_name_ob'] : '';
1929
-
1930
- Cron::updateTask('check_account_status', 'ct_account_status_check', 86400);
 
1931
 
1932
  $apbct->error_delete('account_check', 'save');
1933
 
3
  Plugin Name: Anti-Spam by CleanTalk
4
  Plugin URI: https://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.159
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
56
  // Multisite
57
  define('APBCT_WPMS', (is_multisite() ? true : false)); // WMPS is enabled
58
 
 
 
 
 
59
  // Different params
60
  define('APBCT_REMOTE_CALL_SLEEP', 5); // Minimum time between remote call
61
 
109
  if($apbct->settings['comments__disable_comments__all'] || $apbct->settings['comments__disable_comments__posts'] || $apbct->settings['comments__disable_comments__pages'] || $apbct->settings['comments__disable_comments__media']){
110
  \Cleantalk\Antispam\DisableComments::getInstance();
111
  }
112
+
 
 
 
 
 
 
 
 
 
 
113
  add_action( 'rest_api_init', 'apbct_register_my_rest_routes' );
114
  function apbct_register_my_rest_routes() {
115
  $controller = new RestController();
120
  global $wpdb;
121
  $apbct->db_prefix = !APBCT_WPMS || $apbct->allow_custom_key || $apbct->white_label ? $wpdb->prefix : $wpdb->base_prefix;
122
  $apbct->db_prefix = !$apbct->white_label && defined('CLEANTALK_ACCESS_KEY') ? $wpdb->base_prefix : $wpdb->prefix;
123
+
124
+ // Set some defines
125
+ \Cleantalk\ApbctWP\State::setDefinitions();
126
+
 
 
 
 
 
 
127
  /** @todo HARDCODE FIX */
128
  if($apbct->plugin_version === '1.0.0')
129
  $apbct->plugin_version = '5.100';
130
 
131
  // Do update actions if version is changed
132
  apbct_update_actions();
133
+
134
  // Self cron
135
+ $ct_cron = new Cron();
136
+ $tasks_to_run = $ct_cron->checkTasks(); // Check for current tasks. Drop tasks inner counters.
137
  if(
138
+ $tasks_to_run && // There is tasks to run
139
  ! RemoteCalls::check() && // Do not doing CRON in remote call action
140
  (
141
  ! defined( 'DOING_CRON' ) ||
142
  ( defined( 'DOING_CRON' ) && DOING_CRON !== true )
143
  )
144
  ){
145
+ $cron_res = $ct_cron->runTasks( $tasks_to_run );
146
+ if( is_array( $cron_res ) ) {
147
+ foreach( $cron_res as $task => $res ) {
148
+ if( $res === true ) {
149
+ $apbct->error_delete( $task, 'save_data', 'cron' );
150
+ } else {
151
+ $apbct->error_add( $task, $res, 'cron' );
152
+ }
153
+ }
154
+ }
155
  }
156
 
157
  //Delete cookie for admin trial notice
205
  'Wpdiscuz' => array( 'hook' => array( 'wpdAddComment', 'wpdAddInlineComment' ), 'setting' => 'forms__comments_test', 'ajax' => true ),
206
  'Forminator' => array( 'hook' => 'forminator_submit_form_custom-forms', 'setting' => 'forms__contact_forms_test', 'ajax' => true ),
207
  'HappyForm' => array( 'hook' => 'happyforms_validate_submission', 'setting' => 'forms__contact_forms_test', 'ajax' => false ),
208
+ 'EaelLoginRegister' => array( 'hook' => array ('eael/login-register/before-register', 'wp_ajax_nopriv_eael/login-register/before-register' , 'wp_ajax_eael/login-register/before-register'), 'setting' => 'forms__registrations_test', 'ajax' => false ),
209
  );
210
  new \Cleantalk\Antispam\Integrations( $apbct_active_integrations, (array) $apbct->settings );
211
 
557
  $apbct->save('stats');
558
 
559
  $sqls = Schema::getSchema();
560
+ $ct_cron = new Cron();
561
+
562
  if($network && !defined('CLEANTALK_ACCESS_KEY')){
563
  $initial_blog = get_current_blog_id();
564
  $blogs = array_keys($wpdb->get_results('SELECT blog_id FROM '. $wpdb->blogs, OBJECT_K));
566
  switch_to_blog($blog);
567
  apbct_activation__create_tables($sqls);
568
  // Cron tasks
569
+
570
+ $ct_cron->addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // Checks account status
571
+ $ct_cron->addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
572
+ $ct_cron->addTask('send_feedback', 'ct_send_feedback', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
573
+ $ct_cron->addTask('sfw_update', 'apbct_sfw_update__init', 86400 ); // SFW update
574
+ $ct_cron->addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time() + 1800); // SFW send logs
575
+ $ct_cron->addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
576
+ $ct_cron->addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
577
+ $ct_cron->addTask('antiflood__clear_table', 'apbct_antiflood__clear_table', 86400, time() + 300); // Clear Anti-Flood table
578
  }
579
  switch_to_blog($initial_blog);
580
  }else{
581
 
582
  // Cron tasks
583
+ $ct_cron->addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // Checks account status
584
+ $ct_cron->addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
585
+ $ct_cron->addTask('send_feedback', 'ct_send_feedback', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
586
+ $ct_cron->addTask('sfw_update', 'apbct_sfw_update__init', 86400 ); // SFW update
587
+ $ct_cron->addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time() + 1800); // SFW send logs
588
+ $ct_cron->addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
589
+ $ct_cron->addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
590
+ $ct_cron->addTask('antiflood__clear_table', 'apbct_antiflood__clear_table', 86400, time() + 300); // Clear Anti-Flood table
591
 
592
  apbct_activation__create_tables($sqls);
593
  ct_account_status_check(null, false);
631
  switch_to_blog($blog_id);
632
 
633
  $sqls = Schema::getSchema();
634
+
635
+ $ct_cron = new Cron();
636
+
637
  // Cron tasks
638
+ $ct_cron->addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // Checks account status
639
+ $ct_cron->addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
640
+ $ct_cron->addTask('send_feedback', 'ct_send_feedback', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
641
+ $ct_cron->addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time() + 1800); // SFW send logs
642
+ $ct_cron->addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
643
+ $ct_cron->addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
644
+ $ct_cron->addTask('antiflood__clear_table', 'apbct_antiflood__clear_table', 86400, time() + 300); // Clear Anti-Flood table
645
  apbct_activation__create_tables($sqls);
646
  apbct_sfw_update__init( 3 ); // Updating SFW
647
  ct_account_status_check(null, false);
858
  }
859
 
860
  // Key is empty
861
+ if( ! $apbct->settings['apikey'] && !$apbct->ip_license){
862
  return array( 'error' => 'SFW UPDATE INIT: KEY_EMPTY' );
863
  }
864
 
913
  * @return array|bool|int|string[]
914
  * @throws Exception
915
  */
916
+ function apbct_sfw_update__worker(
917
+ $updating_id = null,
918
+ $multifile_url = null,
919
+ $url_count = null,
920
+ $current_url = null,
921
+ $useragent_url = null) {
922
+
923
+ global $apbct;
924
 
925
  sleep(1);
926
 
987
  }
988
 
989
  function apbct_sfw_update__get_multifiles( $api_key, $updating_id ){
990
+
991
+ global $apbct;
992
+
993
  $result = SFW::update__get_multifile( $api_key );
994
 
995
  if( ! empty( $result['error'] ) ){
996
  return array( 'error' => 'GET MULTIFILE: ' . $result['error'] );
997
  }
998
 
999
+ // Save expected_networks_count and expected_ua_count if exists
1000
+ $file_ck_url__data = Helper::http__get_data_from_remote_gz__and_parse_csv( $result['file_ck_url'] );
1001
+
1002
+ if( ! empty( $file_ck_url__data['error'] ) ){
1003
+ return array( 'error' => 'GET EXPECTED RECORDS COUNT DATA: ' . $result['error'] );
1004
+ }
1005
+
1006
+ $expected_networks_count = 0;
1007
+ $expected_ua_count = 0;
1008
+
1009
+ foreach( $file_ck_url__data as $value ) {
1010
+ if( trim( $value[0], '"' ) === 'networks_count' ){
1011
+ $expected_networks_count = $value[1];
1012
+ }
1013
+ if( trim( $value[0], '"' ) === 'ua_count' ) {
1014
+ $expected_ua_count = $value[1];
1015
+ }
1016
+ }
1017
+
1018
+ $apbct->fw_stats['expected_networks_count'] = $expected_networks_count;
1019
+ $apbct->fw_stats['expected_ua_count'] = $expected_ua_count;
1020
+ $apbct->save( 'fw_stats' );
1021
+
1022
  $rc_result = Helper::http__request__rc_to_host(
1023
  'sfw_update__worker',
1024
  array(
1139
  }
1140
 
1141
  function apbct_sfw_update__process_exclusions( $multifile_url, $updating_id ){
1142
+ global $apbct;
1143
+
1144
  $result = SFW::update__write_to_db__exclusions(
1145
  DB::getInstance(),
1146
  APBCT_TBL_FIREWALL_DATA . '_temp'
1153
  if( ! is_int( $result ) ){
1154
  return array( 'error' => 'EXCLUSIONS: WRONG_RESPONSE update__write_to_db__exclusions' );
1155
  }
1156
+
1157
+ /**
1158
+ * Update expected_networks_count
1159
+ */
1160
+ if( $result > 0 ) {
1161
+ $apbct->fw_stats['expected_networks_count'] += $result;
1162
+ $apbct->save( 'fw_stats' );
1163
+ }
1164
 
1165
  $rc_result = Helper::http__request__rc_to_host(
1166
  'sfw_update__worker',
1209
  $apbct->stats['sfw']['last_update_time'] = time();
1210
  $apbct->save( 'stats' );
1211
 
1212
+ /**
1213
+ * Checking the integrity of the sfw database update
1214
+ */
1215
+ global $ct_cron;
1216
+
1217
+ if( $apbct->stats['sfw']['entries'] != $apbct->fw_stats['expected_networks_count'] ) {
1218
+
1219
+ # call manually
1220
+ if( ! $ct_cron ){
1221
+ return array(
1222
+ 'error' => 'The discrepancy between the amount of data received for the update and in the final table: ' . APBCT_TBL_FIREWALL_DATA . '. RECEIVED: ' . $apbct->fw_stats['expected_networks_count'] . '. ADDED: ' . $apbct->stats['sfw']['entries']);
1223
+ }
1224
+
1225
+ #call cron
1226
+ if( $apbct->fw_stats['failed_update_attempt'] ) {
1227
+ return array(
1228
+ 'error' => 'The discrepancy between the amount of data received for the update and in the final table: ' . APBCT_TBL_FIREWALL_DATA . '. RECEIVED: ' . $apbct->fw_stats['expected_networks_count'] . '. ADDED: ' . $apbct->stats['sfw']['entries']);
1229
+ }
1230
+
1231
+ $apbct->fw_stats['failed_update_attempt'] = true;
1232
+ $apbct->save( 'fw_stats' );
1233
+
1234
+ $cron = new Cron();
1235
+ $cron->updateTask('sfw_update', 'apbct_sfw_update__init', 86400, time() + 180 );
1236
+ return false;
1237
+ }
1238
+
1239
+ $apbct->data['last_firewall_updated'] = current_time('timestamp');
1240
  $apbct->save('data'); // Unused
1241
 
1242
  // Running sfw update once again in 12 min if entries is < 4000
1252
  // Get update period for server
1253
  $update_period = \Cleantalk\Common\DNS::getServerTTL( 'spamfirewall-ttl.cleantalk.org' );
1254
  $update_period = (int)$update_period > 14400 ? (int) $update_period : 14400;
1255
+ $cron = new Cron();
1256
+ $cron->updateTask('sfw_update', 'apbct_sfw_update__init', $update_period );
1257
+
1258
+ /**
1259
+ * Update fw data if update completed
1260
+ */
1261
+ $apbct->fw_stats['failed_update_attempt'] = false;
1262
+ $apbct->fw_stats['expected_networks_count'] = false;
1263
+
1264
+ $apbct->save( 'fw_stats' );
1265
 
1266
  return true;
1267
 
1316
 
1317
  global $apbct;
1318
 
1319
+ if( $apbct->settings['sfw__anti_flood'] || $apbct->settings['sfw__anti_crawler'] ){
1320
 
1321
  $anti_flood = new \Cleantalk\ApbctWP\Firewall\AntiFlood(
1322
  APBCT_TBL_FIREWALL_LOG,
1992
  $apbct->data['user_token'] = isset($result['user_token']) ? (string)$result['user_token'] : '';
1993
  $apbct->data['license_trial'] = isset($result['license_trial']) ? (int)$result['license_trial'] : 0;
1994
  $apbct->data['account_name_ob'] = isset($result['account_name_ob']) ? (string)$result['account_name_ob'] : '';
1995
+
1996
+ $cron = new Cron();
1997
+ $cron->updateTask('check_account_status', 'ct_account_status_check', 86400);
1998
 
1999
  $apbct->error_delete('account_check', 'save');
2000
 
css/cleantalk-admin.min.css CHANGED
@@ -1 +1 @@
1
- :disabled{cursor:not-allowed!important}.apbct_color--gray{color:gray}.apbct_display--none{display:none}.ct_translate_links{color:rgba(150,150,20,1)}.ct_support_links{color:rgba(150,20,20,1)}.ct_faq_links{color:rgba(20,150,20,1)}.ct_setting_links{color:rgba(20,20,150,1)}.ct_translate_links:hover{color:rgba(210,210,20,1)!important}.ct_support_links:hover{color:rgba(250,20,20,1)!important}.ct_faq_links:hover{color:rgba(20,250,20,1)!important}.ct_setting_links:hover{color:rgba(20,20,250,1)!important}.ct_link_new_tab img{float:none!important;margin:0 2px;border:0}#negative_reports_table tr td{padding:7px 5px!important}#apbct_gdpr_open_modal:hover{cursor:pointer}
1
+ :disabled{cursor:not-allowed!important}.apbct_color--gray{color:gray}.apbct_display--none{display:none}.ct_translate_links{color:rgba(150,150,20,1)}.ct_support_links{color:rgba(150,20,20,1)}.ct_faq_links{color:rgba(20,150,20,1)}.ct_setting_links{color:rgba(20,20,150,1)}.ct_translate_links:hover{color:rgba(210,210,20,1)!important}.ct_support_links:hover{color:rgba(250,20,20,1)!important}.ct_faq_links:hover{color:rgba(20,250,20,1)!important}.ct_setting_links:hover{color:rgba(20,20,250,1)!important}.ct_link_new_tab img{float:none!important;margin:0 2px;border:0}#negative_reports_table tr td{padding:7px 5px!important}#apbct_gdpr_open_modal:hover{cursor:pointer}#wp-admin-bar-cleantalk_admin_bar__parent_node img.cleantalk_admin_bar__apbct_icon{width:18px;height:18px;margin-top:7px}#wp-admin-bar-cleantalk_admin_bar__parent_node div.cleantalk_admin_bar__sum_counter{color:#fff;background:#d63638;display:inline;text-align:center;padding:2px 5px!important;border-radius:8px;vertical-align:unset;font-size:9px}.cleantalk_admin_bar__blocked div{cursor:not-allowed!important}.cleantalk_admin_bar__blocked div a{color:#777!important}.cleantalk_admin_bar__title{vertical-align:top;margin-left:5px!important}.cleantalk_admin_bar__separator{height:0!important}
css/cleantalk-dashboard-widget.min.css CHANGED
@@ -1 +1 @@
1
- #ct_widget_wrapper{position:relative;width:100%;height:100%}.ct_widget_top_links{text-align:right;padding:0 12px;height:32px}.ct_widget_settings_link{margin:0 0 0 10px}.ct_preloader{display:none;float:left;width:20px;height:20px;margin:0 10px}.ct_widget_hr{width:100%}.ct_widget_block_header{font-size:18px!important;margin-left:12px!important}.ct_widget_block{display:block;position:relative;padding:12px}.ct_widget_chart_wrapper{height:300px;margin-right:10px}.bar{fill:#4682b4}.bar:nth-child(odd){fill:rgba(50,50,250,.9)}.bar:hover{fill:brown}.axis--x path{display:none}.ct_widget_block table{width:100%;text-align:left}.ct_widget_block table tr{margin-bottom:10px}.ct_widget_activate_button,.ct_widget_button{display:block;margin:10px auto}.ct_widget_block table th{text-align:left;padding:10px 0 5px 10px;border-bottom:2px solid gray}.ct_widget_block table td{text-align:left;padding:10px 0 5px 10px;border-bottom:1px solid gray}.ct_widget_activate_button{padding:7px 15px;font-weight:600;border-radius:3px;border:2px solid #aaa;background:rgba(250,50,50,.9)}.ct_widget_resolve_button{background:rgba(50,250,50,.9)}.ct_widget_activate_header{display:inline-block;width:100%;text-align:center;font-size:18px!important}.ct_widget_wprapper_total_blocked{padding:10px 0 10px 10px;background:#f1f1f1}.ct_widget_wprapper_total_blocked span{position:relative;top:2px}.ct_widget_small_logo{margin-right:1em;vertical-align:middle}#ct_widget_button_view_all{cursor:pointer;border:1px solid #0074a2;-webkit-appearance:none;-webkit-border-radius:2px;border-radius:2px;white-space:nowrap;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;background:#0085ba;-webkit-box-shadow:inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);color:#fff}#ct_widget_button_view_all:hover{color:#000!important}.ct_widget_block__country_cell{display:flex;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;align-items:center;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center}.ct_widget_block__country_cell img{margin-right:5px}
1
+ #ct_widget_wrapper{position:relative;width:100%;height:100%}.ct_widget_top_links{text-align:right;padding:0 12px;height:32px}.ct_widget_settings_link{margin:0 0 0 10px}.ct_preloader{display:none;float:left;width:20px;height:20px;margin:0 10px}.ct_widget_hr{width:100%}.ct_widget_block_header{font-size:18px!important;margin-left:12px!important}.ct_widget_block{display:block;position:relative;padding:12px}.ct_widget_chart_wrapper{height:300px;margin-right:10px}.bar{fill:#4682b4}.bar:nth-child(odd){fill:rgba(50,50,250,.9)}.bar:hover{fill:brown}.axis--x path{display:none}.ct_widget_block table{width:100%;text-align:left}.ct_widget_block table tr{margin-bottom:10px}.ct_widget_activate_button,.ct_widget_button{display:block;margin:10px auto}.ct_widget_block table th{text-align:left;padding:10px 0 5px 10px;border-bottom:2px solid gray}.ct_widget_block table td{text-align:left;padding:10px 0 5px 10px;border-bottom:1px solid gray}.ct_widget_activate_button{padding:7px 15px;font-weight:600;border-radius:3px;border:2px solid #aaa;background:rgba(250,50,50,.9)}.ct_widget_resolve_button{background:rgba(50,250,50,.9)}.ct_widget_activate_header{display:inline-block;width:100%;text-align:center;font-size:18px!important}.ct_widget_wprapper_total_blocked{padding:10px 0 10px 10px;background:#f1f1f1}.ct_widget_wprapper_total_blocked span{position:relative;top:2px}.ct_widget_small_logo{margin-right:1em;vertical-align:middle}#ct_widget_button_view_all{cursor:pointer;border:1px solid #0074a2;-webkit-appearance:none;-webkit-border-radius:2px;border-radius:2px;white-space:nowrap;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;background:#0085ba;-webkit-box-shadow:inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);color:#fff}#ct_widget_button_view_all:hover{color:#000!important}
inc/cleantalk-admin.php CHANGED
@@ -43,8 +43,6 @@ function apbct_add_buttons_to_comments_and_users( $unused_argument ) {
43
 
44
  }
45
 
46
- add_action( 'admin_bar_menu', 'apbct_admin__admin_bar__add', 999 );
47
-
48
  //Adding widget
49
  function ct_dashboard_statistics_widget() {
50
 
@@ -173,8 +171,31 @@ function ct_dashboard_statistics_widget_output( $post, $callback_args ) {
173
  * Admin action 'admin_init' - Add the admin settings and such
174
  */
175
  function apbct_admin__init(){
176
- global $apbct;
177
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  // Getting dashboard widget statistics
179
  if(!empty($_POST['ct_brief_refresh'])){
180
  cleantalk_get_brief_data( $apbct->api_key );
@@ -203,7 +224,10 @@ function apbct_admin__init(){
203
  if( ! is_multisite() || is_main_site() || ( ! is_main_site() && $apbct->network_settings['multisite__allow_custom_settings'] ) ) {
204
  new CleantalkSettingsTemplates( $apbct->api_key );
205
  }
206
-
 
 
 
207
  }
208
 
209
  /**
@@ -272,7 +296,7 @@ function apbct_admin__enqueue_scripts($hook){
272
 
273
  wp_localize_script( 'ct_admin_js_notices', 'ctAdminCommon', array(
274
  '_ajax_nonce' => wp_create_nonce( 'ct_secret_nonce' ),
275
- '_ajax_url' => admin_url( 'admin-ajax.php' ),
276
  'plugin_name' => $apbct->plugin_name,
277
  'logo' => '<img src="' . $apbct->logo . '" alt="" height="" style="width: 17px; vertical-align: text-bottom;" />',
278
  'logo_small' => '<img src="' . $apbct->logo__small . '" alt="" height="" style="width: 17px; vertical-align: text-bottom;" />',
@@ -455,6 +479,13 @@ function apbct_admin__notice_message(){
455
  '</b></h3>
456
  </div>';
457
  }
 
 
 
 
 
 
 
458
  }
459
 
460
  return true;
@@ -481,131 +512,347 @@ function apbct_admin__badge__get_premium($print = true, $out = ''){
481
  return $out;
482
  }
483
 
484
- function apbct_admin__admin_bar__add( $wp_admin_bar ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485
 
486
  global $apbct;
487
-
488
- if (current_user_can('activate_plugins') && $apbct->settings['admin_bar__show'] == 1 && (apbct_api_key__is_correct($apbct->api_key) !== false || (defined('CLEANTALK_SHOW_ADMIN_BAR_FORCE') && CLEANTALK_SHOW_ADMIN_BAR_FORCE))) {
489
-
490
- //Reset or create user counter
491
- if(!empty($_GET['ct_reset_user_counter'])){
492
- $apbct->data['user_counter']['accepted'] = 0;
493
- $apbct->data['user_counter']['blocked'] = 0;
494
- $apbct->data['user_counter']['since'] = date('d M');
495
- $apbct->saveData();
496
- }
497
- //Reset or create all counters
498
- if(!empty($_GET['ct_reset_all_counters'])){
499
- $apbct->data['admin_bar__sfw_counter'] = array('all' => 0, 'blocked' => 0);
500
- $apbct->data['admin_bar__all_time_counter'] = array('accepted' => 0, 'blocked' => 0);
501
- $apbct->data['user_counter'] = array('all' => 0, 'accepted' => 0, 'blocked' => 0, 'since' => date('d M'));
502
- $apbct->data['array_accepted'] = array();
503
- $apbct->data['array_blocked'] = array();
504
- $apbct->data['current_hour'] = '';
505
- $apbct->saveData();
506
- }
507
- //Compile user's counter string
508
- $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']);
509
- //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>';
510
- $user_counter_str='<span style="color: white;">' . __('Since', 'cleantalk-spam-protect') . '&nbsp;' . $user_counter['since'].': </span><span style="color: green;">' .$user_counter['accepted']. '</span> / <span style="color: red;">' .$user_counter['blocked']. '</span>';
511
-
512
- $all_time_counter_str='';
513
- //Don't compile if all time counter disabled
514
- if($apbct->settings['admin_bar__all_time_counter'] == 1){
515
- $all_time_counter=Array('accepted'=>$apbct->data['admin_bar__all_time_counter']['accepted'], 'blocked'=>$apbct->data['admin_bar__all_time_counter']['blocked'], 'all'=>$apbct->data['admin_bar__all_time_counter']['accepted'] + $apbct->data['admin_bar__all_time_counter']['blocked']);
516
- $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-spam-protect').'"><span style="color: white;"> | ' . __('All', 'cleantalk-spam-protect') . ': ' .$all_time_counter['all']. '</span> / <span style="color: green;">' .$all_time_counter['accepted']. '</span> / <span style="color: red;">' .$all_time_counter['blocked']. '</span></span>';
517
- }
518
-
519
- $daily_counter_str='';
520
- //Don't compile if daily counter disabled
521
- if( $apbct->settings['admin_bar__daily_counter'] == 1){
522
- $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']));
523
- //Previous version $daily_counter_str='<span style="color: white;" title="'.__('All / Allowed / Blocked submissions. The number of submissions for past 24 hours. ', 'cleantalk-spam-protect').'"><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>';
524
- $daily_counter_str='<span style="color: white;" title="'.__('Allowed / Blocked submissions. The number of submissions for past 24 hours. ', 'cleantalk-spam-protect').'"><span style="color: white;"> | ' . __('Day', 'cleantalk-spam-protect') . ': </span><span style="color: green;">' .$daily_counter['accepted']. '</span> / <span style="color: red;">' .$daily_counter['blocked']. '</span></span>';
525
- }
526
- $sfw_counter_str='';
527
- //Don't compile if SFW counter disabled
528
- if( $apbct->settings['admin_bar__sfw_counter'] == 1 && $apbct->settings['sfw__enabled'] == 1){
529
- $sfw_counter=Array('all'=>$apbct->data['admin_bar__sfw_counter']['all'], 'blocked'=>$apbct->data['admin_bar__sfw_counter']['blocked']);
530
- $sfw_counter_str='<span style="color: white;" title="'.__('All / Blocked events. Access attempts regitred by SpamFireWall counted since the last plugin activation.', 'cleantalk-spam-protect').'"><span style="color: white;"> | SpamFireWall: ' .$sfw_counter['all']. '</span> / <span style="color: red;">' .$sfw_counter['blocked']. '</span></span>';
531
- }
532
-
533
- $args = array(
534
- 'id' => 'ct_parent_node',
535
- 'title' => '<img src="' . plugin_dir_url(__FILE__) . 'images/logo_small1.png" alt="" height="" style="margin-top:9px; float: left;" />'
536
- .'<div style="margin: auto 7px;" class="ab-item alignright">'
537
- .'<div class="ab-label" id="ct_stats">'
538
- .($apbct->notice_trial == 1
539
- ? "<span><a style='color: red;' href=\"https://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>"
540
- : '<span style="color: white;" title="'.__('Allowed / Blocked submissions. The number of submissions is being counted since ', 'cleantalk-spam-protect').' '.$user_counter['since'].'">'.$user_counter_str.'</span> '.$daily_counter_str.$all_time_counter_str.$sfw_counter_str
541
- )
542
- .'</div>'
543
- .'</div>' //You could change widget string here by simply deleting variables
544
- );
545
- $wp_admin_bar->add_node( $args );
546
-
547
- // DASHBOARD LINK
548
- if(!$apbct->white_label){
549
- $wp_admin_bar->add_node( array(
550
- 'id' => 'ct_dashboard_link',
551
- '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-spam-protect').'</a>',
552
- 'parent' => 'ct_parent_node'
553
- ));
554
- }
555
-
556
- $wp_admin_bar->add_node( array(
557
- 'id' => 'ct_settings_link',
558
- 'title' => '<a href="'.$apbct->settings_link.'">'.__('Settings', 'cleantalk-spam-protect').'</a>',
559
- 'parent' => 'ct_parent_node'
560
- ));
561
-
562
- // add a child item to our parent item. Bulk checks.
563
- if(!is_network_admin()){
564
- $args = array(
565
- 'id' => 'ct_settings_bulk_comments',
566
- 'title' => '<hr style="margin-top: 7px;" /><a href="edit-comments.php?page=ct_check_spam" title="'.__('Bulk spam comments removal tool.', 'cleantalk-spam-protect').'">'.__('Check comments for spam', 'cleantalk-spam-protect').'</a>',
567
- 'parent' => 'ct_parent_node'
568
- );
569
- }
570
- $wp_admin_bar->add_node( $args );
571
-
572
- // add a child item to our parent item. Bulk checks.
573
- if(!is_network_admin()){
574
- $args = array(
575
- 'id' => 'ct_settings_bulk_users',
576
- 'title' => '<a href="users.php?page=ct_check_users" title="Bulk spam users removal tool.">'.__('Check users for spam', 'cleantalk-spam-protect').'</a>',
577
- 'parent' => 'ct_parent_node'
578
- );
579
- }
580
- $wp_admin_bar->add_node( $args );
581
-
582
- // User counter reset.
583
- $args = array(
584
- 'id' => 'ct_reset_counter',
585
- 'title' => '<hr style="margin-top: 7px;"><a href="?ct_reset_user_counter=1" title="Reset your personal counter of submissions.">'.__('Reset first counter', 'cleantalk-spam-protect').'</a>',
586
- 'parent' => 'ct_parent_node'
587
- );
588
- $wp_admin_bar->add_node( $args );// add a child item to our parent item. Counter reset.
589
-
590
- // Reset ALL counter
591
- $args = array(
592
- 'id' => 'ct_reset_counters_all',
593
- 'title' => '<a href="?ct_reset_all_counters=1" title="Reset all counters.">'.__('Reset all counters', 'cleantalk-spam-protect').'</a>',
594
- 'parent' => 'ct_parent_node'
595
- );
596
- $wp_admin_bar->add_node( $args );
597
-
598
- // Support link
599
- if(!$apbct->white_label){
600
- $wp_admin_bar->add_node( array(
601
- 'id' => 'ct_admin_bar_support_link',
602
- 'title' => '<hr style="margin-top: 7px;" /><a target="_blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">'.__('Support', 'cleantalk-spam-protect').'</a>',
603
- 'parent' => 'ct_parent_node'
604
- ));
605
- }
606
- }
607
  }
608
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
609
  /**
610
  * Unmark bad words
611
  * @param string $message
@@ -736,3 +983,11 @@ function apbct_test_connection(){
736
  }
737
  return $out;
738
  }
 
 
 
 
 
 
 
 
43
 
44
  }
45
 
 
 
46
  //Adding widget
47
  function ct_dashboard_statistics_widget() {
48
 
171
  * Admin action 'admin_init' - Add the admin settings and such
172
  */
173
  function apbct_admin__init(){
174
+
175
+ global $apbct, $spbc;
176
+
177
+ // Admin bar
178
+
179
+ $apbct->admin_bar_enabled = $apbct->settings['admin_bar__show'] &&
180
+ current_user_can( 'activate_plugins' ) &&
181
+ apbct_api_key__is_correct() !== false;
182
+
183
+ // ( defined( 'CLEANTALK_SHOW_ADMIN_BAR_FORCE' ) && CLEANTALK_SHOW_ADMIN_BAR_FORCE ) &&
184
+ if( $apbct->admin_bar_enabled ){
185
+ if(
186
+ ! has_action('admin_bar_menu', 'apbct_admin__admin_bar__add_structure' ) &&
187
+ ! has_action('admin_bar_menu', 'spbc_admin__admin_bar__add_structure' )
188
+ ){
189
+ add_action( 'admin_bar_menu', 'apbct_admin__admin_bar__add_structure', 999 );
190
+ }
191
+ add_filter( 'cleantalk_admin_bar__add_icon_to_parent_node', 'apbct_admin__admin_bar__add_parent_icon', 10, 1 );
192
+ add_action( 'admin_bar_menu', 'apbct_admin__admin_bar__add_child_nodes', 1000 );
193
+ if( ! $spbc ){
194
+ add_filter( 'admin_bar_menu', 'apbct_spbc_admin__admin_bar__add_child_nodes', 1001 );
195
+ }
196
+ }
197
+
198
+
199
  // Getting dashboard widget statistics
200
  if(!empty($_POST['ct_brief_refresh'])){
201
  cleantalk_get_brief_data( $apbct->api_key );
224
  if( ! is_multisite() || is_main_site() || ( ! is_main_site() && $apbct->network_settings['multisite__allow_custom_settings'] ) ) {
225
  new CleantalkSettingsTemplates( $apbct->api_key );
226
  }
227
+
228
+ // Check compatibility
229
+ do_action( 'apbct__check_compatibility' );
230
+
231
  }
232
 
233
  /**
296
 
297
  wp_localize_script( 'ct_admin_js_notices', 'ctAdminCommon', array(
298
  '_ajax_nonce' => wp_create_nonce( 'ct_secret_nonce' ),
299
+ '_ajax_url' => admin_url( 'admin-ajax.php', 'relative' ),
300
  'plugin_name' => $apbct->plugin_name,
301
  'logo' => '<img src="' . $apbct->logo . '" alt="" height="" style="width: 17px; vertical-align: text-bottom;" />',
302
  'logo_small' => '<img src="' . $apbct->logo__small . '" alt="" height="" style="width: 17px; vertical-align: text-bottom;" />',
479
  '</b></h3>
480
  </div>';
481
  }
482
+
483
+ //notice_incompatibility
484
+ if( ! empty( $apbct->data['notice_incompatibility'] ) && $page_is_ct_settings ){
485
+ foreach ($apbct->data['notice_incompatibility'] as $notice) {
486
+ echo '<div class="error">' . $notice . '</div>';
487
+ }
488
+ }
489
  }
490
 
491
  return true;
512
  return $out;
513
  }
514
 
515
+ function apbct_admin__admin_bar__add_structure( $wp_admin_bar ) {
516
+
517
+ global $spbc, $apbct;
518
+
519
+ // Adding parent node
520
+ $wp_admin_bar->add_node( array(
521
+ 'id' => 'cleantalk_admin_bar__parent_node',
522
+ 'title' => apply_filters('cleantalk_admin_bar__add_icon_to_parent_node', '' )
523
+ . '<span class="cleantalk_admin_bar__title">' . __('CleanTalk', 'cleantalk-spam-protect') . '</span>',
524
+ ) );
525
+
526
+ // Security
527
+ $title = $apbct->notice_trial
528
+ ? "<span><a style='color: red;' href='https://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', 'cleantalk-spam-protect') . '</a></span>'
529
+ : '<a>' . __( 'Anti-Spam', 'cleantalk-spam-protect' ) . '</a>';
530
+
531
+ $wp_admin_bar->add_node( array(
532
+ 'parent' => 'cleantalk_admin_bar__parent_node',
533
+ 'id' => 'apbct__parent_node',
534
+ 'title' => '<div class="cleantalk-admin_bar__parent">'
535
+ . $title
536
+ . '</div>'
537
+ ) );
538
+
539
+ // Antispam
540
+ // Install link
541
+ if( ! $spbc ){
542
+ $spbc_title = '<a>' . __( 'Security', 'security-malware-firewall' ) . '</a>';
543
+ }elseif( $spbc->admin_bar_enabled ){
544
+ $spbc_title = $spbc->trial == 1
545
+ ? "<span><a style='color: red;' href='https://cleantalk.org/my/bill/security?utm_source=wp-backend&utm_medium=cpc&utm_campaign=WP%20backend%20renew_security&user_token={$spbc->user_token}&cp_mode=security' target='_blank'>" . __( 'Renew Security', 'security-malware-firewall' ) . '</a></span>'
546
+ : '<a>' . __( 'Security', 'security-malware-firewall' ) . '</a>';
547
+ }
548
+
549
+ if( isset( $spbc_title ) ){
550
+ $wp_admin_bar->add_node( array(
551
+ 'parent' => 'cleantalk_admin_bar__parent_node',
552
+ 'id' => 'spbc__parent_node',
553
+ 'title' => '<div class="cleantalk-admin_bar__parent">'
554
+ . $spbc_title
555
+ . '</div>'
556
+ ) );
557
+ }
558
+ }
559
+
560
+ function apbct_admin__admin_bar__add_parent_icon( $icon ){
561
+
562
+ global $apbct;
563
+
564
+ //Reset or create user counter
565
+ if(!empty($_GET['ct_reset_user_counter'])){
566
+ $apbct->data['user_counter']['accepted'] = 0;
567
+ $apbct->data['user_counter']['blocked'] = 0;
568
+ $apbct->data['user_counter']['since'] = date('d M');
569
+ $apbct->saveData();
570
+ }
571
+ //Reset or create all counters
572
+ if(!empty($_GET['ct_reset_all_counters'])){
573
+ $apbct->data['admin_bar__sfw_counter'] = array('all' => 0, 'blocked' => 0);
574
+ $apbct->data['admin_bar__all_time_counter'] = array('accepted' => 0, 'blocked' => 0);
575
+ $apbct->data['user_counter'] = array('all' => 0, 'accepted' => 0, 'blocked' => 0, 'since' => date('d M'));
576
+ $apbct->data['array_accepted'] = array();
577
+ $apbct->data['array_blocked'] = array();
578
+ $apbct->data['current_hour'] = '';
579
+ $apbct->saveData();
580
+ }
581
+
582
+ $apbct->counter__sum = 0;
583
+
584
+ $apbct->counter__user = array(
585
+ 'accepted' => $apbct->data['user_counter']['accepted'],
586
+ 'blocked' => $apbct->data['user_counter']['blocked'],
587
+ 'all' => $apbct->data['user_counter']['accepted'] + $apbct->data['user_counter']['blocked'],
588
+ 'since' => $apbct->data['user_counter']['since']
589
+ );
590
+ $apbct->counter__sum += $apbct->counter__user['all'];
591
+
592
+ if( $apbct->settings['admin_bar__all_time_counter'] ){
593
+ $apbct->counter__all_time = array(
594
+ 'accepted' => $apbct->data['admin_bar__all_time_counter']['accepted'],
595
+ 'blocked' => $apbct->data['admin_bar__all_time_counter']['blocked'],
596
+ 'all' => $apbct->data['admin_bar__all_time_counter']['accepted'] + $apbct->data['admin_bar__all_time_counter']['blocked']
597
+ );
598
+ $apbct->counter__sum += $apbct->counter__all_time['all'];
599
+ }
600
+
601
+ if( $apbct->settings['admin_bar__daily_counter'] ){
602
+ $apbct->counter__daily = array(
603
+ 'accepted' => array_sum( $apbct->data['array_accepted'] ),
604
+ 'blocked' => array_sum( $apbct->data['array_blocked'] ),
605
+ 'all' => array_sum( $apbct->data['array_accepted'] ) + array_sum( $apbct->data['array_blocked'] )
606
+ );
607
+ $apbct->counter__sum += $apbct->counter__daily['all'];
608
+ }
609
+
610
+ if( $apbct->settings['admin_bar__sfw_counter'] && $apbct->settings['sfw__enabled'] ){
611
+ $apbct->counter__sfw = array(
612
+ 'all' => $apbct->data['admin_bar__sfw_counter']['all'],
613
+ 'blocked' => $apbct->data['admin_bar__sfw_counter']['blocked']
614
+ );
615
+ $apbct->counter__sum += $apbct->counter__sfw['all'];
616
+ }
617
+
618
+ $counter__sum__layout = $apbct->counter__sum
619
+ ? ( '<div class="cleantalk_admin_bar__sum_counter">' . $apbct->counter__sum . '</div>')
620
+ : '';
621
+
622
+
623
+ return $icon
624
+ . '<img class="cleantalk_admin_bar__apbct_icon" src="' . APBCT_URL_PATH . '/inc/images/logo.png" alt="">&nbsp;'
625
+ . $counter__sum__layout;
626
+ }
627
+
628
+ function apbct_admin__admin_bar__add_child_nodes( $wp_admin_bar ) {
629
 
630
  global $apbct;
631
+
632
+ // User's counter
633
+ $wp_admin_bar->add_node( array(
634
+ 'parent' => 'apbct__parent_node',
635
+ 'id' => 'apbct_admin_bar__counter__user',
636
+ 'title' => '<a>' . __('Since', 'cleantalk-spam-protect') . '&nbsp;' . $apbct->counter__user['since'] . ': '
637
+ . '<span style="color: green;">' . $apbct->counter__user['accepted']. '</span> / '
638
+ . '<span style="color: red;">' . $apbct->counter__user['blocked'] . '</span></a>',
639
+ ) );
640
+
641
+ // All-time counter
642
+ if($apbct->settings['admin_bar__all_time_counter'] ){
643
+ $wp_admin_bar->add_node( array(
644
+ 'parent' => 'apbct__parent_node',
645
+ 'id' => 'apbct_admin_bar__counter__all_time',
646
+ 'title' =>
647
+ '<a><span title="' . __('All / Allowed / Blocked submissions. The number of submissions is being counted since CleanTalk plugin installation.', 'cleantalk-spam-protect').'">'
648
+ . __('Since installation', 'cleantalk-spam-protect') . ': '
649
+ . '<span style="color: white;">' . $apbct->counter__all_time['all']. '</span> / '
650
+ . '<span style="color: green;">' . $apbct->counter__all_time['accepted']. '</span> / '
651
+ . '<span style="color: red;">' .$apbct->counter__all_time['blocked']. '</span>'
652
+ . '</span></a>',
653
+ ) );
654
+ }
655
+
656
+ // Daily counter
657
+ if( $apbct->settings['admin_bar__daily_counter'] ){
658
+ $wp_admin_bar->add_node( array(
659
+ 'parent' => 'apbct__parent_node',
660
+ 'id' => 'apbct_admin_bar__counter__daily',
661
+ 'title' =>
662
+ '<a><span title="'.__('Allowed / Blocked submissions. The number of submissions for past 24 hours. ', 'cleantalk-spam-protect').'">'
663
+ . __('Day', 'cleantalk-spam-protect') . ': '
664
+ . '<span style="color: green;">' .$apbct->counter__daily['accepted']. '</span> / '
665
+ . '<span style="color: red;">' .$apbct->counter__daily['blocked']. '</span>'
666
+ . '</span></a>',
667
+ ) );
668
+ }
669
+
670
+ // SFW counter
671
+ if( $apbct->settings['admin_bar__sfw_counter'] && $apbct->settings['sfw__enabled'] ){
672
+ $wp_admin_bar->add_node( array(
673
+ 'parent' => 'apbct__parent_node',
674
+ 'id' => 'apbct_admin_bar__counter__sfw',
675
+ 'title' =>
676
+ '<a><span title="'.__('All / Blocked events. Access attempts triggered by SpamFireWall counted since the last plugin activation.', 'cleantalk-spam-protect').'">'
677
+ . __('SpamFireWall', 'cleantalk-spam-protect' ) . ': '
678
+ . '<span style="color: white;">'. $apbct->counter__sfw['all']. '</span> / '
679
+ . '<span style="color: red;">' .$apbct->counter__sfw['blocked']. '</span>'
680
+ . '</span></a>'
681
+ ) );
682
+ }
683
+
684
+ // Counter separator
685
+ if( $apbct->counter__sum ){
686
+ $wp_admin_bar->add_node( array(
687
+ 'parent' => 'apbct__parent_node',
688
+ 'id' => 'apbct_admin_bar__separator',
689
+ 'title' =>'<hr style="margin-top: 7px;" />',
690
+ 'meta' => array( 'class' => 'cleantalk_admin_bar__separator')
691
+ ) );
692
+ }
693
+
694
+ // Dashboard link
695
+ if(!$apbct->white_label){
696
+ $wp_admin_bar->add_node( array(
697
+ 'parent' => 'apbct__parent_node',
698
+ 'id' => 'ct_dashboard_link',
699
+ '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">'.__('Dashboard', 'cleantalk-spam-protect').'</a>',
700
+ ));
701
+ }
702
+
703
+ $wp_admin_bar->add_node( array(
704
+ 'parent' => 'apbct__parent_node',
705
+ 'id' => 'ct_settings_link',
706
+ 'title' => '<a href="'.$apbct->settings_link.'">'.__('Settings', 'cleantalk-spam-protect').'</a>',
707
+ ));
708
+
709
+ // Add a child item to our parent item. Bulk checks.
710
+ if(!is_network_admin()){
711
+ $wp_admin_bar->add_node( array(
712
+ 'parent' => 'apbct__parent_node',
713
+ 'id' => 'ct_settings_bulk_comments',
714
+ 'title' => '<hr style="margin-top: 7px;" /><a href="edit-comments.php?page=ct_check_spam" title="'.__('Bulk spam comments removal tool.', 'cleantalk-spam-protect').'">'.__('Check comments for spam', 'cleantalk-spam-protect').'</a>',
715
+ ) );
716
+ }
717
+
718
+ // Add a child item to our parent item. Bulk checks.
719
+ if(!is_network_admin()){
720
+ $wp_admin_bar->add_node( array(
721
+ 'parent' => 'apbct__parent_node',
722
+ 'id' => 'ct_settings_bulk_users',
723
+ 'title' => '<a href="users.php?page=ct_check_users" title="Bulk spam users removal tool.">'.__('Check users for spam', 'cleantalk-spam-protect').'</a>',
724
+ ) );
725
+ }
726
+
727
+ // User counter reset.
728
+ $args = array(
729
+ 'parent' => 'apbct__parent_node',
730
+ 'id' => 'ct_reset_counter',
731
+ 'title' => '<hr style="margin-top: 7px;"><a href="?ct_reset_user_counter=1" title="Reset your personal counter of submissions.">'.__('Reset first counter', 'cleantalk-spam-protect').'</a>',
732
+ );
733
+ $wp_admin_bar->add_node( $args );// add a child item to our parent item. Counter reset.
734
+
735
+ // Reset ALL counter
736
+ $args = array(
737
+ 'parent' => 'apbct__parent_node',
738
+ 'id' => 'ct_reset_counters_all',
739
+ 'title' => '<a href="?ct_reset_all_counters=1" title="Reset all counters.">'.__('Reset all counters', 'cleantalk-spam-protect').'</a>',
740
+ );
741
+ $wp_admin_bar->add_node( $args );
742
+
743
+ // Support link
744
+ if(!$apbct->white_label){
745
+ $wp_admin_bar->add_node( array(
746
+ 'parent' => 'apbct__parent_node',
747
+ 'id' => 'ct_admin_bar_support_link',
748
+ 'title' => '<hr style="margin-top: 7px;" /><a target="_blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">'.__('Support', 'cleantalk-spam-protect').'</a>',
749
+ ));
750
+ }
751
  }
752
 
753
+ function apbct_spbc_admin__admin_bar__add_child_nodes( $wp_admin_bar ){
754
+
755
+ // Installation link
756
+ $wp_admin_bar->add_node( array(
757
+ 'parent' => 'spbc__parent_node',
758
+ 'id' => 'apbct_admin_bar__install',
759
+ 'title' => '<a target="_blank" style="color: #4291d1; font-weight: bold;" href="plugin-install.php?s=Security%20and%20Malware%20scan%20by%20CleanTalk%20&tab=search">' . __( 'Install Security by CleanTalk', 'cleantalk-spam-protect' ) . '</a>',
760
+ ) );
761
+
762
+ $wp_admin_bar->add_node( array(
763
+ 'parent' => 'spbc__parent_node',
764
+ 'id' => 'install_separator',
765
+ 'title' =>'<hr style="margin-top: 7px;" />',
766
+ 'meta' => array( 'class' => 'cleantalk_admin_bar__separator' )
767
+ ) );
768
+
769
+ // Users online counter
770
+ $wp_admin_bar->add_node( array(
771
+ 'parent' => 'spbc__parent_node',
772
+ 'title' => '<a><span>' . __( 'Users online:', 'cleantalk-spam-protect' ) . '</span>'
773
+ . '&nbsp;<b class="spbc-admin_bar--user_counter">' . 0 . '</b></a>',
774
+ 'id' => 'spbc_admin_bar__counter__online',
775
+ 'meta' => array( 'class' => 'cleantalk_admin_bar__blocked' ),
776
+ ) );
777
+
778
+ // Failed / success login attempts counter
779
+ $wp_admin_bar->add_node( array(
780
+ 'parent' => 'spbc__parent_node',
781
+ 'id' => 'spbc_admin_bar__counter__logins',
782
+ 'title' => '<a><span>' . __('Logins:', 'cleantalk-spam-protect') . '</span>&nbsp;'
783
+ . '<span style="color: white;" title="' . __('Blocked login attempts in the local database.', 'cleantalk-spam-protect') . '">'
784
+ . '<span style="color: white;">'
785
+ . '<span style="color: green;">'
786
+ . 0
787
+ . '</span> / '
788
+ . '<span style="color: red;">'
789
+ . 0
790
+ . '</span>'
791
+ . '</span></a>',
792
+ 'meta' => array( 'class' => 'cleantalk_admin_bar__blocked' ),
793
+ ) );
794
+
795
+
796
+ // Firewall blocked / allowed counter
797
+ $wp_admin_bar->add_node( array(
798
+ 'parent' => 'spbc__parent_node',
799
+ 'id' => 'spbc_admin_bar__counter__firewall',
800
+ 'title' => '<a><span>' .__( 'Security Firewall: ', 'cleantalk-spam-protect' ) .'</span>&nbsp;'
801
+ . '<span style="color: white;" title="'.__('Passed / Blocked requests by Security Firewall.', 'cleantalk-spam-protect').'">'
802
+ . '<span style="color: green;">'
803
+ . 0
804
+ . '</span> / '
805
+ . '<span style="color: red;">'
806
+ . 0
807
+ . '</span>'
808
+ . '</span></a>',
809
+ 'meta' => array( 'class' => 'cleantalk_admin_bar__blocked' ),
810
+ ) );
811
+
812
+ // Counter separator
813
+ $wp_admin_bar->add_node( array(
814
+ 'parent' => 'spbc__parent_node',
815
+ 'id' => 'spbc_admin_bar__separator',
816
+ 'title' =>'<hr style="margin-top: 7px;" />',
817
+ 'meta' => array( 'class' => 'cleantalk_admin_bar__separator')
818
+ ) );
819
+
820
+ // Dashboard
821
+ $wp_admin_bar->add_node( array(
822
+ 'parent' => 'spbc__parent_node',
823
+ 'id' => 'spbc_admin_bar__dashboard_link',
824
+ 'title' => '<a>' . __( 'Dashboard', 'cleantalk-spam-protect' ) . '</a>',
825
+ 'meta' => array( 'class' => 'cleantalk_admin_bar__blocked' ),
826
+ ) );
827
+
828
+ // Settings
829
+ $wp_admin_bar->add_node( array(
830
+ 'parent' => 'spbc__parent_node',
831
+ 'id' => 'spbc_admin_bar__settings_link',
832
+ 'title' => '<a>' . __( 'Settings', 'cleantalk-spam-protect' ) . '</a>',
833
+ 'meta' => array( 'class' => 'cleantalk_admin_bar__blocked' ),
834
+ ) );
835
+
836
+ // Scanner
837
+ $wp_admin_bar->add_node( array(
838
+ 'parent' => 'spbc__parent_node',
839
+ 'id' => 'spbc_admin_bar__scanner_link',
840
+ 'title' => '<a style="display:inline">' . __( 'Scanner', 'cleantalk-spam-protect' ) . '</a>'
841
+ . '/'
842
+ . '<a style="display:inline">' . __( 'Start scan', 'cleantalk-spam-protect' ) . '</a>',
843
+ 'meta' => array( 'class' => 'cleantalk_admin_bar__blocked' ),
844
+ ) );
845
+
846
+ // Support link
847
+ $wp_admin_bar->add_node( array(
848
+ 'parent' => 'spbc__parent_node',
849
+ 'title' => '<hr style="margin-top: 7px;" /><a>' . __( 'Support', 'cleantalk-spam-protect' ) . '</a>',
850
+ 'id' => 'spbc_admin_bar__support_link',
851
+ 'meta' => array( 'class' => 'cleantalk_admin_bar__blocked' ),
852
+ ) );
853
+ }
854
+
855
+
856
  /**
857
  * Unmark bad words
858
  * @param string $message
983
  }
984
  return $out;
985
  }
986
+
987
+ /**
988
+ * Check compatibility action
989
+ */
990
+ add_action('apbct__check_compatibility', 'apbct__check_compatibility_handler');
991
+ function apbct__check_compatibility_handler() {
992
+ new \Cleantalk\Common\Compatibility();
993
+ }
inc/cleantalk-ajax-handlers.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // If this file is called directly, abort.
4
+ if ( ! defined( 'DOING_AJAX' ) ) {
5
+ http_response_code( 403 );
6
+ die('Not allowed.');
7
+ }
8
+
9
+ require_once( __DIR__ . '/../lib/autoloader.php' );
10
+
11
+ $plugin_info = get_file_data( __DIR__ . '/../cleantalk.php', array('Version' => 'Version', 'Name' => 'Plugin Name') );
12
+ if( !defined( 'APBCT_VERSION' ) ) {
13
+ define( 'APBCT_VERSION', $plugin_info['Version'] );
14
+ }
15
+
16
+ global $apbct;
17
+ $apbct = new \Cleantalk\ApbctWP\State('cleantalk', array('settings', 'data'));
18
+ \Cleantalk\ApbctWP\State::setDefinitions();
19
+
20
+ /*******************************************************************/
21
+ /******************* H A N D L E R S H E R E *******************/
22
+ /*******************************************************************/
23
+ function apbct_js_keys__get() {
24
+ require_once( __DIR__ . '/cleantalk-common.php' );
25
+ require_once( __DIR__ . '/cleantalk-pluggable.php' );
26
+ apbct_js_keys__get__ajax();
27
+ }
28
+
29
+ function apbct_email_check_before_post() {
30
+ if (count($_POST) && isset($_POST['data']['email']) && !empty($_POST['data']['email'])) {
31
+ $email = trim($_POST['data']['email']);
32
+ $result = \Cleantalk\ApbctWP\API::method__email_check($email);
33
+ if (isset($result['data'])) {
34
+ die(json_encode(array('result' => $result['data'])));
35
+ }
36
+ die(json_encode(array('error' => 'ERROR_CHECKING_EMAIL')));
37
+ }
38
+ die(json_encode(array('error' => 'EMPTY_DATA')));
39
+ }
40
+
41
+ function apbct_alt_session__save__AJAX() {
42
+ Cleantalk\ApbctWP\Variables\AltSessions::set_fromRemote();
43
+ }
44
+
45
+ function apbct_alt_session__get__AJAX() {
46
+ Cleantalk\ApbctWP\Variables\AltSessions::get_fromRemote();
47
+ }
inc/cleantalk-ajax.php CHANGED
@@ -326,6 +326,7 @@ function ct_ajax_hook($message_obj = false, $additional = false)
326
  'erforms_field_change_command', //ERForms internal request
327
  'wl_out_of_stock_notify', // Sumo Waitlist
328
  'rac_preadd_guest', //Rac internal request
 
329
  /* !! Do not add actions here. Use apbct_is_skip_request() function below !! */
330
  );
331
 
326
  'erforms_field_change_command', //ERForms internal request
327
  'wl_out_of_stock_notify', // Sumo Waitlist
328
  'rac_preadd_guest', //Rac internal request
329
+ 'apbct_email_check_before_post', //Interal request
330
  /* !! Do not add actions here. Use apbct_is_skip_request() function below !! */
331
  );
332
 
inc/cleantalk-autoloader.php CHANGED
@@ -1,21 +1,21 @@
1
- <?php
2
-
3
- /**
4
- * Autoloader for \Cleantalk\* classes
5
- *
6
- * @param string $class
7
- *
8
- * @return void
9
- */
10
- function apbct_autoloader( $class ){
11
- // Register class auto loader
12
- // Custom modules
13
- if( strpos( $class, 'cleantalk-spam-protect') !== false && ! class_exists( '\\' . $class )) {
14
- $class_file = CLEANTALK_PLUGIN_DIR . 'lib' . DIRECTORY_SEPARATOR . $class . '.php';
15
- if( file_exists( $class_file ) ){
16
- require_once( $class_file );
17
- }
18
- }
19
- }
20
-
21
- spl_autoload_register( 'apbct_autoloader' );
1
+ <?php
2
+
3
+ /**
4
+ * Autoloader for \Cleantalk\* classes
5
+ *
6
+ * @param string $class
7
+ *
8
+ * @return void
9
+ */
10
+ function apbct_autoloader( $class ){
11
+ // Register class auto loader
12
+ // Custom modules
13
+ if( strpos( $class, 'cleantalk-spam-protect') !== false && ! class_exists( '\\' . $class )) {
14
+ $class_file = CLEANTALK_PLUGIN_DIR . 'lib' . DIRECTORY_SEPARATOR . $class . '.php';
15
+ if( file_exists( $class_file ) ){
16
+ require_once( $class_file );
17
+ }
18
+ }
19
+ }
20
+
21
+ spl_autoload_register( 'apbct_autoloader' );
inc/cleantalk-common.php CHANGED
@@ -4,6 +4,7 @@ use Cleantalk\Antispam\Cleantalk;
4
  use Cleantalk\Antispam\CleantalkRequest;
5
  use Cleantalk\Antispam\CleantalkResponse;
6
  use Cleantalk\ApbctWP\API;
 
7
  use Cleantalk\ApbctWP\Helper;
8
  use Cleantalk\ApbctWP\Variables\Cookie;
9
  use Cleantalk\Variables\Server;
@@ -150,10 +151,10 @@ function apbct_base_call($params = array(), $reg_flag = false){
150
  ? \Cleantalk\ApbctWP\Helper::array_merge__save_numeric_keys__recursive(apbct_get_sender_info(), (array)$params['sender_info'])
151
  : apbct_get_sender_info();
152
 
153
- $honeypot_website = null;
154
 
155
- if(isset($params['honeypot_website'])) {
156
- $honeypot_website = $params['honeypot_website'];
157
  }
158
 
159
  $default_params = array(
@@ -172,7 +173,7 @@ function apbct_base_call($params = array(), $reg_flag = false){
172
  'agent' => APBCT_AGENT,
173
  'sender_info' => $sender_info,
174
  'submit_time' => apbct_get_submit_time(),
175
- 'honeypot_website' => $honeypot_website
176
  );
177
 
178
  // Send $_SERVER if couldn't find IP
@@ -441,6 +442,9 @@ function apbct_get_sender_info() {
441
  'headers_sent__hook' => !empty($apbct->headers_sent__hook) ? $apbct->headers_sent__hook : 'no_hook',
442
  'headers_sent__where' => !empty($apbct->headers_sent__where) ? $apbct->headers_sent__where : false,
443
  'request_type' => apbct_get_server_variable('REQUEST_METHOD') ? apbct_get_server_variable('REQUEST_METHOD') : 'UNKNOWN',
 
 
 
444
  );
445
  }
446
 
@@ -469,8 +473,8 @@ function apbct_visible_fields__process( $visible_fields ) {
469
  $fields = explode( ' ', $current_fields['visible_fields'] );
470
 
471
  // This fields belong this request
472
- // @ToDo we have to implement a logic to find form fields (fields names, fields count) in serialized/nested/encoded items. not only $_POST.
473
- if( count( array_intersect( array_keys($_POST), $fields ) ) > 0 ) {
474
  // WP Forms visible fields formatting
475
  if(strpos($visible_fields, 'wpforms') !== false){
476
  $visible_fields = preg_replace(
@@ -498,10 +502,28 @@ function apbct_visible_fields__process( $visible_fields ) {
498
  return array();
499
  }
500
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
501
  /*
502
  * Outputs JS key for AJAX-use only. Stops script.
503
  */
504
- function apbct_js_keys__get__ajax( $request ){
505
 
506
  die( json_encode( array( 'js_key' => ct_get_checkjs_value() ) ) );
507
  }
@@ -746,271 +768,35 @@ function ct_delete_spam_comments() {
746
  return null;
747
  }
748
 
749
- /*
750
- * Get data from an ARRAY recursively
751
- * @return array
752
- */
 
 
 
 
 
 
 
 
 
 
753
  function ct_get_fields_any($arr, $message=array(), $email = null, $nickname = array('nick' => '', 'first' => '', 'last' => ''), $subject = null, $contact = true, $prev_name = ''){
754
 
755
- //Skip request if fields exists
756
- $skip_params = array(
757
- 'ipn_track_id', // PayPal IPN #
758
- 'txn_type', // PayPal transaction type
759
- 'payment_status', // PayPal payment status
760
- 'ccbill_ipn', // CCBill IPN
761
- 'ct_checkjs', // skip ct_checkjs field
762
- 'api_mode', // DigiStore-API
763
- 'loadLastCommentId' // Plugin: WP Discuz. ticket_id=5571
764
- );
765
-
766
- // Fields to replace with ****
767
- $obfuscate_params = array(
768
- 'password',
769
- 'pass',
770
- 'pwd',
771
- 'pswd'
772
- );
773
-
774
- // Skip feilds with these strings and known service fields
775
- $skip_fields_with_strings = array(
776
- // Common
777
- 'ct_checkjs', //Do not send ct_checkjs
778
- 'nonce', //nonce for strings such as 'rsvp_nonce_name'
779
- 'security',
780
- // 'action',
781
- 'http_referer',
782
- 'referer-page',
783
- 'timestamp',
784
- 'captcha',
785
- // Formidable Form
786
- 'form_key',
787
- 'submit_entry',
788
- // Custom Contact Forms
789
- 'form_id',
790
- 'ccf_form',
791
- 'form_page',
792
- // Qu Forms
793
- 'iphorm_uid',
794
- 'form_url',
795
- 'post_id',
796
- 'iphorm_ajax',
797
- 'iphorm_id',
798
- // Fast SecureContact Froms
799
- 'fs_postonce_1',
800
- 'fscf_submitted',
801
- 'mailto_id',
802
- 'si_contact_action',
803
- // Ninja Forms
804
- 'formData_id',
805
- 'formData_settings',
806
- 'formData_fields_\d+_id',
807
- 'formData_fields_\d+_files.*',
808
- // E_signature
809
- 'recipient_signature',
810
- 'output_\d+_\w{0,2}',
811
- // Contact Form by Web-Settler protection
812
- '_formId',
813
- '_returnLink',
814
- // Social login and more
815
- '_save',
816
- '_facebook',
817
- '_social',
818
- 'user_login-',
819
- // Contact Form 7
820
- '_wpcf7',
821
- 'ebd_settings',
822
- 'ebd_downloads_',
823
- 'ecole_origine',
824
- 'signature',
825
- // Ultimate Form Builder
826
- 'form_data_%d_name',
827
- );
828
-
829
- // Reset $message if we have a sign-up data
830
- $skip_message_post = array(
831
- 'edd_action', // Easy Digital Downloads
832
- );
833
-
834
- if( apbct_array( array( $_POST, $_GET ) )->get_keys( $skip_params )->result() )
835
- $contact = false;
836
-
837
- $visible_fields = apbct_visible_fields__process( Cookie::get( 'apbct_visible_fields', array(), 'array' ) );
838
- $visible_fields_arr = isset( $visible_fields['visible_fields'] ) ? explode( ' ', $visible_fields['visible_fields'] ) : array();
839
-
840
- $nickname_default = true;
841
- if(is_array($nickname)) {
842
- foreach ($nickname as $v) {
843
- if($v) $nickname_default = false;
844
- }
845
- }
846
- if(is_string($nickname)) {
847
- $nickname_default = false;
848
- }
849
-
850
- if(count($arr)){
851
 
852
- foreach($arr as $key => $value){
853
-
854
- if( is_string( $value ) ){
855
-
856
- $tmp = strpos($value, '\\') !== false ? stripslashes($value) : $value;
857
-
858
- # Remove html tags from $value
859
- $tmp = preg_replace( '@<.*?>@', '', $tmp);
860
-
861
- $decoded_json_value = json_decode($tmp, true); // Try parse JSON from the string
862
- if( strpos( $value, "\n" ) === false || strpos( $value, "\r" ) === false ) {
863
- // Parse an only single-lined string
864
- parse_str( urldecode( $tmp ), $decoded_url_value ); // Try parse URL from the string
865
- }
866
-
867
- // If there is "JSON data" set is it as a value
868
- if($decoded_json_value !== null){
869
-
870
- if(isset($arr['action']) && $arr['action'] === 'nf_ajax_submit') {
871
- unset($decoded_json_value['settings']);
872
- }
873
-
874
- $value = $decoded_json_value;
875
-
876
- // If there is "URL data" set is it as a value
877
- }elseif( isset( $decoded_url_value ) && ! ( count( $decoded_url_value ) === 1 && reset( $decoded_url_value ) === '' ) ){
878
- $value = $decoded_url_value;
879
-
880
- // Ajax Contact Forms. Get data from such strings:
881
- // acfw30_name %% Blocked~acfw30_email %% s@cleantalk.org
882
- // acfw30_textarea %% msg
883
- }elseif(preg_match('/^\S+\s%%\s\S+.+$/', $value)){
884
-
885
- $value = explode('~', $value);
886
- foreach ($value as &$val){
887
- $tmp = explode(' %% ', $val);
888
- $val = array($tmp[0] => $tmp[1]);
889
- }unset( $val );
890
-
891
- }
892
- }
893
-
894
- if(!is_array($value) && !is_object($value)){
895
-
896
- if (in_array($key, $skip_params, true) && $key != 0 && $key != '' || preg_match("/^ct_checkjs/", $key))
897
- $contact = false;
898
-
899
- if($value === '')
900
- continue;
901
-
902
- // Skipping fields names with strings from (array)skip_fields_with_strings
903
- foreach($skip_fields_with_strings as $needle){
904
- if (preg_match("/".$needle."/", $prev_name.$key) == 1){
905
- continue(2);
906
- }
907
- }unset($needle);
908
-
909
- // Obfuscating params
910
- foreach($obfuscate_params as $needle){
911
- if (strpos($key, $needle) !== false){
912
- $value = ct_obfuscate_param($value);
913
- continue(2);
914
- }
915
- }unset($needle);
916
-
917
- $value_for_email = trim( strip_shortcodes( $value ) ); // Removes shortcodes to do better spam filtration on server side.
918
-
919
- // Email
920
- if ( ! $email && preg_match( "/^\S+@\S+\.\S+$/", $value_for_email ) ) {
921
- $email = $value_for_email;
922
-
923
- // Removes whitespaces
924
- $value = urldecode( trim( strip_shortcodes( $value ) ) ); // Fully cleaned message
925
-
926
- // Names
927
- // if there is an visible fields array then we take the name from it,
928
- // ignoring the hidden fields with name
929
- }elseif (
930
- $nickname_default &&
931
- preg_match("/name/i", $key) !== false &&
932
- (
933
- empty($visible_fields_arr) ||
934
- in_array($key, $visible_fields_arr)
935
- )
936
- ) {
937
- preg_match("/(name.?(your|first|for)|(your|first|for).?name)/", $key, $match_forename);
938
- preg_match("/(name.?(last|family|second|sur)|(last|family|second|sur).?name)/", $key, $match_surname);
939
- preg_match("/(name.?(nick|user)|(nick|user).?name)/", $key, $match_nickname);
940
-
941
- if(count($match_forename) > 1)
942
- $nickname['first'] = $value;
943
- elseif(count($match_surname) > 1)
944
- $nickname['last'] = $value;
945
- elseif(count($match_nickname) > 1)
946
- $nickname['nick'] = $value;
947
- else
948
- $message[$prev_name.$key] = $value;
949
- // Subject
950
- }elseif ($subject === null && preg_match("/subject/i", $key)){
951
- $subject = $value;
952
-
953
- // Message
954
- }else{
955
- $message[$prev_name.$key] = $value;
956
- }
957
-
958
- }elseif(!is_object($value)){
959
- $prev_name_original = $prev_name;
960
- $prev_name = ($prev_name === '' ? $key.'_' : $prev_name.$key.'_');
961
-
962
- $temp = ct_get_fields_any($value, $message, $email, $nickname, $subject, $contact, $prev_name);
963
-
964
- $message = $temp['message'];
965
- $email = ($temp['email'] ? $temp['email'] : null);
966
- $nickname = ($temp['nickname'] ? $temp['nickname'] : null);
967
- $subject = ($temp['subject'] ? $temp['subject'] : null);
968
- if($contact === true)
969
- $contact = ($temp['contact'] === false ? false : true);
970
- $prev_name = $prev_name_original;
971
- }
972
- } unset($key, $value);
973
- }
974
-
975
- foreach ($skip_message_post as $v) {
976
- if (isset($_POST[$v])) {
977
- $message = null;
978
- break;
979
- }
980
- } unset($v);
981
-
982
- //If top iteration, returns compiled name field. Example: "Nickname Firtsname Lastname".]
983
- if($nickname_default && $prev_name === ''){
984
- if(!empty($nickname)){
985
- $nickname_str = '';
986
- foreach($nickname as $value){
987
- $nickname_str .= ($value ? $value." " : "");
988
- }unset($value);
989
- }
990
- $nickname = $nickname_str;
991
- }
992
-
993
- $return_param = array(
994
- 'email' => $email,
995
- 'nickname' => $nickname,
996
- 'subject' => $subject,
997
- 'contact' => $contact,
998
- 'message' => $message
999
- );
1000
- return $return_param;
1001
  }
1002
 
1003
  /**
1004
- * Masks a value with asterisks (*)
1005
- * @return string
1006
  */
1007
- function ct_obfuscate_param($value = null) {
1008
- if ($value && (!is_object($value) || !is_array($value))) {
1009
- $length = strlen($value);
1010
- $value = str_repeat('*', $length);
1011
- }
1012
 
1013
- return $value;
1014
  }
1015
 
1016
  //New ct_get_fields_any_postdata
@@ -1175,7 +961,7 @@ function apbct__change_type_website_field( $fields ){
1175
 
1176
  if(isset($apbct->settings['comments__hide_website_field']) && $apbct->settings['comments__hide_website_field']) {
1177
  if(isset($fields['url']) && $fields['url']) {
1178
- $fields['url'] = '<input id="url" name="url" type="hidden" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" />';
1179
  }
1180
  }
1181
 
@@ -1192,6 +978,9 @@ function apbct__styles_if_website_hidden() {
1192
  if(isset($apbct->settings['comments__hide_website_field']) && $apbct->settings['comments__hide_website_field']) {
1193
  $styles = "
1194
  <style>
 
 
 
1195
  .comment-form-cookies-consent {
1196
  width:100%;
1197
  overflow: hidden;
4
  use Cleantalk\Antispam\CleantalkRequest;
5
  use Cleantalk\Antispam\CleantalkResponse;
6
  use Cleantalk\ApbctWP\API;
7
+ use Cleantalk\ApbctWP\GetFieldsAny;
8
  use Cleantalk\ApbctWP\Helper;
9
  use Cleantalk\ApbctWP\Variables\Cookie;
10
  use Cleantalk\Variables\Server;
151
  ? \Cleantalk\ApbctWP\Helper::array_merge__save_numeric_keys__recursive(apbct_get_sender_info(), (array)$params['sender_info'])
152
  : apbct_get_sender_info();
153
 
154
+ $honeypot_field = null;
155
 
156
+ if(isset($params['honeypot_field'])) {
157
+ $honeypot_field = $params['honeypot_field'];
158
  }
159
 
160
  $default_params = array(
173
  'agent' => APBCT_AGENT,
174
  'sender_info' => $sender_info,
175
  'submit_time' => apbct_get_submit_time(),
176
+ 'honeypot_field' => $honeypot_field
177
  );
178
 
179
  // Send $_SERVER if couldn't find IP
442
  'headers_sent__hook' => !empty($apbct->headers_sent__hook) ? $apbct->headers_sent__hook : 'no_hook',
443
  'headers_sent__where' => !empty($apbct->headers_sent__where) ? $apbct->headers_sent__where : false,
444
  'request_type' => apbct_get_server_variable('REQUEST_METHOD') ? apbct_get_server_variable('REQUEST_METHOD') : 'UNKNOWN',
445
+ 'email_check' => Cookie::get( 'ct_checked_emails' ) ? json_encode(Cookie::get( 'ct_checked_emails' )) : null,
446
+ 'screen_info' => Cookie::get( 'ct_screen_info' ) ? json_encode(Cookie::get( 'ct_screen_info' )) : null,
447
+ 'has_scrolled' => Cookie::get( 'ct_has_scrolled' ) ? json_encode(Cookie::get( 'ct_has_scrolled' )) : null,
448
  );
449
  }
450
 
473
  $fields = explode( ' ', $current_fields['visible_fields'] );
474
 
475
  // This fields belong this request
476
+ $fields_to_check = apbct_get_fields_to_check();
477
+ if( count( array_intersect( array_keys($fields_to_check), $fields ) ) > 0 ) {
478
  // WP Forms visible fields formatting
479
  if(strpos($visible_fields, 'wpforms') !== false){
480
  $visible_fields = preg_replace(
502
  return array();
503
  }
504
 
505
+ /**
506
+ * Get fields from POST to checking on visible fields.
507
+ *
508
+ * @return array
509
+ */
510
+ function apbct_get_fields_to_check() {
511
+ //Formidable fields
512
+ if( isset( $_POST['item_meta'] ) && is_array( $_POST['item_meta'] ) ) {
513
+ $fields = array();
514
+ foreach ( $_POST['item_meta'] as $key => $item ) {
515
+ $fields['item_meta['. $key .']'] = $item;
516
+ }
517
+ return $fields;
518
+ }
519
+ // @ToDo we have to implement a logic to find form fields (fields names, fields count) in serialized/nested/encoded items. not only $_POST.
520
+ return $_POST;
521
+ }
522
+
523
  /*
524
  * Outputs JS key for AJAX-use only. Stops script.
525
  */
526
+ function apbct_js_keys__get__ajax(){
527
 
528
  die( json_encode( array( 'js_key' => ct_get_checkjs_value() ) ) );
529
  }
768
  return null;
769
  }
770
 
771
+ /**
772
+ * Get data from an ARRAY recursively
773
+ *
774
+ * @param $arr
775
+ * @param array $message
776
+ * @param null $email
777
+ * @param array $nickname
778
+ * @param null $subject
779
+ * @param bool $contact
780
+ * @param string $prev_name
781
+ *
782
+ * @return array
783
+ * @deprecated Use ct_gfa()
784
+ */
785
  function ct_get_fields_any($arr, $message=array(), $email = null, $nickname = array('nick' => '', 'first' => '', 'last' => ''), $subject = null, $contact = true, $prev_name = ''){
786
 
787
+ return ct_gfa( $arr, $email, $nickname );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
788
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
789
  }
790
 
791
  /**
792
+ * Get data from an ARRAY recursively
793
+ * @return array
794
  */
795
+ function ct_gfa( $input_array, $email = '', $nickname = '' ) {
796
+
797
+ $gfa = new GetFieldsAny( $input_array );
798
+ return $gfa->getFields( $email, $nickname );
 
799
 
 
800
  }
801
 
802
  //New ct_get_fields_any_postdata
961
 
962
  if(isset($apbct->settings['comments__hide_website_field']) && $apbct->settings['comments__hide_website_field']) {
963
  if(isset($fields['url']) && $fields['url']) {
964
+ $fields['url'] = '<input id="honeypot-field-url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" />';
965
  }
966
  }
967
 
978
  if(isset($apbct->settings['comments__hide_website_field']) && $apbct->settings['comments__hide_website_field']) {
979
  $styles = "
980
  <style>
981
+ #honeypot-field-url {
982
+ display: none !important;
983
+ }
984
  .comment-form-cookies-consent {
985
  width:100%;
986
  overflow: hidden;
inc/cleantalk-pluggable.php CHANGED
@@ -477,6 +477,23 @@ function apbct_is_skip_request( $ajax = false ) {
477
  {
478
  return 'formidable_skip';
479
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
480
  break;
481
 
482
  case false :
@@ -520,7 +537,10 @@ function apbct_is_skip_request( $ajax = false ) {
520
  {
521
  return 'happyform_skipped';
522
  }
523
- if( apbct_is_plugin_active( 'essential-addons-for-elementor-lite/essential_adons_elementor.php' ) &&
 
 
 
524
  ( Post::get('eael-login-submit') !== '' && Post::get('eael-user-login') !== '' ) )
525
  {
526
  return 'eael_login_skipped';
477
  {
478
  return 'formidable_skip';
479
  }
480
+ // Artbees Jupiter theme saving settings
481
+ if ( Post::get( 'action' ) === 'mk_theme_save' && strpos( get_template(), 'jupiter' ) !== false ){
482
+ return 'artbees_jupiter_6_skip';
483
+ }
484
+ // fix conflict with wiloke theme and unknown plugin, that removes standard authorization cookies
485
+ if ( Post::get( 'action' ) === 'wiloke_themeoptions_ajax_save' && apbct_is_theme_active( 'wilcity' ) ){
486
+ return 'wiloke_themeoptions_ajax_save_skip';
487
+ }
488
+ // Essentials addons for elementor - light and pro
489
+ if(
490
+ ( apbct_is_plugin_active( 'essential-addons-for-elementor-lite/essential_adons_elementor.php' ) ||
491
+ apbct_is_plugin_active( 'essential-addons-elementor/essential_adons_elementor.php' ) ) &&
492
+ ( Post::get('eael-login-submit') !== '' && Post::get('eael-user-login') !== '' ) )
493
+ {
494
+ return 'eael_login_skipped';
495
+ }
496
+
497
  break;
498
 
499
  case false :
537
  {
538
  return 'happyform_skipped';
539
  }
540
+ // Essentials addons for elementor - light and pro
541
+ if(
542
+ ( apbct_is_plugin_active( 'essential-addons-for-elementor-lite/essential_adons_elementor.php' ) ||
543
+ apbct_is_plugin_active( 'essential-addons-elementor/essential_adons_elementor.php' ) ) &&
544
  ( Post::get('eael-login-submit') !== '' && Post::get('eael-user-login') !== '' ) )
545
  {
546
  return 'eael_login_skipped';
inc/cleantalk-public.php CHANGED
@@ -1091,7 +1091,7 @@ function apbct_hook__wp_footer() {
1091
  if( document.querySelectorAll('[name^=ct_checkjs]').length > 0 ) {
1092
  apbct_public_sendAJAX(
1093
  { action: 'apbct_js_keys__get' },
1094
- { callback: apbct_js_keys__set_input_value, no_nonce: true }
1095
  );
1096
  }
1097
  },". $timeout .");
@@ -1528,12 +1528,12 @@ function ct_preprocess_comment($comment) {
1528
  }
1529
  }
1530
 
1531
- // Add honeypot_website field
1532
- $honeypot_website = 0;
1533
 
1534
  if(isset($apbct->settings['comments__hide_website_field']) && $apbct->settings['comments__hide_website_field']) {
1535
  if(isset($_POST['url']) && !empty($_POST['url']) && $post_info['comment_type'] === 'comment' && isset($_POST['comment_post_ID'])) {
1536
- $honeypot_website = 1;
1537
  }
1538
  }
1539
 
@@ -1554,7 +1554,7 @@ function ct_preprocess_comment($comment) {
1554
  'page_url' => apbct_get_server_variable( 'HTTP_HOST' ) . apbct_get_server_variable( 'REQUEST_URI' ),
1555
  ))
1556
  ),
1557
- 'honeypot_website' => $honeypot_website
1558
  )
1559
  );
1560
  $ct_result = $base_call_result['ct_result'];
@@ -2017,12 +2017,16 @@ function apbct_login__scripts(){
2017
  wp_localize_script('ct_public', 'ctPublic', array(
2018
  '_ajax_nonce' => wp_create_nonce('ct_secret_stuff'),
2019
  '_rest_nonce' => wp_create_nonce('wp_rest'),
2020
- '_ajax_url' => admin_url('admin-ajax.php'),
2021
  '_rest_url' => esc_url( get_rest_url() ),
 
2022
  'pixel__setting' => $apbct->settings['data__pixel'],
2023
  'pixel__enabled' => $apbct->settings['data__pixel'] === '2' ||
2024
  ( $apbct->settings['data__pixel'] === '3' && apbct_is_cache_plugins_exists() ),
2025
  'pixel__url' => $apbct->pixel_url,
 
 
 
2026
  ));
2027
 
2028
  $apbct->public_script_loaded = true;
@@ -4144,14 +4148,16 @@ function ct_enqueue_scripts_public($hook){
4144
  wp_localize_script('ct_public', 'ctPublic', array(
4145
  '_ajax_nonce' => wp_create_nonce('ct_secret_stuff'),
4146
  '_rest_nonce' => wp_create_nonce('wp_rest'),
4147
- '_ajax_url' => admin_url('admin-ajax.php'),
4148
  '_rest_url' => esc_url( get_rest_url() ),
 
4149
  'data__set_cookies' => $apbct->settings['data__set_cookies'],
4150
  'data__set_cookies__alt_sessions_type' => $apbct->settings['data__set_cookies__alt_sessions_type'],
4151
  'pixel__setting' => $apbct->settings['data__pixel'],
4152
  'pixel__enabled' => $apbct->settings['data__pixel'] === '2' ||
4153
  ( $apbct->settings['data__pixel'] === '3' && apbct_is_cache_plugins_exists() ),
4154
  'pixel__url' => $apbct->pixel_url,
 
4155
  ));
4156
  }
4157
 
@@ -4175,7 +4181,7 @@ function ct_enqueue_scripts_public($hook){
4175
 
4176
  wp_enqueue_script('ct_nocache', plugins_url('/cleantalk-spam-protect/js/cleantalk_nocache.min.js'), array(), APBCT_VERSION, false /*in header*/);
4177
  wp_localize_script('ct_nocache', 'ctNocache', array(
4178
- 'ajaxurl' => admin_url('admin-ajax.php'),
4179
  'info_flag' => $apbct->settings['misc__collect_details'] && $apbct->settings['data__set_cookies'],
4180
  'set_cookies_flag' => (bool) $apbct->settings['data__set_cookies'],
4181
  'blog_home' => get_home_url().'/',
@@ -4217,7 +4223,7 @@ function ct_enqueue_scripts_public($hook){
4217
 
4218
  wp_localize_script('ct_public_admin_js', 'ctPublicAdmin', array(
4219
  'ct_ajax_nonce' => $ajax_nonce,
4220
- 'ajaxurl' => admin_url('admin-ajax.php'),
4221
  'ct_feedback_error' => __('Error occurred while sending feedback.', 'cleantalk-spam-protect'),
4222
  'ct_feedback_no_hash' => __('Feedback wasn\'t sent. There is no associated request.', 'cleantalk-spam-protect'),
4223
  'ct_feedback_msg' => sprintf(__("Feedback has been sent to %sCleanTalk Dashboard%s.", 'cleantalk-spam-protect'), $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>" : ''),
1091
  if( document.querySelectorAll('[name^=ct_checkjs]').length > 0 ) {
1092
  apbct_public_sendAJAX(
1093
  { action: 'apbct_js_keys__get' },
1094
+ { callback: apbct_js_keys__set_input_value, apbct_ajax: 1 }
1095
  );
1096
  }
1097
  },". $timeout .");
1528
  }
1529
  }
1530
 
1531
+ // Add honeypot_field field
1532
+ $honeypot_field = 1;
1533
 
1534
  if(isset($apbct->settings['comments__hide_website_field']) && $apbct->settings['comments__hide_website_field']) {
1535
  if(isset($_POST['url']) && !empty($_POST['url']) && $post_info['comment_type'] === 'comment' && isset($_POST['comment_post_ID'])) {
1536
+ $honeypot_field = 0;
1537
  }
1538
  }
1539
 
1554
  'page_url' => apbct_get_server_variable( 'HTTP_HOST' ) . apbct_get_server_variable( 'REQUEST_URI' ),
1555
  ))
1556
  ),
1557
+ 'honeypot_field' => $honeypot_field
1558
  )
1559
  );
1560
  $ct_result = $base_call_result['ct_result'];
2017
  wp_localize_script('ct_public', 'ctPublic', array(
2018
  '_ajax_nonce' => wp_create_nonce('ct_secret_stuff'),
2019
  '_rest_nonce' => wp_create_nonce('wp_rest'),
2020
+ '_ajax_url' => admin_url('admin-ajax.php', 'relative'),
2021
  '_rest_url' => esc_url( get_rest_url() ),
2022
+ '_apbct_ajax_url' => APBCT_URL_PATH . '/lib/Cleantalk/ApbctWP/Ajax.php',
2023
  'pixel__setting' => $apbct->settings['data__pixel'],
2024
  'pixel__enabled' => $apbct->settings['data__pixel'] === '2' ||
2025
  ( $apbct->settings['data__pixel'] === '3' && apbct_is_cache_plugins_exists() ),
2026
  'pixel__url' => $apbct->pixel_url,
2027
+ 'data__set_cookies' => $apbct->settings['data__set_cookies'],
2028
+ 'data__set_cookies__alt_sessions_type' => $apbct->settings['data__set_cookies__alt_sessions_type'],
2029
+ 'data__email_check_before_post' =>$apbct->settings['data__email_check_before_post'],
2030
  ));
2031
 
2032
  $apbct->public_script_loaded = true;
4148
  wp_localize_script('ct_public', 'ctPublic', array(
4149
  '_ajax_nonce' => wp_create_nonce('ct_secret_stuff'),
4150
  '_rest_nonce' => wp_create_nonce('wp_rest'),
4151
+ '_ajax_url' => admin_url('admin-ajax.php', 'relative'),
4152
  '_rest_url' => esc_url( get_rest_url() ),
4153
+ '_apbct_ajax_url' => APBCT_URL_PATH . '/lib/Cleantalk/ApbctWP/Ajax.php',
4154
  'data__set_cookies' => $apbct->settings['data__set_cookies'],
4155
  'data__set_cookies__alt_sessions_type' => $apbct->settings['data__set_cookies__alt_sessions_type'],
4156
  'pixel__setting' => $apbct->settings['data__pixel'],
4157
  'pixel__enabled' => $apbct->settings['data__pixel'] === '2' ||
4158
  ( $apbct->settings['data__pixel'] === '3' && apbct_is_cache_plugins_exists() ),
4159
  'pixel__url' => $apbct->pixel_url,
4160
+ 'data__email_check_before_post' =>$apbct->settings['data__email_check_before_post'],
4161
  ));
4162
  }
4163
 
4181
 
4182
  wp_enqueue_script('ct_nocache', plugins_url('/cleantalk-spam-protect/js/cleantalk_nocache.min.js'), array(), APBCT_VERSION, false /*in header*/);
4183
  wp_localize_script('ct_nocache', 'ctNocache', array(
4184
+ 'ajaxurl' => admin_url('admin-ajax.php', 'relative'),
4185
  'info_flag' => $apbct->settings['misc__collect_details'] && $apbct->settings['data__set_cookies'],
4186
  'set_cookies_flag' => (bool) $apbct->settings['data__set_cookies'],
4187
  'blog_home' => get_home_url().'/',
4223
 
4224
  wp_localize_script('ct_public_admin_js', 'ctPublicAdmin', array(
4225
  'ct_ajax_nonce' => $ajax_nonce,
4226
+ 'ajaxurl' => admin_url('admin-ajax.php', 'relative'),
4227
  'ct_feedback_error' => __('Error occurred while sending feedback.', 'cleantalk-spam-protect'),
4228
  'ct_feedback_no_hash' => __('Feedback wasn\'t sent. There is no associated request.', 'cleantalk-spam-protect'),
4229
  'ct_feedback_msg' => sprintf(__("Feedback has been sent to %sCleanTalk Dashboard%s.", 'cleantalk-spam-protect'), $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>" : ''),
inc/cleantalk-settings.php CHANGED
@@ -105,6 +105,7 @@ function apbct_settings__set_fileds( $fields ){
105
  'title' => __('SpamFireWall', 'cleantalk-spam-protect'),
106
  '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-spam-protect') . '<br>' .esc_html__( 'If the setting is turned on, plugin will automatically add IP address for each session with administration rights to Personal list in the cloud.', 'cleantalk-spam-protect' ),
107
  'childrens' => array('sfw__anti_flood', 'sfw__anti_crawler', 'sfw__use_delete_to_clear_table'),
 
108
  ),
109
  'sfw__anti_crawler' => array(
110
  'type' => 'checkbox',
@@ -293,7 +294,7 @@ function apbct_settings__set_fileds( $fields ){
293
  'description' => __('Options helps protect WordPress against spam with any caching plugins. Turn this option on to avoid issues with caching plugins. Turn off this option and SpamFireWall to be compatible with Accelerated mobile pages (AMP).', 'cleantalk-spam-protect'),
294
  ),
295
  'data__use_static_js_key' => array(
296
- 'title' => __('Use static keys for JS check.', 'cleantalk-spam-protect'),
297
  'description' => __('Could help if you have cache for AJAX requests and you are dealing with false positives. Slightly decreases protection quality. Auto - Static key will be used if caching plugin is spotted.', 'cleantalk-spam-protect'),
298
  'options' => array(
299
  array('val' => 1, 'label' => __('On'), ),
@@ -350,7 +351,7 @@ function apbct_settings__set_fileds( $fields ){
350
  'parent' => 'sfw__enabled',
351
  ),
352
  'data__pixel' => array(
353
- 'title' => __('Use attachment to improve IP-detection', 'cleantalk-spam-protect'),
354
  'description' => __('Upload small graphic file from Cleantalk\'s server to improve IP-detection.', 'cleantalk-spam-protect')
355
  . '<br>' . __('"Auto" use JavaScript option if cache solutions are found.', 'cleantalk-spam-protect'),
356
  'options' => array(
@@ -359,6 +360,10 @@ function apbct_settings__set_fileds( $fields ){
359
  array( 'val' => 3, 'label' => __( 'Auto', 'cleantalk-spam-protect' ), ),
360
  array( 'val' => 0, 'label' => __( 'Off', 'cleantalk-spam-protect' ), ),
361
  ),
 
 
 
 
362
  ),
363
  ),
364
  ),
@@ -521,19 +526,10 @@ function apbct_settings__set_fileds__network( $fields ){
521
  'type' => 'checkbox',
522
  'title' => __('Enable White Label Mode', 'cleantalk-spam-protect'),
523
  'description' => sprintf(__("Learn more information %shere%s.", 'cleantalk-spam-protect'), '<a target="_blank" href="https://cleantalk.org/ru/help/hosting-white-label">', '</a>'),
524
- 'childrens' => array( 'multisite__white_label__hoster_key', 'multisite__white_label__plugin_name', 'multisite__allow_custom_key', ),
525
  'disabled' => defined('CLEANTALK_ACCESS_KEY'),
526
  'network' => true,
527
  ),
528
- 'multisite__white_label__hoster_key' => array(
529
- 'title' => __('Hoster API Key', 'cleantalk-spam-protect'),
530
- 'description' => sprintf(__("You can get it in %sCleantalk's Control Panel%s", 'cleantalk-spam-protect'), '<a target="_blank" href="https://cleantalk.org/my/profile">', '</a>'),
531
- 'type' => 'text',
532
- 'parent' => 'multisite__white_label',
533
- 'class' => 'apbct_settings-field_wrapper--sub',
534
- 'network' => true,
535
- 'required' => true,
536
- ),
537
  'multisite__white_label__plugin_name' => array(
538
  'title' => __('Plugin name', 'cleantalk-spam-protect'),
539
  'description' => sprintf(__("Specify plugin name. Leave empty for deafult %sAntispam by Cleantalk%s", 'cleantalk-spam-protect'), '<b>', '</b>'),
@@ -541,11 +537,10 @@ function apbct_settings__set_fileds__network( $fields ){
541
  'parent' => 'multisite__white_label',
542
  'class' => 'apbct_settings-field_wrapper--sub',
543
  'network' => true,
544
- 'required' => true,
545
  ),
546
  'multisite__allow_custom_key' => array(
547
  'type' => 'checkbox',
548
- 'title' => __('Allow users to use other key', 'cleantalk-spam-protect'),
549
  'description' => __('Allow users to use different Access key in their plugin settings on child blogs. They could use different CleanTalk account.', 'cleantalk-spam-protect')
550
  . (defined('CLEANTALK_ACCESS_KEY')
551
  ? ' <span style="color: red">'
@@ -1508,14 +1503,13 @@ function apbct_settings__validate($settings) {
1508
  'multisite__allow_custom_key' => $settings['multisite__allow_custom_key'],
1509
  'multisite__allow_custom_settings' => $settings['multisite__allow_custom_settings'],
1510
  'multisite__white_label' => $settings['multisite__white_label'],
1511
- 'multisite__white_label__hoster_key' => $settings['multisite__white_label__hoster_key'],
1512
  'multisite__white_label__plugin_name' => $settings['multisite__white_label__plugin_name'],
1513
  'multisite__use_settings_template' => $settings['multisite__use_settings_template'],
1514
  'multisite__use_settings_template_apply_for_new' => $settings['multisite__use_settings_template_apply_for_new'],
1515
  'multisite__use_settings_template_apply_for_current' => $settings['multisite__use_settings_template_apply_for_current'],
1516
  'multisite__use_settings_template_apply_for_current_list_sites' => $settings['multisite__use_settings_template_apply_for_current_list_sites'],
1517
  );
1518
- unset( $settings['multisite__allow_custom_key'], $settings['multisite__white_label'], $settings['multisite__white_label__hoster_key'], $settings['multisite__white_label__plugin_name'] );
1519
  }
1520
 
1521
  // Drop debug data
@@ -1627,8 +1621,7 @@ function apbct_settings__sync( $direct_call = false ){
1627
  if(is_main_site()){
1628
 
1629
  // Network settings
1630
- $network_settings['apikey'] = $apbct->settings['apikey'];
1631
- $apbct->network_settings = $network_settings;
1632
  $apbct->saveNetworkSettings();
1633
 
1634
  // Network data
@@ -1698,19 +1691,19 @@ function apbct_settings__get_key_auto( $direct_call = false ) {
1698
  $language = apbct_get_server_variable( 'HTTP_ACCEPT_LANGUAGE' );
1699
  $wpms = APBCT_WPMS && defined('SUBDOMAIN_INSTALL') && !SUBDOMAIN_INSTALL ? true : false;
1700
  $white_label = $apbct->network_settings['multisite__white_label'] ? 1 : 0;
1701
- $hoster_api_key = $apbct->network_settings['multisite__white_label__hoster_key'] ? $apbct->network_settings['multisite__white_label__hoster_key'] : '';
1702
-
1703
- $result = \Cleantalk\ApbctWP\API::method__get_api_key(
1704
- ! is_main_site() && $apbct->white_label ? 'anti-spam-hosting' : 'antispam',
1705
- ct_get_admin_email(),
 
1706
  $website,
1707
  $platform,
1708
  $timezone,
1709
  $language,
1710
  $user_ip,
1711
  $wpms,
1712
- $white_label,
1713
- $hoster_api_key
1714
  );
1715
 
1716
  if(empty($result['error'])){
105
  'title' => __('SpamFireWall', 'cleantalk-spam-protect'),
106
  '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-spam-protect') . '<br>' .esc_html__( 'If the setting is turned on, plugin will automatically add IP address for each session with administration rights to Personal list in the cloud.', 'cleantalk-spam-protect' ),
107
  'childrens' => array('sfw__anti_flood', 'sfw__anti_crawler', 'sfw__use_delete_to_clear_table'),
108
+ 'disabled' => (bool) $apbct->data['notice_incompatibility'],
109
  ),
110
  'sfw__anti_crawler' => array(
111
  'type' => 'checkbox',
294
  'description' => __('Options helps protect WordPress against spam with any caching plugins. Turn this option on to avoid issues with caching plugins. Turn off this option and SpamFireWall to be compatible with Accelerated mobile pages (AMP).', 'cleantalk-spam-protect'),
295
  ),
296
  'data__use_static_js_key' => array(
297
+ 'title' => __('Use static keys for JavaScript check', 'cleantalk-spam-protect'),
298
  'description' => __('Could help if you have cache for AJAX requests and you are dealing with false positives. Slightly decreases protection quality. Auto - Static key will be used if caching plugin is spotted.', 'cleantalk-spam-protect'),
299
  'options' => array(
300
  array('val' => 1, 'label' => __('On'), ),
351
  'parent' => 'sfw__enabled',
352
  ),
353
  'data__pixel' => array(
354
+ 'title' => __('Add a CleanTalk Pixel to improve IP-detection', 'cleantalk-spam-protect'),
355
  'description' => __('Upload small graphic file from Cleantalk\'s server to improve IP-detection.', 'cleantalk-spam-protect')
356
  . '<br>' . __('"Auto" use JavaScript option if cache solutions are found.', 'cleantalk-spam-protect'),
357
  'options' => array(
360
  array( 'val' => 3, 'label' => __( 'Auto', 'cleantalk-spam-protect' ), ),
361
  array( 'val' => 0, 'label' => __( 'Off', 'cleantalk-spam-protect' ), ),
362
  ),
363
+ ),
364
+ 'data__email_check_before_post' => array(
365
+ 'title' => __('Check email before POST request', 'cleantalk-spam-protect'),
366
+ 'description' => __('Check email address before sending form data', 'cleantalk-spam-protect'),
367
  ),
368
  ),
369
  ),
526
  'type' => 'checkbox',
527
  'title' => __('Enable White Label Mode', 'cleantalk-spam-protect'),
528
  'description' => sprintf(__("Learn more information %shere%s.", 'cleantalk-spam-protect'), '<a target="_blank" href="https://cleantalk.org/ru/help/hosting-white-label">', '</a>'),
529
+ 'childrens' => array( 'multisite__white_label__plugin_name', 'multisite__allow_custom_key', ),
530
  'disabled' => defined('CLEANTALK_ACCESS_KEY'),
531
  'network' => true,
532
  ),
 
 
 
 
 
 
 
 
 
533
  'multisite__white_label__plugin_name' => array(
534
  'title' => __('Plugin name', 'cleantalk-spam-protect'),
535
  'description' => sprintf(__("Specify plugin name. Leave empty for deafult %sAntispam by Cleantalk%s", 'cleantalk-spam-protect'), '<b>', '</b>'),
537
  'parent' => 'multisite__white_label',
538
  'class' => 'apbct_settings-field_wrapper--sub',
539
  'network' => true,
 
540
  ),
541
  'multisite__allow_custom_key' => array(
542
  'type' => 'checkbox',
543
+ 'title' => __('Allow users to use own key', 'cleantalk-spam-protect'),
544
  'description' => __('Allow users to use different Access key in their plugin settings on child blogs. They could use different CleanTalk account.', 'cleantalk-spam-protect')
545
  . (defined('CLEANTALK_ACCESS_KEY')
546
  ? ' <span style="color: red">'
1503
  'multisite__allow_custom_key' => $settings['multisite__allow_custom_key'],
1504
  'multisite__allow_custom_settings' => $settings['multisite__allow_custom_settings'],
1505
  'multisite__white_label' => $settings['multisite__white_label'],
 
1506
  'multisite__white_label__plugin_name' => $settings['multisite__white_label__plugin_name'],
1507
  'multisite__use_settings_template' => $settings['multisite__use_settings_template'],
1508
  'multisite__use_settings_template_apply_for_new' => $settings['multisite__use_settings_template_apply_for_new'],
1509
  'multisite__use_settings_template_apply_for_current' => $settings['multisite__use_settings_template_apply_for_current'],
1510
  'multisite__use_settings_template_apply_for_current_list_sites' => $settings['multisite__use_settings_template_apply_for_current_list_sites'],
1511
  );
1512
+ unset( $settings['multisite__allow_custom_key'], $settings['multisite__white_label'], $settings['multisite__white_label__plugin_name'] );
1513
  }
1514
 
1515
  // Drop debug data
1621
  if(is_main_site()){
1622
 
1623
  // Network settings
1624
+ $apbct->network_settings['apikey'] = $apbct->settings['apikey'];
 
1625
  $apbct->saveNetworkSettings();
1626
 
1627
  // Network data
1691
  $language = apbct_get_server_variable( 'HTTP_ACCEPT_LANGUAGE' );
1692
  $wpms = APBCT_WPMS && defined('SUBDOMAIN_INSTALL') && !SUBDOMAIN_INSTALL ? true : false;
1693
  $white_label = $apbct->network_settings['multisite__white_label'] ? 1 : 0;
1694
+ $admin_email = get_option('admin_email');
1695
+ if (function_exists('is_multisite') && is_multisite() && $apbct->white_label) {
1696
+ $admin_email = get_site_option( 'admin_email' );
1697
+ }
1698
+ $result = \Cleantalk\ApbctWP\API::method__get_api_key('antispam',
1699
+ $admin_email,
1700
  $website,
1701
  $platform,
1702
  $timezone,
1703
  $language,
1704
  $user_ip,
1705
  $wpms,
1706
+ $white_label
 
1707
  );
1708
 
1709
  if(empty($result['error'])){
inc/cleantalk-updater.php CHANGED
@@ -362,7 +362,6 @@ function apbct_update_to_5_127_0(){
362
  if( defined( 'APBCT_WHITELABEL' ) ){
363
  $apbct->network_settings = array(
364
  'white_label' => defined( 'APBCT_WHITELABEL' ) && APBCT_WHITELABEL == true ? 1 : 0,
365
- 'white_label__hoster_key' => defined( 'APBCT_HOSTER_API_KEY' ) ? APBCT_HOSTER_API_KEY : '',
366
  'white_label__plugin_name' => defined( 'APBCT_WHITELABEL_NAME' ) ? APBCT_WHITELABEL_NAME : APBCT_NAME,
367
  );
368
  }elseif( defined( 'CLEANTALK_ACCESS_KEY' ) ){
@@ -810,7 +809,6 @@ function apbct_update_to_5_154_0(){
810
  'allow_custom_key' => 'multisite__allow_custom_key',
811
  'allow_custom_settings' => 'multisite__allow_custom_settings',
812
  'white_label' => 'multisite__white_label',
813
- 'white_label__hoster_key' => 'multisite__white_label__hoster_key',
814
  'white_label__plugin_name' => 'multisite__white_label__plugin_name',
815
  'use_settings_template' => 'multisite__use_settings_template',
816
  'use_settings_template_apply_for_new' => 'multisite__use_settings_template_apply_for_new',
@@ -983,4 +981,10 @@ function apbct_update_to_5_158_0(){
983
  $apbct->settings['data__pixel'] = '0';
984
  $apbct->saveSettings();
985
  }
986
- }
 
 
 
 
 
 
362
  if( defined( 'APBCT_WHITELABEL' ) ){
363
  $apbct->network_settings = array(
364
  'white_label' => defined( 'APBCT_WHITELABEL' ) && APBCT_WHITELABEL == true ? 1 : 0,
 
365
  'white_label__plugin_name' => defined( 'APBCT_WHITELABEL_NAME' ) ? APBCT_WHITELABEL_NAME : APBCT_NAME,
366
  );
367
  }elseif( defined( 'CLEANTALK_ACCESS_KEY' ) ){
809
  'allow_custom_key' => 'multisite__allow_custom_key',
810
  'allow_custom_settings' => 'multisite__allow_custom_settings',
811
  'white_label' => 'multisite__white_label',
 
812
  'white_label__plugin_name' => 'multisite__white_label__plugin_name',
813
  'use_settings_template' => 'multisite__use_settings_template',
814
  'use_settings_template_apply_for_new' => 'multisite__use_settings_template_apply_for_new',
981
  $apbct->settings['data__pixel'] = '0';
982
  $apbct->saveSettings();
983
  }
984
+ }
985
+
986
+ function apbct_update_to_5_158_2() {
987
+ global $apbct;
988
+ $apbct->stats['cron']['last_start'] = 0;
989
+ $apbct->save('stats');
990
+ }
js/apbct-public.min.js CHANGED
@@ -1,2 +1,2 @@
1
- function ctSetCookie(e,t,n){var o;("string"==typeof e&&"string"==typeof t||"number"==typeof t)&&(o="ct_pointer_data"===e||"ct_user_info"===e,e=[[e,t,n]]),0==+ctPublic.data__set_cookies||(1==+ctPublic.data__set_cookies?e.forEach(function(e,t,n){var o=void 0!==e[2]?"expires="+o+"; ":"",i="https:"===location.protocol?"; secure":"";document.cookie=e[0]+"="+encodeURIComponent(e[1])+"; "+o+"path=/; samesite=lax"+i}):2!=+ctPublic.data__set_cookies||o||(1==+ctPublic.data__set_cookies__alt_sessions_type?apbct_public_sendREST("alt_sessions",{method:"POST",data:{cookies:e}}):2==+ctPublic.data__set_cookies__alt_sessions_type&&apbct_public_sendAJAX({action:"apbct_alt_session__save__AJAX",cookies:e},{})))}function apbct_collect_visible_fields(e){var t,n=[],o="",i=0,c="",s=0,a=[];for(t in e.elements)isNaN(+t)||(n[t]=e.elements[t]);return(n=n.filter(function(e){return-1===a.indexOf(e.getAttribute("name"))&&(-1===["radio","checkbox"].indexOf(e.getAttribute("type"))||(a.push(e.getAttribute("name")),!1))})).forEach(function(e,t,n){"submit"!==e.getAttribute("type")&&null!==e.getAttribute("name")&&"ct_checkjs"!==e.getAttribute("name")&&("none"!==getComputedStyle(e).display&&"hidden"!==getComputedStyle(e).visibility&&"0"!==getComputedStyle(e).opacity&&"hidden"!==e.getAttribute("type")||e.classList.contains("wp-editor-area")?(o+=" "+e.getAttribute("name"),i++):(c+=" "+e.getAttribute("name"),s++))}),c=c.trim(),{visible_fields:o=o.trim(),visible_fields_count:i,invisible_fields:c,invisible_fields_count:s}}function apbct_visible_fields_set_cookie(e){e="object"==typeof e&&null!==e?e:{};ctSetCookie("apbct_visible_fields",JSON.stringify(e))}function apbct_js_keys__set_input_value(e,t,n,o){if(0<document.querySelectorAll("[name^=ct_checkjs]").length)for(var i=document.querySelectorAll("[name^=ct_checkjs]"),c=0;c<i.length;c++)i[c].value=e.js_key}function apbct_public_sendAJAX(t,n,o){var i=n.callback||null,c=n.callback_context||null,s=n.callback_params||null,e=n.async||!0,a=n.notJson||null,l=n.timeout||15e3,o=o||null,r=n.button||null,u=n.spinner||null,_=n.progressbar||null,p=n.silent||null,d=n.no_nonce||null;"string"==typeof t?t=(t=!d?t+"&_ajax_nonce="+ctPublic._ajax_nonce:t)+"&no_cache="+Math.random():(d||(t._ajax_nonce=ctPublic._ajax_nonce),t.no_cache=Math.random()),r&&(r.setAttribute("disabled","disabled"),r.style.cursor="not-allowed"),u&&jQuery(u).css("display","inline"),jQuery.ajax({type:"POST",url:ctPublic._ajax_url,data:t,async:e,success:function(e){r&&(r.removeAttribute("disabled"),r.style.cursor="pointer"),u&&jQuery(u).css("display","none"),(e=!a?JSON.parse(e):e).error?(setTimeout(function(){_&&_.fadeOut("slow")},1e3),console.log("Error happens: "+(e.error||"Unkown"))):i&&(s?i.apply(c,s.concat(e,t,n,o)):i(e,t,n,o))},error:function(e,t,n){r&&(r.removeAttribute("disabled"),r.style.cursor="pointer"),u&&jQuery(u).css("display","none"),n&&!p&&(console.log("APBCT_AJAX_ERROR"),console.log(e),console.log(t),console.log("Anti-spam by Cleantalk plugin error: "+n+"Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/"))},timeout:l})}function apbct_public_sendREST(t,n){var o=n.callback||null,e=n.data||[],i=n.method||"POST";jQuery.ajax({type:i,url:ctPublic._rest_url+"cleantalk-antispam/v1/"+t,data:e,beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",ctPublic._rest_nonce)},success:function(e){e.error?console.log("Error happens: "+(e.error||"Unknown")):o&&o(e,t,n,null)},error:function(e,t,n){n&&(console.log("APBCT_REST_ERROR"),console.log(e),console.log(t),console.log("Anti-spam by Cleantalk plugin REST API error: "+n+" Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/"))}})}!function(){var e=new Date,t=(new Date).getTime(),n=!0,o=[],i=0;function c(e,t,n){"function"==typeof window.addEventListener?e.addEventListener(t,n):e.attachEvent(t,n)}function s(e,t,n){"function"==typeof window.removeEventListener?e.removeEventListener(t,n):e.detachEvent(t,n)}ctSetCookie([["ct_ps_timestamp",Math.floor((new Date).getTime()/1e3)],["ct_fkp_timestamp","0"],["ct_pointer_data","0"],["ct_timezone",e.getTimezoneOffset()/60*-1],["apbct_visible_fields","0"]]);var a=function(e){ctSetCookie("ct_fkp_timestamp",Math.floor((new Date).getTime()/1e3)),s(window,"mousedown",a),s(window,"keydown",a)},l=setInterval(function(){n=!0},150),r=setInterval(function(){ctSetCookie("ct_pointer_data",JSON.stringify(o))},1200),u=function(e){!0===n&&(o.push([Math.round(e.clientY),Math.round(e.clientX),Math.round((new Date).getTime()-t)]),n=!1,50<=++i&&(s(window,"mousemove",u),clearInterval(l),clearInterval(r)))};c(window,"mousemove",u),c(window,"mousedown",a),c(window,"keydown",a),c(window,"DOMContentLoaded",function(){+ctPublic.pixel__setting&&(ctSetCookie("apbct_pixel_url",ctPublic.pixel__url),+ctPublic.pixel__enabled&&jQuery("body").append('<img style="display: none; left: 99999px;" src="'+ctPublic.pixel__url+'">')),setTimeout(function(){for(var e={},t=0;t<document.forms.length;t++){var n=document.forms[t];n.classList.contains("slp_search_form")||n.parentElement.classList.contains("mec-booking")||-1!==n.action.toString().indexOf("activehosted.com")||n.id&&"caspioform"==n.id||n.name.classList&&n.name.classList.contains("tinkoffPayRow")||n.name.classList&&n.name.classList.contains("give-form ")||(e[t]=apbct_collect_visible_fields(n),n.onsubmit_prev=n.onsubmit,n.onsubmit=function(e){var t={};t[0]=apbct_collect_visible_fields(this),apbct_visible_fields_set_cookie(t),e.target.onsubmit_prev instanceof Function&&setTimeout(function(){e.target.onsubmit_prev.call(e.target,e)},500)})}apbct_visible_fields_set_cookie(e)},1e3)})}(),"undefined"!=typeof jQuery&&jQuery(document).ajaxComplete(function(e,t,n){!t.responseText||-1===t.responseText.indexOf('"apbct')||void 0!==(t=JSON.parse(t.responseText)).apbct&&(t=t.apbct).blocked&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:t.comment}})),cleantalkModal.loaded=t.comment,cleantalkModal.open(),1==+t.stop_script&&window.stop())});
2
  //# sourceMappingURL=apbct-public.min.js.map
1
+ function ctSetCookie(e,t,n){var o;("string"==typeof e&&"string"==typeof t||"number"==typeof t)&&(o="ct_pointer_data"===e||"ct_user_info"===e,e=[[e,t,n]]),0!=+ctPublic.data__set_cookies&&(1==+ctPublic.data__set_cookies?e.forEach(function(e,t,n){var o=void 0!==e[2]?"expires="+o+"; ":"",i="https:"===location.protocol?"; secure":"";document.cookie=e[0]+"="+encodeURIComponent(e[1])+"; "+o+"path=/; samesite=lax"+i}):2!=+ctPublic.data__set_cookies||o||(1==+ctPublic.data__set_cookies__alt_sessions_type?apbct_public_sendREST("alt_sessions",{method:"POST",data:{cookies:e}}):2==+ctPublic.data__set_cookies__alt_sessions_type&&apbct_public_sendAJAX({action:"apbct_alt_session__save__AJAX",cookies:e},{apbct_ajax:1,notJson:1})))}function apbct_collect_visible_fields(e){var t=[],o="",i=0,c="",a=0,n=[];for(var l in e.elements)isNaN(+l)||(t[l]=e.elements[l]);return(t=t.filter(function(e){return-1===n.indexOf(e.getAttribute("name"))&&(-1===["radio","checkbox"].indexOf(e.getAttribute("type"))||(n.push(e.getAttribute("name")),!1))})).forEach(function(e,t,n){"submit"!==e.getAttribute("type")&&null!==e.getAttribute("name")&&"ct_checkjs"!==e.getAttribute("name")&&("none"!==getComputedStyle(e).display&&"hidden"!==getComputedStyle(e).visibility&&"0"!==getComputedStyle(e).opacity&&"hidden"!==e.getAttribute("type")||e.classList.contains("wp-editor-area")?(o+=" "+e.getAttribute("name"),i++):(c+=" "+e.getAttribute("name"),a++))}),c=c.trim(),{visible_fields:o=o.trim(),visible_fields_count:i,invisible_fields:c,invisible_fields_count:a}}function apbct_visible_fields_set_cookie(e){var t="object"==typeof e&&null!==e?e:{};ctSetCookie("apbct_visible_fields",JSON.stringify(t))}function apbct_js_keys__set_input_value(e,t,n,o){if(0<document.querySelectorAll("[name^=ct_checkjs]").length)for(var i=document.querySelectorAll("[name^=ct_checkjs]"),c=0;c<i.length;c++)i[c].value=e.js_key}function apbct_public_sendAJAX(t,n,o){var i=n.callback||null,c=n.callback_context||null,a=n.callback_params||null,e=n.async||!0,l=n.notJson||null,s=n.timeout||15e3,o=o||null,r=n.button||null,u=n.spinner||null,_=n.progressbar||null,d=n.silent||null,p=n.no_nonce||null,m=n.apbct_ajax||null;"string"==typeof t?(p||(t=t+"&_ajax_nonce="+ctPublic._ajax_nonce),t=t+"&no_cache="+Math.random()):(p||(t._ajax_nonce=ctPublic._ajax_nonce),t.no_cache=Math.random()),r&&(r.setAttribute("disabled","disabled"),r.style.cursor="not-allowed"),u&&jQuery(u).css("display","inline"),jQuery.ajax({type:"POST",url:m?ctPublic._apbct_ajax_url:ctPublic._ajax_url,data:t,async:e,success:function(e){r&&(r.removeAttribute("disabled"),r.style.cursor="pointer"),u&&jQuery(u).css("display","none"),l||(e=JSON.parse(e)),e.error?(setTimeout(function(){_&&_.fadeOut("slow")},1e3),console.log("Error happens: "+(e.error||"Unkown"))):i&&(a?i.apply(c,a.concat(e,t,n,o)):i(e,t,n,o))},error:function(e,t,n){r&&(r.removeAttribute("disabled"),r.style.cursor="pointer"),u&&jQuery(u).css("display","none"),n&&!d&&(console.log("APBCT_AJAX_ERROR"),console.log(e),console.log(t),console.log("Anti-spam by Cleantalk plugin error: "+n+"Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/"))},timeout:s})}function apbct_public_sendREST(t,n){var o=n.callback||null,e=n.data||[],i=n.method||"POST";jQuery.ajax({type:i,url:ctPublic._rest_url+"cleantalk-antispam/v1/"+t,data:e,beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",ctPublic._rest_nonce)},success:function(e){e.error?console.log("Error happens: "+(e.error||"Unknown")):o&&o(e,t,n,null)},error:function(e,t,n){n&&(console.log("APBCT_REST_ERROR"),console.log(e),console.log(t),console.log("Anti-spam by Cleantalk plugin REST API error: "+n+" Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/"))}})}function apbctGetScreenInfo(){return JSON.stringify({fullWidth:document.documentElement.scrollWidth,fullHeight:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight),visibleWidth:document.documentElement.clientWidth,visibleHeight:document.documentElement.clientHeight})}!function(){var e=new Date,t=(new Date).getTime(),n=!0,o=[],i=0,c={},a=!1;function l(e,t,n){"function"==typeof window.addEventListener?e.addEventListener(t,n):e.attachEvent(t,n)}function s(e,t,n){"function"==typeof window.removeEventListener?e.removeEventListener(t,n):e.detachEvent(t,n)}ctSetCookie([["ct_ps_timestamp",Math.floor((new Date).getTime()/1e3)],["ct_fkp_timestamp","0"],["ct_pointer_data","0"],["ct_timezone",e.getTimezoneOffset()/60*-1],["apbct_visible_fields","0"]]);var r=function(){ctSetCookie("ct_fkp_timestamp",Math.floor((new Date).getTime()/1e3)),s(window,"mousedown",r),s(window,"keydown",r)},u=setInterval(function(){n=!0},150),_=setInterval(function(){ctSetCookie("ct_pointer_data",JSON.stringify(o))},1200),d=function(e){!0===n&&(o.push([Math.round(e.clientY),Math.round(e.clientX),Math.round((new Date).getTime()-t)]),n=!1,50<=++i&&(s(window,"mousemove",d),clearInterval(u),clearInterval(_)))};function p(e){var t=e.target.value;!t||t in c||apbct_public_sendAJAX({action:"apbct_email_check_before_post",data:{email:t}},{apbct_ajax:1,callback:function(e){e.result&&(c[t]={result:e.result,timestamp:Date.now()/1e3|0},ctSetCookie("ct_checked_emails",JSON.stringify(c)))}})}l(window,"mousemove",d),l(window,"mousedown",r),l(window,"keydown",r),l(window,"scroll",function(){a||(ctSetCookie("ct_has_scrolled",JSON.stringify(!0)),a=!0)}),l(window,"DOMContentLoaded",function(){+ctPublic.pixel__setting&&(ctSetCookie("apbct_pixel_url",ctPublic.pixel__url),+ctPublic.pixel__enabled&&jQuery("body").append('<img style="display: none; left: 99999px;" src="'+ctPublic.pixel__url+'">')),+ctPublic.data__email_check_before_post&&(ctSetCookie("ct_checked_emails","0"),jQuery("input[type = 'email'], #email").blur(p)),ctSetCookie("ct_screen_info",apbctGetScreenInfo()),ctSetCookie("ct_has_scrolled",JSON.stringify(!1)),setTimeout(function(){for(var e={},t=0;t<document.forms.length;t++){var n=document.forms[t];n.classList.contains("slp_search_form")||n.parentElement.classList.contains("mec-booking")||-1!==n.action.toString().indexOf("activehosted.com")||n.id&&"caspioform"==n.id||n.name.classList&&n.name.classList.contains("tinkoffPayRow")||n.name.classList&&n.name.classList.contains("give-form ")||(e[t]=apbct_collect_visible_fields(n),n.onsubmit_prev=n.onsubmit,n.onsubmit=function(e){var t={};t[0]=apbct_collect_visible_fields(this),apbct_visible_fields_set_cookie(t),e.target.onsubmit_prev instanceof Function&&setTimeout(function(){e.target.onsubmit_prev.call(e.target,e)},500)})}apbct_visible_fields_set_cookie(e)},1e3)})}(),"undefined"!=typeof jQuery&&jQuery(document).ajaxComplete(function(e,t,n){var o;!t.responseText||-1===t.responseText.indexOf('"apbct')||void 0!==(o=JSON.parse(t.responseText)).apbct&&(o=o.apbct).blocked&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:o.comment}})),cleantalkModal.loaded=o.comment,cleantalkModal.open(),1==+o.stop_script&&window.stop())});
2
  //# sourceMappingURL=apbct-public.min.js.map
js/apbct-public.min.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"apbct-public.min.js","sources":["apbct-public.js"],"sourcesContent":["(function() {\n\n\tvar ct_date = new Date(),\n\t\tctTimeMs = new Date().getTime(),\n\t\tctMouseEventTimerFlag = true, //Reading interval flag\n\t\tctMouseData = [],\n\t\tctMouseDataCounter = 0;\n\n\tfunction apbct_attach_event_handler(elem, event, callback){\n\t\tif(typeof window.addEventListener === \"function\") elem.addEventListener(event, callback);\n\t\telse elem.attachEvent(event, callback);\n\t}\n\n\tfunction apbct_remove_event_handler(elem, event, callback){\n\t\tif(typeof window.removeEventListener === \"function\") elem.removeEventListener(event, callback);\n\t\telse elem.detachEvent(event, callback);\n\t}\n\n\tctSetCookie(\n\t\t[\n\t\t\t[ \"ct_ps_timestamp\", Math.floor(new Date().getTime() / 1000) ],\n\t\t\t[ \"ct_fkp_timestamp\", \"0\" ],\n\t\t\t[ \"ct_pointer_data\", \"0\" ],\n\t\t\t[ \"ct_timezone\", ct_date.getTimezoneOffset()/60*(-1) ],\n\t\t\t[ \"apbct_visible_fields\", \"0\" ],\n\t\t]\n\t);\n\n\t//Writing first key press timestamp\n\tvar ctFunctionFirstKey = function output(event){\n\t\tvar KeyTimestamp = Math.floor(new Date().getTime()/1000);\n\t\tctSetCookie(\"ct_fkp_timestamp\", KeyTimestamp);\n\t\tctKeyStopStopListening();\n\t};\n\n\t//Reading interval\n\tvar ctMouseReadInterval = setInterval(function(){\n\t\tctMouseEventTimerFlag = true;\n\t}, 150);\n\n\t//Writting interval\n\tvar ctMouseWriteDataInterval = setInterval(function(){\n\t\tctSetCookie(\"ct_pointer_data\", JSON.stringify(ctMouseData));\n\t}, 1200);\n\n\t//Logging mouse position each 150 ms\n\tvar ctFunctionMouseMove = function output(event){\n\t\tif(ctMouseEventTimerFlag === true){\n\n\t\t\tctMouseData.push([\n\t\t\t\tMath.round(event.clientY),\n\t\t\t\tMath.round(event.clientX),\n\t\t\t\tMath.round(new Date().getTime() - ctTimeMs)\n\t\t\t]);\n\n\t\t\tctMouseDataCounter++;\n\t\t\tctMouseEventTimerFlag = false;\n\t\t\tif(ctMouseDataCounter >= 50){\n\t\t\t\tctMouseStopData();\n\t\t\t}\n\t\t}\n\t};\n\n\t//Stop mouse observing function\n\tfunction ctMouseStopData(){\n\t\tapbct_remove_event_handler(window, \"mousemove\", ctFunctionMouseMove);\n\t\tclearInterval(ctMouseReadInterval);\n\t\tclearInterval(ctMouseWriteDataInterval);\n\t}\n\n\t//Stop key listening function\n\tfunction ctKeyStopStopListening(){\n\t\tapbct_remove_event_handler(window, \"mousedown\", ctFunctionFirstKey);\n\t\tapbct_remove_event_handler(window, \"keydown\", ctFunctionFirstKey);\n\t}\n\n\tapbct_attach_event_handler(window, \"mousemove\", ctFunctionMouseMove);\n\tapbct_attach_event_handler(window, \"mousedown\", ctFunctionFirstKey);\n\tapbct_attach_event_handler(window, \"keydown\", ctFunctionFirstKey);\n\n\t// Ready function\n\tfunction apbct_ready(){\n\n\t\tif( +ctPublic.pixel__setting ){\n\t\t\tctSetCookie( 'apbct_pixel_url', ctPublic.pixel__url );\n\t\t\tif( +ctPublic.pixel__enabled ){\n\t\t\t\tjQuery('body').append( '<img style=\"display: none; left: 99999px;\" src=\"' + ctPublic.pixel__url + '\">' );\n\t\t\t}\n\t\t}\n\n\t\tsetTimeout(function(){\n\n\t\t\tvar visible_fields_collection = {};\n\n\t\t\tfor(var i = 0; i < document.forms.length; i++){\n\t\t\t\tvar form = document.forms[i];\n\n\t\t\t\t//Exclusion for forms\n\t\t\t\tif (\n\t\t\t\t\tform.classList.contains('slp_search_form') || //StoreLocatorPlus form\n\t\t\t\t\tform.parentElement.classList.contains('mec-booking') ||\n\t\t\t\t\tform.action.toString().indexOf('activehosted.com') !== -1 || // Active Campaign\n\t\t\t\t\t(form.id && form.id == 'caspioform') || //Caspio Form\n\t\t\t\t\t(form.name.classList && form.name.classList.contains('tinkoffPayRow')) || // TinkoffPayForm\n\t\t\t\t\t(form.name.classList && form.name.classList.contains('give-form ')) // GiveWP\n\t\t\t\t)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tvisible_fields_collection[i] = apbct_collect_visible_fields( form );\n\n\t\t\t\tform.onsubmit_prev = form.onsubmit;\n\t\t\t\tform.onsubmit = function (event) {\n\n\t\t\t\t\tvar visible_fields = {};\n\t\t\t\t\tvisible_fields[0] = apbct_collect_visible_fields(this);\n\t\t\t\t\tapbct_visible_fields_set_cookie( visible_fields );\n\n\t\t\t\t\t// Call previous submit action\n\t\t\t\t\tif (event.target.onsubmit_prev instanceof Function) {\n\t\t\t\t\t\tsetTimeout(function () {\n\t\t\t\t\t\t\tevent.target.onsubmit_prev.call(event.target, event);\n\t\t\t\t\t\t}, 500);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tapbct_visible_fields_set_cookie( visible_fields_collection );\n\n\t\t}, 1000);\n\t}\n\tapbct_attach_event_handler(window, \"DOMContentLoaded\", apbct_ready);\n\n}());\n\nfunction ctSetCookie( cookies, value, expires ){\n\n\tif( typeof cookies === 'string' && typeof value === 'string' || typeof value === 'number'){\n\t\tvar skip_alt = cookies === 'ct_pointer_data' || cookies === 'ct_user_info';\n\t\tcookies = [ [ cookies, value, expires ] ];\n\t}\n\n\t// Cookies disabled\n\tif( +ctPublic.data__set_cookies === 0 ){\n\t\treturn;\n\n\t// Using traditional cookies\n\t}else if( +ctPublic.data__set_cookies === 1 ){\n\t\tcookies.forEach( function (item, i, arr\t) {\n\t\t\tvar expires = typeof item[2] !== 'undefined' ? \"expires=\" + expires + '; ' : '';\n\t\t\tvar ctSecure = location.protocol === 'https:' ? '; secure' : '';\n\t\t\tdocument.cookie = item[0] + \"=\" + encodeURIComponent(item[1]) + \"; \" + expires + \"path=/; samesite=lax\" + ctSecure;\n\t\t});\n\n\t// Using alternative cookies\n\t}else if( +ctPublic.data__set_cookies === 2 && ! skip_alt ){\n\n\t\t// Using REST API handler\n\t\tif( +ctPublic.data__set_cookies__alt_sessions_type === 1 ){\n\t\t\tapbct_public_sendREST(\n\t\t\t\t'alt_sessions',\n\t\t\t\t{\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tdata: { cookies: cookies }\n\t\t\t\t}\n\t\t\t);\n\n\t\t// Using AJAX request and handler\n\t\t}else if( +ctPublic.data__set_cookies__alt_sessions_type === 2 ) {\n\t\t\tapbct_public_sendAJAX(\n\t\t\t\t{\n\t\t\t\t\taction: 'apbct_alt_session__save__AJAX',\n\t\t\t\t\tcookies: cookies,\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction apbct_collect_visible_fields( form ) {\n\n\t// Get only fields\n\tvar inputs = [],\n\t\tinputs_visible = '',\n\t\tinputs_visible_count = 0,\n\t\tinputs_invisible = '',\n\t\tinputs_invisible_count = 0,\n\t\tinputs_with_duplicate_names = [];\n\n\tfor(var key in form.elements){\n\t\tif(!isNaN(+key))\n\t\t\tinputs[key] = form.elements[key];\n\t}\n\n\t// Filter fields\n\tinputs = inputs.filter(function(elem){\n\n\t\t// Filter already added fields\n\t\tif( inputs_with_duplicate_names.indexOf( elem.getAttribute('name') ) !== -1 ){\n\t\t\treturn false;\n\t\t}\n\t\t// Filter inputs with same names for type == radio\n\t\tif( -1 !== ['radio', 'checkbox'].indexOf( elem.getAttribute(\"type\") )){\n\t\t\tinputs_with_duplicate_names.push( elem.getAttribute('name') );\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t});\n\n\t// Visible fields\n\tinputs.forEach(function(elem, i, elements){\n\t\t// Unnecessary fields\n\t\tif(\n\t\t\telem.getAttribute(\"type\") === \"submit\" || // type == submit\n\t\t\telem.getAttribute('name') === null ||\n\t\t\telem.getAttribute('name') === 'ct_checkjs'\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\t// Invisible fields\n\t\tif(\n\t\t\tgetComputedStyle(elem).display === \"none\" || // hidden\n\t\t\tgetComputedStyle(elem).visibility === \"hidden\" || // hidden\n\t\t\tgetComputedStyle(elem).opacity === \"0\" || // hidden\n\t\t\telem.getAttribute(\"type\") === \"hidden\" // type == hidden\n\t\t) {\n\t\t\tif( elem.classList.contains(\"wp-editor-area\") ) {\n\t\t\t\tinputs_visible += \" \" + elem.getAttribute(\"name\");\n\t\t\t\tinputs_visible_count++;\n\t\t\t} else {\n\t\t\t\tinputs_invisible += \" \" + elem.getAttribute(\"name\");\n\t\t\t\tinputs_invisible_count++;\n\t\t\t}\n\t\t}\n\t\t// Visible fields\n\t\telse {\n\t\t\tinputs_visible += \" \" + elem.getAttribute(\"name\");\n\t\t\tinputs_visible_count++;\n\t\t}\n\n\t});\n\n\tinputs_invisible = inputs_invisible.trim();\n\tinputs_visible = inputs_visible.trim();\n\n\treturn {\n\t\tvisible_fields : inputs_visible,\n\t\tvisible_fields_count : inputs_visible_count,\n\t\tinvisible_fields : inputs_invisible,\n\t\tinvisible_fields_count : inputs_invisible_count,\n\t}\n\n}\n\nfunction apbct_visible_fields_set_cookie( visible_fields_collection ) {\n\n\tvar collection = typeof visible_fields_collection === 'object' && visible_fields_collection !== null ? visible_fields_collection : {};\n\n\tctSetCookie(\"apbct_visible_fields\", JSON.stringify( collection ) );\n\n}\n\nfunction apbct_js_keys__set_input_value(result, data, params, obj){\n\tif( document.querySelectorAll('[name^=ct_checkjs]').length > 0 ) {\n\t\tvar elements = document.querySelectorAll('[name^=ct_checkjs]');\n\t\tfor ( var i = 0; i < elements.length; i++ ) {\n\t\t\telements[i].value = result.js_key;\n\t\t}\n\t}\n}\n\nfunction apbct_public_sendAJAX(data, params, obj){\n\n\t// Default params\n\tvar callback = params.callback || null;\n\tvar callback_context = params.callback_context || null;\n\tvar callback_params = params.callback_params || null;\n\tvar async = params.async || true;\n\tvar notJson = params.notJson || null;\n\tvar timeout = params.timeout || 15000;\n\tvar obj = obj || null;\n\tvar button = params.button || null;\n\tvar spinner = params.spinner || null;\n\tvar progressbar = params.progressbar || null;\n\tvar silent = params.silent || null;\n\tvar no_nonce = params.no_nonce || null;\n\n\tif(typeof (data) === 'string') {\n\t\tif( ! no_nonce )\n\t\t\tdata = data + '&_ajax_nonce=' + ctPublic._ajax_nonce;\n\t\tdata = data + '&no_cache=' + Math.random()\n\t} else {\n\t\tif( ! no_nonce )\n\t\t\tdata._ajax_nonce = ctPublic._ajax_nonce;\n\t\tdata.no_cache = Math.random();\n\t}\n\t// Button and spinner\n\tif(button) {button.setAttribute('disabled', 'disabled'); button.style.cursor = 'not-allowed'; }\n\tif(spinner) jQuery(spinner).css('display', 'inline');\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ctPublic._ajax_url,\n\t\tdata: data,\n\t\tasync: async,\n\t\tsuccess: function(result){\n\t\t\tif(button){ button.removeAttribute('disabled'); button.style.cursor = 'pointer'; }\n\t\t\tif(spinner) jQuery(spinner).css('display', 'none');\n\t\t\tif(!notJson) result = JSON.parse(result);\n\t\t\tif(result.error){\n\t\t\t\tsetTimeout(function(){ if(progressbar) progressbar.fadeOut('slow'); }, 1000);\n\t\t\t\tconsole.log('Error happens: ' + (result.error || 'Unkown'));\n\t\t\t}else{\n\t\t\t\tif(callback) {\n\t\t\t\t\tif (callback_params)\n\t\t\t\t\t\tcallback.apply( callback_context, callback_params.concat( result, data, params, obj ) );\n\t\t\t\t\telse\n\t\t\t\t\t\tcallback(result, data, params, obj);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\terror: function(jqXHR, textStatus, errorThrown){\n\t\t\tif(button){ button.removeAttribute('disabled'); button.style.cursor = 'pointer'; }\n\t\t\tif(spinner) jQuery(spinner).css('display', 'none');\n\t\t\tif( errorThrown && ! silent ) {\n\t\t\t\tconsole.log('APBCT_AJAX_ERROR');\n\t\t\t\tconsole.log(jqXHR);\n\t\t\t\tconsole.log(textStatus);\n\t\t\t\tconsole.log('Anti-spam by Cleantalk plugin error: ' + errorThrown + 'Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/');\n\t\t\t}\n\t\t},\n\t\ttimeout: timeout,\n\t});\n}\n\nfunction apbct_public_sendREST( route, params ) {\n\n\tvar callback = params.callback || null;\n\tvar data = params.data || [];\n\tvar method = params.method || 'POST';\n\n\tjQuery.ajax({\n\t\ttype: method,\n\t\turl: ctPublic._rest_url + 'cleantalk-antispam/v1/' + route,\n\t\tdata: data,\n\t\tbeforeSend : function ( xhr ) {\n\t\t\txhr.setRequestHeader( 'X-WP-Nonce', ctPublic._rest_nonce );\n\t\t},\n\t\tsuccess: function(result){\n\t\t\tif(result.error){\n\t\t\t\tconsole.log('Error happens: ' + (result.error || 'Unknown'));\n\t\t\t}else{\n\t\t\t\tif(callback) {\n\t\t\t\t\tvar obj = null;\n\t\t\t\t\tcallback(result, route, params, obj);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\terror: function(jqXHR, textStatus, errorThrown){\n\t\t\tif( errorThrown ) {\n\t\t\t\tconsole.log('APBCT_REST_ERROR');\n\t\t\t\tconsole.log(jqXHR);\n\t\t\t\tconsole.log(textStatus);\n\t\t\t\tconsole.log('Anti-spam by Cleantalk plugin REST API error: ' + errorThrown + ' Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/');\n\t\t\t}\n\t\t},\n\t});\n\n}\n\nif(typeof jQuery !== 'undefined') {\n\n\t// Capturing responses and output block message for unknown AJAX forms\n\tjQuery(document).ajaxComplete(function (event, xhr, settings) {\n\t\tif (xhr.responseText && xhr.responseText.indexOf('\"apbct') !== -1) {\n\t\t\tvar response = JSON.parse(xhr.responseText);\n\t\t\tif (typeof response.apbct !== 'undefined') {\n\t\t\t\tresponse = response.apbct;\n\t\t\t\tif (response.blocked) {\n\t\t\t\t\tdocument.dispatchEvent(\n\t\t\t\t\t\tnew CustomEvent( \"apbctAjaxBockAlert\", {\n\t\t\t\t\t\t\tbubbles: true,\n\t\t\t\t\t\t\tdetail: { message: response.comment }\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\n\t\t\t\t\t// Show the result by modal\n\t\t\t\t\tcleantalkModal.loaded = response.comment;\n\t\t\t\t\tcleantalkModal.open();\n\n\t\t\t\t\tif(+response.stop_script == 1)\n\t\t\t\t\t\twindow.stop();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n}"],"names":["ctSetCookie","cookies","value","expires","skip_alt","ctPublic","data__set_cookies","forEach","item","i","arr","ctSecure","location","protocol","document","cookie","encodeURIComponent","data__set_cookies__alt_sessions_type","apbct_public_sendREST","method","data","apbct_public_sendAJAX","action","apbct_collect_visible_fields","form","key","inputs","inputs_visible","inputs_visible_count","inputs_invisible","inputs_invisible_count","inputs_with_duplicate_names","elements","isNaN","filter","elem","indexOf","getAttribute","push","getComputedStyle","display","visibility","opacity","classList","contains","trim","visible_fields","visible_fields_count","invisible_fields","invisible_fields_count","apbct_visible_fields_set_cookie","visible_fields_collection","collection","JSON","stringify","apbct_js_keys__set_input_value","result","params","obj","querySelectorAll","length","js_key","callback","callback_context","callback_params","async","notJson","timeout","button","spinner","progressbar","silent","no_nonce","_ajax_nonce","Math","random","no_cache","setAttribute","style","cursor","jQuery","css","ajax","type","url","_ajax_url","success","removeAttribute","parse","error","setTimeout","fadeOut","console","log","apply","concat","jqXHR","textStatus","errorThrown","route","_rest_url","beforeSend","xhr","setRequestHeader","_rest_nonce","ct_date","Date","ctTimeMs","getTime","ctMouseEventTimerFlag","ctMouseData","ctMouseDataCounter","apbct_attach_event_handler","event","window","addEventListener","attachEvent","apbct_remove_event_handler","removeEventListener","detachEvent","floor","getTimezoneOffset","ctFunctionFirstKey","ctMouseReadInterval","setInterval","ctMouseWriteDataInterval","ctFunctionMouseMove","round","clientY","clientX","clearInterval","pixel__setting","pixel__url","pixel__enabled","append","forms","parentElement","toString","id","name","onsubmit_prev","onsubmit","this","target","Function","call","ajaxComplete","settings","responseText","response","apbct","blocked","dispatchEvent","CustomEvent","bubbles","detail","message","comment","cleantalkModal","loaded","open","stop_script","stop"],"mappings":"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"}
1
+ {"version":3,"file":"apbct-public.min.js","sources":["apbct-public.js"],"sourcesContent":["(function() {\n\n\tvar ct_date = new Date(),\n\t\tctTimeMs = new Date().getTime(),\n\t\tctMouseEventTimerFlag = true, //Reading interval flag\n\t\tctMouseData = [],\n\t\tctMouseDataCounter = 0,\n\t\tctCheckedEmails = {},\n\t\tctScrollCollected = false;\n\n\tfunction apbct_attach_event_handler(elem, event, callback){\n\t\tif(typeof window.addEventListener === \"function\") elem.addEventListener(event, callback);\n\t\telse elem.attachEvent(event, callback);\n\t}\n\n\tfunction apbct_remove_event_handler(elem, event, callback){\n\t\tif(typeof window.removeEventListener === \"function\") elem.removeEventListener(event, callback);\n\t\telse elem.detachEvent(event, callback);\n\t}\n\n\tctSetCookie(\n\t\t[\n\t\t\t[ \"ct_ps_timestamp\", Math.floor(new Date().getTime() / 1000) ],\n\t\t\t[ \"ct_fkp_timestamp\", \"0\" ],\n\t\t\t[ \"ct_pointer_data\", \"0\" ],\n\t\t\t[ \"ct_timezone\", ct_date.getTimezoneOffset()/60*(-1) ],\n\t\t\t[ \"apbct_visible_fields\", \"0\" ],\n\t\t]\n\t);\n\n\t//Writing first key press timestamp\n\tvar ctFunctionFirstKey = function output(event){\n\t\tvar KeyTimestamp = Math.floor(new Date().getTime()/1000);\n\t\tctSetCookie(\"ct_fkp_timestamp\", KeyTimestamp);\n\t\tctKeyStopStopListening();\n\t};\n\n\t//Reading interval\n\tvar ctMouseReadInterval = setInterval(function(){\n\t\tctMouseEventTimerFlag = true;\n\t}, 150);\n\n\t//Writting interval\n\tvar ctMouseWriteDataInterval = setInterval(function(){\n\t\tctSetCookie(\"ct_pointer_data\", JSON.stringify(ctMouseData));\n\t}, 1200);\n\n\t//Logging mouse position each 150 ms\n\tvar ctFunctionMouseMove = function output(event){\n\t\tif(ctMouseEventTimerFlag === true){\n\n\t\t\tctMouseData.push([\n\t\t\t\tMath.round(event.clientY),\n\t\t\t\tMath.round(event.clientX),\n\t\t\t\tMath.round(new Date().getTime() - ctTimeMs)\n\t\t\t]);\n\n\t\t\tctMouseDataCounter++;\n\t\t\tctMouseEventTimerFlag = false;\n\t\t\tif(ctMouseDataCounter >= 50){\n\t\t\t\tctMouseStopData();\n\t\t\t}\n\t\t}\n\t};\n\n\t//Stop mouse observing function\n\tfunction ctMouseStopData(){\n\t\tapbct_remove_event_handler(window, \"mousemove\", ctFunctionMouseMove);\n\t\tclearInterval(ctMouseReadInterval);\n\t\tclearInterval(ctMouseWriteDataInterval);\n\t}\n\n\t//Stop key listening function\n\tfunction ctKeyStopStopListening(){\n\t\tapbct_remove_event_handler(window, \"mousedown\", ctFunctionFirstKey);\n\t\tapbct_remove_event_handler(window, \"keydown\", ctFunctionFirstKey);\n\t}\n\n\tfunction checkEmail(e) {\n\t\tvar current_email = e.target.value;\n\t\tif (current_email && !(current_email in ctCheckedEmails)) {\n\t\t\tapbct_public_sendAJAX(\n\t\t\t\t{action: 'apbct_email_check_before_post', data : {'email' : current_email}},\n\t\t\t\t{\n\t\t\t\t\tapbct_ajax: 1,\n\t\t\t\t\tcallback: function (result) {\n\t\t\t\t\t\tif (result.result) {\n\t\t\t\t\t\t\tctCheckedEmails[current_email] = {'result' : result.result, 'timestamp': Date.now() / 1000 |0};\n\t\t\t\t\t\t\tctSetCookie('ct_checked_emails', JSON.stringify(ctCheckedEmails));\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\t\t\n\t\t}\n\t}\n\n\tfunction ctSetHasScrolled() {\n\t\tif( ! ctScrollCollected ) {\n\t\t\tctSetCookie(\"ct_has_scrolled\", JSON.stringify( true ) );\n\t\t\tctScrollCollected = true;\n\t\t}\n\t}\n\n\tapbct_attach_event_handler(window, \"mousemove\", ctFunctionMouseMove);\n\tapbct_attach_event_handler(window, \"mousedown\", ctFunctionFirstKey);\n\tapbct_attach_event_handler(window, \"keydown\", ctFunctionFirstKey);\n\tapbct_attach_event_handler(window, \"scroll\", ctSetHasScrolled);\n\n\t// Ready function\n\tfunction apbct_ready(){\n\n\t\tif( +ctPublic.pixel__setting ){\n\t\t\tctSetCookie( 'apbct_pixel_url', ctPublic.pixel__url );\n\t\t\tif( +ctPublic.pixel__enabled ){\n\t\t\t\tjQuery('body').append( '<img style=\"display: none; left: 99999px;\" src=\"' + ctPublic.pixel__url + '\">' );\n\t\t\t}\n\t\t}\n\n\t\tif ( +ctPublic.data__email_check_before_post) {\n\t\t\tctSetCookie( 'ct_checked_emails', '0');\n\t\t\tjQuery(\"input[type = 'email'], #email\").blur(checkEmail);\n\t\t}\n\n\t\t// Collect scrolling info\n\t\tctSetCookie( 'ct_screen_info', apbctGetScreenInfo() );\n\t\tctSetCookie(\"ct_has_scrolled\", JSON.stringify( false ) );\n\n\t\tsetTimeout(function(){\n\n\t\t\tvar visible_fields_collection = {};\n\n\t\t\tfor(var i = 0; i < document.forms.length; i++){\n\t\t\t\tvar form = document.forms[i];\n\n\t\t\t\t//Exclusion for forms\n\t\t\t\tif (\n\t\t\t\t\tform.classList.contains('slp_search_form') || //StoreLocatorPlus form\n\t\t\t\t\tform.parentElement.classList.contains('mec-booking') ||\n\t\t\t\t\tform.action.toString().indexOf('activehosted.com') !== -1 || // Active Campaign\n\t\t\t\t\t(form.id && form.id == 'caspioform') || //Caspio Form\n\t\t\t\t\t(form.name.classList && form.name.classList.contains('tinkoffPayRow')) || // TinkoffPayForm\n\t\t\t\t\t(form.name.classList && form.name.classList.contains('give-form ')) // GiveWP\n\t\t\t\t)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tvisible_fields_collection[i] = apbct_collect_visible_fields( form );\n\n\t\t\t\tform.onsubmit_prev = form.onsubmit;\n\t\t\t\tform.onsubmit = function (event) {\n\n\t\t\t\t\tvar visible_fields = {};\n\t\t\t\t\tvisible_fields[0] = apbct_collect_visible_fields(this);\n\t\t\t\t\tapbct_visible_fields_set_cookie( visible_fields );\n\n\t\t\t\t\t// Call previous submit action\n\t\t\t\t\tif (event.target.onsubmit_prev instanceof Function) {\n\t\t\t\t\t\tsetTimeout(function () {\n\t\t\t\t\t\t\tevent.target.onsubmit_prev.call(event.target, event);\n\t\t\t\t\t\t}, 500);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tapbct_visible_fields_set_cookie( visible_fields_collection );\n\n\t\t}, 1000);\n\t}\n\tapbct_attach_event_handler(window, \"DOMContentLoaded\", apbct_ready);\n\n}());\n\nfunction ctSetCookie( cookies, value, expires ){\n\n\tif( typeof cookies === 'string' && typeof value === 'string' || typeof value === 'number'){\n\t\tvar skip_alt = cookies === 'ct_pointer_data' || cookies === 'ct_user_info';\n\t\tcookies = [ [ cookies, value, expires ] ];\n\t}\n\n\t// Cookies disabled\n\tif( +ctPublic.data__set_cookies === 0 ){\n\t\treturn;\n\n\t// Using traditional cookies\n\t}else if( +ctPublic.data__set_cookies === 1 ){\n\t\tcookies.forEach( function (item, i, arr\t) {\n\t\t\tvar expires = typeof item[2] !== 'undefined' ? \"expires=\" + expires + '; ' : '';\n\t\t\tvar ctSecure = location.protocol === 'https:' ? '; secure' : '';\n\t\t\tdocument.cookie = item[0] + \"=\" + encodeURIComponent(item[1]) + \"; \" + expires + \"path=/; samesite=lax\" + ctSecure;\n\t\t});\n\n\t// Using alternative cookies\n\t}else if( +ctPublic.data__set_cookies === 2 && ! skip_alt ){\n\n\t\t// Using REST API handler\n\t\tif( +ctPublic.data__set_cookies__alt_sessions_type === 1 ){\n\t\t\tapbct_public_sendREST(\n\t\t\t\t'alt_sessions',\n\t\t\t\t{\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tdata: { cookies: cookies }\n\t\t\t\t}\n\t\t\t);\n\n\t\t// Using AJAX request and handler\n\t\t}else if( +ctPublic.data__set_cookies__alt_sessions_type === 2 ) {\n\t\t\tapbct_public_sendAJAX(\n\t\t\t\t{\n\t\t\t\t\taction: 'apbct_alt_session__save__AJAX',\n\t\t\t\t\tcookies: cookies,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tapbct_ajax: 1,\n\t\t\t\t\tnotJson: 1,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction apbct_collect_visible_fields( form ) {\n\n\t// Get only fields\n\tvar inputs = [],\n\t\tinputs_visible = '',\n\t\tinputs_visible_count = 0,\n\t\tinputs_invisible = '',\n\t\tinputs_invisible_count = 0,\n\t\tinputs_with_duplicate_names = [];\n\n\tfor(var key in form.elements){\n\t\tif(!isNaN(+key))\n\t\t\tinputs[key] = form.elements[key];\n\t}\n\n\t// Filter fields\n\tinputs = inputs.filter(function(elem){\n\n\t\t// Filter already added fields\n\t\tif( inputs_with_duplicate_names.indexOf( elem.getAttribute('name') ) !== -1 ){\n\t\t\treturn false;\n\t\t}\n\t\t// Filter inputs with same names for type == radio\n\t\tif( -1 !== ['radio', 'checkbox'].indexOf( elem.getAttribute(\"type\") )){\n\t\t\tinputs_with_duplicate_names.push( elem.getAttribute('name') );\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t});\n\n\t// Visible fields\n\tinputs.forEach(function(elem, i, elements){\n\t\t// Unnecessary fields\n\t\tif(\n\t\t\telem.getAttribute(\"type\") === \"submit\" || // type == submit\n\t\t\telem.getAttribute('name') === null ||\n\t\t\telem.getAttribute('name') === 'ct_checkjs'\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\t// Invisible fields\n\t\tif(\n\t\t\tgetComputedStyle(elem).display === \"none\" || // hidden\n\t\t\tgetComputedStyle(elem).visibility === \"hidden\" || // hidden\n\t\t\tgetComputedStyle(elem).opacity === \"0\" || // hidden\n\t\t\telem.getAttribute(\"type\") === \"hidden\" // type == hidden\n\t\t) {\n\t\t\tif( elem.classList.contains(\"wp-editor-area\") ) {\n\t\t\t\tinputs_visible += \" \" + elem.getAttribute(\"name\");\n\t\t\t\tinputs_visible_count++;\n\t\t\t} else {\n\t\t\t\tinputs_invisible += \" \" + elem.getAttribute(\"name\");\n\t\t\t\tinputs_invisible_count++;\n\t\t\t}\n\t\t}\n\t\t// Visible fields\n\t\telse {\n\t\t\tinputs_visible += \" \" + elem.getAttribute(\"name\");\n\t\t\tinputs_visible_count++;\n\t\t}\n\n\t});\n\n\tinputs_invisible = inputs_invisible.trim();\n\tinputs_visible = inputs_visible.trim();\n\n\treturn {\n\t\tvisible_fields : inputs_visible,\n\t\tvisible_fields_count : inputs_visible_count,\n\t\tinvisible_fields : inputs_invisible,\n\t\tinvisible_fields_count : inputs_invisible_count,\n\t}\n\n}\n\nfunction apbct_visible_fields_set_cookie( visible_fields_collection ) {\n\n\tvar collection = typeof visible_fields_collection === 'object' && visible_fields_collection !== null ? visible_fields_collection : {};\n\n\tctSetCookie(\"apbct_visible_fields\", JSON.stringify( collection ) );\n\n}\n\nfunction apbct_js_keys__set_input_value(result, data, params, obj){\n\tif( document.querySelectorAll('[name^=ct_checkjs]').length > 0 ) {\n\t\tvar elements = document.querySelectorAll('[name^=ct_checkjs]');\n\t\tfor ( var i = 0; i < elements.length; i++ ) {\n\t\t\telements[i].value = result.js_key;\n\t\t}\n\t}\n}\n\nfunction apbct_public_sendAJAX(data, params, obj){\n\n\t// Default params\n\tvar callback = params.callback || null;\n\tvar callback_context = params.callback_context || null;\n\tvar callback_params = params.callback_params || null;\n\tvar async = params.async || true;\n\tvar notJson = params.notJson || null;\n\tvar timeout = params.timeout || 15000;\n\tvar obj = obj || null;\n\tvar button = params.button || null;\n\tvar spinner = params.spinner || null;\n\tvar progressbar = params.progressbar || null;\n\tvar silent = params.silent || null;\n\tvar no_nonce = params.no_nonce || null;\n\tvar apbct_ajax = params.apbct_ajax || null;\n\n\tif(typeof (data) === 'string') {\n\t\tif( ! no_nonce )\n\t\t\tdata = data + '&_ajax_nonce=' + ctPublic._ajax_nonce;\n\t\tdata = data + '&no_cache=' + Math.random()\n\t} else {\n\t\tif( ! no_nonce )\n\t\t\tdata._ajax_nonce = ctPublic._ajax_nonce;\n\t\tdata.no_cache = Math.random();\n\t}\n\t// Button and spinner\n\tif(button) {button.setAttribute('disabled', 'disabled'); button.style.cursor = 'not-allowed'; }\n\tif(spinner) jQuery(spinner).css('display', 'inline');\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: apbct_ajax ? ctPublic._apbct_ajax_url : ctPublic._ajax_url,\n\t\tdata: data,\n\t\tasync: async,\n\t\tsuccess: function(result){\n\t\t\tif(button){ button.removeAttribute('disabled'); button.style.cursor = 'pointer'; }\n\t\t\tif(spinner) jQuery(spinner).css('display', 'none');\n\t\t\tif(!notJson) result = JSON.parse(result);\n\t\t\tif(result.error){\n\t\t\t\tsetTimeout(function(){ if(progressbar) progressbar.fadeOut('slow'); }, 1000);\n\t\t\t\tconsole.log('Error happens: ' + (result.error || 'Unkown'));\n\t\t\t}else{\n\t\t\t\tif(callback) {\n\t\t\t\t\tif (callback_params)\n\t\t\t\t\t\tcallback.apply( callback_context, callback_params.concat( result, data, params, obj ) );\n\t\t\t\t\telse\n\t\t\t\t\t\tcallback(result, data, params, obj);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\terror: function(jqXHR, textStatus, errorThrown){\n\t\t\tif(button){ button.removeAttribute('disabled'); button.style.cursor = 'pointer'; }\n\t\t\tif(spinner) jQuery(spinner).css('display', 'none');\n\t\t\tif( errorThrown && ! silent ) {\n\t\t\t\tconsole.log('APBCT_AJAX_ERROR');\n\t\t\t\tconsole.log(jqXHR);\n\t\t\t\tconsole.log(textStatus);\n\t\t\t\tconsole.log('Anti-spam by Cleantalk plugin error: ' + errorThrown + 'Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/');\n\t\t\t}\n\t\t},\n\t\ttimeout: timeout,\n\t});\n}\n\nfunction apbct_public_sendREST( route, params ) {\n\n\tvar callback = params.callback || null;\n\tvar data = params.data || [];\n\tvar method = params.method || 'POST';\n\n\tjQuery.ajax({\n\t\ttype: method,\n\t\turl: ctPublic._rest_url + 'cleantalk-antispam/v1/' + route,\n\t\tdata: data,\n\t\tbeforeSend : function ( xhr ) {\n\t\t\txhr.setRequestHeader( 'X-WP-Nonce', ctPublic._rest_nonce );\n\t\t},\n\t\tsuccess: function(result){\n\t\t\tif(result.error){\n\t\t\t\tconsole.log('Error happens: ' + (result.error || 'Unknown'));\n\t\t\t}else{\n\t\t\t\tif(callback) {\n\t\t\t\t\tvar obj = null;\n\t\t\t\t\tcallback(result, route, params, obj);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\terror: function(jqXHR, textStatus, errorThrown){\n\t\t\tif( errorThrown ) {\n\t\t\t\tconsole.log('APBCT_REST_ERROR');\n\t\t\t\tconsole.log(jqXHR);\n\t\t\t\tconsole.log(textStatus);\n\t\t\t\tconsole.log('Anti-spam by Cleantalk plugin REST API error: ' + errorThrown + ' Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/');\n\t\t\t}\n\t\t},\n\t});\n\n}\n\nfunction apbctGetScreenInfo() {\n\treturn JSON.stringify({\n\t\tfullWidth : document.documentElement.scrollWidth,\n\t\tfullHeight : Math.max(\n\t\t\tdocument.body.scrollHeight, document.documentElement.scrollHeight,\n\t\t\tdocument.body.offsetHeight, document.documentElement.offsetHeight,\n\t\t\tdocument.body.clientHeight, document.documentElement.clientHeight\n\t\t),\n\t\tvisibleWidth : document.documentElement.clientWidth,\n\t\tvisibleHeight : document.documentElement.clientHeight,\n\t});\n}\n\nif(typeof jQuery !== 'undefined') {\n\n\t// Capturing responses and output block message for unknown AJAX forms\n\tjQuery(document).ajaxComplete(function (event, xhr, settings) {\n\t\tif (xhr.responseText && xhr.responseText.indexOf('\"apbct') !== -1) {\n\t\t\tvar response = JSON.parse(xhr.responseText);\n\t\t\tif (typeof response.apbct !== 'undefined') {\n\t\t\t\tresponse = response.apbct;\n\t\t\t\tif (response.blocked) {\n\t\t\t\t\tdocument.dispatchEvent(\n\t\t\t\t\t\tnew CustomEvent( \"apbctAjaxBockAlert\", {\n\t\t\t\t\t\t\tbubbles: true,\n\t\t\t\t\t\t\tdetail: { message: response.comment }\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\n\t\t\t\t\t// Show the result by modal\n\t\t\t\t\tcleantalkModal.loaded = response.comment;\n\t\t\t\t\tcleantalkModal.open();\n\n\t\t\t\t\tif(+response.stop_script == 1)\n\t\t\t\t\t\twindow.stop();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n}"],"names":["ctSetCookie","cookies","value","expires","skip_alt","ctPublic","data__set_cookies","forEach","item","i","arr","ctSecure","location","protocol","document","cookie","encodeURIComponent","data__set_cookies__alt_sessions_type","apbct_public_sendREST","method","data","apbct_public_sendAJAX","action","apbct_ajax","notJson","apbct_collect_visible_fields","form","inputs","inputs_visible","inputs_visible_count","inputs_invisible","inputs_invisible_count","inputs_with_duplicate_names","key","elements","isNaN","filter","elem","indexOf","getAttribute","push","getComputedStyle","display","visibility","opacity","classList","contains","trim","visible_fields","visible_fields_count","invisible_fields","invisible_fields_count","apbct_visible_fields_set_cookie","visible_fields_collection","collection","JSON","stringify","apbct_js_keys__set_input_value","result","params","obj","querySelectorAll","length","js_key","callback","callback_context","callback_params","async","timeout","button","spinner","progressbar","silent","no_nonce","_ajax_nonce","Math","random","no_cache","setAttribute","style","cursor","jQuery","css","ajax","type","url","_apbct_ajax_url","_ajax_url","success","removeAttribute","parse","error","setTimeout","fadeOut","console","log","apply","concat","jqXHR","textStatus","errorThrown","route","_rest_url","beforeSend","xhr","setRequestHeader","_rest_nonce","apbctGetScreenInfo","fullWidth","documentElement","scrollWidth","fullHeight","max","body","scrollHeight","offsetHeight","clientHeight","visibleWidth","clientWidth","visibleHeight","ct_date","Date","ctTimeMs","getTime","ctMouseEventTimerFlag","ctMouseData","ctMouseDataCounter","ctCheckedEmails","ctScrollCollected","apbct_attach_event_handler","event","window","addEventListener","attachEvent","apbct_remove_event_handler","removeEventListener","detachEvent","floor","getTimezoneOffset","ctFunctionFirstKey","ctMouseReadInterval","setInterval","ctMouseWriteDataInterval","ctFunctionMouseMove","round","clientY","clientX","clearInterval","checkEmail","e","current_email","target","email","timestamp","now","pixel__setting","pixel__url","pixel__enabled","append","data__email_check_before_post","blur","forms","parentElement","toString","id","name","onsubmit_prev","onsubmit","this","Function","call","ajaxComplete","settings","response","responseText","apbct","blocked","dispatchEvent","CustomEvent","bubbles","detail","message","comment","cleantalkModal","loaded","open","stop_script","stop"],"mappings":"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"}
lib/Cleantalk/Antispam/CleantalkRequest.php CHANGED
@@ -160,7 +160,7 @@ class CleantalkRequest {
160
  /**
161
  * @var int|null
162
  */
163
- public $honeypot_website;
164
 
165
  /**
166
  * Fill params with constructor
@@ -189,7 +189,7 @@ class CleantalkRequest {
189
  $this->submit_time = isset($params['submit_time']) ? (int)$params['submit_time'] : null;
190
  $this->post_info = isset($params['post_info']) ? (string)json_encode($params['post_info']) : null;
191
  $this->sender_info = isset($params['sender_info']) ? (string)json_encode($params['sender_info']) : null;
192
- $this->honeypot_website = isset($params['honeypot_website']) ? (int)$params['honeypot_website'] : null;
193
 
194
  $this->message = ! empty( $params['message'] )
195
  ? ( ! is_scalar( $params['message'] )
160
  /**
161
  * @var int|null
162
  */
163
+ public $honeypot_field;
164
 
165
  /**
166
  * Fill params with constructor
189
  $this->submit_time = isset($params['submit_time']) ? (int)$params['submit_time'] : null;
190
  $this->post_info = isset($params['post_info']) ? (string)json_encode($params['post_info']) : null;
191
  $this->sender_info = isset($params['sender_info']) ? (string)json_encode($params['sender_info']) : null;
192
+ $this->honeypot_field = isset($params['honeypot_field']) ? (int)$params['honeypot_field'] : null;
193
 
194
  $this->message = ! empty( $params['message'] )
195
  ? ( ! is_scalar( $params['message'] )
lib/Cleantalk/Antispam/Integrations.php CHANGED
@@ -1,113 +1,120 @@
1
- <?php
2
-
3
-
4
- namespace Cleantalk\Antispam;
5
-
6
-
7
- class Integrations
8
- {
9
-
10
- private $integrations = array();
11
-
12
- private $integration;
13
-
14
- /**
15
- * Integrations constructor.
16
- *
17
- * @param array $integrations
18
- * @param array $settings
19
- */
20
- public function __construct( $integrations, $settings )
21
- {
22
- $this->integrations = $integrations;
23
-
24
- foreach( $this->integrations as $integration_name => $integration_info ){
25
-
26
- if( empty( $settings[ $integration_info['setting'] ] ) )
27
- continue;
28
-
29
- if( $integration_info['ajax'] ) {
30
- if( is_array( $integration_info['hook'] ) ) {
31
- foreach( $integration_info['hook'] as $hook ) {
32
- add_action( 'wp_ajax_' . $hook, array( $this, 'checkSpam' ), 1 );
33
- add_action( 'wp_ajax_nopriv_' . $hook, array( $this, 'checkSpam' ), 1 );
34
- }
35
- } else {
36
- add_action( 'wp_ajax_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
37
- add_action( 'wp_ajax_nopriv_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
38
- }
39
- } else {
40
- add_action( $integration_info['hook'], array( $this, 'checkSpam' ) );
41
- }
42
- }
43
- }
44
-
45
- public function checkSpam( $argument )
46
- {
47
- global $cleantalk_executed;
48
-
49
- // Getting current integration name
50
- $current_integration = $this->get_current_integration_triggered( current_filter() );
51
- if( $current_integration ) {
52
- // Instantiate the integration object
53
- $class = '\\Cleantalk\\Antispam\\Integrations\\' . $current_integration;
54
- if( class_exists( $class )) {
55
- $this->integration = new $class();
56
- if( ! ( $this->integration instanceof \Cleantalk\Antispam\Integrations\IntegrationBase ) ) {
57
- // @ToDo have to handle an error
58
- do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, array('Integration is not instanse of IntegrationBase class.') );
59
- return;
60
- }
61
- // Run data collecting for spam checking
62
- $data = $this->integration->getDataForChecking( $argument );
63
- if( ! is_null( $data ) ) {
64
- // Go spam checking
65
- $base_call_result = apbct_base_call(
66
- array(
67
- 'message' => !empty( $data['message'] ) ? json_encode( $data['message'] ) : '',
68
- 'sender_email' => !empty( $data['email'] ) ? $data['email'] : '',
69
- 'sender_nickname' => !empty( $data['nickname'] ) ? $data['nickname'] : '',
70
- 'post_info' => array(
71
- 'comment_type' => 'contact_form_wordpress_' . strtolower($current_integration),
72
- 'post_url' => apbct_get_server_variable( 'HTTP_REFERER' ), // Page URL must be an previous page
73
- ),
74
- ),
75
- isset( $data['register'] ) ? true : false
76
- );
77
-
78
- $ct_result = $base_call_result['ct_result'];
79
-
80
- $cleantalk_executed = true;
81
-
82
- if ($ct_result->allow == 0) {
83
- // Do blocking if it is a spam
84
- $this->integration->doBlock( $ct_result->comment );
85
- }
86
- } else {
87
- // @ToDo have to handle an error
88
- return;
89
- }
90
- }
91
- }
92
- }
93
-
94
- private function get_current_integration_triggered( $hook )
95
- {
96
- if( $hook !== false ) {
97
- foreach( $this->integrations as $integration_name => $integration_info ) {
98
- if( is_array( $integration_info['hook'] ) ) {
99
- foreach( $integration_info['hook'] as $integration_hook ) {
100
- if( strpos( $hook, $integration_hook ) !== false ) {
101
- return $integration_name;
102
- }
103
- }
104
- } else {
105
- if( strpos( $hook, $integration_info['hook'] ) !== false ) {
106
- return $integration_name;
107
- }
108
- }
109
- }
110
- }
111
- return false;
112
- }
 
 
 
 
 
 
 
113
  }
1
+ <?php
2
+
3
+
4
+ namespace Cleantalk\Antispam;
5
+
6
+
7
+ class Integrations
8
+ {
9
+
10
+ private $integrations = array();
11
+
12
+ private $integration;
13
+
14
+ /**
15
+ * Integrations constructor.
16
+ *
17
+ * @param array $integrations
18
+ * @param array $settings
19
+ */
20
+ public function __construct( $integrations, $settings )
21
+ {
22
+ $this->integrations = $integrations;
23
+
24
+ foreach( $this->integrations as $integration_name => $integration_info ){
25
+
26
+ if( empty( $settings[ $integration_info['setting'] ] ) )
27
+ continue;
28
+
29
+ if( $integration_info['ajax'] ) {
30
+ if( is_array( $integration_info['hook'] ) ) {
31
+ foreach( $integration_info['hook'] as $hook ) {
32
+ add_action( 'wp_ajax_' . $hook, array( $this, 'checkSpam' ), 1 );
33
+ add_action( 'wp_ajax_nopriv_' . $hook, array( $this, 'checkSpam' ), 1 );
34
+ }
35
+ } else {
36
+ add_action( 'wp_ajax_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
37
+ add_action( 'wp_ajax_nopriv_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
38
+ }
39
+ } else {
40
+ if( is_array( $integration_info['hook'] ) ) {
41
+ foreach ( $integration_info['hook'] as $hook ) {
42
+ add_action( $hook, array( $this, 'checkSpam' ) );
43
+ }
44
+ } else {
45
+ add_action( $integration_info['hook'], array( $this, 'checkSpam' ) );
46
+ }
47
+
48
+ }
49
+ }
50
+ }
51
+
52
+ public function checkSpam( $argument )
53
+ {
54
+ global $cleantalk_executed;
55
+
56
+ // Getting current integration name
57
+ $current_integration = $this->get_current_integration_triggered( current_filter() );
58
+ if( $current_integration ) {
59
+ // Instantiate the integration object
60
+ $class = '\\Cleantalk\\Antispam\\Integrations\\' . $current_integration;
61
+ if( class_exists( $class )) {
62
+ $this->integration = new $class();
63
+ if( ! ( $this->integration instanceof \Cleantalk\Antispam\Integrations\IntegrationBase ) ) {
64
+ // @ToDo have to handle an error
65
+ do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, array('Integration is not instanse of IntegrationBase class.') );
66
+ return;
67
+ }
68
+ // Run data collecting for spam checking
69
+ $data = $this->integration->getDataForChecking( $argument );
70
+ if( ! is_null( $data ) ) {
71
+ // Go spam checking
72
+ $base_call_result = apbct_base_call(
73
+ array(
74
+ 'message' => !empty( $data['message'] ) ? json_encode( $data['message'] ) : '',
75
+ 'sender_email' => !empty( $data['email'] ) ? $data['email'] : '',
76
+ 'sender_nickname' => !empty( $data['nickname'] ) ? $data['nickname'] : '',
77
+ 'post_info' => array(
78
+ 'comment_type' => 'contact_form_wordpress_' . strtolower($current_integration),
79
+ 'post_url' => apbct_get_server_variable( 'HTTP_REFERER' ), // Page URL must be an previous page
80
+ ),
81
+ ),
82
+ isset( $data['register'] ) ? true : false
83
+ );
84
+
85
+ $ct_result = $base_call_result['ct_result'];
86
+
87
+ $cleantalk_executed = true;
88
+
89
+ if ($ct_result->allow == 0) {
90
+ // Do blocking if it is a spam
91
+ $this->integration->doBlock( $ct_result->comment );
92
+ }
93
+ } else {
94
+ // @ToDo have to handle an error
95
+ return;
96
+ }
97
+ }
98
+ }
99
+ }
100
+
101
+ private function get_current_integration_triggered( $hook )
102
+ {
103
+ if( $hook !== false ) {
104
+ foreach( $this->integrations as $integration_name => $integration_info ) {
105
+ if( is_array( $integration_info['hook'] ) ) {
106
+ foreach( $integration_info['hook'] as $integration_hook ) {
107
+ if( strpos( $hook, $integration_hook ) !== false ) {
108
+ return $integration_name;
109
+ }
110
+ }
111
+ } else {
112
+ if( strpos( $hook, $integration_info['hook'] ) !== false ) {
113
+ return $integration_name;
114
+ }
115
+ }
116
+ }
117
+ }
118
+ return false;
119
+ }
120
  }
lib/Cleantalk/Antispam/Integrations/FluentForm.php CHANGED
@@ -1,31 +1,31 @@
1
- <?php
2
-
3
-
4
- namespace Cleantalk\Antispam\Integrations;
5
-
6
-
7
- class FluentForm extends IntegrationBase
8
- {
9
-
10
- function getDataForChecking( $argument )
11
- {
12
- if( isset( $_POST['data'] ) ) {
13
- parse_str( $_POST['data'], $form_data );
14
- return ct_get_fields_any($form_data);
15
- }
16
- return null;
17
- }
18
-
19
- function doBlock($message)
20
- {
21
- wp_send_json(
22
- array(
23
- 'errors' => array(
24
- 'restricted' => array(
25
- $message
26
- )
27
- )
28
- ), 422
29
- );
30
- }
31
  }
1
+ <?php
2
+
3
+
4
+ namespace Cleantalk\Antispam\Integrations;
5
+
6
+
7
+ class FluentForm extends IntegrationBase
8
+ {
9
+
10
+ function getDataForChecking( $argument )
11
+ {
12
+ if( isset( $_POST['data'] ) ) {
13
+ parse_str( $_POST['data'], $form_data );
14
+ return ct_get_fields_any($form_data);
15
+ }
16
+ return null;
17
+ }
18
+
19
+ function doBlock($message)
20
+ {
21
+ wp_send_json(
22
+ array(
23
+ 'errors' => array(
24
+ 'restricted' => array(
25
+ $message
26
+ )
27
+ )
28
+ ), 422
29
+ );
30
+ }
31
  }
lib/Cleantalk/ApbctWP/API.php CHANGED
@@ -63,9 +63,12 @@ class API extends \Cleantalk\Common\API
63
  $url = defined('CLEANTALK_API_URL') ? CLEANTALK_API_URL : $url;
64
 
65
  // Adding agent version to data
66
- $data['agent'] = APBCT_AGENT;
67
 
68
- if($apbct->settings['wp__use_builtin_http_api']){
 
 
 
69
 
70
  $args = array(
71
  'body' => $data,
63
  $url = defined('CLEANTALK_API_URL') ? CLEANTALK_API_URL : $url;
64
 
65
  // Adding agent version to data
66
+ $data['agent'] = defined( 'APBCT_AGENT' ) ? APBCT_AGENT : '';
67
 
68
+ if(
69
+ $apbct->settings['wp__use_builtin_http_api'] &&
70
+ ( ! defined( 'SHORTINIT' ) || ( defined( 'SHORTINIT' ) && SHORTINIT === false ) )
71
+ ){
72
 
73
  $args = array(
74
  'body' => $data,
lib/Cleantalk/ApbctWP/Ajax.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ namespace Cleantalk\ApbctWP;
5
+
6
+
7
+ class Ajax {
8
+
9
+ /**
10
+ * string
11
+ */
12
+ private $table_prefix;
13
+
14
+ public function __construct()
15
+ {
16
+ define( 'DOING_AJAX', true );
17
+ define( 'SHORTINIT', true );
18
+
19
+ require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
20
+ require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-includes/pluggable.php' );
21
+
22
+ $this->checkRequest();
23
+
24
+ $this->setHeaders();
25
+
26
+ $this->handleRequest( $_REQUEST );
27
+ }
28
+
29
+ private function checkRequest()
30
+ {
31
+ if ( empty( $_REQUEST['action'] ) ) {
32
+ http_response_code( 400 );
33
+ die( '0' );
34
+ }
35
+
36
+ $this->check_ajax_referer( 'ct_secret_stuff' );
37
+ }
38
+
39
+ private function setHeaders()
40
+ {
41
+ header( 'Content-Type: text/html;' );
42
+ header( 'X-Robots-Tag: noindex' );
43
+ send_nosniff_header();
44
+ nocache_headers();
45
+ }
46
+
47
+ private function handleRequest( $request )
48
+ {
49
+ require_once( __DIR__ . '/../../../inc/cleantalk-ajax-handlers.php' );
50
+
51
+ global $apbct;
52
+
53
+ switch( $request['action'] ) {
54
+ case 'apbct_js_keys__get' :
55
+ apbct_js_keys__get();
56
+ break;
57
+ case 'apbct_email_check_before_post' :
58
+ if ( $apbct->settings['data__email_check_before_post'] ) {
59
+ apbct_email_check_before_post();
60
+ }
61
+ break;
62
+ case 'apbct_alt_session__save__AJAX':
63
+ // Using alternative sessions with ajax
64
+ if( $apbct->settings['data__set_cookies'] == 2 && $apbct->settings['data__set_cookies__alt_sessions_type'] == 2 ){
65
+ apbct_alt_session__save__AJAX();
66
+ }
67
+ break;
68
+ case 'apbct_alt_session__get__AJAX' :
69
+ // Using alternative sessions with ajax
70
+ if( $apbct->settings['data__set_cookies'] == 2 && $apbct->settings['data__set_cookies__alt_sessions_type'] == 2 ){
71
+ apbct_alt_session__get__AJAX();
72
+ }
73
+ break;
74
+ default :
75
+ return;
76
+ }
77
+
78
+ }
79
+
80
+
81
+ /**
82
+ * Verifies the Ajax request to prevent processing requests external of the blog.
83
+ * @inheritDoc check_ajax_referer()
84
+ */
85
+ private function check_ajax_referer( $action, $query_arg = false )
86
+ {
87
+ $nonce = '';
88
+
89
+ if ( $query_arg && isset( $_REQUEST[ $query_arg ] ) ) {
90
+ $nonce = $_REQUEST[ $query_arg ];
91
+ } elseif ( isset( $_REQUEST['_ajax_nonce'] ) ) {
92
+ $nonce = $_REQUEST['_ajax_nonce'];
93
+ } elseif ( isset( $_REQUEST['_wpnonce'] ) ) {
94
+ $nonce = $_REQUEST['_wpnonce'];
95
+ }
96
+
97
+ $result = $this->wp_verify_nonce( $nonce, $action );
98
+
99
+ if ( false === $result ) {
100
+ http_response_code( 403 );
101
+ die( -1 );
102
+ }
103
+
104
+ return $result;
105
+
106
+ }
107
+
108
+ /**
109
+ * Verifies that a correct security nonce was used with time limit.
110
+ * @inheritDoc wp_verify_nonce()
111
+ */
112
+ private function wp_verify_nonce( $nonce, $action )
113
+ {
114
+ $nonce = (string) $nonce;
115
+ $uid = apply_filters( 'nonce_user_logged_out', 0, $action );
116
+
117
+ if ( empty( $nonce ) ) {
118
+ return false;
119
+ }
120
+
121
+ $token = '';
122
+ $i = $this->wp_nonce_tick();
123
+
124
+ // Nonce generated 0-12 hours ago.
125
+ $expected = substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 );
126
+ if ( hash_equals( $expected, $nonce ) ) {
127
+ return 1;
128
+ }
129
+
130
+ // Nonce generated 12-24 hours ago.
131
+ $expected = substr( wp_hash( ( $i - 1 ) . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 );
132
+ if ( hash_equals( $expected, $nonce ) ) {
133
+ return 2;
134
+ }
135
+
136
+ // Invalid nonce.
137
+ return false;
138
+
139
+ }
140
+
141
+ /**
142
+ * Returns the time-dependent variable for nonce creation.
143
+ * @inheritDoc wp_nonce_tick()
144
+ */
145
+ private function wp_nonce_tick()
146
+ {
147
+ $nonce_life = apply_filters( 'nonce_life', DAY_IN_SECONDS );
148
+
149
+ return ceil( time() / ( $nonce_life / 2 ) );
150
+ }
151
+
152
+ }
153
+
154
+ new Ajax();
lib/Cleantalk/ApbctWP/CleantalkSettingsTemplates.php CHANGED
@@ -244,10 +244,6 @@ class CleantalkSettingsTemplates {
244
  if( isset( $settings['misc__debug_ajax'] ) ) {
245
  unset( $settings['misc__debug_ajax'] );
246
  }
247
- // Remove multisite__white_label__hoster_key from export
248
- if( isset( $settings['multisite__white_label__hoster_key'] ) ) {
249
- unset( $settings['multisite__white_label__hoster_key'] );
250
- }
251
  // Remove all WPMS from export
252
  $settings = array_filter( $settings, function( $key ){
253
  return strpos( $key, 'multisite__' ) === false;
244
  if( isset( $settings['misc__debug_ajax'] ) ) {
245
  unset( $settings['misc__debug_ajax'] );
246
  }
 
 
 
 
247
  // Remove all WPMS from export
248
  $settings = array_filter( $settings, function( $key ){
249
  return strpos( $key, 'multisite__' ) === false;
lib/Cleantalk/ApbctWP/Cron.php CHANGED
@@ -2,288 +2,52 @@
2
 
3
  namespace Cleantalk\ApbctWP;
4
 
5
- /**
6
- * CleanTalk Cron class
7
- *
8
- * @package Antispam by CleanTalk
9
- * @subpackage Cron
10
- * @Version 2.1.1
11
- * @author Cleantalk team (welcome@cleantalk.org)
12
- * @copyright (C) 2014 CleanTalk team (http://cleantalk.org)
13
- * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
14
- *
15
- */
16
 
17
- class Cron
18
- {
19
- public $tasks = array(); // Array with tasks
20
- public $tasks_to_run = array(); // Array with tasks which should be run now
21
- public $tasks_completed = array(); // Result of executed tasks
22
-
23
- // Currently selected task
24
- public $task;
25
- private $handler;
26
- private $period;
27
- private $next_call;
28
- private $params;
29
-
30
- // Option name with cron data
31
- const CRON_OPTION_NAME = 'cleantalk_cron';
32
-
33
- // Interval in seconds for restarting the task
34
- const TASK_EXECUTION_MIN_INTERVAL = 120;
35
-
36
- /**
37
- * Cron constructor.
38
- * Getting tasks option.
39
- */
40
- public function __construct()
41
- {
42
- $this->tasks = self::getTasks();
43
- }
44
-
45
- /**
46
- * Getting all tasks
47
- *
48
- * @return array|bool|mixed|void
49
- */
50
- public static function getTasks(){
51
- $tasks = get_option(self::CRON_OPTION_NAME);
52
- return empty($tasks) ? array() : $tasks;
53
- }
54
-
55
- /**
56
- * Adding new cron task
57
- *
58
- * @param $task
59
- * @param $handler
60
- * @param $period
61
- * @param null $first_call
62
- * @param array $params
63
- *
64
- * @return bool
65
- */
66
- public static function addTask($task, $handler, $period, $first_call = null, $params = array())
67
- {
68
- // First call time() + preiod
69
- $first_call = !$first_call ? time()+$period : $first_call;
70
-
71
- $tasks = self::getTasks();
72
-
73
- if( isset( $tasks[ $task ] ) ){
74
- return false;
75
- }
76
-
77
- // Task entry
78
- $tasks[$task] = array(
79
- 'handler' => $handler,
80
- 'next_call' => $first_call,
81
- 'period' => $period,
82
- 'params' => $params,
83
- );
84
-
85
- return update_option(self::CRON_OPTION_NAME, $tasks);
86
- }
87
-
88
- /**
89
- * Removing cron task
90
- *
91
- * @param $task
92
- *
93
- * @return bool
94
- */
95
- public static function removeTask($task)
96
- {
97
- $tasks = self::getTasks();
98
-
99
- if( ! isset( $tasks[ $task ] ) ){
100
- return false;
101
- }
102
-
103
- unset($tasks[$task]);
104
-
105
- return update_option(self::CRON_OPTION_NAME, $tasks);
106
- }
107
-
108
- // Updates cron task, create task if not exists
109
- public static function updateTask($task, $handler, $period, $first_call = null, $params = array()){
110
- self::removeTask($task);
111
- self::addTask($task, $handler, $period, $first_call, $params);
112
- }
113
-
114
- /**
115
- * Getting tasks which should be run
116
- *
117
- * @return bool|array
118
- */
119
- public static function checkTasks()
120
- {
121
- $tasks = self::getTasks();
122
-
123
- // No tasks to run
124
- if( empty( $tasks ) ){
125
- return false;
126
- }
127
-
128
- $tasks_to_run = array();
129
- foreach($tasks as $task => &$task_data){
130
-
131
- if(
132
- ! isset( $task_data['processing'], $task_data['last_call'] ) ||
133
- ( $task_data['processing'] === true && time() - $task_data['last_call'] > self::TASK_EXECUTION_MIN_INTERVAL )
134
- ){
135
- $task_data['processing'] = false;
136
- $task_data['last_call'] = 0;
137
- }
138
-
139
- if(
140
- $task_data['processing'] === false &&
141
- $task_data['next_call'] <= time() // default condition
142
- ){
143
-
144
- $task_data['processing'] = true;
145
- $task_data['last_call'] = time();
146
-
147
- $tasks_to_run[] = $task;
148
- }
149
 
150
- // Hard bug fix
151
- if( ! isset( $task_data['params'] ) ) {
152
- $task_data['params'] = array();
153
- }
154
-
155
- }
156
-
157
- self::saveTasks( $tasks );
158
-
159
- return $tasks_to_run;
160
- }
161
-
162
- /**
163
- * Run all tasks from $this->tasks_to_run.
164
- * Saving all results to (array) $this->tasks_completed
165
- *
166
- * @return void
167
- */
168
- public function runTasks()
169
- {
170
- global $apbct;
171
-
172
- if( empty( $this->tasks_to_run ) ){
173
- return;
174
- }
175
-
176
- foreach($this->tasks_to_run as $task){
177
-
178
- $this->selectTask($task);
179
-
180
- if(function_exists($this->handler)){
181
-
182
- $result = call_user_func_array($this->handler, isset($this->params) ? $this->params : array());
183
-
184
- if(empty($result['error'])){
185
- $this->tasks_completed[$task] = true;
186
- $apbct->error_delete($task, 'save_data', 'cron');
187
- }else{
188
- $this->tasks_completed[$task] = false;
189
- $apbct->error_add($task, $result, 'cron');
190
- }
191
-
192
- }else{
193
- $this->tasks_completed[$task] = false;
194
- $apbct->error_add($task, $this->handler.'_IS_NOT_EXISTS', 'cron');
195
- }
196
-
197
- $this->saveTask($task);
198
-
199
- }
200
-
201
- //* Merging executed tasks with updated during execution
202
- $tasks = self::getTasks();
203
-
204
- foreach($tasks as $task => $task_data){
205
-
206
- // Task where added during execution
207
- if(!isset($this->tasks[$task])){
208
- $this->tasks[$task] = $task_data;
209
- continue;
210
- }
211
-
212
- // Task where updated during execution
213
- if($task_data !== $this->tasks[$task]){
214
- $this->tasks[$task] = $task_data;
215
- continue;
216
- }
217
-
218
- // Setting next call depending on results
219
- if(isset($this->tasks[$task], $this->tasks_completed[$task])){
220
- $this->tasks[$task]['next_call'] = $this->tasks_completed[$task]
221
- ? time() + $this->tasks[$task]['period']
222
- : time() + round($this->tasks[$task]['period']/4);
223
- }
224
-
225
- if(empty($this->tasks[$task]['next_call']) || $this->tasks[$task]['next_call'] < time()){
226
- $this->tasks[$task]['next_call'] = time() + $this->tasks[$task]['period'];
227
- }
228
-
229
- }
230
-
231
- // Task where deleted during execution
232
- $tmp = $this->tasks;
233
- foreach($tmp as $task => $task_data){
234
- if( ! isset( $tasks[ $task ] ) ){
235
- unset( $this->tasks[ $task ] );
236
- }
237
- }
238
-
239
- //*/ End of merging
240
-
241
- self::saveTasks( $this->tasks );
242
- }
243
-
244
- /**
245
- * Select task in private properties for comfortable use
246
- *
247
- * @param $task
248
- */
249
- private function selectTask($task)
250
- {
251
- $this->task = $task;
252
- $this->handler = $this->tasks[$task]['handler'];
253
- $this->period = $this->tasks[$task]['period'];
254
- $this->next_call = $this->tasks[$task]['next_call'];
255
- $this->params = isset($this->tasks[$task]['params']) ? $this->tasks[$task]['params'] : array();
256
- }
257
-
258
- /**
259
- * Save task in private properties for comfortable use
260
- *
261
- * @param null $task
262
- */
263
- private function saveTask( $task = null )
264
- {
265
- $task = $task ?: $this->task;
266
-
267
- $this->tasks[$task]['handler'] = $this->handler;
268
- $this->tasks[$task]['period'] = $this->period;
269
- $this->tasks[$task]['next_call'] = $this->next_call;
270
- $this->tasks[$task]['params'] = $this->params;
271
- }
272
-
273
- /**
274
- * Save option with tasks
275
- *
276
- * @param array $tasks
277
- */
278
- public static function saveTasks( $tasks = array() )
279
- {
280
- update_option( self::CRON_OPTION_NAME, $tasks );
281
- }
282
-
283
- /**
284
- * @param array $tasks_to_run
285
- */
286
- public function setTasksToRun( $tasks_to_run ){
287
- $this->tasks_to_run = $tasks_to_run;
288
- }
289
  }
2
 
3
  namespace Cleantalk\ApbctWP;
4
 
5
+ class Cron extends \Cleantalk\Common\Cron {
 
 
 
 
 
 
 
 
 
 
6
 
7
+ /**
8
+ * Get timestamp last Cron started.
9
+ *
10
+ * @return int timestamp
11
+ */
12
+ public function getCronLastStart()
13
+ {
14
+ global $apbct;
15
+ return $apbct->stats['cron']['last_start'];
16
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
+ /**
19
+ * Save timestamp of running Cron.
20
+ *
21
+ * @return bool
22
+ */
23
+ public function setCronLastStart()
24
+ {
25
+ global $apbct;
26
+ $apbct->stats['cron']['last_start'] = time();
27
+ $apbct->save('stats');
28
+ return true;
29
+ }
30
+
31
+ /**
32
+ * Save option with tasks
33
+ *
34
+ * @param array $tasks
35
+ *
36
+ * @return bool
37
+ */
38
+ public function saveTasks( $tasks )
39
+ {
40
+ return update_option( $this->cron_option_name, $tasks );
41
+ }
42
+
43
+ /**
44
+ * Getting all tasks
45
+ *
46
+ * @return array
47
+ */
48
+ public function getTasks()
49
+ {
50
+ $tasks = get_option( $this->cron_option_name );
51
+ return empty( $tasks ) ? array() : $tasks;
52
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  }
lib/Cleantalk/ApbctWP/FindSpam/ListTable/Users.php CHANGED
@@ -7,6 +7,8 @@ class Users extends \Cleantalk\ApbctWP\CleantalkListTable
7
 
8
  protected $apbct;
9
 
 
 
10
  function __construct(){
11
 
12
  parent::__construct(array(
@@ -18,6 +20,10 @@ class Users extends \Cleantalk\ApbctWP\CleantalkListTable
18
 
19
  $this->row_actions_handler();
20
 
 
 
 
 
21
  $this->prepare_items();
22
 
23
  global $apbct;
@@ -27,15 +33,19 @@ class Users extends \Cleantalk\ApbctWP\CleantalkListTable
27
 
28
  // Set columns
29
  function get_columns(){
30
- return array(
31
- 'cb' => '<input type="checkbox" />',
32
- 'ct_username' => esc_html__( 'Username', 'cleantalk-spam-protect'),
33
- 'ct_name' => esc_html__( 'Name', 'cleantalk-spam-protect'),
34
- 'ct_email' => esc_html__( 'E-mail', 'cleantalk-spam-protect'),
35
- 'ct_signed_up' => esc_html__( 'Signed up', 'cleantalk-spam-protect'),
36
- 'ct_role' => esc_html__( 'Role', 'cleantalk-spam-protect'),
37
- 'ct_posts' => esc_html__( 'Posts', 'cleantalk-spam-protect'),
38
- );
 
 
 
 
39
  }
40
 
41
  // CheckBox column
@@ -103,6 +113,7 @@ class Users extends \Cleantalk\ApbctWP\CleantalkListTable
103
  case 'ct_checked':
104
  case 'ct_spam':
105
  case 'ct_bad':
 
106
  return $item[ $column_name ];
107
  default:
108
  return print_r( $item, true ) ;
@@ -274,4 +285,21 @@ class Users extends \Cleantalk\ApbctWP\CleantalkListTable
274
 
275
  }
276
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  }
7
 
8
  protected $apbct;
9
 
10
+ protected $wc_active = false;
11
+
12
  function __construct(){
13
 
14
  parent::__construct(array(
20
 
21
  $this->row_actions_handler();
22
 
23
+ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
24
+ $this->wc_active = true;
25
+ }
26
+
27
  $this->prepare_items();
28
 
29
  global $apbct;
33
 
34
  // Set columns
35
  function get_columns(){
36
+ $columns = array(
37
+ 'cb' => '<input type="checkbox" />',
38
+ 'ct_username' => esc_html__( 'Username', 'cleantalk-spam-protect'),
39
+ 'ct_name' => esc_html__( 'Name', 'cleantalk-spam-protect'),
40
+ 'ct_email' => esc_html__( 'E-mail', 'cleantalk-spam-protect'),
41
+ 'ct_signed_up' => esc_html__( 'Signed up', 'cleantalk-spam-protect'),
42
+ 'ct_role' => esc_html__( 'Role', 'cleantalk-spam-protect'),
43
+ 'ct_posts' => esc_html__( 'Posts', 'cleantalk-spam-protect'),
44
+ );
45
+ if( $this->wc_active ) {
46
+ $columns['ct_orders'] = esc_html__( 'Completed WC orders', 'cleantalk-spam-protect') ;
47
+ }
48
+ return $columns;
49
  }
50
 
51
  // CheckBox column
113
  case 'ct_checked':
114
  case 'ct_spam':
115
  case 'ct_bad':
116
+ case 'ct_orders':
117
  return $item[ $column_name ];
118
  default:
119
  return print_r( $item, true ) ;
285
 
286
  }
287
 
288
+ protected function get_wc_orders_count( $user_id )
289
+ {
290
+ $args = array(
291
+ 'post_type' => 'shop_order',
292
+ 'post_status' => 'wc-completed',
293
+ 'numberposts' => -1,
294
+ 'meta_key' => '_customer_user',
295
+ 'meta_value' => $user_id,
296
+ );
297
+
298
+ $description = '';
299
+ if( $count = count( get_posts( $args ) ) ) {
300
+ $description = esc_html__( 'Do "accurate check" to skip checking this user', 'cleantalk-spam-protect' );
301
+ }
302
+ return '<p>'.$count.'</p><i>'.$description.'</i>';
303
+ }
304
+
305
  }
lib/Cleantalk/ApbctWP/FindSpam/ListTable/UsersScan.php CHANGED
@@ -33,16 +33,22 @@ class UsersScan extends Users
33
 
34
  $user_obj = get_userdata( $user_id );
35
 
36
- $this->items[] = array(
37
- 'ct_id' => $user_obj->ID,
38
- 'ct_username' => $user_obj,
39
- 'ct_name' => $user_obj->display_name,
40
- 'ct_email' => $user_obj->user_email,
41
- 'ct_signed_up' => $user_obj->user_registered,
42
- 'ct_role' => implode( ', ', $user_obj->roles ),
43
- 'ct_posts' => count_user_posts( $user_id ),
44
  );
45
 
 
 
 
 
 
 
46
  }
47
 
48
  }
@@ -64,4 +70,4 @@ class UsersScan extends Users
64
  <?php
65
  }
66
 
67
- }
33
 
34
  $user_obj = get_userdata( $user_id );
35
 
36
+ $items = array(
37
+ 'ct_id' => $user_obj->ID,
38
+ 'ct_username' => $user_obj,
39
+ 'ct_name' => $user_obj->display_name,
40
+ 'ct_email' => $user_obj->user_email,
41
+ 'ct_signed_up' => $user_obj->user_registered,
42
+ 'ct_role' => implode( ', ', $user_obj->roles ),
43
+ 'ct_posts' => count_user_posts( $user_id ),
44
  );
45
 
46
+ if( $this->wc_active ) {
47
+ $items['ct_orders'] = $this->get_wc_orders_count( $user_obj->ID );
48
+ }
49
+
50
+ $this->items[] = $items;
51
+
52
  }
53
 
54
  }
70
  <?php
71
  }
72
 
73
+ }
lib/Cleantalk/ApbctWP/FindSpam/Page.php CHANGED
@@ -103,7 +103,7 @@ class Page
103
  <div id="ct_check_tabs">
104
  <ul>
105
  <li <?php echo (1 == $this->current_tab) ? 'class="active"' : ''; ?>><a href="<?php echo $this->spam_checker->getPageScriptName(); ?>?page=ct_check_<?php echo $this->spam_checker->getPageSlug(); ?>"><?php esc_html_e( 'Scan and new results', 'cleantalk-spam-protect') ?></a></li>
106
- <li <?php echo (2 == $this->current_tab) ? 'class="active"' : ''; ?>><a href="<?php echo $this->spam_checker->getPageScriptName(); ?>?page=ct_check_<?php echo $this->spam_checker->getPageSlug(); ?>_bad"><?php esc_html_e( 'Non-checkable users', 'cleantalk-spam-protect') ?></a></li>
107
  <li <?php echo (3 == $this->current_tab) ? 'class="active"' : ''; ?>><a href="<?php echo $this->spam_checker->getPageScriptName(); ?>?page=ct_check_<?php echo $this->spam_checker->getPageSlug(); ?>_logs"><?php esc_html_e( 'Scan logs', 'cleantalk-spam-protect') ?></a></li>
108
  </ul>
109
  <div id="ct_check_content">
103
  <div id="ct_check_tabs">
104
  <ul>
105
  <li <?php echo (1 == $this->current_tab) ? 'class="active"' : ''; ?>><a href="<?php echo $this->spam_checker->getPageScriptName(); ?>?page=ct_check_<?php echo $this->spam_checker->getPageSlug(); ?>"><?php esc_html_e( 'Scan and new results', 'cleantalk-spam-protect') ?></a></li>
106
+ <?php if($this->spam_checker->getPageSlug() === 'users') { ?><li <?php echo (2 == $this->current_tab) ? 'class="active"' : ''; ?>><a href="<?php echo $this->spam_checker->getPageScriptName(); ?>?page=ct_check_<?php echo $this->spam_checker->getPageSlug(); ?>_bad"><?php esc_html_e( 'Non-checkable users', 'cleantalk-spam-protect') ?></a></li><?php }?>
107
  <li <?php echo (3 == $this->current_tab) ? 'class="active"' : ''; ?>><a href="<?php echo $this->spam_checker->getPageScriptName(); ?>?page=ct_check_<?php echo $this->spam_checker->getPageSlug(); ?>_logs"><?php esc_html_e( 'Scan logs', 'cleantalk-spam-protect') ?></a></li>
108
  </ul>
109
  <div id="ct_check_content">
lib/Cleantalk/ApbctWP/FindSpam/UsersChecker.php CHANGED
@@ -153,6 +153,11 @@ class UsersChecker extends Checker
153
 
154
  global $apbct, $wpdb;
155
 
 
 
 
 
 
156
  $amount = !empty($_POST['amount']) && intval($_POST['amount'])
157
  ? intval($_POST['amount'])
158
  : 100;
@@ -170,6 +175,12 @@ class UsersChecker extends Checker
170
 
171
  $from_till = " AND $wpdb->users.user_registered >= '$from_date' AND $wpdb->users.user_registered <= '$till_date'";
172
 
 
 
 
 
 
 
173
  }
174
 
175
  $u = $wpdb->get_results("
@@ -179,6 +190,7 @@ class UsersChecker extends Checker
179
  NOT EXISTS(SELECT * FROM {$wpdb->usermeta} as meta WHERE {$wpdb->users}.ID = meta.user_id AND meta.meta_key = 'ct_bad') AND
180
  NOT EXISTS(SELECT * FROM {$wpdb->usermeta} as meta WHERE {$wpdb->users}.ID = meta.user_id AND meta.meta_key = 'ct_checked') AND
181
  NOT EXISTS(SELECT * FROM {$wpdb->usermeta} as meta WHERE {$wpdb->users}.ID = meta.user_id AND meta.meta_key = 'ct_checked_now')
 
182
  $from_till
183
  ORDER BY {$wpdb->users}.user_registered ASC
184
  LIMIT $amount;"
153
 
154
  global $apbct, $wpdb;
155
 
156
+ $wc_active = false;
157
+ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
158
+ $wc_active = true;
159
+ }
160
+
161
  $amount = !empty($_POST['amount']) && intval($_POST['amount'])
162
  ? intval($_POST['amount'])
163
  : 100;
175
 
176
  $from_till = " AND $wpdb->users.user_registered >= '$from_date' AND $wpdb->users.user_registered <= '$till_date'";
177
 
178
+ }
179
+
180
+ $wc_orders = '';
181
+
182
+ if( $wc_active && ! empty( $_POST['accurate_check'] ) ) {
183
+ $wc_orders = " AND NOT EXISTS (SELECT posts.* FROM {$wpdb->posts} AS posts INNER JOIN {$wpdb->postmeta} AS postmeta WHERE posts.post_type = 'shop_order' AND posts.post_status = 'wc-completed' AND posts.ID = postmeta.post_id AND postmeta.meta_key = '_customer_user' AND postmeta.meta_value = {$wpdb->users}.ID)";
184
  }
185
 
186
  $u = $wpdb->get_results("
190
  NOT EXISTS(SELECT * FROM {$wpdb->usermeta} as meta WHERE {$wpdb->users}.ID = meta.user_id AND meta.meta_key = 'ct_bad') AND
191
  NOT EXISTS(SELECT * FROM {$wpdb->usermeta} as meta WHERE {$wpdb->users}.ID = meta.user_id AND meta.meta_key = 'ct_checked') AND
192
  NOT EXISTS(SELECT * FROM {$wpdb->usermeta} as meta WHERE {$wpdb->users}.ID = meta.user_id AND meta.meta_key = 'ct_checked_now')
193
+ $wc_orders
194
  $from_till
195
  ORDER BY {$wpdb->users}.user_registered ASC
196
  LIMIT $amount;"
lib/Cleantalk/ApbctWP/Firewall/AntiCrawler.php CHANGED
@@ -69,12 +69,18 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule{
69
 
70
  if ( APBCT_WRITE_LIMIT !== $i ) {
71
 
 
 
 
 
72
  // Cast result to int
73
- // @ToDo check the output $entry
74
  $ua_id = preg_replace('/[^\d]*/', '', $entry[0]);
75
  $ua_template = isset($entry[1]) && apbct_is_regexp($entry[1]) ? Helper::db__prepare_param( $entry[1] ) : 0;
76
  $ua_status = isset($entry[2]) ? $entry[2] : 0;
77
 
 
 
 
78
  }
79
 
80
  $values[] = '('. $ua_id .','. $ua_template .','. $ua_status .')';
@@ -164,7 +170,7 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule{
164
  foreach( $this->ip_array as $ip_origin => $current_ip ) {
165
 
166
  // Skip by 301 response code
167
- if( http_response_code() == 301 ){
168
  $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_ANTICRAWLER', );
169
  return $results;
170
  }
@@ -353,14 +359,14 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule{
353
 
354
  public function _die( $result ){
355
 
356
- global $apbct, $wpdb;
357
 
358
  // File exists?
359
  if(file_exists(CLEANTALK_PLUGIN_DIR . "lib/Cleantalk/ApbctWP/Firewall/die_page_anticrawler.html")){
360
 
361
  $sfw_die_page = file_get_contents(CLEANTALK_PLUGIN_DIR . "lib/Cleantalk/ApbctWP/Firewall/die_page_anticrawler.html");
362
 
363
- $net_count = $wpdb->get_var('SELECT COUNT(*) FROM ' . APBCT_TBL_FIREWALL_DATA );
364
 
365
  // Translation
366
  $replaces = array(
@@ -422,4 +428,19 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule{
422
  return false;
423
 
424
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
425
  }
69
 
70
  if ( APBCT_WRITE_LIMIT !== $i ) {
71
 
72
+ if( ! isset( $entry[0], $entry[1] ) ){
73
+ continue;
74
+ }
75
+
76
  // Cast result to int
 
77
  $ua_id = preg_replace('/[^\d]*/', '', $entry[0]);
78
  $ua_template = isset($entry[1]) && apbct_is_regexp($entry[1]) ? Helper::db__prepare_param( $entry[1] ) : 0;
79
  $ua_status = isset($entry[2]) ? $entry[2] : 0;
80
 
81
+ if( ! $ua_id || ! $ua_template ){
82
+ continue;
83
+ }
84
  }
85
 
86
  $values[] = '('. $ua_id .','. $ua_template .','. $ua_status .')';
170
  foreach( $this->ip_array as $ip_origin => $current_ip ) {
171
 
172
  // Skip by 301 response code
173
+ if( $this->is_redirected() ){
174
  $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_ANTICRAWLER', );
175
  return $results;
176
  }
359
 
360
  public function _die( $result ){
361
 
362
+ global $apbct;
363
 
364
  // File exists?
365
  if(file_exists(CLEANTALK_PLUGIN_DIR . "lib/Cleantalk/ApbctWP/Firewall/die_page_anticrawler.html")){
366
 
367
  $sfw_die_page = file_get_contents(CLEANTALK_PLUGIN_DIR . "lib/Cleantalk/ApbctWP/Firewall/die_page_anticrawler.html");
368
 
369
+ $net_count = $apbct->stats['sfw']['entries'];
370
 
371
  // Translation
372
  $replaces = array(
428
  return false;
429
 
430
  }
431
+
432
+ private function is_redirected()
433
+ {
434
+ $is_redirect = false;
435
+ if( Server::get( 'HTTP_REFERER' ) !== '' && Server::get( 'HTTP_HOST' ) !== '' && $this->is_cloudflare() ) {
436
+ $parse_referer = parse_url( Server::get( 'HTTP_REFERER' ) );
437
+ $is_redirect = Server::get( 'HTTP_HOST' ) !== $parse_referer['host'];
438
+ }
439
+ return http_response_code() == 301 || $is_redirect;
440
+ }
441
+
442
+ private function is_cloudflare()
443
+ {
444
+ return Server::get('HTTP_CF_RAY') && Server::get('HTTP_CF_CONNECTING_IP') && Server::get('HTTP_CF_REQUEST_ID');
445
+ }
446
  }
lib/Cleantalk/ApbctWP/Firewall/AntiFlood.php CHANGED
@@ -197,14 +197,14 @@ class AntiFlood extends \Cleantalk\Common\Firewall\FirewallModule{
197
 
198
  parent::_die( $result );
199
 
200
- global $wpdb;
201
 
202
  // File exists?
203
  if( file_exists( CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk/ApbctWP/Firewall/die_page_antiflood.html' ) ){
204
 
205
  $sfw_die_page = file_get_contents( CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk/ApbctWP/Firewall/die_page_antiflood.html' );
206
 
207
- $net_count = $wpdb->get_var('SELECT COUNT(*) FROM ' . APBCT_TBL_FIREWALL_DATA );
208
 
209
  // Translation
210
  $replaces = array(
197
 
198
  parent::_die( $result );
199
 
200
+ global $apbct;
201
 
202
  // File exists?
203
  if( file_exists( CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk/ApbctWP/Firewall/die_page_antiflood.html' ) ){
204
 
205
  $sfw_die_page = file_get_contents( CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk/ApbctWP/Firewall/die_page_antiflood.html' );
206
 
207
+ $net_count = $apbct->stats['sfw']['entries'];
208
 
209
  // Translation
210
  $replaces = array(
lib/Cleantalk/ApbctWP/Firewall/SFW.php CHANGED
@@ -262,7 +262,7 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
262
  */
263
  public function _die( $result ){
264
 
265
- global $apbct, $wpdb;
266
 
267
  parent::_die( $result );
268
 
@@ -279,7 +279,7 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
279
 
280
  $sfw_die_page = file_get_contents(CLEANTALK_PLUGIN_DIR . "lib/Cleantalk/ApbctWP/Firewall/die_page_sfw.html");
281
 
282
- $net_count = $wpdb->get_var('SELECT COUNT(*) FROM ' . APBCT_TBL_FIREWALL_DATA );
283
 
284
  $status = $result['status'] == 'PASS_SFW__BY_WHITELIST' ? '1' : '0';
285
  $cookie_val = md5( $result['ip'] . $this->api_key ) . $status;
@@ -511,8 +511,8 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
511
  public static function update__get_multifile( $api_key ){
512
 
513
  // Getting remote file name
514
- $result = API::method__get_2s_blacklists_db( $api_key, 'multifiles', '3_0' );
515
-
516
  if( empty( $result['error'] ) ){
517
 
518
  if( ! empty( $result['file_url'] ) ){
@@ -525,6 +525,7 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
525
  'multifile_url' => trim( $result['file_url'] ),
526
  'useragent_url' => trim( $result['file_ua_url'] ),
527
  'file_urls' => $data,
 
528
  );
529
 
530
  }else
@@ -545,7 +546,7 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
545
  * @return array|bool array('error' => STRING)
546
  */
547
  public static function update__write_to_db( $db, $db__table__data, $file_url = null ){
548
-
549
  $data = Helper::http__get_data_from_remote_gz__and_parse_csv( $file_url );
550
 
551
  if( empty( $data['errors'] ) ){
@@ -562,14 +563,18 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
562
  continue;
563
 
564
  if ( APBCT_WRITE_LIMIT !== $i ) {
565
-
 
 
 
 
566
  // Cast result to int
567
  $ip = preg_replace( '/[^\d]*/', '', $entry[0] );
568
  $mask = preg_replace( '/[^\d]*/', '', $entry[1] );
569
  $status = isset( $entry[2] ) ? $entry[2] : 0;
570
  $source = isset( $entry[3] ) ? (int) $entry[3] : 'NULL';
571
-
572
- $values[] = '('. $ip .','. $mask .','. $status .','. $source .')';
573
  }
574
 
575
  }
262
  */
263
  public function _die( $result ){
264
 
265
+ global $apbct;
266
 
267
  parent::_die( $result );
268
 
279
 
280
  $sfw_die_page = file_get_contents(CLEANTALK_PLUGIN_DIR . "lib/Cleantalk/ApbctWP/Firewall/die_page_sfw.html");
281
 
282
+ $net_count = $apbct->stats['sfw']['entries'];
283
 
284
  $status = $result['status'] == 'PASS_SFW__BY_WHITELIST' ? '1' : '0';
285
  $cookie_val = md5( $result['ip'] . $this->api_key ) . $status;
511
  public static function update__get_multifile( $api_key ){
512
 
513
  // Getting remote file name
514
+ $result = API::method__get_2s_blacklists_db( $api_key, 'multifiles', '3_1' );
515
+
516
  if( empty( $result['error'] ) ){
517
 
518
  if( ! empty( $result['file_url'] ) ){
525
  'multifile_url' => trim( $result['file_url'] ),
526
  'useragent_url' => trim( $result['file_ua_url'] ),
527
  'file_urls' => $data,
528
+ 'file_ck_url' => trim( $result['file_ck_url'] ),
529
  );
530
 
531
  }else
546
  * @return array|bool array('error' => STRING)
547
  */
548
  public static function update__write_to_db( $db, $db__table__data, $file_url = null ){
549
+
550
  $data = Helper::http__get_data_from_remote_gz__and_parse_csv( $file_url );
551
 
552
  if( empty( $data['errors'] ) ){
563
  continue;
564
 
565
  if ( APBCT_WRITE_LIMIT !== $i ) {
566
+
567
+ if( empty( $entry[0] ) || empty ($entry[1] ) ){
568
+ continue;
569
+ }
570
+
571
  // Cast result to int
572
  $ip = preg_replace( '/[^\d]*/', '', $entry[0] );
573
  $mask = preg_replace( '/[^\d]*/', '', $entry[1] );
574
  $status = isset( $entry[2] ) ? $entry[2] : 0;
575
  $source = isset( $entry[3] ) ? (int) $entry[3] : 'NULL';
576
+
577
+ $values[] = "($ip, $mask, $status, $source)";
578
  }
579
 
580
  }
lib/Cleantalk/ApbctWP/GetFieldsAny.php ADDED
@@ -0,0 +1,397 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Cleantalk\ApbctWP;
4
+
5
+ use Cleantalk\ApbctWP\Variables\Cookie;
6
+
7
+ class GetFieldsAny {
8
+
9
+ /**
10
+ * @var array
11
+ */
12
+ private $input_array;
13
+
14
+ /**
15
+ * Skip fields with these strings and known service fields
16
+ * @var array
17
+ */
18
+ private $skip_fields_with_strings = array(
19
+ // Common
20
+ 'ct_checkjs', //Do not send ct_checkjs
21
+ 'nonce', //nonce for strings such as 'rsvp_nonce_name'
22
+ 'security',
23
+ // 'action',
24
+ 'http_referer',
25
+ 'referer-page',
26
+ 'timestamp',
27
+ 'captcha',
28
+ // Formidable Form
29
+ 'form_key',
30
+ 'submit_entry',
31
+ // Custom Contact Forms
32
+ 'form_id',
33
+ 'ccf_form',
34
+ 'form_page',
35
+ // Qu Forms
36
+ 'iphorm_uid',
37
+ 'form_url',
38
+ 'post_id',
39
+ 'iphorm_ajax',
40
+ 'iphorm_id',
41
+ // Fast SecureContact Froms
42
+ 'fs_postonce_1',
43
+ 'fscf_submitted',
44
+ 'mailto_id',
45
+ 'si_contact_action',
46
+ // Ninja Forms
47
+ 'formData_id',
48
+ 'formData_settings',
49
+ 'formData_fields_\d+_id',
50
+ 'formData_fields_\d+_files.*',
51
+ // E_signature
52
+ 'recipient_signature',
53
+ 'output_\d+_\w{0,2}',
54
+ // Contact Form by Web-Settler protection
55
+ '_formId',
56
+ '_returnLink',
57
+ // Social login and more
58
+ '_save',
59
+ '_facebook',
60
+ '_social',
61
+ 'user_login-',
62
+ // Contact Form 7
63
+ '_wpcf7',
64
+ 'ebd_settings',
65
+ 'ebd_downloads_',
66
+ 'ecole_origine',
67
+ 'signature',
68
+ // Ultimate Form Builder
69
+ 'form_data_%d_name',
70
+ );
71
+
72
+ /**
73
+ * Skip request if fields exists
74
+ * @var array
75
+ */
76
+ private $skip_params = array(
77
+ 'ipn_track_id', // PayPal IPN #
78
+ 'txn_type', // PayPal transaction type
79
+ 'payment_status', // PayPal payment status
80
+ 'ccbill_ipn', // CCBill IPN
81
+ 'ct_checkjs', // skip ct_checkjs field
82
+ 'api_mode', // DigiStore-API
83
+ 'loadLastCommentId' // Plugin: WP Discuz. ticket_id=5571
84
+ );
85
+
86
+ /**
87
+ * Reset $message if we have a sign-up data
88
+ * @var array
89
+ */
90
+ private $skip_message_post = array(
91
+ 'edd_action', // Easy Digital Downloads
92
+ );
93
+
94
+ /**
95
+ * Fields to replace with ****
96
+ * @var array
97
+ */
98
+ private $obfuscate_params = array(
99
+ 'password',
100
+ 'pass',
101
+ 'pwd',
102
+ 'pswd'
103
+ );
104
+
105
+ /**
106
+ * If the form checking will be processing
107
+ * @var bool
108
+ */
109
+ private $contact = true;
110
+
111
+ /**
112
+ * @var array
113
+ */
114
+ private $visible_fields_arr;
115
+
116
+ /**
117
+ * Processed data array to output
118
+ * @var array
119
+ */
120
+ private $processed_data = array(
121
+ 'email' => '',
122
+ 'nickname' => array(),
123
+ 'subject' => '',
124
+ 'contact' => true,
125
+ 'message' => array()
126
+ );
127
+
128
+ /**
129
+ * @var string
130
+ */
131
+ private $preprocessed_email;
132
+
133
+ /**
134
+ * @var string
135
+ */
136
+ private $preprocessed_nickname;
137
+
138
+ /**
139
+ * @var string
140
+ */
141
+ private $prev_name = '';
142
+
143
+ /**
144
+ * GetFieldsAny constructor.
145
+ *
146
+ * @param array $input_array
147
+ */
148
+ public function __construct( array $input_array )
149
+ {
150
+ $this->input_array = $input_array;
151
+ $this->isProcessForm();
152
+ $this->visible_fields_arr = $this->getVisibleFields();
153
+ }
154
+
155
+ /**
156
+ * Public interface to process fields
157
+ *
158
+ * @param string $email
159
+ * @param string $nickname
160
+ *
161
+ * @return array
162
+ */
163
+ public function getFields( $email = '', $nickname = '' )
164
+ {
165
+ $this->preprocessed_email = $email;
166
+ $this->preprocessed_nickname = is_string( $nickname ) ? $nickname : '';
167
+
168
+ if( count( $this->input_array ) ){
169
+
170
+ $this->process( $this->input_array );
171
+
172
+ }
173
+
174
+ foreach ($this->skip_message_post as $v) {
175
+ if (isset($_POST[$v])) {
176
+ $message = null;
177
+ break;
178
+ }
179
+ }
180
+
181
+ if( ! $this->contact ) {
182
+ $this->processed_data['contact'] = $this->contact;
183
+ }
184
+
185
+ if( $this->preprocessed_email ) {
186
+ $this->processed_data['email'] = $this->preprocessed_email;
187
+ }
188
+
189
+ if( $this->preprocessed_nickname ) {
190
+ $this->processed_data['nickname'] = $this->preprocessed_nickname;
191
+ }
192
+
193
+ if( is_array( $this->processed_data['nickname'] ) ){
194
+ $nickname_str = '';
195
+ foreach( $this->processed_data['nickname'] as $value ){
196
+ $nickname_str .= ( $value ? $value." " : "" );
197
+ }
198
+ $this->processed_data['nickname'] = trim( $nickname_str );
199
+ }
200
+
201
+ return $this->processed_data;
202
+ }
203
+
204
+ /**
205
+ * Makes main logic recursively
206
+ *
207
+ * @param $arr
208
+ */
209
+ private function process( $arr )
210
+ {
211
+ foreach( $arr as $key => $value ){
212
+
213
+ if( is_string( $value ) ){
214
+
215
+ $tmp = strpos( $value, '\\' ) !== false ? stripslashes( $value ) : $value;
216
+
217
+ # Remove html tags from $value
218
+ $tmp = preg_replace( '@<.*?>@', '', $tmp );
219
+
220
+ $decoded_json_value = json_decode( $tmp, true ); // Try parse JSON from the string
221
+ if( strpos( $value, "\n" ) === false || strpos( $value, "\r" ) === false ) {
222
+ // Parse an only single-lined string
223
+ parse_str( urldecode( $tmp ), $decoded_url_value ); // Try parse URL from the string
224
+ }
225
+
226
+ // If there is "JSON data" set is it as a value
227
+ if( $decoded_json_value !== null ){
228
+
229
+ if( isset( $arr['action'] ) && $arr['action'] === 'nf_ajax_submit' ) {
230
+ unset( $decoded_json_value['settings'] );
231
+ }
232
+
233
+ $value = $decoded_json_value;
234
+
235
+ // If there is "URL data" set is it as a value
236
+ }elseif( isset( $decoded_url_value ) && ! ( count( $decoded_url_value ) === 1 && reset( $decoded_url_value ) === '' ) ){
237
+ $value = $decoded_url_value;
238
+
239
+ // Ajax Contact Forms. Get data from such strings:
240
+ // acfw30_name %% Blocked~acfw30_email %% s@cleantalk.org
241
+ // acfw30_textarea %% msg
242
+ }elseif( preg_match( '/^\S+\s%%\s\S+.+$/', $value ) ){
243
+
244
+ $value = explode( '~', $value );
245
+ foreach ( $value as &$val ){
246
+ $tmp = explode( ' %% ', $val );
247
+ $val = array( $tmp[0] => $tmp[1] );
248
+ }unset( $val );
249
+
250
+ }
251
+ }
252
+
253
+ if( ! is_array( $value ) && ! is_object( $value ) ){
254
+
255
+ if ( ( in_array( $key, $this->skip_params, true ) && $key !== 0 && $key !== '' ) || 0 === strpos( $key, "ct_checkjs" ) ) {
256
+ $this->contact = false;
257
+ }
258
+
259
+ if( $value === '' ) {
260
+ continue;
261
+ }
262
+
263
+ // Skipping fields names with strings from (array)skip_fields_with_strings
264
+ foreach( $this->skip_fields_with_strings as $needle ){
265
+ if ( preg_match( "/".$needle."/", $key ) === 1 ){
266
+ continue(2);
267
+ }
268
+ }
269
+
270
+ // Obfuscating params
271
+ foreach( $this->obfuscate_params as $needle ){
272
+ if ( strpos($key, $needle) !== false ) {
273
+ $value = $this->obfuscate_param( $value );
274
+ continue(2);
275
+ }
276
+ }
277
+
278
+ $value_for_email = trim( $this->strip_shortcodes( $value ) ); // Removes shortcodes to do better spam filtration on server side.
279
+ // Removes whitespaces
280
+ $value = urldecode( trim( $this->strip_shortcodes( $value ) ) ); // Fully cleaned message
281
+
282
+ // Email
283
+ if ( preg_match( "/^\S+@\S+\.\S+$/", $value_for_email ) ) {
284
+ // Bypass email collecting if it is set by attribute.
285
+ if( $this->preprocessed_email ) {
286
+ continue;
287
+ }
288
+ $this->processed_data['email'] = $value_for_email;
289
+
290
+ // Names
291
+ }elseif ( false !== stripos( $key, "name" ) ) {
292
+ // Bypass name collecting if it is set by attribute or it is on invisible fields.
293
+ if(
294
+ $this->preprocessed_nickname &&
295
+ ( empty( $this->visible_fields_arr ) ||
296
+ in_array( $key, $this->visible_fields_arr, true ) )
297
+ ) {
298
+ continue;
299
+ }
300
+ preg_match("/(name.?(your|first|for)|(your|first|for).?name)/", $key, $match_forename);
301
+ preg_match("/(name.?(last|family|second|sur)|(last|family|second|sur).?name)/", $key, $match_surname);
302
+ preg_match("/(name.?(nick|user)|(nick|user).?name)/", $key, $match_nickname);
303
+
304
+ if( count($match_forename) > 1 ) {
305
+ $this->processed_data['nickname']['first'] = $value;
306
+ }
307
+ elseif( count($match_surname) > 1 ) {
308
+ $this->processed_data['nickname']['last'] = $value;
309
+ }
310
+ elseif( count($match_nickname) > 1 ) {
311
+ $this->processed_data['nickname']['nick'] = $value;
312
+ }
313
+ else {
314
+ $this->processed_data['message'][$this->prev_name . $key] = $value;
315
+ }
316
+
317
+ // Subject
318
+ }elseif ( $this->processed_data['subject'] === '' && false !== stripos( $key, "subject" ) ){
319
+ $this->processed_data['subject'] = $value;
320
+
321
+ // Message
322
+ }else{
323
+ $this->processed_data['message'][$this->prev_name . $key] = $value;
324
+ }
325
+
326
+ }elseif(!is_object($value)){
327
+
328
+ if( $value === '' ) {
329
+ continue;
330
+ }
331
+
332
+ $prev_name_original = $this->prev_name;
333
+ $this->prev_name = ($this->prev_name === '' ? $key.'_' : $this->prev_name.$key.'_');
334
+
335
+ $this->process( $value );
336
+
337
+ $this->prev_name = $prev_name_original;
338
+ }
339
+
340
+ }
341
+ }
342
+
343
+ /**
344
+ * Checking if the form will be skipped checking using global variables
345
+ *
346
+ * @ToDO we have the strong dependence apbct_array() Need to be refactored.
347
+ */
348
+ private function isProcessForm()
349
+ {
350
+ if( apbct_array( array( $_POST, $_GET ) )->get_keys( $this->skip_params )->result() ) {
351
+ $this->contact = false;
352
+ }
353
+ }
354
+
355
+ /**
356
+ * Get visible fields from Cookies to skip them processing
357
+ *
358
+ * @return array
359
+ * @ToDO we have the strong dependence apbct_visible_fields__process() Need to be refactored.
360
+ */
361
+ private function getVisibleFields()
362
+ {
363
+ $visible_fields = apbct_visible_fields__process( Cookie::get( 'apbct_visible_fields', array(), 'array' ) );
364
+ return isset( $visible_fields['visible_fields'] ) ? explode( ' ', $visible_fields['visible_fields'] ) : array();
365
+ }
366
+
367
+ /**
368
+ * Masks a value with asterisks (*)
369
+ *
370
+ * @param null $value
371
+ *
372
+ * @return string|null
373
+ */
374
+ private function obfuscate_param($value = null) {
375
+ if ($value && (!is_object($value) || !is_array($value))) {
376
+ $length = strlen($value);
377
+ $value = str_repeat('*', $length);
378
+ }
379
+
380
+ return $value;
381
+ }
382
+
383
+ /**
384
+ * WP function placeholder
385
+ *
386
+ * @param $value
387
+ *
388
+ * @return string
389
+ */
390
+ private function strip_shortcodes( $value )
391
+ {
392
+ if( function_exists( 'strip_shortcodes' ) ) {
393
+ return strip_shortcodes( $value );
394
+ }
395
+ return $value;
396
+ }
397
+ }
lib/Cleantalk/ApbctWP/RemoteCalls.php CHANGED
@@ -103,7 +103,8 @@ class RemoteCalls
103
  $apbct->data['notice_trial'] = 0;
104
  $apbct->data['notice_renew'] = 0;
105
  $apbct->saveData();
106
- Cron::updateTask( 'check_account_status', 'ct_account_status_check', 86400 );
 
107
 
108
  return 'OK';
109
  }
103
  $apbct->data['notice_trial'] = 0;
104
  $apbct->data['notice_renew'] = 0;
105
  $apbct->saveData();
106
+ $cron = new Cron();
107
+ $cron->updateTask( 'check_account_status', 'ct_account_status_check', 86400 );
108
 
109
  return 'OK';
110
  }
lib/Cleantalk/ApbctWP/State.php CHANGED
@@ -55,7 +55,7 @@ use ArrayObject;
55
  class State
56
  {
57
  public $user = null;
58
- public $use_rest_api = 1;
59
  public $option_prefix = 'cleantalk';
60
  public $storage = array();
61
  public $integrations = array();
@@ -104,7 +104,8 @@ class State
104
  'data__set_cookies' => 1, // Set cookies: Disable - 0 / Enable - 1 / Use Alternative cookies - 2.
105
  'data__set_cookies__alt_sessions_type' => 1, // Alternative cookies handler type: REST API - 1 / AJAX - 2
106
  'data__ssl_on' => 0, // Secure connection to servers
107
- 'data__pixel' => '0',
 
108
 
109
  // Exclusions
110
  'exclusions__urls' => '',
@@ -171,6 +172,7 @@ class State
171
  'notice_renew' => 0,
172
  'notice_review' => 0,
173
  'notice_auto_update' => 0,
 
174
 
175
  // Brief data
176
  'brief_data' => array(
@@ -222,7 +224,6 @@ class State
222
 
223
  // White label settings
224
  'multisite__white_label' => 0,
225
- 'multisite__white_label__hoster_key' => '',
226
  'multisite__white_label__plugin_name' => 'Anti-Spam by CleanTalk',
227
  'multisite__use_settings_template' => 0,
228
  'multisite__use_settings_template_apply_for_new' => 0,
@@ -291,7 +292,10 @@ class State
291
  'activation__timestamp' => 0,
292
  'activation_previous__timestamp' => 0,
293
  'activation__times' => 0,
294
- )
 
 
 
295
  );
296
 
297
  private $default_fw_stats = array(
@@ -300,6 +304,8 @@ class State
300
  'firewall_update_percent' => 0,
301
  'firewall_updating_last_start' => 0,
302
  'last_firewall_updated' => 0,
 
 
303
  );
304
 
305
  /**
@@ -361,7 +367,55 @@ class State
361
  $this->$option_name = is_array($option) ? new ArrayObject($option) : $option;
362
  }
363
  }
364
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  /**
366
  * Get specified option from database
367
  *
@@ -422,7 +476,7 @@ class State
422
  */
423
  public function saveNetworkData()
424
  {
425
- update_site_option($this->option_prefix.'_network_data', $this->network_data);
426
  }
427
 
428
  /**
@@ -430,7 +484,7 @@ class State
430
  */
431
  public function saveNetworkSettings()
432
  {
433
- update_site_option($this->option_prefix.'_network_settings', $this->network_settings);
434
  }
435
 
436
  /**
55
  class State
56
  {
57
  public $user = null;
58
+ public $use_rest_api = 0;
59
  public $option_prefix = 'cleantalk';
60
  public $storage = array();
61
  public $integrations = array();
104
  'data__set_cookies' => 1, // Set cookies: Disable - 0 / Enable - 1 / Use Alternative cookies - 2.
105
  'data__set_cookies__alt_sessions_type' => 1, // Alternative cookies handler type: REST API - 1 / AJAX - 2
106
  'data__ssl_on' => 0, // Secure connection to servers
107
+ 'data__pixel' => '3',
108
+ 'data__email_check_before_post' => 1,
109
 
110
  // Exclusions
111
  'exclusions__urls' => '',
172
  'notice_renew' => 0,
173
  'notice_review' => 0,
174
  'notice_auto_update' => 0,
175
+ 'notice_incompatibility' => array(),
176
 
177
  // Brief data
178
  'brief_data' => array(
224
 
225
  // White label settings
226
  'multisite__white_label' => 0,
 
227
  'multisite__white_label__plugin_name' => 'Anti-Spam by CleanTalk',
228
  'multisite__use_settings_template' => 0,
229
  'multisite__use_settings_template_apply_for_new' => 0,
292
  'activation__timestamp' => 0,
293
  'activation_previous__timestamp' => 0,
294
  'activation__times' => 0,
295
+ ),
296
+ 'cron' => array(
297
+ 'last_start' => 0,
298
+ ),
299
  );
300
 
301
  private $default_fw_stats = array(
304
  'firewall_update_percent' => 0,
305
  'firewall_updating_last_start' => 0,
306
  'last_firewall_updated' => 0,
307
+ 'expected_networks_count' => 0,
308
+ 'expected_ua_count' => 0,
309
  );
310
 
311
  /**
367
  $this->$option_name = is_array($option) ? new ArrayObject($option) : $option;
368
  }
369
  }
370
+
371
+ public static function setDefinitions()
372
+ {
373
+ global $wpdb, $apbct;
374
+
375
+ $db_prefix = ! $apbct->white_label && defined('CLEANTALK_ACCESS_KEY') ? $wpdb->base_prefix : $wpdb->prefix;
376
+
377
+ if( ! defined( 'APBCT_SEESION__LIVE_TIME' ) ) {
378
+ define( 'APBCT_SEESION__LIVE_TIME', 86400 );
379
+ }
380
+ if( ! defined( 'APBCT_SEESION__CHANCE_TO_CLEAN' ) ) {
381
+ define( 'APBCT_SEESION__CHANCE_TO_CLEAN', 100 );
382
+ }
383
+
384
+ // Database constants
385
+ if( ! defined( 'APBCT_TBL_FIREWALL_DATA' ) ) {
386
+ // Table with firewall data.
387
+ define( 'APBCT_TBL_FIREWALL_DATA', $db_prefix . 'cleantalk_sfw' );
388
+ }
389
+ if( ! defined( 'APBCT_TBL_FIREWALL_LOG' ) ) {
390
+ // Table with firewall logs.
391
+ define( 'APBCT_TBL_FIREWALL_LOG', $db_prefix . 'cleantalk_sfw_logs' );
392
+ }
393
+ if( ! defined( 'APBCT_TBL_AC_LOG' ) ) {
394
+ // Table with firewall logs.
395
+ define( 'APBCT_TBL_AC_LOG', $db_prefix . 'cleantalk_ac_log' );
396
+ }
397
+ if( ! defined( 'APBCT_TBL_AC_UA_BL' ) ) {
398
+ // Table with User-Agents blacklist.
399
+ define( 'APBCT_TBL_AC_UA_BL', $db_prefix . 'cleantalk_ua_bl' );
400
+ }
401
+ if( ! defined( 'APBCT_TBL_SESSIONS' ) ) {
402
+ // Table with session data.
403
+ define( 'APBCT_TBL_SESSIONS', $db_prefix . 'cleantalk_sessions' );
404
+ }
405
+ if( ! defined( 'APBCT_SPAMSCAN_LOGS' ) ) {
406
+ // Table with session data.
407
+ define( 'APBCT_SPAMSCAN_LOGS', $db_prefix . 'cleantalk_spamscan_logs' );
408
+ }
409
+ if( ! defined( 'APBCT_SELECT_LIMIT' ) ) {
410
+ // Select limit for logs.
411
+ define( 'APBCT_SELECT_LIMIT', 5000 );
412
+ }
413
+ if( ! defined( 'APBCT_WRITE_LIMIT' ) ) {
414
+ // Write limit for firewall data.
415
+ define( 'APBCT_WRITE_LIMIT', 5000 );
416
+ }
417
+ }
418
+
419
  /**
420
  * Get specified option from database
421
  *
476
  */
477
  public function saveNetworkData()
478
  {
479
+ update_site_option($this->option_prefix.'_network_data', (array)$this->network_data);
480
  }
481
 
482
  /**
484
  */
485
  public function saveNetworkSettings()
486
  {
487
+ update_site_option($this->option_prefix.'_network_settings', (array)$this->network_settings);
488
  }
489
 
490
  /**
lib/Cleantalk/ApbctWP/Variables/AltSessions.php CHANGED
@@ -48,7 +48,6 @@ class AltSessions {
48
  public static function set_fromRemote( $request = null ){
49
 
50
  if( ! $request ){
51
- check_ajax_referer( 'ct_secret_stuff' );
52
  $cookies_to_set = (array) \Cleantalk\Variables\Post::get( 'cookies' );
53
  }else{
54
  $cookies_to_set = $request->get_param( 'cookies' );
@@ -87,11 +86,7 @@ class AltSessions {
87
  }
88
 
89
  public static function get_fromRemote( $request = null ){
90
-
91
- if( ! $request ){
92
- check_ajax_referer( 'ct_secret_stuff' );
93
- }
94
-
95
  $value = \Cleantalk\ApbctWP\Variables\Cookie::get( $request
96
  ? $request->get_param( 'cookies' )
97
  : \Cleantalk\Variables\Post::get( 'name' )
48
  public static function set_fromRemote( $request = null ){
49
 
50
  if( ! $request ){
 
51
  $cookies_to_set = (array) \Cleantalk\Variables\Post::get( 'cookies' );
52
  }else{
53
  $cookies_to_set = $request->get_param( 'cookies' );
86
  }
87
 
88
  public static function get_fromRemote( $request = null ){
89
+
 
 
 
 
90
  $value = \Cleantalk\ApbctWP\Variables\Cookie::get( $request
91
  ? $request->get_param( 'cookies' )
92
  : \Cleantalk\Variables\Post::get( 'name' )
lib/Cleantalk/Common/API.php CHANGED
@@ -63,7 +63,7 @@ class API
63
  *
64
  * @return array|bool|mixed
65
  */
66
- static public function method__get_api_key($product_name, $email, $website, $platform, $timezone = null, $language = null, $user_ip = null, $wpms = false, $white_label = false, $hoster_api_key = '', $do_check = true)
67
  {
68
  $request = array(
69
  'method_name' => 'get_api_key',
@@ -75,8 +75,7 @@ class API
75
  'http_accept_language' => $language,
76
  'user_ip' => $user_ip,
77
  'wpms_setup' => $wpms,
78
- 'hoster_whitelabel' => $white_label,
79
- 'hoster_api_key' => $hoster_api_key,
80
  );
81
 
82
  $result = static::send_request($request);
@@ -206,7 +205,32 @@ class API
206
 
207
  return $result;
208
  }
209
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  /**
211
  * Wrapper for spam_check API method.
212
  * Checks IP|email via CleanTalk's database.
@@ -879,7 +903,10 @@ class API
879
  return $result;
880
 
881
  break;
882
-
 
 
 
883
  // get_antispam_report_breif
884
  case 'get_antispam_report_breif':
885
 
@@ -891,7 +918,7 @@ class API
891
  $tmp[date('Y-m-d', time() - 86400 * 7 + 86400 * $i)] = 0;
892
  }
893
  $out['spam_stat'] = (array)array_merge($tmp, isset($out['spam_stat']) ? $out['spam_stat'] : array());
894
- $out['top5_spam_ip'] = isset($out['top5_spam_ip']) ? $out['top5_spam_ip'] : array();
895
 
896
  return $out;
897
 
63
  *
64
  * @return array|bool|mixed
65
  */
66
+ static public function method__get_api_key($product_name, $email, $website, $platform, $timezone = null, $language = null, $user_ip = null, $wpms = false, $white_label = false, $do_check = true)
67
  {
68
  $request = array(
69
  'method_name' => 'get_api_key',
75
  'http_accept_language' => $language,
76
  'user_ip' => $user_ip,
77
  'wpms_setup' => $wpms,
78
+ 'hoster_whitelabel' => $white_label
 
79
  );
80
 
81
  $result = static::send_request($request);
205
 
206
  return $result;
207
  }
208
+
209
+ /**
210
+ * Wrapper for notice_paid_till API method.
211
+ * Gets information about renew notice.
212
+ *
213
+ * @param string $api_key API key
214
+ * @param string $path_to_cms Website URL
215
+ * @param string $product_name
216
+ * @param bool $do_check
217
+ *
218
+ * @return array|bool|mixed
219
+ */
220
+ static public function method__email_check($email, $cache_only = true, $do_check = true)
221
+ {
222
+ $request = array(
223
+ 'method_name' => 'email_check',
224
+ 'cache_only' => $cache_only ? '1' : '0',
225
+ 'email' => $email,
226
+ );
227
+
228
+ $result = static::send_request($request);
229
+ $result = $do_check ? static::check_response($result, 'email_check') : $result;
230
+
231
+ return $result;
232
+ }
233
+
234
  /**
235
  * Wrapper for spam_check API method.
236
  * Checks IP|email via CleanTalk's database.
903
  return $result;
904
 
905
  break;
906
+ case 'email_check':
907
+ $result = isset($result['data']) ? $result : array('error' => 'NO_DATA');
908
+ return $result;
909
+ break;
910
  // get_antispam_report_breif
911
  case 'get_antispam_report_breif':
912
 
918
  $tmp[date('Y-m-d', time() - 86400 * 7 + 86400 * $i)] = 0;
919
  }
920
  $out['spam_stat'] = (array)array_merge($tmp, isset($out['spam_stat']) ? $out['spam_stat'] : array());
921
+ $out['top5_spam_ip'] = isset($out['top5_spam_ip']) ? array_slice($out['top5_spam_ip'], 0, 5) : array();
922
 
923
  return $out;
924
 
lib/Cleantalk/Common/Compatibility.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Cleantalk\Common;
4
+
5
+ use Cleantalk\ApbctWP\CleantalkSettingsTemplates;
6
+
7
+ /**
8
+ * CleanTalk Compatibility class.
9
+ *
10
+ * @package PHP Antispam by CleanTalk
11
+ * @subpackage Compatibility
12
+ * @Version 3.5
13
+ * @author Cleantalk team (welcome@cleantalk.org)
14
+ * @copyright (C) 2014 CleanTalk team (http://cleantalk.org)
15
+ * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
16
+ * @see https://github.com/CleanTalk/php-antispam
17
+ */
18
+ class Compatibility
19
+ {
20
+ public $notices = array();
21
+
22
+ private $possible_issues = array(
23
+ 'w3_total_cache' => array(
24
+ 'callback' => 'w3tcCheckLateInit__callback',
25
+ ),
26
+ );
27
+
28
+ public function __construct() {
29
+
30
+ foreach( $this->possible_issues as $plugin_name => $issue ){
31
+ $this->{$issue['callback']}() && $this->setNoticesByPlugin( $plugin_name );
32
+ }
33
+
34
+ global $apbct;
35
+
36
+ if( $this->notices ){
37
+
38
+ // @todo save previous setting and restore it once the problem is gone
39
+ $apbct->settings['sfw__enabled'] = 0;
40
+ $apbct->save('settings');
41
+
42
+ $apbct->data['notice_incompatibility'] = $this->notices;
43
+ }else{
44
+ $apbct->data['notice_incompatibility'] = array();
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Function return array compatibility_issues
50
+ *
51
+ * @return true
52
+ */
53
+ private function setNoticesByPlugin( $plugin ){
54
+
55
+ $messages = array(
56
+ 'w3_total_cache' => __('Current W3 Total Cache cache mode is not compatible with SpamFireWall. Please read the instructions on how to fix this issue in <a href="https://cleantalk.org/help/cleantalk-and-w3-total-cache" > the article.</a>'),
57
+ );
58
+
59
+ $this->notices[ $plugin ] = $messages[ $plugin ];
60
+
61
+ return true;
62
+ }
63
+
64
+
65
+
66
+ /**
67
+ * W3 Total Cache check late init option
68
+ *
69
+ * @return boolean
70
+ */
71
+ public function w3tcCheckLateInit__callback(){
72
+
73
+ if(
74
+ is_plugin_active( 'w3-total-cache/w3-total-cache.php' ) &&
75
+ file_exists( WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'w3tc-config/master.php' )
76
+ ){
77
+ $w3_config = file_get_contents( WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'w3tc-config/master.php' );
78
+ $w3_config = str_replace( '<?php exit; ?>', '', $w3_config );
79
+ $w3_config = json_decode( $w3_config, true );
80
+
81
+ if(
82
+ ( isset( $w3_config['pgcache.cache.ssl'] ) && ! $w3_config['pgcache.cache.ssl'] ) ||
83
+ ( isset( $w3_config['pgcache.late_init'] ) && $w3_config['pgcache.late_init'] ) )
84
+ {
85
+ return false;
86
+ }
87
+
88
+ return true;
89
+ }
90
+
91
+ return false;
92
+ }
93
+ }
lib/Cleantalk/Common/Cron.php ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Cleantalk\Common;
4
+
5
+ /**
6
+ * CleanTalk Cron class
7
+ *
8
+ * @package Antispam by CleanTalk
9
+ * @Version 2.1.1
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
+ abstract class Cron
17
+ {
18
+ public $debug = false;
19
+
20
+ protected $tasks = array(); // Array with tasks
21
+ protected $tasks_completed = array(); // Result of executed tasks
22
+
23
+ // Option name with cron data
24
+ protected $cron_option_name;
25
+
26
+ // Interval in seconds for restarting the task
27
+ protected $task_execution_min_interval;
28
+
29
+ // Interval in seconds for cron work availability
30
+ protected $cron_execution_min_interval;
31
+
32
+ /**
33
+ * Cron constructor.
34
+ * Getting tasks option.
35
+ *
36
+ * @param string $cron_option_name
37
+ * @param int $task_execution_min_interval
38
+ * @param int $cron_execution_min_interval
39
+ */
40
+ public function __construct($cron_option_name = 'cleantalk_cron', $task_execution_min_interval = 120, $cron_execution_min_interval = 600)
41
+ {
42
+
43
+ /*
44
+ * @todo perform this logic
45
+ // Assign properties from the given parameters if exists
46
+ // Notice that if $this->$param_name is NULL new value won't be set
47
+ foreach( $params as $param_name => $param ){
48
+ $this->$param_name = isset( $this->$param_name ) ? $param : null;
49
+ }
50
+ */
51
+
52
+ $this->cron_option_name = $cron_option_name;
53
+ $this->task_execution_min_interval = $task_execution_min_interval;
54
+ $this->cron_execution_min_interval = $cron_execution_min_interval;
55
+ if( time() - $this->getCronLastStart() > $this->cron_execution_min_interval ) {
56
+ $this->tasks = $this->getTasks();
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Get timestamp last Cron started.
62
+ *
63
+ * @return int timestamp
64
+ */
65
+ abstract public function getCronLastStart();
66
+
67
+ /**
68
+ * Save timestamp of running Cron.
69
+ *
70
+ * @return bool
71
+ */
72
+ abstract public function setCronLastStart();
73
+
74
+ /**
75
+ * Save option with tasks
76
+ *
77
+ * @param array $tasks
78
+ * @return bool
79
+ */
80
+ abstract public function saveTasks( $tasks );
81
+
82
+ /**
83
+ * Getting all tasks
84
+ *
85
+ * @return array
86
+ */
87
+ abstract public function getTasks();
88
+
89
+ /**
90
+ * Adding new cron task.
91
+ *
92
+ * @param string $task
93
+ * @param string $handler
94
+ * @param int $period
95
+ * @param null|int $first_call
96
+ * @param array $params
97
+ *
98
+ * @return bool
99
+ */
100
+ public function addTask( $task, $handler, $period, $first_call = null, $params = array() )
101
+ {
102
+ // First call time() + period
103
+ $first_call = ! $first_call ? time() + $period : $first_call;
104
+
105
+ if( isset( $this->tasks[ $task ] ) ){
106
+ return false;
107
+ }
108
+
109
+ // Task entry
110
+ $this->tasks[$task] = array(
111
+ 'handler' => $handler,
112
+ 'next_call' => $first_call,
113
+ 'period' => $period,
114
+ 'params' => $params,
115
+ );
116
+
117
+ return $this->saveTasks( $this->tasks );
118
+ }
119
+
120
+ /**
121
+ * Removing cron task
122
+ *
123
+ * @param string $task
124
+ *
125
+ * @return bool
126
+ */
127
+ public function removeTask( $task )
128
+ {
129
+ if( ! isset( $this->tasks[ $task ] ) ){
130
+ return false;
131
+ }
132
+
133
+ unset( $this->tasks[ $task ] );
134
+
135
+ return $this->saveTasks( $this->tasks );
136
+ }
137
+
138
+ /**
139
+ * Updates cron task, create task if not exists.
140
+ *
141
+ * @param string $task
142
+ * @param string $handler
143
+ * @param int $period
144
+ * @param null|int $first_call
145
+ * @param array $params
146
+ *
147
+ * @return bool
148
+ */
149
+ public function updateTask( $task, $handler, $period, $first_call = null, $params = array() )
150
+ {
151
+ $this->removeTask( $task );
152
+ return $this->addTask( $task, $handler, $period, $first_call, $params );
153
+ }
154
+
155
+ /**
156
+ * Get cron option name
157
+ *
158
+ * @return string
159
+ */
160
+ public function getCronOptionName() {
161
+ return $this->cron_option_name;
162
+ }
163
+
164
+ /**
165
+ * Getting tasks which should be run
166
+ *
167
+ * @return bool|array
168
+ */
169
+ public function checkTasks()
170
+ {
171
+ // No tasks to run
172
+ if( empty( $this->tasks ) ){
173
+ return false;
174
+ }
175
+
176
+ $tasks_to_run = array();
177
+ foreach( $this->tasks as $task => &$task_data ){
178
+
179
+ if(
180
+ ! isset( $task_data['processing'], $task_data['last_call'] ) ||
181
+ ( $task_data['processing'] === true && time() - $task_data['last_call'] > $this->task_execution_min_interval )
182
+ ){
183
+ $task_data['processing'] = false;
184
+ $task_data['last_call'] = 0;
185
+ }
186
+
187
+ if(
188
+ $task_data['processing'] === false &&
189
+ $task_data['next_call'] <= time() // default condition
190
+ ){
191
+
192
+ $task_data['processing'] = true;
193
+ $task_data['last_call'] = time();
194
+
195
+ $tasks_to_run[] = $task;
196
+ }
197
+
198
+ // Hard bug fix
199
+ if( ! isset( $task_data['params'] ) ) {
200
+ $task_data['params'] = array();
201
+ }
202
+
203
+ } unset( $task_data );
204
+
205
+ $this->saveTasks( $this->tasks );
206
+
207
+ return $tasks_to_run;
208
+ }
209
+
210
+ /**
211
+ * Run all tasks from $this->tasks_to_run.
212
+ * Saving all results to (array) $this->tasks_completed
213
+ *
214
+ * @param $tasks
215
+ * @return void|array Array of completed and uncompleted tasks.
216
+ */
217
+ public function runTasks( $tasks )
218
+ {
219
+ if( empty( $tasks ) ) {
220
+ return;
221
+ }
222
+
223
+ if( ! $this->setCronLastStart() ) {
224
+ return;
225
+ }
226
+
227
+ foreach( $tasks as $task ){
228
+
229
+ if( is_callable( $this->tasks[$task]['handler'] ) ){
230
+
231
+ if( $this->debug ) {
232
+ error_log( var_export( 'Task ' . $task . ' will be run.', 1 ) );
233
+ }
234
+
235
+ $result = call_user_func_array( $this->tasks[$task]['handler'], isset( $this->tasks[$task]['params'] ) ? $this->tasks[$task]['params'] : array() );
236
+
237
+ if( $this->debug ) {
238
+ error_log( var_export( 'Result:', 1 ) );
239
+ error_log( var_export( $result, 1 ) );
240
+ }
241
+
242
+ if( empty( $result['error'] ) ){
243
+
244
+ $this->tasks_completed[$task] = true;
245
+
246
+ if( $this->tasks[$task]['period'] == 0 ) {
247
+ // One time scheduled event
248
+ unset( $this->tasks[$task] );
249
+ } else {
250
+ // Multi time scheduled event
251
+ $this->tasks[$task]['next_call'] = time() + $this->tasks[$task]['period'];
252
+ }
253
+
254
+ }else{
255
+ $this->tasks_completed[$task] = $result['error'];
256
+ $this->tasks[$task]['next_call'] = time() + $this->tasks[$task]['period'] / 4;
257
+ }
258
+
259
+ }else{
260
+ $this->tasks_completed[$task] = $this->tasks[$task]['handler'].'_IS_NOT_EXISTS';
261
+ }
262
+
263
+ }
264
+
265
+ $this->saveTasks( $this->tasks );
266
+
267
+ return $this->tasks_completed;
268
+ }
269
+ }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: spam, antispam, anti-spam, comments, firewall
4
  Requires at least: 3.0
5
  Tested up to: 5.7
6
  Requires PHP: 5.6
7
- Stable tag: 5.158.1
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
@@ -580,6 +580,50 @@ If your website has forms that send data to external sources, you can enable opt
580
 
581
  == Changelog ==
582
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
583
  = 5.158 May 27 2021 =
584
  * Fix: Firewall. SQL-request error.
585
 
4
  Requires at least: 3.0
5
  Tested up to: 5.7
6
  Requires PHP: 5.6
7
+ Stable tag: 5.159
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
580
 
581
  == Changelog ==
582
 
583
+ = 5.159 Jun 10 2021 =
584
+ * New. Admin Bar. Common admin bar implemented.
585
+ * New: email check before post.
586
+ * New: New admin bar style.
587
+ * New. SFW. Updating integrity control implemented.
588
+ * New. Custom Ajax. Email checking before post.
589
+ * New. Custom Ajax. Getting JS key.
590
+ * New. Custom Ajax. Alternative cookies.
591
+ * Upd. Integrations. Support multiple non-ajax hooks.
592
+ * Upd. Cron. Cron class and cron usage updated.
593
+ * Upd. Pixel. Pixel setting is "auto" for the new installations.
594
+ * Upd. Users checker. Users with completed WC orders no checked.
595
+ * Upd. WPMS settings.
596
+ * Mod. limiting the size of an array top5_spam_ip to five elements in widget.
597
+ * Mod. update data__pixel title.
598
+ * Mod. Update data__use_static_js_key title.
599
+ * Mod. add 'relative' parameter in admin_url() for getting ajaxurl.
600
+ * Mod. update field name honeypot_field, reverse logic
601
+ * Mod. changed website field from comments form: type text, display none.
602
+ * Fix. resolve conflict with wiloke theme and unknown plugin, that removes standard authorization cookies.
603
+ * Fix. moved the wiloke_theme options_ajax_save_skip check to apbct_is_skip_request function.
604
+ * Fix. added a theme check along with a hook wiloke_themeoptions_ajax_save_skip.
605
+ * Fix. Integration. Essentials addons for elementor integration fixed.
606
+ * Fix. AC/AF. Clearing AC table via cron fixed.
607
+ * Fix. SFW. Obtaining the count of the networks was fixed.
608
+ * Fix. Cron. Last cron start fixed.
609
+ * Fix. cookies for login page.
610
+ * Fix. Firewall. Update. Filtering bad data.
611
+ * Fix. Custom Ajax. Localized login scripts.
612
+ * Fix. API. Cleantalk\ApbctWP\API fixed to work on SHORTINIT mode.
613
+ * Fix. Custom Ajax. Getting JS key - removed WP ajax hooks.
614
+ * Fix. GetFieldsAny. Bypassing collecting email and names logic fixed.
615
+ * Fix. New admin bar style. Sorting plugins by Alphabet.
616
+ * Fix. ct_get_admin_email return network email if set.
617
+ * Fix. Fixed the name of the key containing the file address to check the number of records.
618
+ * Fix. Comments checker. Non-checkable users tab removed.
619
+ * Fix. Visible fields. Formidable visible fields collecting fixed.
620
+ * Fix. Get fields any fixed.
621
+ * Fix. empty key error for hosting.
622
+ * Fix. WPMS. Api key saving fixed.
623
+ * Fix. WPMS. Network settings saving fixed.
624
+ * Fix. WPMS. Plugin name setting field is not required now.
625
+ * Fix. Alt sessions js fixed.
626
+
627
  = 5.158 May 27 2021 =
628
  * Fix: Firewall. SQL-request error.
629