Project

General

Profile

Download (41.2 KB) Statistics
| Branch: | Tag: | Revision:
1 e9f147c8 Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	services_dhcp.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6 e9f147c8 Scott Ullrich
7 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9 e9f147c8 Scott Ullrich
10 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12 e9f147c8 Scott Ullrich
13 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15 e9f147c8 Scott Ullrich
16 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19 e9f147c8 Scott Ullrich
20 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31 1d333258 Scott Ullrich
/*
32
	pfSense_BUILDER_BINARIES:	/bin/rm
33
	pfSense_MODULE:	interfaces
34
*/
35 5b237745 Scott Ullrich
36 6b07c15a Matthew Grooms
##|+PRIV
37
##|*IDENT=page-services-dhcpserver
38
##|*NAME=Services: DHCP server page
39
##|*DESCR=Allow access to the 'Services: DHCP server' page.
40
##|*MATCH=services_dhcp.php*
41
##|-PRIV
42
43 b7597d4e Bill Marquette
require("guiconfig.inc");
44 5b237745 Scott Ullrich
45 2ee0410f Scott Ullrich
if(!$g['services_dhcp_server_enable']) {
46
	Header("Location: /");
47
	exit;
48
}
49
50 c2ffc6c1 jim-p
/* This function will remove entries from dhcpd.leases that would otherwise
51
 * overlap with static DHCP reservations. If we don't clean these out,
52
 * then DHCP will print a warning in the logs about a duplicate lease
53
 */
54
function dhcp_clean_leases() {
55
	global $g, $config;
56
	$leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases";
57 69ec9ecf jim-p
	if (!file_exists($leasesfile))
58
		return;
59 c2ffc6c1 jim-p
	/* Build list of static MACs */
60
	$staticmacs = array();
61
	foreach($config['interfaces'] as $ifname => $ifarr)
62
		if (is_array($config['dhcpd'][$ifname]['staticmap']))
63
			foreach($config['dhcpd'][$ifname]['staticmap'] as $static)
64
				$staticmacs[] = $static['mac'];
65
	/* Read existing leases */
66
	$leases_contents = explode("\n", file_get_contents($leasesfile));
67
	$newleases_contents = array();
68
	$i=0;
69
	while ($i < count($leases_contents)) {
70
		/* Find a lease definition */
71
		if (substr($leases_contents[$i], 0, 6) == "lease ") {
72
			$templease = array();
73
			$thismac = "";
74
			/* Read to the end of the lease declaration */
75
			do {
76
				if (substr($leases_contents[$i], 0, 20) == "  hardware ethernet ")
77
					$thismac = substr($leases_contents[$i], 20, 17);
78
				$templease[] = $leases_contents[$i];
79
				$i++;
80
			} while ($leases_contents[$i-1] != "}");
81
			/* Check for a matching MAC address and if not present, keep it. */
82
			if (! in_array($thismac, $staticmacs))
83
				$newleases_contents = array_merge($newleases_contents, $templease);
84
		} else {
85
			/* It's a line we want to keep, copy it over. */
86
			$newleases_contents[] = $leases_contents[$i];
87
			$i++;
88
		}
89
	}
90
	/* Write out the new leases file */
91
	$fd = fopen($leasesfile, 'w');
92
	fwrite($fd, implode("\n", $newleases_contents));
93
	fclose($fd);
94
}
95
96 5b237745 Scott Ullrich
$if = $_GET['if'];
97
if ($_POST['if'])
98
	$if = $_POST['if'];
99 e9f147c8 Scott Ullrich
100 11bc553c Scott Ullrich
/* if OLSRD is enabled, allow WAN to house DHCP. */
101 a3b466b5 Scott Ullrich
if($config['installedpackages']['olsrd']) {
102
	foreach($config['installedpackages']['olsrd']['config'] as $olsrd) {
103 bc15a1b9 Scott Ullrich
			if($olsrd['enable']) {
104 48ab0cd2 Scott Ullrich
				$is_olsr_enabled = true;
105 a3b466b5 Scott Ullrich
				break;
106
			}
107
	}
108 11bc553c Scott Ullrich
}
109
110 934240ef Ermal Luçi
if (!$_GET['if'])
111 a4510ca0 Carlos Eduardo Ramos
	$savemsg = "<b>" . gettext("The DHCP Server can only be enabled on interfaces configured with static IP addresses") . ".<p>" . gettext("Only interfaces configured with a static IP will be shown") . ".</p></b>";
112 5b237745 Scott Ullrich
113 934240ef Ermal Luçi
$iflist = get_configured_interface_with_descr();
114 5b237745 Scott Ullrich
115 1c451b06 Scott Ullrich
/* set the starting interface */
116 f19651d1 Ermal
if (!$if || !isset($iflist[$if])) {
117 01fdb2d3 Erik Fonnesbeck
	foreach ($iflist as $ifent => $ifname) {
118 de792e62 jim-p
		$oc = $config['interfaces'][$ifent];
119
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddr($oc['ipaddr']))) ||
120 01fdb2d3 Erik Fonnesbeck
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddr($oc['ipaddr']))))
121
			continue;
122
		$if = $ifent;
123
		break;
124
	}
125 f19651d1 Ermal
}
126 0a2c6a5b Scott Ullrich
127 89019922 Ermal Luçi
if (is_array($config['dhcpd'][$if])){
128
	if (is_array($config['dhcpd'][$if]['range'])) {
129
		$pconfig['range_from'] = $config['dhcpd'][$if]['range']['from'];
130
		$pconfig['range_to'] = $config['dhcpd'][$if]['range']['to'];
131 de792e62 jim-p
	}
132 89019922 Ermal Luçi
	$pconfig['deftime'] = $config['dhcpd'][$if]['defaultleasetime'];
133
	$pconfig['maxtime'] = $config['dhcpd'][$if]['maxleasetime'];
134
	$pconfig['gateway'] = $config['dhcpd'][$if]['gateway'];
135
	$pconfig['domain'] = $config['dhcpd'][$if]['domain'];
136
	$pconfig['domainsearchlist'] = $config['dhcpd'][$if]['domainsearchlist'];
137
	list($pconfig['wins1'],$pconfig['wins2']) = $config['dhcpd'][$if]['winsserver'];
138
	list($pconfig['dns1'],$pconfig['dns2']) = $config['dhcpd'][$if]['dnsserver'];
139
	$pconfig['enable'] = isset($config['dhcpd'][$if]['enable']);
140
	$pconfig['denyunknown'] = isset($config['dhcpd'][$if]['denyunknown']);
141
	$pconfig['staticarp'] = isset($config['dhcpd'][$if]['staticarp']);
142
	$pconfig['ddnsdomain'] = $config['dhcpd'][$if]['ddnsdomain'];
143
	$pconfig['ddnsupdate'] = isset($config['dhcpd'][$if]['ddnsupdate']);
144
	list($pconfig['ntp1'],$pconfig['ntp2']) = $config['dhcpd'][$if]['ntpserver'];
145
	$pconfig['tftp'] = $config['dhcpd'][$if]['tftp'];
146
	$pconfig['ldap'] = $config['dhcpd'][$if]['ldap'];
147
	$pconfig['netboot'] = isset($config['dhcpd'][$if]['netboot']);
148
	$pconfig['nextserver'] = $config['dhcpd'][$if]['next-server'];
149
	$pconfig['filename'] = $config['dhcpd'][$if]['filename'];
150
	$pconfig['rootpath'] = $config['dhcpd'][$if]['rootpath'];
151
	$pconfig['failover_peerip'] = $config['dhcpd'][$if]['failover_peerip'];
152
	$pconfig['netmask'] = $config['dhcpd'][$if]['netmask'];
153 518030b3 Scott Ullrich
	$pconfig['numberoptions'] = $config['dhcpd'][$if]['numberoptions'];
154 de792e62 jim-p
	if (!is_array($config['dhcpd'][$if]['staticmap']))
155
		$config['dhcpd'][$if]['staticmap'] = array();
156 89019922 Ermal Luçi
	$a_maps = &$config['dhcpd'][$if]['staticmap'];
157
}
158 31c59d0d Scott Ullrich
159 a55e9c70 Ermal Lu?i
$ifcfgip = get_interface_ip($if);
160
$ifcfgsn = get_interface_subnet($if);
161 5b237745 Scott Ullrich
162 3d7b7757 Chris Buechler
/*   set the enabled flag which will tell us if DHCP relay is enabled
163 de792e62 jim-p
 *   on any interface. We will use this to disable DHCP server since
164 3d7b7757 Chris Buechler
 *   the two are not compatible with each other.
165
 */
166
167
$dhcrelay_enabled = false;
168
$dhcrelaycfg = $config['dhcrelay'];
169
170
if(is_array($dhcrelaycfg)) {
171
	foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
172 0c87f8fa Ermal Lu?i
		if (isset($dhcrelayifconf['enable']) && isset($iflist[$dhcrelayif]) &&
173
			(!link_interface_to_bridge($dhcrelayif)))
174 3d7b7757 Chris Buechler
			$dhcrelay_enabled = true;
175
	}
176
}
177
178 0ea7462d Bill Marquette
function is_inrange($test, $start, $end) {
179 96033063 Erik Fonnesbeck
	if ( (ip2ulong($test) < ip2ulong($end)) && (ip2ulong($test) > ip2ulong($start)) )
180 0ea7462d Bill Marquette
		return true;
181
	else
182
		return false;
183
}
184 b7597d4e Bill Marquette
185 5b237745 Scott Ullrich
if ($_POST) {
186
187
	unset($input_errors);
188 b7597d4e Bill Marquette
189 5b237745 Scott Ullrich
	$pconfig = $_POST;
190
191 6d1af0e9 jim-p
	$numberoptions = array();
192
	for($x=0; $x<99; $x++) {
193
		if(isset($_POST["number{$x}"]) && ctype_digit($_POST["number{$x}"])) {
194
			$numbervalue = array();
195
			$numbervalue['number'] = htmlspecialchars($_POST["number{$x}"]);
196 678dfd0f Erik Fonnesbeck
			$numbervalue['type'] = htmlspecialchars($_POST["itemtype{$x}"]);
197
			$numbervalue['value'] = str_replace('&quot;', '"', htmlspecialchars($_POST["value{$x}"]));
198 6d1af0e9 jim-p
			$numberoptions['item'][] = $numbervalue;
199
		}
200
	}
201
	// Reload the new pconfig variable that the forum uses.
202
	$pconfig['numberoptions'] = $numberoptions;
203
204 5b237745 Scott Ullrich
	/* input validation */
205
	if ($_POST['enable']) {
206
		$reqdfields = explode(" ", "range_from range_to");
207 40ad67e0 Rafael Lucas
		$reqdfieldsn = array(gettext("Range begin"),gettext("Range end"));
208 e9f147c8 Scott Ullrich
209 5b237745 Scott Ullrich
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
210 de792e62 jim-p
211
		if (($_POST['range_from'] && !is_ipaddr($_POST['range_from'])))
212 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid range must be specified.");
213 de792e62 jim-p
		if (($_POST['range_to'] && !is_ipaddr($_POST['range_to'])))
214 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid range must be specified.");
215 de792e62 jim-p
		if (($_POST['gateway'] && !is_ipaddr($_POST['gateway'])))
216 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid IP address must be specified for the gateway.");
217 de792e62 jim-p
		if (($_POST['wins1'] && !is_ipaddr($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddr($_POST['wins2'])))
218 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary WINS servers.");
219 de792e62 jim-p
		if (($_POST['dns1'] && !is_ipaddr($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddr($_POST['dns2'])))
220 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary DNS servers.");
221 26e3ca70 sullrich
222 de792e62 jim-p
		if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60)))
223 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("The default lease time must be at least 60 seconds.");
224 de792e62 jim-p
		if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime'])))
225 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("The maximum lease time must be at least 60 seconds and higher than the default lease time.");
226 de792e62 jim-p
		if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain'])))
227 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid domain name must be specified for the dynamic DNS registration.");
228 de792e62 jim-p
		if (($_POST['ntp1'] && !is_ipaddr($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddr($_POST['ntp2'])))
229 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary NTP servers.");
230 26e3ca70 sullrich
		if (($_POST['domain'] && !is_domain($_POST['domain'])))
231 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid domain name must be specified for the DNS domain.");
232 9dea60d1 Ermal
		if ($_POST['tftp'] && !is_ipaddr($_POST['tftp']) && !is_domain($_POST['tftp']) && !is_URL($_POST['tftp']))
233 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid IP address or hostname must be specified for the TFTP server.");
234 de792e62 jim-p
		if (($_POST['nextserver'] && !is_ipaddr($_POST['nextserver'])))
235 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid IP address must be specified for the network boot server.");
236 2c75b451 sullrich
237 26e3ca70 sullrich
		if(gen_subnet($ifcfgip, $ifcfgsn) == $_POST['range_from'])
238 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("You cannot use the network address in the starting subnet range.");
239 26e3ca70 sullrich
		if(gen_subnet_max($ifcfgip, $ifcfgsn) == $_POST['range_to'])
240 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("You cannot use the broadcast address in the ending subnet range.");
241 e9f147c8 Scott Ullrich
242 2c75b451 sullrich
		// Disallow a range that includes the virtualip
243 7dfa60fa Ermal Lu?i
		if (is_array($config['virtualip']['vip'])) {
244
			foreach($config['virtualip']['vip'] as $vip) {
245 de792e62 jim-p
				if($vip['interface'] == $if)
246
					if($vip['subnet'] && is_inrange($vip['subnet'], $_POST['range_from'], $_POST['range_to']))
247 3a3fb8ea Erik Fonnesbeck
						$input_errors[] = sprintf(gettext("The subnet range cannot overlap with virtual IP address %s."),$vip['subnet']);
248 7dfa60fa Ermal Lu?i
			}
249 2c75b451 sullrich
		}
250
251 073a2697 jim-p
		$noip = false;
252 2c7497cb Scott Ullrich
		if(is_array($a_maps))
253
			foreach ($a_maps as $map)
254
				if (empty($map['ipaddr']))
255
					$noip = true;
256 073a2697 jim-p
		if ($_POST['staticarp'] && $noip)
257
			$input_errors[] = "Cannot enable static ARP when you have static map entries without IP addresses. Ensure all static maps have IP addresses and try again.";
258
259 678dfd0f Erik Fonnesbeck
		if(is_array($pconfig['numberoptions']['item'])) {
260
			foreach ($pconfig['numberoptions']['item'] as $numberoption) {
261
				if ( $numberoption['type'] == 'text' && strstr($numberoption['value'], '"') )
262
					$input_errors[] = gettext("Text type cannot include quotation marks.");
263 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'string' && !preg_match('/^"[^"]*"$/', $numberoption['value']) && !preg_match('/^[0-9a-f]{2}(?:\:[0-9a-f]{2})*$/i', $numberoption['value']) )
264 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("String type must be enclosed in quotes like \"this\" or must be a series of octets specified in hexadecimal, separated by colons, like 01:23:45:67:89:ab:cd:ef");
265 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'boolean' && $numberoption['value'] != 'true' && $numberoption['value'] != 'false' && $numberoption['value'] != 'on' && $numberoption['value'] != 'off' )
266 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Boolean type must be true, false, on, or off.");
267 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'unsigned integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 255) )
268 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Unsigned 8-bit integer type must be a number in the range 0 to 255.");
269 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'unsigned integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 65535) )
270 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Unsigned 16-bit integer type must be a number in the range 0 to 65535.");
271 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'unsigned integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 4294967295) )
272 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Unsigned 32-bit integer type must be a number in the range 0 to 4294967295.");
273 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'signed integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -128 || $numberoption['value'] > 127) )
274 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Signed 8-bit integer type must be a number in the range -128 to 127.");
275 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'signed integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -32768 || $numberoption['value'] > 32767) )
276 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Signed 16-bit integer type must be a number in the range -32768 to 32767.");
277 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'signed integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -2147483648 || $numberoption['value'] > 2147483647) )
278 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Signed 32-bit integer type must be a number in the range -2147483648 to 2147483647.");
279
				else if ( $numberoption['type'] == 'ip-address' && !is_ipaddr($numberoption['value']) && !is_hostname($numberoption['value']) )
280
					$input_errors[] = gettext("IP address or host type must be an IP address or host name.");
281
			}
282
		}
283
284 5b237745 Scott Ullrich
		if (!$input_errors) {
285
			/* make sure the range lies within the current subnet */
286 96033063 Erik Fonnesbeck
			$subnet_start = ip2ulong(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
287
			$subnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
288 e9f147c8 Scott Ullrich
289 96033063 Erik Fonnesbeck
			if ((ip2ulong($_POST['range_from']) < $subnet_start) || (ip2ulong($_POST['range_from']) > $subnet_end) ||
290
			    (ip2ulong($_POST['range_to']) < $subnet_start) || (ip2ulong($_POST['range_to']) > $subnet_end)) {
291 40ad67e0 Rafael Lucas
				$input_errors[] = gettext("The specified range lies outside of the current subnet.");
292 5b237745 Scott Ullrich
			}
293 e9f147c8 Scott Ullrich
294 96033063 Erik Fonnesbeck
			if (ip2ulong($_POST['range_from']) > ip2ulong($_POST['range_to']))
295 40ad67e0 Rafael Lucas
				$input_errors[] = gettext("The range is invalid (first element higher than second element).");
296 e9f147c8 Scott Ullrich
297 5b237745 Scott Ullrich
			/* make sure that the DHCP Relay isn't enabled on this interface */
298
			if (isset($config['dhcrelay'][$if]['enable']))
299 3a3fb8ea Erik Fonnesbeck
				$input_errors[] = sprintf(gettext("You must disable the DHCP relay on the %s interface before enabling the DHCP server."),$iflist[$if]);
300 630d7025 jim-p
301
			$dynsubnet_start = ip2ulong($_POST['range_from']);
302
			$dynsubnet_end = ip2ulong($_POST['range_to']);
303 f02f0675 Erik Fonnesbeck
			if (is_array($a_maps)) {
304
				foreach ($a_maps as $map) {
305
					if (empty($map['ipaddr']))
306
						continue;
307
					if ((ip2ulong($map['ipaddr']) > $dynsubnet_start) &&
308
						(ip2ulong($map['ipaddr']) < $dynsubnet_end)) {
309
						$input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings."));
310
						break;
311
					}
312 630d7025 jim-p
				}
313
			}
314 5b237745 Scott Ullrich
		}
315
	}
316
317
	if (!$input_errors) {
318 89019922 Ermal Luçi
		if (!is_array($config['dhcpd'][$if]))
319
			$config['dhcpd'][$if] = array();
320
		if (!is_array($config['dhcpd'][$if]['range']))
321
			$config['dhcpd'][$if]['range'] = array();
322
323 5b237745 Scott Ullrich
		$config['dhcpd'][$if]['range']['from'] = $_POST['range_from'];
324
		$config['dhcpd'][$if]['range']['to'] = $_POST['range_to'];
325
		$config['dhcpd'][$if]['defaultleasetime'] = $_POST['deftime'];
326
		$config['dhcpd'][$if]['maxleasetime'] = $_POST['maxtime'];
327 48ab0cd2 Scott Ullrich
		$config['dhcpd'][$if]['netmask'] = $_POST['netmask'];
328 d378c59b Scott Ullrich
		$previous = $config['dhcpd'][$if]['failover_peerip'];
329 de792e62 jim-p
		if($previous <> $_POST['failover_peerip'])
330 1d333258 Scott Ullrich
			mwexec("/bin/rm -rf /var/dhcpd/var/db/*");
331
332 ea166a33 Scott Ullrich
		$config['dhcpd'][$if]['failover_peerip'] = $_POST['failover_peerip'];
333 e9f147c8 Scott Ullrich
334 5b237745 Scott Ullrich
		unset($config['dhcpd'][$if]['winsserver']);
335
		if ($_POST['wins1'])
336
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins1'];
337
		if ($_POST['wins2'])
338
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins2'];
339 4cab31d0 Scott Ullrich
340 94a9cf1a Scott Ullrich
		unset($config['dhcpd'][$if]['dnsserver']);
341 e9f147c8 Scott Ullrich
		if ($_POST['dns1'])
342 06d754d4 Scott Ullrich
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns1'];
343 e9f147c8 Scott Ullrich
		if ($_POST['dns2'])
344 06d754d4 Scott Ullrich
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns2'];
345 e9f147c8 Scott Ullrich
346 f9261419 Bill Marquette
		$config['dhcpd'][$if]['gateway'] = $_POST['gateway'];
347 1ebf937f Martin Fuchs
		$config['dhcpd'][$if]['domain'] = $_POST['domain'];
348 9be23653 Martin Fuchs
		$config['dhcpd'][$if]['domainsearchlist'] = $_POST['domainsearchlist'];
349 6a01ea44 Bill Marquette
		$config['dhcpd'][$if]['denyunknown'] = ($_POST['denyunknown']) ? true : false;
350
		$config['dhcpd'][$if]['enable'] = ($_POST['enable']) ? true : false;
351
		$config['dhcpd'][$if]['staticarp'] = ($_POST['staticarp']) ? true : false;
352 4e9cd828 Seth Mos
		$config['dhcpd'][$if]['ddnsdomain'] = $_POST['ddnsdomain'];
353
		$config['dhcpd'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
354 ad171999 Seth Mos
355
		unset($config['dhcpd'][$if]['ntpserver']);
356
		if ($_POST['ntp1'])
357
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp1'];
358
		if ($_POST['ntp2'])
359
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp2'];
360
361 6c23757b Martin Fuchs
		$config['dhcpd'][$if]['tftp'] = $_POST['tftp'];
362
		$config['dhcpd'][$if]['ldap'] = $_POST['ldap'];
363 4e9cd828 Seth Mos
		$config['dhcpd'][$if]['netboot'] = ($_POST['netboot']) ? true : false;
364
		$config['dhcpd'][$if]['next-server'] = $_POST['nextserver'];
365
		$config['dhcpd'][$if]['filename'] = $_POST['filename'];
366 ee1b024e Martin Fuchs
		$config['dhcpd'][$if]['rootpath'] = $_POST['rootpath'];
367 9c748b70 Scott Ullrich
368 d72b4114 Scott Ullrich
		// Handle the custom options rowhelper
369 11de5c3d Chris Buechler
		if(isset($config['dhcpd'][$if]['numberoptions']['item']))
370
			unset($config['dhcpd'][$if]['numberoptions']['item']);
371 6d1af0e9 jim-p
372
		$config['dhcpd'][$if]['numberoptions'] = $numberoptions;
373 518030b3 Scott Ullrich
374 5b237745 Scott Ullrich
		write_config();
375 80933129 Bill Marquette
376 5b237745 Scott Ullrich
		$retval = 0;
377 6a01ea44 Bill Marquette
		$retvaldhcp = 0;
378
		$retvaldns = 0;
379 c2ffc6c1 jim-p
		/* Stop DHCP so we can cleanup leases */
380
		killbyname("dhcpd");
381
		dhcp_clean_leases();
382 6a01ea44 Bill Marquette
		/* dnsmasq_configure calls dhcpd_configure */
383
		/* no need to restart dhcpd twice */
384
		if (isset($config['dnsmasq']['regdhcpstatic']))	{
385
			$retvaldns = services_dnsmasq_configure();
386
			if ($retvaldns == 0) {
387 a368a026 Ermal Lu?i
				clear_subsystem_dirty('hosts');
388
				clear_subsystem_dirty('staticmaps');
389 de792e62 jim-p
			}
390 6a01ea44 Bill Marquette
		} else {
391 de792e62 jim-p
			$retvaldhcp = services_dhcpd_configure();
392 a368a026 Ermal Lu?i
			if ($retvaldhcp == 0)
393
				clear_subsystem_dirty('staticmaps');
394 de792e62 jim-p
		}
395 6a01ea44 Bill Marquette
		if($retvaldhcp == 1 || $retvaldns == 1)
396
			$retval = 1;
397 5b237745 Scott Ullrich
		$savemsg = get_std_save_message($retval);
398
	}
399
}
400
401
if ($_GET['act'] == "del") {
402
	if ($a_maps[$_GET['id']]) {
403
		unset($a_maps[$_GET['id']]);
404
		write_config();
405 6a01ea44 Bill Marquette
		if(isset($config['dhcpd'][$if]['enable'])) {
406 a368a026 Ermal Lu?i
			mark_subsystem_dirty('staticmaps');
407 6a01ea44 Bill Marquette
			if (isset($config['dnsmasq']['regdhcpstatic']))
408 a368a026 Ermal Lu?i
				mark_subsystem_dirty('hosts');
409 6a01ea44 Bill Marquette
		}
410 5b237745 Scott Ullrich
		header("Location: services_dhcp.php?if={$if}");
411
		exit;
412
	}
413
}
414 4df96eff Scott Ullrich
415 40ad67e0 Rafael Lucas
$pgtitle = array(gettext("Services"),gettext("DHCP server"));
416 b9546722 Chris Buechler
$statusurl = "status_dhcp_leases.php";
417 5224b8e7 jim-p
$logurl = "diag_logs_dhcp.php";
418
419 4df96eff Scott Ullrich
include("head.inc");
420
421 5b237745 Scott Ullrich
?>
422 4df96eff Scott Ullrich
423 518030b3 Scott Ullrich
<script type="text/javascript" src="/javascript/row_helper.js">
424
</script>
425 4e9cd828 Seth Mos
426 518030b3 Scott Ullrich
<script type="text/javascript">
427 678dfd0f Erik Fonnesbeck
	function itemtype_field(fieldname, fieldsize, n) {
428
		return '<select name="' + fieldname + n + '" class="formselect" id="' + fieldname + n + '"><?php
429 1452fa57 Erik Fonnesbeck
			$customitemtypes = array('text' => gettext('Text'), 'string' => gettext('String'), 'boolean' => gettext('Boolean'),
430
				'unsigned integer 8' => gettext('Unsigned 8-bit integer'), 'unsigned integer 16' => gettext('Unsigned 16-bit integer'), 'unsigned integer 32' => gettext('Unsigned 32-bit integer'),
431
				'signed integer 8' => gettext('Signed 8-bit integer'), 'signed integer 16' => gettext('Signed 16-bit integer'), 'signed integer 32' => gettext('Signed 32-bit integer'), 'ip-address' => gettext('IP address or host'));
432 678dfd0f Erik Fonnesbeck
			foreach ($customitemtypes as $typename => $typedescr) {
433
				echo "<option value=\"{$typename}\">{$typedescr}</option>";
434
			}
435
		?></select>';
436
	}
437
438 518030b3 Scott Ullrich
	rowname[0] = "number";
439
	rowtype[0] = "textbox";
440 4e10cf0a Scott Ullrich
	rowsize[0] = "10";
441 678dfd0f Erik Fonnesbeck
	rowname[1] = "itemtype";
442
	rowtype[1] = itemtype_field;
443
	rowname[2] = "value";
444
	rowtype[2] = "textbox";
445
	rowsize[2] = "40";
446 518030b3 Scott Ullrich
</script>
447 4e9cd828 Seth Mos
448 518030b3 Scott Ullrich
<script type="text/javascript" language="JavaScript">
449
	function enable_change(enable_over) {
450
		var endis;
451
		endis = !(document.iform.enable.checked || enable_over);
452
		document.iform.range_from.disabled = endis;
453
		document.iform.range_to.disabled = endis;
454
		document.iform.wins1.disabled = endis;
455
		document.iform.wins2.disabled = endis;
456
		document.iform.dns1.disabled = endis;
457
		document.iform.dns2.disabled = endis;
458
		document.iform.deftime.disabled = endis;
459
		document.iform.maxtime.disabled = endis;
460
		document.iform.gateway.disabled = endis;
461
		document.iform.failover_peerip.disabled = endis;
462
		document.iform.domain.disabled = endis;
463
		document.iform.domainsearchlist.disabled = endis;
464
		document.iform.staticarp.disabled = endis;
465
		document.iform.ddnsdomain.disabled = endis;
466
		document.iform.ddnsupdate.disabled = endis;
467
		document.iform.ntp1.disabled = endis;
468
		document.iform.ntp2.disabled = endis;
469
		document.iform.tftp.disabled = endis;
470
		document.iform.ldap.disabled = endis;
471
		document.iform.netboot.disabled = endis;
472
		document.iform.nextserver.disabled = endis;
473
		document.iform.filename.disabled = endis;
474
		document.iform.rootpath.disabled = endis;
475
		document.iform.denyunknown.disabled = endis;
476
	}
477 4e9cd828 Seth Mos
478 b1d132f5 Scott Ullrich
	function show_shownumbervalue() {
479
		document.getElementById("shownumbervaluebox").innerHTML='';
480
		aodiv = document.getElementById('shownumbervalue');
481
		aodiv.style.display = "block";
482
	}
483
484 518030b3 Scott Ullrich
	function show_ddns_config() {
485
		document.getElementById("showddnsbox").innerHTML='';
486
		aodiv = document.getElementById('showddns');
487
		aodiv.style.display = "block";
488
	}
489 ad171999 Seth Mos
490 518030b3 Scott Ullrich
	function show_ntp_config() {
491
		document.getElementById("showntpbox").innerHTML='';
492
		aodiv = document.getElementById('showntp');
493
		aodiv.style.display = "block";
494
	}
495 6c23757b Martin Fuchs
496 518030b3 Scott Ullrich
	function show_tftp_config() {
497
		document.getElementById("showtftpbox").innerHTML='';
498
		aodiv = document.getElementById('showtftp');
499
		aodiv.style.display = "block";
500
	}
501 6c23757b Martin Fuchs
502 518030b3 Scott Ullrich
	function show_ldap_config() {
503
		document.getElementById("showldapbox").innerHTML='';
504
		aodiv = document.getElementById('showldap');
505
		aodiv.style.display = "block";
506
	}
507 4e9cd828 Seth Mos
508 518030b3 Scott Ullrich
	function show_netboot_config() {
509
		document.getElementById("shownetbootbox").innerHTML='';
510
		aodiv = document.getElementById('shownetboot');
511
		aodiv.style.display = "block";
512
	}
513 5b237745 Scott Ullrich
</script>
514
515
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
516 b7597d4e Bill Marquette
<?php include("fbegin.inc"); ?>
517 5b237745 Scott Ullrich
<form action="services_dhcp.php" method="post" name="iform" id="iform">
518
<?php if ($input_errors) print_input_errors($input_errors); ?>
519
<?php if ($savemsg) print_info_box($savemsg); ?>
520 de792e62 jim-p
<?php
521 3d7b7757 Chris Buechler
	if ($dhcrelay_enabled) {
522 40ad67e0 Rafael Lucas
		echo gettext("DHCP Relay is currently enabled. Cannot enable the DHCP Server service while the DHCP Relay is enabled on any interface.");
523 de792e62 jim-p
		include("fend.inc");
524 3d7b7757 Chris Buechler
		echo "</body>";
525
		echo "</html>";
526
		exit;
527
	}
528
?>
529 a368a026 Ermal Lu?i
<?php if (is_subsystem_dirty('staticmaps')): ?><p>
530 44d01644 Carlos Eduardo Ramos
<?php print_info_box_np(gettext("The static mapping configuration has been changed") . ".<br>" . gettext("You must apply the changes in order for them to take effect."));?><br>
531 5b237745 Scott Ullrich
<?php endif; ?>
532
<table width="100%" border="0" cellpadding="0" cellspacing="0">
533 de792e62 jim-p
<tr><td>
534
<?php
535 f0cdf141 Scott Ullrich
	/* active tabs */
536
	$tab_array = array();
537
	$tabscounter = 0;
538
	$i = 0;
539
	foreach ($iflist as $ifent => $ifname) {
540 de792e62 jim-p
		$oc = $config['interfaces'][$ifent];
541
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddr($oc['ipaddr']))) ||
542 a0d1dc56 Ermal Lu?i
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddr($oc['ipaddr']))))
543 934240ef Ermal Luçi
			continue;
544 f0cdf141 Scott Ullrich
		if ($ifent == $if)
545
			$active = true;
546
		else
547
			$active = false;
548
		$tab_array[] = array($ifname, $active, "services_dhcp.php?if={$ifent}");
549 934240ef Ermal Luçi
		$tabscounter++;
550
	}
551
	if ($tabscounter == 0) {
552
		echo "</td></tr></table></form>";
553
		include("fend.inc");
554
		echo "</body>";
555
		echo "</html>";
556
		exit;
557 f0cdf141 Scott Ullrich
	}
558
	display_top_tabs($tab_array);
559 de792e62 jim-p
?>
560
</td></tr>
561
<tr>
562
<td>
563 d732f186 Bill Marquette
	<div id="mainarea">
564 de792e62 jim-p
		<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
565
			<tr>
566
			<td width="22%" valign="top" class="vtable">&nbsp;</td>
567
			<td width="78%" class="vtable">
568
				<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
569 44d01644 Carlos Eduardo Ramos
			<strong><?php printf(gettext("Enable DHCP server on " .
570
			"%s " .
571
			"interface"),htmlspecialchars($iflist[$if]));?></strong></td>
572 de792e62 jim-p
			</tr>
573
			<tr>
574
			<td width="22%" valign="top" class="vtable">&nbsp;</td>
575
			<td width="78%" class="vtable">
576
				<input name="denyunknown" id="denyunknown" type="checkbox" value="yes" <?php if ($pconfig['denyunknown']) echo "checked"; ?>>
577 40ad67e0 Rafael Lucas
				<strong><?=gettext("Deny unknown clients");?></strong><br>
578
				<?=gettext("If this is checked, only the clients defined below will get DHCP leases from this server. ");?></td>
579 de792e62 jim-p
			</tr>
580
			<tr>
581 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet");?></td>
582 de792e62 jim-p
			<td width="78%" class="vtable">
583
				<?=gen_subnet($ifcfgip, $ifcfgsn);?>
584
			</td>
585
			</tr>
586
			<tr>
587 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet mask");?></td>
588 de792e62 jim-p
			<td width="78%" class="vtable">
589
				<?=gen_subnet_mask($ifcfgsn);?>
590
			</td>
591
			</tr>
592
			<tr>
593 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Available range");?></td>
594 de792e62 jim-p
			<td width="78%" class="vtable">
595
			<?php
596
				$range_from = ip2long(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
597
				$range_from++;
598
				echo long2ip32($range_from);
599
			?>
600
			-
601
			<?php
602
				$range_to = ip2long(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
603
				$range_to--;
604
				echo long2ip32($range_to);
605
			?>
606
			</td>
607
			</tr>
608
			<?php if($is_olsr_enabled): ?>
609
			<tr>
610 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet Mask");?></td>
611 de792e62 jim-p
			<td width="78%" class="vtable">
612
				<select name="netmask" class="formselect" id="netmask">
613
				<?php
614
				for ($i = 32; $i > 0; $i--) {
615
					if($i <> 31) {
616
						echo "<option value=\"{$i}\" ";
617
						if ($i == $pconfig['netmask']) echo "selected";
618
						echo ">" . $i . "</option>";
619
					}
620
				}
621
				?>
622
				</select>
623
			</td>
624
			</tr>
625
			<?php endif; ?>
626
			<tr>
627 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Range");?></td>
628 de792e62 jim-p
			<td width="78%" class="vtable">
629
				<input name="range_from" type="text" class="formfld unknown" id="range_from" size="20" value="<?=htmlspecialchars($pconfig['range_from']);?>">
630 6c235a30 Carlos Eduardo Ramos
				&nbsp;<?=gettext("to"); ?>&nbsp; <input name="range_to" type="text" class="formfld unknown" id="range_to" size="20" value="<?=htmlspecialchars($pconfig['range_to']);?>">
631 de792e62 jim-p
			</td>
632
			</tr>
633
			<tr>
634 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("WINS servers");?></td>
635 de792e62 jim-p
			<td width="78%" class="vtable">
636
				<input name="wins1" type="text" class="formfld unknown" id="wins1" size="20" value="<?=htmlspecialchars($pconfig['wins1']);?>"><br>
637
				<input name="wins2" type="text" class="formfld unknown" id="wins2" size="20" value="<?=htmlspecialchars($pconfig['wins2']);?>">
638
			</td>
639
			</tr>
640
			<tr>
641 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("DNS servers");?></td>
642 de792e62 jim-p
			<td width="78%" class="vtable">
643
				<input name="dns1" type="text" class="formfld unknown" id="dns1" size="20" value="<?=htmlspecialchars($pconfig['dns1']);?>"><br>
644
				<input name="dns2" type="text" class="formfld unknown" id="dns2" size="20" value="<?=htmlspecialchars($pconfig['dns2']);?>"><br>
645 40ad67e0 Rafael Lucas
				<?=gettext("NOTE: leave blank to use the system default DNS servers - this interface's IP if DNS forwarder is enabled, otherwise the servers configured on the General page.");?>
646 de792e62 jim-p
			</td>
647
			</tr>
648
			<tr>
649 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Gateway");?></td>
650 de792e62 jim-p
			<td width="78%" class="vtable">
651
				<input name="gateway" type="text" class="formfld host" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>"><br>
652 40ad67e0 Rafael Lucas
			 	 <?=gettext("The default is to use the IP on this interface of the firewall as the gateway. Specify an alternate gateway here if this is not the correct gateway for your network.");?>
653 de792e62 jim-p
			</td>
654
			</tr>
655
			<tr>
656 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Domain name");?></td>
657 de792e62 jim-p
			<td width="78%" class="vtable">
658
				<input name="domain" type="text" class="formfld unknown" id="domain" size="20" value="<?=htmlspecialchars($pconfig['domain']);?>"><br>
659 40ad67e0 Rafael Lucas
				 <?=gettext("The default is to use the domain name of this system as the default domain name provided by DHCP. You may specify an alternate domain name here.");?>
660 de792e62 jim-p
			 </td>
661
			</tr>
662
			<tr>
663 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Domain search list");?></td>
664 de792e62 jim-p
			<td width="78%" class="vtable">
665
				<input name="domainsearchlist" type="text" class="formfld unknown" id="domainsearchlist" size="20" value="<?=htmlspecialchars($pconfig['domainsearchlist']);?>"><br>
666 40ad67e0 Rafael Lucas
				<?=gettext("The DHCP server can optionally provide a domain search list.");?>
667 de792e62 jim-p
			</td>
668
			</tr>
669
			<tr>
670 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Default lease time");?></td>
671 de792e62 jim-p
			<td width="78%" class="vtable">
672
				<input name="deftime" type="text" class="formfld unknown" id="deftime" size="10" value="<?=htmlspecialchars($pconfig['deftime']);?>">
673 40ad67e0 Rafael Lucas
				<?=gettext("seconds");?><br>
674 44d01644 Carlos Eduardo Ramos
				<?=gettext("This is used for clients that do not ask for a specific " .
675 16457bdd Renato Botelho
				"expiration time."); ?><br>
676
				<?=gettext("The default is 7200 seconds.");?>
677 de792e62 jim-p
			</td>
678
			</tr>
679
			<tr>
680 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Maximum lease time");?></td>
681 de792e62 jim-p
			<td width="78%" class="vtable">
682
				<input name="maxtime" type="text" class="formfld unknown" id="maxtime" size="10" value="<?=htmlspecialchars($pconfig['maxtime']);?>">
683 40ad67e0 Rafael Lucas
				<?=gettext("seconds");?><br>
684
				<?=gettext("This is the maximum lease time for clients that ask".
685 16457bdd Renato Botelho
				" for a specific expiration time."); ?><br>
686
				<?=gettext("The default is 86400 seconds.");?>
687 de792e62 jim-p
			</td>
688
			</tr>
689
			<tr>
690 16457bdd Renato Botelho
			<td width="22%" valign="top" class="vncell"><?=gettext("Failover peer IP:");?></td>
691 de792e62 jim-p
			<td width="78%" class="vtable">
692 b5c78501 Seth Mos
				<input name="failover_peerip" type="text" class="formfld host" id="failover_peerip" size="20" value="<?=htmlspecialchars($pconfig['failover_peerip']);?>"><br>
693 40ad67e0 Rafael Lucas
				<?=gettext("Leave blank to disable.  Enter the interface IP address of the other machine.  Machines must be using CARP.");?>
694 ea166a33 Scott Ullrich
			</td>
695 518030b3 Scott Ullrich
			</tr>
696
			<tr>
697 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Static ARP");?></td>
698 de792e62 jim-p
			<td width="78%" class="vtable">
699
				<table>
700
					<tr>
701
					<td>
702
						<input valign="middle" type="checkbox" value="yes" name="staticarp" id="staticarp" <?php if($pconfig['staticarp']) echo " checked"; ?>>&nbsp;
703
					</td>
704 40ad67e0 Rafael Lucas
					<td><b><?=gettext("Enable Static ARP entries");?></b></td>
705 de792e62 jim-p
					</tr>
706
					<tr>
707
					<td>&nbsp;</td>
708
					<td>
709 16457bdd Renato Botelho
						<span class="red"><strong><?=gettext("Note:");?></strong></span> <?=gettext("Only the machines listed below will be able to communicate with the firewall on this NIC.");?>
710 de792e62 jim-p
					</td>
711
					</tr>
712
				</table>
713
			</td>
714 518030b3 Scott Ullrich
			</tr>
715
			<tr>
716 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic DNS");?></td>
717 de792e62 jim-p
			<td width="78%" class="vtable">
718
				<div id="showddnsbox">
719 44d01644 Carlos Eduardo Ramos
					<input type="button" onClick="show_ddns_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show Dynamic DNS");?></a>
720 de792e62 jim-p
				</div>
721
				<div id="showddns" style="display:none">
722
					<input valign="middle" type="checkbox" value="yes" name="ddnsupdate" id="ddnsupdate" <?php if($pconfig['ddnsupdate']) echo " checked"; ?>>&nbsp;
723 40ad67e0 Rafael Lucas
					<b><?=gettext("Enable registration of DHCP client names in DNS.");?></b><br />
724 de792e62 jim-p
					<p>
725
					<input name="ddnsdomain" type="text" class="formfld unknown" id="ddnsdomain" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomain']);?>"><br />
726 16457bdd Renato Botelho
					<?=gettext("Note: Leave blank to disable dynamic DNS registration.");?><br />
727
					<?=gettext("Enter the dynamic DNS domain which will be used to register client names in the DNS server.");?>
728 de792e62 jim-p
				</div>
729
			</td>
730
			</tr>
731 518030b3 Scott Ullrich
			<tr>
732 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("NTP servers");?></td>
733 de792e62 jim-p
			<td width="78%" class="vtable">
734 ad171999 Seth Mos
				<div id="showntpbox">
735 44d01644 Carlos Eduardo Ramos
					<input type="button" onClick="show_ntp_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show NTP configuration");?></a>
736 ad171999 Seth Mos
				</div>
737
				<div id="showntp" style="display:none">
738 b5c78501 Seth Mos
					<input name="ntp1" type="text" class="formfld unknown" id="ntp1" size="20" value="<?=htmlspecialchars($pconfig['ntp1']);?>"><br>
739
					<input name="ntp2" type="text" class="formfld unknown" id="ntp2" size="20" value="<?=htmlspecialchars($pconfig['ntp2']);?>">
740 ad171999 Seth Mos
				</div>
741
			</td>
742 518030b3 Scott Ullrich
			</tr>
743
			<tr>
744 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("TFTP server");?></td>
745 de792e62 jim-p
			<td width="78%" class="vtable">
746
			<div id="showtftpbox">
747 44d01644 Carlos Eduardo Ramos
				<input type="button" onClick="show_tftp_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show TFTP configuration");?></a>
748 de792e62 jim-p
			</div>
749
			<div id="showtftp" style="display:none">
750
				<input name="tftp" type="text" class="formfld unknown" id="tftp" size="50" value="<?=htmlspecialchars($pconfig['tftp']);?>"><br>
751 40ad67e0 Rafael Lucas
				<?=gettext("Leave blank to disable.  Enter a full hostname or IP for the TFTP server.");?>
752 de792e62 jim-p
			</div>
753 6c23757b Martin Fuchs
			</td>
754 518030b3 Scott Ullrich
			</tr>
755
			<tr>
756 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("LDAP URI");?></td>
757 de792e62 jim-p
			<td width="78%" class="vtable">
758
				<div id="showldapbox">
759 44d01644 Carlos Eduardo Ramos
					<input type="button" onClick="show_ldap_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show LDAP configuration");?></a>
760 de792e62 jim-p
				</div>
761
				<div id="showldap" style="display:none">
762
					<input name="ldap" type="text" class="formfld unknown" id="ldap" size="80" value="<?=htmlspecialchars($pconfig['ldap']);?>"><br>
763 40ad67e0 Rafael Lucas
					<?=gettext("Leave blank to disable.  Enter a full URI for the LDAP server in the form ldap://ldap.example.com/dc=example,dc=com");?>
764 de792e62 jim-p
				</div>
765
			</td>
766 518030b3 Scott Ullrich
			</tr>
767
			<tr>
768 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Enable network booting");?></td>
769 de792e62 jim-p
			<td width="78%" class="vtable">
770
				<div id="shownetbootbox">
771 44d01644 Carlos Eduardo Ramos
					<input type="button" onClick="show_netboot_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show Network booting");?></a>
772 de792e62 jim-p
				</div>
773
				<div id="shownetboot" style="display:none">
774
					<input valign="middle" type="checkbox" value="yes" name="netboot" id="netboot" <?php if($pconfig['netboot']) echo " checked"; ?>>&nbsp;
775 40ad67e0 Rafael Lucas
					<b><?=gettext("Enables network booting.");?></b>
776 de792e62 jim-p
					<p>
777 44d01644 Carlos Eduardo Ramos
					<?=gettext("Enter the IP of the"); ?> <b><?=gettext("next-server"); ?></b>
778 de792e62 jim-p
					<input name="nextserver" type="text" class="formfld unknown" id="nextserver" size="20" value="<?=htmlspecialchars($pconfig['nextserver']);?>">
779 40ad67e0 Rafael Lucas
					<?=gettext("and the filename");?>
780 de792e62 jim-p
					<input name="filename" type="text" class="formfld unknown" id="filename" size="20" value="<?=htmlspecialchars($pconfig['filename']);?>"><br>
781 40ad67e0 Rafael Lucas
					<?=gettext("Note: You need both a filename and a boot server configured for this to work!");?>
782 de792e62 jim-p
					<p>
783 44d01644 Carlos Eduardo Ramos
					<?=gettext("Enter the"); ?> <b><?=gettext("root-path"); ?></b>-<?=gettext("string");?>
784 de792e62 jim-p
					<input name="rootpath" type="text" class="formfld unknown" id="rootpath" size="90" value="<?=htmlspecialchars($pconfig['rootpath']);?>"><br>
785 40ad67e0 Rafael Lucas
					<?=gettext("Note: string-format: iscsi:(servername):(protocol):(port):(LUN):targetname");?>
786 de792e62 jim-p
				</div>
787 4e9cd828 Seth Mos
			</td>
788 518030b3 Scott Ullrich
			</tr>
789
			<tr>
790 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Additional BOOTP/DHCP Options");?></td>
791 de792e62 jim-p
			<td width="78%" class="vtable">
792
				<div id="shownumbervaluebox">
793 44d01644 Carlos Eduardo Ramos
					<input type="button" onClick="show_shownumbervalue()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show Additional BOOTP/DHCP Options");?></a>
794 de792e62 jim-p
				</div>
795
				<div id="shownumbervalue" style="display:none">
796
				<table id="maintable">
797
				<tbody>
798
				<tr>
799
				<td colspan="3">
800
					<div style="padding:5px; margin-top: 16px; margin-bottom: 16px; border:1px dashed #000066; background-color: #ffffff; color: #000000; font-size: 8pt;" id="itemhelp">
801 44d01644 Carlos Eduardo Ramos
					<?=gettext("Enter the DHCP option number and the value for each item you would like to include in the DHCP lease information.  For a list of available options please visit this"); ?> <a href="http://www.iana.org/assignments/bootp-dhcp-parameters/" target="_new"><?=gettext("URL"); ?></a>
802 b1d132f5 Scott Ullrich
					</div>
803 de792e62 jim-p
				</td>
804
				</tr>
805
				<tr>
806 40ad67e0 Rafael Lucas
				<td><div id="onecolumn"><?=gettext("Number");?></div></td>
807 678dfd0f Erik Fonnesbeck
				<td><div id="twocolumn"><?=gettext("Type");?></div></td>
808
				<td><div id="threecolumn"><?=gettext("Value");?></div></td>
809 de792e62 jim-p
				</tr>
810 518030b3 Scott Ullrich
				<?php $counter = 0; ?>
811 de792e62 jim-p
				<?php
812 518030b3 Scott Ullrich
					if($pconfig['numberoptions'])
813 de792e62 jim-p
						foreach($pconfig['numberoptions']['item'] as $item):
814 518030b3 Scott Ullrich
				?>
815
					<?php
816
						$number = $item['number'];
817 678dfd0f Erik Fonnesbeck
						$itemtype = $item['type'];
818 518030b3 Scott Ullrich
						$value = $item['value'];
819
					?>
820 de792e62 jim-p
				<tr>
821
				<td>
822 3440de72 Erik Fonnesbeck
					<input autocomplete="off" name="number<?php echo $counter; ?>" type="text" class="formfld unknown" id="number<?php echo $counter; ?>" size="10" value="<?=htmlspecialchars($number);?>" />
823 de792e62 jim-p
				</td>
824
				<td>
825 678dfd0f Erik Fonnesbeck
					<select name="itemtype<?php echo $counter; ?>" class="formselect" id="itemtype<?php echo $counter; ?>">
826
					<?php
827
					foreach ($customitemtypes as $typename => $typedescr) {
828
						echo "<option value=\"{$typename}\" ";
829
						if ($itemtype == $typename) echo "selected";
830
						echo ">" . $typedescr . "</option>";
831
					}
832
					?>
833
					</select>
834
				</td>
835
				<td>
836 3440de72 Erik Fonnesbeck
					<input autocomplete="off" name="value<?php echo $counter; ?>" type="text" class="formfld unknown" id="value<?php echo $counter; ?>" size="40" value="<?=htmlspecialchars($value);?>" />
837 de792e62 jim-p
				</td>
838
				<td>
839 bddc8818 Erik Fonnesbeck
					<a onclick="removeRow(this); return false;" href="#"><img border="0" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" /></a>
840 de792e62 jim-p
				</td>
841
				</tr>
842 518030b3 Scott Ullrich
				<?php $counter++; ?>
843
				<?php endforeach; ?>
844 de792e62 jim-p
				</tbody>
845
				<tfoot>
846
				</tfoot>
847 518030b3 Scott Ullrich
				</table>
848
				<a onclick="javascript:addRowTo('maintable', 'formfldalias'); return false;" href="#">
849 40ad67e0 Rafael Lucas
					<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="<?=gettext("add another entry");?>" />
850 518030b3 Scott Ullrich
				</a>
851
				<script type="text/javascript">
852 678dfd0f Erik Fonnesbeck
					field_counter_js = 3;
853 518030b3 Scott Ullrich
					rows = 1;
854
					totalrows = <?php echo $counter; ?>;
855
					loaded = <?php echo $counter; ?>;
856
				</script>
857 b1d132f5 Scott Ullrich
				</div>
858 518030b3 Scott Ullrich
859
				</td>
860
			</tr>
861
			<tr>
862 de792e62 jim-p
			<td width="22%" valign="top">&nbsp;</td>
863
			<td width="78%">
864 dd5bf424 Scott Ullrich
				<input name="if" type="hidden" value="<?=htmlspecialchars($if);?>">
865 40ad67e0 Rafael Lucas
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)">
866 de792e62 jim-p
			</td>
867
			</tr>
868
			<tr>
869
			<td width="22%" valign="top">&nbsp;</td>
870 16457bdd Renato Botelho
			<td width="78%"> <p><span class="vexpl"><span class="red"><strong><?=gettext("Note:");?><br>
871 6c235a30 Carlos Eduardo Ramos
				</strong></span><?=gettext("The DNS servers entered in"); ?> <a href="system.php"><?=gettext("System: " .
872
				"General setup"); ?></a> <?=gettext("(or the"); ?> <a href="services_dnsmasq.php"><?=gettext("DNS " .
873
				"forwarder"); ?></a>, <?=gettext("if enabled)"); ?> </span><span class="vexpl"><?=gettext("will " .
874 16457bdd Renato Botelho
				"be assigned to clients by the DHCP server."); ?><br>
875 de792e62 jim-p
				<br>
876 44d01644 Carlos Eduardo Ramos
				<?=gettext("The DHCP lease table can be viewed on the"); ?> <a href="status_dhcp_leases.php"><?=gettext("Status: " .
877 16457bdd Renato Botelho
				"DHCP leases"); ?></a> <?=gettext("page."); ?><br>
878 de792e62 jim-p
				</span></p>
879
			</td>
880 518030b3 Scott Ullrich
			</tr>
881
		</table>
882 282f7bfc Scott Ullrich
		<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
883 518030b3 Scott Ullrich
		<tr>
884 40ad67e0 Rafael Lucas
			<td width="25%" class="listhdrr"><?=gettext("MAC address");?></td>
885
			<td width="15%" class="listhdrr"><?=gettext("IP address");?></td>
886
			<td width="20%" class="listhdrr"><?=gettext("Hostname");?></td>
887
			<td width="30%" class="listhdr"><?=gettext("Description");?></td>
888 518030b3 Scott Ullrich
			<td width="10%" class="list">
889
			<table border="0" cellspacing="0" cellpadding="1">
890 de792e62 jim-p
			<tr>
891 d415d821 Seth Mos
			<td valign="middle" width="17"></td>
892 dd5bf424 Scott Ullrich
			<td valign="middle"><a href="services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
893 518030b3 Scott Ullrich
			</tr>
894
			</table>
895
			</td>
896 2af4c579 Scott Ullrich
		</tr>
897 de792e62 jim-p
			<?php if(is_array($a_maps)): ?>
898
			<?php $i = 0; foreach ($a_maps as $mapent): ?>
899
			<?php if($mapent['mac'] <> "" or $mapent['ipaddr'] <> ""): ?>
900
		<tr>
901 dd5bf424 Scott Ullrich
		<td class="listlr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&id=<?=$i;?>';">
902 de792e62 jim-p
			<?=htmlspecialchars($mapent['mac']);?>
903
		</td>
904 dd5bf424 Scott Ullrich
		<td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&id=<?=$i;?>';">
905 de792e62 jim-p
			<?=htmlspecialchars($mapent['ipaddr']);?>&nbsp;
906
		</td>
907 dd5bf424 Scott Ullrich
		<td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&id=<?=$i;?>';">
908 de792e62 jim-p
			<?=htmlspecialchars($mapent['hostname']);?>&nbsp;
909
		</td>
910 dd5bf424 Scott Ullrich
		<td class="listbg" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&id=<?=$i;?>';">
911 de792e62 jim-p
			<?=htmlspecialchars($mapent['descr']);?>&nbsp;
912
		</td>
913
		<td valign="middle" nowrap class="list">
914
			<table border="0" cellspacing="0" cellpadding="1">
915
			<tr>
916 dd5bf424 Scott Ullrich
			<td valign="middle"><a href="services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
917
			<td valign="middle"><a href="services_dhcp.php?if=<?=htmlspecialchars($if);?>&act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this mapping?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
918 de792e62 jim-p
			</tr>
919
			</table>
920
		</td>
921
		</tr>
922 6f5b2c3e Scott Ullrich
		<?php endif; ?>
923 75a70796 Bill Marquette
		<?php $i++; endforeach; ?>
924 6f5b2c3e Scott Ullrich
		<?php endif; ?>
925 de792e62 jim-p
		<tr>
926
		<td class="list" colspan="4"></td>
927
		<td class="list">
928
			<table border="0" cellspacing="0" cellpadding="1">
929
			<tr>
930 d415d821 Seth Mos
			<td valign="middle" width="17"></td>
931 dd5bf424 Scott Ullrich
			<td valign="middle"><a href="services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
932 de792e62 jim-p
			</tr>
933
			</table>
934
		</td>
935
		</tr>
936
		</table>
937 d732f186 Bill Marquette
	</div>
938 de792e62 jim-p
</td>
939
</tr>
940 5b237745 Scott Ullrich
</table>
941
</form>
942
<script language="JavaScript">
943
<!--
944
enable_change(false);
945
//-->
946
</script>
947 b7597d4e Bill Marquette
<?php include("fend.inc"); ?>
948 5b237745 Scott Ullrich
</body>
949
</html>