From 80dd552e15c6e112777cdeaaa3e2820bd4da6975 Mon Sep 17 00:00:00 2001 From: fusionate Date: Mon, 29 May 2023 19:38:09 +0000 Subject: [PATCH] Registrations: Updates for PHP 8.1 --- app/registrations/registrations.php | 56 +++++++++++++++-------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/app/registrations/registrations.php b/app/registrations/registrations.php index 10d4cf7b19..ab5bc7602a 100644 --- a/app/registrations/registrations.php +++ b/app/registrations/registrations.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-2019 + Portions created by the Initial Developer are Copyright (C) 2008-2023 the Initial Developer. All Rights Reserved. Contributor(s): @@ -47,23 +47,25 @@ $text = $language->get(); //get common submitted data - $show = $_REQUEST['show']; - $search = $_REQUEST['search']; - $profile = $_REQUEST['profile']; + if (!empty($_REQUEST)) { + $show = $_REQUEST['show'] ?? null; + $search = $_REQUEST['search'] ?? null; + $profile = $_REQUEST['profile'] ?? null; + } //define query string array - if ($show) { $qs['show'] = "&show=".urlencode($show); } - if ($search) { $qs['search'] = "&search=".urlencode($search); } - if ($profile) { $qs['profile'] = "&profile=".urlencode($profile); } + $qs['show'] = !empty($show) ? "&show=".urlencode($show) : null; + $qs['search'] = !empty($search) ? "&search=".urlencode($search) : null; + $qs['profile'] = !empty($profile) ? "&profile=".urlencode($profile) : null; //get posted data - if (is_array($_POST['registrations'])) { + if (!empty($_POST) && is_array($_POST['registrations'])) { $action = $_POST['action']; $registrations = $_POST['registrations']; } //process posted data - if ($action != '' && is_array($registrations) && @sizeof($registrations) != 0) { + if (!empty($action) && !empty($registrations) && is_array($registrations) && @sizeof($registrations) != 0) { $obj = new registrations; switch ($action) { @@ -86,8 +88,8 @@ //get the registrations $obj = new registrations; - $obj->show = $show; - $registrations = $obj->get($profile); + $obj->show = $show ?? null; + $registrations = $obj->get($profile ?? null); //order the array require_once "resources/classes/array_order.php"; @@ -98,7 +100,7 @@ $num_rows = 0; if (is_array($registrations)) { foreach ($registrations as $row) { - $matches = preg_grep("/".$search."/i", $row); + $matches = preg_grep("/".($search ?? '')."/i", $row); if ($matches != false) { $num_rows++; } @@ -126,7 +128,7 @@ echo "
".$text['header-registrations']." (".$num_rows.")
\n"; echo "
\n"; if (!$reload) { - echo button::create(['type'=>'button','label'=>$text['button-refresh'],'icon'=>$_SESSION['theme']['button_icon_refresh'],'link'=>$location.($qs ? '?' : null).$qs['show'].$qs['search'].$qs['profile']]); + echo button::create(['type'=>'button','label'=>$text['button-refresh'],'icon'=>$_SESSION['theme']['button_icon_refresh'],'link'=>$location.(!empty($qs) ? '?'.$qs['show'].$qs['search'].$qs['profile'] : null)]); } if ($registrations) { echo button::create(['type'=>'button','label'=>$text['button-unregister'],'title'=>$text['button-unregister'],'icon'=>'user-slash','style'=>'margin-left: 15px;','onclick'=>"modal_open('modal-unregister','btn_unregister');"]); @@ -135,20 +137,20 @@ } echo "