Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.142

Version Description

Jul 27 2020 = * New: Bot Protection module for Firewall. * New: Anti-Crawler module for Firewall. * Mod: Improved spam Protection. * Fix: Caching plugins auto detection. * Fix: Skip Divi system fields. * Fix: Ultimate Form Builder exception. * Plenty of fixes and upgrades.

Download this release

Release Info

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

Code changes from version 5.141.3 to 5.142

Files changed (46) hide show
  1. cleantalk.php +158 -154
  2. inc/cleantalk-admin.php +10 -2
  3. inc/cleantalk-ajax.php +5 -5
  4. inc/cleantalk-common.php +17 -11
  5. inc/cleantalk-public.php +17 -10
  6. inc/cleantalk-settings.php +33 -4
  7. inc/cleantalk-updater.php +35 -15
  8. inc/find-spam/ClassCleantalkFindSpamCommentsChecker.php +1 -1
  9. inc/find-spam/ClassCleantalkFindSpamUsersChecker.php +1 -1
  10. js/cleantalk-admin-settings-page.min.js +2 -1
  11. js/cleantalk-admin-settings-page.min.js.map +1 -1
  12. lib/{Cleantalk.php → Cleantalk/Antispam/Cleantalk.php} +11 -9
  13. lib/{CleantalkRequest.php → Cleantalk/Antispam/CleantalkRequest.php} +2 -0
  14. lib/{CleantalkResponse.php → Cleantalk/Antispam/CleantalkResponse.php} +2 -0
  15. lib/Cleantalk/{DisableComments.php → Antispam/DisableComments.php} +1 -1
  16. lib/Cleantalk/Antispam/SFW.php +0 -380
  17. lib/{CleantalkAPI.php → Cleantalk/ApbctWP/API.php} +5 -3
  18. lib/{CleantalkUpgrader.php → Cleantalk/ApbctWP/CleantalkUpgrader.php} +3 -1
  19. lib/{CleantalkUpgraderSkin.php → Cleantalk/ApbctWP/CleantalkUpgraderSkin.php} +3 -1
  20. lib/{CleantalkUpgraderSkin_Deprecated.php → Cleantalk/ApbctWP/CleantalkUpgraderSkin_Deprecated.php} +3 -1
  21. lib/{CleantalkCron.php → Cleantalk/ApbctWP/Cron.php} +3 -1
  22. lib/{CleantalkDB.php → Cleantalk/ApbctWP/DB.php} +4 -2
  23. lib/Cleantalk/ApbctWP/Firewall/AntiBot.php +150 -0
  24. lib/Cleantalk/ApbctWP/Firewall/AntiCrawler.php +182 -0
  25. lib/Cleantalk/ApbctWP/Firewall/SFW.php +459 -0
  26. lib/Cleantalk/ApbctWP/Firewall/die_page__antibot.html +130 -0
  27. lib/Cleantalk/ApbctWP/Firewall/die_page__anticrawler.html +129 -0
  28. inc/sfw_die_page.html → lib/Cleantalk/ApbctWP/Firewall/die_page__sfw.html +5 -5
  29. lib/{CleantalkHelper.php → Cleantalk/ApbctWP/Helper.php} +4 -2
  30. lib/{CleantalkState.php → Cleantalk/ApbctWP/State.php} +21 -17
  31. lib/Cleantalk/{Antispam → Common}/API.php +1 -1
  32. lib/Cleantalk/{Arr.php → Common/Arr.php} +1 -1
  33. lib/Cleantalk/{Antispam → Common}/DB.php +1 -1
  34. lib/Cleantalk/Common/Firewall.php +197 -0
  35. lib/Cleantalk/Common/Firewall/FirewallModule.php +73 -0
  36. lib/Cleantalk/Common/Firewall/FirewallModule_abstract.php +52 -0
  37. lib/Cleantalk/{Antispam → Common}/Helper.php +6 -1
  38. lib/Cleantalk/{Common → Variables}/Cookie.php +3 -3
  39. lib/Cleantalk/{Common → Variables}/Get.php +3 -3
  40. lib/Cleantalk/{Common → Variables}/Post.php +3 -3
  41. lib/Cleantalk/{Common → Variables}/Request.php +3 -3
  42. lib/Cleantalk/{Common → Variables}/Server.php +2 -2
  43. lib/Cleantalk/{Common → Variables}/ServerVariables.php +3 -3
  44. lib/CleantalkSFW.php +0 -141
  45. lib/CleantalkSFW_Base.php +0 -16
  46. readme.txt +10 -1
cleantalk.php CHANGED
@@ -3,13 +3,18 @@
3
  Plugin Name: Anti-Spam by CleanTalk
4
  Plugin URI: https://cleantalk.org
5
  Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
6
- Version: 5.141.3
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
10
  Domain Path: /i18n
11
  */
12
 
 
 
 
 
 
13
  $cleantalk_executed = false;
14
 
15
  // Getting version form main file (look above)
@@ -52,30 +57,13 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
52
 
53
  // Base classes
54
  require_once(CLEANTALK_PLUGIN_DIR . 'lib/autoloader.php'); // Autoloader
55
- require_once(CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk/Antispam/API.php'); // API
56
- require_once(CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk/Antispam/DB.php'); // Database driver
57
- require_once(CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk/Antispam/Helper.php'); // Helper
58
- include_once(CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk/Antispam/SFW.php'); // SpamFireWall
59
- include_once(CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk/Arr.php'); // Array functions
60
-
61
- // Child classes
62
- require_once(CLEANTALK_PLUGIN_DIR . 'lib/CleantalkAPI.php'); // API for Wordpress
63
- require_once(CLEANTALK_PLUGIN_DIR . 'lib/CleantalkDB.php'); // Database class for Wordpress
64
- require_once(CLEANTALK_PLUGIN_DIR . 'lib/CleantalkHelper.php'); // Helper for Worpdress
65
- include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php"); // SpamFireWall for Wordpress
66
-
67
- require_once(CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk.php'); // Main class for request
68
- require_once(CLEANTALK_PLUGIN_DIR . 'lib/CleantalkRequest.php'); // Holds request data
69
- require_once(CLEANTALK_PLUGIN_DIR . 'lib/CleantalkResponse.php'); // Holds response data
70
-
71
- require_once(CLEANTALK_PLUGIN_DIR . 'lib/CleantalkCron.php'); // Cron handling
72
- require_once(CLEANTALK_PLUGIN_DIR . 'lib/CleantalkState.php'); // State class
73
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-pluggable.php'); // Pluggable functions
74
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-common.php');
75
 
76
  // Global ArrayObject with settings and other global varables
77
  global $apbct;
78
- $apbct = new CleantalkState('cleantalk', array('settings', 'data', 'debug', 'errors', 'remote_calls', 'stats'));
79
 
80
  $apbct->base_name = 'cleantalk-spam-protect/cleantalk.php';
81
 
@@ -83,7 +71,7 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
83
  $apbct->logo__small = plugin_dir_url(__FILE__) . 'inc/images/logo_small.png';
84
  $apbct->logo__small__colored = plugin_dir_url(__FILE__) . 'inc/images/logo_color.png';
85
 
86
- // Customize CleantalkState
87
  // Account status
88
 
89
  $apbct->white_label = $apbct->network_settings['white_label'];
@@ -104,9 +92,7 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
104
 
105
  // Disabling comments
106
  if($apbct->settings['disable_comments__all'] || $apbct->settings['disable_comments__posts'] || $apbct->settings['disable_comments__pages'] || $apbct->settings['disable_comments__media']){
107
- require_once(CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk/Templates/Singleton.php');
108
- require_once(CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk/DisableComments.php');
109
- \Cleantalk\DisableComments::getInstance();
110
  }
111
 
112
  // Passing JS key to frontend
@@ -120,6 +106,7 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
120
  // Database constants
121
  define('APBCT_TBL_FIREWALL_DATA', $apbct->db_prefix . 'cleantalk_sfw'); // Table with firewall data.
122
  define('APBCT_TBL_FIREWALL_LOG', $apbct->db_prefix . 'cleantalk_sfw_logs'); // Table with firewall logs.
 
123
  define('APBCT_TBL_SESSIONS', $apbct->db_prefix . 'cleantalk_sessions'); // Table with session data.
124
  define('APBCT_SPAMSCAN_LOGS', $apbct->db_prefix . 'cleantalk_spamscan_logs'); // Table with session data.
125
  define('APBCT_SELECT_LIMIT', 5000); // Select limit for logs.
@@ -135,7 +122,7 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
135
  // Self cron
136
  if(!defined('DOING_CRON') || (defined('DOING_CRON') && DOING_CRON !== true)){
137
 
138
- $ct_cron = new CleantalkCron();
139
  $ct_cron->checkTasks();
140
 
141
  if(!empty($ct_cron->tasks_to_run)){
@@ -220,7 +207,7 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
220
 
221
  // Custom register form (ticket_id=13668)
222
  add_action('website_neotrends_signup_fields_check',function( $username, $fields ){
223
- $ip = CleantalkHelper::ip__get( array('real'), false );
224
  $ct_result = ct_test_registration( $username, $fields['email'], $ip );
225
  if( $ct_result['allow'] == 0 ) {
226
  ct_die_extended( $ct_result['comment'] );
@@ -511,7 +498,7 @@ function apbct_remote_call__perform()
511
  $apbct->data['notice_trial'] = 0;
512
  $apbct->data['notice_renew'] = 0;
513
  $apbct->saveData();
514
- CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 86400);
515
  die('OK');
516
  break;
517
 
@@ -587,7 +574,7 @@ function apbct_remote_call__perform()
587
  }else
588
  die('FAIL '.json_encode(array('error' => 'UNKNOWN_ACTION')));
589
  }
590
-
591
  /**
592
  * Function for SpamFireWall check
593
  */
@@ -605,77 +592,65 @@ function apbct_sfw__check()
605
  }
606
  }
607
 
608
- // Turn off the SpamFireWall if Remote Call is in progress
609
- if($apbct->rc_running || (!empty($spbc) && $spbc->rc_running))
610
- return;
611
-
612
- $is_sfw_check = true;
613
- $sfw = new CleantalkSFW();
614
- $sfw->ip_array = (array)$sfw->ip__get(array('real'), true);
615
-
616
- // Skip by cookie
617
- foreach($sfw->ip_array as $ct_cur_ip){
618
- if(isset($_COOKIE['ct_sfw_pass_key']) && $_COOKIE['ct_sfw_pass_key'] == md5($ct_cur_ip.$apbct->api_key)){
619
- $is_sfw_check=false;
620
- if(isset($_COOKIE['ct_sfw_passed'])){
621
- $sfw->logs__update($ct_cur_ip, 'passed');
622
- $apbct->data['sfw_counter']['all']++;
623
- $apbct->saveData();
624
- if(!headers_sent())
625
- \Cleantalk\Antispam\Helper::apbct_cookie__set ('ct_sfw_passed', '0', time()+86400*3, '/', null, false, true, 'Lax' );
626
- }
627
- break;
628
- }else{
629
- $is_sfw_check = true;
630
- }
631
- }
632
-
633
  // Skip the check
634
  if(!empty($_GET['access'])){
635
  $spbc_settings = get_option('spbc_settings');
636
  $spbc_key = !empty($spbc_settings['spbc_key']) ? $spbc_settings['spbc_key'] : false;
637
  if($_GET['access'] === $apbct->api_key || ($spbc_key !== false && $_GET['access'] === $spbc_key)){
638
- $is_sfw_check = false;
639
- \Cleantalk\Antispam\Helper::apbct_cookie__set('spbc_firewall_pass_key', md5(apbct_get_server_variable( 'REMOTE_ADDR' ) . $spbc_key), time()+1200, '/', '');
640
- \Cleantalk\Antispam\Helper::apbct_cookie__set('ct_sfw_pass_key', md5(apbct_get_server_variable( 'REMOTE_ADDR' ) . $apbct->api_key), time()+1200, '/', null);
641
  }
642
  unset($spbc_settings, $spbc_key);
643
  }
644
 
645
- if($is_sfw_check){
646
-
647
- $sfw->ip_check();
648
-
649
- // Pass remote calls
650
- if($sfw->pass === false){
651
- if(isset($_GET['spbc_remote_call_token'], $_GET['spbc_remote_call_action'], $_GET['plugin_name'])){
652
- foreach($sfw->blocked_ips as $ip){
653
- $resolved = CleantalkHelper::ip__resolve($ip['ip']);
654
- if($resolved && preg_match('/cleantalk\.org/', $resolved) === 1 || $resolved === 'back'){
655
- $sfw->pass = true;
656
- }
657
- } unset($ip);
658
- }
659
- }
660
-
661
- // if($sfw->test){
662
- // $sfw->sfw_die($apbct->api_key, '', parse_url(get_option('siteurl'),PHP_URL_HOST), 'test');
663
- // }
664
-
665
- if($sfw->pass === false){
666
- foreach($sfw->blocked_ips as $ip){
667
- $sfw->logs__update($ip['ip'], 'blocked');
668
- }
669
- $apbct->data['sfw_counter']['blocked']++;
670
- $apbct->saveData();
671
- $sfw->sfw_die($apbct->api_key, '', parse_url(get_option('siteurl'),PHP_URL_HOST));
672
- }else{
673
- reset($sfw->passed_ips);
674
- if(!empty($apbct->settings['set_cookies']) && !headers_sent() && key($sfw->passed_ips))
675
- \Cleantalk\Antispam\Helper::apbct_cookie__set( 'ct_sfw_pass_key', md5( $sfw->passed_ips[ key( $sfw->passed_ips ) ]['ip'] . $apbct->api_key ), time() + 86400 * 30, '/', null, false );
676
- }
 
677
  }
678
- unset($is_sfw_check, $sfw, $sfw_ip, $ct_cur_ip);
 
 
 
 
 
 
 
 
 
 
 
 
679
  }
680
 
681
  /**
@@ -695,11 +670,20 @@ function apbct_activation( $network = false ) {
695
 
696
  // SFW log
697
  $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw_logs` (
 
698
  `ip` VARCHAR(15) NOT NULL,
 
699
  `all_entries` INT NOT NULL,
700
  `blocked_entries` INT NOT NULL,
701
  `entries_timestamp` INT NOT NULL,
702
- PRIMARY KEY (`ip`));';
 
 
 
 
 
 
 
703
 
704
  // Sessions
705
  $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sessions` (
@@ -726,25 +710,25 @@ function apbct_activation( $network = false ) {
726
  switch_to_blog($blog);
727
  apbct_activation__create_tables($sqls);
728
  // Cron tasks
729
- CleantalkCron::addTask('check_account_status', 'ct_account_status_check', 3600, time()+1800); // Checks account status
730
- CleantalkCron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time()+3500); // Formerly ct_hourly_event_hook()
731
- CleantalkCron::addTask('send_feedback', 'ct_send_feedback', 3600, time()+3500); // Formerly ct_hourly_event_hook()
732
- CleantalkCron::addTask('sfw_update', 'ct_sfw_update', 86400, time()+300); // SFW update
733
- CleantalkCron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time()+1800); // SFW send logs
734
- CleantalkCron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time()+3500); // Get data for dashboard widget
735
- CleantalkCron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time()+3500); // Send connection report to welcome@cleantalk.org
736
  }
737
  switch_to_blog($initial_blog);
738
  }else{
739
 
740
  // Cron tasks
741
- CleantalkCron::addTask('check_account_status', 'ct_account_status_check', 3600, time()+1800); // Checks account status
742
- CleantalkCron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time()+3500); // Formerly ct_hourly_event_hook()
743
- CleantalkCron::addTask('send_feedback', 'ct_send_feedback', 3600, time()+3500); // Formerly ct_hourly_event_hook()
744
- CleantalkCron::addTask('sfw_update', 'ct_sfw_update', 86400, time()+43200); // SFW update
745
- CleantalkCron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time()+1800); // SFW send logs
746
- CleantalkCron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time()+3500); // Get data for dashboard widget
747
- CleantalkCron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time()+3500); // Send connection report to welcome@cleantalk.org
748
 
749
  apbct_activation__create_tables($sqls);
750
  ct_account_status_check(null, false);
@@ -786,14 +770,23 @@ function apbct_activation__new_blog($blog_id, $user_id, $domain, $path, $site_id
786
  `mask` int(11) unsigned NOT NULL,
787
  INDEX ( `network` , `mask` )
788
  );';
789
-
790
- // SFW log
791
- $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw_logs` (
792
- `ip` VARCHAR(15) NOT NULL,
793
- `all_entries` INT NOT NULL,
794
- `blocked_entries` INT NOT NULL,
795
- `entries_timestamp` INT NOT NULL,
796
- PRIMARY KEY (`ip`));';
 
 
 
 
 
 
 
 
 
797
 
798
  // Sessions
799
  $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sessions` (
@@ -814,13 +807,13 @@ function apbct_activation__new_blog($blog_id, $user_id, $domain, $path, $site_id
814
  PRIMARY KEY (`id`));';
815
 
816
  // Cron tasks
817
- CleantalkCron::addTask('check_account_status', 'ct_account_status_check', 3600, time()+1800); // Checks account status
818
- CleantalkCron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time()+3500); // Formerly ct_hourly_event_hook()
819
- CleantalkCron::addTask('send_feedback', 'ct_send_feedback', 3600, time()+3500); // Formerly ct_hourly_event_hook()
820
- CleantalkCron::addTask('sfw_update', 'ct_sfw_update', 86400, time()+43200); // SFW update
821
- CleantalkCron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time()+1800); // SFW send logs
822
- CleantalkCron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time()+3500); // Get data for dashboard widget
823
- CleantalkCron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time()+3500); // Send connection report to welcome@cleantalk.org
824
  apbct_activation__create_tables($sqls);
825
  ct_sfw_update(); // Updating SFW
826
  ct_account_status_check(null, false);
@@ -910,6 +903,7 @@ function apbct_deactivation__delete_common_tables() {
910
  global $wpdb;
911
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_sfw`;'); // Deleting SFW data
912
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_sfw_logs`;'); // Deleting SFW logs
 
913
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_sessions`;'); // Deleting session table
914
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_spamscan_logs`;'); // Deleting user/comments scan result table
915
  }
@@ -917,7 +911,8 @@ function apbct_deactivation__delete_common_tables() {
917
  function apbct_deactivation__delete_blog_tables() {
918
  global $wpdb;
919
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_sfw`;'); // Deleting SFW data
920
- $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_sfw_logs`;'); // Deleting SFW logs
 
921
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_sessions`;'); // Deleting session table
922
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_spamscan_logs`;'); // Deleting user/comments scan result table
923
  }
@@ -997,9 +992,7 @@ function ct_sfw_update($api_key = '', $immediate = false){
997
  $api_key = !empty($apbct->api_key) ? $apbct->api_key : $api_key;
998
 
999
  if( $apbct->settings['spam_firewall'] == 1 && ( ! empty($api_key) || $apbct->data['moderate_ip'] ) ) {
1000
-
1001
- $sfw = new CleantalkSFW();
1002
-
1003
  $file_urls = isset($_GET['file_urls']) ? urldecode( $_GET['file_urls'] ) : null;
1004
  $file_urls = isset($file_urls) ? explode(',', $file_urls) : null;
1005
 
@@ -1008,8 +1001,14 @@ function ct_sfw_update($api_key = '', $immediate = false){
1008
  //Reset previous entries count
1009
  $apbct->stats['sfw']['entries'] = 0;
1010
  $apbct->save('stats');
1011
-
1012
- $sfw->sfw_update($api_key, null, $immediate);
 
 
 
 
 
 
1013
 
1014
  return ! empty( $result['error'] )
1015
  ? $result
@@ -1017,7 +1016,13 @@ function ct_sfw_update($api_key = '', $immediate = false){
1017
 
1018
  }elseif( is_array( $file_urls ) && count( $file_urls ) ){
1019
 
1020
- $result = $sfw->sfw_update($api_key, $file_urls[0], $immediate);
 
 
 
 
 
 
1021
 
1022
  if( empty( $result['error'] ) ){
1023
 
@@ -1028,7 +1033,7 @@ function ct_sfw_update($api_key = '', $immediate = false){
1028
  $apbct->save('stats');
1029
 
1030
  if (count($file_urls)) {
1031
- CleantalkHelper::http__request(
1032
  get_option('siteurl'),
1033
  array(
1034
  'spbc_remote_call_token' => md5($api_key),
@@ -1042,6 +1047,8 @@ function ct_sfw_update($api_key = '', $immediate = false){
1042
  //Files array is empty update sfw time
1043
  $apbct->stats['sfw']['last_update_time'] = time();
1044
  $apbct->save('stats');
 
 
1045
 
1046
  return $result;
1047
  }
@@ -1062,13 +1069,17 @@ function ct_sfw_send_logs($api_key = '')
1062
 
1063
  if( $apbct->settings['spam_firewall'] == 1 && ( ! empty($api_key) || $apbct->data['moderate_ip'] ) ) {
1064
 
1065
- $sfw = new CleantalkSFW();
1066
- $result = $sfw->logs__send($api_key);
 
 
 
1067
 
1068
  if(empty($result['error'])){
1069
  $apbct->stats['sfw']['last_send_time'] = time();
1070
  $apbct->stats['sfw']['last_send_amount'] = $result['rows'];
1071
  $apbct->save('stats');
 
1072
  }
1073
 
1074
  return $result;
@@ -1083,7 +1094,7 @@ function ct_sfw_send_logs($api_key = '')
1083
  *
1084
  * @param string $action What you want to do?
1085
  * @param array $additional_params Additional GET parameters for RC
1086
- * @param string $presets Presets for CleantalkHelper::http__request(). 'async' maybe?
1087
  * @param string $plugin_name Plugin name 'antispam' by default
1088
  * @param string $call_token RC securirty token
1089
  * @param string $url Current site URL by default
@@ -1103,7 +1114,7 @@ function apbct_rc__send($action, $additional_params = array(), $presets = 'get',
1103
  $params = array_merge($additional_params, $default_params);
1104
 
1105
  return apbct_rc__parse_result(
1106
- CleantalkHelper::http__request(
1107
  $url ? $url : get_option('siteurl'),
1108
  $params,
1109
  $presets
@@ -1165,13 +1176,10 @@ function apbct_rc__install_plugin($wp = null, $plugin = null){
1165
  include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
1166
  include_once( ABSPATH . 'wp-admin/includes/file.php' );
1167
  include_once( ABSPATH . 'wp-admin/includes/misc.php' );
1168
- include_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkUpgrader.php' );
1169
 
1170
  if (version_compare(PHP_VERSION, '5.6.0') >= 0 && version_compare($wp_version, '5.3') >= 0) {
1171
- include_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkUpgraderSkin.php' );
1172
  $installer= new CleantalkUpgrader( new CleantalkUpgraderSkin() );
1173
  } else {
1174
- include_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkUpgraderSkin_Deprecated.php' );
1175
  $installer= new CleantalkUpgrader( new CleantalkUpgraderSkin_Deprecated() );
1176
  }
1177
 
@@ -1329,15 +1337,11 @@ function apbct_rc__update(){
1329
  include_once( ABSPATH . 'wp-admin/includes/file.php' );
1330
  include_once( ABSPATH . 'wp-admin/includes/misc.php' );
1331
 
1332
- include_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkUpgrader.php' );
1333
-
1334
  apbct_maintance_mode__enable( 30 );
1335
 
1336
  if (version_compare(PHP_VERSION, '5.6.0') >= 0 && version_compare($wp_version, '5.3') >= 0){
1337
- include_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkUpgraderSkin.php' );
1338
  $upgrader = new CleantalkUpgrader( new CleantalkUpgraderSkin( compact('title', 'nonce', 'url', 'plugin') ) );
1339
  }else{
1340
- include_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkUpgraderSkin_Deprecated.php' );
1341
  $upgrader = new CleantalkUpgrader( new CleantalkUpgraderSkin_Deprecated( compact('title', 'nonce', 'url', 'plugin') ) );
1342
  }
1343
 
@@ -1357,7 +1361,7 @@ function apbct_rc__update(){
1357
  die('FAIL '. json_encode(array('error' => 'COULD_NOT_ACTIVATE', 'wp_error' => $result->get_error_message())));
1358
  }
1359
 
1360
- $httpResponseCode = CleantalkHelper::http__request(get_option('siteurl'), array(), 'get_code');
1361
 
1362
  if( strpos($httpResponseCode, '200') === false ){
1363
 
@@ -1429,7 +1433,7 @@ function apbct_rc__insert_auth_key($key, $plugin){
1429
 
1430
  if($key && preg_match('/^[a-z\d]{3,15}$/', $key)){
1431
 
1432
- $result = CleantalkAPI::method__notice_paid_till(
1433
  $key,
1434
  preg_replace('/http[s]?:\/\//', '', get_option('siteurl'), 1), // Site URL
1435
  'security'
@@ -1504,7 +1508,7 @@ function cleantalk_get_brief_data(){
1504
 
1505
  global $apbct;
1506
 
1507
- $apbct->data['brief_data'] = CleantalkAPI::method__get_antispam_report_breif($apbct->api_key);
1508
  $apbct->saveData();
1509
 
1510
  return;
@@ -1517,7 +1521,7 @@ function apbct__hook__wp_logout__delete_trial_notice_cookie(){
1517
  }
1518
 
1519
  function apbct_alt_session__id__get(){
1520
- $id = CleantalkHelper::ip__get(array('real'))
1521
  .apbct_get_server_variable( 'HTTP_USER_AGENT' )
1522
  .apbct_get_server_variable( 'HTTP_ACCEPT_LANGUAGE' );
1523
  return hash('sha256', $id);
@@ -1603,7 +1607,7 @@ function apbct_store__urls(){
1603
  // Saving
1604
  $apbct->settings['store_urls__sessions']
1605
  ? apbct_alt_session__save('apbct_urls', json_encode($urls))
1606
- : \Cleantalk\Antispam\Helper::apbct_cookie__set('apbct_urls', json_encode($urls), time()+86400*3, '/', parse_url(get_option('siteurl'),PHP_URL_HOST), false, true, 'Lax');
1607
 
1608
  // REFERER
1609
  // Get current fererer
@@ -1620,7 +1624,7 @@ function apbct_store__urls(){
1620
 
1621
  $apbct->settings['store_urls__sessions']
1622
  ? apbct_alt_session__save('apbct_site_referer', $new_site_referer)
1623
- : \Cleantalk\Antispam\Helper::apbct_cookie__set('apbct_site_referer', $new_site_referer, time()+86400*3, '/', parse_url(get_option('siteurl'),PHP_URL_HOST), false, true, 'Lax');
1624
  }
1625
 
1626
  $apbct->flags__url_stored = true;
@@ -1630,7 +1634,7 @@ function apbct_store__urls(){
1630
 
1631
  /**
1632
  * Universal method to adding cookies.
1633
- * Use \Cleantalk\Antispam\Helper::apbct_cookie__set() instead.
1634
  * @deprecated
1635
  */
1636
  function apbct_cookie__set($name, $value = '', $expires = 0, $path = '', $domain = null, $secure = false, $httponly = false, $samesite = 'Lax' ){
@@ -1702,7 +1706,7 @@ function apbct_cookie(){
1702
  $apbct_timestamp = time();
1703
  $apbct->settings['set_cookies__sessions']
1704
  ? apbct_alt_session__save('apbct_timestamp', $apbct_timestamp)
1705
- : \Cleantalk\Antispam\Helper::apbct_cookie__set('apbct_timestamp', $apbct_timestamp, 0, '/', $domain, false, true, 'Lax' );
1706
  $cookie_test_value['cookies_names'][] = 'apbct_timestamp';
1707
  $cookie_test_value['check_value'] .= $apbct_timestamp;
1708
  }
@@ -1711,7 +1715,7 @@ function apbct_cookie(){
1711
  if(apbct_get_server_variable( 'HTTP_REFERER' )){
1712
  $apbct->settings['set_cookies__sessions']
1713
  ? apbct_alt_session__save('apbct_prev_referer', apbct_get_server_variable( 'HTTP_REFERER' ))
1714
- : \Cleantalk\Antispam\Helper::apbct_cookie__set('apbct_prev_referer', apbct_get_server_variable( 'HTTP_REFERER' ), 0, '/', $domain, false, true, 'Lax' );
1715
  $cookie_test_value['cookies_names'][] = 'apbct_prev_referer';
1716
  $cookie_test_value['check_value'] .= apbct_get_server_variable( 'HTTP_REFERER' );
1717
  }
@@ -1724,7 +1728,7 @@ function apbct_cookie(){
1724
  $site_landing_timestamp = time();
1725
  $apbct->settings['set_cookies__sessions']
1726
  ? apbct_alt_session__save('apbct_site_landing_ts', $site_landing_timestamp)
1727
- : \Cleantalk\Antispam\Helper::apbct_cookie__set('apbct_site_landing_ts', $site_landing_timestamp, 0, '/', $domain, false, true, 'Lax' );
1728
  }
1729
  $cookie_test_value['cookies_names'][] = 'apbct_site_landing_ts';
1730
  $cookie_test_value['check_value'] .= $site_landing_timestamp;
@@ -1739,7 +1743,7 @@ function apbct_cookie(){
1739
 
1740
  $apbct->settings['set_cookies__sessions']
1741
  ? apbct_alt_session__save('apbct_page_hits', $page_hits)
1742
- : \Cleantalk\Antispam\Helper::apbct_cookie__set('apbct_page_hits', $page_hits, 0, '/', $domain, false, true, 'Lax' );
1743
 
1744
  $cookie_test_value['cookies_names'][] = 'apbct_page_hits';
1745
  $cookie_test_value['check_value'] .= $page_hits;
@@ -1747,7 +1751,7 @@ function apbct_cookie(){
1747
  // Cookies test
1748
  $cookie_test_value['check_value'] = md5($cookie_test_value['check_value']);
1749
  if(!$apbct->settings['set_cookies__sessions'])
1750
- \Cleantalk\Antispam\Helper::apbct_cookie__set('apbct_cookies_test', urlencode(json_encode($cookie_test_value)), 0, '/', $domain, false, true, 'Lax' );
1751
 
1752
  $apbct->flags__cookies_setuped = true;
1753
 
@@ -1826,7 +1830,7 @@ function ct_account_status_check($api_key = null, $process_errors = true){
1826
  global $apbct;
1827
 
1828
  $api_key = $api_key ? $api_key : $apbct->api_key;
1829
- $result = CleantalkAPI::method__notice_paid_till(
1830
  $api_key,
1831
  preg_replace('/http[s]?:\/\//', '', get_option('siteurl'), 1),
1832
  ! is_main_site() && $apbct->white_label ? 'anti-spam-hosting' : 'antispam'
@@ -1853,7 +1857,7 @@ function ct_account_status_check($api_key = null, $process_errors = true){
1853
  $apbct->data['license_trial'] = isset($result['license_trial']) ? (int)$result['license_trial'] : 0;
1854
  $apbct->data['account_name_ob'] = isset($result['account_name_ob']) ? (string)$result['account_name_ob'] : '';
1855
 
1856
- CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 86400);
1857
 
1858
  $apbct->error_delete('account_check', 'save');
1859
 
@@ -2028,7 +2032,7 @@ function apbct_statistics__rotate($exec_time){
2028
  /**
2029
  * Runs update actions for new version.
2030
  *
2031
- * @global CleantalkState $apbct
2032
  */
2033
  function apbct_update_actions(){
2034
 
@@ -2064,7 +2068,7 @@ function apbct_update_actions(){
2064
  * @param string $ver
2065
  *
2066
  * @return bool
2067
- * @global CleantalkState $apbct
2068
  *
2069
  */
2070
  function apbct_update__set_version__from_plugin($ver){
3
  Plugin Name: Anti-Spam by CleanTalk
4
  Plugin URI: https://cleantalk.org
5
  Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
6
+ Version: 5.142
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
10
  Domain Path: /i18n
11
  */
12
 
13
+ use Cleantalk\ApbctWP\CleantalkUpgrader;
14
+ use Cleantalk\ApbctWP\CleantalkUpgraderSkin;
15
+ use Cleantalk\ApbctWP\CleantalkUpgraderSkin_Deprecated;
16
+ use Cleantalk\ApbctWP\Cron;
17
+
18
  $cleantalk_executed = false;
19
 
20
  // Getting version form main file (look above)
57
 
58
  // Base classes
59
  require_once(CLEANTALK_PLUGIN_DIR . 'lib/autoloader.php'); // Autoloader
60
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-pluggable.php'); // Pluggable functions
62
  require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-common.php');
63
 
64
  // Global ArrayObject with settings and other global varables
65
  global $apbct;
66
+ $apbct = new \Cleantalk\ApbctWP\State('cleantalk', array('settings', 'data', 'debug', 'errors', 'remote_calls', 'stats'));
67
 
68
  $apbct->base_name = 'cleantalk-spam-protect/cleantalk.php';
69
 
71
  $apbct->logo__small = plugin_dir_url(__FILE__) . 'inc/images/logo_small.png';
72
  $apbct->logo__small__colored = plugin_dir_url(__FILE__) . 'inc/images/logo_color.png';
73
 
74
+ // Customize \Cleantalk\ApbctWP\State
75
  // Account status
76
 
77
  $apbct->white_label = $apbct->network_settings['white_label'];
92
 
93
  // Disabling comments
94
  if($apbct->settings['disable_comments__all'] || $apbct->settings['disable_comments__posts'] || $apbct->settings['disable_comments__pages'] || $apbct->settings['disable_comments__media']){
95
+ \Cleantalk\Antispam\DisableComments::getInstance();
 
 
96
  }
97
 
98
  // Passing JS key to frontend
106
  // Database constants
107
  define('APBCT_TBL_FIREWALL_DATA', $apbct->db_prefix . 'cleantalk_sfw'); // Table with firewall data.
108
  define('APBCT_TBL_FIREWALL_LOG', $apbct->db_prefix . 'cleantalk_sfw_logs'); // Table with firewall logs.
109
+ define('APBCT_TBL_AC_LOG', $apbct->db_prefix . 'cleantalk_ac_log'); // Table with firewall logs.
110
  define('APBCT_TBL_SESSIONS', $apbct->db_prefix . 'cleantalk_sessions'); // Table with session data.
111
  define('APBCT_SPAMSCAN_LOGS', $apbct->db_prefix . 'cleantalk_spamscan_logs'); // Table with session data.
112
  define('APBCT_SELECT_LIMIT', 5000); // Select limit for logs.
122
  // Self cron
123
  if(!defined('DOING_CRON') || (defined('DOING_CRON') && DOING_CRON !== true)){
124
 
125
+ $ct_cron = new Cron();
126
  $ct_cron->checkTasks();
127
 
128
  if(!empty($ct_cron->tasks_to_run)){
207
 
208
  // Custom register form (ticket_id=13668)
209
  add_action('website_neotrends_signup_fields_check',function( $username, $fields ){
210
+ $ip = \Cleantalk\ApbctWP\Helper::ip__get( array('real'), false );
211
  $ct_result = ct_test_registration( $username, $fields['email'], $ip );
212
  if( $ct_result['allow'] == 0 ) {
213
  ct_die_extended( $ct_result['comment'] );
498
  $apbct->data['notice_trial'] = 0;
499
  $apbct->data['notice_renew'] = 0;
500
  $apbct->saveData();
501
+ Cron::updateTask('check_account_status', 'ct_account_status_check', 86400);
502
  die('OK');
503
  break;
504
 
574
  }else
575
  die('FAIL '.json_encode(array('error' => 'UNKNOWN_ACTION')));
576
  }
577
+
578
  /**
579
  * Function for SpamFireWall check
580
  */
592
  }
593
  }
594
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
595
  // Skip the check
596
  if(!empty($_GET['access'])){
597
  $spbc_settings = get_option('spbc_settings');
598
  $spbc_key = !empty($spbc_settings['spbc_key']) ? $spbc_settings['spbc_key'] : false;
599
  if($_GET['access'] === $apbct->api_key || ($spbc_key !== false && $_GET['access'] === $spbc_key)){
600
+ \Cleantalk\Common\Helper::apbct_cookie__set('spbc_firewall_pass_key', md5(apbct_get_server_variable( 'REMOTE_ADDR' ) . $spbc_key), time()+1200, '/', '');
601
+ \Cleantalk\Common\Helper::apbct_cookie__set('ct_sfw_pass_key', md5(apbct_get_server_variable( 'REMOTE_ADDR' ) . $apbct->api_key), time()+1200, '/', null);
602
+ return;
603
  }
604
  unset($spbc_settings, $spbc_key);
605
  }
606
 
607
+ // Turn off the SpamFireWall if Remote Call is in progress
608
+ if($apbct->rc_running || (!empty($spbc) && $spbc->rc_running))
609
+ return;
610
+
611
+ $fw_init_options = array(
612
+ 'set_cookies' => $apbct->settings['set_cookies']
613
+ );
614
+
615
+ $firewall = new \Cleantalk\Common\Firewall(
616
+ \Cleantalk\ApbctWP\DB::getInstance()
617
+ );
618
+
619
+ $firewall->load_fw_module( new \Cleantalk\ApbctWP\Firewall\SFW(
620
+ defined( 'APBCT_TBL_FIREWALL_LOG' ) ? APBCT_TBL_FIREWALL_LOG : $this->db->prefix . 'cleantalk_sfw_logs',
621
+ defined( 'APBCT_TBL_FIREWALL_DATA' ) ? APBCT_TBL_FIREWALL_DATA : $this->db->prefix . 'cleantalk_sfw',
622
+ array(
623
+ 'sfw_counter' => $apbct->settings['sfw_counter'],
624
+ 'api_key' => $apbct->api_key,
625
+ 'apbct' => $apbct,
626
+ 'cookie_domain' => parse_url( get_option( 'siteurl' ), PHP_URL_HOST ),
627
+ 'set_cookies' => $apbct->settings['set_cookies'],
628
+ )
629
+ ) );
630
+
631
+ if( $apbct->settings['sfw__bot_protection']){
632
+ $firewall->load_fw_module( new \Cleantalk\ApbctWP\Firewall\AntiBot(
633
+ defined( 'APBCT_TBL_FIREWALL_LOG' ) ? APBCT_TBL_FIREWALL_LOG : $this->db->prefix . 'cleantalk_sfw_logs',
634
+ defined( 'APBCT_TBL_AC_LOG' ) ? APBCT_TBL_AC_LOG : $this->db->prefix . 'cleantalk_ac_log',
635
+ array(
636
+ 'api_key' => $apbct->api_key,
637
+ 'apbct' => $apbct,
638
+ )
639
+ ) );
640
  }
641
+
642
+ if( $apbct->settings['sfw__anti_crawler'])
643
+ $firewall->load_fw_module( new \Cleantalk\ApbctWP\Firewall\AntiCrawler(
644
+ defined( 'APBCT_TBL_FIREWALL_LOG' ) ? APBCT_TBL_FIREWALL_LOG : $this->db->prefix . 'cleantalk_sfw_logs',
645
+ defined( 'APBCT_TBL_AC_LOG' ) ? APBCT_TBL_AC_LOG : $this->db->prefix . 'cleantalk_ac_log',
646
+ array(
647
+ 'view_limit' => $apbct->settings['sfw__anti_crawler__view_limit'],
648
+ 'apbct' => $apbct,
649
+ )
650
+ ) );
651
+
652
+ $firewall->run();
653
+
654
  }
655
 
656
  /**
670
 
671
  // SFW log
672
  $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw_logs` (
673
+ `id` VARCHAR(40) NOT NULL,
674
  `ip` VARCHAR(15) NOT NULL,
675
+ `status` ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW_BY_WHITELIST\',\'PASS_SFW_BY_COOKIE\',\'DENY_ANTIBOT\',\'DENY_ANTICRAWLER\') NULL DEFAULT NULL,
676
  `all_entries` INT NOT NULL,
677
  `blocked_entries` INT NOT NULL,
678
  `entries_timestamp` INT NOT NULL,
679
+ PRIMARY KEY (`id`));';
680
+
681
+ $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_ac_log` (
682
+ `id` VARCHAR(40) NOT NULL,
683
+ `ip` VARCHAR(40) NOT NULL,
684
+ `entries` INT DEFAULT 0,
685
+ `interval_start` INT NOT NULL,
686
+ PRIMARY KEY (`id`));';
687
 
688
  // Sessions
689
  $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sessions` (
710
  switch_to_blog($blog);
711
  apbct_activation__create_tables($sqls);
712
  // Cron tasks
713
+ Cron::addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // Checks account status
714
+ Cron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
715
+ Cron::addTask('send_feedback', 'ct_send_feedback', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
716
+ Cron::addTask('sfw_update', 'ct_sfw_update', 86400, time() + 300); // SFW update
717
+ Cron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time() + 1800); // SFW send logs
718
+ Cron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
719
+ Cron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
720
  }
721
  switch_to_blog($initial_blog);
722
  }else{
723
 
724
  // Cron tasks
725
+ Cron::addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // Checks account status
726
+ Cron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
727
+ Cron::addTask('send_feedback', 'ct_send_feedback', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
728
+ Cron::addTask('sfw_update', 'ct_sfw_update', 86400, time() + 43200); // SFW update
729
+ Cron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time() + 1800); // SFW send logs
730
+ Cron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
731
+ Cron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
732
 
733
  apbct_activation__create_tables($sqls);
734
  ct_account_status_check(null, false);
770
  `mask` int(11) unsigned NOT NULL,
771
  INDEX ( `network` , `mask` )
772
  );';
773
+
774
+ // SFW log
775
+ $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sfw_logs` (
776
+ `id` VARCHAR(40) NOT NULL,
777
+ `ip` VARCHAR(15) NOT NULL,
778
+ `status` ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW_BY_WHITELIST\',\'PASS_SFW_BY_COOKIE\',\'DENY_ANTIBOT\',\'DENY_ANTICRAWLER\') NULL DEFAULT NULL,
779
+ `all_entries` INT NOT NULL,
780
+ `blocked_entries` INT NOT NULL,
781
+ `entries_timestamp` INT NOT NULL,
782
+ PRIMARY KEY (`id`));';
783
+
784
+ $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_ac_log` (
785
+ `id` VARCHAR(40) NOT NULL,
786
+ `ip` VARCHAR(40) NOT NULL,
787
+ `entries` INT DEFAULT 0,
788
+ `interval_start` INT NOT NULL,
789
+ PRIMARY KEY (`id`));';
790
 
791
  // Sessions
792
  $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_sessions` (
807
  PRIMARY KEY (`id`));';
808
 
809
  // Cron tasks
810
+ Cron::addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // Checks account status
811
+ Cron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
812
+ Cron::addTask('send_feedback', 'ct_send_feedback', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
813
+ Cron::addTask('sfw_update', 'ct_sfw_update', 86400, time() + 43200); // SFW update
814
+ Cron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time() + 1800); // SFW send logs
815
+ Cron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
816
+ Cron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
817
  apbct_activation__create_tables($sqls);
818
  ct_sfw_update(); // Updating SFW
819
  ct_account_status_check(null, false);
903
  global $wpdb;
904
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_sfw`;'); // Deleting SFW data
905
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_sfw_logs`;'); // Deleting SFW logs
906
+ $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_ac_log`;'); // Deleting SFW logs
907
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_sessions`;'); // Deleting session table
908
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_spamscan_logs`;'); // Deleting user/comments scan result table
909
  }
911
  function apbct_deactivation__delete_blog_tables() {
912
  global $wpdb;
913
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_sfw`;'); // Deleting SFW data
914
+ $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_sfw_logs`;'); // Deleting SFW logs
915
+ $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_ac_log`;'); // Deleting SFW logs
916
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_sessions`;'); // Deleting session table
917
  $wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_spamscan_logs`;'); // Deleting user/comments scan result table
918
  }
992
  $api_key = !empty($apbct->api_key) ? $apbct->api_key : $api_key;
993
 
994
  if( $apbct->settings['spam_firewall'] == 1 && ( ! empty($api_key) || $apbct->data['moderate_ip'] ) ) {
995
+
 
 
996
  $file_urls = isset($_GET['file_urls']) ? urldecode( $_GET['file_urls'] ) : null;
997
  $file_urls = isset($file_urls) ? explode(',', $file_urls) : null;
998
 
1001
  //Reset previous entries count
1002
  $apbct->stats['sfw']['entries'] = 0;
1003
  $apbct->save('stats');
1004
+
1005
+ $result = \Cleantalk\ApbctWP\Firewall\SFW::update(
1006
+ \Cleantalk\ApbctWP\DB::getInstance(),
1007
+ defined( 'APBCT_TBL_FIREWALL_DATA' ) ? APBCT_TBL_FIREWALL_DATA : $this->db->prefix . 'cleantalk_sfw',
1008
+ $api_key,
1009
+ null,
1010
+ $immediate
1011
+ );
1012
 
1013
  return ! empty( $result['error'] )
1014
  ? $result
1016
 
1017
  }elseif( is_array( $file_urls ) && count( $file_urls ) ){
1018
 
1019
+ $result = \Cleantalk\ApbctWP\Firewall\SFW::update(
1020
+ \Cleantalk\ApbctWP\DB::getInstance(),
1021
+ defined( 'APBCT_TBL_FIREWALL_DATA' ) ? APBCT_TBL_FIREWALL_DATA : $this->db->prefix . 'cleantalk_sfw',
1022
+ $api_key,
1023
+ $file_urls[0],
1024
+ $immediate
1025
+ );
1026
 
1027
  if( empty( $result['error'] ) ){
1028
 
1033
  $apbct->save('stats');
1034
 
1035
  if (count($file_urls)) {
1036
+ \Cleantalk\ApbctWP\Helper::http__request(
1037
  get_option('siteurl'),
1038
  array(
1039
  'spbc_remote_call_token' => md5($api_key),
1047
  //Files array is empty update sfw time
1048
  $apbct->stats['sfw']['last_update_time'] = time();
1049
  $apbct->save('stats');
1050
+ // Delete update errors
1051
+ $apbct->error_delete( 'sfw_update', 'save_settings' );
1052
 
1053
  return $result;
1054
  }
1069
 
1070
  if( $apbct->settings['spam_firewall'] == 1 && ( ! empty($api_key) || $apbct->data['moderate_ip'] ) ) {
1071
 
1072
+ $result = \Cleantalk\ApbctWP\Firewall\SFW::send_log(
1073
+ \Cleantalk\ApbctWP\DB::getInstance(),
1074
+ defined('APBCT_TBL_FIREWALL_LOG') ? APBCT_TBL_FIREWALL_LOG : $this->db->prefix . 'cleantalk_sfw_logs',
1075
+ $api_key
1076
+ );
1077
 
1078
  if(empty($result['error'])){
1079
  $apbct->stats['sfw']['last_send_time'] = time();
1080
  $apbct->stats['sfw']['last_send_amount'] = $result['rows'];
1081
  $apbct->save('stats');
1082
+ $apbct->error_delete( 'sfw_send_logs', 'save_settings' );
1083
  }
1084
 
1085
  return $result;
1094
  *
1095
  * @param string $action What you want to do?
1096
  * @param array $additional_params Additional GET parameters for RC
1097
+ * @param string $presets Presets for \Cleantalk\ApbctWP\Helper::http__request(). 'async' maybe?
1098
  * @param string $plugin_name Plugin name 'antispam' by default
1099
  * @param string $call_token RC securirty token
1100
  * @param string $url Current site URL by default
1114
  $params = array_merge($additional_params, $default_params);
1115
 
1116
  return apbct_rc__parse_result(
1117
+ \Cleantalk\ApbctWP\Helper::http__request(
1118
  $url ? $url : get_option('siteurl'),
1119
  $params,
1120
  $presets
1176
  include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
1177
  include_once( ABSPATH . 'wp-admin/includes/file.php' );
1178
  include_once( ABSPATH . 'wp-admin/includes/misc.php' );
 
1179
 
1180
  if (version_compare(PHP_VERSION, '5.6.0') >= 0 && version_compare($wp_version, '5.3') >= 0) {
 
1181
  $installer= new CleantalkUpgrader( new CleantalkUpgraderSkin() );
1182
  } else {
 
1183
  $installer= new CleantalkUpgrader( new CleantalkUpgraderSkin_Deprecated() );
1184
  }
1185
 
1337
  include_once( ABSPATH . 'wp-admin/includes/file.php' );
1338
  include_once( ABSPATH . 'wp-admin/includes/misc.php' );
1339
 
 
 
1340
  apbct_maintance_mode__enable( 30 );
1341
 
1342
  if (version_compare(PHP_VERSION, '5.6.0') >= 0 && version_compare($wp_version, '5.3') >= 0){
 
1343
  $upgrader = new CleantalkUpgrader( new CleantalkUpgraderSkin( compact('title', 'nonce', 'url', 'plugin') ) );
1344
  }else{
 
1345
  $upgrader = new CleantalkUpgrader( new CleantalkUpgraderSkin_Deprecated( compact('title', 'nonce', 'url', 'plugin') ) );
1346
  }
1347
 
1361
  die('FAIL '. json_encode(array('error' => 'COULD_NOT_ACTIVATE', 'wp_error' => $result->get_error_message())));
1362
  }
1363
 
1364
+ $httpResponseCode = \Cleantalk\ApbctWP\Helper::http__request(get_option('siteurl'), array(), 'get_code');
1365
 
1366
  if( strpos($httpResponseCode, '200') === false ){
1367
 
1433
 
1434
  if($key && preg_match('/^[a-z\d]{3,15}$/', $key)){
1435
 
1436
+ $result = \Cleantalk\ApbctWP\API::method__notice_paid_till(
1437
  $key,
1438
  preg_replace('/http[s]?:\/\//', '', get_option('siteurl'), 1), // Site URL
1439
  'security'
1508
 
1509
  global $apbct;
1510
 
1511
+ $apbct->data['brief_data'] = \Cleantalk\ApbctWP\API::method__get_antispam_report_breif($apbct->api_key);
1512
  $apbct->saveData();
1513
 
1514
  return;
1521
  }
1522
 
1523
  function apbct_alt_session__id__get(){
1524
+ $id = \Cleantalk\ApbctWP\Helper::ip__get(array('real'))
1525
  .apbct_get_server_variable( 'HTTP_USER_AGENT' )
1526
  .apbct_get_server_variable( 'HTTP_ACCEPT_LANGUAGE' );
1527
  return hash('sha256', $id);
1607
  // Saving
1608
  $apbct->settings['store_urls__sessions']
1609
  ? apbct_alt_session__save('apbct_urls', json_encode($urls))
1610
+ : \Cleantalk\Common\Helper::apbct_cookie__set('apbct_urls', json_encode($urls), time()+86400*3, '/', parse_url(get_option('siteurl'),PHP_URL_HOST), false, true, 'Lax');
1611
 
1612
  // REFERER
1613
  // Get current fererer
1624
 
1625
  $apbct->settings['store_urls__sessions']
1626
  ? apbct_alt_session__save('apbct_site_referer', $new_site_referer)
1627
+ : \Cleantalk\Common\Helper::apbct_cookie__set('apbct_site_referer', $new_site_referer, time()+86400*3, '/', parse_url(get_option('siteurl'),PHP_URL_HOST), false, true, 'Lax');
1628
  }
1629
 
1630
  $apbct->flags__url_stored = true;
1634
 
1635
  /**
1636
  * Universal method to adding cookies.
1637
+ * Use \Cleantalk\Common\Helper::apbct_cookie__set() instead.
1638
  * @deprecated
1639
  */
1640
  function apbct_cookie__set($name, $value = '', $expires = 0, $path = '', $domain = null, $secure = false, $httponly = false, $samesite = 'Lax' ){
1706
  $apbct_timestamp = time();
1707
  $apbct->settings['set_cookies__sessions']
1708
  ? apbct_alt_session__save('apbct_timestamp', $apbct_timestamp)
1709
+ : \Cleantalk\Common\Helper::apbct_cookie__set('apbct_timestamp', $apbct_timestamp, 0, '/', $domain, false, true, 'Lax' );
1710
  $cookie_test_value['cookies_names'][] = 'apbct_timestamp';
1711
  $cookie_test_value['check_value'] .= $apbct_timestamp;
1712
  }
1715
  if(apbct_get_server_variable( 'HTTP_REFERER' )){
1716
  $apbct->settings['set_cookies__sessions']
1717
  ? apbct_alt_session__save('apbct_prev_referer', apbct_get_server_variable( 'HTTP_REFERER' ))
1718
+ : \Cleantalk\Common\Helper::apbct_cookie__set('apbct_prev_referer', apbct_get_server_variable( 'HTTP_REFERER' ), 0, '/', $domain, false, true, 'Lax' );
1719
  $cookie_test_value['cookies_names'][] = 'apbct_prev_referer';
1720
  $cookie_test_value['check_value'] .= apbct_get_server_variable( 'HTTP_REFERER' );
1721
  }
1728
  $site_landing_timestamp = time();
1729
  $apbct->settings['set_cookies__sessions']
1730
  ? apbct_alt_session__save('apbct_site_landing_ts', $site_landing_timestamp)
1731
+ : \Cleantalk\Common\Helper::apbct_cookie__set('apbct_site_landing_ts', $site_landing_timestamp, 0, '/', $domain, false, true, 'Lax' );
1732
  }
1733
  $cookie_test_value['cookies_names'][] = 'apbct_site_landing_ts';
1734
  $cookie_test_value['check_value'] .= $site_landing_timestamp;
1743
 
1744
  $apbct->settings['set_cookies__sessions']
1745
  ? apbct_alt_session__save('apbct_page_hits', $page_hits)
1746
+ : \Cleantalk\Common\Helper::apbct_cookie__set('apbct_page_hits', $page_hits, 0, '/', $domain, false, true, 'Lax' );
1747
 
1748
  $cookie_test_value['cookies_names'][] = 'apbct_page_hits';
1749
  $cookie_test_value['check_value'] .= $page_hits;
1751
  // Cookies test
1752
  $cookie_test_value['check_value'] = md5($cookie_test_value['check_value']);
1753
  if(!$apbct->settings['set_cookies__sessions'])
1754
+ \Cleantalk\Common\Helper::apbct_cookie__set('apbct_cookies_test', urlencode(json_encode($cookie_test_value)), 0, '/', $domain, false, true, 'Lax' );
1755
 
1756
  $apbct->flags__cookies_setuped = true;
1757
 
1830
  global $apbct;
1831
 
1832
  $api_key = $api_key ? $api_key : $apbct->api_key;
1833
+ $result = \Cleantalk\ApbctWP\API::method__notice_paid_till(
1834
  $api_key,
1835
  preg_replace('/http[s]?:\/\//', '', get_option('siteurl'), 1),
1836
  ! is_main_site() && $apbct->white_label ? 'anti-spam-hosting' : 'antispam'
1857
  $apbct->data['license_trial'] = isset($result['license_trial']) ? (int)$result['license_trial'] : 0;
1858
  $apbct->data['account_name_ob'] = isset($result['account_name_ob']) ? (string)$result['account_name_ob'] : '';
1859
 
1860
+ Cron::updateTask('check_account_status', 'ct_account_status_check', 86400);
1861
 
1862
  $apbct->error_delete('account_check', 'save');
1863
 
2032
  /**
2033
  * Runs update actions for new version.
2034
  *
2035
+ * @global \Cleantalk\ApbctWP\State $apbct
2036
  */
2037
  function apbct_update_actions(){
2038
 
2068
  * @param string $ver
2069
  *
2070
  * @return bool
2071
+ * @global \Cleantalk\ApbctWP\State $apbct
2072
  *
2073
  */
2074
  function apbct_update__set_version__from_plugin($ver){
inc/cleantalk-admin.php CHANGED
@@ -7,7 +7,15 @@ add_action( 'manage_comments_nav', 'apbct_add_buttons_to_comments_and_users', 10
7
  add_action( 'manage_users_extra_tablenav', 'apbct_add_buttons_to_comments_and_users', 10, 1 );
8
 
9
  // Check renew banner
10
- add_action( 'wp_ajax_apbct_settings__check_renew_banner', 'apbct_settings__check_renew_banner');
 
 
 
 
 
 
 
 
11
 
12
  function apbct_add_buttons_to_comments_and_users( $unused_argument ) {
13
 
@@ -176,7 +184,7 @@ function apbct_admin__init(){
176
 
177
  // Getting dashboard widget statistics
178
  if(!empty($_POST['ct_brief_refresh'])){
179
- $apbct->data['brief_data'] = CleantalkAPI::method__get_antispam_report_breif($apbct->api_key);
180
  $apbct->saveData();
181
  }
182
 
7
  add_action( 'manage_users_extra_tablenav', 'apbct_add_buttons_to_comments_and_users', 10, 1 );
8
 
9
  // Check renew banner
10
+ add_action( 'wp_ajax_apbct_settings__check_renew_banner', 'apbct_settings__check_renew_banner');
11
+
12
+ // Crunch for Anti-Bot
13
+ add_action( 'admin_head', array( '\Cleantalk\ApbctWP\Firewall\AntiBot', 'set_cookie' ) );
14
+
15
+ function apbct_admin_set_cookie_for_anti_bot(){
16
+ global $apbct;
17
+ echo '<script>document.cookie = "apbct_antibot=' . md5( $apbct->api_key . \Cleantalk\ApbctWP\Helper::ip__get(array('real'), true ) ) . '; path=/; expires=0; samesite=lax";</script>';
18
+ }
19
 
20
  function apbct_add_buttons_to_comments_and_users( $unused_argument ) {
21
 
184
 
185
  // Getting dashboard widget statistics
186
  if(!empty($_POST['ct_brief_refresh'])){
187
+ $apbct->data['brief_data'] = \Cleantalk\ApbctWP\API::method__get_antispam_report_breif($apbct->api_key);
188
  $apbct->saveData();
189
  }
190
 
inc/cleantalk-ajax.php CHANGED
@@ -384,10 +384,10 @@ function ct_ajax_hook($message_obj = false, $additional = false)
384
  $post_info['comment_type'] = 'order';
385
  }
386
  //Easy Forms for Mailchimp
387
- if( \Cleantalk\Common\Post::get('action') == 'process_form_submission' ){
388
  $post_info['comment_type'] = 'contact_enquire_wordpress_easy_forms_for_mailchimp';
389
- if( \Cleantalk\Common\Post::get('form_data') ) {
390
- $form_data = explode( '&', urldecode( \Cleantalk\Common\Post::get('form_data') ) );
391
  $form_data_arr = array();
392
  foreach ( $form_data as $val ) {
393
  $form_data_element = explode( '=', $val );
@@ -759,7 +759,7 @@ function ct_ajax_hook($message_obj = false, $additional = false)
759
  die(json_encode(array( 'apbct' => array(
760
  'blocked' => true,
761
  'comment' => $ct_result->comment,
762
- 'stop_script' => \Cleantalk\Common\Post::has_string('action', 'tve_leads_ajax_')
763
  ? 1
764
  : 0
765
  ))));
@@ -772,7 +772,7 @@ function ct_ajax_hook($message_obj = false, $additional = false)
772
  return $message_obj;
773
  }
774
  // Force AJAX check
775
- if( \Cleantalk\Common\Post::get('action') == 'cleantalk_force_ajax_check' ){
776
  die(json_encode(array( 'apbct' => array(
777
  'blocked' => false,
778
  'allow' => true,
384
  $post_info['comment_type'] = 'order';
385
  }
386
  //Easy Forms for Mailchimp
387
+ if( \Cleantalk\Variables\Post::get('action') == 'process_form_submission' ){
388
  $post_info['comment_type'] = 'contact_enquire_wordpress_easy_forms_for_mailchimp';
389
+ if( \Cleantalk\Variables\Post::get('form_data') ) {
390
+ $form_data = explode( '&', urldecode( \Cleantalk\Variables\Post::get('form_data') ) );
391
  $form_data_arr = array();
392
  foreach ( $form_data as $val ) {
393
  $form_data_element = explode( '=', $val );
759
  die(json_encode(array( 'apbct' => array(
760
  'blocked' => true,
761
  'comment' => $ct_result->comment,
762
+ 'stop_script' => \Cleantalk\Variables\Post::has_string('action', 'tve_leads_ajax_')
763
  ? 1
764
  : 0
765
  ))));
772
  return $message_obj;
773
  }
774
  // Force AJAX check
775
+ if( \Cleantalk\Variables\Post::get('action') == 'cleantalk_force_ajax_check' ){
776
  die(json_encode(array( 'apbct' => array(
777
  'blocked' => false,
778
  'allow' => true,
inc/cleantalk-common.php CHANGED
@@ -1,7 +1,11 @@
1
  <?php
2
 
 
 
 
 
3
  function apbct_array( $array ){
4
- return new Cleantalk\Arr( $array );
5
  }
6
 
7
  $ct_checkjs_frm = 'ct_checkjs_frm';
@@ -85,7 +89,7 @@ function apbct_base_call($params = array(), $reg_flag = false){
85
  $cleantalk_executed = true;
86
 
87
  $sender_info = !empty($params['sender_info'])
88
- ? CleantalkHelper::array_merge__save_numeric_keys__recursive(apbct_get_sender_info(), (array)$params['sender_info'])
89
  : apbct_get_sender_info();
90
 
91
  // Fields exclusions
@@ -107,9 +111,9 @@ function apbct_base_call($params = array(), $reg_flag = false){
107
  $default_params = array(
108
 
109
  // IPs
110
- 'sender_ip' => defined('CT_TEST_IP') ? CT_TEST_IP : (isset($params['sender_ip']) ? $params['sender_ip'] : CleantalkHelper::ip__get(array('real'), false)),
111
- 'x_forwarded_for' => CleantalkHelper::ip__get(array('x_forwarded_for'), false),
112
- 'x_real_ip' => CleantalkHelper::ip__get(array('x_real_ip'), false),
113
 
114
  // Misc
115
  'auth_key' => $apbct->api_key,
@@ -125,7 +129,7 @@ function apbct_base_call($params = array(), $reg_flag = false){
125
  $default_params['sender_info']['server_info'] = $_SERVER;
126
 
127
  $ct_request = new CleantalkRequest(
128
- CleantalkHelper::array_merge__save_numeric_keys__recursive($default_params, $params)
129
  );
130
 
131
  $ct = new Cleantalk();
@@ -242,7 +246,7 @@ function apbct_exclusions_check($func = null){
242
  }
243
 
244
  function apbct_exclusions_check__url__reversed(){
245
- return defined( 'APBCT_URL_EXCLUSIONS__REVERSED' ) && ! \Cleantalk\Common\Server::has_string( 'REQUEST_URI', APBCT_URL_EXCLUSIONS__REVERSED )
246
  ? false
247
  : true;
248
  }
@@ -289,7 +293,7 @@ function apbct_exclusions_check__ip(){
289
 
290
  if( apbct_get_server_variable( 'REMOTE_ADDR' ) ){
291
 
292
- if( CleantalkHelper::ip__is_cleantalks( apbct_get_server_variable( 'REMOTE_ADDR' ) ) ){
293
  return true;
294
  }
295
 
@@ -352,7 +356,7 @@ function apbct_get_sender_info() {
352
  : (array)json_decode(filter_input(INPUT_COOKIE, 'apbct_urls'), true);
353
 
354
  return array(
355
- 'remote_addr' => CleantalkHelper::ip__get(array('remote_addr'), false),
356
  'REFFERRER' => apbct_get_server_variable( 'HTTP_REFERER' ),
357
  'USER_AGENT' => apbct_get_server_variable( 'HTTP_USER_AGENT' ),
358
  'page_url' => apbct_get_server_variable( 'SERVER_NAME' ) . apbct_get_server_variable( 'REQUEST_URI' ),
@@ -525,9 +529,9 @@ function apbct_is_cache_plugins_exists(){
525
  defined('WPCACHEHOME') || // WP Super Cache
526
  defined('WPHB_VERSION') || // Hummingbird – Speed up, Cache, Optimize Your CSS and JS
527
  defined('CE_FILE') || // Cache Enabler – WordPress Cache
528
- class_exists('RedisObjectCache') || // Redis Object Cache
529
  defined('SiteGround_Optimizer\VERSION') || // SG Optimizer
530
- class_exists('WP_Rest_Cache_Plugin\Includes\Plugin'); // WP REST Cache
531
  }
532
 
533
  /**
@@ -757,6 +761,8 @@ function ct_get_fields_any($arr, $message=array(), $email = null, $nickname = ar
757
  'ebd_downloads_',
758
  'ecole_origine',
759
  'signature',
 
 
760
  );
761
 
762
  // Reset $message if we have a sign-up data
1
  <?php
2
 
3
+ use Cleantalk\Antispam\Cleantalk;
4
+ use Cleantalk\Antispam\CleantalkRequest;
5
+ use Cleantalk\Antispam\CleantalkResponse;
6
+
7
  function apbct_array( $array ){
8
+ return new \Cleantalk\Common\Arr( $array );
9
  }
10
 
11
  $ct_checkjs_frm = 'ct_checkjs_frm';
89
  $cleantalk_executed = true;
90
 
91
  $sender_info = !empty($params['sender_info'])
92
+ ? \Cleantalk\ApbctWP\Helper::array_merge__save_numeric_keys__recursive(apbct_get_sender_info(), (array)$params['sender_info'])
93
  : apbct_get_sender_info();
94
 
95
  // Fields exclusions
111
  $default_params = array(
112
 
113
  // IPs
114
+ 'sender_ip' => defined('CT_TEST_IP') ? CT_TEST_IP : (isset($params['sender_ip']) ? $params['sender_ip'] : \Cleantalk\ApbctWP\Helper::ip__get(array('real'), false)),
115
+ 'x_forwarded_for' => \Cleantalk\ApbctWP\Helper::ip__get(array('x_forwarded_for'), false),
116
+ 'x_real_ip' => \Cleantalk\ApbctWP\Helper::ip__get(array('x_real_ip'), false),
117
 
118
  // Misc
119
  'auth_key' => $apbct->api_key,
129
  $default_params['sender_info']['server_info'] = $_SERVER;
130
 
131
  $ct_request = new CleantalkRequest(
132
+ \Cleantalk\ApbctWP\Helper::array_merge__save_numeric_keys__recursive($default_params, $params)
133
  );
134
 
135
  $ct = new Cleantalk();
246
  }
247
 
248
  function apbct_exclusions_check__url__reversed(){
249
+ return defined( 'APBCT_URL_EXCLUSIONS__REVERSED' ) && ! \Cleantalk\Variables\Server::has_string( 'REQUEST_URI', APBCT_URL_EXCLUSIONS__REVERSED )
250
  ? false
251
  : true;
252
  }
293
 
294
  if( apbct_get_server_variable( 'REMOTE_ADDR' ) ){
295
 
296
+ if( \Cleantalk\ApbctWP\Helper::ip__is_cleantalks( apbct_get_server_variable( 'REMOTE_ADDR' ) ) ){
297
  return true;
298
  }
299
 
356
  : (array)json_decode(filter_input(INPUT_COOKIE, 'apbct_urls'), true);
357
 
358
  return array(
359
+ 'remote_addr' => \Cleantalk\ApbctWP\Helper::ip__get(array('remote_addr'), false),
360
  'REFFERRER' => apbct_get_server_variable( 'HTTP_REFERER' ),
361
  'USER_AGENT' => apbct_get_server_variable( 'HTTP_USER_AGENT' ),
362
  'page_url' => apbct_get_server_variable( 'SERVER_NAME' ) . apbct_get_server_variable( 'REQUEST_URI' ),
529
  defined('WPCACHEHOME') || // WP Super Cache
530
  defined('WPHB_VERSION') || // Hummingbird – Speed up, Cache, Optimize Your CSS and JS
531
  defined('CE_FILE') || // Cache Enabler – WordPress Cache
532
+ class_exists('\RedisObjectCache') || // Redis Object Cache
533
  defined('SiteGround_Optimizer\VERSION') || // SG Optimizer
534
+ class_exists('\WP_Rest_Cache_Plugin\Includes\Plugin'); // WP REST Cache
535
  }
536
 
537
  /**
761
  'ebd_downloads_',
762
  'ecole_origine',
763
  'signature',
764
+ // Ultimate Form Builder
765
+ 'form_data_%d_name',
766
  );
767
 
768
  // Reset $message if we have a sign-up data
inc/cleantalk-public.php CHANGED
@@ -1420,7 +1420,7 @@ function ct_preprocess_comment($comment) {
1420
  // Change mail notification if license is out of date
1421
  if($apbct->data['moderate'] == 0){
1422
  $apbct->sender_email = $comment['comment_author_email'];
1423
- $apbct->sender_ip = CleantalkHelper::ip__get(array('real'));
1424
  add_filter('comment_moderation_text', 'apbct_comment__Wordpress__changeMailNotification', 100, 2); // Comment sent to moderation
1425
  add_filter('comment_notification_text', 'apbct_comment__Wordpress__changeMailNotification', 100, 2); // Comment approved
1426
  }
@@ -1984,7 +1984,7 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
1984
  ($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
1985
  ){
1986
  $apbct->sender_email = $user_email;
1987
- $apbct->sender_ip = CleantalkHelper::ip__get(array('real'));
1988
  add_filter('wp_new_user_notification_email_admin', 'apbct_registration__Wordpress__changeMailNotification', 100, 3);
1989
  }
1990
 
@@ -2017,8 +2017,8 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
2017
 
2018
  } else {
2019
  if ($ct_result->id !== null) {
2020
- \Cleantalk\Antispam\Helper::apbct_cookie__set($apbct_cookie_register_ok_label, $ct_result->id, time()+10, '/');
2021
- \Cleantalk\Antispam\Helper::apbct_cookie__set($apbct_cookie_request_id_label, $ct_result->id, time()+10, '/');
2022
  }
2023
  }
2024
 
@@ -2148,7 +2148,7 @@ function apbct_user_register($user_id) {
2148
  global $apbct_cookie_request_id_label;
2149
  if (isset($_COOKIE[$apbct_cookie_request_id_label])) {
2150
  if(update_user_meta($user_id, 'ct_hash', $_COOKIE[$apbct_cookie_request_id_label])){
2151
- \Cleantalk\Antispam\Helper::apbct_cookie__set($apbct_cookie_request_id_label, '0', 1, '/');
2152
  }
2153
  }
2154
  }
@@ -2371,7 +2371,7 @@ function apbct_form__contactForm7__testSpam($param) {
2371
  ($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
2372
  ){
2373
  $apbct->sender_email = $sender_email;
2374
- $apbct->sender_ip = CleantalkHelper::ip__get(array('real'));
2375
  add_filter('wpcf7_mail_components', 'apbct_form__contactForm7__changeMailNotification');
2376
  }
2377
 
@@ -2484,7 +2484,7 @@ function apbct_form__ninjaForms__testSpam() {
2484
  ($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
2485
  ){
2486
  $apbct->sender_email = $sender_email;
2487
- $apbct->sender_ip = CleantalkHelper::ip__get(array('real'));
2488
  add_filter('ninja_forms_action_email_message', 'apbct_form__ninjaForms__changeMailNotification', 1, 3);
2489
  }
2490
 
@@ -2726,7 +2726,7 @@ function apbct_form__WPForms__testSpam() {
2726
  ($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
2727
  ){
2728
  $apbct->sender_email = $sender_email;
2729
- $apbct->sender_ip = CleantalkHelper::ip__get(array('real'));
2730
  add_filter('wpforms_email_message', 'apbct_form__WPForms__changeMailNotification', 100, 2);
2731
  }
2732
 
@@ -2944,7 +2944,7 @@ function ct_check_wplp(){
2944
  $cleantalk_comment = 'OK';
2945
  }
2946
 
2947
- \Cleantalk\Antispam\Helper::apbct_cookie__set($ct_wplp_result_label, $cleantalk_comment, strtotime("+5 seconds"), '/');
2948
  } else {
2949
  // Next POST/AJAX submit(s) of same WPLP form
2950
  $cleantalk_comment = $_COOKIE[$ct_wplp_result_label];
@@ -3347,7 +3347,14 @@ function ct_contact_form_validate() {
3347
  }
3348
  }
3349
  }
3350
-
 
 
 
 
 
 
 
3351
  $post_info['comment_type'] = 'feedback_general_contact_form';
3352
 
3353
  $ct_temp_msg_data = ct_get_fields_any($_POST);
1420
  // Change mail notification if license is out of date
1421
  if($apbct->data['moderate'] == 0){
1422
  $apbct->sender_email = $comment['comment_author_email'];
1423
+ $apbct->sender_ip = \Cleantalk\ApbctWP\Helper::ip__get(array('real'));
1424
  add_filter('comment_moderation_text', 'apbct_comment__Wordpress__changeMailNotification', 100, 2); // Comment sent to moderation
1425
  add_filter('comment_notification_text', 'apbct_comment__Wordpress__changeMailNotification', 100, 2); // Comment approved
1426
  }
1984
  ($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
1985
  ){
1986
  $apbct->sender_email = $user_email;
1987
+ $apbct->sender_ip = \Cleantalk\ApbctWP\Helper::ip__get(array('real'));
1988
  add_filter('wp_new_user_notification_email_admin', 'apbct_registration__Wordpress__changeMailNotification', 100, 3);
1989
  }
1990
 
2017
 
2018
  } else {
2019
  if ($ct_result->id !== null) {
2020
+ \Cleantalk\Common\Helper::apbct_cookie__set($apbct_cookie_register_ok_label, $ct_result->id, time()+10, '/');
2021
+ \Cleantalk\Common\Helper::apbct_cookie__set($apbct_cookie_request_id_label, $ct_result->id, time()+10, '/');
2022
  }
2023
  }
2024
 
2148
  global $apbct_cookie_request_id_label;
2149
  if (isset($_COOKIE[$apbct_cookie_request_id_label])) {
2150
  if(update_user_meta($user_id, 'ct_hash', $_COOKIE[$apbct_cookie_request_id_label])){
2151
+ \Cleantalk\Common\Helper::apbct_cookie__set($apbct_cookie_request_id_label, '0', 1, '/');
2152
  }
2153
  }
2154
  }
2371
  ($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
2372
  ){
2373
  $apbct->sender_email = $sender_email;
2374
+ $apbct->sender_ip = \Cleantalk\ApbctWP\Helper::ip__get(array('real'));
2375
  add_filter('wpcf7_mail_components', 'apbct_form__contactForm7__changeMailNotification');
2376
  }
2377
 
2484
  ($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
2485
  ){
2486
  $apbct->sender_email = $sender_email;
2487
+ $apbct->sender_ip = \Cleantalk\ApbctWP\Helper::ip__get(array('real'));
2488
  add_filter('ninja_forms_action_email_message', 'apbct_form__ninjaForms__changeMailNotification', 1, 3);
2489
  }
2490
 
2726
  ($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
2727
  ){
2728
  $apbct->sender_email = $sender_email;
2729
+ $apbct->sender_ip = \Cleantalk\ApbctWP\Helper::ip__get(array('real'));
2730
  add_filter('wpforms_email_message', 'apbct_form__WPForms__changeMailNotification', 100, 2);
2731
  }
2732
 
2944
  $cleantalk_comment = 'OK';
2945
  }
2946
 
2947
+ \Cleantalk\Common\Helper::apbct_cookie__set($ct_wplp_result_label, $cleantalk_comment, strtotime("+5 seconds"), '/');
2948
  } else {
2949
  // Next POST/AJAX submit(s) of same WPLP form
2950
  $cleantalk_comment = $_COOKIE[$ct_wplp_result_label];
3347
  }
3348
  }
3349
  }
3350
+ //Skip system fields for divi
3351
+ if (strpos($param, 'et_pb_contactform_submit') === 0) {
3352
+ foreach ($_POST as $key => $value) {
3353
+ if (strpos($key, 'et_pb_contact_email_fields') === 0) {
3354
+ unset($_POST[$key]);
3355
+ }
3356
+ }
3357
+ }
3358
  $post_info['comment_type'] = 'feedback_general_contact_form';
3359
 
3360
  $ct_temp_msg_data = ct_get_fields_any($_POST);
inc/cleantalk-settings.php CHANGED
@@ -95,6 +95,22 @@ function apbct_settings__set_fileds( $fields ){
95
  'type' => 'checkbox',
96
  'title' => __('SpamFireWall', 'cleantalk-spam-protect'),
97
  'description' => __("This option allows to filter spam bots before they access website. Also reduces CPU usage on hosting server and accelerates pages load time.", 'cleantalk-spam-protect'),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  ),
99
  ),
100
  ),
@@ -418,6 +434,13 @@ function apbct_settings__set_fileds( $fields ){
418
  'options_callback_params' => array(true),
419
  'class' => 'apbct_settings-field_wrapper--sub',
420
  ),
 
 
 
 
 
 
 
421
  'complete_deactivation' => array(
422
  'type' => 'checkbox',
423
  'title' => __('Complete deactivation', 'cleantalk-spam-protect'),
@@ -1150,6 +1173,7 @@ function apbct_settings__field__draw($params = array()){
1150
  .($value == '1' ? ' checked' : '')
1151
  .$disabled
1152
  .($params['required'] ? ' required="required"' : '')
 
1153
  .' onchange="'
1154
  . ($params['childrens'] ? ' apbctSettingsDependencies(\''. $childrens .'\');' : '')
1155
  . ($params['hide'] ? ' apbct_show_hide_elem(\''. $hide . '\');' : '')
@@ -1278,7 +1302,7 @@ function apbct_settings__field__draw($params = array()){
1278
  /**
1279
  * Admin callback function - Plugin parameters validator
1280
  *
1281
- * @global CleantalkState $apbct
1282
  * @param array $settings Array with passed settings
1283
  * @return array Array with processed settings
1284
  */
@@ -1309,6 +1333,11 @@ function apbct_settings__validate($settings) {
1309
  }
1310
  } unset($setting, $value);
1311
 
 
 
 
 
 
1312
  // Validating API key
1313
  $settings['apikey'] = !empty($settings['apikey']) ? trim($settings['apikey']) : '';
1314
  $settings['apikey'] = defined( 'CLEANTALK_ACCESS_KEY') ? CLEANTALK_ACCESS_KEY : $settings['apikey'];
@@ -1372,14 +1401,14 @@ function apbct_settings__validate($settings) {
1372
 
1373
  $website = parse_url(get_option('siteurl'), PHP_URL_HOST).parse_url(get_option('siteurl'), PHP_URL_PATH);
1374
  $platform = 'wordpress';
1375
- $user_ip = CleantalkHelper::ip__get(array('real'), false);
1376
  $timezone = filter_input(INPUT_POST, 'ct_admin_timezone');
1377
  $language = apbct_get_server_variable( 'HTTP_ACCEPT_LANGUAGE' );
1378
  $wpms = APBCT_WPMS && defined('SUBDOMAIN_INSTALL') && !SUBDOMAIN_INSTALL ? true : false;
1379
  $white_label = $apbct->network_settings['white_label'] ? 1 : 0;
1380
  $hoster_api_key = $apbct->network_settings['white_label__hoster_key'] ? $apbct->network_settings['white_label__hoster_key'] : '';
1381
 
1382
- $result = CleantalkAPI::method__get_api_key(
1383
  ! is_main_site() && $apbct->white_label ? 'anti-spam-hosting' : 'antispam',
1384
  ct_get_admin_email(),
1385
  $website,
@@ -1439,7 +1468,7 @@ function apbct_settings__validate($settings) {
1439
  $apbct->error_add('sfw_send_logs', $result['error']);
1440
  }
1441
  // Updating brief data for dashboard widget
1442
- $apbct->data['brief_data'] = CleantalkAPI::method__get_antispam_report_breif($settings['apikey']);
1443
 
1444
  // Key is not valid
1445
  }else{
95
  'type' => 'checkbox',
96
  'title' => __('SpamFireWall', 'cleantalk-spam-protect'),
97
  'description' => __("This option allows to filter spam bots before they access website. Also reduces CPU usage on hosting server and accelerates pages load time.", 'cleantalk-spam-protect'),
98
+ 'childrens' => array('sfw__anti_crawler', 'sfw__bot_protection'),
99
+ ),
100
+ 'sfw__anti_crawler' => array(
101
+ 'type' => 'checkbox',
102
+ 'title' => __('Bot Protection', 'cleantalk-spam-protect'),
103
+ 'class' => 'apbct_settings-field_wrapper--sub',
104
+ 'parent' => 'spam_firewall',
105
+ 'childrens' => array('sfw__anti_crawler__view_limit',),
106
+ 'description' => __('Shows SpamFireWall page for bot which are trying to scan your website. Look for the page limit setting below.', 'cleantalk-spam-protect'),
107
+ ),
108
+ 'sfw__bot_protection' => array(
109
+ 'type' => 'checkbox',
110
+ 'title' => __('Anti-Crawler', 'cleantalk-spam-protect'),
111
+ 'class' => 'apbct_settings-field_wrapper--sub',
112
+ 'parent' => 'spam_firewall',
113
+ 'description' => __('Plugin shows SpamFireWall stop page for any bot, except allowed bots (Google, Yahoo and etc).', 'cleantalk-spam-protect'),
114
  ),
115
  ),
116
  ),
434
  'options_callback_params' => array(true),
435
  'class' => 'apbct_settings-field_wrapper--sub',
436
  ),
437
+ 'sfw__anti_crawler__view_limit' => array(
438
+ 'type' => 'text',
439
+ 'title' => __('Bot Protection Page Views Limit', 'cleantalk-spam-protect'),
440
+ 'class' => 'apbct_settings-field_wrapper',
441
+ 'parent' => 'sfw__anti_crawler',
442
+ 'description' => __('Count of page view per 1 minute before plugin shows SpamFireWall page. SpamFireWall page active for 30 second after that valid visitor (with JavaScript) passes the page to the demanded page of the site.', 'cleantalk-spam-protect'),
443
+ ),
444
  'complete_deactivation' => array(
445
  'type' => 'checkbox',
446
  'title' => __('Complete deactivation', 'cleantalk-spam-protect'),
1173
  .($value == '1' ? ' checked' : '')
1174
  .$disabled
1175
  .($params['required'] ? ' required="required"' : '')
1176
+ .($params['childrens'] ? ' apbct_children="'. $childrens .'"' : '')
1177
  .' onchange="'
1178
  . ($params['childrens'] ? ' apbctSettingsDependencies(\''. $childrens .'\');' : '')
1179
  . ($params['hide'] ? ' apbct_show_hide_elem(\''. $hide . '\');' : '')
1302
  /**
1303
  * Admin callback function - Plugin parameters validator
1304
  *
1305
+ * @global \Cleantalk\ApbctWP\State $apbct
1306
  * @param array $settings Array with passed settings
1307
  * @return array Array with processed settings
1308
  */
1333
  }
1334
  } unset($setting, $value);
1335
 
1336
+ //Sanitizing sfw__anti_crawler__view_limit setting
1337
+ $settings['sfw__anti_crawler__view_limit'] = floor( intval( $settings['sfw__anti_crawler__view_limit'] ) );
1338
+ $settings['sfw__anti_crawler__view_limit'] = ( $settings['sfw__anti_crawler__view_limit'] == 0 ? 10 : $settings['sfw__anti_crawler__view_limit'] ); // Default if 0 passed
1339
+ $settings['sfw__anti_crawler__view_limit'] = ( $settings['sfw__anti_crawler__view_limit'] < 5 ? 5 : $settings['sfw__anti_crawler__view_limit'] ); //
1340
+
1341
  // Validating API key
1342
  $settings['apikey'] = !empty($settings['apikey']) ? trim($settings['apikey']) : '';
1343
  $settings['apikey'] = defined( 'CLEANTALK_ACCESS_KEY') ? CLEANTALK_ACCESS_KEY : $settings['apikey'];
1401
 
1402
  $website = parse_url(get_option('siteurl'), PHP_URL_HOST).parse_url(get_option('siteurl'), PHP_URL_PATH);
1403
  $platform = 'wordpress';
1404
+ $user_ip = \Cleantalk\ApbctWP\Helper::ip__get(array('real'), false);
1405
  $timezone = filter_input(INPUT_POST, 'ct_admin_timezone');
1406
  $language = apbct_get_server_variable( 'HTTP_ACCEPT_LANGUAGE' );
1407
  $wpms = APBCT_WPMS && defined('SUBDOMAIN_INSTALL') && !SUBDOMAIN_INSTALL ? true : false;
1408
  $white_label = $apbct->network_settings['white_label'] ? 1 : 0;
1409
  $hoster_api_key = $apbct->network_settings['white_label__hoster_key'] ? $apbct->network_settings['white_label__hoster_key'] : '';
1410
 
1411
+ $result = \Cleantalk\ApbctWP\API::method__get_api_key(
1412
  ! is_main_site() && $apbct->white_label ? 'anti-spam-hosting' : 'antispam',
1413
  ct_get_admin_email(),
1414
  $website,
1468
  $apbct->error_add('sfw_send_logs', $result['error']);
1469
  }
1470
  // Updating brief data for dashboard widget
1471
+ $apbct->data['brief_data'] = \Cleantalk\ApbctWP\API::method__get_antispam_report_breif($settings['apikey']);
1472
 
1473
  // Key is not valid
1474
  }else{
inc/cleantalk-updater.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
  function apbct_run_update_actions($current_version, $new_version){
4
 
5
  $current_version = apbct_version_standartization($current_version);
@@ -88,15 +90,15 @@ function apbct_update_to_5_70_0(){
88
  wp_clear_scheduled_hook('cleantalk_get_brief_data_hook');
89
 
90
  // Adding Self cron system tasks
91
- CleantalkCron::addTask('check_account_status', 'ct_account_status_check', 3600, time()+1800); // New
92
- CleantalkCron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time()+3500);
93
- CleantalkCron::addTask('send_feedback', 'ct_send_feedback', 3600, time()+3500);
94
- CleantalkCron::addTask('sfw_update', 'ct_sfw_update', 86400, time()+43200);
95
- CleantalkCron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time()+1800); // New
96
- CleantalkCron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time()+3500);
97
  }
98
  function apbct_update_to_5_74_0(){
99
- CleantalkCron::removeTask('send_daily_request');
100
  }
101
 
102
  function apbct_update_to_5_97_0(){
@@ -135,13 +137,13 @@ function apbct_update_to_5_109_0(){
135
  $wpdb->query(sprintf($sfw_data_query, $wpdb->prefix . 'cleantalk_sfw')); // Table for SpamFireWall data
136
  $wpdb->query(sprintf($sfw_log_query, $wpdb->prefix . 'cleantalk_sfw_logs')); // Table for SpamFireWall logs
137
  // Cron tasks
138
- CleantalkCron::addTask('check_account_status', 'ct_account_status_check', 3600, time()+1800); // Checks account status
139
- CleantalkCron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time()+3500); // Formerly ct_hourly_event_hook()
140
- CleantalkCron::addTask('send_feedback', 'ct_send_feedback', 3600, time()+3500); // Formerly ct_hourly_event_hook()
141
- CleantalkCron::addTask('sfw_update', 'ct_sfw_update', 86400, time()+300); // SFW update
142
- CleantalkCron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time()+1800); // SFW send logs
143
- CleantalkCron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time()+3500); // Get data for dashboard widget
144
- CleantalkCron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time()+3500); // Send connection report to welcome@cleantalk.org
145
  }
146
  switch_to_blog($initial_blog);
147
  }
@@ -468,7 +470,7 @@ function apbct_update_to_5_138_0() {
468
 
469
  $data = get_option( 'cleantalk_data', array() );
470
 
471
- $result = CleantalkAPI::method__notice_paid_till(
472
  $settings['api_key'],
473
  preg_replace('/http[s]?:\/\//', '', get_option('siteurl'), 1),
474
  ! is_main_site() && $net_settings['white_label'] ? 'anti-spam-hosting' : 'antispam'
@@ -515,4 +517,22 @@ function apbct_update_to_5_138_0() {
515
  apbct_activation__create_tables($sqls);
516
  }
517
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
518
  }
1
  <?php
2
 
3
+ use Cleantalk\ApbctWP\Cron;
4
+
5
  function apbct_run_update_actions($current_version, $new_version){
6
 
7
  $current_version = apbct_version_standartization($current_version);
90
  wp_clear_scheduled_hook('cleantalk_get_brief_data_hook');
91
 
92
  // Adding Self cron system tasks
93
+ Cron::addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // New
94
+ Cron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time() + 3500);
95
+ Cron::addTask('send_feedback', 'ct_send_feedback', 3600, time() + 3500);
96
+ Cron::addTask('sfw_update', 'ct_sfw_update', 86400, time() + 43200);
97
+ Cron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time() + 1800); // New
98
+ Cron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500);
99
  }
100
  function apbct_update_to_5_74_0(){
101
+ Cron::removeTask('send_daily_request');
102
  }
103
 
104
  function apbct_update_to_5_97_0(){
137
  $wpdb->query(sprintf($sfw_data_query, $wpdb->prefix . 'cleantalk_sfw')); // Table for SpamFireWall data
138
  $wpdb->query(sprintf($sfw_log_query, $wpdb->prefix . 'cleantalk_sfw_logs')); // Table for SpamFireWall logs
139
  // Cron tasks
140
+ Cron::addTask('check_account_status', 'ct_account_status_check', 3600, time() + 1800); // Checks account status
141
+ Cron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
142
+ Cron::addTask('send_feedback', 'ct_send_feedback', 3600, time() + 3500); // Formerly ct_hourly_event_hook()
143
+ Cron::addTask('sfw_update', 'ct_sfw_update', 86400, time() + 300); // SFW update
144
+ Cron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time() + 1800); // SFW send logs
145
+ Cron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
146
+ Cron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
147
  }
148
  switch_to_blog($initial_blog);
149
  }
470
 
471
  $data = get_option( 'cleantalk_data', array() );
472
 
473
+ $result = \Cleantalk\ApbctWP\API::method__notice_paid_till(
474
  $settings['api_key'],
475
  preg_replace('/http[s]?:\/\//', '', get_option('siteurl'), 1),
476
  ! is_main_site() && $net_settings['white_label'] ? 'anti-spam-hosting' : 'antispam'
517
  apbct_activation__create_tables($sqls);
518
  }
519
 
520
+ }
521
+ function apbct_update_to_5_142_0() {
522
+
523
+ $sqls[] = 'CREATE TABLE IF NOT EXISTS `%scleantalk_ac_log` (
524
+ `id` VARCHAR(40) NOT NULL,
525
+ `ip` VARCHAR(40) NOT NULL,
526
+ `entries` INT DEFAULT 0,
527
+ `interval_start` INT NOT NULL,
528
+ PRIMARY KEY (`id`));';
529
+
530
+ $sqls[] = 'ALTER TABLE `%scleantalk_sfw_logs`
531
+ ADD COLUMN `id` VARCHAR(40) NOT NULL FIRST,
532
+ ADD COLUMN `status` ENUM(\'PASS_SFW\',\'DENY_SFW\',\'PASS_SFW_BY_WHITELIST\',\'PASS_SFW_BY_COOKIE\',\'DENY_ANTIBOT\',\'DENY_ANTICRAWLER\') NOT NULL AFTER `ip`,
533
+ DROP PRIMARY KEY,
534
+ ADD PRIMARY KEY (`id`);';
535
+
536
+ apbct_activation__create_tables( $sqls );
537
+
538
  }
inc/find-spam/ClassCleantalkFindSpamCommentsChecker.php CHANGED
@@ -232,7 +232,7 @@ class ClassCleantalkFindSpamCommentsChecker extends ClassCleantalkFindSpamChecke
232
  die();
233
  }
234
 
235
- $result = CleantalkAPI::method__spam_check_cms($apbct->api_key, $data, !empty($_POST['accurate_check']) ? $curr_date : null);
236
 
237
  if(empty($result['error'])){
238
 
232
  die();
233
  }
234
 
235
+ $result = \Cleantalk\ApbctWP\API::method__spam_check_cms($apbct->api_key, $data, !empty($_POST['accurate_check']) ? $curr_date : null);
236
 
237
  if(empty($result['error'])){
238
 
inc/find-spam/ClassCleantalkFindSpamUsersChecker.php CHANGED
@@ -231,7 +231,7 @@ class ClassCleantalkFindSpamUsersChecker extends ClassCleantalkFindSpamChecker
231
  die();
232
  }
233
 
234
- $result = CleantalkAPI::method__spam_check_cms( $apbct->api_key, $data, !empty($_POST['accurate_check']) ? $curr_date : null );
235
 
236
  if( empty( $result['error'] ) ){
237
 
231
  die();
232
  }
233
 
234
+ $result = \Cleantalk\ApbctWP\API::method__spam_check_cms( $apbct->api_key, $data, !empty($_POST['accurate_check']) ? $curr_date : null );
235
 
236
  if( empty( $result['error'] ) ){
237
 
js/cleantalk-admin-settings-page.min.js CHANGED
@@ -1 +1,2 @@
1
- function apbct_banner_check(){var i=setInterval(function(){apbct_admin_sendAJAX({action:"apbct_settings__check_renew_banner"},{callback:function(e,t,n,c){e.close_renew_banner&&(jQuery("#apbct_renew_notice").length&&jQuery("#apbct_renew_notice").hide("slow"),jQuery("#apbct_trial_notice").length&&jQuery("#apbct_trial_notice").hide("slow"),clearInterval(i))}})},9e5)}function apbct_get_elems(e){for(var t,n=0,c=(e=e.split(",")).length;n<c;n++)t=jQuery("#"+e[n]),e[n]=0===t.length?jQuery("."+e[n]):t;return e}function apbct_get_elems__native(e){"string"==typeof e&&(e=e.split(","));var i=[];return e.forEach(function(e,t,n){var c=document.getElementById(e);if(null===c){if(null!==(c=document.getElementsByClassName(e))&&0!==c.length)for(key in c)0<=+key&&i.push(c[key])}else i.push(c[key])}),i}function apbct_show_hide_elem(e){for(var t=0,n=(e=apbct_get_elems(e)).length;t<n;t++)e[t].each(function(e,t){var n=(t=jQuery(t)).next("label")||t.prev("label")||null;t.is(":visible")?(t.hide(),n&&n.hide()):(t.show(),n&&n.show())})}function apbctSettingsDependencies(e,a){a=+a||null,apbct_get_elems__native(e).forEach(function(e,t,n){function c(){console.log(e),e.setAttribute("disabled","disabled")}function i(){e.removeAttribute("disabled")}(null!==a?1===a?i:c:null===e.getAttribute("disabled")?c:i)()})}function apbct_settings__showDescription(e,t){var i=function(e){void 0!==e&&(0!=jQuery(e.target).parent(".apbct_long_desc").length&&!jQuery(e.target).hasClass("apbct_long_desc__cancel")||jQuery(e.target).hasClass("apbct_long_description__show"))||(jQuery(".apbct_long_desc").remove(),jQuery(document).off("click",i))};i(),e.after("<div id='apbct_long_desc__"+t+"' class='apbct_long_desc'></div>");var n=jQuery("#apbct_long_desc__"+t);n.append("<i class='icon-spin1 animate-spin'></i>").append("<div class='apbct_long_desc__angle'></div>").css({top:e.position().top-5,left:e.position().left+25}),apbct_admin_sendAJAX({action:"apbct_settings__get_description",setting_id:t},{spinner:n.children("img"),callback:function(e,t,n,c){c.empty().append("<div class='apbct_long_desc__angle'></div>").append("<i class='apbct_long_desc__cancel icon-cancel'></i>").append("<h3 class='apbct_long_desc__title'>"+e.title+"</h3>").append("<p>"+e.desc+"</p>"),jQuery(document).on("click",i)}},n)}jQuery(document).ready(function(){"rtl"===getComputedStyle(document.getElementsByClassName("apbct_settings-title")[0]).direction&&jQuery(".apbct_switchers").css("text-align","right"),jQuery("#apbct_showApiKey").on("click",function(){jQuery(".apbct_setting---apikey").val(jQuery(".apbct_setting---apikey").attr("key")),jQuery(".apbct_setting---apikey+div").show(),jQuery(this).fadeOut(300)});var e=new Date;jQuery("#ct_admin_timezone").val(e.getTimezoneOffset()/60*-1),jQuery("#apbct_gdpr_open_modal").on("click",function(){jQuery("#gdpr_dialog").dialog({modal:!0,show:!0,position:{my:"center",at:"center",of:window},width:+jQuery("#wpbody").width()/100*70,height:"auto",title:"GDPR compliance",draggable:!1,resizable:!1,closeText:"Close"})}),jQuery(document).on("click",".apbct_settings-long_description---show",function(){self=jQuery(this),apbct_settings__showDescription(self,self.attr("setting"))}),(jQuery("#apbct_renew_notice").length||jQuery("#apbct_trial_notice").length)&&apbct_banner_check()});
 
1
+ function apbct_banner_check(){var i=setInterval(function(){apbct_admin_sendAJAX({action:"apbct_settings__check_renew_banner"},{callback:function(e,t,n,c){e.close_renew_banner&&(jQuery("#apbct_renew_notice").length&&jQuery("#apbct_renew_notice").hide("slow"),jQuery("#apbct_trial_notice").length&&jQuery("#apbct_trial_notice").hide("slow"),clearInterval(i))}})},9e5)}function apbct_get_elems(e){for(var t,n=0,c=(e=e.split(",")).length;n<c;n++)t=jQuery("#"+e[n]),e[n]=0===t.length?jQuery("."+e[n]):t;return e}function apbct_get_elems__native(e){"string"==typeof e&&(e=e.split(","));var i=[];return e.forEach(function(e,t,n){var c=document.getElementById(e);if(null===c){if(null!==(c=document.getElementsByClassName(e))&&0!==c.length)for(key in c)0<=+key&&i.push(c[key])}else i.push(c[key])}),i}function apbct_show_hide_elem(e){for(var t=0,n=(e=apbct_get_elems(e)).length;t<n;t++)e[t].each(function(e,t){var n=(t=jQuery(t)).next("label")||t.prev("label")||null;t.is(":visible")?(t.hide(),n&&n.hide()):(t.show(),n&&n.show())})}function apbctSettingsDependencies(e,i){i=isNaN(i)?null:i,apbct_get_elems__native(e).forEach(function(e,t,n){console.log(e.getAttribute("id"));if(null===i&&(i=null===e.getAttribute("disabled")?0:1),1===i?e.removeAttribute("disabled"):e.setAttribute("disabled","disabled"),null!==e.getAttribute("apbct_children")){var c=apbctSettingsDependencies_getState(e)&&i;null!==c&&apbctSettingsDependencies(e.getAttribute("apbct_children"),c)}})}function apbctSettingsDependencies_getState(e){var t;switch(e.getAttribute("type")){case"checkbox":t=+e.checked;break;case"radio":t=+(1==+e.getAttribute("value"));break;default:t=null}return t}function apbct_settings__showDescription(e,t){var i=function(e){void 0!==e&&(0!=jQuery(e.target).parent(".apbct_long_desc").length&&!jQuery(e.target).hasClass("apbct_long_desc__cancel")||jQuery(e.target).hasClass("apbct_long_description__show"))||(jQuery(".apbct_long_desc").remove(),jQuery(document).off("click",i))};i(),e.after("<div id='apbct_long_desc__"+t+"' class='apbct_long_desc'></div>");var n=jQuery("#apbct_long_desc__"+t);n.append("<i class='icon-spin1 animate-spin'></i>").append("<div class='apbct_long_desc__angle'></div>").css({top:e.position().top-5,left:e.position().left+25}),apbct_admin_sendAJAX({action:"apbct_settings__get_description",setting_id:t},{spinner:n.children("img"),callback:function(e,t,n,c){c.empty().append("<div class='apbct_long_desc__angle'></div>").append("<i class='apbct_long_desc__cancel icon-cancel'></i>").append("<h3 class='apbct_long_desc__title'>"+e.title+"</h3>").append("<p>"+e.desc+"</p>"),jQuery(document).on("click",i)}},n)}jQuery(document).ready(function(){"rtl"===getComputedStyle(document.getElementsByClassName("apbct_settings-title")[0]).direction&&jQuery(".apbct_switchers").css("text-align","right"),jQuery("#apbct_showApiKey").on("click",function(){jQuery(".apbct_setting---apikey").val(jQuery(".apbct_setting---apikey").attr("key")),jQuery(".apbct_setting---apikey+div").show(),jQuery(this).fadeOut(300)});var e=new Date;jQuery("#ct_admin_timezone").val(e.getTimezoneOffset()/60*-1),jQuery("#apbct_gdpr_open_modal").on("click",function(){jQuery("#gdpr_dialog").dialog({modal:!0,show:!0,position:{my:"center",at:"center",of:window},width:+jQuery("#wpbody").width()/100*70,height:"auto",title:"GDPR compliance",draggable:!1,resizable:!1,closeText:"Close"})}),jQuery(document).on("click",".apbct_settings-long_description---show",function(){self=jQuery(this),apbct_settings__showDescription(self,self.attr("setting"))}),(jQuery("#apbct_renew_notice").length||jQuery("#apbct_trial_notice").length)&&apbct_banner_check()});
2
+ //# sourceMappingURL=cleantalk-admin-settings-page.min.js.map
js/cleantalk-admin-settings-page.min.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["cleantalk-admin-settings-page.js"],"names":["apbct_banner_check","bannerChecker","setInterval","apbct_admin_sendAJAX","action","callback","result","data","params","obj","close_renew_banner","jQuery","length","hide","clearInterval","apbct_get_elems","elems","tmp","i","len","split","apbct_get_elems__native","out","forEach","elem","arr","document","getElementById","getElementsByClassName","key","push","apbct_show_hide_elem","each","label","next","prev","is","show","apbctSettingsDependencies","ids","enable","do_disable","console","log","setAttribute","do_enable","removeAttribute","getAttribute","apbct_settings__showDescription","setting_id","remove_desc_func","e","target","parent","hasClass","remove","off","after","append","css","top","position","left","spinner","children","empty","title","desc","on","ready","getComputedStyle","direction","val","attr","this","fadeOut","d","Date","getTimezoneOffset","dialog","modal","my","at","of","window","width","height","draggable","resizable","closeText","self"],"mappings":"AA6CA,SAASA,qBACR,IAAIC,EAAgBC,YAAa,WAChCC,qBACC,CAACC,OAAQ,sCACT,CACCC,SAAU,SAASC,EAAQC,EAAMC,EAAQC,GACpCH,EAAOI,qBACNC,OAAO,uBAAuBC,QACjCD,OAAO,uBAAuBE,KAAK,QAChCF,OAAO,uBAAuBC,QACjCD,OAAO,uBAAuBE,KAAK,QACpCC,cAAcb,QAKhB,KAUJ,SAASc,gBAAgBC,GAErB,IAAK,IAA6BC,EAAzBC,EAAE,EAAGC,GADdH,EAAQA,EAAMI,MAAM,MACMR,OAAaM,EAAIC,EAAKD,IAC5CD,EAAMN,OAAO,IAAIK,EAAME,IACvBF,EAAME,GAAoB,IAAfD,EAAIL,OAAeD,OAAO,IAAIK,EAAME,IAAMD,EAEzD,OAAOD,EAUX,SAASK,wBAAwBL,GAGZ,iBAAVA,IACTA,EAAQA,EAAMI,MAAM,MAErB,IAAIE,EAAM,GAuBV,OArBAN,EAAMO,QAAQ,SAASC,EAAMN,EAAGO,GAG/B,IAAIR,EAAMS,SAASC,eAAeH,GAClC,GAAY,OAARP,GAQJ,GAAY,QADZA,EAAMS,SAASE,uBAAuBJ,KACJ,IAAdP,EAAIL,OACvB,IAAIiB,OAAOZ,EACE,IAAPY,KACJP,EAAIQ,KAAMb,EAAIY,WAVhBP,EAAIQ,KAAMb,EAAIY,QAgBTP,EAGR,SAASS,qBAAqBf,GAE1B,IAAK,IAAIE,EAAE,EAAGC,GADjBH,EAAQD,gBAAgBC,IACKJ,OAAQM,EAAIC,EAAKD,IACvCF,EAAME,GAAGc,KAAK,SAAUd,EAAGM,GAEvB,IAAIS,GADJT,EAAOb,OAAOa,IACGU,KAAK,UAAYV,EAAKW,KAAK,UAAY,KACpDX,EAAKY,GAAG,aACRZ,EAAKX,OACDoB,GAAOA,EAAMpB,SAEjBW,EAAKa,OACDJ,GAAOA,EAAMI,UAajC,SAASC,0BAA0BC,EAAKC,GAEvCA,GAAUA,GAAU,KAGRnB,wBAAyBkB,GAE/BhB,QAAQ,SAASC,EAAMN,EAAGO,GAEd,SAAbgB,IAAwBC,QAAQC,IAAKnB,GAAQA,EAAKoB,aAAa,WAAY,YACjE,SAAbC,IAAwBrB,EAAKsB,gBAAgB,aAGhC,OAAXN,EACS,IAAXA,EAAeK,EAAcJ,EAIK,OAAlCjB,EAAKuB,aAAa,YAAuBN,EAAeI,OAK3D,SAASG,gCAAgCf,EAAOgB,GAE/C,IAAIC,EAAmB,SAASC,QACf,IAANA,IAA6E,GAAtDxC,OAAOwC,EAAEC,QAAQC,OAAO,oBAAoBzC,SAAeD,OAAOwC,EAAEC,QAAQE,SAAS,4BAAgC3C,OAAOwC,EAAEC,QAAQE,SAAS,mCAC/K3C,OAAO,oBAAoB4C,SAC3B5C,OAAOe,UAAU8B,IAAI,QAASN,KAIhCA,IAEAjB,EAAMwB,MAAM,6BAA6BR,EAAW,oCACpD,IAAIxC,EAAME,OAAO,qBAAqBsC,GACtCxC,EAAIiD,OAAO,2CACTA,OAAO,8CACPC,IAAI,CACJC,IAAK3B,EAAM4B,WAAWD,IAAM,EAC5BE,KAAM7B,EAAM4B,WAAWC,KAAO,KAIhC3D,qBACC,CAACC,OAAQ,kCAAmC6C,WAAYA,GACxD,CACCc,QAAStD,EAAIuD,SAAS,OACtB3D,SAAU,SAASC,EAAQC,EAAMC,EAAQC,GAExCA,EAAIwD,QACFP,OAAO,8CACPA,OAAO,uDACPA,OAAO,sCAAsCpD,EAAO4D,MAAM,SAC1DR,OAAO,MAAMpD,EAAO6D,KAAK,QAE3BxD,OAAOe,UAAU0C,GAAG,QAASlB,KAG/BzC,GA1MFE,OAAOe,UAAU2C,MAAM,WAGwE,QAA3FC,iBAAiB5C,SAASE,uBAAuB,wBAAwB,IAAI2C,WAC/E5D,OAAO,oBAAoBgD,IAAI,aAAc,SAI3ChD,OAAO,qBAAqByD,GAAG,QAAS,WACpCzD,OAAO,2BAA2B6D,IAAI7D,OAAO,2BAA2B8D,KAAK,QAC7E9D,OAAO,+BAA+B0B,OACtC1B,OAAO+D,MAAMC,QAAQ,OAG5B,IAAIC,EAAI,IAAIC,KACZlE,OAAO,sBAAsB6D,IAAII,EAAEE,oBAAoB,IAAK,GAG5DnE,OAAO,0BAA0ByD,GAAG,QAAS,WAC5CzD,OAAO,gBAAgBoE,OAAO,CAC7BC,OAAM,EACN3C,MAAM,EACNwB,SAAU,CAAEoB,GAAI,SAAUC,GAAI,SAAUC,GAAIC,QAC5CC,OAAS1E,OAAO,WAAW0E,QAAU,IAAM,GAC3CC,OAAQ,OACRpB,MAAO,kBACPqB,WAAW,EACXC,WAAW,EACXC,UAAW,YAIb9E,OAAOe,UAAU0C,GAAG,QAAS,0CAA2C,WACvEsB,KAAO/E,OAAO+D,MACd1B,gCAAgC0C,KAAMA,KAAKjB,KAAK,eAG7C9D,OAAO,uBAAuBC,QAAUD,OAAO,uBAAuBC,SACzEZ"}
1
+ {"version":3,"sources":["cleantalk-admin-settings-page.js"],"names":["apbct_banner_check","bannerChecker","setInterval","apbct_admin_sendAJAX","action","callback","result","data","params","obj","close_renew_banner","jQuery","length","hide","clearInterval","apbct_get_elems","elems","tmp","i","len","split","apbct_get_elems__native","out","forEach","elem","arr","document","getElementById","getElementsByClassName","key","push","apbct_show_hide_elem","each","label","next","prev","is","show","apbctSettingsDependencies","ids","enable","isNaN","console","log","getAttribute","removeAttribute","setAttribute","state","apbctSettingsDependencies_getState","checked","apbct_settings__showDescription","setting_id","remove_desc_func","e","target","parent","hasClass","remove","off","after","append","css","top","position","left","spinner","children","empty","title","desc","on","ready","getComputedStyle","direction","val","attr","this","fadeOut","d","Date","getTimezoneOffset","dialog","modal","my","at","of","window","width","height","draggable","resizable","closeText","self"],"mappings":"AA6CA,SAASA,qBACR,IAAIC,EAAgBC,YAAa,WAChCC,qBACC,CAACC,OAAQ,sCACT,CACCC,SAAU,SAASC,EAAQC,EAAMC,EAAQC,GACpCH,EAAOI,qBACNC,OAAO,uBAAuBC,QACjCD,OAAO,uBAAuBE,KAAK,QAChCF,OAAO,uBAAuBC,QACjCD,OAAO,uBAAuBE,KAAK,QACpCC,cAAcb,QAKhB,KAUJ,SAASc,gBAAgBC,GAErB,IAAK,IAA6BC,EAAzBC,EAAE,EAAGC,GADdH,EAAQA,EAAMI,MAAM,MACMR,OAAaM,EAAIC,EAAKD,IAC5CD,EAAMN,OAAO,IAAIK,EAAME,IACvBF,EAAME,GAAoB,IAAfD,EAAIL,OAAeD,OAAO,IAAIK,EAAME,IAAMD,EAEzD,OAAOD,EAUX,SAASK,wBAAwBL,GAGZ,iBAAVA,IACTA,EAAQA,EAAMI,MAAM,MAErB,IAAIE,EAAM,GAuBV,OArBAN,EAAMO,QAAQ,SAASC,EAAMN,EAAGO,GAG/B,IAAIR,EAAMS,SAASC,eAAeH,GAClC,GAAY,OAARP,GAQJ,GAAY,QADZA,EAAMS,SAASE,uBAAuBJ,KACJ,IAAdP,EAAIL,OACvB,IAAIiB,OAAOZ,EACE,IAAPY,KACJP,EAAIQ,KAAMb,EAAIY,WAVhBP,EAAIQ,KAAMb,EAAIY,QAgBTP,EAGR,SAASS,qBAAqBf,GAE1B,IAAK,IAAIE,EAAE,EAAGC,GADjBH,EAAQD,gBAAgBC,IACKJ,OAAQM,EAAIC,EAAKD,IACvCF,EAAME,GAAGc,KAAK,SAAUd,EAAGM,GAEvB,IAAIS,GADJT,EAAOb,OAAOa,IACGU,KAAK,UAAYV,EAAKW,KAAK,UAAY,KACpDX,EAAKY,GAAG,aACRZ,EAAKX,OACDoB,GAAOA,EAAMpB,SAEjBW,EAAKa,OACDJ,GAAOA,EAAMI,UAajC,SAASC,0BAA0BC,EAAKC,GAGvCA,EAAWC,MAAMD,GAAmB,KAATA,EAGfnB,wBAAyBkB,GAE/BhB,QAAQ,SAASC,EAAMN,EAAGO,GAE/BiB,QAAQC,IAAKnB,EAAKoB,aAAa,OAW/B,GALc,OAAXJ,IACFA,EAA2C,OAAlChB,EAAKoB,aAAa,YAAuB,EAAI,GAE5C,IAAXJ,EANyBhB,EAAKqB,gBAAgB,YADlBrB,EAAKsB,aAAa,WAAY,YASd,OAAxCtB,EAAKoB,aAAa,kBAA2B,CAChD,IAAIG,EAAQC,mCAAoCxB,IAAUgB,EAC5C,OAAVO,GACHT,0BAA2Bd,EAAKoB,aAAa,kBAAmBG,MAOpE,SAASC,mCAAoCxB,GAE5C,IAAIuB,EAEJ,OAASvB,EAAKoB,aAAc,SAC3B,IAAK,WACJG,GAASvB,EAAKyB,QACd,MACD,IAAK,QACJF,IAA0C,IAA/BvB,EAAKoB,aAAa,UAC7B,MACD,QACCG,EAAQ,KAGV,OAAOA,EAGR,SAASG,gCAAgCjB,EAAOkB,GAE/C,IAAIC,EAAmB,SAASC,QACf,IAANA,IAA6E,GAAtD1C,OAAO0C,EAAEC,QAAQC,OAAO,oBAAoB3C,SAAeD,OAAO0C,EAAEC,QAAQE,SAAS,4BAAgC7C,OAAO0C,EAAEC,QAAQE,SAAS,mCAC/K7C,OAAO,oBAAoB8C,SAC3B9C,OAAOe,UAAUgC,IAAI,QAASN,KAIhCA,IAEAnB,EAAM0B,MAAM,6BAA6BR,EAAW,oCACpD,IAAI1C,EAAME,OAAO,qBAAqBwC,GACtC1C,EAAImD,OAAO,2CACTA,OAAO,8CACPC,IAAI,CACJC,IAAK7B,EAAM8B,WAAWD,IAAM,EAC5BE,KAAM/B,EAAM8B,WAAWC,KAAO,KAIhC7D,qBACC,CAACC,OAAQ,kCAAmC+C,WAAYA,GACxD,CACCc,QAASxD,EAAIyD,SAAS,OACtB7D,SAAU,SAASC,EAAQC,EAAMC,EAAQC,GAExCA,EAAI0D,QACFP,OAAO,8CACPA,OAAO,uDACPA,OAAO,sCAAsCtD,EAAO8D,MAAM,SAC1DR,OAAO,MAAMtD,EAAO+D,KAAK,QAE3B1D,OAAOe,UAAU4C,GAAG,QAASlB,KAG/B3C,GApOFE,OAAOe,UAAU6C,MAAM,WAGwE,QAA3FC,iBAAiB9C,SAASE,uBAAuB,wBAAwB,IAAI6C,WAC/E9D,OAAO,oBAAoBkD,IAAI,aAAc,SAI3ClD,OAAO,qBAAqB2D,GAAG,QAAS,WACpC3D,OAAO,2BAA2B+D,IAAI/D,OAAO,2BAA2BgE,KAAK,QAC7EhE,OAAO,+BAA+B0B,OACtC1B,OAAOiE,MAAMC,QAAQ,OAG5B,IAAIC,EAAI,IAAIC,KACZpE,OAAO,sBAAsB+D,IAAII,EAAEE,oBAAoB,IAAK,GAG5DrE,OAAO,0BAA0B2D,GAAG,QAAS,WAC5C3D,OAAO,gBAAgBsE,OAAO,CAC7BC,OAAM,EACN7C,MAAM,EACN0B,SAAU,CAAEoB,GAAI,SAAUC,GAAI,SAAUC,GAAIC,QAC5CC,OAAS5E,OAAO,WAAW4E,QAAU,IAAM,GAC3CC,OAAQ,OACRpB,MAAO,kBACPqB,WAAW,EACXC,WAAW,EACXC,UAAW,YAIbhF,OAAOe,UAAU4C,GAAG,QAAS,0CAA2C,WACvEsB,KAAOjF,OAAOiE,MACd1B,gCAAgC0C,KAAMA,KAAKjB,KAAK,eAG7ChE,OAAO,uBAAuBC,QAAUD,OAAO,uBAAuBC,SACzEZ","file":"cleantalk-admin-settings-page.min.js","sourcesContent":["jQuery(document).ready(function(){\n\n\t// Crunch for Right to Left direction languages\n\tif(getComputedStyle(document.getElementsByClassName('apbct_settings-title')[0]).direction === 'rtl'){\n\t\tjQuery('.apbct_switchers').css('text-align', 'right');\n\t}\n\n\t// Show/Hide access key\n jQuery('#apbct_showApiKey').on('click', function(){\n jQuery('.apbct_setting---apikey').val(jQuery('.apbct_setting---apikey').attr('key'));\n jQuery('.apbct_setting---apikey+div').show();\n jQuery(this).fadeOut(300);\n });\n\n\tvar d = new Date();\n\tjQuery('#ct_admin_timezone').val(d.getTimezoneOffset()/60*(-1));\n\t\n\t// GDPR modal window\n\tjQuery('#apbct_gdpr_open_modal').on('click', function(){\n\t\tjQuery('#gdpr_dialog').dialog({\n\t\t\tmodal:true, \n\t\t\tshow: true,\n\t\t\tposition: { my: \"center\", at: \"center\", of: window },\n\t\t\twidth: +(jQuery('#wpbody').width() / 100 * 70), // 70% of #wpbody\n\t\t\theight: 'auto',\n\t\t\ttitle: 'GDPR compliance',\n\t\t\tdraggable: false,\n\t\t\tresizable: false,\n\t\t\tcloseText: \"Close\",\n\t\t});\n\t});\n\n\tjQuery(document).on('click', '.apbct_settings-long_description---show', function(){\n\t\tself = jQuery(this);\n\t\tapbct_settings__showDescription(self, self.attr('setting'));\n\t});\n\n\tif (jQuery('#apbct_renew_notice').length || jQuery('#apbct_trial_notice').length) \n\t\tapbct_banner_check();\n\t\n});\n\n/**\n * Checking current account status for renew notice\n */\nfunction apbct_banner_check() {\n\tvar bannerChecker = setInterval( function() {\n\t\tapbct_admin_sendAJAX(\n\t\t\t{action: 'apbct_settings__check_renew_banner'},\n\t\t\t{\n\t\t\t\tcallback: function(result, data, params, obj){\n\t\t\t\t\tif (result.close_renew_banner) {\n\t\t\t\t\t\tif (jQuery('#apbct_renew_notice').length)\n\t\t\t\t\t\t\tjQuery('#apbct_renew_notice').hide('slow');\n\t\t\t\t\t\tif (jQuery('#apbct_trial_notice').length)\n\t\t\t\t\t\t\tjQuery('#apbct_trial_notice').hide('slow');\n\t\t\t\t\t\tclearInterval(bannerChecker);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}, 900000);\n}\n\n/**\n * Select elems like #{selector} or .{selector}\n * Selector passed in string separated by ,\n *\n * @param elems\n * @returns {*}\n */\nfunction apbct_get_elems(elems){\n elems = elems.split(',');\n for( var i=0, len = elems.length, tmp; i < len; i++){\n tmp = jQuery('#'+elems[i]);\n elems[i] = tmp.length === 0 ? jQuery('.'+elems[i]) : tmp;\n }\n return elems;\n}\n\n/**\n * Select elems like #{selector} or .{selector}\n * Selector could be passed in a string ( separated by comma ) or in array ( [ elem1, elem2, ... ] )\n *\n * @param elems string|array\n * @returns array\n */\nfunction apbct_get_elems__native(elems){\n\n\t// Make array from a string\n\tif(typeof elems === 'string')\n\t\telems = elems.split(',');\n\n\tvar out = [];\n\n\telems.forEach(function(elem, i, arr) {\n\n\t\t// try to get elements with such IDs\n\t\tvar tmp = document.getElementById(elem);\n\t\tif (tmp !== null){\n\t\t\tout.push( tmp[key] );\n\t\t\treturn;\n\t\t}\n\n\t\t// try to get elements with such class name\n\t\t// write each elem from collection to new element of output array\n\t\ttmp = document.getElementsByClassName(elem);\n\t\tif (tmp !== null && tmp.length !==0 ){\n\t\t\tfor(key in tmp){\n\t\t\t\tif( +key >= 0 ){\n\t\t\t\t\tout.push( tmp[key] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\treturn out;\n}\n\nfunction apbct_show_hide_elem(elems){\n\telems = apbct_get_elems(elems);\n for( var i=0, len = elems.length; i < len; i++){\n elems[i].each(function (i, elem) {\n elem = jQuery(elem);\n var label = elem.next('label') || elem.prev('label') || null;\n if (elem.is(\":visible\")) {\n elem.hide();\n if (label) label.hide();\n } else {\n elem.show();\n if (label) label.show();\n }\n });\n }\n}\n\n/**\n * Settings dependences. Switch|toggle depended elements state (disabled|enabled)\n * Recieve list of selectors ( without class mark (.) or id mark (#) )\n *\n * @param ids string|array Selectors\n * @param enable\n */\nfunction apbctSettingsDependencies(ids, enable){\n\n\n\tenable = ! isNaN(enable) ? enable : null;\n\n\t// Get elements\n\tvar elems = apbct_get_elems__native( ids );\n\n\telems.forEach(function(elem, i, arr){\n\n\t\tconsole.log( elem.getAttribute('id') );\n\n\t\tvar do_disable = function(){elem.setAttribute('disabled', 'disabled');},\n\t\t\tdo_enable = function(){elem.removeAttribute('disabled');};\n\n\t\t// Set defined state\n\t\tif(enable === null) // Set\n\t\t\tenable = elem.getAttribute('disabled') === null ? 0 : 1;\n\n\t\tenable === 1 ? do_enable() : do_disable();\n\n\t\tif( elem.getAttribute('apbct_children') !== null){\n\t\t\tvar state = apbctSettingsDependencies_getState( elem ) && enable;\n\t\t\tif( state !== null ) {\n\t\t\t\tapbctSettingsDependencies( elem.getAttribute('apbct_children'), state );\n\t\t\t}\n\t\t}\n\n\t});\n}\n\nfunction apbctSettingsDependencies_getState( elem ){\n\n\tvar state;\n\n\tswitch ( elem.getAttribute( 'type' ) ){\n\t\tcase 'checkbox':\n\t\t\tstate = +elem.checked;\n\t\t\tbreak;\n\t\tcase 'radio':\n\t\t\tstate = +(+elem.getAttribute('value') === 1);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tstate = null;\n\t}\n\n\treturn state;\n}\n\nfunction apbct_settings__showDescription(label, setting_id){\n\n\tvar remove_desc_func = function(e){\n\t\tif(typeof e === 'undefined' || ((jQuery(e.target).parent('.apbct_long_desc').length == 0 || jQuery(e.target).hasClass('apbct_long_desc__cancel')) && !jQuery(e.target).hasClass('apbct_long_description__show'))){\n\t\t\tjQuery('.apbct_long_desc').remove();\n\t\t\tjQuery(document).off('click', remove_desc_func);\n\t\t}\n\t};\n\n\tremove_desc_func();\n\n\tlabel.after(\"<div id='apbct_long_desc__\"+setting_id+\"' class='apbct_long_desc'></div>\");\n\tvar obj = jQuery('#apbct_long_desc__'+setting_id);\n\tobj.append(\"<i class='icon-spin1 animate-spin'></i>\")\n\t\t.append(\"<div class='apbct_long_desc__angle'></div>\")\n\t\t.css({\n\t\t\ttop: label.position().top - 5,\n\t\t\tleft: label.position().left + 25\n\t\t});\n\n\n\tapbct_admin_sendAJAX(\n\t\t{action: 'apbct_settings__get_description', setting_id: setting_id},\n\t\t{\n\t\t\tspinner: obj.children('img'),\n\t\t\tcallback: function(result, data, params, obj){\n\n\t\t\t\tobj.empty()\n\t\t\t\t\t.append(\"<div class='apbct_long_desc__angle'></div>\")\n\t\t\t\t\t.append(\"<i class='apbct_long_desc__cancel icon-cancel'></i>\")\n\t\t\t\t\t.append(\"<h3 class='apbct_long_desc__title'>\"+result.title+\"</h3>\")\n\t\t\t\t\t.append(\"<p>\"+result.desc+\"</p>\");\n\n\t\t\t\tjQuery(document).on('click', remove_desc_func);\n\t\t\t}\n\t\t},\n\t\tobj\n\t);\n}"]}
lib/{Cleantalk.php → Cleantalk/Antispam/Cleantalk.php} RENAMED
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
  /**
4
  * Cleantalk base class
5
  *
@@ -150,18 +152,18 @@ class Cleantalk {
150
  switch ($method) {
151
  case 'check_message':
152
  // Convert strings to UTF8
153
- $request->message = CleantalkHelper::toUTF8($request->message, $this->data_codepage);
154
- $request->example = CleantalkHelper::toUTF8($request->example, $this->data_codepage);
155
- $request->sender_email = CleantalkHelper::toUTF8($request->sender_email, $this->data_codepage);
156
- $request->sender_nickname = CleantalkHelper::toUTF8($request->sender_nickname, $this->data_codepage);
157
  $request->message = $this->compressData($request->message);
158
  $request->example = $this->compressData($request->example);
159
  break;
160
 
161
  case 'check_newuser':
162
  // Convert strings to UTF8
163
- $request->sender_email = CleantalkHelper::toUTF8($request->sender_email, $this->data_codepage);
164
- $request->sender_nickname = CleantalkHelper::toUTF8($request->sender_nickname, $this->data_codepage);
165
  break;
166
 
167
  case 'send_feedback':
@@ -174,7 +176,7 @@ class Cleantalk {
174
  // Removing non UTF8 characters from request, because non UTF8 or malformed characters break json_encode().
175
  foreach ($request as $param => $value) {
176
  if(is_array($request->$param) || is_string($request->$param))
177
- $request->$param = CleantalkHelper::removeNonUTF8($value);
178
  }
179
 
180
  $request->method_name = $method;
@@ -266,7 +268,7 @@ class Cleantalk {
266
  // Loop until find work server
267
  foreach ($servers as $server) {
268
 
269
- $dns = CleantalkHelper::ip__resolve__cleantalks($server['ip']);
270
  if(!$dns)
271
  continue;
272
 
@@ -506,7 +508,7 @@ class Cleantalk {
506
  if (!$result) {
507
  $response = null;
508
  $response['errno'] = 2;
509
- if (!CleantalkHelper::is_json($result)) {
510
  $response['errstr'] = 'Wrong server response format: ' . substr( $result, 100 );
511
  }
512
  else {
1
  <?php
2
 
3
+ namespace Cleantalk\Antispam;
4
+
5
  /**
6
  * Cleantalk base class
7
  *
152
  switch ($method) {
153
  case 'check_message':
154
  // Convert strings to UTF8
155
+ $request->message = \Cleantalk\ApbctWP\Helper::toUTF8($request->message, $this->data_codepage);
156
+ $request->example = \Cleantalk\ApbctWP\Helper::toUTF8($request->example, $this->data_codepage);
157
+ $request->sender_email = \Cleantalk\ApbctWP\Helper::toUTF8($request->sender_email, $this->data_codepage);
158
+ $request->sender_nickname = \Cleantalk\ApbctWP\Helper::toUTF8($request->sender_nickname, $this->data_codepage);
159
  $request->message = $this->compressData($request->message);
160
  $request->example = $this->compressData($request->example);
161
  break;
162
 
163
  case 'check_newuser':
164
  // Convert strings to UTF8
165
+ $request->sender_email = \Cleantalk\ApbctWP\Helper::toUTF8($request->sender_email, $this->data_codepage);
166
+ $request->sender_nickname = \Cleantalk\ApbctWP\Helper::toUTF8($request->sender_nickname, $this->data_codepage);
167
  break;
168
 
169
  case 'send_feedback':
176
  // Removing non UTF8 characters from request, because non UTF8 or malformed characters break json_encode().
177
  foreach ($request as $param => $value) {
178
  if(is_array($request->$param) || is_string($request->$param))
179
+ $request->$param = \Cleantalk\ApbctWP\Helper::removeNonUTF8($value);
180
  }
181
 
182
  $request->method_name = $method;
268
  // Loop until find work server
269
  foreach ($servers as $server) {
270
 
271
+ $dns = \Cleantalk\ApbctWP\Helper::ip__resolve__cleantalks($server['ip']);
272
  if(!$dns)
273
  continue;
274
 
508
  if (!$result) {
509
  $response = null;
510
  $response['errno'] = 2;
511
+ if (!\Cleantalk\ApbctWP\Helper::is_json($result)) {
512
  $response['errstr'] = 'Wrong server response format: ' . substr( $result, 100 );
513
  }
514
  else {
lib/{CleantalkRequest.php → Cleantalk/Antispam/CleantalkRequest.php} RENAMED
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
  /**
4
  * Request class
5
  */
1
  <?php
2
 
3
+ namespace Cleantalk\Antispam;
4
+
5
  /**
6
  * Request class
7
  */
lib/{CleantalkResponse.php → Cleantalk/Antispam/CleantalkResponse.php} RENAMED
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
  /**
4
  * Response class
5
  */
1
  <?php
2
 
3
+ namespace Cleantalk\Antispam;
4
+
5
  /**
6
  * Response class
7
  */
lib/Cleantalk/{DisableComments.php → Antispam/DisableComments.php} RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Cleantalk;
4
 
5
  /**
6
  * Class DisableComments
1
  <?php
2
 
3
+ namespace Cleantalk\Antispam;
4
 
5
  /**
6
  * Class DisableComments
lib/Cleantalk/Antispam/SFW.php DELETED
@@ -1,380 +0,0 @@
1
- <?php
2
-
3
- namespace Cleantalk\Antispam;
4
-
5
- /**
6
- * CleanTalk SpamFireWall base class.
7
- * Compatible with any CMS.
8
- *
9
- * @depends Cleantalk\Antispam\Helper class
10
- * @depends Cleantalk\Antispam\API class
11
- * @depends Cleantalk\Antispam\DB class
12
- *
13
- * @version 3.3
14
- * @author Cleantalk team (welcome@cleantalk.org)
15
- * @copyright (C) 2014 CleanTalk team (http://cleantalk.org)
16
- * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
17
- * @see https://github.com/CleanTalk/php-antispam
18
- */
19
- class SFW
20
- {
21
- public $ip = 0;
22
-
23
- public $ip_array = Array();
24
-
25
- public $results = array();
26
- public $blocked_ip = '';
27
- public $result = false;
28
- public $pass = true;
29
-
30
- public $test = false;
31
-
32
- /**
33
- * @var array of arrays array(origin => array(
34
- 'ip' => '192.168.0.1',
35
- 'network' => '192.168.0.0',
36
- 'mask' => '24',
37
- 'status' => -1 (blocked) | 1 (passed)
38
- )
39
- */
40
- public $all_ips = array();
41
-
42
- /**
43
- * @var array of arrays array(origin => array(
44
- 'ip' => '192.168.0.1',
45
- )
46
- */
47
- public $passed_ips = array();
48
-
49
- /**
50
- * @var array of arrays array(origin => array(
51
- 'ip' => '192.168.0.1',
52
- 'network' => '192.168.0.0',
53
- 'mask' => '24',
54
- )
55
- */
56
- public $blocked_ips = array();
57
-
58
- // Database
59
- protected $db;
60
- protected $data_table;
61
- protected $log_table;
62
-
63
- //Debug
64
- public $debug;
65
- public $debug_data = '';
66
-
67
- /**
68
- * CleantalkSFW_Base constructor.
69
- * Creates Database driver instance.
70
- */
71
- public function __construct()
72
- {
73
- if(empty($this->db)){
74
- // Creating database object. Depends on current CMS.
75
- $this->db = DB::getInstance();
76
-
77
- // Use default tables if not specified
78
- $this->data_table = defined('CLEANTALK_TBL_FIREWALL_DATA') ? CLEANTALK_TBL_FIREWALL_DATA : $this->db->prefix . 'cleantalk_sfw';
79
- $this->log_table = defined('CLEANTALK_TBL_FIREWALL_LOG') ? CLEANTALK_TBL_FIREWALL_LOG : $this->db->prefix . 'cleantalk_sfw_logs';
80
- }
81
-
82
- $this->debug = isset($_GET['debug']) && intval($_GET['debug']) === 1 ? true : false;
83
- }
84
-
85
- /**
86
- * Getting arrays of IP (REMOTE_ADDR, X-Forwarded-For, X-Real-Ip, Cf_Connecting_Ip)
87
- *
88
- * @param array $ips_input type of IP you want to receive
89
- * @param bool $v4_only
90
- *
91
- * @return array|mixed|null
92
- */
93
- public function ip__get($ips_input = array('real', 'remote_addr', 'x_forwarded_for', 'x_real_ip', 'cloud_flare'), $v4_only = true){
94
-
95
- $result = Helper::ip__get($ips_input, $v4_only);
96
-
97
- $result = !empty($result) ? array('real' => $result) : array();
98
-
99
- if(isset($_GET['sfw_test_ip'])){
100
- if(Helper::ip__validate($_GET['sfw_test_ip']) !== false){
101
- $result['sfw_test'] = $_GET['sfw_test_ip'];
102
- $this->test = true;
103
- }
104
- }
105
-
106
- return $result;
107
-
108
- }
109
-
110
- /**
111
- * Checks IP via Database
112
- */
113
- public function ip_check()
114
- {
115
- foreach($this->ip_array as $origin => $current_ip){
116
-
117
- $current_ip_v4 = sprintf("%u", ip2long($current_ip));
118
- for ( $needles = array(), $m = 6; $m <= 32; $m ++ ) {
119
- $mask = sprintf( "%u", ip2long( long2ip( - 1 << ( 32 - (int) $m ) ) ) );
120
- $needles[] = bindec( decbin( $mask ) & decbin( $current_ip_v4 ) );
121
- }
122
- $needles = array_unique( $needles );
123
-
124
- $query = "SELECT
125
- network, mask, status
126
- FROM " . $this->data_table . "
127
- WHERE network IN (". implode( ',', $needles ) .")
128
- AND network = " . $current_ip_v4 . " & mask
129
- ORDER BY status DESC LIMIT 1;";
130
- $this->db->set_query($query)->fetch();
131
-
132
- if( ! empty( $this->db->result ) ){
133
-
134
- if ( 1 == $this->db->result['status'] ) {
135
- // It is the White Listed network - will be passed.
136
- $this->passed_ips[$origin] = array(
137
- 'ip' => $current_ip,
138
- );
139
- $this->all_ips[$origin] = array(
140
- 'ip' => $current_ip,
141
- 'status' => 1,
142
- );
143
- break;
144
- } else {
145
- $this->pass = false;
146
- $this->blocked_ips[$origin] = array(
147
- 'ip' => $current_ip,
148
- 'network' => long2ip($this->db->result['network']),
149
- 'mask' => Helper::ip__mask__long_to_number($this->db->result['mask']),
150
- );
151
- $this->all_ips[$origin] = array(
152
- 'ip' => $current_ip,
153
- 'network' => long2ip($this->db->result['network']),
154
- 'mask' => Helper::ip__mask__long_to_number($this->db->result['mask']),
155
- 'status' => -1,
156
- );
157
- }
158
-
159
- }else{
160
- $this->passed_ips[$origin] = array(
161
- 'ip' => $current_ip,
162
- );
163
- $this->all_ips[$origin] = array(
164
- 'ip' => $current_ip,
165
- 'status' => 1,
166
- );
167
- }
168
- }
169
- }
170
-
171
- /**
172
- * Add entry to SFW log.
173
- * Writes to database.
174
- *
175
- * @param string $ip
176
- * @param string $result "blocked" or "passed"
177
- */
178
- public function logs__update($ip, $result){
179
-
180
- if($ip === NULL || $result === NULL){
181
- return;
182
- }
183
-
184
- $blocked = ($result == 'blocked' ? ' + 1' : '');
185
- $time = time();
186
-
187
- $query = "INSERT INTO ".$this->log_table."
188
- SET
189
- ip = '$ip',
190
- all_entries = 1,
191
- blocked_entries = 1,
192
- entries_timestamp = '".intval($time)."'
193
- ON DUPLICATE KEY
194
- UPDATE
195
- all_entries = all_entries + 1,
196
- blocked_entries = blocked_entries".strval($blocked).",
197
- entries_timestamp = '".intval($time)."'";
198
-
199
- $this->db->execute($query);
200
- }
201
-
202
- /**
203
- * Sends and wipe SFW log
204
- *
205
- * @param string $ct_key API key
206
- *
207
- * @return array|bool array('error' => STRING)
208
- */
209
- public function logs__send($ct_key){
210
-
211
- //Getting logs
212
- $query = "SELECT * FROM ".$this->log_table.";";
213
- $this->db->fetch_all($query);
214
-
215
- if(count($this->db->result)){
216
-
217
- //Compile logs
218
- $data = array();
219
- foreach($this->db->result as $key => $value){
220
- $data[] = array(trim($value['ip']), $value['all_entries'], $value['all_entries']-$value['blocked_entries'], $value['entries_timestamp']);
221
- }
222
- unset($key, $value);
223
-
224
- //Sending the request
225
- $result = API::method__sfw_logs($ct_key, $data);
226
- //Checking answer and deleting all lines from the table
227
- if(empty($result['error'])){
228
- if($result['rows'] == count($data)){
229
- $this->db->execute("TRUNCATE TABLE ".$this->log_table.";");
230
- return $result;
231
- }
232
- return array('error' => 'SENT_AND_RECEIVED_LOGS_COUNT_DOESNT_MACH');
233
- }else{
234
- return $result;
235
- }
236
-
237
- } else {
238
- return $result = array( 'rows' => 0 );
239
- }
240
- }
241
-
242
- /**
243
- * Updates SFW local base
244
- *
245
- * @param string $ct_key API key
246
- * @param null|string $file_url File URL with SFW data.
247
- * @param bool $immediate Requires immmediate update. Without remote call
248
- *
249
- * @return array|bool array('error' => STRING)
250
- */
251
- public function sfw_update($ct_key, $file_url = null, $immediate = false){
252
-
253
- // Getting remote file name
254
- if(!$file_url){
255
-
256
- sleep(6);
257
-
258
- $result = API::method__get_2s_blacklists_db($ct_key, 'multifiles', '2_0');
259
-
260
- if(empty($result['error'])){
261
-
262
- if( !empty($result['file_url']) ){
263
-
264
- if(Helper::http__request($result['file_url'], array(), 'get_code') === 200) {
265
-
266
- if(ini_get('allow_url_fopen')) {
267
-
268
- $pattenrs = array();
269
- $pattenrs[] = 'get';
270
-
271
- if(!$immediate) $pattenrs[] = 'async';
272
-
273
- // Clear SFW table
274
- $this->db->execute("TRUNCATE TABLE {$this->data_table};");
275
- $this->db->set_query("SELECT COUNT(network) as cnt FROM {$this->data_table};")->fetch(); // Check if it is clear
276
- if($this->db->result['cnt'] != 0){
277
- $this->db->execute("DELETE FROM {$this->data_table};"); // Truncate table
278
- $this->db->set_query("SELECT COUNT(network) as cnt FROM {$this->data_table};")->fetch(); // Check if it is clear
279
- if($this->db->result['cnt'] != 0){
280
- return array('error' => 'COULD_NOT_CLEAR_SFW_TABLE'); // throw an error
281
- }
282
- }
283
-
284
- $gf = \gzopen($result['file_url'], 'rb');
285
-
286
- if ($gf) {
287
-
288
- $file_urls = array();
289
-
290
- while( ! \gzeof($gf) )
291
- $file_urls[] = trim( \gzgets($gf, 1024) );
292
-
293
- \gzclose($gf);
294
-
295
- return Helper::http__request(
296
- get_option('siteurl'),
297
- array(
298
- 'spbc_remote_call_token' => md5($ct_key),
299
- 'spbc_remote_call_action' => 'sfw_update',
300
- 'plugin_name' => 'apbct',
301
- 'file_urls' => implode(',', $file_urls),
302
- ),
303
- $pattenrs
304
- );
305
- }else
306
- return array('error' => 'COULD_NOT_OPEN_REMOTE_FILE_SFW');
307
- }else
308
- return array('error' => 'ERROR_ALLOW_URL_FOPEN_DISABLED');
309
- }else
310
- return array('error' => 'NO_FILE_URL_PROVIDED');
311
- }else
312
- return array('error' => 'BAD_RESPONSE');
313
- }else
314
- return $result;
315
- }else{
316
-
317
- if(Helper::http__request($file_url, array(), 'get_code') === 200){ // Check if it's there
318
-
319
- $gf = \gzopen($file_url, 'rb');
320
-
321
- if($gf){
322
-
323
- if( ! \gzeof($gf) ){
324
-
325
- for( $count_result = 0; ! \gzeof($gf); ){
326
-
327
- $query = "INSERT INTO ".$this->data_table." VALUES %s";
328
-
329
- for($i=0, $values = array(); APBCT_WRITE_LIMIT !== $i && ! \gzeof($gf); $i++, $count_result++){
330
-
331
- $entry = trim( \gzgets($gf, 1024) );
332
-
333
- if(empty($entry)) continue;
334
-
335
- $entry = explode(',', $entry);
336
-
337
- // Cast result to int
338
- $ip = preg_replace('/[^\d]*/', '', $entry[0]);
339
- $mask = preg_replace('/[^\d]*/', '', $entry[1]);
340
- $private = isset($entry[2]) ? $entry[2] : 0;
341
-
342
- if(!$ip || !$mask) continue;
343
-
344
- $values[] = '('. $ip .','. $mask .','. $private .')';
345
-
346
- }
347
-
348
- if(!empty($values)){
349
- $query = sprintf($query, implode(',', $values).';');
350
- $this->db->execute($query);
351
- }
352
-
353
- }
354
-
355
- \gzclose($gf);
356
- return $count_result;
357
-
358
- }else
359
- return array('error' => 'ERROR_GZ_EMPTY');
360
- }else
361
- return array('error' => 'ERROR_OPEN_GZ_FILE');
362
- }else
363
- return array('error' => 'NO_REMOTE_FILE_FOUND');
364
- }
365
- }
366
-
367
- /**
368
- * Shows DIE page.
369
- * Stops script executing.
370
- *
371
- * @param string $api_key
372
- * @param string $cookie_prefix
373
- * @param string $cookie_domain
374
- * @param bool $test
375
- */
376
- public function sfw_die($api_key, $cookie_prefix = '', $cookie_domain = '', $test = false)
377
- {
378
- die("IP {$this->blocked_ip} BLACKLISTED");
379
- }
380
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/{CleantalkAPI.php → Cleantalk/ApbctWP/API.php} RENAMED
@@ -1,10 +1,12 @@
1
  <?php
2
 
 
 
3
  /**
4
- * Class CleantalkAPI.
5
  * Compatible only with Wordpress.
6
  *
7
- * @depends Cleantalk\Antispam\API
8
  *
9
  * @version 1.0
10
  * @author Cleantalk team (welcome@cleantalk.org)
@@ -12,7 +14,7 @@
12
  * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
13
  * @see https://github.com/CleanTalk/wordpress-antispam
14
  */
15
- class CleantalkAPI extends Cleantalk\Antispam\API
16
  {
17
  /**
18
  * Function sends raw request to API server.
1
  <?php
2
 
3
+ namespace Cleantalk\ApbctWP;
4
+
5
  /**
6
+ * Class API.
7
  * Compatible only with Wordpress.
8
  *
9
+ * @depends \Cleantalk\Common\API
10
  *
11
  * @version 1.0
12
  * @author Cleantalk team (welcome@cleantalk.org)
14
  * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
15
  * @see https://github.com/CleanTalk/wordpress-antispam
16
  */
17
+ class API extends \Cleantalk\Common\API
18
  {
19
  /**
20
  * Function sends raw request to API server.
lib/{CleantalkUpgrader.php → Cleantalk/ApbctWP/CleantalkUpgrader.php} RENAMED
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
  /**
4
  * Antispam by CleanTalk plugin
5
  *
@@ -9,7 +11,7 @@
9
  * @since : 1.0.0
10
  */
11
 
12
- class CleantalkUpgrader extends Plugin_Upgrader
13
  {
14
 
15
  public $result;
1
  <?php
2
 
3
+ namespace Cleantalk\ApbctWP;
4
+
5
  /**
6
  * Antispam by CleanTalk plugin
7
  *
11
  * @since : 1.0.0
12
  */
13
 
14
+ class CleantalkUpgrader extends \Plugin_Upgrader
15
  {
16
 
17
  public $result;
lib/{CleantalkUpgraderSkin.php → Cleantalk/ApbctWP/CleantalkUpgraderSkin.php} RENAMED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
- class CleantalkUpgraderSkin extends WP_Upgrader_Skin
 
 
4
  {
5
 
6
  public $upgrader;
1
  <?php
2
 
3
+ namespace Cleantalk\ApbctWP;
4
+
5
+ class CleantalkUpgraderSkin extends \WP_Upgrader_Skin
6
  {
7
 
8
  public $upgrader;
lib/{CleantalkUpgraderSkin_Deprecated.php → Cleantalk/ApbctWP/CleantalkUpgraderSkin_Deprecated.php} RENAMED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
- class CleantalkUpgraderSkin_Deprecated extends WP_Upgrader_Skin
 
 
4
  {
5
 
6
  public $upgrader;
1
  <?php
2
 
3
+ namespace Cleantalk\ApbctWP;
4
+
5
+ class CleantalkUpgraderSkin_Deprecated extends \WP_Upgrader_Skin
6
  {
7
 
8
  public $upgrader;
lib/{CleantalkCron.php → Cleantalk/ApbctWP/Cron.php} RENAMED
@@ -1,11 +1,13 @@
1
  <?php
2
 
 
 
3
  /*
4
  * CleanTalk cron class
5
  * Version 1.0
6
  */
7
 
8
- class CleantalkCron
9
  {
10
  public $tasks = array(); // Array with tasks
11
  public $tasks_to_run = array(); // Array with tasks which should be run now
1
  <?php
2
 
3
+ namespace Cleantalk\ApbctWP;
4
+
5
  /*
6
  * CleanTalk cron class
7
  * Version 1.0
8
  */
9
 
10
+ class Cron
11
  {
12
  public $tasks = array(); // Array with tasks
13
  public $tasks_to_run = array(); // Array with tasks which should be run now
lib/{CleantalkDB.php → Cleantalk/ApbctWP/DB.php} RENAMED
@@ -1,11 +1,13 @@
1
  <?php
2
 
 
 
3
  /**
4
  * CleanTalk Wordpress Data Base driver
5
  * Compatible only with Wordpress.
6
  * Uses singleton pattern.
7
  *
8
- * @depends Cleantalk\Antispam\DB
9
  *
10
  * @version 3.2
11
  * @author Cleantalk team (welcome@cleantalk.org)
@@ -14,7 +16,7 @@
14
  * @see https://github.com/CleanTalk/wordpress-antispam
15
  */
16
 
17
- class CleantalkDB extends Cleantalk\Antispam\DB
18
  {
19
 
20
  private static $instance;
1
  <?php
2
 
3
+ namespace Cleantalk\ApbctWP;
4
+
5
  /**
6
  * CleanTalk Wordpress Data Base driver
7
  * Compatible only with Wordpress.
8
  * Uses singleton pattern.
9
  *
10
+ * @depends \Cleantalk\Common\DB
11
  *
12
  * @version 3.2
13
  * @author Cleantalk team (welcome@cleantalk.org)
16
  * @see https://github.com/CleanTalk/wordpress-antispam
17
  */
18
 
19
+ class DB extends \Cleantalk\Common\DB
20
  {
21
 
22
  private static $instance;
lib/Cleantalk/ApbctWP/Firewall/AntiBot.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ namespace Cleantalk\ApbctWP\Firewall;
5
+
6
+
7
+ use Cleantalk\Variables\Cookie;
8
+ use Cleantalk\Variables\Server;
9
+
10
+ class AntiBot extends \Cleantalk\Common\Firewall\FirewallModule{
11
+
12
+ public $module_name = 'ANTIBOT';
13
+
14
+ private $db__table__ac_logs;
15
+ private $api_key = '';
16
+ private $apbct = false;
17
+
18
+ /**
19
+ * AntiBot constructor.
20
+ *
21
+ * @param $log_table
22
+ * @param $ac_logs_table
23
+ * @param array $params
24
+ */
25
+ public function __construct( $log_table, $ac_logs_table, $params = array() ) {
26
+
27
+ $this->db__table__logs = $log_table ?: null;
28
+ $this->db__table__ac_logs = $ac_logs_table ?: null;
29
+
30
+ foreach( $params as $param_name => $param ){
31
+ $this->$param_name = isset( $this->$param_name ) ? $param : false;
32
+ }
33
+
34
+ }
35
+
36
+ /**
37
+ * Use this method to execute main logic of the module.
38
+ *
39
+ * @return array Array of the check results
40
+ */
41
+ public function check() {
42
+
43
+ $results = array();
44
+
45
+ foreach( $this->ip_array as $ip_origin => $current_ip ){
46
+
47
+ // @todo Rename ip column to sign. Use IP + UserAgent for it.
48
+
49
+ $result = $this->db->fetch(
50
+ "SELECT ip"
51
+ . ' FROM `' . $this->db__table__ac_logs . '`'
52
+ . " WHERE ip = '$current_ip'"
53
+ . " LIMIT 1;"
54
+ );
55
+
56
+ if( ! empty( $result ) && isset( $result['ip'] ) ){
57
+ if( Cookie::get('apbct_antibot') !== md5( $this->api_key . $current_ip ) ){
58
+ $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'DENY_ANTIBOT', );
59
+ }
60
+ }else{
61
+ add_action( 'wp_head', array( '\Cleantalk\ApbctWP\Firewall\AntiBot', 'set_cookie' ) );
62
+ global $apbct_antibot_ip;
63
+ $apbct_antibot_ip = $current_ip;
64
+ }
65
+ }
66
+
67
+ return $results;
68
+
69
+ }
70
+
71
+ public static function set_cookie(){
72
+ global $apbct, $apbct_antibot_ip;
73
+ echo '<script>document.cookie = "apbct_antibot=' . md5( $apbct->api_key . $apbct_antibot_ip ) . '; path=/; expires=0; samesite=lax";</script>';
74
+ }
75
+
76
+ /**
77
+ * Add entry to SFW log.
78
+ * Writes to database.
79
+ *
80
+ * @param string $ip
81
+ * @param $status
82
+ */
83
+ public function update_log( $ip, $status ) {
84
+
85
+ $blocked = ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' );
86
+
87
+ if( $blocked ){
88
+
89
+ $id = md5( $ip . $status );
90
+ $time = time();
91
+
92
+ $query = "INSERT INTO " . $this->db__table__logs . "
93
+ SET
94
+ id = '$id',
95
+ ip = '$ip',
96
+ status = '$status',
97
+ all_entries = 1,
98
+ blocked_entries = 1,
99
+ entries_timestamp = '" . intval( $time ) . "'
100
+ ON DUPLICATE KEY
101
+ UPDATE
102
+ all_entries = all_entries + 1,
103
+ blocked_entries = blocked_entries" . strval( $blocked ) . ",
104
+ entries_timestamp = '" . intval( $time ) . "'";
105
+
106
+ $this->db->execute( $query );
107
+ }
108
+ }
109
+
110
+ public function _die( $result ){
111
+
112
+ // Headers
113
+ if(headers_sent() === false){
114
+ header('Expires: '.date(DATE_RFC822, mktime(0, 0, 0, 1, 1, 1971)));
115
+ header('Cache-Control: no-store, no-cache, must-revalidate');
116
+ header('Cache-Control: post-check=0, pre-check=0', FALSE);
117
+ header('Pragma: no-cache');
118
+ header("HTTP/1.0 403 Forbidden");
119
+ }
120
+
121
+ // File exists?
122
+ if(file_exists(CLEANTALK_PLUGIN_DIR . "lib/Cleantalk/ApbctWP/Firewall/die_page__antibot.html")){
123
+
124
+ $sfw_die_page = file_get_contents(CLEANTALK_PLUGIN_DIR . "lib/Cleantalk/ApbctWP/Firewall/die_page__antibot.html");
125
+
126
+ // Translation
127
+ $request_uri = Server::get( 'REQUEST_URI' );
128
+ $sfw_die_page = str_replace('{SFW_DIE_NOTICE_IP}', __('Anti-Crawler Protection is activated for your IP ', 'cleantalk-spam-protect'), $sfw_die_page);
129
+ $sfw_die_page = str_replace('{SFW_DIE_MAKE_SURE_JS_ENABLED}', __('To continue working with web site, please make sure that you have enabled JavaScript.', 'cleantalk-spam-protect'), $sfw_die_page);
130
+ $sfw_die_page = str_replace('{SFW_DIE_YOU_WILL_BE_REDIRECTED}', sprintf(__('You will be automatically redirected to the requested page after %d seconds.', 'cleantalk-spam-protect'), 30), $sfw_die_page);
131
+ $sfw_die_page = str_replace('{CLEANTALK_TITLE}', __('Antispam by CleanTalk', 'cleantalk-spam-protect'), $sfw_die_page);
132
+
133
+ $sfw_die_page = str_replace('{REMOTE_ADDRESS}', $result['ip'], $sfw_die_page);
134
+
135
+ // Service info
136
+ $sfw_die_page = str_replace('{SERVICE_ID}', $this->apbct->data['service_id'], $sfw_die_page);
137
+ $sfw_die_page = str_replace('{HOST}', Server::get( 'HTTP_HOST' ), $sfw_die_page);
138
+
139
+ $sfw_die_page = str_replace('{SFW_COOKIE}', md5( $this->api_key . $result['ip'] ), $sfw_die_page );
140
+
141
+ $sfw_die_page = str_replace('{GENERATED}', "<p>The page was generated at&nbsp;".date("D, d M Y H:i:s")."</p>",$sfw_die_page);
142
+
143
+ wp_die($sfw_die_page, "Blacklisted", Array('response'=>403));
144
+
145
+ }else{
146
+ wp_die("IP BLACKLISTED", "Blacklisted", Array('response'=>403));
147
+ }
148
+
149
+ }
150
+ }
lib/Cleantalk/ApbctWP/Firewall/AntiCrawler.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Cleantalk\ApbctWP\Firewall;
4
+
5
+ use Cleantalk\Common\Helper as Helper;
6
+ use Cleantalk\Variables\Server;
7
+
8
+ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule{
9
+
10
+ public $module_name = 'ANTICRAWLER';
11
+
12
+ private $db__table__ac_logs;
13
+
14
+ private $view_limit = 10;
15
+ private $apbct = array();
16
+ private $store_interval = 30;
17
+ private $block_period = 30;
18
+ private $chance_to_clean = 100;
19
+
20
+ /**
21
+ * AntiCrawler constructor.
22
+ *
23
+ * @param $log_table
24
+ * @param $ac_logs_table
25
+ * @param array $params
26
+ */
27
+ public function __construct( $log_table, $ac_logs_table, $params = array() ) {
28
+
29
+ $this->db__table__logs = $log_table ?: null;
30
+ $this->db__table__ac_logs = $ac_logs_table ?: null;
31
+
32
+ foreach( $params as $param_name => $param ){
33
+ $this->$param_name = isset( $this->$param_name ) ? $param : false;
34
+ }
35
+
36
+ }
37
+
38
+ /**
39
+ * Use this method to execute main logic of the module.
40
+ * @return array
41
+ */
42
+ public function check() {
43
+
44
+ $results = array();
45
+
46
+ $this->clear_table();
47
+
48
+ $time = time() - $this->store_interval;
49
+
50
+ foreach( $this->ip_array as $ip_origin => $current_ip ){
51
+
52
+ // @todo Rename ip column to sign. Use IP + UserAgent for it.
53
+
54
+ $result = $this->db->fetch_all(
55
+ "SELECT SUM(entries) as total_count"
56
+ . ' FROM `' . $this->db__table__ac_logs . '`'
57
+ . " WHERE ip = '$current_ip' AND interval_start > '$time';"
58
+ );
59
+
60
+ if( ! empty( $result ) && isset( $result[0]['total_count'] ) && $result[0]['total_count'] >= $this->view_limit ){
61
+ $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'DENY_ANTICRAWLER', );
62
+ }
63
+ }
64
+
65
+ if( ! empty( $results ) ){
66
+ // Do block page
67
+ return $results;
68
+ } else{
69
+ // Do logging entries
70
+ $this->update_ac_log();
71
+ }
72
+
73
+ return $results;
74
+
75
+ }
76
+
77
+ private function update_ac_log() {
78
+
79
+ $interval_time = Helper::time__get_interval_start( $this->store_interval );
80
+
81
+ // @todo Rename ip column to sign. Use IP + UserAgent for it.
82
+
83
+ foreach( $this->ip_array as $ip_origin => $current_ip ){
84
+ $id = md5( $current_ip . $interval_time );
85
+ $this->db->execute(
86
+ "INSERT INTO " . $this->db__table__ac_logs . " SET
87
+ id = '$id',
88
+ ip = '$current_ip',
89
+ entries = 1,
90
+ interval_start = $interval_time
91
+ ON DUPLICATE KEY UPDATE
92
+ ip = ip,
93
+ entries = entries + 1,
94
+ interval_start = $interval_time;"
95
+ );
96
+ }
97
+
98
+ }
99
+
100
+ private function clear_table() {
101
+
102
+ if( rand( 0, 1000 ) < $this->chance_to_clean ){
103
+ $interval_start = \Cleantalk\ApbctWP\Helper::time__get_interval_start( $this->block_period );
104
+ $this->db->execute(
105
+ 'DELETE
106
+ FROM ' . $this->db__table__ac_logs . '
107
+ WHERE interval_start < '. $interval_start .'
108
+ LIMIT 100000;'
109
+ );
110
+ }
111
+ }
112
+
113
+ /**
114
+ * Add entry to SFW log.
115
+ * Writes to database.
116
+ *
117
+ * @param string $ip
118
+ * @param $status
119
+ */
120
+ public function update_log( $ip, $status ) {
121
+
122
+ $id = md5($ip.$status);
123
+ $blocked = ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' );
124
+ $time = time();
125
+
126
+ $query = "INSERT INTO " . $this->db__table__logs . "
127
+ SET
128
+ id = '$id',
129
+ ip = '$ip',
130
+ status = '$status',
131
+ all_entries = 1,
132
+ blocked_entries = 1,
133
+ entries_timestamp = '" . intval( $time ) . "'
134
+ ON DUPLICATE KEY
135
+ UPDATE
136
+ all_entries = all_entries + 1,
137
+ blocked_entries = blocked_entries" . strval( $blocked ) . ",
138
+ entries_timestamp = '" . intval( $time ) . "'";
139
+
140
+ $this->db->execute( $query );
141
+ }
142
+
143
+ public function _die( $result ){
144
+
145
+ // Headers
146
+ if(headers_sent() === false){
147
+ header('Expires: '.date(DATE_RFC822, mktime(0, 0, 0, 1, 1, 1971)));
148
+ header('Cache-Control: no-store, no-cache, must-revalidate');
149
+ header('Cache-Control: post-check=0, pre-check=0', FALSE);
150
+ header('Pragma: no-cache');
151
+ header("HTTP/1.0 403 Forbidden");
152
+ }
153
+
154
+ // File exists?
155
+ if(file_exists(CLEANTALK_PLUGIN_DIR . "lib/Cleantalk/ApbctWP/Firewall/die_page__anticrawler.html")){
156
+
157
+ $sfw_die_page = file_get_contents(CLEANTALK_PLUGIN_DIR . "lib/Cleantalk/ApbctWP/Firewall/die_page__anticrawler.html");
158
+
159
+ // Translation
160
+ $request_uri = Server::get( 'REQUEST_URI' );
161
+ $sfw_die_page = str_replace('{SFW_DIE_NOTICE_IP}', __('Bot Protection is activated for your IP', 'cleantalk-spam-protect'), $sfw_die_page);
162
+ $sfw_die_page = str_replace('{SFW_DIE_MAKE_SURE_JS_ENABLED}', __('To continue working with web site, please make sure that you have enabled JavaScript.', 'cleantalk-spam-protect'), $sfw_die_page);
163
+ $sfw_die_page = str_replace('{SFW_DIE_YOU_WILL_BE_REDIRECTED}', sprintf(__('You will be automatically redirected to the requested page after %d seconds.', 'cleantalk-spam-protect'), 30), $sfw_die_page);
164
+ $sfw_die_page = str_replace('{CLEANTALK_TITLE}', __('Antispam by CleanTalk', 'cleantalk-spam-protect'), $sfw_die_page);
165
+
166
+ $sfw_die_page = str_replace('{REMOTE_ADDRESS}', $result['ip'], $sfw_die_page);
167
+
168
+ // Service info
169
+ $sfw_die_page = str_replace('{REQUEST_URI}', $request_uri, $sfw_die_page);
170
+ $sfw_die_page = str_replace('{SERVICE_ID}', $this->apbct->data['service_id'], $sfw_die_page);
171
+ $sfw_die_page = str_replace('{HOST}', Server::get( 'HTTP_HOST' ), $sfw_die_page);;
172
+
173
+ $sfw_die_page = str_replace('{GENERATED}', "<p>The page was generated at&nbsp;".date("D, d M Y H:i:s")."</p>",$sfw_die_page);
174
+
175
+ wp_die($sfw_die_page, "Blacklisted", Array('response'=>403));
176
+
177
+ }else{
178
+ wp_die("IP BLACKLISTED", "Blacklisted", Array('response'=>403));
179
+ }
180
+
181
+ }
182
+ }
lib/Cleantalk/ApbctWP/Firewall/SFW.php ADDED
@@ -0,0 +1,459 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Cleantalk\ApbctWP\Firewall;
4
+
5
+ use Cleantalk\Common\Helper as Helper;
6
+ use Cleantalk\Variables\Cookie;
7
+ use Cleantalk\Variables\Get;
8
+ use Cleantalk\Variables\Server;
9
+
10
+ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
11
+
12
+ /**
13
+ * @var bool
14
+ */
15
+ private $test;
16
+
17
+ // Additional params
18
+ private $sfw_counter = false;
19
+ private $api_key = false;
20
+ private $apbct = array();
21
+ private $set_cookies = false;
22
+ private $cookie_domain = false;
23
+
24
+ public $module_name = 'SFW';
25
+
26
+ private $real_ip;
27
+ private $debug;
28
+ private $debug_data = '';
29
+
30
+ /**
31
+ * FireWall_module constructor.
32
+ * Use this method to prepare any data for the module working.
33
+ *
34
+ * @param string $log_table
35
+ * @param string $data_table
36
+ * @param $params
37
+ */
38
+ public function __construct( $log_table, $data_table, $params = array() ){
39
+
40
+ $this->db__table__data = $data_table ?: null;
41
+ $this->db__table__logs = $log_table ?: null;
42
+
43
+ foreach( $params as $param_name => $param ){
44
+ $this->$param_name = isset( $this->$param_name ) ? $param : false;
45
+ }
46
+
47
+ $this->debug = (bool) Get::get( 'debug' );
48
+
49
+ }
50
+
51
+ /**
52
+ * @param $ips
53
+ */
54
+ public function ip__append_additional( &$ips ){
55
+
56
+ $this->real_ip = $ips['real'];
57
+
58
+ if( Get::get( 'sfw_test_ip' ) ){
59
+ if( Helper::ip__validate( Get::get( 'sfw_test_ip' ) ) !== false ){
60
+ $ips['sfw_test'] = Get::get( 'sfw_test_ip' );
61
+ $this->test_ip = Get::get( 'sfw_test_ip' );
62
+ $this->test = true;
63
+ }
64
+ }
65
+
66
+
67
+ }
68
+
69
+ /**
70
+ * Use this method to execute main logic of the module.
71
+ *
72
+ * @return array Array of the check results
73
+ */
74
+ public function check(){
75
+
76
+ $results = array();
77
+
78
+ // Skip by cookie
79
+ foreach( $this->ip_array as $current_ip ){
80
+
81
+ if( Cookie::get( 'ct_sfw_pass_key' ) == md5( $current_ip . $this->api_key ) ){
82
+
83
+ if( Cookie::get( 'ct_sfw_passed' ) ){
84
+
85
+ if( ! headers_sent() ){
86
+ \Cleantalk\Common\Helper::apbct_cookie__set( 'ct_sfw_passed', '0', time() + 86400 * 3, '/', null, false, true, 'Lax' );
87
+ }
88
+
89
+ $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_SFW_BY_COOKIE', );
90
+
91
+ if( $this->sfw_counter ){
92
+ $this->apbct->data['sfw_counter']['all'] ++;
93
+ $this->apbct->saveData();
94
+ }
95
+
96
+ }
97
+
98
+ return $results;
99
+ }
100
+ }
101
+
102
+ // Common check
103
+ foreach($this->ip_array as $origin => $current_ip){
104
+
105
+ $current_ip_v4 = sprintf("%u", ip2long($current_ip));
106
+ for ( $needles = array(), $m = 6; $m <= 32; $m ++ ) {
107
+ $mask = sprintf( "%u", ip2long( long2ip( - 1 << ( 32 - (int) $m ) ) ) );
108
+ $needles[] = bindec( decbin( $mask ) & decbin( $current_ip_v4 ) );
109
+ }
110
+ $needles = array_unique( $needles );
111
+
112
+ $db_results = $this->db->fetch_all("SELECT
113
+ network, mask, status
114
+ FROM " . $this->db__table__data . "
115
+ WHERE network IN (". implode( ',', $needles ) .")
116
+ AND network = " . $current_ip_v4 . " & mask");
117
+
118
+ if( ! empty( $db_results ) ){
119
+
120
+ foreach( $db_results as $db_result ){
121
+
122
+ if( $db_result['status'] === 1 )
123
+ $results[] = array('ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_SFW_BY_WHITELIST',);
124
+ else
125
+ $results[] = array('ip' => $current_ip, 'is_personal' => false, 'status' => 'DENY_SFW',);
126
+
127
+ }
128
+
129
+ }else{
130
+
131
+ $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_SFW' );
132
+
133
+ }
134
+ }
135
+
136
+ return $results;
137
+ }
138
+
139
+ /**
140
+ * Add entry to SFW log.
141
+ * Writes to database.
142
+ *
143
+ * @param string $ip
144
+ * @param $status
145
+ */
146
+ public function update_log( $ip, $status ) {
147
+
148
+ $id = md5($ip.$status);
149
+ $blocked = ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' );
150
+ $time = time();
151
+
152
+ $query = "INSERT INTO " . $this->db__table__logs . "
153
+ SET
154
+ id = '$id',
155
+ ip = '$ip',
156
+ status = '$status',
157
+ all_entries = 1,
158
+ blocked_entries = 1,
159
+ entries_timestamp = '" . $time . "'
160
+ ON DUPLICATE KEY
161
+ UPDATE
162
+ all_entries = all_entries + 1,
163
+ blocked_entries = blocked_entries" . strval( $blocked ) . ",
164
+ entries_timestamp = '" . intval( $time ) . "'";
165
+
166
+ $this->db->execute( $query );
167
+ }
168
+
169
+ public function actions_for_denied( $result ){
170
+
171
+ if( $this->sfw_counter ){
172
+ $this->apbct->data['sfw_counter']['blocked']++;
173
+ $this->apbct->saveData();
174
+ }
175
+
176
+ }
177
+
178
+ public function actions_for_passed( $result ){
179
+ if( $this->set_cookies && ! headers_sent() )
180
+ \Cleantalk\ApbctWP\Helper::apbct_cookie__set( 'ct_sfw_pass_key', md5( $result['ip'] . $this->api_key ), time() + 86400 * 30, '/', null, false );
181
+ }
182
+
183
+ /**
184
+ * Shows DIE page.
185
+ * Stops script executing.
186
+ *
187
+ * @param $result
188
+ * @param string $cookie_domain
189
+ * @param bool $test
190
+ */
191
+ public function _die( $result ){
192
+
193
+ // Statistics
194
+ if(!empty($this->blocked_ips)){
195
+ reset($this->blocked_ips);
196
+ $this->apbct->stats['last_sfw_block']['time'] = time();
197
+ $this->apbct->stats['last_sfw_block']['ip'] = $result['ip'];
198
+ $this->apbct->save('stats');
199
+ }
200
+
201
+ // Headers
202
+ if(headers_sent() === false){
203
+ header('Expires: '.date(DATE_RFC822, mktime(0, 0, 0, 1, 1, 1971)));
204
+ header('Cache-Control: no-store, no-cache, must-revalidate');
205
+ header('Cache-Control: post-check=0, pre-check=0', FALSE);
206
+ header('Pragma: no-cache');
207
+ header("HTTP/1.0 403 Forbidden");
208
+ }
209
+
210
+ // File exists?
211
+ if(file_exists(CLEANTALK_PLUGIN_DIR . "lib/Cleantalk/ApbctWP/Firewall/die_page__sfw.html")){
212
+
213
+ $sfw_die_page = file_get_contents(CLEANTALK_PLUGIN_DIR . "lib/Cleantalk/ApbctWP/Firewall/die_page__sfw.html");
214
+
215
+ // Translation
216
+ $request_uri = Server::get( 'REQUEST_URI' );
217
+ $sfw_die_page = str_replace('{SFW_DIE_NOTICE_IP}', __('SpamFireWall is activated for your IP ', 'cleantalk-spam-protect'), $sfw_die_page);
218
+ $sfw_die_page = str_replace('{SFW_DIE_MAKE_SURE_JS_ENABLED}', __('To continue working with web site, please make sure that you have enabled JavaScript.', 'cleantalk-spam-protect'), $sfw_die_page);
219
+ $sfw_die_page = str_replace('{SFW_DIE_CLICK_TO_PASS}', __('Please click the link below to pass the protection,', 'cleantalk-spam-protect'), $sfw_die_page);
220
+ $sfw_die_page = str_replace('{SFW_DIE_YOU_WILL_BE_REDIRECTED}', sprintf(__('Or you will be automatically redirected to the requested page after %d seconds.', 'cleantalk-spam-protect'), 3), $sfw_die_page);
221
+ $sfw_die_page = str_replace('{CLEANTALK_TITLE}', __('Antispam by CleanTalk', 'cleantalk-spam-protect'), $sfw_die_page);
222
+ $sfw_die_page = str_replace('{TEST_TITLE}', ($this->test ? __('This is the testing page for SpamFireWall', 'cleantalk-spam-protect') : ''), $sfw_die_page);
223
+
224
+ if($this->test){
225
+ $sfw_die_page = str_replace('{REAL_IP__HEADER}', 'Real IP:', $sfw_die_page);
226
+ $sfw_die_page = str_replace('{TEST_IP__HEADER}', 'Test IP:', $sfw_die_page);
227
+ $sfw_die_page = str_replace('{TEST_IP}', $this->test_ip, $sfw_die_page);
228
+ $sfw_die_page = str_replace('{REAL_IP}', $this->real_ip, $sfw_die_page);
229
+ }else{
230
+ $sfw_die_page = str_replace('{REAL_IP__HEADER}', '', $sfw_die_page);
231
+ $sfw_die_page = str_replace('{TEST_IP__HEADER}', '', $sfw_die_page);
232
+ $sfw_die_page = str_replace('{TEST_IP}', '', $sfw_die_page);
233
+ $sfw_die_page = str_replace('{REAL_IP}', '', $sfw_die_page);
234
+ }
235
+
236
+ $sfw_die_page = str_replace('{REMOTE_ADDRESS}', $result['ip'], $sfw_die_page);
237
+
238
+ // Service info
239
+ $sfw_die_page = str_replace('{REQUEST_URI}', $request_uri, $sfw_die_page);
240
+ $sfw_die_page = str_replace('{COOKIE_PREFIX}', '', $sfw_die_page);
241
+ $sfw_die_page = str_replace('{COOKIE_DOMAIN}', $this->cookie_domain, $sfw_die_page);
242
+ $sfw_die_page = str_replace('{SERVICE_ID}', $this->apbct->data['service_id'], $sfw_die_page);
243
+ $sfw_die_page = str_replace('{HOST}', Server::get( 'HTTP_HOST' ), $sfw_die_page);
244
+
245
+ $sfw_die_page = str_replace(
246
+ '{SFW_COOKIE}',
247
+ $this->test
248
+ ? $this->test_ip
249
+ : md5( $result['ip'] . $this->api_key ),
250
+ $sfw_die_page
251
+ );
252
+
253
+ if($this->debug){
254
+ $debug = '<h1>Headers</h1>'
255
+ . var_export(apache_request_headers(), true)
256
+ . '<h1>REMOTE_ADDR</h1>'
257
+ . Server::get( 'REMOTE_ADDR' )
258
+ . '<h1>SERVER_ADDR</h1>'
259
+ . Server::get( 'REMOTE_ADDR' )
260
+ . '<h1>IP_ARRAY</h1>'
261
+ . var_export($this->ip_array, true)
262
+ . '<h1>ADDITIONAL</h1>'
263
+ . var_export($this->debug_data, true);
264
+ }else
265
+ $debug = '';
266
+
267
+ $sfw_die_page = str_replace( "{DEBUG}", $debug, $sfw_die_page );
268
+ $sfw_die_page = str_replace('{GENERATED}', "<p>The page was generated at&nbsp;".date("D, d M Y H:i:s")."</p>",$sfw_die_page);
269
+
270
+ wp_die($sfw_die_page, "Blacklisted", Array('response'=>403));
271
+
272
+ }else{
273
+ wp_die("IP BLACKLISTED", "Blacklisted", Array('response'=>403));
274
+ }
275
+
276
+ }
277
+
278
+ /**
279
+ * Sends and wipe SFW log
280
+ *
281
+ * @param $db
282
+ * @param $log_table
283
+ * @param string $ct_key API key
284
+ *
285
+ * @return array|bool array('error' => STRING)
286
+ */
287
+ public static function send_log( $db, $log_table, $ct_key ) {
288
+
289
+ //Getting logs
290
+ $query = "SELECT * FROM " . $log_table . ";";
291
+ $db->fetch_all( $query );
292
+
293
+ if( count( $db->result ) ){
294
+
295
+ //Compile logs
296
+ $data = array();
297
+ foreach( $db->result as $key => $value ){
298
+
299
+ $value['status'] = $value['status'] === 'DENY_ANTICRAWLER' ? 'BOT_PROTECTION' : $value['status'];
300
+ $value['status'] = $value['status'] === 'DENY_ANTIBOT' ? 'FLOOD_PROTECTION' : $value['status'];
301
+
302
+ $data[] = array(
303
+ trim( $value['ip'] ),
304
+ $value['all_entries'],
305
+ $value['all_entries'] - $value['blocked_entries'],
306
+ $value['entries_timestamp'],
307
+ $value['status'],
308
+ );
309
+ }
310
+ unset( $key, $value );
311
+
312
+ //Sending the request
313
+ $result = \Cleantalk\Common\API::method__sfw_logs( $ct_key, $data );
314
+ //Checking answer and deleting all lines from the table
315
+ if( empty( $result['error'] ) ){
316
+ if( $result['rows'] == count( $data ) ){
317
+ $db->execute( "TRUNCATE TABLE " . $log_table . ";" );
318
+
319
+ return $result;
320
+ }
321
+
322
+ return array( 'error' => 'SENT_AND_RECEIVED_LOGS_COUNT_DOESNT_MACH' );
323
+ } else{
324
+ return $result;
325
+ }
326
+
327
+ } else{
328
+ return $result = array( 'rows' => 0 );
329
+ }
330
+ }
331
+
332
+
333
+ /**
334
+ * Updates SFW local base
335
+ *
336
+ * @param $db
337
+ * @param $db__table__data
338
+ * @param string $ct_key API key
339
+ * @param null|string $file_url File URL with SFW data.
340
+ * @param bool $immediate Requires immmediate update. Without remote call
341
+ *
342
+ * @return array|bool array('error' => STRING)
343
+ */
344
+ public static function update( $db, $db__table__data, $ct_key, $file_url = null, $immediate = false){
345
+
346
+ // Getting remote file name
347
+ if(!$file_url){
348
+
349
+ sleep(6);
350
+
351
+ $result = \Cleantalk\Common\API::method__get_2s_blacklists_db($ct_key, 'multifiles', '2_0');
352
+
353
+ if(empty($result['error'])){
354
+
355
+ if( !empty($result['file_url']) ){
356
+
357
+ if(Helper::http__request($result['file_url'], array(), 'get_code') === 200) {
358
+
359
+ if(ini_get('allow_url_fopen')) {
360
+
361
+ $patterns = array();
362
+ $patterns[] = 'get';
363
+
364
+ if(!$immediate) $patterns[] = 'async';
365
+
366
+ // Clear SFW table
367
+ $db->execute("TRUNCATE TABLE {$db__table__data};");
368
+ $db->set_query("SELECT COUNT(network) as cnt FROM {$db__table__data};")->fetch(); // Check if it is clear
369
+ if($db->result['cnt'] != 0){
370
+ $db->execute("DELETE FROM {$db__table__data};"); // Truncate table
371
+ $db->set_query("SELECT COUNT(network) as cnt FROM {$db__table__data};")->fetch(); // Check if it is clear
372
+ if($db->result['cnt'] != 0){
373
+ return array('error' => 'COULD_NOT_CLEAR_SFW_TABLE'); // throw an error
374
+ }
375
+ }
376
+
377
+ $gf = \gzopen($result['file_url'], 'rb');
378
+
379
+ if ($gf) {
380
+
381
+ $file_urls = array();
382
+
383
+ while( ! \gzeof($gf) )
384
+ $file_urls[] = trim( \gzgets($gf, 1024) );
385
+
386
+ \gzclose($gf);
387
+
388
+ return Helper::http__request(
389
+ get_option('siteurl'),
390
+ array(
391
+ 'spbc_remote_call_token' => md5($ct_key),
392
+ 'spbc_remote_call_action' => 'sfw_update',
393
+ 'plugin_name' => 'apbct',
394
+ 'file_urls' => implode(',', $file_urls),
395
+ ),
396
+ $patterns
397
+ );
398
+ }else
399
+ return array('error' => 'COULD_NOT_OPEN_REMOTE_FILE_SFW');
400
+ }else
401
+ return array('error' => 'ERROR_ALLOW_URL_FOPEN_DISABLED');
402
+ }else
403
+ return array('error' => 'NO_FILE_URL_PROVIDED');
404
+ }else
405
+ return array('error' => 'BAD_RESPONSE');
406
+ }else
407
+ return $result;
408
+ }else{
409
+
410
+ if(Helper::http__request($file_url, array(), 'get_code') === 200){ // Check if it's there
411
+
412
+ $gf = \gzopen($file_url, 'rb');
413
+
414
+ if($gf){
415
+
416
+ if( ! \gzeof($gf) ){
417
+
418
+ for( $count_result = 0; ! \gzeof($gf); ){
419
+
420
+ $query = "INSERT INTO ".$db__table__data." VALUES %s";
421
+
422
+ for($i=0, $values = array(); APBCT_WRITE_LIMIT !== $i && ! \gzeof($gf); $i++, $count_result++){
423
+
424
+ $entry = trim( \gzgets($gf, 1024) );
425
+
426
+ if(empty($entry)) continue;
427
+
428
+ $entry = explode(',', $entry);
429
+
430
+ // Cast result to int
431
+ $ip = preg_replace('/[^\d]*/', '', $entry[0]);
432
+ $mask = preg_replace('/[^\d]*/', '', $entry[1]);
433
+ $private = isset($entry[2]) ? $entry[2] : 0;
434
+
435
+ if(!$ip || !$mask) continue;
436
+
437
+ $values[] = '('. $ip .','. $mask .','. $private .')';
438
+
439
+ }
440
+
441
+ if(!empty($values)){
442
+ $query = sprintf($query, implode(',', $values).';');
443
+ $db->execute($query);
444
+ }
445
+
446
+ }
447
+
448
+ \gzclose($gf);
449
+ return $count_result;
450
+
451
+ }else
452
+ return array('error' => 'ERROR_GZ_EMPTY');
453
+ }else
454
+ return array('error' => 'ERROR_OPEN_GZ_FILE');
455
+ }else
456
+ return array('error' => 'NO_REMOTE_FILE_FOUND');
457
+ }
458
+ }
459
+ }
lib/Cleantalk/ApbctWP/Firewall/die_page__antibot.html ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang='en'>
3
+ <head>
4
+ <meta charset='utf-8' />
5
+ <meta name='viewport' content='width=device-width, initial-scale=1' />
6
+ <meta http-equiv="cache-control" content="no-cache">
7
+ <meta http-equiv="cache-control" content="private">
8
+ <meta http-equiv="cache-control" content="max-age=0, must-revalidate">
9
+ <meta http-equiv="cache-control" content="max-age=0, proxy-revalidate">
10
+ <meta http-equiv="expires" content="0" />
11
+ <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
12
+ <meta http-equiv="pragma" content="no-cache" />
13
+
14
+ <!--[if lt IE 9]>
15
+ <script src='http://html5shiv.googlecode.com/svn/trunk/html5.js'></script>
16
+ <![endif]-->
17
+ <style>
18
+ html{font-size: 14pt;}
19
+ h1{text-align:center}
20
+ h1.main{margin-top: 1em;margin-bottom: 3em;}
21
+ div.container {text-align:center;}
22
+ div.container p.js_notice{width: 60%; display: inline-block;}
23
+ div.footer {color: #666; text-align: center;}
24
+ div.footer a {color: #666; vertical-align:bottom; text-align: center;}
25
+
26
+ @media (max-width: 600px) {
27
+ }
28
+
29
+ .spinner {
30
+ margin-left: auto;
31
+ margin-right: auto;
32
+ width: 70px;
33
+ text-align: center;
34
+ }
35
+
36
+ .spinner > div {
37
+ width: 14px;
38
+ height: 14px;
39
+ background-color: #333;
40
+
41
+ border-radius: 100%;
42
+ display: inline-block;
43
+ -webkit-animation: sk-bouncedelay 1.4s infinite ease-in-out both;
44
+ animation: sk-bouncedelay 1.4s infinite ease-in-out both;
45
+ }
46
+
47
+ .spinner .bounce1 {
48
+ -webkit-animation-delay: -0.32s;
49
+ animation-delay: -0.32s;
50
+ }
51
+
52
+ .spinner .bounce2 {
53
+ -webkit-animation-delay: -0.16s;
54
+ animation-delay: -0.16s;
55
+ }
56
+
57
+ @-webkit-keyframes sk-bouncedelay {
58
+ 0%, 80%, 100% { -webkit-transform: scale(0) }
59
+ 40% { -webkit-transform: scale(1.0) }
60
+ }
61
+
62
+ @keyframes sk-bouncedelay {
63
+ 0%, 80%, 100% {
64
+ -webkit-transform: scale(0);
65
+ transform: scale(0);
66
+ } 40% {
67
+ -webkit-transform: scale(1.0);
68
+ transform: scale(1.0);
69
+ }
70
+ }
71
+ </style>
72
+ <script>
73
+ var ct_date = new Date;
74
+
75
+ function set_spamFireWallCookie(cookie_name, cookie_value) {
76
+ var date = new Date;
77
+ date.setDate(date.getDate() + 30);
78
+ document.cookie = cookie_name + '=' + escape(cookie_value) + '; path=/; expires=' + date.toUTCString() + '; samesite=lax';
79
+ return null;
80
+ }
81
+
82
+ function get_current_url() {
83
+ document.write(window.location.href);
84
+ return null;
85
+ }
86
+ </script>
87
+ </head>
88
+
89
+ <body>
90
+ <div class='container'>
91
+ <h1 class='main'>{SFW_DIE_NOTICE_IP}<a href='https://cleantalk.org/blacklists/{REMOTE_ADDRESS}' target='_blank'> {REMOTE_ADDRESS}</a></h1>
92
+
93
+ <div id='js_info'><br />{SFW_DIE_MAKE_SURE_JS_ENABLED}</div>
94
+
95
+ <div id='js_passed'>
96
+ <br />
97
+ <p class='js_notice'>{SFW_DIE_YOU_WILL_BE_REDIRECTED}</p>
98
+ <br />
99
+ <div class="spinner">
100
+ <div class="bounce1"></div>
101
+ <div class="bounce2"></div>
102
+ <div class="bounce3"></div>
103
+ </div>
104
+ {GENERATED}
105
+ <p>Browser time <span id='curr_date'></span></p>
106
+ </div>
107
+
108
+ </div>
109
+ <div style='position: relative; line-height: 8px; text-align: center;'>
110
+ <p style="margin: 0; display: inline-block; font-size: 10px; color: gray;">{SERVICE_ID}, </p>
111
+ <p style="margin: 0; display: inline-block; font-size: 10px; color: gray;">{HOST}</p>
112
+ </div>
113
+ <div class='footer'>
114
+ <a href='https://cleantalk.org' target='_blank'>{CLEANTALK_TITLE}</a>
115
+ </div>
116
+ <script type='text/javascript'>
117
+ var reload_timeout = 30000;
118
+ document.getElementById('js_info').style.display = 'none';
119
+ document.getElementById('js_passed').style.display = 'block';
120
+ document.getElementById('curr_date').innerHTML = ct_date.toGMTString();
121
+ set_spamFireWallCookie('apbct_antibot','{SFW_COOKIE}');
122
+
123
+ if(location.search.search('debug=1') === -1) {
124
+ setTimeout(function(){
125
+ window.location.href = window.location.origin + window.location.pathname + '?sfw=pass' + Math.round(ct_date.getTime()/1000);
126
+ }, reload_timeout);
127
+ }
128
+ </script>
129
+ </body>
130
+ </html>
lib/Cleantalk/ApbctWP/Firewall/die_page__anticrawler.html ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang='en'>
3
+ <head>
4
+ <meta charset='utf-8' />
5
+ <meta name='viewport' content='width=device-width, initial-scale=1' />
6
+ <meta http-equiv="cache-control" content="no-cache">
7
+ <meta http-equiv="cache-control" content="private">
8
+ <meta http-equiv="cache-control" content="max-age=0, must-revalidate">
9
+ <meta http-equiv="cache-control" content="max-age=0, proxy-revalidate">
10
+ <meta http-equiv="expires" content="0" />
11
+ <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
12
+ <meta http-equiv="pragma" content="no-cache" />
13
+
14
+ <!--[if lt IE 9]>
15
+ <script src='http://html5shiv.googlecode.com/svn/trunk/html5.js'></script>
16
+ <![endif]-->
17
+ <style>
18
+ html{font-size: 14pt;}
19
+ h1{text-align:center}
20
+ h1.main{margin-top: 1em;margin-bottom: 3em;}
21
+ div.container {text-align:center;}
22
+ div.container p.js_notice{width: 60%; display: inline-block;}
23
+ div.footer {color: #666; text-align: center;}
24
+ div.footer a {color: #666; vertical-align:bottom; text-align: center;}
25
+
26
+ @media (max-width: 600px) {
27
+ }
28
+
29
+ .spinner {
30
+ margin-left: auto;
31
+ margin-right: auto;
32
+ width: 70px;
33
+ text-align: center;
34
+ }
35
+
36
+ .spinner > div {
37
+ width: 14px;
38
+ height: 14px;
39
+ background-color: #333;
40
+
41
+ border-radius: 100%;
42
+ display: inline-block;
43
+ -webkit-animation: sk-bouncedelay 1.4s infinite ease-in-out both;
44
+ animation: sk-bouncedelay 1.4s infinite ease-in-out both;
45
+ }
46
+
47
+ .spinner .bounce1 {
48
+ -webkit-animation-delay: -0.32s;
49
+ animation-delay: -0.32s;
50
+ }
51
+
52
+ .spinner .bounce2 {
53
+ -webkit-animation-delay: -0.16s;
54
+ animation-delay: -0.16s;
55
+ }
56
+
57
+ @-webkit-keyframes sk-bouncedelay {
58
+ 0%, 80%, 100% { -webkit-transform: scale(0) }
59
+ 40% { -webkit-transform: scale(1.0) }
60
+ }
61
+
62
+ @keyframes sk-bouncedelay {
63
+ 0%, 80%, 100% {
64
+ -webkit-transform: scale(0);
65
+ transform: scale(0);
66
+ } 40% {
67
+ -webkit-transform: scale(1.0);
68
+ transform: scale(1.0);
69
+ }
70
+ }
71
+ </style>
72
+ <script>
73
+ var ct_date = new Date;
74
+
75
+ function set_spamFireWallCookie(cookie_name, cookie_value) {
76
+ var date = new Date;
77
+ date.setDate(date.getDate() + 30);
78
+ document.cookie = cookie_name + '=' + escape(cookie_value) + '; path=/; expires=' + date.toUTCString() + '; samesite=lax';
79
+ return null;
80
+ }
81
+
82
+ function get_current_url() {
83
+ document.write(window.location.href);
84
+ return null;
85
+ }
86
+ </script>
87
+ </head>
88
+
89
+ <body>
90
+ <div class='container'>
91
+ <h1 class='main'>{SFW_DIE_NOTICE_IP}<a href='https://cleantalk.org/blacklists/{REMOTE_ADDRESS}' target='_blank'> {REMOTE_ADDRESS}</a></h1>
92
+
93
+ <div id='js_info'><br />{SFW_DIE_MAKE_SURE_JS_ENABLED}</div>
94
+
95
+ <div id='js_passed'>
96
+ <br />
97
+ <p class='js_notice'>{SFW_DIE_YOU_WILL_BE_REDIRECTED}</p>
98
+ <br />
99
+ <div class="spinner">
100
+ <div class="bounce1"></div>
101
+ <div class="bounce2"></div>
102
+ <div class="bounce3"></div>
103
+ </div>
104
+ {GENERATED}
105
+ <p>Browser time <span id='curr_date'></span></p>
106
+ </div>
107
+
108
+ </div>
109
+ <div style='position: relative; line-height: 8px; text-align: center;'>
110
+ <p style="margin: 0; display: inline-block; font-size: 10px; color: gray;">{SERVICE_ID}, </p>
111
+ <p style="margin: 0; display: inline-block; font-size: 10px; color: gray;">{HOST}</p>
112
+ </div>
113
+ <div class='footer'>
114
+ <a href='https://cleantalk.org' target='_blank'>{CLEANTALK_TITLE}</a>
115
+ </div>
116
+ <script type='text/javascript'>
117
+ var reload_timeout = 30000;
118
+ document.getElementById('js_info').style.display = 'none';
119
+ document.getElementById('js_passed').style.display = 'block';
120
+ document.getElementById('curr_date').innerHTML = ct_date.toGMTString();
121
+
122
+ if(location.search.search('debug=1') === -1) {
123
+ setTimeout(function(){
124
+ window.location.href = window.location.origin + window.location.pathname + '?sfw=pass' + Math.round(ct_date.getTime()/1000);
125
+ }, reload_timeout);
126
+ }
127
+ </script>
128
+ </body>
129
+ </html>
inc/sfw_die_page.html → lib/Cleantalk/ApbctWP/Firewall/die_page__sfw.html RENAMED
@@ -89,14 +89,14 @@
89
  <body>
90
  <div class='container'>
91
  <h1 class='main'>{SFW_DIE_NOTICE_IP}<a href='https://cleantalk.org/blacklists/{REMOTE_ADDRESS}' target='_blank'>{REMOTE_ADDRESS}</a></h1>
92
-
93
- <h3>{REAL_IP__HEADER} {REAL_IP} {REAL_IP_BLOCKED}</h3>
94
- <h3>{TEST_IP__HEADER} {TEST_IP} {TEST_IP_BLOCKED}</h3>
95
-
96
  <h2>{TEST_TITLE}</h2>
97
 
98
  <div id='js_info'><br />{SFW_DIE_MAKE_SURE_JS_ENABLED}</div>
99
-
100
  <div id='js_passed'>
101
  <h3>{SFW_DIE_CLICK_TO_PASS}</h3>
102
  <a href='{REQUEST_URI}'><script>get_current_url();</script></a>
89
  <body>
90
  <div class='container'>
91
  <h1 class='main'>{SFW_DIE_NOTICE_IP}<a href='https://cleantalk.org/blacklists/{REMOTE_ADDRESS}' target='_blank'>{REMOTE_ADDRESS}</a></h1>
92
+
93
+ <h3>{REAL_IP__HEADER} {REAL_IP}</h3>
94
+ <h3>{TEST_IP__HEADER} {TEST_IP}</h3>
95
+
96
  <h2>{TEST_TITLE}</h2>
97
 
98
  <div id='js_info'><br />{SFW_DIE_MAKE_SURE_JS_ENABLED}</div>
99
+
100
  <div id='js_passed'>
101
  <h3>{SFW_DIE_CLICK_TO_PASS}</h3>
102
  <a href='{REQUEST_URI}'><script>get_current_url();</script></a>
lib/{CleantalkHelper.php → Cleantalk/ApbctWP/Helper.php} RENAMED
@@ -1,10 +1,12 @@
1
  <?php
2
 
 
 
3
  /**
4
  * CleanTalk Cleantalk Antispam Helper class.
5
  * Compatible only with Wordpress.
6
  *
7
- * @depends Cleantalk\Antispam\Helper
8
  *
9
  * @package Antispam Plugin by CleanTalk
10
  * @subpackage Helper
@@ -15,7 +17,7 @@
15
  * @see https://github.com/CleanTalk/wordpress-antispam
16
  */
17
 
18
- class CleantalkHelper extends Cleantalk\Antispam\Helper
19
  {
20
  /**
21
  * Function sends raw http request
1
  <?php
2
 
3
+ namespace Cleantalk\ApbctWP;
4
+
5
  /**
6
  * CleanTalk Cleantalk Antispam Helper class.
7
  * Compatible only with Wordpress.
8
  *
9
+ * @depends \Cleantalk\Common\Helper
10
  *
11
  * @package Antispam Plugin by CleanTalk
12
  * @subpackage Helper
17
  * @see https://github.com/CleanTalk/wordpress-antispam
18
  */
19
 
20
+ class Helper extends \Cleantalk\Common\Helper
21
  {
22
  /**
23
  * Function sends raw http request
lib/{CleantalkState.php → Cleantalk/ApbctWP/State.php} RENAMED
@@ -1,5 +1,9 @@
1
  <?php
2
 
 
 
 
 
3
  /**
4
  * CleanTalk Antispam State class
5
  *
@@ -43,17 +47,20 @@
43
  * MISC
44
  *
45
  */
46
- class CleantalkState
47
  {
48
  public $user = null;
49
  public $option_prefix = 'cleantalk';
50
  public $storage = array();
51
  public $integrations = array();
52
  public $def_settings = array(
53
-
54
- 'spam_firewall' => 1,
55
- 'apikey' => '',
56
- 'autoPubRevelantMess' => 0,
 
 
 
57
 
58
  /* Forms for protection */
59
  'registrations_test' => 1,
@@ -275,11 +282,8 @@ class CleantalkState
275
  );
276
 
277
  /**
278
- * CleantalkState constructor.
279
- *
280
  * @param string $option_prefix Database settings prefix
281
- * @param array $options Array of strings. Types of settings you want to get.
282
- * @param bool $wpms Is multisite?
283
  */
284
  public function __construct($option_prefix, $options = array('settings'))
285
  {
@@ -349,12 +353,12 @@ class CleantalkState
349
  * Save option to database
350
  *
351
  * @param string $option_name
352
- * @param bool $use_perfix
353
  * @param bool $autoload Use autoload flag?
354
  */
355
- public function save($option_name, $use_perfix = true, $autoload = true)
356
  {
357
- $option_name_to_save = $use_perfix ? $this->option_prefix.'_'.$option_name : $option_name;
358
  $arr = array();
359
  foreach($this->$option_name as $key => $value){
360
  $arr[$key] = $value;
@@ -552,18 +556,18 @@ class CleantalkState
552
  }
553
 
554
  public function server(){
555
- return \Cleantalk\Common\Server::getInstance();
556
  }
557
  public function cookie(){
558
- return \Cleantalk\Common\Cookie::getInstance();
559
  }
560
  public function request(){
561
- return \Cleantalk\Common\Request::getInstance();
562
  }
563
  public function post(){
564
- return \Cleantalk\Common\Post::getInstance();
565
  }
566
  public function get(){
567
- return \Cleantalk\Common\Get::getInstance();
568
  }
569
  }
1
  <?php
2
 
3
+ namespace Cleantalk\ApbctWP;
4
+
5
+ use ArrayObject;
6
+
7
  /**
8
  * CleanTalk Antispam State class
9
  *
47
  * MISC
48
  *
49
  */
50
+ class State
51
  {
52
  public $user = null;
53
  public $option_prefix = 'cleantalk';
54
  public $storage = array();
55
  public $integrations = array();
56
  public $def_settings = array(
57
+
58
+ 'spam_firewall' => 1,
59
+ 'sfw__anti_crawler' => 0,
60
+ 'sfw__anti_crawler__view_limit' => 10,
61
+ 'sfw__bot_protection' => 0,
62
+ 'apikey' => '',
63
+ 'autoPubRevelantMess' => 0,
64
 
65
  /* Forms for protection */
66
  'registrations_test' => 1,
282
  );
283
 
284
  /**
 
 
285
  * @param string $option_prefix Database settings prefix
286
+ * @param array $options Array of strings. Types of settings you want to get.
 
287
  */
288
  public function __construct($option_prefix, $options = array('settings'))
289
  {
353
  * Save option to database
354
  *
355
  * @param string $option_name
356
+ * @param bool $use_prefix
357
  * @param bool $autoload Use autoload flag?
358
  */
359
+ public function save($option_name, $use_prefix = true, $autoload = true)
360
  {
361
+ $option_name_to_save = $use_prefix ? $this->option_prefix . '_' . $option_name : $option_name;
362
  $arr = array();
363
  foreach($this->$option_name as $key => $value){
364
  $arr[$key] = $value;
556
  }
557
 
558
  public function server(){
559
+ return \Cleantalk\Variables\Server::getInstance();
560
  }
561
  public function cookie(){
562
+ return \Cleantalk\Variables\Cookie::getInstance();
563
  }
564
  public function request(){
565
+ return \Cleantalk\Variables\Request::getInstance();
566
  }
567
  public function post(){
568
+ return \Cleantalk\Variables\Post::getInstance();
569
  }
570
  public function get(){
571
+ return \Cleantalk\Variables\Get::getInstance();
572
  }
573
  }
lib/Cleantalk/{Antispam → Common}/API.php RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Cleantalk\Antispam;
4
 
5
  /**
6
  * CleanTalk API class.
1
  <?php
2
 
3
+ namespace Cleantalk\Common;
4
 
5
  /**
6
  * CleanTalk API class.
lib/Cleantalk/{Arr.php → Common/Arr.php} RENAMED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
 
4
- namespace Cleantalk;
5
 
6
  /**
7
  * Class Arr
1
  <?php
2
 
3
 
4
+ namespace Cleantalk\Common;
5
 
6
  /**
7
  * Class Arr
lib/Cleantalk/{Antispam → Common}/DB.php RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Cleantalk\Antispam;
4
 
5
  /**
6
  * CleanTalk abstract Data Base driver.
1
  <?php
2
 
3
+ namespace Cleantalk\Common;
4
 
5
  /**
6
  * CleanTalk abstract Data Base driver.
lib/Cleantalk/Common/Firewall.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Cleantalk\Common;
4
+
5
+ use Cleantalk\Common\Helper as Helper;
6
+ use Cleantalk\Variables\Get;
7
+
8
+ /**
9
+ * CleanTalk SpamFireWall base class.
10
+ * Compatible with any CMS.
11
+ *
12
+ * @depends \Cleantalk\Antispam\Helper class
13
+ * @depends \Cleantalk\Antispam\API class
14
+ * @depends \Cleantalk\Antispam\DB class
15
+ *
16
+ * @version 3.3
17
+ * @author Cleantalk team (welcome@cleantalk.org)
18
+ * @copyright (C) 2014 CleanTalk team (http://cleantalk.org)
19
+ * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
20
+ * @see https://github.com/CleanTalk/php-antispam
21
+ */
22
+ class Firewall
23
+ {
24
+
25
+ public $ip_array = Array();
26
+
27
+ // Database
28
+ protected $db;
29
+
30
+ //Debug
31
+ public $debug;
32
+ public $debug_data = '';
33
+
34
+ private $statuses_priority = array(
35
+ // Lowest
36
+ 'PASS_SFW',
37
+ 'DENY_SFW',
38
+ 'PASS_SFW_BY_COOKIE',
39
+ 'DENY_ANTIBOT',
40
+ 'DENY_ANTICRAWLER',
41
+ 'PASS_SFW_BY_WHITELIST',
42
+ // Highest
43
+ );
44
+
45
+ private $fw_modules = array();
46
+ private $module_names = array();
47
+
48
+ /**
49
+ * Creates Database driver instance.
50
+ *
51
+ * @param $db
52
+ */
53
+ public function __construct( $db ){
54
+ $this->db = $db;
55
+ $this->debug = !! Get::get( 'debug' );
56
+ $this->ip_array = $this->ip__get( array('real'), true );
57
+ }
58
+
59
+ /**
60
+ * Getting arrays of IP (REMOTE_ADDR, X-Forwarded-For, X-Real-Ip, Cf_Connecting_Ip)
61
+ *
62
+ * @param array $ips_input type of IP you want to receive
63
+ * @param bool $v4_only
64
+ *
65
+ * @return array|mixed|null
66
+ */
67
+ public function ip__get( $ips_input = array( 'real', 'remote_addr', 'x_forwarded_for', 'x_real_ip', 'cloud_flare' ), $v4_only = true ){
68
+
69
+ $result = Helper::ip__get( $ips_input, $v4_only );
70
+
71
+ return ! empty( $result ) ? array( 'real' => $result ) : array();
72
+
73
+ }
74
+
75
+ /**
76
+ * Loads the FireWall module to the array.
77
+ * For inner usage only.
78
+ * Not returns anything, the result is private storage of the modules.
79
+ *
80
+ * @param \Cleantalk\Common\Firewall\FirewallModule $module
81
+ */
82
+ public function load_fw_module( \Cleantalk\Common\Firewall\FirewallModule $module ) {
83
+
84
+ if( ! in_array( $module, $this->fw_modules ) ) {
85
+ $module->setDb( $this->db );
86
+ $module->ip__append_additional( $this->ip_array );
87
+ $this->fw_modules[ $module->module_name ] = $module;
88
+ $module->setIpArray( $this->ip_array );
89
+ }
90
+
91
+ }
92
+
93
+ /**
94
+ * Do main logic of the module.
95
+ *
96
+ * @return void returns die page or set cookies
97
+ */
98
+ public function run() {
99
+
100
+ $this->module_names = array_keys( $this->fw_modules );
101
+
102
+ $results = array();
103
+
104
+ foreach ( $this->fw_modules as $module ) {
105
+
106
+ $module_results = $module->check();
107
+ if( ! empty( $module_results ) ) {
108
+ $results[] = $this->prioritize( $module_results );
109
+ }
110
+
111
+ if( $this->is_whitelisted( $results ) ) {
112
+ // Break protection logic if it whitelisted or trusted network.
113
+ break;
114
+ }
115
+
116
+ }
117
+
118
+ $result = $this->prioritize( $results );
119
+
120
+ // Blacklisted in DB
121
+
122
+ foreach( $this->module_names as $module_name ){
123
+
124
+ if( strpos( $result['status'], $module_name ) ){
125
+
126
+ $this->fw_modules[ $module_name ]->update_log( $result['ip'], $result['status'] );
127
+
128
+ // Blocked
129
+ if( strpos( $result['status'], 'DENY' ) !== false ){
130
+ $this->fw_modules[ $module_name ]->actions_for_denied( $result );
131
+ $this->fw_modules[ $module_name ]->_die( $result );
132
+
133
+ // Allowed
134
+ }else{
135
+ $this->fw_modules[ $module_name ]->actions_for_passed( $result );
136
+ }
137
+ }
138
+
139
+ }
140
+
141
+ }
142
+
143
+ /**
144
+ * Sets priorities for firewall results.
145
+ * It generates one main result from multi-level results array.
146
+ *
147
+ * @param array $results
148
+ *
149
+ * @return array Single element array of result
150
+ */
151
+ private function prioritize( $results ){
152
+
153
+ $current_fw_result_priority = 0;
154
+ $result = array( 'status' => 'PASS', 'passed_ip' => '' );
155
+
156
+ if( is_array( $results ) ) {
157
+ foreach ( $results as $fw_result ) {
158
+ $priority = array_search( $fw_result['status'], $this->statuses_priority ) + ( isset($fw_result['is_personal']) && $fw_result['is_personal'] ? count ( $this->statuses_priority ) : 0 );
159
+ if( $priority >= $current_fw_result_priority ){
160
+ $current_fw_result_priority = $priority;
161
+ $result['status'] = $fw_result['status'];
162
+ $result['passed_ip'] = isset( $fw_result['ip'] ) ? $fw_result['ip'] : $fw_result['passed_ip'];
163
+ $result['blocked_ip'] = isset( $fw_result['ip'] ) ? $fw_result['ip'] : $fw_result['blocked_ip'];
164
+ $result['pattern'] = isset( $fw_result['pattern'] ) ? $fw_result['pattern'] : array();
165
+ }
166
+ }
167
+ }
168
+
169
+ $result['ip'] = strpos( $result['status'], 'PASS' ) !== false ? $result['passed_ip'] : $result['blocked_ip'];
170
+ $result['passed'] = strpos( $result['status'], 'PASS' ) !== false;
171
+
172
+ return $result;
173
+
174
+ }
175
+
176
+ /**
177
+ * Check the result if it whitelisted or trusted network
178
+ *
179
+ * @param array $results
180
+ *
181
+ * @return bool
182
+ */
183
+ private function is_whitelisted( $results ) {
184
+
185
+ foreach ( $results as $fw_result ) {
186
+ if (
187
+ strpos( $fw_result['status'], 'PASS_BY_TRUSTED_NETWORK' ) !== false ||
188
+ strpos( $fw_result['status'], 'PASS_BY_WHITELIST' ) !== false
189
+ ) {
190
+ return true;
191
+ }
192
+ }
193
+ return false;
194
+
195
+ }
196
+
197
+ }
lib/Cleantalk/Common/Firewall/FirewallModule.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Cleantalk\Common\Firewall;
4
+
5
+ /*
6
+ * The abstract class for any FireWall modules.
7
+ * Compatible with any CMS.
8
+ *
9
+ * @version 1.0
10
+ * @author Cleantalk team (welcome@cleantalk.org)
11
+ * @copyright (C) 2014 CleanTalk team (http://cleantalk.org)
12
+ * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
13
+ * @since 2.49
14
+ */
15
+ class FirewallModule extends FirewallModule_abstract {
16
+
17
+ /**
18
+ * FireWall_module constructor.
19
+ * Use this method to prepare any data for the module working.
20
+ *
21
+ * @param $log_table
22
+ * @param $data_table
23
+ * @param array $params
24
+ */
25
+ public function __construct( $log_table, $data_table, $params = array() ){
26
+
27
+ }
28
+
29
+ public function ip__append_additional( &$ips ){}
30
+
31
+ /**
32
+ * Use this method to execute main logic of the module.
33
+ *
34
+ * @return array Array of the check results
35
+ */
36
+ public function check(){}
37
+
38
+ public function actions_for_denied( $result ){}
39
+
40
+ public function actions_for_passed( $result ){}
41
+
42
+ /**
43
+ * @param mixed $db
44
+ */
45
+ public function setDb( $db ) {
46
+ $this->db = $db;
47
+ }
48
+
49
+ /**
50
+ * @param array $ip_array
51
+ */
52
+ public function setIpArray( $ip_array ) {
53
+ $this->ip_array = $ip_array;
54
+ }
55
+
56
+ public function getIpArray() {
57
+ return $this->ip_array;
58
+ }
59
+
60
+ /**
61
+ * @param mixed $db__table__data
62
+ */
63
+ public function setDbTableData( $db__table__data ) {
64
+ $this->db__table__data = $db__table__data;
65
+ }
66
+
67
+ /**
68
+ * @param mixed $db__table__logs
69
+ */
70
+ public function setDbTableLogs( $db__table__logs ) {
71
+ $this->db__table__logs = $db__table__logs;
72
+ }
73
+ }
lib/Cleantalk/Common/Firewall/FirewallModule_abstract.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Cleantalk\Common\Firewall;
4
+
5
+ /*
6
+ * The abstract class for any FireWall modules.
7
+ * Compatible with any CMS.
8
+ *
9
+ * @version 1.0
10
+ * @author Cleantalk team (welcome@cleantalk.org)
11
+ * @copyright (C) 2014 CleanTalk team (http://cleantalk.org)
12
+ * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
13
+ * @since 2.49
14
+ */
15
+ abstract class FirewallModule_abstract {
16
+
17
+ public $module_name;
18
+
19
+ protected $db;
20
+ protected $db__table__logs;
21
+ protected $db__table__data;
22
+
23
+ protected $service_id;
24
+
25
+ protected $result_code = '';
26
+
27
+ protected $ip_array = array();
28
+
29
+ protected $test_ip;
30
+
31
+ protected $passed_ip;
32
+
33
+ protected $blocked_ip;
34
+
35
+ /**
36
+ * FireWall_module constructor.
37
+ * Use this method to prepare any data for the module working.
38
+ *
39
+ * @param $log_table
40
+ * @param $data_table
41
+ * @param array $params
42
+ */
43
+ abstract public function __construct( $log_table, $data_table, $params = array() );
44
+
45
+ /**
46
+ * Use this method to execute main logic of the module.
47
+ *
48
+ * @return array Array of the check results
49
+ */
50
+ abstract public function check();
51
+
52
+ }
lib/Cleantalk/{Antispam → Common}/Helper.php RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Cleantalk\Antispam;
4
 
5
  /**
6
  * CleanTalk Helper class.
@@ -740,4 +740,9 @@ class Helper
740
  }
741
 
742
  }
 
 
 
 
 
743
  }
1
  <?php
2
 
3
+ namespace Cleantalk\Common;
4
 
5
  /**
6
  * CleanTalk Helper class.
740
  }
741
 
742
  }
743
+
744
+ public static function time__get_interval_start( $interval = 300 ){
745
+ return time() - ( ( time() - strtotime( date( 'd F Y' ) ) ) % $interval );
746
+ }
747
+
748
  }
lib/Cleantalk/{Common → Variables}/Cookie.php RENAMED
@@ -1,14 +1,14 @@
1
  <?php
2
 
3
- namespace Cleantalk\Common;
4
 
5
  /**
6
  * Class Cookie
7
  * Safety handler for $_COOKIE
8
  *
9
- * @usage \Cleantalk\Common\Cookie::get( $name );
10
  *
11
- * @package Cleantalk\Common
12
  */
13
  class Cookie extends ServerVariables{
14
 
1
  <?php
2
 
3
+ namespace Cleantalk\Variables;
4
 
5
  /**
6
  * Class Cookie
7
  * Safety handler for $_COOKIE
8
  *
9
+ * @usage \Cleantalk\Variables\Cookie::get( $name );
10
  *
11
+ * @package Cleantalk\Variables
12
  */
13
  class Cookie extends ServerVariables{
14
 
lib/Cleantalk/{Common → Variables}/Get.php RENAMED
@@ -1,14 +1,14 @@
1
  <?php
2
 
3
- namespace Cleantalk\Common;
4
 
5
  /**
6
  * Class Get
7
  * Safety handler for $_GET
8
  *
9
- * @usage \Cleantalk\Common\Get::get( $name );
10
  *
11
- * @package Cleantalk\Common
12
  */
13
  class Get extends ServerVariables{
14
 
1
  <?php
2
 
3
+ namespace Cleantalk\Variables;
4
 
5
  /**
6
  * Class Get
7
  * Safety handler for $_GET
8
  *
9
+ * @usage \Cleantalk\Variables\Get::get( $name );
10
  *
11
+ * @package Cleantalk\Variables
12
  */
13
  class Get extends ServerVariables{
14
 
lib/Cleantalk/{Common → Variables}/Post.php RENAMED
@@ -1,15 +1,15 @@
1
  <?php
2
 
3
 
4
- namespace Cleantalk\Common;
5
 
6
  /**
7
  * Class Post
8
  * Safety handler for $_POST
9
  *
10
- * @usage \Cleantalk\Common\Post::get( $name );
11
  *
12
- * @package Cleantalk\Common
13
  */
14
  class Post extends ServerVariables{
15
 
1
  <?php
2
 
3
 
4
+ namespace Cleantalk\Variables;
5
 
6
  /**
7
  * Class Post
8
  * Safety handler for $_POST
9
  *
10
+ * @usage \Cleantalk\Variables\Post::get( $name );
11
  *
12
+ * @package Cleantalk\Variables
13
  */
14
  class Post extends ServerVariables{
15
 
lib/Cleantalk/{Common → Variables}/Request.php RENAMED
@@ -1,14 +1,14 @@
1
  <?php
2
 
3
- namespace Cleantalk\Common;
4
 
5
  /**
6
  * Class Request
7
  * Safety handler for $_REQUEST
8
  *
9
- * @usage \Cleantalk\Common\Request::get( $name );
10
  *
11
- * @package Cleantalk\Common
12
  */
13
  class Request extends ServerVariables{
14
 
1
  <?php
2
 
3
+ namespace Cleantalk\Variables;
4
 
5
  /**
6
  * Class Request
7
  * Safety handler for $_REQUEST
8
  *
9
+ * @usage \Cleantalk\Variables\Request::get( $name );
10
  *
11
+ * @package Cleantalk\Variables
12
  */
13
  class Request extends ServerVariables{
14
 
lib/Cleantalk/{Common → Variables}/Server.php RENAMED
@@ -1,12 +1,12 @@
1
  <?php
2
 
3
- namespace Cleantalk\Common;
4
 
5
  /**
6
  * Class Server
7
  * Wrapper to safely get $_SERVER variables
8
  *
9
- * @package Cleantalk\Common
10
  */
11
  class Server extends ServerVariables{
12
 
1
  <?php
2
 
3
+ namespace Cleantalk\Variables;
4
 
5
  /**
6
  * Class Server
7
  * Wrapper to safely get $_SERVER variables
8
  *
9
+ * @package Cleantalk\Variables
10
  */
11
  class Server extends ServerVariables{
12
 
lib/Cleantalk/{Common → Variables}/ServerVariables.php RENAMED
@@ -1,14 +1,14 @@
1
  <?php
2
 
3
- namespace Cleantalk\Common;
4
 
5
  /**
6
  * Class ServerVariables
7
  * Safety handler for ${_SOMETHING}
8
  *
9
- * @usage \Cleantalk\Common\{SOMETHING}::get( $name );
10
  *
11
- * @package Cleantalk\Common
12
  */
13
  class ServerVariables{
14
 
1
  <?php
2
 
3
+ namespace Cleantalk\Variables;
4
 
5
  /**
6
  * Class ServerVariables
7
  * Safety handler for ${_SOMETHING}
8
  *
9
+ * @usage \Cleantalk\Variables\{SOMETHING}::get( $name );
10
  *
11
+ * @package Cleantalk\Variables
12
  */
13
  class ServerVariables{
14
 
lib/CleantalkSFW.php DELETED
@@ -1,141 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CleanTalk SpamFireWall Wordpress class
5
- * Compatible only with Wordpress.
6
- *
7
- * @depends Cleantalk\Antispam\SFW
8
- *
9
- * @version 3.3
10
- * @author Cleantalk team (welcome@cleantalk.org)
11
- * @copyright (C) 2014 CleanTalk team (http://cleantalk.org)
12
- * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
13
- * @see https://github.com/CleanTalk/wordpress-antispam
14
- */
15
- class CleantalkSFW extends Cleantalk\Antispam\SFW
16
- {
17
- /**
18
- * CleantalkSFW_Base constructor.
19
- * Creates Database driver instance.
20
- */
21
- public function __construct()
22
- {
23
-
24
- // Creating database object. Depends on current CMS.
25
- $this->db = CleantalkDB::getInstance();
26
-
27
- // Use default tables if not specified
28
- $this->data_table = defined('APBCT_TBL_FIREWALL_DATA') ? APBCT_TBL_FIREWALL_DATA : $this->db->prefix . 'cleantalk_sfw';
29
- $this->log_table = defined('APBCT_TBL_FIREWALL_LOG') ? APBCT_TBL_FIREWALL_LOG : $this->db->prefix . 'cleantalk_sfw_logs';
30
-
31
- parent::__construct();
32
- }
33
-
34
- /**
35
- * Shows DIE page.
36
- * Stops script executing.
37
- *
38
- * @param string $api_key
39
- * @param string $cookie_prefix
40
- * @param string $cookie_domain
41
- * @param bool $test
42
- */
43
- public function sfw_die($api_key, $cookie_prefix = '', $cookie_domain = '', $test = false){
44
-
45
- global $apbct;
46
-
47
- // Statistics
48
- if(!empty($this->blocked_ips)){
49
- reset($this->blocked_ips);
50
- $apbct->stats['last_sfw_block']['time'] = time();
51
- $apbct->stats['last_sfw_block']['ip'] = $this->blocked_ips[key($this->blocked_ips)]['ip'];
52
- $apbct->save('stats');
53
- }
54
-
55
- // Headers
56
- if(headers_sent() === false){
57
- header('Expires: '.date(DATE_RFC822, mktime(0, 0, 0, 1, 1, 1971)));
58
- header('Cache-Control: no-store, no-cache, must-revalidate');
59
- header('Cache-Control: post-check=0, pre-check=0', FALSE);
60
- header('Pragma: no-cache');
61
- header("HTTP/1.0 403 Forbidden");
62
- }
63
-
64
- // File exists?
65
- if(file_exists(CLEANTALK_PLUGIN_DIR . "inc/sfw_die_page.html")){
66
-
67
- $sfw_die_page = file_get_contents(CLEANTALK_PLUGIN_DIR . "inc/sfw_die_page.html");
68
-
69
- // Translation
70
- $request_uri = apbct_get_server_variable( 'REQUEST_URI' );
71
- $sfw_die_page = str_replace('{SFW_DIE_NOTICE_IP}', __('SpamFireWall is activated for your IP ', 'cleantalk-spam-protect'), $sfw_die_page);
72
- $sfw_die_page = str_replace('{SFW_DIE_MAKE_SURE_JS_ENABLED}', __('To continue working with web site, please make sure that you have enabled JavaScript.', 'cleantalk-spam-protect'), $sfw_die_page);
73
- $sfw_die_page = str_replace('{SFW_DIE_CLICK_TO_PASS}', __('Please click the link below to pass the protection,', 'cleantalk-spam-protect'), $sfw_die_page);
74
- $sfw_die_page = str_replace('{SFW_DIE_YOU_WILL_BE_REDIRECTED}', sprintf(__('Or you will be automatically redirected to the requested page after %d seconds.', 'cleantalk-spam-protect'), 3), $sfw_die_page);
75
- $sfw_die_page = str_replace('{CLEANTALK_TITLE}', __('Antispam by CleanTalk', 'cleantalk-spam-protect'), $sfw_die_page);
76
- $sfw_die_page = str_replace('{TEST_TITLE}', ($this->test ? __('This is the testing page for SpamFireWall', 'cleantalk-spam-protect') : ''), $sfw_die_page);
77
-
78
- if($this->test){
79
- $sfw_die_page = str_replace('{REAL_IP__HEADER}', 'Real IP:', $sfw_die_page);
80
- $sfw_die_page = str_replace('{TEST_IP__HEADER}', 'Test IP:', $sfw_die_page);
81
- $sfw_die_page = str_replace('{TEST_IP}', $this->all_ips['sfw_test']['ip'], $sfw_die_page);
82
- $sfw_die_page = str_replace('{REAL_IP}', $this->all_ips['real']['ip'], $sfw_die_page);
83
- $sfw_die_page = str_replace('{TEST_IP_BLOCKED}', $this->all_ips['sfw_test']['status'] == 1 ? 'Passed' : 'Blocked', $sfw_die_page);
84
- $sfw_die_page = str_replace('{REAL_IP_BLOCKED}', $this->all_ips['real']['status'] == 1 ? 'Passed' : 'Blocked', $sfw_die_page);
85
- }else{
86
- $sfw_die_page = str_replace('{REAL_IP__HEADER}', '', $sfw_die_page);
87
- $sfw_die_page = str_replace('{TEST_IP__HEADER}', '', $sfw_die_page);
88
- $sfw_die_page = str_replace('{TEST_IP}', '', $sfw_die_page);
89
- $sfw_die_page = str_replace('{REAL_IP}', '', $sfw_die_page);
90
- $sfw_die_page = str_replace('{TEST_IP_BLOCKED}', '', $sfw_die_page);
91
- $sfw_die_page = str_replace('{REAL_IP_BLOCKED}', '', $sfw_die_page);
92
- }
93
-
94
- $sfw_die_page = str_replace('{REMOTE_ADDRESS}', $this->blocked_ips ? $this->blocked_ips[key($this->blocked_ips)]['ip'] : '', $sfw_die_page);
95
-
96
- // Service info
97
- $sfw_die_page = str_replace('{REQUEST_URI}', $request_uri, $sfw_die_page);
98
- $sfw_die_page = str_replace('{COOKIE_PREFIX}', $cookie_prefix, $sfw_die_page);
99
- $sfw_die_page = str_replace('{COOKIE_DOMAIN}', $cookie_domain, $sfw_die_page);
100
- $sfw_die_page = str_replace('{SERVICE_ID}', $apbct->data['service_id'], $sfw_die_page);
101
- $sfw_die_page = str_replace('{HOST}', apbct_get_server_variable( 'HTTP_HOST' ), $sfw_die_page);
102
-
103
- $sfw_die_page = str_replace(
104
- '{SFW_COOKIE}',
105
- $this->test
106
- ? $this->all_ips['sfw_test']['ip']
107
- : md5(current(end($this->blocked_ips)).$api_key),
108
- $sfw_die_page
109
- );
110
-
111
- if($this->debug){
112
- $debug = '<h1>IP and Networks</h1>'
113
- . var_export($this->all_ips, true)
114
- .'<h1>Blocked IPs</h1>'
115
- . var_export($this->blocked_ips, true)
116
- .'<h1>Passed IPs</h1>'
117
- . var_export($this->passed_ips, true)
118
- . '<h1>Headers</h1>'
119
- . var_export(apache_request_headers(), true)
120
- . '<h1>REMOTE_ADDR</h1>'
121
- . var_export(apbct_get_server_variable( 'REMOTE_ADDR' ), true)
122
- . '<h1>SERVER_ADDR</h1>'
123
- . var_export(apbct_get_server_variable( 'REMOTE_ADDR' ), true)
124
- . '<h1>IP_ARRAY</h1>'
125
- . var_export($this->ip_array, true)
126
- . '<h1>ADDITIONAL</h1>'
127
- . var_export($this->debug_data, true);
128
- }else
129
- $debug = '';
130
-
131
- $sfw_die_page = str_replace( "{DEBUG}", $debug, $sfw_die_page );
132
- $sfw_die_page = str_replace('{GENERATED}', "<p>The page was generated at&nbsp;".date("D, d M Y H:i:s")."</p>",$sfw_die_page);
133
-
134
- wp_die($sfw_die_page, "Blacklisted", Array('response'=>403));
135
-
136
- }else{
137
- wp_die("IP BLACKLISTED", "Blacklisted", Array('response'=>403));
138
- }
139
-
140
- }
141
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/CleantalkSFW_Base.php DELETED
@@ -1,16 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Patch to use CleantalkBase/CleantalkSFW as CleantalkSFW_Base
5
- *
6
- * @since 5.124.2
7
- *
8
- */
9
-
10
- // Base classes
11
- require_once(CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk/Antispam/API.php'); // API
12
- require_once(CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk/Antispam/DB.php'); // Database driver
13
- require_once(CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk/Antispam/Helper.php'); // Helper
14
- include_once(CLEANTALK_PLUGIN_DIR . "lib/Cleantalk/Antispam/SFW.php"); // SpamFireWall
15
-
16
- require_once(CLEANTALK_PLUGIN_DIR . 'lib/CleantalkDB.php'); // Database class for Wordpress
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: spam, antispam, woocommerce, comments, firewall
4
  Requires at least: 3.0
5
  Tested up to: 5.4
6
  Requires PHP: 5.4
7
- Stable tag: 5.141.3
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
@@ -574,6 +574,15 @@ If your website has forms that send data to external sources, you can enable opt
574
 
575
  == Changelog ==
576
 
 
 
 
 
 
 
 
 
 
577
  = 5.141.3 Jul 17 2020 =
578
  * Fix: 403 error issues with cache plugins.
579
  * Fix: remove apbct-common.js.
4
  Requires at least: 3.0
5
  Tested up to: 5.4
6
  Requires PHP: 5.4
7
+ Stable tag: 5.142
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
574
 
575
  == Changelog ==
576
 
577
+ = 5.142 Jul 27 2020 =
578
+ * New: Bot Protection module for Firewall.
579
+ * New: Anti-Crawler module for Firewall.
580
+ * Mod: Improved spam Protection.
581
+ * Fix: Caching plugins auto detection.
582
+ * Fix: Skip Divi system fields.
583
+ * Fix: Ultimate Form Builder exception.
584
+ * Plenty of fixes and upgrades.
585
+
586
  = 5.141.3 Jul 17 2020 =
587
  * Fix: 403 error issues with cache plugins.
588
  * Fix: remove apbct-common.js.