From dda18481ec28cb711d819260be20d7f0e44f3ce4 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Wed, 15 Oct 2025 21:24:59 -0600 Subject: [PATCH] Refactor PHP code (#7574) * Use settings-get method - get default, domain and user settings - Replace _SESSION * Simplify get domain paging * Change isset using empty * Fix token name and hash * Add new default settings category: contact, name: default_sort_column, and default_sort_order * Update app_config.php * Update footer.php * Fix require.php and core/dashboard/index.php (#7563) * Fix require.php and core/dashboard/index.php * Fix require.php and core/dashboard/index.php * Fix require.php and core/dashboard/index.php * Fix require.php and core/dashboard/index.php * Fix require.php and core/dashboard/index.php * Fix require.php and core/dashboard/index.php * Fix require.php and core/dashboard/index.php * Fix require.php and core/dashboard/index.php * Fix require.php and core/dashboard/index.php * Update destinations.php * Update permission.php * Update require.php --------- Co-authored-by: FusionPBX Co-authored-by: FusionPBX * Update header.php * Use settings get classes (#7567) * access_control * azure * azure * basic_operator_panel * bridges * call_block * call_broadcast * call_center * call_flows * call_forward * call_recordings * do_not_disturb * feature_event_notify * follow_me * remove unused object properties * fix esl command * fix esl command * conference_centers * conference_centers - remove whitespace * conference_controls * conference_profiles * conference_profiles * Delete core/websockets/resources/classes/socket_exception.php.original~ * Delete core/websockets/resources/classes/websocket_server.php.original~ * conferences * destinations * device * dialplan * email_queue * event_guard * extension_settings * extension * fax * fax_queue * fifo * gateways * ivr_menu * modules * switch_music_on_hold * number_translations * phrases * pin_numbers * provision * switch_recordings * registrations * ring_groups * sip_profiles * sofia_global_settings * streams * presence * switch_files * time_conditions * vars * voicemail_greetings * voicemail * ringbacks * contacts * xml_cdr * authentication * dashboard * default_settings * domain_settings * email_templates * permission * user_logs * user_settings * users * button * cache * captcha * remove cli_option * remove directory.php for switch_directory class * email * file * groups * event_socket use config object * Use intval to give an integer port * switch_settings * tones * fix object used before initialization * menu * fix copy paste error for switch_files.php * always include require.php for framework files * Fix missing properties * set the action * Use the $database object * Add missing class properties * Fix the domain_name * Use public scope for domain_uuid and domain_name * Add missing parameters * Correct the user_uuid parameter * Add json_validate and use it in the dashboard update indentation on functions.php * Intialize the active_registrations variable * Define the $parameters * Set a default value for user_setting_enabled * Add condition domain_uuid not empty * Add not empty condition for domain_uuid * Declare the global variables * Update how the defaults are set use ?? * Use ?? to set the default values * Update call_center_queue_edit.php * Prevent an error * Add domain_name property * Fix the null coalescing operator * Removed domain_uuid from the URL * Change condition to check sip_profile_domain_name * Refactor domain_uuid declaration and comments Removed redundant domain_uuid declaration and updated comments. * Account for an empty value * Refactor constructor to use settings array Updated constructor to accept settings array for domain UUID and database initialization. * Refactor xml_cdr.php to improve variable organization Removed duplicate domain_uuid declaration and reorganized private variables for better structure. * Enhance transcription button logic and icon display Updated transcription button visibility conditions and improved application icon handling in the call flow summary. * Refactor settings initialization in domains.php Updated settings initialization to include domain_uuid and user_uuid. * Modify domain change condition in require.php Updated condition to check if 'domain_change' is not empty before proceeding. * Set default_setting_enabled to true by default * Enhance domain UUID check in access controls * Enhance domain UUID check in settings list * Refactor category display logic in vars.php * Simplify list row URL generation Removed domain UUID check from list row URL construction. * Refactor module category display logic * Fix SQL query by removing parameters variable * Initialize result_count variable for call recordings * Refactor leg variable usage in xml_cdr_details.php * Update conference_room_edit.php * Change GET to REQUEST for order and search variables * Set timezone and SQL time format in recordings.php Added timezone and SQL time format settings. * Set default for ring group greeting * Improve domain UUID check in stream listing * Handle null voicemail_option_param safely * Add file existence check for greeting files Check if greeting file exists before getting size and date. * Improve domain UUID check in email templates * Update FIFO strategy dropdown and description text * Add multilingual agent descriptions Added multilingual descriptions for agents in the app_languages.php file. * Add music on hold descriptions * Add the chime list description Updated copyright year from 2024 to 2025. * Fix domain UUID check and handle email subject decoding * Add null coalescing for $value in email_test.php Ensure $value is not null by providing a default empty string. * Handle undefined dialplan_uuid in input field * Add translations for 'Status' label in multiple languages * Fix typo in config instance check --------- Co-authored-by: frytimo --- app/access_controls/access_control_import.php | 4 +- app/access_controls/access_controls.php | 2 +- .../resources/classes/access_controls.php | 39 +- .../resources/dashboard/active_calls.php | 2 +- app/azure/resources/classes/azure.php | 75 +- app/basic_operator_panel/exec.php | 8 +- app/basic_operator_panel/index.php | 6 +- .../classes/basic_operator_panel.php | 56 +- .../resources/content.php | 22 +- app/bridges/bridge_imports.php | 10 +- app/bridges/resources/classes/bridges.php | 46 +- app/call_block/call_block.php | 8 +- app/call_block/call_block_edit.php | 16 +- .../resources/classes/call_block.php | 76 +- app/call_broadcast/call_broadcast.php | 2 +- app/call_broadcast/call_broadcast_send.php | 2 +- .../resources/classes/call_broadcast.php | 38 +- app/call_center_active/call_center_active.php | 2 +- app/call_centers/call_center_agent_edit.php | 16 +- app/call_centers/call_center_agent_status.php | 2 +- app/call_centers/call_center_agents.php | 2 +- app/call_centers/call_center_queue_edit.php | 30 +- app/call_centers/call_center_queues.php | 6 +- .../resources/classes/call_center.php | 69 +- .../dashboard/call_center_agents.php | 2 +- app/call_centers/waveform.php | 24 +- app/call_flows/call_flow_edit.php | 10 +- app/call_flows/call_flows.php | 2 +- .../resources/classes/call_flows.php | 63 +- app/call_flows/waveform.php | 24 +- app/call_forward/call_forward.php | 4 +- .../resources/classes/call_forward.php | 60 +- .../resources/classes/do_not_disturb.php | 92 +- .../classes/feature_event_notify.php | 2 +- .../resources/classes/follow_me.php | 75 +- .../resources/dashboard/call_forward.php | 2 +- app/call_recordings/call_recordings.php | 7 +- .../resources/classes/call_recordings.php | 53 +- app/call_recordings/waveform.php | 20 +- app/calls_active/calls_active.php | 2 +- app/calls_active/calls_active_inc.php | 2 +- app/click_to_call/click_to_call.php | 10 +- .../conference_center_edit.php | 6 +- app/conference_centers/conference_centers.php | 2 +- .../conference_room_edit.php | 10 +- app/conference_centers/conference_rooms.php | 4 +- .../conference_session_details.php | 4 +- .../conference_sessions.php | 2 +- .../resources/classes/call_center_notify.php | 2 +- .../resources/classes/conference_centers.php | 95 +- app/conference_centers/waveform.php | 24 +- .../conference_control_details.php | 2 +- .../conference_controls.php | 2 +- .../resources/classes/conference_controls.php | 8 +- .../conference_profile_params.php | 2 +- .../resources/classes/conference_profiles.php | 9 +- app/conferences/conference_edit.php | 2 +- app/conferences/conferences.php | 2 +- .../resources/classes/conferences.php | 63 +- app/conferences_active/conference_exec.php | 4 +- .../conference_interactive_inc.php | 2 +- .../database_transactions.php | 2 +- app/destinations/destination_imports.php | 18 +- app/destinations/destinations.php | 5 +- .../resources/classes/destinations.php | 66 +- app/devices/device_edit.php | 2 +- app/devices/device_imports.php | 6 +- app/devices/device_profile_edit.php | 6 +- app/devices/device_vendor_edit.php | 2 +- app/devices/device_vendor_function_edit.php | 2 +- app/devices/device_vendor_functions.php | 2 +- app/devices/device_vendors.php | 2 +- app/devices/devices.php | 3 +- app/devices/resources/classes/device.php | 76 +- .../resources/dashboard/device_keys.php | 4 +- app/dialplans/dialplan_xml.php | 10 +- app/dialplans/dialplans.php | 2 +- app/dialplans/resources/classes/dialplan.php | 62 +- .../resources/dashboard/domain_limits.php | 10 +- app/email_queue/email_queue.php | 6 +- app/email_queue/email_queue_edit.php | 10 +- app/email_queue/email_test.php | 9 +- .../resources/classes/email_queue.php | 46 +- .../resources/classes/event_guard.php | 39 +- .../resources/classes/extension_settings.php | 44 +- app/extensions/extension_copy.php | 4 +- app/extensions/extension_imports.php | 10 +- app/extensions/extensions.php | 10 +- .../resources/classes/extension.php | 87 +- .../resources/dashboard/caller_id.php | 2 +- app/fax/fax.php | 4 +- app/fax/fax_advanced.php | 2 +- app/fax/fax_edit.php | 8 +- app/fax/fax_files.php | 14 +- app/fax/fax_files_remote.php | 2 +- app/fax/fax_logs.php | 2 +- app/fax/resources/classes/fax.php | 88 +- app/fax_queue/resources/classes/fax_queue.php | 32 +- app/fifo/app_languages.php | 29 +- app/fifo/fifo_edit.php | 6 +- app/fifo/resources/classes/fifo.php | 40 +- app/fifo_list/fifo_list_inc.php | 2 +- app/gateways/gateway_edit.php | 79 +- app/gateways/gateways.php | 2 +- app/gateways/resources/classes/gateways.php | 58 +- app/ivr_menus/ivr_menu_edit.php | 4 +- app/ivr_menus/ivr_menus.php | 6 +- app/ivr_menus/resources/classes/ivr_menu.php | 53 +- .../resources/functions/ivr_menu_xml.php | 8 +- app/ivr_menus/waveform.php | 24 +- app/log_viewer/log_viewer.php | 12 +- app/modules/modules.php | 22 +- app/modules/resources/classes/modules.php | 51 +- app/music_on_hold/app_languages.php | 270 ++ app/music_on_hold/music_on_hold.php | 10 +- app/music_on_hold/music_on_hold_edit.php | 12 +- .../classes/switch_music_on_hold.php | 70 +- app/music_on_hold/waveform.php | 16 +- .../number_translations.php | 6 +- .../resources/classes/number_translations.php | 15 +- app/phrases/phrase_edit.php | 6 +- app/phrases/resources/classes/phrases.php | 41 +- .../resources/classes/pin_numbers.php | 38 +- app/provision/resources/classes/provision.php | 72 +- app/recordings/app_config.php | 2 +- app/recordings/recordings.php | 10 + .../resources/classes/switch_recordings.php | 59 +- app/recordings/waveform.php | 18 +- .../resources/classes/registrations.php | 70 +- .../resources/dashboard/registrations.php | 3 +- .../resources/classes/ring_groups.php | 66 +- .../dashboard/ring_group_forward.php | 2 +- app/ring_groups/ring_group_edit.php | 9 +- app/ring_groups/ring_groups.php | 6 +- app/ring_groups/waveform.php | 24 +- .../resources/classes/sip_profiles.php | 45 +- app/sip_profiles/sip_profile_edit.php | 2 +- app/sip_profiles/sip_profiles.php | 6 +- app/sip_status/sip_status.php | 2 +- .../classes/sofia_global_settings.php | 13 +- .../sofia_global_settings.php | 2 +- app/streams/resources/classes/streams.php | 55 +- app/streams/streams.php | 4 +- app/switch/resources/classes/presence.php | 1 + app/switch/resources/classes/ringbacks.php | 56 +- app/switch/resources/classes/switch_files.php | 23 +- .../resources/dashboard/switch_status.php | 2 +- app/switch/sounds.php | 8 +- .../resources/dashboard/system_counts.php | 2 +- .../resources/dashboard/system_cpu_status.php | 2 +- .../resources/dashboard/system_disk_usage.php | 2 +- .../dashboard/system_network_status.php | 2 +- .../resources/dashboard/system_status.php | 4 +- app/system/system.php | 10 +- .../resources/classes/time_conditions.php | 55 +- app/time_conditions/time_condition_edit.php | 8 +- app/vars/resources/classes/vars.php | 9 +- app/vars/vars.php | 22 +- .../resources/classes/voicemail_greetings.php | 54 +- .../voicemail_greetings.php | 28 +- app/voicemail_greetings/waveform.php | 20 +- .../resources/classes/voicemail.php | 99 +- .../resources/dashboard/voicemails.php | 4 +- app/voicemails/voicemail_edit.php | 4 +- app/voicemails/voicemail_messages.php | 12 +- app/voicemails/voicemail_name.php | 4 +- app/voicemails/waveform.php | 30 +- app/xml_cdr/app_defaults.php | 4 +- app/xml_cdr/resources/classes/xml_cdr.php | 58 +- .../resources/dashboard/missed_calls.php | 16 +- .../resources/dashboard/recent_calls.php | 16 +- app/xml_cdr/waveform.php | 20 +- app/xml_cdr/xml_cdr.php | 4 +- app/xml_cdr/xml_cdr_details.php | 24 +- app/xml_cdr/xml_cdr_export.php | 2 +- app/xml_cdr/xml_cdr_inc.php | 14 +- .../resources/classes/authentication.php | 4 +- .../resources/classes/plugins/email.php | 2 +- core/contacts/app_config.php | 17 +- core/contacts/contact_address_edit.php | 2 +- core/contacts/contact_attachment.php | 2 +- core/contacts/contact_attachment_edit.php | 6 +- core/contacts/contact_auth.php | 6 +- core/contacts/contact_edit.php | 18 +- core/contacts/contact_email_edit.php | 2 +- core/contacts/contact_import.php | 12 +- core/contacts/contact_phone_edit.php | 2 +- core/contacts/contact_setting_edit.php | 2 +- core/contacts/contact_url_edit.php | 2 +- core/contacts/contact_view.php | 14 +- core/contacts/contacts.php | 13 +- core/contacts/resources/classes/contacts.php | 37 +- core/dashboard/index.php | 14 +- .../dashboard/resources/classes/dashboard.php | 10 +- .../dashboard/resources/dashboard/content.php | 2 +- core/dashboard/resources/dashboard/icon.php | 2 +- core/dashboard/resources/dashboard/parent.php | 2 +- core/databases/databases.php | 2 +- .../default_settings/default_setting_edit.php | 10 +- core/default_settings/default_settings.php | 2 +- .../resources/classes/default_settings.php | 33 +- core/domain_settings/domain_setting_edit.php | 2 +- .../resources/classes/domain_settings.php | 43 +- core/domains/domain_edit.php | 64 +- core/domains/domains.php | 13 +- core/domains/resources/dashboard/domains.php | 2 +- core/email_templates/email_template_edit.php | 12 +- core/email_templates/email_templates.php | 4 +- .../resources/classes/email_templates.php | 37 +- core/groups/resources/classes/permission.php | 11 +- core/install/install.php | 6 +- core/menu/menu_item_list.php | 2 +- core/menu/menu_reload.php | 2 +- core/menu/menu_restore_default.php | 7 +- core/upgrade/index.php | 8 +- .../user_logs/resources/classes/user_logs.php | 35 +- core/user_logs/user_logs.php | 2 +- .../resources/classes/user_settings.php | 36 +- core/user_settings/user_setting_edit.php | 4 +- core/user_settings/user_settings.php | 2 +- core/users/resources/classes/users.php | 36 +- core/users/user_edit.php | 14 +- core/users/user_imports.php | 4 +- core/users/user_profile.php | 5 +- index.php | 8 +- resources/app_languages.php | 27 + resources/classes/button.php | 6 +- resources/classes/cache.php | 12 +- resources/classes/captcha.php | 9 - resources/classes/cli_option.php | 241 - resources/classes/config.php | 10 +- resources/classes/directory.php | 655 --- resources/classes/domains.php | 2 +- resources/classes/email.php | 64 +- resources/classes/event_socket.php | 13 +- resources/classes/file.php | 40 +- resources/classes/groups.php | 13 +- resources/classes/menu.php | 74 +- resources/classes/sounds.php | 28 +- resources/classes/switch_settings.php | 85 +- resources/classes/tones.php | 10 +- resources/fonts/web_font_loader.php | 4 +- resources/footer.php | 67 +- resources/functions.php | 3952 ++++++++--------- resources/header.php | 13 +- resources/login.php | 2 +- resources/pdo_vm.php | 4 +- resources/require.php | 9 +- resources/switch.php | 155 +- 249 files changed, 5180 insertions(+), 4798 deletions(-) delete mode 100644 resources/classes/cli_option.php delete mode 100644 resources/classes/directory.php diff --git a/app/access_controls/access_control_import.php b/app/access_controls/access_control_import.php index 09b4f82026..6059544372 100644 --- a/app/access_controls/access_control_import.php +++ b/app/access_controls/access_control_import.php @@ -64,7 +64,7 @@ //save the data to the csv file if (isset($_POST['data'])) { - $file = $_SESSION['server']['temp']['dir']."/access_control_nodes-".$_SESSION['domain_name'].".csv"; + $file = $settings->get('server', 'temp')."/access_control_nodes-".$_SESSION['domain_name'].".csv"; if (file_put_contents($file, $_POST['data'])) { $_SESSION['file'] = $file; } @@ -74,7 +74,7 @@ //$_POST['submit'] == "Upload" && if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('access_control_node_add')) { if (!empty($_POST['type']) &&$_POST['type'] == 'csv') { - $file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']; + $file = $settings->get('server', 'temp').'/'.$_FILES['ulfile']['name']; if (move_uploaded_file($_FILES['ulfile']['tmp_name'], $file)) { $_SESSION['file'] = $file; } diff --git a/app/access_controls/access_controls.php b/app/access_controls/access_controls.php index 289abd7650..feadcdc5ad 100644 --- a/app/access_controls/access_controls.php +++ b/app/access_controls/access_controls.php @@ -207,7 +207,7 @@ $list_row_url = ''; if (permission_exists('access_control_view')) { $list_row_url = "access_control_edit.php?id=".urlencode($row['access_control_uuid']); - if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { + if (!empty($row['domain_uuid']) && $row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true'; } } diff --git a/app/access_controls/resources/classes/access_controls.php b/app/access_controls/resources/classes/access_controls.php index b95e76f448..29fe4c98b2 100644 --- a/app/access_controls/resources/classes/access_controls.php +++ b/app/access_controls/resources/classes/access_controls.php @@ -12,9 +12,32 @@ const app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd'; /** - * declare private variables + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object */ private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + + /** + * declare private variables + */ private $permission_prefix; private $list_page; private $table; @@ -23,15 +46,17 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $config = $setting_array['config'] ?? config::load(); + $this->database = $setting_array['database'] ?? database::new(['config' => $config]); //assign private variables $this->list_page = 'access_controls.php'; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } } /** diff --git a/app/active_calls/resources/dashboard/active_calls.php b/app/active_calls/resources/dashboard/active_calls.php index 317d90eef9..9055dc2b0d 100644 --- a/app/active_calls/resources/dashboard/active_calls.php +++ b/app/active_calls/resources/dashboard/active_calls.php @@ -44,7 +44,7 @@ $row_style["1"] = "row_style1"; $widget_icon = 'fa-solid fa-phone'; //add multi-lingual support -$text = (new text)->get($_SESSION['domain']['language']['code'], 'app/active_calls'); +$text = (new text)->get($settings->get('domain', 'language', 'en-us'), 'app/active_calls'); //show the widget echo "
\n"; diff --git a/app/azure/resources/classes/azure.php b/app/azure/resources/classes/azure.php index 75adcc4dcd..8a934120fa 100644 --- a/app/azure/resources/classes/azure.php +++ b/app/azure/resources/classes/azure.php @@ -3,115 +3,115 @@ class azure{ public static $formats = array ( - 'English-Zira' => + 'English-Zira' => array ( 'lang' => 'en-US', 'gender' => 'Female', 'name' => 'Microsoft Server Speech Text to Speech Voice (en-US, ZiraRUS)' ), - 'English-Jessa' => + 'English-Jessa' => array ( 'lang' => 'en-US', 'gender' => 'Female', 'name' => 'Microsoft Server Speech Text to Speech Voice (en-US, JessaRUS)' ), - 'English-Benjamin' => + 'English-Benjamin' => array ( 'lang' => 'en-US', 'gender' => 'Male', 'name' => 'Microsoft Server Speech Text to Speech Voice (en-US, BenjaminRUS)' ), - 'British-Susan' => + 'British-Susan' => array ( 'lang' => 'en-GB', 'gender' => 'Female', 'name' => 'Microsoft Server Speech Text to Speech Voice (en-GB, Susan, Apollo)' ), - 'British-Hazel' => + 'British-Hazel' => array ( 'lang' => 'en-GB', 'gender' => 'Female', 'name' => 'Microsoft Server Speech Text to Speech Voice (en-GB, HazelRUS)' ), - 'British-George' => + 'British-George' => array ( 'lang' => 'en-GB', 'gender' => 'Male', 'name' => 'Microsoft Server Speech Text to Speech Voice (en-GB, George, Apollo)' ), - 'Australian-Catherine' => + 'Australian-Catherine' => array ( 'lang' => 'en-AU', 'gender' => 'Female', 'name' => 'Microsoft Server Speech Text to Speech Voice (en-AU, Catherine)' ), - 'Spanish-Helena' => + 'Spanish-Helena' => array ( 'lang' => 'es-ES', 'gender' => 'Female', 'name' => 'Microsoft Server Speech Text to Speech Voice (es-ES, HelenaRUS)' ), - 'Spanish-Laura' => + 'Spanish-Laura' => array ( 'lang' => 'es-ES', 'gender' => 'Female', 'name' => 'Microsoft Server Speech Text to Speech Voice (es-ES, Laura, Apollo)' ), - 'Spanish-Pablo' => + 'Spanish-Pablo' => array ( 'lang' => 'es-ES', 'gender' => 'Male', 'name' => 'Microsoft Server Speech Text to Speech Voice (es-ES, Pablo, Apollo)' ), - 'French-Julie' => + 'French-Julie' => array ( 'lang' => 'fr-FR', 'gender' => 'Female', 'name' => 'Microsoft Server Speech Text to Speech Voice (fr-FR, Julie, Apollo)' ), - 'French-Hortense' => + 'French-Hortense' => array ( 'lang' => 'fr-FR', 'gender' => 'Female', 'name' => 'Microsoft Server Speech Text to Speech Voice (fr-FR, HortenseRUS)' ), - 'French-Paul' => + 'French-Paul' => array ( 'lang' => 'fr-FR', 'gender' => 'Male', 'name' => 'Microsoft Server Speech Text to Speech Voice (fr-FR, Paul, Apollo)' ), - 'German-Hedda' => + 'German-Hedda' => array ( 'lang' => 'de-DE', 'gender' => 'Female', 'name' => 'Microsoft Server Speech Text to Speech Voice (de-DE, Hedda)' ), - 'Russian-Irina' => + 'Russian-Irina' => array ( 'lang' => 'ru-RU', 'gender' => 'Female', 'name' => 'Microsoft Server Speech Text to Speech Voice (ru-RU, Irina, Apollo)' ), - 'Russian-Pavel' => + 'Russian-Pavel' => array ( 'lang' => 'ru-RU', 'gender' => 'Male', 'name' => 'Microsoft Server Speech Text to Speech Voice (ru-RU, Pavel, Apollo)' ), - 'Chinese-Huihui' => + 'Chinese-Huihui' => array ( 'lang' => 'zh-CN', 'gender' => 'Female', 'name' => 'Microsoft Server Speech Text to Speech Voice (zh-CN, HuihuiRUS)' ), - 'Chinese-Yaoyao' => + 'Chinese-Yaoyao' => array ( 'lang' => 'zh-CN', 'gender' => 'Female', 'name' => 'Microsoft Server Speech Text to Speech Voice (zh-CN, Yaoyao, Apollo)' ), - 'Chinese-Kangkang' => + 'Chinese-Kangkang' => array ( 'lang' => 'zh-CN', 'gender' => 'Male', @@ -119,6 +119,17 @@ class azure{ ) ); + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $config = $setting_array['config'] ?? config::load(); + $this->database = $setting_array['database'] ?? database::new(['config' => $config]); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $domain_uuid, 'user_uuid' => $user_uuid]); + } + private static function getTokenUrl(){ return "https://api.cognitive.microsoft.com/sts/v1.0/issueToken"; } @@ -127,13 +138,13 @@ class azure{ return "https://speech.platform.bing.com/synthesize"; } - private static function getSubscriptionKey(){ - return $_SESSION['azure']['key']['text']; + private static function getSubscriptionKey(settings $settings){ + return $settings->get('azure', 'key'); } - private static function _getToken(){ + private static function _getToken(settings $settings){ $url = self::getTokenUrl(); - $subscriptionKey = self::getSubscriptionKey(); + $subscriptionKey = self::getSubscriptionKey($settings); $headers = array(); $headers[] = 'Ocp-Apim-Subscription-Key: '. $subscriptionKey; @@ -149,22 +160,22 @@ class azure{ curl_setopt ( $ch, CURLOPT_VERBOSE, false); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); - + $response = curl_exec($ch); curl_close($ch); return $response; } - public static function synthesize($data,$formate_key){ + public static function synthesize(settings $settings, $data, $format_key){ - $lang = self::$formats[$formate_key]['lang']; - $gender = self::$formats[$formate_key]['gender']; - $name = self::$formats[$formate_key]['name']; - $token = self::_getToken(); + $lang = self::$formats[$format_key]['lang']; + $gender = self::$formats[$format_key]['gender']; + $name = self::$formats[$format_key]['name']; + $token = self::_getToken($settings); $url = self::getApiUrl(); - + $headers = array(); $headers[] = 'Authorization: Bearer '. $token; $headers[] = 'Content-Type: application/ssml+xml'; @@ -187,12 +198,12 @@ class azure{ curl_setopt ( $ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); - + $response = curl_exec($ch); $filename = "tts_".time().".wav"; file_put_contents("/var/www/html/fusionpbx/app/voiplyrecording/tts_record/".$filename, $response); curl_close($ch); - return $filename; + return $filename; } } diff --git a/app/basic_operator_panel/exec.php b/app/basic_operator_panel/exec.php index 7b392c36d0..27275597cc 100644 --- a/app/basic_operator_panel/exec.php +++ b/app/basic_operator_panel/exec.php @@ -72,7 +72,7 @@ if (count($_GET) > 0) { } else if ($switch_cmd == 'uuid_record') { $uuid = preg_replace($uuid_pattern,'',$_GET['uuid']); - $api_cmd = 'uuid_record ' . $uuid . ' start ' . $_SESSION['switch']['recordings']['dir'] . '/' . $_SESSION['domain_name'] . '/archive/' . date('Y/M/d') . '/' . $uuid . '.wav'; + $api_cmd = 'uuid_record ' . $uuid . ' start ' . $settings->get('switch', 'recordings') . '/' . $_SESSION['domain_name'] . '/archive/' . date('Y/M/d') . '/' . $uuid . '.wav'; } else if ($switch_cmd == 'uuid_transfer') { $uuid = preg_replace($uuid_pattern,'',$_GET['uuid']); @@ -108,13 +108,13 @@ if (count($_GET) > 0) { $x=0; while (true) { if ($x > 0) { - $dest_file = $_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"]."_".$x.".wav"; + $dest_file = $settings->get('switch', 'recordings')."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"]."_".$x.".wav"; } else { - $dest_file = $_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"].".wav"; + $dest_file = $settings->get('switch', 'recordings')."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"].".wav"; } if (!file_exists($dest_file)) { - rename($_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"].".wav", $dest_file); + rename($settings->get('switch', 'recordings')."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"].".wav", $dest_file); break; } $x++; diff --git a/app/basic_operator_panel/index.php b/app/basic_operator_panel/index.php index 55d1ec6246..de7a4e3ea9 100644 --- a/app/basic_operator_panel/index.php +++ b/app/basic_operator_panel/index.php @@ -162,10 +162,10 @@ //delete extension from the cache $cache = new cache; if (!empty($extension)) { - $cache->delete("directory:".$extension."@".$this->domain_name); + $cache->delete("directory:".$extension."@".$domain_name); } if (!empty($number_alias)) { - $cache->delete("directory:".$number_alias."@".$this->domain_name); + $cache->delete("directory:".$number_alias."@".$domain_name); } } @@ -195,7 +195,7 @@ get('operator_panel', 'refresh')) ? $settings->get('operator_panel', 'refresh') : $refresh_default; if ($refresh >= 0.5 && $refresh <= 120) { //convert seconds to milliseconds $refresh = $refresh * 1000; } diff --git a/app/basic_operator_panel/resources/classes/basic_operator_panel.php b/app/basic_operator_panel/resources/classes/basic_operator_panel.php index a998018e26..e3c0fe5430 100644 --- a/app/basic_operator_panel/resources/classes/basic_operator_panel.php +++ b/app/basic_operator_panel/resources/classes/basic_operator_panel.php @@ -36,28 +36,50 @@ const app_uuid = 'dd3d173a-5d51-4231-ab22-b18c5b712bb2'; /** - * declare public variables - */ - public $domain_uuid; - - /** - * declare private variables + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object */ private $database; + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + public $domain_uuid; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_name; + /** * Called when the object is created */ - public function __construct() { - //assign public variables - if (!isset($this->domain_uuid)) { - $this->domain_uuid = $_SESSION['domain_uuid']; - } + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } + //set domain_name + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + + //set objects + $config = $setting_array['config'] ?? config::load(); + $this->database = $setting_array['database'] ?? database::new(['config' => $config]); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); } /** @@ -87,7 +109,7 @@ $sql .= "e.domain_uuid = :domain_uuid "; $sql .= "order by "; $sql .= "e.extension asc "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $extensions = $this->database->select($sql, $parameters); //store extension status by user uuid @@ -164,7 +186,7 @@ $presence_id = $presence[0]; $presence_domain = $presence[1] ?? ''; if ($user == $presence_id) { - if ($presence_domain == $_SESSION['domain_name']) { + if ($presence_domain == $this->domain_name) { $found = true; break; } diff --git a/app/basic_operator_panel/resources/content.php b/app/basic_operator_panel/resources/content.php index 2331f92afb..e9e5f47f43 100644 --- a/app/basic_operator_panel/resources/content.php +++ b/app/basic_operator_panel/resources/content.php @@ -74,29 +74,29 @@ if ($valet_info !== false) { } //view_array($valet_matches, false); - //unset($_SESSION['valet']); + //unset($valet); foreach($valet_matches as $row) { - if (!isset($_SESSION['valet']['uuid']['caller_id_name'])) { - $_SESSION['valet'][$row[1]]['caller_id_name'] = event_socket::api('uuid_getvar '.$row[1].' caller_id_name'); + if (!isset($valet['uuid']['caller_id_name'])) { + $valet[$row[1]]['caller_id_name'] = event_socket::api('uuid_getvar '.$row[1].' caller_id_name'); } - if (!isset($_SESSION['valet']['uuid']['caller_id_number'])) { - $_SESSION['valet'][$row[1]]['caller_id_number'] = event_socket::api('uuid_getvar '.$row[1].' caller_id_number'); + if (!isset($valet['uuid']['caller_id_number'])) { + $valet[$row[1]]['caller_id_number'] = event_socket::api('uuid_getvar '.$row[1].' caller_id_number'); } } //unset the array - //view_array($_SESSION['valet']); + //view_array($valet); //reformat the array and add the caller ID name and numbers $x = 0; foreach($valet_matches as $row) { $valet_array[$x]['uuid'] = $row[1]; $valet_array[$x]['extension'] = $row[2]; - if (isset($_SESSION['valet'][$row[1]]['caller_id_name'])) { - $valet_array[$x]['caller_id_name'] = $_SESSION['valet'][$row[1]]['caller_id_name']; + if (isset($valet[$row[1]]['caller_id_name'])) { + $valet_array[$x]['caller_id_name'] = $valet[$row[1]]['caller_id_name']; } - if (isset($_SESSION['valet'][$row[1]]['caller_id_number'])) { - $valet_array[$x]['caller_id_number'] = $_SESSION['valet'][$row[1]]['caller_id_number']; + if (isset($valet[$row[1]]['caller_id_number'])) { + $valet_array[$x]['caller_id_number'] = $valet[$row[1]]['caller_id_number']; } $x++; } @@ -475,7 +475,7 @@ if (is_array($activity)) { //record if (permission_exists('operator_panel_record') && $ext_state == 'active') { $call_identifier_record = $ext['call_uuid']; - $rec_file = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/archive/".date("Y")."/".date("M")."/".date("d")."/".escape($call_identifier_record).".wav"; + $rec_file = $settings->get('switch', 'recordings')."/".$_SESSION['domain_name']."/archive/".date("Y")."/".date("M")."/".date("d")."/".escape($call_identifier_record).".wav"; if (file_exists($rec_file)) { $block .= "\n"; } diff --git a/app/bridges/bridge_imports.php b/app/bridges/bridge_imports.php index 6f8c8fe617..83ea7b4cc7 100644 --- a/app/bridges/bridge_imports.php +++ b/app/bridges/bridge_imports.php @@ -64,7 +64,7 @@ //save the data to the csv file if (isset($_POST['data'])) { - $file = $_SESSION['server']['temp']['dir']."/bridges-".$_SESSION['domain_name'].".csv"; + $file = $settings->get('server', 'temp')."/bridges-".$_SESSION['domain_name'].".csv"; file_put_contents($file, $_POST['data']); $_SESSION['file'] = $file; } @@ -72,11 +72,11 @@ //copy the csv file if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('bridge_import')) { if ($_POST['type'] == 'csv') { - move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']); - $save_msg = "Uploaded file to ".$_SESSION['server']['temp']['dir']."/". htmlentities($_FILES['ulfile']['name']); - //system('chmod -R 744 '.$_SESSION['server']['temp']['dir'].'*'); + move_uploaded_file($_FILES['ulfile']['tmp_name'], $settings->get('server', 'temp').'/'.$_FILES['ulfile']['name']); + $save_msg = "Uploaded file to ".$settings->get('server', 'temp')."/". htmlentities($_FILES['ulfile']['name']); + //system('chmod -R 744 '.$settings->get('server', 'temp').'*'); unset($_POST['txtCommand']); - $file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']; + $file = $settings->get('server', 'temp').'/'.$_FILES['ulfile']['name']; $_SESSION['file'] = $file; } } diff --git a/app/bridges/resources/classes/bridges.php b/app/bridges/resources/classes/bridges.php index 55ceda3b8b..7967b746b0 100644 --- a/app/bridges/resources/classes/bridges.php +++ b/app/bridges/resources/classes/bridges.php @@ -34,9 +34,32 @@ const app_uuid = 'a6a7c4c5-340a-43ce-bcbc-2ed9bab8659d'; /** - * declare private variables + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object */ private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + + /** + * declare private variables + */ private $permission_prefix; private $list_page; private $table; @@ -47,7 +70,15 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $config = $setting_array['config'] ?? config::load(); + $this->database = $setting_array['database'] ?? database::new(['config' => $config]); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); //assign private variables @@ -58,11 +89,6 @@ $this->toggle_field = 'bridge_enabled'; $this->toggle_values = ['true','false']; - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } - } /** @@ -90,7 +116,7 @@ foreach ($records as $x => $record) { if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) { $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; } } @@ -145,7 +171,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -218,7 +244,7 @@ $sql = "select * from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $x => $row) { diff --git a/app/call_block/call_block.php b/app/call_block/call_block.php index b9d98e3826..4d02b6f8d3 100644 --- a/app/call_block/call_block.php +++ b/app/call_block/call_block.php @@ -135,7 +135,7 @@ unset($parameters); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = "&search=".$search; if ($show == "all" && permission_exists('call_block_all')) { $param .= "&show=all"; @@ -151,7 +151,7 @@ $sql .= " call_block_country_code, call_block_number, extension, number_alias, call_block_count, "; $sql .= " call_block_app, call_block_data, "; $sql .= " to_char(timezone(:time_zone, insert_date), 'DD Mon YYYY') as date_formatted, \n"; - if (date(!empty($_SESSION['domain']['time_format']['text']) == '12h')) { + if (date(!empty($settings->get('domain', 'time_format')) == '12h')) { $sql .= " to_char(timezone(:time_zone, insert_date), 'HH12:MI:SS am') as time_formatted, \n"; } else { @@ -336,8 +336,8 @@ } echo " "; switch ($row['call_block_direction']) { - case "inbound": echo "\n"; break; - case "outbound": echo "\n"; break; + case "inbound": echo "\n"; break; + case "outbound": echo "\n"; break; } echo " \n"; echo " "; diff --git a/app/call_block/call_block_edit.php b/app/call_block/call_block_edit.php index a555457cb0..9ec1d439ae 100644 --- a/app/call_block/call_block_edit.php +++ b/app/call_block/call_block_edit.php @@ -618,7 +618,7 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr $sql .= "and direction <> 'local' "; $sql .= $sql_where ?? null; $sql .= "order by start_stamp desc "; - $sql .= limit_offset($_SESSION['call_block']['recent_call_limit']['text']); + $sql .= limit_offset($settings->get('call_block', 'recent_call_limit')); $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $recent_calls = $database->select($sql, $parameters); unset($sql, $parameters); @@ -685,7 +685,7 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr $list_row_onclick_uncheck = "if (!this.checked) { document.getElementById('checkbox_all_".$direction."').checked = false; }"; $list_row_onclick_toggle = "onclick=\"document.getElementById('checkbox_".$x."').checked = document.getElementById('checkbox_".$x."').checked ? false : true; ".$list_row_onclick_uncheck."\""; if (strlen($row['caller_id_number']) >= 7) { - if (!empty($_SESSION['domain']['time_format']['text']) && $_SESSION['domain']['time_format']['text'] == '24h') { + if (!empty($settings->get('domain', 'time_format')) && $settings->get('domain', 'time_format') == '24h') { $tmp_start_epoch = date('j M Y', $row['start_epoch'])." ".date('H:i:s', $row['start_epoch']).''; } else { @@ -697,10 +697,10 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr echo " \n"; echo " \n"; if ( - file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_inbound_voicemail.png") && - file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_inbound_answered.png") && - file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_outbound_failed.png") && - file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_outbound_answered.png") + file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$settings->get('domain', 'template')."/images/icon_cdr_inbound_voicemail.png") && + file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$settings->get('domain', 'template')."/images/icon_cdr_inbound_answered.png") && + file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$settings->get('domain', 'template')."/images/icon_cdr_outbound_failed.png") && + file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$settings->get('domain', 'template')."/images/icon_cdr_outbound_answered.png") ) { $title_mod = null; echo " "; @@ -713,7 +713,7 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr else { $file_mod = "_answered"; } - echo "\n"; + echo "\n"; break; case "outbound": if ($row['billsec'] == 0) { @@ -723,7 +723,7 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr else { $file_mod = "_answered"; } - echo "\n"; + echo "\n"; break; } echo " \n"; diff --git a/app/call_block/resources/classes/call_block.php b/app/call_block/resources/classes/call_block.php index 3e7d06a3f7..4039adc393 100644 --- a/app/call_block/resources/classes/call_block.php +++ b/app/call_block/resources/classes/call_block.php @@ -12,9 +12,38 @@ const app_uuid = '9ed63276-e085-4897-839c-4f2e36d92d6c'; /** - * declare private variables + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object */ private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_name; + + /** + * declare private variables + */ private $permission_prefix; private $list_page; private $table; @@ -33,7 +62,16 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $config = $setting_array['config'] ?? config::load(); + $this->database = $setting_array['database'] ?? database::new(['config' => $config]); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); //assign private variables $this->permission_prefix = 'call_block_'; @@ -42,12 +80,6 @@ $this->uuid_prefix = 'call_block_'; $this->toggle_field = 'call_block_enabled'; $this->toggle_values = ['true','false']; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } - } /** @@ -88,7 +120,7 @@ } $sql .= ") "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -103,7 +135,7 @@ foreach ($call_block_numbers as $call_block_uuid => $call_block_number) { $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $call_block_uuid; if (!permission_exists('call_block_domain')) { - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; } $x++; } @@ -118,7 +150,7 @@ //clear the cache $cache = new cache; foreach ($call_block_numbers as $call_block_number) { - $cache->delete("app:call_block:".$_SESSION['domain_name'].":".$call_block_number); + $cache->delete("app:call_block:".$this->domain_name.":".$call_block_number); } //set message @@ -160,7 +192,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, call_block_number from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -190,7 +222,7 @@ //clear the cache $cache = new cache; foreach ($call_block_numbers as $call_block_number) { - $cache->delete("app:call_block:".$_SESSION['domain_name'].":".$call_block_number); + $cache->delete("app:call_block:".$this->domain_name.":".$call_block_number); } //set message @@ -235,7 +267,7 @@ $sql = "select * from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $x => $row) { @@ -307,7 +339,7 @@ } //get the caller id info from call detail records - if (isset($_SESSION['domain_uuid']) && is_uuid($_SESSION['domain_uuid'])) { + if (is_uuid($this->domain_uuid)) { //get the destination country code $sql = "select distinct(destination_prefix), "; $sql .= "(select count(destination_prefix) from v_destinations where domain_uuid = :domain_uuid and destination_prefix = d.destination_prefix) as count "; @@ -316,7 +348,7 @@ $sql .= "and destination_prefix <> '' "; $sql .= "and destination_enabled = true "; $sql .= "order by count desc limit 1; "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $destination_country_code = $this->database->select($sql, $parameters ?? null, 'column'); unset($sql, $parameters); @@ -331,14 +363,14 @@ if (!permission_exists('call_block_extension')) { $sql = "select extension_uuid from v_extension_users "; $sql .= "where user_uuid = :user_uuid "; - $parameters['user_uuid'] = $_SESSION['user_uuid']; + $parameters['user_uuid'] = $this->user_uuid; $user_extensions = $this->database->select($sql, $parameters ?? null, 'all'); unset($sql, $parameters); } //get the country code from default settings - if (!empty($_SESSION['domain']['country_code']['numeric'])) { - $country_code = $_SESSION['domain']['country_code']['numeric']; + if ($this->settings->get('domain', 'country_code', null) !== null) { + $country_code = $this->settings->get('domain', 'country_code'); } //loop through records @@ -361,7 +393,7 @@ //build insert array if (permission_exists('call_block_extension')) { $array['call_block'][$x]['call_block_uuid'] = uuid(); - $array['call_block'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['call_block'][$x]['domain_uuid'] = $this->domain_uuid; $array['call_block'][$x]['call_block_direction'] = $this->call_block_direction; if (is_uuid($this->extension_uuid)) { $array['call_block'][$x]['extension_uuid'] = $this->extension_uuid; @@ -387,7 +419,7 @@ foreach ($user_extensions as $field) { if (is_uuid($field['extension_uuid'])) { $array['call_block'][$x]['call_block_uuid'] = uuid(); - $array['call_block'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['call_block'][$x]['domain_uuid'] = $this->domain_uuid; $array['call_block'][$x]['call_block_direction'] = $this->call_block_direction; $array['call_block'][$x]['extension_uuid'] = $field['extension_uuid']; if ($this->call_block_direction == 'inbound') { @@ -421,7 +453,7 @@ $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and app_uuid = '".self::app_uuid."' "; $sql .= "and dialplan_enabled <> true "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $x => $row) { diff --git a/app/call_broadcast/call_broadcast.php b/app/call_broadcast/call_broadcast.php index 71831f30e0..4842180a08 100644 --- a/app/call_broadcast/call_broadcast.php +++ b/app/call_broadcast/call_broadcast.php @@ -107,7 +107,7 @@ //prepare the paging $param = ''; - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); if (!empty($search)) { $param .= "&search=".urlencode($search); } diff --git a/app/call_broadcast/call_broadcast_send.php b/app/call_broadcast/call_broadcast_send.php index 97050fc9cf..1af7924e00 100644 --- a/app/call_broadcast/call_broadcast_send.php +++ b/app/call_broadcast/call_broadcast_send.php @@ -202,7 +202,7 @@ $response = event_socket::command($cmd); //method 2 - //cmd_async($_SESSION['switch']['bin']['dir']."/fs_cli -x \"".$cmd."\";"); + //cmd_async($settings->get('switch', 'bin')."/fs_cli -x \"".$cmd."\";"); //spread the calls out so that they are scheduled with different times if (strlen($broadcast_concurrent_limit) > 0 && !empty($broadcast_timeout)) { diff --git a/app/call_broadcast/resources/classes/call_broadcast.php b/app/call_broadcast/resources/classes/call_broadcast.php index ac276d401d..dba05ace54 100644 --- a/app/call_broadcast/resources/classes/call_broadcast.php +++ b/app/call_broadcast/resources/classes/call_broadcast.php @@ -36,11 +36,27 @@ const app_name = 'call_broadcast'; const app_uuid = 'efc11f6b-ed73-9955-4d4d-3a1bed75a056'; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + /** * declare private variables */ - - private $database; private $permission_prefix; private $list_page; private $table; @@ -49,19 +65,19 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); //assign private variables $this->permission_prefix = 'call_broadcast_'; $this->list_page = 'call_broadcast.php'; $this->table = 'call_broadcasts'; $this->uuid_prefix = 'call_broadcast_'; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } - } /** @@ -89,7 +105,7 @@ foreach($records as $x => $record) { if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) { $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; } } @@ -141,7 +157,7 @@ $sql = "select * from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $x => $row) { diff --git a/app/call_center_active/call_center_active.php b/app/call_center_active/call_center_active.php index f53910a8a5..95e642744a 100644 --- a/app/call_center_active/call_center_active.php +++ b/app/call_center_active/call_center_active.php @@ -118,7 +118,7 @@ //determine refresh rate $refresh_default = 1500; //milliseconds - $refresh = is_numeric($_SESSION['call_center']['refresh']['numeric']) ? $_SESSION['call_center']['refresh']['numeric'] : $refresh_default; + $refresh = is_numeric($settings->get('call_center', 'refresh')) ? $settings->get('call_center', 'refresh') : $refresh_default; if ($refresh >= 0.5 && $refresh <= 120) { //convert seconds to milliseconds $refresh = $refresh * 1000; } diff --git a/app/call_centers/call_center_agent_edit.php b/app/call_centers/call_center_agent_edit.php index 55af84c0c8..da81a3b56d 100644 --- a/app/call_centers/call_center_agent_edit.php +++ b/app/call_centers/call_center_agent_edit.php @@ -122,13 +122,13 @@ } //set default values - if (empty($agent_call_timeout)) { $agent_call_timeout = "20"; } - if (empty($agent_max_no_answer)) { $agent_max_no_answer = "0"; } - if (empty($agent_wrap_up_time)) { $agent_wrap_up_time = "10"; } - if (empty($agent_no_answer_delay_time)) { $agent_no_answer_delay_time = "30"; } - if (empty($agent_reject_delay_time)) { $agent_reject_delay_time = "90"; } - if (empty($agent_busy_delay_time)) { $agent_busy_delay_time = "90"; } - if ($agent_record === null) { $agent_record = false; } + $agent_call_timeout = $agent_call_timeout ?? "20"; + $agent_max_no_answer = $agent_max_no_answer ?? "0"; + $agent_wrap_up_time = $agent_wrap_up_time ?? "10"; + $agent_no_answer_delay_time = $agent_no_answer_delay_time ?? "30"; + $agent_reject_delay_time = $agent_reject_delay_time ?? "90"; + $agent_busy_delay_time = $agent_busy_delay_time ?? "90"; + $agent_record = $agent_record ?? false; //add the call_center_agent_uuid if (empty($call_center_agent_uuid)) { @@ -136,7 +136,7 @@ } //change the contact string to loopback - Not recommended added for backwards comptability causes multiple problems - if ($_SESSION['call_center']['agent_contact_method']['text'] == 'loopback') { + if ($settings->get('call_center', 'agent_contact_method') == 'loopback') { $agent_contact = str_replace("user/", "loopback/", $agent_contact); $agent_contact = str_replace("@", "/", $agent_contact); } diff --git a/app/call_centers/call_center_agent_status.php b/app/call_centers/call_center_agent_status.php index 61fcc19beb..149165bdef 100644 --- a/app/call_centers/call_center_agent_status.php +++ b/app/call_centers/call_center_agent_status.php @@ -47,7 +47,7 @@ $sql .= "where domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $tiers = $database->select($sql, $parameters, 'all'); - if (!empty($_SESSION['call_center']['queue_login']['text']) && $_SESSION['call_center']['queue_login']['text'] == 'dynamic') { + if (!empty($settings->get('call_center', 'queue_login')) && $settings->get('call_center', 'queue_login') == 'dynamic') { $per_queue_login = true; } else { diff --git a/app/call_centers/call_center_agents.php b/app/call_centers/call_center_agents.php index 3005a8f165..ec536694e2 100644 --- a/app/call_centers/call_center_agents.php +++ b/app/call_centers/call_center_agents.php @@ -94,7 +94,7 @@ $num_rows = $database->select($sql, $parameters ?? null, 'column'); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = "&search=".urlencode($search); if ($show == "all" && permission_exists('call_center_all')) { $param .= "&show=all"; diff --git a/app/call_centers/call_center_queue_edit.php b/app/call_centers/call_center_queue_edit.php index aa7dd4d978..d2abb4e1d2 100644 --- a/app/call_centers/call_center_queue_edit.php +++ b/app/call_centers/call_center_queue_edit.php @@ -685,21 +685,21 @@ unset($sounds); } -//set default values - if (empty($queue_strategy)) { $queue_strategy = "longest-idle-agent"; } - if (empty($queue_moh_sound)) { $queue_moh_sound = "\$\${hold_music}"; } - if (empty($queue_time_base_score)) { $queue_time_base_score = "system"; } - if (empty($queue_max_wait_time)) { $queue_max_wait_time = "0"; } - if (empty($queue_max_wait_time_with_no_agent)) { $queue_max_wait_time_with_no_agent = "90"; } - if (empty($queue_max_wait_time_with_no_agent_time_reached)) { $queue_max_wait_time_with_no_agent_time_reached = "30"; } - if (empty($queue_tier_rule_wait_second)) { $queue_tier_rule_wait_second = "30"; } - if (empty($queue_discard_abandoned_after)) { $queue_discard_abandoned_after = "900"; } - if (empty($queue_context)) { $queue_context = $domain_name; } - if ($queue_record_template === null) { $queue_record_template = 'false'; } - if ($queue_tier_rules_apply === null) { $queue_tier_rules_apply = false; } - if ($queue_tier_rule_wait_multiply_level === null) { $queue_tier_rule_wait_multiply_level = true; } - if ($queue_tier_rule_no_agent_no_wait === null) { $queue_tier_rule_no_agent_no_wait = true; } - if ($queue_abandoned_resume_allowed === null) { $queue_abandoned_resume_allowed = false; } +//set the default values + $queue_strategy = $queue_strategy ?? "longest-idle-agent"; + $queue_moh_sound = $queue_moh_sound ?? "\$\${hold_music}"; + $queue_time_base_score = $queue_time_base_score ?? "system"; + $queue_max_wait_time = $queue_max_wait_time ?? "0"; + $queue_max_wait_time_with_no_agent = $queue_max_wait_time_with_no_agent ?? "90"; + $queue_max_wait_time_with_no_agent_time_reached = $queue_max_wait_time_with_no_agent_time_reached ?? "30"; + $queue_tier_rule_wait_second = $queue_tier_rule_wait_second ?? "30"; + $queue_discard_abandoned_after = $queue_discard_abandoned_after ?? "900"; + $queue_context = $queue_context ?? $domain_name; + $queue_record_template = $queue_record_template ?? 'false'; + $queue_tier_rules_apply = $queue_tier_rules_apply ?? false; + $queue_tier_rule_wait_multiply_level = $queue_tier_rule_wait_multiply_level ?? true; + $queue_tier_rule_no_agent_no_wait = $queue_tier_rule_no_agent_no_wait ?? true; + $queue_abandoned_resume_allowed = $queue_abandoned_resume_allowed ?? false; //create token $object = new token; diff --git a/app/call_centers/call_center_queues.php b/app/call_centers/call_center_queues.php index f45ee1c477..b3d19fe446 100644 --- a/app/call_centers/call_center_queues.php +++ b/app/call_centers/call_center_queues.php @@ -144,11 +144,11 @@ echo button::create(['type'=>'button','label'=>$text['button-wallboard'],'icon'=>'th','link'=>PROJECT_PATH.'/app/call_center_wallboard/call_center_wallboard.php']); } $margin_left = permission_exists('call_center_agent_view') || permission_exists('call_center_wallboard') ? 'margin-left: 15px;' : null; - if (permission_exists('call_center_queue_add') && (!is_numeric($_SESSION['limit']['call_center_queues']['numeric'] ?? '') || $num_rows <= $_SESSION['limit']['call_center_queues']['numeric'])) { + if (permission_exists('call_center_queue_add') && (!is_numeric($settings->get('limit', 'call_center_queues') ?? '') || $num_rows <= $settings->get('limit', 'call_center_queues'))) { echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','style'=>$margin_left,'link'=>'call_center_queue_edit.php']); unset($margin_left); } - if (permission_exists('call_center_queue_add') && $result && (!is_numeric($_SESSION['limit']['call_center_queues']['numeric'] ?? '') || $num_rows <= $_SESSION['limit']['call_center_queues']['numeric'])) { + if (permission_exists('call_center_queue_add') && $result && (!is_numeric($settings->get('limit', 'call_center_queues') ?? '') || $num_rows <= $settings->get('limit', 'call_center_queues'))) { echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$settings->get('theme', 'button_icon_copy'),'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none; '.!empty($margin_left),'onclick'=>"modal_open('modal-copy','btn_copy');"]); unset($margin_left); } @@ -176,7 +176,7 @@ echo "
\n"; echo "
\n"; - if (permission_exists('call_center_queue_add') && $result && (!is_numeric($_SESSION['limit']['call_center_queues']['numeric'] ?? '') || $num_rows <= $_SESSION['limit']['call_center_queues']['numeric'])) { + if (permission_exists('call_center_queue_add') && $result && (!is_numeric($settings->get('limit', 'call_center_queues') ?? '') || $num_rows <= $settings->get('limit', 'call_center_queues'))) { echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]); } if (permission_exists('call_center_queue_delete') && $result) { diff --git a/app/call_centers/resources/classes/call_center.php b/app/call_centers/resources/classes/call_center.php index 0cee3b8b31..a466e5b3c8 100644 --- a/app/call_centers/resources/classes/call_center.php +++ b/app/call_centers/resources/classes/call_center.php @@ -37,9 +37,14 @@ const app_uuid = '95788e50-9500-079e-2807-fd530b0ea370'; /** - * define public variables + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string */ public $domain_uuid; + + /** + * define public variables + */ public $call_center_queue_uuid; public $dialplan_uuid; public $queue_name; @@ -47,10 +52,27 @@ public $destination_number; public $queue_cc_exit_keys; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_name; + /** * declare private variables */ - private $database; private $permission_prefix; private $list_page; private $table; @@ -59,11 +81,14 @@ /** * Called when the object is created */ - public function __construct() { - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); } /** @@ -100,7 +125,7 @@ $dialplan["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_name"] = ($this->queue_name != '') ? $this->queue_name : format_phone($this->destination_number); $dialplan["dialplan_number"] = $this->destination_number; - $dialplan["dialplan_context"] = $_SESSION['domain_name']; + $dialplan["dialplan_context"] = $this->domain_name; $dialplan["dialplan_continue"] = false; $dialplan["dialplan_order"] = "210"; $dialplan["dialplan_enabled"] = true; @@ -190,7 +215,7 @@ $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "callcenter"; - $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = $this->queue_name.'@'.$_SESSION["domain_name"]; + $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = $this->queue_name.'@'.$this->domain_name; $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "2"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; @@ -252,7 +277,7 @@ //clear the cache $cache = new cache; - $cache->delete("dialplan:".$_SESSION['domain_name']); + $cache->delete("dialplan:".$this->domain_name); //return the dialplan_uuid return $dialplan_response; @@ -299,7 +324,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, dialplan_uuid, queue_name, queue_extension from v_".$this->table." "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and ".$this->uuid_prefix."uuid in ('".implode("','", $uuids)."') "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -315,16 +340,16 @@ $x = 0; foreach ($call_center_queues as $call_center_queue_uuid => $call_center_queue) { $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $call_center_queue_uuid; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; $array['dialplans'][$x]['dialplan_uuid'] = $call_center_queue['dialplan_uuid']; - $array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['domain_uuid'] = $this->domain_uuid; $array['dialplan_details'][$x]['dialplan_uuid'] = $call_center_queue['dialplan_uuid']; - $array['dialplan_details'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplan_details'][$x]['domain_uuid'] = $this->domain_uuid; $array['call_center_tiers'][$x][$this->uuid_prefix.'uuid'] = $call_center_queue_uuid; - $array['call_center_tiers'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['call_center_tiers'][$x]['domain_uuid'] = $this->domain_uuid; $x++; - $array['call_center_tiers'][$x]['queue_name'] = $call_center_queue['queue_extension']."@".$_SESSION['domain_name']; - $array['call_center_tiers'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['call_center_tiers'][$x]['queue_name'] = $call_center_queue['queue_extension']."@".$this->domain_name; + $array['call_center_tiers'][$x]['domain_uuid'] = $this->domain_uuid; $x++; } @@ -337,7 +362,7 @@ //delete the queue in the switch if ($esl->is_connected()) { foreach ($uuids as $uuid) { - $cmd = "callcenter_config queue unload ".$call_center_queues[$uuid]['queue_extension']."@".$_SESSION['domain_name']; + $cmd = "callcenter_config queue unload ".$call_center_queues[$uuid]['queue_extension']."@".$this->domain_name; $response = event_socket::api($cmd); } } @@ -359,7 +384,7 @@ //clear the cache $cache = new cache; - $cache->delete("dialplan:".$_SESSION["domain_name"]); + $cache->delete("dialplan:".$this->domain_name); remove_config_from_cache('configuration:callcenter.conf'); //clear the destinations session array @@ -417,9 +442,9 @@ if (is_array($uuids) && @sizeof($uuids) != 0) { foreach ($uuids as $x => $uuid) { $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $uuid; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; $array['call_center_tiers'][$x]['call_center_agent_uuid'] = $uuid; - $array['call_center_tiers'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['call_center_tiers'][$x]['domain_uuid'] = $this->domain_uuid; } } @@ -580,7 +605,7 @@ //clear the cache $cache = new cache; - $cache->delete("dialplan:".$_SESSION["domain_name"]); + $cache->delete("dialplan:".$this->domain_name); //set message message::add($text['message-copy']); diff --git a/app/call_centers/resources/dashboard/call_center_agents.php b/app/call_centers/resources/dashboard/call_center_agents.php index b69ae3e164..f7f781d62d 100644 --- a/app/call_centers/resources/dashboard/call_center_agents.php +++ b/app/call_centers/resources/dashboard/call_center_agents.php @@ -39,7 +39,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'app/call_centers'); + $text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/call_centers'); //get http variables and set as php variables $order_by = $_GET["order_by"] ?? null; diff --git a/app/call_centers/waveform.php b/app/call_centers/waveform.php index 04f03fa01e..03d6bdea0d 100644 --- a/app/call_centers/waveform.php +++ b/app/call_centers/waveform.php @@ -46,20 +46,20 @@ if ($_GET['type'] == 'recordings') { $slash = substr($_GET['data'],0,1) != '/' ? '/' : null; - $full_file_path = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].$slash.str_replace($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'], '', $_GET['data']); + $full_file_path = $settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].$slash.str_replace($settings->get('switch', 'recordings')."/".$_SESSION['domain_name'], '', $_GET['data']); } else if ($_GET['type'] == 'sounds') { //get first installed language (like en/us/callie) - $language_paths = glob($_SESSION["switch"]['sounds']['dir']."/*/*/*"); + $language_paths = glob($settings->get('switch', 'sounds')."/*/*/*"); foreach ($language_paths as $key => $path) { - $path = str_replace($_SESSION["switch"]['sounds']['dir'].'/', "", $path); + $path = str_replace($settings->get('switch', 'sounds').'/', "", $path); $path_array = explode('/', $path); if (count($path_array) <> 3 || strlen($path_array[0]) <> 2 || strlen($path_array[1]) <> 2) { unset($language_paths[$key]); } - $language_paths[$key] = str_replace($_SESSION["switch"]['sounds']['dir']."/","",$language_paths[$key] ?? ''); + $language_paths[$key] = str_replace($settings->get('switch', 'sounds')."/","",$language_paths[$key] ?? ''); if (empty($language_paths[$key])) { unset($language_paths[$key]); } @@ -69,7 +69,7 @@ //determine the path for sound file $filename_parts = explode('/', str_replace('..', '', $_GET['data'])); if (!is_array($filename_parts) || @sizeof($filename_parts) != 2) { exit; } - $path = $_SESSION['switch']['sounds']['dir'].'/'.$language_path.'/'.$filename_parts[0].'/8000/'; + $path = $settings->get('switch', 'sounds').'/'.$language_path.'/'.$filename_parts[0].'/8000/'; //build full path to sound file $full_file_path = $path.$filename_parts[1]; @@ -91,13 +91,13 @@ $waveform = new Waveform($full_file_path); Waveform::$linesPerPixel = 1; // default: 8 Waveform::$samplesPerLine = 512; // default: 512 - Waveform::$colorA = !empty($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color - Waveform::$colorB = !empty($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color - Waveform::$backgroundColor = !empty($_SESSION['theme']['audio_player_waveform_color_background']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_background']['text']) : [0,0,0,0]; // array rgba, default: transparent - Waveform::$axisColor = !empty($_SESSION['theme']['audio_player_waveform_color_axis']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_axis']['text']) : [0,0,0,0.3]; // array rgba - Waveform::$singlePhase = filter_var($_SESSION['theme']['audio_player_waveform_single_phase']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom - Waveform::$singleAxis = filter_var($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis - $height = !empty($_SESSION['theme']['audio_player_waveform_height']['text']) && is_numeric(str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text'])) ? 2.2 * (int) str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text']) : null; + Waveform::$colorA = !empty($settings->get('theme', 'audio_player_waveform_color_a_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_a_leg')) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color + Waveform::$colorB = !empty($settings->get('theme', 'audio_player_waveform_color_b_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_b_leg')) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color + Waveform::$backgroundColor = !empty($settings->get('theme', 'audio_player_waveform_color_background')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_background')) : [0,0,0,0]; // array rgba, default: transparent + Waveform::$axisColor = !empty($settings->get('theme', 'audio_player_waveform_color_axis')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_axis')) : [0,0,0,0.3]; // array rgba + Waveform::$singlePhase = filter_var($settings->get('theme', 'audio_player_waveform_single_phase') ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom + Waveform::$singleAxis = filter_var($settings->get('theme', 'audio_player_waveform_single_axis') ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis + $height = !empty($settings->get('theme', 'audio_player_waveform_height')) && is_numeric(str_replace('px','',$settings->get('theme', 'audio_player_waveform_height'))) ? 2.2 * (int) str_replace('px','',$settings->get('theme', 'audio_player_waveform_height')) : null; $wf = $waveform->getWaveform($temp_filename, 1600, $height ?? 180); // input: png filename returns boolean true/false, or 'base64' returns base64 string } diff --git a/app/call_flows/call_flow_edit.php b/app/call_flows/call_flow_edit.php index 0123a17d51..4595f55dc5 100644 --- a/app/call_flows/call_flow_edit.php +++ b/app/call_flows/call_flow_edit.php @@ -470,7 +470,7 @@ echo " ".$text['label-call_flow_extension']."\n"; echo "\n"; echo "\n"; - echo " \n"; + echo " get('call_flow', 'extension_range') ?? '')."\">\n"; echo "
\n"; echo $text['description-call_flow_extension']."\n"; echo "\n"; @@ -575,8 +575,8 @@ if ($key == 'recordings') { if ( !empty($instance_value) && - ($instance_value == $row["value"] || $instance_value == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.$row["value"]) && - file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME)) + ($instance_value == $row["value"] || $instance_value == $settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].'/'.$row["value"]) && + file_exists($settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME)) ) { $selected = "selected='selected'"; $playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME); @@ -677,8 +677,8 @@ if ($key == 'recordings') { if ( !empty($instance_value) && - ($instance_value == $row["value"] || $instance_value == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.$row["value"]) && - file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME)) + ($instance_value == $row["value"] || $instance_value == $settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].'/'.$row["value"]) && + file_exists($settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME)) ) { $selected = "selected='selected'"; $playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME); diff --git a/app/call_flows/call_flows.php b/app/call_flows/call_flows.php index 6f866495b2..eb43308464 100644 --- a/app/call_flows/call_flows.php +++ b/app/call_flows/call_flows.php @@ -118,7 +118,7 @@ $num_rows = $database->select($sql, $parameters ?? null, 'column'); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = "&search=".urlencode($search); if ($show == "all" && permission_exists('call_flow_all')) { $param .= "&show=all"; diff --git a/app/call_flows/resources/classes/call_flows.php b/app/call_flows/resources/classes/call_flows.php index 2a86691976..a9f460a872 100644 --- a/app/call_flows/resources/classes/call_flows.php +++ b/app/call_flows/resources/classes/call_flows.php @@ -38,11 +38,39 @@ const app_name = 'call_flows'; const app_uuid = 'b1b70f85-6b42-429b-8c5a-60c8b02b7d14'; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_name; + /** * declare private variables */ - - private $database; private $permission_prefix; private $list_page; private $table; @@ -52,7 +80,14 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); //assign private variables $this->permission_prefix = 'call_flow_'; @@ -60,12 +95,6 @@ $this->table = 'call_flows'; $this->uuid_prefix = 'call_flow_'; $this->toggle_values = ['true','false']; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } - } /** @@ -101,7 +130,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, dialplan_uuid, call_flow_context from v_".$this->table." "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -116,11 +145,11 @@ $x = 0; foreach ($call_flows as $call_flow_uuid => $call_flow) { $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $call_flow_uuid; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; $array['dialplans'][$x]['dialplan_uuid'] = $call_flow['dialplan_uuid']; - $array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['domain_uuid'] = $this->domain_uuid; $array['dialplan_details'][$x]['dialplan_uuid'] = $call_flow['dialplan_uuid']; - $array['dialplan_details'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplan_details'][$x]['domain_uuid'] = $this->domain_uuid; $x++; } @@ -197,7 +226,7 @@ $sql .= "dialplan_uuid, call_flow_feature_code, call_flow_context from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (!empty($rows)) { foreach ($rows as $row) { @@ -265,8 +294,8 @@ //prepare the event $cmd = "sendevent PRESENCE_IN\n"; $cmd .= "proto: flow\n"; - $cmd .= "login: ".$row['call_flow_feature_code']."@".$_SESSION['domain_name']."\n"; - $cmd .= "from: ".$row['call_flow_feature_code']."@".$_SESSION['domain_name']."\n"; + $cmd .= "login: ".$row['call_flow_feature_code']."@".$this->domain_name."\n"; + $cmd .= "from: ".$row['call_flow_feature_code']."@".$this->domain_name."\n"; $cmd .= "status: Active (1 waiting)\n"; $cmd .= "rpid: unknown\n"; $cmd .= "event_type: presence\n"; @@ -327,7 +356,7 @@ $sql = "select * from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $x => $row) { diff --git a/app/call_flows/waveform.php b/app/call_flows/waveform.php index 8b760cd949..e65e25191c 100644 --- a/app/call_flows/waveform.php +++ b/app/call_flows/waveform.php @@ -46,20 +46,20 @@ if ($_GET['type'] == 'recordings') { $slash = substr($_GET['data'],0,1) != '/' ? '/' : null; - $full_file_path = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].$slash.str_replace($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'], '', $_GET['data']); + $full_file_path = $settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].$slash.str_replace($settings->get('switch', 'recordings')."/".$_SESSION['domain_name'], '', $_GET['data']); } else if ($_GET['type'] == 'sounds') { //get first installed language (like en/us/callie) - $language_paths = glob($_SESSION["switch"]['sounds']['dir']."/*/*/*"); + $language_paths = glob($settings->get('switch', 'sounds')."/*/*/*"); foreach ($language_paths as $key => $path) { - $path = str_replace($_SESSION["switch"]['sounds']['dir'].'/', "", $path); + $path = str_replace($settings->get('switch', 'sounds').'/', "", $path); $path_array = explode('/', $path); if (count($path_array) <> 3 || strlen($path_array[0]) <> 2 || strlen($path_array[1]) <> 2) { unset($language_paths[$key]); } - $language_paths[$key] = str_replace($_SESSION["switch"]['sounds']['dir']."/","",$language_paths[$key] ?? ''); + $language_paths[$key] = str_replace($settings->get('switch', 'sounds')."/","",$language_paths[$key] ?? ''); if (empty($language_paths[$key])) { unset($language_paths[$key]); } @@ -69,7 +69,7 @@ //determine the path for sound file $filename_parts = explode('/', str_replace('..', '', $_GET['data'])); if (!is_array($filename_parts) || @sizeof($filename_parts) != 2) { exit; } - $path = $_SESSION['switch']['sounds']['dir'].'/'.$language_path.'/'.$filename_parts[0].'/8000/'; + $path = $settings->get('switch', 'sounds').'/'.$language_path.'/'.$filename_parts[0].'/8000/'; //build full path to sound file $full_file_path = $path.$filename_parts[1]; @@ -91,13 +91,13 @@ $waveform = new Waveform($full_file_path); Waveform::$linesPerPixel = 1; // default: 8 Waveform::$samplesPerLine = 512; // default: 512 - Waveform::$colorA = !empty($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color - Waveform::$colorB = !empty($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color - Waveform::$backgroundColor = !empty($_SESSION['theme']['audio_player_waveform_color_background']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_background']['text']) : [0,0,0,0]; // array rgba, default: transparent - Waveform::$axisColor = !empty($_SESSION['theme']['audio_player_waveform_color_axis']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_axis']['text']) : [0,0,0,0.3]; // array rgba - Waveform::$singlePhase = filter_var($_SESSION['theme']['audio_player_waveform_single_phase']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom - Waveform::$singleAxis = filter_var($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis - $height = !empty($_SESSION['theme']['audio_player_waveform_height']['text']) && is_numeric(str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text'])) ? 2.2 * (int) str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text']) : null; + Waveform::$colorA = !empty($settings->get('theme', 'audio_player_waveform_color_a_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_a_leg')) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color + Waveform::$colorB = !empty($settings->get('theme', 'audio_player_waveform_color_b_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_b_leg')) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color + Waveform::$backgroundColor = !empty($settings->get('theme', 'audio_player_waveform_color_background')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_background')) : [0,0,0,0]; // array rgba, default: transparent + Waveform::$axisColor = !empty($settings->get('theme', 'audio_player_waveform_color_axis')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_axis')) : [0,0,0,0.3]; // array rgba + Waveform::$singlePhase = filter_var($settings->get('theme', 'audio_player_waveform_single_phase') ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom + Waveform::$singleAxis = filter_var($settings->get('theme', 'audio_player_waveform_single_axis') ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis + $height = !empty($settings->get('theme', 'audio_player_waveform_height')) && is_numeric(str_replace('px','',$settings->get('theme', 'audio_player_waveform_height'))) ? 2.2 * (int) str_replace('px','',$settings->get('theme', 'audio_player_waveform_height')) : null; $wf = $waveform->getWaveform($temp_filename, 1600, $height ?? 180); // input: png filename returns boolean true/false, or 'base64' returns base64 string } diff --git a/app/call_forward/call_forward.php b/app/call_forward/call_forward.php index 0941e45474..38b6f241e6 100644 --- a/app/call_forward/call_forward.php +++ b/app/call_forward/call_forward.php @@ -44,7 +44,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'app/call_forward'); + $text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/call_forward'); //get posted data and set defaults $action = $_POST['action'] ?? ''; @@ -127,7 +127,7 @@ unset($parameters); //prepare the paging - $rows_per_page = !empty($_SESSION['domain']['paging']['numeric']) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = !empty($settings->get('domain', 'paging')) ? $settings->get('domain', 'paging') : 50; if ($search) { $params[] = "search=" . $search; diff --git a/app/call_forward/resources/classes/call_forward.php b/app/call_forward/resources/classes/call_forward.php index 64d56a564b..03ccc168ef 100644 --- a/app/call_forward/resources/classes/call_forward.php +++ b/app/call_forward/resources/classes/call_forward.php @@ -37,12 +37,22 @@ const app_name = 'call_forward'; const app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d'; + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + public $domain_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + public $domain_name; + /** * declare public variables */ public $debug; - public $domain_uuid; - public $domain_name; public $extension_uuid; public $forward_all_destination; public $forward_all_enabled; @@ -50,11 +60,27 @@ public $outbound_caller_id_name; public $outbound_caller_id_number; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + /** * declare private variables */ - - private $database; private $extension; private $number_alias; private $toll_allow; @@ -62,15 +88,19 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); + //assign private variables $this->toggle_field = 'forward_all_enabled'; $this->toggle_values = ['true', 'false']; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } } public function set() { @@ -166,7 +196,7 @@ $sql .= "from v_extensions "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and extension_uuid in (" . implode(', ', $uuids) . ") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -235,7 +265,7 @@ if ($settings->get('device', 'feature_sync', false)) { foreach ($extensions as $uuid => $extension) { $feature_event_notify = new feature_event_notify; - $feature_event_notify->domain_name = $_SESSION['domain_name']; + $feature_event_notify->domain_name = $this->domain_name; $feature_event_notify->extension = $extension['extension']; $feature_event_notify->do_not_disturb = $extension['do_not_disturb']; $feature_event_notify->ring_count = ceil($extension['call_timeout'] / 6); @@ -252,7 +282,7 @@ } //synchronize configuration - if (!empty($_SESSION['switch']['extensions']['dir']) && is_readable($_SESSION['switch']['extensions']['dir'])) { + if (!empty($this->settings->get('switch', 'extensions')) && is_readable($this->settings->get('switch', 'extensions'))) { $ext = new extension; $ext->xml(); unset($ext); @@ -261,9 +291,9 @@ //clear the cache $cache = new cache; foreach ($extensions as $uuid => $extension) { - $cache->delete("directory:" . $extension['extension'] . "@" . $_SESSION['domain_name']); + $cache->delete("directory:" . $extension['extension'] . "@" . $this->domain_name); if ($extension['number_alias'] != '') { - $cache->delete("directory:" . $extension['number_alias'] . "@" . $_SESSION['domain_name']); + $cache->delete("directory:" . $extension['number_alias'] . "@" . $this->domain_name); } } diff --git a/app/call_forward/resources/classes/do_not_disturb.php b/app/call_forward/resources/classes/do_not_disturb.php index 0db547cff8..0098f3dcbb 100644 --- a/app/call_forward/resources/classes/do_not_disturb.php +++ b/app/call_forward/resources/classes/do_not_disturb.php @@ -33,32 +33,73 @@ const app_name = 'call_forward'; const app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d'; + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + public $domain_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + public $domain_name; + /** * declare public variables */ public $debug; - public $domain_uuid; - public $domain_name; public $extension_uuid; public $extension; public $enabled; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Username set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $username; + /** * declare private variables */ - - private $database; + private $permission; + private $list_page; + private $table; + private $uuid_prefix; + private $toggle_field; + private $toggle_values; /** * called when the object is created */ - public function __construct() { - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + $this->username = $setting_array['username'] ?? $_SESSION['username'] ?? ''; + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); } //update the user_status @@ -69,8 +110,8 @@ $user_status = "Logged Out"; $esl = event_socket::create(); if ($esl->is_connected()) { - $switch_cmd .= "callcenter_config agent set status ".$_SESSION['username']."@".$this->domain_name." '".$user_status."'"; - $switch_result = event_socket::api($switch_cmd); + $switch_cmd .= "callcenter_config agent set status ".$this->username."@".$this->domain_name." '".$user_status."'"; + $esl->request('api '.$switch_cmd); } //update the database user_status @@ -81,7 +122,7 @@ $sql .= "and username = :username "; $parameters['user_status'] = "Do Not Disturb"; $parameters['domain_uuid'] = $this->domain_uuid; - $parameters['username'] = $_SESSION['username']; + $parameters['username'] = $this->username; $this->database->execute($sql); } } @@ -140,18 +181,7 @@ } //function - /** - * declare private variables - */ - - private $permission; - private $list_page; - private $table; - private $uuid_prefix; - private $toggle_field; - private $toggle_values; - - /** + /** * toggle records */ public function toggle($records) { @@ -197,7 +227,7 @@ $sql .= "from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -257,10 +287,10 @@ $p->delete('extension_edit', 'temp'); //send feature event notify to the phone - if ($settings->get('device', 'feature_sync', false)) { + if ($this->settings->get('device', 'feature_sync', false)) { foreach ($extensions as $uuid => $extension) { $feature_event_notify = new feature_event_notify; - $feature_event_notify->domain_name = $_SESSION['domain_name']; + $feature_event_notify->domain_name = $this->domain_name; $feature_event_notify->extension = $extension['extension']; $feature_event_notify->do_not_disturb = $extension['do_not_disturb'] == "true" ? "false" : "true"; $feature_event_notify->ring_count = ceil($extension['call_timeout'] / 6); @@ -277,7 +307,7 @@ } //synchronize configuration - if (!empty($_SESSION['switch']['extensions']['dir']) && is_readable($_SESSION['switch']['extensions']['dir'])) { + if (!empty($this->settings->get('switch', 'extensions')) && is_readable($this->settings->get('switch', 'extensions'))) { $ext = new extension; $ext->xml(); unset($ext); @@ -286,9 +316,9 @@ //clear the cache $cache = new cache; foreach ($extensions as $uuid => $extension) { - $cache->delete("directory:".$extension['extension']."@".$_SESSION['domain_name']); + $cache->delete("directory:".$extension['extension']."@".$this->domain_name); if ($extension['number_alias'] != '') { - $cache->delete("directory:".$extension['number_alias']."@".$_SESSION['domain_name']); + $cache->delete("directory:".$extension['number_alias']."@".$this->domain_name); } } diff --git a/app/call_forward/resources/classes/feature_event_notify.php b/app/call_forward/resources/classes/feature_event_notify.php index a9173dcb55..7841ec464f 100644 --- a/app/call_forward/resources/classes/feature_event_notify.php +++ b/app/call_forward/resources/classes/feature_event_notify.php @@ -40,7 +40,7 @@ public $do_not_disturb; public $ring_count; - //feature_event method + //feature_event method public function send_notify() { $esl = event_socket::create(); if ($esl->is_connected()) { diff --git a/app/call_forward/resources/classes/follow_me.php b/app/call_forward/resources/classes/follow_me.php index bfd2026cad..1a7f751a86 100644 --- a/app/call_forward/resources/classes/follow_me.php +++ b/app/call_forward/resources/classes/follow_me.php @@ -38,9 +38,14 @@ const app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d'; /** - * declare public variables + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string */ public $domain_uuid; + + /** + * declare public variables + */ public $db_type; public $follow_me_uuid; public $cid_name_prefix; @@ -85,23 +90,52 @@ public $destination_order = 1; /** - * declare private variables + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object */ private $database; - private $toll_allow; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ private $domain_name; + + /** + * declare private variables + */ private $extension; - private $number_alias; + private $permission; + private $list_page; + private $table; + private $uuid_prefix; + private $toggle_field; + private $toggle_values; /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); } public function add() { @@ -270,18 +304,7 @@ } //function - /** - * declare private variables - */ - - private $permission; - private $list_page; - private $table; - private $uuid_prefix; - private $toggle_field; - private $toggle_values; - - /** + /** * toggle records */ public function toggle($records) { @@ -327,7 +350,7 @@ $sql .= "from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -410,7 +433,7 @@ if ($settings->get('device', 'feature_sync', false)) { foreach ($extensions as $uuid => $extension) { $feature_event_notify = new feature_event_notify; - $feature_event_notify->domain_name = $_SESSION['domain_name']; + $feature_event_notify->domain_name = $this->domain_name; $feature_event_notify->extension = $extension['extension']; $feature_event_notify->do_not_disturb = $extension['do_not_disturb']; $feature_event_notify->ring_count = ceil($extension['call_timeout'] / 6); @@ -427,7 +450,7 @@ } //synchronize configuration - if (!empty($_SESSION['switch']['extensions']['dir']) && is_readable($_SESSION['switch']['extensions']['dir'])) { + if (!empty($this->settings->get('switch', 'extensions')) && is_readable($this->settings->get('switch', 'extensions'))) { $ext = new extension; $ext->xml(); unset($ext); @@ -436,9 +459,9 @@ //clear the cache $cache = new cache; foreach ($extensions as $uuid => $extension) { - $cache->delete("directory:".$extension['extension']."@".$_SESSION['domain_name']); + $cache->delete("directory:".$extension['extension']."@".$this->domain_name); if ($extension['number_alias'] != '') { - $cache->delete("directory:".$extension['number_alias']."@".$_SESSION['domain_name']); + $cache->delete("directory:".$extension['number_alias']."@".$this->domain_name); } } diff --git a/app/call_forward/resources/dashboard/call_forward.php b/app/call_forward/resources/dashboard/call_forward.php index 2888b7e13e..f7da9d6160 100644 --- a/app/call_forward/resources/dashboard/call_forward.php +++ b/app/call_forward/resources/dashboard/call_forward.php @@ -15,7 +15,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'app/call_forward'); + $text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/call_forward'); //extensions link $extension_link = '#'; diff --git a/app/call_recordings/call_recordings.php b/app/call_recordings/call_recordings.php index 56ef110235..432fd28904 100644 --- a/app/call_recordings/call_recordings.php +++ b/app/call_recordings/call_recordings.php @@ -50,6 +50,7 @@ //set additional variables $search = $_GET["search"] ?? ''; $show = $_GET["show"] ?? ''; + $result_count = 0; //get the http post data if (!empty($_POST['call_recordings']) && is_array($_POST['call_recordings'])) { @@ -100,7 +101,7 @@ $parameters['time_zone'] = $time_zone; //prepare some of the paging values - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $page = $_GET['page'] ?? ''; if (empty($page)) { $page = 0; $_GET['page'] = 0; } $offset = $rows_per_page * $page; @@ -145,8 +146,8 @@ } //limit the number of results - if (!empty($_SESSION['cdr']['limit']['numeric']) && $_SESSION['cdr']['limit']['numeric'] > 0) { - $num_rows = $_SESSION['cdr']['limit']['numeric']; + if (!empty($settings->get('cdr', 'limit')) && $settings->get('cdr', 'limit') > 0) { + $num_rows = $settings->get('cdr', 'limit'); } //prepare to page the results diff --git a/app/call_recordings/resources/classes/call_recordings.php b/app/call_recordings/resources/classes/call_recordings.php index 97b2e4c91d..ca01f78aad 100644 --- a/app/call_recordings/resources/classes/call_recordings.php +++ b/app/call_recordings/resources/classes/call_recordings.php @@ -35,11 +35,45 @@ const app_name = 'follow_me'; const app_uuid = 'b1b70f85-6b42-429b-8c5a-60c8b02b7d14'; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Username set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $username; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_name; + /** * declare the variables */ - private $settings; - private $database; private $name; private $table; private $description_field; @@ -50,18 +84,21 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); + //assign the variables $this->name = 'call_recording'; $this->table = 'call_recordings'; $this->description_field = 'call_recording_description'; $this->location = 'call_recordings.php'; - //allow global - $this->database = database::new(); - - //initialize the settings object - $this->settings = new settings(["domain_uuid" => $_SESSION['domain_uuid'], "user_uuid" => $_SESSION['user_uuid']]); } /** diff --git a/app/call_recordings/waveform.php b/app/call_recordings/waveform.php index 0f9127f645..8ed6db884f 100644 --- a/app/call_recordings/waveform.php +++ b/app/call_recordings/waveform.php @@ -44,7 +44,7 @@ //get call recording details from database $sql = "select call_recording_name, call_recording_path "; - if (!empty($_SESSION['call_recordings']['storage_type']['text']) && $_SESSION['call_recordings']['storage_type']['text'] == 'base64' && !empty($row['call_recording_base64'])) { + if (!empty($settings->get('call_recordings', 'storage_type')) && $settings->get('call_recordings', 'storage_type') == 'base64' && !empty($row['call_recording_base64'])) { $sql = ", call_recording_base64 "; } $sql .= "from view_call_recordings "; @@ -54,7 +54,7 @@ if (is_array($row) && @sizeof($row) != 0) { $call_recording_name = $row['call_recording_name']; $call_recording_path = $row['call_recording_path']; - if (!empty($_SESSION['call_recordings']['storage_type']['text']) && $_SESSION['call_recordings']['storage_type']['text'] == 'base64' && !empty($row['call_recording_base64'])) { + if (!empty($settings->get('call_recordings', 'storage_type')) && $settings->get('call_recordings', 'storage_type') == 'base64' && !empty($row['call_recording_base64'])) { file_put_contents($call_recording_path.'/'.$call_recording_name, base64_decode($row['call_recording_base64'])); } } @@ -78,13 +78,13 @@ $waveform = new Waveform($full_recording_path); Waveform::$linesPerPixel = 1; // default: 8 Waveform::$samplesPerLine = 512; // default: 512 - Waveform::$colorA = !empty($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color - Waveform::$colorB = !empty($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color - Waveform::$backgroundColor = !empty($_SESSION['theme']['audio_player_waveform_color_background']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_background']['text']) : [0,0,0,0]; // array rgba, default: transparent - Waveform::$axisColor = !empty($_SESSION['theme']['audio_player_waveform_color_axis']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_axis']['text']) : [0,0,0,0.3]; // array rgba - Waveform::$singlePhase = filter_var($_SESSION['theme']['audio_player_waveform_single_phase']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom - Waveform::$singleAxis = filter_var($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis - $height = !empty($_SESSION['theme']['audio_player_waveform_height']['text']) && is_numeric(str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text'])) ? 2.2 * (int) str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text']) : null; + Waveform::$colorA = !empty($settings->get('theme', 'audio_player_waveform_color_a_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_a_leg')) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color + Waveform::$colorB = !empty($settings->get('theme', 'audio_player_waveform_color_b_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_b_leg')) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color + Waveform::$backgroundColor = !empty($settings->get('theme', 'audio_player_waveform_color_background')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_background')) : [0,0,0,0]; // array rgba, default: transparent + Waveform::$axisColor = !empty($settings->get('theme', 'audio_player_waveform_color_axis')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_axis')) : [0,0,0,0.3]; // array rgba + Waveform::$singlePhase = filter_var($settings->get('theme', 'audio_player_waveform_single_phase') ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom + Waveform::$singleAxis = filter_var($settings->get('theme', 'audio_player_waveform_single_axis') ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis + $height = !empty($settings->get('theme', 'audio_player_waveform_height')) && is_numeric(str_replace('px','',$settings->get('theme', 'audio_player_waveform_height'))) ? 2.2 * (int) str_replace('px','',$settings->get('theme', 'audio_player_waveform_height')) : null; $wf = $waveform->getWaveform($temp_filename, 1600, $height ?? 180); // input: png filename returns boolean true/false, or 'base64' returns base64 string } @@ -111,7 +111,7 @@ } //if base64, remove temp recording file - if (!empty($_SESSION['call_recordings']['storage_type']['text']) && $_SESSION['call_recordings']['storage_type']['text'] == 'base64' && !empty($row['call_recording_base64'])) { + if (!empty($settings->get('call_recordings', 'storage_type')) && $settings->get('call_recordings', 'storage_type') == 'base64' && !empty($row['call_recording_base64'])) { @unlink($full_recording_path); } unset($row); diff --git a/app/calls_active/calls_active.php b/app/calls_active/calls_active.php index f9bf5b7ec7..4f85a51bf3 100644 --- a/app/calls_active/calls_active.php +++ b/app/calls_active/calls_active.php @@ -210,7 +210,7 @@ } function get_record_cmd(uuid, prefix, name) { - cmd = \"uuid_record \"+uuid+\" start ".$_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/archive/".date("Y")."/".date("M")."/".date("d")."/\"+uuid+\".wav\"; + cmd = \"uuid_record \"+uuid+\" start ".$settings->get('switch', 'recordings')."/".$_SESSION['domain_name']."/archive/".date("Y")."/".date("M")."/".date("d")."/\"+uuid+\".wav\"; return escape(cmd); } */ diff --git a/app/calls_active/calls_active_inc.php b/app/calls_active/calls_active_inc.php index 7a14d5dc93..91a58003d4 100644 --- a/app/calls_active/calls_active_inc.php +++ b/app/calls_active/calls_active_inc.php @@ -273,7 +273,7 @@ echo " \n"; echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; ?> diff --git a/app/click_to_call/click_to_call.php b/app/click_to_call/click_to_call.php index debd831c82..1982a5cb72 100644 --- a/app/click_to_call/click_to_call.php +++ b/app/click_to_call/click_to_call.php @@ -101,16 +101,16 @@ //add record path and name if ($rec == "true") { - $record_path = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/archive/".date("Y")."/".date("M")."/".date("d"); - if (isset($_SESSION['recordings']['extension']['text'])) { - $record_extension = $_SESSION['recordings']['extension']['text']; + $record_path = $settings->get('switch', 'recordings')."/".$_SESSION['domain_name']."/archive/".date("Y")."/".date("M")."/".date("d"); + if (!empty($settings->get('recordings', 'extension'))) { + $record_extension = $settings->get('recordings', 'extension'); } else { $record_extension = 'wav'; } - if (isset($_SESSION['recordings']['template']['text'])) { + if (!empty($settings->get('recordings', 'template'))) { //${year}${month}${day}-${caller_id_number}-${caller_destination}-${uuid}.${record_extension} - $record_name = $_SESSION['recordings']['template']['text']; + $record_name = $settings->get('recordings', 'template'); $record_name = str_replace('${year}', date("Y"), $record_name); $record_name = str_replace('${month}', date("M"), $record_name); $record_name = str_replace('${day}', date("d"), $record_name); diff --git a/app/conference_centers/conference_center_edit.php b/app/conference_centers/conference_center_edit.php index cc41cd4c7c..81ad8bc355 100644 --- a/app/conference_centers/conference_center_edit.php +++ b/app/conference_centers/conference_center_edit.php @@ -352,7 +352,7 @@ echo " ".$text['label-conference_center_extension']."\n"; echo "\n"; echo "\n"; - echo " \n"; + echo " get('conference_center', 'extension_range') ?? '')."\">\n"; echo "
\n"; echo $text['description-conference_center_extension']."\n"; echo "\n"; @@ -379,8 +379,8 @@ if ($key == 'recordings') { if ( !empty($instance_value) && - ($instance_value == $row["value"] || $instance_value == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.$row["value"]) && - file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME)) + ($instance_value == $row["value"] || $instance_value == $settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].'/'.$row["value"]) && + file_exists($settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME)) ) { $selected = "selected='selected'"; $playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME); diff --git a/app/conference_centers/conference_centers.php b/app/conference_centers/conference_centers.php index afa55814b8..8287521693 100644 --- a/app/conference_centers/conference_centers.php +++ b/app/conference_centers/conference_centers.php @@ -112,7 +112,7 @@ $num_rows = $database->select($sql, $parameters ?? null, 'column'); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = "&search=".urlencode($search); if ($show == "all" && permission_exists('conference_center_all')) { $param .= "&show=all"; diff --git a/app/conference_centers/conference_room_edit.php b/app/conference_centers/conference_room_edit.php index 72b4d50883..f07583aabf 100644 --- a/app/conference_centers/conference_room_edit.php +++ b/app/conference_centers/conference_room_edit.php @@ -90,6 +90,10 @@ $participant_pin = preg_replace('{\D}', '', $participant_pin); } +//set the default values + $profile = $profile ?? 'default'; + $max_members = $max_members ?? 0; + //get the conference centers array and set a default conference center $sql = "select * from v_conference_centers "; $sql .= "where domain_uuid = :domain_uuid "; @@ -141,7 +145,7 @@ $default_language = 'en'; $default_dialect = 'us'; $default_voice = 'callie'; - $switch_cmd = "conference ".$conference_room_uuid."@".$_SESSION['domain_name']." play ".$_SESSION['switch']['sounds']['dir']."/".$default_language."/".$default_dialect."/".$default_voice."/ivr/ivr-recording_started.wav"; + $switch_cmd = "conference ".$conference_room_uuid."@".$_SESSION['domain_name']." play ".$settings->get('switch', 'sounds')."/".$default_language."/".$default_dialect."/".$default_voice."/ivr/ivr-recording_started.wav"; //connect to event socket $esl = event_socket::create(); @@ -296,10 +300,6 @@ if (empty($_POST["persistformvar"])) { if ($action == "add" && permission_exists('conference_room_add')) { - //set default values - if (empty($profile)) { $profile = 'default'; } - if (empty($max_members)) { $max_members = 0; } - //add a conference room $conference_room_uuid = uuid(); $array['conference_rooms'][0]['conference_room_uuid'] = $conference_room_uuid; diff --git a/app/conference_centers/conference_rooms.php b/app/conference_centers/conference_rooms.php index 1fdf84399c..b1af9859d6 100644 --- a/app/conference_centers/conference_rooms.php +++ b/app/conference_centers/conference_rooms.php @@ -96,7 +96,7 @@ $default_language = 'en'; $default_dialect = 'us'; $default_voice = 'callie'; - $switch_cmd = "conference ".$meeting_uuid."@".$_SESSION['domain_name']." play ".$_SESSION['switch']['sounds']['dir']."/".$default_language."/".$default_dialect."/".$default_voice."/ivr/ivr-recording_started.wav"; + $switch_cmd = "conference ".$meeting_uuid."@".$_SESSION['domain_name']." play ".$settings->get('switch', 'sounds')."/".$default_language."/".$default_dialect."/".$default_voice."/ivr/ivr-recording_started.wav"; //connect to event socket $esl = event_socket::create(); if ($esl) { @@ -178,7 +178,7 @@ $num_rows = $conference_center->room_count(); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = !empty($search) ? "&search=".$search : null; if (isset($_GET['page'])) { $page = is_numeric($_GET['page']) ? $_GET['page'] : 0; diff --git a/app/conference_centers/conference_session_details.php b/app/conference_centers/conference_session_details.php index 941a5dd46e..6b53e14432 100644 --- a/app/conference_centers/conference_session_details.php +++ b/app/conference_centers/conference_session_details.php @@ -85,7 +85,7 @@ unset($sql, $parameters); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = ''; $page = isset($_GET['page']) ? $_GET['page'] : 0; list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); @@ -111,7 +111,7 @@ echo "
".$text['title-conference_session_details']."
".number_format($num_rows)."
\n"; echo "
\n"; echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','link'=>'conference_sessions.php']); - $tmp_dir = $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day; + $tmp_dir = $settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day; $tmp_name = ''; if (!empty($row['conference_session_uuid']) && file_exists($tmp_dir.'/'.$row['conference_session_uuid'].'.mp3')) { $tmp_name = $row['conference_session_uuid'].".mp3"; diff --git a/app/conference_centers/conference_sessions.php b/app/conference_centers/conference_sessions.php index 345fc049a3..c177c6d612 100644 --- a/app/conference_centers/conference_sessions.php +++ b/app/conference_centers/conference_sessions.php @@ -88,7 +88,7 @@ unset($sql, $parameters); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = ''; $page = isset($_GET['page']) ? $_GET['page'] : 0; list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); diff --git a/app/conference_centers/resources/classes/call_center_notify.php b/app/conference_centers/resources/classes/call_center_notify.php index 0153776787..d871820a31 100644 --- a/app/conference_centers/resources/classes/call_center_notify.php +++ b/app/conference_centers/resources/classes/call_center_notify.php @@ -50,7 +50,7 @@ $event .= "login: agent+".$this->agent_name."@".$this->domain_name."\n"; $event .= "unique-id: ".$this->agent_uuid."\n"; $event .= "answer-state: ".$this->answer_state."\n"; - event_socket::command($event); + $esl->request('api ' . $event); //echo $event."
"; } } //function diff --git a/app/conference_centers/resources/classes/conference_centers.php b/app/conference_centers/resources/classes/conference_centers.php index 16ce6db4c7..c50cd50af8 100644 --- a/app/conference_centers/resources/classes/conference_centers.php +++ b/app/conference_centers/resources/classes/conference_centers.php @@ -35,9 +35,14 @@ Luis Daniel Lucio Quiroz const app_uuid = '8d083f5a-f726-42a8-9ffa-8d28f848f10e'; /** - * declare public variables + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string */ public $domain_uuid; + + /** + * declare public variables + */ public $conference_room_uuid; public $order_by; public $order; @@ -48,11 +53,39 @@ Luis Daniel Lucio Quiroz public $created_by; public $toggle_field; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Username set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $username; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_name; + /** * declare private variables */ - - private $database; private $permission_prefix; private $list_page; private $table; @@ -63,13 +96,15 @@ Luis Daniel Lucio Quiroz /** * Called when the object is created */ - public function __construct() { - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); } /** @@ -147,7 +182,7 @@ Luis Daniel Lucio Quiroz if ($not_admin) { $sql .= "and r.conference_room_uuid = u.conference_room_uuid "; $sql .= "and u.user_uuid = :user_uuid "; - $parameters['user_uuid'] = $_SESSION["user_uuid"]; + $parameters['user_uuid'] = $this->user_uuid; } if (!empty($this->search)) { $sql .= "and ("; @@ -240,8 +275,8 @@ Luis Daniel Lucio Quiroz } //set the path for the directory - $default_path = $_SESSION['switch']['call_recordings']['dir']."/".$_SESSION['domain_name']; - + $default_path = $this->settings->get('switch', 'call_recordings')."/".$this->domain_name; + //get the file path and name $record_path = dirname($recording); $record_name = basename($recording); @@ -288,7 +323,7 @@ Luis Daniel Lucio Quiroz } //if base64, remove temp recording file - //if ($_SESSION['conference']['storage_type']['text'] == 'base64' && $row['conference_recording_base64'] != '') { + //if ($this->settings->get('conference', 'storage_type') == 'base64' && $row['conference_recording_base64'] != '') { // @unlink($record_path.'/'.$record_name); //} } @@ -330,18 +365,18 @@ Luis Daniel Lucio Quiroz $sql = "select dialplan_uuid from v_conference_centers "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and conference_center_uuid = :conference_center_uuid "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $parameters['conference_center_uuid'] = $record['uuid']; $dialplan_uuid = $this->database->select($sql, $parameters, 'column'); unset($sql, $parameters); //create array $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; $array['dialplan_details'][$x]['dialplan_uuid'] = $dialplan_uuid; - $array['dialplan_details'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplan_details'][$x]['domain_uuid'] = $this->domain_uuid; $array['dialplans'][$x]['dialplan_uuid'] = $dialplan_uuid; - $array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['domain_uuid'] = $this->domain_uuid; } } @@ -363,7 +398,7 @@ Luis Daniel Lucio Quiroz //clear the cache $cache = new cache; - $cache->delete("dialplan:".$_SESSION["domain_name"]); + $cache->delete("dialplan:".$this->domain_name); //clear the destinations session array if (isset($_SESSION['destinations']['array'])) { @@ -412,9 +447,9 @@ Luis Daniel Lucio Quiroz //create array $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; $array['conference_room_users'][$x]['conference_room_uuid'] = $record['uuid']; - $array['conference_room_users'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['conference_room_users'][$x]['domain_uuid'] = $this->domain_uuid; } } @@ -473,9 +508,9 @@ Luis Daniel Lucio Quiroz //create array $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; $array['conference_session_details'][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; - $array['conference_session_details'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['conference_session_details'][$x]['domain_uuid'] = $this->domain_uuid; } } @@ -543,7 +578,7 @@ Luis Daniel Lucio Quiroz $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, dialplan_uuid from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (!empty($rows)) { foreach ($rows as $row) { @@ -584,7 +619,7 @@ Luis Daniel Lucio Quiroz //clear the cache $cache = new cache; - $cache->delete("dialplan:".$_SESSION["domain_name"]); + $cache->delete("dialplan:".$this->domain_name); //clear the destinations session array if (isset($_SESSION['destinations']['array'])) { @@ -646,7 +681,7 @@ Luis Daniel Lucio Quiroz $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (!empty($rows)) { foreach ($rows as $row) { @@ -669,9 +704,9 @@ Luis Daniel Lucio Quiroz $default_language = 'en'; $default_dialect = 'us'; $default_voice = 'callie'; -// $recording_dir = $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.date("Y").'/'.date("M").'/'.date("d"); -// $switch_cmd_record = "conference ".$meeting_uuid[$uuid]."@".$_SESSION['domain_name']." record ".$recording_dir.'/'.$meeting_uuid[$uuid].'.wav'; - $switch_cmd_notice = "conference ".$meeting_uuid[$uuid]."@".$_SESSION['domain_name']." play ".$_SESSION['switch']['sounds']['dir']."/".$default_language."/".$default_dialect."/".$default_voice."/ivr/ivr-recording_started.wav"; +// $recording_dir = $this->settings->get('switch', 'recordings').'/'.$this->domain_name.'/archive/'.date("Y").'/'.date("M").'/'.date("d"); +// $switch_cmd_record = "conference ".$meeting_uuid[$uuid]."@".$this->domain_name." record ".$recording_dir.'/'.$meeting_uuid[$uuid].'.wav'; + $switch_cmd_notice = "conference ".$meeting_uuid[$uuid]."@".$this->domain_name." play ".$this->settings->get('switch', 'sounds')."/".$default_language."/".$default_dialect."/".$default_voice."/ivr/ivr-recording_started.wav"; //execute api commands // if (!file_exists($recording_dir.'/'.$meeting_uuid[$uuid].'.wav')) { $esl = event_socket::create(); @@ -744,7 +779,7 @@ Luis Daniel Lucio Quiroz $sql = "select * from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (!empty($rows)) { foreach ($rows as $x => $row) { @@ -787,7 +822,7 @@ Luis Daniel Lucio Quiroz //example conference center /* $conference_center = new conference_centers; - $conference_center->domain_uuid = $_SESSION['domain_uuid']; + $conference_center->domain_uuid = $this->domain_uuid; $conference_center->rows_per_page = 150; $conference_center->offset = 0; $conference_center->created_by = uuid; diff --git a/app/conference_centers/waveform.php b/app/conference_centers/waveform.php index 8b760cd949..e65e25191c 100644 --- a/app/conference_centers/waveform.php +++ b/app/conference_centers/waveform.php @@ -46,20 +46,20 @@ if ($_GET['type'] == 'recordings') { $slash = substr($_GET['data'],0,1) != '/' ? '/' : null; - $full_file_path = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].$slash.str_replace($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'], '', $_GET['data']); + $full_file_path = $settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].$slash.str_replace($settings->get('switch', 'recordings')."/".$_SESSION['domain_name'], '', $_GET['data']); } else if ($_GET['type'] == 'sounds') { //get first installed language (like en/us/callie) - $language_paths = glob($_SESSION["switch"]['sounds']['dir']."/*/*/*"); + $language_paths = glob($settings->get('switch', 'sounds')."/*/*/*"); foreach ($language_paths as $key => $path) { - $path = str_replace($_SESSION["switch"]['sounds']['dir'].'/', "", $path); + $path = str_replace($settings->get('switch', 'sounds').'/', "", $path); $path_array = explode('/', $path); if (count($path_array) <> 3 || strlen($path_array[0]) <> 2 || strlen($path_array[1]) <> 2) { unset($language_paths[$key]); } - $language_paths[$key] = str_replace($_SESSION["switch"]['sounds']['dir']."/","",$language_paths[$key] ?? ''); + $language_paths[$key] = str_replace($settings->get('switch', 'sounds')."/","",$language_paths[$key] ?? ''); if (empty($language_paths[$key])) { unset($language_paths[$key]); } @@ -69,7 +69,7 @@ //determine the path for sound file $filename_parts = explode('/', str_replace('..', '', $_GET['data'])); if (!is_array($filename_parts) || @sizeof($filename_parts) != 2) { exit; } - $path = $_SESSION['switch']['sounds']['dir'].'/'.$language_path.'/'.$filename_parts[0].'/8000/'; + $path = $settings->get('switch', 'sounds').'/'.$language_path.'/'.$filename_parts[0].'/8000/'; //build full path to sound file $full_file_path = $path.$filename_parts[1]; @@ -91,13 +91,13 @@ $waveform = new Waveform($full_file_path); Waveform::$linesPerPixel = 1; // default: 8 Waveform::$samplesPerLine = 512; // default: 512 - Waveform::$colorA = !empty($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color - Waveform::$colorB = !empty($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color - Waveform::$backgroundColor = !empty($_SESSION['theme']['audio_player_waveform_color_background']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_background']['text']) : [0,0,0,0]; // array rgba, default: transparent - Waveform::$axisColor = !empty($_SESSION['theme']['audio_player_waveform_color_axis']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_axis']['text']) : [0,0,0,0.3]; // array rgba - Waveform::$singlePhase = filter_var($_SESSION['theme']['audio_player_waveform_single_phase']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom - Waveform::$singleAxis = filter_var($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis - $height = !empty($_SESSION['theme']['audio_player_waveform_height']['text']) && is_numeric(str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text'])) ? 2.2 * (int) str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text']) : null; + Waveform::$colorA = !empty($settings->get('theme', 'audio_player_waveform_color_a_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_a_leg')) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color + Waveform::$colorB = !empty($settings->get('theme', 'audio_player_waveform_color_b_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_b_leg')) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color + Waveform::$backgroundColor = !empty($settings->get('theme', 'audio_player_waveform_color_background')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_background')) : [0,0,0,0]; // array rgba, default: transparent + Waveform::$axisColor = !empty($settings->get('theme', 'audio_player_waveform_color_axis')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_axis')) : [0,0,0,0.3]; // array rgba + Waveform::$singlePhase = filter_var($settings->get('theme', 'audio_player_waveform_single_phase') ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom + Waveform::$singleAxis = filter_var($settings->get('theme', 'audio_player_waveform_single_axis') ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis + $height = !empty($settings->get('theme', 'audio_player_waveform_height')) && is_numeric(str_replace('px','',$settings->get('theme', 'audio_player_waveform_height'))) ? 2.2 * (int) str_replace('px','',$settings->get('theme', 'audio_player_waveform_height')) : null; $wf = $waveform->getWaveform($temp_filename, 1600, $height ?? 180); // input: png filename returns boolean true/false, or 'base64' returns base64 string } diff --git a/app/conference_controls/conference_control_details.php b/app/conference_controls/conference_control_details.php index fb4fea949d..fc6a83fea4 100644 --- a/app/conference_controls/conference_control_details.php +++ b/app/conference_controls/conference_control_details.php @@ -101,7 +101,7 @@ unset($sql, $parameters); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = "&id=".!empty($conference_control_uuid); if (isset($_GET['page'])) { $page = isset($_GET['page']) ? $_GET['page'] : 0; diff --git a/app/conference_controls/conference_controls.php b/app/conference_controls/conference_controls.php index cfb29d8969..4a6add57c6 100644 --- a/app/conference_controls/conference_controls.php +++ b/app/conference_controls/conference_controls.php @@ -100,7 +100,7 @@ unset($sql); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = $search ? "&search=".$search : null; $page = isset($_GET['page']) ? $_GET['page'] : 0; list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); diff --git a/app/conference_controls/resources/classes/conference_controls.php b/app/conference_controls/resources/classes/conference_controls.php index 2c0636c9e3..f78eaba3fc 100644 --- a/app/conference_controls/resources/classes/conference_controls.php +++ b/app/conference_controls/resources/classes/conference_controls.php @@ -55,11 +55,9 @@ /** * called when the object is created */ - public function __construct() { - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } + public function __construct(array $setting_array = []) { + //set objects + $this->database = $setting_array['database'] ?? database::new(); } /** diff --git a/app/conference_profiles/conference_profile_params.php b/app/conference_profiles/conference_profile_params.php index 5ebfb26e97..283f80e1a3 100644 --- a/app/conference_profiles/conference_profile_params.php +++ b/app/conference_profiles/conference_profile_params.php @@ -88,7 +88,7 @@ unset($sql, $parameters); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = "&id=".$conference_profile_uuid; if (isset($_GET['page'])) { $page = isset($_GET['page']) ? $_GET['page'] : 0; diff --git a/app/conference_profiles/resources/classes/conference_profiles.php b/app/conference_profiles/resources/classes/conference_profiles.php index c04abf49ba..e742b2e621 100644 --- a/app/conference_profiles/resources/classes/conference_profiles.php +++ b/app/conference_profiles/resources/classes/conference_profiles.php @@ -45,6 +45,7 @@ private $toggle_values; private $description_field; private $location; + private $database; /** * declare public variables @@ -54,11 +55,9 @@ /** * called when the object is created */ - public function __construct() { - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } + public function __construct(array $setting_array = []) { + //set objects + $this->database = $setting_array['database'] ?? database::new(); } /** diff --git a/app/conferences/conference_edit.php b/app/conferences/conference_edit.php index 1b0f353c69..d19697ecf9 100644 --- a/app/conferences/conference_edit.php +++ b/app/conferences/conference_edit.php @@ -404,7 +404,7 @@ echo " ".$text['label-extension']."\n"; echo "\n"; echo "\n"; - echo " \n"; + echo " get('conference', 'extension_range') ?? '')."\">\n"; echo "
\n"; echo "".$text['description-extension']."\n"; echo "\n"; diff --git a/app/conferences/conferences.php b/app/conferences/conferences.php index 1e389f0067..40e0369508 100644 --- a/app/conferences/conferences.php +++ b/app/conferences/conferences.php @@ -121,7 +121,7 @@ $num_rows = $database->select($sql, $parameters ?? null, 'column'); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = "&search=".urlencode($search); if ($show == "all" && permission_exists('conference_all')) { $param .= "&show=all"; diff --git a/app/conferences/resources/classes/conferences.php b/app/conferences/resources/classes/conferences.php index 86bc40b8bf..2975197b70 100644 --- a/app/conferences/resources/classes/conferences.php +++ b/app/conferences/resources/classes/conferences.php @@ -33,11 +33,33 @@ const app_name = 'conferences'; const app_uuid = 'b81412e8-7253-91f4-e48e-42fc2c9a38d9'; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_name; + /** * declare private variables */ - - private $database; private $permission_prefix; private $list_page; private $table; @@ -48,7 +70,15 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + //assign private variables $this->permission_prefix = 'conference_'; $this->list_page = 'conferences.php'; @@ -56,11 +86,6 @@ $this->uuid_prefix = 'conference_'; $this->toggle_field = 'conference_enabled'; $this->toggle_values = ['true','false']; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } } /** @@ -92,20 +117,20 @@ $sql = "select dialplan_uuid from v_conferences "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and conference_uuid = :conference_uuid "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $parameters['conference_uuid'] = $record['uuid']; $dialplan_uuid = $this->database->select($sql, $parameters, 'column'); unset($sql, $parameters); //build array $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; $array['conference_users'][$x]['conference_uuid'] = $record['uuid']; - $array['conference_users'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['conference_users'][$x]['domain_uuid'] = $this->domain_uuid; $array['dialplans'][$x]['dialplan_uuid'] = $dialplan_uuid; - $array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['domain_uuid'] = $this->domain_uuid; $array['dialplan_details'][$x]['dialplan_uuid'] = $dialplan_uuid; - $array['dialplan_details'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplan_details'][$x]['domain_uuid'] = $this->domain_uuid; } } @@ -133,7 +158,7 @@ //clear the cache $cache = new cache; - $cache->delete("dialplan:".$_SESSION["domain_name"]); + $cache->delete("dialplan:".$this->domain_name); //clear the destinations session array if (isset($_SESSION['destinations']['array'])) { @@ -180,7 +205,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, dialplan_uuid from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -221,7 +246,7 @@ //clear the cache $cache = new cache; - $cache->delete("dialplan:".$_SESSION["domain_name"]); + $cache->delete("dialplan:".$this->domain_name); //clear the destinations session array if (isset($_SESSION['destinations']['array'])) { @@ -270,7 +295,7 @@ $sql = "select * from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { $y = 0; @@ -291,7 +316,7 @@ $sql_2 .= "where conference_uuid = :conference_uuid "; $sql_2 .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; $parameters_2['conference_uuid'] = $row['conference_uuid']; - $parameters_2['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters_2['domain_uuid'] = $this->domain_uuid; $conference_users = $this->database->select($sql_2, $parameters_2, 'all'); if (is_array($conference_users) && @sizeof($conference_users) != 0) { foreach ($conference_users as $conference_user) { @@ -356,7 +381,7 @@ //clear the cache $cache = new cache; - $cache->delete("dialplan:".$_SESSION["domain_name"]); + $cache->delete("dialplan:".$this->domain_name); //set message message::add($text['message-copy']); diff --git a/app/conferences_active/conference_exec.php b/app/conferences_active/conference_exec.php index 5e694e1d0c..a9c1159717 100644 --- a/app/conferences_active/conference_exec.php +++ b/app/conferences_active/conference_exec.php @@ -218,7 +218,7 @@ $switch_result = event_socket::api($switch_cmd.' '.$tmp_value); } elseif ($data == "record") { - $recording_dir = $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.date("Y").'/'.date("M").'/'.date("d"); + $recording_dir = $settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/archive/'.date("Y").'/'.date("M").'/'.date("d"); $switch_cmd .= $recording_dir."/{$uuid}.wav"; if (!file_exists($switch_cmd)) { $switch_result = event_socket::api($switch_cmd); @@ -226,7 +226,7 @@ } elseif ($data == "norecord") { //stop recording and rename the file - $recording_dir = $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.date("Y").'/'.date("M").'/'.date("d"); + $recording_dir = $settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/archive/'.date("Y").'/'.date("M").'/'.date("d"); $switch_cmd .= $recording_dir."/".$uuid.".wav"; $switch_result = event_socket::api($switch_cmd); } diff --git a/app/conferences_active/conference_interactive_inc.php b/app/conferences_active/conference_interactive_inc.php index 4a30193f5e..2170dea63f 100644 --- a/app/conferences_active/conference_interactive_inc.php +++ b/app/conferences_active/conference_interactive_inc.php @@ -115,7 +115,7 @@ echo "
\n"; - $recording_dir = $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.date("Y").'/'.date("M").'/'.date("d"); + $recording_dir = $settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/archive/'.date("Y").'/'.date("M").'/'.date("d"); $recording_name = ''; if (!empty($recording_dir) && !empty($row['uuid'])) { if (file_exists($recording_dir.'/'.$row['uuid'].'.wav')) { diff --git a/app/database_transactions/database_transactions.php b/app/database_transactions/database_transactions.php index 59dd56043b..5cb8b59158 100644 --- a/app/database_transactions/database_transactions.php +++ b/app/database_transactions/database_transactions.php @@ -90,7 +90,7 @@ unset($parameters); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = "search=".$search; $page = empty($_GET['page']) ? $page = 0 : $page = $_GET['page']; list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); diff --git a/app/destinations/destination_imports.php b/app/destinations/destination_imports.php index 1487f01975..eb63ed7c81 100644 --- a/app/destinations/destination_imports.php +++ b/app/destinations/destination_imports.php @@ -72,7 +72,7 @@ //save the data to the csv file if (isset($_POST['data'])) { - $file = $_SESSION['server']['temp']['dir']."/destinations-".$_SESSION['domain_name'].".csv"; + $file = $settings->get('server', 'temp')."/destinations-".$_SESSION['domain_name'].".csv"; file_put_contents($file, $_POST['data']); $_SESSION['file'] = $file; $_SESSION['file_name'] = $_FILES['ulfile']['name']; @@ -82,11 +82,11 @@ //$_POST['submit'] == "Upload" && if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('destination_upload')) { if ($_POST['type'] == 'csv') { - move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']); - $save_msg = "Uploaded file to ".$_SESSION['server']['temp']['dir']."/". htmlentities($_FILES['ulfile']['name']); - //system('chmod -R 744 '.$_SESSION['server']['temp']['dir'].'*'); + move_uploaded_file($_FILES['ulfile']['tmp_name'], $settings->get('server', 'temp').'/'.$_FILES['ulfile']['name']); + $save_msg = "Uploaded file to ".$settings->get('server', 'temp')."/". htmlentities($_FILES['ulfile']['name']); + //system('chmod -R 744 '.$settings->get('server', 'temp').'*'); unset($_POST['txtCommand']); - $file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']; + $file = $settings->get('server', 'temp').'/'.$_FILES['ulfile']['name']; $_SESSION['file'] = $file; } } @@ -277,8 +277,8 @@ $dialplan_detail_order = $dialplan_detail_order + 10; //set the dialplan detail type - if (!empty($_SESSION['dialplan']['destination']['text'])) { - $dialplan_detail_type = $_SESSION['dialplan']['destination']['text']; + if (!empty($settings->get('dialplan', 'destination'))) { + $dialplan_detail_type = $settings->get('dialplan', 'destination'); } else { $dialplan_detail_type = "destination_number"; @@ -339,8 +339,8 @@ //check the destination number $array["dialplans"][$row_id]["dialplan_details"][$y]["domain_uuid"] = $domain_uuid; $array["dialplans"][$row_id]["dialplan_details"][$y]["dialplan_detail_tag"] = "condition"; - if (!empty($_SESSION['dialplan']['destination']['text'])) { - $array["dialplans"][$row_id]["dialplan_details"][$y]["dialplan_detail_type"] = $_SESSION['dialplan']['destination']['text']; + if (!empty($settings->get('dialplan', 'destination'))) { + $array["dialplans"][$row_id]["dialplan_details"][$y]["dialplan_detail_type"] = $settings->get('dialplan', 'destination'); } else { $array["dialplans"][$row_id]["dialplan_details"][$y]["dialplan_detail_type"] = "destination_number"; diff --git a/app/destinations/destinations.php b/app/destinations/destinations.php index 45a22372c4..2d8916b64e 100644 --- a/app/destinations/destinations.php +++ b/app/destinations/destinations.php @@ -89,6 +89,7 @@ //function to return the action names in the order defined function action_name($destination_array, $destination_actions) { + global $settings; $actions = []; if (!empty($destination_array) && is_array($destination_array)) { if (!empty($destination_actions) && is_array($destination_actions)) { @@ -102,7 +103,7 @@ if (!isset($language2) && !isset($text2)) { if (file_exists($_SERVER["PROJECT_ROOT"]."/app/dialplans/app_languages.php")) { $language2 = new text; - $text2 = $language2->get($_SESSION['domain']['language']['code'], 'app/dialplans'); + $text2 = $language2->get($settings->get('domain', 'language', 'en-us'), 'app/dialplans'); } } $actions[] = trim($text2['title-other'].' › '.$text2['option-'.str_replace('_','_',$key)]); @@ -110,7 +111,7 @@ else { if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$group."/app_languages.php")) { $language3 = new text; - $text3 = $language3->get($_SESSION['domain']['language']['code'], 'app/'.$group); + $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 2097d730e0..cc7bee3fdc 100644 --- a/app/destinations/resources/classes/destinations.php +++ b/app/destinations/resources/classes/destinations.php @@ -35,16 +35,44 @@ const app_name = 'destinations'; const app_uuid = '5ec89622-b19c-3559-64f0-afde802ab139'; + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + public $domain_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + public $domain_name; + /** * declare public variables */ public $destinations; - public $domain_uuid; - public $domain_name; public $start_stamp_begin; public $start_stamp_end; public $quick_select; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + /** * declare private variables */ @@ -54,31 +82,19 @@ private $list_page; private $table; private $uuid_prefix; - private $database; - private $settings; /** * Called when the object is created */ - public function __construct($setting_array = []) { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; - //open a database connection - if (empty($setting_array['database'])) { - $this->database = database::new(); - } else { - $this->database = $setting_array['database']; - } - - //set the domain details - $this->domain_uuid = $_SESSION['domain_uuid'] ?? ''; - $this->user_uuid = $_SESSION['user_uuid'] ?? ''; - - //get the settings object - if (empty($setting_array['settings'])) { - $this->settings = new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); - } else { - $this->settings = $setting_array['settings']; - } + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); //assign private variables $this->permission_prefix = 'destination_'; @@ -553,7 +569,7 @@ public function all($destination_type) { //set the global variables - global $db_type; + global $db_type, $settings; //set default values $destination_name = ''; @@ -575,7 +591,7 @@ try { include($config_path); } - catch (Exception $e) { + catch (Throwable $e) { //echo 'Caught exception: ', $e->getMessage(), "\n"; } $x++; @@ -764,7 +780,7 @@ public function get($destination_type) { //set the global variables - global $db_type; + global $db_type, $settings; //get the domain_name $sql = "select domain_name from v_domains "; diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 1c441cff8a..6e66ffd7e0 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -540,7 +540,7 @@ unset($sql, $parameters); //set the defaults - if ($device_enabled === null) { $device_enabled = true; } + $device_enabled = $device_enabled ?? true; //use the device address to get the vendor if (empty($device_vendor)) { diff --git a/app/devices/device_imports.php b/app/devices/device_imports.php index 78baaabd4c..a1ff3848b8 100644 --- a/app/devices/device_imports.php +++ b/app/devices/device_imports.php @@ -64,7 +64,7 @@ //save the data to the csv file if (isset($_POST['data'])) { - $file = $_SESSION['server']['temp']['dir']."/devices-".$_SESSION['domain_name'].".csv"; + $file = $settings->get('server', 'temp')."/devices-".$_SESSION['domain_name'].".csv"; if (file_put_contents($file, $_POST['data'])) { $_SESSION['file'] = $file; } @@ -74,7 +74,7 @@ //$_POST['submit'] == "Upload" && if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('device_import')) { if ($_POST['type'] == 'csv') { - $file = $_SESSION['server']['temp']['dir']."/devices-".$_SESSION['domain_name'].".csv"; + $file = $settings->get('server', 'temp')."/devices-".$_SESSION['domain_name'].".csv"; if (move_uploaded_file($_FILES['ulfile']['tmp_name'], $file)) { $_SESSION['file'] = $file; } @@ -443,7 +443,7 @@ //view_array($message); } - if (!empty($_SESSION['provision']['path']['text'])) { + if (!empty($settings->get('provision', 'path'))) { $prov = new provision; $prov->domain_uuid = $domain_uuid; $response = $prov->write(); diff --git a/app/devices/device_profile_edit.php b/app/devices/device_profile_edit.php index 86c2fa8444..1ee7814061 100644 --- a/app/devices/device_profile_edit.php +++ b/app/devices/device_profile_edit.php @@ -313,11 +313,11 @@ //add an empty row if (empty($device_profile_keys) || !is_array($device_profile_keys) || count($device_profile_keys) == 0) { - $rows = $_SESSION['devices']['profile_key_add_rows']['numeric']; + $rows = $settings->get('devices', 'profile_key_add_rows'); $id = 0; } if (!empty($device_profile_keys) && is_array($device_profile_keys) && count($device_profile_keys) > 0) { - $rows = $_SESSION['devices']['profile_key_edit_rows']['numeric']; + $rows = $settings->get('devices', 'profile_key_edit_rows'); $id = count($device_profile_keys)+1; } for ($x = 0; $x < $rows; $x++) { @@ -371,7 +371,7 @@ } //set the defaults - if ($device_profile_enabled === null) { $device_profile_enabled = true; } + $device_profile_enabled = $device_profile_enabled ?? true; //create token $object = new token; diff --git a/app/devices/device_vendor_edit.php b/app/devices/device_vendor_edit.php index 459890105a..2d212aa6ad 100644 --- a/app/devices/device_vendor_edit.php +++ b/app/devices/device_vendor_edit.php @@ -137,7 +137,7 @@ } //set the defaults - if ($enabled === null) { $enabled = true; } + $enabled = $enabled ?? true; //create token $object = new token; diff --git a/app/devices/device_vendor_function_edit.php b/app/devices/device_vendor_function_edit.php index 5174c93692..63d382d6a9 100644 --- a/app/devices/device_vendor_function_edit.php +++ b/app/devices/device_vendor_function_edit.php @@ -269,7 +269,7 @@ unset($sql, $parameters, $sql_where, $index); //set the defaults - if ($enabled === null) { $enabled = true; } + $enabled = $enabled ?? true; //create token $object = new token; diff --git a/app/devices/device_vendor_functions.php b/app/devices/device_vendor_functions.php index a9a7cbe099..fe3fb20a1c 100644 --- a/app/devices/device_vendor_functions.php +++ b/app/devices/device_vendor_functions.php @@ -220,7 +220,7 @@ $list_row_url = ''; if (permission_exists('device_vendor_function_edit')) { $list_row_url = "device_vendor_function_edit.php?device_vendor_uuid=".urlencode($row['device_vendor_uuid'])."&id=".urlencode($row['device_vendor_function_uuid']); - if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { + if (!empty($row['domain_uuid']) && $row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true'; } } diff --git a/app/devices/device_vendors.php b/app/devices/device_vendors.php index 117ce46ddf..84c67a0e5f 100644 --- a/app/devices/device_vendors.php +++ b/app/devices/device_vendors.php @@ -191,7 +191,7 @@ $list_row_url = ''; if (permission_exists('device_vendor_edit')) { $list_row_url = "device_vendor_edit.php?id=".urlencode($row['device_vendor_uuid']); - if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { + if (!empty($row['domain_uuid']) && $row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true'; } } diff --git a/app/devices/devices.php b/app/devices/devices.php index cb9891ef59..bc7aba3913 100644 --- a/app/devices/devices.php +++ b/app/devices/devices.php @@ -103,6 +103,7 @@ //get the devices profiles $sql = "select * from v_device_profiles "; $sql .= "where true "; + $parameters = []; if (!permission_exists('device_profile_all')) { $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; $parameters['domain_uuid'] = $domain_uuid; @@ -321,7 +322,7 @@ echo button::create(['type'=>'button','label'=>$text['button-profiles'],'icon'=>'clone','link'=>'device_profiles.php']); } $margin_left = permission_exists('device_import') || permission_exists('device_export') || permission_exists('device_vendor_view') || permission_exists('device_profile_view') ? "margin-left: 15px;" : null; - if (permission_exists('device_add') && (empty($_SESSION['limit']['devices']['numeric']) || ($total_devices < $_SESSION['limit']['devices']['numeric']))) { + if (permission_exists('device_add') && (empty($settings->get('limit', 'devices')) || ($total_devices < $settings->get('limit', 'devices')))) { echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','style'=>$margin_left,'link'=>'device_edit.php']); unset($margin_left); } diff --git a/app/devices/resources/classes/device.php b/app/devices/resources/classes/device.php index 0df98533a5..ad0c7f0f65 100644 --- a/app/devices/resources/classes/device.php +++ b/app/devices/resources/classes/device.php @@ -34,14 +34,49 @@ const app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e'; /** - * declare public variables + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string */ public $domain_uuid; + + /** + * declare public variables + */ public $template_dir; public $device_uuid; public $device_vendor_uuid; public $device_profile_uuid; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Username set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $username; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_name; + /** * declare private variables */ @@ -52,12 +87,6 @@ private $toggle_field; private $toggle_values; - /** - * Set in the constructor. Must be a database object and cannot be null. - * @var database Database Object - */ - private $database; - /** * Create a settings object using key/value pairs in the $setting_array. * @@ -66,16 +95,15 @@ * @depends database::new() * @access public */ - public function __construct($setting_array = []) { - - //open a database connection - if (empty($setting_array['database'])) { - $this->database = database::new(); - } else { - $this->database = $setting_array['database']; - } - + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); } public function get_domain_uuid() { @@ -471,8 +499,8 @@ } //check to see if the domain name sub directory exists - if (is_dir($this->template_dir."/".$_SESSION["domain_name"])) { - $this->template_dir = $this->template_dir."/".$_SESSION["domain_name"]; + if (is_dir($this->template_dir."/".$this->domain_name)) { + $this->template_dir = $this->template_dir."/".$this->domain_name; } //return the template directory @@ -541,9 +569,9 @@ $p->delete('device_key_delete', 'temp'); //write the provision files - if (!empty($_SESSION['provision']['path']['text'])) { + if (!empty($this->settings->get('provision', 'path'))) { $prov = new provision; - $prov->domain_uuid = $_SESSION['domain_uuid']; + $prov->domain_uuid = $this->domain_uuid; $response = $prov->write(); } @@ -994,7 +1022,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -1021,9 +1049,9 @@ unset($array); //write the provision files - if (!empty($_SESSION['provision']['path']['text'])) { + if (!empty($this->settings->get('provision', 'path'))) { $prov = new provision; - $prov->domain_uuid = $_SESSION['domain_uuid']; + $prov->domain_uuid = $this->domain_uuid; $response = $prov->write(); } @@ -1288,7 +1316,7 @@ $sql = "select * from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { $y = $z = 0; diff --git a/app/devices/resources/dashboard/device_keys.php b/app/devices/resources/dashboard/device_keys.php index b6e2e3bd61..57cd92ea93 100644 --- a/app/devices/resources/dashboard/device_keys.php +++ b/app/devices/resources/dashboard/device_keys.php @@ -28,7 +28,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'app/devices'); + $text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/devices'); //get the vendor functions $sql = "select v.name as vendor_name, f.type, f.value "; @@ -270,7 +270,7 @@ } //write the provision files - if (!empty($_SESSION['provision']['path']['text'])) { + if (!empty($settings->get('provision', 'path'))) { $prov = new provision; $prov->domain_uuid = $domain_uuid; $response = $prov->write(); diff --git a/app/dialplans/dialplan_xml.php b/app/dialplans/dialplan_xml.php index 376940e4e4..7db3264af1 100644 --- a/app/dialplans/dialplan_xml.php +++ b/app/dialplans/dialplan_xml.php @@ -174,11 +174,11 @@ $text = $language->get(); // load editor preferences/defaults - $setting_size = !empty($_SESSION["editor"]["font_size"]["text"]) ? $_SESSION["editor"]["font_size"]["text"] : '12px'; - $setting_theme = !empty($_SESSION["editor"]["theme"]["text"]) ? $_SESSION["editor"]["theme"]["text"] : 'cobalt'; - $setting_invisibles = isset($_SESSION['editor']['invisibles']['text']) ? $_SESSION['editor']['invisibles']["text"] : 'false'; - $setting_indenting = isset($_SESSION['editor']['indent_guides']['text']) ? $_SESSION['editor']['indent_guides']["text"]: 'false'; - $setting_numbering = isset($_SESSION['editor']['line_numbers']['text']) ? $_SESSION['editor']['line_numbers']["text"] : 'true'; + $setting_size = !empty($settings->get('editor', 'font_size')) ? $settings->get('editor', 'font_size') : '12px'; + $setting_theme = !empty($settings->get('editor', 'theme')) ? $settings->get('editor', 'theme') : 'cobalt'; + $setting_invisibles = $settings->get('editor', 'invisibles', 'false'); + $setting_indenting = $settings->get('editor', 'indent_guides', 'false'); + $setting_numbering = $settings->get('editor', 'line_numbers', 'true'); //create token $object = new token; diff --git a/app/dialplans/dialplans.php b/app/dialplans/dialplans.php index 9804b403d2..324122d451 100644 --- a/app/dialplans/dialplans.php +++ b/app/dialplans/dialplans.php @@ -574,7 +574,7 @@ ) { $list_row_url = "dialplan_edit.php?id=".urlencode($row['dialplan_uuid']).(is_uuid($app_uuid) ? "&app_uuid=".urlencode($app_uuid) : null); if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { - $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true'; + $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid'] ?? '').'&domain_change=true'; } } else { diff --git a/app/dialplans/resources/classes/dialplan.php b/app/dialplans/resources/classes/dialplan.php index 5bf666fb34..1f54c573f8 100644 --- a/app/dialplans/resources/classes/dialplan.php +++ b/app/dialplans/resources/classes/dialplan.php @@ -34,9 +34,14 @@ const app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db'; /** - * declare public variables + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string */ public $domain_uuid; + + /** + * declare public variables + */ public $dialplan_uuid; public $dialplan_detail_uuid; public $xml; @@ -73,6 +78,24 @@ public $array; public $list_page; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + /** * declare private variables */ @@ -82,14 +105,16 @@ private $toggle_field; private $toggle_values; - /** - * Set in the constructor. Must be a database object and cannot be null. - * @var database Database Object - */ - private $database; + //class constructor + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); - //class constructor - public function __construct() { //set the default value $this->dialplan_global = false; @@ -100,13 +125,6 @@ $this->uuid_prefix = 'dialplan_'; $this->toggle_field = 'dialplan_enabled'; $this->toggle_values = ['true','false']; - - //open a database connection - if (empty($setting_array['database'])) { - $this->database = database::new(); - } else { - $this->database = $setting_array['database']; - } } @@ -138,7 +156,7 @@ //prepare the xml if (!empty($xml_string)) { //replace the variables - $length = (is_numeric($_SESSION["security"]["pin_length"]["var"])) ? $_SESSION["security"]["pin_length"]["var"] : 8; + $length = (is_numeric($this->settings->get('security', 'pin_length'))) ? $this->settings->get('security', 'pin_length') : 8; $xml_string = str_replace("{v_context}", $domain['domain_name'], $xml_string); $xml_string = str_replace("{v_pin_number}", generate_password($length, 1), $xml_string); //convert the xml string to an xml object @@ -179,7 +197,7 @@ //prepare the xml if (!empty($xml_string)) { //replace the variables - $length = (!empty($_SESSION["security"]["pin_length"]["var"])) ? $_SESSION["security"]["pin_length"]["var"] : 8; + $length = (!empty($this->settings->get('security', 'pin_length'))) ? $this->settings->get('security', 'pin_length') : 8; $xml_string = str_replace("{v_context}", $domain['domain_name'], $xml_string); $xml_string = str_replace("{v_pin_number}", generate_password($length, 1), $xml_string); @@ -418,7 +436,7 @@ $destination_number = trim($destination_number); //check the session array if it doesn't exist then build the array - if (empty($_SESSION[$_SESSION['domain_uuid']]['outbound_routes'])) { + if (empty($_SESSION[$this->domain_uuid]['outbound_routes'])) { //get the outbound routes from the database $sql = "select * "; $sql .= "from v_dialplans as d, "; @@ -479,12 +497,12 @@ } //set the session array - $_SESSION[$_SESSION['domain_uuid']]['outbound_routes'] = $array; + $_SESSION[$this->domain_uuid]['outbound_routes'] = $array; } //find the matching outbound routes - if (isset($_SESSION[$_SESSION['domain_uuid']]['outbound_routes'])) { - foreach ($_SESSION[$_SESSION['domain_uuid']]['outbound_routes'] as $row) { + if (isset($_SESSION[$this->domain_uuid]['outbound_routes'])) { + foreach ($_SESSION[$this->domain_uuid]['outbound_routes'] as $row) { if (isset($row['dialplan_details'])) { foreach ($row['dialplan_details'] as $field) { if ($field['dialplan_detail_tag'] == "condition") { @@ -1232,7 +1250,7 @@ $sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; if (!permission_exists('dialplan_all')) { $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; } $rows = $this->database->select($sql, $parameters ?? null, 'all'); if (!empty($rows)) { diff --git a/app/domain_limits/resources/dashboard/domain_limits.php b/app/domain_limits/resources/dashboard/domain_limits.php index 39afeb8cf9..2403f9ec93 100644 --- a/app/domain_limits/resources/dashboard/domain_limits.php +++ b/app/domain_limits/resources/dashboard/domain_limits.php @@ -39,7 +39,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings'); + $text = $language->get($settings->get('domain', 'language', 'en-us'), 'core/user_settings'); //clear initial stat unset($hud_stat); @@ -52,10 +52,6 @@ $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; - //set default values - if (!isset($_SESSION['limit']['extensions']['numeric'])) { $_SESSION['limit']['extensions']['numeric'] = 0; } - if (!isset($_SESSION['limit']['destinations']['numeric'])) { $_SESSION['limit']['destinations']['numeric'] = 0; } - //caller id echo "
\n"; @@ -95,13 +91,13 @@ if (permission_exists('extension_view')) { $onclick = "onclick=\"document.location.href='".PROJECT_PATH."/app/extensions/extensions.php'\""; $hud_stat_used = $usage['extensions']; - $hud_stat_remaining = $_SESSION['limit']['extensions']['numeric'] - $usage['extensions']; + $hud_stat_remaining = $settings->get('limit', 'extensions', 0) - $usage['extensions']; $hud_stat_title = $text['label-extensions']; } else if (permission_exists('destination_view')) { $onclick = "onclick=\"document.location.href='".PROJECT_PATH."/app/destinations/destinations.php'\""; $hud_stat_used = $usage['destinations']; - $hud_stat_remaining = $_SESSION['limit']['destinations']['numeric'] - $usage['destinations']; + $hud_stat_remaining = $settings->get('limit', 'destinations', 0) - $usage['destinations']; $hud_stat_title = $text['label-destinations']; } diff --git a/app/email_queue/email_queue.php b/app/email_queue/email_queue.php index 3fc63eeb7c..ef801f3335 100644 --- a/app/email_queue/email_queue.php +++ b/app/email_queue/email_queue.php @@ -321,7 +321,7 @@ $list_row_url = ''; if (permission_exists('email_queue_edit')) { $list_row_url = "email_queue_edit.php?id=".urlencode($row['email_queue_uuid']); - if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { + if (!empty($row['domain_uuid']) && $row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true'; } } @@ -348,7 +348,7 @@ echo " ".escape($row['hostname'])."\n"; echo " ".escape($row['email_from'])."\n"; echo " ".escape($row['email_to'])."\n"; - echo " ".iconv_mime_decode($row['email_subject'])."\n"; + echo " ".iconv_mime_decode($row['email_subject'] ?? '')."\n"; // echo " ".escape($row['email_body'])."\n"; echo " ".ucwords($text['label-'.$row['email_status']])."\n"; echo " ".escape($row['email_retry_count'])."\n"; @@ -398,4 +398,4 @@ //include the footer require_once "resources/footer.php"; -?> \ No newline at end of file +?> diff --git a/app/email_queue/email_queue_edit.php b/app/email_queue/email_queue_edit.php index b3fcef38e6..3b032f5fc1 100644 --- a/app/email_queue/email_queue_edit.php +++ b/app/email_queue/email_queue_edit.php @@ -227,11 +227,11 @@ } //load editor preferences/defaults - $setting_size = !empty($_SESSION["editor"]["font_size"]["text"]) ? $_SESSION["editor"]["font_size"]["text"] : '12px'; - $setting_theme = !empty($_SESSION["editor"]["theme"]["text"]) ? $_SESSION["editor"]["theme"]["text"] : 'cobalt'; - $setting_invisibles = isset($_SESSION['editor']['invisibles']['text']) ? $_SESSION['editor']['invisibles']["text"] : 'false'; - $setting_indenting = isset($_SESSION['editor']['indent_guides']['text']) ? $_SESSION['editor']['indent_guides']["text"]: 'false'; - $setting_numbering = isset($_SESSION['editor']['line_numbers']['text']) ? $_SESSION['editor']['line_numbers']["text"] : 'true'; + $setting_size = !empty($settings->get('editor', 'font_size')) ? $settings->get('editor', 'font_size') : '12px'; + $setting_theme = !empty($settings->get('editor', 'theme')) ? $settings->get('editor', 'theme') : 'cobalt'; + $setting_invisibles = $settings->get('editor', 'invisibles', 'false'); + $setting_indenting = $settings->get('editor', 'indent_guides', 'false'); + $setting_numbering = $settings->get('editor', 'line_numbers', 'true'); //create token $object = new token; diff --git a/app/email_queue/email_test.php b/app/email_queue/email_test.php index e9203f3903..d6b7daf46e 100644 --- a/app/email_queue/email_test.php +++ b/app/email_queue/email_test.php @@ -76,8 +76,8 @@ $email_body .= "If you received this message, your current SMTP settings are valid.

\n"; } - $email_from_address = $_SESSION['email']['smtp_from']['text']; - $email_from_name = $_SESSION['email']['smtp_from_name']['text']; + $email_from_address = $settings->get('email', 'smtp_from'); + $email_from_name = $settings->get('email', 'smtp_from_name'); //send email $sent = 0; @@ -118,6 +118,7 @@ echo "\n"; foreach ($_SESSION['email'] as $name => $setting) { foreach ($setting as $type => $value) { + $value = $value ?? ''; echo "\n"; if ($type == 'uuid') { $uuid = $value; continue; } if ($name == 'smtp_password') { $value = str_repeat('*', strlen($value)); } @@ -138,7 +139,7 @@ echo "".$text['header-connection']."\n"; echo "

\n"; - echo "
\n"; + echo "
get('theme', 'table_row_background_color_light') ?? '#fff')."; font-family: monospace; font-size: 85%;'>\n"; if (!empty($email_response) && is_array($email_response) && @sizeof($email_response) != 0) { echo implode("
\n
\n", $email_response); @@ -155,4 +156,4 @@ echo " \n"; echo "\n"; -?> \ No newline at end of file +?> diff --git a/app/email_queue/resources/classes/email_queue.php b/app/email_queue/resources/classes/email_queue.php index 29f4a7c0e9..9465b1ee81 100644 --- a/app/email_queue/resources/classes/email_queue.php +++ b/app/email_queue/resources/classes/email_queue.php @@ -11,10 +11,33 @@ const app_name = 'email_queue'; const app_uuid = '5befdf60-a242-445f-91b3-2e9ee3e0ddf7'; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + /** * declare the variables */ - private $database; private $name; private $table; private $toggle_field; @@ -24,18 +47,21 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); + //assign the variables $this->name = 'email_queue'; $this->table = 'email_queue'; $this->toggle_field = ''; $this->toggle_values = ['true','false']; $this->location = 'email_queue.php'; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } } /** @@ -65,7 +91,7 @@ if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { $array[$this->table][$x][$this->name.'_uuid'] = $record['uuid']; $array['email_queue_attachments'][$x][$this->name.'_uuid'] = $record['uuid']; - //$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + //$array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; } //increment the id @@ -165,7 +191,7 @@ $sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -234,7 +260,7 @@ $sql = "select * from v_".$this->table." "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { $x = 0; diff --git a/app/event_guard/resources/classes/event_guard.php b/app/event_guard/resources/classes/event_guard.php index c2bc791436..6e248eebc9 100644 --- a/app/event_guard/resources/classes/event_guard.php +++ b/app/event_guard/resources/classes/event_guard.php @@ -35,10 +35,33 @@ const app_name = 'event_guard'; const app_uuid = 'c5b86612-1514-40cb-8e2c-3f01a8f6f637'; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + /** * declare the variables */ - private $database; private $name; private $table; private $toggle_field; @@ -48,18 +71,20 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + //assign the variables $this->name = 'event_guard_log'; $this->table = 'event_guard_logs'; $this->toggle_field = ''; $this->toggle_values = ['block','pending']; $this->location = 'event_guard_logs.php'; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } } /** diff --git a/app/extension_settings/resources/classes/extension_settings.php b/app/extension_settings/resources/classes/extension_settings.php index 83d6e58acd..54abd32353 100644 --- a/app/extension_settings/resources/classes/extension_settings.php +++ b/app/extension_settings/resources/classes/extension_settings.php @@ -35,10 +35,33 @@ const app_name = 'extension_settings'; const app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd'; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + /** * declare the variables */ - private $database; private $name; private $table; private $toggle_field; @@ -49,7 +72,14 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + //assign the variables $this->name = 'extension_setting'; $this->table = 'extension_settings'; @@ -58,10 +88,6 @@ $this->description_field = 'extension_setting_description'; $this->location = 'extension_settings.php'; - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } } /** @@ -90,7 +116,7 @@ //add to the array if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) { $array[$this->table][$x][$this->name.'_uuid'] = $record['uuid']; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; } //increment the id @@ -150,7 +176,7 @@ $sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle, extension_uuid from v_".$this->table." "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { $extension_uuid = $rows[0]['extension_uuid']; @@ -229,7 +255,7 @@ $sql = "select * from v_".$this->table." "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $x => $row) { diff --git a/app/extensions/extension_copy.php b/app/extensions/extension_copy.php index 932954a249..aab7983439 100644 --- a/app/extensions/extension_copy.php +++ b/app/extensions/extension_copy.php @@ -113,7 +113,7 @@ $array['extensions'][0]['extension_uuid'] = uuid(); $array['extensions'][0]['extension'] = $extension_new; $array['extensions'][0]['number_alias'] = $number_alias_new; - $array['extensions'][0]['password'] = generate_password($_SESSION["extension"]["password_length"]["numeric"], $_SESSION["extension"]["password_strength"]["numeric"]); + $array['extensions'][0]['password'] = generate_password($settings->get('extension', 'password_length'), $settings->get('extension', 'password_strength')); $array['extensions'][0]['accountcode'] = $password; $array['extensions'][0]['effective_caller_id_name'] = $effective_caller_id_name; $array['extensions'][0]['effective_caller_id_number'] = $effective_caller_id_number; @@ -187,7 +187,7 @@ } //synchronize configuration - if (is_writable($_SESSION['switch']['extensions']['dir'])) { + if (is_writable($settings->get('switch', 'extensions'))) { $ext = new extension; $ext->xml(); unset($ext); diff --git a/app/extensions/extension_imports.php b/app/extensions/extension_imports.php index 5ec98421d1..94a41e4523 100644 --- a/app/extensions/extension_imports.php +++ b/app/extensions/extension_imports.php @@ -61,7 +61,7 @@ //save the data to the csv file if (isset($_POST['data'])) { - $file = $_SESSION['server']['temp']['dir']."/extensions-".$_SESSION['domain_name'].".csv"; + $file = $settings->get('server', 'temp')."/extensions-".$_SESSION['domain_name'].".csv"; file_put_contents($file, $_POST['data']); $_SESSION['file'] = $file; } @@ -70,11 +70,11 @@ //$_POST['submit'] == "Upload" && if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('extension_import')) { if ($_POST['type'] == 'csv') { - move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']); - $save_msg = "Uploaded file to ".$_SESSION['server']['temp']['dir']."/". htmlentities($_FILES['ulfile']['name']); - //system('chmod -R 744 '.$_SESSION['server']['temp']['dir'].'*'); + move_uploaded_file($_FILES['ulfile']['tmp_name'], $settings->get('server', 'temp').'/'.$_FILES['ulfile']['name']); + $save_msg = "Uploaded file to ".$settings->get('server', 'temp')."/". htmlentities($_FILES['ulfile']['name']); + //system('chmod -R 744 '.$settings->get('server', 'temp').'*'); unset($_POST['txtCommand']); - $file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']; + $file = $settings->get('server', 'temp').'/'.$_FILES['ulfile']['name']; $_SESSION['file'] = $file; } } diff --git a/app/extensions/extensions.php b/app/extensions/extensions.php index 08548855f1..f7de4caff0 100644 --- a/app/extensions/extensions.php +++ b/app/extensions/extensions.php @@ -82,7 +82,7 @@ } //get total extension count for domain - if (isset($_SESSION['limit']['extensions']['numeric'])) { + if (!empty($settings->get('limit', 'extensions'))) { $sql = "select count(*) from v_extensions "; $sql .= "where domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; @@ -288,14 +288,14 @@ echo "
\n"; echo "
".$text['header-extensions']."
".number_format($num_rows)."
\n"; echo "
\n"; - if (permission_exists('extension_import') && (!isset($_SESSION['limit']['extensions']['numeric']) || $total_extensions < $_SESSION['limit']['extensions']['numeric'])) { + if (permission_exists('extension_import') && (empty($settings->get('limit', 'extensions', 0)) || $total_extensions < $settings->get('limit', 'extensions'))) { echo button::create(['type'=>'button','label'=>$text['button-import'],'icon'=>$settings->get('theme', 'button_icon_import'),'link'=>'extension_imports.php']); } if (permission_exists('extension_export')) { echo button::create(['type'=>'button','label'=>$text['button-export'],'icon'=>$settings->get('theme', 'button_icon_export'),'link'=>'extension_download.php']); } $margin_left = permission_exists('extension_import') || permission_exists('extension_export') ? "margin-left: 15px;" : null; - if (permission_exists('extension_add') && (!isset($_SESSION['limit']['extensions']['numeric']) || $total_extensions < $_SESSION['limit']['extensions']['numeric'])) { + if (permission_exists('extension_add') && (empty($settings->get('limit', 'extensions', 0)) || $total_extensions < $settings->get('limit', 'extensions'))) { echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','style'=>($margin_left ?? ''),'link'=>'extension_edit.php']); unset($margin_left); } @@ -435,8 +435,8 @@ echo "
\n"; } if (permission_exists('extension_registered')) { - $icon_registered_color = $_SESSION['extension']['icon_registered_color']['text'] ?? '#12d600'; - $icon_unregistered_color = $_SESSION['extension']['icon_unregistered_color']['text'] ?? '#e21b1b'; + $icon_registered_color = $settings->get('extension', 'icon_registered_color') ?? '#12d600'; + $icon_unregistered_color = $settings->get('extension', 'icon_unregistered_color') ?? '#e21b1b'; $extension_number = $row['extension'].'@'.$_SESSION['domains'][$row['domain_uuid']]['domain_name']; $extension_number_alias = $row['number_alias']; diff --git a/app/extensions/resources/classes/extension.php b/app/extensions/resources/classes/extension.php index 59935ae62b..1432182a56 100644 --- a/app/extensions/resources/classes/extension.php +++ b/app/extensions/resources/classes/extension.php @@ -34,10 +34,20 @@ const app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3'; /** - * declare public variables + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string */ public $domain_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ public $domain_name; + + /** + * declare public variables + */ public $extension_uuid; public $extension; public $voicemail_id; @@ -80,9 +90,26 @@ public $delete_voicemail; /** - * declare private variables + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object */ private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * declare private variables + */ private $permission_prefix; private $list_page; private $table; @@ -93,7 +120,15 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); //assign private variables $this->permission_prefix = 'extension_'; @@ -102,12 +137,6 @@ $this->uuid_prefix = 'extension_'; $this->toggle_field = 'enabled'; $this->toggle_values = ['true','false']; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } - } public function exists($domain_uuid, $extension) { @@ -188,7 +217,7 @@ } public function xml() { - if (isset($_SESSION['switch']['extensions']['dir'])) { + if (!empty($this->settings->get('switch', 'extensions'))) { //declare global variables global $config, $domain_uuid; @@ -197,7 +226,7 @@ $user_context = $domain_name; //delete all old extensions to prepare for new ones - $dialplan_list = glob($_SESSION['switch']['extensions']['dir']."/".$user_context."/v_*.xml"); + $dialplan_list = glob($this->settings->get('switch', 'extensions')."/".$user_context."/v_*.xml"); foreach($dialplan_list as $name => $value) { unlink($value); } @@ -243,8 +272,8 @@ $extension = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $extension); $dial_string = $row['dial_string']; if (empty($dial_string)) { - if (!empty($_SESSION['domain']['dial_string']['text'])) { - $dial_string = $_SESSION['domain']['dial_string']['text']; + if (!empty($this->settings->get('domain', 'dial_string'))) { + $dial_string = $this->settings->get('domain', 'dial_string'); } else { $dial_string = "{sip_invite_domain=\${domain_name},leg_timeout=".$call_timeout.",presence_id=\${dialed_user}@\${dialed_domain}}\${sofia_contact(\${dialed_user}@\${dialed_domain})}"; @@ -318,8 +347,8 @@ $xml .= " \n"; $xml .= " \n"; $xml .= " \n"; - $xml .= " \n"; - $xml .= " \n"; + $xml .= " domain_name . "\"/>\n"; + $xml .= " domain_uuid . "\"/>\n"; $xml .= " \n"; if (!empty($row['call_group'])) { $xml .= " \n"; @@ -428,11 +457,11 @@ $xml .= " \n"; $xml .= " \n"; - if (!is_readable($_SESSION['switch']['extensions']['dir']."/".$row['user_context'])) { - mkdir($_SESSION['switch']['extensions']['dir']."/".$row['user_context'], 0770, false); + if (!is_readable($this->settings->get('switch', 'extensions')."/".$row['user_context'])) { + mkdir($this->settings->get('switch', 'extensions')."/".$row['user_context'], 0770, false); } if (!empty($extension)) { - $fout = fopen($_SESSION['switch']['extensions']['dir']."/".$row['user_context']."/v_".$extension.".xml","w"); + $fout = fopen($this->settings->get('switch', 'extensions')."/".$row['user_context']."/v_".$extension.".xml","w"); } $xml .= "\n"; fwrite($fout, $xml); @@ -444,7 +473,7 @@ unset($rows, $row); //prepare extension - $extension_dir = realpath($_SESSION['switch']['extensions']['dir']); + $extension_dir = realpath($this->settings->get('switch', 'extensions')); $user_context = str_replace(" ", "_", $user_context); $user_context = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $user_context); @@ -568,7 +597,7 @@ $sql = "select extension, number_alias, user_context, follow_me_uuid from v_extensions "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and extension_uuid = :extension_uuid "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $parameters['extension_uuid'] = $record['uuid']; $row = $this->database->select($sql, $parameters, 'row'); if (is_array($row) && @sizeof($row) != 0) { @@ -589,10 +618,10 @@ //include ring group destinations, if exists if (file_exists($_SERVER["PROJECT_ROOT"]."/app/ring_groups/app_config.php")) { $array['ring_group_destinations'][$x]['destination_number'] = $extensions[$x]['extension']; - $array['ring_group_destinations'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['ring_group_destinations'][$x]['domain_uuid'] = $this->domain_uuid; if (is_numeric($extensions[$x]['number_alias'])) { $array['ring_group_destinations'][$y]['destination_number'] = $extensions[$x]['number_alias']; - $array['ring_group_destinations'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['ring_group_destinations'][$y]['domain_uuid'] = $this->domain_uuid; } $y++; } @@ -600,7 +629,7 @@ //include extension settings, if exists if (file_exists($_SERVER["PROJECT_ROOT"]."/app/extension_settings/app_config.php")) { $array['extension_settings'][$x]['extension_uuid'] = $record['uuid']; - $array['extension_settings'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['extension_settings'][$x]['domain_uuid'] = $this->domain_uuid; } //create array of voicemail ids @@ -629,7 +658,7 @@ $sql = "select voicemail_uuid as uuid from v_voicemails "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and voicemail_id in ('".implode("','", $voicemail_ids)."') "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $r => $row) { @@ -675,7 +704,7 @@ unset($extensions); //synchronize configuration - if (!empty($_SESSION['switch']['extensions']['dir']) && is_writable($_SESSION['switch']['extensions']['dir'])) { + if (!empty($this->settings->get('switch', 'extensions')) && is_writable($this->settings->get('switch', 'extensions'))) { $this->xml(); } @@ -724,7 +753,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, extension, number_alias, user_context from v_".$this->table." "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -762,15 +791,15 @@ $p->delete('extension_edit', 'temp'); //synchronize configuration - if (!empty($_SESSION['switch']['extensions']['dir']) && is_writable($_SESSION['switch']['extensions']['dir'])) { + if (!empty($this->settings->get('switch', 'extensions')) && is_writable($this->settings->get('switch', 'extensions'))) { $this->xml(); } //write the provision files - if (!empty($_SESSION['provision']['path']['text'])) { + if (!empty($this->settings->get('provision', 'path'))) { if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/provision')) { $prov = new provision; - $prov->domain_uuid = $_SESSION['domain_uuid']; + $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 7b156a89b2..5dc673b227 100644 --- a/app/extensions/resources/dashboard/caller_id.php +++ b/app/extensions/resources/dashboard/caller_id.php @@ -33,7 +33,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'app/extensions'); + $text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/extensions'); //add or update the database if (isset($_POST['extensions']) && is_array($_POST['extensions']) && @sizeof($_POST['extensions']) != 0) { diff --git a/app/fax/fax.php b/app/fax/fax.php index b6eca16eaa..73e747f566 100644 --- a/app/fax/fax.php +++ b/app/fax/fax.php @@ -117,7 +117,7 @@ $num_rows = $database->select($sql, $parameters ?? null, 'column'); //prepare paging - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = "&search=".urlencode($search); if ($show == "all" && permission_exists('fax_extension_view_all')) { $param .= "&show=all"; @@ -294,7 +294,7 @@ if (permission_exists('fax_log_view')) { echo " ".$text['label-log']."  "; } - if (file_exists(__DIR__ . '/fax_active.php') && permission_exists('fax_active_view') && isset($_SESSION['fax']['send_mode']['text']) && $_SESSION['fax']['send_mode']['text'] == 'queue') { + if (file_exists(__DIR__ . '/fax_active.php') && permission_exists('fax_active_view') && !empty($settings->get('fax', 'send_mode')) && $settings->get('fax', 'send_mode') == 'queue') { echo " ".$text['label-active']."  "; } if (permission_exists('fax_queue_view')) { diff --git a/app/fax/fax_advanced.php b/app/fax/fax_advanced.php index 210e8635d0..a89808739c 100644 --- a/app/fax/fax_advanced.php +++ b/app/fax/fax_advanced.php @@ -424,7 +424,7 @@ echo "
"; if ($action == "update") { echo " \n"; - echo " \n"; + echo " \n"; } echo " \n"; echo " \n"; diff --git a/app/fax/fax_edit.php b/app/fax/fax_edit.php index 77326bbd58..4a6f59b75e 100644 --- a/app/fax/fax_edit.php +++ b/app/fax/fax_edit.php @@ -47,7 +47,7 @@ } //set the fax directory - $fax_dir = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name']; + $fax_dir = $settings->get('switch', 'storage').'/fax/'.$_SESSION['domain_name']; //get the fax extension if (!empty($fax_extension) && is_numeric($fax_extension)) { @@ -57,8 +57,8 @@ $dir_fax_temp = $fax_dir.'/'.$fax_extension.'/temp'; //make sure the directories exist - if (!is_dir($_SESSION['switch']['storage']['dir'])) { - mkdir($_SESSION['switch']['storage']['dir'], 0770, true); + if (!is_dir($settings->get('switch', 'storage'))) { + mkdir($settings->get('switch', 'storage'), 0770, true); } if (!is_dir($fax_dir.'/'.$fax_extension)) { mkdir($fax_dir.'/'.$fax_extension, 0770, true); @@ -549,7 +549,7 @@ echo " ".$text['label-extension']."\n"; echo "\n"; echo "\n"; diff --git a/app/fax/fax_files.php b/app/fax/fax_files.php index bf6a7cb57b..09efe92a37 100644 --- a/app/fax/fax_files.php +++ b/app/fax/fax_files.php @@ -123,8 +123,8 @@ } //set the fax directory - if (!empty($_SESSION['switch']['storage']['dir'])) { - $fax_dir = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name']; + if (!empty($settings->get('switch', 'storage'))) { + $fax_dir = $settings->get('switch', 'storage').'/fax/'.$_SESSION['domain_name']; } //download the fax @@ -204,8 +204,8 @@ $dir_fax_temp = $fax_dir.'/'.$fax_extension.'/temp'; //make sure the directories exist - if (!empty($_SESSION['switch']['storage']['dir']) && !is_dir($_SESSION['switch']['storage']['dir'])) { - mkdir($_SESSION['switch']['storage']['dir'], 0770, false); + if (!empty($settings->get('switch', 'storage')) && !is_dir($settings->get('switch', 'storage'))) { + mkdir($settings->get('switch', 'storage'), 0770, false); } if (!is_dir($fax_dir.'/'.$fax_extension)) { mkdir($fax_dir.'/'.$fax_extension, 0770, false); @@ -250,11 +250,11 @@ $parameters['time_zone'] = $time_zone; //set the time format options: 12h, 24h - if (isset($_SESSION['domain']['time_format']['text'])) { - if ($_SESSION['domain']['time_format']['text'] == '12h') { + if (!empty($settings->get('domain', 'time_format'))) { + if ($settings->get('domain', 'time_format') == '12h') { $time_format = 'HH12:MI:SS am'; } - elseif ($_SESSION['domain']['time_format']['text'] == '24h') { + elseif ($settings->get('domain', 'time_format') == '24h') { $time_format = 'HH24:MI:SS'; } } diff --git a/app/fax/fax_files_remote.php b/app/fax/fax_files_remote.php index bb1aacd7d0..3ed361ab53 100644 --- a/app/fax/fax_files_remote.php +++ b/app/fax/fax_files_remote.php @@ -152,7 +152,7 @@ if (imap_delete($connection, $email_id, FT_UID)) { if (imap_expunge($connection)) { //clean up local inbox copy - $fax_dir = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name']; + $fax_dir = $settings->get('switch', 'storage').'/fax/'.$_SESSION['domain_name']; @unlink($fax_dir.'/'.$fax_extension.'/inbox/'.$attachment['name']); //redirect user message::add($text['message-delete']); diff --git a/app/fax/fax_logs.php b/app/fax/fax_logs.php index 5c7d2e0bb8..6a84386803 100644 --- a/app/fax/fax_logs.php +++ b/app/fax/fax_logs.php @@ -193,7 +193,7 @@ echo " \n"; echo " \n"; } - echo " \n"; + echo " \n"; echo " \n"; echo " \n"; echo " \n"; diff --git a/app/fax/resources/classes/fax.php b/app/fax/resources/classes/fax.php index 2aaa0fdf56..e9d0611316 100644 --- a/app/fax/resources/classes/fax.php +++ b/app/fax/resources/classes/fax.php @@ -33,10 +33,15 @@ const app_name = 'fax'; const app_uuid = '24108154-4ac3-1db6-1551-4731703a4440'; + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + public $domain_uuid; + /** * define the variables */ - public $domain_uuid; public $fax_uuid; public $dialplan_uuid; public $fax_name; @@ -49,10 +54,33 @@ public $order; public $download; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_name; + /** * declare private variables */ - private $database; private $permission_prefix; private $list_page; private $table; @@ -64,13 +92,15 @@ /** * Called when the object is created */ - public function __construct() { - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); } /** @@ -131,15 +161,15 @@ $fax_name = ($this->fax_name != '') ? $this->fax_name : format_phone($this->destination_number); //set the last fax - if (!empty($_SESSION['fax']['last_fax']['text'])) { - $last_fax = "last_fax=".xml::sanitize($_SESSION['fax']['last_fax']['text']); + if (!empty($this->settings->get('fax', 'last_fax'))) { + $last_fax = "last_fax=".xml::sanitize($this->settings->get('fax', 'last_fax')); } else { $last_fax = "last_fax=\${caller_id_number}-\${strftime(%Y-%m-%d-%H-%M-%S)}"; } //set the rx_fax - $rxfax_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name'].'/'.xml::sanitize($this->fax_extension).'/inbox/'.xml::sanitize($this->forward_prefix).'${last_fax}.tif'; + $rxfax_data = $this->settings->get('switch', 'storage').'/fax/'.$this->domain_name.'/'.xml::sanitize($this->fax_extension).'/inbox/'.xml::sanitize($this->forward_prefix).'${last_fax}.tif'; //build the xml dialplan $dialplan_xml = "dialplan_uuid)."\">\n"; @@ -168,7 +198,7 @@ $dialplan["dialplan_uuid"] = $this->dialplan_uuid; $dialplan["dialplan_name"] = ($this->fax_name != '') ? $this->fax_name : format_phone($this->destination_number); $dialplan["dialplan_number"] = $this->fax_extension; - $dialplan["dialplan_context"] = $_SESSION['domain_name']; + $dialplan["dialplan_context"] = $this->domain_name; $dialplan["dialplan_continue"] = false; $dialplan["dialplan_xml"] = $dialplan_xml; $dialplan["dialplan_order"] = "40"; @@ -200,7 +230,7 @@ //clear the cache $cache = new cache; - $cache->delete("dialplan:".$_SESSION['domain_name']); + $cache->delete("dialplan:".$this->domain_name); //return the dialplan_uuid return $dialplan_response ?? null; @@ -247,7 +277,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, dialplan_uuid from v_".$this->table." "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -262,7 +292,7 @@ $sql = "select fax_file_uuid as uuid, fax_mode, fax_file_path, fax_file_type from v_fax_files "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -304,17 +334,17 @@ if (!empty($faxes) && is_array($faxes) && @sizeof($faxes) != 0) { foreach ($faxes as $fax_uuid => $fax) { $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $fax_uuid; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; $array['fax_users'][$x][$this->uuid_prefix.'uuid'] = $fax_uuid; - $array['fax_users'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['fax_users'][$x]['domain_uuid'] = $this->domain_uuid; $array['fax_files'][$x][$this->uuid_prefix.'uuid'] = $fax_uuid; - $array['fax_files'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['fax_files'][$x]['domain_uuid'] = $this->domain_uuid; $array['fax_logs'][$x][$this->uuid_prefix.'uuid'] = $fax_uuid; - $array['fax_logs'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['fax_logs'][$x]['domain_uuid'] = $this->domain_uuid; $array['dialplans'][$x]['dialplan_uuid'] = $fax['dialplan_uuid']; - $array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['domain_uuid'] = $this->domain_uuid; $array['dialplan_details'][$x]['dialplan_uuid'] = $fax['dialplan_uuid']; - $array['dialplan_details'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplan_details'][$x]['domain_uuid'] = $this->domain_uuid; $x++; } } @@ -348,7 +378,7 @@ //clear the cache $cache = new cache; - $cache->delete("dialplan:".$_SESSION["domain_name"]); + $cache->delete("dialplan:".$this->domain_name); //clear the destinations session array if (isset($_SESSION['destinations']['array'])) { @@ -400,7 +430,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, fax_mode, fax_file_path, fax_file_type from v_".$this->table." "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -441,7 +471,7 @@ $x = 0; foreach ($fax_files as $fax_file_uuid => $fax_file) { $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $fax_file_uuid; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; $x++; } @@ -489,7 +519,7 @@ foreach ($records as $x => $record) { if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) { $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; } } @@ -550,7 +580,7 @@ $sql = "select * from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { $y = 0; @@ -574,7 +604,7 @@ $sql_2 .= "where e.user_uuid = u.user_uuid "; $sql_2 .= "and e.domain_uuid = :domain_uuid "; $sql_2 .= "and e.fax_uuid = :fax_uuid "; - $parameters_2['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters_2['domain_uuid'] = $this->domain_uuid; $parameters_2['fax_uuid'] = $row['fax_uuid']; $rows_2 = $this->database->select($sql_2, $parameters_2, 'all'); if (is_array($rows_2) && @sizeof($rows_2) != 0) { @@ -641,7 +671,7 @@ //clear the cache $cache = new cache; - $cache->delete("dialplan:".$_SESSION["domain_name"]); + $cache->delete("dialplan:".$this->domain_name); //set message message::add($text['message-copy']); @@ -689,7 +719,7 @@ //toggle read state $array['fax_files'][$x]['fax_file_uuid'] = $record['uuid']; - $array['fax_files'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['fax_files'][$x]['domain_uuid'] = $this->domain_uuid; $array['fax_files'][$x]['read_date'] = empty($read_date) ? 'now()' : null; $fax_files_toggled++; } diff --git a/app/fax_queue/resources/classes/fax_queue.php b/app/fax_queue/resources/classes/fax_queue.php index 979b2eff06..4e1e6cfb57 100644 --- a/app/fax_queue/resources/classes/fax_queue.php +++ b/app/fax_queue/resources/classes/fax_queue.php @@ -35,10 +35,21 @@ const app_name = 'fax_queue'; const app_uuid = '3656287f-4b22-4cf1-91f6-00386bf488f4'; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + /** * declare private variables */ - private $database; private $name; private $table; private $toggle_field; @@ -48,18 +59,19 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + //assign the variables $this->name = 'fax_queue'; $this->table = 'fax_queue'; $this->toggle_field = ''; $this->toggle_values = ['true','false']; $this->location = 'fax_queue.php'; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } } /** @@ -88,7 +100,7 @@ //add to the array if ($record['checked'] == 'true' && is_uuid($record['fax_queue_uuid'])) { $array[$this->table][$x]['fax_queue_uuid'] = $record['fax_queue_uuid']; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; } //increment the id @@ -191,7 +203,7 @@ $sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -260,7 +272,7 @@ $sql = "select * from v_".$this->table." "; $sql .= "where fax_queue_uuid in (".implode(', ', $uuids).") "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { $x = 0; diff --git a/app/fifo/app_languages.php b/app/fifo/app_languages.php index cba78e315d..c92a599506 100644 --- a/app/fifo/app_languages.php +++ b/app/fifo/app_languages.php @@ -1127,4 +1127,31 @@ $text['label-member_enabled']['zh-cn'] = "已启用"; $text['label-member_enabled']['ja-jp'] = "有効"; $text['label-member_enabled']['ko-kr'] = "활성화됨"; -?> \ No newline at end of file +$text['description-agents']['en-us'] = "Select the agent, set the call timeout, wrap up time, and enabled."; +$text['description-agents']['en-gb'] = "Select the agent, set the call timeout, wrap up time, and enabled."; +$text['description-agents']['ar-eg'] = "حدد وكيل التحول، و 설정 الدخول، و الزمن المحدد، و التفعيل."; +$text['description-agents']['de-at'] = "Wählen Sie den Agenten, stellen Sie die Anruferwartungszeit, die Abschlusszeit und den Status ein."; +$text['description-agents']['de-ch'] = "Wählen Sie den Agenten, stellen Sie die Anruferwartungszeit, die Abschlusszeit und den Status ein."; +$text['description-agents']['de-de'] = "Wählen Sie den Agenten, stellen Sie die Anruferwartungszeit, die Abschlusszeit und den Status ein."; +$text['description-agents']['el-gr'] = "Επιλέξτε τον αρχικό, θετείτε το χρόνο αναμονής, το χρόνο ολοκλήρωσης και την ενεργοποίηση."; +$text['description-agents']['es-cl'] = "Seleccione el agente, establezca el tiempo de espera, el tiempo de cierre y el estado."; +$text['description-agents']['es-mx'] = "Seleccione el agente, establezca el tiempo de espera, el tiempo de cierre y el estado."; +$text['description-agents']['fr-ca'] = "Sélectionnez l'agent, définissez le délai d'attente, le temps de clôture et l'état."; +$text['description-agents']['fr-fr'] = "Sélectionnez l'agent, définissez le délai d'attente, le temps de clôture et l'état."; +$text['description-agents']['he-il'] = "בחר את המנהל,設置 הwartime, זמן סיום ופעולה."; +$text['description-agents']['it-it'] = "Seleziona l'agente, impostare il tempo di attesa, il tempo di chiusura e lo stato."; +$text['description-agents']['ka-ge'] = "დაირჩეთ აგენტს, დადგენით გამომავლენი დრო, დამთავრების დრო და აქტიურობა."; +$text['description-agents']['nl-nl'] = "Selecteer de agent, stel de wachtduur, afsluitduur en status in."; +$text['description-agents']['pl-pl'] = "Wybierz agenta, ustaw czas oczekiwania, czas zakończenia i status."; +$text['description-agents']['pt-br'] = "Selecione o agente, configure o tempo de espera, o tempo de encerramento e o status."; +$text['description-agents']['pt-pt'] = "Selecione o agente, configure o tempo de espera, o tempo de encerramento e o status."; +$text['description-agents']['ro-ro'] = "Selectați agentul, setați timpul de așteptare, timpul de închidere și starea."; +$text['description-agents']['ru-ru'] = "Выберите агента, установите время ожидания, время завершения и включите."; +$text['description-agents']['sv-se'] = "Välj agenten, ställ in väntetid, avslutningstid och status."; +$text['description-agents']['uk-ua'] = "Оберіть агента, встановіть час очікування, час закінчення та включіть."; +$text['description-agents']['tr-tr'] = "Ağcın seçin, bekletme süresini, sona erme süresini ve durumunu ayarlayın."; +$text['description-agents']['zh-cn'] = "选择代理,设置等待时间,结束时间,并启用。"; +$text['description-agents']['ja-jp'] = "アーカイブを選択し、待ち時間、終了時間、有効化を設定します。"; +$text['description-agents']['ko-kr'] = "대리자를 선택하고 대기 시간, 종료 시간, 활성화를 설정하세요."; + +?> diff --git a/app/fifo/fifo_edit.php b/app/fifo/fifo_edit.php index b465e5af6b..d4d69d776f 100644 --- a/app/fifo/fifo_edit.php +++ b/app/fifo/fifo_edit.php @@ -577,7 +577,7 @@ echo " ".$text['label-strategy']."\n"; echo "\n"; echo "
".escape($_SESSION['domains'][$row['domain_uuid']]['domain_name'])."\n"; - echo " \n"; + echo " get('fax', 'extension_range') ?? '')."\">\n"; echo "
\n"; echo "".$text['description-extension']."\n"; echo "
".(!empty($_SESSION['domain']['time_format']['text']) && $_SESSION['domain']['time_format']['text'] == '12h' ? date("j M Y g:i:sa", $row['fax_epoch']) : date("j M Y H:i:s", $row['fax_epoch']))." ".(!empty($settings->get('domain', 'time_format')) && $settings->get('domain', 'time_format') == '12h' ? date("j M Y g:i:sa", $row['fax_epoch']) : date("j M Y H:i:s", $row['fax_epoch']))." ".$row['fax_success']." ".$row['fax_result_code']." ".$row['fax_result_text']." \n"; - echo " \n"; echo " \n"; echo " \n"; echo " \n"; @@ -659,7 +659,7 @@ } echo "
\n"; echo "
\n"; - echo $text['description-member_enabled']."\n"; + echo $text['description-agents']."\n"; echo "\n"; echo "\n"; @@ -805,4 +805,4 @@ //include the footer require_once "resources/footer.php"; -?> \ No newline at end of file +?> diff --git a/app/fifo/resources/classes/fifo.php b/app/fifo/resources/classes/fifo.php index ff3d8f042a..1a63a5a4e9 100644 --- a/app/fifo/resources/classes/fifo.php +++ b/app/fifo/resources/classes/fifo.php @@ -11,12 +11,21 @@ const app_name = 'fifo'; const app_uuid = '16589224-c876-aeb3-f59f-523a1c0801f7'; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + /** * declare the variables */ - private $app_name; - private $app_uuid; - private $database; private $name; private $table; private $toggle_field; @@ -27,7 +36,13 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + //assign the variables $this->name = 'fifo'; $this->table = 'fifo'; @@ -36,11 +51,6 @@ $this->toggle_values = ['true','false']; $this->description_field = 'fifo_description'; $this->location = 'fifo.php'; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } } /** @@ -87,7 +97,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, dialplan_uuid from v_".$this->table." "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -102,11 +112,11 @@ foreach ($fifos as $fifo_uuid => $fifo) { //add to the array $array[$this->table][$x][$this->name.'_uuid'] = $fifo_uuid; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; $array['fifo_members'][$x]['fifo_uuid'] = $fifo_uuid; - $array['fifo_members'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['fifo_members'][$x]['domain_uuid'] = $this->domain_uuid; $array['dialplans'][$x]['dialplan_uuid'] = $fifo['dialplan_uuid']; - $array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['domain_uuid'] = $this->domain_uuid; //increment the id $x++; @@ -165,7 +175,7 @@ $sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -234,7 +244,7 @@ $sql = "select * from v_".$this->table." "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { diff --git a/app/fifo_list/fifo_list_inc.php b/app/fifo_list/fifo_list_inc.php index 58f5ecfd22..7ebf427aeb 100644 --- a/app/fifo_list/fifo_list_inc.php +++ b/app/fifo_list/fifo_list_inc.php @@ -42,7 +42,7 @@ $text = $language->get(); //include theme config for button images - include_once("themes/".$_SESSION['domain']['template']['name']."/config.php"); + include_once("themes/".$settings->get('domain', 'template')."/config.php"); //show the list $switch_cmd = 'fifo list'; diff --git a/app/gateways/gateway_edit.php b/app/gateways/gateway_edit.php index 1ad44810f4..fd38c6eea4 100644 --- a/app/gateways/gateway_edit.php +++ b/app/gateways/gateway_edit.php @@ -58,14 +58,14 @@ //get total gateway count from the database, check limit, if defined if ($action == 'add') { - if (!empty($_SESSION['limit']['gateways']['numeric'])) { + if (!empty($settings->get('limit', 'gateways'))) { $sql = "select count(gateway_uuid) from v_gateways "; $sql .= "where (domain_uuid = :domain_uuid ".(permission_exists('gateway_domain') ? " or domain_uuid is null " : null).") "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $total_gateways = $database->select($sql, $parameters, 'column'); unset($sql, $parameters); - if ($total_gateways >= $_SESSION['limit']['gateways']['numeric']) { - message::add($text['message-maximum_gateways'].' '.$_SESSION['limit']['gateways']['numeric'], 'negative'); + if ($total_gateways >= $settings->get('limit', 'gateways')) { + message::add($text['message-maximum_gateways'].' '.$settings->get('limit', 'gateways'), 'negative'); header('Location: gateways.php'); exit; } @@ -212,8 +212,8 @@ $message = $database->message; //remove xml file (if any) if not enabled - if ($enabled != true && !empty($_SESSION['switch']['sip_profiles']['dir'])) { - $gateway_xml_file = $_SESSION['switch']['sip_profiles']['dir']."/".$profile."/v_".$gateway_uuid.".xml"; + if ($enabled != true && !empty($settings->get('switch', 'sip_profiles'))) { + $gateway_xml_file = $settings->get('switch', 'sip_profiles')."/".$profile."/v_".$gateway_uuid.".xml"; if (file_exists($gateway_xml_file)) { unlink($gateway_xml_file); } @@ -303,41 +303,40 @@ $sip_profiles = $database->select($sql, null, 'all'); unset($sql); -//set defaults - if (empty($gateway_uuid)) { $gateway_uuid = ""; } - if (empty($retry_seconds)) { $retry_seconds = "30"; } - if (empty($gateway)) { $gateway = ''; } - if (empty($username)) { $username = ''; } - if (empty($password)) { $password = ''; } - if (empty($auth_username)) { $auth_username = ''; } - if (empty($realm)) { $realm = ''; } - if (empty($from_user)) { $from_user = ''; } - if (empty($from_domain)) { $from_domain = ''; } - if (empty($proxy)) { $proxy = ''; } - if (empty($register_proxy)) { $register_proxy = ''; } - if (empty($outbound_proxy)) { $outbound_proxy = ''; } - if (empty($expire_seconds)) { $expire_seconds = ''; } - if (empty($register_transport)) { $register_transport = ''; } - if (empty($contact_params)) { $contact_params = ''; } - if (empty($retry_seconds)) { $retry_seconds = ''; } - if (empty($extension)) { $extension = ''; } - if (empty($ping)) { $ping = ''; } - if (empty($ping_min)) { $ping_min = ''; } - if (empty($ping_max)) { $ping_max = ''; } - if (empty($channels)) { $channels = ''; } - if (empty($sip_cid_type)) { $sip_cid_type = ''; } - if (empty($codec_prefs)) { $codec_prefs = ''; } - if (empty($extension_in_contact)) { $extension_in_contact = ''; } - if (empty($context)) { $context = ''; } - if (empty($profile)) { $profile = ''; } - if (empty($hostname)) { $hostname = ''; } - if (empty($description)) { $description = ''; } - if ($register === null) { $register = true; } - if ($distinct_to === null) { $distinct_to = false; } - if ($caller_id_in_from === null) { $caller_id_in_from = false; } - if ($supress_cng === null) { $supress_cng = false; } - if ($contact_in_ping === null) { $contact_in_ping = true; } - if ($enabled === null) { $enabled = true; } +//set the defaults + $gateway_uuid = $gateway_uuid ?? ''; + $retry_seconds = $retry_seconds ?? '30'; + $gateway = $gateway ?? ''; + $username = $username ?? ''; + $password = $password ?? ''; + $auth_username = $auth_username ?? ''; + $realm = $realm ?? ''; + $from_user = $from_user ?? ''; + $from_domain = $from_domain ?? ''; + $proxy = $proxy ?? ''; + $register_proxy = $register_proxy ?? ''; + $outbound_proxy = $outbound_proxy ?? ''; + $expire_seconds = $expire_seconds ?? ''; + $register_transport = $register_transport ?? ''; + $contact_params = $contact_params ?? ''; + $extension = $extension ?? ''; + $ping = $ping ?? ''; + $ping_min = $ping_min ?? ''; + $ping_max = $ping_max ?? ''; + $channels = $channels ?? ''; + $sip_cid_type = $sip_cid_type ?? ''; + $codec_prefs = $codec_prefs ?? ''; + $extension_in_contact = $extension_in_contact ?? ''; + $context = $context ?? ''; + $profile = $profile ?? ''; + $hostname = $hostname ?? ''; + $description = $description ?? ''; + $register = $register ?? false; + $distinct_to = $distinct_to ?? false; + $caller_id_in_from = $caller_id_in_from ?? false; + $supress_cng = $supress_cng ?? false; + $contact_in_ping = $contact_in_ping ?? false; + $enabled = $enabled ?? false; //create token $object = new token; diff --git a/app/gateways/gateways.php b/app/gateways/gateways.php index 4d723ae9d6..76ef7e7c77 100644 --- a/app/gateways/gateways.php +++ b/app/gateways/gateways.php @@ -300,7 +300,7 @@ $list_row_url = ''; if (permission_exists('gateway_edit')) { $list_row_url = "gateway_edit.php?id=".urlencode($row['gateway_uuid']); - if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { + if (!empty($row['domain_uuid']) && $row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true'; } } diff --git a/app/gateways/resources/classes/gateways.php b/app/gateways/resources/classes/gateways.php index 0d90253711..2467c684ea 100644 --- a/app/gateways/resources/classes/gateways.php +++ b/app/gateways/resources/classes/gateways.php @@ -34,9 +34,32 @@ const app_uuid = '297ab33e-2c2f-8196-552c-f3567d2caaf8'; /** - * declare private variables + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object */ private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + + /** + * declare private variables + */ private $permission_prefix; private $list_page; private $table; @@ -47,7 +70,14 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); //assign private variables $this->permission_prefix = 'gateway_'; @@ -56,12 +86,6 @@ $this->uuid_prefix = 'gateway_'; $this->toggle_field = 'enabled'; $this->toggle_values = ['true','false']; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } - } /** @@ -101,7 +125,7 @@ else { $sql .= "where (domain_uuid = :domain_uuid) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; } $rows = $this->database->select($sql, $parameters ?? null, 'all'); if (!empty($rows) && is_array($rows) && @sizeof($rows) != 0) { @@ -188,7 +212,7 @@ else { $sql .= "where (domain_uuid = :domain_uuid) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; } $rows = $this->database->select($sql, $parameters ?? null, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { @@ -265,7 +289,7 @@ else { $sql .= "where (domain_uuid = :domain_uuid) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; } $rows = $this->database->select($sql, $parameters ?? null, 'all'); if (!empty($rows) && is_array($rows) && @sizeof($rows) != 0) { @@ -288,8 +312,8 @@ unset($_SESSION['gateways'][$gateway_uuid]); //remove the xml file (if any) - if (!empty($_SESSION['switch']['sip_profiles']['dir'])) { - $gateway_xml_file = $_SESSION['switch']['sip_profiles']['dir']."/".$gateway['profile']."/v_".$gateway_uuid.".xml"; + if (!empty($this->settings->get('switch', 'sip_profiles'))) { + $gateway_xml_file = $this->settings->get('switch', 'sip_profiles')."/".$gateway['profile']."/v_".$gateway_uuid.".xml"; if (file_exists($gateway_xml_file)) { unlink($gateway_xml_file); } @@ -388,7 +412,7 @@ else { $sql .= "where (domain_uuid = :domain_uuid) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; } $rows = $this->database->select($sql, $parameters ?? null, 'all'); if (!empty($rows) && is_array($rows) && @sizeof($rows) != 0) { @@ -426,8 +450,8 @@ unset($_SESSION['gateways'][$gateway_uuid]); //remove the xml file (if any) - if (!empty($_SESSION['switch']['sip_profiles']['dir'])) { - $gateway_xml_file = $_SESSION['switch']['sip_profiles']['dir']."/".$gateway['profile']."/v_".$gateway_uuid.".xml"; + if (!empty($this->settings->get('switch', 'sip_profiles'))) { + $gateway_xml_file = $this->settings->get('switch', 'sip_profiles')."/".$gateway['profile']."/v_".$gateway_uuid.".xml"; if (file_exists($gateway_xml_file)) { unlink($gateway_xml_file); } @@ -511,7 +535,7 @@ else { $sql .= "where (domain_uuid = :domain_uuid) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; } $rows = $this->database->select($sql, $parameters ?? null, 'all'); if (!empty($rows) && is_array($rows) && @sizeof($rows) != 0) { diff --git a/app/ivr_menus/ivr_menu_edit.php b/app/ivr_menus/ivr_menu_edit.php index 5697598e1c..c731af0bf7 100644 --- a/app/ivr_menus/ivr_menu_edit.php +++ b/app/ivr_menus/ivr_menu_edit.php @@ -611,8 +611,8 @@ if (empty($ivr_menu_digit_len)) { $ivr_menu_digit_len = '5'; } if (!isset($ivr_menu_context)) { $ivr_menu_context = $_SESSION['domain_name']; } if (!isset($ivr_menu_exit_action)) { $ivr_menu_exit_action = ''; } - if ($ivr_menu_direct_dial === null) { $ivr_menu_direct_dial = false; } - if ($ivr_menu_enabled === null) { $ivr_menu_enabled = true; } + $ivr_menu_direct_dial = $ivr_menu_direct_dial ?? false; + $ivr_menu_enabled = $ivr_menu_enabled ?? true; //get installed languages $language_paths = glob($settings->get('switch', 'sounds')."/*/*/*"); diff --git a/app/ivr_menus/ivr_menus.php b/app/ivr_menus/ivr_menus.php index 6d470792d1..4607c2e7b4 100644 --- a/app/ivr_menus/ivr_menus.php +++ b/app/ivr_menus/ivr_menus.php @@ -114,7 +114,7 @@ $num_rows = $database->select($sql, $parameters ?? '', 'column'); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = "&search=".urlencode($search); if ($show == "all" && permission_exists('ivr_menu_all')) { $param .= "&show=all"; @@ -166,10 +166,10 @@ echo "
\n"; echo "
".$text['title-ivr_menus']."
".number_format($num_rows)."
\n"; echo "
\n"; - if (permission_exists('ivr_menu_add') && (empty($_SESSION['limit']['ivr_menus']['numeric']) || $num_rows < $_SESSION['limit']['ivr_menus']['numeric'])) { + if (permission_exists('ivr_menu_add') && (empty($settings->get('limit', 'ivr_menus')) || $num_rows < $settings->get('limit', 'ivr_menus'))) { echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','link'=>'ivr_menu_edit.php']); } - if (permission_exists('ivr_menu_add') && $ivr_menus && (empty($_SESSION['limit']['ivr_menus']['numeric']) || $num_rows < $_SESSION['limit']['ivr_menus']['numeric'])) { + if (permission_exists('ivr_menu_add') && $ivr_menus && (empty($settings->get('limit', 'ivr_menus')) || $num_rows < $settings->get('limit', 'ivr_menus'))) { echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$settings->get('theme', 'button_icon_copy'),'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]); } if (permission_exists('ivr_menu_edit') && $ivr_menus) { diff --git a/app/ivr_menus/resources/classes/ivr_menu.php b/app/ivr_menus/resources/classes/ivr_menu.php index 3e50c097a4..f677a93a29 100644 --- a/app/ivr_menus/resources/classes/ivr_menu.php +++ b/app/ivr_menus/resources/classes/ivr_menu.php @@ -34,16 +34,37 @@ const app_uuid = 'a5788e9b-58bc-bd1b-df59-fff5d51253ab'; /** - * declare public variables + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string */ public $domain_uuid; + + /** + * declare public variables + */ public $ivr_menu_uuid; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_name; + /** * declare private variables */ - - private $database; private $permission_prefix; private $list_page; private $table; @@ -54,16 +75,16 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); //assign private variables $this->list_page = 'ivr_menus.php'; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } - } public function find() { @@ -121,7 +142,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, dialplan_uuid, ivr_menu_context from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -220,7 +241,7 @@ $sql = "select ivr_menu_context from v_ivr_menus "; $sql .= "where (domain_uuid = :domain_uuid) "; $sql .= "and ivr_menu_uuid = :ivr_menu_uuid "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $parameters['ivr_menu_uuid'] = $this->ivr_menu_uuid; $ivr_menu_context = $this->database->select($sql, $parameters, 'column'); unset($sql, $parameters); @@ -285,7 +306,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, dialplan_uuid from v_".$this->table." "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -322,7 +343,7 @@ //clear the cache $cache = new cache; - $cache->delete("dialplan:".$_SESSION['domain_name']); + $cache->delete("dialplan:".$this->domain_name); foreach ($ivr_menus as $ivr_menu_uuid => $ivr_menu) { $cache->delete("configuration:ivr.conf:".$ivr_menu_uuid); } @@ -383,7 +404,7 @@ $sql = "select * from v_".$this->table." "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (!empty($rows)) { $y = $z = 0; @@ -466,7 +487,7 @@ //clear the cache $cache = new cache; - $cache->delete("dialplan:".$_SESSION['domain_name']); + $cache->delete("dialplan:".$this->domain_name); //set message message::add($text['message-copy']); diff --git a/app/ivr_menus/resources/functions/ivr_menu_xml.php b/app/ivr_menus/resources/functions/ivr_menu_xml.php index bf042b5894..5669d46802 100644 --- a/app/ivr_menus/resources/functions/ivr_menu_xml.php +++ b/app/ivr_menus/resources/functions/ivr_menu_xml.php @@ -35,7 +35,7 @@ else { $v_needle = 'v_'; } - if($dh = opendir($_SESSION['switch']['conf']['dir']."/ivr_menus/")) { + if($dh = opendir($settings->get('switch', 'conf')."/ivr_menus/")) { $files = Array(); while($file = readdir($dh)) { if($file != "." && $file != ".." && $file[0] != '.') { @@ -44,7 +44,7 @@ } else { if (strpos($file, $v_needle) !== false && substr($file,-4) == '.xml') { //echo "file: $file
\n"; - unlink($_SESSION['switch']['conf']['dir']."/ivr_menus/".$file); + unlink($settings->get('switch', 'conf')."/ivr_menus/".$file); } } } @@ -169,10 +169,10 @@ //write the file if (count($_SESSION["domains"]) > 1) { - $fout = fopen($_SESSION['switch']['conf']['dir']."/ivr_menus/v_".$_SESSION['domains'][$row['domain_uuid']]['domain_name']."_".$ivr_menu_name.".xml","w"); + $fout = fopen($settings->get('switch', 'conf')."/ivr_menus/v_".$_SESSION['domains'][$row['domain_uuid']]['domain_name']."_".$ivr_menu_name.".xml","w"); } else { - $fout = fopen($_SESSION['switch']['conf']['dir']."/ivr_menus/v_".$ivr_menu_name.".xml","w"); + $fout = fopen($settings->get('switch', 'conf')."/ivr_menus/v_".$ivr_menu_name.".xml","w"); } fwrite($fout, $tmp); fclose($fout); diff --git a/app/ivr_menus/waveform.php b/app/ivr_menus/waveform.php index 8b760cd949..e65e25191c 100644 --- a/app/ivr_menus/waveform.php +++ b/app/ivr_menus/waveform.php @@ -46,20 +46,20 @@ if ($_GET['type'] == 'recordings') { $slash = substr($_GET['data'],0,1) != '/' ? '/' : null; - $full_file_path = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].$slash.str_replace($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'], '', $_GET['data']); + $full_file_path = $settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].$slash.str_replace($settings->get('switch', 'recordings')."/".$_SESSION['domain_name'], '', $_GET['data']); } else if ($_GET['type'] == 'sounds') { //get first installed language (like en/us/callie) - $language_paths = glob($_SESSION["switch"]['sounds']['dir']."/*/*/*"); + $language_paths = glob($settings->get('switch', 'sounds')."/*/*/*"); foreach ($language_paths as $key => $path) { - $path = str_replace($_SESSION["switch"]['sounds']['dir'].'/', "", $path); + $path = str_replace($settings->get('switch', 'sounds').'/', "", $path); $path_array = explode('/', $path); if (count($path_array) <> 3 || strlen($path_array[0]) <> 2 || strlen($path_array[1]) <> 2) { unset($language_paths[$key]); } - $language_paths[$key] = str_replace($_SESSION["switch"]['sounds']['dir']."/","",$language_paths[$key] ?? ''); + $language_paths[$key] = str_replace($settings->get('switch', 'sounds')."/","",$language_paths[$key] ?? ''); if (empty($language_paths[$key])) { unset($language_paths[$key]); } @@ -69,7 +69,7 @@ //determine the path for sound file $filename_parts = explode('/', str_replace('..', '', $_GET['data'])); if (!is_array($filename_parts) || @sizeof($filename_parts) != 2) { exit; } - $path = $_SESSION['switch']['sounds']['dir'].'/'.$language_path.'/'.$filename_parts[0].'/8000/'; + $path = $settings->get('switch', 'sounds').'/'.$language_path.'/'.$filename_parts[0].'/8000/'; //build full path to sound file $full_file_path = $path.$filename_parts[1]; @@ -91,13 +91,13 @@ $waveform = new Waveform($full_file_path); Waveform::$linesPerPixel = 1; // default: 8 Waveform::$samplesPerLine = 512; // default: 512 - Waveform::$colorA = !empty($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color - Waveform::$colorB = !empty($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color - Waveform::$backgroundColor = !empty($_SESSION['theme']['audio_player_waveform_color_background']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_background']['text']) : [0,0,0,0]; // array rgba, default: transparent - Waveform::$axisColor = !empty($_SESSION['theme']['audio_player_waveform_color_axis']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_axis']['text']) : [0,0,0,0.3]; // array rgba - Waveform::$singlePhase = filter_var($_SESSION['theme']['audio_player_waveform_single_phase']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom - Waveform::$singleAxis = filter_var($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis - $height = !empty($_SESSION['theme']['audio_player_waveform_height']['text']) && is_numeric(str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text'])) ? 2.2 * (int) str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text']) : null; + Waveform::$colorA = !empty($settings->get('theme', 'audio_player_waveform_color_a_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_a_leg')) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color + Waveform::$colorB = !empty($settings->get('theme', 'audio_player_waveform_color_b_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_b_leg')) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color + Waveform::$backgroundColor = !empty($settings->get('theme', 'audio_player_waveform_color_background')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_background')) : [0,0,0,0]; // array rgba, default: transparent + Waveform::$axisColor = !empty($settings->get('theme', 'audio_player_waveform_color_axis')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_axis')) : [0,0,0,0.3]; // array rgba + Waveform::$singlePhase = filter_var($settings->get('theme', 'audio_player_waveform_single_phase') ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom + Waveform::$singleAxis = filter_var($settings->get('theme', 'audio_player_waveform_single_axis') ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis + $height = !empty($settings->get('theme', 'audio_player_waveform_height')) && is_numeric(str_replace('px','',$settings->get('theme', 'audio_player_waveform_height'))) ? 2.2 * (int) str_replace('px','',$settings->get('theme', 'audio_player_waveform_height')) : null; $wf = $waveform->getWaveform($temp_filename, 1600, $height ?? 180); // input: png filename returns boolean true/false, or 'base64' returns base64 string } diff --git a/app/log_viewer/log_viewer.php b/app/log_viewer/log_viewer.php index a3d4e38627..7541aa9b4f 100644 --- a/app/log_viewer/log_viewer.php +++ b/app/log_viewer/log_viewer.php @@ -64,27 +64,27 @@ //set default default log file if (isset($_POST['log_file'])) { - $approved_files = glob($_SESSION['switch']['log']['dir'].'/freeswitch.log*'); + $approved_files = glob($settings->get('switch', 'log').'/freeswitch.log*'); if (is_array($approved_files)) { foreach($approved_files as $approved_file) { - if ($approved_file == $_SESSION['switch']['log']['dir'].'/'.$_POST['log_file']) { + if ($approved_file == $settings->get('switch', 'log').'/'.$_POST['log_file']) { $log_file = $approved_file; } } } } else { - $log_file = $_SESSION['switch']['log']['dir'].'/freeswitch.log'; + $log_file = $settings->get('switch', 'log').'/freeswitch.log'; } //download the log if (permission_exists('log_download')) { if (isset($_GET['n'])) { if (isset($filename)) { unset($filename); } - $approved_files = glob($_SESSION['switch']['log']['dir'].'/freeswitch.log*'); + $approved_files = glob($settings->get('switch', 'log').'/freeswitch.log*'); if (is_array($approved_files)) { foreach($approved_files as $approved_file) { - if ($approved_file == $_SESSION['switch']['log']['dir'].'/'.$_GET['n']) { + if ($approved_file == $settings->get('switch', 'log').'/'.$_GET['n']) { $filename = $approved_file; } } @@ -121,7 +121,7 @@ echo "
\n"; echo "
\n"; echo " ".$text['label-log_file']." \n"; + echo "
\n"; + echo $text['description-music_on_hold_chime_list']."\n"; echo "\n"; echo "\n"; 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 334d8657da..0035cc7031 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 @@ -35,13 +35,48 @@ const app_name = 'music_on_hold'; const app_uuid = '1dafe0f8-c08a-289b-0312-15baf4f20f81'; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Username set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $username; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_name; + /** * declare private variables */ private $xml; private $app_name; private $app_uuid; - private $database; private $permission_prefix; private $list_page; private $table; @@ -50,19 +85,20 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); //assign private variables $this->permission_prefix = 'music_on_hold_'; $this->list_page = 'music_on_hold.php'; $this->table = 'music_on_hold'; $this->uuid_prefix = 'music_on_hold_'; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } - } public function select($name, $selected, $options) { @@ -110,7 +146,7 @@ $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and stream_enabled = 'true' "; $sql .= "order by stream_name asc "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $streams = $this->database->select($sql, $parameters, 'all'); if (is_array($streams) && @sizeof($streams) != 0) { $select .= " "; @@ -146,7 +182,7 @@ $sql .= "left join v_domains as d on d.domain_uuid = m.domain_uuid "; $sql .= "where (m.domain_uuid = :domain_uuid or m.domain_uuid is null) "; $sql .= "order by m.domain_uuid desc, music_on_hold_name asc, music_on_hold_rate asc "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; return $this->database->select($sql, $parameters, 'all'); unset($sql, $parameters); } @@ -168,7 +204,7 @@ public function xml() { //build the list of categories - $music_on_hold_dir = $_SESSION['switch']['sounds']['dir'].'/music'; + $music_on_hold_dir = $settings->get('switch', 'sounds').'/music'; //default category (note: GLOB_BRACE doesn't work on some systems) $array_1 = glob($music_on_hold_dir."/8000".$class_name.".php", GLOB_ONLYDIR); $array_2 = glob($music_on_hold_dir."/16000".$class_name.".php", GLOB_ONLYDIR); @@ -218,7 +254,7 @@ } //check where the default music is stored $default_moh_prefix = 'music/default'; - if(file_exists($_SESSION['switch']['sounds']['dir'].'/music/8000')) { + if(file_exists($settings->get('switch', 'sounds').'/music/8000')) { $default_moh_prefix = 'music'; } //replace the variables @@ -226,7 +262,7 @@ $file_contents = preg_replace("/[\t ]*(?:)?/", $this->xml, $file_contents); //write the XML config file - $fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/local_stream.conf.xml","w"); + $fout = fopen($settings->get('switch', 'conf')."/autoload_configs/local_stream.conf.xml","w"); fwrite($fout, $file_contents); fclose($fout); @@ -250,7 +286,7 @@ unset($sql); //build an array of the sound files - $music_directory = $_SESSION['switch']['sounds']['dir'].'/music'; + $music_directory = $settings->get('switch', 'sounds').'/music'; if (file_exists($music_directory)) { $files = array_merge(glob($music_directory.'/*/*/*.wav'), glob($music_directory.'/*/*/*/*.wav'), glob($stream_path.'/*/*/*/*.mp3'), glob($stream_path.'/*/*/*/*.ogg')); } @@ -362,7 +398,7 @@ $sql = "select * from v_music_on_hold "; $sql .= "where (domain_uuid = :domain_uuid ".(!permission_exists('music_on_hold_domain') ? "": "or domain_uuid is null ").") "; $sql .= "and music_on_hold_uuid in ('".implode("','", array_keys($moh))."') "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -378,7 +414,7 @@ //prepare path $stream_path = $streams[$music_on_hold_uuid]['music_on_hold_path']; - $stream_path = str_replace('$${sounds_dir}', $_SESSION['switch']['sounds']['dir'], $stream_path); + $stream_path = str_replace('$${sounds_dir}', $settings->get('switch', 'sounds'), $stream_path); //delete checked files foreach ($row as $key => $stream_file) { @@ -396,7 +432,7 @@ //build delete array $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $music_on_hold_uuid; if (!permission_exists('music_on_hold_domain')) { - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; } $x++; diff --git a/app/music_on_hold/waveform.php b/app/music_on_hold/waveform.php index 5c668fca9c..036b7ea99f 100644 --- a/app/music_on_hold/waveform.php +++ b/app/music_on_hold/waveform.php @@ -57,7 +57,7 @@ unset($sql, $parameters); //replace the sounds_dir variable in the path - $stream_path = str_replace('$${sounds_dir}', $_SESSION['switch']['sounds']['dir'], $stream_path); + $stream_path = str_replace('$${sounds_dir}', $settings->get('switch', 'sounds'), $stream_path); $stream_path = str_replace('..', '', $stream_path); //get the file and sanitize it @@ -81,13 +81,13 @@ $waveform = new Waveform($stream_full_path); Waveform::$linesPerPixel = 1; // default: 8 Waveform::$samplesPerLine = 512; // default: 512 - Waveform::$colorA = !empty($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color - Waveform::$colorB = !empty($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color - Waveform::$backgroundColor = !empty($_SESSION['theme']['audio_player_waveform_color_background']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_background']['text']) : [0,0,0,0]; // array rgba, default: transparent - Waveform::$axisColor = !empty($_SESSION['theme']['audio_player_waveform_color_axis']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_axis']['text']) : [0,0,0,0.3]; // array rgba - Waveform::$singlePhase = filter_var($_SESSION['theme']['audio_player_waveform_single_phase']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom - Waveform::$singleAxis = Waveform::$singlePhase === true ? false : (filter_var($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'); // combine channels into single axis - $height = !empty($_SESSION['theme']['audio_player_waveform_height']['text']) && is_numeric(str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text'])) ? 2.2 * (int) str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text']) : null; + Waveform::$colorA = !empty($settings->get('theme', 'audio_player_waveform_color_a_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_a_leg')) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color + Waveform::$colorB = !empty($settings->get('theme', 'audio_player_waveform_color_b_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_b_leg')) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color + Waveform::$backgroundColor = !empty($settings->get('theme', 'audio_player_waveform_color_background')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_background')) : [0,0,0,0]; // array rgba, default: transparent + Waveform::$axisColor = !empty($settings->get('theme', 'audio_player_waveform_color_axis')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_axis')) : [0,0,0,0.3]; // array rgba + Waveform::$singlePhase = filter_var($settings->get('theme', 'audio_player_waveform_single_phase') ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom + Waveform::$singleAxis = Waveform::$singlePhase === true ? false : (filter_var($settings->get('theme', 'audio_player_waveform_single_axis') ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'); // combine channels into single axis + $height = !empty($settings->get('theme', 'audio_player_waveform_height')) && is_numeric(str_replace('px','',$settings->get('theme', 'audio_player_waveform_height'))) ? 2.2 * (int) str_replace('px','',$settings->get('theme', 'audio_player_waveform_height')) : null; $wf = $waveform->getWaveform($temp_filename, 1600, $height ?? 180); // input: png filename returns boolean true/false, or 'base64' returns base64 string } diff --git a/app/number_translations/number_translations.php b/app/number_translations/number_translations.php index 06e59644d9..b400108878 100644 --- a/app/number_translations/number_translations.php +++ b/app/number_translations/number_translations.php @@ -121,7 +121,7 @@ $num_rows = $database->select($sql, $parameters ?? null, 'column'); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = $search ? "&search=".$search : null; $page = isset($_GET['page']) ? $_GET['page'] : 0; list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); @@ -221,9 +221,6 @@ $list_row_url = ''; if (permission_exists('number_translation_edit')) { $list_row_url = "number_translation_edit.php?id=".urlencode($row['number_translation_uuid']); - if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { - $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true'; - } } echo "\n"; if (permission_exists('number_translation_add') || permission_exists('number_translation_edit') || permission_exists('number_translation_delete')) { @@ -273,4 +270,3 @@ require_once "resources/footer.php"; ?> - diff --git a/app/number_translations/resources/classes/number_translations.php b/app/number_translations/resources/classes/number_translations.php index dfbd224a42..fa1b236bee 100644 --- a/app/number_translations/resources/classes/number_translations.php +++ b/app/number_translations/resources/classes/number_translations.php @@ -54,7 +54,9 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set objects + $this->database = $setting_array['database'] ?? database::new(); //assign private variables $this->permission_prefix = 'number_translation_'; @@ -63,12 +65,6 @@ $this->uuid_prefix = 'number_translation_'; $this->toggle_field = 'number_translation_enabled'; $this->toggle_values = ['true','false']; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } - } /** @@ -79,7 +75,6 @@ $sql .= "where number_translation_name = :number_translation_name "; $parameters['number_translation_name'] = $name; return $this->database->select($sql, $parameters, 'column') != 0 ? true : false; - unset($sql, $parameters); } /** @@ -135,7 +130,7 @@ $this->database->save($array); unset($array); if (!empty($this->display_type) && $this->display_type == "text") { - if ($this->database->message['code'] != '200') { + if ($this->database->message['code'] != '200') { echo "number_translation:".$number_translation['@attributes']['name'].": failed: ".$this->database->message['message']."\n"; } else { @@ -148,7 +143,7 @@ } unset ($this->xml, $this->json); } - + /** * delete records */ diff --git a/app/phrases/phrase_edit.php b/app/phrases/phrase_edit.php index 925785faa2..659530f76b 100644 --- a/app/phrases/phrase_edit.php +++ b/app/phrases/phrase_edit.php @@ -338,11 +338,11 @@ echo "var opt_group = document.createElement('optgroup');\n"; echo "opt_group.label = \"".$text['label-recordings']."\";\n"; foreach ($recordings as $row) { - if (!empty($_SESSION['recordings']['storage_type']['text']) && $_SESSION['recordings']['storage_type']['text'] == 'base64') { + if (!empty($settings->get('recordings', 'storage_type')) && $settings->get('recordings', 'storage_type') == 'base64') { echo "opt_group.appendChild(new Option(\"".$row["recording_name"]."\", \"\${lua streamfile.lua ".$row["recording_filename"]."}\"));\n"; } else { - echo "opt_group.appendChild(new Option(\"".$row["recording_name"]."\", \"".$_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$row["recording_filename"]."\"));\n"; + echo "opt_group.appendChild(new Option(\"".$row["recording_name"]."\", \"".$settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/'.$row["recording_filename"]."\"));\n"; } } echo "obj_action.appendChild(opt_group);\n"; @@ -511,7 +511,7 @@ } else if ($field['phrase_detail_function'] == 'play-file') { $phrase_detail_function = $text['label-play']; - $phrase_detail_data = str_replace($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/', '', $field['phrase_detail_data']); + $phrase_detail_data = str_replace($settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/', '', $field['phrase_detail_data']); } else { $phrase_detail_function = $field['phrase_detail_function']; diff --git a/app/phrases/resources/classes/phrases.php b/app/phrases/resources/classes/phrases.php index f7fc8549f9..f09e63ac75 100644 --- a/app/phrases/resources/classes/phrases.php +++ b/app/phrases/resources/classes/phrases.php @@ -38,11 +38,21 @@ */ public $phrase_uuid; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + /** * declare private variables */ - - private $database; private $permission_prefix; private $list_page; private $table; @@ -53,7 +63,12 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); //assign private variables $this->permission_prefix = 'phrase_'; @@ -62,12 +77,6 @@ $this->uuid_prefix = 'phrase_'; $this->toggle_field = 'phrase_enabled'; $this->toggle_values = ['true','false']; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } - } /** @@ -103,7 +112,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, phrase_language as lang from v_".$this->table." "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -118,9 +127,9 @@ $x = 0; foreach ($phrase_languages as $phrase_uuid => $phrase_language) { $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $phrase_uuid; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; $array['phrase_details'][$x][$this->uuid_prefix.'uuid'] = $phrase_uuid; - $array['phrase_details'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['phrase_details'][$x]['domain_uuid'] = $this->domain_uuid; $x++; } } @@ -188,7 +197,7 @@ if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) { $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; $array[$this->table][$x]['phrase_uuid'] = $this->phrase_uuid; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; } } @@ -197,7 +206,7 @@ $sql = "select phrase_language as lang from v_phrases "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and phrase_uuid = :phrase_uuid "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $parameters['phrase_uuid'] = $this->phrase_uuid; $phrase_language = $this->database->select($sql, $parameters, 'column'); unset($sql, $parameters, $rows, $row); @@ -260,7 +269,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, phrase_language as lang from v_".$this->table." "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -345,7 +354,7 @@ $sql = "select * from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { $y = 0; diff --git a/app/pin_numbers/resources/classes/pin_numbers.php b/app/pin_numbers/resources/classes/pin_numbers.php index 8c28e22c19..17fe911935 100644 --- a/app/pin_numbers/resources/classes/pin_numbers.php +++ b/app/pin_numbers/resources/classes/pin_numbers.php @@ -34,9 +34,26 @@ const app_uuid = '4b88ccfb-cb98-40e1-a5e5-33389e14a388'; /** - * declare private variables + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object */ private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + + /** + * declare private variables + */ private $permission_prefix; private $list_page; private $table; @@ -47,7 +64,12 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); //assign private variables $this->permission_prefix = 'pin_number_'; @@ -56,12 +78,6 @@ $this->uuid_prefix = 'pin_number_'; $this->toggle_field = 'enabled'; $this->toggle_values = ['true','false']; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } - } /** @@ -89,7 +105,7 @@ foreach ($records as $x => $record) { if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; } } @@ -139,7 +155,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -207,7 +223,7 @@ $sql = "select * from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $x => $row) { diff --git a/app/provision/resources/classes/provision.php b/app/provision/resources/classes/provision.php index 078b860fcb..e40dd57a9c 100644 --- a/app/provision/resources/classes/provision.php +++ b/app/provision/resources/classes/provision.php @@ -35,56 +35,54 @@ const app_uuid = 'abf28ead-92ef-3de6-ebbb-023fbc2b6dd3'; /** - * declare public variables + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string */ public $domain_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ public $domain_name; + + /** + * declare public variables + */ public $template_dir; public $device_address; public $device_template; /** - * declare private variables + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object */ private $settings; - private $database; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; /** * called when the object is created */ - public function __construct($params = []) { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; - //preset the the values - $settings = null; - $domain_uuid = null; - - //use the parameters to set the values if they exist - if (isset($params['database'])) { - $this->database = $params['database']; - } - if (isset($params['settings'])) { - $settings = $params['settings']; - } - if (isset($params['domain_uuid'])) { - $domain_uuid = $params['domain_uuid']; - } - - //check if we can use the settings object to get the database object - if (!empty($settings) && empty($this->database)) { - $this->database = $settings->database(); - } - - //fill in missing - if (empty($this->database)) { - $this->database = database::new(); - } - if (empty($settings)) { - $settings = new settings(['database' => $this->database, 'domain_uuid' => $domain_uuid]); - } - - //assign to the object - $this->settings = $settings; - $this->domain_uuid = $domain_uuid; + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); //get the project root $project_root = dirname(__DIR__, 4); @@ -138,8 +136,8 @@ } //normalize the device address - if (isset($this->device_address)) { - $this->device_address = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $this->device_address)); + if (isset($setting_array['device_address'])) { + $this->device_address = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $setting_array['device_address'])); } } diff --git a/app/recordings/app_config.php b/app/recordings/app_config.php index 0807009202..6ca206625c 100644 --- a/app/recordings/app_config.php +++ b/app/recordings/app_config.php @@ -137,7 +137,7 @@ $apps[$x]['default_settings'][$y]['default_setting_category'] = "recordings"; $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "recording_password"; $apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric"; - $apps[$x]['default_settings'][$y]['default_setting_value'] = generate_password(!empty($_SESSION['voicemail']['password_length']['numeric']) && is_numeric($_SESSION['voicemail']['password_length']['numeric']) ? $_SESSION['voicemail']['password_length']['numeric'] : 8, 1); + $apps[$x]['default_settings'][$y]['default_setting_value'] = ''; $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false"; $apps[$x]['default_settings'][$y]['default_setting_description'] = "Set the password required to create a recording (overrides recordings dialplan)."; diff --git a/app/recordings/recordings.php b/app/recordings/recordings.php index 207dff9bb8..3c61ed017d 100644 --- a/app/recordings/recordings.php +++ b/app/recordings/recordings.php @@ -335,6 +335,16 @@ list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; +//set the time zone + $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); + $parameters['time_zone'] = $time_zone; + +//set the sql time format + $sql_time_format = 'HH12:MI am'; + if (!empty($settings->get('domain', 'time_format'))) { + $sql_time_format = $settings->get('domain', 'time_format') == '12h' ? "HH12:MI am" : "HH24:MI"; + } + //get the file size if ($recording_storage_type == 'base64') { switch ($db_type) { diff --git a/app/recordings/resources/classes/switch_recordings.php b/app/recordings/resources/classes/switch_recordings.php index d5fd4db1ee..6e28d97418 100644 --- a/app/recordings/resources/classes/switch_recordings.php +++ b/app/recordings/resources/classes/switch_recordings.php @@ -35,15 +35,38 @@ const app_uuid = '83913217-c7a2-9e90-925d-a866eb40b60e'; /** - * declare public variables + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string */ public $domain_uuid; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_name; + /** * declare private variables */ - - private $database; private $permission_prefix; private $list_page; private $table; @@ -54,21 +77,21 @@ /** * called when the object is created */ - public function __construct() { - //assign public variables - $this->domain_uuid = $_SESSION['domain_uuid']; + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); //assign private variables $this->permission_prefix = 'recording_'; $this->list_page = 'recordings.php'; $this->table = 'recordings'; $this->uuid_prefix = 'recording_'; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } - } /** @@ -81,8 +104,9 @@ $parameters['domain_uuid'] = $this->domain_uuid; $result = $this->database->select($sql, $parameters, 'all'); if (!empty($result)) { + $switch_recordings_domain_dir = $this->settings->get('switch', 'recordings').'/'.$this->domain_name; foreach ($result as $row) { - $recordings[$_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name']."/".$row['recording_filename']] = $row['recording_filename']; + $recordings[$switch_recordings_domain_dir."/".$row['recording_filename']] = $row['recording_filename']; } } else { @@ -121,14 +145,14 @@ $sql = "select recording_filename from v_recordings "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and recording_uuid = :recording_uuid "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $parameters['recording_uuid'] = $record['uuid']; $filenames[] = $this->database->select($sql, $parameters, 'column'); unset($sql, $parameters); //build delete array $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; } } @@ -141,9 +165,10 @@ //delete recording files if (is_array($filenames) && @sizeof($filenames) != 0) { + $switch_recordings_domain_dir = $this->settings->get('switch', 'recordings')."/".$this->domain_name; foreach ($filenames as $filename) { - if (isset($filename) && !empty($filename) && file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$filename)) { - @unlink($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$filename); + if (!empty($filename) && file_exists($switch_recordings_domain_dir."/".$filename)) { + @unlink($switch_recordings_domain_dir."/".$filename); } } } diff --git a/app/recordings/waveform.php b/app/recordings/waveform.php index 5f058ac280..93b01b61aa 100644 --- a/app/recordings/waveform.php +++ b/app/recordings/waveform.php @@ -43,7 +43,7 @@ if (is_uuid($_GET['id']) || !empty($_GET['data'])) { //set the path for the directory - $path = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']; + $path = $settings->get('switch', 'recordings')."/".$_SESSION['domain_name']; //get recording details from db if (is_uuid($_GET['id'])) { @@ -56,7 +56,7 @@ $row = $database->select($sql, $parameters, 'row'); if (is_array($row) && @sizeof($row) != 0) { $recording_filename = $row['recording_filename']; - if (!empty($_SESSION['recordings']['storage_type']['text']) && $_SESSION['recordings']['storage_type']['text'] == 'base64' && !empty($row['recording_base64'])) { + if (!empty($settings->get('recordings', 'storage_type')) && $settings->get('recordings', 'storage_type') == 'base64' && !empty($row['recording_base64'])) { $recording_decoded = base64_decode($row['recording_base64']); file_put_contents($path.'/'.$recording_filename, $recording_decoded); } @@ -86,13 +86,13 @@ $waveform = new Waveform($full_file_path); Waveform::$linesPerPixel = 1; // default: 8 Waveform::$samplesPerLine = 512; // default: 512 - Waveform::$colorA = !empty($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color - Waveform::$colorB = !empty($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color - Waveform::$backgroundColor = !empty($_SESSION['theme']['audio_player_waveform_color_background']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_background']['text']) : [0,0,0,0]; // array rgba, default: transparent - Waveform::$axisColor = !empty($_SESSION['theme']['audio_player_waveform_color_axis']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_axis']['text']) : [0,0,0,0.3]; // array rgba - Waveform::$singlePhase = filter_var($_SESSION['theme']['audio_player_waveform_single_phase']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom - Waveform::$singleAxis = filter_var($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis - $height = !empty($_SESSION['theme']['audio_player_waveform_height']['text']) && is_numeric(str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text'])) ? 2.2 * (int) str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text']) : null; + Waveform::$colorA = !empty($settings->get('theme', 'audio_player_waveform_color_a_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_a_leg')) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color + Waveform::$colorB = !empty($settings->get('theme', 'audio_player_waveform_color_b_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_b_leg')) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color + Waveform::$backgroundColor = !empty($settings->get('theme', 'audio_player_waveform_color_background')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_background')) : [0,0,0,0]; // array rgba, default: transparent + Waveform::$axisColor = !empty($settings->get('theme', 'audio_player_waveform_color_axis')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_axis')) : [0,0,0,0.3]; // array rgba + Waveform::$singlePhase = filter_var($settings->get('theme', 'audio_player_waveform_single_phase') ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom + Waveform::$singleAxis = filter_var($settings->get('theme', 'audio_player_waveform_single_axis') ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis + $height = !empty($settings->get('theme', 'audio_player_waveform_height')) && is_numeric(str_replace('px','',$settings->get('theme', 'audio_player_waveform_height'))) ? 2.2 * (int) str_replace('px','',$settings->get('theme', 'audio_player_waveform_height')) : null; $wf = $waveform->getWaveform($temp_filename, 1600, $height ?? 180); // input: png filename returns boolean true/false, or 'base64' returns base64 string } diff --git a/app/registrations/resources/classes/registrations.php b/app/registrations/resources/classes/registrations.php index 9bbe4ab549..756935a47d 100644 --- a/app/registrations/resources/classes/registrations.php +++ b/app/registrations/resources/classes/registrations.php @@ -32,51 +32,54 @@ const app_name = 'registrations'; const app_uuid = '5d9e7cd7-629e-3553-4cf5-f26e39fefa39'; - /** - * declare private variables - */ - private $permission_prefix; - private $list_page; - public $show; - private $domain_name; - /** * Set in the constructor. Must be a database object and cannot be null. * @var database Database Object */ private $database; + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_name; + /** * Set in the constructor. Must be an event_socket object and cannot be null. * @var event_socket Event Socket Connection Object */ private $event_socket; + /** + * declare private variables + */ + private $permission_prefix; + private $list_page; + public $show; + /** * called when the object is created */ - public function __construct($setting_array = []) { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; - //open a database connection - if (empty($setting_array['database'])) { - $this->database = database::new(); - } - else { - $this->database = $setting_array['database']; - } - - //trap passing a PDO object instead of the required database object - if (!($this->database instanceof database)) { - //should never happen but will trap it here just in case - throw new \InvalidArgumentException("Database object passed in the constructor is not a valid database object"); - } - - if (!empty($setting_array['event_socket'])) { - $this->event_socket = $setting_array['event_socket']; - } - else { - $this->event_socket = event_socket::create(); - } + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->event_socket = $setting_array['event_socket'] ?? event_socket::create(); //trap passing an invalid connection object for communicating to the switch if (!($this->event_socket instanceof event_socket)) { @@ -88,15 +91,6 @@ $this->permission_prefix = 'registration_'; $this->list_page = 'registrations.php'; $this->show = 'local'; - - //get the domain_name - if (empty($setting_array['domain_name'])) { - $this->domain_name = $_SESSION['domain_name']; - } - else { - $this->domain_name = $setting_array['domain_name']; - } - } /** diff --git a/app/registrations/resources/dashboard/registrations.php b/app/registrations/resources/dashboard/registrations.php index 5742e7749e..c91e27be7a 100644 --- a/app/registrations/resources/dashboard/registrations.php +++ b/app/registrations/resources/dashboard/registrations.php @@ -9,7 +9,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], dirname($widget_url)); + $text = $language->get($settings->get('domain', 'language', 'en-us'), dirname($widget_url)); //get the dashboard label $widget_label = $text['title-'.$widget_key] ?? $widget_name; @@ -25,6 +25,7 @@ $esl = event_socket::create(); //registration count + $active_registrations = 0; if ($esl->is_connected() && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/registrations/")) { $registration = new registrations; if (permission_exists("registration_all")) { diff --git a/app/ring_groups/resources/classes/ring_groups.php b/app/ring_groups/resources/classes/ring_groups.php index 97008cfde9..3ad6b4a127 100644 --- a/app/ring_groups/resources/classes/ring_groups.php +++ b/app/ring_groups/resources/classes/ring_groups.php @@ -34,9 +34,38 @@ const app_uuid = '1d61fb65-1eec-bc73-a6ee-a6203b4fe6f2'; /** - * declare private variables + * Ring group primary key + * @var uuid + */ + public $ring_group_uuid; + + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object */ private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + + /** + * declare private variables + */ private $permission_prefix; private $list_page; private $table; @@ -44,15 +73,16 @@ private $toggle_field; private $toggle_values; - /** - * declare public variables - */ - public $ring_group_uuid; - /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); //assign private variables $this->permission_prefix = 'ring_group_'; @@ -61,12 +91,6 @@ $this->uuid_prefix = 'ring_group_'; $this->toggle_field = 'ring_group_enabled'; $this->toggle_values = ['true','false']; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } - } /** @@ -102,7 +126,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, dialplan_uuid, ring_group_context from v_".$this->table." "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -117,11 +141,11 @@ $x = 0; foreach ($ring_groups as $ring_group_uuid => $ring_group) { $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $ring_group_uuid; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; $array['ring_group_users'][$x][$this->uuid_prefix.'uuid'] = $ring_group_uuid; - $array['ring_group_users'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['ring_group_users'][$x]['domain_uuid'] = $this->domain_uuid; $array['ring_group_destinations'][$x][$this->uuid_prefix.'uuid'] = $ring_group_uuid; - $array['ring_group_destinations'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['ring_group_destinations'][$x]['domain_uuid'] = $this->domain_uuid; $array['dialplans'][$x]['dialplan_uuid'] = $ring_group['dialplan_uuid']; $array['dialplan_details'][$x]['dialplan_uuid'] = $ring_group['dialplan_uuid']; $x++; @@ -208,7 +232,7 @@ $sql = "select ring_group_context from v_ring_groups "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and ring_group_uuid = :ring_group_uuid "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $parameters['ring_group_uuid'] = $this->ring_group_uuid; $ring_group_context = $this->database->select($sql, $parameters, 'column'); unset($sql, $parameters); @@ -219,7 +243,7 @@ $x = 0; foreach ($uuids as $uuid) { $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $uuid; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; $x++; } } @@ -277,7 +301,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, dialplan_uuid, ring_group_context from v_".$this->table." "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -375,7 +399,7 @@ $sql = "select * from v_".$this->table." "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { $y = $z = 0; diff --git a/app/ring_groups/resources/dashboard/ring_group_forward.php b/app/ring_groups/resources/dashboard/ring_group_forward.php index f11947571a..9aba8cc16a 100644 --- a/app/ring_groups/resources/dashboard/ring_group_forward.php +++ b/app/ring_groups/resources/dashboard/ring_group_forward.php @@ -30,7 +30,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'app/ring_groups'); + $text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/ring_groups'); //get the list if (permission_exists('ring_group_add') || permission_exists('ring_group_edit')) { diff --git a/app/ring_groups/ring_group_edit.php b/app/ring_groups/ring_group_edit.php index 489c671e9e..035725f065 100644 --- a/app/ring_groups/ring_group_edit.php +++ b/app/ring_groups/ring_group_edit.php @@ -588,10 +588,11 @@ //set the defaults $destination_delay_max = $settings->get('ring_group', 'destination_delay_max', ''); $destination_timeout_max = $settings->get('ring_group', 'destination_timeout_max', ''); - if (empty($ring_group_call_timeout)) { $ring_group_call_timeout = '30'; } - if ($ring_group_call_screen_enabled === null) { $ring_group_call_screen_enabled = false; } - if ($ring_group_call_forward_enabled === null) { $ring_group_call_forward_enabled = false; } - if ($ring_group_follow_me_enabled === null) { $ring_group_follow_me_enabled = false; } + $ring_group_call_timeout = $ring_group_call_timeout ?? '30'; + $ring_group_greeting = $ring_group_greeting ?? ''; + $ring_group_call_screen_enabled = $ring_group_call_screen_enabled ?? false; + $ring_group_call_forward_enabled = $ring_group_call_forward_enabled ?? false; + $ring_group_follow_me_enabled = $ring_group_follow_me_enabled ?? false; //get the ring group destination array if ($action == "add") { diff --git a/app/ring_groups/ring_groups.php b/app/ring_groups/ring_groups.php index 19c39e082f..22b935dbcc 100644 --- a/app/ring_groups/ring_groups.php +++ b/app/ring_groups/ring_groups.php @@ -183,10 +183,10 @@ echo "
\n"; echo "
".$text['title-ring_groups']."
".number_format($num_rows)."
\n"; echo "
\n"; - if (permission_exists('ring_group_add') && (!isset($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) { + if (permission_exists('ring_group_add') && (empty($settings->get('limit', 'ring_groups', 0)) || ($total_ring_groups < $settings->get('limit', 'ring_groups')))) { echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','link'=>'ring_group_edit.php']); } - if (permission_exists('ring_group_add') && $ring_groups && (!isset($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) { + if (permission_exists('ring_group_add') && $ring_groups && (empty($settings->get('limit', 'ring_groups', 0)) || ($total_ring_groups < $settings->get('limit', 'ring_groups')))) { echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$settings->get('theme', 'button_icon_copy'),'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]); } if (permission_exists('ring_group_edit') && $ring_groups) { @@ -215,7 +215,7 @@ echo "
\n"; echo "
\n"; - if (permission_exists('ring_group_add') && $ring_groups && (!isset($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) { + if (permission_exists('ring_group_add') && $ring_groups && (empty($settings->get('limit', 'ring_groups', 0)) || ($total_ring_groups < $settings->get('limit', 'ring_groups')))) { echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]); } if (permission_exists('ring_group_edit') && $ring_groups) { diff --git a/app/ring_groups/waveform.php b/app/ring_groups/waveform.php index 8b760cd949..e65e25191c 100644 --- a/app/ring_groups/waveform.php +++ b/app/ring_groups/waveform.php @@ -46,20 +46,20 @@ if ($_GET['type'] == 'recordings') { $slash = substr($_GET['data'],0,1) != '/' ? '/' : null; - $full_file_path = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].$slash.str_replace($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'], '', $_GET['data']); + $full_file_path = $settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].$slash.str_replace($settings->get('switch', 'recordings')."/".$_SESSION['domain_name'], '', $_GET['data']); } else if ($_GET['type'] == 'sounds') { //get first installed language (like en/us/callie) - $language_paths = glob($_SESSION["switch"]['sounds']['dir']."/*/*/*"); + $language_paths = glob($settings->get('switch', 'sounds')."/*/*/*"); foreach ($language_paths as $key => $path) { - $path = str_replace($_SESSION["switch"]['sounds']['dir'].'/', "", $path); + $path = str_replace($settings->get('switch', 'sounds').'/', "", $path); $path_array = explode('/', $path); if (count($path_array) <> 3 || strlen($path_array[0]) <> 2 || strlen($path_array[1]) <> 2) { unset($language_paths[$key]); } - $language_paths[$key] = str_replace($_SESSION["switch"]['sounds']['dir']."/","",$language_paths[$key] ?? ''); + $language_paths[$key] = str_replace($settings->get('switch', 'sounds')."/","",$language_paths[$key] ?? ''); if (empty($language_paths[$key])) { unset($language_paths[$key]); } @@ -69,7 +69,7 @@ //determine the path for sound file $filename_parts = explode('/', str_replace('..', '', $_GET['data'])); if (!is_array($filename_parts) || @sizeof($filename_parts) != 2) { exit; } - $path = $_SESSION['switch']['sounds']['dir'].'/'.$language_path.'/'.$filename_parts[0].'/8000/'; + $path = $settings->get('switch', 'sounds').'/'.$language_path.'/'.$filename_parts[0].'/8000/'; //build full path to sound file $full_file_path = $path.$filename_parts[1]; @@ -91,13 +91,13 @@ $waveform = new Waveform($full_file_path); Waveform::$linesPerPixel = 1; // default: 8 Waveform::$samplesPerLine = 512; // default: 512 - Waveform::$colorA = !empty($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color - Waveform::$colorB = !empty($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color - Waveform::$backgroundColor = !empty($_SESSION['theme']['audio_player_waveform_color_background']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_background']['text']) : [0,0,0,0]; // array rgba, default: transparent - Waveform::$axisColor = !empty($_SESSION['theme']['audio_player_waveform_color_axis']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_axis']['text']) : [0,0,0,0.3]; // array rgba - Waveform::$singlePhase = filter_var($_SESSION['theme']['audio_player_waveform_single_phase']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom - Waveform::$singleAxis = filter_var($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis - $height = !empty($_SESSION['theme']['audio_player_waveform_height']['text']) && is_numeric(str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text'])) ? 2.2 * (int) str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text']) : null; + Waveform::$colorA = !empty($settings->get('theme', 'audio_player_waveform_color_a_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_a_leg')) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color + Waveform::$colorB = !empty($settings->get('theme', 'audio_player_waveform_color_b_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_b_leg')) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color + Waveform::$backgroundColor = !empty($settings->get('theme', 'audio_player_waveform_color_background')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_background')) : [0,0,0,0]; // array rgba, default: transparent + Waveform::$axisColor = !empty($settings->get('theme', 'audio_player_waveform_color_axis')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_axis')) : [0,0,0,0.3]; // array rgba + Waveform::$singlePhase = filter_var($settings->get('theme', 'audio_player_waveform_single_phase') ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom + Waveform::$singleAxis = filter_var($settings->get('theme', 'audio_player_waveform_single_axis') ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis + $height = !empty($settings->get('theme', 'audio_player_waveform_height')) && is_numeric(str_replace('px','',$settings->get('theme', 'audio_player_waveform_height'))) ? 2.2 * (int) str_replace('px','',$settings->get('theme', 'audio_player_waveform_height')) : null; $wf = $waveform->getWaveform($temp_filename, 1600, $height ?? 180); // input: png filename returns boolean true/false, or 'base64' returns base64 string } diff --git a/app/sip_profiles/resources/classes/sip_profiles.php b/app/sip_profiles/resources/classes/sip_profiles.php index c3439cd3ae..6357fbb780 100644 --- a/app/sip_profiles/resources/classes/sip_profiles.php +++ b/app/sip_profiles/resources/classes/sip_profiles.php @@ -34,9 +34,32 @@ const app_uuid = 'a6a7c4c5-340a-43ce-bcbc-2ed9bab8659d'; /** - * declare private variables + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object */ private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + + /** + * declare private variables + */ private $permission_prefix; private $list_page; private $table; @@ -52,7 +75,14 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); //assign private variables $this->permission_prefix = 'sip_profile_'; @@ -61,12 +91,6 @@ $this->uuid_prefix = 'sip_profile_'; $this->toggle_field = 'sip_profile_enabled'; $this->toggle_values = ['true','false']; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } - } /** @@ -135,9 +159,10 @@ $p->delete('sip_profile_setting_delete', 'temp'); //delete the xml sip profile and directory + $switch_conf_dir = $this->settings->get('switch', 'conf'); foreach ($sip_profiles as $sip_profile_uuid => $sip_profile) { - @unlink($_SESSION['switch']['conf']['dir']."/sip_profiles/".$sip_profile['name'].".xml"); - @unlink($_SESSION['switch']['conf']['dir']."/sip_profiles/".$sip_profile['name']); + @unlink($switch_conf_dir."/sip_profiles/".$sip_profile['name'].".xml"); + @unlink($switch_conf_dir."/sip_profiles/".$sip_profile['name']); } //save the sip profile xml diff --git a/app/sip_profiles/sip_profile_edit.php b/app/sip_profiles/sip_profile_edit.php index 3912881541..9d5de6d718 100644 --- a/app/sip_profiles/sip_profile_edit.php +++ b/app/sip_profiles/sip_profile_edit.php @@ -171,7 +171,7 @@ else { $sip_profile_domain_uuid = uuid(); } - if (!empty($row["sip_profile_domain_alias"])) { + if (!empty($row["sip_profile_domain_name"])) { $array['sip_profiles'][0]['sip_profile_domains'][$y]["sip_profile_uuid"] = $sip_profile_uuid; $array['sip_profiles'][0]['sip_profile_domains'][$y]["sip_profile_domain_uuid"] = $sip_profile_domain_uuid; $array['sip_profiles'][0]['sip_profile_domains'][$y]["sip_profile_domain_name"] = $row["sip_profile_domain_name"]; diff --git a/app/sip_profiles/sip_profiles.php b/app/sip_profiles/sip_profiles.php index 56c90a7868..e21d63b9b4 100644 --- a/app/sip_profiles/sip_profiles.php +++ b/app/sip_profiles/sip_profiles.php @@ -102,7 +102,7 @@ $num_rows = $database->select($sql, $parameters ?? null, 'column'); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = $search ? "&search=".$search : null; $page = !empty($_GET['page']) ? $_GET['page'] : 0; list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); @@ -189,9 +189,6 @@ $list_row_url = ''; if (permission_exists('sip_profile_edit')) { $list_row_url = "sip_profile_edit.php?id=".urlencode($row['sip_profile_uuid']); - if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { - $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true'; - } } echo "\n"; if (permission_exists('sip_profile_add') || permission_exists('sip_profile_edit') || permission_exists('sip_profile_delete')) { @@ -241,4 +238,3 @@ require_once "resources/footer.php"; ?> - diff --git a/app/sip_status/sip_status.php b/app/sip_status/sip_status.php index 8e1f065d32..97a3d2e626 100644 --- a/app/sip_status/sip_status.php +++ b/app/sip_status/sip_status.php @@ -172,7 +172,7 @@ foreach ($xml->profile as $row) { unset($list_row_url); $profile_name = (string) $row->name; - $list_row_url = is_uuid($sip_profiles[$profile_name]) && permission_exists('sip_profile_edit') ? PROJECT_PATH."/app/sip_profiles/sip_profile_edit.php?id=".$sip_profiles[$profile_name] : null; + $list_row_url = is_uuid($sip_profiles[$profile_name] ?? '') && permission_exists('sip_profile_edit') ? PROJECT_PATH."/app/sip_profiles/sip_profile_edit.php?id=".$sip_profiles[$profile_name] : null; echo "\n"; echo " "; if ($list_row_url) { diff --git a/app/sofia_global_settings/resources/classes/sofia_global_settings.php b/app/sofia_global_settings/resources/classes/sofia_global_settings.php index ae18c4f790..5e5b62743d 100644 --- a/app/sofia_global_settings/resources/classes/sofia_global_settings.php +++ b/app/sofia_global_settings/resources/classes/sofia_global_settings.php @@ -39,6 +39,7 @@ * declare the variables */ private $database; + private $name; private $table; private $toggle_field; @@ -46,10 +47,13 @@ private $description_field; private $location; - /** + /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set objects + $this->database = $setting_array['database'] ?? database::new(); + //assign the variables $this->name = 'sofia_global_setting'; $this->table = 'sofia_global_settings'; @@ -57,11 +61,6 @@ $this->toggle_values = ['true','false']; $this->description_field = 'global_setting_description'; $this->location = 'sofia_global_settings.php'; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } } /** diff --git a/app/sofia_global_settings/sofia_global_settings.php b/app/sofia_global_settings/sofia_global_settings.php index 2e864c2ee6..be4088deaa 100644 --- a/app/sofia_global_settings/sofia_global_settings.php +++ b/app/sofia_global_settings/sofia_global_settings.php @@ -210,7 +210,7 @@ $list_row_url = ''; if (permission_exists('sofia_global_setting_edit')) { $list_row_url = "sofia_global_setting_edit.php?id=".urlencode($row['sofia_global_setting_uuid']); - if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { + if (!empty($row['domain_uuid']) && $row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true'; } } diff --git a/app/streams/resources/classes/streams.php b/app/streams/resources/classes/streams.php index 09c11581de..cdabef3be0 100644 --- a/app/streams/resources/classes/streams.php +++ b/app/streams/resources/classes/streams.php @@ -33,11 +33,45 @@ const app_name = 'streams'; const app_uuid = 'ffde6287-aa18-41fc-9a38-076d292e0a38'; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Username set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $username; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_name; + /** * declare private variables */ - - private $database; private $permission_prefix; private $list_page; private $table; @@ -48,7 +82,12 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); //assign private variables $this->permission_prefix = 'stream_'; @@ -57,12 +96,6 @@ $this->uuid_prefix = 'stream_'; $this->toggle_field = 'stream_enabled'; $this->toggle_values = ['true','false']; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } - } /** @@ -139,7 +172,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -207,7 +240,7 @@ $sql = "select * from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $x => $row) { diff --git a/app/streams/streams.php b/app/streams/streams.php index 795324c728..813c25bd46 100644 --- a/app/streams/streams.php +++ b/app/streams/streams.php @@ -115,7 +115,7 @@ unset($parameters); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = "&search=".$search; $param = ($show == 'all' && permission_exists('stream_all')) ? "&show=all" : null; $page = isset($_GET['page']) ? $_GET['page'] : 0; @@ -252,7 +252,7 @@ $list_row_url = ''; if (permission_exists('stream_edit')) { $list_row_url = "stream_edit.php?id=".urlencode($row['stream_uuid']); - if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { + if (!empty($row['domain_uuid']) && $row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true'; } } diff --git a/app/switch/resources/classes/presence.php b/app/switch/resources/classes/presence.php index c645f8eac4..ad0ac4cbbb 100644 --- a/app/switch/resources/classes/presence.php +++ b/app/switch/resources/classes/presence.php @@ -57,6 +57,7 @@ * show presence */ public function show() { + $array = []; $json = event_socket::api('show calls as json'); $call_array = json_decode($json, true); if (isset($call_array['rows'])) { diff --git a/app/switch/resources/classes/ringbacks.php b/app/switch/resources/classes/ringbacks.php index 6b6343268a..684ae10eb7 100644 --- a/app/switch/resources/classes/ringbacks.php +++ b/app/switch/resources/classes/ringbacks.php @@ -34,11 +34,46 @@ const app_uuid = 'b63db353-e1c6-4401-8f10-101a6ee73b74'; /** - * declare public variables + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string */ public $domain_uuid; + + /** + * declare public variables + */ public $ringtones_list; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Username set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $username; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_name; + /** * declare private variables */ @@ -51,14 +86,15 @@ /** * called when the object is created */ - public function __construct() { - //set the domain_uuid - $this->domain_uuid = $_SESSION['domain_uuid']; + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + $this->username = $setting_array['username'] ?? $_SESSION['username'] ?? ''; - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } + //set objects + $this->database = $setting_array['database'] ?? database::new(); //add multi-lingual support $language = new text; @@ -142,7 +178,7 @@ foreach($this->music_list as $row) { $name = ''; if (!empty($row['domain_uuid'])) { - $name = $row['domain_name'].'/'; + $name = $row['domain_name'].'/'; } $name .= $row['music_on_hold_name']; if ($value == "local_stream://".$name) { @@ -182,7 +218,7 @@ if ($previous_name != $row['music_on_hold_name']) { $name = ''; if (!empty($row['domain_uuid'])) { - $name = $row['domain_name'].'/'; + $name = $row['domain_name'].'/'; } $name .= $row['music_on_hold_name']; $select .= " \n"; diff --git a/app/switch/resources/classes/switch_files.php b/app/switch/resources/classes/switch_files.php index c98091a624..ae8416a3a5 100644 --- a/app/switch/resources/classes/switch_files.php +++ b/app/switch/resources/classes/switch_files.php @@ -29,11 +29,14 @@ */ class switch_files { - /** + private $config; + + /** * Called when the object is created */ - public function __construct() { - + public function __construct(array $setting_array = []) { + //set objects + $this->config = $setting_array['config'] ?? config::load(); } /** @@ -55,9 +58,6 @@ */ public function copy_scripts() { - //include files - require dirname(__DIR__, 4) . "/resources/require.php"; - //get the source directory if (file_exists('/usr/share/examples/fusionpbx/scripts')) { $source_directory = '/usr/share/examples/fusionpbx/scripts'; @@ -73,8 +73,8 @@ } //get the destination directory - if (file_exists($conf['switch.scripts.dir'])) { - $destination_directory = $conf['switch.scripts.dir']; + if (file_exists($this->config->get('switch.scripts.dir'))) { + $destination_directory = $this->config->get('switch.scripts.dir'); } elseif (file_exists('/etc/freeswitch/scripts')) { $destination_directory = '/etc/freeswitch/scripts'; @@ -110,9 +110,6 @@ */ public function copy_languages() { - //include files - require dirname(__DIR__, 4) . "/resources/require.php"; - //get the source directory if (file_exists('/usr/share/examples/freeswitch/conf/languages')) { $source_directory = '/usr/share/examples/fusionpbx/conf/languages'; @@ -128,8 +125,8 @@ } //get the destination directory - if (file_exists($conf['switch.scripts.dir'])) { - $destination_directory = $conf['switch.conf.dir'].'/languages'; + if (file_exists($this->config->get('switch.conf.dir').'/languages')) { + $destination_directory = $this->config->get('switch.conf.dir').'/languages'; } elseif (file_exists('/etc/freeswitch/languages')) { $destination_directory = '/usr/local/share/freeswitch/languages'; diff --git a/app/switch/resources/dashboard/switch_status.php b/app/switch/resources/dashboard/switch_status.php index a18b5ab5cc..6a0e7628a9 100644 --- a/app/switch/resources/dashboard/switch_status.php +++ b/app/switch/resources/dashboard/switch_status.php @@ -15,7 +15,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'app/switch'); + $text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/switch'); //switch status echo "
\n"; diff --git a/app/switch/sounds.php b/app/switch/sounds.php index a054c901f3..c3f27ae3bd 100644 --- a/app/switch/sounds.php +++ b/app/switch/sounds.php @@ -47,14 +47,14 @@ if ($action == "download") { //get first installed language (like en/us/callie) - $language_paths = glob($_SESSION["switch"]['sounds']['dir']."/*/*/*"); + $language_paths = glob($settings->get('switch', 'sounds')."/*/*/*"); foreach ($language_paths as $key => $path) { - $path = str_replace($_SESSION["switch"]['sounds']['dir'].'/', "", $path); + $path = str_replace($settings->get('switch', 'sounds').'/', "", $path); $path_array = explode('/', $path); if (count($path_array) <> 3 || strlen($path_array[0]) <> 2 || strlen($path_array[1]) <> 2) { unset($language_paths[$key]); } - $language_paths[$key] = str_replace($_SESSION["switch"]['sounds']['dir']."/","",$language_paths[$key] ?? ''); + $language_paths[$key] = str_replace($settings->get('switch', 'sounds')."/","",$language_paths[$key] ?? ''); if (empty($language_paths[$key])) { unset($language_paths[$key]); } @@ -64,7 +64,7 @@ //determine the path for sound file $filename_parts = explode('/', str_replace('..', '', $_GET['filename'])); if (!is_array($filename_parts) || @sizeof($filename_parts) != 2) { exit; } - $path = $_SESSION['switch']['sounds']['dir'].'/'.$language_path.'/'.$filename_parts[0].'/8000/'; + $path = $settings->get('switch', 'sounds').'/'.$language_path.'/'.$filename_parts[0].'/8000/'; //set sound filename $sound_filename = $filename_parts[1]; diff --git a/app/system/resources/dashboard/system_counts.php b/app/system/resources/dashboard/system_counts.php index 2caf130121..527bc3f5f8 100644 --- a/app/system/resources/dashboard/system_counts.php +++ b/app/system/resources/dashboard/system_counts.php @@ -15,7 +15,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings'); + $text = $language->get($settings->get('domain', 'language', 'en-us'), 'core/user_settings'); //system counts //domains diff --git a/app/system/resources/dashboard/system_cpu_status.php b/app/system/resources/dashboard/system_cpu_status.php index 36a0d59bae..3da68be77d 100644 --- a/app/system/resources/dashboard/system_cpu_status.php +++ b/app/system/resources/dashboard/system_cpu_status.php @@ -15,7 +15,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'app/system'); + $text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/system'); //system cpu status echo "
\n"; diff --git a/app/system/resources/dashboard/system_disk_usage.php b/app/system/resources/dashboard/system_disk_usage.php index 9b72700998..90fffdd3b3 100644 --- a/app/system/resources/dashboard/system_disk_usage.php +++ b/app/system/resources/dashboard/system_disk_usage.php @@ -15,7 +15,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings'); + $text = $language->get($settings->get('domain', 'language', 'en-us'), 'core/user_settings'); //system status echo "
\n"; diff --git a/app/system/resources/dashboard/system_network_status.php b/app/system/resources/dashboard/system_network_status.php index 999f0a3aa6..6deab09644 100644 --- a/app/system/resources/dashboard/system_network_status.php +++ b/app/system/resources/dashboard/system_network_status.php @@ -14,7 +14,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'app/system'); + $text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/system'); //set the row style class names $c = 0; diff --git a/app/system/resources/dashboard/system_status.php b/app/system/resources/dashboard/system_status.php index de7aa06ff0..26d182692b 100644 --- a/app/system/resources/dashboard/system_status.php +++ b/app/system/resources/dashboard/system_status.php @@ -15,7 +15,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings'); + $text = $language->get($settings->get('domain', 'language', 'en-us'), 'core/user_settings'); //system status echo "
\n"; @@ -222,7 +222,7 @@ //pbx version echo "\n"; - echo "".(isset($_SESSION['theme']['title']['text'])?$_SESSION['theme']['title']['text']:'FusionPBX')."\n"; + echo "".$settings->get('theme', 'title', 'FusionPBX')."\n"; echo "".software::version()."\n"; echo "\n"; $c = ($c) ? 0 : 1; diff --git a/app/system/system.php b/app/system/system.php index f78e45c0c8..fb34ddd0ff 100644 --- a/app/system/system.php +++ b/app/system/system.php @@ -47,11 +47,11 @@ Con Portions created by the Initial Developer are Copyright (C) 2008-2025 //load editor preferences/defaults if (permission_exists("system_view_support")) { - $setting_size = !empty($_SESSION["editor"]["font_size"]["text"]) ? $_SESSION["editor"]["font_size"]["text"] : '12px'; - $setting_theme = !empty($_SESSION["editor"]["theme"]["text"]) ? $_SESSION["editor"]["theme"]["text"] : 'cobalt'; - $setting_invisibles = isset($_SESSION['editor']['invisibles']['text']) ? $_SESSION['editor']['invisibles']["text"] : 'false'; - $setting_indenting = isset($_SESSION['editor']['indent_guides']['text']) ? $_SESSION['editor']['indent_guides']["text"]: 'false'; - $setting_numbering = isset($_SESSION['editor']['line_numbers']['text']) ? $_SESSION['editor']['line_numbers']["text"] : 'true'; + $setting_size = !empty($settings->get('editor', 'font_size')) ? $settings->get('editor', 'font_size') : '12px'; + $setting_theme = !empty($settings->get('editor', 'theme')) ? $settings->get('editor', 'theme') : 'cobalt'; + $setting_invisibles = $settings->get('editor', 'invisibles', 'false'); + $setting_indenting = $settings->get('editor', 'indent_guides', 'false'); + $setting_numbering = $settings->get('editor', 'line_numbers', 'true'); } //additional includes diff --git a/app/time_conditions/resources/classes/time_conditions.php b/app/time_conditions/resources/classes/time_conditions.php index e6c83d5404..c6038bc29c 100644 --- a/app/time_conditions/resources/classes/time_conditions.php +++ b/app/time_conditions/resources/classes/time_conditions.php @@ -33,12 +33,45 @@ const app_name = 'time_conditions'; const app_uuid = '4b821450-926b-175a-af93-a03c441818b1'; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Username set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $username; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_name; + /** * declare public/private properties */ - private $app_name; - private $app_uuid; - private $database; private $permission_prefix; private $list_page; private $table; @@ -46,8 +79,13 @@ private $toggle_field; private $toggle_values; - //class constructor - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + //set the default value $this->dialplan_global = false; @@ -58,11 +96,6 @@ $this->uuid_prefix = 'dialplan_'; $this->toggle_field = 'dialplan_enabled'; $this->toggle_values = ['true','false']; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } } /** @@ -174,7 +207,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, dialplan_context from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { diff --git a/app/time_conditions/time_condition_edit.php b/app/time_conditions/time_condition_edit.php index 4ae778df09..e19d2f9e97 100644 --- a/app/time_conditions/time_condition_edit.php +++ b/app/time_conditions/time_condition_edit.php @@ -45,7 +45,7 @@ $destination = new destinations; //load available presets - $preset_region = "preset_".$_SESSION['time_conditions']['region']['text']; + $preset_region = "preset_".$settings->get('time_conditions', 'region'); if (is_array($_SESSION['time_conditions'][$preset_region])) { foreach ($_SESSION['time_conditions'][$preset_region] as $json) { $json_array = json_decode($json, true); @@ -809,7 +809,7 @@ case 'hour': //hours of day get('domain', 'time_format') == "24h") { for ($h = 0; $h <= 23; $h++) { echo "sel_start.options[sel_start.options.length] = new Option(".$h.", ".$h.");\n"; @@ -828,7 +828,7 @@ case 'time-of-day': //time of day get('domain', 'time_format') == "24h") { for ($h = 0; $h <= 23; $h++) { for ($m = 0; $m <= 59; $m++) { @@ -986,7 +986,7 @@ echo "\n"; echo " ".$text['label-extension']."\n"; echo "\n"; echo "\n"; -echo " \n"; +echo " get('time_conditions', 'extension_range') ?? '')."\">\n"; echo "
\n"; echo " ".$text['description-extension']."
\n"; echo "\n"; diff --git a/app/vars/resources/classes/vars.php b/app/vars/resources/classes/vars.php index a5292e7255..3456c6814e 100644 --- a/app/vars/resources/classes/vars.php +++ b/app/vars/resources/classes/vars.php @@ -48,7 +48,9 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set objects + $this->database = $setting_array['database'] ?? database::new(); //assign private variables $this->permission_prefix = 'var_'; @@ -57,11 +59,6 @@ $this->uuid_prefix = 'var_'; $this->toggle_field = 'var_enabled'; $this->toggle_values = ['true','false']; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } } /** diff --git a/app/vars/vars.php b/app/vars/vars.php index 297b358914..e7506894a4 100644 --- a/app/vars/vars.php +++ b/app/vars/vars.php @@ -222,20 +222,18 @@ $previous_category = ''; foreach ($vars as $x => $row) { //write category and column headings - if ($previous_category != $row["var_category"]) { - echo "\n"; - echo "\n"; - echo ($previous_category != '' ? '
' : null)."".$row["var_category"].""; - echo "\n"; - echo "\n"; - write_header($row["var_category"]); - } + if ($previous_category != $row["var_category"]) { + echo "\n"; + echo "\n"; + echo ($previous_category != '' ? '
' : null)."".$row["var_category"].""; + echo "\n"; + echo "\n"; + write_header($row["var_category"]); + } + $list_row_url = ''; if (permission_exists('var_edit')) { $list_row_url = "var_edit.php?id=".urlencode($row['var_uuid']); - if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { - $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true'; - } } echo "\n"; if (permission_exists('var_add') || permission_exists('var_edit') || permission_exists('var_delete')) { @@ -292,4 +290,4 @@ //include the footer require_once "resources/footer.php"; -?> \ No newline at end of file +?> diff --git a/app/voicemail_greetings/resources/classes/voicemail_greetings.php b/app/voicemail_greetings/resources/classes/voicemail_greetings.php index 58d507e94b..e15991e8cc 100644 --- a/app/voicemail_greetings/resources/classes/voicemail_greetings.php +++ b/app/voicemail_greetings/resources/classes/voicemail_greetings.php @@ -33,11 +33,39 @@ const app_name = 'voicemail_greetings'; const app_uuid = 'e4b4fbee-9e4d-8e46-3810-91ba663db0c2'; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $user_uuid; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_name; + /** * declare private variables */ - - private $database; private $permission_prefix; private $list_page; private $table; @@ -51,7 +79,15 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); //assign private variables $this->permission_prefix = 'voicemail_greeting_'; @@ -63,12 +99,6 @@ } $this->table = 'voicemail_greetings'; $this->uuid_prefix = 'voicemail_greeting_'; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } - } /** @@ -120,7 +150,7 @@ } //set the greeting directory - $greeting_directory = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'].'/'.$this->voicemail_id; + $greeting_directory = $this->settings->get('switch', 'storage').'/voicemail/default/'.$this->domain_name.'/'.$this->voicemail_id; //loop through greetings if (is_array($greeting_filenames) && @sizeof($greeting_filenames) != 0) { @@ -130,7 +160,7 @@ @unlink($greeting_directory.'/'.$greeting_filename); //build the delete array $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $voicemail_greeting_uuid; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; $x++; } } @@ -143,7 +173,7 @@ $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and voicemail_id = :voicemail_id "; $sql .= "and greeting_id = :greeting_id "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $parameters['voicemail_id'] = $voicemail_id; $parameters['greeting_id'] = $greeting_id; $this->database->execute($sql, $parameters); diff --git a/app/voicemail_greetings/voicemail_greetings.php b/app/voicemail_greetings/voicemail_greetings.php index 09d4a9768a..5fa2cbbb68 100644 --- a/app/voicemail_greetings/voicemail_greetings.php +++ b/app/voicemail_greetings/voicemail_greetings.php @@ -82,7 +82,7 @@ unset($sql, $parameters); //define greeting directory - $greeting_dir = $_SESSION['switch']['voicemail']['dir'].'/default/'.$_SESSION['domains'][$domain_uuid]['domain_name'].'/'.$voicemail_id; + $greeting_dir = $settings->get('switch', 'voicemail').'/default/'.$_SESSION['domains'][$domain_uuid]['domain_name'].'/'.$voicemail_id; //download the greeting if (!empty($_GET['a']) && $_GET['a'] == "download" && (permission_exists('voicemail_greeting_play') || permission_exists('voicemail_greeting_download'))) { @@ -102,7 +102,7 @@ if (is_array($row) && @sizeof($row) != 0) { $greeting_filename = $row['greeting_filename']; $greeting_id = $row['greeting_id']; - if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64' && $row['greeting_base64'] != '') { + if (!empty($settings->get('voicemail', 'storage_type')) && $settings->get('voicemail', 'storage_type') == 'base64' && $row['greeting_base64'] != '') { $greeting_decoded = base64_decode($row['greeting_base64']); file_put_contents($greeting_dir.'/'.$greeting_filename, $greeting_decoded); } @@ -142,7 +142,7 @@ } //if base64, remove temp greeting file (if not currently selected greeting) - if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64' && $row['greeting_base64'] != '') { + if (!empty($settings->get('voicemail', 'storage_type')) && $settings->get('voicemail', 'storage_type') == 'base64' && $row['greeting_base64'] != '') { if ($greeting_id != $selected_greeting_id) { @unlink($greeting_dir.'/'.$greeting_filename); } @@ -203,7 +203,7 @@ $array['voicemail_greetings'][$x]['greeting_name'] = $text['label-greeting'].' '.$greeting_id; $array['voicemail_greetings'][$x]['greeting_filename'] = $greeting_file_name; $array['voicemail_greetings'][$x]['greeting_description'] = ''; - if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64') { + if (!empty($settings->get('voicemail', 'storage_type')) && $settings->get('voicemail', 'storage_type') == 'base64') { $array['voicemail_greetings'][$x]['greeting_base64'] = base64_encode(file_get_contents($greeting_dir.'/'.$file_name)); } @@ -296,7 +296,7 @@ } //get the greetings list - if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64') { + if (!empty($settings->get('voicemail', 'storage_type')) && $settings->get('voicemail', 'storage_type') == 'base64') { switch ($db_type) { case 'pgsql': $sql_file_size = ", length(decode(greeting_base64,'base64')) as greeting_size "; break; case 'mysql': $sql_file_size = ", length(from_base64(greeting_base64)) as greeting_size "; break; @@ -393,7 +393,7 @@ $col_count++; echo th_order_by('greeting_name', $text['label-name'], $order_by, $order, null, null, "id=".urlencode($voicemail_id)); $col_count++; - if (empty($_SESSION['voicemail']['storage_type']['text']) || $_SESSION['voicemail']['storage_type']['text'] != 'base64') { + if (empty($settings->get('voicemail', 'storage_type')) || $settings->get('voicemail', 'storage_type') != 'base64') { echo th_order_by('greeting_filename', $text['label-filename'], $order_by, $order, null, "class='hide-sm-dn'", "id=".urlencode($voicemail_id)); $col_count++; } @@ -403,7 +403,7 @@ } echo "".$text['label-size']."\n"; $col_count++; - if (empty($_SESSION['voicemail']['storage_type']['text']) || $_SESSION['voicemail']['storage_type']['text'] != 'base64') { + if (empty($settings->get('voicemail', 'storage_type')) || $settings->get('voicemail', 'storage_type') != 'base64') { echo "".$text['label-uploaded']."\n"; $col_count++; } @@ -449,7 +449,7 @@ echo escape($row['greeting_name']); } echo " \n"; - if (empty($_SESSION['voicemail']['storage_type']['text']) || $_SESSION['voicemail']['storage_type']['text'] != 'base64') { + if (empty($settings->get('voicemail', 'storage_type')) || $settings->get('voicemail', 'storage_type') != 'base64') { echo " ".escape($row['greeting_filename'])."\n"; } if (permission_exists('voicemail_greeting_play') || permission_exists('voicemail_greeting_download')) { @@ -471,13 +471,19 @@ } echo " \n"; } - if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64') { + + if (!empty($settings->get('voicemail', 'storage_type')) && $settings->get('voicemail', 'storage_type') == 'base64') { $file_size = byte_convert($row['greeting_size']); echo " ".$file_size."\n"; } else { - $file_size = byte_convert(filesize($greeting_dir.'/'.$row['greeting_filename'])); - $file_date = date("M d, Y H:i:s", filemtime($greeting_dir.'/'.$row['greeting_filename'])); + if (file_exists($greeting_dir.'/'.$row['greeting_filename'])) { + $file_size = byte_convert(filesize($greeting_dir.'/'.$row['greeting_filename'])); + $file_date = date("M d, Y H:i:s", filemtime($greeting_dir.'/'.$row['greeting_filename'])); + } else { + $file_size = 0; + $file_date = ''; + } echo " ".$file_size."\n"; echo " ".$file_date."\n"; } diff --git a/app/voicemail_greetings/waveform.php b/app/voicemail_greetings/waveform.php index 6da66eb002..6fb95642c2 100644 --- a/app/voicemail_greetings/waveform.php +++ b/app/voicemail_greetings/waveform.php @@ -58,7 +58,7 @@ unset($sql, $parameters); //define greeting directory - $greeting_dir = $_SESSION['switch']['voicemail']['dir'].'/default/'.$_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'].'/'.$voicemail_id; + $greeting_dir = $settings->get('switch', 'voicemail').'/default/'.$_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'].'/'.$voicemail_id; //get voicemail greeting details from db $sql = "select greeting_filename, greeting_base64, greeting_id "; @@ -71,7 +71,7 @@ if (!empty($row) && is_array($row) && @sizeof($row) != 0) { $greeting_filename = $row['greeting_filename']; $greeting_id = $row['greeting_id']; - if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64' && !empty($row['greeting_base64'])) { + if (!empty($settings->get('voicemail', 'storage_type')) && $settings->get('voicemail', 'storage_type') == 'base64' && !empty($row['greeting_base64'])) { $greeting_decoded = base64_decode($row['greeting_base64']); file_put_contents($greeting_dir.'/'.$greeting_filename, $greeting_decoded); } @@ -96,13 +96,13 @@ $waveform = new Waveform($full_file_path); Waveform::$linesPerPixel = 1; // default: 8 Waveform::$samplesPerLine = 512; // default: 512 - Waveform::$colorA = !empty($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color - Waveform::$colorB = !empty($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color - Waveform::$backgroundColor = !empty($_SESSION['theme']['audio_player_waveform_color_background']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_background']['text']) : [0,0,0,0]; // array rgba, default: transparent - Waveform::$axisColor = !empty($_SESSION['theme']['audio_player_waveform_color_axis']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_axis']['text']) : [0,0,0,0.3]; // array rgba - Waveform::$singlePhase = filter_var($_SESSION['theme']['audio_player_waveform_single_phase']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom - Waveform::$singleAxis = filter_var($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis - $height = !empty($_SESSION['theme']['audio_player_waveform_height']['text']) && is_numeric(str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text'])) ? 2.2 * (int) str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text']) : null; + Waveform::$colorA = !empty($settings->get('theme', 'audio_player_waveform_color_a_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_a_leg')) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color + Waveform::$colorB = !empty($settings->get('theme', 'audio_player_waveform_color_b_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_b_leg')) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color + Waveform::$backgroundColor = !empty($settings->get('theme', 'audio_player_waveform_color_background')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_background')) : [0,0,0,0]; // array rgba, default: transparent + Waveform::$axisColor = !empty($settings->get('theme', 'audio_player_waveform_color_axis')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_axis')) : [0,0,0,0.3]; // array rgba + Waveform::$singlePhase = filter_var($settings->get('theme', 'audio_player_waveform_single_phase') ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom + Waveform::$singleAxis = filter_var($settings->get('theme', 'audio_player_waveform_single_axis') ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis + $height = !empty($settings->get('theme', 'audio_player_waveform_height')) && is_numeric(str_replace('px','',$settings->get('theme', 'audio_player_waveform_height'))) ? 2.2 * (int) str_replace('px','',$settings->get('theme', 'audio_player_waveform_height')) : null; $wf = $waveform->getWaveform($greeting_dir.'/'.$temp_filename, 1600, $height ?? 180); // input: png filename returns boolean true/false, or 'base64' returns base64 string } @@ -129,7 +129,7 @@ } //if base64, remove temp file - if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64' && !empty($row['greeting_base64'])) { + if (!empty($settings->get('voicemail', 'storage_type')) && $settings->get('voicemail', 'storage_type') == 'base64' && !empty($row['greeting_base64'])) { if ($greeting_id != $selected_greeting_id) { @unlink($greeting_dir.'/'.$greeting_filename); } diff --git a/app/voicemails/resources/classes/voicemail.php b/app/voicemails/resources/classes/voicemail.php index 2f85ad3534..4be6d99a87 100644 --- a/app/voicemails/resources/classes/voicemail.php +++ b/app/voicemails/resources/classes/voicemail.php @@ -34,29 +34,34 @@ const app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044'; /** - * declare public variables - */ + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ public $domain_uuid; + + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ public $domain_name; + + /** + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + public $user_uuid; + + /** + * declare additional public variables + */ public $voicemail_uuid; public $voicemail_id; public $voicemail_message_uuid; - public $user_uuid; public $order_by; public $order; public $offset; public $type; - /** - * declare private variables - */ - private $permission_prefix; - private $list_page; - private $table; - private $uuid_prefix; - private $toggle_field; - private $toggle_values; - /** * Internal array structure that is populated from the database * @var array Array of settings loaded from Default Settings @@ -69,36 +74,32 @@ */ private $database; - public function __construct(array $params = []) { + /** + * Username set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $username; - //set the domain_uuid if not provided - if (!empty($params['domain_uuid']) && is_uuid($params['domain_uuid'])) { - $this->domain_uuid = $params['domain_uuid']; - } else { - $this->domain_uuid = $_SESSION['domain_uuid'] ?? ''; - } + /** + * declare private variables + */ + private $permission_prefix; + private $list_page; + private $table; + private $uuid_prefix; + private $toggle_field; + private $toggle_values; - //set the user_uuid if not provided - if (!empty($params['user_uuid']) && is_uuid($params['user_uuid'])) { - $this->user_uuid = $params['user_uuid']; - } else { - $this->user_uuid = $_SESSION['user_uuid'] ?? ''; - } + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; + $this->username = $setting_array['username'] ?? $_SESSION['username'] ?? ''; - //database connection - if (empty($params['database'])) { - $this->database = database::new(); - } else { - $this->database = $params['database']; - } - - //assign the settings object - if (empty($params['settings'])) { - $this->settings = new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); - } - else { - $this->settings = $params['settings']; - } + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); //assign private variables $this->permission_prefix = 'voicemail_'; @@ -317,7 +318,7 @@ if (is_array($result)) { foreach ($result as $i => $row) { //set the greeting directory - $path = $this->settings->get('switch', 'voicemail', '/var/lib/freeswitch/storage').'/default/'.$_SESSION['domain_name'].'/'.$row['voicemail_id']; + $path = $this->settings->get('switch', 'voicemail', '/var/lib/freeswitch/storage').'/default/'.$this->domain_name.'/'.$row['voicemail_id']; if (file_exists($path.'/msg_'.$row['voicemail_message_uuid'].'.wav')) { $result[$i]['file_path'] = $path.'/msg_'.$row['voicemail_message_uuid'].'.wav'; } @@ -387,7 +388,7 @@ //delete voicemail message recording and greeting files if (is_numeric($voicemail_id)) { - $file_path = $_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$voicemail_id; + $file_path = $this->settings->get('switch', 'voicemail')."/default/".$this->domain_name."/".$voicemail_id; foreach (glob($file_path."/*.*") as $file_name) { @unlink($file_name); } @@ -658,7 +659,7 @@ $esl = event_socket::create(); if ($esl->is_connected()) { - $switch_cmd = "luarun app.lua voicemail mwi ".$this->voicemail_id."@".$_SESSION['domain_name']; + $switch_cmd = "luarun app.lua voicemail mwi ".$this->voicemail_id."@".$this->domain_name; $switch_result = event_socket::api($switch_cmd); } } @@ -678,7 +679,7 @@ } //delete the recording - $file_path = $_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$this->voicemail_id; + $file_path = $this->settings->get('switch', 'voicemail')."/default/".$this->domain_name."/".$this->voicemail_id; if (is_uuid($this->voicemail_message_uuid)) { foreach (glob($file_path."/intro_msg_".$this->voicemail_message_uuid.".*") as $file_name) { unlink($file_name); @@ -1032,7 +1033,7 @@ unset($sql, $parameters); //define voicemail message file path - $voicemail_message_path = $switch_voicemail.'/default/'.$_SESSION['domain_name'].'/'.$this->voicemail_id; + $voicemail_message_path = $switch_voicemail.'/default/'.$this->domain_name.'/'.$this->voicemail_id; //determine voicemail message file properties (decode if base64) if ( @@ -1143,9 +1144,7 @@ public function message_intro_download(string $domain_name = '') { //check domain name - if (empty($domain_name)) { - $domain_name = $_SESSION['domain_name'] ?? ''; - } + $domain_name = $this->domain_name; //check if for valid input if (!is_numeric($this->voicemail_id) @@ -1251,9 +1250,7 @@ public function message_download(string $domain_name = '') { //check domain name - if (empty($domain_name)) { - $domain_name = $_SESSION['domain_name'] ?? ''; - } + $domain_name = $this->domain_name ?? ''; //check if for valid input if (!is_numeric($this->voicemail_id) diff --git a/app/voicemails/resources/dashboard/voicemails.php b/app/voicemails/resources/dashboard/voicemails.php index 3a6140a152..65c4d76933 100644 --- a/app/voicemails/resources/dashboard/voicemails.php +++ b/app/voicemails/resources/dashboard/voicemails.php @@ -15,10 +15,10 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings'); + $text = $language->get($settings->get('domain', 'language', 'en-us'), 'core/user_settings'); //used for missed and recent calls - $theme_image_path = $_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/"; + $theme_image_path = $_SERVER["DOCUMENT_ROOT"]."/themes/".$settings->get('domain', 'template')."/images/"; //voicemail echo "
\n"; diff --git a/app/voicemails/voicemail_edit.php b/app/voicemails/voicemail_edit.php index 0d22b4e339..d339d2b499 100644 --- a/app/voicemails/voicemail_edit.php +++ b/app/voicemails/voicemail_edit.php @@ -417,7 +417,7 @@ if (!empty($voicemail_options)) { foreach ($voicemail_options as $x => $field) { $voicemail_option_param = $field['voicemail_option_param']; - if (empty(trim($voicemail_option_param))) { + if (empty(trim($voicemail_option_param ?? ''))) { $voicemail_option_param = $field['voicemail_option_action']; } $voicemail_option_param = str_replace("menu-", "", $voicemail_option_param); @@ -1014,4 +1014,4 @@ //include the footer require_once "resources/footer.php"; -?> \ No newline at end of file +?> diff --git a/app/voicemails/voicemail_messages.php b/app/voicemails/voicemail_messages.php index 4ee6e3bd40..24d6c30704 100644 --- a/app/voicemails/voicemail_messages.php +++ b/app/voicemails/voicemail_messages.php @@ -279,7 +279,7 @@ $total_rows = $num_rows; //prepare to page the results - $rows_per_page = $_SESSION['domain']['paging']['numeric'] != '' ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging') != '' ? $settings->get('domain', 'paging') : 50; $page = empty($_GET['page']) ? 0 : $_GET['page']; $param = 'id='.urlencode($_REQUEST['id']).'&back='.$_SESSION['back'][$_SERVER['PHP_SELF']]; list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); @@ -417,7 +417,7 @@ $col_count++; echo th_order_by('message_length', $text['label-message_length'], $order_by, $order, null, "class='hide-xs right pct-15'"); $col_count++; - if (empty($_SESSION['voicemail']['storage_type']['text']) || $_SESSION['voicemail']['storage_type']['text'] != 'base64') { + if (empty($settings->get('voicemail', 'storage_type')) || $settings->get('voicemail', 'storage_type') != 'base64') { echo "".$text['label-message_size']."\n"; $col_count++; } @@ -448,9 +448,9 @@ echo " "; echo ""; if ( - ($_SESSION['voicemail']['storage_type']['text'] == 'base64' && !empty($row['message_intro_base64'])) || - file_exists($_SESSION['switch']['voicemail']['dir'].'/default/'.$_SESSION['domain_name'].'/'.$field['voicemail_id'].'/intro_'.$row['voicemail_message_uuid'].'.wav') || - file_exists($_SESSION['switch']['voicemail']['dir'].'/default/'.$_SESSION['domain_name'].'/'.$field['voicemail_id'].'/intro_'.$row['voicemail_message_uuid'].'.mp3') + ($settings->get('voicemail', 'storage_type') == 'base64' && !empty($row['message_intro_base64'])) || + file_exists($settings->get('switch', 'voicemail').'/default/'.$_SESSION['domain_name'].'/'.$field['voicemail_id'].'/intro_'.$row['voicemail_message_uuid'].'.wav') || + file_exists($settings->get('switch', 'voicemail').'/default/'.$_SESSION['domain_name'].'/'.$field['voicemail_id'].'/intro_'.$row['voicemail_message_uuid'].'.mp3') ) { echo ""; echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'].' '.$text['label-introduction'],'icon'=>$settings->get('theme', 'button_icon_comment'),'id'=>'recording_button_intro_'.escape($row['voicemail_message_uuid']),'onclick'=>"recording_play('intro_".escape($row['voicemail_message_uuid'])."','".$row['voicemail_id'].'|'.$row['voicemail_uuid']."','message_intro');"]); @@ -462,7 +462,7 @@ } echo " \n"; echo " ".escape($row['message_length_label'])."\n"; - if (empty($_SESSION['voicemail']['storage_type']['text']) || $_SESSION['voicemail']['storage_type']['text'] != 'base64') { + if (empty($settings->get('voicemail', 'storage_type')) || $settings->get('voicemail', 'storage_type') != 'base64') { echo " ".escape($row['file_size_label'])."\n"; } echo "\n"; diff --git a/app/voicemails/voicemail_name.php b/app/voicemails/voicemail_name.php index 237c7a273f..ee005fd694 100644 --- a/app/voicemails/voicemail_name.php +++ b/app/voicemails/voicemail_name.php @@ -48,8 +48,8 @@ } //define name recording directory - if (!empty($_SESSION['switch']['storage']['dir'])) { - $recording_dir = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domains'][$domain_uuid]['domain_name'].'/'.$voicemail_id; + if (!empty($settings->get('switch', 'storage'))) { + $recording_dir = $settings->get('switch', 'storage').'/voicemail/default/'.$_SESSION['domains'][$domain_uuid]['domain_name'].'/'.$voicemail_id; } //download the name recording diff --git a/app/voicemails/waveform.php b/app/voicemails/waveform.php index 557aa8ca68..14131e50ec 100644 --- a/app/voicemails/waveform.php +++ b/app/voicemails/waveform.php @@ -59,15 +59,15 @@ unset($data); //set source folder path - $path = $_SESSION['switch']['voicemail']['dir'].'/default/'.$_SESSION['domain_name'].'/'.$voicemail_id; + $path = $settings->get('switch', 'voicemail').'/default/'.$_SESSION['domain_name'].'/'.$voicemail_id; //prepare base64 content from db, if enabled if ( is_numeric($voicemail_id) && is_uuid($voicemail_uuid) && is_uuid($_GET['id']) && - !empty($_SESSION['voicemail']['storage_type']['text']) && - $_SESSION['voicemail']['storage_type']['text'] == 'base64' + !empty($settings->get('voicemail', 'storage_type')) && + $settings->get('voicemail', 'storage_type') == 'base64' ) { $sql = "select message_base64 "; @@ -152,9 +152,9 @@ !empty($_GET['data']) && is_numeric($_GET['data']) && extension_assigned($_GET['data']) && - !empty($_SESSION['switch']['storage']['dir']) + !empty($settings->get('switch', 'storage')) ) { - $full_file_path = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'].'/'.$_GET['data'].'/recorded_name.wav'; + $full_file_path = $settings->get('switch', 'storage').'/voicemail/default/'.$_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'].'/'.$_GET['data'].'/recorded_name.wav'; } break; @@ -176,7 +176,7 @@ unset($sql, $parameters); //define greeting directory - $greeting_dir = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'].'/'.$voicemail_id; + $greeting_dir = $settings->get('switch', 'storage').'/voicemail/default/'.$_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'].'/'.$voicemail_id; //get voicemail greeting details from db $sql = "select greeting_filename, greeting_base64, greeting_id "; @@ -189,7 +189,7 @@ if (!empty($row) && is_array($row) && @sizeof($row) != 0) { $greeting_filename = $row['greeting_filename']; $greeting_id = $row['greeting_id']; - if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64' && !empty($row['greeting_base64'])) { + if (!empty($settings->get('voicemail', 'storage_type')) && $settings->get('voicemail', 'storage_type') == 'base64' && !empty($row['greeting_base64'])) { $greeting_decoded = base64_decode($row['greeting_base64']); file_put_contents($greeting_dir.'/'.$greeting_filename, $greeting_decoded); } @@ -217,13 +217,13 @@ $waveform = new Waveform($full_file_path); Waveform::$linesPerPixel = 1; // default: 8 Waveform::$samplesPerLine = 512; // default: 512 - Waveform::$colorA = !empty($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color - Waveform::$colorB = !empty($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color - Waveform::$backgroundColor = !empty($_SESSION['theme']['audio_player_waveform_color_background']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_background']['text']) : [0,0,0,0]; // array rgba, default: transparent - Waveform::$axisColor = !empty($_SESSION['theme']['audio_player_waveform_color_axis']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_axis']['text']) : [0,0,0,0.3]; // array rgba - Waveform::$singlePhase = filter_var($_SESSION['theme']['audio_player_waveform_single_phase']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom - Waveform::$singleAxis = filter_var($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis - $height = !empty($_SESSION['theme']['audio_player_waveform_height']['text']) && is_numeric(str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text'])) ? 2.2 * (int) str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text']) : null; + Waveform::$colorA = !empty($settings->get('theme', 'audio_player_waveform_color_a_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_a_leg')) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color + Waveform::$colorB = !empty($settings->get('theme', 'audio_player_waveform_color_b_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_b_leg')) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color + Waveform::$backgroundColor = !empty($settings->get('theme', 'audio_player_waveform_color_background')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_background')) : [0,0,0,0]; // array rgba, default: transparent + Waveform::$axisColor = !empty($settings->get('theme', 'audio_player_waveform_color_axis')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_axis')) : [0,0,0,0.3]; // array rgba + Waveform::$singlePhase = filter_var($settings->get('theme', 'audio_player_waveform_single_phase') ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom + Waveform::$singleAxis = filter_var($settings->get('theme', 'audio_player_waveform_single_axis') ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis + $height = !empty($settings->get('theme', 'audio_player_waveform_height')) && is_numeric(str_replace('px','',$settings->get('theme', 'audio_player_waveform_height'))) ? 2.2 * (int) str_replace('px','',$settings->get('theme', 'audio_player_waveform_height')) : null; $wf = $waveform->getWaveform($temp_filename, 1600, $height ?? 180); // input: png filename returns boolean true/false, or 'base64' returns base64 string } @@ -259,7 +259,7 @@ break; case 'greeting': - if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64' && !empty($row['greeting_base64'])) { + if (!empty($settings->get('voicemail', 'storage_type')) && $settings->get('voicemail', 'storage_type') == 'base64' && !empty($row['greeting_base64'])) { if ($greeting_id != $selected_greeting_id) { @unlink($greeting_dir.'/'.$greeting_filename); } diff --git a/app/xml_cdr/app_defaults.php b/app/xml_cdr/app_defaults.php index bc8994d58d..fb55f69d5a 100644 --- a/app/xml_cdr/app_defaults.php +++ b/app/xml_cdr/app_defaults.php @@ -28,10 +28,10 @@ if ($domains_processed == 1) { /* - $file_contents = file_get_contents($_SESSION['switch']['conf']['dir']."/autoload_configs/xml_cdr.conf.xml"); + $file_contents = file_get_contents($settings->get('switch', 'conf')."/autoload_configs/xml_cdr.conf.xml"); $file_contents_new = str_replace("param name=\"prefix-a-leg\" value=\"false\"/", "param name=\"prefix-a-leg\" value=\"true\"/", $file_contents); if ($file_contents != $file_contents_new) { - $fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/xml_cdr.conf.xml","w"); + $fout = fopen($settings->get('switch', 'conf')."/autoload_configs/xml_cdr.conf.xml","w"); fwrite($fout, $file_contents_new); fclose($fout); if ($display_type == "text") { diff --git a/app/xml_cdr/resources/classes/xml_cdr.php b/app/xml_cdr/resources/classes/xml_cdr.php index c7f4e4dfad..e7a11bf5e3 100644 --- a/app/xml_cdr/resources/classes/xml_cdr.php +++ b/app/xml_cdr/resources/classes/xml_cdr.php @@ -35,13 +35,18 @@ const app_name = 'xml_cdr'; const app_uuid = '4a085c51-7635-ff03-f67b-86e834422848'; + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + public $domain_uuid; + /** * declare public variables */ public $array; public $fields; public $setting; - public $domain_uuid; public $call_details; public $call_direction; public $status; @@ -63,6 +68,12 @@ */ public $file; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + /** * Internal array structure that is populated from the database * @var array Array of settings loaded from Default Settings @@ -70,10 +81,16 @@ private $settings; /** - * Set in the constructor. Must be a database object and cannot be null. - * @var database Database Object + * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string */ - private $database; + private $user_uuid; + + /** + * Username set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $username; /** * Set in the constructor. This can be null. @@ -93,24 +110,20 @@ /** * additional private variables */ - private $username; private $password; private $json; /** * Called when the object is created */ - public function __construct($setting_array = []) { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? ''; - //open a database connection - $this->database = database::new(); - - //get the settings object - if (empty($setting_array['settings'])) { - $this->settings = new settings(['database' => $this->database]); - } else { - $this->settings = $setting_array['settings']; - } + //set objects + $this->database = $setting_array['database'] ?? database::new(); + $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); //set the directory $this->xml_cdr_dir = $this->settings->get('switch', 'log', '/var/log/freeswitch').'/xml_cdr'; @@ -1189,12 +1202,7 @@ public function call_flow_summary($call_flow_array) { //set the time zone - if (!empty($this->settings->get('domain', 'time_zone'))) { - $time_zone = $this->settings->get('domain', 'time_zone'); - } - else { - $time_zone = date_default_timezone_get(); - } + $time_zone = $this->settings->get('domain', 'time_zone', date_default_timezone_get()); //set the time zone for php date_default_timezone_set($time_zone); @@ -1420,6 +1428,7 @@ } //build the application urls + $application_url = ''; if (!empty($app['application'])) { //build the source url $source_url = ''; @@ -1766,12 +1775,7 @@ public function user_summary() { //set the time zone - if (!empty($this->settings->get('domain', 'time_zone'))) { - $time_zone = $this->settings->get('domain', 'time_zone'); - } - else { - $time_zone = date_default_timezone_get(); - } + $time_zone = $this->settings->get('domain', 'time_zone', date_default_timezone_get()); //set the time zone for php date_default_timezone_set($time_zone); diff --git a/app/xml_cdr/resources/dashboard/missed_calls.php b/app/xml_cdr/resources/dashboard/missed_calls.php index eb53d51001..1fd793d228 100644 --- a/app/xml_cdr/resources/dashboard/missed_calls.php +++ b/app/xml_cdr/resources/dashboard/missed_calls.php @@ -15,7 +15,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings'); + $text = $language->get($settings->get('domain', 'language', 'en-us'), 'core/user_settings'); //create assigned extensions array if (is_array($_SESSION['user']['extension'])) { @@ -30,8 +30,8 @@ //set the sql time format $sql_time_format = 'DD Mon HH12:MI am'; - if (!empty($_SESSION['domain']['time_format']['text'])) { - $sql_time_format = $_SESSION['domain']['time_format']['text'] == '12h' ? "DD Mon HH12:MI am" : "DD Mon HH24:MI"; + if (!empty($settings->get('domain', 'time_format'))) { + $sql_time_format = $settings->get('domain', 'time_format') == '12h' ? "DD Mon HH12:MI am" : "DD Mon HH24:MI"; } //get the missed calls from call detail records @@ -173,7 +173,7 @@ foreach ($result as $index => $row) { $start_date_time = str_replace('/0','/', ltrim($row['start_date_time'], '0')); - if (!empty($_SESSION['domain']['time_format']) && $_SESSION['domain']['time_format']['text'] == '12h') { + if (!empty($_SESSION['domain']['time_format']) && $settings->get('domain', 'time_format') == '12h') { $start_date_time = str_replace(' 0',' ', $start_date_time); } //set click-to-call variables @@ -185,9 +185,9 @@ "&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number'] ?? ''). "&src=".urlencode($_SESSION['user']['extension'][0]['user'] ?? ''). "&dest=".urlencode($row['caller_id_number'] ?? ''). - "&rec=".(filter_var($_SESSION['click_to_call']['record']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? "true" : "false"). - "&ringback=".(isset($_SESSION['click_to_call']['ringback']['text']) ? $_SESSION['click_to_call']['ringback']['text'] : "us-ring"). - "&auto_answer=".(filter_var($_SESSION['click_to_call']['auto_answer']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? "true" : "false"). + "&rec=".(filter_var($settings->get('click_to_call', 'record') ?? false, FILTER_VALIDATE_BOOL) ? "true" : "false"). + "&ringback=".$settings->get('click_to_call', 'ringback', 'us-ring'). + "&auto_answer=".(filter_var($settings->get('click_to_call', 'auto_answer') ?? false, FILTER_VALIDATE_BOOL) ? "true" : "false"). "');\" ". "style='cursor: pointer;'"; } @@ -196,7 +196,7 @@ if ($theme_cdr_images_exist) { $call_result = $row['status']; if (isset($row['direction'])) { - echo " \n"; + echo " \n"; } } echo "\n"; diff --git a/app/xml_cdr/resources/dashboard/recent_calls.php b/app/xml_cdr/resources/dashboard/recent_calls.php index fd099aff4f..6fe412f785 100644 --- a/app/xml_cdr/resources/dashboard/recent_calls.php +++ b/app/xml_cdr/resources/dashboard/recent_calls.php @@ -15,7 +15,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings'); + $text = $language->get($settings->get('domain', 'language', 'en-us'), 'core/user_settings'); //create assigned extensions array if (is_array($_SESSION['user']['extension'])) { @@ -30,8 +30,8 @@ //set the sql time format $sql_time_format = 'DD Mon HH12:MI am'; - if (!empty($_SESSION['domain']['time_format']['text'])) { - $sql_time_format = $_SESSION['domain']['time_format']['text'] == '12h' ? "DD Mon HH12:MI am" : "DD Mon HH24:MI"; + if (!empty($settings->get('domain', 'time_format'))) { + $sql_time_format = $settings->get('domain', 'time_format') == '12h' ? "DD Mon HH12:MI am" : "DD Mon HH24:MI"; } //get the recent calls from call detail records @@ -179,7 +179,7 @@ foreach ($result as $index => $row) { $start_date_time = str_replace('/0','/', ltrim($row['start_date_time'], '0')); - if (!empty($_SESSION['domain']['time_format']) && $_SESSION['domain']['time_format']['text'] == '12h') { + if (!empty($_SESSION['domain']['time_format']) && $settings->get('domain', 'time_format') == '12h') { $start_date_time = str_replace(' 0',' ', $start_date_time); } @@ -203,9 +203,9 @@ "&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number'] ?? ''). "&src=".urlencode($_SESSION['user']['extension'][0]['user'] ?? ''). "&dest=".urlencode($dest ?? ''). - "&rec=".(filter_var($_SESSION['click_to_call']['record']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true' : 'false'). - "&ringback=".(isset($_SESSION['click_to_call']['ringback']['text']) ? $_SESSION['click_to_call']['ringback']['text'] : "us-ring"). - "&auto_answer=".(filter_var($_SESSION['click_to_call']['auto_answer']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true' : 'false'). + "&rec=".(filter_var($settings->get('click_to_call', 'record') ?? false, FILTER_VALIDATE_BOOL) ? 'true' : 'false'). + "&ringback=".$settings->get('click_to_call', 'ringback', 'us-ring'). + "&auto_answer=".(filter_var($settings->get('click_to_call', 'auto_answer') ?? false, FILTER_VALIDATE_BOOL) ? 'true' : 'false'). "');\" ". "style='cursor: pointer;'"; } @@ -215,7 +215,7 @@ if ($theme_cdr_images_exist) { $call_result = $row['status']; if (isset($row['direction'])) { - echo "\n"; + echo "\n"; } } echo "\n"; diff --git a/app/xml_cdr/waveform.php b/app/xml_cdr/waveform.php index 5a67a6e165..9df607cff3 100644 --- a/app/xml_cdr/waveform.php +++ b/app/xml_cdr/waveform.php @@ -44,7 +44,7 @@ //get call recording details from database $sql = "select call_recording_name, call_recording_path "; - if (!empty($_SESSION['call_recordings']['storage_type']['text']) && $_SESSION['call_recordings']['storage_type']['text'] == 'base64' && !empty($row['call_recording_base64'])) { + if (!empty($settings->get('call_recordings', 'storage_type')) && $settings->get('call_recordings', 'storage_type') == 'base64' && !empty($row['call_recording_base64'])) { $sql = ", call_recording_base64 "; } $sql .= "from view_call_recordings "; @@ -54,7 +54,7 @@ if (is_array($row) && @sizeof($row) != 0) { $call_recording_name = $row['call_recording_name']; $call_recording_path = $row['call_recording_path']; - if (!empty($_SESSION['call_recordings']['storage_type']['text']) && $_SESSION['call_recordings']['storage_type']['text'] == 'base64' && !empty($row['call_recording_base64'])) { + if (!empty($settings->get('call_recordings', 'storage_type')) && $settings->get('call_recordings', 'storage_type') == 'base64' && !empty($row['call_recording_base64'])) { file_put_contents($call_recording_path.'/'.$call_recording_name, base64_decode($row['call_recording_base64'])); } } @@ -78,13 +78,13 @@ $waveform = new Waveform($full_recording_path); Waveform::$linesPerPixel = 1; // default: 8 Waveform::$samplesPerLine = 512; // default: 512 - Waveform::$colorA = !empty($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color - Waveform::$colorB = !empty($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color - Waveform::$backgroundColor = !empty($_SESSION['theme']['audio_player_waveform_color_background']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_background']['text']) : [0,0,0,0]; // array rgba, default: transparent - Waveform::$axisColor = !empty($_SESSION['theme']['audio_player_waveform_color_axis']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_axis']['text']) : [0,0,0,0.3]; // array rgba - Waveform::$singlePhase = filter_var($_SESSION['theme']['audio_player_waveform_single_phase']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom - Waveform::$singleAxis = filter_var($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis - $height = !empty($_SESSION['theme']['audio_player_waveform_height']['text']) && is_numeric(str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text'])) ? 2.2 * (int) str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text']) : null; + Waveform::$colorA = !empty($settings->get('theme', 'audio_player_waveform_color_a_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_a_leg')) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color + Waveform::$colorB = !empty($settings->get('theme', 'audio_player_waveform_color_b_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_b_leg')) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color + Waveform::$backgroundColor = !empty($settings->get('theme', 'audio_player_waveform_color_background')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_background')) : [0,0,0,0]; // array rgba, default: transparent + Waveform::$axisColor = !empty($settings->get('theme', 'audio_player_waveform_color_axis')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_axis')) : [0,0,0,0.3]; // array rgba + Waveform::$singlePhase = filter_var($settings->get('theme', 'audio_player_waveform_single_phase') ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom + Waveform::$singleAxis = filter_var($settings->get('theme', 'audio_player_waveform_single_axis') ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis + $height = !empty($settings->get('theme', 'audio_player_waveform_height')) && is_numeric(str_replace('px','',$settings->get('theme', 'audio_player_waveform_height'))) ? 2.2 * (int) str_replace('px','',$settings->get('theme', 'audio_player_waveform_height')) : null; $wf = $waveform->getWaveform($temp_filename, 1600, $height ?? 180); // input: png filename returns boolean true/false, or 'base64' returns base64 string } @@ -111,7 +111,7 @@ } //if base64, remove temp recording file - if (!empty($_SESSION['call_recordings']['storage_type']['text']) && $_SESSION['call_recordings']['storage_type']['text'] == 'base64' && !empty($row['call_recording_base64'])) { + if (!empty($settings->get('call_recordings', 'storage_type')) && $settings->get('call_recordings', 'storage_type') == 'base64' && !empty($row['call_recording_base64'])) { @unlink($full_recording_path); } unset($row); diff --git a/app/xml_cdr/xml_cdr.php b/app/xml_cdr/xml_cdr.php index 247a980cb3..32955b8870 100644 --- a/app/xml_cdr/xml_cdr.php +++ b/app/xml_cdr/xml_cdr.php @@ -829,7 +829,7 @@ if (is_array($result)) { //determine if theme images exist - $theme_image_path = $_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/"; + $theme_image_path = $_SERVER["DOCUMENT_ROOT"]."/themes/".$settings->get('domain', 'template')."/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") && @@ -966,7 +966,7 @@ } $image_name .= ".png"; if (file_exists($theme_image_path.$image_name)) { - $content .= "\n"; + $content .= "\n"; } else { $content .= " "; } } diff --git a/app/xml_cdr/xml_cdr_details.php b/app/xml_cdr/xml_cdr_details.php index 3cbdc7c321..0e13e1a685 100644 --- a/app/xml_cdr/xml_cdr_details.php +++ b/app/xml_cdr/xml_cdr_details.php @@ -75,6 +75,7 @@ $start_stamp = trim($row["start_stamp"] ?? ''); $xml_string = trim($row["xml"] ?? ''); $json_string = trim($row["json"] ?? ''); + $leg = trim($row["leg"] ?? ''); $call_flow = trim($row["call_flow"] ?? ''); $direction = trim($row["direction"] ?? ''); $call_direction = trim($row["direction"] ?? ''); @@ -203,7 +204,7 @@ $tmp_year = date("Y", $tmp_time); $tmp_month = date("M", $tmp_time); $tmp_day = date("d", $tmp_time); - $tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day; + $tmp_dir = $settings->get('switch', 'log').'/xml_cdr/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day; if (file_exists($tmp_dir.'/'.$uuid.'.json')) { $format = "json"; $json_string = file_get_contents($tmp_dir.'/'.$uuid.'.json'); @@ -382,7 +383,7 @@ if (permission_exists('xml_cdr_call_log') && $call_log_enabled && isset($log_content) && !empty($log_content)) { echo button::create(['type'=>'button','label'=>$text['button-call_log'],'icon'=>$settings->get('theme', 'button_icon_search'),'style'=>'margin-left: 15px;','link'=>'xml_cdr_log.php?id='.$uuid]); } - if ($transcribe_enabled && !empty($transcribe_engine) && empty($record_transcription)) { + if ($transcribe_enabled && !empty($transcribe_engine) && empty($record_transcription) && !empty($record_path) && !empty($record_name) && file_exists($record_path.'/'.$record_name)) { echo button::create(['type'=>'button','label'=>$text['button-transcribe'],'icon'=>'quote-right','id'=>'btn_transcribe','name'=>'btn_transcribe','collapse'=>'hide-xs','style'=>'margin-left: 15px;','onclick'=>"window.location.href='?id=".$uuid."&action=transcribe';"]); } echo "\n"; @@ -448,18 +449,18 @@ echo " \n"; if (!empty($call_direction)) { $image_name = "icon_cdr_" . $call_direction . "_" . $status; - if ($row['leg'] == 'b') { + if ($leg == 'b') { $image_name .= '_b'; } $image_name .= ".png"; - echo " \n"; + echo " \n"; } echo " \n"; echo " ".escape($direction)."\n"; //echo " ".$language."\n"; //echo " ".$context."\n"; echo " "; - if (file_exists($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$uuid.'.wav')) { + if (file_exists($settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$uuid.'.wav')) { //echo " \n"; //echo " "; @@ -473,7 +474,7 @@ } echo " \n"; echo " "; - if (file_exists($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$uuid.'.wav')) { + if (file_exists($settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$uuid.'.wav')) { echo " \n"; echo escape($caller_id_number).' '; echo " "; @@ -519,8 +520,9 @@ echo " \n"; $i = 1; foreach ($call_flow_summary as $row) { + $application_icon = $row["application_icon"][$row["application_name"] ?? ''] ?? ''; echo " \n"; - echo " "; + echo " "; echo " ".escape($row["application_label"])."\n"; if ($call_direction == 'local' || $call_direction == 'outbound') { echo " ".escape($row["source_number"])."\n"; @@ -725,7 +727,7 @@ if ($key == "bridge_uuid" || $key == "signal_bond") { echo " \n"; echo " ".escape($value)." \n"; - $tmp_dir = $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day; + $tmp_dir = $settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day; $tmp_name = ''; if (file_exists($tmp_dir.'/'.$value.'.wav')) { $tmp_name = $value.".wav"; @@ -739,12 +741,12 @@ else if (file_exists($tmp_dir.'/'.$value.'_1.mp3')) { $tmp_name = $value."_1.mp3"; } - if (!empty($tmp_name) && file_exists($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) { + if (!empty($tmp_name) && file_exists($settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) { echo " \n"; echo " play"; echo "  "; } - if (!empty($tmp_name) && file_exists($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) { + if (!empty($tmp_name) && file_exists($settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) { echo " \n"; echo " download"; echo " "; @@ -784,7 +786,7 @@ echo "\n"; //foreach($array["variables"] as $key => $value) { - if (is_array($array["app_log"]["application"])) { + if (!empty($array["app_log"]["application"])) { foreach ($array["app_log"]["application"] as $key=>$row) { //single app if ($key === "@attributes") { diff --git a/app/xml_cdr/xml_cdr_export.php b/app/xml_cdr/xml_cdr_export.php index 83a4af48da..5070c9e4c2 100644 --- a/app/xml_cdr/xml_cdr_export.php +++ b/app/xml_cdr/xml_cdr_export.php @@ -152,7 +152,7 @@ require_once "resources/fpdi/fpdi.php"; //determine page size - switch ($_SESSION['fax']['page_size']['text']) { + switch ($settings->get('fax', 'page_size')) { case 'a4': $page_width = 11.7; //in $page_height = 8.3; //in diff --git a/app/xml_cdr/xml_cdr_inc.php b/app/xml_cdr/xml_cdr_inc.php index 8e3683924f..a8c3351622 100644 --- a/app/xml_cdr/xml_cdr_inc.php +++ b/app/xml_cdr/xml_cdr_inc.php @@ -270,7 +270,7 @@ //count the records in the database /* - if ($_SESSION['cdr']['limit']['numeric'] == 0) { + if ($settings->get('cdr', 'limit') == 0) { $sql = "select count(*) from v_xml_cdr "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= ".$sql_where; @@ -281,12 +281,12 @@ */ //limit the number of results - if (!empty($_SESSION['cdr']['limit']['numeric']) && $_SESSION['cdr']['limit']['numeric'] > 0) { - $num_rows = $_SESSION['cdr']['limit']['numeric']; + if (!empty($settings->get('cdr', 'limit')) && $settings->get('cdr', 'limit') > 0) { + $num_rows = $settings->get('cdr', 'limit'); } //set the default paging - //$rows_per_page = $_SESSION['domain']['paging']['numeric']; + //$rows_per_page = $settings->get('domain', 'paging'); //prepare to page the results //$rows_per_page = $settings->get('domain', 'paging', 50); //set on the page that includes this page @@ -303,8 +303,8 @@ //set the sql time format $sql_time_format = 'HH12:MI am'; - if (!empty($_SESSION['domain']['time_format']['text'])) { - $sql_time_format = $_SESSION['domain']['time_format']['text'] == '12h' ? "HH12:MI am" : "HH24:MI"; + if (!empty($settings->get('domain', 'time_format'))) { + $sql_time_format = $settings->get('domain', 'time_format') == '12h' ? "HH12:MI am" : "HH24:MI"; } //get the results from the db @@ -637,7 +637,7 @@ if ($export_format !== "csv" && $export_format !== "pdf") { if ($rows_per_page == 0) { $sql .= " limit :limit offset 0 \n"; - $parameters['limit'] = $_SESSION['cdr']['limit']['numeric']; + $parameters['limit'] = $settings->get('cdr', 'limit'); } else { $sql .= " limit :limit offset :offset \n"; diff --git a/core/authentication/resources/classes/authentication.php b/core/authentication/resources/classes/authentication.php index e81532f845..e03048a9ef 100644 --- a/core/authentication/resources/classes/authentication.php +++ b/core/authentication/resources/classes/authentication.php @@ -45,8 +45,8 @@ class authentication { /** * Called when the object is created */ - public function __construct() { - $this->database = database::new(); + public function __construct(array $setting_array = []) { + $this->database = $setting_array['database'] ?? database::new(); $this->user_uuid = null; } diff --git a/core/authentication/resources/classes/plugins/email.php b/core/authentication/resources/classes/plugins/email.php index 65413c3c8d..a74f9983b5 100644 --- a/core/authentication/resources/classes/plugins/email.php +++ b/core/authentication/resources/classes/plugins/email.php @@ -221,7 +221,7 @@ class plugin_email { //$response = ob_get_clean(); //get the language code - $language_code = $_SESSION['domain']['language']['code']; + $language_code = $settings->get('domain', 'language', 'en-us'); //get the email template from the database $sql = "select template_subject, template_body "; diff --git a/core/contacts/app_config.php b/core/contacts/app_config.php index 03d5862101..4eaff669af 100644 --- a/core/contacts/app_config.php +++ b/core/contacts/app_config.php @@ -1222,5 +1222,20 @@ $apps[$x]['default_settings'][$y]['default_setting_value'] = "false"; $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true"; $apps[$x]['default_settings'][$y]['default_setting_description'] = ""; - + $y++; + $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "b28a0d3d-64d4-4306-b38b-07fbf07d53b6"; + $apps[$x]['default_settings'][$y]['default_setting_category'] = "contact"; + $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "default_sort_column"; + $apps[$x]['default_settings'][$y]['default_setting_name'] = "text"; + $apps[$x]['default_settings'][$y]['default_setting_value'] = "last_mod_date"; + $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true"; + $apps[$x]['default_settings'][$y]['default_setting_description'] = "Order by field name used in list"; + $y++; + $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "d7652f7f-1521-4e17-87a8-21d436e497ec"; + $apps[$x]['default_settings'][$y]['default_setting_category'] = "contact"; + $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "default_sort_order"; + $apps[$x]['default_settings'][$y]['default_setting_name'] = "text"; + $apps[$x]['default_settings'][$y]['default_setting_value'] = "desc"; + $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true"; + $apps[$x]['default_settings'][$y]['default_setting_description'] = "Options: asc, desc"; ?> diff --git a/core/contacts/contact_address_edit.php b/core/contacts/contact_address_edit.php index 3fff4e40b2..b370bb1ec1 100644 --- a/core/contacts/contact_address_edit.php +++ b/core/contacts/contact_address_edit.php @@ -218,7 +218,7 @@ } //set the defaults - if ($address_primary === null) { $address_primary = false; } + $address_primary = $address_primary ?? false; //create token $object = new token; diff --git a/core/contacts/contact_attachment.php b/core/contacts/contact_attachment.php index 5fd4c1bd03..c720c007a7 100644 --- a/core/contacts/contact_attachment.php +++ b/core/contacts/contact_attachment.php @@ -52,7 +52,7 @@ //determine mime type $content_type = 'application/octet-stream'; //set default - $allowed_attachment_types = json_decode($_SESSION['contact']['allowed_attachment_types']['text'] ?? '', true); + $allowed_attachment_types = json_decode($settings->get('contact', 'allowed_attachment_types') ?? '', true); if (!empty($allowed_attachment_types)) { if ($allowed_attachment_types[$attachment_type] != '') { $content_type = $allowed_attachment_types[$attachment_type]; diff --git a/core/contacts/contact_attachment_edit.php b/core/contacts/contact_attachment_edit.php index db1c00072a..cd24e96968 100644 --- a/core/contacts/contact_attachment_edit.php +++ b/core/contacts/contact_attachment_edit.php @@ -91,7 +91,7 @@ } //get the allowed extensions - $allowed_extensions = array_keys(json_decode($_SESSION['contact']['allowed_attachment_types']['text'], true)); + $allowed_extensions = array_keys(json_decode($settings->get('contact', 'allowed_attachment_types'), true)); //check the allowed extensions if ($attachment['error'] == '0' && in_array($attachment_extension, $allowed_extensions)) { @@ -183,7 +183,7 @@ } //set the defaults - if ($attachment_primary === null) { $attachment_primary = false; } + $attachment_primary = $attachment_primary ?? false; //create token $object = new token; @@ -236,7 +236,7 @@ } } else { - $allowed_attachment_types = json_decode($_SESSION['contact']['allowed_attachment_types']['text'], true); + $allowed_attachment_types = json_decode($settings->get('contact', 'allowed_attachment_types'), true); echo " \n"; echo " ".strtoupper(implode(', ', array_keys($allowed_attachment_types))).""; } diff --git a/core/contacts/contact_auth.php b/core/contacts/contact_auth.php index e43356017f..07c1e7d4ae 100644 --- a/core/contacts/contact_auth.php +++ b/core/contacts/contact_auth.php @@ -66,7 +66,7 @@ if ($_SESSION['contact_auth']['source'] == 'google') { } if ($_GET['code'] == '') { - header("Location: https://accounts.google.com/o/oauth2/auth?client_id=".$_SESSION['contact']['google_oauth_client_id']['text']."&redirect_uri=".(($_SERVER["HTTPS"] == "on") ? "https" : "http")."://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."&scope=https://www.google.com/m8/feeds/&response_type=code"); + header("Location: https://accounts.google.com/o/oauth2/auth?client_id=".$settings->get('contact', 'google_oauth_client_id')."&redirect_uri=".(($_SERVER["HTTPS"] == "on") ? "https" : "http")."://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."&scope=https://www.google.com/m8/feeds/&response_type=code"); exit; } else { @@ -78,8 +78,8 @@ if ($_SESSION['contact_auth']['source'] == 'google') { $fields = array( 'code' => urlencode($auth_code), - 'client_id' => urlencode($_SESSION['contact']['google_oauth_client_id']['text']), - 'client_secret' => urlencode($_SESSION['contact']['google_oauth_client_secret']['text']), + 'client_id' => urlencode($settings->get('contact', 'google_oauth_client_id')), + 'client_secret' => urlencode($settings->get('contact', 'google_oauth_client_secret')), 'redirect_uri' => urlencode((($_SERVER["HTTPS"] == "on") ? "https" : "http")."://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']), 'grant_type' => urlencode('authorization_code') ); diff --git a/core/contacts/contact_edit.php b/core/contacts/contact_edit.php index 97c8ed0446..5bcef0513c 100644 --- a/core/contacts/contact_edit.php +++ b/core/contacts/contact_edit.php @@ -55,7 +55,7 @@ $contact_attachments = []; //set from session variables - $body_text_color = !empty($_SESSION['theme']['body_text_color']['text']) ? $_SESSION['theme']['body_text_color']['text'] : 'false'; + $body_text_color = !empty($settings->get('theme', 'body_text_color')) ? $settings->get('theme', 'body_text_color') : 'false'; //action add or update if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) { @@ -991,29 +991,29 @@ "; + if (!empty($settings->get('theme', 'qr_brand_image')) && $settings->get('theme', 'qr_brand_type') == 'image') { + echo ""; $qr_option = "image: $('#img-buffer')[0],"; $qr_mode = '4'; $qr_size = '0.2'; } - elseif (empty($_SESSION['theme']['qr_brand_image']['text']) && !empty($_SESSION['theme']['qr_brand_type']['text']) && $_SESSION['theme']['qr_brand_type']['text'] == 'image') { + elseif (empty($settings->get('theme', 'qr_brand_image')) && !empty($settings->get('theme', 'qr_brand_type')) && $settings->get('theme', 'qr_brand_type') == 'image') { $qr_option = ''; $qr_mode = '3'; $qr_size = '0'; } - elseif (!empty($_SESSION['theme']['qr_brand_image']['text']) && $_SESSION['theme']['qr_brand_type']['text'] == 'text') { - $qr_option = 'label: "'.$_SESSION['theme']['qr_brand_text']['text'].'"'; + elseif (!empty($settings->get('theme', 'qr_brand_image')) && $settings->get('theme', 'qr_brand_type') == 'text') { + $qr_option = 'label: "'.$settings->get('theme', 'qr_brand_text').'"'; $qr_mode = '2'; $qr_size = '0.05'; } - elseif (!empty($_SESSION['theme']['qr_brand_image']['text']) && $_SESSION['theme']['qr_brand_type']['text'] == 'none') { + elseif (!empty($settings->get('theme', 'qr_brand_image')) && $settings->get('theme', 'qr_brand_type') == 'none') { $qr_option = ''; $qr_mode = '3'; $qr_size = '0'; } else { - echo ""; + echo ""; $qr_option = "image: $('#img-buffer')[0],"; $qr_mode = '4'; $qr_size = '0.2'; @@ -2561,7 +2561,7 @@ if (permission_exists('contact_attachment_view')) { } //} //else { - // $allowed_attachment_types = json_decode($_SESSION['contact']['allowed_attachment_types']['text'], true); + // $allowed_attachment_types = json_decode($settings->get('contact', 'allowed_attachment_types'), true); // echo " \n"; // echo " ".strtoupper(implode(', ', array_keys($allowed_attachment_types))).""; //} diff --git a/core/contacts/contact_email_edit.php b/core/contacts/contact_email_edit.php index 8c7f3d6aea..0eff7600e0 100644 --- a/core/contacts/contact_email_edit.php +++ b/core/contacts/contact_email_edit.php @@ -181,7 +181,7 @@ if (!empty($_GET["contact_uuid"]) && is_uuid($_GET["contact_uuid"])) { } //set the defaults - if ($email_primary === null) { $email_primary = false; } + $email_primary = $email_primary ?? false; //create token $object = new token; diff --git a/core/contacts/contact_import.php b/core/contacts/contact_import.php index 4aee9a78b0..cace77a2a5 100644 --- a/core/contacts/contact_import.php +++ b/core/contacts/contact_import.php @@ -64,7 +64,7 @@ //save the data to the csv file if (isset($_POST['data'])) { - $file = $_SESSION['server']['temp']['dir']."/contacts-".$_SESSION['domain_name'].".csv"; + $file = $settings->get('server', 'temp')."/contacts-".$_SESSION['domain_name'].".csv"; file_put_contents($file, $_POST['data']); $_SESSION['file'] = $file; } @@ -73,10 +73,10 @@ //$_POST['submit'] == "Upload" && if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('contact_upload')) { if ($_POST['type'] == 'csv') { - move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']); - $save_msg = "Uploaded file to ".$_SESSION['server']['temp']['dir']."/". htmlentities($_FILES['ulfile']['name']); - //system('chmod -R 744 '.$_SESSION['server']['temp']['dir'].'*'); - $file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']; + move_uploaded_file($_FILES['ulfile']['tmp_name'], $settings->get('server', 'temp').'/'.$_FILES['ulfile']['name']); + $save_msg = "Uploaded file to ".$settings->get('server', 'temp')."/". htmlentities($_FILES['ulfile']['name']); + //system('chmod -R 744 '.$settings->get('server', 'temp').'*'); + $file = $settings->get('server', 'temp').'/'.$_FILES['ulfile']['name']; $_SESSION['file'] = $file; } } @@ -510,7 +510,7 @@ echo "
\n"; echo "
\n"; - if (function_exists('curl_version') && !empty($_SESSION['contact']['google_oauth_client_id']['text']) && !empty($_SESSION['contact']['google_oauth_client_secret']['text'])) { + if (function_exists('curl_version') && !empty($settings->get('contact', 'google_oauth_client_id')) && !empty($settings->get('contact', 'google_oauth_client_secret'))) { echo "".$text['header-contacts_import_google']."\n"; } diff --git a/core/contacts/contact_phone_edit.php b/core/contacts/contact_phone_edit.php index 83f49c4209..e083b9f50f 100644 --- a/core/contacts/contact_phone_edit.php +++ b/core/contacts/contact_phone_edit.php @@ -243,7 +243,7 @@ } //set the defaults - if ($phone_primary === null) { $phone_primary = false; } + $phone_primary = $phone_primary ?? false; //create token $object = new token; diff --git a/core/contacts/contact_setting_edit.php b/core/contacts/contact_setting_edit.php index 26e94fd180..c48ba79423 100644 --- a/core/contacts/contact_setting_edit.php +++ b/core/contacts/contact_setting_edit.php @@ -195,7 +195,7 @@ } //set the defaults - if ($contact_setting_enabled === null) { $contact_setting_enabled = true; } + $contact_setting_enabled = $contact_setting_enabled ?? true; //create token $object = new token; diff --git a/core/contacts/contact_url_edit.php b/core/contacts/contact_url_edit.php index 986247406d..e6a24bde66 100644 --- a/core/contacts/contact_url_edit.php +++ b/core/contacts/contact_url_edit.php @@ -183,7 +183,7 @@ } //set the defaults - if ($url_primary === null) { $url_primary = false; } + $url_primary = $url_primary ?? false; //create token $object = new token; diff --git a/core/contacts/contact_view.php b/core/contacts/contact_view.php index a9aa29b922..81507f0238 100644 --- a/core/contacts/contact_view.php +++ b/core/contacts/contact_view.php @@ -150,29 +150,29 @@ require_once "resources/header.php"; //determine qr branding - if (!empty($_SESSION['theme']['qr_brand_type']['text']) && !empty($_SESSION['theme']['qr_brand_image']['text']) && $_SESSION['theme']['qr_brand_type']['text'] == 'image') { - echo ""; + if (!empty($settings->get('theme', 'qr_brand_type')) && !empty($settings->get('theme', 'qr_brand_image')) && $settings->get('theme', 'qr_brand_type') == 'image') { + echo ""; $qr_option = "image: $('#img-buffer')[0],"; $qr_mode = '4'; $qr_size = '0.2'; } - elseif (!empty($_SESSION['theme']['qr_brand_type']['text']) && empty($_SESSION['theme']['qr_brand_image']['text']) && $_SESSION['theme']['qr_brand_type']['text'] == 'image') { + elseif (!empty($settings->get('theme', 'qr_brand_type')) && empty($settings->get('theme', 'qr_brand_image')) && $settings->get('theme', 'qr_brand_type') == 'image') { $qr_option = ''; $qr_mode = '3'; $qr_size = '0'; } - elseif (!empty($_SESSION['theme']['qr_brand_type']['text']) && !empty($_SESSION['theme']['qr_brand_text']['text']) && $_SESSION['theme']['qr_brand_type']['text'] == 'text') { - $qr_option = 'label: "'.$_SESSION['theme']['qr_brand_text']['text'].'"'; + elseif (!empty($settings->get('theme', 'qr_brand_type')) && !empty($settings->get('theme', 'qr_brand_text')) && $settings->get('theme', 'qr_brand_type') == 'text') { + $qr_option = 'label: "'.$settings->get('theme', 'qr_brand_text').'"'; $qr_mode = '2'; $qr_size = '0.05'; } - elseif (!empty($_SESSION['theme']['qr_brand_type']['text']) && $_SESSION['theme']['qr_brand_type']['text'] == 'none') { + elseif (!empty($settings->get('theme', 'qr_brand_type')) && $settings->get('theme', 'qr_brand_type') == 'none') { $qr_option = ''; $qr_mode = '3'; $qr_size = '0'; } else { - echo ""; + echo ""; $qr_option = "image: $('#img-buffer')[0],"; $qr_mode = '4'; $qr_size = '0.2'; diff --git a/core/contacts/contacts.php b/core/contacts/contacts.php index 005dc43d11..8bb2e485bc 100644 --- a/core/contacts/contacts.php +++ b/core/contacts/contacts.php @@ -125,11 +125,12 @@ unset($sql, $parameters, $result); //get variables used to control the order - $order_by = $_GET["order_by"] ?? ''; - $order = $_GET["order"] ?? ''; + $order_by = $_REQUEST["order_by"] ?? ''; + $order = $_REQUEST["order"] ?? ''; //add the search term - $search = strtolower(trim($_GET["search"]) ?? ''); + $search = $_REQUEST["search"] ?? ''; + $search = strtolower(trim($search ?? '')); if (!empty($search)) { if (is_numeric($search)) { $sql_search = "and contact_uuid in ( "; @@ -230,7 +231,7 @@ $num_rows = $database->select($sql, $parameters ?? null, 'column'); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = "&search=".urlencode($search); if ($show == "all" && permission_exists('contact_all')) { $param .= "&show=all"; @@ -284,8 +285,8 @@ $sql .= ", contact_organization asc "; } else { - $contact_default_sort_column = !empty($_SESSION['contacts']['default_sort_column']['text']) ? $_SESSION['contacts']['default_sort_column']['text'] : "last_mod_date"; - $contact_default_sort_order = !empty($_SESSION['contacts']['default_sort_order']['text']) ? $_SESSION['contacts']['default_sort_order']['text'] : "desc"; + $contact_default_sort_column = $settings->get('contact', 'default_sort_column', 'last_mod_date'); + $contact_default_sort_order = $settings->get('contact', 'default_sort_order', 'desc'); $sql .= order_by($contact_default_sort_column, $contact_default_sort_order); if ($db_type == "pgsql") { diff --git a/core/contacts/resources/classes/contacts.php b/core/contacts/resources/classes/contacts.php index 65bc69f561..fb8fe45727 100644 --- a/core/contacts/resources/classes/contacts.php +++ b/core/contacts/resources/classes/contacts.php @@ -33,11 +33,27 @@ const app_name = 'contacts'; const app_uuid = '04481e0e-a478-c559-adad-52bd4174574c'; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + /** * declare private variables */ - - private $database; private $permission_prefix; private $list_page; private $tables; @@ -51,7 +67,12 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); //assign private variables $this->permission_prefix = 'contact_'; @@ -69,12 +90,6 @@ $this->tables[] = 'contact_users'; $this->tables[] = 'contacts'; $this->uuid_prefix = 'contact_'; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } - } /** @@ -104,7 +119,7 @@ if (is_array($this->tables) && @sizeof($this->tables) != 0) { foreach ($this->tables as $table) { $array[$table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; - $array[$table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$table][$x]['domain_uuid'] = $this->domain_uuid; } } } @@ -161,7 +176,7 @@ if ($property['checked'] == 'true' && is_uuid($property['uuid'])) { $array[$property_name][$x][database::singular($property_name).'_uuid'] = $property['uuid']; $array[$property_name][$x]['contact_uuid'] = $this->contact_uuid; - $array[$property_name][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$property_name][$x]['domain_uuid'] = $this->domain_uuid; $x++; } } diff --git a/core/dashboard/index.php b/core/dashboard/index.php index 2c7a06749a..38b8091659 100644 --- a/core/dashboard/index.php +++ b/core/dashboard/index.php @@ -47,7 +47,7 @@ //disable login message if (isset($_GET['msg']) && $_GET['msg'] == 'dismiss') { - unset($_SESSION['login']['message']['text']); + unset($_SESSION['login']['message']); $sql = "update v_default_settings "; $sql .= "set default_setting_enabled = false "; @@ -262,8 +262,8 @@ echo "
\n"; //display login message - //if (if_group("superadmin") && isset($_SESSION['login']['message']['text']) && $_SESSION['login']['message']['text'] != '') { - // echo "\n"; + //if (if_group("superadmin") && !empty($settings->get('login', 'message')) && $settings->get('login', 'message') != '') { + // echo "\n"; //} ?> @@ -351,7 +351,7 @@ foreach ($widgets as $row) { echo "}\n"; } if (!empty($row['widget_background_color'])) { - $background_color = json_decode($row['widget_background_color'], true); + $background_color = json_validate($row['widget_background_color']) ? json_decode($row['widget_background_color'], true) : $row['widget_background_color']; echo "#".$widget_id." > .hud_box:first-of-type {\n"; echo " background: ".$background_color[0].";\n"; if (empty($row['widget_background_gradient_style']) || $row['widget_background_gradient_style'] == 'mirror') { @@ -363,7 +363,7 @@ foreach ($widgets as $row) { echo "}\n"; } if (!empty($row['widget_background_color_hover'])) { - $background_color_hover = json_decode($row['widget_background_color_hover'], true); + $background_color_hover = json_validate($row['widget_background_color_hover']) ? json_decode($row['widget_background_color_hover'], true) : $row['widget_background_color_hover']; echo "#".$widget_id.":hover > .hud_box:first-of-type {\n"; echo " background: ".$background_color_hover[0].";\n"; if (empty($row['widget_background_gradient_style']) || $row['widget_background_gradient_style'] == 'mirror') { @@ -375,7 +375,7 @@ foreach ($widgets as $row) { echo "}\n"; } if (!empty($row['widget_detail_background_color'])) { - $detail_background_color = json_decode($row['widget_detail_background_color'], true); + $detail_background_color = json_validate($row['widget_detail_background_color']) ? json_decode($row['widget_detail_background_color'], true) : $row['widget_detail_background_color']; echo "#".$widget_id." > .hud_box > .hud_details {\n"; echo " background: ".$detail_background_color[0].";\n"; if (empty($row['widget_background_gradient_style']) || $row['widget_background_gradient_style'] == 'mirror') { @@ -753,7 +753,7 @@ window.addEventListener('resize', update_parent_height); .ghost { border: 2px dashed rgba(0,0,0,1); - + get('theme', 'dashboard_border_radius') ?? null, '5px'); ?> -webkit-border-radius: ; -moz-border-radius: ; border-radius: ; diff --git a/core/dashboard/resources/classes/dashboard.php b/core/dashboard/resources/classes/dashboard.php index 71f758cc31..87914225ec 100644 --- a/core/dashboard/resources/classes/dashboard.php +++ b/core/dashboard/resources/classes/dashboard.php @@ -51,7 +51,10 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set objects + $this->database = $setting_array['database'] ?? database::new(); + //assign the variables $this->tables[] = 'dashboards'; $this->tables[] = 'dashboard_widgets'; @@ -61,11 +64,6 @@ $this->description_field = 'dashboard_description'; $this->location = 'dashboard.php'; $this->uuid_prefix = 'dashboard_'; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } } /** diff --git a/core/dashboard/resources/dashboard/content.php b/core/dashboard/resources/dashboard/content.php index 13340a61ae..e07f047fe7 100644 --- a/core/dashboard/resources/dashboard/content.php +++ b/core/dashboard/resources/dashboard/content.php @@ -6,7 +6,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'core/dashboard'); + $text = $language->get($settings->get('domain', 'language', 'en-us'), 'core/dashboard'); //prepare the settings $widget_content_length = strlen($widget_content); diff --git a/core/dashboard/resources/dashboard/icon.php b/core/dashboard/resources/dashboard/icon.php index 6a0c845a5d..16eab8f64b 100644 --- a/core/dashboard/resources/dashboard/icon.php +++ b/core/dashboard/resources/dashboard/icon.php @@ -9,7 +9,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], dirname($widget_url)); + $text = $language->get($settings->get('domain', 'language', 'en-us'), dirname($widget_url)); //get the dashboard label $widget_label = $text['title-'.$widget_key] ?? $widget_name; diff --git a/core/dashboard/resources/dashboard/parent.php b/core/dashboard/resources/dashboard/parent.php index 568f523be9..921f6da21f 100644 --- a/core/dashboard/resources/dashboard/parent.php +++ b/core/dashboard/resources/dashboard/parent.php @@ -9,7 +9,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], dirname($widget_url)); + $text = $language->get($settings->get('domain', 'language', 'en-us'), dirname($widget_url)); //get the dashboard label $widget_label = $text['title-'.$widget_key] ?? ''; diff --git a/core/databases/databases.php b/core/databases/databases.php index 80efa36bd0..344dbedb40 100644 --- a/core/databases/databases.php +++ b/core/databases/databases.php @@ -79,7 +79,7 @@ $num_rows = $database->select($sql, null, 'column'); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = ""; $page = isset($_GET['page']) ? $_GET['page'] : 0; list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); diff --git a/core/default_settings/default_setting_edit.php b/core/default_settings/default_setting_edit.php index e31a2f6d39..d6aad054c0 100644 --- a/core/default_settings/default_setting_edit.php +++ b/core/default_settings/default_setting_edit.php @@ -47,7 +47,7 @@ $default_setting_name = ''; $default_setting_value = ''; $default_setting_order = ''; - $default_setting_enabled = ''; + $default_setting_enabled = true; $default_setting_description = ''; $search = ''; @@ -72,7 +72,7 @@ $default_setting_name = strtolower($_POST["default_setting_name"] ?? ''); $default_setting_value = $_POST["default_setting_value"] ?? ''; $default_setting_order = $_POST["default_setting_order"] ?? ''; - $default_setting_enabled = $_POST["default_setting_enabled"]; + $default_setting_enabled = $_POST["default_setting_enabled"] ?? true; $default_setting_description = $_POST["default_setting_description"] ?? ''; } @@ -120,7 +120,7 @@ if (empty($default_setting_name)) { $msg .= $text['message-required'].$text['label-type']."
\n"; } //if (empty($default_setting_value)) { $msg .= $text['message-required'].$text['label-value']."
\n"; } if (empty($default_setting_order)) { $msg .= $text['message-required'].$text['label-order']."
\n"; } - if (empty($default_setting_enabled)) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } + //if (empty($default_setting_enabled)) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } //if (empty($default_setting_description)) { $msg .= $text['message-required'].$text['label-description']."
\n"; } if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; @@ -217,7 +217,7 @@ $database->save($array); $message = $database->message; - //reset the cache for settings object + //reset the cache for the settings object settings::clear_cache(); //reset others @@ -745,7 +745,7 @@ echo " \n"; } else { - if (!empty($_SESSION['domain']['setting_value_input_type']) && $_SESSION['domain']['setting_value_input_type']['text'] == 'textarea') { + if (!empty($_SESSION['domain']['setting_value_input_type']) && $settings->get('domain', 'setting_value_input_type') == 'textarea') { echo " \n"; } else { diff --git a/core/default_settings/default_settings.php b/core/default_settings/default_settings.php index 5d0151b295..cc779ff59e 100644 --- a/core/default_settings/default_settings.php +++ b/core/default_settings/default_settings.php @@ -483,7 +483,7 @@ echo escape($row['default_setting_subcategory']); } echo " \n"; - if (isset($_SESSION['default_settings']['display_order']['text']) && $_SESSION['default_settings']['display_order']['text'] == 'inline') { + if (!empty($settings->get('default_settings', 'display_order')) && $settings->get('default_settings', 'display_order') == 'inline') { $setting_types = ['Array','Boolean','Code','Dir','Name','Numeric','Text','UUID']; echo " ".$setting_types[array_search(strtolower($row['default_setting_name']), array_map('strtolower',$setting_types))].($row['default_setting_name'] == 'array' && isset($row['default_setting_order']) ? ' ('.$row['default_setting_order'].')' : null)."
\n"; } diff --git a/core/default_settings/resources/classes/default_settings.php b/core/default_settings/resources/classes/default_settings.php index ef2028b187..18a808ec16 100644 --- a/core/default_settings/resources/classes/default_settings.php +++ b/core/default_settings/resources/classes/default_settings.php @@ -35,32 +35,49 @@ const app_name = 'default_settings'; const app_uuid = '2c2453c0-1bea-4475-9f44-4d969650de09'; + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + public $domain_uuid; + + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + /** * declare private variables */ - private $database; private $name; private $table; private $toggle_field; private $toggle_values; private $location; - public $domain_uuid; /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + //assign the variables $this->name = 'default_setting'; $this->table = 'default_settings'; $this->toggle_field = 'default_setting_enabled'; $this->toggle_values = ['true','false']; $this->location = 'default_settings.php'; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } } /** diff --git a/core/domain_settings/domain_setting_edit.php b/core/domain_settings/domain_setting_edit.php index aec302eb0a..42f794f85c 100644 --- a/core/domain_settings/domain_setting_edit.php +++ b/core/domain_settings/domain_setting_edit.php @@ -775,7 +775,7 @@ echo " \n"; } else { - if (!empty($_SESSION['domain']['setting_value_input_type']) && $_SESSION['domain']['setting_value_input_type']['text'] == 'textarea') { + if (!empty($_SESSION['domain']['setting_value_input_type']) && $settings->get('domain', 'setting_value_input_type') == 'textarea') { echo " \n"; } else { diff --git a/core/domain_settings/resources/classes/domain_settings.php b/core/domain_settings/resources/classes/domain_settings.php index d39edfde5a..57e5debec7 100644 --- a/core/domain_settings/resources/classes/domain_settings.php +++ b/core/domain_settings/resources/classes/domain_settings.php @@ -33,11 +33,32 @@ const app_name = 'domain_settings'; const app_uuid = 'b31e723a-bf70-670c-a49b-470d2a232f71'; + /** + * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + public $domain_name; + + /** + * declare public variables + */ + public $domain_uuid_target; + + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + /** * declare private variables */ - - private $database; private $permission_prefix; private $list_page; private $table; @@ -45,16 +66,15 @@ private $toggle_field; private $toggle_values; - /** - * declare public variables - */ - public $domain_uuid; - public $domain_uuid_target; - /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); //assign private variables $this->permission_prefix = 'domain_setting_'; @@ -63,11 +83,6 @@ $this->uuid_prefix = 'domain_setting_'; $this->toggle_field = 'domain_setting_enabled'; $this->toggle_values = ['true','false']; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } } /** diff --git a/core/domains/domain_edit.php b/core/domains/domain_edit.php index b00315b783..ab12b7850d 100644 --- a/core/domains/domain_edit.php +++ b/core/domains/domain_edit.php @@ -162,16 +162,16 @@ } //create the recordings directory for the new domain. - if (isset($_SESSION['switch']['recordings']['dir']) && !empty($_SESSION['switch']['recordings']['dir'])) { - if (!file_exists($_SESSION['switch']['recordings']['dir']."/".$domain_name)) { - mkdir($_SESSION['switch']['recordings']['dir']."/".$domain_name, 0770); + if (!empty($settings->get('switch', 'recordings')) && !empty($settings->get('switch', 'recordings'))) { + if (!file_exists($settings->get('switch', 'recordings')."/".$domain_name)) { + mkdir($settings->get('switch', 'recordings')."/".$domain_name, 0770); } } //create the voicemail directory for the new domain. - if (isset($_SESSION['switch']['voicemail']['dir']) && !empty($_SESSION['switch']['voicemail']['dir'])) { - if (!file_exists($_SESSION['switch']['voicemail']['dir']."/default/".$domain_name)) { - mkdir($_SESSION['switch']['voicemail']['dir']."/default/".$domain_name, 0770); + if (!empty($settings->get('switch', 'voicemail')) && !empty($settings->get('switch', 'voicemail'))) { + if (!file_exists($settings->get('switch', 'voicemail')."/default/".$domain_name)) { + mkdir($settings->get('switch', 'voicemail')."/default/".$domain_name, 0770); } } @@ -407,69 +407,69 @@ } //rename switch/storage/voicemail/default/[domain] (folder) - if (isset($_SESSION['switch']['voicemail']['dir']) && file_exists($_SESSION['switch']['voicemail']['dir']."/default/".$original_domain_name)) { - @rename($_SESSION['switch']['voicemail']['dir']."/default/".$original_domain_name, $_SESSION['switch']['voicemail']['dir']."/default/".$domain_name); // folder + if (!empty($settings->get('switch', 'voicemail')) && file_exists($settings->get('switch', 'voicemail')."/default/".$original_domain_name)) { + @rename($settings->get('switch', 'voicemail')."/default/".$original_domain_name, $settings->get('switch', 'voicemail')."/default/".$domain_name); // folder } //rename switch/storage/fax/[domain] (folder) - if (isset($_SESSION['switch']['storage']['dir']) && file_exists($_SESSION['switch']['storage']['dir']."/fax/".$original_domain_name)) { - @rename($_SESSION['switch']['storage']['dir']."/fax/".$original_domain_name, $_SESSION['switch']['storage']['dir']."/fax/".$domain_name); // folder + if (!empty($settings->get('switch', 'storage')) && file_exists($settings->get('switch', 'storage')."/fax/".$original_domain_name)) { + @rename($settings->get('switch', 'storage')."/fax/".$original_domain_name, $settings->get('switch', 'storage')."/fax/".$domain_name); // folder } //rename switch/conf/dialplan/[domain] (folder/file) - if (isset($_SESSION['switch']['dialplan']['dir'])) { - if (file_exists($_SESSION['switch']['dialplan']['dir']."/".$original_domain_name)) { - @rename($_SESSION['switch']['dialplan']['dir']."/".$original_domain_name, $_SESSION['switch']['dialplan']['dir']."/".$domain_name); // folder + if (!empty($settings->get('switch', 'dialplan'))) { + if (file_exists($settings->get('switch', 'dialplan')."/".$original_domain_name)) { + @rename($settings->get('switch', 'dialplan')."/".$original_domain_name, $settings->get('switch', 'dialplan')."/".$domain_name); // folder } - if (file_exists($_SESSION['switch']['dialplan']['dir']."/".$original_domain_name.".xml")) { - @rename($_SESSION['switch']['dialplan']['dir']."/".$original_domain_name.".xml", $_SESSION['switch']['dialplan']['dir']."/".$domain_name.".xml"); // file + if (file_exists($settings->get('switch', 'dialplan')."/".$original_domain_name.".xml")) { + @rename($settings->get('switch', 'dialplan')."/".$original_domain_name.".xml", $settings->get('switch', 'dialplan')."/".$domain_name.".xml"); // file } } //rename switch/conf/dialplan/public/[domain] (folder/file) - if (isset($_SESSION['switch']['dialplan']['dir'])) { - if (file_exists($_SESSION['switch']['dialplan']['dir']."/public/".$original_domain_name)) { - @rename($_SESSION['switch']['dialplan']['dir']."/public/".$original_domain_name, $_SESSION['switch']['dialplan']['dir']."/public/".$domain_name); // folder + if (!empty($settings->get('switch', 'dialplan'))) { + if (file_exists($settings->get('switch', 'dialplan')."/public/".$original_domain_name)) { + @rename($settings->get('switch', 'dialplan')."/public/".$original_domain_name, $settings->get('switch', 'dialplan')."/public/".$domain_name); // folder } - if (file_exists($_SESSION['switch']['dialplan']['dir']."/public/".$original_domain_name.".xml")) { - @rename($_SESSION['switch']['dialplan']['dir']."/public/".$original_domain_name.".xml", $_SESSION['switch']['dialplan']['dir']."/public/".$domain_name.".xml"); // file + if (file_exists($settings->get('switch', 'dialplan')."/public/".$original_domain_name.".xml")) { + @rename($settings->get('switch', 'dialplan')."/public/".$original_domain_name.".xml", $settings->get('switch', 'dialplan')."/public/".$domain_name.".xml"); // file } } //rename switch/conf/directory/[domain] (folder/file) - if (isset($_SESSION['switch']['extensions']['dir'])) { - if (file_exists($_SESSION['switch']['extensions']['dir']."/".$original_domain_name)) { - @rename($_SESSION['switch']['extensions']['dir']."/".$original_domain_name, $_SESSION['switch']['extensions']['dir']."/".$domain_name); // folder + if (!empty($settings->get('switch', 'extensions'))) { + if (file_exists($settings->get('switch', 'extensions')."/".$original_domain_name)) { + @rename($settings->get('switch', 'extensions')."/".$original_domain_name, $settings->get('switch', 'extensions')."/".$domain_name); // folder } - if (file_exists($_SESSION['switch']['extensions']['dir']."/".$original_domain_name.".xml")) { - @rename($_SESSION['switch']['extensions']['dir']."/".$original_domain_name.".xml", $_SESSION['switch']['extensions']['dir']."/".$domain_name.".xml"); // file + if (file_exists($settings->get('switch', 'extensions')."/".$original_domain_name.".xml")) { + @rename($settings->get('switch', 'extensions')."/".$original_domain_name.".xml", $settings->get('switch', 'extensions')."/".$domain_name.".xml"); // file } } //rename switch/recordings/[domain] (folder) - if (file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'])) { - $switch_recordings_dir = str_replace("/".$_SESSION["domain_name"], "", $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']); + if (file_exists($settings->get('switch', 'recordings')."/".$_SESSION['domain_name'])) { + $switch_recordings_dir = str_replace("/".$_SESSION["domain_name"], "", $settings->get('switch', 'recordings')."/".$_SESSION['domain_name']); if (file_exists($switch_recordings_dir."/".$original_domain_name)) { @rename($switch_recordings_dir."/".$original_domain_name, $switch_recordings_dir."/".$domain_name); // folder } } //update dialplan, dialplan/public xml files - $dialplan_xml = file_get_contents($_SESSION['switch']['dialplan']['dir']."/".$domain_name.".xml"); + $dialplan_xml = file_get_contents($settings->get('switch', 'dialplan')."/".$domain_name.".xml"); $dialplan_xml = str_replace($original_domain_name, $domain_name, $dialplan_xml); - file_put_contents($_SESSION['switch']['dialplan']['dir']."/".$domain_name.".xml", $dialplan_xml); + file_put_contents($settings->get('switch', 'dialplan')."/".$domain_name.".xml", $dialplan_xml); unset($dialplan_xml); - $dialplan_public_xml = file_get_contents($_SESSION['switch']['dialplan']['dir']."/public/".$domain_name.".xml"); + $dialplan_public_xml = file_get_contents($settings->get('switch', 'dialplan')."/public/".$domain_name.".xml"); $dialplan_public_xml = str_replace($original_domain_name, $domain_name, $dialplan_public_xml); - file_put_contents($_SESSION['switch']['dialplan']['dir']."/public/".$domain_name.".xml", $dialplan_public_xml); + file_put_contents($settings->get('switch', 'dialplan')."/public/".$domain_name.".xml", $dialplan_public_xml); unset($dialplan_public_xml); //update session domain name $_SESSION['domains'][$domain_uuid]['domain_name'] = $domain_name; //recreate dialplan and extension xml files - if (is_readable($_SESSION['switch']['extensions']['dir'])) { + if (is_readable($settings->get('switch', 'extensions'))) { $extension = new extension; $extension->xml(); } diff --git a/core/domains/domains.php b/core/domains/domains.php index eee3f53bee..1702b433c1 100644 --- a/core/domains/domains.php +++ b/core/domains/domains.php @@ -61,7 +61,6 @@ $_SESSION["previous_domain_uuid"] = $_SESSION['domain_uuid']; $_SESSION['domain_uuid'] = $domain_uuid; $_SESSION["domain_name"] = $_SESSION['domains'][$domain_uuid]['domain_name']; - $_SESSION['domain']['template']['name'] = $_SESSION['domains'][$domain_uuid]['template_name'] ?? null; $_SESSION["context"] = $_SESSION["domain_name"]; //clear the extension array so that it is regenerated for the selected domain @@ -71,17 +70,17 @@ $domain = new domains(); $domain->set(); - //initialize the settigns object - $settings = new settings(['database' => $database]); + //initialize the settings object + $settings = new settings(['database' => $database, 'domain_uuid' => $domain_uuid, 'user_uuid' => $user_uuid]); //reload domain on domain change, if enabled if ($settings->get('menu', 'domain_change_reload', false)) { - //unset the sesssion menu array + //unset the session menu array unset($_SESSION['menu']['array']); //get the menu array and save it to the session $menu = new menu; - $menu->menu_uuid = $_SESSION['domain']['menu']['uuid']; + $menu->menu_uuid = $settings->get('domain', 'menu'); $_SESSION['menu']['array'] = $menu->menu_array(); unset($menu); } @@ -89,7 +88,7 @@ //redirect the user if (!empty($_SESSION["login"]["destination"])) { // to default, or domain specific, login destination - header("Location: ".PROJECT_PATH.$_SESSION["login"]["destination"]["text"]); + header("Location: ".PROJECT_PATH.$settings->get('login', 'destination')); } else { header("Location: ".PROJECT_PATH."/core/dashboard/"); @@ -173,7 +172,7 @@ $num_rows = $database->select($sql, $parameters ?? null, 'column'); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = $search ? "&search=".$search : null; $page = !empty($_GET['page']) ? $_GET['page'] : 0; list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); diff --git a/core/domains/resources/dashboard/domains.php b/core/domains/resources/dashboard/domains.php index 259040b868..4e5b8c5ff0 100644 --- a/core/domains/resources/dashboard/domains.php +++ b/core/domains/resources/dashboard/domains.php @@ -9,7 +9,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], dirname($widget_url)); + $text = $language->get($settings->get('domain', 'language', 'en-us'), dirname($widget_url)); //get the dashboard label $widget_label = $text['title-'.$widget_key]; diff --git a/core/email_templates/email_template_edit.php b/core/email_templates/email_template_edit.php index 1661b68346..1d2ae869b1 100644 --- a/core/email_templates/email_template_edit.php +++ b/core/email_templates/email_template_edit.php @@ -180,14 +180,14 @@ } //load editor preferences/defaults - $setting_size = !empty($_SESSION["editor"]["font_size"]["text"]) ? $_SESSION["editor"]["font_size"]["text"] : '12px'; - $setting_theme = !empty($_SESSION["editor"]["theme"]["text"]) ? $_SESSION["editor"]["theme"]["text"] : 'cobalt'; - $setting_invisibles = isset($_SESSION['editor']['invisibles']['text']) ? $_SESSION['editor']['invisibles']["text"] : 'false'; - $setting_indenting = isset($_SESSION['editor']['indent_guides']['text']) ? $_SESSION['editor']['indent_guides']["text"]: 'false'; - $setting_numbering = isset($_SESSION['editor']['line_numbers']['text']) ? $_SESSION['editor']['line_numbers']["text"] : 'true'; + $setting_size = !empty($settings->get('editor', 'font_size')) ? $settings->get('editor', 'font_size') : '12px'; + $setting_theme = !empty($settings->get('editor', 'theme')) ? $settings->get('editor', 'theme') : 'cobalt'; + $setting_invisibles = $settings->get('editor', 'invisibles', 'false'); + $setting_indenting = $settings->get('editor', 'indent_guides', 'false'); + $setting_numbering = $settings->get('editor', 'line_numbers', 'true'); //set the defaults - if ($template_enabled === null) { $template_enabled = true; } + $template_enabled = $template_enabled ?? true; //create token $object = new token; diff --git a/core/email_templates/email_templates.php b/core/email_templates/email_templates.php index 6c94bb0a57..8877914765 100644 --- a/core/email_templates/email_templates.php +++ b/core/email_templates/email_templates.php @@ -125,7 +125,7 @@ $num_rows = $database->select($sql, $parameters ?? '', 'column'); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = $settings->get('domain', 'paging', 50); $param = "&search=".$search; if (!empty($_GET['show']) == "all" && permission_exists('email_template_all')) { $param .= "&show=all"; @@ -283,7 +283,7 @@ $list_row_url = ''; if (permission_exists('email_template_edit')) { $list_row_url = "email_template_edit.php?id=".urlencode($row['email_template_uuid']); - if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { + if (!empty($row['domain_uuid']) && $row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true'; } } diff --git a/core/email_templates/resources/classes/email_templates.php b/core/email_templates/resources/classes/email_templates.php index 06b9e3c2ec..cea75612a1 100644 --- a/core/email_templates/resources/classes/email_templates.php +++ b/core/email_templates/resources/classes/email_templates.php @@ -33,11 +33,27 @@ const app_name = 'email_templates'; const app_uuid = '8173e738-2523-46d5-8943-13883befd2fd'; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + /** * declare private variables */ - - private $database; private $permission_prefix; private $list_page; private $table; @@ -48,7 +64,12 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); //assign private variables $this->permission_prefix = 'email_template_'; @@ -57,12 +78,6 @@ $this->uuid_prefix = 'email_template_'; $this->toggle_field = 'template_enabled'; $this->toggle_values = ['true','false']; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } - } /** @@ -139,7 +154,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -207,7 +222,7 @@ $sql = "select * from v_".$this->table." "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $x => $row) { diff --git a/core/groups/resources/classes/permission.php b/core/groups/resources/classes/permission.php index c71f7b3faf..1786bc068d 100644 --- a/core/groups/resources/classes/permission.php +++ b/core/groups/resources/classes/permission.php @@ -42,12 +42,9 @@ /** * called when the object is created */ - public function __construct() { - - //assign the database - if (empty($this->database)) { - $this->database = database::new(); - } + public function __construct(array $setting_array = []) { + //set objects + $this->database = $setting_array['database'] ?? database::new(); } //delete the permissions @@ -138,7 +135,7 @@ //delete the group permissions $this->delete(); - + //get the remaining group permissions $sql = "select permission_name, group_name from v_group_permissions "; $this->database_group_permissions = $this->database->select($sql, null, 'all'); diff --git a/core/install/install.php b/core/install/install.php index cc64e42eaf..ee8656c9ea 100644 --- a/core/install/install.php +++ b/core/install/install.php @@ -330,9 +330,9 @@ ini_set('max_execution_time',3600); //set a default template - $_SESSION['domain']['template']['name'] = 'default'; - $_SESSION['theme']['menu_brand_image']['text'] = PROJECT_PATH.'/themes/default/images/logo.png'; - $_SESSION['theme']['menu_brand_type']['text'] = 'image'; + $settings->get('domain', 'template') = 'default'; + $settings->get('theme', 'menu_brand_image') = PROJECT_PATH.'/themes/default/images/logo.png'; + $settings->get('theme', 'menu_brand_type') = 'image'; //set a default step if not already set if(empty($_REQUEST['step'])) { diff --git a/core/menu/menu_item_list.php b/core/menu/menu_item_list.php index dc534059ac..9a0573e448 100644 --- a/core/menu/menu_item_list.php +++ b/core/menu/menu_item_list.php @@ -241,7 +241,7 @@ //get the group list $sql = "select group_uuid, group_name from v_groups "; - $groups = $database->select($sql, $parameters, 'all'); + $groups = $database->select($sql, null, 'all'); unset($sql, $parameters); //create token diff --git a/core/menu/menu_reload.php b/core/menu/menu_reload.php index 39983451bd..92166a5039 100644 --- a/core/menu/menu_reload.php +++ b/core/menu/menu_reload.php @@ -49,7 +49,7 @@ //get the menu array and save it to the session $menu = new menu; - $menu->menu_uuid = $_SESSION['domain']['menu']['uuid']; + $menu->menu_uuid = $settings->get('domain', 'menu'); $_SESSION['menu']['array'] = $menu->menu_array(); unset($menu); diff --git a/core/menu/menu_restore_default.php b/core/menu/menu_restore_default.php index 163b695613..bbabeb096f 100644 --- a/core/menu/menu_restore_default.php +++ b/core/menu/menu_restore_default.php @@ -24,10 +24,11 @@ Mark J Crane */ +//includes files + require_once dirname(__DIR__, 2) . "/resources/require.php"; + //check permissions if(!defined('STDIN')) { - //includes files - require_once dirname(__DIR__, 2) . "/resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('menu_restore')) { //access granted @@ -60,7 +61,7 @@ //get the menu array and save it to the session $menu = new menu; - $menu->menu_uuid = $_SESSION['domain']['menu']['uuid'] ?? null; + $menu->menu_uuid = $settings->get('domain', 'menu') ?? null; $_SESSION['menu']['array'] = $menu->menu_array(); unset($menu); diff --git a/core/upgrade/index.php b/core/upgrade/index.php index 8ada90a323..360a2a9580 100644 --- a/core/upgrade/index.php +++ b/core/upgrade/index.php @@ -60,7 +60,7 @@ $updateable_repos[$app_path]['name'] = $apps[$x]['name']; $updateable_repos[$app_path]['uuid'] = $apps[$x]['uuid']; $updateable_repos[$app_path]['version'] = $apps[$x]['version']; - $updateable_repos[$app_path]['description'] = $apps[$x]['description'][$_SESSION['domain']['language']['code']]; + $updateable_repos[$app_path]['description'] = $apps[$x]['description'][$settings->get('domain', 'language', 'en-us')]; unset($apps, $updateable_repos[$app_path][0]); } } @@ -241,7 +241,7 @@ //adjust color and initialize step counter $step = 1; - $step_color = isset($_SESSION['theme']['upgrade_step_color']['text']) ? $_SESSION['theme']['upgrade_step_color']['text'] : color_adjust((!empty($_SESSION['theme']['form_table_label_background_color']['text']) ? $_SESSION['theme']['form_table_label_background_color']['text'] : '#e5e9f0'), -0.1); + $step_color = !empty($settings->get('theme', 'upgrade_step_color')) ? $settings->get('theme', 'upgrade_step_color') : color_adjust((!empty($settings->get('theme', 'form_table_label_background_color')) ? $settings->get('theme', 'form_table_label_background_color') : '#e5e9f0'), -0.1); $step_container_style = "width: 30px; height: 30px; border: 2px solid ".$step_color."; border-radius: 50%; float: left; text-align: center; vertical-align: middle;"; $step_number_style = "font-size: 150%; font-weight: 600; color: ".$step_color.";"; @@ -297,7 +297,7 @@ echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; diff --git a/core/user_logs/resources/classes/user_logs.php b/core/user_logs/resources/classes/user_logs.php index 292a71f418..6fedd34916 100644 --- a/core/user_logs/resources/classes/user_logs.php +++ b/core/user_logs/resources/classes/user_logs.php @@ -36,30 +36,49 @@ const app_uuid = '582a13cf-7d75-4ea3-b2d9-60914352d76e'; /** - * declare private variables + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object */ private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + + /** + * declare private variables + */ private $name; private $table; private $toggle_field; private $toggle_values; private $location; + /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + //assign the variables $this->name = 'user_log'; $this->table = 'user_logs'; $this->toggle_field = ''; $this->toggle_values = ['true','false']; $this->location = 'user_logs.php'; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } } /** @@ -128,7 +147,7 @@ //add to the array if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { $array[$this->table][$x][$this->name.'_uuid'] = $record['uuid']; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; } //increment the id diff --git a/core/user_logs/user_logs.php b/core/user_logs/user_logs.php index f869278bfc..5b2d1a75c2 100644 --- a/core/user_logs/user_logs.php +++ b/core/user_logs/user_logs.php @@ -41,7 +41,7 @@ //set config object global $config; - if (!($confing instanceof config)) { + if (!($config instanceof config)) { $config = config::load(); } diff --git a/core/user_settings/resources/classes/user_settings.php b/core/user_settings/resources/classes/user_settings.php index 7f6c24d0e2..8aed87cda2 100644 --- a/core/user_settings/resources/classes/user_settings.php +++ b/core/user_settings/resources/classes/user_settings.php @@ -33,11 +33,27 @@ const app_name = 'user_settings'; const app_uuid = '3a3337f7-78d1-23e3-0cfd-f14499b8ed97'; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + /** * declare private variables */ - - private $database; private $permission_prefix; private $list_page; private $table; @@ -53,7 +69,12 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); //assign private variables $this->permission_prefix = 'user_setting_'; @@ -62,11 +83,6 @@ $this->uuid_prefix = 'user_setting_'; $this->toggle_field = 'user_setting_enabled'; $this->toggle_values = ['true','false']; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } } /** @@ -94,7 +110,7 @@ foreach ($records as $x => $record) { if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; - $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; } } @@ -144,7 +160,7 @@ $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $this->domain_uuid; $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { diff --git a/core/user_settings/user_setting_edit.php b/core/user_settings/user_setting_edit.php index b69c525a08..d98e2969f6 100644 --- a/core/user_settings/user_setting_edit.php +++ b/core/user_settings/user_setting_edit.php @@ -81,7 +81,7 @@ $user_setting_name = strtolower($_POST["user_setting_name"] ?? ''); $user_setting_value = $_POST["user_setting_value"] ?? ''; $user_setting_order = $_POST["user_setting_order"] ?? ''; - $user_setting_enabled = $_POST["user_setting_enabled"]; + $user_setting_enabled = $_POST["user_setting_enabled"] ?? true; $user_setting_description = $_POST["user_setting_description"] ?? ''; } @@ -689,7 +689,7 @@ if (!empty($_POST) && empty($_POST["persistformvar"])) { echo " \n"; } else { - if (!empty($_SESSION['domain']['setting_value_input_type']) && $_SESSION['domain']['setting_value_input_type']['text'] == 'textarea') { + if (!empty($_SESSION['domain']['setting_value_input_type']) && $settings->get('domain', 'setting_value_input_type') == 'textarea') { echo " \n"; } else { diff --git a/core/user_settings/user_settings.php b/core/user_settings/user_settings.php index f6dab8db1d..abd5dd0024 100644 --- a/core/user_settings/user_settings.php +++ b/core/user_settings/user_settings.php @@ -137,7 +137,7 @@ unset($sql); //prepare to page the results - $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 100; + $rows_per_page = (!empty($settings->get('domain', 'paging'))) ? $settings->get('domain', 'paging') : 100; $param = ''; $paging_controls = ''; if (isset($_GET['page'])) { diff --git a/core/users/resources/classes/users.php b/core/users/resources/classes/users.php index 41a4f31158..1f168e2ff4 100644 --- a/core/users/resources/classes/users.php +++ b/core/users/resources/classes/users.php @@ -35,12 +35,27 @@ const app_name = 'users'; const app_uuid = '112124b3-95c2-5352-7e9d-d14c0b88f207'; + /** + * Set in the constructor. Must be a database object and cannot be null. + * @var database Database Object + */ + private $database; + + /** + * Settings object set in the constructor. Must be a settings object and cannot be null. + * @var settings Settings Object + */ + private $settings; + + /** + * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array + * @var string + */ + private $domain_uuid; + /** * declare the variables */ - private $app_name; - private $app_uuid; - private $database; private $name; private $table; private $toggle_field; @@ -50,18 +65,19 @@ /** * called when the object is created */ - public function __construct() { + public function __construct(array $setting_array = []) { + //set domain and user UUIDs + $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? ''; + + //set objects + $this->database = $setting_array['database'] ?? database::new(); + //assign the variables $this->name = 'user'; $this->table = 'users'; $this->toggle_field = 'user_enabled'; $this->toggle_values = ['true','false']; $this->location = 'users.php'; - - //connect to the database - if (empty($this->database)) { - $this->database = database::new(); - } } /** @@ -101,7 +117,7 @@ unset($sql, $parameters); } else { - $domain_uuid = $_SESSION['domain_uuid']; + $domain_uuid = $this->domain_uuid; } //required to be a superadmin to delete a member of the superadmin group diff --git a/core/users/user_edit.php b/core/users/user_edit.php index 273c3254b2..97eaeba986 100644 --- a/core/users/user_edit.php +++ b/core/users/user_edit.php @@ -50,7 +50,7 @@ } //get total user count from the database, check limit, if defined - if (permission_exists('user_add') && $action == 'add' && !empty($_SESSION['limit']['users']['numeric'])) { + if (permission_exists('user_add') && $action == 'add' && !empty($settings->get('limit', 'users'))) { $sql = "select count(*) "; $sql .= "from v_users "; $sql .= "where domain_uuid = :domain_uuid "; @@ -58,8 +58,8 @@ $num_rows = $database->select($sql, $parameters, 'column'); unset($sql, $parameters); - if ($num_rows >= $_SESSION['limit']['users']['numeric']) { - message::add($text['message-maximum_users'].' '.$_SESSION['limit']['users']['numeric'], 'negative'); + if ($num_rows >= $settings->get('limit', 'users')) { + message::add($text['message-maximum_users'].' '.$settings->get('limit', 'users'), 'negative'); header('Location: users.php'); exit; } @@ -178,10 +178,10 @@ } //require a username format: any, email, no_email - if (!empty($_SESSION['users']['username_format']['text']) && $_SESSION['users']['username_format']['text'] != 'any') { + if (!empty($settings->get('users', 'username_format')) && $settings->get('users', 'username_format') != 'any') { if ( - ($_SESSION['users']['username_format']['text'] == 'email' && !valid_email($username)) || - ($_SESSION['users']['username_format']['text'] == 'no_email' && valid_email($username)) + ($settings->get('users', 'username_format') == 'email' && !valid_email($username)) || + ($settings->get('users', 'username_format') == 'no_email' && valid_email($username)) ) { message::add($text['message-username_format_invalid'], 'negative', 7500); } @@ -192,7 +192,7 @@ (permission_exists('user_add') && $action == 'add' && !empty($username))) { $sql = "select count(*) from v_users "; - if (isset($_SESSION["users"]["unique"]["text"]) && $_SESSION["users"]["unique"]["text"] == "global") { + if (!empty($settings->get('users', 'unique')) && $settings->get('users', 'unique') == "global") { $sql .= "where username = :username "; } else { diff --git a/core/users/user_imports.php b/core/users/user_imports.php index 3ee5e77d2b..de388542f0 100644 --- a/core/users/user_imports.php +++ b/core/users/user_imports.php @@ -58,7 +58,7 @@ //save the data to the csv file if (isset($_POST['data'])) { - $file = $_SESSION['server']['temp']['dir'].'/users-'.$_SESSION['domain_name'].'.csv'; + $file = $settings->get('server', 'temp').'/users-'.$_SESSION['domain_name'].'.csv'; if (file_put_contents($file, $_POST['data'])) { $_SESSION['file'] = $file; } @@ -68,7 +68,7 @@ //$_POST['submit'] == "Upload" && if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('user_import')) { if (!empty($_POST['type']) && $_POST['type'] == 'csv') { - $file = $_SESSION['server']['temp']['dir'].'/users-'.$_SESSION['domain_name'].'.csv'; + $file = $settings->get('server', 'temp').'/users-'.$_SESSION['domain_name'].'.csv'; if (move_uploaded_file($_FILES['ulfile']['tmp_name'], $file)) { $_SESSION['file'] = $file; } diff --git a/core/users/user_profile.php b/core/users/user_profile.php index fd8947336a..bf59a9f195 100644 --- a/core/users/user_profile.php +++ b/core/users/user_profile.php @@ -35,6 +35,9 @@ //get the user uuid $user_uuid = $_SESSION['user_uuid']; +//set the action + $action = 'edit'; + //retrieve password requirements if (permission_exists('user_password')) { $required['length'] = $settings->get('users', 'password_length', 12); @@ -825,7 +828,7 @@ echo " \n"; echo " \n"; echo " "; - return $html; + } else { + $description .= $text['label-order'] . ' ' . $text['label-ascending']; + $html .= "" . escape($column_title) . ""; + } + $html .= ""; + return $html; + } +} + +if (!function_exists('get_ext')) { + function get_ext($filename) { + preg_match('/[^?]*/', $filename, $matches); + $string = $matches[0]; + + $pattern = preg_split('/\./', $string, -1, PREG_SPLIT_OFFSET_CAPTURE); + + // check if there is any extension + if (count($pattern) == 1) { + //echo 'No File Extension Present'; + return ''; } + if (count($pattern) > 1) { + $filenamepart = $pattern[count($pattern) - 1][0]; + preg_match('/[^?]*/', $filenamepart, $matches); + return $matches[0]; + } } + //echo "ext: ".get_ext('test.txt'); +} - if (!function_exists('get_ext')) { +if (!function_exists('file_upload')) { + function file_upload($field = '', $file_type = '', $dest_dir = '') { - function get_ext($filename) { - preg_match('/[^?]*/', $filename, $matches); - $string = $matches[0]; + $uploadtempdir = $_ENV["TEMP"] . "\\"; + ini_set('upload_tmp_dir', $uploadtempdir); - $pattern = preg_split('/\./', $string, -1, PREG_SPLIT_OFFSET_CAPTURE); + $tmp_name = $_FILES[$field]["tmp_name"]; + $file_name = $_FILES[$field]["name"]; + $file_type = $_FILES[$field]["type"]; + $file_size = $_FILES[$field]["size"]; + $file_ext = get_ext($file_name); + $file_name_orig = $file_name; + $file_name_base = substr($file_name, 0, (strlen($file_name) - (strlen($file_ext) + 1))); + //$dest_dir = '/tmp'; - // check if there is any extension - if (count($pattern) == 1) { - //echo 'No File Extension Present'; - return ''; + if ($file_size == 0) { + return; + } + + if (!is_dir($dest_dir)) { + echo "dest_dir not found
\n"; + return; + } + + //check if allowed file type + if ($file_type == "img") { + switch (strtolower($file_ext)) { + case "jpg": + case "png": + case "gif": + case "bmp": + case "psd": + case "tif": break; + default: return false; } - - if (count($pattern) > 1) { - $filenamepart = $pattern[count($pattern) - 1][0]; - preg_match('/[^?]*/', $filenamepart, $matches); - return $matches[0]; + } + if ($file_type == "file") { + switch (strtolower($file_ext)) { + case "doc": + case "pdf": + case "ppt": + case "xls": + case "zip": + case "exe": break; + default: return false; } } - //echo "ext: ".get_ext('test.txt'); - } - - if (!function_exists('file_upload')) { - - function file_upload($field = '', $file_type = '', $dest_dir = '') { - - $uploadtempdir = $_ENV["TEMP"] . "\\"; - ini_set('upload_tmp_dir', $uploadtempdir); - - $tmp_name = $_FILES[$field]["tmp_name"]; - $file_name = $_FILES[$field]["name"]; - $file_type = $_FILES[$field]["type"]; - $file_size = $_FILES[$field]["size"]; - $file_ext = get_ext($file_name); - $file_name_orig = $file_name; - $file_name_base = substr($file_name, 0, (strlen($file_name) - (strlen($file_ext) + 1))); - //$dest_dir = '/tmp'; - - if ($file_size == 0) { - return; - } - - if (!is_dir($dest_dir)) { - echo "dest_dir not found
\n"; - return; - } - - //check if allowed file type - if ($file_type == "img") { - switch (strtolower($file_ext)) { - case "jpg": - case "png": - case "gif": - case "bmp": - case "psd": - case "tif": break; - default: return false; - } - } - if ($file_type == "file") { - switch (strtolower($file_ext)) { - case "doc": - case "pdf": - case "ppt": - case "xls": - case "zip": - case "exe": break; - default: return false; - } - } - - //find unique filename: check if file exists if it does then increment the filename - $i = 1; - while (file_exists($dest_dir . '/' . $file_name)) { - if (!empty($file_ext)) { - $file_name = $file_name_base . $i . '.' . $file_ext; - } else { - $file_name = $file_name_orig . $i; - } - $i++; - } - - //echo "file_type: ".$file_type."
\n"; - //echo "tmp_name: ".$tmp_name."
\n"; - //echo "file_name: ".$file_name."
\n"; - //echo "file_ext: ".$file_ext."
\n"; - //echo "file_name_orig: ".$file_name_orig."
\n"; - //echo "file_name_base: ".$file_name_base."
\n"; - //echo "dest_dir: ".$dest_dir."
\n"; - //move the file to upload directory - //bool move_uploaded_file ( string $filename, string $destination ) - - if (move_uploaded_file($tmp_name, $dest_dir . '/' . $file_name)) { - return $file_name; + //find unique filename: check if file exists if it does then increment the filename + $i = 1; + while (file_exists($dest_dir . '/' . $file_name)) { + if (!empty($file_ext)) { + $file_name = $file_name_base . $i . '.' . $file_ext; } else { - echo "File upload failed! Here's some debugging info:\n"; - return false; + $file_name = $file_name_orig . $i; } - exit; + $i++; } - } + //echo "file_type: ".$file_type."
\n"; + //echo "tmp_name: ".$tmp_name."
\n"; + //echo "file_name: ".$file_name."
\n"; + //echo "file_ext: ".$file_ext."
\n"; + //echo "file_name_orig: ".$file_name_orig."
\n"; + //echo "file_name_base: ".$file_name_base."
\n"; + //echo "dest_dir: ".$dest_dir."
\n"; + //move the file to upload directory + //bool move_uploaded_file ( string $filename, string $destination ) - if (!function_exists('sys_get_temp_dir')) { - - function sys_get_temp_dir() { - if ($temp = getenv('TMP')) { - return $temp; - } - if ($temp = getenv('TEMP')) { - return $temp; - } - if ($temp = getenv('TMPDIR')) { - return $temp; - } - $temp = tempnam(__FILE__, ''); - if (file_exists($temp)) { - unlink($temp); - return dirname($temp); - } - return null; - } - - } - //echo realpath(sys_get_temp_dir()); - - if (!function_exists('normalize_path')) { - - //don't use DIRECTORY_SEPARATOR as it will change on a per platform basis and we need consistency - function normalize_path($path) { - return str_replace(array('/', '\\'), '/', $path); - } - - } - - if (!function_exists('normalize_path_to_os')) { - - function normalize_path_to_os($path) { - return str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); - } - - } - - if (!function_exists('username_exists')) { - - function username_exists($username) { - global $database, $domain_uuid; - $sql = "select count(*) from v_users "; - $sql .= "where domain_uuid = :domain_uuid "; - $sql .= "and username = :username "; - $parameters['domain_uuid'] = $domain_uuid; - $parameters['username'] = $username; - $num_rows = $database->select($sql, $parameters, 'column'); - return $num_rows > 0 ? true : false; - } - - } - - if (!function_exists('add_extension_user')) { - - function add_extension_user($extension_uuid, $username) { - global $database, $domain_uuid; - //get the user_uuid by using the username - $sql = "select user_uuid from v_users "; - $sql .= "where domain_uuid = :domain_uuid "; - $sql .= "and username = :username "; - $parameters['domain_uuid'] = $domain_uuid; - $parameters['username'] = $username; - $user_uuid = $database->select($sql, $parameters, 'column'); - unset($sql, $parameters); - - if (is_uuid($user_uuid)) { - //check if the user_uuid exists in v_extension_users - $sql = "select count(*) from v_extension_users "; - $sql .= "where domain_uuid = :domain_uuid "; - $sql .= "and user_uuid = :user_uuid "; - $parameters['domain_uuid'] = $domain_uuid; - $parameters['user_uuid'] = $user_uuid; - $num_rows = $database->select($sql, $parameters, 'column'); - unset($sql, $parameters); - - //assign the extension to the user - if ($num_rows == 0) { - //build insert array - $extension_user_uuid = uuid(); - $array['extension_users'][$x]['extension_user_uuid'] = $extension_user_uuid; - $array['extension_users'][$x]['domain_uuid'] = $domain_uuid; - $array['extension_users'][$x]['extension_uuid'] = $extension_uuid; - $array['extension_users'][$x]['user_uuid'] = $row["user_uuid"]; - //grant temporary permissions - $p = permissions::new(); - $p->add('extension_user_add', 'temp'); - //execute insert - $database->save($array); - unset($array); - //revoke temporary permissions - $p->delete('extension_user_add', 'temp'); - } - } - } - - } - - if (!function_exists('user_add')) { - - function user_add($username, $password, $user_email = '') { - global $database, $domain_uuid; - if (empty($username)) { - return false; - } - if (empty($password)) { - return false; - } - if (!username_exists($username)) { - //build user insert array - $user_uuid = uuid(); - $salt = generate_password('20', '4'); - $array['users'][0]['user_uuid'] = $user_uuid; - $array['users'][0]['domain_uuid'] = $domain_uuid; - $array['users'][0]['username'] = $username; - $array['users'][0]['password'] = md5($salt . $password); - $array['users'][0]['salt'] = $salt; - if (valid_email($user_email)) { - $array['users'][0]['user_email'] = $user_email; - } - $array['users'][0]['add_date'] = 'now()'; - $array['users'][0]['add_user'] = $_SESSION["username"]; - - //build user group insert array - $user_group_uuid = uuid(); - $array['user_groups'][0]['user_group_uuid'] = $user_group_uuid; - $array['user_groups'][0]['domain_uuid'] = $domain_uuid; - $array['user_groups'][0]['group_name'] = 'user'; - $array['user_groups'][0]['user_uuid'] = $user_uuid; - - //grant temporary permissions - $p = permissions::new(); - $p->add('user_add', 'temp'); - $p->add('user_group_add', 'temp'); - - //save the data insert - $database->save($array); - unset($array); - - //revoke temporary permissions - $p->delete('user_add', 'temp'); - $p->delete('user_group_add', 'temp'); - } - } - - } - - function switch_module_is_running($mod, event_socket $esl = null) { - //if the object does not exist create it - if ($esl === null) { - $esl = event_socket::create(); - } - //if we are not connected to freeswitch show an error message - if (!$esl->is_connected()) { + if (move_uploaded_file($tmp_name, $dest_dir . '/' . $file_name)) { + return $file_name; + } else { + echo "File upload failed! Here's some debugging info:\n"; return false; } - //send the api command to check if the module exists - $switch_result = event_socket::api("module_exists $mod"); - return (trim($switch_result) == "true"); + exit; } +} + +if (!function_exists('sys_get_temp_dir')) { + function sys_get_temp_dir() { + if ($temp = getenv('TMP')) { + return $temp; + } + if ($temp = getenv('TEMP')) { + return $temp; + } + if ($temp = getenv('TMPDIR')) { + return $temp; + } + $temp = tempnam(__FILE__, ''); + if (file_exists($temp)) { + unlink($temp); + return dirname($temp); + } + return null; + } +} +//echo realpath(sys_get_temp_dir()); + +if (!function_exists('normalize_path')) { + //don't use DIRECTORY_SEPARATOR as it will change on a per platform basis and we need consistency + function normalize_path($path) { + return str_replace(array('/', '\\'), '/', $path); + } +} + +if (!function_exists('normalize_path_to_os')) { + function normalize_path_to_os($path) { + return str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); + } +} + +if (!function_exists('username_exists')) { + function username_exists($username) { + global $database, $domain_uuid; + $sql = "select count(*) from v_users "; + $sql .= "where domain_uuid = :domain_uuid "; + $sql .= "and username = :username "; + $parameters['domain_uuid'] = $domain_uuid; + $parameters['username'] = $username; + $num_rows = $database->select($sql, $parameters, 'column'); + return $num_rows > 0 ? true : false; + } +} + +if (!function_exists('add_extension_user')) { + function add_extension_user($extension_uuid, $username) { + global $database, $domain_uuid; + //get the user_uuid by using the username + $sql = "select user_uuid from v_users "; + $sql .= "where domain_uuid = :domain_uuid "; + $sql .= "and username = :username "; + $parameters['domain_uuid'] = $domain_uuid; + $parameters['username'] = $username; + $user_uuid = $database->select($sql, $parameters, 'column'); + unset($sql, $parameters); + + if (is_uuid($user_uuid)) { + //check if the user_uuid exists in v_extension_users + $sql = "select count(*) from v_extension_users "; + $sql .= "where domain_uuid = :domain_uuid "; + $sql .= "and user_uuid = :user_uuid "; + $parameters['domain_uuid'] = $domain_uuid; + $parameters['user_uuid'] = $user_uuid; + $num_rows = $database->select($sql, $parameters, 'column'); + unset($sql, $parameters); + + //assign the extension to the user + if ($num_rows == 0) { + //build insert array + $extension_user_uuid = uuid(); + $array['extension_users'][$x]['extension_user_uuid'] = $extension_user_uuid; + $array['extension_users'][$x]['domain_uuid'] = $domain_uuid; + $array['extension_users'][$x]['extension_uuid'] = $extension_uuid; + $array['extension_users'][$x]['user_uuid'] = $row["user_uuid"]; + //grant temporary permissions + $p = permissions::new(); + $p->add('extension_user_add', 'temp'); + //execute insert + $database->save($array); + unset($array); + //revoke temporary permissions + $p->delete('extension_user_add', 'temp'); + } + } + } +} + +if (!function_exists('user_add')) { + function user_add($username, $password, $user_email = '') { + global $database, $domain_uuid; + if (empty($username)) { + return false; + } + if (empty($password)) { + return false; + } + if (!username_exists($username)) { + //build user insert array + $user_uuid = uuid(); + $salt = generate_password('20', '4'); + $array['users'][0]['user_uuid'] = $user_uuid; + $array['users'][0]['domain_uuid'] = $domain_uuid; + $array['users'][0]['username'] = $username; + $array['users'][0]['password'] = md5($salt . $password); + $array['users'][0]['salt'] = $salt; + if (valid_email($user_email)) { + $array['users'][0]['user_email'] = $user_email; + } + $array['users'][0]['add_date'] = 'now()'; + $array['users'][0]['add_user'] = $_SESSION["username"]; + + //build user group insert array + $user_group_uuid = uuid(); + $array['user_groups'][0]['user_group_uuid'] = $user_group_uuid; + $array['user_groups'][0]['domain_uuid'] = $domain_uuid; + $array['user_groups'][0]['group_name'] = 'user'; + $array['user_groups'][0]['user_uuid'] = $user_uuid; + + //grant temporary permissions + $p = permissions::new(); + $p->add('user_add', 'temp'); + $p->add('user_group_add', 'temp'); + + //save the data insert + $database->save($array); + unset($array); + + //revoke temporary permissions + $p->delete('user_add', 'temp'); + $p->delete('user_group_add', 'temp'); + } + } +} + +function switch_module_is_running($mod, event_socket $esl = null) { + //if the object does not exist create it + if ($esl === null) { + $esl = event_socket::create(); + } + //if we are not connected to freeswitch show an error message + if (!$esl->is_connected()) { + return false; + } + //send the api command to check if the module exists + $switch_result = event_socket::api("module_exists $mod"); + return (trim($switch_result) == "true"); +} //print (switch_module_is_running('mod_spidermonkey') ? "true" : "false"); //format a number (n) replace with a number (r) remove the number - function format_string($format, $data) { - //nothing to do so return - if (empty($format)) - return $data; +function format_string($format, $data) { + //nothing to do so return + if (empty($format)) { + return $data; + } - //preset values - $x = 0; - $tmp = ''; + //preset values + $x = 0; + $tmp = ''; - //count the characters - $format_count = substr_count($format, 'x'); - $format_count = $format_count + substr_count($format, 'R'); - $format_count = $format_count + substr_count($format, 'r'); + //count the characters + $format_count = substr_count($format, 'x'); + $format_count = $format_count + substr_count($format, 'R'); + $format_count = $format_count + substr_count($format, 'r'); - //format the string if it matches - if ($format_count == strlen($data)) { - for ($i = 0; $i <= strlen($format); $i++) { - $tmp_format = strtolower(substr($format, $i, 1)); - if ($tmp_format == 'x') { - $tmp .= substr($data, $x, 1); - $x++; - } elseif ($tmp_format == 'r') { - $x++; - } else { - $tmp .= $tmp_format; - } + //format the string if it matches + if ($format_count == strlen($data)) { + for ($i = 0; $i <= strlen($format); $i++) { + $tmp_format = strtolower(substr($format, $i, 1)); + if ($tmp_format == 'x') { + $tmp .= substr($data, $x, 1); + $x++; + } elseif ($tmp_format == 'r') { + $x++; + } else { + $tmp .= $tmp_format; } } - if (empty($tmp)) { - return $data; - } else { - return $tmp; - } } + if (empty($tmp)) { + return $data; + } else { + return $tmp; + } +} //get the format and use it to format the phone number - function format_phone($phone_number) { - if (is_numeric(trim($phone_number ?? '', ' +'))) { - if (isset($_SESSION["format"]["phone"])) { - $phone_number = trim($phone_number, ' +'); - foreach ($_SESSION["format"]["phone"] as $format) { - $format_count = substr_count($format, 'x'); - $format_count = $format_count + substr_count($format, 'R'); - $format_count = $format_count + substr_count($format, 'r'); - if ($format_count == strlen($phone_number)) { - //format the number - $phone_number = format_string($format, $phone_number); - } +function format_phone($phone_number) { + if (is_numeric(trim($phone_number ?? '', ' +'))) { + if (isset($_SESSION["format"]["phone"])) { + $phone_number = trim($phone_number, ' +'); + foreach ($_SESSION["format"]["phone"] as $format) { + $format_count = substr_count($format, 'x'); + $format_count = $format_count + substr_count($format, 'R'); + $format_count = $format_count + substr_count($format, 'r'); + if ($format_count == strlen($phone_number)) { + //format the number + $phone_number = format_string($format, $phone_number); } } } - return $phone_number; } + return $phone_number; +} //format seconds into hh:mm:ss - function format_hours($seconds) { - $seconds = (int) $seconds; //convert seconds to an integer - $hours = floor($seconds / 3600); - $minutes = floor(floor($seconds / 60) % 60); - $seconds = $seconds % 60; - return sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds); - } +function format_hours($seconds) { + $seconds = (int) $seconds; //convert seconds to an integer + $hours = floor($seconds / 3600); + $minutes = floor(floor($seconds / 60) % 60); + $seconds = $seconds % 60; + return sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds); +} //format seconds - function format_seconds($seconds) { - return gmdate("H:i:s", $seconds); - } +function format_seconds($seconds) { + return gmdate("H:i:s", $seconds); +} //browser detection without browscap.ini dependency - function http_user_agent($info = '') { +function http_user_agent($info = '') { - //set default values - $user_agent = $_SERVER['HTTP_USER_AGENT']; - $browser_name = 'Unknown'; - $platform = 'Unknown'; - $version = ''; - $mobile = false; + //set default values + $user_agent = $_SERVER['HTTP_USER_AGENT']; + $browser_name = 'Unknown'; + $platform = 'Unknown'; + $version = ''; + $mobile = false; - //get the platform - if (preg_match('/linux/i', $user_agent)) { - $platform = 'Linux'; - } elseif (preg_match('/macintosh|mac os x/i', $user_agent)) { - $platform = 'Apple'; - } elseif (preg_match('/windows|win32/i', $user_agent)) { - $platform = 'Windows'; - } - - //set mobile to true or false - if (preg_match('/mobile/i', $user_agent)) { - $platform = 'Mobile'; - $mobile = true; - } elseif (preg_match('/android/i', $user_agent)) { - $platform = 'Android'; - $mobile = true; - } - - //get the name of the useragent - if (preg_match('/MSIE/i', $user_agent) || preg_match('/Trident/i', $user_agent)) { - $browser_name = 'Internet Explorer'; - $browser_name_short = 'MSIE'; - } elseif (preg_match('/Firefox/i', $user_agent)) { - $browser_name = 'Mozilla Firefox'; - $browser_name_short = 'Firefox'; - } elseif (preg_match('/Chrome/i', $user_agent)) { - $browser_name = 'Google Chrome'; - $browser_name_short = 'Chrome'; - } elseif (preg_match('/Safari/i', $user_agent)) { - $browser_name = 'Apple Safari'; - $browser_name_short = 'Safari'; - } elseif (preg_match('/Opera/i', $user_agent)) { - $browser_name = 'Opera'; - $browser_name_short = 'Opera'; - } elseif (preg_match('/Netscape/i', $user_agent)) { - $browser_name = 'Netscape'; - $browser_name_short = 'Netscape'; - } else { - $browser_name = 'Unknown'; - $browser_name_short = 'Unknown'; - } - - //finally get the correct version number - $known = array('Version', $browser_name_short, 'other'); - $pattern = '#(?' . join('|', $known) . ')[/ ]+(?[0-9.|a-zA-Z.]*)#'; - if (!preg_match_all($pattern, $user_agent, $matches)) { - //we have no matching number just continue - } - - //see how many we have - $i = count($matches['browser']); - if ($i != 1) { - //we will have two since we are not using 'other' argument yet - //see if version is before or after the name - if (strripos($user_agent, "Version") < strripos($user_agent, $browser_name_short)) { - $version = $matches['version'][0]; - } else { - $version = $matches['version'][1]; - } - } else { - $version = $matches['version'][0]; - } - - //check if we have a number - if ($version == null || $version == "") { - $version = "?"; - } - - //return the data - switch ($info) { - case "agent": return $user_agent; - break; - case "name": return $browser_name; - break; - case "name_short": return $browser_name_short; - break; - case "version": return $version; - break; - case "platform": return $platform; - break; - case "mobile": return $mobile; - break; - case "pattern": return $pattern; - break; - default : - return array( - 'user_agent' => $user_agent, - 'name' => $browser_name, - 'name_short' => $browser_name_short, - 'version' => $version, - 'platform' => $platform, - 'mobile' => $mobile, - 'pattern' => $pattern - ); - } + //get the platform + if (preg_match('/linux/i', $user_agent)) { + $platform = 'Linux'; + } elseif (preg_match('/macintosh|mac os x/i', $user_agent)) { + $platform = 'Apple'; + } elseif (preg_match('/windows|win32/i', $user_agent)) { + $platform = 'Windows'; } + //set mobile to true or false + if (preg_match('/mobile/i', $user_agent)) { + $platform = 'Mobile'; + $mobile = true; + } elseif (preg_match('/android/i', $user_agent)) { + $platform = 'Android'; + $mobile = true; + } + + //get the name of the useragent + if (preg_match('/MSIE/i', $user_agent) || preg_match('/Trident/i', $user_agent)) { + $browser_name = 'Internet Explorer'; + $browser_name_short = 'MSIE'; + } elseif (preg_match('/Firefox/i', $user_agent)) { + $browser_name = 'Mozilla Firefox'; + $browser_name_short = 'Firefox'; + } elseif (preg_match('/Chrome/i', $user_agent)) { + $browser_name = 'Google Chrome'; + $browser_name_short = 'Chrome'; + } elseif (preg_match('/Safari/i', $user_agent)) { + $browser_name = 'Apple Safari'; + $browser_name_short = 'Safari'; + } elseif (preg_match('/Opera/i', $user_agent)) { + $browser_name = 'Opera'; + $browser_name_short = 'Opera'; + } elseif (preg_match('/Netscape/i', $user_agent)) { + $browser_name = 'Netscape'; + $browser_name_short = 'Netscape'; + } else { + $browser_name = 'Unknown'; + $browser_name_short = 'Unknown'; + } + + //finally get the correct version number + $known = array('Version', $browser_name_short, 'other'); + $pattern = '#(?' . join('|', $known) . ')[/ ]+(?[0-9.|a-zA-Z.]*)#'; + if (!preg_match_all($pattern, $user_agent, $matches)) { + //we have no matching number just continue + } + + //see how many we have + $i = count($matches['browser']); + if ($i != 1) { + //we will have two since we are not using 'other' argument yet + //see if version is before or after the name + if (strripos($user_agent, "Version") < strripos($user_agent, $browser_name_short)) { + $version = $matches['version'][0]; + } else { + $version = $matches['version'][1]; + } + } else { + $version = $matches['version'][0]; + } + + //check if we have a number + if ($version == null || $version == "") { + $version = "?"; + } + + //return the data + switch ($info) { + case "agent": return $user_agent; + break; + case "name": return $browser_name; + break; + case "name_short": return $browser_name_short; + break; + case "version": return $version; + break; + case "platform": return $platform; + break; + case "mobile": return $mobile; + break; + case "pattern": return $pattern; + break; + default : + return array( + 'user_agent' => $user_agent, + 'name' => $browser_name, + 'name_short' => $browser_name_short, + 'version' => $version, + 'platform' => $platform, + 'mobile' => $mobile, + 'pattern' => $pattern + ); + } +} + //tail php function for non posix systems - function tail($file, $num_to_get = 10) { - $esl = fopen($file, 'r'); - $position = filesize($file); - $chunklen = 4096; +function tail($file, $num_to_get = 10) { + $esl = fopen($file, 'r'); + $position = filesize($file); + $chunklen = 4096; + if ($position - $chunklen <= 0) { + fseek($esl, 0); + } else { + fseek($esl, $position - $chunklen); + } + $data = ""; + $ret = ""; + $lc = 0; + while ($chunklen > 0) { + $data = fread($esl, $chunklen); + $dl = strlen($data); + for ($i = $dl - 1; $i >= 0; $i--) { + if ($data[$i] == "\n") { + if ($lc == 0 && $ret != "") + $lc++; + $lc++; + if ($lc > $num_to_get) + return $ret; + } + $ret = $data[$i] . $ret; + } if ($position - $chunklen <= 0) { fseek($esl, 0); + $chunklen = $chunklen - abs($position - $chunklen); } else { fseek($esl, $position - $chunklen); } - $data = ""; - $ret = ""; - $lc = 0; - while ($chunklen > 0) { - $data = fread($esl, $chunklen); - $dl = strlen($data); - for ($i = $dl - 1; $i >= 0; $i--) { - if ($data[$i] == "\n") { - if ($lc == 0 && $ret != "") - $lc++; - $lc++; - if ($lc > $num_to_get) - return $ret; - } - $ret = $data[$i] . $ret; - } - if ($position - $chunklen <= 0) { - fseek($esl, 0); - $chunklen = $chunklen - abs($position - $chunklen); - } else { - fseek($esl, $position - $chunklen); - } - $position = $position - $chunklen; - } - return $ret; + $position = $position - $chunklen; } + return $ret; +} //generate a random password with upper, lowercase and symbols - function generate_password($length = 0, $strength = 0) { - $password = ''; - $chars = ''; - if ($length === 0 && $strength === 0) { //set length and strenth if specified in default settings and strength isn't numeric-only - $length = (is_numeric($_SESSION["users"]["password_length"]["numeric"])) ? $_SESSION["users"]["password_length"]["numeric"] : 20; - $strength = (is_numeric($_SESSION["users"]["password_strength"]["numeric"])) ? $_SESSION["users"]["password_strength"]["numeric"] : 4; - } - if ($strength >= 1) { - $chars .= "0123456789"; - } - if ($strength >= 2) { - $chars .= "abcdefghijkmnopqrstuvwxyz"; - } - if ($strength >= 3) { - $chars .= "ABCDEFGHIJKLMNPQRSTUVWXYZ"; - } - if ($strength >= 4) { - $chars .= "!^$%*?."; - } - for ($i = 0; $i < $length; $i++) { - $password .= $chars[random_int(0, strlen($chars) - 1)]; - } - return $password; +function generate_password($length = 0, $strength = 0) { + $password = ''; + $chars = ''; + if ($length === 0 && $strength === 0) { //set length and strenth if specified in default settings and strength isn't numeric-only + $length = (is_numeric($settings->get('users', 'password_length'))) ? $settings->get('users', 'password_length') : 20; + $strength = (is_numeric($settings->get('users', 'password_strength'))) ? $settings->get('users', 'password_strength') : 4; } + if ($strength >= 1) { + $chars .= "0123456789"; + } + if ($strength >= 2) { + $chars .= "abcdefghijkmnopqrstuvwxyz"; + } + if ($strength >= 3) { + $chars .= "ABCDEFGHIJKLMNPQRSTUVWXYZ"; + } + if ($strength >= 4) { + $chars .= "!^$%*?."; + } + for ($i = 0; $i < $length; $i++) { + $password .= $chars[random_int(0, strlen($chars) - 1)]; + } + return $password; +} //check password strength against requirements (if any) - function check_password_strength($password, $text, $type = 'default') { +function check_password_strength($password, $text, $type = 'default') { - //initialize the settigns object - $settings = new settings(['database' => $database, 'domain_uuid' => $_SESSION['domain_uuid']]); + //initialize the settigns object + $settings = new settings(['database' => $database, 'domain_uuid' => $_SESSION['domain_uuid']]); - if (!empty($password)) { - if ($type == 'default') { - $req['length'] = $settings->get('extension', 'password_length', '10'); - $req['number'] = $settings->get('extension', 'password_number', true); - $req['lowercase'] = $settings->get('extension', 'password_lowercase', true); - $req['uppercase'] = $settings->get('extension', 'password_uppercase', false); - $req['special'] = $settings->get('extension', 'password_special', false); - } elseif ($type == 'user') { - $req['length'] = $settings->get('users', 'password_length', '10'); - $req['number'] = $settings->get('users', 'password_number', true); - $req['lowercase'] = $settings->get('users', 'password_lowercase', true); - $req['uppercase'] = $settings->get('users', 'password_uppercase', false); - $req['special'] = $settings->get('users', 'password_special', false); - } - if (is_numeric($req['length']) && $req['length'] != 0 && !preg_match_all('$\S*(?=\S{' . $req['length'] . ',})\S*$', $password)) { // length - $msg_errors[] = $req['length'] . '+ ' . $text['label-characters']; - } - if ($req['number'] && !preg_match_all('$\S*(?=\S*[\d])\S*$', $password)) { //number - $msg_errors[] = '1+ ' . $text['label-numbers']; - } - if ($req['lowercase'] && !preg_match_all('$\S*(?=\S*[a-z])\S*$', $password)) { //lowercase - $msg_errors[] = '1+ ' . $text['label-lowercase_letters']; - } - if ($req['uppercase'] && !preg_match_all('$\S*(?=\S*[A-Z])\S*$', $password)) { //uppercase - $msg_errors[] = '1+ ' . $text['label-uppercase_letters']; - } - if ($req['special'] && !preg_match_all('$\S*(?=\S*[\W])\S*$', $password)) { //special - $msg_errors[] = '1+ ' . $text['label-special_characters']; - } - if (is_array($msg_errors) && sizeof($msg_errors) > 0) { - message::add($_SESSION["message"] = $text['message-password_requirements'] . ': ' . implode(', ', $msg_errors), 'negative', 6000); - return false; - } else { - return true; - } + if (!empty($password)) { + if ($type == 'default') { + $req['length'] = $settings->get('extension', 'password_length', '10'); + $req['number'] = $settings->get('extension', 'password_number', true); + $req['lowercase'] = $settings->get('extension', 'password_lowercase', true); + $req['uppercase'] = $settings->get('extension', 'password_uppercase', false); + $req['special'] = $settings->get('extension', 'password_special', false); + } elseif ($type == 'user') { + $req['length'] = $settings->get('users', 'password_length', '10'); + $req['number'] = $settings->get('users', 'password_number', true); + $req['lowercase'] = $settings->get('users', 'password_lowercase', true); + $req['uppercase'] = $settings->get('users', 'password_uppercase', false); + $req['special'] = $settings->get('users', 'password_special', false); + } + if (is_numeric($req['length']) && $req['length'] != 0 && !preg_match_all('$\S*(?=\S{' . $req['length'] . ',})\S*$', $password)) { // length + $msg_errors[] = $req['length'] . '+ ' . $text['label-characters']; + } + if ($req['number'] && !preg_match_all('$\S*(?=\S*[\d])\S*$', $password)) { //number + $msg_errors[] = '1+ ' . $text['label-numbers']; + } + if ($req['lowercase'] && !preg_match_all('$\S*(?=\S*[a-z])\S*$', $password)) { //lowercase + $msg_errors[] = '1+ ' . $text['label-lowercase_letters']; + } + if ($req['uppercase'] && !preg_match_all('$\S*(?=\S*[A-Z])\S*$', $password)) { //uppercase + $msg_errors[] = '1+ ' . $text['label-uppercase_letters']; + } + if ($req['special'] && !preg_match_all('$\S*(?=\S*[\W])\S*$', $password)) { //special + $msg_errors[] = '1+ ' . $text['label-special_characters']; + } + if (is_array($msg_errors) && sizeof($msg_errors) > 0) { + message::add($_SESSION["message"] = $text['message-password_requirements'] . ': ' . implode(', ', $msg_errors), 'negative', 6000); + return false; + } else { + return true; } - return true; } + return true; +} //based on Wez Furlong do_post_request - if (!function_exists('send_http_request')) { - - function send_http_request($url, $data, $method = "POST", $optional_headers = null) { - $params = array('http' => array( - 'method' => $method, - 'content' => $data - )); - if ($optional_headers !== null) { - $params['http']['header'] = $optional_headers; - } - $ctx = stream_context_create($params); - $esl = @fopen($url, 'rb', false, $ctx); - if (!$esl) { - throw new Exception("Problem with $url, $php_errormsg"); - } - $response = @stream_get_contents($esl); - if ($response === false) { - throw new Exception("Problem reading data from $url, $php_errormsg"); - } - return $response; +if (!function_exists('send_http_request')) { + function send_http_request($url, $data, $method = "POST", $optional_headers = null) { + $params = array('http' => array( + 'method' => $method, + 'content' => $data + )); + if ($optional_headers !== null) { + $params['http']['header'] = $optional_headers; } - + $ctx = stream_context_create($params); + $esl = @fopen($url, 'rb', false, $ctx); + if (!$esl) { + throw new Exception("Problem with $url, $php_errormsg"); + } + $response = @stream_get_contents($esl); + if ($response === false) { + throw new Exception("Problem reading data from $url, $php_errormsg"); + } + return $response; } +} //convert the string to a named array - if (!function_exists('csv_to_named_array')) { - - function csv_to_named_array($tmp_str, $tmp_delimiter) { - $tmp_array = explode("\n", $tmp_str); - $result = array(); - if (trim(strtoupper($tmp_array[0])) !== "+OK") { - $tmp_field_name_array = explode($tmp_delimiter, $tmp_array[0]); - $x = 0; - foreach ($tmp_array as $row) { - if ($x > 0) { - $tmp_field_value_array = explode($tmp_delimiter, $tmp_array[$x]); - $y = 0; - foreach ($tmp_field_value_array as $tmp_value) { - $tmp_name = $tmp_field_name_array[$y]; - if (trim(strtoupper($tmp_value)) !== "+OK") { - $result[$x][$tmp_name] = $tmp_value; - } - $y++; +if (!function_exists('csv_to_named_array')) { + function csv_to_named_array($tmp_str, $tmp_delimiter) { + $tmp_array = explode("\n", $tmp_str); + $result = array(); + if (trim(strtoupper($tmp_array[0])) !== "+OK") { + $tmp_field_name_array = explode($tmp_delimiter, $tmp_array[0]); + $x = 0; + foreach ($tmp_array as $row) { + if ($x > 0) { + $tmp_field_value_array = explode($tmp_delimiter, $tmp_array[$x]); + $y = 0; + foreach ($tmp_field_value_array as $tmp_value) { + $tmp_name = $tmp_field_name_array[$y]; + if (trim(strtoupper($tmp_value)) !== "+OK") { + $result[$x][$tmp_name] = $tmp_value; } + $y++; } - $x++; } - unset($row); + $x++; } - return $result; + unset($row); } - + return $result; } +} - function get_time_zone_offset($remote_tz, $origin_tz = 'UTC') { - $origin_dtz = new DateTimeZone($origin_tz); - $remote_dtz = new DateTimeZone($remote_tz); - $origin_dt = new DateTime("now", $origin_dtz); - $remote_dt = new DateTime("now", $remote_dtz); - $offset = $remote_dtz->getOffset($remote_dt) - $origin_dtz->getOffset($origin_dt); - return $offset; - } +function get_time_zone_offset($remote_tz, $origin_tz = 'UTC') { + $origin_dtz = new DateTimeZone($origin_tz); + $remote_dtz = new DateTimeZone($remote_tz); + $origin_dt = new DateTime("now", $origin_dtz); + $remote_dt = new DateTime("now", $remote_dtz); + $offset = $remote_dtz->getOffset($remote_dt) - $origin_dtz->getOffset($origin_dt); + return $offset; +} - function number_pad($number, $n) { - return str_pad((int) $number, $n, "0", STR_PAD_LEFT); - } +function number_pad($number, $n) { + return str_pad((int) $number, $n, "0", STR_PAD_LEFT); +} // validate email address syntax - if (!function_exists('valid_email')) { - - function valid_email($email) { - return (filter_var($email, FILTER_VALIDATE_EMAIL)) ? true : false; - } - +if (!function_exists('valid_email')) { + function valid_email($email) { + return (filter_var($email, FILTER_VALIDATE_EMAIL)) ? true : false; } +} //function to convert hexidecimal color value to rgb string/array value - if (!function_exists('hex_to_rgb')) { +if (!function_exists('hex_to_rgb')) { + function hex_to_rgb($hex, $delim = null, $include_alpha = false, $alpha = 1) { + $hex = str_replace("#", "", $hex); - function hex_to_rgb($hex, $delim = null, $include_alpha = false, $alpha = 1) { - $hex = str_replace("#", "", $hex); - - if (strlen($hex) == 3) { - $r = hexdec(substr($hex, 0, 1) . substr($hex, 0, 1)); - $g = hexdec(substr($hex, 1, 1) . substr($hex, 1, 1)); - $b = hexdec(substr($hex, 2, 1) . substr($hex, 2, 1)); - } - else { - $r = hexdec(substr($hex, 0, 2)); - $g = hexdec(substr($hex, 2, 2)); - $b = hexdec(substr($hex, 4, 2)); - } - $rgb = array($r, $g, $b); - if ($include_alpha) { $rgb[] = $alpha; } - - if (!empty($delim)) { - return implode($delim, $rgb); // return rgb delimited string - } - else { - return $rgb; // return array of rgb values - } + if (strlen($hex) == 3) { + $r = hexdec(substr($hex, 0, 1) . substr($hex, 0, 1)); + $g = hexdec(substr($hex, 1, 1) . substr($hex, 1, 1)); + $b = hexdec(substr($hex, 2, 1) . substr($hex, 2, 1)); } + else { + $r = hexdec(substr($hex, 0, 2)); + $g = hexdec(substr($hex, 2, 2)); + $b = hexdec(substr($hex, 4, 2)); + } + $rgb = array($r, $g, $b); + if ($include_alpha) { $rgb[] = $alpha; } + if (!empty($delim)) { + return implode($delim, $rgb); // return rgb delimited string + } + else { + return $rgb; // return array of rgb values + } } +} //function to convert a hex or rgb/a color to an rgba array - if (!function_exists('color_to_rgba_array')) { - - function color_to_rgba_array($string, $alpha = null) { - if (!empty($string)) { - if (strpos($string, '#') === 0) { //is hex - return hex_to_rgb($string, null, true, $alpha); - } - else if (strpos($string, 'rgb') === 0) { //is rgb/a - $string = str_replace(['rgba(','rgb(',')'], '', $string); //values to csv - $array = explode(',', $string); //create array - if (!empty($array)) { - if (@sizeof($array) == 3) { //add alpha - $array[] = $alpha ?? 1; - } - else if (@sizeof($array) == 4 && !empty($alpha)) { //replace alpha - $array[3] = $alpha; - } - } - return !empty($array) && is_array($array) ? $array : false; - } +if (!function_exists('color_to_rgba_array')) { + function color_to_rgba_array($string, $alpha = null) { + if (!empty($string)) { + if (strpos($string, '#') === 0) { //is hex + return hex_to_rgb($string, null, true, $alpha); + } + else if (strpos($string, 'rgb') === 0) { //is rgb/a + $string = str_replace(['rgba(','rgb(',')'], '', $string); //values to csv + $array = explode(',', $string); //create array + if (!empty($array)) { + if (@sizeof($array) == 3) { //add alpha + $array[] = $alpha ?? 1; + } + else if (@sizeof($array) == 4 && !empty($alpha)) { //replace alpha + $array[3] = $alpha; + } + } + return !empty($array) && is_array($array) ? $array : false; } - return false; } - + return false; } +} //function to get a color's luminence level -- dependencies: rgb_to_hsl() - if (!function_exists('get_color_luminence')) { - - function get_color_luminence($color) { - //convert hex to rgb - if (substr_count($color, ',') == 0) { - $color = str_replace(' ', '', $color); - $color = str_replace('#', '', $color); - if (strlen($color) == 3) { - $r = hexdec(substr($color, 0, 1) . substr($color, 0, 1)); - $g = hexdec(substr($color, 1, 1) . substr($color, 1, 1)); - $b = hexdec(substr($color, 2, 1) . substr($color, 2, 1)); - } else { - $r = hexdec(substr($color, 0, 2)); - $g = hexdec(substr($color, 2, 2)); - $b = hexdec(substr($color, 4, 2)); - } - $color = $r . ',' . $g . ',' . $b; +if (!function_exists('get_color_luminence')) { + function get_color_luminence($color) { + //convert hex to rgb + if (substr_count($color, ',') == 0) { + $color = str_replace(' ', '', $color); + $color = str_replace('#', '', $color); + if (strlen($color) == 3) { + $r = hexdec(substr($color, 0, 1) . substr($color, 0, 1)); + $g = hexdec(substr($color, 1, 1) . substr($color, 1, 1)); + $b = hexdec(substr($color, 2, 1) . substr($color, 2, 1)); + } else { + $r = hexdec(substr($color, 0, 2)); + $g = hexdec(substr($color, 2, 2)); + $b = hexdec(substr($color, 4, 2)); } - - //color to array, pop alpha - if (substr_count($color, ',') > 0) { - $color = str_replace(' ', '', $color); - $color = str_replace('rgb', '', $color); - $color = str_replace('a(', '', $color); - $color = str_replace(')', '', $color); - $color = explode(',', $color); - $hsl = rgb_to_hsl($color[0], $color[1], $color[2]); - } - - //return luminence value - return (is_array($hsl) && is_numeric($hsl[2])) ? $hsl[2] : null; + $color = $r . ',' . $g . ',' . $b; } + //color to array, pop alpha + if (substr_count($color, ',') > 0) { + $color = str_replace(' ', '', $color); + $color = str_replace('rgb', '', $color); + $color = str_replace('a(', '', $color); + $color = str_replace(')', '', $color); + $color = explode(',', $color); + $hsl = rgb_to_hsl($color[0], $color[1], $color[2]); + } + + //return luminence value + return (is_array($hsl) && is_numeric($hsl[2])) ? $hsl[2] : null; } +} //function to lighten or darken a hexidecimal, rgb, or rgba color value by a percentage -- dependencies: rgb_to_hsl(), hsl_to_rgb() - if (!function_exists('color_adjust')) { +if (!function_exists('color_adjust')) { + function color_adjust($color, $percent) { + /* + USAGE + 20% Lighter + color_adjust('#3f4265', 0.2); + color_adjust('234,120,6,0.3', 0.2); + 20% Darker + color_adjust('#3f4265', -0.2); // + color_adjust('rgba(234,120,6,0.3)', -0.2); + RETURNS + Same color format provided (hex in = hex out, rgb(a) in = rgb(a) out) + */ - function color_adjust($color, $percent) { - /* - USAGE - 20% Lighter - color_adjust('#3f4265', 0.2); - color_adjust('234,120,6,0.3', 0.2); - 20% Darker - color_adjust('#3f4265', -0.2); // - color_adjust('rgba(234,120,6,0.3)', -0.2); - RETURNS - Same color format provided (hex in = hex out, rgb(a) in = rgb(a) out) - */ - - //convert hex to rgb - if (substr_count($color, ',') == 0) { - $color = str_replace(' ', '', $color); - if (substr_count($color, '#') > 0) { - $color = str_replace('#', '', $color); - $hash = '#'; - } - if (strlen($color) == 3) { - $r = hexdec(substr($color, 0, 1) . substr($color, 0, 1)); - $g = hexdec(substr($color, 1, 1) . substr($color, 1, 1)); - $b = hexdec(substr($color, 2, 1) . substr($color, 2, 1)); - } else { - $r = hexdec(substr($color, 0, 2)); - $g = hexdec(substr($color, 2, 2)); - $b = hexdec(substr($color, 4, 2)); - } - $color = $r . ',' . $g . ',' . $b; + //convert hex to rgb + if (substr_count($color, ',') == 0) { + $color = str_replace(' ', '', $color); + if (substr_count($color, '#') > 0) { + $color = str_replace('#', '', $color); + $hash = '#'; } - - //color to array, pop alpha - if (substr_count($color, ',') > 0) { - $color = str_replace(' ', '', $color); - $wrapper = false; - if (substr_count($color, 'rgb') != 0) { - $color = str_replace('rgb', '', $color); - $color = str_replace('a(', '', $color); - $color = str_replace('(', '', $color); - $color = str_replace(')', '', $color); - $wrapper = true; - } - $colors = explode(',', $color); - $alpha = (sizeof($colors) == 4) ? array_pop($colors) : null; - $color = $colors; - unset($colors); - - //adjust color using rgb > hsl > rgb conversion - $hsl = rgb_to_hsl($color[0], $color[1], $color[2]); - $hsl[2] = $hsl[2] + $percent; - $color = hsl_to_rgb($hsl[0], $hsl[1], $hsl[2]); - - //return adjusted color in format received - if (isset($hash) && $hash == '#') { //hex - $hex = ''; - for ($i = 0; $i <= 2; $i++) { - $hex_color = dechex($color[$i]); - if (strlen($hex_color) == 1) { - $hex_color = '0' . $hex_color; - } - $hex .= $hex_color; - } - return $hash . $hex; - } else { //rgb(a) - $rgb = implode(',', $color); - if (!empty($alpha)) { - $rgb .= ',' . $alpha; - $a = 'a'; - } - if ($wrapper) { - $rgb = 'rgb' . ($a ?? '') . '(' . $rgb . ')'; - } - return $rgb; - } + if (strlen($color) == 3) { + $r = hexdec(substr($color, 0, 1) . substr($color, 0, 1)); + $g = hexdec(substr($color, 1, 1) . substr($color, 1, 1)); + $b = hexdec(substr($color, 2, 1) . substr($color, 2, 1)); + } else { + $r = hexdec(substr($color, 0, 2)); + $g = hexdec(substr($color, 2, 2)); + $b = hexdec(substr($color, 4, 2)); } - - return $color; + $color = $r . ',' . $g . ',' . $b; } + //color to array, pop alpha + if (substr_count($color, ',') > 0) { + $color = str_replace(' ', '', $color); + $wrapper = false; + if (substr_count($color, 'rgb') != 0) { + $color = str_replace('rgb', '', $color); + $color = str_replace('a(', '', $color); + $color = str_replace('(', '', $color); + $color = str_replace(')', '', $color); + $wrapper = true; + } + $colors = explode(',', $color); + $alpha = (sizeof($colors) == 4) ? array_pop($colors) : null; + $color = $colors; + unset($colors); + + //adjust color using rgb > hsl > rgb conversion + $hsl = rgb_to_hsl($color[0], $color[1], $color[2]); + $hsl[2] = $hsl[2] + $percent; + $color = hsl_to_rgb($hsl[0], $hsl[1], $hsl[2]); + + //return adjusted color in format received + if (isset($hash) && $hash == '#') { //hex + $hex = ''; + for ($i = 0; $i <= 2; $i++) { + $hex_color = dechex($color[$i]); + if (strlen($hex_color) == 1) { + $hex_color = '0' . $hex_color; + } + $hex .= $hex_color; + } + return $hash . $hex; + } else { //rgb(a) + $rgb = implode(',', $color); + if (!empty($alpha)) { + $rgb .= ',' . $alpha; + $a = 'a'; + } + if ($wrapper) { + $rgb = 'rgb' . ($a ?? '') . '(' . $rgb . ')'; + } + return $rgb; + } + } + + return $color; } +} //function to convert an rgb color array to an hsl color array - if (!function_exists('rgb_to_hsl')) { +if (!function_exists('rgb_to_hsl')) { + function rgb_to_hsl($r, $g, $b) { + $r /= 255; + $g /= 255; + $b /= 255; - function rgb_to_hsl($r, $g, $b) { - $r /= 255; - $g /= 255; - $b /= 255; + $max = max($r, $g, $b); + $min = min($r, $g, $b); - $max = max($r, $g, $b); - $min = min($r, $g, $b); + $h; + $s; + $l = ($max + $min) / 2; + $d = $max - $min; - $h; - $s; - $l = ($max + $min) / 2; - $d = $max - $min; - - if ($d == 0) { - $h = $s = 0; // achromatic - } else { - $s = $d / (1 - abs((2 * $l) - 1)); - switch ($max) { - case $r: - $h = 60 * fmod((($g - $b) / $d), 6); - if ($b > $g) { - $h += 360; - } - break; - case $g: - $h = 60 * (($b - $r) / $d + 2); - break; - case $b: - $h = 60 * (($r - $g) / $d + 4); - break; - } + if ($d == 0) { + $h = $s = 0; // achromatic + } else { + $s = $d / (1 - abs((2 * $l) - 1)); + switch ($max) { + case $r: + $h = 60 * fmod((($g - $b) / $d), 6); + if ($b > $g) { + $h += 360; + } + break; + case $g: + $h = 60 * (($b - $r) / $d + 2); + break; + case $b: + $h = 60 * (($r - $g) / $d + 4); + break; } - - return array(round($h, 2), round($s, 2), round($l, 2)); } + return array(round($h, 2), round($s, 2), round($l, 2)); } +} //function to convert an hsl color array to an rgb color array - if (!function_exists('hsl_to_rgb')) { +if (!function_exists('hsl_to_rgb')) { + function hsl_to_rgb($h, $s, $l) { + $r; + $g; + $b; - function hsl_to_rgb($h, $s, $l) { - $r; - $g; - $b; + $c = (1 - abs((2 * $l) - 1)) * $s; + $x = $c * (1 - abs(fmod(($h / 60), 2) - 1)); + $m = $l - ($c / 2); - $c = (1 - abs((2 * $l) - 1)) * $s; - $x = $c * (1 - abs(fmod(($h / 60), 2) - 1)); - $m = $l - ($c / 2); - - if ($h < 60) { - $r = $c; - $g = $x; - $b = 0; - } else if ($h < 120) { - $r = $x; - $g = $c; - $b = 0; - } else if ($h < 180) { - $r = 0; - $g = $c; - $b = $x; - } else if ($h < 240) { - $r = 0; - $g = $x; - $b = $c; - } else if ($h < 300) { - $r = $x; - $g = 0; - $b = $c; - } else { - $r = $c; - $g = 0; - $b = $x; - } - - $r = ($r + $m) * 255; - $g = ($g + $m) * 255; - $b = ($b + $m) * 255; - - if ($r > 255) { - $r = 255; - } - if ($g > 255) { - $g = 255; - } - if ($b > 255) { - $b = 255; - } - - if ($r < 0) { - $r = 0; - } - if ($g < 0) { - $g = 0; - } - if ($b < 0) { - $b = 0; - } - - return array(floor($r), floor($g), floor($b)); + if ($h < 60) { + $r = $c; + $g = $x; + $b = 0; + } else if ($h < 120) { + $r = $x; + $g = $c; + $b = 0; + } else if ($h < 180) { + $r = 0; + $g = $c; + $b = $x; + } else if ($h < 240) { + $r = 0; + $g = $x; + $b = $c; + } else if ($h < 300) { + $r = $x; + $g = 0; + $b = $c; + } else { + $r = $c; + $g = 0; + $b = $x; } + $r = ($r + $m) * 255; + $g = ($g + $m) * 255; + $b = ($b + $m) * 255; + + if ($r > 255) { + $r = 255; + } + if ($g > 255) { + $g = 255; + } + if ($b > 255) { + $b = 255; + } + + if ($r < 0) { + $r = 0; + } + if ($g < 0) { + $g = 0; + } + if ($b < 0) { + $b = 0; + } + + return array(floor($r), floor($g), floor($b)); } +} //function to send email - if (!function_exists('send_email')) { +if (!function_exists('send_email')) { + function send_email($email_recipients, $email_subject, $email_body, &$email_error = '', $email_from_address = '', $email_from_name = '', $email_priority = 3, $email_debug_level = 0, $email_attachments = '', $email_read_confirmation = false) { + /* + RECIPIENTS NOTE: - function send_email($email_recipients, $email_subject, $email_body, &$email_error = '', $email_from_address = '', $email_from_name = '', $email_priority = 3, $email_debug_level = 0, $email_attachments = '', $email_read_confirmation = false) { - /* - RECIPIENTS NOTE: + Pass in a single email address... - Pass in a single email address... + user@domain.com - user@domain.com + Pass in a comma or semi-colon delimited string of e-mail addresses... - Pass in a comma or semi-colon delimited string of e-mail addresses... + user@domain.com,user2@domain2.com,user3@domain3.com + user@domain.com;user2@domain2.com;user3@domain3.com - user@domain.com,user2@domain2.com,user3@domain3.com - user@domain.com;user2@domain2.com;user3@domain3.com + Pass in a simple array of email addresses... - Pass in a simple array of email addresses... + Array ( + [0] => user@domain.com + [1] => user2@domain2.com + [2] => user3@domain3.com + ) - Array ( - [0] => user@domain.com - [1] => user2@domain2.com - [2] => user3@domain3.com - ) + Pass in a multi-dimentional array of addresses (delivery, address, name)... - Pass in a multi-dimentional array of addresses (delivery, address, name)... + Array ( + [0] => Array ( + [delivery] => to + [address] => user@domain.com + [name] => user 1 + ) + [1] => Array ( + [delivery] => cc + [address] => user2@domain2.com + [name] => user 2 + ) + [2] => Array ( + [delivery] => bcc + [address] => user3@domain3.com + [name] => user 3 + ) + ) - Array ( - [0] => Array ( - [delivery] => to - [address] => user@domain.com - [name] => user 1 - ) - [1] => Array ( - [delivery] => cc - [address] => user2@domain2.com - [name] => user 2 - ) - [2] => Array ( - [delivery] => bcc - [address] => user3@domain3.com - [name] => user 3 - ) - ) + ATTACHMENTS NOTE: - ATTACHMENTS NOTE: + Pass in as many files as necessary in an array in the following format... - Pass in as many files as necessary in an array in the following format... + Array ( + [0] => Array ( + [type] => file (or 'path') + [name] => filename.ext + [value] => /folder/filename.ext + ) + [1] => Array ( + [type] => string + [name] => filename.ext + [value] => (string of file contents - if base64, will be decoded automatically) + ) + ) - Array ( - [0] => Array ( - [type] => file (or 'path') - [name] => filename.ext - [value] => /folder/filename.ext - ) - [1] => Array ( - [type] => string - [name] => filename.ext - [value] => (string of file contents - if base64, will be decoded automatically) - ) - ) + ERROR RESPONSE: - ERROR RESPONSE: + Error messages are stored in the variable passed into $email_error BY REFERENCE - Error messages are stored in the variable passed into $email_error BY REFERENCE + */ - */ + //add the email recipients + $address_found = false; + if (!is_array($email_recipients)) { // must be a single or delimited recipient address(s) + $email_recipients = str_replace(' ', '', $email_recipients); + $email_recipients = str_replace(',', ';', $email_recipients); + $email_recipients = explode(';', $email_recipients); // convert to array of addresses + } - //add the email recipients - $address_found = false; - if (!is_array($email_recipients)) { // must be a single or delimited recipient address(s) - $email_recipients = str_replace(' ', '', $email_recipients); - $email_recipients = str_replace(',', ';', $email_recipients); - $email_recipients = explode(';', $email_recipients); // convert to array of addresses - } - - foreach ($email_recipients as $email_recipient) { - if (is_array($email_recipient)) { // check if each recipient has multiple fields - if (!empty($email_recipient["address"]) && valid_email($email_recipient["address"])) { // check if valid address - $recipients = $email_recipient["address"]; - $address_found = true; - } - } else if (!empty($email_recipient) && valid_email($email_recipient)) { // check if recipient value is simply (only) an address - $email_recipients = $email_recipient; + foreach ($email_recipients as $email_recipient) { + if (is_array($email_recipient)) { // check if each recipient has multiple fields + if (!empty($email_recipient["address"]) && valid_email($email_recipient["address"])) { // check if valid address + $recipients = $email_recipient["address"]; $address_found = true; } + } else if (!empty($email_recipient) && valid_email($email_recipient)) { // check if recipient value is simply (only) an address + $email_recipients = $email_recipient; + $address_found = true; } - if (is_array($recipients)) { - $email_recipients = implode(",", $recipients); - } - if (!$address_found) { - $email_error = "No valid e-mail address provided."; - return false; - } - - //get the from address and name - $email_from_address = (!empty($email_from_address)) ? $email_from_address : $_SESSION['email']['smtp_from']['text']; - $email_from_name = (!empty($email_from_name)) ? $email_from_name : $_SESSION['email']['smtp_from_name']['text']; - - //send email - $email = new email; - $email->recipients = $email_recipients; - $email->subject = $email_subject; - $email->body = $email_body; - $email->from_address = $email_from_address; - $email->from_name = $email_from_name; - $email->attachments = $email_attachments; - $email->debug_level = 3; - $sent = $email->send(); - //$email_error = $email->email_error; } - - } - -//encrypt a string - if (!function_exists('encrypt')) { - - function encrypt($key, $data) { - $encryption_key = base64_decode($key); - $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc')); - $encrypted = openssl_encrypt($data, 'aes-256-cbc', $encryption_key, 0, $iv); - return base64_encode($encrypted . '::' . $iv); + if (is_array($recipients)) { + $email_recipients = implode(",", $recipients); } - - } - -//decrypt a string - if (!function_exists('decrypt')) { - - function decrypt($key, $data) { - $encryption_key = base64_decode($key); - list($encrypted_data, $iv) = explode('::', base64_decode($data), 2); - return openssl_decrypt($encrypted_data, 'aes-256-cbc', $encryption_key, 0, $iv); - } - - } - -//json detection - if (!function_exists('is_json')) { - - function is_json($str) { - return is_string($str) && is_array(json_decode($str, true)) ? true : false; - } - - } - -//mac detection - if (!function_exists('is_mac')) { - - function is_mac($str) { - return preg_match('/([a-fA-F0-9]{2}[:|\-]?){6}/', $str) == 1 && strlen(preg_replace("#[^a-fA-F0-9]#", '', $str)) == 12 ? true : false; - } - - } - -//detect if php is running as command line interface - if (!function_exists('is_cli')) { - - function is_cli() { - if (defined('STDIN')) { - return true; - } - if (php_sapi_name() == 'cli' && !isset($_SERVER['HTTP_USER_AGENT']) && is_numeric($_SERVER['argc'])) { - return true; - } + if (!$address_found) { + $email_error = "No valid e-mail address provided."; return false; } + //get the from address and name + $email_from_address = (!empty($email_from_address)) ? $email_from_address : $settings->get('email', 'smtp_from'); + $email_from_name = (!empty($email_from_name)) ? $email_from_name : $settings->get('email', 'smtp_from_name'); + + //send email + $email = new email; + $email->recipients = $email_recipients; + $email->subject = $email_subject; + $email->body = $email_body; + $email->from_address = $email_from_address; + $email->from_name = $email_from_name; + $email->attachments = $email_attachments; + $email->debug_level = 3; + $sent = $email->send(); + //$email_error = $email->email_error; } +} + +//encrypt a string +if (!function_exists('encrypt')) { + function encrypt($key, $data) { + $encryption_key = base64_decode($key); + $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc')); + $encrypted = openssl_encrypt($data, 'aes-256-cbc', $encryption_key, 0, $iv); + return base64_encode($encrypted . '::' . $iv); + } +} + +//decrypt a string +if (!function_exists('decrypt')) { + function decrypt($key, $data) { + $encryption_key = base64_decode($key); + list($encrypted_data, $iv) = explode('::', base64_decode($data), 2); + return openssl_decrypt($encrypted_data, 'aes-256-cbc', $encryption_key, 0, $iv); + } +} + +//json detection +if (!function_exists('is_json')) { + function is_json($str) { + return is_string($str) && is_array(json_decode($str, true)) ? true : false; + } +} + +// PHP versions lower than 8.3 need the json_validate function +if (!function_exists('json_validate')) { + function json_validate($json) { + // decode the JSON data + $data = json_decode($json); + + // check json last error for decoding errors + if (json_last_error() === JSON_ERROR_NONE) { + return true; + } else { + return false; + } + } +} + +//mac detection +if (!function_exists('is_mac')) { + function is_mac($str) { + return preg_match('/([a-fA-F0-9]{2}[:|\-]?){6}/', $str) == 1 && strlen(preg_replace("#[^a-fA-F0-9]#", '', $str)) == 12 ? true : false; + } +} + +//detect if php is running as command line interface +if (!function_exists('is_cli')) { + function is_cli() { + if (defined('STDIN')) { + return true; + } + if (php_sapi_name() == 'cli' && !isset($_SERVER['HTTP_USER_AGENT']) && is_numeric($_SERVER['argc'])) { + return true; + } + return false; + } +} //format device address - if (!function_exists('format_device_address')) { - - function format_device_address($str, $delim = '-', $case = 'lower') { - if (empty($str)) { - return false; - } - $str = preg_replace("#[^a-fA-F0-9]#", '', $str); //remove formatting, if any - if (is_mac($str)) { - $str = join($delim, str_split($str, 2)); - } else if (is_uuid($str)) { - $str = substr($str, 0, 8) . '-' . substr($str, 8, 4) . '-' . substr($str, 12, 4) . '-' . substr($str, 16, 4) . '-' . substr($str, 20, 12); - } - $str = $case == 'upper' ? strtoupper($str) : strtolower($str); - return $str; +if (!function_exists('format_device_address')) { + function format_device_address($str, $delim = '-', $case = 'lower') { + if (empty($str)) { + return false; } - + $str = preg_replace("#[^a-fA-F0-9]#", '', $str); //remove formatting, if any + if (is_mac($str)) { + $str = join($delim, str_split($str, 2)); + } else if (is_uuid($str)) { + $str = substr($str, 0, 8) . '-' . substr($str, 8, 4) . '-' . substr($str, 12, 4) . '-' . substr($str, 16, 4) . '-' . substr($str, 20, 12); + } + $str = $case == 'upper' ? strtoupper($str) : strtolower($str); + return $str; } +} //transparent gif - if (!function_exists('img_spacer')) { - - function img_spacer($width = '1px', $height = '1px', $custom = null) { - return ""; - } +if (!function_exists('img_spacer')) { + function img_spacer($width = '1px', $height = '1px', $custom = null) { + return ""; } +} + //lower case - function lower_case($string) { - if (function_exists('mb_strtolower')) { - return mb_strtolower($string, 'UTF-8'); - } else { - return strtolower($string); - } +function lower_case($string) { + if (function_exists('mb_strtolower')) { + return mb_strtolower($string, 'UTF-8'); + } else { + return strtolower($string); } +} //upper case - function upper_case($string) { - if (function_exists('mb_strtoupper')) { - return mb_strtoupper($string, 'UTF-8'); - } else { - return strtoupper($string); - } +function upper_case($string) { + if (function_exists('mb_strtoupper')) { + return mb_strtoupper($string, 'UTF-8'); + } else { + return strtoupper($string); } +} //write javascript function that detects select key combinations to perform designated actions - if (!function_exists('key_press')) { - - function key_press($key, $direction = 'up', $subject = 'document', $exceptions = array(), $prompt = null, $action = null, $script_wrapper = true) { - //determine key code - switch (strtolower($key)) { - case 'escape': - $key_code = '(e.which == 27)'; - break; - case 'delete': - $key_code = '(e.which == 46)'; - break; - case 'enter': - $key_code = '(e.which == 13)'; - break; - case 'backspace': - $key_code = '(e.which == 8)'; - break; - case 'space': - $key_code = '(e.which == 32)'; - break; - case 'ctrl+s': - $key_code = '(((e.which == 115 || e.which == 83) && (e.ctrlKey || e.metaKey)) || (e.which == 19))'; - break; - case 'ctrl+q': - $key_code = '(((e.which == 113 || e.which == 81) && (e.ctrlKey || e.metaKey)) || (e.which == 19))'; - break; - case 'ctrl+a': - $key_code = '(((e.which == 97 || e.which == 65) && (e.ctrlKey || e.metaKey)) || (e.which == 19))'; - break; - case 'ctrl+c': - $key_code = '(((e.which == 99 || e.which == 67) && (e.ctrlKey || e.metaKey)) || (e.which == 19))'; - break; - case 'ctrl+enter': - $key_code = '(((e.which == 13 || e.which == 10) && (e.ctrlKey || e.metaKey)) || (e.which == 19))'; - break; - default: - return; - } - //filter direction - switch ($direction) { - case 'down': $direction = 'keydown'; - break; - case 'press': $direction = 'keypress'; - break; - case 'up': $direction = 'keyup'; - break; - } - //check for element exceptions - if (is_array($exceptions)) { - if (sizeof($exceptions) > 0) { - $exceptions = "!$(e.target).is('" . implode(',', $exceptions) . "') && "; - } - } - //quote if selector is id or class - $subject = ($subject != 'window' && $subject != 'document') ? "'" . $subject . "'" : $subject; - //output script - echo "\n\n\n"; - if ($script_wrapper) { - echo "\n"; - } - echo "\n\n\n"; +if (!function_exists('key_press')) { + function key_press($key, $direction = 'up', $subject = 'document', $exceptions = array(), $prompt = null, $action = null, $script_wrapper = true) { + //determine key code + switch (strtolower($key)) { + case 'escape': + $key_code = '(e.which == 27)'; + break; + case 'delete': + $key_code = '(e.which == 46)'; + break; + case 'enter': + $key_code = '(e.which == 13)'; + break; + case 'backspace': + $key_code = '(e.which == 8)'; + break; + case 'space': + $key_code = '(e.which == 32)'; + break; + case 'ctrl+s': + $key_code = '(((e.which == 115 || e.which == 83) && (e.ctrlKey || e.metaKey)) || (e.which == 19))'; + break; + case 'ctrl+q': + $key_code = '(((e.which == 113 || e.which == 81) && (e.ctrlKey || e.metaKey)) || (e.which == 19))'; + break; + case 'ctrl+a': + $key_code = '(((e.which == 97 || e.which == 65) && (e.ctrlKey || e.metaKey)) || (e.which == 19))'; + break; + case 'ctrl+c': + $key_code = '(((e.which == 99 || e.which == 67) && (e.ctrlKey || e.metaKey)) || (e.which == 19))'; + break; + case 'ctrl+enter': + $key_code = '(((e.which == 13 || e.which == 10) && (e.ctrlKey || e.metaKey)) || (e.which == 19))'; + break; + default: + return; } - + //filter direction + switch ($direction) { + case 'down': $direction = 'keydown'; + break; + case 'press': $direction = 'keypress'; + break; + case 'up': $direction = 'keyup'; + break; + } + //check for element exceptions + if (is_array($exceptions)) { + if (sizeof($exceptions) > 0) { + $exceptions = "!$(e.target).is('" . implode(',', $exceptions) . "') && "; + } + } + //quote if selector is id or class + $subject = ($subject != 'window' && $subject != 'document') ? "'" . $subject . "'" : $subject; + //output script + echo "\n\n\n"; + if ($script_wrapper) { + echo "\n"; + } + echo "\n\n\n"; } +} //format border radius values - if (!function_exists('format_border_radius')) { - - function format_border_radius($radius_value, $default = 5) { - $radius_value = (!empty($radius_value)) ? $radius_value : $default; - $br_a = explode(' ', $radius_value); - foreach ($br_a as $index => $br) { - if (substr_count($br, '%') > 0) { - $br_b[$index]['number'] = str_replace('%', '', $br); - $br_b[$index]['unit'] = '%'; - } else { - $br_b[$index]['number'] = str_replace('px', '', strtolower($br)); - $br_b[$index]['unit'] = 'px'; - } - } - unset($br_a, $br); - if (sizeof($br_b) == 4) { - $br['tl']['n'] = $br_b[0]['number']; - $br['tr']['n'] = $br_b[1]['number']; - $br['br']['n'] = $br_b[2]['number']; - $br['bl']['n'] = $br_b[3]['number']; - $br['tl']['u'] = $br_b[0]['unit']; - $br['tr']['u'] = $br_b[1]['unit']; - $br['br']['u'] = $br_b[2]['unit']; - $br['bl']['u'] = $br_b[3]['unit']; - } else if (sizeof($br_b) == 2) { - $br['tl']['n'] = $br_b[0]['number']; - $br['tr']['n'] = $br_b[0]['number']; - $br['br']['n'] = $br_b[1]['number']; - $br['bl']['n'] = $br_b[1]['number']; - $br['tl']['u'] = $br_b[0]['unit']; - $br['tr']['u'] = $br_b[0]['unit']; - $br['br']['u'] = $br_b[1]['unit']; - $br['bl']['u'] = $br_b[1]['unit']; +if (!function_exists('format_border_radius')) { + function format_border_radius($radius_value, $default = 5) { + $radius_value = (!empty($radius_value)) ? $radius_value : $default; + $br_a = explode(' ', $radius_value); + foreach ($br_a as $index => $br) { + if (substr_count($br, '%') > 0) { + $br_b[$index]['number'] = str_replace('%', '', $br); + $br_b[$index]['unit'] = '%'; } else { - $br['tl']['n'] = $br_b[0]['number']; - $br['tr']['n'] = $br_b[0]['number']; - $br['br']['n'] = $br_b[0]['number']; - $br['bl']['n'] = $br_b[0]['number']; - $br['tl']['u'] = $br_b[0]['unit']; - $br['tr']['u'] = $br_b[0]['unit']; - $br['br']['u'] = $br_b[0]['unit']; - $br['bl']['u'] = $br_b[0]['unit']; + $br_b[$index]['number'] = str_replace('px', '', strtolower($br)); + $br_b[$index]['unit'] = 'px'; } - unset($br_b); - - return $br; //array } + unset($br_a, $br); + if (sizeof($br_b) == 4) { + $br['tl']['n'] = $br_b[0]['number']; + $br['tr']['n'] = $br_b[1]['number']; + $br['br']['n'] = $br_b[2]['number']; + $br['bl']['n'] = $br_b[3]['number']; + $br['tl']['u'] = $br_b[0]['unit']; + $br['tr']['u'] = $br_b[1]['unit']; + $br['br']['u'] = $br_b[2]['unit']; + $br['bl']['u'] = $br_b[3]['unit']; + } else if (sizeof($br_b) == 2) { + $br['tl']['n'] = $br_b[0]['number']; + $br['tr']['n'] = $br_b[0]['number']; + $br['br']['n'] = $br_b[1]['number']; + $br['bl']['n'] = $br_b[1]['number']; + $br['tl']['u'] = $br_b[0]['unit']; + $br['tr']['u'] = $br_b[0]['unit']; + $br['br']['u'] = $br_b[1]['unit']; + $br['bl']['u'] = $br_b[1]['unit']; + } else { + $br['tl']['n'] = $br_b[0]['number']; + $br['tr']['n'] = $br_b[0]['number']; + $br['br']['n'] = $br_b[0]['number']; + $br['bl']['n'] = $br_b[0]['number']; + $br['tl']['u'] = $br_b[0]['unit']; + $br['tr']['u'] = $br_b[0]['unit']; + $br['br']['u'] = $br_b[0]['unit']; + $br['bl']['u'] = $br_b[0]['unit']; + } + unset($br_b); + return $br; //array } +} //converts a string to a regular expression - if (!function_exists('string_to_regex')) { - - function string_to_regex($string, $prefix = '') { - $original_string = $string; - //escape the plus - if (substr($string, 0, 1) == "+") { - $string = "^\\+(" . substr($string, 1) . ")$"; - } - //add prefix - if (!empty($prefix)) { - if (!empty($prefix) && strlen($prefix) < 4) { - $plus = (substr($string, 0, 1) == "+") ? '' : '\+?'; - $prefix = $plus . $prefix . '?'; - } else { - $prefix = '(?:' . $prefix . ')?'; - } - } - //convert N,X,Z syntax to regex - if (preg_match('/^[NnXxZz]+$/', $original_string)) { - $string = str_ireplace("N", "[2-9]", $string); - $string = str_ireplace("X", "[0-9]", $string); - $string = str_ireplace("Z", "[1-9]", $string); - } - //add ^ to the start of the string if missing - if (substr($string, 0, 1) != "^") { - $string = "^" . $string; - } - //add $ to the end of the string if missing - if (substr($string, -1) != "$") { - $string = $string . "$"; - } - //add the round brackets - if (!strstr($string, '(')) { - if (strstr($string, '^')) { - $string = str_replace("^", "^" . $prefix . "(", $string); - } else { - $string = '^(' . $string; - } - if (strstr($string, '$')) { - $string = str_replace("$", ")$", $string); - } else { - $string = $string . ')$'; - } - } - //return the result - return $string; +if (!function_exists('string_to_regex')) { + function string_to_regex($string, $prefix = '') { + $original_string = $string; + //escape the plus + if (substr($string, 0, 1) == "+") { + $string = "^\\+(" . substr($string, 1) . ")$"; } - - //$string = "+12089068227"; echo $string." ".string_to_regex($string)."\n"; - //$string = "12089068227"; echo $string." ".string_to_regex($string)."\n"; - //$string = "2089068227"; echo $string." ".string_to_regex($string)."\n"; - //$string = "^(20890682[0-9][0-9])$"; echo $string." ".string_to_regex($string)."\n"; - //$string = "1208906xxxx"; echo $string." ".string_to_regex($string)."\n"; - //$string = "nxxnxxxxxxx"; echo $string." ".string_to_regex($string)."\n"; - //$string = "208906xxxx"; echo $string." ".string_to_regex($string)."\n"; - //$string = "^(2089068227"; echo $string." ".string_to_regex($string)."\n"; - //$string = "^2089068227)"; echo $string." ".string_to_regex($string)."\n"; - //$string = "2089068227$"; echo $string." ".string_to_regex($string)."\n"; - //$string = "2089068227)$"; echo $string." ".string_to_regex($string)."\n"; + //add prefix + if (!empty($prefix)) { + if (!empty($prefix) && strlen($prefix) < 4) { + $plus = (substr($string, 0, 1) == "+") ? '' : '\+?'; + $prefix = $plus . $prefix . '?'; + } else { + $prefix = '(?:' . $prefix . ')?'; + } + } + //convert N,X,Z syntax to regex + if (preg_match('/^[NnXxZz]+$/', $original_string)) { + $string = str_ireplace("N", "[2-9]", $string); + $string = str_ireplace("X", "[0-9]", $string); + $string = str_ireplace("Z", "[1-9]", $string); + } + //add ^ to the start of the string if missing + if (substr($string, 0, 1) != "^") { + $string = "^" . $string; + } + //add $ to the end of the string if missing + if (substr($string, -1) != "$") { + $string = $string . "$"; + } + //add the round brackets + if (!strstr($string, '(')) { + if (strstr($string, '^')) { + $string = str_replace("^", "^" . $prefix . "(", $string); + } else { + $string = '^(' . $string; + } + if (strstr($string, '$')) { + $string = str_replace("$", ")$", $string); + } else { + $string = $string . ')$'; + } + } + //return the result + return $string; } + //$string = "+12089068227"; echo $string." ".string_to_regex($string)."\n"; + //$string = "12089068227"; echo $string." ".string_to_regex($string)."\n"; + //$string = "2089068227"; echo $string." ".string_to_regex($string)."\n"; + //$string = "^(20890682[0-9][0-9])$"; echo $string." ".string_to_regex($string)."\n"; + //$string = "1208906xxxx"; echo $string." ".string_to_regex($string)."\n"; + //$string = "nxxnxxxxxxx"; echo $string." ".string_to_regex($string)."\n"; + //$string = "208906xxxx"; echo $string." ".string_to_regex($string)."\n"; + //$string = "^(2089068227"; echo $string." ".string_to_regex($string)."\n"; + //$string = "^2089068227)"; echo $string." ".string_to_regex($string)."\n"; + //$string = "2089068227$"; echo $string." ".string_to_regex($string)."\n"; + //$string = "2089068227)$"; echo $string." ".string_to_regex($string)."\n"; +} + //dynamically load available web fonts - if (!function_exists('get_available_fonts')) { - - function get_available_fonts($sort = 'alpha') { - if (!empty($_SESSION['theme']['font_source_key']['text'])) { - if (!is_array($_SESSION['fonts_available']) || sizeof($_SESSION['fonts_available']) == 0) { - /* - sort options: - alpha - alphabetically - date - by date added (most recent font added or updated first) - popularity - by popularity (most popular family first) - style - by number of styles available (family with most styles first) - trending - by families seeing growth in usage (family seeing the most growth first) - */ - $google_api_url = 'https://www.googleapis.com/webfonts/v1/webfonts?key=' . $_SESSION['theme']['font_source_key']['text'] . '&sort=' . $sort; - $response = file_get_contents($google_api_url); - if (!empty($response)) { - $data = json_decode($response, true); - $items = $data['items']; - foreach ($items as $item) { - $fonts[] = $item['family']; - } - //echo "
".print_r($font_list, true)."
"; +if (!function_exists('get_available_fonts')) { + function get_available_fonts($sort = 'alpha') { + if (!empty($settings->get('theme', 'font_source_key'))) { + if (!is_array($_SESSION['fonts_available']) || sizeof($_SESSION['fonts_available']) == 0) { + /* + sort options: + alpha - alphabetically + date - by date added (most recent font added or updated first) + popularity - by popularity (most popular family first) + style - by number of styles available (family with most styles first) + trending - by families seeing growth in usage (family seeing the most growth first) + */ + $google_api_url = 'https://www.googleapis.com/webfonts/v1/webfonts?key=' . $settings->get('theme', 'font_source_key') . '&sort=' . $sort; + $response = file_get_contents($google_api_url); + if (!empty($response)) { + $data = json_decode($response, true); + $items = $data['items']; + foreach ($items as $item) { + $fonts[] = $item['family']; } - $_SESSION['fonts_available'] = $fonts; - unset($fonts); + //echo "
".print_r($font_list, true)."
"; } - return (is_array($_SESSION['fonts_available']) && sizeof($_SESSION['fonts_available']) > 0) ? $_SESSION['fonts_available'] : array(); - } else { - return false; + $_SESSION['fonts_available'] = $fonts; + unset($fonts); } + return (is_array($_SESSION['fonts_available']) && sizeof($_SESSION['fonts_available']) > 0) ? $_SESSION['fonts_available'] : array(); + } else { + return false; } - } +} //dynamically import web fonts (by reading static css file) - if (!function_exists('import_fonts')) { +if (!function_exists('import_fonts')) { + function import_fonts($file_to_parse, $line_styles_begin = null) { + /* + This function reads the contents of $file_to_parse, beginning at $line_styles_begin (if set), + and attempts to parse the specified google fonts used. The assumption is that each curly brace + will be on its own line, each CSS style (attribute: value;) will be on its own line, a single + Google Fonts name will be used per selector, and that it will be surrounded by SINGLE quotes, + as shown in the example below: - function import_fonts($file_to_parse, $line_styles_begin = null) { - /* - This function reads the contents of $file_to_parse, beginning at $line_styles_begin (if set), - and attempts to parse the specified google fonts used. The assumption is that each curly brace - will be on its own line, each CSS style (attribute: value;) will be on its own line, a single - Google Fonts name will be used per selector, and that it will be surrounded by SINGLE quotes, - as shown in the example below: + .class_name { + font-family: 'Google Font'; + font-weight: 300; + font-style: italic; + } - .class_name { - font-family: 'Google Font'; - font-weight: 300; - font-style: italic; - } + If the CSS styles are formatted as described, the necessary @import string should be generated + correctly. + */ - If the CSS styles are formatted as described, the necessary @import string should be generated - correctly. - */ + $file = file_get_contents($_SERVER["DOCUMENT_ROOT"] . $file_to_parse); + $lines = explode("\n", $file); - $file = file_get_contents($_SERVER["DOCUMENT_ROOT"] . $file_to_parse); - $lines = explode("\n", $file); - - $style_counter = 0; - foreach ($lines as $line_number => $line) { - if (!empty($line_styles_begin) && $line_number < $line_styles_begin - 1) { - continue; - } - if (substr_count($line, "{") > 0) { - $style_lines[$style_counter]['begins'] = $line_number; - } - if (substr_count($line, "}") > 0) { - $style_lines[$style_counter]['ends'] = $line_number; - $style_counter++; - } + $style_counter = 0; + foreach ($lines as $line_number => $line) { + if (!empty($line_styles_begin) && $line_number < $line_styles_begin - 1) { + continue; } - //echo "\n\n".print_r($style_lines, true)."\n\n"; + if (substr_count($line, "{") > 0) { + $style_lines[$style_counter]['begins'] = $line_number; + } + if (substr_count($line, "}") > 0) { + $style_lines[$style_counter]['ends'] = $line_number; + $style_counter++; + } + } + //echo "\n\n".print_r($style_lines, true)."\n\n"; - if (is_array($style_lines) && sizeof($style_lines) > 0) { + if (is_array($style_lines) && sizeof($style_lines) > 0) { - foreach ($style_lines as $index => $style_line) { - for ($l = $style_line['begins'] + 1; $l < $style_line['ends']; $l++) { - $tmp[] = $lines[$l]; + foreach ($style_lines as $index => $style_line) { + for ($l = $style_line['begins'] + 1; $l < $style_line['ends']; $l++) { + $tmp[] = $lines[$l]; + } + $style_groups[] = $tmp; + unset($tmp); + } + //echo "\n\n".print_r($style_groups, true)."\n\n"; + + if (is_array($style_groups) && sizeof($style_groups) > 0) { + + foreach ($style_groups as $style_group_index => $style_group) { + foreach ($style_group as $style_index => $style) { + $tmp = explode(':', $style); + $attribute = trim($tmp[0]); + $value = trim(trim($tmp[1]), ';'); + $style_array[$attribute] = $value; } - $style_groups[] = $tmp; - unset($tmp); + $style_groups[$style_group_index] = $style_array; + unset($style_array); } //echo "\n\n".print_r($style_groups, true)."\n\n"; - if (is_array($style_groups) && sizeof($style_groups) > 0) { - - foreach ($style_groups as $style_group_index => $style_group) { - foreach ($style_group as $style_index => $style) { - $tmp = explode(':', $style); - $attribute = trim($tmp[0]); - $value = trim(trim($tmp[1]), ';'); - $style_array[$attribute] = $value; - } - $style_groups[$style_group_index] = $style_array; - unset($style_array); + foreach ($style_groups as $style_group_index => $style_group) { + $style_value = $style_group['font-family']; + if (substr_count($style_value, "'") > 0) { + //determine font + $font_begin = strpos($style_value, "'") + 1; + $font_end = strpos($style_value, "'", $font_begin); + $font_name = substr($style_value, $font_begin, $font_end - $font_begin); + //determine modifiers + $weight = (is_numeric($style_group['font-weight']) || strtolower($style_group['font-weight']) == 'bold') ? strtolower($style_group['font-weight']) : null; + $italic = (strtolower($style_group['font-style']) == 'italic') ? 'italic' : null; + //add font to array + $fonts[$font_name][] = $weight . $italic; } - //echo "\n\n".print_r($style_groups, true)."\n\n"; + } + //echo "\n\n/*".print_r($fonts, true)."*/\n\n"; - foreach ($style_groups as $style_group_index => $style_group) { - $style_value = $style_group['font-family']; - if (substr_count($style_value, "'") > 0) { - //determine font - $font_begin = strpos($style_value, "'") + 1; - $font_end = strpos($style_value, "'", $font_begin); - $font_name = substr($style_value, $font_begin, $font_end - $font_begin); - //determine modifiers - $weight = (is_numeric($style_group['font-weight']) || strtolower($style_group['font-weight']) == 'bold') ? strtolower($style_group['font-weight']) : null; - $italic = (strtolower($style_group['font-style']) == 'italic') ? 'italic' : null; - //add font to array - $fonts[$font_name][] = $weight . $italic; + if (is_array($fonts)) { + foreach ($fonts as $font_name => $modifiers) { + $modifiers = array_unique($modifiers); + $import_font_string = str_replace(' ', '+', $font_name); + if (is_array($modifiers) && sizeof($modifiers) > 0) { + $import_font_string .= ':' . implode(',', $modifiers); } + $import_fonts[] = $import_font_string; } - //echo "\n\n/*".print_r($fonts, true)."*/\n\n"; - - if (is_array($fonts)) { - foreach ($fonts as $font_name => $modifiers) { - $modifiers = array_unique($modifiers); - $import_font_string = str_replace(' ', '+', $font_name); - if (is_array($modifiers) && sizeof($modifiers) > 0) { - $import_font_string .= ':' . implode(',', $modifiers); - } - $import_fonts[] = $import_font_string; - } - //echo "\n\n/*".print_r($import_fonts, true)."*/\n\n"; - $import_string = "@import url(//fonts.googleapis.com/css?family=" . implode('|', $import_fonts) . ");"; - echo $import_string . "\n"; - } + //echo "\n\n/*".print_r($import_fonts, true)."*/\n\n"; + $import_string = "@import url(//fonts.googleapis.com/css?family=" . implode('|', $import_fonts) . ");"; + echo $import_string . "\n"; } } } - } +} //retrieve array of countries - if (!function_exists('get_countries')) { - - function get_countries() { - global $database; - $sql = "select * from v_countries order by country asc"; - $result = $database->select($sql, null, 'all'); - unset($sql); - - return is_array($result) && @sizeof($result) != 0 ? $result : false; - } +if (!function_exists('get_countries')) { + function get_countries() { + global $database; + $sql = "select * from v_countries order by country asc"; + $result = $database->select($sql, null, 'all'); + unset($sql); + return is_array($result) && @sizeof($result) != 0 ? $result : false; } +} //make directory with event socket - function event_socket_mkdir($dir) { - //connect to fs - $esl = event_socket::create(); - if (!$esl->is_connected()) { - return false; - } - //send the mkdir command to freeswitch - //build and send the mkdir command to freeswitch - $switch_cmd = "lua mkdir.lua " . escapeshellarg($dir); - $switch_result = event_socket::api($switch_cmd); - //check result - if (trim($switch_result) == "-ERR no reply") { - return true; - } - - //can not create directory +function event_socket_mkdir($dir) { + //connect to fs + $esl = event_socket::create(); + if (!$esl->is_connected()) { return false; } + //send the mkdir command to freeswitch + //build and send the mkdir command to freeswitch + $switch_cmd = "lua mkdir.lua " . escapeshellarg($dir); + $switch_result = event_socket::api($switch_cmd); + //check result + if (trim($switch_result) == "-ERR no reply") { + return true; + } + + //can not create directory + return false; +} /** - * Escape the user data - *

Escapes all characters that have HTML character entity - * @param string $string the value to escape - * @return string - * @link https://www.php.net/htmlentities - */ +* Escape the user data +*

Escapes all characters that have HTML character entity +* @param string $string the value to escape +* @return string +* @link https://www.php.net/htmlentities +*/ function escape($string) { if (is_string($string)) { return htmlentities($string, ENT_QUOTES | ENT_HTML5, 'UTF-8'); @@ -2077,327 +1994,301 @@ function escape($string) { } /** - * Escape the user data for a textarea - *

Escapes & " ' < and > characters

- * @param string $string the value to escape - * @return string - * @link https://www.php.net/htmlspecialchars - */ +* Escape the user data for a textarea +*

Escapes & " ' < and > characters

+* @param string $string the value to escape +* @return string +* @link https://www.php.net/htmlspecialchars +*/ function escape_textarea($string) { return htmlspecialchars($string, ENT_QUOTES, 'UTF-8'); } //output pre-formatted array keys and values - if (!function_exists('view_array')) { - - function view_array($array, $exit = true, $return = false) { - $html = "
" . print_r($array, true) . '

'; - if ($return) { - return $html; - } else { - echo $html; - } - $exit and exit(); +if (!function_exists('view_array')) { + function view_array($array, $exit = true, $return = false) { + $html = "
" . print_r($array, true) . '

'; + if ($return) { + return $html; + } else { + echo $html; } - + $exit and exit(); } +} //format db date and/or time to local date and/or time - if (!function_exists('format_when_local')) { - - function format_when_local($when, $format = 'dt', $include_seconds = false) { - if (!empty($when)) { - // determine when format - if (substr_count($when, ' ') > 0) { // date and time - $tmp = explode(' ', $when); - $date = $tmp[0]; - $time = $tmp[1]; - } else if (substr_count($when, '-') > 0) { // date only - $date = $when; - } else if (substr_count($when, ':') > 0) { // time only - $time = $when; - } - unset($when, $tmp); - - // format date - if (!empty($date)) { - $tmp = explode('-', $date); - $date = $tmp[1] . '-' . $tmp[2] . '-' . $tmp[0]; - } - - // format time - if (!empty($time)) { - $tmp = explode(':', $time); - if ($tmp[0] >= 0 && $tmp[0] <= 11) { - $meridiem = 'AM'; - $hour = ($tmp[0] == 0) ? 12 : $tmp[0]; - } else { - $meridiem = 'PM'; - $hour = ($tmp[0] > 12) ? ($tmp[0] - 12) : $tmp[0]; - } - $minute = $tmp[1]; - $second = $tmp[2]; - } - - // structure requested time format - $time = $hour . ':' . $minute; - if ($include_seconds) { - $time .= ':' . $second; - } - $time .= ' ' . $meridiem; - - $return['d'] = $date; - $return['t'] = $time; - $return['dt'] = $date . ' ' . $time; - - return $return[$format]; - } else { - return false; +if (!function_exists('format_when_local')) { + function format_when_local($when, $format = 'dt', $include_seconds = false) { + if (!empty($when)) { + // determine when format + if (substr_count($when, ' ') > 0) { // date and time + $tmp = explode(' ', $when); + $date = $tmp[0]; + $time = $tmp[1]; + } else if (substr_count($when, '-') > 0) { // date only + $date = $when; + } else if (substr_count($when, ':') > 0) { // time only + $time = $when; } - } + unset($when, $tmp); + // format date + if (!empty($date)) { + $tmp = explode('-', $date); + $date = $tmp[1] . '-' . $tmp[2] . '-' . $tmp[0]; + } + + // format time + if (!empty($time)) { + $tmp = explode(':', $time); + if ($tmp[0] >= 0 && $tmp[0] <= 11) { + $meridiem = 'AM'; + $hour = ($tmp[0] == 0) ? 12 : $tmp[0]; + } else { + $meridiem = 'PM'; + $hour = ($tmp[0] > 12) ? ($tmp[0] - 12) : $tmp[0]; + } + $minute = $tmp[1]; + $second = $tmp[2]; + } + + // structure requested time format + $time = $hour . ':' . $minute; + if ($include_seconds) { + $time .= ':' . $second; + } + $time .= ' ' . $meridiem; + + $return['d'] = $date; + $return['t'] = $time; + $return['dt'] = $date . ' ' . $time; + + return $return[$format]; + } else { + return false; + } } +} //define email button (src: https://buttons.cm) - if (!function_exists('email_button')) { +if (!function_exists('email_button')) { + function email_button($text = 'Click Here!', $link = 'URL', $bg_color = '#dddddd', $fg_color = '#000000', $radius = '') { - function email_button($text = 'Click Here!', $link = 'URL', $bg_color = '#dddddd', $fg_color = '#000000', $radius = '') { + // default button radius + $radius = !empty($radius) ? $radius : '3px'; - // default button radius - $radius = !empty($radius) ? $radius : '3px'; - - // retrieve single/first numeric radius value for ms arc - $tmp = $radius; - if (substr_count($radius, ' ') > 0) { - $tmp = explode(' ', $radius); - $tmp = $tmp[0]; - } - $tmp = preg_replace("/[^0-9,.]/", '', $tmp); // remove non-numeric characters - $arc = floor($tmp / 35 * 100); // calculate percentage - // create button code - $btn = " -
- - " . $text . " - -
- "; - - return $btn; + // retrieve single/first numeric radius value for ms arc + $tmp = $radius; + if (substr_count($radius, ' ') > 0) { + $tmp = explode(' ', $radius); + $tmp = $tmp[0]; } + $tmp = preg_replace("/[^0-9,.]/", '', $tmp); // remove non-numeric characters + $arc = floor($tmp / 35 * 100); // calculate percentage + // create button code + $btn = " +
+ + " . $text . " + +
+ "; + return $btn; } +} //validate and format order by clause of select statement - if (!function_exists('order_by')) { - - function order_by($col, $dir, $col_default = '', $dir_default = 'asc', $sort = '') { - global $db_type; - $order_by = ' order by '; - $col = preg_replace('#[^a-zA-Z0-9-_.]#', '', $col ?? ''); - $dir = !empty($dir) && strtolower($dir) == 'desc' ? 'desc' : 'asc'; - if (!empty($col)) { - if ($sort == 'natural' && $db_type == "pgsql") { - return $order_by . 'natural_sort(' . $col . '::text) ' . $dir . ' '; - } else { - return $order_by . $col . ' ' . $dir . ' '; +if (!function_exists('order_by')) { + function order_by($col, $dir, $col_default = '', $dir_default = 'asc', $sort = '') { + global $db_type; + $order_by = ' order by '; + $col = preg_replace('#[^a-zA-Z0-9-_.]#', '', $col ?? ''); + $dir = !empty($dir) && strtolower($dir) == 'desc' ? 'desc' : 'asc'; + if (!empty($col)) { + if ($sort == 'natural' && $db_type == "pgsql") { + return $order_by . 'natural_sort(' . $col . '::text) ' . $dir . ' '; + } else { + return $order_by . $col . ' ' . $dir . ' '; + } + } else if (!empty($col_default)) { + if (is_array($col_default) && @sizeof($col_default) != 0) { + foreach ($col_default as $k => $column) { + $direction = (is_array($dir_default) && @sizeof($dir_default) != 0 && (strtolower($dir_default[$k]) == 'asc' || strtolower($dir_default[$k]) == 'desc')) ? $dir_default[$k] : 'asc'; + $order_bys[] = $column . ' ' . $direction . ' '; } - } else if (!empty($col_default)) { - if (is_array($col_default) && @sizeof($col_default) != 0) { - foreach ($col_default as $k => $column) { - $direction = (is_array($dir_default) && @sizeof($dir_default) != 0 && (strtolower($dir_default[$k]) == 'asc' || strtolower($dir_default[$k]) == 'desc')) ? $dir_default[$k] : 'asc'; - $order_bys[] = $column . ' ' . $direction . ' '; - } - if (is_array($order_bys) && @sizeof($order_bys) != 0) { - return $order_by . implode(', ', $order_bys); - } + if (is_array($order_bys) && @sizeof($order_bys) != 0) { + return $order_by . implode(', ', $order_bys); + } + } else { + if ($sort == 'natural' && $db_type == "pgsql") { + return $order_by . 'natural_sort(' . $col_default . '::text) ' . $dir_default . ' '; } else { - if ($sort == 'natural' && $db_type == "pgsql") { - return $order_by . 'natural_sort(' . $col_default . '::text) ' . $dir_default . ' '; - } else { - return $order_by . $col_default . ' ' . $dir_default . ' '; - } + return $order_by . $col_default . ' ' . $dir_default . ' '; } } } - } +} //validate and format limit and offset clause of select statement - if (!function_exists('limit_offset')) { - - function limit_offset($limit = null, $offset = 0) { - $regex = '#[^0-9]#'; - if (!empty($limit)) { - $limit = preg_replace($regex, '', $limit); - $offset = preg_replace($regex, '', $offset ?? ''); - if (is_numeric($limit) && $limit > 0) { - $clause = ' limit ' . $limit; - $offset = is_numeric($offset) ? $offset : 0; - $clause .= ' offset ' . $offset; - } - return $clause . ' '; - } else { - return ''; +if (!function_exists('limit_offset')) { + function limit_offset($limit = null, $offset = 0) { + $regex = '#[^0-9]#'; + if (!empty($limit)) { + $limit = preg_replace($regex, '', $limit); + $offset = preg_replace($regex, '', $offset ?? ''); + if (is_numeric($limit) && $limit > 0) { + $clause = ' limit ' . $limit; + $offset = is_numeric($offset) ? $offset : 0; + $clause .= ' offset ' . $offset; } + return $clause . ' '; + } else { + return ''; } - } +} //add a random_bytes function when it doesn't exist for old versions of PHP - if (!function_exists('random_bytes')) { - - function random_bytes($length) { - $chars .= "0123456789"; - $chars .= "abcdefghijkmnopqrstuvwxyz"; - $chars .= "ABCDEFGHIJKLMNPQRSTUVWXYZ"; - for ($i = 0; $i < $length; $i++) { - $string .= $chars[random_int(0, strlen($chars) - 1)]; - } - return $string . ' '; +if (!function_exists('random_bytes')) { + function random_bytes($length) { + $chars .= "0123456789"; + $chars .= "abcdefghijkmnopqrstuvwxyz"; + $chars .= "ABCDEFGHIJKLMNPQRSTUVWXYZ"; + for ($i = 0; $i < $length; $i++) { + $string .= $chars[random_int(0, strlen($chars) - 1)]; } - + return $string . ' '; } +} //add a hash_equals function when it doesn't exist for old versions of PHP - if (!function_exists('hash_equals')) { - - function hash_equals($var1, $var2) { - if ($var1 == $var2) { - return true; - } else { - return false; - } +if (!function_exists('hash_equals')) { + function hash_equals($var1, $var2) { + if ($var1 == $var2) { + return true; + } else { + return false; } - } +} //convert bytes to readable human format - if (!function_exists('byte_convert')) { - - function byte_convert($bytes, $precision = 2) { - static $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); - $step = 1024; - $i = 0; - while (($bytes / $step) > 0.9) { - $bytes = $bytes / $step; - $i++; - } - return round($bytes, $precision) . ' ' . $units[$i]; +if (!function_exists('byte_convert')) { + function byte_convert($bytes, $precision = 2) { + static $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); + $step = 1024; + $i = 0; + while (($bytes / $step) > 0.9) { + $bytes = $bytes / $step; + $i++; } - + return round($bytes, $precision) . ' ' . $units[$i]; } +} //convert bytes to readable human format - if (!function_exists('random_int')) { - - function random_int($min, $max) { - return rand($min, $max); - } - +if (!function_exists('random_int')) { + function random_int($min, $max) { + return rand($min, $max); } +} //manage submitted form values in a session array - if (!function_exists('persistent_form_values')) { - - function persistent_form_values($action, $array = null) { - switch ($action) { - case 'store': - // $array is expected to be an array of key / value pairs to store in the session - if (is_array($array) && @sizeof($array) != 0) { - $_SESSION['persistent'][$_SERVER['PHP_SELF']] = $array; - } - break; - case 'exists': - return !empty($_SESSION['persistent']) && is_array($_SESSION['persistent'][$_SERVER['PHP_SELF']]) && @sizeof($_SESSION['persistent'][$_SERVER['PHP_SELF']]) != 0 ? true : false; - break; - case 'load': - // $array is expected to be the name of the array to create containing the key / value pairs - if ($array && !is_array($array)) { - global $$array; - } - if (!empty($_SESSION['persistent']) && is_array($_SESSION['persistent'][$_SERVER['PHP_SELF']]) && @sizeof($_SESSION['persistent'][$_SERVER['PHP_SELF']]) != 0) { - foreach ($_SESSION['persistent'][$_SERVER['PHP_SELF']] as $key => $value) { - if ($key != 'XID' && $key != 'ACT' && $key != 'RET') { - if ($array && !is_array($array)) { - $$array[$key] = $value; - } else { - global $$key; - $$key = $value; - } +if (!function_exists('persistent_form_values')) { + function persistent_form_values($action, $array = null) { + switch ($action) { + case 'store': + // $array is expected to be an array of key / value pairs to store in the session + if (is_array($array) && @sizeof($array) != 0) { + $_SESSION['persistent'][$_SERVER['PHP_SELF']] = $array; + } + break; + case 'exists': + return !empty($_SESSION['persistent']) && is_array($_SESSION['persistent'][$_SERVER['PHP_SELF']]) && @sizeof($_SESSION['persistent'][$_SERVER['PHP_SELF']]) != 0 ? true : false; + break; + case 'load': + // $array is expected to be the name of the array to create containing the key / value pairs + if ($array && !is_array($array)) { + global $$array; + } + if (!empty($_SESSION['persistent']) && is_array($_SESSION['persistent'][$_SERVER['PHP_SELF']]) && @sizeof($_SESSION['persistent'][$_SERVER['PHP_SELF']]) != 0) { + foreach ($_SESSION['persistent'][$_SERVER['PHP_SELF']] as $key => $value) { + if ($key != 'XID' && $key != 'ACT' && $key != 'RET') { + if ($array && !is_array($array)) { + $$array[$key] = $value; + } else { + global $$key; + $$key = $value; } } - global $unsaved; - $unsaved = true; } - break; - case 'view': - if (is_array($_SESSION['persistent'][$_SERVER['PHP_SELF']]) && @sizeof($_SESSION['persistent'][$_SERVER['PHP_SELF']]) != 0) { - view_array($_SESSION['persistent'][$_SERVER['PHP_SELF']], false); - } - break; - case 'clear': - unset($_SESSION['persistent'][$_SERVER['PHP_SELF']]); - break; - } + global $unsaved; + $unsaved = true; + } + break; + case 'view': + if (is_array($_SESSION['persistent'][$_SERVER['PHP_SELF']]) && @sizeof($_SESSION['persistent'][$_SERVER['PHP_SELF']]) != 0) { + view_array($_SESSION['persistent'][$_SERVER['PHP_SELF']], false); + } + break; + case 'clear': + unset($_SESSION['persistent'][$_SERVER['PHP_SELF']]); + break; } - } +} //add alternative array_key_first for older verisons of PHP - if (!function_exists('array_key_first')) { - - function array_key_first(array $arr) { - foreach ($arr as $key => $unused) { - return $key; - } - return NULL; +if (!function_exists('array_key_first')) { + function array_key_first(array $arr) { + foreach ($arr as $key => $unused) { + return $key; } - + return NULL; } +} //get accountcode - if (!function_exists('get_accountcode')) { - - function get_accountcode() { - if (!empty($accountcode = $_SESSION['domain']['accountcode']['text'] ?? '')) { - if ($accountcode == "none") { - return; - } - } else { - $accountcode = $_SESSION['domain_name']; +if (!function_exists('get_accountcode')) { + function get_accountcode() { + if (!empty($accountcode = $settings->get('domain', 'accountcode') ?? '')) { + if ($accountcode == "none") { + return; } - return $accountcode; + } else { + $accountcode = $_SESSION['domain_name']; } - + return $accountcode; } +} //user exists - if (!function_exists('user_exists')) { - - function user_exists($login, $domain_name = null) { - //connect to freeswitch - $esl = event_socket::create(); - if (!$esl->is_connected()) { - return false; - } - - if (is_null($domain_name)) { - $domain_name = $_SESSION['domain_name']; - } - $switch_cmd = "user_exists id '$login' '$domain_name'"; - $switch_result = event_socket::api($switch_cmd); - return ($switch_result == 'true' ? true : false); +if (!function_exists('user_exists')) { + function user_exists($login, $domain_name = null) { + //connect to freeswitch + $esl = event_socket::create(); + if (!$esl->is_connected()) { + return false; } + if (is_null($domain_name)) { + $domain_name = $_SESSION['domain_name']; + } + $switch_cmd = "user_exists id '$login' '$domain_name'"; + $switch_result = event_socket::api($switch_cmd); + return ($switch_result == 'true' ? true : false); } +} //git pull if (!function_exists('git_pull')) { @@ -2461,11 +2352,11 @@ if (!function_exists('git_pull')) { } /** - * Check if the given directory is in the array of git safe directories. - * - * @param string $directory The directory to check. - * @return bool Returns true if the directory is safe, false otherwise. - */ +* Check if the given directory is in the array of git safe directories. +* +* @param string $directory The directory to check. +* @return bool Returns true if the directory is safe, false otherwise. +*/ function is_git_safe_directory($directory) { // Set the project root @@ -2561,7 +2452,6 @@ if (!function_exists('git_repo_info')) { else { return false; } - } } diff --git a/resources/header.php b/resources/header.php index 868bb54f72..08952d9008 100644 --- a/resources/header.php +++ b/resources/header.php @@ -56,13 +56,8 @@ //set the template base directory path $template_base_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes'; -//check if the template exists if it is missing then use the default - if (!file_exists($template_base_path.'/'.$_SESSION['domain']['template']['name'].'/template.php')) { - $_SESSION['domain']['template']['name'] = 'default'; - } - //start the output buffer - include $template_base_path.'/'.$_SESSION['domain']['template']['name'].'/config.php'; + include $template_base_path.'/'.$settings->get('domain', 'template', 'default').'/config.php'; //start the output buffer ob_start(); @@ -79,7 +74,7 @@ $sql = "select menu_item_parent_uuid from v_menu_items "; $sql .= "where menu_uuid = :menu_uuid "; $sql .= "and menu_item_link = :menu_item_link "; - $parameters['menu_uuid'] = $_SESSION['domain']['menu']['uuid']; + $parameters['menu_uuid'] = $settings->get('domain', 'menu'); $parameters['menu_item_link'] = $_SERVER["SCRIPT_NAME"]; $_SESSION["menu_item_parent_uuid"] = $database->select($sql, $parameters, 'column'); unset($sql, $parameters); @@ -126,7 +121,7 @@ $button_icon_style = 'padding: 3px;'; $button_label_class = 'button-label'; $button_label_style = 'padding-left: 5px; padding-right: 3px;'; - $button_icons = (!empty($_SESSION['theme']['button_icons']['text'])) ? $button_icons = $_SESSION['theme']['button_icons']['text'] : ''; + $button_icons = (!empty($settings->get('theme', 'button_icons'))) ? $button_icons = $settings->get('theme', 'button_icons') : ''; switch ($button_icons) { case 'auto': $button_label_class .= ' hide-md-dn'; @@ -157,4 +152,4 @@ require_once("app/translate/translate_header.php"); } -?> \ No newline at end of file +?> diff --git a/resources/login.php b/resources/login.php index b3b0c7eda0..0cd75b3b16 100644 --- a/resources/login.php +++ b/resources/login.php @@ -99,7 +99,7 @@ } $key = encrypt($settings->get('login', 'password_reset_key', ''), $result['username'].'|'.$result['domain_uuid'].'|'.$result['password']); $reset_link = "https://".$password_reset_domain.PROJECT_PATH."/resources/login.php?action=define&key=".urlencode($key); - $reset_button = email_button(strtoupper($text['label-reset_password']), $reset_link, ($_SESSION['theme']['button_background_color_email']['text'] ? $_SESSION['theme']['button_background_color_email']['text'] : '#2e82d0'), ($_SESSION['theme']['button_text_color_email']['text'] ? $_SESSION['theme']['button_text_color_email']['text'] : '#ffffff')); + $reset_button = email_button(strtoupper($text['label-reset_password']), $reset_link, ($settings->get('theme', 'button_background_color_email') ? $settings->get('theme', 'button_background_color_email') : '#2e82d0'), ($settings->get('theme', 'button_text_color_email') ? $settings->get('theme', 'button_text_color_email') : '#ffffff')); $logo_full = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPoAAABGCAYAAADl5IkzAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUu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th2I0Jd9dLbMyM6KCAWNSMsE9APKLFxLufE4i49pvESXGrra292vOqs7jApo2GY/NOfHIR/f0kHnqdYsGymzkmwaj9R+sYhS6N9D6NnlYRBE+8w7C97Qzr6QcfU0KIK8H2kFreuRnpC9duIntvjucN982o7F+2+rWl9e+fhyLXjo/fWsctmD1RcD13b0rgxIfQ55RSeEUkosMQ2SBUqRnUiqk5dn8J8w3LkfvIG++QjVXXIvg2cnlkRSLxwzcveqHg9IlWZJYX4vhHv41n29Riz45fpLCuZugnT6PWGaXWKL8BdIh7u6AyWZH78N/PKLQpcp4D35VcHjN83lD9ksXPO8+eO4+yWZU4eviR6ASTQnT/9XcmbsgHQ0E5JIpA3NOBRCyCSeu2dKot9ltob9u3WpbJx4HyAe9I79yKWjrpQml60aNSX180QvMD/rqdQu/fHpM8+7ZJva8+JMX97naanzoeu+MllzE1znKtq5dsp13VUobpLunzU+4QzbuGT3wQd+/eLPFD/efou2C8Nq+HXIaNsP+pje/RzjmEQmnTE+/QlHRcksQH6d9+Pfaul3wMmw78u1GqqnhA2v3GoSh9z/8udsZz4a41fkCgZo63x14m1zv+K8AAzpBEP7qfQcsAAAAASUVORK5CYII='; diff --git a/resources/pdo_vm.php b/resources/pdo_vm.php index 481fdafe1f..047d86691b 100644 --- a/resources/pdo_vm.php +++ b/resources/pdo_vm.php @@ -28,7 +28,7 @@ require_once __DIR__ . "/require.php"; //get the contents of xml_cdr.conf.xml - $conf_xml_string = file_get_contents($_SESSION['switch']['conf']['dir'].'/autoload_configs/voicemail.conf.xml'); + $conf_xml_string = file_get_contents($settings->get('switch', 'conf').'/autoload_configs/voicemail.conf.xml'); //parse the xml to get the call detail record info try { @@ -57,7 +57,7 @@ try { unset($db); if (empty($odbc_dsn)) { - $db = new PDO('sqlite:'.$_SESSION['switch']['db']['dir'].'/voicemail_default.db'); //sqlite 3 + $db = new PDO('sqlite:'.$settings->get('switch', 'db').'/voicemail_default.db'); //sqlite 3 } else { $db = new PDO("odbc:$odbc_dsn", "$odbc_db_user", "$odbc_db_pass"); diff --git a/resources/require.php b/resources/require.php index dbc326d533..3bc2b1f653 100644 --- a/resources/require.php +++ b/resources/require.php @@ -120,12 +120,12 @@ } //change language on the fly - for translate tool (if available) - if (!defined('STDIN') && isset($_REQUEST['view_lang_code']) && ($_REQUEST['view_lang_code']) != '') { - $_SESSION['domain']['language']['code'] = $_REQUEST['view_lang_code']; - } + //if (!defined('STDIN') && isset($_REQUEST['view_lang_code']) && ($_REQUEST['view_lang_code']) != '') { + // $_SESSION['domain']['language']['en-us'] = $_REQUEST['view_lang_code']; + //} //change the domain - if (!empty($_GET["domain_uuid"]) && is_uuid($_GET["domain_uuid"]) && $_GET["domain_change"] == "true" && permission_exists('domain_select')) { + if (!empty($_GET["domain_uuid"]) && is_uuid($_GET["domain_uuid"]) && !empty($_GET["domain_change"]) && $_GET["domain_change"] == "true" && permission_exists('domain_select')) { //include domains if (file_exists($_SERVER["PROJECT_ROOT"]."/app/domains/app_config.php") && !permission_exists('domain_all')) { @@ -150,7 +150,6 @@ //update the domain session variables $_SESSION["domain_name"] = $_SESSION['domains'][$domain_uuid]['domain_name']; - $_SESSION['domain']['template']['name'] = $_SESSION['domains'][$domain_uuid]['template_name'] ?? null; $_SESSION["context"] = $_SESSION["domain_name"]; //clear the extension array so that it is regenerated for the selected domain diff --git a/resources/switch.php b/resources/switch.php index 6942604fab..4ff0c9a857 100644 --- a/resources/switch.php +++ b/resources/switch.php @@ -115,14 +115,14 @@ function filename_safe($filename) { function save_gateway_xml() { + //declare the global variables + global $database, $settings, $domain_uuid, $config; + //skip saving the gateway xml if the directory is not set - if (empty($_SESSION['switch']['sip_profiles']['dir'])) { + if (empty($settings->get('switch', 'sip_profiles'))) { return; } - //declare the global variables - global $database, $domain_uuid, $config; - //delete all old gateways to prepare for new ones if (count($_SESSION["domains"]) > 1) { $v_needle = 'v_'.$_SESSION['domain_name'].'-'; @@ -130,7 +130,7 @@ function save_gateway_xml() { else { $v_needle = 'v_'; } - $gateway_list = glob($_SESSION['switch']['sip_profiles']['dir'] . "/*/".$v_needle."*.xml"); + $gateway_list = glob($settings->get('switch', 'sip_profiles') . "/*/".$v_needle."*.xml"); foreach ($gateway_list as $gateway_file) { unlink($gateway_file); } @@ -149,7 +149,7 @@ function save_gateway_xml() { $profile = "external"; } //open the xml file - $fout = fopen($_SESSION['switch']['sip_profiles']['dir']."/".$profile."/v_".strtolower($row['gateway_uuid']).".xml","w"); + $fout = fopen($settings->get('switch', 'sip_profiles')."/".$profile."/v_".strtolower($row['gateway_uuid']).".xml","w"); //build the xml $xml .= "\n"; $xml .= " \n"; @@ -254,63 +254,63 @@ function save_gateway_xml() { } function save_var_xml() { - if (!empty($_SESSION['switch']['conf']) && is_array($_SESSION['switch']['conf'])) { - //declare the global variables - global $database, $config, $domain_uuid; + //declare the global variables + global $database, $config, $settings, $domain_uuid; - //skip this function if the conf directory is empty - if (empty($_SESSION['switch']['conf']['dir'])) { - return false; - } - - //open the vars.xml file - $fout = fopen($_SESSION['switch']['conf']['dir']."/vars.xml","w"); - - //get the hostname - $hostname = trim(event_socket_request_cmd('api switchname')); - if (empty($hostname)) { - $hostname = trim(gethostname()); - } - if (empty($hostname)) { - return; - } - - //build the xml - $sql = "select * from v_vars "; - $sql .= "where var_enabled = true "; - $sql .= "order by var_category, var_order asc "; - $variables = $database->select($sql, null, 'all'); - $prev_var_category = ''; - $xml = ''; - if (!empty($variables)) { - foreach ($variables as $row) { - if ($row['var_category'] != 'Provision') { - if ($prev_var_category != $row['var_category']) { - $xml .= "\n\n"; - } - if (empty($row['var_command'])) { $row['var_command'] = 'set'; } - if ($row['var_category'] == 'Exec-Set') { $row['var_command'] = 'exec-set'; } - if (empty($row['var_hostname'])) { - $xml .= "\n"; - } elseif ($row['var_hostname'] == $hostname) { - $xml .= "\n"; - } - } - $prev_var_category = $row['var_category']; - } - } - $xml .= "\n"; - fwrite($fout, $xml); - unset($sql, $variables, $xml); - fclose($fout); - - //apply settings - $_SESSION["reload_xml"] = true; - - //$cmd = "api reloadxml"; - //event_socket_request_cmd($cmd); - //unset($cmd); + //skip this function if the conf directory is empty + $switch_conf_dir = $settings->get('switch', 'conf', $config->get('switch.conf.dir', '')); + if (empty($switch_conf_dir)) { + return false; } + + //open the vars.xml file + $fout = fopen($switch_conf_dir."/vars.xml","w"); + + //get the hostname + $hostname = trim(event_socket_request_cmd('api switchname')); + if (empty($hostname)) { + $hostname = trim(gethostname()); + } + if (empty($hostname)) { + return; + } + + //build the xml + $sql = "select * from v_vars "; + $sql .= "where var_enabled = true "; + $sql .= "order by var_category, var_order asc "; + $variables = $database->select($sql, null, 'all'); + $prev_var_category = ''; + $xml = ''; + if (!empty($variables)) { + foreach ($variables as $row) { + if ($row['var_category'] != 'Provision') { + if ($prev_var_category != $row['var_category']) { + $xml .= "\n\n"; + } + if (empty($row['var_command'])) { $row['var_command'] = 'set'; } + if ($row['var_category'] == 'Exec-Set') { $row['var_command'] = 'exec-set'; } + if (empty($row['var_hostname'])) { + $xml .= "\n"; + } elseif ($row['var_hostname'] == $hostname) { + $xml .= "\n"; + } + } + $prev_var_category = $row['var_category']; + } + } + $xml .= "\n"; + fwrite($fout, $xml); + unset($sql, $variables, $xml); + fclose($fout); + + //apply settings + $_SESSION["reload_xml"] = true; + + //$cmd = "api reloadxml"; + //event_socket_request_cmd($cmd); + //unset($cmd); + } function outbound_route_to_bridge($domain_uuid, $destination_number, array $channel_variables=null) { @@ -525,7 +525,8 @@ function extension_exists($extension) { } function extension_presence_id($extension, $number_alias = false) { - global $database, $domain_uuid; + //declare the global variables + global $database, $domain_uuid, $settings; if ($number_alias === false) { $sql = "select extension, number_alias from v_extensions "; @@ -548,7 +549,7 @@ function extension_presence_id($extension, $number_alias = false) { } if (!empty($number_alias)) { - if ($_SESSION['provision']['number_as_presence_id']['text'] === 'true') { + if ($settings->get('provision', 'number_as_presence_id') === 'true') { return $number_alias; } } @@ -556,6 +557,7 @@ function extension_presence_id($extension, $number_alias = false) { } function get_recording_filename($id) { + //declare the global variables global $database, $domain_uuid; $sql = "select * from v_recordings "; @@ -589,9 +591,10 @@ if (!function_exists('phone_letter_to_number')) { if (!function_exists('save_call_center_xml')) { function save_call_center_xml() { - global $database, $domain_uuid; + //declare the global variables + global $database, $domain_uuid, $settings; - if (!empty($_SESSION['switch']['call_center']['dir'])) { + if (!empty($settings->get('switch', 'call_center'))) { //get the call center queue array $sql = "select * from v_call_center_queues "; @@ -797,7 +800,7 @@ if (!function_exists('save_call_center_xml')) { unset($v_tiers); //write the XML config file - $fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/callcenter.conf.xml","w"); + $fout = fopen($settings->get('switch', 'conf')."/autoload_configs/callcenter.conf.xml","w"); fwrite($fout, $file_contents); fclose($fout); @@ -812,6 +815,9 @@ if (!function_exists('save_call_center_xml')) { if (!function_exists('switch_conf_xml')) { function switch_conf_xml() { + //declare the global variables + global $settings; + //get the contents of the template if (file_exists('/usr/share/examples/fusionpbx/resources/templates/conf')) { $path = "/usr/share/examples/fusionpbx/resources/templates/conf"; @@ -858,7 +864,7 @@ if (!function_exists('switch_conf_xml')) { unset ($v_mailer_app_args); //write the XML config file - $fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/switch.conf.xml","w"); + $fout = fopen($settings->get('switch', 'conf')."/autoload_configs/switch.conf.xml","w"); fwrite($fout, $file_contents); fclose($fout); @@ -892,7 +898,7 @@ if (!function_exists('xml_cdr_conf_xml')) { unset ($v_pass); //write the XML config file - $switch_configuration_dir = !empty($_SESSION['switch']['conf']['dir']) ? $_SESSION['switch']['conf']['dir'] : '/etc/freeswitch'; + $switch_configuration_dir = !empty($settings->get('switch', 'conf')) ? $settings->get('switch', 'conf') : '/etc/freeswitch'; $fout = fopen($switch_configuration_dir . "/autoload_configs/xml_cdr.conf.xml","w"); fwrite($fout, $file_contents); fclose($fout); @@ -905,15 +911,15 @@ if (!function_exists('xml_cdr_conf_xml')) { if (!function_exists('save_sip_profile_xml')) { function save_sip_profile_xml() { //declare the global variables - global $database; + global $database, $settings; //skip saving the sip profile xml if the directory is not set - if (empty($_SESSION['switch']['sip_profiles']['dir'])) { + if (empty($settings->get('switch', 'sip_profiles'))) { return; } // make profile dir if needed - $profile_dir = $_SESSION['switch']['conf']['dir']."/sip_profiles"; + $profile_dir = $settings->get('switch', 'conf')."/sip_profiles"; if (!is_readable($profile_dir)) { mkdir($profile_dir, 0770, false); } @@ -986,13 +992,16 @@ if (!function_exists('save_sip_profile_xml')) { if (!function_exists('save_switch_xml')) { function save_switch_xml() { - if (is_readable($_SESSION['switch']['extensions']['dir'])) { + //define the global settings + global $settings; + + if (is_readable($settings->get('switch', 'extensions'))) { if (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/extensions/resources/classes/extension.php")) { $extension = new extension; $extension->xml(); } } - if (is_readable($_SESSION['switch']['conf']['dir'])) { + if (is_readable($settings->get('switch', 'conf'))) { if (file_exists($_SERVER["PROJECT_ROOT"]."/app/settings/app_config.php")) { save_setting_xml(); }
\n"; - echo " ".(isset($_SESSION['theme']['title']['text']) ? $_SESSION['theme']['title']['text'] : 'FusionPBX')."\n"; + echo " ".$settings->get('theme', 'title', 'FusionPBX')."\n"; echo " \n"; echo " \n"; @@ -314,7 +314,7 @@ } if ($branch_return_value == 0 && $commit_return_value == 0) { echo " ".$git_current_branch.""; - echo "  \n"; + echo "  \n"; } echo "
".$text['label-address_country']."\n"; - $countries = get_countries($db); + $countries = get_countries($database); if (is_array($countries) && sizeof($countries) > 0) { echo " \n"; + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "
\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "
"; + + return $html; + } +} + +if (!function_exists('html_select')) { + function html_select($table_name, $field_name, $sql_where_optional, $field_current_value, $field_value = '', $style = '', $on_change = '') { + //html select: build a select box from distinct items in db + global $database, $domain_uuid; + + $table_name = preg_replace("#[^a-zA-Z0-9_]#", "", $table_name); + $field_name = preg_replace("#[^a-zA-Z0-9_]#", "", $field_name); + $field_value = preg_replace("#[^a-zA-Z0-9_]#", "", $field_value); + + if (!empty($field_value)) { + $html .= "\n"; + $html .= " \n"; + + $sql = "select distinct(" . $field_name . ") as " . $field_name . " from " . $table_name . " " . $sql_where_optional . " "; } - } - - //check if the permission exists - if (!function_exists('permission_exists')) { - - function permission_exists($permission_name) { - global $database, $domain_uuid, $user_uuid; - $permission = permissions::new($database, $domain_uuid, $user_uuid); - return $permission->exists($permission_name); - } - - } - - if (!function_exists('if_group_member')) { - - function if_group_member($group_members, $group) { - if (stripos($group_members, "||" . $group . "||") === false) { - return false; //group does not exist - } else { - return true; //group exists - } - } - - } - - if (!function_exists('superadmin_list')) { - - function superadmin_list() { - global $database, $domain_uuid; - $sql = "select * from v_user_groups "; - $sql .= "where group_name = 'superadmin' "; - $result = $database->select($sql, null, 'all'); - $superadmin_list = "||"; - if (is_array($result) && @sizeof($result) != 0) { - foreach ($result as $field) { - //get the list of superadmins - $superadmin_list .= $field['user_uuid'] . "||"; + $result = $database->select($sql, null, 'all'); + if (is_array($result) && @sizeof($result) != 0) { + foreach ($result as $field) { + if (!empty($field[$field_name])) { + $selected = $field_current_value == $field[$field_name] ? "selected='selected'" : null; + $array_key = empty($field_value) ? $field_name : $field_value; + $html .= "\n"; } } - unset($sql, $result, $field); - return $superadmin_list; } + unset($sql, $result, $field); + $html .= "\n"; + return $html; } +} - if (!function_exists('if_superadmin')) { +if (!function_exists('th_order_by')) { + //html table header order by + function th_order_by($field_name, $column_title, $order_by, $order, $app_uuid = '', $css = '', $http_get_params = '', $description = '') { + global $text; + if (is_uuid($app_uuid) > 0) { + $app_uuid = "&app_uuid=" . urlencode($app_uuid); + } // accomodate need to pass app_uuid where necessary (inbound/outbound routes lists) - function if_superadmin($superadmin_list, $user_uuid) { - if (stripos($superadmin_list, "||" . $user_uuid . "||") === false) { - return false; - } else { - return true; //user_uuid exists - } - } + $field_name = preg_replace("#[^a-zA-Z0-9_]#", "", $field_name); + $field_value = preg_replace("#[^a-zA-Z0-9_]#", "", $field_value ?? ''); - } - - if (!function_exists('html_select_other')) { - - function html_select_other($table_name, $field_name, $sql_where_optional, $field_current_value, $sql_order_by = null, $label_other = 'Other...') { - //html select other: build a select box from distinct items in db with option for other - global $database, $domain_uuid; - $table_name = preg_replace("#[^a-zA-Z0-9_]#", "", $table_name); - $field_name = preg_replace("#[^a-zA-Z0-9_]#", "", $field_name); - - $html = "\n"; - $html .= "\n"; - $html .= "\n"; - $html .= "\n"; - $html .= "\n"; - $html .= "
\n"; - $html .= "\n"; - $html .= "\n"; - $html .= "\n"; - $html .= "\n"; - $html .= "
"; - - return $html; - } - - } - - if (!function_exists('html_select')) { - - function html_select($table_name, $field_name, $sql_where_optional, $field_current_value, $field_value = '', $style = '', $on_change = '') { - //html select: build a select box from distinct items in db - global $database, $domain_uuid; - - $table_name = preg_replace("#[^a-zA-Z0-9_]#", "", $table_name); - $field_name = preg_replace("#[^a-zA-Z0-9_]#", "", $field_name); - $field_value = preg_replace("#[^a-zA-Z0-9_]#", "", $field_value); - - if (!empty($field_value)) { - $html .= "\n"; - $html .= " \n"; - - $sql = "select distinct(" . $field_name . ") as " . $field_name . " from " . $table_name . " " . $sql_where_optional . " "; - } - - $result = $database->select($sql, null, 'all'); - if (is_array($result) && @sizeof($result) != 0) { - foreach ($result as $field) { - if (!empty($field[$field_name])) { - $selected = $field_current_value == $field[$field_name] ? "selected='selected'" : null; - $array_key = empty($field_value) ? $field_name : $field_value; - $html .= "\n"; - } - } - } - unset($sql, $result, $field); - $html .= "\n"; - - return $html; - } - - } - - if (!function_exists('th_order_by')) { - - //html table header order by - function th_order_by($field_name, $column_title, $order_by, $order, $app_uuid = '', $css = '', $http_get_params = '', $description = '') { - global $text; - if (is_uuid($app_uuid) > 0) { - $app_uuid = "&app_uuid=" . urlencode($app_uuid); - } // accomodate need to pass app_uuid where necessary (inbound/outbound routes lists) - - $field_name = preg_replace("#[^a-zA-Z0-9_]#", "", $field_name); - $field_value = preg_replace("#[^a-zA-Z0-9_]#", "", $field_value ?? ''); - - $sanitized_parameters = ''; - if (isset($http_get_params) && !empty($http_get_params)) { - $parameters = explode('&', $http_get_params); - if (is_array($parameters)) { - foreach ($parameters as $parameter) { - if (substr_count($parameter, '=') != 0) { - $array = explode('=', $parameter); - $key = preg_replace('#[^a-zA-Z0-9_\-]#', '', $array['0']); - $value = urldecode($array['1']); - if ($key == 'order_by' && !empty($value)) { - //validate order by - $sanitized_parameters .= "&order_by=" . preg_replace('#[^a-zA-Z0-9_\-]#', '', $value); - } else if ($key == 'order' && !empty($value)) { - //validate order - switch ($value) { - case 'asc': - $sanitized_parameters .= "&order=asc"; - break; - case 'desc': - $sanitized_parameters .= "&order=desc"; - break; - } - } else if (!empty($value) && is_numeric($value)) { - $sanitized_parameters .= "&" . $key . "=" . $value; - } else { - $sanitized_parameters .= "&" . $key . "=" . urlencode($value); + $sanitized_parameters = ''; + if (isset($http_get_params) && !empty($http_get_params)) { + $parameters = explode('&', $http_get_params); + if (is_array($parameters)) { + foreach ($parameters as $parameter) { + if (substr_count($parameter, '=') != 0) { + $array = explode('=', $parameter); + $key = preg_replace('#[^a-zA-Z0-9_\-]#', '', $array['0']); + $value = urldecode($array['1']); + if ($key == 'order_by' && !empty($value)) { + //validate order by + $sanitized_parameters .= "&order_by=" . preg_replace('#[^a-zA-Z0-9_\-]#', '', $value); + } else if ($key == 'order' && !empty($value)) { + //validate order + switch ($value) { + case 'asc': + $sanitized_parameters .= "&order=asc"; + break; + case 'desc': + $sanitized_parameters .= "&order=desc"; + break; } + } else if (!empty($value) && is_numeric($value)) { + $sanitized_parameters .= "&" . $key . "=" . $value; + } else { + $sanitized_parameters .= "&" . $key . "=" . urlencode($value); } } } } + } - $html = "
"; - $description = empty($description) ? '' : $description . ', '; - if (empty($order_by)) { - $order = 'asc'; - } - if ($order_by == $field_name) { - if ($order == "asc") { - $description .= $text['label-order'] . ' ' . $text['label-descending']; - $html .= "" . escape($column_title) . ""; - } else { - $description .= $text['label-order'] . ' ' . $text['label-ascending']; - $html .= "" . escape($column_title) . ""; - } + $html = ""; + $description = empty($description) ? '' : $description . ', '; + if (empty($order_by)) { + $order = 'asc'; + } + if ($order_by == $field_name) { + if ($order == "asc") { + $description .= $text['label-order'] . ' ' . $text['label-descending']; + $html .= "" . escape($column_title) . ""; } else { $description .= $text['label-order'] . ' ' . $text['label-ascending']; $html .= "" . escape($column_title) . ""; } - $html .= "