X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/fe92ec8f17c832c4a663aea399dc90a4c09ce6b1..d6bf8fa992cc01adc311b2ba80f29d7af466c2f3:/edit/index.php diff --git a/edit/index.php b/edit/index.php index 25f9f1b..a6a64a2 100644 --- a/edit/index.php +++ b/edit/index.php @@ -1,72 +1,3 @@ window.parent.CKEDITOR.tools.callFunction(%s)', - "{$_GET['CKEditorFuncNum']}, '$target'" - ); - break; - default: - abort($target); - } - exit; -} - -if (!$_POST) - abort("niets te doen", '405 post error'); -if (!$Args) - abort("geen bestand aangeleverd", '409 input error'); - -$filename = ltrim($Args, '/').'.html'; -if (preg_match('{^\.}', $filename)) - abort("ongeldige bestandsnaam: $filename", '403 input error'); -if (file_exists($filename) and !is_writable($filename)) - abort("onwijzigbaar bestand: $filename", '403 input error'); - -if (!isset($_POST['body'])) - abort("geen inhoud aangeleverd", '409 input error'); - -$upload = $_POST['body']; - -if (!strlen($upload)) { - if (file_exists($filename) and !unlink($filename)) - abort("fout bij het verwijderen van $filename", '500 delete error'); - - abort("Bestand verwijderd"); -} - -if (!file_exists(dirname($filename)) and !mkdir(dirname($filename), 0777, TRUE)) - abort("fout bij aanmaken van map voor $filename", '500 save error'); - -if (!file_put_contents($filename, $upload)) - abort("fout bij schrijven van $filename", '500 save error'); - -if (is_writable('../.git')) { - $gitmsg = preg_replace('/\.html$/', '', $filename).": edit from {$_SERVER['REMOTE_ADDR']}"; - $gitcmd = 'git'; - $gitcmd .= ' -c user.name='.escapeshellarg($User['name']); - $gitcmd .= ' -c user.email='.escapeshellarg("{$User['name']}@lijtweg.nl"); - $gitcmd .= ' commit -q'; - $gitcmd .= ' -m '.escapeshellarg($gitmsg); - $gitcmd .= ' -- '.escapeshellarg($filename); - exec("$gitcmd 2>&1", $gitlog, $gitstatus); - if ($gitstatus) { - trigger_error("git commit failure $gitstatus: ".implode("\n", $gitlog), E_USER_WARNING); - } -} - -abort("Bestand opgeslagen"); - +abort("aanpasdienst onbekend", '404 unknown');