scriptygoddess

07 Jun, 2004

Clean up spam words

Posted by: Jennifer In: WordPress

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 | christian

June 7th, 2004 at 10:48 pm

Avatar

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 | Jennifer

June 8th, 2004 at 6:47 am

Avatar

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 | christian

June 8th, 2004 at 6:58 am

Avatar

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 | Jennifer

June 8th, 2004 at 5:23 pm

Avatar

(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 | Jennifer

June 8th, 2004 at 10:43 pm

Avatar

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 | Kitten

June 9th, 2004 at 5:41 am

Avatar

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 | christian

June 9th, 2004 at 5:42 am

Avatar

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

8 | Jennifer

June 9th, 2004 at 6:41 am

Avatar

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 | Kitten

June 9th, 2004 at 5:08 pm

Avatar

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 | Shelagh

June 10th, 2004 at 2:29 am

Avatar

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 | Jennifer

June 10th, 2004 at 6:43 am

Avatar

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 | Kitten

June 11th, 2004 at 1:55 am

Avatar

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.

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements