diff options
author | cflip <36554078+cflip@users.noreply.github.com> | 2021-04-24 09:40:20 -0600 |
---|---|---|
committer | cflip <36554078+cflip@users.noreply.github.com> | 2021-04-24 09:40:20 -0600 |
commit | 7c3f2e348c015ea93563d866f89ec8cea9159ea0 (patch) | |
tree | b7b6b18cf9087f42300f621d15101628a8d214e4 /moderate.php | |
parent | 6c9369ad85f2fb3dc61234b54db7e7079cdc0c4e (diff) |
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.
Diffstat (limited to 'moderate.php')
-rw-r--r-- | moderate.php | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/moderate.php b/moderate.php index afeefa1..3b8d05d 100644 --- a/moderate.php +++ b/moderate.php @@ -1,25 +1,22 @@ <?php - -include_once 'includes/db_inc.php'; -include_once 'model/User.php'; +include_once './includes/db_inc.php'; +include_once './includes/functions_thread.php'; +include_once './includes/Session.php'; +include_once './includes/model/User.php'; session_start(); -function delete_thread($dbc, $thread_id) { - $sql = "DELETE FROM threads WHERE thread_id = $thread_id;"; - mysqli_query($dbc, $sql); -} - -if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_SESSION['signed_in'])) { +if ($_SERVER['REQUEST_METHOD'] == 'POST') { $thread_id = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT); $delete = filter_input(INPUT_POST, "delete", FILTER_SANITIZE_STRING); - - $user = new User(); - $user->get_by_id($_SESSION['user_id'], $dbc); - if ($user->level > 0) { + $user = Session::get()->get_current_user(); + + if ($user->level == USER_LEVEL_MODERATOR) { if (strcasecmp($delete, "on") == 0) { - delete_thread($dbc, $thread_id); + $thread = new Thread(); + $thread->get_from_database($thread_id, $dbc); + delete_thread($thread); header("Location: /"); exit(); |