scriptygoddess RSS Feed
 
 
 
 

Clean up spam words

A few problems I have with the built in blacklist in wordpress is that 1) it's not alphabetized, and 2) it allows duplicates, 3) as well as spaces next to each listing.

I wrote a little script that will clean up the list – which you can load directly in a browser (change extension to .php and upload to your wordpress install directory) – it will clean up and then update your list – however, it would be great to integrate this directly into Wordpress. Anyone have any ideas where it would go, exactly?

12 Responses to “Clean up spam words”

  1. 1
    christian:

    You could (if you wanted to modify one of the WP files) drop the code you have there into the wp-admin/options.php file just under the // HACK section .. where all the updates occur, so possibly you check to see that moderation_keys was being updated, if so, after you've added the new entry, perform this funtion to clean up the information ?

    Just a thought.

  2. 2
    Jennifer:

    Well, one small problem with my script is that it adds an ending line break. Therefore any comment that has a line break will be thrown into "moderation".

    I removed the line break simply by going into the admin panel and stripping it out and saving the options again – (partially testing that out now) – But I'll need to modify my script so that it doesn't do that :)

    Once I do that – I'll try your suggestion christian :)

  3. 3
    christian:

    i haven't actually done much work with WP (still on MT .. but i'm slowly moving over) .. but it'd be interesting to sort of incorporate their URL auto-addition to the blacklist .. so u get a new comment email, you can see it's a spam comment.. click on a URL – the page pulls out all of the URL's from that spammed comment – adds them to the moderation_keys, removes the comment.

    I'm much more of a PHP programmer than PERL so modifying WP directly seems much easier to me.. but i just haven't got the time .. though when i do there's heaps of things i'd want to change in it.. i guess we'll just have to see what happens.

    Good luck with the rest of your mods/hacks/etc to WP.

  4. 4
    Jennifer:

    (I fixed the script so that it won't add the ending, extra new line) :)

    Now I just have to integrate it directly into the admin page…

  5. 5
    Jennifer:

    Just putting this here for my reference (and anyone else who's interested)

    I edited options.php (in wp-admin) and added this code:

    if ($option->option_name == 'moderation_keys') {
    $spamarray = explode("n", $new_val);
    $spamarray = array_unique($spamarray);
    sort($spamarray);
    $newmoderation = "";
    $cnt = 0;
    foreach ($spamarray as $spamvalue) {
    if ($cnt > 0) {
    $newmoderation .= "n";
    }
    if ($spamvalue != " ") {
    $newmoderation .= trim($spamvalue);
    $cnt++;
    }
    }
    $new_val = $newmoderation;
    }

    I put that code above just after the lines that looked like this (last line was 77?) :

    if ($user_level >= $option->option_admin_level) {
    $old_val = stripslashes($option->option_value);
    $new_val = $_POST[$option->option_name];

  6. 6
    Kitten:

    I did something similar, except it adds a "delete as spam" button to the mass edit page, then any comments being deleted as such, have their email address, IP, domain of the url, and the domain of any links in the comment body all added to the spam words list. Then the list is nicely sorted, and dupes removed.

  7. 7
    christian:

    Kitten, that's exactly what i was talking about.. sounds like the same functionality as the MT blackmailer thingo.

  8. 8
    Jennifer:

    kitten – can you optionally have it NOT add the email and IP, and just have it add the URLs you specifically indicate? The reason I ask is because very often the IPs are bogus, as well as the emails they use – and even the URLs are usually SUBDOMAINS of ONE URL. So if you can't go in and selectively indicate WHICH THINGS you want it to add – it may add alot more lines than you really need it to…

  9. 9
    Kitten:

    I'll reply in both places. Making the email/IP address to be options is no big deal, but have them become user choices each time it's run, it a bigger deal. Basically, there's no good way for a WP plugin to interact with the user. So to have a popup list of what was being added is quite an undertaking. If you have any ideas about the best way to go about it, I'm all ears.

  10. 10
    Shelagh:

    On a slightly different note, I wanted to add the MT Blacklist to my WP spamlist but it includes things like

    8th\S*street\S*latina\S*\.[a-z]{2,}

    Can WP cope with this?

  11. 11
    Jennifer:

    Shelagh – I copied my blacklist into a text editor and removed those lines (or added the base of whatever the line had)… If you want to copy what I have, there's a link in the sidebar to my blacklist – that is what i'm using in WP. I should warn you that some of the items are on the broad side… but with the way WP handles it, they'll just put the comment in "moderation" mode – and then you can decide if it's really spam or not (as opposed to mt-blacklist which wouldn't even allow the comment to go through at all – which, with broad terms, was more problematic)

  12. 12
    Kitten:

    On the user-options front, I've come up with a way to make the plugin fully customisable from the plugins page. Allowing for install/uninstall/and option setting via links in the plugin listing. I'll be rolling this out soon.

Categories

Archives

Bookmarks

WordPress Resources

Meta

ADVERTISEMENTS