<?php
    error_reporting(E_ALL & ~E_NOTICE);
    date_default_timezone_set("UTC");

    if (isset($_GET['url'])) {
        define("URL", explode('/', rtrim($_GET['url'], '/')));

        // Default to login page if no specific page is requested
        if (empty(URL[0])) {
            include('views/home.php');
        } else if (file_exists('views/' . URL[0] . ".php")) {
            include('views/' . URL[0] . '.php');
        } else if (isset(URL[1])) {
            // Check if the file exists in the correct directory
            define("PAGE", "views/" . URL[0] . "/" . URL[1] . ".php");
            if (file_exists(PAGE)) {
                include('main.php');
            } else {
                include('views/404.php');
            }
        } else {
            include('views/404.php');
        }
    } else {
        include('views/home.php');
    }
?>