Răsfoiți Sursa

Replace config.php with config.conf

FusionPBX 2 ani în urmă
părinte
comite
88a57bfd93
1 a modificat fișierele cu 39 adăugiri și 16 ștergeri
  1. 39 16
      resources/require.php

+ 39 - 16
resources/require.php

@@ -17,30 +17,53 @@
 
 	The Initial Developer of the Original Code is
 	Mark J Crane <[email protected]>
-	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 <[email protected]>
 */
 
-//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")) {