diff options
author | cflip <36554078+cflip@users.noreply.github.com> | 2021-06-05 11:18:10 -0600 |
---|---|---|
committer | cflip <36554078+cflip@users.noreply.github.com> | 2021-06-05 11:18:10 -0600 |
commit | 24efe49bc2b545e3a3e46d7d6f2bd1166163e52b (patch) | |
tree | c1852447d06c062052def6fc89be2e2dece17c78 /viewthread.php | |
parent | 45acfc48b3dd80b945a1501edea9ad4faa700c0f (diff) |
Move object related functions into their classes.
Some of the pages are still broken from this commit, but I plan
to either rewrite or ignore them.
Diffstat (limited to 'viewthread.php')
-rw-r--r-- | viewthread.php | 24 |
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); } } |