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 " "; diff --git a/app/call_broadcast/call_broadcast_edit.php b/app/call_broadcast/call_broadcast_edit.php index 95378d4181..d5fdd55ba4 100644 --- a/app/call_broadcast/call_broadcast_edit.php +++ b/app/call_broadcast/call_broadcast_edit.php @@ -124,7 +124,7 @@ function upload_file($sql, $broadcast_phone_numbers) { if (if_group("superadmin")) { $broadcast_accountcode = $_POST["broadcast_accountcode"]; } - else if (if_group("admin") && file_exists($_SERVER["PROJECT_ROOT"]."/app/billing/app_config.php")){ + else if (if_group("admin") && file_exists(dirname(__DIR__, 2)."/app/billing/app_config.php")){ $sql = "select count(*) "; $sql .= "from v_billings "; $sql .= "where domain_uuid = :domain_uuid "; diff --git a/app/conference_controls/app_defaults.php b/app/conference_controls/app_defaults.php index bb8ca9c447..22e6c81a3f 100644 --- a/app/conference_controls/app_defaults.php +++ b/app/conference_controls/app_defaults.php @@ -34,7 +34,7 @@ //set the directory $xml_dir = $settings->get('switch','conf').'/autoload_configs'; $xml_file = $xml_dir."/conference.conf"; - $xml_file_alt = $_SERVER["DOCUMENT_ROOT"].'/'.PROJECT_PATH.'/app/switch/resources/conf/autoload_configs/conference.conf'; + $xml_file_alt = dirname(__DIR__, 2).'/'.PROJECT_PATH.'/app/switch/resources/conf/autoload_configs/conference.conf'; //rename the file if (file_exists($xml_dir.'/conference.conf.xml.noload')) { diff --git a/app/conference_profiles/app_defaults.php b/app/conference_profiles/app_defaults.php index 38753f9072..68ea22d24f 100644 --- a/app/conference_profiles/app_defaults.php +++ b/app/conference_profiles/app_defaults.php @@ -34,7 +34,7 @@ //set the directory $xml_dir = $settings->get('switch','conf').'/autoload_configs'; $xml_file = $xml_dir."/conference.conf"; - $xml_file_alt = $_SERVER["DOCUMENT_ROOT"].'/'.PROJECT_PATH.'/app/switch/resources/conf/autoload_configs/conference.conf'; + $xml_file_alt = dirname(__DIR__, 2).'/'.PROJECT_PATH.'/app/switch/resources/conf/autoload_configs/conference.conf'; //rename the file if (file_exists($xml_dir.'/conference.conf.xml.noload')) { diff --git a/app/destinations/destination_edit.php b/app/destinations/destination_edit.php index 85d3b70dee..4c5213a8c6 100644 --- a/app/destinations/destination_edit.php +++ b/app/destinations/destination_edit.php @@ -2007,7 +2007,7 @@ } //hold music - if (permission_exists("destination_hold_music") && is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/music_on_hold')) { + if (permission_exists("destination_hold_music") && is_dir(dirname(__DIR__, 2).'/app/music_on_hold')) { echo "\n"; echo "\n"; echo " ".$text['label-destination_hold_music']."\n"; diff --git a/app/destinations/destinations.php b/app/destinations/destinations.php index 6f0c6693b9..1f28bfc4f6 100644 --- a/app/destinations/destinations.php +++ b/app/destinations/destinations.php @@ -100,7 +100,7 @@ if ($destination_action == $value) { if ($group == 'other') { if (!isset($language2) && !isset($text2)) { - if (file_exists($_SERVER["PROJECT_ROOT"]."/app/dialplans/app_languages.php")) { + if (file_exists(dirname(__DIR__, 2)."/app/dialplans/app_languages.php")) { $language2 = new text; $text2 = $language2->get($settings->get('domain', 'language', 'en-us'), 'app/dialplans'); } @@ -108,7 +108,7 @@ $actions[] = trim($text2['title-other'].' › '.$text2['option-'.str_replace('_','_',$key)]); } else { - if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$group."/app_languages.php")) { + if (file_exists(dirname(__DIR__, 2)."/app/".$group."/app_languages.php")) { $language3 = new text; $text3 = $language3->get($settings->get('domain', 'language', 'en-us'), 'app/'.$group); $actions[] = trim($text3['title-'.$group].' › '.$key); diff --git a/app/destinations/resources/classes/destinations.php b/app/destinations/resources/classes/destinations.php index 96c4ed0dc6..2e6c0cd1cb 100644 --- a/app/destinations/resources/classes/destinations.php +++ b/app/destinations/resources/classes/destinations.php @@ -405,7 +405,7 @@ $destination = $row['field']['destination'] ?? ''; //add multi-lingual support - if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$name."/app_languages.php")) { + if (file_exists(dirname(__DIR__, 4)."/app/".$name."/app_languages.php")) { $text2 = $language2->get($this->language, 'app/'.$name); } @@ -540,7 +540,7 @@ $selected = (isset($destination_key) && $key == $destination_key) ? "selected='selected'" : ''; //add multi-lingual support - if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$key."/app_languages.php")) { + if (file_exists(dirname(__DIR__, 4)."/app/".$key."/app_languages.php")) { $text2 = $language2->get($this->language, 'app/'.$key); $found = 'true'; } @@ -617,7 +617,7 @@ $destination = $row['field']['destination'] ?? ''; //add multi-lingual support - if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$name."/app_languages.php")) { + if (file_exists(dirname(__DIR__, 4)."/app/".$name."/app_languages.php")) { $language2 = new text; $text2 = $language2->get($this->language, 'app/'.$name); } @@ -729,7 +729,7 @@ $destination = $row['field']['destination'] ?? null; //add multi-lingual support - if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$name."/app_languages.php")) { + if (file_exists(dirname(__DIR__, 4)."/app/".$name."/app_languages.php")) { $language2 = new text; $text2 = $language2->get($this->language, 'app/'.$name); } diff --git a/app/devices/app_defaults.php b/app/devices/app_defaults.php index b4c1913c54..ad3125871e 100644 --- a/app/devices/app_defaults.php +++ b/app/devices/app_defaults.php @@ -162,7 +162,7 @@ if ($domains_processed == 1) { if ($num_rows == 0) { //get the vendor array - require_once $_SERVER["DOCUMENT_ROOT"].'/'.PROJECT_PATH.'/app/devices/app_config.php'; + require_once dirname(__DIR__, 2).'/'.PROJECT_PATH.'/app/devices/app_config.php'; //get the groups and create an array to use the name to get the uuid $sql = "select * from v_groups "; diff --git a/app/devices/device_vendor_restore.php b/app/devices/device_vendor_restore.php index 03ab1a0f8b..dffa13d215 100644 --- a/app/devices/device_vendor_restore.php +++ b/app/devices/device_vendor_restore.php @@ -61,7 +61,7 @@ //get the vendor array $x = 0; - require_once $_SERVER["DOCUMENT_ROOT"].'/'.PROJECT_PATH.'/app/devices/app_config.php'; + require_once dirname(__DIR__, 2).'/'.PROJECT_PATH.'/app/devices/app_config.php'; //get the groups and create an array to use the name to get the uuid $sql = "select * from v_groups "; diff --git a/app/devices/resources/classes/device.php b/app/devices/resources/classes/device.php index 32d05393e0..2adde4e4c7 100644 --- a/app/devices/resources/classes/device.php +++ b/app/devices/resources/classes/device.php @@ -500,7 +500,7 @@ class device { } 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") { @@ -511,23 +511,23 @@ class device { } 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/dialplans/resources/classes/dialplan.php b/app/dialplans/resources/classes/dialplan.php index 207fffd6c1..f9b1869254 100644 --- a/app/dialplans/resources/classes/dialplan.php +++ b/app/dialplans/resources/classes/dialplan.php @@ -169,7 +169,7 @@ class dialplan { $x = 0; //get the array of xml files - $xml_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/resources/switch/conf/dialplan/*.xml"); + $xml_list = glob(dirname(__DIR__, 4) . "/*/*/resources/switch/conf/dialplan/*.xml"); //add a band-aid for CLI editors with faulty syntax highlighting /* **/ @@ -1052,7 +1052,7 @@ class dialplan { public function defaults() { //get the array of xml files and then process thm - $xml_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/resources/switch/conf/dialplan/*.xml"); + $xml_list = glob(dirname(__DIR__, 4) . "/*/*/resources/switch/conf/dialplan/*.xml"); foreach ($xml_list as $xml_file) { //get and parse the xml $xml_string = file_get_contents($xml_file); diff --git a/app/email_queue/resources/jobs/email_queue.php b/app/email_queue/resources/jobs/email_queue.php index d10e2f9fc7..053e82567c 100755 --- a/app/email_queue/resources/jobs/email_queue.php +++ b/app/email_queue/resources/jobs/email_queue.php @@ -11,7 +11,7 @@ //includes files require_once "resources/pdo.php"; - require $_SERVER['DOCUMENT_ROOT']."/app/email_queue/resources/functions/transcribe.php"; + require dirname(__DIR__, 4)."/app/email_queue/resources/functions/transcribe.php"; //increase limits set_time_limit(0); @@ -134,7 +134,7 @@ //process the messages if (is_array($email_queue) && @sizeof($email_queue) != 0) { foreach($email_queue as $row) { - $command = PHP_BINARY." ".$_SERVER['DOCUMENT_ROOT']."/app/email_queue/resources/jobs/email_send.php "; + $command = PHP_BINARY." ".dirname(__DIR__, 4)."/app/email_queue/resources/jobs/email_send.php "; $command .= "'action=send&email_queue_uuid=".$row["email_queue_uuid"]."&hostname=".$hostname."'"; if (isset($debug)) { //run process inline to see debug info diff --git a/app/email_queue/resources/service/email_queue.php b/app/email_queue/resources/service/email_queue.php index 952dc6d1f1..795c6d082b 100644 --- a/app/email_queue/resources/service/email_queue.php +++ b/app/email_queue/resources/service/email_queue.php @@ -160,7 +160,7 @@ //process the messages if (is_array($email_queue) && @sizeof($email_queue) != 0) { foreach($email_queue as $row) { - $command = PHP_BINARY." ".$_SERVER['DOCUMENT_ROOT']."/app/email_queue/resources/jobs/email_send.php "; + $command = PHP_BINARY." ".dirname(__DIR__, 4)."/app/email_queue/resources/jobs/email_send.php "; $command .= "'action=send&email_queue_uuid=".$row["email_queue_uuid"]."&hostname=".$hostname."'"; if (isset($debug)) { //run process inline to see debug info diff --git a/app/extensions/extension_copy.php b/app/extensions/extension_copy.php index 16bbf880a3..721ce61e74 100644 --- a/app/extensions/extension_copy.php +++ b/app/extensions/extension_copy.php @@ -178,7 +178,7 @@ unset($array); //get the source extension voicemail data - if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/voicemails')) { + if (is_dir(dirname(__DIR__, 2).'/app/voicemails')) { //get the voicemails $sql = "select "; diff --git a/app/extensions/extension_edit.php b/app/extensions/extension_edit.php index 225d96fd76..c842adbc53 100644 --- a/app/extensions/extension_edit.php +++ b/app/extensions/extension_edit.php @@ -332,7 +332,7 @@ } //delete the line from the v_device_lines - if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/devices')) { + if (is_dir(dirname(__DIR__, 2).'/app/devices')) { if (!empty($_REQUEST["delete_type"]) && $_REQUEST["delete_type"] == "device_line" && is_uuid($_REQUEST["delete_uuid"]) && permission_exists("extension_delete")) { //set the variables $device_line_uuid = $_REQUEST["delete_uuid"]; @@ -729,7 +729,7 @@ } //add or update voicemail - if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/voicemails')) { + if (is_dir(dirname(__DIR__, 2).'/app/voicemails')) { //set the voicemail password if (empty($voicemail_password)) { $voicemail_password = generate_password($voicemail_password_length, 1); @@ -856,7 +856,7 @@ } //write the provision files - if (!empty($provision_path) && is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/provision')) { + if (!empty($provision_path) && is_dir(dirname(__DIR__, 2).'/app/provision')) { $prov = new provision; $prov->domain_uuid = $domain_uuid; $response = $prov->write(); @@ -959,7 +959,7 @@ } //get the voicemail data - if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/voicemails')) { + if (is_dir(dirname(__DIR__, 2).'/app/voicemails')) { $sql = "select * from v_voicemails "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and voicemail_id = :voicemail_id "; @@ -1329,7 +1329,7 @@ echo " "; } - if (permission_exists('voicemail_edit') && is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/voicemails')) { + if (permission_exists('voicemail_edit') && is_dir(dirname(__DIR__, 2).'/app/voicemails')) { echo "\n"; echo "\n"; echo " ".$text['label-voicemail_password']."\n"; @@ -1357,7 +1357,7 @@ } if (permission_exists('device_edit') && (empty($extension_type) || $extension_type != 'virtual')) { - if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/devices')) { + if (is_dir(dirname(__DIR__, 2).'/app/devices')) { echo "\n"; echo "\n"; echo " ".$text['label-provisioning']."\n"; @@ -1794,7 +1794,7 @@ echo "\n"; } - if (permission_exists('voicemail_edit') && is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/voicemails')) { + if (permission_exists('voicemail_edit') && is_dir(dirname(__DIR__, 2).'/app/voicemails')) { echo "\n"; echo "\n"; echo " ".$text['label-voicemail_enabled']."\n"; @@ -2040,7 +2040,7 @@ echo "\n"; } - if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/music_on_hold') && permission_exists('extension_hold_music')) { + if (is_dir(dirname(__DIR__, 2).'/app/music_on_hold') && permission_exists('extension_hold_music')) { 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 " \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 "
".$text['label-icon']."\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"; 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 " "; echo "
".$text['label-icon'].""; - 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 "