From f70e87afce3ccfc962e1f7489b70f56931f7d0df Mon Sep 17 00:00:00 2001 From: tracer Date: Sun, 6 Feb 2022 18:00:15 +0100 Subject: [PATCH] changed startpage Signed-off-by: tracer --- public/index.php | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/public/index.php b/public/index.php index aa99e76..7a9c8ee 100644 --- a/public/index.php +++ b/public/index.php @@ -14,6 +14,24 @@ $configJSON = file_get_contents(filename: $configFile); $config = json_decode(json: $configJSON, associative: true); +// TODO make a log class +$oFile = fopen(filename: 'log.txt', mode: 'a'); + +$uri = parse_url(url: $_SERVER['REQUEST_URI'], component: PHP_URL_PATH); +fputs(stream: $oFile, data: $uri . PHP_EOL); +fputs(stream: $oFile, data: "here"); + +$uri = explode(separator: '/', string: $uri); + +fclose(stream: $oFile); + +if ($uri[1] !== 'api') { + $scheme = $_SERVER['REQUEST_SCHEME']; + $host = $_SERVER['SERVER_NAME']; + $header = "$scheme://$host/openapi/index.html"; + header(header: "Location: $header"); + exit(0); +} // TODO only valid clients? header(header: "Access-Control-Allow-Origin: *"); header(header: "Content-Type: application/json; charset=UTF-8"); @@ -22,19 +40,6 @@ header(header: "Access-Control-Max-Age: 3600"); header(header: "Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"); -// TODO make a log class -$oFile = fopen(filename: 'log.txt', mode: 'a'); - -$uri = parse_url(url: $_SERVER['REQUEST_URI'], component: PHP_URL_PATH); -fputs(stream: $oFile, data: $uri . PHP_EOL); -fclose(stream: $oFile); - -$uri = explode(separator: '/', string: $uri); -if ($uri[1] !== 'api') { - header(header: "HTTP/1.1 404 Not Found"); - exit(); -} - $requestMethod = $_SERVER["REQUEST_METHOD"]; try {