My b2evolution Version: Not Entered
A few days ago I was searching for a way do recheck and delete all spam comments with one click and didn't find anything.
So I decided to make a hack ;)
Save this code as hacks.php and upload in conf/ directory. Don't forget to update your spam blacklist before running the script.
if( !empty($_GET['delete_all_spam_comments']) )
global $Messages, $DB;
$keywords = $DB->get_results( 'SELECT aspm_string FROM T_antispam' );
foreach( $keywords as $keyword )
$r = $DB->query('DELETE FROM T_comments
WHERE comment_author LIKE '.$DB->quote('%'.$keyword->aspm_string.'%').'
OR comment_author_email LIKE '.$DB->quote('%'.$keyword->aspm_string.'%').'
OR comment_author_url LIKE '.$DB->quote('%'.$keyword->aspm_string.'%').'
OR comment_content LIKE '.$DB->quote('%'.$keyword->aspm_string.'%') );
if( $r )
$Messages->add( sprintf( T_('Deleted %d comments matching «%s».'),
$r, htmlspecialchars($keyword->aspm_string) ), 'success' );
If you have a few thousands of comments use this query instead or you'll get "Script timed out" error
SELECT aspm_string FROM T_antispam LIMIT 0,500
Type the following in address bar to delete all spam comments/trackbacks