now/Mass Delete for 1.5

now/Content

Back in September of 2004 I released a plugin that allowed you to delete large amounts of spam with one click.

Some backstory

Basically one afternoon I was hit with a wave of spam that resulted in 1500+ comments awaiting moderation that were all spam.  That was not a fun prospect, deleting all of those comments via the admin UI.  So I took a trip to the terminal and issued one command, which wiped them all out.

So taking that experience I created a plugin that allowed you to delete comments by author, IP, email or URI.  Now fast forward to WordPress 1.5.  1.5 has some wonderful toosl to help you combat spam built in, a blacklist feature, moderation by keywords and so on.  At first I was stoked at how well these tools were working, I didn’t see any real waves of spam hitting my site, I was assuming that 1.5 was sending all that evil to /dev/null/ like a good little monkey.

I however, was very wrong.

Apparently the DEVs decided that what should happen is that anything that is considered spam will be flagged as such: ‘spam’ and kept in the comments table in all our databases.  I still fail to see the usefullness of this, but that was not my call.  The point is that I was in my DB mucking around, as I am want to do, and found that I had 1500+ “spam” comments just hanging around in my comments table, with no way to interact with them from within WP.  Now for me, that really isn’t a big deal, I just fire up the old terminal, or open phpMyAdmin and delete them that way.  For the normal user though, that is another story.

Enter Spam Nuke

spam nuker!

So I being the good samaritan I am, raised a feature request bug about this, and was basically told that you should just issue the "DELETE from wp_comments WHERE comment_approved = 'spam'"; which my friends is crap.  The normal user who cares about the size of thier DB should be able to easily and quickly get rid of that chaff from within WordPress.

Well now you can.

I had been meaning to update Mass Delete for 1.5 for some time.  This answer from the DEVs gave me the impetus I needed to get it done.  This new version serves two purposes:

Getting to the features

You can still delete groups of spam as you did originally, only now Mass Delete only deletes from comments flagged as spam, when you are successful you see this message:

nuke some

The new feature is Mass Nuke, with one click you can nuke every comment in your table that is flagged as spam, when run successfully you see this message:

nuke em all!

Not really much to it, really.  Once the plugin is activated you can find it in the Manage submenu, there will be a selection labeled Spam at the end.

Here is the file you need cjd_delete.zip.  Enjoy and let me know if you find any bugs, or have any comments.

now/Information




comment/Content

comment/Information


  1. personal avatar

    Spam

    Chris Davis has a wonderful plugin for WP 1.5 that deletes any/all spam from your comments database. Apparently, when we mark comments as spam. Wordpress still saves those comments in the database, but marks them as spam. There is no way to see what is…



  2. personal avatar

    Best. Plugin. EVER.

    Seriously, it found 304 messages marked as spam in the database for one of the WordPress installations I maintain. I love it.



  3. personal avatar

    And to think that I was overjoyed to see a ‘spam’ marker for comments!
    Well, immense thanks for the plug.



  4. personal avatar

    We flag them as spam rather than outright deleting them in order to give plugin authors (such as yourself) something to keep you busy ;)

    No, seriously. I think we will eventually add something (unobtrusive) in the admin interface to let you delete them. But there is value in saving them. First of all, because some small fraction of users might want to review the data for finding false-positives. And also because the data can be used for Bayesian analysis.



  5. personal avatar

    Thanks Chris. I can’t tell you how long I’ve been looking for a plugin like this. I appreciate your effort. :)

    If you have a sliver of time, could you email me? I’ve got an idea for a simple Wordpress plugin and believe me, if I knew how to write a plugin (yeah, I’ve read the tutorial floating around the net) I’d do it myself.



  6. personal avatar

    You are a genius. Ill be trying that plugin real soon. From what I have read so far is that, this is the most awesome spam deletion tool! Great work man! Oh, and congratulations again on the parenthood!



  7. personal avatar

    Another extremely useful plugin. Not that running a SQL query is big problem for me, but I’m sure it is for many…and well, this way’s easier.

    Thanks for being the good samaritan you are! :D



  8. personal avatar

    Great update Chris. I had forgotten about all the spam I had in my table from moderation. And now they are all gone.

    All spam Nuked! Rowr! I love it!



  9. personal avatar

    What a nice plugin - works like a charm. And here I had thought that the messages I marked as spam were deleted completely. Well - not only have you made me aware of that - you also made it easy for me to get rid of’em. Thanks! :)



  10. personal avatar
    The end user should never have to go to the DB or phpMyAdmin to do something.

    Well the answer to the bug was very targetted, because users would never know the spam existed unless they used this plugin (which I wouldn’t advise) or they looked at the database. We’ll never be able to have a decent bayesian filter unless we have a good corpus of ham AND spam comments.



  11. personal avatar

    Dougal,

    We flag them as spam rather than outright deleting them in order to give plugin authors (such as yourself) something to keep you busy ;)

    I appreciate you guys looking out for me like this, brings a tear to my eye…

    No, seriously. I think we will eventually add something (unobtrusive) in the admin interface to let you delete them. But there is value in saving them. First of all, because some small fraction of users might want to review the data for finding false-positives. And also because the data can be used for Bayesian analysis.

    I agree that there is some value to saving the comments flagged as spam, my point was that the answer I got was crap, it took me 10 minutes to adapt some of my old code to do this, I assume it would have taken you who are code-gods much less time.

    The end user should never have to go to the DB or phpMyAdmin to do something. And for the record had I not been cleaning out my table via the terminal until I had this done, I would have around 3000 spam comments in my DB, and that is only since I installed whatever build of 1.5 that incorporated this, think about had I gone a year without checking my DB.

    Lets just say I have been running like this for 2 months. 3,000 commments every two months becomes 3,000 X 6 = 18,000 comments that are spam. And I would have never known. This is unnaceptable from an end user standpoint.

    That was my point, this should have been provided by the core, not a plugin, but what do I know, right? ;)



  12. personal avatar
    …users would never know the spam existed unless they used this plugin (which I wouldn’t advise) or they looked at the database. We’ll never be able to have a decent bayesian filter unless we have a good corpus of ham AND spam comments.

    ooh…I LOVE being an unknowing guinea-pig. Thanks Chris for your fix.



  13. personal avatar

    Also, I may not agree with the plugins you make but I’ll fight to the death for your ability to make them. :)



  14. personal avatar

    Matt,

    Well the answer to the bug was very targetted, because users would never know the spam existed unless they used this plugin (which I wouldn’t advise) or they looked at the database. We’ll never be able to have a decent bayesian filter unless we have a good corpus of ham AND spam comments.

    Agreed, I just don’t think that the way you chose to implement this is the best way. Period. But again, that is my opinion and I am able to fix what I see as a hole on my own, aint open source grand?

    Also, I may not agree with the plugins you make but I’ll fight to the death for your ability to make them. :)

    And that my friend is why I am still here, and why I work with you to hoepfully make this a product that surpasses all expectations. I don’t have a problem with the project lead not agreeing with me when I rant. ;)

    Oh and get a freakin gravatar!



  15. personal avatar

    Thank you Chris, thank you thank you thank you!

    It’s just what I’ve been looking for



  16. personal avatar

    Yeah Matt sort yourself out, you lazy bum :). The power of open source is all too great.



  17. personal avatar

    I must be the first person for it not to work :( Installation, no problem; visible in the plugins management area, no problem; clicking on the button to “nuke ‘em all” sends it off to do its work. But the spam is still there. all 439 instances. :( I am guessing its a server config issue but because I have no clue regarding those things (and no control over the server config in any case) i am stumped. Everything *looks* as if its working but the spam doesnt get nuked.

    any clues at all?



  18. personal avatar

    Matt,

    We’ll never be able to have a decent bayesian filter unless we have a good corpus of ham AND spam comments.

    Well, why don’t you just have a “delete spam comments silently” checkbox in the admin interface. If the box was checked the spams would be deleted, if it was unchecked the current behavior would take place. This would allow the user to decide.



  19. personal avatar

    I never new all the spam comments stayed in the DB once marked as Spam, so this plugin is a revaltion! Installed and i had 394 Spam comments! Brill plugin. :)



  20. personal avatar

    Thanks! Your plug-in works wonders.



  21. personal avatar

    Thanks for the quick response.

    I can admit the validity of some of your points, much better stated this time around!

    I am stil l not convinced on the usefullness of a large spam/ham farm as opposed to a small, targeted one.

    But time will tell, and I am willing to wait to find out.



  22. personal avatar

    The IP information is likely worthless, but the URIs are valuable, as are the keywords they use. Spam Karma 2 is going to use that information in some way. It is already useful in Spam Karma 1 (with a one line modification) to save comments as “spam” instead of dropping them entirely, because if you see a legit comment in your SK digest, it can easily be restored (using ColdForged’s plugin for viewing and editing spam comments).

    My use of the word “yahoo” wasn’t meant to refer to people who have massive quantities of spam in their database and want to trim it down… I was more referring to a casual user who might see a “delete spam instead of saving it” option and think “heavens, I don’t want to save spam!” and thus any benefit of being able to take past spam into consideration would be severely muted because of the ease with which yahoo — er, people, could disable it.

    Also, I can see how a buildup of spam could be a problem in the long term (or short term if you have a massively popular site). That is a problem that needs to be addressed. There should be a limit to how many spams are stored in the database, or things will eventually get out of hand. I think I’ll suggest that in Mosquito.

    No snarkiness taken. And I apologize if my first comment implied that people don’t have a right to the contents of their database. I don’t think that at all. You absolutely have a right to it. I just think that if you put a “delete spam instead of saving it” option in there, people will opt to can the spam instead of saving it for possible future benefit. I think the best compromise is to limit the number of comments so that your concerns about database bloat are addressed, but there is enough of a spam base for anti-spam plugins to use to fight future spam.



  23. personal avatar

    I am not even sure where to begin Mark.

    I am not sure what amazes me more, that you think that having a spam farm full of information that is most likely spoofed, and therefore of no real value is good, or that I and all the other users, what did you call them… “yahoos” that was it, out there have no right to the contents of our databases.

    And I am not sure what kind of traffic you are generating, but I assure you that the spam comments that would be “hanging out” in my DB are like stinking rats, since I would have tens of thousands at the end of even a few months. That is unacceptable.

    And I appreciate you giving me permission to delete the spam in my db, thanks for that. *edit* I don’t want to be snarky, that is not my intent, I do appreciate your comment I just don’t see the logic.



  24. personal avatar

    I’m rather confused as to what problem this is solving. This isn’t like a rat who dies in your wall and starts to stink after a few days… spam sitting hidden in your database does you no harm, and one day (rather soon, actually), it will be used to better identify blog spam. It seems to me that this appeals to the obsessive compulsive types who, now that they know spam is lurking in their database, are losing sleep. “Everywhere I turn, I can’t see them, but I know they’re there… I feel them watching me! Ahhhh!”

    As to providing an option… and forgive me for going all Socialist on you… sometimes things need to be done in order to benefit the largest possible number of users. If you want to purge the invisible spam, more power to you, but it shouldn’t be included in the core so that any yahoo can limit their spam-fighting abilities with a single click.

    Also, I may not agree with the plugins you make but I’ll fight to the death for your ability to make them.

    What he said. :-)



  25. personal avatar

    sweeet it worked for me :)



  26. personal avatar

    Thank you so much! Until I stumbled upon your site, I didn’t have a clue that all the spam was in my database (duh!!!) Thank you again! :-)



  27. personal avatar

    Worked great; thanks!



  28. personal avatar

    This is the single best WP plug-in I’ve ever downloaded. Thanks for doing this.



  29. personal avatar

    Lovely! And much less of a chore than remembering to ssh out to my host and do SQL things.

    Thanks for this, as well as your many other fine contributions that make my life easier.



  30. personal avatar

    No, that should read as it does,

    Be warned this is undoable.”

    And as for the sorting, I am fairly confident that a valid commenter will be showing up in singles, not in multiples.

    But I have been investigating how to modify the code to allow for differing sorts.



  31. personal avatar

    There appears to be a small error in the text:
    “Be warned this is [missing word?] undoable …”



  32. personal avatar

    Or possibly:
    tr '\r' '\n' <cjd_delete.php >cjd_delete.php.unix; mv cjd_delete.php.unix cjd_delete.php



  33. personal avatar

    Thanks!

    The Unspam menu would be easier to use if it could be sorted by a column other than IP.



  34. personal avatar

    Great plug-in, thank you! Worth it for the “unmark as spam” option alone.

    This didn’t work out of the box for me when I unzipped it under linux. The “Enable plugins” screen became garbled with the contents of the raw php file. I’m guessing this is because you developed this on a Mac which handles endline characters differently.

    If anyone other linux user is having the same problem, the following converts the code to unix format:
    tr '\r' '\n' cjd_delete.php.unix && mv cjd_delete.php.unix cjd_delete.php

    Hope this helps a few more linux newbies enjoy the fruits of your work!



  35. personal avatar

    […] der: race — Anton @ 21:42 Ron Paul’s remarks on the war, to the House useful spam-handling plugin for WordPress 1.5 a gag about clashing jargons Sheldon Richma […]



  36. personal avatar

    Anton is correct - apologies for the typo above in which I’ve somehow missed out a vital chunk of the command sequence. Thanks for correcting this.



  37. personal avatar

    Oh. How is it undoable? (And why the warning?)

    Yes, a valid commenter is likely to be unique, and thus harder to spot if the sorting is effectively random. Each dummy domain tends to occupy several rows of the table with different IPs; the false positive does not stand out.

    If the table were sorted on the name, it would be easier to find the one whose name is not some variant of “poker”. If it were sorted on the URL, it would be easier to find the one that is not in a “dummy domain of the day”.



  38. personal avatar

    […] m any popular search engine. Search Pages, to allow pages to be searched as well as posts. Spam Nuker, to manage spam deleted by WordPress’ default anti-spam tools. Translator, […]



  39. personal avatar

    […] Hmmm… it seems WP doesn’t delete the comments that you mark as spam from the moderation queue; it simply marks them in the database and doesn’t display them, maybe as a precursor for using them to generate anti-spam software or dbs. Now I know that, seems like I have some db cleaning to do. There’s even a plug-in for this. […]



  40. personal avatar

    Excellent! Thank you so much - had no idea those peskie lumps of spam were still hanging around

    All nuked!!

    :)



  41. personal avatar

    Excellent plugin. I didn’t even know that those little spam-spawn were still in my database. Thanks!



  42. personal avatar

    […] And there’s more…I found a neat little plugin called Spam Nuke. It seems that when we delete a comment as spam, we’re not actually deleting it…it’s being kept in the comments table in our databases. Interestingly enough, when I installed this little plugin I discovered 1833 tucked away in a dark corner. They have since been “nuked”. In light of all this new armour, I’ve turned off moderation. I hope I don’t live to regret that. […]



  43. personal avatar

    […] But then the bandwidth messages started coming, and after looking at the logs, I learned a new phrase: “referer spam.” Online poker and prescription meds were hitting me every couple of minutes. Their goal is to get a link embedded in as many databases as they can, increasing their rankings in search engines. Because of Hashcash, they weren’t making it into the database (CJD Spam Nuke keeps track of that), but were still showing up in the logs, meaning they were eating up my bandwidth. […]



  44. personal avatar

    All spam Nuked! Rowr!

    I’ve just checked the database for this site and found a whopping 717 spam comments in the DB that had been moderated. It seems WP doesn’t delete them when you moderate, it just marks them as spam and doesn’t publish them. Well, tha…



  45. personal avatar

    Much like many of the others said, I had no idea that when I marked a comment as “spam” it was still chillin’ in my DB. Thanks for the plug-in! I like order…



  46. personal avatar

    Comment Spam and Mass Delete

    Recently I’ve had a rash of comment spam, of course it’s all been in moderation though. the problem then becomes one of database size. After marking a comment as spam, it stays in the database to help in the future….I wanted to get…



  47. personal avatar

    WP - Mass Spam Nuke German (Plugin)

    Click mich !

    In den vergangenen Tagen hat Kylaloo einen Beitrag veröffentlicht, bei dem er seine Probleme mit Spam schildert. Auch ich hatte Probleme mit Spam-Kommentaren und änderte dies über ein Plugin. Nun erfährt der aufmerksame Leser vo…



  48. personal avatar

    3333 spam comments in my db counts PHPadmin. One click with ur great Plugin and they all gone to nirvana.
    Thx a lot from a german user



  49. personal avatar

    […] Außerdem sind ein paar neue Plugins installiert worden bzw. ein paar Plugins gelöscht worden. Die neuen Plugins heißen Bad Behavior, Spam Nuker, Dofollow und Google Sitemaps. […]



  50. personal avatar

    […] And there’s more…I found a neat little plugin called Spam Nuke. It seems that when we delete a comment as spam, we’re not actually deleting it…it’s being kept in the comments table in our databases. Interestingly enough, when I installed this little plugin (on my main site) I discovered 1833 tucked away in a dark corner. They have since been “nuked”. […]



  51. personal avatar

    […] 1) Mass Delete 1.5 (AKA “Spam Nuker”) […]



  52. personal avatar

    […] Leider werden als Spam gekennzeichnete Eintr



  53. personal avatar

    […] Apropos Spam und Wordpress. Moderierte Kommentare können bekanntlich mit der Option “mark as spam” als Spam markiert werden. Wer jedoch denkt, damit wird eine Art Blacklist gefüttert, mit der ähnliche Kommentare zukünftig unterbunden werden, liegt falsch. Die Funktion markiert diese Kommentare lediglich als Spam und speichert sie; mit dem Ergebnis, dass die MySQL-Datenbank langsam zumüllt. Also ziemlich sinnlos, zumal man die Spam-markierten Kommentare über Wordpress nicht mehr löschen kann. Das geht nur direkt in der Datenbank über phpMyAdmin oder komfortabler über das Wordpress-Plugin Mass Delete.   [link] […]



  54. personal avatar

    Fighting Spam…

    To help me fight comment spam from my blogs, I’ve decided to try out Spam Karma 2 and CJD Spam Nuke. So far they are all doing well.



  55. personal avatar

    Very handy little tool. Thanks for it. I hate spam and any invention to make it go away easier is dearly loved. :-)



  56. personal avatar

    Wow! I’ve just installed this. I’ve just recently started getting stupid spam comments from online poker and all that shiznay, and phpadmin is a bit screwwy on my computer. Thank you for making this, I’m a bit of a newbie, so this is UBERhelpful!



  57. personal avatar

    I take it this works OK with Wordpress 2.0.x? I hope so as I’ve just nuked 45 spam comments with it! I really don’t want those cluttering up my database. Thanks for the plugin.



  58. personal avatar

    […] Die eingehenden Kommentare werden in zwei getrennten Listen für durchgelassene Kommentare und Spam aufgeführt. Hier ist neben den allgemeinen Angaben (Datum, Zeit, Absender, Bezugsartikel und Anrisstext) auch die Filterergebnisses, die zur Übernahme oder Abweisung geführt haben protokolliert (wichtig für ggf. notwendiges Feintuning). In der Übersicht mit dem (vermeintlichen) Spam kann man einzelne Kommentare auch recovern. Hierüber kann man auch Kommentare recovern, die man manuell über die normale Kommentarübersicht von WordPress als Spam markiert hat (geht wohl sonst nur mit Plugins wie Spam Nuker). Täglich wird eine Reportmail mit den abgewiesenen Kommentaren erstellt. […]



  59. personal avatar

    I just wanted to say thank you for a brilliant plugin. Effective, simple, easy to install and make use of.



  60. personal avatar

    Absolutely gorgeous plugin……



  61. personal avatar

    […] fortunately, i remembered talk of a spam annihilation plugin from when i was first looking into the problem, and i went and snagged it, and in a few short minutes i was greeted with: […]



  62. personal avatar

    Thank you for this plugin. I’m sure it will help me !!

    (Sorry for my bad english : I’m french :-p)



  63. personal avatar

    […] - Et pour terminer, le plugin Mass Delete, je l’espère, m’aidera



  64. personal avatar

    […] In den letzten Tagen machten mir die unzähligen Spam’s in meinen Blogs zu schaffen. Tausende von undurchsichtigen Mails beschäftigen mich fast Tag und Nacht. Auf der Suche nach einem geeignetem Spam Programm bin ich nun fündig geworden. Das WP Plugin habe ich installiert und die ‘falschen’ Mails bleiben aus. Und so funktionierts: […]



  65. personal avatar

    I keep getting this error when trying to delete all spam comments:

    Cannot load cjd_delete.php



  66. personal avatar

    […] So i post something, and my inbox is flooded with spam comments, which is very irritating so i did a Google to find out how to combat this annoyance, it turns out that someone has created a plugin for wordpress called Mass Delete its a terrific plugin and one every WP user should have installed. […]



  67. personal avatar

    […] Das original Plugin findet ihr bei Chris J. Davis. […]



  68. personal avatar

    Great tool - I also has no idea that they left the comments in the db, I assumed they sent a short id or something to some spam database somewhere and then deleted it. I too do not understand why they would leave it in the db withoout giving the user an option to delete it as well. Thanks again!



  69. personal avatar

    I have a blog with 30,000+ spam comments. When I click on the spam item in the manage toolbar, the connection times out.

    I’m guessing this is probably because of all spam. Is there a setting somewhere that I can change so it doesn’t time out, either on my browser, or on the server (I have root access).



  70. personal avatar

    Worked like a charm on 5762 spams … plugged into WP 2.5 perfectly. Rowr indeed!



  71. personal avatar

    Thanks a lot for this saviour, Chris. Plugged into WP 2.5.1 perfectly and deleted all the spam that was accumulated in a flash.




comment/Body

comment/Meta



media/Flickr





media/LastFM

http://www.last.fm/music/Cake/_/Stickshifts+and+Safetybelts
http://www.last.fm/music/Poor+Old+Lu/_/Bones+are+Breaking
http://www.last.fm/music/Billy+Joel/_/Hey+Girl
http://www.last.fm/music/Gorillaz/_/Feel+Good+Inc
http://www.last.fm/music/ZZ+Top/_/Certified+Blues
http://www.last.fm/music/Da+Vinci%27s+Notebook/_/Blue+Moon
http://www.last.fm/music/The+Beatles/_/Can%27t+Buy+Me+Love
http://www.last.fm/music/KISS/_/Nothin%27+to+Lose
http://www.last.fm/music/KISS/_/See+You+Tonight
http://www.last.fm/music/Natasha+Bedingfield/_/These+Words
http://www.last.fm/music/Cake/_/Sheep+Go+to+Heaven
http://www.last.fm/music/Model+Engine/_/Drawing+Lines
http://www.last.fm/music/The+Temptations/_/Sugar+Pie+Honey+Bunch
http://www.last.fm/music/Sting/_/This+Cowboy+Song
http://www.last.fm/music/Barenaked+Ladies/_/The+King+of+Bedside+Manor
http://www.last.fm/music/Billy+Joel/_/The+Downeaster+%27Alexa%27
http://www.last.fm/music/Alanis+Morissette/_/You+Learn
http://www.last.fm/music/Barenaked+Ladies/_/I+Love+You
http://www.last.fm/music/ZZ+Top/_/Waitin%27+for+the+Bus
http://www.last.fm/music/Foo+Fighters/_/Another+Round