Project

General

Profile

Download (58.5 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	services_dhcp.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6

    
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
9
	All rights reserved.
10

    
11
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13

    
14
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16

    
17
	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

    
21
	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
/*
33
	pfSense_BUILDER_BINARIES:	/bin/rm
34
	pfSense_MODULE:	interfaces
35
*/
36

    
37
##|+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
require("guiconfig.inc");
45
require_once("filter.inc");
46

    
47
if(!$g['services_dhcp_server_enable']) {
48
	header("Location: /");
49
	exit;
50
}
51

    
52
/* 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
	if (!file_exists($leasesfile))
60
		return;
61
	/* 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
$if = $_GET['if'];
99
if (!empty($_POST['if']))
100
	$if = $_POST['if'];
101

    
102
/* if OLSRD is enabled, allow WAN to house DHCP. */
103
if($config['installedpackages']['olsrd']) {
104
	foreach($config['installedpackages']['olsrd']['config'] as $olsrd) {
105
			if($olsrd['enable']) {
106
				$is_olsr_enabled = true;
107
				break;
108
			}
109
	}
110
}	
111

    
112
$iflist = get_configured_interface_with_descr();
113

    
114
/* set the starting interface */
115
if (!$if || !isset($iflist[$if])) {
116
	foreach ($iflist as $ifent => $ifname) {
117
		$oc = $config['interfaces'][$ifent];
118
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) ||
119
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr']))))
120
			continue;
121
		$if = $ifent;
122
		break;
123
	}
124
}
125

    
126
$act = $_GET['act'];
127
if (!empty($_POST['act']))
128
	$act = $_POST['act'];
129

    
130
$a_pools = array();
131

    
132
if (is_array($config['dhcpd'][$if])){
133
	$pool = $_GET['pool'];
134
	if (is_numeric($_POST['pool']))
135
		$pool = $_POST['pool'];
136

    
137
	// If we have a pool but no interface name, that's not valid. Redirect away.
138
	if (is_numeric($pool) && empty($if)) {
139
		header("Location: services_dhcp.php");
140
		exit;
141
	}
142

    
143
	if (!is_array($config['dhcpd'][$if]['pool']))
144
		$config['dhcpd'][$if]['pool'] = array();
145
	$a_pools = &$config['dhcpd'][$if]['pool'];
146

    
147
	if (is_numeric($pool) && $a_pools[$pool])
148
		$dhcpdconf = &$a_pools[$pool];
149
	elseif ($act == "newpool")
150
		$dhcpdconf = array();
151
	else
152
		$dhcpdconf = &$config['dhcpd'][$if];
153
}
154
if (is_array($dhcpdconf)) {
155
	// Global Options
156
	if (!is_numeric($pool) && !($act == "newpool")) {
157
		$pconfig['enable'] = isset($dhcpdconf['enable']);
158
		$pconfig['staticarp'] = isset($dhcpdconf['staticarp']);
159
		// No reason to specify this per-pool, per the dhcpd.conf man page it needs to be in every
160
		//   pool and should be specified in every pool both nodes share, so we'll treat it as global
161
		$pconfig['failover_peerip'] = $dhcpdconf['failover_peerip'];
162

    
163
		// dhcpleaseinlocaltime is global to all interfaces. So if it is selected on any interface,
164
		// then show it true/checked.
165
		foreach ($config['dhcpd'] as $dhcpdifitem) {
166
			$dhcpleaseinlocaltime = $dhcpdifitem['dhcpleaseinlocaltime'];
167
			if ($dhcpleaseinlocaltime)
168
				break;
169
		}
170

    
171
		$pconfig['dhcpleaseinlocaltime'] = $dhcpleaseinlocaltime;
172

    
173
		if (!is_array($dhcpdconf['staticmap']))
174
			$dhcpdconf['staticmap'] = array();
175
		$a_maps = &$dhcpdconf['staticmap'];
176
	} else {
177
		// Options that exist only in pools
178
		$pconfig['descr'] = $dhcpdconf['descr'];
179
	}
180

    
181
	// Options that can be global or per-pool.
182
	if (is_array($dhcpdconf['range'])) {
183
		$pconfig['range_from'] = $dhcpdconf['range']['from'];
184
		$pconfig['range_to'] = $dhcpdconf['range']['to'];
185
	}
186
	$pconfig['deftime'] = $dhcpdconf['defaultleasetime'];
187
	$pconfig['maxtime'] = $dhcpdconf['maxleasetime'];
188
	$pconfig['gateway'] = $dhcpdconf['gateway'];
189
	$pconfig['domain'] = $dhcpdconf['domain'];
190
	$pconfig['domainsearchlist'] = $dhcpdconf['domainsearchlist'];
191
	list($pconfig['wins1'],$pconfig['wins2']) = $dhcpdconf['winsserver'];
192
	list($pconfig['dns1'],$pconfig['dns2'],$pconfig['dns3'],$pconfig['dns4']) = $dhcpdconf['dnsserver'];
193
	$pconfig['denyunknown'] = isset($dhcpdconf['denyunknown']);
194
	$pconfig['ddnsdomain'] = $dhcpdconf['ddnsdomain'];
195
	$pconfig['ddnsdomainprimary'] = $dhcpdconf['ddnsdomainprimary'];
196
	$pconfig['ddnsdomainkeyname'] = $dhcpdconf['ddnsdomainkeyname'];
197
	$pconfig['ddnsdomainkey'] = $dhcpdconf['ddnsdomainkey'];
198
	$pconfig['ddnsupdate'] = isset($dhcpdconf['ddnsupdate']);
199
	$pconfig['mac_allow'] = $dhcpdconf['mac_allow'];
200
	$pconfig['mac_deny'] = $dhcpdconf['mac_deny'];
201
	list($pconfig['ntp1'],$pconfig['ntp2']) = $dhcpdconf['ntpserver'];
202
	$pconfig['tftp'] = $dhcpdconf['tftp'];
203
	$pconfig['ldap'] = $dhcpdconf['ldap'];
204
	$pconfig['netboot'] = isset($dhcpdconf['netboot']);
205
	$pconfig['nextserver'] = $dhcpdconf['nextserver'];
206
	$pconfig['filename'] = $dhcpdconf['filename'];
207
	$pconfig['filename32'] = $dhcpdconf['filename32'];
208
	$pconfig['filename64'] = $dhcpdconf['filename64'];
209
	$pconfig['rootpath'] = $dhcpdconf['rootpath'];
210
	$pconfig['netmask'] = $dhcpdconf['netmask'];
211
	$pconfig['numberoptions'] = $dhcpdconf['numberoptions'];
212
}
213

    
214
$ifcfgip = $config['interfaces'][$if]['ipaddr'];
215
$ifcfgsn = $config['interfaces'][$if]['subnet'];
216

    
217
function validate_partial_mac_list($maclist) {
218
	$macs = explode(',', $maclist);
219

    
220
	// Loop through and look for invalid MACs.
221
	foreach ($macs as $mac)
222
		if (!is_macaddr($mac, true))
223
			return false;
224
	return true;
225
}
226

    
227
if (isset($_POST['submit'])) {
228

    
229
	unset($input_errors);
230

    
231
	$pconfig = $_POST;
232

    
233
	$numberoptions = array();
234
	for($x=0; $x<99; $x++) {
235
		if(isset($_POST["number{$x}"]) && ctype_digit($_POST["number{$x}"])) {
236
			$numbervalue = array();
237
			$numbervalue['number'] = htmlspecialchars($_POST["number{$x}"]);
238
			$numbervalue['type'] = htmlspecialchars($_POST["itemtype{$x}"]);
239
			$numbervalue['value'] = str_replace('&quot;', '"', htmlspecialchars($_POST["value{$x}"]));
240
			$numberoptions['item'][] = $numbervalue;
241
		}
242
	}
243
	// Reload the new pconfig variable that the form uses.
244
	$pconfig['numberoptions'] = $numberoptions;
245

    
246
	/* input validation */
247
	if ($_POST['enable'] || is_numeric($pool) || $act == "newpool") {
248
		$reqdfields = explode(" ", "range_from range_to");
249
		$reqdfieldsn = array(gettext("Range begin"),gettext("Range end"));
250

    
251
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
252

    
253
		if (($_POST['range_from'] && !is_ipaddrv4($_POST['range_from'])))
254
			$input_errors[] = gettext("A valid range must be specified.");
255
		if (($_POST['range_to'] && !is_ipaddrv4($_POST['range_to'])))
256
			$input_errors[] = gettext("A valid range must be specified.");
257
		if (($_POST['gateway'] && $_POST['gateway'] != "none" && !is_ipaddrv4($_POST['gateway'])))
258
			$input_errors[] = gettext("A valid IP address must be specified for the gateway.");
259
		if (($_POST['wins1'] && !is_ipaddrv4($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddrv4($_POST['wins2'])))
260
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary WINS servers.");
261
		$parent_ip = get_interface_ip($_POST['if']);
262
		if (is_ipaddrv4($parent_ip) && $_POST['gateway'] && $_POST['gateway'] != "none") {
263
			$parent_sn = get_interface_subnet($_POST['if']);
264
			if(!ip_in_subnet($_POST['gateway'], gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn) && !ip_in_interface_alias_subnet($_POST['if'], $_POST['gateway']))
265
				$input_errors[] = sprintf(gettext("The gateway address %s does not lie within the chosen interface's subnet."), $_POST['gateway']);
266
		}
267
		if (($_POST['dns1'] && !is_ipaddrv4($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddrv4($_POST['dns2'])) || ($_POST['dns3'] && !is_ipaddrv4($_POST['dns3'])) || ($_POST['dns4'] && !is_ipaddrv4($_POST['dns4'])))
268
			$input_errors[] = gettext("A valid IP address must be specified for each of the DNS servers.");
269

    
270
		if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60)))
271
				$input_errors[] = gettext("The default lease time must be at least 60 seconds.");
272

    
273
		if (isset($config['captiveportal']) && is_array($config['captiveportal'])) {
274
			$deftime = 7200; // Default value if it's empty
275
			if (is_numeric($_POST['deftime']))
276
				$deftime = $_POST['deftime'];
277

    
278
			foreach ($config['captiveportal'] as $cpZone => $cpdata) {
279
				if (!isset($cpdata['enable']))
280
					continue;
281
				if (!isset($cpdata['timeout']) || !is_numeric($cpdata['timeout']))
282
					continue;
283
				$cp_ifs = explode(',', $cpdata['interface']);
284
				if (!in_array($if, $cp_ifs))
285
					continue;
286
				if ($cpdata['timeout'] > $deftime)
287
					$input_errors[] = sprintf(gettext(
288
						"The Captive Portal zone '%s' has Hard Timeout parameter set to a value bigger than Default lease time (%s)."), $cpZone, $deftime);
289
			}
290
		}
291

    
292
		if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime'])))
293
			$input_errors[] = gettext("The maximum lease time must be at least 60 seconds and higher than the default lease time.");
294
		if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain'])))
295
			$input_errors[] = gettext("A valid domain name must be specified for the dynamic DNS registration.");
296
		if (($_POST['ddnsdomain'] && !is_ipaddrv4($_POST['ddnsdomainprimary'])))
297
			$input_errors[] = gettext("A valid primary domain name server IP address must be specified for the dynamic domain name.");
298
		if (($_POST['ddnsdomainkey'] && !$_POST['ddnsdomainkeyname']) ||
299
			($_POST['ddnsdomainkeyname'] && !$_POST['ddnsdomainkey']))
300
			$input_errors[] = gettext("You must specify both a valid domain key and key name.");
301
		if ($_POST['domainsearchlist']) {
302
			$domain_array=preg_split("/[ ;]+/",$_POST['domainsearchlist']);
303
			foreach ($domain_array as $curdomain) {
304
				if (!is_domain($curdomain)) {
305
					$input_errors[] = gettext("A valid domain search list must be specified.");
306
					break;
307
				}
308
			}
309
		}
310

    
311
		// Validate MACs
312
		if (!empty($_POST['mac_allow']) && !validate_partial_mac_list($_POST['mac_allow']))
313
			$input_errors[] = gettext("If you specify a mac allow list, it must contain only valid partial MAC addresses.");
314
		if (!empty($_POST['mac_deny']) && !validate_partial_mac_list($_POST['mac_deny']))
315
			$input_errors[] = gettext("If you specify a mac deny list, it must contain only valid partial MAC addresses.");
316

    
317
		if (($_POST['ntp1'] && !is_ipaddrv4($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddrv4($_POST['ntp2'])))
318
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary NTP servers.");
319
		if (($_POST['domain'] && !is_domain($_POST['domain'])))
320
			$input_errors[] = gettext("A valid domain name must be specified for the DNS domain.");
321
		if ($_POST['tftp'] && !is_ipaddrv4($_POST['tftp']) && !is_domain($_POST['tftp']) && !is_URL($_POST['tftp']))
322
			$input_errors[] = gettext("A valid IP address or hostname must be specified for the TFTP server.");
323
		if (($_POST['nextserver'] && !is_ipaddrv4($_POST['nextserver'])))
324
			$input_errors[] = gettext("A valid IP address must be specified for the network boot server.");
325

    
326
		if(gen_subnet($ifcfgip, $ifcfgsn) == $_POST['range_from'])
327
			$input_errors[] = gettext("You cannot use the network address in the starting subnet range.");
328
		if(gen_subnet_max($ifcfgip, $ifcfgsn) == $_POST['range_to'])
329
			$input_errors[] = gettext("You cannot use the broadcast address in the ending subnet range.");
330

    
331
		// Disallow a range that includes the virtualip
332
		if (is_array($config['virtualip']['vip'])) {
333
			foreach($config['virtualip']['vip'] as $vip) {
334
				if($vip['interface'] == $if)
335
					if($vip['subnet'] && is_inrange_v4($vip['subnet'], $_POST['range_from'], $_POST['range_to']))
336
						$input_errors[] = sprintf(gettext("The subnet range cannot overlap with virtual IP address %s."),$vip['subnet']);
337
			}
338
		}
339

    
340
		$noip = false;
341
		if(is_array($a_maps))
342
			foreach ($a_maps as $map)
343
				if (empty($map['ipaddr']))
344
					$noip = true;
345
		if ($_POST['staticarp'] && $noip)
346
			$input_errors[] = "Cannot enable static ARP when you have static map entries without IP addresses. Ensure all static maps have IP addresses and try again.";
347

    
348
		if(is_array($pconfig['numberoptions']['item'])) {
349
			foreach ($pconfig['numberoptions']['item'] as $numberoption) {
350
				if ( $numberoption['type'] == 'text' && strstr($numberoption['value'], '"') )
351
					$input_errors[] = gettext("Text type cannot include quotation marks.");
352
				else if ( $numberoption['type'] == 'string' && !preg_match('/^"[^"]*"$/', $numberoption['value']) && !preg_match('/^[0-9a-f]{2}(?:\:[0-9a-f]{2})*$/i', $numberoption['value']) )
353
					$input_errors[] = gettext("String type must be enclosed in quotes like \"this\" or must be a series of octets specified in hexadecimal, separated by colons, like 01:23:45:67:89:ab:cd:ef");
354
				else if ( $numberoption['type'] == 'boolean' && $numberoption['value'] != 'true' && $numberoption['value'] != 'false' && $numberoption['value'] != 'on' && $numberoption['value'] != 'off' )
355
					$input_errors[] = gettext("Boolean type must be true, false, on, or off.");
356
				else if ( $numberoption['type'] == 'unsigned integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 255) )
357
					$input_errors[] = gettext("Unsigned 8-bit integer type must be a number in the range 0 to 255.");
358
				else if ( $numberoption['type'] == 'unsigned integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 65535) )
359
					$input_errors[] = gettext("Unsigned 16-bit integer type must be a number in the range 0 to 65535.");
360
				else if ( $numberoption['type'] == 'unsigned integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 4294967295) )
361
					$input_errors[] = gettext("Unsigned 32-bit integer type must be a number in the range 0 to 4294967295.");
362
				else if ( $numberoption['type'] == 'signed integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -128 || $numberoption['value'] > 127) )
363
					$input_errors[] = gettext("Signed 8-bit integer type must be a number in the range -128 to 127.");
364
				else if ( $numberoption['type'] == 'signed integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -32768 || $numberoption['value'] > 32767) )
365
					$input_errors[] = gettext("Signed 16-bit integer type must be a number in the range -32768 to 32767.");
366
				else if ( $numberoption['type'] == 'signed integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -2147483648 || $numberoption['value'] > 2147483647) )
367
					$input_errors[] = gettext("Signed 32-bit integer type must be a number in the range -2147483648 to 2147483647.");
368
				else if ( $numberoption['type'] == 'ip-address' && !is_ipaddrv4($numberoption['value']) && !is_hostname($numberoption['value']) )
369
					$input_errors[] = gettext("IP address or host type must be an IP address or host name.");
370
			}
371
		}
372

    
373
		if (!$input_errors) {
374
			/* make sure the range lies within the current subnet */
375
			$subnet_start = ip2ulong(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
376
			$subnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
377

    
378
			if ((ip2ulong($_POST['range_from']) < $subnet_start) || (ip2ulong($_POST['range_from']) > $subnet_end) ||
379
			    (ip2ulong($_POST['range_to']) < $subnet_start) || (ip2ulong($_POST['range_to']) > $subnet_end)) {
380
				$input_errors[] = gettext("The specified range lies outside of the current subnet.");
381
			}
382

    
383
			if (ip2ulong($_POST['range_from']) > ip2ulong($_POST['range_to']))
384
				$input_errors[] = gettext("The range is invalid (first element higher than second element).");
385

    
386
			if (is_numeric($pool) || ($act == "newpool")) {
387
				$rfrom = $config['dhcpd'][$if]['range']['from'];
388
				$rto = $config['dhcpd'][$if]['range']['to'];
389

    
390
				if (is_inrange_v4($_POST['range_from'], $rfrom, $rto) || is_inrange_v4($_POST['range_to'], $rfrom, $rto))
391
					$input_errors[] = gettext("The specified range must not be within the DHCP range for this interface.");
392
			}
393

    
394
			foreach ($a_pools as $id => $p) {
395
				if (is_numeric($pool) && ($id == $pool))
396
					continue;
397

    
398
				if (is_inrange_v4($_POST['range_from'], $p['range']['from'], $p['range']['to']) ||
399
				    is_inrange_v4($_POST['range_to'], $p['range']['from'], $p['range']['to'])) {
400
					$input_errors[] = gettext("The specified range must not be within the range configured on a DHCP pool for this interface.");
401
					break;
402
				}
403
			}
404

    
405
			/* make sure that the DHCP Relay isn't enabled on this interface */
406
			if (isset($config['dhcrelay']['enable']) && (stristr($config['dhcrelay']['interface'], $if) !== false))
407
				$input_errors[] = sprintf(gettext("You must disable the DHCP relay on the %s interface before enabling the DHCP server."),$iflist[$if]);
408

    
409
			$dynsubnet_start = ip2ulong($_POST['range_from']);
410
			$dynsubnet_end = ip2ulong($_POST['range_to']);
411
			if (is_array($a_maps)) {
412
				foreach ($a_maps as $map) {
413
					if (empty($map['ipaddr']))
414
						continue;
415
					if ((ip2ulong($map['ipaddr']) > $dynsubnet_start) &&
416
						(ip2ulong($map['ipaddr']) < $dynsubnet_end)) {
417
						$input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings."));
418
						break;
419
					}
420
				}
421
			}
422
		}
423
	}
424

    
425
	if (!$input_errors) {
426
		if (!is_numeric($pool)) {
427
			if ($act == "newpool") {
428
				$dhcpdconf = array();
429
			} else {
430
				if (!is_array($config['dhcpd'][$if]))
431
					$config['dhcpd'][$if] = array();
432
				$dhcpdconf = $config['dhcpd'][$if];
433
			}
434
		} else {
435
			if (is_array($a_pools[$pool])) {
436
				$dhcpdconf = $a_pools[$pool];
437
			} else {
438
				// Someone specified a pool but it doesn't exist. Punt.
439
				header("Location: services_dhcp.php");
440
				exit;
441
			}
442
		}
443
		if (!is_array($dhcpdconf['range']))
444
			$dhcpdconf['range'] = array();
445

    
446
		$dhcpd_enable_changed = false;
447

    
448
		// Global Options
449
		if (!is_numeric($pool) && !($act == "newpool")) {
450
			$old_dhcpd_enable = isset($dhcpdconf['enable']);
451
			$new_dhcpd_enable = ($_POST['enable']) ? true : false;
452
			if ($old_dhcpd_enable != $new_dhcpd_enable) {
453
				/* DHCP has been enabled or disabled. The pf ruleset will need to be rebuilt to allow or disallow DHCP. */
454
				$dhcpd_enable_changed = true;
455
			}
456
			$dhcpdconf['enable'] = $new_dhcpd_enable;
457
			$dhcpdconf['staticarp'] = ($_POST['staticarp']) ? true : false;
458
			$previous = $dhcpdconf['failover_peerip'];
459
			if($previous <> $_POST['failover_peerip'])
460
				mwexec("/bin/rm -rf /var/dhcpd/var/db/*");
461
			$dhcpdconf['failover_peerip'] = $_POST['failover_peerip'];
462
			// dhcpleaseinlocaltime is global to all interfaces. So update the setting on all interfaces.
463
			foreach ($config['dhcpd'] as &$dhcpdifitem) {
464
				$dhcpdifitem['dhcpleaseinlocaltime'] = $_POST['dhcpleaseinlocaltime'];
465
			}
466
		} else {
467
			// Options that exist only in pools
468
			$dhcpdconf['descr'] = $_POST['descr'];
469
		}
470

    
471
		// Options that can be global or per-pool.
472
		$dhcpdconf['range']['from'] = $_POST['range_from'];
473
		$dhcpdconf['range']['to'] = $_POST['range_to'];
474
		$dhcpdconf['defaultleasetime'] = $_POST['deftime'];
475
		$dhcpdconf['maxleasetime'] = $_POST['maxtime'];
476
		$dhcpdconf['netmask'] = $_POST['netmask'];
477

    
478
		unset($dhcpdconf['winsserver']);
479
		if ($_POST['wins1'])
480
			$dhcpdconf['winsserver'][] = $_POST['wins1'];
481
		if ($_POST['wins2'])
482
			$dhcpdconf['winsserver'][] = $_POST['wins2'];
483

    
484
		unset($dhcpdconf['dnsserver']);
485
		if ($_POST['dns1'])
486
			$dhcpdconf['dnsserver'][] = $_POST['dns1'];
487
		if ($_POST['dns2'])
488
			$dhcpdconf['dnsserver'][] = $_POST['dns2'];
489
		if ($_POST['dns3'])
490
			$dhcpdconf['dnsserver'][] = $_POST['dns3'];
491
		if ($_POST['dns4'])
492
			$dhcpdconf['dnsserver'][] = $_POST['dns4'];
493

    
494
		$dhcpdconf['gateway'] = $_POST['gateway'];
495
		$dhcpdconf['domain'] = $_POST['domain'];
496
		$dhcpdconf['domainsearchlist'] = $_POST['domainsearchlist'];
497
		$dhcpdconf['denyunknown'] = ($_POST['denyunknown']) ? true : false;
498
		$dhcpdconf['ddnsdomain'] = $_POST['ddnsdomain'];
499
		$dhcpdconf['ddnsdomainprimary'] = $_POST['ddnsdomainprimary'];
500
		$dhcpdconf['ddnsdomainkeyname'] = $_POST['ddnsdomainkeyname'];
501
		$dhcpdconf['ddnsdomainkey'] = $_POST['ddnsdomainkey'];
502
		$dhcpdconf['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
503
		$dhcpdconf['mac_allow'] = $_POST['mac_allow'];
504
		$dhcpdconf['mac_deny'] = $_POST['mac_deny'];
505

    
506
		unset($dhcpdconf['ntpserver']);
507
		if ($_POST['ntp1'])
508
			$dhcpdconf['ntpserver'][] = $_POST['ntp1'];
509
		if ($_POST['ntp2'])
510
			$dhcpdconf['ntpserver'][] = $_POST['ntp2'];
511

    
512
		$dhcpdconf['tftp'] = $_POST['tftp'];
513
		$dhcpdconf['ldap'] = $_POST['ldap'];
514
		$dhcpdconf['netboot'] = ($_POST['netboot']) ? true : false;
515
		$dhcpdconf['nextserver'] = $_POST['nextserver'];
516
		$dhcpdconf['filename'] = $_POST['filename'];
517
		$dhcpdconf['filename32'] = $_POST['filename32'];
518
		$dhcpdconf['filename64'] = $_POST['filename64'];
519
		$dhcpdconf['rootpath'] = $_POST['rootpath'];
520

    
521
		// Handle the custom options rowhelper
522
		if(isset($dhcpdconf['numberoptions']['item']))
523
			unset($dhcpdconf['numberoptions']['item']);
524

    
525
		$dhcpdconf['numberoptions'] = $numberoptions;
526

    
527
		if (is_numeric($pool) && is_array($a_pools[$pool])) {
528
			$a_pools[$pool] = $dhcpdconf;
529
		} elseif ($act == "newpool") {
530
			$a_pools[] = $dhcpdconf;
531
		} else {
532
			$config['dhcpd'][$if] = $dhcpdconf;
533
		}
534

    
535
		write_config();
536
	}
537
}
538

    
539
if (isset($_POST['submit']) || isset($_POST['apply'])) {
540
	$retval = 0;
541
	$retvaldhcp = 0;
542
	$retvaldns = 0;
543
	/* Stop DHCP so we can cleanup leases */
544
	killbyname("dhcpd");
545
	dhcp_clean_leases();
546
	/* dnsmasq_configure calls dhcpd_configure */
547
	/* no need to restart dhcpd twice */
548
	if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic']))	{
549
		$retvaldns = services_dnsmasq_configure();
550
		if ($retvaldns == 0) {
551
			clear_subsystem_dirty('hosts');
552
			clear_subsystem_dirty('staticmaps');
553
		}
554
	} else if (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic'])) {
555
		$retvaldns = services_unbound_configure();
556
		if ($retvaldns == 0)
557
			clear_subsystem_dirty('unbound');
558
			clear_subsystem_dirty('hosts');
559
			clear_subsystem_dirty('staticmaps');
560
	} else {
561
		$retvaldhcp = services_dhcpd_configure();
562
		if ($retvaldhcp == 0)
563
			clear_subsystem_dirty('staticmaps');
564
	}
565
	if ($dhcpd_enable_changed)
566
		$retvalfc = filter_configure();
567

    
568
	if($retvaldhcp == 1 || $retvaldns == 1 || $retvalfc == 1)
569
		$retval = 1;
570
	$savemsg = get_std_save_message($retval);
571
}
572

    
573
if ($act == "delpool") {
574
	if ($a_pools[$_GET['id']]) {
575
		unset($a_pools[$_GET['id']]);
576
		write_config();
577
		header("Location: services_dhcp.php?if={$if}");
578
		exit;
579
	}
580
}
581

    
582
if ($act == "del") {
583
	if ($a_maps[$_GET['id']]) {
584
		unset($a_maps[$_GET['id']]);
585
		write_config();
586
		if(isset($config['dhcpd'][$if]['enable'])) {
587
			mark_subsystem_dirty('staticmaps');
588
			if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic']))
589
				mark_subsystem_dirty('hosts');
590
		}
591
		header("Location: services_dhcp.php?if={$if}");
592
		exit;
593
	}
594
}
595

    
596
$closehead = false;
597
$pgtitle = array(gettext("Services"),gettext("DHCP server"));
598
$shortcut_section = "dhcp";
599

    
600
include("head.inc");
601

    
602
?>
603

    
604
<script type="text/javascript" src="/javascript/row_helper.js">
605
</script>
606

    
607
<script type="text/javascript">
608
//<![CDATA[
609
	function itemtype_field(fieldname, fieldsize, n) {
610
		return '<select name="' + fieldname + n + '" class="formselect" id="' + fieldname + n + '"><?php
611
			$customitemtypes = array('text' => gettext('Text'), 'string' => gettext('String'), 'boolean' => gettext('Boolean'),
612
				'unsigned integer 8' => gettext('Unsigned 8-bit integer'), 'unsigned integer 16' => gettext('Unsigned 16-bit integer'), 'unsigned integer 32' => gettext('Unsigned 32-bit integer'),
613
				'signed integer 8' => gettext('Signed 8-bit integer'), 'signed integer 16' => gettext('Signed 16-bit integer'), 'signed integer 32' => gettext('Signed 32-bit integer'), 'ip-address' => gettext('IP address or host'));
614
			foreach ($customitemtypes as $typename => $typedescr) {
615
				echo "<option value=\"{$typename}\">{$typedescr}<\/option>";
616
			}
617
		?><\/select>';
618
	}
619

    
620
	rowname[0] = "number";
621
	rowtype[0] = "textbox";
622
	rowsize[0] = "10";
623
	rowname[1] = "itemtype";
624
	rowtype[1] = itemtype_field;
625
	rowname[2] = "value";
626
	rowtype[2] = "textbox";
627
	rowsize[2] = "40";
628
//]]>
629
</script>
630

    
631
<script type="text/javascript">
632
//<![CDATA[
633
	function enable_change(enable_over) {
634
		var endis;
635
		<?php if (is_numeric($pool) || ($act == "newpool")): ?>
636
			enable_over = true;
637
		<?php endif; ?>
638
		endis = !(document.iform.enable.checked || enable_over);
639
		<?php if (is_numeric($pool) || ($act == "newpool")): ?>
640
			document.iform.descr.disabled = endis;
641
		<?php endif; ?>
642
		document.iform.range_from.disabled = endis;
643
		document.iform.range_to.disabled = endis;
644
		document.iform.wins1.disabled = endis;
645
		document.iform.wins2.disabled = endis;
646
		document.iform.dns1.disabled = endis;
647
		document.iform.dns2.disabled = endis;
648
		document.iform.dns3.disabled = endis;
649
		document.iform.dns4.disabled = endis;
650
		document.iform.deftime.disabled = endis;
651
		document.iform.maxtime.disabled = endis;
652
		document.iform.gateway.disabled = endis;
653
		document.iform.failover_peerip.disabled = endis;
654
		document.iform.domain.disabled = endis;
655
		document.iform.domainsearchlist.disabled = endis;
656
		document.iform.staticarp.disabled = endis;
657
		document.iform.dhcpleaseinlocaltime.disabled = endis;
658
		document.iform.ddnsdomain.disabled = endis;
659
		document.iform.ddnsdomainprimary.disabled = endis;
660
		document.iform.ddnsdomainkeyname.disabled = endis;
661
		document.iform.ddnsdomainkey.disabled = endis;
662
		document.iform.ddnsupdate.disabled = endis;
663
		document.iform.mac_allow.disabled = endis;
664
		document.iform.mac_deny.disabled = endis;
665
		document.iform.ntp1.disabled = endis;
666
		document.iform.ntp2.disabled = endis;
667
		document.iform.tftp.disabled = endis;
668
		document.iform.ldap.disabled = endis;
669
		document.iform.netboot.disabled = endis;
670
		document.iform.nextserver.disabled = endis;
671
		document.iform.filename.disabled = endis;
672
		document.iform.filename32.disabled = endis;
673
		document.iform.filename64.disabled = endis;
674
		document.iform.rootpath.disabled = endis;
675
		document.iform.denyunknown.disabled = endis;
676
	}
677

    
678
	function show_shownumbervalue() {
679
		document.getElementById("shownumbervaluebox").innerHTML='';
680
		aodiv = document.getElementById('shownumbervalue');
681
		aodiv.style.display = "block";
682
	}
683

    
684
	function show_ddns_config() {
685
		document.getElementById("showddnsbox").innerHTML='';
686
		aodiv = document.getElementById('showddns');
687
		aodiv.style.display = "block";
688
	}
689

    
690
	function show_maccontrol_config() {
691
		document.getElementById("showmaccontrolbox").innerHTML='';
692
		aodiv = document.getElementById('showmaccontrol');
693
		aodiv.style.display = "block";
694
	}
695

    
696
	function show_ntp_config() {
697
		document.getElementById("showntpbox").innerHTML='';
698
		aodiv = document.getElementById('showntp');
699
		aodiv.style.display = "block";
700
	}
701

    
702
	function show_tftp_config() {
703
		document.getElementById("showtftpbox").innerHTML='';
704
		aodiv = document.getElementById('showtftp');
705
		aodiv.style.display = "block";
706
	}
707

    
708
	function show_ldap_config() {
709
		document.getElementById("showldapbox").innerHTML='';
710
		aodiv = document.getElementById('showldap');
711
		aodiv.style.display = "block";
712
	}
713

    
714
	function show_netboot_config() {
715
		document.getElementById("shownetbootbox").innerHTML='';
716
		aodiv = document.getElementById('shownetboot');
717
		aodiv.style.display = "block";
718
	}
719
//]]>
720
</script>
721
</head>
722

    
723
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
724
<?php include("fbegin.inc"); ?>
725
<form action="services_dhcp.php" method="post" name="iform" id="iform">
726
<?php if ($input_errors) print_input_errors($input_errors); ?>
727
<?php if ($savemsg) print_info_box($savemsg); ?>
728
<?php
729
	if (isset($config['dhcrelay']['enable'])) {
730
		echo gettext("DHCP Relay is currently enabled. Cannot enable the DHCP Server service while the DHCP Relay is enabled on any interface.");
731
		include("fend.inc");
732
		echo "</body>";
733
		echo "</html>";
734
		exit;
735
	}
736
?>
737
<?php if (is_subsystem_dirty('staticmaps')): ?><br/>
738
<?php print_info_box_np(gettext("The static mapping configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));?><br />
739
<?php endif; ?>
740
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp server">
741
<tr><td>
742
<?php
743
	/* active tabs */
744
	$tab_array = array();
745
	$tabscounter = 0;
746
	$i = 0;
747
	foreach ($iflist as $ifent => $ifname) {
748
		$oc = $config['interfaces'][$ifent];
749
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) ||
750
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr']))))
751
			continue;
752
		if ($ifent == $if)
753
			$active = true;
754
		else
755
			$active = false;
756
		$tab_array[] = array($ifname, $active, "services_dhcp.php?if={$ifent}");
757
		$tabscounter++;
758
	}
759
	if ($tabscounter == 0) {
760
		echo "<b>" . gettext("The DHCP Server can only be enabled on interfaces configured with a static IPv4 address. This system has none.") . "<br/><br/>";
761
		echo "</td></tr></table></form>";
762
		include("fend.inc");
763
		echo "</body>";
764
		echo "</html>";
765
		exit;
766
	}
767
	display_top_tabs($tab_array);
768
?>
769
</td></tr>
770
<tr>
771
<td>
772
	<div id="mainarea">
773
		<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
774
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
775
			<tr>
776
			<td width="22%" valign="top" class="vtable">&nbsp;</td>
777
			<td width="78%" class="vtable">
778
				<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onclick="enable_change(false)" />
779
			<strong><?php printf(gettext("Enable DHCP server on " .
780
			"%s " .
781
			"interface"),htmlspecialchars($iflist[$if]));?></strong></td>
782
			</tr>
783
			<?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
			<tr>
789
			<td width="22%" valign="top" class="vtable">&nbsp;</td>
790
			<td width="78%" class="vtable">
791
				<input name="denyunknown" id="denyunknown" type="checkbox" value="yes" <?php if ($pconfig['denyunknown']) echo "checked=\"checked\""; ?> />
792
				<strong><?=gettext("Deny unknown clients");?></strong><br />
793
				<?=gettext("If this is checked, only the clients defined below will get DHCP leases from this server. ");?></td>
794
			</tr>
795
			<?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
					<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>" />
800
				</td>
801
				</tr>
802
			<?php endif; ?>
803
			<tr>
804
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet");?></td>
805
			<td width="78%" class="vtable">
806
				<?=gen_subnet($ifcfgip, $ifcfgsn);?>
807
			</td>
808
			</tr>
809
			<tr>
810
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet mask");?></td>
811
			<td width="78%" class="vtable">
812
				<?=gen_subnet_mask($ifcfgsn);?>
813
			</td>
814
			</tr>
815
			<tr>
816
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Available range");?></td>
817
			<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
			<?php if (is_numeric($pool) || ($act == "newpool")): ?>
830
				<br />In-use DHCP Pool Ranges:
831
				<?php if (is_array($config['dhcpd'][$if]['range'])): ?>
832
					<br /><?php echo $config['dhcpd'][$if]['range']['from']; ?>-<?php echo $config['dhcpd'][$if]['range']['to']; ?>
833
				<?php endif; ?>
834
				<?php foreach ($a_pools as $p): ?>
835
					<?php if (is_array($p['range'])): ?>
836
					<br /><?php echo $p['range']['from']; ?>-<?php echo $p['range']['to']; ?>
837
					<?php endif; ?>
838
				<?php endforeach; ?>
839
			<?php endif; ?>
840
			</td>
841
			</tr>
842
			<?php if($is_olsr_enabled): ?>
843
			<tr>
844
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet Mask");?></td>
845
			<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
						if ($i == $pconfig['netmask']) echo "selected=\"selected\"";
852
						echo ">" . $i . "</option>";
853
					}
854
				}
855
				?>
856
				</select>
857
			</td>
858
			</tr>
859
			<?php endif; ?>
860
			<tr>
861
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Range");?></td>
862
			<td width="78%" class="vtable">
863
				<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
			</td>
866
			</tr>
867
			<?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
				<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="subnet">
873
				<tr>
874
					<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
					<td width="10%" class="list">
878
					<table border="0" cellspacing="0" cellpadding="1" summary="pool">
879
					<tr>
880
					<td valign="middle" width="17"></td>
881
					<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
					</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
				<td class="listlr" ondblclick="document.location='services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;pool=<?=$i;?>';">
891
					<?=htmlspecialchars($poolent['range']['from']);?>
892
				</td>
893
				<td class="listr" ondblclick="document.location='services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;pool=<?=$i;?>';">
894
					<?=htmlspecialchars($poolent['range']['to']);?>&nbsp;
895
				</td>
896
				<td class="listr" ondblclick="document.location='services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;pool=<?=$i;?>';">
897
					<?=htmlspecialchars($poolent['descr']);?>&nbsp;
898
				</td>
899
				<td valign="middle" class="list nowrap">
900
					<table border="0" cellspacing="0" cellpadding="1" summary="icons">
901
					<tr>
902
					<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
					</tr>
905
					</table>
906
				</td>
907
				</tr>
908
				<?php endif; ?>
909
				<?php $i++; endforeach; ?>
910
				<?php endif; ?>
911
				<tr>
912
				<td class="list" colspan="3"></td>
913
				<td class="list">
914
					<table border="0" cellspacing="0" cellpadding="1" summary="add">
915
					<tr>
916
					<td valign="middle" width="17"></td>
917
					<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
					</tr>
919
					</table>
920
				</td>
921
				</tr>
922
				</table>
923
			</td>
924
			</tr>
925
			<?php endif; ?>
926
			<tr>
927
			<td width="22%" valign="top" class="vncell"><?=gettext("WINS servers");?></td>
928
			<td width="78%" class="vtable">
929
				<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
			</td>
932
			</tr>
933
			<tr>
934
			<td width="22%" valign="top" class="vncell"><?=gettext("DNS servers");?></td>
935
			<td width="78%" class="vtable">
936
				<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
				<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
				<?=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
			</td>
942
			</tr>
943
			<tr>
944
			<td width="22%" valign="top" class="vncell"><?=gettext("Gateway");?></td>
945
			<td width="78%" class="vtable">
946
				<input name="gateway" type="text" class="formfld host" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>" /><br />
947
				<?=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
			</td>
949
			</tr>
950
			<tr>
951
			<td width="22%" valign="top" class="vncell"><?=gettext("Domain name");?></td>
952
			<td width="78%" class="vtable">
953
				<input name="domain" type="text" class="formfld unknown" id="domain" size="20" value="<?=htmlspecialchars($pconfig['domain']);?>" /><br />
954
				<?=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
			</td>
956
			</tr>
957
			<tr>
958
			<td width="22%" valign="top" class="vncell"><?=gettext("Domain search list");?></td>
959
			<td width="78%" class="vtable">
960
				<input name="domainsearchlist" type="text" class="formfld unknown" id="domainsearchlist" size="20" value="<?=htmlspecialchars($pconfig['domainsearchlist']);?>" /><br />
961
				<?=gettext("The DHCP server can optionally provide a domain search list. Use the semicolon character as separator ");?>
962
			</td>
963
			</tr>
964
			<tr>
965
			<td width="22%" valign="top" class="vncell"><?=gettext("Default lease time");?></td>
966
			<td width="78%" class="vtable">
967
				<input name="deftime" type="text" class="formfld unknown" id="deftime" size="10" value="<?=htmlspecialchars($pconfig['deftime']);?>" />
968
				<?=gettext("seconds");?><br />
969
				<?=gettext("This is used for clients that do not ask for a specific " .
970
				"expiration time."); ?><br />
971
				<?=gettext("The default is 7200 seconds.");?>
972
			</td>
973
			</tr>
974
			<tr>
975
			<td width="22%" valign="top" class="vncell"><?=gettext("Maximum lease time");?></td>
976
			<td width="78%" class="vtable">
977
				<input name="maxtime" type="text" class="formfld unknown" id="maxtime" size="10" value="<?=htmlspecialchars($pconfig['maxtime']);?>" />
978
				<?=gettext("seconds");?><br />
979
				<?=gettext("This is the maximum lease time for clients that ask".
980
				" for a specific expiration time."); ?><br />
981
				<?=gettext("The default is 86400 seconds.");?>
982
			</td>
983
			</tr>
984
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
985
			<tr>
986
			<td width="22%" valign="top" class="vncell"><?=gettext("Failover peer IP:");?></td>
987
			<td width="78%" class="vtable">
988
				<input name="failover_peerip" type="text" class="formfld host" id="failover_peerip" size="20" value="<?=htmlspecialchars($pconfig['failover_peerip']);?>" /><br />
989
				<?=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
			</td>
991
			</tr>
992
			<?php endif; ?>
993
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
994
			<tr>
995
			<td width="22%" valign="top" class="vncell"><?=gettext("Static ARP");?></td>
996
			<td width="78%" class="vtable">
997
				<table summary="static arp">
998
					<tr>
999
					<td>
1000
						<input style="vertical-align:middle" type="checkbox" value="yes" name="staticarp" id="staticarp" <?php if($pconfig['staticarp']) echo " checked=\"checked\""; ?> />&nbsp;
1001
					</td>
1002
					<td><b><?=gettext("Enable Static ARP entries");?></b></td>
1003
					</tr>
1004
					<tr>
1005
					<td>&nbsp;</td>
1006
					<td>
1007
						<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
					</td>
1009
					</tr>
1010
				</table>
1011
			</td>
1012
			</tr>
1013
			<?php endif; ?>
1014
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
1015
			<tr>
1016
				<td width="22%" valign="top" class="vncell"><?=gettext("Time format change"); ?></td>
1017
				<td width="78%" class="vtable">
1018
				<table summary="time format">
1019
					<tr>
1020
					<td>
1021
						<input name="dhcpleaseinlocaltime" type="checkbox" id="dhcpleaseinlocaltime" value="yes" <?php if ($pconfig['dhcpleaseinlocaltime']) echo "checked=\"checked\""; ?> />
1022
					</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
						<span class="red"><strong><?=gettext("Note:");?></strong></span> <?=gettext("By default DHCP leases are displayed in UTC time.  By checking this
1033
						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
			<?php endif; ?>
1040
			<tr>
1041
			<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic DNS");?></td>
1042
			<td width="78%" class="vtable">
1043
				<div id="showddnsbox">
1044
					<input type="button" onclick="show_ddns_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show Dynamic DNS");?>
1045
				</div>
1046
				<div id="showddns" style="display:none">
1047
					<input style="vertical-align:middle" type="checkbox" value="yes" name="ddnsupdate" id="ddnsupdate" <?php if($pconfig['ddnsupdate']) echo " checked=\"checked\""; ?> />&nbsp;
1048
					<b><?=gettext("Enable registration of DHCP client names in DNS.");?></b><br />
1049
					<br/>
1050
					<input name="ddnsdomain" type="text" class="formfld unknown" id="ddnsdomain" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomain']);?>" /><br />
1051
					<?=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.");?><br />
1053
					<input name="ddnsdomainprimary" type="text" class="formfld unknown" id="ddnsdomainprimary" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomainprimary']);?>" /><br />
1054
					<?=gettext("Enter the primary domain name server IP address for the dynamic domain name.");?><br />
1055
					<input name="ddnsdomainkeyname" type="text" class="formfld unknown" id="ddnsdomainkeyname" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomainkeyname']);?>" /><br />
1056
					<?=gettext("Enter the dynamic DNS domain key name which will be used to register client names in the DNS server.");?><br />
1057
					<input name="ddnsdomainkey" type="text" class="formfld unknown" id="ddnsdomainkey" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomainkey']);?>" /><br />
1058
					<?=gettext("Enter the dynamic DNS domain key secret which will be used to register client names in the DNS server.");?>
1059
				</div>
1060
			</td>
1061
			</tr>
1062
			<tr>
1063
			<td width="22%" valign="top" class="vncell"><?=gettext("MAC Address Control");?></td>
1064
			<td width="78%" class="vtable">
1065
				<div id="showmaccontrolbox">
1066
					<input type="button" onclick="show_maccontrol_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show MAC Address Control");?>
1067
				</div>
1068
				<div id="showmaccontrol" style="display:none">
1069
					<input name="mac_allow" type="text" class="formfld unknown" id="mac_allow" size="20" value="<?=htmlspecialchars($pconfig['mac_allow']);?>" /><br />
1070
					<?=gettext("Enter a list of partial MAC addresses to allow, comma separated, no spaces, such as ");?>00:00:00,01:E5:FF<br />
1071
					<input name="mac_deny" type="text" class="formfld unknown" id="mac_deny" size="20" value="<?=htmlspecialchars($pconfig['mac_deny']);?>" /><br />
1072
					<?=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
			<td width="22%" valign="top" class="vncell"><?=gettext("NTP servers");?></td>
1078
			<td width="78%" class="vtable">
1079
				<div id="showntpbox">
1080
					<input type="button" onclick="show_ntp_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show NTP configuration");?>
1081
				</div>
1082
				<div id="showntp" style="display:none">
1083
					<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
				</div>
1086
			</td>
1087
			</tr>
1088
			<tr>
1089
			<td width="22%" valign="top" class="vncell"><?=gettext("TFTP server");?></td>
1090
			<td width="78%" class="vtable">
1091
			<div id="showtftpbox">
1092
				<input type="button" onclick="show_tftp_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show TFTP configuration");?>
1093
			</div>
1094
			<div id="showtftp" style="display:none">
1095
				<input name="tftp" type="text" class="formfld unknown" id="tftp" size="50" value="<?=htmlspecialchars($pconfig['tftp']);?>" /><br />
1096
				<?=gettext("Leave blank to disable.  Enter a full hostname or IP for the TFTP server.");?>
1097
			</div>
1098
			</td>
1099
			</tr>
1100
			<tr>
1101
			<td width="22%" valign="top" class="vncell"><?=gettext("LDAP URI");?></td>
1102
			<td width="78%" class="vtable">
1103
				<div id="showldapbox">
1104
					<input type="button" onclick="show_ldap_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show LDAP configuration");?>
1105
				</div>
1106
				<div id="showldap" style="display:none">
1107
					<input name="ldap" type="text" class="formfld unknown" id="ldap" size="80" value="<?=htmlspecialchars($pconfig['ldap']);?>" /><br />
1108
					<?=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
				</div>
1110
			</td>
1111
			</tr>
1112
			<tr>
1113
			<td width="22%" valign="top" class="vncell"><?=gettext("Enable network booting");?></td>
1114
			<td width="78%" class="vtable">
1115
				<div id="shownetbootbox">
1116
					<input type="button" onclick="show_netboot_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show Network booting");?>
1117
				</div>
1118
				<div id="shownetboot" style="display:none">
1119
					<input style="vertical-align:middle" type="checkbox" value="yes" name="netboot" id="netboot" <?php if($pconfig['netboot']) echo " checked=\"checked\""; ?> />&nbsp;
1120
					<b><?=gettext("Enables network booting.");?></b>
1121
					<br/>
1122
					<table border="0" cellspacing="0" cellpadding="2" summary="network booting">
1123
						<tr>
1124
							<td>
1125
								<?=gettext("Enter the IP of the"); ?> <b><?=gettext("next-server"); ?></b>
1126
							</td>
1127
							<td>
1128
								<input name="nextserver" type="text" class="formfld unknown" id="nextserver" size="20" value="<?=htmlspecialchars($pconfig['nextserver']);?>" /><br />
1129
							</td>
1130
						</tr>
1131
						<tr>
1132
							<td>
1133
								<?=gettext("and the default bios filename");?>
1134
							</td>
1135
							<td>
1136
								<input name="filename" type="text" class="formfld unknown" id="filename" size="20" value="<?=htmlspecialchars($pconfig['filename']);?>" /><br />
1137
							</td>
1138
						</tr>
1139
						<tr>
1140
							<td>
1141
								<?=gettext("and the UEFI 32bit filename  ");?>
1142
							</td>
1143
							<td>
1144
								<input name="filename32" type="text" class="formfld unknown" id="filename32" size="20" value="<?=htmlspecialchars($pconfig['filename32']);?>" /><br />
1145
							</td>
1146
						</tr>
1147
						<tr>
1148
							<td>
1149
								<?=gettext("and the UEFI 64bit filename  ");?>
1150
							</td>
1151
							<td>
1152
								<input name="filename64" type="text" class="formfld unknown" id="filename64" size="20" value="<?=htmlspecialchars($pconfig['filename64']);?>" /><br />
1153
							</td>
1154
						</tr>
1155
					</table>
1156
					<?=gettext("Note: You need both a filename and a boot server configured for this to work!");?>
1157
					<?=gettext("You will need all three filenames and a boot server configured for UEFI to work!");?>
1158
					<?=gettext("Enter the"); ?> <b><?=gettext("root-path"); ?></b>-<?=gettext("string");?>
1159
					<input name="rootpath" type="text" class="formfld unknown" id="rootpath" size="90" value="<?=htmlspecialchars($pconfig['rootpath']);?>" /><br />
1160
					<?=gettext("Note: string-format: iscsi:(servername):(protocol):(port):(LUN):targetname");?>
1161
				</div>
1162
			</td>
1163
			</tr>
1164
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
1165
			<tr>
1166
			<td width="22%" valign="top" class="vncell"><?=gettext("Additional BOOTP/DHCP Options");?></td>
1167
			<td width="78%" class="vtable">
1168
				<div id="shownumbervaluebox">
1169
					<input type="button" onclick="show_shownumbervalue()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show Additional BOOTP/DHCP Options");?>
1170
				</div>
1171
				<div id="shownumbervalue" style="display:none">
1172
				<table id="maintable" summary="bootp-dhcp options">
1173
				<tbody>
1174
				<tr>
1175
				<td colspan="3">
1176
					<div style="padding:5px; margin-top: 16px; margin-bottom: 16px; border:1px dashed #000066; background-color: #ffffff; color: #000000; font-size: 8pt;" id="itemhelp">
1177
					<?=gettext("Enter the DHCP option number and the value for each item you would like to include in the DHCP lease information.  For a list of available options please visit this"); ?> <a href="http://www.iana.org/assignments/bootp-dhcp-parameters/" target="_blank"><?=gettext("URL"); ?></a>
1178
					</div>
1179
				</td>
1180
				</tr>
1181
				<tr>
1182
				<td><div id="onecolumn"><?=gettext("Number");?></div></td>
1183
				<td><div id="twocolumn"><?=gettext("Type");?></div></td>
1184
				<td><div id="threecolumn"><?=gettext("Value");?></div></td>
1185
				</tr>
1186
				<?php $counter = 0; ?>
1187
				<?php
1188
					if($pconfig['numberoptions'])
1189
						foreach($pconfig['numberoptions']['item'] as $item):
1190
				?>
1191
					<?php
1192
						$number = $item['number'];
1193
						$itemtype = $item['type'];
1194
						$value = $item['value'];
1195
					?>
1196
				<tr>
1197
				<td>
1198
					<input autocomplete="off" name="number<?php echo $counter; ?>" type="text" class="formfld unknown" id="number<?php echo $counter; ?>" size="10" value="<?=htmlspecialchars($number);?>" />
1199
				</td>
1200
				<td>
1201
					<select name="itemtype<?php echo $counter; ?>" class="formselect" id="itemtype<?php echo $counter; ?>">
1202
					<?php
1203
					foreach ($customitemtypes as $typename => $typedescr) {
1204
						echo "<option value=\"{$typename}\" ";
1205
						if ($itemtype == $typename) echo "selected=\"selected\"";
1206
						echo ">" . $typedescr . "</option>";
1207
					}
1208
					?>
1209
					</select>
1210
				</td>
1211
				<td>
1212
					<input autocomplete="off" name="value<?php echo $counter; ?>" type="text" class="formfld unknown" id="value<?php echo $counter; ?>" size="40" value="<?=htmlspecialchars($value);?>" />
1213
				</td>
1214
				<td>
1215
					<a onclick="removeRow(this); return false;" href="#"><img border="0" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" alt="delete" /></a>
1216
				</td>
1217
				</tr>
1218
				<?php $counter++; ?>
1219
				<?php endforeach; ?>
1220
				</tbody>
1221
				</table>
1222
				<a onclick="javascript:addRowTo('maintable', 'formfldalias'); return false;" href="#">
1223
					<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="<?=gettext("add another entry");?>" />
1224
				</a>
1225
				<script type="text/javascript">
1226
				//<![CDATA[
1227
					field_counter_js = 3;
1228
					rows = 1;
1229
					totalrows = <?php echo $counter; ?>;
1230
					loaded = <?php echo $counter; ?>;
1231
				//]]>
1232
				</script>
1233
				</div>
1234

    
1235
				</td>
1236
			</tr>
1237
			<?php endif; ?>
1238
			<tr>
1239
			<td width="22%" valign="top">&nbsp;</td>
1240
			<td width="78%">
1241
				<?php if ($act == "newpool"): ?>
1242
				<input type="hidden" name="act" value="newpool" />
1243
				<?php endif; ?>
1244
				<?php if (is_numeric($pool)): ?>
1245
				<input type="hidden" name="pool" value="<?php echo $pool; ?>" />
1246
				<?php endif; ?>
1247
				<input name="if" type="hidden" value="<?=htmlspecialchars($if);?>" />
1248
				<input name="submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)" />
1249
			</td>
1250
			</tr>
1251
			<tr>
1252
			<td width="22%" valign="top">&nbsp;</td>
1253
			<td width="78%"> <p><span class="vexpl"><span class="red"><strong><?=gettext("Note:");?><br />
1254
				</strong></span><?=gettext("The DNS servers entered in"); ?> <a href="system.php"><?=gettext("System: " .
1255
				"General setup"); ?></a> <?=gettext("(or the"); ?> <a href="services_dnsmasq.php"><?=gettext("DNS " .
1256
				"forwarder"); ?></a>, <?=gettext("if enabled)"); ?> </span><span class="vexpl"><?=gettext("will " .
1257
				"be assigned to clients by the DHCP server."); ?><br />
1258
				<br />
1259
				<?=gettext("The DHCP lease table can be viewed on the"); ?> <a href="status_dhcp_leases.php"><?=gettext("Status: " .
1260
				"DHCP leases"); ?></a> <?=gettext("page."); ?><br />
1261
				</span></p>
1262
			</td>
1263
			</tr>
1264
		</table>
1265
		<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
1266
		<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="static mappings">
1267
		<tr>
1268
			<td colspan="5" valign="top" class="listtopic"><?=gettext("DHCP Static Mappings for this interface.");?></td>
1269
			<td>&nbsp;</td>
1270
		</tr>
1271
		<tr>
1272
			<td width="7%" class="listhdrr"><?=gettext("Static ARP");?></td>
1273
			<td width="18%" class="listhdrr"><?=gettext("MAC address");?></td>
1274
			<td width="15%" class="listhdrr"><?=gettext("IP address");?></td>
1275
			<td width="20%" class="listhdrr"><?=gettext("Hostname");?></td>
1276
			<td width="30%" class="listhdr"><?=gettext("Description");?></td>
1277
			<td width="10%" class="list">
1278
			<table border="0" cellspacing="0" cellpadding="1" summary="add">
1279
			<tr>
1280
			<td valign="middle" width="17"></td>
1281
			<td valign="middle"><a href="services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="add" /></a></td>
1282
			</tr>
1283
			</table>
1284
			</td>
1285
		</tr>
1286
			<?php if(is_array($a_maps)): ?>
1287
			<?php $i = 0; foreach ($a_maps as $mapent): ?>
1288
			<?php if($mapent['mac'] <> "" or $mapent['ipaddr'] <> ""): ?>
1289
		<tr>
1290
		<td align="center" class="listlr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>';">
1291
			<?php if (isset($mapent['arp_table_static_entry'])): ?>
1292
				<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_alert.gif" alt="ARP Table Static Entry" width="17" height="17" border="0" alt="alert" />
1293
			<?php endif; ?>
1294
		</td>
1295
		<td class="listlr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>';">
1296
			<?=htmlspecialchars($mapent['mac']);?>
1297
		</td>
1298
		<td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>';">
1299
			<?=htmlspecialchars($mapent['ipaddr']);?>&nbsp;
1300
		</td>
1301
		<td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>';">
1302
			<?=htmlspecialchars($mapent['hostname']);?>&nbsp;
1303
		</td>
1304
		<td class="listbg" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>';">
1305
			<?=htmlspecialchars($mapent['descr']);?>&nbsp;
1306
		</td>
1307
		<td valign="middle" class="list nowrap">
1308
			<table border="0" cellspacing="0" cellpadding="1" summary="icons">
1309
			<tr>
1310
			<td valign="middle"><a href="services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="edit" /></a></td>
1311
			<td valign="middle"><a href="services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this mapping?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="delete" /></a></td>
1312
			</tr>
1313
			</table>
1314
		</td>
1315
		</tr>
1316
		<?php endif; ?>
1317
		<?php $i++; endforeach; ?>
1318
		<?php endif; ?>
1319
		<tr>
1320
		<td class="list" colspan="5"></td>
1321
		<td class="list">
1322
			<table border="0" cellspacing="0" cellpadding="1" summary="add">
1323
			<tr>
1324
			<td valign="middle" width="17"></td>
1325
			<td valign="middle"><a href="services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="add" /></a></td>
1326
			</tr>
1327
			</table>
1328
		</td>
1329
		</tr>
1330
		</table>
1331
		<?php endif; ?>
1332
	</div>
1333
</td>
1334
</tr>
1335
</table>
1336
</form>
1337
<script type="text/javascript">
1338
//<![CDATA[
1339
enable_change(false);
1340
//]]>
1341
</script>
1342
<?php include("fend.inc"); ?>
1343
</body>
1344
</html>
(150-150/256)