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 |
|
|
##|*NAME=Services: NTP
|
60 |
|
|
##|*DESCR=Allow access to the 'Services: NTP' page.
|
61 |
|
|
##|*MATCH=services_ntpd.php*
|
62 |
|
|
##|-PRIV
|
63 |
|
|
|
64 |
08d56bd1
|
sbeaver
|
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 |
08005d0a
|
Ermal
|
write_config("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['kod'])) {
|
161 |
c1e68244
|
nagyrobi
|
$config['ntpd']['kod'] = 'on';
|
162 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['kod'])) {
|
163 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['kod']);
|
164 |
7a6f0ebc
|
Phil Davis
|
}
|
165 |
c1e68244
|
nagyrobi
|
|
166 |
7a6f0ebc
|
Phil Davis
|
if (empty($_POST['nomodify'])) {
|
167 |
c1e68244
|
nagyrobi
|
$config['ntpd']['nomodify'] = 'on';
|
168 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['nomodify'])) {
|
169 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['nomodify']);
|
170 |
7a6f0ebc
|
Phil Davis
|
}
|
171 |
c1e68244
|
nagyrobi
|
|
172 |
7a6f0ebc
|
Phil Davis
|
if (!empty($_POST['noquery'])) {
|
173 |
c1e68244
|
nagyrobi
|
$config['ntpd']['noquery'] = $_POST['noquery'];
|
174 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['noquery'])) {
|
175 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['noquery']);
|
176 |
7a6f0ebc
|
Phil Davis
|
}
|
177 |
c1e68244
|
nagyrobi
|
|
178 |
7a6f0ebc
|
Phil Davis
|
if (!empty($_POST['noserve'])) {
|
179 |
c1e68244
|
nagyrobi
|
$config['ntpd']['noserve'] = $_POST['noserve'];
|
180 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['noserve'])) {
|
181 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['noserve']);
|
182 |
7a6f0ebc
|
Phil Davis
|
}
|
183 |
c1e68244
|
nagyrobi
|
|
184 |
7a6f0ebc
|
Phil Davis
|
if (empty($_POST['nopeer'])) {
|
185 |
c1e68244
|
nagyrobi
|
$config['ntpd']['nopeer'] = 'on';
|
186 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['nopeer'])) {
|
187 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['nopeer']);
|
188 |
7a6f0ebc
|
Phil Davis
|
}
|
189 |
c1e68244
|
nagyrobi
|
|
190 |
7a6f0ebc
|
Phil Davis
|
if (empty($_POST['notrap'])) {
|
191 |
c1e68244
|
nagyrobi
|
$config['ntpd']['notrap'] = 'on';
|
192 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['notrap'])) {
|
193 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['notrap']);
|
194 |
7a6f0ebc
|
Phil Davis
|
}
|
195 |
c1e68244
|
nagyrobi
|
|
196 |
7a6f0ebc
|
Phil Davis
|
if ((empty($_POST['statsgraph'])) == (isset($config['ntpd']['statsgraph']))) {
|
197 |
e2caaee8
|
k-paulius
|
$enable_rrd_graphing = true;
|
198 |
7a6f0ebc
|
Phil Davis
|
}
|
199 |
|
|
if (!empty($_POST['statsgraph'])) {
|
200 |
c1e68244
|
nagyrobi
|
$config['ntpd']['statsgraph'] = $_POST['statsgraph'];
|
201 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['statsgraph'])) {
|
202 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['statsgraph']);
|
203 |
7a6f0ebc
|
Phil Davis
|
}
|
204 |
|
|
if (isset($enable_rrd_graphing)) {
|
205 |
e2caaee8
|
k-paulius
|
enable_rrd_graphing();
|
206 |
7a6f0ebc
|
Phil Davis
|
}
|
207 |
c1e68244
|
nagyrobi
|
|
208 |
7a6f0ebc
|
Phil Davis
|
if (!empty($_POST['leaptxt'])) {
|
209 |
c1e68244
|
nagyrobi
|
$config['ntpd']['leapsec'] = base64_encode($_POST['leaptxt']);
|
210 |
7a6f0ebc
|
Phil Davis
|
} elseif (isset($config['ntpd']['leapsec'])) {
|
211 |
c1e68244
|
nagyrobi
|
unset($config['ntpd']['leapsec']);
|
212 |
7a6f0ebc
|
Phil Davis
|
}
|
213 |
c1e68244
|
nagyrobi
|
|
214 |
7a6f0ebc
|
Phil Davis
|
if (is_uploaded_file($_FILES['leapfile']['tmp_name'])) {
|
215 |
c1e68244
|
nagyrobi
|
$config['ntpd']['leapsec'] = base64_encode(file_get_contents($_FILES['leapfile']['tmp_name']));
|
216 |
7a6f0ebc
|
Phil Davis
|
}
|
217 |
c1e68244
|
nagyrobi
|
|
218 |
cf180ccc
|
jim-p
|
write_config("Updated NTP Server Settings");
|
219 |
|
|
|
220 |
|
|
$retval = 0;
|
221 |
|
|
$retval = system_ntp_configure();
|
222 |
|
|
$savemsg = get_std_save_message($retval);
|
223 |
08d56bd1
|
sbeaver
|
}
|
224 |
|
|
}
|
225 |
|
|
|
226 |
|
|
function build_interface_list() {
|
227 |
|
|
global $pconfig;
|
228 |
|
|
|
229 |
|
|
$iflist = array('options' => array(), 'selected' => array());
|
230 |
|
|
|
231 |
|
|
$interfaces = get_configured_interface_with_descr();
|
232 |
|
|
$carplist = get_configured_carp_interface_list();
|
233 |
|
|
|
234 |
1fe07ba8
|
Chris Buechler
|
foreach ($carplist as $cif => $carpip) {
|
235 |
08d56bd1
|
sbeaver
|
$interfaces[$cif] = $carpip . " (" . get_vip_descr($carpip) .")";
|
236 |
1fe07ba8
|
Chris Buechler
|
}
|
237 |
08d56bd1
|
sbeaver
|
|
238 |
|
|
$aliaslist = get_configured_ip_aliases_list();
|
239 |
|
|
|
240 |
1fe07ba8
|
Chris Buechler
|
foreach ($aliaslist as $aliasip => $aliasif) {
|
241 |
08d56bd1
|
sbeaver
|
$interfaces[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
|
242 |
1fe07ba8
|
Chris Buechler
|
}
|
243 |
08d56bd1
|
sbeaver
|
|
244 |
|
|
$size = (count($interfaces) < 10) ? count($interfaces) : 10;
|
245 |
|
|
|
246 |
|
|
foreach ($interfaces as $iface => $ifacename) {
|
247 |
1fe07ba8
|
Chris Buechler
|
if (!is_ipaddr(get_interface_ip($iface)) && !is_ipaddr($iface)) {
|
248 |
08d56bd1
|
sbeaver
|
continue;
|
249 |
1fe07ba8
|
Chris Buechler
|
}
|
250 |
08d56bd1
|
sbeaver
|
|
251 |
d05950fb
|
Stephen Beaver
|
$iflist['options'][$iface] = $ifacename;
|
252 |
08d56bd1
|
sbeaver
|
|
253 |
1fe07ba8
|
Chris Buechler
|
if (in_array($iface, $pconfig['interface'])) {
|
254 |
|
|
array_push($iflist['selected'], $iface);
|
255 |
|
|
}
|
256 |
cf180ccc
|
jim-p
|
}
|
257 |
08d56bd1
|
sbeaver
|
|
258 |
|
|
return($iflist);
|
259 |
cf180ccc
|
jim-p
|
}
|
260 |
08d56bd1
|
sbeaver
|
|
261 |
c1e68244
|
nagyrobi
|
$pconfig = &$config['ntpd'];
|
262 |
7a6f0ebc
|
Phil Davis
|
if (empty($pconfig['interface'])) {
|
263 |
63d5a5e0
|
Jean Cyr
|
$pconfig['interface'] = array();
|
264 |
7a6f0ebc
|
Phil Davis
|
} else {
|
265 |
63d5a5e0
|
Jean Cyr
|
$pconfig['interface'] = explode(",", $pconfig['interface']);
|
266 |
7a6f0ebc
|
Phil Davis
|
}
|
267 |
0e0c4523
|
Phil Davis
|
$pgtitle = array(gettext("Services"), gettext("NTP"), gettext("NTP"));
|
268 |
b32dd0a6
|
jim-p
|
$shortcut_section = "ntp";
|
269 |
cf180ccc
|
jim-p
|
include("head.inc");
|
270 |
|
|
|
271 |
20db3e1a
|
Phil Davis
|
if ($input_errors) {
|
272 |
08d56bd1
|
sbeaver
|
print_input_errors($input_errors);
|
273 |
20db3e1a
|
Phil Davis
|
}
|
274 |
|
|
if ($savemsg) {
|
275 |
08d56bd1
|
sbeaver
|
print_info_box($savemsg, 'success');
|
276 |
20db3e1a
|
Phil Davis
|
}
|
277 |
08d56bd1
|
sbeaver
|
|
278 |
|
|
$tab_array = array();
|
279 |
|
|
$tab_array[] = array(gettext("NTP"), true, "services_ntpd.php");
|
280 |
|
|
$tab_array[] = array(gettext("Serial GPS"), false, "services_ntpd_gps.php");
|
281 |
|
|
$tab_array[] = array(gettext("PPS"), false, "services_ntpd_pps.php");
|
282 |
|
|
display_top_tabs($tab_array);
|
283 |
|
|
|
284 |
|
|
$form = new Form;
|
285 |
|
|
|
286 |
|
|
$section = new Form_Section('NTP server configuration');
|
287 |
|
|
|
288 |
|
|
$iflist = build_interface_list();
|
289 |
|
|
|
290 |
|
|
$section->addInput(new Form_Select(
|
291 |
|
|
'interface',
|
292 |
|
|
'Interface',
|
293 |
|
|
$iflist['selected'],
|
294 |
|
|
$iflist['options'],
|
295 |
|
|
true
|
296 |
|
|
))->setHelp('Interfaces without an IP address will not be shown.' . '<br />' .
|
297 |
|
|
'Selecting no interfaces will listen on all interfaces with a wildcard.' . '<br />' .
|
298 |
|
|
'Selecting all interfaces will explicitly listen on only the interfaces/IPs specified.');
|
299 |
|
|
|
300 |
20db3e1a
|
Phil Davis
|
$timeservers = explode(' ', $config['system']['timeservers']);
|
301 |
83b9d03e
|
Phil Davis
|
$maxrows = max(count($timeservers), 1);
|
302 |
f4439c00
|
Stephen Beaver
|
for ($counter=0; $counter < $maxrows; $counter++) {
|
303 |
ff8e3635
|
jim-p
|
$group = new Form_Group($counter == 0 ? 'Time Servers':'');
|
304 |
f4439c00
|
Stephen Beaver
|
$group->addClass('repeatable');
|
305 |
08d56bd1
|
sbeaver
|
|
306 |
|
|
$group->add(new Form_Input(
|
307 |
f4439c00
|
Stephen Beaver
|
'server' . $counter,
|
308 |
08d56bd1
|
sbeaver
|
null,
|
309 |
|
|
'text',
|
310 |
f4439c00
|
Stephen Beaver
|
$timeservers[$counter],
|
311 |
|
|
['placeholder' => 'Hostname']
|
312 |
|
|
))->setWidth(3);
|
313 |
08d56bd1
|
sbeaver
|
|
314 |
|
|
$group->add(new Form_Checkbox(
|
315 |
f4439c00
|
Stephen Beaver
|
'servprefer' . $counter,
|
316 |
08d56bd1
|
sbeaver
|
null,
|
317 |
f4439c00
|
Stephen Beaver
|
null,
|
318 |
|
|
isset($config['ntpd']['prefer']) && isset($timeservers[$counter]) && substr_count($config['ntpd']['prefer'], $timeservers[$counter])
|
319 |
|
|
))->sethelp('Prefer');
|
320 |
08d56bd1
|
sbeaver
|
|
321 |
|
|
$group->add(new Form_Checkbox(
|
322 |
f4439c00
|
Stephen Beaver
|
'servselect' . $counter,
|
323 |
|
|
null,
|
324 |
08d56bd1
|
sbeaver
|
null,
|
325 |
f4439c00
|
Stephen Beaver
|
isset($config['ntpd']['noselect']) && isset($timeservers[$counter]) && substr_count($config['ntpd']['noselect'], $timeservers[$counter])
|
326 |
|
|
))->sethelp('No Select');
|
327 |
|
|
|
328 |
|
|
$group->add(new Form_Button(
|
329 |
|
|
'deleterow' . $counter,
|
330 |
|
|
'Delete'
|
331 |
|
|
))->removeClass('btn-primary')->addClass('btn-warning');
|
332 |
08d56bd1
|
sbeaver
|
|
333 |
|
|
$section->add($group);
|
334 |
|
|
}
|
335 |
|
|
|
336 |
f4439c00
|
Stephen Beaver
|
$section->addInput(new Form_Button(
|
337 |
|
|
'addrow',
|
338 |
|
|
'Add'
|
339 |
|
|
))->removeClass('btn-primary')->addClass('btn-success');
|
340 |
08d56bd1
|
sbeaver
|
|
341 |
|
|
$section->addInput(new Form_StaticText(
|
342 |
|
|
null,
|
343 |
|
|
$btnaddrow
|
344 |
|
|
))->setHelp('For best results three to five servers should be configured here.' . '<br />' .
|
345 |
|
|
'The prefer option indicates that NTP should favor the use of this server more than all others.' . '<br />' .
|
346 |
|
|
'The noselect option indicates that NTP should not use this server for time, but stats for this server will be collected and displayed.');
|
347 |
|
|
|
348 |
|
|
$section->addInput(new Form_Input(
|
349 |
|
|
'ntporphan',
|
350 |
ff8e3635
|
jim-p
|
'Orphan Mode',
|
351 |
08d56bd1
|
sbeaver
|
'text',
|
352 |
|
|
$pconfig['ntporphan']
|
353 |
|
|
))->setHelp('Orphan mode allows the system clock to be used when no other clocks are available. ' .
|
354 |
|
|
'The number here specifies the stratum reported during orphan mode and should normally be set to a number high enough ' .
|
355 |
|
|
'to insure that any other servers available to clients are preferred over this server. (default: 12).');
|
356 |
|
|
|
357 |
|
|
$section->addInput(new Form_Checkbox(
|
358 |
|
|
'statsgraph',
|
359 |
|
|
'NTP Graphs',
|
360 |
|
|
'Enable RRD graphs of NTP statistics (default: disabled).',
|
361 |
|
|
$pconfig['statsgraph']
|
362 |
|
|
));
|
363 |
|
|
|
364 |
|
|
$section->addInput(new Form_Checkbox(
|
365 |
|
|
'logpeer',
|
366 |
ff8e3635
|
jim-p
|
'Logging',
|
367 |
|
|
'Log peer messages (default: disabled).',
|
368 |
08d56bd1
|
sbeaver
|
$pconfig['logpeer']
|
369 |
|
|
));
|
370 |
|
|
|
371 |
|
|
$section->addInput(new Form_Checkbox(
|
372 |
|
|
'logsys',
|
373 |
|
|
null,
|
374 |
ff8e3635
|
jim-p
|
'Log system messages (default: disabled).',
|
375 |
08d56bd1
|
sbeaver
|
$pconfig['logsys']
|
376 |
|
|
))->setHelp('These options enable additional messages from NTP to be written to the System Log ' .
|
377 |
|
|
'<a href="diag_logs_ntpd.php">' . 'Status > System Logs > NTP' . '</a>');
|
378 |
|
|
|
379 |
|
|
// Statistics logging section
|
380 |
|
|
$btnadvstats = new Form_Button(
|
381 |
|
|
'btnadvstats',
|
382 |
|
|
'Advanced'
|
383 |
|
|
);
|
384 |
|
|
|
385 |
|
|
$btnadvstats->removeClass('btn-primary')->addClass('btn-default btn-sm');
|
386 |
|
|
|
387 |
|
|
$section->addInput(new Form_StaticText(
|
388 |
ff8e3635
|
jim-p
|
'Statistics Logging',
|
389 |
08d56bd1
|
sbeaver
|
$btnadvstats
|
390 |
1f1cd32f
|
Chris Buechler
|
))->setHelp('Warning: These options will create persistent daily log files in /var/log/ntp.');
|
391 |
08d56bd1
|
sbeaver
|
|
392 |
|
|
$section->addInput(new Form_Checkbox(
|
393 |
|
|
'clockstats',
|
394 |
|
|
null,
|
395 |
ff8e3635
|
jim-p
|
'Log reference clock statistics (default: disabled).',
|
396 |
08d56bd1
|
sbeaver
|
$pconfig['clockstats']
|
397 |
|
|
));
|
398 |
|
|
|
399 |
|
|
$section->addInput(new Form_Checkbox(
|
400 |
|
|
'loopstats',
|
401 |
|
|
null,
|
402 |
ff8e3635
|
jim-p
|
'Log clock discipline statistics (default: disabled).',
|
403 |
08d56bd1
|
sbeaver
|
$pconfig['loopstats']
|
404 |
|
|
));
|
405 |
|
|
|
406 |
|
|
$section->addInput(new Form_Checkbox(
|
407 |
|
|
'peerstats',
|
408 |
|
|
null,
|
409 |
ff8e3635
|
jim-p
|
'Log NTP peer statistics (default: disabled).',
|
410 |
08d56bd1
|
sbeaver
|
$pconfig['peerstats']
|
411 |
|
|
));
|
412 |
|
|
|
413 |
|
|
// Access restrictions section
|
414 |
|
|
$btnadvrestr = new Form_Button(
|
415 |
|
|
'btnadvrestr',
|
416 |
|
|
'Advanced'
|
417 |
|
|
);
|
418 |
|
|
|
419 |
|
|
$btnadvrestr->removeClass('btn-primary')->addClass('btn-default btn-sm');
|
420 |
|
|
|
421 |
|
|
$section->addInput(new Form_StaticText(
|
422 |
|
|
'Access Restrictions',
|
423 |
|
|
$btnadvrestr
|
424 |
|
|
))->setHelp('These options control access to NTP from the WAN.');
|
425 |
|
|
|
426 |
|
|
$section->addInput(new Form_Checkbox(
|
427 |
|
|
'kod',
|
428 |
|
|
null,
|
429 |
ff8e3635
|
jim-p
|
'Enable Kiss-o\'-death packets (default: checked).',
|
430 |
|
|
!$pconfig['kod']
|
431 |
08d56bd1
|
sbeaver
|
));
|
432 |
|
|
|
433 |
|
|
$section->addInput(new Form_Checkbox(
|
434 |
|
|
'nomodify',
|
435 |
|
|
null,
|
436 |
ff8e3635
|
jim-p
|
'Deny state modifications (i.e. run time configuration) by ntpq and ntpdc (default: checked).',
|
437 |
|
|
!$pconfig['nomodify']
|
438 |
08d56bd1
|
sbeaver
|
));
|
439 |
|
|
|
440 |
|
|
$section->addInput(new Form_Checkbox(
|
441 |
|
|
'noquery',
|
442 |
|
|
null,
|
443 |
ff8e3635
|
jim-p
|
'Disable ntpq and ntpdc queries (default: unchecked).',
|
444 |
08d56bd1
|
sbeaver
|
$pconfig['noquery']
|
445 |
|
|
));
|
446 |
|
|
|
447 |
|
|
$section->addInput(new Form_Checkbox(
|
448 |
|
|
'noserve',
|
449 |
|
|
null,
|
450 |
ff8e3635
|
jim-p
|
'Disable all except ntpq and ntpdc queries (default: unchecked).',
|
451 |
08d56bd1
|
sbeaver
|
$pconfig['noserve']
|
452 |
|
|
));
|
453 |
|
|
|
454 |
|
|
$section->addInput(new Form_Checkbox(
|
455 |
|
|
'nopeer',
|
456 |
|
|
null,
|
457 |
ff8e3635
|
jim-p
|
'Deny packets that attempt a peer association (default: checked).',
|
458 |
|
|
!$pconfig['nopeer']
|
459 |
08d56bd1
|
sbeaver
|
));
|
460 |
|
|
|
461 |
|
|
$section->addInput(new Form_Checkbox(
|
462 |
|
|
'notrap',
|
463 |
|
|
null,
|
464 |
ff8e3635
|
jim-p
|
'Deny mode 6 control message trap service (default: checked).',
|
465 |
|
|
!$pconfig['notrap']
|
466 |
08d56bd1
|
sbeaver
|
))->addClass('advrestrictions');
|
467 |
|
|
|
468 |
|
|
// Leap seconds section
|
469 |
|
|
$btnleap = new Form_Button(
|
470 |
|
|
'btnleap',
|
471 |
|
|
'Advanced'
|
472 |
|
|
);
|
473 |
|
|
|
474 |
|
|
$btnleap->removeClass('btn-primary')->addClass('btn-default btn-sm');
|
475 |
|
|
|
476 |
|
|
$section->addInput(new Form_StaticText(
|
477 |
|
|
'Leap seconds',
|
478 |
|
|
$btnleap
|
479 |
|
|
))->setHelp('A leap second file allows NTP to advertize an upcoming leap second addition or subtraction. ' .
|
480 |
|
|
'Normally this is only useful if this server is a stratum 1 time server. ');
|
481 |
|
|
|
482 |
|
|
$section->addInput(new Form_Textarea(
|
483 |
|
|
'leaptext',
|
484 |
|
|
null,
|
485 |
|
|
base64_decode(chunk_split($pconfig['leapsec']))
|
486 |
|
|
))->setHelp('Enter Leap second configuration as text OR select a file to upload');
|
487 |
|
|
|
488 |
|
|
$section->addInput(new Form_Input(
|
489 |
|
|
'leapfile',
|
490 |
|
|
null,
|
491 |
|
|
'file'
|
492 |
|
|
))->addClass('btn-default');
|
493 |
|
|
|
494 |
|
|
$form->add($section);
|
495 |
|
|
print($form);
|
496 |
|
|
|
497 |
cf180ccc
|
jim-p
|
?>
|
498 |
|
|
|
499 |
8fd9052f
|
Colin Fleming
|
<script type="text/javascript">
|
500 |
|
|
//<![CDATA[
|
501 |
08ec2d99
|
Stephen Beaver
|
// If this variable is declared, any help text will not be deleted when rows are added
|
502 |
|
|
// IOW the help text will appear on every row
|
503 |
|
|
retainhelp = true;
|
504 |
|
|
</script>
|
505 |
|
|
|
506 |
8fd9052f
|
Colin Fleming
|
<script type="text/javascript">
|
507 |
d9555fc5
|
Colin Fleming
|
//<![CDATA[
|
508 |
20db3e1a
|
Phil Davis
|
events.push(function() {
|
509 |
08d56bd1
|
sbeaver
|
|
510 |
|
|
// Make the ‘clear’ button a plain button, not a submit button
|
511 |
|
|
$('#btnadvstats').prop('type','button');
|
512 |
|
|
|
513 |
|
|
// On click, show the controls in the stats section
|
514 |
|
|
$("#btnadvstats").click(function() {
|
515 |
|
|
hideCheckbox('clockstats', false);
|
516 |
|
|
hideCheckbox('loopstats', false);
|
517 |
|
|
hideCheckbox('peerstats', false);
|
518 |
|
|
});
|
519 |
|
|
|
520 |
|
|
// Make the ‘clear’ button a plain button, not a submit button
|
521 |
|
|
$('#btnadvrestr').prop('type','button');
|
522 |
|
|
|
523 |
|
|
// On click, show the controls in the restrictions section
|
524 |
|
|
$("#btnadvrestr").click(function() {
|
525 |
ff8e3635
|
jim-p
|
hideCheckbox('kod', false);
|
526 |
08d56bd1
|
sbeaver
|
hideCheckbox('nomodify', false);
|
527 |
|
|
hideCheckbox('noquery', false);
|
528 |
|
|
hideCheckbox('noserve', false);
|
529 |
|
|
hideCheckbox('nopeer', false);
|
530 |
|
|
hideCheckbox('notrap', false);
|
531 |
|
|
});
|
532 |
|
|
|
533 |
|
|
// Make the ‘btnleap’ button a plain button, not a submit button
|
534 |
|
|
$('#btnleap').prop('type','button');
|
535 |
|
|
|
536 |
|
|
// On click, show the controls in the leap seconds section
|
537 |
|
|
$("#btnleap").click(function() {
|
538 |
|
|
hideInput('leaptext', false);
|
539 |
|
|
hideInput('leapfile', false);
|
540 |
|
|
});
|
541 |
|
|
|
542 |
|
|
// Set intial states
|
543 |
|
|
hideCheckbox('clockstats', true);
|
544 |
|
|
hideCheckbox('loopstats', true);
|
545 |
|
|
hideCheckbox('peerstats', true);
|
546 |
|
|
hideCheckbox('kod', true);
|
547 |
|
|
hideCheckbox('nomodify', true);
|
548 |
|
|
hideCheckbox('noquery', true);
|
549 |
|
|
hideCheckbox('noserve', true);
|
550 |
|
|
hideCheckbox('nopeer', true);
|
551 |
|
|
hideCheckbox('notrap', true);
|
552 |
|
|
hideInput('leaptext', true);
|
553 |
|
|
hideInput('leapfile', true);
|
554 |
0bc61baa
|
Stephen Beaver
|
|
555 |
|
|
// Suppress "Delete row" button if there are fewer than two rows
|
556 |
|
|
checkLastRow();
|
557 |
08d56bd1
|
sbeaver
|
});
|
558 |
d9555fc5
|
Colin Fleming
|
//]]>
|
559 |
c1e68244
|
nagyrobi
|
</script>
|
560 |
cf180ccc
|
jim-p
|
|
561 |
c10cb196
|
Stephen Beaver
|
<?php include("foot.inc");
|