<?php

require_once __DIR__ . "/Auth/db.php";

$stmt = $pdo->query("
    SELECT maintenance_mode
    FROM site_settings
    WHERE id = 1
");

$settings = $stmt->fetch(PDO::FETCH_ASSOC);

$currentFile = basename($_SERVER["PHP_SELF"]);

$allowedFiles = [
    "Maintenance.php"
];

if (
    !empty($settings["maintenance_mode"]) &&
    !in_array($currentFile, $allowedFiles)
) {
    header("Location: /Maintenance.php");
    exit;
}