changeset 28:ce92f4d41714

Add support for displaying hidden files.
author edogawaconan <me@myconan.net>
date Thu, 30 Oct 2014 12:14:32 +0900
parents aa3f0003fb41
children e4f534198385
files README.md index.php
diffstat 2 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/README.md	Thu Oct 30 12:05:35 2014 +0900
+++ b/README.md	Thu Oct 30 12:14:32 2014 +0900
@@ -37,6 +37,14 @@
 
 And done. Probably also works with apache but I have no idea how to set it up.
 
+Configurations
+--------------
+
+Here are some variables which changes how it behaves:
+
+- `DL_DIR`: sets directory to be listed.
+- `DL_SHOWALL`: show or hide files which name start with `.`. Set to `1` to show.
+
 Upgrading
 ---------
 
--- a/index.php	Thu Oct 30 12:05:35 2014 +0900
+++ b/index.php	Thu Oct 30 12:14:32 2014 +0900
@@ -28,7 +28,8 @@
   $files = array();
   $dirs = array();
   while (($file = readdir($dir_handle)) !== false) {
-    if (substr($file, 0, 1) === ".") { continue; }
+    if ($file === "." || $file === "..") { continue; }
+    elseif (!(isset($_SERVER["DL_SHOWALL"]) && $_SERVER["DL_SHOWALL"] === "1") && substr($file, 0, 1) === ".") { continue; }
     elseif (is_dir($dir . $file)) { $dirs[] = $file; }
     else { $files[] = $file; }
   }