open($zip_path, ZipArchive::CREATE) === TRUE) { foreach ($selected as $item) { $full_path = $current_dir . DIRECTORY_SEPARATOR . $item; if (file_exists($full_path)) { if (is_dir($full_path)) { // Add directory recursively $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($full_path), RecursiveIteratorIterator::LEAVES_ONLY ); foreach ($files as $name => $file) { if (!$file->isDir()) { $filePath = $file->getRealPath(); $relativePath = $item . '/' . substr($filePath, strlen($full_path) + 1); $zip->addFile($filePath, $relativePath); } } } else { $zip->addFile($full_path, $item); } } } $zip->close(); // Download zip header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename="' . $zip_name . '"'); header('Content-Length: ' . filesize($zip_path)); readfile($zip_path); unlink($zip_path); // Delete temp file exit; } } } // --- NAVIGASI --- // Tombol Back $parent_dir = dirname($current_dir); if (strpos(realpath($parent_dir), $real_root) === 0 && $current_dir != $root_dir) { $back_link = "?dir=" . urlencode($parent_dir); } else { $back_link = null; } // Daftar isi direktori $items = scandir($current_dir); $files = []; $folders = []; foreach ($items as $item) { if ($item == '.' || $item == '..') continue; $full_path = $current_dir . DIRECTORY_SEPARATOR . $item; if (is_dir($full_path)) { $folders[] = $item; } else { $files[] = $item; } } sort($folders); sort($files); $all_items = array_merge($folders, $files); // --- VARIABLE UNTUK EDIT --- $edit_content = ''; $edit_file = ''; if (isset($_GET['edit'])) { $edit_file = basename($_GET['edit']); $file_path = $current_dir . DIRECTORY_SEPARATOR . $edit_file; if (file_exists($file_path) && is_file($file_path) && is_readable($file_path)) { $edit_content = file_get_contents($file_path); // Cegah edit file PHP ini sendiri if (basename($file_path) == 'filemanager.php') { $edit_content = "⚠️ Tidak bisa mengedit file manager itu sendiri!"; } } } // --- GET DIRECTORY LIST FOR COPY/MOVE --- function getDirectories($dir, $root) { $result = []; if (is_dir($dir)) { $items = scandir($dir); foreach ($items as $item) { if ($item == '.' || $item == '..') continue; $full = $dir . DIRECTORY_SEPARATOR . $item; if (is_dir($full) && strpos(realpath($full), $root) === 0) { $result[] = $full; $result = array_merge($result, getDirectories($full, $root)); } } } return $result; } $all_dirs = getDirectories($root_dir, $root_dir); ?> 📂 Simple File Manager

📂 Simple File Manager

📁
⬅ Kembali 🔄 Refresh
Nama Ukuran Terakhir Dimodifikasi Aksi
Kosong
PHP

✏️ Edit File:


❌ Tutup
Simple File Manager v2.0 | Root: | Total: item