Project

General

Profile

« Previous | Next » 

Revision 8f8682f7

Added by Phil Davis about 10 years ago

Code style services DHCP

View differences:

usr/local/www/services_dhcp.php
44 44
require("guiconfig.inc");
45 45
require_once("filter.inc");
46 46

  
47
if(!$g['services_dhcp_server_enable']) {
47
if (!$g['services_dhcp_server_enable']) {
48 48
	header("Location: /");
49 49
	exit;
50 50
}
51 51

  
52 52
$if = $_GET['if'];
53
if (!empty($_POST['if']))
53
if (!empty($_POST['if'])) {
54 54
	$if = $_POST['if'];
55
}
55 56

  
56 57
/* if OLSRD is enabled, allow WAN to house DHCP. */
57
if($config['installedpackages']['olsrd']) {
58
	foreach($config['installedpackages']['olsrd']['config'] as $olsrd) {
59
			if($olsrd['enable']) {
60
				$is_olsr_enabled = true;
61
				break;
62
			}
58
if ($config['installedpackages']['olsrd']) {
59
	foreach ($config['installedpackages']['olsrd']['config'] as $olsrd) {
60
		if ($olsrd['enable']) {
61
			$is_olsr_enabled = true;
62
			break;
63
		}
63 64
	}
64
}	
65
}
65 66

  
66 67
$iflist = get_configured_interface_with_descr();
67 68

  
......
70 71
	foreach ($iflist as $ifent => $ifname) {
71 72
		$oc = $config['interfaces'][$ifent];
72 73
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) ||
73
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr']))))
74
		    (!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr'])))) {
74 75
			continue;
76
		}
75 77
		$if = $ifent;
76 78
		break;
77 79
	}
78 80
}
79 81

  
80 82
$act = $_GET['act'];
81
if (!empty($_POST['act']))
83
if (!empty($_POST['act'])) {
82 84
	$act = $_POST['act'];
85
}
83 86

  
84 87
$a_pools = array();
85 88

  
86
if (is_array($config['dhcpd'][$if])){
89
if (is_array($config['dhcpd'][$if])) {
87 90
	$pool = $_GET['pool'];
88
	if (is_numeric($_POST['pool']))
91
	if (is_numeric($_POST['pool'])) {
89 92
		$pool = $_POST['pool'];
93
	}
90 94

  
91 95
	// If we have a pool but no interface name, that's not valid. Redirect away.
92 96
	if (is_numeric($pool) && empty($if)) {
......
94 98
		exit;
95 99
	}
96 100

  
97
	if (!is_array($config['dhcpd'][$if]['pool']))
101
	if (!is_array($config['dhcpd'][$if]['pool'])) {
98 102
		$config['dhcpd'][$if]['pool'] = array();
103
	}
99 104
	$a_pools = &$config['dhcpd'][$if]['pool'];
100 105

  
101
	if (is_numeric($pool) && $a_pools[$pool])
106
	if (is_numeric($pool) && $a_pools[$pool]) {
102 107
		$dhcpdconf = &$a_pools[$pool];
103
	elseif ($act == "newpool")
108
	} elseif ($act == "newpool") {
104 109
		$dhcpdconf = array();
105
	else
110
	} else {
106 111
		$dhcpdconf = &$config['dhcpd'][$if];
112
	}
107 113
}
108 114
if (is_array($dhcpdconf)) {
109 115
	// Global Options
......
118 124
		// then show it true/checked.
119 125
		foreach ($config['dhcpd'] as $dhcpdifitem) {
120 126
			$dhcpleaseinlocaltime = $dhcpdifitem['dhcpleaseinlocaltime'];
121
			if ($dhcpleaseinlocaltime)
127
			if ($dhcpleaseinlocaltime) {
122 128
				break;
129
			}
123 130
		}
124 131

  
125 132
		$pconfig['dhcpleaseinlocaltime'] = $dhcpleaseinlocaltime;
126 133

  
127
		if (!is_array($dhcpdconf['staticmap']))
134
		if (!is_array($dhcpdconf['staticmap'])) {
128 135
			$dhcpdconf['staticmap'] = array();
136
		}
129 137
		$a_maps = &$dhcpdconf['staticmap'];
130 138
	} else {
131 139
		// Options that exist only in pools
......
142 150
	$pconfig['gateway'] = $dhcpdconf['gateway'];
143 151
	$pconfig['domain'] = $dhcpdconf['domain'];
144 152
	$pconfig['domainsearchlist'] = $dhcpdconf['domainsearchlist'];
145
	list($pconfig['wins1'],$pconfig['wins2']) = $dhcpdconf['winsserver'];
146
	list($pconfig['dns1'],$pconfig['dns2'],$pconfig['dns3'],$pconfig['dns4']) = $dhcpdconf['dnsserver'];
153
	list($pconfig['wins1'], $pconfig['wins2']) = $dhcpdconf['winsserver'];
154
	list($pconfig['dns1'], $pconfig['dns2'], $pconfig['dns3'], $pconfig['dns4']) = $dhcpdconf['dnsserver'];
147 155
	$pconfig['denyunknown'] = isset($dhcpdconf['denyunknown']);
148 156
	$pconfig['ddnsdomain'] = $dhcpdconf['ddnsdomain'];
149 157
	$pconfig['ddnsdomainprimary'] = $dhcpdconf['ddnsdomainprimary'];
......
152 160
	$pconfig['ddnsupdate'] = isset($dhcpdconf['ddnsupdate']);
153 161
	$pconfig['mac_allow'] = $dhcpdconf['mac_allow'];
154 162
	$pconfig['mac_deny'] = $dhcpdconf['mac_deny'];
155
	list($pconfig['ntp1'],$pconfig['ntp2']) = $dhcpdconf['ntpserver'];
163
	list($pconfig['ntp1'], $pconfig['ntp2']) = $dhcpdconf['ntpserver'];
156 164
	$pconfig['tftp'] = $dhcpdconf['tftp'];
157 165
	$pconfig['ldap'] = $dhcpdconf['ldap'];
158 166
	$pconfig['netboot'] = isset($dhcpdconf['netboot']);
......
172 180
	$macs = explode(',', $maclist);
173 181

  
174 182
	// Loop through and look for invalid MACs.
175
	foreach ($macs as $mac)
176
		if (!is_macaddr($mac, true))
183
	foreach ($macs as $mac) {
184
		if (!is_macaddr($mac, true)) {
177 185
			return false;
186
		}
187
	}
178 188
	return true;
179 189
}
180 190

  
......
185 195
	$pconfig = $_POST;
186 196

  
187 197
	$numberoptions = array();
188
	for($x=0; $x<99; $x++) {
189
		if(isset($_POST["number{$x}"]) && ctype_digit($_POST["number{$x}"])) {
198
	for ($x=0; $x<99; $x++) {
199
		if (isset($_POST["number{$x}"]) && ctype_digit($_POST["number{$x}"])) {
190 200
			$numbervalue = array();
191 201
			$numbervalue['number'] = htmlspecialchars($_POST["number{$x}"]);
192 202
			$numbervalue['type'] = htmlspecialchars($_POST["itemtype{$x}"]);
......
200 210
	/* input validation */
201 211
	if ($_POST['enable'] || is_numeric($pool) || $act == "newpool") {
202 212
		$reqdfields = explode(" ", "range_from range_to");
203
		$reqdfieldsn = array(gettext("Range begin"),gettext("Range end"));
213
		$reqdfieldsn = array(gettext("Range begin"), gettext("Range end"));
204 214

  
205 215
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
206 216

  
207
		if (($_POST['range_from'] && !is_ipaddrv4($_POST['range_from'])))
217
		if (($_POST['range_from'] && !is_ipaddrv4($_POST['range_from']))) {
208 218
			$input_errors[] = gettext("A valid range must be specified.");
209
		if (($_POST['range_to'] && !is_ipaddrv4($_POST['range_to'])))
219
		}
220
		if (($_POST['range_to'] && !is_ipaddrv4($_POST['range_to']))) {
210 221
			$input_errors[] = gettext("A valid range must be specified.");
211
		if (($_POST['gateway'] && $_POST['gateway'] != "none" && !is_ipaddrv4($_POST['gateway'])))
222
		}
223
		if (($_POST['gateway'] && $_POST['gateway'] != "none" && !is_ipaddrv4($_POST['gateway']))) {
212 224
			$input_errors[] = gettext("A valid IP address must be specified for the gateway.");
213
		if (($_POST['wins1'] && !is_ipaddrv4($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddrv4($_POST['wins2'])))
225
		}
226
		if (($_POST['wins1'] && !is_ipaddrv4($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddrv4($_POST['wins2']))) {
214 227
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary WINS servers.");
228
		}
215 229
		$parent_ip = get_interface_ip($_POST['if']);
216 230
		if (is_ipaddrv4($parent_ip) && $_POST['gateway'] && $_POST['gateway'] != "none") {
217 231
			$parent_sn = get_interface_subnet($_POST['if']);
218
			if(!ip_in_subnet($_POST['gateway'], gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn) && !ip_in_interface_alias_subnet($_POST['if'], $_POST['gateway']))
232
			if (!ip_in_subnet($_POST['gateway'], gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn) && !ip_in_interface_alias_subnet($_POST['if'], $_POST['gateway'])) {
219 233
				$input_errors[] = sprintf(gettext("The gateway address %s does not lie within the chosen interface's subnet."), $_POST['gateway']);
234
			}
220 235
		}
221
		if (($_POST['dns1'] && !is_ipaddrv4($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddrv4($_POST['dns2'])) || ($_POST['dns3'] && !is_ipaddrv4($_POST['dns3'])) || ($_POST['dns4'] && !is_ipaddrv4($_POST['dns4'])))
236
		if (($_POST['dns1'] && !is_ipaddrv4($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddrv4($_POST['dns2'])) || ($_POST['dns3'] && !is_ipaddrv4($_POST['dns3'])) || ($_POST['dns4'] && !is_ipaddrv4($_POST['dns4']))) {
222 237
			$input_errors[] = gettext("A valid IP address must be specified for each of the DNS servers.");
238
		}
223 239

  
224
		if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60)))
225
				$input_errors[] = gettext("The default lease time must be at least 60 seconds.");
240
		if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60))) {
241
			$input_errors[] = gettext("The default lease time must be at least 60 seconds.");
242
		}
226 243

  
227 244
		if (isset($config['captiveportal']) && is_array($config['captiveportal'])) {
228 245
			$deftime = 7200; // Default value if it's empty
229
			if (is_numeric($_POST['deftime']))
246
			if (is_numeric($_POST['deftime'])) {
230 247
				$deftime = $_POST['deftime'];
248
			}
231 249

  
232 250
			foreach ($config['captiveportal'] as $cpZone => $cpdata) {
233
				if (!isset($cpdata['enable']))
251
				if (!isset($cpdata['enable'])) {
234 252
					continue;
235
				if (!isset($cpdata['timeout']) || !is_numeric($cpdata['timeout']))
253
				}
254
				if (!isset($cpdata['timeout']) || !is_numeric($cpdata['timeout'])) {
236 255
					continue;
256
				}
237 257
				$cp_ifs = explode(',', $cpdata['interface']);
238
				if (!in_array($if, $cp_ifs))
258
				if (!in_array($if, $cp_ifs)) {
239 259
					continue;
240
				if ($cpdata['timeout'] > $deftime)
260
				}
261
				if ($cpdata['timeout'] > $deftime) {
241 262
					$input_errors[] = sprintf(gettext(
242 263
						"The Captive Portal zone '%s' has Hard Timeout parameter set to a value bigger than Default lease time (%s)."), $cpZone, $deftime);
264
				}
243 265
			}
244 266
		}
245 267

  
246
		if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime'])))
268
		if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime']))) {
247 269
			$input_errors[] = gettext("The maximum lease time must be at least 60 seconds and higher than the default lease time.");
248
		if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain'])))
270
		}
271
		if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain']))) {
249 272
			$input_errors[] = gettext("A valid domain name must be specified for the dynamic DNS registration.");
250
		if (($_POST['ddnsdomain'] && !is_ipaddrv4($_POST['ddnsdomainprimary'])))
273
		}
274
		if (($_POST['ddnsdomain'] && !is_ipaddrv4($_POST['ddnsdomainprimary']))) {
251 275
			$input_errors[] = gettext("A valid primary domain name server IP address must be specified for the dynamic domain name.");
276
		}
252 277
		if (($_POST['ddnsdomainkey'] && !$_POST['ddnsdomainkeyname']) ||
253
			($_POST['ddnsdomainkeyname'] && !$_POST['ddnsdomainkey']))
278
		    ($_POST['ddnsdomainkeyname'] && !$_POST['ddnsdomainkey'])) {
254 279
			$input_errors[] = gettext("You must specify both a valid domain key and key name.");
280
		}
255 281
		if ($_POST['domainsearchlist']) {
256
			$domain_array=preg_split("/[ ;]+/",$_POST['domainsearchlist']);
282
			$domain_array = preg_split("/[ ;]+/", $_POST['domainsearchlist']);
257 283
			foreach ($domain_array as $curdomain) {
258 284
				if (!is_domain($curdomain)) {
259 285
					$input_errors[] = gettext("A valid domain search list must be specified.");
......
263 289
		}
264 290

  
265 291
		// Validate MACs
266
		if (!empty($_POST['mac_allow']) && !validate_partial_mac_list($_POST['mac_allow']))
292
		if (!empty($_POST['mac_allow']) && !validate_partial_mac_list($_POST['mac_allow'])) {
267 293
			$input_errors[] = gettext("If you specify a mac allow list, it must contain only valid partial MAC addresses.");
268
		if (!empty($_POST['mac_deny']) && !validate_partial_mac_list($_POST['mac_deny']))
294
		}
295
		if (!empty($_POST['mac_deny']) && !validate_partial_mac_list($_POST['mac_deny'])) {
269 296
			$input_errors[] = gettext("If you specify a mac deny list, it must contain only valid partial MAC addresses.");
297
		}
270 298

  
271
		if (($_POST['ntp1'] && !is_ipaddrv4($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddrv4($_POST['ntp2'])))
299
		if (($_POST['ntp1'] && !is_ipaddrv4($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddrv4($_POST['ntp2']))) {
272 300
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary NTP servers.");
273
		if (($_POST['domain'] && !is_domain($_POST['domain'])))
301
		}
302
		if (($_POST['domain'] && !is_domain($_POST['domain']))) {
274 303
			$input_errors[] = gettext("A valid domain name must be specified for the DNS domain.");
275
		if ($_POST['tftp'] && !is_ipaddrv4($_POST['tftp']) && !is_domain($_POST['tftp']) && !is_URL($_POST['tftp']))
304
		}
305
		if ($_POST['tftp'] && !is_ipaddrv4($_POST['tftp']) && !is_domain($_POST['tftp']) && !is_URL($_POST['tftp'])) {
276 306
			$input_errors[] = gettext("A valid IP address or hostname must be specified for the TFTP server.");
277
		if (($_POST['nextserver'] && !is_ipaddrv4($_POST['nextserver'])))
307
		}
308
		if (($_POST['nextserver'] && !is_ipaddrv4($_POST['nextserver']))) {
278 309
			$input_errors[] = gettext("A valid IP address must be specified for the network boot server.");
310
		}
279 311

  
280
		if(gen_subnet($ifcfgip, $ifcfgsn) == $_POST['range_from'])
312
		if (gen_subnet($ifcfgip, $ifcfgsn) == $_POST['range_from']) {
281 313
			$input_errors[] = gettext("You cannot use the network address in the starting subnet range.");
282
		if(gen_subnet_max($ifcfgip, $ifcfgsn) == $_POST['range_to'])
314
		}
315
		if (gen_subnet_max($ifcfgip, $ifcfgsn) == $_POST['range_to']) {
283 316
			$input_errors[] = gettext("You cannot use the broadcast address in the ending subnet range.");
317
		}
284 318

  
285 319
		// Disallow a range that includes the virtualip
286 320
		if (is_array($config['virtualip']['vip'])) {
287
			foreach($config['virtualip']['vip'] as $vip) {
288
				if($vip['interface'] == $if)
289
					if($vip['subnet'] && is_inrange_v4($vip['subnet'], $_POST['range_from'], $_POST['range_to']))
290
						$input_errors[] = sprintf(gettext("The subnet range cannot overlap with virtual IP address %s."),$vip['subnet']);
321
			foreach ($config['virtualip']['vip'] as $vip) {
322
				if ($vip['interface'] == $if) {
323
					if ($vip['subnet'] && is_inrange_v4($vip['subnet'], $_POST['range_from'], $_POST['range_to'])) {
324
						$input_errors[] = sprintf(gettext("The subnet range cannot overlap with virtual IP address %s."), $vip['subnet']);
325
					}
326
				}
291 327
			}
292 328
		}
293 329

  
294 330
		$noip = false;
295
		if(is_array($a_maps))
296
			foreach ($a_maps as $map)
297
				if (empty($map['ipaddr']))
331
		if (is_array($a_maps)) {
332
			foreach ($a_maps as $map) {
333
				if (empty($map['ipaddr'])) {
298 334
					$noip = true;
299
		if ($_POST['staticarp'] && $noip)
335
				}
336
			}
337
		}
338
		if ($_POST['staticarp'] && $noip) {
300 339
			$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.";
340
		}
301 341

  
302
		if(is_array($pconfig['numberoptions']['item'])) {
342
		if (is_array($pconfig['numberoptions']['item'])) {
303 343
			foreach ($pconfig['numberoptions']['item'] as $numberoption) {
304
				if ( $numberoption['type'] == 'text' && strstr($numberoption['value'], '"') )
344
				if ($numberoption['type'] == 'text' && strstr($numberoption['value'], '"')) {
305 345
					$input_errors[] = gettext("Text type cannot include quotation marks.");
306
				else if ( $numberoption['type'] == 'string' && !preg_match('/^"[^"]*"$/', $numberoption['value']) && !preg_match('/^[0-9a-f]{2}(?:\:[0-9a-f]{2})*$/i', $numberoption['value']) )
346
				} else if ($numberoption['type'] == 'string' && !preg_match('/^"[^"]*"$/', $numberoption['value']) && !preg_match('/^[0-9a-f]{2}(?:\:[0-9a-f]{2})*$/i', $numberoption['value'])) {
307 347
					$input_errors[] = gettext("String type must be enclosed in quotes like \"this\" or must be a series of octets specified in hexadecimal, separated by colons, like 01:23:45:67:89:ab:cd:ef");
308
				else if ( $numberoption['type'] == 'boolean' && $numberoption['value'] != 'true' && $numberoption['value'] != 'false' && $numberoption['value'] != 'on' && $numberoption['value'] != 'off' )
348
				} else if ($numberoption['type'] == 'boolean' && $numberoption['value'] != 'true' && $numberoption['value'] != 'false' && $numberoption['value'] != 'on' && $numberoption['value'] != 'off') {
309 349
					$input_errors[] = gettext("Boolean type must be true, false, on, or off.");
310
				else if ( $numberoption['type'] == 'unsigned integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 255) )
350
				} else if ($numberoption['type'] == 'unsigned integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 255)) {
311 351
					$input_errors[] = gettext("Unsigned 8-bit integer type must be a number in the range 0 to 255.");
312
				else if ( $numberoption['type'] == 'unsigned integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 65535) )
352
				} else if ($numberoption['type'] == 'unsigned integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 65535)) {
313 353
					$input_errors[] = gettext("Unsigned 16-bit integer type must be a number in the range 0 to 65535.");
314
				else if ( $numberoption['type'] == 'unsigned integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 4294967295) )
354
				} else if ($numberoption['type'] == 'unsigned integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 4294967295)) {
315 355
					$input_errors[] = gettext("Unsigned 32-bit integer type must be a number in the range 0 to 4294967295.");
316
				else if ( $numberoption['type'] == 'signed integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -128 || $numberoption['value'] > 127) )
356
				} else if ($numberoption['type'] == 'signed integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -128 || $numberoption['value'] > 127)) {
317 357
					$input_errors[] = gettext("Signed 8-bit integer type must be a number in the range -128 to 127.");
318
				else if ( $numberoption['type'] == 'signed integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -32768 || $numberoption['value'] > 32767) )
358
				} else if ($numberoption['type'] == 'signed integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -32768 || $numberoption['value'] > 32767)) {
319 359
					$input_errors[] = gettext("Signed 16-bit integer type must be a number in the range -32768 to 32767.");
320
				else if ( $numberoption['type'] == 'signed integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -2147483648 || $numberoption['value'] > 2147483647) )
360
				} else if ($numberoption['type'] == 'signed integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -2147483648 || $numberoption['value'] > 2147483647)) {
321 361
					$input_errors[] = gettext("Signed 32-bit integer type must be a number in the range -2147483648 to 2147483647.");
322
				else if ( $numberoption['type'] == 'ip-address' && !is_ipaddrv4($numberoption['value']) && !is_hostname($numberoption['value']) )
362
				} else if ($numberoption['type'] == 'ip-address' && !is_ipaddrv4($numberoption['value']) && !is_hostname($numberoption['value'])) {
323 363
					$input_errors[] = gettext("IP address or host type must be an IP address or host name.");
364
				}
324 365
			}
325 366
		}
326 367

  
......
334 375
				$input_errors[] = gettext("The specified range lies outside of the current subnet.");
335 376
			}
336 377

  
337
			if (ip2ulong($_POST['range_from']) > ip2ulong($_POST['range_to']))
378
			if (ip2ulong($_POST['range_from']) > ip2ulong($_POST['range_to'])) {
338 379
				$input_errors[] = gettext("The range is invalid (first element higher than second element).");
380
			}
339 381

  
340 382
			if (is_numeric($pool) || ($act == "newpool")) {
341 383
				$rfrom = $config['dhcpd'][$if]['range']['from'];
342 384
				$rto = $config['dhcpd'][$if]['range']['to'];
343 385

  
344
				if (is_inrange_v4($_POST['range_from'], $rfrom, $rto) || is_inrange_v4($_POST['range_to'], $rfrom, $rto))
386
				if (is_inrange_v4($_POST['range_from'], $rfrom, $rto) || is_inrange_v4($_POST['range_to'], $rfrom, $rto)) {
345 387
					$input_errors[] = gettext("The specified range must not be within the DHCP range for this interface.");
388
				}
346 389
			}
347 390

  
348 391
			foreach ($a_pools as $id => $p) {
349
				if (is_numeric($pool) && ($id == $pool))
392
				if (is_numeric($pool) && ($id == $pool)) {
350 393
					continue;
394
				}
351 395

  
352 396
				if (is_inrange_v4($_POST['range_from'], $p['range']['from'], $p['range']['to']) ||
353 397
				    is_inrange_v4($_POST['range_to'], $p['range']['from'], $p['range']['to'])) {
......
357 401
			}
358 402

  
359 403
			/* make sure that the DHCP Relay isn't enabled on this interface */
360
			if (isset($config['dhcrelay']['enable']) && (stristr($config['dhcrelay']['interface'], $if) !== false))
361
				$input_errors[] = sprintf(gettext("You must disable the DHCP relay on the %s interface before enabling the DHCP server."),$iflist[$if]);
404
			if (isset($config['dhcrelay']['enable']) && (stristr($config['dhcrelay']['interface'], $if) !== false)) {
405
				$input_errors[] = sprintf(gettext("You must disable the DHCP relay on the %s interface before enabling the DHCP server."), $iflist[$if]);
406
			}
362 407

  
363 408
			$dynsubnet_start = ip2ulong($_POST['range_from']);
364 409
			$dynsubnet_end = ip2ulong($_POST['range_to']);
365 410
			if (is_array($a_maps)) {
366 411
				foreach ($a_maps as $map) {
367
					if (empty($map['ipaddr']))
412
					if (empty($map['ipaddr'])) {
368 413
						continue;
414
					}
369 415
					if ((ip2ulong($map['ipaddr']) > $dynsubnet_start) &&
370
						(ip2ulong($map['ipaddr']) < $dynsubnet_end)) {
416
					    (ip2ulong($map['ipaddr']) < $dynsubnet_end)) {
371 417
						$input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings."));
372 418
						break;
373 419
					}
......
381 427
			if ($act == "newpool") {
382 428
				$dhcpdconf = array();
383 429
			} else {
384
				if (!is_array($config['dhcpd'][$if]))
430
				if (!is_array($config['dhcpd'][$if])) {
385 431
					$config['dhcpd'][$if] = array();
432
				}
386 433
				$dhcpdconf = $config['dhcpd'][$if];
387 434
			}
388 435
		} else {
......
394 441
				exit;
395 442
			}
396 443
		}
397
		if (!is_array($dhcpdconf['range']))
444
		if (!is_array($dhcpdconf['range'])) {
398 445
			$dhcpdconf['range'] = array();
446
		}
399 447

  
400 448
		$dhcpd_enable_changed = false;
401 449

  
......
410 458
			$dhcpdconf['enable'] = $new_dhcpd_enable;
411 459
			$dhcpdconf['staticarp'] = ($_POST['staticarp']) ? true : false;
412 460
			$previous = $dhcpdconf['failover_peerip'];
413
			if($previous <> $_POST['failover_peerip'])
461
			if ($previous <> $_POST['failover_peerip']) {
414 462
				mwexec("/bin/rm -rf /var/dhcpd/var/db/*");
463
			}
415 464
			$dhcpdconf['failover_peerip'] = $_POST['failover_peerip'];
416 465
			// dhcpleaseinlocaltime is global to all interfaces. So update the setting on all interfaces.
417 466
			foreach ($config['dhcpd'] as &$dhcpdifitem) {
......
430 479
		$dhcpdconf['netmask'] = $_POST['netmask'];
431 480

  
432 481
		unset($dhcpdconf['winsserver']);
433
		if ($_POST['wins1'])
482
		if ($_POST['wins1']) {
434 483
			$dhcpdconf['winsserver'][] = $_POST['wins1'];
435
		if ($_POST['wins2'])
484
		}
485
		if ($_POST['wins2']) {
436 486
			$dhcpdconf['winsserver'][] = $_POST['wins2'];
487
		}
437 488

  
438 489
		unset($dhcpdconf['dnsserver']);
439
		if ($_POST['dns1'])
490
		if ($_POST['dns1']) {
440 491
			$dhcpdconf['dnsserver'][] = $_POST['dns1'];
441
		if ($_POST['dns2'])
492
		}
493
		if ($_POST['dns2']) {
442 494
			$dhcpdconf['dnsserver'][] = $_POST['dns2'];
443
		if ($_POST['dns3'])
495
		}
496
		if ($_POST['dns3']) {
444 497
			$dhcpdconf['dnsserver'][] = $_POST['dns3'];
445
		if ($_POST['dns4'])
498
		}
499
		if ($_POST['dns4']) {
446 500
			$dhcpdconf['dnsserver'][] = $_POST['dns4'];
501
		}
447 502

  
448 503
		$dhcpdconf['gateway'] = $_POST['gateway'];
449 504
		$dhcpdconf['domain'] = $_POST['domain'];
......
458 513
		$dhcpdconf['mac_deny'] = $_POST['mac_deny'];
459 514

  
460 515
		unset($dhcpdconf['ntpserver']);
461
		if ($_POST['ntp1'])
516
		if ($_POST['ntp1']) {
462 517
			$dhcpdconf['ntpserver'][] = $_POST['ntp1'];
463
		if ($_POST['ntp2'])
518
		}
519
		if ($_POST['ntp2']) {
464 520
			$dhcpdconf['ntpserver'][] = $_POST['ntp2'];
521
		}
465 522

  
466 523
		$dhcpdconf['tftp'] = $_POST['tftp'];
467 524
		$dhcpdconf['ldap'] = $_POST['ldap'];
......
473 530
		$dhcpdconf['rootpath'] = $_POST['rootpath'];
474 531

  
475 532
		// Handle the custom options rowhelper
476
		if(isset($dhcpdconf['numberoptions']['item']))
533
		if (isset($dhcpdconf['numberoptions']['item'])) {
477 534
			unset($dhcpdconf['numberoptions']['item']);
535
		}
478 536

  
479 537
		$dhcpdconf['numberoptions'] = $numberoptions;
480 538

  
......
510 568
			clear_subsystem_dirty('staticmaps');
511 569
	} else {
512 570
		$retvaldhcp = services_dhcpd_configure();
513
		if ($retvaldhcp == 0)
571
		if ($retvaldhcp == 0) {
514 572
			clear_subsystem_dirty('staticmaps');
573
		}
515 574
	}
516
	if ($dhcpd_enable_changed)
575
	if ($dhcpd_enable_changed) {
517 576
		$retvalfc = filter_configure();
577
	}
518 578

  
519
	if($retvaldhcp == 1 || $retvaldns == 1 || $retvalfc == 1)
579
	if ($retvaldhcp == 1 || $retvaldns == 1 || $retvalfc == 1) {
520 580
		$retval = 1;
581
	}
521 582
	$savemsg = get_std_save_message($retval);
522 583
}
523 584

  
......
534 595
	if ($a_maps[$_GET['id']]) {
535 596
		unset($a_maps[$_GET['id']]);
536 597
		write_config();
537
		if(isset($config['dhcpd'][$if]['enable'])) {
598
		if (isset($config['dhcpd'][$if]['enable'])) {
538 599
			mark_subsystem_dirty('staticmaps');
539
			if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic']))
600
			if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic'])) {
540 601
				mark_subsystem_dirty('hosts');
602
			}
541 603
		}
542 604
		header("Location: services_dhcp.php?if={$if}");
543 605
		exit;
......
545 607
}
546 608

  
547 609
$closehead = false;
548
$pgtitle = array(gettext("Services"),gettext("DHCP server"));
610
$pgtitle = array(gettext("Services"), gettext("DHCP server"));
549 611
$shortcut_section = "dhcp";
550 612

  
551 613
include("head.inc");
......
689 751
<?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 />
690 752
<?php endif; ?>
691 753
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp server">
692
<tr><td>
754
	<tr>
755
		<td>
693 756
<?php
694 757
	/* active tabs */
695 758
	$tab_array = array();
......
698 761
	foreach ($iflist as $ifent => $ifname) {
699 762
		$oc = $config['interfaces'][$ifent];
700 763
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) ||
701
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr']))))
764
		    (!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr'])))) {
702 765
			continue;
703
		if ($ifent == $if)
766
		}
767
		if ($ifent == $if) {
704 768
			$active = true;
705
		else
769
		} else {
706 770
			$active = false;
771
		}
707 772
		$tab_array[] = array($ifname, $active, "services_dhcp.php?if={$ifent}");
708 773
		$tabscounter++;
709 774
	}
......
717 782
	}
718 783
	display_top_tabs($tab_array);
719 784
?>
720
</td></tr>
721
<tr>
722
<td>
723
	<div id="mainarea">
724
		<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
785
		</td>
786
	</tr>
787
	<tr>
788
		<td>
789
			<div id="mainarea">
790
			<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
725 791
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
726
			<tr>
727
			<td width="22%" valign="top" class="vtable">&nbsp;</td>
728
			<td width="78%" class="vtable">
729
				<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onclick="enable_change(false)" />
730
			<strong><?php printf(gettext("Enable DHCP server on " .
731
			"%s " .
732
			"interface"),htmlspecialchars($iflist[$if]));?></strong></td>
733
			</tr>
792
				<tr>
793
					<td width="22%" valign="top" class="vtable">&nbsp;</td>
794
					<td width="78%" class="vtable">
795
						<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onclick="enable_change(false)" />
796
						<strong><?php printf(gettext("Enable DHCP server on %s interface"), htmlspecialchars($iflist[$if]));?></strong>
797
					</td>
798
				</tr>
734 799
			<?php else: ?>
735
			<tr>
736
				<td colspan="2" class="listtopic"><?php echo gettext("Editing Pool-Specific Options. To return to the Interface, click its tab above."); ?></td>
737
			</tr>
738
			<?php endif; ?>
739
			<tr>
740
			<td width="22%" valign="top" class="vtable">&nbsp;</td>
741
			<td width="78%" class="vtable">
742
				<input name="denyunknown" id="denyunknown" type="checkbox" value="yes" <?php if ($pconfig['denyunknown']) echo "checked=\"checked\""; ?> />
743
				<strong><?=gettext("Deny unknown clients");?></strong><br />
744
				<?=gettext("If this is checked, only the clients defined below will get DHCP leases from this server. ");?></td>
745
			</tr>
746
			<?php if (is_numeric($pool) || ($act == "newpool")): ?>
747 800
				<tr>
748
				<td width="22%" valign="top" class="vncell"><?=gettext("Pool Description");?></td>
749
				<td width="78%" class="vtable">
750
					<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>" />
751
				</td>
801
					<td colspan="2" class="listtopic"><?php echo gettext("Editing Pool-Specific Options. To return to the Interface, click its tab above."); ?></td>
752 802
				</tr>
753 803
			<?php endif; ?>
754
			<tr>
755
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet");?></td>
756
			<td width="78%" class="vtable">
757
				<?=gen_subnet($ifcfgip, $ifcfgsn);?>
758
			</td>
759
			</tr>
760
			<tr>
761
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet mask");?></td>
762
			<td width="78%" class="vtable">
763
				<?=gen_subnet_mask($ifcfgsn);?>
764
			</td>
765
			</tr>
766
			<tr>
767
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Available range");?></td>
768
			<td width="78%" class="vtable">
769
			<?php
770
				$range_from = ip2long(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
771
				$range_from++;
772
				echo long2ip32($range_from);
773
			?>
774
			-
775
			<?php
776
				$range_to = ip2long(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
777
				$range_to--;
778
				echo long2ip32($range_to);
779
			?>
804
				<tr>
805
					<td width="22%" valign="top" class="vtable">&nbsp;</td>
806
					<td width="78%" class="vtable">
807
						<input name="denyunknown" id="denyunknown" type="checkbox" value="yes" <?php if ($pconfig['denyunknown']) echo "checked=\"checked\""; ?> />
808
						<strong><?=gettext("Deny unknown clients");?></strong><br />
809
						<?=gettext("If this is checked, only the clients defined below will get DHCP leases from this server. ");?>
810
					</td>
811
				</tr>
780 812
			<?php if (is_numeric($pool) || ($act == "newpool")): ?>
781
				<br />In-use DHCP Pool Ranges:
782
				<?php if (is_array($config['dhcpd'][$if]['range'])): ?>
783
					<br /><?php echo $config['dhcpd'][$if]['range']['from']; ?>-<?php echo $config['dhcpd'][$if]['range']['to']; ?>
784
				<?php endif; ?>
785
				<?php foreach ($a_pools as $p): ?>
786
					<?php if (is_array($p['range'])): ?>
787
					<br /><?php echo $p['range']['from']; ?>-<?php echo $p['range']['to']; ?>
788
					<?php endif; ?>
789
				<?php endforeach; ?>
790
			<?php endif; ?>
791
			</td>
792
			</tr>
793
			<?php if($is_olsr_enabled): ?>
794
			<tr>
795
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet Mask");?></td>
796
			<td width="78%" class="vtable">
797
				<select name="netmask" class="formselect" id="netmask">
798
				<?php
799
				for ($i = 32; $i > 0; $i--) {
800
					if($i <> 31) {
801
						echo "<option value=\"{$i}\" ";
802
						if ($i == $pconfig['netmask']) echo "selected=\"selected\"";
803
						echo ">" . $i . "</option>";
804
					}
805
				}
806
				?>
807
				</select>
808
			</td>
809
			</tr>
813
				<tr>
814
					<td width="22%" valign="top" class="vncell"><?=gettext("Pool Description");?></td>
815
					<td width="78%" class="vtable">
816
						<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>" />
817
					</td>
818
				</tr>
810 819
			<?php endif; ?>
811
			<tr>
812
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Range");?></td>
813
			<td width="78%" class="vtable">
814
				<input name="range_from" type="text" class="formfld unknown" id="range_from" size="20" value="<?=htmlspecialchars($pconfig['range_from']);?>" />
815
				&nbsp;<?=gettext("to"); ?>&nbsp; <input name="range_to" type="text" class="formfld unknown" id="range_to" size="20" value="<?=htmlspecialchars($pconfig['range_to']);?>" />
816
			</td>
817
			</tr>
818
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
819
			<tr>
820
			<td width="22%" valign="top" class="vncell"><?=gettext("Additional Pools");?></td>
821
			<td width="78%" class="vtable">
822
				<?php echo gettext("If you need additional pools of addresses inside of this subnet outside the above Range, they may be specified here."); ?>
823
				<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="subnet">
824 820
				<tr>
825
					<td width="35%" class="listhdrr"><?=gettext("Pool Start");?></td>
826
					<td width="35%" class="listhdrr"><?=gettext("Pool End");?></td>
827
					<td width="20%" class="listhdrr"><?=gettext("Description");?></td>
828
					<td width="10%" class="list">
829
					<table border="0" cellspacing="0" cellpadding="1" summary="pool">
830
					<tr>
831
					<td valign="middle" width="17"></td>
832
					<td valign="middle"><a href="services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;act=newpool"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="plus" /></a></td>
833
					</tr>
834
					</table>
821
					<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet");?></td>
822
					<td width="78%" class="vtable">
823
						<?=gen_subnet($ifcfgip, $ifcfgsn);?>
835 824
					</td>
836 825
				</tr>
837
					<?php if(is_array($a_pools)): ?>
838
					<?php $i = 0; foreach ($a_pools as $poolent): ?>
839
					<?php if(!empty($poolent['range']['from']) && !empty($poolent['range']['to'])): ?>
840 826
				<tr>
841
				<td class="listlr" ondblclick="document.location='services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;pool=<?=$i;?>';">
842
					<?=htmlspecialchars($poolent['range']['from']);?>
843
				</td>
844
				<td class="listr" ondblclick="document.location='services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;pool=<?=$i;?>';">
845
					<?=htmlspecialchars($poolent['range']['to']);?>&nbsp;
846
				</td>
847
				<td class="listr" ondblclick="document.location='services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;pool=<?=$i;?>';">
848
					<?=htmlspecialchars($poolent['descr']);?>&nbsp;
849
				</td>
850
				<td valign="middle" class="list nowrap">
851
					<table border="0" cellspacing="0" cellpadding="1" summary="icons">
852
					<tr>
853
					<td valign="middle"><a href="services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;pool=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="edit" /></a></td>
854
					<td valign="middle"><a href="services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;act=delpool&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this pool?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="delete" /></a></td>
855
					</tr>
856
					</table>
857
				</td>
827
					<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet mask");?></td>
828
					<td width="78%" class="vtable">
829
						<?=gen_subnet_mask($ifcfgsn);?>
830
					</td>
858 831
				</tr>
859
				<?php endif; ?>
860
				<?php $i++; endforeach; ?>
861
				<?php endif; ?>
862 832
				<tr>
863
				<td class="list" colspan="3"></td>
864
				<td class="list">
865
					<table border="0" cellspacing="0" cellpadding="1" summary="add">
866
					<tr>
867
					<td valign="middle" width="17"></td>
868
					<td valign="middle"><a href="services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;act=newpool"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="add" /></a></td>
869
					</tr>
870
					</table>
871
				</td>
833
					<td width="22%" valign="top" class="vncellreq"><?=gettext("Available range");?></td>
834
					<td width="78%" class="vtable">
835
						<?php
836
							$range_from = ip2long(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
837
							$range_from++;
838
							echo long2ip32($range_from);
839
						?>
840
						-
841
						<?php
842
							$range_to = ip2long(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
843
							$range_to--;
844
							echo long2ip32($range_to);
845
							if (is_numeric($pool) || ($act == "newpool")):
846
						?>
847
						<br />In-use DHCP Pool Ranges:
848
						<?php
849
								if (is_array($config['dhcpd'][$if]['range'])):
850
						?>
851
						<br />
852
						<?php
853
									echo $config['dhcpd'][$if]['range']['from'];
854
						?>
855
						-
856
						<?php
857
									echo $config['dhcpd'][$if]['range']['to'];
858
								endif;
859
						?>
860
						<?php
861
								foreach ($a_pools as $p):
862
									if (is_array($p['range'])):
863
						?>
864
						<br />
865
						<?php 
866
										echo $p['range']['from'];
867
						?>
868
						-
869
						<?php
870
										echo $p['range']['to'];
871
									endif;
872
								endforeach;
873
							endif;
874
						?>
875
					</td>
872 876
				</tr>
873
				</table>
874
			</td>
875
			</tr>
876
			<?php endif; ?>
877
			<tr>
878
			<td width="22%" valign="top" class="vncell"><?=gettext("WINS servers");?></td>
879
			<td width="78%" class="vtable">
880
				<input name="wins1" type="text" class="formfld unknown" id="wins1" size="20" value="<?=htmlspecialchars($pconfig['wins1']);?>" /><br />
881
				<input name="wins2" type="text" class="formfld unknown" id="wins2" size="20" value="<?=htmlspecialchars($pconfig['wins2']);?>" />
882
			</td>
883
			</tr>
884
			<tr>
885
			<td width="22%" valign="top" class="vncell"><?=gettext("DNS servers");?></td>
886
			<td width="78%" class="vtable">
887
				<input name="dns1" type="text" class="formfld unknown" id="dns1" size="20" value="<?=htmlspecialchars($pconfig['dns1']);?>" /><br />
888
				<input name="dns2" type="text" class="formfld unknown" id="dns2" size="20" value="<?=htmlspecialchars($pconfig['dns2']);?>" /><br />
889
				<input name="dns3" type="text" class="formfld unknown" id="dns3" size="20" value="<?=htmlspecialchars($pconfig['dns3']);?>" /><br />
890
				<input name="dns4" type="text" class="formfld unknown" id="dns4" size="20" value="<?=htmlspecialchars($pconfig['dns4']);?>" /><br />
891
				<?=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.");?>
892
			</td>
893
			</tr>
894
			<tr>
895
			<td width="22%" valign="top" class="vncell"><?=gettext("Gateway");?></td>
896
			<td width="78%" class="vtable">
897
				<input name="gateway" type="text" class="formfld host" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>" /><br />
898
				<?=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. Type \"none\" for no gateway assignment.");?>
899
			</td>
900
			</tr>
901
			<tr>
902
			<td width="22%" valign="top" class="vncell"><?=gettext("Domain name");?></td>
903
			<td width="78%" class="vtable">
904
				<input name="domain" type="text" class="formfld unknown" id="domain" size="20" value="<?=htmlspecialchars($pconfig['domain']);?>" /><br />
905
				<?=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.");?>
906
			</td>
907
			</tr>
908
			<tr>
909
			<td width="22%" valign="top" class="vncell"><?=gettext("Domain search list");?></td>
910
			<td width="78%" class="vtable">
911
				<input name="domainsearchlist" type="text" class="formfld unknown" id="domainsearchlist" size="20" value="<?=htmlspecialchars($pconfig['domainsearchlist']);?>" /><br />
912
				<?=gettext("The DHCP server can optionally provide a domain search list. Use the semicolon character as separator ");?>
913
			</td>
914
			</tr>
915
			<tr>
916
			<td width="22%" valign="top" class="vncell"><?=gettext("Default lease time");?></td>
917
			<td width="78%" class="vtable">
918
				<input name="deftime" type="text" class="formfld unknown" id="deftime" size="10" value="<?=htmlspecialchars($pconfig['deftime']);?>" />
919
				<?=gettext("seconds");?><br />
920
				<?=gettext("This is used for clients that do not ask for a specific " .
921
				"expiration time."); ?><br />
922
				<?=gettext("The default is 7200 seconds.");?>
923
			</td>
924
			</tr>
925
			<tr>
926
			<td width="22%" valign="top" class="vncell"><?=gettext("Maximum lease time");?></td>
927
			<td width="78%" class="vtable">
928
				<input name="maxtime" type="text" class="formfld unknown" id="maxtime" size="10" value="<?=htmlspecialchars($pconfig['maxtime']);?>" />
929
				<?=gettext("seconds");?><br />
930
				<?=gettext("This is the maximum lease time for clients that ask".
931
				" for a specific expiration time."); ?><br />
932
				<?=gettext("The default is 86400 seconds.");?>
933
			</td>
934
			</tr>
935
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
936
			<tr>
937
			<td width="22%" valign="top" class="vncell"><?=gettext("Failover peer IP:");?></td>
938
			<td width="78%" class="vtable">
939
				<input name="failover_peerip" type="text" class="formfld host" id="failover_peerip" size="20" value="<?=htmlspecialchars($pconfig['failover_peerip']);?>" /><br />
940
				<?=gettext("Leave blank to disable.  Enter the interface IP address of the other machine.  Machines must be using CARP. Interface's advskew determines whether the DHCPd process is Primary or Secondary. Ensure one machine's advskew<20 (and the other is >20).");?>
941
			</td>
942
			</tr>
943
			<?php endif; ?>
944
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
945
			<tr>
946
			<td width="22%" valign="top" class="vncell"><?=gettext("Static ARP");?></td>
947
			<td width="78%" class="vtable">
948
				<table summary="static arp">
949
					<tr>
950
					<td>
951
						<input style="vertical-align:middle" type="checkbox" value="yes" name="staticarp" id="staticarp" <?php if($pconfig['staticarp']) echo " checked=\"checked\""; ?> />&nbsp;
877
<?php if ($is_olsr_enabled): ?>
878
				<tr>
879
					<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet Mask");?></td>
880
					<td width="78%" class="vtable">
881
						<select name="netmask" class="formselect" id="netmask">
882
							<?php
883
							for ($i = 32; $i > 0; $i--) {
884
								if ($i <> 31) {
885
									echo "<option value=\"{$i}\" ";
886
									if ($i == $pconfig['netmask']) {
887
										echo "selected=\"selected\"";
888
									}
889
									echo ">" . $i . "</option>";
890
								}
891
							}
892
							?>
893
						</select>
952 894
					</td>
953
					<td><b><?=gettext("Enable Static ARP entries");?></b></td>
954
					</tr>
955
					<tr>
956
					<td>&nbsp;</td>
957
					<td>
958
						<span class="red"><strong><?=gettext("Note:");?></strong></span> <?=gettext("This option persists even if DHCP server is disabled. Only the machines listed below will be able to communicate with the firewall on this NIC.");?>
895
				</tr>
896
<?php endif; ?>
897
				<tr>
898
					<td width="22%" valign="top" class="vncellreq"><?=gettext("Range");?></td>
899
					<td width="78%" class="vtable">
900
						<input name="range_from" type="text" class="formfld unknown" id="range_from" size="20" value="<?=htmlspecialchars($pconfig['range_from']);?>" />
901
						&nbsp;<?=gettext("to"); ?>&nbsp; <input name="range_to" type="text" class="formfld unknown" id="range_to" size="20" value="<?=htmlspecialchars($pconfig['range_to']);?>" />
959 902
					</td>
960
					</tr>
961
				</table>
962
			</td>
963
			</tr>
964
			<?php endif; ?>
965
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
966
			<tr>
967
				<td width="22%" valign="top" class="vncell"><?=gettext("Time format change"); ?></td>
968
				<td width="78%" class="vtable">
969
				<table summary="time format">
970
					<tr>
971
					<td>
972
						<input name="dhcpleaseinlocaltime" type="checkbox" id="dhcpleaseinlocaltime" value="yes" <?php if ($pconfig['dhcpleaseinlocaltime']) echo "checked=\"checked\""; ?> />
903
				</tr>
904
<?php
905
	if (!is_numeric($pool) && !($act == "newpool")):
906
?>
907
				<tr>
908
					<td width="22%" valign="top" class="vncell">
909
						<?=gettext("Additional Pools");?>
973 910
					</td>
974
					<td>
975
						<strong>
976
							<?=gettext("Change DHCP display lease time from UTC to local time."); ?>
977
						</strong>
911
					<td width="78%" class="vtable">
912
						<?php echo gettext("If you need additional pools of addresses inside of this subnet outside the above Range, they may be specified here."); ?>
913
						<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="subnet">
914
							<tr>
915
								<td width="35%" class="listhdrr"><?=gettext("Pool Start");?></td>
916
								<td width="35%" class="listhdrr"><?=gettext("Pool End");?></td>
917
								<td width="20%" class="listhdrr"><?=gettext("Description");?></td>
918
								<td width="10%" class="list">
919
									<table border="0" cellspacing="0" cellpadding="1" summary="pool">
920
										<tr>
921
											<td valign="middle" width="17"></td>
922
											<td valign="middle">
923
												<a href="services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;act=newpool"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="plus" /></a>
924
											</td>
925
										</tr>
926
									</table>
927
								</td>
928
							</tr>
929
<?php
930
		if (is_array($a_pools)):
931
			$i = 0;
932
			foreach ($a_pools as $poolent):
933
				if (!empty($poolent['range']['from']) && !empty($poolent['range']['to'])):
934
?>
935
							<tr>
936
								<td class="listlr" ondblclick="document.location='services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;pool=<?=$i;?>';">
937
									<?=htmlspecialchars($poolent['range']['from']);?>
938
								</td>
939
								<td class="listr" ondblclick="document.location='services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;pool=<?=$i;?>';">
940
									<?=htmlspecialchars($poolent['range']['to']);?>&nbsp;
941
								</td>
942
								<td class="listr" ondblclick="document.location='services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;pool=<?=$i;?>';">
943
									<?=htmlspecialchars($poolent['descr']);?>&nbsp;
944
								</td>
945
								<td valign="middle" class="list nowrap">
946
									<table border="0" cellspacing="0" cellpadding="1" summary="icons">
947
										<tr>
948
											<td valign="middle">
949
												<a href="services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;pool=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="edit" /></a>
950
											</td>
951
											<td valign="middle">
952
												<a href="services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;act=delpool&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this pool?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="delete" /></a>
953
											</td>
954
										</tr>
955
									</table>
956
								</td>
957
							</tr>
958
<?php
959
				endif;
960
				$i++;
961
			endforeach;
962
		endif;
963
?>
964
							<tr>
965
								<td class="list" colspan="3"></td>
966
								<td class="list">
967
									<table border="0" cellspacing="0" cellpadding="1" summary="add">
968
										<tr>
969
											<td valign="middle" width="17"></td>
970
											<td valign="middle">
971
												<a href="services_dhcp.php?if=<?=htmlspecialchars($if);?>&amp;act=newpool"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="add" /></a>
972
											</td>
973
										</tr>
974
									</table>
975
								</td>
976
							</tr>
977
						</table>
978 978
					</td>
979
					</tr>
980
					<tr>
981
					<td>&nbsp;</td>
982
					<td>
983
						<span class="red"><strong><?=gettext("Note:");?></strong></span> <?=gettext("By default DHCP leases are displayed in UTC time.  By checking this
984
						box DHCP lease time will be displayed in local time and set to time zone selected.  This will be used for all DHCP interfaces lease time."); ?>
979
				</tr>
980
<?php
981
	endif;
982
?>
983
				<tr>
984
					<td width="22%" valign="top" class="vncell"><?=gettext("WINS servers");?></td>
985
					<td width="78%" class="vtable">
986
						<input name="wins1" type="text" class="formfld unknown" id="wins1" size="20" value="<?=htmlspecialchars($pconfig['wins1']);?>" /><br />
987
						<input name="wins2" type="text" class="formfld unknown" id="wins2" size="20" value="<?=htmlspecialchars($pconfig['wins2']);?>" />
985 988
					</td>
986
					</tr>
987
				</table>
988
				</td>
989
			</tr>
990
			<?php endif; ?>
991
			<tr>
992
			<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic DNS");?></td>
993
			<td width="78%" class="vtable">
994
				<div id="showddnsbox">
995
					<input type="button" onclick="show_ddns_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show Dynamic DNS");?>
996
				</div>
997
				<div id="showddns" style="display:none">
998
					<input style="vertical-align:middle" type="checkbox" value="yes" name="ddnsupdate" id="ddnsupdate" <?php if($pconfig['ddnsupdate']) echo " checked=\"checked\""; ?> />&nbsp;
999
					<b><?=gettext("Enable registration of DHCP client names in DNS.");?></b><br />
1000
					<br/>
1001
					<input name="ddnsdomain" type="text" class="formfld unknown" id="ddnsdomain" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomain']);?>" /><br />
1002
					<?=gettext("Note: Leave blank to disable dynamic DNS registration.");?><br />
1003
					<?=gettext("Enter the dynamic DNS domain which will be used to register client names in the DNS server.");?><br />
1004
					<input name="ddnsdomainprimary" type="text" class="formfld unknown" id="ddnsdomainprimary" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomainprimary']);?>" /><br />
1005
					<?=gettext("Enter the primary domain name server IP address for the dynamic domain name.");?><br />
1006
					<input name="ddnsdomainkeyname" type="text" class="formfld unknown" id="ddnsdomainkeyname" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomainkeyname']);?>" /><br />
1007
					<?=gettext("Enter the dynamic DNS domain key name which will be used to register client names in the DNS server.");?><br />
1008
					<input name="ddnsdomainkey" type="text" class="formfld unknown" id="ddnsdomainkey" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomainkey']);?>" /><br />
1009
					<?=gettext("Enter the dynamic DNS domain key secret which will be used to register client names in the DNS server.");?>
1010
				</div>
1011
			</td>
1012
			</tr>
1013
			<tr>
1014
			<td width="22%" valign="top" class="vncell"><?=gettext("MAC Address Control");?></td>
1015
			<td width="78%" class="vtable">
1016
				<div id="showmaccontrolbox">
1017
					<input type="button" onclick="show_maccontrol_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show MAC Address Control");?>
1018
				</div>
1019
				<div id="showmaccontrol" style="display:none">
1020
					<input name="mac_allow" type="text" class="formfld unknown" id="mac_allow" size="20" value="<?=htmlspecialchars($pconfig['mac_allow']);?>" /><br />
1021
					<?=gettext("Enter a list of partial MAC addresses to allow, comma separated, no spaces, such as ");?>00:00:00,01:E5:FF<br />
1022
					<input name="mac_deny" type="text" class="formfld unknown" id="mac_deny" size="20" value="<?=htmlspecialchars($pconfig['mac_deny']);?>" /><br />
1023
					<?=gettext("Enter a list of partial MAC addresses to deny access, comma separated, no spaces, such as ");?>00:00:00,01:E5:FF
1024
				</div>
1025
			</td>
1026
			</tr>
1027
			<tr>
1028
			<td width="22%" valign="top" class="vncell"><?=gettext("NTP servers");?></td>
1029
			<td width="78%" class="vtable">
1030
				<div id="showntpbox">
1031
					<input type="button" onclick="show_ntp_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show NTP configuration");?>
1032
				</div>
1033
				<div id="showntp" style="display:none">
1034
					<input name="ntp1" type="text" class="formfld unknown" id="ntp1" size="20" value="<?=htmlspecialchars($pconfig['ntp1']);?>" /><br />
1035
					<input name="ntp2" type="text" class="formfld unknown" id="ntp2" size="20" value="<?=htmlspecialchars($pconfig['ntp2']);?>" />
1036
				</div>
1037
			</td>
1038
			</tr>
1039
			<tr>
1040
			<td width="22%" valign="top" class="vncell"><?=gettext("TFTP server");?></td>
1041
			<td width="78%" class="vtable">
1042
			<div id="showtftpbox">
1043
				<input type="button" onclick="show_tftp_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show TFTP configuration");?>
1044
			</div>
1045
			<div id="showtftp" style="display:none">
1046
				<input name="tftp" type="text" class="formfld unknown" id="tftp" size="50" value="<?=htmlspecialchars($pconfig['tftp']);?>" /><br />
1047
				<?=gettext("Leave blank to disable.  Enter a full hostname or IP for the TFTP server.");?>
1048
			</div>
1049
			</td>
1050
			</tr>
1051
			<tr>
1052
			<td width="22%" valign="top" class="vncell"><?=gettext("LDAP URI");?></td>
1053
			<td width="78%" class="vtable">
1054
				<div id="showldapbox">
1055
					<input type="button" onclick="show_ldap_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show LDAP configuration");?>
1056
				</div>
1057
				<div id="showldap" style="display:none">
1058
					<input name="ldap" type="text" class="formfld unknown" id="ldap" size="80" value="<?=htmlspecialchars($pconfig['ldap']);?>" /><br />
1059
					<?=gettext("Leave blank to disable.  Enter a full URI for the LDAP server in the form ldap://ldap.example.com/dc=example,dc=com");?>
1060
				</div>
1061
			</td>
1062
			</tr>
1063
			<tr>
1064
			<td width="22%" valign="top" class="vncell"><?=gettext("Enable network booting");?></td>
1065
			<td width="78%" class="vtable">
1066
				<div id="shownetbootbox">
1067
					<input type="button" onclick="show_netboot_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show Network booting");?>
1068
				</div>
1069
				<div id="shownetboot" style="display:none">
1070
					<input style="vertical-align:middle" type="checkbox" value="yes" name="netboot" id="netboot" <?php if($pconfig['netboot']) echo " checked=\"checked\""; ?> />&nbsp;
1071
					<b><?=gettext("Enables network booting.");?></b>
1072
					<br/>
1073
					<table border="0" cellspacing="0" cellpadding="2" summary="network booting">
1074
						<tr>
1075
							<td>
1076
								<?=gettext("Enter the IP of the"); ?> <b><?=gettext("next-server"); ?></b>
1077
							</td>
1078
							<td>
1079
								<input name="nextserver" type="text" class="formfld unknown" id="nextserver" size="20" value="<?=htmlspecialchars($pconfig['nextserver']);?>" /><br />
1080
							</td>
1081
						</tr>
1082
						<tr>
1083
							<td>
1084
								<?=gettext("and the default bios filename");?>
1085
							</td>
1086
							<td>
1087
								<input name="filename" type="text" class="formfld unknown" id="filename" size="20" value="<?=htmlspecialchars($pconfig['filename']);?>" /><br />
1088
							</td>
1089
						</tr>
1090
						<tr>
1091
							<td>
1092
								<?=gettext("and the UEFI 32bit filename  ");?>
1093
							</td>
1094
							<td>
1095
								<input name="filename32" type="text" class="formfld unknown" id="filename32" size="20" value="<?=htmlspecialchars($pconfig['filename32']);?>" /><br />
1096
							</td>
1097
						</tr>
1098
						<tr>
1099
							<td>
1100
								<?=gettext("and the UEFI 64bit filename  ");?>
1101
							</td>
1102
							<td>
1103
								<input name="filename64" type="text" class="formfld unknown" id="filename64" size="20" value="<?=htmlspecialchars($pconfig['filename64']);?>" /><br />
1104
							</td>
1105
						</tr>
1106
					</table>
1107
					<?=gettext("Note: You need both a filename and a boot server configured for this to work!");?>
1108
					<?=gettext("You will need all three filenames and a boot server configured for UEFI to work!");?>
1109
					<?=gettext("Enter the"); ?> <b><?=gettext("root-path"); ?></b>-<?=gettext("string");?>
1110
					<input name="rootpath" type="text" class="formfld unknown" id="rootpath" size="90" value="<?=htmlspecialchars($pconfig['rootpath']);?>" /><br />
1111
					<?=gettext("Note: string-format: iscsi:(servername):(protocol):(port):(LUN):targetname");?>
1112
				</div>
1113
			</td>
1114
			</tr>
1115
			<?php if (!is_numeric($pool) && !($act == "newpool")): ?>
1116
			<tr>
1117
			<td width="22%" valign="top" class="vncell"><?=gettext("Additional BOOTP/DHCP Options");?></td>
1118
			<td width="78%" class="vtable">
1119
				<div id="shownumbervaluebox">
1120
					<input type="button" onclick="show_shownumbervalue()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show Additional BOOTP/DHCP Options");?>
1121
				</div>
1122
				<div id="shownumbervalue" style="display:none">
1123
				<table id="maintable" summary="bootp-dhcp options">
1124
				<tbody>
989
				</tr>
990
				<tr>
991
					<td width="22%" valign="top" class="vncell"><?=gettext("DNS servers");?></td>
992
					<td width="78%" class="vtable">
993
						<input name="dns1" type="text" class="formfld unknown" id="dns1" size="20" value="<?=htmlspecialchars($pconfig['dns1']);?>" /><br />
994
						<input name="dns2" type="text" class="formfld unknown" id="dns2" size="20" value="<?=htmlspecialchars($pconfig['dns2']);?>" /><br />
995
						<input name="dns3" type="text" class="formfld unknown" id="dns3" size="20" value="<?=htmlspecialchars($pconfig['dns3']);?>" /><br />
996
						<input name="dns4" type="text" class="formfld unknown" id="dns4" size="20" value="<?=htmlspecialchars($pconfig['dns4']);?>" /><br />
997
						<?=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.");?>
998
					</td>
999
				</tr>
1000
				<tr>
1001
					<td width="22%" valign="top" class="vncell"><?=gettext("Gateway");?></td>
1002
					<td width="78%" class="vtable">
1003
						<input name="gateway" type="text" class="formfld host" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>" /><br />
1004
						<?=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. Type \"none\" for no gateway assignment.");?>
1005
					</td>
1006
				</tr>
1007
				<tr>
1008
					<td width="22%" valign="top" class="vncell"><?=gettext("Domain name");?></td>
1009
					<td width="78%" class="vtable">
1010
						<input name="domain" type="text" class="formfld unknown" id="domain" size="20" value="<?=htmlspecialchars($pconfig['domain']);?>" /><br />
1011
						<?=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.");?>
1012
					</td>
1013
				</tr>
1014
				<tr>
1015
					<td width="22%" valign="top" class="vncell"><?=gettext("Domain search list");?></td>
1016
					<td width="78%" class="vtable">
1017
						<input name="domainsearchlist" type="text" class="formfld unknown" id="domainsearchlist" size="20" value="<?=htmlspecialchars($pconfig['domainsearchlist']);?>" /><br />
1018
						<?=gettext("The DHCP server can optionally provide a domain search list. Use the semicolon character as separator ");?>
1019
					</td>
1020
				</tr>
1021
				<tr>
1022
					<td width="22%" valign="top" class="vncell"><?=gettext("Default lease time");?></td>
1023
					<td width="78%" class="vtable">
1024
						<input name="deftime" type="text" class="formfld unknown" id="deftime" size="10" value="<?=htmlspecialchars($pconfig['deftime']);?>" />
1025
						<?=gettext("seconds");?><br />
1026
						<?=gettext("This is used for clients that do not ask for a specific expiration time."); ?><br />
1027
						<?=gettext("The default is 7200 seconds.");?>
1028
					</td>
1029
				</tr>
1030
				<tr>
1031
					<td width="22%" valign="top" class="vncell"><?=gettext("Maximum lease time");?></td>
1032
					<td width="78%" class="vtable">
1033
						<input name="maxtime" type="text" class="formfld unknown" id="maxtime" size="10" value="<?=htmlspecialchars($pconfig['maxtime']);?>" />
1034
						<?=gettext("seconds");?><br />
1035
						<?=gettext("This is the maximum lease time for clients that ask for a specific expiration time."); ?><br />
1036
						<?=gettext("The default is 86400 seconds.");?>
1037
					</td>
1038
				</tr>
1039
<?php
1040
	if (!is_numeric($pool) && !($act == "newpool")):
1041
?>
1042
				<tr>
1043
					<td width="22%" valign="top" class="vncell"><?=gettext("Failover peer IP:");?></td>
1044
					<td width="78%" class="vtable">
1045
						<input name="failover_peerip" type="text" class="formfld host" id="failover_peerip" size="20" value="<?=htmlspecialchars($pconfig['failover_peerip']);?>" /><br />
1046
						<?=gettext("Leave blank to disable.  Enter the interface IP address of the other machine.  Machines must be using CARP. Interface's advskew determines whether the DHCPd process is Primary or Secondary. Ensure one machine's advskew<20 (and the other is >20).");?>
1047
					</td>
1048
				</tr>
1049
<?php
1050
	endif;
1051

  
1052
	if (!is_numeric($pool) && !($act == "newpool")):
1053
?>
1054
				<tr>
1055
					<td width="22%" valign="top" class="vncell"><?=gettext("Static ARP");?></td>
1056
					<td width="78%" class="vtable">
1057
						<table summary="static arp">
1058
							<tr>
1059
								<td>
1060
									<input style="vertical-align:middle" type="checkbox" value="yes" name="staticarp" id="staticarp" <?php if ($pconfig['staticarp']) echo " checked=\"checked\""; ?> />&nbsp;
1061
								</td>
1062
								<td><b><?=gettext("Enable Static ARP entries");?></b></td>
1063
							</tr>
1064
							<tr>
1065
								<td>&nbsp;</td>
1066
								<td>
1067
									<span class="red">
1068
										<strong><?=gettext("Note:");?></strong>
1069
									</span>
1070
									<?=gettext("This option persists even if DHCP server is disabled. Only the machines listed below will be able to communicate with the firewall on this NIC.");?>
1071
								</td>
1072
							</tr>
1073
						</table>
1074
					</td>
1075
				</tr>
1076
<?php
1077
	endif;
1078

  
1079
	if (!is_numeric($pool) && !($act == "newpool")): ?>
1080
				<tr>
1081
					<td width="22%" valign="top" class="vncell"><?=gettext("Time format change"); ?></td>
1082
					<td width="78%" class="vtable">
1083
						<table summary="time format">
1084
							<tr>
1085
								<td>
1086
									<input name="dhcpleaseinlocaltime" type="checkbox" id="dhcpleaseinlocaltime" value="yes" <?php if ($pconfig['dhcpleaseinlocaltime']) echo "checked=\"checked\""; ?> />
1087
								</td>
1088
								<td>
1089
									<strong>
1090
										<?=gettext("Change DHCP display lease time from UTC to local time."); ?>
1091
									</strong>
1092
								</td>
1093
							</tr>
1094
							<tr>
1095
								<td>&nbsp;</td>
1096
								<td>
1097
									<span class="red">
1098
										<strong><?=gettext("Note:");?></strong>
1099
									</span>
1100
									<?=gettext("By default DHCP leases are displayed in UTC time.  By checking this box DHCP lease time will be displayed in local time and set to time zone selected.  This will be used for all DHCP interfaces lease time."); ?>
1101
								</td>
1102
							</tr>
1103
						</table>
1104
					</td>
1105
				</tr>
1106
<?php
1107
	endif;
1108
?>
1109
				<tr>
1110
					<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic DNS");?></td>
1111
					<td width="78%" class="vtable">
1112
						<div id="showddnsbox">
1113
							<input type="button" onclick="show_ddns_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show Dynamic DNS");?>
1114
						</div>
1115
						<div id="showddns" style="display:none">
1116
							<input style="vertical-align:middle" type="checkbox" value="yes" name="ddnsupdate" id="ddnsupdate" <?php if ($pconfig['ddnsupdate']) echo " checked=\"checked\""; ?> />&nbsp;
1117
							<b><?=gettext("Enable registration of DHCP client names in DNS.");?></b><br />
1118
							<br/>
1119
							<input name="ddnsdomain" type="text" class="formfld unknown" id="ddnsdomain" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomain']);?>" /><br />
1120
							<?=gettext("Note: Leave blank to disable dynamic DNS registration.");?><br />
1121
							<?=gettext("Enter the dynamic DNS domain which will be used to register client names in the DNS server.");?><br />
1122
							<input name="ddnsdomainprimary" type="text" class="formfld unknown" id="ddnsdomainprimary" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomainprimary']);?>" /><br />
1123
							<?=gettext("Enter the primary domain name server IP address for the dynamic domain name.");?><br />
1124
							<input name="ddnsdomainkeyname" type="text" class="formfld unknown" id="ddnsdomainkeyname" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomainkeyname']);?>" /><br />
1125
							<?=gettext("Enter the dynamic DNS domain key name which will be used to register client names in the DNS server.");?><br />
1126
							<input name="ddnsdomainkey" type="text" class="formfld unknown" id="ddnsdomainkey" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomainkey']);?>" /><br />
1127
							<?=gettext("Enter the dynamic DNS domain key secret which will be used to register client names in the DNS server.");?>
1128
						</div>
1129
					</td>
1130
				</tr>
1131
				<tr>
1132
					<td width="22%" valign="top" class="vncell"><?=gettext("MAC Address Control");?></td>
1133
					<td width="78%" class="vtable">
1134
						<div id="showmaccontrolbox">
1135
							<input type="button" onclick="show_maccontrol_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show MAC Address Control");?>
1136
						</div>
1137
						<div id="showmaccontrol" style="display:none">
1138
							<input name="mac_allow" type="text" class="formfld unknown" id="mac_allow" size="20" value="<?=htmlspecialchars($pconfig['mac_allow']);?>" /><br />
1139
							<?=gettext("Enter a list of partial MAC addresses to allow, comma separated, no spaces, such as ");?>00:00:00,01:E5:FF<br />
1140
							<input name="mac_deny" type="text" class="formfld unknown" id="mac_deny" size="20" value="<?=htmlspecialchars($pconfig['mac_deny']);?>" /><br />
1141
							<?=gettext("Enter a list of partial MAC addresses to deny access, comma separated, no spaces, such as ");?>00:00:00,01:E5:FF
1142
						</div>
1143
					</td>
1144
				</tr>
1145
				<tr>
1146
					<td width="22%" valign="top" class="vncell"><?=gettext("NTP servers");?></td>
1147
					<td width="78%" class="vtable">
1148
						<div id="showntpbox">
1149
							<input type="button" onclick="show_ntp_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show NTP configuration");?>
1150
						</div>
1151
						<div id="showntp" style="display:none">
1152
							<input name="ntp1" type="text" class="formfld unknown" id="ntp1" size="20" value="<?=htmlspecialchars($pconfig['ntp1']);?>" /><br />
1153
							<input name="ntp2" type="text" class="formfld unknown" id="ntp2" size="20" value="<?=htmlspecialchars($pconfig['ntp2']);?>" />
1154
						</div>
1155
					</td>
1156
				</tr>
1125 1157
				<tr>
1126
				<td colspan="3">
1127
					<div style="padding:5px; margin-top: 16px; margin-bottom: 16px; border:1px dashed #000066; background-color: #ffffff; color: #000000; font-size: 8pt;" id="itemhelp">
1128
					<?=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="_blank"><?=gettext("URL"); ?></a>
1129
					</div>
1130
				</td>
1158
					<td width="22%" valign="top" class="vncell"><?=gettext("TFTP server");?></td>
1159
					<td width="78%" class="vtable">
1160
						<div id="showtftpbox">
1161
							<input type="button" onclick="show_tftp_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show TFTP configuration");?>
1162
						</div>
1163
						<div id="showtftp" style="display:none">
1164
							<input name="tftp" type="text" class="formfld unknown" id="tftp" size="50" value="<?=htmlspecialchars($pconfig['tftp']);?>" /><br />
1165
							<?=gettext("Leave blank to disable.  Enter a full hostname or IP for the TFTP server.");?>
1166
						</div>
1167
					</td>
1131 1168
				</tr>
1132 1169
				<tr>
1133
				<td><div id="onecolumn"><?=gettext("Number");?></div></td>
1134
				<td><div id="twocolumn"><?=gettext("Type");?></div></td>
1135
				<td><div id="threecolumn"><?=gettext("Value");?></div></td>
1170
					<td width="22%" valign="top" class="vncell"><?=gettext("LDAP URI");?></td>
1171
					<td width="78%" class="vtable">
1172
						<div id="showldapbox">
1173
							<input type="button" onclick="show_ldap_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show LDAP configuration");?>
1174
						</div>
1175
						<div id="showldap" style="display:none">
1176
							<input name="ldap" type="text" class="formfld unknown" id="ldap" size="80" value="<?=htmlspecialchars($pconfig['ldap']);?>" /><br />
1177
							<?=gettext("Leave blank to disable.  Enter a full URI for the LDAP server in the form ldap://ldap.example.com/dc=example,dc=com");?>
1178
						</div>
1179
					</td>
1136 1180
				</tr>
1137
				<?php $counter = 0; ?>
1138
				<?php
1139
					if($pconfig['numberoptions'])
1140
						foreach($pconfig['numberoptions']['item'] as $item):
1141
				?>
1142
					<?php
1143
						$number = $item['number'];
1144
						$itemtype = $item['type'];
1145
						$value = $item['value'];
1146
					?>
1147 1181
				<tr>
1148
				<td>
1149
					<input autocomplete="off" name="number<?php echo $counter; ?>" type="text" class="formfld unknown" id="number<?php echo $counter; ?>" size="10" value="<?=htmlspecialchars($number);?>" />
1150
				</td>
1151
				<td>
1152
					<select name="itemtype<?php echo $counter; ?>" class="formselect" id="itemtype<?php echo $counter; ?>">
1153
					<?php
1154
					foreach ($customitemtypes as $typename => $typedescr) {
1155
						echo "<option value=\"{$typename}\" ";
1156
						if ($itemtype == $typename) echo "selected=\"selected\"";
1157
						echo ">" . $typedescr . "</option>";
1182
					<td width="22%" valign="top" class="vncell"><?=gettext("Enable network booting");?></td>
1183
					<td width="78%" class="vtable">
1184
						<div id="shownetbootbox">
1185
							<input type="button" onclick="show_netboot_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show Network booting");?>
1186
						</div>
1187
						<div id="shownetboot" style="display:none">
1188
							<input style="vertical-align:middle" type="checkbox" value="yes" name="netboot" id="netboot" <?php if ($pconfig['netboot']) echo " checked=\"checked\""; ?> />&nbsp;
1189
							<b><?=gettext("Enables network booting.");?></b>
1190
							<br/>
1191
							<table border="0" cellspacing="0" cellpadding="2" summary="network booting">
1192
								<tr>
1193
									<td>
1194
										<?=gettext("Enter the IP of the"); ?> <b><?=gettext("next-server"); ?></b>
1195
									</td>
1196
									<td>
1197
										<input name="nextserver" type="text" class="formfld unknown" id="nextserver" size="20" value="<?=htmlspecialchars($pconfig['nextserver']);?>" /><br />
1198
									</td>
1199
								</tr>
1200
								<tr>
1201
									<td>
1202
										<?=gettext("and the default bios filename");?>
1203
									</td>
1204
									<td>
1205
										<input name="filename" type="text" class="formfld unknown" id="filename" size="20" value="<?=htmlspecialchars($pconfig['filename']);?>" /><br />
1206
									</td>
1207
								</tr>
1208
								<tr>
1209
									<td>
1210
										<?=gettext("and the UEFI 32bit filename  ");?>
1211
									</td>
1212
									<td>
1213
										<input name="filename32" type="text" class="formfld unknown" id="filename32" size="20" value="<?=htmlspecialchars($pconfig['filename32']);?>" /><br />
1214
									</td>
1215
								</tr>
1216
								<tr>
1217
									<td>
1218
										<?=gettext("and the UEFI 64bit filename  ");?>
1219
									</td>
1220
									<td>
1221
										<input name="filename64" type="text" class="formfld unknown" id="filename64" size="20" value="<?=htmlspecialchars($pconfig['filename64']);?>" /><br />
1222
									</td>
1223
								</tr>
1224
							</table>
1225
							<?=gettext("Note: You need both a filename and a boot server configured for this to work!");?>
1226
							<?=gettext("You will need all three filenames and a boot server configured for UEFI to work!");?>
1227
							<?=gettext("Enter the"); ?> <b><?=gettext("root-path"); ?></b>-<?=gettext("string");?>
1228
							<input name="rootpath" type="text" class="formfld unknown" id="rootpath" size="90" value="<?=htmlspecialchars($pconfig['rootpath']);?>" /><br />
1229
							<?=gettext("Note: string-format: iscsi:(servername):(protocol):(port):(LUN):targetname");?>
1230
						</div>
1231
					</td>
1232
				</tr>
1233
<?php
1234
	if (!is_numeric($pool) && !($act == "newpool")):
1235
?>
1236
				<tr>
1237
					<td width="22%" valign="top" class="vncell"><?=gettext("Additional BOOTP/DHCP Options");?></td>
1238
					<td width="78%" class="vtable">
1239
						<div id="shownumbervaluebox">
1240
							<input type="button" onclick="show_shownumbervalue()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show Additional BOOTP/DHCP Options");?>
1241
						</div>
1242
						<div id="shownumbervalue" style="display:none">
1243
							<table id="maintable" summary="bootp-dhcp options">
1244
							<tbody>
1245
								<tr>
1246
									<td colspan="3">
1247
										<div style="padding:5px; margin-top: 16px; margin-bottom: 16px; border:1px dashed #000066; background-color: #ffffff; color: #000000; font-size: 8pt;" id="itemhelp">
1248
											<?=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="_blank"><?=gettext("URL"); ?></a>
1249
										</div>
1250
									</td>
1251
								</tr>
1252
								<tr>
1253
									<td><div id="onecolumn"><?=gettext("Number");?></div></td>
1254
									<td><div id="twocolumn"><?=gettext("Type");?></div></td>
1255
									<td><div id="threecolumn"><?=gettext("Value");?></div></td>
1256
								</tr>
1257
<?php
1258
		$counter = 0;
1259
		if ($pconfig['numberoptions']):
1260
			foreach ($pconfig['numberoptions']['item'] as $item):
1261
				$number = $item['number'];
1262
				$itemtype = $item['type'];
1263
				$value = $item['value'];
1264
?>
1265
								<tr>
1266
									<td>
1267
										<input autocomplete="off" name="number<?php echo $counter; ?>" type="text" class="formfld unknown" id="number<?php echo $counter; ?>" size="10" value="<?=htmlspecialchars($number);?>" />
1268
									</td>
1269
									<td>
1270
										<select name="itemtype<?php echo $counter; ?>" class="formselect" id="itemtype<?php echo $counter; ?>">
1271
<?php
1272
				foreach ($customitemtypes as $typename => $typedescr) {
1273
					echo "<option value=\"{$typename}\" ";
1274
					if ($itemtype == $typename) {
1275
						echo "selected=\"selected\"";
1158 1276
					}
1159
					?>
1160
					</select>
1161
				</td>
1162
				<td>
1163
					<input autocomplete="off" name="value<?php echo $counter; ?>" type="text" class="formfld unknown" id="value<?php echo $counter; ?>" size="40" value="<?=htmlspecialchars($value);?>" />
1164
				</td>
1165
				<td>
1166
					<a onclick="removeRow(this); return false;" href="#"><img border="0" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" alt="delete" /></a>
1167
				</td>
1277
					echo ">" . $typedescr . "</option>";
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff