<?php
require_once __DIR__ . '/../includes/functions.php';
start_secure_session();

function admin_is_logged_in()
{
    return !empty($_SESSION['admin_id']);
}

function require_admin()
{
    if (!admin_is_logged_in()) {
        header('Location: login.php');
        exit;
    }
}

function admin_current_name()
{
    return isset($_SESSION['admin_name']) ? $_SESSION['admin_name'] : 'Admin';
}

function admin_redirect($path)
{
    header('Location: ' . $path);
    exit;
}

function admin_db_required()
{
    return db() !== null;
}

function admin_h($value)
{
    return e($value);
}
