Project

General

Profile

Download (41.3 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
/*  Fix failover DHCP problem
51
 *  http://article.gmane.org/gmane.comp.security.firewalls.pfsense.support/18749
52
 */
53
ini_set("memory_limit","64M");
54

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

    
101
$if = $_GET['if'];
102
if ($_POST['if'])
103
	$if = $_POST['if'];
104

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

    
115
if (!$_GET['if'])
116
	$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>";
117

    
118
$iflist = get_configured_interface_with_descr();
119

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

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

    
164
$ifcfgip = get_interface_ip($if);
165
$ifcfgsn = get_interface_subnet($if);
166

    
167
/*   set the enabled flag which will tell us if DHCP relay is enabled
168
 *   on any interface. We will use this to disable DHCP server since
169
 *   the two are not compatible with each other.
170
 */
171

    
172
$dhcrelay_enabled = false;
173
$dhcrelaycfg = $config['dhcrelay'];
174

    
175
if(is_array($dhcrelaycfg)) {
176
	foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
177
		if (isset($dhcrelayifconf['enable']) && isset($iflist[$dhcrelayif]) &&
178
			(!link_interface_to_bridge($dhcrelayif)))
179
			$dhcrelay_enabled = true;
180
	}
181
}
182

    
183
function is_inrange($test, $start, $end) {
184
	if ( (ip2ulong($test) < ip2ulong($end)) && (ip2ulong($test) > ip2ulong($start)) )
185
		return true;
186
	else
187
		return false;
188
}
189

    
190
if ($_POST) {
191

    
192
	unset($input_errors);
193

    
194
	$pconfig = $_POST;
195

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

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

    
214
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
215

    
216
		if (($_POST['range_from'] && !is_ipaddr($_POST['range_from'])))
217
			$input_errors[] = gettext("A valid range must be specified.");
218
		if (($_POST['range_to'] && !is_ipaddr($_POST['range_to'])))
219
			$input_errors[] = gettext("A valid range must be specified.");
220
		if (($_POST['gateway'] && !is_ipaddr($_POST['gateway'])))
221
			$input_errors[] = gettext("A valid IP address must be specified for the gateway.");
222
		if (($_POST['wins1'] && !is_ipaddr($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddr($_POST['wins2'])))
223
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary WINS servers.");
224
		if (($_POST['dns1'] && !is_ipaddr($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddr($_POST['dns2'])))
225
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary DNS servers.");
226

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
379
		write_config();
380

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

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

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

    
424
include("head.inc");
425

    
426
?>
427

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

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

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

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

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

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

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

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

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

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

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

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