Project

General

Profile

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