summaryrefslogtreecommitdiff
path: root/pages/api.php
blob: 1d839855e63daf49f0c5079977bc14c5fb11bba1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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();
}