mirror of
https://github.com/DeNNiiInc/UltyScan.git
synced 2026-04-17 18:26:00 +00:00
Enhance debug info for delete action
This commit is contained in:
@@ -97,13 +97,37 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
|
|
||||||
if ($action === 'delete') {
|
if ($action === 'delete') {
|
||||||
if (is_dir($wsPath)) {
|
if (is_dir($wsPath)) {
|
||||||
|
// Debug info
|
||||||
|
$currentUser = trim(shell_exec('whoami'));
|
||||||
|
|
||||||
// Delete directory recursively using sudo
|
// Delete directory recursively using sudo
|
||||||
exec("sudo rm -rf " . escapeshellarg($wsPath));
|
$cmd = "sudo rm -rf " . escapeshellarg($wsPath) . " 2>&1";
|
||||||
|
exec($cmd, $output, $returnVar);
|
||||||
|
|
||||||
if (!file_exists($wsPath)) {
|
if (!file_exists($wsPath)) {
|
||||||
echo json_encode(['success' => true, 'message' => 'Workspace deleted']);
|
echo json_encode([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Workspace deleted',
|
||||||
|
'debug' => [
|
||||||
|
'user' => $currentUser,
|
||||||
|
'cmd' => $cmd,
|
||||||
|
'output' => implode("\n", $output),
|
||||||
|
'return' => $returnVar
|
||||||
|
]
|
||||||
|
]);
|
||||||
} else {
|
} else {
|
||||||
echo json_encode(['success' => false, 'error' => 'Failed to delete workspace. Check permissions.']);
|
echo json_encode([
|
||||||
|
'success' => false,
|
||||||
|
'error' => 'Failed to delete workspace.',
|
||||||
|
'debug' => [
|
||||||
|
'user' => $currentUser,
|
||||||
|
'cmd' => $cmd,
|
||||||
|
'output' => implode("\n", $output),
|
||||||
|
'return' => $returnVar,
|
||||||
|
'permissions' => substr(sprintf('%o', fileperms($wsPath)), -4),
|
||||||
|
'owner' => posix_getpwuid(fileowner($wsPath))['name']
|
||||||
|
]
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo json_encode(['success' => false, 'error' => 'Workspace not found']);
|
echo json_encode(['success' => false, 'error' => 'Workspace not found']);
|
||||||
|
|||||||
Reference in New Issue
Block a user