Fixed scope issue

This commit is contained in:
Victor Westerlund 2021-02-08 16:08:27 +01:00
parent ca08e18965
commit 471dc0d8da

View file

@ -2,12 +2,13 @@
header("Content-Type: application/json"); header("Content-Type: application/json");
$api = $_GET["api"]; $api = preg_replace("/[^a-z0-9]/i","-",$_GET["api"]); // Replace special chars
function response($online = false) { // Return the API state
$isError = $online ? true : false; function online($online = false) {
$message = $online ? "Online" : "Offline"; $isError = $online === true ? true : false;
$color = $online ? "green" : "lightgrey"; $message = $online === true ? "Online" : "Offline";
$color = $online === true ? "green" : "lightgrey";
$response = [ $response = [
"schemaVersion" => 1, "schemaVersion" => 1,
@ -20,13 +21,13 @@
echo json_encode($response); echo json_encode($response);
} }
function getStatus() { function checkStatus($api) {
if(!is_dir($api)) { if(!file_exists($api)) {
response(false); online(false);
return false; return false;
} }
response(true); online(true);
} }
getStatus(); checkStatus($api);