diff --git a/app/devices/devices.php b/app/devices/devices.php index 84ea960856..9a7bfbfb80 100644 --- a/app/devices/devices.php +++ b/app/devices/devices.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008 - 2020 + Portions created by the Initial Developer are Copyright (C) 2008 - 2023 the Initial Developer. All Rights Reserved. Contributor(s): @@ -47,7 +47,7 @@ $text = $language->get(); //get posted data - if (is_array($_POST['devices'])) { + if (!empty($_POST['devices']) && is_array($_POST['devices'])) { $action = $_POST['action']; $devices = $_POST['devices']; } @@ -57,7 +57,7 @@ $fields = strtolower($_REQUEST["fields"] ?? ''); //process the http post data by action - if ($action != '' && is_array($devices) && @sizeof($devices) != 0) { + if (!empty($action) && !empty($devices) && is_array($devices) && @sizeof($devices) != 0) { switch ($action) { case 'toggle': if (permission_exists('device_edit')) { @@ -78,8 +78,8 @@ } //get order and order by and sanatize the values - $order_by = $_GET["order_by"]; - $order = $_GET["order"]; + $order_by = $_GET["order_by"] ?? ''; + $order = $_GET["order"] ?? ''; //set the time zone if (isset($_SESSION['domain']['time_zone']['name'])) { @@ -165,22 +165,22 @@ $parameters['search'] = '%'.strtolower($search).'%'; } $database = new database; - $num_rows = $database->select($sql, $parameters, 'column'); + $num_rows = $database->select($sql, $parameters ?? null, 'column'); unset($sql, $parameters); //prepare to page the results $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; + $param = ''; if ($search) { $param = "&search=".$search; $param .= "&fields=".$fields; } - if ($_GET['show'] == "all" && permission_exists('device_all')) { + if (!empty($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) { $param .= "&show=all"; } - $page = $_GET['page']; - 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); + $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 @@ -303,16 +303,16 @@ unset($margin_left); } if (permission_exists('device_edit') && $devices) { - echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display: none; '.$margin_left,'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; '.($margin_left ?? null),'onclick'=>"modal_open('modal-toggle','btn_toggle');"]); unset($margin_left); } if (permission_exists('device_delete') && $devices) { - echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; '.$margin_left,'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; '.($margin_left ?? null),'onclick'=>"modal_open('modal-delete','btn_delete');"]); unset($margin_left); } echo "