• Resolved mattshepherd

    (@mattshepherd)


    Long story short: I’ve had a stalker for over a decade, nothing legally actionable but a lonnnnng string of annoying phone calls, e-mails, forum posts and blog comments (which is why I’m here) that basically harangue me.

    I’ve tried eliminating one source of the constant bombardment by putting the first two digits of her IP address in my comments blacklist box on WP, but that doesn’t seem to have done anything (I imagine she’s got a modem that gets re-assigned a new IP when you power down and back up again).

    I’m wondering if there’s any way to block comments by some sort of geographical trackback: the IPs always track back to one company (Sympatico) in one city (Toronto), but the IP changes constantly. Yesterday it was 74.14.112.*; today it’s 76.64.48.*. Asterisks there for decency’s sake.

    “Regular” spam-tagging doesn’t work either — the person in question just keeps creating new freemail accounts to badger me with.

    Not looking for sympathy, legal advice, or anything else — I’m well-equipped psychologically, spiritually and legally to deal with this as much as possible — but it WOULD be helpful if I could configure WP to not accept any comments coming from an IP that tracks back to Sympatico modems or to Toronto, Ontario.

    I don’t think anyone else in Toronto would be much bothered by this, but it would eliminate one source of white noise that I have to clean out and delete on a daily basis.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    How are you tracking her IP addresses to Sympatico in Toronto currently?

    I’ve seen GeoIP plugins before, but not one to block comments. It’s an interesting problem.

    Thread Starter mattshepherd

    (@mattshepherd)

    For current tracking, I’m taking the IP from the Manage/Comments admin screen and running it through WHOIS.

    I wasn’t sure which forum this should be posted in (maybe it’s a requested feature?) but this one seemed to be the most “catch-all” for this sort of problem.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    I’m thinking of a simple solution. If you’re basically doing a reverse DNS lookup on her IP and seeing things like “hse-toronto-ppp123824.sympatico.ca”, then that may or may not be accurate, but either way it would be possible to block on it.

    This little plugin should block (mark as spam) any IP address that returns “toronto” in a reverse DNS lookup:

    <?php
    /*
    Plugin Name: Block Toronto
    */
    function anti_city($comment) {
    	$comment['user_ip'] = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] );
    	$hostname = strtolower(gethostbyaddr($comment['user_ip']));
    	if (strpos($hostname, 'toronto')!==FALSE) {
    		add_filter('pre_comment_approved', create_function('$a', 'return \'spam\';'));
    	}
    }
    add_action('preprocess_comment', 'anti_city', 1);
    ?>
    Thread Starter mattshepherd

    (@mattshepherd)

    Thanks a lot. I’ll give it a try. I’ve saved that as a .php file, uploaded it to the plugin folder, and activated it in the control panel — that should do it, right?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Yep. Make sure that you don’t have any blank lines at the end of the text file for the plugin however. The ?> should be the absolute end of the file, just like the <?php should be the beginning.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Blocking comments by geography?’ is closed to new replies.