Project

General

Profile

Download (60.2 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
$if = $_GET['if'];
53
if (!empty($_POST['if'])) {
54
	$if = $_POST['if'];
55
}
56

    
57
/* if OLSRD is enabled, allow WAN to house DHCP. */
58
if ($config['installedpackages']['olsrd']) {
59
	foreach ($config['installedpackages']['olsrd']['config'] as $olsrd) {
60
		if ($olsrd['enable']) {
61
			$is_olsr_enabled = true;
62
			break;
63
		}
64
	}
65
}
66

    
67
$iflist = get_configured_interface_with_descr();
68

    
69
/* set the starting interface */
70
if (!$if || !isset($iflist[$if])) {
71
	foreach ($iflist as $ifent => $ifname) {
72
		$oc = $config['interfaces'][$ifent];
73
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) ||
74
		    (!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr'])))) {
75
			continue;
76
		}
77
		$if = $ifent;
78
		break;
79
	}
80
}
81

    
82
$act = $_GET['act'];
83
if (!empty($_POST['act'])) {
84
	$act = $_POST['act'];
85
}
86

    
87
$a_pools = array();
88

    
89
if (is_array($config['dhcpd'][$if])) {
90
	$pool = $_GET['pool'];
91
	if (is_numeric($_POST['pool'])) {
92
		$pool = $_POST['pool'];
93
	}
94

    
95
	// If we have a pool but no interface name, that's not valid. Redirect away.
96
	if (is_numeric($pool) && empty($if)) {
97
		header("Location: services_dhcp.php");
98
		exit;
99
	}
100

    
101
	if (!is_array($config['dhcpd'][$if]['pool'])) {
102
		$config['dhcpd'][$if]['pool'] = array();
103
	}
104
	$a_pools = &$config['dhcpd'][$if]['pool'];
105

    
106
	if (is_numeric($pool) && $a_pools[$pool]) {
107
		$dhcpdconf = &$a_pools[$pool];
108
	} elseif ($act == "newpool") {
109
		$dhcpdconf = array();
110
	} else {
111
		$dhcpdconf = &$config['dhcpd'][$if];
112
	}
113
}
114
if (is_array($dhcpdconf)) {
115
	// Global Options
116
	if (!is_numeric($pool) && !($act == "newpool")) {
117
		$pconfig['enable'] = isset($dhcpdconf['enable']);
118
		$pconfig['staticarp'] = isset($dhcpdconf['staticarp']);
119
		// No reason to specify this per-pool, per the dhcpd.conf man page it needs to be in every
120
		//   pool and should be specified in every pool both nodes share, so we'll treat it as global
121
		$pconfig['failover_peerip'] = $dhcpdconf['failover_peerip'];
122

    
123
		// dhcpleaseinlocaltime is global to all interfaces. So if it is selected on any interface,
124
		// then show it true/checked.
125
		foreach ($config['dhcpd'] as $dhcpdifitem) {
126
			$dhcpleaseinlocaltime = $dhcpdifitem['dhcpleaseinlocaltime'];
127
			if ($dhcpleaseinlocaltime) {
128
				break;
129
			}
130
		}
131

    
132
		$pconfig['dhcpleaseinlocaltime'] = $dhcpleaseinlocaltime;
133

    
134
		if (!is_array($dhcpdconf['staticmap'])) {
135
			$dhcpdconf['staticmap'] = array();
136
		}
137
		$a_maps = &$dhcpdconf['staticmap'];
138
	} else {
139
		// Options that exist only in pools
140
		$pconfig['descr'] = $dhcpdconf['descr'];
141
	}
142

    
143
	// Options that can be global or per-pool.
144
	if (is_array($dhcpdconf['range'])) {
145
		$pconfig['range_from'] = $dhcpdconf['range']['from'];
146
		$pconfig['range_to'] = $dhcpdconf['range']['to'];
147
	}
148
	$pconfig['deftime'] = $dhcpdconf['defaultleasetime'];
149
	$pconfig['maxtime'] = $dhcpdconf['maxleasetime'];
150
	$pconfig['gateway'] = $dhcpdconf['gateway'];
151
	$pconfig['domain'] = $dhcpdconf['domain'];
152
	$pconfig['domainsearchlist'] = $dhcpdconf['domainsearchlist'];
153
	list($pconfig['wins1'], $pconfig['wins2']) = $dhcpdconf['winsserver'];
154
	list($pconfig['dns1'], $pconfig['dns2'], $pconfig['dns3'], $pconfig['dns4']) = $dhcpdconf['dnsserver'];
155
	$pconfig['denyunknown'] = isset($dhcpdconf['denyunknown']);
156
	$pconfig['ddnsdomain'] = $dhcpdconf['ddnsdomain'];
157
	$pconfig['ddnsdomainprimary'] = $dhcpdconf['ddnsdomainprimary'];
158
	$pconfig['ddnsdomainkeyname'] = $dhcpdconf['ddnsdomainkeyname'];
159
	$pconfig['ddnsdomainkey'] = $dhcpdconf['ddnsdomainkey'];
160
	$pconfig['ddnsupdate'] = isset($dhcpdconf['ddnsupdate']);
161
	$pconfig['mac_allow'] = $dhcpdconf['mac_allow'];
162
	$pconfig['mac_deny'] = $dhcpdconf['mac_deny'];
163
	list($pconfig['ntp1'], $pconfig['ntp2']) = $dhcpdconf['ntpserver'];
164
	$pconfig['tftp'] = $dhcpdconf['tftp'];
165
	$pconfig['ldap'] = $dhcpdconf['ldap'];
166
	$pconfig['netboot'] = isset($dhcpdconf['netboot']);
167
	$pconfig['nextserver'] = $dhcpdconf['nextserver'];
168
	$pconfig['filename'] = $dhcpdconf['filename'];
169
	$pconfig['filename32'] = $dhcpdconf['filename32'];
170
	$pconfig['filename64'] = $dhcpdconf['filename64'];
171
	$pconfig['rootpath'] = $dhcpdconf['rootpath'];
172
	$pconfig['netmask'] = $dhcpdconf['netmask'];
173
	$pconfig['numberoptions'] = $dhcpdconf['numberoptions'];
174
}
175

    
176
$ifcfgip = $config['interfaces'][$if]['ipaddr'];
177
$ifcfgsn = $config['interfaces'][$if]['subnet'];
178

    
179
function validate_partial_mac_list($maclist) {
180
	$macs = explode(',', $maclist);
181

    
182
	// Loop through and look for invalid MACs.
183
	foreach ($macs as $mac) {
184
		if (!is_macaddr($mac, true)) {
185
			return false;
186
		}
187
	}
188
	return true;
189
}
190

    
191
if (isset($_POST['submit'])) {
192

    
193
	unset($input_errors);
194

    
195
	$pconfig = $_POST;
196

    
197
	$numberoptions = array();
198
	for ($x = 0; $x < 99; $x++) {
199
		if (isset($_POST["number{$x}"]) && ctype_digit($_POST["number{$x}"])) {
200
			$numbervalue = array();
201
			$numbervalue['number'] = htmlspecialchars($_POST["number{$x}"]);
202
			$numbervalue['type'] = htmlspecialchars($_POST["itemtype{$x}"]);
203
			$numbervalue['value'] = str_replace('&quot;', '"', htmlspecialchars($_POST["value{$x}"]));
204
			$numberoptions['item'][] = $numbervalue;
205
		}
206
	}
207
	// Reload the new pconfig variable that the form uses.
208
	$pconfig['numberoptions'] = $numberoptions;
209

    
210
	/* input validation */
211
	if ($_POST['enable'] || is_numeric($pool) || $act == "newpool") {
212
		$reqdfields = explode(" ", "range_from range_to");
213
		$reqdfieldsn = array(gettext("Range begin"), gettext("Range end"));
214

    
215
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
216

    
217
		if (($_POST['range_from'] && !is_ipaddrv4($_POST['range_from']))) {
218
			$input_errors[] = gettext("A valid range must be specified.");
219
		}
220
		if (($_POST['range_to'] && !is_ipaddrv4($_POST['range_to']))) {
221
			$input_errors[] = gettext("A valid range must be specified.");
222
		}
223
		if (($_POST['gateway'] && $_POST['gateway'] != "none" && !is_ipaddrv4($_POST['gateway']))) {
224
			$input_errors[] = gettext("A valid IP address must be specified for the gateway.");
225
		}
226
		if (($_POST['wins1'] && !is_ipaddrv4($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddrv4($_POST['wins2']))) {
227
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary WINS servers.");
228
		}
229
		$parent_ip = get_interface_ip($_POST['if']);
230
		if (is_ipaddrv4($parent_ip) && $_POST['gateway'] && $_POST['gateway'] != "none") {
231
			$parent_sn = get_interface_subnet($_POST['if']);
232
			if (!ip_in_subnet($_POST['gateway'], gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn) && !ip_in_interface_alias_subnet($_POST['if'], $_POST['gateway'])) {
233
				$input_errors[] = sprintf(gettext("The gateway address %s does not lie within the chosen interface's subnet."), $_POST['gateway']);
234
			}
235
		}
236
		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']))) {
237
			$input_errors[] = gettext("A valid IP address must be specified for each of the DNS servers.");
238
		}
239

    
240
		if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60))) {
241
			$input_errors[] = gettext("The default lease time must be at least 60 seconds.");
242
		}
243

    
244
		if (isset($config['captiveportal']) && is_array($config['captiveportal'])) {
245
			$deftime = 7200; // Default value if it's empty
246
			if (is_numeric($_POST['deftime'])) {
247
				$deftime = $_POST['deftime'];
248
			}
249

    
250
			foreach ($config['captiveportal'] as $cpZone => $cpdata) {
251
				if (!isset($cpdata['enable'])) {
252
					continue;
253
				}
254
				if (!isset($cpdata['timeout']) || !is_numeric($cpdata['timeout'])) {
255
					continue;
256
				}
257
				$cp_ifs = explode(',', $cpdata['interface']);
258
				if (!in_array($if, $cp_ifs)) {
259
					continue;
260
				}
261
				if ($cpdata['timeout'] > $deftime) {
262
					$input_errors[] = sprintf(gettext(
263
						"The Captive Portal zone '%s' has Hard Timeout parameter set to a value bigger than Default lease time (%s)."), $cpZone, $deftime);
264
				}
265
			}
266
		}
267

    
268
		if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime']))) {
269
			$input_errors[] = gettext("The maximum lease time must be at least 60 seconds and higher than the default lease time.");
270
		}
271
		if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain']))) {
272
			$input_errors[] = gettext("A valid domain name must be specified for the dynamic DNS registration.");
273
		}
274
		if (($_POST['ddnsdomain'] && !is_ipaddrv4($_POST['ddnsdomainprimary']))) {
275
			$input_errors[] = gettext("A valid primary domain name server IP address must be specified for the dynamic domain name.");
276
		}
277
		if (($_POST['ddnsdomainkey'] && !$_POST['ddnsdomainkeyname']) ||
278
		    ($_POST['ddnsdomainkeyname'] && !$_POST['ddnsdomainkey'])) {
279
			$input_errors[] = gettext("You must specify both a valid domain key and key name.");
280
		}
281
		if ($_POST['domainsearchlist']) {
282
			$domain_array = preg_split("/[ ;]+/", $_POST['domainsearchlist']);
283
			foreach ($domain_array as $curdomain) {
284
				if (!is_domain($curdomain)) {
285
					$input_errors[] = gettext("A valid domain search list must be specified.");
286
					break;
287
				}
288
			}
289
		}
290

    
291
		// Validate MACs
292
		if (!empty($_POST['mac_allow']) && !validate_partial_mac_list($_POST['mac_allow'])) {
293
			$input_errors[] = gettext("If you specify a mac allow list, it must contain only valid partial MAC addresses.");
294
		}
295
		if (!empty($_POST['mac_deny']) && !validate_partial_mac_list($_POST['mac_deny'])) {
296
			$input_errors[] = gettext("If you specify a mac deny list, it must contain only valid partial MAC addresses.");
297
		}
298

    
299
		if (($_POST['ntp1'] && !is_ipaddrv4($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddrv4($_POST['ntp2']))) {
300
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary NTP servers.");
301
		}
302
		if (($_POST['domain'] && !is_domain($_POST['domain']))) {
303
			$input_errors[] = gettext("A valid domain name must be specified for the DNS domain.");
304
		}
305
		if ($_POST['tftp'] && !is_ipaddrv4($_POST['tftp']) && !is_domain($_POST['tftp']) && !is_URL($_POST['tftp'])) {
306
			$input_errors[] = gettext("A valid IP address or hostname must be specified for the TFTP server.");
307
		}
308
		if (($_POST['nextserver'] && !is_ipaddrv4($_POST['nextserver']))) {
309
			$input_errors[] = gettext("A valid IP address must be specified for the network boot server.");
310
		}
311

    
312
		if (gen_subnet($ifcfgip, $ifcfgsn) == $_POST['range_from']) {
313
			$input_errors[] = gettext("You cannot use the network address in the starting subnet range.");
314
		}
315
		if (gen_subnet_max($ifcfgip, $ifcfgsn) == $_POST['range_to']) {
316
			$input_errors[] = gettext("You cannot use the broadcast address in the ending subnet range.");
317
		}
318

    
319
		// Disallow a range that includes the virtualip
320
		if (is_array($config['virtualip']['vip'])) {
321
			foreach ($config['virtualip']['vip'] as $vip) {
322
				if ($vip['interface'] == $if) {
323
					if ($vip['subnet'] && is_inrange_v4($vip['subnet'], $_POST['range_from'], $_POST['range_to'])) {
324
						$input_errors[] = sprintf(gettext("The subnet range cannot overlap with virtual IP address %s."), $vip['subnet']);
325
					}
326
				}
327
			}
328
		}
329

    
330
		$noip = false;
331
		if (is_array($a_maps)) {
332
			foreach ($a_maps as $map) {
333
				if (empty($map['ipaddr'])) {
334
					$noip = true;
335
				}
336
			}
337
		}
338
		if ($_POST['staticarp'] && $noip) {
339
			$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.";
340
		}
341

    
342
		if (is_array($pconfig['numberoptions']['item'])) {
343
			foreach ($pconfig['numberoptions']['item'] as $numberoption) {
344
				if ($numberoption['type'] == 'text' && strstr($numberoption['value'], '"')) {
345
					$input_errors[] = gettext("Text type cannot include quotation marks.");
346
				} else if ($numberoption['type'] == 'string' && !preg_match('/^"[^"]*"$/', $numberoption['value']) && !preg_match('/^[0-9a-f]{2}(?:\:[0-9a-f]{2})*$/i', $numberoption['value'])) {
347
					$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");
348
				} else if ($numberoption['type'] == 'boolean' && $numberoption['value'] != 'true' && $numberoption['value'] != 'false' && $numberoption['value'] != 'on' && $numberoption['value'] != 'off') {
349
					$input_errors[] = gettext("Boolean type must be true, false, on, or off.");
350
				} else if ($numberoption['type'] == 'unsigned integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 255)) {
351
					$input_errors[] = gettext("Unsigned 8-bit integer type must be a number in the range 0 to 255.");
352
				} else if ($numberoption['type'] == 'unsigned integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 65535)) {
353
					$input_errors[] = gettext("Unsigned 16-bit integer type must be a number in the range 0 to 65535.");
354
				} else if ($numberoption['type'] == 'unsigned integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 4294967295)) {
355
					$input_errors[] = gettext("Unsigned 32-bit integer type must be a number in the range 0 to 4294967295.");
356
				} else if ($numberoption['type'] == 'signed integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -128 || $numberoption['value'] > 127)) {
357
					$input_errors[] = gettext("Signed 8-bit integer type must be a number in the range -128 to 127.");
358
				} else if ($numberoption['type'] == 'signed integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -32768 || $numberoption['value'] > 32767)) {
359
					$input_errors[] = gettext("Signed 16-bit integer type must be a number in the range -32768 to 32767.");
360
				} else if ($numberoption['type'] == 'signed integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -2147483648 || $numberoption['value'] > 2147483647)) {
361
					$input_errors[] = gettext("Signed 32-bit integer type must be a number in the range -2147483648 to 2147483647.");
362
				} else if ($numberoption['type'] == 'ip-address' && !is_ipaddrv4($numberoption['value']) && !is_hostname($numberoption['value'])) {
363
					$input_errors[] = gettext("IP address or host type must be an IP address or host name.");
364
				}
365
			}
366
		}
367

    
368
		if (!$input_errors) {
369
			/* make sure the range lies within the current subnet */
370
			$subnet_start = ip2ulong(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
371
			$subnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
372

    
373
			if ((ip2ulong($_POST['range_from']) < $subnet_start) || (ip2ulong($_POST['range_from']) > $subnet_end) ||
374
			    (ip2ulong($_POST['range_to']) < $subnet_start) || (ip2ulong($_POST['range_to']) > $subnet_end)) {
375
				$input_errors[] = gettext("The specified range lies outside of the current subnet.");
376
			}
377

    
378
			if (ip2ulong($_POST['range_from']) > ip2ulong($_POST['range_to'])) {
379
				$input_errors[] = gettext("The range is invalid (first element higher than second element).");
380
			}
381

    
382
			if (is_numeric($pool) || ($act == "newpool")) {
383
				$rfrom = $config['dhcpd'][$if]['range']['from'];
384
				$rto = $config['dhcpd'][$if]['range']['to'];
385

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

    
391
			foreach ($a_pools as $id => $p) {
392
				if (is_numeric($pool) && ($id == $pool)) {
393
					continue;
394
				}
395

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

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

    
408
			$dynsubnet_start = ip2ulong($_POST['range_from']);
409
			$dynsubnet_end = ip2ulong($_POST['range_to']);
410
			if (is_array($a_maps)) {
411
				foreach ($a_maps as $map) {
412
					if (empty($map['ipaddr'])) {
413
						continue;
414
					}
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
				}
433
				$dhcpdconf = $config['dhcpd'][$if];
434
			}
435
		} else {
436
			if (is_array($a_pools[$pool])) {
437
				$dhcpdconf = $a_pools[$pool];
438
			} else {
439
				// Someone specified a pool but it doesn't exist. Punt.
440
				header("Location: services_dhcp.php");
441
				exit;
442
			}
443
		}
444
		if (!is_array($dhcpdconf['range'])) {
445
			$dhcpdconf['range'] = array();
446
		}
447

    
448
		$dhcpd_enable_changed = false;
449

    
450
		// Global Options
451
		if (!is_numeric($pool) && !($act == "newpool")) {
452
			$old_dhcpd_enable = isset($dhcpdconf['enable']);
453
			$new_dhcpd_enable = ($_POST['enable']) ? true : false;
454
			if ($old_dhcpd_enable != $new_dhcpd_enable) {
455
				/* DHCP has been enabled or disabled. The pf ruleset will need to be rebuilt to allow or disallow DHCP. */
456
				$dhcpd_enable_changed = true;
457
			}
458
			$dhcpdconf['enable'] = $new_dhcpd_enable;
459
			$dhcpdconf['staticarp'] = ($_POST['staticarp']) ? true : false;
460
			$previous = $dhcpdconf['failover_peerip'];
461
			if ($previous <> $_POST['failover_peerip']) {
462
				mwexec("/bin/rm -rf /var/dhcpd/var/db/*");
463
			}
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
		}
485
		if ($_POST['wins2']) {
486
			$dhcpdconf['winsserver'][] = $_POST['wins2'];
487
		}
488

    
489
		unset($dhcpdconf['dnsserver']);
490
		if ($_POST['dns1']) {
491
			$dhcpdconf['dnsserver'][] = $_POST['dns1'];
492
		}
493
		if ($_POST['dns2']) {
494
			$dhcpdconf['dnsserver'][] = $_POST['dns2'];
495
		}
496
		if ($_POST['dns3']) {
497
			$dhcpdconf['dnsserver'][] = $_POST['dns3'];
498
		}
499
		if ($_POST['dns4']) {
500
			$dhcpdconf['dnsserver'][] = $_POST['dns4'];
501
		}
502

    
503
		$dhcpdconf['gateway'] = $_POST['gateway'];
504
		$dhcpdconf['domain'] = $_POST['domain'];
505
		$dhcpdconf['domainsearchlist'] = $_POST['domainsearchlist'];
506
		$dhcpdconf['denyunknown'] = ($_POST['denyunknown']) ? true : false;
507
		$dhcpdconf['ddnsdomain'] = $_POST['ddnsdomain'];
508
		$dhcpdconf['ddnsdomainprimary'] = $_POST['ddnsdomainprimary'];
509
		$dhcpdconf['ddnsdomainkeyname'] = $_POST['ddnsdomainkeyname'];
510
		$dhcpdconf['ddnsdomainkey'] = $_POST['ddnsdomainkey'];
511
		$dhcpdconf['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
512
		$dhcpdconf['mac_allow'] = $_POST['mac_allow'];
513
		$dhcpdconf['mac_deny'] = $_POST['mac_deny'];
514

    
515
		unset($dhcpdconf['ntpserver']);
516
		if ($_POST['ntp1']) {
517
			$dhcpdconf['ntpserver'][] = $_POST['ntp1'];
518
		}
519
		if ($_POST['ntp2']) {
520
			$dhcpdconf['ntpserver'][] = $_POST['ntp2'];
521
		}
522

    
523
		$dhcpdconf['tftp'] = $_POST['tftp'];
524
		$dhcpdconf['ldap'] = $_POST['ldap'];
525
		$dhcpdconf['netboot'] = ($_POST['netboot']) ? true : false;
526
		$dhcpdconf['nextserver'] = $_POST['nextserver'];
527
		$dhcpdconf['filename'] = $_POST['filename'];
528
		$dhcpdconf['filename32'] = $_POST['filename32'];
529
		$dhcpdconf['filename64'] = $_POST['filename64'];
530
		$dhcpdconf['rootpath'] = $_POST['rootpath'];
531

    
532
		// Handle the custom options rowhelper
533
		if (isset($dhcpdconf['numberoptions']['item'])) {
534
			unset($dhcpdconf['numberoptions']['item']);
535
		}
536

    
537
		$dhcpdconf['numberoptions'] = $numberoptions;
538

    
539
		if (is_numeric($pool) && is_array($a_pools[$pool])) {
540
			$a_pools[$pool] = $dhcpdconf;
541
		} elseif ($act == "newpool") {
542
			$a_pools[] = $dhcpdconf;
543
		} else {
544
			$config['dhcpd'][$if] = $dhcpdconf;
545
		}
546

    
547
		write_config();
548
	}
549
}
550

    
551
if ((isset($_POST['submit']) || isset($_POST['apply'])) && (!$input_errors)) {
552
	$retval = 0;
553
	$retvaldhcp = 0;
554
	$retvaldns = 0;
555
	/* dnsmasq_configure calls dhcpd_configure */
556
	/* no need to restart dhcpd twice */
557
	if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic']))	{
558
		$retvaldns = services_dnsmasq_configure();
559
		if ($retvaldns == 0) {
560
			clear_subsystem_dirty('hosts');
561
			clear_subsystem_dirty('staticmaps');
562
		}
563
	} else if (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic'])) {
564
		$retvaldns = services_unbound_configure();
565
		if ($retvaldns == 0) {
566
			clear_subsystem_dirty('unbound');
567
			clear_subsystem_dirty('hosts');
568
			clear_subsystem_dirty('staticmaps');
569
		}
570
	} else {
571
		$retvaldhcp = services_dhcpd_configure();
572
		if ($retvaldhcp == 0) {
573
			clear_subsystem_dirty('staticmaps');
574
		}
575
	}
576
	if ($dhcpd_enable_changed) {
577
		$retvalfc = filter_configure();
578
	}
579

    
580
	if ($retvaldhcp == 1 || $retvaldns == 1 || $retvalfc == 1) {
581
		$retval = 1;
582
	}
583
	$savemsg = get_std_save_message($retval);
584
}
585

    
586
if ($act == "delpool") {
587
	if ($a_pools[$_GET['id']]) {
588
		unset($a_pools[$_GET['id']]);
589
		write_config();
590
		header("Location: services_dhcp.php?if={$if}");
591
		exit;
592
	}
593
}
594

    
595
if ($act == "del") {
596
	if ($a_maps[$_GET['id']]) {
597
		unset($a_maps[$_GET['id']]);
598
		write_config();
599
		if (isset($config['dhcpd'][$if]['enable'])) {
600
			mark_subsystem_dirty('staticmaps');
601
			if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic'])) {
602
				mark_subsystem_dirty('hosts');
603
			}
604
		}
605
		header("Location: services_dhcp.php?if={$if}");
606
		exit;
607
	}
608
}
609

    
610
$closehead = false;
611
$pgtitle = array(gettext("Services"), gettext("DHCP server"));
612
$shortcut_section = "dhcp";
613

    
614
include("head.inc");
615

    
616
?>
617

    
618
<script type="text/javascript" src="/javascript/row_helper.js">
619
</script>
620

    
621
<script type="text/javascript">
622
//<![CDATA[
623
	function itemtype_field(fieldname, fieldsize, n) {
624
		return '<select name="' + fieldname + n + '" class="formselect" id="' + fieldname + n + '"><?php
625
			$customitemtypes = array('text' => gettext('Text'), 'string' => gettext('String'), 'boolean' => gettext('Boolean'),
626
				'unsigned integer 8' => gettext('Unsigned 8-bit integer'), 'unsigned integer 16' => gettext('Unsigned 16-bit integer'), 'unsigned integer 32' => gettext('Unsigned 32-bit integer'),
627
				'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'));
628
			foreach ($customitemtypes as $typename => $typedescr) {
629
				echo "<option value=\"{$typename}\">{$typedescr}<\/option>";
630
			}
631
		?><\/select>';
632
	}
633

    
634
	rowname[0] = "number";
635
	rowtype[0] = "textbox";
636
	rowsize[0] = "10";
637
	rowname[1] = "itemtype";
638
	rowtype[1] = itemtype_field;
639
	rowname[2] = "value";
640
	rowtype[2] = "textbox";
641
	rowsize[2] = "40";
642
//]]>
643
</script>
644

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

    
692
	function show_shownumbervalue() {
693
		document.getElementById("shownumbervaluebox").innerHTML='';
694
		aodiv = document.getElementById('shownumbervalue');
695
		aodiv.style.display = "block";
696
	}
697

    
698
	function show_ddns_config() {
699
		document.getElementById("showddnsbox").innerHTML='';
700
		aodiv = document.getElementById('showddns');
701
		aodiv.style.display = "block";
702
	}
703

    
704
	function show_maccontrol_config() {
705
		document.getElementById("showmaccontrolbox").innerHTML='';
706
		aodiv = document.getElementById('showmaccontrol');
707
		aodiv.style.display = "block";
708
	}
709

    
710
	function show_ntp_config() {
711
		document.getElementById("showntpbox").innerHTML='';
712
		aodiv = document.getElementById('showntp');
713
		aodiv.style.display = "block";
714
	}
715

    
716
	function show_tftp_config() {
717
		document.getElementById("showtftpbox").innerHTML='';
718
		aodiv = document.getElementById('showtftp');
719
		aodiv.style.display = "block";
720
	}
721

    
722
	function show_ldap_config() {
723
		document.getElementById("showldapbox").innerHTML='';
724
		aodiv = document.getElementById('showldap');
725
		aodiv.style.display = "block";
726
	}
727

    
728
	function show_netboot_config() {
729
		document.getElementById("shownetbootbox").innerHTML='';
730
		aodiv = document.getElementById('shownetboot');
731
		aodiv.style.display = "block";
732
	}
733
//]]>
734
</script>
735
</head>
736

    
737
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
738
<?php include("fbegin.inc"); ?>
739
<form action="services_dhcp.php" method="post" name="iform" id="iform">
740
<?php if ($input_errors) print_input_errors($input_errors); ?>
741
<?php if ($savemsg) print_info_box($savemsg); ?>
742
<?php
743
	if (isset($config['dhcrelay']['enable'])) {
744
		echo gettext("DHCP Relay is currently enabled. Cannot enable the DHCP Server service while the DHCP Relay is enabled on any interface.");
745
		include("fend.inc");
746
		echo "</body>";
747
		echo "</html>";
748
		exit;
749
	}
750
?>
751
<?php if (is_subsystem_dirty('staticmaps')): ?><br/>
752
<?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 />
753
<?php endif; ?>
754
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp server">
755
	<tr>
756
		<td>
757
<?php
758
	/* active tabs */
759
	$tab_array = array();
760
	$tabscounter = 0;
761
	$i = 0;
762
	foreach ($iflist as $ifent => $ifname) {
763
		$oc = $config['interfaces'][$ifent];
764
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) ||
765
		    (!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr'])))) {
766
			continue;
767
		}
768
		if ($ifent == $if) {
769
			$active = true;
770
		} else {
771
			$active = false;
772
		}
773
		$tab_array[] = array($ifname, $active, "services_dhcp.php?if={$ifent}");
774
		$tabscounter++;
775
	}
776
	if ($tabscounter == 0) {
777
		echo "<b>" . gettext("The DHCP Server can only be enabled on interfaces configured with a static IPv4 address. This system has none.") . "<br/><br/>";
778
		echo "</td></tr></table></form>";
779
		include("fend.inc");
780
		echo "</body>";
781
		echo "</html>";
782
		exit;
783
	}
784
	display_top_tabs($tab_array);
785
?>
786
		</td>
787
	</tr>
788
	<tr>
789
		<td>
790
			<div id="mainarea">
791
			<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
792
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
793
				<tr>
794
					<td width="22%" valign="top" class="vtable">&nbsp;</td>
795
					<td width="78%" class="vtable">
796
						<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onclick="enable_change(false)" />
797
						<strong><?php printf(gettext("Enable DHCP server on %s interface"), htmlspecialchars($iflist[$if]));?></strong>
798
					</td>
799
				</tr>
800
			<?php else: ?>
801
				<tr>
802
					<td colspan="2" class="listtopic"><?php echo gettext("Editing Pool-Specific Options. To return to the Interface, click its tab above."); ?></td>
803
				</tr>
804
			<?php endif; ?>
805
				<tr>
806
					<td width="22%" valign="top" class="vtable">&nbsp;</td>
807
					<td width="78%" class="vtable">
808
						<input name="denyunknown" id="denyunknown" type="checkbox" value="yes" <?php if ($pconfig['denyunknown']) echo "checked=\"checked\""; ?> />
809
						<strong><?=gettext("Deny unknown clients");?></strong><br />
810
						<?=gettext("If this is checked, only the clients defined below will get DHCP leases from this server. ");?>
811
					</td>
812
				</tr>
813
			<?php if (is_numeric($pool) || ($act == "newpool")): ?>
814
				<tr>
815
					<td width="22%" valign="top" class="vncell"><?=gettext("Pool Description");?></td>
816
					<td width="78%" class="vtable">
817
						<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>" />
818
					</td>
819
				</tr>
820
			<?php endif; ?>
821
				<tr>
822
					<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet");?></td>
823
					<td width="78%" class="vtable">
824
						<?=gen_subnet($ifcfgip, $ifcfgsn);?>
825
					</td>
826
				</tr>
827
				<tr>
828
					<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet mask");?></td>
829
					<td width="78%" class="vtable">
830
						<?=gen_subnet_mask($ifcfgsn);?>
831
					</td>
832
				</tr>
833
				<tr>
834
					<td width="22%" valign="top" class="vncellreq"><?=gettext("Available range");?></td>
835
					<td width="78%" class="vtable">
836
						<?php
837
							$range_from = ip2long(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
838
							$range_from++;
839
							echo long2ip32($range_from);
840
						?>
841
						-
842
						<?php
843
							$range_to = ip2long(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
844
							$range_to--;
845
							echo long2ip32($range_to);
846
							if (is_numeric($pool) || ($act == "newpool")):
847
						?>
848
						<br />In-use DHCP Pool Ranges:
849
						<?php
850
								if (is_array($config['dhcpd'][$if]['range'])):
851
						?>
852
						<br />
853
						<?php
854
									echo $config['dhcpd'][$if]['range']['from'];
855
						?>
856
						-
857
						<?php
858
									echo $config['dhcpd'][$if]['range']['to'];
859
								endif;
860
						?>
861
						<?php
862
								foreach ($a_pools as $p):
863
									if (is_array($p['range'])):
864
						?>
865
						<br />
866
						<?php 
867
										echo $p['range']['from'];
868
						?>
869
						-
870
						<?php
871
										echo $p['range']['to'];
872
									endif;
873
								endforeach;
874
							endif;
875
						?>
876
					</td>
877
				</tr>
878
<?php if ($is_olsr_enabled): ?>
879
				<tr>
880
					<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet Mask");?></td>
881
					<td width="78%" class="vtable">
882
						<select name="netmask" class="formselect" id="netmask">
883
							<?php
884
							for ($i = 32; $i > 0; $i--) {
885
								if ($i <> 31) {
886
									echo "<option value=\"{$i}\" ";
887
									if ($i == $pconfig['netmask']) {
888
										echo "selected=\"selected\"";
889
									}
890
									echo ">" . $i . "</option>";
891
								}
892
							}
893
							?>
894
						</select>
895
					</td>
896
				</tr>
897
<?php endif; ?>
898
				<tr>
899
					<td width="22%" valign="top" class="vncellreq"><?=gettext("Range");?></td>
900
					<td width="78%" class="vtable">
901
						<input name="range_from" type="text" class="formfld unknown" id="range_from" size="20" value="<?=htmlspecialchars($pconfig['range_from']);?>" />
902
						&nbsp;<?=gettext("to"); ?>&nbsp; <input name="range_to" type="text" class="formfld unknown" id="range_to" size="20" value="<?=htmlspecialchars($pconfig['range_to']);?>" />
903
					</td>
904
				</tr>
905
<?php
906
	if (!is_numeric($pool) && !($act == "newpool")):
907
?>
908
				<tr>
909
					<td width="22%" valign="top" class="vncell">
910
						<?=gettext("Additional Pools");?>
911
					</td>
912
					<td width="78%" class="vtable">
913
						<?php echo gettext("If you need additional pools of addresses inside of this subnet outside the above Range, they may be specified here."); ?>
914
						<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="subnet">
915
							<tr>
916
								<td width="35%" class="listhdrr"><?=gettext("Pool Start");?></td>
917
								<td width="35%" class="listhdrr"><?=gettext("Pool End");?></td>
918
								<td width="20%" class="listhdrr"><?=gettext("Description");?></td>
919
								<td width="10%" class="list">
920
									<table border="0" cellspacing="0" cellpadding="1" summary="pool">
921
										<tr>
922
											<td valign="middle" width="17"></td>
923
											<td valign="middle">
924
												<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>
925
											</td>
926
										</tr>
927
									</table>
928
								</td>
929
							</tr>
930
<?php
931
		if (is_array($a_pools)):
932
			$i = 0;
933
			foreach ($a_pools as $poolent):
934
				if (!empty($poolent['range']['from']) && !empty($poolent['range']['to'])):
935
?>
936
							<tr>
937
								<td class="listlr" ondblclick="document.location='services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;pool=<?=$i;?>';">
938
									<?=htmlspecialchars($poolent['range']['from']);?>
939
								</td>
940
								<td class="listr" ondblclick="document.location='services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;pool=<?=$i;?>';">
941
									<?=htmlspecialchars($poolent['range']['to']);?>&nbsp;
942
								</td>
943
								<td class="listr" ondblclick="document.location='services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;pool=<?=$i;?>';">
944
									<?=htmlspecialchars($poolent['descr']);?>&nbsp;
945
								</td>
946
								<td valign="middle" class="list nowrap">
947
									<table border="0" cellspacing="0" cellpadding="1" summary="icons">
948
										<tr>
949
											<td valign="middle">
950
												<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>
951
											</td>
952
											<td valign="middle">
953
												<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>
954
											</td>
955
										</tr>
956
									</table>
957
								</td>
958
							</tr>
959
<?php
960
				endif;
961
				$i++;
962
			endforeach;
963
		endif;
964
?>
965
							<tr>
966
								<td class="list" colspan="3"></td>
967
								<td class="list">
968
									<table border="0" cellspacing="0" cellpadding="1" summary="add">
969
										<tr>
970
											<td valign="middle" width="17"></td>
971
											<td valign="middle">
972
												<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>
973
											</td>
974
										</tr>
975
									</table>
976
								</td>
977
							</tr>
978
						</table>
979
					</td>
980
				</tr>
981
<?php
982
	endif;
983
?>
984
				<tr>
985
					<td width="22%" valign="top" class="vncell"><?=gettext("WINS servers");?></td>
986
					<td width="78%" class="vtable">
987
						<input name="wins1" type="text" class="formfld unknown" id="wins1" size="20" value="<?=htmlspecialchars($pconfig['wins1']);?>" /><br />
988
						<input name="wins2" type="text" class="formfld unknown" id="wins2" size="20" value="<?=htmlspecialchars($pconfig['wins2']);?>" />
989
					</td>
990
				</tr>
991
				<tr>
992
					<td width="22%" valign="top" class="vncell"><?=gettext("DNS servers");?></td>
993
					<td width="78%" class="vtable">
994
						<input name="dns1" type="text" class="formfld unknown" id="dns1" size="20" value="<?=htmlspecialchars($pconfig['dns1']);?>" /><br />
995
						<input name="dns2" type="text" class="formfld unknown" id="dns2" size="20" value="<?=htmlspecialchars($pconfig['dns2']);?>" /><br />
996
						<input name="dns3" type="text" class="formfld unknown" id="dns3" size="20" value="<?=htmlspecialchars($pconfig['dns3']);?>" /><br />
997
						<input name="dns4" type="text" class="formfld unknown" id="dns4" size="20" value="<?=htmlspecialchars($pconfig['dns4']);?>" /><br />
998
						<?=gettext("NOTE: leave blank to use the system default DNS servers - this interface's IP if DNS Forwarder or Resolver is enabled, otherwise the servers configured on the General page.");?>
999
					</td>
1000
				</tr>
1001
				<tr>
1002
					<td width="22%" valign="top" class="vncell"><?=gettext("Gateway");?></td>
1003
					<td width="78%" class="vtable">
1004
						<input name="gateway" type="text" class="formfld host" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>" /><br />
1005
						<?=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.");?>
1006
					</td>
1007
				</tr>
1008
				<tr>
1009
					<td width="22%" valign="top" class="vncell"><?=gettext("Domain name");?></td>
1010
					<td width="78%" class="vtable">
1011
						<input name="domain" type="text" class="formfld unknown" id="domain" size="20" value="<?=htmlspecialchars($pconfig['domain']);?>" /><br />
1012
						<?=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.");?>
1013
					</td>
1014
				</tr>
1015
				<tr>
1016
					<td width="22%" valign="top" class="vncell"><?=gettext("Domain search list");?></td>
1017
					<td width="78%" class="vtable">
1018
						<input name="domainsearchlist" type="text" class="formfld unknown" id="domainsearchlist" size="20" value="<?=htmlspecialchars($pconfig['domainsearchlist']);?>" /><br />
1019
						<?=gettext("The DHCP server can optionally provide a domain search list. Use the semicolon character as separator ");?>
1020
					</td>
1021
				</tr>
1022
				<tr>
1023
					<td width="22%" valign="top" class="vncell"><?=gettext("Default lease time");?></td>
1024
					<td width="78%" class="vtable">
1025
						<input name="deftime" type="text" class="formfld unknown" id="deftime" size="10" value="<?=htmlspecialchars($pconfig['deftime']);?>" />
1026
						<?=gettext("seconds");?><br />
1027
						<?=gettext("This is used for clients that do not ask for a specific expiration time."); ?><br />
1028
						<?=gettext("The default is 7200 seconds.");?>
1029
					</td>
1030
				</tr>
1031
				<tr>
1032
					<td width="22%" valign="top" class="vncell"><?=gettext("Maximum lease time");?></td>
1033
					<td width="78%" class="vtable">
1034
						<input name="maxtime" type="text" class="formfld unknown" id="maxtime" size="10" value="<?=htmlspecialchars($pconfig['maxtime']);?>" />
1035
						<?=gettext("seconds");?><br />
1036
						<?=gettext("This is the maximum lease time for clients that ask for a specific expiration time."); ?><br />
1037
						<?=gettext("The default is 86400 seconds.");?>
1038
					</td>
1039
				</tr>
1040
<?php
1041
	if (!is_numeric($pool) && !($act == "newpool")):
1042
?>
1043
				<tr>
1044
					<td width="22%" valign="top" class="vncell"><?=gettext("Failover peer IP:");?></td>
1045
					<td width="78%" class="vtable">
1046
						<input name="failover_peerip" type="text" class="formfld host" id="failover_peerip" size="20" value="<?=htmlspecialchars($pconfig['failover_peerip']);?>" /><br />
1047
						<?=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).");?>
1048
					</td>
1049
				</tr>
1050
<?php
1051
	endif;
1052

    
1053
	if (!is_numeric($pool) && !($act == "newpool")):
1054
?>
1055
				<tr>
1056
					<td width="22%" valign="top" class="vncell"><?=gettext("Static ARP");?></td>
1057
					<td width="78%" class="vtable">
1058
						<table summary="static arp">
1059
							<tr>
1060
								<td>
1061
									<input style="vertical-align:middle" type="checkbox" value="yes" name="staticarp" id="staticarp" <?php if ($pconfig['staticarp']) echo " checked=\"checked\""; ?> />&nbsp;
1062
								</td>
1063
								<td><b><?=gettext("Enable Static ARP entries");?></b></td>
1064
							</tr>
1065
							<tr>
1066
								<td>&nbsp;</td>
1067
								<td>
1068
									<span class="red">
1069
										<strong><?=gettext("Note:");?></strong>
1070
									</span>
1071
									<?=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.");?>
1072
								</td>
1073
							</tr>
1074
						</table>
1075
					</td>
1076
				</tr>
1077
<?php
1078
	endif;
1079

    
1080
	if (!is_numeric($pool) && !($act == "newpool")): ?>
1081
				<tr>
1082
					<td width="22%" valign="top" class="vncell"><?=gettext("Time format change"); ?></td>
1083
					<td width="78%" class="vtable">
1084
						<table summary="time format">
1085
							<tr>
1086
								<td>
1087
									<input name="dhcpleaseinlocaltime" type="checkbox" id="dhcpleaseinlocaltime" value="yes" <?php if ($pconfig['dhcpleaseinlocaltime']) echo "checked=\"checked\""; ?> />
1088
								</td>
1089
								<td>
1090
									<strong>
1091
										<?=gettext("Change DHCP display lease time from UTC to local time."); ?>
1092
									</strong>
1093
								</td>
1094
							</tr>
1095
							<tr>
1096
								<td>&nbsp;</td>
1097
								<td>
1098
									<span class="red">
1099
										<strong><?=gettext("Note:");?></strong>
1100
									</span>
1101
									<?=gettext("By default DHCP leases are displayed in UTC time.  By checking this 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."); ?>
1102
								</td>
1103
							</tr>
1104
						</table>
1105
					</td>
1106
				</tr>
1107
<?php
1108
	endif;
1109
?>
1110
				<tr>
1111
					<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic DNS");?></td>
1112
					<td width="78%" class="vtable">
1113
						<div id="showddnsbox" <?php if ($pconfig['ddnsupdate'] || !empty($pconfig['ddnsdomain']) || !empty($pconfig['ddnsdomainprimary']) || !empty($pconfig['ddnsdomainkeyname']) || !empty($pconfig['ddnsdomainkey'])) echo "style='display:none'"; ?>>
1114
							<input type="button" onclick="show_ddns_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show Dynamic DNS");?>
1115
						</div>
1116
						<div id="showddns" <?php if (!$pconfig['ddnsupdate'] && empty($pconfig['ddnsdomain']) && empty($pconfig['ddnsdomainprimary']) && empty($pconfig['ddnsdomainkeyname']) && empty($pconfig['ddnsdomainkey'])) echo "style='display:none'"; ?>>
1117
							<input style="vertical-align:middle" type="checkbox" value="yes" name="ddnsupdate" id="ddnsupdate" <?php if ($pconfig['ddnsupdate']) echo " checked=\"checked\""; ?> />&nbsp;
1118
							<b><?=gettext("Enable registration of DHCP client names in DNS.");?></b><br />
1119
							<br/>
1120
							<input name="ddnsdomain" type="text" class="formfld unknown" id="ddnsdomain" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomain']);?>" /><br />
1121
							<?=gettext("Note: Leave blank to disable dynamic DNS registration.");?><br />
1122
							<?=gettext("Enter the dynamic DNS domain which will be used to register client names in the DNS server.");?><br />
1123
							<input name="ddnsdomainprimary" type="text" class="formfld unknown" id="ddnsdomainprimary" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomainprimary']);?>" /><br />
1124
							<?=gettext("Enter the primary domain name server IP address for the dynamic domain name.");?><br />
1125
							<input name="ddnsdomainkeyname" type="text" class="formfld unknown" id="ddnsdomainkeyname" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomainkeyname']);?>" /><br />
1126
							<?=gettext("Enter the dynamic DNS domain key name which will be used to register client names in the DNS server.");?><br />
1127
							<input name="ddnsdomainkey" type="text" class="formfld unknown" id="ddnsdomainkey" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomainkey']);?>" /><br />
1128
							<?=gettext("Enter the dynamic DNS domain key secret which will be used to register client names in the DNS server.");?>
1129
						</div>
1130
					</td>
1131
				</tr>
1132
				<tr>
1133
					<td width="22%" valign="top" class="vncell"><?=gettext("MAC Address Control");?></td>
1134
					<td width="78%" class="vtable">
1135
						<div id="showmaccontrolbox" <?php if (!empty($pconfig['mac_allow']) || !empty($pconfig['mac_deny'])) echo "style='display:none'"; ?>>
1136
							<input type="button" onclick="show_maccontrol_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show MAC Address Control");?>
1137
						</div>
1138
						<div id="showmaccontrol" <?php if (empty($pconfig['mac_allow']) && empty($pconfig['mac_deny'])) echo "style='display:none'"; ?>>
1139
							<input name="mac_allow" type="text" class="formfld unknown" id="mac_allow" size="20" value="<?=htmlspecialchars($pconfig['mac_allow']);?>" /><br />
1140
							<?=gettext("Enter a list of partial MAC addresses to allow, comma separated, no spaces, such as ");?>00:00:00,01:E5:FF<br />
1141
							<input name="mac_deny" type="text" class="formfld unknown" id="mac_deny" size="20" value="<?=htmlspecialchars($pconfig['mac_deny']);?>" /><br />
1142
							<?=gettext("Enter a list of partial MAC addresses to deny access, comma separated, no spaces, such as ");?>00:00:00,01:E5:FF
1143
						</div>
1144
					</td>
1145
				</tr>
1146
				<tr>
1147
					<td width="22%" valign="top" class="vncell"><?=gettext("NTP servers");?></td>
1148
					<td width="78%" class="vtable">
1149
						<div id="showntpbox" <?php if (!empty($pconfig['ntp1']) || !empty($pconfig['ntp2'])) echo "style='display:none'"; ?>>
1150
							<input type="button" onclick="show_ntp_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show NTP configuration");?>
1151
						</div>
1152
						<div id="showntp" <?php if (empty($pconfig['ntp1']) && empty($pconfig['ntp2'])) echo "style='display:none'"; ?>>
1153
							<input name="ntp1" type="text" class="formfld unknown" id="ntp1" size="20" value="<?=htmlspecialchars($pconfig['ntp1']);?>" /><br />
1154
							<input name="ntp2" type="text" class="formfld unknown" id="ntp2" size="20" value="<?=htmlspecialchars($pconfig['ntp2']);?>" />
1155
						</div>
1156
					</td>
1157
				</tr>
1158
				<tr>
1159
					<td width="22%" valign="top" class="vncell"><?=gettext("TFTP server");?></td>
1160
					<td width="78%" class="vtable">
1161
						<div id="showtftpbox" <?php if (!empty($pconfig['tftp'])) echo "style='display:none'"; ?>>
1162
							<input type="button" onclick="show_tftp_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show TFTP configuration");?>
1163
						</div>
1164
						<div id="showtftp" <?php if (empty($pconfig['tftp'])) echo "style='display:none'"; ?>>
1165
							<input name="tftp" type="text" class="formfld unknown" id="tftp" size="50" value="<?=htmlspecialchars($pconfig['tftp']);?>" /><br />
1166
							<?=gettext("Leave blank to disable.  Enter a full hostname or IP for the TFTP server.");?>
1167
						</div>
1168
					</td>
1169
				</tr>
1170
				<tr>
1171
					<td width="22%" valign="top" class="vncell"><?=gettext("LDAP URI");?></td>
1172
					<td width="78%" class="vtable">
1173
						<div id="showldapbox" <?php if (!empty($pconfig['ldap'])) echo "style='display:none'"; ?>>
1174
							<input type="button" onclick="show_ldap_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show LDAP configuration");?>
1175
						</div>
1176
						<div id="showldap" <?php if (empty($pconfig['ldap'])) echo "style='display:none'"; ?>>
1177
							<input name="ldap" type="text" class="formfld unknown" id="ldap" size="80" value="<?=htmlspecialchars($pconfig['ldap']);?>" /><br />
1178
							<?=gettext("Leave blank to disable.  Enter a full URI for the LDAP server in the form ldap://ldap.example.com/dc=example,dc=com");?>
1179
						</div>
1180
					</td>
1181
				</tr>
1182
				<tr>
1183
					<td width="22%" valign="top" class="vncell"><?=gettext("Enable network booting");?></td>
1184
					<td width="78%" class="vtable">
1185
						<div id="shownetbootbox" <?php if ($pconfig['netboot'] || !empty($pconfig['nextserver']) || !empty($pconfig['filename']) || !empty($pconfig['filename32']) || !empty($pconfig['filename64']) || !empty($pconfig['rootpath'])) echo "style='display:none'"; ?>>
1186
							<input type="button" onclick="show_netboot_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show Network booting");?>
1187
						</div>
1188
						<div id="shownetboot" <?php if (!$pconfig['netboot'] && empty($pconfig['nextserver']) && empty($pconfig['filename']) && empty($pconfig['filename32']) && empty($pconfig['filename64']) && empty($pconfig['rootpath'])) echo "style='display:none'"; ?>>
1189
							<input style="vertical-align:middle" type="checkbox" value="yes" name="netboot" id="netboot" <?php if ($pconfig['netboot']) echo " checked=\"checked\""; ?> />&nbsp;
1190
							<b><?=gettext("Enables network booting.");?></b>
1191
							<br/>
1192
							<table border="0" cellspacing="0" cellpadding="2" summary="network booting">
1193
								<tr>
1194
									<td>
1195
										<?=gettext("Enter the IP of the"); ?> <b><?=gettext("next-server"); ?></b>
1196
									</td>
1197
									<td>
1198
										<input name="nextserver" type="text" class="formfld unknown" id="nextserver" size="20" value="<?=htmlspecialchars($pconfig['nextserver']);?>" /><br />
1199
									</td>
1200
								</tr>
1201
								<tr>
1202
									<td>
1203
										<?=gettext("and the default bios filename");?>
1204
									</td>
1205
									<td>
1206
										<input name="filename" type="text" class="formfld unknown" id="filename" size="20" value="<?=htmlspecialchars($pconfig['filename']);?>" /><br />
1207
									</td>
1208
								</tr>
1209
								<tr>
1210
									<td>
1211
										<?=gettext("and the UEFI 32bit filename  ");?>
1212
									</td>
1213
									<td>
1214
										<input name="filename32" type="text" class="formfld unknown" id="filename32" size="20" value="<?=htmlspecialchars($pconfig['filename32']);?>" /><br />
1215
									</td>
1216
								</tr>
1217
								<tr>
1218
									<td>
1219
										<?=gettext("and the UEFI 64bit filename  ");?>
1220
									</td>
1221
									<td>
1222
										<input name="filename64" type="text" class="formfld unknown" id="filename64" size="20" value="<?=htmlspecialchars($pconfig['filename64']);?>" /><br />
1223
									</td>
1224
								</tr>
1225
							</table>
1226
							<?=gettext("Note: You need both a filename and a boot server configured for this to work!");?>
1227
							<?=gettext("You will need all three filenames and a boot server configured for UEFI to work!");?>
1228
							<?=gettext("Enter the"); ?> <b><?=gettext("root-path"); ?></b>-<?=gettext("string");?>
1229
							<input name="rootpath" type="text" class="formfld unknown" id="rootpath" size="90" value="<?=htmlspecialchars($pconfig['rootpath']);?>" /><br />
1230
							<?=gettext("Note: string-format: iscsi:(servername):(protocol):(port):(LUN):targetname");?>
1231
						</div>
1232
					</td>
1233
				</tr>
1234
<?php
1235
	if (!is_numeric($pool) && !($act == "newpool")):
1236
?>
1237
				<tr>
1238
					<td width="22%" valign="top" class="vncell"><?=gettext("Additional BOOTP/DHCP Options");?></td>
1239
					<td width="78%" class="vtable">
1240
						<div id="shownumbervaluebox" <?php if (!empty($pconfig['numberoptions'])) echo "style='display:none'"; ?>>
1241
							<input type="button" onclick="show_shownumbervalue()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show Additional BOOTP/DHCP Options");?>
1242
						</div>
1243
						<div id="shownumbervalue" <?php if (empty($pconfig['numberoptions'])) echo "style='display:none'"; ?>>
1244
							<table id="maintable" summary="bootp-dhcp options">
1245
							<tbody>
1246
								<tr>
1247
									<td colspan="3">
1248
										<div style="padding:5px; margin-top: 16px; margin-bottom: 16px; border:1px dashed #000066; background-color: #ffffff; color: #000000; font-size: 8pt;" id="itemhelp">
1249
											<?=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>
1250
										</div>
1251
									</td>
1252
								</tr>
1253
								<tr>
1254
									<td><div id="onecolumn"><?=gettext("Number");?></div></td>
1255
									<td><div id="twocolumn"><?=gettext("Type");?></div></td>
1256
									<td><div id="threecolumn"><?=gettext("Value");?></div></td>
1257
								</tr>
1258
<?php
1259
		$counter = 0;
1260
		if ($pconfig['numberoptions']):
1261
			foreach ($pconfig['numberoptions']['item'] as $item):
1262
				$number = $item['number'];
1263
				$itemtype = $item['type'];
1264
				$value = $item['value'];
1265
?>
1266
								<tr>
1267
									<td>
1268
										<input autocomplete="off" name="number<?php echo $counter; ?>" type="text" class="formfld unknown" id="number<?php echo $counter; ?>" size="10" value="<?=htmlspecialchars($number);?>" />
1269
									</td>
1270
									<td>
1271
										<select name="itemtype<?php echo $counter; ?>" class="formselect" id="itemtype<?php echo $counter; ?>">
1272
<?php
1273
				foreach ($customitemtypes as $typename => $typedescr) {
1274
					echo "<option value=\"{$typename}\" ";
1275
					if ($itemtype == $typename) {
1276
						echo "selected=\"selected\"";
1277
					}
1278
					echo ">" . $typedescr . "</option>";
1279
				}
1280
?>
1281
										</select>
1282
									</td>
1283
									<td>
1284
										<input autocomplete="off" name="value<?php echo $counter; ?>" type="text" class="formfld unknown" id="value<?php echo $counter; ?>" size="40" value="<?=htmlspecialchars($value);?>" />
1285
									</td>
1286
									<td>
1287
										<a onclick="removeRow(this); return false;" href="#"><img border="0" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" alt="delete" /></a>
1288
									</td>
1289
								</tr>
1290
<?php
1291
				$counter++;
1292
			endforeach;
1293
		endif; // numberoptions
1294
?>
1295
							</tbody>
1296
							</table>
1297
							<a onclick="javascript:addRowTo('maintable', 'formfldalias'); return false;" href="#">
1298
								<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="<?=gettext("add another entry");?>" />
1299
							</a>
1300
							<script type="text/javascript">
1301
							//<![CDATA[
1302
								field_counter_js = 3;
1303
								rows = 1;
1304
								totalrows = <?php echo $counter; ?>;
1305
								loaded = <?php echo $counter; ?>;
1306
							//]]>
1307
							</script>
1308
						</div>
1309
					</td>
1310
				</tr>
1311
<?php
1312
	endif;
1313
?>
1314
				<tr>
1315
					<td width="22%" valign="top">&nbsp;</td>
1316
					<td width="78%">
1317
						<?php if ($act == "newpool"): ?>
1318
							<input type="hidden" name="act" value="newpool" />
1319
						<?php endif; ?>
1320
						<?php if (is_numeric($pool)): ?>
1321
							<input type="hidden" name="pool" value="<?php echo $pool; ?>" />
1322
						<?php endif; ?>
1323
						<input name="if" type="hidden" value="<?=htmlspecialchars($if);?>" />
1324
						<input name="submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)" />
1325
					</td>
1326
				</tr>
1327
				<tr>
1328
					<td width="22%" valign="top">&nbsp;</td>
1329
					<td width="78%">
1330
						<p>
1331
							<span class="vexpl">
1332
								<span class="red"><strong><?=gettext("Note:");?>
1333
									<br />
1334
									</strong>
1335
								</span>
1336
								<?=gettext("The DNS servers entered in"); ?>
1337
								<a href="system.php"><?=gettext("System: General setup"); ?></a>
1338
								<?=gettext("(or the"); ?> <a href="services_dnsmasq.php"><?=gettext("DNS forwarder"); ?></a>, <?=gettext("if enabled)"); ?>
1339
							</span>
1340
							<span class="vexpl">
1341
								<?=gettext("will be assigned to clients by the DHCP server."); ?>
1342
								<br />
1343
								<br />
1344
								<?=gettext("The DHCP lease table can be viewed on the"); ?>
1345
								<a href="status_dhcp_leases.php"><?=gettext("Status: DHCP leases"); ?></a>
1346
								<?=gettext("page."); ?>
1347
								<br />
1348
							</span>
1349
						</p>
1350
					</td>
1351
				</tr>
1352
			</table>
1353
<?php
1354
	if (!is_numeric($pool) && !($act == "newpool")):
1355
?>
1356
			<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="static mappings">
1357
				<tr>
1358
					<td colspan="5" valign="top" class="listtopic"><?=gettext("DHCP Static Mappings for this interface.");?></td>
1359
					<td>&nbsp;</td>
1360
				</tr>
1361
				<tr>
1362
					<td width="7%" class="listhdrr"><?=gettext("Static ARP");?></td>
1363
					<td width="18%" class="listhdrr"><?=gettext("MAC address");?></td>
1364
					<td width="15%" class="listhdrr"><?=gettext("IP address");?></td>
1365
					<td width="20%" class="listhdrr"><?=gettext("Hostname");?></td>
1366
					<td width="30%" class="listhdr"><?=gettext("Description");?></td>
1367
					<td width="10%" class="list">
1368
						<table border="0" cellspacing="0" cellpadding="1" summary="add">
1369
							<tr>
1370
								<td valign="middle" width="17"></td>
1371
								<td valign="middle">
1372
									<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>
1373
								</td>
1374
							</tr>
1375
						</table>
1376
					</td>
1377
				</tr>
1378
<?php
1379
		if (is_array($a_maps)):
1380
			$i = 0;
1381
			foreach ($a_maps as $mapent):
1382
?>
1383
				<tr>
1384
					<td align="center" class="listlr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>';">
1385
						<?php if (isset($mapent['arp_table_static_entry'])): ?>
1386
							<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_alert.gif" alt="ARP Table Static Entry" width="17" height="17" border="0" alt="alert" />
1387
						<?php endif; ?>
1388
					</td>
1389
					<td class="listlr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>';">
1390
						<?=htmlspecialchars($mapent['mac']);?>
1391
					</td>
1392
					<td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>';">
1393
						<?=htmlspecialchars($mapent['ipaddr']);?>&nbsp;
1394
					</td>
1395
					<td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>';">
1396
						<?=htmlspecialchars($mapent['hostname']);?>&nbsp;
1397
					</td>
1398
					<td class="listbg" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>';">
1399
						<?=htmlspecialchars($mapent['descr']);?>&nbsp;
1400
					</td>
1401
					<td valign="middle" class="list nowrap">
1402
						<table border="0" cellspacing="0" cellpadding="1" summary="icons">
1403
							<tr>
1404
								<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>
1405
								<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>
1406
							</tr>
1407
						</table>
1408
					</td>
1409
				</tr>
1410
<?php
1411
				$i++;
1412
			endforeach;
1413
		endif;
1414
?>
1415
				<tr>
1416
					<td class="list" colspan="5"></td>
1417
					<td class="list">
1418
						<table border="0" cellspacing="0" cellpadding="1" summary="add">
1419
							<tr>
1420
								<td valign="middle" width="17"></td>
1421
								<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>
1422
							</tr>
1423
						</table>
1424
					</td>
1425
				</tr>
1426
			</table>
1427
<?php
1428
	endif;
1429
?>
1430
			</div>
1431
		</td>
1432
	</tr>
1433
</table>
1434
</form>
1435
<script type="text/javascript">
1436
//<![CDATA[
1437
enable_change(false);
1438
//]]>
1439
</script>
1440
<?php include("fend.inc"); ?>
1441
</body>
1442
</html>
(133-133/238)