From 2805ef7311eeb028cd48bffe04a705676c4682be Mon Sep 17 00:00:00 2001 From: cflip <36554078+cflip@users.noreply.github.com> Date: Sun, 21 Mar 2021 10:54:47 -0600 Subject: big changes pt1 --- thread.php | 97 +++++++++++++++++++++++--------------------------------------- 1 file changed, 36 insertions(+), 61 deletions(-) (limited to 'thread.php') diff --git a/thread.php b/thread.php index 97ab6b9..9c43217 100644 --- a/thread.php +++ b/thread.php @@ -1,68 +1,43 @@ - - Unknown category.'; -} else { - $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 '

' . $row['thread_subject'] . '

'; - echo 'Created by ' . $row['user_name'] . ' on ' . date('M d, Y', strtotime($row['thread_date'])) . '
'; - $thread_id = $row['thread_id']; - } - } - - echo ''; +include_once 'model/Thread.php'; - mysqli_free_result($result); +session_start(); - $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); +$current = new Thread(); - if (!$result) { - die('Error trying to display posts: ' . mysqli_error($dbc)); - } - - if (mysqli_num_rows($result) == 0) { - echo '
This thread has no posts
'; - } else { - display_posts($dbc, $result); - } - - mysqli_free_result($result); - - if (isset($_SESSION['signed_in'])) { - echo ' -
-
-

Reply to this thread

- Quote a post with ># and the number above the post (example: >#7) - -
- -
-
- '; - } else { - echo ' -
- Sign in to reply to this thread -
- '; - } +if (!isset($_GET['id']) || !filter_var($_GET['id'], FILTER_VALIDATE_INT)) { +} else { + $current->get_from_database($_GET['id'], $dbc); } - -include_once 'footer.php'; ?> + + + + <?php echo $current->subject; ?> - cflip.net forum + + + +

subject; ?>

+ created by user->name'; ?> + in category->name; ?> + 3 days ago +
+ This thread has no posts'; + } else { + display_posts($dbc, $_GET['id'], $result); + } + ?> + + \ No newline at end of file -- cgit v1.2.3