]> git.lizzy.rs Git - dirlistozxa.git/blobdiff - dirlistozxa.php
gen-thumbs: generate video thumbnails
[dirlistozxa.git] / dirlistozxa.php
index f23c6aebd9f6fd493ec52b070731703d3b0e5313..eff24698b0be349ea63e4100b30d2c1b3bde3588 100644 (file)
 
 // 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
 ];
 
 // ================
@@ -35,6 +31,9 @@ $ignore_file_list = [
 // 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;
 
@@ -61,8 +60,12 @@ function row($name, $date, $size, $thumb) {
        };
 
        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) {
@@ -73,7 +76,7 @@ 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;