'application/pdf', 'zip' => 'application/zip', 'rar' => 'application/x-rar-compressed', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'png' => 'image/png', 'gif' => 'image/gif', 'txt' => 'text/plain', 'php' => 'text/plain', 'html' => 'text/html', 'css' => 'text/css', 'js' => 'application/javascript', 'mp3' => 'audio/mpeg', 'mp4' => 'video/mp4', ); $fileExtension = strtolower(pathinfo($fullPath, PATHINFO_EXTENSION)); $contentType = isset($mimeTypes[$fileExtension]) ? $mimeTypes[$fileExtension] : 'application/octet-stream'; header('Content-Description: File Transfer'); header('Content-Type: ' . $contentType); header('Content-Disposition: attachment; filename="' . basename($fullPath) . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($fullPath)); readfile($fullPath); exit; } $dirHandle = @opendir($fullPath); if ($dirHandle === false) {die("Cannot open dir: " . htmlspecialchars($currentPath));} $files = array(); $directories = array(); while (false !== ($entry = readdir($dirHandle))) { if ($entry == '.' || $entry == '..') {continue;} if (!$showHiddenFiles && substr($entry, 0, 1) === '.') {continue;} $itemPath = $fullPath . DIRECTORY_SEPARATOR . $entry; if (is_dir($itemPath)) { $directories[] = $entry; } else { $files[] = $entry; } } closedir($dirHandle); sort($directories); sort($files); ?> Index of <?php echo htmlspecialchars($currentPath); ?>

Index of

'; echo ''; echo ''; echo ''; echo ''; } foreach ($directories as $dir) { $itemPath = $fullPath . DIRECTORY_SEPARATOR . $dir; $modifiedTime = filemtime($itemPath); echo ''; echo ''; echo ''; echo ''; echo ''; } foreach ($files as $file) { $itemPath = $fullPath . DIRECTORY_SEPARATOR . $file; $fileSize = filesize($itemPath); $modifiedTime = filemtime($itemPath); echo ''; echo ''; echo ''; echo ''; echo ''; } ?>
NameSizeModified
..
' . htmlspecialchars($dir) . '/' . date('Y-m-d H:i:s', $modifiedTime) . '
' . htmlspecialchars($file) . '' . formatBytes($fileSize) . '' . date('Y-m-d H:i:s', $modifiedTime) . '