summaryrefslogtreecommitdiff
path: root/moderate.php
blob: 68bf1b9c62c9a67292917b14cee4be73d18d6b8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
include_once './includes/functions_thread.php';
include_once './includes/Session.php';
include_once './includes/model/User.php';

session_start();

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 = Session::get()->get_current_user();

	if ($user->level == USER_LEVEL_MODERATOR) {
		if (strcasecmp($delete, "on") == 0) {
			$thread = new Thread();
			$thread->get_from_database($thread_id);
			delete_thread($thread);

			header("Location: /");
			exit();
		}
	}

	header("Location: viewthread.php?id=$thread_id");
	exit();
}

header("Location: /");