<?php
// ADMIN CONFIG

// Include root config first
require_once __DIR__ . '/../config.php';

// Admin folder constants
define('ADMIN_BASE', __DIR__ . '/');
define('ADMIN_URL', '/admin/');

// Admin Authentication Helpers
if (!function_exists('require_admin_login')) {
    function require_admin_login() {
        $current = basename($_SERVER['PHP_SELF']);
        if ($current === 'login.php') return;

        if (empty($_SESSION['is_admin']) || $_SESSION['is_admin'] != 1) {
            set_flash("Admins only", "error");
            header("Location: " . ADMIN_URL . "login.php");
            exit;
        }
    }
}

if (!function_exists('is_admin_logged_in')) {
    function is_admin_logged_in() {
        return !empty($_SESSION['is_admin']) && $_SESSION['is_admin'] == 1;
    }
}
?>