Project

General

Profile

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