Growmap Anti Spambot Plugin - Version 1.0

Version Description

  • release version

=

Download this release

Release Info

Developer teamplaylotto
Plugin Icon wp plugin Growmap Anti Spambot Plugin
Version 1.0
Comparing to
See all releases

Version 1.0

growmap-anti-spambot-plugin.php ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.0
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
+
17
+
18
+ /*********************************************
19
+ * hooks
20
+ *********************************************/
21
+ if(is_admin()){
22
+ // admin hooks
23
+ add_action( 'admin_menu', 'gasp_admin_link' );
24
+ add_action( 'admin_init', 'gasp_admin_init' );
25
+ add_filter ( 'plugin_action_links', 'gasp_action' , - 10, 2 );
26
+ } else {
27
+ // public hooks
28
+ add_action('comment_form','gasp_add_checkbox',1);
29
+ add_filter('preprocess_comment','gasp_check_comment',1,1);
30
+ }
31
+ // everywhere hooks
32
+ add_action('init','gasp_init');
33
+
34
+ /*********************************************
35
+ * internal functions
36
+ *********************************************/
37
+
38
+ /** gasp_init
39
+ */
40
+ function gasp_init(){
41
+ load_plugin_textdomain( 'ab_gasp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
42
+ }
43
+ /** gasp_admin_init
44
+ * Sets up the admin pages and settings
45
+ */
46
+ function gasp_admin_init(){
47
+ register_setting( 'gasp_options_group', 'gasp_options' , 'gasp_options_sanitize');
48
+ }
49
+
50
+ /** gasp_admin_link
51
+ * Add link to settings panel in dashboard
52
+ */
53
+ function gasp_admin_link(){
54
+ // language
55
+ load_plugin_textdomain( 'ab_gasp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
56
+ add_options_page('Growmap Anti Spambot Plugin Settings','G.A.S.P.','manage_options','gasp','gasp_options_page');
57
+ }
58
+
59
+ /** gasp_action
60
+ * adds a link on the plugins page next to activate/deactivate to go to the settings page
61
+ * @param array $links - the links to be filtered
62
+ *@param string $file - the file whos links are being filtered
63
+ * return string $links - the new string of links
64
+ */
65
+ function gasp_action($links,$file){
66
+ $this_plugin = plugin_basename ( __FILE__ );
67
+ if ($file == $this_plugin) {
68
+ $links [] = "<a href='options-general.php?page=gasp'>" . __ ( 'Settings', 'ab_gasp' ) . "</a>";
69
+ }
70
+ return $links;
71
+ }
72
+
73
+ /** gasp_get_options
74
+ * Retrieves the options from the database.
75
+ * Returns saved options or defaults if no options have been saved.
76
+ */
77
+ function gasp_get_options(){
78
+ $default_options = array(
79
+ 'checkbox_alert' => __('Please check the box to confirm that you are NOT a spammer','ab_gasp'),
80
+ 'no_checkbox_message' => __('You may have disabled javascript. Please enable javascript before leaving a comment on this site.','ab_gasp'),
81
+ 'hidden_email_message' => __('You appear to be a spambot. Contact admin another way if you feel this message is in error','ab_gasp'),
82
+ 'checkbox_label' => __('Confirm you are NOT a spammer','ab_gasp'),
83
+ 'version' => '1.0'
84
+ );
85
+ $options = get_option('gasp_options',$default_options);
86
+ // update options with new defaults if upgrading from older version
87
+ if((float)$options['version'] < 1.0 ){
88
+ update_option('gasp_options',$default_options);
89
+ return $default_options;
90
+ }
91
+ return $options;
92
+ }
93
+
94
+ /** gasp_options_sanitize
95
+ * checks the options before they are saved
96
+ */
97
+ function gasp_options_sanitize($newoptions){
98
+ return $newoptions;
99
+ }
100
+
101
+ /** gasp_check_comment
102
+ * Called by preprocess_comment filter
103
+ * @param array $commentdata - array containing indices "comment_post_ID", "comment_author", "comment_author_email", "comment_author_url", "comment_content", "comment_type", and "user_ID"
104
+ * Return array updated comment data array or wp_die()
105
+ */
106
+ function gasp_check_comment($commentdata){
107
+ if(is_user_logged_in()){
108
+ return $commentdata;
109
+ }
110
+ $options = gasp_get_options();
111
+ if(!isset($_POST['gasp_checkbox'])){
112
+ wp_die($options['no_checkbox_message']);
113
+ } elseif (isset($_POST['gasp_email']) && $_POST['gasp_email'] !== ''){
114
+ wp_die($options['hidden_email_message']);
115
+ } elseif ($_POST['gasp_checkbox'] === 'on') {
116
+ return $commentdata;
117
+ }
118
+ return $commentdata; // not needed but put it here anyway
119
+ }
120
+
121
+
122
+ /*********************************************
123
+ * admin output
124
+ *********************************************/
125
+ /** gasp_options_page
126
+ * This function handles the page for options
127
+ */
128
+ function gasp_options_page(){
129
+ $options = gasp_get_options();
130
+ ?>
131
+ <div class="wrap">
132
+ <h2>Growmap Anti Spambot Plugin Settings Page</h2> Version <?php echo $options['version'];?>
133
+ <form method="post" action="options.php">
134
+ <?php settings_fields( 'gasp_options_group' );?>
135
+ <table class="form-table postbox">
136
+ <tr valign="top" class="alt menu_option postbox">
137
+ <td><?php _e('Checkbox Label','ab_gasp');?></td>
138
+ <td><input type="text" size="60" name="gasp_options[checkbox_label]" value="<?php echo $options['checkbox_label'];?>"/></td>
139
+ </tr>
140
+ <tr><td colspan="2"><p><?php _e('These are the messages you will show the user if they forget to check the checkbox or if the comment looks like it was submitted by a spambot','ab_gasp');?></p></td></tr>
141
+ <tr><td width="30%">
142
+ <?php _e('There is only 1 situation where this can happen','ab_gasp'); ?>
143
+ <ol>
144
+ <li><?php _e('The user forgot to check the checkbox','ab_gasp');?></li>
145
+ </ol>
146
+ </td>
147
+ <td><h2><?php _e('Checkbox not checked alert','ab_gasp');?></h2>
148
+ <input type="text" size = "95" name="gasp_options[checkbox_alert]" value="<?php echo $options['checkbox_alert'];?>" />
149
+ </td>
150
+ </tr>
151
+ <tr><td width="30%">
152
+ <?php _e('There is only 1 situation where this can happen','ab_gasp'); ?>
153
+ <ol>
154
+ <li><?php _e('The user does not have javascript enabled','ab_gasp');?></li>
155
+ </ol>
156
+ </td>
157
+ <td><h2><?php _e('No checkbox','ab_gasp');?></h2>
158
+ <textarea cols="60" rows="5" name="gasp_options[no_checkbox_message]" ><?php echo $options['no_checkbox_message'];?></textarea>
159
+ </td>
160
+ </tr>
161
+ <tr>
162
+ <td><?php _e('There is only one situation where this would happen','ab_gasp');?>
163
+ <ol>
164
+ <li><?php _e('The form has a hidden field added with a label that has a name value with the word "email" in it. A spam bot will usually try to fill in all fields on a form, if this field has been filled in then something is wrong','ab_gasp');?></li>
165
+ </ol>
166
+ </td>
167
+ <td><h2><?php _e('Hidden email field completed','ab_gasp');?></h2>
168
+ <textarea cols="60" rows="5" name="gasp_options[hidden_email_message]" ><?php echo $options['hidden_email_message'];?></textarea>
169
+ </td>
170
+ </tr>
171
+ </table>
172
+ <input type="hidden" name="action" value="update" />
173
+ <input type="hidden" name="gasp_options[version]" value="<?php echo $options['version'];?>"/>
174
+ <p class="submit">
175
+ <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
176
+ </p>
177
+ </form>
178
+ <table class="form-table postbox">
179
+ <tr class="alt">
180
+ <td valign="top" width="150px">
181
+ This plugin was made by Andy Bailey (<a href="http://twitter.com/commentluv">@commentluv</a>)
182
+ <br/><p style="float:left; margin: 5px 5px 5px 0px;"><?php echo get_avatar('admin@comluv.com',48);?></p>
183
+ I make custom wordpress plugins for private sites and edit existing plugins to do what you need them to do!
184
+ </td>
185
+ <td>
186
+ </td>
187
+ <td valign="top" width="250px">
188
+ Some of my other plugins :
189
+ </td>
190
+ <td>
191
+ <ul><li><a href="http://wordpress.org/extend/plugins/commentluv/">CommentLuv</a>
192
+ <br />An easy way to reward your readers and find out what they're posting about by automatically including a titled link to their latest blog post when they comment</li>
193
+ <li><a href="http://wordpress.org/extend/plugins/twitterlink-comments/">TwitterLink Comments</a>
194
+ <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>
195
+ <li><a href="http://wordpress.org/extend/plugins/easy-amember-protect-lite/">Easy aMember Protect Lite</a>
196
+ <br />A very quick and simple way to protect individual posts and pages on your Wordpress site from being seen unless the person trying to view has an active subscription to one of your aMember products (requires <a href="http://ql2.me/1/amember">aMember</a>)</li>
197
+ </ul>
198
+ </td>
199
+ </tr>
200
+
201
+ </table>
202
+
203
+ </div>
204
+ <?php
205
+ }
206
+
207
+ /*********************************************
208
+ * public output
209
+ *********************************************/
210
+
211
+ /** gasp_add_checkbox
212
+ * Called by comment_form action
213
+ * Adds javascript to create a checkbox on the comment form
214
+ */
215
+ function gasp_add_checkbox(){
216
+ if(!is_user_logged_in()){
217
+ $options = gasp_get_options();
218
+ echo '<p id="gasp_p" style="clear:both;"></p>';
219
+ echo '<script type="text/javascript">
220
+ var gasp_p = document.getElementById("gasp_p");
221
+ var gasp_cb = document.createElement("input");
222
+ var gasp_text = document.createTextNode(" '.$options['checkbox_label'].'");
223
+ gasp_cb.type = "checkbox";
224
+ gasp_cb.id = "gasp_checkbox";
225
+ gasp_cb.name = "gasp_checkbox";
226
+ gasp_cb.style.width = "25px";
227
+ gasp_p.appendChild(gasp_cb);
228
+ gasp_p.appendChild(gasp_text);
229
+ var sub = document.getElementById("submit");
230
+ sub.onclick= gasp_it;
231
+ function gasp_it(){
232
+ if(gasp_cb.checked != true){
233
+ alert("'.$options['checkbox_alert'].'");
234
+ return false;
235
+ }
236
+ return true;
237
+ }
238
+ </script>
239
+ <input type="hidden" id="gasp_email" name="gasp_email" value="" />';
240
+ } else {
241
+ echo '<!-- no checkbox needed by Growmap Anti Spambot Plugin for logged on user -->';
242
+ }
243
+ }
244
+ ?>
readme.txt ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Growmap Anti Spambot Plugin ===
2
+ Contributors: commentluv
3
+ Donate link:http://comluv.com/about/donate
4
+ Tags: comments, anti spam, spam, spambot
5
+ Requires at least: 2.9.2
6
+ Tested up to: 3.0.1
7
+ Stable tag: 1.0
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
+ == Installation ==
21
+
22
+ 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.
23
+
24
+ WordpressMu : Same as above (do not place in mu-plugins)
25
+
26
+ == Frequently Asked Questions ==
27
+
28
+ = Does this plugin add any database tables? =
29
+
30
+ No.
31
+
32
+ = Will this plugin work with Disqus/Intense Debate/js-kit? =
33
+
34
+ This will only work with the default Wordpress comments system.
35
+
36
+ = If I disable javascript will it still work? =
37
+
38
+ No. This plugin requires javascript to be enabled in the users browser for the comment to be accepted.
39
+
40
+ = The checkbox doesn't appear in my comment form =
41
+
42
+ The checkbox only appears for logged out users.
43
+ If you're logged out, it only shows if you have javascript enabled.
44
+ If you are logged out and have javascript enabled and it is still not showing then you need to have the comment form action active in your comments.php theme file
45
+ ` do_action('comment_form',$post->ID); `
46
+
47
+ == Screenshots ==
48
+
49
+ 1. settings page
50
+
51
+ 2. in use
52
+
53
+ 3. error message
54
+
55
+ == ChangeLog ==
56
+
57
+ = 0.1 =
58
+ * First version , commissioned by @phollows via @growmap
59
+
60
+ = 0.2 =
61
+ * tidied up options page and added field for checkbox label
62
+
63
+ = 0.3 =
64
+ * changed the hidden div with text type input to hidden input to prevent google toolbar from filling in the text field
65
+
66
+ = 0.4 =
67
+ * added client side alert if checkbox is not checked. @donnafontenot http://bit.ly/9Uqfxz
68
+
69
+ = 1.0 =
70
+ * release version
71
+
72
+ == Configuration ==
73
+
74
+ * You only need to specify which error messages to show when the user forgets to use the checkbox or no checkbox is present.
screenshot-1.jpg ADDED
Binary file
screenshot-2.jpg ADDED
Binary file
screenshot-3.jpg ADDED
Binary file