From c1e682445df5c23b632f9beee88fb017b27041b9 Mon Sep 17 00:00:00 2001 From: nagyrobi Date: Tue, 18 Feb 2014 15:14:18 +0100 Subject: Update services_ntpd.php Extended options for NTPd --- usr/local/www/services_ntpd.php | 349 ++++++++++++++++++++++++++++++++++------ 1 file changed, 299 insertions(+), 50 deletions(-) (limited to 'usr/local') diff --git a/usr/local/www/services_ntpd.php b/usr/local/www/services_ntpd.php index c68476b..a0fa211 100644 --- a/usr/local/www/services_ntpd.php +++ b/usr/local/www/services_ntpd.php @@ -2,6 +2,7 @@ /* services_ntpd.php + Copyright (C) 2013 Dagorlad Copyright (C) 2012 Jim Pingle All rights reserved. @@ -38,6 +39,8 @@ ##|-PRIV require("guiconfig.inc"); +require_once('rrd.inc'); +require_once("shaper.inc"); if (empty($config['ntpd']['interface'])) if ($config['installedpackages']['openntpd'] && empty($config['installedpackages']['openntpd']['config'][0]['interface'])) { @@ -64,6 +67,94 @@ if ($_POST) { 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} "; + } + } + $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; @@ -73,27 +164,81 @@ if ($_POST) { } } +$pconfig = &$config['ntpd']; $pgtitle = array(gettext("Services"),gettext("NTP")); $shortcut_section = "ntp"; include("head.inc"); ?> + + + -
+ -
- - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Interface(s) +
+ +
+
+ + + + + + + - - - - - - - - - - - - - -
Interface(s) - $ifacename) { if (!is_ipaddr(get_interface_ip($iface)) && !is_ipaddr($iface)) continue; echo "\n"; } ?> - -
-
-
-
-
-
Serial GPS - -
-
-
-
-
-
General"); ?> -
  - " onclick="enable_change(true)"> -
+ +
+
+
+
+
+
Time servers + \n"; + + echo " "; + echo "\n prefer '; + echo "\n noselect\n
\n\n"; + } + ?> +
+ " OnClick="NewTimeServer()"> +
+
+ +
+ prefer option indicates that NTP should favor the use of this server more than all others.'); ?> +
+ noselect option indicates that NTP should not use this server for time, but stats for this server will be collected and displayed.'); ?> +
Orphan mode +
+ +
NTP graphs + > + +
Syslog logging + ( System Logs > NTP"); ?>). +

+ > + +
+ > + +
Statistics logging +
+ "> - +
+ +
Access restrictions +
+ "> - +
+ +
Leap seconds +
+ "> - +
+ +
  + "> +
+ -- cgit v1.1