Add removal of files as well
This commit is contained in:
parent
335c00bf37
commit
832ae4b3e6
|
@ -105,6 +105,7 @@ if ($Action == "files") {
|
||||||
$html .= "\t\t\t\t\t\t<td class=\"adminUploadDate\">$uploadDate</td>\n";
|
$html .= "\t\t\t\t\t\t<td class=\"adminUploadDate\">$uploadDate</td>\n";
|
||||||
$html .= "\t\t\t\t\t\t<td class=\"adminKeyID\">$keyID</td>\n";
|
$html .= "\t\t\t\t\t\t<td class=\"adminKeyID\">$keyID</td>\n";
|
||||||
$html .= "\t\t\t\t\t\t<td class=\"adminKeyType\">$keyType</td>\n";
|
$html .= "\t\t\t\t\t\t<td class=\"adminKeyType\">$keyType</td>\n";
|
||||||
|
$html .= "\t\t\t\t\t\t<td class=\"adminRemove\"><a href=\"/remove.php?redir=admin&id=$ID\">Remove</a></td>\n";
|
||||||
|
|
||||||
$html .= "\t\t\t\t\t</tr>\n";
|
$html .= "\t\t\t\t\t</tr>\n";
|
||||||
}
|
}
|
||||||
|
|
37
remove.php
37
remove.php
|
@ -7,10 +7,11 @@
|
||||||
include "config.php";
|
include "config.php";
|
||||||
include "create-table.php";
|
include "create-table.php";
|
||||||
|
|
||||||
if (isset($_REQUEST['key'])) {
|
if (!isset($_COOKIE[$cookieName]) || !isset($_COOKIE[$cookieTypeName])) {
|
||||||
$Key = $_REQUEST['key'];
|
header('Location: login.php?redir=admin');
|
||||||
} else {
|
die();
|
||||||
print "No key specified.";
|
} else if ($_COOKIE[$cookieTypeName] != 2) { // not allowed
|
||||||
|
header('Location: /');
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,11 +27,32 @@ if (!$enableUploadRemoval || $enableUploadRemoval == "false") {
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$Redirect = "";
|
||||||
$FileToRemove = "";
|
$FileToRemove = "";
|
||||||
$AuthorizedRemoval = 0;
|
$AuthorizedRemoval = 0;
|
||||||
$fileUploadedByPrimary = 0;
|
$fileUploadedByPrimary = 0;
|
||||||
|
|
||||||
|
if (isset($_REQUEST['redir'])) {
|
||||||
|
$Redirect = $_REQUEST['redir'];
|
||||||
|
}
|
||||||
|
|
||||||
$Database = createTables($sqlDB);
|
$Database = createTables($sqlDB);
|
||||||
|
$DatabaseQuery = $Database->query('SELECT * FROM admins');
|
||||||
|
|
||||||
|
while ($line = $DatabaseQuery->fetchArray()) {
|
||||||
|
if ($line['key'] == $_COOKIE[$cookieName] && $_COOKIE[$cookieName] != "" && $line['key'] != "" && ($enableKeys || $enableKeys == "true")) {
|
||||||
|
$AuthorizedRemoval = 1;
|
||||||
|
$AdminIsPrimary = $line['primaryadmin'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// not authorized
|
||||||
|
if ($AuthorizedRemoval != 1) {
|
||||||
|
header('Location: /');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
$DatabaseQuery = $Database->query('SELECT * FROM uploads');
|
$DatabaseQuery = $Database->query('SELECT * FROM uploads');
|
||||||
|
|
||||||
while ($line = $DatabaseQuery->fetchArray()) {
|
while ($line = $DatabaseQuery->fetchArray()) {
|
||||||
|
@ -84,4 +106,11 @@ if ($AuthorizedRemoval != 1) {
|
||||||
|
|
||||||
$Database->exec("DELETE FROM uploads WHERE id='$fileID'");
|
$Database->exec("DELETE FROM uploads WHERE id='$fileID'");
|
||||||
unlink(ltrim($FileToRemove, '/'));
|
unlink(ltrim($FileToRemove, '/'));
|
||||||
|
|
||||||
|
if ($Redirect == "admin") {
|
||||||
|
header("Location: admin.php?action=files");
|
||||||
|
} else {
|
||||||
|
header("Location: /");
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue