replaced array_merge with array_replace_recursive

This commit is contained in:
Paul Wilde 2021-08-12 15:35:20 +01:00
parent 51b25e1580
commit 11bc449966
2 changed files with 15 additions and 3 deletions

View file

@ -34,7 +34,7 @@ class Init {
// merge the default config with the custom config // merge the default config with the custom config
Core::$Config = array_merge($default_config,$config); Core::$Config = array_merge($default_config,$config);
Core::$Config["PrimaryDomain"] = Core::$Config["Domain"][0]; Core::$Config["PrimaryDomain"] = Core::$Config["Domain"][0];
// parse the default services file for default values // parse the default services file for default values
$default_services = parse_ini_file(Core::root_dir()."/default-config/services.default.ini", true); $default_services = parse_ini_file(Core::root_dir()."/default-config/services.default.ini", true);
@ -47,9 +47,11 @@ class Init {
} }
// merge the default config with the custom config // merge the default config with the custom config
Core::$Config["Services"] = array_merge($default_services,$services); // using replace recursive as the config file contains arrays itself
Core::$Config["Services"] = array_replace_recursive($default_services,$services);
// get the current git commit, if it exists. For testing // get the current git commit, if it exists. For testing
Core::$Config["CommitID"] = Core::get_current_git_commit(); Core::$Config["CommitID"] = Core::get_current_git_commit();
} }
} }

View file

@ -54,6 +54,9 @@ class Responder {
case "autodiscover/autodiscover.json": case "autodiscover/autodiscover.json":
$resp = $this->ms_autodiscover_json(); $resp = $this->ms_autodiscover_json();
break; break;
case "get/config":
$resp = $this->get_config();
break;
case "none": case "none":
case "test": case "test":
case "home": case "home":
@ -65,10 +68,17 @@ class Responder {
} }
return $resp; return $resp;
} }
private function get_config(){
$response = new Response();
$response->message = "Here's your config...";
foreach (Core::$Config as $k => $v){
$response->content[$k] = $v;
}
return $response;
}
private function get_username($service,$email_address) { private function get_username($service,$email_address) {
$username = "%EMAILADDRESS%"; $username = "%EMAILADDRESS%";
if(!$service["UsernameIsFQDN"]) { if(!$service["UsernameIsFQDN"]) {
preg_match("/^[^@]+/",$email_address,$matches); preg_match("/^[^@]+/",$email_address,$matches);
if (count($matches) > 0){ if (count($matches) > 0){
$username = $matches[0]; $username = $matches[0];