summaryrefslogtreecommitdiff
path: root/pages/api.inc
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-05-14 14:02:50 +0200
committerRaindropsSys <contact@minteck.org>2023-05-14 14:02:50 +0200
commita98bafed63f9322d54422861521c0c3c5d110d9a (patch)
treeca86cd09fd85055f8eb1ccfef10d8ed24c447145 /pages/api.inc
parent926714a89d3dcc2976228b9f0039a34b1e18f5e6 (diff)
downloadpluralconnect-a98bafed63f9322d54422861521c0c3c5d110d9a.tar.gz
pluralconnect-a98bafed63f9322d54422861521c0c3c5d110d9a.tar.bz2
pluralconnect-a98bafed63f9322d54422861521c0c3c5d110d9a.zip
Updated 7 files and added 4 files (automated)
Diffstat (limited to 'pages/api.inc')
-rw-r--r--pages/api.inc17
1 files changed, 11 insertions, 6 deletions
diff --git a/pages/api.inc b/pages/api.inc
index 5c13bac..418df76 100644
--- a/pages/api.inc
+++ b/pages/api.inc
@@ -7,12 +7,17 @@ if (str_ends_with($_GET['_'], "/")) {
}
$toplevel = explode("/", $pagename)[1];
+$middlelevel = explode("/", $pagename)[2];
-if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . ".php")) {
- require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . ".php";
+if (isset($middlelevel) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . "/" . $middlelevel . ".php") && is_file($_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . "/" . $middlelevel . ".php")) {
+ require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . "/" . $middlelevel . ".php";
} else {
- header("HTTP/1.1 500 Internal Server Error");
- header("Content-Type: text/plain");
- echo("Endpoint not found");
- die();
+ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . ".php") && is_file($_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . ".php")) {
+ require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . ".php";
+ } else {
+ header("HTTP/1.1 500 Internal Server Error");
+ header("Content-Type: text/plain");
+ echo("Endpoint not found");
+ die();
+ }
} \ No newline at end of file