Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.157.2

Version Description

May 05 2021 = * Fix: Code. get_fields_any() notice fixed. * Fix: Integration. Gravity Forms integration fixed. * Fix: Forms. Nicknames detecting fixed.

Download this release

Release Info

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

Code changes from version 5.157.1 to 5.157.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.157.1
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
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.157.2
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
inc/cleantalk-autoloader.php CHANGED
@@ -1,21 +1,21 @@
1
- <?php
2
-
3
- /**
4
- * Autoloader for \Cleantalk\* classes
5
- *
6
- * @param string $class
7
- *
8
- * @return void
9
- */
10
- function apbct_autoloader( $class ){
11
- // Register class auto loader
12
- // Custom modules
13
- if( strpos( $class, 'cleantalk-spam-protect') !== false && ! class_exists( '\\' . $class )) {
14
- $class_file = CLEANTALK_PLUGIN_DIR . 'lib' . DIRECTORY_SEPARATOR . $class . '.php';
15
- if( file_exists( $class_file ) ){
16
- require_once( $class_file );
17
- }
18
- }
19
- }
20
-
21
- spl_autoload_register( 'apbct_autoloader' );
1
+ <?php
2
+
3
+ /**
4
+ * Autoloader for \Cleantalk\* classes
5
+ *
6
+ * @param string $class
7
+ *
8
+ * @return void
9
+ */
10
+ function apbct_autoloader( $class ){
11
+ // Register class auto loader
12
+ // Custom modules
13
+ if( strpos( $class, 'cleantalk-spam-protect') !== false && ! class_exists( '\\' . $class )) {
14
+ $class_file = CLEANTALK_PLUGIN_DIR . 'lib' . DIRECTORY_SEPARATOR . $class . '.php';
15
+ if( file_exists( $class_file ) ){
16
+ require_once( $class_file );
17
+ }
18
+ }
19
+ }
20
+
21
+ spl_autoload_register( 'apbct_autoloader' );
inc/cleantalk-common.php CHANGED
@@ -828,6 +828,16 @@ function ct_get_fields_any($arr, $message=array(), $email = null, $nickname = ar
828
  $visible_fields = apbct_visible_fields__process( Cookie::get( 'apbct_visible_fields', array(), 'array' ) );
829
  $visible_fields_arr = isset( $visible_fields['visible_fields'] ) ? explode( ' ', $visible_fields['visible_fields'] ) : array();
830
 
 
 
 
 
 
 
 
 
 
 
831
  if(count($arr)){
832
 
833
  foreach($arr as $key => $value){
@@ -908,14 +918,15 @@ function ct_get_fields_any($arr, $message=array(), $email = null, $nickname = ar
908
  // if there is an visible fields array then we take the name from it,
909
  // ignoring the hidden fields with name
910
  }elseif (
 
911
  preg_match("/name/i", $key) !== false &&
912
  (
913
  empty($visible_fields_arr) ||
914
  in_array($key, $visible_fields_arr)
915
  )
916
  ) {
917
- preg_match("/((name.?)?(your|first|for)(.?name)?)/", $key, $match_forename);
918
- preg_match("/((name.?)?(last|family|second|sur)(.?name)?)/", $key, $match_surname);
919
  preg_match("/(name.?)?(nick|user)(.?name)?/", $key, $match_nickname);
920
 
921
  if(count($match_forename) > 1)
@@ -959,10 +970,10 @@ function ct_get_fields_any($arr, $message=array(), $email = null, $nickname = ar
959
  }
960
  } unset($v);
961
 
962
- //If top iteration, returns compiled name field. Example: "Nickname Firtsname Lastname".
963
- if($prev_name === ''){
 
964
  if(!empty($nickname)){
965
- $nickname_str = '';
966
  foreach($nickname as $value){
967
  $nickname_str .= ($value ? $value." " : "");
968
  }unset($value);
828
  $visible_fields = apbct_visible_fields__process( Cookie::get( 'apbct_visible_fields', array(), 'array' ) );
829
  $visible_fields_arr = isset( $visible_fields['visible_fields'] ) ? explode( ' ', $visible_fields['visible_fields'] ) : array();
830
 
831
+ $nickname_default = true;
832
+ if(is_array($nickname)) {
833
+ foreach ($nickname as $v) {
834
+ if($v) $nickname_default = false;
835
+ }
836
+ }
837
+ if(is_string($nickname)) {
838
+ $nickname_default = false;
839
+ }
840
+
841
  if(count($arr)){
842
 
843
  foreach($arr as $key => $value){
918
  // if there is an visible fields array then we take the name from it,
919
  // ignoring the hidden fields with name
920
  }elseif (
921
+ $nickname_default &&
922
  preg_match("/name/i", $key) !== false &&
923
  (
924
  empty($visible_fields_arr) ||
925
  in_array($key, $visible_fields_arr)
926
  )
927
  ) {
928
+ preg_match("/(name.?)?(your|first|for)(.?name)/", $key, $match_forename);
929
+ preg_match("/(name.?)?(last|family|second|sur)(.?name)/", $key, $match_surname);
930
  preg_match("/(name.?)?(nick|user)(.?name)?/", $key, $match_nickname);
931
 
932
  if(count($match_forename) > 1)
970
  }
971
  } unset($v);
972
 
973
+ //If top iteration, returns compiled name field. Example: "Nickname Firtsname Lastname".]
974
+ if( ( $nickname_default && $prev_name === '' ) || is_array( $nickname ) ){
975
+ $nickname_str = '';
976
  if(!empty($nickname)){
 
977
  foreach($nickname as $value){
978
  $nickname_str .= ($value ? $value." " : "");
979
  }unset($value);
inc/cleantalk-public.php CHANGED
@@ -3268,13 +3268,6 @@ function apbct_form__gravityForms__testSpam($is_spam, $form, $entry) {
3268
  $subject = ($ct_temp_msg_data['subject'] ? $ct_temp_msg_data['subject'] : '');
3269
  $contact_form = ($ct_temp_msg_data['contact'] ? $ct_temp_msg_data['contact'] : true);
3270
  $message = ($ct_temp_msg_data['message'] ? $ct_temp_msg_data['message'] : array());
3271
-
3272
- // Adding 'input_' to every field /Gravity Forms fix/
3273
- $tmp = $message;
3274
- $message = array();
3275
- foreach($tmp as $key => $value){
3276
- $message[ 'input_' . $key] = $value;
3277
- } unset( $key, $value, $tmp );
3278
 
3279
  if($subject != '')
3280
  $message['subject'] = $subject;
3268
  $subject = ($ct_temp_msg_data['subject'] ? $ct_temp_msg_data['subject'] : '');
3269
  $contact_form = ($ct_temp_msg_data['contact'] ? $ct_temp_msg_data['contact'] : true);
3270
  $message = ($ct_temp_msg_data['message'] ? $ct_temp_msg_data['message'] : array());
 
 
 
 
 
 
 
3271
 
3272
  if($subject != '')
3273
  $message['subject'] = $subject;
lib/Cleantalk/Antispam/Integrations.php CHANGED
@@ -1,113 +1,113 @@
1
- <?php
2
-
3
-
4
- namespace Cleantalk\Antispam;
5
-
6
-
7
- class Integrations
8
- {
9
-
10
- private $integrations = array();
11
-
12
- private $integration;
13
-
14
- /**
15
- * Integrations constructor.
16
- *
17
- * @param array $integrations
18
- * @param array $settings
19
- */
20
- public function __construct( $integrations, $settings )
21
- {
22
- $this->integrations = $integrations;
23
-
24
- foreach( $this->integrations as $integration_name => $integration_info ){
25
-
26
- if( empty( $settings[ $integration_info['setting'] ] ) )
27
- continue;
28
-
29
- if( $integration_info['ajax'] ) {
30
- if( is_array( $integration_info['hook'] ) ) {
31
- foreach( $integration_info['hook'] as $hook ) {
32
- add_action( 'wp_ajax_' . $hook, array( $this, 'checkSpam' ), 1 );
33
- add_action( 'wp_ajax_nopriv_' . $hook, array( $this, 'checkSpam' ), 1 );
34
- }
35
- } else {
36
- add_action( 'wp_ajax_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
37
- add_action( 'wp_ajax_nopriv_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
38
- }
39
- } else {
40
- add_action( $integration_info['hook'], array( $this, 'checkSpam' ) );
41
- }
42
- }
43
- }
44
-
45
- public function checkSpam( $argument )
46
- {
47
- global $cleantalk_executed;
48
-
49
- // Getting current integration name
50
- $current_integration = $this->get_current_integration_triggered( current_filter() );
51
- if( $current_integration ) {
52
- // Instantiate the integration object
53
- $class = '\\Cleantalk\\Antispam\\Integrations\\' . $current_integration;
54
- if( class_exists( $class )) {
55
- $this->integration = new $class();
56
- if( ! ( $this->integration instanceof \Cleantalk\Antispam\Integrations\IntegrationBase ) ) {
57
- // @ToDo have to handle an error
58
- do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, array('Integration is not instanse of IntegrationBase class.') );
59
- return;
60
- }
61
- // Run data collecting for spam checking
62
- $data = $this->integration->getDataForChecking( $argument );
63
- if( ! is_null( $data ) ) {
64
- // Go spam checking
65
- $base_call_result = apbct_base_call(
66
- array(
67
- 'message' => !empty( $data['message'] ) ? json_encode( $data['message'] ) : '',
68
- 'sender_email' => !empty( $data['email'] ) ? $data['email'] : '',
69
- 'sender_nickname' => !empty( $data['nickname'] ) ? $data['nickname'] : '',
70
- 'post_info' => array(
71
- 'comment_type' => 'contact_form_wordpress_' . strtolower($current_integration),
72
- 'post_url' => apbct_get_server_variable( 'HTTP_REFERER' ), // Page URL must be an previous page
73
- ),
74
- ),
75
- isset( $data['register'] ) ? true : false
76
- );
77
-
78
- $ct_result = $base_call_result['ct_result'];
79
-
80
- $cleantalk_executed = true;
81
-
82
- if ($ct_result->allow == 0) {
83
- // Do blocking if it is a spam
84
- $this->integration->doBlock( $ct_result->comment );
85
- }
86
- } else {
87
- // @ToDo have to handle an error
88
- return;
89
- }
90
- }
91
- }
92
- }
93
-
94
- private function get_current_integration_triggered( $hook )
95
- {
96
- if( $hook !== false ) {
97
- foreach( $this->integrations as $integration_name => $integration_info ) {
98
- if( is_array( $integration_info['hook'] ) ) {
99
- foreach( $integration_info['hook'] as $integration_hook ) {
100
- if( strpos( $hook, $integration_hook ) !== false ) {
101
- return $integration_name;
102
- }
103
- }
104
- } else {
105
- if( strpos( $hook, $integration_info['hook'] ) !== false ) {
106
- return $integration_name;
107
- }
108
- }
109
- }
110
- }
111
- return false;
112
- }
113
  }
1
+ <?php
2
+
3
+
4
+ namespace Cleantalk\Antispam;
5
+
6
+
7
+ class Integrations
8
+ {
9
+
10
+ private $integrations = array();
11
+
12
+ private $integration;
13
+
14
+ /**
15
+ * Integrations constructor.
16
+ *
17
+ * @param array $integrations
18
+ * @param array $settings
19
+ */
20
+ public function __construct( $integrations, $settings )
21
+ {
22
+ $this->integrations = $integrations;
23
+
24
+ foreach( $this->integrations as $integration_name => $integration_info ){
25
+
26
+ if( empty( $settings[ $integration_info['setting'] ] ) )
27
+ continue;
28
+
29
+ if( $integration_info['ajax'] ) {
30
+ if( is_array( $integration_info['hook'] ) ) {
31
+ foreach( $integration_info['hook'] as $hook ) {
32
+ add_action( 'wp_ajax_' . $hook, array( $this, 'checkSpam' ), 1 );
33
+ add_action( 'wp_ajax_nopriv_' . $hook, array( $this, 'checkSpam' ), 1 );
34
+ }
35
+ } else {
36
+ add_action( 'wp_ajax_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
37
+ add_action( 'wp_ajax_nopriv_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
38
+ }
39
+ } else {
40
+ add_action( $integration_info['hook'], array( $this, 'checkSpam' ) );
41
+ }
42
+ }
43
+ }
44
+
45
+ public function checkSpam( $argument )
46
+ {
47
+ global $cleantalk_executed;
48
+
49
+ // Getting current integration name
50
+ $current_integration = $this->get_current_integration_triggered( current_filter() );
51
+ if( $current_integration ) {
52
+ // Instantiate the integration object
53
+ $class = '\\Cleantalk\\Antispam\\Integrations\\' . $current_integration;
54
+ if( class_exists( $class )) {
55
+ $this->integration = new $class();
56
+ if( ! ( $this->integration instanceof \Cleantalk\Antispam\Integrations\IntegrationBase ) ) {
57
+ // @ToDo have to handle an error
58
+ do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, array('Integration is not instanse of IntegrationBase class.') );
59
+ return;
60
+ }
61
+ // Run data collecting for spam checking
62
+ $data = $this->integration->getDataForChecking( $argument );
63
+ if( ! is_null( $data ) ) {
64
+ // Go spam checking
65
+ $base_call_result = apbct_base_call(
66
+ array(
67
+ 'message' => !empty( $data['message'] ) ? json_encode( $data['message'] ) : '',
68
+ 'sender_email' => !empty( $data['email'] ) ? $data['email'] : '',
69
+ 'sender_nickname' => !empty( $data['nickname'] ) ? $data['nickname'] : '',
70
+ 'post_info' => array(
71
+ 'comment_type' => 'contact_form_wordpress_' . strtolower($current_integration),
72
+ 'post_url' => apbct_get_server_variable( 'HTTP_REFERER' ), // Page URL must be an previous page
73
+ ),
74
+ ),
75
+ isset( $data['register'] ) ? true : false
76
+ );
77
+
78
+ $ct_result = $base_call_result['ct_result'];
79
+
80
+ $cleantalk_executed = true;
81
+
82
+ if ($ct_result->allow == 0) {
83
+ // Do blocking if it is a spam
84
+ $this->integration->doBlock( $ct_result->comment );
85
+ }
86
+ } else {
87
+ // @ToDo have to handle an error
88
+ return;
89
+ }
90
+ }
91
+ }
92
+ }
93
+
94
+ private function get_current_integration_triggered( $hook )
95
+ {
96
+ if( $hook !== false ) {
97
+ foreach( $this->integrations as $integration_name => $integration_info ) {
98
+ if( is_array( $integration_info['hook'] ) ) {
99
+ foreach( $integration_info['hook'] as $integration_hook ) {
100
+ if( strpos( $hook, $integration_hook ) !== false ) {
101
+ return $integration_name;
102
+ }
103
+ }
104
+ } else {
105
+ if( strpos( $hook, $integration_info['hook'] ) !== false ) {
106
+ return $integration_name;
107
+ }
108
+ }
109
+ }
110
+ }
111
+ return false;
112
+ }
113
  }
lib/Cleantalk/Antispam/Integrations/ContactBank.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
-
3
-
4
- namespace Cleantalk\Antispam\Integrations;
5
-
6
-
7
- class ContactBank extends IntegrationBase
8
- {
9
-
10
- function getDataForChecking( $argument )
11
- {
12
- if( isset( $_REQUEST['param'] ) ) {
13
- parse_str( isset( $_REQUEST['data'] ) ? base64_decode( $_REQUEST['data'] ) : '', $form_data );
14
- return ct_get_fields_any($form_data);
15
- }
16
- return null;
17
- }
18
-
19
- function doBlock( $message )
20
- {
21
- die(json_encode(array('apbct' => array('blocked' => true, 'comment' => $message,)), JSON_HEX_QUOT | JSON_HEX_TAG));
22
- }
23
  }
1
+ <?php
2
+
3
+
4
+ namespace Cleantalk\Antispam\Integrations;
5
+
6
+
7
+ class ContactBank extends IntegrationBase
8
+ {
9
+
10
+ function getDataForChecking( $argument )
11
+ {
12
+ if( isset( $_REQUEST['param'] ) ) {
13
+ parse_str( isset( $_REQUEST['data'] ) ? base64_decode( $_REQUEST['data'] ) : '', $form_data );
14
+ return ct_get_fields_any($form_data);
15
+ }
16
+ return null;
17
+ }
18
+
19
+ function doBlock( $message )
20
+ {
21
+ die(json_encode(array('apbct' => array('blocked' => true, 'comment' => $message,)), JSON_HEX_QUOT | JSON_HEX_TAG));
22
+ }
23
  }
lib/Cleantalk/Antispam/Integrations/FluentForm.php CHANGED
@@ -1,31 +1,31 @@
1
- <?php
2
-
3
-
4
- namespace Cleantalk\Antispam\Integrations;
5
-
6
-
7
- class FluentForm extends IntegrationBase
8
- {
9
-
10
- function getDataForChecking( $argument )
11
- {
12
- if( isset( $_POST['data'] ) ) {
13
- parse_str( $_POST['data'], $form_data );
14
- return ct_get_fields_any($form_data);
15
- }
16
- return null;
17
- }
18
-
19
- function doBlock($message)
20
- {
21
- wp_send_json(
22
- array(
23
- 'errors' => array(
24
- 'restricted' => array(
25
- $message
26
- )
27
- )
28
- ), 422
29
- );
30
- }
31
  }
1
+ <?php
2
+
3
+
4
+ namespace Cleantalk\Antispam\Integrations;
5
+
6
+
7
+ class FluentForm extends IntegrationBase
8
+ {
9
+
10
+ function getDataForChecking( $argument )
11
+ {
12
+ if( isset( $_POST['data'] ) ) {
13
+ parse_str( $_POST['data'], $form_data );
14
+ return ct_get_fields_any($form_data);
15
+ }
16
+ return null;
17
+ }
18
+
19
+ function doBlock($message)
20
+ {
21
+ wp_send_json(
22
+ array(
23
+ 'errors' => array(
24
+ 'restricted' => array(
25
+ $message
26
+ )
27
+ )
28
+ ), 422
29
+ );
30
+ }
31
  }
lib/Cleantalk/Antispam/Integrations/IntegrationBase.php CHANGED
@@ -1,11 +1,11 @@
1
- <?php
2
-
3
-
4
- namespace Cleantalk\Antispam\Integrations;
5
-
6
-
7
- abstract class IntegrationBase
8
- {
9
- abstract function getDataForChecking( $argument );
10
- abstract function doBlock( $message );
11
  }
1
+ <?php
2
+
3
+
4
+ namespace Cleantalk\Antispam\Integrations;
5
+
6
+
7
+ abstract class IntegrationBase
8
+ {
9
+ abstract function getDataForChecking( $argument );
10
+ abstract function doBlock( $message );
11
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: spam, antispam, anti-spam, comments, firewall
4
  Requires at least: 3.0
5
  Tested up to: 5.7
6
  Requires PHP: 5.4
7
- Stable tag: 5.157.1
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
@@ -580,6 +580,11 @@ If your website has forms that send data to external sources, you can enable opt
580
 
581
  == Changelog ==
582
 
 
 
 
 
 
583
  = 5.157.1 Apr 29 2021 =
584
  * Mod: \Cleantalk\ApbctWP\Variables\Cookie::get() now has 'cast_to' param. If defined trying to cast to a given type.
585
  * Fix: \Cleantalk\ApbctWP\Variables\Cookie::get() calls using 'cast_to' param if needed.
4
  Requires at least: 3.0
5
  Tested up to: 5.7
6
  Requires PHP: 5.4
7
+ Stable tag: 5.157.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.157.2 May 05 2021 =
584
+ * Fix: Code. get_fields_any() notice fixed.
585
+ * Fix: Integration. Gravity Forms integration fixed.
586
+ * Fix: Forms. Nicknames detecting fixed.
587
+
588
  = 5.157.1 Apr 29 2021 =
589
  * Mod: \Cleantalk\ApbctWP\Variables\Cookie::get() now has 'cast_to' param. If defined trying to cast to a given type.
590
  * Fix: \Cleantalk\ApbctWP\Variables\Cookie::get() calls using 'cast_to' param if needed.