Skip to content

WP-DenyHost

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.

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-sourcehttp://soderlind.no/code/view/ps_wp_denyhost.php

Changelog (updated 28.12.2009):

v1.1.3: Fixed a minor bug
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

8 Comments

  1. Andrew

    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?

    Posted on 28-Dec-09 at 1:04 | Permalink
  2. PerS

    Thanks Andrew. “403 Forbidden” is added to v1.1.2

    Posted on 28-Dec-09 at 4:32 | Permalink
  3. 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.

    Posted on 28-Dec-09 at 5:38 | Permalink
  4. PerS

    Thanks ChipD, this was a bug. Fixed in v1.1.3

    Posted on 28-Dec-09 at 12:10 | Permalink
  5. Thank you very much, PerS; I appreciate your quick reply and fix. The automatic upgrade succeeded.

    Posted on 28-Dec-09 at 17:30 | Permalink
  6. Is there any button available? I thougt I found a documentation some time ago, but I really don’t remember…

    Posted on 22-Jan-10 at 12:11 | Permalink
  7. PerS

    Button ? What do you mean ?

    Posted on 23-Jan-10 at 17:40 | Permalink
  8. Mike Lemann

    Hi!
    I’ve got by activateing:
    Fatal error: Call to undefined function plugins_url() in /is/htdocs/wp1078111_GSWBBDOKG5/www/wp-content/plugins/wp-denyhost/ps_wp_denyhost.php on line 66

    any idea what das it mean?

    Posted on 12-Feb-10 at 18:01 | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*
Rodney's 404 Handler Plugin plugged in.