mirror of
https://codeberg.org/vlw/victorwesterlund.com.git
synced 2025-09-13 19:13:42 +02:00
Fixed scope issue
This commit is contained in:
parent
ca08e18965
commit
471dc0d8da
1 changed files with 11 additions and 10 deletions
|
@ -2,12 +2,13 @@
|
|||
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$api = $_GET["api"];
|
||||
$api = preg_replace("/[^a-z0-9]/i","-",$_GET["api"]); // Replace special chars
|
||||
|
||||
function response($online = false) {
|
||||
$isError = $online ? true : false;
|
||||
$message = $online ? "Online" : "Offline";
|
||||
$color = $online ? "green" : "lightgrey";
|
||||
// Return the API state
|
||||
function online($online = false) {
|
||||
$isError = $online === true ? true : false;
|
||||
$message = $online === true ? "Online" : "Offline";
|
||||
$color = $online === true ? "green" : "lightgrey";
|
||||
|
||||
$response = [
|
||||
"schemaVersion" => 1,
|
||||
|
@ -20,13 +21,13 @@
|
|||
echo json_encode($response);
|
||||
}
|
||||
|
||||
function getStatus() {
|
||||
if(!is_dir($api)) {
|
||||
response(false);
|
||||
function checkStatus($api) {
|
||||
if(!file_exists($api)) {
|
||||
online(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
response(true);
|
||||
online(true);
|
||||
}
|
||||
|
||||
getStatus();
|
||||
checkStatus($api);
|
Loading…
Add table
Reference in a new issue