diff --git a/src/www/services_ntpd.php b/src/www/services_ntpd.php
index e8a49cae8..68e94025d 100644
--- a/src/www/services_ntpd.php
+++ b/src/www/services_ntpd.php
@@ -33,7 +33,7 @@ require_once("services.inc");
require_once("system.inc");
require_once("interfaces.inc");
-if (!is_array($config['ntpd']))
+if (!isset($config['ntpd']) || !is_array($config['ntpd']))
$config['ntpd'] = array();
if (empty($config['ntpd']['interface'])) {
@@ -46,114 +46,112 @@ if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
- if (!$input_errors) {
- if (is_array($_POST['interface']))
- $config['ntpd']['interface'] = implode(",", $_POST['interface']);
- elseif (isset($config['ntpd']['interface']))
- unset($config['ntpd']['interface']);
+ if (isset($_POST['interface']) && is_array($_POST['interface']))
+ $config['ntpd']['interface'] = implode(",", $_POST['interface']);
+ elseif (isset($config['ntpd']['interface']))
+ unset($config['ntpd']['interface']);
- if (!empty($_POST['gpsport']) && file_exists('/dev/'.$_POST['gpsport']))
- $config['ntpd']['gpsport'] = $_POST['gpsport'];
- elseif (isset($config['ntpd']['gpsport']))
- unset($config['ntpd']['gpsport']);
+ if (!empty($_POST['gpsport']) && file_exists('/dev/'.$_POST['gpsport']))
+ $config['ntpd']['gpsport'] = $_POST['gpsport'];
+ elseif (isset($config['ntpd']['gpsport']))
+ unset($config['ntpd']['gpsport']);
- unset($config['ntpd']['prefer']);
- unset($config['ntpd']['noselect']);
- $timeservers = '';
- for ($i = 0; $i < 10; $i++) {
- $tserver = trim($_POST["server{$i}"]);
- if (!empty($tserver)) {
- $timeservers .= "{$tserver} ";
- if (!empty($_POST["servprefer{$i}"])) $config['ntpd']['prefer'] .= "{$tserver} ";
- if (!empty($_POST["servselect{$i}"])) $config['ntpd']['noselect'].= "{$tserver} ";
- }
+ unset($config['ntpd']['prefer']);
+ unset($config['ntpd']['noselect']);
+ $timeservers = '';
+ for ($i = 0; $i < 10; $i++) {
+ $tserver = trim($_POST["server{$i}"]);
+ if (!empty($tserver)) {
+ $timeservers .= "{$tserver} ";
+ if (!empty($_POST["servprefer{$i}"])) $config['ntpd']['prefer'] .= "{$tserver} ";
+ if (!empty($_POST["servselect{$i}"])) $config['ntpd']['noselect'].= "{$tserver} ";
}
- if (trim($timeservers) == "")
- $timeservers = "pool.ntp.org";
- $config['system']['timeservers'] = trim($timeservers);
-
- if (!empty($_POST['ntporphan']) && ($_POST['ntporphan'] < 17) && ($_POST['ntporphan'] != '12'))
- $config['ntpd']['orphan'] = $_POST['ntporphan'];
- elseif (isset($config['ntpd']['orphan']))
- unset($config['ntpd']['orphan']);
-
- if (!empty($_POST['logpeer']))
- $config['ntpd']['logpeer'] = $_POST['logpeer'];
- elseif (isset($config['ntpd']['logpeer']))
- unset($config['ntpd']['logpeer']);
-
- if (!empty($_POST['logsys']))
- $config['ntpd']['logsys'] = $_POST['logsys'];
- elseif (isset($config['ntpd']['logsys']))
- unset($config['ntpd']['logsys']);
-
- if (!empty($_POST['clockstats']))
- $config['ntpd']['clockstats'] = $_POST['clockstats'];
- elseif (isset($config['ntpd']['clockstats']))
- unset($config['ntpd']['clockstats']);
-
- if (!empty($_POST['loopstats']))
- $config['ntpd']['loopstats'] = $_POST['loopstats'];
- elseif (isset($config['ntpd']['loopstats']))
- unset($config['ntpd']['loopstats']);
-
- if (!empty($_POST['peerstats']))
- $config['ntpd']['peerstats'] = $_POST['peerstats'];
- elseif (isset($config['ntpd']['peerstats']))
- unset($config['ntpd']['peerstats']);
-
- if (empty($_POST['kod']))
- $config['ntpd']['kod'] = 'on';
- elseif (isset($config['ntpd']['kod']))
- unset($config['ntpd']['kod']);
-
- if (empty($_POST['nomodify']))
- $config['ntpd']['nomodify'] = 'on';
- elseif (isset($config['ntpd']['nomodify']))
- unset($config['ntpd']['nomodify']);
-
- if (!empty($_POST['noquery']))
- $config['ntpd']['noquery'] = $_POST['noquery'];
- elseif (isset($config['ntpd']['noquery']))
- unset($config['ntpd']['noquery']);
-
- if (!empty($_POST['noserve']))
- $config['ntpd']['noserve'] = $_POST['noserve'];
- elseif (isset($config['ntpd']['noserve']))
- unset($config['ntpd']['noserve']);
-
- if (empty($_POST['nopeer']))
- $config['ntpd']['nopeer'] = 'on';
- elseif (isset($config['ntpd']['nopeer']))
- unset($config['ntpd']['nopeer']);
-
- if (empty($_POST['notrap']))
- $config['ntpd']['notrap'] = 'on';
- elseif (isset($config['ntpd']['notrap']))
- unset($config['ntpd']['notrap']);
-
- if ((empty($_POST['statsgraph'])) != (isset($config['ntpd']['statsgraph'])));
- enable_rrd_graphing();
- if (!empty($_POST['statsgraph']))
- $config['ntpd']['statsgraph'] = $_POST['statsgraph'];
- elseif (isset($config['ntpd']['statsgraph']))
- unset($config['ntpd']['statsgraph']);
-
- if (!empty($_POST['leaptxt']))
- $config['ntpd']['leapsec'] = base64_encode($_POST['leaptxt']);
- elseif (isset($config['ntpd']['leapsec']))
- unset($config['ntpd']['leapsec']);
-
- if (is_uploaded_file($_FILES['leapfile']['tmp_name']))
- $config['ntpd']['leapsec'] = base64_encode(file_get_contents($_FILES['leapfile']['tmp_name']));
-
- write_config("Updated NTP Server Settings");
-
- $retval = 0;
- $retval = system_ntp_configure();
- $savemsg = get_std_save_message($retval);
-
}
+ if (trim($timeservers) == "")
+ $timeservers = "pool.ntp.org";
+ $config['system']['timeservers'] = trim($timeservers);
+
+ if (!empty($_POST['ntporphan']) && ($_POST['ntporphan'] < 17) && ($_POST['ntporphan'] != '12'))
+ $config['ntpd']['orphan'] = $_POST['ntporphan'];
+ elseif (isset($config['ntpd']['orphan']))
+ unset($config['ntpd']['orphan']);
+
+ if (!empty($_POST['logpeer']))
+ $config['ntpd']['logpeer'] = $_POST['logpeer'];
+ elseif (isset($config['ntpd']['logpeer']))
+ unset($config['ntpd']['logpeer']);
+
+ if (!empty($_POST['logsys']))
+ $config['ntpd']['logsys'] = $_POST['logsys'];
+ elseif (isset($config['ntpd']['logsys']))
+ unset($config['ntpd']['logsys']);
+
+ if (!empty($_POST['clockstats']))
+ $config['ntpd']['clockstats'] = $_POST['clockstats'];
+ elseif (isset($config['ntpd']['clockstats']))
+ unset($config['ntpd']['clockstats']);
+
+ if (!empty($_POST['loopstats']))
+ $config['ntpd']['loopstats'] = $_POST['loopstats'];
+ elseif (isset($config['ntpd']['loopstats']))
+ unset($config['ntpd']['loopstats']);
+
+ if (!empty($_POST['peerstats']))
+ $config['ntpd']['peerstats'] = $_POST['peerstats'];
+ elseif (isset($config['ntpd']['peerstats']))
+ unset($config['ntpd']['peerstats']);
+
+ if (empty($_POST['kod']))
+ $config['ntpd']['kod'] = 'on';
+ elseif (isset($config['ntpd']['kod']))
+ unset($config['ntpd']['kod']);
+
+ if (empty($_POST['nomodify']))
+ $config['ntpd']['nomodify'] = 'on';
+ elseif (isset($config['ntpd']['nomodify']))
+ unset($config['ntpd']['nomodify']);
+
+ if (!empty($_POST['noquery']))
+ $config['ntpd']['noquery'] = $_POST['noquery'];
+ elseif (isset($config['ntpd']['noquery']))
+ unset($config['ntpd']['noquery']);
+
+ if (!empty($_POST['noserve']))
+ $config['ntpd']['noserve'] = $_POST['noserve'];
+ elseif (isset($config['ntpd']['noserve']))
+ unset($config['ntpd']['noserve']);
+
+ if (empty($_POST['nopeer']))
+ $config['ntpd']['nopeer'] = 'on';
+ elseif (isset($config['ntpd']['nopeer']))
+ unset($config['ntpd']['nopeer']);
+
+ if (empty($_POST['notrap']))
+ $config['ntpd']['notrap'] = 'on';
+ elseif (isset($config['ntpd']['notrap']))
+ unset($config['ntpd']['notrap']);
+
+ if ((empty($_POST['statsgraph'])) != (isset($config['ntpd']['statsgraph'])));
+ enable_rrd_graphing();
+ if (!empty($_POST['statsgraph']))
+ $config['ntpd']['statsgraph'] = $_POST['statsgraph'];
+ elseif (isset($config['ntpd']['statsgraph']))
+ unset($config['ntpd']['statsgraph']);
+
+ if (!empty($_POST['leaptxt']))
+ $config['ntpd']['leapsec'] = base64_encode($_POST['leaptxt']);
+ elseif (isset($config['ntpd']['leapsec']))
+ unset($config['ntpd']['leapsec']);
+
+ if (is_uploaded_file($_FILES['leapfile']['tmp_name']))
+ $config['ntpd']['leapsec'] = base64_encode(file_get_contents($_FILES['leapfile']['tmp_name']));
+
+ write_config("Updated NTP Server Settings");
+
+ $retval = 0;
+ $retval = system_ntp_configure();
+ $savemsg = get_std_save_message($retval);
+
}
$closehead = false;
$pconfig = &$config['ntpd'];
@@ -282,13 +280,17 @@ include("head.inc");
echo " style=\"display:none\"";
}
echo ">\n";
-
- echo " ";
+ if (!isset($timeservers[$i])) {
+ $timeserverVal = null;
+ } else {
+ $timeserverVal =$timeservers[$i];
+ }
+ echo " ";
echo "\n prefer ";
echo "\n noselect\n
\n\n";
}
?>
@@ -306,14 +308,14 @@ include("head.inc");
| - /> + /> | @@ -495,7 +494,7 @@ SureGPS = #Sure Electronics SKG16B |
| - /> + /> | @@ -503,7 +502,7 @@ SureGPS = #Sure Electronics SKG16B |
| - /> + /> | @@ -511,7 +510,7 @@ SureGPS = #Sure Electronics SKG16B |
| - /> + /> | @@ -519,7 +518,7 @@ SureGPS = #Sure Electronics SKG16B |
| - /> + /> | @@ -527,7 +526,7 @@ SureGPS = #Sure Electronics SKG16B |
| - /> + /> | @@ -535,7 +534,7 @@ SureGPS = #Sure Electronics SKG16B |
| - /> + /> | Note: enabling this will rapidly fill the log, but is useful for tuning Fudge time 2."); ?> @@ -547,7 +546,7 @@ SureGPS = #Sure Electronics SKG16B |
| Clock ID |
- + " /> (: GPS). |