diff options
Diffstat (limited to 'usr/local/www/firewall_rules.php')
-rwxr-xr-x | usr/local/www/firewall_rules.php | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/usr/local/www/firewall_rules.php b/usr/local/www/firewall_rules.php index 57869da..24dfb2c 100755 --- a/usr/local/www/firewall_rules.php +++ b/usr/local/www/firewall_rules.php @@ -70,6 +70,16 @@ function check_for_advaned_options(&$item) { return $item_set; } +function delete_nat_association(&$a_nat, $id) { + if (!$id || !is_array($a_nat)) + return; + + for ($pos = 0; $pos < sizeof($a_nat); $pos++) { + if ($a_nat[$pos]['associated-rule-id'] == $id) + $a_nat[$pos]['associated-rule-id'] = ''; + } +} + if (!is_array($config['filter']['rule'])) { $config['filter']['rule'] = array(); } @@ -135,19 +145,25 @@ if ($_POST) { } if ($_GET['act'] == "del") { - if ($a_filter[$_GET['id']]) { - unset($a_filter[$_GET['id']]); - write_config(); + if ($a_filter[$_GET['id']]) { + if (!empty($a_filter[$_GET['id']]['associated-rule-id'])) { + $a_nat = &$config['nat']['rule']; + delete_nat_association($a_nat, $a_filter[$_GET['id']]['associated-rule-id']); + } + unset($a_filter[$_GET['id']]); + write_config(); mark_subsystem_dirty('filter'); - header("Location: firewall_rules.php?if={$if}"); - exit; - } + header("Location: firewall_rules.php?if={$if}"); + exit; + } } if (isset($_POST['del_x'])) { /* delete selected rules */ if (is_array($_POST['rule']) && count($_POST['rule'])) { + $a_nat = &$config['nat']['rule']; foreach ($_POST['rule'] as $rulei) { + delete_nat_association($a_nat, $a_filter[$rulei]['associated-rule-id']); unset($a_filter[$rulei]); } write_config(); |