From d54528f8ea80134002ffd186e83333d8df631944 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sat, 11 Mar 2023 22:28:10 +0000 Subject: [PATCH] Gave posts a 1 minute cooldown for edits without being marked as edited. --- public/forum/posting.php | 7 ++++++- src/Forum/post.php | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/public/forum/posting.php b/public/forum/posting.php index b69071d..2f9ee47 100644 --- a/public/forum/posting.php +++ b/public/forum/posting.php @@ -219,7 +219,12 @@ if(!empty($_POST)) { break; case 'edit': - if(!forum_post_update($postId, $_SERVER['REMOTE_ADDR'], $postText, $postParser, $postSignature, $postText !== $post['post_text'])) { + + $markUpdated = $post['poster_id'] === $currentUserId + && $post['post_created_unix'] < strtotime('-1 minutes') + && $postText !== $post['post_text']; + + if(!forum_post_update($postId, $_SERVER['REMOTE_ADDR'], $postText, $postParser, $postSignature, $markUpdated)) { $notices[] = 'Post edit failed.'; } diff --git a/src/Forum/post.php b/src/Forum/post.php index 8fc3675..fdf10cc 100644 --- a/src/Forum/post.php +++ b/src/Forum/post.php @@ -87,6 +87,8 @@ function forum_post_find(int $postId, int $userId): array { } function forum_post_get(int $postId, bool $allowDeleted = false): array { + // i have no idea if the post_created field depend on not being parsed, so post_created_unix it is! + // not even the first time i've done this either (see forum_latest_post) lol, what a mess $getPost = \Misuzu\DB::prepare(sprintf( ' SELECT @@ -95,6 +97,7 @@ function forum_post_get(int $postId, bool $allowDeleted = false): array { INET6_NTOA(p.`post_ip`) AS `post_ip`, u.`user_id` AS `poster_id`, u.`username` AS `poster_name`, u.`user_created` AS `poster_joined`, u.`user_country` AS `poster_country`, + UNIX_TIMESTAMP(p.`post_created`) AS `post_created_unix`, COALESCE(u.`user_colour`, r.`role_colour`) AS `poster_colour`, ( SELECT COUNT(`post_id`)