changed startpage

Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
tracer 2022-02-06 18:00:15 +01:00
parent 909bfcdc85
commit f70e87afce
1 changed files with 18 additions and 13 deletions

View File

@ -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 {