summaryrefslogtreecommitdiff
path: root/moderate.php
diff options
context:
space:
mode:
authorcflip <36554078+cflip@users.noreply.github.com>2021-04-12 09:56:22 -0600
committercflip <36554078+cflip@users.noreply.github.com>2021-04-12 09:56:22 -0600
commit424622fbdbe7065cb5b93b39d6cfc5ba0a31775e (patch)
tree4c436c21340618453e751e05ddf5ef7c0ed524fc /moderate.php
parent10280968b8b45fe130bc50e2ede4ce3cabfe1e58 (diff)
Begin post moderation, add delete feature
Diffstat (limited to 'moderate.php')
-rw-r--r--moderate.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/moderate.php b/moderate.php
new file mode 100644
index 0000000..afeefa1
--- /dev/null
+++ b/moderate.php
@@ -0,0 +1,33 @@
+<?php
+
+include_once 'includes/db_inc.php';
+include_once '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'])) {
+ $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) {
+ if (strcasecmp($delete, "on") == 0) {
+ delete_thread($dbc, $thread_id);
+
+ header("Location: /");
+ exit();
+ }
+ }
+
+ header("Location: viewthread.php?id=$thread_id");
+ exit();
+}
+
+header("Location: /"); \ No newline at end of file