-#!/usr/bin/php-cgi
<?php
function abort($status, $body) {
header("HTTP/1.1 $status");
exit;
}
+require 'auth.inc.php';
+if (!$Admin)
+ abort('401 unauthorised', "geen beheersrechten");
+
if (!$_POST)
abort('405 post error', "niets te doen");
if (!isset($_SERVER['PATH_INFO']) or strlen($_SERVER['PATH_INFO']) <= 1)
abort('409 input error', "geen bestand aangeleverd");
-$filename = preg_replace('/(?:\.html)?$/', '.html', 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))
+ abort('403 input error', "onwijzigbaar bestand: $filename");
if (!isset($_POST['body']))
abort('409 input error', "geen inhoud aangeleverd");
exit;
}
-$prepend = '<!--#include virtual="/head.inc.html" -->'."\n\n";
-$append = "\n".'<!--#include virtual="/foot.inc.html" -->'."\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";