git.shiar.nl
/
minimedit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
59694e2
)
edit: delete page if emptied
author
Mischa POSLAWSKY
<perl@shiar.org>
Mon, 19 Jan 2015 19:45:19 +0000
(20:45 +0100)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Mon, 19 Jan 2015 19:45:19 +0000
(20:45 +0100)
edit.php
patch
|
blob
|
history
diff --git
a/edit.php
b/edit.php
index 1091da44af5a90054f20a24d6c9d3a8f3d222789..28d866b477874a45b6b43aa96ad035ef287f49da 100755
(executable)
--- a/
edit.php
+++ b/
edit.php
@@
-15,12
+15,21
@@
$filename = preg_replace('/(?:\.html)?$/', '.html', ltrim($_SERVER['PATH_INFO'],
if (file_exists($filename) and !is_writable($filename))
abort('403 input error', "ongeldige bestandsnaam: $filename");
if (file_exists($filename) and !is_writable($filename))
abort('403 input error', "ongeldige bestandsnaam: $filename");
-$prepend = '<!--#include virtual="/common.html" -->'."\n\n";
-$append = "\n".'<!--#include virtual="/footer.html" -->'."\n";
+if (!isset($_POST['body']))
+ abort('409 input error', "geen inhoud aangeleverd");
+
$upload = $_POST['body'];
$upload = $_POST['body'];
-if (!$upload)
- abort('409 input error', "leeg bestand aangeleverd");
+if (!strlen($upload)) {
+ if (file_exists($filename) and !unlink($filename))
+ abort('500 delete error', "fout bij het verwijderen van $filename");
+
+ print "Bestand verwijderd";
+ exit;
+}
+
+$prepend = '<!--#include virtual="/common.html" -->'."\n\n";
+$append = "\n".'<!--#include virtual="/footer.html" -->'."\n";
if (!file_put_contents($filename, $prepend . $upload . $append))
abort('500 save error', "fout bij schrijven van $filename");
if (!file_put_contents($filename, $prepend . $upload . $append))
abort('500 save error', "fout bij schrijven van $filename");