From edc0e3a052540933d5becb918cf71dc8352ca667 Mon Sep 17 00:00:00 2001 From: Cflip <36554078+cflip@users.noreply.github.com> Date: Wed, 27 Jan 2021 23:43:27 -0700 Subject: Add simple quoting system --- thread.php | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'thread.php') diff --git a/thread.php b/thread.php index ce39d2f..0ba4906 100644 --- a/thread.php +++ b/thread.php @@ -3,12 +3,28 @@ '; + } + + $reply = mysqli_fetch_assoc($result); + + return '
Quote from ' . $reply['user_name'] . ''; + } +} + $sql = "SELECT thread_id, thread_subject, thread_date, user_id, user_name FROM threads LEFT JOIN users ON thread_author = user_id WHERE thread_id = " . mysqli_real_escape_string($dbc, $_GET['id']); $result = mysqli_query($dbc, $sql); if (!$result) { die('Error trying to display thread page: ' . mysqli_error($dbc)); -} +} if (mysqli_num_rows($result) == 0) { echo 'This thread does not exist'; @@ -24,7 +40,7 @@ echo ''; mysqli_free_result($result); -$sql = "SELECT post_content, post_date, post_author, user_id, user_name FROM posts LEFT JOIN users ON post_author = user_id WHERE post_thread = " . mysqli_real_escape_string($dbc, $_GET['id']); +$sql = "SELECT post_id, post_content, post_date, post_author, user_id, user_name FROM posts LEFT JOIN users ON post_author = user_id WHERE post_thread = " . mysqli_real_escape_string($dbc, $_GET['id']); $result = mysqli_query($dbc, $sql); if (!$result) { @@ -35,9 +51,22 @@ if (mysqli_num_rows($result) == 0) { echo '
' . $reply['post_content'] . '
Posted by ' . $row['user_name'] . ' ' . date('m/d/Y g:ia', strtotime($row['post_date'])) . ' | ';
- echo '' . $row['post_content'] . ' |
' . $post_index . ' | |
---|---|
Posted by ' . $row['user_name'] . ' ' . date('m/d/Y g:ia', strtotime($row['post_date'])) . ' | ';
+
+ $post_content = $row['post_content'];
+
+ $post_content = preg_replace_callback('/>#\d+/', function($matches) use($thread_id, $dbc) {
+ return add_quote($dbc, $thread_id, $matches);
+ }, $post_content);
+
+ echo '' . $post_content . ' |