summaryrefslogtreecommitdiff
path: root/pages/api.inc
blob: 5c13bacdbb3e3cad48fc5a86b6f291c0d43a778d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?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'] . "/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();
}