Prevent deletion of system files
This commit is contained in:
@ -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']);
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user