edit: encode page url in path
[minimedit.git] / edit.php
index 398581e1e7c6ffbf3578e6b0296f63aa1b844af8..719c2f029976b523d953de8337331b24ac2cd8f8 100644 (file)
--- a/edit.php
+++ b/edit.php
@@ -7,15 +7,15 @@ function abort($status, $body) {
 
 if (!$_POST)
        abort('405 post error', "niets te doen");
-if (!isset($_POST['page']))
+if (!isset($_SERVER['PATH_INFO']) or strlen($_SERVER['PATH_INFO']) <= 1)
        abort('409 input error', "geen bestand aangeleverd");
 
-$filename = preg_replace('/(?:\.html)?$/', '.html', ltrim($_POST['page'], '/'), 1);
+$filename = preg_replace('/(?:\.html)?$/', '.html', ltrim($_SERVER['PATH_INFO'], '/'), 1);
 if (file_exists($filename) and !is_writable($filename))
        abort('403 input error', "ongeldige bestandsnaam: $filename");
 
-$prepend = '<!--#include virtual="common.html" -->'."\n\n";
-$append  = "\n".'<!--#include virtual="footer.html" -->'."\n";
+$prepend = '<!--#include virtual="/common.html" -->'."\n\n";
+$append  = "\n".'<!--#include virtual="/footer.html" -->'."\n";
 $upload = $_POST['body'];
 
 if (!$upload)