Anti-spam - Version 2.4

Version Description

  • 2014-11-25 =
  • update input names
Download this release

Release Info

Developer webvitaly
Plugin Icon 128x128 Anti-spam
Version 2.4
Comparing to
See all releases

Code changes from version 2.3 to 2.4

Files changed (3) hide show
  1. anti-spam.php +13 -13
  2. js/anti-spam.js +10 -10
  3. readme.txt +4 -1
anti-spam.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Anti-spam
4
  Plugin URI: http://wordpress.org/plugins/anti-spam/
5
  Description: No spam in comments. No captcha.
6
- Version: 2.3
7
  Author: webvitaly
8
  Author URI: http://web-profile.com.ua/wordpress/plugins/
9
  License: GPLv3
@@ -15,7 +15,7 @@ $antispam_allow_trackbacks = false; // if true, than trackbacks will be allowed
15
  // trackbacks almost not used by users, but mostly used by spammers; pingbacks are always enabled
16
  // more about the difference between trackback and pingback - http://web-profile.com.ua/web/trackback-vs-pingback/
17
 
18
- $antispam_version = '2.3';
19
 
20
 
21
  if ( ! function_exists('antispam_enqueue_script') ) :
@@ -33,15 +33,15 @@ if ( ! function_exists('antispam_form_part') ) :
33
  function antispam_form_part() {
34
  global $antispam_version;
35
  if ( ! is_user_logged_in() ) { // add anti-spam fields only for not logged in users
36
- echo '<p class="comment-form-ant-spm" style="clear:both;">
37
  <strong>Current ye@r</strong> <span class="required">*</span>
38
- <input type="hidden" name="ant-spm-a" id="ant-spm-a" value="'.date('Y').'" />
39
- <input type="text" name="ant-spm-q" id="ant-spm-q" size="30" value="'.$antispam_version.'" />
40
  </p>'; // question (hidden with js) [required="required"]
41
 
42
- echo '<p class="comment-form-ant-spm-2" style="display:none;">
43
  <strong>Leave this field empty</strong>
44
- <input type="text" name="ant-spm-e-email-url" id="ant-spm-e-email-url" size="30" value="" />
45
  </p>'; // empty field (hidden with css)
46
  }
47
  }
@@ -95,18 +95,18 @@ if ( ! function_exists('antispam_check_comment') ) :
95
  if ( ! is_user_logged_in() && $comment_type != 'pingback' && $comment_type != 'trackback' ) { // logged in user is not a spammer
96
  $spam_flag = false;
97
 
98
- if ( array_key_exists('ant-spm-q', $_POST) && trim($_POST['ant-spm-q']) != date('Y') ) { // answer is wrong - maybe spam
99
  $spam_flag = true;
100
- if ( empty( $_POST['ant-spm-q'] ) ) { // empty answer - maybe spam
101
- $antispam_error_message .= 'Error: empty answer. ['.$_POST['ant-spm-q'].']<br> ';
102
  } else {
103
- $antispam_error_message .= 'Error: answer is wrong. ['.$_POST['ant-spm-q'].']<br> ';
104
  }
105
  }
106
 
107
- if ( ! empty( $_POST['ant-spm-e-email-url'] ) ) { // field is not empty - maybe spam
108
  $spam_flag = true;
109
- $antispam_error_message .= 'Error: field should be empty. ['.$_POST['ant-spm-e-email-url'].']<br> ';
110
  }
111
 
112
  if ( $spam_flag ) { // if we have spam
3
  Plugin Name: Anti-spam
4
  Plugin URI: http://wordpress.org/plugins/anti-spam/
5
  Description: No spam in comments. No captcha.
6
+ Version: 2.4
7
  Author: webvitaly
8
  Author URI: http://web-profile.com.ua/wordpress/plugins/
9
  License: GPLv3
15
  // trackbacks almost not used by users, but mostly used by spammers; pingbacks are always enabled
16
  // more about the difference between trackback and pingback - http://web-profile.com.ua/web/trackback-vs-pingback/
17
 
18
+ $antispam_version = '2.4';
19
 
20
 
21
  if ( ! function_exists('antispam_enqueue_script') ) :
33
  function antispam_form_part() {
34
  global $antispam_version;
35
  if ( ! is_user_logged_in() ) { // add anti-spam fields only for not logged in users
36
+ echo '<p class="comment-form-antspm" style="clear: both;">
37
  <strong>Current ye@r</strong> <span class="required">*</span>
38
+ <input type="hidden" name="antspm-a" class="antspm-a" value="'.date('Y').'" />
39
+ <input type="text" name="antspm-q" class="antspm-q" value="'.$antispam_version.'" />
40
  </p>'; // question (hidden with js) [required="required"]
41
 
42
+ echo '<p class="comment-form-antspm-2" style="display: none;">
43
  <strong>Leave this field empty</strong>
44
+ <input type="text" name="antspm-e-email-url" class="antspm-e-email-url" value="" />
45
  </p>'; // empty field (hidden with css)
46
  }
47
  }
95
  if ( ! is_user_logged_in() && $comment_type != 'pingback' && $comment_type != 'trackback' ) { // logged in user is not a spammer
96
  $spam_flag = false;
97
 
98
+ if ( array_key_exists('antspm-q', $_POST) && trim($_POST['antspm-q']) != date('Y') ) { // answer is wrong - maybe spam
99
  $spam_flag = true;
100
+ if ( empty( $_POST['antspm-q'] ) ) { // empty answer - maybe spam
101
+ $antispam_error_message .= 'Error: empty answer. ['.$_POST['antspm-q'].']<br> ';
102
  } else {
103
+ $antispam_error_message .= 'Error: answer is wrong. ['.$_POST['antspm-q'].']<br> ';
104
  }
105
  }
106
 
107
+ if ( ! empty( $_POST['antspm-e-email-url'] ) ) { // field is not empty - maybe spam
108
  $spam_flag = true;
109
+ $antispam_error_message .= 'Error: field should be empty. ['.$_POST['antspm-e-email-url'].']<br> ';
110
  }
111
 
112
  if ( $spam_flag ) { // if we have spam
js/anti-spam.js CHANGED
@@ -7,24 +7,24 @@ wordpress.org/plugins/anti-spam/
7
  (function($) {
8
 
9
  function anti_spam_init() {
10
- $('.comment-form-ant-spm, .comment-form-ant-spm-2').hide(); // hide inputs from users
11
- var answer = $('.comment-form-ant-spm input#ant-spm-a').val(); // get answer
12
- $('.comment-form-ant-spm input#ant-spm-q').val(answer); // set answer into other input instead of user
13
- $('.comment-form-ant-spm-2 input#ant-spm-e-email-url').val(''); // clear value of the empty input because some themes are adding some value for all inputs
14
 
15
  var current_date = new Date();
16
  var current_year = current_date.getFullYear();
17
 
18
- if ( $('#comments form input#ant-spm-q').length == 0 ) { // anti-spam input does not exist (could be because of cache or because theme does not use 'comment_form' action)
19
- $('#comments form').append('<input type="hidden" name="ant-spm-q" id="ant-spm-q" value="'+current_year+'" />'); // add whole input with answer via js to comment form
20
  }
21
 
22
- if ( $('#respond form input#ant-spm-q').length == 0 ) { // similar, just in case (used because user could bot have #comments)
23
- $('#respond form').append('<input type="hidden" name="ant-spm-q" id="ant-spm-q" value="'+current_year+'" />'); // add whole input with answer via js to comment form
24
  }
25
 
26
- if ( $('form#commentform input#ant-spm-q').length == 0 ) { // similar, just in case (used because user could bot have #respond)
27
- $('form#commentform').append('<input type="hidden" name="ant-spm-q" id="ant-spm-q" value="'+current_year+'" />'); // add whole input with answer via js to comment form
28
  }
29
  }
30
 
7
  (function($) {
8
 
9
  function anti_spam_init() {
10
+ $('.comment-form-antspm, .comment-form-antspm-2').hide(); // hide inputs from users
11
+ var answer = $('.comment-form-antspm input.antspm-a').val(); // get answer
12
+ $('.comment-form-antspm input.antspm-q').val(answer); // set answer into other input instead of user
13
+ $('.comment-form-antspm-2 input.antspm-e-email-url').val(''); // clear value of the empty input because some themes are adding some value for all inputs
14
 
15
  var current_date = new Date();
16
  var current_year = current_date.getFullYear();
17
 
18
+ if ( $('#comments form input.antspm-q').length == 0 ) { // anti-spam input does not exist (could be because of cache or because theme does not use 'comment_form' action)
19
+ $('#comments form').append('<input type="hidden" name="antspm-q" class="antspm-q" value="'+current_year+'" />'); // add whole input with answer via js to comment form
20
  }
21
 
22
+ if ( $('#respond form input.antspm-q').length == 0 ) { // similar, just in case (used because user could bot have #comments)
23
+ $('#respond form').append('<input type="hidden" name="antspm-q" class="antspm-q" value="'+current_year+'" />'); // add whole input with answer via js to comment form
24
  }
25
 
26
+ if ( $('form#commentform input.antspm-q').length == 0 ) { // similar, just in case (used because user could bot have #respond)
27
+ $('form#commentform').append('<input type="hidden" name="antspm-q" class="antspm-q" value="'+current_year+'" />'); // add whole input with answer via js to comment form
28
  }
29
  }
30
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://web-profile.com.ua/donate/
4
  Tags: spam, spammer, spammers, comment, comments, antispam, anti-spam, block-spam, spamfree, spam-free, spambot, spam-bot, bot
5
  Requires at least: 3.0
6
  Tested up to: 4.0
7
- Stable tag: 2.3
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
@@ -112,6 +112,9 @@ Do not order products from spam. If spam will be less effective than spammers wi
112
 
113
  == Changelog ==
114
 
 
 
 
115
  = 2.3 - 2014-11-23 =
116
  * enqueue script only for pages with comments form and in the footer (thanks to dougvdotcom)
117
  * clean up code
4
  Tags: spam, spammer, spammers, comment, comments, antispam, anti-spam, block-spam, spamfree, spam-free, spambot, spam-bot, bot
5
  Requires at least: 3.0
6
  Tested up to: 4.0
7
+ Stable tag: 2.4
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
112
 
113
  == Changelog ==
114
 
115
+ = 2.4 - 2014-11-25 =
116
+ * update input names
117
+
118
  = 2.3 - 2014-11-23 =
119
  * enqueue script only for pages with comments form and in the footer (thanks to dougvdotcom)
120
  * clean up code