########################################################################################################## # WordPress Blacklist Comment SPAM prevention coded by LaughingLizard http://dinki.mine.nu/word/ # # Compatible with all versions of WordPress http://www.mindfulmusings.net/weblog/ # ########################################################################################################## Instructions: 1) Unzip all files into the root of your hard drive. 2) Edit import_blacklist.php and change your database values 3) Open a browser and run import_blacklist.php. You should see some "Imported domain/regex" messages 4) (this step only valid for WP version 1.0) Edit wp-comments-post.php and look for this function: if ('manual' == $comment_moderation) { $approved = 0; } else if ('auto' == $comment_moderation) { $approved = 0; } else { // none $approved = 1; } Paste this right below it: $blacklists = $wpdb->get_results("SELECT domain FROM blacklist"); foreach ($blacklists as $blacklist) { $regex = "/".$blacklist->domain."/i"; if (@preg_match($regex, $url)) $approved = 0; if (@preg_match($regex, $email)) $approved = 0; if (@preg_match($regex, $comment)) $approved = 0; } All Done! Now when a spammer (whose website url or comment matches the given list) tries to leave a comment, it is set to be moderated by you. 5) (This step only valid for WP version 0.72 and below) Find this line in your b2comments.post.php: if ($ok) { // if there was no comment from this IP in the last 10 seconds And paste this after that line: $blacklists = $wpdb->get_results("SELECT domain FROM blacklist"); foreach ($blacklists as $blacklist) { $regex = "/".$blacklist->domain."/i"; if (@preg_match($regex, $url)) exit; if (@preg_match($regex, $email)) exit; if (@preg_match($regex, $comment)) exit; }