Project

General

Profile

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