// List of filenames (and folder names) that should be ignored.
$ignore_file_list = [
- '.htaccess', '.htpasswd', // Apache junk files
- 'Thumbs.db', '.DS_Store', // OS junk files
- 'index.php', 'index.html', // Potential other index files
- '.git', 'vendor', // Dev
- 'dirlistozxa.php', '.dirlistozxa', '.thumbs', 'gen-thumbs' // dirlistozxa
+ 'dirlistozxa.php', 'gen-thumbs' // dirlistozxa
];
// ================
// nginx with default configuration (merge_slashes) doesn't actually need this.
$_SERVER['REQUEST_URI'] = str_replace('../', '', $_SERVER['REQUEST_URI']);
+// Allow spaces and other heretical stuff in folder names.
+$_SERVER['REQUEST_URI'] = urldecode($_SERVER['REQUEST_URI']);
+
$folder = str_replace('?'.$_SERVER['QUERY_STRING'], '', $_SERVER['REQUEST_URI']);
$path = $_SERVER['DOCUMENT_ROOT'].$folder;
};
return sprintf(
- '<tr><td class="tum"><img src="%s" loading="lazy"></td><td><a href="%s">%s</a></td><td>%s</td><td class="r">%s</td></tr>',
- $img, $name, $name, $date, $size);
+ '<tr>
+ <td class="tum"><a href="%s"><img src="%s" loading="lazy"></td>
+ <td><a href="%s">%s</a></td>
+ <td>%s</td><td class="r">%s</td>
+ </tr>',
+ $name, $img, $name, $name, $date, $size);
}
function build_blocks($items) {
$objects = [ 'directories' => [], 'files' => [] ];
foreach ($items as $item) {
- if ($item == '..' || $item == '.' || in_array($item, $ignore_file_list)) continue;
+ if (in_array($item, $ignore_file_list) || str_starts_with($item, '.')) continue;
if (is_dir($path.$item))
$objects['directories'][$item] = $item;