diff options
author | cflip <36554078+cflip@users.noreply.github.com> | 2021-06-23 15:21:12 -0600 |
---|---|---|
committer | cflip <36554078+cflip@users.noreply.github.com> | 2021-06-23 15:21:12 -0600 |
commit | f5e972c030675f46cda543e13da1b787457e070b (patch) | |
tree | 7c0d2bb4138fe60060ff73b61e15881765ba5412 /viewthread.php | |
parent | fd0c3a283153d6f2d759e5e14888e40e65dc61b7 (diff) |
Add the rest of the changes
Diffstat (limited to 'viewthread.php')
-rwxr-xr-x[-rw-r--r--] | viewthread.php | 156 |
1 files changed, 73 insertions, 83 deletions
diff --git a/viewthread.php b/viewthread.php index 365e014..85f1813 100644..100755 --- a/viewthread.php +++ b/viewthread.php @@ -1,83 +1,73 @@ -<?php -include_once './includes/model/User.php'; -include_once './includes/model/Thread.php'; -include_once './includes/model/Post.php'; - -session_start(); - -if (!isset($_GET['id']) || !filter_var($_GET['id'], FILTER_VALIDATE_INT)) { - http_response_code(404); - include('includes/templates/404.php'); - die(); -} - -$current = new Thread($_GET['id']); -if (!$current->has_value()) { - http_response_code(404); - include('includes/templates/404.php'); - die(); -} -?> -<!DOCTYPE html> -<html lang="en"> - <head> - <title><?= $current->subject; ?> - cflip.net forum</title> - <link rel="stylesheet" href="styles/style.css"> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - </head> - <body> -<?php include_once 'includes/templates/header.php'; ?> - <div id="banner"></div> - <h1><?= $current->subject; ?></h1> - created by <b><?= $current->author->name; ?></b> - in <b><?= $current->category->name; ?></b>, <?= date('M d, Y g:ia', strtotime($current->date_created)); ?> -<?php if (Session::get()->is_signed_in() and Session::get()->get_current_user()->level == USER_LEVEL_MODERATOR): ?> - <form action="moderate.php" method="post"> - <p> - <b>Moderator Options</b> - <input type="hidden" name="id" value="<?= $current->id ?>"> - <input type="checkbox" id="delete" name="delete"> - <label for="delete">Delete thread</label> - <input type="checkbox" id="lock" name="lock"> - <label for="lock">Locked</label> - <input type="checkbox" id="pin" name="pin"> - <label for="pin">Pinned</label> - <input type="submit" value="Update thread"> - </p> - </form> -<?php endif ?> - <hr> -<?php -foreach ($current->get_posts() as $post) { - echo $post->get_content(); -} -?> - <hr> - <h2>Reply to this thread</h2> -<?php -include_once 'includes/error.php'; - -if ($_SERVER['REQUEST_METHOD'] == 'POST') { - if (!Session::get()->is_signed_in()) { - trigger_error('You must be <a href="signin.php">signed in</a> to reply to this thread.', E_USER_NOTICE); - return; - } - - $post_content = filter_input(INPUT_POST, 'post_content', FILTER_SANITIZE_STRING); - - if (empty($post_content) or !$post_content) { - trigger_error('Reply cannot be empty'); - } else { - Post::create($post_content, $current->id, $current->category->id); - header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $current->id); - } -} -?> - <form method="post"> - <textarea name="post_content" rows="10" cols="50"></textarea> - <br> - <input type="submit" name="submit"> - </form> - </body> -</html> +<?php
+include_once './includes/model/User.php';
+include_once './includes/model/Thread.php';
+include_once './includes/model/Post.php';
+
+session_start();
+
+if (!isset($_GET['id']) || !filter_var($_GET['id'], FILTER_VALIDATE_INT)) {
+ http_response_code(404);
+ include('includes/templates/404.php');
+ die();
+}
+
+$current = new Thread($_GET['id']);
+if (!$current->has_value()) {
+ http_response_code(404);
+ include('includes/templates/404.php');
+ die();
+}
+?>
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <title><?= $current->subject; ?> - cflip.net forum</title>
+<?php include_once 'includes/templates/head.php'; ?>
+ <meta property="og:site_name" content="cflip.net forum">
+ <meta property="og:title" content="<?= $current->subject; ?>">
+ <meta property="og:url" content="https://forum.cflip.net/viewthread.php?id=<?= $current->id; ?>">
+ <meta property="og:type" content="article">
+ <meta property="article:section" content="<?= $current->category->name; ?>">
+ </head>
+ <body>
+<?php include_once 'includes/templates/header.php'; ?>
+ <h1><?= $current->subject; ?></h1>
+ created by <b><?= $current->author->name; ?></b>
+ in <b><?= $current->category->name; ?></b>, <?= date('M d, Y g:ia', strtotime($current->date_created)); ?>
+<?php if (Session::get()->is_signed_in() and Session::get()->get_current_user()->level == USER_LEVEL_MODERATOR): ?>
+ <a href="moderate.php?type=thread&id=<?= $current->id; ?>">Moderator Options</a>
+<?php endif ?>
+ <hr>
+<?php
+foreach ($current->get_posts() as $post) {
+ echo $post->get_content();
+}
+?>
+ <hr>
+ <h2>Reply to this thread</h2>
+<?php
+include_once 'includes/error.php';
+
+if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+ if (!Session::get()->is_signed_in()) {
+ trigger_error('You must be <a href="signin.php">signed in</a> to reply to this thread.', E_USER_NOTICE);
+ return;
+ }
+
+ $post_content = filter_input(INPUT_POST, 'post_content', FILTER_SANITIZE_STRING);
+
+ if (empty($post_content) or !$post_content) {
+ trigger_error('Reply cannot be empty');
+ } else {
+ Post::create($post_content, $current->id, $current->category->id);
+ header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $current->id);
+ }
+}
+?>
+ <form method="post">
+ <textarea name="post_content" rows="10" cols="50"></textarea>
+ <br>
+ <input type="submit" name="submit">
+ </form>
+ </body>
+</html>
|