Project

General

Profile

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