From 140e72641490f38fb28c55ec76694d3cbecf2293 Mon Sep 17 00:00:00 2001 From: fusionate Date: Mon, 29 May 2023 20:05:49 +0000 Subject: [PATCH] User Logs - List: Updates for PHP 8.1 --- core/user_logs/user_logs.php | 44 +++++++++++++++++------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/core/user_logs/user_logs.php b/core/user_logs/user_logs.php index 35b246b035..d9c8d9382e 100644 --- a/core/user_logs/user_logs.php +++ b/core/user_logs/user_logs.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) 2018 - 2022 + Portions created by the Initial Developer are Copyright (C) 2018 - 2023 the Initial Developer. All Rights Reserved. */ @@ -44,14 +44,14 @@ $text = $language->get(); //get the http post data - if (is_array($_POST['user_logs'])) { + if (!empty($_POST['user_logs']) && is_array($_POST['user_logs'])) { $action = $_POST['action']; $search = $_POST['search']; $user_logs = $_POST['user_logs']; } //process the http post data by action - if ($action != '' && is_array($user_logs) && @sizeof($user_logs) != 0) { + if (!empty($action) && !empty($user_logs) && is_array($user_logs) && @sizeof($user_logs) != 0) { //validate the token $token = new token; @@ -62,7 +62,7 @@ } //prepare the array - foreach($user_logs as $row) { + foreach ($user_logs as $row) { $array['user_logs'][$x]['checked'] = $row['checked']; $array['user_logs'][$x]['user_log_uuid'] = $row['user_log_uuid']; $x++; @@ -86,8 +86,8 @@ } //get order and order by - $order_by = $_GET["order_by"]; - $order = $_GET["order"]; + $order_by = $_GET["order_by"] ?? null; + $order = $_GET["order"] ?? null; //add the search if (isset($_GET["search"])) { @@ -98,7 +98,7 @@ //get the count $sql = "select count(user_log_uuid) "; $sql .= "from v_user_logs "; - if (permission_exists('user_log_all') && $_GET['show'] == 'all') { + if (permission_exists('user_log_all') && !empty($_GET['show']) && $_GET['show'] == 'all') { $sql .= "where true "; } else { @@ -116,14 +116,14 @@ $parameters['search'] = '%'.$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 = $search ? "search=".$search : null; - $param .= ($_GET['show'] == 'all' && permission_exists('user_log_all')) ? "&show=all" : null; - $page = is_numeric($_GET['page']) ? $_GET['page'] : 0; + $param = !empty($search) ? "search=".$search : null; + $param .= !empty($_GET['show']) && $_GET['show'] == 'all' && permission_exists('user_log_all') ? "&show=all" : null; + $page = !empty($_GET['page']) && is_numeric($_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; @@ -150,7 +150,7 @@ $sql .= "remote_address, "; $sql .= "user_agent "; $sql .= "from v_user_logs "; - if (permission_exists('user_log_all') && $_GET['show'] == 'all') { + if (permission_exists('user_log_all') && !empty($_GET['show']) && $_GET['show'] == 'all') { $sql .= "where true "; } else { @@ -190,14 +190,14 @@ } echo "