Growmap Anti Spambot Plugin - Version 1.01

Version Description

Download this release

Release Info

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

Code changes from version 1.0 to 1.01

growmap-anti-spambot-plugin.php → tags/1.0/growmap-anti-spambot-plugin.php RENAMED
File without changes
readme.txt → tags/1.0/readme.txt RENAMED
File without changes
screenshot-1.jpg → tags/1.0/screenshot-1.jpg RENAMED
File without changes
screenshot-2.jpg → tags/1.0/screenshot-2.jpg RENAMED
File without changes
screenshot-3.jpg → tags/1.0/screenshot-3.jpg RENAMED
File without changes
trunk/growmap-anti-spambot-plugin.php ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.01
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.01'
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'] < 0.4 ){
88
+ update_option('gasp_options',$default_options);
89
+ return $default_options;
90
+ }
91
+ if((float)$options['version'] < 1){
92
+ $options['version'] = '1.0';
93
+ update_option('gasp_options',$options);
94
+ }
95
+ return $options;
96
+ }
97
+
98
+ /** gasp_options_sanitize
99
+ * checks the options before they are saved
100
+ */
101
+ function gasp_options_sanitize($newoptions){
102
+ return $newoptions;
103
+ }
104
+
105
+ /** gasp_check_comment
106
+ * Called by preprocess_comment filter
107
+ * @param array $commentdata - array containing indices "comment_post_ID", "comment_author", "comment_author_email", "comment_author_url", "comment_content", "comment_type", and "user_ID"
108
+ * Return array updated comment data array or wp_die()
109
+ */
110
+ function gasp_check_comment($commentdata){
111
+ if(is_user_logged_in()){
112
+ return $commentdata;
113
+ }
114
+ $options = gasp_get_options();
115
+ if(!isset($_POST['gasp_checkbox'])){
116
+ wp_die($options['no_checkbox_message']);
117
+ } elseif (isset($_POST['gasp_email']) && $_POST['gasp_email'] !== ''){
118
+ wp_die($options['hidden_email_message']);
119
+ } elseif ($_POST['gasp_checkbox'] === 'on') {
120
+ return $commentdata;
121
+ }
122
+ return $commentdata; // not needed but put it here anyway
123
+ }
124
+
125
+
126
+ /*********************************************
127
+ * admin output
128
+ *********************************************/
129
+ /** gasp_options_page
130
+ * This function handles the page for options
131
+ */
132
+ function gasp_options_page(){
133
+ $options = gasp_get_options();
134
+ ?>
135
+ <div class="wrap">
136
+ <h2>Growmap Anti Spambot Plugin Settings Page</h2> Version <?php echo $options['version'];?>
137
+ <form method="post" action="options.php">
138
+ <?php settings_fields( 'gasp_options_group' );?>
139
+ <table class="form-table postbox">
140
+ <tr valign="top" class="alt menu_option postbox">
141
+ <td><?php _e('Checkbox Label','ab_gasp');?></td>
142
+ <td><input type="text" size="60" name="gasp_options[checkbox_label]" value="<?php echo $options['checkbox_label'];?>"/></td>
143
+ </tr>
144
+ <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>
145
+ <tr><td width="30%">
146
+ <?php _e('There is only 1 situation where this can happen','ab_gasp'); ?>
147
+ <ol>
148
+ <li><?php _e('The user forgot to check the checkbox','ab_gasp');?></li>
149
+ </ol>
150
+ </td>
151
+ <td><h2><?php _e('Checkbox not checked alert','ab_gasp');?></h2>
152
+ <input type="text" size = "95" name="gasp_options[checkbox_alert]" value="<?php echo $options['checkbox_alert'];?>" />
153
+ </td>
154
+ </tr>
155
+ <tr><td width="30%">
156
+ <?php _e('There is only 1 situation where this can happen','ab_gasp'); ?>
157
+ <ol>
158
+ <li><?php _e('The user does not have javascript enabled','ab_gasp');?></li>
159
+ </ol>
160
+ </td>
161
+ <td><h2><?php _e('No checkbox','ab_gasp');?></h2>
162
+ <textarea cols="60" rows="5" name="gasp_options[no_checkbox_message]" ><?php echo $options['no_checkbox_message'];?></textarea>
163
+ </td>
164
+ </tr>
165
+ <tr>
166
+ <td><?php _e('There is only one situation where this would happen','ab_gasp');?>
167
+ <ol>
168
+ <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>
169
+ </ol>
170
+ </td>
171
+ <td><h2><?php _e('Hidden email field completed','ab_gasp');?></h2>
172
+ <textarea cols="60" rows="5" name="gasp_options[hidden_email_message]" ><?php echo $options['hidden_email_message'];?></textarea>
173
+ </td>
174
+ </tr>
175
+ </table>
176
+ <input type="hidden" name="action" value="update" />
177
+ <input type="hidden" name="gasp_options[version]" value="<?php echo $options['version'];?>"/>
178
+ <p class="submit">
179
+ <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
180
+ </p>
181
+ </form>
182
+ <table class="form-table postbox">
183
+ <tr class="alt">
184
+ <td valign="top" width="150px">
185
+ This plugin was made by Andy Bailey (<a href="http://twitter.com/commentluv">@commentluv</a>)
186
+ <br/><p style="float:left; margin: 5px 5px 5px 0px;"><?php echo get_avatar('admin@comluv.com',48);?></p>
187
+ I make custom wordpress plugins for private sites and edit existing plugins to do what you need them to do!
188
+ </td>
189
+ <td>
190
+ </td>
191
+ <td valign="top" width="250px">
192
+ Some of my other plugins :
193
+ </td>
194
+ <td>
195
+ <ul><li><a href="http://wordpress.org/extend/plugins/commentluv/">CommentLuv</a>
196
+ <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>
197
+ <li><a href="http://wordpress.org/extend/plugins/twitterlink-comments/">TwitterLink Comments</a>
198
+ <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>
199
+ <li><a href="http://wordpress.org/extend/plugins/easy-amember-protect-lite/">Easy aMember Protect Lite</a>
200
+ <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>
201
+ </ul>
202
+ </td>
203
+ </tr>
204
+
205
+ </table>
206
+
207
+ </div>
208
+ <?php
209
+ }
210
+
211
+ /*********************************************
212
+ * public output
213
+ *********************************************/
214
+
215
+ /** gasp_add_checkbox
216
+ * Called by comment_form action
217
+ * Adds javascript to create a checkbox on the comment form
218
+ */
219
+ function gasp_add_checkbox(){
220
+ if(!is_user_logged_in()){
221
+ $options = gasp_get_options();
222
+ echo '<p id="gasp_p" style="clear:both;"></p>';
223
+ echo '<script type="text/javascript">
224
+ //v1.01
225
+ var gasp_p = document.getElementById("gasp_p");
226
+ var gasp_cb = document.createElement("input");
227
+ var gasp_text = document.createTextNode(" '.$options['checkbox_label'].'");
228
+ gasp_cb.type = "checkbox";
229
+ gasp_cb.id = "gasp_checkbox";
230
+ gasp_cb.name = "gasp_checkbox";
231
+ gasp_cb.style.width = "25px";
232
+ gasp_p.appendChild(gasp_cb);
233
+ gasp_p.appendChild(gasp_text);
234
+ var frm = gasp_cb.form;
235
+ frm.onsubmit = gasp_it;
236
+ function gasp_it(){
237
+ if(gasp_cb.checked != true){
238
+ alert("'.$options['checkbox_alert'].'");
239
+ return false;
240
+ }
241
+ return true;
242
+ }
243
+ </script>
244
+ <input type="hidden" id="gasp_email" name="gasp_email" value="" />';
245
+ } else {
246
+ echo '<!-- no checkbox needed by Growmap Anti Spambot Plugin for logged on user -->';
247
+ }
248
+ }
249
+ ?>
trunk/languages/ab_gasp.mo ADDED
Binary file
trunk/languages/ab_gasp.po ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Growmap Anti Spambot Plugin\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2010-10-13 16:53-0000\n"
6
+ "PO-Revision-Date: 2010-10-13 16:55-0000\n"
7
+ "Last-Translator: Andy Bailey <admin@comluv.com>\n"
8
+ "Language-Team: ComLuv.com GrowMap.com FeedBlitz.com <admin@comluv.com>\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
+ "X-Poedit-Language: English\n"
15
+ "X-Poedit-Country: UNITED KINGDOM\n"
16
+ "X-Poedit-SearchPath-0: ..\n"
17
+
18
+ #: Z:\firedwok_html\wordpress\wp-content\plugins\growmap-anti-spambot-plugin/growmap-anti-spambot-plugin.php:68
19
+ msgid "Settings"
20
+ msgstr ""
21
+
22
+ #: Z:\firedwok_html\wordpress\wp-content\plugins\growmap-anti-spambot-plugin/growmap-anti-spambot-plugin.php:79
23
+ msgid "Please check the box to confirm that you are NOT a spammer"
24
+ msgstr ""
25
+
26
+ #: Z:\firedwok_html\wordpress\wp-content\plugins\growmap-anti-spambot-plugin/growmap-anti-spambot-plugin.php:80
27
+ msgid "You may have disabled javascript. Please enable javascript before leaving a comment on this site."
28
+ msgstr ""
29
+
30
+ #: Z:\firedwok_html\wordpress\wp-content\plugins\growmap-anti-spambot-plugin/growmap-anti-spambot-plugin.php:81
31
+ msgid "You appear to be a spambot. Contact admin another way if you feel this message is in error"
32
+ msgstr ""
33
+
34
+ #: Z:\firedwok_html\wordpress\wp-content\plugins\growmap-anti-spambot-plugin/growmap-anti-spambot-plugin.php:82
35
+ msgid "Confirm you are NOT a spammer"
36
+ msgstr ""
37
+
38
+ #: Z:\firedwok_html\wordpress\wp-content\plugins\growmap-anti-spambot-plugin/growmap-anti-spambot-plugin.php:141
39
+ msgid "Checkbox Label"
40
+ msgstr ""
41
+
42
+ #: Z:\firedwok_html\wordpress\wp-content\plugins\growmap-anti-spambot-plugin/growmap-anti-spambot-plugin.php:144
43
+ msgid "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"
44
+ msgstr ""
45
+
46
+ #: Z:\firedwok_html\wordpress\wp-content\plugins\growmap-anti-spambot-plugin/growmap-anti-spambot-plugin.php:146
47
+ #: Z:\firedwok_html\wordpress\wp-content\plugins\growmap-anti-spambot-plugin/growmap-anti-spambot-plugin.php:156
48
+ msgid "There is only 1 situation where this can happen"
49
+ msgstr ""
50
+
51
+ #: Z:\firedwok_html\wordpress\wp-content\plugins\growmap-anti-spambot-plugin/growmap-anti-spambot-plugin.php:148
52
+ msgid "The user forgot to check the checkbox"
53
+ msgstr ""
54
+
55
+ #: Z:\firedwok_html\wordpress\wp-content\plugins\growmap-anti-spambot-plugin/growmap-anti-spambot-plugin.php:151
56
+ msgid "Checkbox not checked alert"
57
+ msgstr ""
58
+
59
+ #: Z:\firedwok_html\wordpress\wp-content\plugins\growmap-anti-spambot-plugin/growmap-anti-spambot-plugin.php:158
60
+ msgid "The user does not have javascript enabled"
61
+ msgstr ""
62
+
63
+ #: Z:\firedwok_html\wordpress\wp-content\plugins\growmap-anti-spambot-plugin/growmap-anti-spambot-plugin.php:161
64
+ msgid "No checkbox"
65
+ msgstr ""
66
+
67
+ #: Z:\firedwok_html\wordpress\wp-content\plugins\growmap-anti-spambot-plugin/growmap-anti-spambot-plugin.php:166
68
+ msgid "There is only one situation where this would happen"
69
+ msgstr ""
70
+
71
+ #: Z:\firedwok_html\wordpress\wp-content\plugins\growmap-anti-spambot-plugin/growmap-anti-spambot-plugin.php:168
72
+ msgid "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"
73
+ msgstr ""
74
+
75
+ #: Z:\firedwok_html\wordpress\wp-content\plugins\growmap-anti-spambot-plugin/growmap-anti-spambot-plugin.php:171
76
+ msgid "Hidden email field completed"
77
+ msgstr ""
78
+
79
+ #: Z:\firedwok_html\wordpress\wp-content\plugins\growmap-anti-spambot-plugin/growmap-anti-spambot-plugin.php:179
80
+ msgid "Save Changes"
81
+ msgstr ""
82
+
trunk/readme.txt ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Growmap Anti Spambot Plugin ===
2
+ Contributors: commentluv
3
+ Donate link:http://comluv.com/about/donate
4
+ Tags: comments, anti spam, spam, spambot, gasp, growmap
5
+ Requires at least: 2.9.2
6
+ Tested up to: 3.0.1
7
+ Stable tag: 1.01
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
+ = 1.01 =
73
+ * use different method to identify submitted form for forms that have a submit button with no id or name set (@dragonblogger)
74
+
75
+ == Upgrade Notice ==
76
+
77
+ = 1.01 =
78
+
79
+ * Fix for comment form submit button that has no ID or name set.
80
+
81
+ == Configuration ==
82
+
83
+ * You only need to specify which error messages to show when the user forgets to use the checkbox or no checkbox is present.
trunk/screenshot-1.jpg ADDED
Binary file
trunk/screenshot-2.jpg ADDED
Binary file
trunk/screenshot-3.jpg ADDED
Binary file