Project

General

Profile

Download (36.3 KB) Statistics
| Branch: | Tag: | Revision:
1 e9f147c8 Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	services_dhcp.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6 e9f147c8 Scott Ullrich
7 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9 e9f147c8 Scott Ullrich
10 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12 e9f147c8 Scott Ullrich
13 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15 e9f147c8 Scott Ullrich
16 5b237745 Scott Ullrich
	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 e9f147c8 Scott Ullrich
20 5b237745 Scott Ullrich
	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 1d333258 Scott Ullrich
/*
32
	pfSense_BUILDER_BINARIES:	/bin/rm
33
	pfSense_MODULE:	interfaces
34
*/
35 5b237745 Scott Ullrich
36 6b07c15a Matthew Grooms
##|+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 b7597d4e Bill Marquette
require("guiconfig.inc");
44 5b237745 Scott Ullrich
45 2ee0410f Scott Ullrich
if(!$g['services_dhcp_server_enable']) {
46
	Header("Location: /");
47
	exit;
48
}
49
50 d5f5cf26 Scott Ullrich
/*  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 c2ffc6c1 jim-p
/* 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 69ec9ecf jim-p
	if (!file_exists($leasesfile))
63
		return;
64 c2ffc6c1 jim-p
	/* 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 5b237745 Scott Ullrich
$if = $_GET['if'];
102
if ($_POST['if'])
103
	$if = $_POST['if'];
104 e9f147c8 Scott Ullrich
105 11bc553c Scott Ullrich
/* if OLSRD is enabled, allow WAN to house DHCP. */
106 a3b466b5 Scott Ullrich
if($config['installedpackages']['olsrd']) {
107
	foreach($config['installedpackages']['olsrd']['config'] as $olsrd) {
108 bc15a1b9 Scott Ullrich
			if($olsrd['enable']) {
109 48ab0cd2 Scott Ullrich
				$is_olsr_enabled = true;
110 a3b466b5 Scott Ullrich
				break;
111
			}
112
	}
113 11bc553c Scott Ullrich
}
114
115 934240ef Ermal Luçi
if (!$_GET['if'])
116
	$savemsg = "<b>The DHCP Server can only be enabled on interfaces configured with static IP addresses.<p> The interfaces not configured with static ip will not be shown.</p></b>";
117 5b237745 Scott Ullrich
118 934240ef Ermal Luçi
$iflist = get_configured_interface_with_descr();
119 5b237745 Scott Ullrich
120 1c451b06 Scott Ullrich
/* set the starting interface */
121 0a2c6a5b Scott Ullrich
if($config['interfaces']['lan']) {
122 1c451b06 Scott Ullrich
	if (!$if || !isset($iflist[$if]))
123
		$if = "lan";
124 89019922 Ermal Luçi
} else
125 1c451b06 Scott Ullrich
	$if = "wan";
126 0a2c6a5b Scott Ullrich
127 89019922 Ermal Luçi
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 518030b3 Scott Ullrich
	$pconfig['numberoptions'] = $config['dhcpd'][$if]['numberoptions'];
154 89019922 Ermal Luçi
	if (!is_array($config['dhcpd'][$if]['staticmap'])) 
155
        	$config['dhcpd'][$if]['staticmap'] = array();
156
	$a_maps = &$config['dhcpd'][$if]['staticmap'];
157
}
158 31c59d0d Scott Ullrich
159 a55e9c70 Ermal Lu?i
$ifcfgip = get_interface_ip($if);
160
$ifcfgsn = get_interface_subnet($if);
161 5b237745 Scott Ullrich
162 3d7b7757 Chris Buechler
163
/*   set the enabled flag which will tell us if DHCP relay is enabled
164
 *   on any interface.   We will use this to disable DHCP server since
165
 *   the two are not compatible with each other.
166
 */
167
168
$dhcrelay_enabled = false;
169
$dhcrelaycfg = $config['dhcrelay'];
170
171
if(is_array($dhcrelaycfg)) {
172
	foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
173
		if (isset($dhcrelayifconf['enable']) &&
174
			(($dhcrelayif == "lan") ||
175
			(isset($config['interfaces'][$dhcrelayif]['enable']) &&
176 7ec05d27 Ermal Luçi
			$config['interfaces'][$dhcrelayif]['if'] && (!link_interface_to_bridge($dhcrelayif)))))
177 3d7b7757 Chris Buechler
			$dhcrelay_enabled = true;
178
	}
179
}
180
181 0ea7462d Bill Marquette
function is_inrange($test, $start, $end) {
182 dd5b2ec6 Bill Marquette
	if ( (ip2long($test) < ip2long($end)) && (ip2long($test) > ip2long($start)) )
183 0ea7462d Bill Marquette
		return true;
184
	else
185
		return false;
186
}
187 b7597d4e Bill Marquette
188 5b237745 Scott Ullrich
if ($_POST) {
189
190
	unset($input_errors);
191 b7597d4e Bill Marquette
192 5b237745 Scott Ullrich
	$pconfig = $_POST;
193
194
	/* input validation */
195
	if ($_POST['enable']) {
196
		$reqdfields = explode(" ", "range_from range_to");
197
		$reqdfieldsn = explode(",", "Range begin,Range end");
198 e9f147c8 Scott Ullrich
199 5b237745 Scott Ullrich
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
200 e2bce342 Scott Ullrich
		
201 5b237745 Scott Ullrich
		if (($_POST['range_from'] && !is_ipaddr($_POST['range_from']))) {
202
			$input_errors[] = "A valid range must be specified.";
203
		}
204
		if (($_POST['range_to'] && !is_ipaddr($_POST['range_to']))) {
205
			$input_errors[] = "A valid range must be specified.";
206
		}
207 6a01ea44 Bill Marquette
		if (($_POST['gateway'] && !is_ipaddr($_POST['gateway']))) {
208 f9261419 Bill Marquette
			$input_errors[] = "A valid IP address must be specified for the gateway.";
209 6a01ea44 Bill Marquette
		}
210 5b237745 Scott Ullrich
		if (($_POST['wins1'] && !is_ipaddr($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddr($_POST['wins2']))) {
211 4cab31d0 Scott Ullrich
			$input_errors[] = "A valid IP address must be specified for the primary/secondary WINS servers.";
212
		}
213
		if (($_POST['dns1'] && !is_ipaddr($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddr($_POST['dns2']))) {
214
			$input_errors[] = "A valid IP address must be specified for the primary/secondary DNS servers.";
215 5b237745 Scott Ullrich
		}
216
		if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60))) {
217
			$input_errors[] = "The default lease time must be at least 60 seconds.";
218
		}
219
		if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime']))) {
220
			$input_errors[] = "The maximum lease time must be at least 60 seconds and higher than the default lease time.";
221
		}
222 4e9cd828 Seth Mos
		if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain']))) {
223
			$input_errors[] = "A valid domain name must be specified for the dynamic DNS registration.";
224
		}
225 ad171999 Seth Mos
		if (($_POST['ntp1'] && !is_ipaddr($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddr($_POST['ntp2']))) {
226
			$input_errors[] = "A valid IP address must be specified for the primary/secondary NTP servers.";
227
		}
228 ee1b024e Martin Fuchs
		if (($_POST['domain'] && !is_domain($_POST['domain']))) {
229
			$input_errors[] = "A valid domain name must be specified for the DNS domain.";
230
    }
231
		if (($_POST['tftp'] && !is_ipaddr($_POST['tftp']))) {
232
			$input_errors[] = "A valid IP address must be specified for the tftp server.";
233 53f926df Martin Fuchs
		}
234 4e9cd828 Seth Mos
		if (($_POST['nextserver'] && !is_ipaddr($_POST['nextserver']))) {
235
			$input_errors[] = "A valid IP address must be specified for the network boot server.";
236
		}
237 e9f147c8 Scott Ullrich
238 5b237745 Scott Ullrich
		if (!$input_errors) {
239
			/* make sure the range lies within the current subnet */
240 a55e9c70 Ermal Lu?i
			$subnet_start = (ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn));
241
			$subnet_end = (ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn)));
242 e9f147c8 Scott Ullrich
243 5b237745 Scott Ullrich
			if ((ip2long($_POST['range_from']) < $subnet_start) || (ip2long($_POST['range_from']) > $subnet_end) ||
244
			    (ip2long($_POST['range_to']) < $subnet_start) || (ip2long($_POST['range_to']) > $subnet_end)) {
245 e9f147c8 Scott Ullrich
				$input_errors[] = "The specified range lies outside of the current subnet.";
246 5b237745 Scott Ullrich
			}
247 e9f147c8 Scott Ullrich
248 5b237745 Scott Ullrich
			if (ip2long($_POST['range_from']) > ip2long($_POST['range_to']))
249
				$input_errors[] = "The range is invalid (first element higher than second element).";
250 e9f147c8 Scott Ullrich
251 5b237745 Scott Ullrich
			/* make sure that the DHCP Relay isn't enabled on this interface */
252
			if (isset($config['dhcrelay'][$if]['enable']))
253
				$input_errors[] = "You must disable the DHCP relay on the {$iflist[$if]} interface before enabling the DHCP server.";
254
		}
255
	}
256
257
	if (!$input_errors) {
258 89019922 Ermal Luçi
		if (!is_array($config['dhcpd'][$if]))
259
			$config['dhcpd'][$if] = array();
260
		if (!is_array($config['dhcpd'][$if]['range']))
261
			$config['dhcpd'][$if]['range'] = array();
262
263 5b237745 Scott Ullrich
		$config['dhcpd'][$if]['range']['from'] = $_POST['range_from'];
264
		$config['dhcpd'][$if]['range']['to'] = $_POST['range_to'];
265
		$config['dhcpd'][$if]['defaultleasetime'] = $_POST['deftime'];
266
		$config['dhcpd'][$if]['maxleasetime'] = $_POST['maxtime'];
267 48ab0cd2 Scott Ullrich
		$config['dhcpd'][$if]['netmask'] = $_POST['netmask'];
268 d378c59b Scott Ullrich
		$previous = $config['dhcpd'][$if]['failover_peerip'];
269 1d333258 Scott Ullrich
		if($previous <> $_POST['failover_peerip']) 
270
			mwexec("/bin/rm -rf /var/dhcpd/var/db/*");
271
272 ea166a33 Scott Ullrich
		$config['dhcpd'][$if]['failover_peerip'] = $_POST['failover_peerip'];
273 e9f147c8 Scott Ullrich
274 5b237745 Scott Ullrich
		unset($config['dhcpd'][$if]['winsserver']);
275
		if ($_POST['wins1'])
276
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins1'];
277
		if ($_POST['wins2'])
278
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins2'];
279 4cab31d0 Scott Ullrich
280 94a9cf1a Scott Ullrich
		unset($config['dhcpd'][$if]['dnsserver']);
281 e9f147c8 Scott Ullrich
		if ($_POST['dns1'])
282 06d754d4 Scott Ullrich
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns1'];
283 e9f147c8 Scott Ullrich
		if ($_POST['dns2'])
284 06d754d4 Scott Ullrich
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns2'];
285 e9f147c8 Scott Ullrich
286 f9261419 Bill Marquette
		$config['dhcpd'][$if]['gateway'] = $_POST['gateway'];
287 1ebf937f Martin Fuchs
		$config['dhcpd'][$if]['domain'] = $_POST['domain'];
288 9be23653 Martin Fuchs
		$config['dhcpd'][$if]['domainsearchlist'] = $_POST['domainsearchlist'];
289 6a01ea44 Bill Marquette
		$config['dhcpd'][$if]['denyunknown'] = ($_POST['denyunknown']) ? true : false;
290
		$config['dhcpd'][$if]['enable'] = ($_POST['enable']) ? true : false;
291
		$config['dhcpd'][$if]['staticarp'] = ($_POST['staticarp']) ? true : false;
292 4e9cd828 Seth Mos
		$config['dhcpd'][$if]['ddnsdomain'] = $_POST['ddnsdomain'];
293
		$config['dhcpd'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
294 ad171999 Seth Mos
295
		unset($config['dhcpd'][$if]['ntpserver']);
296
		if ($_POST['ntp1'])
297
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp1'];
298
		if ($_POST['ntp2'])
299
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp2'];
300
301 6c23757b Martin Fuchs
		$config['dhcpd'][$if]['tftp'] = $_POST['tftp'];
302
		$config['dhcpd'][$if]['ldap'] = $_POST['ldap'];
303 4e9cd828 Seth Mos
		$config['dhcpd'][$if]['netboot'] = ($_POST['netboot']) ? true : false;
304
		$config['dhcpd'][$if]['next-server'] = $_POST['nextserver'];
305
		$config['dhcpd'][$if]['filename'] = $_POST['filename'];
306 ee1b024e Martin Fuchs
		$config['dhcpd'][$if]['rootpath'] = $_POST['rootpath'];
307 9c748b70 Scott Ullrich
308 d72b4114 Scott Ullrich
		// Handle the custom options rowhelper
309 518030b3 Scott Ullrich
		$numbervalue = array();
310
		unset($config['dhcpd'][$if]['numberoptions']['item']);
311
		for($x=0; $x<isset($_POST["number{$x}"]); $x++) {
312 c7820b65 Scott Ullrich
			if(is_int(intval($_POST["number{$x}"]))) {
313 990a271c Scott Ullrich
				$numbervalue['number'] = htmlspecialchars($_POST["number{$x}"]);
314
				$numbervalue['value'] = htmlspecialchars($_POST["value{$x}"]);
315
				$config['dhcpd'][$if]['numberoptions']['item'][] = $numbervalue;
316
			}
317 518030b3 Scott Ullrich
		}
318 d72b4114 Scott Ullrich
		
319
		// Reload the new pconfig variable that the forum uses.
320 518030b3 Scott Ullrich
		$pconfig['numberoptions'] = $config['dhcpd'][$if]['numberoptions'];
321
322 5b237745 Scott Ullrich
		write_config();
323 80933129 Bill Marquette
324
		/* static arp configuration */
325 c5a0fd3c Scott Ullrich
		interfaces_staticarp_configure($if);
326 e9f147c8 Scott Ullrich
327 5b237745 Scott Ullrich
		$retval = 0;
328 6a01ea44 Bill Marquette
		$retvaldhcp = 0;
329
		$retvaldns = 0;
330 c2ffc6c1 jim-p
		/* Stop DHCP so we can cleanup leases */
331
		killbyname("dhcpd");
332
		dhcp_clean_leases();
333 6a01ea44 Bill Marquette
		/* dnsmasq_configure calls dhcpd_configure */
334
		/* no need to restart dhcpd twice */
335
		if (isset($config['dnsmasq']['regdhcpstatic']))	{
336
			$retvaldns = services_dnsmasq_configure();
337
			if ($retvaldns == 0) {
338 a368a026 Ermal Lu?i
				clear_subsystem_dirty('hosts');
339
				clear_subsystem_dirty('staticmaps');
340 6a01ea44 Bill Marquette
			}					
341
		} else {
342
			$retvaldhcp = services_dhcpd_configure();	
343 a368a026 Ermal Lu?i
			if ($retvaldhcp == 0)
344
				clear_subsystem_dirty('staticmaps');
345 6a01ea44 Bill Marquette
		}	
346
		if($retvaldhcp == 1 || $retvaldns == 1)
347
			$retval = 1;
348 5b237745 Scott Ullrich
		$savemsg = get_std_save_message($retval);
349
	}
350
}
351
352
if ($_GET['act'] == "del") {
353
	if ($a_maps[$_GET['id']]) {
354
		unset($a_maps[$_GET['id']]);
355
		write_config();
356 6a01ea44 Bill Marquette
		if(isset($config['dhcpd'][$if]['enable'])) {
357 a368a026 Ermal Lu?i
			mark_subsystem_dirty('staticmaps');
358 6a01ea44 Bill Marquette
			if (isset($config['dnsmasq']['regdhcpstatic']))
359 a368a026 Ermal Lu?i
				mark_subsystem_dirty('hosts');
360 6a01ea44 Bill Marquette
		}
361 5b237745 Scott Ullrich
		header("Location: services_dhcp.php?if={$if}");
362
		exit;
363
	}
364
}
365 4df96eff Scott Ullrich
366 d88c6a9f Scott Ullrich
$pgtitle = array("Services","DHCP server");
367 4df96eff Scott Ullrich
include("head.inc");
368
369 5b237745 Scott Ullrich
?>
370 4df96eff Scott Ullrich
371 518030b3 Scott Ullrich
<script type="text/javascript" src="/javascript/row_helper.js">
372
</script>
373 4e9cd828 Seth Mos
374 518030b3 Scott Ullrich
<script type="text/javascript">
375
	rowname[0] = "number";
376
	rowtype[0] = "textbox";
377 4e10cf0a Scott Ullrich
	rowsize[0] = "10";
378 518030b3 Scott Ullrich
	rowname[1] = "value";
379
	rowtype[1] = "textbox";
380 4e10cf0a Scott Ullrich
	rowsize[1] = "55";
381 518030b3 Scott Ullrich
</script>
382 4e9cd828 Seth Mos
383 518030b3 Scott Ullrich
<script type="text/javascript" language="JavaScript">
384
	function enable_change(enable_over) {
385
		var endis;
386
		endis = !(document.iform.enable.checked || enable_over);
387
		document.iform.range_from.disabled = endis;
388
		document.iform.range_to.disabled = endis;
389
		document.iform.wins1.disabled = endis;
390
		document.iform.wins2.disabled = endis;
391
		document.iform.dns1.disabled = endis;
392
		document.iform.dns2.disabled = endis;
393
		document.iform.deftime.disabled = endis;
394
		document.iform.maxtime.disabled = endis;
395
		document.iform.gateway.disabled = endis;
396
		document.iform.failover_peerip.disabled = endis;
397
		document.iform.domain.disabled = endis;
398
		document.iform.domainsearchlist.disabled = endis;
399
		document.iform.staticarp.disabled = endis;
400
		document.iform.ddnsdomain.disabled = endis;
401
		document.iform.ddnsupdate.disabled = endis;
402
		document.iform.ntp1.disabled = endis;
403
		document.iform.ntp2.disabled = endis;
404
		document.iform.tftp.disabled = endis;
405
		document.iform.ldap.disabled = endis;
406
		document.iform.netboot.disabled = endis;
407
		document.iform.nextserver.disabled = endis;
408
		document.iform.filename.disabled = endis;
409
		document.iform.rootpath.disabled = endis;
410
		document.iform.denyunknown.disabled = endis;
411
	}
412 4e9cd828 Seth Mos
413 b1d132f5 Scott Ullrich
	function show_shownumbervalue() {
414
		document.getElementById("shownumbervaluebox").innerHTML='';
415
		aodiv = document.getElementById('shownumbervalue');
416
		aodiv.style.display = "block";
417
	}
418
419 518030b3 Scott Ullrich
	function show_ddns_config() {
420
		document.getElementById("showddnsbox").innerHTML='';
421
		aodiv = document.getElementById('showddns');
422
		aodiv.style.display = "block";
423
	}
424 ad171999 Seth Mos
425 518030b3 Scott Ullrich
	function show_ntp_config() {
426
		document.getElementById("showntpbox").innerHTML='';
427
		aodiv = document.getElementById('showntp');
428
		aodiv.style.display = "block";
429
	}
430 6c23757b Martin Fuchs
431 518030b3 Scott Ullrich
	function show_tftp_config() {
432
		document.getElementById("showtftpbox").innerHTML='';
433
		aodiv = document.getElementById('showtftp');
434
		aodiv.style.display = "block";
435
	}
436 6c23757b Martin Fuchs
437 518030b3 Scott Ullrich
	function show_ldap_config() {
438
		document.getElementById("showldapbox").innerHTML='';
439
		aodiv = document.getElementById('showldap');
440
		aodiv.style.display = "block";
441
	}
442 4e9cd828 Seth Mos
443 518030b3 Scott Ullrich
	function show_netboot_config() {
444
		document.getElementById("shownetbootbox").innerHTML='';
445
		aodiv = document.getElementById('shownetboot');
446
		aodiv.style.display = "block";
447
	}
448 5b237745 Scott Ullrich
</script>
449
450
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
451 b7597d4e Bill Marquette
<?php include("fbegin.inc"); ?>
452 5b237745 Scott Ullrich
<form action="services_dhcp.php" method="post" name="iform" id="iform">
453
<?php if ($input_errors) print_input_errors($input_errors); ?>
454
<?php if ($savemsg) print_info_box($savemsg); ?>
455 3d7b7757 Chris Buechler
<?php 
456
	if ($dhcrelay_enabled) {
457
		echo "DHCP Relay is currently enabled.  Cannot enable the DHCP Server service while the DHCP Relay is enabled on any interface.";
458
		include("fend.inc"); 
459
		echo "</body>";
460
		echo "</html>";
461
		exit;
462
	}
463
?>
464 a368a026 Ermal Lu?i
<?php if (is_subsystem_dirty('staticmaps')): ?><p>
465 5b237745 Scott Ullrich
<?php print_info_box_np("The static mapping configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
466
<?php endif; ?>
467
<table width="100%" border="0" cellpadding="0" cellspacing="0">
468
  <tr><td>
469 f0cdf141 Scott Ullrich
  <?php
470
	/* active tabs */
471
	$tab_array = array();
472
	$tabscounter = 0;
473
	$i = 0;
474
	foreach ($iflist as $ifent => $ifname) {
475 934240ef Ermal Luçi
        	$oc = $config['interfaces'][$ifent];
476
        	if (!is_ipaddr($oc['ipaddr']))
477
			continue;
478 f0cdf141 Scott Ullrich
		if ($ifent == $if)
479
			$active = true;
480
		else
481
			$active = false;
482
		$tab_array[] = array($ifname, $active, "services_dhcp.php?if={$ifent}");
483 934240ef Ermal Luçi
		$tabscounter++;
484
	}
485
	if ($tabscounter == 0) {
486
		echo "</td></tr></table></form>";
487
		include("fend.inc");
488
		echo "</body>";
489
		echo "</html>";
490
		exit;
491 f0cdf141 Scott Ullrich
	}
492
	display_top_tabs($tab_array);
493
  ?>
494 5b237745 Scott Ullrich
  </td></tr>
495 e9f147c8 Scott Ullrich
  <tr>
496 d732f186 Bill Marquette
    <td>
497
	<div id="mainarea">
498
              <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
499 e9f147c8 Scott Ullrich
                      <tr>
500 5b237745 Scott Ullrich
                        <td width="22%" valign="top" class="vtable">&nbsp;</td>
501
                        <td width="78%" class="vtable">
502 518030b3 Scott Ullrich
			  			<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
503 e9f147c8 Scott Ullrich
                          <strong>Enable DHCP server on
504 5b237745 Scott Ullrich
                          <?=htmlspecialchars($iflist[$if]);?>
505
                          interface</strong></td>
506
                      </tr>
507
				  <tr>
508
	              <td width="22%" valign="top" class="vtable">&nbsp;</td>
509
                      <td width="78%" class="vtable">
510 518030b3 Scott Ullrich
					  <input name="denyunknown" id="denyunknown" type="checkbox" value="yes" <?php if ($pconfig['denyunknown']) echo "checked"; ?>>
511 5b237745 Scott Ullrich
                      <strong>Deny unknown clients</strong><br>
512
                      If this is checked, only the clients defined below will get DHCP leases from this server. </td>
513
		      		  </tr>
514 e9f147c8 Scott Ullrich
                      <tr>
515 5b237745 Scott Ullrich
                        <td width="22%" valign="top" class="vncellreq">Subnet</td>
516 e9f147c8 Scott Ullrich
                        <td width="78%" class="vtable">
517 a55e9c70 Ermal Lu?i
                          <?=gen_subnet($ifcfgip, $ifcfgsn);?>
518 5b237745 Scott Ullrich
                        </td>
519
                      </tr>
520 e9f147c8 Scott Ullrich
                      <tr>
521
                        <td width="22%" valign="top" class="vncellreq">Subnet
522 5b237745 Scott Ullrich
                          mask</td>
523 e9f147c8 Scott Ullrich
                        <td width="78%" class="vtable">
524 a55e9c70 Ermal Lu?i
                          <?=gen_subnet_mask($ifcfgsn);?>
525 5b237745 Scott Ullrich
                        </td>
526
                      </tr>
527 e9f147c8 Scott Ullrich
                      <tr>
528
                        <td width="22%" valign="top" class="vncellreq">Available
529 5b237745 Scott Ullrich
                          range</td>
530 e9f147c8 Scott Ullrich
                        <td width="78%" class="vtable">
531 a55e9c70 Ermal Lu?i
                          <?=long2ip(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn));?>
532 e9f147c8 Scott Ullrich
                          -
533 a55e9c70 Ermal Lu?i
                          <?=long2ip(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))); ?>
534 5b237745 Scott Ullrich
                        </td>
535
                      </tr>
536 48ab0cd2 Scott Ullrich
					  <?php if($is_olsr_enabled): ?>
537 e9f147c8 Scott Ullrich
                      <tr>
538 48ab0cd2 Scott Ullrich
                        <td width="22%" valign="top" class="vncellreq">Subnet Mask</td>
539 e9f147c8 Scott Ullrich
                        <td width="78%" class="vtable">
540 b5c78501 Seth Mos
	                        <select name="netmask" class="formselect" id="netmask">
541 48ab0cd2 Scott Ullrich
							<?php
542
							for ($i = 32; $i > 0; $i--) {
543
								if($i <> 31) {
544
									echo "<option value=\"{$i}\" ";
545 983c0b1f Scott Ullrich
									if ($i == $pconfig['netmask']) echo "selected";
546 48ab0cd2 Scott Ullrich
									echo ">" . $i . "</option>";
547
								}
548
							}
549
							?>
550
							</select>
551
                        </td>
552
                      </tr>
553 e9f147c8 Scott Ullrich
                      <?php endif; ?>
554
                      <tr>
555 5b237745 Scott Ullrich
                        <td width="22%" valign="top" class="vncellreq">Range</td>
556 e9f147c8 Scott Ullrich
                        <td width="78%" class="vtable">
557 b5c78501 Seth Mos
                          <input name="range_from" type="text" class="formfld unknown" id="range_from" size="20" value="<?=htmlspecialchars($pconfig['range_from']);?>">
558
                          &nbsp;to&nbsp; <input name="range_to" type="text" class="formfld unknown" id="range_to" size="20" value="<?=htmlspecialchars($pconfig['range_to']);?>">
559 518030b3 Scott Ullrich
					   </td>
560 5b237745 Scott Ullrich
                      </tr>
561 e9f147c8 Scott Ullrich
                      <tr>
562 5b237745 Scott Ullrich
                        <td width="22%" valign="top" class="vncell">WINS servers</td>
563 e9f147c8 Scott Ullrich
                        <td width="78%" class="vtable">
564 b5c78501 Seth Mos
                          <input name="wins1" type="text" class="formfld unknown" id="wins1" size="20" value="<?=htmlspecialchars($pconfig['wins1']);?>"><br>
565
                          <input name="wins2" type="text" class="formfld unknown" id="wins2" size="20" value="<?=htmlspecialchars($pconfig['wins2']);?>">
566 518030b3 Scott Ullrich
					   </td>
567 5b237745 Scott Ullrich
                      </tr>
568 e9f147c8 Scott Ullrich
                      <tr>
569 4cab31d0 Scott Ullrich
                        <td width="22%" valign="top" class="vncell">DNS servers</td>
570 e9f147c8 Scott Ullrich
                        <td width="78%" class="vtable">
571 b5c78501 Seth Mos
                          <input name="dns1" type="text" class="formfld unknown" id="dns1" size="20" value="<?=htmlspecialchars($pconfig['dns1']);?>"><br>
572
                          <input name="dns2" type="text" class="formfld unknown" id="dns2" size="20" value="<?=htmlspecialchars($pconfig['dns2']);?>"><br>
573 518030b3 Scott Ullrich
					   	  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.  
574
					   </td>
575 4cab31d0 Scott Ullrich
                      </tr>
576 e9f147c8 Scott Ullrich
                     <tr>
577 b7597d4e Bill Marquette
                       <td width="22%" valign="top" class="vncell">Gateway</td>
578 e9f147c8 Scott Ullrich
                       <td width="78%" class="vtable">
579 b5c78501 Seth Mos
                         <input name="gateway" type="text" class="formfld host" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>"><br>
580 518030b3 Scott Ullrich
			 			 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.
581
					   </td>
582 1ebf937f Martin Fuchs
                     </tr>
583 9be23653 Martin Fuchs
                      <tr>
584 1ebf937f Martin Fuchs
                       <td width="22%" valign="top" class="vncell">Domain-Name</td>
585
                       <td width="78%" class="vtable">
586 b5c78501 Seth Mos
                         <input name="domain" type="text" class="formfld unknown" id="domain" size="20" value="<?=htmlspecialchars($pconfig['domain']);?>"><br>
587 518030b3 Scott Ullrich
			 			 The default is to use the domainname of the router as DNS-Search string that is served via DHCP. Specify an alternate DNS-Search string here.
588
					 </td>
589 2af4c579 Scott Ullrich
                     </tr>
590 e9f147c8 Scott Ullrich
                      <tr>
591 9be23653 Martin Fuchs
                       <td width="22%" valign="top" class="vncell">Domain-Searchlist</td>
592
                       <td width="78%" class="vtable">
593 b5c78501 Seth Mos
                         <input name="domainsearchlist" type="text" class="formfld unknown" id="domainsearchlist" size="20" value="<?=htmlspecialchars($pconfig['domainsearchlist']);?>"><br>
594 518030b3 Scott Ullrich
			 				DNS-Searchlist: the DHCP server can serve a list of domains to be searched.
595
						</td>
596 9be23653 Martin Fuchs
                     </tr>                     
597
                      <tr>
598
                        <td width="22%" valign="top" class="vncell">Default lease time</td>
599 e9f147c8 Scott Ullrich
                        <td width="78%" class="vtable">
600 b5c78501 Seth Mos
                          <input name="deftime" type="text" class="formfld unknown" id="deftime" size="10" value="<?=htmlspecialchars($pconfig['deftime']);?>">
601 5b237745 Scott Ullrich
                          seconds<br>
602 e9f147c8 Scott Ullrich
                          This is used for clients that do not ask for a specific
603 5b237745 Scott Ullrich
                          expiration time.<br>
604 2af4c579 Scott Ullrich
                          The default is 7200 seconds.
605 518030b3 Scott Ullrich
					   </td>
606 5b237745 Scott Ullrich
                      </tr>
607 e9f147c8 Scott Ullrich
                      <tr>
608 9be23653 Martin Fuchs
                        <td width="22%" valign="top" class="vncell">Maximum lease time</td>
609 e9f147c8 Scott Ullrich
                        <td width="78%" class="vtable">
610 b5c78501 Seth Mos
                          <input name="maxtime" type="text" class="formfld unknown" id="maxtime" size="10" value="<?=htmlspecialchars($pconfig['maxtime']);?>">
611 5b237745 Scott Ullrich
                          seconds<br>
612 e9f147c8 Scott Ullrich
                          This is the maximum lease time for clients that ask
613 5b237745 Scott Ullrich
                          for a specific expiration time.<br>
614 2af4c579 Scott Ullrich
                          The default is 86400 seconds.
615 518030b3 Scott Ullrich
					   </td>
616 5b237745 Scott Ullrich
                      </tr>
617 ea166a33 Scott Ullrich
                      <tr>
618
                        <td width="22%" valign="top" class="vncell">Failover peer IP:</td>
619
                        <td width="78%" class="vtable">
620 b5c78501 Seth Mos
				<input name="failover_peerip" type="text" class="formfld host" id="failover_peerip" size="20" value="<?=htmlspecialchars($pconfig['failover_peerip']);?>"><br>
621 be586e5f Scott Ullrich
				Leave blank to disable.  Enter the REAL address of the other machine.  Machines must be using CARP.
622 ea166a33 Scott Ullrich
			</td>
623 518030b3 Scott Ullrich
			</tr>
624
			<tr>
625
				<td width="22%" valign="top" class="vncell">
626
					Static ARP
627
				</td>
628
				<td width="78%" class="vtable">
629
					<table>
630
						<tr>
631
							<td>
632
								<input valign="middle" type="checkbox" value="yes" name="staticarp" id="staticarp" <?php if($pconfig['staticarp']) echo " checked"; ?>>&nbsp;
633
							</td>
634
							<td>
635
								<b>Enable Static ARP entries</b>
636
							</td>
637
						</tr>
638
						<tr>
639
							<td>
640
								&nbsp;
641
							</td>
642
							<td>
643
								<span class="red"><strong>Note:</strong></span> Only the machines listed below will be able to communicate with the firewall on this NIC.
644
							</td>
645
						</tr>
646
					</table>
647
				</td>
648
			</tr>
649
			<tr>
650
				<td width="22%" valign="top" class="vncell">
651
					Dynamic DNS
652
				</td>
653
				<td width="78%" class="vtable">
654
					<div id="showddnsbox">
655
						<input type="button" onClick="show_ddns_config()" value="Advanced"></input> - Show Dynamic DNS</a>
656
					</div>
657
					<div id="showddns" style="display:none">
658
						<input valign="middle" type="checkbox" value="yes" name="ddnsupdate" id="ddnsupdate" <?php if($pconfig['ddnsupdate']) echo " checked"; ?>>&nbsp;
659
						<b>Enable registration of DHCP client names in DNS.</b><br />
660
						<p>
661
						<input name="ddnsdomain" type="text" class="formfld unknown" id="ddnsdomain" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomain']);?>"><br />
662
						Note: Leave blank to disable dynamic DNS registration.<br />
663
						Enter the dynamic DNS domain which will be used to register client names in the DNS server.
664
					</div>
665
				</td>
666 ea166a33 Scott Ullrich
		      </tr>
667 518030b3 Scott Ullrich
			<tr>
668
				<td width="22%" valign="top" class="vncell">NTP servers</td>
669
				<td width="78%" class="vtable">
670 ad171999 Seth Mos
				<div id="showntpbox">
671
					<input type="button" onClick="show_ntp_config()" value="Advanced"></input> - Show NTP configuration</a>
672
				</div>
673
				<div id="showntp" style="display:none">
674 b5c78501 Seth Mos
					<input name="ntp1" type="text" class="formfld unknown" id="ntp1" size="20" value="<?=htmlspecialchars($pconfig['ntp1']);?>"><br>
675
					<input name="ntp2" type="text" class="formfld unknown" id="ntp2" size="20" value="<?=htmlspecialchars($pconfig['ntp2']);?>">
676 ad171999 Seth Mos
				</div>
677
			</td>
678 518030b3 Scott Ullrich
			</tr>
679
			<tr>
680
				<td width="22%" valign="top" class="vncell">
681
					TFTP server
682
				</td>
683
				<td width="78%" class="vtable">
684 6c23757b Martin Fuchs
				<div id="showtftpbox">
685
					<input type="button" onClick="show_tftp_config()" value="Advanced"></input> - Show TFTP configuration</a>
686
				</div>
687
				<div id="showtftp" style="display:none">
688 b5c78501 Seth Mos
					<input name="tftp" type="text" class="formfld unknown" id="tftp" size="50" value="<?=htmlspecialchars($pconfig['tftp']);?>"><br>
689 6c23757b Martin Fuchs
					Leave blank to disable.  Enter a full hostname or IP for the TFTP server.
690
				</div>
691
			</td>
692 518030b3 Scott Ullrich
			</tr>
693
			<tr>
694
				<td width="22%" valign="top" class="vncell">LDAP URI</td>
695
					<td width="78%" class="vtable">
696
						<div id="showldapbox">
697
							<input type="button" onClick="show_ldap_config()" value="Advanced"></input> - Show LDAP configuration</a>
698
						</div>
699
						<div id="showldap" style="display:none">
700
							<input name="ldap" type="text" class="formfld unknown" id="ldap" size="80" value="<?=htmlspecialchars($pconfig['ldap']);?>"><br>
701
							Leave blank to disable.  Enter a full URI for the LDAP server in the form ldap://ldap.example.com/dc=example,dc=com
702
						</div>
703
					</td>
704
			</tr>
705
			<tr>
706
				<td width="22%" valign="top" class="vncell">Enable Network booting</td>
707
				<td width="78%" class="vtable">
708
					<div id="shownetbootbox">
709
						<input type="button" onClick="show_netboot_config()" value="Advanced"></input> - Show Network booting</a>
710
					</div>
711
					<div id="shownetboot" style="display:none">
712
						<input valign="middle" type="checkbox" value="yes" name="netboot" id="netboot" <?php if($pconfig['netboot']) echo " checked"; ?>>&nbsp;
713
						<b>Enables network booting.</b>
714
						<p>
715
						Enter the IP of the <b>next-server</b>
716
						<input name="nextserver" type="text" class="formfld unknown" id="nextserver" size="20" value="<?=htmlspecialchars($pconfig['nextserver']);?>">
717
						and the filename					
718
						<input name="filename" type="text" class="formfld unknown" id="filename" size="20" value="<?=htmlspecialchars($pconfig['filename']);?>"><br>
719
						Note: You need both a filename and a boot server configured for this to work!
720
					  	<p>
721
						Enter the <b>root-path</b>-string
722
	          			<input name="rootpath" type="text" class="formfld unknown" id="rootpath" size="90" value="<?=htmlspecialchars($pconfig['rootpath']);?>"><br>
723
	          			Note: string-format: iscsi:(servername):(protocol):(port):(LUN):targetname
724
        			</div>
725 4e9cd828 Seth Mos
			</td>
726 518030b3 Scott Ullrich
			</tr>
727
			<tr>
728
729
730
				<td width="22%" valign="top" class="vncell">
731
					Additional BOOTP/DHCP Options
732
				</td>
733
				<td width="78%" class="vtable">
734 b1d132f5 Scott Ullrich
					<div id="shownumbervaluebox">
735
						<input type="button" onClick="show_shownumbervalue()" value="Advanced"></input> - Show Additional BOOTP/DHCP Options</a>
736
					</div>
737
					<div id="shownumbervalue" style="display:none">
738 518030b3 Scott Ullrich
			    <table id="maintable">
739
			        <tbody>
740
			          <tr>
741 f2305ddb Scott Ullrich
			            <td colspan="3">
742 2a778c44 Scott Ullrich
			      		    <div style="padding:5px; margin-top: 16px; margin-bottom: 16px; border:1px dashed #000066; background-color: #ffffff; color: #000000; font-size: 8pt;" id="itemhelp">
743
								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">URL</a>.
744
							</div>
745 518030b3 Scott Ullrich
			            </td>
746
			          </tr>
747
			          <tr>
748
			            <td><div id="onecolumn">Number</div></td>
749
			            <td><div id="twocolumn">Value</div></td>
750
			          </tr>
751
				<?php $counter = 0; ?>
752
				<?php 
753
					if($pconfig['numberoptions'])
754
				 		foreach($pconfig['numberoptions']['item'] as $item): 
755
				?>
756
					<?php
757
						$number = $item['number'];
758
						$value = $item['value'];
759
					?>
760
			          <tr>
761
			            <td>
762 4e10cf0a Scott Ullrich
							<input autocomplete="off" name="number<?php echo $counter; ?>" type="text" class="formfld" id="number<?php echo $counter; ?>" size="10" value="<?=htmlspecialchars($number);?>" />
763 518030b3 Scott Ullrich
			            </td>
764
			            <td>
765 4e10cf0a Scott Ullrich
							<input autocomplete="off" name="value<?php echo $counter; ?>" type="text" class="formfld" id="value<?php echo $counter; ?>" size="55" value="<?=htmlspecialchars($value);?>" />
766 518030b3 Scott Ullrich
						</td>
767
			            <td>
768
			    		<input type="image" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" onclick="removeRow(this); return false;" value="Delete" />
769
				      </td>
770
			          </tr>
771
				<?php $counter++; ?>
772
				<?php endforeach; ?>
773
			        </tbody>
774
			        <tfoot>
775
			        </tfoot>
776
				</table>
777
				<a onclick="javascript:addRowTo('maintable', 'formfldalias'); return false;" href="#">
778
					<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="add another entry" />
779
				</a>
780
				<script type="text/javascript">
781
					field_counter_js = 2;
782
					rows = 1;
783
					totalrows = <?php echo $counter; ?>;
784
					loaded = <?php echo $counter; ?>;
785
				</script>
786 b1d132f5 Scott Ullrich
				</div>
787 518030b3 Scott Ullrich
788
				</td>
789
			</tr>
790
            <tr>
791
              <td width="22%" valign="top">&nbsp;</td>
792
              <td width="78%">
793
                <input name="if" type="hidden" value="<?=$if;?>">
794
                <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
795
              </td>
796
            </tr>
797
			<tr>
798
				<td width="22%" valign="top">&nbsp;</td>
799
				<td width="78%"> <p><span class="vexpl"><span class="red"><strong>Note:<br>
800
					</strong></span>The DNS servers entered in <a href="system.php">System:
801
					General setup</a> (or the <a href="services_dnsmasq.php">DNS
802
					forwarder</a>, if enabled) </span><span class="vexpl">will
803
					be assigned to clients by the DHCP server.<br>
804
					<br>
805
					The DHCP lease table can be viewed on the <a href="diag_dhcp_leases.php">Status:
806
					DHCP leases</a> page.<br>
807
					</span></p>
808
				</td>
809
			</tr>
810
		</table>
811 7128ed17 Scott Ullrich
		<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
812 518030b3 Scott Ullrich
		<tr>
813
			<td width="25%" class="listhdrr">MAC address</td>
814
			<td width="15%" class="listhdrr">IP address</td>
815
			<td width="20%" class="listhdrr">Hostname</td>
816
			<td width="30%" class="listhdr">Description</td>
817
			<td width="10%" class="list">
818
			<table border="0" cellspacing="0" cellpadding="1">
819
		<tr>
820 d415d821 Seth Mos
			<td valign="middle" width="17"></td>
821 518030b3 Scott Ullrich
			<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>
822
			</tr>
823
			</table>
824
			</td>
825 2af4c579 Scott Ullrich
		</tr>
826 6f5b2c3e Scott Ullrich
			  <?php if(is_array($a_maps)): ?>
827 5b237745 Scott Ullrich
			  <?php $i = 0; foreach ($a_maps as $mapent): ?>
828 11c9bb94 Scott Ullrich
			  <?php if($mapent['mac'] <> "" or $mapent['ipaddr'] <> ""): ?>
829 5b237745 Scott Ullrich
                <tr>
830 2d165eff Bill Marquette
                  <td class="listlr" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
831 5b237745 Scott Ullrich
                    <?=htmlspecialchars($mapent['mac']);?>
832
                  </td>
833 2d165eff Bill Marquette
                  <td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
834 5b237745 Scott Ullrich
                    <?=htmlspecialchars($mapent['ipaddr']);?>&nbsp;
835
                  </td>
836 6a01ea44 Bill Marquette
                  <td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
837
                    <?=htmlspecialchars($mapent['hostname']);?>&nbsp;
838
                  </td>	
839 2d165eff Bill Marquette
                  <td class="listbg" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
840 d4da6249 Scott Ullrich
                    <?=htmlspecialchars($mapent['descr']);?>&nbsp;
841 5b237745 Scott Ullrich
                  </td>
842 75a70796 Bill Marquette
                  <td valign="middle" nowrap class="list">
843
                    <table border="0" cellspacing="0" cellpadding="1">
844
                      <tr>
845 677c0869 Erik Kristensen
                        <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>
846
                        <td valign="middle"><a href="services_dhcp.php?if=<?=$if;?>&act=del&id=<?=$i;?>" onclick="return confirm('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>
847 75a70796 Bill Marquette
                      </tr>
848
                    </table>
849
                  </td>
850
                </tr>
851 6f5b2c3e Scott Ullrich
		<?php endif; ?>
852 75a70796 Bill Marquette
		<?php $i++; endforeach; ?>
853 6f5b2c3e Scott Ullrich
		<?php endif; ?>
854 e9f147c8 Scott Ullrich
                <tr>
855 6a01ea44 Bill Marquette
                  <td class="list" colspan="4"></td>
856 75a70796 Bill Marquette
                  <td class="list">
857
                    <table border="0" cellspacing="0" cellpadding="1">
858
                      <tr>
859 d415d821 Seth Mos
			<td valign="middle" width="17"></td>
860 677c0869 Erik Kristensen
                        <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>
861 75a70796 Bill Marquette
                      </tr>
862
                    </table>
863
                  </td>
864
                </tr>
865 5b237745 Scott Ullrich
              </table>
866 d732f186 Bill Marquette
	</div>
867 5b237745 Scott Ullrich
    </td>
868
  </tr>
869
</table>
870
</form>
871
<script language="JavaScript">
872
<!--
873
enable_change(false);
874
//-->
875
</script>
876 b7597d4e Bill Marquette
<?php include("fend.inc"); ?>
877 5b237745 Scott Ullrich
</body>
878
</html>