summaryrefslogtreecommitdiff
path: root/viewthread.php
diff options
context:
space:
mode:
Diffstat (limited to 'viewthread.php')
-rw-r--r--viewthread.php24
1 files changed, 10 insertions, 14 deletions
diff --git a/viewthread.php b/viewthread.php
index fa1c81b..12b9429 100644
--- a/viewthread.php
+++ b/viewthread.php
@@ -3,20 +3,17 @@ include_once 'includes/model/Thread.php';
session_start();
-$current = new Thread();
-
if (!isset($_GET['id']) || !filter_var($_GET['id'], FILTER_VALIDATE_INT)) {
http_response_code(404);
include('includes/templates/404.php');
die();
-} else {
- $result = $current->get_from_database($_GET['id']);
+}
- if (!$result) {
- 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>
@@ -32,7 +29,7 @@ created by <b><?= $current->author->name; ?></b>
in <b><?= $current->category->name; ?></b>
<abbr title="<?= date('M d, Y g:ia', strtotime($current->date_created)); ?>">3 days ago</abbr>
<?php
-include_once('includes/model/User.php');
+include_once './includes/model/User.php';
if (Session::get()->is_signed_in()) {
$user = Session::get()->get_current_user();
@@ -58,18 +55,17 @@ if (Session::get()->is_signed_in()) {
?>
<hr>
<?php
-include './includes/functions_post.php';
+include_once './includes/model/Post.php';
$posts = $current->get_posts();
foreach ($posts as $post) {
- echo get_post_content($post);
+ echo $post->get_content();
}
?>
<hr>
<h2>Reply to this thread</h2>
<?php
-include_once 'includes/functions_post.php';
include_once 'includes/error.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
@@ -83,7 +79,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (empty($post_content) or !$post_content) {
trigger_error('Reply cannot be empty');
} else {
- create_post($post_content, $current->id, $current->category->id);
+ Post::create($post_content, $current->id, $current->category->id);
header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $current->id);
}
}