<?php
// server/reset_users.php
// Utility to backup and wipe users.json for a clean slate.

$file = __DIR__ . '/data/users.json';
$backup = __DIR__ . '/data/users_backup_' . date('Ymd_His') . '.json';

if (file_exists($file)) {
    // Backup
    copy($file, $backup);
    echo "Backed up existing users to: $backup\n";

    // Wipe
    file_put_contents($file, json_encode([]));
    echo "CLEAN SLATE: users.json has been reset to empty array.\n";
} else {
    echo "No users.json found to reset.\n";
    // Create empty
    if (!is_dir(__DIR__ . '/data')) mkdir(__DIR__ . '/data');
    file_put_contents($file, json_encode([]));
    echo "Created new empty users.json.\n";
}
