Gazelle/sections/reports/takereport.php

90 lines
2.5 KiB
PHP
Raw Normal View History

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-08-28 23:08:41 +00:00
case 'comment':
$Link = "comments.php?action=jump&postid=$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();
$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-08-28 23:08:41 +00:00
if (in_array($Short, array('comment', 'post', 'thread'))) {
2013-05-15 08:00:54 +00:00
$Channels[] = '#forumreports';
}
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
?>