-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
347 lines (321 loc) · 13.6 KB
/
index.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
<?php
include 'session.php';
include 'conn.php';
include 'functions/getStats.function.php';
include 'functions/updateLogs.function.php';
$stats = getStats($conn);
if(is_array($stats) && count($stats) > 7 && $stats[0] > 0){
$totalMachines = $stats[0];
$totalOnline = $stats[1];
$totalAdmins = $stats[2];
$Server2016Count = $stats[3];
$Server2012Count = $stats[4];
$Server2008Count =$stats[5];
$Win10Count = $stats[6];
$Windows8Count = $stats[7];
$Server2016Percentage = 100 * $stats[3] / $totalMachines;
$Server2012Percentage = 100 * $stats[4] / $totalMachines;
$Server2008Percentage = 100 * $stats[5] / $totalMachines;
$Windows10Percentage = 100 * $stats[6] / $totalMachines;
$Windows8Percentage = 100 * $stats[7] / $totalMachines;
}
else{
updateLogs($conn, "Error", "An error occured while retrieving stats", " ", " ", " ");
$totalMachines = 0;
$totalOnline = 0;
$totalAdmins = 0;
$Server2016Count = 0;
$Server2012Count = 0;
$Server2008Count = 0;
$Win10Count = 0;
$Windows8Count = 0;
$Server2016Percentage = 0;
$Server2012Percentage = 0;
$Server2008Percentage = 0;
$Windows10Percentage = 0;
$Windows8Percentage = 0;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>NorthStar - Dashboard</title>
<link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="css/ruang-admin.min.css" rel="stylesheet">
<script>
var broadcasting = false;
function reload()
{
setTimeout(function(){
if(!broadcasting)
location.reload();
}, 90000);
}
function broadcastPing(){
broadcasting = true;
var csrfToken = "<?php echo $_SESSION['token'];?>";
var xhr = new XMLHttpRequest();
xhr.open("POST", '/functions/setCommand.nonfunction.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() { // Call a function when the state changes.
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
if(!xhr.responseText.includes("error"))
{
document.getElementById("reloadButton").value = " ";
document.getElementById("reloadButton").disabled = true;
document.getElementById("reloadButton").className = "spinner-border";
setTimeout(function(){
broadcasting = false;
location.reload();
}, 14000);
}
else
{
document.getElementById("reloadErrControl").innerHTML = xhr.responseText;
}
}
}
xhr.send("slave=broadcast&command=ping&token=" + csrfToken);
}
reload();
</script>
</head>
<body id="page-top">
<div id="wrapper">
<!-- Sidebar -->
<ul class="navbar-nav sidebar sidebar-light">
<a class="sidebar-brand d-flex align-items-center justify-content-center" href="index.php">
<div class="sidebar-brand-text mx-3">NorthStar</div>
</a>
<hr class="sidebar-divider my-0">
<li class="nav-item">
<a class="nav-link" href="index.php">
<i class="fas fa-fw fa-tachometer-alt"></i>
<span>Dashboard</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="clients.php">
<i class="fas fa-fw fa-desktop"></i>
<span>Sessions</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="logs.php">
<i class="fas fa-fw fa-history"></i>
<span>Server Logs</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="user.php">
<i class="fas fa-fw fa-user"></i>
<span>User Settings</span></a>
</li>
<hr class="sidebar-divider">
<div class="version" id="version-ruangadmin"></div>
</ul>
<!-- Sidebar -->
<div id="content-wrapper" class="d-flex flex-column">
<div id="content">
<!-- TopBar -->
<div id="content-wrapper" class="d-flex flex-column">
<div id="content">
<!-- TopBar -->
<nav class="navbar navbar-expand navbar-light bg-navbar topbar mb-4 static-top">
<ul class="navbar-nav ml-auto">
<li class="nav-item dropdown no-arrow">
<a class="nav-link dropdown-toggle" href="/logout.php" role="button" aria-expanded="false">
<i class="fas fa-sign-out-alt fa-sm fa-fw text-gray-400"></i>
<span class="ml-2 d-none d-lg-inline text-white small">Logout</span>
</a>
</li>
</ul>
</nav>
<!-- Container Fluid-->
<div class="container-fluid" id="container-wrapper">
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">Dashboard</h1>
</div>
<div class="row mb-3">
<div class="col-xl-3 col-md-6 mb-4">
<div class="card h-100">
<div class="card-body">
<div class="row align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-uppercase mb-1">Total Sessions</div>
<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $totalMachines;?></div>
<div class="mt-2 mb-0 text-muted text-xs">
</div>
</div>
<div class="col-auto">
<i class="fas fa-desktop fa-2x text-primary"></i>
</div>
</div>
</div>
</div>
</div>
<!-- Earnings (Annual) Card Example -->
<div class="col-xl-3 col-md-6 mb-4">
<div class="card h-100">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-uppercase mb-1">Alive Sessions</div>
<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $totalOnline;?></div>
<div class="mt-2 mb-0 text-muted text-xs">
</div>
</div>
<div class="col-auto">
<i class="fas fa-arrow-up fa-2x text-success"></i><br>
<input type="button" id="reloadButton" value="Reload" class="btn btn-sm btn-primary" onclick="broadcastPing();" />
<br>
<p id="reloadErrControl"></p>
</div>
</div>
</div>
</div>
</div>
<!-- New User Card Example -->
<div class="col-xl-3 col-md-6 mb-4">
<div class="card h-100">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-uppercase mb-1">Admin Privileges</div>
<div class="h5 mb-0 mr-3 font-weight-bold text-gray-800"><?php echo $totalAdmins;?></div>
<div class="mt-2 mb-0 text-muted text-xs">
</div>
</div>
<div class="col-auto">
<i class="fas fa-users fa-2x text-info"></i>
</div>
</div>
</div>
</div>
</div>
<!-- Pending Requests Card Example -->
<div class="col-xl-3 col-md-6 mb-4">
<div class="card h-100">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-uppercase mb-1">Online Web Users</div>
<div class="h5 mb-0 font-weight-bold text-gray-800">1</div>
<div class="mt-2 mb-0 text-muted text-xs">
</div>
</div>
<div class="col-auto">
<i class="fas fa-user fa-2x text-warning"></i>
</div>
</div>
</div>
</div>
</div>
<!-- Area Chart -->
<div class="col-xl-8 col-lg-7">
<div class="card mb-4">
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">Machine Report</h6>
<div class="dropdown no-arrow">
</div>
</div>
<div class="card-body">
<div class="chart-area">
<canvas id="myAreaChart"></canvas>
</div>
</div>
</div>
</div>
<!-- Pie Chart -->
<div class="col-xl-4 col-lg-5">
<div class="card mb-4">
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">Operating Systems</h6>
<div class="dropdown no-arrow">
</div>
</div>
<div class="card-body">
<div class="mb-3">
<div class="small text-gray-500">Windows Server 2016
<div class="small float-right"><b><?php echo $Server2016Count;?> of <?php echo $totalMachines;?> </b></div>
</div>
<div class="progress" style="height: 12px;">
<div class="progress-bar bg-warning" role="progressbar" style="width:<?php echo $Server2016Percentage;?>%" aria-valuenow="80"
aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
<div class="mb-3">
<div class="small text-gray-500">Windows Server 2012
<div class="small float-right"><b><?php echo $Server2012Count;?> of <?php echo $totalMachines;?></b></div>
</div>
<div class="progress" style="height: 12px;">
<div class="progress-bar bg-success" role="progressbar" style="width: <?php echo $Server2012Count;?>%" aria-valuenow="70"
aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
<div class="mb-3">
<div class="small text-gray-500">Windows Server 2008
<div class="small float-right"><b><?php echo $Server2008Count;?> of <?php echo $totalMachines;?></b></div>
</div>
<div class="progress" style="height: 12px;">
<div class="progress-bar bg-danger" role="progressbar" style="width: <?php echo $Server2008Count;?>%" aria-valuenow="55"
aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
<div class="mb-3">
<div class="small text-gray-500">Windows 10
<div class="small float-right"><b><?php echo $Win10Count;?> of <?php echo $totalMachines;?></b></div>
</div>
<div class="progress" style="height: 12px;">
<div class="progress-bar bg-info" role="progressbar" style="width:<?php echo $Windows10Percentage;?>%" aria-valuenow="50"
aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
<div class="mb-3">
<div class="small text-gray-500">Windows 8
<div class="small float-right"><b><?php echo $Windows8Count;?> of <?php echo $totalMachines;?></b></div>
</div>
<div class="progress" style="height: 12px;">
<div class="progress-bar bg-success" role="progressbar" style="width: <?php echo $Windows8Percentage;?>%" aria-valuenow="30"
aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
</div>
<div class="card-footer text-center">
</div>
</div>
</div>
<div class="card-footer"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!---Container Fluid-->
</div>
<!-- Footer -->
<footer class="sticky-footer bg-white">
<div class="container my-auto">
<div class="copyright text-center my-auto">
<span>copyright © <script> document.write(new Date().getFullYear()); </script> - developed by
<b><a href="https://engindemirbilek.github.io" target="_blank">Engin Demirbilek</a></b>
</span>
</div>
</div>
</footer>
<!-- Footer -->
</div>
</div>
<!-- Scroll to top -->
<a class="scroll-to-top rounded" href="#page-top">
<i class="fas fa-angle-up"></i>
</a>
<script src="vendor/chart.js/Chart.min.js"></script>
<script src="js/chart-area.php" type="text/javascript"></script>
</body>
</html>