From 9f85daaa86c477a93e086a873b7cf0b0dcb7fad8 Mon Sep 17 00:00:00 2001 From: billz Date: Sat, 5 Dec 2020 09:12:47 +0000 Subject: [PATCH] Added getDefaultNetValue() --- includes/functions.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/includes/functions.php b/includes/functions.php index ea19b828..73f06600 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -121,6 +121,24 @@ function scanConfigDir($dir_conf,$interface,$status) return $status; } +/** + * Returns a default (fallback) value for the selected service, interface & setting + * from /etc/raspap/networking/defaults.json + * + * @param string $svc + * @param string $iface + * @return string $value + */ +function getDefaultNetValue($svc,$iface,$key) +{ + $json = json_decode(file_get_contents(RASPI_CONFIG_NETWORK), true); + if ($json === null) { + return false; + } else { + return $json[$svc][$iface][$key][0]; + } +} + /* Functions to write ini files */ function write_php_ini($array, $file)