From 6c9369ad85f2fb3dc61234b54db7e7079cdc0c4e Mon Sep 17 00:00:00 2001
From: cflip <36554078+cflip@users.noreply.github.com>
Date: Fri, 23 Apr 2021 18:43:12 -0600
Subject: Refactoring part 1
---
viewthread.php | 60 +++++++++++++++++++++++++++-------------------------------
1 file changed, 28 insertions(+), 32 deletions(-)
(limited to 'viewthread.php')
diff --git a/viewthread.php b/viewthread.php
index d41fb9b..ae08090 100644
--- a/viewthread.php
+++ b/viewthread.php
@@ -1,6 +1,6 @@
get_from_database($_GET['id'], $dbc);
if ($result == 0) {
http_response_code(404);
- include_once 'templates/404.php';
+ include('includes/templates/404.php');
die();
}
}
?>
-
+
- = $current->subject; ?> - cflip.net forum
-
+ = $current->subject; ?> - cflip.net forum
+
-
- = $current->subject; ?>
- created by = $current->author->name; ?>
- in = $current->category->name; ?>
- 3 days ago
+
+= $current->subject; ?>
+created by = $current->author->name; ?>
+in = $current->category->name; ?>
+3 days ago
-
- get_posts($dbc);
+
+get_posts($dbc);
- foreach ($posts as $post) {
- $post->display_content($dbc);
- }
- ?>
-
- Reply to this thread
-
+foreach ($posts as $post) {
+ $post->display_content($dbc);
+}
+?>
+
+Reply to this thread
+
signed in to reply to this thread.';
return;
- }
+ }
$post_content = filter_input(INPUT_POST, 'post_content', FILTER_SANITIZE_STRING);
$user_id = filter_var($_SESSION['user_id'], FILTER_SANITIZE_NUMBER_INT);
@@ -93,5 +90,4 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
insert_post($dbc, $post_content, $current->id, $user_id, $current->category->id);
}
}
-
?>
--
cgit v1.2.3
From 7c3f2e348c015ea93563d866f89ec8cea9159ea0 Mon Sep 17 00:00:00 2001
From: cflip <36554078+cflip@users.noreply.github.com>
Date: Sat, 24 Apr 2021 09:40:20 -0600
Subject: Refactoring part 2
Starting to move some functionality such as the session and database connection into singleton classes to manage them. Functions for modifying posts and threads are being put in one place as well.
---
viewthread.php | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
(limited to 'viewthread.php')
diff --git a/viewthread.php b/viewthread.php
index ae08090..cc2d221 100644
--- a/viewthread.php
+++ b/viewthread.php
@@ -34,11 +34,10 @@ in = $current->category->name; ?>
get_by_id($_SESSION['user_id'], $dbc);
+if (Session::get()->is_signed_in()) {
+ $user = Session::get()->get_current_user();
- if ($user->level > 0) {
+ if ($user->level == USER_LEVEL_MODERATOR) {
echo '