-
Notifications
You must be signed in to change notification settings - Fork 28
/
bugs.php
222 lines (212 loc) · 12.9 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
<?php
/**
|--------------------------------------------------------------------------|
| https://github.com/Bigjoos/ |
|--------------------------------------------------------------------------|
| Licence Info: GPL |
|--------------------------------------------------------------------------|
| Copyright (C) 2010 U-232 V4 |
|--------------------------------------------------------------------------|
| A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon. |
|--------------------------------------------------------------------------|
| Project Leaders: Mindless,putyn. |
|--------------------------------------------------------------------------|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
( U | - | 2 | 3 | 2 )-( S | o | u | r | c | e )-( C | o | d | e )
\_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
*/
require_once (dirname(__FILE__) . 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 = array(
'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)) or sqlerr(__FILE__, __LINE__);
while ($q1 = mysqli_fetch_assoc($query1)) {
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, {$INSTALLER09['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);
$mc1->begin_transaction('userstats_' . $q1['sender']);
$mc1->update_row(false, array(
'uploaded' => $update['uploaded']
));
$mc1->commit_transaction($INSTALLER09['expires']['u_stats']);
$mc1->begin_transaction('user_stats_' . $q1['sender']);
$mc1->update_row(false, array(
'uploaded' => $update['uploaded']
));
$mc1->commit_transaction($INSTALLER09['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, {$INSTALLER09['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));
$mc1->delete_value('inbox_new_' . $q1['sender']);
$mc1->delete_value('inbox_new_sb_' . $q1['sender']);
$mc1->delete_value('bug_mess_');
}
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)) or sqlerr(__FILE__, __LINE__);
while ($a = mysqli_fetch_assoc($as)) {
$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 cellpadding='5' cellspacing='0' border='0' align='center'>
<tr><td class='rowhead'>{$lang['title']}:</td><td>{$title}</td></tr>
<tr><td class='rowhead'>{$lang['added']} / {$lang['by']}</td><td>{$added} / {$addedby}</td></tr>
<tr><td class='rowhead'>{$lang['priority']}</td><td>" . $priority . "</td></tr>
<tr><td class='rowhead'>{$lang['problem_bug']}</td><td><textarea cols='60' rows='10' readonly='readonly'>{$problem}</textarea></td></tr>
<tr><td class='rowhead'>{$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 = mysqli_fetch_array($search_count);
$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']}") or sqlerr(__FILE__, __LINE__);
$r = sql_query("SELECT * FROM bugs WHERE status = 'na'");
if (mysqli_num_rows($res) > 0) {
$count = mysqli_num_rows($r);
$HTMLOUT.= $pager['pagertop'];
$HTMLOUT.= "
<!--<h1 align='center'>There is <font color='#FF0000'>{$count}</font> new bug" . ($count > 1 ? "s" : "") . ". Please check them.</h1>-->
<h1 align='center'>" . sprintf($lang['h1_count_bugs'], $count, ($count > 1 ? "s" : "")) . "</h1>
<font class='small' style='font-weight:bold;'>{$lang['delete_when']}</font><br/>
<table cellpadding='10' cellspacing='0' border='0' align='center'><tr>
<td class='colhead' align='center'>{$lang['title']}</td>
<td class='colhead' align='center'>{$lang['added']} / {$lang['by']}</td>
<td class='colhead' align='center'>{$lang['priority']}</td>
<td class='colhead' align='center'>{$lang['status']}</td>
<td class='colhead' align='center'>{$lang['coder']}</td>
</tr>";
while ($q1 = mysqli_fetch_assoc($res)) {
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 align='center'><a href='?action=viewbug&id=" . (int)$q1['id'] . "'>" . htmlsafechars($q1['title']) . "</a></td>
<td align='center' nowrap='nowrap'>" . get_date($q1['added'], 'TINY') . " / <a href='userdetails.php?id=" . (int)$q1['sender'] . "'>" . htmlsafechars($q1['username']) . "</a></td>
<td align='center'>{$priority}</td>
<td align='center'>{$status}</td>
<td align='center'>" . ($q1['status'] != 'na' ? "<a href='userdetails.php?id=" . (int)$q1['staff'] . "'>" . htmlsafechars($q1['staffusername']) . "</a>" : "---") . "</td>
</tr>";
}
$HTMLOUT.= "</table>";
$HTMLOUT.= $pager['pagerbottom'];
} else $HTMLOUT.= stdmsg("w00t", "{$lang['no_bugs']}");
} 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 . ")") or sqlerr(__FILE__, __LINE__);
$mc1->delete_value('bug_mess_');
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 cellpadding='5' cellspacing='0' border='0' align='center'>
<tr><td class='rowhead'>{$lang['title']}:</td><td><input type='text' name='title' size='60'/><br/>{$lang['proper_title']}</td></tr>
<tr><td class='rowhead'>{$lang['problem_bug']}:</td><td><textarea cols='60' rows='10' name='problem'></textarea><br/>{$lang['describe_problem']}</td></tr>
<tr><td class='rowhead'>{$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' align='center'><input type='submit' value='{$lang['submit_btn_send']}' class='btn'/></td></tr>
</table></form>";
}
echo stdhead("{$lang['header']}") . $HTMLOUT . stdfoot();
?>