FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » Prune stale users?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Prune stale users? [message #36289 is a reply to message #36288] Tue, 13 March 2007 18:21 Go to previous messageGo to previous message
Marticus   United States
Messages: 272
Registered: June 2002
Karma:
Senior Member
My Finished product. Not using fudAPI user delete. This creates a sql dump file of the deleted users in case they need to be reinserted, but using the api would probably be better. I run the command './purge.php > log' and the log file shows a nicely formatted listing of deleted users.

require_once ( "GLOBALS.php" );
include_once ( $GLOBALS['DATA_DIR'] . "scripts/fudapi.inc.php" );
fud_use ( 'db.inc' );
include_once ( '../include/users_adm.inc' );

define ( 'forum_debug', 1 );

$num_days = 60; /* Number of days to keep stale users */

$query = "SELECT * FROM " . $GLOBALS['DBHOST_TBL_PREFIX']
            . "users ORDER BY join_date ASC ";

$listing = _fud_simple_fetch_query( 0, $query );

$fh = fopen ( 'users.dump', 'w' );

foreach ( $listing as $user ) {
    if ( ( $user->posted_msg_count == 0 ) && ( $user->id != 1 )
            && ( time() - $user->join_date >= ( $num_days * 24 * 60 * 60 ) ) ) {
        print "Deleted ID: " . $user->id . " ";
        print "Login: " . $user->login . " ";
        print "Joined: " . date('m/d/Y',$user->join_date) . " ";
        print "Posts: " . $user->posted_msg_count . "\n";
        while ( list ( $key, $val ) = each ($user) )
            $vals[] = "'".$val."'";
        $sqlcode = 'INSERT INTO users VALUES ('.join(', ', $vals).');';
        fwrite ( $fh, $sqlcode."\n" );
        usr_delete($user->id);
    }
    $vals = "";
}

fclose ( $fh );
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message icon6.gif
Read Message
Previous Topic: Embedding audio via html
Next Topic: Problem sending e-mail from the forum
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 17:53:28 GMT 2024

Total time taken to generate the page: 0.04527 seconds