delete_user.php: optionally delete user by name

This commit is contained in:
David Anderson 2024-08-01 00:44:22 -07:00
parent 5241a64a7f
commit 3c53650e7c
1 changed files with 18 additions and 9 deletions

View File

@ -27,16 +27,25 @@ require_once("../inc/boinc_db.inc");
die("Delete this line first\n");
$id = (int) $argv[1];
$user = BoincUser::lookup_id($id);
if (is_numeric($argv[1])) {
$user = BoincUser::lookup_id((int) $argv[1]);
if (!$user) die("no such user\n");
$retval = delete_account($user);
if ($retval) {
echo "Failed to delete user: $retval\n";
} else {
echo "User deleted\n";
}
} else {
$users = BoincUser::enum(sprintf("name='%s'", $argv[1]));
foreach ($users as $user) {
$retval = delete_account($user);
if ($retval) {
echo "Failed to delete user: $retval\n";
} else {
echo "User $user->id deleted\n";
}
}
}
?>