1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 17:59:55 +02:00
Oinktube/CreatePlugin/delete_zip_file.php

38 lines
1,010 B
PHP

<?php
require_once __DIR__.'/../videos/configuration.php';
header('Content-Type: application/json');
if(!User::isAdmin()){
forbiddenPage('You Must be admin');
}
if(!empty($global['disableAdvancedConfigurations'])){
forbiddenPage('Configuration disabled');
}
$response = ['error' => false, 'msg' => ''];
if (!isset($_POST['fileName'])) {
$response['error'] = true;
$response['msg'] = 'File name not specified.';
echo json_encode($response);
exit;
}
$fileName = basename($_POST['fileName']); // Sanitize file name
$filePath = __DIR__ . '/plugins/' . $fileName;
if (file_exists($filePath) && pathinfo($filePath, PATHINFO_EXTENSION) === 'zip') {
if (unlink($filePath)) {
$response['msg'] = 'File deleted successfully.';
} else {
$response['error'] = true;
$response['msg'] = 'Failed to delete the file.';
}
} else {
$response['error'] = true;
$response['msg'] = 'File does not exist or is not a zip file.';
}
echo json_encode($response);