Version Description
- updated : set checkbox as descendant of label so users can click the label to tick the box (thanks Anthony T)
- updated : added a link back to the post with a query arg to fix pages that were expired and had old form fields on the die message
- updated : change refer check logic
- updated : add error codes to error messages
- updated : allow user to not use secret_key (set as no by default)
- fixed : max_mod kept reverting back to 3 due to get_options not saving version number
- updated : added warning message about clearing the cache if a user upgrades or changes settings and has a cache plugin installed
Download this release
Release Info
Developer | commentluv |
Plugin | Growmap Anti Spambot Plugin |
Version | 1.5.2 |
Comparing to | |
See all releases |
Code changes from version 1.5.1 to 1.5.2
- growmap-anti-spambot-plugin.php +48 -28
- readme.txt +15 -3
growmap-anti-spambot-plugin.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Growmap Anti Spambot Plugin
|
4 |
Plugin URI: http://www.growmap.com/growmap-anti-spambot-plugin/
|
5 |
Description: Very simple plugin that adds a client side generated checkbox to the comment form requesting that the user clicks it to prove they are not a spammer. Bots wont see it so their spam comment will be discarded.
|
6 |
-
Version: 1.5.
|
7 |
Author: Andy Bailey
|
8 |
Author URI: http://ComLuv.com
|
9 |
*/
|
@@ -92,7 +92,7 @@ function gasp_get_options(){
|
|
92 |
'checkbox_name' => $checkbox_name,
|
93 |
'secret_key' => COOKIEHASH.md5(home_url()),
|
94 |
'send_to' => 'spam',
|
95 |
-
'version' => '1.5'
|
96 |
);
|
97 |
$options = get_option('gasp_options',$default_options);
|
98 |
// update options with new defaults if upgrading from older version
|
@@ -118,9 +118,12 @@ function gasp_get_options(){
|
|
118 |
$options['secret_key'] = COOKIEHASH.md5(home_url());
|
119 |
update_option('gasp_options',$options);
|
120 |
}
|
121 |
-
if(version_compare($options['version'],'1.5.
|
|
|
122 |
$options['refer_check'] = 'yes';
|
|
|
123 |
$options['max_mod'] = 3;
|
|
|
124 |
}
|
125 |
return $options;
|
126 |
}
|
@@ -137,9 +140,11 @@ function gasp_options_sanitize($newoptions){
|
|
137 |
}
|
138 |
$secret_key = preg_replace('/[^a-zA-Z0-9]/','',$newoptions['secret_key']);
|
139 |
$newoptions['secret_key'] = $secret_key;
|
|
|
140 |
$newoptions['urls'] = (string)$urls;
|
141 |
$newoptions['name_words'] = (string)$name_words;
|
142 |
$newoptions['refer_check'] = $newoptions['refer_check'] == 'yes'? 'yes':'no';
|
|
|
143 |
return $newoptions;
|
144 |
}
|
145 |
|
@@ -163,38 +168,42 @@ function gasp_check_comment($commentdata){
|
|
163 |
if(is_user_logged_in()){
|
164 |
return $commentdata;
|
165 |
}
|
|
|
|
|
166 |
// referer check. make sure the page sending the comment is correct
|
167 |
-
//debugbreak();
|
168 |
if($options['refer_check'] != 'no'){
|
169 |
if(!isset($_SERVER['HTTP_REFERER'])){
|
170 |
update_option('gasp_count',get_option('gasp_count',true)+1);
|
171 |
-
wp_die($options['hidden_email_message']);
|
172 |
}
|
173 |
-
$refer = $_SERVER['HTTP_REFERER'];
|
174 |
-
$posturl = get_permalink($_POST['comment_post_ID']);
|
175 |
-
if(
|
176 |
update_option('gasp_count',get_option('gasp_count',true)+1);
|
177 |
-
wp_die($options['hidden_email_message']);
|
178 |
}
|
179 |
}
|
180 |
|
181 |
// checkbox check
|
182 |
if(!isset($_POST[$options['checkbox_name']])){
|
183 |
-
wp_die($options['no_checkbox_message']);
|
184 |
} elseif (isset($_POST['gasp_email']) && $_POST['gasp_email'] !== ''){
|
185 |
$commentdata['comment_approved'] = 'spam';
|
186 |
wp_insert_comment($commentdata);
|
187 |
update_option('gasp_count',get_option('gasp_count',true)+1);
|
188 |
-
wp_die($options['hidden_email_message']);
|
189 |
}
|
190 |
// secret key check
|
191 |
-
|
192 |
-
|
193 |
-
$
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
|
|
198 |
// check optional heuritics
|
199 |
if($options['urls'] != '0'){
|
200 |
$count = (int)$options['urls'];
|
@@ -211,7 +220,7 @@ function gasp_check_comment($commentdata){
|
|
211 |
if(isset($options['max_mod']) && $options['max_mod'] != 'disabled'){
|
212 |
$count = get_comments(array('status'=>'hold','author_email'=>$commentdata['comment_author_email'],'count'=>true));
|
213 |
if($count > $options['max_mod']){
|
214 |
-
wp_die(__('You already have too many comments in moderation. Please wait until your existing comments have been approved before attempting to leave more comments','ab_gasp'));
|
215 |
}
|
216 |
}
|
217 |
return $commentdata; // send back commentdata, another filter will set comment as spam/pending if gasp is set
|
@@ -261,8 +270,8 @@ function gasp_options_page(){
|
|
261 |
</td>
|
262 |
</tr>
|
263 |
<tr valign="top" class="alt menu_option postbox">
|
264 |
-
<td><?php _e('Secret Key','ab_gasp');?> <span style="position: relative; top: -0.5em; font-size: 80%; color: red;">
|
265 |
-
<td><input type="text" size="60" name="gasp_options[secret_key]" value="<?php echo $options['secret_key'];?>"/>
|
266 |
<p class="description"><?php _e('this another bit of security to secure your comment form. You can change this to any value (letters and numbers only)','ab_gasp');?></p>
|
267 |
</td>
|
268 |
</tr>
|
@@ -312,23 +321,23 @@ function gasp_options_page(){
|
|
312 |
<p><?php _e('You can have more advanced spam detection by setting these options. Many thanks to @dragonblogger for these suggestions','ab_gasp');?></p>
|
313 |
<table class="form-table postbox">
|
314 |
<tr valign="top" class="alt menu_option postbox">
|
315 |
-
<td width="30%"><?php _e('User refer check?','ab_gasp');?><span style="position: relative; top: -0.5em; font-size: 80%; color: red;">
|
316 |
<td><select name="gasp_options[refer_check]">
|
317 |
<option value="yes" <?php selected($options['refer_check'],'yes');?>><?php _e('Yes','ab_gasp');?></option>
|
318 |
<option value="no" <?php selected($options['refer_check'],'no');?>><?php _e('No','ab_gasp');?></option>
|
319 |
</select>
|
320 |
(<?php _e('GASP will check if the page the comment was sent on matches the page the comment was for','ab_gasp');?>)
|
321 |
</td>
|
322 |
-
</tr>
|
323 |
<tr valign="top" class="alt menu_option postbox">
|
324 |
<td width="30%"><?php _e('Maximum comments in moderation?','ab_gasp');?><span style="position: relative; top: -0.5em; font-size: 80%; color: red;">new</span></td>
|
325 |
<td>
|
326 |
<select name="gasp_options[max_mod]">
|
327 |
<option value="disabled" <?php selected($options['max_mod'],'disabled');?>><?php _e('disabled','ab_gasp');?></option>
|
328 |
<?php
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
?>
|
333 |
</select>
|
334 |
(<?php $desc = sprintf(__('A user can only submit comments if they have less than this number of comments to be moderated %s( for more control and to change the message, upgrade to CommentLuv Premium )%s','ab_gasp'),'<br/><a href="http://www.commentluv.com/?utm_source=settingspage&utm_medium=plugin&utm_term=gasp&utm_content=textlink&utm_campaign=freeplugin">','</a>');
|
@@ -365,7 +374,18 @@ function gasp_options_page(){
|
|
365 |
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
366 |
</p>
|
367 |
</form>
|
|
|
368 |
<table class="form-table postbox">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
369 |
<tr class="alt">
|
370 |
<td valign="top" width="150px">
|
371 |
This plugin was made by Andy Bailey (<a href="http://twitter.com/commentluv">@commentluv</a>)
|
@@ -432,10 +452,10 @@ function gasp_add_checkbox(){
|
|
432 |
gasp_cb.type = "checkbox";
|
433 |
gasp_cb.id = "'.$options['checkbox_name'].'";
|
434 |
gasp_cb.name = "'.$options['checkbox_name'].'";
|
435 |
-
|
436 |
var gasp_label = document.createElement("label");
|
437 |
gasp_p.appendChild(gasp_label);
|
438 |
-
|
439 |
gasp_label.appendChild(gasp_text);
|
440 |
var frm = gasp_cb.form;
|
441 |
frm.onsubmit = gasp_it;
|
3 |
Plugin Name: Growmap Anti Spambot Plugin
|
4 |
Plugin URI: http://www.growmap.com/growmap-anti-spambot-plugin/
|
5 |
Description: Very simple plugin that adds a client side generated checkbox to the comment form requesting that the user clicks it to prove they are not a spammer. Bots wont see it so their spam comment will be discarded.
|
6 |
+
Version: 1.5.2
|
7 |
Author: Andy Bailey
|
8 |
Author URI: http://ComLuv.com
|
9 |
*/
|
92 |
'checkbox_name' => $checkbox_name,
|
93 |
'secret_key' => COOKIEHASH.md5(home_url()),
|
94 |
'send_to' => 'spam',
|
95 |
+
'version' => '1.5.2'
|
96 |
);
|
97 |
$options = get_option('gasp_options',$default_options);
|
98 |
// update options with new defaults if upgrading from older version
|
118 |
$options['secret_key'] = COOKIEHASH.md5(home_url());
|
119 |
update_option('gasp_options',$options);
|
120 |
}
|
121 |
+
if(version_compare($options['version'],'1.5.2','<')){
|
122 |
+
$options['version'] = '1.5.2';
|
123 |
$options['refer_check'] = 'yes';
|
124 |
+
$options['use_secret_key'] = 'no';
|
125 |
$options['max_mod'] = 3;
|
126 |
+
update_option('gasp_options',$options);
|
127 |
}
|
128 |
return $options;
|
129 |
}
|
140 |
}
|
141 |
$secret_key = preg_replace('/[^a-zA-Z0-9]/','',$newoptions['secret_key']);
|
142 |
$newoptions['secret_key'] = $secret_key;
|
143 |
+
$newoptions['use_secret_key'] = $newoptions['use_secret_key'] == 'yes'? 'yes':'no';
|
144 |
$newoptions['urls'] = (string)$urls;
|
145 |
$newoptions['name_words'] = (string)$name_words;
|
146 |
$newoptions['refer_check'] = $newoptions['refer_check'] == 'yes'? 'yes':'no';
|
147 |
+
$newoptions['max_mod'] = (int)$newoptions['max_mod'];
|
148 |
return $newoptions;
|
149 |
}
|
150 |
|
168 |
if(is_user_logged_in()){
|
169 |
return $commentdata;
|
170 |
}
|
171 |
+
// construct return link
|
172 |
+
$nocache_return = '<p><a href="'.add_query_arg('nocache','yes',get_permalink($commentdata['comment_post_ID'])).'">'.__('The cache may have been out of date. Use this link to view a fresh version','ab_gasp').' '.get_the_title($commentdata['comment_post_ID']).'</a>';
|
173 |
// referer check. make sure the page sending the comment is correct
|
174 |
+
//debugbreak();
|
175 |
if($options['refer_check'] != 'no'){
|
176 |
if(!isset($_SERVER['HTTP_REFERER'])){
|
177 |
update_option('gasp_count',get_option('gasp_count',true)+1);
|
178 |
+
wp_die($options['hidden_email_message'].$nocache_return.'<p>Error Code: nr01');
|
179 |
}
|
180 |
+
$refer = parse_url($_SERVER['HTTP_REFERER']);
|
181 |
+
$posturl = parse_url(get_permalink($_POST['comment_post_ID']));
|
182 |
+
if($refer['host'] != $posturl['host']){
|
183 |
update_option('gasp_count',get_option('gasp_count',true)+1);
|
184 |
+
wp_die($options['hidden_email_message'].$nocache_return.'<p>Error Code: nr02');
|
185 |
}
|
186 |
}
|
187 |
|
188 |
// checkbox check
|
189 |
if(!isset($_POST[$options['checkbox_name']])){
|
190 |
+
wp_die($options['no_checkbox_message'].$nocache_return.'<p>Error Code: nc03');
|
191 |
} elseif (isset($_POST['gasp_email']) && $_POST['gasp_email'] !== ''){
|
192 |
$commentdata['comment_approved'] = 'spam';
|
193 |
wp_insert_comment($commentdata);
|
194 |
update_option('gasp_count',get_option('gasp_count',true)+1);
|
195 |
+
wp_die($options['hidden_email_message'].$nocache_return.'<p>Error Code: he04');
|
196 |
}
|
197 |
// secret key check
|
198 |
+
if($options['use_secret_key'] != 'no'){
|
199 |
+
$check = md5($options['secret_key'].$commentdata['comment_post_ID']);
|
200 |
+
if(!isset($_POST[$check]) || $_POST[$check] != $check){
|
201 |
+
$commentdata['comment_approved'] = 'spam';
|
202 |
+
wp_insert_comment($commentdata);
|
203 |
+
update_option('gasp_count',get_option('gasp_count',true)+1);
|
204 |
+
wp_die($options['hidden_email_message'].$nocache_return.'<p>Error Code sk05');
|
205 |
+
}
|
206 |
+
}
|
207 |
// check optional heuritics
|
208 |
if($options['urls'] != '0'){
|
209 |
$count = (int)$options['urls'];
|
220 |
if(isset($options['max_mod']) && $options['max_mod'] != 'disabled'){
|
221 |
$count = get_comments(array('status'=>'hold','author_email'=>$commentdata['comment_author_email'],'count'=>true));
|
222 |
if($count > $options['max_mod']){
|
223 |
+
wp_die(__('You already have too many comments in moderation. Please wait until your existing comments have been approved before attempting to leave more comments','ab_gasp').$nocache_return.'<p>Error Code: mc'.$count.'mm0'.$options['max_mod']);
|
224 |
}
|
225 |
}
|
226 |
return $commentdata; // send back commentdata, another filter will set comment as spam/pending if gasp is set
|
270 |
</td>
|
271 |
</tr>
|
272 |
<tr valign="top" class="alt menu_option postbox">
|
273 |
+
<td><?php _e('Secret Key','ab_gasp');?> <span style="position: relative; top: -0.5em; font-size: 80%; color: red;">updated</span></td>
|
274 |
+
<td><input type="checkbox" name="gasp_options[use_secret_key]" value="yes" <?php checked($options['use_secret_key'],'yes',true);?>/> <?php _e('Use secret key?','ab_gasp');?> <input type="text" size="60" name="gasp_options[secret_key]" value="<?php echo $options['secret_key'];?>"/>
|
275 |
<p class="description"><?php _e('this another bit of security to secure your comment form. You can change this to any value (letters and numbers only)','ab_gasp');?></p>
|
276 |
</td>
|
277 |
</tr>
|
321 |
<p><?php _e('You can have more advanced spam detection by setting these options. Many thanks to @dragonblogger for these suggestions','ab_gasp');?></p>
|
322 |
<table class="form-table postbox">
|
323 |
<tr valign="top" class="alt menu_option postbox">
|
324 |
+
<td width="30%"><?php _e('User refer check?','ab_gasp');?><span style="position: relative; top: -0.5em; font-size: 80%; color: red;">updated</span></td>
|
325 |
<td><select name="gasp_options[refer_check]">
|
326 |
<option value="yes" <?php selected($options['refer_check'],'yes');?>><?php _e('Yes','ab_gasp');?></option>
|
327 |
<option value="no" <?php selected($options['refer_check'],'no');?>><?php _e('No','ab_gasp');?></option>
|
328 |
</select>
|
329 |
(<?php _e('GASP will check if the page the comment was sent on matches the page the comment was for','ab_gasp');?>)
|
330 |
</td>
|
331 |
+
</tr>
|
332 |
<tr valign="top" class="alt menu_option postbox">
|
333 |
<td width="30%"><?php _e('Maximum comments in moderation?','ab_gasp');?><span style="position: relative; top: -0.5em; font-size: 80%; color: red;">new</span></td>
|
334 |
<td>
|
335 |
<select name="gasp_options[max_mod]">
|
336 |
<option value="disabled" <?php selected($options['max_mod'],'disabled');?>><?php _e('disabled','ab_gasp');?></option>
|
337 |
<?php
|
338 |
+
for($i = 1; $i<10 ; $i++){
|
339 |
+
echo '<option value="'.$i.'" '.selected($options['max_mod'],$i,false).'>'.$i.'</option>';
|
340 |
+
}
|
341 |
?>
|
342 |
</select>
|
343 |
(<?php $desc = sprintf(__('A user can only submit comments if they have less than this number of comments to be moderated %s( for more control and to change the message, upgrade to CommentLuv Premium )%s','ab_gasp'),'<br/><a href="http://www.commentluv.com/?utm_source=settingspage&utm_medium=plugin&utm_term=gasp&utm_content=textlink&utm_campaign=freeplugin">','</a>');
|
374 |
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
375 |
</p>
|
376 |
</form>
|
377 |
+
<table class="form-table postbox"><tr><td><h2>Warning:</h2><?php _e('If you are using a cache plugin like WP Super Cache or W3 total cache you MUST clear your cache after installing the updated plugin and/or changing any settings on this page. If you do not delete your cache after upgrading or changing settings, your comment form will still be using the old values and your readers may not be able to leave comments until you clear/delete your cache. (ignore this message if you do not have a cache plugin installed)','ab_gasp');?></td></tr></table>
|
378 |
<table class="form-table postbox">
|
379 |
+
<tr class="alt"><td><h2><?php _e('Error Codes','ab_gasp');?>:</h2><?php _e('What the error codes on the error messages mean and what to do about them','ab_gasp');?></td></tr>
|
380 |
+
<tr><td>nr01 : <?php echo __('No referrer sent with comment.','ab_gasp').'<p class="description">'.__('Sometimes peoples browsers do not send the referring page. This can appear to be bot behaviour. Advise the commenter to use another browser or switch off the refer check','ab_gasp');?></td></tr>
|
381 |
+
<tr class="alt"><td>nr02 : <?php echo __('Referring domain does not match your domain.','ab_gasp').'<p class="description">'.__('The page that sent the comment was not from your site or was using a different domain name which appears to be bot behaviour','ab_gasp');?></td></tr>
|
382 |
+
<tr><td>nc03 : <?php echo __('No checkbox value sent','ab_gasp').'<p class="description">'.__('The user did not check the checkbox or has disabled javascript or is using a bot','ab_gasp');?></td></tr>
|
383 |
+
<tr class="alt"><td>he04 : <?php echo __('Hidden email field was submitted','ab_gasp').'<p class="description">'.__('A hidden field on the form was filled. Sometimes bots fill in all fields with the word "email" as the name. Bot behaviour','ab_gasp');?></td></tr>
|
384 |
+
<tr><td>sk05 : <?php echo __('Secret Key value mismatch','ab_gasp').'<p class="description">'.__('The extra check using the secret key failed. This could be bot behaviour or the comment form is from a cached page which is out of date. Clear your cache if you have a cache plugin installed','ab_gasp');?></td></tr>
|
385 |
+
<tr class="alt"><td>mc{x}mm0{x} : <?php echo '<p class="description">'.__('User tried to make a comment when they already had the maxiumum number of comments allowed in moderation. (where mc# is made comments and mm# is the maximum you have set)','ab_gasp');?></td></tr>
|
386 |
+
</table>
|
387 |
+
<br />
|
388 |
+
<table class="form-table postbox">
|
389 |
<tr class="alt">
|
390 |
<td valign="top" width="150px">
|
391 |
This plugin was made by Andy Bailey (<a href="http://twitter.com/commentluv">@commentluv</a>)
|
452 |
gasp_cb.type = "checkbox";
|
453 |
gasp_cb.id = "'.$options['checkbox_name'].'";
|
454 |
gasp_cb.name = "'.$options['checkbox_name'].'";
|
455 |
+
|
456 |
var gasp_label = document.createElement("label");
|
457 |
gasp_p.appendChild(gasp_label);
|
458 |
+
gasp_label.appendChild(gasp_cb);
|
459 |
gasp_label.appendChild(gasp_text);
|
460 |
var frm = gasp_cb.form;
|
461 |
frm.onsubmit = gasp_it;
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link:http://comluv.com/about/donate
|
|
4 |
Tags: comments, anti spam, spam, spambot, gasp
|
5 |
Requires at least: 2.9.2
|
6 |
Tested up to: 3.6
|
7 |
-
Stable tag: 1.5.
|
8 |
|
9 |
Defeat automated spambots (even the new 'learning' bots with dynamically named hidden fields) by adding a client side generated checkbox.
|
10 |
|
@@ -25,6 +25,8 @@ You can get support and see this plugin in action at [Growmap](http://www.growma
|
|
25 |
|
26 |
This is provided for free by [Andy Bailey](http://comluv.com "Andy Bailey @ ComLuv - The CommentLuv Network")
|
27 |
|
|
|
|
|
28 |
[youtube http://www.youtube.com/watch?v=MVZ6pN8FFfw]
|
29 |
|
30 |
Translations :
|
@@ -86,6 +88,16 @@ also, you can try saving the settings again to reset all the variables
|
|
86 |
|
87 |
== ChangeLog ==
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
= 1.5.1 =
|
90 |
|
91 |
* updated : set the max_mod value during install if it doesn't exist
|
@@ -155,9 +167,9 @@ also, you can try saving the settings again to reset all the variables
|
|
155 |
|
156 |
== Upgrade Notice ==
|
157 |
|
158 |
-
= 1.5.
|
159 |
|
160 |
-
* fix -
|
161 |
|
162 |
== Configuration ==
|
163 |
|
4 |
Tags: comments, anti spam, spam, spambot, gasp
|
5 |
Requires at least: 2.9.2
|
6 |
Tested up to: 3.6
|
7 |
+
Stable tag: 1.5.2
|
8 |
|
9 |
Defeat automated spambots (even the new 'learning' bots with dynamically named hidden fields) by adding a client side generated checkbox.
|
10 |
|
25 |
|
26 |
This is provided for free by [Andy Bailey](http://comluv.com "Andy Bailey @ ComLuv - The CommentLuv Network")
|
27 |
|
28 |
+
(please remember to delete your cache when you upgrade or change any settings if you are using a cache plugin)
|
29 |
+
|
30 |
[youtube http://www.youtube.com/watch?v=MVZ6pN8FFfw]
|
31 |
|
32 |
Translations :
|
88 |
|
89 |
== ChangeLog ==
|
90 |
|
91 |
+
= 1.5.2 =
|
92 |
+
|
93 |
+
* updated : set checkbox as descendant of label so users can click the label to tick the box (thanks Anthony T)
|
94 |
+
* updated : added a link back to the post with a query arg to fix pages that were expired and had old form fields on the die message
|
95 |
+
* updated : change refer check logic
|
96 |
+
* updated : add error codes to error messages
|
97 |
+
* updated : allow user to not use secret_key (set as no by default)
|
98 |
+
* fixed : max_mod kept reverting back to 3 due to get_options not saving version number
|
99 |
+
* updated : added warning message about clearing the cache if a user upgrades or changes settings and has a cache plugin installed
|
100 |
+
|
101 |
= 1.5.1 =
|
102 |
|
103 |
* updated : set the max_mod value during install if it doesn't exist
|
167 |
|
168 |
== Upgrade Notice ==
|
169 |
|
170 |
+
= 1.5.2 =
|
171 |
|
172 |
+
* fix - set secret key check to no by default and added nocache url and error codes to error messages
|
173 |
|
174 |
== Configuration ==
|
175 |
|