<?php
// unfreeze-user.php
session_start();
require_once 'auth/db.php';
header('Content-Type: application/json');

if (!isset($_SESSION['is_admin']) || $_SESSION['is_admin'] !== true) {
    echo json_encode(['success'=>false,'message'=>'Unauthorized']); exit;
}

$data = json_decode(file_get_contents('php://input'), true);
$userId = intval($data['user_id'] ?? 0);
if (!$userId) { echo json_encode(['success'=>false,'message'=>'Missing user id']); exit; }

$stmt = $conn->prepare("UPDATE users SET status='active' WHERE id = ?");
$stmt->bind_param("i", $userId);
$stmt->execute();
$stmt->close();

echo json_encode(['success'=>true,'message'=>'User unfrozen']);
