Archive for the 'Frustrations' Category

How to delete masses of WordPress Spam Comments in One Go

Monday, April 18th, 2011

Recently a friend of mine asked me to look at his blog as he had a huge spam comment problem.

He’d been a regular blogger, then had a 6 month break while his little girl had been born, and came back to find he’d got 50,000 spam comments.  Worst of all every time he went to the comments page there were that many that it timed out, so he couldn’t even delete them manually.

We took and look and found out his hosted WordPress install wouldn’t allow database access, nor file system access.  Not good.

So we took a look at his potential plugin list - and “Hello Dolly” was right there waiting to be abused.

Of course we don’t want to name and shame the owner of the blog (let’s call him Greg to keep him anonymous - that’s ok isn’t it Greg? :) ) but he thankfully made a decision that made this a 10 minute change: he declared he wasn’t interested in keeping any comments.

Here’s what we did:

Go to Plugins, activate the Hello Dolly plugin.  Go to plugin editor and then hack some additional code right into the plugin.

As this isn’t production code we’re going to abuse the “dolly_css” function.  So look for “function dolly_css” then right underneath the { paste the following lines:

global $wpdb;
$wpdb->query("DELETE FROM $wpdb->comments");
print ("**************   DELETE FROM $wpdb->comments");
$wpdb->query("OPTIMIZE TABLE $wpdb->comments");
Then click ok.  The page will take a minute or so to refresh, but you should see a “**** DELETE FROM…” message at the top of the screen.  If so then you’ve just deleted all comments on your blog (congratulations???).Once that’s complete you can either delete those lines, or leave them in place so every time you login and do admin stuff it’ll nuke all new comments - your call…

Hope that hackery is helpful :)

.NET Developer Technical Questions for Non-Technical Interviewers

Friday, June 18th, 2010

VIM Macros: Old-School text editing using macros massively boosts programmer productivity - How to Do it

Thursday, September 17th, 2009

.NET ClickOnce Application Issues - won’t update/fails to run

Thursday, September 17th, 2009

iPod Touch: Safari won’t work - keeps showing refresh sign and won’t go further

Tuesday, February 10th, 2009

Why shouldn’t IT people look different?

Sunday, October 19th, 2008

TIP: Getting VIM to open files in Unicode (UTF8) format by default

Monday, August 11th, 2008

“Open Command Line Here” windows explorer option for Vista

Friday, June 20th, 2008

Upgrading PEAR - A moan and groan

Wednesday, March 12th, 2008