1 |
e078c882
|
jim-p
|
<?php
|
2 |
|
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* status_ntpd.php
|
4 |
191cb31d
|
Stephen Beaver
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
b8f91b7c
|
Luiz Souza
|
* Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
|
7 |
c5d81585
|
Renato Botelho
|
* Copyright (c) 2013 Dagorlad
|
8 |
|
|
* All rights reserved.
|
9 |
191cb31d
|
Stephen Beaver
|
*
|
10 |
c5d81585
|
Renato Botelho
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
11 |
|
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
12 |
|
|
* All rights reserved.
|
13 |
191cb31d
|
Stephen Beaver
|
*
|
14 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
15 |
|
|
* you may not use this file except in compliance with the License.
|
16 |
|
|
* You may obtain a copy of the License at
|
17 |
191cb31d
|
Stephen Beaver
|
*
|
18 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
19 |
191cb31d
|
Stephen Beaver
|
*
|
20 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
21 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
22 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
23 |
|
|
* See the License for the specific language governing permissions and
|
24 |
|
|
* limitations under the License.
|
25 |
5d36f3c4
|
Stephen Beaver
|
*/
|
26 |
e078c882
|
jim-p
|
|
27 |
|
|
##|+PRIV
|
28 |
|
|
##|*IDENT=page-status-ntp
|
29 |
5230f468
|
jim-p
|
##|*NAME=Status: NTP
|
30 |
e078c882
|
jim-p
|
##|*DESCR=Allow access to the 'Status: NTP' page.
|
31 |
|
|
##|*MATCH=status_ntpd.php*
|
32 |
|
|
##|-PRIV
|
33 |
|
|
|
34 |
|
|
require_once("guiconfig.inc");
|
35 |
|
|
|
36 |
679098e5
|
Nano Caiordo
|
$allow_query = !isset($config['ntpd']['noquery']);
|
37 |
a0d75da3
|
Nano Caiordo
|
if (!empty($config['ntpd']['restrictions']['row']) && is_array($config['ntpd']['restrictions']['row'])) {
|
38 |
e8d2b4de
|
Nano Caiordo
|
foreach ($config['ntpd']['restrictions']['row'] as $v) {
|
39 |
679098e5
|
Nano Caiordo
|
if (ip_in_subnet($_SERVER['REMOTE_ADDR'], "{$v['acl_network']}/{$v['mask']}")) {
|
40 |
|
|
$allow_query = !isset($v['noquery']);
|
41 |
e8d2b4de
|
Nano Caiordo
|
}
|
42 |
|
|
}
|
43 |
|
|
}
|
44 |
|
|
|
45 |
|
|
if ($allow_query) {
|
46 |
42b0c921
|
Phil Davis
|
if (isset($config['system']['ipv6allow'])) {
|
47 |
e4a496ae
|
Phil Davis
|
$inet_version = "";
|
48 |
42b0c921
|
Phil Davis
|
} else {
|
49 |
e4a496ae
|
Phil Davis
|
$inet_version = " -4";
|
50 |
42b0c921
|
Phil Davis
|
}
|
51 |
5c8843d5
|
jim-p
|
|
52 |
e4a496ae
|
Phil Davis
|
exec("/usr/local/sbin/ntpq -pn $inet_version | /usr/bin/tail +3", $ntpq_output);
|
53 |
25890c50
|
jim-p
|
|
54 |
c56d07dc
|
nagyrobi
|
$ntpq_servers = array();
|
55 |
|
|
foreach ($ntpq_output as $line) {
|
56 |
|
|
$server = array();
|
57 |
fbb652ed
|
jim-p
|
$status_char = substr($line, 0, 1);
|
58 |
|
|
$line = substr($line, 1);
|
59 |
|
|
$peerinfo = preg_split("/[\s\t]+/", $line);
|
60 |
|
|
|
61 |
|
|
$server['server'] = $peerinfo[0];
|
62 |
|
|
$server['refid'] = $peerinfo[1];
|
63 |
|
|
$server['stratum'] = $peerinfo[2];
|
64 |
|
|
$server['type'] = $peerinfo[3];
|
65 |
|
|
$server['when'] = $peerinfo[4];
|
66 |
|
|
$server['poll'] = $peerinfo[5];
|
67 |
|
|
$server['reach'] = $peerinfo[6];
|
68 |
|
|
$server['delay'] = $peerinfo[7];
|
69 |
|
|
$server['offset'] = $peerinfo[8];
|
70 |
|
|
$server['jitter'] = $peerinfo[9];
|
71 |
c56d07dc
|
nagyrobi
|
|
72 |
fbb652ed
|
jim-p
|
switch ($status_char) {
|
73 |
c56d07dc
|
nagyrobi
|
case " ":
|
74 |
fbb652ed
|
jim-p
|
if ($server['refid'] == ".POOL.") {
|
75 |
|
|
$server['status'] = gettext("Pool Placeholder");
|
76 |
|
|
} else {
|
77 |
|
|
$server['status'] = gettext("Unreach/Pending");
|
78 |
|
|
}
|
79 |
c56d07dc
|
nagyrobi
|
break;
|
80 |
|
|
case "*":
|
81 |
3bd74348
|
bruno
|
$server['status'] = gettext("Active Peer");
|
82 |
c56d07dc
|
nagyrobi
|
break;
|
83 |
|
|
case "+":
|
84 |
3bd74348
|
bruno
|
$server['status'] = gettext("Candidate");
|
85 |
c56d07dc
|
nagyrobi
|
break;
|
86 |
|
|
case "o":
|
87 |
3bd74348
|
bruno
|
$server['status'] = gettext("PPS Peer");
|
88 |
c56d07dc
|
nagyrobi
|
break;
|
89 |
|
|
case "#":
|
90 |
3bd74348
|
bruno
|
$server['status'] = gettext("Selected");
|
91 |
c56d07dc
|
nagyrobi
|
break;
|
92 |
|
|
case ".":
|
93 |
3bd74348
|
bruno
|
$server['status'] = gettext("Excess Peer");
|
94 |
c56d07dc
|
nagyrobi
|
break;
|
95 |
|
|
case "x":
|
96 |
3bd74348
|
bruno
|
$server['status'] = gettext("False Ticker");
|
97 |
c56d07dc
|
nagyrobi
|
break;
|
98 |
|
|
case "-":
|
99 |
3bd74348
|
bruno
|
$server['status'] = gettext("Outlier");
|
100 |
c56d07dc
|
nagyrobi
|
break;
|
101 |
|
|
}
|
102 |
|
|
|
103 |
|
|
$ntpq_servers[] = $server;
|
104 |
|
|
}
|
105 |
|
|
|
106 |
62a407da
|
Phil Davis
|
exec("/usr/local/sbin/ntpq -c clockvar $inet_version", $ntpq_clockvar_output);
|
107 |
c56d07dc
|
nagyrobi
|
foreach ($ntpq_clockvar_output as $line) {
|
108 |
|
|
if (substr($line, 0, 9) == "timecode=") {
|
109 |
|
|
$tmp = explode('"', $line);
|
110 |
|
|
$tmp = $tmp[1];
|
111 |
|
|
if (substr($tmp, 0, 6) == '$GPRMC') {
|
112 |
|
|
$gps_vars = explode(",", $tmp);
|
113 |
6c07db48
|
Phil Davis
|
$gps_ok = ($gps_vars[2] == "A");
|
114 |
c56d07dc
|
nagyrobi
|
$gps_lat_deg = substr($gps_vars[3], 0, 2);
|
115 |
d627983d
|
jskyboo
|
$gps_lat_min = substr($gps_vars[3], 2);
|
116 |
c56d07dc
|
nagyrobi
|
$gps_lon_deg = substr($gps_vars[5], 0, 3);
|
117 |
d627983d
|
jskyboo
|
$gps_lon_min = substr($gps_vars[5], 3);
|
118 |
|
|
$gps_lat = $gps_lat_deg + $gps_lat_min / 60.0;
|
119 |
c56d07dc
|
nagyrobi
|
$gps_lat = $gps_lat * (($gps_vars[4] == "N") ? 1 : -1);
|
120 |
d627983d
|
jskyboo
|
$gps_lon = $gps_lon_deg + $gps_lon_min / 60.0;
|
121 |
c56d07dc
|
nagyrobi
|
$gps_lon = $gps_lon * (($gps_vars[6] == "E") ? 1 : -1);
|
122 |
d627983d
|
jskyboo
|
$gps_lat_dir = $gps_vars[4];
|
123 |
|
|
$gps_lon_dir = $gps_vars[6];
|
124 |
42b0c921
|
Phil Davis
|
} elseif (substr($tmp, 0, 6) == '$GPGGA') {
|
125 |
c56d07dc
|
nagyrobi
|
$gps_vars = explode(",", $tmp);
|
126 |
6c07db48
|
Phil Davis
|
$gps_ok = $gps_vars[6];
|
127 |
c56d07dc
|
nagyrobi
|
$gps_lat_deg = substr($gps_vars[2], 0, 2);
|
128 |
d627983d
|
jskyboo
|
$gps_lat_min = substr($gps_vars[2], 2);
|
129 |
c56d07dc
|
nagyrobi
|
$gps_lon_deg = substr($gps_vars[4], 0, 3);
|
130 |
d627983d
|
jskyboo
|
$gps_lon_min = substr($gps_vars[4], 3);
|
131 |
|
|
$gps_lat = $gps_lat_deg + $gps_lat_min / 60.0;
|
132 |
c56d07dc
|
nagyrobi
|
$gps_lat = $gps_lat * (($gps_vars[3] == "N") ? 1 : -1);
|
133 |
d627983d
|
jskyboo
|
$gps_lon = $gps_lon_deg + $gps_lon_min / 60.0;
|
134 |
c56d07dc
|
nagyrobi
|
$gps_lon = $gps_lon * (($gps_vars[5] == "E") ? 1 : -1);
|
135 |
|
|
$gps_alt = $gps_vars[9];
|
136 |
|
|
$gps_alt_unit = $gps_vars[10];
|
137 |
fdb04797
|
jskyboo
|
$gps_sat = (int)$gps_vars[7];
|
138 |
d627983d
|
jskyboo
|
$gps_lat_dir = $gps_vars[3];
|
139 |
|
|
$gps_lon_dir = $gps_vars[5];
|
140 |
42b0c921
|
Phil Davis
|
} elseif (substr($tmp, 0, 6) == '$GPGLL') {
|
141 |
fdb04797
|
jskyboo
|
$gps_vars = preg_split('/[,\*]+/', $tmp);
|
142 |
6c07db48
|
Phil Davis
|
$gps_ok = ($gps_vars[6] == "A");
|
143 |
c56d07dc
|
nagyrobi
|
$gps_lat_deg = substr($gps_vars[1], 0, 2);
|
144 |
d627983d
|
jskyboo
|
$gps_lat_min = substr($gps_vars[1], 2);
|
145 |
c56d07dc
|
nagyrobi
|
$gps_lon_deg = substr($gps_vars[3], 0, 3);
|
146 |
d627983d
|
jskyboo
|
$gps_lon_min = substr($gps_vars[3], 3);
|
147 |
|
|
$gps_lat = $gps_lat_deg + $gps_lat_min / 60.0;
|
148 |
c56d07dc
|
nagyrobi
|
$gps_lat = $gps_lat * (($gps_vars[2] == "N") ? 1 : -1);
|
149 |
d627983d
|
jskyboo
|
$gps_lon = $gps_lon_deg + $gps_lon_min / 60.0;
|
150 |
c56d07dc
|
nagyrobi
|
$gps_lon = $gps_lon * (($gps_vars[4] == "E") ? 1 : -1);
|
151 |
d627983d
|
jskyboo
|
$gps_lat_dir = $gps_vars[2];
|
152 |
|
|
$gps_lon_dir = $gps_vars[4];
|
153 |
6924a2bf
|
jskyboo
|
} elseif (substr($tmp, 0, 6) == '$PGRMF') {
|
154 |
|
|
$gps_vars = preg_split('/[,\*]+/', $tmp);
|
155 |
|
|
$gps_ok = $gps_vars[11];
|
156 |
|
|
$gps_lat_deg = substr($gps_vars[6], 0, 2);
|
157 |
|
|
$gps_lat_min = substr($gps_vars[6], 2);
|
158 |
|
|
$gps_lon_deg = substr($gps_vars[8], 0, 3);
|
159 |
|
|
$gps_lon_min = substr($gps_vars[8], 3);
|
160 |
|
|
$gps_lat = $gps_lat_deg + $gps_lat_min / 60.0;
|
161 |
|
|
$gps_lat = $gps_lat * (($gps_vars[7] == "N") ? 1 : -1);
|
162 |
|
|
$gps_lon = $gps_lon_deg + $gps_lon_min / 60.0;
|
163 |
|
|
$gps_lon = $gps_lon * (($gps_vars[9] == "E") ? 1 : -1);
|
164 |
|
|
$gps_lat_dir = $gps_vars[7];
|
165 |
|
|
$gps_lon_dir = $gps_vars[9];
|
166 |
c56d07dc
|
nagyrobi
|
}
|
167 |
|
|
}
|
168 |
25890c50
|
jim-p
|
}
|
169 |
e078c882
|
jim-p
|
}
|
170 |
|
|
|
171 |
d627983d
|
jskyboo
|
if (isset($gps_ok) && isset($config['ntpd']['gps']['extstatus']) && ($config['ntpd']['gps']['nmeaset']['gpgsv'] || $config['ntpd']['gps']['nmeaset']['gpgga'])) {
|
172 |
|
|
$lookfor['GPGSV'] = $config['ntpd']['gps']['nmeaset']['gpgsv'];
|
173 |
|
|
$lookfor['GPGGA'] = !isset($gps_sat) && $config['ntpd']['gps']['nmeaset']['gpgga'];
|
174 |
|
|
$gpsport = fopen('/dev/gps0', 'r+');
|
175 |
|
|
while ($gpsport && ($lookfor['GPGSV'] || $lookfor['GPGGA'])) {
|
176 |
c56d07dc
|
nagyrobi
|
$buffer = fgets($gpsport);
|
177 |
d627983d
|
jskyboo
|
if ($lookfor['GPGSV'] && substr($buffer, 0, 6) == '$GPGSV') {
|
178 |
6c07db48
|
Phil Davis
|
$gpgsv = explode(',', $buffer);
|
179 |
d627983d
|
jskyboo
|
$gps_satview = (int)$gpgsv[3];
|
180 |
|
|
$lookfor['GPGSV'] = 0;
|
181 |
|
|
} elseif ($lookfor['GPGGA'] && substr($buffer, 0, 6) == '$GPGGA') {
|
182 |
|
|
$gpgga = explode(',', $buffer);
|
183 |
|
|
$gps_sat = (int)$gpgga[7];
|
184 |
|
|
$gps_alt = $gpgga[9];
|
185 |
|
|
$gps_alt_unit = $gpgga[10];
|
186 |
|
|
$lookfor['GPGGA'] = 0;
|
187 |
5c8843d5
|
jim-p
|
}
|
188 |
|
|
}
|
189 |
|
|
}
|
190 |
|
|
|
191 |
0cdf72ef
|
Stephen Beaver
|
// Responding to an AJAX call, we return the GPS data or the status data depending on $_REQUEST['dogps']
|
192 |
|
|
if ($_REQUEST['ajax']) {
|
193 |
|
|
|
194 |
|
|
if ($_REQUEST['dogps'] == "yes") {
|
195 |
|
|
print_gps();
|
196 |
|
|
} else {
|
197 |
|
|
print_status();
|
198 |
|
|
}
|
199 |
|
|
|
200 |
|
|
exit;
|
201 |
|
|
}
|
202 |
|
|
|
203 |
|
|
function print_status() {
|
204 |
e8d2b4de
|
Nano Caiordo
|
global $config, $ntpq_servers, $allow_query;
|
205 |
0cdf72ef
|
Stephen Beaver
|
|
206 |
e8d2b4de
|
Nano Caiordo
|
if (!$allow_query):
|
207 |
0cdf72ef
|
Stephen Beaver
|
|
208 |
|
|
print("<tr>\n");
|
209 |
|
|
print('<td class="warning" colspan="11">');
|
210 |
702fa4d0
|
Phil Davis
|
printf(gettext('Statistics unavailable because ntpq and ntpdc queries are disabled in the %1$sNTP service settings%2$s'), '<a href="services_ntpd.php">', '</a>');
|
211 |
0cdf72ef
|
Stephen Beaver
|
print("</td>\n");
|
212 |
|
|
print("</tr>\n");
|
213 |
|
|
elseif (count($ntpq_servers) == 0):
|
214 |
|
|
print("<tr>\n");
|
215 |
|
|
print('<td class="warning" colspan="11">');
|
216 |
702fa4d0
|
Phil Davis
|
printf(gettext('No peers found, %1$sis the ntp service running?%2$s'), '<a href="status_services.php">', '</a>');
|
217 |
0cdf72ef
|
Stephen Beaver
|
print("</td>\n");
|
218 |
|
|
print("</tr>\n");
|
219 |
|
|
else:
|
220 |
|
|
|
221 |
|
|
$i = 0;
|
222 |
|
|
foreach ($ntpq_servers as $server):
|
223 |
|
|
print("<tr>\n");
|
224 |
|
|
print("<td>" . $server['status'] . "</td>\n");
|
225 |
|
|
print("<td>" . $server['server'] . "</td>\n");
|
226 |
|
|
print("<td>" . $server['refid'] . "</td>\n");
|
227 |
|
|
print("<td>" . $server['stratum'] . "</td>\n");
|
228 |
|
|
print("<td>" . $server['type'] . "</td>\n");
|
229 |
|
|
print("<td>" . $server['when'] . "</td>\n");
|
230 |
|
|
print("<td>" . $server['poll'] . "</td>\n");
|
231 |
|
|
print("<td>" . $server['reach'] . "</td>\n");
|
232 |
|
|
print("<td>" . $server['delay'] . "</td>\n");
|
233 |
|
|
print("<td>" . $server['offset'] . "</td>\n");
|
234 |
|
|
print("<td>" . $server['jitter'] . "</td>\n");
|
235 |
|
|
print("</tr>\n");
|
236 |
|
|
$i++;
|
237 |
|
|
endforeach;
|
238 |
|
|
endif;
|
239 |
|
|
}
|
240 |
|
|
|
241 |
|
|
function print_gps() {
|
242 |
d627983d
|
jskyboo
|
global $gps_lat, $gps_lon, $gps_lat_deg, $gps_lon_deg, $gps_lat_min, $gps_lon_min, $gps_lat_dir, $gps_lon_dir,
|
243 |
0cdf72ef
|
Stephen Beaver
|
$gps_alt, $gps_alt_unit, $gps_sat, $gps_satview, $gps_goo_lnk;
|
244 |
|
|
|
245 |
|
|
print("<tr>\n");
|
246 |
|
|
print("<td>\n");
|
247 |
ef268b48
|
Stephen Beaver
|
printf("%.5f", $gps_lat);
|
248 |
0cdf72ef
|
Stephen Beaver
|
print(" (");
|
249 |
ef268b48
|
Stephen Beaver
|
printf("%d%s", $gps_lat_deg, "°");
|
250 |
d627983d
|
jskyboo
|
printf("%.5f", $gps_lat_min);
|
251 |
|
|
print($gps_lat_dir);
|
252 |
0cdf72ef
|
Stephen Beaver
|
print(")");
|
253 |
|
|
print("</td>\n");
|
254 |
|
|
print("<td>\n");
|
255 |
ef268b48
|
Stephen Beaver
|
printf("%.5f", $gps_lon);
|
256 |
0cdf72ef
|
Stephen Beaver
|
print(" (");
|
257 |
ef268b48
|
Stephen Beaver
|
printf("%d%s", $gps_lon_deg, "°");
|
258 |
d627983d
|
jskyboo
|
printf("%.5f", $gps_lon_min);
|
259 |
|
|
print($gps_lon_dir);
|
260 |
0cdf72ef
|
Stephen Beaver
|
print(")");
|
261 |
|
|
print("</td>\n");
|
262 |
|
|
|
263 |
|
|
if (isset($gps_alt)) {
|
264 |
ef268b48
|
Stephen Beaver
|
print("<td>\n");
|
265 |
|
|
print($gps_alt . ' ' . $gps_alt_unit);
|
266 |
|
|
print("</td>\n");
|
267 |
0cdf72ef
|
Stephen Beaver
|
}
|
268 |
|
|
|
269 |
|
|
if (isset($gps_sat) || isset($gps_satview)) {
|
270 |
fdb04797
|
jskyboo
|
print('<td>');
|
271 |
0cdf72ef
|
Stephen Beaver
|
|
272 |
|
|
if (isset($gps_satview)) {
|
273 |
|
|
print(gettext('in view ') . intval($gps_satview));
|
274 |
|
|
}
|
275 |
|
|
|
276 |
|
|
if (isset($gps_sat) && isset($gps_satview)) {
|
277 |
|
|
print(', ');
|
278 |
|
|
}
|
279 |
|
|
if (isset($gps_sat)) {
|
280 |
|
|
print(gettext('in use ') . $gps_sat);
|
281 |
|
|
}
|
282 |
|
|
|
283 |
|
|
print("</td>\n");
|
284 |
|
|
}
|
285 |
|
|
|
286 |
|
|
print("</tr>\n");
|
287 |
|
|
print("<tr>\n");
|
288 |
|
|
print('<td colspan="' . $gps_goo_lnk . '"><a target="_gmaps" href="http://maps.google.com/?q=' . $gps_lat . ',' . $gps_lon . '">' . gettext("Google Maps Link") . '</a></td>');
|
289 |
|
|
print("</tr>\n");
|
290 |
|
|
}
|
291 |
|
|
|
292 |
6c07db48
|
Phil Davis
|
$pgtitle = array(gettext("Status"), gettext("NTP"));
|
293 |
b32dd0a6
|
jim-p
|
$shortcut_section = "ntp";
|
294 |
8dff26ce
|
sbeaver
|
|
295 |
e078c882
|
jim-p
|
include("head.inc");
|
296 |
|
|
?>
|
297 |
8dff26ce
|
sbeaver
|
|
298 |
|
|
<div class="panel panel-default">
|
299 |
3bd74348
|
bruno
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext("Network Time Protocol Status");?></h2></div>
|
300 |
8dff26ce
|
sbeaver
|
<div class="panel-body">
|
301 |
10fe1eb5
|
Stephen Beaver
|
<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
|
302 |
8dff26ce
|
sbeaver
|
<thead>
|
303 |
|
|
<tr>
|
304 |
0cdf72ef
|
Stephen Beaver
|
<th><?=gettext("Status")?></th>
|
305 |
|
|
<th><?=gettext("Server")?></th>
|
306 |
|
|
<th><?=gettext("Ref ID")?></th>
|
307 |
|
|
<th><?=gettext("Stratum")?></th>
|
308 |
|
|
<th><?=gettext("Type")?></th>
|
309 |
|
|
<th><?=gettext("When")?></th>
|
310 |
|
|
<th><?=gettext("Poll")?></th>
|
311 |
|
|
<th><?=gettext("Reach")?></th>
|
312 |
|
|
<th><?=gettext("Delay")?></th>
|
313 |
|
|
<th><?=gettext("Offset")?></th>
|
314 |
|
|
<th><?=gettext("Jitter")?></th>
|
315 |
8dff26ce
|
sbeaver
|
</tr>
|
316 |
|
|
</thead>
|
317 |
0cdf72ef
|
Stephen Beaver
|
<tbody id="ntpbody">
|
318 |
|
|
<?=print_status()?>
|
319 |
8dff26ce
|
sbeaver
|
</tbody>
|
320 |
|
|
</table>
|
321 |
|
|
</div>
|
322 |
|
|
</div>
|
323 |
|
|
|
324 |
|
|
|
325 |
|
|
<?php
|
326 |
|
|
|
327 |
0cdf72ef
|
Stephen Beaver
|
$showgps = 0;
|
328 |
|
|
|
329 |
8dff26ce
|
sbeaver
|
// GPS satellite information (if available)
|
330 |
|
|
if (($gps_ok) && ($gps_lat) && ($gps_lon)):
|
331 |
c33f2391
|
Phil Davis
|
$gps_goo_lnk = 2;
|
332 |
0cdf72ef
|
Stephen Beaver
|
$showgps = 1;
|
333 |
c33f2391
|
Phil Davis
|
?>
|
334 |
8dff26ce
|
sbeaver
|
|
335 |
c33f2391
|
Phil Davis
|
<div class="panel panel-default">
|
336 |
3d7a8696
|
k-paulius
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext("GPS Information");?></h2></div>
|
337 |
c33f2391
|
Phil Davis
|
<div class="panel-body">
|
338 |
|
|
<table class="table table-striped table-hover table-condensed">
|
339 |
|
|
<thead>
|
340 |
8dff26ce
|
sbeaver
|
<tr>
|
341 |
0cdf72ef
|
Stephen Beaver
|
<th><?=gettext("Clock Latitude")?></th>
|
342 |
|
|
<th><?=gettext("Clock Longitude")?></th>
|
343 |
c33f2391
|
Phil Davis
|
<?php
|
344 |
|
|
if (isset($gps_alt)) {
|
345 |
|
|
?>
|
346 |
0cdf72ef
|
Stephen Beaver
|
<th><?=gettext("Clock Altitude")?></th>
|
347 |
c33f2391
|
Phil Davis
|
<?php
|
348 |
|
|
$gps_goo_lnk++;
|
349 |
|
|
}
|
350 |
8dff26ce
|
sbeaver
|
|
351 |
c33f2391
|
Phil Davis
|
if (isset($gps_sat) || isset($gps_satview)) {
|
352 |
|
|
?>
|
353 |
0cdf72ef
|
Stephen Beaver
|
<th><?=gettext("Satellites")?></th>
|
354 |
c33f2391
|
Phil Davis
|
<?php
|
355 |
|
|
$gps_goo_lnk++;
|
356 |
|
|
}
|
357 |
|
|
?>
|
358 |
|
|
</tr>
|
359 |
|
|
</thead>
|
360 |
8dff26ce
|
sbeaver
|
|
361 |
0cdf72ef
|
Stephen Beaver
|
<tbody id="gpsbody">
|
362 |
|
|
<?=print_gps()?>
|
363 |
|
|
</tbody>
|
364 |
|
|
</table>
|
365 |
|
|
</div>
|
366 |
|
|
</div>
|
367 |
8dff26ce
|
sbeaver
|
|
368 |
c33f2391
|
Phil Davis
|
<?php
|
369 |
0cdf72ef
|
Stephen Beaver
|
endif;
|
370 |
c33f2391
|
Phil Davis
|
?>
|
371 |
8dff26ce
|
sbeaver
|
|
372 |
0cdf72ef
|
Stephen Beaver
|
<script type="text/javascript">
|
373 |
|
|
//<![CDATA[
|
374 |
|
|
events.push(function() {
|
375 |
|
|
ajax_lock = false; // Mutex so we don't make a call until the previous call is finished
|
376 |
|
|
do_gps = "no";
|
377 |
8dff26ce
|
sbeaver
|
|
378 |
0cdf72ef
|
Stephen Beaver
|
// Fetch the tbody contents from the server
|
379 |
|
|
function update_tables() {
|
380 |
|
|
|
381 |
|
|
if (ajax_lock) {
|
382 |
|
|
return;
|
383 |
c33f2391
|
Phil Davis
|
}
|
384 |
0cdf72ef
|
Stephen Beaver
|
|
385 |
|
|
ajax_lock = true;
|
386 |
|
|
|
387 |
|
|
ajaxRequest = $.ajax(
|
388 |
|
|
{
|
389 |
|
|
url: "/status_ntpd.php",
|
390 |
|
|
type: "post",
|
391 |
|
|
data: {
|
392 |
|
|
ajax: "ajax",
|
393 |
|
|
dogps: do_gps
|
394 |
|
|
}
|
395 |
|
|
}
|
396 |
|
|
);
|
397 |
|
|
|
398 |
|
|
// Deal with the results of the above ajax call
|
399 |
|
|
ajaxRequest.done(function (response, textStatus, jqXHR) {
|
400 |
|
|
if (do_gps == "yes") {
|
401 |
|
|
$('#gpsbody').html(response);
|
402 |
|
|
} else {
|
403 |
|
|
$('#ntpbody').html(response);
|
404 |
|
|
}
|
405 |
|
|
|
406 |
|
|
ajax_lock = false;
|
407 |
|
|
|
408 |
adaa4d03
|
Stephen Beaver
|
// Alternate updating the status table and the gps table (if enabled)
|
409 |
0cdf72ef
|
Stephen Beaver
|
if ((do_gps == "yes") || ("<?=$showgps?>" != 1)) {
|
410 |
|
|
do_gps = "no";
|
411 |
|
|
} else {
|
412 |
adaa4d03
|
Stephen Beaver
|
do_gps = "yes";
|
413 |
0cdf72ef
|
Stephen Beaver
|
}
|
414 |
|
|
|
415 |
|
|
// and do it again
|
416 |
|
|
setTimeout(update_tables, 5000);
|
417 |
|
|
});
|
418 |
|
|
|
419 |
|
|
|
420 |
c33f2391
|
Phil Davis
|
}
|
421 |
8dff26ce
|
sbeaver
|
|
422 |
0cdf72ef
|
Stephen Beaver
|
// Populate the tbody on page load
|
423 |
|
|
update_tables();
|
424 |
|
|
});
|
425 |
|
|
//]]>
|
426 |
|
|
</script>
|
427 |
8dff26ce
|
sbeaver
|
|
428 |
0cdf72ef
|
Stephen Beaver
|
<?php
|
429 |
c33f2391
|
Phil Davis
|
include("foot.inc");
|
430 |
|
|
?>
|