Replace the DOCUMENT_ROOT and PROJECT_ROOT variables

Use the __DIR__ constant and dirname as needed
This commit is contained in:
FusionPBX
2025-12-08 14:12:19 -07:00
committed by GitHub
parent df90513f86
commit 6b063f2c28
84 changed files with 217 additions and 210 deletions

View File

@@ -66,7 +66,7 @@ class captcha {
$text = $this->code;
// Set the font path
$font_path = $_SERVER["DOCUMENT_ROOT"] . "/resources/captcha/fonts";
$font_path = dirname(__DIR__, 2) . "/resources/captcha/fonts";
// Array of fonts
//$fonts[] = 'ROUGD.TTF';

View File

@@ -19,21 +19,29 @@
* @param string $config_file Configuration file currently in use
* @param string $config_path_and_filename Full path and configuration file currently in use
*
* @internal the @param statements are used because they match the magic __get function that allows those to be
* accessed publicly
* @internal the @param statements are used because they match the magic __get function that allows those to be accessed publicly
*/
final class config {
// Full path and filename of config.conf
/**
* Configuration object used to hold a single instance
*
* @var array
* @var config
*/
public static $config = null;
// The internal array that holds the configuration in the config.conf file
/**
* The full path and file name for the config file.
*
* @var string
*/
private $file;
/**
* The array of settings contained in the config file.
*
* @var array
*/
private $configuration;
/**

View File

@@ -1651,7 +1651,7 @@ class database {
$transaction_type = 'delete';
//log the transaction results
if (file_exists($_SERVER["PROJECT_ROOT"] . "/app/database_transactions/app_config.php")) {
if (file_exists(dirname(__DIR__, 2) . "/app/database_transactions/app_config.php")) {
$sql = "insert into " . self::TABLE_PREFIX . "database_transactions ";
$sql .= "(";
$sql .= "database_transaction_uuid, ";
@@ -1792,7 +1792,7 @@ class database {
$applications = [$schema, self::singular($schema)];
foreach ($directories as $directory) {
foreach ($applications as $application) {
$path = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/$directory/$application/app_config.php";
$path = dirname(__DIR__, 2) . "/$directory/$application/app_config.php";
$app_config_files = glob($path);
if ($app_config_files !== false) {
$config_list = array_merge($config_list, $app_config_files);
@@ -3269,7 +3269,7 @@ class database {
}
//log the transaction results
if ($transaction_save && $database_updated && file_exists($_SERVER["PROJECT_ROOT"] . "/app/database_transactions/app_config.php")) {
if ($transaction_save && $database_updated && file_exists(dirname(__DIR__, 2) . "/app/database_transactions/app_config.php")) {
try {
//build the json string from the array
if (!empty($old_array)) {
@@ -3515,12 +3515,12 @@ class database {
*
* @return null Does not return any values
* @uses PROJECT_PATH Global variable
* @uses $_SERVER['DOCUMENT_ROOT'] Global variable
* @uses dirname(__DIR__, 2) Global variable
* @internal Moved to class to conserve resources.
*/
public static function get_apps() {
//get the $apps array from the installed apps from the core and mod directories
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
$config_list = glob(dirname(__DIR__, 2) . "/*/*/app_config.php");
$x = 0;
if (is_array($config_list)) {
foreach ($config_list as $config_path) {

View File

@@ -340,8 +340,8 @@ class domains {
$config_path = $config->config_file;
//get the list of installed apps from the core and app directories (note: GLOB_BRACE doesn't work on some systems)
$config_list_1 = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
$config_list_2 = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_menu.php");
$config_list_1 = glob(dirname(__DIR__, 2) . "/*/*/app_config.php");
$config_list_2 = glob(dirname(__DIR__, 2) . "/*/*/app_menu.php");
$config_list = array_merge((array)$config_list_1, (array)$config_list_2);
unset($config_list_1, $config_list_2);
$x = 0;
@@ -358,7 +358,7 @@ class domains {
unset($sql);
//get the list of installed apps from the core and mod directories
$default_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_defaults.php");
$default_list = glob(dirname(__DIR__, 2) . "/*/*/app_defaults.php");
//loop through all domains
$domains_processed = 1;
@@ -408,7 +408,7 @@ class domains {
unset($sql);
//get the list of default settings
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
$config_list = glob(dirname(__DIR__, 2) . "/*/*/app_config.php");
$x = 0;
foreach ($config_list as $config_path) {
include($config_path);
@@ -517,7 +517,7 @@ class domains {
unset($result, $row);
//get the $apps array from the installed apps from the core and mod directories
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
$config_list = glob(dirname(__DIR__, 2) . "/*/*/app_config.php");
$x = 0;
if (isset($config_list)) foreach ($config_list as $config_path) {
include($config_path);

View File

@@ -125,8 +125,8 @@ class email {
//includes
require_once('resources/pop3/mime_parser.php');
require_once('resources/pop3/rfc822_addresses.php');
if (file_exists($_SERVER["PROJECT_ROOT"] . "/app/emails/email_transcription.php")) {
require_once($_SERVER["PROJECT_ROOT"] . "/app/emails/email_transcription.php");
if (file_exists(dirname(__DIR__, 2) . "/app/emails/email_transcription.php")) {
require_once(dirname(__DIR__, 2) . "/app/emails/email_transcription.php");
}
//parse the email message

View File

@@ -530,7 +530,7 @@ class groups {
$num_rows = $this->database->select($sql, null, 'column');
if ($num_rows == 0) {
//build the apps array
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
$config_list = glob(dirname(__DIR__, 2) . "/*/*/app_config.php");
$x = 0;
foreach ($config_list as $config_path) {
include($config_path);

View File

@@ -944,7 +944,7 @@ class menu {
public function restore_default() {
//get the $apps array from the installed apps from the core and mod directories
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_menu.php");
$config_list = glob(dirname(__DIR__, 2) . "/*/*/app_menu.php");
$x = 0;
if (is_array($config_list)) {
foreach ($config_list as $config_path) {

View File

@@ -58,7 +58,7 @@ class schema {
$this->database = $setting_array['database'] ?? database::new();
//get the list of installed apps from the core and mod directories
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
$config_list = glob(dirname(__DIR__, 2) . "/*/*/app_config.php");
$x = 0;
foreach ($config_list as $config_path) {
try {

View File

@@ -61,7 +61,7 @@ class sounds {
}
}
//recordings
if ((empty($this->sound_types) || (is_array($this->sound_types) && in_array('recordings', $this->sound_types))) && file_exists($_SERVER["PROJECT_ROOT"] . "/app/recordings/app_config.php")) {
if ((empty($this->sound_types) || (is_array($this->sound_types) && in_array('recordings', $this->sound_types))) && file_exists(dirname(__DIR__, 2) . "/app/recordings/app_config.php")) {
$sql = "select recording_name, recording_filename from v_recordings ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by recording_name asc ";
@@ -79,7 +79,7 @@ class sounds {
unset($sql, $parameters, $recordings, $row);
}
//phrases
if ((empty($this->sound_types) || (is_array($this->sound_types) && in_array('phrases', $this->sound_types))) && file_exists($_SERVER["PROJECT_ROOT"] . "/app/phrases/app_config.php")) {
if ((empty($this->sound_types) || (is_array($this->sound_types) && in_array('phrases', $this->sound_types))) && file_exists(dirname(__DIR__, 2) . "/app/phrases/app_config.php")) {
$sql = "select * from v_phrases ";
$sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
@@ -94,7 +94,7 @@ class sounds {
unset($sql, $parameters, $phrases, $row);
}
//sounds
if ((empty($this->sound_types) || (is_array($this->sound_types) && in_array('sounds', $this->sound_types))) && file_exists($_SERVER["PROJECT_ROOT"] . "/app/phrases/app_config.php")) {
if ((empty($this->sound_types) || (is_array($this->sound_types) && in_array('sounds', $this->sound_types))) && file_exists(dirname(__DIR__, 2) . "/app/phrases/app_config.php")) {
$file = new file;
$sound_files = $file->sounds();
if (is_array($sound_files) && @sizeof($sound_files) != 0) {

View File

@@ -102,8 +102,8 @@ class text implements clear_cache {
}
//get the global app_languages.php so we can get the list of languages
if (file_exists($_SERVER["PROJECT_ROOT"] . "/resources/app_languages.php")) {
include $_SERVER["PROJECT_ROOT"] . "/resources/app_languages.php";
if (file_exists(dirname(__DIR__, 2) . "/resources/app_languages.php")) {
include dirname(__DIR__, 2) . "/resources/app_languages.php";
}
//get the list of languages, remove en-us, sort it then put en-us in front
@@ -174,7 +174,7 @@ class text implements clear_cache {
//get the app_languages.php
if ($app_path != null) {
$lang_path = $_SERVER["PROJECT_ROOT"] . "/" . $app_path;
$lang_path = dirname(__DIR__, 2) . "/" . $app_path;
} else {
$lang_path = getcwd();
}
@@ -190,8 +190,8 @@ class text implements clear_cache {
}
//get the global app_languages.php
if (!$exclude_global && file_exists($_SERVER["PROJECT_ROOT"] . "/resources/app_languages.php")) {
require $_SERVER["PROJECT_ROOT"] . "/resources/app_languages.php";
if (!$exclude_global && file_exists(dirname(__DIR__, 2) . "/resources/app_languages.php")) {
require dirname(__DIR__, 2) . "/resources/app_languages.php";
}
if (file_exists($lang_path . "/app_languages.php") && ($lang_path != 'resources' or $exclude_global)) {
@@ -241,11 +241,11 @@ class text implements clear_cache {
$languages = [];
//retrieve all the languages
$files = glob($_SERVER["PROJECT_ROOT"] . "/*/*/app_languages.php");
$files = glob(dirname(__DIR__, 2) . "/*/*/app_languages.php");
foreach ($files as $file) {
include $file;
}
include $_SERVER["PROJECT_ROOT"] . "/resources/app_languages.php";
include dirname(__DIR__, 2) . "/resources/app_languages.php";
//check every tag
foreach ($text as $lang_codes) {
@@ -290,7 +290,7 @@ class text implements clear_cache {
if ($app_path == null) {
throw new Exception("\$app_path must be specified");
}
$lang_path = $_SERVER["PROJECT_ROOT"] . "/$app_path/app_languages.php";
$lang_path = dirname(__DIR__, 2) . "/$app_path/app_languages.php";
if (!file_exists($lang_path)) {
throw new Exception("could not find app_languages for '$app_path'");
}
@@ -453,11 +453,11 @@ class text implements clear_cache {
//retrieve all the languages
$text = [];
$files = glob($_SERVER["PROJECT_ROOT"] . "/*/*/app_languages.php");
$files = glob(dirname(__DIR__, 2) . "/*/*/app_languages.php");
foreach ($files as $file) {
include $file;
}
include $_SERVER["PROJECT_ROOT"] . "/resources/app_languages.php";
include dirname(__DIR__, 2) . "/resources/app_languages.php";
//check every tag
foreach ($text as $label_name => $values) {
@@ -471,7 +471,7 @@ class text implements clear_cache {
//retrieve all the menus
$x = 0;
$files = glob($_SERVER["PROJECT_ROOT"] . "/*/*");
$files = glob(dirname(__DIR__, 2) . "/*/*");
foreach ($files as $file) {
if (file_exists($file . "/app_menu.php"))
include $file . "/app_menu.php";