-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathreport.php
206 lines (183 loc) · 11.7 KB
/
report.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
<?php
require_once("include/bittorrent.php");
dbconn();
require_once(get_langfile_path());
loggedinorreturn();
parked();
global $staffmem_class, $CURUSER;
$reportofferid = $_GET["reportofferid"];
$reportrequestid = $_GET["reportrequestid"];
$user = $_GET["user"];
$commentid = $_GET["commentid"];
$torrent = $_GET["torrent"];
$forumpost = $_GET["forumpost"];
$subtitle = $_GET["subtitle"];
$request = $_GET["request"];
$takeuser = $_POST["takeuser"];
$takecommentid = $_POST["takecommentid"];
$taketorrent = $_POST["taketorrent"];
$takeforumpost = $_POST["takeforumpost"];
$takereason = $_POST["reason"];
$takereportofferid = $_POST["takereportofferid"];
$takerequestid = $_POST["takerequestid"];
$takesubtitleid = $_POST["takesubtitleid"];
function takereport($reportid, $type, $reason)
{
global $CURUSER, $lang_report, $Cache;
int_check($reportid);
// Check if takereason is set
if ($reason == '') {
stderr($lang_report['std_error'], $lang_report['std_missing_reason']);
die();
}
$res = sql_query("SELECT id FROM reports WHERE addedby = " . sqlesc($CURUSER['id']) . " AND reportid= " . sqlesc($reportid) . " AND type = " . sqlesc($type)) or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) == 0) {
$date = sqlesc(date("Y-m-d H:i:s"));
sql_query("INSERT into reports (addedby,reportid,type,reason,added) VALUES (" . sqlesc($CURUSER['id']) . "," . sqlesc($reportid) . "," . sqlesc($type) . ", " . sqlesc(trim($reason)) . "," . $date . ")") or sqlerr(__FILE__, __LINE__);
$Cache->delete_value('staff_report_count');
$Cache->delete_value('staff_new_report_count');
stderr($lang_report['std_message'], $lang_report['std_successfully_reported']);
die();
} else {
stderr($lang_report['std_error'], $lang_report['std_already_reported_this']);
die();
}
}
//////////OFFER #1 START//////////
if (isset($takereportofferid) && isset($takereason)) {
takereport($takereportofferid, 'offer', $takereason);
}
//////////OFFER #1 END//////////
//////////REQUEST #1 START//////////
elseif ((isset($takerequestid)) && (isset($takereason))) {
takereport($takerequestid, 'request', $takereason);
}
//////////REQUEST #1 END//////////
//////////USER #1 START//////////
elseif ((isset($takeuser)) && (isset($takereason))) {
takereport($takeuser, 'user', $takereason);
}
//////////USER #1 END//////////
//////////TORRENT #1 START//////////
elseif ((isset($taketorrent)) && (isset($takereason))) {
takereport($taketorrent, 'torrent', $takereason);
}
//////////TORRENT #1 END//////////
//////////FORUM POST #1 START//////////
elseif ((isset($takeforumpost)) && (isset($takereason))) {
takereport($takeforumpost, 'post', $takereason);
}
//////////FORUM #1 END//////////
//////////COMMENT #1 START//////////
elseif ((isset($takecommentid)) && (isset($takereason))) {
takereport($takecommentid, 'comment', $takereason);
}
//////////COMMENT #1 END//////////
//////////SUBTITLE #1 START//////////
elseif ((isset($takesubtitleid)) && (isset($takereason))) {
takereport($takesubtitleid, 'subtitle', $takereason);
}
//////////SUBTITLE #1 END//////////
//////////USER #2 START//////////
elseif (isset($user)) {
int_check($user);
if ($user == $CURUSER['id']) {
stderr($lang_report['std_sorry'], $lang_report['std_cannot_report_oneself']);
die;
}
$res = sql_query("SELECT username, class FROM users WHERE id=" . sqlesc($user)) or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) == 0) {
stderr($lang_report['std_error'], $lang_report['std_invalid_user_id']);
die();
}
$arr = mysql_fetch_assoc($res);
if ($arr["class"] >= $staffmem_class) {
stderr($lang_report['std_sorry'], $lang_report['std_cannot_report'] . get_user_class_name($arr["class"], false, true, true), false);
die();
} else {
stderr($lang_report['std_are_you_sure'], $lang_report['text_are_you_sure_user'] . get_username(htmlspecialchars($user)) . $lang_report['text_to_staff'] . "<br />" . $lang_report['text_not_for_leechers'] . "<br />" . $lang_report['text_reason_note'] . "<br /><form method=post action=report.php><input type=hidden name=takeuser value=\"" . htmlspecialchars($user) . "\">" . $lang_report['text_reason_is'] . "<input type=text style=\"width: 200px\" name=reason><input type=submit value=\"" . $lang_report['submit_confirm'] . "\"></form>", false);
}
}
//////////USER #2 END//////////
//////////TORRENT #2 START//////////
elseif (isset($torrent)) {
int_check($torrent);
$res = sql_query("SELECT name FROM torrents WHERE id=" . sqlesc($torrent));
if (mysql_num_rows($res) == 0) {
stderr($lang_report['std_error'], $lang_report['std_invalid_torrent_id']);
die();
}
$arr = mysql_fetch_array($res);
stderr($lang_report['std_are_you_sure'], $lang_report['text_are_you_sure_torrent'] . "<a href=details.php?id=" . htmlspecialchars($torrent) . "><b>" . htmlspecialchars($arr['name']) . "</b></a>" . $lang_report['text_to_staff'] . "<br />" . $lang_report['text_reason_note'] . "<br /><form method=post action=report.php><input type=hidden name=taketorrent value=\"" . htmlspecialchars($torrent) . "\">" . $lang_report['text_reason_is'] . "<input type=text style=\"width: 200px\" name=reason><input type=submit value=\"" . $lang_report['submit_confirm'] . "\"></form>", false);
}
//////////TORRENT #2 END//////////
//////////FORUM POST #2 START//////////
elseif (isset($forumpost)) {
int_check($forumpost);
$res = sql_query("SELECT topics.id AS topicid, topics.subject AS subject, posts.userid AS postuserid FROM topics LEFT JOIN posts ON posts.topicid = topics.id WHERE posts.id=" . sqlesc($forumpost));
if (mysql_num_rows($res) == 0) {
stderr($lang_report['std_error'], $lang_report['std_invalid_post_id']);
}
$arr = mysql_fetch_array($res);
stderr($lang_report['std_are_you_sure'], $lang_report['text_are_you_sure_post'] . $forumpost . $lang_report['text_of_topic'] . "<a href=\"forums.php?action=viewtopic&topicid=" . $arr['topicid'] . "&page=p" . htmlspecialchars($forumpost) . "#" . htmlspecialchars($forumpost) . "\"><b>" . htmlspecialchars($arr['subject']) . "</b></a>" . $lang_report['text_by'] . get_username($arr['postuserid']) . $lang_report['text_to_staff'] . "<br />" . $lang_report['text_reason_note'] . "<br /><form method=post action=report.php><input type=hidden name=takeforumpost value=\"" . htmlspecialchars($forumpost) . "\">" . $lang_report['text_reason_is'] . "<input type=text style=\"width: 200px\" name=reason><input type=submit value=\"" . $lang_report['submit_confirm'] . "\"></form>", false);
}
//////////FORUM POST #2 END//////////
//////////COMMENT #2 START//////////
elseif (isset($commentid)) {
int_check($commentid);
$res = sql_query("SELECT id, user, torrent, request, offer FROM comments WHERE id=" . sqlesc($commentid));
if (mysql_num_rows($res) == 0) {
stderr($lang_report['std_error'], $lang_report['std_invalid_comment_id']);
}
$arr = mysql_fetch_array($res);
if ($arr['torrent']) { //Comment of torrent. BTW, this is shitty code!
$name = get_single_value("torrents", "name", "WHERE id=" . sqlesc($arr['torrent']));
$url = "details.php?id=" . $arr['torrent'] . "#" . $commentid;
$of = $lang_report['text_of_torrent'];
} elseif ($arr['offer']) { //Comment of offer
$name = get_single_value("offers", "name", "WHERE id=" . sqlesc($arr['offer']));
$url = "offers.php?id=" . $arr['offer'] . "&off_details=1#" . $commentid;
$of = $lang_report['text_of_offer'];
} elseif ($arr['request']) { //Comment of request
$name = get_single_value("req", "name", "WHERE id=" . sqlesc($arr['request']));
$url = "viewrequests.php?action=view&id=" . $arr['request'] . "&req_details=1#" . $commentid;
$of = $lang_report['text_of_request'];
} else //Comment belongs to no one
stderr($lang_report['std_error'], $lang_report['std_orphaned_comment']);
stderr($lang_report['std_are_you_sure'], $lang_report['text_are_you_sure_comment'] . $commentid . $of . "<a href=\"" . $url . "\"><b>" . htmlspecialchars($name) . "</b></a>" . $lang_report['text_by'] . get_username($arr['user']) . $lang_report['text_to_staff'] . "<br />" . $lang_report['text_reason_note'] . "<br /><form method=post action=report.php><input type=hidden name=takecommentid value=\"" . htmlspecialchars($commentid) . "\">" . $lang_report['text_reason_is'] . "<input type=text style=\"width: 200px\" name=reason><input type=submit value=\"" . $lang_report['submit_confirm'] . "\"></form>", false);
}
//////////COMMENT #2 END//////////
//////////OFFER #2 START//////////
elseif (isset($reportofferid)) {
int_check($reportofferid);
$res = sql_query("SELECT id,name FROM offers WHERE id=" . sqlesc($reportofferid));
if (mysql_num_rows($res) == 0) {
stderr($lang_report['std_error'], $lang_report['std_invalid_offer_id']);
}
$arr = mysql_fetch_array($res);
stderr($lang_report['std_are_you_sure'], $lang_report['text_are_you_sure_offer'] . "<a href=\"offers.php?id=" . $arr['id'] . "&off_details=1\"><b>" . htmlspecialchars($arr['name']) . "</b></a>" . $lang_report['text_to_staff'] . "<br />" . $lang_report['text_reason_note'] . "<br /><form method=post action=report.php><input type=hidden name=takereportofferid value=\"" . htmlspecialchars($reportofferid) . "\">" . $lang_report['text_reason_is'] . "<input type=text style=\"width: 200px\" name=reason><input type=submit value=\"" . $lang_report['submit_confirm'] . "\"></form>", false);
}
//////////OFFERT #2 END//////////
//////////REQUEST #2 START//////////
elseif (isset($reportrequestid)) {
int_check($reportrequestid);
$res = sql_query("SELECT id,name FROM req WHERE id=" . sqlesc($reportrequestid));
if (mysql_num_rows($res) == 0) {
stderr($lang_report['std_error'], $lang_report['std_invalid_request_id']);
}
$arr = mysql_fetch_array($res);
stderr($lang_report['std_are_you_sure'], $lang_report['std_are_you_sure_request'] . "<a href=\"viewrequests.php?action=view&id=" . $arr['id'] . "&req_details=1\"><b>" . htmlspecialchars($arr['name']) . "</b></a>" . $lang_report['text_to_staff'] . "<br />" . $lang_report['text_reason_note'] . "<br /><form method=post action=report.php><input type=hidden name=takerequestid value=\"" . htmlspecialchars($reportrequestid) . "\">" . $lang_report['text_reason_is'] . "<input type=text style=\"width: 200px\" name=reason id=reason ><input type=submit value=\"" . $lang_report['submit_confirm'] . "\"><br/><input type=radio id=\"expire\" value=\"" . $lang_report['text_expire'] . "\" onClick=getexpirevalue()>" . $lang_report['text_expire'] . "</form>", false);
}
//////////REQUEST #2 END//////////
//////////SUBTITLE #2 START//////////
elseif (isset($subtitle)) {
int_check($subtitle);
$res = sql_query("SELECT id, torrent_id, title FROM subs WHERE id=" . sqlesc($subtitle));
if (mysql_num_rows($res) == 0) {
stderr($lang_report['std_error'], $lang_report['std_invalid_subtitle_id']);
}
$arr = mysql_fetch_array($res);
stderr($lang_report['std_are_you_sure'], $lang_report['text_are_you_sure_subtitle'] . "<a href=\"downloadsubs.php?torrentid=" . $arr['torrent_id'] . "&subid=" . $arr['id'] . "\"><b>" . htmlspecialchars($arr['title']) . "</b></a>" . $lang_report['text_to_staff'] . "<br />" . $lang_report['text_reason_note'] . "<br /><form method=post action=report.php><input type=hidden name=takesubtitleid value=\"" . htmlspecialchars($subtitle) . "\">" . $lang_report['text_reason_is'] . "<input type=text style=\"width: 200px\" name=reason><input type=submit value=\"" . $lang_report['submit_confirm'] . "\"></form>", false);
} //////////SUBTITLE #2 END//////////
else // unknown action
stderr($lang_report['std_error'], $lang_report['std_invalid_action']);