git.shiar.nl
/
minimedit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
edit: right-align ckeditor toolbar
[minimedit.git]
/
edit.php
diff --git
a/edit.php
b/edit.php
old mode 100755
(executable)
new mode 100644
(file)
index
3774bfc
..
2a63bd2
--- a/
edit.php
+++ b/
edit.php
@@
-1,12
+1,13
@@
<?php
<?php
+ob_clean();
+
function abort($status, $body) {
header("HTTP/1.1 $status");
print "$body\n";
exit;
}
function abort($status, $body) {
header("HTTP/1.1 $status");
print "$body\n";
exit;
}
-require 'auth.inc.php';
-if (!$Admin)
+if (!@$User['admin'])
abort('401 unauthorised', "geen beheersrechten");
if (!$_POST)
abort('401 unauthorised', "geen beheersrechten");
if (!$_POST)
@@
-14,10
+15,10
@@
if (!$_POST)
if (!isset($_SERVER['PATH_INFO']) or strlen($_SERVER['PATH_INFO']) <= 1)
abort('409 input error', "geen bestand aangeleverd");
if (!isset($_SERVER['PATH_INFO']) or strlen($_SERVER['PATH_INFO']) <= 1)
abort('409 input error', "geen bestand aangeleverd");
-$filename =
preg_replace('/(?:\.php)?$/', '.php', ltrim($_SERVER['PATH_INFO'], '/'), 1)
;
-if (
file_exists($filename) and !is_writable(
$filename))
+$filename =
ltrim($Args, '/').'.html'
;
+if (
!preg_match('{^(?:[/a-z0-9-])+\.html$}',
$filename))
abort('403 input error', "ongeldige bestandsnaam: $filename");
abort('403 input error', "ongeldige bestandsnaam: $filename");
-if (
is_execu
table($filename))
+if (
file_exists($filename) and !is_wri
table($filename))
abort('403 input error', "onwijzigbaar bestand: $filename");
if (!isset($_POST['body']))
abort('403 input error', "onwijzigbaar bestand: $filename");
if (!isset($_POST['body']))
@@
-33,11
+34,7
@@
if (!strlen($upload)) {
exit;
}
exit;
}
-$rootpath = str_repeat('../', substr_count($filename, '/'));
-$prepend = "<?php include '${rootpath}head.inc.php'; ?>\n\n";
-$append = "\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";
abort('500 save error', "fout bij schrijven van $filename");
print "Bestand opgeslagen";