Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.165

Version Description

Nov 08 2021 = * New: Public. Mouse moved flag implemented. * Upd: State. Errors adding method updated. * Upd: Settings. Errors show function updated. * Upd: Updater. Clean errors options for new errors structure. * Upd: Public. Cookies aggregation. * Mod: Improving the functionality of checking comments for spam. * Mod: CommentsChecker - updated functionality and refactoring * Mod: merged inc/cleantalk-updater.php * Mod: merged UpdatePlugin dir * Mod: merged Schema.php * Mod: merged SchemaTest.php * Mod: merged cleantalk.php * Mod: merged State.php, Activator.php * Fix: SFW. Directory for FW files moved to wordpress uploads directory. * Fix: Settings. GDPR link fixed. * Fix: testrequesttohost error handle. * Fix: check ctsetcookie before call. * Fix: Settings. Save button padding fixed. * Fix: add console.log if ctSetcookie is not defined. * Fix: SFW. Skip if sfw not updated yet. * Fix: change console output if apbct-public-functions.js is not loaded. * Fix: Added secure and samesite in cookie * Fix: Renamed field apbct_wc_honeypot to wc_apbct_email_id * Fix.Users.Feedback about deleting user implemented. * Fix. SFW. Deleting table fixed. * Fix: set buffer type to string if epico theme is active. * Fix: Integration. Jetpack contact forms hooks fixed. * Fix: SFW. Separating the end of update stage into several stages. * Fix: SFW. Fallback function on SFW updating errors implemented. * Fix. Integration. WP Forms hooks fixed. * Fix. SFW. Auto updating for new users fixed. * Fix. Comment. Set meta fixed. * Fix: WPMS. Settings saving fixed.

Download this release

Release Info

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

Code changes from version 5.164.1 to 5.165

cleantalk.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Anti-Spam by CleanTalk
5
  Plugin URI: https://cleantalk.org
6
  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.
7
- Version: 5.164.1
8
  Author: СleanTalk <welcome@cleantalk.org>
9
  Author URI: https://cleantalk.org
10
  Text Domain: cleantalk-spam-protect
@@ -27,6 +27,7 @@ use Cleantalk\ApbctWP\Helper;
27
  use Cleantalk\ApbctWP\RemoteCalls;
28
  use Cleantalk\ApbctWP\RestController;
29
  use Cleantalk\ApbctWP\State;
 
30
  use Cleantalk\ApbctWP\Variables\Cookie;
31
  use Cleantalk\Common\DNS;
32
  use Cleantalk\Common\Firewall;
@@ -348,6 +349,14 @@ add_filter('wppb_output_field_errors_filter', 'apbct_form_profile_builder__check
348
  // WP Foro register system integration
349
  add_filter('wpforo_create_profile', 'wpforo_create_profile__check_register', 1, 1);
350
 
 
 
 
 
 
 
 
 
351
  // Public actions
352
  if ( ! is_admin() && ! apbct_is_ajax() && ! apbct_is_customize_preview() ) {
353
  // Default search
@@ -363,6 +372,7 @@ if ( ! is_admin() && ! apbct_is_ajax() && ! apbct_is_customize_preview() ) {
363
  // SpamFireWall check
364
  if ( $apbct->plugin_version == APBCT_VERSION && // Do not call with first start
365
  $apbct->settings['sfw__enabled'] == 1 &&
 
366
  apbct_is_get() &&
367
  ! apbct_wp_doing_cron() &&
368
  ! \Cleantalk\Variables\Server::inUri('/favicon.ico') &&
@@ -481,10 +491,6 @@ if ( is_admin() || is_network_admin() ) {
481
  } // Questions
482
  add_filter('et_pre_insert_answer', 'ct_ajax_hook', 1, 1); // Answers
483
 
484
- // Formidable
485
- add_filter('frm_entries_before_create', 'apbct_form__formidable__testSpam', 10, 2);
486
- add_action('frm_entries_footer_scripts', 'apbct_form__formidable__footerScripts', 20, 2);
487
-
488
  // Some of plugins to register a users use AJAX context.
489
  add_filter('registration_errors', 'ct_registration_errors', 1, 3);
490
  add_filter('registration_errors', 'ct_check_registration_erros', 999999, 3);
@@ -702,20 +708,6 @@ function apbct_sfw__check()
702
  $firewall->run();
703
  }
704
 
705
- /**
706
- * Creating specific tables
707
- *
708
- * @param $sqls
709
- * @param string $db_prefix
710
- *
711
- * @return void
712
- * @depreacted Use Activator::create_tables() instead
713
- */
714
- function apbct_activation__create_tables($sqls, $db_prefix = '')
715
- {
716
- Activator::createTables($sqls, $db_prefix);
717
- }
718
-
719
  /**
720
  * Redirects admin to plugin settings after activation.
721
  * @psalm-suppress UnusedVariable
@@ -845,7 +837,8 @@ function apbct_sfw_update__init($delay = 0)
845
  $apbct->save('stats');
846
  }
847
 
848
- $apbct->fw_stats['updating_folder'] = APBCT_DIR_PATH . DIRECTORY_SEPARATOR . 'fw_files_for_blog_' . get_current_blog_id() . DIRECTORY_SEPARATOR;
 
849
 
850
  $prepare_dir__result = apbct_prepare_upd_dir();
851
  $test_rc_result = Helper::httpRequestRcToHostTest(
@@ -946,6 +939,8 @@ function apbct_sfw_update__worker($checker_work = false)
946
  $apbct->errorAdd('sfw_update', $result['error']);
947
  $apbct->saveErrors();
948
 
 
 
949
  return $result['error'];
950
  }
951
 
@@ -1067,7 +1062,9 @@ function apbct_sfw_update__create_tables()
1067
  global $apbct;
1068
  // Preparing database infrastructure
1069
  // Creating SFW tables to make sure that they are exist
1070
- apbct_activation__create_tables(Schema::getSchema('sfw'), $apbct->db_prefix);
 
 
1071
 
1072
  return array(
1073
  'next_stage' => array(
@@ -1246,104 +1243,125 @@ function apbct_sfw_update__process_exclusions()
1246
 
1247
  return array(
1248
  'next_stage' => array(
1249
- 'name' => 'apbct_sfw_update__end_of_update',
1250
  'accepted_tries' => 1
1251
  )
1252
  );
1253
  }
1254
 
1255
- function apbct_sfw_update__end_of_update($is_direct_update = false)
1256
  {
1257
- global $apbct, $wpdb;
 
 
 
 
 
 
 
 
1258
 
1259
  $apbct->fw_stats['update_mode'] = 1;
1260
  $apbct->save('fw_stats');
1261
  usleep(10000);
1262
 
1263
-
1264
  // REMOVE AND RENAME
1265
  $result = SFW::dataTablesDelete(DB::getInstance(), APBCT_TBL_FIREWALL_DATA);
1266
  if ( empty($result['error']) ) {
1267
  $result = SFW::renameDataTablesFromTempToMain(DB::getInstance(), APBCT_TBL_FIREWALL_DATA);
1268
  }
1269
- if ( ! empty($result['error']) ) {
1270
- $apbct->fw_stats['update_mode'] = 0;
1271
- $apbct->save('fw_stats');
1272
 
 
 
 
 
1273
  return $result;
1274
  }
1275
 
1276
- // Increment firewall entries
1277
- $apbct->fw_stats['firewall_update_percent'] = 0;
1278
- $apbct->fw_stats['firewall_updating_id'] = null;
1279
- $apbct->fw_stats['last_firewall_updated'] = time();
1280
- $apbct->fw_stats['update_mode'] = 0;
1281
- $apbct->save('fw_stats');
 
1282
 
1283
- $apbct->stats['sfw']['entries'] = $wpdb->get_var('SELECT COUNT(*) FROM ' . APBCT_TBL_FIREWALL_DATA);
 
 
1284
 
1285
- // Running sfw update once again in 12 min if entries is < 4000
1286
- if ( ! $apbct->stats['sfw']['last_update_time'] &&
1287
- $apbct->stats['sfw']['entries'] < 4000
1288
- ) {
1289
- wp_schedule_single_event(time() + 720, 'apbct_sfw_update__init');
1290
  }
1291
 
1292
- $apbct->stats['sfw']['last_update_time'] = time();
1293
- $apbct->stats['sfw']['last_update_way'] = $is_direct_update ? 'Direct update' : 'Queue update';
1294
  $apbct->save('stats');
1295
 
1296
  /**
1297
  * Checking the integrity of the sfw database update
1298
  */
1299
- //@ToDo NEED TO BE REVIEWED
1300
- global $ct_cron;
1301
-
1302
  if ( $apbct->stats['sfw']['entries'] != $apbct->fw_stats['expected_networks_count'] ) {
1303
- # call manually
1304
- /** @psalm-suppress TypeDoesNotContainType */
1305
- if ( ! $ct_cron ) {
1306
- return array(
1307
- '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']
1308
- );
1309
- }
 
1310
 
1311
- #call cron
1312
- if ( $apbct->fw_stats['failed_update_attempt'] ) {
1313
- return array(
1314
- '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']
1315
- );
1316
- }
 
1317
 
1318
- $apbct->fw_stats['failed_update_attempt'] = true;
1319
- $apbct->save('fw_stats');
 
1320
 
1321
- $cron = new Cron();
1322
- $cron->updateTask('sfw_update', 'apbct_sfw_update__init', 86400, time() + 180);
 
 
 
1323
 
1324
- return false;
1325
- }
 
 
 
 
 
 
 
 
 
 
 
1326
 
1327
- $apbct->data['last_firewall_updated'] = current_time('timestamp');
1328
- $apbct->save('data'); // Unused
 
1329
 
1330
  // Delete update errors
1331
  $apbct->errorDelete('sfw_update', 'save_settings');
1332
 
 
 
 
 
 
 
 
1333
  $cron = new Cron();
1334
  $cron->updateTask('sfw_update', 'apbct_sfw_update__init', $apbct->stats['sfw']['update_period']);
1335
  $cron->removeTask('sfw_update_checker');
1336
 
1337
- /**
1338
- * Update fw data if update completed
1339
- */
1340
- $apbct->fw_stats['failed_update_attempt'] = false;
1341
- $apbct->fw_stats['expected_networks_count'] = false;
1342
-
1343
  apbct_remove_upd_folder($apbct->fw_stats['updating_folder']);
1344
 
1345
- $apbct->save('fw_stats');
1346
-
1347
  return true;
1348
  }
1349
 
@@ -1449,7 +1467,9 @@ function apbct_sfw_direct_update()
1449
 
1450
  // Preparing database infrastructure
1451
  // @ToDo need to implement returning result of the Activator::createTables work.
1452
- apbct_activation__create_tables(Schema::getSchema('sfw'), $apbct->db_prefix);
 
 
1453
 
1454
  $result__creating_tmp_table = SFW::createTempTables(DB::getInstance(), APBCT_TBL_FIREWALL_DATA);
1455
  if ( ! empty($result__creating_tmp_table['error']) ) {
@@ -1497,10 +1517,34 @@ function apbct_sfw_direct_update()
1497
  return array('error' => 'DIRECT UPDATING EXCLUSIONS: ' . $excl_result['error']);
1498
  }
1499
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1500
  /**
1501
  * END OF UPDATE
1502
  */
1503
- return apbct_sfw_update__end_of_update(true);
1504
  }
1505
 
1506
  return $result;
@@ -1517,6 +1561,34 @@ function apbct_sfw_update__cleanData()
1517
  $apbct->save('fw_stats');
1518
  }
1519
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1520
  function ct_sfw_send_logs($api_key = '')
1521
  {
1522
  global $apbct;
@@ -2337,6 +2409,7 @@ function ct_mail_send_connection_report()
2337
 
2338
  $headers = "Content-type: text/html; charset=windows-1251 \r\n";
2339
  $headers .= 'From: ' . ct_get_admin_email();
 
2340
  mail($to, $subject, $message, $headers);
2341
  }
2342
 
4
  Plugin Name: Anti-Spam by CleanTalk
5
  Plugin URI: https://cleantalk.org
6
  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.
7
+ Version: 5.165
8
  Author: СleanTalk <welcome@cleantalk.org>
9
  Author URI: https://cleantalk.org
10
  Text Domain: cleantalk-spam-protect
27
  use Cleantalk\ApbctWP\RemoteCalls;
28
  use Cleantalk\ApbctWP\RestController;
29
  use Cleantalk\ApbctWP\State;
30
+ use Cleantalk\ApbctWP\UpdatePlugin\DbTablesCreator;
31
  use Cleantalk\ApbctWP\Variables\Cookie;
32
  use Cleantalk\Common\DNS;
33
  use Cleantalk\Common\Firewall;
349
  // WP Foro register system integration
350
  add_filter('wpforo_create_profile', 'wpforo_create_profile__check_register', 1, 1);
351
 
352
+ // WPForms
353
+ // Adding fields
354
+ add_action('wpforms_frontend_output', 'apbct_form__WPForms__addField', 1000, 5);
355
+ // Gathering data to validate
356
+ add_filter('wpforms_process_before_filter', 'apbct_from__WPForms__gatherData', 100, 2);
357
+ // Do spam check
358
+ add_filter('wpforms_process_initial_errors', 'apbct_form__WPForms__showResponse', 100, 2);
359
+
360
  // Public actions
361
  if ( ! is_admin() && ! apbct_is_ajax() && ! apbct_is_customize_preview() ) {
362
  // Default search
372
  // SpamFireWall check
373
  if ( $apbct->plugin_version == APBCT_VERSION && // Do not call with first start
374
  $apbct->settings['sfw__enabled'] == 1 &&
375
+ $apbct->stats['sfw']['last_update_time'] &&
376
  apbct_is_get() &&
377
  ! apbct_wp_doing_cron() &&
378
  ! \Cleantalk\Variables\Server::inUri('/favicon.ico') &&
491
  } // Questions
492
  add_filter('et_pre_insert_answer', 'ct_ajax_hook', 1, 1); // Answers
493
 
 
 
 
 
494
  // Some of plugins to register a users use AJAX context.
495
  add_filter('registration_errors', 'ct_registration_errors', 1, 3);
496
  add_filter('registration_errors', 'ct_check_registration_erros', 999999, 3);
708
  $firewall->run();
709
  }
710
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
711
  /**
712
  * Redirects admin to plugin settings after activation.
713
  * @psalm-suppress UnusedVariable
837
  $apbct->save('stats');
838
  }
839
 
840
+ $wp_upload_dir = wp_upload_dir();
841
+ $apbct->fw_stats['updating_folder'] = $wp_upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'cleantalk_fw_files_for_blog_' . get_current_blog_id() . DIRECTORY_SEPARATOR;
842
 
843
  $prepare_dir__result = apbct_prepare_upd_dir();
844
  $test_rc_result = Helper::httpRequestRcToHostTest(
939
  $apbct->errorAdd('sfw_update', $result['error']);
940
  $apbct->saveErrors();
941
 
942
+ apbct_sfw_update__fallback();
943
+
944
  return $result['error'];
945
  }
946
 
1062
  global $apbct;
1063
  // Preparing database infrastructure
1064
  // Creating SFW tables to make sure that they are exist
1065
+ $db_tables_creator = new DbTablesCreator();
1066
+ $table_name = $apbct->db_prefix . Schema::getSchemaTablePrefix() . 'sfw';
1067
+ $db_tables_creator->createTable($table_name);
1068
 
1069
  return array(
1070
  'next_stage' => array(
1243
 
1244
  return array(
1245
  'next_stage' => array(
1246
+ 'name' => 'apbct_sfw_update__end_of_update__renaming_tables',
1247
  'accepted_tries' => 1
1248
  )
1249
  );
1250
  }
1251
 
1252
+ function apbct_sfw_update__end_of_update__renaming_tables()
1253
  {
1254
+ global $apbct;
1255
+
1256
+ if ( ! DB::getInstance()->isTableExists(APBCT_TBL_FIREWALL_DATA) ) {
1257
+ return array('error' => 'Error while completing data: SFW main table does not exist.');
1258
+ }
1259
+
1260
+ if ( ! DB::getInstance()->isTableExists(APBCT_TBL_FIREWALL_DATA . '_temp') ) {
1261
+ return array('error' => 'Error while completing data: SFW temp table does not exist.');
1262
+ }
1263
 
1264
  $apbct->fw_stats['update_mode'] = 1;
1265
  $apbct->save('fw_stats');
1266
  usleep(10000);
1267
 
 
1268
  // REMOVE AND RENAME
1269
  $result = SFW::dataTablesDelete(DB::getInstance(), APBCT_TBL_FIREWALL_DATA);
1270
  if ( empty($result['error']) ) {
1271
  $result = SFW::renameDataTablesFromTempToMain(DB::getInstance(), APBCT_TBL_FIREWALL_DATA);
1272
  }
 
 
 
1273
 
1274
+ $apbct->fw_stats['update_mode'] = 0;
1275
+ $apbct->save('fw_stats');
1276
+
1277
+ if ( ! empty($result['error']) ) {
1278
  return $result;
1279
  }
1280
 
1281
+ return array(
1282
+ 'next_stage' => array(
1283
+ 'name' => 'apbct_sfw_update__end_of_update__checking_data',
1284
+ 'accepted_tries' => 1
1285
+ )
1286
+ );
1287
+ }
1288
 
1289
+ function apbct_sfw_update__end_of_update__checking_data()
1290
+ {
1291
+ global $apbct, $wpdb;
1292
 
1293
+ if ( ! DB::getInstance()->isTableExists(APBCT_TBL_FIREWALL_DATA) ) {
1294
+ return array('error' => 'Error while checking data: SFW main table does not exist.');
 
 
 
1295
  }
1296
 
1297
+ $apbct->stats['sfw']['entries'] = $wpdb->get_var('SELECT COUNT(*) FROM ' . APBCT_TBL_FIREWALL_DATA);
 
1298
  $apbct->save('stats');
1299
 
1300
  /**
1301
  * Checking the integrity of the sfw database update
1302
  */
 
 
 
1303
  if ( $apbct->stats['sfw']['entries'] != $apbct->fw_stats['expected_networks_count'] ) {
1304
+ return array(
1305
+ 'error' =>
1306
+ 'The discrepancy between the amount of data received for the update and in the final table: '
1307
+ . APBCT_TBL_FIREWALL_DATA
1308
+ . '. RECEIVED: ' . $apbct->fw_stats['expected_networks_count']
1309
+ . '. ADDED: ' . $apbct->stats['sfw']['entries']
1310
+ );
1311
+ }
1312
 
1313
+ return array(
1314
+ 'next_stage' => array(
1315
+ 'name' => 'apbct_sfw_update__end_of_update__updating_stats',
1316
+ 'accepted_tries' => 1
1317
+ )
1318
+ );
1319
+ }
1320
 
1321
+ function apbct_sfw_update__end_of_update__updating_stats($is_direct_update = false)
1322
+ {
1323
+ global $apbct;
1324
 
1325
+ // Increment firewall entries
1326
+ $apbct->fw_stats['firewall_update_percent'] = 0;
1327
+ $apbct->fw_stats['firewall_updating_id'] = null;
1328
+ $apbct->fw_stats['expected_networks_count'] = false;
1329
+ $apbct->save('fw_stats');
1330
 
1331
+ $is_first_updating = ! $apbct->stats['sfw']['last_update_time'];
1332
+ $apbct->stats['sfw']['last_update_time'] = time();
1333
+ $apbct->stats['sfw']['last_update_way'] = $is_direct_update ? 'Direct update' : 'Queue update';
1334
+ $apbct->save('stats');
1335
+
1336
+ return array(
1337
+ 'next_stage' => array(
1338
+ 'name' => 'apbct_sfw_update__end_of_update',
1339
+ 'accepted_tries' => 1,
1340
+ 'args' => $is_first_updating
1341
+ )
1342
+ );
1343
+ }
1344
 
1345
+ function apbct_sfw_update__end_of_update($is_first_updating = false)
1346
+ {
1347
+ global $apbct;
1348
 
1349
  // Delete update errors
1350
  $apbct->errorDelete('sfw_update', 'save_settings');
1351
 
1352
+ // Running sfw update once again in 12 min if entries is < 4000
1353
+ if ( $is_first_updating &&
1354
+ $apbct->stats['sfw']['entries'] < 4000
1355
+ ) {
1356
+ wp_schedule_single_event(time() + 720, 'apbct_sfw_update__init');
1357
+ }
1358
+
1359
  $cron = new Cron();
1360
  $cron->updateTask('sfw_update', 'apbct_sfw_update__init', $apbct->stats['sfw']['update_period']);
1361
  $cron->removeTask('sfw_update_checker');
1362
 
 
 
 
 
 
 
1363
  apbct_remove_upd_folder($apbct->fw_stats['updating_folder']);
1364
 
 
 
1365
  return true;
1366
  }
1367
 
1467
 
1468
  // Preparing database infrastructure
1469
  // @ToDo need to implement returning result of the Activator::createTables work.
1470
+ $db_tables_creator = new DbTablesCreator();
1471
+ $table_name = $apbct->db_prefix . Schema::getSchemaTablePrefix() . 'sfw';
1472
+ $db_tables_creator->createTable($table_name);
1473
 
1474
  $result__creating_tmp_table = SFW::createTempTables(DB::getInstance(), APBCT_TBL_FIREWALL_DATA);
1475
  if ( ! empty($result__creating_tmp_table['error']) ) {
1517
  return array('error' => 'DIRECT UPDATING EXCLUSIONS: ' . $excl_result['error']);
1518
  }
1519
 
1520
+ /**
1521
+ * DELETING AND RENAMING THE TABLES
1522
+ */
1523
+ $rename_tables_res = apbct_sfw_update__end_of_update__renaming_tables();
1524
+ if ( ! empty($rename_tables_res['error']) ) {
1525
+ return array('error' => 'DIRECT UPDATING BLACK LIST: ' . $rename_tables_res['error']);
1526
+ }
1527
+
1528
+ /**
1529
+ * CHECKING THE UPDATE
1530
+ */
1531
+ $check_data_res = apbct_sfw_update__end_of_update__checking_data();
1532
+ if ( ! empty($check_data_res['error']) ) {
1533
+ return array('error' => 'DIRECT UPDATING BLACK LIST: ' . $check_data_res['error']);
1534
+ }
1535
+
1536
+ /**
1537
+ * WRITE UPDATING STATS
1538
+ */
1539
+ $update_stats_res = apbct_sfw_update__end_of_update__updating_stats(true);
1540
+ if ( ! empty($update_stats_res['error']) ) {
1541
+ return array('error' => 'DIRECT UPDATING BLACK LIST: ' . $update_stats_res['error']);
1542
+ }
1543
+
1544
  /**
1545
  * END OF UPDATE
1546
  */
1547
+ return apbct_sfw_update__end_of_update();
1548
  }
1549
 
1550
  return $result;
1561
  $apbct->save('fw_stats');
1562
  }
1563
 
1564
+ function apbct_sfw_update__fallback()
1565
+ {
1566
+ global $apbct;
1567
+
1568
+ /**
1569
+ * Remove the upd folder
1570
+ */
1571
+ if ( $apbct->fw_stats['updating_folder'] ) {
1572
+ apbct_remove_upd_folder($apbct->fw_stats['updating_folder']);
1573
+ }
1574
+
1575
+ /**
1576
+ * Remove SFW updating checker cron-task
1577
+ */
1578
+ $cron = new Cron();
1579
+ $cron->removeTask('sfw_update_checker');
1580
+
1581
+ /**
1582
+ * Remove _temp table
1583
+ */
1584
+ apbct_sfw_update__cleanData();
1585
+
1586
+ /**
1587
+ * Create SFW table if not exists
1588
+ */
1589
+ apbct_sfw_update__create_tables();
1590
+ }
1591
+
1592
  function ct_sfw_send_logs($api_key = '')
1593
  {
1594
  global $apbct;
2409
 
2410
  $headers = "Content-type: text/html; charset=windows-1251 \r\n";
2411
  $headers .= 'From: ' . ct_get_admin_email();
2412
+ /** @psalm-suppress UnusedFunctionCall */
2413
  mail($to, $subject, $message, $headers);
2414
  }
2415
 
css/cleantalk-admin-settings-page.min.css CHANGED
@@ -1 +1 @@
1
- .apbct_settings-field_content,.cleantalk_link-auto,.cleantalk_link-manual,.ct-warning-test-failed,.ct_rate_block,.ct_settings_banner,i.animate-spin{display:inline-block}#apbctTopWarning{margin-bottom:5px}#apbctTopWarning h3{margin:10px 0 5px}#apbctTopWarning h4{margin:10px}#apbctTopWarning h4 span{margin-top:5px}.apbct_settings-subtitle{position:relative;top:-15px;margin:0}.apbct_settings-field_wrapper{margin:15px 0}.apbct_settings-field_wrapper--sub{margin-left:30px!important}.apbct_settings__label{margin-right:10px;font-size:17px;vertical-align:text-bottom}.apbct_settings-field_content--radio,.apbct_settings-field_wrapper>.apbct_settings-field_description{width:70%}.apbct_settings-field_title--radio{display:inline-block;margin:0;width:210px;padding-right:10px;font-size:14px;vertical-align:top}.apbct_input_text{min-width:255px;width:400px}.apbct_settings-field--api_key{font-size:14pt}.apbct_settings-long_description---show:hover{color:#aaa;cursor:pointer}.apbct_setting_textarea{min-width:300px}.cleantalk_link{text-decoration:none;font-size:13px;line-height:26px;margin:0;padding:0 10px 1px;cursor:pointer;border-width:1px;border-style:solid;-webkit-appearance:none;white-space:nowrap;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.cleantalk_link-auto{background:#ccc;border-color:#999;-webkit-box-shadow:inset 0 1px 0 rgba(200,200,200,.5),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(200,200,200,.5),0 1px 0 rgba(0,0,0,.15);color:#000;height:28px;-webkit-border-radius:2px;border-radius:2px}.cleantalk_link-auto:hover{color:#fff}.cleantalk_link-manual{background:#2ea2cc;border-color:#0074a2;-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;-webkit-border-radius:3px;border-radius:3px;text-align:center}.cleantalk_link-manual:hover{color:#000}.cleantalk_link[disabled=disabled]{background:#5d9db5;color:#000}.apbct_status_icon{vertical-align:text-bottom;margin:0 5px 0 8px}a.ct_support_link{color:#666;margin-right:.5em;font-size:10pt;font-weight:400}.ct-warning-test-failed{position:relative;padding:5px;margin:4px;border:3px solid rgba(240,50,50,1);border-radius:5px;background-color:rgba(255,200,200,1)}.ct_settings_banner{text-align:right;width:100%;margin:1em 0;vertical-align:top}#cleantalk-modal-content,.ct_rate_block{text-align:center}#ct_translate_plugin{margin-left:0}.ct_rate_block{width:370px;margin-right:3em;padding:.8em .8em 15px;border:1px dashed #666}#ct_translate_plugin .apbct_button_rate{margin-bottom:10px}.apbct_long_desc{position:absolute;background:#5a5a5a;min-width:80px;min-height:80px;max-width:500px;padding:10px;color:#fff;z-index:10}i.animate-spin{-moz-animation:spin 2s infinite linear;-o-animation:spin 2s infinite linear;-webkit-animation:spin 2s infinite linear;animation:spin 2s infinite linear;font-size:25px;line-height:20px;color:rgba(120,200,230,1);margin:25px}@keyframes spin{to{transform:rotate(359deg)}}.apbct_long_desc__cancel{position:absolute;top:5px;right:5px;color:rgba(255,255,255,.5)}.apbct_long_desc__cancel:hover{color:#fff}.apbct_long_desc__angle{position:absolute;top:5px;left:-17px;width:10px;height:10px;background:#5a5a5a;-webkit-transform:rotate(135deg);-ms-transform:rotate(135deg);transform:rotate(135deg);-webkit-transform-origin:100% 100%;-ms-transform-origin:100% 100%;transform-origin:100% 100%}.apbct_long_desc__title{color:rgba(120,200,230,1);margin:0}.--hide{display:none}.apbct_preloader_button{height:15px;margin-left:5px;vertical-align:text-top;display:none}#cleantalk-modal-content>*{display:block;width:100%}button.ct_support_link{border:none;background:0 0;color:#666;text-decoration:underline;cursor:pointer}.apbct-btn-as-link{padding:0;margin:0;vertical-align:baseline;color:gray;border:0;border-bottom:1px solid;cursor:pointer}#apbct-account-email[contenteditable=true]{padding:6px;background-color:#fff;border:1px solid #ccc}button[value=save_changes]:disabled{color:#2271b1;border-color:#2271b1;background:#f6f7f7}#apbct_settings__advanced_settings{position:relative}#apbct_settings__advanced_settings_inner{width:70%}#apbct_hidden_section_nav{position:absolute;top:0;right:20px}#apbct_settings__after_advanced_settings{margin-bottom:20px}#apbct_settings__button_section{position:fixed;z-index:9999;width:100%;padding-bottom:20px}
1
+ .apbct_settings-field_content,.cleantalk_link-auto,.cleantalk_link-manual,.ct-warning-test-failed,.ct_rate_block,.ct_settings_banner,i.animate-spin{display:inline-block}#apbctTopWarning{margin-bottom:5px}#apbctTopWarning h3{margin:10px 0 5px}#apbctTopWarning h4{margin:10px}#apbctTopWarning h4 span{margin-top:5px}.apbct_settings-subtitle{position:relative;top:-15px;margin:0}.apbct_settings-field_wrapper{margin:15px 0}.apbct_settings-field_wrapper--sub{margin-left:30px!important}.apbct_settings__label{margin-right:10px;font-size:17px;vertical-align:text-bottom}.apbct_settings-field_content--radio,.apbct_settings-field_wrapper>.apbct_settings-field_description{width:70%}.apbct_settings-field_title--radio{display:inline-block;margin:0;width:210px;padding-right:10px;font-size:14px;vertical-align:top}.apbct_input_text{min-width:255px;width:400px}.apbct_settings-field--api_key{font-size:14pt}.apbct_settings-long_description---show:hover{color:#aaa;cursor:pointer}.apbct_setting_textarea{min-width:300px}.cleantalk_link{text-decoration:none;font-size:13px;line-height:26px;margin:0;padding:0 10px 1px;cursor:pointer;border-width:1px;border-style:solid;-webkit-appearance:none;white-space:nowrap;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.cleantalk_link-auto{background:#ccc;border-color:#999;-webkit-box-shadow:inset 0 1px 0 rgba(200,200,200,.5),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(200,200,200,.5),0 1px 0 rgba(0,0,0,.15);color:#000;height:28px;-webkit-border-radius:2px;border-radius:2px}.cleantalk_link-auto:hover{color:#fff}.cleantalk_link-manual{background:#2ea2cc;border-color:#0074a2;-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;-webkit-border-radius:3px;border-radius:3px;text-align:center}.cleantalk_link-manual:hover{color:#000}.cleantalk_link[disabled=disabled]{background:#5d9db5;color:#000}.apbct_status_icon{vertical-align:text-bottom;margin:0 5px 0 8px}a.ct_support_link{color:#666;margin-right:.5em;font-size:10pt;font-weight:400}.ct-warning-test-failed{position:relative;padding:5px;margin:4px;border:3px solid rgba(240,50,50,1);border-radius:5px;background-color:rgba(255,200,200,1)}.ct_settings_banner{text-align:right;width:100%;margin:1em 0;vertical-align:top}#cleantalk-modal-content,.ct_rate_block{text-align:center}#ct_translate_plugin{margin-left:0}.ct_rate_block{width:370px;margin-right:3em;padding:.8em .8em 15px;border:1px dashed #666}#ct_translate_plugin .apbct_button_rate{margin-bottom:10px}.apbct_long_desc{position:absolute;background:#5a5a5a;min-width:80px;min-height:80px;max-width:500px;padding:10px;color:#fff;z-index:10}i.animate-spin{-moz-animation:spin 2s infinite linear;-o-animation:spin 2s infinite linear;-webkit-animation:spin 2s infinite linear;animation:spin 2s infinite linear;font-size:25px;line-height:20px;color:rgba(120,200,230,1);margin:25px}@keyframes spin{to{transform:rotate(359deg)}}.apbct_long_desc__cancel{position:absolute;top:5px;right:5px;color:rgba(255,255,255,.5)}.apbct_long_desc__cancel:hover{color:#fff}.apbct_long_desc__angle{position:absolute;top:5px;left:-17px;width:10px;height:10px;background:#5a5a5a;-webkit-transform:rotate(135deg);-ms-transform:rotate(135deg);transform:rotate(135deg);-webkit-transform-origin:100% 100%;-ms-transform-origin:100% 100%;transform-origin:100% 100%}.apbct_long_desc__title{color:rgba(120,200,230,1);margin:0}.--hide{display:none}.apbct_preloader_button{height:15px;margin-left:5px;vertical-align:text-top;display:none}#cleantalk-modal-content>*{display:block;width:100%}button.ct_support_link{border:none;background:0 0;color:#666;text-decoration:underline;cursor:pointer}.apbct-btn-as-link{padding:0;margin:0;vertical-align:baseline;color:gray;border:0;border-bottom:1px solid;cursor:pointer}#apbct-account-email[contenteditable=true]{padding:6px;background-color:#fff;border:1px solid #ccc}button[value=save_changes]:disabled{color:#2271b1;border-color:#2271b1;background:#f6f7f7}#apbct_settings__advanced_settings{position:relative}#apbct_settings__advanced_settings_inner{width:70%}#apbct_hidden_section_nav{position:absolute;top:0;right:20px}#apbct_settings__after_advanced_settings{margin-bottom:20px}#apbct_settings__button_section{position:fixed;z-index:9999;width:100%;padding-bottom:40px}
i18n/cleantalk-ru_RU.po CHANGED
@@ -157,7 +157,7 @@ msgstr "Получить ключ вручную"
157
 
158
  #: inc/cleantalk-admin.php:408
159
  #, php-format
160
- msgid "Please enter Access Key in %s settings to enable anti spam protection!"
161
  msgstr ""
162
  "Пожалуйста, укажите Ключ доступа в настройках %s для активации защиты от "
163
  "спама!"
157
 
158
  #: inc/cleantalk-admin.php:408
159
  #, php-format
160
+ msgid "Please enter the Access Key in %s plugin to enable spam protection!"
161
  msgstr ""
162
  "Пожалуйста, укажите Ключ доступа в настройках %s для активации защиты от "
163
  "спама!"
i18n/cleantalk.pot CHANGED
@@ -151,7 +151,7 @@ msgstr ""
151
 
152
  #: inc/cleantalk-admin.php:408
153
  #, php-format
154
- msgid "Please enter Access Key in %s settings to enable anti spam protection!"
155
  msgstr ""
156
 
157
  #: inc/cleantalk-admin.php:418
151
 
152
  #: inc/cleantalk-admin.php:408
153
  #, php-format
154
+ msgid "Please enter the Access Key in %s plugin to enable spam protection!"
155
  msgstr ""
156
 
157
  #: inc/cleantalk-admin.php:418
inc/cleantalk-ajax.php CHANGED
@@ -512,14 +512,21 @@ function ct_ajax_hook($message_obj = null)
512
  }
513
  }
514
 
 
 
 
 
 
515
  /**
516
  * Filter for POST
517
  */
518
- $input_array = apply_filters('apbct__filter_post', $_POST);
 
 
 
 
519
 
520
- $ct_temp_msg_data = isset($ct_post_temp)
521
- ? ct_get_fields_any($ct_post_temp)
522
- : ct_get_fields_any($input_array);
523
 
524
  $sender_email = $ct_temp_msg_data['email'] ?: '';
525
  $sender_nickname = $ct_temp_msg_data['nickname'] ?: '';
@@ -883,6 +890,18 @@ function ct_ajax_hook($message_obj = null)
883
  wp_send_json_error(array(0 => array('username_error', $ct_result->comment)));
884
  }
885
 
 
 
 
 
 
 
 
 
 
 
 
 
886
  // Regular block output
887
  die(
888
  json_encode(
512
  }
513
  }
514
 
515
+ // Kali form integration
516
+ if (Post::hasString('action', 'kaliforms_form_process')) {
517
+ $ct_post_temp = $_POST['data'];
518
+ }
519
+
520
  /**
521
  * Filter for POST
522
  */
523
+ if (!empty($ct_post_temp)) {
524
+ $input_array = apply_filters('apbct__filter_post', $ct_post_temp);
525
+ } else {
526
+ $input_array = apply_filters('apbct__filter_post', $_POST);
527
+ }
528
 
529
+ $ct_temp_msg_data = ct_get_fields_any($input_array);
 
 
530
 
531
  $sender_email = $ct_temp_msg_data['email'] ?: '';
532
  $sender_nickname = $ct_temp_msg_data['nickname'] ?: '';
890
  wp_send_json_error(array(0 => array('username_error', $ct_result->comment)));
891
  }
892
 
893
+ // Kali Form Integration
894
+ if ( Post::hasString('action', 'kaliforms_form_process') ) {
895
+ die(
896
+ json_encode(
897
+ array(
898
+ 'status' => 'ok',
899
+ 'thank_you_message' => $ct_result->comment
900
+ )
901
+ )
902
+ );
903
+ }
904
+
905
  // Regular block output
906
  die(
907
  json_encode(
inc/cleantalk-common.php CHANGED
@@ -501,6 +501,7 @@ function apbct_get_sender_info()
501
  ) : null,
502
  'screen_info' => Cookie::get('ct_screen_info') ? json_encode(Cookie::get('ct_screen_info')) : null,
503
  'has_scrolled' => Cookie::get('ct_has_scrolled') ? json_encode(Cookie::get('ct_has_scrolled')) : null,
 
504
  );
505
  }
506
 
@@ -1117,7 +1118,7 @@ function apbct__styles_if_website_hidden()
1117
  if ( $apbct->settings['forms__wc_honeypot'] ) {
1118
  $styles = "
1119
  <style>
1120
- .apbct_wc_honeypot {
1121
  display: none !important;
1122
  }
1123
  </style>";
@@ -1135,13 +1136,13 @@ function apbct__wc_add_honeypot_field($fields)
1135
  global $apbct;
1136
 
1137
  if ( $apbct->settings['forms__wc_honeypot'] ) {
1138
- $fields['billing']['apbct_wc_honeypot'] = array(
1139
- 'id' => 'apbct_wc_honeypot',
1140
  'type' => 'text',
1141
  'label' => '',
1142
  'placeholder' => '',
1143
  'required' => false,
1144
- 'class' => array('form-row-wide', 'apbct_wc_honeypot'),
1145
  'clear' => true,
1146
  'autocomplete' => 'off'
1147
  );
501
  ) : null,
502
  'screen_info' => Cookie::get('ct_screen_info') ? json_encode(Cookie::get('ct_screen_info')) : null,
503
  'has_scrolled' => Cookie::get('ct_has_scrolled') ? json_encode(Cookie::get('ct_has_scrolled')) : null,
504
+ 'mouse_moved' => Cookie::get('ct_mouse_moved') ? json_encode(Cookie::get('ct_mouse_moved')) : null,
505
  );
506
  }
507
 
1118
  if ( $apbct->settings['forms__wc_honeypot'] ) {
1119
  $styles = "
1120
  <style>
1121
+ .wc_apbct_email_id {
1122
  display: none !important;
1123
  }
1124
  </style>";
1136
  global $apbct;
1137
 
1138
  if ( $apbct->settings['forms__wc_honeypot'] ) {
1139
+ $fields['billing']['wc_apbct_email_id'] = array(
1140
+ 'id' => 'wc_apbct_email_id',
1141
  'type' => 'text',
1142
  'label' => '',
1143
  'placeholder' => '',
1144
  'required' => false,
1145
+ 'class' => array('form-row-wide', 'wc_apbct_email_id'),
1146
  'clear' => true,
1147
  'autocomplete' => 'off'
1148
  );
inc/cleantalk-pluggable.php CHANGED
@@ -321,6 +321,7 @@ function apbct_is_ajax()
321
  * Checks if the request is REST
322
  *
323
  * @return boolean
 
324
  */
325
  function apbct_is_rest()
326
  {
@@ -398,11 +399,12 @@ function apbct_is_in_uri($str)
398
  return stripos(apbct_get_server_variable('REQUEST_URI'), $str) !== false;
399
  }
400
 
401
- /*
402
  * Checking if current request is a cron job
403
  * Support for wordpress < 4.8.0
404
  *
405
  * @return bool
 
406
  */
407
  function apbct_wp_doing_cron()
408
  {
321
  * Checks if the request is REST
322
  *
323
  * @return boolean
324
+ * @psalm-suppress RedundantCondition
325
  */
326
  function apbct_is_rest()
327
  {
399
  return stripos(apbct_get_server_variable('REQUEST_URI'), $str) !== false;
400
  }
401
 
402
+ /**
403
  * Checking if current request is a cron job
404
  * Support for wordpress < 4.8.0
405
  *
406
  * @return bool
407
+ * @psalm-suppress RedundantCondition
408
  */
409
  function apbct_wp_doing_cron()
410
  {
inc/cleantalk-public-integrations.php CHANGED
@@ -489,7 +489,7 @@ function ct_woocommerce_checkout_check()
489
  if ( $apbct->settings['forms__wc_honeypot'] ) {
490
  $honeypot_field = 1;
491
 
492
- if ( Post::get('apbct_wc_honeypot') ) {
493
  $honeypot_field = 0;
494
  }
495
 
@@ -1086,7 +1086,7 @@ function ct_preprocess_comment($comment)
1086
  }
1087
 
1088
  // Change comment flow only for new authors
1089
- if ( empty($base_call_data['post_info']['post_url']) ) {
1090
  add_action('comment_post', 'ct_set_meta', 10, 2);
1091
  }
1092
 
@@ -1338,7 +1338,7 @@ function ct_test_registration($nickname, $email, $ip = null)
1338
  true
1339
  );
1340
  $ct_result = $base_call_result['ct_result'];
1341
-
1342
  $result = array(
1343
  'allow' => $ct_result->allow,
1344
  'comment' => $ct_result->comment,
@@ -1449,7 +1449,7 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
1449
  true
1450
  );
1451
  $ct_result = $base_call_result['ct_result'];
1452
-
1453
  // Change mail notification if license is out of date
1454
  if ( $apbct->data['moderate'] == 0 &&
1455
  ($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
@@ -1654,18 +1654,9 @@ function ct_check_registration_erros($errors, $_sanitized_user_login = null, $_u
1654
  */
1655
  function apbct_user_register($user_id)
1656
  {
1657
- global $apbct_cookie_request_id_label, $apbct_cookie_request_id;
1658
-
1659
- if ( ! empty($apbct_cookie_request_id) ) {
1660
- update_user_meta($user_id, 'ct_hash', $apbct_cookie_request_id);
1661
-
1662
- return;
1663
- }
1664
-
1665
- if ( isset($_COOKIE[$apbct_cookie_request_id_label]) ) {
1666
- if ( update_user_meta($user_id, 'ct_hash', $_COOKIE[$apbct_cookie_request_id_label]) ) {
1667
- Cookie::set($apbct_cookie_request_id_label, '0', 1, '/');
1668
- }
1669
  }
1670
  }
1671
 
489
  if ( $apbct->settings['forms__wc_honeypot'] ) {
490
  $honeypot_field = 1;
491
 
492
+ if ( Post::get('wc_apbct_email_id') ) {
493
  $honeypot_field = 0;
494
  }
495
 
1086
  }
1087
 
1088
  // Change comment flow only for new authors
1089
+ if ( ! empty($new_user) || empty($base_call_data['post_info']['post_url']) ) {
1090
  add_action('comment_post', 'ct_set_meta', 10, 2);
1091
  }
1092
 
1338
  true
1339
  );
1340
  $ct_result = $base_call_result['ct_result'];
1341
+ ct_hash($ct_result->id);
1342
  $result = array(
1343
  'allow' => $ct_result->allow,
1344
  'comment' => $ct_result->comment,
1449
  true
1450
  );
1451
  $ct_result = $base_call_result['ct_result'];
1452
+ ct_hash($ct_result->id);
1453
  // Change mail notification if license is out of date
1454
  if ( $apbct->data['moderate'] == 0 &&
1455
  ($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
1654
  */
1655
  function apbct_user_register($user_id)
1656
  {
1657
+ $hash = ct_hash();
1658
+ if ( ! empty($hash) ) {
1659
+ update_user_meta($user_id, 'ct_hash', $hash);
 
 
 
 
 
 
 
 
 
1660
  }
1661
  }
1662
 
inc/cleantalk-public-validate.php CHANGED
@@ -452,14 +452,66 @@ function apbct__filter_form_data($form_data)
452
  return $form_data;
453
  }
454
 
455
- $exclusion_fields = explode(',', $apbct->settings['exclusions__fields']);
 
 
 
 
 
 
 
 
 
 
 
 
 
456
 
457
- foreach (array_keys($form_data) as $key) {
458
- if (in_array($key, $exclusion_fields)) {
459
- unset($form_data[$key]);
460
  }
461
  }
462
  }
463
 
464
  return $form_data;
465
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
452
  return $form_data;
453
  }
454
 
455
+ $excluded_fields = explode(',', $apbct->settings['exclusions__fields']);
456
+
457
+ foreach ($excluded_fields as $excluded_field) {
458
+ preg_match_all('/\[(\S*?)\]/', $excluded_field, $matches);
459
+
460
+ if (!empty($matches[1])) {
461
+ $excluded_matches = $matches[1];
462
+ $first_el = strstr($excluded_field, '[', true);
463
+ array_unshift($excluded_matches, $first_el);
464
+ foreach ($excluded_matches as $k => $v) {
465
+ if ($v === '') {
466
+ unset($excluded_matches[$k]);
467
+ }
468
+ }
469
 
470
+ $form_data = apbct__filter_array_recursive($form_data, $excluded_matches);
471
+ } else {
472
+ $form_data = apbct__filter_array_recursive($form_data, array($excluded_field));
473
  }
474
  }
475
  }
476
 
477
  return $form_data;
478
  }
479
+
480
+ /**
481
+ * Filtering array to exclude another array
482
+ * Example: delete fields from $_POST
483
+ *
484
+ * @param $array
485
+ * @param array $excluded_matches
486
+ * @param int $level
487
+ *
488
+ * @return array|mixed
489
+ */
490
+ function apbct__filter_array_recursive(&$array, $excluded_matches, $level = 0)
491
+ {
492
+ if (! is_array($array) || empty($array)) {
493
+ return $array;
494
+ }
495
+
496
+ foreach ($array as $key => $value) {
497
+ if ((string) $key !== (string) $excluded_matches[$level]) {
498
+ continue;
499
+ }
500
+
501
+ if (is_array($value)) {
502
+ $level++;
503
+
504
+ if ($level === count($excluded_matches)) {
505
+ unset($array[$key]);
506
+ return $array;
507
+ }
508
+
509
+ $array[$key] = apbct__filter_array_recursive($value, $excluded_matches, $level);
510
+ } else {
511
+ unset($array[$key]);
512
+ return $array;
513
+ }
514
+ }
515
+
516
+ return $array;
517
+ }
inc/cleantalk-public.php CHANGED
@@ -8,6 +8,7 @@ use Cleantalk\Common\Helper;
8
  *
9
  * @throws Exception
10
  * @psalm-suppress UnusedVariable
 
11
  */
12
  function apbct_init()
13
  {
@@ -167,17 +168,9 @@ function apbct_init()
167
  // JetPack Contact form
168
  if ( defined('JETPACK__VERSION') ) {
169
  // Checking Jetpack contact form
170
- if ( isset($_POST['action']) && $_POST['action'] === 'grunion-contact-form' ) {
171
- if ( JETPACK__VERSION === '3.4-beta' ) {
172
- add_filter('contact_form_is_spam', 'ct_contact_form_is_spam');
173
- } elseif ( JETPACK__VERSION === '3.4-beta2' || JETPACK__VERSION >= '3.4' ) {
174
- add_filter('jetpack_contact_form_is_spam', 'ct_contact_form_is_spam_jetpack', 50, 2);
175
- } else {
176
- add_filter('contact_form_is_spam', 'ct_contact_form_is_spam');
177
- }
178
- } else {
179
- add_filter('grunion_contact_form_field_html', 'ct_grunion_contact_form_field_html', 10, 2);
180
- }
181
 
182
  // Checking Jetpack comments form
183
  $jetpack_active_modules = get_option('jetpack_active_modules');
@@ -203,7 +196,7 @@ function apbct_init()
203
  }
204
 
205
  // Formidable
206
- add_filter('frm_entries_before_create', 'apbct_form__formidable__testSpam', 10, 2);
207
  add_action('frm_entries_footer_scripts', 'apbct_form__formidable__footerScripts', 20, 2);
208
 
209
  // BuddyPress
@@ -287,14 +280,6 @@ function apbct_init()
287
  }
288
  }
289
 
290
- // WPForms
291
- // Adding fields
292
- add_action('wpforms_frontend_output', 'apbct_form__WPForms__addField', 1000, 5);
293
- // Gathering data to validate
294
- add_filter('wpforms_process_before_filter', 'apbct_from__WPForms__gatherData', 100, 2);
295
- // Do spam check
296
- add_filter('wpforms_process_initial_errors', 'apbct_form__WPForms__showResponse', 100, 2);
297
-
298
  // QForms integration
299
  add_filter('quform_post_validate', 'ct_quform_post_validate', 10, 2);
300
 
@@ -390,7 +375,7 @@ function apbct_buffer__output()
390
  return;
391
  }
392
 
393
- if ( apbct_is_plugin_active('flow-flow/flow-flow.php') ) {
394
  $output = apbct_buffer_modify_by_string();
395
  } else {
396
  $output = apbct_buffer_modify_by_dom();
@@ -600,7 +585,10 @@ function ct_add_hidden_fields(
600
  else elem.attachEvent(event, callback);
601
  }
602
  apbct_attach_event_handler__backend(window, 'load', function(){
603
- ctSetCookie('{$field_name}', '{$ct_checkjs_key}' );
 
 
 
604
  });
605
  </script>";
606
  // Using AJAX to get key
@@ -1165,20 +1153,6 @@ function ct_enqueue_scripts_public($_hook)
1165
  'set_cookies_flag' => $apbct->settings['data__set_cookies'] ? false : true,
1166
  ));
1167
  }
1168
-
1169
- wp_enqueue_script(
1170
- 'ct_nocache',
1171
- plugins_url('/cleantalk-spam-protect/js/cleantalk_nocache.min.js'),
1172
- array(),
1173
- APBCT_VERSION,
1174
- false /*in header*/
1175
- );
1176
- wp_localize_script('ct_nocache', 'ctNocache', array(
1177
- 'ajaxurl' => admin_url('admin-ajax.php', 'relative'),
1178
- 'info_flag' => $apbct->settings['misc__collect_details'] && $apbct->settings['data__set_cookies'],
1179
- 'set_cookies_flag' => (bool)$apbct->settings['data__set_cookies'],
1180
- 'blog_home' => get_home_url() . '/',
1181
- ));
1182
  }
1183
 
1184
  // GDPR script
8
  *
9
  * @throws Exception
10
  * @psalm-suppress UnusedVariable
11
+ * @psalm-suppress RedundantCondition
12
  */
13
  function apbct_init()
14
  {
168
  // JetPack Contact form
169
  if ( defined('JETPACK__VERSION') ) {
170
  // Checking Jetpack contact form
171
+ add_filter('contact_form_is_spam', 'ct_contact_form_is_spam');
172
+ add_filter('jetpack_contact_form_is_spam', 'ct_contact_form_is_spam_jetpack', 50, 2);
173
+ add_filter('grunion_contact_form_field_html', 'ct_grunion_contact_form_field_html', 10, 2);
 
 
 
 
 
 
 
 
174
 
175
  // Checking Jetpack comments form
176
  $jetpack_active_modules = get_option('jetpack_active_modules');
196
  }
197
 
198
  // Formidable
199
+ add_filter('frm_entries_before_create', 'apbct_form__formidable__testSpam', 999999, 2);
200
  add_action('frm_entries_footer_scripts', 'apbct_form__formidable__footerScripts', 20, 2);
201
 
202
  // BuddyPress
280
  }
281
  }
282
 
 
 
 
 
 
 
 
 
283
  // QForms integration
284
  add_filter('quform_post_validate', 'ct_quform_post_validate', 10, 2);
285
 
375
  return;
376
  }
377
 
378
+ if ( apbct_is_plugin_active('flow-flow/flow-flow.php') || apbct_is_theme_active('epico') ) {
379
  $output = apbct_buffer_modify_by_string();
380
  } else {
381
  $output = apbct_buffer_modify_by_dom();
585
  else elem.attachEvent(event, callback);
586
  }
587
  apbct_attach_event_handler__backend(window, 'load', function(){
588
+ if (typeof ctSetCookie === \"function\")
589
+ ctSetCookie('{$field_name}', '{$ct_checkjs_key}' );
590
+ else
591
+ console.log('APBCT ERROR: apbct-public--functions is not loaded.');
592
  });
593
  </script>";
594
  // Using AJAX to get key
1153
  'set_cookies_flag' => $apbct->settings['data__set_cookies'] ? false : true,
1154
  ));
1155
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1156
  }
1157
 
1158
  // GDPR script
inc/cleantalk-settings.php CHANGED
@@ -1037,10 +1037,9 @@ function apbct_settings__display()
1037
  . '<br>';
1038
  echo __('Plugin Homepage at', 'cleantalk-spam-protect') .
1039
  ' <a href="https://cleantalk.org" target="_blank">cleantalk.org</a>.<br/>';
1040
- echo '<span id="apbct_gdpr_open_modal" style="text-decoration: underline;">' . __(
1041
- 'GDPR compliance',
1042
- 'cleantalk-spam-protect'
1043
- ) . '</span><br/>';
1044
  echo __('Use s@cleantalk.org to test plugin in any WordPress form.', 'cleantalk-spam-protect') . '<br>';
1045
  echo __('CleanTalk is registered Trademark. All rights reserved.', 'cleantalk-spam-protect') . '<br/>';
1046
  if ( $apbct->key_is_ok ) {
@@ -1051,9 +1050,6 @@ function apbct_settings__display()
1051
  ) . '</b><br />';
1052
  }
1053
  apbct_admin__badge__get_premium();
1054
- echo '<div id="gdpr_dialog" style="display: none; padding: 7px;">';
1055
- apbct_settings_show_gdpr_text('print');
1056
- echo '</div>';
1057
  echo '</div>';
1058
  }
1059
 
@@ -1219,6 +1215,7 @@ function apbct_settings__error__output($return = false)
1219
  'cleantalk-spam-protect'
1220
  ),
1221
  'api' => __('Error occurred while executing API call. Error: ', 'cleantalk-spam-protect'),
 
1222
  'sfw_outdated' => __(
1223
  'Error occurred on last SpamFireWall check. Error: ',
1224
  'cleantalk-spam-protect'
@@ -1235,10 +1232,15 @@ function apbct_settings__error__output($return = false)
1235
 
1236
  $errors_out = array();
1237
 
 
 
1238
  foreach ( $errors as $type => $error ) {
1239
  if ( ! empty($error) ) {
1240
- if ( is_array(current($error)) ) {
1241
  foreach ( $error as $sub_type => $sub_error ) {
 
 
 
1242
  if ( isset($sub_error['error']) && strpos($sub_error['error'], 'SFW_IS_DISABLED') !== false ) {
1243
  continue;
1244
  }
@@ -1250,7 +1252,6 @@ function apbct_settings__error__output($return = false)
1250
  $errors_out[$sub_type] .= (isset($error_texts[$type]) ? $error_texts[$type] : ucfirst($type)) . ': ';
1251
  $errors_out[$sub_type] .= (isset($error_texts[$sub_type]) ? $error_texts[$sub_type] : ( $error_texts['unknown'] . $sub_type . ' ' . __('Error: ', 'cleantalk-spam-protect') ) . ' ' . $sub_error['error'] );
1252
  }
1253
- continue;
1254
  }
1255
 
1256
  if (
@@ -1299,6 +1300,34 @@ function apbct_settings__error__output($return = false)
1299
  }
1300
  }
1301
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1302
  function apbct_settings__field__debug()
1303
  {
1304
  global $apbct;
@@ -1993,8 +2022,9 @@ function apbct_settings__validate($settings)
1993
  unset($setting, $value);
1994
 
1995
  // Set missing network settings.
 
1996
  foreach ( $apbct->def_network_settings as $setting => $value ) {
1997
- if ( ! isset($settings[$setting]) ) {
1998
  $settings[$setting] = $value;
1999
  settype($settings[$setting], gettype($value));
2000
  }
@@ -2281,6 +2311,12 @@ function apbct_settings__sync($direct_call = false)
2281
  die(json_encode($out));
2282
  }
2283
 
 
 
 
 
 
 
2284
  function apbct_settings__get_key_auto($direct_call = false)
2285
  {
2286
  if ( ! $direct_call ) {
@@ -2483,31 +2519,6 @@ function apbct_settings__sanitize__exclusions($exclusions, $regexp = false)
2483
  }
2484
  }
2485
 
2486
- function apbct_settings_show_gdpr_text($print = false)
2487
- {
2488
- $out = wpautop('The notice requirements remain and are expanded. They must include the retention time for personal data, and contact information for data controller and data protection officer has to be provided.
2489
- Automated individual decision-making, including profiling (Article 22) is contestable, similarly to the Data Protection Directive (Article 15). Citizens have rights to question and fight significant decisions that affect them that have been made on a solely-algorithmic basis. Many media outlets have commented on the introduction of a "right to explanation" of algorithmic decisions, but legal scholars have since argued that the existence of such a right is highly unclear without judicial tests and is limited at best.
2490
- To be able to demonstrate compliance with the GDPR, the data controller should implement measures, which meet the principles of data protection by design and data protection by default. Privacy by design and by default (Article 25) require data protection measures to be designed into the development of business processes for products and services. Such measures include pseudonymising personal data, by the controller, as soon as possible (Recital 78).
2491
- It is the responsibility and the liability of the data controller to implement effective measures and be able to demonstrate the compliance of processing activities even if the processing is carried out by a data processor on behalf of the controller (Recital 74).
2492
- Data Protection Impact Assessments (Article 35) have to be conducted when specific risks occur to the rights and freedoms of data subjects. Risk assessment and mitigation is required and prior approval of the national data protection authorities (DPAs) is required for high risks. Data protection officers (Articles 37–39) are required to ensure compliance within organisations.
2493
- They have to be appointed:')
2494
- . '<ul style="padding: 0px 25px; list-style: disc;">'
2495
- . '<li>for all public authorities, except for courts acting in their judicial capacity</li>'
2496
- . '<li>if the core activities of the controller or the processor are:</li>'
2497
- . '<ul style="padding: 0px 25px; list-style: disc;">'
2498
- . '<li>processing operations, which, by virtue of their nature, their scope and/or their purposes, require regular and systematic monitoring of data subjects on a large scale</li>'
2499
- . '<li>processing on a large scale of special categories of data pursuant to Article 9 and personal data relating to criminal convictions and offences referred to in Article 10;</li>'
2500
- . '</ul>'
2501
- . '</li>'
2502
- . '</ul>';
2503
-
2504
- if ( $print ) {
2505
- echo $out;
2506
- } else {
2507
- return $out;
2508
- }
2509
- }
2510
-
2511
  function apbct_settings__get__long_description()
2512
  {
2513
  check_ajax_referer('ct_secret_nonce');
1037
  . '<br>';
1038
  echo __('Plugin Homepage at', 'cleantalk-spam-protect') .
1039
  ' <a href="https://cleantalk.org" target="_blank">cleantalk.org</a>.<br/>';
1040
+ echo '<a href="https://cleantalk.org/publicoffer#cleantalk_gdpr_compliance" target="_blank">'
1041
+ . __('GDPR compliance', 'cleantalk-spam-protect')
1042
+ . '</a><br/>';
 
1043
  echo __('Use s@cleantalk.org to test plugin in any WordPress form.', 'cleantalk-spam-protect') . '<br>';
1044
  echo __('CleanTalk is registered Trademark. All rights reserved.', 'cleantalk-spam-protect') . '<br/>';
1045
  if ( $apbct->key_is_ok ) {
1050
  ) . '</b><br />';
1051
  }
1052
  apbct_admin__badge__get_premium();
 
 
 
1053
  echo '</div>';
1054
  }
1055
 
1215
  'cleantalk-spam-protect'
1216
  ),
1217
  'api' => __('Error occurred while executing API call. Error: ', 'cleantalk-spam-protect'),
1218
+ 'cron' => __('Error occurred while executing CleantalkCron job. Error: ', 'cleantalk-spam-protect'),
1219
  'sfw_outdated' => __(
1220
  'Error occurred on last SpamFireWall check. Error: ',
1221
  'cleantalk-spam-protect'
1232
 
1233
  $errors_out = array();
1234
 
1235
+ $errors = apbct_settings__prepare_errors((array)$errors);
1236
+
1237
  foreach ( $errors as $type => $error ) {
1238
  if ( ! empty($error) ) {
1239
+ if ( count($error) > 2 || ( ! isset($error['error'], $error['error_time']) ) ) {
1240
  foreach ( $error as $sub_type => $sub_error ) {
1241
+ if ( $sub_type === 'error' || $sub_type === 'error_time' ) {
1242
+ continue;
1243
+ }
1244
  if ( isset($sub_error['error']) && strpos($sub_error['error'], 'SFW_IS_DISABLED') !== false ) {
1245
  continue;
1246
  }
1252
  $errors_out[$sub_type] .= (isset($error_texts[$type]) ? $error_texts[$type] : ucfirst($type)) . ': ';
1253
  $errors_out[$sub_type] .= (isset($error_texts[$sub_type]) ? $error_texts[$sub_type] : ( $error_texts['unknown'] . $sub_type . ' ' . __('Error: ', 'cleantalk-spam-protect') ) . ' ' . $sub_error['error'] );
1254
  }
 
1255
  }
1256
 
1257
  if (
1300
  }
1301
  }
1302
 
1303
+ /**
1304
+ * Get only last error from each error types from errors array
1305
+ *
1306
+ * @param array $errors
1307
+ *
1308
+ * @return array
1309
+ */
1310
+ function apbct_settings__prepare_errors($errors)
1311
+ {
1312
+ $prepared_errors = array();
1313
+
1314
+ if ( is_array($errors) ) {
1315
+ foreach ( $errors as $type => $error ) {
1316
+ if ( is_array($error) ) {
1317
+ foreach ( $error as $key => $error_info ) {
1318
+ if ( is_string($key) ) {
1319
+ $prepared_errors[$type][$key] = end($error_info);
1320
+ } else {
1321
+ $prepared_errors[$type] = $error_info;
1322
+ }
1323
+ }
1324
+ }
1325
+ }
1326
+ }
1327
+
1328
+ return $prepared_errors;
1329
+ }
1330
+
1331
  function apbct_settings__field__debug()
1332
  {
1333
  global $apbct;
2022
  unset($setting, $value);
2023
 
2024
  // Set missing network settings.
2025
+ $stored_network_options = get_site_option($apbct->option_prefix . '_network_settings');
2026
  foreach ( $apbct->def_network_settings as $setting => $value ) {
2027
+ if ( ! isset($settings[$setting]) && ! array_key_exists($setting, $stored_network_options) ) {
2028
  $settings[$setting] = $value;
2029
  settype($settings[$setting], gettype($value));
2030
  }
2311
  die(json_encode($out));
2312
  }
2313
 
2314
+ /**
2315
+ * @param bool $direct_call
2316
+ *
2317
+ * @return array|bool|false[]|mixed|string|string[]|void
2318
+ * @psalm-suppress RedundantCondition
2319
+ */
2320
  function apbct_settings__get_key_auto($direct_call = false)
2321
  {
2322
  if ( ! $direct_call ) {
2519
  }
2520
  }
2521
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2522
  function apbct_settings__get__long_description()
2523
  {
2524
  check_ajax_referer('ct_secret_nonce');
inc/cleantalk-updater.php CHANGED
@@ -2,7 +2,6 @@
2
 
3
  use Cleantalk\ApbctWP\Cron;
4
  use Cleantalk\ApbctWP\Helper;
5
- use Cleantalk\Common\Schema;
6
  use Cleantalk\Variables\Server;
7
 
8
  /**
@@ -15,42 +14,92 @@ use Cleantalk\Variables\Server;
15
  *
16
  * @psalm-suppress PossiblyUndefinedIntArrayOffset
17
  */
 
18
  function apbct_run_update_actions($current_version, $new_version)
19
  {
 
 
 
 
 
 
 
 
 
 
 
20
  $current_version_arr = apbct_version_standardization($current_version);
21
  $new_version_arr = apbct_version_standardization($new_version);
22
 
23
  $current_version_str = implode('.', $current_version_arr);
24
  $new_version_str = implode('.', $new_version_arr);
25
 
26
- for ( $ver_major = $current_version_arr[0]; $ver_major <= $current_version_arr[0]; $ver_major++ ) {
27
- for ( $ver_minor = 0; $ver_minor <= 300; $ver_minor++ ) {
28
- for ( $ver_fix = 0; $ver_fix <= 10; $ver_fix++ ) {
29
- if ( version_compare("{$ver_major}.{$ver_minor}.{$ver_fix}", $current_version_str, '<=') ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  continue;
31
  }
32
 
33
- if ( function_exists("apbct_update_to_{$ver_major}_{$ver_minor}_{$ver_fix}") ) {
34
  $result = call_user_func("apbct_update_to_{$ver_major}_{$ver_minor}_{$ver_fix}");
35
- if ( ! empty($result['error']) ) {
36
  break;
37
  }
38
  }
39
 
40
- if ( $ver_fix == 0 && function_exists("apbct_update_to_{$ver_major}_{$ver_minor}") ) {
41
  $result = call_user_func("apbct_update_to_{$ver_major}_{$ver_minor}");
42
- if ( ! empty($result['error']) ) {
43
  break;
44
  }
45
  }
46
 
47
- if ( version_compare("{$ver_major}.{$ver_minor}.{$ver_fix}", $new_version_str, '>=') ) {
48
- break(2);
49
  }
50
  }
51
  }
52
  }
53
 
 
 
 
 
 
 
 
 
54
  return true;
55
  }
56
 
@@ -72,50 +121,6 @@ function apbct_version_standardization($version)
72
  return $parsed_version;
73
  }
74
 
75
- /**
76
- * Get columns from a selected DB table
77
- *
78
- * @param string $table_name
79
- *
80
- * @return array
81
- */
82
- function apbct_get_table_columns($table_name)
83
- {
84
- global $wpdb;
85
- $query = 'SHOW COLUMNS FROM ' . $table_name;
86
- $res = $wpdb->get_results($query, ARRAY_A);
87
- $columns_names = array();
88
- foreach ( $res as $column ) {
89
- $columns_names[] = $column['Field'];
90
- }
91
-
92
- return $columns_names;
93
- }
94
-
95
- /**
96
- * @return void
97
- */
98
- function apbct_update_to_5_50_0()
99
- {
100
- global $wpdb;
101
- $wpdb->query(
102
- 'CREATE TABLE IF NOT EXISTS `' . APBCT_TBL_FIREWALL_DATA . '` (
103
- `network` int(11) unsigned NOT NULL,
104
- `mask` int(11) unsigned NOT NULL,
105
- INDEX ( `network` , `mask` )
106
- );'
107
- );
108
-
109
- $wpdb->query(
110
- 'CREATE TABLE IF NOT EXISTS `' . APBCT_TBL_FIREWALL_LOG . '` (
111
- `ip` VARCHAR(15) NOT NULL ,
112
- `all` INT NOT NULL ,
113
- `blocked` INT NOT NULL ,
114
- `timestamp` INT NOT NULL ,
115
- PRIMARY KEY (`ip`));'
116
- );
117
- }
118
-
119
  /**
120
  * @return void
121
  */
@@ -131,17 +136,6 @@ function apbct_update_to_5_56_0()
131
  */
132
  function apbct_update_to_5_70_0()
133
  {
134
- global $wpdb;
135
-
136
- if ( ! in_array('all_entries', $wpdb->get_col('DESC ' . APBCT_TBL_FIREWALL_LOG, 0)) ) {
137
- $wpdb->query(
138
- 'ALTER TABLE `' . APBCT_TBL_FIREWALL_LOG . '`
139
- CHANGE `all` `all_entries` INT(11) NOT NULL,
140
- CHANGE `blocked` `blocked_entries` INT(11) NOT NULL,
141
- CHANGE `timestamp` `entries_timestamp` INT(11) NOT NULL;'
142
- );
143
- }
144
-
145
  // Deleting usless data
146
  delete_option('cleantalk_sends_reports_till');
147
  delete_option('cleantalk_activation_timestamp');
@@ -197,28 +191,12 @@ function apbct_update_to_5_109_0()
197
  {
198
  global $apbct, $wpdb;
199
 
200
- if ( apbct_is_plugin_active_for_network($apbct->base_name) && ! defined('CLEANTALK_ACCESS_KEY') ) {
201
- $sfw_data_query = 'CREATE TABLE IF NOT EXISTS `%s` (
202
- `network` int(11) unsigned NOT NULL,
203
- `mask` int(11) unsigned NOT NULL,
204
- INDEX ( `network` , `mask` )
205
- );';
206
-
207
- $sfw_log_query = 'CREATE TABLE IF NOT EXISTS `%s` (
208
- `ip` VARCHAR(15) NOT NULL,
209
- `all_entries` INT NOT NULL,
210
- `blocked_entries` INT NOT NULL,
211
- `entries_timestamp` INT NOT NULL,
212
- PRIMARY KEY (`ip`));';
213
 
214
- $initial_blog = get_current_blog_id();
215
- $blogs = array_keys($wpdb->get_results('SELECT blog_id FROM ' . $wpdb->blogs, OBJECT_K));
216
- foreach ( $blogs as $blog ) {
217
  switch_to_blog($blog);
218
- $wpdb->query(
219
- sprintf($sfw_data_query, $wpdb->prefix . 'cleantalk_sfw')
220
- ); // Table for SpamFireWall data
221
- $wpdb->query(sprintf($sfw_log_query, $wpdb->prefix . 'cleantalk_sfw_logs')); // Table for SpamFireWall logs
222
  // Cron tasks
223
  $cron = new Cron();
224
  $cron->addTask(
@@ -249,6 +227,7 @@ function apbct_update_to_5_109_0()
249
  time() + 3500
250
  ); // Send connection report to welcome@cleantalk.org
251
  }
 
252
  switch_to_blog($initial_blog);
253
  }
254
  }
@@ -260,7 +239,7 @@ function apbct_update_to_5_110_0()
260
  {
261
  global $apbct;
262
  unset($apbct->data['last_remote_call']);
263
- $apbct->saveData;
264
  $apbct->save('remote_calls');
265
  }
266
 
@@ -269,54 +248,11 @@ function apbct_update_to_5_110_0()
269
  */
270
  function apbct_update_to_5_116_0()
271
  {
272
- global $apbct, $wpdb;
273
 
274
- $apbct->settings['store_urls'] = 0;
275
  $apbct->settings['store_urls__sessions'] = 0;
276
  $apbct->saveSettings();
277
-
278
- $wpdb->query(
279
- 'CREATE TABLE IF NOT EXISTS `' . APBCT_TBL_SESSIONS . '` (
280
- `id` VARCHAR(64) NOT NULL,
281
- `name` TEXT NOT NULL,
282
- `value` TEXT NULL,
283
- `last_update` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
284
- PRIMARY KEY (`id`, `name`(10)));'
285
- );
286
- }
287
-
288
- /**
289
- * @return void
290
- */
291
- function apbct_update_to_5_116_1()
292
- {
293
- global $wpdb;
294
-
295
- $wpdb->query(
296
- 'CREATE TABLE IF NOT EXISTS `' . APBCT_TBL_SESSIONS . '` (
297
- `id` VARCHAR(64) NOT NULL,
298
- `name` TEXT NOT NULL,
299
- `value` TEXT NULL,
300
- `last_update` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
301
- PRIMARY KEY (`id`, `name`(10)));'
302
- );
303
- }
304
-
305
- /**
306
- * @return void
307
- */
308
- function apbct_update_to_5_116_2()
309
- {
310
- global $wpdb;
311
-
312
- $wpdb->query(
313
- 'CREATE TABLE IF NOT EXISTS `' . APBCT_TBL_SESSIONS . '` (
314
- `id` VARCHAR(64) NOT NULL,
315
- `name` TEXT NOT NULL,
316
- `value` TEXT NULL DEFAULT NULL,
317
- `last_update` DATETIME NULL DEFAULT NULL,
318
- PRIMARY KEY (`id`, `name`(10)));'
319
- );
320
  }
321
 
322
  /**
@@ -324,12 +260,6 @@ function apbct_update_to_5_116_2()
324
  */
325
  function apbct_update_to_5_118_0()
326
  {
327
- global $wpdb;
328
- $wpdb->query(
329
- 'DELETE
330
- FROM `' . APBCT_TBL_SESSIONS . '`
331
- WHERE last_update < NOW() - INTERVAL ' . APBCT_SEESION__LIVE_TIME . ' SECOND;'
332
- );
333
  delete_option('cleantalk_server');
334
  }
335
 
@@ -349,49 +279,6 @@ function apbct_update_to_5_118_2()
349
  */
350
  function apbct_update_to_5_119_0()
351
  {
352
- global $wpdb;
353
-
354
- $wpdb->query('DROP TABLE IF EXISTS `' . $wpdb->prefix . 'cleantalk_sessions`;'); // Deleting session table
355
-
356
- $sqls = array();
357
-
358
- // SFW data
359
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw` (
360
- `network` int(11) unsigned NOT NULL,
361
- `mask` int(11) unsigned NOT NULL,
362
- INDEX ( `network` , `mask` )
363
- );';
364
-
365
- // SFW log
366
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw_logs` (
367
- `ip` VARCHAR(15) NOT NULL,
368
- `all_entries` INT NOT NULL,
369
- `blocked_entries` INT NOT NULL,
370
- `entries_timestamp` INT NOT NULL,
371
- PRIMARY KEY (`ip`));';
372
-
373
- // Sessions
374
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sessions` (
375
- `id` VARCHAR(64) NOT NULL,
376
- `name` VARCHAR(64) NOT NULL,
377
- `value` TEXT NULL DEFAULT NULL,
378
- `last_update` DATETIME NULL DEFAULT NULL,
379
- PRIMARY KEY (`id`(64), `name`(64)));';
380
-
381
- apbct_activation__create_tables($sqls);
382
-
383
- // WPMS
384
- if ( is_multisite() ) {
385
- $initial_blog = get_current_blog_id();
386
- $blogs = array_keys($wpdb->get_results('SELECT blog_id FROM ' . $wpdb->blogs, OBJECT_K));
387
- foreach ( $blogs as $blog ) {
388
- switch_to_blog($blog);
389
- $wpdb->query('DROP TABLE IF EXISTS `' . $wpdb->prefix . 'cleantalk_sessions`;'); // Deleting session table
390
- apbct_activation__create_tables($sqls);
391
- }
392
- switch_to_blog($initial_blog);
393
- }
394
-
395
  // Drop work url
396
  update_option(
397
  'cleantalk_server',
@@ -435,10 +322,11 @@ function apbct_update_to_5_127_0()
435
 
436
  // Move exclusions from variable to settins
437
  global $cleantalk_url_exclusions, $cleantalk_key_exclusions;
 
438
  // URLs
439
- if ( ! empty($cleantalk_url_exclusions) && is_array($cleantalk_url_exclusions) ) {
440
  $apbct->settings['exclusions__urls'] = implode(',', $cleantalk_url_exclusions);
441
- if ( APBCT_WPMS ) {
442
  $initial_blog = get_current_blog_id();
443
  switch_to_blog(1);
444
  $apbct->saveSettings();
@@ -448,9 +336,9 @@ function apbct_update_to_5_127_0()
448
  }
449
  }
450
  // Fields
451
- if ( ! empty($cleantalk_key_exclusions) && is_array($cleantalk_key_exclusions) ) {
452
  $apbct->settings['exclusions__fields'] = implode(',', $cleantalk_key_exclusions);
453
- if ( APBCT_WPMS ) {
454
  $initial_blog = get_current_blog_id();
455
  switch_to_blog(1);
456
  $apbct->saveSettings();
@@ -461,40 +349,40 @@ function apbct_update_to_5_127_0()
461
  }
462
 
463
  // Deleting legacy
464
- if ( isset($apbct->data['testing_failed']) ) {
465
  unset($apbct->data['testing_failed']);
466
  $apbct->saveData();
467
  }
468
 
469
- if ( APBCT_WPMS ) {
470
  // Whitelabel
471
  // Reset "api_key_is_received" flag
472
  $initial_blog = get_current_blog_id();
473
  $blogs = array_keys($wpdb->get_results('SELECT blog_id FROM ' . $wpdb->blogs, OBJECT_K));
474
- foreach ( $blogs as $blog ) {
475
  switch_to_blog($blog);
476
 
477
  $settings = get_option('cleantalk_settings');
478
- if ( isset($settings['data__use_static_js_key']) ) {
479
- $settings['data__use_static_js_key'] = $settings['data__use_static_js_key'] === 0
480
  ? -1
481
- : $settings['data__use_static_js_key'];
482
  update_option('cleantalk_settings', $settings);
483
 
484
  $data = get_option('cleantalk_data');
485
- if ( isset($data['white_label_data']['is_key_recieved']) ) {
486
  unset($data['white_label_data']['is_key_recieved']);
487
  update_option('cleantalk_data', $data);
488
  }
489
  }
490
  switch_to_blog($initial_blog);
491
 
492
- if ( defined('APBCT_WHITELABEL') ) {
493
  $apbct->network_settings = array(
494
  'white_label' => defined('APBCT_WHITELABEL') && APBCT_WHITELABEL == true ? 1 : 0,
495
  'white_label__plugin_name' => defined('APBCT_WHITELABEL_NAME') ? APBCT_WHITELABEL_NAME : APBCT_NAME,
496
  );
497
- } elseif ( defined('CLEANTALK_ACCESS_KEY') ) {
498
  $apbct->network_settings = array(
499
  'allow_custom_key' => 0,
500
  'apikey' => CLEANTALK_ACCESS_KEY,
@@ -517,9 +405,10 @@ function apbct_update_to_5_127_0()
517
  function apbct_update_to_5_127_1()
518
  {
519
  global $apbct;
520
- if ( APBCT_WPMS && is_main_site() ) {
 
521
  $network_settings = get_site_option('cleantalk_network_settings');
522
- if ( $network_settings !== false && empty($network_settings['allow_custom_key']) && empty($network_settings['white_label']) ) {
523
  $network_settings['allow_custom_key'] = 1;
524
  update_site_option('cleantalk_network_settings', $network_settings);
525
  }
@@ -547,27 +436,6 @@ function apbct_update_to_5_128_0()
547
  $apbct->save('remote_calls');
548
  }
549
 
550
- /**
551
- * @return void
552
- */
553
- function apbct_update_to_5_133_0()
554
- {
555
- $sqls = array();
556
-
557
- // Scan comment/user log
558
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_spamscan_logs` (
559
- `id` int(11) NOT NULL AUTO_INCREMENT,
560
- `scan_type` varchar(11) NOT NULL,
561
- `start_time` datetime NOT NULL,
562
- `finish_time` datetime NOT NULL,
563
- `count_to_scan` int(11) DEFAULT NULL,
564
- `found_spam` int(11) DEFAULT NULL,
565
- `found_bad` int(11) DEFAULT NULL,
566
- PRIMARY KEY (`id`));';
567
-
568
- apbct_activation__create_tables($sqls);
569
- }
570
-
571
  /**
572
  * @return void
573
  *
@@ -576,38 +444,13 @@ function apbct_update_to_5_133_0()
576
  function apbct_update_to_5_138_0()
577
  {
578
  global $wpdb;
579
- // change name for prevent psalm false positive
580
- $_wpdb = $wpdb;
581
-
582
- $sqls = array();
583
-
584
- // SQL queries for each blog
585
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_spamscan_logs` (
586
- `id` int(11) NOT NULL AUTO_INCREMENT,
587
- `scan_type` varchar(11) NOT NULL,
588
- `start_time` datetime NOT NULL,
589
- `finish_time` datetime NOT NULL,
590
- `count_to_scan` int(11) DEFAULT NULL,
591
- `found_spam` int(11) DEFAULT NULL,
592
- `found_bad` int(11) DEFAULT NULL,
593
- PRIMARY KEY (`id`));';
594
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw` (
595
- `network` int(11) unsigned NOT NULL,
596
- `mask` int(11) unsigned NOT NULL,
597
- INDEX ( `network` , `mask` )
598
- );';
599
-
600
- $table_sfw_columns = apbct_get_table_columns(APBCT_TBL_FIREWALL_DATA);
601
- if ( ! in_array('status', $table_sfw_columns) ) {
602
- $sqls[] = 'ALTER TABLE `%scleantalk_sfw` ADD COLUMN status TINYINT(1) NOT NULL DEFAULT 0 AFTER mask;';
603
- }
604
 
605
  // Actions for WPMS
606
- if ( APBCT_WPMS ) {
607
  // Getting all blog ids
608
- $initial_blog = get_current_blog_id();
609
- $blogs = $_wpdb->get_results('SELECT blog_id FROM ' . $_wpdb->blogs, OBJECT_K);
610
- $blogs_ids = array_keys($blogs);
611
 
612
  // Getting main blog setting
613
  switch_to_blog(1);
@@ -617,22 +460,19 @@ function apbct_update_to_5_138_0()
617
  // Getting network settings
618
  $net_settings = get_site_option('cleantalk_network_settings');
619
 
620
- foreach ( $blogs_ids as $blog ) {
621
  // Update time limit to prevent exec time error
622
  set_time_limit(20);
623
 
624
  switch_to_blog($blog);
625
 
626
- // Update SQL structure
627
- apbct_activation__create_tables($sqls);
628
-
629
  // Getting key
630
  $settings = $net_settings['allow_custom_key']
631
  ? get_option('cleantalk_settings')
632
  : $main_blog_settings;
633
 
634
  // Update plugin status
635
- if ( ! empty($settings['apikey']) ) {
636
  $data = get_option('cleantalk_data', array());
637
 
638
  $result = \Cleantalk\ApbctWP\API::methodNoticePaidTill(
@@ -641,25 +481,25 @@ function apbct_update_to_5_138_0()
641
  ! is_main_site() && $net_settings['white_label'] ? 'anti-spam-hosting' : 'antispam'
642
  );
643
 
644
- if ( empty($result['error']) || ! empty($result['valid']) ) {
645
  // Notices
646
- $data['notice_show'] = isset($result['show_notice']) ? (int)$result['show_notice'] : 0;
647
- $data['notice_renew'] = isset($result['renew']) ? (int)$result['renew'] : 0;
648
- $data['notice_trial'] = isset($result['trial']) ? (int)$result['trial'] : 0;
649
- $data['notice_review'] = isset($result['show_review']) ? (int)$result['show_review'] : 0;
650
  $data['notice_auto_update'] = isset($result['show_auto_update_notice']) ? (int)$result['show_auto_update_notice'] : 0;
651
 
652
  // Other
653
- $data['service_id'] = isset($result['service_id']) ? (int)$result['service_id'] : 0;
654
- $data['valid'] = isset($result['valid']) ? (int)$result['valid'] : 0;
655
- $data['moderate'] = isset($result['moderate']) ? (int)$result['moderate'] : 0;
656
- $data['ip_license'] = isset($result['ip_license']) ? (int)$result['ip_license'] : 0;
657
- $data['moderate_ip'] = isset($result['moderate_ip'], $result['ip_license']) ? (int)$result['moderate_ip'] : 0;
658
- $data['spam_count'] = isset($result['spam_count']) ? (int)$result['spam_count'] : 0;
659
- $data['auto_update'] = isset($result['auto_update_app']) ? (int)$result['auto_update_app'] : 0;
660
- $data['user_token'] = isset($result['user_token']) ? (string)$result['user_token'] : '';
661
- $data['license_trial'] = isset($result['license_trial']) ? (int)$result['license_trial'] : 0;
662
- $data['account_name_ob'] = isset($result['account_name_ob']) ? (string)$result['account_name_ob'] : '';
663
  }
664
 
665
  $data['key_is_ok'] = ! empty($result['valid'])
@@ -672,132 +512,7 @@ function apbct_update_to_5_138_0()
672
 
673
  // Restoring initial blog
674
  switch_to_blog($initial_blog);
675
- // Actions for stand alone blog
676
- } else {
677
- apbct_activation__create_tables($sqls);
678
- }
679
- }
680
-
681
- /**
682
- * @return void
683
- */
684
- function apbct_update_to_5_142_0()
685
- {
686
- $sqls = array();
687
-
688
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_ac_log` (
689
- `id` VARCHAR(40) NOT NULL,
690
- `ip` VARCHAR(40) NOT NULL,
691
- `entries` INT DEFAULT 0,
692
- `interval_start` INT NOT NULL,
693
- PRIMARY KEY (`id`));';
694
-
695
- $table_sfw_logs_columns = apbct_get_table_columns(APBCT_TBL_FIREWALL_LOG);
696
- if ( ! in_array('id', $table_sfw_logs_columns) ) {
697
- $status = ! in_array(
698
- 'status',
699
- $table_sfw_logs_columns
700
- ) ? ' ADD COLUMN `status` ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW_BY_WHITELIST\',\'PASS_SFW_BY_COOKIE\',\'DENY_ANTIBOT\',\'DENY_ANTICRAWLER\') NOT NULL AFTER `ip`,' : '';
701
- $sqls[] = 'ALTER TABLE `%scleantalk_sfw_logs`
702
- ADD COLUMN `id` VARCHAR(40) NOT NULL FIRST,
703
- ' . $status . '
704
- DROP PRIMARY KEY,
705
- ADD PRIMARY KEY (`id`);';
706
  }
707
-
708
-
709
- apbct_activation__create_tables($sqls);
710
- }
711
-
712
- /**
713
- * @return void
714
- */
715
- function apbct_update_to_5_142_1()
716
- {
717
- $sqls = array();
718
- $sqls[] = 'DELETE FROM `%scleantalk_sfw_logs` WHERE 1=1';
719
-
720
- $sqls[] = 'ALTER TABLE `%scleantalk_sfw_logs`
721
- CHANGE `status` `status` ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW_BY_WHITELIST\',\'PASS_SFW_BY_COOKIE\',\'DENY_ANTICRAWLER\',\'DENY_ANTIFLOOD\') NOT NULL AFTER `ip`;';
722
-
723
- apbct_activation__create_tables($sqls);
724
- }
725
-
726
- /**
727
- * @return void
728
- */
729
- function apbct_update_to_5_142_2()
730
- {
731
- $sqls = array();
732
- $sqls[] = 'DELETE FROM `%scleantalk_sfw_logs` WHERE 1=1';
733
-
734
- $sqls[] = 'ALTER TABLE `%scleantalk_sfw_logs`
735
- CHANGE `status` `status` ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW__BY_WHITELIST\',\'PASS_SFW__BY_COOKIE\',\'DENY_ANTICRAWLER\',\'PASS_ANTICRAWLER\',\'DENY_ANTIFLOOD\',\'PASS_ANTIFLOOD\') NOT NULL AFTER `ip`;';
736
-
737
- apbct_activation__create_tables($sqls);
738
- }
739
-
740
- /**
741
- * @return void
742
- */
743
- function apbct_update_to_5_142_3()
744
- {
745
- global $apbct;
746
-
747
- $sqls = array();
748
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw_logs` (
749
- `id` VARCHAR(40) NOT NULL,
750
- `ip` VARCHAR(15) NOT NULL,
751
- `status` ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW__BY_WHITELIST\',\'PASS_SFW__BY_COOKIE\',\'DENY_ANTICRAWLER\',\'PASS_ANTICRAWLER\',\'DENY_ANTIFLOOD\',\'PASS_ANTIFLOOD\') NULL DEFAULT NULL,
752
- `all_entries` INT NOT NULL,
753
- `blocked_entries` INT NOT NULL,
754
- `entries_timestamp` INT NOT NULL,
755
- PRIMARY KEY (`id`));';
756
-
757
- apbct_activation__create_tables($sqls, $apbct->db_prefix);
758
- }
759
-
760
- /**
761
- * @return void
762
- */
763
- function apbct_update_to_5_143_2()
764
- {
765
- global $apbct;
766
-
767
- $sqls = array();
768
- $sqls[] = 'DROP TABLE IF EXISTS `%scleantalk_sfw_logs`;';
769
-
770
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw_logs` (
771
- `id` VARCHAR(40) NOT NULL,
772
- `ip` VARCHAR(15) NOT NULL,
773
- `status` ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW__BY_WHITELIST\',\'PASS_SFW__BY_COOKIE\',\'DENY_ANTICRAWLER\',\'PASS_ANTICRAWLER\',\'DENY_ANTIFLOOD\',\'PASS_ANTIFLOOD\') NULL DEFAULT NULL,
774
- `all_entries` INT NOT NULL,
775
- `blocked_entries` INT NOT NULL,
776
- `entries_timestamp` INT NOT NULL,
777
- PRIMARY KEY (`id`));';
778
-
779
- apbct_activation__create_tables($sqls, $apbct->db_prefix);
780
- }
781
-
782
- /**
783
- * @return void
784
- */
785
- function apbct_update_to_5_146_1()
786
- {
787
- global $apbct;
788
-
789
- $sqls = array();
790
- $sqls[] = 'DROP TABLE IF EXISTS `%scleantalk_ac_log`;';
791
-
792
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_ac_log` (
793
- `id` VARCHAR(40) NOT NULL,
794
- `ip` VARCHAR(40) NOT NULL,
795
- `ua` VARCHAR(40) NOT NULL,
796
- `entries` INT DEFAULT 0,
797
- `interval_start` INT NOT NULL,
798
- PRIMARY KEY (`id`));';
799
-
800
- apbct_activation__create_tables($sqls, $apbct->db_prefix);
801
  }
802
 
803
  /**
@@ -817,38 +532,6 @@ function apbct_update_to_5_148_0()
817
  $cron->updateTask('antiflood__clear_table', 'apbct_antiflood__clear_table', 86400);
818
  }
819
 
820
- /**
821
- * @return void
822
- */
823
- function apbct_update_to_5_149_2()
824
- {
825
- global $apbct;
826
-
827
- $sqls = array();
828
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_ua_bl` (
829
- `id` INT(11) NOT NULL,
830
- `ua_template` VARCHAR(255) NULL DEFAULT NULL,
831
- `ua_status` TINYINT(1) NULL DEFAULT NULL,
832
- PRIMARY KEY ( `id` ),
833
- INDEX ( `ua_template` )
834
- ) DEFAULT CHARSET=utf8;'; // Don't remove the default charset!
835
-
836
- $sqls[] = 'DROP TABLE IF EXISTS `%scleantalk_sfw_logs`;';
837
-
838
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw_logs` (
839
- `id` VARCHAR(40) NOT NULL,
840
- `ip` VARCHAR(15) NOT NULL,
841
- `status` ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW__BY_WHITELIST\',\'PASS_SFW__BY_COOKIE\',\'DENY_ANTICRAWLER\',\'PASS_ANTICRAWLER\',\'DENY_ANTICRAWLER_UA\',\'PASS_ANTICRAWLER_UA\',\'DENY_ANTIFLOOD\',\'PASS_ANTIFLOOD\') NULL DEFAULT NULL,
842
- `all_entries` INT NOT NULL,
843
- `blocked_entries` INT NOT NULL,
844
- `entries_timestamp` INT NOT NULL,
845
- `ua_id` INT(11) NULL DEFAULT NULL,
846
- `ua_name` VARCHAR(1024) NOT NULL,
847
- PRIMARY KEY (`id`));';
848
-
849
- apbct_activation__create_tables($sqls, $apbct->db_prefix);
850
- }
851
-
852
  /**
853
  * @return void
854
  */
@@ -857,12 +540,12 @@ function apbct_update_to_5_150_0()
857
  global $wpdb;
858
 
859
  // Actions for WPMS
860
- if ( APBCT_WPMS ) {
861
  // Getting all blog ids
862
  $initial_blog = get_current_blog_id();
863
  $blogs = array_keys($wpdb->get_results('SELECT blog_id FROM ' . $wpdb->blogs, OBJECT_K));
864
 
865
- foreach ( $blogs as $blog ) {
866
  switch_to_blog($blog);
867
 
868
  update_option('cleantalk_plugin_request_ids', array());
@@ -873,26 +556,6 @@ function apbct_update_to_5_150_0()
873
  }
874
  }
875
 
876
- /**
877
- * @return void
878
- */
879
- function apbct_update_to_5_150_1()
880
- {
881
- global $apbct;
882
- $sqls = array();
883
- // UA BL with default charset
884
- $sqls[] = 'DROP TABLE IF EXISTS `%scleantalk_ua_bl`;';
885
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_ua_bl` (
886
- `id` INT(11) NOT NULL,
887
- `ua_template` VARCHAR(255) NULL DEFAULT NULL,
888
- `ua_status` TINYINT(1) NULL DEFAULT NULL,
889
- PRIMARY KEY ( `id` ),
890
- INDEX ( `ua_template` )
891
- ) DEFAULT CHARSET=utf8;'; // Don't remove the default charset!
892
-
893
- apbct_activation__create_tables($sqls, $apbct->db_prefix);
894
- }
895
-
896
  /**
897
  * @return void
898
  */
@@ -917,13 +580,8 @@ function apbct_update_to_5_151_1()
917
  */
918
  function apbct_update_to_5_151_3()
919
  {
920
- global $wpdb, $apbct;
921
- $sql = 'SHOW TABLES LIKE "%scleantalk_sfw";';
922
- $sql = sprintf($sql, $wpdb->prefix); // Adding current blog prefix
923
- $result = $wpdb->get_var($sql);
924
- if ( ! $result ) {
925
- apbct_activation__create_tables(Schema::getSchema('sfw'), $apbct->db_prefix);
926
- }
927
  $apbct->fw_stats['firewall_updating_last_start'] = 0;
928
  $apbct->save('fw_stats');
929
  $apbct->stats['sfw']['entries'] = 0;
@@ -959,114 +617,114 @@ function apbct_update_to_5_154_0()
959
 
960
  // Old setting name => New setting name
961
  $keys_map = array(
962
- 'spam_firewall' => 'sfw__enabled',
963
- 'registrations_test' => 'forms__registrations_test',
964
- 'comments_test' => 'forms__comments_test',
965
- 'contact_forms_test' => 'forms__contact_forms_test',
966
- 'general_contact_forms_test' => 'forms__general_contact_forms_test',
967
- 'wc_checkout_test' => 'forms__wc_checkout_test',
968
- 'wc_register_from_order' => 'forms__wc_register_from_order',
969
- 'search_test' => 'forms__search_test',
970
- 'check_external' => 'forms__check_external',
971
- 'check_external__capture_buffer' => 'forms__check_external__capture_buffer',
972
- 'check_internal' => 'forms__check_internal',
973
- 'disable_comments__all' => 'comments__disable_comments__all',
974
- 'disable_comments__posts' => 'comments__disable_comments__posts',
975
- 'disable_comments__pages' => 'comments__disable_comments__pages',
976
- 'disable_comments__media' => 'comments__disable_comments__media',
977
- 'bp_private_messages' => 'comments__bp_private_messages',
978
- 'check_comments_number' => 'comments__check_comments_number',
979
- 'remove_old_spam' => 'comments__remove_old_spam',
980
- 'remove_comments_links' => 'comments__remove_comments_links',
981
- 'show_check_links' => 'comments__show_check_links',
982
- 'manage_comments_on_public_page' => 'comments__manage_comments_on_public_page',
983
- 'protect_logged_in' => 'data__protect_logged_in',
984
- 'use_ajax' => 'data__use_ajax',
985
- 'use_static_js_key' => 'data__use_static_js_key',
986
- 'general_postdata_test' => 'data__general_postdata_test',
987
- 'set_cookies' => 'data__set_cookies',
988
- 'set_cookies__sessions' => 'data__set_cookies__sessions',
989
- 'ssl_on' => 'data__ssl_on',
990
- 'show_adminbar' => 'admin_bar__show',
991
- 'all_time_counter' => 'admin_bar__all_time_counter',
992
- 'daily_counter' => 'admin_bar__daily_counter',
993
- 'sfw_counter' => 'admin_bar__sfw_counter',
994
- 'gdpr_enabled' => 'gdpr__enabled',
995
- 'gdpr_text' => 'gdpr__text',
996
- 'collect_details' => 'misc__collect_details',
997
- 'send_connection_reports' => 'misc__send_connection_reports',
998
- 'async_js' => 'misc__async_js',
999
- 'debug_ajax' => 'misc__debug_ajax',
1000
- 'store_urls' => 'misc__store_urls',
1001
- 'store_urls__sessions' => 'misc__store_urls__sessions',
1002
- 'complete_deactivation' => 'misc__complete_deactivation',
1003
- 'use_buitin_http_api' => 'wp__use_builtin_http_api',
1004
- 'comment_notify' => 'wp__comment_notify',
1005
- 'comment_notify__roles' => 'wp__comment_notify__roles',
1006
- 'dashboard_widget__show' => 'wp__dashboard_widget__show',
1007
- 'allow_custom_key' => 'multisite__allow_custom_key',
1008
- 'allow_custom_settings' => 'multisite__allow_custom_settings',
1009
- 'white_label' => 'multisite__white_label',
1010
- 'white_label__plugin_name' => 'multisite__white_label__plugin_name',
1011
- 'use_settings_template' => 'multisite__use_settings_template',
1012
- 'use_settings_template_apply_for_new' => 'multisite__use_settings_template_apply_for_new',
1013
- 'use_settings_template_apply_for_current' => 'multisite__use_settings_template_apply_for_current',
1014
  'use_settings_template_apply_for_current_list_sites' => 'multisite__use_settings_template_apply_for_current_list_sites',
1015
  );
1016
 
1017
- if ( is_multisite() ) {
1018
  $network_settings = get_site_option('cleantalk_network_settings');
1019
 
1020
- if ( $network_settings ) {
1021
  $_network_settings = array();
1022
  // replacing old key to new keys
1023
- foreach ( $network_settings as $key => $value ) {
1024
- if ( array_key_exists($key, $keys_map) ) {
1025
  $_network_settings[$keys_map[$key]] = $value;
1026
  } else {
1027
  $_network_settings[$key] = $value;
1028
  }
1029
  }
1030
- if ( ! empty($_network_settings) ) {
1031
  update_site_option('cleantalk_network_settings', $_network_settings);
1032
  }
1033
  }
1034
 
1035
- $initial_blog = get_current_blog_id();
1036
- $blogs = array_keys($wpdb->get_results('SELECT blog_id FROM ' . $wpdb->blogs, OBJECT_K));
1037
- foreach ( $blogs as $blog ) {
1038
  switch_to_blog($blog);
1039
 
1040
  $settings = get_option('cleantalk_settings');
1041
 
1042
- if ( $settings ) {
1043
  // replacing old key to new keys
1044
  $_settings = array();
1045
- foreach ( $settings as $key => $value ) {
1046
- if ( array_key_exists($key, $keys_map) ) {
1047
  $_settings[$keys_map[$key]] = $value;
1048
  } else {
1049
  $_settings[$key] = $value;
1050
  }
1051
  }
1052
- if ( ! empty($_settings) ) {
1053
  update_option('cleantalk_settings', $_settings);
1054
  }
1055
  }
1056
  }
1057
  switch_to_blog($initial_blog);
1058
  } else {
1059
- $apbct->data['current_settings_template_id'] = null;
1060
  $apbct->data['current_settings_template_name'] = null;
1061
  $apbct->saveData();
1062
 
1063
- $settings = (array)$apbct->settings;
1064
 
1065
- if ( $settings ) {
1066
  $_settings = array();
1067
  // replacing old key to new keys
1068
- foreach ( $settings as $key => $value ) {
1069
- if ( array_key_exists($key, $keys_map) ) {
1070
  $_settings[$keys_map[$key]] = $value;
1071
  } else {
1072
  $_settings[$key] = $value;
@@ -1077,23 +735,6 @@ function apbct_update_to_5_154_0()
1077
  $apbct->saveSettings();
1078
  }
1079
  }
1080
-
1081
- $sqls = array();
1082
-
1083
- $sqls[] = 'DROP TABLE IF EXISTS `%scleantalk_sfw_logs`;';
1084
-
1085
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw_logs` (
1086
- `id` VARCHAR(40) NOT NULL,
1087
- `ip` VARCHAR(15) NOT NULL,
1088
- `status` ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW__BY_WHITELIST\',\'PASS_SFW__BY_COOKIE\',\'DENY_ANTICRAWLER\',\'PASS_ANTICRAWLER\',\'DENY_ANTICRAWLER_UA\',\'PASS_ANTICRAWLER_UA\',\'DENY_ANTIFLOOD\',\'PASS_ANTIFLOOD\',\'DENY_ANTIFLOOD_UA\',\'PASS_ANTIFLOOD_UA\') NULL DEFAULT NULL,
1089
- `all_entries` INT NOT NULL,
1090
- `blocked_entries` INT NOT NULL,
1091
- `entries_timestamp` INT NOT NULL,
1092
- `ua_id` INT(11) NULL DEFAULT NULL,
1093
- `ua_name` VARCHAR(1024) NOT NULL,
1094
- PRIMARY KEY (`id`));';
1095
-
1096
- apbct_activation__create_tables($sqls, $apbct->db_prefix);
1097
  }
1098
 
1099
  /**
@@ -1103,8 +744,8 @@ function apbct_update_to_5_156_0()
1103
  {
1104
  global $apbct;
1105
 
1106
- $apbct->remote_calls['debug'] = array('last_call' => 0, 'cooldown' => 0);
1107
- $apbct->remote_calls['debug_sfw'] = array('last_call' => 0, 'cooldown' => 0);
1108
  $apbct->save('remote_calls');
1109
 
1110
  $cron = new Cron();
@@ -1121,7 +762,7 @@ function apbct_update_to_5_157_0()
1121
  $apbct->remote_calls['sfw_update__worker'] = array('last_call' => 0, 'cooldown' => 0);
1122
  $apbct->save('remote_calls');
1123
 
1124
- if ( ! empty($apbct->settings['data__set_cookies__sessions']) ) {
1125
  $apbct->settings['data__set_cookies'] = 2;
1126
  }
1127
  $apbct->data['ajax_type'] = 'rest';
@@ -1141,63 +782,17 @@ function apbct_update_to_5_158_0()
1141
  // change name for prevent psalm false positive
1142
  $_wpdb = $wpdb;
1143
 
1144
- $sqls = array();
1145
-
1146
- $table_sfw_columns = apbct_get_table_columns(APBCT_TBL_FIREWALL_DATA);
1147
- $table_sfw_logs_columns = apbct_get_table_columns(APBCT_TBL_FIREWALL_LOG);
1148
-
1149
- if ( ! in_array('source', $table_sfw_columns) ) {
1150
- $sqls[] = 'ALTER TABLE `%scleantalk_sfw` ADD COLUMN `source` TINYINT(1) NULL DEFAULT NULL AFTER `status`;';
1151
- }
1152
-
1153
- if ( ! in_array('source', $table_sfw_logs_columns) ) {
1154
- $network = ! in_array(
1155
- 'network',
1156
- $table_sfw_logs_columns
1157
- ) ? ' ADD COLUMN `network` VARCHAR(20) NULL DEFAULT NULL AFTER `source`,' : '';
1158
- $first_url = ! in_array(
1159
- 'first_url',
1160
- $table_sfw_logs_columns
1161
- ) ? ' ADD COLUMN `first_url` VARCHAR(100) NULL DEFAULT NULL AFTER `network`,' : '';
1162
- $last_url = ! in_array(
1163
- 'last_url',
1164
- $table_sfw_logs_columns
1165
- ) ? ' ADD COLUMN `last_url` VARCHAR(100) NULL DEFAULT NULL AFTER `first_url`' : '';
1166
- $sqls[] = 'ALTER TABLE `%scleantalk_sfw_logs`'
1167
- . ' ADD COLUMN `source` TINYINT(1) NULL DEFAULT NULL AFTER `ua_name`,'
1168
- . $network
1169
- . $first_url
1170
- . $last_url
1171
- . ';';
1172
- }
1173
-
1174
- if ( APBCT_WPMS ) {
1175
- // Getting all blog ids
1176
- $initial_blog = get_current_blog_id();
1177
- $blogs = array_keys($_wpdb->get_results('SELECT blog_id FROM ' . $_wpdb->blogs, OBJECT_K));
1178
-
1179
- foreach ( $blogs as $blog ) {
1180
- switch_to_blog($blog);
1181
- apbct_activation__create_tables($sqls);
1182
- }
1183
-
1184
- // Restoring initial blog
1185
- switch_to_blog($initial_blog);
1186
- } else {
1187
- apbct_activation__create_tables($sqls);
1188
- }
1189
-
1190
  // Update from fix branch
1191
- if ( APBCT_WPMS && is_main_site() ) {
1192
  $wp_blogs = $_wpdb->get_results('SELECT blog_id, site_id FROM ' . $_wpdb->blogs, OBJECT_K);
1193
  $current_sites_list = $apbct->settings['multisite__use_settings_template_apply_for_current_list_sites'];
1194
 
1195
- if ( is_array($wp_blogs) && is_array($current_sites_list) ) {
1196
- foreach ( $wp_blogs as $blog ) {
1197
  $blog_details = get_blog_details(array('blog_id' => $blog->blog_id));
1198
- if ( $blog_details ) {
1199
  $site_list_index = array_search($blog_details->blogname, $current_sites_list, true);
1200
- if ( $site_list_index !== false ) {
1201
  $current_sites_list[$site_list_index] = $blog_details->id;
1202
  }
1203
  }
@@ -1233,10 +828,10 @@ function apbct_update_to_5_159_6()
1233
 
1234
  $ct_cron = new Cron();
1235
 
1236
- if ( is_multisite() ) {
1237
  $initial_blog = get_current_blog_id();
1238
  $blogs = array_keys($wpdb->get_results('SELECT blog_id FROM ' . $wpdb->blogs, OBJECT_K));
1239
- foreach ( $blogs as $blog ) {
1240
  switch_to_blog($blog);
1241
  // Cron tasks
1242
  $ct_cron->addTask(
@@ -1317,64 +912,6 @@ function apbct_update_to_5_159_6()
1317
  }
1318
  }
1319
 
1320
- /**
1321
- * @return void
1322
- */
1323
- function apbct_update_to_5_159_7()
1324
- {
1325
- global $wpdb;
1326
- // change name for prevent psalm false positive
1327
- $_wpdb = $wpdb;
1328
-
1329
- $sqls = array();
1330
-
1331
- $table_sfw_columns = apbct_get_table_columns(APBCT_TBL_FIREWALL_DATA);
1332
- $table_sfw_logs_columns = apbct_get_table_columns(APBCT_TBL_FIREWALL_LOG);
1333
-
1334
- if ( ! in_array('source', $table_sfw_columns) ) {
1335
- $sqls[] = 'ALTER TABLE `%scleantalk_sfw` ADD COLUMN `source` TINYINT(1) NULL DEFAULT NULL AFTER `status`;';
1336
- }
1337
-
1338
- if ( ! in_array('source', $table_sfw_logs_columns) ) {
1339
- $network = ! in_array(
1340
- 'network',
1341
- $table_sfw_logs_columns
1342
- ) ? ' ADD COLUMN `network` VARCHAR(20) NULL DEFAULT NULL AFTER `source`,' : '';
1343
- $first_url = ! in_array(
1344
- 'first_url',
1345
- $table_sfw_logs_columns
1346
- ) ? ' ADD COLUMN `first_url` VARCHAR(100) NULL DEFAULT NULL AFTER `network`,' : '';
1347
- $last_url = ! in_array(
1348
- 'last_url',
1349
- $table_sfw_logs_columns
1350
- ) ? ' ADD COLUMN `last_url` VARCHAR(100) NULL DEFAULT NULL AFTER `first_url`' : '';
1351
- $sqls[] = 'ALTER TABLE `%scleantalk_sfw_logs`'
1352
- . ' ADD COLUMN `source` TINYINT(1) NULL DEFAULT NULL AFTER `ua_name`,'
1353
- . $network
1354
- . $first_url
1355
- . $last_url
1356
- . ';';
1357
- }
1358
-
1359
- if ( ! empty($sqls) ) {
1360
- if ( APBCT_WPMS ) {
1361
- // Getting all blog ids
1362
- $initial_blog = get_current_blog_id();
1363
- $blogs = array_keys($_wpdb->get_results('SELECT blog_id FROM ' . $_wpdb->blogs, OBJECT_K));
1364
-
1365
- foreach ( $blogs as $blog ) {
1366
- switch_to_blog($blog);
1367
- apbct_activation__create_tables($sqls);
1368
- }
1369
-
1370
- // Restoring initial blog
1371
- switch_to_blog($initial_blog);
1372
- } else {
1373
- apbct_activation__create_tables($sqls);
1374
- }
1375
- }
1376
- }
1377
-
1378
  /**
1379
  * @return void
1380
  */
@@ -1396,7 +933,7 @@ function apbct_update_to_5_160_4()
1396
 
1397
  apbct_remove_upd_folder(APBCT_DIR_PATH . '/fw_files');
1398
 
1399
- if ( $apbct->is_multisite ) {
1400
  $apbct->network_settings = array_merge((array)$apbct->network_settings, $apbct->default_network_settings);
1401
  $apbct->save('network_settings');
1402
  }
@@ -1404,7 +941,7 @@ function apbct_update_to_5_160_4()
1404
  apbct_remove_upd_folder(ABSPATH . '/wp-admin/fw_files');
1405
  apbct_remove_upd_folder(Server::get('DOCUMENT_ROOT') . '/fw_files');
1406
  $file_path = Server::get('DOCUMENT_ROOT') . '/fw_filesindex.php';
1407
- if ( is_file($file_path) && is_writable($file_path) ) {
1408
  unlink($file_path);
1409
  }
1410
  }
@@ -1413,7 +950,7 @@ function apbct_update_to_5_161_1()
1413
  {
1414
  global $apbct;
1415
 
1416
- if ( $apbct->is_multisite ) {
1417
  $apbct->network_settings = array_merge((array)$apbct->network_settings, $apbct->default_network_settings);
1418
  // Migrate old WPMS to the new wpms mode
1419
  if ( isset($apbct->network_settings['multisite__allow_custom_key']) ) {
@@ -1431,16 +968,16 @@ function apbct_update_to_5_161_2()
1431
  {
1432
  global $apbct;
1433
  // Set type of the alt cookies
1434
- if ( $apbct->settings['data__set_cookies'] == 2 ) {
1435
  // Check custom ajax availability
1436
  $res_custom_ajax = Helper::httpRequestGetResponseCode(esc_url(APBCT_URL_PATH . '/lib/Cleantalk/ApbctWP/Ajax.php'));
1437
- if ( $res_custom_ajax != 400 ) {
1438
  // Check rest availability
1439
  $res_rest = Helper::httpRequestGetResponseCode(esc_url(apbct_get_rest_url()));
1440
- if ( $res_rest != 200 ) {
1441
  // Check WP ajax availability
1442
  $res_ajax = Helper::httpRequestGetResponseCode(admin_url('admin-ajax.php'));
1443
- if ( $res_ajax != 400 ) {
1444
  // There is no available alt cookies types. Cookies will be disabled.
1445
  $apbct->settings['data__set_cookies'] = 0;
1446
  } else {
@@ -1489,13 +1026,13 @@ function apbct_update_to_5_162_1()
1489
  $res_custom_ajax = Helper::httpRequestGetResponseCode(
1490
  esc_url(APBCT_URL_PATH . '/lib/Cleantalk/ApbctWP/Ajax.php')
1491
  );
1492
- if ( $res_custom_ajax != 400 ) {
1493
  // Check rest availability
1494
  $res_rest = Helper::httpRequestGetResponseCode(esc_url(apbct_get_rest_url()));
1495
- if ( $res_rest != 200 ) {
1496
  // Check WP ajax availability
1497
  $res_ajax = Helper::httpRequestGetResponseCode(admin_url('admin-ajax.php'));
1498
- if ( $res_ajax != 400 ) {
1499
  // There is no available alt cookies types. Cookies will be disabled.
1500
  $apbct->settings['data__use_ajax'] = 0;
1501
  } else {
@@ -1548,3 +1085,12 @@ function apbct_update_to_5_164_0()
1548
  $apbct->data['ajax_type'] = $alt_cookies_type;
1549
  $apbct->saveData();
1550
  }
 
 
 
 
 
 
 
 
 
2
 
3
  use Cleantalk\ApbctWP\Cron;
4
  use Cleantalk\ApbctWP\Helper;
 
5
  use Cleantalk\Variables\Server;
6
 
7
  /**
14
  *
15
  * @psalm-suppress PossiblyUndefinedIntArrayOffset
16
  */
17
+
18
  function apbct_run_update_actions($current_version, $new_version)
19
  {
20
+ global $apbct;
21
+ $need_start_update_sfw = false;
22
+
23
+ // Excludes the repeated call of the plugin update if the process is already running.
24
+ if ((int)$apbct->stats['plugin']['plugin_is_being_updated'] === 1) {
25
+ return false;
26
+ }
27
+
28
+ $apbct->stats['plugin']['plugin_is_being_updated'] = 1;
29
+ $apbct->save('stats');
30
+
31
  $current_version_arr = apbct_version_standardization($current_version);
32
  $new_version_arr = apbct_version_standardization($new_version);
33
 
34
  $current_version_str = implode('.', $current_version_arr);
35
  $new_version_str = implode('.', $new_version_arr);
36
 
37
+ $db_analyzer = new \Cleantalk\ApbctWP\UpdatePlugin\DbAnalyzer();
38
+
39
+ // Create not exists tables
40
+ if ($db_analyzer->getNotExistsTables()) {
41
+ foreach ($db_analyzer->getNotExistsTables() as $table) {
42
+ // Checking whether to run the SFW update
43
+ if (substr($table, -3) === 'sfw') {
44
+ $need_start_update_sfw = true;
45
+ }
46
+
47
+ $db_tables_creator = new \Cleantalk\ApbctWP\UpdatePlugin\DbTablesCreator();
48
+ $db_tables_creator->createTable($table);
49
+ }
50
+ }
51
+
52
+ // Analyze exists tables, update columns
53
+ if ($db_analyzer->getExistsTables()) {
54
+ foreach ($db_analyzer->getExistsTables() as $table_name) {
55
+ $db_column_creator = new \Cleantalk\ApbctWP\UpdatePlugin\DbColumnCreator($table_name);
56
+ $db_column_creator->execute();
57
+
58
+ if ($db_column_creator->getTableChangedStatus()) {
59
+ // Checking whether to run the SFW update
60
+ if (substr($table_name, -3) === 'sfw') {
61
+ $need_start_update_sfw = true;
62
+ }
63
+ }
64
+ }
65
+ }
66
+
67
+ for ($ver_major = $current_version_arr[0]; $ver_major <= $current_version_arr[0]; $ver_major++) {
68
+ for ($ver_minor = 0; $ver_minor <= 300; $ver_minor++) {
69
+ for ($ver_fix = 0; $ver_fix <= 10; $ver_fix++) {
70
+ if (version_compare("{$ver_major}.{$ver_minor}.{$ver_fix}", $current_version_str, '<=')) {
71
  continue;
72
  }
73
 
74
+ if (function_exists("apbct_update_to_{$ver_major}_{$ver_minor}_{$ver_fix}")) {
75
  $result = call_user_func("apbct_update_to_{$ver_major}_{$ver_minor}_{$ver_fix}");
76
+ if (!empty($result['error'])) {
77
  break;
78
  }
79
  }
80
 
81
+ if ($ver_fix == 0 && function_exists("apbct_update_to_{$ver_major}_{$ver_minor}")) {
82
  $result = call_user_func("apbct_update_to_{$ver_major}_{$ver_minor}");
83
+ if (!empty($result['error'])) {
84
  break;
85
  }
86
  }
87
 
88
+ if (version_compare("{$ver_major}.{$ver_minor}.{$ver_fix}", $new_version_str, '>=')) {
89
+ break( 2 );
90
  }
91
  }
92
  }
93
  }
94
 
95
+ $apbct->stats['plugin']['plugin_is_being_updated'] = 0;
96
+ $apbct->save('stats');
97
+
98
+ // Start SFW update
99
+ if ($need_start_update_sfw) {
100
+ apbct_sfw_update__init();
101
+ }
102
+
103
  return true;
104
  }
105
 
121
  return $parsed_version;
122
  }
123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  /**
125
  * @return void
126
  */
136
  */
137
  function apbct_update_to_5_70_0()
138
  {
 
 
 
 
 
 
 
 
 
 
 
139
  // Deleting usless data
140
  delete_option('cleantalk_sends_reports_till');
141
  delete_option('cleantalk_activation_timestamp');
191
  {
192
  global $apbct, $wpdb;
193
 
194
+ if (apbct_is_plugin_active_for_network($apbct->base_name) && !defined('CLEANTALK_ACCESS_KEY')) {
195
+ $initial_blog = get_current_blog_id();
196
+ $blogs = array_keys($wpdb->get_results('SELECT blog_id FROM ' . $wpdb->blogs, OBJECT_K));
 
 
 
 
 
 
 
 
 
 
197
 
198
+ foreach ($blogs as $blog) {
 
 
199
  switch_to_blog($blog);
 
 
 
 
200
  // Cron tasks
201
  $cron = new Cron();
202
  $cron->addTask(
227
  time() + 3500
228
  ); // Send connection report to welcome@cleantalk.org
229
  }
230
+
231
  switch_to_blog($initial_blog);
232
  }
233
  }
239
  {
240
  global $apbct;
241
  unset($apbct->data['last_remote_call']);
242
+ $apbct->saveData();
243
  $apbct->save('remote_calls');
244
  }
245
 
248
  */
249
  function apbct_update_to_5_116_0()
250
  {
251
+ global $apbct;
252
 
253
+ $apbct->settings['store_urls'] = 0;
254
  $apbct->settings['store_urls__sessions'] = 0;
255
  $apbct->saveSettings();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
  }
257
 
258
  /**
260
  */
261
  function apbct_update_to_5_118_0()
262
  {
 
 
 
 
 
 
263
  delete_option('cleantalk_server');
264
  }
265
 
279
  */
280
  function apbct_update_to_5_119_0()
281
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
  // Drop work url
283
  update_option(
284
  'cleantalk_server',
322
 
323
  // Move exclusions from variable to settins
324
  global $cleantalk_url_exclusions, $cleantalk_key_exclusions;
325
+
326
  // URLs
327
+ if (!empty($cleantalk_url_exclusions) && is_array($cleantalk_url_exclusions)) {
328
  $apbct->settings['exclusions__urls'] = implode(',', $cleantalk_url_exclusions);
329
+ if (APBCT_WPMS) {
330
  $initial_blog = get_current_blog_id();
331
  switch_to_blog(1);
332
  $apbct->saveSettings();
336
  }
337
  }
338
  // Fields
339
+ if (!empty($cleantalk_key_exclusions) && is_array($cleantalk_key_exclusions)) {
340
  $apbct->settings['exclusions__fields'] = implode(',', $cleantalk_key_exclusions);
341
+ if (APBCT_WPMS) {
342
  $initial_blog = get_current_blog_id();
343
  switch_to_blog(1);
344
  $apbct->saveSettings();
349
  }
350
 
351
  // Deleting legacy
352
+ if (isset($apbct->data['testing_failed'])) {
353
  unset($apbct->data['testing_failed']);
354
  $apbct->saveData();
355
  }
356
 
357
+ if (APBCT_WPMS) {
358
  // Whitelabel
359
  // Reset "api_key_is_received" flag
360
  $initial_blog = get_current_blog_id();
361
  $blogs = array_keys($wpdb->get_results('SELECT blog_id FROM ' . $wpdb->blogs, OBJECT_K));
362
+ foreach ($blogs as $blog) {
363
  switch_to_blog($blog);
364
 
365
  $settings = get_option('cleantalk_settings');
366
+ if (isset($settings['use_static_js_key'])) {
367
+ $settings['use_static_js_key'] = $settings['use_static_js_key'] === 0
368
  ? -1
369
+ : $settings['use_static_js_key'];
370
  update_option('cleantalk_settings', $settings);
371
 
372
  $data = get_option('cleantalk_data');
373
+ if (isset($data['white_label_data']['is_key_recieved'])) {
374
  unset($data['white_label_data']['is_key_recieved']);
375
  update_option('cleantalk_data', $data);
376
  }
377
  }
378
  switch_to_blog($initial_blog);
379
 
380
+ if (defined('APBCT_WHITELABEL')) {
381
  $apbct->network_settings = array(
382
  'white_label' => defined('APBCT_WHITELABEL') && APBCT_WHITELABEL == true ? 1 : 0,
383
  'white_label__plugin_name' => defined('APBCT_WHITELABEL_NAME') ? APBCT_WHITELABEL_NAME : APBCT_NAME,
384
  );
385
+ } elseif (defined('CLEANTALK_ACCESS_KEY')) {
386
  $apbct->network_settings = array(
387
  'allow_custom_key' => 0,
388
  'apikey' => CLEANTALK_ACCESS_KEY,
405
  function apbct_update_to_5_127_1()
406
  {
407
  global $apbct;
408
+
409
+ if (APBCT_WPMS && is_main_site()) {
410
  $network_settings = get_site_option('cleantalk_network_settings');
411
+ if ($network_settings !== false && empty($network_settings['allow_custom_key']) && empty($network_settings['white_label'])) {
412
  $network_settings['allow_custom_key'] = 1;
413
  update_site_option('cleantalk_network_settings', $network_settings);
414
  }
436
  $apbct->save('remote_calls');
437
  }
438
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
439
  /**
440
  * @return void
441
  *
444
  function apbct_update_to_5_138_0()
445
  {
446
  global $wpdb;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
447
 
448
  // Actions for WPMS
449
+ if (APBCT_WPMS) {
450
  // Getting all blog ids
451
+ $initial_blog = get_current_blog_id();
452
+ $blogs = $wpdb->get_results('SELECT blog_id FROM ' . $wpdb->blogs, OBJECT_K);
453
+ $blogs_ids = array_keys($blogs);
454
 
455
  // Getting main blog setting
456
  switch_to_blog(1);
460
  // Getting network settings
461
  $net_settings = get_site_option('cleantalk_network_settings');
462
 
463
+ foreach ($blogs_ids as $blog) {
464
  // Update time limit to prevent exec time error
465
  set_time_limit(20);
466
 
467
  switch_to_blog($blog);
468
 
 
 
 
469
  // Getting key
470
  $settings = $net_settings['allow_custom_key']
471
  ? get_option('cleantalk_settings')
472
  : $main_blog_settings;
473
 
474
  // Update plugin status
475
+ if (! empty($settings['apikey'])) {
476
  $data = get_option('cleantalk_data', array());
477
 
478
  $result = \Cleantalk\ApbctWP\API::methodNoticePaidTill(
481
  ! is_main_site() && $net_settings['white_label'] ? 'anti-spam-hosting' : 'antispam'
482
  );
483
 
484
+ if (empty($result['error']) || ! empty($result['valid'])) {
485
  // Notices
486
+ $data['notice_show'] = isset($result['show_notice']) ? (int)$result['show_notice'] : 0;
487
+ $data['notice_renew'] = isset($result['renew']) ? (int)$result['renew'] : 0;
488
+ $data['notice_trial'] = isset($result['trial']) ? (int)$result['trial'] : 0;
489
+ $data['notice_review'] = isset($result['show_review']) ? (int)$result['show_review'] : 0;
490
  $data['notice_auto_update'] = isset($result['show_auto_update_notice']) ? (int)$result['show_auto_update_notice'] : 0;
491
 
492
  // Other
493
+ $data['service_id'] = isset($result['service_id']) ? (int)$result['service_id'] : 0;
494
+ $data['valid'] = isset($result['valid']) ? (int)$result['valid'] : 0;
495
+ $data['moderate'] = isset($result['moderate']) ? (int)$result['moderate'] : 0;
496
+ $data['ip_license'] = isset($result['ip_license']) ? (int)$result['ip_license'] : 0;
497
+ $data['moderate_ip'] = isset($result['moderate_ip'], $result['ip_license']) ? (int)$result['moderate_ip'] : 0;
498
+ $data['spam_count'] = isset($result['spam_count']) ? (int)$result['spam_count'] : 0;
499
+ $data['auto_update'] = isset($result['auto_update_app']) ? (int)$result['auto_update_app'] : 0;
500
+ $data['user_token'] = isset($result['user_token']) ? (string)$result['user_token'] : '';
501
+ $data['license_trial'] = isset($result['license_trial']) ? (int)$result['license_trial'] : 0;
502
+ $data['account_name_ob'] = isset($result['account_name_ob']) ? (string)$result['account_name_ob'] : '';
503
  }
504
 
505
  $data['key_is_ok'] = ! empty($result['valid'])
512
 
513
  // Restoring initial blog
514
  switch_to_blog($initial_blog);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
515
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
516
  }
517
 
518
  /**
532
  $cron->updateTask('antiflood__clear_table', 'apbct_antiflood__clear_table', 86400);
533
  }
534
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
535
  /**
536
  * @return void
537
  */
540
  global $wpdb;
541
 
542
  // Actions for WPMS
543
+ if (APBCT_WPMS) {
544
  // Getting all blog ids
545
  $initial_blog = get_current_blog_id();
546
  $blogs = array_keys($wpdb->get_results('SELECT blog_id FROM ' . $wpdb->blogs, OBJECT_K));
547
 
548
+ foreach ($blogs as $blog) {
549
  switch_to_blog($blog);
550
 
551
  update_option('cleantalk_plugin_request_ids', array());
556
  }
557
  }
558
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
559
  /**
560
  * @return void
561
  */
580
  */
581
  function apbct_update_to_5_151_3()
582
  {
583
+ global $apbct;
584
+
 
 
 
 
 
585
  $apbct->fw_stats['firewall_updating_last_start'] = 0;
586
  $apbct->save('fw_stats');
587
  $apbct->stats['sfw']['entries'] = 0;
617
 
618
  // Old setting name => New setting name
619
  $keys_map = array(
620
+ 'spam_firewall' => 'sfw__enabled',
621
+ 'registrations_test' => 'forms__registrations_test',
622
+ 'comments_test' => 'forms__comments_test',
623
+ 'contact_forms_test' => 'forms__contact_forms_test',
624
+ 'general_contact_forms_test' => 'forms__general_contact_forms_test',
625
+ 'wc_checkout_test' => 'forms__wc_checkout_test',
626
+ 'wc_register_from_order' => 'forms__wc_register_from_order',
627
+ 'search_test' => 'forms__search_test',
628
+ 'check_external' => 'forms__check_external',
629
+ 'check_external__capture_buffer' => 'forms__check_external__capture_buffer',
630
+ 'check_internal' => 'forms__check_internal',
631
+ 'disable_comments__all' => 'comments__disable_comments__all',
632
+ 'disable_comments__posts' => 'comments__disable_comments__posts',
633
+ 'disable_comments__pages' => 'comments__disable_comments__pages',
634
+ 'disable_comments__media' => 'comments__disable_comments__media',
635
+ 'bp_private_messages' => 'comments__bp_private_messages',
636
+ 'check_comments_number' => 'comments__check_comments_number',
637
+ 'remove_old_spam' => 'comments__remove_old_spam',
638
+ 'remove_comments_links' => 'comments__remove_comments_links',
639
+ 'show_check_links' => 'comments__show_check_links',
640
+ 'manage_comments_on_public_page' => 'comments__manage_comments_on_public_page',
641
+ 'protect_logged_in' => 'data__protect_logged_in',
642
+ 'use_ajax' => 'data__use_ajax',
643
+ 'use_static_js_key' => 'data__use_static_js_key',
644
+ 'general_postdata_test' => 'data__general_postdata_test',
645
+ 'set_cookies' => 'data__set_cookies',
646
+ 'set_cookies__sessions' => 'data__set_cookies__sessions',
647
+ 'ssl_on' => 'data__ssl_on',
648
+ 'show_adminbar' => 'admin_bar__show',
649
+ 'all_time_counter' => 'admin_bar__all_time_counter',
650
+ 'daily_counter' => 'admin_bar__daily_counter',
651
+ 'sfw_counter' => 'admin_bar__sfw_counter',
652
+ 'gdpr_enabled' => 'gdpr__enabled',
653
+ 'gdpr_text' => 'gdpr__text',
654
+ 'collect_details' => 'misc__collect_details',
655
+ 'send_connection_reports' => 'misc__send_connection_reports',
656
+ 'async_js' => 'misc__async_js',
657
+ 'debug_ajax' => 'misc__debug_ajax',
658
+ 'store_urls' => 'misc__store_urls',
659
+ 'store_urls__sessions' => 'misc__store_urls__sessions',
660
+ 'complete_deactivation' => 'misc__complete_deactivation',
661
+ 'use_buitin_http_api' => 'wp__use_builtin_http_api',
662
+ 'comment_notify' => 'wp__comment_notify',
663
+ 'comment_notify__roles' => 'wp__comment_notify__roles',
664
+ 'dashboard_widget__show' => 'wp__dashboard_widget__show',
665
+ 'allow_custom_key' => 'multisite__allow_custom_key',
666
+ 'allow_custom_settings' => 'multisite__allow_custom_settings',
667
+ 'white_label' => 'multisite__white_label',
668
+ 'white_label__plugin_name' => 'multisite__white_label__plugin_name',
669
+ 'use_settings_template' => 'multisite__use_settings_template',
670
+ 'use_settings_template_apply_for_new' => 'multisite__use_settings_template_apply_for_new',
671
+ 'use_settings_template_apply_for_current' => 'multisite__use_settings_template_apply_for_current',
672
  'use_settings_template_apply_for_current_list_sites' => 'multisite__use_settings_template_apply_for_current_list_sites',
673
  );
674
 
675
+ if (is_multisite()) {
676
  $network_settings = get_site_option('cleantalk_network_settings');
677
 
678
+ if ($network_settings) {
679
  $_network_settings = array();
680
  // replacing old key to new keys
681
+ foreach ($network_settings as $key => $value) {
682
+ if (array_key_exists($key, $keys_map)) {
683
  $_network_settings[$keys_map[$key]] = $value;
684
  } else {
685
  $_network_settings[$key] = $value;
686
  }
687
  }
688
+ if (! empty($_network_settings)) {
689
  update_site_option('cleantalk_network_settings', $_network_settings);
690
  }
691
  }
692
 
693
+ $initial_blog = get_current_blog_id();
694
+ $blogs = array_keys($wpdb->get_results('SELECT blog_id FROM ' . $wpdb->blogs, OBJECT_K));
695
+ foreach ($blogs as $blog) {
696
  switch_to_blog($blog);
697
 
698
  $settings = get_option('cleantalk_settings');
699
 
700
+ if ($settings) {
701
  // replacing old key to new keys
702
  $_settings = array();
703
+ foreach ($settings as $key => $value) {
704
+ if (array_key_exists($key, $keys_map)) {
705
  $_settings[$keys_map[$key]] = $value;
706
  } else {
707
  $_settings[$key] = $value;
708
  }
709
  }
710
+ if (! empty($_settings)) {
711
  update_option('cleantalk_settings', $_settings);
712
  }
713
  }
714
  }
715
  switch_to_blog($initial_blog);
716
  } else {
717
+ $apbct->data['current_settings_template_id'] = null;
718
  $apbct->data['current_settings_template_name'] = null;
719
  $apbct->saveData();
720
 
721
+ $settings = (array) $apbct->settings;
722
 
723
+ if ($settings) {
724
  $_settings = array();
725
  // replacing old key to new keys
726
+ foreach ($settings as $key => $value) {
727
+ if (array_key_exists($key, $keys_map)) {
728
  $_settings[$keys_map[$key]] = $value;
729
  } else {
730
  $_settings[$key] = $value;
735
  $apbct->saveSettings();
736
  }
737
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
738
  }
739
 
740
  /**
744
  {
745
  global $apbct;
746
 
747
+ $apbct->remote_calls['debug'] = array( 'last_call' => 0, 'cooldown' => 0 );
748
+ $apbct->remote_calls['debug_sfw'] = array( 'last_call' => 0, 'cooldown' => 0 );
749
  $apbct->save('remote_calls');
750
 
751
  $cron = new Cron();
762
  $apbct->remote_calls['sfw_update__worker'] = array('last_call' => 0, 'cooldown' => 0);
763
  $apbct->save('remote_calls');
764
 
765
+ if (! empty($apbct->settings['data__set_cookies__sessions'])) {
766
  $apbct->settings['data__set_cookies'] = 2;
767
  }
768
  $apbct->data['ajax_type'] = 'rest';
782
  // change name for prevent psalm false positive
783
  $_wpdb = $wpdb;
784
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
785
  // Update from fix branch
786
+ if (APBCT_WPMS && is_main_site()) {
787
  $wp_blogs = $_wpdb->get_results('SELECT blog_id, site_id FROM ' . $_wpdb->blogs, OBJECT_K);
788
  $current_sites_list = $apbct->settings['multisite__use_settings_template_apply_for_current_list_sites'];
789
 
790
+ if (is_array($wp_blogs) && is_array($current_sites_list)) {
791
+ foreach ($wp_blogs as $blog) {
792
  $blog_details = get_blog_details(array('blog_id' => $blog->blog_id));
793
+ if ($blog_details) {
794
  $site_list_index = array_search($blog_details->blogname, $current_sites_list, true);
795
+ if ($site_list_index !== false) {
796
  $current_sites_list[$site_list_index] = $blog_details->id;
797
  }
798
  }
828
 
829
  $ct_cron = new Cron();
830
 
831
+ if (is_multisite()) {
832
  $initial_blog = get_current_blog_id();
833
  $blogs = array_keys($wpdb->get_results('SELECT blog_id FROM ' . $wpdb->blogs, OBJECT_K));
834
+ foreach ($blogs as $blog) {
835
  switch_to_blog($blog);
836
  // Cron tasks
837
  $ct_cron->addTask(
912
  }
913
  }
914
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
915
  /**
916
  * @return void
917
  */
933
 
934
  apbct_remove_upd_folder(APBCT_DIR_PATH . '/fw_files');
935
 
936
+ if ($apbct->is_multisite) {
937
  $apbct->network_settings = array_merge((array)$apbct->network_settings, $apbct->default_network_settings);
938
  $apbct->save('network_settings');
939
  }
941
  apbct_remove_upd_folder(ABSPATH . '/wp-admin/fw_files');
942
  apbct_remove_upd_folder(Server::get('DOCUMENT_ROOT') . '/fw_files');
943
  $file_path = Server::get('DOCUMENT_ROOT') . '/fw_filesindex.php';
944
+ if (is_file($file_path) && is_writable($file_path)) {
945
  unlink($file_path);
946
  }
947
  }
950
  {
951
  global $apbct;
952
 
953
+ if ($apbct->is_multisite) {
954
  $apbct->network_settings = array_merge((array)$apbct->network_settings, $apbct->default_network_settings);
955
  // Migrate old WPMS to the new wpms mode
956
  if ( isset($apbct->network_settings['multisite__allow_custom_key']) ) {
968
  {
969
  global $apbct;
970
  // Set type of the alt cookies
971
+ if ($apbct->settings['data__set_cookies'] == 2) {
972
  // Check custom ajax availability
973
  $res_custom_ajax = Helper::httpRequestGetResponseCode(esc_url(APBCT_URL_PATH . '/lib/Cleantalk/ApbctWP/Ajax.php'));
974
+ if ($res_custom_ajax != 400) {
975
  // Check rest availability
976
  $res_rest = Helper::httpRequestGetResponseCode(esc_url(apbct_get_rest_url()));
977
+ if ($res_rest != 200) {
978
  // Check WP ajax availability
979
  $res_ajax = Helper::httpRequestGetResponseCode(admin_url('admin-ajax.php'));
980
+ if ($res_ajax != 400) {
981
  // There is no available alt cookies types. Cookies will be disabled.
982
  $apbct->settings['data__set_cookies'] = 0;
983
  } else {
1026
  $res_custom_ajax = Helper::httpRequestGetResponseCode(
1027
  esc_url(APBCT_URL_PATH . '/lib/Cleantalk/ApbctWP/Ajax.php')
1028
  );
1029
+ if ($res_custom_ajax != 400) {
1030
  // Check rest availability
1031
  $res_rest = Helper::httpRequestGetResponseCode(esc_url(apbct_get_rest_url()));
1032
+ if ($res_rest != 200) {
1033
  // Check WP ajax availability
1034
  $res_ajax = Helper::httpRequestGetResponseCode(admin_url('admin-ajax.php'));
1035
+ if ($res_ajax != 400) {
1036
  // There is no available alt cookies types. Cookies will be disabled.
1037
  $apbct->settings['data__use_ajax'] = 0;
1038
  } else {
1085
  $apbct->data['ajax_type'] = $alt_cookies_type;
1086
  $apbct->saveData();
1087
  }
1088
+
1089
+ /**
1090
+ * 5.164.2
1091
+ */
1092
+ function apbct_update_to_5_164_2()
1093
+ {
1094
+ global $apbct;
1095
+ $apbct->errorDeleteAll();
1096
+ }
js/apbct-public.min.js CHANGED
@@ -1,2 +1,2 @@
1
- function apbct_collect_visible_fields(e){var t=[],n="",o=0,c="",l=0,i=[];for(var a in e.elements)isNaN(+a)||(t[a]=e.elements[a]);return(t=t.filter(function(e){return-1===i.indexOf(e.getAttribute("name"))&&(-1===["radio","checkbox"].indexOf(e.getAttribute("type"))||(i.push(e.getAttribute("name")),!1))})).forEach(function(e,t,i){"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")?(n+=" "+e.getAttribute("name"),o++):(c+=" "+e.getAttribute("name"),l++))}),c=c.trim(),{visible_fields:n=n.trim(),visible_fields_count:o,invisible_fields:c,invisible_fields_count:l}}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,i,n){if(0<document.querySelectorAll("[name^=ct_checkjs]").length)for(var o=document.querySelectorAll("[name^=ct_checkjs]"),c=0;c<o.length;c++)o[c].value=e.js_key}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(),i=!0,n=[],o=0,c={},l=!1;function a(e,t,i){"function"==typeof window.addEventListener?e.addEventListener(t,i):e.attachEvent(t,i)}function s(e,t,i){"function"==typeof window.removeEventListener?e.removeEventListener(t,i):e.detachEvent(t,i)}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 u=function(){var e=Math.floor((new Date).getTime()/1e3);ctSetCookie("ct_fkp_timestamp",e),s(window,"mousedown",u),s(window,"keydown",u)},r=setInterval(function(){i=!0},150),d=setInterval(function(){ctSetCookie("ct_pointer_data",JSON.stringify(n))},1200),m=function(e){!0===i&&(n.push([Math.round(e.clientY),Math.round(e.clientX),Math.round((new Date).getTime()-t)]),i=!1,50<=++o&&(s(window,"mousemove",m),clearInterval(r),clearInterval(d)))};function _(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)))}})}a(window,"mousemove",m),a(window,"mousedown",u),a(window,"keydown",u),a(window,"scroll",function(){l||(ctSetCookie("ct_has_scrolled",JSON.stringify(!0)),l=!0)}),a(window,"DOMContentLoaded",function(){+ctPublic.pixel__setting&&(ctSetCookie("apbct_pixel_url",ctPublic.pixel__url),+ctPublic.pixel__enabled&&(document.getElementById("apbct_pixel")||jQuery("body").append('<img alt="Cleantalk Pixel" id="apbct_pixel" 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(_)),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 i=document.forms[t];i.classList.contains("slp_search_form")||i.parentElement.classList.contains("mec-booking")||-1!==i.action.toString().indexOf("activehosted.com")||i.id&&"caspioform"==i.id||i.name.classList&&i.name.classList.contains("tinkoffPayRow")||i.name.classList&&i.name.classList.contains("give-form")||(e[t]=apbct_collect_visible_fields(i),i.onsubmit_prev=i.onsubmit,i.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,i){var n;!t.responseText||-1===t.responseText.indexOf('"apbct')||void 0!==(n=JSON.parse(t.responseText)).apbct&&(n=n.apbct).blocked&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:n.comment}})),cleantalkModal.loaded=n.comment,cleantalkModal.open(),1==+n.stop_script&&window.stop())});
2
  //# sourceMappingURL=apbct-public.min.js.map
1
+ function apbct_collect_visible_fields(e){var t=[],n="",o=0,c="",l=0,i=[];for(var a in e.elements)isNaN(+a)||(t[a]=e.elements[a]);return(t=t.filter(function(e){return-1===i.indexOf(e.getAttribute("name"))&&(-1===["radio","checkbox"].indexOf(e.getAttribute("type"))||(i.push(e.getAttribute("name")),!1))})).forEach(function(e,t,i){"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")?(n+=" "+e.getAttribute("name"),o++):(c+=" "+e.getAttribute("name"),l++))}),c=c.trim(),{visible_fields:n=n.trim(),visible_fields_count:o,invisible_fields:c,invisible_fields_count:l}}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,i,n){if(0<document.querySelectorAll("[name^=ct_checkjs]").length)for(var o=document.querySelectorAll("[name^=ct_checkjs]"),c=0;c<o.length;c++)o[c].value=e.js_key}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 t=new Date,i=(new Date).getTime(),n=!0,o=[],c=0,l={},e=!1,a=!1;function s(e,t,i){"function"==typeof window.addEventListener?e.addEventListener(t,i):e.attachEvent(t,i)}function u(e,t,i){"function"==typeof window.removeEventListener?e.removeEventListener(t,i):e.detachEvent(t,i)}var r=function(){var e=Math.floor((new Date).getTime()/1e3);ctSetCookie("ct_fkp_timestamp",e),u(window,"mousedown",r),u(window,"keydown",r)},d=setInterval(function(){n=!0},150),m=setInterval(function(){ctSetCookie("ct_pointer_data",JSON.stringify(o))},1200),_=function(e){a||(ctSetCookie("ct_mouse_moved","true"),a=!0),!0===n&&(o.push([Math.round(e.clientY),Math.round(e.clientX),Math.round((new Date).getTime()-i)]),n=!1,50<=++c&&(u(window,"mousemove",_),clearInterval(d),clearInterval(m)))};function f(e){var t=e.target.value;!t||t in l||apbct_public_sendAJAX({action:"apbct_email_check_before_post",data:{email:t}},{apbct_ajax:1,callback:function(e){e.result&&(l[t]={result:e.result,timestamp:Date.now()/1e3|0},ctSetCookie("ct_checked_emails",JSON.stringify(l)))}})}s(window,"mousemove",_),s(window,"mousedown",r),s(window,"keydown",r),s(window,"scroll",function(){e||(ctSetCookie("ct_has_scrolled","true"),e=!0)}),s(window,"DOMContentLoaded",function(){var e=[["ct_ps_timestamp",Math.floor((new Date).getTime()/1e3)],["ct_fkp_timestamp","0"],["ct_pointer_data","0"],["ct_timezone",t.getTimezoneOffset()/60*-1],["apbct_visible_fields","0"],["ct_screen_info",apbctGetScreenInfo()],["ct_has_scrolled","false"],["ct_mouse_moved","false"]];+ctPublic.pixel__setting&&(e.push(["apbct_pixel_url",ctPublic.pixel__url]),+ctPublic.pixel__enabled&&(document.getElementById("apbct_pixel")||jQuery("body").append('<img alt="Cleantalk Pixel" id="apbct_pixel" style="display: none; left: 99999px;" src="'+ctPublic.pixel__url+'">'))),+ctPublic.data__email_check_before_post&&(e.push(["ct_checked_emails","0"]),jQuery("input[type = 'email'], #email").blur(f)),ctSetCookie(e),setTimeout(function(){for(var e={},t=0;t<document.forms.length;t++){var i=document.forms[t];i.classList.contains("slp_search_form")||i.parentElement.classList.contains("mec-booking")||-1!==i.action.toString().indexOf("activehosted.com")||i.id&&"caspioform"==i.id||i.name.classList&&i.name.classList.contains("tinkoffPayRow")||i.name.classList&&i.name.classList.contains("give-form")||(e[t]=apbct_collect_visible_fields(i),i.onsubmit_prev=i.onsubmit,i.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,i){var n;!t.responseText||-1===t.responseText.indexOf('"apbct')||void 0!==(n=JSON.parse(t.responseText)).apbct&&(n=n.apbct).blocked&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:n.comment}})),cleantalkModal.loaded=n.comment,cleantalkModal.open(),1==+n.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\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\tif( ! document.getElementById('apbct_pixel') ) {\n\t\t\t\t\tjQuery('body').append( '<img alt=\"Cleantalk Pixel\" id=\"apbct_pixel\" style=\"display: none; left: 99999px;\" src=\"' + ctPublic.pixel__url + '\">' );\n\t\t\t\t}\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 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 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":["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","forEach","i","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","ctSetCookie","JSON","stringify","apbct_js_keys__set_input_value","result","data","params","obj","document","querySelectorAll","length","value","js_key","apbctGetScreenInfo","fullWidth","documentElement","scrollWidth","fullHeight","Math","max","body","scrollHeight","offsetHeight","clientHeight","visibleWidth","clientWidth","visibleHeight","ct_date","Date","ctTimeMs","getTime","ctMouseEventTimerFlag","ctMouseData","ctMouseDataCounter","ctCheckedEmails","ctScrollCollected","apbct_attach_event_handler","event","callback","window","addEventListener","attachEvent","apbct_remove_event_handler","removeEventListener","detachEvent","floor","getTimezoneOffset","ctFunctionFirstKey","KeyTimestamp","ctMouseReadInterval","setInterval","ctMouseWriteDataInterval","ctFunctionMouseMove","round","clientY","clientX","clearInterval","checkEmail","e","current_email","target","apbct_public_sendAJAX","action","email","apbct_ajax","timestamp","now","ctPublic","pixel__setting","pixel__url","pixel__enabled","getElementById","jQuery","append","data__email_check_before_post","blur","setTimeout","forms","parentElement","toString","id","name","onsubmit_prev","onsubmit","this","Function","call","ajaxComplete","xhr","settings","response","responseText","parse","apbct","blocked","dispatchEvent","CustomEvent","bubbles","detail","message","comment","cleantalkModal","loaded","open","stop_script","stop"],"mappings":"AA6KA,SAASA,6BAA8BC,GAGtC,IAAIC,EAAS,GACZC,EAAiB,GACjBC,EAAuB,EACvBC,EAAmB,GACnBC,EAAyB,EACzBC,EAA8B,GAE/B,IAAI,IAAIC,KAAOP,EAAKQ,SACfC,OAAOF,KACVN,EAAOM,GAAOP,EAAKQ,SAASD,IAsD9B,OAlDAN,EAASA,EAAOS,OAAO,SAASC,GAG/B,OAA0E,IAAtEL,EAA4BM,QAASD,EAAKE,aAAa,YAItD,IAAM,CAAC,QAAS,YAAYD,QAASD,EAAKE,aAAa,WAC3DP,EAA4BQ,KAAMH,EAAKE,aAAa,UAC7C,OAMFE,QAAQ,SAASJ,EAAMK,EAAGR,GAGO,WAAtCG,EAAKE,aAAa,SACoB,OAAtCF,EAAKE,aAAa,SACoB,eAAtCF,EAAKE,aAAa,UAMoB,SAAtCI,iBAAiBN,GAAMO,SACe,WAAtCD,iBAAiBN,GAAMQ,YACe,MAAtCF,iBAAiBN,GAAMS,SACe,WAAtCT,EAAKE,aAAa,SAEdF,EAAKU,UAAUC,SAAS,mBAU5BpB,GAAkB,IAAMS,EAAKE,aAAa,QAC1CV,MAPCC,GAAoB,IAAMO,EAAKE,aAAa,QA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C,SAAS,EACTC,OAAQ,CAAEC,QAAST,EAASU,YAK9BC,eAAeC,OAASZ,EAASU,QACjCC,eAAeE,OAEa,IAAxBb,EAASc,aACZjE,OAAOkE"}
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\t\tctMouseMovedCollected = 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\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\tctSetMouseMoved();\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\", 'true');\n\t\t\tctScrollCollected = true;\n\t\t}\n\t}\n\n\tfunction ctSetMouseMoved() {\n\t\tif( ! ctMouseMovedCollected ) {\n\t\t\tctSetCookie(\"ct_mouse_moved\", 'true');\n\t\t\tctMouseMovedCollected = 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\t// Collect scrolling info\n\t\tvar initCookies = [\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\t[\"ct_screen_info\", apbctGetScreenInfo()],\n\t\t\t[\"ct_has_scrolled\", 'false'],\n\t\t\t[\"ct_mouse_moved\", 'false'],\n\t\t];\n\n\t\tif( +ctPublic.pixel__setting ){\n\t\t\tinitCookies.push(['apbct_pixel_url', ctPublic.pixel__url]);\n\t\t\tif( +ctPublic.pixel__enabled ){\n\t\t\t\tif( ! document.getElementById('apbct_pixel') ) {\n\t\t\t\t\tjQuery('body').append( '<img alt=\"Cleantalk Pixel\" id=\"apbct_pixel\" style=\"display: none; left: 99999px;\" src=\"' + ctPublic.pixel__url + '\">' );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( +ctPublic.data__email_check_before_post) {\n\t\t\tinitCookies.push(['ct_checked_emails', '0']);\n\t\t\tjQuery(\"input[type = 'email'], #email\").blur(checkEmail);\n\t\t}\n\n\t\tctSetCookie(initCookies);\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 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 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":["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","forEach","i","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","ctSetCookie","JSON","stringify","apbct_js_keys__set_input_value","result","data","params","obj","document","querySelectorAll","length","value","js_key","apbctGetScreenInfo","fullWidth","documentElement","scrollWidth","fullHeight","Math","max","body","scrollHeight","offsetHeight","clientHeight","visibleWidth","clientWidth","visibleHeight","ct_date","Date","ctTimeMs","getTime","ctMouseEventTimerFlag","ctMouseData","ctMouseDataCounter","ctCheckedEmails","ctScrollCollected","ctMouseMovedCollected","apbct_attach_event_handler","event","callback","window","addEventListener","attachEvent","apbct_remove_event_handler","removeEventListener","detachEvent","ctFunctionFirstKey","KeyTimestamp","floor","ctMouseReadInterval","setInterval","ctMouseWriteDataInterval","ctFunctionMouseMove","round","clientY","clientX","clearInterval","checkEmail","e","current_email","target","apbct_public_sendAJAX","action","email","apbct_ajax","timestamp","now","initCookies","getTimezoneOffset","ctPublic","pixel__setting","pixel__url","pixel__enabled","getElementById","jQuery","append","data__email_check_before_post","blur","setTimeout","forms","parentElement","toString","id","name","onsubmit_prev","onsubmit","this","Function","call","ajaxComplete","xhr","settings","response","responseText","parse","apbct","blocked","dispatchEvent","CustomEvent","bubbles","detail","message","comment","cleantalkModal","loaded","open","stop_script","stop"],"mappings":"AAsLA,SAASA,6BAA8BC,GAGtC,IAAIC,EAAS,GACZC,EAAiB,GACjBC,EAAuB,EACvBC,EAAmB,GACnBC,EAAyB,EACzBC,EAA8B,GAE/B,IAAI,IAAIC,KAAOP,EAAKQ,SACfC,OAAOF,KACVN,EAAOM,GAAOP,EAAKQ,SAASD,IAsD9B,OAlDAN,EAASA,EAAOS,OAAO,SAASC,GAG/B,OAA0E,IAAtEL,EAA4BM,QAASD,EAAKE,aAAa,YAItD,IAAM,CAAC,QAAS,YAAYD,QAASD,EAAKE,aAAa,WAC3DP,EAA4BQ,KAAMH,EAAKE,aAAa,UAC7C,OAMFE,QAAQ,SAASJ,EAAMK,EAAGR,GAGO,WAAtCG,EAAKE,aAAa,SACoB,OAAtCF,EAAKE,aAAa,SACoB,eAAtCF,EAAKE,aAAa,UAMoB,SAAtCI,iBAAiBN,GAAMO,SACe,WAAtCD,iBAAiBN,GAAMQ,YACe,MAAtCF,iBAAiBN,GAAMS,SACe,W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UiF,aAAa,SAAUnD,EAAOoD,EAAKC,GACnD,IACKC,GADDF,EAAIG,eAAwD,IAAxCH,EAAIG,aAAahH,QAAQ,gBAElB,KAD1B+G,EAAW3F,KAAK6F,MAAMJ,EAAIG,eACVE,QACnBH,EAAWA,EAASG,OACPC,UACZxF,SAASyF,cACR,IAAIC,YAAa,qBAAsB,CACtCC,SAAS,EACTC,OAAQ,CAAEC,QAAST,EAASU,YAK9BC,eAAeC,OAASZ,EAASU,QACjCC,eAAeE,OAEa,IAAxBb,EAASc,aACZlE,OAAOmE"}
js/cleantalk-comments-checkspam.min.js CHANGED
@@ -1,2 +1,2 @@
1
- var ct_working=!(String.prototype.printf=function(){var e=this;for(var t in arguments)var c=e.substring(0,e.indexOf("%s",0)),a=e.substring(e.indexOf("%s",0)+2,e.length),e=c+arguments[t]+a;return e}),ct_new_check=!0,ct_cooling_down_flag=!1,ct_close_animate=!0,ct_accurate_check=!1,ct_pause=!1,ct_prev_accurate=ctCommentsCheck.ct_prev_accurate,ct_prev_from=ctCommentsCheck.ct_prev_from,ct_prev_till=ctCommentsCheck.ct_prev_till,ct_cool_down_time=9e4,ct_requests_counter=0,ct_max_requests=60,ct_ajax_nonce=ctCommentsCheck.ct_ajax_nonce,ct_comments_total=0,ct_comments_checked=0,ct_comments_spam=0,ct_comments_bad=0,ct_unchecked="unset",ct_date_from=0,ct_date_till=0;function animate_comment(e,t){ct_close_animate?.3==e?jQuery("#comment-"+t).fadeTo(200,e,function(){animate_comment(1,t)}):jQuery("#comment-"+t).fadeTo(200,e,function(){animate_comment(.3,t)}):ct_close_animate=!0}function ct_clear_comments(){var e=0,t=0;jQuery("#ct_allow_date_range").is(":checked")&&(e=jQuery("#ct_date_range_from").val(),t=jQuery("#ct_date_range_till").val());var c={action:"ajax_clear_comments",security:ct_ajax_nonce,from:e,till:t};jQuery.ajax({type:"POST",url:ajaxurl,data:c,success:function(e){ct_show_info(),ct_send_comments()}})}function ct_cooling_down_toggle(){ct_cooling_down_flag=!1,ct_send_comments(),ct_show_info()}function ct_send_comments(){if(!0!==ct_cooling_down_flag){if(ct_max_requests<=ct_requests_counter)return setTimeout(ct_cooling_down_toggle,ct_cool_down_time),void(ct_cooling_down_flag=!(ct_requests_counter=0));ct_requests_counter++;var e={action:"ajax_check_comments",security:ct_ajax_nonce,new_check:ct_new_check,unchecked:ct_unchecked};ct_accurate_check&&(e.accurate_check=!0),ct_date_from&&ct_date_till&&(e.from=ct_date_from,e.till=ct_date_till),jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){var t,c;e=jQuery.parseJSON(e),parseInt(e.error)?(ct_working=!1,confirm(e.error_message+". Do you want to proceed?")?ct_send_comments():(t="edit-comments.php?page=ct_check_spam",0!=ct_date_from&&0!=ct_date_till&&(t+="&from="+ct_date_from+"&till="+ct_date_till),location.href=t)):(ct_new_check=!1,1==parseInt(e.end)||!0===ct_pause?(1==parseInt(e.end)&&(document.cookie="ct_paused_spam_check=0; path=/; samesite=lax"),ct_working=!1,jQuery("#ct_working_message").hide(),t="edit-comments.php?page=ct_check_spam",0!=ct_date_from&&0!=ct_date_till&&(t+="&from="+ct_date_from+"&till="+ct_date_till),location.href=t):0==parseInt(e.end)&&(ct_comments_checked+=e.checked,ct_comments_spam+=e.spam,ct_comments_bad+=e.bad,ct_unchecked=ct_comments_total-ct_comments_checked-ct_comments_bad,c=(c=String(ctCommentsCheck.ct_status_string)).printf(ct_comments_checked,ct_comments_spam,ct_comments_bad),0<parseInt(ct_comments_spam)&&(c+=ctCommentsCheck.ct_status_string_warning),jQuery("#ct_checking_status").html(c),jQuery("#ct_error_message").hide(),+ct_comments_total<ct_comments_checked+ct_comments_bad&&(document.cookie="ct_comments_start_check=1; path=/; samesite=lax",document.cookie="ct_comments_safe_check=1; path=/; samesite=lax",location.href="edit-comments.php?page=ct_check_spam"),ct_send_comments()))},error:function(e,t,c){jQuery("#ct_error_message").show(),jQuery("#cleantalk_ajax_error").html(t),jQuery("#cleantalk_js_func").html("Check comments"),setTimeout(ct_send_comments(),3e3)},timeout:25e3})}}function ct_show_info(){if(ct_working){if(1==ct_cooling_down_flag)return jQuery("#ct_cooling_notice").html("Waiting for API to cool down. (About a minute)"),void jQuery("#ct_cooling_notice").show();var e;jQuery("#ct_cooling_notice").hide(),ct_comments_total||(e={action:"ajax_info_comments",security:ct_ajax_nonce},ct_date_from&&ct_date_till&&(e.from=ct_date_from,e.till=ct_date_till),jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){e=jQuery.parseJSON(e),jQuery("#ct_checking_status").html(e.message),ct_comments_total=e.total,ct_comments_spam=e.spam,ct_comments_checked=e.checked,ct_comments_bad=e.bad},error:function(e,t,c){jQuery("#ct_error_message").show(),jQuery("#cleantalk_ajax_error").html(t),jQuery("#cleantalk_js_func").html("Check comments"),setTimeout(ct_show_info(),3e3)},timeout:15e3}))}}function ct_toggle_depended(e,t){t=t||null;var c=jQuery(e.data("depended"));e.data("state")||t?(e.data("state",!1),c.prop("disabled",!0),c.removeProp("checked"),c.data("depended")&&ct_toggle_depended(c,!0)):(e.data("state",!0),c.removeProp("disabled"))}function ct_trash_all(a){var e={action:"ajax_trash_all",security:ct_ajax_nonce};jQuery("."+a.target.id).addClass("disabled"),jQuery(".spinner").css("visibility","visible"),jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){0<e?(jQuery("#cleantalk_comments_left").html(e),ct_trash_all(a)):(jQuery("."+a.target.id).removeClass("disabled"),jQuery(".spinner").css("visibility","hidden"),location.href="edit-comments.php?page=ct_check_spam")},error:function(e,t,c){jQuery("#ct_error_message").show(),jQuery("#cleantalk_ajax_error").html(t),jQuery("#cleantalk_js_func").html("Check comments"),setTimeout(ct_trash_all(a),3e3)},timeout:25e3})}function ct_spam_all(a){var e={action:"ajax_spam_all",security:ct_ajax_nonce};jQuery("."+a.target.id).addClass("disabled"),jQuery(".spinner").css("visibility","visible"),jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){0<e?(jQuery("#cleantalk_comments_left").html(e),ct_spam_all(a)):(jQuery("."+a.target.id).removeClass("disabled"),jQuery(".spinner").css("visibility","hidden"),location.href="edit-comments.php?page=ct_check_spam")},error:function(e,t,c){jQuery("#ct_error_message").show(),jQuery("#cleantalk_ajax_error").html(t),jQuery("#cleantalk_js_func").html("Check comments"),setTimeout(ct_spam_all(a),3e3)},timeout:25e3})}jQuery(document).ready(function(){ct_prev_accurate&&jQuery("#ct_accurate_check").prop("checked",!0),ct_prev_from&&(jQuery("#ct_allow_date_range").prop("checked",!0).data("state",!0),jQuery("#ct_date_range_from").removeProp("disabled").val(ct_prev_from),jQuery("#ct_date_range_till").removeProp("disabled").val(ct_prev_till)),jQuery("#ct_allow_date_range").on("change",function(){document.cookie="ct_spam_dates_from="+jQuery("#ct_date_range_from").val()+"; path=/; samesite=lax",document.cookie="ct_spam_dates_till="+jQuery("#ct_date_range_till").val()+"; path=/; samesite=lax",this.checked?(document.cookie="ct_spam_dates_allowed=1; path=/; samesite=lax",jQuery(".ct_date").prop("checked",!0).attr("disabled",!1)):(document.cookie="ct_spam_dates_allowed=0; path=/; samesite=lax",jQuery(".ct_date").prop("disabled",!0).attr("disabled",!0))}),jQuery.datepicker.setDefaults(jQuery.datepicker.regional.en);var _=jQuery("#ct_date_range_from, #ct_date_range_till").datepicker({dateFormat:"M d yy",maxDate:"+0D",changeMonth:!0,changeYear:!0,showAnim:"slideDown",onSelect:function(e){var t="ct_date_range_from"==this.id?"minDate":"maxDate",c=jQuery(this).data("datepicker"),a=jQuery.datepicker.parseDate(c.settings.dateFormat||jQuery.datepicker._defaults.dateFormat,e,c.settings);_.not(this).datepicker("option",t,a),document.cookie="ct_spam_dates_from="+jQuery("#ct_date_range_from").val()+"; path=/; samesite=lax",document.cookie="ct_spam_dates_till="+jQuery("#ct_date_range_till").val()+"; path=/; samesite=lax"}});function e(e){e=e||null,jQuery("#ct_allow_date_range").is(":checked")&&(ct_date_from=jQuery("#ct_date_range_from").val(),ct_date_till=jQuery("#ct_date_range_till").val(),""==ct_date_from||""==ct_date_till)?alert("Please, specify a date range."):(jQuery("#ct_accurate_check").is(":checked")&&(ct_accurate_check=!0),jQuery(".ct_to_hide").hide(),jQuery("#ct_working_message").show(),jQuery("#ct_preloader").show(),jQuery("#ct_pause").show(),ct_working=!0,e?(ct_show_info(),ct_send_comments()):ct_clear_comments())}jQuery("#ct_check_spam_button").click(function(){e(!(document.cookie="ct_paused_spam_check=0; path=/; samesite=lax"))}),jQuery("#ct_proceed_check_button").click(function(){e(!0)}),jQuery("#ct_pause").on("click",function(){ct_pause=!0;var e={accurate:ct_accurate_check,from:ct_date_from,till:ct_date_till};document.cookie="ct_paused_spam_check="+JSON.stringify(e)+"; path=/; samesite=lax"}),"1"===ctCommentsCheck.start&&(document.cookie="ct_comments_start_check=0; expires="+new Date(0).toUTCString()+"; path=/; samesite=lax",jQuery("#ct_check_spam_button").click()),jQuery(".ct_trash_all").click(function(e){return!!confirm(ctCommentsCheck.ct_confirm_trash_all)&&void ct_trash_all(e)}),jQuery(".ct_spam_all").click(function(e){return!!confirm(ctCommentsCheck.ct_confirm_spam_all)&&void ct_spam_all(e)})});
2
  //# sourceMappingURL=cleantalk-comments-checkspam.min.js.map
1
+ var ct_working=!(String.prototype.printf=function(){var e,t=this;for(e in arguments)var c=t.substring(0,t.indexOf("%s",0)),a=t.substring(t.indexOf("%s",0)+2,t.length),t=c+arguments[e]+a;return t}),ct_new_check=!0,ct_cooling_down_flag=!1,ct_close_animate=!0,ct_accurate_check=!1,ct_pause=!1,ct_prev_accurate=ctCommentsCheck.ct_prev_accurate,ct_prev_from=ctCommentsCheck.ct_prev_from,ct_prev_till=ctCommentsCheck.ct_prev_till,ct_cool_down_time=9e4,ct_requests_counter=0,ct_max_requests=60,ct_ajax_nonce=ctCommentsCheck.ct_ajax_nonce,ct_comments_total=0,ct_comments_checked=0,ct_comments_spam=0,ct_comments_bad=0,ct_unchecked="unset",ct_date_from=0,ct_date_till=0;function animate_comment(e,t){ct_close_animate?.3==e?jQuery("#comment-"+t).fadeTo(200,e,function(){animate_comment(1,t)}):jQuery("#comment-"+t).fadeTo(200,e,function(){animate_comment(.3,t)}):ct_close_animate=!0}function ct_clear_comments(){var e=0,t=0;jQuery("#ct_allow_date_range").is(":checked")&&(e=jQuery("#ct_date_range_from").val(),t=jQuery("#ct_date_range_till").val());var c="https:"===location.protocol?"; secure":"";document.cookie="apbct_check_comments_offset=0; path=/; samesite=lax"+c,jQuery.ajax({type:"POST",url:ajaxurl,data:{action:"ajax_clear_comments",security:ct_ajax_nonce,from:e,till:t},success:function(e){ct_show_info(),ct_send_comments()}})}function ct_cooling_down_toggle(){ct_cooling_down_flag=!1,ct_send_comments(),ct_show_info()}function ct_send_comments(){if(!0!==ct_cooling_down_flag){if(ct_max_requests<=ct_requests_counter)return setTimeout(ct_cooling_down_toggle,ct_cool_down_time),void(ct_cooling_down_flag=!(ct_requests_counter=0));ct_requests_counter++;var e={action:"ajax_check_comments",security:ct_ajax_nonce,new_check:ct_new_check,unchecked:ct_unchecked,offset:Number(ctGetCookie("apbct_check_comments_offset"))};ct_accurate_check&&(e.accurate_check=!0),ct_date_from&&ct_date_till&&(e.from=ct_date_from,e.till=ct_date_till),jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){var t;e=jQuery.parseJSON(e),parseInt(e.error)?(ct_working=!1,confirm(e.error_message+". Do you want to proceed?")?ct_send_comments():(t="edit-comments.php?page=ct_check_spam",0!=ct_date_from&&0!=ct_date_till&&(t+="&from="+ct_date_from+"&till="+ct_date_till),location.href=t)):(ct_new_check=!1,1==parseInt(e.end)||!0===ct_pause?(1==parseInt(e.end)&&(document.cookie="ct_paused_spam_check=0; path=/; samesite=lax"),ct_working=!1,jQuery("#ct_working_message").hide(),t="edit-comments.php?page=ct_check_spam",0!=ct_date_from&&0!=ct_date_till&&(t+="&from="+ct_date_from+"&till="+ct_date_till),location.href=t):0==parseInt(e.end)&&(ct_comments_checked+=e.checked,ct_comments_spam+=e.spam,ct_comments_bad+=e.bad,ct_unchecked=ct_comments_total-ct_comments_checked-ct_comments_bad,e=(e=String(ctCommentsCheck.ct_status_string)).printf(ct_comments_checked,ct_comments_spam,ct_comments_bad),0<parseInt(ct_comments_spam)&&(e+=ctCommentsCheck.ct_status_string_warning),jQuery("#ct_checking_status").html(e),jQuery("#ct_error_message").hide(),+ct_comments_total<ct_comments_checked+ct_comments_bad&&(document.cookie="ct_comments_start_check=1; path=/; samesite=lax",location.href="edit-comments.php?page=ct_check_spam"),e=Number(ctGetCookie("apbct_check_comments_offset"))+100,document.cookie="apbct_check_comments_offset="+e+"; path=/",ct_send_comments()))},error:function(e,t,c){jQuery("#ct_error_message").show(),jQuery("#cleantalk_ajax_error").html(t),jQuery("#cleantalk_js_func").html("Check comments"),setTimeout(ct_send_comments(),3e3)},timeout:25e3})}}function ct_show_info(){if(ct_working){if(1==ct_cooling_down_flag)return jQuery("#ct_cooling_notice").html("Waiting for API to cool down. (About a minute)"),void jQuery("#ct_cooling_notice").show();var e;jQuery("#ct_cooling_notice").hide(),ct_comments_total||(e={action:"ajax_info_comments",security:ct_ajax_nonce},ct_date_from&&ct_date_till&&(e.from=ct_date_from,e.till=ct_date_till),jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){e=jQuery.parseJSON(e),jQuery("#ct_checking_status").html(e.message),ct_comments_total=e.total,ct_comments_spam=e.spam,ct_comments_checked=e.checked,ct_comments_bad=e.bad},error:function(e,t,c){jQuery("#ct_error_message").show(),jQuery("#cleantalk_ajax_error").html(t),jQuery("#cleantalk_js_func").html("Check comments"),setTimeout(ct_show_info(),3e3)},timeout:15e3}))}}function ct_toggle_depended(e,t){t=t||null;var c=jQuery(e.data("depended"));e.data("state")||t?(e.data("state",!1),c.prop("disabled",!0),c.removeProp("checked"),c.data("depended")&&ct_toggle_depended(c,!0)):(e.data("state",!0),c.removeProp("disabled"))}function ct_trash_all(a){var e={action:"ajax_trash_all",security:ct_ajax_nonce};jQuery("."+a.target.id).addClass("disabled"),jQuery(".spinner").css("visibility","visible"),jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){0<e?(jQuery("#cleantalk_comments_left").html(e),ct_trash_all(a)):(jQuery("."+a.target.id).removeClass("disabled"),jQuery(".spinner").css("visibility","hidden"),location.href="edit-comments.php?page=ct_check_spam")},error:function(e,t,c){jQuery("#ct_error_message").show(),jQuery("#cleantalk_ajax_error").html(t),jQuery("#cleantalk_js_func").html("Check comments"),setTimeout(ct_trash_all(a),3e3)},timeout:25e3})}function ct_spam_all(a){var e={action:"ajax_spam_all",security:ct_ajax_nonce};jQuery("."+a.target.id).addClass("disabled"),jQuery(".spinner").css("visibility","visible"),jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){0<e?(jQuery("#cleantalk_comments_left").html(e),ct_spam_all(a)):(jQuery("."+a.target.id).removeClass("disabled"),jQuery(".spinner").css("visibility","hidden"),location.href="edit-comments.php?page=ct_check_spam")},error:function(e,t,c){jQuery("#ct_error_message").show(),jQuery("#cleantalk_ajax_error").html(t),jQuery("#cleantalk_js_func").html("Check comments"),setTimeout(ct_spam_all(a),3e3)},timeout:25e3})}function ctGetCookie(e){e=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return e?decodeURIComponent(e[1]):void 0}jQuery(document).ready(function(){ct_prev_accurate&&jQuery("#ct_accurate_check").prop("checked",!0),ct_prev_from&&(jQuery("#ct_allow_date_range").prop("checked",!0).data("state",!0),jQuery("#ct_date_range_from").removeProp("disabled").val(ct_prev_from),jQuery("#ct_date_range_till").removeProp("disabled").val(ct_prev_till)),jQuery("#ct_allow_date_range").on("change",function(){document.cookie="ct_spam_dates_from="+jQuery("#ct_date_range_from").val()+"; path=/; samesite=lax",document.cookie="ct_spam_dates_till="+jQuery("#ct_date_range_till").val()+"; path=/; samesite=lax",this.checked?(document.cookie="ct_spam_dates_allowed=1; path=/; samesite=lax",jQuery(".ct_date").prop("checked",!0).attr("disabled",!1)):(document.cookie="ct_spam_dates_allowed=0; path=/; samesite=lax",jQuery(".ct_date").prop("disabled",!0).attr("disabled",!0))}),jQuery.datepicker.setDefaults(jQuery.datepicker.regional.en);var a=jQuery("#ct_date_range_from, #ct_date_range_till").datepicker({dateFormat:"M d yy",maxDate:"+0D",changeMonth:!0,changeYear:!0,showAnim:"slideDown",onSelect:function(e){var t="ct_date_range_from"==this.id?"minDate":"maxDate",c=jQuery(this).data("datepicker"),c=jQuery.datepicker.parseDate(c.settings.dateFormat||jQuery.datepicker._defaults.dateFormat,e,c.settings);a.not(this).datepicker("option",t,c),document.cookie="ct_spam_dates_from="+jQuery("#ct_date_range_from").val()+"; path=/; samesite=lax",document.cookie="ct_spam_dates_till="+jQuery("#ct_date_range_till").val()+"; path=/; samesite=lax"}});function e(e){e=e||null,jQuery("#ct_allow_date_range").is(":checked")&&(ct_date_from=jQuery("#ct_date_range_from").val(),ct_date_till=jQuery("#ct_date_range_till").val(),""==ct_date_from||""==ct_date_till)?alert("Please, specify a date range."):(jQuery("#ct_accurate_check").is(":checked")&&(ct_accurate_check=!0),jQuery(".ct_to_hide").hide(),jQuery("#ct_working_message").show(),jQuery("#ct_preloader").show(),jQuery("#ct_pause").show(),ct_working=!0,e?(ct_show_info(),ct_send_comments()):ct_clear_comments())}jQuery("#ct_check_spam_button").click(function(){e(!(document.cookie="ct_paused_spam_check=0; path=/; samesite=lax"))}),jQuery("#ct_proceed_check_button").click(function(){e(!0)}),jQuery("#ct_pause").on("click",function(){ct_pause=!0;var e={accurate:ct_accurate_check,from:ct_date_from,till:ct_date_till};document.cookie="ct_paused_spam_check="+JSON.stringify(e)+"; path=/; samesite=lax"}),"1"===ctCommentsCheck.start&&(document.cookie="ct_comments_start_check=0; expires="+new Date(0).toUTCString()+"; path=/; samesite=lax",jQuery("#ct_check_spam_button").click()),jQuery(".ct_trash_all").click(function(e){return!!confirm(ctCommentsCheck.ct_confirm_trash_all)&&void ct_trash_all(e)}),jQuery(".ct_spam_all").click(function(e){return!!confirm(ctCommentsCheck.ct_confirm_spam_all)&&void ct_spam_all(e)})});
2
  //# sourceMappingURL=cleantalk-comments-checkspam.min.js.map
js/cleantalk-comments-checkspam.min.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cleantalk-comments-checkspam.min.js","sources":["cleantalk-comments-checkspam.js"],"sourcesContent":["// Printf for JS\nString.prototype.printf = function(){\n var formatted = this;\n for( var arg in arguments ) {\n\t\tvar before_formatted = formatted.substring(0, formatted.indexOf(\"%s\", 0));\n\t\tvar after_formatted = formatted.substring(formatted.indexOf(\"%s\", 0)+2, formatted.length);\n\t\tformatted = before_formatted + arguments[arg] + after_formatted;\n }\n return formatted;\n};\n\n// Flags\nvar ct_working = false,\n\tct_new_check = true,\n\tct_cooling_down_flag = false,\n\tct_close_animate = true,\n\tct_accurate_check = false,\n\tct_pause = false,\n\tct_prev_accurate = ctCommentsCheck.ct_prev_accurate,\n\tct_prev_from = ctCommentsCheck.ct_prev_from,\t\n\tct_prev_till = ctCommentsCheck.ct_prev_till;\n// Settings\nvar ct_cool_down_time = 90000,\n\tct_requests_counter = 0,\n\tct_max_requests = 60;\n// Variables\nvar ct_ajax_nonce = ctCommentsCheck.ct_ajax_nonce,\n\tct_comments_total = 0,\n\tct_comments_checked = 0,\n\tct_comments_spam = 0,\n\tct_comments_bad = 0,\n\tct_unchecked = 'unset',\n\tct_date_from = 0,\n\tct_date_till = 0;\n\nfunction animate_comment(to,id){\n\tif(ct_close_animate){\n\t\tif(to==0.3){\n\t\t\tjQuery('#comment-'+id).fadeTo(200,to,function(){\n\t\t\t\tanimate_comment(1,id)\n\t\t\t});\n\t\t}else{\n\t\t\tjQuery('#comment-'+id).fadeTo(200,to,function(){\n\t\t\t\tanimate_comment(0.3,id)\n\t\t\t});\n\t\t}\n\t}else{\n\t\tct_close_animate=true;\n\t}\n}\n\nfunction ct_clear_comments(){\n\n\tvar from = 0, till = 0;\n\tif(jQuery('#ct_allow_date_range').is(':checked')) {\n\t\tfrom = jQuery('#ct_date_range_from').val();\n\t\ttill = jQuery('#ct_date_range_till').val();\n\t}\n\tvar data = {\n\t\t'action' : 'ajax_clear_comments',\n\t\t'security' : ct_ajax_nonce,\n\t\t'from' : from,\n\t\t'till' : till\n\t};\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(msg){\n\t\t\tct_show_info();\n\t\t\tct_send_comments();\n\t\t}\n\t});\n}\n\n//Continues the check after cooldown time\n//Called by ct_send_users();\nfunction ct_cooling_down_toggle(){\n\tct_cooling_down_flag = false;\n\tct_send_comments();\n\tct_show_info();\n}\n\nfunction ct_send_comments(){\n\t\n\tif(ct_cooling_down_flag === true)\n\t\treturn;\n\t\n\tif(ct_requests_counter >= ct_max_requests){\n\t\tsetTimeout(ct_cooling_down_toggle, ct_cool_down_time);\n\t\tct_requests_counter = 0;\n\t\tct_cooling_down_flag = true;\n\t\treturn;\n\t}else{\n\t\tct_requests_counter++;\n\t}\n\t\n\tvar data = {\n\t\t'action': 'ajax_check_comments',\n\t\t'security': ct_ajax_nonce,\n\t\t'new_check': ct_new_check,\n\t\t'unchecked': ct_unchecked\n\t};\n\t\n\tif(ct_accurate_check)\n\t\tdata['accurate_check'] = true;\n\t\n\tif(ct_date_from && ct_date_till){\n\t\tdata['from'] = ct_date_from;\n\t\tdata['till'] = ct_date_till;\n\t}\n\t\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(msg){\n\t\t\t\n\t\t\tmsg = jQuery.parseJSON(msg);\n\t\t\t\n\t\t\tif(parseInt(msg.error)){\n\t\t\t\tct_working=false;\n\t\t\t\tif(!confirm(msg.error_message+\". Do you want to proceed?\")){\n\t\t\t\t\tvar new_href = 'edit-comments.php?page=ct_check_spam';\n\t\t\t\t\tif(ct_date_from != 0 && ct_date_till != 0)\n\t\t\t\t\t\tnew_href+='&from='+ct_date_from+'&till='+ct_date_till;\n\t\t\t\t\tlocation.href = new_href;\n\t\t\t\t}else\n\t\t\t\t\tct_send_comments();\n\t\t\t}else{\n\t\t\t\tct_new_check = false;\n\t\t\t\tif(parseInt(msg.end) == 1 || ct_pause === true){\n\t\t\t\t\tif(parseInt(msg.end) == 1)\n\t\t\t\t\t\tdocument.cookie = 'ct_paused_spam_check=0; path=/; samesite=lax';\n\t\t\t\t\tct_working=false;\n\t\t\t\t\tjQuery('#ct_working_message').hide();\n\t\t\t\t\tvar new_href = 'edit-comments.php?page=ct_check_spam';\n\t\t\t\t\tif(ct_date_from != 0 && ct_date_till != 0)\n\t\t\t\t\t\tnew_href+='&from='+ct_date_from+'&till='+ct_date_till;\n\t\t\t\t\tlocation.href = new_href;\n\t\t\t\t}else if(parseInt(msg.end) == 0){\n\t\t\t\t\tct_comments_checked += msg.checked;\n\t\t\t\t\tct_comments_spam += msg.spam;\n\t\t\t\t\tct_comments_bad += msg.bad;\n\t\t\t\t\tct_unchecked = ct_comments_total - ct_comments_checked - ct_comments_bad;\n\t\t\t\t\tvar status_string = String(ctCommentsCheck.ct_status_string);\n\t\t\t\t\tvar status_string = status_string.printf(ct_comments_checked, ct_comments_spam, ct_comments_bad);\n\t\t\t\t\tif(parseInt(ct_comments_spam) > 0)\n\t\t\t\t\t\tstatus_string += ctCommentsCheck.ct_status_string_warning;\n\t\t\t\t\tjQuery('#ct_checking_status').html(status_string);\n\t\t\t\t\tjQuery('#ct_error_message').hide();\n\t\t\t\t\t// If DB woks not properly\n\t\t\t\t\tif(+ct_comments_total < ct_comments_checked + ct_comments_bad){\n\t\t\t\t\t\tdocument.cookie = 'ct_comments_start_check=1; path=/; samesite=lax';\n\t\t\t\t\t\tdocument.cookie = 'ct_comments_safe_check=1; path=/; samesite=lax';\n\t\t\t\t\t\tlocation.href = 'edit-comments.php?page=ct_check_spam';\n\t\t\t\t\t}\n\t\t\t\t\tct_send_comments();\n\t\t\t\t}\n\t\t\t}\n\t\t},\n error: function(jqXHR, textStatus, errorThrown) {\n\t\t\tjQuery('#ct_error_message').show();\n\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\n\t\t\tjQuery('#cleantalk_js_func').html('Check comments');\n\t\t\tsetTimeout(ct_send_comments(), 3000); \n },\n timeout: 25000\n\t});\n}\nfunction ct_show_info(){\n\t\n\tif(ct_working){\n\t\t\n\t\tif(ct_cooling_down_flag == true){\n\t\t\tjQuery('#ct_cooling_notice').html('Waiting for API to cool down. (About a minute)');\n\t\t\tjQuery('#ct_cooling_notice').show();\n\t\t\treturn;\t\t\t\n\t\t}else{\n\t\t\tjQuery('#ct_cooling_notice').hide();\n\t\t}\n\t\t\n\t\tif(!ct_comments_total){\n\t\t\t\n\t\t\tvar data = {\n\t\t\t\t'action': 'ajax_info_comments',\n\t\t\t\t'security': ct_ajax_nonce\n\t\t\t};\n\t\t\t\n\t\t\tif(ct_date_from && ct_date_till){\n\t\t\t\tdata['from'] = ct_date_from;\n\t\t\t\tdata['till'] = ct_date_till;\n\t\t\t}\n\t\t\t\n\t\t\tjQuery.ajax({\n\t\t\t\ttype: \"POST\",\n\t\t\t\turl: ajaxurl,\n\t\t\t\tdata: data,\n\t\t\t\tsuccess: function(msg){\n\t\t\t\t\tmsg = jQuery.parseJSON(msg);\n\t\t\t\t\tjQuery('#ct_checking_status').html(msg.message);\n\t\t\t\t\tct_comments_total = msg.total;\n\t\t\t\t\tct_comments_spam = msg.spam;\n\t\t\t\t\tct_comments_checked = msg.checked;\n\t\t\t\t\tct_comments_bad = msg.bad;\n\t\t\t\t},\n\t\t\t\terror: function(jqXHR, textStatus, errorThrown) {\n\t\t\t\t\tjQuery('#ct_error_message').show();\n\t\t\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\n\t\t\t\t\tjQuery('#cleantalk_js_func').html('Check comments');\n\t\t\t\t\tsetTimeout(ct_show_info(), 3000); \n\t\t\t\t},\n\t\t\t\ttimeout: 15000\n\t\t\t});\n\t\t}\n\t}\n}\n\n// Function to toggle dependences\nfunction ct_toggle_depended(obj, secondary){\n\n secondary = secondary || null;\n\n\tvar depended = jQuery(obj.data('depended')),\n\t\tstate = obj.data('state');\n\t\t\n\tif(!state && !secondary){\n\t\tobj.data('state', true);\n\t\tdepended.removeProp('disabled');\n\t}else{\n\t\tobj.data('state', false);\n\t\tdepended.prop('disabled', true);\n\t\tdepended.removeProp('checked');\n\t\tif(depended.data('depended'))\n\t\t\tct_toggle_depended(depended, true);\n\t}\n}\n\nfunction ct_trash_all( e ) {\n\n\tvar data = {\n\t\t'action': 'ajax_trash_all',\n\t\t'security': ct_ajax_nonce\n\t};\n\n\tjQuery('.' + e.target.id).addClass('disabled');\n\tjQuery('.spinner').css('visibility', 'visible');\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function( msg ){\n\t\t\tif( msg > 0 ){\n\t\t\t\tjQuery('#cleantalk_comments_left').html(msg);\n\t\t\t\tct_trash_all( e );\n\t\t\t}else{\n\t\t\t\tjQuery('.' + e.target.id).removeClass('disabled');\n\t\t\t\tjQuery('.spinner').css('visibility', 'hidden');\n\t\t\t\tlocation.href='edit-comments.php?page=ct_check_spam';\n\t\t\t}\n\t\t},\n\t\terror: function(jqXHR, textStatus, errorThrown) {\n\t\t\tjQuery('#ct_error_message').show();\n\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\n\t\t\tjQuery('#cleantalk_js_func').html('Check comments');\n\t\t\tsetTimeout(ct_trash_all( e ), 3000);\n\t\t},\n\t\ttimeout: 25000\n\t});\n\n}\n\nfunction ct_spam_all( e ) {\n\n\tvar data = {\n\t\t'action': 'ajax_spam_all',\n\t\t'security': ct_ajax_nonce\n\t};\n\n\tjQuery('.' + e.target.id).addClass('disabled');\n\tjQuery('.spinner').css('visibility', 'visible');\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function( msg ){\n\t\t\tif( msg > 0 ){\n\t\t\t\tjQuery('#cleantalk_comments_left').html(msg);\n\t\t\t\tct_spam_all( e );\n\t\t\t}else{\n\t\t\t\tjQuery('.' + e.target.id).removeClass('disabled');\n\t\t\t\tjQuery('.spinner').css('visibility', 'hidden');\n\t\t\t\tlocation.href='edit-comments.php?page=ct_check_spam';\n\t\t\t}\n\t\t},\n\t\terror: function(jqXHR, textStatus, errorThrown) {\n\t\t\tjQuery('#ct_error_message').show();\n\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\n\t\t\tjQuery('#cleantalk_js_func').html('Check comments');\n\t\t\tsetTimeout(ct_spam_all( e ), 3000);\n\t\t},\n\t\ttimeout: 25000\n\t});\n\n}\n\njQuery(document).ready(function(){\n\t\n\t// Prev check parameters\n\tif(ct_prev_accurate){\n\t\tjQuery(\"#ct_accurate_check\").prop('checked', true);\n\t}\n\tif(ct_prev_from){\n\t\tjQuery(\"#ct_allow_date_range\").prop('checked', true).data('state', true);\n\t\tjQuery(\"#ct_date_range_from\").removeProp('disabled').val(ct_prev_from);\n\t\tjQuery(\"#ct_date_range_till\").removeProp('disabled').val(ct_prev_till);\n\t}\n\t\n\t// Toggle dependences\n\tjQuery(\"#ct_allow_date_range\").on('change', function(){\n\t\tdocument.cookie = 'ct_spam_dates_from='+ jQuery('#ct_date_range_from').val() +'; path=/; samesite=lax';\n\t\tdocument.cookie = 'ct_spam_dates_till='+ jQuery('#ct_date_range_till').val() +'; path=/; samesite=lax';\n\t\tif( this.checked ) {\n\t\t\tdocument.cookie = 'ct_spam_dates_allowed=1; path=/; samesite=lax';\n\t\t\tjQuery('.ct_date').prop('checked', true).attr('disabled',false);\n\t\t} else {\n\t\t\tdocument.cookie = 'ct_spam_dates_allowed=0; path=/; samesite=lax';\n\t\t\tjQuery('.ct_date').prop('disabled', true).attr('disabled',true);\n\t\t}\n\t});\n\n jQuery.datepicker.setDefaults(jQuery.datepicker.regional['en']);\n\tvar dates = jQuery('#ct_date_range_from, #ct_date_range_till').datepicker(\n\t\t{\n\t\t\tdateFormat: 'M d yy',\n\t\t\tmaxDate:\"+0D\",\n\t\t\tchangeMonth:true,\n\t\t\tchangeYear:true,\n\t\t\tshowAnim: 'slideDown',\n\t\t\tonSelect: function(selectedDate){\n\t\t\tvar option = this.id == \"ct_date_range_from\" ? \"minDate\" : \"maxDate\",\n\t\t\t\tinstance = jQuery( this ).data( \"datepicker\" ),\n\t\t\t\tdate = jQuery.datepicker.parseDate(\n\t\t\t\t\tinstance.settings.dateFormat || jQuery.datepicker._defaults.dateFormat,\n\t\t\t\t\tselectedDate, instance.settings);\n\t\t\t\tdates.not(this).datepicker(\"option\", option, date);\n\t\t\t\tdocument.cookie = 'ct_spam_dates_from='+ jQuery('#ct_date_range_from').val() +'; path=/; samesite=lax';\n\t\t\t\tdocument.cookie = 'ct_spam_dates_till='+ jQuery('#ct_date_range_till').val() +'; path=/; samesite=lax';\n\t\t\t}\n\t\t}\n\t);\n\t\n\tfunction ct_start_check(continue_check){\n\n continue_check = continue_check || null;\n\n\t\tif(jQuery('#ct_allow_date_range').is(':checked')){\n\t\t\t\n\t\t\tct_date_from = jQuery('#ct_date_range_from').val();\n\t\t\tct_date_till = jQuery('#ct_date_range_till').val();\n\t\t\t\t\t\t\n\t\t\tif(!(ct_date_from != '' && ct_date_till != '')){\n\t\t\t\talert('Please, specify a date range.');\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(jQuery('#ct_accurate_check').is(':checked')){\n\t\t\tct_accurate_check = true;\n\t\t}\n\t\t\n\t\tjQuery('.ct_to_hide').hide();\n\t\tjQuery('#ct_working_message').show();\n\t\tjQuery('#ct_preloader').show();\n\t\tjQuery('#ct_pause').show();\n\n\t\tct_working=true;\n\t\t\n\t\tif(continue_check){\n\t\t\tct_show_info();\n\t\t\tct_send_comments();\n\t\t}else\n\t\t\tct_clear_comments();\n\t\t\n\t}\n\t\n\t// Check comments\n\tjQuery(\"#ct_check_spam_button\").click(function(){\n\t\tdocument.cookie = 'ct_paused_spam_check=0; path=/; samesite=lax';\n\t\tct_start_check(false);\n\t});\n\tjQuery(\"#ct_proceed_check_button\").click(function(){\n\t\tct_start_check(true);\n\t});\n\n\t// Pause the check\n\tjQuery('#ct_pause').on('click', function(){\n\t\tct_pause = true;\n\t\tvar ct_check = {\n\t\t\t'accurate': ct_accurate_check,\n\t\t\t'from' : ct_date_from,\n\t\t\t'till' : ct_date_till\n\t\t};\n\t\tdocument.cookie = 'ct_paused_spam_check=' + JSON.stringify(ct_check) + '; path=/; samesite=lax';\n\t});\n\n\n\tif(ctCommentsCheck.start === '1'){\n\t\tdocument.cookie = 'ct_comments_start_check=0; expires=' + new Date(0).toUTCString() + '; path=/; samesite=lax';\n\t\tjQuery('#ct_check_spam_button').click();\t\n\t}\n\n\t// Delete all spam comments\n\tjQuery(\".ct_trash_all\").click(function( e ){\n\n\t\tif (!confirm(ctCommentsCheck.ct_confirm_trash_all))\n\t\t\treturn false;\n\n\t\tct_trash_all( e );\n\n\t});\n\n\t// Mark as spam all spam comments\n\tjQuery(\".ct_spam_all\").click(function( e ){\n\n\t\tif (!confirm(ctCommentsCheck.ct_confirm_spam_all))\n\t\t\treturn false;\n\n\t\tct_spam_all( e );\n\n\t});\n\n});"],"names":["ct_working","String","prototype","printf","formatted","this","arg","arguments","before_formatted","substring","indexOf","after_formatted","length","ct_new_check","ct_cooling_down_flag","ct_close_animate","ct_accurate_check","ct_pause","ct_prev_accurate","ctCommentsCheck","ct_prev_from","ct_prev_till","ct_cool_down_time","ct_requests_counter","ct_max_requests","ct_ajax_nonce","ct_comments_total","ct_comments_checked","ct_comments_spam","ct_comments_bad","ct_unchecked","ct_date_from","ct_date_till","animate_comment","to","id","jQuery","fadeTo","ct_clear_comments","from","till","is","val","data","action","security","ajax","type","url","ajaxurl","success","msg","ct_show_info","ct_send_comments","ct_cooling_down_toggle","setTimeout","new_check","unchecked","new_href","status_string","parseJSON","parseInt","error","confirm","error_message","location","href","end","document","cookie","hide","checked","spam","bad","ct_status_string","ct_status_string_warning","html","jqXHR","textStatus","errorThrown","show","timeout","message","total","ct_toggle_depended","obj","secondary","depended","prop","removeProp","ct_trash_all","e","target","addClass","css","removeClass","ct_spam_all","ready","on","attr","datepicker","setDefaults","regional","dates","dateFormat","maxDate","changeMonth","changeYear","showAnim","onSelect","selectedDate","option","instance","date","parseDate","settings","_defaults","not","ct_start_check","continue_check","alert","click","ct_check","accurate","JSON","stringify","start","Date","toUTCString","ct_confirm_trash_all","ct_confirm_spam_all"],"mappings":"AAYA,IAAIA,aAXJC,OAAOC,UAAUC,OAAS,WACtB,IAAIC,EAAYC,KAChB,IAAK,IAAIC,KAAOC,UAClB,IAAIC,EAAmBJ,EAAUK,UAAU,EAAGL,EAAUM,QAAQ,KAAM,IAClEC,EAAmBP,EAAUK,UAAUL,EAAUM,QAAQ,KAAM,GAAG,EAAGN,EAAUQ,QACnFR,EAAYI,EAAmBD,UAAUD,GAAOK,EAE9C,OAAOP,IAKVS,cAAe,EACfC,sBAAuB,EACvBC,kBAAmB,EACnBC,mBAAoB,EACpBC,UAAW,EACXC,iBAAmBC,gBAAgBD,iBACnCE,aAAeD,gBAAgBC,aAC/BC,aAAeF,gBAAgBE,aAE5BC,kBAAoB,IACvBC,oBAAsB,EACtBC,gBAAkB,GAEfC,cAAgBN,gBAAgBM,cACnCC,kBAAoB,EACpBC,oBAAsB,EACtBC,iBAAmB,EACnBC,gBAAkB,EAClBC,aAAe,QACfC,aAAe,EACfC,aAAe,EAEhB,SAASC,gBAAgBC,EAAGC,GACxBpB,iBACK,IAAJmB,EACFE,OAAO,YAAYD,GAAIE,OAAO,IAAIH,EAAG,WACpCD,gBAAgB,EAAEE,KAGnBC,OAAO,YAAYD,GAAIE,OAAO,IAAIH,EAAG,WACpCD,gBAAgB,GAAIE,KAItBpB,kBAAiB,EAInB,SAASuB,oBAER,IAAIC,EAAO,EAAGC,EAAO,EAClBJ,OAAO,wBAAwBK,GAAG,cACpCF,EAAOH,OAA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sBAAuBjC,OAAO,uBAAuBM,MAAO,4BAKjF,SAAS4E,EAAeC,GAEjBA,EAAiBA,GAAkB,KAEtCnF,OAAO,wBAAwBK,GAAG,cAEpCV,aAAeK,OAAO,uBAAuBM,MAC7CV,aAAeI,OAAO,uBAAuBM,MAExB,IAAhBX,cAAsC,IAAhBC,cAC1BwF,MAAM,kCAKLpF,OAAO,sBAAsBK,GAAG,cAClCzB,mBAAoB,GAGrBoB,OAAO,eAAekC,OACtBlC,OAAO,uBAAuB4C,OAC9B5C,OAAO,iBAAiB4C,OACxB5C,OAAO,aAAa4C,OAEpBhF,YAAW,EAERuH,GACFnE,eACAC,oBAEAf,qBAKFF,OAAO,yBAAyBqF,MAAM,WAErCH,IADAlD,SAASC,OAAS,mDAGnBjC,OAAO,4BAA4BqF,MAAM,WACxCH,GAAe,KAIhBlF,OAAO,aAAa8D,GAAG,QAAS,WAC/BjF,UAAW,EACX,IAAIyG,EAAW,CACdC,SAAY3G,kBACZuB,KAAYR,aACZS,KAAYR,cAEboC,SAASC,OAAS,wBAA0BuD,KAAKC,UAAUH,GAAY,2BAI3C,MAA1BvG,gBAAgB2G,QAClB1D,SAASC,OAAS,sCAAwC,IAAI0D,KAAK,GAAGC,cAAgB,yBACtF5F,OAAO,yBAAyBqF,SAIjCrF,OAAO,iBAAiBqF,MAAM,SAAU9B,GAEvC,QAAK5B,QAAQ5C,gBAAgB8G,4BAG7BvC,aAAcC,KAKfvD,OAAO,gBAAgBqF,MAAM,SAAU9B,GAEtC,QAAK5B,QAAQ5C,gBAAgB+G,2BAG7BlC,YAAaL"}
1
+ {"version":3,"file":"cleantalk-comments-checkspam.min.js","sources":["cleantalk-comments-checkspam.js"],"sourcesContent":["// Printf for JS\nString.prototype.printf = function(){\n var formatted = this;\n for( var arg in arguments ) {\n\t\tvar before_formatted = formatted.substring(0, formatted.indexOf(\"%s\", 0));\n\t\tvar after_formatted = formatted.substring(formatted.indexOf(\"%s\", 0)+2, formatted.length);\n\t\tformatted = before_formatted + arguments[arg] + after_formatted;\n }\n return formatted;\n};\n\n// Flags\nvar ct_working = false,\n\tct_new_check = true,\n\tct_cooling_down_flag = false,\n\tct_close_animate = true,\n\tct_accurate_check = false,\n\tct_pause = false,\n\tct_prev_accurate = ctCommentsCheck.ct_prev_accurate,\n\tct_prev_from = ctCommentsCheck.ct_prev_from,\t\n\tct_prev_till = ctCommentsCheck.ct_prev_till;\n// Settings\nvar ct_cool_down_time = 90000,\n\tct_requests_counter = 0,\n\tct_max_requests = 60;\n// Variables\nvar ct_ajax_nonce = ctCommentsCheck.ct_ajax_nonce,\n\tct_comments_total = 0,\n\tct_comments_checked = 0,\n\tct_comments_spam = 0,\n\tct_comments_bad = 0,\n\tct_unchecked = 'unset',\n\tct_date_from = 0,\n\tct_date_till = 0;\n\nfunction animate_comment(to,id){\n\tif(ct_close_animate){\n\t\tif(to==0.3){\n\t\t\tjQuery('#comment-'+id).fadeTo(200,to,function(){\n\t\t\t\tanimate_comment(1,id)\n\t\t\t});\n\t\t}else{\n\t\t\tjQuery('#comment-'+id).fadeTo(200,to,function(){\n\t\t\t\tanimate_comment(0.3,id)\n\t\t\t});\n\t\t}\n\t}else{\n\t\tct_close_animate=true;\n\t}\n}\n\nfunction ct_clear_comments(){\n\n\tvar from = 0, till = 0;\n\tif(jQuery('#ct_allow_date_range').is(':checked')) {\n\t\tfrom = jQuery('#ct_date_range_from').val();\n\t\ttill = jQuery('#ct_date_range_till').val();\n\t}\n\tvar ctSecure = location.protocol === 'https:' ? '; secure' : '';\n\tdocument.cookie = 'apbct_check_comments_offset' + \"=\" + 0 + \"; path=/; samesite=lax\" + ctSecure;\n\t\n\tvar data = {\n\t\t'action' : 'ajax_clear_comments',\n\t\t'security' : ct_ajax_nonce,\n\t\t'from' : from,\n\t\t'till' : till\n\t};\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(msg){\n\t\t\tct_show_info();\n\t\t\tct_send_comments();\n\t\t}\n\t});\n}\n\n//Continues the check after cooldown time\n//Called by ct_send_users();\nfunction ct_cooling_down_toggle(){\n\tct_cooling_down_flag = false;\n\tct_send_comments();\n\tct_show_info();\n}\n\nfunction ct_send_comments(){\n\t\n\tif(ct_cooling_down_flag === true)\n\t\treturn;\n\t\n\tif(ct_requests_counter >= ct_max_requests){\n\t\tsetTimeout(ct_cooling_down_toggle, ct_cool_down_time);\n\t\tct_requests_counter = 0;\n\t\tct_cooling_down_flag = true;\n\t\treturn;\n\t}else{\n\t\tct_requests_counter++;\n\t}\n\t\n\tvar data = {\n\t\t'action': 'ajax_check_comments',\n\t\t'security': ct_ajax_nonce,\n\t\t'new_check': ct_new_check,\n\t\t'unchecked': ct_unchecked,\n\t\t'offset' : Number(ctGetCookie('apbct_check_comments_offset'))\n\t};\n\t\n\tif(ct_accurate_check)\n\t\tdata['accurate_check'] = true;\n\t\n\tif(ct_date_from && ct_date_till){\n\t\tdata['from'] = ct_date_from;\n\t\tdata['till'] = ct_date_till;\n\t}\n\t\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(msg){\n\t\t\t\n\t\t\tmsg = jQuery.parseJSON(msg);\n\t\t\t\n\t\t\tif(parseInt(msg.error)){\n\t\t\t\tct_working=false;\n\t\t\t\tif(!confirm(msg.error_message+\". Do you want to proceed?\")){\n\t\t\t\t\tvar new_href = 'edit-comments.php?page=ct_check_spam';\n\t\t\t\t\tif(ct_date_from != 0 && ct_date_till != 0)\n\t\t\t\t\t\tnew_href+='&from='+ct_date_from+'&till='+ct_date_till;\n\t\t\t\t\tlocation.href = new_href;\n\t\t\t\t}else\n\t\t\t\t\tct_send_comments();\n\t\t\t}else{\n\t\t\t\tct_new_check = false;\n\t\t\t\tif(parseInt(msg.end) == 1 || ct_pause === true){\n\t\t\t\t\tif(parseInt(msg.end) == 1)\n\t\t\t\t\t\tdocument.cookie = 'ct_paused_spam_check=0; path=/; samesite=lax';\n\t\t\t\t\tct_working=false;\n\t\t\t\t\tjQuery('#ct_working_message').hide();\n\t\t\t\t\tvar new_href = 'edit-comments.php?page=ct_check_spam';\n\t\t\t\t\tif(ct_date_from != 0 && ct_date_till != 0)\n\t\t\t\t\t\tnew_href+='&from='+ct_date_from+'&till='+ct_date_till;\n\t\t\t\t\tlocation.href = new_href;\n\t\t\t\t}else if(parseInt(msg.end) == 0){\n\t\t\t\t\tct_comments_checked += msg.checked;\n\t\t\t\t\tct_comments_spam += msg.spam;\n\t\t\t\t\tct_comments_bad += msg.bad;\n\t\t\t\t\tct_unchecked = ct_comments_total - ct_comments_checked - ct_comments_bad;\n\t\t\t\t\tvar status_string = String(ctCommentsCheck.ct_status_string);\n\t\t\t\t\tvar status_string = status_string.printf(ct_comments_checked, ct_comments_spam, ct_comments_bad);\n\t\t\t\t\tif(parseInt(ct_comments_spam) > 0)\n\t\t\t\t\t\tstatus_string += ctCommentsCheck.ct_status_string_warning;\n\t\t\t\t\tjQuery('#ct_checking_status').html(status_string);\n\t\t\t\t\tjQuery('#ct_error_message').hide();\n\t\t\t\t\t// If DB woks not properly\n\t\t\t\t\tif(+ct_comments_total < ct_comments_checked + ct_comments_bad){\n\t\t\t\t\t\tdocument.cookie = 'ct_comments_start_check=1; path=/; samesite=lax';\n\t\t\t\t\t\tlocation.href = 'edit-comments.php?page=ct_check_spam';\n\t\t\t\t\t}\n\n\t\t\t\t\tvar offset = Number(ctGetCookie('apbct_check_comments_offset')) + 100;\n\t\t\t\t\tdocument.cookie = 'apbct_check_comments_offset' + \"=\" + offset + \"; path=/\";\n\t\t\t\t\t\n\t\t\t\t\tct_send_comments();\n\t\t\t\t}\n\t\t\t}\n\t\t},\n error: function(jqXHR, textStatus, errorThrown) {\n\t\t\tjQuery('#ct_error_message').show();\n\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\n\t\t\tjQuery('#cleantalk_js_func').html('Check comments');\n\t\t\tsetTimeout(ct_send_comments(), 3000); \n },\n timeout: 25000\n\t});\n}\nfunction ct_show_info(){\n\t\n\tif(ct_working){\n\t\t\n\t\tif(ct_cooling_down_flag == true){\n\t\t\tjQuery('#ct_cooling_notice').html('Waiting for API to cool down. (About a minute)');\n\t\t\tjQuery('#ct_cooling_notice').show();\n\t\t\treturn;\t\t\t\n\t\t}else{\n\t\t\tjQuery('#ct_cooling_notice').hide();\n\t\t}\n\t\t\n\t\tif(!ct_comments_total){\n\t\t\t\n\t\t\tvar data = {\n\t\t\t\t'action': 'ajax_info_comments',\n\t\t\t\t'security': ct_ajax_nonce\n\t\t\t};\n\t\t\t\n\t\t\tif(ct_date_from && ct_date_till){\n\t\t\t\tdata['from'] = ct_date_from;\n\t\t\t\tdata['till'] = ct_date_till;\n\t\t\t}\n\t\t\t\n\t\t\tjQuery.ajax({\n\t\t\t\ttype: \"POST\",\n\t\t\t\turl: ajaxurl,\n\t\t\t\tdata: data,\n\t\t\t\tsuccess: function(msg){\n\t\t\t\t\tmsg = jQuery.parseJSON(msg);\n\t\t\t\t\tjQuery('#ct_checking_status').html(msg.message);\n\t\t\t\t\tct_comments_total = msg.total;\n\t\t\t\t\tct_comments_spam = msg.spam;\n\t\t\t\t\tct_comments_checked = msg.checked;\n\t\t\t\t\tct_comments_bad = msg.bad;\n\t\t\t\t},\n\t\t\t\terror: function(jqXHR, textStatus, errorThrown) {\n\t\t\t\t\tjQuery('#ct_error_message').show();\n\t\t\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\n\t\t\t\t\tjQuery('#cleantalk_js_func').html('Check comments');\n\t\t\t\t\tsetTimeout(ct_show_info(), 3000); \n\t\t\t\t},\n\t\t\t\ttimeout: 15000\n\t\t\t});\n\t\t}\n\t}\n}\n\n// Function to toggle dependences\nfunction ct_toggle_depended(obj, secondary){\n\n secondary = secondary || null;\n\n\tvar depended = jQuery(obj.data('depended')),\n\t\tstate = obj.data('state');\n\t\t\n\tif(!state && !secondary){\n\t\tobj.data('state', true);\n\t\tdepended.removeProp('disabled');\n\t}else{\n\t\tobj.data('state', false);\n\t\tdepended.prop('disabled', true);\n\t\tdepended.removeProp('checked');\n\t\tif(depended.data('depended'))\n\t\t\tct_toggle_depended(depended, true);\n\t}\n}\n\nfunction ct_trash_all( e ) {\n\n\tvar data = {\n\t\t'action': 'ajax_trash_all',\n\t\t'security': ct_ajax_nonce\n\t};\n\n\tjQuery('.' + e.target.id).addClass('disabled');\n\tjQuery('.spinner').css('visibility', 'visible');\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function( msg ){\n\t\t\tif( msg > 0 ){\n\t\t\t\tjQuery('#cleantalk_comments_left').html(msg);\n\t\t\t\tct_trash_all( e );\n\t\t\t}else{\n\t\t\t\tjQuery('.' + e.target.id).removeClass('disabled');\n\t\t\t\tjQuery('.spinner').css('visibility', 'hidden');\n\t\t\t\tlocation.href='edit-comments.php?page=ct_check_spam';\n\t\t\t}\n\t\t},\n\t\terror: function(jqXHR, textStatus, errorThrown) {\n\t\t\tjQuery('#ct_error_message').show();\n\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\n\t\t\tjQuery('#cleantalk_js_func').html('Check comments');\n\t\t\tsetTimeout(ct_trash_all( e ), 3000);\n\t\t},\n\t\ttimeout: 25000\n\t});\n\n}\n\nfunction ct_spam_all( e ) {\n\n\tvar data = {\n\t\t'action': 'ajax_spam_all',\n\t\t'security': ct_ajax_nonce\n\t};\n\n\tjQuery('.' + e.target.id).addClass('disabled');\n\tjQuery('.spinner').css('visibility', 'visible');\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function( msg ){\n\t\t\tif( msg > 0 ){\n\t\t\t\tjQuery('#cleantalk_comments_left').html(msg);\n\t\t\t\tct_spam_all( e );\n\t\t\t}else{\n\t\t\t\tjQuery('.' + e.target.id).removeClass('disabled');\n\t\t\t\tjQuery('.spinner').css('visibility', 'hidden');\n\t\t\t\tlocation.href='edit-comments.php?page=ct_check_spam';\n\t\t\t}\n\t\t},\n\t\terror: function(jqXHR, textStatus, errorThrown) {\n\t\t\tjQuery('#ct_error_message').show();\n\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\n\t\t\tjQuery('#cleantalk_js_func').html('Check comments');\n\t\t\tsetTimeout(ct_spam_all( e ), 3000);\n\t\t},\n\t\ttimeout: 25000\n\t});\n\n}\n\njQuery(document).ready(function(){\n\t\n\t// Prev check parameters\n\tif(ct_prev_accurate){\n\t\tjQuery(\"#ct_accurate_check\").prop('checked', true);\n\t}\n\tif(ct_prev_from){\n\t\tjQuery(\"#ct_allow_date_range\").prop('checked', true).data('state', true);\n\t\tjQuery(\"#ct_date_range_from\").removeProp('disabled').val(ct_prev_from);\n\t\tjQuery(\"#ct_date_range_till\").removeProp('disabled').val(ct_prev_till);\n\t}\n\t\n\t// Toggle dependences\n\tjQuery(\"#ct_allow_date_range\").on('change', function(){\n\t\tdocument.cookie = 'ct_spam_dates_from='+ jQuery('#ct_date_range_from').val() +'; path=/; samesite=lax';\n\t\tdocument.cookie = 'ct_spam_dates_till='+ jQuery('#ct_date_range_till').val() +'; path=/; samesite=lax';\n\t\tif( this.checked ) {\n\t\t\tdocument.cookie = 'ct_spam_dates_allowed=1; path=/; samesite=lax';\n\t\t\tjQuery('.ct_date').prop('checked', true).attr('disabled',false);\n\t\t} else {\n\t\t\tdocument.cookie = 'ct_spam_dates_allowed=0; path=/; samesite=lax';\n\t\t\tjQuery('.ct_date').prop('disabled', true).attr('disabled',true);\n\t\t}\n\t});\n\n jQuery.datepicker.setDefaults(jQuery.datepicker.regional['en']);\n\tvar dates = jQuery('#ct_date_range_from, #ct_date_range_till').datepicker(\n\t\t{\n\t\t\tdateFormat: 'M d yy',\n\t\t\tmaxDate:\"+0D\",\n\t\t\tchangeMonth:true,\n\t\t\tchangeYear:true,\n\t\t\tshowAnim: 'slideDown',\n\t\t\tonSelect: function(selectedDate){\n\t\t\tvar option = this.id == \"ct_date_range_from\" ? \"minDate\" : \"maxDate\",\n\t\t\t\tinstance = jQuery( this ).data( \"datepicker\" ),\n\t\t\t\tdate = jQuery.datepicker.parseDate(\n\t\t\t\t\tinstance.settings.dateFormat || jQuery.datepicker._defaults.dateFormat,\n\t\t\t\t\tselectedDate, instance.settings);\n\t\t\t\tdates.not(this).datepicker(\"option\", option, date);\n\t\t\t\tdocument.cookie = 'ct_spam_dates_from='+ jQuery('#ct_date_range_from').val() +'; path=/; samesite=lax';\n\t\t\t\tdocument.cookie = 'ct_spam_dates_till='+ jQuery('#ct_date_range_till').val() +'; path=/; samesite=lax';\n\t\t\t}\n\t\t}\n\t);\n\t\n\tfunction ct_start_check(continue_check){\n\n continue_check = continue_check || null;\n\n\t\tif(jQuery('#ct_allow_date_range').is(':checked')){\n\t\t\t\n\t\t\tct_date_from = jQuery('#ct_date_range_from').val();\n\t\t\tct_date_till = jQuery('#ct_date_range_till').val();\n\t\t\t\t\t\t\n\t\t\tif(!(ct_date_from != '' && ct_date_till != '')){\n\t\t\t\talert('Please, specify a date range.');\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(jQuery('#ct_accurate_check').is(':checked')){\n\t\t\tct_accurate_check = true;\n\t\t}\n\t\t\n\t\tjQuery('.ct_to_hide').hide();\n\t\tjQuery('#ct_working_message').show();\n\t\tjQuery('#ct_preloader').show();\n\t\tjQuery('#ct_pause').show();\n\n\t\tct_working=true;\n\t\t\n\t\tif(continue_check){\n\t\t\tct_show_info();\n\t\t\tct_send_comments();\n\t\t}else\n\t\t\tct_clear_comments();\n\t\t\n\t}\n\t\n\t// Check comments\n\tjQuery(\"#ct_check_spam_button\").click(function(){\n\t\tdocument.cookie = 'ct_paused_spam_check=0; path=/; samesite=lax';\n\t\tct_start_check(false);\n\t});\n\tjQuery(\"#ct_proceed_check_button\").click(function(){\n\t\tct_start_check(true);\n\t});\n\n\t// Pause the check\n\tjQuery('#ct_pause').on('click', function(){\n\t\tct_pause = true;\n\t\tvar ct_check = {\n\t\t\t'accurate': ct_accurate_check,\n\t\t\t'from' : ct_date_from,\n\t\t\t'till' : ct_date_till\n\t\t};\n\t\tdocument.cookie = 'ct_paused_spam_check=' + JSON.stringify(ct_check) + '; path=/; samesite=lax';\n\t});\n\n\n\tif(ctCommentsCheck.start === '1'){\n\t\tdocument.cookie = 'ct_comments_start_check=0; expires=' + new Date(0).toUTCString() + '; path=/; samesite=lax';\n\t\tjQuery('#ct_check_spam_button').click();\t\n\t}\n\n\t// Delete all spam comments\n\tjQuery(\".ct_trash_all\").click(function( e ){\n\n\t\tif (!confirm(ctCommentsCheck.ct_confirm_trash_all))\n\t\t\treturn false;\n\n\t\tct_trash_all( e );\n\n\t});\n\n\t// Mark as spam all spam comments\n\tjQuery(\".ct_spam_all\").click(function( e ){\n\n\t\tif (!confirm(ctCommentsCheck.ct_confirm_spam_all))\n\t\t\treturn false;\n\n\t\tct_spam_all( e );\n\n\t});\n\n});\n\n\n/**\n * Get cookie by name\n * @param name\n * @returns {string|undefined}\n */\nfunction ctGetCookie(name) {\n\tlet matches = document.cookie.match(new RegExp(\n\t\t\"(?:^|; )\" + name.replace(/([\\.$?*|{}\\(\\)\\[\\]\\\\\\/\\+^])/g, '\\\\$1') + \"=([^;]*)\"\n\t));\n\treturn matches ? decodeURIComponent(matches[1]) : undefined;\n}"],"names":["ct_working","String","prototype","printf","arg","formatted","this","arguments","before_formatted","substring","indexOf","after_formatted","length","ct_new_check","ct_cooling_down_flag","ct_close_animate","ct_accurate_check","ct_pause","ct_prev_accurate","ctCommentsCheck","ct_prev_from","ct_prev_till","ct_cool_down_time","ct_requests_counter","ct_max_requests","ct_ajax_nonce","ct_comments_total","ct_comments_checked","ct_comments_spam","ct_comments_bad","ct_unchecked","ct_date_from","ct_date_till","animate_comment","to","id","jQuery","fadeTo","ct_clear_comments","from","till","is","val","ctSecure","location","protocol","document","cookie","ajax","type","url","ajaxurl","data","action","security","success","msg","ct_show_info","ct_send_comments","ct_cooling_down_toggle","setTimeout","new_check","unchecked","offset","Number","ctGetCookie","new_href","parseJSON","parseInt","error","confirm","error_message","href","end","hide","checked","spam","bad","status_string","ct_status_string","ct_status_string_warning","html","jqXHR","textStatus","errorThrown","show","timeout","message","total","ct_toggle_depended","obj","secondary","depended","prop","removeProp","ct_trash_all","e","target","addClass","css","removeClass","ct_spam_all","name","matches","match","RegExp","replace","decodeURIComponent","undefined","ready","on","attr","datepicker","setDefaults","regional","dates","dateFormat","maxDate","changeMonth","changeYear","showAnim","onSelect","selectedDate","option","instance","date","parseDate","settings","_defaults","not","ct_start_check","continue_check","alert","click","ct_check","accurate","JSON","stringify","start","Date","toUTCString","ct_confirm_trash_all","ct_confirm_spam_all"],"mappings":"AAYA,IAAIA,aAXJC,OAAOC,UAAUC,OAAS,WACtB,IACSC,EADLC,EAAYC,KAChB,IAASF,KAAOG,UAClB,IAAIC,EAAmBH,EAAUI,UAAU,EAAGJ,EAAUK,QAAQ,KAAM,IAClEC,EAAmBN,EAAUI,UAAUJ,EAAUK,QAAQ,KAAM,GAAG,EAAGL,EAAUO,QACnFP,EAAYG,EAAmBD,UAAUH,GAAOO,EAE9C,OAAON,IAKVQ,cAAe,EACfC,sBAAuB,EACvBC,kBAAmB,EACnBC,mBAAoB,EACpBC,UAAW,EACXC,iBAAmBC,gBAAgBD,iBACnCE,aAAeD,gBAAgBC,aAC/BC,aAAeF,gBAAgBE,aAE5BC,kBAAoB,IACvBC,oBAAsB,EACtBC,gBAAkB,GAEfC,cAAgBN,gBAAgBM,cACnCC,kBAAoB,EACpBC,oBAAsB,EACtBC,iBAAmB,EACnBC,gBAAkB,EAClBC,aAAe,QACfC,aAAe,EACfC,aAAe,EAEhB,SAASC,gBAAgBC,EAAGC,GACxBpB,iBACK,IAAJmB,EACFE,OAAO,YAAYD,GAAIE,OAAO,IAAIH,EAAG,WACpCD,gBAAgB,EAAEE,KAGnBC,OAAO,YAAYD,GAAIE,OAAO,IAAIH,EAAG,WACpCD,gB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SAAUrC,GAEvC,QAAK1B,QAAQnD,gBAAgB0H,4BAG7B9C,aAAcC,KAKf5D,OAAO,gBAAgBiG,MAAM,SAAUrC,GAEtC,QAAK1B,QAAQnD,gBAAgB2H,2BAG7BzC,YAAaL"}
js/cleantalk_collect_details.min.js CHANGED
@@ -1,2 +1,2 @@
1
- var ctCollectDetails;function ct_getCookie(e){var t=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return t?decodeURIComponent(t[1]):void 0}function ct_setCookie(t,i){var e,n;return ctNocache.set_cookies_flag&&(e="https:"===location.protocol?"; secure":"",document.cookie=t+" =; expires=Thu, 01 Jan 1970 00:00:01 GMT; path = /; samesite=lax"+e,document.cookie=t+" =; expires=Thu, 01 Jan 1970 00:00:01 GMT; samesite=lax"+e,(n=new Date).setDate(n.getDate()+1),setTimeout(function(){var e="https:"===location.protocol?"; secure":"";document.cookie=t+"="+i+"; expires="+n.toUTCString()+"; path = /; samesite=lax"+e},500)),null}if(void 0===ctCollectDetails&&(ctCollectDetails={set_cookies_flag:!0}),Date.now||(Date.now=function(){return(new Date).getTime()}),void 0===ct_collect_details){var ct_collect_details=!0,cleantalk_user_info={},cleantalk_screen_info={};for(var prop in screen)navigator[prop]instanceof Object||""===screen[prop]||(cleantalk_screen_info[prop]=screen[prop]);cleantalk_user_info.screen=cleantalk_screen_info;for(var prev,cleantalk_plugins=Array(),cnt=0,i=0;i<navigator.plugins.length;i++){var plugin=navigator.plugins[i];prev!=(plugin=plugin.name+" "+(plugin.version||""))&&(cleantalk_plugins[cnt]=plugin,cnt++,prev=plugin)}cleantalk_user_info.plugins=cleantalk_plugins,cleantalk_user_info.timezone_offset=-(new Date).getTimezoneOffset()/60,cleantalk_user_info.datetime=Math.round((new Date).getTime()/1e3),cleantalk_user_info.browser_x=document.documentElement.clientWidth,cleantalk_user_info.browser_y=document.documentElement.clientHeight;var ua=navigator.userAgent.toLowerCase(),flashInstalled=0;if(void 0!==navigator.plugins&&"object"==typeof navigator.plugins["Shockwave Flash"])flashInstalled=1;else if(void 0!==window.ActiveXObject)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash")&&(flashInstalled=1)}catch(e){}cleantalk_user_info.is_flash=flashInstalled,isVisitedMain=-1,location.href!="http://"+location.hostname+"/"&&location.href!="https://"+location.hostname+"/"||(isVisitedMain=1,setTimeout(function(){ct_setCookie("ct_visited_main","1")},1500)),ct_visited_main=ct_getCookie("ct_visited_main"),isVisitedMain=null==ct_visited_main&&-1==isVisitedMain?0:1,cleantalk_user_info.is_main=isVisitedMain,setTimeout(function(){ctSetCookie("ct_user_info",escape(JSON.stringify(cleantalk_user_info)))},1500)}
2
  //# sourceMappingURL=cleantalk_collect_details.min.js.map
1
+ var ctCollectDetails;function ct_getCookie(e){var t=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return t?decodeURIComponent(t[1]):void 0}function ct_setCookie(t,i){var e,n;return ctNocache.set_cookies_flag&&(e="https:"===location.protocol?"; secure":"",document.cookie=t+" =; expires=Thu, 01 Jan 1970 00:00:01 GMT; path = /; samesite=lax"+e,document.cookie=t+" =; expires=Thu, 01 Jan 1970 00:00:01 GMT; samesite=lax"+e,(n=new Date).setDate(n.getDate()+1),setTimeout(function(){var e="https:"===location.protocol?"; secure":"";document.cookie=t+"="+i+"; expires="+n.toUTCString()+"; path = /; samesite=lax"+e},500)),null}if(void 0===ctCollectDetails&&(ctCollectDetails={set_cookies_flag:!0}),Date.now||(Date.now=function(){return(new Date).getTime()}),void 0===ct_collect_details){var ct_collect_details=!0,cleantalk_user_info={},cleantalk_screen_info={};for(var prop in screen)navigator[prop]instanceof Object||""===screen[prop]||(cleantalk_screen_info[prop]=screen[prop]);cleantalk_user_info.screen=cleantalk_screen_info;for(var cleantalk_plugins=Array(),cnt=0,i=0,prev="";i<navigator.plugins.length;i++){var plugin=navigator.plugins[i];prev!==(plugin=plugin.name+" "+(plugin.version||""))&&(cleantalk_plugins[cnt]=plugin,cnt++,prev=plugin)}cleantalk_user_info.plugins=cleantalk_plugins,cleantalk_user_info.timezone_offset=-(new Date).getTimezoneOffset()/60,cleantalk_user_info.datetime=Math.round((new Date).getTime()/1e3),cleantalk_user_info.browser_x=document.documentElement.clientWidth,cleantalk_user_info.browser_y=document.documentElement.clientHeight;var ua=navigator.userAgent.toLowerCase(),flashInstalled=0;if(void 0!==navigator.plugins&&"object"==typeof navigator.plugins["Shockwave Flash"])flashInstalled=1;else if(void 0!==window.ActiveXObject)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash")&&(flashInstalled=1)}catch(e){}cleantalk_user_info.is_flash=flashInstalled,isVisitedMain=-1,location.href!="http://"+location.hostname+"/"&&location.href!="https://"+location.hostname+"/"||(isVisitedMain=1,setTimeout(function(){ct_setCookie("ct_visited_main","1")},1500)),ct_visited_main=ct_getCookie("ct_visited_main"),isVisitedMain=null==ct_visited_main&&-1==isVisitedMain?0:1,cleantalk_user_info.is_main=isVisitedMain,setTimeout(function(){ctSetCookie("ct_user_info",escape(JSON.stringify(cleantalk_user_info)))},1500)}
2
  //# sourceMappingURL=cleantalk_collect_details.min.js.map
js/cleantalk_collect_details.min.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cleantalk_collect_details.min.js","sources":["cleantalk_collect_details.js"],"sourcesContent":["/*\n Assign default values for backend variables.\n*/\nif (typeof ctCollectDetails === 'undefined') {\n var ctCollectDetails = {};\n ctCollectDetails.set_cookies_flag = true;\n}\n\nfunction ct_getCookie(name) {\n var matches = document.cookie.match(new RegExp(\n \"(?:^|; )\" + name.replace(/([\\.$?*|{}\\(\\)\\[\\]\\\\\\/\\+^])/g, '\\\\$1') + \"=([^;]*)\"\n ));\n return matches ? decodeURIComponent(matches[1]) : undefined;\n}\n\nfunction ct_setCookie(name, value)\n{\n if (ctNocache.set_cookies_flag) {\n var ctSecure = location.protocol === 'https:' ? '; secure' : '';\n document.cookie = name+\" =; expires=Thu, 01 Jan 1970 00:00:01 GMT; path = /; samesite=lax\" + ctSecure;\n document.cookie = name+\" =; expires=Thu, 01 Jan 1970 00:00:01 GMT; samesite=lax\" + ctSecure;\n\n var date = new Date;\n date.setDate(date.getDate() + 1);\n setTimeout(function() {\n var ctSecure = location.protocol === 'https:' ? '; secure' : '';\n document.cookie = name+\"=\" + value + \"; expires=\" + date.toUTCString() + \"; path = /; samesite=lax\" + ctSecure;\n }, 500);\n }\n\n return null;\n}\n\nif (!Date.now) {\n Date.now = function() { return new Date().getTime(); }\n}\n\nif( ct_collect_details === undefined )\n{\n var ct_collect_details = true;\n\n var cleantalk_user_info={};\n\n var cleantalk_screen_info={};\n\n for(var prop in screen)\n {\n if (navigator[prop] instanceof Object || screen[prop]==='')\n continue;\n cleantalk_screen_info[prop]=screen[prop];\n }\n\n cleantalk_user_info.screen=cleantalk_screen_info;\n\n var cleantalk_plugins=Array();\n var prev;\n var cnt=0;\n for(var i=0;i<navigator.plugins.length;i++)\n {\n var plugin = navigator.plugins[i];\n var plugin = plugin.name+\" \"+(plugin.version || '')\n if (prev == plugin ) continue;\n cleantalk_plugins[cnt]=plugin;\n cnt++;\n prev = plugin;\n }\n cleantalk_user_info.plugins=cleantalk_plugins;\n\n cleantalk_user_info.timezone_offset = -new Date().getTimezoneOffset()/60;\n cleantalk_user_info.datetime = Math.round((new Date().getTime())/1000);\n\n cleantalk_user_info.browser_x=document.documentElement.clientWidth;\n cleantalk_user_info.browser_y=document.documentElement.clientHeight;\n\n var ua = navigator.userAgent.toLowerCase();\n var flashInstalled = 0;\n if (typeof(navigator.plugins)!=\"undefined\"&&typeof(navigator.plugins[\"Shockwave Flash\"])==\"object\")\n {\n flashInstalled = 1;\n }\n else if (typeof window.ActiveXObject != \"undefined\")\n {\n try\n {\n if (new ActiveXObject(\"ShockwaveFlash.ShockwaveFlash\"))\n {\n flashInstalled = 1;\n }\n } catch(e) {};\n };\n\n cleantalk_user_info.is_flash=flashInstalled;\n\n isVisitedMain=-1;\n if(location.href=='http://'+location.hostname+'/' || location.href=='https://'+location.hostname+'/')\n {\n isVisitedMain=1;\n setTimeout(function () {\n ct_setCookie('ct_visited_main',\n '1')\n }, 1500);\n }\n\n\n ct_visited_main = ct_getCookie('ct_visited_main');\n if(ct_visited_main==undefined && isVisitedMain==-1)\n {\n isVisitedMain=0;\n }\n else\n {\n isVisitedMain=1;\n }\n\n cleantalk_user_info.is_main=isVisitedMain;\n\n setTimeout(function () {\n ctSetCookie(\n 'ct_user_info',\n escape(JSON.stringify(cleantalk_user_info)));\n }, 1500);\n\n}"],"names":["ctCollectDetails","ct_getCookie","name","matches","document","cookie","match","RegExp","replace","decodeURIComponent","undefined","ct_setCookie","value","ctSecure","date","ctNocache","set_cookies_flag","location","protocol","Date","setDate","getDate","setTimeout","toUTCString","now","getTime","ct_collect_details","cleantalk_user_info","cleantalk_screen_info","prop","screen","navigator","Object","prev","cleantalk_plugins","Array","cnt","i","plugins","length","plugin","version","timezone_offset","getTimezoneOffset","datetime","Math","round","browser_x","documentElement","clientWidth","browser_y","clientHeight","ua","userAgent","toLowerCase","flashInstalled","window","ActiveXObject","e","is_flash","isVisitedMain","href","hostname","ct_visited_main","is_main","ctSetCookie","escape","JSON","stringify"],"mappings":"AAGA,IACQA,iBAIR,SAASC,aAAaC,GAClB,IAAIC,EAAUC,SAASC,OAAOC,MAAM,IAAIC,OACpC,WAAaL,EAAKM,QAAQ,+BAAgC,QAAU,aAExE,OAAOL,EAAUM,mBAAmBN,EAAQ,SAAMO,EAGtD,SAASC,aAAaT,EAAMU,GAExB,IACQC,EAIAC,EAQR,OAbIC,UAAUC,mBACNH,EAAiC,WAAtBI,SAASC,SAAwB,WAAa,GAC7Dd,SAASC,OAASH,EAAK,oEAAsEW,EAC7FT,SAASC,OAASH,EAAK,0DAA4DW,GAE/EC,EAAO,IAAIK,MACVC,QAAQN,EAAKO,UAAY,GAC9BC,WAAW,WACP,I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AAO7C,SAAS4C,MAAM,WAAW5C,SAAS6C,SAAS,MAE7FF,cAAc,EACdtC,WAAW,WACPX,aAAa,kBACT,MACL,OAIPoD,gBAAkB9D,aAAa,mBAG3B2D,cAFgBlD,MAAjBqD,kBAA8C,GAAhBH,cAEf,EAIA,EAGlBjC,oBAAoBqC,QAAQJ,cAE5BtC,WAAW,WACP2C,YACI,eACAC,OAAOC,KAAKC,UAAUzC,wBAC3B"}
1
+ {"version":3,"file":"cleantalk_collect_details.min.js","sources":["cleantalk_collect_details.js"],"sourcesContent":["/*\n Assign default values for backend variables.\n*/\nif (typeof ctCollectDetails === 'undefined') {\n var ctCollectDetails = {};\n ctCollectDetails.set_cookies_flag = true;\n}\n\nfunction ct_getCookie(name) {\n var matches = document.cookie.match(new RegExp(\n \"(?:^|; )\" + name.replace(/([\\.$?*|{}\\(\\)\\[\\]\\\\\\/\\+^])/g, '\\\\$1') + \"=([^;]*)\"\n ));\n return matches ? decodeURIComponent(matches[1]) : undefined;\n}\n\nfunction ct_setCookie(name, value)\n{\n if (ctNocache.set_cookies_flag) {\n var ctSecure = location.protocol === 'https:' ? '; secure' : '';\n document.cookie = name+\" =; expires=Thu, 01 Jan 1970 00:00:01 GMT; path = /; samesite=lax\" + ctSecure;\n document.cookie = name+\" =; expires=Thu, 01 Jan 1970 00:00:01 GMT; samesite=lax\" + ctSecure;\n\n var date = new Date;\n date.setDate(date.getDate() + 1);\n setTimeout(function() {\n var ctSecure = location.protocol === 'https:' ? '; secure' : '';\n document.cookie = name+\"=\" + value + \"; expires=\" + date.toUTCString() + \"; path = /; samesite=lax\" + ctSecure;\n }, 500);\n }\n\n return null;\n}\n\nif (!Date.now) {\n Date.now = function() { return new Date().getTime(); }\n}\n\nif( ct_collect_details === undefined )\n{\n var ct_collect_details = true;\n\n var cleantalk_user_info={};\n\n var cleantalk_screen_info={};\n\n for(var prop in screen)\n {\n if (navigator[prop] instanceof Object || screen[prop]==='')\n continue;\n cleantalk_screen_info[prop]=screen[prop];\n }\n\n cleantalk_user_info.screen=cleantalk_screen_info;\n\n var cleantalk_plugins = Array();\n var cnt=0;\n for(var i=0, prev = ''; i<navigator.plugins.length; i++)\n {\n var plugin = navigator.plugins[i];\n plugin = plugin.name+\" \"+(plugin.version || '')\n if (prev === plugin ) continue;\n cleantalk_plugins[cnt]=plugin;\n cnt++;\n prev = plugin;\n }\n cleantalk_user_info.plugins = cleantalk_plugins;\n\n cleantalk_user_info.timezone_offset = -new Date().getTimezoneOffset()/60;\n cleantalk_user_info.datetime = Math.round((new Date().getTime())/1000);\n\n cleantalk_user_info.browser_x=document.documentElement.clientWidth;\n cleantalk_user_info.browser_y=document.documentElement.clientHeight;\n\n var ua = navigator.userAgent.toLowerCase();\n var flashInstalled = 0;\n if (typeof(navigator.plugins)!=\"undefined\"&&typeof(navigator.plugins[\"Shockwave Flash\"])==\"object\")\n {\n flashInstalled = 1;\n }\n else if (typeof window.ActiveXObject != \"undefined\")\n {\n try\n {\n if (new ActiveXObject(\"ShockwaveFlash.ShockwaveFlash\"))\n {\n flashInstalled = 1;\n }\n } catch(e) {}\n }\n\n cleantalk_user_info.is_flash=flashInstalled;\n\n isVisitedMain=-1;\n if(location.href=='http://'+location.hostname+'/' || location.href=='https://'+location.hostname+'/')\n {\n isVisitedMain=1;\n setTimeout(function () {\n ct_setCookie('ct_visited_main',\n '1')\n }, 1500);\n }\n\n\n ct_visited_main = ct_getCookie('ct_visited_main');\n if(ct_visited_main==undefined && isVisitedMain==-1)\n {\n isVisitedMain=0;\n }\n else\n {\n isVisitedMain=1;\n }\n\n cleantalk_user_info.is_main=isVisitedMain;\n\n setTimeout(function () {\n ctSetCookie(\n 'ct_user_info',\n escape(JSON.stringify(cleantalk_user_info)));\n }, 1500);\n\n}"],"names":["ctCollectDetails","ct_getCookie","name","matches","document","cookie","match","RegExp","replace","decodeURIComponent","undefined","ct_setCookie","value","ctSecure","date","ctNocache","set_cookies_flag","location","protocol","Date","setDate","getDate","setTimeout","toUTCString","now","getTime","ct_collect_details","cleantalk_user_info","cleantalk_screen_info","prop","screen","navigator","Object","cleantalk_plugins","Array","cnt","i","prev","plugins","length","plugin","version","timezone_offset","getTimezoneOffset","datetime","Math","round","browser_x","documentElement","clientWidth","browser_y","clientHeight","ua","userAgent","toLowerCase","flashInstalled","window","ActiveXObject","e","is_flash","isVisitedMain","href","hostname","ct_visited_main","is_main","ctSetCookie","escape","JSON","stringify"],"mappings":"AAGA,IACQA,iBAIR,SAASC,aAAaC,GAClB,IAAIC,EAAUC,SAASC,OAAOC,MAAM,IAAIC,OACpC,WAAaL,EAAKM,QAAQ,+BAAgC,QAAU,aAExE,OAAOL,EAAUM,mBAAmBN,EAAQ,SAAMO,EAGtD,SAASC,aAAaT,EAAMU,GAExB,IACQC,EAIAC,EAQR,OAbIC,UAAUC,mBACNH,EAAiC,WAAtBI,SAASC,SAAwB,WAAa,GAC7Dd,SAASC,OAASH,EAAK,oEAAsEW,EAC7FT,SAASC,OAASH,EAAK,0DAA4DW,GAE/EC,EAAO,IAAIK,MACVC,QAAQN,EAAKO,UAAY,GAC9BC,WAAW,WACP,IAAIT,EAAiC,WAAtBI,SAASC,SAAwB,WAAa,GAC7Dd,SAASC,OAASH,EAAK,IAAMU,EAAQ,aAAeE,EAAKS,cAAgB,2BAA6BV,GACvG,MAGA,KAOX,QAlCgC,IAArBb,mBACHA,iBAAmB,CACvBgB,kBAAoC,IA4BnCG,KAAKK,MACNL,KAAKK,IAAM,WAAa,OAAO,IAAIL,MAAOM,iBAGnBf,IAAvBgB,mBACJ,CACI,IAAIA,oBAAqB,EAErBC,oBAAoB,GAEpBC,sBAAsB,GAE1B,IAAI,IAAIC,QAAQC,OAERC,UAAUF,gBAAiBG,QAAyB,KAAfF,OAAOD,QAEhDD,sBAAsBC,MAAMC,OAAOD,OAGvCF,oBAAoBG,OAAOF,sBAI3B,IAFA,IAAIK,kBAAoBC,QACpBC,IAAI,EACAC,EAAE,EAAGC,KAAO,GAAID,EAAEL,UAAUO,QAAQC,OAAQH,IACpD,CACI,IAAII,OAAST,UAAUO,QAAQF,GAE3BC,QADJG,OAASA,OAAOtC,KAAK,KAAKsC,OAAOC,SAAW,OAE5CR,kBAAkBE,KAAKK,OACvBL,MACAE,KAAOG,QAEXb,oBAAoBW,QAAUL,kBAE9BN,oBAAoBe,kBAAmB,IAAIvB,MAAOwB,oBAAoB,GACtEhB,oBAAoBiB,SAAWC,KAAKC,OAAO,IAAI3B,MAAOM,UAAW,KAEjEE,oBAAoBoB,UAAU3C,SAAS4C,gBAAgBC,YACvDtB,oBAAoBuB,UAAU9C,SAAS4C,gBAAgBG,aAEvD,IAAIC,GAAKrB,UAAUsB,UAAUC,cACzBC,eAAiB,EACrB,QAA+B,IAApBxB,UAAiB,SAA8D,iBAAvCA,UAAUO,QAAQ,mBAEjEiB,eAAiB,OAEhB,QAAmC,IAAxBC,OAAOC,cAEnB,IAEQ,IAAIA,cAAc,mCAElBF,eAAiB,GAEvB,MAAMG,IAGZ/B,oBAAoBgC,SAASJ,eAE7BK,eAAe,EACZ3C,SAAS4C,MAAM,UAAU5C,SAAS6C,SAAS,KAAO7C,SAAS4C,MAAM,WAAW5C,SAAS6C,SAAS,MAE7FF,cAAc,EACdtC,WAAW,WACPX,aAAa,kBACT,MACL,OAIPoD,gBAAkB9D,aAAa,mBAG3B2D,cAFgBlD,MAAjBqD,kBAA8C,GAAhBH,cAEf,EAIA,EAGlBjC,oBAAoBqC,QAAQJ,cAE5BtC,WAAW,WACP2C,YACI,eACAC,OAAOC,KAAKC,UAAUzC,wBAC3B"}
lib/Cleantalk/Antispam/Cleantalk.php CHANGED
@@ -348,6 +348,8 @@ class Cleantalk
348
  * @todo Refactor / fix logic errors
349
  *
350
  * Function DNS request
 
 
351
  */
352
  public function getServersIp($host)
353
  {
348
  * @todo Refactor / fix logic errors
349
  *
350
  * Function DNS request
351
+ *
352
+ * @psalm-suppress RedundantCondition
353
  */
354
  public function getServersIp($host)
355
  {
lib/Cleantalk/ApbctWP/Activator.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  namespace Cleantalk\ApbctWP;
4
 
 
5
  use Cleantalk\Common\Schema;
6
 
7
  class Activator
@@ -10,6 +11,8 @@ class Activator
10
  {
11
  global $wpdb, $apbct;
12
 
 
 
13
  if ( is_null($concrete_blog_id) ) {
14
  // Do actions for the all blogs on activation
15
  $apbct->stats['plugin']['activation_previous__timestamp'] = $apbct->stats['plugin']['activation__timestamp'];
@@ -22,13 +25,13 @@ class Activator
22
  $blogs = array_keys($wpdb->get_results('SELECT blog_id FROM ' . $wpdb->blogs, OBJECT_K));
23
  foreach ( $blogs as $blog ) {
24
  switch_to_blog($blog);
25
- self::createTables(Schema::getSchema());
26
  self::setCronJobs();
27
  }
28
  switch_to_blog($initial_blog);
29
  } else {
30
  self::setCronJobs();
31
- apbct_activation__create_tables(Schema::getSchema());
32
  ct_account_status_check(null, false);
33
  }
34
 
@@ -43,7 +46,7 @@ class Activator
43
  switch_to_blog($concrete_blog_id);
44
 
45
  self::setCronJobs(false);
46
- apbct_activation__create_tables(Schema::getSchema());
47
  apbct_sfw_update__init(3); // Updating SFW
48
  ct_account_status_check(null, false);
49
 
@@ -55,40 +58,6 @@ class Activator
55
  }
56
  }
57
 
58
- /**
59
- * Creating specific tables
60
- *
61
- * @param $sqls
62
- * @param string $db_prefix
63
- *
64
- * @return void
65
- */
66
- public static function createTables($sqls, $db_prefix = '')
67
- {
68
- if ( ! is_array($sqls) && empty($sqls) ) {
69
- return;
70
- }
71
-
72
- global $wpdb;
73
-
74
- $db_prefix = $db_prefix ?: $wpdb->prefix;
75
-
76
- $wpdb->show_errors = false;
77
- foreach ( $sqls as $sql ) {
78
- $sql = sprintf($sql, $db_prefix); // Adding current blog prefix
79
- $result = $wpdb->query($sql);
80
- if ( $result === false ) {
81
- $errors[] = "Failed.\nQuery: $wpdb->last_query\nError: $wpdb->last_error";
82
- }
83
- }
84
- $wpdb->show_errors = true;
85
-
86
- // Logging errors
87
- if ( ! empty($errors) ) {
88
- apbct_log($errors);
89
- }
90
- }
91
-
92
  /**
93
  * Set CRON jobs
94
  *
2
 
3
  namespace Cleantalk\ApbctWP;
4
 
5
+ use Cleantalk\ApbctWP\UpdatePlugin\DbTablesCreator;
6
  use Cleantalk\Common\Schema;
7
 
8
  class Activator
11
  {
12
  global $wpdb, $apbct;
13
 
14
+ $db_tables_creator = new DbTablesCreator();
15
+
16
  if ( is_null($concrete_blog_id) ) {
17
  // Do actions for the all blogs on activation
18
  $apbct->stats['plugin']['activation_previous__timestamp'] = $apbct->stats['plugin']['activation__timestamp'];
25
  $blogs = array_keys($wpdb->get_results('SELECT blog_id FROM ' . $wpdb->blogs, OBJECT_K));
26
  foreach ( $blogs as $blog ) {
27
  switch_to_blog($blog);
28
+ $db_tables_creator->createAllTables();
29
  self::setCronJobs();
30
  }
31
  switch_to_blog($initial_blog);
32
  } else {
33
  self::setCronJobs();
34
+ $db_tables_creator->createAllTables();
35
  ct_account_status_check(null, false);
36
  }
37
 
46
  switch_to_blog($concrete_blog_id);
47
 
48
  self::setCronJobs(false);
49
+ $db_tables_creator->createAllTables();
50
  apbct_sfw_update__init(3); // Updating SFW
51
  ct_account_status_check(null, false);
52
 
58
  }
59
  }
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  /**
62
  * Set CRON jobs
63
  *
lib/Cleantalk/ApbctWP/AdminNotices.php CHANGED
@@ -140,7 +140,7 @@ class AdminNotices
140
  {
141
  if ( ( ! apbct_api_key__is_correct() && $this->apbct->moderate_ip == 0) && ! $this->apbct->white_label ) {
142
  $content = sprintf(
143
- __("Please enter Access Key in %s settings to enable anti spam protection!", 'cleantalk-spam-protect'),
144
  "<a href='{$this->settings_link}'>{$this->apbct->plugin_name}</a>"
145
  );
146
  $id = 'cleantalk_' . __FUNCTION__;
@@ -290,6 +290,7 @@ class AdminNotices
290
  * @param string $after
291
  *
292
  * @return string
 
293
  */
294
  public function addAttentionMark($after)
295
  {
140
  {
141
  if ( ( ! apbct_api_key__is_correct() && $this->apbct->moderate_ip == 0) && ! $this->apbct->white_label ) {
142
  $content = sprintf(
143
+ __("Please enter the Access Key in %s plugin to enable spam protection!", 'cleantalk-spam-protect'),
144
  "<a href='{$this->settings_link}'>{$this->apbct->plugin_name}</a>"
145
  );
146
  $id = 'cleantalk_' . __FUNCTION__;
290
  * @param string $after
291
  *
292
  * @return string
293
+ * @psalm-suppress PossiblyUnusedReturnValue
294
  */
295
  public function addAttentionMark($after)
296
  {
lib/Cleantalk/ApbctWP/FindSpam/CommentsChecker.php CHANGED
@@ -119,61 +119,25 @@ class CommentsChecker extends Checker
119
  check_ajax_referer('ct_secret_nonce', 'security');
120
 
121
  global $wpdb, $apbct;
 
122
 
123
  if ( isset($_POST['from'], $_POST['till']) ) {
124
  $from_date = date('Y-m-d', intval(strtotime($_POST['from'])));
125
  $till_date = date('Y-m-d', intval(strtotime($_POST['till'])));
126
- }
127
 
128
- // Getting comments 100 unchecked comments
129
- if ( isset($_COOKIE['ct_comments_safe_check']) ) {
130
- $c = $wpdb->get_results(
131
- "
132
- SELECT comment_ID, comment_date_gmt, comment_author_IP, comment_author_email
133
- FROM {$wpdb->comments} as comm
134
- WHERE
135
- (comm.comment_approved = '1' OR comm.comment_approved = '0')
136
- AND NOT EXISTS(
137
- SELECT comment_id, meta_key
138
- FROM {$wpdb->commentmeta} as meta
139
- WHERE comm.comment_ID = meta.comment_id AND (meta_key = 'ct_checked' OR meta_key = 'ct_bad')
140
- )
141
- ORDER BY comment_date_gmt
142
- LIMIT 100",
143
- ARRAY_A
144
- );
145
- } else {
146
- $params = array(
147
- 'meta_query' => array(
148
- 'relation' => 'AND',
149
- array(
150
- 'key' => 'ct_checked_now',
151
- 'compare' => 'NOT EXISTS'
152
- ),
153
- array(
154
- 'key' => 'ct_checked',
155
- 'compare' => 'NOT EXISTS'
156
- ),
157
- array(
158
- 'key' => 'ct_bad',
159
- 'compare' => 'NOT EXISTS'
160
- )
161
- ),
162
- 'orderby' => 'comment_date_gmt',
163
- 'order' => 'ASC',
164
- 'number' => 100
165
- );
166
- if ( isset($from_date, $till_date) ) {
167
- $params['date_query'] = array(
168
- 'column' => 'comment_date_gmt',
169
- 'after' => $from_date,
170
- 'before' => $till_date,
171
- 'inclusive' => true,
172
- );
173
- }
174
- $c = get_comments($params);
175
  }
176
 
 
 
 
 
 
 
 
 
 
 
177
  $check_result = array(
178
  'end' => 0,
179
  'checked' => 0,
@@ -216,9 +180,6 @@ class CommentsChecker extends Checker
216
 
217
  if ( empty($curr_ip) && empty($curr_email) ) {
218
  $check_result['bad']++;
219
- update_comment_meta($iValue->comment_ID, 'ct_bad', '1');
220
- update_comment_meta($iValue->comment_ID, 'ct_checked', '1');
221
- update_comment_meta($iValue->comment_ID, 'ct_checked_now', '1');
222
  unset($c[$i]);
223
  } else {
224
  if ( ! empty($curr_ip) ) {
@@ -233,6 +194,10 @@ class CommentsChecker extends Checker
233
  }
234
  }
235
 
 
 
 
 
236
  // Recombining after checking and unsetting
237
  $c = array_values($c);
238
 
@@ -257,8 +222,6 @@ class CommentsChecker extends Checker
257
  $mark_spam_email = false;
258
 
259
  $check_result['checked']++;
260
- update_comment_meta($iValue->comment_ID, 'ct_checked', date("Y-m-d H:m:s"));
261
- update_comment_meta($iValue->comment_ID, 'ct_checked_now', date("Y-m-d H:m:s"), true);
262
 
263
  $uip = $iValue->comment_author_IP;
264
  $uim = $iValue->comment_author_email;
@@ -276,6 +239,11 @@ class CommentsChecker extends Checker
276
  update_comment_meta($iValue->comment_ID, 'ct_marked_as_spam', '1');
277
  }
278
  }
 
 
 
 
 
279
  print json_encode($check_result);
280
  } else {
281
  $check_result['error'] = 1;
@@ -302,19 +270,13 @@ class CommentsChecker extends Checker
302
 
303
  public static function ctAjaxInfo($direct_call = false)
304
  {
305
- global $wpdb;
306
 
307
  if ( ! $direct_call ) {
308
  check_ajax_referer('ct_secret_nonce', 'security');
309
  }
310
 
311
- // Checked comments
312
- $params_checked = array(
313
- 'meta_key' => 'ct_checked_now',
314
- 'orderby' => 'ct_checked_now'
315
- );
316
- $checked_comments = new \WP_Comment_Query($params_checked);
317
- $cnt_checked = count($checked_comments->get_comments());
318
 
319
  // Spam comments
320
  $params_spam = array(
@@ -322,33 +284,16 @@ class CommentsChecker extends Checker
322
  'relation' => 'AND',
323
  array(
324
  'key' => 'ct_marked_as_spam',
325
- 'compare' => 'EXISTS'
326
- ),
327
- array(
328
- 'key' => 'ct_checked_now',
329
- 'compare' => 'EXISTS'
330
- ),
331
  ),
332
  );
333
  $spam_comments = new \WP_Comment_Query($params_spam);
334
  $cnt_spam = count($spam_comments->get_comments());
335
 
336
  // Bad comments (without IP and Email)
337
- $params_bad = array(
338
- 'meta_query' => array(
339
- 'relation' => 'AND',
340
- array(
341
- 'key' => 'ct_bad',
342
- 'compare' => 'EXISTS'
343
- ),
344
- array(
345
- 'key' => 'ct_checked_now',
346
- 'compare' => 'EXISTS'
347
- ),
348
- ),
349
- );
350
- $bad_comments = new \WP_Comment_Query($params_bad);
351
- $cnt_bad = count($bad_comments->get_comments());
352
 
353
  /**
354
  * Total comments
@@ -418,45 +363,23 @@ class CommentsChecker extends Checker
418
 
419
  public static function ctAjaxClearComments()
420
  {
421
- global $wpdb;
422
 
423
  check_ajax_referer('ct_secret_nonce', 'security');
424
 
425
- $wpdb->query("DELETE FROM {$wpdb->commentmeta} WHERE meta_key IN ('ct_checked_now')");
426
-
427
- if ( isset($_POST['from']) && isset($_POST['till']) ) {
428
- if (
429
- preg_match('/[a-zA-Z]{3}\s{1}\d{1,2}\s{1}\d{4}/', $_POST['from']) &&
430
- preg_match('/[a-zA-Z]{3}\s{1}\d{1,2}\s{1}\d{4}/', $_POST['till'])
431
- ) {
432
- $from = date('Y-m-d', intval(strtotime($_POST['from']))) . ' 00:00:00';
433
- $till = date('Y-m-d', intval(strtotime($_POST['till']))) . ' 23:59:59';
434
-
435
- $wpdb->query(
436
- "DELETE FROM {$wpdb->commentmeta} WHERE
437
- meta_key IN ('ct_checked','ct_marked_as_spam','ct_bad')
438
- AND meta_value >= '{$from}'
439
- AND meta_value <= '{$till}';"
440
- );
441
- die();
442
- } else {
443
- $wpdb->query(
444
- "DELETE FROM {$wpdb->commentmeta} WHERE
445
- meta_key IN ('ct_checked','ct_marked_as_spam','ct_bad')"
446
- );
447
- die();
448
- }
449
- }
450
  }
451
 
452
  private static function getLogData()
453
  {
454
- // Checked users
455
- $params_spam = array(
456
- 'meta_key' => 'ct_checked_now',
457
- );
458
- $spam_comments = new \WP_Comment_Query($params_spam);
459
- $cnt_checked = count($spam_comments->get_comments());
460
 
461
  // Spam users
462
  $params_spam = array(
@@ -464,33 +387,15 @@ class CommentsChecker extends Checker
464
  'relation' => 'AND',
465
  array(
466
  'key' => 'ct_marked_as_spam',
467
- 'compare' => 'EXISTS'
468
- ),
469
- array(
470
- 'key' => 'ct_checked_now',
471
- 'compare' => 'EXISTS'
472
  ),
473
  ),
474
  );
475
  $spam_comments = new \WP_Comment_Query($params_spam);
476
  $cnt_spam = count($spam_comments->get_comments());
477
 
478
- // Bad users (without IP and Email)
479
- $params_bad = array(
480
- 'meta_query' => array(
481
- 'relation' => 'AND',
482
- array(
483
- 'key' => 'ct_bad',
484
- 'compare' => 'EXISTS'
485
- ),
486
- array(
487
- 'key' => 'ct_checked_now',
488
- 'compare' => 'EXISTS'
489
- ),
490
- ),
491
- );
492
- $spam_comments = new \WP_Comment_Query($params_bad);
493
- $cnt_bad = count($spam_comments->get_comments());
494
 
495
  return array(
496
  'spam' => $cnt_spam,
119
  check_ajax_referer('ct_secret_nonce', 'security');
120
 
121
  global $wpdb, $apbct;
122
+ $sql_where = '';
123
 
124
  if ( isset($_POST['from'], $_POST['till']) ) {
125
  $from_date = date('Y-m-d', intval(strtotime($_POST['from'])));
126
  $till_date = date('Y-m-d', intval(strtotime($_POST['till'])));
 
127
 
128
+ $sql_where = "WHERE comment_date_gmt > '$from_date 00:00:00' AND comment_date_gmt < '$till_date 23:59:59'";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  }
130
 
131
+ $offset = $_COOKIE['apbct_check_comments_offset'] ?: 0;
132
+
133
+ $c = $wpdb->get_results(
134
+ "SELECT comment_ID, comment_date_gmt, comment_author_IP, comment_author_email
135
+ FROM $wpdb->comments
136
+ $sql_where
137
+ ORDER BY comment_ID
138
+ LIMIT 100 OFFSET $offset"
139
+ );
140
+
141
  $check_result = array(
142
  'end' => 0,
143
  'checked' => 0,
180
 
181
  if ( empty($curr_ip) && empty($curr_email) ) {
182
  $check_result['bad']++;
 
 
 
183
  unset($c[$i]);
184
  } else {
185
  if ( ! empty($curr_ip) ) {
194
  }
195
  }
196
 
197
+ // save count bad comments to State:data
198
+ $apbct->data['count_bad_comments'] += $check_result['bad'];
199
+ $apbct->saveData();
200
+
201
  // Recombining after checking and unsetting
202
  $c = array_values($c);
203
 
222
  $mark_spam_email = false;
223
 
224
  $check_result['checked']++;
 
 
225
 
226
  $uip = $iValue->comment_author_IP;
227
  $uim = $iValue->comment_author_email;
239
  update_comment_meta($iValue->comment_ID, 'ct_marked_as_spam', '1');
240
  }
241
  }
242
+
243
+ // save count checked comments to State:data
244
+ $apbct->data['count_checked_comments'] += $check_result['checked'];
245
+ $apbct->saveData();
246
+
247
  print json_encode($check_result);
248
  } else {
249
  $check_result['error'] = 1;
270
 
271
  public static function ctAjaxInfo($direct_call = false)
272
  {
273
+ global $wpdb, $apbct;
274
 
275
  if ( ! $direct_call ) {
276
  check_ajax_referer('ct_secret_nonce', 'security');
277
  }
278
 
279
+ $cnt_checked = $apbct->data['count_checked_comments'];
 
 
 
 
 
 
280
 
281
  // Spam comments
282
  $params_spam = array(
284
  'relation' => 'AND',
285
  array(
286
  'key' => 'ct_marked_as_spam',
287
+ 'compare' => '=',
288
+ 'value' => 1
289
+ )
 
 
 
290
  ),
291
  );
292
  $spam_comments = new \WP_Comment_Query($params_spam);
293
  $cnt_spam = count($spam_comments->get_comments());
294
 
295
  // Bad comments (without IP and Email)
296
+ $cnt_bad = $apbct->data['count_bad_comments'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
 
298
  /**
299
  * Total comments
363
 
364
  public static function ctAjaxClearComments()
365
  {
366
+ global $wpdb ,$apbct;
367
 
368
  check_ajax_referer('ct_secret_nonce', 'security');
369
 
370
+ $apbct->data['count_checked_comments'] = 0;
371
+ $apbct->data['count_bad_comments'] = 0;
372
+ $apbct->saveData();
373
+
374
+ $wpdb->query("DELETE FROM {$wpdb->commentmeta} WHERE meta_key IN ('ct_marked_as_spam')");
375
+ die;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376
  }
377
 
378
  private static function getLogData()
379
  {
380
+ global $apbct;
381
+
382
+ $cnt_checked = $apbct->data['count_checked_comments'];
 
 
 
383
 
384
  // Spam users
385
  $params_spam = array(
387
  'relation' => 'AND',
388
  array(
389
  'key' => 'ct_marked_as_spam',
390
+ 'compare' => '=',
391
+ 'value' => 1
 
 
 
392
  ),
393
  ),
394
  );
395
  $spam_comments = new \WP_Comment_Query($params_spam);
396
  $cnt_spam = count($spam_comments->get_comments());
397
 
398
+ $cnt_bad = $apbct->data['count_bad_comments'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
399
 
400
  return array(
401
  'spam' => $cnt_spam,
lib/Cleantalk/ApbctWP/FindSpam/ListTable/Comments.php CHANGED
@@ -308,37 +308,7 @@ class Comments extends \Cleantalk\ApbctWP\CleantalkListTable
308
  */
309
  public function getChecked()
310
  {
311
- $params_spam = array(
312
- 'meta_key' => 'ct_checked',
313
- );
314
-
315
- return new \WP_Comment_Query($params_spam);
316
- }
317
-
318
- /**
319
- * @return \WP_Comment_Query
320
- * @psalm-suppress PossiblyUnusedMethod
321
- */
322
- public function getCheckedNow()
323
- {
324
- $params_spam = array(
325
- 'meta_key' => 'ct_checked_now',
326
- );
327
-
328
- return new \WP_Comment_Query($params_spam);
329
- }
330
-
331
- /**
332
- * @return \WP_Comment_Query
333
- * @psalm-suppress PossiblyUnusedMethod
334
- */
335
- public function getSpam()
336
- {
337
- $params_spam = array(
338
- 'meta_key' => 'ct_marked_as_spam',
339
- );
340
-
341
- return new \WP_Comment_Query($params_spam);
342
  }
343
 
344
  /**
@@ -349,17 +319,7 @@ class Comments extends \Cleantalk\ApbctWP\CleantalkListTable
349
  public function getSpamNow()
350
  {
351
  $params_spam = array(
352
- 'meta_query' => array(
353
- 'relation' => 'AND',
354
- array(
355
- 'key' => 'ct_marked_as_spam',
356
- 'compare' => 'EXISTS'
357
- ),
358
- array(
359
- 'key' => 'ct_checked_now',
360
- 'compare' => 'EXISTS'
361
- ),
362
- )
363
  );
364
 
365
  return new \WP_Comment_Query($params_spam);
@@ -373,11 +333,7 @@ class Comments extends \Cleantalk\ApbctWP\CleantalkListTable
373
  */
374
  public function getBad()
375
  {
376
- $params_bad = array(
377
- 'meta_key' => 'ct_bad',
378
- );
379
-
380
- return new \WP_Comment_Query($params_bad);
381
  }
382
 
383
  public function getScansLogs()
308
  */
309
  public function getChecked()
310
  {
311
+ return $this->apbct->data['count_checked_comments'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
312
  }
313
 
314
  /**
319
  public function getSpamNow()
320
  {
321
  $params_spam = array(
322
+ 'meta_key' => 'ct_marked_as_spam',
 
 
 
 
 
 
 
 
 
 
323
  );
324
 
325
  return new \WP_Comment_Query($params_spam);
333
  */
334
  public function getBad()
335
  {
336
+ return $this->apbct->data['count_bad_comments'];
 
 
 
 
337
  }
338
 
339
  public function getScansLogs()
lib/Cleantalk/ApbctWP/Firewall/SFW.php CHANGED
@@ -82,11 +82,6 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule
82
  $results = array();
83
  $status = 0;
84
 
85
- //Skip if sfw not updated yet
86
- if ( ! $this->apbct->stats['sfw']['last_update_time']) {
87
- return $results;
88
- }
89
-
90
  // Skip by cookie
91
  foreach ($this->ip_array as $current_ip) {
92
  if (strpos(Cookie::get('ct_sfw_pass_key'), md5($current_ip . $this->api_key)) === 0) {
@@ -750,11 +745,7 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule
750
  $table_names = (array)$table_names;
751
 
752
  foreach ($table_names as $table_name) {
753
- if ( ! $db->isTableExists($table_name)) {
754
- return array('error' => 'DELETE TABLE: TABLE IS NOT EXISTS: ' . $table_name);
755
- }
756
-
757
- if ( ! $db->execute('DROP TABLE ' . $table_name . ';') ) {
758
  return array(
759
  'error' => 'DELETE TABLE: FAILED TO DROP: ' . $table_name
760
  . ' DB Error: ' . $db->getLastError()
82
  $results = array();
83
  $status = 0;
84
 
 
 
 
 
 
85
  // Skip by cookie
86
  foreach ($this->ip_array as $current_ip) {
87
  if (strpos(Cookie::get('ct_sfw_pass_key'), md5($current_ip . $this->api_key)) === 0) {
745
  $table_names = (array)$table_names;
746
 
747
  foreach ($table_names as $table_name) {
748
+ if ( $db->isTableExists($table_name) && ! $db->execute('DROP TABLE ' . $table_name . ';') ) {
 
 
 
 
749
  return array(
750
  'error' => 'DELETE TABLE: FAILED TO DROP: ' . $table_name
751
  . ' DB Error: ' . $db->getLastError()
lib/Cleantalk/ApbctWP/Helper.php CHANGED
@@ -147,7 +147,7 @@ class Helper extends \Cleantalk\Common\Helper
147
  } elseif ( ! empty($result['error'])) {
148
  $result = array('error' => 'WRONG_SITE_RESPONSE TEST ACTION: ' . $rc_action . ' ERROR: ' . $result['error']);
149
  // Expects 'OK' string as good response otherwise - error
150
- } elseif ( ! preg_match('@^.*?OK$@', $result)) {
151
  $result = array(
152
  'error' => 'WRONG_SITE_RESPONSE ACTION: ' .
153
  $rc_action .
147
  } elseif ( ! empty($result['error'])) {
148
  $result = array('error' => 'WRONG_SITE_RESPONSE TEST ACTION: ' . $rc_action . ' ERROR: ' . $result['error']);
149
  // Expects 'OK' string as good response otherwise - error
150
+ } elseif ( ( is_string($result) && ! preg_match('@^.*?OK$@', $result) ) || ! is_string($result) ) {
151
  $result = array(
152
  'error' => 'WRONG_SITE_RESPONSE ACTION: ' .
153
  $rc_action .
lib/Cleantalk/ApbctWP/RemoteCalls.php CHANGED
@@ -25,6 +25,7 @@ class RemoteCalls
25
  * Execute corresponding method of RemoteCalls if exists
26
  *
27
  * @return bool|string|string[]|null
 
28
  */
29
  public static function perform()
30
  {
25
  * Execute corresponding method of RemoteCalls if exists
26
  *
27
  * @return bool|string|string[]|null
28
+ * @psalm-suppress PossiblyUnusedReturnValue
29
  */
30
  public static function perform()
31
  {
lib/Cleantalk/ApbctWP/State.php CHANGED
@@ -206,6 +206,9 @@ class State extends \Cleantalk\Common\State
206
  'key_is_ok' => 0,
207
  'salt' => '',
208
 
 
 
 
209
  );
210
 
211
  public $def_network_settings = array(
@@ -288,6 +291,7 @@ class State extends \Cleantalk\Common\State
288
  'activation__timestamp' => 0,
289
  'activation_previous__timestamp' => 0,
290
  'activation__times' => 0,
 
291
  ),
292
  'cron' => array(
293
  'last_start' => 0,
@@ -300,7 +304,6 @@ class State extends \Cleantalk\Common\State
300
  'firewall_updating_id' => null,
301
  'firewall_update_percent' => 0,
302
  'firewall_updating_last_start' => 0,
303
- 'last_firewall_updated' => 0,
304
  'expected_networks_count' => 0,
305
  'expected_ua_count' => 0,
306
  'update_mode' => 0,
@@ -565,10 +568,39 @@ class State extends \Cleantalk\Common\State
565
  'error_time' => $set_time ? current_time('timestamp') : null,
566
  );
567
 
 
568
  if ( ! empty($major_type)) {
569
- $this->errors[$major_type][$type] = $error;
 
 
 
570
  } else {
571
- $this->errors[$type] = $error;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
572
  }
573
 
574
  $this->saveErrors();
206
  'key_is_ok' => 0,
207
  'salt' => '',
208
 
209
+ // Comment's test
210
+ 'count_checked_comments' => 0,
211
+ 'count_bad_comments' => 0,
212
  );
213
 
214
  public $def_network_settings = array(
291
  'activation__timestamp' => 0,
292
  'activation_previous__timestamp' => 0,
293
  'activation__times' => 0,
294
+ 'plugin_is_being_updated' => 0,
295
  ),
296
  'cron' => array(
297
  'last_start' => 0,
304
  'firewall_updating_id' => null,
305
  'firewall_update_percent' => 0,
306
  'firewall_updating_last_start' => 0,
 
307
  'expected_networks_count' => 0,
308
  'expected_ua_count' => 0,
309
  'update_mode' => 0,
568
  'error_time' => $set_time ? current_time('timestamp') : null,
569
  );
570
 
571
+ //@ToDo Have to rebuild subtypes. These are too difficult to process now.
572
  if ( ! empty($major_type)) {
573
+ if ( is_array($this->errors[$major_type][$type]) && count($this->errors[$major_type][$type]) >= 5 ) {
574
+ array_shift($this->errors[$major_type][$type]);
575
+ }
576
+ $this->errors[$major_type][$type][] = $error;
577
  } else {
578
+ // Remove subtype errors from processing.
579
+ // No need to array_shift for these
580
+ $sub_errors = array();
581
+ if ( is_array($this->errors[$type]) ) {
582
+ foreach ( $this->errors[$type] as $key => $sub_error ) {
583
+ if ( is_string($key) ) {
584
+ $sub_errors[$key] = $sub_error;
585
+ unset($this->errors[$type][$key]);
586
+ }
587
+ }
588
+ }
589
+
590
+ // Drop first element if errors array length is more than 5
591
+ if ( is_array($this->errors[$type]) && count($this->errors[$type]) >= 5 ) {
592
+ array_shift($this->errors[$type]);
593
+ }
594
+
595
+ // Add the error to the errors array
596
+ $this->errors[$type][] = $error;
597
+
598
+ // Add the sub error to the errors array
599
+ if ( count($sub_errors) ) {
600
+ foreach ( $sub_errors as $sub_key => $sub_val ) {
601
+ $this->errors[$type][$sub_key] = $sub_val;
602
+ }
603
+ }
604
  }
605
 
606
  $this->saveErrors();
lib/Cleantalk/ApbctWP/UpdatePlugin/DbAnalyzer.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Cleantalk\ApbctWP\UpdatePlugin;
4
+
5
+ use Cleantalk\Common\Schema;
6
+
7
+ class DbAnalyzer
8
+ {
9
+ /**
10
+ * Contain DB Schema
11
+ */
12
+ private $dbSchema;
13
+
14
+ /**
15
+ * Contain DB Schema prefix
16
+ */
17
+ private $dbSchemaPrefix;
18
+
19
+ /**
20
+ * Tables exists
21
+ */
22
+ private $table_exists;
23
+
24
+ /**
25
+ * Tables not exists
26
+ */
27
+ private $table_not_exists;
28
+
29
+ /**
30
+ * Multisite is On
31
+ */
32
+ private $multisite;
33
+
34
+ public function __construct()
35
+ {
36
+ $this->dbSchema = Schema::getStructureSchemas();
37
+ $this->dbSchemaPrefix = Schema::getSchemaTablePrefix();
38
+ $this->multisite = $this->checkingMultisite();
39
+ $this->checkingCurrentScheme();
40
+ }
41
+
42
+ /**
43
+ * Cheking multisite
44
+ */
45
+ private function checkingMultisite()
46
+ {
47
+ return is_multisite();
48
+ }
49
+
50
+ /**
51
+ * Checking the existence of tables and non-existent tables
52
+ * Filled fields of class
53
+ */
54
+ private function checkingCurrentScheme()
55
+ {
56
+ global $wpdb;
57
+ $tablesExists = array();
58
+ $tablesNotExists = array();
59
+
60
+ if ($this->dbSchema) {
61
+ $schema_table_keys = array_keys($this->dbSchema);
62
+
63
+ // Multisite
64
+ if ($this->multisite) {
65
+ $sites = get_sites();
66
+
67
+ foreach ($sites as $site) {
68
+ foreach ($schema_table_keys as $table_key) {
69
+ switch_to_blog($site->blog_id);
70
+ $table_name = $wpdb->prefix . $this->dbSchemaPrefix . $table_key;
71
+ $result = $this->showTables($table_name);
72
+
73
+ if (is_null($result)) {
74
+ $tablesNotExists[] = $table_name;
75
+ } else {
76
+ $tablesExists[] = $table_name;
77
+ }
78
+ }
79
+ }
80
+ switch_to_blog(get_main_site_id());
81
+ } else {
82
+ foreach ($schema_table_keys as $table_key) {
83
+ $table_name = $wpdb->prefix . $this->dbSchemaPrefix . $table_key;
84
+ $result = $this->showTables($table_name);
85
+
86
+ if (is_null($result)) {
87
+ $tablesNotExists[] = $table_name;
88
+ } else {
89
+ $tablesExists[] = $table_name;
90
+ }
91
+ }
92
+ }
93
+ }
94
+
95
+ $this->table_exists = $tablesExists;
96
+ $this->table_not_exists = $tablesNotExists;
97
+ }
98
+
99
+ /**
100
+ * Show tables LIKE table name
101
+ */
102
+ private function showTables($table_name)
103
+ {
104
+ global $wpdb;
105
+ $query = $wpdb->prepare('SHOW TABLES LIKE %s', $wpdb->esc_like($table_name));
106
+
107
+ return $wpdb->get_var($query);
108
+ }
109
+
110
+ /**
111
+ * Get exists tables
112
+ */
113
+ public function getExistsTables()
114
+ {
115
+ return $this->table_exists;
116
+ }
117
+
118
+ /**
119
+ * Get non-exists tables
120
+ */
121
+ public function getNotExistsTables()
122
+ {
123
+ return $this->table_not_exists;
124
+ }
125
+ }
lib/Cleantalk/ApbctWP/UpdatePlugin/DbColumnCreator.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Cleantalk\ApbctWP\UpdatePlugin;
4
+
5
+ use Cleantalk\Common\Schema;
6
+
7
+ class DbColumnCreator
8
+ {
9
+ /**
10
+ * Table name
11
+ */
12
+ private $dbTableName;
13
+
14
+ /**
15
+ * Tables that have been changed
16
+ */
17
+ private $dbTableChanged;
18
+
19
+ /**
20
+ * Table structure
21
+ */
22
+ private $dbTableStructure;
23
+
24
+ public function __construct($table_name)
25
+ {
26
+ $this->dbTableName = $table_name;
27
+ $this->dbTableChanged = false;
28
+ }
29
+
30
+ /**
31
+ * Create columns and drop excess columns
32
+ */
33
+ public function execute()
34
+ {
35
+ global $wpdb;
36
+
37
+ $query = 'SHOW COLUMNS FROM ' . $this->dbTableName;
38
+ $this->dbTableStructure = $wpdb->get_results($query, ARRAY_A);
39
+
40
+ if ($this->dbTableStructure) {
41
+ $this->addColumnsIfNotExists();
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Analise table columns, add not exists columns
47
+ */
48
+ private function addColumnsIfNotExists()
49
+ {
50
+ global $wpdb;
51
+ $wpdb->show_errors = true;
52
+ $schema_table_structure = Schema::getStructureSchemas();
53
+ $table_key = explode(Schema::getSchemaTablePrefix(), $this->dbTableName)[1];
54
+ $db_column_names = array();
55
+
56
+ // Create array of column names from DB structure
57
+ foreach ($this->dbTableStructure as $column) {
58
+ $db_column_names[] = $column['Field'];
59
+ }
60
+
61
+ // Add primary key
62
+ if (! in_array('id', $db_column_names)) {
63
+ $db_column_names[] = 'id';
64
+ $sql = "ALTER TABLE `$this->dbTableName`";
65
+ foreach ($this->dbTableStructure as $column) {
66
+ if (strtolower($column['Key']) === 'pri') {
67
+ $sql .= " DROP PRIMARY KEY,";
68
+ }
69
+ }
70
+ $sql .= " ADD COLUMN `id`";
71
+ $sql .= " " . $schema_table_structure[$table_key]['__createkey'];
72
+ $result = $wpdb->query($sql);
73
+ $this->dbTableChanged = true;
74
+ if ($result === false) {
75
+ $errors[] = "Failed.\nQuery: $wpdb->last_query\nError: $wpdb->last_error";
76
+ }
77
+ }
78
+
79
+ // Add columns
80
+ $counter = 0;
81
+ foreach ($schema_table_structure[$table_key] as $schema_column_name => $schema_column_params) {
82
+ if (! in_array($schema_column_name, $db_column_names) && $schema_column_name !== '__indexes' && $schema_column_name !== '__createkey') {
83
+ $sql = "ALTER TABLE `$this->dbTableName`";
84
+ $sql .= " ADD COLUMN $schema_column_name";
85
+ $sql .= " $schema_column_params";
86
+ if ($counter !== 0) {
87
+ $schema_prev_column_name = array_keys($schema_table_structure[$table_key])[$counter - 1];
88
+ $sql .= " AFTER $schema_prev_column_name";
89
+ }
90
+
91
+ $result = $wpdb->query($sql);
92
+ $this->dbTableChanged = true;
93
+ if ($result === false) {
94
+ $errors[] = "Failed.\nQuery: $wpdb->last_query\nError: $wpdb->last_error";
95
+ }
96
+ }
97
+ $counter++;
98
+ }
99
+
100
+ // Logging errors
101
+ if (!empty($errors)) {
102
+ apbct_log($errors);
103
+ }
104
+ }
105
+
106
+ /**
107
+ * Get information about table changes
108
+ */
109
+ public function getTableChangedStatus()
110
+ {
111
+ return $this->dbTableChanged;
112
+ }
113
+ }
lib/Cleantalk/ApbctWP/UpdatePlugin/DbTablesCreator.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Cleantalk\ApbctWP\UpdatePlugin;
4
+
5
+ use Cleantalk\Common\Schema;
6
+
7
+ class DbTablesCreator
8
+ {
9
+ /**
10
+ * Create all plugin tables from Schema
11
+ */
12
+ public function createAllTables($wpdb_prefix = '')
13
+ {
14
+ global $wpdb;
15
+ $wpdb->show_errors = true;
16
+ $db_schema = Schema::getStructureSchemas();
17
+ $schema_prefix = Schema::getSchemaTablePrefix();
18
+ $wpdb_prefix = $wpdb_prefix ?: $wpdb->prefix;
19
+
20
+ foreach ($db_schema as $table_key => $table_schema) {
21
+ $sql = 'CREATE TABLE IF NOT EXISTS `%s' . $schema_prefix . $table_key . '` (';
22
+ $sql = sprintf($sql, $wpdb_prefix);
23
+ foreach ($table_schema as $column_name => $column_params) {
24
+ if ($column_name !== '__indexes' && $column_name !== '__createkey') {
25
+ $sql .= '`' . $column_name . '` ' . $column_params . ', ';
26
+ } elseif ($column_name === '__indexes') {
27
+ $sql .= $table_schema['__indexes'];
28
+ }
29
+ }
30
+ $sql .= ');';
31
+
32
+ $result = $wpdb->query($sql);
33
+ if ($result === false) {
34
+ $errors[] = "Failed.\nQuery: $wpdb->last_query\nError: $wpdb->last_error";
35
+ }
36
+ }
37
+
38
+ // Logging errors
39
+ if (!empty($errors)) {
40
+ apbct_log($errors);
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Create Table by table name
46
+ */
47
+ public function createTable($table_name)
48
+ {
49
+ global $wpdb;
50
+ $wpdb->show_errors = true;
51
+ $db_schema = Schema::getStructureSchemas();
52
+ $schema_prefix = Schema::getSchemaTablePrefix();
53
+ $table_key = explode($schema_prefix, $table_name)[1];
54
+
55
+ $sql = 'CREATE TABLE IF NOT EXISTS `' . $table_name . '` (';
56
+ foreach ($db_schema[$table_key] as $column_name => $column_params) {
57
+ if ($column_name !== '__indexes' && $column_name !== '__createkey') {
58
+ $sql .= '`' . $column_name . '` ' . $column_params . ', ';
59
+ } elseif ($column_name === '__indexes') {
60
+ $sql .= $db_schema[$table_key]['__indexes'];
61
+ }
62
+ }
63
+ $sql .= ');';
64
+
65
+ $result = $wpdb->query($sql);
66
+ if ($result === false) {
67
+ $errors[] = "Failed.\nQuery: $wpdb->last_query\nError: $wpdb->last_error";
68
+ }
69
+
70
+ // Logging errors
71
+ if (!empty($errors)) {
72
+ apbct_log($errors);
73
+ }
74
+ }
75
+ }
lib/Cleantalk/Common/Cron.php CHANGED
@@ -162,6 +162,7 @@ abstract class Cron
162
  * @param array $params
163
  *
164
  * @return bool
 
165
  */
166
  public function updateTask($task, $handler, $period, $first_call = null, $params = array())
167
  {
162
  * @param array $params
163
  *
164
  * @return bool
165
+ * @psalm-suppress PossiblyUnusedReturnValue
166
  */
167
  public function updateTask($task, $handler, $period, $first_call = null, $params = array())
168
  {
lib/Cleantalk/Common/Schema.php CHANGED
@@ -7,81 +7,91 @@ use Exception;
7
  class Schema
8
  {
9
  /**
10
- * Set of schemas in array
 
 
 
 
 
11
  *
12
  * @var array
13
  */
14
- private static $schemas = array(
15
- 'sfw' => 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw` (
16
- `id` INT(11) NOT NULL AUTO_INCREMENT,
17
- `network` int(11) unsigned NOT NULL,
18
- `mask` int(11) unsigned NOT NULL,
19
- `status` TINYINT(1) NOT NULL DEFAULT 0,
20
- `source` TINYINT(1) NULL DEFAULT NULL,
21
- PRIMARY KEY (`id`),
22
- INDEX ( `network` , `mask` )
23
- );',
24
- 'ua_bl' => 'CREATE TABLE IF NOT EXISTS `%scleantalk_ua_bl` (
25
- `id` INT(11) NOT NULL,
26
- `ua_template` VARCHAR(255) NULL DEFAULT NULL,
27
- `ua_status` TINYINT(1) NULL DEFAULT NULL,
28
- PRIMARY KEY ( `id` ),
29
- INDEX ( `ua_template` )
30
- ) DEFAULT CHARSET=utf8;', // Don't remove the default charset!
31
- 'sfw_logs' => 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw_logs` (
32
- `id` VARCHAR(40) NOT NULL,
33
- `ip` VARCHAR(15) NOT NULL,
34
- `status` ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW__BY_WHITELIST\',\'PASS_SFW__BY_COOKIE\',\'DENY_ANTICRAWLER\',\'PASS_ANTICRAWLER\',\'DENY_ANTICRAWLER_UA\',\'PASS_ANTICRAWLER_UA\',\'DENY_ANTIFLOOD\',\'PASS_ANTIFLOOD\',\'DENY_ANTIFLOOD_UA\',\'PASS_ANTIFLOOD_UA\') NULL DEFAULT NULL,
35
- `all_entries` INT NOT NULL,
36
- `blocked_entries` INT NOT NULL,
37
- `entries_timestamp` INT NOT NULL,
38
- `ua_id` INT(11) NULL DEFAULT NULL,
39
- `ua_name` VARCHAR(1024) NOT NULL,
40
- `source` TINYINT(1) NULL DEFAULT NULL,
41
- `network` VARCHAR(20) NULL DEFAULT NULL,
42
- `first_url` VARCHAR(100) NULL DEFAULT NULL,
43
- `last_url` VARCHAR(100) NULL DEFAULT NULL,
44
- PRIMARY KEY (`id`));',
45
- 'ac_logs' => 'CREATE TABLE IF NOT EXISTS `%scleantalk_ac_log` (
46
- `id` VARCHAR(40) NOT NULL,
47
- `ip` VARCHAR(40) NOT NULL,
48
- `ua` VARCHAR(40) NOT NULL,
49
- `entries` INT DEFAULT 0,
50
- `interval_start` INT NOT NULL,
51
- PRIMARY KEY (`id`));',
52
- 'sessions' => 'CREATE TABLE IF NOT EXISTS `%scleantalk_sessions` (
53
- `id` VARCHAR(64) NOT NULL,
54
- `name` VARCHAR(40) NOT NULL,
55
- `value` TEXT NULL DEFAULT NULL,
56
- `last_update` DATETIME NULL DEFAULT NULL,
57
- PRIMARY KEY (`name`(40), `id`(64)));',
58
- 'spamscan_logs' => 'CREATE TABLE IF NOT EXISTS `%scleantalk_spamscan_logs` (
59
- `id` int(11) NOT NULL AUTO_INCREMENT,
60
- `scan_type` varchar(11) NOT NULL,
61
- `start_time` datetime NOT NULL,
62
- `finish_time` datetime NOT NULL,
63
- `count_to_scan` int(11) DEFAULT NULL,
64
- `found_spam` int(11) DEFAULT NULL,
65
- `found_bad` int(11) DEFAULT NULL,
66
- PRIMARY KEY (`id`));',
 
 
 
 
 
 
 
 
67
  );
68
 
69
  /**
70
- * @param null|string $table Name of called table
71
- *
72
- * @return array Array of schemas
73
- * @throws Exception Throws if calling un-existed schema
74
  */
75
- public static function getSchema($table = null)
76
  {
77
- if (is_null($table)) {
78
- return self::$schemas;
79
- }
80
-
81
- if (array_key_exists($table, self::$schemas)) {
82
- return array(self::$schemas[$table]);
83
- }
84
 
85
- throw new Exception('Called table scheme not exist.');
 
 
 
 
 
86
  }
87
  }
7
  class Schema
8
  {
9
  /**
10
+ * Schema table prefix
11
+ */
12
+ private static $schemaTablePrefix = 'cleantalk_';
13
+
14
+ /**
15
+ * Structure of schema
16
  *
17
  * @var array
18
  */
19
+ private static $structureSchemas = array(
20
+ 'sfw' => array(
21
+ 'id' => 'INT NOT NULL AUTO_INCREMENT',
22
+ 'network' => 'INT unsigned NOT NULL',
23
+ 'mask' => 'INT unsigned NOT NULL',
24
+ 'status' => 'TINYINT NOT NULL DEFAULT 0',
25
+ 'source' => 'TINYINT NULL DEFAULT NULL',
26
+ '__indexes' => 'PRIMARY KEY (`id`), INDEX ( `network` , `mask` )',
27
+ '__createkey' => 'INT unsigned primary KEY AUTO_INCREMENT FIRST'
28
+ ),
29
+ 'ua_bl' => array(
30
+ 'id' => 'INT NOT NULL',
31
+ 'ua_template' => 'VARCHAR(255) NULL DEFAULT NULL',
32
+ 'ua_status' => 'TINYINT NULL DEFAULT NULL',
33
+ '__indexes' => 'PRIMARY KEY ( `id` ), INDEX ( `ua_template` )',
34
+ '__createkey' => 'INT unsigned primary KEY FIRST'
35
+ ),
36
+ 'sfw_logs' => array(
37
+ 'id' => 'VARCHAR(40) NOT NULL',
38
+ 'ip' => 'VARCHAR(15) NOT NULL',
39
+ 'status' => 'ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW__BY_WHITELIST\',\'PASS_SFW__BY_COOKIE\',\'DENY_ANTICRAWLER\',\'PASS_ANTICRAWLER\',\'DENY_ANTICRAWLER_UA\',\'PASS_ANTICRAWLER_UA\',\'DENY_ANTIFLOOD\',\'PASS_ANTIFLOOD\',\'DENY_ANTIFLOOD_UA\',\'PASS_ANTIFLOOD_UA\') NULL DEFAULT NULL',
40
+ 'all_entries' => 'INT NOT NULL',
41
+ 'blocked_entries' => 'INT NOT NULL',
42
+ 'entries_timestamp' => 'INT NOT NULL',
43
+ 'ua_id' => 'INT NULL DEFAULT NULL',
44
+ 'ua_name' => 'VARCHAR(1024) NOT NULL',
45
+ 'source' => 'TINYINT NULL DEFAULT NULL',
46
+ 'network' => 'VARCHAR(20) NULL DEFAULT NULL',
47
+ 'first_url' => 'VARCHAR(100) NULL DEFAULT NULL',
48
+ 'last_url' => 'VARCHAR(100) NULL DEFAULT NULL',
49
+ '__indexes' => 'PRIMARY KEY (`id`)',
50
+ '__createkey' => 'VARCHAR(40) NOT NULL primary KEY FIRST'
51
+ ),
52
+ 'ac_log' => array(
53
+ 'id' => 'VARCHAR(40) NOT NULL',
54
+ 'ip' => 'VARCHAR(40) NOT NULL',
55
+ 'ua' => 'VARCHAR(40) NOT NULL',
56
+ 'entries' => 'INT DEFAULT 0',
57
+ 'interval_start' => 'INT NOT NULL',
58
+ '__indexes' => 'PRIMARY KEY (`id`)',
59
+ '__createkey' => 'VARCHAR(40) NOT NULL primary KEY FIRST'
60
+ ),
61
+ 'sessions' => array(
62
+ 'id' => 'VARCHAR(64) NOT NULL',
63
+ 'name' => 'VARCHAR(40) NOT NULL',
64
+ 'value' => 'TEXT NULL DEFAULT NULL',
65
+ 'last_update' => 'DATETIME NULL DEFAULT NULL',
66
+ '__indexes' => 'PRIMARY KEY (`name`(40), `id`(64))',
67
+ '__createkey' => 'VARCHAR(64) NOT NULL primary KEY FIRST'
68
+ ),
69
+ 'spamscan_logs' => array(
70
+ 'id' => 'INT NOT NULL AUTO_INCREMENT',
71
+ 'scan_type' => 'VARCHAR(11) NOT NULL',
72
+ 'start_time' => 'DATETIME NOT NULL',
73
+ 'finish_time' => 'DATETIME NOT NULL',
74
+ 'count_to_scan' => 'INT DEFAULT NULL',
75
+ 'found_spam' => 'INT DEFAULT NULL',
76
+ 'found_bad' => 'INT DEFAULT NULL',
77
+ '__indexes' => 'PRIMARY KEY (`id`)',
78
+ '__createkey' => 'INT unsigned primary KEY AUTO_INCREMENT FIRST'
79
+ ),
80
  );
81
 
82
  /**
83
+ * Return $schemaTablePrefix
 
 
 
84
  */
85
+ public static function getSchemaTablePrefix()
86
  {
87
+ return self::$schemaTablePrefix;
88
+ }
 
 
 
 
 
89
 
90
+ /**
91
+ * Return $structure_schemas
92
+ */
93
+ public static function getStructureSchemas()
94
+ {
95
+ return self::$structureSchemas;
96
  }
97
  }
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.8
6
  Requires PHP: 5.6
7
- Stable tag: 5.164.1
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
@@ -595,6 +595,41 @@ If your website has forms that send data to external sources, you can enable opt
595
 
596
  == Changelog ==
597
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
598
  = 5.164.1 Oct 21 2021 =
599
  * Fix. SFW. Incompatibility WP-Rocket notice removed.
600
 
4
  Requires at least: 3.0
5
  Tested up to: 5.8
6
  Requires PHP: 5.6
7
+ Stable tag: 5.165
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
595
 
596
  == Changelog ==
597
 
598
+ = 5.165 Nov 08 2021 =
599
+ * New: Public. Mouse moved flag implemented.
600
+ * Upd: State. Errors adding method updated.
601
+ * Upd: Settings. Errors show function updated.
602
+ * Upd: Updater. Clean errors options for new errors structure.
603
+ * Upd: Public. Cookies aggregation.
604
+ * Mod: Improving the functionality of checking comments for spam.
605
+ * Mod: CommentsChecker - updated functionality and refactoring
606
+ * Mod: merged inc/cleantalk-updater.php
607
+ * Mod: merged UpdatePlugin dir
608
+ * Mod: merged Schema.php
609
+ * Mod: merged SchemaTest.php
610
+ * Mod: merged cleantalk.php
611
+ * Mod: merged State.php, Activator.php
612
+ * Fix: SFW. Directory for FW files moved to wordpress uploads directory.
613
+ * Fix: Settings. GDPR link fixed.
614
+ * Fix: testrequesttohost error handle.
615
+ * Fix: check ctsetcookie before call.
616
+ * Fix: Settings. Save button padding fixed.
617
+ * Fix: add console.log if ctSetcookie is not defined.
618
+ * Fix: SFW. Skip if sfw not updated yet.
619
+ * Fix: change console output if apbct-public-functions.js is not loaded.
620
+ * Fix: Added secure and samesite in cookie
621
+ * Fix: Renamed field apbct_wc_honeypot to wc_apbct_email_id
622
+ * Fix.Users.Feedback about deleting user implemented.
623
+ * Fix. SFW. Deleting table fixed.
624
+ * Fix: set buffer type to string if epico theme is active.
625
+ * Fix: Integration. Jetpack contact forms hooks fixed.
626
+ * Fix: SFW. Separating the end of update stage into several stages.
627
+ * Fix: SFW. Fallback function on SFW updating errors implemented.
628
+ * Fix. Integration. WP Forms hooks fixed.
629
+ * Fix. SFW. Auto updating for new users fixed.
630
+ * Fix. Comment. Set meta fixed.
631
+ * Fix: WPMS. Settings saving fixed.
632
+
633
  = 5.164.1 Oct 21 2021 =
634
  * Fix. SFW. Incompatibility WP-Rocket notice removed.
635