blob: 8bcea021a674393986d137ca229646775b993d39 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
<?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 (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 {
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();
}
}
|