Project

General

Profile

Download (58.1 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-2014 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
if (!$_GET['if'])
113
	$savemsg = gettext("The DHCP Server can only be enabled on interfaces configured with static IP addresses") . ".<br/><br/>" . gettext("Only interfaces configured with a static IP will be shown") . ".";
114

    
115
$iflist = get_configured_interface_with_descr();
116

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

    
129
$act = $_GET['act'];
130
if (!empty($_POST['act']))
131
	$act = $_POST['act'];
132

    
133
$a_pools = array();
134

    
135
if (is_array($config['dhcpd'][$if])){
136
	$pool = $_GET['pool'];
137
	if (is_numeric($_POST['pool']))
138
		$pool = $_POST['pool'];
139

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

    
146
	if (!is_array($config['dhcpd'][$if]['pool']))
147
		$config['dhcpd'][$if]['pool'] = array();
148
	$a_pools = &$config['dhcpd'][$if]['pool'];
149

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

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

    
174
		$pconfig['dhcpleaseinlocaltime'] = $dhcpleaseinlocaltime;
175

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

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

    
217
$ifcfgip = $config['interfaces'][$if]['ipaddr'];
218
$ifcfgsn = $config['interfaces'][$if]['subnet'];
219

    
220
function validate_partial_mac_list($maclist) {
221
	$macs = explode(',', $maclist);
222

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

    
230
if (isset($_POST['submit'])) {
231

    
232
	unset($input_errors);
233

    
234
	$pconfig = $_POST;
235

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

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

    
254
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
255

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
397
			foreach ($a_pools as $id => $p) {
398
				if (is_numeric($pool) && ($id == $pool))
399
					continue;
400

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

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

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

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

    
449
		$dhcpd_enable_changed = false;
450

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

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

    
481
		unset($dhcpdconf['winsserver']);
482
		if ($_POST['wins1'])
483
			$dhcpdconf['winsserver'][] = $_POST['wins1'];
484
		if ($_POST['wins2'])
485
			$dhcpdconf['winsserver'][] = $_POST['wins2'];
486

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

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

    
509
		unset($dhcpdconf['ntpserver']);
510
		if ($_POST['ntp1'])
511
			$dhcpdconf['ntpserver'][] = $_POST['ntp1'];
512
		if ($_POST['ntp2'])
513
			$dhcpdconf['ntpserver'][] = $_POST['ntp2'];
514

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

    
524
		// Handle the custom options rowhelper
525
		if(isset($dhcpdconf['numberoptions']['item']))
526
			unset($dhcpdconf['numberoptions']['item']);
527

    
528
		$dhcpdconf['numberoptions'] = $numberoptions;
529

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

    
538
		write_config();
539
	}
540
}
541

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

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

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

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

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

    
601
include("head.inc");
602

    
603
?>
604

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

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

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

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

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

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

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

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

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

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

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

    
724
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
725
<?php include("fbegin.inc"); ?>
726
<form action="services_dhcp.php" method="post" name="iform" id="iform">
727
<?php if ($input_errors) print_input_errors($input_errors); ?>
728
<?php if ($savemsg) print_info_box($savemsg); ?>
729
<?php
730
	if (isset($config['dhcrelay']['enable'])) {
731
		echo gettext("DHCP Relay is currently enabled. Cannot enable the DHCP Server service while the DHCP Relay is enabled on any interface.");
732
		include("fend.inc");
733
		echo "</body>";
734
		echo "</html>";
735
		exit;
736
	}
737
?>
738
<?php if (is_subsystem_dirty('staticmaps')): ?><br/>
739
<?php print_info_box_np(gettext("The static mapping configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));?><br />
740
<?php endif; ?>
741
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp server">
742
<tr><td>
743
<?php
744
	/* active tabs */
745
	$tab_array = array();
746
	$tabscounter = 0;
747
	$i = 0;
748
	foreach ($iflist as $ifent => $ifname) {
749
		$oc = $config['interfaces'][$ifent];
750
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) ||
751
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr']))))
752
			continue;
753
		if ($ifent == $if)
754
			$active = true;
755
		else
756
			$active = false;
757
		$tab_array[] = array($ifname, $active, "services_dhcp.php?if={$ifent}");
758
		$tabscounter++;
759
	}
760
	if ($tabscounter == 0) {
761
		echo "</td></tr></table></form>";
762
		include("fend.inc");
763
		echo "</body>";
764
		echo "</html>";
765
		exit;
766
	}
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.");?>
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.");?>
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
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
					<?=gettext("Enter the IP of the"); ?> <b><?=gettext("next-server"); ?></b>
1123
					<input name="nextserver" type="text" class="formfld unknown" id="nextserver" size="20" value="<?=htmlspecialchars($pconfig['nextserver']);?>" /><br />
1124
					<?=gettext("and the default bios filename");?>
1125
						<input name="filename" type="text" class="formfld unknown" id="filename" size="20" value="<?=htmlspecialchars($pconfig['filename']);?>" /><br />
1126
					<?=gettext("and the UEFI 32bit filename  ");?>
1127
						<input name="filename32" type="text" class="formfld unknown" id="filename32" size="20" value="<?=htmlspecialchars($pconfig['filename32']);?>" /><br />
1128
					<?=gettext("and the UEFI 64bit filename  ");?>
1129
						<input name="filename64" type="text" class="formfld unknown" id="filename64" size="20" value="<?=htmlspecialchars($pconfig['filename64']);?>" /><br />
1130
					<?=gettext("Note: You need both a filename and a boot server configured for this to work!");?>
1131
					<?=gettext("You will need all three filenames and a boot server configured for UEFI to work!");?>
1132
					<?=gettext("Enter the"); ?> <b><?=gettext("root-path"); ?></b>-<?=gettext("string");?>
1133
					<input name="rootpath" type="text" class="formfld unknown" id="rootpath" size="90" value="<?=htmlspecialchars($pconfig['rootpath']);?>" /><br />
1134
					<?=gettext("Note: string-format: iscsi:(servername):(protocol):(port):(LUN):targetname");?>
1135
				</div>
1136
			</td>
1137
			</tr>
1138
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
1139
			<tr>
1140
			<td width="22%" valign="top" class="vncell"><?=gettext("Additional BOOTP/DHCP Options");?></td>
1141
			<td width="78%" class="vtable">
1142
				<div id="shownumbervaluebox">
1143
					<input type="button" onclick="show_shownumbervalue()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show Additional BOOTP/DHCP Options");?>
1144
				</div>
1145
				<div id="shownumbervalue" style="display:none">
1146
				<table id="maintable" summary="bootp-dhcp options">
1147
				<tbody>
1148
				<tr>
1149
				<td colspan="3">
1150
					<div style="padding:5px; margin-top: 16px; margin-bottom: 16px; border:1px dashed #000066; background-color: #ffffff; color: #000000; font-size: 8pt;" id="itemhelp">
1151
					<?=gettext("Enter the DHCP option number and the value for each item you would like to include in the DHCP lease information.  For a list of available options please visit this"); ?> <a href="http://www.iana.org/assignments/bootp-dhcp-parameters/" target="_blank"><?=gettext("URL"); ?></a>
1152
					</div>
1153
				</td>
1154
				</tr>
1155
				<tr>
1156
				<td><div id="onecolumn"><?=gettext("Number");?></div></td>
1157
				<td><div id="twocolumn"><?=gettext("Type");?></div></td>
1158
				<td><div id="threecolumn"><?=gettext("Value");?></div></td>
1159
				</tr>
1160
				<?php $counter = 0; ?>
1161
				<?php
1162
					if($pconfig['numberoptions'])
1163
						foreach($pconfig['numberoptions']['item'] as $item):
1164
				?>
1165
					<?php
1166
						$number = $item['number'];
1167
						$itemtype = $item['type'];
1168
						$value = $item['value'];
1169
					?>
1170
				<tr>
1171
				<td>
1172
					<input autocomplete="off" name="number<?php echo $counter; ?>" type="text" class="formfld unknown" id="number<?php echo $counter; ?>" size="10" value="<?=htmlspecialchars($number);?>" />
1173
				</td>
1174
				<td>
1175
					<select name="itemtype<?php echo $counter; ?>" class="formselect" id="itemtype<?php echo $counter; ?>">
1176
					<?php
1177
					foreach ($customitemtypes as $typename => $typedescr) {
1178
						echo "<option value=\"{$typename}\" ";
1179
						if ($itemtype == $typename) echo "selected=\"selected\"";
1180
						echo ">" . $typedescr . "</option>";
1181
					}
1182
					?>
1183
					</select>
1184
				</td>
1185
				<td>
1186
					<input autocomplete="off" name="value<?php echo $counter; ?>" type="text" class="formfld unknown" id="value<?php echo $counter; ?>" size="40" value="<?=htmlspecialchars($value);?>" />
1187
				</td>
1188
				<td>
1189
					<a onclick="removeRow(this); return false;" href="#"><img border="0" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" alt="delete" /></a>
1190
				</td>
1191
				</tr>
1192
				<?php $counter++; ?>
1193
				<?php endforeach; ?>
1194
				</tbody>
1195
				</table>
1196
				<a onclick="javascript:addRowTo('maintable', 'formfldalias'); return false;" href="#">
1197
					<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="<?=gettext("add another entry");?>" />
1198
				</a>
1199
				<script type="text/javascript">
1200
				//<![CDATA[
1201
					field_counter_js = 3;
1202
					rows = 1;
1203
					totalrows = <?php echo $counter; ?>;
1204
					loaded = <?php echo $counter; ?>;
1205
				//]]>
1206
				</script>
1207
				</div>
1208

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