-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
264 lines (226 loc) · 9.89 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
<?php
function consolelog($data) {
if(is_array($data) || is_object($data)) {
echo("<script>console.log('PHP: ".json_encode($data)."');</script>");
} else {
echo("<script>console.log('PHP: ".$data."');</script>");
}
}
function isMobile() {
return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
}
include "str2safestr.php";
if(isset($_REQUEST['project'])) {
$project = str2safestr(strtolower($_REQUEST['project']));
// project doesnt exit, go to overview
if (!file_exists('projects/'.$project)){header("Refresh:0; url=index.php?project=overview");}
} else {
//just entered dolueg in header and no project? refresh and go to overview
header("Refresh:0; url=index.php?project=overview");
}
$specialprojects = array("control", "overview");
//we only need the variable set if its not a special project
if (!in_array($project, $specialprojects)) {
if(isset($_REQUEST['var'])) {
$selectedvar = ''. str2safestr(strtolower($_REQUEST['var']));
} else {
$selectedvar = '0';
}
}
header("X-XSS-Protection: 1; mode=block");
?>
<!DOCTYPE html>
<html>
<head>
<title>YOUR MEASUREMENT NETWORK!</title>
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css?family=Open+Sans&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="layout/dolueg_min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.css" type="text/css" media="screen" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.31.1/css/theme.metro-dark.min.css" type="text/css" media="screen" />
</head>
<body>
<div class="menu"> <a href="ENTERYOURMAINPAGE" class="back" target=""><h2 class="title" title="YOUR MAIN PAGE">Your main page</h2></a></div>
<div class="submenu">
<?php include "./projects/proj_list.php";?>
</div>
<div class="subsubmenu">
<?php
if (!in_array($project, $specialprojects)) {
echo "<h3>Stations</h3>";
// the stationlist should be unique for each campaign and thus is in subfolders
include "./projects/$project/stat_list.php";
// the varlist should be equal for all campaigns for better user experience
include "./projects/var_list.php";
}
?>
</div>
<div class="contentwrapper">
<div>
<?php
echo '<div class="btncontainer">'."\n";
if (!in_array($project, $specialprojects)) {
echo '<button id="0daybutton" class="btnselector" onclick="plots('."'0day'".')" onfocus="plots('."'0day'".')">Day</button>'."\n";
echo '<button id="1weekbutton" class="btnselector" onclick="plots('."'1week'".')" onfocus="plots('."'1week'".')">Week</button>'."\n";
echo '<button id="2monthbutton" class="btnselector" onclick="plots('."'2month'".')" onfocus="plots('."'2month'".')">Month</button>'."\n";
echo '<button id="3yearbutton" class="btnselector" onclick="plots('."'3year'".')" onfocus="plots('."'3year'".')">Year</button>'."\n";
echo '<button id="infobutton" class="btnselector" onclick="plots('."'info'".')" onfocus="plots('."'info'".')">Information</button>'."\n";
echo '<button id="meteogram_mb" class="btnselector" onclick="plots('."'meteogram'".')" onfocus="plots('."'meteogram'".')">Meteogram</button>'."\n";
} else {
if ($project == 'overview') {
echo '<button class="btnselector" onclick="show('."'0'".')" onfocus="show('."'0'".')">Current Data</button>'."\n";
echo '<button class="btnselector forecastbutton" onclick="show('."'1'".')" onfocus="show('."'1'".')">Today forecast</button>'."\n";
echo '<button class="btnselector forecastbutton" onclick="show('."'2'".')" onfocus="show('."'2'".')">Five day forecast</button>'."\n";
echo '<button class="btnselector" onclick="show('."'3'".')" onfocus="show('."'3'".')" >Windfield</button>'."\n";
echo '<button class="btnselector" onclick="show('."'4'".')" onfocus="show('."'4'".')" >About</button>'."\n";
}
}
echo '</div>'."\n";
echo "<br>";
include "./projects/plot_search.php";
?>
</div>
<a href="ADJUSTTOALINK" style="padding:0;margin:0;">
<div id="logo_foot">
<object data="./logos/logo_footer.svg" id="logo" class="footer" alt="" type="image/svg+xml"></object>
</div>
</a>
</div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<?php
if ($project =='control' or $project == 'overview') {
?>
<script type="text/javascript">
function controlupdate() {
var now = new Date();
var microsecond2hour = 1000 * 60 * 60;
var checktimes = document.getElementsByClassName('checktime');
for (i = 0; i < checktimes.length; i++) {
var element = checktimes[i];
var parenttable = $(element).closest("table")[0];
var good = parenttable.getAttribute('data-good');
var bad = parenttable.getAttribute('data-bad');
bad *= microsecond2hour;
good *= microsecond2hour;
var delay =$(element).next("td")[0];
var creationtime = new Date(element.innerHTML); //;+'+00:00');
var tdiff = now - creationtime;
if (tdiff >= bad) {
$(delay).removeClass().addClass('bad');
hourdelay = (tdiff / microsecond2hour).toFixed(1);
if (hourdelay >= 96) {
delay.innerHTML = '> 96H';
} else {
delay.innerHTML = hourdelay + ' H';
}
} else if (tdiff <= good){
if (tdiff / microsecond2hour > 1) {
delay.innerHTML = (tdiff / microsecond2hour).toFixed(1) +' H';
} else {
if (tdiff < 0) {tdiff=0;}
delay.innerHTML = (tdiff / microsecond2hour * 60).toFixed(0) +'M';
}
$(delay).removeClass().addClass('good');
} else {
delay.innerHTML = (tdiff / microsecond2hour).toFixed(1) +' H';
$(delay).removeClass().addClass('warn');
}
}
var creationheaders = document.getElementsByClassName('creationheader');
for (i = 0; i < creationheaders.length; i++) {
element = creationheaders[i];
var timestamp = element.innerText.split(': ')[1];
if (timestamp.length >= 19){
timestamp = timestamp.slice(0,19);
}
//console.log(timestamp.innerHTML);
var creationtime = new Date(timestamp); //+'+00:00');
var tdiff = (now - creationtime)/microsecond2hour;
if (tdiff >= 6) {
element.children[0].style.background='repeating-linear-gradient(45deg, rgb(102, 102, 102), rgb(102, 102, 102) 7px, firebrick 7px, firebrick 14px)';
} else if (tdiff >= 3) {
element.children[0].style.background='repeating-linear-gradient(45deg, rgb(119, 119, 119), rgb(119, 119, 119) 7px, gold 7px, gold 14px)';
}
//console.log(tdiff,element);
}
}
// check the times once in the beginning to they are proper
controlupdate();
// adjust all the times of the control after 1 minute
window.setInterval(controlupdate, 60000);
// function to refresh
function pagerefresh() {
location.reload(true);
}
// refresh control page after 15 minutes because only our javascript timer runs but the actual data might have been updated
var refreshtime = 900000;
window.setTimeout(pagerefresh, refreshtime);
</script>
<?php
}
?>
<script type="text/javascript">
function show(id) {
for (i = 0; i < 50; i++) {
if (i != id) {
if (document.getElementById(i) != null) {
var theid = document.getElementById(i);
theid.style.display = "none";
}
else {
if (document.getElementById(id) != null) {
var theid = document.getElementById(id);
theid.style.display = "inline";
}
}
}
}
var x = document.getElementsByClassName('btnselector');
if (x.length) {
for (i = 0; i < x.length; i++) {
var c = x[i].onfocus.toString();
if (c.indexOf(id) > 0) {
x[i].focus();
}
}
}
}
function plots(v) {
if (document.getElementById("0day") != null) {
document.getElementById("0day").style.display = "none";
}
if (document.getElementById("1week") != null) {
document.getElementById("1week").style.display = "none";
}
if (document.getElementById("2month") != null) {
document.getElementById("2month").style.display = "none";
}
if (document.getElementById("3year") != null) {
document.getElementById("3year").style.display = "none";
}
if (document.getElementById("info") != null) {
document.getElementById("info").style.display = "none";
}
if (document.getElementById("meteogram") != null) {
document.getElementById("meteogram").style.display = "none";
}
if (document.getElementById(v) != null) {
document.getElementById(v).style.display = "inline";
}
}
$(document).ready(function () {
<?php
if ($project == 'overview') {
echo "show('0');";
} else {
echo "plots('1week');";
}
?>
});
</script>
</body>
</html>