edit: root include from parent directory on subpages
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 11 Jul 2017 16:19:47 +0000 (18:19 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Wed, 12 Jul 2017 02:46:06 +0000 (04:46 +0200)
edit.php

index 94206bb054732b0410370b3b6bfe135f3c3bae77..12859595de865444baf29dd94a8f1eaa1b61ca57 100755 (executable)
--- a/edit.php
+++ b/edit.php
@@ -29,7 +29,8 @@ if (!strlen($upload)) {
        exit;
 }
 
-$prepend = "<?php include 'head.inc.php'; ?>\n\n";
+$rootpath = str_repeat('../', substr_count($filename, '/'));
+$prepend = "<?php include '${rootpath}head.inc.php'; ?>\n\n";
 $append  = "\n";
 
 if (!file_put_contents($filename, $prepend . $upload . $append))