Growmap Anti Spambot Plugin - Version 1.5

Version Description

  • updated : max_mod is set at 3 by default
  • updated : readme.txt updated
Download this release

Release Info

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

Code changes from version 1.4.1 to 1.5

growmap-anti-spambot-plugin.php CHANGED
@@ -1,223 +1,252 @@
1
  <?php
2
- /*
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
- */
10
 
11
- /*********************************************
12
- * setup
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
- /*********************************************
21
- * hooks
22
- *********************************************/
23
- if(is_admin()){
24
- // admin hooks
25
- add_action( 'admin_menu', 'gasp_admin_link' );
26
- add_action( 'admin_init', 'gasp_admin_init' );
27
- add_filter ( 'plugin_action_links', 'gasp_action' , - 10, 2 );
28
- } else {
29
- // public hooks
30
- add_action('comment_form','gasp_add_checkbox',1);
31
- add_filter('preprocess_comment','gasp_check_comment',1,1);
32
- add_filter('pre_comment_approved','gasp_autospam_comment_check',1,1);
33
- }
34
- // everywhere hooks
35
- add_action('init','gasp_init');
36
 
37
- /*********************************************
38
- * internal functions
39
- *********************************************/
40
 
41
- /** gasp_init
42
- */
43
- function gasp_init(){
44
- load_plugin_textdomain( 'ab_gasp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
45
- }
46
- /** gasp_admin_init
47
- * Sets up the admin pages and settings
48
- */
49
- function gasp_admin_init(){
50
- register_setting( 'gasp_options_group', 'gasp_options' , 'gasp_options_sanitize');
51
- }
52
 
53
- /** gasp_admin_link
54
- * Add link to settings panel in dashboard
55
- */
56
- function gasp_admin_link(){
57
- // language
58
- load_plugin_textdomain( 'ab_gasp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
59
- add_options_page('Growmap Anti Spambot Plugin Settings','G.A.S.P.','manage_options','gasp','gasp_options_page');
60
- }
61
 
62
- /** gasp_action
63
- * adds a link on the plugins page next to activate/deactivate to go to the settings page
64
- * @param array $links - the links to be filtered
65
- *@param string $file - the file whos links are being filtered
66
- * return string $links - the new string of links
67
- */
68
- function gasp_action($links,$file){
69
- $this_plugin = plugin_basename ( __FILE__ );
70
- if ($file == $this_plugin) {
71
- $links [] = "<a href='options-general.php?page=gasp'>" . __ ( 'Settings', 'ab_gasp' ) . "</a>";
72
- }
73
- return $links;
74
  }
 
 
75
 
76
- /** gasp_get_options
77
- * Retrieves the options from the database.
78
- * Returns saved options or defaults if no options have been saved.
79
- */
80
- function gasp_get_options(){
81
- //debugbreak();
82
- $checkbox_name = 'cl_check_'.substr(md5(home_url()),0,3);
83
- $default_options = array(
84
  'checkbox_alert' => __('Please check the box to confirm that you are NOT a spammer','ab_gasp'),
85
  'no_checkbox_message' => __('You may have disabled javascript. Please enable javascript before leaving a comment on this site.','ab_gasp'),
86
  'hidden_email_message' => __('You appear to be a spambot. Contact admin another way if you feel this message is in error','ab_gasp'),
87
  'checkbox_label' => __('Confirm you are NOT a spammer','ab_gasp'),
88
  'trackbacks' => 'yes',
 
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
98
- if((float)$options['version'] < 0.4 ){
99
- update_option('gasp_options',$default_options);
100
- return $default_options;
101
- }
102
- if((float)$options['version'] < 1.1){
103
- $options['version'] = '1.1';
104
- $options['trackbacks'] = 'yes';
105
- $options['urls'] = '0';
106
- $options['name_words'] = '0';
107
- $options['send_to'] = 'spam';
108
- update_option('gasp_options',$options);
109
- }
110
- if(version_compare($options['version'],'1.2','<')){
111
- $options['version'] = '1.2';
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
 
123
- /** gasp_options_sanitize
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;
138
  }
 
 
 
 
 
 
 
139
 
140
- /** gasp_check_comment
141
- * Called by preprocess_comment filter
142
- * @param array $commentdata - array containing indices "comment_post_ID", "comment_author", "comment_author_email", "comment_author_url", "comment_content", "comment_type", and "user_ID"
143
- * Return array updated comment data array or wp_die()
144
- */
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'){
152
- return $commentdata;
153
- } else {
154
- exit;
155
- }
156
- }
157
- if(is_user_logged_in()){
158
  return $commentdata;
 
 
159
  }
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
177
- if($options['urls'] != '0'){
178
- $count = (int)$options['urls'];
179
- if(substr_count($commentdata['comment_content'], "http") > $count){
180
- $gasp_check = $options['send_to'];
181
- }
182
  }
183
- if($options['name_words'] != '0'){
184
- $count = (int)$options['name_words'];
185
- if(substr_count($commentdata['comment_author'],' ') >= $count){
186
- $gasp_check = $options['send_to'];
187
- }
188
  }
189
- return $commentdata; // send back commentdata, another filter will set comment as spam/pending if gasp is set
190
  }
 
 
191
 
192
- function gasp_autospam_comment_check($approved){
193
- //DebugBreak();
194
- global $gasp_check;
195
- if($gasp_check != NULL){
196
- $approved = $gasp_check;
197
- }
198
- return $approved;
199
  }
 
 
200
 
201
 
202
- /*********************************************
203
- * admin output
204
- *********************************************/
205
- /** gasp_options_page
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">
@@ -228,18 +257,18 @@
228
  <tr valign="top" class="alt menu_option postbox">
229
  <td><?php _e('Checkbox Name','ab_gasp');?></td>
230
  <td><input type="text" size="60" name="gasp_options[checkbox_name]" value="<?php echo $options['checkbox_name'];?>"/>
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');?>/>
243
  (<?php _e('Unchecking the box will prevent ALL trackbacks', 'ab_gasp'); ?>)
244
  <br/><?php _e('See this plugin if you want a trackback validation plugin that works well with GASP','ab_gasp');?>
245
  <a href="http://wordpress.org/extend/plugins/simple-trackback-validation/" target="_blank">Simple Trackback Validation</a>
@@ -281,7 +310,32 @@
281
  <?php // heuristics ?>
282
  <h2><?php _e('Heuristics (optional spam detection)','ab_gasp');?></h2>
283
  <p><?php _e('You can have more advanced spam detection by setting these options. Many thanks to @dragonblogger for these suggestions','ab_gasp');?></p>
284
- <table class="form-table postbox">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  <tr valign="top" class="alt menu_option postbox">
286
  <td width="30%"><?php _e('Maximum number of URLs allowed in comment text','ab_gasp');?></td>
287
  <td><input type="text" size = "5" name="gasp_options[urls]" value="<?php echo $options['urls'];?>" />
@@ -334,16 +388,16 @@
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>
@@ -351,53 +405,53 @@
351
 
352
  </div>
353
  <?php
354
- }
355
 
356
- /*********************************************
357
- * public output
358
- *********************************************/
359
 
360
- /** gasp_add_checkbox
361
- * Called by comment_form action
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(){
389
- if(gasp_cb.checked != true){
390
- alert("'.$options['checkbox_alert'].'");
391
- return false;
392
- }
393
- return true;
394
- }
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
  }
 
 
 
 
 
 
402
  }
 
403
  ?>
1
  <?php
2
+ /*
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
+ */
10
 
11
+ /*********************************************
12
+ * setup
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
+ /*********************************************
21
+ * hooks
22
+ *********************************************/
23
+ if(is_admin()){
24
+ // admin hooks
25
+ add_action( 'admin_menu', 'gasp_admin_link' );
26
+ add_action( 'admin_init', 'gasp_admin_init' );
27
+ add_filter ( 'plugin_action_links', 'gasp_action' , - 10, 2 );
28
+ } else {
29
+ // public hooks
30
+ add_action('comment_form','gasp_add_checkbox',1);
31
+ add_filter('preprocess_comment','gasp_check_comment',1,1);
32
+ add_filter('pre_comment_approved','gasp_autospam_comment_check',1,1);
33
+ }
34
+ // everywhere hooks
35
+ add_action('init','gasp_init');
36
 
37
+ /*********************************************
38
+ * internal functions
39
+ *********************************************/
40
 
41
+ /** gasp_init
42
+ */
43
+ function gasp_init(){
44
+ load_plugin_textdomain( 'ab_gasp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
45
+ }
46
+ /** gasp_admin_init
47
+ * Sets up the admin pages and settings
48
+ */
49
+ function gasp_admin_init(){
50
+ register_setting( 'gasp_options_group', 'gasp_options' , 'gasp_options_sanitize');
51
+ }
52
 
53
+ /** gasp_admin_link
54
+ * Add link to settings panel in dashboard
55
+ */
56
+ function gasp_admin_link(){
57
+ // language
58
+ load_plugin_textdomain( 'ab_gasp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
59
+ add_options_page('Growmap Anti Spambot Plugin Settings','G.A.S.P.','manage_options','gasp','gasp_options_page');
60
+ }
61
 
62
+ /** gasp_action
63
+ * adds a link on the plugins page next to activate/deactivate to go to the settings page
64
+ * @param array $links - the links to be filtered
65
+ *@param string $file - the file whos links are being filtered
66
+ * return string $links - the new string of links
67
+ */
68
+ function gasp_action($links,$file){
69
+ $this_plugin = plugin_basename ( __FILE__ );
70
+ if ($file == $this_plugin) {
71
+ $links [] = "<a href='options-general.php?page=gasp'>" . __ ( 'Settings', 'ab_gasp' ) . "</a>";
 
 
72
  }
73
+ return $links;
74
+ }
75
 
76
+ /** gasp_get_options
77
+ * Retrieves the options from the database.
78
+ * Returns saved options or defaults if no options have been saved.
79
+ */
80
+ function gasp_get_options(){
81
+ //debugbreak();
82
+ $checkbox_name = 'cl_check_'.substr(md5(home_url()),0,3);
83
+ $default_options = array(
84
  'checkbox_alert' => __('Please check the box to confirm that you are NOT a spammer','ab_gasp'),
85
  'no_checkbox_message' => __('You may have disabled javascript. Please enable javascript before leaving a comment on this site.','ab_gasp'),
86
  'hidden_email_message' => __('You appear to be a spambot. Contact admin another way if you feel this message is in error','ab_gasp'),
87
  'checkbox_label' => __('Confirm you are NOT a spammer','ab_gasp'),
88
  'trackbacks' => 'yes',
89
+ 'refer_check' => 'yes',
90
  'urls' => '0',
91
  'name_words' => '0',
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
99
+ if((float)$options['version'] < 0.4 ){
100
+ update_option('gasp_options',$default_options);
101
+ return $default_options;
102
+ }
103
+ if((float)$options['version'] < 1.1){
104
+ $options['version'] = '1.1';
105
+ $options['trackbacks'] = 'yes';
106
+ $options['urls'] = '0';
107
+ $options['name_words'] = '0';
108
+ $options['send_to'] = 'spam';
109
+ update_option('gasp_options',$options);
110
+ }
111
+ if(version_compare($options['version'],'1.2','<')){
112
+ $options['version'] = '1.2';
113
+ $options['checkbox_name'] = $checkbox_name;
114
+ update_option('gasp_options',$options);
 
 
 
 
 
 
 
115
  }
116
+ if(version_compare($options['version'], 1.4,'<')){
117
+ $options['version'] = '1.4';
118
+ $options['secret_key'] = COOKIEHASH.md5(home_url());
119
+ update_option('gasp_options',$options);
120
+ }
121
+ if(version_compare($options['version'],'1.4.3','<')){
122
+ $options['refer_check'] = 'yes';
123
+ $options['max_mod'] = 3;
124
+ }
125
+ return $options;
126
+ }
127
 
128
+ /** gasp_options_sanitize
129
+ * checks the options before they are saved
130
+ */
131
+ function gasp_options_sanitize($newoptions){
132
+ //debugbreak();
133
+ $urls = intval($newoptions['urls']);
134
+ $name_words = intval($newoptions['name_words']);
135
+ if(!isset($newoptions['secret_key']) || !$newoptions['secret_key']){
136
+ $secret_key = COOKIEHASH.md5(home_url());
 
 
 
 
 
 
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
 
146
+ /** gasp_check_comment
147
+ * Called by preprocess_comment filter
148
+ * @param array $commentdata - array containing indices "comment_post_ID", "comment_author", "comment_author_email", "comment_author_url", "comment_content", "comment_type", and "user_ID"
149
+ * Return array updated comment data array or wp_die()
150
+ */
151
+ function gasp_check_comment($commentdata){
152
+ //DebugBreak();
153
+ global $gasp_check;
154
+
155
+ $options = gasp_get_options();
156
+ if($commentdata['comment_type'] == 'pingback' || $commentdata['comment_type'] == 'trackback'){
157
+ if($options['trackbacks'] == 'yes'){
 
 
 
 
 
 
158
  return $commentdata;
159
+ } else {
160
+ exit;
161
  }
162
+ }
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(strstr($posturl,$refer)===false){
 
 
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
+ $check = md5($options['secret_key'].$commentdata['comment_post_ID']);
192
+ if(!isset($_POST[$check]) || $_POST[$check] != $check){
193
+ $commentdata['comment_approved'] = 'spam';
194
+ wp_insert_comment($commentdata);
195
+ update_option('gasp_count',get_option('gasp_count',true)+1);
196
+ wp_die($options['hidden_email_message']);
197
+ }
198
+ // check optional heuritics
199
+ if($options['urls'] != '0'){
200
+ $count = (int)$options['urls'];
201
+ if(substr_count($commentdata['comment_content'], "http") > $count){
202
+ $gasp_check = $options['send_to'];
203
  }
204
+ }
205
+ if($options['name_words'] != '0'){
206
+ $count = (int)$options['name_words'];
207
+ if(substr_count($commentdata['comment_author'],' ') >= $count){
208
+ $gasp_check = $options['send_to'];
 
209
  }
210
+ }
211
+ if($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
218
+ }
219
 
220
+ function gasp_autospam_comment_check($approved){
221
+ //DebugBreak();
222
+ global $gasp_check;
223
+ if($gasp_check != NULL){
224
+ $approved = $gasp_check;
 
 
225
  }
226
+ return $approved;
227
+ }
228
 
229
 
230
+ /*********************************************
231
+ * admin output
232
+ *********************************************/
233
+ /** gasp_options_page
234
+ * This function handles the page for options
235
+ */
236
+ function gasp_options_page(){
237
+ //debugbreaK();
238
+ $options = gasp_get_options();
239
+
240
+ global $gasp_plugin_url;
241
+ if(empty($options['secret_key'])){
242
+ $options['secret_key'] = COOKIEHASH.md5(home_url());
243
+ }
244
+ $count = get_option('gasp_count');
245
+ $gasp_count = $count ? $count : 0;
246
  ?>
247
  <div class="wrap">
248
  <h2>Growmap Anti Spambot Plugin Settings Page</h2> Version <?php echo $options['version'];?>
249
+ <?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')?>
250
  <form method="post" action="options.php">
251
  <?php settings_fields( 'gasp_options_group' );?>
252
  <table class="form-table postbox">
257
  <tr valign="top" class="alt menu_option postbox">
258
  <td><?php _e('Checkbox Name','ab_gasp');?></td>
259
  <td><input type="text" size="60" name="gasp_options[checkbox_name]" value="<?php echo $options['checkbox_name'];?>"/>
260
+ <p class="description"><?php _e('You can change this if you find that bots have started to target your blog again','ab_gasp');?></p>
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;">new</span></td>
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>
269
  <tr valign="top" class="alt menu_option postbox">
270
  <td><?php _e('Allow Trackbacks?','ab_gasp');?></td>
271
+ <td><input type="checkbox" name="gasp_options[trackbacks]" value="yes" <?php if(isset($options['trackbacks'])){checked($options['trackbacks'],'yes');}?>/>
272
  (<?php _e('Unchecking the box will prevent ALL trackbacks', 'ab_gasp'); ?>)
273
  <br/><?php _e('See this plugin if you want a trackback validation plugin that works well with GASP','ab_gasp');?>
274
  <a href="http://wordpress.org/extend/plugins/simple-trackback-validation/" target="_blank">Simple Trackback Validation</a>
310
  <?php // heuristics ?>
311
  <h2><?php _e('Heuristics (optional spam detection)','ab_gasp');?></h2>
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;">new</span></td>
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
+ for($i = 1; $i<10 ; $i++){
330
+ echo '<option value="'.$i.'" '.selected($options['max_mod'],$i,false).'>'.$i.'</option>';
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>');
335
+ echo $desc;
336
+ ?>)
337
+ </td>
338
+ </tr>
339
  <tr valign="top" class="alt menu_option postbox">
340
  <td width="30%"><?php _e('Maximum number of URLs allowed in comment text','ab_gasp');?></td>
341
  <td><input type="text" size = "5" name="gasp_options[urls]" value="<?php echo $options['urls'];?>" />
388
  <td colspan="4">
389
  <?php
390
  //debugbreak();
391
+ include_once(ABSPATH.WPINC.'/feed.php');
392
+ $rss = fetch_feed('http://comluv.com/category/ads/feed/');
393
+ if(!is_wp_error($rss)) {
394
+ $maxitems = $rss->get_item_quantity(2);
395
+ $rssitems = $rss->get_items(0,$maxitems);
396
+ }
397
+ foreach($rssitems as $item){
398
+ echo '<div><a href="'.esc_url( $item->get_permalink() ).'">'.esc_html($item->get_title()).'</a>';
399
+ echo '<p>'.$item->get_content().'</p></div>';
400
+ }
401
  ?>
402
  </td>
403
  </tr>
405
 
406
  </div>
407
  <?php
408
+ }
409
 
410
+ /*********************************************
411
+ * public output
412
+ *********************************************/
413
 
414
+ /** gasp_add_checkbox
415
+ * Called by comment_form action
416
+ * Adds javascript to create a checkbox on the comment form
417
+ */
418
+ function gasp_add_checkbox(){
419
+ global $gasped, $post;
420
+
421
+ if(!is_user_logged_in() && !$gasped){
422
+ //debugbreak();
423
+ $options = gasp_get_options();
424
+ $gasp_secret = md5($options['secret_key'].$post->ID);
425
+ echo '<input type="hidden" name="'.$gasp_secret.'" value="'.$gasp_secret.'"/>';
426
+ echo '<p id="gasp_p" style="clear:both;"></p>';
427
+ echo '<script type="text/javascript">
428
+ //v1.4.3
429
+ var gasp_p = document.getElementById("gasp_p");
430
+ var gasp_cb = document.createElement("input");
431
+ var gasp_text = document.createTextNode(" '.$options['checkbox_label'].'");
432
+ gasp_cb.type = "checkbox";
433
+ gasp_cb.id = "'.$options['checkbox_name'].'";
434
+ gasp_cb.name = "'.$options['checkbox_name'].'";
435
+ gasp_p.appendChild(gasp_cb);
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;
442
+ function gasp_it(){
443
+ if(gasp_cb.checked != true){
444
+ alert("'.$options['checkbox_alert'].'");
445
+ return false;
446
+ }
447
+ return true;
 
 
 
 
 
 
 
448
  }
449
+ </script>
450
+ <noscript>you MUST enable javascript to be able to comment</noscript>
451
+ <input type="hidden" id="gasp_email" name="gasp_email" value="" />';
452
+ $gasped = true;
453
+ } else {
454
+ echo '<!-- no checkbox needed by Growmap Anti Spambot Plugin for logged on user -->';
455
  }
456
+ }
457
  ?>
languages/ab_gasp-es_ES.mo ADDED
Binary file
languages/ab_gasp-es_ES.po ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Growmap Anti Spambot Plugin\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2012-09-01 08:47-0000\n"
6
+ "PO-Revision-Date: 2013-09-05 17:44+0100\n"
7
+ "Last-Translator: Ramon <marketing@apasionados.es>\n"
8
+ "Language-Team: Ramón <info@apasionados.es>\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Poedit-KeywordsList: __;_e\n"
13
+ "X-Poedit-Basepath: .\n"
14
+ "Language: es_ES\n"
15
+ "X-Generator: Poedit 1.5.7\n"
16
+ "X-Poedit-SearchPath-0: ..\n"
17
+
18
+ #: ../growmap-anti-spambot-plugin.php:70
19
+ msgid "Settings"
20
+ msgstr "Ajustes"
21
+
22
+ #: ../growmap-anti-spambot-plugin.php:83
23
+ msgid "Please check the box to confirm that you are NOT a spammer"
24
+ msgstr ""
25
+ "Por favor selecciona la casilla antes de comentar para confirmar que eres "
26
+ "humano. Gracias por ayudarnos a mantener este blog libre de spam."
27
+
28
+ #: ../growmap-anti-spambot-plugin.php:84
29
+ msgid ""
30
+ "You may have disabled javascript. Please enable javascript before leaving a "
31
+ "comment on this site."
32
+ msgstr ""
33
+ "Para que puedas dejar un comentario, tienes que tener activado Javascript"
34
+
35
+ #: ../growmap-anti-spambot-plugin.php:85
36
+ msgid ""
37
+ "You appear to be a spambot. Contact admin another way if you feel this "
38
+ "message is in error"
39
+ msgstr ""
40
+ "Pareces ser un robot que envía spam. En caso de que no sea así, por favor "
41
+ "contacta con el administrador"
42
+
43
+ #: ../growmap-anti-spambot-plugin.php:86
44
+ msgid "Confirm you are NOT a spammer"
45
+ msgstr "Por favor confirma que eres humano antes de comentar"
46
+
47
+ #: ../growmap-anti-spambot-plugin.php:193
48
+ msgid "Checkbox Label"
49
+ msgstr "Etiqueta de la casilla de comprobación"
50
+
51
+ #: ../growmap-anti-spambot-plugin.php:197
52
+ msgid "Checkbox Name"
53
+ msgstr "Nombre de la casilla de comprobación"
54
+
55
+ #: ../growmap-anti-spambot-plugin.php:199
56
+ msgid ""
57
+ "You can change this if you find that bots have started to target your blog "
58
+ "again"
59
+ msgstr ""
60
+ "Puedes cambiar esto si los robots han vuelto a poner tu blog en su punto de "
61
+ "mira"
62
+
63
+ #: ../growmap-anti-spambot-plugin.php:203
64
+ msgid "Allow Trackbacks?"
65
+ msgstr "¿Permitir notificaciones de enlace desde otros sitios (trackbacks)?"
66
+
67
+ #: ../growmap-anti-spambot-plugin.php:205
68
+ msgid "Unchecking the box will prevent ALL trackbacks"
69
+ msgstr "Si desmarcas esta casilla, no se permitirá ningún trackback."
70
+
71
+ #: ../growmap-anti-spambot-plugin.php:206
72
+ msgid ""
73
+ "See this plugin if you want a trackback validation plugin that works well "
74
+ "with GASP"
75
+ msgstr ""
76
+ "Mira este plugin si estás buscando uno que valide trackbacks y funcione bien "
77
+ "con GASP"
78
+
79
+ #: ../growmap-anti-spambot-plugin.php:210
80
+ msgid ""
81
+ "These are the messages you will show the user if they forget to check the "
82
+ "checkbox or if the comment looks like it was submitted by a spambot"
83
+ msgstr ""
84
+ "Estos son los mensajes que se van a mostrar si el usuario ha olvidado marcar "
85
+ "la casilla o si el comentario parece ser enviado por un robot de envío de "
86
+ "comentarios spam"
87
+
88
+ #: ../growmap-anti-spambot-plugin.php:212
89
+ #: ../growmap-anti-spambot-plugin.php:222
90
+ msgid "There is only 1 situation where this can happen"
91
+ msgstr "Solo hay una situación en la que pueda pasar esto"
92
+
93
+ #: ../growmap-anti-spambot-plugin.php:214
94
+ msgid "The user forgot to check the checkbox"
95
+ msgstr "El usuario olvidó marcar la casilla"
96
+
97
+ #: ../growmap-anti-spambot-plugin.php:217
98
+ msgid "Checkbox not checked alert"
99
+ msgstr "Alerta cuando la casilla de comprobación no está seleccionada"
100
+
101
+ #: ../growmap-anti-spambot-plugin.php:224
102
+ msgid "The user does not have javascript enabled"
103
+ msgstr "El usuario no tiene javascript activado"
104
+
105
+ #: ../growmap-anti-spambot-plugin.php:227
106
+ msgid "No checkbox"
107
+ msgstr "No hay casilla"
108
+
109
+ #: ../growmap-anti-spambot-plugin.php:232
110
+ msgid "There is only one situation where this would happen"
111
+ msgstr "Solo hay una situación en la que pueda pasar esto"
112
+
113
+ #: ../growmap-anti-spambot-plugin.php:234
114
+ msgid ""
115
+ "The form has a hidden field added with a label that has a name value with "
116
+ "the word \"email\" in it. A spam bot will usually try to fill in all fields "
117
+ "on a form, if this field has been filled in then something is wrong"
118
+ msgstr ""
119
+ "Este formulario tiene un campo oculto con una etiqueta que contiene el "
120
+ "texto \"email\". Un robot que deja comentarios spam normalmente rellena "
121
+ "todos los campos y por tanto si este campo oculto se ha rellenado, pasa algo "
122
+ "extraño."
123
+
124
+ #: ../growmap-anti-spambot-plugin.php:237
125
+ msgid "Hidden email field completed"
126
+ msgstr "Campo oculto de email rellenado"
127
+
128
+ #: ../growmap-anti-spambot-plugin.php:244
129
+ msgid "Heuristics (optional spam detection)"
130
+ msgstr "Heurística (detección opcional de spam)"
131
+
132
+ #: ../growmap-anti-spambot-plugin.php:245
133
+ msgid ""
134
+ "You can have more advanced spam detection by setting these options. Many "
135
+ "thanks to @dragonblogger for these suggestions"
136
+ msgstr ""
137
+ "Puedes tener una detección de spam más avanzada si configuras estas "
138
+ "opciones. Muchas gracias a @dragonblogger por las sugerencias."
139
+
140
+ #: ../growmap-anti-spambot-plugin.php:248
141
+ msgid "Maximum number of URLs allowed in comment text"
142
+ msgstr "Número máximo de URLs permitidos en el texto del comentario"
143
+
144
+ #: ../growmap-anti-spambot-plugin.php:250
145
+ #: ../growmap-anti-spambot-plugin.php:256
146
+ msgid "Use 0 (zero) to disable check"
147
+ msgstr "Usa 0 (cero) para deshabilitar la comprobación"
148
+
149
+ #: ../growmap-anti-spambot-plugin.php:254
150
+ msgid "Maximum number of words allowed in name field"
151
+ msgstr "Número máximo de palabras permitidas en el campo nombre"
152
+
153
+ #: ../growmap-anti-spambot-plugin.php:260
154
+ msgid "Where to send suspicious comments?"
155
+ msgstr "¿Qué hacemos con los comentarios que son sospechosos?"
156
+
157
+ #: ../growmap-anti-spambot-plugin.php:263
158
+ msgid "spam"
159
+ msgstr "spam"
160
+
161
+ #: ../growmap-anti-spambot-plugin.php:264
162
+ msgid "pending"
163
+ msgstr "pendiente"
164
+
165
+ #: ../growmap-anti-spambot-plugin.php:273
166
+ msgid "Save Changes"
167
+ msgstr "Guardar cambios"
readme.txt CHANGED
@@ -4,23 +4,35 @@ 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
 
11
  == Description ==
12
 
 
 
13
  This plugin will add a client side generated checkbox to your comment form asking users to confirm that they are not a spammer.
14
  It is a lot less trouble to click a box than it is to enter a captcha and because the box is genereated via client side javascript that bots cannot see, it should stop 99% of all automated spam bots.
15
 
16
  A check is made that the checkbox has been checked before the comment is submitted so there's no chance that a comment will be lost if it's being submitted by legitimate human user.
17
 
 
 
 
 
18
  You can get support and see this plugin in action at [Growmap](http://www.growmap.com/growmap-anti-spambot-plugin/ "Growmap Internet Strategist")
19
 
 
 
 
 
20
  Translations :
21
 
22
  French : [Frederic](http://www.fredserva.fr "French Translation")
23
 
 
 
24
  == Installation ==
25
 
26
  Wordpress : Extract the zip file and just drop the contents in the wp-content/plugins/ directory of your WordPress installation and then activate the Plugin from Plugins page.
@@ -56,6 +68,7 @@ You can download any of the number of trackback validation plugins which will ch
56
 
57
  Sometimes scripts can semi automate spam and they know what the checkbox name is so they can automatically tick it.
58
  Change the `checkbox name` value in the settings page to something new (like change the number) so the autmoated systems don't know what the checkbox is called any more
 
59
 
60
  == Screenshots ==
61
 
@@ -67,6 +80,21 @@ Change the `checkbox name` value in the settings page to something new (like cha
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
@@ -116,9 +144,9 @@ Change the `checkbox name` value in the settings page to something new (like cha
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
 
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
 
11
  == Description ==
12
 
13
+ [Upgrade to CommentLuv Pro For More Anti-Spam Heuristics](http://www.commentluv.com "Upgrade to CommentLuv Pro")
14
+
15
  This plugin will add a client side generated checkbox to your comment form asking users to confirm that they are not a spammer.
16
  It is a lot less trouble to click a box than it is to enter a captcha and because the box is genereated via client side javascript that bots cannot see, it should stop 99% of all automated spam bots.
17
 
18
  A check is made that the checkbox has been checked before the comment is submitted so there's no chance that a comment will be lost if it's being submitted by legitimate human user.
19
 
20
+ To combat the new 'learning' bots, this plugin adds dynamically named fields to the comment form so each post has a differently named field and value.
21
+
22
+ You can set the maximum amount of comments a user can have in the moderation queue to protect you from comment floods (provided you haven't approved any of the spammers comments before)
23
+
24
  You can get support and see this plugin in action at [Growmap](http://www.growmap.com/growmap-anti-spambot-plugin/ "Growmap Internet Strategist")
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 :
31
 
32
  French : [Frederic](http://www.fredserva.fr "French Translation")
33
 
34
+ Spanish : [Ramon](http://apasionados.es/ "Spanish Translation")
35
+
36
  == Installation ==
37
 
38
  Wordpress : Extract the zip file and just drop the contents in the wp-content/plugins/ directory of your WordPress installation and then activate the Plugin from Plugins page.
68
 
69
  Sometimes scripts can semi automate spam and they know what the checkbox name is so they can automatically tick it.
70
  Change the `checkbox name` value in the settings page to something new (like change the number) so the autmoated systems don't know what the checkbox is called any more
71
+ You can also change the secret key value and set the maximum comments in moderation to a lower number.
72
 
73
  == Screenshots ==
74
 
80
 
81
  == ChangeLog ==
82
 
83
+ = 1.5 =
84
+
85
+ * updated : max_mod is set at 3 by default
86
+ * updated : readme.txt updated
87
+
88
+ = 1.4.3 =
89
+ * updated : allow option of using referer check or not in settings
90
+ * updated : use dynamic input field name so each post uses a different value and can't be learned for the whole site
91
+ * added : allow user to set maximum comments that can be held in moderation before new comments can be added (from CommentLuv Premium)
92
+
93
+ = 1.4.2 =
94
+ * added : add a referer check to start of check_comment
95
+ * updated : notices about undefined index when debug turned on
96
+ * updated : check $_SERVER['HTTP_REFERER'] is set and die if not
97
+
98
  = 1.4.1 =
99
  * updated : improved code for checkbox and label to help with styling (thanks James)
100
  * updated : regex for saving secret key
144
 
145
  == Upgrade Notice ==
146
 
147
+ = 1.5 =
148
 
149
+ * added - better measures for combatting the new 'learning' bots by using dynamically named hidden fields
150
 
151
  == Configuration ==
152
 
screenshot-1.jpg CHANGED
Binary file