Project

General

Profile

Download (41 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-z]{2}(?:\:[0-9a-z]{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'] == 'flag' && $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'] == 'uint8' && (!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'] == 'uint16' && (!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'] == 'uint32' && (!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'] == 'int8' && (!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'] == 'int16' && (!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'] == 'int32' && (!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
			foreach ($a_maps as $map) {
309
				if (empty($map['ipaddr']))
310
					continue;
311
				if ((ip2ulong($map['ipaddr']) > $dynsubnet_start) &&
312
					(ip2ulong($map['ipaddr']) < $dynsubnet_end)) {
313
					$input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings."));
314
					break;
315
				}
316
			}
317
		}
318
	}
319

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

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

    
335
		$config['dhcpd'][$if]['failover_peerip'] = $_POST['failover_peerip'];
336

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

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

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

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

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

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

    
375
		$config['dhcpd'][$if]['numberoptions'] = $numberoptions;
376

    
377
		write_config();
378

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

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

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

    
422
include("head.inc");
423

    
424
?>
425

    
426
<script type="text/javascript" src="/javascript/row_helper.js">
427
</script>
428

    
429
<script type="text/javascript">
430
	function itemtype_field(fieldname, fieldsize, n) {
431
		return '<select name="' + fieldname + n + '" class="formselect" id="' + fieldname + n + '"><?php
432
			$customitemtypes = array('text' => gettext('Text'), 'string' => gettext('String'), 'flag' => gettext('Boolean'),
433
				'uint8' => gettext('Unsigned 8-bit integer'), 'uint16' => gettext('Unsigned 16-bit integer'), 'uint32' => gettext('Unsigned 32-bit integer'),
434
				'int8' => gettext('Signed 8-bit integer'), 'int16' => gettext('Signed 16-bit integer'), 'int32' => gettext('Signed 32-bit integer'), 'ip-address' => gettext('IP address or host'));
435
			foreach ($customitemtypes as $typename => $typedescr) {
436
				echo "<option value=\"{$typename}\">{$typedescr}</option>";
437
			}
438
		?></select>';
439
	}
440

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

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

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

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

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

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

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

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

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

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