diff --git a/app/devices/device_profiles.php b/app/devices/device_profiles.php index 1c03650caa..ec5225f760 100644 --- a/app/devices/device_profiles.php +++ b/app/devices/device_profiles.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Copyright (C) 2019 All Rights Reserved. + Copyright (C) 2019-2023 All Rights Reserved. Contributor(s): Mark J Crane @@ -46,18 +46,18 @@ $text = $language->get(); //get posted data - if (is_array($_POST['profiles'])) { + if (!empty($_POST['profiles']) && is_array($_POST['profiles'])) { $action = $_POST['action']; $search = $_POST['search']; $profiles = $_POST['profiles']; } //get the search - $search = strtolower($_REQUEST["search"]); - $fields = strtolower($_REQUEST["fields"]); + $search = strtolower($_REQUEST["search"] ?? ''); + $fields = strtolower($_REQUEST["fields"] ?? ''); //process the http post data by action - if ($action != '' && is_array($profiles) && @sizeof($profiles) != 0) { + if (!empty($action) && !empty($profiles) && is_array($profiles) && @sizeof($profiles) != 0) { switch ($action) { case 'copy': if (permission_exists('device_profile_add')) { @@ -84,8 +84,8 @@ } //get variables used to control the order - $order_by = $_GET["order_by"]; - $order = $_GET["order"]; + $order_by = $_GET["order_by"] ?? null; + $order = $_GET["order"] ?? null; //add the search term if (!empty($search)) { @@ -114,25 +114,25 @@ //get the count $sql = "select count(*) from v_device_profiles "; $sql .= "where true "; - if ($_GET['show'] != "all" || !permission_exists('device_profile_all')) { + if (empty($_GET['show']) || $_GET['show'] != "all" || !permission_exists('device_profile_all')) { $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; $parameters['domain_uuid'] = $domain_uuid; } - $sql .= $sql_search; + $sql .= $sql_search ?? ''; $database = new database; - $num_rows = $database->select($sql, $parameters, 'column'); + $num_rows = $database->select($sql, $parameters ?? null, 'column'); //prepare to page the results $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; + $param = ''; if ($search) { - $param = "&search=".$search; + $param .= "&search=".$search; $param .= "&fields=".$fields; } - if ($_GET['show'] == "all" && permission_exists('device_profile_all')) { + if (!empty($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_profile_all')) { $param .= "&show=all"; } - $page = $_GET['page']; - if (empty($page)) { $page = 0; $_GET['page'] = 0; } + $page = $_GET['page'] ?? 0; list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); //bottom list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); //top $offset = $rows_per_page * $page; @@ -142,7 +142,7 @@ $sql .= order_by($order_by, $order, 'device_profile_name', 'asc'); $sql .= limit_offset($rows_per_page, $offset); $database = new database; - $device_profiles = $database->select($sql, $parameters, 'all'); + $device_profiles = $database->select($sql, $parameters ?? null, 'all'); unset($sql, $parameters); //create token @@ -162,17 +162,17 @@ echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','link'=>'device_profile_edit.php']); } if (permission_exists('device_profile_add') && $device_profiles) { - 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');"]); + echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]); } if (permission_exists('device_profile_edit') && $device_profiles) { - echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'name'=>'btn_toggle','onclick'=>"modal_open('modal-toggle','btn_toggle');"]); + echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display: none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]); } if (permission_exists('device_profile_delete') && $device_profiles) { - echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','onclick'=>"modal_open('modal-delete','btn_delete');"]); + echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none;','onclick'=>"modal_open('modal-delete','btn_delete');"]); } echo "