From bf5bb4f642ea9be0157ae5863aebc1e2d892ef25 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 1 Nov 2025 19:58:21 -0600 Subject: [PATCH] Fix multiple PHP warnings --- .../resources/classes/access_controls.php | 2 +- .../resources/classes/call_center.php | 5 +- .../resources/classes/call_forward.php | 14 +- .../resources/classes/do_not_disturb.php | 3 +- .../resources/classes/follow_me.php | 2 +- .../resources/classes/call_recordings.php | 5 +- .../resources/classes/conference_centers.php | 2 +- app/devices/resources/classes/device.php | 1 + app/dialplans/resources/classes/dialplan.php | 59 ++- .../resources/classes/event_guard.php | 6 +- .../resources/classes/extension_settings.php | 38 +- .../resources/classes/extension.php | 1 + app/fifo/resources/classes/fifo.php | 1 + app/ivr_menus/resources/classes/ivr_menu.php | 9 +- .../classes/switch_music_on_hold.php | 71 +-- .../resources/classes/number_translations.php | 10 +- app/provision/index.php | 2 +- app/provision/resources/classes/provision.php | 54 ++- .../resources/functions/device_by.php | 4 + .../resources/classes/registrations.php | 11 +- .../resources/classes/time_conditions.php | 1 + .../resources/classes/authentication.php | 41 +- .../resources/classes/plugins/database.php | 9 + .../resources/classes/plugins/email.php | 12 +- .../resources/classes/plugins/ldap.php | 73 +-- .../resources/classes/plugins/totp.php | 17 +- core/contacts/resources/classes/contacts.php | 1 + .../dashboard/resources/classes/dashboard.php | 426 +++++++++--------- .../resources/classes/domain_settings.php | 3 +- core/groups/resources/classes/permission.php | 1 + resources/check_auth.php | 2 +- resources/classes/database.php | 14 +- resources/classes/domains.php | 2 +- resources/classes/email.php | 22 +- resources/classes/file.php | 9 +- resources/classes/menu.php | 14 +- resources/classes/schema.php | 16 +- resources/classes/sounds.php | 2 +- resources/classes/text.php | 2 +- resources/classes/tones.php | 9 +- resources/classes/xml.php | 5 + 41 files changed, 539 insertions(+), 442 deletions(-) diff --git a/app/access_controls/resources/classes/access_controls.php b/app/access_controls/resources/classes/access_controls.php index 6e61f3f084..5a74b24e10 100644 --- a/app/access_controls/resources/classes/access_controls.php +++ b/app/access_controls/resources/classes/access_controls.php @@ -216,7 +216,7 @@ //primary table $sql = "select * from v_" . $this->table . " "; $sql .= "where " . $this->uuid_prefix . "uuid in (" . implode(', ', $uuids) . ") "; - $rows = $this->database->select($sql, $parameters, 'all'); + $rows = $this->database->select($sql, null, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { $y = 0; foreach ($rows as $x => $row) { diff --git a/app/call_centers/resources/classes/call_center.php b/app/call_centers/resources/classes/call_center.php index c9f5b62e9c..31cb77e0ae 100644 --- a/app/call_centers/resources/classes/call_center.php +++ b/app/call_centers/resources/classes/call_center.php @@ -51,6 +51,9 @@ public $queue_description; public $destination_number; public $queue_cc_exit_keys; + public $queue_cid_prefix; + public $queue_greeting; + public $queue_timeout_action; /** * Set in the constructor. Must be a database object and cannot be null. @@ -526,7 +529,7 @@ //primary table $sql = "select * from v_".$this->table." "; $sql .= "where ".$this->uuid_prefix."uuid in ('".implode("','", $uuids)."') "; - $rows = $this->database->select($sql, $parameters, 'all'); + $rows = $this->database->select($sql, null, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { $y = 0; foreach ($rows as $x => $row) { diff --git a/app/call_forward/resources/classes/call_forward.php b/app/call_forward/resources/classes/call_forward.php index a2b6b2d9d2..be3ca17664 100644 --- a/app/call_forward/resources/classes/call_forward.php +++ b/app/call_forward/resources/classes/call_forward.php @@ -84,6 +84,8 @@ private $extension; private $number_alias; private $toll_allow; + private $toggle_field; + private $toggle_values; /** * called when the object is created @@ -156,6 +158,10 @@ */ public function toggle(array $records) { + //add multi-lingual support + $language = new text; + $text = $language->get(); + //validate the token $token = new token; if (!$token->validate($_SERVER['PHP_SELF'])) { @@ -170,14 +176,10 @@ //check we have permission for this action if (permission_exists('call_forward')) { - //add multi-lingual support - $language = new text; - $text = $language->get(); - // initialize an empty array $uuids = []; $extensions = []; - + //get current toggle state foreach ($records as $x => $record) { if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) { @@ -262,7 +264,7 @@ $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 = $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 c62c220cb7..da077bf25c 100644 --- a/app/call_forward/resources/classes/do_not_disturb.php +++ b/app/call_forward/resources/classes/do_not_disturb.php @@ -51,6 +51,7 @@ public $debug; public $extension_uuid; public $extension; + public $number_alias; public $enabled; /** @@ -110,7 +111,7 @@ $user_status = "Logged Out"; $esl = event_socket::create(); if ($esl->is_connected()) { - $switch_cmd .= "callcenter_config agent set status ".$this->username."@".$this->domain_name." '".$user_status."'"; + $switch_cmd = "callcenter_config agent set status ".$this->username."@".$this->domain_name." '".$user_status."'"; $esl->request('api '.$switch_cmd); } diff --git a/app/call_forward/resources/classes/follow_me.php b/app/call_forward/resources/classes/follow_me.php index 348f00057f..4ca203475e 100644 --- a/app/call_forward/resources/classes/follow_me.php +++ b/app/call_forward/resources/classes/follow_me.php @@ -430,7 +430,7 @@ $p->delete('follow_me_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 = $this->domain_name; diff --git a/app/call_recordings/resources/classes/call_recordings.php b/app/call_recordings/resources/classes/call_recordings.php index ca01f78aad..d73dcb4566 100644 --- a/app/call_recordings/resources/classes/call_recordings.php +++ b/app/call_recordings/resources/classes/call_recordings.php @@ -335,6 +335,7 @@ $call_recording_time = $row['call_recording_time']; $call_recording_date_formatted = $row['call_recording_date_formatted']; $call_recording_time_formatted = $row['call_recording_time_formatted']; + $call_recording_base64 = $row['call_recording_base64']; if (!empty($storage_type) && $storage_type == 'base64' && !empty($row['call_recording_base64'])) { file_put_contents($call_recording_path.'/'.$call_recording_name, base64_decode($row['call_recording_base64'])); } @@ -398,7 +399,7 @@ } //if base64, remove temp recording file - if (!empty($storage_type) && $storage_type == 'base64' && !empty($row['call_recording_base64'])) { + if (!empty($storage_type) && $storage_type == 'base64' && !empty($call_recording_base64)) { @unlink($full_recording_path); } @@ -446,7 +447,7 @@ $sql .= "TO_CHAR(timezone(:time_zone, call_recording_date), 'HH24MISS') AS call_recording_time, "; $sql .= "TO_CHAR(timezone(:time_zone, call_recording_date), 'DD Mon YYYY') as call_recording_date_formatted, "; $sql .= "TO_CHAR(timezone(:time_zone, call_recording_date), 'HH12:MI:SS am') as call_recording_time_formatted "; - if (!empty($storage_type) && $storage_type == 'base64' && $row['call_recording_base64'] != '') { + if (!empty($storage_type) && $storage_type == 'base64') { $sql .= ", call_recording_base64 "; } $sql .= "from view_call_recordings "; diff --git a/app/conference_centers/resources/classes/conference_centers.php b/app/conference_centers/resources/classes/conference_centers.php index c50cd50af8..8a5125e31a 100644 --- a/app/conference_centers/resources/classes/conference_centers.php +++ b/app/conference_centers/resources/classes/conference_centers.php @@ -124,7 +124,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'] = $user_uuid; + $parameters['user_uuid'] = $this->user_uuid; } if (isset($this->conference_room_uuid)) { $sql .= "and r.conference_room_uuid = :conference_room_uuid "; diff --git a/app/devices/resources/classes/device.php b/app/devices/resources/classes/device.php index 82e6c8ddd5..5e383fba9c 100644 --- a/app/devices/resources/classes/device.php +++ b/app/devices/resources/classes/device.php @@ -86,6 +86,7 @@ private $uuid_prefix; private $toggle_field; private $toggle_values; + private $tables; /** * Create a settings object using key/value pairs in the $setting_array. diff --git a/app/dialplans/resources/classes/dialplan.php b/app/dialplans/resources/classes/dialplan.php index d990d28b13..34dd6a260d 100644 --- a/app/dialplans/resources/classes/dialplan.php +++ b/app/dialplans/resources/classes/dialplan.php @@ -524,10 +524,10 @@ } if ($regex_match) { //get the variables - if ($field[dialplan_detail_type] == "set" && $field[dialplan_detail_tag] == "action") { + if ($field['dialplan_detail_type'] == "set" && $field['dialplan_detail_tag'] == "action") { //only set variables with values not variables - if (strpos($field[dialplan_detail_data], '$') === false) { - $this->variables .= $field[dialplan_detail_data].","; + if (strpos($field['dialplan_detail_data'], '$') === false) { + $this->variables .= $field['dialplan_detail_data'].","; } } //process the $x detail data variables @@ -700,9 +700,12 @@ } //define the values before they are used - $previous_dialplan_uuid = null; - $previous_dialplan_detail_group = null; - $dialplan_tag_status = null; + $previous_dialplan_uuid = ''; + $previous_dialplan_detail_group = ''; + $dialplan_tag_status = ''; + $condition_attribute = ''; + $condition_break = ''; + $xml = ''; //loop through the results to get the xml from the dialplan_xml field or from dialplan details table $x = 0; @@ -869,7 +872,7 @@ } //get the condition break attribute - $condition_break = ""; + $condition_break = ''; if ($dialplan_detail_break) { if (!empty($dialplan_detail_break)) { $condition_break = " break=\"" . $dialplan_detail_break . "\""; @@ -974,7 +977,7 @@ if ($condition_attribute && (!empty($condition_attribute))) { $xml .= " \n"; } - else if (!empty($condition) && substr($string, -1) == ">") { + else if (!empty($condition) && substr($condition, -1) == ">") { $xml .= $condition . "\n"; } else if (!empty($condition)) { @@ -1035,29 +1038,35 @@ $xml_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/resources/switch/conf/dialplan/*.xml"); foreach ($xml_list as $xml_file) { //get and parse the xml - $xml_string = file_get_contents($xml_file); - //get the order number prefix from the file name - $name_array = explode('_', basename($xml_file)); - if (is_numeric($name_array[0])) { - $dialplan_order = $name_array[0]; - } - else { - $dialplan_order = 0; - } - $dialplan->dialplan_order = $dialplan_order; + $xml_string = file_get_contents($xml_file); - $this->xml = $xml_string; - $this->import(); + //get the order number prefix from the file name + $name_array = explode('_', basename($xml_file)); + if (is_numeric($name_array[0])) { + $dialplan_order = $name_array[0]; + } + else { + $dialplan_order = 0; + } + + //set the xml string + $this->xml = $xml_string; + + //get the domains + $sql = 'select * from v_domains'; + $domains = $this->database->select($sql, null, 'all'); + $this->import($domains); + unset($sql); } //update the dialplan order - $sql[] = "update v_dialplans set dialplan_order = '870' where dialplan_order = '980' and dialplan_name = 'cidlookup' "; - $sql[] = "update v_dialplans set dialplan_order = '880' where dialplan_order = '990' and dialplan_name = 'call_screen' "; - $sql[] = "update v_dialplans set dialplan_order = '890' where dialplan_order = '999' and dialplan_name = 'local_extension' "; - foreach ($sql as $query) { + $sql_array[] = "update v_dialplans set dialplan_order = '870' where dialplan_order = '980' and dialplan_name = 'cidlookup' "; + $sql_array[] = "update v_dialplans set dialplan_order = '880' where dialplan_order = '990' and dialplan_name = 'call_screen' "; + $sql_array[] = "update v_dialplans set dialplan_order = '890' where dialplan_order = '999' and dialplan_name = 'local_extension' "; + foreach ($sql_array as $query) { $this->database->execute($query); } - unset($sql, $query); + unset($sql_array, $query); //add xml for each dialplan where the dialplan xml is empty $this->source = "details"; diff --git a/app/event_guard/resources/classes/event_guard.php b/app/event_guard/resources/classes/event_guard.php index 19172584b5..f76fa47bad 100644 --- a/app/event_guard/resources/classes/event_guard.php +++ b/app/event_guard/resources/classes/event_guard.php @@ -219,7 +219,7 @@ if (is_array($uuids) && @sizeof($uuids) != 0) { $sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; - $rows = $this->database->select($sql, $parameters, 'all'); + $rows = $this->database->select($sql, null, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { $states[$row['uuid']] = $row['toggle']; @@ -286,7 +286,7 @@ if (is_array($uuids) && @sizeof($uuids) != 0) { $sql = "select * from v_".$this->table." "; $sql .= "where event_guard_log_uuid in (".implode(', ', $uuids).") "; - $rows = $this->database->select($sql, $parameters, 'all'); + $rows = $this->database->select($sql, null, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { $x = 0; foreach ($rows as $row) { @@ -302,7 +302,7 @@ $array[$this->table][$x] = $row; //add copy to the description - $array[$this->table][$x][event_guard_log.'_uuid'] = uuid(); + $array[$this->table][$x]['event_guard_log_uuid'] = uuid(); //increment the id $x++; diff --git a/app/extension_settings/resources/classes/extension_settings.php b/app/extension_settings/resources/classes/extension_settings.php index fb08b8cb91..cb6423c609 100644 --- a/app/extension_settings/resources/classes/extension_settings.php +++ b/app/extension_settings/resources/classes/extension_settings.php @@ -68,6 +68,7 @@ private $toggle_values; private $description_field; private $location; + private $extension_uuid; /** * called when the object is created @@ -117,6 +118,20 @@ 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'] = $this->domain_uuid; + + if (empty($this->extension_uuid)) { + $sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle, extension_uuid "; + $sql .= "from v_".$this->table." "; + $sql .= "where ".$this->name."_uuid in :uuid "; + $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; + $parameters['domain_uuid'] = $this->domain_uuid; + $parameters['uuid'] = $record['uuid']; + $rows = $this->database->select($sql, $parameters, 'all'); + if (is_array($rows) && @sizeof($rows) != 0) { + $this->extension_uuid = $rows[0]['extension_uuid']; + } + unset($sql, $parameters); + } } //increment the id @@ -130,13 +145,15 @@ unset($array); //clear the cache - $sql = "select extension, number_alias, user_context from v_extensions "; - $sql .= "where extension_uuid = :extension_uuid "; - $parameters['extension_uuid'] = $this->extension_uuid; - $extension = $this->database->select($sql, $parameters, 'row'); - $cache = new cache; - $cache->delete(gethostname().":directory:".$extension["extension"]."@".$extension["user_context"]); - $cache->delete(gethostname().":directory:".$extension["number_alias"]."@".$extension["user_context"]); + if (!empty($this->extension_uuid)) { + $sql = "select extension, number_alias, user_context from v_extensions "; + $sql .= "where extension_uuid = :extension_uuid "; + $parameters['extension_uuid'] = $this->extension_uuid; + $extension = $this->database->select($sql, $parameters, 'row'); + $cache = new cache; + $cache->delete(gethostname().":directory:".$extension["extension"]."@".$extension["user_context"]); + $cache->delete(gethostname().":directory:".$extension["number_alias"]."@".$extension["user_context"]); + } //set message message::add($text['message-delete']); @@ -179,7 +196,7 @@ $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']; + $this->extension_uuid = $rows[0]['extension_uuid']; foreach ($rows as $row) { $states[$row['uuid']] = $row['toggle']; } @@ -208,7 +225,7 @@ //clear the cache $sql = "select extension, number_alias, user_context from v_extensions "; $sql .= "where extension_uuid = :extension_uuid "; - $parameters['extension_uuid'] = $extension_uuid; + $parameters['extension_uuid'] = $this->extension_uuid; $extension = $this->database->select($sql, $parameters, 'row'); $cache = new cache; $cache->delete(gethostname().":directory:".$extension["extension"]."@".$extension["user_context"]); @@ -259,8 +276,6 @@ $rows = $this->database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $x => $row) { -// var_dump($row); exit; - //convert boolean values to a string foreach($row as $key => $value) { if (gettype($value) == 'boolean') { @@ -285,7 +300,6 @@ //save the changes and set the message if (is_array($array) && @sizeof($array) != 0) { //save the array - $this->database->save($array); unset($array); diff --git a/app/extensions/resources/classes/extension.php b/app/extensions/resources/classes/extension.php index a86e051409..d18b1ed0f9 100644 --- a/app/extensions/resources/classes/extension.php +++ b/app/extensions/resources/classes/extension.php @@ -246,6 +246,7 @@ $call_group = $row['call_group'] ?? ''; $call_group = str_replace(";", ",", $call_group); $tmp_array = explode(",", $call_group); + $call_group_array = []; foreach ($tmp_array as $tmp_call_group) { $tmp_call_group = trim($tmp_call_group); if (!empty($tmp_call_group)) { diff --git a/app/fifo/resources/classes/fifo.php b/app/fifo/resources/classes/fifo.php index 1a63a5a4e9..206eb852ca 100644 --- a/app/fifo/resources/classes/fifo.php +++ b/app/fifo/resources/classes/fifo.php @@ -32,6 +32,7 @@ private $toggle_values; private $description_field; private $location; + private $uuid_prefix; /** * called when the object is created diff --git a/app/ivr_menus/resources/classes/ivr_menu.php b/app/ivr_menus/resources/classes/ivr_menu.php index a01065509e..6b3167770a 100644 --- a/app/ivr_menus/resources/classes/ivr_menu.php +++ b/app/ivr_menus/resources/classes/ivr_menu.php @@ -40,10 +40,17 @@ public $domain_uuid; /** - * declare public variables + * declare ivr menu primary uuid key + * @var string */ public $ivr_menu_uuid; + /** + * declare order_by variables + * @var string + */ + public $order_by; + /** * Set in the constructor. Must be a database object and cannot be null. * @var database Database Object 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 5546440a81..564820442b 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 @@ -48,25 +48,25 @@ 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 + * User UUID set in the constructor. This can be passed in through the $this->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 + * Username set in the constructor. This can be passed in through the $this->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 + * Domain UUID set in the constructor. This can be passed in through the $this->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 + * Domain name set in the constructor. This can be passed in through the $this->settings_array associative array or set in the session global array * @var string */ private $domain_name; @@ -188,12 +188,18 @@ } public function reload() { + //add multi-lingual support + $language = new text; + $text = $language->get(); + //if the handle does not exist create it $esl = event_socket::create(); + //if the handle still does not exist show an error message if (!$esl->is_connected()) { $msg = "
".$text['message-event-socket']."
"; } + //send the api command to check if the module exists if ($esl->is_connected()) { $cmd = "reload mod_local_stream"; @@ -202,48 +208,6 @@ } } - public function xml() { - //build the list of categories - $music_on_hold_dir = $this->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); - $array_3 = glob($music_on_hold_dir."/32000".$class_name.".php", GLOB_ONLYDIR); - $array_4 = glob($music_on_hold_dir."/48000".$class_name.".php", GLOB_ONLYDIR); - $array = array_merge((array)$array_1,(array)$array_2,(array)$array_3,(array)$array_4); - unset($array_1,$array_2,$array_3,$array_4); - //other categories - if (count($_SESSION['domains']) > 1) { - $array = array_merge($array, glob($music_on_hold_dir."/*/*/*", GLOB_ONLYDIR)); - } - else { - $array = array_merge($array, glob($music_on_hold_dir."/*/*", GLOB_ONLYDIR)); - } - //list the categories - $xml = ""; - foreach($array as $moh_dir) { - //set the directory - $moh_dir = substr($moh_dir, strlen($music_on_hold_dir."/")); - //get and set the rate - $sub_array = explode("/", $moh_dir); - $moh_rate = end($sub_array); - //set the name - $moh_name = $moh_dir; - if ($moh_dir == $moh_rate) { - $moh_name = "default/$moh_rate"; - } - //build the xml - $xml .= " \n"; - $xml .= " \n"; - $xml .= " \n"; - $xml .= " \n"; - $xml .= " \n"; - $xml .= " \n"; - $xml .= " \n"; - $this->xml = $xml; - } - } - public function save() { //get the contents of the template if (file_exists('/usr/share/examples/fusionpbx')) { @@ -254,7 +218,7 @@ } //check where the default music is stored $default_moh_prefix = 'music/default'; - if(file_exists($settings->get('switch', 'sounds').'/music/8000')) { + if(file_exists($this->settings->get('switch', 'sounds').'/music/8000')) { $default_moh_prefix = 'music'; } //replace the variables @@ -262,7 +226,7 @@ $file_contents = preg_replace("/[\t ]*(?:)?/", $this->xml, $file_contents); //write the XML config file - $fout = fopen($settings->get('switch', 'conf')."/autoload_configs/local_stream.conf.xml","w"); + $fout = fopen($this->settings->get('switch', 'conf')."/autoload_configs/local_stream.conf.xml","w"); fwrite($fout, $file_contents); fclose($fout); @@ -288,7 +252,7 @@ //build an array of the sound files $music_directory = $this->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')); + $files = array_merge(glob($music_directory.'/*/*/*.wav'), glob($music_directory.'/*/*/*/*.wav')); } //build a new file array @@ -309,10 +273,9 @@ foreach($a2 as $sample_rate => $file_path) { //echo "domain_name ".$domain_name."
\n"; //echo "category_name ".$category_name."
\n"; - foreach($domains as $domain) { - //view_array($field, false); + foreach($domains as $field) { if ($field['domain_name'] === $domain_name) { - $domain_uuid = $domain['domain_uuid']; + $domain_uuid = $field['domain_uuid']; //echo "domain_uuid ".$domain_uuid."
\n"; } } @@ -320,7 +283,6 @@ if ($domain_name == 'global' || $domain_name == 'default') { $domain_uuid = null; } - //view_array($row, false); $array['music_on_hold'][$i]['music_on_hold_uuid'] = uuid(); $array['music_on_hold'][$i]['domain_uuid'] = $domain_uuid; @@ -350,7 +312,7 @@ //echo $this->database->message; unset($array); - $p->delete('music_on_hold_add', 'temp'); + $p->delete('music_on_hold_add', 'temp'); } /** @@ -375,7 +337,6 @@ if (is_array($records) && @sizeof($records) != 0) { //filter checked records -// view_array($records, 0); foreach ($records as $music_on_hold_uuid => $record) { if (is_uuid($music_on_hold_uuid)) { if ($record['checked'] == 'true') { diff --git a/app/number_translations/resources/classes/number_translations.php b/app/number_translations/resources/classes/number_translations.php index 0c10e446d5..e545adfa79 100644 --- a/app/number_translations/resources/classes/number_translations.php +++ b/app/number_translations/resources/classes/number_translations.php @@ -41,7 +41,6 @@ /** * declare private variables */ - private $database; private $permission_prefix; private $list_page; @@ -49,7 +48,10 @@ private $uuid_prefix; private $toggle_field; private $toggle_values; - public $xml; + private $json; + private $xml; + private $display_type; + /** * called when the object is created @@ -270,7 +272,7 @@ if (is_array($uuids) && @sizeof($uuids) != 0) { $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $rows = $this->database->select($sql, $parameters, 'all'); + $rows = $this->database->select($sql, null, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { $states[$row['uuid']] = $row['toggle']; @@ -338,7 +340,7 @@ //primary table $sql = "select * from v_".$this->table." "; $sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $rows = $this->database->select($sql, $parameters, 'all'); + $rows = $this->database->select($sql, null, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { $y = 0; foreach ($rows as $x => $row) { diff --git a/app/provision/index.php b/app/provision/index.php index 0d88bf138b..249191f2db 100644 --- a/app/provision/index.php +++ b/app/provision/index.php @@ -217,7 +217,7 @@ //send a request to a remote server to validate the MAC address and secret if (!empty($_SERVER['auth_server'])) { - $result = send_http_request($_SERVER['auth_server'], 'mac='.url_encode($_REQUEST['mac']).'&secret='.url_encode($_REQUEST['secret'])); + $result = send_http_request($_SERVER['auth_server'], 'mac='.urlencode($_REQUEST['mac']).'&secret='.urlencode($_REQUEST['secret'])); if ($result == "false") { syslog(LOG_WARNING, '['.$_SERVER['REMOTE_ADDR']."] provision attempt but the remote auth server said no for ".escape($_REQUEST['mac'])); http_error('404'); diff --git a/app/provision/resources/classes/provision.php b/app/provision/resources/classes/provision.php index e40dd57a9c..00c5009572 100644 --- a/app/provision/resources/classes/provision.php +++ b/app/provision/resources/classes/provision.php @@ -52,6 +52,7 @@ public $template_dir; public $device_address; public $device_template; + public $file; /** * Set in the constructor. Must be a database object and cannot be null. @@ -555,33 +556,38 @@ //get a new primary key $device_uuid = uuid(); - //prepare the array - $x = 0; - $array['devices'][$x]['domain_uuid'] = $domain_uuid; - $array['devices'][$x]['device_uuid'] = $device_uuid; - $array['devices'][$x]['device_address'] = $device_address; - $array['devices'][$x]['device_vendor'] = $device_vendor; - $array['devices'][$x]['device_enabled'] = true; - $array['devices'][$x]['device_template'] = $device_template; - $array['devices'][$x]['device_description'] = $_SERVER['HTTP_USER_AGENT']; + //prepare the auto insert enabled + if (!empty($device_address)) { + $device_vendor = device::get_vendor($device_address); - //add the dialplan permission - $p = permissions::new(); - $p->add("device_add", "temp"); - $p->add("device_edit", "temp"); + //prepare the array + $x = 0; + $array['devices'][$x]['domain_uuid'] = $domain_uuid; + $array['devices'][$x]['device_uuid'] = $device_uuid; + $array['devices'][$x]['device_address'] = $device_address; + $array['devices'][$x]['device_vendor'] = $device_vendor; + $array['devices'][$x]['device_enabled'] = true; + $array['devices'][$x]['device_template'] = $device_template; + $array['devices'][$x]['device_description'] = $_SERVER['HTTP_USER_AGENT']; - //save to the data - $this->database->app_name = 'devices'; - $this->database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e'; - if (!empty($device_uuid)) { - $this->database->uuid($device_uuid); + //add the dialplan permission + $p = permissions::new(); + $p->add("device_add", "temp"); + $p->add("device_edit", "temp"); + + //save to the data + $this->database->app_name = 'devices'; + $this->database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e'; + if (!empty($device_uuid)) { + $this->database->uuid($device_uuid); + } + $this->database->save($array); + $message = $this->database->message; + + //remove the temporary permission + $p->delete("device_add", "temp"); + $p->delete("device_edit", "temp"); } - $this->database->save($array); - $message = $this->database->message; - - //remove the temporary permission - $p->delete("device_add", "temp"); - $p->delete("device_edit", "temp"); } } //} diff --git a/app/provision/resources/functions/device_by.php b/app/provision/resources/functions/device_by.php index e781a1856b..b700d8e8a5 100644 --- a/app/provision/resources/functions/device_by.php +++ b/app/provision/resources/functions/device_by.php @@ -1,6 +1,8 @@ get(null, '/app/registrations'); + //initialize the id used in the registrations array $id = 0; @@ -116,8 +120,6 @@ } } - - //get the default settings $sql = "select sip_profile_name from v_sip_profiles "; $sql .= "where true "; @@ -142,10 +144,6 @@ //show an error message if ($xml_response == "Invalid Profile!") { - //add multi-lingual support - $language = new text; - $text = $language->get(null, '/app/registrations'); - //show the error message $xml_response = "".escape($text['label-message']).""; } @@ -407,6 +405,7 @@ //set message if (is_array($response_api)) { + $message = ''; foreach ($response_api as $registration_user => $response) { if (is_array($response['command'])) { foreach($response['command'] as $command) { diff --git a/app/time_conditions/resources/classes/time_conditions.php b/app/time_conditions/resources/classes/time_conditions.php index a5d8767366..7f81bc66e9 100644 --- a/app/time_conditions/resources/classes/time_conditions.php +++ b/app/time_conditions/resources/classes/time_conditions.php @@ -78,6 +78,7 @@ private $uuid_prefix; private $toggle_field; private $toggle_values; + private $dialplan_global; public function __construct(array $setting_array = []) { //set domain and user UUIDs diff --git a/core/authentication/resources/classes/authentication.php b/core/authentication/resources/classes/authentication.php index 403e4672ca..d68a612f3c 100644 --- a/core/authentication/resources/classes/authentication.php +++ b/core/authentication/resources/classes/authentication.php @@ -33,20 +33,39 @@ class authentication { /** - * Define variables and their scope + * Declare Public variables + * + * @var mixed */ - private $database; public $domain_uuid; public $user_uuid; public $domain_name; public $username; public $password; + public $key; + + /** + * Declare Private variables + * + * @var mixed + */ + private $database; + private $settings; /** * Called when the object is created */ public function __construct(array $setting_array = []) { - $this->database = $setting_array['database'] ?? database::new(); + //set the config object + $config = $setting_array['config'] ?? config::load(); + + //set the database connection + $this->database = $setting_array['database'] ?? database::new(['config' => $config]); + + //set the settings object + $this->settings = $setting_array['settings']; + + //intialize the object $this->user_uuid = null; } @@ -68,7 +87,7 @@ class authentication { } //create a settings object to pass to plugins - $settings = new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid]); + $this->settings = new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid]); //start the session if its not started if (session_status() === PHP_SESSION_NONE) { @@ -114,7 +133,7 @@ class authentication { $object->password = $this->password; } //initialize the plugin send the authentication object and settings - $array = $object->$name($this, $settings); + $array = $object->$name($this, $this->settings); //build a result array if (!empty($array) && is_array($array)) { @@ -187,11 +206,11 @@ class authentication { //user is authorized - get user settings, check user cidr if ($authorized) { //get the cidr restrictions from global, domain, and user default settings - $settings = new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); - $cidr_list = $settings->get('domain', 'cidr', []); + $this->settings = new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); + $cidr_list = $this->settings->get('domain', 'cidr', []); if (check_cidr($cidr_list, $_SERVER['REMOTE_ADDR'])) { //user passed the cidr check - self::create_user_session($result, $settings); + self::create_user_session($result, $this->settings); } else { //user failed the cidr check - no longer authorized $authorized = false; @@ -456,12 +475,10 @@ class authentication { } //set a default value for unqiue - if (empty($_SESSION["users"]["unique"]["text"])) { - $_SESSION["users"]["unique"]["text"] = 'false'; - } + $_SESSION["users"]["unique"]["text"] = $this->settings->get('users', 'unique', ''); //get the domain name from the username - if (!empty($_SESSION['username']) && $_SESSION["users"]["unique"]["text"] != "global") { + if (!empty($_SESSION['username']) && $this->settings->get('users', 'unique', '') != "global") { $username_array = explode("@", $_SESSION['username']); if (count($username_array) > 1) { //get the domain name diff --git a/core/authentication/resources/classes/plugins/database.php b/core/authentication/resources/classes/plugins/database.php index 9352e9b9f6..b2d3553227 100644 --- a/core/authentication/resources/classes/plugins/database.php +++ b/core/authentication/resources/classes/plugins/database.php @@ -57,6 +57,9 @@ class plugin_database { //pre-process some settings $theme_favicon = $settings->get('theme', 'favicon', PROJECT_PATH.'/themes/default/favicon.ico'); $theme_logo = $settings->get('theme', 'logo', PROJECT_PATH.'/themes/default/images/logo_login.png'); + $theme_login_type = $settings->get('theme', 'login_brand_type', ''); + $theme_login_image = $settings->get('theme', 'login_brand_image', ''); + $theme_login_text = $settings->get('theme', 'login_brand_text', ''); $theme_login_logo_width = $settings->get('theme', 'login_logo_width', 'auto; max-width: 300px'); $theme_login_logo_height = $settings->get('theme', 'login_logo_height', 'auto; max-height: 300px'); $theme_message_delay = 1000 * (float)$settings->get('theme', 'message_delay', 3000); @@ -67,6 +70,12 @@ class plugin_database { $login_destination = $settings->get('login', 'destination'); $users_unique = $settings->get('users', 'unique', ''); + //set the default login type and image + if (empty($theme_login_type)) { + $theme_login_type = 'image'; + $theme_login_image = $theme_logo; + } + //determine whether to show the forgot password for resetting the password $login_password_reset_enabled = false; if (!empty($settings->get('login', 'password_reset_key'))) { diff --git a/core/authentication/resources/classes/plugins/email.php b/core/authentication/resources/classes/plugins/email.php index 286aa75220..2e826cd0f4 100644 --- a/core/authentication/resources/classes/plugins/email.php +++ b/core/authentication/resources/classes/plugins/email.php @@ -41,6 +41,13 @@ class plugin_email { public $contact_uuid; public $debug; + /** + * Declare Private variables + * + * @var mixed + */ + private $database; + /** * Called when the object is created */ @@ -60,6 +67,9 @@ class plugin_email { //pre-process some settings $theme_favicon = $settings->get('theme', 'favicon', PROJECT_PATH.'/themes/default/favicon.ico'); $theme_logo = $settings->get('theme', 'logo', PROJECT_PATH.'/themes/default/images/logo_login.png'); + $theme_login_type = $settings->get('theme', 'login_brand_type', ''); + $theme_login_image = $settings->get('theme', 'login_brand_image', ''); + $theme_login_text = $settings->get('theme', 'login_brand_text', ''); $theme_login_logo_width = $settings->get('theme', 'login_logo_width', 'auto; max-width: 300px'); $theme_login_logo_height = $settings->get('theme', 'login_logo_height', 'auto; max-height: 300px'); $theme_message_delay = 1000 * (float)$settings->get('theme', 'message_delay', 3000); @@ -69,7 +79,7 @@ class plugin_email { //$login_domain_name = $settings->get('login', 'domain_name'); $login_destination = $settings->get('login', 'destination'); $users_unique = $settings->get('users', 'unique', ''); - + //get the domain $domain_array = explode(":", $_SERVER["HTTP_HOST"]); $domain_name = $domain_array[0]; diff --git a/core/authentication/resources/classes/plugins/ldap.php b/core/authentication/resources/classes/plugins/ldap.php index fdeff4dbc7..2d16a68cd3 100644 --- a/core/authentication/resources/classes/plugins/ldap.php +++ b/core/authentication/resources/classes/plugins/ldap.php @@ -8,15 +8,25 @@ class plugin_ldap { /** - * Declare public variables + * Declare Public variables + * + * @var mixed */ public $debug; public $domain_name; + public $domain_uuid; public $username; public $password; public $user_uuid; public $contact_uuid; + /** + * Declare Private variables + * + * @var mixed + */ + private $database; + /** * Called when the object is created */ @@ -37,13 +47,14 @@ class plugin_ldap { if ($_REQUEST["username"]) { //pre-process some settings - $settings['theme']['favicon'] = !empty($_SESSION['theme']['favicon']['text']) ? $_SESSION['theme']['favicon']['text'] : PROJECT_PATH.'/themes/default/favicon.ico'; - $settings['login']['destination'] = !empty($_SESSION['login']['destination']['text']) ? $_SESSION['login']['destination']['text'] : ''; - $settings['users']['unique'] = !empty($_SESSION['users']['unique']['text']) ? $_SESSION['users']['unique']['text'] : ''; - $settings['theme']['logo'] = !empty($_SESSION['theme']['logo']['text']) ? $_SESSION['theme']['logo']['text'] : PROJECT_PATH.'/themes/default/images/logo_login.png'; - $settings['theme']['login_logo_width'] = !empty($_SESSION['theme']['login_logo_width']['text']) ? $_SESSION['theme']['login_logo_width']['text'] : 'auto; max-width: 300px'; - $settings['theme']['login_logo_height'] = !empty($_SESSION['theme']['login_logo_height']['text']) ? $_SESSION['theme']['login_logo_height']['text'] : 'auto; max-height: 300px'; - $settings['theme']['background_video'] = isset($_SESSION['theme']['background_video'][0]) ? $_SESSION['theme']['background_video'][0] : null; + $theme_favicon = $settings->get('theme', 'favicon', PROJECT_PATH.'/themes/default/favicon.ico'); + $theme_logo = $settings->get('theme', 'logo', PROJECT_PATH.'/themes/default/images/logo_login.png'); + $login_destination = $settings->get('login', 'destination'); + $theme_login_logo_width = $settings->get('theme', 'login_logo_width', 'auto; max-width: 300px'); + $theme_login_logo_height = $settings->get('theme', 'login_logo_height', 'auto; max-height: 300px'); + $background_videos = $settings->get('theme', 'background_video', null); + $theme_background_video = (isset($background_videos) && is_array($background_videos)) ? $background_videos[0] : null; + $users_unique = $settings->get('users', 'unique', ''); //get the domain $domain_array = explode(":", $_SERVER["HTTP_HOST"]); @@ -72,12 +83,12 @@ class plugin_ldap { //assign default values to the template $view->assign("project_path", PROJECT_PATH); - $view->assign("login_destination_url", $settings['login']['destination']); - $view->assign("favicon", $settings['theme']['favicon']); - $view->assign("login_logo_width", $settings['theme']['login_logo_width']); - $view->assign("login_logo_height", $settings['theme']['login_logo_height']); - $view->assign("login_logo_source", $settings['theme']['logo']); - $view->assign("background_video", $settings['theme']['background_video']); + $view->assign("login_destination_url", $login_destination); + $view->assign("favicon", $theme_favicon); + $view->assign("login_logo_width", $theme_login_logo_width); + $view->assign("login_logo_height", $theme_login_logo_height); + $view->assign("login_logo_source", $theme_logo); + $view->assign("background_video", $theme_background_video); //add the token name and hash to the view //$view->assign("token_name", $token['name']); @@ -90,16 +101,16 @@ class plugin_ldap { } //use ldap to validate the user credentials - if (isset($_SESSION["ldap"]["certpath"])) { - $s = "LDAPTLS_CERT=" . $_SESSION["ldap"]["certpath"]["text"]; + if (!empty($settings->get('ldap', 'certpath', ''))) { + $s = "LDAPTLS_CERT=" . $settings->get('ldap', 'certpath', ''); putenv($s); } - if (isset($_SESSION["ldap"]["certkey"])) { - $s = "LDAPTLS_KEY=" . $_SESSION["ldap"]["certkey"]["text"]; + if (!empty($settings->get('ldap', 'certkey', ''))) { + $s = "LDAPTLS_KEY=" . $settings->get('ldap', 'certkey', ''); putenv($s); } - $host = $_SESSION["ldap"]["server_host"]["text"]; - $port = $_SESSION["ldap"]["server_port"]["numeric"]; + $host = $settings->get('ldap', 'server_host', ''); + $port = $settings->get('ldap', 'server_port', ''); $connect = ldap_connect($host, $port) or die("Could not connect to the LDAP server."); //ldap_set_option($connect, LDAP_OPT_NETWORK_TIMEOUT, 10); @@ -110,13 +121,13 @@ class plugin_ldap { $user_authorized = false; //provide backwards compatability - if (!empty($_SESSION["ldap"]["user_dn"]["text"])) { - $_SESSION["ldap"]["user_dn"][] = $_SESSION["ldap"]["user_dn"]["text"]; + if (!empty($settings->get('ldap', 'user_dn', ''))) { + $ldap_user_dn[] = $settings->get('ldap', 'user_dn', ''); } //check all user_dn in the array - foreach ($_SESSION["ldap"]["user_dn"] as $user_dn) { - $bind_dn = $_SESSION["ldap"]["user_attribute"]["text"]."=".$this->username.",".$user_dn; + foreach ($ldap_user_dn as $user_dn) { + $bind_dn = $settings->get('ldap', 'user_attribute', '')."=".$this->username.",".$user_dn; $bind_pw = $this->password; //Note: As of 4/16, the call below will fail randomly. PHP debug reports ldap_bind //called below with all arguments '*uninitialized*'. However, the debugger @@ -135,7 +146,7 @@ class plugin_ldap { if ($user_authorized) { $sql = "select * from v_users "; $sql .= "where username = :username "; - if ($settings['users']['unique'] != "global") { + if (!empty($users_unique) && $users_unique != "global") { //unique username per domain (not globally unique across system - example: email address) $sql .= "and domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $this->domain_uuid; @@ -144,10 +155,14 @@ class plugin_ldap { $parameters['username'] = $this->username; $row = $this->database->select($sql, $parameters, 'row'); if (is_array($row) && @sizeof($row) != 0) { - if ($settings['users']['unique'] == "global" && $row["domain_uuid"] != $this->domain_uuid) { - //get the domain uuid + if (!empty($users_unique) && $users_unique == "global" && $row["domain_uuid"] != $this->domain_uuid) { + //set the domain uuid $this->domain_uuid = $row["domain_uuid"]; - $this->domain_name = $_SESSION['domains'][$this->domain_uuid]['domain_name']; + + //set the domain name + $sql .= "select domain_name from v_domains where domain_uuid = :domain_uuid "; + $parameters['domain_uuid'] = $this->domain_uuid; + $this->domain_name = $this->database->select($sql, $parameters, 'column'); //set the domain session variables $_SESSION["domain_uuid"] = $this->domain_uuid; @@ -176,7 +191,7 @@ class plugin_ldap { $array['users'][0]['username'] = strtolower($this->username); $array['users'][0]['password'] = md5($salt.$password); $array['users'][0]['salt'] = $salt; - $array['users'][0]['add_date'] = now(); + $array['users'][0]['add_date'] = 'now()'; $array['users'][0]['add_user'] = strtolower($this->username); $array['users'][0]['user_enabled'] = true; diff --git a/core/authentication/resources/classes/plugins/totp.php b/core/authentication/resources/classes/plugins/totp.php index cf911c80a8..8ac120707a 100644 --- a/core/authentication/resources/classes/plugins/totp.php +++ b/core/authentication/resources/classes/plugins/totp.php @@ -32,15 +32,25 @@ class plugin_totp { /** - * Define variables and their scope + * Declare Public variables + * + * @var mixed */ public $debug; public $domain_name; + public $domain_uuid; public $username; public $password; public $user_uuid; public $user_email; public $contact_uuid; + + /** + * Declare Private variables + * + * @var mixed + */ + private $database; private $user_totp_secret; /** @@ -62,6 +72,9 @@ class plugin_totp { //pre-process some settings $theme_favicon = $settings->get('theme', 'favicon', PROJECT_PATH.'/themes/default/favicon.ico'); $theme_logo = $settings->get('theme', 'logo', PROJECT_PATH.'/themes/default/images/logo_login.png'); + $theme_login_type = $settings->get('theme', 'login_brand_type', ''); + $theme_login_image = $settings->get('theme', 'login_brand_image', ''); + $theme_login_text = $settings->get('theme', 'login_brand_text', ''); $theme_login_logo_width = $settings->get('theme', 'login_logo_width', 'auto; max-width: 300px'); $theme_login_logo_height = $settings->get('theme', 'login_logo_height', 'auto; max-height: 300px'); $theme_message_delay = 1000 * (float)$settings->get('theme', 'message_delay', 3000); @@ -71,7 +84,7 @@ class plugin_totp { //$login_domain_name = $settings->get('login', 'domain_name'); $login_destination = $settings->get('login', 'destination'); $users_unique = $settings->get('users', 'unique', ''); - + //get the username if (isset($_SESSION["username"])) { $this->username = $_SESSION["username"]; diff --git a/core/contacts/resources/classes/contacts.php b/core/contacts/resources/classes/contacts.php index fb8fe45727..1a37be4095 100644 --- a/core/contacts/resources/classes/contacts.php +++ b/core/contacts/resources/classes/contacts.php @@ -57,6 +57,7 @@ private $permission_prefix; private $list_page; private $tables; + private $table; private $uuid_prefix; /** diff --git a/core/dashboard/resources/classes/dashboard.php b/core/dashboard/resources/classes/dashboard.php index 87914225ec..96cffed905 100644 --- a/core/dashboard/resources/classes/dashboard.php +++ b/core/dashboard/resources/classes/dashboard.php @@ -328,47 +328,49 @@ $this->name = 'dashboard_widget'; $this->table = 'dashboard_widgets'; - if (permission_exists($this->name.'_delete')) { + //permission not found return false + if (!permission_exists($this->name.'_delete')) { + return false; + } - //validate the token - $token = new token; - if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) { - message::add($this->text['message-invalid_token'],'negative'); - header('Location: '.$this->location); - exit; - } + //add multi-lingual support + $language = new text; + $text = $language->get(); - //add multi-lingual support - $language = new text; - $text = $language->get(); + //validate the token + $token = new token; + if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) { + message::add($text['message-invalid_token'],'negative'); + header('Location: '.$this->location); + exit; + } - //delete multiple records - if (is_array($records) && @sizeof($records) != 0) { - //build the delete array - $x = 0; - foreach ($records as $record) { - //add to the array - if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) { - $array[$this->table][$x]['dashboard_widget_uuid'] = $record['dashboard_widget_uuid']; - $array[$this->name.'_groups'][$x]['dashboard_widget_uuid'] = $record['dashboard_widget_uuid']; - } + //delete multiple records + if (is_array($records) && @sizeof($records) != 0) { + //build the delete array + $x = 0; + foreach ($records as $record) { + //add to the array + if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) { + $array[$this->table][$x]['dashboard_widget_uuid'] = $record['dashboard_widget_uuid']; + $array[$this->name.'_groups'][$x]['dashboard_widget_uuid'] = $record['dashboard_widget_uuid']; + } - //increment the id - $x++; - } + //increment the id + $x++; + } - //delete the checked rows - if (is_array($array) && @sizeof($array) != 0) { - //execute delete - $this->database->delete($array); - unset($array); + //delete the checked rows + if (is_array($array) && @sizeof($array) != 0) { + //execute delete + $this->database->delete($array); + unset($array); - //set message - message::add($text['message-delete']); - } - unset($records); - } - } + //set message + message::add($text['message-delete']); + } + unset($records); + } } public function toggle_widgets($records) { @@ -377,64 +379,66 @@ $this->table = 'dashboard_widgets'; $this->toggle_field = 'widget_enabled'; - if (permission_exists($this->name.'_edit')) { + //permission not found return false + if (!permission_exists($this->name.'_edit')) { + return false; + } - //add multi-lingual support - $language = new text; - $text = $language->get(); + //add multi-lingual support + $language = new text; + $text = $language->get(); - //validate the token - $token = new token; - if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) { - message::add($this->text['message-invalid_token'],'negative'); - header('Location: '.$this->location); - exit; - } + //validate the token + $token = new token; + if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) { + message::add($text['message-invalid_token'],'negative'); + header('Location: '.$this->location); + exit; + } - //toggle the checked records - if (is_array($records) && @sizeof($records) != 0) { - //get current toggle state - foreach($records as $record) { - if (isset($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) { - $uuids[] = "'".$record['dashboard_widget_uuid']."'"; + //toggle the checked records + if (is_array($records) && @sizeof($records) != 0) { + //get current toggle state + foreach($records as $record) { + if (isset($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) { + $uuids[] = "'".$record['dashboard_widget_uuid']."'"; + } + } + if (is_array($uuids) && @sizeof($uuids) != 0) { + $sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; + $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; + $rows = $this->database->select($sql, $parameters ?? null, 'all'); + if (is_array($rows) && @sizeof($rows) != 0) { + foreach ($rows as $row) { + $states[$row['uuid']] = $row['toggle']; } } - if (is_array($uuids) && @sizeof($uuids) != 0) { - $sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; - $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; - $rows = $this->database->select($sql, $parameters ?? null, 'all'); - if (is_array($rows) && @sizeof($rows) != 0) { - foreach ($rows as $row) { - $states[$row['uuid']] = $row['toggle']; - } - } - unset($sql, $parameters, $rows, $row); - } + unset($sql, $parameters, $rows, $row); + } - //build update array - $x = 0; - foreach($states as $uuid => $state) { - //create the array - $array[$this->table][$x][$this->name.'_uuid'] = $uuid; - $array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0]; + //build update array + $x = 0; + foreach($states as $uuid => $state) { + //create the array + $array[$this->table][$x][$this->name.'_uuid'] = $uuid; + $array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0]; - //increment the id - $x++; - } + //increment the id + $x++; + } - //save the changes - if (is_array($array) && @sizeof($array) != 0) { - //save the array + //save the changes + if (is_array($array) && @sizeof($array) != 0) { + //save the array - $this->database->save($array); - unset($array); + $this->database->save($array); + unset($array); - //set message - message::add($text['message-toggle']); - } - unset($records, $states); - } - } + //set message + message::add($text['message-toggle']); + } + unset($records, $states); + } } public function assign_widgets($records, $dashboard_uuid, $group_uuid) { @@ -442,76 +446,78 @@ $this->name = 'dashboard_widget'; $this->table = 'dashboard_widgets'; - if (permission_exists($this->name.'_add')) { + //permission not found return false + if (!permission_exists($this->name.'_add')) { + return false; + } - //add multi-lingual support - $language = new text; - $text = $language->get(); + //add multi-lingual support + $language = new text; + $text = $language->get(); - //validate the token - $token = new token; - if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) { - message::add($text['message-invalid_token'],'negative'); - header('Location: '.$this->location); - exit; - } + //validate the token + $token = new token; + if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) { + message::add($text['message-invalid_token'],'negative'); + header('Location: '.$this->location); + exit; + } - //assign multiple records - if (is_array($records) && @sizeof($records) != 0 && !empty($group_uuid)) { + //assign multiple records + if (is_array($records) && @sizeof($records) != 0 && !empty($group_uuid)) { - //define the group_name and group_uuid - if (!empty($records) && @sizeof($records) != 0) { - $sql = "select group_name, group_uuid from v_groups "; - $sql .= "where group_uuid = :group_uuid "; - $parameters['group_uuid'] = $group_uuid; - $group = $this->database->select($sql, $parameters, 'row'); - } - - //build the delete array - $x = 0; - foreach ($records as $record) { - if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) { - //build array - $uuids[] = "'".$record['dashboard_widget_uuid']."'"; - //assign dashboard widget groups - $array[$this->name.'_groups'][$x][$this->name.'_group_uuid'] = uuid(); - $array[$this->name.'_groups'][$x]['dashboard_uuid'] = $dashboard_uuid; - $array[$this->name.'_groups'][$x][$this->name.'_uuid'] = $record['dashboard_widget_uuid']; - $array[$this->name.'_groups'][$x]['group_uuid'] = $group['group_uuid']; - //increment - $x++; - } - } - - unset($records); - - //exlude exist rows - if (!empty($array) && @sizeof($array) != 0) { - $sql = "select dashboard_uuid, ".$this->name."_uuid, "; - $sql .= "group_uuid from v_".$this->name."_groups "; - $dashboard_widget_groups = $this->database->select($sql, null, 'all'); - $array[$this->name.'_groups'] = array_filter($array[$this->name.'_groups'], function($ar) use ($dashboard_widget_groups) { - foreach ($dashboard_widget_groups as $existing_array_item) { - if ($ar['dashboard_uuid'] == $existing_array_item['dashboard_uuid'] && $ar[$this->name.'_uuid'] == $existing_array_item[$this->name.'_uuid'] && $ar['group_uuid'] == $existing_array_item['group_uuid']) { - return false; - } - } - return true; - }); - unset($dashboard_widget_groups); + //define the group_name and group_uuid + if (!empty($records) && @sizeof($records) != 0) { + $sql = "select group_name, group_uuid from v_groups "; + $sql .= "where group_uuid = :group_uuid "; + $parameters['group_uuid'] = $group_uuid; + $group = $this->database->select($sql, $parameters, 'row'); } - //add the checked rows from group - if (!empty($array) && is_array($array) && @sizeof($array) != 0) { - //execute save - - $this->database->save($array); - unset($array); - //set message - message::add($text['message-add']); + //build the delete array + $x = 0; + foreach ($records as $record) { + if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) { + //build array + $uuids[] = "'".$record['dashboard_widget_uuid']."'"; + //assign dashboard widget groups + $array[$this->name.'_groups'][$x][$this->name.'_group_uuid'] = uuid(); + $array[$this->name.'_groups'][$x]['dashboard_uuid'] = $dashboard_uuid; + $array[$this->name.'_groups'][$x][$this->name.'_uuid'] = $record['dashboard_widget_uuid']; + $array[$this->name.'_groups'][$x]['group_uuid'] = $group['group_uuid']; + //increment + $x++; } + } + + unset($records); + + //exlude exist rows + if (!empty($array) && @sizeof($array) != 0) { + $sql = "select dashboard_uuid, ".$this->name."_uuid, "; + $sql .= "group_uuid from v_".$this->name."_groups "; + $dashboard_widget_groups = $this->database->select($sql, null, 'all'); + $array[$this->name.'_groups'] = array_filter($array[$this->name.'_groups'], function($ar) use ($dashboard_widget_groups) { + foreach ($dashboard_widget_groups as $existing_array_item) { + if ($ar['dashboard_uuid'] == $existing_array_item['dashboard_uuid'] && $ar[$this->name.'_uuid'] == $existing_array_item[$this->name.'_uuid'] && $ar['group_uuid'] == $existing_array_item['group_uuid']) { + return false; + } + } + return true; + }); + unset($dashboard_widget_groups); } - } + + //add the checked rows from group + if (!empty($array) && is_array($array) && @sizeof($array) != 0) { + //execute save + $this->database->save($array); + unset($array); + + //set message + message::add($text['message-add']); + } + } } public function unassign_widgets($records, $dashboard_uuid, $group_uuid) { @@ -519,85 +525,87 @@ $this->name = 'dashboard_widget'; $this->table = 'dashboard_widgets'; - if (permission_exists($this->name.'_add')) { + //permission not found return now + if (!permission_exists($this->name.'_add')) { + return false; + } - //add multi-lingual support - $language = new text; - $text = $language->get(); + //add multi-lingual support + $language = new text; + $text = $language->get(); - //validate the token - $token = new token; - if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) { - message::add($text['message-invalid_token'],'negative'); - header('Location: '.$this->location); - exit; - } + //validate the token + $token = new token; + if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) { + message::add($text['message-invalid_token'],'negative'); + header('Location: '.$this->location); + exit; + } - //assign multiple records - if (is_array($records) && @sizeof($records) != 0 && !empty($group_uuid)) { + //assign multiple records + if (is_array($records) && @sizeof($records) != 0 && !empty($group_uuid)) { - //define the group_name and group_uuid - if (!empty($records) && @sizeof($records) != 0) { - $sql = "select group_name, group_uuid from v_groups "; - $sql .= "where group_uuid = :group_uuid "; - $parameters['group_uuid'] = $group_uuid; - $group = $this->database->select($sql, $parameters, 'row'); + //define the group_name and group_uuid + if (!empty($records) && @sizeof($records) != 0) { + $sql = "select group_name, group_uuid from v_groups "; + $sql .= "where group_uuid = :group_uuid "; + $parameters['group_uuid'] = $group_uuid; + $group = $this->database->select($sql, $parameters, 'row'); + } + + //build the delete array + $x = 0; + foreach ($records as $record) { + if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) { + //build array + $uuids[] = "'".$record['dashboard_widget_uuid']."'"; + //assign dashboard widget groups + $array[$this->name.'_groups'][$x]['dashboard_uuid'] = $dashboard_uuid; + $array[$this->name.'_groups'][$x][$this->name.'_uuid'] = $record['dashboard_widget_uuid']; + $array[$this->name.'_groups'][$x]['group_uuid'] = $group['group_uuid']; + //increment + $x++; } + } - //build the delete array - $x = 0; - foreach ($records as $record) { - if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) { - //build array - $uuids[] = "'".$record['dashboard_widget_uuid']."'"; + unset($records); + + //include child dashboard widgets and their dasboard_uuid too + if (!empty($uuids) && @sizeof($uuids) != 0) { + $sql = "select dashboard_uuid, ".$this->name."_uuid from v_".$this->table." "; + $sql .= "where ".$this->name."_parent_uuid in (".implode(', ', $uuids).") "; + $rows = $this->database->select($sql, null, 'all'); + if (!empty($rows) && @sizeof($rows) != 0) { + foreach ($rows as $row) { //assign dashboard widget groups - $array[$this->name.'_groups'][$x]['dashboard_uuid'] = $dashboard_uuid; - $array[$this->name.'_groups'][$x][$this->name.'_uuid'] = $record['dashboard_widget_uuid']; - $array[$this->name.'_groups'][$x]['group_uuid'] = $group['group_uuid']; + $array[$this->name.'_groups'][$x]['dashboard_uuid'] = $row['dashboard_uuid']; + $array[$this->name.'_groups'][$x][$this->name.'_uuid'] = $row['dashboard_widget_uuid']; + $array[$this->name.'_groups'][$x]['group_uuid'] = $group['group_uuid']; //increment - $x++; + $x++; } } + } - unset($records); + unset($uuids); - //include child dashboard widgets and their dasboard_uuid too - if (!empty($uuids) && @sizeof($uuids) != 0) { - $sql = "select dashboard_uuid, ".$this->name."_uuid from v_".$this->table." "; - $sql .= "where ".$this->name."_parent_uuid in (".implode(', ', $uuids).") "; - $rows = $this->database->select($sql, null, 'all'); - if (!empty($rows) && @sizeof($rows) != 0) { - foreach ($rows as $row) { - //assign dashboard widget groups - $array[$this->name.'_groups'][$x]['dashboard_uuid'] = $row['dashboard_uuid']; - $array[$this->name.'_groups'][$x][$this->name.'_uuid'] = $row['dashboard_widget_uuid']; - $array[$this->name.'_groups'][$x]['group_uuid'] = $group['group_uuid']; - //increment - $x++; - } - } - } + //add the checked rows from group + if (!empty($array) && is_array($array) && @sizeof($array) != 0) { + //grant temporary permissions + $p = new permissions; + $p->add('dashboard_widget_group_delete', 'temp'); - unset($uuids); + //execute delete + $this->database->delete($array); + unset($array); - //add the checked rows from group - if (!empty($array) && is_array($array) && @sizeof($array) != 0) { - //grant temporary permissions - $p = new permissions; - $p->add('dashboard_widget_group_delete', 'temp'); + //revoke temporary permissions + $p->delete('dashboard_widget_group_delete', 'temp'); - //execute delete - $this->database->delete($array); - unset($array); - - //revoke temporary permissions - $p->delete('dashboard_widget_group_delete', 'temp'); - - //set message - message::add($text['message-delete']); - } - } - } + //set message + message::add($text['message-delete']); + } + } } } diff --git a/core/domain_settings/resources/classes/domain_settings.php b/core/domain_settings/resources/classes/domain_settings.php index 57e5debec7..f0d50c514d 100644 --- a/core/domain_settings/resources/classes/domain_settings.php +++ b/core/domain_settings/resources/classes/domain_settings.php @@ -59,6 +59,7 @@ /** * declare private variables */ + private $domain_uuid; private $permission_prefix; private $list_page; private $table; @@ -211,7 +212,7 @@ $token = new token; if (!$token->validate('/core/domain_settings/domain_settings.php')) { message::add($text['message-invalid_token'],'negative'); - header('Location: '.$this->location); + header('Location: '.$this->list_page); exit; } diff --git a/core/groups/resources/classes/permission.php b/core/groups/resources/classes/permission.php index 1786bc068d..362cf587d1 100644 --- a/core/groups/resources/classes/permission.php +++ b/core/groups/resources/classes/permission.php @@ -38,6 +38,7 @@ */ private $database; + private $database_group_permissions; /** * called when the object is created diff --git a/resources/check_auth.php b/resources/check_auth.php index dac2f89674..d008f2444b 100644 --- a/resources/check_auth.php +++ b/resources/check_auth.php @@ -120,7 +120,7 @@ } //validate the username and password - $auth = new authentication; + $auth = new authentication(['settings' => $settings]); $result = $auth->validate(); //if not authorized diff --git a/resources/classes/database.php b/resources/classes/database.php index f1fd26c12b..01e5287de7 100644 --- a/resources/classes/database.php +++ b/resources/classes/database.php @@ -739,11 +739,11 @@ class database { *

Note:
* Table name must be sanitized. Otherwise, a warning will be * emitted and false will be returned.

- * @param type $table_name Sanitized name of the table to search for. + * @param string $table_name Sanitized name of the table to search for. * @return boolean Returns true if the table exists and false if it does not. * @depends connect() */ - public function table_exists ($table_name) { + public function table_exists (string $table_name) { if (self::sanitize($table_name) != $table_name) { trigger_error('Table Name must be sanitized', E_USER_WARNING); return false; @@ -793,12 +793,12 @@ class database { *

Note:
* Tables and Column names must be sanitized. Otherwise, a warning will be * emitted and false will be returned.

- * @param type $table_name Sanitized name of the table to search for. - * @param type $column_name Sanitized name of the column to search for. + * @param string $table_name Sanitized name of the table to search for. + * @param string $column_name Sanitized name of the column to search for. * @return boolean Returns true if the column exists and false if it does not. * @depends connect() */ - public function column_exists ($table_name, $column_name) { + public function column_exists (string $table_name, string $column_name) { //sanitize the table name if (self::sanitize($table_name) != $table_name) { trigger_error('Table Name must be sanitized', E_USER_WARNING); @@ -955,7 +955,7 @@ class database { if (is_array($this->where)) { foreach($this->where as $row) { //sanitize the name - $array['name'] = self::sanitize($array['name']); + $row['name'] = self::sanitize($row['name']); //validate the operator switch ($row['operator']) { @@ -1997,7 +1997,7 @@ class database { foreach ($field_value as $sub_row) { //build the delete array - if ($action == 'delete' && $sub_row['checked'] == 'true') { + if ($sub_row['checked'] == 'true') { //delete the child data $delete_array[$child_name][$y][$child_key_name] = $sub_row[$child_key_name]; diff --git a/resources/classes/domains.php b/resources/classes/domains.php index dd15431e41..dcf3655efc 100644 --- a/resources/classes/domains.php +++ b/resources/classes/domains.php @@ -411,7 +411,7 @@ class domains { if (is_array($uuids) && @sizeof($uuids) != 0) { $sql = "select * from v_".$this->table." "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; - $rows = $this->database->select($sql, $parameters, 'all'); + $rows = $this->database->select($sql, null, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { $x = 0; foreach ($rows as $row) { diff --git a/resources/classes/email.php b/resources/classes/email.php index bb41a7b04c..008d257d9d 100644 --- a/resources/classes/email.php +++ b/resources/classes/email.php @@ -57,6 +57,10 @@ public $read_confirmation; public $error; public $response; + public $headers; + public $content_type; + public $reply_to; + public $date; /** * Set in the constructor. Must be a database object and cannot be null. @@ -554,19 +558,19 @@ $this->recipients = explode(';', $this->recipients); // convert to array of addresses } - foreach ($this->recipients as $this->recipient) { - if (is_array($this->recipient)) { // check if each recipient has multiple fields - if ($this->recipient["address"] != '' && valid_email($this->recipient["address"])) { // check if valid address - switch ($this->recipient["delivery"]) { - case "cc" : $mail->AddCC($this->recipient["address"], ($this->recipient["name"]) ? $this->recipient["name"] : $this->recipient["address"]); break; - case "bcc" : $mail->AddBCC($this->recipient["address"], ($this->recipient["name"]) ? $this->recipient["name"] : $this->recipient["address"]); break; - default : $mail->AddAddress($this->recipient["address"], ($this->recipient["name"]) ? $this->recipient["name"] : $this->recipient["address"]); + foreach ($this->recipients as $recipient) { + if (is_array($recipient)) { // check if each recipient has multiple fields + if ($recipient["address"] != '' && valid_email($recipient["address"])) { // check if valid address + switch ($recipient["delivery"]) { + case "cc" : $mail->AddCC($recipient["address"], ($recipient["name"]) ? $recipient["name"] : $recipient["address"]); break; + case "bcc" : $mail->AddBCC($recipient["address"], ($recipient["name"]) ? $recipient["name"] : $recipient["address"]); break; + default : $mail->AddAddress($recipient["address"], ($recipient["name"]) ? $recipient["name"] : $recipient["address"]); } $address_found = true; } } - else if ($this->recipient != '' && valid_email($this->recipient)) { // check if recipient value is simply (only) an address - $mail->AddAddress($this->recipient); + else if ($recipient != '' && valid_email($recipient)) { // check if recipient value is simply (only) an address + $mail->AddAddress($recipient); $address_found = true; } } diff --git a/resources/classes/file.php b/resources/classes/file.php index a0e3c18153..02344545be 100644 --- a/resources/classes/file.php +++ b/resources/classes/file.php @@ -52,8 +52,9 @@ class file { * Glob search for a list of files * @var string $dir this is the directory to scan * @var boolean $recursive get the sub directories + * @return array list of files or an empty array if not found */ - public function glob($dir, $recursive) { + public function glob($dir, $recursive): array { $files = []; if ($dir != '' || $dir != '/') { $tree = glob(rtrim($dir, '/') . '/*'); @@ -69,12 +70,6 @@ class file { } } } - else { - $files[] = $file; - } - } - else { - $files[] = $file; } return $files; } diff --git a/resources/classes/menu.php b/resources/classes/menu.php index a7857c0757..7a0783a93a 100644 --- a/resources/classes/menu.php +++ b/resources/classes/menu.php @@ -785,16 +785,16 @@ $menu_tags = ''; switch ($menu_item_category) { case "internal": - $menu_tags = "href='".PROJECT_PATH.$submenu_item_link."'"; + $menu_tags = "href='".PROJECT_PATH.$menu_item_link."'"; break; case "external": - if (substr($submenu_item_link, 0,1) == "/") { - $submenu_item_link = PROJECT_PATH.$submenu_item_link; + if (substr($menu_item_link, 0,1) == "/") { + $menu_item_link = PROJECT_PATH.$menu_item_link; } - $menu_tags = "href='".$submenu_item_link."' target='_blank'"; + $menu_tags = "href='".$menu_item_link."' target='_blank'"; break; case "email": - $menu_tags = "href='mailto:".$submenu_item_link."'"; + $menu_tags = "href='mailto:".$menu_item_link."'"; break; } @@ -805,11 +805,11 @@ $menu_html .= "

".$menu_item_title."

\n"; } else { - if ($submenu_item_link == "/login.php" || $submenu_item_link == "/users/signup.php") { + if ($menu_item_link == "/login.php" || $menu_item_link == "/users/signup.php") { //hide login and sign-up when the user is logged in } else { - if (empty($submenu_item_link)) { + if (empty($menu_item_link)) { $menu_html .= "

".$menu_item_title."

\n"; } else { diff --git a/resources/classes/schema.php b/resources/classes/schema.php index 03b8e08eed..5b21a45b1d 100644 --- a/resources/classes/schema.php +++ b/resources/classes/schema.php @@ -36,13 +36,13 @@ public $data_types; //class constructor - public function __construct() { + public function __construct($setting_array) { //includes files require dirname(__DIR__, 2) . "/resources/require.php"; - //connect to the database - $this->database = database::new(); + //open a database connection + $this->database = $setting_array['database'] ?? database::new(); //get the list of installed apps from the core and mod directories $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php"); @@ -122,7 +122,7 @@ $this->database->beginTransaction(); //execute the sql query try { - $this->database->query($sql); + $this->database->execute($sql, null); } catch (PDOException $error) { echo "error: " . $error->getMessage() . " sql: $sql
"; } @@ -138,7 +138,7 @@ return true; } } - return $false; + return false; } //check if a column exists @@ -208,7 +208,7 @@ //database table exists alternate private function db_table_exists_alternate($db_type, $table_name) { $sql = "select count(*) from $table_name "; - $result = $this->database->query($sql); + $result = $this->database->execute($sql, null); if ($result > 0) { return true; //table exists } else { @@ -282,7 +282,7 @@ return true; } } - return $false; + return false; } //database column exists @@ -839,7 +839,7 @@ foreach ($update_array as $sql) { if (strlen(trim($sql))) { try { - $this->database->db->query(trim($sql)); + $this->database->execute(trim($sql), null); if ($format == "text") { $response .= " $sql;\n"; } diff --git a/resources/classes/sounds.php b/resources/classes/sounds.php index 20bd6c073c..fc654a03a8 100644 --- a/resources/classes/sounds.php +++ b/resources/classes/sounds.php @@ -94,7 +94,7 @@ class sounds { if (is_array($sound_files) && @sizeof($sound_files) != 0) { foreach ($sound_files as $value) { if (substr($value, 0, 71) == "\$\${sounds_dir}/\${default_language}/\${default_dialect}/\${default_voice}/") { - $value = substr($var, 71); + $value = substr($value, 71); } $array['sounds'][$x]['name'] = $value; $array['sounds'][$x]['value'] = $value; diff --git a/resources/classes/text.php b/resources/classes/text.php index 957a6179ec..394681c18f 100644 --- a/resources/classes/text.php +++ b/resources/classes/text.php @@ -295,7 +295,7 @@ class text { } } } - if(empty($append) && array_key_exists($comment, $lang_label) && array_key_exists($comment[$lang_label], $lang_code)) { + if(empty($append) && array_key_exists($comment[$lang_label], $lang_code)) { $append = " //$comment[$lang_label][$lang_code]"; } fwrite($lang_file, "\$text['$lang_label']['$target_lang'$spacer] = \"".$this->escape_str($value)."\";$append\n"); diff --git a/resources/classes/tones.php b/resources/classes/tones.php index 99aa032e69..26c1ebea80 100644 --- a/resources/classes/tones.php +++ b/resources/classes/tones.php @@ -35,7 +35,7 @@ private $default_tone_label; private $database; - /** + /** * called when the object is created */ public function __construct(array $setting_array = []) { @@ -47,6 +47,11 @@ $this->database = $setting_array['database'] ?? database::new(); } + /** + * tones_list function + * + * @return array + */ public function tones_list() { //get the tones $sql = "select * from v_vars "; @@ -68,6 +73,6 @@ unset($sql, $tones, $tone); //return the tones - return $tone_list ?? ''; + return $tone_list ?? []; } } diff --git a/resources/classes/xml.php b/resources/classes/xml.php index ac7d883297..7a1942c023 100644 --- a/resources/classes/xml.php +++ b/resources/classes/xml.php @@ -1,9 +1,14 @@