Project

General

Profile

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