diff options
author | Erik Fonnesbeck <efonnes@gmail.com> | 2010-11-10 22:58:30 -0700 |
---|---|---|
committer | Erik Fonnesbeck <efonnes@gmail.com> | 2010-11-10 22:58:30 -0700 |
commit | baaa8bb142f1f86dd7a7e60fe34fc07020fb482e (patch) | |
tree | 146336050de7920b8b62f217c865e64dda1efae4 | |
parent | 88bc276013552268ebef7058cd7b58c89de67125 (diff) | |
download | pfsense-baaa8bb142f1f86dd7a7e60fe34fc07020fb482e.zip pfsense-baaa8bb142f1f86dd7a7e60fe34fc07020fb482e.tar.gz |
Move this function to allow removing it from easyrule.
-rw-r--r-- | etc/inc/pfsense-utils.inc | 26 | ||||
-rwxr-xr-x | usr/local/bin/easyrule | 22 | ||||
-rwxr-xr-x | usr/local/www/guiconfig.inc | 26 |
3 files changed, 26 insertions, 48 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 6bd1671..7c0bdc0 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -2107,4 +2107,30 @@ function get_country_name($country_code) { return ""; } +/* sort by interface only, retain the original order of rules that apply to + the same interface */ +function filter_rules_sort() { + global $config; + + /* mark each rule with the sequence number (to retain the order while sorting) */ + for ($i = 0; isset($config['filter']['rule'][$i]); $i++) + $config['filter']['rule'][$i]['seq'] = $i; + + usort($config['filter']['rule'], "filter_rules_compare"); + + /* strip the sequence numbers again */ + for ($i = 0; isset($config['filter']['rule'][$i]); $i++) + unset($config['filter']['rule'][$i]['seq']); +} +function filter_rules_compare($a, $b) { + if ($a['interface'] == $b['interface'] || ( isset($a['floating']) && isset($b['floating']) )) + return $a['seq'] - $b['seq']; + else if (isset($a['floating'])) + return -1; + else if (isset($b['floating'])) + return 1; + else + return compare_interface_friendly_names($a['interface'], $b['interface']); +} + ?> diff --git a/usr/local/bin/easyrule b/usr/local/bin/easyrule index 60f5fb1..f4c9dad 100755 --- a/usr/local/bin/easyrule +++ b/usr/local/bin/easyrule @@ -84,28 +84,6 @@ function is_specialnet($net) { return false; } -/* Another one we need from guiconfig.inc but can't include... */ -function filter_rules_sort() { - global $config; - - /* mark each rule with the sequence number (to retain the order while sorting) */ - for ($i = 0; isset($config['filter']['rule'][$i]); $i++) - $config['filter']['rule'][$i]['seq'] = $i; - - function filtercmp($a, $b) { - if ($a['interface'] == $b['interface']) - return $a['seq'] - $b['seq']; - else - return -strcmp($a['interface'], $b['interface']); - } - - usort($config['filter']['rule'], "filtercmp"); - - /* strip the sequence numbers again */ - for ($i = 0; isset($config['filter']['rule'][$i]); $i++) - unset($config['filter']['rule'][$i]['seq']); -} - if (($argc > 1) && !empty($argv[1])) { $message = ""; diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc index d1a92c7..ca038a5 100755 --- a/usr/local/www/guiconfig.inc +++ b/usr/local/www/guiconfig.inc @@ -455,32 +455,6 @@ function pprint_port($port) { return $pport; } -/* sort by interface only, retain the original order of rules that apply to - the same interface */ -function filter_rules_sort() { - global $config; - - /* mark each rule with the sequence number (to retain the order while sorting) */ - for ($i = 0; isset($config['filter']['rule'][$i]); $i++) - $config['filter']['rule'][$i]['seq'] = $i; - - usort($config['filter']['rule'], "filter_rules_compare"); - - /* strip the sequence numbers again */ - for ($i = 0; isset($config['filter']['rule'][$i]); $i++) - unset($config['filter']['rule'][$i]['seq']); -} -function filter_rules_compare($a, $b) { - if ($a['interface'] == $b['interface'] || ( isset($a['floating']) && isset($b['floating']) )) - return $a['seq'] - $b['seq']; - else if (isset($a['floating'])) - return -1; - else if (isset($b['floating'])) - return 1; - else - return compare_interface_friendly_names($a['interface'], $b['interface']); -} - function firewall_check_for_advanced_options(&$item) { $item_set = ""; if($item['max']) |