diff --git a/app/access_controls/app_defaults.php b/app/access_controls/app_defaults.php
index c11175c83a..4dcd75bb10 100644
--- a/app/access_controls/app_defaults.php
+++ b/app/access_controls/app_defaults.php
@@ -35,7 +35,7 @@
//set the directory
$xml_dir = $settings->get('switch','conf').'/autoload_configs';
$xml_file = $xml_dir."/acl.conf.xml";
- $xml_file_alt = $_SERVER["DOCUMENT_ROOT"].'/'.PROJECT_PATH.'/app/switch/resources/conf/autoload_configs/acl.conf';
+ $xml_file_alt = dirname(__DIR__, 2).'/'.PROJECT_PATH.'/app/switch/resources/conf/autoload_configs/acl.conf';
//load the xml and save it into an array
if (file_exists($xml_file)) {
diff --git a/app/basic_operator_panel/index.php b/app/basic_operator_panel/index.php
index 5091b3d235..e00436ded8 100644
--- a/app/basic_operator_panel/index.php
+++ b/app/basic_operator_panel/index.php
@@ -78,7 +78,7 @@
}
//if call center app is installed then update the user_status
- if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/call_centers')) {
+ if (is_dir(dirname(__DIR__, 2).'/app/call_centers')) {
//get the call center agent uuid
$sql = "select call_center_agent_uuid from v_call_center_agents ";
$sql .= "where domain_uuid = :domain_uuid ";
diff --git a/app/call_block/call_block_edit.php b/app/call_block/call_block_edit.php
index 521adaacd6..0e3193e18c 100644
--- a/app/call_block/call_block_edit.php
+++ b/app/call_block/call_block_edit.php
@@ -709,10 +709,10 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr
echo " \n";
echo " \n";
if (
- file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$settings->get('domain', 'template', 'default')."/images/icon_cdr_inbound_voicemail.png") &&
- file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$settings->get('domain', 'template', 'default')."/images/icon_cdr_inbound_answered.png") &&
- file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$settings->get('domain', 'template', 'default')."/images/icon_cdr_outbound_failed.png") &&
- file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$settings->get('domain', 'template', 'default')."/images/icon_cdr_outbound_answered.png")
+ file_exists(dirname(__DIR__, 2)."/themes/".$settings->get('domain', 'template', 'default')."/images/icon_cdr_inbound_voicemail.png") &&
+ file_exists(dirname(__DIR__, 2)."/themes/".$settings->get('domain', 'template', 'default')."/images/icon_cdr_inbound_answered.png") &&
+ file_exists(dirname(__DIR__, 2)."/themes/".$settings->get('domain', 'template', 'default')."/images/icon_cdr_outbound_failed.png") &&
+ file_exists(dirname(__DIR__, 2)."/themes/".$settings->get('domain', 'template', 'default')."/images/icon_cdr_outbound_answered.png")
) {
$title_mod = null;
echo "
\n";
echo "\n";
echo " ".$text['label-hold_music']."\n";
diff --git a/app/extensions/resources/classes/extension.php b/app/extensions/resources/classes/extension.php
index 6614da2950..80bb722df3 100644
--- a/app/extensions/resources/classes/extension.php
+++ b/app/extensions/resources/classes/extension.php
@@ -658,7 +658,7 @@ class extension {
}
//include ring group destinations, if exists
- if (file_exists($_SERVER["PROJECT_ROOT"] . "/app/ring_groups/app_config.php")) {
+ if (file_exists(dirname(__DIR__, 4) . "/app/ring_groups/app_config.php")) {
$array['ring_group_destinations'][$x]['destination_number'] = $extensions[$x]['extension'];
$array['ring_group_destinations'][$x]['domain_uuid'] = $this->domain_uuid;
if (is_numeric($extensions[$x]['number_alias'])) {
@@ -669,7 +669,7 @@ class extension {
}
//include extension settings, if exists
- if (file_exists($_SERVER["PROJECT_ROOT"] . "/app/extension_settings/app_config.php")) {
+ if (file_exists(dirname(__DIR__, 4) . "/app/extension_settings/app_config.php")) {
$array['extension_settings'][$x]['extension_uuid'] = $record['uuid'];
$array['extension_settings'][$x]['domain_uuid'] = $this->domain_uuid;
}
@@ -849,7 +849,7 @@ class extension {
//write the provision files
if (!empty($this->settings->get('provision', 'path'))) {
- if (is_dir($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/app/provision')) {
+ if (is_dir(dirname(__DIR__, 4) . '/app/provision')) {
$prov = new provision;
$prov->domain_uuid = $this->domain_uuid;
$response = $prov->write();
diff --git a/app/extensions/resources/dashboard/caller_id.php b/app/extensions/resources/dashboard/caller_id.php
index 126ce00f91..b6a4f46114 100644
--- a/app/extensions/resources/dashboard/caller_id.php
+++ b/app/extensions/resources/dashboard/caller_id.php
@@ -46,7 +46,7 @@
//validate the token
$token = new token;
- if (!$token->validate($_SERVER["DOCUMENT_ROOT"].'/extensions/resources/dashboard/caller_id.php')) {
+ if (!$token->validate(dirname(__DIR__, 4).'/extensions/resources/dashboard/caller_id.php')) {
message::add($text['message-invalid_token'],'negative');
header('Location: /core/dashboard/');
exit;
@@ -166,7 +166,7 @@
//create token
$object = new token;
- $token = $object->create($_SERVER["DOCUMENT_ROOT"].'/extensions/resources/dashboard/caller_id.php');
+ $token = $object->create(dirname(__DIR__, 4).'/extensions/resources/dashboard/caller_id.php');
//caller id
echo "\n";
diff --git a/app/fax/fax_send.php b/app/fax/fax_send.php
index ca48202f5f..69856b71cc 100644
--- a/app/fax/fax_send.php
+++ b/app/fax/fax_send.php
@@ -438,8 +438,8 @@ if (!function_exists('fax_split_dtmf')) {
$logo = $settings->get('fax','cover_logo');
}
else if (substr($settings->get('fax','cover_logo'), 0, 1) == '/') {
- if (substr($settings->get('fax','cover_logo'), 0, strlen($_SERVER['DOCUMENT_ROOT'])) != $_SERVER['DOCUMENT_ROOT']) {
- $logo = $_SERVER['DOCUMENT_ROOT'].$settings->get('fax','cover_logo');
+ if (substr($settings->get('fax','cover_logo'), 0, strlen(dirname(__DIR__, 2))) != dirname(__DIR__, 2)) {
+ $logo = dirname(__DIR__, 2).$settings->get('fax','cover_logo');
}
else {
$logo = $settings->get('fax','cover_logo');
diff --git a/app/fax_queue/resources/job/fax_queue.php b/app/fax_queue/resources/job/fax_queue.php
index 9c422dc42e..3e8ba45ab9 100644
--- a/app/fax_queue/resources/job/fax_queue.php
+++ b/app/fax_queue/resources/job/fax_queue.php
@@ -149,12 +149,12 @@
unset($parameters);
//change the working directory
- chdir($_SERVER['DOCUMENT_ROOT']);
+ chdir(dirname(__DIR__, 4));
//process the messages
if (is_array($fax_queue) && @sizeof($fax_queue) != 0) {
foreach($fax_queue as $row) {
- $command = PHP_BINARY." ".$_SERVER['DOCUMENT_ROOT']."/app/fax_queue/resources/job/fax_send.php ";
+ $command = PHP_BINARY." ".dirname(__DIR__, 4)."/app/fax_queue/resources/job/fax_send.php ";
$command .= "'action=send&fax_queue_uuid=".$row["fax_queue_uuid"]."&hostname=".$hostname."&debug=true'";
if (isset($debug)) {
//run process inline to see debug info
diff --git a/app/fax_queue/resources/service/fax_queue.php b/app/fax_queue/resources/service/fax_queue.php
index 7abf4cf321..91fce1e05d 100644
--- a/app/fax_queue/resources/service/fax_queue.php
+++ b/app/fax_queue/resources/service/fax_queue.php
@@ -141,7 +141,7 @@
}
//change the working directory
- chdir($_SERVER['DOCUMENT_ROOT']);
+ chdir(dirname(__DIR__, 4));
//get the messages waiting in the fax queue
while (true) {
@@ -195,7 +195,7 @@
//process the messages
if (is_array($fax_queue) && @sizeof($fax_queue) != 0) {
foreach($fax_queue as $row) {
- $command = PHP_BINARY." ".$_SERVER['DOCUMENT_ROOT']."/app/fax_queue/resources/job/fax_send.php ";
+ $command = PHP_BINARY." ".dirname(__DIR__, 4)."/app/fax_queue/resources/job/fax_send.php ";
$command .= "'action=send&fax_queue_uuid=".$row["fax_queue_uuid"]."&hostname=".$hostname."'";
if (isset($debug)) {
//run process inline to see debug info
diff --git a/app/music_on_hold/app_defaults.php b/app/music_on_hold/app_defaults.php
index 2b94682f52..b131245d52 100644
--- a/app/music_on_hold/app_defaults.php
+++ b/app/music_on_hold/app_defaults.php
@@ -51,7 +51,7 @@ if ($domains_processed == 1) {
if ($num_rows == 0) {
//set the alternate directory
- $xml_file_alt = $_SERVER["DOCUMENT_ROOT"].'/'.PROJECT_PATH.'/app/switch/resources/conf/autoload_configs/local_stream.conf';
+ $xml_file_alt = dirname(__DIR__, 2).'/'.PROJECT_PATH.'/app/switch/resources/conf/autoload_configs/local_stream.conf';
//load the xml and save it into an array
if (file_exists($xml_file)) {
diff --git a/app/music_on_hold/resources/classes/switch_music_on_hold.php b/app/music_on_hold/resources/classes/switch_music_on_hold.php
index b3175fe1dd..220c60b06c 100644
--- a/app/music_on_hold/resources/classes/switch_music_on_hold.php
+++ b/app/music_on_hold/resources/classes/switch_music_on_hold.php
@@ -153,7 +153,7 @@ class switch_music_on_hold {
$select .= " \n";
}
//recordings
- if (is_dir($_SERVER["PROJECT_ROOT"] . '/app/recordings')) {
+ if (is_dir(dirname(__DIR__, 4) . '/app/recordings')) {
$recordings_c = new switch_recordings;
$recordings = $recordings_c->list_recordings();
if (is_array($recordings) && sizeof($recordings) > 0) {
@@ -165,7 +165,7 @@ class switch_music_on_hold {
}
}
//streams
- if (is_dir($_SERVER["PROJECT_ROOT"] . '/app/streams')) {
+ if (is_dir(dirname(__DIR__, 4) . '/app/streams')) {
$sql = "select * from v_streams ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and stream_enabled = 'true' ";
@@ -246,7 +246,7 @@ class switch_music_on_hold {
if (file_exists('/usr/share/examples/fusionpbx')) {
$file_contents = file_get_contents("/usr/share/examples/fusionpbx/resources/templates/conf/autoload_configs/local_stream.conf.xml");
} else {
- $file_contents = file_get_contents($_SERVER["PROJECT_ROOT"] . "/app/switch/resources/conf/autoload_configs/local_stream.conf.xml");
+ $file_contents = file_get_contents(dirname(__DIR__, 4) . "/app/switch/resources/conf/autoload_configs/local_stream.conf.xml");
}
//check where the default music is stored
$default_moh_prefix = 'music/default';
diff --git a/app/provision/index.php b/app/provision/index.php
index b8091c1103..c24816c257 100644
--- a/app/provision/index.php
+++ b/app/provision/index.php
@@ -498,7 +498,7 @@
closelog();
//device logs
- if (file_exists($_SERVER["PROJECT_ROOT"]."/app/device_logs/app_config.php")){
+ if (file_exists(dirname(__DIR__, 2)."/app/device_logs/app_config.php")){
require_once "app/device_logs/resources/device_logs.php";
}
diff --git a/app/provision/resources/classes/provision.php b/app/provision/resources/classes/provision.php
index 65ff46c93b..7e8dd7ef7d 100644
--- a/app/provision/resources/classes/provision.php
+++ b/app/provision/resources/classes/provision.php
@@ -110,7 +110,7 @@ class provision {
} elseif (file_exists('/etc/fusionpbx/resources/templates/provision')) {
$this->template_dir = '/etc/fusionpbx/resources/templates/provision';
} else {
- $this->template_dir = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/resources/templates/provision';
+ $this->template_dir = dirname(__DIR__, 4) . '/resources/templates/provision';
}
}
} elseif (PHP_OS == "FreeBSD") {
@@ -121,23 +121,23 @@ class provision {
} elseif (file_exists('/usr/local/etc/fusionpbx/resources/templates/provision')) {
$this->template_dir = '/usr/local/etc/fusionpbx/resources/templates/provision';
} else {
- $this->template_dir = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/resources/templates/provision';
+ $this->template_dir = dirname(__DIR__, 4) . '/resources/templates/provision';
}
}
} elseif (PHP_OS == "NetBSD") {
//set the default template_dir
if (empty($this->template_dir)) {
- $this->template_dir = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/resources/templates/provision';
+ $this->template_dir = dirname(__DIR__, 4) . '/resources/templates/provision';
}
} elseif (PHP_OS == "OpenBSD") {
//set the default template_dir
if (empty($this->template_dir)) {
- $this->template_dir = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/resources/templates/provision';
+ $this->template_dir = dirname(__DIR__, 4) . '/resources/templates/provision';
}
} else {
//set the default template_dir
if (empty($this->template_dir)) {
- $this->template_dir = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/resources/templates/provision';
+ $this->template_dir = dirname(__DIR__, 4) . '/resources/templates/provision';
}
}
diff --git a/app/registrations/resources/dashboard/registrations.php b/app/registrations/resources/dashboard/registrations.php
index c91e27be7a..f10045ad49 100644
--- a/app/registrations/resources/dashboard/registrations.php
+++ b/app/registrations/resources/dashboard/registrations.php
@@ -26,7 +26,7 @@
//registration count
$active_registrations = 0;
- if ($esl->is_connected() && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/registrations/")) {
+ if ($esl->is_connected() && file_exists(dirname(__DIR__, 4)."/app/registrations/")) {
$registration = new registrations;
if (permission_exists("registration_all")) {
$active_registrations = $registration->show = 'all';
diff --git a/app/switch/resources/classes/ringbacks.php b/app/switch/resources/classes/ringbacks.php
index b854c5919d..8ba38bf2c3 100644
--- a/app/switch/resources/classes/ringbacks.php
+++ b/app/switch/resources/classes/ringbacks.php
@@ -155,16 +155,16 @@ class ringbacks {
$this->tones_list = $tones->tones_list();
//get music on hold and recordings
- if (is_dir($_SERVER["PROJECT_ROOT"] . '/app/music_on_hold')) {
+ if (is_dir(dirname(__DIR__, 4) . '/app/music_on_hold')) {
$music = new switch_music_on_hold;
$this->music_list = $music->get();
}
- if (is_dir($_SERVER["PROJECT_ROOT"] . '/app/recordings')) {
+ if (is_dir(dirname(__DIR__, 4) . '/app/recordings')) {
$recordings = new switch_recordings;
$this->recordings_list = $recordings->list_recordings();
}
- if (is_dir($_SERVER["PROJECT_ROOT"] . '/app/streams')) {
+ if (is_dir(dirname(__DIR__, 4) . '/app/streams')) {
$sql = "select * from v_streams ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and stream_enabled = 'true' ";
diff --git a/app/switch/resources/classes/switch_files.php b/app/switch/resources/classes/switch_files.php
index 2b183e1e2d..dfe106b619 100644
--- a/app/switch/resources/classes/switch_files.php
+++ b/app/switch/resources/classes/switch_files.php
@@ -84,7 +84,7 @@ class switch_files {
} elseif (file_exists('/var/www/fusionpbx/app/switch/resources/scripts')) {
$source_directory = '/var/www/fusionpbx/app/switch/resources/scripts';
} else {
- $source_directory = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/app/switch/resources/scripts';
+ $source_directory = dirname(__DIR__, 4) . '/app/switch/resources/scripts';
}
//get the destination directory
@@ -103,7 +103,7 @@ class switch_files {
unset($source_directory);
//copy the app/*/resource/install/scripts
- $app_scripts = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . 'app/*/resource/scripts');
+ $app_scripts = glob(dirname(__DIR__, 4) . 'app/*/resource/scripts');
foreach ($app_scripts as $app_script) {
recursive_copy($app_script, $destination_directory);
}
@@ -131,7 +131,7 @@ class switch_files {
} elseif (file_exists('/var/www/fusionpbx/app/switch/resources/conf/languages')) {
$source_directory = '/var/www/fusionpbx/app/switch/resources/conf/languages';
} else {
- $source_directory = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/app/switch/resources/conf/languages';
+ $source_directory = dirname(__DIR__, 4) . '/app/switch/resources/conf/languages';
}
//get the destination directory
diff --git a/app/switch/resources/dashboard/switch_status.php b/app/switch/resources/dashboard/switch_status.php
index 9fff85aacc..eb9358e375 100644
--- a/app/switch/resources/dashboard/switch_status.php
+++ b/app/switch/resources/dashboard/switch_status.php
@@ -73,7 +73,7 @@
//registration count
$registrations = '';
- if (permission_exists('switch_registrations') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/registrations/")) {
+ if (permission_exists('switch_registrations') && file_exists(dirname(__DIR__, 4)."/app/registrations/")) {
$registration = new registrations;
if (permission_exists("registration_all")) {
$registration->show = 'all';
diff --git a/app/system/resources/dashboard/system_counts.php b/app/system/resources/dashboard/system_counts.php
index 367224d279..87a72086b0 100644
--- a/app/system/resources/dashboard/system_counts.php
+++ b/app/system/resources/dashboard/system_counts.php
@@ -279,12 +279,12 @@
$hud_stat = $stats[$scope]['domains']['total'] - $stats[$scope]['domains']['disabled'];
$hud_stat_title = $text['label-active_domains'];
}
- else if (permission_exists('extension_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/extensions/")) {
+ else if (permission_exists('extension_view') && file_exists(dirname(__DIR__, 4)."/app/extensions/")) {
$onclick = "onclick=\"document.location.href='".PROJECT_PATH."/app/extensions/extensions.php'\"";
$hud_stat = $stats[$scope]['extensions']['total'] - $stats[$scope]['extensions']['disabled'];
$hud_stat_title = $text['label-active_extensions'];
}
- else if ((permission_exists('user_view') || if_group("superadmin")) && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/core/users/")) {
+ else if ((permission_exists('user_view') || if_group("superadmin")) && file_exists(dirname(__DIR__, 4)."/core/users/")) {
$onclick = "onclick=\"document.location.href='".PROJECT_PATH."/core/users/users.php'\"";
$hud_stat = $stats[$scope]['users']['total'] - $stats[$scope]['users']['disabled'];
$hud_stat_title = $text['label-active_users'];
@@ -381,7 +381,7 @@
}
//devices
- if (permission_exists('device_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/devices/")) {
+ if (permission_exists('device_view') && file_exists(dirname(__DIR__, 4)."/app/devices/")) {
$tr_link = "href='".PROJECT_PATH."/app/devices/devices.php'";
echo "
\n";
echo "".$text['label-devices']." \n";
@@ -392,7 +392,7 @@
}
//extensions
- if (permission_exists('extension_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/extensions/")) {
+ if (permission_exists('extension_view') && file_exists(dirname(__DIR__, 4)."/app/extensions/")) {
$tr_link = "href='".PROJECT_PATH."/app/extensions/extensions.php'";
echo " \n";
echo "".$text['label-extensions']." \n";
@@ -403,7 +403,7 @@
}
//gateways
- if (permission_exists('gateway_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/gateways/")) {
+ if (permission_exists('gateway_view') && file_exists(dirname(__DIR__, 4)."/app/gateways/")) {
$tr_link = "href='".PROJECT_PATH."/app/gateways/gateways.php'";
echo " \n";
echo "".$text['label-gateways']." \n";
@@ -414,7 +414,7 @@
}
//users
- if ((permission_exists('user_view') || if_group("superadmin")) && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/core/users/")) {
+ if ((permission_exists('user_view') || if_group("superadmin")) && file_exists(dirname(__DIR__, 4)."/core/users/")) {
$tr_link = "href='".PROJECT_PATH."/core/users/users.php'";
echo " \n";
echo "".$text['label-users']." \n";
@@ -425,7 +425,7 @@
}
//destinations
- if (permission_exists('destination_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/destinations/")) {
+ if (permission_exists('destination_view') && file_exists(dirname(__DIR__, 4)."/app/destinations/")) {
$tr_link = "href='".PROJECT_PATH."/app/destinations/destinations.php'";
echo " \n";
echo "".$text['label-destinations']." \n";
@@ -436,7 +436,7 @@
}
//call center queues
- if (permission_exists('call_center_active_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/call_centers/")) {
+ if (permission_exists('call_center_active_view') && file_exists(dirname(__DIR__, 4)."/app/call_centers/")) {
$tr_link = "href='".PROJECT_PATH."/app/call_centers/call_center_queues.php'";
echo " \n";
echo "".$text['label-call_center_queues']." \n";
@@ -447,7 +447,7 @@
}
//ivr menus
- if (permission_exists('ivr_menu_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/ivr_menus/")) {
+ if (permission_exists('ivr_menu_view') && file_exists(dirname(__DIR__, 4)."/app/ivr_menus/")) {
$tr_link = "href='".PROJECT_PATH."/app/ivr_menus/ivr_menus.php'";
echo " \n";
echo "".$text['label-ivr_menus']." \n";
@@ -458,7 +458,7 @@
}
//ring groups
- if (permission_exists('ring_group_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/ring_groups/")) {
+ if (permission_exists('ring_group_view') && file_exists(dirname(__DIR__, 4)."/app/ring_groups/")) {
$tr_link = "href='".PROJECT_PATH."/app/ring_groups/ring_groups.php'";
echo " \n";
echo "".$text['label-ring_groups']." \n";
@@ -469,7 +469,7 @@
}
//voicemails
- if (permission_exists('voicemail_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/voicemails/")) {
+ if (permission_exists('voicemail_view') && file_exists(dirname(__DIR__, 4)."/app/voicemails/")) {
$tr_link = "href='".PROJECT_PATH."/app/voicemails/voicemails.php'";
echo " \n";
echo "".$text['label-voicemail']." \n";
@@ -480,7 +480,7 @@
}
//messages
- if (permission_exists('voicemail_message_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/voicemails/")) {
+ if (permission_exists('voicemail_message_view') && file_exists(dirname(__DIR__, 4)."/app/voicemails/")) {
echo " \n";
echo "".$text['label-item']." \n";
echo "".$text['label-new']." \n";
diff --git a/app/system/resources/functions/system_information.php b/app/system/resources/functions/system_information.php
index 2fba947344..48209ca620 100644
--- a/app/system/resources/functions/system_information.php
+++ b/app/system/resources/functions/system_information.php
@@ -261,7 +261,7 @@
//disk_free_space returns the number of bytes available on the drive;
//1 kilobyte = 1024 byte
//1 megabyte = 1024 kilobyte
- $drive_letter = substr($_SERVER["DOCUMENT_ROOT"], 0, 2);
+ $drive_letter = substr(dirname(__DIR__, 4), 0, 2);
$disk_size = round(disk_total_space($drive_letter) / 1024 / 1024, 2);
$disk_size_free = round(disk_free_space($drive_letter) / 1024 / 1024, 2);
$disk_percent_available = round(($disk_size_free / $disk_size) * 100, 2);
@@ -309,7 +309,7 @@
}
//memcache information
- if (permission_exists("system_view_memcache") && file_exists($_SERVER["PROJECT_ROOT"] . "/app/sip_status/app_config.php")) {
+ if (permission_exists("system_view_memcache") && file_exists(dirname(__DIR__, 4) . "/app/sip_status/app_config.php")) {
$memcache_fail = true;
$mod = new modules;
if ($mod->active("mod_memcache")) {
diff --git a/app/system/system.php b/app/system/system.php
index 94a0aa0516..6b23d5e3f3 100644
--- a/app/system/system.php
+++ b/app/system/system.php
@@ -339,7 +339,7 @@ Con Portions created by the Initial Developer are Copyright (C) 2008-2025
//disk_free_space returns the number of bytes available on the drive;
//1 kilobyte = 1024 byte
//1 megabyte = 1024 kilobyte
- $drive_letter = substr($_SERVER["DOCUMENT_ROOT"], 0, 2);
+ $drive_letter = substr(dirname(__DIR__, 2), 0, 2);
$disk_size = round(disk_total_space($drive_letter)/1024/1024, 2);
$disk_size_free = round(disk_free_space($drive_letter)/1024/1024, 2);
$disk_percent_available = round(($disk_size_free/$disk_size) * 100, 2);
@@ -437,7 +437,7 @@ Con Portions created by the Initial Developer are Copyright (C) 2008-2025
}
//memcache information
- if (permission_exists("system_view_memcache") && file_exists($_SERVER["PROJECT_ROOT"]."/app/sip_status/app_config.php")){
+ if (permission_exists("system_view_memcache") && file_exists(dirname(__DIR__, 2)."/app/sip_status/app_config.php")){
echo "\n";
echo "
\n";
echo " \n";
diff --git a/app/voicemails/resources/dashboard/voicemails.php b/app/voicemails/resources/dashboard/voicemails.php
index 1a7fb9b2cc..5bac02b912 100644
--- a/app/voicemails/resources/dashboard/voicemails.php
+++ b/app/voicemails/resources/dashboard/voicemails.php
@@ -24,7 +24,7 @@
$widget_label = $text['label-'.$widget_key] ?? $widget_name;
//used for missed and recent calls
- $theme_image_path = $_SERVER["DOCUMENT_ROOT"]."/themes/".$settings->get('domain', 'template', 'default')."/images/";
+ $theme_image_path = dirname(__DIR__, 4)."/themes/".$settings->get('domain', 'template', 'default')."/images/";
//voicemail
echo "\n";
diff --git a/app/voicemails/voicemail_edit.php b/app/voicemails/voicemail_edit.php
index 54299e272b..005173006d 100644
--- a/app/voicemails/voicemail_edit.php
+++ b/app/voicemails/voicemail_edit.php
@@ -828,7 +828,7 @@
echo "\n";
echo "
\n";
- if (permission_exists('voicemail_sms_edit') && file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH.'/app/sms/')) {
+ if (permission_exists('voicemail_sms_edit') && file_exists(dirname(__DIR__, 2).'/app/sms/')) {
echo "\n";
echo "\n";
echo " ".$text['label-voicemail_sms_to']."\n";
diff --git a/app/xml_cdr/resources/classes/xml_cdr.php b/app/xml_cdr/resources/classes/xml_cdr.php
index 34dc1a549f..9334309483 100644
--- a/app/xml_cdr/resources/classes/xml_cdr.php
+++ b/app/xml_cdr/resources/classes/xml_cdr.php
@@ -1584,7 +1584,7 @@ class xml_cdr {
|| '+' . ($value['destination_prefix'] ?? '') . ($value['destination_area_code'] ?? '') . $value['destination_number'] == $detail_action
|| ($value['destination_prefix'] ?? '') . ($value['destination_area_code'] ?? '') . $value['destination_number'] == $detail_action
|| ($value['destination_area_code'] ?? '') . $value['destination_number'] == $detail_action) {
- if (file_exists($_SERVER["PROJECT_ROOT"] . "/app/" . $application . "/app_languages.php")) {
+ if (file_exists(dirname(__DIR__, 4) . "/app/" . $application . "/app_languages.php")) {
$value['application'] = $application;
return $value;
}
@@ -1593,7 +1593,7 @@ class xml_cdr {
//find all other matching actions
if (!empty($value['extension']) && $value['extension'] == $detail_action || preg_match('/^' . preg_quote($value['extension'] ?? '') . '$/', $detail_action)) {
- if (file_exists($_SERVER["PROJECT_ROOT"] . "/app/" . $application . "/app_languages.php")) {
+ if (file_exists(dirname(__DIR__, 4) . "/app/" . $application . "/app_languages.php")) {
$value['application'] = $application;
return $value;
}
diff --git a/app/xml_cdr/xml_cdr.php b/app/xml_cdr/xml_cdr.php
index b3a352550a..a8e39d2432 100644
--- a/app/xml_cdr/xml_cdr.php
+++ b/app/xml_cdr/xml_cdr.php
@@ -833,7 +833,7 @@
if (is_array($result)) {
//determine if theme images exist
- $theme_image_path = $_SERVER["DOCUMENT_ROOT"]."/themes/".$settings->get('domain', 'template', 'default')."/images/";
+ $theme_image_path = dirname(__DIR__, 2)."/themes/".$settings->get('domain', 'template', 'default')."/images/";
$theme_cdr_images_exist = (
file_exists($theme_image_path."icon_cdr_inbound_answered.png") &&
file_exists($theme_image_path."icon_cdr_inbound_no_answer.png") &&
diff --git a/core/authentication/resources/classes/plugins/database.php b/core/authentication/resources/classes/plugins/database.php
index e52107bf0c..65881bc46b 100644
--- a/core/authentication/resources/classes/plugins/database.php
+++ b/core/authentication/resources/classes/plugins/database.php
@@ -106,7 +106,7 @@ class plugin_database {
//initialize a template object
$view = new template();
$view->engine = 'smarty';
- $view->template_dir = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/core/authentication/resources/views/';
+ $view->template_dir = dirname(__DIR__, 5) . '/core/authentication/resources/views/';
$view->cache_dir = sys_get_temp_dir();
$view->init();
@@ -210,7 +210,7 @@ class plugin_database {
$user_authorized = false;
//check if contacts app exists
- $contacts_exists = file_exists($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/core/contacts/') ? true : false;
+ $contacts_exists = file_exists(dirname(__DIR__, 5) . '/core/contacts/') ? true : false;
//check the username and password if they don't match then redirect to the login
$sql = "select ";
diff --git a/core/authentication/resources/classes/plugins/email.php b/core/authentication/resources/classes/plugins/email.php
index 6a960b446e..dd118295f2 100644
--- a/core/authentication/resources/classes/plugins/email.php
+++ b/core/authentication/resources/classes/plugins/email.php
@@ -101,7 +101,7 @@ class plugin_email {
//initialize a template object
$view = new template();
$view->engine = 'smarty';
- $view->template_dir = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/core/authentication/resources/views/';
+ $view->template_dir = dirname(__DIR__, 5) . '/core/authentication/resources/views/';
$view->cache_dir = sys_get_temp_dir();
$view->init();
@@ -335,7 +335,7 @@ class plugin_email {
//initialize a template object
$view = new template();
$view->engine = 'smarty';
- $view->template_dir = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/core/authentication/resources/views/';
+ $view->template_dir = dirname(__DIR__, 5) . '/core/authentication/resources/views/';
$view->cache_dir = sys_get_temp_dir();
$view->init();
@@ -416,7 +416,7 @@ class plugin_email {
unset($_POST['authentication_code']);
//check if contacts app exists
- $contacts_exists = file_exists($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/core/contacts/') ? true : false;
+ $contacts_exists = file_exists(dirname(__DIR__, 5) . '/core/contacts/') ? true : false;
//get the user details
if ($auth_valid) {
diff --git a/core/authentication/resources/classes/plugins/ldap.php b/core/authentication/resources/classes/plugins/ldap.php
index 514a933c2c..e53847c1ed 100644
--- a/core/authentication/resources/classes/plugins/ldap.php
+++ b/core/authentication/resources/classes/plugins/ldap.php
@@ -72,7 +72,7 @@ class plugin_ldap {
//initialize a template object
$view = new template();
$view->engine = 'smarty';
- $view->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/core/authentication/resources/views/';
+ $view->template_dir = dirname(__DIR__, 5).'/core/authentication/resources/views/';
$view->cache_dir = sys_get_temp_dir();
$view->init();
diff --git a/core/authentication/resources/classes/plugins/totp.php b/core/authentication/resources/classes/plugins/totp.php
index b214ef8ce1..8490a72484 100644
--- a/core/authentication/resources/classes/plugins/totp.php
+++ b/core/authentication/resources/classes/plugins/totp.php
@@ -113,7 +113,7 @@ class plugin_totp {
//initialize a template object
$view = new template();
$view->engine = 'smarty';
- $view->template_dir = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/core/authentication/resources/views/';
+ $view->template_dir = dirname(__DIR__, 5) . '/core/authentication/resources/views/';
$view->cache_dir = sys_get_temp_dir();
$view->init();
@@ -214,7 +214,7 @@ class plugin_totp {
//initialize a template object
$view = new template();
$view->engine = 'smarty';
- $view->template_dir = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/core/authentication/resources/views/';
+ $view->template_dir = dirname(__DIR__, 5) . '/core/authentication/resources/views/';
$view->cache_dir = sys_get_temp_dir();
$view->init();
@@ -347,7 +347,7 @@ class plugin_totp {
unset($_POST['authentication_code']);
//check if contacts app exists
- $contacts_exists = file_exists($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/core/contacts/') ? true : false;
+ $contacts_exists = file_exists(dirname(__DIR__, 5) . '/core/contacts/') ? true : false;
//get the user details
if ($auth_valid) {
diff --git a/core/contacts/contact_view.php b/core/contacts/contact_view.php
index 64b85710b4..9994ab86d4 100644
--- a/core/contacts/contact_view.php
+++ b/core/contacts/contact_view.php
@@ -253,10 +253,10 @@
}
echo button::create(['type'=>'button','label'=>$text['button-qr_code'],'icon'=>'qrcode','collapse'=>'hide-sm-dn','onclick'=>"$('#qr_code_container').fadeIn(400);"]);
echo button::create(['type'=>'button','label'=>$text['button-vcard'],'icon'=>'address-card','collapse'=>'hide-sm-dn','link'=>'contacts_vcard.php?id='.urlencode($contact_uuid).'&type=download']);
- if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/invoices')) {
+ if (is_dir(dirname(__DIR__, 2).'/app/invoices')) {
echo button::create(['type'=>'button','label'=>$text['button-invoices'],'icon'=>'file-invoice-dollar','collapse'=>'hide-sm-dn','link'=>'../invoices/invoices.php?id='.urlencode($contact_uuid)]);
}
- if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/certificates')) {
+ if (is_dir(dirname(__DIR__, 2).'/app/certificates')) {
echo button::create(['type'=>'button','label'=>$text['button-certificate'],'icon'=>'certificate','collapse'=>'hide-sm-dn','link'=>'../certificates/index.php?name='.urlencode($contact_name_given." ".$contact_name_family)]);
}
if (!empty($contact_user_uuid) && permission_exists('user_edit') && is_uuid($contact_user_uuid)) {
diff --git a/core/contacts/contacts_vcard.php b/core/contacts/contacts_vcard.php
index 30d8e77e03..04be8aa61e 100644
--- a/core/contacts/contacts_vcard.php
+++ b/core/contacts/contacts_vcard.php
@@ -201,7 +201,7 @@ if (!empty($_GET)) {
}
//include
- require_once $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/qr/qrcode.php";
+ require_once dirname(__DIR__, 2)."/resources/qr/qrcode.php";
//error correction level
//QR_ERROR_CORRECT_LEVEL_L : $e = 0;
diff --git a/core/dashboard/app_defaults.php b/core/dashboard/app_defaults.php
index 89a777a920..1f791f06ea 100644
--- a/core/dashboard/app_defaults.php
+++ b/core/dashboard/app_defaults.php
@@ -174,7 +174,7 @@ if ($domains_processed == 1) {
unset($sql, $parameters);
//add the dashboards
- $dashboard_config_file = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/core/dashboard/resources/dashboard/config.php');
+ $dashboard_config_file = glob(dirname(__DIR__, 2).'/core/dashboard/resources/dashboard/config.php');
$x = 0;
foreach($dashboard_config_file as $file) {
include ($file);
@@ -224,7 +224,7 @@ if ($domains_processed == 1) {
unset($sql, $parameters);
//add the dashboard widgets
- $config_files = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/*/*/resources/dashboard/config.php');
+ $config_files = glob(dirname(__DIR__, 2).'/*/*/resources/dashboard/config.php');
$x = 0;
foreach($config_files as $file) {
include ($file);
diff --git a/core/dashboard/dashboard_widget_edit.php b/core/dashboard/dashboard_widget_edit.php
index 621be57f7c..fb9bb88389 100644
--- a/core/dashboard/dashboard_widget_edit.php
+++ b/core/dashboard/dashboard_widget_edit.php
@@ -523,7 +523,7 @@
//build the $widget_tools array
$i = 0;
- foreach(glob($_SERVER["DOCUMENT_ROOT"].'/*/*/resources/dashboard/*.php') as $value) {
+ foreach(glob(dirname(__DIR__, 2).'/*/*/resources/dashboard/*.php') as $value) {
//skip adding config.php to the array
if (basename($value) === 'config.php') {
@@ -534,14 +534,14 @@
$value = str_replace('\\', '/', $value);
//prepare the key
- $key_replace[] = $_SERVER["DOCUMENT_ROOT"].'/core/';
- $key_replace[] = $_SERVER["DOCUMENT_ROOT"].'/app/';
+ $key_replace[] = dirname(__DIR__, 2).'/core/';
+ $key_replace[] = dirname(__DIR__, 2).'/app/';
$key_replace[] = 'resources/dashboard/';
$key_replace[] = '.php';
$key = str_replace($key_replace, '', $value);
//prepare the value
- $value_replace[] = $_SERVER["DOCUMENT_ROOT"].'/';
+ $value_replace[] = dirname(__DIR__, 2).'/';
$value = str_replace($value_replace, '', $value);
//build the array
@@ -847,8 +847,8 @@ document.addEventListener('DOMContentLoaded', function() {
echo " \n";
echo " ".$text['label-icon']." \n";
echo " \n";
- if (file_exists($_SERVER["PROJECT_ROOT"].'/resources/fontawesome/fa_icons.php')) {
- include $_SERVER["PROJECT_ROOT"].'/resources/fontawesome/fa_icons.php';
+ if (file_exists(dirname(__DIR__, 2).'/resources/fontawesome/fa_icons.php')) {
+ include dirname(__DIR__, 2).'/resources/fontawesome/fa_icons.php';
}
if (!empty($font_awesome_icons) && is_array($font_awesome_icons)) {
echo "\n";
diff --git a/core/default_settings/default_setting_edit.php b/core/default_settings/default_setting_edit.php
index 8d054e6b70..21b119601d 100644
--- a/core/default_settings/default_setting_edit.php
+++ b/core/default_settings/default_setting_edit.php
@@ -397,8 +397,8 @@
elseif ($category == "domain" && $subcategory == "template" && $name == "name" ) {
echo " \n";
//add all the themes to the list
- $theme_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes';
- if ($handle = opendir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes')) {
+ $theme_dir = dirname(__DIR__, 2).'/themes';
+ if ($handle = opendir(dirname(__DIR__, 2).'/themes')) {
while (false !== ($dir_name = readdir($handle))) {
if ($dir_name != "." && $dir_name != ".." && $dir_name != ".svn" && $dir_name != ".git" && is_dir($theme_dir.'/'.$dir_name)) {
$dir_label = str_replace('_', ' ', $dir_name);
diff --git a/core/default_settings/default_settings.php b/core/default_settings/default_settings.php
index 586957f835..1717577287 100644
--- a/core/default_settings/default_settings.php
+++ b/core/default_settings/default_settings.php
@@ -212,7 +212,7 @@
//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) {
include($config_path);
diff --git a/core/domain_settings/domain_setting_edit.php b/core/domain_settings/domain_setting_edit.php
index 188f1db302..4062fe067e 100644
--- a/core/domain_settings/domain_setting_edit.php
+++ b/core/domain_settings/domain_setting_edit.php
@@ -481,8 +481,8 @@
echo " \n";
echo " \n";
//add all the themes to the list
- $theme_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes';
- if ($handle = opendir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes')) {
+ $theme_dir = dirname(__DIR__, 2).'/themes';
+ if ($handle = opendir(dirname(__DIR__, 2).'/themes')) {
while (false !== ($dir_name = readdir($handle))) {
if ($dir_name != "." && $dir_name != ".." && $dir_name != ".svn" && $dir_name != ".git" && is_dir($theme_dir.'/'.$dir_name)) {
$dir_label = str_replace('_', ' ', $dir_name);
diff --git a/core/domains/domain_edit.php b/core/domains/domain_edit.php
index c98d741840..41846d2b92 100644
--- a/core/domains/domain_edit.php
+++ b/core/domains/domain_edit.php
@@ -472,7 +472,7 @@
}
//if single-tenant and variables exist, update variables > domain value to match new domain
- if (count($_SESSION['domains']) == 1 && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/vars/")) {
+ if (count($_SESSION['domains']) == 1 && file_exists(dirname(__DIR__, 2)."/app/vars/")) {
$sql = "update v_vars set ";
$sql .= "var_value = :var_value ";
$sql .= "where var_name = 'domain' ";
diff --git a/core/domains/domain_json.php b/core/domains/domain_json.php
index 104a85bdc3..732142dd6b 100644
--- a/core/domains/domain_json.php
+++ b/core/domains/domain_json.php
@@ -74,7 +74,7 @@
}
//get the domains
- if (file_exists($_SERVER["PROJECT_ROOT"]."/app/domains/app_config.php") && !is_cli()){
+ if (file_exists(dirname(__DIR__, 2)."/app/domains/app_config.php") && !is_cli()){
require_once "app/domains/resources/domains.php";
}
diff --git a/core/domains/domains.php b/core/domains/domains.php
index 68562b408b..bc0f3053d4 100644
--- a/core/domains/domains.php
+++ b/core/domains/domains.php
@@ -30,7 +30,7 @@
require_once "resources/paging.php";
//redirect admin to app instead
- if (file_exists($_SERVER["PROJECT_ROOT"]."/app/domains/app_config.php") && !permission_exists('domain_all') && !is_cli()) {
+ if (file_exists(dirname(__DIR__, 2)."/app/domains/app_config.php") && !permission_exists('domain_all') && !is_cli()) {
header("Location: ".PROJECT_PATH."/app/domains/domains.php");
exit;
}
diff --git a/core/groups/resources/classes/permission.php b/core/groups/resources/classes/permission.php
index ca17356555..48d8c5f533 100644
--- a/core/groups/resources/classes/permission.php
+++ b/core/groups/resources/classes/permission.php
@@ -64,7 +64,7 @@ class permission {
function delete() {
//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__, 4) . "/*/*/app_config.php");
$x = 0;
foreach ($config_list as $config_path) {
include($config_path);
@@ -165,7 +165,7 @@ class permission {
$this->database_group_permissions = $this->database->select($sql, null, 'all');
//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__, 4) . "/*/*/app_config.php");
$x = 0;
foreach ($config_list as $config_path) {
include($config_path);
diff --git a/core/install/install.php b/core/install/install.php
index 2b22ef070d..8b42615455 100644
--- a/core/install/install.php
+++ b/core/install/install.php
@@ -27,8 +27,8 @@
//set the include path
$document_root = dirname(__DIR__, 2);
set_include_path($document_root);
- $_SERVER["DOCUMENT_ROOT"] = $document_root;
- $_SERVER["PROJECT_ROOT"] = $document_root;
+
+//defined for backwards compatibility
define("PROJECT_PATH", '');
//includes files
@@ -172,7 +172,7 @@
sleep(1);
//add the database schema
- $output = shell_exec('cd '.$_SERVER["DOCUMENT_ROOT"].' && php /var/www/fusionpbx/core/upgrade/upgrade_schema.php');
+ $output = shell_exec('cd '.dirname(__DIR__, 2).' && php /var/www/fusionpbx/core/upgrade/upgrade_schema.php');
//connect to the database
$database = new database;
@@ -222,7 +222,7 @@
$_SESSION['domain_name'] = $domain_name;
//app defaults
- $output = shell_exec('cd '.$_SERVER["DOCUMENT_ROOT"].' && php /var/www/fusionpbx/core/upgrade/upgrade_domains.php');
+ $output = shell_exec('cd '.dirname(__DIR__, 2).' && php /var/www/fusionpbx/core/upgrade/upgrade_domains.php');
//prepare the user settings
$admin_username = $_SESSION['install']['admin_username'];
@@ -306,7 +306,7 @@
}
#app defaults
- $output = shell_exec('cd '.$_SERVER["DOCUMENT_ROOT"].' && php /var/www/fusionpbx/core/upgrade/upgrade_domains.php');
+ $output = shell_exec('cd '.dirname(__DIR__, 2).' && php /var/www/fusionpbx/core/upgrade/upgrade_domains.php');
//install completed - prompt the user to login
header("Location: /logout.php");
@@ -330,7 +330,7 @@
//initialize a template object
$view = new template();
$view->engine = 'smarty';
- $view->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/core/install/resources/views/';
+ $view->template_dir = dirname(__DIR__, 2).'/core/install/resources/views/';
$view->cache_dir = sys_get_temp_dir();
$view->init();
diff --git a/core/install/resources/classes/install.php b/core/install/resources/classes/install.php
index e9ff59c3d1..d3388c7a09 100644
--- a/core/install/resources/classes/install.php
+++ b/core/install/resources/classes/install.php
@@ -72,7 +72,7 @@ class install {
$system_drive = getenv('SystemDrive');
$config_path = $system_drive . DIRECTORY_SEPARATOR . 'ProgramData' . DIRECTORY_SEPARATOR . 'fusionpbx';
$config_file = $config_path . DIRECTORY_SEPARATOR . 'config.conf';
- $document_root = $_SERVER["DOCUMENT_ROOT"];
+ $document_root = dirname(__DIR__, 4);
$conf_dir = $_SERVER['ProgramFiles'] . DIRECTORY_SEPARATOR . 'freeswitch' . DIRECTORY_SEPARATOR . 'conf';
$sounds_dir = $_SERVER['ProgramFiles'] . DIRECTORY_SEPARATOR . 'freeswitch' . DIRECTORY_SEPARATOR . 'sounds';
@@ -82,7 +82,7 @@ class install {
$voicemail_dir = $_SERVER['ProgramFiles'] . DIRECTORY_SEPARATOR . 'freeswitch' . DIRECTORY_SEPARATOR . 'voicemail';
$scripts_dir = $_SERVER['ProgramFiles'] . DIRECTORY_SEPARATOR . 'freeswitch' . DIRECTORY_SEPARATOR . 'scripts';
$php_dir = dirname(PHP_BINARY);
- $cache_location = dirname($_SERVER['DOCUMENT_ROOT']) . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'fusionpbx';
+ $cache_location = dirname(dirname(__DIR__, 4)) . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'fusionpbx';
break;
}
diff --git a/core/menu/menu_item_edit.php b/core/menu/menu_item_edit.php
index 37d57e5bdd..6efa71b4a0 100644
--- a/core/menu/menu_item_edit.php
+++ b/core/menu/menu_item_edit.php
@@ -423,8 +423,8 @@
echo " ";
echo " ".$text['label-icon']." ";
echo " ";
- if (file_exists($_SERVER["PROJECT_ROOT"].'/resources/fontawesome/fa_icons.php')) {
- include $_SERVER["PROJECT_ROOT"].'/resources/fontawesome/fa_icons.php';
+ if (file_exists(dirname(__DIR__, 2).'/resources/fontawesome/fa_icons.php')) {
+ include dirname(__DIR__, 2).'/resources/fontawesome/fa_icons.php';
}
if (!empty($font_awesome_icons) && is_array($font_awesome_icons)) {
echo "\n";
diff --git a/core/upgrade/index.php b/core/upgrade/index.php
index 79989632e8..e65712ed0e 100644
--- a/core/upgrade/index.php
+++ b/core/upgrade/index.php
@@ -54,7 +54,7 @@
$language = $settings->get('domain', 'language', 'en-us');
//find optional apps with repos
- $updateable_repos = git_find_repos($_SERVER["PROJECT_ROOT"]."/app");
+ $updateable_repos = git_find_repos(dirname(__DIR__, 2)."/app");
if (!empty($updateable_repos) && is_array($updateable_repos) && @sizeof($updateable_repos) != 0) {
foreach ($updateable_repos as $app_path => $repo) {
//set the value
@@ -97,7 +97,7 @@
//run source update
if (!empty($action["upgrade_source"]) && permission_exists("upgrade_source") && !is_dir("/usr/share/examples/fusionpbx")) {
- $project_update_status = git_pull($_SERVER["PROJECT_ROOT"]);
+ $project_update_status = git_pull(dirname(__DIR__, 2));
$_SESSION["response"]["upgrade_source"] = $project_update_status['message'];
@@ -289,7 +289,7 @@
echo " ";
echo "\n";
- if (permission_exists("upgrade_source") && !is_dir("/usr/share/examples/fusionpbx") && is_writeable($_SERVER["PROJECT_ROOT"]."/.git")) {
+ if (permission_exists("upgrade_source") && !is_dir("/usr/share/examples/fusionpbx") && is_writeable(dirname(__DIR__, 2)."/.git")) {
echo "
\n";
echo "\n";
echo " \n";
@@ -318,7 +318,7 @@
echo " \n";
echo " ".$text['description-upgrade_source']." \n";
//show current git version info
- chdir($_SERVER["PROJECT_ROOT"]);
+ chdir(dirname(__DIR__, 2));
exec("git rev-parse --abbrev-ref HEAD 2>&1", $git_current_branch, $branch_return_value);
$git_current_branch = $git_current_branch[0];
exec("git log --pretty=format:'%H' -n 1 2>&1", $git_current_commit, $commit_return_value);
diff --git a/core/upgrade/upgrade.php b/core/upgrade/upgrade.php
index 55869c929b..b00a011657 100644
--- a/core/upgrade/upgrade.php
+++ b/core/upgrade/upgrade.php
@@ -67,7 +67,7 @@
$system_drive = getenv('SystemDrive');
$config_path = $system_drive . DIRECTORY_SEPARATOR . 'ProgramData' . DIRECTORY_SEPARATOR . 'fusionpbx' ;
$config_file = $config_path.DIRECTORY_SEPARATOR.'config.conf';
- $document_root = $_SERVER["DOCUMENT_ROOT"];
+ $document_root = dirname(__DIR__, 2);
$conf_dir = $_SERVER['ProgramFiles'].DIRECTORY_SEPARATOR.'freeswitch'.DIRECTORY_SEPARATOR.'conf';
$sounds_dir = $_SERVER['ProgramFiles'].DIRECTORY_SEPARATOR.'freeswitch'.DIRECTORY_SEPARATOR.'sounds';
@@ -77,7 +77,7 @@
$voicemail_dir = $_SERVER['ProgramFiles'].DIRECTORY_SEPARATOR.'freeswitch'.DIRECTORY_SEPARATOR.'voicemail';
$scripts_dir = $_SERVER['ProgramFiles'].DIRECTORY_SEPARATOR.'freeswitch'.DIRECTORY_SEPARATOR.'scripts';
$php_dir = dirname(PHP_BINARY);
- $cache_location = dirname($_SERVER['DOCUMENT_ROOT']).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.'fusionpbx';
+ $cache_location = dirname(dirname(__DIR__, 2)).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.'fusionpbx';
}
//make the config directory
diff --git a/core/upgrade/upgrade_domains.php b/core/upgrade/upgrade_domains.php
index 69525db3a0..3425f782d6 100644
--- a/core/upgrade/upgrade_domains.php
+++ b/core/upgrade/upgrade_domains.php
@@ -28,7 +28,6 @@
if(defined('STDIN')) {
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
- $_SERVER["DOCUMENT_ROOT"] = $document_root;
$display_type = 'text'; //html, text
}
else if (!$included) {
diff --git a/core/user_settings/user_setting_edit.php b/core/user_settings/user_setting_edit.php
index f78c1190ff..17deb515a5 100644
--- a/core/user_settings/user_setting_edit.php
+++ b/core/user_settings/user_setting_edit.php
@@ -446,8 +446,8 @@ if (!empty($_POST) && empty($_POST["persistformvar"])) {
echo " \n";
echo " \n";
//add all the themes to the list
- $theme_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes';
- if ($handle = opendir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes')) {
+ $theme_dir = dirname(__DIR__, 2).'/themes';
+ if ($handle = opendir(dirname(__DIR__, 2).'/themes')) {
while (false !== ($dir_name = readdir($handle))) {
if ($dir_name != "." && $dir_name != ".." && $dir_name != ".svn" && $dir_name != ".git" && is_dir($theme_dir.'/'.$dir_name)) {
$dir_label = str_replace('_', ' ', $dir_name);
diff --git a/core/users/app_defaults.php b/core/users/app_defaults.php
index c9b6313b7c..62138c0954 100644
--- a/core/users/app_defaults.php
+++ b/core/users/app_defaults.php
@@ -163,7 +163,7 @@ if ($domains_processed == 1) {
}
//insert default password reset email template
- if (file_exists($_SERVER['DOCUMENT_ROOT'].'/app/email_templates')) {
+ if (file_exists(dirname(__DIR__, 2).'/app/email_templates')) {
//add the email templates to the database
$sql = "select count(*) as num_rows from v_email_templates ";
diff --git a/core/users/user_edit.php b/core/users/user_edit.php
index 006c61fb38..b6963df21b 100644
--- a/core/users/user_edit.php
+++ b/core/users/user_edit.php
@@ -578,7 +578,7 @@
settings::clear_cache();
//if call center installed
- if ($action == 'edit' && permission_exists('user_edit') && file_exists($_SERVER["PROJECT_ROOT"]."/app/call_centers/app_config.php")) {
+ if ($action == 'edit' && permission_exists('user_edit') && file_exists(dirname(__DIR__, 2)."/app/call_centers/app_config.php")) {
//get the call center agent uuid
$sql = "select call_center_agent_uuid from v_call_center_agents ";
$sql .= "where domain_uuid = :domain_uuid ";
diff --git a/core/users/user_profile.php b/core/users/user_profile.php
index 8514a89717..3501d69bb2 100644
--- a/core/users/user_profile.php
+++ b/core/users/user_profile.php
@@ -464,7 +464,7 @@
settings::clear_cache();
//if call center installed
- if ($action == 'edit' && file_exists($_SERVER["PROJECT_ROOT"]."/app/call_centers/app_config.php")) {
+ if ($action == 'edit' && file_exists(dirname(__DIR__, 2)."/app/call_centers/app_config.php")) {
//get the call center agent uuid
$sql = "select call_center_agent_uuid from v_call_center_agents ";
$sql .= "where domain_uuid = :domain_uuid ";
diff --git a/index.php b/index.php
index c1de9c7434..8a69fbe85a 100644
--- a/index.php
+++ b/index.php
@@ -32,7 +32,7 @@
if (!empty($settings->get('login', 'destination'))) {
header("Location: ".$settings->get('login', 'destination'));
}
- elseif (file_exists($_SERVER["PROJECT_ROOT"]."/core/dashboard/app_config.php")) {
+ elseif (file_exists(__DIR__."/core/dashboard/app_config.php")) {
header("Location: ".PROJECT_PATH."/core/dashboard/");
}
else {
@@ -42,7 +42,7 @@
}
else {
//use custom index, if present, otherwise use custom login, if present, otherwise use default login
- if (file_exists($_SERVER["PROJECT_ROOT"]."/themes/".($settings->get('domain', 'template') ?? '')."/index.php")) {
+ if (file_exists(__DIR__."/themes/".($settings->get('domain', 'template') ?? '')."/index.php")) {
require_once "themes/".$settings->get('domain', 'template', 'default')."/index.php";
}
else {
diff --git a/resources/check_auth.php b/resources/check_auth.php
index d008f2444b..4e7ff6e10b 100644
--- a/resources/check_auth.php
+++ b/resources/check_auth.php
@@ -167,7 +167,7 @@
header("Location: ".$settings->get('login', 'destination', ''));
exit;
}
- elseif (file_exists($_SERVER["PROJECT_ROOT"]."/core/dashboard/app_config.php")) {
+ elseif (file_exists(dirname(__DIR__, 1)."/core/dashboard/app_config.php")) {
header("Location: ".PROJECT_PATH."/core/dashboard/");
exit;
}
diff --git a/resources/classes/captcha.php b/resources/classes/captcha.php
index d6a976d10c..afdce9845d 100644
--- a/resources/classes/captcha.php
+++ b/resources/classes/captcha.php
@@ -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';
diff --git a/resources/classes/config.php b/resources/classes/config.php
index 52ede00e29..de16e30bb0 100644
--- a/resources/classes/config.php
+++ b/resources/classes/config.php
@@ -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;
/**
diff --git a/resources/classes/database.php b/resources/classes/database.php
index 8c2857097d..ed3b522f04 100644
--- a/resources/classes/database.php
+++ b/resources/classes/database.php
@@ -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) {
diff --git a/resources/classes/domains.php b/resources/classes/domains.php
index 9407ada73b..33c56b2deb 100644
--- a/resources/classes/domains.php
+++ b/resources/classes/domains.php
@@ -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);
diff --git a/resources/classes/email.php b/resources/classes/email.php
index 278c0eea4b..1d92e2ec99 100644
--- a/resources/classes/email.php
+++ b/resources/classes/email.php
@@ -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
diff --git a/resources/classes/groups.php b/resources/classes/groups.php
index f11c076f3a..b4d09210e7 100644
--- a/resources/classes/groups.php
+++ b/resources/classes/groups.php
@@ -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);
diff --git a/resources/classes/menu.php b/resources/classes/menu.php
index 483a498782..6fc5330f08 100644
--- a/resources/classes/menu.php
+++ b/resources/classes/menu.php
@@ -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) {
diff --git a/resources/classes/schema.php b/resources/classes/schema.php
index 22f9a29dd4..6abe4eeac1 100644
--- a/resources/classes/schema.php
+++ b/resources/classes/schema.php
@@ -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 {
diff --git a/resources/classes/sounds.php b/resources/classes/sounds.php
index fce92e31c2..a274bfae97 100644
--- a/resources/classes/sounds.php
+++ b/resources/classes/sounds.php
@@ -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) {
diff --git a/resources/classes/text.php b/resources/classes/text.php
index bf2b6a7d67..b69eef618f 100644
--- a/resources/classes/text.php
+++ b/resources/classes/text.php
@@ -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";
diff --git a/resources/fontawesome/fa_icons.php b/resources/fontawesome/fa_icons.php
index 558cea25d0..4fad2cd48c 100644
--- a/resources/fontawesome/fa_icons.php
+++ b/resources/fontawesome/fa_icons.php
@@ -29,8 +29,8 @@ require_once dirname(__DIR__, 2) . "/resources/require.php";
//load icons
$font_awesome_icons = [];
-if (file_exists($_SERVER["PROJECT_ROOT"].'/resources/fontawesome/metadata/icons.json')) {
- $icons_json = file_get_contents($_SERVER["PROJECT_ROOT"].'/resources/fontawesome/metadata/icons.json');
+if (file_exists(dirname(__DIR__, 2).'/resources/fontawesome/metadata/icons.json')) {
+ $icons_json = file_get_contents(dirname(__DIR__, 2).'/resources/fontawesome/metadata/icons.json');
if (!empty($icons_json)) {
$icons_array = json_decode($icons_json, true);
if (!empty($icons_array) && is_array($icons_array)) {
diff --git a/resources/footer.php b/resources/footer.php
index d45d87c1e9..e8c983848e 100644
--- a/resources/footer.php
+++ b/resources/footer.php
@@ -46,10 +46,10 @@
$body = ob_get_contents();
ob_end_clean(); //clean the buffer
-//set a default template
+//set the default template
if (empty($_SESSION["template_full_path"])) { //build template if session template has no length
//set the template base path
- $template_base_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes';
+ $template_base_path = dirname(__DIR__, 1).'/themes';
//get the contents of the template and save it to the template variable
$template_full_path = $template_base_path.'/'.$settings->get('domain', 'template', 'default').'/template.php';
@@ -185,7 +185,7 @@
$authenticated = isset($_SESSION['username']) && !empty($_SESSION['username']) ? true : false;
$view->assign('authenticated', $authenticated);
//domains application path
- $view->assign('domains_app_path', PROJECT_PATH.(file_exists($_SERVER['DOCUMENT_ROOT'].'/app/domains/domains.php') ? '/app/domains/domains.php' : '/core/domains/domains.php'));
+ $view->assign('domains_app_path', PROJECT_PATH.(file_exists(dirname(__DIR__, 1).'/app/domains/domains.php') ? '/app/domains/domains.php' : '/core/domains/domains.php'));
//domain count
$view->assign('domain_count', $domain_count);
//domain selector row background colors
@@ -289,7 +289,7 @@
//session timer
if ($authenticated &&
- file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH.'/app/session_timer/session_timer.php') &&
+ file_exists(dirname(__DIR__, 1).'/app/session_timer/session_timer.php') &&
$settings->get('security', 'session_timer_enabled', false)
) {
include_once PROJECT_PATH.'app/session_timer/session_timer.php';
diff --git a/resources/functions.php b/resources/functions.php
index 2870e3f75e..edf41c6022 100644
--- a/resources/functions.php
+++ b/resources/functions.php
@@ -2457,7 +2457,7 @@ if (!function_exists('import_fonts')) {
correctly.
*/
- $file = file_get_contents($_SERVER["DOCUMENT_ROOT"] . $file_to_parse);
+ $file = file_get_contents(dirname(__DIR__, 1) . $file_to_parse);
$lines = explode("\n", $file);
$style_counter = 0;
diff --git a/resources/header.php b/resources/header.php
index 185caeed59..76e2efb9fa 100644
--- a/resources/header.php
+++ b/resources/header.php
@@ -54,7 +54,7 @@
}
//set the template base directory path
- $template_base_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes';
+ $template_base_path = dirname(__DIR__, 1).'/themes';
//start the output buffer
include $template_base_path.'/'.$settings->get('domain', 'template', 'default').'/config.php';
@@ -111,7 +111,7 @@
ob_start();
//for translate tool (if available)
- if (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/translate/translate_header.php")) {
+ if (file_exists(dirname(__DIR__, 1)."/app/translate/translate_header.php")) {
require_once("app/translate/translate_header.php");
}
diff --git a/resources/pdo.php b/resources/pdo.php
index 74671b4ecb..a9b6d3ef81 100644
--- a/resources/pdo.php
+++ b/resources/pdo.php
@@ -105,7 +105,7 @@ if ($db_type == "sqlite") {
//set the document_root
if (empty($document_root)) {
- $document_root = $_SERVER["DOCUMENT_ROOT"];
+ $document_root = dirname(__DIR__, 1);
}
//prepare the database connection
diff --git a/resources/require.php b/resources/require.php
index e98bb5add2..e4cbf6dc78 100644
--- a/resources/require.php
+++ b/resources/require.php
@@ -77,8 +77,8 @@
//debug info
//echo "Include Path: ".get_include_path()."\n";
- //echo "Document Root: ".$_SERVER["DOCUMENT_ROOT"]."\n";
- //echo "Project Root: ".$_SERVER["PROJECT_ROOT"]."\n";
+ //echo "Document Root: ".dirname(__DIR__, 1)."\n";
+ //echo "Project Root: ".dirname(__DIR__, 1)."\n";
//include global functions
@@ -130,7 +130,7 @@
if (!empty($_GET["domain_uuid"]) && is_uuid($_GET["domain_uuid"]) && !empty($_GET["domain_change"]) && $_GET["domain_change"] == "true" && permission_exists('domain_select')) {
//include domains
- if (file_exists($_SERVER["PROJECT_ROOT"]."/app/domains/app_config.php") && !permission_exists('domain_all')) {
+ if (file_exists(dirname(__DIR__, 1)."/app/domains/app_config.php") && !permission_exists('domain_all')) {
include_once "app/domains/domains.php";
}
diff --git a/resources/switch.php b/resources/switch.php
index b53e8b850f..8410fadd23 100644
--- a/resources/switch.php
+++ b/resources/switch.php
@@ -834,7 +834,7 @@ if (!function_exists('save_call_center_xml')) {
$path = "/usr/share/examples/fusionpbx/resources/templates/conf";
}
else {
- $path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/switch/resources/conf";
+ $path = dirname(__DIR__, 1)."/app/switch/resources/conf";
}
//get the contents of the template
@@ -878,7 +878,7 @@ if (!function_exists('switch_conf_xml')) {
$path = "/usr/share/examples/fusionpbx/resources/templates/conf";
}
else {
- $path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/switch/resources/conf";
+ $path = dirname(__DIR__, 1)."/app/switch/resources/conf";
}
$file_contents = file_get_contents($path."/autoload_configs/switch.conf.xml");
@@ -889,7 +889,7 @@ if (!function_exists('switch_conf_xml')) {
$php_bin = 'php.exe';
}
- $secure_path = path_join($_SERVER["DOCUMENT_ROOT"], PROJECT_PATH, 'secure');
+ $secure_path = path_join(dirname(__DIR__, 1), PROJECT_PATH, 'secure');
$v_mail_bat = path_join($secure_path, 'mailto.bat');
$v_mail_cmd = '@' .
@@ -906,7 +906,7 @@ if (!function_exists('switch_conf_xml')) {
}
else {
if (file_exists(PHP_BINDIR.'/php')) { define("PHP_BIN", "php"); }
- $v_mailer_app = PHP_BINDIR."/".PHP_BIN." ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/v_mailto.php";
+ $v_mailer_app = PHP_BINDIR."/".PHP_BIN." ".dirname(__DIR__, 1)."/secure/v_mailto.php";
$v_mailer_app_args = "-t";
}
@@ -939,7 +939,7 @@ if (!function_exists('xml_cdr_conf_xml')) {
$path = "/usr/share/examples/fusionpbx/resources/templates/conf";
}
else {
- $path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/switch/resources/conf";
+ $path = dirname(__DIR__, 1)."/app/switch/resources/conf";
}
$file_contents = file_get_contents($path."/autoload_configs/xml_cdr.conf.xml");
@@ -1008,10 +1008,10 @@ if (!function_exists('save_sip_profile_xml')) {
//get the xml sip profile template
if ($sip_profile_name == "internal" || $sip_profile_name == "external" || $sip_profile_name == "internal-ipv6") {
- $file_contents = file_get_contents($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/sip_profiles/resources/xml/sip_profiles/".$sip_profile_name.".xml");
+ $file_contents = file_get_contents(dirname(__DIR__, 1)."/app/sip_profiles/resources/xml/sip_profiles/".$sip_profile_name.".xml");
}
else {
- $file_contents = file_get_contents($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/sip_profiles/resources/xml/sip_profiles/default.xml");
+ $file_contents = file_get_contents(dirname(__DIR__, 1)."/app/sip_profiles/resources/xml/sip_profiles/default.xml");
}
//get the sip profile settings
@@ -1063,33 +1063,33 @@ if (!function_exists('save_switch_xml')) {
global $settings;
if (is_readable($settings->get('switch', 'extensions'))) {
- if (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/extensions/resources/classes/extension.php")) {
+ if (file_exists(dirname(__DIR__, 1)."/app/extensions/resources/classes/extension.php")) {
$extension = new extension;
$extension->xml();
}
}
if (is_readable($settings->get('switch', 'conf'))) {
- if (file_exists($_SERVER["PROJECT_ROOT"]."/app/settings/app_config.php")) {
+ if (file_exists(dirname(__DIR__, 1)."/app/settings/app_config.php")) {
save_setting_xml();
}
- if (file_exists($_SERVER["PROJECT_ROOT"]."/app/modules/app_config.php")) {
+ if (file_exists(dirname(__DIR__, 1)."/app/modules/app_config.php")) {
$module = new modules;
$module->xml();
//$msg = $module->msg;
}
- if (file_exists($_SERVER["PROJECT_ROOT"]."/app/vars/app_config.php")) {
+ if (file_exists(dirname(__DIR__, 1)."/app/vars/app_config.php")) {
save_var_xml();
}
- if (file_exists($_SERVER["PROJECT_ROOT"]."/app/call_center/app_config.php")) {
+ if (file_exists(dirname(__DIR__, 1)."/app/call_center/app_config.php")) {
save_call_center_xml();
}
- if (file_exists($_SERVER["PROJECT_ROOT"]."/app/gateways/app_config.php")) {
+ if (file_exists(dirname(__DIR__, 1)."/app/gateways/app_config.php")) {
save_gateway_xml();
}
- //if (file_exists($_SERVER["PROJECT_ROOT"]."/app/ivr_menu/app_config.php")) {
+ //if (file_exists(dirname(__DIR__, 1)."/app/ivr_menu/app_config.php")) {
// save_ivr_menu_xml();
//}
- if (file_exists($_SERVER["PROJECT_ROOT"]."/app/sip_profiles/app_config.php")) {
+ if (file_exists(dirname(__DIR__, 1)."/app/sip_profiles/app_config.php")) {
save_sip_profile_xml();
}
}
diff --git a/secure/v_mailto.php b/secure/v_mailto.php
index 80652768b0..b3f272c941 100644
--- a/secure/v_mailto.php
+++ b/secure/v_mailto.php
@@ -77,8 +77,8 @@
//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__, 1)."/app/emails/email_transcription.php")) {
+ // require_once(dirname(__DIR__, )."/app/emails/email_transcription.php");
//}
//parse the email
diff --git a/themes/default/app_defaults.php b/themes/default/app_defaults.php
index bf0c0110a8..9dc12d8b3c 100644
--- a/themes/default/app_defaults.php
+++ b/themes/default/app_defaults.php
@@ -29,7 +29,7 @@
//get the background images
$relative_path = PROJECT_PATH.'/themes/default/images/backgrounds';
- $backgrounds = opendir($_SERVER["DOCUMENT_ROOT"].'/'.$relative_path);
+ $backgrounds = opendir(dirname(__DIR__, 2).'/'.$relative_path);
unset($array);
$x = 0;
while (false !== ($file = readdir($backgrounds))) {
diff --git a/themes/default/css.php b/themes/default/css.php
index e518d155bb..39cbe6ec9d 100644
--- a/themes/default/css.php
+++ b/themes/default/css.php
@@ -446,9 +446,9 @@ if ($background_images_enabled) {
}
if ($image_source == 'folder') {
- if (file_exists($_SERVER["DOCUMENT_ROOT"].$source_path)) {
+ if (file_exists(dirname(__DIR__, 2).$source_path)) {
//retrieve a random background image
- $dir_list = opendir($_SERVER["DOCUMENT_ROOT"].$source_path);
+ $dir_list = opendir(dirname(__DIR__, 2).$source_path);
$v_background_array = array();
$x = 0;
while (false !== ($file = readdir($dir_list))) {