From f0598117ab12e0acb9589023bcd7a194c629dc43 Mon Sep 17 00:00:00 2001 From: Anthony <96078404+AntoniusDC@users.noreply.github.com> Date: Wed, 31 May 2023 11:00:55 -0600 Subject: [PATCH] Fixed Errors for Streams & Ring Groups (#6728) * Fixed Errors streams.php * Update streams.php * Update stream_edit.php * Update ring_groups.php * Update tones.php * Update ringbacks.php * Update ring_group_edit.php --- app/ring_groups/ring_group_edit.php | 47 ++++++++++++++++++----------- app/ring_groups/ring_groups.php | 40 +++++++++++++----------- app/streams/stream_edit.php | 12 ++++++-- app/streams/streams.php | 34 ++++++++++++--------- resources/classes/ringbacks.php | 10 +++--- resources/classes/tones.php | 6 ++-- 6 files changed, 92 insertions(+), 57 deletions(-) diff --git a/app/ring_groups/ring_group_edit.php b/app/ring_groups/ring_group_edit.php index 0f89866d16..c95f766b8a 100644 --- a/app/ring_groups/ring_group_edit.php +++ b/app/ring_groups/ring_group_edit.php @@ -48,6 +48,19 @@ $language = new text; $text = $language->get(); +//set the defaults + $ring_group_strategy = ''; + $ring_group_name = ''; + $ring_group_extension = ''; + $ring_group_caller_id_name = ''; + $ring_group_caller_id_number = ''; + $ring_group_distinctive_ring = ''; + $ring_group_missed_call_app = ''; + $ring_group_missed_call_data = ''; + $ring_group_forward_destination = ''; + $ring_group_forward_toll_allow = ''; + $ring_group_description = ''; + //initialize the destinations object $destination = new destinations; @@ -56,11 +69,11 @@ $sql .= "where domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $domain_uuid; $database = new database; - $total_ring_groups = $database->select($sql, $parameters, 'column'); + $total_ring_groups = $database->select($sql, $parameters ?? null, 'column'); unset($sql, $parameters); //action add or update - if (is_uuid($_REQUEST["id"]) || is_uuid($_REQUEST["ring_group_uuid"])) { + if (!empty($_REQUEST["id"]) || !empty($_REQUEST["ring_group_uuid"])) { $action = "update"; //get the ring_group_uuid @@ -89,7 +102,7 @@ //delete the user from the ring group if ( - $_GET["a"] == "delete" + (!empty($_GET["a"])) == "delete" && is_uuid($_REQUEST["user_uuid"]) && permission_exists("ring_group_edit") ) { @@ -119,7 +132,7 @@ //get total ring group count from the database, check limit, if defined if ($action == 'add') { - if ($_SESSION['limit']['ring_groups']['numeric'] != '') { + if ($_SESSION['limit']['ring_groups']['numeric'] ?? '') { $sql = "select count(*) from v_ring_groups "; $sql .= "where domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $domain_uuid; @@ -207,7 +220,7 @@ } //assign the user to the ring group - if (is_uuid($_REQUEST["user_uuid"]) && is_uuid($_REQUEST["id"]) && $_GET["a"] != "delete" && permission_exists("ring_group_edit")) { + if (!empty($_REQUEST["user_uuid"]) && is_uuid($_REQUEST["id"]) && $_GET["a"] != "delete" && permission_exists("ring_group_edit")) { //set the variables $user_uuid = $_REQUEST["user_uuid"]; //build array @@ -464,7 +477,7 @@ } //pre-populate the form - if (is_uuid($ring_group_uuid)) { + if (!empty($ring_group_uuid)) { $sql = "select * from v_ring_groups "; $sql .= "where ring_group_uuid = :ring_group_uuid "; $parameters['ring_group_uuid'] = $ring_group_uuid; @@ -519,7 +532,7 @@ $x = 0; $limit = 5; } - if (is_uuid($ring_group_uuid)) { + if (!empty($ring_group_uuid)) { $sql = "select * from v_ring_group_destinations "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and ring_group_uuid = :ring_group_uuid "; @@ -532,12 +545,12 @@ } //add an empty row to the options array - if (!is_array($ring_group_destinations) || count($ring_group_destinations) == 0) { + if (!isset($ring_group_destinations) || count($ring_group_destinations) == 0) { $rows = $_SESSION['ring_group']['destination_add_rows']['numeric']; $id = 0; $show_destination_delete = false; } - if (is_array($ring_group_destinations) && count($ring_group_destinations) > 0) { + if (isset($ring_group_destinations) && count($ring_group_destinations) > 0) { $rows = $_SESSION['ring_group']['destination_edit_rows']['numeric']; $id = count($ring_group_destinations)+1; $show_destination_delete = true; @@ -551,7 +564,7 @@ } //get the ring group users - if (is_uuid($ring_group_uuid)) { + if (!empty($ring_group_uuid)) { $sql = "select u.username, r.user_uuid, r.ring_group_uuid "; $sql .= "from v_ring_group_users as r, v_users as u "; $sql .= "where r.user_uuid = u.user_uuid "; @@ -775,7 +788,7 @@ echo " \n"; echo " \n"; - if (!is_uuid($row['ring_group_destination_uuid'])) { // new record + if (!isset($row['ring_group_destination_uuid'])) { // new record if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') { $onkeyup = "onkeyup=\"document.getElementById('ring_group_destinations_".$x."_destination_enabled').checked = (this.value != '' ? true : false);\""; // switch } @@ -827,7 +840,7 @@ // switch if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') { echo " \n"; } @@ -864,7 +877,7 @@ echo " ".$text['label-timeout_destination']."\n"; echo "\n"; echo "\n"; - echo $destination->select('dialplan', 'ring_group_timeout_action', $ring_group_timeout_action); + echo $destination->select('dialplan', 'ring_group_timeout_action', $ring_group_timeout_action ?? ''); echo "
\n"; echo " ".$text['description-timeout_destination']."\n"; echo "\n"; @@ -877,7 +890,7 @@ echo "\n"; echo " \n"; echo "
\n"; - echo $text['description-ring_group_call_timeout']." \n"; + echo (!empty($text['description-ring_group_call_timeout']))." \n"; echo "\n"; echo "\n"; @@ -958,7 +971,7 @@ echo " "; echo " ".$text['label-user_list'].""; echo " "; - if (is_array($ring_group_users) && @sizeof($ring_group_users) != 0) { + if (!empty($ring_group_users)) { echo " \n"; foreach ($ring_group_users as $field) { echo " \n"; @@ -1138,10 +1151,10 @@ echo "
"; echo "

"; - if (is_uuid($dialplan_uuid)) { + if (!empty($dialplan_uuid)) { echo "\n"; } - if (is_uuid($ring_group_uuid)) { + if (!empty($ring_group_uuid)) { echo "\n"; } echo "\n"; diff --git a/app/ring_groups/ring_groups.php b/app/ring_groups/ring_groups.php index 0932924f24..b41db9ef40 100644 --- a/app/ring_groups/ring_groups.php +++ b/app/ring_groups/ring_groups.php @@ -47,15 +47,21 @@ $language = new text; $text = $language->get(); +//set additional variables + $show = $_GET["show"] ?? ''; + +//set the defaults + $search = ''; + //get posted data - if (is_array($_POST['ring_groups'])) { + if (!empty($_POST['ring_groups'])) { $action = $_POST['action']; $search = $_POST['search']; $ring_groups = $_POST['ring_groups']; } //process the http post data by action - if ($action != '' && is_array($ring_groups) && @sizeof($ring_groups) != 0) { + if (!empty($action) && !empty($ring_groups)) { switch ($action) { case 'copy': $obj = new ring_groups; @@ -76,8 +82,8 @@ } //get order and order by - $order_by = $_GET["order_by"]; - $order = $_GET["order"]; + $order_by = $_GET["order_by"] ?? ''; + $order = $_GET["order"] ?? ''; //add the search term if (isset($_GET["search"])) { @@ -93,7 +99,7 @@ $num_rows = $total_ring_groups; //get filtered ring group count - if ($search) { + if (!empty($search)) { $sql = "select count(*) from v_ring_groups where true "; if ($_GET['show'] != "all" || !permission_exists('ring_group_all')) { $sql .= "and domain_uuid = :domain_uuid "; @@ -117,15 +123,15 @@ //prepare to page the results $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $param = $search ? "&search=".$search : null; - $param = ($_GET['show'] == "all" && permission_exists('ring_group_all')) ? "&show=all" : null; - $page = is_numeric($_GET['page']) ? $_GET['page'] : 0; + $param = ($show == "all" && permission_exists('ring_group_all')) ? "&show=all" : null; + $page = isset($_GET['page']) ? $_GET['page'] : 0; list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; //get the list $sql = "select * from v_ring_groups where true "; - if ($_GET['show'] != "all" || !permission_exists('ring_group_all')) { + if ($show != "all" || !permission_exists('ring_group_all')) { $sql .= "and domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $domain_uuid; } @@ -156,10 +162,10 @@ echo "
\n"; echo "
".$text['title-ring_groups']." (".$num_rows.")
\n"; echo "
\n"; - if (permission_exists('ring_group_add') && (!is_numeric($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) { + if (permission_exists('ring_group_add') && (!isset($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) { echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','link'=>'ring_group_edit.php']); } - if (permission_exists('ring_group_add') && $ring_groups && (!is_numeric($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) { + if (permission_exists('ring_group_add') && $ring_groups && (!isset($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) { echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'name'=>'btn_copy','onclick'=>"modal_open('modal-copy','btn_copy');"]); } if (permission_exists('ring_group_edit') && $ring_groups) { @@ -170,7 +176,7 @@ } echo "
\n"; - if (permission_exists('ring_group_add') && $ring_groups && (!is_numeric($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) { + if (permission_exists('ring_group_add') && $ring_groups && (!isset($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) { 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) { @@ -209,10 +215,10 @@ echo "\n"; if (permission_exists('ring_group_add') || permission_exists('ring_group_edit') || permission_exists('ring_group_delete')) { echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; } - if ($_GET['show'] == "all" && permission_exists('ring_group_all')) { + if ($show == "all" && permission_exists('ring_group_all')) { echo th_order_by('domain_name', $text['label-domain'], $order_by, $order); } echo th_order_by('ring_group_name', $text['label-name'], $order_by, $order); @@ -221,7 +227,7 @@ echo th_order_by('ring_group_forward_enabled', $text['label-forwarding'], $order_by, $order); echo th_order_by('ring_group_enabled', $text['label-enabled'], $order_by, $order, null, "class='center'"); echo th_order_by('ring_group_description', $text['header-description'], $order_by, $order, null, "class='hide-sm-dn'"); - if (permission_exists('ring_group_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + if (permission_exists('ring_group_edit') && !empty($_SESSION['theme']['list_row_edit_button']['boolean']) && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { echo "  \n"; } echo "\n"; @@ -239,7 +245,7 @@ echo " \n"; echo " \n"; } - if ($_GET['show'] == "all" && permission_exists('ring_group_all')) { + if ($show == "all" && permission_exists('ring_group_all')) { echo " ".escape($_SESSION['domains'][$row['domain_uuid']]['domain_name'])."\n"; } echo " "; @@ -263,7 +269,7 @@ } echo " \n"; echo " ".escape($row['ring_group_description'])." \n"; - if (permission_exists('ring_group_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + if (permission_exists('ring_group_edit') && !empty($_SESSION['theme']['list_row_edit_button']['boolean']) && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { echo " "; echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]); echo " \n"; diff --git a/app/streams/stream_edit.php b/app/streams/stream_edit.php index f06b1c78fa..c52113036c 100644 --- a/app/streams/stream_edit.php +++ b/app/streams/stream_edit.php @@ -42,8 +42,14 @@ $language = new text; $text = $language->get(); +//set the defaults + $stream_name = ''; + $stream_location = ''; + $stream_description = ''; + $stream_uuid = ''; + //action add or update - if (is_uuid($_REQUEST["id"])) { + if (!empty($_REQUEST["id"])) { $action = "update"; $stream_uuid = $_REQUEST["id"]; $id = $_REQUEST["id"]; @@ -137,7 +143,7 @@ } //pre-populate the form - if (is_array($_GET) && $_POST["persistformvar"] != "true") { + if (!empty($_GET) && $_POST["persistformvar"] != "true") { $stream_uuid = $_GET["id"]; $sql = "select * from v_streams "; $sql .= "where stream_uuid = :stream_uuid "; @@ -252,7 +258,7 @@ } echo " \n"; echo "
\n"; - echo $text['description-domain_uuid']."\n"; + echo !empty($text['description-domain_uuid'])."\n"; echo "\n"; echo "\n"; } diff --git a/app/streams/streams.php b/app/streams/streams.php index 85277d7902..2046c8be93 100644 --- a/app/streams/streams.php +++ b/app/streams/streams.php @@ -43,15 +43,21 @@ $language = new text; $text = $language->get(); +//set additional variables + $show = $_GET["show"] ?? ''; + +//set the defaults + $search = ''; + //get the http post data - if (is_array($_POST['streams'])) { + if (!empty($_POST['streams'])) { $action = $_POST['action']; $search = $_POST['search']; $streams = $_POST['streams']; } //process the http post data by action - if ($action != '' && is_array($streams) && @sizeof($streams) != 0) { + if (!empty($action)) { switch ($action) { case 'copy': if (permission_exists('stream_add')) { @@ -78,8 +84,8 @@ } //get order and order by - $order_by = $_GET["order_by"]; - $order = $_GET["order"]; + $order_by = $_GET["order_by"] ?? ''; + $order = $_GET["order"] ?? ''; //add the search term if (isset($_GET["search"])) { @@ -98,7 +104,7 @@ $sql .= ") "; $parameters['search'] = '%'.$search.'%'; } - if (permission_exists('stream_all') && $_GET['show'] == "all") { + if (permission_exists('stream_all') && $show == "all") { //show all } elseif (permission_exists('stream_all')) { @@ -110,15 +116,15 @@ $parameters['domain_uuid'] = $domain_uuid; } $database = new database; - $num_rows = $database->select($sql, $parameters, 'column'); + $num_rows = $database->select($sql, $parameters ?? null, 'column'); unset($parameters); //prepare to page the results $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $param = "&search=".$search; - $param = ($_GET['show'] == 'all' && permission_exists('stream_all')) ? "&show=all" : null; - $page = is_numeric($_GET['page']) ? $_GET['page'] : 0; - if (empty($page)) { $page = 0; $_GET['page'] = 0; } + $param = ($show == 'all' && permission_exists('stream_all')) ? "&show=all" : null; + $page = isset($_GET['page']) ? $_GET['page'] : 0; + if (!empty($page)) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; @@ -135,7 +141,7 @@ $sql .= ") "; $parameters['search'] = '%'.$search.'%'; } - if (permission_exists('stream_all') && $_GET['show'] == "all") { + if (permission_exists('stream_all') && $show == "all") { //show all } elseif (permission_exists('stream_all')) { @@ -149,7 +155,7 @@ $sql .= order_by($order_by, $order, 'stream_name', 'asc'); $sql .= limit_offset($rows_per_page, $offset); $database = new database; - $streams = $database->select($sql, (is_array($parameters) && @sizeof($parameters) != 0 ? $parameters : null), 'all'); + $streams = $database->select($sql, (!empty($parameters) && @sizeof($parameters) != 0 ? $parameters : null), 'all'); unset($sql, $parameters); //create token @@ -188,7 +194,7 @@ } echo "\n"; if (permission_exists('stream_all')) { - if ($_GET['show'] == 'all') { + if ($show == 'all') { echo " \n"; } else { @@ -230,14 +236,14 @@ echo " \n"; echo " \n"; } - if ($_GET['show'] == 'all' && permission_exists('stream_all')) { + if ($show == 'all' && permission_exists('stream_all')) { echo th_order_by('domain_name', $text['label-domain'], $order_by, $order); } echo th_order_by('stream_name', $text['label-stream_name'], $order_by, $order); echo " ".$text['label-play']."\n"; echo th_order_by('stream_enabled', $text['label-stream_enabled'], $order_by, $order, null, "class='center'"); echo th_order_by('stream_description', $text['label-stream_description'], $order_by, $order, null, "class='hide-sm-dn'"); - if (permission_exists('stream_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + if (permission_exists('stream_edit') && !empty($_SESSION['theme']['list_row_edit_button']['boolean']) && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { echo "  \n"; } echo "\n"; diff --git a/resources/classes/ringbacks.php b/resources/classes/ringbacks.php index 747ea9fb51..a3db2a1d13 100644 --- a/resources/classes/ringbacks.php +++ b/resources/classes/ringbacks.php @@ -30,7 +30,7 @@ if (!class_exists('ringbacks')) { //define variables public $domain_uuid; - private $ringtones_list; + public $ringtones_list; private $tones_list; private $music_list; private $recordings_list; @@ -54,14 +54,16 @@ if (!class_exists('ringbacks')) { if (!empty($ringtones)) { foreach ($ringtones as $ringtone) { $ringtone = $ringtone['var_name']; - $label = $text['label-'.$ringtone]; - if ($label == "") { + if (isset($text['label-'.$ringtone])) { + $label = $text['label-'.$ringtone]; + } + else { $label = $ringtone; } $ringtones_list[$ringtone] = $label; } } - $this->ringtones_list = $ringtones_list ?? ''; + $this->ringtones_list = $ringtones_list; unset($sql, $ringtones, $ringtone, $ringtones_list); //get the default_ringback label diff --git a/resources/classes/tones.php b/resources/classes/tones.php index 42c4263aab..397348e660 100644 --- a/resources/classes/tones.php +++ b/resources/classes/tones.php @@ -49,8 +49,10 @@ if (!class_exists('tones')) { if (!empty($tones)) { foreach ($tones as $tone) { $tone = $tone['var_name']; - $label = $text['label-'.$tone]; - if ($label == "") { + if (isset($text['label-'.$tone])) { + $label = $text['label-'.$tone]; + } + else { $label = $tone; } $tone_list[$tone] = $label;