From 91dafb19ec171e747d9976cf738606759bde3aae Mon Sep 17 00:00:00 2001 From: msquare Date: Thu, 29 Sep 2016 10:53:17 +0200 Subject: prohibit inline control structures on pages --- includes/pages/admin_active.php | 59 ++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 24 deletions(-) (limited to 'includes/pages/admin_active.php') diff --git a/includes/pages/admin_active.php b/includes/pages/admin_active.php index ab962a93..b672fddb 100644 --- a/includes/pages/admin_active.php +++ b/includes/pages/admin_active.php @@ -14,8 +14,9 @@ function admin_active() { $limit = ""; $set_active = ""; - if (isset($_REQUEST['search'])) + if (isset($_REQUEST['search'])) { $search = strip_request_item('search'); + } $show_all_shifts = isset($_REQUEST['show_all_shifts']); @@ -33,8 +34,9 @@ function admin_active() { $msg .= error(_("Please enter a number of angels to be marked as active."), true); } - if ($ok) + if ($ok) { $limit = " LIMIT " . $count; + } if (isset($_REQUEST['ack'])) { sql_query("UPDATE `User` SET `Aktiv` = 0 WHERE `Tshirt` = 0"); $users = sql_select(" @@ -67,8 +69,9 @@ function admin_active() { sql_query("UPDATE `User` SET `Aktiv`=1 WHERE `UID`='" . sql_escape($id) . "' LIMIT 1"); engelsystem_log("User " . User_Nick_render($user_source) . " is active now."); $msg = success(_("Angel has been marked as active."), true); - } else + } else { $msg = error(_("Angel not found."), true); + } } elseif (isset($_REQUEST['not_active']) && preg_match("/^[0-9]+$/", $_REQUEST['not_active'])) { $id = $_REQUEST['not_active']; $user_source = User($id); @@ -76,8 +79,9 @@ function admin_active() { sql_query("UPDATE `User` SET `Aktiv`=0 WHERE `UID`='" . sql_escape($id) . "' LIMIT 1"); engelsystem_log("User " . User_Nick_render($user_source) . " is NOT active now."); $msg = success(_("Angel has been marked as not active."), true); - } else + } else { $msg = error(_("Angel not found."), true); + } } elseif (isset($_REQUEST['tshirt']) && preg_match("/^[0-9]+$/", $_REQUEST['tshirt'])) { $id = $_REQUEST['tshirt']; $user_source = User($id); @@ -85,8 +89,9 @@ function admin_active() { sql_query("UPDATE `User` SET `Tshirt`=1 WHERE `UID`='" . sql_escape($id) . "' LIMIT 1"); engelsystem_log("User " . User_Nick_render($user_source) . " has tshirt now."); $msg = success(_("Angel has got a t-shirt."), true); - } else + } else { $msg = error("Angel not found.", true); + } } elseif (isset($_REQUEST['not_tshirt']) && preg_match("/^[0-9]+$/", $_REQUEST['not_tshirt'])) { $id = $_REQUEST['not_tshirt']; $user_source = User($id); @@ -94,8 +99,9 @@ function admin_active() { sql_query("UPDATE `User` SET `Tshirt`=0 WHERE `UID`='" . sql_escape($id) . "' LIMIT 1"); engelsystem_log("User " . User_Nick_render($user_source) . " has NO tshirt."); $msg = success(_("Angel has got no t-shirt."), true); - } else + } else { $msg = error(_("Angel not found."), true); + } } $users = sql_select(" @@ -107,21 +113,24 @@ function admin_active() { GROUP BY `User`.`UID` ORDER BY `force_active` DESC, `shift_length` DESC" . $limit); - $matched_users = array(); - if ($search == "") - $tokens = array(); - else + $matched_users = []; + if ($search == "") { + $tokens = []; + } else { $tokens = explode(" ", $search); + } foreach ($users as &$usr) { if (count($tokens) > 0) { $match = false; - foreach ($tokens as $t) + foreach ($tokens as $t) { if (stristr($usr['Nick'], trim($t))) { $match = true; break; } - if (! $match) + } + if (! $match) { continue; + } } $usr['nick'] = User_Nick_render($usr); $usr['shirt_size'] = $tshirt_sizes[$usr['Size']]; @@ -131,14 +140,16 @@ function admin_active() { $usr['tshirt'] = glyph_bool($usr['Tshirt'] == 1); $actions = array(); - if ($usr['Aktiv'] == 0) + if ($usr['Aktiv'] == 0) { $actions[] = '' . _("set active") . ''; + } if ($usr['Aktiv'] == 1 && $usr['Tshirt'] == 0) { $actions[] = '' . _("remove active") . ''; $actions[] = '' . _("got t-shirt") . ''; } - if ($usr['Tshirt'] == 1) + if ($usr['Tshirt'] == 1) { $actions[] = '' . _("remove t-shirt") . ''; + } $usr['actions'] = join(' ', $actions); @@ -161,18 +172,18 @@ function admin_active() { 'given' => '' . sql_select_single_cell("SELECT count(*) FROM `User` WHERE `Tshirt`=1") . '' ]; - return page_with_title(admin_active_title(), array( - form(array( + return page_with_title(admin_active_title(), [ + form([ form_text('search', _("Search angel:"), $search), form_checkbox('show_all_shifts', _("Show all shifts"), $show_all_shifts), form_submit('submit', _("Search")) - ), page_link_to('admin_active')), - $set_active == "" ? form(array( + ], page_link_to('admin_active')), + $set_active == "" ? form([ form_text('count', _("How much angels should be active?"), $count), form_submit('set_active', _("Preview")) - )) : $set_active, + ]) : $set_active, msg(), - table(array( + table([ 'nick' => _("Nickname"), 'shirt_size' => _("Size"), 'shift_count' => _("Shifts"), @@ -181,13 +192,13 @@ function admin_active() { 'force_active' => _("Forced"), 'tshirt' => _("T-shirt?"), 'actions' => "" - ), $matched_users), + ], $matched_users), '

' . _("Shirt statistics") . '

', - table(array( + table([ 'size' => _("Size"), 'needed' => _("Needed shirts"), 'given' => _("Given shirts") - ), $shirt_statistics) - )); + ], $shirt_statistics) + ]); } ?> -- cgit v1.2.3-70-g09d2