Mass Deleting Comments from Spammers in Gallery

In case anyone needs this:

If you had a gallery installation where the comments where open to guests and started getting spammers, you can do this:

delete from g2_Comments where g_comment like '[url=%';

or to do by IP address since they are alike usually:
delete from g2_Comments where g_host like '197.66.55%';

Then when you think you've got the junk out, run cleanup:
delete g2_ChildEntity, g2_Entity from g2_ChildEntity, g2_Entity where g2_ChildEntity.g_id=g2_Entity.g_id and g2_Entity.g_entityType='GalleryComment' and g2_Entity.g_id not in (select g_id from g2_Comment)

Topics: