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