diff --git a/CHANGELOG.md b/CHANGELOG.md index f33469b4..6ae8abe0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * adds icons from [Evolvere Icon Theme](http://franksouza183.deviantart.com/art/Evolvere-Icon-theme-440718295) * adds PHP variant to calc folder sizes * adds scroll position reset on location change (issue #279) +* adds "hide if 403" option * updates H5BP to 4.3.0 * updates jQuery to 2.1.1 * updates json2.js to 2014-02-04 diff --git a/src/_h5ai/conf/options.json b/src/_h5ai/conf/options.json index d7c2acc8..701dc728 100644 --- a/src/_h5ai/conf/options.json +++ b/src/_h5ai/conf/options.json @@ -41,6 +41,7 @@ Options - ignore: don't list items matching these regular expressions - smartBrowsing: use History API if available (no need to reload the whole page) - extInNewWindow: open non-h5ai links in new window/tab + - hideIf403: hide files and folders that are not readable by the server */ "view": { "modes": ["details", "grid", "icons"], @@ -52,7 +53,8 @@ Options "indexFiles": ["index.html", "index.htm", "index.php"], "ignore": ["^\\.", "^_{{pkg.name}}"], "smartBrowsing": true, - "extInNewWindow": false + "extInNewWindow": false, + "hideIf403": true }, diff --git a/src/_h5ai/server/php/inc/class-app.php b/src/_h5ai/server/php/inc/class-app.php index 989a5ac3..0b208153 100644 --- a/src/_h5ai/server/php/inc/class-app.php +++ b/src/_h5ai/server/php/inc/class-app.php @@ -80,9 +80,14 @@ class App { if (is_dir($path)) { if ($dir = opendir($path)) { while (($name = readdir($dir)) !== false) { - if (!$this->is_ignored($name) && !$this->is_ignored($this->to_url($path) . $name)) { - $names[] = $name; + if ( + $this->is_ignored($name) + || $this->is_ignored($this->to_url($path) . $name) + || (!is_readable($path .'/'. $name) && $this->options["view"]["hideIf403"]) + ) { + continue; } + $names[] = $name; } closedir($dir); }