unbound: remove superflous msort() function

This commit is contained in:
Franco Fichtner 2018-09-16 18:49:05 +02:00
parent a0d9ce9c3c
commit 490a68e8c1
2 changed files with 6 additions and 38 deletions

View File

@ -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();

View File

@ -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