46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
/*
|
|
* ROUTING
|
|
*/
|
|
|
|
// store request method (GET, PUT, POST) and requested route / path
|
|
$method = $_SERVER['REQUEST_METHOD'];
|
|
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
|
$path = str_replace('/index.php', '', $path);
|
|
$path = rtrim($path, '/');
|
|
|
|
switch ($path) {
|
|
case '/request': // request access to another user's emergency / legacy key file
|
|
request_access();
|
|
break;
|
|
case 'deny': //deny access
|
|
deny_access();
|
|
break;
|
|
default:
|
|
user_interface();
|
|
break;
|
|
}
|
|
|
|
function ReturnJsonResponse($data, $status = 200) {
|
|
http_response_code($status);
|
|
header('Content-Type: application/json');
|
|
header('Cache-Control: no-cache, no-store, must-revalidate');
|
|
echo json_encode($data);
|
|
exit;
|
|
}
|
|
|
|
function request_access() {
|
|
$data = ['request access' => 'request not allowed'];
|
|
ReturnJsonResponse($data, 403);
|
|
}
|
|
|
|
function deny_access() {
|
|
$data = ['deny access'=>'emergency user request revoked'];
|
|
ReturnJsonResponse($data);
|
|
}
|
|
|
|
function user_interface() {
|
|
print('<!DOCTYPE html><html><head><title>DigiErbe Tresor</title></head><body><h1>Willkommen beim DigiErbe Tresor</h1></body></html>');
|
|
}
|
|
?>
|