mirror of
https://codeberg.org/vlw/victorwesterlund.com.git
synced 2025-09-14 03:23:41 +02:00
33 lines
No EOL
661 B
PHP
33 lines
No EOL
661 B
PHP
<?php
|
|
|
|
header("Content-Type: application/json");
|
|
|
|
$api = preg_replace("/[^a-z0-9]/i","-",$_GET["api"]); // Replace special chars
|
|
|
|
// 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,
|
|
"label" => "API",
|
|
"message" => $message,
|
|
"color" => $color,
|
|
"isError" => $isError
|
|
];
|
|
|
|
echo json_encode($response);
|
|
}
|
|
|
|
function checkStatus($api) {
|
|
if(!file_exists($api)) {
|
|
online(false);
|
|
return false;
|
|
}
|
|
|
|
online(true);
|
|
}
|
|
|
|
checkStatus($api); |