00001 <?php 00002 00019 function isInactiveAccount( $id, $master = false ) { 00020 $dbo = wfGetDB( $master ? DB_MASTER : DB_SLAVE ); 00021 $fname = 'isInactiveAccount'; 00022 $checks = array( 'revision' => 'rev', 'archive' => 'ar', 'logging' => 'log', 00023 'image' => 'img', 'oldimage' => 'oi' ); 00024 $count = 0; 00025 00026 $dbo->immediateBegin(); 00027 foreach( $checks as $table => $fprefix ) { 00028 $conds = array( $fprefix . '_user' => $id ); 00029 $count += (int)$dbo->selectField( $table, 'COUNT(*)', $conds, $fname ); 00030 } 00031 $dbo->immediateCommit(); 00032 00033 return $count == 0; 00034 } 00035 00039 function showHelp() { 00040 echo( "Delete unused user accounts from the database.\n\n" ); 00041 echo( "USAGE: php removeUnusedAccounts.php [--delete]\n\n" ); 00042 echo( " --delete : Delete accounts which are discovered to be inactive\n" ); 00043 echo( " --ignore-touched=x : Ignore accounts touched within the lasts x days\n" ); 00044 echo( " --ignore-groups=x,y : Ignore accounts within these groups\n" ); 00045 echo( "\n" ); 00046 }