From 26601743fd5be58415a09b8c369034718be40ab1 Mon Sep 17 00:00:00 2001 From: speedie Date: Sun, 1 Oct 2023 01:44:33 +0200 Subject: [PATCH] Add links to all uploads by key --- admin.php | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/admin.php b/admin.php index 34d47b8..c699537 100644 --- a/admin.php +++ b/admin.php @@ -11,6 +11,7 @@ include "create-table.php"; $Action = ""; $Authorized = 0; $Primary = 0; +$filterID = -1; if (!isset($_COOKIE[$cookieName]) || !isset($_COOKIE[$cookieTypeName])) { header('Location: login.php?redir=admin'); @@ -26,6 +27,12 @@ if (!isset($_REQUEST['action'])) { $Action = $_REQUEST['action']; } +if (!isset($_REQUEST['id'])) { + $filterID = -1; +} else { + $filterID = $_REQUEST['id']; +} + // in case admin keys are disabled if (!$enableAdminKeys || $enableAdminKeys == "false") { header('Location: /'); @@ -88,6 +95,7 @@ if ($Action == "files") { $Filename = $line['file']; $uploadDate = $line['uploaddate']; $keyID = $line['keyid']; + $keytypeID = $line['keytype']; if ($line['keytype'] == 0) { $keyType = "Key"; @@ -103,7 +111,7 @@ if ($Action == "files") { $html .= "\t\t\t\t\t\t$ID\n"; $html .= "\t\t\t\t\t\t$Filename\n"; $html .= "\t\t\t\t\t\t$uploadDate\n"; - $html .= "\t\t\t\t\t\t$keyID\n"; + $html .= "\t\t\t\t\t\t$keyID\n"; $html .= "\t\t\t\t\t\t$keyType\n"; $html .= "\t\t\t\t\t\tRemove\n"; @@ -135,6 +143,11 @@ if ($Action == "files") { break; } + // allow filtering + if ($line['id'] != $filterID && $filterID != -1) { + continue; + } + $ID = $line['id']; $Key = $line['key']; $NumberOfUploads = $line['numberofuploads']; @@ -154,7 +167,7 @@ if ($Action == "files") { $html .= "\t\t\t\t\t\n"; $html .= "\t\t\t\t\t\t$ID\n"; $html .= "\t\t\t\t\t\t$Key\n"; - $html .= "\t\t\t\t\t\t$NumberOfUploads\n"; + $html .= "\t\t\t\t\t\t$NumberOfUploads\n"; $html .= "\t\t\t\t\t\t$UploadsLeft\n"; $html .= "\t\t\t\t\t\t$LastUsed\n"; $html .= "\t\t\t\t\t\t$Issued\n"; @@ -171,6 +184,10 @@ if ($Action == "files") { $DatabaseQuery = $Database->query('SELECT * FROM keys'); while ($line = $DatabaseQuery->fetchArray()) { + if ($line['id'] != $filterID && $filterID != -1) { + continue; + } + $ID = $line['id']; $Key = $line['key']; $NumberOfUploads = $line['numberofuploads']; @@ -186,7 +203,7 @@ if ($Action == "files") { $html .= "\t\t\t\t\t\n"; $html .= "\t\t\t\t\t\t$ID\n"; $html .= "\t\t\t\t\t\t$Key\n"; - $html .= "\t\t\t\t\t\t$NumberOfUploads\n"; + $html .= "\t\t\t\t\t\t$NumberOfUploads\n"; $html .= "\t\t\t\t\t\t$UploadsLeft\n"; $html .= "\t\t\t\t\t\t$LastUsed\n"; $html .= "\t\t\t\t\t\t$Issued\n"; @@ -199,6 +216,10 @@ if ($Action == "files") { $DatabaseQuery = $Database->query('SELECT * FROM tkeys'); while ($line = $DatabaseQuery->fetchArray()) { + if ($line['id'] != $filterID && $filterID != -1) { + continue; + } + $ID = $line['id']; $Key = $line['key']; $NumberOfUploads = $line['numberofuploads']; @@ -214,7 +235,7 @@ if ($Action == "files") { $html .= "\t\t\t\t\t\n"; $html .= "\t\t\t\t\t\t$ID\n"; $html .= "\t\t\t\t\t\t$Key\n"; - $html .= "\t\t\t\t\t\t$NumberOfUploads\n"; + $html .= "\t\t\t\t\t\t$NumberOfUploads\n"; $html .= "\t\t\t\t\t\t$UploadsLeft\n"; $html .= "\t\t\t\t\t\t$LastUsed\n"; $html .= "\t\t\t\t\t\t$Issued\n";