This is a plugin that will block a spammer if he already has been tagged as a spammer. I use it together with the Akismet plugin. Akismet tags the spammer, and wp-denyhost prevents him from adding more comment spam.
PS_DENYHOST_THESHOLD gives him a grace, this is to prevent an innocent commenter, with comments wrongly tagged as spam, from being blocked. You can set this as low as 1.
Core functionality :
define('PS_DENYHOST_THRESHOLD', 5);
function ps_denyhost() {
global $wpdb;
$suspect = $this->get_IP();
$count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_author_IP = '$suspect'");
if ($count > PS_DENYHOST_THRESHOLD) {
exit;
}
}
add_action('init', 'ps_denyhost');
Download / install: http://wordpress.org/extend/plugins/wp-denyhost/
view-source: http://soderlind.no/code/view/ps_wp_denyhost.php
Changelog (updated 28.12.2009):
v1.1.3: Fixed minor bug
v1.1.2: Added response 403 Forbidden
v1.1.1: Added languages/wp-denyhost.pot
v1.1.2: Added response 403 Forbidden
v1.1.1: Added languages/wp-denyhost.pot
v1.1.0: Major rewrite. Added option page
v1.0.1: Replaced LIKE (‘%$suspect%’) with = ‘$suspect’ i.e. look for exact match
v1.0: Initial release
7 Comments
Great plugin.
Have a request though: Would like to be able to send spammers to a 403 Forbidden page instead of 404 not found page. I have a 404 notifier feature set up to alert me when people can’t find content, and so sending spammers to a 404 error page is not ideal. Redirecting to Google is not ideal either.
Can this be implemented?
Thanks Andrew. “403 Forbidden” is added to v1.1.2
If you add /blog/ to the website address, you find the blog, under development. I noticed something when I looked at source code of blog homepage:
the path includes an extra blog/ subdirectory! like this:
http://www.example.com/blog/blog/wp-content/plugins/wp-denyhost/ps_wp_denyhost.php?ps_wp_denyhost_javascript&ver=2.9
I don’t understand why this happened. I installed by the wp-admin dashboard.
Thanks ChipD, this was a bug. Fixed in v1.1.3
Thank you very much, PerS; I appreciate your quick reply and fix. The automatic upgrade succeeded.
Is there any button available? I thougt I found a documentation some time ago, but I really don’t remember…
Button ? What do you mean ?
Post a Comment