4 * Remove unused user accounts from the database
5 * An unused account is one which has made no edits
8 * @subpackage Maintenance
9 * @author Rob Church <robchur@gmail.com>
12 define( 'ACTION_REPORT', 0 );
13 define( 'ACTION_DELETE', 1 );
14 $options = array( 'delete','help' );
15 require_once( 'commandLine.inc' );
16 require_once( 'userFunctions.inc' );
18 echo( "Remove Unused Accounts\nThis script will delete all users who have made no edits.\n\n" );
21 if( @$options['help'] ) {
22 echo( "USAGE: removeUnusedAccounts.php [--help|--delete]\n\nThe first (default) account is ignored.\n\n" );
25 $delete = @$options['delete'] ?
true : false ;
31 # Right, who needs deleting?
33 echo( "Found " . count( $users ) . " accounts.\n\n" );
34 echo( "Locating inactive users..." );
35 foreach( $users as $user ) {
36 if( $user != 1 ) { # Don't *touch* the first user account, ever
37 if( CountEdits( $user, false ) == 0 ) {
38 # User has no edits, mark them for deletion
46 # Purge the inactive accounts we found
47 echo( $count . " inactive accounts found.\n" );
50 echo( "Deleting..." );
54 echo "Run the script with the --delete option to remove them from the database.\n";