summaryrefslogtreecommitdiff
path: root/pages/api.inc
diff options
context:
space:
mode:
Diffstat (limited to 'pages/api.inc')
-rw-r--r--pages/api.inc17
1 files changed, 17 insertions, 0 deletions
diff --git a/pages/api.inc b/pages/api.inc
new file mode 100644
index 0000000..1d83985
--- /dev/null
+++ b/pages/api.inc
@@ -0,0 +1,17 @@
+<?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("HTTP/1.1 500 Internal Server Error");
+ echo("Endpoint not found");
+ die();
+} \ No newline at end of file