Project

General

Profile

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