Project

General

Profile

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