Mass-delete comment spam from Gallery

Ever woken up to find your Gallery full of comment spam? Ever tried deleting the comment spam, one by one? Not good...

Here’s how to delete it directly from the database, all at once (for Gallery 2.x).

You will need access to the database running behind your Gallery. This can often be through phpMyAdmin in cPanel or similar.

You’ll need to change the parts in bold to match what you’re trying to delete. Note that a % is a wildcard in SQL, so matches anything. For example, ‘%a%’ would match anything with an ‘a’ in it, and ‘209.31.123%’ would match anything starting in ‘209.31.123’.

To delete comments posted by an IP, or a few IPs, run this SQL statement:

delete ce, e, co from g2_ChildEntity ce, g2_Entity e, g2_Comment co where ce.g_id=e.g_id and e.g_id=co.g_id and e.g_entityType='GalleryComment' and (co.g_host='67.104.112.176' or co.g_host='209.31.123.128')

To delete comments based on the comment itself, run this SQL statement:

delete ce, e, co from g2_ChildEntity ce, g2_Entity e, g2_Comment co where ce.g_id=e.g_id and e.g_id=co.g_id and e.g_entityType='GalleryComment' and (co.g_comment like '%[url=http://%')

To delete comments by a specific author or authors, run this SQL statement:

delete ce, e, co from g2_ChildEntity ce, g2_Entity e, g2_Comment co where ce.g_id=e.g_id and e.g_id=co.g_id and e.g_entityType='GalleryComment' and (co.g_author like '%ialis%' or co.g_author like '%iagra%')

More Information

Fore more information on:

 

Updated about 8 mths, 26 days ago (October 11, 2007). Know a better answer? Let us know!

Related categories [coloured].

Comment on this article (no HTML, max 1200 characters):