login/pass: error messages below page title
[minimedit.git] / edit / index.php
index 2367b2377e72834d52c8851cd54f4728fdcbed12..ebf3d5d9fe086257a745dffc048b4236b4147dd1 100644 (file)
@@ -1,78 +1,3 @@
 <?php
-ob_clean();
-
-if (empty($User['admin']))
-       abort("geen beheersrechten", '401 unauthorised');
-
-if ($_FILES) {
-       $img = @$_FILES['upload'];
-       if (!$img or $img['error'] !== UPLOAD_ERR_OK)
-               abort('bestand niet goed ontvangen: '.$img['error'], '409 upload error');
-
-       $datadir = implode('/', ['data', date('Y')]);
-       if (!file_exists($datadir) and !@mkdir($datadir, 0777, TRUE)) {
-               abort("bestand kon niet geplaatst worden in $datadir", '409 upload error');
-       }
-
-       $target = $datadir.'/'.$img['name'];
-       if (!@move_uploaded_file($img['tmp_name'], $target)) {
-               abort('bestand kon niet worden opgeslagen', '409 upload error');
-       }
-
-       switch (@$_GET['output']) {
-       case 'ckescript':
-               printf('<script>window.parent.CKEDITOR.tools.callFunction(%s)</script>',
-                       "{$_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");
-
+if ($Page->api) return;
+abort("aanpasdienst onbekend", '404 unknown');