From f83530a122119d7f69812493f9c2f4987ccb2065 Mon Sep 17 00:00:00 2001 From: Cflip <36554078+cflip@users.noreply.github.com> Date: Wed, 10 Feb 2021 20:40:32 -0700 Subject: Reorganize code and add info to front page --- thread.php | 139 +++++++++++++++++++++---------------------------------------- 1 file changed, 48 insertions(+), 91 deletions(-) (limited to 'thread.php') diff --git a/thread.php b/thread.php index 01ffeaa..97ab6b9 100644 --- a/thread.php +++ b/thread.php @@ -2,109 +2,66 @@ '; - } - - $reply = mysqli_fetch_assoc($result); - - if (empty($reply)) { - return '
Invalid quote!'; - } - - $id = $id + 1; +if (!isset($_GET['id']) || !filter_var($_GET['id'], FILTER_VALIDATE_INT)) { + echo '
Quote from ' . $reply['user_name'] . ''; + if (!$result) { + die('Error trying to display thread page: ' . mysqli_error($dbc)); } -} - -$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'; -} else { - while ($row = mysqli_fetch_assoc($result)) { - echo '
' . $reply['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);
-
- $post_content = preg_replace(
- "/\s*[a-zA-Z\/\/:\.]*youtu(be.com\/watch\?v=|.be\/)([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i",
- '' . $post_content . ' |