diff options
author | Stephen Beaver <sbeaver@netgate.com> | 2015-12-14 12:35:06 -0500 |
---|---|---|
committer | Stephen Beaver <sbeaver@netgate.com> | 2015-12-14 12:35:06 -0500 |
commit | e8e836212a2644a4a4eebf01efcb1e557b75051a (patch) | |
tree | 94fd78360a4607ada0a11844ed03b31bdb2ba8d5 /src/usr/local | |
parent | 3183d432cc0c17cc3af0fc49151fed0a4a724520 (diff) | |
parent | 67c2baf157c50ae1b545f36bcf6afee6cdf6f67c (diff) | |
download | pfsense-e8e836212a2644a4a4eebf01efcb1e557b75051a.zip pfsense-e8e836212a2644a4a4eebf01efcb1e557b75051a.tar.gz |
Merge pull request #2224 from phil-davis/r005
Diffstat (limited to 'src/usr/local')
20 files changed, 551 insertions, 445 deletions
diff --git a/src/usr/local/www/firewall_aliases.php b/src/usr/local/www/firewall_aliases.php index c5f6acc..6df3ad2 100644 --- a/src/usr/local/www/firewall_aliases.php +++ b/src/usr/local/www/firewall_aliases.php @@ -191,7 +191,7 @@ $tab_array[] = array(gettext("URLs"), ($tab == "url"? true : false), "/firewall $tab_array[] = array(gettext("All"), ($tab == "all"? true : false), "/firewall_aliases.php?tab=all"); foreach ($tab_array as $dtab) { - if($dtab[1] == true) { + if ($dtab[1] == true) { $bctab = $dtab[0]; break; } @@ -202,11 +202,13 @@ $shortcut_section = "aliases"; include("head.inc"); -if ($savemsg) +if ($savemsg) { print_info_box($savemsg, 'success'); +} -if (is_subsystem_dirty('aliases')) +if (is_subsystem_dirty('aliases')) { print_info_box_np(gettext("The alias list has been changed.") . "<br />" . gettext("You must apply the changes in order for them to take effect.")); +} display_top_tabs($tab_array); @@ -234,16 +236,19 @@ display_top_tabs($tab_array); case "ip": case "host": case "network": - if (preg_match("/(host|network)/", $alias["type"])) + if (preg_match("/(host|network)/", $alias["type"])) { $show_alias= true; + } break; case "url": - if (preg_match("/(url)/i", $alias["type"])) + if (preg_match("/(url)/i", $alias["type"])) { $show_alias= true; + } break; case "port": - if ($alias["type"] == "port") + if ($alias["type"] == "port") { $show_alias= true; + } break; } if ($show_alias): @@ -303,7 +308,7 @@ display_top_tabs($tab_array); That way jQuery (in pfenseHelpers.js) will automatically take care of the display. --> <div> <div id="infoblock"> - <?=print_info_box(gettext( 'Aliases act as placeholders for real hosts, networks or ports. They can be used to minimize the number ' . + <?=print_info_box(gettext('Aliases act as placeholders for real hosts, networks or ports. They can be used to minimize the number ' . 'of changes that have to be made if a host, network or port changes. <br />' . 'You can enter the name of an alias instead of the host, network or port where indicated. The alias will be resolved according to the list above.' . '<br />' . 'If an alias cannot be resolved (e.g. because you deleted it), the corresponding element (e.g. filter/NAT/shaper rule) will be considered invalid and skipped.'), info)?> diff --git a/src/usr/local/www/firewall_aliases_edit.php b/src/usr/local/www/firewall_aliases_edit.php index be82985..0adc184 100755 --- a/src/usr/local/www/firewall_aliases_edit.php +++ b/src/usr/local/www/firewall_aliases_edit.php @@ -116,7 +116,7 @@ function alias_same_type($name, $type) { foreach ($config['aliases']['alias'] as $alias) { if ($name == $alias['name']) { if (in_array($type, array("host", "network")) && - in_array($alias['type'], array("host", "network"))) { + in_array($alias['type'], array("host", "network"))) { return true; } @@ -426,7 +426,7 @@ if ($_POST) { if (!alias_same_type($input_address, $_POST['type'])) { // But alias type network can include alias type urltable. Feature#1603. if (!($_POST['type'] == 'network' && - preg_match("/urltable/i", alias_get_type($input_address)))) { + preg_match("/urltable/i", alias_get_type($input_address)))) { $wrongaliases .= " " . $input_address; } } @@ -436,7 +436,7 @@ if ($_POST) { } } else if ($_POST['type'] == "host" || $_POST['type'] == "network") { if (is_subnet($input_address) || - (!is_ipaddr($input_address) && !is_hostname($input_address))) { + (!is_ipaddr($input_address) && !is_hostname($input_address))) { $input_errors[] = sprintf(gettext('%1$s is not a valid %2$s address, FQDN or alias.'), $input_address, $_POST['type']); } } @@ -606,16 +606,18 @@ $types = array( ); if (empty($tab)) { - if (preg_match("/url/i", $pconfig['type'])) + if (preg_match("/url/i", $pconfig['type'])) { $tab = 'url'; - else if ($pconfig['type'] == 'host') + } else if ($pconfig['type'] == 'host') { $tab = 'ip'; - else + } else { $tab = $pconfig['type']; + } } -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} $form = new Form; @@ -633,8 +635,7 @@ $form->addGlobal(new Form_Input( $pconfig['name'] )); -if (isset($id) && $a_aliases[$id]) -{ +if (isset($id) && $a_aliases[$id]) { $form->addGlobal(new Form_Input( 'id', null, @@ -734,7 +735,7 @@ print $form; //<![CDATA[ addressarray = <?= json_encode(array_exclude($pconfig['name'], get_alias_list($pconfig['type']))) ?>; -events.push(function(){ +events.push(function() { var disable_subnets; @@ -764,7 +765,7 @@ events.push(function(){ hideRowsAfter(1, (tab == 'urltable') || (tab == 'urltable_ports')); // The add button and delete buttons must not show on URL Table IP or URL table ports - if((tab == 'urltable') || (tab == 'urltable_ports')) { + if ((tab == 'urltable') || (tab == 'urltable_ports')) { hideClass('addbtn', true); $('[id^=deleterow]').hide(); } else { @@ -778,7 +779,7 @@ events.push(function(){ var idx = 0; $('.repeatable').each(function(el) { - if ( idx >= row ) { + if (idx >= row) { hideRow(idx, hide); } @@ -808,7 +809,7 @@ events.push(function(){ // Autocomplete $('[id^=address]').each(function() { - if(this.id.substring(0, 8) != "address_") { + if (this.id.substring(0, 8) != "address_") { $(this).autocomplete({ source: addressarray }); diff --git a/src/usr/local/www/firewall_aliases_import.php b/src/usr/local/www/firewall_aliases_import.php index f44c92f..a263208 100755 --- a/src/usr/local/www/firewall_aliases_import.php +++ b/src/usr/local/www/firewall_aliases_import.php @@ -191,8 +191,9 @@ if ($_POST['aliasimport'] != "") { include("head.inc"); -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} $form = new Form; $section = new Form_Section('Alias details'); diff --git a/src/usr/local/www/firewall_nat.php b/src/usr/local/www/firewall_nat.php index e89e934..6c856a5 100644 --- a/src/usr/local/www/firewall_nat.php +++ b/src/usr/local/www/firewall_nat.php @@ -79,18 +79,20 @@ if (!is_array($config['nat']['rule'])) { $a_nat = &$config['nat']['rule']; /* update rule order, POST[rule] is an array of ordered IDs */ -if(array_key_exists('order-store', $_POST)) { +if (array_key_exists('order-store', $_POST)) { if (is_array($_POST['rule']) && !empty($_POST['rule'])) { $a_nat_new = array(); // if a rule is not in POST[rule], it has been deleted by the user - foreach ($_POST['rule'] as $id) + foreach ($_POST['rule'] as $id) { $a_nat_new[] = $a_nat[$id]; + } $a_nat = $a_nat_new; - if (write_config()) + if (write_config()) { mark_subsystem_dirty('filter'); + } header("Location: firewall_nat.php"); exit; @@ -171,12 +173,14 @@ $closehead = false; $pgtitle = array(gettext("Firewall"), gettext("NAT"), gettext("Port Forward")); include("head.inc"); -if ($savemsg) +if ($savemsg) { print_info_box($savemsg, 'success'); +} -if (is_subsystem_dirty('natconf')) +if (is_subsystem_dirty('natconf')) { print_info_box_np(gettext('The NAT configuration has been changed.') . '<br />' . gettext('You must apply the changes in order for them to take effect.') . '<br />'); +} $tab_array = array(); $tab_array[] = array(gettext("Port Forward"), true, "firewall_nat.php"); @@ -222,8 +226,9 @@ foreach ($a_nat as $natent): ); /* if user does not have access to edit an interface skip on to the next record */ - if (!have_natpfruleint_access($natent['interface'])) + if (!have_natpfruleint_access($natent['interface'])) { continue; + } ?> <tr id="fr<?=$nnats;?>" onClick="fr_toggle(<?=$nnats;?>)" ondblclick="document.location='firewall_nat_edit.php?id=<?=$i;?>';"> @@ -246,10 +251,11 @@ foreach ($a_nat as $natent): <td> <?=$textss?> <?php - if (!$natent['interface']) + if (!$natent['interface']) { echo htmlspecialchars(convert_friendly_interface_to_friendly_descr("wan")); - else + } else { echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface'])); + } ?> <?=$textse?> </td> diff --git a/src/usr/local/www/firewall_nat_1to1.php b/src/usr/local/www/firewall_nat_1to1.php index a2213b8..0995cb8 100644 --- a/src/usr/local/www/firewall_nat_1to1.php +++ b/src/usr/local/www/firewall_nat_1to1.php @@ -78,18 +78,20 @@ if (!is_array($config['nat']['onetoone'])) { $a_1to1 = &$config['nat']['onetoone']; /* update rule order, POST[rule] is an array of ordered IDs */ -if($_POST['order-store']) { +if ($_POST['order-store']) { if (is_array($_POST['rule']) && !empty($_POST['rule'])) { $a_1to1_new = array(); // if a rule is not in POST[rule], it has been deleted by the user - foreach ($_POST['rule'] as $id) + foreach ($_POST['rule'] as $id) { $a_1to1_new[] = $a_1to1[$id]; + } $a_1to1 = $a_1to1_new; - if (write_config()) + if (write_config()) { mark_subsystem_dirty('natconf'); + } header("Location: firewall_nat_1to1.php"); exit; @@ -156,12 +158,14 @@ if (isset($_POST['del_x'])) { $pgtitle = array(gettext("Firewall"), gettext("NAT"), gettext("1:1")); include("head.inc"); -if ($savemsg) +if ($savemsg) { print_info_box($savemsg, 'success'); +} -if (is_subsystem_dirty('natconf')) +if (is_subsystem_dirty('natconf')) { print_info_box_np(gettext('The NAT configuration has been changed.') . '<br />' . gettext('You must apply the changes in order for them to take effect.') . '<br />'); +} $tab_array = array(); $tab_array[] = array(gettext("Port Forward"), false, "firewall_nat.php"); diff --git a/src/usr/local/www/firewall_nat_1to1_edit.php b/src/usr/local/www/firewall_nat_1to1_edit.php index 5b4acfc..4b4d960 100644 --- a/src/usr/local/www/firewall_nat_1to1_edit.php +++ b/src/usr/local/www/firewall_nat_1to1_edit.php @@ -143,8 +143,9 @@ if ($_POST) { $temp = str_replace(">", "", $value); $newpost = htmlentities($temp); - if ($newpost != $temp) + if ($newpost != $temp) { $input_errors[] = sprintf(gettext("Invalid characters detected (%s). Please remove invalid characters and save again."), $temp); + } } /* input validation */ @@ -283,11 +284,13 @@ function build_srctype_list() { $sel = is_specialnet($pconfig['src']); - if (have_ruleint_access("pppoe")) + if (have_ruleint_access("pppoe")) { $list['pppoe'] = 'PPPoE clients'; + } - if (have_ruleint_access("l2tp")) + if (have_ruleint_access("l2tp")) { $list['l2tp'] = 'L2TP clients'; + } foreach ($ifdisp as $ifent => $ifdesc) { if (have_ruleint_access($ifent)) { @@ -305,8 +308,9 @@ function srctype_selected() { $sel = is_specialnet($pconfig['src']); if (!$sel) { - if (($pconfig['srcmask'] == 32) || (!isset($pconfig['srcmask']))) + if (($pconfig['srcmask'] == 32) || (!isset($pconfig['srcmask']))) { return('single'); + } return('network'); } @@ -320,11 +324,13 @@ function build_dsttype_list() { $sel = is_specialnet($pconfig['dst']); $list = array('any' => 'Any', 'single' => 'Single host or alias', 'network' => 'Network', '(self)' => 'This Firewall (self)'); - if (have_ruleint_access("pppoe")) + if (have_ruleint_access("pppoe")) { $list['pppoe'] = 'PPPoE clients'; + } - if (have_ruleint_access("l2tp")) + if (have_ruleint_access("l2tp")) { $list['l2tp'] = 'L2TP clients'; + } foreach ($ifdisp as $if => $ifdesc) { if (have_ruleint_access($if)) { @@ -335,8 +341,9 @@ function build_dsttype_list() { if (is_array($config['virtualip']['vip'])) { foreach ($config['virtualip']['vip'] as $sn) { - if (isset($sn['noexpand'])) + if (isset($sn['noexpand'])) { continue; + } if ($sn['mode'] == "proxyarp" && $sn['type'] == "network") { $start = ip2long32(gen_subnet($sn['subnet'], $sn['subnet_bits'])); @@ -362,12 +369,14 @@ function dsttype_selected() { $sel = is_specialnet($pconfig['dst']); - if (empty($pconfig['dst'] || $pconfig['dst'] == "any")) + if (empty($pconfig['dst'] || $pconfig['dst'] == "any")) { return('any'); + } if (!$sel) { - if ($pconfig['dstmask'] == 32) + if ($pconfig['dstmask'] == 32) { return('single'); + } return('network'); } @@ -375,8 +384,9 @@ function dsttype_selected() { return($pconfig['dst']); } -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} $form = new Form(new Form_Button( 'Submit', @@ -394,24 +404,31 @@ $section->addInput(new Form_Checkbox( $iflist = get_configured_interface_with_descr(false, true); -foreach ($iflist as $if => $ifdesc) - if (have_ruleint_access($if)) +foreach ($iflist as $if => $ifdesc) { + if (have_ruleint_access($if)) { $interfaces[$if] = $ifdesc; + } +} -if ($config['l2tp']['mode'] == "server") - if (have_ruleint_access("l2tp")) +if ($config['l2tp']['mode'] == "server") { + if (have_ruleint_access("l2tp")) { $interfaces['l2tp'] = "L2TP VPN"; + } +} -if (is_pppoe_server_enabled() && have_ruleint_access("pppoe")) +if (is_pppoe_server_enabled() && have_ruleint_access("pppoe")) { $interfaces['pppoe'] = "PPPoE Server"; +} /* add ipsec interfaces */ -if (ipsec_enabled() && have_ruleint_access("enc0")) +if (ipsec_enabled() && have_ruleint_access("enc0")) { $interfaces["enc0"] = "IPsec"; +} /* add openvpn/tun interfaces */ -if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) +if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) { $interfaces["openvpn"] = "OpenVPN"; +} $section->addInput(new Form_Select( 'interface', @@ -505,7 +522,7 @@ print($form); <script type="text/javascript"> //<![CDATA[ -events.push(function(){ +events.push(function() { // Disables the specified input element function disableInput(id, disable) { diff --git a/src/usr/local/www/firewall_nat_edit.php b/src/usr/local/www/firewall_nat_edit.php index 0c09a59..fa2842e 100644 --- a/src/usr/local/www/firewall_nat_edit.php +++ b/src/usr/local/www/firewall_nat_edit.php @@ -158,8 +158,9 @@ unset($input_errors); foreach ($_POST as $key => $value) { $temp = $value; $newpost = htmlentities($temp); - if ($newpost != $temp) + if ($newpost != $temp) { $input_errors[] = sprintf(gettext("Invalid characters detected %s. Please remove invalid characters and save again."), $temp); + } } if ($_POST) { @@ -310,7 +311,7 @@ if ($_POST) { /* if user enters an alias and selects "network" then disallow. */ if (($_POST['srctype'] == "network" && is_alias($_POST['src'])) || - ($_POST['dsttype'] == "network" && is_alias($_POST['dst']))) { + ($_POST['dsttype'] == "network" && is_alias($_POST['dst']))) { $input_errors[] = gettext("You must specify single host or alias for alias entries."); } @@ -373,7 +374,7 @@ if ($_POST) { } if (!((($_POST['dstbeginport'] < $begp) && ($_POST['dstendport'] < $begp)) || - (($_POST['dstbeginport'] > $endp) && ($_POST['dstendport'] > $endp)))) { + (($_POST['dstbeginport'] > $endp) && ($_POST['dstendport'] > $endp)))) { $input_errors[] = gettext("The destination port range overlaps with an existing entry."); break; } @@ -446,8 +447,8 @@ if ($_POST) { } // If creating a new rule, where we want to add the filter rule, associated or not else if (isset($_POST['filter-rule-association']) && - ($_POST['filter-rule-association'] == 'add-associated' || - $_POST['filter-rule-association'] == 'add-unassociated')) { + ($_POST['filter-rule-association'] == 'add-associated' || + $_POST['filter-rule-association'] == 'add-unassociated')) { $need_filter_rule = true; } @@ -537,11 +538,13 @@ function build_srctype_list() { $sel = is_specialnet($pconfig['src']); - if (have_ruleint_access("pppoe")) + if (have_ruleint_access("pppoe")) { $list['pppoe'] = 'PPPoE clients'; + } - if (have_ruleint_access("l2tp")) + if (have_ruleint_access("l2tp")) { $list['l2tp'] = 'L2TP clients'; + } foreach ($ifdisp as $ifent => $ifdesc) { if (have_ruleint_access($ifent)) { @@ -579,11 +582,13 @@ function build_dsttype_list() { $sel = is_specialnet($pconfig['dst']); $list = array('any' => 'Any', 'single' => 'Single host or alias', 'network' => 'Network', '(self)' => 'This Firewall (self)'); - if (have_ruleint_access("pppoe")) + if (have_ruleint_access("pppoe")) { $list['pppoe'] = 'PPPoE clients'; + } - if (have_ruleint_access("l2tp")) + if (have_ruleint_access("l2tp")) { $list['l2tp'] = 'L2TP clients'; + } foreach ($ifdisp as $if => $ifdesc) { if (have_ruleint_access($if)) { @@ -645,8 +650,9 @@ $closehead = false; $pgtitle = array(gettext("Firewall"), gettext("NAT"), gettext("Port Forward"), gettext("Edit")); include("head.inc"); -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} $form = new Form(new Form_Button( 'Submit', @@ -671,24 +677,31 @@ $section->addInput(new Form_Checkbox( $iflist = get_configured_interface_with_descr(false, true); -foreach ($iflist as $if => $ifdesc) - if (have_ruleint_access($if)) +foreach ($iflist as $if => $ifdesc) { + if (have_ruleint_access($if)) { $interfaces[$if] = $ifdesc; + } +} -if ($config['l2tp']['mode'] == "server") - if (have_ruleint_access("l2tp")) +if ($config['l2tp']['mode'] == "server") { + if (have_ruleint_access("l2tp")) { $interfaces['l2tp'] = "L2TP VPN"; + } +} -if (is_pppoe_server_enabled() && have_ruleint_access("pppoe")) +if (is_pppoe_server_enabled() && have_ruleint_access("pppoe")) { $interfaces['pppoe'] = "PPPoE Server"; +} /* add ipsec interfaces */ -if (ipsec_enabled() && have_ruleint_access("enc0")) +if (ipsec_enabled() && have_ruleint_access("enc0")) { $interfaces["enc0"] = "IPsec"; +} /* add openvpn/tun interfaces */ -if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) +if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) { $interfaces["openvpn"] = "OpenVPN"; +} $section->addInput(new Form_Select( 'interface', @@ -745,8 +758,9 @@ $section->add($group); $portlist = array("" => 'Other', 'any' => 'Any'); -foreach ($wkports as $wkport => $wkportdesc) +foreach ($wkports as $wkport => $wkportdesc) { $portlist[$wkport] = $wkportdesc; +} $group = new Form_Group('Source port range'); $group->addClass('srcportrange'); @@ -927,8 +941,9 @@ if (isset($id) && $a_nat[$id] && (!isset($_GET['dup']) || !is_numericint($_GET[' } } - if (isset($pconfig['associated-rule-id'])) + if (isset($pconfig['associated-rule-id'])) { $rulelist['new'] = 'Create new associated filter rule'; + } $section->addInput(new Form_Select( 'associated-rule-id', @@ -996,7 +1011,7 @@ print($form); <script type="text/javascript"> //<![CDATA[ -events.push(function(){ +events.push(function() { var portsenabled = 1; var dstenabled = 1; var showsource = 0; @@ -1050,7 +1065,7 @@ events.push(function(){ disableInput('srcbeginport', false); disableInput('srcendport', false); disableInput('localbeginport_cust', false); - if ( dstenabled ) { + if (dstenabled) { disableInput('dstbeginport', false); disableInput('dstendport', false); } @@ -1058,7 +1073,7 @@ events.push(function(){ } function nordr_change() { - if ( $('#nordr').prop('checked') ) { + if ($('#nordr').prop('checked')) { hideInput('localip', true); hideClass('lclportrange', true); hideInput('associated-rule-id', true); @@ -1192,8 +1207,8 @@ events.push(function(){ $('#dstendport').prop("selectedIndex", $('#dstbeginport').find(":selected").index()); } - function dst_change( iface, old_iface, old_dst ) { - if ( ( old_dst == "" ) || ( old_iface.concat("ip") == old_dst ) ) { + function dst_change(iface, old_iface, old_dst) { + if ((old_dst == "") || (old_iface.concat("ip") == old_dst)) { $('#dsttype').val(iface + "ip"); } } @@ -1256,7 +1271,7 @@ events.push(function(){ }); // ---------- On initial page load -------------------------------------------------------------------------------- - $("#srcadv").prop('type' ,'button'); + $("#srcadv").prop('type', 'button'); ext_change(); dst_change($('#interface').val(),'<?=htmlspecialchars($pconfig['interface'])?>','<?=htmlspecialchars($pconfig['dst'])?>'); iface_old = $('#interface').val(); diff --git a/src/usr/local/www/firewall_nat_npt.php b/src/usr/local/www/firewall_nat_npt.php index 6f6c426..54e64ff 100644 --- a/src/usr/local/www/firewall_nat_npt.php +++ b/src/usr/local/www/firewall_nat_npt.php @@ -72,8 +72,9 @@ require_once("functions.inc"); require_once("filter.inc"); require_once("shaper.inc"); -if (!is_array($config['nat']['npt'])) +if (!is_array($config['nat']['npt'])) { $config['nat']['npt'] = array(); +} $a_npt = &$config['nat']['npt']; @@ -106,11 +107,13 @@ if ($_GET['act'] == "del") { $pgtitle = array(gettext("Firewall"), gettext("NAT"), gettext("NPt")); include("head.inc"); -if ($savemsg) +if ($savemsg) { print_info_box($savemsg, 'success'); +} -if (is_subsystem_dirty('natconf')) +if (is_subsystem_dirty('natconf')) { print_info_box_np(gettext("The NAT configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect.")); +} $tab_array = array(); $tab_array[] = array(gettext("Port Forward"), false, "firewall_nat.php"); @@ -142,10 +145,11 @@ foreach ($a_npt as $natent): <td> <input type="hidden" name="rule[]" value="<?=$i?>" /> <?php - if (!$natent['interface']) + if (!$natent['interface']) { print(htmlspecialchars(convert_friendly_interface_to_friendly_descr("wan"))); - else + } else { print(htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface']))); + } ?> </td> <?php diff --git a/src/usr/local/www/firewall_nat_npt_edit.php b/src/usr/local/www/firewall_nat_npt_edit.php index a83f13d..9a783bb 100644 --- a/src/usr/local/www/firewall_nat_npt_edit.php +++ b/src/usr/local/www/firewall_nat_npt_edit.php @@ -92,8 +92,9 @@ foreach ($ifdisp as $kif => $kdescr) { $specialsrcdst[] = "{$kif}ip"; } -if (!is_array($config['nat']['npt'])) +if (!is_array($config['nat']['npt'])) { $config['nat']['npt'] = array(); +} $a_npt = &$config['nat']['npt']; @@ -180,25 +181,32 @@ function build_if_list() { global $ifdisp; foreach ($ifdisp as $if => $ifdesc) { - if (have_ruleint_access($if)) + if (have_ruleint_access($if)) { $interfaces[$if] = $ifdesc; + } } - if ($config['l2tp']['mode'] == "server") - if (have_ruleint_access("l2tp")) + if ($config['l2tp']['mode'] == "server") { + if (have_ruleint_access("l2tp")) { $interfaces['l2tp'] = "L2TP VPN"; + } + } - if ($config['pppoe']['mode'] == "server") - if (have_ruleint_access("pppoe")) + if ($config['pppoe']['mode'] == "server") { + if (have_ruleint_access("pppoe")) { $interfaces['pppoe'] = "PPPoE Server"; + } + } /* add ipsec interfaces */ - if (ipsec_enabled() && have_ruleint_access("enc0")) + if (ipsec_enabled() && have_ruleint_access("enc0")) { $interfaces["enc0"] = "IPsec"; + } /* add openvpn/tun interfaces */ - if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) + if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) { $interfaces["openvpn"] = "OpenVPN"; + } return($interfaces); } @@ -206,8 +214,9 @@ function build_if_list() { $pgtitle = array(gettext("Firewall"), gettext("NAT"), gettext("NPt"), gettext("Edit")); include("head.inc"); -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} $form = new Form(); diff --git a/src/usr/local/www/firewall_nat_out.php b/src/usr/local/www/firewall_nat_out.php index 0fa4f09..1679be2 100644 --- a/src/usr/local/www/firewall_nat_out.php +++ b/src/usr/local/www/firewall_nat_out.php @@ -87,7 +87,7 @@ $a_out = &$config['nat']['outbound']['rule']; // update rule order, POST[rule] is an array of ordered IDs // All rule are 'checked' before posting if (isset($_POST['order-store'])) { - if(is_array($_POST['rule']) && !empty($_POST['rule'])) { + if (is_array($_POST['rule']) && !empty($_POST['rule'])) { $a_out_new = array(); @@ -98,8 +98,9 @@ if (isset($_POST['order-store'])) { $a_out = $a_out_new; - if (write_config()) + if (write_config()) { mark_subsystem_dirty('natconf'); + } header("Location: firewall_nat_out.php"); exit; @@ -107,8 +108,9 @@ if (isset($_POST['order-store'])) { } } -if (!isset($config['nat']['outbound']['mode'])) +if (!isset($config['nat']['outbound']['mode'])) { $config['nat']['outbound']['mode'] = "automatic"; +} $mode = $config['nat']['outbound']['mode']; @@ -159,10 +161,10 @@ if ($_POST['save']) { $found = false; foreach ($a_out as $rule) { if ($rule['interface'] == $natent['interface'] && - $rule['source']['network'] == $natent['source']['network'] && - $rule['dstport'] == $natent['dstport'] && - $rule['target'] == $natent['target'] && - $rule['descr'] == $natent['descr']) { + $rule['source']['network'] == $natent['source']['network'] && + $rule['dstport'] == $natent['dstport'] && + $rule['target'] == $natent['target'] && + $rule['descr'] == $natent['descr']) { $found = true; break; } @@ -240,11 +242,13 @@ if (isset($_POST['del_x'])) { $pgtitle = array(gettext("Firewall"), gettext("NAT"), gettext("Outbound")); include("head.inc"); -if ($savemsg) +if ($savemsg) { print_info_box($savemsg, 'success'); +} -if (is_subsystem_dirty('natconf')) +if (is_subsystem_dirty('natconf')) { print_info_box_np(gettext("The NAT configuration has been changed.")."<br />".gettext("You must apply the changes in order for them to take effect.")); +} $tab_array = array(); $tab_array[] = array(gettext("Port Forward"), false, "firewall_nat.php"); @@ -325,8 +329,9 @@ print($form); foreach ($a_out as $natent): $iconfn = "pass"; $textss = $textse = ""; - if ($mode == "disabled" || $mode == "automatic" || isset($natent['disabled'])) + if ($mode == "disabled" || $mode == "automatic" || isset($natent['disabled'])) { $iconfn .= "_d"; + } $alias = rule_columns_with_alias( @@ -413,8 +418,9 @@ print($form); if (isset($natent['destination']['any'])) { echo "*"; } else { - if (isset($natent['destination']['not'])) + if (isset($natent['destination']['not'])) { echo "! "; + } if (isset($alias['dst'])): @@ -461,32 +467,35 @@ print($form); <td> <?php - if (isset($natent['nonat'])) + if (isset($natent['nonat'])) { echo '<I>NO NAT</I>'; - elseif (!$natent['target']) + } elseif (!$natent['target']) { echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface'])) . " address"; - elseif ($natent['target'] == "other-subnet") + } elseif ($natent['target'] == "other-subnet") { echo $natent['targetip'] . '/' . $natent['targetip_subnet']; - else + } else { echo $natent['target']; + } ?> </td> <td> <?php - if (!$natent['natport']) + if (!$natent['natport']) { echo "*"; - else + } else { echo $natent['natport']; + } ?> </td> <td> <?php - if (isset($natent['staticnatport'])) + if (isset($natent['staticnatport'])) { echo gettext("YES"); - else + } else { echo gettext("NO"); + } ?> </td> @@ -531,11 +540,13 @@ print($form); <?php if ($mode == "automatic" || $mode == "hybrid"): - if (empty($FilterIflist)) + if (empty($FilterIflist)) { filter_generate_optcfg_array(); + } - if (empty($GatewaysList)) + if (empty($GatewaysList)) { filter_generate_gateways(); + } $automatic_rules = filter_nat_rules_outbound_automatic(implode(" ", filter_nat_rules_automatic_tonathosts())); unset($FilterIflist, $GatewaysList); @@ -577,10 +588,11 @@ if ($mode == "automatic" || $mode == "hybrid"): <?php echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ; - if (!$natent['sourceport']) + if (!$natent['sourceport']) { echo "*"; - else + } else { echo $natent['sourceport']; + } ?> </td> <td> @@ -588,8 +600,9 @@ if ($mode == "automatic" || $mode == "hybrid"): if (isset($natent['destination']['any'])) { echo "*"; } else { - if (isset($natent['destination']['not'])) + if (isset($natent['destination']['not'])) { echo "! "; + } echo $natent['destination']['address']; } @@ -598,38 +611,42 @@ if ($mode == "automatic" || $mode == "hybrid"): <td> <?php echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ; - if (!$natent['dstport']) + if (!$natent['dstport']) { echo "*"; - else + } else { echo $natent['dstport']; + } ?> </td> <td> <?php - if (isset($natent['nonat'])) + if (isset($natent['nonat'])) { echo 'NO NAT'; - elseif (!$natent['target']) + } elseif (!$natent['target']) { echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface'])) . " address"; - elseif ($natent['target'] == "other-subnet") + } elseif ($natent['target'] == "other-subnet") { echo $natent['targetip'] . '/' . $natent['targetip_subnet']; - else + } else { echo $natent['target']; + } ?> </td> <td> <?php - if (!$natent['natport']) + if (!$natent['natport']) { echo "*"; - else + } else { echo $natent['natport']; + } ?> </td> <td> <?php - if (isset($natent['staticnatport'])) + if (isset($natent['staticnatport'])) { echo gettext("YES"); - else + } else { echo gettext("NO"); + } ?> </td> <td> diff --git a/src/usr/local/www/firewall_nat_out_edit.php b/src/usr/local/www/firewall_nat_out_edit.php index bf00c99..0f10140 100644 --- a/src/usr/local/www/firewall_nat_out_edit.php +++ b/src/usr/local/www/firewall_nat_out_edit.php @@ -71,8 +71,9 @@ require_once("ipsec.inc"); require_once("filter.inc"); require("shaper.inc"); -if (!is_array($config['nat']['outbound'])) +if (!is_array($config['nat']['outbound'])) { $config['nat']['outbound'] = array(); +} if (!is_array($config['nat']['outbound']['rule'])) { $config['nat']['outbound']['rule'] = array(); @@ -404,8 +405,9 @@ function build_target_list() { if (is_array($config['virtualip']['vip'])) { foreach ($config['virtualip']['vip'] as $sn) { - if (isset($sn['noexpand'])) + if (isset($sn['noexpand'])) { continue; + } if ($sn['mode'] == "proxyarp" && $sn['type'] == "network") { $start = ip2long32(gen_subnet($sn['subnet'], $sn['subnet_bits'])); @@ -425,8 +427,9 @@ function build_target_list() { } foreach ($a_aliases as $alias) { - if ($alias['type'] != "host") + if ($alias['type'] != "host") { continue; + } $list[$alias['name']] = 'Host Alias: ' . $alias['name'] . ' (' . $alias['descr'] . ')'; } @@ -436,8 +439,9 @@ function build_target_list() { return($list); } -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} $form = new Form(new Form_Button( 'Submit', @@ -462,24 +466,31 @@ $section->addInput(new Form_Checkbox( $iflist = get_configured_interface_with_descr(false, true); -foreach ($iflist as $if => $ifdesc) - if (have_ruleint_access($if)) +foreach ($iflist as $if => $ifdesc) { + if (have_ruleint_access($if)) { $interfaces[$if] = $ifdesc; + } +} -if ($config['l2tp']['mode'] == "server") - if (have_ruleint_access("l2tp")) +if ($config['l2tp']['mode'] == "server") { + if (have_ruleint_access("l2tp")) { $interfaces['l2tp'] = "L2TP VPN"; + } +} -if (is_pppoe_server_enabled() && have_ruleint_access("pppoe")) +if (is_pppoe_server_enabled() && have_ruleint_access("pppoe")) { $interfaces['pppoe'] = "PPPoE Server"; +} /* add ipsec interfaces */ -if (ipsec_enabled() && have_ruleint_access("enc0")) +if (ipsec_enabled() && have_ruleint_access("enc0")) { $interfaces["enc0"] = "IPsec"; +} /* add openvpn/tun interfaces */ -if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) +if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) { $interfaces["openvpn"] = "OpenVPN"; +} $section->addInput(new Form_Select( 'interface', @@ -683,7 +694,7 @@ print($form); <script type="text/javascript"> //<![CDATA[ -events.push(function(){ +events.push(function() { var portsenabled = 1; function staticportchange() { @@ -699,8 +710,7 @@ events.push(function(){ if ($('#source_type').find(":selected").val() == "network") { disableInput('source', false); disableInput('source_subnet', false); - } - else { + } else { $('#source').val(""); disableInput('source', true); $('#source_subnet').val("24"); @@ -712,8 +722,7 @@ events.push(function(){ if ($('#destination_type').find(":selected").val() == "network") { disableInput('destination', false); disableInput('destination_subnet', false); - } - else { + } else { $('#destination').val(""); disableInput('destination', true); $('#destination_subnet').val("24"); diff --git a/src/usr/local/www/firewall_rules.php b/src/usr/local/www/firewall_rules.php index 641f647..4f7469b 100644 --- a/src/usr/local/www/firewall_rules.php +++ b/src/usr/local/www/firewall_rules.php @@ -136,8 +136,9 @@ if (is_array($config['pppoes']['pppoe'])) { } /* add ipsec interfaces */ -if (ipsec_enabled() && have_ruleint_access("enc0")) +if (ipsec_enabled() && have_ruleint_access("enc0")) { $iflist["enc0"] = "IPsec"; +} /* add openvpn/tun interfaces */ if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) { @@ -201,7 +202,7 @@ if (isset($_POST['del_x'])) { $deleted = true; } - if($deleted) { + if ($deleted) { if (write_config()) { mark_subsystem_dirty('filter'); } @@ -224,14 +225,15 @@ if (isset($_POST['del_x'])) { header("Location: firewall_rules.php?if=" . htmlspecialchars($if)); exit; } -} else if($_POST['order-store']) { +} else if ($_POST['order-store']) { /* update rule order, POST[rule] is an array of ordered IDs */ if (is_array($_POST['rule']) && !empty($_POST['rule'])) { $a_filter_new = array(); // if a rule is not in POST[rule], it has been deleted by the user - foreach ($_POST['rule'] as $id) + foreach ($_POST['rule'] as $id) { $a_filter_new[] = $a_filter[$id]; + } $a_filter = $a_filter_new; if (write_config()) { @@ -245,11 +247,12 @@ if (isset($_POST['del_x'])) { $tab_array = array(array(gettext("Floating"), ("FloatingRules" == $if), "firewall_rules.php?if=FloatingRules")); -foreach ($iflist as $ifent => $ifname) +foreach ($iflist as $ifent => $ifname) { $tab_array[] = array($ifname, ($ifent == $if), "firewall_rules.php?if={$ifent}"); +} foreach ($tab_array as $dtab) { - if($dtab[1]) { + if ($dtab[1]) { $bctab = $dtab[0]; break; } @@ -261,13 +264,13 @@ $shortcut_section = "firewall"; include("head.inc"); $nrules = 0; -if ($savemsg) +if ($savemsg) { print_info_box($savemsg, 'success'); +} -if (is_subsystem_dirty('filter')) +if (is_subsystem_dirty('filter')) { print_info_box_np(gettext("The firewall rule configuration has been changed.") . "<br />" . gettext("You must apply the changes in order for them to take effect."), "apply", "", true); - - +} display_top_tabs($tab_array); @@ -297,8 +300,8 @@ display_top_tabs($tab_array); <?php // Show the anti-lockout rule if it's enabled, and we are on LAN with an if count > 1, or WAN with an if count of 1. if (!isset($config['system']['webgui']['noantilockout']) && - (((count($config['interfaces']) > 1) && ($if == 'lan')) || - ((count($config['interfaces']) == 1) && ($if == 'wan')))): + (((count($config['interfaces']) > 1) && ($if == 'lan')) || + ((count($config['interfaces']) == 1) && ($if == 'wan')))): $alports = implode('<br />', filter_get_antilockout_ports(true)); ?> <tr id="antilockout"> @@ -362,7 +365,7 @@ $nrules = 0; for ($i = 0; isset($a_filter[$i]); $i++): $filterent = $a_filter[$i]; - if ( ($filterent['interface'] != $if && !isset($filterent['floating'])) || (isset($filterent['floating']) && "FloatingRules" != $if) ) { + if (($filterent['interface'] != $if && !isset($filterent['floating'])) || (isset($filterent['floating']) && "FloatingRules" != $if)) { $display = 'style="display: none;"'; } else { $display = ""; @@ -393,11 +396,13 @@ for ($i = 0; isset($a_filter[$i]); $i++): <i class="fa fa-<?=$iconfn?>"></i> <?php $isadvset = firewall_check_for_advanced_options($filterent); - if ($isadvset) + if ($isadvset) { print '<i class="fa fa-cog" title="'. gettext("advanced setting") .': '. $isadvset .'"></i>'; + } - if (isset($filterent['log'])) + if (isset($filterent['log'])) { print '<i class="fa fa-tasks" title="'. gettext("traffic is logged") .'"></i>'; + } ?> </td> <?php @@ -418,8 +423,7 @@ for ($i = 0; isset($a_filter[$i]); $i++): $dayArray = array (gettext('Mon'), gettext('Tues'), gettext('Wed'), gettext('Thur'), gettext('Fri'), gettext('Sat'), gettext('Sun')); $monthArray = array (gettext('January'), gettext('February'), gettext('March'), gettext('April'), gettext('May'), gettext('June'), gettext('July'), gettext('August'), gettext('September'), gettext('October'), gettext('November'), gettext('December')); if ($config['schedules']['schedule'] != "" && is_array($config['schedules']['schedule'])) { - foreach ($a_schedules as $schedule) - { + foreach ($a_schedules as $schedule) { if ($schedule['name'] == $filterent['sched']) { $schedstatus = filter_get_time_based_rule_status($schedule); @@ -448,8 +452,7 @@ for ($i = 0; isset($a_filter[$i]); $i++): $month = $tempmontharray[$arraycounter]; $day = $tempdayarray[$arraycounter]; - if (!$firstDayFound) - { + if (!$firstDayFound) { $firstDay = $day; $firstmonth = $month; $firstDayFound = true; @@ -459,21 +462,21 @@ for ($i = 0; isset($a_filter[$i]); $i++): $nextDay = $tempdayarray[$arraycounter+1]; $currentDay++; if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])) { - if ($firstPrint) + if ($firstPrint) { $dayFriendly .= ", "; + } $currentDay--; - if ($currentDay != $firstDay) + if ($currentDay != $firstDay) { $dayFriendly .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ; - else + } else { $dayFriendly .= $monthArray[$month-1] . " " . $day; + } $firstDayFound = false; $firstPrint = true; } $arraycounter++; } - } - else - { + } else { $tempdayFriendly = $timerange['position']; $firstDayFound = false; $tempFriendlyDayArray = explode(",", $tempdayFriendly); @@ -483,8 +486,7 @@ for ($i = 0; isset($a_filter[$i]); $i++): $counter = 0; foreach ($tempFriendlyDayArray as $day) { if ($day != "") { - if (!$firstDayFound) - { + if (!$firstDayFound) { $firstDay = $tempFriendlyDayArray[$counter]; $firstDayFound = true; } @@ -493,13 +495,15 @@ for ($i = 0; isset($a_filter[$i]); $i++): $nextDay = $tempFriendlyDayArray[$counter+1]; $currentDay++; if ($currentDay != $nextDay) { - if ($firstprint) + if ($firstprint) { $dayFriendly .= ", "; + } $currentDay--; - if ($currentDay != $firstDay) + if ($currentDay != $firstDay) { $dayFriendly .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1]; - else + } else { $dayFriendly .= $dayArray[$firstDay-1]; + } $firstDayFound = false; $firstprint = true; } @@ -533,10 +537,11 @@ for ($i = 0; isset($a_filter[$i]); $i++): } $printicon = true; } else if ($filterent['sched']) { - if ($iconfn == "block" || $iconfn == "reject") + if ($iconfn == "block" || $iconfn == "reject") { $image = "times-circle"; - else + } else { $image = "times-circle"; + } $alttext = gettext("This rule is not currently active because its period has expired"); $printicon = true; } @@ -615,8 +620,9 @@ for ($i = 0; isset($a_filter[$i]); $i++): } else if (isset($filterent['defaultqueue'])) { $desc = $filterent['defaultqueue']; echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&action=show\">{$desc}</a>"; - } else + } else { echo gettext("none"); + } ?> </td> <td> @@ -700,18 +706,19 @@ for ($i = 0; isset($a_filter[$i]); $i++): </dl> <?php - if ("FloatingRules" != $if) + if ("FloatingRules" != $if) { print(gettext("Rules are evaluated on a first-match basis (i.e. " . "the action of the first rule to match a packet will be executed). ") . '<br />' . gettext("This means that if you use block rules, you'll have to pay attention " . "to the rule order. Everything that isn't explicitly passed is blocked " . "by default. ")); - else + } else { print(gettext("Floating rules are evaluated on a first-match basis (i.e. " . "the action of the first rule to match a packet will be executed) only " . "if the 'quick' option is checked on a rule. Otherwise they will only match if no " . "other rules match. Pay close attention to the rule order and options " . "chosen. If no rule here matches, the per-interface or default rules are used. ")); + } ?> </div> </div> diff --git a/src/usr/local/www/firewall_rules_edit.php b/src/usr/local/www/firewall_rules_edit.php index 7ac4494..32d6342 100644 --- a/src/usr/local/www/firewall_rules_edit.php +++ b/src/usr/local/www/firewall_rules_edit.php @@ -86,16 +86,16 @@ function is_aoadv_used($rule_config) { // Note that the user could set "tag" or "tagged" to the string "0", which is valid but empty(). // And if the user enters "0" in other fields, we want to present an error message, and keep the Advanced Options section open. if ((isset($rule_config['allowopts'])) || - (isset($rule_config['disablereplyto'])) || - ($rule_config['tag'] != "") || - ($rule_config['tagged'] != "") || - ($rule_config['max'] != "") || - ($rule_config['max-src-nodes'] != "") || - ($rule_config['max-src-conn'] != "") || - ($rule_config['max-src-states'] != "") || - ($rule_config['max-src-conn-rate'] != "") || - ($rule_config['max-src-conn-rates'] != "") || - ($rule_config['statetimeout'] != "")) { + (isset($rule_config['disablereplyto'])) || + ($rule_config['tag'] != "") || + ($rule_config['tagged'] != "") || + ($rule_config['max'] != "") || + ($rule_config['max-src-nodes'] != "") || + ($rule_config['max-src-conn'] != "") || + ($rule_config['max-src-states'] != "") || + ($rule_config['max-src-conn-rate'] != "") || + ($rule_config['max-src-conn-rates'] != "") || + ($rule_config['statetimeout'] != "")) { return true; } @@ -448,12 +448,12 @@ if ($_POST) { } if (isset($a_filter[$id]['associated-rule-id']) === false && - (!(is_specialnet($_POST['srctype']) || ($_POST['srctype'] == "single")))) { + (!(is_specialnet($_POST['srctype']) || ($_POST['srctype'] == "single")))) { $reqdfields[] = "srcmask"; $reqdfieldsn[] = "Source bit count"; } if (isset($a_filter[$id]['associated-rule-id']) === false && - (!(is_specialnet($_POST['dsttype']) || ($_POST['dsttype'] == "single")))) { + (!(is_specialnet($_POST['dsttype']) || ($_POST['dsttype'] == "single")))) { $reqdfields[] = "dstmask"; $reqdfieldsn[] = gettext("Destination bit count"); } @@ -491,7 +491,7 @@ if ($_POST) { $input_errors[] = 'The same port alias must be used in Source port range from: and to: fields'; } if ((is_alias($_POST['srcbeginport_cust']) && (!is_alias($_POST['srcendport_cust']) && $_POST['srcendport_cust'] != '')) || - ((!is_alias($_POST['srcbeginport_cust']) && $_POST['srcbeginport_cust'] != '') && is_alias($_POST['srcendport_cust']))) { + ((!is_alias($_POST['srcbeginport_cust']) && $_POST['srcbeginport_cust'] != '') && is_alias($_POST['srcendport_cust']))) { $input_errors[] = 'You cannot specify numbers and port aliases at the same time in Source port range from: and to: field'; } } @@ -505,7 +505,7 @@ if ($_POST) { $input_errors[] = 'The same port alias must be used in Destination port range from: and to: fields'; } if ((is_alias($_POST['dstbeginport_cust']) && (!is_alias($_POST['dstendport_cust']) && $_POST['dstendport_cust'] != '')) || - ((!is_alias($_POST['dstbeginport_cust']) && $_POST['dstbeginport_cust'] != '') && is_alias($_POST['dstendport_cust']))) { + ((!is_alias($_POST['dstbeginport_cust']) && $_POST['dstbeginport_cust'] != '') && is_alias($_POST['dstendport_cust']))) { $input_errors[] = 'You cannot specify numbers and port aliases at the same time in Destination port range from: and to: field'; } } @@ -692,7 +692,7 @@ if ($_POST) { } if ((($_POST['max-src-conn-rate'] <> "" and $_POST['max-src-conn-rates'] == "")) || - (($_POST['max-src-conn-rate'] == "" and $_POST['max-src-conn-rates'] <> ""))) { + (($_POST['max-src-conn-rate'] == "" and $_POST['max-src-conn-rates'] <> ""))) { $input_errors[] = gettext("Both maximum new connections per host and the interval (per second(s)) must be specified"); } @@ -1024,14 +1024,14 @@ $closehead = false; $page_filename = "firewall_rules_edit.php"; include("head.inc"); -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} $form = new Form; $section = new Form_Section('Edit Firewall rule'); -if (isset($id)) -{ +if (isset($id)) { $form->addGlobal(new Form_Input( 'id', 'ID', @@ -1040,8 +1040,7 @@ if (isset($id)) )); } -if (isset($a_filter[$id])) -{ +if (isset($a_filter[$id])) { $form->addGlobal(new Form_Input( 'tracker', 'Tracker', @@ -1073,8 +1072,9 @@ $values = array( 'reject' => 'Reject', ); -if ($if == "FloatingRules" || isset($pconfig['floating'])) +if ($if == "FloatingRules" || isset($pconfig['floating'])) { $values['match'] = 'Match'; +} $section->addInput(new Form_Select( 'type', @@ -1095,8 +1095,7 @@ $section->addInput(new Form_Checkbox( ))->setHelp('Set this option to disable this rule without removing it from the '. 'list.'); -if ($if == "FloatingRules" || isset($pconfig['floating'])) -{ +if ($if == "FloatingRules" || isset($pconfig['floating'])) { $section->addInput(new Form_Checkbox( 'quick', 'Quick', @@ -1108,13 +1107,12 @@ if ($if == "FloatingRules" || isset($pconfig['floating'])) $edit_disabled = isset($pconfig['associated-rule-id']); -if ($edit_disabled) -{ +if ($edit_disabled) { $extra = ''; - foreach ($config['nat']['rule'] as $index => $nat_rule) - { - if ($nat_rule['associated-rule-id'] === $pconfig['associated-rule-id']) + foreach ($config['nat']['rule'] as $index => $nat_rule) { + if ($nat_rule['associated-rule-id'] === $pconfig['associated-rule-id']) { $extra = '<br/><a href="firewall_nat_edit.php?id='. $index .'">'. gettext('View the NAT rule') .'</a>'; + } } $section->addInput(new Form_StaticText( @@ -1133,8 +1131,7 @@ if ($edit_disabled) $pconfig['associated-rule-id'] )); - if (!empty($pconfig['interface'])) - { + if (!empty($pconfig['interface'])) { $form->addGlobal(new Form_Input( 'interface', null, @@ -1269,17 +1266,20 @@ foreach (['src' => 'Source', 'dst' => 'Destination'] as $type => $name) { $ruleValues['(self)'] = "This firewall (self)"; } - if (isset($a_filter[$id]['floating']) || $if == "FloatingRules") + if (isset($a_filter[$id]['floating']) || $if == "FloatingRules") { $ruleValues['(self)'] = 'This Firewall (self)'; - if (have_ruleint_access("pppoe")) + } + if (have_ruleint_access("pppoe")) { $ruleValues['pppoe'] = 'PPPoE clients'; - if (have_ruleint_access("l2tp")) + } + if (have_ruleint_access("l2tp")) { $ruleValues['l2tp'] = 'L2TP clients'; + } - foreach ($ifdisp as $ifent => $ifdesc) - { - if (!have_ruleint_access($ifent)) + foreach ($ifdisp as $ifent => $ifdesc) { + if (!have_ruleint_access($ifent)) { continue; + } $ruleValues[$ifent] = $ifdesc.' net'; $ruleValues[$ifent.'ip'] = $ifdesc.' address'; @@ -1309,8 +1309,9 @@ foreach (['src' => 'Source', 'dst' => 'Destination'] as $type => $name) { $portValues = ['' => '(other)', 'any' => 'any']; - foreach ($wkports as $port => $portName) + foreach ($wkports as $port => $portName) { $portValues[$port] = $portName.' ('. $port .')'; + } $group = new Form_Group($name .' port range'); @@ -1387,7 +1388,7 @@ $btnadvanced = new Form_Button( $btnadvanced->removeClass('btn-primary')->addClass('btn-default'); -if(!$adv_open) { +if (!$adv_open) { $section->addInput(new Form_StaticText( null, $btnadvanced @@ -1543,10 +1544,10 @@ $section->addInput(new Form_Select( ))->setHelp('Choose 802.1p priority to apply'); $schedules = array(); -foreach ((array)$config['schedules']['schedule'] as $schedule) -{ - if ($schedule['name'] != "") +foreach ((array)$config['schedules']['schedule'] as $schedule) { + if ($schedule['name'] != "") { $schedules[] = $schedule['name']; + } } $section->addInput(new Form_Select( @@ -1557,24 +1558,27 @@ $section->addInput(new Form_Select( ))->setHelp('Leave as \'none\' to leave the rule enabled all the time'); $gateways = array("" => 'default'); -foreach (return_gateways_array() as $gwname => $gw) -{ - if (($pconfig['ipprotocol'] == "inet46")) +foreach (return_gateways_array() as $gwname => $gw) { + if (($pconfig['ipprotocol'] == "inet46")) { continue; - if (($pconfig['ipprotocol'] == "inet6") && !(($gw['ipprotocol'] == "inet6") || (is_ipaddrv6($gw['gateway'])))) + } + if (($pconfig['ipprotocol'] == "inet6") && !(($gw['ipprotocol'] == "inet6") || (is_ipaddrv6($gw['gateway'])))) { continue; - if (($pconfig['ipprotocol'] == "inet") && !(($gw['ipprotocol'] == "inet") || (is_ipaddrv4($gw['gateway'])))) + } + if (($pconfig['ipprotocol'] == "inet") && !(($gw['ipprotocol'] == "inet") || (is_ipaddrv4($gw['gateway'])))) { continue; - if ($gw == "") + } + if ($gw == "") { continue; + } $gateways[ $gwname ] = $gw['name'] . (empty($gw['gateway'])? '' : ' - '. $gateway_addr_str); } -foreach ((array)$a_gatewaygroups as $gwg_name => $gwg_data) -{ - if ((empty($pconfig['ipprotocol'])) || ($pconfig['ipprotocol'] == $gwg_data['ipprotocol'])) +foreach ((array)$a_gatewaygroups as $gwg_name => $gwg_data) { + if ((empty($pconfig['ipprotocol'])) || ($pconfig['ipprotocol'] == $gwg_data['ipprotocol'])) { $gateways[ $gwg_name ] = $gwg_name; + } } $section->addInput(new Form_Select( @@ -1612,14 +1616,16 @@ $section->add($group)->setHelp('Choose the Out queue/Virtual interface only if ' $group = new Form_Group('Ackqueue / Queue'); $list = array('' => 'none'); -if(!is_array($qlist)) +if (!is_array($qlist)) { $qlist = array(); +} foreach ($qlist as $q => $qkey) { - if (isset($ifdisp[$q])) + if (isset($ifdisp[$q])) { $list[$q] = $ifdisp[$q]; - else + } else { $list[$q] = $q; + } } $group->add(new Form_Select( @@ -1644,21 +1650,18 @@ $has_created_time = (isset($a_filter[$id]['created']) && is_array($a_filter[$id] $has_updated_time = (isset($a_filter[$id]['updated']) && is_array($a_filter[$id]['updated'])); -if ($has_created_time || $has_updated_time) -{ +if ($has_created_time || $has_updated_time) { $form->add($section); $section = new Form_Section('Rule Information'); - if ($has_created_time) - { + if ($has_created_time) { $section->addInput(new Form_StaticText( 'Created', date('n/j/y H:i:s', $a_filter[$id]['created']['time']) . gettext(' by ') .'<b>'. $a_filter[$id]['created']['username'] .'</b>' )); } - if ($has_updated_time) - { + if ($has_updated_time) { $section->addInput(new Form_StaticText( 'Updated', date('n/j/y H:i:s', $a_filter[$id]['updated']['time']) . gettext(' by ') .'<b>'. $a_filter[$id]['updated']['username'] .'</b>' @@ -1672,7 +1675,7 @@ echo $form; <script type="text/javascript"> //<![CDATA[ -events.push(function(){ +events.push(function() { var portsenabled = 1; var editenabled = 1; @@ -1683,8 +1686,9 @@ events.push(function(){ if (($('#srcbeginport').find(":selected").index() == 0) && portsenabled && editenabled) { disableInput('srcbeginport_cust', false); } else { - if (editenabled) + if (editenabled) { $('#srcbeginport_cust').val(""); + } disableInput('srcbeginport_cust', true); } @@ -1692,8 +1696,9 @@ events.push(function(){ if (($('#srcendport').find(":selected").index() == 0) && portsenabled && editenabled) { disableInput('srcendport_cust', false); } else { - if (editenabled) + if (editenabled) { $('#srcendport_cust').val(""); + } disableInput('srcendport_cust', true); } @@ -1701,8 +1706,9 @@ events.push(function(){ if (($('#dstbeginport').find(":selected").index() == 0) && portsenabled && editenabled) { disableInput('dstbeginport_cust', false); } else { - if (editenabled) + if (editenabled) { $('#dstbeginport_cust').val(""); + } disableInput('dstbeginport_cust', true); } @@ -1710,8 +1716,9 @@ events.push(function(){ if (($('#dstendport').find(":selected").index() == 0) && portsenabled && editenabled) { disableInput('dstendport_cust', false); } else { - if (editenabled) + if (editenabled) { $('#dstendport_cust').val(""); + } disableInput('dstendport_cust', true); } @@ -1900,15 +1907,17 @@ events.push(function(){ $('#toggle-advanced').click(function() { optionsvisible = 1; hideClass('advanced-options', false); - if ($('#tcpflags_any').prop('checked')) + if ($('#tcpflags_any').prop('checked')) { $('.table-flags').addClass('hidden'); + } }); $('#tcpflags_any').click(function () { - if (this.checked) + if (this.checked) { $('.table-flags').addClass('hidden'); - else + } else { $('.table-flags').removeClass('hidden'); + } }); // Change help text based on the selector value @@ -1919,14 +1928,15 @@ events.push(function(){ function setOptText(target, val) { var dispstr = '<span class="text-success">'; - if (val == 'keep state') + if (val == 'keep state') { dispstr += 'Keep: works with all IP protocols'; - else if (val == 'sloppy state') + } else if (val == 'sloppy state') { dispstr += 'Sloppy: works with all IP protocols'; - else if (val == 'synproxy state') + } else if (val == 'synproxy state') { dispstr += 'Synproxy: proxies incoming TCP connections to help protect servers from spoofed TCP SYN floods. This option includes the functionality of keep state and modulate state combined'; - else if (val == 'none') + } else if (val == 'none') { dispstr += 'None: Do not use state mechanisms to keep track. This is only useful if you\'re doing advanced queueing in certain situations'; + } dispstr += '</span>'; setHelpText(target, dispstr); diff --git a/src/usr/local/www/firewall_schedule.php b/src/usr/local/www/firewall_schedule.php index 39880ce..11bf2bb 100644 --- a/src/usr/local/www/firewall_schedule.php +++ b/src/usr/local/www/firewall_schedule.php @@ -113,8 +113,9 @@ if ($_GET['act'] == "del") { include("head.inc"); -if ($savemsg) +if ($savemsg) { print_info_box($savemsg, 'success'); +} ?> <div class="panel panel-default"> @@ -183,23 +184,24 @@ foreach ($a_schedules as $schedule): $currentDay++; if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])) { - if ($firstPrint) + if ($firstPrint) { $dayFriendly .= "<br />"; + } $currentDay--; - if ($currentDay != $firstDay) + if ($currentDay != $firstDay) { $dayFriendly .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ; - else + } else { $dayFriendly .= $monthArray[$month-1] . " " . $day; + } $firstDayFound = false; $firstPrint = true; } $arraycounter++; } - } - else { + } else { $tempdayFriendly = $timerange['position']; $firstDayFound = false; $tempFriendlyDayArray = explode(",", $tempdayFriendly); @@ -210,8 +212,7 @@ foreach ($a_schedules as $schedule): foreach ($tempFriendlyDayArray as $day) { if ($day != "") { - if (!$firstDayFound) - { + if (!$firstDayFound) { $firstDay = $tempFriendlyDayArray[$counter]; $firstDayFound = true; } @@ -222,15 +223,17 @@ foreach ($a_schedules as $schedule): $currentDay++; if ($currentDay != $nextDay) { - if ($firstprint) + if ($firstprint) { $dayFriendly .= "<br />"; + } $currentDay--; - if ($currentDay != $firstDay) + if ($currentDay != $firstDay) { $dayFriendly .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1]; - else + } else { $dayFriendly .= $dayArray[$firstDay-1]; + } $firstDayFound = false; $firstprint = true; diff --git a/src/usr/local/www/firewall_schedule_edit.php b/src/usr/local/www/firewall_schedule_edit.php index 0621591..14cab5a 100644 --- a/src/usr/local/www/firewall_schedule_edit.php +++ b/src/usr/local/www/firewall_schedule_edit.php @@ -73,8 +73,9 @@ function schedulecmp($a, $b) { function schedule_sort() { global $g, $config; - if (!is_array($config['schedules']['schedule'])) + if (!is_array($config['schedules']['schedule'])) { return; + } usort($config['schedules']['schedule'], "schedulecmp"); } @@ -91,16 +92,19 @@ $referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/firew $dayArray = array (gettext('Mon'), gettext('Tues'), gettext('Wed'), gettext('Thur'), gettext('Fri'), gettext('Sat'), gettext('Sun')); $monthArray = array (gettext('January'), gettext('February'), gettext('March'), gettext('April'), gettext('May'), gettext('June'), gettext('July'), gettext('August'), gettext('September'), gettext('October'), gettext('November'), gettext('December')); -if (!is_array($config['schedules']['schedule'])) +if (!is_array($config['schedules']['schedule'])) { $config['schedules']['schedule'] = array(); +} $a_schedules = &$config['schedules']['schedule']; -if (is_numericint($_GET['id'])) +if (is_numericint($_GET['id'])) { $id = $_GET['id']; +} -if (isset($_POST['id']) && is_numericint($_POST['id'])) +if (isset($_POST['id']) && is_numericint($_POST['id'])) { $id = $_POST['id']; +} if (isset($id) && $a_schedules[$id]) { $pconfig['name'] = $a_schedules[$id]['name']; @@ -112,27 +116,32 @@ if (isset($id) && $a_schedules[$id]) { if ($_POST) { - if (strtolower($_POST['name']) == "lan") + if (strtolower($_POST['name']) == "lan") { $input_errors[] = gettext("Schedule may not be named LAN."); + } - if (strtolower($_POST['name']) == "wan") + if (strtolower($_POST['name']) == "wan") { $input_errors[] = gettext("Schedule may not be named WAN."); + } - if (strtolower($_POST['name']) == "") + if (strtolower($_POST['name']) == "") { $input_errors[] = gettext("Schedule name cannot be blank."); + } $x = is_validaliasname($_POST['name']); if (!isset($x)) { $input_errors[] = gettext("Reserved word used for schedule name."); } else { - if (is_validaliasname($_POST['name']) == false) + if (is_validaliasname($_POST['name']) == false) { $input_errors[] = gettext("The schedule name may only consist of the characters a-z, A-Z, 0-9"); + } } /* check for name conflicts */ foreach ($a_schedules as $schedule) { - if (isset($id) && ($a_schedules[$id]) && ($a_schedules[$id] === $schedule)) + if (isset($id) && ($a_schedules[$id]) && ($a_schedules[$id] === $schedule)) { continue; + } if ($schedule['name'] == $_POST['name']) { $input_errors[] = gettext("A Schedule with this name already exists."); @@ -169,21 +178,16 @@ if ($_POST) { $timedescrstr = htmlentities($_POST['timedescr' . $x], ENT_QUOTES, 'UTF-8'); $dashpos = strpos($timestr, '-'); - if ($dashpos === false) - { + if ($dashpos === false) { $timeparts['position'] = $timestr; - } - else - { + } else { $tempindarray = array(); $monthstr = ""; $daystr = ""; $tempindarray = explode(",", $timestr); - foreach ($tempindarray as $currentselection) - { + foreach ($tempindarray as $currentselection) { if ($currentselection) { - if ($firstprint) - { + if ($firstprint) { $monthstr .= ","; $daystr .= ","; } @@ -206,39 +210,41 @@ if ($_POST) { } } - if (!$timerangeFound) + if (!$timerangeFound) { $input_errors[] = gettext("The schedule must have at least one time range configured."); + } if (!$input_errors) { - if (!empty($pconfig['schedlabel'])) + if (!empty($pconfig['schedlabel'])) { $schedule['schedlabel'] = $pconfig['schedlabel']; - else + } else { $schedule['schedlabel'] = uniqid(); + } if (isset($id) && $a_schedules[$id]) { $a_schedules[$id] = $schedule; - } - else { + } else { $a_schedules[] = $schedule; } schedule_sort(); - if (write_config()) + if (write_config()) { filter_configure(); + } header("Location: firewall_schedule.php"); exit; } //we received input errors, copy data to prevent retype - else - { - if (!$_POST['schedule0']) + else { + if (!$_POST['schedule0']) { $getSchedule = false; - else + } else { $getSchedule = true; + } $pconfig['name'] = $schedule['name']; $pconfig['descr'] = $schedule['descr']; @@ -260,8 +266,9 @@ function build_date_table() { for ($k = 0; $k < 12; $k++) { $firstdayofmonth = date("w", mktime(0, 0, 0, date($monthcounter), 1, date($yearcounter))); - if ($firstdayofmonth == 0) + if ($firstdayofmonth == 0) { $firstdayofmonth = 7; + } $daycounter = 1; //number of day in month @@ -273,10 +280,11 @@ function build_date_table() { $mostr = '<div id="' . date("F_y", mktime(0, 0, 0, date($monthcounter), 1, date($yearcounter))) ; $mostr .= '" style="position:relative; display:'; - if ($firstmonth) + if ($firstmonth) { $mostr .= "block"; - else + } else { $mostr .= "none"; + } $mostr .= '" class="col-md-6">'; @@ -301,8 +309,7 @@ function build_date_table() { while ($daycounter<=$numberofdays) { $weekcounter = date("W", mktime(0, 0, 0, date($monthcounter), date($daycounter), date($yearcounter))); $weekcounter = ltrim($weekcounter, "0"); - if ($positioncounter == 1) - { + if ($positioncounter == 1) { $mostr .= "<tr>"; } @@ -313,22 +320,18 @@ function build_date_table() { $daycounter++; $firstdayprinted = TRUE; $mostr .= "</td>"; - } - elseif ($firstdayprinted == TRUE && $daycounter <= $numberofdays) { + } elseif ($firstdayprinted == TRUE && $daycounter <= $numberofdays) { $mostr .= '<td class="text-center" style="cursor: pointer;" id="w' . $weekcounter . 'p' . $positioncounter . '" onclick="daytoggle(\'w' . $weekcounter . 'p' . $positioncounter . '-m' . $monthcounter . 'd' . $daycounter . '\');">' . $daycounter . "\r\n"; $daycounter++; $mostr .= "</td>"; - } - else - { + } else { $mostr .= '<td class="text-center"></td>'; } if ($positioncounter == 7 || $daycounter > $numberofdays) { $positioncounter = 1; $mostr .= "</tr>"; - } - else { + } else { $positioncounter++; } @@ -338,13 +341,10 @@ function build_date_table() { $mostr .= gettext('Click individual date to select that date only. Click the appropriate weekday Header to select all occurrences of that weekday. '); $mostr .= '</div>'; - if ($monthcounter == 12) - { + if ($monthcounter == 12) { $monthcounter = 1; $yearcounter++; - } - else - { + } else { $monthcounter++; } @@ -368,9 +368,7 @@ function build_month_list() { if ($monthcounter == 12) { $monthcounter = 1; $yearcounter++; - } - else - { + } else { $monthcounter++; } } @@ -378,8 +376,9 @@ function build_month_list() { return($list); } -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} $form = new Form(); @@ -395,8 +394,9 @@ $input = new Form_Input( $input->setHelp((is_schedule_inuse($pconfig['name']) != true) ? 'The name of the alias may only consist of the characters a-z, A-Z and 0-9': 'This schedule is in use so the name may not be modified!'); -if (is_schedule_inuse($pconfig['name']) == true) +if (is_schedule_inuse($pconfig['name']) == true) { $input->setReadonly(); +} $section->addInput($input); @@ -529,16 +529,14 @@ if ($getSchedule) { $weeknumber = date("W", mktime(0, 0, 0, date($month), date($day), date("Y"))); $weeknumber = ltrim($weeknumber, "0"); - if ($firstPrint) - { + if ($firstPrint) { $tempID .= ","; } $tempID .= "w" . $weeknumber . "p" . $daypos . "-m" . $month . "d" . $day; $firstPrint = true; - if (!$firstDayFound) - { + if (!$firstDayFound) { $firstDay = $day; $firstmonth = $month; $firstDayFound = true; @@ -548,15 +546,17 @@ if ($getSchedule) { $nextDay = $tempdayarray[$arraycounter+1]; $currentDay++; if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])) { - if ($firstprint2) + if ($firstprint2) { $tempFriendlyTime .= ", "; + } $currentDay--; - if ($currentDay != $firstDay) + if ($currentDay != $firstDay) { $tempFriendlyTime .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ; - else + } else { $tempFriendlyTime .= $monthArray[$month-1] . " " . $day; + } $firstDayFound = false; $firstprint2 = true; @@ -564,9 +564,7 @@ if ($getSchedule) { $arraycounter++; } - } - else - { + } else { $dayFriendly = $timerange['position']; $tempID = $dayFriendly; } @@ -586,8 +584,7 @@ if ($getSchedule) { if (!$timerange['month']) { foreach ($tempFriendlyDayArray as $day) { if ($day != "") { - if (!$firstDayFound) - { + if (!$firstDayFound) { $firstDay = $tempFriendlyDayArray[$i]; $firstDayFound = true; } @@ -598,15 +595,17 @@ if ($getSchedule) { $currentDay++; if ($currentDay != $nextDay) { - if ($firstprint) + if ($firstprint) { $tempFriendlyTime .= ", "; + } $currentDay--; - if ($currentDay != $firstDay) + if ($currentDay != $firstDay) { $tempFriendlyTime .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1]; - else + } else { $tempFriendlyTime .= $dayArray[$firstDay-1]; + } $firstDayFound = false; $firstprint = true; @@ -679,7 +678,7 @@ print($form); <script type="text/javascript"> //<![CDATA[ -events.push(function(){ +events.push(function() { //Update the calendar when a new month is selected $('#monthsel').on('change', function() { @@ -721,8 +720,9 @@ var schCounter = 0; function rgb2hex(rgb) { var parts = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); - if (parts == null) + if (parts == null) { return; + } function hex(x) { return ("0" + parseInt(x).toString(16)).slice(-2); @@ -731,7 +731,7 @@ function rgb2hex(rgb) { return ("#" + hex(parts[1]) + hex(parts[2]) + hex(parts[3])).toUpperCase(); } -function repeatExistingDays(){ +function repeatExistingDays() { var tempstr, tempstrdaypos, week, daypos, dayposdone = ""; var dayarray = daysSelected.split(","); @@ -749,17 +749,18 @@ function repeatExistingDays(){ tempstr = 'w' + week + 'p' + daypos; daycell = eval('document.getElementById(tempstr)'); if (daydone == "-1") { - if (rgb2hex(daycell.style.backgroundColor) == "#F08080") // lightcoral + if (rgb2hex(daycell.style.backgroundColor) == "#F08080") { // lightcoral daytogglerepeating(week,daypos,true); - else + } else { daytogglerepeating(week,daypos,false); + } dayposdone += daypos + ","; } } } -function daytogglerepeating(week,daypos,bExists){ +function daytogglerepeating(week, daypos, bExists) { var tempstr, daycell, dayoriginal = ""; for (j=1; j<=53; j++) { @@ -773,9 +774,7 @@ function daytogglerepeating(week,daypos,bExists){ if (daycell != null) { if (bExists) { daycell.style.backgroundColor = "#FFFFFF"; // white - } - else - { + } else { daycell.style.backgroundColor = "#F08080"; // lightcoral } @@ -803,9 +802,7 @@ function daytoggle(id) { idmod = id; runrepeat = true; var daypos = id.substr(tempstrdaypos+1); - } - else - { + } else { idmod = id.substring(0, iddashpos); var daypos = id.substring(tempstrdaypos+1, iddashpos); } @@ -820,28 +817,19 @@ function daytoggle(id) { daycell.style.backgroundColor = "#FFFFFF"; // white str = id + ","; daysSelected = daysSelected.replace(str, ""); - } - else if (rgb2hex(daycell.style.backgroundColor) == "#F08080") // lightcoral - { + } else if (rgb2hex(daycell.style.backgroundColor) == "#F08080") { // lightcoral daytogglerepeating(week,daypos,true); - } - else //color is white cell - { - if (!runrepeat) - { + } else { //color is white cell + if (!runrepeat) { daycell.style.backgroundColor = "#FF0000"; // red - } - else - { + } else { daycell.style.backgroundColor = "#F08080"; // lightcoral daytogglerepeating(week,daypos,false); } daysSelected += id + ","; } bFoundValid = true; - } - else - { + } else { //we found an invalid cell when column was clicked, move up to the next week week++; tempstr = "w" + week + "p" + daypos; @@ -858,21 +846,19 @@ function update_month() { option = document.forms[0].monthsel.options[i].text; document.popupMonthLayer = eval('document.getElementById (option)'); - if (selected == option) + if (selected == option) { document.popupMonthLayer.style.display="block"; - else + } else { document.popupMonthLayer.style.display="none"; + } } } function checkForRanges() { - if (daysSelected != "") - { + if (daysSelected != "") { alert("You have not saved the specified time range. Please click 'Add Time' button to save the time range."); return false; - } - else - { + } else { return true; } } @@ -888,14 +874,11 @@ function processEntries() { stoptimemin = parseInt(document.getElementById("stoptimemin").value); //do time checks - if (starttimehour > stoptimehour) - { + if (starttimehour > stoptimehour) { errors = "Error: Start Hour cannot be greater than Stop Hour."; passedValidiation = false; - } - else if (starttimehour == stoptimehour) - { + } else if (starttimehour == stoptimehour) { if (starttimemin > stoptimemin) { errors = "Error: Start Minute cannot be greater than Stop Minute."; passedValidiation = false; @@ -904,10 +887,10 @@ function processEntries() { if (passedValidiation) { addTimeRange(); - } - else { - if (errors != "") + } else { + if (errors != "") { alert(errors); + } } } @@ -931,8 +914,7 @@ function addTimeRange() { for (u = 0; u < 99; u++) { findCurrentCounter = document.getElementById("schedule" + u); - if (!findCurrentCounter) - { + if (!findCurrentCounter) { schCounter = u; break; } @@ -941,18 +923,15 @@ function addTimeRange() { if (daysSelected != "") { //get days selected - for (i = 0; i < tempdayarray.length; i++) - { + for (i = 0; i < tempdayarray.length; i++) { tempstr = tempdayarray[i]; - if (tempstr != "") - { + if (tempstr != "") { tempstrdaypos = tempstr.search("p"); week = tempstr.substring(1, tempstrdaypos); week = parseInt(week); dashpos = tempstr.search("-"); - if (dashpos != "-1") - { + if (dashpos != "-1") { var nonrepeatingfound = true; daypos = tempstr.substring(tempstrdaypos+1, dashpos); daypos = parseInt(daypos); @@ -965,9 +944,7 @@ function addTimeRange() { monthstr += month + ","; daystr += day + ","; nrtempID += tempstr + ","; - } - else - { + } else { var repeatingfound = true; daypos = tempstr.substr(tempstrdaypos+1); daypos = parseInt(daypos); @@ -988,8 +965,7 @@ function addTimeRange() { for (k = 0; k < tempFriendlyMonthArray.length; k++) { tempstr = tempFriendlyMonthArray[k]; if (tempstr != "") { - if (!firstDayFound) - { + if (!firstDayFound) { firstDay = tempFriendlyDayArray[k]; firstDay = parseInt(firstDay); firstMonth = tempFriendlyMonthArray[k]; @@ -1006,15 +982,17 @@ function addTimeRange() { currentDay++; if ((currentDay != nextDay) || (tempFriendlyMonthArray[k] != tempFriendlyMonthArray[k+1])) { - if (firstprint) + if (firstprint) { nrtempFriendlyTime += ", "; + } currentDay--; - if (currentDay != firstDay) + if (currentDay != firstDay) { nrtempFriendlyTime += month_array[firstMonth-1] + " " + firstDay + "-" + currentDay; - else + } else { nrtempFriendlyTime += month_array[firstMonth-1] + " " + currentDay; + } firstDayFound = false; firstprint = true; @@ -1033,8 +1011,7 @@ function addTimeRange() { for (k = 0; k < tempFriendlyDayArray.length; k++) { tempstr = tempFriendlyDayArray[k]; if (tempstr != "") { - if (!firstDayFound) - { + if (!firstDayFound) { firstDay = tempFriendlyDayArray[k]; firstDay = parseInt(firstDay); firstDayFound = true; @@ -1048,15 +1025,17 @@ function addTimeRange() { currentDay++; if (currentDay != nextDay) { - if (firstprint) + if (firstprint) { rtempFriendlyTime += ", "; + } currentDay--; - if (currentDay != firstDay) + if (currentDay != firstDay) { rtempFriendlyTime += day_array[firstDay-1] + " - " + day_array[currentDay-1]; - else + } else { rtempFriendlyTime += day_array[firstDay-1]; + } firstDayFound = false; firstprint = true; @@ -1072,15 +1051,14 @@ function addTimeRange() { //clear tempID rtempID = ""; - for (t = 0; t < tempsortArray.length; t++) - { + for (t = 0; t < tempsortArray.length; t++) { if (tempsortArray[t] != "") { if (!isFirstdone) { rtempID += tempsortArray[t]; isFirstdone = true; - } - else + } else { rtempID += "," + tempsortArray[t]; + } } } @@ -1116,9 +1094,7 @@ function addTimeRange() { insertElements(rtempFriendlyTime, starttimehour, starttimemin, stoptimehour, stoptimemin, tempdescr, rtempTime, rtempID); } - } - else - { + } else { //no days were selected, alert user alert ("You must select at least 1 day before adding time"); } @@ -1129,8 +1105,7 @@ function clearCalendar() { //clear days selected daysSelected = ""; //loop through all 52 weeks - for (j = 1; j <= 53; j++) - { + for (j = 1; j <= 53; j++) { //loop through all 7 days for (k = 1; k < 8; k++) { tempstr = 'w' + j + 'p' + k; @@ -1164,7 +1139,7 @@ function insertElements(tempFriendlyTime, starttimehour, starttimemin, stoptimeh rows_displayed = counter; } - // Template for the schedule deifinition. '@' will be replaced with the row number using .replace() + // Template for the schedule definition. '@' will be replaced with the row number using .replace() rowhtml = '<div class="form-group schedulegrp' + counter + '">' + '<label for="tempFriendlyTime" class="col-sm-2 control-label"></label>' + diff --git a/src/usr/local/www/firewall_shaper_queues.php b/src/usr/local/www/firewall_shaper_queues.php index 2794a07..0e67215 100644 --- a/src/usr/local/www/firewall_shaper_queues.php +++ b/src/usr/local/www/firewall_shaper_queues.php @@ -160,8 +160,9 @@ if ($_GET) { $config['shaper']['queue'][] = $newroot; } - if (write_config()) + if (write_config()) { mark_subsystem_dirty('shaper'); + } break; } @@ -177,17 +178,19 @@ if ($_GET) { if ($altq) { $qtmp =& $altq->find_queue("", $qname); - if ($qtmp) + if ($qtmp) { $output .= $qtmp->build_shortform(); - else + } else { $output .= build_iface_without_this_queue($if, $qname); - + } } else { - if (!is_altq_capable($ifdesc['if'])) + if (!is_altq_capable($ifdesc['if'])) { continue; + } - if (!isset($ifdesc['enable']) && $if != "lan" && $if != "wan") + if (!isset($ifdesc['enable']) && $if != "lan" && $if != "wan") { continue; + } $output .= build_iface_without_this_queue($if, $qname); } @@ -228,14 +231,17 @@ include("head.inc"); <script type="text/javascript" src="./tree/tree.js"></script> <?php -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} -if ($savemsg) +if ($savemsg) { print_info_box($savemsg); +} -if (is_subsystem_dirty('shaper')) +if (is_subsystem_dirty('shaper')) { print_info_box_np(gettext("The traffic shaper configuration has been changed. You must apply the changes in order for them to take effect.")); +} $tab_array = array(); $tab_array[] = array(gettext("By Interface"), false, "firewall_shaper.php"); diff --git a/src/usr/local/www/firewall_shaper_vinterface.php b/src/usr/local/www/firewall_shaper_vinterface.php index 18ad00a..753f0e5 100644 --- a/src/usr/local/www/firewall_shaper_vinterface.php +++ b/src/usr/local/www/firewall_shaper_vinterface.php @@ -198,8 +198,9 @@ if ($_GET) { } else if ($addnewpipe) { $q = new dnpipe_class(); $q->SetQname($pipe); - } else + } else { $input_errors[] = gettext("Could not create new queue/discipline!"); + } if ($q) { $sform = $q->build_form(); @@ -220,8 +221,9 @@ if ($_GET) { $queue->SetEnabled("on"); $sform = $queue->build_form(); $queue->wconfig(); - if (write_config()) + if (write_config()) { mark_subsystem_dirty('shaper'); + } } else { $input_errors[] = gettext("Queue not found!"); } @@ -231,8 +233,9 @@ if ($_GET) { $queue->SetEnabled(""); $sform = $queue->build_form(); $queue->wconfig(); - if (write_config()) + if (write_config()) { mark_subsystem_dirty('shaper'); + } } else { $input_errors[] = gettext("Queue not found!"); } @@ -351,8 +354,9 @@ if ($queue) { } if ($queue->CanHaveChildren()) { $can_add = true; - } else + } else { $can_add = false; + } } $tree = "<ul class=\"tree\" >"; @@ -469,7 +473,7 @@ if ($dfltmsg) { <script type="text/javascript"> //<![CDATA[ -events.push(function(){ +events.push(function() { // Disables the specified input element function disableInput(id, disable) { diff --git a/src/usr/local/www/firewall_shaper_wizards.php b/src/usr/local/www/firewall_shaper_wizards.php index 4bfb9a8..4246201 100644 --- a/src/usr/local/www/firewall_shaper_wizards.php +++ b/src/usr/local/www/firewall_shaper_wizards.php @@ -107,8 +107,9 @@ $wizards = array( $closehead = false; include("head.inc"); -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} $tab_array = array(); $tab_array[] = array(gettext("By Interface"), false, "firewall_shaper.php"); @@ -117,11 +118,13 @@ $tab_array[] = array(gettext("Limiter"), false, "firewall_shaper_vinterface.php" $tab_array[] = array(gettext("Wizards"), true, "firewall_shaper_wizards.php"); display_top_tabs($tab_array); -if ($savemsg) +if ($savemsg) { print_info_box($savemsg, 'success'); +} -if (is_subsystem_dirty('shaper')) +if (is_subsystem_dirty('shaper')) { print_info_box_np(gettext("The traffic shaper configuration has been changed.") . "<br />" . gettext("You must apply the changes in order for them to take effect.")); +} ?> <div class="panel panel-default"> diff --git a/src/usr/local/www/firewall_virtual_ip.php b/src/usr/local/www/firewall_virtual_ip.php index b6b0e46..45fb083 100644 --- a/src/usr/local/www/firewall_virtual_ip.php +++ b/src/usr/local/www/firewall_virtual_ip.php @@ -275,12 +275,13 @@ $types = array('proxyarp' => 'Proxy ARP', $pgtitle = array(gettext("Firewall"), gettext("Virtual IP Addresses")); include("head.inc"); -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); -else if ($savemsg) +} else if ($savemsg) { print_info_box($savemsg, 'success'); -else if (is_subsystem_dirty('vip')) +} else if (is_subsystem_dirty('vip')) { print_info_box_np(gettext("The VIP configuration has been changed.")."<br />".gettext("You must apply the changes in order for them to take effect.")); +} /* active tabs $tab_array = array(); @@ -307,8 +308,9 @@ display_top_tabs($tab_array); $interfaces = get_configured_interface_with_descr(false, true); $carplist = get_configured_carp_interface_list(); -foreach ($carplist as $cif => $carpip) +foreach ($carplist as $cif => $carpip) { $interfaces[$cif] = $carpip." (".get_vip_descr($carpip).")"; +} $interfaces['lo0'] = "Localhost"; @@ -320,15 +322,19 @@ foreach ($a_vip as $vipent): <tr> <td> <?php - if (($vipent['type'] == "single") || ($vipent['type'] == "network")) - if ($vipent['subnet_bits']) + if (($vipent['type'] == "single") || ($vipent['type'] == "network")) { + if ($vipent['subnet_bits']) { print("{$vipent['subnet']}/{$vipent['subnet_bits']}"); + } + } - if ($vipent['type'] == "range") - print("{$vipent['range']['from']}-{$vipent['range']['to']}"); + if ($vipent['type'] == "range") { + print("{$vipent['range']['from']}-{$vipent['range']['to']}"); + } - if ($vipent['mode'] == "carp") - print(" (vhid: {$vipent['vhid']})"); + if ($vipent['mode'] == "carp") { + print(" (vhid: {$vipent['vhid']})"); + } ?> </td> <td> diff --git a/src/usr/local/www/firewall_virtual_ip_edit.php b/src/usr/local/www/firewall_virtual_ip_edit.php index ebdccc4..9d30ce7 100644 --- a/src/usr/local/www/firewall_virtual_ip_edit.php +++ b/src/usr/local/www/firewall_virtual_ip_edit.php @@ -202,19 +202,22 @@ if ($_POST) { case 'carp': /* verify against reusage of vhids */ $idtracker = 0; - foreach($config['virtualip']['vip'] as $vip) { - if($vip['vhid'] == $_POST['vhid'] && $vip['interface'] == $_POST['interface'] && $idtracker != $id) - $input_errors[] = sprintf(gettext("VHID %s is already in use on interface %s. Pick a unique number on this interface."),$_POST['vhid'], convert_friendly_interface_to_friendly_descr($_POST['interface'])); + foreach ($config['virtualip']['vip'] as $vip) { + if ($vip['vhid'] == $_POST['vhid'] && $vip['interface'] == $_POST['interface'] && $idtracker != $id) { + $input_errors[] = sprintf(gettext("VHID %s is already in use on interface %s. Pick a unique number on this interface."), $_POST['vhid'], convert_friendly_interface_to_friendly_descr($_POST['interface'])); + } $idtracker++; } - if (empty($_POST['password'])) + if (empty($_POST['password'])) { $input_errors[] = gettext("You must specify a CARP password that is shared between the two VHID members."); + } - if ($_POST['interface'] == 'lo0') + if ($_POST['interface'] == 'lo0') { $input_errors[] = gettext("For this type of vip localhost is not allowed."); - else if (strpos($_POST['interface'], '_vip')) + } else if (strpos($_POST['interface'], '_vip')) { $input_errors[] = gettext("A CARP parent interface can only be used with IP Alias type Virtual IPs."); + } break; case 'ipalias': @@ -230,9 +233,9 @@ if ($_POST) { } if (isset($parent_ip) && !ip_in_subnet($_POST['subnet'], "{$subnet}/{$parent_sn}") && - !ip_in_interface_alias_subnet(link_carp_interface_to_parent($_POST['interface']), $_POST['subnet'])) { + !ip_in_interface_alias_subnet(link_carp_interface_to_parent($_POST['interface']), $_POST['subnet'])) { $cannot_find = $_POST['subnet'] . "/" . $_POST['subnet_bits'] ; - $input_errors[] = sprintf(gettext("Sorry, we could not locate an interface with a matching subnet for %s. Please add an IP alias in this subnet on this interface."),$cannot_find); + $input_errors[] = sprintf(gettext("Sorry, we could not locate an interface with a matching subnet for %s. Please add an IP alias in this subnet on this interface."), $cannot_find); } unset($parent_ip, $parent_sn, $subnet); @@ -240,10 +243,11 @@ if ($_POST) { break; default: - if ($_POST['interface'] == 'lo0') + if ($_POST['interface'] == 'lo0') { $input_errors[] = gettext("For this type of vip localhost is not allowed."); - else if (strpos($_POST['interface'], '_vip')) + } else if (strpos($_POST['interface'], '_vip')) { $input_errors[] = gettext("A CARP parent interface can only be used with IP Alias type Virtual IPs."); + } break; } @@ -327,7 +331,7 @@ if ($_POST) { $ipaliashelp = gettext('The mask must be the network\'s subnet mask. It does not specify a CIDR range.'); $proxyarphelp = gettext('Enter a CIDR block of proxy ARP addresses.'); -$pgtitle = array(gettext("Firewall"),gettext("Virtual IP Address"),gettext("Edit")); +$pgtitle = array(gettext("Firewall"), gettext("Virtual IP Address"), gettext("Edit")); include("head.inc"); function build_if_list() { @@ -336,16 +340,18 @@ function build_if_list() { $interfaces = get_configured_interface_with_descr(false, true); $carplist = get_configured_carp_interface_list(); - foreach ($carplist as $cif => $carpip) + foreach ($carplist as $cif => $carpip) { $interfaces[$cif] = $carpip . ' (' . get_vip_descr($carpip) . ')'; + } $interfaces['lo0'] = 'Localhost'; return($interfaces); } -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} $form = new Form(); @@ -485,14 +491,15 @@ print($form); <script type="text/javascript"> //<![CDATA[ -events.push(function(){ +events.push(function() { // Hides the <div> in which the specified checkbox lives so that the checkbox, its label and help text are hidden function hideCheckbox(id, hide) { - if(hide) + if (hide) { $('#' + id).parent().parent().parent('div').addClass('hidden'); - else + } else { $('#' + id).parent().parent().parent('div').removeClass('hidden'); + } } // Disables the specified input element @@ -512,13 +519,12 @@ events.push(function(){ disableInput('password', true); hideCheckbox('noexpand', true); - if(mode == 'ipalias') { + if (mode == 'ipalias') { $('#address_note').html("<?=$ipaliashelp?>"); $('#type').val('single'); disableInput('subnet_bits', false); - } - else if(mode == 'carp') { + } else if (mode == 'carp') { $('#address_note').html("<?=$ipaliashelp?>"); disableInput('vhid', false); disableInput('advbase', false); @@ -526,13 +532,11 @@ events.push(function(){ disableInput('password', false); disableInput('subnet_bits', false); $('#type').val('single'); - } - else if(mode == 'proxyarp') { + } else if (mode == 'proxyarp') { $('#address_note').html("<?=$proxyarphelp?>"); disableInput('type', false); disableInput('subnet_bits', ($('#type').val() == 'single')); - } - else { + } else { $('#address_note').html(''); disableInput('type', false); disableInput('subnet_bits', ($('#type').val() == 'single')); |