Project

General

Profile

Download (52.1 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 cba980f6 jim-p
if (!empty($_POST['if']))
98 5b237745 Scott Ullrich
	$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 e5770bc2 Bill Marquette
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) ||
120
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr']))))
121 01fdb2d3 Erik Fonnesbeck
			continue;
122
		$if = $ifent;
123
		break;
124
	}
125 f19651d1 Ermal
}
126 0a2c6a5b Scott Ullrich
127 cba980f6 jim-p
$act = $_GET['act'];
128
if (!empty($_POST['act']))
129
	$act = $_POST['act'];
130
131 cc6052f0 Renato Botelho
$a_pools = array();
132 cba980f6 jim-p
133 89019922 Ermal Luçi
if (is_array($config['dhcpd'][$if])){
134 cba980f6 jim-p
	$pool = $_GET['pool'];
135
	if (is_numeric($_POST['pool']))
136
		$pool = $_POST['pool'];
137
138
	// If we have a pool but no interface name, that's not valid. Redirect away.
139
	if (is_numeric($pool) && empty($if)) {
140
		header("Location: services_dhcp.php");
141
		exit;
142 de792e62 jim-p
	}
143 cba980f6 jim-p
144
	if (!is_array($config['dhcpd'][$if]['pool']))
145
		$config['dhcpd'][$if]['pool'] = array();
146
	$a_pools = &$config['dhcpd'][$if]['pool'];
147
148
	if (is_numeric($pool) && $a_pools[$pool])
149
		$dhcpdconf = &$a_pools[$pool];
150
	elseif ($act == "newpool")
151
		$dhcpdconf = array();
152
	else
153
		$dhcpdconf = &$config['dhcpd'][$if];
154
}
155
if (is_array($dhcpdconf)) {
156
	// Global Options
157
	if (!is_numeric($pool) && !($act == "newpool")) {
158
		$pconfig['enable'] = isset($dhcpdconf['enable']);
159
		$pconfig['staticarp'] = isset($dhcpdconf['staticarp']);
160
		// No reason to specify this per-pool, per the dhcpd.conf man page it needs to be in every
161
		//   pool and should be specified in every pool both nodes share, so we'll treat it as global
162
		$pconfig['failover_peerip'] = $dhcpdconf['failover_peerip'];
163
		$pconfig['dhcpleaseinlocaltime'] = $dhcpdconf['dhcpleaseinlocaltime'];
164
		if (!is_array($dhcpdconf['staticmap']))
165
			$dhcpdconf['staticmap'] = array();
166
		$a_maps = &$dhcpdconf['staticmap'];
167 ee1fb205 jim-p
	} else {
168
		// Options that exist only in pools
169
		$pconfig['descr'] = $dhcpdconf['descr'];
170 cba980f6 jim-p
	}
171
172
	// Options that can be global or per-pool.
173
	if (is_array($dhcpdconf['range'])) {
174
		$pconfig['range_from'] = $dhcpdconf['range']['from'];
175
		$pconfig['range_to'] = $dhcpdconf['range']['to'];
176
	}
177
	$pconfig['deftime'] = $dhcpdconf['defaultleasetime'];
178
	$pconfig['maxtime'] = $dhcpdconf['maxleasetime'];
179
	$pconfig['gateway'] = $dhcpdconf['gateway'];
180
	$pconfig['domain'] = $dhcpdconf['domain'];
181
	$pconfig['domainsearchlist'] = $dhcpdconf['domainsearchlist'];
182
	list($pconfig['wins1'],$pconfig['wins2']) = $dhcpdconf['winsserver'];
183
	list($pconfig['dns1'],$pconfig['dns2']) = $dhcpdconf['dnsserver'];
184
	$pconfig['denyunknown'] = isset($dhcpdconf['denyunknown']);
185
	$pconfig['ddnsdomain'] = $dhcpdconf['ddnsdomain'];
186
	$pconfig['ddnsupdate'] = isset($dhcpdconf['ddnsupdate']);
187
	$pconfig['mac_allow'] = $dhcpdconf['mac_allow'];
188
	$pconfig['mac_deny'] = $dhcpdconf['mac_deny'];
189
	list($pconfig['ntp1'],$pconfig['ntp2']) = $dhcpdconf['ntpserver'];
190
	$pconfig['tftp'] = $dhcpdconf['tftp'];
191
	$pconfig['ldap'] = $dhcpdconf['ldap'];
192
	$pconfig['netboot'] = isset($dhcpdconf['netboot']);
193
	$pconfig['nextserver'] = $dhcpdconf['nextserver'];
194
	$pconfig['filename'] = $dhcpdconf['filename'];
195
	$pconfig['rootpath'] = $dhcpdconf['rootpath'];
196
	$pconfig['netmask'] = $dhcpdconf['netmask'];
197
	$pconfig['numberoptions'] = $dhcpdconf['numberoptions'];
198 89019922 Ermal Luçi
}
199 31c59d0d Scott Ullrich
200 51cd7a1e Evgeny Yurchenko
$ifcfgip = $config['interfaces'][$if]['ipaddr'];
201
$ifcfgsn = $config['interfaces'][$if]['subnet'];
202 5b237745 Scott Ullrich
203 1f1a08c8 jim-p
function validate_partial_mac_list($maclist) {
204
	$macs = explode(',', $maclist);
205
206
	// Loop through and look for invalid MACs.
207
	foreach ($macs as $mac)
208
		if (!is_macaddr($mac, true))
209
			return false;
210
	return true;
211
}
212
213 5b237745 Scott Ullrich
if ($_POST) {
214
215
	unset($input_errors);
216 b7597d4e Bill Marquette
217 5b237745 Scott Ullrich
	$pconfig = $_POST;
218
219 6d1af0e9 jim-p
	$numberoptions = array();
220
	for($x=0; $x<99; $x++) {
221
		if(isset($_POST["number{$x}"]) && ctype_digit($_POST["number{$x}"])) {
222
			$numbervalue = array();
223
			$numbervalue['number'] = htmlspecialchars($_POST["number{$x}"]);
224 678dfd0f Erik Fonnesbeck
			$numbervalue['type'] = htmlspecialchars($_POST["itemtype{$x}"]);
225
			$numbervalue['value'] = str_replace('&quot;', '"', htmlspecialchars($_POST["value{$x}"]));
226 6d1af0e9 jim-p
			$numberoptions['item'][] = $numbervalue;
227
		}
228
	}
229
	// Reload the new pconfig variable that the forum uses.
230
	$pconfig['numberoptions'] = $numberoptions;
231
232 5b237745 Scott Ullrich
	/* input validation */
233 cba980f6 jim-p
	if ($_POST['enable'] || is_numeric($pool) || $act == "newpool") {
234 5b237745 Scott Ullrich
		$reqdfields = explode(" ", "range_from range_to");
235 40ad67e0 Rafael Lucas
		$reqdfieldsn = array(gettext("Range begin"),gettext("Range end"));
236 e9f147c8 Scott Ullrich
237 507628d5 Renato Botelho
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
238 de792e62 jim-p
239 e5770bc2 Bill Marquette
		if (($_POST['range_from'] && !is_ipaddrv4($_POST['range_from'])))
240 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid range must be specified.");
241 e5770bc2 Bill Marquette
		if (($_POST['range_to'] && !is_ipaddrv4($_POST['range_to'])))
242 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid range must be specified.");
243 e5770bc2 Bill Marquette
		if (($_POST['gateway'] && !is_ipaddrv4($_POST['gateway'])))
244 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid IP address must be specified for the gateway.");
245 e5770bc2 Bill Marquette
		if (($_POST['wins1'] && !is_ipaddrv4($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddrv4($_POST['wins2'])))
246 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary WINS servers.");
247 9bc59815 Evgeny Yurchenko
		$parent_ip = get_interface_ip($_POST['if']);
248 8b6313a4 jim-p
		if (is_ipaddrv4($parent_ip) && $_POST['gateway']) {
249 9bc59815 Evgeny Yurchenko
			$parent_sn = get_interface_subnet($_POST['if']);
250 b75d7fd5 Renato Botelho
			if(!ip_in_subnet($_POST['gateway'], gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn) && !ip_in_interface_alias_subnet($_POST['if'], $_POST['gateway']))
251 9bc59815 Evgeny Yurchenko
				$input_errors[] = sprintf(gettext("The gateway address %s does not lie within the chosen interface's subnet."), $_POST['gateway']);
252 45d1024d Scott Ullrich
		}
253 e5770bc2 Bill Marquette
		if (($_POST['dns1'] && !is_ipaddrv4($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddrv4($_POST['dns2'])))
254 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary DNS servers.");
255 26e3ca70 sullrich
256 de792e62 jim-p
		if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60)))
257 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("The default lease time must be at least 60 seconds.");
258 de792e62 jim-p
		if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime'])))
259 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("The maximum lease time must be at least 60 seconds and higher than the default lease time.");
260 de792e62 jim-p
		if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain'])))
261 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid domain name must be specified for the dynamic DNS registration.");
262 42a3cbab Pierre POMES
		if ($_POST['domainsearchlist']) {
263
			$domain_array=preg_split("/[ ;]+/",$_POST['domainsearchlist']);
264
			foreach ($domain_array as $curdomain) {
265
				if (!is_domain($curdomain)) {
266
					$input_errors[] = gettext("A valid domain search list must be specified.");
267
					break;
268
				}
269
			}
270
		}
271 1f1a08c8 jim-p
272
		// Validate MACs
273
		if (!empty($_POST['mac_allow']) && !validate_partial_mac_list($_POST['mac_allow']))
274
			$input_errors[] = gettext("If you specify a mac allow list, it must contain only valid partial MAC addresses.");
275
		if (!empty($_POST['mac_deny']) && !validate_partial_mac_list($_POST['mac_deny']))
276
			$input_errors[] = gettext("If you specify a mac deny list, it must contain only valid partial MAC addresses.");
277
278 e5770bc2 Bill Marquette
		if (($_POST['ntp1'] && !is_ipaddrv4($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddrv4($_POST['ntp2'])))
279 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary NTP servers.");
280 26e3ca70 sullrich
		if (($_POST['domain'] && !is_domain($_POST['domain'])))
281 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid domain name must be specified for the DNS domain.");
282 e5770bc2 Bill Marquette
		if ($_POST['tftp'] && !is_ipaddrv4($_POST['tftp']) && !is_domain($_POST['tftp']) && !is_URL($_POST['tftp']))
283 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid IP address or hostname must be specified for the TFTP server.");
284 e5770bc2 Bill Marquette
		if (($_POST['nextserver'] && !is_ipaddrv4($_POST['nextserver'])))
285 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid IP address must be specified for the network boot server.");
286 2c75b451 sullrich
287 26e3ca70 sullrich
		if(gen_subnet($ifcfgip, $ifcfgsn) == $_POST['range_from'])
288 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("You cannot use the network address in the starting subnet range.");
289 26e3ca70 sullrich
		if(gen_subnet_max($ifcfgip, $ifcfgsn) == $_POST['range_to'])
290 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("You cannot use the broadcast address in the ending subnet range.");
291 e9f147c8 Scott Ullrich
292 2c75b451 sullrich
		// Disallow a range that includes the virtualip
293 7dfa60fa Ermal Lu?i
		if (is_array($config['virtualip']['vip'])) {
294
			foreach($config['virtualip']['vip'] as $vip) {
295 de792e62 jim-p
				if($vip['interface'] == $if)
296 54404519 Renato Botelho
					if($vip['subnet'] && is_inrange_v4($vip['subnet'], $_POST['range_from'], $_POST['range_to']))
297 3a3fb8ea Erik Fonnesbeck
						$input_errors[] = sprintf(gettext("The subnet range cannot overlap with virtual IP address %s."),$vip['subnet']);
298 7dfa60fa Ermal Lu?i
			}
299 2c75b451 sullrich
		}
300
301 073a2697 jim-p
		$noip = false;
302 2c7497cb Scott Ullrich
		if(is_array($a_maps))
303
			foreach ($a_maps as $map)
304
				if (empty($map['ipaddr']))
305
					$noip = true;
306 073a2697 jim-p
		if ($_POST['staticarp'] && $noip)
307
			$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.";
308
309 678dfd0f Erik Fonnesbeck
		if(is_array($pconfig['numberoptions']['item'])) {
310
			foreach ($pconfig['numberoptions']['item'] as $numberoption) {
311
				if ( $numberoption['type'] == 'text' && strstr($numberoption['value'], '"') )
312
					$input_errors[] = gettext("Text type cannot include quotation marks.");
313 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']) )
314 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");
315 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'boolean' && $numberoption['value'] != 'true' && $numberoption['value'] != 'false' && $numberoption['value'] != 'on' && $numberoption['value'] != 'off' )
316 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Boolean type must be true, false, on, or off.");
317 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'unsigned integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 255) )
318 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Unsigned 8-bit integer type must be a number in the range 0 to 255.");
319 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'unsigned integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 65535) )
320 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Unsigned 16-bit integer type must be a number in the range 0 to 65535.");
321 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'unsigned integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 4294967295) )
322 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Unsigned 32-bit integer type must be a number in the range 0 to 4294967295.");
323 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'signed integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -128 || $numberoption['value'] > 127) )
324 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Signed 8-bit integer type must be a number in the range -128 to 127.");
325 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'signed integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -32768 || $numberoption['value'] > 32767) )
326 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Signed 16-bit integer type must be a number in the range -32768 to 32767.");
327 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'signed integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -2147483648 || $numberoption['value'] > 2147483647) )
328 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Signed 32-bit integer type must be a number in the range -2147483648 to 2147483647.");
329 e5770bc2 Bill Marquette
				else if ( $numberoption['type'] == 'ip-address' && !is_ipaddrv4($numberoption['value']) && !is_hostname($numberoption['value']) )
330 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("IP address or host type must be an IP address or host name.");
331
			}
332
		}
333
334 5b237745 Scott Ullrich
		if (!$input_errors) {
335
			/* make sure the range lies within the current subnet */
336 96033063 Erik Fonnesbeck
			$subnet_start = ip2ulong(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
337
			$subnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
338 e9f147c8 Scott Ullrich
339 96033063 Erik Fonnesbeck
			if ((ip2ulong($_POST['range_from']) < $subnet_start) || (ip2ulong($_POST['range_from']) > $subnet_end) ||
340
			    (ip2ulong($_POST['range_to']) < $subnet_start) || (ip2ulong($_POST['range_to']) > $subnet_end)) {
341 40ad67e0 Rafael Lucas
				$input_errors[] = gettext("The specified range lies outside of the current subnet.");
342 5b237745 Scott Ullrich
			}
343 e9f147c8 Scott Ullrich
344 96033063 Erik Fonnesbeck
			if (ip2ulong($_POST['range_from']) > ip2ulong($_POST['range_to']))
345 40ad67e0 Rafael Lucas
				$input_errors[] = gettext("The range is invalid (first element higher than second element).");
346 e9f147c8 Scott Ullrich
347 f657f5e1 Renato Botelho
			if (is_numeric($pool) || ($act == "newpool")) {
348
				$rfrom = $config['dhcpd'][$if]['range']['from'];
349
				$rto = $config['dhcpd'][$if]['range']['to'];
350
351
				if (is_inrange_v4($_POST['range_from'], $rfrom, $rto) || is_inrange_v4($_POST['range_to'], $rfrom, $rto))
352
					$input_errors[] = gettext("The specified range must not be within the DHCP range for this interface.");
353
			}
354
355
			foreach ($a_pools as $id => $p) {
356
				if (is_numeric($pool) && ($id == $pool))
357
					continue;
358
359
				if (is_inrange_v4($_POST['range_from'], $p['range']['from'], $p['range']['to']) ||
360
				    is_inrange_v4($_POST['range_to'], $p['range']['from'], $p['range']['to'])) {
361
					$input_errors[] = gettext("The specified range must not be within the range configured on a DHCP pool for this interface.");
362
					break;
363
				}
364
			}
365 cba980f6 jim-p
366 5b237745 Scott Ullrich
			/* make sure that the DHCP Relay isn't enabled on this interface */
367 0a35ca7c jim-p
			if (isset($config['dhcrelay']['enable']) && (stristr($config['dhcrelay']['interface'], $if) !== false))
368 3a3fb8ea Erik Fonnesbeck
				$input_errors[] = sprintf(gettext("You must disable the DHCP relay on the %s interface before enabling the DHCP server."),$iflist[$if]);
369 630d7025 jim-p
370
			$dynsubnet_start = ip2ulong($_POST['range_from']);
371
			$dynsubnet_end = ip2ulong($_POST['range_to']);
372 f02f0675 Erik Fonnesbeck
			if (is_array($a_maps)) {
373
				foreach ($a_maps as $map) {
374
					if (empty($map['ipaddr']))
375
						continue;
376
					if ((ip2ulong($map['ipaddr']) > $dynsubnet_start) &&
377
						(ip2ulong($map['ipaddr']) < $dynsubnet_end)) {
378
						$input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings."));
379
						break;
380
					}
381 630d7025 jim-p
				}
382
			}
383 5b237745 Scott Ullrich
		}
384
	}
385
386
	if (!$input_errors) {
387 cba980f6 jim-p
		if (!is_numeric($pool)) {
388
			if ($act == "newpool") {
389
				$dhcpdconf = array();
390
			} else {
391
				if (!is_array($config['dhcpd'][$if]))
392
					$config['dhcpd'][$if] = array();
393
				$dhcpdconf = $config['dhcpd'][$if];
394
			}
395
		} else {
396
			if (is_array($a_pools[$pool])) {
397
				$dhcpdconf = $a_pools[$pool];
398
			} else {
399
				// Someone specified a pool but it doesn't exist. Punt.
400
				header("Location: services_dhcp.php");
401
				exit;
402
			}
403
		}
404
		if (!is_array($dhcpdconf['range']))
405
			$dhcpdconf['range'] = array();
406
407
		// Global Options
408
		if (!is_numeric($pool) && !($act == "newpool")) {
409
			$dhcpdconf['enable'] = ($_POST['enable']) ? true : false;
410
			$dhcpdconf['staticarp'] = ($_POST['staticarp']) ? true : false;
411
			$previous = $dhcpdconf['failover_peerip'];
412
			if($previous <> $_POST['failover_peerip'])
413
				mwexec("/bin/rm -rf /var/dhcpd/var/db/*");
414
			$dhcpdconf['failover_peerip'] = $_POST['failover_peerip'];
415
			$dhcpdconf['dhcpleaseinlocaltime'] = $_POST['dhcpleaseinlocaltime'];
416 ee1fb205 jim-p
		} else {
417
			// Options that exist only in pools
418
			$dhcpdconf['descr'] = $_POST['descr'];
419 cba980f6 jim-p
		}
420
421
		// Options that can be global or per-pool.
422
		$dhcpdconf['range']['from'] = $_POST['range_from'];
423
		$dhcpdconf['range']['to'] = $_POST['range_to'];
424
		$dhcpdconf['defaultleasetime'] = $_POST['deftime'];
425
		$dhcpdconf['maxleasetime'] = $_POST['maxtime'];
426
		$dhcpdconf['netmask'] = $_POST['netmask'];
427
428
		unset($dhcpdconf['winsserver']);
429 5b237745 Scott Ullrich
		if ($_POST['wins1'])
430 cba980f6 jim-p
			$dhcpdconf['winsserver'][] = $_POST['wins1'];
431 5b237745 Scott Ullrich
		if ($_POST['wins2'])
432 cba980f6 jim-p
			$dhcpdconf['winsserver'][] = $_POST['wins2'];
433 4cab31d0 Scott Ullrich
434 cba980f6 jim-p
		unset($dhcpdconf['dnsserver']);
435 e9f147c8 Scott Ullrich
		if ($_POST['dns1'])
436 cba980f6 jim-p
			$dhcpdconf['dnsserver'][] = $_POST['dns1'];
437 e9f147c8 Scott Ullrich
		if ($_POST['dns2'])
438 cba980f6 jim-p
			$dhcpdconf['dnsserver'][] = $_POST['dns2'];
439
440
		$dhcpdconf['gateway'] = $_POST['gateway'];
441
		$dhcpdconf['domain'] = $_POST['domain'];
442
		$dhcpdconf['domainsearchlist'] = $_POST['domainsearchlist'];
443
		$dhcpdconf['denyunknown'] = ($_POST['denyunknown']) ? true : false;
444
		$dhcpdconf['ddnsdomain'] = $_POST['ddnsdomain'];
445
		$dhcpdconf['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
446
		$dhcpdconf['mac_allow'] = $_POST['mac_allow'];
447
		$dhcpdconf['mac_deny'] = $_POST['mac_deny'];
448
449
		unset($dhcpdconf['ntpserver']);
450 ad171999 Seth Mos
		if ($_POST['ntp1'])
451 cba980f6 jim-p
			$dhcpdconf['ntpserver'][] = $_POST['ntp1'];
452 ad171999 Seth Mos
		if ($_POST['ntp2'])
453 cba980f6 jim-p
			$dhcpdconf['ntpserver'][] = $_POST['ntp2'];
454 ad171999 Seth Mos
455 cba980f6 jim-p
		$dhcpdconf['tftp'] = $_POST['tftp'];
456
		$dhcpdconf['ldap'] = $_POST['ldap'];
457
		$dhcpdconf['netboot'] = ($_POST['netboot']) ? true : false;
458
		$dhcpdconf['nextserver'] = $_POST['nextserver'];
459
		$dhcpdconf['filename'] = $_POST['filename'];
460
		$dhcpdconf['rootpath'] = $_POST['rootpath'];
461 9c748b70 Scott Ullrich
462 d72b4114 Scott Ullrich
		// Handle the custom options rowhelper
463 cba980f6 jim-p
		if(isset($dhcpdconf['numberoptions']['item']))
464
			unset($dhcpdconf['numberoptions']['item']);
465 6d1af0e9 jim-p
466 cba980f6 jim-p
		$dhcpdconf['numberoptions'] = $numberoptions;
467
468
		if (is_numeric($pool) && is_array($a_pools[$pool])) {
469
			$a_pools[$pool] = $dhcpdconf;
470
		} elseif ($act == "newpool") {
471
			$a_pools[] = $dhcpdconf;
472
		} else {
473
			$config['dhcpd'][$if] = $dhcpdconf;
474
		}
475 518030b3 Scott Ullrich
476 5b237745 Scott Ullrich
		write_config();
477 80933129 Bill Marquette
478 5b237745 Scott Ullrich
		$retval = 0;
479 6a01ea44 Bill Marquette
		$retvaldhcp = 0;
480
		$retvaldns = 0;
481 c2ffc6c1 jim-p
		/* Stop DHCP so we can cleanup leases */
482
		killbyname("dhcpd");
483
		dhcp_clean_leases();
484 6a01ea44 Bill Marquette
		/* dnsmasq_configure calls dhcpd_configure */
485
		/* no need to restart dhcpd twice */
486
		if (isset($config['dnsmasq']['regdhcpstatic']))	{
487
			$retvaldns = services_dnsmasq_configure();
488
			if ($retvaldns == 0) {
489 a368a026 Ermal Lu?i
				clear_subsystem_dirty('hosts');
490
				clear_subsystem_dirty('staticmaps');
491 de792e62 jim-p
			}
492 6a01ea44 Bill Marquette
		} else {
493 de792e62 jim-p
			$retvaldhcp = services_dhcpd_configure();
494 a368a026 Ermal Lu?i
			if ($retvaldhcp == 0)
495
				clear_subsystem_dirty('staticmaps');
496 de792e62 jim-p
		}
497 6a01ea44 Bill Marquette
		if($retvaldhcp == 1 || $retvaldns == 1)
498
			$retval = 1;
499 5b237745 Scott Ullrich
		$savemsg = get_std_save_message($retval);
500
	}
501
}
502
503 cba980f6 jim-p
if ($act == "delpool") {
504
	if ($a_pools[$_GET['id']]) {
505
		unset($a_pools[$_GET['id']]);
506
		write_config();
507
		header("Location: services_dhcp.php?if={$if}");
508
		exit;
509
	}
510
}
511
512
if ($act == "del") {
513 5b237745 Scott Ullrich
	if ($a_maps[$_GET['id']]) {
514
		unset($a_maps[$_GET['id']]);
515
		write_config();
516 6a01ea44 Bill Marquette
		if(isset($config['dhcpd'][$if]['enable'])) {
517 a368a026 Ermal Lu?i
			mark_subsystem_dirty('staticmaps');
518 6a01ea44 Bill Marquette
			if (isset($config['dnsmasq']['regdhcpstatic']))
519 a368a026 Ermal Lu?i
				mark_subsystem_dirty('hosts');
520 6a01ea44 Bill Marquette
		}
521 5b237745 Scott Ullrich
		header("Location: services_dhcp.php?if={$if}");
522
		exit;
523
	}
524
}
525 4df96eff Scott Ullrich
526 40ad67e0 Rafael Lucas
$pgtitle = array(gettext("Services"),gettext("DHCP server"));
527 b32dd0a6 jim-p
$shortcut_section = "dhcp";
528 5224b8e7 jim-p
529 4df96eff Scott Ullrich
include("head.inc");
530
531 5b237745 Scott Ullrich
?>
532 4df96eff Scott Ullrich
533 518030b3 Scott Ullrich
<script type="text/javascript" src="/javascript/row_helper.js">
534
</script>
535 4e9cd828 Seth Mos
536 518030b3 Scott Ullrich
<script type="text/javascript">
537 678dfd0f Erik Fonnesbeck
	function itemtype_field(fieldname, fieldsize, n) {
538
		return '<select name="' + fieldname + n + '" class="formselect" id="' + fieldname + n + '"><?php
539 1452fa57 Erik Fonnesbeck
			$customitemtypes = array('text' => gettext('Text'), 'string' => gettext('String'), 'boolean' => gettext('Boolean'),
540
				'unsigned integer 8' => gettext('Unsigned 8-bit integer'), 'unsigned integer 16' => gettext('Unsigned 16-bit integer'), 'unsigned integer 32' => gettext('Unsigned 32-bit integer'),
541
				'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'));
542 678dfd0f Erik Fonnesbeck
			foreach ($customitemtypes as $typename => $typedescr) {
543
				echo "<option value=\"{$typename}\">{$typedescr}</option>";
544
			}
545
		?></select>';
546
	}
547
548 518030b3 Scott Ullrich
	rowname[0] = "number";
549
	rowtype[0] = "textbox";
550 4e10cf0a Scott Ullrich
	rowsize[0] = "10";
551 678dfd0f Erik Fonnesbeck
	rowname[1] = "itemtype";
552
	rowtype[1] = itemtype_field;
553
	rowname[2] = "value";
554
	rowtype[2] = "textbox";
555
	rowsize[2] = "40";
556 518030b3 Scott Ullrich
</script>
557 4e9cd828 Seth Mos
558 518030b3 Scott Ullrich
<script type="text/javascript" language="JavaScript">
559
	function enable_change(enable_over) {
560
		var endis;
561 cba980f6 jim-p
		<?php if (is_numeric($pool) || ($act == "newpool")): ?>
562
			enable_over = true;
563
		<?php endif; ?>
564 518030b3 Scott Ullrich
		endis = !(document.iform.enable.checked || enable_over);
565 ee1fb205 jim-p
		<?php if (is_numeric($pool) || ($act == "newpool")): ?>
566
			document.iform.descr.disabled = endis;
567
		<?php endif; ?>
568 518030b3 Scott Ullrich
		document.iform.range_from.disabled = endis;
569
		document.iform.range_to.disabled = endis;
570
		document.iform.wins1.disabled = endis;
571
		document.iform.wins2.disabled = endis;
572
		document.iform.dns1.disabled = endis;
573
		document.iform.dns2.disabled = endis;
574
		document.iform.deftime.disabled = endis;
575
		document.iform.maxtime.disabled = endis;
576
		document.iform.gateway.disabled = endis;
577
		document.iform.failover_peerip.disabled = endis;
578
		document.iform.domain.disabled = endis;
579
		document.iform.domainsearchlist.disabled = endis;
580
		document.iform.staticarp.disabled = endis;
581 f365fa90 Joecowboy
		document.iform.dhcpleaseinlocaltime.disabled = endis;
582 518030b3 Scott Ullrich
		document.iform.ddnsdomain.disabled = endis;
583
		document.iform.ddnsupdate.disabled = endis;
584 1f1a08c8 jim-p
		document.iform.mac_allow.disabled = endis;
585
		document.iform.mac_deny.disabled = endis;
586 518030b3 Scott Ullrich
		document.iform.ntp1.disabled = endis;
587
		document.iform.ntp2.disabled = endis;
588
		document.iform.tftp.disabled = endis;
589
		document.iform.ldap.disabled = endis;
590
		document.iform.netboot.disabled = endis;
591
		document.iform.nextserver.disabled = endis;
592
		document.iform.filename.disabled = endis;
593
		document.iform.rootpath.disabled = endis;
594
		document.iform.denyunknown.disabled = endis;
595
	}
596 4e9cd828 Seth Mos
597 b1d132f5 Scott Ullrich
	function show_shownumbervalue() {
598
		document.getElementById("shownumbervaluebox").innerHTML='';
599
		aodiv = document.getElementById('shownumbervalue');
600
		aodiv.style.display = "block";
601
	}
602
603 518030b3 Scott Ullrich
	function show_ddns_config() {
604
		document.getElementById("showddnsbox").innerHTML='';
605
		aodiv = document.getElementById('showddns');
606
		aodiv.style.display = "block";
607
	}
608 ad171999 Seth Mos
609 1f1a08c8 jim-p
	function show_maccontrol_config() {
610
		document.getElementById("showmaccontrolbox").innerHTML='';
611
		aodiv = document.getElementById('showmaccontrol');
612
		aodiv.style.display = "block";
613
	}
614
615 518030b3 Scott Ullrich
	function show_ntp_config() {
616
		document.getElementById("showntpbox").innerHTML='';
617
		aodiv = document.getElementById('showntp');
618
		aodiv.style.display = "block";
619
	}
620 6c23757b Martin Fuchs
621 518030b3 Scott Ullrich
	function show_tftp_config() {
622
		document.getElementById("showtftpbox").innerHTML='';
623
		aodiv = document.getElementById('showtftp');
624
		aodiv.style.display = "block";
625
	}
626 6c23757b Martin Fuchs
627 518030b3 Scott Ullrich
	function show_ldap_config() {
628
		document.getElementById("showldapbox").innerHTML='';
629
		aodiv = document.getElementById('showldap');
630
		aodiv.style.display = "block";
631
	}
632 4e9cd828 Seth Mos
633 518030b3 Scott Ullrich
	function show_netboot_config() {
634
		document.getElementById("shownetbootbox").innerHTML='';
635
		aodiv = document.getElementById('shownetboot');
636
		aodiv.style.display = "block";
637
	}
638 5b237745 Scott Ullrich
</script>
639
640
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
641 b7597d4e Bill Marquette
<?php include("fbegin.inc"); ?>
642 5b237745 Scott Ullrich
<form action="services_dhcp.php" method="post" name="iform" id="iform">
643
<?php if ($input_errors) print_input_errors($input_errors); ?>
644
<?php if ($savemsg) print_info_box($savemsg); ?>
645 de792e62 jim-p
<?php
646 0a35ca7c jim-p
	if (isset($config['dhcrelay']['enable'])) {
647 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.");
648 de792e62 jim-p
		include("fend.inc");
649 3d7b7757 Chris Buechler
		echo "</body>";
650
		echo "</html>";
651
		exit;
652
	}
653
?>
654 a368a026 Ermal Lu?i
<?php if (is_subsystem_dirty('staticmaps')): ?><p>
655 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>
656 5b237745 Scott Ullrich
<?php endif; ?>
657
<table width="100%" border="0" cellpadding="0" cellspacing="0">
658 de792e62 jim-p
<tr><td>
659
<?php
660 f0cdf141 Scott Ullrich
	/* active tabs */
661
	$tab_array = array();
662
	$tabscounter = 0;
663
	$i = 0;
664
	foreach ($iflist as $ifent => $ifname) {
665 de792e62 jim-p
		$oc = $config['interfaces'][$ifent];
666 e5770bc2 Bill Marquette
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) ||
667
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr']))))
668 934240ef Ermal Luçi
			continue;
669 f0cdf141 Scott Ullrich
		if ($ifent == $if)
670
			$active = true;
671
		else
672
			$active = false;
673
		$tab_array[] = array($ifname, $active, "services_dhcp.php?if={$ifent}");
674 934240ef Ermal Luçi
		$tabscounter++;
675
	}
676
	if ($tabscounter == 0) {
677
		echo "</td></tr></table></form>";
678
		include("fend.inc");
679
		echo "</body>";
680
		echo "</html>";
681
		exit;
682 f0cdf141 Scott Ullrich
	}
683
	display_top_tabs($tab_array);
684 de792e62 jim-p
?>
685
</td></tr>
686
<tr>
687
<td>
688 d732f186 Bill Marquette
	<div id="mainarea">
689 de792e62 jim-p
		<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
690 cba980f6 jim-p
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
691 de792e62 jim-p
			<tr>
692
			<td width="22%" valign="top" class="vtable">&nbsp;</td>
693
			<td width="78%" class="vtable">
694
				<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
695 44d01644 Carlos Eduardo Ramos
			<strong><?php printf(gettext("Enable DHCP server on " .
696
			"%s " .
697
			"interface"),htmlspecialchars($iflist[$if]));?></strong></td>
698 de792e62 jim-p
			</tr>
699 cba980f6 jim-p
			<?php else: ?>
700
			<tr>
701
				<td colspan="2" class="listtopic"><?php echo gettext("Editing Pool-Specific Options. To return to the Interface, click its tab above."); ?></td>
702
			</tr>
703
			<?php endif; ?>
704 de792e62 jim-p
			<tr>
705
			<td width="22%" valign="top" class="vtable">&nbsp;</td>
706
			<td width="78%" class="vtable">
707
				<input name="denyunknown" id="denyunknown" type="checkbox" value="yes" <?php if ($pconfig['denyunknown']) echo "checked"; ?>>
708 40ad67e0 Rafael Lucas
				<strong><?=gettext("Deny unknown clients");?></strong><br>
709
				<?=gettext("If this is checked, only the clients defined below will get DHCP leases from this server. ");?></td>
710 de792e62 jim-p
			</tr>
711 ee1fb205 jim-p
			<?php if (is_numeric($pool) || ($act == "newpool")): ?>
712
				<tr>
713
				<td width="22%" valign="top" class="vncell"><?=gettext("Pool Description");?></td>
714
				<td width="78%" class="vtable">
715
					<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>">
716
				</td>
717
				</tr>
718
			<?php endif; ?>
719 de792e62 jim-p
			<tr>
720 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet");?></td>
721 de792e62 jim-p
			<td width="78%" class="vtable">
722
				<?=gen_subnet($ifcfgip, $ifcfgsn);?>
723
			</td>
724
			</tr>
725
			<tr>
726 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet mask");?></td>
727 de792e62 jim-p
			<td width="78%" class="vtable">
728
				<?=gen_subnet_mask($ifcfgsn);?>
729
			</td>
730
			</tr>
731
			<tr>
732 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Available range");?></td>
733 de792e62 jim-p
			<td width="78%" class="vtable">
734
			<?php
735
				$range_from = ip2long(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
736
				$range_from++;
737
				echo long2ip32($range_from);
738
			?>
739
			-
740
			<?php
741
				$range_to = ip2long(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
742
				$range_to--;
743
				echo long2ip32($range_to);
744
			?>
745 cba980f6 jim-p
			<?php if (is_numeric($pool) || ($act == "newpool")): ?>
746
				<br/>In-use DHCP Pool Ranges:
747
				<?php if (is_array($config['dhcpd'][$if]['range'])): ?>
748
					<br/><?php echo $config['dhcpd'][$if]['range']['from']; ?>-<?php echo $config['dhcpd'][$if]['range']['to']; ?>
749
				<?php endif; ?>
750
				<?php foreach ($a_pools as $p): ?>
751 db4fb430 jim-p
					<?php if (is_array($p['range'])): ?>
752 cba980f6 jim-p
					<br/><?php echo $p['range']['from']; ?>-<?php echo $p['range']['to']; ?>
753 db4fb430 jim-p
					<?php endif; ?>
754 cba980f6 jim-p
				<?php endforeach; ?>
755
			<?php endif; ?>
756 de792e62 jim-p
			</td>
757
			</tr>
758
			<?php if($is_olsr_enabled): ?>
759
			<tr>
760 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet Mask");?></td>
761 de792e62 jim-p
			<td width="78%" class="vtable">
762
				<select name="netmask" class="formselect" id="netmask">
763
				<?php
764
				for ($i = 32; $i > 0; $i--) {
765
					if($i <> 31) {
766
						echo "<option value=\"{$i}\" ";
767
						if ($i == $pconfig['netmask']) echo "selected";
768
						echo ">" . $i . "</option>";
769
					}
770
				}
771
				?>
772
				</select>
773
			</td>
774
			</tr>
775
			<?php endif; ?>
776
			<tr>
777 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Range");?></td>
778 de792e62 jim-p
			<td width="78%" class="vtable">
779
				<input name="range_from" type="text" class="formfld unknown" id="range_from" size="20" value="<?=htmlspecialchars($pconfig['range_from']);?>">
780 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']);?>">
781 de792e62 jim-p
			</td>
782
			</tr>
783 cba980f6 jim-p
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
784
			<tr>
785
			<td width="22%" valign="top" class="vncell"><?=gettext("Additional Pools");?></td>
786
			<td width="78%" class="vtable">
787
				<?php echo gettext("If you need additional pools of addresses inside of this subnet outside the above Range, they may be specified here."); ?>
788
				<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
789
				<tr>
790 ee1fb205 jim-p
					<td width="35%" class="listhdrr"><?=gettext("Pool Start");?></td>
791
					<td width="35%" class="listhdrr"><?=gettext("Pool End");?></td>
792
					<td width="20%" class="listhdrr"><?=gettext("Description");?></td>
793 cba980f6 jim-p
					<td width="10%" class="list">
794
					<table border="0" cellspacing="0" cellpadding="1">
795
					<tr>
796
					<td valign="middle" width="17"></td>
797
					<td valign="middle"><a href="services_dhcp.php?if=<?=htmlspecialchars($if);?>&act=newpool"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
798
					</tr>
799
					</table>
800
					</td>
801
				</tr>
802
					<?php if(is_array($a_pools)): ?>
803
					<?php $i = 0; foreach ($a_pools as $poolent): ?>
804
					<?php if(!empty($poolent['range']['from']) && !empty($poolent['range']['to'])): ?>
805
				<tr>
806
				<td class="listlr" ondblclick="document.location='services_dhcp.php?if=<?=htmlspecialchars($if);?>&pool=<?=$i;?>';">
807
					<?=htmlspecialchars($poolent['range']['from']);?>
808
				</td>
809
				<td class="listr" ondblclick="document.location='services_dhcp.php?if=<?=htmlspecialchars($if);?>&pool=<?=$i;?>';">
810
					<?=htmlspecialchars($poolent['range']['to']);?>&nbsp;
811
				</td>
812 ee1fb205 jim-p
				<td class="listr" ondblclick="document.location='services_dhcp.php?if=<?=htmlspecialchars($if);?>&pool=<?=$i;?>';">
813
					<?=htmlspecialchars($poolent['descr']);?>&nbsp;
814
				</td>
815 cba980f6 jim-p
				<td valign="middle" nowrap class="list">
816
					<table border="0" cellspacing="0" cellpadding="1">
817
					<tr>
818
					<td valign="middle"><a href="services_dhcp.php?if=<?=htmlspecialchars($if);?>&pool=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
819
					<td valign="middle"><a href="services_dhcp.php?if=<?=htmlspecialchars($if);?>&act=delpool&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this pool?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
820
					</tr>
821
					</table>
822
				</td>
823
				</tr>
824
				<?php endif; ?>
825
				<?php $i++; endforeach; ?>
826
				<?php endif; ?>
827
				<tr>
828 ee1fb205 jim-p
				<td class="list" colspan="3"></td>
829 cba980f6 jim-p
				<td class="list">
830
					<table border="0" cellspacing="0" cellpadding="1">
831
					<tr>
832
					<td valign="middle" width="17"></td>
833
					<td valign="middle"><a href="services_dhcp.php?if=<?=htmlspecialchars($if);?>&act=newpool"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
834
					</tr>
835
					</table>
836
				</td>
837
				</tr>
838
				</table>
839
			</td>
840
			</tr>
841
			<?php endif; ?>
842 de792e62 jim-p
			<tr>
843 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("WINS servers");?></td>
844 de792e62 jim-p
			<td width="78%" class="vtable">
845
				<input name="wins1" type="text" class="formfld unknown" id="wins1" size="20" value="<?=htmlspecialchars($pconfig['wins1']);?>"><br>
846
				<input name="wins2" type="text" class="formfld unknown" id="wins2" size="20" value="<?=htmlspecialchars($pconfig['wins2']);?>">
847
			</td>
848
			</tr>
849
			<tr>
850 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("DNS servers");?></td>
851 de792e62 jim-p
			<td width="78%" class="vtable">
852
				<input name="dns1" type="text" class="formfld unknown" id="dns1" size="20" value="<?=htmlspecialchars($pconfig['dns1']);?>"><br>
853
				<input name="dns2" type="text" class="formfld unknown" id="dns2" size="20" value="<?=htmlspecialchars($pconfig['dns2']);?>"><br>
854 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.");?>
855 de792e62 jim-p
			</td>
856
			</tr>
857
			<tr>
858 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Gateway");?></td>
859 de792e62 jim-p
			<td width="78%" class="vtable">
860
				<input name="gateway" type="text" class="formfld host" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>"><br>
861 b75d7fd5 Renato Botelho
				 <?=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.");?>
862 de792e62 jim-p
			</td>
863
			</tr>
864
			<tr>
865 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Domain name");?></td>
866 de792e62 jim-p
			<td width="78%" class="vtable">
867
				<input name="domain" type="text" class="formfld unknown" id="domain" size="20" value="<?=htmlspecialchars($pconfig['domain']);?>"><br>
868 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.");?>
869 b75d7fd5 Renato Botelho
			</td>
870 de792e62 jim-p
			</tr>
871
			<tr>
872 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Domain search list");?></td>
873 de792e62 jim-p
			<td width="78%" class="vtable">
874
				<input name="domainsearchlist" type="text" class="formfld unknown" id="domainsearchlist" size="20" value="<?=htmlspecialchars($pconfig['domainsearchlist']);?>"><br>
875 a3de8b9e Pierre POMES
				<?=gettext("The DHCP server can optionally provide a domain search list. Use the semicolon character as seperator ");?>
876 de792e62 jim-p
			</td>
877
			</tr>
878
			<tr>
879 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Default lease time");?></td>
880 de792e62 jim-p
			<td width="78%" class="vtable">
881
				<input name="deftime" type="text" class="formfld unknown" id="deftime" size="10" value="<?=htmlspecialchars($pconfig['deftime']);?>">
882 40ad67e0 Rafael Lucas
				<?=gettext("seconds");?><br>
883 44d01644 Carlos Eduardo Ramos
				<?=gettext("This is used for clients that do not ask for a specific " .
884 16457bdd Renato Botelho
				"expiration time."); ?><br>
885
				<?=gettext("The default is 7200 seconds.");?>
886 de792e62 jim-p
			</td>
887
			</tr>
888
			<tr>
889 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Maximum lease time");?></td>
890 de792e62 jim-p
			<td width="78%" class="vtable">
891
				<input name="maxtime" type="text" class="formfld unknown" id="maxtime" size="10" value="<?=htmlspecialchars($pconfig['maxtime']);?>">
892 40ad67e0 Rafael Lucas
				<?=gettext("seconds");?><br>
893
				<?=gettext("This is the maximum lease time for clients that ask".
894 16457bdd Renato Botelho
				" for a specific expiration time."); ?><br>
895
				<?=gettext("The default is 86400 seconds.");?>
896 de792e62 jim-p
			</td>
897
			</tr>
898 cba980f6 jim-p
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
899 de792e62 jim-p
			<tr>
900 16457bdd Renato Botelho
			<td width="22%" valign="top" class="vncell"><?=gettext("Failover peer IP:");?></td>
901 de792e62 jim-p
			<td width="78%" class="vtable">
902 b5c78501 Seth Mos
				<input name="failover_peerip" type="text" class="formfld host" id="failover_peerip" size="20" value="<?=htmlspecialchars($pconfig['failover_peerip']);?>"><br>
903 83a9a1d2 framer99
				<?=gettext("Leave blank to disable.  Enter the interface IP address of the other machine.  Machines must be using CARP. Interface's advskew determines whether the DHCPd process is Primary or Secondary. Ensure one machine's advskew<20 (and the other is >20).");?>
904 ea166a33 Scott Ullrich
			</td>
905 518030b3 Scott Ullrich
			</tr>
906 cba980f6 jim-p
			<?php endif; ?>
907
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
908 518030b3 Scott Ullrich
			<tr>
909 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Static ARP");?></td>
910 de792e62 jim-p
			<td width="78%" class="vtable">
911
				<table>
912
					<tr>
913
					<td>
914
						<input valign="middle" type="checkbox" value="yes" name="staticarp" id="staticarp" <?php if($pconfig['staticarp']) echo " checked"; ?>>&nbsp;
915
					</td>
916 40ad67e0 Rafael Lucas
					<td><b><?=gettext("Enable Static ARP entries");?></b></td>
917 de792e62 jim-p
					</tr>
918
					<tr>
919
					<td>&nbsp;</td>
920
					<td>
921 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.");?>
922 de792e62 jim-p
					</td>
923
					</tr>
924
				</table>
925
			</td>
926 518030b3 Scott Ullrich
			</tr>
927 cba980f6 jim-p
			<?php endif; ?>
928
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
929 6215694a Joecowboy
			<tr>
930
				<td width="22%" valign="top" class="vncell"><?=gettext("Time format change"); ?></td>
931
				<td width="78%" class="vtable">
932
				<table>
933
					<tr>
934
					<td>
935 f365fa90 Joecowboy
						<input name="dhcpleaseinlocaltime" type="checkbox" id="dhcpleaseinlocaltime" value="yes" <?php if ($pconfig['dhcpleaseinlocaltime']) echo "checked"; ?>>
936 6215694a Joecowboy
					</td>
937
					<td>
938
						<strong>
939
							<?=gettext("Change DHCP display lease time from UTC to local time."); ?>
940
						</strong>
941
					</td>
942
					</tr>
943
					<tr>
944
					<td>&nbsp;</td>
945
					<td>
946 b75d7fd5 Renato Botelho
						<span class="red"><strong><?=gettext("Note:");?></strong></span> <?=gettext("By default DHCP leases are displayed in UTC time.  By checking this
947 6215694a Joecowboy
						box DHCP lease time will be displayed in local time and set to time zone selected.  This will be used for all DHCP interfaces lease time."); ?>
948
					</td>
949
					</tr>
950
				</table>
951
				</td>
952
			</tr>
953 cba980f6 jim-p
			<?php endif; ?>
954 518030b3 Scott Ullrich
			<tr>
955 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic DNS");?></td>
956 de792e62 jim-p
			<td width="78%" class="vtable">
957
				<div id="showddnsbox">
958 44d01644 Carlos Eduardo Ramos
					<input type="button" onClick="show_ddns_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show Dynamic DNS");?></a>
959 de792e62 jim-p
				</div>
960
				<div id="showddns" style="display:none">
961
					<input valign="middle" type="checkbox" value="yes" name="ddnsupdate" id="ddnsupdate" <?php if($pconfig['ddnsupdate']) echo " checked"; ?>>&nbsp;
962 40ad67e0 Rafael Lucas
					<b><?=gettext("Enable registration of DHCP client names in DNS.");?></b><br />
963 de792e62 jim-p
					<p>
964
					<input name="ddnsdomain" type="text" class="formfld unknown" id="ddnsdomain" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomain']);?>"><br />
965 16457bdd Renato Botelho
					<?=gettext("Note: Leave blank to disable dynamic DNS registration.");?><br />
966
					<?=gettext("Enter the dynamic DNS domain which will be used to register client names in the DNS server.");?>
967 de792e62 jim-p
				</div>
968
			</td>
969
			</tr>
970 518030b3 Scott Ullrich
			<tr>
971 1f1a08c8 jim-p
			<td width="22%" valign="top" class="vncell"><?=gettext("MAC Address Control");?></td>
972
			<td width="78%" class="vtable">
973
				<div id="showmaccontrolbox">
974
					<input type="button" onClick="show_maccontrol_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show MAC Address Control");?></a>
975
				</div>
976
				<div id="showmaccontrol" style="display:none">
977
					<input name="mac_allow" type="text" class="formfld unknown" id="mac_allow" size="20" value="<?=htmlspecialchars($pconfig['mac_allow']);?>"><br />
978
					<?=gettext("Enter a list of partial MAC addresses to allow, comma separated, no spaces, such as ");?>00:00:00,01:E5:FF
979
					<input name="mac_deny" type="text" class="formfld unknown" id="mac_deny" size="20" value="<?=htmlspecialchars($pconfig['mac_deny']);?>"><br />
980
					<?=gettext("Enter a list of partial MAC addresses to deny access, comma separated, no spaces, such as ");?>00:00:00,01:E5:FF
981
				</div>
982
			</td>
983
			</tr>
984
			<tr>
985 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("NTP servers");?></td>
986 de792e62 jim-p
			<td width="78%" class="vtable">
987 ad171999 Seth Mos
				<div id="showntpbox">
988 44d01644 Carlos Eduardo Ramos
					<input type="button" onClick="show_ntp_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show NTP configuration");?></a>
989 ad171999 Seth Mos
				</div>
990
				<div id="showntp" style="display:none">
991 b5c78501 Seth Mos
					<input name="ntp1" type="text" class="formfld unknown" id="ntp1" size="20" value="<?=htmlspecialchars($pconfig['ntp1']);?>"><br>
992
					<input name="ntp2" type="text" class="formfld unknown" id="ntp2" size="20" value="<?=htmlspecialchars($pconfig['ntp2']);?>">
993 ad171999 Seth Mos
				</div>
994
			</td>
995 518030b3 Scott Ullrich
			</tr>
996
			<tr>
997 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("TFTP server");?></td>
998 de792e62 jim-p
			<td width="78%" class="vtable">
999
			<div id="showtftpbox">
1000 44d01644 Carlos Eduardo Ramos
				<input type="button" onClick="show_tftp_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show TFTP configuration");?></a>
1001 de792e62 jim-p
			</div>
1002
			<div id="showtftp" style="display:none">
1003
				<input name="tftp" type="text" class="formfld unknown" id="tftp" size="50" value="<?=htmlspecialchars($pconfig['tftp']);?>"><br>
1004 40ad67e0 Rafael Lucas
				<?=gettext("Leave blank to disable.  Enter a full hostname or IP for the TFTP server.");?>
1005 de792e62 jim-p
			</div>
1006 6c23757b Martin Fuchs
			</td>
1007 518030b3 Scott Ullrich
			</tr>
1008
			<tr>
1009 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("LDAP URI");?></td>
1010 de792e62 jim-p
			<td width="78%" class="vtable">
1011
				<div id="showldapbox">
1012 44d01644 Carlos Eduardo Ramos
					<input type="button" onClick="show_ldap_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show LDAP configuration");?></a>
1013 de792e62 jim-p
				</div>
1014
				<div id="showldap" style="display:none">
1015
					<input name="ldap" type="text" class="formfld unknown" id="ldap" size="80" value="<?=htmlspecialchars($pconfig['ldap']);?>"><br>
1016 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");?>
1017 de792e62 jim-p
				</div>
1018
			</td>
1019 518030b3 Scott Ullrich
			</tr>
1020
			<tr>
1021 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Enable network booting");?></td>
1022 de792e62 jim-p
			<td width="78%" class="vtable">
1023
				<div id="shownetbootbox">
1024 44d01644 Carlos Eduardo Ramos
					<input type="button" onClick="show_netboot_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show Network booting");?></a>
1025 de792e62 jim-p
				</div>
1026
				<div id="shownetboot" style="display:none">
1027
					<input valign="middle" type="checkbox" value="yes" name="netboot" id="netboot" <?php if($pconfig['netboot']) echo " checked"; ?>>&nbsp;
1028 40ad67e0 Rafael Lucas
					<b><?=gettext("Enables network booting.");?></b>
1029 de792e62 jim-p
					<p>
1030 44d01644 Carlos Eduardo Ramos
					<?=gettext("Enter the IP of the"); ?> <b><?=gettext("next-server"); ?></b>
1031 de792e62 jim-p
					<input name="nextserver" type="text" class="formfld unknown" id="nextserver" size="20" value="<?=htmlspecialchars($pconfig['nextserver']);?>">
1032 40ad67e0 Rafael Lucas
					<?=gettext("and the filename");?>
1033 de792e62 jim-p
					<input name="filename" type="text" class="formfld unknown" id="filename" size="20" value="<?=htmlspecialchars($pconfig['filename']);?>"><br>
1034 40ad67e0 Rafael Lucas
					<?=gettext("Note: You need both a filename and a boot server configured for this to work!");?>
1035 de792e62 jim-p
					<p>
1036 44d01644 Carlos Eduardo Ramos
					<?=gettext("Enter the"); ?> <b><?=gettext("root-path"); ?></b>-<?=gettext("string");?>
1037 de792e62 jim-p
					<input name="rootpath" type="text" class="formfld unknown" id="rootpath" size="90" value="<?=htmlspecialchars($pconfig['rootpath']);?>"><br>
1038 40ad67e0 Rafael Lucas
					<?=gettext("Note: string-format: iscsi:(servername):(protocol):(port):(LUN):targetname");?>
1039 de792e62 jim-p
				</div>
1040 4e9cd828 Seth Mos
			</td>
1041 518030b3 Scott Ullrich
			</tr>
1042 cba980f6 jim-p
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
1043 518030b3 Scott Ullrich
			<tr>
1044 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Additional BOOTP/DHCP Options");?></td>
1045 de792e62 jim-p
			<td width="78%" class="vtable">
1046
				<div id="shownumbervaluebox">
1047 44d01644 Carlos Eduardo Ramos
					<input type="button" onClick="show_shownumbervalue()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show Additional BOOTP/DHCP Options");?></a>
1048 de792e62 jim-p
				</div>
1049
				<div id="shownumbervalue" style="display:none">
1050
				<table id="maintable">
1051
				<tbody>
1052
				<tr>
1053
				<td colspan="3">
1054
					<div style="padding:5px; margin-top: 16px; margin-bottom: 16px; border:1px dashed #000066; background-color: #ffffff; color: #000000; font-size: 8pt;" id="itemhelp">
1055 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>
1056 b1d132f5 Scott Ullrich
					</div>
1057 de792e62 jim-p
				</td>
1058
				</tr>
1059
				<tr>
1060 40ad67e0 Rafael Lucas
				<td><div id="onecolumn"><?=gettext("Number");?></div></td>
1061 678dfd0f Erik Fonnesbeck
				<td><div id="twocolumn"><?=gettext("Type");?></div></td>
1062
				<td><div id="threecolumn"><?=gettext("Value");?></div></td>
1063 de792e62 jim-p
				</tr>
1064 518030b3 Scott Ullrich
				<?php $counter = 0; ?>
1065 de792e62 jim-p
				<?php
1066 518030b3 Scott Ullrich
					if($pconfig['numberoptions'])
1067 de792e62 jim-p
						foreach($pconfig['numberoptions']['item'] as $item):
1068 518030b3 Scott Ullrich
				?>
1069
					<?php
1070
						$number = $item['number'];
1071 678dfd0f Erik Fonnesbeck
						$itemtype = $item['type'];
1072 518030b3 Scott Ullrich
						$value = $item['value'];
1073
					?>
1074 de792e62 jim-p
				<tr>
1075
				<td>
1076 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);?>" />
1077 de792e62 jim-p
				</td>
1078
				<td>
1079 678dfd0f Erik Fonnesbeck
					<select name="itemtype<?php echo $counter; ?>" class="formselect" id="itemtype<?php echo $counter; ?>">
1080
					<?php
1081
					foreach ($customitemtypes as $typename => $typedescr) {
1082
						echo "<option value=\"{$typename}\" ";
1083
						if ($itemtype == $typename) echo "selected";
1084
						echo ">" . $typedescr . "</option>";
1085
					}
1086
					?>
1087
					</select>
1088
				</td>
1089
				<td>
1090 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);?>" />
1091 de792e62 jim-p
				</td>
1092
				<td>
1093 bddc8818 Erik Fonnesbeck
					<a onclick="removeRow(this); return false;" href="#"><img border="0" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" /></a>
1094 de792e62 jim-p
				</td>
1095
				</tr>
1096 518030b3 Scott Ullrich
				<?php $counter++; ?>
1097
				<?php endforeach; ?>
1098 de792e62 jim-p
				</tbody>
1099
				<tfoot>
1100
				</tfoot>
1101 518030b3 Scott Ullrich
				</table>
1102
				<a onclick="javascript:addRowTo('maintable', 'formfldalias'); return false;" href="#">
1103 40ad67e0 Rafael Lucas
					<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="<?=gettext("add another entry");?>" />
1104 518030b3 Scott Ullrich
				</a>
1105
				<script type="text/javascript">
1106 678dfd0f Erik Fonnesbeck
					field_counter_js = 3;
1107 518030b3 Scott Ullrich
					rows = 1;
1108
					totalrows = <?php echo $counter; ?>;
1109
					loaded = <?php echo $counter; ?>;
1110
				</script>
1111 b1d132f5 Scott Ullrich
				</div>
1112 518030b3 Scott Ullrich
1113
				</td>
1114
			</tr>
1115 cba980f6 jim-p
			<?php endif; ?>
1116 518030b3 Scott Ullrich
			<tr>
1117 de792e62 jim-p
			<td width="22%" valign="top">&nbsp;</td>
1118
			<td width="78%">
1119 cba980f6 jim-p
				<?php if ($act == "newpool"): ?>
1120
				<input type="hidden" name="act" value="newpool">
1121
				<?php endif; ?>
1122
				<?php if (is_numeric($pool)): ?>
1123
				<input type="hidden" name="pool" value="<?php echo $pool; ?>">
1124
				<?php endif; ?>
1125 dd5bf424 Scott Ullrich
				<input name="if" type="hidden" value="<?=htmlspecialchars($if);?>">
1126 40ad67e0 Rafael Lucas
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)">
1127 de792e62 jim-p
			</td>
1128
			</tr>
1129
			<tr>
1130
			<td width="22%" valign="top">&nbsp;</td>
1131 16457bdd Renato Botelho
			<td width="78%"> <p><span class="vexpl"><span class="red"><strong><?=gettext("Note:");?><br>
1132 6c235a30 Carlos Eduardo Ramos
				</strong></span><?=gettext("The DNS servers entered in"); ?> <a href="system.php"><?=gettext("System: " .
1133
				"General setup"); ?></a> <?=gettext("(or the"); ?> <a href="services_dnsmasq.php"><?=gettext("DNS " .
1134
				"forwarder"); ?></a>, <?=gettext("if enabled)"); ?> </span><span class="vexpl"><?=gettext("will " .
1135 16457bdd Renato Botelho
				"be assigned to clients by the DHCP server."); ?><br>
1136 de792e62 jim-p
				<br>
1137 44d01644 Carlos Eduardo Ramos
				<?=gettext("The DHCP lease table can be viewed on the"); ?> <a href="status_dhcp_leases.php"><?=gettext("Status: " .
1138 16457bdd Renato Botelho
				"DHCP leases"); ?></a> <?=gettext("page."); ?><br>
1139 de792e62 jim-p
				</span></p>
1140
			</td>
1141 518030b3 Scott Ullrich
			</tr>
1142
		</table>
1143 0d1b26ee jim-p
		<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
1144 282f7bfc Scott Ullrich
		<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
1145 f2ea45ef jim-p
		<tr>
1146
			<td colspan="5" valign="top" class="listtopic"><?=gettext("DHCP Static Mappings for this interface.");?></td>
1147
			<td>&nbsp;</td>
1148
		</tr>
1149 518030b3 Scott Ullrich
		<tr>
1150 25c1ebd5 N0YB
			<td width="7%" class="listhdrr"><?=gettext("Static ARP");?></td>
1151
			<td width="18%" class="listhdrr"><?=gettext("MAC address");?></td>
1152 40ad67e0 Rafael Lucas
			<td width="15%" class="listhdrr"><?=gettext("IP address");?></td>
1153
			<td width="20%" class="listhdrr"><?=gettext("Hostname");?></td>
1154
			<td width="30%" class="listhdr"><?=gettext("Description");?></td>
1155 518030b3 Scott Ullrich
			<td width="10%" class="list">
1156
			<table border="0" cellspacing="0" cellpadding="1">
1157 de792e62 jim-p
			<tr>
1158 d415d821 Seth Mos
			<td valign="middle" width="17"></td>
1159 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>
1160 518030b3 Scott Ullrich
			</tr>
1161
			</table>
1162
			</td>
1163 2af4c579 Scott Ullrich
		</tr>
1164 de792e62 jim-p
			<?php if(is_array($a_maps)): ?>
1165
			<?php $i = 0; foreach ($a_maps as $mapent): ?>
1166
			<?php if($mapent['mac'] <> "" or $mapent['ipaddr'] <> ""): ?>
1167
		<tr>
1168 25c1ebd5 N0YB
		<td align="center" class="listlr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&id=<?=$i;?>';">
1169
			<?php if (isset($mapent['arp_table_static_entry'])): ?>
1170
				<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_alert.gif" alt="ARP Table Static Entry" width="17" height="17" border="0">
1171
			<?php endif; ?>
1172
		</td>
1173 dd5bf424 Scott Ullrich
		<td class="listlr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&id=<?=$i;?>';">
1174 de792e62 jim-p
			<?=htmlspecialchars($mapent['mac']);?>
1175
		</td>
1176 dd5bf424 Scott Ullrich
		<td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&id=<?=$i;?>';">
1177 de792e62 jim-p
			<?=htmlspecialchars($mapent['ipaddr']);?>&nbsp;
1178
		</td>
1179 dd5bf424 Scott Ullrich
		<td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&id=<?=$i;?>';">
1180 de792e62 jim-p
			<?=htmlspecialchars($mapent['hostname']);?>&nbsp;
1181
		</td>
1182 dd5bf424 Scott Ullrich
		<td class="listbg" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&id=<?=$i;?>';">
1183 de792e62 jim-p
			<?=htmlspecialchars($mapent['descr']);?>&nbsp;
1184
		</td>
1185
		<td valign="middle" nowrap class="list">
1186
			<table border="0" cellspacing="0" cellpadding="1">
1187
			<tr>
1188 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>
1189
			<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>
1190 de792e62 jim-p
			</tr>
1191
			</table>
1192
		</td>
1193
		</tr>
1194 6f5b2c3e Scott Ullrich
		<?php endif; ?>
1195 75a70796 Bill Marquette
		<?php $i++; endforeach; ?>
1196 6f5b2c3e Scott Ullrich
		<?php endif; ?>
1197 de792e62 jim-p
		<tr>
1198 25c1ebd5 N0YB
		<td class="list" colspan="5"></td>
1199 de792e62 jim-p
		<td class="list">
1200
			<table border="0" cellspacing="0" cellpadding="1">
1201
			<tr>
1202 d415d821 Seth Mos
			<td valign="middle" width="17"></td>
1203 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>
1204 de792e62 jim-p
			</tr>
1205
			</table>
1206
		</td>
1207
		</tr>
1208
		</table>
1209 0d1b26ee jim-p
		<?php endif; ?>
1210 d732f186 Bill Marquette
	</div>
1211 de792e62 jim-p
</td>
1212
</tr>
1213 5b237745 Scott Ullrich
</table>
1214
</form>
1215
<script language="JavaScript">
1216
<!--
1217
enable_change(false);
1218
//-->
1219
</script>
1220 b7597d4e Bill Marquette
<?php include("fend.inc"); ?>
1221 5b237745 Scott Ullrich
</body>
1222
</html>