diff options
author | Renato Botelho <renato.botelho@bluepex.com> | 2010-04-12 09:49:40 -0300 |
---|---|---|
committer | Renato Botelho <renato.botelho@bluepex.com> | 2010-04-12 09:49:40 -0300 |
commit | 00c827829ba1100be39dbd5508718903a07f11c8 (patch) | |
tree | 087beb1b3f088e32e80f06e8004683f997d9c448 /usr/local/www/firewall_rules.php | |
parent | cfcaabfb608758071b065754b6bf53cb131af22a (diff) | |
download | pfsense-00c827829ba1100be39dbd5508718903a07f11c8.zip pfsense-00c827829ba1100be39dbd5508718903a07f11c8.tar.gz |
Simplify logic implemented on commit 673d29c0
Diffstat (limited to 'usr/local/www/firewall_rules.php')
-rwxr-xr-x | usr/local/www/firewall_rules.php | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/usr/local/www/firewall_rules.php b/usr/local/www/firewall_rules.php index 24dfb2c..af0fedb 100755 --- a/usr/local/www/firewall_rules.php +++ b/usr/local/www/firewall_rules.php @@ -70,14 +70,17 @@ function check_for_advaned_options(&$item) { return $item_set; } -function delete_nat_association(&$a_nat, $id) { - if (!$id || !is_array($a_nat)) +function delete_nat_association($id) { + global $config; + + if (!$id || !is_array($config['nat']['rule'])) return; - for ($pos = 0; $pos < sizeof($a_nat); $pos++) { - if ($a_nat[$pos]['associated-rule-id'] == $id) - $a_nat[$pos]['associated-rule-id'] = ''; - } + $a_nat = &$config['nat']['rule']; + + foreach ($a_nat as &$natent) + if ($natent['associated-rule-id'] == $id) + $natent['associated-rule-id'] = ''; } if (!is_array($config['filter']['rule'])) { @@ -147,8 +150,7 @@ if ($_POST) { if ($_GET['act'] == "del") { 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']); + delete_nat_association($a_filter[$_GET['id']]['associated-rule-id']); } unset($a_filter[$_GET['id']]); write_config(); @@ -161,9 +163,8 @@ if ($_GET['act'] == "del") { 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']); + delete_nat_association($a_filter[$rulei]['associated-rule-id']); unset($a_filter[$rulei]); } write_config(); |