added selectable hosted dns servers

This commit is contained in:
glaszig
2020-03-04 19:43:22 +01:00
parent 6c6de51a45
commit cfa3f9cfd3
4 changed files with 77 additions and 0 deletions

View File

@@ -346,3 +346,27 @@ function mb_escapeshellarg($arg)
return "\"$escaped_arg\"";
}
function dnsServers()
{
$data = json_decode(file_get_contents("./config/dns-servers.json"));
return (array) $data;
}
function optionsForSelect($options)
{
$html = "";
foreach ($options as $key => $value) {
// optgroup
if (is_array($value)) {
$html .= "<optgroup label=\"$key\">";
$html .= optionsForSelect($value);
$html .= "</optgroup>";
}
// option
else {
$key = is_int($key) ? $value : $key;
$html .= "<option value=\"$value\">$key</option>";
}
}
return $html;
}