Core Update 1.4.0

This commit is contained in:
2022-02-20 16:53:26 +01:00
parent 918244125c
commit bd1f302433
86 changed files with 3301 additions and 41128 deletions

View File

@@ -28,15 +28,16 @@ $sql = $user->getSQL();
$settings = $config->getSettings();
$installation = !$sql || ($sql->isConnected() && !$settings->isInstalled());
if(isset($_GET["api"]) && is_string($_GET["api"])) {
header("Content-Type: application/json");
if($installation) {
if (isset($_GET["api"]) && is_string($_GET["api"])) {
$isApiResponse = true;
if ($installation) {
$response = createError("Not installed");
} else {
$apiFunction = $_GET["api"];
if(empty($apiFunction)) {
http_response_code(403);
$response = "";
if (empty($apiFunction) || $apiFunction === "/") {
$document = new \Elements\TemplateDocument($user, "swagger.twig");
$response = $document->getCode();
$isApiResponse = false;
} else if(!preg_match("/[a-zA-Z]+(\/[a-zA-Z]+)*/", $apiFunction)) {
http_response_code(400);
$response = createError("Invalid Method");
@@ -72,6 +73,12 @@ if(isset($_GET["api"]) && is_string($_GET["api"])) {
$response = createError("Error instantiating class: $e");
}
}
if ($isApiResponse) {
header("Content-Type: application/json");
} else {
header("Content-Type: text/html");
}
}
} else {
$requestedUri = $_GET["site"] ?? $_SERVER["REQUEST_URI"];