-
Notifications
You must be signed in to change notification settings - Fork 0
/
data-modify.php
66 lines (53 loc) · 1.52 KB
/
data-modify.php
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
62
63
64
65
66
<!-- head less page -->
<?php
// header file
require('./templates/header.php');
// prevent direct page response
if (empty($_POST))
{
header("location: 404.php");
}
$token = $_POST['token'];
if ($token != $_SESSION['token'])
{
// possible csrf
header("location: 403.php");
}
// type of change to be done
$action = $_POST['action'];
// id of post to modify
$id = $_POST['id'];
// reported quizzes modification
if ($action == "approve" || $action == "remove")
{
if ($action == "approve")
{
// set quiz visibility to public
$sql = "UPDATE quizzes SET visibility = 1 WHERE id='$id'";
mysqli_query($conn, $sql);
}
else
{
// delete meta data
$sql = "DELETE FROM quizzes WHERE id='$id'";
mysqli_query($conn, $sql);
// delete content
$sql = "DELETE FROM quiz_contents WHERE id='$id'";
mysqli_query($conn, $sql);
}
}
// feedback modification
if ($action == "read_feedback")
{
// mark feedback as read
$sql = "UPDATE feedback SET feedback_read = 1 WHERE id = '$id'";
mysqli_query($conn, $sql);
}
// solved a problem in site
if ($action == "solved_problem")
{
// mark feedback as read
$sql = "UPDATE reported_problems SET status = 0 WHERE id = '$id'";
mysqli_query($conn, $sql);
}
?>