page: route requests through global php handler
[minimedit.git] / edit.php
index 3774bfc51407bf441ed055b8ffcbd7342a129887..fe80528a7d1c83faca00ef8e751cf5e271baae72 100755 (executable)
--- a/edit.php
+++ b/edit.php
@@ -14,7 +14,7 @@ if (!$_POST)
 if (!isset($_SERVER['PATH_INFO']) or strlen($_SERVER['PATH_INFO']) <= 1)
        abort('409 input error', "geen bestand aangeleverd");
 
-$filename = preg_replace('/(?:\.php)?$/', '.php', ltrim($_SERVER['PATH_INFO'], '/'), 1);
+$filename = ltrim($Args, '/').'.html';
 if (file_exists($filename) and !is_writable($filename))
        abort('403 input error', "ongeldige bestandsnaam: $filename");
 if (is_executable($filename))
@@ -33,11 +33,7 @@ if (!strlen($upload)) {
        exit;
 }
 
-$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))
+if (!file_put_contents($filename, $upload))
        abort('500 save error', "fout bij schrijven van $filename");
 
 print "Bestand opgeslagen";