-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
104 lines (102 loc) · 2.55 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
<?php
require $_SERVER['DOCUMENT_ROOT'] . "/inc/config.php";
$alive = 0;
$dead = 0;
$dates = array();
// DB Fetch
$query = $conn->query('SELECT * FROM server');
$results = $query->fetchAll();
?>
<html>
<head>
<title>Server Listing</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="//code.jquery.com/jquery-3.3.1.min.js"></script>
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
<link href="./css/style.css" rel="stylesheet">
<style>
<?php foreach($results as $row) {
if (!$row['dead']) { $alive++; }
if ($row['dead']) { $dead++; }
$totalcost = $totalcost + $row['cost'];
$dates[] = $row['datetime'];
}
$latestdate = date("d M Y", max(array_map('strtotime', $dates)));
$all = $alive + $dead; ?>
@media screen and (min-width: 600px) {
.alive, ul {
column-count: <?php echo "1"; ?>;
}
.dead, ul {
column-count: <?php echo "1"; ?>;
}
}
@media screen and (min-width: 900px) {
.alive {
column-count: <?php if ($alive >= 3) {echo "3";} else {echo "2";} ?>;
}
.dead {
column-count: <?php if ($dead >= 3) {echo "3";} else {echo "2";} ?>;
}
}
</style>
</head>
<body onload="startScript()">
<h1>Servers</h1>
<p>
Total: <?php echo "${all} ({$alive} running, {$dead} dead)<br>
Cost: {$totalcost}€/mo<br>"?>
Updated: <?php echo $latestdate; ?> <br>
</p>
<h3>Currently Active</h3>
<ul class="alive">
<?php
//$query = $conn->query('SELECT * FROM server');
//$results = $query->fetchAll();
foreach($results as $row) {
if (!$row['dead']){
switch ($row['type']) {
case "vps":
$type = " ☁";
if ($row['cost']) {
$coststr = "({$row['cost']}€/mo)";
} else {
$coststr = "(⚡/mo)";
}
break;
case "home":
$type = " 🏠";
if ($row['cost']) {
$coststr = "({$row['cost']}€/mo)";
} else {
$coststr = "(⚡/mo)";
}
break;
default:
$type = "";
if ($row['cost']) {
$coststr = "({$row['cost']}€/mo)";
} else {
$coststr = "(⚡/mo)";
}
break;
}
echo "<li id='{$row['href']}'><a href='//{$row['href']}'>{$row['name']}{$type}<br><i>{$row['description']}<br>{$coststr}</i></a></li>";
}} ?>
</ul>
<h3>Inactive or Dead</h3>
<ul class="dead">
<?php
foreach($results as $row) {
if ($row['dead']){
$type = " 💀";
echo "<li>{$row['name']}{$type}<br><i>{$row['description']}</i></li>";
}} ?>
</ul>
</body>
<script>
function startScript() {
$('li a[href*="' + window.location.hostname + '"]').closest('a').addClass('current');
}
</script>
</html>