Spam protection, AntiSpam, FireWall by CleanTalk - Version 4.16

Version Description

2015-02-05 = * New base class. * Fixed JetPack filters logics. * Optimized Formidable, bbPress, BuddyPress filters.

Download this release

Release Info

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

Code changes from version 4.15 to 4.16

Files changed (3) hide show
  1. cleantalk.class.php +11 -64
  2. cleantalk.php +24 -18
  3. readme.txt +10 -2
cleantalk.class.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Cleantalk base class
4
  *
5
- * @version 1.33
6
  * @package Cleantalk
7
  * @subpackage Base
8
  * @author Сleantalk team (welcome@cleantalk.org)
@@ -411,18 +411,7 @@ class Cleantalk {
411
  * @return type
412
  */
413
  public function isAllowMessage(CleantalkRequest $request) {
414
- $error_params = $this->filterRequest('check_message', $request);
415
-
416
- if (!empty($error_params)) {
417
- $response = new CleantalkResponse(
418
- array(
419
- 'allow' => 0,
420
- 'comment' => 'CleanTalk. Request params error: ' . implode(', ', $error_params)
421
- ), null);
422
-
423
- return $response;
424
- }
425
-
426
  $msg = $this->createMsg('check_message', $request);
427
  return $this->httpRequest($msg);
428
  }
@@ -433,18 +422,7 @@ class Cleantalk {
433
  * @return type
434
  */
435
  public function isAllowUser(CleantalkRequest $request) {
436
- $error_params = $this->filterRequest('check_newuser', $request);
437
-
438
- if (!empty($error_params)) {
439
- $response = new CleantalkResponse(
440
- array(
441
- 'allow' => 0,
442
- 'comment' => 'CleanTalk. Request params error: ' . implode(', ', $error_params)
443
- ), null);
444
-
445
- return $response;
446
- }
447
-
448
  $msg = $this->createMsg('check_newuser', $request);
449
  return $this->httpRequest($msg);
450
  }
@@ -456,20 +434,8 @@ class Cleantalk {
456
  * @return type
457
  */
458
  public function sendFeedback(CleantalkRequest $request) {
459
- $error_params = $this->filterRequest('send_feedback', $request);
460
-
461
- if (!empty($error_params)) {
462
- $response = new CleantalkResponse(
463
- array(
464
- 'allow' => 0,
465
- 'comment' => 'Cleantalk. Spam protect. Request params error: ' . implode(', ', $error_params)
466
- ), null);
467
-
468
- return $response;
469
- }
470
-
471
  $msg = $this->createMsg('send_feedback', $request);
472
-
473
  return $this->httpRequest($msg);
474
  }
475
 
@@ -478,65 +444,46 @@ class Cleantalk {
478
  * @param CleantalkRequest $request
479
  * @return type
480
  */
481
- private function filterRequest($method, CleantalkRequest $request) {
482
- $error_params = array();
483
-
484
  // general and optional
485
  foreach ($request as $param => $value) {
486
  if (in_array($param, array('message', 'example', 'agent',
487
  'sender_info', 'sender_nickname', 'post_info', 'phone')) && !empty($value)) {
488
  if (!is_string($value) && !is_integer($value)) {
489
- $error_params[] = $param;
490
  }
491
  }
492
 
493
  if (in_array($param, array('stoplist_check', 'allow_links')) && !empty($value)) {
494
  if (!in_array($value, array(1, 2))) {
495
- $error_params[] = $param;
496
  }
497
  }
498
 
499
  if (in_array($param, array('js_on')) && !empty($value)) {
500
  if (!is_integer($value)) {
501
- $error_params[] = $param;
502
  }
503
  }
504
 
505
  if ($param == 'sender_ip' && !empty($value)) {
506
  if (!is_string($value)) {
507
- $error_params[] = $param;
508
  }
509
  }
510
 
511
  if ($param == 'sender_email' && !empty($value)) {
512
  if (!is_string($value)) {
513
- $error_params[] = $param;
514
  }
515
  }
516
 
517
  if ($param == 'submit_time' && !empty($value)) {
518
  if (!is_int($value)) {
519
- $error_params[] = $param;
520
  }
521
  }
522
  }
523
-
524
- // special and must be
525
- switch ($method) {
526
- case 'check_message':
527
- break;
528
-
529
- case 'check_newuser':
530
- break;
531
-
532
- case 'send_feedback':
533
- if (empty($request->feedback)) {
534
- $error_params[] = 'feedback';
535
- }
536
- break;
537
- }
538
-
539
- return $error_params;
540
  }
541
 
542
  /**
2
  /**
3
  * Cleantalk base class
4
  *
5
+ * @version 1.34
6
  * @package Cleantalk
7
  * @subpackage Base
8
  * @author Сleantalk team (welcome@cleantalk.org)
411
  * @return type
412
  */
413
  public function isAllowMessage(CleantalkRequest $request) {
414
+ $this->filterRequest($request);
 
 
 
 
 
 
 
 
 
 
 
415
  $msg = $this->createMsg('check_message', $request);
416
  return $this->httpRequest($msg);
417
  }
422
  * @return type
423
  */
424
  public function isAllowUser(CleantalkRequest $request) {
425
+ $this->filterRequest($request);
 
 
 
 
 
 
 
 
 
 
 
426
  $msg = $this->createMsg('check_newuser', $request);
427
  return $this->httpRequest($msg);
428
  }
434
  * @return type
435
  */
436
  public function sendFeedback(CleantalkRequest $request) {
437
+ $this->filterRequest($request);
 
 
 
 
 
 
 
 
 
 
 
438
  $msg = $this->createMsg('send_feedback', $request);
 
439
  return $this->httpRequest($msg);
440
  }
441
 
444
  * @param CleantalkRequest $request
445
  * @return type
446
  */
447
+ private function filterRequest(CleantalkRequest &$request) {
 
 
448
  // general and optional
449
  foreach ($request as $param => $value) {
450
  if (in_array($param, array('message', 'example', 'agent',
451
  'sender_info', 'sender_nickname', 'post_info', 'phone')) && !empty($value)) {
452
  if (!is_string($value) && !is_integer($value)) {
453
+ $request->$param = NULL;
454
  }
455
  }
456
 
457
  if (in_array($param, array('stoplist_check', 'allow_links')) && !empty($value)) {
458
  if (!in_array($value, array(1, 2))) {
459
+ $request->$param = NULL;
460
  }
461
  }
462
 
463
  if (in_array($param, array('js_on')) && !empty($value)) {
464
  if (!is_integer($value)) {
465
+ $request->$param = NULL;
466
  }
467
  }
468
 
469
  if ($param == 'sender_ip' && !empty($value)) {
470
  if (!is_string($value)) {
471
+ $request->$param = NULL;
472
  }
473
  }
474
 
475
  if ($param == 'sender_email' && !empty($value)) {
476
  if (!is_string($value)) {
477
+ $request->$param = NULL;
478
  }
479
  }
480
 
481
  if ($param == 'submit_time' && !empty($value)) {
482
  if (!is_int($value)) {
483
+ $request->$param = NULL;
484
  }
485
  }
486
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
487
  }
488
 
489
  /**
cleantalk.php CHANGED
@@ -3,14 +3,14 @@
3
  Plugin Name: Anti-spam by CleanTalk
4
  Plugin URI: http://cleantalk.org
5
  Description: Max power, all-in-one, captcha less, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
6
- Version: 4.15
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
10
 
11
  define('CLEANTALK_PLUGIN_DIR', plugin_dir_path(__FILE__));
12
 
13
- $ct_agent_version = 'wordpress-415';
14
  $ct_plugin_name = 'Anti-spam by CleanTalk';
15
  $ct_checkjs_frm = 'ct_checkjs_frm';
16
  $ct_checkjs_register_form = 'ct_checkjs_register_form';
@@ -101,10 +101,6 @@ add_action( 'plugins_loaded', 'ct_plugin_loaded' );
101
  add_filter('preprocess_comment', 'ct_preprocess_comment', 1, 1); // param - comment data array
102
  add_filter('comment_text', 'ct_comment_text' );
103
 
104
- // Formidable
105
- add_action('frm_validate_entry', 'ct_frm_validate_entry', 20, 2);
106
- add_action('frm_entries_footer_scripts', 'ct_frm_entries_footer_scripts', 20, 2);
107
-
108
  // Registrations
109
  add_action('register_form','ct_register_form');
110
  add_filter('registration_errors', 'ct_registration_errors', 1, 3);
@@ -114,19 +110,9 @@ add_action('user_register', 'ct_user_register');
114
  add_action('signup_extra_fields','ct_register_form');
115
  add_filter('wpmu_validate_user_signup', 'ct_registration_errors_wpmu', 10, 3);
116
 
117
- // BuddyPress
118
- add_action('bp_before_registration_submit_buttons','ct_register_form');
119
- add_filter('bp_signup_validate', 'ct_registration_errors');
120
-
121
  // Login form - for notifications only
122
  add_filter('login_message', 'ct_login_message');
123
 
124
- // bbPress
125
- add_filter('bbp_new_topic_pre_content', 'ct_bbp_new_pre_content', 1);
126
- add_filter('bbp_new_reply_pre_content', 'ct_bbp_new_pre_content', 1);
127
- add_action('bbp_theme_before_topic_form_content', 'ct_comment_form');
128
- add_action('bbp_theme_before_reply_form_content', 'ct_comment_form');
129
-
130
  register_activation_hook( __FILE__, 'ct_activation' );
131
 
132
  /**
@@ -209,12 +195,12 @@ function ct_init() {
209
  // JetPack Contact form
210
  $jetpack_active_modules = false;
211
  if(defined('JETPACK__VERSION')){
 
 
212
  $jetpack_active_modules = get_option('jetpack_active_modules');
213
  if (
214
  (class_exists( 'Jetpack', false) && $jetpack_active_modules && in_array('comments', $jetpack_active_modules))
215
  ) {
216
- add_filter('grunion_contact_form_field_html', 'ct_grunion_contact_form_field_html', 10, 2);
217
- add_filter('contact_form_is_spam', 'ct_contact_form_is_spam');
218
  $ct_jp_comments = true;
219
  }
220
  }
@@ -229,6 +215,26 @@ function ct_init() {
229
  }
230
  }
231
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  add_action('comment_form', 'ct_comment_form');
233
 
234
  # if (
3
  Plugin Name: Anti-spam by CleanTalk
4
  Plugin URI: http://cleantalk.org
5
  Description: Max power, all-in-one, captcha less, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
6
+ Version: 4.16
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
10
 
11
  define('CLEANTALK_PLUGIN_DIR', plugin_dir_path(__FILE__));
12
 
13
+ $ct_agent_version = 'wordpress-416';
14
  $ct_plugin_name = 'Anti-spam by CleanTalk';
15
  $ct_checkjs_frm = 'ct_checkjs_frm';
16
  $ct_checkjs_register_form = 'ct_checkjs_register_form';
101
  add_filter('preprocess_comment', 'ct_preprocess_comment', 1, 1); // param - comment data array
102
  add_filter('comment_text', 'ct_comment_text' );
103
 
 
 
 
 
104
  // Registrations
105
  add_action('register_form','ct_register_form');
106
  add_filter('registration_errors', 'ct_registration_errors', 1, 3);
110
  add_action('signup_extra_fields','ct_register_form');
111
  add_filter('wpmu_validate_user_signup', 'ct_registration_errors_wpmu', 10, 3);
112
 
 
 
 
 
113
  // Login form - for notifications only
114
  add_filter('login_message', 'ct_login_message');
115
 
 
 
 
 
 
 
116
  register_activation_hook( __FILE__, 'ct_activation' );
117
 
118
  /**
195
  // JetPack Contact form
196
  $jetpack_active_modules = false;
197
  if(defined('JETPACK__VERSION')){
198
+ add_filter('grunion_contact_form_field_html', 'ct_grunion_contact_form_field_html', 10, 2);
199
+ add_filter('contact_form_is_spam', 'ct_contact_form_is_spam');
200
  $jetpack_active_modules = get_option('jetpack_active_modules');
201
  if (
202
  (class_exists( 'Jetpack', false) && $jetpack_active_modules && in_array('comments', $jetpack_active_modules))
203
  ) {
 
 
204
  $ct_jp_comments = true;
205
  }
206
  }
215
  }
216
  }
217
 
218
+ // Formidable
219
+ if(class_exists('FrmSettings')){
220
+ add_action('frm_validate_entry', 'ct_frm_validate_entry', 20, 2);
221
+ add_action('frm_entries_footer_scripts', 'ct_frm_entries_footer_scripts', 20, 2);
222
+ }
223
+
224
+ // BuddyPress
225
+ if(class_exists('BuddyPress')){
226
+ add_action('bp_before_registration_submit_buttons','ct_register_form');
227
+ add_filter('bp_signup_validate', 'ct_registration_errors');
228
+ }
229
+
230
+ // bbPress
231
+ if(class_exists('bbPress')){
232
+ add_filter('bbp_new_topic_pre_content', 'ct_bbp_new_pre_content', 1);
233
+ add_filter('bbp_new_reply_pre_content', 'ct_bbp_new_pre_content', 1);
234
+ add_action('bbp_theme_before_topic_form_content', 'ct_comment_form');
235
+ add_action('bbp_theme_before_reply_form_content', 'ct_comment_form');
236
+ }
237
+
238
  add_action('comment_form', 'ct_comment_form');
239
 
240
  # if (
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: znaeff, shagimuratov
3
  Tags: Akismet, anti spam, antispam, bbpress spam, buddypress spam, capcha, captcha antispam, cf7 spam, comments spam, contact form spam, fast secure contact form spam, form, Formidable spam, jetpack spam, landing pages, math, registration spam, s2member, signup spam, spam, spammers, spammy, WooCommerce spam, wordpress spam, booking spam, order spam, subscriptions spam, comments, gravity spam, gravity forms spam
4
  Requires at least: 3.0
5
  Tested up to: 4.1
6
- Stable tag: 4.15
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -171,12 +171,17 @@ WordPress 3.0 at least. PHP 4, 5 with CURL or file_get_contents() function and e
171
  1. Setup Android/iOS app to have push notices when new legitiamte comments/registrations or contactcs appears on the website.
172
 
173
  == Changelog ==
 
 
 
 
 
174
  = 4.15 2015-01-29 =
175
  * Support of Contact Form 7 versions before 3.0.0.
176
  * Fixed global JS-vars.
177
  * Fixed online notice cookie logics.
178
  * Optimized filters for FSCF, WooCommerce, JetPack.
179
- * Optomized option getting.
180
 
181
  = 4.14 2015-01-19 =
182
  * Removed deprecated option from comment approvement code.
@@ -488,6 +493,9 @@ WordPress 3.0 at least. PHP 4, 5 with CURL or file_get_contents() function and e
488
  * First version
489
 
490
  == Upgrade Notice ==
 
 
 
491
  = 4.15 2015-01-29 =
492
  Support of Contact Form 7 versions before 3.0.0, fixed global JS-vars and online notice cookie logics.
493
 
3
  Tags: Akismet, anti spam, antispam, bbpress spam, buddypress spam, capcha, captcha antispam, cf7 spam, comments spam, contact form spam, fast secure contact form spam, form, Formidable spam, jetpack spam, landing pages, math, registration spam, s2member, signup spam, spam, spammers, spammy, WooCommerce spam, wordpress spam, booking spam, order spam, subscriptions spam, comments, gravity spam, gravity forms spam
4
  Requires at least: 3.0
5
  Tested up to: 4.1
6
+ Stable tag: 4.16
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
171
  1. Setup Android/iOS app to have push notices when new legitiamte comments/registrations or contactcs appears on the website.
172
 
173
  == Changelog ==
174
+ = 4.16 2015-02-05 =
175
+ * New base class.
176
+ * Fixed JetPack filters logics.
177
+ * Optimized Formidable, bbPress, BuddyPress filters.
178
+
179
  = 4.15 2015-01-29 =
180
  * Support of Contact Form 7 versions before 3.0.0.
181
  * Fixed global JS-vars.
182
  * Fixed online notice cookie logics.
183
  * Optimized filters for FSCF, WooCommerce, JetPack.
184
+ * Optimized option getting.
185
 
186
  = 4.14 2015-01-19 =
187
  * Removed deprecated option from comment approvement code.
493
  * First version
494
 
495
  == Upgrade Notice ==
496
+ = 4.16 2015-06-05 =
497
+ New base class, fixed JetPack filters logics, optimized Formidable, bbPress, BuddyPress filters.
498
+
499
  = 4.15 2015-01-29 =
500
  Support of Contact Form 7 versions before 3.0.0, fixed global JS-vars and online notice cookie logics.
501