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?
June 7th, 2004 at 10:48 pm
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.
June 8th, 2004 at 6:47 am
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
June 8th, 2004 at 6:58 am
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.
June 8th, 2004 at 5:23 pm
(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…
June 8th, 2004 at 10:43 pm
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];
June 9th, 2004 at 5:41 am
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.
June 9th, 2004 at 5:42 am
Kitten, that’s exactly what i was talking about.. sounds like the same functionality as the MT blackmailer thingo.
June 9th, 2004 at 6:41 am
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…
June 9th, 2004 at 5:08 pm
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.
June 10th, 2004 at 2:29 am
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?
June 10th, 2004 at 6:43 am
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)
June 11th, 2004 at 1:55 am
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.