<?php
session_start();
require_once __DIR__ . '/auth/db.php';

// Optional: restrict access to admin only
if (!isset($_SESSION['is_admin']) || $_SESSION['is_admin'] !== true) {
    echo json_encode(['success' => false, 'message' => 'Unauthorized']);
    exit();
}

try {
    $stmt = $conn->prepare("UPDATE users SET mining_start_time = NULL, mining_balance = 0");
    $stmt->execute();
    echo json_encode(['success' => true, 'message' => 'All mining balances and timers reset']);
} catch (Exception $e) {
    echo json_encode(['success' => false, 'message' => 'DB error: ' . $e->getMessage()]);
}
?>
