summaryrefslogtreecommitdiffstats
path: root/usr/local/www/firewall_rules.php
diff options
context:
space:
mode:
authorErik Fonnesbeck <efonnes@gmail.com>2010-11-11 02:03:40 -0700
committerErik Fonnesbeck <efonnes@gmail.com>2010-11-11 02:24:04 -0700
commitcb53651f679341c8c6cdf717f5f33622e24b22f0 (patch)
treeb4fb0c3a07d0dd86fe4f119554fd54149a4e528b /usr/local/www/firewall_rules.php
parenta5ebdeff9269034cee1291720718202526a1d43d (diff)
downloadpfsense-cb53651f679341c8c6cdf717f5f33622e24b22f0.zip
pfsense-cb53651f679341c8c6cdf717f5f33622e24b22f0.tar.gz
Small rework of code for applying drag and drop reordering of rules and some extra checks added to fix some potential bugs. Ticket #878
Also minimizes the extent of the changes performed (useful when comparing config.xml files from before and after).
Diffstat (limited to 'usr/local/www/firewall_rules.php')
-rwxr-xr-xusr/local/www/firewall_rules.php37
1 files changed, 18 insertions, 19 deletions
diff --git a/usr/local/www/firewall_rules.php b/usr/local/www/firewall_rules.php
index b7f990d..ccf1e58 100755
--- a/usr/local/www/firewall_rules.php
+++ b/usr/local/www/firewall_rules.php
@@ -79,34 +79,33 @@ $ifdescs = get_configured_interface_with_descr();
// Drag and drop reordering
if($_REQUEST['dragdroporder']) {
// First create a new ruleset array and tmp arrays
- $a_filter_unorder = array();
+ $a_filter_before = array();
$a_filter_order = array();
$a_filter_order_tmp = array();
- // Pointer to id of item being reordered
- $found = 0;
+ $a_filter_after = array();
+ $found = false;
$drag_order = $_REQUEST['dragtable'];
// Next traverse through rules building a new order for interface
for ($i = 0; isset($a_filter[$i]); $i++) {
- if($_REQUEST['if'] == "FloatingRules") {
- if(!isset($a_filter[$i]['floating']))
- $a_filter_unorder[] = $a_filter[$i];
- else
- $a_filter_order_tmp[] = $a_filter[$i];
- } else {
- if($a_filter[$i]['interface'] <> $_REQUEST['if'] || isset($a_filter[$i]['floating']))
- $a_filter_unorder[] = $a_filter[$i];
- else
- $a_filter_order_tmp[] = $a_filter[$i];
- }
+ if(( $_REQUEST['if'] == "FloatingRules" && isset($a_filter[$i]['floating']) ) || ( $a_filter[$i]['interface'] == $_REQUEST['if'] && !isset($a_filter[$i]['floating']) )) {
+ $a_filter_order_tmp[] = $a_filter[$i];
+ $found = true;
+ } else if (!$found)
+ $a_filter_before[] = $a_filter[$i];
+ else
+ $a_filter_after[] = $a_filter[$i];
}
// Reorder rules with the posted order
- for ($i = 0; $i<count($drag_order); $i++)
+ for ($i = 0; $i<count($drag_order); $i++)
$a_filter_order[] = $a_filter_order_tmp[$drag_order[$i]];
- unset($config['filter']['rule']);
+ // In case $drag_order didn't account for some rules, make sure we don't lose them
+ if(count($a_filter_order) < count($a_filter_order_tmp)) {
+ for ($i = 0; $i<count($a_filter_order_tmp); $i++)
+ if(!in_array($i, $drag_order))
+ $a_filter_order[] = $a_filter_order_tmp[$i];
+ }
// Overwrite filter rules with newly created items
- $config['filter']['rule'] = $a_filter_order;
- foreach($a_filter_unorder as $aa)
- $config['filter']['rule'][] = $aa;
+ $config['filter']['rule'] = array_merge($a_filter_before, $a_filter_order, $a_filter_after);
// Write configuration
$config = write_config("Drag and drop firewall rules ordering update.");
// Redirect back to page
OpenPOWER on IntegriCloud