-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublishresults.inc.php
85 lines (82 loc) · 3.1 KB
/
publishresults.inc.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
<?php
/*
* openrouteserver - Open source NDW route configurator en server
* Copyright (C) 2014,2017 Jasper Vries
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
write_log('publish results', $publicationtime);
//publish results as HTML table
$qry_routes = "SELECT `route_history`.`route_id`, `route_history`.`time`, `route_history`.`value`, `route_history`.`level_of_service`, `routes`.`name`, `route_history`.`smoothed`, `route_history`.`quality` FROM `route_history`
INNER JOIN (SELECT `route_id`, MAX(`time`) AS `mtime` FROM `route_history`
GROUP BY (`route_id`)) AS `t1`
ON `t1`.`route_id` = `route_history`.`route_id` AND `t1`.`mtime` = `route_history`.`time`
LEFT JOIN `routes`
ON `routes`.`route_id` = `route_history`.`route_id`
WHERE `routes`.`disabled` = 0
ORDER BY `routes`.`name`";
$res_routes = mysqli_query($db['link'], $qry_routes);
if (mysqli_num_rows($res_routes)) {
$html = '<table>
<thead>
<tr><th>ID</th><th>Naam</th><th>Gemeten<br>reistijd [min]</th><th>Afgevlakte<br>reistijd [min]</th></tr>
</thead>
<tbody>';
while ($row_routes = mysqli_fetch_row($res_routes)) {
$html.= '<tr>
<td>
'.$cfg_site_prefix.$row_routes[0].'
</td><td>
<a onclick="showChart('.$row_routes[0].')" title="'.$cfg_site_prefix.$row_routes[0].'">
'.htmlspecialchars($row_routes[4]).'
</a></td>';
//instantaneous travel time
if ($row_routes[2] == -1) {
$html.= '<td style="color:#FFF;background-color:#999;">-1</td>';
}
else {
$html.= '<td style="color:'.$cfg_LOS_colour[$row_routes[3]].';background-color:#333;">';
$html.= floor($row_routes[2]/60).':'.str_pad($row_routes[2]%60, 2, '0', STR_PAD_LEFT).'</td>';
}
//smoothed travel time
if ($row_routes[5] == -1) {
$html.= '<td style="color:#FFF;background-color:#999;">-1</td>';
}
else {
if ($row_routes[6] < 100) {
$html.= '<td style="color:'.$cfg_LOS_colour[$row_routes[3]].';background-color:#999;">';
}
else {
$html.= '<td style="color:'.$cfg_LOS_colour[$row_routes[3]].';background-color:#333;">';
}
$html.= round($row_routes[5]/60).':00</td>';
}
$html.= '</tr>';
}
$html.= '</tbody>
</table>';
}
else {
$html = '<p>Geen routes geconfigureerd.</p>';
}
//write file
$hdl = fopen('gui/routes.html', 'w');
fwrite($hdl, $html);
fclose($hdl);
//set last update time
$hdl = fopen('gui/lastupdate.html', 'w');
fwrite($hdl, time());
fclose($hdl);
?>