diff options
author | Renato Botelho <renato.botelho@bluepex.com> | 2010-11-16 09:31:33 -0200 |
---|---|---|
committer | Renato Botelho <renato.botelho@bluepex.com> | 2010-11-16 09:31:33 -0200 |
commit | 39a8090a5a9ee447442ca6da154b0005b7e1bf80 (patch) | |
tree | fd327d4c1ebda352a39afdf83c0a9bf09f7c3b5f /etc/inc/pfsense-utils.inc | |
parent | 129841508a5659a2c428213e0b231f9132fbfc4a (diff) | |
parent | e6b960ccffd51fd6a2ad190760f029608051f478 (diff) | |
download | pfsense-39a8090a5a9ee447442ca6da154b0005b7e1bf80.zip pfsense-39a8090a5a9ee447442ca6da154b0005b7e1bf80.tar.gz |
Merge remote branch 'mainline/master' into inc
Conflicts:
etc/inc/PEAR.inc
etc/inc/filter.inc
Diffstat (limited to 'etc/inc/pfsense-utils.inc')
-rw-r--r-- | etc/inc/pfsense-utils.inc | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index c5d3b69..96a9d25 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -149,22 +149,13 @@ function get_tmp_file() { ******/ function get_dns_servers() { $dns_servers = array(); - $dns = `cat /etc/resolv.conf`; - $dns_s = split("\n", $dns); + $dns_s = file("/etc/resolv.conf", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach($dns_s as $dns) { $matches = ""; if (preg_match("/nameserver (.*)/", $dns, $matches)) $dns_servers[] = $matches[1]; } - $dns_server_master = array(); - $lastseen = ""; - foreach($dns_servers as $t) { - if($t <> $lastseen) - if($t <> "") - $dns_server_master[] = $t; - $lastseen = $t; - } - return $dns_server_master; + return array_unique($dns_servers); } /****f* pfsense-utils/enable_hardware_offloading @@ -2116,4 +2107,32 @@ 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 (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 if ($a['interface'] == $b['interface']) + return $a['seq'] - $b['seq']; + else + return compare_interface_friendly_names($a['interface'], $b['interface']); +} + ?> |