X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/4653a970f0c574750b1ea2e19b112b13d66e80eb..ab89443fa6d3a9e13476dae2a3a6c23d13ccf9b0:/edit.php diff --git a/edit.php b/edit.php index afa6c6d..3774bfc 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 = preg_replace('/(?:\.php)?$/', '.php', ltrim($_SERVER['PATH_INFO'], '/'), 1); if (file_exists($filename) and !is_writable($filename)) abort('403 input error', "ongeldige bestandsnaam: $filename"); if (is_executable($filename)) @@ -29,7 +33,8 @@ if (!strlen($upload)) { exit; } -$prepend = "\n\n"; +$rootpath = str_repeat('../', substr_count($filename, '/')); +$prepend = "\n\n"; $append = "\n"; if (!file_put_contents($filename, $prepend . $upload . $append))