From 4c372277dba0427e47fd9c31f94000c17ff5600f Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 24 Feb 2024 11:56:28 +0100 Subject: [PATCH] Fixes SQL query error on sort by last_update --- www/scripts/tploverview.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/www/scripts/tploverview.php b/www/scripts/tploverview.php index b9152b9..02fb111 100644 --- a/www/scripts/tploverview.php +++ b/www/scripts/tploverview.php @@ -2,30 +2,28 @@ global $db, $smarty; $sort_by = filter_input(INPUT_GET, 'sort', FILTER_DEFAULT, FILTER_REQUIRE_SCALAR) ?? null; +$order_by = filter_input(INPUT_GET, 'order', FILTER_DEFAULT, FILTER_REQUIRE_SCALAR) ?? 'DESC'; switch ($sort_by) { case 'tpl': - $sort = 'ORDER BY id'; + $sort = 'id'; break; case 'titel': - $sort = 'ORDER BY title'; + $sort = 'title'; break; case 'word': - $sort = 'ORDER BY word'; + $sort = 'word'; break; case 'owner': - $sort = 'ORDER BY owner'; - break; - case 'update': + $sort = 'owner'; break; + case 'update'; default: - $sort = 'ORDER BY last_update'; break; + $sort = 'last_update'; } -$order = $_GET['order'] === 'ASC' ? 'ASC' : 'DESC'; -$sort_order = $sort.' '.$order; - +$sort_order = sprintf('ORDER BY %s %s', $sort, $order_by); $e = $db->query('SELECT id, title, word, owner, LENGTH(tpl) size, UNIX_TIMESTAMP(last_update) updated, update_user, read_rights, write_rights FROM templates WHERE del="0" '.$sort_order, __FILE__, __LINE__, 'SELECT All Templates'); $list = []; $totalsize = 0;