summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/inc/util.inc13
-rwxr-xr-xusr/local/www/firewall_aliases_edit.php34
-rwxr-xr-xusr/local/www/firewall_nat_1to1_edit.php28
-rwxr-xr-xusr/local/www/firewall_nat_edit.php34
-rwxr-xr-xusr/local/www/firewall_nat_out_edit.php47
-rwxr-xr-xusr/local/www/firewall_rules_edit.php35
-rwxr-xr-xusr/local/www/system_routes_edit.php21
7 files changed, 45 insertions, 167 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index 5539400..a052fbc 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -1773,4 +1773,17 @@ function get_alias_list($type = null) {
return $result;
}
+/* returns an array consisting of every element of $haystack that is not equal to $needle. */
+function array_exclude($needle, $haystack) {
+ $result = array();
+ if (is_array($haystack)) {
+ foreach ($haystack as $thing) {
+ if ($needle !== $thing) {
+ $result[] = $thing;
+ }
+ }
+ }
+ return $result;
+}
+
?>
diff --git a/usr/local/www/firewall_aliases_edit.php b/usr/local/www/firewall_aliases_edit.php
index d72ec43..e11d32e 100755
--- a/usr/local/www/firewall_aliases_edit.php
+++ b/usr/local/www/firewall_aliases_edit.php
@@ -693,6 +693,7 @@ EOD;
</form>
<script type="text/javascript">
+//<![CDATA[
field_counter_js = 3;
rows = 1;
totalrows = <?php echo $counter; ?>;
@@ -700,32 +701,17 @@ EOD;
typesel_change();
update_box_type();
-<?php
- $isfirst = 0;
- $aliases = "";
- $addrisfirst = 0;
- $aliasesaddr = "";
- if(isset($config['aliases']['alias']) && is_array($config['aliases']['alias']))
- foreach($config['aliases']['alias'] as $alias_name) {
- if ($pconfig['name'] <> "" && $pconfig['name'] == $alias_name['name'])
- continue;
- if($addrisfirst == 1) $aliasesaddr .= ",";
- $aliasesaddr .= "'" . $alias_name['name'] . "'";
- $addrisfirst = 1;
- }
-?>
+ var addressarray = <?= json_encode(array_exclude($pconfig['name'], get_alias_list("port"))) ?>;
- var addressarray=new Array(<?php echo $aliasesaddr; ?>);
-
-function createAutoSuggest() {
-<?php
- for ($jv = 0; $jv < $counter; $jv++)
- echo "objAlias[{$jv}] = new AutoSuggestControl(document.getElementById(\"address{$jv}\"), new StateSuggestions(addressarray));\n";
-?>
-}
-
-setTimeout("createAutoSuggest();", 500);
+ function createAutoSuggest() {
+ <?php
+ for ($jv = 0; $jv < $counter; $jv++)
+ echo "objAlias[{$jv}] = new AutoSuggestControl(document.getElementById(\"address{$jv}\"), new StateSuggestions(addressarray));\n";
+ ?>
+ }
+ setTimeout("createAutoSuggest();", 500);
+//]]>
</script>
<?php include("fend.inc"); ?>
diff --git a/usr/local/www/firewall_nat_1to1_edit.php b/usr/local/www/firewall_nat_1to1_edit.php
index 135d0e9..d6dc9af 100755
--- a/usr/local/www/firewall_nat_1to1_edit.php
+++ b/usr/local/www/firewall_nat_1to1_edit.php
@@ -467,33 +467,11 @@ function typesel_change() {
<script language="JavaScript">
typesel_change();
</script>
-<?php
-$isfirst = 0;
-$aliases = "";
-$addrisfirst = 0;
-$aliasesaddr = "";
-if($config['aliases']['alias'] <> "")
- foreach($config['aliases']['alias'] as $alias_name) {
- switch ($alias_name['type']) {
- case "host":
- case "network":
- case "openvpn":
- case "urltable":
- if($addrisfirst == 1) $aliasesaddr .= ",";
- $aliasesaddr .= "'" . $alias_name['name'] . "'";
- $addrisfirst = 1;
- break;
- default:
- break;
- }
- }
-?>
<script language="JavaScript">
-<!--
- var addressarray=new Array(<?php echo $aliasesaddr; ?>);
-
+//<![CDATA[
+ var addressarray = <?= json_encode(get_alias_list(array("host", "network", "openvpn", "urltable"))) ?>;
var oTextbox1 = new AutoSuggestControl(document.getElementById("dst"), new StateSuggestions(addressarray));
-//-->
+//]]>
</script>
<?php include("fend.inc"); ?>
</body>
diff --git a/usr/local/www/firewall_nat_edit.php b/usr/local/www/firewall_nat_edit.php
index d0ab5ba..ad91112 100755
--- a/usr/local/www/firewall_nat_edit.php
+++ b/usr/local/www/firewall_nat_edit.php
@@ -865,36 +865,10 @@ include("fbegin.inc"); ?>
nordr_change();
//-->
</script>
-<?php
-$isfirst = 0;
-$aliases = "";
-$addrisfirst = 0;
-$aliasesaddr = "";
-if($config['aliases']['alias'] <> "")
- foreach($config['aliases']['alias'] as $alias_name) {
- switch ($alias_name['type']) {
- case "port":
- if($isfirst == 1) $portaliases .= ",";
- $portaliases .= "'" . $alias_name['name'] . "'";
- $isfirst = 1;
- break;
- case "host":
- case "network":
- case "openvpn":
- case "urltable":
- if($addrisfirst == 1) $aliasesaddr .= ",";
- $aliasesaddr .= "'" . $alias_name['name'] . "'";
- $addrisfirst = 1;
- break;
- default:
- break;
- }
- }
-?>
<script language="JavaScript">
-<!--
- var addressarray=new Array(<?php echo $aliasesaddr; ?>);
- var customarray=new Array(<?php echo $portaliases; ?>);
+//<![CDATA[
+ var addressarray = <?= json_encode(get_alias_list(array("host", "network", "openvpn", "urltable"))) ?>;
+ var customarray = <?= json_encode(get_alias_list("port")) ?>;
var oTextbox1 = new AutoSuggestControl(document.getElementById("localip"), new StateSuggestions(addressarray));
var oTextbox2 = new AutoSuggestControl(document.getElementById("src"), new StateSuggestions(addressarray));
@@ -904,7 +878,7 @@ if($config['aliases']['alias'] <> "")
var oTextbox6 = new AutoSuggestControl(document.getElementById("srcbeginport_cust"), new StateSuggestions(customarray));
var oTextbox7 = new AutoSuggestControl(document.getElementById("srcendport_cust"), new StateSuggestions(customarray));
var oTextbox8 = new AutoSuggestControl(document.getElementById("localbeginport_cust"), new StateSuggestions(customarray));
-//-->
+//]]>
</script>
<?php include("fend.inc"); ?>
</body>
diff --git a/usr/local/www/firewall_nat_out_edit.php b/usr/local/www/firewall_nat_out_edit.php
index a5be313..2ef7210 100755
--- a/usr/local/www/firewall_nat_out_edit.php
+++ b/usr/local/www/firewall_nat_out_edit.php
@@ -655,49 +655,22 @@ any)");?></td>
</table>
</form>
<script language="JavaScript">
-<!--
-sourcesel_change();
-typesel_change();
-staticportchange();
-nonat_change();
-proto_change();
-poolopts_change();
+//<![CDATA[
+ sourcesel_change();
+ typesel_change();
+ staticportchange();
+ nonat_change();
+ proto_change();
+ poolopts_change();
-<?php
- $isfirst = 0;
- $aliases = "";
- $addrisfirst = 0;
- $aliasesaddr = "";
- if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
- foreach($config['aliases']['alias'] as $alias_name) {
- switch ($alias_name['type']) {
- case "port":
- if($isfirst == 1) $portaliases .= ",";
- $portaliases .= "'" . $alias_name['name'] . "'";
- $isfirst = 1;
- break;
- case "host":
- case "network":
- case "openvpn":
- case "urltable":
- if($addrisfirst == 1) $aliasesaddr .= ",";
- $aliasesaddr .= "'" . $alias_name['name'] . "'";
- $addrisfirst = 1;
- break;
- default:
- break;
- }
- }
-?>
-
- var addressarray=new Array(<?php echo $aliasesaddr; ?>);
- var customarray=new Array(<?php echo $portaliases; ?>);
+ var addressarray = <?= json_encode(get_alias_list(array("host", "network", "openvpn", "urltable"))) ?>;
+ var customarray = <?= json_encode(get_alias_list("port")) ?>;
var oTextbox1 = new AutoSuggestControl(document.getElementById("source"), new StateSuggestions(addressarray));
var oTextbox2 = new AutoSuggestControl(document.getElementById("sourceport"), new StateSuggestions(customarray));
var oTextbox3 = new AutoSuggestControl(document.getElementById("destination"), new StateSuggestions(addressarray));
var oTextbox4 = new AutoSuggestControl(document.getElementById("dstport"), new StateSuggestions(customarray));
-//-->
+//]]>
</script>
<?php include("fend.inc"); ?>
</body>
diff --git a/usr/local/www/firewall_rules_edit.php b/usr/local/www/firewall_rules_edit.php
index de3a9eb..b53d151 100755
--- a/usr/local/www/firewall_rules_edit.php
+++ b/usr/local/www/firewall_rules_edit.php
@@ -1490,7 +1490,7 @@ $i--): ?>
</table>
</form>
<script language="JavaScript">
-<!--
+//<![CDATA[
ext_change();
typesel_change();
proto_change();
@@ -1498,35 +1498,8 @@ $i--): ?>
show_source_port_range();
<?php endif; ?>
-<?php
- $isfirst = 0;
- $aliases = "";
- $addrisfirst = 0;
- $aliasesaddr = "";
- if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
- foreach($config['aliases']['alias'] as $alias_name) {
- switch ($alias_name['type']) {
- case "port":
- if($isfirst == 1) $portaliases .= ",";
- $portaliases .= "'" . $alias_name['name'] . "'";
- $isfirst = 1;
- break;
- case "host":
- case "network":
- case "openvpn":
- case "urltable":
- if($addrisfirst == 1) $aliasesaddr .= ",";
- $aliasesaddr .= "'" . $alias_name['name'] . "'";
- $addrisfirst = 1;
- break;
- default:
- break;
- }
- }
-?>
-
- var addressarray=new Array(<?php echo $aliasesaddr; ?>);
- var customarray=new Array(<?php echo $portaliases; ?>);
+ var addressarray = <?= json_encode(get_alias_list(array("host", "network", "openvpn", "urltable"))) ?>;
+ var customarray = <?= json_encode(get_alias_list("port")) ?>;
var oTextbox1 = new AutoSuggestControl(document.getElementById("src"), new StateSuggestions(addressarray));
var oTextbox2 = new AutoSuggestControl(document.getElementById("srcbeginport_cust"), new StateSuggestions(customarray));
@@ -1534,7 +1507,7 @@ $i--): ?>
var oTextbox4 = new AutoSuggestControl(document.getElementById("dst"), new StateSuggestions(addressarray));
var oTextbox5 = new AutoSuggestControl(document.getElementById("dstbeginport_cust"), new StateSuggestions(customarray));
var oTextbox6 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
-//-->
+//]]>
</script>
<?php include("fend.inc"); ?>
</body>
diff --git a/usr/local/www/system_routes_edit.php b/usr/local/www/system_routes_edit.php
index ce47e97..ac7e9f1 100755
--- a/usr/local/www/system_routes_edit.php
+++ b/usr/local/www/system_routes_edit.php
@@ -384,26 +384,7 @@ include("head.inc");
report_failure();
}
}
- <?php
- $isfirst = 0;
- $aliases = "";
- $addrisfirst = 0;
- $aliasesaddr = "";
- if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
- foreach($config['aliases']['alias'] as $alias_name) {
- switch ($alias_name['type']) {
- case "host":
- case "network":
- if($addrisfirst == 1) $aliasesaddr .= ",";
- $aliasesaddr .= "'" . $alias_name['name'] . "'";
- $addrisfirst = 1;
- break;
- default:
- break;
- }
- }
- ?>
- var addressarray=new Array(<?php echo $aliasesaddr; ?>);
+ var addressarray = <?= json_encode(get_alias_list(array("host", "network"))) ?>;
var oTextbox1 = new AutoSuggestControl(document.getElementById("network"), new StateSuggestions(addressarray));
</script>
OpenPOWER on IntegriCloud