convert ssi html files to php code
[minimedit.git] / edit.php
index 80a49eb5e6dba49a62dad68d9a8190dc48df34d6..afa6c6d4868c1948ade99c31579726d52ea9a358 100755 (executable)
--- a/edit.php
+++ b/edit.php
@@ -1,4 +1,3 @@
-#!/usr/bin/php-cgi
 <?php
 function abort($status, $body) {
        header("HTTP/1.1 $status");
@@ -14,6 +13,8 @@ if (!isset($_SERVER['PATH_INFO']) or strlen($_SERVER['PATH_INFO']) <= 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");
+if (is_executable($filename))
+       abort('403 input error', "onwijzigbaar bestand: $filename");
 
 if (!isset($_POST['body']))
        abort('409 input error', "geen inhoud aangeleverd");
@@ -28,8 +29,8 @@ if (!strlen($upload)) {
        exit;
 }
 
-$prepend = '<!--#include virtual="/head.inc.html" -->'."\n\n";
-$append  = "\n".'<!--#include virtual="/foot.inc.html" -->'."\n";
+$prepend = "<?php include 'head.inc.php'; ?>\n\n";
+$append  = "\n";
 
 if (!file_put_contents($filename, $prepend . $upload . $append))
        abort('500 save error', "fout bij schrijven van $filename");