keyload/files.php
Jacob 2d4cb3c5d9 Simplify significantly, by combining admins, temporary keys and keys
into one. Also some miscellanious codebase improvements.
2023-10-04 15:53:02 +02:00

85 lines
2.6 KiB
PHP

<?php
/* curload
* Simple file uploading using POST requests and temporary keys
* Licensed under the GNU Affero General Public License version 3.0
*/
include "config.php";
include "core.php";
$Error = "";
$html = "";
if (isset($_REQUEST['e'])) $Error = $_REQUEST['e'];
$html = printHeader($html);
$html .= "\t\t\t<h1>Your files</h1>\n";
$html .= "\t\t\t\t<p>These are the files you have uploaded using this key.</p>\n";
// If logged in ...
if (isset($_COOKIE[$cookieTypeName]) && (!$publicUploading || $publicUploading == "false")) {
$Database = createTables($sqlDB);
$DatabaseQuery = $Database->query('SELECT * FROM uploads');
$html .= "\t\t\t\t<table class=\"FileView\">\n";
$html .= "\t\t\t\t\t<tr class=\"FileView\">\n";
$html .= "\t\t\t\t\t\t<th class=\"fileID\">ID</th>\n";
$html .= "\t\t\t\t\t\t<th class=\"fileFilename\">Filename</th>\n";
$html .= "\t\t\t\t\t\t<th class=\"fileUploadDate\">Upload date</th>\n";
$html .= "\t\t\t\t\t</tr>\n";
while ($line = $DatabaseQuery->fetchArray()) {
$ID = $line['id'];
$Filename = $line['file'];
$uploadDate = $line['uploaddate'];
$keyID = $line['keyid'];
$keytypeID = $line['keytype'];
$CorrectFile = 0;
if ($line['keytype'] == 1) {
$keyType = "Key";
} else if ($line['keytype'] == 2) {
$keyType = "Administrator";
} else {
$keyType = "Unknown";
}
$UserDatabaseQuery = $Database->query('SELECT * FROM keys');
while ($uline = $UserDatabaseQuery->fetchArray()) {
if ($uline['id'] == $keyID && $_COOKIE[$cookieName] == $uline['key']) {
$CorrectFile = 1;
break;
}
}
// wrong file, move on
if ($CorrectFile != 1) {
continue;
}
$html .= "\t\t\t\t\t<tr class=\"FileView\">\n";
$html .= "\t\t\t\t\t\t<td class=\"fileID\" id=\"fileID-$ID\">$ID</td>\n";
$html .= "\t\t\t\t\t\t<td class=\"fileFilename\"><a href=\"$Filename\">$Filename</a></td>\n";
$html .= "\t\t\t\t\t\t<td class=\"fileUploadDate\">$uploadDate</td>\n";
if (($enableKeyUploadRemoval || $enableKeyUploadRemoval == "true") || $keytypeID == 2) {
$html .= "\t\t\t\t\t\t<td class=\"fileRemove\"><a href=\"/remove.php?redir=files&id=$ID\">Remove</a></td>\n";
}
$html .= "\t\t\t\t\t</tr>\n";
}
$html .= "\t\t\t\t</table>\n";
} else {
header("Location: index.php");
die();
}
// End the content div and print footer
$html = printFooter($html);
// Finally print it all out at once
print "$html";
?>