X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/3f78a38cb23e2bb2609e010f0d3b4dce2d3c1727..d092b634576730fc2ead1dc4c88711da09415f75:/edit.php diff --git a/edit.php b/edit.php index 357d3a4..fe80528 100755 --- a/edit.php +++ b/edit.php @@ -5,12 +5,16 @@ function abort($status, $body) { 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)) @@ -29,10 +33,7 @@ if (!strlen($upload)) { exit; } -$prepend = ''."\n\n"; -$append = "\n".''."\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";