* @author Rob Church <robchur@gmail.com>
*/
+define( 'ACTION_REPORT', 0 );
+define( 'ACTION_DELETE', 1 );
+
# Count the number of edits the specified user has made
function CountEdits( $user_id ) {
# We've *got* to pull this stuff off the master. If the user *has* made an edit, but it hasn't
require_once( 'commandLine.inc' );
require_once( 'removeUnusedAccounts.inc' );
echo( "REMOVE UNUSED ACCOUNTS\nThis script will delete all users who have made no edits.\n\n" );
+echo( "Syntax: removeUnusedAccounts.php [delete]\n * delete -> delete the accounts\n * The first user (usually the site owner) is left alone\n\n" );
+
+# Handle parameters
+if( isset( $args[0] ) ) {
+ $param = array_shift( $args );
+ if( $param == 'delete' ) {
+ $action = ACTION_DELETE;
+ } else {
+ $action = ACTION_REPORT;
+ }
+} else {
+ $action = ACTION_REPORT;
+}
$count = 0;
$del = array();
# Right, who needs deleting?
$users = GetUsers();
-echo( "Found " . count( $users ) . " accounts.\n" );
+echo( "Found " . count( $users ) . " accounts.\n\n" );
echo( "Locating inactive users..." );
foreach( $users as $user ) {
if( $user != 1 ) { # Don't *touch* the first user account, ever
echo( "done.\n" );
# Purge the inactive accounts we found
-echo( $count . " inactive accounts found. Deleting..." );
-DeleteUsers( $del );
-echo( "done.\n" );
-
-# We're done
-echo( "Complete.\n" );
+echo( $count . " inactive accounts found." );
+if( ( $action == ACTION_DELETE ) && ( $count > 0 ) ) {
+ echo( " Deleting..." );
+ DeleteUsers( $del );
+ echo( "done.\n" );
+}
?>
\ No newline at end of file