132 lines
5.0 KiB
PHP
132 lines
5.0 KiB
PHP
<?php
|
|
if (file_exists('lastcheck.json')) {
|
|
$filename = 'lastcheck.json';
|
|
$data = file_get_contents($filename); //data read from json file
|
|
$status = json_decode($data, true); //decode a data
|
|
|
|
// print_r($users); //array format data printing
|
|
// print_r($users['Service']); //array format data printing
|
|
// print_r($users['Date']); //array format data printing
|
|
// print_r($users['Status']); //array format data printing
|
|
// print_r($users['Time']); //array format data printing
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
|
<meta http-equiv="x-ua-compatible" content="ie=edge" />
|
|
<title>BML -Status</title>
|
|
<!-- MDB icon -->
|
|
<link rel="icon" href="" type="image/x-icon" />
|
|
<!-- Font Awesome -->
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" />
|
|
<!-- Google Fonts Roboto -->
|
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700;900&display=swap" />
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" integrity="sha512-xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
|
<!-- MDB -->
|
|
<link rel="stylesheet" href="css/mdb.min.css" />
|
|
<link rel="stylesheet" href="css/main.css">
|
|
</head>
|
|
|
|
<body>
|
|
<nav class="navbar">
|
|
<div class="container">
|
|
<div class="navbar-brand" href="#">
|
|
<div class="status d-flex align-items-center">
|
|
|
|
<!-- <i class="fa-solid fa-circle-exclamation text-success"></i>
|
|
<i class="fa-regular fa-circle-xmark text-danger"></i> -->
|
|
<h6>Last Update:<?php print_r($status['Date'] . " " . $status['Time']);
|
|
} ?></h6>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</nav>
|
|
<!-- Start your project here-->
|
|
<div class="container">
|
|
<!-- Just an image -->
|
|
|
|
|
|
<div class="d-flex justify-content-center align-items-center" style="height: 100vh">
|
|
|
|
<div class="text-center">
|
|
<h5 class="mb-3">Server Status:<span id="status" class="text-success">All Systems Operational</span></h5>
|
|
<!-- <img class="mb-4" src="img/database.svg" /> -->
|
|
|
|
<table id="table" class="table table-striped table-hover bg-light">
|
|
<thead class="bg-black text-light">
|
|
<tr>
|
|
<th>Service</th>
|
|
<th>Time</th>
|
|
<th>date</th>
|
|
<th>Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><?php
|
|
if (file_exists('status.json')) {
|
|
$filename = 'status.json';
|
|
$data = file_get_contents($filename); //data read from json file
|
|
$users = json_decode($data); //decode a data
|
|
// var_dump($users);
|
|
|
|
// print_r($users); //array format data printing
|
|
// print_r($users['Service']); //array format data printing
|
|
// print_r($users['Date']); //array format data printing
|
|
// print_r($users['Status']); //array format data printing
|
|
// print_r($users['Time']); //array format data printing
|
|
?>
|
|
|
|
<?php
|
|
foreach ($users->looper as $user) {
|
|
?> <tr>
|
|
<td><?php print_r($user->Service); ?></td>
|
|
<td><?php print_r($user->Status); ?></td>
|
|
<td><?php print_r($user->Date); ?></td>
|
|
<td><?php print_r($user->Time); ?></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
<?php } ?>
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- End your project here-->
|
|
<script type="text/javascript">
|
|
const elementStatus = document.getElementById("status");
|
|
function status() {
|
|
fetch("lastcheck.json")
|
|
.then(function(response) {
|
|
return response.json();
|
|
})
|
|
.then(function(data) {
|
|
// console.log('here');
|
|
console.log(data['Status']);
|
|
if (data['Status'] != 200) {
|
|
elementStatus.innerHTML = "Server Down!";
|
|
elementStatus.classList.add('text-danger');
|
|
elementStatus.classList.remove('text-success');
|
|
|
|
} else {
|
|
elementStatus.innerHTML = "All Systems Operational";
|
|
}
|
|
})
|
|
}
|
|
|
|
setTimeout(status, 500);
|
|
</script>
|
|
<script type="text/javascript" src="js/mdb.min.js"></script>
|
|
<!-- Custom scripts -->
|
|
<script type="text/javascript"></script>
|
|
|
|
</body>
|
|
|
|
</html>
|