Recent Topics

[Hack] Recheck and delete all spam comments

Started by on Aug 08, 2008 – Contents updated: Aug 08, 2008

Aug 08, 2008 01:02    

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.

PHP

<?php
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->addsprintfT_('Deleted %d comments matching &laquo;%s&raquo;.'),
                        $rhtmlspecialchars($keyword->aspm_string) ), 'success' );
    }
}
?>

If you have a few thousands of comments use this query instead or you'll get "Script timed out" error

Code

SELECT aspm_string FROM T_antispam LIMIT 0,500

Type the following in address bar to delete all spam comments/trackbacks

Code

YOUR_BLOG/index.php?delete_all_spam_comments=1

Nov 17, 2009 21:21

I tried this, but comments are not deleted. When trying to delete comments manually afterwards i get this:

Warning: Cannot modify header information - headers already sent by (output started at /usr/home/dan18265/public_html/blogs/conf/hacks.php:1) in /usr/home/dan18265/public_html/blogs/inc/_core/_template.funcs.php on line 133

Warning: Cannot modify header information - headers already sent by (output started at /usr/home/dan18265/public_html/blogs/conf/hacks.php:1) in /usr/home/dan18265/public_html/blogs/inc/_core/_template.funcs.php on line 136

Nov 20, 2009 16:51

Bookmarking to try soon. I am so sick of all the spam comments.

Jun 14, 2011 08:07

In b2evolution 4.1 added options remove all comments and hits matching antispam blacklist.

Tools > Misc > Antispam tools

Jan 03, 2012 12:49

It doesn’t stop comments from coming in. It just deletes all pending comments at once. So if you’re sure all your pending comments are spam, then you can get rid of them all very quickly.

Mar 10, 2012 14:30

I can't access the file sam2KB suggested back in 2009. Is there a more recent file to delete-stop spam? I really just want to turn off the ability for users to post comments temporarily. I am using version 4.05 and there is NO WAY I'm going through all the hassle of upgrading.


Form is loading...

powered by b2evolution – This forum is powered by b2evolution CMS, a complete engine for your website.