Spam protection, AntiSpam, FireWall by CleanTalk - Version 2.23

Version Description

2013-11-20 = * New: Added automatic training blacklists on spam bot account deletion. * New: Added URL to project homepage at plugin options. * Changed: Improved antispam logic.

Download this release

Release Info

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

Code changes from version 2.21 to 2.23

Files changed (3) hide show
  1. cleantalk.php +106 -27
  2. i18n/cleantalk-ru_RU.mo +0 -0
  3. readme.txt +12 -2
cleantalk.php CHANGED
@@ -3,35 +3,38 @@
3
  Plugin Name: Anti-spam by CleanTalk
4
  Plugin URI: http://cleantalk.org/wordpress
5
  Description: Invisible antispam for comments, registrations and feedbacks. The plugin doesn't use CAPTCHA, Q&A, math or quiz to stop spam bots.
6
- Version: 2.21
7
  Author: СleanTalk <welcome@cleantalk.ru>
8
  Author URI: http://cleantalk.org
9
  */
10
 
11
- $ct_agent_version = 'wordpress-221';
12
  $ct_checkjs_frm = 'ct_checkjs_frm';
13
  $ct_checkjs_register_form = 'ct_checkjs_register_form';
 
14
 
15
  add_action('comment_form', 'ct_add_hidden_fields');
16
- add_action('parse_request', 'ct_set_session');
17
- add_action('admin_notices', 'admin_notice_message');
18
  add_filter('preprocess_comment', 'ct_check'); // param - comment data array
19
  add_action('frm_validate_entry', 'ct_frm_validate_entry', 20, 2);
20
  add_action('frm_entries_footer_scripts', 'ct_frm_entries_footer_scripts', 20, 2);
21
 
22
  add_action('register_form','ct_register_form');
23
  add_filter('registration_errors', 'ct_registration_errors', 10, 3);
 
24
 
25
  if (is_admin()) {
26
  add_action('admin_init', 'ct_admin_init', 1);
27
  add_action('admin_menu', 'ct_admin_add_page');
28
  add_action('admin_enqueue_scripts', 'ct_enqueue_scripts');
 
29
  add_action('comment_unapproved_to_approved', 'ct_comment_approved'); // param - comment object
30
  add_action('comment_approved_to_unapproved', 'ct_comment_unapproved'); // param - comment object
31
  add_action('comment_unapproved_to_spam', 'ct_comment_spam'); // param - comment object
32
  add_action('comment_approved_to_spam', 'ct_comment_spam'); // param - comment object
33
  add_filter('get_comment_text', 'ct_get_comment_text'); // param - current comment text
34
  add_filter('unspam_comment', 'ct_unspam_comment');
 
 
35
  }
36
 
37
  /**
@@ -87,7 +90,7 @@ function ct_hash($new_hash = '') {
87
  * @param int $allow flag good comment (1) or bad (0)
88
  * @return string comment_content w\o cleantalk resume
89
  */
90
- function ct_feedback($hash, $message, $allow) {
91
 
92
  require_once('cleantalk.class.php');
93
  $options = ct_get_options();
@@ -103,7 +106,9 @@ function ct_feedback($hash, $message, $allow) {
103
  if (empty($hash)) {
104
  $hash = $ct->getCleantalkCommentHash($message);
105
  }
106
- $resultMessage = $ct->delCleantalkComment($message);
 
 
107
 
108
  $ct_feedback = $hash . ':' . $allow . ';';
109
  if (empty($_SESSION['feedback_request'])) {
@@ -193,6 +198,9 @@ function ct_add_hidden_fields($post_id = 0, $field_name = 'ct_checkjs') {
193
  return false;
194
  }
195
 
 
 
 
196
  ?>
197
  <input type="hidden" id="<?php echo $field_name; ?>" name="<?php echo $field_name; ?>" value="0">
198
  <script type="text/javascript">
@@ -203,21 +211,6 @@ function ct_add_hidden_fields($post_id = 0, $field_name = 'ct_checkjs') {
203
  <?php
204
  }
205
 
206
- /**
207
- * Public action 'parse_request' - Inits session value
208
- */
209
- function ct_set_session() {
210
-
211
- $options = ct_get_options();
212
- if (ct_is_user_enable() === false || $options['comments_test'] == 0) {
213
- return false;
214
- }
215
- // this action is called any time WP process GET request (shows any page)
216
- // this action is called AFTER wp-comments-post.php executing and AFTER ct_check calling so we can create new session value here
217
- // it can be any action between init and send_headers, see http://codex.wordpress.org/Plugin_API/Action_Reference
218
-
219
- }
220
-
221
  /**
222
  * Is enable for user group
223
  * @return boolean
@@ -392,6 +385,13 @@ function ct_check($comment) {
392
  $post = get_post($comment_post_id);
393
 
394
  $checkjs = js_test('ct_checkjs');
 
 
 
 
 
 
 
395
 
396
  $example = null;
397
  if (function_exists('json_encode')) {
@@ -455,6 +455,7 @@ function ct_check($comment) {
455
  $ct_request->agent = $ct_agent_version;
456
  $ct_request->sender_info = $user_info;
457
  $ct_request->js_on = $checkjs;
 
458
  $ct_request->post_info = $post_info;
459
 
460
  $ct_result = $ct->isAllowMessage($ct_request);
@@ -481,7 +482,12 @@ function ct_check($comment) {
481
  if ($ct_result->spam == 1) {
482
  $comment['comment_content'] = $ct->addCleantalkComment($comment['comment_content'], $ct_result->comment);
483
  add_filter('pre_comment_approved', 'ct_set_comment_spam');
 
 
 
 
484
  add_action('comment_post', 'ct_set_meta', 10, 2);
 
485
  return $comment;
486
  }
487
 
@@ -512,6 +518,20 @@ function ct_check($comment) {
512
  return $comment;
513
  }
514
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
515
  /**
516
  *
517
  *
@@ -727,8 +747,9 @@ function admin_notice_message(){
727
  return false;
728
 
729
  $options = ct_get_options();
730
- if ($options['apikey'] === 'enter key' || $options['apikey'] === '')
731
- echo '<div class="updated"><p>' . __("Please enter the Access Key in <a href=\"options-general.php?page=cleantalk\">CleanTalk plugin</a> settings to enable protection from spam in comments!", 'cleantalk') . '</p></div>';
 
732
 
733
  ct_send_feedback();
734
 
@@ -746,6 +767,18 @@ function admin_addDescriptionsFields($descr = '') {
746
  echo "<p style='color: #666 !important'>$descr</p>";
747
  }
748
 
 
 
 
 
 
 
 
 
 
 
 
 
749
  /**
750
  * Tests plugin activation status
751
  * @return bool
@@ -819,7 +852,7 @@ function ct_register_form() {
819
  * @return array with errors
820
  */
821
  function ct_registration_errors($errors, $sanitized_user_login, $user_email) {
822
- global $ct_agent_version, $ct_checkjs_register_form;
823
 
824
  $options = ct_get_options();
825
  if ($options['registrations_test'] == 0) {
@@ -871,14 +904,47 @@ function ct_registration_errors($errors, $sanitized_user_login, $user_email) {
871
  );
872
  }
873
 
874
- if ($ct_result->errno == 0 && $ct_result->allow == 0) {
 
 
 
 
875
  $wordpress_domain = preg_replace("/^https?:\/\//", "", site_url());
876
  $errors->add('ct_error', __($ct_result->comment, $wordpress_domain));
 
 
 
 
 
877
  }
878
 
879
  return $errors;
880
  }
881
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
882
 
883
  /**
884
  * Admin action 'admin_enqueue_scripts' - Enqueue admin script of reloading admin page after needed AJAX events
@@ -967,7 +1033,9 @@ function ct_input_apikey() {
967
 
968
  $def_value = '';
969
  echo "<input id='cleantalk_apikey' name='cleantalk_settings[apikey]' size='10' type='text' value='$value' />";
970
- echo "<a target='__blank' style='margin-left: 10px' href='http://cleantalk.org/install/wordpress?step=2'>".__('Click here to get access key', 'cleantalk')."</a>";
 
 
971
  }
972
 
973
  /**
@@ -1026,8 +1094,19 @@ function ct_settings_page() {
1026
  <br>
1027
  <br>
1028
  <input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes'); ?>" />
1029
- </form></div>
 
 
1030
 
 
 
 
 
 
 
 
 
 
1031
  <?php
1032
  }
1033
 
3
  Plugin Name: Anti-spam by CleanTalk
4
  Plugin URI: http://cleantalk.org/wordpress
5
  Description: Invisible antispam for comments, registrations and feedbacks. The plugin doesn't use CAPTCHA, Q&A, math or quiz to stop spam bots.
6
+ Version: 2.23
7
  Author: СleanTalk <welcome@cleantalk.ru>
8
  Author URI: http://cleantalk.org
9
  */
10
 
11
+ $ct_agent_version = 'wordpress-222';
12
  $ct_checkjs_frm = 'ct_checkjs_frm';
13
  $ct_checkjs_register_form = 'ct_checkjs_register_form';
14
+ $ct_session_request_id_label = 'request_id';
15
 
16
  add_action('comment_form', 'ct_add_hidden_fields');
 
 
17
  add_filter('preprocess_comment', 'ct_check'); // param - comment data array
18
  add_action('frm_validate_entry', 'ct_frm_validate_entry', 20, 2);
19
  add_action('frm_entries_footer_scripts', 'ct_frm_entries_footer_scripts', 20, 2);
20
 
21
  add_action('register_form','ct_register_form');
22
  add_filter('registration_errors', 'ct_registration_errors', 10, 3);
23
+ add_action('user_register', 'ct_user_register');
24
 
25
  if (is_admin()) {
26
  add_action('admin_init', 'ct_admin_init', 1);
27
  add_action('admin_menu', 'ct_admin_add_page');
28
  add_action('admin_enqueue_scripts', 'ct_enqueue_scripts');
29
+ add_action('admin_notices', 'admin_notice_message');
30
  add_action('comment_unapproved_to_approved', 'ct_comment_approved'); // param - comment object
31
  add_action('comment_approved_to_unapproved', 'ct_comment_unapproved'); // param - comment object
32
  add_action('comment_unapproved_to_spam', 'ct_comment_spam'); // param - comment object
33
  add_action('comment_approved_to_spam', 'ct_comment_spam'); // param - comment object
34
  add_filter('get_comment_text', 'ct_get_comment_text'); // param - current comment text
35
  add_filter('unspam_comment', 'ct_unspam_comment');
36
+
37
+ add_action('delete_user', 'ct_delete_user');
38
  }
39
 
40
  /**
90
  * @param int $allow flag good comment (1) or bad (0)
91
  * @return string comment_content w\o cleantalk resume
92
  */
93
+ function ct_feedback($hash, $message = null, $allow) {
94
 
95
  require_once('cleantalk.class.php');
96
  $options = ct_get_options();
106
  if (empty($hash)) {
107
  $hash = $ct->getCleantalkCommentHash($message);
108
  }
109
+ if ($message !== null) {
110
+ $resultMessage = $ct->delCleantalkComment($message);
111
+ }
112
 
113
  $ct_feedback = $hash . ':' . $allow . ';';
114
  if (empty($_SESSION['feedback_request'])) {
198
  return false;
199
  }
200
 
201
+ ct_init_session();
202
+ $_SESSION['formtime'] = time();
203
+
204
  ?>
205
  <input type="hidden" id="<?php echo $field_name; ?>" name="<?php echo $field_name; ?>" value="0">
206
  <script type="text/javascript">
211
  <?php
212
  }
213
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  /**
215
  * Is enable for user group
216
  * @return boolean
385
  $post = get_post($comment_post_id);
386
 
387
  $checkjs = js_test('ct_checkjs');
388
+
389
+ ct_init_session();
390
+ if (array_key_exists('formtime', $_SESSION)) {
391
+ $submit_time = time() - (int) $_SESSION['formtime'];
392
+ } else {
393
+ $submit_time = null;
394
+ }
395
 
396
  $example = null;
397
  if (function_exists('json_encode')) {
455
  $ct_request->agent = $ct_agent_version;
456
  $ct_request->sender_info = $user_info;
457
  $ct_request->js_on = $checkjs;
458
+ $ct_request->submit_time = $submit_time;
459
  $ct_request->post_info = $post_info;
460
 
461
  $ct_result = $ct->isAllowMessage($ct_request);
482
  if ($ct_result->spam == 1) {
483
  $comment['comment_content'] = $ct->addCleantalkComment($comment['comment_content'], $ct_result->comment);
484
  add_filter('pre_comment_approved', 'ct_set_comment_spam');
485
+
486
+ global $ct_comment;
487
+ $ct_comment = $ct_result->comment;
488
+ add_action('comment_post', 'ct_die', 12, 2);
489
  add_action('comment_post', 'ct_set_meta', 10, 2);
490
+
491
  return $comment;
492
  }
493
 
518
  return $comment;
519
  }
520
 
521
+ /**
522
+ * Set die page with Cleantalk comment.
523
+ * @global type $ct_comment
524
+ $err_text = '<center><b style="color: #49C73B;">Clean</b><b style="color: #349ebf;">Talk.</b> ' . __('Spam protection', 'cleantalk') . "</center><br><br>\n" . $ct_comment;
525
+ * @param type $comment_status
526
+ */
527
+ function ct_die($comment_id, $comment_status) {
528
+ global $ct_comment;
529
+ $err_text = '<center><b style="color: #49C73B;">Clean</b><b style="color: #349ebf;">Talk.</b> ' . __('Spam protection', 'cleantalk') . "</center><br><br>\n" . $ct_comment;
530
+ $err_text .= '<script>setTimeout("history.back()", 5000);</script>';
531
+ wp_die($err_text, 'Blacklisted', array('back_link' => true));
532
+ }
533
+
534
+
535
  /**
536
  *
537
  *
747
  return false;
748
 
749
  $options = ct_get_options();
750
+ if (ct_valid_key($options['apikey']) === false) {
751
+ echo '<div class="updated"><p>' . __("Please enter the Access Key in <a href=\"options-general.php?page=cleantalk\">CleanTalk plugin</a> settings to enable protection from spam in comments!", 'cleantalk') . '</p></div>';
752
+ }
753
 
754
  ct_send_feedback();
755
 
767
  echo "<p style='color: #666 !important'>$descr</p>";
768
  }
769
 
770
+ /**
771
+ * Test API key
772
+ */
773
+ function ct_valid_key($apikey = null) {
774
+ if ($apikey === null) {
775
+ $options = ct_get_options();
776
+ $apikey = $options['apikey'];
777
+ }
778
+
779
+ return ($apikey === 'enter key' || $apikey === '') ? false : true;
780
+ }
781
+
782
  /**
783
  * Tests plugin activation status
784
  * @return bool
852
  * @return array with errors
853
  */
854
  function ct_registration_errors($errors, $sanitized_user_login, $user_email) {
855
+ global $ct_agent_version, $ct_checkjs_register_form, $ct_session_request_id_label;
856
 
857
  $options = ct_get_options();
858
  if ($options['registrations_test'] == 0) {
904
  );
905
  }
906
 
907
+ if ($ct_result->errno != 0) {
908
+ return $errors;
909
+ }
910
+
911
+ if ($ct_result->allow == 0) {
912
  $wordpress_domain = preg_replace("/^https?:\/\//", "", site_url());
913
  $errors->add('ct_error', __($ct_result->comment, $wordpress_domain));
914
+ } else {
915
+ if ($ct_result->id !== null) {
916
+ ct_init_session();
917
+ $_SESSION[$ct_session_request_id_label] = $ct_result->id;
918
+ }
919
  }
920
 
921
  return $errors;
922
  }
923
 
924
+ /**
925
+ * Set user meta
926
+ * @return null
927
+ */
928
+ function ct_user_register($user_id) {
929
+ global $ct_session_request_id_label;
930
+
931
+ if (isset($_SESSION[$ct_session_request_id_label])) {
932
+ update_user_meta($user_id, 'ct_hash', $_SESSION[$ct_session_request_id_label]);
933
+ unset($_SESSION[$ct_session_request_id_label]);
934
+ }
935
+ }
936
+
937
+ /**
938
+ * Send feedback for user deletion
939
+ * @return null
940
+ */
941
+ function ct_delete_user($user_id) {
942
+ $hash = get_user_meta($user_id, 'ct_hash', true);
943
+ if ($hash !== '') {
944
+ ct_feedback($hash, null, 0);
945
+ }
946
+ }
947
+
948
 
949
  /**
950
  * Admin action 'admin_enqueue_scripts' - Enqueue admin script of reloading admin page after needed AJAX events
1033
 
1034
  $def_value = '';
1035
  echo "<input id='cleantalk_apikey' name='cleantalk_settings[apikey]' size='10' type='text' value='$value' />";
1036
+ if (ct_valid_key($value) === false) {
1037
+ echo "<a target='__blank' style='margin-left: 10px' href='http://cleantalk.org/install/wordpress?step=2'>".__('Click here to get access key', 'cleantalk')."</a>";
1038
+ }
1039
  }
1040
 
1041
  /**
1094
  <br>
1095
  <br>
1096
  <input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes'); ?>" />
1097
+ </form>
1098
+ </div>
1099
+ <?php
1100
 
1101
+ if (ct_valid_key() === false)
1102
+ return null;
1103
+ ?>
1104
+ <br />
1105
+ <br />
1106
+ <br />
1107
+ <div>
1108
+ <?php echo __('Plugin Homepage at', 'cleantalk'); ?> <a href="http://cleantalk.org" target="_blank">cleantalk.org</a>.
1109
+ </div>
1110
  <?php
1111
  }
1112
 
i18n/cleantalk-ru_RU.mo CHANGED
Binary file
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: znaeff, shagimuratov
3
  Tags: spam, antispam, anti-spam, spambot, spam-bot, stop spam, spammers, spamfree, captcha, capcha, captha, catcha, recaptcha, comment, comments, math, cloud, blacklist, puzzle, wpmu, network, multisite, akismet, спам, 垃圾邮件, correo no deseado, forms, formidable forms, feedback, registration
4
  Requires at least: 3.0
5
  Tested up to: 3.7.1
6
- Stable tag: 2.21
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -21,7 +21,7 @@ Plugin filters spam bots in the comments, spam moves to trash. The plugin is not
21
 
22
  Also every comment from a new author plugin compares with post and previous comments. If the relevance of the comment is good enough it gets approval at the blog without manual approval.
23
 
24
- The plugin is a client application for anti-spam cloud service <a href="http://cleantalk.org" target="_blank">cleantalk.org</a>. CleanTalk.org daily prevents from spam 4 500 blogs, blocks up to 400 000 spam bots attacks and approves up to 2 000 not spam comments.
25
 
26
  The plugin is WordPress MultiUser (WPMU or WordPress network) compatible. Each blog in multisite environment has individual anitspam options for spam bots protection.
27
 
@@ -87,6 +87,11 @@ Use other antispam plugins not necessarily, because CleanTalk stops 99.99% of sp
87
 
88
  == Changelog ==
89
 
 
 
 
 
 
90
  = 2.21 2013-11-13 =
91
  * Changed: WordPress blacklists settings get priority over plugin's antispam settings
92
  * Changed: Disabled management approval comments for regular commentators of the blog. Automatically approved for publication only the comments of the new blog authors.
@@ -209,6 +214,11 @@ Use other antispam plugins not necessarily, because CleanTalk stops 99.99% of sp
209
  * First version
210
 
211
  == Upgrade Notice ==
 
 
 
 
 
212
  = 2.21 2013-11-13 =
213
  * Changed: WordPress blacklists settings get priority over plugin's antispam settings
214
  * Changed: Disabled management approval comments for regular commentators of the blog. Automatically approved for publication only the comments of the new blog authors.
3
  Tags: spam, antispam, anti-spam, spambot, spam-bot, stop spam, spammers, spamfree, captcha, capcha, captha, catcha, recaptcha, comment, comments, math, cloud, blacklist, puzzle, wpmu, network, multisite, akismet, спам, 垃圾邮件, correo no deseado, forms, formidable forms, feedback, registration
4
  Requires at least: 3.0
5
  Tested up to: 3.7.1
6
+ Stable tag: 2.23
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
21
 
22
  Also every comment from a new author plugin compares with post and previous comments. If the relevance of the comment is good enough it gets approval at the blog without manual approval.
23
 
24
+ The plugin is a client application for anti-spam cloud service <a href="http://cleantalk.org" target="_blank">cleantalk.org</a>. CleanTalk.org daily prevents from spam 5000 blogs, blocks up to 400 000 spam bots attacks and approves up to 4000 not spam comments.
25
 
26
  The plugin is WordPress MultiUser (WPMU or WordPress network) compatible. Each blog in multisite environment has individual anitspam options for spam bots protection.
27
 
87
 
88
  == Changelog ==
89
 
90
+ = 2.23 2013-11-20 =
91
+ * New: Added automatic training blacklists on spam bot account deletion.
92
+ * New: Added URL to project homepage at plugin options.
93
+ * Changed: Improved antispam logic.
94
+
95
  = 2.21 2013-11-13 =
96
  * Changed: WordPress blacklists settings get priority over plugin's antispam settings
97
  * Changed: Disabled management approval comments for regular commentators of the blog. Automatically approved for publication only the comments of the new blog authors.
214
  * First version
215
 
216
  == Upgrade Notice ==
217
+ = 2.23 2013-11-20 =
218
+ * New: Added automatic training blacklists on spam bot account deletion.
219
+ * New: Added URL to project homepage at plugin options.
220
+ * Changed: Improved antispam logic.
221
+
222
  = 2.21 2013-11-13 =
223
  * Changed: WordPress blacklists settings get priority over plugin's antispam settings
224
  * Changed: Disabled management approval comments for regular commentators of the blog. Automatically approved for publication only the comments of the new blog authors.