blob: fe838558251d320a10d741bf3046fc7e9b0daecc (
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
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
<?php
include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/accounts.php";
include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/config.php";
include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/partials.php";
include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/utils.php";
include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/alert.php";
if (!CONFIG['reports']['enable']) {
generate_alert("/404.php", "Reports are disabled", 403);
exit;
}
if (!authorize_user(true)) {
exit;
}
if (isset($_SESSION["user_role"]) && !$_SESSION["user_role"]["permission_report"]) {
generate_alert("/404.php", "Not enough permissions", 403);
exit;
}
$db = new PDO(CONFIG['database']['url'], CONFIG['database']['user'], CONFIG['database']['pass']);
$report = null;
$report_id = $_GET["id"] ?? "";
if ($report_id != "") {
$stmt = $db->prepare("SELECT * FROM reports WHERE id = ? AND sender_id = ?");
$stmt->execute([$report_id, $_SESSION["user_id"]]);
if ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$report = $row;
if (CLIENT_REQUIRES_JSON) {
json_response([
"status_code" => 201,
"message" => null,
"data" => $report
], 201);
exit;
}
} else {
generate_alert("/report", "Report ID #" . $_GET["id"] . " not found or not accessable");
exit;
}
}
$contents = "";
if ($contents == "") {
if (isset($_GET["user_id"])) {
$contents = "Hi! I want to report user ID #" . $_GET["user_id"] . " because...";
} else if (isset($_GET["emote_id"])) {
$contents = "Hi! I want to report emote ID #" . $_GET["emote_id"] . " because...";
}
}
?>
<html>
<head>
<title>
<?php echo ($report == null ? "Send a message to MODS" : "A message to MODS") . ' - ' . CONFIG['instance']['name'] ?>
</title>
<link rel="stylesheet" href="/static/style.css">
<link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon">
</head>
<body>
<div class="container">
<div class="wrapper">
<?php html_navigation_bar() ?>
<section class="content" style="width: 25%;">
<?php display_alert() ?>
<section class="box">
<div class="box navtab">
<?php echo $report == null ? "Send a message to MODS" : "A message to MODS" ?>
</div>
<?php if ($report == null) {
echo '' ?>
<div class="box content">
<form action="/report/send.php" method="POST">
<textarea name="contents" style="resize: none;height:250px;" autofocus
required><?php echo $contents; ?></textarea>
<button type="submit">Send</button>
</form>
</div> <?php ;
} else {
echo '' ?>
<div class="box content">
<textarea name="contents" style="resize: none;height:250px;"
disabled><?php echo $report["contents"]; ?></textarea>
</div>
</section>
<section class="box">
<p>Reported <?php echo format_timestamp(time() - strtotime($report["sent_at"])) ?> ago</p>
<p>Status:
<?php echo $report["resolved_by"] == null ? "<b style='color:red;'>Unresolved</b>" : "<b style='color:green;'>Resolved</b>" ?>
</p>
</section>
<?php
if ($report["response_message"]) {
?>
<section class="box">
<div class="box navtab">
Response from MOD
</div>
<div class="box content">
<textarea name="contents" style="resize: none;height:250px;"
disabled><?php echo $report["response_message"]; ?></textarea>
</div>
</section>
<?php
}
?>
<?php ;
}
?>
</section>
</section>
</div>
</div>
</body>
</html>
|