Growmap Anti Spambot Plugin - Version 1.4.1

Version Description

  • updated : improved code for checkbox and label to help with styling (thanks James)
  • updated : regex for saving secret key
  • added : keep a count of bots caught
  • added : ad box below author info
Download this release

Release Info

Developer commentluv
Plugin Icon wp plugin Growmap Anti Spambot Plugin
Version 1.4.1
Comparing to
See all releases

Code changes from version 1.2 to 1.4.1

Files changed (2) hide show
  1. growmap-anti-spambot-plugin.php +71 -9
  2. readme.txt +19 -4
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.2
7
  Author: Andy Bailey
8
  Author URI: http://ComLuv.com
9
  */
@@ -13,7 +13,8 @@
13
  *********************************************/
14
  $gasp_plugin_dir = dirname(__FILE__);
15
  $gasp_plugin_url = WP_PLUGIN_URL.'/'.basename(dirname(__FILE__));
16
- $gasp_check == false;
 
17
 
18
 
19
  /*********************************************
@@ -88,8 +89,9 @@
88
  'urls' => '0',
89
  'name_words' => '0',
90
  'checkbox_name' => $checkbox_name,
 
91
  'send_to' => 'spam',
92
- 'version' => '1.2'
93
  );
94
  $options = get_option('gasp_options',$default_options);
95
  // update options with new defaults if upgrading from older version
@@ -110,6 +112,11 @@
110
  $options['checkbox_name'] = $checkbox_name;
111
  update_option('gasp_options',$options);
112
  }
 
 
 
 
 
113
  return $options;
114
  }
115
 
@@ -117,8 +124,14 @@
117
  * checks the options before they are saved
118
  */
119
  function gasp_options_sanitize($newoptions){
 
120
  $urls = intval($newoptions['urls']);
121
  $name_words = intval($newoptions['name_words']);
 
 
 
 
 
122
  $newoptions['urls'] = (string)$urls;
123
  $newoptions['name_words'] = (string)$name_words;
124
  return $newoptions;
@@ -132,6 +145,7 @@
132
  function gasp_check_comment($commentdata){
133
  //DebugBreak();
134
  global $gasp_check;
 
135
  $options = gasp_get_options();
136
  if($commentdata['comment_type'] == 'pingback' || $commentdata['comment_type'] == 'trackback'){
137
  if($options['trackbacks'] == 'yes'){
@@ -146,6 +160,17 @@
146
  if(!isset($_POST[$options['checkbox_name']])){
147
  wp_die($options['no_checkbox_message']);
148
  } elseif (isset($_POST['gasp_email']) && $_POST['gasp_email'] !== ''){
 
 
 
 
 
 
 
 
 
 
 
149
  wp_die($options['hidden_email_message']);
150
  }
151
  // check optional heuritics
@@ -181,11 +206,18 @@
181
  * This function handles the page for options
182
  */
183
  function gasp_options_page(){
 
184
  $options = gasp_get_options();
185
  global $gasp_plugin_url;
 
 
 
 
 
186
  ?>
187
  <div class="wrap">
188
  <h2>Growmap Anti Spambot Plugin Settings Page</h2> Version <?php echo $options['version'];?>
 
189
  <form method="post" action="options.php">
190
  <?php settings_fields( 'gasp_options_group' );?>
191
  <table class="form-table postbox">
@@ -199,6 +231,12 @@
199
  <p class="description"><?php _e('You can change this if you find that bots have started to target your blog again','ab_gasp');?></p>
200
  </td>
201
  </tr>
 
 
 
 
 
 
202
  <tr valign="top" class="alt menu_option postbox">
203
  <td><?php _e('Allow Trackbacks?','ab_gasp');?></td>
204
  <td><input type="checkbox" name="gasp_options[trackbacks]" value="yes" <?php checked($options['trackbacks'],'yes');?>/>
@@ -285,14 +323,30 @@
285
  Some of my other plugins :
286
  </td>
287
  <td>
288
- <ul><li><a target="_blank" href="http://www.commentluv.com/"><img title="Download CommentLuv Premium today!"src="<?php echo $gasp_plugin_url;?>/commentluv-plus-logo.png"/></a>
289
  <br />A fantastically powerful new plugin that combines 8 premium plugins in to 1. It has advanced heuristics for anti spam (like this plugin but even more powerful!). It can help your posts go viral, allow dofollow, keywordname, twitterlink and much much more! <a href="http://www.commentluv.com" target="_blank">Click here to see the video</a></li>
290
  <li><a href="http://wordpress.org/extend/plugins/twitterlink-comments/">TwitterLink Comments</a>
291
  <br />Add an extra field to your comment form to allow your visitors to leave their twitter username and have it displayed along with their comment. All without having to edit your theme.</li>
292
  </ul>
293
  </td>
294
  </tr>
295
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  </table>
297
 
298
  </div>
@@ -308,20 +362,27 @@
308
  * Adds javascript to create a checkbox on the comment form
309
  */
310
  function gasp_add_checkbox(){
311
- if(!is_user_logged_in()){
 
 
 
312
  $options = gasp_get_options();
 
 
313
  echo '<p id="gasp_p" style="clear:both;"></p>';
314
  echo '<script type="text/javascript">
315
- //v1.2
316
  var gasp_p = document.getElementById("gasp_p");
317
  var gasp_cb = document.createElement("input");
318
  var gasp_text = document.createTextNode(" '.$options['checkbox_label'].'");
319
  gasp_cb.type = "checkbox";
320
  gasp_cb.id = "'.$options['checkbox_name'].'";
321
  gasp_cb.name = "'.$options['checkbox_name'].'";
322
- gasp_cb.style.width = "25px";
323
  gasp_p.appendChild(gasp_cb);
324
- gasp_p.appendChild(gasp_text);
 
 
 
325
  var frm = gasp_cb.form;
326
  frm.onsubmit = gasp_it;
327
  function gasp_it(){
@@ -334,6 +395,7 @@
334
  </script>
335
  <noscript>you MUST enable javascript to be able to comment</noscript>
336
  <input type="hidden" id="gasp_email" name="gasp_email" value="" />';
 
337
  } else {
338
  echo '<!-- no checkbox needed by Growmap Anti Spambot Plugin for logged on user -->';
339
  }
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.4.1
7
  Author: Andy Bailey
8
  Author URI: http://ComLuv.com
9
  */
13
  *********************************************/
14
  $gasp_plugin_dir = dirname(__FILE__);
15
  $gasp_plugin_url = WP_PLUGIN_URL.'/'.basename(dirname(__FILE__));
16
+ $gasp_check = false;
17
+ $gasped = false;
18
 
19
 
20
  /*********************************************
89
  'urls' => '0',
90
  'name_words' => '0',
91
  'checkbox_name' => $checkbox_name,
92
+ 'secret_key' => COOKIEHASH.md5(home_url()),
93
  'send_to' => 'spam',
94
+ 'version' => '1.4.1'
95
  );
96
  $options = get_option('gasp_options',$default_options);
97
  // update options with new defaults if upgrading from older version
112
  $options['checkbox_name'] = $checkbox_name;
113
  update_option('gasp_options',$options);
114
  }
115
+ if(version_compare($options['version'], 1.4,'<')){
116
+ $options['version'] = '1.4';
117
+ $options['secret_key'] = COOKIEHASH.md5(home_url());
118
+ update_option('gasp_options',$options);
119
+ }
120
  return $options;
121
  }
122
 
124
  * checks the options before they are saved
125
  */
126
  function gasp_options_sanitize($newoptions){
127
+ //debugbreak();
128
  $urls = intval($newoptions['urls']);
129
  $name_words = intval($newoptions['name_words']);
130
+ if(!isset($newoptions['secret_key']) || !$newoptions['secret_key']){
131
+ $secret_key = COOKIEHASH.md5(home_url());
132
+ }
133
+ $secret_key = preg_replace('/[^a-zA-Z0-9]/','',$newoptions['secret_key']);
134
+ $newoptions['secret_key'] = $secret_key;
135
  $newoptions['urls'] = (string)$urls;
136
  $newoptions['name_words'] = (string)$name_words;
137
  return $newoptions;
145
  function gasp_check_comment($commentdata){
146
  //DebugBreak();
147
  global $gasp_check;
148
+
149
  $options = gasp_get_options();
150
  if($commentdata['comment_type'] == 'pingback' || $commentdata['comment_type'] == 'trackback'){
151
  if($options['trackbacks'] == 'yes'){
160
  if(!isset($_POST[$options['checkbox_name']])){
161
  wp_die($options['no_checkbox_message']);
162
  } elseif (isset($_POST['gasp_email']) && $_POST['gasp_email'] !== ''){
163
+ $commentdata['comment_approved'] = 'spam';
164
+ wp_insert_comment($commentdata);
165
+ update_option('gasp_count',get_option('gasp_count',true)+1);
166
+ wp_die($options['hidden_email_message']);
167
+ }
168
+ // secret key check
169
+ $check = md5($options['secret_key'].$commentdata['comment_post_ID']);
170
+ if(!isset($_POST['gasp_secret']) || $_POST['gasp_secret'] != $check){
171
+ $commentdata['comment_approved'] = 'spam';
172
+ wp_insert_comment($commentdata);
173
+ update_option('gasp_count',get_option('gasp_count',true)+1);
174
  wp_die($options['hidden_email_message']);
175
  }
176
  // check optional heuritics
206
  * This function handles the page for options
207
  */
208
  function gasp_options_page(){
209
+ //debugbreaK();
210
  $options = gasp_get_options();
211
  global $gasp_plugin_url;
212
+ if(empty($options['secret_key'])){
213
+ $options['secret_key'] = COOKIEHASH.md5(home_url());
214
+ }
215
+ $count = get_option('gasp_count');
216
+ $gasp_count = $count ? $count : 0;
217
  ?>
218
  <div class="wrap">
219
  <h2>Growmap Anti Spambot Plugin Settings Page</h2> Version <?php echo $options['version'];?>
220
+ <?php echo __('GASP has caught this many bot comments',$ab_gasp) . ' : <strong style="font-size:1.2em">'. $gasp_count . '</strong> '. __('(This does not count people who do not check the box)','ab_gasp')?>
221
  <form method="post" action="options.php">
222
  <?php settings_fields( 'gasp_options_group' );?>
223
  <table class="form-table postbox">
231
  <p class="description"><?php _e('You can change this if you find that bots have started to target your blog again','ab_gasp');?></p>
232
  </td>
233
  </tr>
234
+ <tr valign="top" class="alt menu_option postbox">
235
+ <td><?php _e('Secret Key','ab_gasp');?></td>
236
+ <td><input type="text" size="60" name="gasp_options[secret_key]" value="<?php echo $options['secret_key'];?>"/>
237
+ <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>
238
+ </td>
239
+ </tr>
240
  <tr valign="top" class="alt menu_option postbox">
241
  <td><?php _e('Allow Trackbacks?','ab_gasp');?></td>
242
  <td><input type="checkbox" name="gasp_options[trackbacks]" value="yes" <?php checked($options['trackbacks'],'yes');?>/>
323
  Some of my other plugins :
324
  </td>
325
  <td>
326
+ <ul><li><a target="_blank" href="http://www.commentluv.com/?utm_source=gasp&utm_medium=settingspage&utm_campaign=freeplugin"><img title="Download CommentLuv Premium today!"src="<?php echo $gasp_plugin_url;?>/commentluv-plus-logo.png"/></a>
327
  <br />A fantastically powerful new plugin that combines 8 premium plugins in to 1. It has advanced heuristics for anti spam (like this plugin but even more powerful!). It can help your posts go viral, allow dofollow, keywordname, twitterlink and much much more! <a href="http://www.commentluv.com" target="_blank">Click here to see the video</a></li>
328
  <li><a href="http://wordpress.org/extend/plugins/twitterlink-comments/">TwitterLink Comments</a>
329
  <br />Add an extra field to your comment form to allow your visitors to leave their twitter username and have it displayed along with their comment. All without having to edit your theme.</li>
330
  </ul>
331
  </td>
332
  </tr>
333
+ <tr>
334
+ <td colspan="4">
335
+ <?php
336
+ //debugbreak();
337
+ include_once(ABSPATH.WPINC.'/feed.php');
338
+ $rss = fetch_feed('http://comluv.com/category/ads/feed/');
339
+ if(!is_wp_error($rss)) {
340
+ $maxitems = $rss->get_item_quantity(2);
341
+ $rssitems = $rss->get_items(0,$maxitems);
342
+ }
343
+ foreach($rssitems as $item){
344
+ echo '<div><a href="'.esc_url( $item->get_permalink() ).'">'.esc_html($item->get_title()).'</a>';
345
+ echo '<p>'.$item->get_content().'</p></div>';
346
+ }
347
+ ?>
348
+ </td>
349
+ </tr>
350
  </table>
351
 
352
  </div>
362
  * Adds javascript to create a checkbox on the comment form
363
  */
364
  function gasp_add_checkbox(){
365
+ global $gasped, $post;
366
+
367
+ if(!is_user_logged_in() && !$gasped){
368
+ //debugbreak();
369
  $options = gasp_get_options();
370
+ $gasp_secret = md5($options['secret_key'].$post->ID);
371
+ echo '<input type="hidden" name="gasp_secret" value="'.$gasp_secret.'"/>';
372
  echo '<p id="gasp_p" style="clear:both;"></p>';
373
  echo '<script type="text/javascript">
374
+ //v1.4.1
375
  var gasp_p = document.getElementById("gasp_p");
376
  var gasp_cb = document.createElement("input");
377
  var gasp_text = document.createTextNode(" '.$options['checkbox_label'].'");
378
  gasp_cb.type = "checkbox";
379
  gasp_cb.id = "'.$options['checkbox_name'].'";
380
  gasp_cb.name = "'.$options['checkbox_name'].'";
 
381
  gasp_p.appendChild(gasp_cb);
382
+ var gasp_label = document.createElement("label");
383
+ gasp_p.appendChild(gasp_label);
384
+
385
+ gasp_label.appendChild(gasp_text);
386
  var frm = gasp_cb.form;
387
  frm.onsubmit = gasp_it;
388
  function gasp_it(){
395
  </script>
396
  <noscript>you MUST enable javascript to be able to comment</noscript>
397
  <input type="hidden" id="gasp_email" name="gasp_email" value="" />';
398
+ $gasped = true;
399
  } else {
400
  echo '<!-- no checkbox needed by Growmap Anti Spambot Plugin for logged on user -->';
401
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: commentluv
3
  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.5
7
- Stable tag: 1.2
8
 
9
  Defeat automated spambots by adding a client side generated checkbox asking the comment author to confirm that they are not a spammer.
10
 
@@ -67,6 +67,21 @@ Change the `checkbox name` value in the settings page to something new (like cha
67
 
68
  == ChangeLog ==
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  = 1.2 =
71
  * allow blogger to change checkbox name in settings
72
 
@@ -101,9 +116,9 @@ Change the `checkbox name` value in the settings page to something new (like cha
101
 
102
  == Upgrade Notice ==
103
 
104
- = 1.2 =
105
 
106
- * added - allow user to change gasp checkbox name
107
 
108
  == Configuration ==
109
 
3
  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.4.1
8
 
9
  Defeat automated spambots by adding a client side generated checkbox asking the comment author to confirm that they are not a spammer.
10
 
67
 
68
  == ChangeLog ==
69
 
70
+ = 1.4.1 =
71
+ * updated : improved code for checkbox and label to help with styling (thanks James)
72
+ * updated : regex for saving secret key
73
+ * added : keep a count of bots caught
74
+ * added : ad box below author info
75
+
76
+ = 1.4 =
77
+ * added : new extra security added with secret_key
78
+ * added : insert commentdata as spam before wp_die so spammer can't keep submitting the same comment with new key try
79
+ * fixed : bug with gasp_check declaration using == instead of =
80
+ * added : keep a track of bot comments and show count in settings page (only bot comments, not forgotten checkboxes)
81
+
82
+ = 1.3 =
83
+ * fixed : prevent two checkboxes being rendered on some themes (nexus)
84
+
85
  = 1.2 =
86
  * allow blogger to change checkbox name in settings
87
 
116
 
117
  == Upgrade Notice ==
118
 
119
+ = 1.4 =
120
 
121
+ * added - new secret_key for combatting the new wave of automated spam bots
122
 
123
  == Configuration ==
124