Project

General

Profile

« Previous | Next » 

Revision 6e3488e9

Added by Phil Davis over 9 years ago

Code style services dhcp dnsmasq dyndns

View differences:

src/usr/local/www/services_dhcp.php
95 95
	foreach ($iflist as $ifent => $ifname) {
96 96
		$oc = $config['interfaces'][$ifent];
97 97
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) ||
98
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr'])))) {
98
		    (!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr'])))) {
99 99
			continue;
100 100
		}
101 101

  
......
307 307
			$input_errors[] = gettext("A valid primary domain name server IP address must be specified for the dynamic domain name.");
308 308
		}
309 309
		if (($_POST['ddnsdomainkey'] && !$_POST['ddnsdomainkeyname']) ||
310
			($_POST['ddnsdomainkeyname'] && !$_POST['ddnsdomainkey'])) {
310
		    ($_POST['ddnsdomainkeyname'] && !$_POST['ddnsdomainkey'])) {
311 311
			$input_errors[] = gettext("You must specify both a valid domain key and key name.");
312 312
		}
313 313
		if ($_POST['domainsearchlist']) {
......
404 404
			$subnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
405 405

  
406 406
			if ((ip2ulong($_POST['range_from']) < $subnet_start) || (ip2ulong($_POST['range_from']) > $subnet_end) ||
407
				(ip2ulong($_POST['range_to']) < $subnet_start) || (ip2ulong($_POST['range_to']) > $subnet_end)) {
407
			    (ip2ulong($_POST['range_to']) < $subnet_start) || (ip2ulong($_POST['range_to']) > $subnet_end)) {
408 408
				$input_errors[] = gettext("The specified range lies outside of the current subnet.");
409 409
			}
410 410

  
......
427 427
				}
428 428

  
429 429
				if (is_inrange_v4($_POST['range_from'], $p['range']['from'], $p['range']['to']) ||
430
					is_inrange_v4($_POST['range_to'], $p['range']['from'], $p['range']['to'])) {
430
				    is_inrange_v4($_POST['range_to'], $p['range']['from'], $p['range']['to'])) {
431 431
					$input_errors[] = gettext("The specified range must not be within the range configured on a DHCP pool for this interface.");
432 432
					break;
433 433
				}
......
446 446
						continue;
447 447
					}
448 448
					if ((ip2ulong($map['ipaddr']) > $dynsubnet_start) &&
449
						(ip2ulong($map['ipaddr']) < $dynsubnet_end)) {
449
					    (ip2ulong($map['ipaddr']) < $dynsubnet_end)) {
450 450
						$input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings."));
451 451
						break;
452 452
					}
......
701 701

  
702 702
include("head.inc");
703 703

  
704
if ($input_errors)
704
if ($input_errors) {
705 705
	print_input_errors($input_errors);
706
}
706 707

  
707
if ($savemsg)
708
if ($savemsg) {
708 709
	print_info_box($savemsg, 'success');
710
}
709 711

  
710 712
if (isset($config['dhcrelay']['enable'])) {
711 713
	print_info_box(gettext("DHCP Relay is currently enabled. Cannot enable the DHCP Server service while the DHCP Relay is enabled on any interface."));
......
713 715
	exit;
714 716
}
715 717

  
716
if (is_subsystem_dirty('staticmaps'))
718
if (is_subsystem_dirty('staticmaps')) {
717 719
	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."));
720
}
718 721

  
719 722
/* active tabs */
720 723
$tab_array = array();
......
724 727
foreach ($iflist as $ifent => $ifname) {
725 728
	$oc = $config['interfaces'][$ifent];
726 729
	if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) ||
727
		(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr'])))) {
730
	    (!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr'])))) {
728 731
		continue;
729 732
	}
730 733

  
......
886 889
	$pconfig['wins2']
887 890
))->setPattern('[.a-zA-Z0-9_]+')->setAttribute('placeholder', 'WINS Server 2');
888 891

  
889
for($idx=1; $idx<=4; $idx++) {
892
for ($idx=1; $idx<=4; $idx++) {
890 893
	$section->addInput(new Form_IpAddress(
891 894
		'dns' . $idx,
892 895
		($idx == 1) ? 'DNS servers':null,
......
1183 1186
	'For a list of available options please visit this ') . '<a href="http://www.iana.org/assignments/bootp-dhcp-parameters/" target="_blank">' . gettext("URL") . '</a></div>'
1184 1187
));
1185 1188

  
1186
if(!$pconfig['numberoptions']) {
1189
if (!$pconfig['numberoptions']) {
1187 1190
	$pconfig['numberoptions']['item']  = array(array('number' => '', 'type' => 'text', 'value' => ''));
1188 1191
}
1189 1192

  
......
1346 1349

  
1347 1350
<script type="text/javascript">
1348 1351
//<![CDATA[
1349
events.push(function(){
1352
events.push(function() {
1350 1353

  
1351 1354
	// Show advanced DNS options ======================================================================================
1352 1355
	var showadvdns = false;
......
1354 1357
	function show_advdns() {
1355 1358
<?php
1356 1359
		if (!$pconfig['ddnsupdate'] && empty($pconfig['ddnsdomain']) && empty($pconfig['ddnsdomainprimary']) &&
1357
		    empty($pconfig['ddnsdomainkeyname']) && empty($pconfig['ddnsdomainkey']))
1360
		    empty($pconfig['ddnsdomainkeyname']) && empty($pconfig['ddnsdomainkey'])) {
1358 1361
			$hide = false;
1359
		else
1362
		} else {
1360 1363
			$hide = true;
1364
		}
1361 1365
?>
1362
		var hide = <?php if($hide) {echo 'true';} else {echo 'false';} ?>;
1366
		var hide = <?php if ($hide) {echo 'true';} else {echo 'false';} ?>;
1363 1367

  
1364 1368
		hideCheckbox('ddnsupdate', !showadvdns && !hide);
1365 1369
		hideInput('ddnsdomain', !showadvdns && !hide);
......
1381 1385

  
1382 1386
	function show_advmac() {
1383 1387
<?php
1384
		if (empty($pconfig['mac_allow']) && empty($pconfig['mac_deny']))
1388
		if (empty($pconfig['mac_allow']) && empty($pconfig['mac_deny'])) {
1385 1389
			$hide = false;
1386
		else
1390
		} else {
1387 1391
			$hide = true;
1392
		}
1388 1393
?>
1389
		var hide = <?php if($hide) {echo 'true';} else {echo 'false';} ?>;
1394
		var hide = <?php if ($hide) {echo 'true';} else {echo 'false';} ?>;
1390 1395

  
1391 1396
		hideInput('mac_allow', !showadvmac && !hide);
1392 1397
		hideInput('mac_deny', !showadvmac && !hide);
......
1406 1411

  
1407 1412
	function show_advntp() {
1408 1413
<?php
1409
		if (empty($pconfig['ntp1']) && empty($pconfig['ntp2']))
1414
		if (empty($pconfig['ntp1']) && empty($pconfig['ntp2'])) {
1410 1415
			$hide = false;
1411
		else
1416
		} else {
1412 1417
			$hide = true;
1418
		}
1413 1419
?>
1414
		var hide = <?php if($hide) {echo 'true';} else {echo 'false';} ?>;
1420
		var hide = <?php if ($hide) {echo 'true';} else {echo 'false';} ?>;
1415 1421

  
1416 1422
		hideInput('ntp1', !showadvntp && !hide);
1417 1423
		hideInput('ntp2', !showadvntp && !hide);
......
1431 1437

  
1432 1438
	function show_advtftp() {
1433 1439
<?php
1434
		if (empty($pconfig['tftp']))
1440
		if (empty($pconfig['tftp'])) {
1435 1441
			$hide = false;
1436
		else
1442
		} else {
1437 1443
			$hide = true;
1444
		}
1438 1445
?>
1439
		var hide = <?php if($hide) {echo 'true';} else {echo 'false';} ?>;
1446
		var hide = <?php if ($hide) {echo 'true';} else {echo 'false';} ?>;
1440 1447

  
1441 1448
		hideInput('tftp', !showadvtftp && !hide);
1442 1449
		hideInput('btnadvtftp', hide);
......
1455 1462

  
1456 1463
	function show_advldap() {
1457 1464
<?php
1458
		if (empty($pconfig['ldap']))
1465
		if (empty($pconfig['ldap'])) {
1459 1466
			$hide = false;
1460
		else
1467
		} else {
1461 1468
			$hide = true;
1469
		}
1462 1470
?>
1463
		var hide = <?php if($hide) {echo 'true';} else {echo 'false';} ?>;
1471
		var hide = <?php if ($hide) {echo 'true';} else {echo 'false';} ?>;
1464 1472

  
1465 1473
		hideInput('ldap', !showadvldap && !hide);
1466 1474
		hideInput('btnadvldap', hide);
......
1480 1488
	function show_advboot() {
1481 1489
<?php
1482 1490
		if (!$pconfig['netboot'] && empty($pconfig['nextserver']) && empty($pconfig['filename']) && empty($pconfig['filename32']) &&
1483
		    empty($pconfig['filename64']) && empty($pconfig['rootpath']))
1491
		    empty($pconfig['filename64']) && empty($pconfig['rootpath'])) {
1484 1492
			$hide = false;
1485
		else
1493
		} else {
1486 1494
			$hide = true;
1495
		}
1487 1496
?>
1488
		var hide = <?php if($hide) {echo 'true';} else {echo 'false';} ?>;
1497
		var hide = <?php if ($hide) {echo 'true';} else {echo 'false';} ?>;
1489 1498

  
1490 1499
		hideCheckbox('netboot', !showadvboot && !hide);
1491 1500
		hideInput('nextserver', !showadvboot && !hide);
......
1509 1518

  
1510 1519
	function show_advopts() {
1511 1520
<?php
1512
		if ( empty($pconfig['numberoptions']) ||
1513
		    (empty($pconfig['numberoptions']['item'][0]['number']) && (empty($pconfig['numberoptions']['item'][0]['value']))))
1521
		if (empty($pconfig['numberoptions']) ||
1522
		    (empty($pconfig['numberoptions']['item'][0]['number']) && (empty($pconfig['numberoptions']['item'][0]['value'])))) {
1514 1523
			$hide = false;
1515
		else
1524
		} else {
1516 1525
			$hide = true;
1526
		}
1517 1527
?>
1518
		var hide = <?php if($hide) {echo 'true';} else {echo 'false';} ?>;
1528
		var hide = <?php if ($hide) {echo 'true';} else {echo 'false';} ?>;
1519 1529

  
1520 1530
		hideClass('adnlopts', !showadvopts && !hide);
1521 1531
		hideInput('btnadvopts', hide);
src/usr/local/www/services_dhcp_edit.php
84 84

  
85 85
$if = $_GET['if'];
86 86

  
87
if ($_POST['if'])
87
if ($_POST['if']) {
88 88
	$if = $_POST['if'];
89
}
89 90

  
90 91
if (!$if) {
91 92
	header("Location: services_dhcp.php");
......
398 399
// Get our MAC address
399 400
$ip = $_SERVER['REMOTE_ADDR'];
400 401
$mymac = `/usr/sbin/arp -an | grep '('{$ip}')' | cut -d" " -f4`;
401
$mymac = str_replace("\n","",$mymac);
402
$mymac = str_replace("\n", "", $mymac);
402 403

  
403 404
$closehead = false;
404 405
$pgtitle = array(gettext("Services"), gettext("DHCP"), gettext("Edit static mapping"));
......
406 407

  
407 408
include("head.inc");
408 409

  
409
if ($input_errors)
410
if ($input_errors) {
410 411
	print_input_errors($input_errors);
412
}
411 413

  
412 414
$form = new Form();
413 415

  
......
455 457
	$pconfig['hostname']
456 458
))->setHelp('Name of the host, without domain part.');
457 459

  
458
if($netboot_enabled) {
460
if ($netboot_enabled) {
459 461
	$section->addInput(new Form_Input(
460 462
		'filename',
461 463
		'Netboot filename',
......
682 684

  
683 685
<script type="text/javascript">
684 686
//<![CDATA[
685
events.push(function(){
687
events.push(function() {
686 688

  
687 689
	function hideDDNS(hide) {
688 690
		hideCheckbox('ddnsupdate', hide);
src/usr/local/www/services_dhcp_relay.php
114 114
		$svrlist = '';
115 115

  
116 116
		if ($_POST['server']) {
117
			foreach($_POST['server'] as $checksrv => $srv) {
118
				if (!is_ipaddr($srv[0]))
117
			foreach ($_POST['server'] as $checksrv => $srv) {
118
				if (!is_ipaddr($srv[0])) {
119 119
					$input_errors[] = gettext("A valid Destination Server IP address must be specified.");
120
				}
120 121

  
121
				if(!empty($srv[0])) { // Filter out any empties
122
					if(!empty($svrlist))
122
				if (!empty($srv[0])) { // Filter out any empties
123
					if (!empty($svrlist)) {
123 124
						$svrlist .= ',';
125
					}
124 126

  
125 127
					$svrlist .= $srv[0];
126 128
				}
......
157 159
	exit;
158 160
}
159 161

  
160
if ($input_errors)
162
if ($input_errors) {
161 163
	print_input_errors($input_errors);
164
}
162 165

  
163
if ($savemsg)
166
if ($savemsg) {
164 167
	print_info_box($savemsg, 'success');
168
}
165 169

  
166 170
$form = new Form;
167 171

  
......
194 198
);
195 199

  
196 200
//Small function to prevent duplicate code
197
function createDestinationServerInputGroup($value = null)
198
{
201
function createDestinationServerInputGroup($value = null) {
199 202
	$group = new Form_Group('Destination server');
200 203

  
201 204
	$group->add(new Form_IpAddress(
......
210 213
	return $group;
211 214
}
212 215

  
213
if (!isset($pconfig['server']) || count($pconfig['server']) < 1)
216
if (!isset($pconfig['server']) || count($pconfig['server']) < 1) {
214 217
	$section->add(createDestinationServerInputGroup());
215
else {
218
} else {
216 219
	foreach (explode(',', $pconfig['server']) as $server) {
217 220
			$section->add(createDestinationServerInputGroup($server));
218 221
	}
src/usr/local/www/services_dhcpv6.php
101 101
		$oc = $config['interfaces'][$ifent];
102 102

  
103 103
		if ((is_array($config['dhcpdv6'][$ifent]) && !isset($config['dhcpdv6'][$ifent]['enable']) && !(is_ipaddrv6($oc['ipaddrv6']) && (!is_linklocal($oc['ipaddrv6'])))) ||
104
			(!is_array($config['dhcpdv6'][$ifent]) && !(is_ipaddrv6($oc['ipaddrv6']) && (!is_linklocal($oc['ipaddrv6']))))) {
104
		    (!is_array($config['dhcpdv6'][$ifent]) && !(is_ipaddrv6($oc['ipaddrv6']) && (!is_linklocal($oc['ipaddrv6']))))) {
105 105
			continue;
106 106
		}
107 107
		$if = $ifent;
......
160 160
if (is_array($dhcrelaycfg)) {
161 161
	foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
162 162
		if (isset($dhcrelayifconf['enable']) && isset($iflist[$dhcrelayif]) &&
163
			(!link_interface_to_bridge($dhcrelayif))) {
163
		    (!link_interface_to_bridge($dhcrelayif))) {
164 164
			$dhcrelay_enabled = true;
165 165
		}
166 166
	}
......
210 210
			$input_errors[] = gettext("A valid IPv6 address must be specified for the gateway.");
211 211
		}
212 212
		if (($_POST['dns1'] && !is_ipaddrv6($_POST['dns1'])) ||
213
			($_POST['dns2'] && !is_ipaddrv6($_POST['dns2'])) ||
214
			($_POST['dns3'] && !is_ipaddrv6($_POST['dns3'])) ||
215
			($_POST['dns4'] && !is_ipaddrv6($_POST['dns4']))) {
213
		    ($_POST['dns2'] && !is_ipaddrv6($_POST['dns2'])) ||
214
		    ($_POST['dns3'] && !is_ipaddrv6($_POST['dns3'])) ||
215
		    ($_POST['dns4'] && !is_ipaddrv6($_POST['dns4']))) {
216 216
			$input_errors[] = gettext("A valid IPv6 address must be specified for each of the DNS servers.");
217 217
		}
218 218

  
......
229 229
			$input_errors[] = gettext("A valid primary domain name server IPv4 address must be specified for the dynamic domain name.");
230 230
		}
231 231
		if (($_POST['ddnsdomainkey'] && !$_POST['ddnsdomainkeyname']) ||
232
			($_POST['ddnsdomainkeyname'] && !$_POST['ddnsdomainkey'])) {
232
		    ($_POST['ddnsdomainkeyname'] && !$_POST['ddnsdomainkey'])) {
233 233
			$input_errors[] = gettext("You must specify both a valid domain key and key name.");
234 234
		}
235 235
		if ($_POST['domainsearchlist']) {
......
281 281

  
282 282
			if (is_ipaddrv6($ifcfgip)) {
283 283
				if ((!is_inrange_v6($_POST['range_from'], $subnet_start, $subnet_end)) ||
284
					(!is_inrange_v6($_POST['range_to'], $subnet_start, $subnet_end))) {
284
				    (!is_inrange_v6($_POST['range_to'], $subnet_start, $subnet_end))) {
285 285
					$input_errors[] = gettext("The specified range lies outside of the current subnet.");
286 286
				}
287 287
			}
......
308 308
						continue;
309 309
					}
310 310
					if ((inet_pton($map['ipaddrv6']) > $dynsubnet_start) &&
311
						(inet_pton($map['ipaddrv6']) < $dynsubnet_end)) {
311
					    (inet_pton($map['ipaddrv6']) < $dynsubnet_end)) {
312 312
						$input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings."));
313 313
						break;
314 314
					}
......
437 437
}
438 438

  
439 439
// Delete a row in the options table
440
if($_GET['act'] == "delopt") {
440
if ($_GET['act'] == "delopt") {
441 441
	$idx = $_GET['id'];
442 442

  
443
	if($pconfig['numberoptions'] && is_array($pconfig['numberoptions']['item'][$idx])) {
443
	if ($pconfig['numberoptions'] && is_array($pconfig['numberoptions']['item'][$idx])) {
444 444
	   unset($pconfig['numberoptions']['item'][$idx]);
445 445
	}
446 446
}
447 447

  
448 448
// Add an option row
449
if($_GET['act'] == "addopt") {
450
	if(!is_array($pconfig['numberoptions']['item']))
449
if ($_GET['act'] == "addopt") {
450
	if (!is_array($pconfig['numberoptions']['item'])) {
451 451
		$pconfig['numberoptions']['item'] = array();
452
	}
452 453

  
453 454
	array_push($pconfig['numberoptions']['item'], array('number' => null, 'value' => null));
454 455
}
......
459 460

  
460 461
include("head.inc");
461 462

  
462
if ($input_errors)
463
if ($input_errors) {
463 464
	print_input_errors($input_errors);
465
}
464 466

  
465
if ($savemsg)
467
if ($savemsg) {
466 468
	print_info_box($savemsg, 'success');
469
}
467 470

  
468 471
if ($dhcrelay_enabled) {
469 472
	print_info_box(gettext("DHCP Relay is currently enabled. Cannot enable the DHCP Server service while the DHCP Relay is enabled on any interface."), 'danger');
......
471 474
	exit;
472 475
}
473 476

  
474
if (is_subsystem_dirty('staticmaps'))
477
if (is_subsystem_dirty('staticmaps')) {
475 478
	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.'));
479
}
476 480

  
477 481
/* active tabs */
478 482
$tab_array = array();
......
483 487
	$oc = $config['interfaces'][$ifent];
484 488

  
485 489

  
486
	if((is_array($config['dhcpdv6'][$ifent]) && !isset($config['dhcpdv6'][$ifent]['enable']) && !(is_ipaddrv6($oc['ipaddrv6']) && (!is_linklocal($oc['ipaddrv6'])))) ||
487
		(!is_array($config['dhcpdv6'][$ifent]) && !(is_ipaddrv6($oc['ipaddrv6']) && (!is_linklocal($oc['ipaddrv6'])))))
490
	if ((is_array($config['dhcpdv6'][$ifent]) && !isset($config['dhcpdv6'][$ifent]['enable']) && !(is_ipaddrv6($oc['ipaddrv6']) && (!is_linklocal($oc['ipaddrv6'])))) ||
491
	    (!is_array($config['dhcpdv6'][$ifent]) && !(is_ipaddrv6($oc['ipaddrv6']) && (!is_linklocal($oc['ipaddrv6']))))) {
488 492
		continue;
493
	}
489 494

  
490
	if ($ifent == $if)
495
	if ($ifent == $if) {
491 496
		$active = true;
492
	else
497
	} else {
493 498
		$active = false;
499
	}
494 500

  
495 501
	$tab_array[] = array($ifname, $active, "services_dhcpv6.php?if={$ifent}");
496 502
	$tabscounter++;
......
499 505
/* tack on PPPoE or PPtP servers here */
500 506
/* pppoe server */
501 507
if (is_array($config['pppoes']['pppoe'])) {
502
	foreach($config['pppoes']['pppoe'] as $pppoe) {
508
	foreach ($config['pppoes']['pppoe'] as $pppoe) {
503 509
		if ($pppoe['mode'] == "server") {
504 510
			$ifent = "poes". $pppoe['pppoeid'];
505 511
			$ifname = strtoupper($ifent);
506 512

  
507
			if ($ifent == $if)
513
			if ($ifent == $if) {
508 514
				$active = true;
509
			else
515
			} else {
510 516
				$active = false;
517
			}
511 518

  
512 519
			$tab_array[] = array($ifname, $active, "services_dhcpv6.php?if={$ifent}");
513 520
			$tabscounter++;
......
526 533
$tab_array = array();
527 534
$tab_array[] = array(gettext("DHCPv6 Server"),		 true,	"services_dhcpv6.php?if={$if}");
528 535
$tab_array[] = array(gettext("Router Advertisements"), false, "services_router_advertisements.php?if={$if}");
529
display_top_tabs($tab_array, false, 'nav nav-tabs' );
536
display_top_tabs($tab_array, false, 'nav nav-tabs');
530 537

  
531 538
$form = new Form(new Form_Button(
532 539
	'Submit',
......
542 549
	$pconfig['enable']
543 550
))->toggles('.form-group:not(:first-child)');
544 551

  
545
if(is_ipaddrv6($ifcfgip)) {
552
if (is_ipaddrv6($ifcfgip)) {
546 553

  
547 554
	$section->addInput(new Form_StaticText(
548 555
		'Subnet',
......
560 567
		));
561 568
}
562 569

  
563
if($is_olsr_enabled) {
570
if ($is_olsr_enabled) {
564 571
	$section->addInput(new Form_Select(
565 572
	'netmask',
566 573
	'Subnet Mask',
......
635 642

  
636 643
$group = new Form_Group('DNS Servers');
637 644

  
638
for($i=1;$i<=4; $i++) {
645
for ($i=1;$i<=4; $i++) {
639 646
	$group->add(new Form_input(
640 647
		'dns' . $i,
641 648
		null,
......
645 652
	));
646 653
}
647 654

  
648
$group->setHelp('Leave blank to use the system default DNS servers,this interface\'s IP if DNS forwarder is enabled, or the servers configured on the "General" page.');
655
$group->setHelp('Leave blank to use the system default DNS servers, this interface\'s IP if DNS forwarder is enabled, or the servers configured on the "General" page.');
649 656
$section->add($group);
650 657

  
651 658
$section->addInput(new Form_Input(
......
828 835

  
829 836
$title = 'Show Additional BOOTP/DHCP Options';
830 837

  
831
if($pconfig['numberoptions']) {
838
if ($pconfig['numberoptions']) {
832 839
	$counter = 0;
833 840
	$last = count($pconfig['numberoptions']['item']) - 1;
834 841

  
835
	foreach($pconfig['numberoptions']['item'] as $item) {
842
	foreach ($pconfig['numberoptions']['item'] as $item) {
836 843
		$group = new Form_Group(null);
837 844

  
838 845
		$group->add(new Form_Input(
......
904 911
			</thead>
905 912
			<tbody>
906 913
<?php
907
if(is_array($a_maps)):
914
if (is_array($a_maps)):
908 915
	$i = 0;
909 916
	foreach ($a_maps as $mapent):
910
		if($mapent['duid'] != "" or $mapent['ipaddrv6'] != ""):
917
		if ($mapent['duid'] != "" or $mapent['ipaddrv6'] != ""):
911 918
?>
912 919
				<tr>
913 920
					<td>
......
947 954

  
948 955
<script type="text/javascript">
949 956
//<![CDATA[
950
events.push(function(){
957
events.push(function() {
951 958

  
952 959
	function hideDDNS(hide) {
953 960
		hideCheckBox('ddnsupdate', hide);
src/usr/local/www/services_dhcpv6_edit.php
76 76

  
77 77
require_once('globals.inc');
78 78

  
79
if(!$g['services_dhcp_server_enable']) {
79
if (!$g['services_dhcp_server_enable']) {
80 80
	header("Location: /");
81 81
	exit;
82 82
}
......
219 219

  
220 220
include("head.inc");
221 221

  
222
if ($input_errors)
222
if ($input_errors) {
223 223
	print_input_errors($input_errors);
224
}
224 225

  
225 226
$form = new Form();
226 227

  
src/usr/local/www/services_dhcpv6_relay.php
63 63
##|-PRIV
64 64

  
65 65
require("guiconfig.inc");
66
function filterDestinationServers(array $destinationServers)
67
{
66
function filterDestinationServers(array $destinationServers) {
68 67
	return array_unique(
69 68
		array_filter($destinationServers)
70 69
	);
......
113 112

  
114 113
	unset($input_errors);
115 114

  
116
	if ($_POST['server'])
115
	if ($_POST['server']) {
117 116
		$_POST['server'] = filterDestinationServers($_POST['server']);
117
	}
118 118

  
119 119
	$pconfig = $_POST;
120 120

  
......
127 127

  
128 128
		if ($_POST['server']) {
129 129
			foreach ($_POST['server'] as $srv) {
130
				if (!is_ipaddrv6($srv))
130
				if (!is_ipaddrv6($srv)) {
131 131
					$input_errors[] = gettext("A valid Destination Server IPv6 address  must be specified.");
132
				}
132 133
			}
133 134
		}
134 135
	}
......
152 153
$shortcut_section = "dhcp6";
153 154
include("head.inc");
154 155

  
155
if ($dhcpd_enabled)
156
{
156
if ($dhcpd_enabled) {
157 157
	echo '<div class="alert alert-danger">DHCPv6 Server is currently enabled. Cannot enable the DHCPv6 Relay service while the DHCPv6 Server is enabled on any interface.</div>';
158 158
	include("foot.inc");
159 159
	exit;
160 160
}
161 161

  
162
if ($input_errors)
162
if ($input_errors) {
163 163
	print_input_errors($input_errors);
164
}
164 165

  
165
if ($savemsg)
166
if ($savemsg) {
166 167
	print_info_box($savemsg);
168
}
167 169

  
168 170
$form = new Form;
169 171

  
......
196 198
	[$g['product_name']]
197 199
);
198 200

  
199
function createDestinationServerInputGroup($value = null)
200
{
201
function createDestinationServerInputGroup($value = null) {
201 202
	$group = new Form_Group('Destination server');
202 203
	$group->enableDuplication();
203 204

  
......
212 213
	return $group;
213 214
}
214 215

  
215
if (!isset($pconfig['server']) || count($pconfig['server']) < 1)
216
if (!isset($pconfig['server']) || count($pconfig['server']) < 1) {
216 217
	$section->add(createDestinationServerInputGroup());
217
else
218
	foreach ($pconfig['server'] as $idx => $server)
218
} else {
219
	foreach ($pconfig['server'] as $idx => $server) {
219 220
		$section->add(createDestinationServerInputGroup($server));
221
	}
222
}
220 223

  
221 224
$form->add($section);
222 225
print $form;
src/usr/local/www/services_dnsmasq.php
117 117
	} else {
118 118
		$pconfig = $_POST;
119 119
		unset($input_errors);
120
	
120

  
121 121
		$config['dnsmasq']['enable'] = ($_POST['enable']) ? true : false;
122 122
		$config['dnsmasq']['regdhcp'] = ($_POST['regdhcp']) ? true : false;
123 123
		$config['dnsmasq']['regdhcpstatic'] = ($_POST['regdhcpstatic']) ? true : false;
......
127 127
		$config['dnsmasq']['no_private_reverse'] = ($_POST['no_private_reverse']) ? true : false;
128 128
		$config['dnsmasq']['custom_options'] = str_replace("\r\n", "\n", $_POST['custom_options']);
129 129
		$config['dnsmasq']['strictbind'] = ($_POST['strictbind']) ? true : false;
130
	
130

  
131 131
		if (isset($_POST['enable']) && isset($config['unbound']['enable'])) {
132 132
			if ($_POST['port'] == $config['unbound']['port']) {
133 133
				$input_errors[] = "The DNS Resolver is enabled using this port. Choose a non-conflicting port, or disable DNS Resolver.";
134 134
			}
135 135
		}
136
	
136

  
137 137
		if ($_POST['port']) {
138 138
			if (is_port($_POST['port'])) {
139 139
				$config['dnsmasq']['port'] = $_POST['port'];
......
143 143
		} else if (isset($config['dnsmasq']['port'])) {
144 144
			unset($config['dnsmasq']['port']);
145 145
		}
146
	
146

  
147 147
		if (is_array($_POST['interface'])) {
148 148
			$config['dnsmasq']['interface'] = implode(",", $_POST['interface']);
149 149
		} elseif (isset($config['dnsmasq']['interface'])) {
150 150
			unset($config['dnsmasq']['interface']);
151 151
		}
152
	
152

  
153 153
		if ($config['dnsmasq']['custom_options']) {
154 154
			$args = '';
155 155
			foreach (preg_split('/\s+/', $config['dnsmasq']['custom_options']) as $c) {
......
160 160
				$input_errors[] = gettext("Invalid custom options");
161 161
			}
162 162
		}
163
	
163

  
164 164
		if (!$input_errors) {
165 165
			write_config();
166 166
			mark_subsystem_dirty('hosts');
......
177 177
			header("Location: services_dnsmasq.php");
178 178
			exit;
179 179
		}
180
	}
181
	elseif ($_GET['type'] == 'doverride') {
180
	} elseif ($_GET['type'] == 'doverride') {
182 181
		if ($a_domainOverrides[$_GET['id']]) {
183 182
			unset($a_domainOverrides[$_GET['id']]);
184 183
			write_config();
......
194 193
	$iflist = array('options' => array(), 'selected' => array());
195 194

  
196 195
	$iflist['options'][""]	= "All";
197
	if (empty($pconfig['interface']) || empty($pconfig['interface'][0]))
196
	if (empty($pconfig['interface']) || empty($pconfig['interface'][0])) {
198 197
		array_push($iflist['selected'], "");
198
	}
199 199

  
200 200
	foreach ($interface_addresses as $laddr => $ldescr) {
201 201
		$iflist['options'][$laddr] = htmlspecialchars($ldescr);
202 202

  
203
		if ($pconfig['interface'] && in_array($laddr, $pconfig['interface']))
203
		if ($pconfig['interface'] && in_array($laddr, $pconfig['interface'])) {
204 204
			array_push($iflist['selected'], $laddr);
205
		}
205 206
	}
206 207

  
207 208
	unset($interface_addresses);
......
214 215
$shortcut_section = "forwarder";
215 216
include("head.inc");
216 217

  
217
if ($input_errors)
218
if ($input_errors) {
218 219
	print_input_errors($input_errors);
220
}
219 221

  
220
if ($savemsg)
222
if ($savemsg) {
221 223
	print_info_box($savemsg, 'success');
224
}
222 225

  
223
if (is_subsystem_dirty('hosts'))
226
if (is_subsystem_dirty('hosts')) {
224 227
	print_info_box_np(gettext("The DNS forwarder configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));
228
}
225 229

  
226 230
$form = new Form();
227 231

  
......
479 483

  
480 484
<script type="text/javascript">
481 485
//<![CDATA[
482
events.push(function(){
486
events.push(function() {
483 487
	// On clicking the "Apply" button, submit the main form, not the little form the button lives in
484 488
//	$('[name=apply]').prop('type', 'button');
485 489

  
src/usr/local/www/services_dnsmasq_domainoverride_edit.php
92 92
}
93 93

  
94 94
if ($_POST) {
95
	   unset($input_errors);
96
	   $pconfig = $_POST;
95
		unset($input_errors);
96
		$pconfig = $_POST;
97 97

  
98
	   /* input validation */
99
	   $reqdfields = explode(" ", "domain ip");
100
	   $reqdfieldsn = array(gettext("Domain"),gettext("IP address"));
98
		/* input validation */
99
		$reqdfields = explode(" ", "domain ip");
100
		$reqdfieldsn = array(gettext("Domain"), gettext("IP address"));
101 101

  
102
	   do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
102
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
103 103

  
104
	   function String_Begins_With($needle, $haystack) {
105
		   return (substr($haystack, 0, strlen($needle))==$needle);
106
	   }
104
		function String_Begins_With($needle, $haystack) {
105
			return (substr($haystack, 0, strlen($needle)) == $needle);
106
		}
107 107

  
108
	   if (String_Begins_With(_msdcs, $_POST['domain'])) {
109
			   $subdomainstr = substr($_POST['domain'], 7);
108
		if (String_Begins_With(_msdcs, $_POST['domain'])) {
109
			$subdomainstr = substr($_POST['domain'], 7);
110 110

  
111
			   if ($subdomainstr && !is_domain($subdomainstr)) {
112
				  $input_errors[] = gettext("A valid domain must be specified after _msdcs.");
113
			   }
114
	   }
115
	   elseif ($_POST['domain'] && !is_domain($_POST['domain'])) {
116
			   $input_errors[] = gettext("A valid domain must be specified.");
117
	   }
111
			if ($subdomainstr && !is_domain($subdomainstr)) {
112
				$input_errors[] = gettext("A valid domain must be specified after _msdcs.");
113
			}
114
		} elseif ($_POST['domain'] && !is_domain($_POST['domain'])) {
115
			$input_errors[] = gettext("A valid domain must be specified.");
116
		}
118 117

  
119
	   if ($_POST['ip'] && !is_ipaddr($_POST['ip']) && ($_POST['ip'] != '#') && ($_POST['ip'] != '!')) {
120
			  $input_errors[] = gettext("A valid IP address must be specified, or # for an exclusion or ! to not forward at all.");
121
	   }
118
		if ($_POST['ip'] && !is_ipaddr($_POST['ip']) && ($_POST['ip'] != '#') && ($_POST['ip'] != '!')) {
119
			$input_errors[] = gettext("A valid IP address must be specified, or # for an exclusion or ! to not forward at all.");
120
		}
122 121

  
123
	   if ($_POST['dnssrcip'] && !in_array($_POST['dnssrcip'], get_configured_ip_addresses())) {
124
			  $input_errors[] = gettext("An interface IP address must be specified for the DNS query source.");
125
	   }
122
		if ($_POST['dnssrcip'] && !in_array($_POST['dnssrcip'], get_configured_ip_addresses())) {
123
			$input_errors[] = gettext("An interface IP address must be specified for the DNS query source.");
124
		}
126 125

  
127
	   if (!$input_errors) {
126
		if (!$input_errors) {
128 127
			$doment = array();
129 128
			$doment['domain'] = $_POST['domain'];
130 129

  
131
			if (empty($_POST['dnssrcip']))
130
			if (empty($_POST['dnssrcip'])) {
132 131
				$doment['ip'] = $_POST['ip'];
133
			else
134
			   $doment['ip'] = $_POST['ip'] . "@" . $_POST['dnssrcip'];
132
			} else {
133
				$doment['ip'] = $_POST['ip'] . "@" . $_POST['dnssrcip'];
134
			}
135 135

  
136 136
			$doment['descr'] = $_POST['descr'];
137 137

  
......
154 154
$shortcut_section = "forwarder";
155 155
include("head.inc");
156 156

  
157
if ($input_errors)
157
if ($input_errors) {
158 158
	print_input_errors($input_errors);
159
}
159 160

  
160 161
$form = new Form();
161 162

  
src/usr/local/www/services_dnsmasq_edit.php
80 80

  
81 81
require("guiconfig.inc");
82 82

  
83
if (!is_array($config['dnsmasq']['hosts']))
83
if (!is_array($config['dnsmasq']['hosts'])) {
84 84
	$config['dnsmasq']['hosts'] = array();
85
}
85 86

  
86 87
$a_hosts = &$config['dnsmasq']['hosts'];
87 88

  
......
137 138
			if (!substr_compare('aliashost', $key, 0, 9)) {
138 139
				$entry = substr($key, 9);
139 140
				$field = 'host';
140
			}
141
			elseif (!substr_compare('aliasdomain', $key, 0, 11)) {
141
			} elseif (!substr_compare('aliasdomain', $key, 0, 11)) {
142 142
				$entry = substr($key, 11);
143 143
				$field = 'domain';
144
			}
145
			elseif (!substr_compare('aliasdescription', $key, 0, 16)) {
144
			} elseif (!substr_compare('aliasdescription', $key, 0, 16)) {
146 145
				$entry = substr($key, 16);
147 146
				$field = 'description';
148 147
			}
......
213 212
}
214 213

  
215 214
// Delete a row in the options table
216
if($_GET['act'] == "delopt") {
215
if ($_GET['act'] == "delopt") {
217 216
	$idx = $_GET['id'];
218 217

  
219
	if($pconfig['aliases'] && is_array($pconfig['aliases']['item'][$idx])) {
218
	if ($pconfig['aliases'] && is_array($pconfig['aliases']['item'][$idx])) {
220 219
	   unset($pconfig['aliases']['item'][$idx]);
221 220
	}
222 221
}
223 222

  
224 223
// Add an option row
225
if($_GET['act'] == "addopt") {
226
    if(!is_array($pconfig['aliases']['item']))
224
if ($_GET['act'] == "addopt") {
225
    if (!is_array($pconfig['aliases']['item'])) {
227 226
        $pconfig['aliases']['item'] = array();
227
	}
228 228

  
229 229
	array_push($pconfig['aliases']['item'], array('host' => null, 'domain' => null, 'description' => null));
230 230
}
231 231

  
232
$pgtitle = array(gettext("Services"),gettext("DNS Forwarder"),gettext("Edit Host Override"));
232
$pgtitle = array(gettext("Services"), gettext("DNS Forwarder"), gettext("Edit Host Override"));
233 233
$shortcut_section = "forwarder";
234 234
include("head.inc");
235 235

  
236
if ($input_errors)
236
if ($input_errors) {
237 237
	print_input_errors($input_errors);
238
}
238 239

  
239 240
$form = new Form();
240 241

  
......
283 284

  
284 285
$section = new Form_Section('Additional names for this host');
285 286

  
286
if(!$pconfig['aliases']['item']) {
287
if (!$pconfig['aliases']['item']) {
287 288
	$pconfig['aliases']['item'] = array('host' => "");
288 289
}
289 290

  
290
if( $pconfig['aliases']['item']) {
291
if ($pconfig['aliases']['item']) {
291 292
	$counter = 0;
292 293
	$last = count($pconfig['aliases']['item']) - 1;
293 294

  
294
	foreach($pconfig['aliases']['item'] as $item) {
295
	foreach ($pconfig['aliases']['item'] as $item) {
295 296
		$group = new Form_Group(null);
296 297
		$group->addClass('repeatable');
297 298

  
src/usr/local/www/services_dyndns.php
78 78

  
79 79
	header("Location: services_dyndns.php");
80 80
	exit;
81
}
82
else if ($_GET['act'] == "toggle") {
81
} else if ($_GET['act'] == "toggle") {
83 82
	if ($a_dyndns[$_GET['id']]) {
84 83
		if (isset($a_dyndns[$_GET['id']]['enable'])) {
85 84
			unset($a_dyndns[$_GET['id']]['enable']);
......
96 95
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("Dynamic DNS Clients"));
97 96
include("head.inc");
98 97

  
99
if ($input_errors)
98
if ($input_errors) {
100 99
	print_input_errors($input_errors);
100
}
101 101

  
102 102
$tab_array = array();
103 103
$tab_array[] = array(gettext("Dynamic DNS"), true, "services_dyndns.php");
......
171 171
		$cached_ip_s = explode(":", file_get_contents($filename));
172 172
		$cached_ip = $cached_ip_s[0];
173 173

  
174
		if ($ipaddr != $cached_ip)
174
		if ($ipaddr != $cached_ip) {
175 175
			print('<span class="text-danger">');
176
		else
176
		} else {
177 177
			print('<span class="text-success">');
178
		}
178 179

  
179 180
		print(htmlspecialchars($cached_ip));
180 181
		print('</span>');
......
183 184
		$cached_ipv6_s = explode("|", file_get_contents($filename_v6));
184 185
		$cached_ipv6 = $cached_ipv6_s[0];
185 186

  
186
		if ($ipv6addr != $cached_ipv6)
187
		if ($ipv6addr != $cached_ipv6) {
187 188
			print('<span class="text-danger">');
188
		else
189
		} else {
189 190
			print('<span class="text-success">');
191
		}
190 192

  
191 193
		print(htmlspecialchars($cached_ipv6));
192 194
		print('</span>');
src/usr/local/www/services_dyndns_edit.php
217 217
	$vals = explode(" ", DYNDNS_PROVIDER_VALUES);
218 218
	$typelist = array();
219 219

  
220
	for ($j = 0; $j < count($vals); $j++)
220
	for ($j = 0; $j < count($vals); $j++) {
221 221
		$typelist[$vals[$j]] = htmlspecialchars($types[$j]);
222
	}
222 223

  
223 224
	return($typelist);
224 225
}
......
228 229

  
229 230
	$iflist = get_configured_interface_with_descr();
230 231

  
231
	foreach ($iflist as $if => $ifdesc)
232
	foreach ($iflist as $if => $ifdesc) {
232 233
		$list[$if] = $ifdesc;
234
	}
233 235

  
234 236
	unset($iflist);
235 237

  
236 238
	$grouplist = return_gateway_groups_array();
237 239

  
238
	foreach ($grouplist as $name => $group)
240
	foreach ($grouplist as $name => $group) {
239 241
		$list[$name] = 'GW Group ' . $name;
242
	}
240 243

  
241 244
	unset($grouplist);
242 245

  
......
246 249
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("Dynamic DNS Client"), gettext("Edit"));
247 250
include("head.inc");
248 251

  
249
if ($input_errors)
252
if ($input_errors) {
250 253
	print_input_errors($input_errors);
254
}
251 255

  
252
if ($savemsg)
256
if ($savemsg) {
253 257
	print_info_box($savemsg, 'success');
258
}
254 259

  
255 260
$form = new Form;
256 261

  
......
418 423
events.push(function() {
419 424

  
420 425
	function setVisible(service) {
421
		switch(service) {
426
		switch (service) {
422 427
			case "custom" :
423 428
			case "custom-v6" :
424 429
				hideInput('resultmatch', false);
......
463 468

  
464 469
	// When the 'Service type" selector is changed, we show/hide certain elements
465 470
	$('#type').on('change', function() {
466
		setVisible( this.value );
471
		setVisible(this.value);
467 472
	});
468 473

  
469 474
	// ---------- On initial page load ------------------------------------------------------------

Also available in: Unified diff