Use require.php

This commit is contained in:
markjcrane 2023-06-17 21:50:29 -06:00
parent ab646085be
commit 38150d25aa
2 changed files with 13 additions and 16 deletions

View File

@ -24,17 +24,13 @@
Mark J Crane <markjcrane@fusionpbx.com>
*/
//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')) {

View File

@ -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'];