Prevent deletion of system files

This commit is contained in:
2025-06-20 05:59:01 +02:00
parent bf9f1d2ffe
commit caa4142aa7
2 changed files with 10 additions and 0 deletions

View File

@ -5,6 +5,11 @@ require_once __DIR__ . '/../vfs.php';
$data = json_decode(file_get_contents('php://input'), true); $data = json_decode(file_get_contents('php://input'), true);
$pathV = $data['path'] ?? ''; $pathV = $data['path'] ?? '';
if (strpos($pathV, '/.apps') === 0 || $pathV === '/.thos_state.json') {
echo json_encode(['success'=>false, 'error'=>'Cannot delete system files']);
exit;
}
$real = resolve_path($pathV); $real = resolve_path($pathV);
if (!file_exists($real)) { if (!file_exists($real)) {
echo json_encode(['success'=>false,'error'=>'Not found']); echo json_encode(['success'=>false,'error'=>'Not found']);

View File

@ -6,6 +6,11 @@ $data = json_decode(file_get_contents('php://input'), true);
$oldV = $data['old'] ?? ''; $oldV = $data['old'] ?? '';
$newName = $data['new'] ?? ''; $newName = $data['new'] ?? '';
if (strpos($oldV, '/.apps') === 0 || $oldV === '/.thos_state.json') {
echo json_encode(['success'=>false, 'error'=>'Cannot rename system files']);
exit;
}
$oldReal = resolve_path($oldV); $oldReal = resolve_path($oldV);
$newReal = dirname($oldReal) . '/' . basename($newName); $newReal = dirname($oldReal) . '/' . basename($newName);