WordPress.org

Ready to get started?Download WordPress

Forums

Disemvoweler? (14 posts)

  1. marky
    Member
    Posted 10 years ago #

    I'm just in the middle of upgrading from Movable Type, and there's a plugin I sorely need. If anyone know if this has been created, please let me know.
    Basically, it's a disemvoweler for comments. Any post that comes from a specific IP address gets all its vowels removed before displaying. :)
    In the past, this feature has worked like a charm in keeping the trolls permanently away, and I would hate for all my disemvoweled comments to re-appear when I officially switch over the WP.

  2. Beel
    Member
    Posted 10 years ago #

    I have not run across such an item but there is a blacklist hack in the wiki which you may wish to look over:
    http://wiki.wordpress.org/index.php/WPHacks?PHPSESSID=4b85404695d7a12ac5818cf730f13f9f

  3. marky
    Member
    Posted 10 years ago #

    Thanks for the link. Sadly, blacklisting isn't what I had in mind; I've found it to be no where near as effective as a publically embarrasing disemvowelment. :)
    If anyone would like to create such a plugin, I'm sure a few users (including myself) would greatly appreciate it! Thanks.

  4. sunshine
    Member
    Posted 10 years ago #

    I don't think I could do it (I am just learning/practising RegEx), but it seems to me that wouldn't be too difficult -- it uses RegEx and PHP can do this too.
    Someone wanna take this on?
    Here's a copy of the MT plugin Mark refers to, in case you aren't familiar with it. :)
    http://mt-plugins.org/archives/entry/disenvowelment.php

  5. haaseg
    Member
    Posted 10 years ago #

    Actually, I think the code you're looking for is listed as an example for str_replace on php.net.
    // Provides: Hll Wrld f PHP
    $vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
    $onlyconsonants = str_replace($vowels, "", "Hello World of PHP");

  6. Ryan Boren
    WordPress Dev
    Posted 10 years ago #

    Creating a disevoweler filter is easy. Integrating it into the moderation system is the harder part, especially if we want to make it a plugin that doesn't need to touch any core code. That would probably require some architectural additions to the moderation system. I'll try to come up with something.
    In the meantime, a brute force hack wouldn't be too hard if someone wants to take it head on.

  7. haaseg
    Member
    Posted 10 years ago #

    I'll take a crack at brute force:
    Open up template_functions.php and look for function comment_text();
    find the following line:
    echo $comment_text;
    and right before it add:
    $vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
    $badIPs = array("174.16.43.355","152.44.53.114");
    if (in_array($comment->comment_author_IP, $badIPs))
    {
    $comment_text = str_replace($vowels, "", $comment_text);
    }
    Obviously you'd want to replace the IPs above with those of the offending trolls.
    disclaimer: code is completely untested.

  8. marky
    Member
    Posted 10 years ago #

    Marvellous! Thank you. :-)

  9. haaseg
    Member
    Posted 10 years ago #

    Sweet. I wasn't sure how the whole apply_filter thing worked yet (yesterday was my first day to dive into the code). Your example has given me a bit of "applied experience" which will no doubt help in the future.

  10. marky
    Member
    Posted 10 years ago #

    I made a small modification to the plugin for those that are interested. It replaces the author's name with "troll" and removes any URL he/she may have posted. :-)
    function disemvowel($content) {
    global $comment, $disemvowelIPs;
    if (in_array($comment->comment_author_IP, $disemvowelIPs)) {
    echo "disemvowel";
    $content = preg_replace("/[aeiou]/i", '', $content);
    $comment->comment_author = "troll";
    $comment->comment_author_url = "";
    }
    return $content;
    }

  11. haaseg
    Member
    Posted 10 years ago #

    hmm... if you really want to expose them for what they are, you don't really want to mask their name like that though... I would suggest
    $comment->comment_author .= " is a troll";
    That will append "is a troll" to the end of the author's name. So if the troll's name is "Larry" is will show as "Larry is a troll"
    If you really want to make them mad, just publish their IP address...
    $comment->comment_author ,= " is a troll from ".$comment->comment_author_IP;
    That might be going a little overboard though.

  12. marky
    Member
    Posted 10 years ago #

    Clever, but my trolls used to leave fake (and often obscene) names. The disemvoweler works wonders, though. If anyone has a troll problem, I strongly recommend it over banning them. :-)
    Anyway, I made one more modification to the disemvowel function. Sometimes you may want to disemvowel a single comment without affecting past and future posts from the same IP address. With this modification, if you edit the comment to include [troll] as the first word in that comment, the comment will be disemvoweled.
    function disemvowel($content) {
    global $comment, $disemvowelIPs;
    $troll = ereg("^\[troll\]", $content);
    if (in_array($comment->comment_author_IP, $disemvowelIPs) || $troll) {
    if($troll)
    $content = substr($content, 7);
    $content = preg_replace("/[aeiou]/i", '', $content);
    $comment->comment_author = "troll";
    $comment->comment_author_url = "";
    }
    return $content;
    }

  13. ampersand
    Member
    Posted 9 years ago #

    Can someone tell me precisely where to insert the code Marky suggests, please? Or does it just go anywhere in template_functions.php?

    Thank you!

  14. Dalby
    Member
    Posted 8 years ago #

    I know this a very old thread but I wonder if anyone has tried to use this plugin (with Marky's amendment) with WP V2+ ?

    I get the msg "Warning: in_array(): Wrong datatype for second argument"

    The Codex URL is

    http://codex.wordpress.org/Plugins/Disemvoweler

    It looks like a very useful tool to try and defeat trolls.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.