2011-03-28 14:21:28 +00:00
|
|
|
<?
|
|
|
|
authorize();
|
|
|
|
|
2013-05-01 08:00:16 +00:00
|
|
|
if (empty($_POST['id']) || !is_number($_POST['id']) || empty($_POST['type']) || ($_POST['type'] != 'request_update' && empty($_POST['reason']))) {
|
2011-03-28 14:21:28 +00:00
|
|
|
error(404);
|
|
|
|
}
|
|
|
|
|
|
|
|
include(SERVER_ROOT.'/sections/reports/array.php');
|
|
|
|
|
2013-05-01 08:00:16 +00:00
|
|
|
if (!array_key_exists($_POST['type'], $Types)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
error(403);
|
|
|
|
}
|
|
|
|
$Short = $_POST['type'];
|
2013-02-22 08:00:24 +00:00
|
|
|
$Type = $Types[$Short];
|
2011-03-28 14:21:28 +00:00
|
|
|
$ID = $_POST['id'];
|
2013-05-15 08:00:54 +00:00
|
|
|
if ($Short == 'request_update') {
|
2013-05-01 08:00:16 +00:00
|
|
|
if (empty($_POST['year']) || !is_number($_POST['year'])) {
|
2011-03-28 14:21:28 +00:00
|
|
|
error('Year must be specified.');
|
2013-07-04 08:00:56 +00:00
|
|
|
header("Location: reports.php?action=report&type=request_update&id=$ID");
|
2011-03-28 14:21:28 +00:00
|
|
|
die();
|
|
|
|
}
|
2013-05-30 08:00:30 +00:00
|
|
|
$Reason = '[b]Year[/b]: '.$_POST['year'].".\n\n";
|
2012-10-02 08:00:20 +00:00
|
|
|
// If the release type is somehow invalid, return "Not given"; otherwise, return the release type.
|
2013-05-15 08:00:54 +00:00
|
|
|
$Reason .= '[b]Release type[/b]: '.((empty($_POST['releasetype']) || !is_number($_POST['releasetype']) || $_POST['releasetype'] == 0) ? 'Not given' : $ReleaseTypes[$_POST['releasetype']]).". \n\n";
|
|
|
|
$Reason .= '[b]Additional comments[/b]: '.$_POST['comment'];
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
|
|
|
$Reason = $_POST['reason'];
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:00:16 +00:00
|
|
|
switch ($Short) {
|
2013-07-04 08:00:56 +00:00
|
|
|
case 'request':
|
|
|
|
case 'request_update':
|
|
|
|
$Link = "requests.php?action=view&id=$ID";
|
2011-03-28 14:21:28 +00:00
|
|
|
break;
|
2013-07-04 08:00:56 +00:00
|
|
|
case 'user':
|
|
|
|
$Link = "user.php?id=$ID";
|
2011-03-28 14:21:28 +00:00
|
|
|
break;
|
2013-07-04 08:00:56 +00:00
|
|
|
case 'collage':
|
|
|
|
$Link = "collages.php?id=$ID";
|
2011-03-28 14:21:28 +00:00
|
|
|
break;
|
2013-07-04 08:00:56 +00:00
|
|
|
case 'thread':
|
|
|
|
$Link = "forums.php?action=viewthread&threadid=$ID";
|
2011-03-28 14:21:28 +00:00
|
|
|
break;
|
2013-07-04 08:00:56 +00:00
|
|
|
case 'post':
|
2013-05-15 08:00:54 +00:00
|
|
|
$DB->query("
|
|
|
|
SELECT
|
|
|
|
p.ID,
|
|
|
|
p.TopicID,
|
|
|
|
( SELECT COUNT(ID)
|
|
|
|
FROM forums_posts
|
|
|
|
WHERE forums_posts.TopicID = p.TopicID
|
2013-07-04 08:00:56 +00:00
|
|
|
AND forums_posts.ID <= p.ID
|
2013-05-15 08:00:54 +00:00
|
|
|
) AS PostNum
|
|
|
|
FROM forums_posts AS p
|
2013-07-04 08:00:56 +00:00
|
|
|
WHERE ID = $ID");
|
|
|
|
list($PostID, $TopicID, $PostNum) = $DB->next_record();
|
|
|
|
$Link = "forums.php?action=viewthread&threadid=$TopicID&post=$PostNum#post$PostID";
|
2011-03-28 14:21:28 +00:00
|
|
|
break;
|
2013-07-04 08:00:56 +00:00
|
|
|
case 'requests_comment':
|
2013-05-15 08:00:54 +00:00
|
|
|
$DB->query("
|
|
|
|
SELECT
|
|
|
|
rc.RequestID,
|
|
|
|
rc.Body,
|
|
|
|
( SELECT COUNT(ID)
|
|
|
|
FROM requests_comments
|
|
|
|
WHERE ID <= $ID
|
|
|
|
AND requests_comments.RequestID = rc.RequestID
|
|
|
|
) AS CommentNum
|
|
|
|
FROM requests_comments AS rc
|
2013-07-04 08:00:56 +00:00
|
|
|
WHERE ID = $ID");
|
2011-03-28 14:21:28 +00:00
|
|
|
list($RequestID, $Body, $PostNum) = $DB->next_record();
|
|
|
|
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
|
2013-07-04 08:00:56 +00:00
|
|
|
$Link = "requests.php?action=view&id=$RequestID&page=$PageNum#post$ID";
|
2011-03-28 14:21:28 +00:00
|
|
|
break;
|
2013-07-04 08:00:56 +00:00
|
|
|
case 'torrents_comment':
|
2013-05-15 08:00:54 +00:00
|
|
|
$DB->query("
|
|
|
|
SELECT
|
|
|
|
tc.GroupID,
|
|
|
|
tc.Body,
|
|
|
|
( SELECT COUNT(ID)
|
|
|
|
FROM torrents_comments
|
|
|
|
WHERE ID <= $ID
|
|
|
|
AND torrents_comments.GroupID = tc.GroupID
|
|
|
|
) AS CommentNum
|
|
|
|
FROM torrents_comments AS tc
|
2013-07-04 08:00:56 +00:00
|
|
|
WHERE ID = $ID");
|
2011-03-28 14:21:28 +00:00
|
|
|
list($GroupID, $Body, $PostNum) = $DB->next_record();
|
|
|
|
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
|
2013-07-04 08:00:56 +00:00
|
|
|
$Link = "torrents.php?id=$GroupID&page=$PageNum#post$ID";
|
2011-03-28 14:21:28 +00:00
|
|
|
break;
|
2013-07-04 08:00:56 +00:00
|
|
|
case 'artist_comment':
|
2013-05-15 08:00:54 +00:00
|
|
|
$DB->query("
|
|
|
|
SELECT
|
|
|
|
ac.ArtistID,
|
|
|
|
ac.Body,
|
|
|
|
( SELECT COUNT(ID)
|
|
|
|
FROM artist_comments
|
|
|
|
WHERE ID <= $ID
|
|
|
|
AND artist_comments.ArtistID = ac.ArtistID
|
|
|
|
) AS CommentNum
|
|
|
|
FROM artist_comments AS ac
|
2013-07-04 08:00:56 +00:00
|
|
|
WHERE ID = $ID");
|
2012-10-29 08:00:20 +00:00
|
|
|
list($ArtistID, $Body, $PostNum) = $DB->next_record();
|
|
|
|
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
|
2013-07-04 08:00:56 +00:00
|
|
|
$Link = "artist.php?id=$ArtistID&page=$PageNum#post$ID";
|
2012-10-29 08:00:20 +00:00
|
|
|
break;
|
2013-07-04 08:00:56 +00:00
|
|
|
case 'collages_comment':
|
2013-05-15 08:00:54 +00:00
|
|
|
$DB->query("
|
|
|
|
SELECT
|
|
|
|
cc.CollageID,
|
|
|
|
cc.Body,
|
|
|
|
( SELECT COUNT(ID)
|
|
|
|
FROM collages_comments
|
|
|
|
WHERE ID <= $ID
|
|
|
|
AND collages_comments.CollageID = cc.CollageID
|
|
|
|
) AS CommentNum
|
|
|
|
FROM collages_comments AS cc
|
2013-07-04 08:00:56 +00:00
|
|
|
WHERE ID = $ID");
|
2011-03-28 14:21:28 +00:00
|
|
|
list($CollageID, $Body, $PostNum) = $DB->next_record();
|
|
|
|
$PerPage = POSTS_PER_PAGE;
|
|
|
|
$PageNum = ceil($PostNum / $PerPage);
|
2013-07-04 08:00:56 +00:00
|
|
|
$Link = "collage.php?action=comments&collageid=$CollageID&page=$PageNum#post$ID";
|
2011-03-28 14:21:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-05-15 08:00:54 +00:00
|
|
|
$DB->query('
|
|
|
|
INSERT INTO reports
|
|
|
|
(UserID, ThingID, Type, ReportedTime, Reason)
|
|
|
|
VALUES
|
|
|
|
('.db_string($LoggedUser['ID']).", $ID , '$Short', '".sqltime()."', '".db_string($Reason)."')");
|
2011-03-28 14:21:28 +00:00
|
|
|
$ReportID = $DB->inserted_id();
|
|
|
|
|
2011-06-30 08:00:06 +00:00
|
|
|
$Channels = array();
|
2011-03-28 14:21:28 +00:00
|
|
|
|
2013-05-15 08:00:54 +00:00
|
|
|
if ($Short == 'request_update') {
|
|
|
|
$Channels[] = '#requestedits';
|
2011-03-28 14:21:28 +00:00
|
|
|
$Cache->increment('num_update_reports');
|
|
|
|
}
|
2013-05-04 08:00:48 +00:00
|
|
|
if (in_array($Short, array('collages_comment', 'post', 'requests_comment', 'thread', 'torrents_comment'))) {
|
2013-05-15 08:00:54 +00:00
|
|
|
$Channels[] = '#forumreports';
|
|
|
|
|
2011-06-30 08:00:06 +00:00
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
|
2013-05-06 08:00:32 +00:00
|
|
|
foreach ($Channels as $Channel) {
|
2013-05-15 08:00:54 +00:00
|
|
|
send_irc("PRIVMSG $Channel :$ReportID - ".$LoggedUser['Username']." just reported a $Short: https://".SSL_SITE_URL."/$Link : ".strtr($Reason, "\n", ' '));
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$Cache->delete_value('num_other_reports');
|
|
|
|
|
2013-07-04 08:00:56 +00:00
|
|
|
header("Location: $Link");
|
2011-03-28 14:21:28 +00:00
|
|
|
?>
|