summaryrefslogtreecommitdiff
path: root/pages/api.php
blob: a1f13d9748b790436bf30bbdf7605baf3ada0f51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?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("Location: /?error=Endpoint not found: " . strip_tags($toplevel)) and die();
}