Posts with mood triumphant (2)

take that, damn spammers!
Mood: triumphant
Posted on 2006-12-03 22:33:00
Tags: programming sql
Words: 316

So I've noticed off and on for a while that my gallery has been getting some weird hits - mostly google searches for "hentay" (I'm guessing they meant hentai, which is most definitely a NSFW search term) and such. At first I laughed it off because they were obviously mistaken, but I couldn't figure out why it was happening. Apparently I have a knack for missing the blindingly obvious, so I was a bit shocked today when I looked on the front page of the gallery, again trying to figure out what was going on, and saw comment spam. Lots and lots of comment spam. (people posting links to their web sites to gain PageRank) Unfortunately, this meant I had to disable anonymous commenting, so if you want to comment just open an account and I'll approve it :-)

More unfortunately, there were still over 2000 comments (all of them spam) on the front page! I looked around and it turns out there's no way to bulk delete comments as of yet. And I sure wasn't going to sit there clicking more than 4000 times (one to delete, one to confirm). So I dug into the SQL and beat those bastards!

Anyway, in case anyone else runs into this problem, here's what I did: open up mysql and the first thing I found was that the root album had a g_id of 7. So I did these commands to first isolate the ID's of all the comments, and then delete them. There are probably better ways to do this but I'm a novice at this so I was aiming for safety...

CREATE TEMPORARY TABLE tmptable SELECT g2_Entity.g_id FROM g2_ChildEntity, g2_Entity WHERE g2_ChildEntity.g_id=g2_Entity.g_id AND g2_ChildEntity.g_parentId=7 AND g2_Entity.g_entityType='GalleryComment';

DELETE FROM g2_Comment, g2_Entity, g2_ChildEntity USING g2_Comment, g2_Entity, g2_ChildEntity, tmptable WHERE g2_Comment.g_id=tmptable.g_id AND g2_Entity.g_id=tmptable.g_id AND g2_ChildEntity.g_id=tmptable.g_id;

Hopefully this will be helpful to someone else, or at least a future version of myself :-)

4 comments

Woohoo!
Mood: triumphant
Posted on 2006-01-29 00:01:00
Words: 118

I spent all evening installing a new hard drive/copying data over (I had 90GB and 120GB drives, now I have 120GB and 320GB drives), and it all works! And I learned some things along the way that I had always wondered about, too (like how to make lilo work when you need to chroot - the key is to remount the partition with the dev option).

Also, I thought it fitting to mention that the very same day that I posted I could cook from a recipe, due to some miscommunication I made a waffle that, when I opened the waffle iron, split in half (the long way). Here's a tip, kids: be sure the waffle iron's been Pamed!

3 comments

This backup was done by LJBackup.