diff options
Diffstat (limited to 'pages/api.php')
-rw-r--r-- | pages/api.php | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pages/api.php b/pages/api.php new file mode 100644 index 0000000..a1f13d9 --- /dev/null +++ b/pages/api.php @@ -0,0 +1,15 @@ +<?php + +if (str_ends_with($_GET['_'], "/")) { + $pagename = substr($_GET['_'], 0, strlen($_GET['_']) - 1); +} else { + $pagename = $_GET['_']; +} + +$toplevel = explode("/", $pagename)[1]; + +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . ".php")) { + require_once $_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . ".php"; +} else { + header("Location: /?error=Endpoint not found: " . strip_tags($toplevel)) and die(); +}
\ No newline at end of file |