36516-vm/delete_template.php
Flatlogic Bot e87822db43 v.1
2025-12-01 02:19:38 +00:00

30 lines
814 B
PHP

<?php
require_once 'admin/config.php';
require_login();
$template_name = isset($_GET['template']) ? basename($_GET['template']) : '';
if (empty($template_name)) {
header('Location: admin.php');
exit;
}
$template_path = 'templates/' . $template_name;
if (file_exists($template_path)) {
if (unlink($template_path)) {
// Optionally, you might want to delete the associated image as well.
// This part is left commented out as it requires more logic to find the correct image.
/*
$image_name = pathinfo($template_name, PATHINFO_FILENAME) . '.jpg'; // or png, etc.
$image_path = 'assets/images/templates/' . $image_name;
if (file_exists($image_path)) {
unlink($image_path);
}
*/
}
}
header('Location: admin.php');
exit;
?>