Topic: Script to remove users with signatures but no posts from PunBB 1.3.x

Script to remove users with signatures but no posts from PunBB 1.3.x
Author: Slavok

<?php

define('FORUM_IGNORE_REQUEST_URI', 1);
define('FORUM_ROOT', '/home/.../public_html/.../');
define('NUM_DAYS', 7);

include FORUM_ROOT.'include/essentials.php';

$select_query = array(
        'SELECT' => 'id',
        'FROM'   => 'users',
        'WHERE'  => '( num_posts = 0 ) AND (registered < ( NOW() - '.(NUM_DAYS * 86400).' )) AND (( signature IS NOT NULL ) OR ( url IS NOT NULL ))'
);

$query_result = $forum_db->query_build($select_query) or error(__FILE__, __LINE__);
$num_users = 0;
while ($cur_user = $forum_db->fetch_assoc($query_result))
{
        delete_user($cur_user['id'], false);
        $num_users++;
}
echo $num_users.' was removed from DB'."\n";
$forum_db->close();

?>

Thanks a lot to Slavok for coding this.

Re: Script to remove users with signatures but no posts from PunBB 1.3.x

Just wondering if it wouldn't make a lot of sense to submit all the users deleted to the stopforumspam.com db.

This is some info they have on their site on how to do it (please also see Grez's comment on doing it an easier way)
[code=php]
function PostToHost($data) {
$fp = fsockopen("www.stopformspam.com",80);
fputs($fp, "POST /add.php HTTP/1.1\n" );
fputs($fp, "Host: www.stopforumspam.com\n" );
fputs($fp, "Content-type: application/x-www-form-urlencoded\n" );
fputs($fp, "Content-length: ".strlen($data)."\n" );
fputs($fp, "Connection: close\n\n" );
fputs($fp, $data);
fclose($fp);
}
PostToHost("username=USERNAME&ip_addr=IPADDRESS&email=
    EMAILADDRESS&api_key=XXXXXXXXXXXXX");
[/code]

IMO, a prompt for the API key following Slavoks' script and a "Do you want to submit the deleted users to stopforumspam.com?" prompt would make a lot of sense.

Re: Script to remove users with signatures but no posts from PunBB 1.3.x

I just remade it to make users with no messages disappear.

It works under Punbb 1.4.1

<?php

define('FORUM_IGNORE_REQUEST_URI', 1);
define('FORUM_ROOT', 'base-url-of-the-forum-change-me');
define('NUM_DAYS', 7);

include FORUM_ROOT.'include/essentials.php';

$select_query = array(
        'SELECT' => 'id',
        'FROM'   => 'users',
        'WHERE'  => '( num_posts = 0 )'
);

$query_result = $forum_db->query_build($select_query) or error(__FILE__, __LINE__);
$num_users = 0;
while ($cur_user = $forum_db->fetch_assoc($query_result))
{
        delete_user($cur_user['id'], false);
        $num_users++;
}
echo $num_users.' was removed from DB'."\n";
$forum_db->close();

?>