Project

General

Profile

Download (14 KB) Statistics
| Branch: | Tag: | Revision:
1 cf180ccc jim-p
<?php
2
/*
3 c5d81585 Renato Botelho
 * services_ntpd.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6 81299b5c Renato Botelho
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7 c5d81585 Renato Botelho
 * Copyright (c) 2013 Dagorlad
8
 * All rights reserved.
9
 *
10 b12ea3fb Renato Botelho
 * Licensed under the Apache License, Version 2.0 (the "License");
11
 * you may not use this file except in compliance with the License.
12
 * You may obtain a copy of the License at
13 c5d81585 Renato Botelho
 *
14 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
15 c5d81585 Renato Botelho
 *
16 b12ea3fb Renato Botelho
 * Unless required by applicable law or agreed to in writing, software
17
 * distributed under the License is distributed on an "AS IS" BASIS,
18
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
 * See the License for the specific language governing permissions and
20
 * limitations under the License.
21 f4439c00 Stephen Beaver
 */
22 cf180ccc jim-p
23
##|+PRIV
24
##|*IDENT=page-services-ntpd
25 448280c3 k-paulius
##|*NAME=Services: NTP Settings
26
##|*DESCR=Allow access to the 'Services: NTP Settings' page.
27 cf180ccc jim-p
##|*MATCH=services_ntpd.php*
28
##|-PRIV
29
30 820562e8 NewEraCracker
define('NUMTIMESERVERS', 10);		// The maximum number of configurable time servers
31 c81ef6e2 Phil Davis
require_once("guiconfig.inc");
32 c1e68244 nagyrobi
require_once('rrd.inc');
33
require_once("shaper.inc");
34 cf180ccc jim-p
35 7a6f0ebc Phil Davis
if (!is_array($config['ntpd'])) {
36 08005d0a Ermal
	$config['ntpd'] = array();
37 7a6f0ebc Phil Davis
}
38 08005d0a Ermal
39
if (empty($config['ntpd']['interface'])) {
40
	if (is_array($config['installedpackages']['openntpd']) && is_array($config['installedpackages']['openntpd']['config']) &&
41 20db3e1a Phil Davis
	    is_array($config['installedpackages']['openntpd']['config'][0]) && !empty($config['installedpackages']['openntpd']['config'][0]['interface'])) {
42 46ca7f3d jim-p
		$pconfig['interface'] = explode(",", $config['installedpackages']['openntpd']['config'][0]['interface']);
43 cf180ccc jim-p
		unset($config['installedpackages']['openntpd']);
44 4bfc3f7d Phil Davis
		write_config(gettext("Upgraded settings from openttpd"));
45 7a6f0ebc Phil Davis
	} else {
46 cf180ccc jim-p
		$pconfig['interface'] = array();
47 7a6f0ebc Phil Davis
	}
48
} else {
49 cf180ccc jim-p
	$pconfig['interface'] = explode(",", $config['ntpd']['interface']);
50 7a6f0ebc Phil Davis
}
51 cf180ccc jim-p
52 08d56bd1 sbeaver
if ($_POST) {
53 cf180ccc jim-p
	unset($input_errors);
54
	$pconfig = $_POST;
55
56 531c3486 jim-p
	if ((strlen($pconfig['ntporphan']) > 0) && (!is_numericint($pconfig['ntporphan']) || ($pconfig['ntporphan'] < 1) || ($pconfig['ntporphan'] > 15))) {
57
		$input_errors[] = gettext("The supplied value for NTP Orphan Mode is invalid.");
58
	}
59
60 cf180ccc jim-p
	if (!$input_errors) {
61 7a6f0ebc Phil Davis
		if (is_array($_POST['interface'])) {
62 58168f4e jim-p
			$config['ntpd']['interface'] = implode(",", $_POST['interface']);
63 7a6f0ebc Phil Davis
		} elseif (isset($config['ntpd']['interface'])) {
64 58168f4e jim-p
			unset($config['ntpd']['interface']);
65 7a6f0ebc Phil Davis
		}
66 cf180ccc jim-p
67 7a6f0ebc Phil Davis
		if (!empty($_POST['gpsport']) && file_exists('/dev/'.$_POST['gpsport'])) {
68 5c8843d5 jim-p
			$config['ntpd']['gpsport'] = $_POST['gpsport'];
69 7a6f0ebc Phil Davis
		} elseif (isset($config['ntpd']['gpsport'])) {
70 5c8843d5 jim-p
			unset($config['ntpd']['gpsport']);
71 7a6f0ebc Phil Davis
		}
72 5c8843d5 jim-p
73 c1e68244 nagyrobi
		unset($config['ntpd']['prefer']);
74
		unset($config['ntpd']['noselect']);
75 fbb652ed jim-p
		unset($config['ntpd']['ispool']);
76 c1e68244 nagyrobi
		$timeservers = '';
77 08d56bd1 sbeaver
78 83b9d03e Phil Davis
		for ($i = 0; $i < NUMTIMESERVERS; $i++) {
79 08005d0a Ermal
			$tserver = trim($_POST["server{$i}"]);
80 c1e68244 nagyrobi
			if (!empty($tserver)) {
81
				$timeservers .= "{$tserver} ";
82 7a6f0ebc Phil Davis
				if (!empty($_POST["servprefer{$i}"])) {
83
					$config['ntpd']['prefer'] .= "{$tserver} ";
84
				}
85
				if (!empty($_POST["servselect{$i}"])) {
86
					$config['ntpd']['noselect'] .= "{$tserver} ";
87
				}
88 fbb652ed jim-p
				if (!empty($_POST["servispool{$i}"])) {
89
					$config['ntpd']['ispool'] .= "{$tserver} ";
90
				}
91 c1e68244 nagyrobi
			}
92
		}
93 7a6f0ebc Phil Davis
		if (trim($timeservers) == "") {
94 4e6b0a0e nagyrobi
			$timeservers = "pool.ntp.org";
95 7a6f0ebc Phil Davis
		}
96 c1e68244 nagyrobi
		$config['system']['timeservers'] = trim($timeservers);
97
98 531c3486 jim-p
		$config['ntpd']['orphan'] = trim($pconfig['ntporphan']);
99 c1e68244 nagyrobi
100 7a6f0ebc Phil Davis
		if (!empty($_POST['logpeer'])) {
101 c1e68244 nagyrobi
			$config['ntpd']['logpeer'] = $_POST['logpeer'];
102 7a6f0ebc Phil Davis
		} elseif (isset($config['ntpd']['logpeer'])) {
103 c1e68244 nagyrobi
			unset($config['ntpd']['logpeer']);
104 7a6f0ebc Phil Davis
		}
105 c1e68244 nagyrobi
106 7a6f0ebc Phil Davis
		if (!empty($_POST['logsys'])) {
107 c1e68244 nagyrobi
			$config['ntpd']['logsys'] = $_POST['logsys'];
108 7a6f0ebc Phil Davis
		} elseif (isset($config['ntpd']['logsys'])) {
109 c1e68244 nagyrobi
			unset($config['ntpd']['logsys']);
110 7a6f0ebc Phil Davis
		}
111 c1e68244 nagyrobi
112 7a6f0ebc Phil Davis
		if (!empty($_POST['clockstats'])) {
113 c1e68244 nagyrobi
			$config['ntpd']['clockstats'] = $_POST['clockstats'];
114 7a6f0ebc Phil Davis
		} elseif (isset($config['ntpd']['clockstats'])) {
115 c1e68244 nagyrobi
			unset($config['ntpd']['clockstats']);
116 7a6f0ebc Phil Davis
		}
117 c1e68244 nagyrobi
118 7a6f0ebc Phil Davis
		if (!empty($_POST['loopstats'])) {
119 c1e68244 nagyrobi
			$config['ntpd']['loopstats'] = $_POST['loopstats'];
120 7a6f0ebc Phil Davis
		} elseif (isset($config['ntpd']['loopstats'])) {
121 c1e68244 nagyrobi
			unset($config['ntpd']['loopstats']);
122 7a6f0ebc Phil Davis
		}
123 c1e68244 nagyrobi
124 7a6f0ebc Phil Davis
		if (!empty($_POST['peerstats'])) {
125 c1e68244 nagyrobi
			$config['ntpd']['peerstats'] = $_POST['peerstats'];
126 7a6f0ebc Phil Davis
		} elseif (isset($config['ntpd']['peerstats'])) {
127 c1e68244 nagyrobi
			unset($config['ntpd']['peerstats']);
128 7a6f0ebc Phil Davis
		}
129 c1e68244 nagyrobi
130 7a6f0ebc Phil Davis
		if ((empty($_POST['statsgraph'])) == (isset($config['ntpd']['statsgraph']))) {
131 e2caaee8 k-paulius
			$enable_rrd_graphing = true;
132 7a6f0ebc Phil Davis
		}
133
		if (!empty($_POST['statsgraph'])) {
134 c1e68244 nagyrobi
			$config['ntpd']['statsgraph'] = $_POST['statsgraph'];
135 7a6f0ebc Phil Davis
		} elseif (isset($config['ntpd']['statsgraph'])) {
136 c1e68244 nagyrobi
			unset($config['ntpd']['statsgraph']);
137 7a6f0ebc Phil Davis
		}
138
		if (isset($enable_rrd_graphing)) {
139 e2caaee8 k-paulius
			enable_rrd_graphing();
140 7a6f0ebc Phil Davis
		}
141 c1e68244 nagyrobi
142 f99f8a67 Phil Davis
		if (!empty($_POST['leaptext'])) {
143
			$config['ntpd']['leapsec'] = base64_encode($_POST['leaptext']);
144 7a6f0ebc Phil Davis
		} elseif (isset($config['ntpd']['leapsec'])) {
145 c1e68244 nagyrobi
			unset($config['ntpd']['leapsec']);
146 7a6f0ebc Phil Davis
		}
147 c1e68244 nagyrobi
148 7a6f0ebc Phil Davis
		if (is_uploaded_file($_FILES['leapfile']['tmp_name'])) {
149 c1e68244 nagyrobi
			$config['ntpd']['leapsec'] = base64_encode(file_get_contents($_FILES['leapfile']['tmp_name']));
150 7a6f0ebc Phil Davis
		}
151 c1e68244 nagyrobi
152 cf180ccc jim-p
		write_config("Updated NTP Server Settings");
153
154 44c42356 Phil Davis
		$changes_applied = true;
155 cf180ccc jim-p
		$retval = 0;
156 44c42356 Phil Davis
		$retval |= system_ntp_configure();
157 08d56bd1 sbeaver
	}
158
}
159
160
function build_interface_list() {
161
	global $pconfig;
162
163
	$iflist = array('options' => array(), 'selected' => array());
164
165
	$interfaces = get_configured_interface_with_descr();
166
	foreach ($interfaces as $iface => $ifacename) {
167 2a5960b0 Luiz Otavio O Souza
		if (!is_ipaddr(get_interface_ip($iface)) &&
168
		    !is_ipaddrv6(get_interface_ipv6($iface))) {
169 08d56bd1 sbeaver
			continue;
170 1fe07ba8 Chris Buechler
		}
171 08d56bd1 sbeaver
172 d05950fb Stephen Beaver
		$iflist['options'][$iface] = $ifacename;
173 08d56bd1 sbeaver
174 1fe07ba8 Chris Buechler
		if (in_array($iface, $pconfig['interface'])) {
175
			array_push($iflist['selected'], $iface);
176
		}
177 cf180ccc jim-p
	}
178 08d56bd1 sbeaver
179
	return($iflist);
180 cf180ccc jim-p
}
181 08d56bd1 sbeaver
182 c1e68244 nagyrobi
$pconfig = &$config['ntpd'];
183 7a6f0ebc Phil Davis
if (empty($pconfig['interface'])) {
184 63d5a5e0 Jean Cyr
	$pconfig['interface'] = array();
185 7a6f0ebc Phil Davis
} else {
186 63d5a5e0 Jean Cyr
	$pconfig['interface'] = explode(",", $pconfig['interface']);
187 7a6f0ebc Phil Davis
}
188 448280c3 k-paulius
$pgtitle = array(gettext("Services"), gettext("NTP"), gettext("Settings"));
189 edcd7535 Phil Davis
$pglinks = array("", "@self", "@self");
190 b32dd0a6 jim-p
$shortcut_section = "ntp";
191 cf180ccc jim-p
include("head.inc");
192
193 20db3e1a Phil Davis
if ($input_errors) {
194 08d56bd1 sbeaver
	print_input_errors($input_errors);
195 20db3e1a Phil Davis
}
196 44c42356 Phil Davis
197
if ($changes_applied) {
198
	print_apply_result_box($retval);
199 20db3e1a Phil Davis
}
200 08d56bd1 sbeaver
201
$tab_array = array();
202 448280c3 k-paulius
$tab_array[] = array(gettext("Settings"), true, "services_ntpd.php");
203 31b15180 jim-p
$tab_array[] = array(gettext("ACLs"), false, "services_ntpd_acls.php");
204 08d56bd1 sbeaver
$tab_array[] = array(gettext("Serial GPS"), false, "services_ntpd_gps.php");
205
$tab_array[] = array(gettext("PPS"), false, "services_ntpd_pps.php");
206
display_top_tabs($tab_array);
207
208
$form = new Form;
209 76763c4c Phil Davis
$form->setMultipartEncoding();	// Allow file uploads
210 08d56bd1 sbeaver
211 70dc5cd6 Phil Davis
$section = new Form_Section('NTP Server Configuration');
212 08d56bd1 sbeaver
213
$iflist = build_interface_list();
214
215
$section->addInput(new Form_Select(
216
	'interface',
217
	'Interface',
218
	$iflist['selected'],
219
	$iflist['options'],
220
	true
221 3fd41815 Phil Davis
))->setHelp('Interfaces without an IP address will not be shown.%1$s' .
222
			'Selecting no interfaces will listen on all interfaces with a wildcard.%1$s' .
223
			'Selecting all interfaces will explicitly listen on only the interfaces/IPs specified.', '<br />');
224 08d56bd1 sbeaver
225 20db3e1a Phil Davis
$timeservers = explode(' ', $config['system']['timeservers']);
226 83b9d03e Phil Davis
$maxrows = max(count($timeservers), 1);
227 fbb652ed jim-p
$auto_pool_suffix = "pool.ntp.org";
228 f4439c00 Stephen Beaver
for ($counter=0; $counter < $maxrows; $counter++) {
229 ff8e3635 jim-p
	$group = new Form_Group($counter == 0 ? 'Time Servers':'');
230 c18d0d12 jskyboo
	$group->addClass('repeatable');
231
	$group->setAttribute('max_repeats', NUMTIMESERVERS);
232
	$group->setAttribute('max_repeats_alert', sprintf(gettext('%d is the maximum number of configured servers.'), NUMTIMESERVERS));
233 08d56bd1 sbeaver
234
	$group->add(new Form_Input(
235 f4439c00 Stephen Beaver
		'server' . $counter,
236 08d56bd1 sbeaver
		null,
237
		'text',
238 f4439c00 Stephen Beaver
		$timeservers[$counter],
239
		['placeholder' => 'Hostname']
240
	 ))->setWidth(3);
241 08d56bd1 sbeaver
242
	 $group->add(new Form_Checkbox(
243 f4439c00 Stephen Beaver
		'servprefer' . $counter,
244 08d56bd1 sbeaver
		null,
245 f4439c00 Stephen Beaver
		null,
246
		isset($config['ntpd']['prefer']) && isset($timeservers[$counter]) && substr_count($config['ntpd']['prefer'], $timeservers[$counter])
247
	 ))->sethelp('Prefer');
248 08d56bd1 sbeaver
249
	 $group->add(new Form_Checkbox(
250 f4439c00 Stephen Beaver
		'servselect' . $counter,
251
		null,
252 08d56bd1 sbeaver
		null,
253 f4439c00 Stephen Beaver
		isset($config['ntpd']['noselect']) && isset($timeservers[$counter]) && substr_count($config['ntpd']['noselect'], $timeservers[$counter])
254
	 ))->sethelp('No Select');
255
256 fbb652ed jim-p
	$group->add(new Form_Checkbox(
257
		'servispool' . $counter,
258
		null,
259
		null,
260
		(substr_compare($timeservers[$counter], $auto_pool_suffix, strlen($timeservers[$counter]) - strlen($auto_pool_suffix), strlen($auto_pool_suffix)) === 0)
261
		 || (isset($config['ntpd']['ispool']) && isset($timeservers[$counter]) && substr_count($config['ntpd']['ispool'], $timeservers[$counter]))
262
	 ))->sethelp('Is a Pool');
263
264 f4439c00 Stephen Beaver
	$group->add(new Form_Button(
265
		'deleterow' . $counter,
266 faab522f Renato Botelho
		'Delete',
267 cd7ddae6 jim-p
		null,
268
		'fa-trash'
269
	))->addClass('btn-warning');
270 08d56bd1 sbeaver
271
	 $section->add($group);
272
}
273
274 f4439c00 Stephen Beaver
$section->addInput(new Form_Button(
275
	'addrow',
276 faab522f Renato Botelho
	'Add',
277 cd7ddae6 jim-p
	null,
278
	'fa-plus'
279
))->addClass('btn-success');
280 08d56bd1 sbeaver
281
$section->addInput(new Form_StaticText(
282
	null,
283
	$btnaddrow
284 3fd41815 Phil Davis
))->setHelp('For best results three to five servers should be configured here, or at least one pool.%1$s' .
285
			'The %2$sPrefer%3$s option indicates that NTP should favor the use of this server more than all others.%1$s' .
286
			'The %2$sNo Select%3$s option indicates that NTP should not use this server for time, but stats for this server will be collected and displayed.%1$s' .
287
			'The %2$sIs a Pool%3$s option indicates this entry is a pool of NTP servers and not a single address. This is assumed for *.pool.ntp.org.',
288
			'<br />', '<b>', '</b>');
289 08d56bd1 sbeaver
290
$section->addInput(new Form_Input(
291
	'ntporphan',
292 ff8e3635 jim-p
	'Orphan Mode',
293 08d56bd1 sbeaver
	'text',
294 d0db0f9b jim-p
	$pconfig['orphan'],
295
	['placeholder' => "12"]
296 08d56bd1 sbeaver
))->setHelp('Orphan mode allows the system clock to be used when no other clocks are available. ' .
297
			'The number here specifies the stratum reported during orphan mode and should normally be set to a number high enough ' .
298 bb80af58 NOYB
			'to insure that any other servers available to clients are preferred over this server (default: 12).');
299 08d56bd1 sbeaver
300
$section->addInput(new Form_Checkbox(
301
	'statsgraph',
302
	'NTP Graphs',
303
	'Enable RRD graphs of NTP statistics (default: disabled).',
304
	$pconfig['statsgraph']
305
));
306
307
$section->addInput(new Form_Checkbox(
308
	'logpeer',
309 ff8e3635 jim-p
	'Logging',
310
	'Log peer messages (default: disabled).',
311 08d56bd1 sbeaver
	$pconfig['logpeer']
312
));
313
314
$section->addInput(new Form_Checkbox(
315
	'logsys',
316
	null,
317 ff8e3635 jim-p
	'Log system messages (default: disabled).',
318 08d56bd1 sbeaver
	$pconfig['logsys']
319 3fd41815 Phil Davis
))->setHelp('These options enable additional messages from NTP to be written to the System Log %1$sStatus > System Logs > NTP%2$s',
320
			'<a href="status_logs.php?logfile=ntpd">', '</a>.');
321 08d56bd1 sbeaver
322
// Statistics logging section
323 c0d1ceda Phil Davis
$btnadv = new Form_Button(
324 08d56bd1 sbeaver
	'btnadvstats',
325 c0d1ceda Phil Davis
	'Display Advanced',
326 3314e626 jim-p
	null,
327
	'fa-cog'
328 08d56bd1 sbeaver
);
329
330 347c0214 Phil Davis
$btnadv->setAttribute('type','button')->addClass('btn-info btn-sm');
331 08d56bd1 sbeaver
332
$section->addInput(new Form_StaticText(
333 ff8e3635 jim-p
	'Statistics Logging',
334 c0d1ceda Phil Davis
	$btnadv
335 1f1cd32f Chris Buechler
))->setHelp('Warning: These options will create persistent daily log files in /var/log/ntp.');
336 08d56bd1 sbeaver
337
$section->addInput(new Form_Checkbox(
338
	'clockstats',
339
	null,
340 ff8e3635 jim-p
	'Log reference clock statistics (default: disabled).',
341 08d56bd1 sbeaver
	$pconfig['clockstats']
342
));
343
344
$section->addInput(new Form_Checkbox(
345
	'loopstats',
346
	null,
347 ff8e3635 jim-p
	'Log clock discipline statistics (default: disabled).',
348 08d56bd1 sbeaver
	$pconfig['loopstats']
349
));
350
351
$section->addInput(new Form_Checkbox(
352
	'peerstats',
353
	null,
354 ff8e3635 jim-p
	'Log NTP peer statistics (default: disabled).',
355 08d56bd1 sbeaver
	$pconfig['peerstats']
356
));
357
358
// Leap seconds section
359 c0d1ceda Phil Davis
$btnadv = new Form_Button(
360
	'btnadvleap',
361
	'Display Advanced',
362 3314e626 jim-p
	null,
363
	'fa-cog'
364 08d56bd1 sbeaver
);
365
366 347c0214 Phil Davis
$btnadv->setAttribute('type','button')->addClass('btn-info btn-sm');
367 08d56bd1 sbeaver
368
$section->addInput(new Form_StaticText(
369
	'Leap seconds',
370 c0d1ceda Phil Davis
	$btnadv
371 bb80af58 NOYB
))->setHelp('A leap second file allows NTP to advertise an upcoming leap second addition or subtraction. ' .
372 08d56bd1 sbeaver
			'Normally this is only useful if this server is a stratum 1 time server. ');
373
374
$section->addInput(new Form_Textarea(
375
	'leaptext',
376
	null,
377
	base64_decode(chunk_split($pconfig['leapsec']))
378 e78ecb96 NOYB
))->setHelp('Enter Leap second configuration as text OR select a file to upload.');
379 08d56bd1 sbeaver
380
$section->addInput(new Form_Input(
381
	'leapfile',
382
	null,
383
	'file'
384
))->addClass('btn-default');
385
386
$form->add($section);
387 31b15180 jim-p
388 08d56bd1 sbeaver
print($form);
389
390 cf180ccc jim-p
?>
391
392 8fd9052f Colin Fleming
<script type="text/javascript">
393
//<![CDATA[
394 08ec2d99 Stephen Beaver
	// If this variable is declared, any help text will not be deleted when rows are added
395
	// IOW the help text will appear on every row
396
	retainhelp = true;
397
</script>
398
399 8fd9052f Colin Fleming
<script type="text/javascript">
400 d9555fc5 Colin Fleming
//<![CDATA[
401 20db3e1a Phil Davis
events.push(function() {
402 08d56bd1 sbeaver
403 c0d1ceda Phil Davis
	// Show advanced stats options ============================================
404
	var showadvstats = false;
405 08d56bd1 sbeaver
406 c0d1ceda Phil Davis
	function show_advstats(ispageload) {
407
		var text;
408
		// On page load decide the initial state based on the data.
409
		if (ispageload) {
410
<?php
411
			if (!$pconfig['clockstats'] && !$pconfig['loopstats'] && !$pconfig['peerstats']) {
412
				$showadv = false;
413
			} else {
414
				$showadv = true;
415
			}
416
?>
417
			showadvstats = <?php if ($showadv) {echo 'true';} else {echo 'false';} ?>;
418
		} else {
419
			// It was a click, swap the state.
420
			showadvstats = !showadvstats;
421
		}
422
423
		hideCheckbox('clockstats', !showadvstats);
424
		hideCheckbox('loopstats', !showadvstats);
425
		hideCheckbox('peerstats', !showadvstats);
426
427
		if (showadvstats) {
428
			text = "<?=gettext('Hide Advanced');?>";
429
		} else {
430
			text = "<?=gettext('Display Advanced');?>";
431
		}
432
		$('#btnadvstats').html('<i class="fa fa-cog"></i> ' + text);
433
	}
434
435
	$('#btnadvstats').click(function(event) {
436
		show_advstats();
437 08d56bd1 sbeaver
	});
438
439 c0d1ceda Phil Davis
	// Show advanced leap second options ======================================
440
	var showadvleap = false;
441
442
	function show_advleap(ispageload) {
443
		var text;
444
		// On page load decide the initial state based on the data.
445
		if (ispageload) {
446
<?php
447
			// Note: leapfile is not a field saved in the config, so no need to test for it here.
448
			// leapsec is the encoded text in the config, leaptext is not a pconfig[] key.
449
			if (empty($pconfig['leapsec'])) {
450
				$showadv = false;
451
			} else {
452
				$showadv = true;
453
			}
454
?>
455
			showadvleap = <?php if ($showadv) {echo 'true';} else {echo 'false';} ?>;
456
		} else {
457
			// It was a click, swap the state.
458
			showadvleap = !showadvleap;
459
		}
460
461
		hideInput('leaptext', !showadvleap);
462
		hideInput('leapfile', !showadvleap);
463
464
		if (showadvleap) {
465
			text = "<?=gettext('Hide Advanced');?>";
466
		} else {
467
			text = "<?=gettext('Display Advanced');?>";
468
		}
469
		$('#btnadvleap').html('<i class="fa fa-cog"></i> ' + text);
470
	}
471 08d56bd1 sbeaver
472 c0d1ceda Phil Davis
	$('#btnadvleap').click(function(event) {
473
		show_advleap();
474 08d56bd1 sbeaver
	});
475
476 c0d1ceda Phil Davis
	// Set initial states
477
	show_advstats(true);
478
	show_advleap(true);
479 0bc61baa Stephen Beaver
480
	// Suppress "Delete row" button if there are fewer than two rows
481
	checkLastRow();
482 08d56bd1 sbeaver
});
483 d9555fc5 Colin Fleming
//]]>
484 c1e68244 nagyrobi
</script>
485 cf180ccc jim-p
486 c10cb196 Stephen Beaver
<?php include("foot.inc");