edit: include anchor button to refer news items
[minimedit.git] / edit.php
old mode 100644 (file)
new mode 100755 (executable)
index 398581e..1091da4
--- a/edit.php
+++ b/edit.php
@@ -1,3 +1,4 @@
+#!/usr/bin/php-cgi
 <?php
 function abort($status, $body) {
        header("HTTP/1.1 $status");
@@ -7,15 +8,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)