summaryrefslogtreecommitdiff
path: root/api/_main.php
diff options
context:
space:
mode:
authorRaindropsSys <raindrops@equestria.dev>2024-03-29 22:05:35 +0100
committerRaindropsSys <raindrops@equestria.dev>2024-03-29 22:05:35 +0100
commit5860551daa0f60103ad24e93da29f401a653f144 (patch)
tree9ad97e04152a6edc11d5096c87880978df39086a /api/_main.php
parenta51979ad60074db84af78a06d30fcb888ccb0b03 (diff)
downloadpluralconnect-5860551daa0f60103ad24e93da29f401a653f144.tar.gz
pluralconnect-5860551daa0f60103ad24e93da29f401a653f144.tar.bz2
pluralconnect-5860551daa0f60103ad24e93da29f401a653f144.zip
Updated 20 files, added 6 files, deleted 144 files and renamed .idea/ponycule.iml (automated)
Diffstat (limited to 'api/_main.php')
-rw-r--r--api/_main.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/api/_main.php b/api/_main.php
new file mode 100644
index 0000000..215c1b2
--- /dev/null
+++ b/api/_main.php
@@ -0,0 +1,30 @@
+<?php
+
+if (str_ends_with($_GET['_'], "/")) {
+ $pagename = substr($_GET['_'], 0, strlen($_GET['_']) - 1);
+} else {
+ $pagename = $_GET['_'];
+}
+
+$toplevel = explode("/", $pagename)[1];
+$middlelevel = explode("/", $pagename)[2] ?? null;
+
+if ($toplevel === "_main" || $middlelevel === "_main") {
+ header("HTTP/1.1 404 Not Found");
+ header("Content-Type: text/plain");
+ echo("Endpoint not found");
+ die();
+}
+
+if (isset($middlelevel) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . "/" . $middlelevel . ".php") && is_file($_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . "/" . $middlelevel . ".php")) {
+ require_once $_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . "/" . $middlelevel . ".php";
+} else {
+ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . ".php") && is_file($_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . ".php")) {
+ require_once $_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . ".php";
+ } else {
+ header("HTTP/1.1 404 Not Found");
+ header("Content-Type: text/plain");
+ echo("Endpoint not found");
+ die();
+ }
+}