-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
158 lines (140 loc) · 6.14 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
<html>
<head>
<title>Weather Station</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./css/w3.css">
<link rel="stylesheet" href="./css/w3-theme-dark-grey.css">
<link rel="stylesheet" href="./css/main.css">
<script src="main.js"></script>
</head>
<body class="w3-theme-d4">
<div class="w3-container">
<?php
$config = json_decode(file_get_contents("./config.json"));
?>
<h1 class="w3-left-align w3-monospace w3-text-orange">Weather Station: <?php echo $config->stationName; ?></h1>
<h2 class="w3-left-align w3-monospace" id="location"><?php echo $config->location->lat . ", " . $config->location->lon; ?></h2>
<?php
$files = preg_grep('/^([^.])/', scandir("./audio", SCANDIR_SORT_DESCENDING));
$renamed = [];
for ($i = 0; $i < sizeof($files); $i++) {
array_push($renamed, explode("-", $files[$i])[1] . explode("-", $files[$i])[2] . "_" . $files[$i]);
}
rsort($renamed);
$files = [];
for ($i = 0; $i < sizeof($renamed); $i++) {
array_push($files, explode("_", $renamed[$i])[1]);
}
if (0 < isset($_GET["file"])) {
$current = $_GET["file"];
for ($i = 0; $i < sizeof($files); $i++) {
if ($current == $files[$i]) {
if ($i != 0) {
$prev = $files[$i - 1];
}
if ($i != (count($files) - 1)) {
$next = $files[$i + 1];
}
}
}
} else {
$current = $files[0];
$next = $files[1];
}
$sat = explode("-", $current)[0];
$timestamp = date ("F d, Y H:i:s", filemtime("./audio/" . $current));
$fileBaseName = explode(".", $current)[0];
echo "<h4 class='w3-monospace'>";
if (0 < isset($next)) {
echo "<a href='/?file=$next' style='text-decoration:none;'>◀ </a>";
}
echo "$sat: " . $timestamp;
if (0 < isset($prev)) {
echo "<a href='/?file=$prev' style='text-decoration:none;'> ▶</a>";
}
echo "</h4>";
?>
<div class="w3-bar w3-black">
<button class="w3-bar-item w3-button tablink w3-orange" onclick="openImg(event,'MCIR')">MCIR</button>
<button class="w3-bar-item w3-button tablink" onclick="openImg(event,'MSA')">MSA</button>
<button class="w3-bar-item w3-button tablink" onclick="openImg(event,'NO')">NO</button>
<button class="w3-bar-item w3-button tablink" onclick="openImg(event,'THERM')">THERM</button>
<button class="w3-bar-item w3-button tablink" onclick="openImg(event,'ZA')">ZA</button>
<button class="w3-bar-item w3-button tablink" onclick='updateCalendar(event, 0, 0, <?php echo json_encode($files); ?>)'>Archive</button>
<button class="w3-bar-item w3-button tablink"><a href="/" style="text-decoration: none;">Latest</a></button>
</div>
<div id="MCIR" class="map w3-container w3-border w3-border-black">
<?php
if (file_exists ( "./images/$fileBaseName-MCIR.png" )) {
echo "<img class='w3-image' style='width:100%' src='./images/$fileBaseName-MCIR.png'>";
} else {
echo "<h1 class='w3-monospace w3-text-orange'>Recording in Progress</h1>";
}
?>
</div>
<div id="MSA" class="map w3-container w3-border w3-border-black" style="display:none">
<?php
if (file_exists ( "./images/$fileBaseName-MSA.png" )) {
echo "<img class='w3-image' style='width:100%' src='./images/$fileBaseName-MSA.png'>";
} else {
echo "<h1 class='w3-monospace w3-text-orange'>Recording in Progress</h1>";
}
?>
</div>
<div id="NO" class="map w3-container w3-border w3-border-black" style="display:none">
<?php
if (file_exists ( "./images/$fileBaseName-NO.png" )) {
echo "<img class='w3-image' style='width:100%' src='./images/$fileBaseName-NO.png'>";
} else {
echo "<h1 class='w3-monospace w3-text-orange'>Recording in Progress</h1>";
}
?>
</div>
<div id="THERM" class="map w3-container w3-border w3-border-black" style="display:none">
<?php
if (file_exists ( "./images/$fileBaseName-THERM.png" )) {
echo "<img class='w3-image' style='width:100%' src='./images/$fileBaseName-THERM.png'>";
} else {
echo "<h1 class='w3-monospace w3-text-orange'>Recording in Progress</h1>";
}
?>
</div>
<div id="ZA" class="map w3-container w3-border w3-border-black" style="display:none">
<?php
if (file_exists ( "./images/$fileBaseName-ZA.png" )) {
echo "<img class='w3-image' style='width:100%' src='./images/$fileBaseName-ZA.png'>";
} else {
echo "<h1 class='w3-monospace w3-text-orange'>Recording in Progress</h1>";
}
?>
</div>
<div id="Archive" class="map w3-border w3-border-black w3-theme" style="display:none;">
<div id="calendar">
</div>
<div id="archiveListing">
<?php
$currentID = "";
for ($i = 0; $i < sizeof($files); $i++) {
$newID = substr($files[$i], 7, 8);
if ($newID != $currentID) {
if ($currentID != "") {
echo "</ul>";
echo "</div>";
}
$currentID = $newID;
echo "<div id=\"$newID\" class=\"imageList w3-container w3-border w3-border-black\" style=\"display:none\">";
echo "<ul>";
}
$sat = explode("-", $files[$i])[0];
$timestamp = date ("F d, Y H:i:s", filemtime("./audio/" . $files[$i]));
echo "<li><a href='?file=$files[$i]' class='w3-large w3-margin'><span>$sat: $timestamp</span></a><a href='/audio/" . $files[$i] . "' class='w3-large w3-margin'>Raw Audio</a></li>";
}
echo "</ul>";
echo "</div>";
?>
</div>
</div>
</div>
<div style="padding-bottom: 100px;"></div>
</body>
</html>