diff --git a/core/upgrade/upgrade.php b/core/upgrade/upgrade.php index 17df755a08..1553f9716b 100644 --- a/core/upgrade/upgrade.php +++ b/core/upgrade/upgrade.php @@ -24,17 +24,13 @@ Mark J Crane */ -//add the document root to the include path - $config_glob = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE); - if (is_array($config_glob) && count($config_glob) > 0) { - $config_glob = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE); - $conf = parse_ini_file($config_glob[0]); - set_include_path($conf['document.root']); - } - else { +//include file + require dirname(__DIR__, 2) . "/resources/require.php"; + +//if the config file doesn't exist and the config.php does exist use it to write a new config file + if (!$config_exists && file_exists("/etc/fusionpbx/config.php")) { //include the config.php - $config_php_glob = glob("{/usr/local/etc,/etc}/fusionpbx/config.php", GLOB_BRACE); - include($config_php_glob[0]); + include("/etc/fusionpbx/config.php"); //set the default config file location if (stristr(PHP_OS, 'BSD')) { @@ -123,15 +119,10 @@ if(!$file_handle){ return; } fwrite($file_handle, $conf); fclose($file_handle); - - //set the include path - $config_glob = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE); - $conf = parse_ini_file($config_glob[0]); - set_include_path($conf['document.root']); } //include files - require_once "resources/require.php"; + require dirname(__DIR__, 2) . "/resources/require.php"; //check the permission if(defined('STDIN')) { diff --git a/resources/require.php b/resources/require.php index 95078cdf4e..a3d5cb617c 100644 --- a/resources/require.php +++ b/resources/require.php @@ -29,6 +29,12 @@ $conf = parse_ini_file($config_glob[0]); set_include_path($conf['document.root']); +//config file + $config_file = $config_glob[0] ?? ''; + +//check if the config file exists + $config_exists = file_exists($config_file) ? true : false; + //set the server variables and define project path constant $_SERVER["DOCUMENT_ROOT"] = $conf['document.root']; $_SERVER["PROJECT_ROOT"] = $conf['document.root'];