<?php

require_once($_SERVER['DOCUMENT_ROOT'] . '/lib/functions.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/config.php');

if (!in_array($ip, $ab['wlip'])) {
    if (isset($db)) {
        foreach (($db->get("blip") ?: []) as $data) {
            if ($data["id"] == $ip) {
                header("HTTP/1.0 404 Not Found");
                $requestedPage = $_SERVER['REQUEST_URI'] ?? 'Unknown';
                $requestedPageWithoutQueryString = parse_url($requestedPage, PHP_URL_PATH);
                $serverName = $_SERVER['SERVER_NAME'] ?? 'Unknown';
                echo <<<EOL
            <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
            <html><head>
            <title>404 Not Found</title>
            </head><body>
            <h1>Not Found</h1>
            <p>The requested URL $requestedPageWithoutQueryString was not found on this server.</p>
            <hr>
            <address>Apache/2.4.57 (Debian) Server at $serverName Port 80</address>
            </body></html>
            EOL;
                die();
            }
        }
    }

    if (!isset($admin)) {
        require_once($_SERVER['DOCUMENT_ROOT'] . '/case/anti/0.php');
        require_once($_SERVER['DOCUMENT_ROOT'] . '/case/anti/1.php');
    }
}
