<?php
// Get the absolute path to Admin directory
$admin_dir = dirname(__DIR__);

// Include admin files with absolute paths
include($admin_dir . "/ADMIN_HEADER.php");
include($admin_dir . "/ADMIN_nav.php");


// Use the $lnk variable that comes from main engine.php
// $lnk already contains 'deemand' for /Admin/Agent/deemand

if ($lnk == "") {
    include("list_agents.php");
} 
// Check if the requested file exists
elseif (file_exists(__DIR__ . "/" . $lnk . ".php")) {
    include($lnk . ".php");
}
// If file doesn't exist, show list or 404
else {
    include("list_agents.php");
    // or include("404.php");
}

include($admin_dir . "/ADMIN_FOOTER.php");
?>