-
Notifications
You must be signed in to change notification settings - Fork 10
/
bugs.php
244 lines (233 loc) · 12.4 KB
/
bugs.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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<?php
/**
* ------- U-232 Codename Trinity ----------*
* ---------------------------------------------*
* -------- @authors U-232 Team --------------*
* ---------------------------------------------*
* ----- @site https://u-232.duckdns.org/ ----*
* ---------------------------------------------*
* ----- @copyright 2020 U-232 Team ----------*
* ---------------------------------------------*
* ------------ @version V6 ------------------*
*/
require_once(__DIR__.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'bittorrent.php');
require_once(INCL_DIR.'user_functions.php');
require_once INCL_DIR.'pager_functions.php';
dbconn();
loggedinorreturn();
$HTMLOUT = "";
$lang = array_merge(load_language('global'), load_language('bugs'));
$possible_actions = [
'viewbug',
'bugs',
'add',
];
$action = (isset($_GET['action']) ? htmlsafechars($_GET['action']) : (isset($_POST['action']) ? htmlsafechars($_POST['action']) : ''));
if (!in_array($action, $possible_actions)) {
stderr('Error', 'A ruffian that will swear, drink, dance, revel the night, rob, murder and commit the oldest of ins the newest kind of ways.');
}
if ($action == 'viewbug') {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($CURUSER['class'] < UC_MAX) {
stderr("{$lang['stderr_error']}", "{$lang['stderr_only_coder']}");
}
$id = isset($_POST["id"]) ? (int)$_POST["id"] : '';
$status = isset($_POST["status"]) ? htmlsafechars($_POST["status"]) : '';
if ($status == 'na') {
stderr("{$lang['stderr_error']}", "{$lang['stderr_no_na']}");
}
if (!$id || !is_valid_id($id)) {
stderr("{$lang['stderr_error']}", "{$lang['stderr_invalid_id']}");
}
($query1 = sql_query("SELECT b.*, u.username, u.uploaded FROM bugs AS b LEFT JOIN users AS u ON b.sender = u.id WHERE b.id = ".sqlesc($id))) || sqlerr(__FILE__,
__LINE__);
while ($q1 = $query1->fetch_assoc()) {
switch ($status) {
case 'fixed':
$msg = sqlesc("Hello ".htmlsafechars($q1['username']).".\nYour bug: [b]".htmlsafechars($q1['title'])."[/b] has been treated by one of our coder, and is done.\n\nWe would to thank you and therefore we have added [b]2 GB[/b] to your upload total :].\n\nBest regards, {$TRINITY20['site_name']}'s coders.\n");
$uq = "UPDATE users SET uploaded = uploaded +". 1024 * 1024 * 1024 * 2 ." WHERE id = ".sqlesc($q1['sender'])."";
$update['uploaded'] = ($q1['uploaded'] + 1024 * 1024 * 1024 * 2);
$update['uploaded'] = ($q1['uploaded'] + 1024 * 1024 * 1024 * 2);
$cache->update_row($cache_keys['user_stats'].$q1['sender'], [
'uploaded' => $update['uploaded'],
], $TRINITY20['expires']['u_stats']);
$cache->update_row($cache_keys['user_statss'].$q1['sender'], [
'uploaded' => $update['uploaded'],
], $TRINITY20['expires']['user_stats']);
break;
case 'ignored':
$msg = sqlesc("Hello ".htmlsafechars($q1['username']).".\nYour bug: [b]".htmlsafechars($q1['title'])."[/b] has been ignored by one of our coder.\n\nPossibly it was not a bug.\n\nBest regards, {$TRINITY20['site_name']}'s coders.\n");
$uq = "";
break;
}
sql_query($uq);
sql_query("INSERT INTO messages (sender, receiver, added, msg) VALUES (0, ".sqlesc($q1['sender']).", ".TIME_NOW.", {$msg})");
sql_query("UPDATE bugs SET status=".sqlesc($status).", staff=".sqlesc($CURUSER['id'])." WHERE id = ".sqlesc($id));
$cache->delete($cache_keys['inbox_new'].$q1['sender']);
$cache->delete($cache_keys['inbox_new_sb'].$q1['sender']);
$cache->delete($cache_keys['bug_message']);
}
header("location: bugs.php?action=viewbug&id={$id}");
}
$id = isset($_GET["id"]) ? (int)$_GET["id"] : '';
if (!$id || !is_valid_id($id)) {
stderr("{$lang['stderr_error']}", "{$lang['stderr_invalid_id']}");
}
if ($CURUSER['class'] < UC_STAFF) {
stderr("{$lang['stderr_error']}", 'Only staff can view bugs.');
}
($as = sql_query("SELECT b.*, u.username, u.class, staff.username AS st, staff.class AS stclass FROM bugs AS b LEFT JOIN users AS u ON b.sender = u.id LEFT JOIN users AS staff ON b.staff = staff.id WHERE b.id =".sqlesc($id))) || sqlerr(__FILE__,
__LINE__);
while ($a = $as->fetch_assoc()) {
$title = htmlsafechars($a['title']);
$added = get_date($a['added'], '', 0, 1);
$addedby = "<a href='userdetails.php?id=".(int)$a['sender']."'>".htmlsafechars($a['username'])."</a> <i>(".get_user_class_name($a['class']).")</i>";
switch ($a['priority']) {
case 'low':
$priority = "<font color='green'>{$lang['low']}</font>";
break;
case 'high':
$priority = "<font color='red'>{$lang['high']}</font>";
break;
case 'veryhigh':
$priority = "<font color='red'><b><u>{$lang['veryhigh']}</u></b></font>";
break;
}
$problem = htmlsafechars($a['problem']);
switch ($a['status']) {
case 'fixed':
$status = "<font color='green'><b>{$lang['fixed']}</b></font>";
break;
case 'ignored':
$status = "<font color='#FF8C00'><b>{$lang['ignored']}</b></font>";
break;
default:
$status = "<select name='status'>
<option value='na'>{$lang['select_one']}</option>
<option value='fixed'>{$lang['fix_problem']}</option>
<option value='ignored'>{$lang['ignore_problem']}</option>
</select>";
}
switch ($a['staff']) {
case 0:
$by = "";
break;
default:
$by = "<a href='userdetails.php?id=".(int)$a['staff']."'>".htmlsafechars($a['st'])."</a> <i>(".get_user_class_name($a['stclass']).")</i>";
break;
}
$HTMLOUT .= "<form method='post' action='{$_SERVER["PHP_SELF"]}?action=viewbug'>
<input type='hidden' name='id' value='".(int)$a['id']."'/>
<table class='table table-bordered'>
<tr><td>{$lang['title']}:</td><td>{$title}</td></tr>
<tr><td>{$lang['added']} / {$lang['by']}</td><td>{$added} / {$addedby}</td></tr>
<tr><td>{$lang['priority']}</td><td>".$priority."</td></tr>
<tr><td>{$lang['problem_bug']}</td><td><textarea class='form-control' rows='10' readonly='readonly'>{$problem}</textarea></td></tr>
<tr><td>{$lang['status']} / {$lang['by']}</td><td>{$status} - {$by}</td></tr>";
if ($a['status'] == 'na') {
$HTMLOUT .= "<tr><td colspan='2' align='center'><input type='submit' value='{$lang['submit_btn_fix']}' class='btn'/></td></tr>\n";
}
}
$HTMLOUT .= "</table></form><a href='bugs.php?action=bugs'>{$lang['go_back']}</a>\n";
} elseif ($action == 'bugs') {
if ($CURUSER['class'] < UC_STAFF) {
stderr("{$lang['stderr_error']}", "{$lang['stderr_only_staff_can_view']}");
}
$search_count = sql_query("SELECT COUNT(id) FROM bugs");
$row = $search_count->fetch_array(MYSQLI_BOTH);
$count = $row[0];
$perpage = 10;
$pager = pager($perpage, $count, 'bugs.php?action=bugs&');
($res = sql_query("SELECT b.*, u.username, staff.username AS staffusername FROM bugs AS b LEFT JOIN users AS u ON b.sender = u.id LEFT JOIN users AS staff ON b.staff = staff.id ORDER BY b.id DESC {$pager['limit']}")) || sqlerr(__FILE__,
__LINE__);
$r = sql_query("SELECT * FROM bugs WHERE status = 'na'");
if ($res->num_rows > 0) {
$count = $r->num_rows;
$HTMLOUT .= $pager['pagertop'];
$HTMLOUT .= "
<h1 align='center'>".sprintf($lang['h1_count_bugs'], $count, ($count > 1 ? "s" : ""))."</h1>
<h4 class='text-center'>{$lang['delete_when']}</h4><br>
<table class='table table-bordered'><tr>
<td class='text-center'>{$lang['title']}</td>
<td class='text-center'>{$lang['added']} / {$lang['by']}</td>
<td class='text-center'>{$lang['priority']}</td>
<td class='text-center'>{$lang['status']}</td>
<td class='text-center'>{$lang['coder']}</td>
</tr>";
while ($q1 = $res->fetch_assoc()) {
switch ($q1['priority']) {
case 'low':
$priority = "<font color='green'>{$lang['low']}</font>";
break;
case 'high':
$priority = "<font color='red'>{$lang['high']}</font>";
break;
case 'veryhigh':
$priority = "<font color='red'><b><u>{$lang['veryhigh']}</u></b></font>";
break;
}
switch ($q1['status']) {
case 'fixed':
$status = "<font color='green'><b>{$lang['fixed']}</b></font>";
break;
case 'ignored':
$status = "<font color='#FF8C00'><b>{$lang['ignored']}</b></font>";
break;
default:
$status = "<font color='black'><b>N/A</b></font>";
break;
}
$HTMLOUT .= "<tr>
<td class='text-center'><a href='?action=viewbug&id=".(int)$q1['id']."'>".htmlsafechars($q1['title'])."</a></td>
<td class='text-center' nowrap='nowrap'>".get_date($q1['added'],
'TINY')." / <a href='userdetails.php?id=".(int)$q1['sender']."'>".htmlsafechars($q1['username'])."</a></td>
<td class='text-center'>{$priority}</td>
<td class='text-center'>{$status}</td>
<td class='text-center'>".($q1['status'] != 'na' ? "<a href='userdetails.php?id=".(int)$q1['staff']."'>".htmlsafechars($q1['staffusername'])."</a>" : "---")."</td>
</tr>";
}
$HTMLOUT .= "</table>";
$HTMLOUT .= $pager['pagerbottom']."<br>";
} else {
$HTMLOUT .= "<div class='row'><div class='col-md-8 col-md-offset-2 text-center panel panel-default'>".stdmsg("w00t",
"{$lang['no_bugs']}")."</div></div><br>";
}
} elseif ($action == 'add') {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$title = htmlsafechars($_POST['title']);
$priority = htmlsafechars($_POST['priority']);
$problem = htmlsafechars($_POST['problem']);
if (empty($title) || empty($priority) || empty($problem)) {
stderr("{$lang['stderr_error']}", "{$lang['stderr_missing']}");
}
if (strlen($problem) < 20) {
stderr("{$lang['stderr_error']}", "{$lang['stderr_problem_20']}");
}
if (strlen($title) < 10) {
stderr("{$lang['stderr_error']}", "{$lang['stderr_title_10']}");
}
($q1 = sql_query("INSERT INTO bugs (title, priority, problem, sender, added) VALUES (".sqlesc($title).", ".sqlesc($priority).", ".sqlesc($problem).", ".sqlesc($CURUSER['id']).", ".TIME_NOW.")")) || sqlerr(__FILE__,
__LINE__);
$cache->delete($cache_keys['bug_message']);
if ($q1) {
stderr("{$lang['stderr_sucess']}", sprintf($lang['stderr_sucess_2'], $priority));
} else {
stderr("{$lang['stderr_error']}", "{$lang['stderr_something_is_wrong']}");
}
}
$HTMLOUT .= "<form method='post' action='bugs.php?action=add'>
<table class='table table-bordered'>
<tr><td>{$lang['title']}:</td><td><input type='text' name='title' size='160'/><br/>{$lang['proper_title']}</td></tr>
<tr><td>{$lang['problem_bug']}:</td><td><textarea class='form-control'rows='10' name='problem'></textarea><br/>{$lang['describe_problem']}</td></tr>
<tr><td>{$lang['priority']}:</td><td><select name='priority'>
<option value='0'>{$lang['select_one']}</option>
<option value='low'>{$lang['low']}</option>
<option value='high'>{$lang['high']}</option>
<option value='veryhigh'>{$lang['veryhigh']}</option>
</select>
<br/>{$lang['only_veryhigh_when']}</td></tr>
<tr><td colspan='2'class='text-center'><input type='submit' value='{$lang['submit_btn_send']}' class='btn'/></td></tr>
</table></form>";
}
echo stdhead("{$lang['header']}").$HTMLOUT.stdfoot();
?>