Allow namespace in auto loader (#7307)

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove class_exists wrapper for class definitions

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove include statement of class file

* remove closing tag

* remove invalid method params

* remove closing tag

* remove closing tag

* Update auto_loader to load each class file in the project
Update the auto_loader class to use an include statement on each file in the project to load the class within the file. This will allow mismatched names within the file to be loaded and mapped according to the declaration instead of the filename. The class is then checked against the parsed classes from the PHP engine so that namespaces are available and mapped to the file they were declared in. An update was also made to the search algorithm used to find a file that was not already loaded by collapsing the array to have only valid matches to increase performance on a cache miss. Logging within the auto_loader has been moved to a function.
Multiple files were modified to allow the include statement. When the class has the `if(class_exists())` statement, the auto_loader is called to check for the class. This caused an infinite loop scenario so all wrappers have been removed. The auto_loader will now break the loop by directly modifying the internal classes array instead of trying to restart with the 'reload_classes' method.

- APCu is used to cache classes so any loading of the classes is done only once. To clear the APCu cache, restart php-fpm or call the auto_loader::clear_cache() function.
- Cache file is used when APCu is not available. To clear the cache remove it from the tmp folder or call the auto_loader::clear_cache() function.
- All classes must no longer have a class_exists wrapper to benefit from the performance boost.
- Classes should not be directly included when the auto_loader is used.

* remove include statement of class file

* Update destinations.php
This commit is contained in:
frytimo 2025-03-12 16:55:47 -03:00 committed by GitHub
parent abb95e38bb
commit 08001488f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
110 changed files with 209 additions and 520 deletions

View File

@ -2,11 +2,7 @@
/**
* access controls class
*
* @method null download
*/
if (!class_exists('access_controls')) {
class access_controls {
/**
@ -264,6 +260,3 @@ if (!class_exists('access_controls')) {
}
}
}
}
?>

View File

@ -27,7 +27,6 @@
/**
* Define the operator_panel class
*/
if (!class_exists('basic_operator_panel')) {
class basic_operator_panel {
/**
@ -245,6 +244,3 @@ if (!class_exists('basic_operator_panel')) {
return $result;
}
}
}
?>

View File

@ -25,7 +25,6 @@
*/
//define the bridges class
if (!class_exists('bridges')) {
class bridges {
/**
@ -255,6 +254,3 @@ if (!class_exists('bridges')) {
}
}
}
?>

View File

@ -2,10 +2,7 @@
/**
* call block class
*
* @method null download
*/
if (!class_exists('call_block')) {
class call_block {
/**
@ -459,6 +456,3 @@ if (!class_exists('call_block')) {
} //method
} //class
}
?>

View File

@ -27,10 +27,7 @@
/**
* call broadcast class
*
* @method null download
*/
if (!class_exists('call_broadcast')) {
class call_broadcast {
/**
@ -177,6 +174,3 @@ if (!class_exists('call_broadcast')) {
}
}
}
?>

View File

@ -26,11 +26,8 @@
/**
* cache class provides an abstracted cache
*
* @method string dialplan - builds the dialplan for call center
*/
//define the call center class
if (!class_exists('call_center')) {
class call_center {
/**
* define the variables
@ -611,7 +608,6 @@
} //method
} //class
}
/*
$o = new call_center;
@ -625,5 +621,3 @@ $c->destination_number = "";
$c->queue_cc_exit_keys = "";
$c->dialplan();
*/
?>

View File

@ -27,8 +27,7 @@
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/classes/waveform.php";
use maximal\audio\Waveform;
//check permisions

View File

@ -25,7 +25,6 @@
*/
//define the call_flows class
if (!class_exists('call_flows')) {
class call_flows {
/**
@ -410,6 +409,3 @@ if (!class_exists('call_flows')) {
} //method
} //class
}
?>

View File

@ -27,7 +27,6 @@
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/classes/waveform.php";
use maximal\audio\Waveform;

View File

@ -421,7 +421,6 @@
//synchronize configuration
if (!empty($_SESSION['switch']['extensions']['dir']) && is_readable($_SESSION['switch']['extensions']['dir'])) {
require_once "app/extensions/resources/classes/extension.php";
$ext = new extension;
$ext->xml();
unset($ext);

View File

@ -248,7 +248,6 @@
//synchronize configuration
if (!empty($_SESSION['switch']['extensions']['dir']) && is_readable($_SESSION['switch']['extensions']['dir'])) {
require_once "app/extensions/resources/classes/extension.php";
$ext = new extension;
$ext->xml();
unset($ext);

View File

@ -261,7 +261,6 @@
//synchronize configuration
if (!empty($_SESSION['switch']['extensions']['dir']) && is_readable($_SESSION['switch']['extensions']['dir'])) {
require_once "app/extensions/resources/classes/extension.php";
$ext = new extension;
$ext->xml();
unset($ext);

View File

@ -426,7 +426,6 @@
//synchronize configuration
if (!empty($_SESSION['switch']['extensions']['dir']) && is_readable($_SESSION['switch']['extensions']['dir'])) {
require_once "app/extensions/resources/classes/extension.php";
$ext = new extension;
$ext->xml();
unset($ext);

View File

@ -26,10 +26,7 @@
/**
* call_recordings class
*
* @method null download
*/
if (!class_exists('call_recordings')) {
class call_recordings {
/**
@ -525,6 +522,3 @@ if (!class_exists('call_recordings')) {
}
} //class
}
?>

View File

@ -27,7 +27,6 @@
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/classes/waveform.php";
use maximal\audio\Waveform;

View File

@ -26,7 +26,6 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
*/
//define the conference centers class
if (!class_exists('conference_centers')) {
class conference_centers {
/**
@ -800,7 +799,7 @@ if (!class_exists('conference_centers')) {
} //class
}
//example conference center
/*
@ -814,5 +813,3 @@ if (!class_exists('conference_centers')) {
$result = $conference_center->rooms();
print_r($result);
*/
?>

View File

@ -27,7 +27,6 @@
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/classes/waveform.php";
use maximal\audio\Waveform;

View File

@ -26,12 +26,7 @@
/**
* conference_controls class
*
* @method null delete
* @method null toggle
* @method null copy
*/
if (!class_exists('conference_controls')) {
class conference_controls {
/**
@ -426,6 +421,3 @@ if (!class_exists('conference_controls')) {
}
}
}
?>

View File

@ -26,12 +26,7 @@
/**
* conference_profiles class
*
* @method null delete
* @method null toggle
* @method null copy
*/
if (!class_exists('conference_profiles')) {
class conference_profiles {
/**
@ -432,6 +427,3 @@ if (!class_exists('conference_profiles')) {
}
}
}
?>

View File

@ -25,7 +25,6 @@
*/
//define the conferences class
if (!class_exists('conferences')) {
class conferences {
/**
@ -374,6 +373,3 @@ if (!class_exists('conferences')) {
}
}
}
?>

View File

@ -1964,7 +1964,6 @@
echo " ".$text['label-destination_hold_music']."\n";
echo "</td>\n";
echo "<td width=\"70%\" class='vtable' align='left'>\n";
require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php";
$music_on_hold = new switch_music_on_hold;
echo $music_on_hold->select('destination_hold_music', $destination_hold_music, null);
echo " <br />\n";

View File

@ -26,11 +26,7 @@
/**
* destinations
*
* @method get_array get the destinations
* @method select build the html select
*/
if (!class_exists('destinations')) {
class destinations {
/**
@ -455,26 +451,24 @@ if (!class_exists('destinations')) {
$destination_id = str_replace("[", "_", $destination_id);
//$destination_id = preg_replace('/[^a-zA-Z_,.]/', '', $destination_name);
?>
<script type="text/javascript">
function get_destinations(id, destination_type, action, search) {
//alert(action);
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById(id).innerHTML = this.responseText;
}
};
if (action) {
xhttp.open("GET", "/app/destinations/resources/destinations.php?destination_type="+destination_type+"&action="+action, true);
}
else {
xhttp.open("GET", "/app/destinations/resources/destinations.php?destination_type="+destination_type, true);
}
xhttp.send();
}
</script>
<?php
//send request for destinations
echo "<script type=\"text/javascript\">\n";
echo " function get_destinations(id, destination_type, action, search) {\n";
echo " var xhttp = new XMLHttpRequest();\n";
echo " xhttp.onreadystatechange = function() {\n";
echo " if (this.readyState == 4 && this.status == 200) {\n";
echo " document.getElementById(id).innerHTML = this.responseText;\n";
echo " }\n";
echo " };\n";
echo " if (action) {\n";
echo " xhttp.open(\"GET\", \"/app/destinations/resources/destinations.php?destination_type=\"+destination_type+\"&action=\"+action, true);\n";
echo " }\n";
echo " else {\n";
echo " xhttp.open(\"GET\", \"/app/destinations/resources/destinations.php?destination_type=\"+destination_type, true);\n";
echo " }\n";
echo " xhttp.send();\n";
echo " }\n";
echo "</script>\n";
//get the destinations
$destinations = $this->get($destination_type);
@ -1308,7 +1302,7 @@ if (!class_exists('destinations')) {
} //method
} //class
}
/*
$obj = new destinations;
//$destinations = $obj->destinations;
@ -1319,5 +1313,3 @@ echo $obj->select('ivr', 'example4', '');
echo $obj->select('ivr', 'example5', '');
echo $obj->select('ivr', 'example6', '');
*/
?>

View File

@ -25,7 +25,6 @@
*/
//define the dialplan class
if (!class_exists('dialplan')) {
class dialplan {
//variables
@ -1580,6 +1579,3 @@
} //class
}
?>

View File

@ -2,12 +2,7 @@
/**
* email_queue class
*
* @method null delete
* @method null toggle
* @method null copy
*/
if (!class_exists('email_queue')) {
class email_queue {
/**
@ -225,6 +220,3 @@ if (!class_exists('email_queue')) {
}
}
}
?>

View File

@ -11,7 +11,6 @@
//includes files
require_once "resources/pdo.php";
include "resources/classes/permissions.php";
require $_SERVER['DOCUMENT_ROOT']."/app/email_queue/resources/functions/transcribe.php";
//increase limits

View File

@ -10,7 +10,6 @@
}
//include files
include "resources/classes/permissions.php";
include_once "resources/phpmailer/class.phpmailer.php";
include_once "resources/phpmailer/class.smtp.php";

View File

@ -9,9 +9,6 @@
exit;
}
//include files
include "resources/classes/permissions.php";
//increase limits
set_time_limit(0);
ini_set('max_execution_time', 0);

View File

@ -26,12 +26,7 @@
/**
* event_guard_logs class
*
* @method null delete
* @method null toggle
* @method null copy
*/
if (!class_exists('event_guard')) {
class event_guard {
/**
@ -303,6 +298,3 @@ if (!class_exists('event_guard')) {
}
}
}
?>

View File

@ -26,12 +26,7 @@
/**
* extension_settings class
*
* @method null delete
* @method null toggle
* @method null copy
*/
if (!class_exists('extension_settings')) {
class extension_settings {
/**
@ -272,6 +267,3 @@ if (!class_exists('extension_settings')) {
}
}
}
?>

View File

@ -186,7 +186,6 @@
//synchronize configuration
if (is_writable($_SESSION['switch']['extensions']['dir'])) {
require_once "app/extensions/resources/classes/extension.php";
$ext = new extension;
$ext->xml();
unset($ext);

View File

@ -850,7 +850,6 @@
//synchronize configuration
if (is_writable($switch_extensions)) {
require_once "app/extensions/resources/classes/extension.php";
$ext = new extension;
$ext->xml();
unset($ext);
@ -2037,7 +2036,6 @@
echo " ".$text['label-hold_music']."\n";
echo "</td>\n";
echo "<td width=\"70%\" class='vtable' align='left'>\n";
require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php";
$options = '';
$moh = new switch_music_on_hold;
echo $moh->select('hold_music', $hold_music ?? '', $options);

View File

@ -25,7 +25,6 @@
*/
//define the directory class
if (!class_exists('extension')) {
class extension {
/**
@ -795,6 +794,3 @@ if (!class_exists('extension')) {
}
}
}
?>

View File

@ -29,7 +29,6 @@
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/functions/object_to_array.php";
require_once "resources/functions/parse_message.php";
require_once "resources/classes/text.php";
//get accounts to monitor
$sql = "select d.domain_name, f.* ";

View File

@ -25,7 +25,6 @@
*/
//define the fax class
if (!class_exists('fax')) {
class fax {
/**
@ -725,7 +724,6 @@ if (!class_exists('fax')) {
}
} //class
}
/*
$o = new fax;
@ -738,5 +736,3 @@ $c->destination_number = $fax_destination_number;
$c->fax_description = $fax_description;
$c->dialplan();
*/
?>

View File

@ -26,12 +26,7 @@
/**
* fax_queue class
*
* @method null delete
* @method null toggle
* @method null copy
*/
if (!class_exists('fax_queue')) {
class fax_queue {
/**
@ -274,6 +269,3 @@ if (!class_exists('fax_queue')) {
}
}
}
}
?>

View File

@ -8,7 +8,6 @@
//includes files
require_once dirname(__DIR__, 4) . "/resources/require.php";
require_once "resources/pdo.php";
include "resources/classes/permissions.php";
//increase limits
set_time_limit(0);

View File

@ -2,12 +2,7 @@
/**
* fifo class
*
* @method null delete
* @method null toggle
* @method null copy
*/
if (!class_exists('fifo')) {
class fifo {
/**
@ -283,6 +278,3 @@ if (!class_exists('fifo')) {
}
}
}
?>

View File

@ -25,7 +25,6 @@
*/
//define the gateways class
if (!class_exists('gateways')) {
class gateways {
/**
@ -583,6 +582,3 @@ if (!class_exists('gateways')) {
}
}
}
?>

View File

@ -25,7 +25,6 @@
*/
//define the ivr_menu class
if (!class_exists('ivr_menu')) {
class ivr_menu {
/**
@ -489,6 +488,3 @@ if (!class_exists('ivr_menu')) {
}
}
}
?>

View File

@ -27,7 +27,6 @@
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/classes/waveform.php";
use maximal\audio\Waveform;

View File

@ -25,7 +25,6 @@
*/
//define the modules class
if (!class_exists('modules')) {
class modules {
/**
@ -1101,10 +1100,8 @@ if (!class_exists('modules')) {
} //class
}
/*
require_once "resources/classes/modules.php";
$mod = new modules;
$mod->dir = $_SESSION['switch']['mod']['dir'];
echo $mod->dir."\n";
@ -1138,5 +1135,3 @@ echo $mod->dir."\n";
//print_r($result);
//echo "</pre>\n";
*/
?>

View File

@ -308,7 +308,6 @@
$cache = new cache;
$cache->delete("configuration:local_stream.conf");
//require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php";
$music = new switch_music_on_hold;
$music->reload();

View File

@ -27,7 +27,6 @@
*/
//define the switch_music_on_hold class
if (!class_exists('switch_music_on_hold')) {
class switch_music_on_hold {
/**
@ -85,7 +84,6 @@ if (!class_exists('switch_music_on_hold')) {
}
//recordings
if (is_dir($_SERVER["PROJECT_ROOT"].'/app/recordings')) {
require_once "app/recordings/resources/classes/switch_recordings.php";
$recordings_c = new switch_recordings;
$recordings = $recordings_c->list_recordings();
if (is_array($recordings) && sizeof($recordings) > 0) {
@ -447,12 +445,9 @@ if (!class_exists('switch_music_on_hold')) {
} //method
} //class
}
//build and save the XML
//require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php";
//$moh = new switch_music_on_hold;
//$moh->xml();
//$moh->save();
?>

View File

@ -27,7 +27,6 @@
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/classes/waveform.php";
use maximal\audio\Waveform;

View File

@ -25,7 +25,6 @@
*/
//define the number translations class
if (!class_exists('number_translations')) {
class number_translations {
/**
@ -414,11 +413,8 @@ if (!class_exists('number_translations')) {
} //method
} //class
}
/*
$obj = new number_translations;
$obj->delete();
*/
?>

View File

@ -25,7 +25,6 @@
*/
//define the phrases class
if (!class_exists('phrases')) {
class phrases {
/**
@ -431,6 +430,3 @@ if (!class_exists('phrases')) {
} //method
} //class
}
?>

View File

@ -25,7 +25,6 @@
*/
//define the pin numbers class
if (!class_exists('pin_numbers')) {
class pin_numbers {
/**
@ -245,6 +244,3 @@ if (!class_exists('pin_numbers')) {
}
}
}
?>

View File

@ -26,7 +26,6 @@
*/
//define the switch_recordings class
if (!class_exists('switch_recordings')) {
class switch_recordings {
/**
@ -158,6 +157,3 @@ if (!class_exists('switch_recordings')) {
} //method
} //class
}
?>

View File

@ -27,7 +27,6 @@
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/classes/waveform.php";
use maximal\audio\Waveform;

View File

@ -88,7 +88,6 @@
$registrations = $obj->get($profile ?? null);
//order the array
require_once "resources/classes/array_order.php";
$order = new array_order();
$registrations = $order->sort($registrations, 'sip-auth-realm', 'user');

View File

@ -25,7 +25,6 @@
*/
//define the ring groups class
if (!class_exists('ring_groups')) {
class ring_groups {
/**
@ -512,6 +511,3 @@ if (!class_exists('ring_groups')) {
}
}
}
?>

View File

@ -27,7 +27,6 @@
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/classes/waveform.php";
use maximal\audio\Waveform;

View File

@ -25,7 +25,6 @@
*/
//define the sip profiles class
if (!class_exists('sip_profiles')) {
class sip_profiles {
/**
@ -434,6 +433,3 @@ if (!class_exists('sip_profiles')) {
}
}
}
?>

View File

@ -26,12 +26,7 @@
/**
* sofia_global_settings class
*
* @method null delete
* @method null toggle
* @method null copy
*/
if (!class_exists('sofia_global_settings')) {
class sofia_global_settings {
/**
@ -247,6 +242,3 @@ if (!class_exists('sofia_global_settings')) {
}
}
}
?>

View File

@ -25,7 +25,6 @@
*/
//define the streams class
if (!class_exists('streams')) {
class streams {
/**
@ -244,6 +243,3 @@ if (!class_exists('streams')) {
}
}
}
?>

View File

@ -23,12 +23,7 @@
/**
* presence class
*
* @method boolean active
* @method array show
*/
if (!class_exists('presence')) {
class presence {
/**
@ -84,7 +79,6 @@ if (!class_exists('presence')) {
return $array;
}
}
}
//examples
/*
@ -97,11 +91,9 @@ if (!class_exists('presence')) {
echo "active: true\n";
}
else {
echo "active: false\n";
echo "active: false\n";
}
//show active the presence
$presence = new presence;
$array = $presence->show();
*/
?>

View File

@ -25,7 +25,6 @@
Matthew Vale <github@mafoo.org>
*/
if (!class_exists('ringbacks')) {
class ringbacks {
//define variables
@ -85,18 +84,15 @@ if (!class_exists('ringbacks')) {
*/
//get the tones
require_once "resources/classes/tones.php";
$tones = new tones;
$this->tones_list = $tones->tones_list();
//get music on hold and recordings
if (is_dir($_SERVER["PROJECT_ROOT"].'/app/music_on_hold')) {
require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php";
$music = new switch_music_on_hold;
$this->music_list = $music->get();
}
if (is_dir($_SERVER["PROJECT_ROOT"].'/app/recordings')) {
require_once "app/recordings/resources/classes/switch_recordings.php";
$recordings = new switch_recordings;
$this->recordings_list = $recordings->list_recordings();
}
@ -232,6 +228,3 @@ if (!class_exists('ringbacks')) {
return $select;
}
}
}
?>

View File

@ -26,12 +26,7 @@
/**
* switch class provides methods for copying switch_files
*
* @method string correct_path
* @method string copy_scripts
* @method string copy_languages
*/
if (!class_exists('switch_files')) {
class switch_files {
/**
@ -158,7 +153,6 @@ if (!class_exists('switch_files')) {
}
}
}
/*
//example use
@ -168,5 +162,3 @@ if (!class_exists('switch_files')) {
$obj->copy_scripts();
$obj->copy_languages();
*/
?>

View File

@ -25,7 +25,6 @@
*/
//define the time conditions class
if (!class_exists('time_conditions')) {
class time_conditions {
/**
@ -346,6 +345,3 @@
} //class
}
?>

View File

@ -25,7 +25,6 @@
*/
//define the vars class
if (!class_exists('vars')) {
class vars {
/**
@ -258,6 +257,3 @@ if (!class_exists('vars')) {
}
}
}
?>

View File

@ -25,7 +25,6 @@
*/
//define the voicemail greetings class
if (!class_exists('voicemail_greetings')) {
class voicemail_greetings {
/**
@ -166,6 +165,3 @@ if (!class_exists('voicemail_greetings')) {
} //method
} //class
}
?>

View File

@ -27,7 +27,6 @@
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/classes/waveform.php";
use maximal\audio\Waveform;

View File

@ -1581,7 +1581,6 @@
}
//example voicemail messages
//require_once "app/voicemails/resources/classes/voicemail.php";
//$voicemail = new voicemail;
//$voicemail->voicemail_uuid = $voicemail_uuid;
//$voicemail->order_by = $order_by;

View File

@ -23,9 +23,6 @@
//voicemail
echo "<div class='hud_box'>\n";
//required class
require_once "app/voicemails/resources/classes/voicemail.php";
//get the voicemail
$vm = new voicemail;
$vm->domain_uuid = $_SESSION['domain_uuid'];

View File

@ -47,7 +47,6 @@
//toggle the voicemail message
$toggled = 0;
if (is_array($voicemail_messages) && sizeof($voicemail_messages) > 0) {
require_once "resources/classes/voicemail.php";
foreach ($voicemail_messages as $voicemail_uuid => $voicemail_message_uuids) {
foreach ($voicemail_message_uuids as $voicemail_message_uuid) {
if (is_uuid($voicemail_uuid) && is_uuid($voicemail_message_uuid)) {

View File

@ -27,7 +27,6 @@
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/classes/waveform.php";
use maximal\audio\Waveform;

View File

@ -26,10 +26,7 @@
/**
* xml_cdr class provides methods for adding cdr records to the database
*
* @method boolean add
*/
if (!class_exists('xml_cdr')) {
class xml_cdr {
/**
@ -2370,4 +2367,3 @@ if (!class_exists('xml_cdr')) {
}
} //class
}

View File

@ -27,7 +27,6 @@
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/classes/waveform.php";
use maximal\audio\Waveform;

View File

@ -96,7 +96,6 @@ class authentication {
//process the plugin
if (file_exists($plugin)) {
//run the plugin
include_once $plugin;
$object = new $class_name();
$object->domain_name = $this->domain_name;
$object->domain_uuid = $this->domain_uuid;

View File

@ -26,8 +26,6 @@
/**
* plugin_email
*
* @method email time based one time password authenticate the user
*/
class plugin_email {
@ -521,5 +519,3 @@ class plugin_email {
}
}
?>

View File

@ -209,5 +209,3 @@ class plugin_ldap {
return $result;
}
}
?>

View File

@ -439,5 +439,3 @@ class plugin_totp {
}
}
?>

View File

@ -42,7 +42,6 @@ if (!empty($_GET)) {
$text = $language->get();
//create the vcard object
require_once "resources/classes/vcard.php";
$vcard = new vcard();
//get the contact id

View File

@ -25,7 +25,6 @@
*/
//define the contacts class
if (!class_exists('contacts')) {
class contacts {
const APP_NAME = "contacts";
@ -277,6 +276,3 @@ if (!class_exists('contacts')) {
} //method
} //class
}
?>

View File

@ -26,12 +26,7 @@
/**
* dashboard class
*
* @method null delete
* @method null toggle
* @method null copy
*/
if (!class_exists('dashboard')) {
class dashboard {
/**
@ -247,6 +242,3 @@ if (!class_exists('dashboard')) {
}
}
}
?>

View File

@ -25,7 +25,6 @@
*/
//define the databases class
if (!class_exists('databases')) {
class databases {
/**
@ -169,6 +168,3 @@ if (!class_exists('databases')) {
}
}
}
?>

View File

@ -26,12 +26,7 @@
/**
* default_settings class
*
* @method null delete
* @method null toggle
* @method null copy
*/
if (!class_exists('default_settings')) {
class default_settings {
/**
@ -327,6 +322,3 @@ if (!class_exists('default_settings')) {
} //method
} //class
}
?>

View File

@ -25,7 +25,6 @@
*/
//define the domain settings class
if (!class_exists('domain_settings')) {
class domain_settings {
/**
@ -386,6 +385,3 @@ if (!class_exists('domain_settings')) {
} //method
} //class
}
?>

View File

@ -486,7 +486,6 @@
//recreate dialplan and extension xml files
if (is_readable($_SESSION['switch']['extensions']['dir'])) {
require_once $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/extensions/resources/classes/extension.php";
$extension = new extension;
$extension->xml();
}

View File

@ -25,7 +25,6 @@
*/
//define the email templates class
if (!class_exists('email_templates')) {
class email_templates {
/**
@ -244,6 +243,3 @@ if (!class_exists('email_templates')) {
}
}
}
?>

View File

@ -2,9 +2,6 @@
/**
* events class provides an event system
*
* @method void load_plugins
* @method dynamic __call
*/
class events {
@ -31,11 +28,7 @@ class events {
//create the database connection
//includes files
require_once dirname(__DIR__, 4) . "/resources/require.php";
//includes files
require_once "resources/classes/database.php";
$database = new database;
$database = database::new();
$database->connect();
$this->db = $database->db;
return $this->db = $database->db;

View File

@ -43,7 +43,6 @@
$text = $language->get();
//permission restore default
require_once "core/groups/resources/classes/permission.php";
$permission = new permission;
$permission->restore();

View File

@ -1,6 +1,5 @@
<?php
if (!class_exists('install')) {
class install {
/**
@ -154,7 +153,7 @@ if (!class_exists('install')) {
if(!$file_handle) { return; }
fwrite($file_handle, $conf);
fclose($file_handle);
//if the config.conf file was saved return true
if (file_exists($config_file)) {
return true;
@ -166,6 +165,3 @@ if (!class_exists('install')) {
}
}
}
?>

View File

@ -51,7 +51,6 @@
}
//menu restore default
//require_once "resources/classes/menu.php";
$menu = new menu;
$menu->menu_uuid = $menu_uuid;
$menu->menu_language = $menu_language;

View File

@ -2,10 +2,7 @@
/**
* software class
*
* @method string version
*/
if (!class_exists('software')) {
class software {
/**
@ -25,6 +22,3 @@ if (!class_exists('software')) {
}
}
}
?>

View File

@ -133,7 +133,6 @@
//load an array of the database schema and compare it with the active database
if (!empty($action["upgrade_schema"]) && permission_exists("upgrade_schema")) {
require_once "resources/classes/schema.php";
$obj = new schema();
if (isset($action["data_types"]) && $action["data_types"] == 'true') {
$obj->data_types = true;

View File

@ -189,8 +189,6 @@
//run all app_defaults.php files
if ($upgrade_type == 'domains') {
require_once "resources/classes/config.php";
require_once "resources/classes/domains.php";
$domain = new domains;
$domain->display_type = $display_type;
$domain->upgrade();
@ -199,7 +197,6 @@
//upgrade schema and/or data_types
if ($upgrade_type == 'schema') {
//get the database schema put it into an array then compare and update the database as needed.
require_once "resources/classes/schema.php";
$obj = new schema;
if (isset($argv[2]) && $argv[2] == 'data_types') {
$obj->data_types = true;

View File

@ -46,8 +46,6 @@
}
//run all app_defaults.php files
require_once "resources/classes/config.php";
require_once "resources/classes/domains.php";
$domain = new domains;
$domain->display_type = $display_type;
$domain->upgrade();

View File

@ -273,8 +273,6 @@ function do_upgrade_code_submodules() {
* Execute all app_defaults.php files
*/
function do_upgrade_domains() {
require_once dirname(__DIR__, 2) . "/resources/classes/config.php";
require_once dirname(__DIR__, 2) . "/resources/classes/domains.php";
$domain = new domains;
$domain->display_type = 'text';
$domain->upgrade();
@ -285,7 +283,6 @@ function do_upgrade_domains() {
*/
function do_upgrade_schema(bool $data_types = false) {
//get the database schema put it into an array then compare and update the database as needed.
require_once dirname(__DIR__, 2) . "/resources/classes/schema.php";
$obj = new schema;
$obj->data_types = $data_types;
echo $obj->schema('text');

View File

@ -59,7 +59,6 @@
$text = $language->get();
//get the database schema put it into an array then compare and update the database as needed.
require_once "resources/classes/schema.php";
$obj = new schema;
if (isset($argv[1]) && $argv[1] == 'data_types') {
$obj->data_types = true;

View File

@ -26,12 +26,7 @@
/**
* user_logs class
*
* @method null delete
* @method null toggle
* @method null copy
*/
if (!class_exists('user_logs')) {
class user_logs {
/**
@ -151,6 +146,3 @@ if (!class_exists('user_logs')) {
}
}
}
?>

View File

@ -25,7 +25,6 @@
*/
//define the user settings class
if (!class_exists('user_settings')) {
class user_settings {
/**
@ -181,6 +180,3 @@ if (!class_exists('user_settings')) {
} //method
} //class
}
?>

View File

@ -107,7 +107,6 @@ Mark J Crane <markjcrane@fusionpbx.com>
//revoke temporary permissions
$p->delete('user_setting_delete', 'temp');
//reset session variables to default
require "resources/classes/domains.php";
$domain = new domains();
$domain->set();
}

View File

@ -26,12 +26,7 @@
/**
* users class
*
* @method null delete
* @method null toggle
* @method null copy
*/
if (!class_exists('users')) {
class users {
/**
@ -315,6 +310,3 @@ if (!class_exists('users')) {
}
}
}
}
?>

View File

@ -1,29 +1,37 @@
<?php
/*
FusionPBX
Version: MPL 1.1
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2024
the Initial Developer. All Rights Reserved.
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
/**
* Auto Loader class
* Searches for project files when a class is required. Debugging mode can be set using:
* - export DEBUG=1
* OR
* - debug=true is appended to the url
*/
class auto_loader {
const FILE = 'autoloader_cache.php';
@ -37,11 +45,20 @@ class auto_loader {
*/
private $apcu_enabled;
/**
* Cache path and file name
* @var string
*/
private static $cache_file = null;
public function __construct($project_path = '') {
//set if we can use RAM cache
$this->apcu_enabled = function_exists('apcu_enabled') && apcu_enabled();
//set cache location
self::$cache_file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . self::FILE;
//classes must be loaded before this object is registered
if (!$this->load_cache()) {
//cache miss so load them
@ -61,12 +78,14 @@ class auto_loader {
//update RAM cache when available
if ($this->apcu_enabled) {
apcu_store(self::CACHE_KEY, $this->classes);
$success = apcu_store(self::CACHE_KEY, $this->classes);
//do not save to drive when we are using apcu
if ($success) return true;
}
//ensure we have somewhere to put the file
if (empty($file)) {
$file = sys_get_temp_dir() . '/' . self::FILE;
$file = self::$cache_file;
}
//export the classes array using PHP engine
@ -77,13 +96,10 @@ class auto_loader {
if ($result !== false) {
return true;
}
//file failed to save - send error to syslog when debugging
$error_array = error_get_last();
//send to syslog when debugging
if (!empty($_REQUEST['debug']) && $_REQUEST['debug'] == 'true') {
openlog("PHP", LOG_PID | LOG_PERROR, LOG_LOCAL0);
syslog(LOG_WARNING, "[php][auto_loader] " . $error_array['message']);
closelog();
}
self::log(LOG_WARNING, $error_array['message'] ?? '');
return false;
}
@ -99,21 +115,21 @@ class auto_loader {
//use a standard file
if (empty($file)) {
$file = sys_get_temp_dir() . '/'. self::FILE;
$file = self::$cache_file;
}
//use PHP engine to parse it
if (file_exists($file)) {
$this->classes = include $file;
}
//assign to an array
if (!empty($this->classes)) {
//cache edge case of first time using apcu cache
if ($this->apcu_enabled) {
apcu_store(self::CACHE_KEY, $this->classes);
}
return true;
//catch edge case of first time using apcu cache
if ($this->apcu_enabled) {
apcu_store(self::CACHE_KEY, $this->classes);
}
return false;
//return true when we have classes and false if the array is still empty
return !empty($this->classes);
}
public function reload_classes($project_path = '') {
@ -122,26 +138,87 @@ class auto_loader {
$project_path = dirname(__DIR__, 2);
}
//build the array of all classes
$search_path = [];
$search_path = array_merge($search_path, glob($project_path . '/resources/classes/*.php'));
$search_path = array_merge($search_path, glob($project_path . '/resources/interfaces/*.php'));
$search_path = array_merge($search_path, glob($project_path . '/resources/traits/*.php'));
$search_path = array_merge($search_path, glob($project_path . '/*/*/resources/classes/*.php'));
$search_path = array_merge($search_path, glob($project_path . '/*/*/resources/interfaces/*.php'));
$search_path = array_merge($search_path, glob($project_path . '/*/*/resources/traits/*.php'));
//build the array of all locations for classes in specific order
$search_path = [
$project_path . '/resources/interfaces/*.php',
$project_path . '/resources/traits/*.php',
$project_path . '/resources/classes/*.php',
$project_path . '/*/*/resources/interfaces/*.php',
$project_path . '/*/*/resources/traits/*.php',
$project_path . '/*/*/resources/classes/*.php',
$project_path . '/core/authentication/resources/classes/plugins/*.php',
];
//get all php files for each path
$files = [];
foreach ($search_path as $path) {
$files = array_merge($files, glob($path));
}
//reset the current array
$this->classes = [];
//store the class name (key) and the path (value)
foreach ($search_path as $path) {
$this->classes[basename($path, '.php')] = $path;
}
//store PHP language declared classes, interfaces, and traits
$curr_classes = get_declared_classes();
$curr_interfaces = get_declared_interfaces();
$curr_traits = get_declared_traits();
//store the class name (key) and the path (value)
foreach ($files as $file) {
//include the new class
try {
include_once $file;
} catch (Exception $e) {
//report the error
self::log(LOG_ERR, "Exception while trying to include file '$file': " . $e->getMessage());
continue;
}
//get the new classes
$new_classes = get_declared_classes();
$new_interfaces = get_declared_interfaces();
$new_traits = get_declared_traits();
//check for a new class
$classes = array_diff($new_classes, $curr_classes);
if (!empty($classes)) {
foreach ($classes as $class) {
$this->classes[$class] = $file;
}
//overwrite previous array with new values
$curr_classes = $new_classes;
}
//check for a new interface
$interfaces = array_diff($new_interfaces, $curr_interfaces);
if (!empty($interfaces)) {
foreach ($interfaces as $interface) {
$this->classes[$interface] = $file;
}
//overwrite previous array with new values
$curr_interfaces = $new_interfaces;
}
//check for a new trait
$traits = array_diff($new_traits, $curr_traits);
if (!empty($traits)) {
foreach ($traits as $trait) {
$this->classes[$trait] = $file;
}
//overwrite previous array with new values
$curr_traits = $new_traits;
}
}
}
private function loader($class_name) : bool {
/**
* The loader is set to private because only the PHP engine should be calling this method
* @param string $class_name The class name that needs to be loaded
* @return bool True if the class is loaded or false when the class is not found
* @access private
*/
private function loader($class_name): bool {
//sanitize the class name
$class_name = preg_replace('[^a-zA-Z0-9_]', '', $class_name);
@ -161,32 +238,29 @@ class auto_loader {
}
//cache miss
if (!empty($_REQUEST['debug']) && $_REQUEST['debug'] == 'true') {
openlog("PHP", LOG_PID | LOG_PERROR, LOG_LOCAL0);
syslog(LOG_WARNING, "[php][auto_loader] class not found in cache: ".$class_name);
closelog();
}
self::log(LOG_WARNING, "class '$class_name' not found in cache");
//set project path using magic dir constant
$project_path = dirname(__DIR__, 2);
//build the search path array
$search_path[] = glob($project_path . "/resources/classes/".$class_name.".php");
$search_path[] = glob($project_path . "/resources/interfaces/".$class_name.".php");
$search_path[] = glob($project_path . "/resources/traits/".$class_name.".php");
$search_path[] = glob($project_path . "/*/*/resources/classes/".$class_name.".php");
$search_path[] = glob($project_path . "/*/*/resources/interfaces/".$class_name.".php");
$search_path[] = glob($project_path . "/*/*/resources/traits/".$class_name.".php");
$search_path[] = glob($project_path . "/resources/interfaces/" . $class_name . ".php");
$search_path[] = glob($project_path . "/resources/traits/" . $class_name . ".php");
$search_path[] = glob($project_path . "/resources/classes/" . $class_name . ".php");
$search_path[] = glob($project_path . "/*/*/resources/interfaces/" . $class_name . ".php");
$search_path[] = glob($project_path . "/*/*/resources/traits/" . $class_name . ".php");
$search_path[] = glob($project_path . "/*/*/resources/classes/" . $class_name . ".php");
//find the path
$path = self::autoload_search($search_path);
if (!empty($path)) {
//collapse all entries to only the matched entry
$matches = array_filter($search_path);
if (!empty($matches)) {
$path = array_pop($matches)[0];
//include the class or interface
include $path;
//include the class, interface, or trait
include_once $path;
//make sure to reload the cache after we found a new class
$this->reload_classes();
//inject the class in to the array
$this->classes[$class_name] = $path;
//update the cache with new classes
$this->update_cache();
@ -196,35 +270,54 @@ class auto_loader {
}
//send to syslog when debugging
if (!empty($_REQUEST['debug']) && $_REQUEST['debug'] == 'true') {
openlog("PHP", LOG_PID | LOG_PERROR, LOG_LOCAL0);
syslog(LOG_WARNING, "[php][auto_loader] class not found name: ".$class_name);
closelog();
}
self::log(LOG_ERR, "class '$class_name' not found name");
//return boolean
return false;
}
public static function autoload_search($array) : string {
foreach($array as $path) {
if (is_array($path) && count($path) != 0) {
foreach($path as $sub_path) {
if (!empty($sub_path) && file_exists($sub_path)) {
return $sub_path;
}
}
}
elseif (!empty($path) && file_exists($path)) {
return $path;
}
/**
* Returns a list of classes loaded by the auto_loader. If no classes have been loaded an empty array is returned.
* @return array List of classes loaded by the auto_loader or empty array
*/
public function get_class_list(): array {
if (!empty($this->classes)) {
return $this->classes;
}
return '';
return [];
}
public static function clear_cache() {
public static function clear_cache(string $file = '') {
//check for apcu cache
if (function_exists('apcu_enabled') && apcu_enabled()) {
apcu_delete(self::CACHE_KEY);
}
//set default file
if (empty(self::$cache_file)) {
self::$cache_file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . self::FILE;
}
//set file to clear
if (empty($file)) {
$file = self::$cache_file;
}
//remove the file when it exists
if (file_exists($file)) {
@unlink($file);
$error_array = error_get_last();
//send to syslog when debugging with either environment variable or debug in the url
self::log(LOG_WARNING, $error_array['message'] ?? '');
}
}
private static function log(int $level, string $message): void {
if (filter_var($_REQUEST['debug'] ?? false, FILTER_VALIDATE_BOOL) || filter_var(getenv('DEBUG') ?? false, FILTER_VALIDATE_BOOL)) {
openlog("PHP", LOG_PID | LOG_PERROR, LOG_LOCAL0);
syslog($level, "[auto_loader] " . $message);
closelog();
}
}
}

View File

@ -25,7 +25,6 @@
Mark J Crane <markjcrane@fusionpbx.com>
*/
if (!class_exists('button')) {
class button {
public static $collapse = 'hide-md-dn';
@ -127,7 +126,6 @@ if (!class_exists('button')) {
$button = $anchor.$button."</a>";
}
return $button;
unset($button);
}
private static function quote($value) {
@ -135,7 +133,6 @@ if (!class_exists('button')) {
}
}
}
/*
@ -236,5 +233,3 @@ if (!class_exists('button')) {
*/
?>

View File

@ -3279,7 +3279,7 @@
* @see database::__construct()
* @see database::connect()
*/
public static function new(array $params = []) {
public static function new(array $params = []): static {
if (self::$database === null) {
self::$database = new database($params);
if (!self::$database->is_connected()) {
@ -3326,7 +3326,6 @@
/*
//example usage
//find
require_once "resources/classes/database.php";
$database = new database;
$database->domain_uuid = $_SESSION["domain_uuid"];
$database->type = $db_type;
@ -3343,7 +3342,6 @@
$database->find();
print_r($database->result);
//insert
require_once "resources/classes/database.php";
$database = new database;
$database->domain_uuid = $_SESSION["domain_uuid"];
$database->table = "v_ivr_menus";

View File

@ -28,11 +28,7 @@
/**
* domains class
*
* @method null delete
* @method null toggle
* @method null copy
*/
if (!class_exists('domains')) {
class domains {
/**
@ -786,6 +782,3 @@ if (!class_exists('domains')) {
}
}
}
?>

View File

@ -27,9 +27,7 @@
/**
* email class
*
* @method boolean send
*/
if (!class_exists('email')) {
class email {
/**
@ -625,7 +623,7 @@ if (!class_exists('email')) {
}
}
}
/*
$email = new email;

View File

@ -27,11 +27,7 @@
/**
* groups class provides methods for add, delete groups, and add default groups
*
* @method null delete
* @method null toggle
* @method null copy
*/
if (!class_exists('groups')) {
class groups {
/**
@ -534,6 +530,3 @@ if (!class_exists('groups')) {
$_SESSION["user"]["group_level"] = $this->group_level;
}
}
}
?>

Some files were not shown because too many files have changed in this diff Show More