Replace config.php with config.conf

This commit is contained in:
FusionPBX 2022-10-10 13:16:32 -06:00 committed by GitHub
parent 7aa7ae4dd1
commit 1c81f9c8b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 39 additions and 16 deletions

View File

@ -17,30 +17,53 @@
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
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. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//ensure that $_SERVER["DOCUMENT_ROOT"] is defined //add the document root to the include path
include "root.php"; $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 //set the server variables and define project path constant
$config_exists = false; $_SERVER["DOCUMENT_ROOT"] = $conf['document.root'];
if (file_exists("/etc/fusionpbx/config.php")) { $_SERVER["PROJECT_PATH"] = $conf['project.path'];
$config_exists = true; if (isset($conf['project.path'])) {
include "/etc/fusionpbx/config.php"; $_SERVER["PROJECT_ROOT"] = $conf['document.root'].$conf['project.path'];
} }
elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) { else {
$config_exists = true; $_SERVER["PROJECT_ROOT"] = $conf['document.root'];
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";
} }
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 //class auto loader
include "resources/classes/auto_loader.php"; include "resources/classes/auto_loader.php";
@ -49,7 +72,7 @@
//additional includes //additional includes
require_once "resources/php.php"; require_once "resources/php.php";
require_once "resources/functions.php"; require_once "resources/functions.php";
if ($config_exists) { if (is_array($conf) && count($conf) > 0) {
require "resources/pdo.php"; require "resources/pdo.php";
require_once "resources/cidr.php"; require_once "resources/cidr.php";
if (file_exists($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/resources/switch.php")) { if (file_exists($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/resources/switch.php")) {