From 490a68e8c13af4d1252e06a3cf849b5ae5878fc4 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Sun, 16 Sep 2018 18:49:05 +0200 Subject: [PATCH] unbound: remove superflous msort() function --- src/etc/inc/plugins.inc.d/unbound.inc | 10 ++++---- src/etc/inc/util.inc | 34 --------------------------- 2 files changed, 6 insertions(+), 38 deletions(-) diff --git a/src/etc/inc/plugins.inc.d/unbound.inc b/src/etc/inc/plugins.inc.d/unbound.inc index 42fb93d10..e3c0b0e5c 100644 --- a/src/etc/inc/plugins.inc.d/unbound.inc +++ b/src/etc/inc/plugins.inc.d/unbound.inc @@ -467,13 +467,15 @@ function unbound_configure_do($verbose = false, $interface = '') function unbound_add_domain_overrides($pvt = false) { - global $config; + $domains = config_read_array('unbound', 'domainoverrides'); - $domains = $config['unbound']['domainoverrides']; + usort($domains, function ($a, $b) { + return strcasecmp($a['domain'], $b['domain']); + }); - $sorted_domains = msort($domains, "domain"); $result = array(); - foreach ($sorted_domains as $domain) { + + foreach ($domains as $domain) { $domain_key = current($domain); if (!isset($result[$domain_key])) { $result[$domain_key] = array(); diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index 9c7c051a8..b52d136d9 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -1176,40 +1176,6 @@ function set_single_sysctl($name, $value) return true; } -/****f* util/msort - * NAME - * msort - sort array - * INPUTS - * $array to be sorted, field to sort by, direction of sort - * RESULT - * returns newly sorted array - ******/ -function msort($array, $id="id", $sort_ascending=true) -{ - $temp_array = array(); - while(count($array)>0) { - $lowest_id = 0; - $index=0; - foreach ($array as $item) { - if (isset($item[$id])) { - if ($array[$lowest_id][$id]) { - if (strtolower($item[$id]) < strtolower($array[$lowest_id][$id])) { - $lowest_id = $index; - } - } - } - $index++; - } - $temp_array[] = $array[$lowest_id]; - $array = array_merge(array_slice($array, 0,$lowest_id), array_slice($array, $lowest_id+1)); - } - if ($sort_ascending) { - return $temp_array; - } else { - return array_reverse($temp_array); - } -} - /****f* util/is_URL * NAME * is_URL