Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.153.2

Version Description

Feb 25 2021 = * Fix: Integration. Registration on WICITY theme. * Fix: Integration. Registration on Paid Memberships Pro * Fix: IP detection. * Fix: Error: SFW_DISABLED. * Fix: Formidable form. Error with sophisticated field types. * Fix: Remote Calls. Cooldown checking for the SFW update fixed. * Fix: easy-login-woocommerce requests exclusion fixed. * Fix: Jackmail plugin. Skip all admin-side actions. * Fix: Remote Calls. Unused deactivation option removed. * Fix: Users checker. Last check date fixed. * Fix: Users checker. Total users count description fixed.

Download this release

Release Info

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

Code changes from version 5.153.1 to 5.153.2

cleantalk.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Anti-Spam by CleanTalk
4
  Plugin URI: https://cleantalk.org
5
  Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
6
- Version: 5.153.1
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
@@ -224,7 +224,7 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
224
 
225
  // Custom register form (ticket_id=13668)
226
  add_action('website_neotrends_signup_fields_check',function( $username, $fields ){
227
- $ip = Helper::ip__get( array('real'), false );
228
  $ct_result = ct_test_registration( $username, $fields['email'], $ip );
229
  if( $ct_result['allow'] == 0 ) {
230
  ct_die_extended( $ct_result['comment'] );
@@ -835,137 +835,133 @@ function ct_sfw_update( $api_key = '', $immediate = false ){
835
 
836
  $api_key = !empty($apbct->api_key) ? $apbct->api_key : $api_key;
837
 
838
- if( empty( $api_key ) && ! $apbct->data['moderate_ip'] ){
839
  return true;
840
  }
841
-
842
- if( $apbct->settings['spam_firewall'] == 1 ) {
843
 
844
- if( get_option( 'sfw_sync_first' ) ) {
845
- $first = 'first';
846
- } else {
847
- $first = '';
848
- }
849
- // Set new update ID
850
- if( ! $apbct->fw_stats['firewall_updating_id'] || time() - $apbct->fw_stats['firewall_updating_last_start'] > 300 ){
851
- $apbct->fw_stats['firewall_updating_id'] = md5( rand( 0, 100000 ) ) . $first;
852
- $apbct->fw_stats['firewall_updating_last_start'] = time();
853
- $apbct->save( 'fw_stats' );
854
- }
855
 
856
- if( RemoteCalls::check() ) {
857
- // Remote call is in process, do updating
858
-
859
- $file_urls = isset($_GET['file_urls']) ? urldecode( $_GET['file_urls'] ) : null;
860
- $url_count = isset($_GET['url_count']) ? urldecode( $_GET['url_count'] ) : null;
861
- $current_url = isset($_GET['current_url']) ? urldecode( $_GET['current_url'] ) : null;
862
-
863
- if( ! $file_urls ){
864
-
865
- // @todo We have to handle errors here
866
- SFW::create_temp_tables( DB::getInstance() );
867
-
868
- $result = SFW::update(
869
- DB::getInstance(),
870
- APBCT_TBL_FIREWALL_DATA . '_temp',
871
- $api_key,
872
- null,
873
- $immediate
874
- );
875
-
876
- return ! empty( $result['error'] )
877
- ? $result
878
- : true;
879
-
880
- }elseif( $file_urls && $url_count > $current_url ){
881
-
882
- $result = SFW::update(
883
- DB::getInstance(),
884
- APBCT_TBL_FIREWALL_DATA . '_temp',
885
- $api_key,
886
- str_replace( 'multifiles', $current_url, $file_urls ),
887
- $immediate
888
- );
889
-
890
- if( empty( $result['error'] ) ){
891
-
892
- $current_url++;
893
-
894
- $apbct->fw_stats['firewall_update_percent'] = round( ( ( (int) $current_url + 1 ) / (int) $url_count ), 2) * 100;
895
- $apbct->save('fw_stats');
896
-
897
- if ( $url_count > $current_url ) {
898
- return Helper::http__request__rc_to_host(
899
- get_option('siteurl'),
900
- array(
901
- 'spbc_remote_call_token' => md5($api_key),
902
- 'spbc_remote_call_action' => 'sfw_update',
903
- 'plugin_name' => 'apbct',
904
- 'file_urls' => str_replace( array( 'http://', 'https://' ), '', $file_urls ),
905
- 'url_count' => $url_count,
906
- 'current_url' => $current_url,
907
- // Additional params
908
- 'firewall_updating_id' => $apbct->fw_stats['firewall_updating_id'],
909
- ),
910
- array('get', 'async')
911
- );
912
- } else {
913
 
914
- $is_first_updating = strpos( $apbct->fw_stats['firewall_updating_id'], 'first' );
915
-
916
- // @todo We have to handle errors here
917
- SFW::delete_main_data_tables( DB::getInstance() );
918
- // @todo We have to handle errors here
919
- SFW::rename_data_tables( DB::getInstance() );
920
-
921
- //Files array is empty update sfw stats
922
- $apbct->data['last_firewall_updated'] = current_time('timestamp'); // Unused
923
- $apbct->save('data'); // Unused
924
- $apbct->fw_stats['firewall_update_percent'] = 0;
925
- $apbct->fw_stats['firewall_updating_id'] = null;
926
- $apbct->save( 'fw_stats' );
927
-
928
- //Files array is empty update sfw time
929
- $apbct->stats['sfw']['entries'] = $wpdb->get_var('SELECT COUNT(*) FROM ' . APBCT_TBL_FIREWALL_DATA );
930
- $apbct->stats['sfw']['last_update_time'] = time();
931
- $apbct->save('stats');
932
-
933
- // Running sfw update once again in 12 min if entries is < 4000
934
- if( $is_first_updating !== false ) {
935
- if( $apbct->stats['sfw']['entries'] < 4000 ) {
936
- wp_schedule_single_event( time() + 720, 'ct_sfw_update' );
937
- }
938
- delete_option( 'sfw_sync_first' );
939
- }
940
 
941
- // Delete update errors
942
- $apbct->error_delete( 'sfw_update', 'save_settings' );
943
 
944
- // REMOVE AND RENAME
945
- return $result;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
946
  }
947
- }else
 
 
 
 
948
  return $result;
 
949
  }else
950
- return array('error' => 'SFW_UPDATE WRONG_FILE_URLS');
951
-
952
- } else {
953
- // Go to init remote call
954
- return Helper::http__request__rc_to_host(
955
- get_option( 'siteurl' ),
956
- array(
957
- 'spbc_remote_call_token' => md5( $api_key ),
958
- 'spbc_remote_call_action' => 'sfw_update',
959
- 'plugin_name' => 'apbct',
960
- // Additional params
961
- 'firewall_updating_id' => $apbct->fw_stats['firewall_updating_id'],
962
- ),
963
- array( 'get','async' )
964
- );
965
- }
966
 
967
- }else
968
- return array('error' => 'SFW_DISABLED');
 
 
 
 
 
 
 
 
 
 
 
 
 
969
  }
970
 
971
  function ct_sfw_send_logs($api_key = '')
@@ -974,29 +970,24 @@ function ct_sfw_send_logs($api_key = '')
974
 
975
  $api_key = !empty($apbct->api_key) ? $apbct->api_key : $api_key;
976
 
977
- if( empty( $api_key ) && ! $apbct->data['moderate_ip'] ){
978
  return true;
979
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
980
 
981
- if( $apbct->settings['spam_firewall'] == 1 ) {
982
-
983
- $result = SFW::send_log(
984
- DB::getInstance(),
985
- APBCT_TBL_FIREWALL_LOG,
986
- $api_key
987
- );
988
-
989
- if(empty($result['error'])){
990
- $apbct->stats['sfw']['last_send_time'] = time();
991
- $apbct->stats['sfw']['last_send_amount'] = $result['rows'];
992
- $apbct->save('stats');
993
- $apbct->error_delete( 'sfw_send_logs', 'save_settings' );
994
- }
995
-
996
- return $result;
997
-
998
- } else
999
- return array('error' => 'SFW_DISABLED');
1000
  }
1001
 
1002
  function apbct_antiflood__clear_table(){
@@ -1454,7 +1445,7 @@ function apbct__hook__wp_logout__delete_trial_notice_cookie(){
1454
  }
1455
 
1456
  function apbct_alt_session__id__get(){
1457
- $id = Helper::ip__get(array('real'))
1458
  .apbct_get_server_variable( 'HTTP_USER_AGENT' )
1459
  .apbct_get_server_variable( 'HTTP_ACCEPT_LANGUAGE' );
1460
  return hash('sha256', $id);
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.153.2
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
224
 
225
  // Custom register form (ticket_id=13668)
226
  add_action('website_neotrends_signup_fields_check',function( $username, $fields ){
227
+ $ip = Helper::ip__get( 'real', false );
228
  $ct_result = ct_test_registration( $username, $fields['email'], $ip );
229
  if( $ct_result['allow'] == 0 ) {
230
  ct_die_extended( $ct_result['comment'] );
835
 
836
  $api_key = !empty($apbct->api_key) ? $apbct->api_key : $api_key;
837
 
838
+ if( empty( $api_key ) || $apbct->settings['spam_firewall'] != 1 ){
839
  return true;
840
  }
 
 
841
 
842
+ if( get_option( 'sfw_sync_first' ) ) {
843
+ $first = 'first';
844
+ } else {
845
+ $first = '';
846
+ }
847
+ // Set new update ID
848
+ if( ! $apbct->fw_stats['firewall_updating_id'] || time() - $apbct->fw_stats['firewall_updating_last_start'] > 300 ){
849
+ $apbct->fw_stats['firewall_updating_id'] = md5( rand( 0, 100000 ) ) . $first;
850
+ $apbct->fw_stats['firewall_updating_last_start'] = time();
851
+ $apbct->save( 'fw_stats' );
852
+ }
853
 
854
+ if( RemoteCalls::check() ) {
855
+ // Remote call is in process, do updating
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
856
 
857
+ $file_urls = isset($_GET['file_urls']) ? urldecode( $_GET['file_urls'] ) : null;
858
+ $url_count = isset($_GET['url_count']) ? urldecode( $_GET['url_count'] ) : null;
859
+ $current_url = isset($_GET['current_url']) ? urldecode( $_GET['current_url'] ) : null;
860
+
861
+ if( ! $file_urls ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
862
 
863
+ // @todo We have to handle errors here
864
+ SFW::create_temp_tables( DB::getInstance() );
865
 
866
+ $result = SFW::update(
867
+ DB::getInstance(),
868
+ APBCT_TBL_FIREWALL_DATA . '_temp',
869
+ $api_key,
870
+ null,
871
+ $immediate
872
+ );
873
+
874
+ return ! empty( $result['error'] )
875
+ ? $result
876
+ : true;
877
+
878
+ }elseif( $file_urls && $url_count > $current_url ){
879
+
880
+ $result = SFW::update(
881
+ DB::getInstance(),
882
+ APBCT_TBL_FIREWALL_DATA . '_temp',
883
+ $api_key,
884
+ str_replace( 'multifiles', $current_url, $file_urls ),
885
+ $immediate
886
+ );
887
+
888
+ if( empty( $result['error'] ) ){
889
+
890
+ $current_url++;
891
+
892
+ $apbct->fw_stats['firewall_update_percent'] = round( ( ( (int) $current_url + 1 ) / (int) $url_count ), 2) * 100;
893
+ $apbct->save('fw_stats');
894
+
895
+ if ( $url_count > $current_url ) {
896
+ return Helper::http__request__rc_to_host(
897
+ get_option('siteurl'),
898
+ array(
899
+ 'spbc_remote_call_token' => md5($api_key),
900
+ 'spbc_remote_call_action' => 'sfw_update',
901
+ 'plugin_name' => 'apbct',
902
+ 'file_urls' => str_replace( array( 'http://', 'https://' ), '', $file_urls ),
903
+ 'url_count' => $url_count,
904
+ 'current_url' => $current_url,
905
+ // Additional params
906
+ 'firewall_updating_id' => $apbct->fw_stats['firewall_updating_id'],
907
+ ),
908
+ array('get', 'async')
909
+ );
910
+ } else {
911
+
912
+ $is_first_updating = strpos( $apbct->fw_stats['firewall_updating_id'], 'first' );
913
+
914
+ // @todo We have to handle errors here
915
+ SFW::delete_main_data_tables( DB::getInstance() );
916
+ // @todo We have to handle errors here
917
+ SFW::rename_data_tables( DB::getInstance() );
918
+
919
+ //Files array is empty update sfw stats
920
+ $apbct->data['last_firewall_updated'] = current_time('timestamp'); // Unused
921
+ $apbct->save('data'); // Unused
922
+ $apbct->fw_stats['firewall_update_percent'] = 0;
923
+ $apbct->fw_stats['firewall_updating_id'] = null;
924
+ $apbct->save( 'fw_stats' );
925
+
926
+ //Files array is empty update sfw time
927
+ $apbct->stats['sfw']['entries'] = $wpdb->get_var('SELECT COUNT(*) FROM ' . APBCT_TBL_FIREWALL_DATA );
928
+ $apbct->stats['sfw']['last_update_time'] = time();
929
+ $apbct->save('stats');
930
+
931
+ // Running sfw update once again in 12 min if entries is < 4000
932
+ if( $is_first_updating !== false ) {
933
+ if( $apbct->stats['sfw']['entries'] < 4000 ) {
934
+ wp_schedule_single_event( time() + 720, 'ct_sfw_update' );
935
+ }
936
+ delete_option( 'sfw_sync_first' );
937
  }
938
+
939
+ // Delete update errors
940
+ $apbct->error_delete( 'sfw_update', 'save_settings' );
941
+
942
+ // REMOVE AND RENAME
943
  return $result;
944
+ }
945
  }else
946
+ return $result;
947
+ }else
948
+ return array('error' => 'SFW_UPDATE WRONG_FILE_URLS');
 
 
 
 
 
 
 
 
 
 
 
 
 
949
 
950
+ } else {
951
+ // Go to init remote call
952
+ return Helper::http__request__rc_to_host(
953
+ get_option( 'siteurl' ),
954
+ array(
955
+ 'spbc_remote_call_token' => md5( $api_key ),
956
+ 'spbc_remote_call_action' => 'sfw_update',
957
+ 'plugin_name' => 'apbct',
958
+ // Additional params
959
+ 'firewall_updating_id' => $apbct->fw_stats['firewall_updating_id'],
960
+ ),
961
+ array( 'get','async' )
962
+ );
963
+ }
964
+
965
  }
966
 
967
  function ct_sfw_send_logs($api_key = '')
970
 
971
  $api_key = !empty($apbct->api_key) ? $apbct->api_key : $api_key;
972
 
973
+ if( empty( $api_key ) || $apbct->settings['spam_firewall'] != 1 ){
974
  return true;
975
  }
976
+
977
+ $result = SFW::send_log(
978
+ DB::getInstance(),
979
+ APBCT_TBL_FIREWALL_LOG,
980
+ $api_key
981
+ );
982
+
983
+ if(empty($result['error'])){
984
+ $apbct->stats['sfw']['last_send_time'] = time();
985
+ $apbct->stats['sfw']['last_send_amount'] = $result['rows'];
986
+ $apbct->save('stats');
987
+ $apbct->error_delete( 'sfw_send_logs', 'save_settings' );
988
+ }
989
 
990
+ return $result;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
991
  }
992
 
993
  function apbct_antiflood__clear_table(){
1445
  }
1446
 
1447
  function apbct_alt_session__id__get(){
1448
+ $id = Helper::ip__get('real')
1449
  .apbct_get_server_variable( 'HTTP_USER_AGENT' )
1450
  .apbct_get_server_variable( 'HTTP_ACCEPT_LANGUAGE' );
1451
  return hash('sha256', $id);
inc/cleantalk-common.php CHANGED
@@ -148,9 +148,11 @@ function apbct_base_call($params = array(), $reg_flag = false){
148
  $default_params = array(
149
 
150
  // IPs
151
- 'sender_ip' => defined('CT_TEST_IP') ? CT_TEST_IP : (isset($params['sender_ip']) ? $params['sender_ip'] : \Cleantalk\ApbctWP\Helper::ip__get(array('real'), false)),
152
- 'x_forwarded_for' => \Cleantalk\ApbctWP\Helper::ip__get(array('x_forwarded_for'), false),
153
- 'x_real_ip' => \Cleantalk\ApbctWP\Helper::ip__get(array('x_real_ip'), false),
 
 
154
 
155
  // Misc
156
  'auth_key' => $apbct->api_key,
@@ -407,7 +409,7 @@ function apbct_get_sender_info() {
407
  return array(
408
  'plugin_request_id' => $apbct->plugin_request_id,
409
  'wpms' => is_multisite() ? 'yes' : 'no',
410
- 'remote_addr' => \Cleantalk\ApbctWP\Helper::ip__get(array('remote_addr'), false),
411
  'REFFERRER' => apbct_get_server_variable( 'HTTP_REFERER' ),
412
  'USER_AGENT' => apbct_get_server_variable( 'HTTP_USER_AGENT' ),
413
  'page_url' => apbct_get_server_variable( 'SERVER_NAME' ) . apbct_get_server_variable( 'REQUEST_URI' ),
148
  $default_params = array(
149
 
150
  // IPs
151
+ 'sender_ip' => defined('CT_TEST_IP')
152
+ ? CT_TEST_IP
153
+ : \Cleantalk\ApbctWP\Helper::ip__get('remote_addr', false),
154
+ 'x_forwarded_for' => \Cleantalk\ApbctWP\Helper::ip__get('x_forwarded_for', false),
155
+ 'x_real_ip' => \Cleantalk\ApbctWP\Helper::ip__get('x_real_ip', false),
156
 
157
  // Misc
158
  'auth_key' => $apbct->api_key,
409
  return array(
410
  'plugin_request_id' => $apbct->plugin_request_id,
411
  'wpms' => is_multisite() ? 'yes' : 'no',
412
+ 'remote_addr' => \Cleantalk\ApbctWP\Helper::ip__get('remote_addr', false),
413
  'REFFERRER' => apbct_get_server_variable( 'HTTP_REFERER' ),
414
  'USER_AGENT' => apbct_get_server_variable( 'HTTP_USER_AGENT' ),
415
  'page_url' => apbct_get_server_variable( 'SERVER_NAME' ) . apbct_get_server_variable( 'REQUEST_URI' ),
inc/cleantalk-pluggable.php CHANGED
@@ -401,11 +401,19 @@ function apbct_is_skip_request( $ajax = false ) {
401
  }
402
  // Exception for plugin https://ru.wordpress.org/plugins/easy-login-woocommerce/ login form
403
  if(
404
- apbct_is_plugin_active( 'easy-login-woocommerce\xoo-el-main.php' ) &&
405
  Post::get( '_xoo_el_form' ) === 'login'
406
  ){
407
  return 'xoo_login';
408
  }
 
 
 
 
 
 
 
 
409
 
410
  break;
411
 
401
  }
402
  // Exception for plugin https://ru.wordpress.org/plugins/easy-login-woocommerce/ login form
403
  if(
404
+ apbct_is_plugin_active( 'easy-login-woocommerce/xoo-el-main.php' ) &&
405
  Post::get( '_xoo_el_form' ) === 'login'
406
  ){
407
  return 'xoo_login';
408
  }
409
+ // Emails & Newsletters with Jackmail: skip all admin-side actions
410
+ if(
411
+ apbct_is_plugin_active( 'jackmail-newsletters/jackmail-newsletters.php' ) &&
412
+ is_admin() &&
413
+ strpos( Server::get('HTTP_REFERER'), 'jackmail_' ) !== false
414
+ ){
415
+ return 'jackmail_admin_actions';
416
+ }
417
 
418
  break;
419
 
inc/cleantalk-public.php CHANGED
@@ -287,7 +287,7 @@ function apbct_init() {
287
  ! empty( $pmpro_required_user_fields['bconfirmemail'] ) &&
288
  $pmpro_required_user_fields['bemail'] == $pmpro_required_user_fields['bconfirmemail']
289
  ) {
290
- $check = ct_test_registration( $pmpro_required_user_fields['username'], $pmpro_required_user_fields['bemail'], apbct_get_server_variable( 'REMOTE_ADDR' ) );
291
  if( $check['allow'] == 0 ) {
292
  pmpro_setMessage( $check['comment'], 'pmpro_error' );
293
  }
@@ -1062,19 +1062,33 @@ function apbct_rorm__formidable__testSpam ( $errors, $form ) {
1062
 
1063
  $ct_temp_msg_data = ct_get_fields_any($_POST['item_meta']);
1064
 
1065
- $sender_email = ($ct_temp_msg_data['email'] ? $ct_temp_msg_data['email'] : '');
1066
- $sender_nickname = ($ct_temp_msg_data['nickname'] ? $ct_temp_msg_data['nickname'] : '');
1067
- $subject = ($ct_temp_msg_data['subject'] ? $ct_temp_msg_data['subject'] : '');
1068
- $contact_form = ($ct_temp_msg_data['contact'] ? $ct_temp_msg_data['contact'] : true);
1069
- $message = ($ct_temp_msg_data['message'] ? $ct_temp_msg_data['message'] : array());
1070
-
1071
  // Adding 'input_meta[]' to every field /Formidable fix/
1072
- $message = array_flip($message);
1073
- foreach($message as &$value){
 
 
 
 
 
 
 
 
 
 
 
 
1074
  $value = 'item_meta['.$value.']';
1075
  } unset($value);
1076
- $message = array_flip($message);
1077
-
 
 
1078
  $checkjs = apbct_js_test('ct_checkjs', $_COOKIE)
1079
  ? apbct_js_test('ct_checkjs', $_COOKIE)
1080
  : apbct_js_test('ct_checkjs', $_POST);
@@ -1435,7 +1449,7 @@ function ct_preprocess_comment($comment) {
1435
  // Change mail notification if license is out of date
1436
  if($apbct->data['moderate'] == 0){
1437
  $apbct->sender_email = $comment['comment_author_email'];
1438
- $apbct->sender_ip = \Cleantalk\ApbctWP\Helper::ip__get(array('real'));
1439
  add_filter('comment_moderation_text', 'apbct_comment__Wordpress__changeMailNotification', 100, 2); // Comment sent to moderation
1440
  add_filter('comment_notification_text', 'apbct_comment__Wordpress__changeMailNotification', 100, 2); // Comment approved
1441
  }
@@ -1880,7 +1894,7 @@ function ct_test_message($nickname, $email, $ip, $text){
1880
  * Check registrations for external plugins
1881
  * @return array with checking result;
1882
  */
1883
- function ct_test_registration($nickname, $email, $ip){
1884
 
1885
  global $ct_checkjs_register_form, $apbct;
1886
 
@@ -2014,7 +2028,7 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
2014
  ($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
2015
  ){
2016
  $apbct->sender_email = $user_email;
2017
- $apbct->sender_ip = \Cleantalk\ApbctWP\Helper::ip__get(array('real'));
2018
  add_filter('wp_new_user_notification_email_admin', 'apbct_registration__Wordpress__changeMailNotification', 100, 3);
2019
  }
2020
 
@@ -2346,7 +2360,7 @@ function apbct_form__contactForm7__tesSpam__before_validate($result = null, $tag
2346
  $invalid_fields = $result->get_invalid_fields();
2347
  if(!empty($invalid_fields) && is_array($invalid_fields)){
2348
  $apbct->validation_error = $invalid_fields[key($invalid_fields)]['reason'];
2349
- apbct_form__contactForm7__testSpam( false, null );
2350
  }
2351
  }
2352
 
@@ -2356,7 +2370,7 @@ function apbct_form__contactForm7__tesSpam__before_validate($result = null, $tag
2356
  /**
2357
  * Test CF7 message for spam
2358
  */
2359
- function apbct_form__contactForm7__testSpam($spam, $submission) {
2360
 
2361
  global $ct_checkjs_cf7, $apbct;
2362
 
@@ -2413,7 +2427,7 @@ function apbct_form__contactForm7__testSpam($spam, $submission) {
2413
  ($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
2414
  ){
2415
  $apbct->sender_email = $sender_email;
2416
- $apbct->sender_ip = \Cleantalk\ApbctWP\Helper::ip__get(array('real'));
2417
  add_filter('wpcf7_mail_components', 'apbct_form__contactForm7__changeMailNotification');
2418
  }
2419
 
@@ -2531,7 +2545,7 @@ function apbct_form__ninjaForms__testSpam() {
2531
  ($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
2532
  ){
2533
  $apbct->sender_email = $sender_email;
2534
- $apbct->sender_ip = \Cleantalk\ApbctWP\Helper::ip__get(array('real'));
2535
  add_filter('ninja_forms_action_email_message', 'apbct_form__ninjaForms__changeMailNotification', 1, 3);
2536
  }
2537
 
@@ -2774,7 +2788,7 @@ function apbct_form__WPForms__testSpam() {
2774
  ($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
2775
  ){
2776
  $apbct->sender_email = $sender_email;
2777
- $apbct->sender_ip = \Cleantalk\ApbctWP\Helper::ip__get(array('real'));
2778
  add_filter('wpforms_email_message', 'apbct_form__WPForms__changeMailNotification', 100, 2);
2779
  }
2780
 
287
  ! empty( $pmpro_required_user_fields['bconfirmemail'] ) &&
288
  $pmpro_required_user_fields['bemail'] == $pmpro_required_user_fields['bconfirmemail']
289
  ) {
290
+ $check = ct_test_registration( $pmpro_required_user_fields['username'], $pmpro_required_user_fields['bemail'] );
291
  if( $check['allow'] == 0 ) {
292
  pmpro_setMessage( $check['comment'], 'pmpro_error' );
293
  }
1062
 
1063
  $ct_temp_msg_data = ct_get_fields_any($_POST['item_meta']);
1064
 
1065
+ $sender_email = $ct_temp_msg_data['email'] ?: '';
1066
+ $sender_nickname = $ct_temp_msg_data['nickname'] ?: '';
1067
+ $subject = $ct_temp_msg_data['subject'] ?: '';
1068
+ $contact_form = $ct_temp_msg_data['contact'] ?: true;
1069
+ $message = $ct_temp_msg_data['message'] ?: array();
1070
+
1071
  // Adding 'input_meta[]' to every field /Formidable fix/
1072
+ // because filed names is 'input_meta[NUM]'
1073
+ // Get all scalar values
1074
+ $tmp_message = array();
1075
+ $tmp_message2 = array();
1076
+ foreach( $message as $key => $value ){
1077
+ if( is_scalar( $value ) ){
1078
+ $tmp_message[ $key ] = $value;
1079
+ }else{
1080
+ $tmp_message2[ $key ] = $value;
1081
+ }
1082
+ }
1083
+ // Replacing key to input_meta[NUM] for scalar values
1084
+ $tmp_message = array_flip($tmp_message);
1085
+ foreach($tmp_message as &$value){
1086
  $value = 'item_meta['.$value.']';
1087
  } unset($value);
1088
+ $tmp_message = array_flip($tmp_message);
1089
+ // Combine it with non-scalar values
1090
+ $message = array_merge( $tmp_message, $tmp_message2 );
1091
+
1092
  $checkjs = apbct_js_test('ct_checkjs', $_COOKIE)
1093
  ? apbct_js_test('ct_checkjs', $_COOKIE)
1094
  : apbct_js_test('ct_checkjs', $_POST);
1449
  // Change mail notification if license is out of date
1450
  if($apbct->data['moderate'] == 0){
1451
  $apbct->sender_email = $comment['comment_author_email'];
1452
+ $apbct->sender_ip = \Cleantalk\ApbctWP\Helper::ip__get('real');
1453
  add_filter('comment_moderation_text', 'apbct_comment__Wordpress__changeMailNotification', 100, 2); // Comment sent to moderation
1454
  add_filter('comment_notification_text', 'apbct_comment__Wordpress__changeMailNotification', 100, 2); // Comment approved
1455
  }
1894
  * Check registrations for external plugins
1895
  * @return array with checking result;
1896
  */
1897
+ function ct_test_registration($nickname, $email, $ip = null){
1898
 
1899
  global $ct_checkjs_register_form, $apbct;
1900
 
2028
  ($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
2029
  ){
2030
  $apbct->sender_email = $user_email;
2031
+ $apbct->sender_ip = \Cleantalk\ApbctWP\Helper::ip__get('real');
2032
  add_filter('wp_new_user_notification_email_admin', 'apbct_registration__Wordpress__changeMailNotification', 100, 3);
2033
  }
2034
 
2360
  $invalid_fields = $result->get_invalid_fields();
2361
  if(!empty($invalid_fields) && is_array($invalid_fields)){
2362
  $apbct->validation_error = $invalid_fields[key($invalid_fields)]['reason'];
2363
+ apbct_form__contactForm7__testSpam( false, null );
2364
  }
2365
  }
2366
 
2370
  /**
2371
  * Test CF7 message for spam
2372
  */
2373
+ function apbct_form__contactForm7__testSpam($spam, $submission ) {
2374
 
2375
  global $ct_checkjs_cf7, $apbct;
2376
 
2427
  ($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
2428
  ){
2429
  $apbct->sender_email = $sender_email;
2430
+ $apbct->sender_ip = \Cleantalk\ApbctWP\Helper::ip__get('real');
2431
  add_filter('wpcf7_mail_components', 'apbct_form__contactForm7__changeMailNotification');
2432
  }
2433
 
2545
  ($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
2546
  ){
2547
  $apbct->sender_email = $sender_email;
2548
+ $apbct->sender_ip = \Cleantalk\ApbctWP\Helper::ip__get('real');
2549
  add_filter('ninja_forms_action_email_message', 'apbct_form__ninjaForms__changeMailNotification', 1, 3);
2550
  }
2551
 
2788
  ($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
2789
  ){
2790
  $apbct->sender_email = $sender_email;
2791
+ $apbct->sender_ip = \Cleantalk\ApbctWP\Helper::ip__get('real');
2792
  add_filter('wpforms_email_message', 'apbct_form__WPForms__changeMailNotification', 100, 2);
2793
  }
2794
 
inc/cleantalk-settings.php CHANGED
@@ -924,8 +924,9 @@ function apbct_settings__field__state(){
924
  // WooCommerce
925
  if(class_exists('WooCommerce'))
926
  echo '<img class="apbct_status_icon" src="'.($apbct->settings['wc_checkout_test'] == 1 ? $img : $img_no).'"/>'.__('WooCommerce checkout form', 'cleantalk-spam-protect');
927
- if($apbct->moderate_ip)
928
- print "<br /><br />The anti-spam service is paid by your hosting provider. License #".$apbct->data['ip_license'].".<br />";
 
929
 
930
  print "</div>";
931
  }
@@ -1403,7 +1404,7 @@ function apbct_settings__validate($settings) {
1403
 
1404
  $website = parse_url(get_option('siteurl'), PHP_URL_HOST).parse_url(get_option('siteurl'), PHP_URL_PATH);
1405
  $platform = 'wordpress';
1406
- $user_ip = \Cleantalk\ApbctWP\Helper::ip__get(array('real'), false);
1407
  $timezone = filter_input(INPUT_POST, 'ct_admin_timezone');
1408
  $language = apbct_get_server_variable( 'HTTP_ACCEPT_LANGUAGE' );
1409
  $wpms = APBCT_WPMS && defined('SUBDOMAIN_INSTALL') && !SUBDOMAIN_INSTALL ? true : false;
924
  // WooCommerce
925
  if(class_exists('WooCommerce'))
926
  echo '<img class="apbct_status_icon" src="'.($apbct->settings['wc_checkout_test'] == 1 ? $img : $img_no).'"/>'.__('WooCommerce checkout form', 'cleantalk-spam-protect');
927
+
928
+ if($apbct->moderate_ip)
929
+ print "<br /><br />The anti-spam service is paid by your hosting provider. License #".$apbct->data['ip_license'].".<br />";
930
 
931
  print "</div>";
932
  }
1404
 
1405
  $website = parse_url(get_option('siteurl'), PHP_URL_HOST).parse_url(get_option('siteurl'), PHP_URL_PATH);
1406
  $platform = 'wordpress';
1407
+ $user_ip = \Cleantalk\ApbctWP\Helper::ip__get('real', false);
1408
  $timezone = filter_input(INPUT_POST, 'ct_admin_timezone');
1409
  $language = apbct_get_server_variable( 'HTTP_ACCEPT_LANGUAGE' );
1410
  $wpms = APBCT_WPMS && defined('SUBDOMAIN_INSTALL') && !SUBDOMAIN_INSTALL ? true : false;
js/apbct-disable-comments.min.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";wp.domReady(function(){wp.blocks&&wp.blocks.getBlockTypes().forEach(function(e){apbctDisableComments.disabled_blocks.includes(e.name)&&wp.blocks.unregisterBlockType(e.name)})});
2
- //# sourceMappingURL=apbct-disable-comments.min.js.map
1
+ "use strict";wp.domReady(function(){wp.blocks&&wp.blocks.getBlockTypes().forEach(function(e){apbctDisableComments.disabled_blocks.includes(e.name)&&wp.blocks.unregisterBlockType(e.name)})});
2
+ //# sourceMappingURL=apbct-disable-comments.min.js.map
js/cleantalk-admin-settings-page.min.js CHANGED
@@ -1,2 +1,2 @@
1
- function apbct_banner_check(){var a=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(a))}})},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 a=[];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&&a.push(c[key])}else a.push(c[key])}),a}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=isNaN(a)?null:a,apbct_get_elems__native(e).forEach(function(e,t,n){console.log(e.getAttribute("id"));if(null===a&&(a=null===e.getAttribute("disabled")?0:1),1===a?e.removeAttribute("disabled"):e.setAttribute("disabled","disabled"),null!==e.getAttribute("apbct_children")){var c=apbctSettingsDependencies_getState(e)&&a;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 a=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",a))};a(),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",a)}},n)}jQuery(document).ready(function(){document.getElementsByClassName("apbct_settings-title")[0]&&"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("#apbct_button__sync").on("click",function(){apbct_admin_sendAJAX({action:"apbct_sync"},{timeout:25e3,button:document.getElementById("apbct_button__sync"),spinner:jQuery("#apbct_button__sync .apbct_preloader_button"),callback:function(e,t,n,c){jQuery(".apbct_success").show(300),setTimeout(function(){jQuery(".apbct_success").hide(300)},2e3),e.reload&&document.location.reload()}})}),ctSettingsPage.key_changed&&jQuery("#apbct_button__sync").click(),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
1
+ function apbct_banner_check(){var a=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(a))}})},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 a=[];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&&a.push(c[key])}else a.push(c[key])}),a}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=isNaN(a)?null:a,apbct_get_elems__native(e).forEach(function(e,t,n){console.log(e.getAttribute("id"));if(null===a&&(a=null===e.getAttribute("disabled")?0:1),1===a?e.removeAttribute("disabled"):e.setAttribute("disabled","disabled"),null!==e.getAttribute("apbct_children")){var c=apbctSettingsDependencies_getState(e)&&a;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 a=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",a))};a(),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",a)}},n)}jQuery(document).ready(function(){document.getElementsByClassName("apbct_settings-title")[0]&&"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("#apbct_button__sync").on("click",function(){apbct_admin_sendAJAX({action:"apbct_sync"},{timeout:25e3,button:document.getElementById("apbct_button__sync"),spinner:jQuery("#apbct_button__sync .apbct_preloader_button"),callback:function(e,t,n,c){jQuery(".apbct_success").show(300),setTimeout(function(){jQuery(".apbct_success").hide(300)},2e3),e.reload&&document.location.reload()}})}),ctSettingsPage.key_changed&&jQuery("#apbct_button__sync").click(),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
lib/Cleantalk/Antispam/Integrations.php CHANGED
@@ -1,103 +1,103 @@
1
- <?php
2
-
3
-
4
- namespace Cleantalk\Antispam;
5
-
6
-
7
- class Integrations
8
- {
9
-
10
- private $integrations = array();
11
-
12
- private $integration;
13
-
14
- public function __construct( $integrations )
15
- {
16
- $this->integrations = $integrations;
17
-
18
- foreach( $this->integrations as $integration_name => $integration_info ) {
19
- if( $integration_info['ajax'] ) {
20
- if( is_array( $integration_info['hook'] ) ) {
21
- foreach( $integration_info['hook'] as $hook ) {
22
- add_action( 'wp_ajax_' . $hook, array( $this, 'checkSpam' ), 1 );
23
- add_action( 'wp_ajax_nopriv_' . $hook, array( $this, 'checkSpam' ), 1 );
24
- }
25
- } else {
26
- add_action( 'wp_ajax_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
27
- add_action( 'wp_ajax_nopriv_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
28
- }
29
- } else {
30
- add_action( $integration_info['hook'], array( $this, 'checkSpam' ) );
31
- }
32
- }
33
- }
34
-
35
- public function checkSpam( $argument )
36
- {
37
- global $cleantalk_executed;
38
-
39
- // Getting current integration name
40
- $current_integration = $this->get_current_integration_triggered( current_filter() );
41
- if( $current_integration ) {
42
- // Instantiate the integration object
43
- $class = '\\Cleantalk\\Antispam\\Integrations\\' . $current_integration;
44
- if( class_exists( $class )) {
45
- $this->integration = new $class();
46
- if( ! ( $this->integration instanceof \Cleantalk\Antispam\Integrations\IntegrationBase ) ) {
47
- // @ToDo have to handle an error
48
- do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, array('Integration is not instanse of IntegrationBase class.') );
49
- return;
50
- }
51
- // Run data collecting for spam checking
52
- $data = $this->integration->getDataForChecking( $argument );
53
- if( ! is_null( $data ) ) {
54
- // Go spam checking
55
- $base_call_result = apbct_base_call(
56
- array(
57
- 'message' => !empty( $data['message'] ) ? json_encode( $data['message'] ) : '',
58
- 'sender_email' => !empty( $data['email'] ) ? $data['email'] : '',
59
- 'sender_nickname' => !empty( $data['nickname'] ) ? $data['nickname'] : '',
60
- 'post_info' => array(
61
- 'comment_type' => 'contact_form_wordpress_' . strtolower($current_integration),
62
- 'post_url' => apbct_get_server_variable( 'HTTP_REFERER' ), // Page URL must be an previous page
63
- ),
64
- ),
65
- isset( $data['register'] ) ? true : false
66
- );
67
-
68
- $ct_result = $base_call_result['ct_result'];
69
-
70
- $cleantalk_executed = true;
71
-
72
- if ($ct_result->allow == 0) {
73
- // Do blocking if it is a spam
74
- $this->integration->doBlock( $ct_result->comment );
75
- }
76
- } else {
77
- // @ToDo have to handle an error
78
- return;
79
- }
80
- }
81
- }
82
- }
83
-
84
- private function get_current_integration_triggered( $hook )
85
- {
86
- if( $hook !== false ) {
87
- foreach( $this->integrations as $integration_name => $integration_info ) {
88
- if( is_array( $integration_info['hook'] ) ) {
89
- foreach( $integration_info['hook'] as $integration_hook ) {
90
- if( strpos( $hook, $integration_hook ) !== false ) {
91
- return $integration_name;
92
- }
93
- }
94
- } else {
95
- if( strpos( $hook, $integration_info['hook'] ) !== false ) {
96
- return $integration_name;
97
- }
98
- }
99
- }
100
- }
101
- return false;
102
- }
103
  }
1
+ <?php
2
+
3
+
4
+ namespace Cleantalk\Antispam;
5
+
6
+
7
+ class Integrations
8
+ {
9
+
10
+ private $integrations = array();
11
+
12
+ private $integration;
13
+
14
+ public function __construct( $integrations )
15
+ {
16
+ $this->integrations = $integrations;
17
+
18
+ foreach( $this->integrations as $integration_name => $integration_info ) {
19
+ if( $integration_info['ajax'] ) {
20
+ if( is_array( $integration_info['hook'] ) ) {
21
+ foreach( $integration_info['hook'] as $hook ) {
22
+ add_action( 'wp_ajax_' . $hook, array( $this, 'checkSpam' ), 1 );
23
+ add_action( 'wp_ajax_nopriv_' . $hook, array( $this, 'checkSpam' ), 1 );
24
+ }
25
+ } else {
26
+ add_action( 'wp_ajax_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
27
+ add_action( 'wp_ajax_nopriv_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
28
+ }
29
+ } else {
30
+ add_action( $integration_info['hook'], array( $this, 'checkSpam' ) );
31
+ }
32
+ }
33
+ }
34
+
35
+ public function checkSpam( $argument )
36
+ {
37
+ global $cleantalk_executed;
38
+
39
+ // Getting current integration name
40
+ $current_integration = $this->get_current_integration_triggered( current_filter() );
41
+ if( $current_integration ) {
42
+ // Instantiate the integration object
43
+ $class = '\\Cleantalk\\Antispam\\Integrations\\' . $current_integration;
44
+ if( class_exists( $class )) {
45
+ $this->integration = new $class();
46
+ if( ! ( $this->integration instanceof \Cleantalk\Antispam\Integrations\IntegrationBase ) ) {
47
+ // @ToDo have to handle an error
48
+ do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, array('Integration is not instanse of IntegrationBase class.') );
49
+ return;
50
+ }
51
+ // Run data collecting for spam checking
52
+ $data = $this->integration->getDataForChecking( $argument );
53
+ if( ! is_null( $data ) ) {
54
+ // Go spam checking
55
+ $base_call_result = apbct_base_call(
56
+ array(
57
+ 'message' => !empty( $data['message'] ) ? json_encode( $data['message'] ) : '',
58
+ 'sender_email' => !empty( $data['email'] ) ? $data['email'] : '',
59
+ 'sender_nickname' => !empty( $data['nickname'] ) ? $data['nickname'] : '',
60
+ 'post_info' => array(
61
+ 'comment_type' => 'contact_form_wordpress_' . strtolower($current_integration),
62
+ 'post_url' => apbct_get_server_variable( 'HTTP_REFERER' ), // Page URL must be an previous page
63
+ ),
64
+ ),
65
+ isset( $data['register'] ) ? true : false
66
+ );
67
+
68
+ $ct_result = $base_call_result['ct_result'];
69
+
70
+ $cleantalk_executed = true;
71
+
72
+ if ($ct_result->allow == 0) {
73
+ // Do blocking if it is a spam
74
+ $this->integration->doBlock( $ct_result->comment );
75
+ }
76
+ } else {
77
+ // @ToDo have to handle an error
78
+ return;
79
+ }
80
+ }
81
+ }
82
+ }
83
+
84
+ private function get_current_integration_triggered( $hook )
85
+ {
86
+ if( $hook !== false ) {
87
+ foreach( $this->integrations as $integration_name => $integration_info ) {
88
+ if( is_array( $integration_info['hook'] ) ) {
89
+ foreach( $integration_info['hook'] as $integration_hook ) {
90
+ if( strpos( $hook, $integration_hook ) !== false ) {
91
+ return $integration_name;
92
+ }
93
+ }
94
+ } else {
95
+ if( strpos( $hook, $integration_info['hook'] ) !== false ) {
96
+ return $integration_name;
97
+ }
98
+ }
99
+ }
100
+ }
101
+ return false;
102
+ }
103
  }
lib/Cleantalk/ApbctWP/FindSpam/UsersChecker.php CHANGED
@@ -66,10 +66,14 @@ class UsersChecker extends Checker
66
  */
67
  public static function get_count_text() {
68
 
69
- $res = count_users();
 
 
 
 
70
 
71
- if( $res['total_users'] ) {
72
- $text = sprintf( esc_html__ ('Total count of users: %s.', 'cleantalk-spam-protect' ), $res['total_users'] );
73
  } else {
74
  $text = esc_html__( 'No users found.', 'cleantalk-spam-protect' );
75
  }
@@ -97,9 +101,9 @@ class UsersChecker extends Checker
97
 
98
  if( $cnt_checked > 0 ) {
99
 
100
- // If we have checked users return last user reg date
101
  $users = $tmp->get_results();
102
- return self::getUserRegister( end( $users ) );
103
 
104
  } else {
105
 
66
  */
67
  public static function get_count_text() {
68
 
69
+ global $wpdb;
70
+
71
+ $res = $wpdb->get_var("
72
+ SELECT COUNT(*)
73
+ FROM {$wpdb->users}");
74
 
75
+ if( $res ) {
76
+ $text = sprintf( esc_html__ ('Total count of users: %s.', 'cleantalk-spam-protect' ), $res );
77
  } else {
78
  $text = esc_html__( 'No users found.', 'cleantalk-spam-protect' );
79
  }
101
 
102
  if( $cnt_checked > 0 ) {
103
 
104
+ // If we have checked users return last checking date
105
  $users = $tmp->get_results();
106
+ return date( "M j Y", strtotime( get_user_meta( end( $users ), 'ct_checked', true ) ) );
107
 
108
  } else {
109
 
lib/Cleantalk/ApbctWP/RemoteCalls.php CHANGED
@@ -45,7 +45,7 @@ class RemoteCalls
45
  if ( Get::get( 'test' ) )
46
  die('OK');
47
 
48
- if( time() - $apbct->remote_calls[ $action ]['last_call'] >= $cooldown ){
49
 
50
  $apbct->remote_calls[$action]['last_call'] = time();
51
  $apbct->save('remote_calls');
@@ -58,30 +58,23 @@ class RemoteCalls
58
 
59
  $action = 'action__'.$action;
60
 
61
- if(method_exists('Cleantalk\ApbctWP\RemoteCalls', $action)){
62
-
63
- if(get_option('spbc_deactivation_in_process') === false){ // Continue if plugin is active
64
-
65
- // Delay before perform action;
66
- if ( Get::get( 'delay' ) )
67
- sleep( Get::get( 'delay' ) );
68
-
69
- $action_result = RemoteCalls::$action();
70
- $response = empty( $action_result['error'] )
71
- ? 'OK'
72
- : 'FAIL ' . json_encode( array( 'error' => $action_result['error'] ) );
73
-
74
- if( ! Get::get( 'continue_execution' ) ){
75
- die( $response );
76
- }
77
-
78
- return $response;
79
-
80
- // Stop execution if plugin is deactivated
81
- }else{
82
- delete_option('cleantalk_deactivation_in_process');
83
- $out = 'FAIL '.json_encode(array('error' => 'PLUGIN_DEACTIVATION_IN_PROCESS'));
84
- }
85
  }else
86
  $out = 'FAIL '.json_encode(array('error' => 'UNKNOWN_ACTION_METHOD'));
87
  }else
45
  if ( Get::get( 'test' ) )
46
  die('OK');
47
 
48
+ if( time() - $apbct->remote_calls[ $action ]['last_call'] >= $cooldown || ( $action === 'sfw_update' && isset($_GET['file_urls'] ) ) ){
49
 
50
  $apbct->remote_calls[$action]['last_call'] = time();
51
  $apbct->save('remote_calls');
58
 
59
  $action = 'action__'.$action;
60
 
61
+ if( method_exists( 'Cleantalk\ApbctWP\RemoteCalls', $action ) ){
62
+
63
+ // Delay before perform action;
64
+ if ( Get::get( 'delay' ) )
65
+ sleep( Get::get( 'delay' ) );
66
+
67
+ $action_result = RemoteCalls::$action();
68
+ $response = empty( $action_result['error'] )
69
+ ? 'OK'
70
+ : 'FAIL ' . json_encode( array( 'error' => $action_result['error'] ) );
71
+
72
+ if( ! Get::get( 'continue_execution' ) ){
73
+ die( $response );
74
+ }
75
+
76
+ return $response;
77
+
 
 
 
 
 
 
 
78
  }else
79
  $out = 'FAIL '.json_encode(array('error' => 'UNKNOWN_ACTION_METHOD'));
80
  }else
lib/Cleantalk/Common/Firewall.php CHANGED
@@ -57,18 +57,18 @@ class Firewall
57
  public function __construct( $db ){
58
  $this->db = $db;
59
  $this->debug = !! Get::get( 'debug' );
60
- $this->ip_array = $this->ip__get( array('real'), true );
61
  }
62
 
63
  /**
64
  * Getting arrays of IP (REMOTE_ADDR, X-Forwarded-For, X-Real-Ip, Cf_Connecting_Ip)
65
  *
66
- * @param array $ips_input type of IP you want to receive
67
  * @param bool $v4_only
68
  *
69
  * @return array|mixed|null
70
  */
71
- public function ip__get( $ips_input = array( 'real', 'remote_addr', 'x_forwarded_for', 'x_real_ip', 'cloud_flare' ), $v4_only = true ){
72
 
73
  $result = Helper::ip__get( $ips_input, $v4_only );
74
 
57
  public function __construct( $db ){
58
  $this->db = $db;
59
  $this->debug = !! Get::get( 'debug' );
60
+ $this->ip_array = $this->ip__get( 'real', true );
61
  }
62
 
63
  /**
64
  * Getting arrays of IP (REMOTE_ADDR, X-Forwarded-For, X-Real-Ip, Cf_Connecting_Ip)
65
  *
66
+ * @param string $ips_input type of IP you want to receive
67
  * @param bool $v4_only
68
  *
69
  * @return array|mixed|null
70
  */
71
+ public function ip__get( $ips_input = 'real', $v4_only = true ){
72
 
73
  $result = Helper::ip__get( $ips_input, $v4_only );
74
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: spam, antispam, anti-spam, comments, firewall
4
  Requires at least: 3.0
5
  Tested up to: 5.6
6
  Requires PHP: 5.4
7
- Stable tag: 5.153.1
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
@@ -580,10 +580,23 @@ If your website has forms that send data to external sources, you can enable opt
580
 
581
  == Changelog ==
582
 
 
 
 
 
 
 
 
 
 
 
 
 
 
583
  = 5.153.1 Feb 20 2021 =
584
  * Fix: CF7. Modified spam hook #2
585
 
586
- = 5.153 Feb 17.02.2021 =
587
  * New: Integrations. WPDiscuz integration implemented.
588
  * New: Using custom modal message instead allert.
589
  * New: JS cleantalk-modal added.
4
  Requires at least: 3.0
5
  Tested up to: 5.6
6
  Requires PHP: 5.4
7
+ Stable tag: 5.153.2
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
580
 
581
  == Changelog ==
582
 
583
+ = 5.153.2 Feb 25 2021 =
584
+ * Fix: Integration. Registration on WICITY theme.
585
+ * Fix: Integration. Registration on Paid Memberships Pro
586
+ * Fix: IP detection.
587
+ * Fix: Error: SFW_DISABLED.
588
+ * Fix: Formidable form. Error with sophisticated field types.
589
+ * Fix: Remote Calls. Cooldown checking for the SFW update fixed.
590
+ * Fix: easy-login-woocommerce requests exclusion fixed.
591
+ * Fix: Jackmail plugin. Skip all admin-side actions.
592
+ * Fix: Remote Calls. Unused deactivation option removed.
593
+ * Fix: Users checker. Last check date fixed.
594
+ * Fix: Users checker. Total users count description fixed.
595
+
596
  = 5.153.1 Feb 20 2021 =
597
  * Fix: CF7. Modified spam hook #2
598
 
599
+ = 5.153 Feb 17 2021 =
600
  * New: Integrations. WPDiscuz integration implemented.
601
  * New: Using custom modal message instead allert.
602
  * New: JS cleantalk-modal added.