From ae74c26d191774f7aedc4361f87afaaba1a15aaa Mon Sep 17 00:00:00 2001 From: Stephen Beaver Date: Tue, 12 Apr 2016 18:22:31 -0400 Subject: Fixed #6117 --- src/usr/local/www/status_ntpd.php | 284 ++++++++++++++++++++++++-------------- 1 file changed, 180 insertions(+), 104 deletions(-) (limited to 'src/usr/local') diff --git a/src/usr/local/www/status_ntpd.php b/src/usr/local/www/status_ntpd.php index 9a451ec..66befec 100644 --- a/src/usr/local/www/status_ntpd.php +++ b/src/usr/local/www/status_ntpd.php @@ -183,6 +183,107 @@ if (isset($config['ntpd']['gps']['type']) && ($config['ntpd']['gps']['type'] == } } +// Responding to an AJAX call, we return the GPS data or the status data depending on $_REQUEST['dogps'] +if ($_REQUEST['ajax']) { + + if ($_REQUEST['dogps'] == "yes") { + print_gps(); + } else { + print_status(); + } + + exit; +} + +function print_status() { + global $config, $ntpq_servers; + + if (isset($config['ntpd']['noquery'])): + + print("\n"); + print(''); + printf(gettext("Statistics unavailable because ntpq and ntpdc queries are disabled in the %sNTP service settings%s"), '', ''); + print("\n"); + print("\n"); + elseif (count($ntpq_servers) == 0): + print("\n"); + print(''); + sprintf(gettext("No peers found, %sis the ntp service running?%s"), '', ''); + print("\n"); + print("\n"); + else: + + $i = 0; + foreach ($ntpq_servers as $server): + print("\n"); + print("" . $server['status'] . "\n"); + print("" . $server['server'] . "\n"); + print("" . $server['refid'] . "\n"); + print("" . $server['stratum'] . "\n"); + print("" . $server['type'] . "\n"); + print("" . $server['when'] . "\n"); + print("" . $server['poll'] . "\n"); + print("" . $server['reach'] . "\n"); + print("" . $server['delay'] . "\n"); + print("" . $server['offset'] . "\n"); + print("" . $server['jitter'] . "\n"); + print("\n"); + $i++; + endforeach; + endif; +} + +function print_gps() { + global $gps_lat, $gps_lon, $gps_lat_deg, $gps_lon_deg, $gps_lat_min, $gps_lon_min, $gps_vars, + $gps_alt, $gps_alt_unit, $gps_sat, $gps_satview, $gps_goo_lnk; + + print("\n"); + print("\n"); + sprintf("%.5f", $gps_lat); + print(" ("); + sprintf("%d%s", $gps_lat_deg, "°"); + sprintf("%.5f", $gps_lat_min*60); + print($gps_vars[4]); + print(")"); + print("\n"); + print("\n"); + sprintf("%.5f", $gps_lon); + print(" ("); + sprintf("%d%s", $gps_lon_deg, "°"); + sprintf("%.5f", $gps_lon_min*60); + print($gps_vars[6]); + print(")"); + print("\n"); + + if (isset($gps_alt)) { + print("\n"); + print($gps_alt . ' ' . $gps_alt_unit); + print("\n"); + } + + if (isset($gps_sat) || isset($gps_satview)) { + print(''); + + if (isset($gps_satview)) { + print(gettext('in view ') . intval($gps_satview)); + } + + if (isset($gps_sat) && isset($gps_satview)) { + print(', '); + } + if (isset($gps_sat)) { + print(gettext('in use ') . $gps_sat); + } + + print("\n"); + } + + print("\n"); + print("\n"); + print('' . gettext("Google Maps Link") . ''); + print("\n"); +} + $pgtitle = array(gettext("Status"), gettext("NTP")); $shortcut_section = "ntp"; @@ -195,60 +296,21 @@ include("head.inc"); - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + +
- ', '');?> -
- ', '');?> -
@@ -257,9 +319,12 @@ include("head.inc");
@@ -268,27 +333,19 @@ if (($gps_ok) && ($gps_lat) && ($gps_lon)): - - + + - + - + - - - - + + + +
- - - - - - - -
- (° ) - - (° ) -
+
+ - - - - - - +// - -" != 1)) { + do_gps = "no"; + } else { + do_gps = "yes"; + } + + // and do it again + setTimeout(update_tables, 5000); + }); + + } -?> - - - - - - - - - + + -- cgit v1.1