From 1c81f9c8b2dbc83c9637762f699e00c3926acd1c Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Mon, 10 Oct 2022 13:16:32 -0600 Subject: [PATCH] Replace config.php with config.conf --- resources/require.php | 55 ++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/resources/require.php b/resources/require.php index e60c640b0b..b397f2be29 100644 --- a/resources/require.php +++ b/resources/require.php @@ -17,30 +17,53 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2021 + Portions created by the Initial Developer are Copyright (C) 2008-2022 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ -//ensure that $_SERVER["DOCUMENT_ROOT"] is defined - include "root.php"; +//add the document root to 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']); -//find and include the config.php file - $config_exists = false; - if (file_exists("/etc/fusionpbx/config.php")) { - $config_exists = true; - include "/etc/fusionpbx/config.php"; +//set the server variables and define project path constant + $_SERVER["DOCUMENT_ROOT"] = $conf['document.root']; + $_SERVER["PROJECT_PATH"] = $conf['project.path']; + if (isset($conf['project.path'])) { + $_SERVER["PROJECT_ROOT"] = $conf['document.root'].$conf['project.path']; } - elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) { - $config_exists = true; - include "/usr/local/etc/fusionpbx/config.php"; - } - elseif (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/config.php")) { - $config_exists = true; - include "resources/config.php"; + else { + $_SERVER["PROJECT_ROOT"] = $conf['document.root']; } + define("PROJECT_PATH", $conf['project.path']); + +//set the error reporting + ini_set('display_errors', '1'); + error_reporting($conf['error.reporting']); + +//get the database connection settings + //$db_type = $settings['database']['type']; + //$db_host = $settings['database']['host']; + //$db_port = $settings['database']['port']; + //$db_name = $settings['database']['name']; + //$db_username = $settings['database']['username']; + //$db_password = $settings['database']['password']; + +//get the database connection settings + $db_type = $conf['database.0.type']; + $db_host = $conf['database.0.host']; + $db_port = $conf['database.0.port']; + $db_name = $conf['database.0.name']; + $db_username = $conf['database.0.username']; + $db_password = $conf['database.0.password']; + +//debug info + //echo "Include Path: ".get_include_path()."\n"; + //echo "Document Root: ".$_SERVER["DOCUMENT_ROOT"]."\n"; + //echo "Project Root: ".$_SERVER["PROJECT_ROOT"]."\n"; //class auto loader include "resources/classes/auto_loader.php"; @@ -49,7 +72,7 @@ //additional includes require_once "resources/php.php"; require_once "resources/functions.php"; - if ($config_exists) { + if (is_array($conf) && count($conf) > 0) { require "resources/pdo.php"; require_once "resources/cidr.php"; if (file_exists($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/resources/switch.php")) {