038875f4d99a5a9c48b46250b2ff7f9d7e7d2fb3
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 require_once( 'commandLine.inc' );
13 require_once( 'removeUnusedAccounts.inc' );
14 echo( "REMOVE UNUSED ACCOUNTS\nThis script will delete all users who have made no edits.\n\n" );
15 echo( "Syntax: removeUnusedAccounts.php [delete]\n * delete -> delete the accounts\n * The first user (usually the site owner) is left alone\n\n" );
18 if( isset( $args[0] ) ) {
19 $param = array_shift( $args );
20 if( $param == 'delete' ) {
21 $action = ACTION_DELETE
;
23 $action = ACTION_REPORT
;
26 $action = ACTION_REPORT
;
32 # Right, who needs deleting?
34 echo( "Found " . count( $users ) . " accounts.\n\n" );
35 echo( "Locating inactive users..." );
36 foreach( $users as $user ) {
37 if( $user != 1 ) { # Don't *touch* the first user account, ever
38 if( CountEdits( $user ) == 0 ) {
39 # User has no edits, mark them for deletion
47 # Purge the inactive accounts we found
48 echo( $count . " inactive accounts found." );
49 if( ( $action == ACTION_DELETE
) && ( $count > 0 ) ) {
50 echo( " Deleting..." );