-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlogfiles.php
115 lines (100 loc) · 3.42 KB
/
logfiles.php
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
# Start the session
InitSession();
# Simple API
if(!empty($_GET['alerts'])) {
# Save the date into a variable
$hsDate = $_GET['alerts'];
if(file_exists(__DIR__ . '/resources/data/alerts_' . $hsDate . '.json')) {
$GetLog = file_get_contents(__DIR__ . '/resources/data/alerts_' . $hsDate . '.json');
}else{
$GetLog = array('status' => 'no_alerts');
$GetLog = json_encode($GetLog, true);
}
print_r($GetLog);
die;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Silo - Resource Panel</title>
<link type="text/css" rel="stylesheet" href="resources/style/css/bootstrap.min.css" media="screen,projection"/>
<link type="text/css" rel="stylesheet" href="resources/style/css/font-awesome.min.css" media="screen"/>
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Gloria+Hallelujah' rel='stylesheet' type='text/css'>
<link type="text/css" rel="stylesheet" href="resources/style/css/montr.css" media="screen"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.pdR {
margin-right:8px;
}
</style>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navcollapse" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.php">
<img alt="" class="menuimg" />
<p class="logo_letter">s</p>
</a>
</div>
<div class="collapse navbar-collapse" id="navcollapse">
<ul class="nav navbar-nav" style="margin-left:22px;">
<li><a href="index.php">Home</a></li>
<li class="active"><a href="logfiles.php">Logs <span class="sr-only">(current)</span></a></li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-md-12">
<p align="center" class="title">logs</p><br />
<div class="fill-in">
</div>
</div>
</div>
</div>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="resources/style/js/bootstrap.min.js"></script>
<script>
// Initially load the table
$(document).ready(function () {
$('.fill-in').load('resources/logs.php').stop().fadeIn();
});
// Reload the table every 5 seconds
setInterval(function(){
$('.fill-in').load('resources/logs.php').stop().fadeIn();
}, 5000);
</script>
</body>
</html>
<?php
function LoadConfig() {
if(file_exists(__DIR__ . '/resources/data/config.json')) {
$cfgCont = file_get_contents(__DIR__ . '/resources/data/config.json');
$cfgCont = json_decode($cfgCont, true);
return $cfgCont;
}
}
# Custom session function
function InitSession($timeout = 3600) {
ini_set('session.gc_maxlifetime', $timeout);
session_start();
if(isset($_SESSION['timeout_idle']) && $_SESSION['timeout_idle'] < time()) {
session_destroy();
session_start();
session_regenerate_id();
$_SESSION = array();
}
$_SESSION['timeout_idle'] = time() + $timeout;
}
?>