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 $options = array( 'delete','help' );
13 require_once( 'commandLine.inc' );
14 require_once( 'removeUnusedAccounts.inc' );
16 echo( "Remove Unused Accounts\nThis script will delete all users who have made no edits.\n\n" );
19 if( @$options['help'] ) {
20 echo( "USAGE: removeUnusedAccounts.php [--help|--delete]\n\nThe first (default) account is ignored.\n\n" );
23 $delete = @$options['delete'] ?
true : false ;
29 # Right, who needs deleting?
31 echo( "Found " . count( $users ) . " accounts.\n\n" );
32 echo( "Locating inactive users..." );
33 foreach( $users as $user ) {
34 if( $user != 1 ) { # Don't *touch* the first user account, ever
35 if( CountEdits( $user ) == 0 ) {
36 # User has no edits, mark them for deletion
44 # Purge the inactive accounts we found
45 echo( $count . " inactive accounts found.\n" );
46 if( ( $delete ) and ( $count > 0 ) ) {
47 echo( " Deleting..." );
51 echo "Run the script with the --delete option to remove them from the database.\n";