Changeset 536369
- Timestamp:
- 04/25/2012 07:28:18 PM (14 years ago)
- Location:
- botblocker
- Files:
-
- 5 added
- 2 edited
-
tags/1.0.4 (added)
-
tags/1.0.4/botblocker.php (added)
-
tags/1.0.4/readme.txt (added)
-
tags/1.0.4/screenshot-1.jpg (added)
-
tags/1.0.4/styles.css (added)
-
trunk/botblocker.php (modified) (14 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
botblocker/trunk/botblocker.php
r533682 r536369 4 4 Plugin URI: http://www.lform.com/botblocker/ 5 5 Description: Kills spam-bots, leaves humans standing. No CAPTCHAS, no math questions, no passwords, just spam blocking that stops comment spam-bots dead in their tracks. 6 Version: 1.0. 36 Version: 1.0.4 7 7 Author: Lform Design (Brandon Fenning) 8 8 Author URI: http://www.lform.com/botblocker/ … … 11 11 12 12 /* 13 * TODO: Test all the way back to IE 5.514 * TODO: Test on WP 3.015 13 * TODO: add complete obscusfication 16 14 * TODO: add themeable error page hook option 17 15 * TODO: make honey pot togglable 18 16 * TODO: add unit tests 19 * BUG: When logged in as admin & commenting, flagged as spam bot17 * 20 18 */ 21 19 … … 27 25 protected $options; 28 26 protected $isSpam = FALSE; 27 protected $disabled = FALSE; 29 28 30 29 protected $debug = FALSE; … … 45 44 add_filter('pre_comment_approved',array( &$this, 'commentApproval' ), '99', 2 ); 46 45 add_action('comment_form_top', array( &$this, 'printError' )); 46 add_action('pre_comment_on_post', array( &$this, 'preventRawSubmit' )); 47 47 48 48 49 $this->options = $this->getWpOptions(); 49 50 $this->msg = &$_SESSION['_spamMsg']; 51 52 // # Used to access user data 53 //global $current_user; 54 //get_currentuserinfo(); 55 } 56 57 // # Prevents spammers from directly submitting comments to wp-comments-post.php 58 function preventRawSubmit() { 59 $fieldName = $this->getHoneyPotName(); 60 if (!$this->disabled && !isset($_POST[$fieldName])) { 61 $this->isSpam = TRUE; 62 wp_die(__('<strong>ERROR</strong>: '.$this->getErrorMsg())); 63 } 64 50 65 } 51 66 … … 65 80 } 66 81 82 function getErrorMsg() { 83 84 $options = $this->getOptions(); 85 86 if ($options['honeypot_reaction'] == 'Block') { 87 $approved = '0'; 88 $errorMsg = $options['honeypot_error_msg_block']; 89 } 90 else if ($options['honeypot_reaction'] == 'Spam') { 91 $approved = 'spam'; 92 $errorMsg = $options['honeypot_error_msg_flag']; 93 } 94 else if ($options['honeypot_reaction'] == 'Hold') { 95 $approved = '0'; 96 $errorMsg = $options['honeypot_error_msg_hold']; 97 } 98 99 return ($options['honeypot_error_msg'].' '.$errorMsg); 100 101 } 102 67 103 function commentApproval($approved, $commentData) { 68 104 … … 70 106 71 107 $options = $this->getOptions(); 72 108 /* 73 109 if ($options['honeypot_reaction'] == 'Block') { 74 110 $approved = '0'; … … 85 121 86 122 $this->logError($options['honeypot_error_msg'].' '.$errorMsg); 123 */ 124 125 $this->logError($this->getErrorMsg()); 87 126 88 127 if ($options['honeypot_error_type'] == 'Die') { … … 113 152 return FALSE; 114 153 } 115 116 function ge nerateHoneypot($fields) {117 $options = $this->getOptions(); 118 154 155 function getHoneyPotName() { 156 $options = $this->getOptions(); 157 119 158 $additionalRandom = ''; 120 159 if ($options['honeypot_random'] == 'Yes') { 121 160 $additionalRandom = $this->getAdditionalRandom(); 122 161 } 162 163 if ($options['honeypot_method'] == 'Smart') { 164 $todaysDecoy = $this->getTodaysDecoy($options['fields']); 165 $honeypotName = $additionalRandom.$todaysDecoy; 166 } 167 else if ($options['honeypot_method'] == 'Static') { 168 $honeypotName = $additionalRandom.$options['honeypot_field']; 169 } 170 else { 171 $todaysRandom = $this->getTodaysRandom(); 172 $honeypotName = $additionalRandom.$todaysRandom; 173 } 174 return $honeypotName; 175 } 176 177 function generateHoneypot($fields) { 178 $options = $this->getOptions(); 179 180 // # Update field cache 181 $fieldList = array_keys($fields); 182 $fieldList = array_combine($fieldList, $fieldList); 183 if ($fieldList != $options['fields']) { 184 $options['fields'] = $fieldList; 185 update_option("BotBlocker_options", $options); 186 } 187 188 $additionalRandom = ''; 189 if ($options['honeypot_random'] == 'Yes') { 190 $additionalRandom = $this->getAdditionalRandom(); 191 } 123 192 124 193 if ($options['obfuscation'] == 'Swap Email and Name') { … … 129 198 // # Todo: Add ability to completely obfuscate the field names with random characters 130 199 } 131 200 201 $honeypotName = $this->getHoneyPotName(); 202 203 /* 132 204 if ($options['honeypot_method'] == 'Smart') { 133 205 $todaysDecoy = $this->getTodaysDecoy($fields); … … 141 213 $honeypotName = $additionalRandom.$todaysRandom; 142 214 } 215 */ 216 143 217 144 218 $honeyClass = ''; … … 164 238 165 239 function preprocessComment() { 240 //# Disable plugin for logged in users so theyre not flagged as spam. 241 if (is_user_logged_in()) { 242 $this->disabled = TRUE; 243 } 244 166 245 $additionalRandom = ''; 167 246 $options = $this->getOptions(); … … 216 295 217 296 if ($isSpam) { 218 $this->isSpam = TRUE; 297 $this->isSpam = TRUE; 298 } 299 300 if ($this->disabled == TRUE) { 301 $this->isSpam = FALSE; // # Logged in users not flagged as spam. 219 302 } 220 303 … … 223 306 //get_currentuserinfo(); 224 307 225 if (is_user_logged_in()) { // # Logged in users not flagged as spam.226 $this->isSpam = FALSE;227 }308 //if (is_user_logged_in()) { 309 // $this->isSpam = FALSE; 310 //} 228 311 229 312 return $comment; … … 330 413 'honeypot_reaction'=>'Block', 331 414 'obfuscation'=>'Swap Email and Name', 332 'seed'=>rand(0,99999), 415 'seed'=>rand(0,99999999), 416 'fields'=>array(), // # Caches fields for smart system 333 417 ); 334 418 add_option("BotBlocker_options",$options); -
botblocker/trunk/readme.txt
r533682 r536369 2 2 Contributors: brandonfenning 3 3 Donate link: http://www.lform.com/ 4 Tags: comments, spam, akismet, captcha, bot, comment spam, anti-spam, block, blocker, botblocker, bot blocker, reduce spam 4 Tags: comments, spam, akismet, captcha, bot, comment spam, anti-spam, block, blocker, botblocker, bot blocker, reduce spam, plugin 5 5 Requires at least: 3.0 6 6 Tested up to: 3.3.1 7 Stable tag: 1.0. 37 Stable tag: 1.0.4 8 8 9 9 Kills spam-bots, leaves humans standing. No CAPTCHAS, no math questions, no passwords, just spam blocking that stops spam-bots dead in their tracks. … … 52 52 == Changelog == 53 53 54 = 1.0.4 = 55 * Fixed bug with mechanism that prevents comments from directly being submitted to wp-comments-post.php. 56 54 57 = 1.0.3 = 55 58 * Fixed bug that caused logged in users & admins to be flagged as spam bots. Registered users & admins will no longer be filtered by the spam bot system.
Note: See TracChangeset
for help on using the changeset viewer.