diff options
Diffstat (limited to 'thread.php')
-rw-r--r-- | thread.php | 97 |
1 files changed, 36 insertions, 61 deletions
@@ -1,68 +1,43 @@ -<?php include_once 'header.php'; ?> - <?php include_once 'includes/db_inc.php'; -include_once 'includes/functions_display.php'; - -if (!isset($_GET['id']) || !filter_var($_GET['id'], FILTER_VALIDATE_INT)) { - echo '<section>Unknown category.</section>'; -} 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 '<section><h1>' . $row['thread_subject'] . '</h1>'; - echo 'Created by <a href="user.php?id='. $row['user_id'] .'">' . $row['user_name'] . '</a> on ' . date('M d, Y', strtotime($row['thread_date'])) . '</section>'; - $thread_id = $row['thread_id']; - } - } - - echo '</section>'; +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 '<section>This thread has no posts</section>'; - } else { - display_posts($dbc, $result); - } - - mysqli_free_result($result); - - if (isset($_SESSION['signed_in'])) { - echo ' - <section> - <form action="includes/reply_inc.php?reply_to=' . $thread_id .'" method="post"> - <h2>Reply to this thread</h2> - <i>Quote a post with ># and the number above the post (example: >#7)</i> - <textarea name="reply_content"></textarea> - <br> - <input type="submit" name="submit"> - </form> - </section> - '; - } else { - echo ' - <section> - <a href="signin.php">Sign in</a> to reply to this thread</a> - </section> - '; - } +if (!isset($_GET['id']) || !filter_var($_GET['id'], FILTER_VALIDATE_INT)) { +} else { + $current->get_from_database($_GET['id'], $dbc); } - -include_once 'footer.php'; ?> +<!DOCTYPE html> +<html> +<head> + <title><?php echo $current->subject; ?> - cflip.net forum</title> +</head> +<body> + <?php include_once 'templates/header.php';?> + <h1><?php echo $current->subject; ?></h1> + created by <b><?php echo '$current->user->name'; ?></b> + in <b><?php echo $current->category->name; ?></b> + <abbr title="<?php echo date('M d, Y g:ia', strtotime($current->date_created));?>">3 days ago</abbr> + <hr> + <?php + include_once 'includes/functions_display.php'; + + $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) { + die('Error trying to display posts: ' . mysqli_error($dbc)); + } + + if (mysqli_num_rows($result) == 0) { + echo '<section>This thread has no posts</section>'; + } else { + display_posts($dbc, $_GET['id'], $result); + } + ?> +</body> +</html>
\ No newline at end of file |