git.shiar.nl
/
minimedit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
issue: secure against external form submissions
[minimedit.git]
/
widget
/
reply.php
diff --git
a/widget/reply.php
b/widget/reply.php
index edffaa75ceb3b6bc9de79f34d79af2b4d94bff72..0a0e4e55848f275380f7a3d97ef910382e0545e7 100644
(file)
--- a/
widget/reply.php
+++ b/
widget/reply.php
@@
-4,6
+4,7
@@
require_once 'database.inc.php';
$journalcol = [
'assign' => 'Toegewezen aan',
$journalcol = [
'assign' => 'Toegewezen aan',
+ 'subject' => 'Onderwerp',
];
if ($_POST) {
];
if ($_POST) {
@@
-17,11
+18,18
@@
if ($_POST) {
}
$target .= '/' . $User->login;
if ($result = userupload($_FILES['image'], $target)) {
}
$target .= '/' . $User->login;
if ($result = userupload($_FILES['image'], $target)) {
- $html .= sprintf('<p><img src="/thumb/640x/%s" /></p>', $result);
+ if (preg_match('(^image/)', $_FILES['image']['type'])) {
+ $html .= sprintf('<p><img src="/thumb/640x/%s" /></p>', $result);
+ }
+ else {
+ $html .= sprintf('<p>Bijgevoegd bestand: <a href="/%s" />%s</a></p>',
+ $result, basename($result)
+ );
+ }
}
}
$query = $Db->set('comments', [
}
}
$query = $Db->set('comments', [
- 'page' => $Page,
+ 'page' => $Page
->link
,
'message' => $html,
'author' => $User->login,
]);
'message' => $html,
'author' => $User->login,
]);
@@
-60,21
+68,27
@@
if ($_POST) {
$Issue = $updated;
}
}
$Issue = $updated;
}
}
+
+ $target = "/{$Page->link}/$newcomment#$newcomment";
+ abort($target, ($Page->api ? 200 : 303) . ' reply success');
$_POST['reply'] = NULL;
}
catch (Exception $e) {
$_POST['reply'] = NULL;
}
catch (Exception $e) {
+ if ($Page->api) {
+ abort(ucfirst($e->getMessage()), '500 reply error');
+ }
print "<p class=warn>Antwoord niet opgeslagen: {$e->getMessage()}.</p>\n\n";
}
}
$cols = '*, (SELECT json_agg(journal.*) FROM journal WHERE comment_id = comments.id) AS journal';
print "<p class=warn>Antwoord niet opgeslagen: {$e->getMessage()}.</p>\n\n";
}
}
$cols = '*, (SELECT json_agg(journal.*) FROM journal WHERE comment_id = comments.id) AS journal';
-$query = $Db->query("SELECT $cols FROM comments WHERE page = ? ORDER BY created", [$Page]);
+$query = $Db->query("SELECT $cols FROM comments WHERE page = ? ORDER BY created", [$Page
->link
]);
print '<ul class="replies">';
while ($row = $query->fetch()) {
$rowuser = new User("profile/{$row->author}");
print '<ul class="replies">';
while ($row = $query->fetch()) {
$rowuser = new User("profile/{$row->author}");
- print
'<li>'
;
+ print
f('<li id="%d">', $row->id)
;
printf('<strong>%s</strong> <small class=date>%s</small>',
$rowuser->html, showdate(preg_split('/\D/', $row->created))
);
printf('<strong>%s</strong> <small class=date>%s</small>',
$rowuser->html, showdate(preg_split('/\D/', $row->created))
);
@@
-90,7
+104,7
@@
while ($row = $query->fetch()) {
printf("<em>%s</em> %s",
$journalcol[$change->col], sprintf(
!isset($change->old_value) ? 'gewijzigd naar <q>%2$s</q>' :
printf("<em>%s</em> %s",
$journalcol[$change->col], sprintf(
!isset($change->old_value) ? 'gewijzigd naar <q>%2$s</q>' :
- (!isset($change->value) ? 'verwijderd (<s
trike>%s</strike
>)' :
+ (!isset($change->value) ? 'verwijderd (<s
>%s</s
>)' :
'gewijzigd van <q>%s</q> naar <q>%s</q>'),
$change->old_value, $change->value
)
'gewijzigd van <q>%s</q> naar <q>%s</q>'),
$change->old_value, $change->value
)
@@
-106,7
+120,7
@@
while ($row = $query->fetch()) {
if ($User->login) {
print '<li>';
print '<form method="post" action="" enctype="multipart/form-data">';
if ($User->login) {
print '<li>';
print '<form method="post" action="" enctype="multipart/form-data">';
- if (isset($Issue) and $User->admin("edit
$Page
")) {
+ if (isset($Issue) and $User->admin("edit
{$Page->link}
")) {
print '<p>';
printf(
'<label for="%s">%s:</label> '
print '<p>';
printf(
'<label for="%s">%s:</label> '
@@
-139,7
+153,9
@@
if ($User->login) {
''
);
print '<input type="submit" value="Plaatsen" />'."\n";
''
);
print '<input type="submit" value="Plaatsen" />'."\n";
- print "</form></li>\n";
+ print "</form>";
+ print '<script src="/upload/progress.js"></script>';
+ print "</li>\n";
}
print "</ul>\n\n";
}
print "</ul>\n\n";