This repository was archived by the owner on Aug 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
61 lines (54 loc) · 1.8 KB
/
delete.php
File metadata and controls
61 lines (54 loc) · 1.8 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
include 'include/header.php';
?>
<div class="container mt-3">
<?php
if ($_GET) {
$forum_id = $_GET['forum'];
$category_id = $_GET['category'];
$topic_id = $_GET['topic'];
$post_id = $_GET['post'];
$forum = $database->prepare("SELECT * FROM forums WHERE id = ?;");
$forum->execute(array($forum_id));
$category = $database->prepare("SELECT * FROM categories WHERE id = ?;");
$category->execute(array($category_id));
$topic = $database->prepare("SELECT * FROM topics WHERE id = ?;");
$topic->execute(array($topic_id));
$post = $database->prepare("SELECT * FROM posts WHERE id = ?;");
$post->execute(array($post_id));
$error = '';
if (empty($forum_id) || empty($category_id) || empty($post_id) || empty($topic_id)) {
$error = 'Podane forum, kategoria, temat lub post nie istnieje!';
} else if ($forum->rowCount() <= 0) {
$error = 'Podane forum nie istnieje!';
} else if ($category->rowCount() <= 0) {
$error = 'Podana kategoria nie istnieje!';
} else if ($post->rowCount() <= 0) {
$error = 'Podany post nie istnieje!';
} else if ($topic->rowCount() <= 0) {
$error = 'Podany temat nie istnieje!';
}
if (empty($error)) {
if (USER_ID) {
if (empty($post_error)) {
$edit_post = $database->prepare("DELETE FROM posts WHERE id = ?;");
$edit_post->execute(array($post_id));
alert('success', 'Post został usunięty.');
header("refresh:2;url={$config['default']['link']}topic.php?forum=$forum_id&category=$category_id&topic=$topic_id");
} else {
alert('danger', $post_error);
}
} else {
alert("danger", "Musisz być zalogowany aby usunąć post!");
}
} else {
alert('danger', $error);
}
} else {
alert("danger", "Podane forum, kategoria, temat lub post nie istnieje!");
}
?>
</div>
<?php
include 'include/footer.php';
?>