2 function abort($status, $body) {
3 header("HTTP/1.1 $status");
9 abort('405 post error', "niets te doen");
10 if (!isset($_POST['page']))
11 abort('409 input error', "geen bestand aangeleverd");
13 $filename = preg_replace('/(?:\.html)?$/', '.html', ltrim($_POST['page'], '/'), 1);
14 if (file_exists($filename) and !is_writable($filename))
15 abort('403 input error', "ongeldige bestandsnaam: $filename");
17 $prepend = '<!--#include virtual="/common.html" -->'."\n\n";
18 $append = "\n".'<!--#include virtual="/footer.html" -->'."\n";
19 $upload = $_POST['body'];
22 abort('409 input error', "leeg bestand aangeleverd");
24 if (!file_put_contents($filename, $prepend . $upload . $append))
25 abort('500 save error', "fout bij schrijven van $filename");
27 print "Bestand opgeslagen";