37 lines
772 B
PHP
37 lines
772 B
PHP
<?php
|
|
include_once "logcheck.php";
|
|
|
|
$file = $_GET["f"] ?? null;
|
|
$kind = $_GET["k"] ?? null;
|
|
|
|
// Err if all parts didnt arrive
|
|
if ( !file || !$kind ) {
|
|
header("Location: admin.php?success=0");
|
|
die();
|
|
}
|
|
|
|
// Err if not a valid prefix
|
|
if ( $kind !== "media" && $kind !== "posts" ) {
|
|
header("Location: admin.php?success=0");
|
|
die();
|
|
}
|
|
|
|
$path = realpath( $kind . "/" . $file );
|
|
|
|
// Err if file does not exist
|
|
if ( !file_exists($path) ) {
|
|
error_log( "File does not exist: " . $path );
|
|
header("Location: admin.php?success=0");
|
|
die();
|
|
}
|
|
|
|
if ( is_writable( $path ) ) {
|
|
$success = unlink( $path ) ? "6" : "0";
|
|
header("Location: admin.php?success=" . $success);
|
|
die();
|
|
} else {
|
|
error_log( "File not writable: " . $path );
|
|
header("Location: admin.php?success=0");
|
|
die();
|
|
}
|