-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
42 lines (41 loc) · 1.33 KB
/
index.php
File metadata and controls
42 lines (41 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
$str = file_get_contents('settings/settings.json');
$json = json_decode($str, true);
if(!in_array($_SERVER['REMOTE_ADDR'], $json["allowed_ips"]) && !in_array($_SERVER["HTTP_X_FORWARDED_FOR"], $json["allowed_ips"])) {
header("Location: not_allowed.php"); //redirect
exit();
}
?>
<html>
<head>
<title>MONITOR</title>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
</head>
<body>
<div id="header">
Sistema di monitoraggio delle risorse
</div>
<div id="content">
<input type="hidden" id="timeout" value="<?php echo $json["timeout"]; ?>" />
<?php foreach($json["sections"] as $title => $contents) :?>
<div class="section">
<div class="title"><?php echo $title; ?></div>
<div class="content">
<?php foreach($contents as $content) :?>
<div class="row">
<div class="cell name"><?php echo $content["name"]; ?></div>
<?php
$output = shell_exec($content["script"]);
$status = preg_match("/" . $content["expected"] . "/", $output);
?>
<div class="cell"><div class="status <?php echo $status ? "ok" : "ko";?>"></div></div>
</div>
<?php endforeach;?>
</div>
</div>
<?php endforeach;?>
</div>
<div id="remaining-time"><?php echo $json["timeout"] / 1000; ?></div>
<script src="js/script.js"></script>
</body>
</html>