Project

General

Profile

Download (41.2 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	services_dhcp.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6

    
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9

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

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

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

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

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

    
43
require("guiconfig.inc");
44

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

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

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

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

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

    
113
$iflist = get_configured_interface_with_descr();
114

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

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

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

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

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

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

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

    
185
if ($_POST) {
186

    
187
	unset($input_errors);
188

    
189
	$pconfig = $_POST;
190

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

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

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

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

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

    
237
		if(gen_subnet($ifcfgip, $ifcfgsn) == $_POST['range_from'])
238
			$input_errors[] = gettext("You cannot use the network address in the starting subnet range.");
239
		if(gen_subnet_max($ifcfgip, $ifcfgsn) == $_POST['range_to'])
240
			$input_errors[] = gettext("You cannot use the broadcast address in the ending subnet range.");
241

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

    
251
		$noip = false;
252
		if(is_array($a_maps))
253
			foreach ($a_maps as $map)
254
				if (empty($map['ipaddr']))
255
					$noip = true;
256
		if ($_POST['staticarp'] && $noip)
257
			$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.";
258

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

    
284
		if (!$input_errors) {
285
			/* make sure the range lies within the current subnet */
286
			$subnet_start = ip2ulong(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
287
			$subnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
288

    
289
			if ((ip2ulong($_POST['range_from']) < $subnet_start) || (ip2ulong($_POST['range_from']) > $subnet_end) ||
290
			    (ip2ulong($_POST['range_to']) < $subnet_start) || (ip2ulong($_POST['range_to']) > $subnet_end)) {
291
				$input_errors[] = gettext("The specified range lies outside of the current subnet.");
292
			}
293

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

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

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

    
317
	if (!$input_errors) {
318
		if (!is_array($config['dhcpd'][$if]))
319
			$config['dhcpd'][$if] = array();
320
		if (!is_array($config['dhcpd'][$if]['range']))
321
			$config['dhcpd'][$if]['range'] = array();
322

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

    
332
		$config['dhcpd'][$if]['failover_peerip'] = $_POST['failover_peerip'];
333

    
334
		unset($config['dhcpd'][$if]['winsserver']);
335
		if ($_POST['wins1'])
336
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins1'];
337
		if ($_POST['wins2'])
338
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins2'];
339

    
340
		unset($config['dhcpd'][$if]['dnsserver']);
341
		if ($_POST['dns1'])
342
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns1'];
343
		if ($_POST['dns2'])
344
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns2'];
345

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

    
355
		unset($config['dhcpd'][$if]['ntpserver']);
356
		if ($_POST['ntp1'])
357
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp1'];
358
		if ($_POST['ntp2'])
359
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp2'];
360

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

    
368
		// Handle the custom options rowhelper
369
		if(isset($config['dhcpd'][$if]['numberoptions']['item']))
370
			unset($config['dhcpd'][$if]['numberoptions']['item']);
371

    
372
		$config['dhcpd'][$if]['numberoptions'] = $numberoptions;
373

    
374
		write_config();
375

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

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

    
415
$pgtitle = array(gettext("Services"),gettext("DHCP server"));
416
$statusurl = "status_dhcp_leases.php";
417
$logurl = "diag_logs_dhcp.php";
418

    
419
include("head.inc");
420

    
421
?>
422

    
423
<script type="text/javascript" src="/javascript/row_helper.js">
424
</script>
425

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

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

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

    
478
	function show_shownumbervalue() {
479
		document.getElementById("shownumbervaluebox").innerHTML='';
480
		aodiv = document.getElementById('shownumbervalue');
481
		aodiv.style.display = "block";
482
	}
483

    
484
	function show_ddns_config() {
485
		document.getElementById("showddnsbox").innerHTML='';
486
		aodiv = document.getElementById('showddns');
487
		aodiv.style.display = "block";
488
	}
489

    
490
	function show_ntp_config() {
491
		document.getElementById("showntpbox").innerHTML='';
492
		aodiv = document.getElementById('showntp');
493
		aodiv.style.display = "block";
494
	}
495

    
496
	function show_tftp_config() {
497
		document.getElementById("showtftpbox").innerHTML='';
498
		aodiv = document.getElementById('showtftp');
499
		aodiv.style.display = "block";
500
	}
501

    
502
	function show_ldap_config() {
503
		document.getElementById("showldapbox").innerHTML='';
504
		aodiv = document.getElementById('showldap');
505
		aodiv.style.display = "block";
506
	}
507

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

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

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