Adds a Jilo Server check and notice.
parent
e76c78fde4
commit
f3457d5240
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
class Server {
|
||||
private $db;
|
||||
|
||||
public function __construct($database) {
|
||||
$this->db = $database->getConnection();
|
||||
}
|
||||
|
||||
// get Jilo Server status
|
||||
public function getServerStatus($host = '127.0.0.1', $port = 8080, $endpoint = '/health') {
|
||||
$url = "http://$host:$port$endpoint";
|
||||
$options = [
|
||||
'http' => [
|
||||
'method' => 'GET',
|
||||
'timeout' => 3,
|
||||
],
|
||||
];
|
||||
$context = stream_context_create($options);
|
||||
$response = @file_get_contents($url, false, $context);
|
||||
|
||||
// We check the response if it's 200 OK
|
||||
if ($response !== false && isset($http_response_header) && strpos($http_response_header[0], '200 OK') !== false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If it's not 200 OK
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -147,6 +147,15 @@ if ($page == 'logout') {
|
|||
$userTimezone = isset($userDetails[0]['timezone']) ? $userDetails[0]['timezone'] : 'UTC'; // Default to UTC if no timezone is set
|
||||
}
|
||||
|
||||
// check if the Jilo Server is running
|
||||
require '../app/classes/server.php';
|
||||
$serverObject = new Server($dbWeb);
|
||||
|
||||
$server_status = $serverObject->getServerStatus();
|
||||
if (!$server_status) {
|
||||
$error = 'The Jilo Server is not running. Some data may be old and incorrect.';
|
||||
}
|
||||
|
||||
// page building
|
||||
include '../app/templates/page-header.php';
|
||||
include '../app/templates/page-menu.php';
|
||||
|
|
Loading…
Reference in New Issue