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