1
|
<?php
|
2
|
/*
|
3
|
services_ntpd.php
|
4
|
|
5
|
Copyright (C) 2012 Jim Pingle
|
6
|
All rights reserved.
|
7
|
|
8
|
Redistribution and use in source and binary forms, with or without
|
9
|
modification, are permitted provided that the following conditions are met:
|
10
|
|
11
|
1. Redistributions of source code must retain the above copyright notice,
|
12
|
this list of conditions and the following disclaimer.
|
13
|
|
14
|
2. Redistributions in binary form must reproduce the above copyright
|
15
|
notice, this list of conditions and the following disclaimer in the
|
16
|
documentation and/or other materials provided with the distribution.
|
17
|
|
18
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
19
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
21
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
22
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
23
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
24
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
25
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27
|
POSSIBILITY OF SUCH DAMAGE.
|
28
|
*/
|
29
|
/*
|
30
|
pfSense_MODULE: ntpd
|
31
|
*/
|
32
|
|
33
|
##|+PRIV
|
34
|
##|*IDENT=page-services-ntpd
|
35
|
##|*NAME=Services: NTP
|
36
|
##|*DESCR=Allow access to the 'Services: NTP' page.
|
37
|
##|*MATCH=services_ntpd.php*
|
38
|
##|-PRIV
|
39
|
|
40
|
require("guiconfig.inc");
|
41
|
|
42
|
if (empty($config['ntpd']['interface']))
|
43
|
if (empty($config['installedpackages']['openntpd']['config'][0]['interface'])) {
|
44
|
$pconfig['interface'] = explode(",", $config['installedpackages']['openntpd']['config'][0]['interface']);
|
45
|
unset($config['installedpackages']['openntpd']);
|
46
|
} else
|
47
|
$pconfig['interface'] = array();
|
48
|
else
|
49
|
$pconfig['interface'] = explode(",", $config['ntpd']['interface']);
|
50
|
|
51
|
if ($_POST) {
|
52
|
|
53
|
unset($input_errors);
|
54
|
$pconfig = $_POST;
|
55
|
|
56
|
if (!$input_errors) {
|
57
|
if (is_array($_POST['interface']))
|
58
|
$config['ntpd']['interface'] = implode(",", $_POST['interface']);
|
59
|
elseif (isset($config['ntpd']['interface']))
|
60
|
unset($config['ntpd']['interface']);
|
61
|
|
62
|
write_config("Updated NTP Server Settings");
|
63
|
|
64
|
$retval = 0;
|
65
|
$retval = system_ntp_configure();
|
66
|
$savemsg = get_std_save_message($retval);
|
67
|
|
68
|
}
|
69
|
}
|
70
|
|
71
|
$pgtitle = array(gettext("Services"),gettext("NTP"));
|
72
|
include("head.inc");
|
73
|
|
74
|
?>
|
75
|
|
76
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
77
|
<?php include("fbegin.inc"); ?>
|
78
|
<form action="services_ntpd.php" method="post" name="iform" id="iform">
|
79
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
80
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
81
|
|
82
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
83
|
<tr><td><div id="mainarea">
|
84
|
<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
|
85
|
<tr>
|
86
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("NTP Server Configuration"); ?></td>
|
87
|
</tr>
|
88
|
<tr>
|
89
|
<td width="22%" valign="top" class="vncellreq">Interface(s)</td>
|
90
|
<td width="78%" class="vtable">
|
91
|
<?php
|
92
|
$interfaces = get_configured_interface_with_descr();
|
93
|
$carplist = get_configured_carp_interface_list();
|
94
|
foreach ($carplist as $cif => $carpip)
|
95
|
$interfaces[$cif] = $carpip." (".get_vip_descr($carpip).")";
|
96
|
$aliaslist = get_configured_ip_aliases_list();
|
97
|
foreach ($aliaslist as $aliasip => $aliasif)
|
98
|
$interfaces[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
|
99
|
$size = (count($interfaces) < 10) ? count($interfaces) : 10;
|
100
|
?>
|
101
|
<select id="interface" name="interface[]" multiple="true" class="formselect" size="<?php echo $size; ?>">
|
102
|
<?php
|
103
|
foreach ($interfaces as $iface => $ifacename) {
|
104
|
if (!is_ipaddr(get_interface_ip($iface)) && !is_ipaddr($iface))
|
105
|
continue;
|
106
|
echo "<option value='{$iface}'";
|
107
|
if (in_array($iface, $pconfig['interface']))
|
108
|
echo "selected";
|
109
|
echo ">{$ifacename}</option>\n";
|
110
|
} ?>
|
111
|
</select>
|
112
|
<br/>Interfaces without an IP address will not be shown.
|
113
|
<br/>
|
114
|
<br/>Selecting no interfaces will listen on all interfaces with a wildcard.
|
115
|
<br/>Selecting all interfaces will explicitly listen on only the interfaces/IPs specified.
|
116
|
</td>
|
117
|
</tr>
|
118
|
<tr>
|
119
|
<td width="22%" valign="top"> </td>
|
120
|
<td width="78%">
|
121
|
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)">
|
122
|
</td>
|
123
|
</tr>
|
124
|
</table>
|
125
|
</div></td></tr></table>
|
126
|
</form>
|
127
|
<?php include("fend.inc"); ?>
|
128
|
</body>
|
129
|
</html>
|