Project

General

Profile

Download (58.1 KB) Statistics
| Branch: | Tag: | Revision:
1 e9f147c8 Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	services_dhcp.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6 e9f147c8 Scott Ullrich
7 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8 29aef6c4 Jim Thompson
	Copyright (C) 2013-2014 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 11bc553c Scott Ullrich
}
111
112 934240ef Ermal Luçi
if (!$_GET['if'])
113 180db186 Colin Fleming
	$savemsg = gettext("The DHCP Server can only be enabled on interfaces configured with static IP addresses") . ".<br/><br/>" . gettext("Only interfaces configured with a static IP will be shown") . ".";
114 5b237745 Scott Ullrich
115 934240ef Ermal Luçi
$iflist = get_configured_interface_with_descr();
116 5b237745 Scott Ullrich
117 1c451b06 Scott Ullrich
/* set the starting interface */
118 f19651d1 Ermal
if (!$if || !isset($iflist[$if])) {
119 01fdb2d3 Erik Fonnesbeck
	foreach ($iflist as $ifent => $ifname) {
120 de792e62 jim-p
		$oc = $config['interfaces'][$ifent];
121 e5770bc2 Bill Marquette
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) ||
122
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr']))))
123 01fdb2d3 Erik Fonnesbeck
			continue;
124
		$if = $ifent;
125
		break;
126
	}
127 f19651d1 Ermal
}
128 0a2c6a5b Scott Ullrich
129 cba980f6 jim-p
$act = $_GET['act'];
130
if (!empty($_POST['act']))
131
	$act = $_POST['act'];
132
133 cc6052f0 Renato Botelho
$a_pools = array();
134 cba980f6 jim-p
135 89019922 Ermal Luçi
if (is_array($config['dhcpd'][$if])){
136 cba980f6 jim-p
	$pool = $_GET['pool'];
137
	if (is_numeric($_POST['pool']))
138
		$pool = $_POST['pool'];
139
140
	// If we have a pool but no interface name, that's not valid. Redirect away.
141
	if (is_numeric($pool) && empty($if)) {
142
		header("Location: services_dhcp.php");
143
		exit;
144 de792e62 jim-p
	}
145 cba980f6 jim-p
146
	if (!is_array($config['dhcpd'][$if]['pool']))
147
		$config['dhcpd'][$if]['pool'] = array();
148
	$a_pools = &$config['dhcpd'][$if]['pool'];
149
150
	if (is_numeric($pool) && $a_pools[$pool])
151
		$dhcpdconf = &$a_pools[$pool];
152
	elseif ($act == "newpool")
153
		$dhcpdconf = array();
154
	else
155
		$dhcpdconf = &$config['dhcpd'][$if];
156
}
157
if (is_array($dhcpdconf)) {
158
	// Global Options
159
	if (!is_numeric($pool) && !($act == "newpool")) {
160
		$pconfig['enable'] = isset($dhcpdconf['enable']);
161
		$pconfig['staticarp'] = isset($dhcpdconf['staticarp']);
162
		// No reason to specify this per-pool, per the dhcpd.conf man page it needs to be in every
163
		//   pool and should be specified in every pool both nodes share, so we'll treat it as global
164
		$pconfig['failover_peerip'] = $dhcpdconf['failover_peerip'];
165 466aae83 Phil Davis
166
		// dhcpleaseinlocaltime is global to all interfaces. So if it is selected on any interface,
167
		// then show it true/checked.
168
		foreach ($config['dhcpd'] as $dhcpdifitem) {
169
			$dhcpleaseinlocaltime = $dhcpdifitem['dhcpleaseinlocaltime'];
170
			if ($dhcpleaseinlocaltime)
171
				break;
172
		}
173
174
		$pconfig['dhcpleaseinlocaltime'] = $dhcpleaseinlocaltime;
175
176 cba980f6 jim-p
		if (!is_array($dhcpdconf['staticmap']))
177
			$dhcpdconf['staticmap'] = array();
178
		$a_maps = &$dhcpdconf['staticmap'];
179 ee1fb205 jim-p
	} else {
180
		// Options that exist only in pools
181
		$pconfig['descr'] = $dhcpdconf['descr'];
182 cba980f6 jim-p
	}
183
184
	// Options that can be global or per-pool.
185
	if (is_array($dhcpdconf['range'])) {
186
		$pconfig['range_from'] = $dhcpdconf['range']['from'];
187
		$pconfig['range_to'] = $dhcpdconf['range']['to'];
188
	}
189
	$pconfig['deftime'] = $dhcpdconf['defaultleasetime'];
190
	$pconfig['maxtime'] = $dhcpdconf['maxleasetime'];
191
	$pconfig['gateway'] = $dhcpdconf['gateway'];
192
	$pconfig['domain'] = $dhcpdconf['domain'];
193
	$pconfig['domainsearchlist'] = $dhcpdconf['domainsearchlist'];
194
	list($pconfig['wins1'],$pconfig['wins2']) = $dhcpdconf['winsserver'];
195 3b5707db Phil Davis
	list($pconfig['dns1'],$pconfig['dns2'],$pconfig['dns3'],$pconfig['dns4']) = $dhcpdconf['dnsserver'];
196 cba980f6 jim-p
	$pconfig['denyunknown'] = isset($dhcpdconf['denyunknown']);
197
	$pconfig['ddnsdomain'] = $dhcpdconf['ddnsdomain'];
198 87019fc4 Andres Petralli
	$pconfig['ddnsdomainprimary'] = $dhcpdconf['ddnsdomainprimary'];
199
	$pconfig['ddnsdomainkeyname'] = $dhcpdconf['ddnsdomainkeyname'];
200
	$pconfig['ddnsdomainkey'] = $dhcpdconf['ddnsdomainkey'];
201 cba980f6 jim-p
	$pconfig['ddnsupdate'] = isset($dhcpdconf['ddnsupdate']);
202
	$pconfig['mac_allow'] = $dhcpdconf['mac_allow'];
203
	$pconfig['mac_deny'] = $dhcpdconf['mac_deny'];
204
	list($pconfig['ntp1'],$pconfig['ntp2']) = $dhcpdconf['ntpserver'];
205
	$pconfig['tftp'] = $dhcpdconf['tftp'];
206
	$pconfig['ldap'] = $dhcpdconf['ldap'];
207
	$pconfig['netboot'] = isset($dhcpdconf['netboot']);
208
	$pconfig['nextserver'] = $dhcpdconf['nextserver'];
209
	$pconfig['filename'] = $dhcpdconf['filename'];
210 7023c602 Charlie Root
	$pconfig['filename32'] = $dhcpdconf['filename32'];
211
	$pconfig['filename64'] = $dhcpdconf['filename64'];
212 cba980f6 jim-p
	$pconfig['rootpath'] = $dhcpdconf['rootpath'];
213
	$pconfig['netmask'] = $dhcpdconf['netmask'];
214
	$pconfig['numberoptions'] = $dhcpdconf['numberoptions'];
215 89019922 Ermal Luçi
}
216 31c59d0d Scott Ullrich
217 51cd7a1e Evgeny Yurchenko
$ifcfgip = $config['interfaces'][$if]['ipaddr'];
218
$ifcfgsn = $config['interfaces'][$if]['subnet'];
219 5b237745 Scott Ullrich
220 1f1a08c8 jim-p
function validate_partial_mac_list($maclist) {
221
	$macs = explode(',', $maclist);
222
223
	// Loop through and look for invalid MACs.
224
	foreach ($macs as $mac)
225
		if (!is_macaddr($mac, true))
226
			return false;
227
	return true;
228
}
229
230 565488c9 Renato Botelho
if (isset($_POST['submit'])) {
231 5b237745 Scott Ullrich
232
	unset($input_errors);
233 b7597d4e Bill Marquette
234 5b237745 Scott Ullrich
	$pconfig = $_POST;
235
236 6d1af0e9 jim-p
	$numberoptions = array();
237
	for($x=0; $x<99; $x++) {
238
		if(isset($_POST["number{$x}"]) && ctype_digit($_POST["number{$x}"])) {
239
			$numbervalue = array();
240
			$numbervalue['number'] = htmlspecialchars($_POST["number{$x}"]);
241 678dfd0f Erik Fonnesbeck
			$numbervalue['type'] = htmlspecialchars($_POST["itemtype{$x}"]);
242
			$numbervalue['value'] = str_replace('&quot;', '"', htmlspecialchars($_POST["value{$x}"]));
243 6d1af0e9 jim-p
			$numberoptions['item'][] = $numbervalue;
244
		}
245
	}
246 466aae83 Phil Davis
	// Reload the new pconfig variable that the form uses.
247 6d1af0e9 jim-p
	$pconfig['numberoptions'] = $numberoptions;
248
249 5b237745 Scott Ullrich
	/* input validation */
250 cba980f6 jim-p
	if ($_POST['enable'] || is_numeric($pool) || $act == "newpool") {
251 5b237745 Scott Ullrich
		$reqdfields = explode(" ", "range_from range_to");
252 40ad67e0 Rafael Lucas
		$reqdfieldsn = array(gettext("Range begin"),gettext("Range end"));
253 e9f147c8 Scott Ullrich
254 507628d5 Renato Botelho
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
255 de792e62 jim-p
256 e5770bc2 Bill Marquette
		if (($_POST['range_from'] && !is_ipaddrv4($_POST['range_from'])))
257 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid range must be specified.");
258 e5770bc2 Bill Marquette
		if (($_POST['range_to'] && !is_ipaddrv4($_POST['range_to'])))
259 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid range must be specified.");
260 1bd021e3 timdufrane
		if (($_POST['gateway'] && $_POST['gateway'] != "none" && !is_ipaddrv4($_POST['gateway'])))
261 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid IP address must be specified for the gateway.");
262 e5770bc2 Bill Marquette
		if (($_POST['wins1'] && !is_ipaddrv4($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddrv4($_POST['wins2'])))
263 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary WINS servers.");
264 9bc59815 Evgeny Yurchenko
		$parent_ip = get_interface_ip($_POST['if']);
265 1bd021e3 timdufrane
		if (is_ipaddrv4($parent_ip) && $_POST['gateway'] && $_POST['gateway'] != "none") {
266 9bc59815 Evgeny Yurchenko
			$parent_sn = get_interface_subnet($_POST['if']);
267 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']))
268 9bc59815 Evgeny Yurchenko
				$input_errors[] = sprintf(gettext("The gateway address %s does not lie within the chosen interface's subnet."), $_POST['gateway']);
269 45d1024d Scott Ullrich
		}
270 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'])))
271
			$input_errors[] = gettext("A valid IP address must be specified for each of the DNS servers.");
272 26e3ca70 sullrich
273 de792e62 jim-p
		if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60)))
274 e680b2f9 Renato Botelho
				$input_errors[] = gettext("The default lease time must be at least 60 seconds.");
275
276
		if (isset($config['captiveportal']) && is_array($config['captiveportal'])) {
277
			$deftime = 7200; // Default value if it's empty
278
			if (is_numeric($_POST['deftime']))
279
				$deftime = $_POST['deftime'];
280
281
			foreach ($config['captiveportal'] as $cpZone => $cpdata) {
282
				if (!isset($cpdata['enable']))
283
					continue;
284
				if (!isset($cpdata['timeout']) || !is_numeric($cpdata['timeout']))
285
					continue;
286
				$cp_ifs = explode(',', $cpdata['interface']);
287
				if (!in_array($if, $cp_ifs))
288
					continue;
289
				if ($cpdata['timeout'] > $deftime)
290
					$input_errors[] = sprintf(gettext(
291
						"The Captive Portal zone '%s' has Hard Timeout parameter set to a value bigger than Default lease time (%s)."), $cpZone, $deftime);
292
			}
293
		}
294
295 de792e62 jim-p
		if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime'])))
296 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("The maximum lease time must be at least 60 seconds and higher than the default lease time.");
297 de792e62 jim-p
		if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain'])))
298 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid domain name must be specified for the dynamic DNS registration.");
299 87019fc4 Andres Petralli
		if (($_POST['ddnsdomain'] && !is_ipaddrv4($_POST['ddnsdomainprimary'])))
300
			$input_errors[] = gettext("A valid primary domain name server IP address must be specified for the dynamic domain name.");
301
		if (($_POST['ddnsdomainkey'] && !$_POST['ddnsdomainkeyname']) ||
302
			($_POST['ddnsdomainkeyname'] && !$_POST['ddnsdomainkey']))
303
			$input_errors[] = gettext("You must specify both a valid domain key and key name.");
304 42a3cbab Pierre POMES
		if ($_POST['domainsearchlist']) {
305
			$domain_array=preg_split("/[ ;]+/",$_POST['domainsearchlist']);
306
			foreach ($domain_array as $curdomain) {
307
				if (!is_domain($curdomain)) {
308
					$input_errors[] = gettext("A valid domain search list must be specified.");
309
					break;
310
				}
311
			}
312
		}
313 1f1a08c8 jim-p
314
		// Validate MACs
315
		if (!empty($_POST['mac_allow']) && !validate_partial_mac_list($_POST['mac_allow']))
316
			$input_errors[] = gettext("If you specify a mac allow list, it must contain only valid partial MAC addresses.");
317
		if (!empty($_POST['mac_deny']) && !validate_partial_mac_list($_POST['mac_deny']))
318
			$input_errors[] = gettext("If you specify a mac deny list, it must contain only valid partial MAC addresses.");
319
320 e5770bc2 Bill Marquette
		if (($_POST['ntp1'] && !is_ipaddrv4($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddrv4($_POST['ntp2'])))
321 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary NTP servers.");
322 26e3ca70 sullrich
		if (($_POST['domain'] && !is_domain($_POST['domain'])))
323 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid domain name must be specified for the DNS domain.");
324 e5770bc2 Bill Marquette
		if ($_POST['tftp'] && !is_ipaddrv4($_POST['tftp']) && !is_domain($_POST['tftp']) && !is_URL($_POST['tftp']))
325 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid IP address or hostname must be specified for the TFTP server.");
326 e5770bc2 Bill Marquette
		if (($_POST['nextserver'] && !is_ipaddrv4($_POST['nextserver'])))
327 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("A valid IP address must be specified for the network boot server.");
328 2c75b451 sullrich
329 26e3ca70 sullrich
		if(gen_subnet($ifcfgip, $ifcfgsn) == $_POST['range_from'])
330 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("You cannot use the network address in the starting subnet range.");
331 26e3ca70 sullrich
		if(gen_subnet_max($ifcfgip, $ifcfgsn) == $_POST['range_to'])
332 40ad67e0 Rafael Lucas
			$input_errors[] = gettext("You cannot use the broadcast address in the ending subnet range.");
333 e9f147c8 Scott Ullrich
334 2c75b451 sullrich
		// Disallow a range that includes the virtualip
335 7dfa60fa Ermal Lu?i
		if (is_array($config['virtualip']['vip'])) {
336
			foreach($config['virtualip']['vip'] as $vip) {
337 de792e62 jim-p
				if($vip['interface'] == $if)
338 54404519 Renato Botelho
					if($vip['subnet'] && is_inrange_v4($vip['subnet'], $_POST['range_from'], $_POST['range_to']))
339 3a3fb8ea Erik Fonnesbeck
						$input_errors[] = sprintf(gettext("The subnet range cannot overlap with virtual IP address %s."),$vip['subnet']);
340 7dfa60fa Ermal Lu?i
			}
341 2c75b451 sullrich
		}
342
343 073a2697 jim-p
		$noip = false;
344 2c7497cb Scott Ullrich
		if(is_array($a_maps))
345
			foreach ($a_maps as $map)
346
				if (empty($map['ipaddr']))
347
					$noip = true;
348 073a2697 jim-p
		if ($_POST['staticarp'] && $noip)
349
			$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.";
350
351 678dfd0f Erik Fonnesbeck
		if(is_array($pconfig['numberoptions']['item'])) {
352
			foreach ($pconfig['numberoptions']['item'] as $numberoption) {
353
				if ( $numberoption['type'] == 'text' && strstr($numberoption['value'], '"') )
354
					$input_errors[] = gettext("Text type cannot include quotation marks.");
355 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']) )
356 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");
357 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'boolean' && $numberoption['value'] != 'true' && $numberoption['value'] != 'false' && $numberoption['value'] != 'on' && $numberoption['value'] != 'off' )
358 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Boolean type must be true, false, on, or off.");
359 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'unsigned integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 255) )
360 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Unsigned 8-bit integer type must be a number in the range 0 to 255.");
361 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'unsigned integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 65535) )
362 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Unsigned 16-bit integer type must be a number in the range 0 to 65535.");
363 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'unsigned integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 4294967295) )
364 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Unsigned 32-bit integer type must be a number in the range 0 to 4294967295.");
365 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'signed integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -128 || $numberoption['value'] > 127) )
366 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Signed 8-bit integer type must be a number in the range -128 to 127.");
367 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'signed integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -32768 || $numberoption['value'] > 32767) )
368 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Signed 16-bit integer type must be a number in the range -32768 to 32767.");
369 1452fa57 Erik Fonnesbeck
				else if ( $numberoption['type'] == 'signed integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -2147483648 || $numberoption['value'] > 2147483647) )
370 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("Signed 32-bit integer type must be a number in the range -2147483648 to 2147483647.");
371 e5770bc2 Bill Marquette
				else if ( $numberoption['type'] == 'ip-address' && !is_ipaddrv4($numberoption['value']) && !is_hostname($numberoption['value']) )
372 678dfd0f Erik Fonnesbeck
					$input_errors[] = gettext("IP address or host type must be an IP address or host name.");
373
			}
374
		}
375
376 5b237745 Scott Ullrich
		if (!$input_errors) {
377
			/* make sure the range lies within the current subnet */
378 96033063 Erik Fonnesbeck
			$subnet_start = ip2ulong(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
379
			$subnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
380 e9f147c8 Scott Ullrich
381 96033063 Erik Fonnesbeck
			if ((ip2ulong($_POST['range_from']) < $subnet_start) || (ip2ulong($_POST['range_from']) > $subnet_end) ||
382
			    (ip2ulong($_POST['range_to']) < $subnet_start) || (ip2ulong($_POST['range_to']) > $subnet_end)) {
383 40ad67e0 Rafael Lucas
				$input_errors[] = gettext("The specified range lies outside of the current subnet.");
384 5b237745 Scott Ullrich
			}
385 e9f147c8 Scott Ullrich
386 96033063 Erik Fonnesbeck
			if (ip2ulong($_POST['range_from']) > ip2ulong($_POST['range_to']))
387 40ad67e0 Rafael Lucas
				$input_errors[] = gettext("The range is invalid (first element higher than second element).");
388 e9f147c8 Scott Ullrich
389 f657f5e1 Renato Botelho
			if (is_numeric($pool) || ($act == "newpool")) {
390
				$rfrom = $config['dhcpd'][$if]['range']['from'];
391
				$rto = $config['dhcpd'][$if]['range']['to'];
392
393
				if (is_inrange_v4($_POST['range_from'], $rfrom, $rto) || is_inrange_v4($_POST['range_to'], $rfrom, $rto))
394
					$input_errors[] = gettext("The specified range must not be within the DHCP range for this interface.");
395
			}
396
397
			foreach ($a_pools as $id => $p) {
398
				if (is_numeric($pool) && ($id == $pool))
399
					continue;
400
401
				if (is_inrange_v4($_POST['range_from'], $p['range']['from'], $p['range']['to']) ||
402
				    is_inrange_v4($_POST['range_to'], $p['range']['from'], $p['range']['to'])) {
403
					$input_errors[] = gettext("The specified range must not be within the range configured on a DHCP pool for this interface.");
404
					break;
405
				}
406
			}
407 cba980f6 jim-p
408 5b237745 Scott Ullrich
			/* make sure that the DHCP Relay isn't enabled on this interface */
409 0a35ca7c jim-p
			if (isset($config['dhcrelay']['enable']) && (stristr($config['dhcrelay']['interface'], $if) !== false))
410 3a3fb8ea Erik Fonnesbeck
				$input_errors[] = sprintf(gettext("You must disable the DHCP relay on the %s interface before enabling the DHCP server."),$iflist[$if]);
411 630d7025 jim-p
412
			$dynsubnet_start = ip2ulong($_POST['range_from']);
413
			$dynsubnet_end = ip2ulong($_POST['range_to']);
414 f02f0675 Erik Fonnesbeck
			if (is_array($a_maps)) {
415
				foreach ($a_maps as $map) {
416
					if (empty($map['ipaddr']))
417
						continue;
418
					if ((ip2ulong($map['ipaddr']) > $dynsubnet_start) &&
419
						(ip2ulong($map['ipaddr']) < $dynsubnet_end)) {
420
						$input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings."));
421
						break;
422
					}
423 630d7025 jim-p
				}
424
			}
425 5b237745 Scott Ullrich
		}
426
	}
427
428
	if (!$input_errors) {
429 cba980f6 jim-p
		if (!is_numeric($pool)) {
430
			if ($act == "newpool") {
431
				$dhcpdconf = array();
432
			} else {
433
				if (!is_array($config['dhcpd'][$if]))
434
					$config['dhcpd'][$if] = array();
435
				$dhcpdconf = $config['dhcpd'][$if];
436
			}
437
		} else {
438
			if (is_array($a_pools[$pool])) {
439
				$dhcpdconf = $a_pools[$pool];
440
			} else {
441
				// Someone specified a pool but it doesn't exist. Punt.
442
				header("Location: services_dhcp.php");
443
				exit;
444
			}
445
		}
446
		if (!is_array($dhcpdconf['range']))
447
			$dhcpdconf['range'] = array();
448
449 6c124212 Phil Davis
		$dhcpd_enable_changed = false;
450
451 cba980f6 jim-p
		// Global Options
452
		if (!is_numeric($pool) && !($act == "newpool")) {
453 6c124212 Phil Davis
			$old_dhcpd_enable = isset($dhcpdconf['enable']);
454
			$new_dhcpd_enable = ($_POST['enable']) ? true : false;
455
			if ($old_dhcpd_enable != $new_dhcpd_enable) {
456
				/* DHCP has been enabled or disabled. The pf ruleset will need to be rebuilt to allow or disallow DHCP. */
457
				$dhcpd_enable_changed = true;
458
			}
459
			$dhcpdconf['enable'] = $new_dhcpd_enable;
460 cba980f6 jim-p
			$dhcpdconf['staticarp'] = ($_POST['staticarp']) ? true : false;
461
			$previous = $dhcpdconf['failover_peerip'];
462
			if($previous <> $_POST['failover_peerip'])
463
				mwexec("/bin/rm -rf /var/dhcpd/var/db/*");
464
			$dhcpdconf['failover_peerip'] = $_POST['failover_peerip'];
465 466aae83 Phil Davis
			// dhcpleaseinlocaltime is global to all interfaces. So update the setting on all interfaces.
466
			foreach ($config['dhcpd'] as &$dhcpdifitem) {
467
				$dhcpdifitem['dhcpleaseinlocaltime'] = $_POST['dhcpleaseinlocaltime'];
468
			}
469 ee1fb205 jim-p
		} else {
470
			// Options that exist only in pools
471
			$dhcpdconf['descr'] = $_POST['descr'];
472 cba980f6 jim-p
		}
473
474
		// Options that can be global or per-pool.
475
		$dhcpdconf['range']['from'] = $_POST['range_from'];
476
		$dhcpdconf['range']['to'] = $_POST['range_to'];
477
		$dhcpdconf['defaultleasetime'] = $_POST['deftime'];
478
		$dhcpdconf['maxleasetime'] = $_POST['maxtime'];
479
		$dhcpdconf['netmask'] = $_POST['netmask'];
480
481
		unset($dhcpdconf['winsserver']);
482 5b237745 Scott Ullrich
		if ($_POST['wins1'])
483 cba980f6 jim-p
			$dhcpdconf['winsserver'][] = $_POST['wins1'];
484 5b237745 Scott Ullrich
		if ($_POST['wins2'])
485 cba980f6 jim-p
			$dhcpdconf['winsserver'][] = $_POST['wins2'];
486 4cab31d0 Scott Ullrich
487 cba980f6 jim-p
		unset($dhcpdconf['dnsserver']);
488 e9f147c8 Scott Ullrich
		if ($_POST['dns1'])
489 cba980f6 jim-p
			$dhcpdconf['dnsserver'][] = $_POST['dns1'];
490 e9f147c8 Scott Ullrich
		if ($_POST['dns2'])
491 cba980f6 jim-p
			$dhcpdconf['dnsserver'][] = $_POST['dns2'];
492 3b5707db Phil Davis
		if ($_POST['dns3'])
493
			$dhcpdconf['dnsserver'][] = $_POST['dns3'];
494
		if ($_POST['dns4'])
495
			$dhcpdconf['dnsserver'][] = $_POST['dns4'];
496 cba980f6 jim-p
497
		$dhcpdconf['gateway'] = $_POST['gateway'];
498
		$dhcpdconf['domain'] = $_POST['domain'];
499
		$dhcpdconf['domainsearchlist'] = $_POST['domainsearchlist'];
500
		$dhcpdconf['denyunknown'] = ($_POST['denyunknown']) ? true : false;
501
		$dhcpdconf['ddnsdomain'] = $_POST['ddnsdomain'];
502 87019fc4 Andres Petralli
		$dhcpdconf['ddnsdomainprimary'] = $_POST['ddnsdomainprimary'];
503
		$dhcpdconf['ddnsdomainkeyname'] = $_POST['ddnsdomainkeyname'];
504
		$dhcpdconf['ddnsdomainkey'] = $_POST['ddnsdomainkey'];
505 cba980f6 jim-p
		$dhcpdconf['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
506
		$dhcpdconf['mac_allow'] = $_POST['mac_allow'];
507
		$dhcpdconf['mac_deny'] = $_POST['mac_deny'];
508
509
		unset($dhcpdconf['ntpserver']);
510 ad171999 Seth Mos
		if ($_POST['ntp1'])
511 cba980f6 jim-p
			$dhcpdconf['ntpserver'][] = $_POST['ntp1'];
512 ad171999 Seth Mos
		if ($_POST['ntp2'])
513 cba980f6 jim-p
			$dhcpdconf['ntpserver'][] = $_POST['ntp2'];
514 ad171999 Seth Mos
515 cba980f6 jim-p
		$dhcpdconf['tftp'] = $_POST['tftp'];
516
		$dhcpdconf['ldap'] = $_POST['ldap'];
517
		$dhcpdconf['netboot'] = ($_POST['netboot']) ? true : false;
518
		$dhcpdconf['nextserver'] = $_POST['nextserver'];
519
		$dhcpdconf['filename'] = $_POST['filename'];
520 7023c602 Charlie Root
		$dhcpdconf['filename32'] = $_POST['filename32'];
521
		$dhcpdconf['filename64'] = $_POST['filename64'];
522 cba980f6 jim-p
		$dhcpdconf['rootpath'] = $_POST['rootpath'];
523 9c748b70 Scott Ullrich
524 d72b4114 Scott Ullrich
		// Handle the custom options rowhelper
525 cba980f6 jim-p
		if(isset($dhcpdconf['numberoptions']['item']))
526
			unset($dhcpdconf['numberoptions']['item']);
527 6d1af0e9 jim-p
528 cba980f6 jim-p
		$dhcpdconf['numberoptions'] = $numberoptions;
529
530
		if (is_numeric($pool) && is_array($a_pools[$pool])) {
531
			$a_pools[$pool] = $dhcpdconf;
532
		} elseif ($act == "newpool") {
533
			$a_pools[] = $dhcpdconf;
534
		} else {
535
			$config['dhcpd'][$if] = $dhcpdconf;
536
		}
537 518030b3 Scott Ullrich
538 5b237745 Scott Ullrich
		write_config();
539 565488c9 Renato Botelho
	}
540
}
541 80933129 Bill Marquette
542 565488c9 Renato Botelho
if (isset($_POST['submit']) || isset($_POST['apply'])) {
543
	$retval = 0;
544
	$retvaldhcp = 0;
545
	$retvaldns = 0;
546
	/* Stop DHCP so we can cleanup leases */
547
	killbyname("dhcpd");
548
	dhcp_clean_leases();
549
	/* dnsmasq_configure calls dhcpd_configure */
550
	/* no need to restart dhcpd twice */
551
	if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic']))	{
552
		$retvaldns = services_dnsmasq_configure();
553
		if ($retvaldns == 0) {
554
			clear_subsystem_dirty('hosts');
555
			clear_subsystem_dirty('staticmaps');
556 de792e62 jim-p
		}
557 565488c9 Renato Botelho
	} else if (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic'])) {
558
		$retvaldns = services_unbound_configure();
559
		if ($retvaldns == 0)
560
			clear_subsystem_dirty('unbound');
561
	} else {
562
		$retvaldhcp = services_dhcpd_configure();
563
		if ($retvaldhcp == 0)
564
			clear_subsystem_dirty('staticmaps');
565 5b237745 Scott Ullrich
	}
566 565488c9 Renato Botelho
	if ($dhcpd_enable_changed)
567
		$retvalfc = filter_configure();
568
569
	if($retvaldhcp == 1 || $retvaldns == 1 || $retvalfc == 1)
570
		$retval = 1;
571
	$savemsg = get_std_save_message($retval);
572 5b237745 Scott Ullrich
}
573
574 cba980f6 jim-p
if ($act == "delpool") {
575
	if ($a_pools[$_GET['id']]) {
576
		unset($a_pools[$_GET['id']]);
577
		write_config();
578
		header("Location: services_dhcp.php?if={$if}");
579
		exit;
580
	}
581
}
582
583
if ($act == "del") {
584 5b237745 Scott Ullrich
	if ($a_maps[$_GET['id']]) {
585
		unset($a_maps[$_GET['id']]);
586
		write_config();
587 6a01ea44 Bill Marquette
		if(isset($config['dhcpd'][$if]['enable'])) {
588 a368a026 Ermal Lu?i
			mark_subsystem_dirty('staticmaps');
589 ea1aca13 Renato Botelho
			if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic']))
590 a368a026 Ermal Lu?i
				mark_subsystem_dirty('hosts');
591 6a01ea44 Bill Marquette
		}
592 5b237745 Scott Ullrich
		header("Location: services_dhcp.php?if={$if}");
593
		exit;
594
	}
595
}
596 4df96eff Scott Ullrich
597 180db186 Colin Fleming
$closehead = false;
598 40ad67e0 Rafael Lucas
$pgtitle = array(gettext("Services"),gettext("DHCP server"));
599 b32dd0a6 jim-p
$shortcut_section = "dhcp";
600 5224b8e7 jim-p
601 4df96eff Scott Ullrich
include("head.inc");
602
603 5b237745 Scott Ullrich
?>
604 4df96eff Scott Ullrich
605 518030b3 Scott Ullrich
<script type="text/javascript" src="/javascript/row_helper.js">
606
</script>
607 4e9cd828 Seth Mos
608 518030b3 Scott Ullrich
<script type="text/javascript">
609 180db186 Colin Fleming
//<![CDATA[
610 678dfd0f Erik Fonnesbeck
	function itemtype_field(fieldname, fieldsize, n) {
611
		return '<select name="' + fieldname + n + '" class="formselect" id="' + fieldname + n + '"><?php
612 1452fa57 Erik Fonnesbeck
			$customitemtypes = array('text' => gettext('Text'), 'string' => gettext('String'), 'boolean' => gettext('Boolean'),
613
				'unsigned integer 8' => gettext('Unsigned 8-bit integer'), 'unsigned integer 16' => gettext('Unsigned 16-bit integer'), 'unsigned integer 32' => gettext('Unsigned 32-bit integer'),
614
				'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'));
615 678dfd0f Erik Fonnesbeck
			foreach ($customitemtypes as $typename => $typedescr) {
616 180db186 Colin Fleming
				echo "<option value=\"{$typename}\">{$typedescr}<\/option>";
617 678dfd0f Erik Fonnesbeck
			}
618 180db186 Colin Fleming
		?><\/select>';
619 678dfd0f Erik Fonnesbeck
	}
620
621 518030b3 Scott Ullrich
	rowname[0] = "number";
622
	rowtype[0] = "textbox";
623 4e10cf0a Scott Ullrich
	rowsize[0] = "10";
624 678dfd0f Erik Fonnesbeck
	rowname[1] = "itemtype";
625
	rowtype[1] = itemtype_field;
626
	rowname[2] = "value";
627
	rowtype[2] = "textbox";
628
	rowsize[2] = "40";
629 180db186 Colin Fleming
//]]>
630 518030b3 Scott Ullrich
</script>
631 4e9cd828 Seth Mos
632 91f026b0 ayvis
<script type="text/javascript">
633 180db186 Colin Fleming
//<![CDATA[
634 518030b3 Scott Ullrich
	function enable_change(enable_over) {
635
		var endis;
636 cba980f6 jim-p
		<?php if (is_numeric($pool) || ($act == "newpool")): ?>
637
			enable_over = true;
638
		<?php endif; ?>
639 518030b3 Scott Ullrich
		endis = !(document.iform.enable.checked || enable_over);
640 ee1fb205 jim-p
		<?php if (is_numeric($pool) || ($act == "newpool")): ?>
641
			document.iform.descr.disabled = endis;
642
		<?php endif; ?>
643 518030b3 Scott Ullrich
		document.iform.range_from.disabled = endis;
644
		document.iform.range_to.disabled = endis;
645
		document.iform.wins1.disabled = endis;
646
		document.iform.wins2.disabled = endis;
647
		document.iform.dns1.disabled = endis;
648
		document.iform.dns2.disabled = endis;
649 3b5707db Phil Davis
		document.iform.dns3.disabled = endis;
650
		document.iform.dns4.disabled = endis;
651 518030b3 Scott Ullrich
		document.iform.deftime.disabled = endis;
652
		document.iform.maxtime.disabled = endis;
653
		document.iform.gateway.disabled = endis;
654
		document.iform.failover_peerip.disabled = endis;
655
		document.iform.domain.disabled = endis;
656
		document.iform.domainsearchlist.disabled = endis;
657
		document.iform.staticarp.disabled = endis;
658 f365fa90 Joecowboy
		document.iform.dhcpleaseinlocaltime.disabled = endis;
659 518030b3 Scott Ullrich
		document.iform.ddnsdomain.disabled = endis;
660 87019fc4 Andres Petralli
		document.iform.ddnsdomainprimary.disabled = endis;
661
		document.iform.ddnsdomainkeyname.disabled = endis;
662
		document.iform.ddnsdomainkey.disabled = endis;
663 518030b3 Scott Ullrich
		document.iform.ddnsupdate.disabled = endis;
664 1f1a08c8 jim-p
		document.iform.mac_allow.disabled = endis;
665
		document.iform.mac_deny.disabled = endis;
666 518030b3 Scott Ullrich
		document.iform.ntp1.disabled = endis;
667
		document.iform.ntp2.disabled = endis;
668
		document.iform.tftp.disabled = endis;
669
		document.iform.ldap.disabled = endis;
670
		document.iform.netboot.disabled = endis;
671
		document.iform.nextserver.disabled = endis;
672
		document.iform.filename.disabled = endis;
673 7023c602 Charlie Root
		document.iform.filename32.disabled = endis;
674
		document.iform.filename64.disabled = endis;
675 518030b3 Scott Ullrich
		document.iform.rootpath.disabled = endis;
676
		document.iform.denyunknown.disabled = endis;
677
	}
678 4e9cd828 Seth Mos
679 b1d132f5 Scott Ullrich
	function show_shownumbervalue() {
680
		document.getElementById("shownumbervaluebox").innerHTML='';
681
		aodiv = document.getElementById('shownumbervalue');
682
		aodiv.style.display = "block";
683
	}
684
685 518030b3 Scott Ullrich
	function show_ddns_config() {
686
		document.getElementById("showddnsbox").innerHTML='';
687
		aodiv = document.getElementById('showddns');
688
		aodiv.style.display = "block";
689
	}
690 ad171999 Seth Mos
691 1f1a08c8 jim-p
	function show_maccontrol_config() {
692
		document.getElementById("showmaccontrolbox").innerHTML='';
693
		aodiv = document.getElementById('showmaccontrol');
694
		aodiv.style.display = "block";
695
	}
696
697 518030b3 Scott Ullrich
	function show_ntp_config() {
698
		document.getElementById("showntpbox").innerHTML='';
699
		aodiv = document.getElementById('showntp');
700
		aodiv.style.display = "block";
701
	}
702 6c23757b Martin Fuchs
703 518030b3 Scott Ullrich
	function show_tftp_config() {
704
		document.getElementById("showtftpbox").innerHTML='';
705
		aodiv = document.getElementById('showtftp');
706
		aodiv.style.display = "block";
707
	}
708 6c23757b Martin Fuchs
709 518030b3 Scott Ullrich
	function show_ldap_config() {
710
		document.getElementById("showldapbox").innerHTML='';
711
		aodiv = document.getElementById('showldap');
712
		aodiv.style.display = "block";
713
	}
714 4e9cd828 Seth Mos
715 518030b3 Scott Ullrich
	function show_netboot_config() {
716
		document.getElementById("shownetbootbox").innerHTML='';
717
		aodiv = document.getElementById('shownetboot');
718
		aodiv.style.display = "block";
719
	}
720 180db186 Colin Fleming
//]]>
721 5b237745 Scott Ullrich
</script>
722 180db186 Colin Fleming
</head>
723 5b237745 Scott Ullrich
724
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
725 b7597d4e Bill Marquette
<?php include("fbegin.inc"); ?>
726 5b237745 Scott Ullrich
<form action="services_dhcp.php" method="post" name="iform" id="iform">
727
<?php if ($input_errors) print_input_errors($input_errors); ?>
728
<?php if ($savemsg) print_info_box($savemsg); ?>
729 de792e62 jim-p
<?php
730 0a35ca7c jim-p
	if (isset($config['dhcrelay']['enable'])) {
731 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.");
732 de792e62 jim-p
		include("fend.inc");
733 3d7b7757 Chris Buechler
		echo "</body>";
734
		echo "</html>";
735
		exit;
736
	}
737
?>
738 180db186 Colin Fleming
<?php if (is_subsystem_dirty('staticmaps')): ?><br/>
739 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 />
740 5b237745 Scott Ullrich
<?php endif; ?>
741 180db186 Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp server">
742 de792e62 jim-p
<tr><td>
743
<?php
744 f0cdf141 Scott Ullrich
	/* active tabs */
745
	$tab_array = array();
746
	$tabscounter = 0;
747
	$i = 0;
748
	foreach ($iflist as $ifent => $ifname) {
749 de792e62 jim-p
		$oc = $config['interfaces'][$ifent];
750 e5770bc2 Bill Marquette
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) ||
751
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr']))))
752 934240ef Ermal Luçi
			continue;
753 f0cdf141 Scott Ullrich
		if ($ifent == $if)
754
			$active = true;
755
		else
756
			$active = false;
757
		$tab_array[] = array($ifname, $active, "services_dhcp.php?if={$ifent}");
758 934240ef Ermal Luçi
		$tabscounter++;
759
	}
760
	if ($tabscounter == 0) {
761
		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
					<?=gettext("Enter the dynamic DNS domain which will be used to register client names in the DNS server.");?>
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 87019fc4 Andres Petralli
					<?=gettext("Enter the dynamic DNS domain key name which will be used to register client names in the DNS server.");?>
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 1f1a08c8 jim-p
					<?=gettext("Enter a list of partial MAC addresses to allow, comma separated, no spaces, such as ");?>00:00:00,01:E5:FF
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 44d01644 Carlos Eduardo Ramos
					<?=gettext("Enter the IP of the"); ?> <b><?=gettext("next-server"); ?></b>
1123 180db186 Colin Fleming
					<input name="nextserver" type="text" class="formfld unknown" id="nextserver" size="20" value="<?=htmlspecialchars($pconfig['nextserver']);?>" /><br />
1124 7023c602 Charlie Root
					<?=gettext("and the default bios filename");?>
1125 180db186 Colin Fleming
						<input name="filename" type="text" class="formfld unknown" id="filename" size="20" value="<?=htmlspecialchars($pconfig['filename']);?>" /><br />
1126 7023c602 Charlie Root
					<?=gettext("and the UEFI 32bit filename  ");?>
1127 180db186 Colin Fleming
						<input name="filename32" type="text" class="formfld unknown" id="filename32" size="20" value="<?=htmlspecialchars($pconfig['filename32']);?>" /><br />
1128 7023c602 Charlie Root
					<?=gettext("and the UEFI 64bit filename  ");?>
1129 180db186 Colin Fleming
						<input name="filename64" type="text" class="formfld unknown" id="filename64" size="20" value="<?=htmlspecialchars($pconfig['filename64']);?>" /><br />
1130 40ad67e0 Rafael Lucas
					<?=gettext("Note: You need both a filename and a boot server configured for this to work!");?>
1131 7023c602 Charlie Root
					<?=gettext("You will need all three filenames and a boot server configured for UEFI to work!");?>
1132 44d01644 Carlos Eduardo Ramos
					<?=gettext("Enter the"); ?> <b><?=gettext("root-path"); ?></b>-<?=gettext("string");?>
1133 180db186 Colin Fleming
					<input name="rootpath" type="text" class="formfld unknown" id="rootpath" size="90" value="<?=htmlspecialchars($pconfig['rootpath']);?>" /><br />
1134 40ad67e0 Rafael Lucas
					<?=gettext("Note: string-format: iscsi:(servername):(protocol):(port):(LUN):targetname");?>
1135 de792e62 jim-p
				</div>
1136 4e9cd828 Seth Mos
			</td>
1137 518030b3 Scott Ullrich
			</tr>
1138 cba980f6 jim-p
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
1139 518030b3 Scott Ullrich
			<tr>
1140 40ad67e0 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Additional BOOTP/DHCP Options");?></td>
1141 de792e62 jim-p
			<td width="78%" class="vtable">
1142
				<div id="shownumbervaluebox">
1143 1edd5d22 Colin Fleming
					<input type="button" onclick="show_shownumbervalue()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show Additional BOOTP/DHCP Options");?>
1144 de792e62 jim-p
				</div>
1145
				<div id="shownumbervalue" style="display:none">
1146 180db186 Colin Fleming
				<table id="maintable" summary="bootp-dhcp options">
1147 de792e62 jim-p
				<tbody>
1148
				<tr>
1149
				<td colspan="3">
1150
					<div style="padding:5px; margin-top: 16px; margin-bottom: 16px; border:1px dashed #000066; background-color: #ffffff; color: #000000; font-size: 8pt;" id="itemhelp">
1151 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>
1152 b1d132f5 Scott Ullrich
					</div>
1153 de792e62 jim-p
				</td>
1154
				</tr>
1155
				<tr>
1156 40ad67e0 Rafael Lucas
				<td><div id="onecolumn"><?=gettext("Number");?></div></td>
1157 678dfd0f Erik Fonnesbeck
				<td><div id="twocolumn"><?=gettext("Type");?></div></td>
1158
				<td><div id="threecolumn"><?=gettext("Value");?></div></td>
1159 de792e62 jim-p
				</tr>
1160 518030b3 Scott Ullrich
				<?php $counter = 0; ?>
1161 de792e62 jim-p
				<?php
1162 518030b3 Scott Ullrich
					if($pconfig['numberoptions'])
1163 de792e62 jim-p
						foreach($pconfig['numberoptions']['item'] as $item):
1164 518030b3 Scott Ullrich
				?>
1165
					<?php
1166
						$number = $item['number'];
1167 678dfd0f Erik Fonnesbeck
						$itemtype = $item['type'];
1168 518030b3 Scott Ullrich
						$value = $item['value'];
1169
					?>
1170 de792e62 jim-p
				<tr>
1171
				<td>
1172 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);?>" />
1173 de792e62 jim-p
				</td>
1174
				<td>
1175 678dfd0f Erik Fonnesbeck
					<select name="itemtype<?php echo $counter; ?>" class="formselect" id="itemtype<?php echo $counter; ?>">
1176
					<?php
1177
					foreach ($customitemtypes as $typename => $typedescr) {
1178
						echo "<option value=\"{$typename}\" ";
1179 180db186 Colin Fleming
						if ($itemtype == $typename) echo "selected=\"selected\"";
1180 678dfd0f Erik Fonnesbeck
						echo ">" . $typedescr . "</option>";
1181
					}
1182
					?>
1183
					</select>
1184
				</td>
1185
				<td>
1186 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);?>" />
1187 de792e62 jim-p
				</td>
1188
				<td>
1189 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>
1190 de792e62 jim-p
				</td>
1191
				</tr>
1192 518030b3 Scott Ullrich
				<?php $counter++; ?>
1193
				<?php endforeach; ?>
1194 de792e62 jim-p
				</tbody>
1195 518030b3 Scott Ullrich
				</table>
1196
				<a onclick="javascript:addRowTo('maintable', 'formfldalias'); return false;" href="#">
1197 40ad67e0 Rafael Lucas
					<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="<?=gettext("add another entry");?>" />
1198 518030b3 Scott Ullrich
				</a>
1199
				<script type="text/javascript">
1200 180db186 Colin Fleming
				//<![CDATA[
1201 678dfd0f Erik Fonnesbeck
					field_counter_js = 3;
1202 518030b3 Scott Ullrich
					rows = 1;
1203
					totalrows = <?php echo $counter; ?>;
1204
					loaded = <?php echo $counter; ?>;
1205 180db186 Colin Fleming
				//]]>
1206 518030b3 Scott Ullrich
				</script>
1207 b1d132f5 Scott Ullrich
				</div>
1208 518030b3 Scott Ullrich
1209
				</td>
1210
			</tr>
1211 cba980f6 jim-p
			<?php endif; ?>
1212 518030b3 Scott Ullrich
			<tr>
1213 de792e62 jim-p
			<td width="22%" valign="top">&nbsp;</td>
1214
			<td width="78%">
1215 cba980f6 jim-p
				<?php if ($act == "newpool"): ?>
1216 180db186 Colin Fleming
				<input type="hidden" name="act" value="newpool" />
1217 cba980f6 jim-p
				<?php endif; ?>
1218
				<?php if (is_numeric($pool)): ?>
1219 180db186 Colin Fleming
				<input type="hidden" name="pool" value="<?php echo $pool; ?>" />
1220 cba980f6 jim-p
				<?php endif; ?>
1221 180db186 Colin Fleming
				<input name="if" type="hidden" value="<?=htmlspecialchars($if);?>" />
1222 565488c9 Renato Botelho
				<input name="submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)" />
1223 de792e62 jim-p
			</td>
1224
			</tr>
1225
			<tr>
1226
			<td width="22%" valign="top">&nbsp;</td>
1227 8cd558b6 ayvis
			<td width="78%"> <p><span class="vexpl"><span class="red"><strong><?=gettext("Note:");?><br />
1228 6c235a30 Carlos Eduardo Ramos
				</strong></span><?=gettext("The DNS servers entered in"); ?> <a href="system.php"><?=gettext("System: " .
1229
				"General setup"); ?></a> <?=gettext("(or the"); ?> <a href="services_dnsmasq.php"><?=gettext("DNS " .
1230
				"forwarder"); ?></a>, <?=gettext("if enabled)"); ?> </span><span class="vexpl"><?=gettext("will " .
1231 8cd558b6 ayvis
				"be assigned to clients by the DHCP server."); ?><br />
1232
				<br />
1233 44d01644 Carlos Eduardo Ramos
				<?=gettext("The DHCP lease table can be viewed on the"); ?> <a href="status_dhcp_leases.php"><?=gettext("Status: " .
1234 8cd558b6 ayvis
				"DHCP leases"); ?></a> <?=gettext("page."); ?><br />
1235 de792e62 jim-p
				</span></p>
1236
			</td>
1237 518030b3 Scott Ullrich
			</tr>
1238
		</table>
1239 0d1b26ee jim-p
		<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
1240 180db186 Colin Fleming
		<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="static mappings">
1241 f2ea45ef jim-p
		<tr>
1242
			<td colspan="5" valign="top" class="listtopic"><?=gettext("DHCP Static Mappings for this interface.");?></td>
1243
			<td>&nbsp;</td>
1244
		</tr>
1245 518030b3 Scott Ullrich
		<tr>
1246 25c1ebd5 N0YB
			<td width="7%" class="listhdrr"><?=gettext("Static ARP");?></td>
1247
			<td width="18%" class="listhdrr"><?=gettext("MAC address");?></td>
1248 40ad67e0 Rafael Lucas
			<td width="15%" class="listhdrr"><?=gettext("IP address");?></td>
1249
			<td width="20%" class="listhdrr"><?=gettext("Hostname");?></td>
1250
			<td width="30%" class="listhdr"><?=gettext("Description");?></td>
1251 518030b3 Scott Ullrich
			<td width="10%" class="list">
1252 180db186 Colin Fleming
			<table border="0" cellspacing="0" cellpadding="1" summary="add">
1253 de792e62 jim-p
			<tr>
1254 d415d821 Seth Mos
			<td valign="middle" width="17"></td>
1255 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>
1256 518030b3 Scott Ullrich
			</tr>
1257
			</table>
1258
			</td>
1259 2af4c579 Scott Ullrich
		</tr>
1260 de792e62 jim-p
			<?php if(is_array($a_maps)): ?>
1261
			<?php $i = 0; foreach ($a_maps as $mapent): ?>
1262
			<?php if($mapent['mac'] <> "" or $mapent['ipaddr'] <> ""): ?>
1263
		<tr>
1264 180db186 Colin Fleming
		<td align="center" class="listlr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>';">
1265 25c1ebd5 N0YB
			<?php if (isset($mapent['arp_table_static_entry'])): ?>
1266 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" />
1267 25c1ebd5 N0YB
			<?php endif; ?>
1268
		</td>
1269 180db186 Colin Fleming
		<td class="listlr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>';">
1270 de792e62 jim-p
			<?=htmlspecialchars($mapent['mac']);?>
1271
		</td>
1272 180db186 Colin Fleming
		<td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>';">
1273 de792e62 jim-p
			<?=htmlspecialchars($mapent['ipaddr']);?>&nbsp;
1274
		</td>
1275 180db186 Colin Fleming
		<td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>';">
1276 de792e62 jim-p
			<?=htmlspecialchars($mapent['hostname']);?>&nbsp;
1277
		</td>
1278 180db186 Colin Fleming
		<td class="listbg" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>';">
1279 de792e62 jim-p
			<?=htmlspecialchars($mapent['descr']);?>&nbsp;
1280
		</td>
1281 180db186 Colin Fleming
		<td valign="middle" class="list nowrap">
1282
			<table border="0" cellspacing="0" cellpadding="1" summary="icons">
1283 de792e62 jim-p
			<tr>
1284 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>
1285
			<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>
1286 de792e62 jim-p
			</tr>
1287
			</table>
1288
		</td>
1289
		</tr>
1290 6f5b2c3e Scott Ullrich
		<?php endif; ?>
1291 75a70796 Bill Marquette
		<?php $i++; endforeach; ?>
1292 6f5b2c3e Scott Ullrich
		<?php endif; ?>
1293 de792e62 jim-p
		<tr>
1294 25c1ebd5 N0YB
		<td class="list" colspan="5"></td>
1295 de792e62 jim-p
		<td class="list">
1296 180db186 Colin Fleming
			<table border="0" cellspacing="0" cellpadding="1" summary="add">
1297 de792e62 jim-p
			<tr>
1298 d415d821 Seth Mos
			<td valign="middle" width="17"></td>
1299 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>
1300 de792e62 jim-p
			</tr>
1301
			</table>
1302
		</td>
1303
		</tr>
1304
		</table>
1305 0d1b26ee jim-p
		<?php endif; ?>
1306 d732f186 Bill Marquette
	</div>
1307 de792e62 jim-p
</td>
1308
</tr>
1309 5b237745 Scott Ullrich
</table>
1310
</form>
1311 91f026b0 ayvis
<script type="text/javascript">
1312 180db186 Colin Fleming
//<![CDATA[
1313 5b237745 Scott Ullrich
enable_change(false);
1314 180db186 Colin Fleming
//]]>
1315 5b237745 Scott Ullrich
</script>
1316 b7597d4e Bill Marquette
<?php include("fend.inc"); ?>
1317 5b237745 Scott Ullrich
</body>
1318
</html>