Project

General

Profile

Download (41.6 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
	All rights reserved.
9

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

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

    
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19

    
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31
/*
32
	pfSense_BUILDER_BINARIES:	/bin/rm
33
	pfSense_MODULE:	interfaces
34
*/
35

    
36
##|+PRIV
37
##|*IDENT=page-services-dhcpserver
38
##|*NAME=Services: DHCP server page
39
##|*DESCR=Allow access to the 'Services: DHCP server' page.
40
##|*MATCH=services_dhcp.php*
41
##|-PRIV
42

    
43
require("guiconfig.inc");
44

    
45
if(!$g['services_dhcp_server_enable']) {
46
	Header("Location: /");
47
	exit;
48
}
49

    
50
/* This function will remove entries from dhcpd.leases that would otherwise
51
 * overlap with static DHCP reservations. If we don't clean these out,
52
 * then DHCP will print a warning in the logs about a duplicate lease
53
 */
54
function dhcp_clean_leases() {
55
	global $g, $config;
56
	$leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases";
57
	if (!file_exists($leasesfile))
58
		return;
59
	/* Build list of static MACs */
60
	$staticmacs = array();
61
	foreach($config['interfaces'] as $ifname => $ifarr)
62
		if (is_array($config['dhcpd'][$ifname]['staticmap']))
63
			foreach($config['dhcpd'][$ifname]['staticmap'] as $static)
64
				$staticmacs[] = $static['mac'];
65
	/* Read existing leases */
66
	$leases_contents = explode("\n", file_get_contents($leasesfile));
67
	$newleases_contents = array();
68
	$i=0;
69
	while ($i < count($leases_contents)) {
70
		/* Find a lease definition */
71
		if (substr($leases_contents[$i], 0, 6) == "lease ") {
72
			$templease = array();
73
			$thismac = "";
74
			/* Read to the end of the lease declaration */
75
			do {
76
				if (substr($leases_contents[$i], 0, 20) == "  hardware ethernet ")
77
					$thismac = substr($leases_contents[$i], 20, 17);
78
				$templease[] = $leases_contents[$i];
79
				$i++;
80
			} while ($leases_contents[$i-1] != "}");
81
			/* Check for a matching MAC address and if not present, keep it. */
82
			if (! in_array($thismac, $staticmacs))
83
				$newleases_contents = array_merge($newleases_contents, $templease);
84
		} else {
85
			/* It's a line we want to keep, copy it over. */
86
			$newleases_contents[] = $leases_contents[$i];
87
			$i++;
88
		}
89
	}
90
	/* Write out the new leases file */
91
	$fd = fopen($leasesfile, 'w');
92
	fwrite($fd, implode("\n", $newleases_contents));
93
	fclose($fd);
94
}
95

    
96
$if = $_GET['if'];
97
if ($_POST['if'])
98
	$if = $_POST['if'];
99

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

    
110
if (!$_GET['if'])
111
	$savemsg = "<b>" . gettext("The DHCP Server can only be enabled on interfaces configured with static IP addresses") . ".<p>" . gettext("Only interfaces configured with a static IP will be shown") . ".</p></b>";
112

    
113
$iflist = get_configured_interface_with_descr();
114

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

    
127
if (is_array($config['dhcpd'][$if])){
128
	if (is_array($config['dhcpd'][$if]['range'])) {
129
		$pconfig['range_from'] = $config['dhcpd'][$if]['range']['from'];
130
		$pconfig['range_to'] = $config['dhcpd'][$if]['range']['to'];
131
	}
132
	$pconfig['deftime'] = $config['dhcpd'][$if]['defaultleasetime'];
133
	$pconfig['maxtime'] = $config['dhcpd'][$if]['maxleasetime'];
134
	$pconfig['gateway'] = $config['dhcpd'][$if]['gateway'];
135
	$pconfig['domain'] = $config['dhcpd'][$if]['domain'];
136
	$pconfig['domainsearchlist'] = $config['dhcpd'][$if]['domainsearchlist'];
137
	list($pconfig['wins1'],$pconfig['wins2']) = $config['dhcpd'][$if]['winsserver'];
138
	list($pconfig['dns1'],$pconfig['dns2']) = $config['dhcpd'][$if]['dnsserver'];
139
	$pconfig['enable'] = isset($config['dhcpd'][$if]['enable']);
140
	$pconfig['denyunknown'] = isset($config['dhcpd'][$if]['denyunknown']);
141
	$pconfig['staticarp'] = isset($config['dhcpd'][$if]['staticarp']);
142
	$pconfig['ddnsdomain'] = $config['dhcpd'][$if]['ddnsdomain'];
143
	$pconfig['ddnsupdate'] = isset($config['dhcpd'][$if]['ddnsupdate']);
144
	list($pconfig['ntp1'],$pconfig['ntp2']) = $config['dhcpd'][$if]['ntpserver'];
145
	$pconfig['tftp'] = $config['dhcpd'][$if]['tftp'];
146
	$pconfig['ldap'] = $config['dhcpd'][$if]['ldap'];
147
	$pconfig['netboot'] = isset($config['dhcpd'][$if]['netboot']);
148
	$pconfig['nextserver'] = $config['dhcpd'][$if]['next-server'];
149
	$pconfig['filename'] = $config['dhcpd'][$if]['filename'];
150
	$pconfig['rootpath'] = $config['dhcpd'][$if]['rootpath'];
151
	$pconfig['failover_peerip'] = $config['dhcpd'][$if]['failover_peerip'];
152
	$pconfig['netmask'] = $config['dhcpd'][$if]['netmask'];
153
	$pconfig['numberoptions'] = $config['dhcpd'][$if]['numberoptions'];
154
	if (!is_array($config['dhcpd'][$if]['staticmap']))
155
		$config['dhcpd'][$if]['staticmap'] = array();
156
	$a_maps = &$config['dhcpd'][$if]['staticmap'];
157
}
158

    
159
$ifcfgip = get_interface_ip($if);
160
$ifcfgsn = get_interface_subnet($if);
161

    
162
/*   set the enabled flag which will tell us if DHCP relay is enabled
163
 *   on any interface. We will use this to disable DHCP server since
164
 *   the two are not compatible with each other.
165
 */
166

    
167
$dhcrelay_enabled = false;
168
$dhcrelaycfg = $config['dhcrelay'];
169

    
170
if(is_array($dhcrelaycfg)) {
171
	foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
172
		if (isset($dhcrelayifconf['enable']) && isset($iflist[$dhcrelayif]) &&
173
			(!link_interface_to_bridge($dhcrelayif)))
174
			$dhcrelay_enabled = true;
175
	}
176
}
177

    
178
function is_inrange($test, $start, $end) {
179
	if ( (ip2ulong($test) < ip2ulong($end)) && (ip2ulong($test) > ip2ulong($start)) )
180
		return true;
181
	else
182
		return false;
183
}
184

    
185
if ($_POST) {
186

    
187
	unset($input_errors);
188

    
189
	$pconfig = $_POST;
190

    
191
	$numberoptions = array();
192
	for($x=0; $x<99; $x++) {
193
		if(isset($_POST["number{$x}"]) && ctype_digit($_POST["number{$x}"])) {
194
			$numbervalue = array();
195
			$numbervalue['number'] = htmlspecialchars($_POST["number{$x}"]);
196
			$numbervalue['type'] = htmlspecialchars($_POST["itemtype{$x}"]);
197
			$numbervalue['value'] = str_replace('&quot;', '"', htmlspecialchars($_POST["value{$x}"]));
198
			$numberoptions['item'][] = $numbervalue;
199
		}
200
	}
201
	// Reload the new pconfig variable that the forum uses.
202
	$pconfig['numberoptions'] = $numberoptions;
203

    
204
	/* input validation */
205
	if ($_POST['enable']) {
206
		$reqdfields = explode(" ", "range_from range_to");
207
		$reqdfieldsn = array(gettext("Range begin"),gettext("Range end"));
208

    
209
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
210

    
211
		if (($_POST['range_from'] && !is_ipaddrv4($_POST['range_from'])))
212
			$input_errors[] = gettext("A valid range must be specified.");
213
		if (($_POST['range_to'] && !is_ipaddrv4($_POST['range_to'])))
214
			$input_errors[] = gettext("A valid range must be specified.");
215
		if (($_POST['gateway'] && !is_ipaddrv4($_POST['gateway'])))
216
			$input_errors[] = gettext("A valid IP address must be specified for the gateway.");
217
		if (($_POST['wins1'] && !is_ipaddrv4($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddrv4($_POST['wins2'])))
218
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary WINS servers.");
219
		$parent_ip = get_interface_ip($_POST['if']);
220
		if (is_ipaddrv4($parent_ip) && $_POST['gateway']) {
221
			$parent_sn = get_interface_subnet($_POST['if']);
222
			if(!ip_in_subnet($_POST['gateway'], gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn) && !ip_in_interface_alias_subnet($_POST['if'], $_POST['gateway'])) 
223
				$input_errors[] = sprintf(gettext("The gateway address %s does not lie within the chosen interface's subnet."), $_POST['gateway']);
224
		}
225
		if (($_POST['dns1'] && !is_ipaddrv4($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddrv4($_POST['dns2'])))
226
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary DNS servers.");
227

    
228
		if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60)))
229
			$input_errors[] = gettext("The default lease time must be at least 60 seconds.");
230
		if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime'])))
231
			$input_errors[] = gettext("The maximum lease time must be at least 60 seconds and higher than the default lease time.");
232
		if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain'])))
233
			$input_errors[] = gettext("A valid domain name must be specified for the dynamic DNS registration.");
234
		if (($_POST['ntp1'] && !is_ipaddrv4($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddrv4($_POST['ntp2'])))
235
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary NTP servers.");
236
		if (($_POST['domain'] && !is_domain($_POST['domain'])))
237
			$input_errors[] = gettext("A valid domain name must be specified for the DNS domain.");
238
		if ($_POST['tftp'] && !is_ipaddrv4($_POST['tftp']) && !is_domain($_POST['tftp']) && !is_URL($_POST['tftp']))
239
			$input_errors[] = gettext("A valid IP address or hostname must be specified for the TFTP server.");
240
		if (($_POST['nextserver'] && !is_ipaddrv4($_POST['nextserver'])))
241
			$input_errors[] = gettext("A valid IP address must be specified for the network boot server.");
242

    
243
		if(gen_subnet($ifcfgip, $ifcfgsn) == $_POST['range_from'])
244
			$input_errors[] = gettext("You cannot use the network address in the starting subnet range.");
245
		if(gen_subnet_max($ifcfgip, $ifcfgsn) == $_POST['range_to'])
246
			$input_errors[] = gettext("You cannot use the broadcast address in the ending subnet range.");
247

    
248
		// Disallow a range that includes the virtualip
249
		if (is_array($config['virtualip']['vip'])) {
250
			foreach($config['virtualip']['vip'] as $vip) {
251
				if($vip['interface'] == $if)
252
					if($vip['subnet'] && is_inrange($vip['subnet'], $_POST['range_from'], $_POST['range_to']))
253
						$input_errors[] = sprintf(gettext("The subnet range cannot overlap with virtual IP address %s."),$vip['subnet']);
254
			}
255
		}
256

    
257
		$noip = false;
258
		if(is_array($a_maps))
259
			foreach ($a_maps as $map)
260
				if (empty($map['ipaddr']))
261
					$noip = true;
262
		if ($_POST['staticarp'] && $noip)
263
			$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.";
264

    
265
		if(is_array($pconfig['numberoptions']['item'])) {
266
			foreach ($pconfig['numberoptions']['item'] as $numberoption) {
267
				if ( $numberoption['type'] == 'text' && strstr($numberoption['value'], '"') )
268
					$input_errors[] = gettext("Text type cannot include quotation marks.");
269
				else if ( $numberoption['type'] == 'string' && !preg_match('/^"[^"]*"$/', $numberoption['value']) && !preg_match('/^[0-9a-f]{2}(?:\:[0-9a-f]{2})*$/i', $numberoption['value']) )
270
					$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");
271
				else if ( $numberoption['type'] == 'boolean' && $numberoption['value'] != 'true' && $numberoption['value'] != 'false' && $numberoption['value'] != 'on' && $numberoption['value'] != 'off' )
272
					$input_errors[] = gettext("Boolean type must be true, false, on, or off.");
273
				else if ( $numberoption['type'] == 'unsigned integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 255) )
274
					$input_errors[] = gettext("Unsigned 8-bit integer type must be a number in the range 0 to 255.");
275
				else if ( $numberoption['type'] == 'unsigned integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 65535) )
276
					$input_errors[] = gettext("Unsigned 16-bit integer type must be a number in the range 0 to 65535.");
277
				else if ( $numberoption['type'] == 'unsigned integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 4294967295) )
278
					$input_errors[] = gettext("Unsigned 32-bit integer type must be a number in the range 0 to 4294967295.");
279
				else if ( $numberoption['type'] == 'signed integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -128 || $numberoption['value'] > 127) )
280
					$input_errors[] = gettext("Signed 8-bit integer type must be a number in the range -128 to 127.");
281
				else if ( $numberoption['type'] == 'signed integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -32768 || $numberoption['value'] > 32767) )
282
					$input_errors[] = gettext("Signed 16-bit integer type must be a number in the range -32768 to 32767.");
283
				else if ( $numberoption['type'] == 'signed integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -2147483648 || $numberoption['value'] > 2147483647) )
284
					$input_errors[] = gettext("Signed 32-bit integer type must be a number in the range -2147483648 to 2147483647.");
285
				else if ( $numberoption['type'] == 'ip-address' && !is_ipaddrv4($numberoption['value']) && !is_hostname($numberoption['value']) )
286
					$input_errors[] = gettext("IP address or host type must be an IP address or host name.");
287
			}
288
		}
289

    
290
		if (!$input_errors) {
291
			/* make sure the range lies within the current subnet */
292
			$subnet_start = ip2ulong(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
293
			$subnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
294

    
295
			if ((ip2ulong($_POST['range_from']) < $subnet_start) || (ip2ulong($_POST['range_from']) > $subnet_end) ||
296
			    (ip2ulong($_POST['range_to']) < $subnet_start) || (ip2ulong($_POST['range_to']) > $subnet_end)) {
297
				$input_errors[] = gettext("The specified range lies outside of the current subnet.");
298
			}
299

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

    
303
			/* make sure that the DHCP Relay isn't enabled on this interface */
304
			if (isset($config['dhcrelay'][$if]['enable']))
305
				$input_errors[] = sprintf(gettext("You must disable the DHCP relay on the %s interface before enabling the DHCP server."),$iflist[$if]);
306

    
307
			$dynsubnet_start = ip2ulong($_POST['range_from']);
308
			$dynsubnet_end = ip2ulong($_POST['range_to']);
309
			if (is_array($a_maps)) {
310
				foreach ($a_maps as $map) {
311
					if (empty($map['ipaddr']))
312
						continue;
313
					if ((ip2ulong($map['ipaddr']) > $dynsubnet_start) &&
314
						(ip2ulong($map['ipaddr']) < $dynsubnet_end)) {
315
						$input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings."));
316
						break;
317
					}
318
				}
319
			}
320
		}
321
	}
322

    
323
	if (!$input_errors) {
324
		if (!is_array($config['dhcpd'][$if]))
325
			$config['dhcpd'][$if] = array();
326
		if (!is_array($config['dhcpd'][$if]['range']))
327
			$config['dhcpd'][$if]['range'] = array();
328

    
329
		$config['dhcpd'][$if]['range']['from'] = $_POST['range_from'];
330
		$config['dhcpd'][$if]['range']['to'] = $_POST['range_to'];
331
		$config['dhcpd'][$if]['defaultleasetime'] = $_POST['deftime'];
332
		$config['dhcpd'][$if]['maxleasetime'] = $_POST['maxtime'];
333
		$config['dhcpd'][$if]['netmask'] = $_POST['netmask'];
334
		$previous = $config['dhcpd'][$if]['failover_peerip'];
335
		if($previous <> $_POST['failover_peerip'])
336
			mwexec("/bin/rm -rf /var/dhcpd/var/db/*");
337

    
338
		$config['dhcpd'][$if]['failover_peerip'] = $_POST['failover_peerip'];
339

    
340
		unset($config['dhcpd'][$if]['winsserver']);
341
		if ($_POST['wins1'])
342
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins1'];
343
		if ($_POST['wins2'])
344
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins2'];
345

    
346
		unset($config['dhcpd'][$if]['dnsserver']);
347
		if ($_POST['dns1'])
348
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns1'];
349
		if ($_POST['dns2'])
350
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns2'];
351

    
352
		$config['dhcpd'][$if]['gateway'] = $_POST['gateway'];
353
		$config['dhcpd'][$if]['domain'] = $_POST['domain'];
354
		$config['dhcpd'][$if]['domainsearchlist'] = $_POST['domainsearchlist'];
355
		$config['dhcpd'][$if]['denyunknown'] = ($_POST['denyunknown']) ? true : false;
356
		$config['dhcpd'][$if]['enable'] = ($_POST['enable']) ? true : false;
357
		$config['dhcpd'][$if]['staticarp'] = ($_POST['staticarp']) ? true : false;
358
		$config['dhcpd'][$if]['ddnsdomain'] = $_POST['ddnsdomain'];
359
		$config['dhcpd'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
360

    
361
		unset($config['dhcpd'][$if]['ntpserver']);
362
		if ($_POST['ntp1'])
363
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp1'];
364
		if ($_POST['ntp2'])
365
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp2'];
366

    
367
		$config['dhcpd'][$if]['tftp'] = $_POST['tftp'];
368
		$config['dhcpd'][$if]['ldap'] = $_POST['ldap'];
369
		$config['dhcpd'][$if]['netboot'] = ($_POST['netboot']) ? true : false;
370
		$config['dhcpd'][$if]['next-server'] = $_POST['nextserver'];
371
		$config['dhcpd'][$if]['filename'] = $_POST['filename'];
372
		$config['dhcpd'][$if]['rootpath'] = $_POST['rootpath'];
373

    
374
		// Handle the custom options rowhelper
375
		if(isset($config['dhcpd'][$if]['numberoptions']['item']))
376
			unset($config['dhcpd'][$if]['numberoptions']['item']);
377

    
378
		$config['dhcpd'][$if]['numberoptions'] = $numberoptions;
379

    
380
		write_config();
381

    
382
		$retval = 0;
383
		$retvaldhcp = 0;
384
		$retvaldns = 0;
385
		/* Stop DHCP so we can cleanup leases */
386
		killbyname("dhcpd");
387
		dhcp_clean_leases();
388
		/* dnsmasq_configure calls dhcpd_configure */
389
		/* no need to restart dhcpd twice */
390
		if (isset($config['dnsmasq']['regdhcpstatic']))	{
391
			$retvaldns = services_dnsmasq_configure();
392
			if ($retvaldns == 0) {
393
				clear_subsystem_dirty('hosts');
394
				clear_subsystem_dirty('staticmaps');
395
			}
396
		} else {
397
			$retvaldhcp = services_dhcpd_configure();
398
			if ($retvaldhcp == 0)
399
				clear_subsystem_dirty('staticmaps');
400
		}
401
		if($retvaldhcp == 1 || $retvaldns == 1)
402
			$retval = 1;
403
		$savemsg = get_std_save_message($retval);
404
	}
405
}
406

    
407
if ($_GET['act'] == "del") {
408
	if ($a_maps[$_GET['id']]) {
409
		unset($a_maps[$_GET['id']]);
410
		write_config();
411
		if(isset($config['dhcpd'][$if]['enable'])) {
412
			mark_subsystem_dirty('staticmaps');
413
			if (isset($config['dnsmasq']['regdhcpstatic']))
414
				mark_subsystem_dirty('hosts');
415
		}
416
		header("Location: services_dhcp.php?if={$if}");
417
		exit;
418
	}
419
}
420

    
421
$pgtitle = array(gettext("Services"),gettext("DHCP server"));
422
$statusurl = "status_dhcp_leases.php";
423
$logurl = "diag_logs_dhcp.php";
424

    
425
include("head.inc");
426

    
427
?>
428

    
429
<script type="text/javascript" src="/javascript/row_helper.js">
430
</script>
431

    
432
<script type="text/javascript">
433
	function itemtype_field(fieldname, fieldsize, n) {
434
		return '<select name="' + fieldname + n + '" class="formselect" id="' + fieldname + n + '"><?php
435
			$customitemtypes = array('text' => gettext('Text'), 'string' => gettext('String'), 'boolean' => gettext('Boolean'),
436
				'unsigned integer 8' => gettext('Unsigned 8-bit integer'), 'unsigned integer 16' => gettext('Unsigned 16-bit integer'), 'unsigned integer 32' => gettext('Unsigned 32-bit integer'),
437
				'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'));
438
			foreach ($customitemtypes as $typename => $typedescr) {
439
				echo "<option value=\"{$typename}\">{$typedescr}</option>";
440
			}
441
		?></select>';
442
	}
443

    
444
	rowname[0] = "number";
445
	rowtype[0] = "textbox";
446
	rowsize[0] = "10";
447
	rowname[1] = "itemtype";
448
	rowtype[1] = itemtype_field;
449
	rowname[2] = "value";
450
	rowtype[2] = "textbox";
451
	rowsize[2] = "40";
452
</script>
453

    
454
<script type="text/javascript" language="JavaScript">
455
	function enable_change(enable_over) {
456
		var endis;
457
		endis = !(document.iform.enable.checked || enable_over);
458
		document.iform.range_from.disabled = endis;
459
		document.iform.range_to.disabled = endis;
460
		document.iform.wins1.disabled = endis;
461
		document.iform.wins2.disabled = endis;
462
		document.iform.dns1.disabled = endis;
463
		document.iform.dns2.disabled = endis;
464
		document.iform.deftime.disabled = endis;
465
		document.iform.maxtime.disabled = endis;
466
		document.iform.gateway.disabled = endis;
467
		document.iform.failover_peerip.disabled = endis;
468
		document.iform.domain.disabled = endis;
469
		document.iform.domainsearchlist.disabled = endis;
470
		document.iform.staticarp.disabled = endis;
471
		document.iform.ddnsdomain.disabled = endis;
472
		document.iform.ddnsupdate.disabled = endis;
473
		document.iform.ntp1.disabled = endis;
474
		document.iform.ntp2.disabled = endis;
475
		document.iform.tftp.disabled = endis;
476
		document.iform.ldap.disabled = endis;
477
		document.iform.netboot.disabled = endis;
478
		document.iform.nextserver.disabled = endis;
479
		document.iform.filename.disabled = endis;
480
		document.iform.rootpath.disabled = endis;
481
		document.iform.denyunknown.disabled = endis;
482
	}
483

    
484
	function show_shownumbervalue() {
485
		document.getElementById("shownumbervaluebox").innerHTML='';
486
		aodiv = document.getElementById('shownumbervalue');
487
		aodiv.style.display = "block";
488
	}
489

    
490
	function show_ddns_config() {
491
		document.getElementById("showddnsbox").innerHTML='';
492
		aodiv = document.getElementById('showddns');
493
		aodiv.style.display = "block";
494
	}
495

    
496
	function show_ntp_config() {
497
		document.getElementById("showntpbox").innerHTML='';
498
		aodiv = document.getElementById('showntp');
499
		aodiv.style.display = "block";
500
	}
501

    
502
	function show_tftp_config() {
503
		document.getElementById("showtftpbox").innerHTML='';
504
		aodiv = document.getElementById('showtftp');
505
		aodiv.style.display = "block";
506
	}
507

    
508
	function show_ldap_config() {
509
		document.getElementById("showldapbox").innerHTML='';
510
		aodiv = document.getElementById('showldap');
511
		aodiv.style.display = "block";
512
	}
513

    
514
	function show_netboot_config() {
515
		document.getElementById("shownetbootbox").innerHTML='';
516
		aodiv = document.getElementById('shownetboot');
517
		aodiv.style.display = "block";
518
	}
519
</script>
520

    
521
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
522
<?php include("fbegin.inc"); ?>
523
<form action="services_dhcp.php" method="post" name="iform" id="iform">
524
<?php if ($input_errors) print_input_errors($input_errors); ?>
525
<?php if ($savemsg) print_info_box($savemsg); ?>
526
<?php
527
	if ($dhcrelay_enabled) {
528
		echo gettext("DHCP Relay is currently enabled. Cannot enable the DHCP Server service while the DHCP Relay is enabled on any interface.");
529
		include("fend.inc");
530
		echo "</body>";
531
		echo "</html>";
532
		exit;
533
	}
534
?>
535
<?php if (is_subsystem_dirty('staticmaps')): ?><p>
536
<?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>
537
<?php endif; ?>
538
<table width="100%" border="0" cellpadding="0" cellspacing="0">
539
<tr><td>
540
<?php
541
	/* active tabs */
542
	$tab_array = array();
543
	$tabscounter = 0;
544
	$i = 0;
545
	foreach ($iflist as $ifent => $ifname) {
546
		$oc = $config['interfaces'][$ifent];
547
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) ||
548
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr']))))
549
			continue;
550
		if ($ifent == $if)
551
			$active = true;
552
		else
553
			$active = false;
554
		$tab_array[] = array($ifname, $active, "services_dhcp.php?if={$ifent}");
555
		$tabscounter++;
556
	}
557
	if ($tabscounter == 0) {
558
		echo "</td></tr></table></form>";
559
		include("fend.inc");
560
		echo "</body>";
561
		echo "</html>";
562
		exit;
563
	}
564
	display_top_tabs($tab_array);
565
?>
566
</td></tr>
567
<tr>
568
<td>
569
	<div id="mainarea">
570
		<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
571
			<tr>
572
			<td width="22%" valign="top" class="vtable">&nbsp;</td>
573
			<td width="78%" class="vtable">
574
				<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
575
			<strong><?php printf(gettext("Enable DHCP server on " .
576
			"%s " .
577
			"interface"),htmlspecialchars($iflist[$if]));?></strong></td>
578
			</tr>
579
			<tr>
580
			<td width="22%" valign="top" class="vtable">&nbsp;</td>
581
			<td width="78%" class="vtable">
582
				<input name="denyunknown" id="denyunknown" type="checkbox" value="yes" <?php if ($pconfig['denyunknown']) echo "checked"; ?>>
583
				<strong><?=gettext("Deny unknown clients");?></strong><br>
584
				<?=gettext("If this is checked, only the clients defined below will get DHCP leases from this server. ");?></td>
585
			</tr>
586
			<tr>
587
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet");?></td>
588
			<td width="78%" class="vtable">
589
				<?=gen_subnet($ifcfgip, $ifcfgsn);?>
590
			</td>
591
			</tr>
592
			<tr>
593
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet mask");?></td>
594
			<td width="78%" class="vtable">
595
				<?=gen_subnet_mask($ifcfgsn);?>
596
			</td>
597
			</tr>
598
			<tr>
599
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Available range");?></td>
600
			<td width="78%" class="vtable">
601
			<?php
602
				$range_from = ip2long(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
603
				$range_from++;
604
				echo long2ip32($range_from);
605
			?>
606
			-
607
			<?php
608
				$range_to = ip2long(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
609
				$range_to--;
610
				echo long2ip32($range_to);
611
			?>
612
			</td>
613
			</tr>
614
			<?php if($is_olsr_enabled): ?>
615
			<tr>
616
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet Mask");?></td>
617
			<td width="78%" class="vtable">
618
				<select name="netmask" class="formselect" id="netmask">
619
				<?php
620
				for ($i = 32; $i > 0; $i--) {
621
					if($i <> 31) {
622
						echo "<option value=\"{$i}\" ";
623
						if ($i == $pconfig['netmask']) echo "selected";
624
						echo ">" . $i . "</option>";
625
					}
626
				}
627
				?>
628
				</select>
629
			</td>
630
			</tr>
631
			<?php endif; ?>
632
			<tr>
633
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Range");?></td>
634
			<td width="78%" class="vtable">
635
				<input name="range_from" type="text" class="formfld unknown" id="range_from" size="20" value="<?=htmlspecialchars($pconfig['range_from']);?>">
636
				&nbsp;<?=gettext("to"); ?>&nbsp; <input name="range_to" type="text" class="formfld unknown" id="range_to" size="20" value="<?=htmlspecialchars($pconfig['range_to']);?>">
637
			</td>
638
			</tr>
639
			<tr>
640
			<td width="22%" valign="top" class="vncell"><?=gettext("WINS servers");?></td>
641
			<td width="78%" class="vtable">
642
				<input name="wins1" type="text" class="formfld unknown" id="wins1" size="20" value="<?=htmlspecialchars($pconfig['wins1']);?>"><br>
643
				<input name="wins2" type="text" class="formfld unknown" id="wins2" size="20" value="<?=htmlspecialchars($pconfig['wins2']);?>">
644
			</td>
645
			</tr>
646
			<tr>
647
			<td width="22%" valign="top" class="vncell"><?=gettext("DNS servers");?></td>
648
			<td width="78%" class="vtable">
649
				<input name="dns1" type="text" class="formfld unknown" id="dns1" size="20" value="<?=htmlspecialchars($pconfig['dns1']);?>"><br>
650
				<input name="dns2" type="text" class="formfld unknown" id="dns2" size="20" value="<?=htmlspecialchars($pconfig['dns2']);?>"><br>
651
				<?=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.");?>
652
			</td>
653
			</tr>
654
			<tr>
655
			<td width="22%" valign="top" class="vncell"><?=gettext("Gateway");?></td>
656
			<td width="78%" class="vtable">
657
				<input name="gateway" type="text" class="formfld host" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>"><br>
658
			 	 <?=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.");?>
659
			</td>
660
			</tr>
661
			<tr>
662
			<td width="22%" valign="top" class="vncell"><?=gettext("Domain name");?></td>
663
			<td width="78%" class="vtable">
664
				<input name="domain" type="text" class="formfld unknown" id="domain" size="20" value="<?=htmlspecialchars($pconfig['domain']);?>"><br>
665
				 <?=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.");?>
666
			 </td>
667
			</tr>
668
			<tr>
669
			<td width="22%" valign="top" class="vncell"><?=gettext("Domain search list");?></td>
670
			<td width="78%" class="vtable">
671
				<input name="domainsearchlist" type="text" class="formfld unknown" id="domainsearchlist" size="20" value="<?=htmlspecialchars($pconfig['domainsearchlist']);?>"><br>
672
				<?=gettext("The DHCP server can optionally provide a domain search list.");?>
673
			</td>
674
			</tr>
675
			<tr>
676
			<td width="22%" valign="top" class="vncell"><?=gettext("Default lease time");?></td>
677
			<td width="78%" class="vtable">
678
				<input name="deftime" type="text" class="formfld unknown" id="deftime" size="10" value="<?=htmlspecialchars($pconfig['deftime']);?>">
679
				<?=gettext("seconds");?><br>
680
				<?=gettext("This is used for clients that do not ask for a specific " .
681
				"expiration time."); ?><br>
682
				<?=gettext("The default is 7200 seconds.");?>
683
			</td>
684
			</tr>
685
			<tr>
686
			<td width="22%" valign="top" class="vncell"><?=gettext("Maximum lease time");?></td>
687
			<td width="78%" class="vtable">
688
				<input name="maxtime" type="text" class="formfld unknown" id="maxtime" size="10" value="<?=htmlspecialchars($pconfig['maxtime']);?>">
689
				<?=gettext("seconds");?><br>
690
				<?=gettext("This is the maximum lease time for clients that ask".
691
				" for a specific expiration time."); ?><br>
692
				<?=gettext("The default is 86400 seconds.");?>
693
			</td>
694
			</tr>
695
			<tr>
696
			<td width="22%" valign="top" class="vncell"><?=gettext("Failover peer IP:");?></td>
697
			<td width="78%" class="vtable">
698
				<input name="failover_peerip" type="text" class="formfld host" id="failover_peerip" size="20" value="<?=htmlspecialchars($pconfig['failover_peerip']);?>"><br>
699
				<?=gettext("Leave blank to disable.  Enter the interface IP address of the other machine.  Machines must be using CARP.");?>
700
			</td>
701
			</tr>
702
			<tr>
703
			<td width="22%" valign="top" class="vncell"><?=gettext("Static ARP");?></td>
704
			<td width="78%" class="vtable">
705
				<table>
706
					<tr>
707
					<td>
708
						<input valign="middle" type="checkbox" value="yes" name="staticarp" id="staticarp" <?php if($pconfig['staticarp']) echo " checked"; ?>>&nbsp;
709
					</td>
710
					<td><b><?=gettext("Enable Static ARP entries");?></b></td>
711
					</tr>
712
					<tr>
713
					<td>&nbsp;</td>
714
					<td>
715
						<span class="red"><strong><?=gettext("Note:");?></strong></span> <?=gettext("Only the machines listed below will be able to communicate with the firewall on this NIC.");?>
716
					</td>
717
					</tr>
718
				</table>
719
			</td>
720
			</tr>
721
			<tr>
722
			<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic DNS");?></td>
723
			<td width="78%" class="vtable">
724
				<div id="showddnsbox">
725
					<input type="button" onClick="show_ddns_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show Dynamic DNS");?></a>
726
				</div>
727
				<div id="showddns" style="display:none">
728
					<input valign="middle" type="checkbox" value="yes" name="ddnsupdate" id="ddnsupdate" <?php if($pconfig['ddnsupdate']) echo " checked"; ?>>&nbsp;
729
					<b><?=gettext("Enable registration of DHCP client names in DNS.");?></b><br />
730
					<p>
731
					<input name="ddnsdomain" type="text" class="formfld unknown" id="ddnsdomain" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomain']);?>"><br />
732
					<?=gettext("Note: Leave blank to disable dynamic DNS registration.");?><br />
733
					<?=gettext("Enter the dynamic DNS domain which will be used to register client names in the DNS server.");?>
734
				</div>
735
			</td>
736
			</tr>
737
			<tr>
738
			<td width="22%" valign="top" class="vncell"><?=gettext("NTP servers");?></td>
739
			<td width="78%" class="vtable">
740
				<div id="showntpbox">
741
					<input type="button" onClick="show_ntp_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show NTP configuration");?></a>
742
				</div>
743
				<div id="showntp" style="display:none">
744
					<input name="ntp1" type="text" class="formfld unknown" id="ntp1" size="20" value="<?=htmlspecialchars($pconfig['ntp1']);?>"><br>
745
					<input name="ntp2" type="text" class="formfld unknown" id="ntp2" size="20" value="<?=htmlspecialchars($pconfig['ntp2']);?>">
746
				</div>
747
			</td>
748
			</tr>
749
			<tr>
750
			<td width="22%" valign="top" class="vncell"><?=gettext("TFTP server");?></td>
751
			<td width="78%" class="vtable">
752
			<div id="showtftpbox">
753
				<input type="button" onClick="show_tftp_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show TFTP configuration");?></a>
754
			</div>
755
			<div id="showtftp" style="display:none">
756
				<input name="tftp" type="text" class="formfld unknown" id="tftp" size="50" value="<?=htmlspecialchars($pconfig['tftp']);?>"><br>
757
				<?=gettext("Leave blank to disable.  Enter a full hostname or IP for the TFTP server.");?>
758
			</div>
759
			</td>
760
			</tr>
761
			<tr>
762
			<td width="22%" valign="top" class="vncell"><?=gettext("LDAP URI");?></td>
763
			<td width="78%" class="vtable">
764
				<div id="showldapbox">
765
					<input type="button" onClick="show_ldap_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show LDAP configuration");?></a>
766
				</div>
767
				<div id="showldap" style="display:none">
768
					<input name="ldap" type="text" class="formfld unknown" id="ldap" size="80" value="<?=htmlspecialchars($pconfig['ldap']);?>"><br>
769
					<?=gettext("Leave blank to disable.  Enter a full URI for the LDAP server in the form ldap://ldap.example.com/dc=example,dc=com");?>
770
				</div>
771
			</td>
772
			</tr>
773
			<tr>
774
			<td width="22%" valign="top" class="vncell"><?=gettext("Enable network booting");?></td>
775
			<td width="78%" class="vtable">
776
				<div id="shownetbootbox">
777
					<input type="button" onClick="show_netboot_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show Network booting");?></a>
778
				</div>
779
				<div id="shownetboot" style="display:none">
780
					<input valign="middle" type="checkbox" value="yes" name="netboot" id="netboot" <?php if($pconfig['netboot']) echo " checked"; ?>>&nbsp;
781
					<b><?=gettext("Enables network booting.");?></b>
782
					<p>
783
					<?=gettext("Enter the IP of the"); ?> <b><?=gettext("next-server"); ?></b>
784
					<input name="nextserver" type="text" class="formfld unknown" id="nextserver" size="20" value="<?=htmlspecialchars($pconfig['nextserver']);?>">
785
					<?=gettext("and the filename");?>
786
					<input name="filename" type="text" class="formfld unknown" id="filename" size="20" value="<?=htmlspecialchars($pconfig['filename']);?>"><br>
787
					<?=gettext("Note: You need both a filename and a boot server configured for this to work!");?>
788
					<p>
789
					<?=gettext("Enter the"); ?> <b><?=gettext("root-path"); ?></b>-<?=gettext("string");?>
790
					<input name="rootpath" type="text" class="formfld unknown" id="rootpath" size="90" value="<?=htmlspecialchars($pconfig['rootpath']);?>"><br>
791
					<?=gettext("Note: string-format: iscsi:(servername):(protocol):(port):(LUN):targetname");?>
792
				</div>
793
			</td>
794
			</tr>
795
			<tr>
796
			<td width="22%" valign="top" class="vncell"><?=gettext("Additional BOOTP/DHCP Options");?></td>
797
			<td width="78%" class="vtable">
798
				<div id="shownumbervaluebox">
799
					<input type="button" onClick="show_shownumbervalue()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show Additional BOOTP/DHCP Options");?></a>
800
				</div>
801
				<div id="shownumbervalue" style="display:none">
802
				<table id="maintable">
803
				<tbody>
804
				<tr>
805
				<td colspan="3">
806
					<div style="padding:5px; margin-top: 16px; margin-bottom: 16px; border:1px dashed #000066; background-color: #ffffff; color: #000000; font-size: 8pt;" id="itemhelp">
807
					<?=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="_new"><?=gettext("URL"); ?></a>
808
					</div>
809
				</td>
810
				</tr>
811
				<tr>
812
				<td><div id="onecolumn"><?=gettext("Number");?></div></td>
813
				<td><div id="twocolumn"><?=gettext("Type");?></div></td>
814
				<td><div id="threecolumn"><?=gettext("Value");?></div></td>
815
				</tr>
816
				<?php $counter = 0; ?>
817
				<?php
818
					if($pconfig['numberoptions'])
819
						foreach($pconfig['numberoptions']['item'] as $item):
820
				?>
821
					<?php
822
						$number = $item['number'];
823
						$itemtype = $item['type'];
824
						$value = $item['value'];
825
					?>
826
				<tr>
827
				<td>
828
					<input autocomplete="off" name="number<?php echo $counter; ?>" type="text" class="formfld unknown" id="number<?php echo $counter; ?>" size="10" value="<?=htmlspecialchars($number);?>" />
829
				</td>
830
				<td>
831
					<select name="itemtype<?php echo $counter; ?>" class="formselect" id="itemtype<?php echo $counter; ?>">
832
					<?php
833
					foreach ($customitemtypes as $typename => $typedescr) {
834
						echo "<option value=\"{$typename}\" ";
835
						if ($itemtype == $typename) echo "selected";
836
						echo ">" . $typedescr . "</option>";
837
					}
838
					?>
839
					</select>
840
				</td>
841
				<td>
842
					<input autocomplete="off" name="value<?php echo $counter; ?>" type="text" class="formfld unknown" id="value<?php echo $counter; ?>" size="40" value="<?=htmlspecialchars($value);?>" />
843
				</td>
844
				<td>
845
					<a onclick="removeRow(this); return false;" href="#"><img border="0" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" /></a>
846
				</td>
847
				</tr>
848
				<?php $counter++; ?>
849
				<?php endforeach; ?>
850
				</tbody>
851
				<tfoot>
852
				</tfoot>
853
				</table>
854
				<a onclick="javascript:addRowTo('maintable', 'formfldalias'); return false;" href="#">
855
					<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="<?=gettext("add another entry");?>" />
856
				</a>
857
				<script type="text/javascript">
858
					field_counter_js = 3;
859
					rows = 1;
860
					totalrows = <?php echo $counter; ?>;
861
					loaded = <?php echo $counter; ?>;
862
				</script>
863
				</div>
864

    
865
				</td>
866
			</tr>
867
			<tr>
868
			<td width="22%" valign="top">&nbsp;</td>
869
			<td width="78%">
870
				<input name="if" type="hidden" value="<?=htmlspecialchars($if);?>">
871
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)">
872
			</td>
873
			</tr>
874
			<tr>
875
			<td width="22%" valign="top">&nbsp;</td>
876
			<td width="78%"> <p><span class="vexpl"><span class="red"><strong><?=gettext("Note:");?><br>
877
				</strong></span><?=gettext("The DNS servers entered in"); ?> <a href="system.php"><?=gettext("System: " .
878
				"General setup"); ?></a> <?=gettext("(or the"); ?> <a href="services_dnsmasq.php"><?=gettext("DNS " .
879
				"forwarder"); ?></a>, <?=gettext("if enabled)"); ?> </span><span class="vexpl"><?=gettext("will " .
880
				"be assigned to clients by the DHCP server."); ?><br>
881
				<br>
882
				<?=gettext("The DHCP lease table can be viewed on the"); ?> <a href="status_dhcp_leases.php"><?=gettext("Status: " .
883
				"DHCP leases"); ?></a> <?=gettext("page."); ?><br>
884
				</span></p>
885
			</td>
886
			</tr>
887
		</table>
888
		<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
889
		<tr>
890
			<td width="25%" class="listhdrr"><?=gettext("MAC address");?></td>
891
			<td width="15%" class="listhdrr"><?=gettext("IP address");?></td>
892
			<td width="20%" class="listhdrr"><?=gettext("Hostname");?></td>
893
			<td width="30%" class="listhdr"><?=gettext("Description");?></td>
894
			<td width="10%" class="list">
895
			<table border="0" cellspacing="0" cellpadding="1">
896
			<tr>
897
			<td valign="middle" width="17"></td>
898
			<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"></a></td>
899
			</tr>
900
			</table>
901
			</td>
902
		</tr>
903
			<?php if(is_array($a_maps)): ?>
904
			<?php $i = 0; foreach ($a_maps as $mapent): ?>
905
			<?php if($mapent['mac'] <> "" or $mapent['ipaddr'] <> ""): ?>
906
		<tr>
907
		<td class="listlr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&id=<?=$i;?>';">
908
			<?=htmlspecialchars($mapent['mac']);?>
909
		</td>
910
		<td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&id=<?=$i;?>';">
911
			<?=htmlspecialchars($mapent['ipaddr']);?>&nbsp;
912
		</td>
913
		<td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&id=<?=$i;?>';">
914
			<?=htmlspecialchars($mapent['hostname']);?>&nbsp;
915
		</td>
916
		<td class="listbg" ondblclick="document.location='services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&id=<?=$i;?>';">
917
			<?=htmlspecialchars($mapent['descr']);?>&nbsp;
918
		</td>
919
		<td valign="middle" nowrap class="list">
920
			<table border="0" cellspacing="0" cellpadding="1">
921
			<tr>
922
			<td valign="middle"><a href="services_dhcp_edit.php?if=<?=htmlspecialchars($if);?>&id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
923
			<td valign="middle"><a href="services_dhcp.php?if=<?=htmlspecialchars($if);?>&act=del&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"></a></td>
924
			</tr>
925
			</table>
926
		</td>
927
		</tr>
928
		<?php endif; ?>
929
		<?php $i++; endforeach; ?>
930
		<?php endif; ?>
931
		<tr>
932
		<td class="list" colspan="4"></td>
933
		<td class="list">
934
			<table border="0" cellspacing="0" cellpadding="1">
935
			<tr>
936
			<td valign="middle" width="17"></td>
937
			<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"></a></td>
938
			</tr>
939
			</table>
940
		</td>
941
		</tr>
942
		</table>
943
	</div>
944
</td>
945
</tr>
946
</table>
947
</form>
948
<script language="JavaScript">
949
<!--
950
enable_change(false);
951
//-->
952
</script>
953
<?php include("fend.inc"); ?>
954
</body>
955
</html>
(141-141/232)