<?php
// admin/auth.php
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

function ensureAdminAuth() {
    if (empty($_SESSION['admin_id'])) {
        header('Location: ../login.php');
        exit();
    }
}

function ensureAdminAjaxAuth() {
    if (empty($_SESSION['admin_id'])) {
        http_response_code(401);
        header('Content-Type: application/json');
        echo json_encode(['success' => false, 'message' => 'Unauthorized admin access']);
        exit();
    }
}
?>
