edit: root include from parent directory on subpages
[minimedit.git] / 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))