New forbidroot plugin to forbid rootdir listing
authorMarc MAURICE <marc-bizou@pub.positon.org>
Mon, 11 Nov 2013 11:15:55 +0000 (12:15 +0100)
committerMarc MAURICE <marc-bizou@pub.positon.org>
Mon, 11 Nov 2013 11:15:55 +0000 (12:15 +0100)
index.php
plugins/forbidroot/before_tpl.php [new file with mode: 0644]

index 708a9e3..e77be4e 100644 (file)
--- a/index.php
+++ b/index.php
@@ -77,6 +77,8 @@ if (dirname($simplePath) !== '')
 else
        $parentLink = "";
 
+plugins_include("before_tpl.php");
+
 ///// template starts here /////
 header('Content-Type: text/html; charset=utf-8');
 header('Cache-Control: max-age=3600');
diff --git a/plugins/forbidroot/before_tpl.php b/plugins/forbidroot/before_tpl.php
new file mode 100644 (file)
index 0000000..b9b5361
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+if ($GLOBALS['simplePath'] === "") {
+        header("HTTP/1.1 403 Forbidden");
+        die("Forbdidden directory");
+}
+
+if (dirname($GLOBALS['simplePath']) === "/") {
+       $GLOBALS['parentLink'] = "";
+}