1 |
cf180ccc
|
jim-p
|
<?php
|
2 |
|
|
/*
|
3 |
|
|
services_ntpd.php
|
4 |
|
|
|
5 |
c1e68244
|
nagyrobi
|
Copyright (C) 2013 Dagorlad
|
6 |
cf180ccc
|
jim-p
|
Copyright (C) 2012 Jim Pingle
|
7 |
ce77a9c4
|
Phil Davis
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
8 |
cf180ccc
|
jim-p
|
All rights reserved.
|
9 |
|
|
|
10 |
|
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
|
|
|
13 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
|
|
|
16 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
17 |
|
|
notice, this list of conditions and the following disclaimer in the
|
18 |
|
|
documentation and/or other materials provided with the distribution.
|
19 |
|
|
|
20 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
30 |
|
|
*/
|
31 |
|
|
/*
|
32 |
08d56bd1
|
sbeaver
|
pfSense_MODULE: ntpd
|
33 |
cf180ccc
|
jim-p
|
*/
|
34 |
|
|
|
35 |
|
|
##|+PRIV
|
36 |
|
|
##|*IDENT=page-services-ntpd
|
37 |
|
|
##|*NAME=Services: NTP
|
38 |
|
|
##|*DESCR=Allow access to the 'Services: NTP' page.
|
39 |
|
|
##|*MATCH=services_ntpd.php*
|
40 |
|
|
##|-PRIV
|
41 |
|
|
|
42 |
08d56bd1
|
sbeaver
|
define(NUMTIMESERVERS, 10); // The maximum number of configurable time servers
|
43 |
cf180ccc
|
jim-p
|
require("guiconfig.inc");
|
44 |
c1e68244
|
nagyrobi
|
require_once('rrd.inc');
|
45 |
|
|
require_once("shaper.inc");
|
46 |
cf180ccc
|
jim-p
|
|
47 |
7a6f0ebc
|
Phil Davis
|
if (!is_array($config['ntpd'])) {
|
48 |
08005d0a
|
Ermal
|
$config['ntpd'] = array();
|
49 |
7a6f0ebc
|
Phil Davis
|
}
|
50 |
08005d0a
|
Ermal
|
|
51 |
|
|
if (empty($config['ntpd']['interface'])) {
|
52 |
|
|
if (is_array($config['installedpackages']['openntpd']) && is_array($config['installedpackages']['openntpd']['config']) &&
|
53 |
08d56bd1
|
sbeaver
|
is_array($config['installedpackages']['openntpd']['config'][0]) && !empty($config['installedpackages']['openntpd']['config'][0]['interface'])) {
|
54 |
46ca7f3d
|
jim-p
|
$pconfig['interface'] = explode(",", $config['installedpackages']['openntpd']['config'][0]['interface']);
|
55 |
cf180ccc
|
jim-p
|
unset($config['installedpackages']['openntpd']);
|
56 |
08005d0a
|
Ermal
|
write_config("Upgraded settings from openttpd");
|
57 |
7a6f0ebc
|
Phil Davis
|
} else {
|
58 |
cf180ccc
|
jim-p
|
$pconfig['interface'] = array();
|
59 |
7a6f0ebc
|
Phil Davis
|
}
|
60 |
|
|
} else {
|
61 |
cf180ccc
|
jim-p
|
$pconfig['interface'] = explode(",", $config['ntpd']['interface']);
|
62 |
7a6f0ebc
|
Phil Davis
|
}
|
63 |
cf180ccc
|
jim-p
|
|
64 |
08d56bd1
|
sbeaver
|
if($_GET['addrow'])
|
65 |
|
|
$maxrows = $_GET['addrow'] + 1;
|
66 |
|
|
else
|
67 |
|
|
$maxrows = 3;
|
68 |
cf180ccc
|
jim-p
|
|
69 |
08d56bd1
|
sbeaver
|
if ($_POST) {
|
70 |
cf180ccc
|
jim-p
|
unset($input_errors);
|
71 |
|
|
$pconfig = $_POST;
|
72 |
|
|
|
73 |
|
|
if (!$input_errors) {
|
74 |
7a6f0ebc
|
Phil Davis
|
if (is_array($_POST['interface'])) {
|
75 |
58168f4e
|
jim-p
|
$config['ntpd']['interface'] = implode(",", $_POST['interface']);
|
76 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['interface'])) {
|
77 |
58168f4e
|
jim-p
|
unset($config['ntpd']['interface']);
|
78 |
7a6f0ebc
|
Phil Davis
|
}
|
79 |
cf180ccc
|
jim-p
|
|
80 |
7a6f0ebc
|
Phil Davis
|
if (!empty($_POST['gpsport']) && file_exists('/dev/'.$_POST['gpsport'])) {
|
81 |
5c8843d5
|
jim-p
|
$config['ntpd']['gpsport'] = $_POST['gpsport'];
|
82 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['gpsport'])) {
|
83 |
5c8843d5
|
jim-p
|
unset($config['ntpd']['gpsport']);
|
84 |
7a6f0ebc
|
Phil Davis
|
}
|
85 |
5c8843d5
|
jim-p
|
|
86 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['prefer']);
|
87 |
|
|
unset($config['ntpd']['noselect']);
|
88 |
|
|
$timeservers = '';
|
89 |
08d56bd1
|
sbeaver
|
|
90 |
c1e68244
|
nagyrobi
|
for ($i = 0; $i < 10; $i++) {
|
91 |
08005d0a
|
Ermal
|
$tserver = trim($_POST["server{$i}"]);
|
92 |
c1e68244
|
nagyrobi
|
if (!empty($tserver)) {
|
93 |
|
|
$timeservers .= "{$tserver} ";
|
94 |
7a6f0ebc
|
Phil Davis
|
if (!empty($_POST["servprefer{$i}"])) {
|
95 |
|
|
$config['ntpd']['prefer'] .= "{$tserver} ";
|
96 |
|
|
}
|
97 |
|
|
if (!empty($_POST["servselect{$i}"])) {
|
98 |
|
|
$config['ntpd']['noselect'] .= "{$tserver} ";
|
99 |
|
|
}
|
100 |
c1e68244
|
nagyrobi
|
}
|
101 |
|
|
}
|
102 |
7a6f0ebc
|
Phil Davis
|
if (trim($timeservers) == "") {
|
103 |
4e6b0a0e
|
nagyrobi
|
$timeservers = "pool.ntp.org";
|
104 |
7a6f0ebc
|
Phil Davis
|
}
|
105 |
c1e68244
|
nagyrobi
|
$config['system']['timeservers'] = trim($timeservers);
|
106 |
|
|
|
107 |
7a6f0ebc
|
Phil Davis
|
if (!empty($_POST['ntporphan']) && ($_POST['ntporphan'] < 17) && ($_POST['ntporphan'] != '12')) {
|
108 |
c1e68244
|
nagyrobi
|
$config['ntpd']['orphan'] = $_POST['ntporphan'];
|
109 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['orphan'])) {
|
110 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['orphan']);
|
111 |
7a6f0ebc
|
Phil Davis
|
}
|
112 |
c1e68244
|
nagyrobi
|
|
113 |
7a6f0ebc
|
Phil Davis
|
if (!empty($_POST['logpeer'])) {
|
114 |
c1e68244
|
nagyrobi
|
$config['ntpd']['logpeer'] = $_POST['logpeer'];
|
115 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['logpeer'])) {
|
116 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['logpeer']);
|
117 |
7a6f0ebc
|
Phil Davis
|
}
|
118 |
c1e68244
|
nagyrobi
|
|
119 |
7a6f0ebc
|
Phil Davis
|
if (!empty($_POST['logsys'])) {
|
120 |
c1e68244
|
nagyrobi
|
$config['ntpd']['logsys'] = $_POST['logsys'];
|
121 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['logsys'])) {
|
122 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['logsys']);
|
123 |
7a6f0ebc
|
Phil Davis
|
}
|
124 |
c1e68244
|
nagyrobi
|
|
125 |
7a6f0ebc
|
Phil Davis
|
if (!empty($_POST['clockstats'])) {
|
126 |
c1e68244
|
nagyrobi
|
$config['ntpd']['clockstats'] = $_POST['clockstats'];
|
127 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['clockstats'])) {
|
128 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['clockstats']);
|
129 |
7a6f0ebc
|
Phil Davis
|
}
|
130 |
c1e68244
|
nagyrobi
|
|
131 |
7a6f0ebc
|
Phil Davis
|
if (!empty($_POST['loopstats'])) {
|
132 |
c1e68244
|
nagyrobi
|
$config['ntpd']['loopstats'] = $_POST['loopstats'];
|
133 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['loopstats'])) {
|
134 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['loopstats']);
|
135 |
7a6f0ebc
|
Phil Davis
|
}
|
136 |
c1e68244
|
nagyrobi
|
|
137 |
7a6f0ebc
|
Phil Davis
|
if (!empty($_POST['peerstats'])) {
|
138 |
c1e68244
|
nagyrobi
|
$config['ntpd']['peerstats'] = $_POST['peerstats'];
|
139 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['peerstats'])) {
|
140 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['peerstats']);
|
141 |
7a6f0ebc
|
Phil Davis
|
}
|
142 |
c1e68244
|
nagyrobi
|
|
143 |
7a6f0ebc
|
Phil Davis
|
if (empty($_POST['kod'])) {
|
144 |
c1e68244
|
nagyrobi
|
$config['ntpd']['kod'] = 'on';
|
145 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['kod'])) {
|
146 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['kod']);
|
147 |
7a6f0ebc
|
Phil Davis
|
}
|
148 |
c1e68244
|
nagyrobi
|
|
149 |
7a6f0ebc
|
Phil Davis
|
if (empty($_POST['nomodify'])) {
|
150 |
c1e68244
|
nagyrobi
|
$config['ntpd']['nomodify'] = 'on';
|
151 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['nomodify'])) {
|
152 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['nomodify']);
|
153 |
7a6f0ebc
|
Phil Davis
|
}
|
154 |
c1e68244
|
nagyrobi
|
|
155 |
7a6f0ebc
|
Phil Davis
|
if (!empty($_POST['noquery'])) {
|
156 |
c1e68244
|
nagyrobi
|
$config['ntpd']['noquery'] = $_POST['noquery'];
|
157 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['noquery'])) {
|
158 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['noquery']);
|
159 |
7a6f0ebc
|
Phil Davis
|
}
|
160 |
c1e68244
|
nagyrobi
|
|
161 |
7a6f0ebc
|
Phil Davis
|
if (!empty($_POST['noserve'])) {
|
162 |
c1e68244
|
nagyrobi
|
$config['ntpd']['noserve'] = $_POST['noserve'];
|
163 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['noserve'])) {
|
164 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['noserve']);
|
165 |
7a6f0ebc
|
Phil Davis
|
}
|
166 |
c1e68244
|
nagyrobi
|
|
167 |
7a6f0ebc
|
Phil Davis
|
if (empty($_POST['nopeer'])) {
|
168 |
c1e68244
|
nagyrobi
|
$config['ntpd']['nopeer'] = 'on';
|
169 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['nopeer'])) {
|
170 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['nopeer']);
|
171 |
7a6f0ebc
|
Phil Davis
|
}
|
172 |
c1e68244
|
nagyrobi
|
|
173 |
7a6f0ebc
|
Phil Davis
|
if (empty($_POST['notrap'])) {
|
174 |
c1e68244
|
nagyrobi
|
$config['ntpd']['notrap'] = 'on';
|
175 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['notrap'])) {
|
176 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['notrap']);
|
177 |
7a6f0ebc
|
Phil Davis
|
}
|
178 |
c1e68244
|
nagyrobi
|
|
179 |
7a6f0ebc
|
Phil Davis
|
if ((empty($_POST['statsgraph'])) == (isset($config['ntpd']['statsgraph']))) {
|
180 |
e2caaee8
|
k-paulius
|
$enable_rrd_graphing = true;
|
181 |
7a6f0ebc
|
Phil Davis
|
}
|
182 |
|
|
if (!empty($_POST['statsgraph'])) {
|
183 |
c1e68244
|
nagyrobi
|
$config['ntpd']['statsgraph'] = $_POST['statsgraph'];
|
184 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['statsgraph'])) {
|
185 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['statsgraph']);
|
186 |
7a6f0ebc
|
Phil Davis
|
}
|
187 |
|
|
if (isset($enable_rrd_graphing)) {
|
188 |
e2caaee8
|
k-paulius
|
enable_rrd_graphing();
|
189 |
7a6f0ebc
|
Phil Davis
|
}
|
190 |
c1e68244
|
nagyrobi
|
|
191 |
7a6f0ebc
|
Phil Davis
|
if (!empty($_POST['leaptxt'])) {
|
192 |
c1e68244
|
nagyrobi
|
$config['ntpd']['leapsec'] = base64_encode($_POST['leaptxt']);
|
193 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['leapsec'])) {
|
194 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['leapsec']);
|
195 |
7a6f0ebc
|
Phil Davis
|
}
|
196 |
c1e68244
|
nagyrobi
|
|
197 |
7a6f0ebc
|
Phil Davis
|
if (is_uploaded_file($_FILES['leapfile']['tmp_name'])) {
|
198 |
c1e68244
|
nagyrobi
|
$config['ntpd']['leapsec'] = base64_encode(file_get_contents($_FILES['leapfile']['tmp_name']));
|
199 |
7a6f0ebc
|
Phil Davis
|
}
|
200 |
c1e68244
|
nagyrobi
|
|
201 |
cf180ccc
|
jim-p
|
write_config("Updated NTP Server Settings");
|
202 |
|
|
|
203 |
|
|
$retval = 0;
|
204 |
|
|
$retval = system_ntp_configure();
|
205 |
|
|
$savemsg = get_std_save_message($retval);
|
206 |
08d56bd1
|
sbeaver
|
}
|
207 |
|
|
}
|
208 |
|
|
|
209 |
|
|
function build_interface_list() {
|
210 |
|
|
global $pconfig;
|
211 |
|
|
|
212 |
|
|
$iflist = array('options' => array(), 'selected' => array());
|
213 |
|
|
|
214 |
|
|
$interfaces = get_configured_interface_with_descr();
|
215 |
|
|
$carplist = get_configured_carp_interface_list();
|
216 |
|
|
|
217 |
|
|
foreach ($carplist as $cif => $carpip)
|
218 |
|
|
$interfaces[$cif] = $carpip . " (" . get_vip_descr($carpip) .")";
|
219 |
|
|
|
220 |
|
|
$aliaslist = get_configured_ip_aliases_list();
|
221 |
|
|
|
222 |
|
|
foreach ($aliaslist as $aliasip => $aliasif)
|
223 |
|
|
$interfaces[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
|
224 |
|
|
|
225 |
|
|
$size = (count($interfaces) < 10) ? count($interfaces) : 10;
|
226 |
|
|
|
227 |
|
|
foreach ($interfaces as $iface => $ifacename) {
|
228 |
|
|
if (!is_ipaddr(get_interface_ip($iface)) && !is_ipaddr($iface))
|
229 |
|
|
continue;
|
230 |
|
|
|
231 |
|
|
$iflist['options']['$iface'] = $ifacename;
|
232 |
|
|
|
233 |
|
|
if (in_array($iface, $pconfig['interface']))
|
234 |
|
|
array_push($iflist['slected'], $iface);
|
235 |
cf180ccc
|
jim-p
|
|
236 |
|
|
}
|
237 |
08d56bd1
|
sbeaver
|
|
238 |
|
|
return($iflist);
|
239 |
cf180ccc
|
jim-p
|
}
|
240 |
08d56bd1
|
sbeaver
|
|
241 |
d9555fc5
|
Colin Fleming
|
$closehead = false;
|
242 |
c1e68244
|
nagyrobi
|
$pconfig = &$config['ntpd'];
|
243 |
7a6f0ebc
|
Phil Davis
|
if (empty($pconfig['interface'])) {
|
244 |
63d5a5e0
|
Jean Cyr
|
$pconfig['interface'] = array();
|
245 |
7a6f0ebc
|
Phil Davis
|
} else {
|
246 |
63d5a5e0
|
Jean Cyr
|
$pconfig['interface'] = explode(",", $pconfig['interface']);
|
247 |
7a6f0ebc
|
Phil Davis
|
}
|
248 |
|
|
$pgtitle = array(gettext("Services"), gettext("NTP"));
|
249 |
b32dd0a6
|
jim-p
|
$shortcut_section = "ntp";
|
250 |
cf180ccc
|
jim-p
|
include("head.inc");
|
251 |
|
|
|
252 |
08d56bd1
|
sbeaver
|
if ($input_errors)
|
253 |
|
|
print_input_errors($input_errors);
|
254 |
|
|
if ($savemsg)
|
255 |
|
|
print_info_box($savemsg, 'success');
|
256 |
|
|
|
257 |
|
|
$tab_array = array();
|
258 |
|
|
$tab_array[] = array(gettext("NTP"), true, "services_ntpd.php");
|
259 |
|
|
$tab_array[] = array(gettext("Serial GPS"), false, "services_ntpd_gps.php");
|
260 |
|
|
$tab_array[] = array(gettext("PPS"), false, "services_ntpd_pps.php");
|
261 |
|
|
display_top_tabs($tab_array);
|
262 |
|
|
|
263 |
|
|
require('classes/Form.class.php');
|
264 |
|
|
|
265 |
|
|
$form = new Form;
|
266 |
|
|
|
267 |
|
|
$section = new Form_Section('NTP server configuration');
|
268 |
|
|
|
269 |
|
|
$iflist = build_interface_list();
|
270 |
|
|
|
271 |
|
|
$section->addInput(new Form_Select(
|
272 |
|
|
'interface',
|
273 |
|
|
'Interface',
|
274 |
|
|
$iflist['selected'],
|
275 |
|
|
$iflist['options'],
|
276 |
|
|
true
|
277 |
|
|
))->setHelp('Interfaces without an IP address will not be shown.' . '<br />' .
|
278 |
|
|
'Selecting no interfaces will listen on all interfaces with a wildcard.' . '<br />' .
|
279 |
|
|
'Selecting all interfaces will explicitly listen on only the interfaces/IPs specified.');
|
280 |
|
|
|
281 |
|
|
// NUMTIMESERVERS time servers are always available, but we only display a smaller number of these ($maxrows)
|
282 |
|
|
// Clicking the 'Add Row' button increments $maxrows so you can see more of time servers
|
283 |
|
|
$timeservers = explode( ' ', $config['system']['timeservers']);
|
284 |
|
|
for ($i = $j = 0; $i < NUMTIMESERVERS; $i++){
|
285 |
|
|
|
286 |
|
|
if($i >= $maxrows)
|
287 |
|
|
continue;
|
288 |
|
|
|
289 |
|
|
$group = new Form_Group($i == 0 ? 'Time servers':'');
|
290 |
|
|
|
291 |
|
|
$group->add(new Form_Input(
|
292 |
|
|
'server' . $i,
|
293 |
|
|
null,
|
294 |
|
|
'text',
|
295 |
|
|
$timeservers[$i]
|
296 |
|
|
));
|
297 |
|
|
|
298 |
|
|
$group->add(new Form_Checkbox(
|
299 |
|
|
'servprefer' . $i,
|
300 |
|
|
null,
|
301 |
|
|
'Prefer',
|
302 |
|
|
isset($config['ntpd']['prefer']) && isset($timeservers[$i]) && substr_count($config['ntpd']['prefer'], $timeservers[$i])
|
303 |
|
|
));
|
304 |
|
|
|
305 |
|
|
$group->add(new Form_Checkbox(
|
306 |
|
|
'servselect' . $i,
|
307 |
|
|
null,
|
308 |
|
|
'NoSelect',
|
309 |
|
|
isset($config['ntpd']['noselect']) && isset($timeservers[$i]) && substr_count($config['ntpd']['noselect'], $timeservers[$i])
|
310 |
|
|
));
|
311 |
|
|
|
312 |
|
|
$section->add($group);
|
313 |
|
|
}
|
314 |
|
|
|
315 |
|
|
// Show the 'Add Rows' button only if we are currently displaying less than the maximum
|
316 |
|
|
// number of configured servers
|
317 |
|
|
if($maxrows < NUMTIMESERVERS) {
|
318 |
|
|
$btnaddrow = new Form_Button(
|
319 |
|
|
'btnaddrow',
|
320 |
|
|
'Add Server',
|
321 |
|
|
'services_ntpd.php?addrow=' . $maxrows
|
322 |
|
|
);
|
323 |
|
|
|
324 |
|
|
$btnaddrow->removeClass('btn-primary')->addClass('btn-success btn-sm');
|
325 |
|
|
} else
|
326 |
|
|
$btnaddrow = false;
|
327 |
|
|
|
328 |
|
|
$section->addInput(new Form_StaticText(
|
329 |
|
|
null,
|
330 |
|
|
$btnaddrow
|
331 |
|
|
))->setHelp('For best results three to five servers should be configured here.' . '<br />' .
|
332 |
|
|
'The prefer option indicates that NTP should favor the use of this server more than all others.' . '<br />' .
|
333 |
|
|
'The noselect option indicates that NTP should not use this server for time, but stats for this server will be collected and displayed.');
|
334 |
|
|
|
335 |
|
|
$section->addInput(new Form_Input(
|
336 |
|
|
'ntporphan',
|
337 |
|
|
'Orphan mode',
|
338 |
|
|
'text',
|
339 |
|
|
$pconfig['ntporphan']
|
340 |
|
|
))->setHelp('Orphan mode allows the system clock to be used when no other clocks are available. ' .
|
341 |
|
|
'The number here specifies the stratum reported during orphan mode and should normally be set to a number high enough ' .
|
342 |
|
|
'to insure that any other servers available to clients are preferred over this server. (default: 12).');
|
343 |
|
|
|
344 |
|
|
$section->addInput(new Form_Checkbox(
|
345 |
|
|
'statsgraph',
|
346 |
|
|
'NTP Graphs',
|
347 |
|
|
'Enable RRD graphs of NTP statistics (default: disabled).',
|
348 |
|
|
$pconfig['statsgraph']
|
349 |
|
|
));
|
350 |
|
|
|
351 |
|
|
$section->addInput(new Form_Checkbox(
|
352 |
|
|
'logpeer',
|
353 |
|
|
'Syslog logging',
|
354 |
|
|
'Enable logging of peer messages (default: disabled).',
|
355 |
|
|
$pconfig['logpeer']
|
356 |
|
|
));
|
357 |
|
|
|
358 |
|
|
$section->addInput(new Form_Checkbox(
|
359 |
|
|
'logsys',
|
360 |
|
|
null,
|
361 |
|
|
'Enable logging of system messages (default: disabled).',
|
362 |
|
|
$pconfig['logsys']
|
363 |
|
|
))->setHelp('These options enable additional messages from NTP to be written to the System Log ' .
|
364 |
|
|
'<a href="diag_logs_ntpd.php">' . 'Status > System Logs > NTP' . '</a>');
|
365 |
|
|
|
366 |
|
|
// Statistics logging section
|
367 |
|
|
$btnadvstats = new Form_Button(
|
368 |
|
|
'btnadvstats',
|
369 |
|
|
'Advanced'
|
370 |
|
|
);
|
371 |
|
|
|
372 |
|
|
$btnadvstats->removeClass('btn-primary')->addClass('btn-default btn-sm');
|
373 |
|
|
|
374 |
|
|
$section->addInput(new Form_StaticText(
|
375 |
|
|
'Statistics logging',
|
376 |
|
|
$btnadvstats
|
377 |
|
|
))->setHelp('Warning: These options will create persistant daily log files in /var/log/ntp.');
|
378 |
|
|
|
379 |
|
|
$section->addInput(new Form_Checkbox(
|
380 |
|
|
'clockstats',
|
381 |
|
|
null,
|
382 |
|
|
'Enable logging of reference clock statistics (default: disabled).',
|
383 |
|
|
$pconfig['clockstats']
|
384 |
|
|
));
|
385 |
|
|
|
386 |
|
|
$section->addInput(new Form_Checkbox(
|
387 |
|
|
'loopstats',
|
388 |
|
|
null,
|
389 |
|
|
'Enable logging of clock discipline statistics (default: disabled).',
|
390 |
|
|
$pconfig['loopstats']
|
391 |
|
|
));
|
392 |
|
|
|
393 |
|
|
$section->addInput(new Form_Checkbox(
|
394 |
|
|
'peerstats',
|
395 |
|
|
null,
|
396 |
|
|
'Enable logging of NTP peer statistics (default: disabled).',
|
397 |
|
|
$pconfig['peerstats']
|
398 |
|
|
));
|
399 |
|
|
|
400 |
|
|
// Access restrictions section
|
401 |
|
|
$btnadvrestr = new Form_Button(
|
402 |
|
|
'btnadvrestr',
|
403 |
|
|
'Advanced'
|
404 |
|
|
);
|
405 |
|
|
|
406 |
|
|
$btnadvrestr->removeClass('btn-primary')->addClass('btn-default btn-sm');
|
407 |
|
|
|
408 |
|
|
$section->addInput(new Form_StaticText(
|
409 |
|
|
'Access Restrictions',
|
410 |
|
|
$btnadvrestr
|
411 |
|
|
))->setHelp('These options control access to NTP from the WAN.');
|
412 |
|
|
|
413 |
|
|
$section->addInput(new Form_Checkbox(
|
414 |
|
|
'kod',
|
415 |
|
|
null,
|
416 |
|
|
'Enable Kiss-o\'-death packets (default: enabled).',
|
417 |
|
|
$pconfig['kod']
|
418 |
|
|
));
|
419 |
|
|
|
420 |
|
|
$section->addInput(new Form_Checkbox(
|
421 |
|
|
'nomodify',
|
422 |
|
|
null,
|
423 |
|
|
'Deny state modifications (i.e. run time configuration) by ntpq and ntpdc (default: enabled).',
|
424 |
|
|
$pconfig['nomodify']
|
425 |
|
|
));
|
426 |
|
|
|
427 |
|
|
$section->addInput(new Form_Checkbox(
|
428 |
|
|
'noquery',
|
429 |
|
|
null,
|
430 |
|
|
'Disable ntpq and ntpdc queries (default: disabled).',
|
431 |
|
|
$pconfig['noquery']
|
432 |
|
|
));
|
433 |
|
|
|
434 |
|
|
$section->addInput(new Form_Checkbox(
|
435 |
|
|
'noserve',
|
436 |
|
|
null,
|
437 |
|
|
'Disable all except ntpq and ntpdc queries (default: disabled).',
|
438 |
|
|
$pconfig['noserve']
|
439 |
|
|
));
|
440 |
|
|
|
441 |
|
|
$section->addInput(new Form_Checkbox(
|
442 |
|
|
'nopeer',
|
443 |
|
|
null,
|
444 |
|
|
'Deny packets that attempt a peer association (default: enabled).',
|
445 |
|
|
$pconfig['nopeer']
|
446 |
|
|
));
|
447 |
|
|
|
448 |
|
|
$section->addInput(new Form_Checkbox(
|
449 |
|
|
'notrap',
|
450 |
|
|
null,
|
451 |
|
|
'Deny mode 6 control message trap service (default: enabled).',
|
452 |
|
|
$pconfig['notrap']
|
453 |
|
|
))->addClass('advrestrictions');
|
454 |
|
|
|
455 |
|
|
// Leap seconds section
|
456 |
|
|
$btnleap = new Form_Button(
|
457 |
|
|
'btnleap',
|
458 |
|
|
'Advanced'
|
459 |
|
|
);
|
460 |
|
|
|
461 |
|
|
$btnleap->removeClass('btn-primary')->addClass('btn-default btn-sm');
|
462 |
|
|
|
463 |
|
|
$section->addInput(new Form_StaticText(
|
464 |
|
|
'Leap seconds',
|
465 |
|
|
$btnleap
|
466 |
|
|
))->setHelp('A leap second file allows NTP to advertize an upcoming leap second addition or subtraction. ' .
|
467 |
|
|
'Normally this is only useful if this server is a stratum 1 time server. ');
|
468 |
|
|
|
469 |
|
|
$section->addInput(new Form_Textarea(
|
470 |
|
|
'leaptext',
|
471 |
|
|
null,
|
472 |
|
|
base64_decode(chunk_split($pconfig['leapsec']))
|
473 |
|
|
))->setHelp('Enter Leap second configuration as text OR select a file to upload');
|
474 |
|
|
|
475 |
|
|
$section->addInput(new Form_Input(
|
476 |
|
|
'leapfile',
|
477 |
|
|
null,
|
478 |
|
|
'file'
|
479 |
|
|
))->addClass('btn-default');
|
480 |
|
|
|
481 |
|
|
$form->add($section);
|
482 |
|
|
print($form);
|
483 |
|
|
|
484 |
cf180ccc
|
jim-p
|
?>
|
485 |
|
|
|
486 |
08d56bd1
|
sbeaver
|
<script>
|
487 |
d9555fc5
|
Colin Fleming
|
//<![CDATA[
|
488 |
08d56bd1
|
sbeaver
|
events.push(function(){
|
489 |
|
|
|
490 |
|
|
// Hides the <div> in which the specified input element lives so that the input, its label and help text are hidden
|
491 |
|
|
function hideInput(id, hide) {
|
492 |
|
|
if(hide)
|
493 |
|
|
$('#' + id).parent().parent('div').addClass('hidden');
|
494 |
|
|
else
|
495 |
|
|
$('#' + id).parent().parent('div').removeClass('hidden');
|
496 |
c1e68244
|
nagyrobi
|
}
|
497 |
|
|
|
498 |
08d56bd1
|
sbeaver
|
// Hides the <div> in which the specified checkbox lives so that the checkbox, its label and help text are hidden
|
499 |
|
|
function hideCheckbox(id, hide) {
|
500 |
|
|
if(hide)
|
501 |
|
|
$('#' + id).parent().parent().parent('div').addClass('hidden');
|
502 |
|
|
else
|
503 |
|
|
$('#' + id).parent().parent().parent('div').removeClass('hidden');
|
504 |
c1e68244
|
nagyrobi
|
}
|
505 |
|
|
|
506 |
08d56bd1
|
sbeaver
|
// Make the ‘clear’ button a plain button, not a submit button
|
507 |
|
|
$('#btnadvstats').prop('type','button');
|
508 |
|
|
|
509 |
|
|
// On click, show the controls in the stats section
|
510 |
|
|
$("#btnadvstats").click(function() {
|
511 |
|
|
hideCheckbox('clockstats', false);
|
512 |
|
|
hideCheckbox('loopstats', false);
|
513 |
|
|
hideCheckbox('peerstats', false);
|
514 |
|
|
});
|
515 |
|
|
|
516 |
|
|
// Make the ‘clear’ button a plain button, not a submit button
|
517 |
|
|
$('#btnadvrestr').prop('type','button');
|
518 |
|
|
|
519 |
|
|
// On click, show the controls in the restrictions section
|
520 |
|
|
$("#btnadvrestr").click(function() {
|
521 |
|
|
hideCheckbox('nomodify', false);
|
522 |
|
|
hideCheckbox('noquery', false);
|
523 |
|
|
hideCheckbox('noserve', false);
|
524 |
|
|
hideCheckbox('nopeer', false);
|
525 |
|
|
hideCheckbox('notrap', false);
|
526 |
|
|
});
|
527 |
|
|
|
528 |
|
|
// Make the ‘btnleap’ button a plain button, not a submit button
|
529 |
|
|
$('#btnleap').prop('type','button');
|
530 |
|
|
|
531 |
|
|
// On click, show the controls in the leap seconds section
|
532 |
|
|
$("#btnleap").click(function() {
|
533 |
|
|
hideInput('leaptext', false);
|
534 |
|
|
hideInput('leapfile', false);
|
535 |
|
|
});
|
536 |
|
|
|
537 |
|
|
// Set intial states
|
538 |
|
|
hideCheckbox('clockstats', true);
|
539 |
|
|
hideCheckbox('loopstats', true);
|
540 |
|
|
hideCheckbox('peerstats', true);
|
541 |
|
|
hideCheckbox('kod', true);
|
542 |
|
|
hideCheckbox('nomodify', true);
|
543 |
|
|
hideCheckbox('noquery', true);
|
544 |
|
|
hideCheckbox('noserve', true);
|
545 |
|
|
hideCheckbox('nopeer', true);
|
546 |
|
|
hideCheckbox('notrap', true);
|
547 |
|
|
hideInput('leaptext', true);
|
548 |
|
|
hideInput('leapfile', true);
|
549 |
|
|
});
|
550 |
d9555fc5
|
Colin Fleming
|
//]]>
|
551 |
c1e68244
|
nagyrobi
|
</script>
|
552 |
cf180ccc
|
jim-p
|
|
553 |
08d56bd1
|
sbeaver
|
<?php include("foot.inc");
|