From de12c9fa54bdf8539233eeba6f34a64b10db28c9 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Mon, 7 Mar 2016 21:50:39 +0100 Subject: [PATCH] (legacy) refactor services_ntpd_gps.php --- src/www/services_ntpd_gps.php | 987 ++++++++++++++++------------------ 1 file changed, 475 insertions(+), 512 deletions(-) diff --git a/src/www/services_ntpd_gps.php b/src/www/services_ntpd_gps.php index 267a1aa07..c9777a278 100644 --- a/src/www/services_ntpd_gps.php +++ b/src/www/services_ntpd_gps.php @@ -1,31 +1,31 @@ 17 || $pconfig['stratum'] < 0 || (int)$pconfig['stratum'] == null)) { + $input_errors[] = gettext("Clock stratum must be a number in the range 0..16"); + } + // swap prefer + $pconfig['prefer'] = empty($pconfig['prefer']) ? "on" : ""; - if (!empty($_POST['gpsflag2'])) - $config['ntpd']['gps']['flag2'] = $_POST['gpsflag2']; - elseif (isset($config['ntpd']['gps']['flag2'])) - unset($config['ntpd']['gps']['flag2']); - - if (!empty($_POST['gpsflag3'])) - $config['ntpd']['gps']['flag3'] = $_POST['gpsflag3']; - elseif (isset($config['ntpd']['gps']['flag3'])) - unset($config['ntpd']['gps']['flag3']); - - if (!empty($_POST['gpsflag4'])) - $config['ntpd']['gps']['flag4'] = $_POST['gpsflag4']; - elseif (isset($config['ntpd']['gps']['flag4'])) - unset($config['ntpd']['gps']['flag4']); - - if (!empty($_POST['gpssubsec'])) - $config['ntpd']['gps']['subsec'] = $_POST['gpssubsec']; - elseif (isset($config['ntpd']['gps']['subsec'])) - unset($config['ntpd']['gps']['subsec']); - - if (!empty($_POST['gpsrefid'])) - $config['ntpd']['gps']['refid'] = $_POST['gpsrefid']; - elseif (isset($config['ntpd']['gps']['refid'])) - unset($config['ntpd']['gps']['refid']); - - if (!empty($_POST['gpsinitcmd'])) - $config['ntpd']['gps']['initcmd'] = base64_encode($_POST['gpsinitcmd']); - elseif (isset($config['ntpd']['gps']['initcmd'])) - unset($config['ntpd']['gps']['initcmd']); - - write_config("Updated NTP GPS Settings"); - - $retval = system_ntp_configure(); - $savemsg = get_std_save_message(); + if (count($input_errors) == 0) { + $gps = array(); + foreach ($copy_fields as $fieldname) { + if (!empty($pconfig[$fieldname])) { + $gps[$fieldname] = $pconfig[$fieldname]; + } + } + $gps['initcmd']= base64_encode($gps['initcmd']); + $config['ntpd']['gps'] = $gps; + write_config("Updated NTP GPS Settings"); + system_ntp_configure(); + header("Location: services_ntpd_gps.php"); + exit; + } } -$pconfig = &$config['ntpd']['gps']; $service_hook = 'ntpd'; - +legacy_html_escape_form_data($pconfig); include("head.inc"); - ?> - -
-
-
- - 0) print_input_errors($input_errors); ?> - - -
- -
- -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
NTP"); ?> -
- - -
-
-
- -
-   - -

-   -
-
- -
-
- -
- " />()
- (: 0.0).
- " />()
- (: 0.0).
- " />
- (: 0).
- - - - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- /> - - -
- /> - - -
- /> - - -
- /> - - -
- /> - - -
- /> - - -
- /> - - Note: enabling this will rapidly fill the log, but is useful for tuning Fudge time 2."); ?> -
-
- " />
- (: GPS).
-
- " /> - -
- -
  - " /> -
-
- -
- -
-
-
-
-
- - - +
+
+
+ 0) print_input_errors($input_errors); ?> + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +    +
+ + + +
+ + +
+
+ + +
+ + + +
() + + +
() + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ /> + + +
+ /> + + +
+ /> + + +
+ /> + + +
+ /> + + +
+ /> + + +
+ /> + + Note: enabling this will rapidly fill the log, but is useful for tuning Fudge time 2."); ?> +
+
+ + +
+
+ " /> - +
+ +
  + " /> +
+ +
+
NTP"); ?> +
+
+
+
+
+
+
+