📁 Share

индекс папки
'; echo ' '; echo ' '; echo ' '; echo ' '; echo ''; $items = scandir($path); $files = []; $dirs = []; foreach ($items as $item) { if ($item === '.' || $item === '..') continue; if (in_array($item, $exclude)) continue; $fullPath = $path . DIRECTORY_SEPARATOR . $item; if (is_dir($fullPath)) { $dirs[] = $item; } else { $files[] = $item; } } sort($dirs, SORT_STRING | SORT_FLAG_CASE); sort($files, SORT_STRING | SORT_FLAG_CASE); $allItems = array_merge($dirs, $files); if (empty($allItems)) { echo ''; } else { foreach ($allItems as $item) { $fullPath = $path . DIRECTORY_SEPARATOR . $item; $isDir = is_dir($fullPath); $size = $isDir ? '—' : formatSize(filesize($fullPath)); $mtime = date('Y-m-d H:i', filemtime($fullPath)); $safeName = htmlspecialchars($item); $fullUrl = $baseUrl . '/' . rawurlencode($item); echo ''; echo ' '; echo ' '; echo ' '; echo ' '; echo ''; } } function formatSize($bytes) { if ($bytes === 0) return '0 Б'; $units = ['Б', 'КБ', 'МБ', 'ГБ', 'ТБ']; $i = floor(log($bytes, 1024)); $size = round($bytes / pow(1024, $i), 1); return $size . ' ' . $units[$i]; } ?>
Имя Последнее изменение Размер Ссылка
Parent Directory
Папка пуста
'; if ($isDir) { echo '' . $safeName . '/'; } else { echo '' . $safeName . ''; } echo ' ' . $mtime . '' . $size . ''; if (!$isDir) { echo ''; } else { echo '—'; } echo '